parse 5.3.0-alpha.4 → 5.3.0-alpha.6
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/README.md +6 -5
- package/dist/parse.js +171 -296
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +171 -296
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/Cloud.js +12 -16
- package/lib/browser/CoreManager.js +3 -3
- package/lib/browser/ParseFile.js +1 -1
- package/lib/browser/ParseObject.js +86 -120
- package/lib/browser/ParseQuery.js +21 -88
- package/lib/browser/ParseSession.js +1 -5
- package/lib/browser/ParseUser.js +40 -56
- package/lib/browser/Push.js +2 -2
- package/lib/browser/Storage.js +1 -1
- package/lib/browser/StorageController.default.js +2 -2
- package/lib/node/Cloud.js +12 -16
- package/lib/node/CoreManager.js +3 -3
- package/lib/node/ParseFile.js +1 -1
- package/lib/node/ParseObject.js +82 -115
- package/lib/node/ParseQuery.js +21 -88
- package/lib/node/ParseSession.js +1 -5
- package/lib/node/ParseUser.js +40 -56
- package/lib/node/Push.js +2 -2
- package/lib/node/Storage.js +1 -1
- package/lib/node/StorageController.default.js +2 -2
- package/lib/react-native/Cloud.js +4 -16
- package/lib/react-native/CoreManager.js +3 -3
- package/lib/react-native/ParseFile.js +1 -1
- package/lib/react-native/ParseInstallation.js +3 -3
- package/lib/react-native/ParseObject.js +54 -115
- package/lib/react-native/ParseQuery.js +20 -88
- package/lib/react-native/ParseRole.js +3 -3
- package/lib/react-native/ParseSession.js +1 -5
- package/lib/react-native/ParseUser.js +16 -59
- package/lib/react-native/Push.js +2 -2
- package/lib/react-native/Storage.js +1 -1
- package/lib/react-native/StorageController.default.js +2 -2
- package/lib/weapp/Cloud.js +12 -16
- package/lib/weapp/CoreManager.js +3 -3
- package/lib/weapp/ParseFile.js +1 -1
- package/lib/weapp/ParseObject.js +86 -120
- package/lib/weapp/ParseQuery.js +21 -88
- package/lib/weapp/ParseSession.js +1 -5
- package/lib/weapp/ParseUser.js +40 -56
- package/lib/weapp/Push.js +2 -2
- package/lib/weapp/Storage.js +1 -1
- package/lib/weapp/StorageController.default.js +2 -2
- package/package.json +24 -24
package/lib/browser/Cloud.js
CHANGED
|
@@ -16,6 +16,7 @@ var _decode = _interopRequireDefault(require("./decode"));
|
|
|
16
16
|
var _encode = _interopRequireDefault(require("./encode"));
|
|
17
17
|
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
18
18
|
var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
|
|
19
|
+
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
19
20
|
/**
|
|
20
21
|
* Contains functions for calling and declaring
|
|
21
22
|
* <a href="/docs/cloud_code_guide#functions">cloud functions</a>.
|
|
@@ -36,27 +37,22 @@ var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
|
|
|
36
37
|
* @param {string} name The function name.
|
|
37
38
|
* @param {object} data The parameters to send to the cloud function.
|
|
38
39
|
* @param {object} options
|
|
40
|
+
* Valid options are:<ul>
|
|
41
|
+
* <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
|
|
42
|
+
* be used for this request.
|
|
43
|
+
* <li>sessionToken: A valid session token, used for making a request on
|
|
44
|
+
* behalf of a specific user.
|
|
45
|
+
* <li>installationId: the installationId which made the request
|
|
46
|
+
* <li>context: A dictionary that is accessible in Cloud Code triggers.
|
|
47
|
+
* </ul>
|
|
39
48
|
* @returns {Promise} A promise that will be resolved with the result
|
|
40
49
|
* of the function.
|
|
41
50
|
*/
|
|
42
51
|
function run(name, data, options) {
|
|
43
|
-
options = options || {};
|
|
44
52
|
if (typeof name !== 'string' || name.length === 0) {
|
|
45
53
|
throw new TypeError('Cloud function name must be a string.');
|
|
46
54
|
}
|
|
47
|
-
const requestOptions =
|
|
48
|
-
if (options.useMasterKey) {
|
|
49
|
-
requestOptions.useMasterKey = options.useMasterKey;
|
|
50
|
-
}
|
|
51
|
-
if (options.sessionToken) {
|
|
52
|
-
requestOptions.sessionToken = options.sessionToken;
|
|
53
|
-
}
|
|
54
|
-
if (options.installationId) {
|
|
55
|
-
requestOptions.installationId = options.installationId;
|
|
56
|
-
}
|
|
57
|
-
if (options.context && typeof options.context === 'object') {
|
|
58
|
-
requestOptions.context = options.context;
|
|
59
|
-
}
|
|
55
|
+
const requestOptions = _ParseObject.default._getRequestOptions(options);
|
|
60
56
|
return _CoreManager.default.getCloudController().run(name, data, requestOptions);
|
|
61
57
|
}
|
|
62
58
|
|
|
@@ -113,11 +109,11 @@ const DefaultController = {
|
|
|
113
109
|
const payload = (0, _encode.default)(data, true);
|
|
114
110
|
const request = RESTController.request('POST', 'functions/' + name, payload, options);
|
|
115
111
|
return request.then(res => {
|
|
116
|
-
if (typeof res === 'object' && (0, _keys.default)(res).length > 0 && !
|
|
112
|
+
if (typeof res === 'object' && (0, _keys.default)(res).length > 0 && !Object.hasOwn(res, 'result')) {
|
|
117
113
|
throw new _ParseError.default(_ParseError.default.INVALID_JSON, 'The server returned an invalid response.');
|
|
118
114
|
}
|
|
119
115
|
const decoded = (0, _decode.default)(res);
|
|
120
|
-
if (decoded &&
|
|
116
|
+
if (decoded && Object.hasOwn(decoded, 'result')) {
|
|
121
117
|
return _promise.default.resolve(decoded.result);
|
|
122
118
|
}
|
|
123
119
|
return _promise.default.resolve(undefined);
|
|
@@ -19,7 +19,7 @@ const config = {
|
|
|
19
19
|
SERVER_AUTH_TOKEN: null,
|
|
20
20
|
LIVEQUERY_SERVER_URL: null,
|
|
21
21
|
ENCRYPTED_KEY: null,
|
|
22
|
-
VERSION: 'js' + "5.3.0-alpha.
|
|
22
|
+
VERSION: 'js' + "5.3.0-alpha.6",
|
|
23
23
|
APPLICATION_ID: null,
|
|
24
24
|
JAVASCRIPT_KEY: null,
|
|
25
25
|
MASTER_KEY: null,
|
|
@@ -40,7 +40,7 @@ function requireMethods(name, methods, controller) {
|
|
|
40
40
|
}
|
|
41
41
|
const CoreManager = {
|
|
42
42
|
get: function (key) {
|
|
43
|
-
if (
|
|
43
|
+
if (Object.hasOwn(config, key)) {
|
|
44
44
|
return config[key];
|
|
45
45
|
}
|
|
46
46
|
throw new Error('Configuration key not found: ' + key);
|
|
@@ -49,7 +49,7 @@ const CoreManager = {
|
|
|
49
49
|
config[key] = value;
|
|
50
50
|
},
|
|
51
51
|
setIfNeeded: function (key, value) {
|
|
52
|
-
if (!
|
|
52
|
+
if (!Object.hasOwn(config, key)) {
|
|
53
53
|
config[key] = value;
|
|
54
54
|
}
|
|
55
55
|
return config[key];
|
package/lib/browser/ParseFile.js
CHANGED
|
@@ -299,7 +299,7 @@ class ParseFile {
|
|
|
299
299
|
const destroyOptions = {
|
|
300
300
|
useMasterKey: true
|
|
301
301
|
};
|
|
302
|
-
if (
|
|
302
|
+
if (Object.hasOwn(options, 'useMasterKey')) {
|
|
303
303
|
destroyOptions.useMasterKey = !!options.useMasterKey;
|
|
304
304
|
}
|
|
305
305
|
const controller = _CoreManager.default.getFileController();
|
|
@@ -17,9 +17,9 @@ var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-
|
|
|
17
17
|
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
|
18
18
|
var _getPrototypeOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-prototype-of"));
|
|
19
19
|
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
20
|
-
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
21
20
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
22
21
|
var _some = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/some"));
|
|
22
|
+
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
23
23
|
var _create = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/create"));
|
|
24
24
|
var _defineProperty3 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/define-property"));
|
|
25
25
|
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
|
|
@@ -427,6 +427,41 @@ class ParseObject {
|
|
|
427
427
|
static _getClassMap() {
|
|
428
428
|
return classMap;
|
|
429
429
|
}
|
|
430
|
+
static _getRequestOptions() {
|
|
431
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
432
|
+
const requestOptions = {};
|
|
433
|
+
const {
|
|
434
|
+
hasOwn
|
|
435
|
+
} = Object;
|
|
436
|
+
if (hasOwn(options, 'useMasterKey')) {
|
|
437
|
+
requestOptions.useMasterKey = !!options.useMasterKey;
|
|
438
|
+
}
|
|
439
|
+
if (hasOwn(options, 'sessionToken') && typeof options.sessionToken === 'string') {
|
|
440
|
+
requestOptions.sessionToken = options.sessionToken;
|
|
441
|
+
}
|
|
442
|
+
if (hasOwn(options, 'installationId') && typeof options.installationId === 'string') {
|
|
443
|
+
requestOptions.installationId = options.installationId;
|
|
444
|
+
}
|
|
445
|
+
if (hasOwn(options, 'transaction') && typeof options.transaction === 'boolean') {
|
|
446
|
+
requestOptions.transaction = options.transaction;
|
|
447
|
+
}
|
|
448
|
+
if (hasOwn(options, 'batchSize') && typeof options.batchSize === 'number') {
|
|
449
|
+
requestOptions.batchSize = options.batchSize;
|
|
450
|
+
}
|
|
451
|
+
if (hasOwn(options, 'context') && typeof options.context === 'object') {
|
|
452
|
+
requestOptions.context = options.context;
|
|
453
|
+
}
|
|
454
|
+
if (hasOwn(options, 'include')) {
|
|
455
|
+
requestOptions.include = ParseObject.handleIncludeOptions(options);
|
|
456
|
+
}
|
|
457
|
+
if (hasOwn(options, 'usePost')) {
|
|
458
|
+
requestOptions.usePost = options.usePost;
|
|
459
|
+
}
|
|
460
|
+
if (hasOwn(options, 'json')) {
|
|
461
|
+
requestOptions.json = options.json;
|
|
462
|
+
}
|
|
463
|
+
return requestOptions;
|
|
464
|
+
}
|
|
430
465
|
|
|
431
466
|
/* Public methods */
|
|
432
467
|
|
|
@@ -493,11 +528,11 @@ class ParseObject {
|
|
|
493
528
|
const pendingOps = this._getPendingOps();
|
|
494
529
|
const dirtyObjects = this._getDirtyObjectAttributes();
|
|
495
530
|
if (attr) {
|
|
496
|
-
if (
|
|
531
|
+
if (Object.hasOwn(dirtyObjects, attr)) {
|
|
497
532
|
return true;
|
|
498
533
|
}
|
|
499
534
|
for (let i = 0; i < pendingOps.length; i++) {
|
|
500
|
-
if (pendingOps[i]
|
|
535
|
+
if (Object.hasOwn(pendingOps[i], attr)) {
|
|
501
536
|
return true;
|
|
502
537
|
}
|
|
503
538
|
}
|
|
@@ -631,7 +666,7 @@ class ParseObject {
|
|
|
631
666
|
*/
|
|
632
667
|
has(attr) {
|
|
633
668
|
const attributes = this.attributes;
|
|
634
|
-
if (
|
|
669
|
+
if (Object.hasOwn(attributes, attr)) {
|
|
635
670
|
return attributes[attr] != null;
|
|
636
671
|
}
|
|
637
672
|
return false;
|
|
@@ -1010,7 +1045,7 @@ class ParseObject {
|
|
|
1010
1045
|
* @see Parse.Object#set
|
|
1011
1046
|
*/
|
|
1012
1047
|
validate(attrs) {
|
|
1013
|
-
if (
|
|
1048
|
+
if (Object.hasOwn(attrs, 'ACL') && !(attrs.ACL instanceof _ParseACL.default)) {
|
|
1014
1049
|
return new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'ACL must be a Parse ACL.');
|
|
1015
1050
|
}
|
|
1016
1051
|
for (const key in attrs) {
|
|
@@ -1110,33 +1145,7 @@ class ParseObject {
|
|
|
1110
1145
|
* completes.
|
|
1111
1146
|
*/
|
|
1112
1147
|
fetch(options) {
|
|
1113
|
-
|
|
1114
|
-
const fetchOptions = {};
|
|
1115
|
-
if (options.hasOwnProperty('useMasterKey')) {
|
|
1116
|
-
fetchOptions.useMasterKey = options.useMasterKey;
|
|
1117
|
-
}
|
|
1118
|
-
if (options.hasOwnProperty('sessionToken')) {
|
|
1119
|
-
fetchOptions.sessionToken = options.sessionToken;
|
|
1120
|
-
}
|
|
1121
|
-
if (options.hasOwnProperty('context') && typeof options.context === 'object') {
|
|
1122
|
-
fetchOptions.context = options.context;
|
|
1123
|
-
}
|
|
1124
|
-
if (options.hasOwnProperty('include')) {
|
|
1125
|
-
fetchOptions.include = [];
|
|
1126
|
-
if ((0, _isArray.default)(options.include)) {
|
|
1127
|
-
var _context;
|
|
1128
|
-
(0, _forEach.default)(_context = options.include).call(_context, key => {
|
|
1129
|
-
if ((0, _isArray.default)(key)) {
|
|
1130
|
-
var _context2;
|
|
1131
|
-
fetchOptions.include = (0, _concat.default)(_context2 = fetchOptions.include).call(_context2, key);
|
|
1132
|
-
} else {
|
|
1133
|
-
fetchOptions.include.push(key);
|
|
1134
|
-
}
|
|
1135
|
-
});
|
|
1136
|
-
} else {
|
|
1137
|
-
fetchOptions.include.push(options.include);
|
|
1138
|
-
}
|
|
1139
|
-
}
|
|
1148
|
+
const fetchOptions = ParseObject._getRequestOptions(options);
|
|
1140
1149
|
const controller = _CoreManager.default.getObjectController();
|
|
1141
1150
|
return controller.fetch(this, true, fetchOptions);
|
|
1142
1151
|
}
|
|
@@ -1288,23 +1297,10 @@ class ParseObject {
|
|
|
1288
1297
|
return _promise.default.reject(validationError);
|
|
1289
1298
|
}
|
|
1290
1299
|
}
|
|
1291
|
-
const saveOptions =
|
|
1292
|
-
if (options.hasOwnProperty('useMasterKey')) {
|
|
1293
|
-
saveOptions.useMasterKey = !!options.useMasterKey;
|
|
1294
|
-
}
|
|
1295
|
-
if (options.hasOwnProperty('sessionToken') && typeof options.sessionToken === 'string') {
|
|
1296
|
-
saveOptions.sessionToken = options.sessionToken;
|
|
1297
|
-
}
|
|
1298
|
-
if (options.hasOwnProperty('installationId') && typeof options.installationId === 'string') {
|
|
1299
|
-
saveOptions.installationId = options.installationId;
|
|
1300
|
-
}
|
|
1301
|
-
if (options.hasOwnProperty('context') && typeof options.context === 'object') {
|
|
1302
|
-
saveOptions.context = options.context;
|
|
1303
|
-
}
|
|
1300
|
+
const saveOptions = ParseObject._getRequestOptions(options);
|
|
1304
1301
|
const controller = _CoreManager.default.getObjectController();
|
|
1305
1302
|
const unsaved = options.cascadeSave !== false ? (0, _unsavedChildren.default)(this) : null;
|
|
1306
1303
|
if (unsaved && unsaved.length && options.transaction === true && (0, _some.default)(unsaved).call(unsaved, el => el instanceof ParseObject)) {
|
|
1307
|
-
saveOptions.transaction = options.transaction;
|
|
1308
1304
|
const unsavedFiles = [];
|
|
1309
1305
|
const unsavedObjects = [];
|
|
1310
1306
|
(0, _forEach.default)(unsaved).call(unsaved, el => {
|
|
@@ -1368,20 +1364,10 @@ class ParseObject {
|
|
|
1368
1364
|
* completes.
|
|
1369
1365
|
*/
|
|
1370
1366
|
destroy(options) {
|
|
1371
|
-
options = options || {};
|
|
1372
|
-
const destroyOptions = {};
|
|
1373
|
-
if (options.hasOwnProperty('useMasterKey')) {
|
|
1374
|
-
destroyOptions.useMasterKey = options.useMasterKey;
|
|
1375
|
-
}
|
|
1376
|
-
if (options.hasOwnProperty('sessionToken')) {
|
|
1377
|
-
destroyOptions.sessionToken = options.sessionToken;
|
|
1378
|
-
}
|
|
1379
|
-
if (options.hasOwnProperty('context') && typeof options.context === 'object') {
|
|
1380
|
-
destroyOptions.context = options.context;
|
|
1381
|
-
}
|
|
1382
1367
|
if (!this.id) {
|
|
1383
1368
|
return _promise.default.resolve();
|
|
1384
1369
|
}
|
|
1370
|
+
const destroyOptions = ParseObject._getRequestOptions(options);
|
|
1385
1371
|
return _CoreManager.default.getObjectController().destroy(this, destroyOptions);
|
|
1386
1372
|
}
|
|
1387
1373
|
|
|
@@ -1534,17 +1520,8 @@ class ParseObject {
|
|
|
1534
1520
|
*/
|
|
1535
1521
|
static fetchAll(list) {
|
|
1536
1522
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1537
|
-
const
|
|
1538
|
-
|
|
1539
|
-
queryOptions.useMasterKey = options.useMasterKey;
|
|
1540
|
-
}
|
|
1541
|
-
if (options.hasOwnProperty('sessionToken')) {
|
|
1542
|
-
queryOptions.sessionToken = options.sessionToken;
|
|
1543
|
-
}
|
|
1544
|
-
if (options.hasOwnProperty('include')) {
|
|
1545
|
-
queryOptions.include = ParseObject.handleIncludeOptions(options);
|
|
1546
|
-
}
|
|
1547
|
-
return _CoreManager.default.getObjectController().fetch(list, true, queryOptions);
|
|
1523
|
+
const fetchOptions = ParseObject._getRequestOptions(options);
|
|
1524
|
+
return _CoreManager.default.getObjectController().fetch(list, true, fetchOptions);
|
|
1548
1525
|
}
|
|
1549
1526
|
|
|
1550
1527
|
/**
|
|
@@ -1633,28 +1610,27 @@ class ParseObject {
|
|
|
1633
1610
|
*
|
|
1634
1611
|
* @param {Array} list A list of <code>Parse.Object</code>.
|
|
1635
1612
|
* @param {object} options
|
|
1613
|
+
* Valid options are:<ul>
|
|
1614
|
+
* <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
|
|
1615
|
+
* be used for this request.
|
|
1616
|
+
* <li>sessionToken: A valid session token, used for making a request on
|
|
1617
|
+
* behalf of a specific user.
|
|
1618
|
+
* <li>include: The name(s) of the key(s) to include. Can be a string, an array of strings,
|
|
1619
|
+
* or an array of array of strings.
|
|
1620
|
+
* <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
|
|
1621
|
+
* </ul>
|
|
1636
1622
|
* @static
|
|
1637
1623
|
* @returns {Parse.Object[]}
|
|
1638
1624
|
*/
|
|
1639
1625
|
static fetchAllIfNeeded(list, options) {
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
if (options.hasOwnProperty('useMasterKey')) {
|
|
1643
|
-
queryOptions.useMasterKey = options.useMasterKey;
|
|
1644
|
-
}
|
|
1645
|
-
if (options.hasOwnProperty('sessionToken')) {
|
|
1646
|
-
queryOptions.sessionToken = options.sessionToken;
|
|
1647
|
-
}
|
|
1648
|
-
if (options.hasOwnProperty('include')) {
|
|
1649
|
-
queryOptions.include = ParseObject.handleIncludeOptions(options);
|
|
1650
|
-
}
|
|
1651
|
-
return _CoreManager.default.getObjectController().fetch(list, false, queryOptions);
|
|
1626
|
+
const fetchOptions = ParseObject._getRequestOptions(options);
|
|
1627
|
+
return _CoreManager.default.getObjectController().fetch(list, false, fetchOptions);
|
|
1652
1628
|
}
|
|
1653
1629
|
static handleIncludeOptions(options) {
|
|
1654
1630
|
let include = [];
|
|
1655
1631
|
if ((0, _isArray.default)(options.include)) {
|
|
1656
|
-
var
|
|
1657
|
-
(0, _forEach.default)(
|
|
1632
|
+
var _context;
|
|
1633
|
+
(0, _forEach.default)(_context = options.include).call(_context, key => {
|
|
1658
1634
|
if ((0, _isArray.default)(key)) {
|
|
1659
1635
|
include = (0, _concat.default)(include).call(include, key);
|
|
1660
1636
|
} else {
|
|
@@ -1709,28 +1685,22 @@ class ParseObject {
|
|
|
1709
1685
|
*
|
|
1710
1686
|
* @param {Array} list A list of <code>Parse.Object</code>.
|
|
1711
1687
|
* @param {object} options
|
|
1688
|
+
* Valid options are:<ul>
|
|
1689
|
+
* <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
|
|
1690
|
+
* be used for this request.
|
|
1691
|
+
* <li>sessionToken: A valid session token, used for making a request on
|
|
1692
|
+
* behalf of a specific user.
|
|
1693
|
+
* <li>context: A dictionary that is accessible in Cloud Code `beforeDelete` and `afterDelete` triggers.
|
|
1694
|
+
* <li>transaction: Set to true to enable transactions
|
|
1695
|
+
* <li>batchSize: How many objects to yield in each batch (default: 20)
|
|
1696
|
+
* </ul>
|
|
1712
1697
|
* @static
|
|
1713
1698
|
* @returns {Promise} A promise that is fulfilled when the destroyAll
|
|
1714
1699
|
* completes.
|
|
1715
1700
|
*/
|
|
1716
1701
|
static destroyAll(list) {
|
|
1717
1702
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1718
|
-
const destroyOptions =
|
|
1719
|
-
if (options.hasOwnProperty('useMasterKey')) {
|
|
1720
|
-
destroyOptions.useMasterKey = options.useMasterKey;
|
|
1721
|
-
}
|
|
1722
|
-
if (options.hasOwnProperty('sessionToken')) {
|
|
1723
|
-
destroyOptions.sessionToken = options.sessionToken;
|
|
1724
|
-
}
|
|
1725
|
-
if (options.hasOwnProperty('transaction') && typeof options.transaction === 'boolean') {
|
|
1726
|
-
destroyOptions.transaction = options.transaction;
|
|
1727
|
-
}
|
|
1728
|
-
if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
|
|
1729
|
-
destroyOptions.batchSize = options.batchSize;
|
|
1730
|
-
}
|
|
1731
|
-
if (options.hasOwnProperty('context') && typeof options.context === 'object') {
|
|
1732
|
-
destroyOptions.context = options.context;
|
|
1733
|
-
}
|
|
1703
|
+
const destroyOptions = ParseObject._getRequestOptions(options);
|
|
1734
1704
|
return _CoreManager.default.getObjectController().destroy(list, destroyOptions);
|
|
1735
1705
|
}
|
|
1736
1706
|
|
|
@@ -1749,27 +1719,23 @@ class ParseObject {
|
|
|
1749
1719
|
*
|
|
1750
1720
|
* @param {Array} list A list of <code>Parse.Object</code>.
|
|
1751
1721
|
* @param {object} options
|
|
1722
|
+
* Valid options are:
|
|
1723
|
+
* <ul>
|
|
1724
|
+
* <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
|
|
1725
|
+
* be used for this request.
|
|
1726
|
+
* <li>sessionToken: A valid session token, used for making a request on
|
|
1727
|
+
* behalf of a specific user.
|
|
1728
|
+
* <li>cascadeSave: If `false`, nested objects will not be saved (default is `true`).
|
|
1729
|
+
* <li>context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers.
|
|
1730
|
+
* <li>transaction: Set to true to enable transactions
|
|
1731
|
+
* <li>batchSize: How many objects to yield in each batch (default: 20)
|
|
1732
|
+
* </ul>
|
|
1752
1733
|
* @static
|
|
1753
1734
|
* @returns {Parse.Object[]}
|
|
1754
1735
|
*/
|
|
1755
1736
|
static saveAll(list) {
|
|
1756
1737
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1757
|
-
const saveOptions =
|
|
1758
|
-
if (options.hasOwnProperty('useMasterKey')) {
|
|
1759
|
-
saveOptions.useMasterKey = options.useMasterKey;
|
|
1760
|
-
}
|
|
1761
|
-
if (options.hasOwnProperty('sessionToken')) {
|
|
1762
|
-
saveOptions.sessionToken = options.sessionToken;
|
|
1763
|
-
}
|
|
1764
|
-
if (options.hasOwnProperty('transaction') && typeof options.transaction === 'boolean') {
|
|
1765
|
-
saveOptions.transaction = options.transaction;
|
|
1766
|
-
}
|
|
1767
|
-
if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
|
|
1768
|
-
saveOptions.batchSize = options.batchSize;
|
|
1769
|
-
}
|
|
1770
|
-
if (options.hasOwnProperty('context') && typeof options.context === 'object') {
|
|
1771
|
-
saveOptions.context = options.context;
|
|
1772
|
-
}
|
|
1738
|
+
const saveOptions = ParseObject._getRequestOptions(options);
|
|
1773
1739
|
return _CoreManager.default.getObjectController().save(list, saveOptions);
|
|
1774
1740
|
}
|
|
1775
1741
|
|
|
@@ -1926,7 +1892,7 @@ class ParseObject {
|
|
|
1926
1892
|
adjustedClassName = '_User';
|
|
1927
1893
|
}
|
|
1928
1894
|
let parentProto = ParseObject.prototype;
|
|
1929
|
-
if (
|
|
1895
|
+
if (Object.hasOwn(this, '__super__') && this.__super__) {
|
|
1930
1896
|
parentProto = this.prototype;
|
|
1931
1897
|
}
|
|
1932
1898
|
let ParseObjectSubclass = function (attributes, options) {
|
|
@@ -2293,7 +2259,7 @@ const DefaultController = {
|
|
|
2293
2259
|
deleteCompleted = deleteCompleted.then(() => {
|
|
2294
2260
|
return RESTController.request('POST', 'batch', body, options).then(results => {
|
|
2295
2261
|
for (let i = 0; i < results.length; i++) {
|
|
2296
|
-
if (results[i] && results[i]
|
|
2262
|
+
if (results[i] && Object.hasOwn(results[i], 'error')) {
|
|
2297
2263
|
const err = new _ParseError.default(results[i].error.code, results[i].error.error);
|
|
2298
2264
|
err.object = batch[i];
|
|
2299
2265
|
errors.push(err);
|
|
@@ -2364,7 +2330,7 @@ const DefaultController = {
|
|
|
2364
2330
|
const batch = [];
|
|
2365
2331
|
const nextPending = [];
|
|
2366
2332
|
(0, _forEach.default)(pending).call(pending, el => {
|
|
2367
|
-
if (allowCustomObjectId && Object.
|
|
2333
|
+
if (allowCustomObjectId && Object.hasOwn(el, 'id') && !el.id) {
|
|
2368
2334
|
throw new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'objectId must not be empty or null');
|
|
2369
2335
|
}
|
|
2370
2336
|
if (batch.length < batchSize && (0, _canBeSerialized.default)(el)) {
|
|
@@ -2390,7 +2356,7 @@ const DefaultController = {
|
|
|
2390
2356
|
batchTasks.push(stateController.enqueueTask(obj._getStateIdentifier(), function () {
|
|
2391
2357
|
ready.resolve();
|
|
2392
2358
|
return batchReturned.then(responses => {
|
|
2393
|
-
if (responses[index]
|
|
2359
|
+
if (Object.hasOwn(responses[index], 'success')) {
|
|
2394
2360
|
const objectId = responses[index].success.objectId;
|
|
2395
2361
|
const status = responses[index]._status;
|
|
2396
2362
|
delete responses[index]._status;
|
|
@@ -2399,7 +2365,7 @@ const DefaultController = {
|
|
|
2399
2365
|
mapIdForPin[objectId] = obj._localId;
|
|
2400
2366
|
obj._handleSaveResponse(responses[index].success, status);
|
|
2401
2367
|
} else {
|
|
2402
|
-
if (!objectError && responses[index]
|
|
2368
|
+
if (!objectError && Object.hasOwn(responses[index], 'error')) {
|
|
2403
2369
|
const serverError = responses[index].error;
|
|
2404
2370
|
objectError = new _ParseError.default(serverError.code, serverError.error);
|
|
2405
2371
|
// Cancel the rest of the save
|
|
@@ -2443,7 +2409,7 @@ const DefaultController = {
|
|
|
2443
2409
|
});
|
|
2444
2410
|
});
|
|
2445
2411
|
} else if (target instanceof ParseObject) {
|
|
2446
|
-
if (allowCustomObjectId && Object.
|
|
2412
|
+
if (allowCustomObjectId && Object.hasOwn(target, 'id') && !target.id) {
|
|
2447
2413
|
throw new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'objectId must not be empty or null');
|
|
2448
2414
|
}
|
|
2449
2415
|
// generate _localId in case if cascadeSave=false
|
|
@@ -73,7 +73,7 @@ function handleSelectResult(data, select) {
|
|
|
73
73
|
const serverDataMask = {};
|
|
74
74
|
(0, _forEach.default)(select).call(select, field => {
|
|
75
75
|
const hasSubObjectSelect = (0, _indexOf.default)(field).call(field, '.') !== -1;
|
|
76
|
-
if (!hasSubObjectSelect && !
|
|
76
|
+
if (!hasSubObjectSelect && !Object.hasOwn(data, field)) {
|
|
77
77
|
// this field was selected, but is missing from the retrieved data
|
|
78
78
|
data[field] = undefined;
|
|
79
79
|
} else if (hasSubObjectSelect) {
|
|
@@ -84,7 +84,7 @@ function handleSelectResult(data, select) {
|
|
|
84
84
|
let serverMask = serverDataMask;
|
|
85
85
|
(0, _forEach.default)(pathComponents).call(pathComponents, (component, index, arr) => {
|
|
86
86
|
// add keys if the expected data is missing
|
|
87
|
-
if (obj && !
|
|
87
|
+
if (obj && !Object.hasOwn(obj, component)) {
|
|
88
88
|
obj[component] = undefined;
|
|
89
89
|
}
|
|
90
90
|
if (obj && typeof obj === 'object') {
|
|
@@ -118,7 +118,7 @@ function copyMissingDataWithMask(src, dest, mask, copyThisLevel) {
|
|
|
118
118
|
//copy missing elements at this level
|
|
119
119
|
if (copyThisLevel) {
|
|
120
120
|
for (const key in src) {
|
|
121
|
-
if (
|
|
121
|
+
if (Object.hasOwn(src, key) && !Object.hasOwn(dest, key)) {
|
|
122
122
|
dest[key] = src[key];
|
|
123
123
|
}
|
|
124
124
|
}
|
|
@@ -522,7 +522,7 @@ class ParseQuery {
|
|
|
522
522
|
this._comment = json.comment;
|
|
523
523
|
}
|
|
524
524
|
for (const key in json) {
|
|
525
|
-
if (
|
|
525
|
+
if (Object.hasOwn(json, key)) {
|
|
526
526
|
var _context3;
|
|
527
527
|
if ((0, _indexOf.default)(_context3 = ['where', 'include', 'keys', 'count', 'limit', 'skip', 'order', 'readPreference', 'includeReadPreference', 'subqueryReadPreference', 'hint', 'explain', 'comment']).call(_context3, key) === -1) {
|
|
528
528
|
this._extraOptions[key] = json[key];
|
|
@@ -564,19 +564,7 @@ class ParseQuery {
|
|
|
564
564
|
*/
|
|
565
565
|
get(objectId, options) {
|
|
566
566
|
this.equalTo('objectId', objectId);
|
|
567
|
-
const firstOptions =
|
|
568
|
-
if (options && options.hasOwnProperty('useMasterKey')) {
|
|
569
|
-
firstOptions.useMasterKey = options.useMasterKey;
|
|
570
|
-
}
|
|
571
|
-
if (options && options.hasOwnProperty('sessionToken')) {
|
|
572
|
-
firstOptions.sessionToken = options.sessionToken;
|
|
573
|
-
}
|
|
574
|
-
if (options && options.hasOwnProperty('context') && typeof options.context === 'object') {
|
|
575
|
-
firstOptions.context = options.context;
|
|
576
|
-
}
|
|
577
|
-
if (options && options.hasOwnProperty('json')) {
|
|
578
|
-
firstOptions.json = options.json;
|
|
579
|
-
}
|
|
567
|
+
const firstOptions = _ParseObject.default._getRequestOptions(options);
|
|
580
568
|
return this.first(firstOptions).then(response => {
|
|
581
569
|
if (response) {
|
|
582
570
|
return response;
|
|
@@ -602,17 +590,7 @@ class ParseQuery {
|
|
|
602
590
|
* the query completes.
|
|
603
591
|
*/
|
|
604
592
|
find(options) {
|
|
605
|
-
|
|
606
|
-
const findOptions = {};
|
|
607
|
-
if (options.hasOwnProperty('useMasterKey')) {
|
|
608
|
-
findOptions.useMasterKey = options.useMasterKey;
|
|
609
|
-
}
|
|
610
|
-
if (options.hasOwnProperty('sessionToken')) {
|
|
611
|
-
findOptions.sessionToken = options.sessionToken;
|
|
612
|
-
}
|
|
613
|
-
if (options.hasOwnProperty('context') && typeof options.context === 'object') {
|
|
614
|
-
findOptions.context = options.context;
|
|
615
|
-
}
|
|
593
|
+
const findOptions = _ParseObject.default._getRequestOptions(options);
|
|
616
594
|
this._setRequestTask(findOptions);
|
|
617
595
|
const controller = _CoreManager.default.getQueryController();
|
|
618
596
|
const select = this._select;
|
|
@@ -638,7 +616,7 @@ class ParseQuery {
|
|
|
638
616
|
if (select) {
|
|
639
617
|
handleSelectResult(data, select);
|
|
640
618
|
}
|
|
641
|
-
if (
|
|
619
|
+
if (findOptions.json) {
|
|
642
620
|
return data;
|
|
643
621
|
} else {
|
|
644
622
|
return _ParseObject.default.fromJSON(data, !select);
|
|
@@ -666,6 +644,7 @@ class ParseQuery {
|
|
|
666
644
|
* be used for this request.
|
|
667
645
|
* <li>sessionToken: A valid session token, used for making a request on
|
|
668
646
|
* behalf of a specific user.
|
|
647
|
+
* <li>json: Return raw JSON without converting to Parse.Object.
|
|
669
648
|
* </ul>
|
|
670
649
|
* @returns {Promise} A promise that is resolved with the results when
|
|
671
650
|
* the query completes.
|
|
@@ -695,13 +674,7 @@ class ParseQuery {
|
|
|
695
674
|
*/
|
|
696
675
|
count(options) {
|
|
697
676
|
options = options || {};
|
|
698
|
-
const findOptions =
|
|
699
|
-
if (options.hasOwnProperty('useMasterKey')) {
|
|
700
|
-
findOptions.useMasterKey = options.useMasterKey;
|
|
701
|
-
}
|
|
702
|
-
if (options.hasOwnProperty('sessionToken')) {
|
|
703
|
-
findOptions.sessionToken = options.sessionToken;
|
|
704
|
-
}
|
|
677
|
+
const findOptions = _ParseObject.default._getRequestOptions(options);
|
|
705
678
|
this._setRequestTask(findOptions);
|
|
706
679
|
const controller = _CoreManager.default.getQueryController();
|
|
707
680
|
const params = this.toJSON();
|
|
@@ -725,7 +698,7 @@ class ParseQuery {
|
|
|
725
698
|
const distinctOptions = {
|
|
726
699
|
useMasterKey: true
|
|
727
700
|
};
|
|
728
|
-
if (
|
|
701
|
+
if (Object.hasOwn(options, 'sessionToken')) {
|
|
729
702
|
distinctOptions.sessionToken = options.sessionToken;
|
|
730
703
|
}
|
|
731
704
|
this._setRequestTask(distinctOptions);
|
|
@@ -753,7 +726,7 @@ class ParseQuery {
|
|
|
753
726
|
const aggregateOptions = {
|
|
754
727
|
useMasterKey: true
|
|
755
728
|
};
|
|
756
|
-
if (
|
|
729
|
+
if (Object.hasOwn(options, 'sessionToken')) {
|
|
757
730
|
aggregateOptions.sessionToken = options.sessionToken;
|
|
758
731
|
}
|
|
759
732
|
this._setRequestTask(aggregateOptions);
|
|
@@ -798,16 +771,7 @@ class ParseQuery {
|
|
|
798
771
|
*/
|
|
799
772
|
first() {
|
|
800
773
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
801
|
-
const findOptions =
|
|
802
|
-
if (options.hasOwnProperty('useMasterKey')) {
|
|
803
|
-
findOptions.useMasterKey = options.useMasterKey;
|
|
804
|
-
}
|
|
805
|
-
if (options.hasOwnProperty('sessionToken')) {
|
|
806
|
-
findOptions.sessionToken = options.sessionToken;
|
|
807
|
-
}
|
|
808
|
-
if (options.hasOwnProperty('context') && typeof options.context === 'object') {
|
|
809
|
-
findOptions.context = options.context;
|
|
810
|
-
}
|
|
774
|
+
const findOptions = _ParseObject.default._getRequestOptions(options);
|
|
811
775
|
this._setRequestTask(findOptions);
|
|
812
776
|
const controller = _CoreManager.default.getQueryController();
|
|
813
777
|
const params = this.toJSON();
|
|
@@ -836,7 +800,7 @@ class ParseQuery {
|
|
|
836
800
|
if (select) {
|
|
837
801
|
handleSelectResult(objects[0], select);
|
|
838
802
|
}
|
|
839
|
-
if (
|
|
803
|
+
if (findOptions.json) {
|
|
840
804
|
return objects[0];
|
|
841
805
|
} else {
|
|
842
806
|
return _ParseObject.default.fromJSON(objects[0], !select);
|
|
@@ -870,45 +834,10 @@ class ParseQuery {
|
|
|
870
834
|
if (this._order || this._skip || this._limit >= 0) {
|
|
871
835
|
return _promise.default.reject('Cannot iterate on a query with sort, skip, or limit.');
|
|
872
836
|
}
|
|
873
|
-
const query =
|
|
874
|
-
query._limit = options.batchSize || 100;
|
|
875
|
-
query._include = [...this._include];
|
|
876
|
-
query._exclude = [...this._exclude];
|
|
877
|
-
if (this._select) {
|
|
878
|
-
query._select = [...this._select];
|
|
879
|
-
}
|
|
880
|
-
query._hint = this._hint;
|
|
881
|
-
query._where = {};
|
|
882
|
-
for (const attr in this._where) {
|
|
883
|
-
const val = this._where[attr];
|
|
884
|
-
if ((0, _isArray.default)(val)) {
|
|
885
|
-
query._where[attr] = (0, _map.default)(val).call(val, v => {
|
|
886
|
-
return v;
|
|
887
|
-
});
|
|
888
|
-
} else if (val && typeof val === 'object') {
|
|
889
|
-
const conditionMap = {};
|
|
890
|
-
query._where[attr] = conditionMap;
|
|
891
|
-
for (const cond in val) {
|
|
892
|
-
conditionMap[cond] = val[cond];
|
|
893
|
-
}
|
|
894
|
-
} else {
|
|
895
|
-
query._where[attr] = val;
|
|
896
|
-
}
|
|
897
|
-
}
|
|
837
|
+
const query = ParseQuery.fromJSON(this.className, this.toJSON());
|
|
898
838
|
query.ascending('objectId');
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
findOptions.useMasterKey = options.useMasterKey;
|
|
902
|
-
}
|
|
903
|
-
if (options.hasOwnProperty('sessionToken')) {
|
|
904
|
-
findOptions.sessionToken = options.sessionToken;
|
|
905
|
-
}
|
|
906
|
-
if (options.hasOwnProperty('context') && typeof options.context === 'object') {
|
|
907
|
-
findOptions.context = options.context;
|
|
908
|
-
}
|
|
909
|
-
if (options.hasOwnProperty('json')) {
|
|
910
|
-
findOptions.json = options.json;
|
|
911
|
-
}
|
|
839
|
+
query._limit = options.batchSize || 100;
|
|
840
|
+
const findOptions = _ParseObject.default._getRequestOptions(options);
|
|
912
841
|
let finished = false;
|
|
913
842
|
let previousResults = [];
|
|
914
843
|
return (0, _promiseUtils.continueWhile)(() => {
|
|
@@ -916,7 +845,11 @@ class ParseQuery {
|
|
|
916
845
|
}, async () => {
|
|
917
846
|
const [results] = await _promise.default.all([(0, _find.default)(query).call(query, findOptions), _promise.default.resolve(previousResults.length > 0 && callback(previousResults))]);
|
|
918
847
|
if (results.length >= query._limit) {
|
|
919
|
-
|
|
848
|
+
if (findOptions.json) {
|
|
849
|
+
query.greaterThan('objectId', results[results.length - 1].objectId);
|
|
850
|
+
} else {
|
|
851
|
+
query.greaterThan('objectId', results[results.length - 1].id);
|
|
852
|
+
}
|
|
920
853
|
previousResults = results;
|
|
921
854
|
} else if (results.length > 0) {
|
|
922
855
|
await _promise.default.resolve(callback(results));
|
|
@@ -58,12 +58,8 @@ class ParseSession extends _ParseObject.default {
|
|
|
58
58
|
* promise will be rejected.
|
|
59
59
|
*/
|
|
60
60
|
static current(options) {
|
|
61
|
-
options = options || {};
|
|
62
61
|
const controller = _CoreManager.default.getSessionController();
|
|
63
|
-
const sessionOptions =
|
|
64
|
-
if (options.hasOwnProperty('useMasterKey')) {
|
|
65
|
-
sessionOptions.useMasterKey = options.useMasterKey;
|
|
66
|
-
}
|
|
62
|
+
const sessionOptions = _ParseObject.default._getRequestOptions(options);
|
|
67
63
|
return _ParseUser.default.currentAsync().then(user => {
|
|
68
64
|
if (!user) {
|
|
69
65
|
return _promise.default.reject('There is no current user.');
|