parse 5.3.0-alpha.2 → 5.3.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/parse.js +625 -557
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +625 -555
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/CoreManager.js +1 -1
- package/lib/browser/FacebookUtils.js +1 -1
- package/lib/browser/LocalDatastoreController.react-native.js +1 -1
- package/lib/browser/OfflineQuery.js +5 -9
- package/lib/browser/Parse.js +1 -3
- package/lib/browser/ParseConfig.js +1 -1
- package/lib/browser/ParseFile.js +0 -1
- package/lib/browser/ParseObject.js +54 -19
- package/lib/browser/ParseQuery.js +1 -1
- package/lib/browser/ParseUser.js +1 -1
- package/lib/browser/RESTController.js +2 -2
- package/lib/browser/StorageController.weapp.js +1 -1
- package/lib/node/CoreManager.js +1 -1
- package/lib/node/FacebookUtils.js +1 -1
- package/lib/node/LocalDatastoreController.react-native.js +1 -1
- package/lib/node/OfflineQuery.js +5 -9
- package/lib/node/Parse.js +1 -1
- package/lib/node/ParseConfig.js +1 -1
- package/lib/node/ParseFile.js +0 -1
- package/lib/node/ParseObject.js +53 -19
- package/lib/node/ParseQuery.js +1 -1
- package/lib/node/ParseUser.js +1 -1
- package/lib/node/RESTController.js +2 -2
- package/lib/node/StorageController.weapp.js +1 -1
- package/lib/react-native/CoreManager.js +1 -1
- package/lib/react-native/LocalDatastoreController.react-native.js +1 -1
- package/lib/react-native/OfflineQuery.js +5 -5
- package/lib/react-native/ParseConfig.js +1 -1
- package/lib/react-native/ParseInstallation.js +11 -5
- package/lib/react-native/ParseObject.js +60 -17
- package/lib/react-native/ParseQuery.js +1 -1
- package/lib/react-native/ParseRole.js +8 -2
- package/lib/react-native/ParseUser.js +12 -6
- package/lib/react-native/RESTController.js +11 -10
- package/lib/react-native/StorageController.weapp.js +1 -1
- package/lib/weapp/CoreManager.js +1 -1
- package/lib/weapp/FacebookUtils.js +1 -1
- package/lib/weapp/LocalDatastoreController.react-native.js +1 -1
- package/lib/weapp/OfflineQuery.js +5 -9
- package/lib/weapp/Parse.js +1 -1
- package/lib/weapp/ParseConfig.js +1 -1
- package/lib/weapp/ParseFile.js +0 -1
- package/lib/weapp/ParseObject.js +54 -19
- package/lib/weapp/ParseQuery.js +1 -1
- package/lib/weapp/ParseUser.js +1 -1
- package/lib/weapp/RESTController.js +2 -2
- package/lib/weapp/StorageController.weapp.js +1 -1
- package/package.json +25 -23
|
@@ -103,7 +103,7 @@ const FacebookUtils = {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
if (initOptions.status && typeof console !== 'undefined') {
|
|
106
|
-
const warn = console.warn || console.log || function () {};
|
|
106
|
+
const warn = console.warn || console.log || function () {};
|
|
107
107
|
warn.call(console, 'The "status" flag passed into' + ' FB.init, when set to true, can interfere with Parse Facebook' + ' integration, so it has been suppressed. Please call' + ' FB.getLoginStatus() explicitly if you require this behavior.');
|
|
108
108
|
}
|
|
109
109
|
initOptions.status = false;
|
|
@@ -317,11 +317,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
317
317
|
compareTo = parserResult.result;
|
|
318
318
|
}
|
|
319
319
|
// Compare Date Object or Date String
|
|
320
|
-
if (toString.call(compareTo) === '[object Date]' || typeof compareTo === 'string' &&
|
|
321
|
-
// @ts-ignore
|
|
322
|
-
new Date(compareTo) !== 'Invalid Date' &&
|
|
323
|
-
// @ts-ignore
|
|
324
|
-
!isNaN(new Date(compareTo))) {
|
|
320
|
+
if (toString.call(compareTo) === '[object Date]' || typeof compareTo === 'string' && new Date(compareTo).toString() !== 'Invalid Date') {
|
|
325
321
|
object[key] = new Date(object[key].iso ? object[key].iso : object[key]);
|
|
326
322
|
}
|
|
327
323
|
switch (condition) {
|
|
@@ -442,7 +438,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
442
438
|
break;
|
|
443
439
|
case '$select':
|
|
444
440
|
{
|
|
445
|
-
const subQueryObjects = (0, _filter.default)(objects).call(objects, (obj,
|
|
441
|
+
const subQueryObjects = (0, _filter.default)(objects).call(objects, (obj, _index, arr) => {
|
|
446
442
|
return matchesQuery(compareTo.query.className, obj, arr, compareTo.query.where);
|
|
447
443
|
});
|
|
448
444
|
for (let i = 0; i < subQueryObjects.length; i += 1) {
|
|
@@ -453,7 +449,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
453
449
|
}
|
|
454
450
|
case '$dontSelect':
|
|
455
451
|
{
|
|
456
|
-
const subQueryObjects = (0, _filter.default)(objects).call(objects, (obj,
|
|
452
|
+
const subQueryObjects = (0, _filter.default)(objects).call(objects, (obj, _index, arr) => {
|
|
457
453
|
return matchesQuery(compareTo.query.className, obj, arr, compareTo.query.where);
|
|
458
454
|
});
|
|
459
455
|
for (let i = 0; i < subQueryObjects.length; i += 1) {
|
|
@@ -464,7 +460,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
464
460
|
}
|
|
465
461
|
case '$inQuery':
|
|
466
462
|
{
|
|
467
|
-
const subQueryObjects = (0, _filter.default)(objects).call(objects, (obj,
|
|
463
|
+
const subQueryObjects = (0, _filter.default)(objects).call(objects, (obj, _index, arr) => {
|
|
468
464
|
return matchesQuery(compareTo.className, obj, arr, compareTo.where);
|
|
469
465
|
});
|
|
470
466
|
for (let i = 0; i < subQueryObjects.length; i += 1) {
|
|
@@ -477,7 +473,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
477
473
|
}
|
|
478
474
|
case '$notInQuery':
|
|
479
475
|
{
|
|
480
|
-
const subQueryObjects = (0, _filter.default)(objects).call(objects, (obj,
|
|
476
|
+
const subQueryObjects = (0, _filter.default)(objects).call(objects, (obj, _index, arr) => {
|
|
481
477
|
return matchesQuery(compareTo.className, obj, arr, compareTo.where);
|
|
482
478
|
});
|
|
483
479
|
for (let i = 0; i < subQueryObjects.length; i += 1) {
|
package/lib/browser/Parse.js
CHANGED
|
@@ -137,9 +137,7 @@ const Parse = {
|
|
|
137
137
|
*/
|
|
138
138
|
initialize(applicationId, javaScriptKey) {
|
|
139
139
|
if ("browser" === 'browser' && _CoreManager.default.get('IS_NODE') && !process.env.SERVER_RENDERING) {
|
|
140
|
-
/* eslint-disable no-console */
|
|
141
140
|
console.log("It looks like you're using the browser version of the SDK in a " + "node.js environment. You should require('parse/node') instead.");
|
|
142
|
-
/* eslint-enable no-console */
|
|
143
141
|
}
|
|
144
142
|
Parse._initialize(applicationId, javaScriptKey);
|
|
145
143
|
},
|
|
@@ -373,7 +371,7 @@ const Parse = {
|
|
|
373
371
|
*/
|
|
374
372
|
dumpLocalDatastore() {
|
|
375
373
|
if (!this.LocalDatastore.isEnabled) {
|
|
376
|
-
console.log('Parse.enableLocalDatastore() must be called first');
|
|
374
|
+
console.log('Parse.enableLocalDatastore() must be called first');
|
|
377
375
|
return _promise.default.resolve({});
|
|
378
376
|
} else {
|
|
379
377
|
return Parse.LocalDatastore._getAllContents();
|
package/lib/browser/ParseFile.js
CHANGED
|
@@ -403,7 +403,6 @@ const DefaultController = {
|
|
|
403
403
|
throw new Error('saveFile can only be used with File-type sources.');
|
|
404
404
|
}
|
|
405
405
|
const base64Data = await new _promise.default((res, rej) => {
|
|
406
|
-
// eslint-disable-next-line no-undef
|
|
407
406
|
const reader = new FileReader();
|
|
408
407
|
reader.onload = () => res(reader.result);
|
|
409
408
|
reader.onerror = error => rej(error);
|
|
@@ -19,6 +19,7 @@ var _getPrototypeOf = _interopRequireDefault(require("@babel/runtime-corejs3/cor
|
|
|
19
19
|
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
20
20
|
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
21
21
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
22
|
+
var _some = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/some"));
|
|
22
23
|
var _create = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/create"));
|
|
23
24
|
var _defineProperty3 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/define-property"));
|
|
24
25
|
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
|
|
@@ -262,7 +263,7 @@ class ParseObject {
|
|
|
262
263
|
if (objectCache[attr] !== stringified) {
|
|
263
264
|
dirty[attr] = val;
|
|
264
265
|
}
|
|
265
|
-
} catch (
|
|
266
|
+
} catch (_) {
|
|
266
267
|
// Error occurred, possibly by a nested unsaved pointer in a mutable container
|
|
267
268
|
// No matter how it happened, it indicates a change in the attribute
|
|
268
269
|
dirty[attr] = val;
|
|
@@ -1302,6 +1303,17 @@ class ParseObject {
|
|
|
1302
1303
|
}
|
|
1303
1304
|
const controller = _CoreManager.default.getObjectController();
|
|
1304
1305
|
const unsaved = options.cascadeSave !== false ? (0, _unsavedChildren.default)(this) : null;
|
|
1306
|
+
if (unsaved && unsaved.length && options.transaction === true && (0, _some.default)(unsaved).call(unsaved, el => el instanceof ParseObject)) {
|
|
1307
|
+
saveOptions.transaction = options.transaction;
|
|
1308
|
+
const unsavedFiles = [];
|
|
1309
|
+
const unsavedObjects = [];
|
|
1310
|
+
(0, _forEach.default)(unsaved).call(unsaved, el => {
|
|
1311
|
+
if (el instanceof _ParseFile.default) unsavedFiles.push(el);else unsavedObjects.push(el);
|
|
1312
|
+
});
|
|
1313
|
+
unsavedObjects.push(this);
|
|
1314
|
+
const filePromise = unsavedFiles.length ? controller.save(unsavedFiles, saveOptions) : _promise.default.resolve();
|
|
1315
|
+
return filePromise.then(() => controller.save(unsavedObjects, saveOptions)).then(savedOjbects => savedOjbects.pop());
|
|
1316
|
+
}
|
|
1305
1317
|
return controller.save(unsaved, saveOptions).then(() => {
|
|
1306
1318
|
return controller.save(this, saveOptions);
|
|
1307
1319
|
});
|
|
@@ -1710,6 +1722,9 @@ class ParseObject {
|
|
|
1710
1722
|
if (options.hasOwnProperty('sessionToken')) {
|
|
1711
1723
|
destroyOptions.sessionToken = options.sessionToken;
|
|
1712
1724
|
}
|
|
1725
|
+
if (options.hasOwnProperty('transaction') && typeof options.transaction === 'boolean') {
|
|
1726
|
+
destroyOptions.transaction = options.transaction;
|
|
1727
|
+
}
|
|
1713
1728
|
if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
|
|
1714
1729
|
destroyOptions.batchSize = options.batchSize;
|
|
1715
1730
|
}
|
|
@@ -1746,6 +1761,9 @@ class ParseObject {
|
|
|
1746
1761
|
if (options.hasOwnProperty('sessionToken')) {
|
|
1747
1762
|
saveOptions.sessionToken = options.sessionToken;
|
|
1748
1763
|
}
|
|
1764
|
+
if (options.hasOwnProperty('transaction') && typeof options.transaction === 'boolean') {
|
|
1765
|
+
saveOptions.transaction = options.transaction;
|
|
1766
|
+
}
|
|
1749
1767
|
if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
|
|
1750
1768
|
saveOptions.batchSize = options.batchSize;
|
|
1751
1769
|
}
|
|
@@ -2233,10 +2251,12 @@ const DefaultController = {
|
|
|
2233
2251
|
return _promise.default.resolve(undefined);
|
|
2234
2252
|
},
|
|
2235
2253
|
async destroy(target, options) {
|
|
2236
|
-
|
|
2254
|
+
if (options && options.batchSize && options.transaction) throw new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'You cannot use both transaction and batchSize options simultaneously.');
|
|
2255
|
+
let batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
|
|
2237
2256
|
const localDatastore = _CoreManager.default.getLocalDatastore();
|
|
2238
2257
|
const RESTController = _CoreManager.default.getRESTController();
|
|
2239
2258
|
if ((0, _isArray.default)(target)) {
|
|
2259
|
+
if (options && options.transaction && target.length > 1) batchSize = target.length;
|
|
2240
2260
|
if (target.length < 1) {
|
|
2241
2261
|
return _promise.default.resolve([]);
|
|
2242
2262
|
}
|
|
@@ -2257,16 +2277,21 @@ const DefaultController = {
|
|
|
2257
2277
|
let deleteCompleted = _promise.default.resolve();
|
|
2258
2278
|
const errors = [];
|
|
2259
2279
|
(0, _forEach.default)(batches).call(batches, batch => {
|
|
2280
|
+
const requests = (0, _map.default)(batch).call(batch, obj => {
|
|
2281
|
+
return {
|
|
2282
|
+
method: 'DELETE',
|
|
2283
|
+
path: getServerUrlPath() + 'classes/' + obj.className + '/' + obj._getId(),
|
|
2284
|
+
body: {}
|
|
2285
|
+
};
|
|
2286
|
+
});
|
|
2287
|
+
const body = options && options.transaction && requests.length > 1 ? {
|
|
2288
|
+
requests,
|
|
2289
|
+
transaction: true
|
|
2290
|
+
} : {
|
|
2291
|
+
requests
|
|
2292
|
+
};
|
|
2260
2293
|
deleteCompleted = deleteCompleted.then(() => {
|
|
2261
|
-
return RESTController.request('POST', 'batch', {
|
|
2262
|
-
requests: (0, _map.default)(batch).call(batch, obj => {
|
|
2263
|
-
return {
|
|
2264
|
-
method: 'DELETE',
|
|
2265
|
-
path: getServerUrlPath() + 'classes/' + obj.className + '/' + obj._getId(),
|
|
2266
|
-
body: {}
|
|
2267
|
-
};
|
|
2268
|
-
})
|
|
2269
|
-
}, options).then(results => {
|
|
2294
|
+
return RESTController.request('POST', 'batch', body, options).then(results => {
|
|
2270
2295
|
for (let i = 0; i < results.length; i++) {
|
|
2271
2296
|
if (results[i] && results[i].hasOwnProperty('error')) {
|
|
2272
2297
|
const err = new _ParseError.default(results[i].error.code, results[i].error.error);
|
|
@@ -2297,7 +2322,8 @@ const DefaultController = {
|
|
|
2297
2322
|
return _promise.default.resolve(target);
|
|
2298
2323
|
},
|
|
2299
2324
|
save(target, options) {
|
|
2300
|
-
|
|
2325
|
+
if (options && options.batchSize && options.transaction) return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'You cannot use both transaction and batchSize options simultaneously.'));
|
|
2326
|
+
let batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
|
|
2301
2327
|
const localDatastore = _CoreManager.default.getLocalDatastore();
|
|
2302
2328
|
const mapIdForPin = {};
|
|
2303
2329
|
const RESTController = _CoreManager.default.getRESTController();
|
|
@@ -2326,6 +2352,10 @@ const DefaultController = {
|
|
|
2326
2352
|
pending.push(el);
|
|
2327
2353
|
}
|
|
2328
2354
|
});
|
|
2355
|
+
if (options && options.transaction && pending.length > 1) {
|
|
2356
|
+
if ((0, _some.default)(pending).call(pending, el => !(0, _canBeSerialized.default)(el))) return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Tried to save a transactional batch containing an object with unserializable attributes.'));
|
|
2357
|
+
batchSize = pending.length;
|
|
2358
|
+
}
|
|
2329
2359
|
return _promise.default.all(filesSaved).then(() => {
|
|
2330
2360
|
let objectError = null;
|
|
2331
2361
|
return (0, _promiseUtils.continueWhile)(() => {
|
|
@@ -2382,13 +2412,18 @@ const DefaultController = {
|
|
|
2382
2412
|
});
|
|
2383
2413
|
(0, _promiseUtils.when)(batchReady).then(() => {
|
|
2384
2414
|
// Kick off the batch request
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2415
|
+
const requests = (0, _map.default)(batch).call(batch, obj => {
|
|
2416
|
+
const params = obj._getSaveParams();
|
|
2417
|
+
params.path = getServerUrlPath() + params.path;
|
|
2418
|
+
return params;
|
|
2419
|
+
});
|
|
2420
|
+
const body = options && options.transaction && requests.length > 1 ? {
|
|
2421
|
+
requests,
|
|
2422
|
+
transaction: true
|
|
2423
|
+
} : {
|
|
2424
|
+
requests
|
|
2425
|
+
};
|
|
2426
|
+
return RESTController.request('POST', 'batch', body, options);
|
|
2392
2427
|
}).then(batchReturned.resolve, error => {
|
|
2393
2428
|
batchReturned.reject(new _ParseError.default(_ParseError.default.INCORRECT_TYPE, error.message));
|
|
2394
2429
|
});
|
|
@@ -342,7 +342,7 @@ class ParseQuery {
|
|
|
342
342
|
_OfflineQuery.default.validateQuery(this);
|
|
343
343
|
const localDatastore = _CoreManager.default.getLocalDatastore();
|
|
344
344
|
const objects = await localDatastore._serializeObjectsFromPinName(this._localDatastorePinName);
|
|
345
|
-
let results = (0, _filter.default)(_context = (0, _map.default)(objects).call(objects, (json,
|
|
345
|
+
let results = (0, _filter.default)(_context = (0, _map.default)(objects).call(objects, (json, _index, arr) => {
|
|
346
346
|
const object = _ParseObject.default.fromJSON(json, false);
|
|
347
347
|
if (json._localId && !json.objectId) {
|
|
348
348
|
object._localId = json._localId;
|
package/lib/browser/ParseUser.js
CHANGED
|
@@ -28,7 +28,7 @@ let useXDomainRequest = false;
|
|
|
28
28
|
if (typeof XDomainRequest !== 'undefined' && !('withCredentials' in new XMLHttpRequest())) {
|
|
29
29
|
useXDomainRequest = true;
|
|
30
30
|
}
|
|
31
|
-
function ajaxIE9(method, url, data,
|
|
31
|
+
function ajaxIE9(method, url, data, _headers, options) {
|
|
32
32
|
return new _promise.default((resolve, reject) => {
|
|
33
33
|
// @ts-ignore
|
|
34
34
|
const xdr = new XDomainRequest();
|
|
@@ -291,7 +291,7 @@ const RESTController = {
|
|
|
291
291
|
try {
|
|
292
292
|
const errorJSON = JSON.parse(response.responseText);
|
|
293
293
|
error = new _ParseError.default(errorJSON.code, errorJSON.error);
|
|
294
|
-
} catch (
|
|
294
|
+
} catch (_) {
|
|
295
295
|
// If we fail to parse the error text, that's okay.
|
|
296
296
|
error = new _ParseError.default(_ParseError.default.INVALID_JSON, 'Received an error with invalid JSON from Parse: ' + response.responseText);
|
|
297
297
|
}
|
package/lib/node/CoreManager.js
CHANGED
|
@@ -106,7 +106,7 @@ const FacebookUtils = {
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
if (initOptions.status && typeof console !== 'undefined') {
|
|
109
|
-
const warn = console.warn || console.log || function () {};
|
|
109
|
+
const warn = console.warn || console.log || function () {};
|
|
110
110
|
warn.call(console, 'The "status" flag passed into' + ' FB.init, when set to true, can interfere with Parse Facebook' + ' integration, so it has been suppressed. Please call' + ' FB.getLoginStatus() explicitly if you require this behavior.');
|
|
111
111
|
}
|
|
112
112
|
initOptions.status = false;
|
package/lib/node/OfflineQuery.js
CHANGED
|
@@ -311,11 +311,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
311
311
|
compareTo = parserResult.result;
|
|
312
312
|
}
|
|
313
313
|
// Compare Date Object or Date String
|
|
314
|
-
if (toString.call(compareTo) === '[object Date]' || typeof compareTo === 'string' &&
|
|
315
|
-
// @ts-ignore
|
|
316
|
-
new Date(compareTo) !== 'Invalid Date' &&
|
|
317
|
-
// @ts-ignore
|
|
318
|
-
!isNaN(new Date(compareTo))) {
|
|
314
|
+
if (toString.call(compareTo) === '[object Date]' || typeof compareTo === 'string' && new Date(compareTo).toString() !== 'Invalid Date') {
|
|
319
315
|
object[key] = new Date(object[key].iso ? object[key].iso : object[key]);
|
|
320
316
|
}
|
|
321
317
|
switch (condition) {
|
|
@@ -435,7 +431,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
435
431
|
break;
|
|
436
432
|
case '$select':
|
|
437
433
|
{
|
|
438
|
-
const subQueryObjects = objects.filter((obj,
|
|
434
|
+
const subQueryObjects = objects.filter((obj, _index, arr) => {
|
|
439
435
|
return matchesQuery(compareTo.query.className, obj, arr, compareTo.query.where);
|
|
440
436
|
});
|
|
441
437
|
for (let i = 0; i < subQueryObjects.length; i += 1) {
|
|
@@ -446,7 +442,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
446
442
|
}
|
|
447
443
|
case '$dontSelect':
|
|
448
444
|
{
|
|
449
|
-
const subQueryObjects = objects.filter((obj,
|
|
445
|
+
const subQueryObjects = objects.filter((obj, _index, arr) => {
|
|
450
446
|
return matchesQuery(compareTo.query.className, obj, arr, compareTo.query.where);
|
|
451
447
|
});
|
|
452
448
|
for (let i = 0; i < subQueryObjects.length; i += 1) {
|
|
@@ -457,7 +453,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
457
453
|
}
|
|
458
454
|
case '$inQuery':
|
|
459
455
|
{
|
|
460
|
-
const subQueryObjects = objects.filter((obj,
|
|
456
|
+
const subQueryObjects = objects.filter((obj, _index, arr) => {
|
|
461
457
|
return matchesQuery(compareTo.className, obj, arr, compareTo.where);
|
|
462
458
|
});
|
|
463
459
|
for (let i = 0; i < subQueryObjects.length; i += 1) {
|
|
@@ -470,7 +466,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
470
466
|
}
|
|
471
467
|
case '$notInQuery':
|
|
472
468
|
{
|
|
473
|
-
const subQueryObjects = objects.filter((obj,
|
|
469
|
+
const subQueryObjects = objects.filter((obj, _index, arr) => {
|
|
474
470
|
return matchesQuery(compareTo.className, obj, arr, compareTo.where);
|
|
475
471
|
});
|
|
476
472
|
for (let i = 0; i < subQueryObjects.length; i += 1) {
|
package/lib/node/Parse.js
CHANGED
|
@@ -360,7 +360,7 @@ const Parse = {
|
|
|
360
360
|
*/
|
|
361
361
|
dumpLocalDatastore() {
|
|
362
362
|
if (!this.LocalDatastore.isEnabled) {
|
|
363
|
-
console.log('Parse.enableLocalDatastore() must be called first');
|
|
363
|
+
console.log('Parse.enableLocalDatastore() must be called first');
|
|
364
364
|
return Promise.resolve({});
|
|
365
365
|
} else {
|
|
366
366
|
return Parse.LocalDatastore._getAllContents();
|
package/lib/node/ParseConfig.js
CHANGED
package/lib/node/ParseFile.js
CHANGED
|
@@ -387,7 +387,6 @@ const DefaultController = {
|
|
|
387
387
|
throw new Error('saveFile can only be used with File-type sources.');
|
|
388
388
|
}
|
|
389
389
|
const base64Data = await new Promise((res, rej) => {
|
|
390
|
-
// eslint-disable-next-line no-undef
|
|
391
390
|
const reader = new FileReader();
|
|
392
391
|
reader.onload = () => res(reader.result);
|
|
393
392
|
reader.onerror = error => rej(error);
|
package/lib/node/ParseObject.js
CHANGED
|
@@ -247,7 +247,7 @@ class ParseObject {
|
|
|
247
247
|
if (objectCache[attr] !== stringified) {
|
|
248
248
|
dirty[attr] = val;
|
|
249
249
|
}
|
|
250
|
-
} catch (
|
|
250
|
+
} catch (_) {
|
|
251
251
|
// Error occurred, possibly by a nested unsaved pointer in a mutable container
|
|
252
252
|
// No matter how it happened, it indicates a change in the attribute
|
|
253
253
|
dirty[attr] = val;
|
|
@@ -1282,6 +1282,17 @@ class ParseObject {
|
|
|
1282
1282
|
}
|
|
1283
1283
|
const controller = _CoreManager.default.getObjectController();
|
|
1284
1284
|
const unsaved = options.cascadeSave !== false ? (0, _unsavedChildren.default)(this) : null;
|
|
1285
|
+
if (unsaved && unsaved.length && options.transaction === true && unsaved.some(el => el instanceof ParseObject)) {
|
|
1286
|
+
saveOptions.transaction = options.transaction;
|
|
1287
|
+
const unsavedFiles = [];
|
|
1288
|
+
const unsavedObjects = [];
|
|
1289
|
+
unsaved.forEach(el => {
|
|
1290
|
+
if (el instanceof _ParseFile.default) unsavedFiles.push(el);else unsavedObjects.push(el);
|
|
1291
|
+
});
|
|
1292
|
+
unsavedObjects.push(this);
|
|
1293
|
+
const filePromise = unsavedFiles.length ? controller.save(unsavedFiles, saveOptions) : Promise.resolve();
|
|
1294
|
+
return filePromise.then(() => controller.save(unsavedObjects, saveOptions)).then(savedOjbects => savedOjbects.pop());
|
|
1295
|
+
}
|
|
1285
1296
|
return controller.save(unsaved, saveOptions).then(() => {
|
|
1286
1297
|
return controller.save(this, saveOptions);
|
|
1287
1298
|
});
|
|
@@ -1687,6 +1698,9 @@ class ParseObject {
|
|
|
1687
1698
|
if (options.hasOwnProperty('sessionToken')) {
|
|
1688
1699
|
destroyOptions.sessionToken = options.sessionToken;
|
|
1689
1700
|
}
|
|
1701
|
+
if (options.hasOwnProperty('transaction') && typeof options.transaction === 'boolean') {
|
|
1702
|
+
destroyOptions.transaction = options.transaction;
|
|
1703
|
+
}
|
|
1690
1704
|
if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
|
|
1691
1705
|
destroyOptions.batchSize = options.batchSize;
|
|
1692
1706
|
}
|
|
@@ -1722,6 +1736,9 @@ class ParseObject {
|
|
|
1722
1736
|
if (options.hasOwnProperty('sessionToken')) {
|
|
1723
1737
|
saveOptions.sessionToken = options.sessionToken;
|
|
1724
1738
|
}
|
|
1739
|
+
if (options.hasOwnProperty('transaction') && typeof options.transaction === 'boolean') {
|
|
1740
|
+
saveOptions.transaction = options.transaction;
|
|
1741
|
+
}
|
|
1725
1742
|
if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
|
|
1726
1743
|
saveOptions.batchSize = options.batchSize;
|
|
1727
1744
|
}
|
|
@@ -2209,10 +2226,12 @@ const DefaultController = {
|
|
|
2209
2226
|
return Promise.resolve(undefined);
|
|
2210
2227
|
},
|
|
2211
2228
|
async destroy(target, options) {
|
|
2212
|
-
|
|
2229
|
+
if (options && options.batchSize && options.transaction) throw new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'You cannot use both transaction and batchSize options simultaneously.');
|
|
2230
|
+
let batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
|
|
2213
2231
|
const localDatastore = _CoreManager.default.getLocalDatastore();
|
|
2214
2232
|
const RESTController = _CoreManager.default.getRESTController();
|
|
2215
2233
|
if (Array.isArray(target)) {
|
|
2234
|
+
if (options && options.transaction && target.length > 1) batchSize = target.length;
|
|
2216
2235
|
if (target.length < 1) {
|
|
2217
2236
|
return Promise.resolve([]);
|
|
2218
2237
|
}
|
|
@@ -2233,16 +2252,21 @@ const DefaultController = {
|
|
|
2233
2252
|
let deleteCompleted = Promise.resolve();
|
|
2234
2253
|
const errors = [];
|
|
2235
2254
|
batches.forEach(batch => {
|
|
2255
|
+
const requests = batch.map(obj => {
|
|
2256
|
+
return {
|
|
2257
|
+
method: 'DELETE',
|
|
2258
|
+
path: getServerUrlPath() + 'classes/' + obj.className + '/' + obj._getId(),
|
|
2259
|
+
body: {}
|
|
2260
|
+
};
|
|
2261
|
+
});
|
|
2262
|
+
const body = options && options.transaction && requests.length > 1 ? {
|
|
2263
|
+
requests,
|
|
2264
|
+
transaction: true
|
|
2265
|
+
} : {
|
|
2266
|
+
requests
|
|
2267
|
+
};
|
|
2236
2268
|
deleteCompleted = deleteCompleted.then(() => {
|
|
2237
|
-
return RESTController.request('POST', 'batch', {
|
|
2238
|
-
requests: batch.map(obj => {
|
|
2239
|
-
return {
|
|
2240
|
-
method: 'DELETE',
|
|
2241
|
-
path: getServerUrlPath() + 'classes/' + obj.className + '/' + obj._getId(),
|
|
2242
|
-
body: {}
|
|
2243
|
-
};
|
|
2244
|
-
})
|
|
2245
|
-
}, options).then(results => {
|
|
2269
|
+
return RESTController.request('POST', 'batch', body, options).then(results => {
|
|
2246
2270
|
for (let i = 0; i < results.length; i++) {
|
|
2247
2271
|
if (results[i] && results[i].hasOwnProperty('error')) {
|
|
2248
2272
|
const err = new _ParseError.default(results[i].error.code, results[i].error.error);
|
|
@@ -2273,7 +2297,8 @@ const DefaultController = {
|
|
|
2273
2297
|
return Promise.resolve(target);
|
|
2274
2298
|
},
|
|
2275
2299
|
save(target, options) {
|
|
2276
|
-
|
|
2300
|
+
if (options && options.batchSize && options.transaction) return Promise.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'You cannot use both transaction and batchSize options simultaneously.'));
|
|
2301
|
+
let batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
|
|
2277
2302
|
const localDatastore = _CoreManager.default.getLocalDatastore();
|
|
2278
2303
|
const mapIdForPin = {};
|
|
2279
2304
|
const RESTController = _CoreManager.default.getRESTController();
|
|
@@ -2302,6 +2327,10 @@ const DefaultController = {
|
|
|
2302
2327
|
pending.push(el);
|
|
2303
2328
|
}
|
|
2304
2329
|
});
|
|
2330
|
+
if (options && options.transaction && pending.length > 1) {
|
|
2331
|
+
if (pending.some(el => !(0, _canBeSerialized.default)(el))) return Promise.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Tried to save a transactional batch containing an object with unserializable attributes.'));
|
|
2332
|
+
batchSize = pending.length;
|
|
2333
|
+
}
|
|
2305
2334
|
return Promise.all(filesSaved).then(() => {
|
|
2306
2335
|
let objectError = null;
|
|
2307
2336
|
return (0, _promiseUtils.continueWhile)(() => {
|
|
@@ -2358,13 +2387,18 @@ const DefaultController = {
|
|
|
2358
2387
|
});
|
|
2359
2388
|
(0, _promiseUtils.when)(batchReady).then(() => {
|
|
2360
2389
|
// Kick off the batch request
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2390
|
+
const requests = batch.map(obj => {
|
|
2391
|
+
const params = obj._getSaveParams();
|
|
2392
|
+
params.path = getServerUrlPath() + params.path;
|
|
2393
|
+
return params;
|
|
2394
|
+
});
|
|
2395
|
+
const body = options && options.transaction && requests.length > 1 ? {
|
|
2396
|
+
requests,
|
|
2397
|
+
transaction: true
|
|
2398
|
+
} : {
|
|
2399
|
+
requests
|
|
2400
|
+
};
|
|
2401
|
+
return RESTController.request('POST', 'batch', body, options);
|
|
2368
2402
|
}).then(batchReturned.resolve, error => {
|
|
2369
2403
|
batchReturned.reject(new _ParseError.default(_ParseError.default.INCORRECT_TYPE, error.message));
|
|
2370
2404
|
});
|
package/lib/node/ParseQuery.js
CHANGED
|
@@ -309,7 +309,7 @@ class ParseQuery {
|
|
|
309
309
|
_OfflineQuery.default.validateQuery(this);
|
|
310
310
|
const localDatastore = _CoreManager.default.getLocalDatastore();
|
|
311
311
|
const objects = await localDatastore._serializeObjectsFromPinName(this._localDatastorePinName);
|
|
312
|
-
let results = objects.map((json,
|
|
312
|
+
let results = objects.map((json, _index, arr) => {
|
|
313
313
|
const object = _ParseObject.default.fromJSON(json, false);
|
|
314
314
|
if (json._localId && !json.objectId) {
|
|
315
315
|
object._localId = json._localId;
|
package/lib/node/ParseUser.js
CHANGED
|
@@ -26,7 +26,7 @@ let useXDomainRequest = false;
|
|
|
26
26
|
if (typeof XDomainRequest !== 'undefined' && !('withCredentials' in new XMLHttpRequest())) {
|
|
27
27
|
useXDomainRequest = true;
|
|
28
28
|
}
|
|
29
|
-
function ajaxIE9(method, url, data,
|
|
29
|
+
function ajaxIE9(method, url, data, _headers, options) {
|
|
30
30
|
return new Promise((resolve, reject) => {
|
|
31
31
|
// @ts-ignore
|
|
32
32
|
const xdr = new XDomainRequest();
|
|
@@ -287,7 +287,7 @@ const RESTController = {
|
|
|
287
287
|
try {
|
|
288
288
|
const errorJSON = JSON.parse(response.responseText);
|
|
289
289
|
error = new _ParseError.default(errorJSON.code, errorJSON.error);
|
|
290
|
-
} catch (
|
|
290
|
+
} catch (_) {
|
|
291
291
|
// If we fail to parse the error text, that's okay.
|
|
292
292
|
error = new _ParseError.default(_ParseError.default.INVALID_JSON, 'Received an error with invalid JSON from Parse: ' + response.responseText);
|
|
293
293
|
}
|