parse 5.3.0-alpha.5 → 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.
Files changed (46) hide show
  1. package/README.md +4 -4
  2. package/dist/parse.js +171 -296
  3. package/dist/parse.min.js +2 -2
  4. package/dist/parse.weapp.js +171 -296
  5. package/dist/parse.weapp.min.js +2 -2
  6. package/lib/browser/Cloud.js +12 -16
  7. package/lib/browser/CoreManager.js +3 -3
  8. package/lib/browser/ParseFile.js +1 -1
  9. package/lib/browser/ParseObject.js +86 -120
  10. package/lib/browser/ParseQuery.js +21 -88
  11. package/lib/browser/ParseSession.js +1 -5
  12. package/lib/browser/ParseUser.js +40 -56
  13. package/lib/browser/Push.js +2 -2
  14. package/lib/browser/Storage.js +1 -1
  15. package/lib/browser/StorageController.default.js +2 -2
  16. package/lib/node/Cloud.js +12 -16
  17. package/lib/node/CoreManager.js +3 -3
  18. package/lib/node/ParseFile.js +1 -1
  19. package/lib/node/ParseObject.js +82 -115
  20. package/lib/node/ParseQuery.js +21 -88
  21. package/lib/node/ParseSession.js +1 -5
  22. package/lib/node/ParseUser.js +40 -56
  23. package/lib/node/Push.js +2 -2
  24. package/lib/node/Storage.js +1 -1
  25. package/lib/node/StorageController.default.js +2 -2
  26. package/lib/react-native/Cloud.js +4 -16
  27. package/lib/react-native/CoreManager.js +3 -3
  28. package/lib/react-native/ParseFile.js +1 -1
  29. package/lib/react-native/ParseObject.js +54 -115
  30. package/lib/react-native/ParseQuery.js +20 -88
  31. package/lib/react-native/ParseSession.js +1 -5
  32. package/lib/react-native/ParseUser.js +13 -56
  33. package/lib/react-native/Push.js +2 -2
  34. package/lib/react-native/Storage.js +1 -1
  35. package/lib/react-native/StorageController.default.js +2 -2
  36. package/lib/weapp/Cloud.js +12 -16
  37. package/lib/weapp/CoreManager.js +3 -3
  38. package/lib/weapp/ParseFile.js +1 -1
  39. package/lib/weapp/ParseObject.js +86 -120
  40. package/lib/weapp/ParseQuery.js +21 -88
  41. package/lib/weapp/ParseSession.js +1 -5
  42. package/lib/weapp/ParseUser.js +40 -56
  43. package/lib/weapp/Push.js +2 -2
  44. package/lib/weapp/Storage.js +1 -1
  45. package/lib/weapp/StorageController.default.js +2 -2
  46. package/package.json +5 -5
@@ -47,15 +47,15 @@ class ParseUser extends _ParseObject.default {
47
47
  * Request a revocable session token to replace the older style of token.
48
48
  *
49
49
  * @param {object} options
50
+ * Valid options are:<ul>
51
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
52
+ * be used for this request.
53
+ * </ul>
50
54
  * @returns {Promise} A promise that is resolved when the replacement
51
55
  * token has been fetched.
52
56
  */
53
57
  _upgradeToRevocableSession(options) {
54
- options = options || {};
55
- const upgradeOptions = {};
56
- if (options.hasOwnProperty('useMasterKey')) {
57
- upgradeOptions.useMasterKey = options.useMasterKey;
58
- }
58
+ const upgradeOptions = _ParseObject.default._getRequestOptions(options);
59
59
  const controller = _CoreManager.default.getUserController();
60
60
  return controller.upgradeToRevocableSession(this, upgradeOptions);
61
61
  }
@@ -99,7 +99,7 @@ class ParseUser extends _ParseObject.default {
99
99
  } else {
100
100
  authType = provider.getAuthType();
101
101
  }
102
- if (options && options.hasOwnProperty('authData')) {
102
+ if (options && Object.hasOwn(options, 'authData')) {
103
103
  const authData = this.get('authData') || {};
104
104
  if (typeof authData !== 'object') {
105
105
  throw new Error('Invalid type: authData field should be an object');
@@ -305,7 +305,7 @@ class ParseUser extends _ParseObject.default {
305
305
  }
306
306
  stripAnonymity() {
307
307
  const authData = this.get('authData');
308
- if (authData && typeof authData === 'object' && authData.hasOwnProperty('anonymous')) {
308
+ if (authData && typeof authData === 'object' && Object.hasOwn(authData, 'anonymous')) {
309
309
  // We need to set anonymous to null instead of deleting it in order to remove it from Parse.
310
310
  authData.anonymous = null;
311
311
  }
@@ -407,21 +407,17 @@ class ParseUser extends _ParseObject.default {
407
407
  *
408
408
  * @param {object} attrs Extra fields to set on the new user, or null.
409
409
  * @param {object} options
410
+ * Valid options are:<ul>
411
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
412
+ * be used for this request.
413
+ * <li>installationId: the installationId which made the request
414
+ * <li>context: A dictionary that is accessible in Cloud Code `beforeLogin` and `afterLogin` triggers.
415
+ * </ul>
410
416
  * @returns {Promise} A promise that is fulfilled when the signup
411
417
  * finishes.
412
418
  */
413
419
  signUp(attrs, options) {
414
- options = options || {};
415
- const signupOptions = {};
416
- if (options.hasOwnProperty('useMasterKey')) {
417
- signupOptions.useMasterKey = options.useMasterKey;
418
- }
419
- if (options.hasOwnProperty('installationId')) {
420
- signupOptions.installationId = options.installationId;
421
- }
422
- if (options.hasOwnProperty('context') && Object.prototype.toString.call(options.context) === '[object Object]') {
423
- signupOptions.context = options.context;
424
- }
420
+ const signupOptions = _ParseObject.default._getRequestOptions(options);
425
421
  const controller = _CoreManager.default.getUserController();
426
422
  return controller.signUp(this, attrs, signupOptions);
427
423
  }
@@ -434,26 +430,21 @@ class ParseUser extends _ParseObject.default {
434
430
  * <p>A username and password must be set before calling logIn.</p>
435
431
  *
436
432
  * @param {object} options
433
+ * Valid options are:<ul>
434
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
435
+ * be used for this request.
436
+ * <li>usePost: Use POST method to make the request (default: true)
437
+ * <li>installationId: the installationId which made the request
438
+ * <li>context: A dictionary that is accessible in Cloud Code `beforeLogin` and `afterLogin` triggers.
439
+ * </ul>
437
440
  * @returns {Promise} A promise that is fulfilled with the user when
438
441
  * the login is complete.
439
442
  */
440
443
  logIn() {
441
444
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
442
- options = options || {};
443
- const loginOptions = {
444
- usePost: true
445
- };
446
- if (options.hasOwnProperty('useMasterKey')) {
447
- loginOptions.useMasterKey = options.useMasterKey;
448
- }
449
- if (options.hasOwnProperty('installationId')) {
450
- loginOptions.installationId = options.installationId;
451
- }
452
- if (options.hasOwnProperty('usePost')) {
453
- loginOptions.usePost = options.usePost;
454
- }
455
- if (options.hasOwnProperty('context') && Object.prototype.toString.call(options.context) === '[object Object]') {
456
- loginOptions.context = options.context;
445
+ const loginOptions = _ParseObject.default._getRequestOptions(options);
446
+ if (!Object.hasOwn(loginOptions, 'usePost')) {
447
+ loginOptions.usePost = true;
457
448
  }
458
449
  const controller = _CoreManager.default.getUserController();
459
450
  return controller.logIn(this, loginOptions);
@@ -724,6 +715,7 @@ class ParseUser extends _ParseObject.default {
724
715
  *
725
716
  * @param {string} sessionToken The sessionToken to log in with.
726
717
  * @param {object} options
718
+ * @param {boolean} [options.useMasterKey]
727
719
  * @static
728
720
  * @returns {Promise} A promise that is fulfilled with the user when
729
721
  * the login completes.
@@ -732,13 +724,8 @@ class ParseUser extends _ParseObject.default {
732
724
  if (!canUseCurrentUser) {
733
725
  throw new Error('It is not memory-safe to become a user in a server environment');
734
726
  }
735
- options = options || {};
736
- const becomeOptions = {
737
- sessionToken: sessionToken
738
- };
739
- if (options.hasOwnProperty('useMasterKey')) {
740
- becomeOptions.useMasterKey = options.useMasterKey;
741
- }
727
+ const becomeOptions = _ParseObject.default._getRequestOptions(options);
728
+ becomeOptions.sessionToken = sessionToken;
742
729
  const controller = _CoreManager.default.getUserController();
743
730
  const user = new this();
744
731
  return controller.become(user, becomeOptions);
@@ -749,18 +736,15 @@ class ParseUser extends _ParseObject.default {
749
736
  *
750
737
  * @param {string} sessionToken The sessionToken to get user with.
751
738
  * @param {object} options
739
+ * @param {boolean} [options.useMasterKey]
752
740
  * @static
753
741
  * @returns {Promise} A promise that is fulfilled with the user is fetched.
754
742
  */
755
743
  static me(sessionToken) {
756
744
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
757
745
  const controller = _CoreManager.default.getUserController();
758
- const meOptions = {
759
- sessionToken: sessionToken
760
- };
761
- if (options.useMasterKey) {
762
- meOptions.useMasterKey = options.useMasterKey;
763
- }
746
+ const meOptions = _ParseObject.default._getRequestOptions(options);
747
+ meOptions.sessionToken = sessionToken;
764
748
  const user = new this();
765
749
  return controller.me(user, meOptions);
766
750
  }
@@ -820,15 +804,15 @@ class ParseUser extends _ParseObject.default {
820
804
  * @param {string} email The email address associated with the user that
821
805
  * forgot their password.
822
806
  * @param {object} options
807
+ * Valid options are:<ul>
808
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
809
+ * be used for this request.
810
+ * </ul>
823
811
  * @static
824
812
  * @returns {Promise}
825
813
  */
826
814
  static requestPasswordReset(email, options) {
827
- options = options || {};
828
- const requestOptions = {};
829
- if (options.hasOwnProperty('useMasterKey')) {
830
- requestOptions.useMasterKey = options.useMasterKey;
831
- }
815
+ const requestOptions = _ParseObject.default._getRequestOptions(options);
832
816
  const controller = _CoreManager.default.getUserController();
833
817
  return controller.requestPasswordReset(email, requestOptions);
834
818
  }
@@ -839,15 +823,15 @@ class ParseUser extends _ParseObject.default {
839
823
  * @param {string} email The email address associated with the user that
840
824
  * needs to verify their email.
841
825
  * @param {object} options
826
+ * Valid options are:<ul>
827
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
828
+ * be used for this request.
829
+ * </ul>
842
830
  * @static
843
831
  * @returns {Promise}
844
832
  */
845
833
  static requestEmailVerification(email, options) {
846
- options = options || {};
847
- const requestOptions = {};
848
- if (options.hasOwnProperty('useMasterKey')) {
849
- requestOptions.useMasterKey = options.useMasterKey;
850
- }
834
+ const requestOptions = _ParseObject.default._getRequestOptions(options);
851
835
  const controller = _CoreManager.default.getUserController();
852
836
  return controller.requestEmailVerification(email, requestOptions);
853
837
  }
@@ -62,7 +62,7 @@ function send(data) {
62
62
  const pushOptions = {
63
63
  useMasterKey: true
64
64
  };
65
- if (options.hasOwnProperty('useMasterKey')) {
65
+ if (Object.hasOwn(options, 'useMasterKey')) {
66
66
  pushOptions.useMasterKey = options.useMasterKey;
67
67
  }
68
68
  return _CoreManager.default.getPushController().send(data, pushOptions);
@@ -86,7 +86,7 @@ function getPushStatus(pushStatusId) {
86
86
  const pushOptions = {
87
87
  useMasterKey: true
88
88
  };
89
- if (options.hasOwnProperty('useMasterKey')) {
89
+ if (Object.hasOwn(options, 'useMasterKey')) {
90
90
  pushOptions.useMasterKey = options.useMasterKey;
91
91
  }
92
92
  const query = new _ParseQuery.default('_PushStatus');
@@ -83,7 +83,7 @@ const Storage = {
83
83
  },
84
84
  _clear() {
85
85
  const controller = _CoreManager.default.getStorageController();
86
- if (controller.hasOwnProperty('clear')) {
86
+ if (Object.hasOwn(controller, 'clear')) {
87
87
  controller.clear();
88
88
  }
89
89
  }
@@ -12,7 +12,7 @@ const memMap = {};
12
12
  const StorageController = {
13
13
  async: 0,
14
14
  getItem(path) {
15
- if (memMap.hasOwnProperty(path)) {
15
+ if (Object.hasOwn(memMap, path)) {
16
16
  return memMap[path];
17
17
  }
18
18
  return null;
@@ -28,7 +28,7 @@ const StorageController = {
28
28
  },
29
29
  clear() {
30
30
  for (const key in memMap) {
31
- if (memMap.hasOwnProperty(key)) {
31
+ if (Object.hasOwn(memMap, key)) {
32
32
  delete memMap[key];
33
33
  }
34
34
  }
package/lib/node/Cloud.js CHANGED
@@ -12,6 +12,7 @@ var _decode = _interopRequireDefault(require("./decode"));
12
12
  var _encode = _interopRequireDefault(require("./encode"));
13
13
  var _ParseError = _interopRequireDefault(require("./ParseError"));
14
14
  var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
15
+ var _ParseObject = _interopRequireDefault(require("./ParseObject"));
15
16
  function _interopRequireDefault(e) {
16
17
  return e && e.__esModule ? e : {
17
18
  default: e
@@ -37,27 +38,22 @@ function _interopRequireDefault(e) {
37
38
  * @param {string} name The function name.
38
39
  * @param {object} data The parameters to send to the cloud function.
39
40
  * @param {object} options
41
+ * Valid options are:<ul>
42
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
43
+ * be used for this request.
44
+ * <li>sessionToken: A valid session token, used for making a request on
45
+ * behalf of a specific user.
46
+ * <li>installationId: the installationId which made the request
47
+ * <li>context: A dictionary that is accessible in Cloud Code triggers.
48
+ * </ul>
40
49
  * @returns {Promise} A promise that will be resolved with the result
41
50
  * of the function.
42
51
  */
43
52
  function run(name, data, options) {
44
- options = options || {};
45
53
  if (typeof name !== 'string' || name.length === 0) {
46
54
  throw new TypeError('Cloud function name must be a string.');
47
55
  }
48
- const requestOptions = {};
49
- if (options.hasOwnProperty('useMasterKey')) {
50
- requestOptions.useMasterKey = !!options.useMasterKey;
51
- }
52
- if (options.sessionToken) {
53
- requestOptions.sessionToken = options.sessionToken;
54
- }
55
- if (options.installationId) {
56
- requestOptions.installationId = options.installationId;
57
- }
58
- if (options.context && typeof options.context === 'object') {
59
- requestOptions.context = options.context;
60
- }
56
+ const requestOptions = _ParseObject.default._getRequestOptions(options);
61
57
  return _CoreManager.default.getCloudController().run(name, data, requestOptions);
62
58
  }
63
59
 
@@ -114,11 +110,11 @@ const DefaultController = {
114
110
  const payload = (0, _encode.default)(data, true);
115
111
  const request = RESTController.request('POST', 'functions/' + name, payload, options);
116
112
  return request.then(res => {
117
- if (typeof res === 'object' && Object.keys(res).length > 0 && !res.hasOwnProperty('result')) {
113
+ if (typeof res === 'object' && Object.keys(res).length > 0 && !Object.hasOwn(res, 'result')) {
118
114
  throw new _ParseError.default(_ParseError.default.INVALID_JSON, 'The server returned an invalid response.');
119
115
  }
120
116
  const decoded = (0, _decode.default)(res);
121
- if (decoded && decoded.hasOwnProperty('result')) {
117
+ if (decoded && Object.hasOwn(decoded, 'result')) {
122
118
  return Promise.resolve(decoded.result);
123
119
  }
124
120
  return Promise.resolve(undefined);
@@ -16,7 +16,7 @@ const config = {
16
16
  SERVER_AUTH_TOKEN: null,
17
17
  LIVEQUERY_SERVER_URL: null,
18
18
  ENCRYPTED_KEY: null,
19
- VERSION: 'js' + "5.3.0-alpha.5",
19
+ VERSION: 'js' + "5.3.0-alpha.6",
20
20
  APPLICATION_ID: null,
21
21
  JAVASCRIPT_KEY: null,
22
22
  MASTER_KEY: null,
@@ -37,7 +37,7 @@ function requireMethods(name, methods, controller) {
37
37
  }
38
38
  const CoreManager = {
39
39
  get: function (key) {
40
- if (config.hasOwnProperty(key)) {
40
+ if (Object.hasOwn(config, key)) {
41
41
  return config[key];
42
42
  }
43
43
  throw new Error('Configuration key not found: ' + key);
@@ -46,7 +46,7 @@ const CoreManager = {
46
46
  config[key] = value;
47
47
  },
48
48
  setIfNeeded: function (key, value) {
49
- if (!config.hasOwnProperty(key)) {
49
+ if (!Object.hasOwn(config, key)) {
50
50
  config[key] = value;
51
51
  }
52
52
  return config[key];
@@ -285,7 +285,7 @@ class ParseFile {
285
285
  const destroyOptions = {
286
286
  useMasterKey: true
287
287
  };
288
- if (options.hasOwnProperty('useMasterKey')) {
288
+ if (Object.hasOwn(options, 'useMasterKey')) {
289
289
  destroyOptions.useMasterKey = !!options.useMasterKey;
290
290
  }
291
291
  const controller = _CoreManager.default.getFileController();
@@ -411,6 +411,40 @@ class ParseObject {
411
411
  static _getClassMap() {
412
412
  return classMap;
413
413
  }
414
+ static _getRequestOptions(options = {}) {
415
+ const requestOptions = {};
416
+ const {
417
+ hasOwn
418
+ } = Object;
419
+ if (hasOwn(options, 'useMasterKey')) {
420
+ requestOptions.useMasterKey = !!options.useMasterKey;
421
+ }
422
+ if (hasOwn(options, 'sessionToken') && typeof options.sessionToken === 'string') {
423
+ requestOptions.sessionToken = options.sessionToken;
424
+ }
425
+ if (hasOwn(options, 'installationId') && typeof options.installationId === 'string') {
426
+ requestOptions.installationId = options.installationId;
427
+ }
428
+ if (hasOwn(options, 'transaction') && typeof options.transaction === 'boolean') {
429
+ requestOptions.transaction = options.transaction;
430
+ }
431
+ if (hasOwn(options, 'batchSize') && typeof options.batchSize === 'number') {
432
+ requestOptions.batchSize = options.batchSize;
433
+ }
434
+ if (hasOwn(options, 'context') && typeof options.context === 'object') {
435
+ requestOptions.context = options.context;
436
+ }
437
+ if (hasOwn(options, 'include')) {
438
+ requestOptions.include = ParseObject.handleIncludeOptions(options);
439
+ }
440
+ if (hasOwn(options, 'usePost')) {
441
+ requestOptions.usePost = options.usePost;
442
+ }
443
+ if (hasOwn(options, 'json')) {
444
+ requestOptions.json = options.json;
445
+ }
446
+ return requestOptions;
447
+ }
414
448
 
415
449
  /* Public methods */
416
450
 
@@ -477,11 +511,11 @@ class ParseObject {
477
511
  const pendingOps = this._getPendingOps();
478
512
  const dirtyObjects = this._getDirtyObjectAttributes();
479
513
  if (attr) {
480
- if (dirtyObjects.hasOwnProperty(attr)) {
514
+ if (Object.hasOwn(dirtyObjects, attr)) {
481
515
  return true;
482
516
  }
483
517
  for (let i = 0; i < pendingOps.length; i++) {
484
- if (pendingOps[i].hasOwnProperty(attr)) {
518
+ if (Object.hasOwn(pendingOps[i], attr)) {
485
519
  return true;
486
520
  }
487
521
  }
@@ -615,7 +649,7 @@ class ParseObject {
615
649
  */
616
650
  has(attr) {
617
651
  const attributes = this.attributes;
618
- if (attributes.hasOwnProperty(attr)) {
652
+ if (Object.hasOwn(attributes, attr)) {
619
653
  return attributes[attr] != null;
620
654
  }
621
655
  return false;
@@ -994,7 +1028,7 @@ class ParseObject {
994
1028
  * @see Parse.Object#set
995
1029
  */
996
1030
  validate(attrs) {
997
- if (attrs.hasOwnProperty('ACL') && !(attrs.ACL instanceof _ParseACL.default)) {
1031
+ if (Object.hasOwn(attrs, 'ACL') && !(attrs.ACL instanceof _ParseACL.default)) {
998
1032
  return new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'ACL must be a Parse ACL.');
999
1033
  }
1000
1034
  for (const key in attrs) {
@@ -1091,31 +1125,7 @@ class ParseObject {
1091
1125
  * completes.
1092
1126
  */
1093
1127
  fetch(options) {
1094
- options = options || {};
1095
- const fetchOptions = {};
1096
- if (options.hasOwnProperty('useMasterKey')) {
1097
- fetchOptions.useMasterKey = options.useMasterKey;
1098
- }
1099
- if (options.hasOwnProperty('sessionToken')) {
1100
- fetchOptions.sessionToken = options.sessionToken;
1101
- }
1102
- if (options.hasOwnProperty('context') && typeof options.context === 'object') {
1103
- fetchOptions.context = options.context;
1104
- }
1105
- if (options.hasOwnProperty('include')) {
1106
- fetchOptions.include = [];
1107
- if (Array.isArray(options.include)) {
1108
- options.include.forEach(key => {
1109
- if (Array.isArray(key)) {
1110
- fetchOptions.include = fetchOptions.include.concat(key);
1111
- } else {
1112
- fetchOptions.include.push(key);
1113
- }
1114
- });
1115
- } else {
1116
- fetchOptions.include.push(options.include);
1117
- }
1118
- }
1128
+ const fetchOptions = ParseObject._getRequestOptions(options);
1119
1129
  const controller = _CoreManager.default.getObjectController();
1120
1130
  return controller.fetch(this, true, fetchOptions);
1121
1131
  }
@@ -1267,23 +1277,10 @@ class ParseObject {
1267
1277
  return Promise.reject(validationError);
1268
1278
  }
1269
1279
  }
1270
- const saveOptions = {};
1271
- if (options.hasOwnProperty('useMasterKey')) {
1272
- saveOptions.useMasterKey = !!options.useMasterKey;
1273
- }
1274
- if (options.hasOwnProperty('sessionToken') && typeof options.sessionToken === 'string') {
1275
- saveOptions.sessionToken = options.sessionToken;
1276
- }
1277
- if (options.hasOwnProperty('installationId') && typeof options.installationId === 'string') {
1278
- saveOptions.installationId = options.installationId;
1279
- }
1280
- if (options.hasOwnProperty('context') && typeof options.context === 'object') {
1281
- saveOptions.context = options.context;
1282
- }
1280
+ const saveOptions = ParseObject._getRequestOptions(options);
1283
1281
  const controller = _CoreManager.default.getObjectController();
1284
1282
  const unsaved = options.cascadeSave !== false ? (0, _unsavedChildren.default)(this) : null;
1285
1283
  if (unsaved && unsaved.length && options.transaction === true && unsaved.some(el => el instanceof ParseObject)) {
1286
- saveOptions.transaction = options.transaction;
1287
1284
  const unsavedFiles = [];
1288
1285
  const unsavedObjects = [];
1289
1286
  unsaved.forEach(el => {
@@ -1347,20 +1344,10 @@ class ParseObject {
1347
1344
  * completes.
1348
1345
  */
1349
1346
  destroy(options) {
1350
- options = options || {};
1351
- const destroyOptions = {};
1352
- if (options.hasOwnProperty('useMasterKey')) {
1353
- destroyOptions.useMasterKey = options.useMasterKey;
1354
- }
1355
- if (options.hasOwnProperty('sessionToken')) {
1356
- destroyOptions.sessionToken = options.sessionToken;
1357
- }
1358
- if (options.hasOwnProperty('context') && typeof options.context === 'object') {
1359
- destroyOptions.context = options.context;
1360
- }
1361
1347
  if (!this.id) {
1362
1348
  return Promise.resolve();
1363
1349
  }
1350
+ const destroyOptions = ParseObject._getRequestOptions(options);
1364
1351
  return _CoreManager.default.getObjectController().destroy(this, destroyOptions);
1365
1352
  }
1366
1353
 
@@ -1512,17 +1499,8 @@ class ParseObject {
1512
1499
  * @returns {Parse.Object[]}
1513
1500
  */
1514
1501
  static fetchAll(list, options = {}) {
1515
- const queryOptions = {};
1516
- if (options.hasOwnProperty('useMasterKey')) {
1517
- queryOptions.useMasterKey = options.useMasterKey;
1518
- }
1519
- if (options.hasOwnProperty('sessionToken')) {
1520
- queryOptions.sessionToken = options.sessionToken;
1521
- }
1522
- if (options.hasOwnProperty('include')) {
1523
- queryOptions.include = ParseObject.handleIncludeOptions(options);
1524
- }
1525
- return _CoreManager.default.getObjectController().fetch(list, true, queryOptions);
1502
+ const fetchOptions = ParseObject._getRequestOptions(options);
1503
+ return _CoreManager.default.getObjectController().fetch(list, true, fetchOptions);
1526
1504
  }
1527
1505
 
1528
1506
  /**
@@ -1611,22 +1589,21 @@ class ParseObject {
1611
1589
  *
1612
1590
  * @param {Array} list A list of <code>Parse.Object</code>.
1613
1591
  * @param {object} options
1592
+ * Valid options are:<ul>
1593
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
1594
+ * be used for this request.
1595
+ * <li>sessionToken: A valid session token, used for making a request on
1596
+ * behalf of a specific user.
1597
+ * <li>include: The name(s) of the key(s) to include. Can be a string, an array of strings,
1598
+ * or an array of array of strings.
1599
+ * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
1600
+ * </ul>
1614
1601
  * @static
1615
1602
  * @returns {Parse.Object[]}
1616
1603
  */
1617
1604
  static fetchAllIfNeeded(list, options) {
1618
- options = options || {};
1619
- const queryOptions = {};
1620
- if (options.hasOwnProperty('useMasterKey')) {
1621
- queryOptions.useMasterKey = options.useMasterKey;
1622
- }
1623
- if (options.hasOwnProperty('sessionToken')) {
1624
- queryOptions.sessionToken = options.sessionToken;
1625
- }
1626
- if (options.hasOwnProperty('include')) {
1627
- queryOptions.include = ParseObject.handleIncludeOptions(options);
1628
- }
1629
- return _CoreManager.default.getObjectController().fetch(list, false, queryOptions);
1605
+ const fetchOptions = ParseObject._getRequestOptions(options);
1606
+ return _CoreManager.default.getObjectController().fetch(list, false, fetchOptions);
1630
1607
  }
1631
1608
  static handleIncludeOptions(options) {
1632
1609
  let include = [];
@@ -1686,27 +1663,21 @@ class ParseObject {
1686
1663
  *
1687
1664
  * @param {Array} list A list of <code>Parse.Object</code>.
1688
1665
  * @param {object} options
1666
+ * Valid options are:<ul>
1667
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
1668
+ * be used for this request.
1669
+ * <li>sessionToken: A valid session token, used for making a request on
1670
+ * behalf of a specific user.
1671
+ * <li>context: A dictionary that is accessible in Cloud Code `beforeDelete` and `afterDelete` triggers.
1672
+ * <li>transaction: Set to true to enable transactions
1673
+ * <li>batchSize: How many objects to yield in each batch (default: 20)
1674
+ * </ul>
1689
1675
  * @static
1690
1676
  * @returns {Promise} A promise that is fulfilled when the destroyAll
1691
1677
  * completes.
1692
1678
  */
1693
1679
  static destroyAll(list, options = {}) {
1694
- const destroyOptions = {};
1695
- if (options.hasOwnProperty('useMasterKey')) {
1696
- destroyOptions.useMasterKey = options.useMasterKey;
1697
- }
1698
- if (options.hasOwnProperty('sessionToken')) {
1699
- destroyOptions.sessionToken = options.sessionToken;
1700
- }
1701
- if (options.hasOwnProperty('transaction') && typeof options.transaction === 'boolean') {
1702
- destroyOptions.transaction = options.transaction;
1703
- }
1704
- if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
1705
- destroyOptions.batchSize = options.batchSize;
1706
- }
1707
- if (options.hasOwnProperty('context') && typeof options.context === 'object') {
1708
- destroyOptions.context = options.context;
1709
- }
1680
+ const destroyOptions = ParseObject._getRequestOptions(options);
1710
1681
  return _CoreManager.default.getObjectController().destroy(list, destroyOptions);
1711
1682
  }
1712
1683
 
@@ -1725,26 +1696,22 @@ class ParseObject {
1725
1696
  *
1726
1697
  * @param {Array} list A list of <code>Parse.Object</code>.
1727
1698
  * @param {object} options
1699
+ * Valid options are:
1700
+ * <ul>
1701
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
1702
+ * be used for this request.
1703
+ * <li>sessionToken: A valid session token, used for making a request on
1704
+ * behalf of a specific user.
1705
+ * <li>cascadeSave: If `false`, nested objects will not be saved (default is `true`).
1706
+ * <li>context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers.
1707
+ * <li>transaction: Set to true to enable transactions
1708
+ * <li>batchSize: How many objects to yield in each batch (default: 20)
1709
+ * </ul>
1728
1710
  * @static
1729
1711
  * @returns {Parse.Object[]}
1730
1712
  */
1731
1713
  static saveAll(list, options = {}) {
1732
- const saveOptions = {};
1733
- if (options.hasOwnProperty('useMasterKey')) {
1734
- saveOptions.useMasterKey = options.useMasterKey;
1735
- }
1736
- if (options.hasOwnProperty('sessionToken')) {
1737
- saveOptions.sessionToken = options.sessionToken;
1738
- }
1739
- if (options.hasOwnProperty('transaction') && typeof options.transaction === 'boolean') {
1740
- saveOptions.transaction = options.transaction;
1741
- }
1742
- if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
1743
- saveOptions.batchSize = options.batchSize;
1744
- }
1745
- if (options.hasOwnProperty('context') && typeof options.context === 'object') {
1746
- saveOptions.context = options.context;
1747
- }
1714
+ const saveOptions = ParseObject._getRequestOptions(options);
1748
1715
  return _CoreManager.default.getObjectController().save(list, saveOptions);
1749
1716
  }
1750
1717
 
@@ -1901,7 +1868,7 @@ class ParseObject {
1901
1868
  adjustedClassName = '_User';
1902
1869
  }
1903
1870
  let parentProto = ParseObject.prototype;
1904
- if (this.hasOwnProperty('__super__') && this.__super__) {
1871
+ if (Object.hasOwn(this, '__super__') && this.__super__) {
1905
1872
  parentProto = this.prototype;
1906
1873
  }
1907
1874
  let ParseObjectSubclass = function (attributes, options) {
@@ -2268,7 +2235,7 @@ const DefaultController = {
2268
2235
  deleteCompleted = deleteCompleted.then(() => {
2269
2236
  return RESTController.request('POST', 'batch', body, options).then(results => {
2270
2237
  for (let i = 0; i < results.length; i++) {
2271
- if (results[i] && results[i].hasOwnProperty('error')) {
2238
+ if (results[i] && Object.hasOwn(results[i], 'error')) {
2272
2239
  const err = new _ParseError.default(results[i].error.code, results[i].error.error);
2273
2240
  err.object = batch[i];
2274
2241
  errors.push(err);
@@ -2339,7 +2306,7 @@ const DefaultController = {
2339
2306
  const batch = [];
2340
2307
  const nextPending = [];
2341
2308
  pending.forEach(el => {
2342
- if (allowCustomObjectId && Object.prototype.hasOwnProperty.call(el, 'id') && !el.id) {
2309
+ if (allowCustomObjectId && Object.hasOwn(el, 'id') && !el.id) {
2343
2310
  throw new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'objectId must not be empty or null');
2344
2311
  }
2345
2312
  if (batch.length < batchSize && (0, _canBeSerialized.default)(el)) {
@@ -2365,7 +2332,7 @@ const DefaultController = {
2365
2332
  batchTasks.push(stateController.enqueueTask(obj._getStateIdentifier(), function () {
2366
2333
  ready.resolve();
2367
2334
  return batchReturned.then(responses => {
2368
- if (responses[index].hasOwnProperty('success')) {
2335
+ if (Object.hasOwn(responses[index], 'success')) {
2369
2336
  const objectId = responses[index].success.objectId;
2370
2337
  const status = responses[index]._status;
2371
2338
  delete responses[index]._status;
@@ -2374,7 +2341,7 @@ const DefaultController = {
2374
2341
  mapIdForPin[objectId] = obj._localId;
2375
2342
  obj._handleSaveResponse(responses[index].success, status);
2376
2343
  } else {
2377
- if (!objectError && responses[index].hasOwnProperty('error')) {
2344
+ if (!objectError && Object.hasOwn(responses[index], 'error')) {
2378
2345
  const serverError = responses[index].error;
2379
2346
  objectError = new _ParseError.default(serverError.code, serverError.error);
2380
2347
  // Cancel the rest of the save
@@ -2418,7 +2385,7 @@ const DefaultController = {
2418
2385
  });
2419
2386
  });
2420
2387
  } else if (target instanceof ParseObject) {
2421
- if (allowCustomObjectId && Object.prototype.hasOwnProperty.call(target, 'id') && !target.id) {
2388
+ if (allowCustomObjectId && Object.hasOwn(target, 'id') && !target.id) {
2422
2389
  throw new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'objectId must not be empty or null');
2423
2390
  }
2424
2391
  // generate _localId in case if cascadeSave=false