Update parse SDK to 2.0.0 (#4925)

* WIP: Integrate JS SDK v2

- Removes backbone style callbacks
- Use Promise instead of Parse.Promise

* Fixes ParseObject and ParseRelation

* Updates Parse.Query with promises

* Alls tests should pass

* Ensure a fresh user is used for each test

* Use REST implementation to avoid side effects for username/email duplicates

* Uses js sdk v2
This commit is contained in:
Florent Vilmart
2018-08-05 13:58:07 -04:00
committed by GitHub
parent a61ef7ee2f
commit ff25ae254d
30 changed files with 3217 additions and 4783 deletions

View File

@@ -6,15 +6,15 @@ const Parse = require('parse/node');
function getSessionToken(options) {
if (options && typeof options.sessionToken === 'string') {
return Parse.Promise.as(options.sessionToken);
return Promise.resolve(options.sessionToken);
}
return Parse.Promise.as(null);
return Promise.resolve(null);
}
function getAuth(options = {}, config) {
const installationId = options.installationId || 'cloud';
if (options.useMasterKey) {
return Parse.Promise.as(new Auth.Auth({config, isMaster: true, installationId }));
return Promise.resolve(new Auth.Auth({config, isMaster: true, installationId }));
}
return getSessionToken(options).then((sessionToken) => {
if (sessionToken) {
@@ -25,7 +25,7 @@ function getAuth(options = {}, config) {
installationId
});
} else {
return Parse.Promise.as(new Auth.Auth({ config, installationId }));
return Promise.resolve(new Auth.Auth({ config, installationId }));
}
})
}
@@ -48,12 +48,12 @@ function ParseServerRESTController(applicationId, router) {
if (path === '/batch') {
const promises = data.requests.map((request) => {
return handleRequest(request.method, request.path, request.body, options).then((response) => {
return Parse.Promise.as({success: response});
return Promise.resolve({success: response});
}, (error) => {
return Parse.Promise.as({error: {code: error.code, error: error.message}});
return Promise.resolve({error: {code: error.code, error: error.message}});
});
});
return Parse.Promise.all(promises);
return Promise.all(promises);
}
let query;
@@ -61,7 +61,7 @@ function ParseServerRESTController(applicationId, router) {
query = data;
}
return new Parse.Promise((resolve, reject) => {
return new Promise((resolve, reject) => {
getAuth(options, config).then((auth) => {
const request = {
body: data,