parse 5.3.0 → 6.0.0-alpha.2

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 (81) hide show
  1. package/README.md +6 -5
  2. package/dist/parse.js +829 -884
  3. package/dist/parse.min.js +2 -2
  4. package/dist/parse.weapp.js +829 -882
  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/FacebookUtils.js +1 -1
  9. package/lib/browser/LocalDatastoreController.react-native.js +1 -1
  10. package/lib/browser/OfflineQuery.js +5 -9
  11. package/lib/browser/Parse.js +1 -3
  12. package/lib/browser/ParseConfig.js +1 -1
  13. package/lib/browser/ParseFile.js +1 -2
  14. package/lib/browser/ParseHooks.js +7 -7
  15. package/lib/browser/ParseInstallation.js +3 -1
  16. package/lib/browser/ParseObject.js +160 -163
  17. package/lib/browser/ParseQuery.js +22 -89
  18. package/lib/browser/ParseSession.js +4 -6
  19. package/lib/browser/ParseUser.js +44 -58
  20. package/lib/browser/Push.js +2 -2
  21. package/lib/browser/RESTController.js +2 -2
  22. package/lib/browser/Storage.js +1 -1
  23. package/lib/browser/StorageController.default.js +2 -2
  24. package/lib/browser/StorageController.weapp.js +1 -1
  25. package/lib/node/Cloud.js +12 -16
  26. package/lib/node/CoreManager.js +3 -3
  27. package/lib/node/FacebookUtils.js +1 -1
  28. package/lib/node/LocalDatastoreController.react-native.js +1 -1
  29. package/lib/node/OfflineQuery.js +5 -9
  30. package/lib/node/Parse.js +1 -1
  31. package/lib/node/ParseConfig.js +1 -1
  32. package/lib/node/ParseFile.js +1 -2
  33. package/lib/node/ParseHooks.js +7 -7
  34. package/lib/node/ParseInstallation.js +3 -1
  35. package/lib/node/ParseObject.js +155 -158
  36. package/lib/node/ParseQuery.js +22 -89
  37. package/lib/node/ParseSession.js +4 -6
  38. package/lib/node/ParseUser.js +44 -58
  39. package/lib/node/Push.js +2 -2
  40. package/lib/node/RESTController.js +2 -2
  41. package/lib/node/Storage.js +1 -1
  42. package/lib/node/StorageController.default.js +2 -2
  43. package/lib/node/StorageController.weapp.js +1 -1
  44. package/lib/react-native/Cloud.js +4 -16
  45. package/lib/react-native/CoreManager.js +3 -3
  46. package/lib/react-native/LocalDatastoreController.react-native.js +1 -1
  47. package/lib/react-native/OfflineQuery.js +5 -5
  48. package/lib/react-native/ParseConfig.js +1 -1
  49. package/lib/react-native/ParseFile.js +1 -1
  50. package/lib/react-native/ParseHooks.js +7 -7
  51. package/lib/react-native/ParseInstallation.js +14 -6
  52. package/lib/react-native/ParseObject.js +147 -163
  53. package/lib/react-native/ParseQuery.js +21 -89
  54. package/lib/react-native/ParseRole.js +8 -2
  55. package/lib/react-native/ParseSession.js +4 -6
  56. package/lib/react-native/ParseUser.js +28 -63
  57. package/lib/react-native/Push.js +2 -2
  58. package/lib/react-native/RESTController.js +11 -10
  59. package/lib/react-native/Storage.js +1 -1
  60. package/lib/react-native/StorageController.default.js +2 -2
  61. package/lib/react-native/StorageController.weapp.js +1 -1
  62. package/lib/weapp/Cloud.js +12 -16
  63. package/lib/weapp/CoreManager.js +3 -3
  64. package/lib/weapp/FacebookUtils.js +1 -1
  65. package/lib/weapp/LocalDatastoreController.react-native.js +1 -1
  66. package/lib/weapp/OfflineQuery.js +5 -9
  67. package/lib/weapp/Parse.js +1 -1
  68. package/lib/weapp/ParseConfig.js +1 -1
  69. package/lib/weapp/ParseFile.js +1 -2
  70. package/lib/weapp/ParseHooks.js +7 -7
  71. package/lib/weapp/ParseInstallation.js +3 -1
  72. package/lib/weapp/ParseObject.js +160 -163
  73. package/lib/weapp/ParseQuery.js +22 -89
  74. package/lib/weapp/ParseSession.js +4 -6
  75. package/lib/weapp/ParseUser.js +44 -58
  76. package/lib/weapp/Push.js +2 -2
  77. package/lib/weapp/RESTController.js +2 -2
  78. package/lib/weapp/Storage.js +1 -1
  79. package/lib/weapp/StorageController.default.js +2 -2
  80. package/lib/weapp/StorageController.weapp.js +1 -1
  81. package/package.json +30 -28
@@ -60,7 +60,7 @@ function handleSelectResult(data, select) {
60
60
  const serverDataMask = {};
61
61
  select.forEach(field => {
62
62
  const hasSubObjectSelect = field.indexOf('.') !== -1;
63
- if (!hasSubObjectSelect && !data.hasOwnProperty(field)) {
63
+ if (!hasSubObjectSelect && !Object.hasOwn(data, field)) {
64
64
  // this field was selected, but is missing from the retrieved data
65
65
  data[field] = undefined;
66
66
  } else if (hasSubObjectSelect) {
@@ -71,7 +71,7 @@ function handleSelectResult(data, select) {
71
71
  let serverMask = serverDataMask;
72
72
  pathComponents.forEach((component, index, arr) => {
73
73
  // add keys if the expected data is missing
74
- if (obj && !obj.hasOwnProperty(component)) {
74
+ if (obj && !Object.hasOwn(obj, component)) {
75
75
  obj[component] = undefined;
76
76
  }
77
77
  if (obj && typeof obj === 'object') {
@@ -105,7 +105,7 @@ function copyMissingDataWithMask(src, dest, mask, copyThisLevel) {
105
105
  //copy missing elements at this level
106
106
  if (copyThisLevel) {
107
107
  for (const key in src) {
108
- if (src.hasOwnProperty(key) && !dest.hasOwnProperty(key)) {
108
+ if (Object.hasOwn(src, key) && !Object.hasOwn(dest, key)) {
109
109
  dest[key] = src[key];
110
110
  }
111
111
  }
@@ -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, index, arr) => {
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;
@@ -488,7 +488,7 @@ class ParseQuery {
488
488
  this._comment = json.comment;
489
489
  }
490
490
  for (const key in json) {
491
- if (json.hasOwnProperty(key)) {
491
+ if (Object.hasOwn(json, key)) {
492
492
  if (['where', 'include', 'keys', 'count', 'limit', 'skip', 'order', 'readPreference', 'includeReadPreference', 'subqueryReadPreference', 'hint', 'explain', 'comment'].indexOf(key) === -1) {
493
493
  this._extraOptions[key] = json[key];
494
494
  }
@@ -529,19 +529,7 @@ class ParseQuery {
529
529
  */
530
530
  get(objectId, options) {
531
531
  this.equalTo('objectId', objectId);
532
- const firstOptions = {};
533
- if (options && options.hasOwnProperty('useMasterKey')) {
534
- firstOptions.useMasterKey = options.useMasterKey;
535
- }
536
- if (options && options.hasOwnProperty('sessionToken')) {
537
- firstOptions.sessionToken = options.sessionToken;
538
- }
539
- if (options && options.hasOwnProperty('context') && typeof options.context === 'object') {
540
- firstOptions.context = options.context;
541
- }
542
- if (options && options.hasOwnProperty('json')) {
543
- firstOptions.json = options.json;
544
- }
532
+ const firstOptions = _ParseObject.default._getRequestOptions(options);
545
533
  return this.first(firstOptions).then(response => {
546
534
  if (response) {
547
535
  return response;
@@ -567,17 +555,7 @@ class ParseQuery {
567
555
  * the query completes.
568
556
  */
569
557
  find(options) {
570
- options = options || {};
571
- const findOptions = {};
572
- if (options.hasOwnProperty('useMasterKey')) {
573
- findOptions.useMasterKey = options.useMasterKey;
574
- }
575
- if (options.hasOwnProperty('sessionToken')) {
576
- findOptions.sessionToken = options.sessionToken;
577
- }
578
- if (options.hasOwnProperty('context') && typeof options.context === 'object') {
579
- findOptions.context = options.context;
580
- }
558
+ const findOptions = _ParseObject.default._getRequestOptions(options);
581
559
  this._setRequestTask(findOptions);
582
560
  const controller = _CoreManager.default.getQueryController();
583
561
  const select = this._select;
@@ -604,7 +582,7 @@ class ParseQuery {
604
582
  if (select) {
605
583
  handleSelectResult(data, select);
606
584
  }
607
- if (options.json) {
585
+ if (findOptions.json) {
608
586
  return data;
609
587
  } else {
610
588
  return _ParseObject.default.fromJSON(data, !select);
@@ -632,6 +610,7 @@ class ParseQuery {
632
610
  * be used for this request.
633
611
  * <li>sessionToken: A valid session token, used for making a request on
634
612
  * behalf of a specific user.
613
+ * <li>json: Return raw JSON without converting to Parse.Object.
635
614
  * </ul>
636
615
  * @returns {Promise} A promise that is resolved with the results when
637
616
  * the query completes.
@@ -661,13 +640,7 @@ class ParseQuery {
661
640
  */
662
641
  count(options) {
663
642
  options = options || {};
664
- const findOptions = {};
665
- if (options.hasOwnProperty('useMasterKey')) {
666
- findOptions.useMasterKey = options.useMasterKey;
667
- }
668
- if (options.hasOwnProperty('sessionToken')) {
669
- findOptions.sessionToken = options.sessionToken;
670
- }
643
+ const findOptions = _ParseObject.default._getRequestOptions(options);
671
644
  this._setRequestTask(findOptions);
672
645
  const controller = _CoreManager.default.getQueryController();
673
646
  const params = this.toJSON();
@@ -691,7 +664,7 @@ class ParseQuery {
691
664
  const distinctOptions = {
692
665
  useMasterKey: true
693
666
  };
694
- if (options.hasOwnProperty('sessionToken')) {
667
+ if (Object.hasOwn(options, 'sessionToken')) {
695
668
  distinctOptions.sessionToken = options.sessionToken;
696
669
  }
697
670
  this._setRequestTask(distinctOptions);
@@ -719,7 +692,7 @@ class ParseQuery {
719
692
  const aggregateOptions = {
720
693
  useMasterKey: true
721
694
  };
722
- if (options.hasOwnProperty('sessionToken')) {
695
+ if (Object.hasOwn(options, 'sessionToken')) {
723
696
  aggregateOptions.sessionToken = options.sessionToken;
724
697
  }
725
698
  this._setRequestTask(aggregateOptions);
@@ -763,16 +736,7 @@ class ParseQuery {
763
736
  * the query completes.
764
737
  */
765
738
  first(options = {}) {
766
- const findOptions = {};
767
- if (options.hasOwnProperty('useMasterKey')) {
768
- findOptions.useMasterKey = options.useMasterKey;
769
- }
770
- if (options.hasOwnProperty('sessionToken')) {
771
- findOptions.sessionToken = options.sessionToken;
772
- }
773
- if (options.hasOwnProperty('context') && typeof options.context === 'object') {
774
- findOptions.context = options.context;
775
- }
739
+ const findOptions = _ParseObject.default._getRequestOptions(options);
776
740
  this._setRequestTask(findOptions);
777
741
  const controller = _CoreManager.default.getQueryController();
778
742
  const params = this.toJSON();
@@ -801,7 +765,7 @@ class ParseQuery {
801
765
  if (select) {
802
766
  handleSelectResult(objects[0], select);
803
767
  }
804
- if (options.json) {
768
+ if (findOptions.json) {
805
769
  return objects[0];
806
770
  } else {
807
771
  return _ParseObject.default.fromJSON(objects[0], !select);
@@ -835,45 +799,10 @@ class ParseQuery {
835
799
  if (this._order || this._skip || this._limit >= 0) {
836
800
  return Promise.reject('Cannot iterate on a query with sort, skip, or limit.');
837
801
  }
838
- const query = new ParseQuery(this.className);
839
- query._limit = options.batchSize || 100;
840
- query._include = [...this._include];
841
- query._exclude = [...this._exclude];
842
- if (this._select) {
843
- query._select = [...this._select];
844
- }
845
- query._hint = this._hint;
846
- query._where = {};
847
- for (const attr in this._where) {
848
- const val = this._where[attr];
849
- if (Array.isArray(val)) {
850
- query._where[attr] = val.map(v => {
851
- return v;
852
- });
853
- } else if (val && typeof val === 'object') {
854
- const conditionMap = {};
855
- query._where[attr] = conditionMap;
856
- for (const cond in val) {
857
- conditionMap[cond] = val[cond];
858
- }
859
- } else {
860
- query._where[attr] = val;
861
- }
862
- }
802
+ const query = ParseQuery.fromJSON(this.className, this.toJSON());
863
803
  query.ascending('objectId');
864
- const findOptions = {};
865
- if (options.hasOwnProperty('useMasterKey')) {
866
- findOptions.useMasterKey = options.useMasterKey;
867
- }
868
- if (options.hasOwnProperty('sessionToken')) {
869
- findOptions.sessionToken = options.sessionToken;
870
- }
871
- if (options.hasOwnProperty('context') && typeof options.context === 'object') {
872
- findOptions.context = options.context;
873
- }
874
- if (options.hasOwnProperty('json')) {
875
- findOptions.json = options.json;
876
- }
804
+ query._limit = options.batchSize || 100;
805
+ const findOptions = _ParseObject.default._getRequestOptions(options);
877
806
  let finished = false;
878
807
  let previousResults = [];
879
808
  return (0, _promiseUtils.continueWhile)(() => {
@@ -881,7 +810,11 @@ class ParseQuery {
881
810
  }, async () => {
882
811
  const [results] = await Promise.all([query.find(findOptions), Promise.resolve(previousResults.length > 0 && callback(previousResults))]);
883
812
  if (results.length >= query._limit) {
884
- query.greaterThan('objectId', results[results.length - 1].id);
813
+ if (findOptions.json) {
814
+ query.greaterThan('objectId', results[results.length - 1].objectId);
815
+ } else {
816
+ query.greaterThan('objectId', results[results.length - 1].id);
817
+ }
885
818
  previousResults = results;
886
819
  } else if (results.length > 0) {
887
820
  await Promise.resolve(callback(results));
@@ -28,7 +28,9 @@ class ParseSession extends _ParseObject.default {
28
28
  constructor(attributes) {
29
29
  super('_Session');
30
30
  if (attributes && typeof attributes === 'object') {
31
- if (!this.set(attributes || {})) {
31
+ try {
32
+ this.set(attributes || {});
33
+ } catch (_) {
32
34
  throw new Error("Can't create an invalid Session");
33
35
  }
34
36
  }
@@ -60,12 +62,8 @@ class ParseSession extends _ParseObject.default {
60
62
  * promise will be rejected.
61
63
  */
62
64
  static current(options) {
63
- options = options || {};
64
65
  const controller = _CoreManager.default.getSessionController();
65
- const sessionOptions = {};
66
- if (options.hasOwnProperty('useMasterKey')) {
67
- sessionOptions.useMasterKey = options.useMasterKey;
68
- }
66
+ const sessionOptions = _ParseObject.default._getRequestOptions(options);
69
67
  return _ParseUser.default.currentAsync().then(user => {
70
68
  if (!user) {
71
69
  return Promise.reject('There is no current user.');
@@ -37,7 +37,9 @@ class ParseUser extends _ParseObject.default {
37
37
  constructor(attributes) {
38
38
  super('_User');
39
39
  if (attributes && typeof attributes === 'object') {
40
- if (!this.set(attributes || {})) {
40
+ try {
41
+ this.set(attributes || {});
42
+ } catch (_) {
41
43
  throw new Error("Can't create an invalid Parse User");
42
44
  }
43
45
  }
@@ -47,15 +49,15 @@ class ParseUser extends _ParseObject.default {
47
49
  * Request a revocable session token to replace the older style of token.
48
50
  *
49
51
  * @param {object} options
52
+ * Valid options are:<ul>
53
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
54
+ * be used for this request.
55
+ * </ul>
50
56
  * @returns {Promise} A promise that is resolved when the replacement
51
57
  * token has been fetched.
52
58
  */
53
59
  _upgradeToRevocableSession(options) {
54
- options = options || {};
55
- const upgradeOptions = {};
56
- if (options.hasOwnProperty('useMasterKey')) {
57
- upgradeOptions.useMasterKey = options.useMasterKey;
58
- }
60
+ const upgradeOptions = _ParseObject.default._getRequestOptions(options);
59
61
  const controller = _CoreManager.default.getUserController();
60
62
  return controller.upgradeToRevocableSession(this, upgradeOptions);
61
63
  }
@@ -98,7 +100,7 @@ class ParseUser extends _ParseObject.default {
98
100
  } else {
99
101
  authType = provider.getAuthType();
100
102
  }
101
- if (options && options.hasOwnProperty('authData')) {
103
+ if (options && Object.hasOwn(options, 'authData')) {
102
104
  const authData = this.get('authData') || {};
103
105
  if (typeof authData !== 'object') {
104
106
  throw new Error('Invalid type: authData field should be an object');
@@ -124,7 +126,7 @@ class ParseUser extends _ParseObject.default {
124
126
  reject(error);
125
127
  });
126
128
  },
127
- error: (provider, error) => {
129
+ error: (_provider, error) => {
128
130
  reject(error);
129
131
  }
130
132
  });
@@ -303,7 +305,7 @@ class ParseUser extends _ParseObject.default {
303
305
  }
304
306
  stripAnonymity() {
305
307
  const authData = this.get('authData');
306
- if (authData && typeof authData === 'object' && authData.hasOwnProperty('anonymous')) {
308
+ if (authData && typeof authData === 'object' && Object.hasOwn(authData, 'anonymous')) {
307
309
  // We need to set anonymous to null instead of deleting it in order to remove it from Parse.
308
310
  authData.anonymous = null;
309
311
  }
@@ -405,21 +407,17 @@ class ParseUser extends _ParseObject.default {
405
407
  *
406
408
  * @param {object} attrs Extra fields to set on the new user, or null.
407
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>
408
416
  * @returns {Promise} A promise that is fulfilled when the signup
409
417
  * finishes.
410
418
  */
411
419
  signUp(attrs, options) {
412
- options = options || {};
413
- const signupOptions = {};
414
- if (options.hasOwnProperty('useMasterKey')) {
415
- signupOptions.useMasterKey = options.useMasterKey;
416
- }
417
- if (options.hasOwnProperty('installationId')) {
418
- signupOptions.installationId = options.installationId;
419
- }
420
- if (options.hasOwnProperty('context') && Object.prototype.toString.call(options.context) === '[object Object]') {
421
- signupOptions.context = options.context;
422
- }
420
+ const signupOptions = _ParseObject.default._getRequestOptions(options);
423
421
  const controller = _CoreManager.default.getUserController();
424
422
  return controller.signUp(this, attrs, signupOptions);
425
423
  }
@@ -432,25 +430,20 @@ class ParseUser extends _ParseObject.default {
432
430
  * <p>A username and password must be set before calling logIn.</p>
433
431
  *
434
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>
435
440
  * @returns {Promise} A promise that is fulfilled with the user when
436
441
  * the login is complete.
437
442
  */
438
443
  logIn(options = {}) {
439
- options = options || {};
440
- const loginOptions = {
441
- usePost: true
442
- };
443
- if (options.hasOwnProperty('useMasterKey')) {
444
- loginOptions.useMasterKey = options.useMasterKey;
445
- }
446
- if (options.hasOwnProperty('installationId')) {
447
- loginOptions.installationId = options.installationId;
448
- }
449
- if (options.hasOwnProperty('usePost')) {
450
- loginOptions.usePost = options.usePost;
451
- }
452
- if (options.hasOwnProperty('context') && Object.prototype.toString.call(options.context) === '[object Object]') {
453
- loginOptions.context = options.context;
444
+ const loginOptions = _ParseObject.default._getRequestOptions(options);
445
+ if (!Object.hasOwn(loginOptions, 'usePost')) {
446
+ loginOptions.usePost = true;
454
447
  }
455
448
  const controller = _CoreManager.default.getUserController();
456
449
  return controller.logIn(this, loginOptions);
@@ -709,6 +702,7 @@ class ParseUser extends _ParseObject.default {
709
702
  *
710
703
  * @param {string} sessionToken The sessionToken to log in with.
711
704
  * @param {object} options
705
+ * @param {boolean} [options.useMasterKey]
712
706
  * @static
713
707
  * @returns {Promise} A promise that is fulfilled with the user when
714
708
  * the login completes.
@@ -717,13 +711,8 @@ class ParseUser extends _ParseObject.default {
717
711
  if (!canUseCurrentUser) {
718
712
  throw new Error('It is not memory-safe to become a user in a server environment');
719
713
  }
720
- options = options || {};
721
- const becomeOptions = {
722
- sessionToken: sessionToken
723
- };
724
- if (options.hasOwnProperty('useMasterKey')) {
725
- becomeOptions.useMasterKey = options.useMasterKey;
726
- }
714
+ const becomeOptions = _ParseObject.default._getRequestOptions(options);
715
+ becomeOptions.sessionToken = sessionToken;
727
716
  const controller = _CoreManager.default.getUserController();
728
717
  const user = new this();
729
718
  return controller.become(user, becomeOptions);
@@ -734,17 +723,14 @@ class ParseUser extends _ParseObject.default {
734
723
  *
735
724
  * @param {string} sessionToken The sessionToken to get user with.
736
725
  * @param {object} options
726
+ * @param {boolean} [options.useMasterKey]
737
727
  * @static
738
728
  * @returns {Promise} A promise that is fulfilled with the user is fetched.
739
729
  */
740
730
  static me(sessionToken, options = {}) {
741
731
  const controller = _CoreManager.default.getUserController();
742
- const meOptions = {
743
- sessionToken: sessionToken
744
- };
745
- if (options.useMasterKey) {
746
- meOptions.useMasterKey = options.useMasterKey;
747
- }
732
+ const meOptions = _ParseObject.default._getRequestOptions(options);
733
+ meOptions.sessionToken = sessionToken;
748
734
  const user = new this();
749
735
  return controller.me(user, meOptions);
750
736
  }
@@ -803,15 +789,15 @@ class ParseUser extends _ParseObject.default {
803
789
  * @param {string} email The email address associated with the user that
804
790
  * forgot their password.
805
791
  * @param {object} options
792
+ * Valid options are:<ul>
793
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
794
+ * be used for this request.
795
+ * </ul>
806
796
  * @static
807
797
  * @returns {Promise}
808
798
  */
809
799
  static requestPasswordReset(email, options) {
810
- options = options || {};
811
- const requestOptions = {};
812
- if (options.hasOwnProperty('useMasterKey')) {
813
- requestOptions.useMasterKey = options.useMasterKey;
814
- }
800
+ const requestOptions = _ParseObject.default._getRequestOptions(options);
815
801
  const controller = _CoreManager.default.getUserController();
816
802
  return controller.requestPasswordReset(email, requestOptions);
817
803
  }
@@ -822,15 +808,15 @@ class ParseUser extends _ParseObject.default {
822
808
  * @param {string} email The email address associated with the user that
823
809
  * needs to verify their email.
824
810
  * @param {object} options
811
+ * Valid options are:<ul>
812
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
813
+ * be used for this request.
814
+ * </ul>
825
815
  * @static
826
816
  * @returns {Promise}
827
817
  */
828
818
  static requestEmailVerification(email, options) {
829
- options = options || {};
830
- const requestOptions = {};
831
- if (options.hasOwnProperty('useMasterKey')) {
832
- requestOptions.useMasterKey = options.useMasterKey;
833
- }
819
+ const requestOptions = _ParseObject.default._getRequestOptions(options);
834
820
  const controller = _CoreManager.default.getUserController();
835
821
  return controller.requestEmailVerification(email, requestOptions);
836
822
  }
package/lib/node/Push.js CHANGED
@@ -64,7 +64,7 @@ function send(data, options = {}) {
64
64
  const pushOptions = {
65
65
  useMasterKey: true
66
66
  };
67
- if (options.hasOwnProperty('useMasterKey')) {
67
+ if (Object.hasOwn(options, 'useMasterKey')) {
68
68
  pushOptions.useMasterKey = options.useMasterKey;
69
69
  }
70
70
  return _CoreManager.default.getPushController().send(data, pushOptions);
@@ -87,7 +87,7 @@ function getPushStatus(pushStatusId, options = {}) {
87
87
  const pushOptions = {
88
88
  useMasterKey: true
89
89
  };
90
- if (options.hasOwnProperty('useMasterKey')) {
90
+ if (Object.hasOwn(options, 'useMasterKey')) {
91
91
  pushOptions.useMasterKey = options.useMasterKey;
92
92
  }
93
93
  const query = new _ParseQuery.default('_PushStatus');
@@ -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, headers, options) {
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 (e) {
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
  }
@@ -85,7 +85,7 @@ const Storage = {
85
85
  },
86
86
  _clear() {
87
87
  const controller = _CoreManager.default.getStorageController();
88
- if (controller.hasOwnProperty('clear')) {
88
+ if (Object.hasOwn(controller, 'clear')) {
89
89
  controller.clear();
90
90
  }
91
91
  }
@@ -9,7 +9,7 @@ const memMap = {};
9
9
  const StorageController = {
10
10
  async: 0,
11
11
  getItem(path) {
12
- if (memMap.hasOwnProperty(path)) {
12
+ if (Object.hasOwn(memMap, path)) {
13
13
  return memMap[path];
14
14
  }
15
15
  return null;
@@ -25,7 +25,7 @@ const StorageController = {
25
25
  },
26
26
  clear() {
27
27
  for (const key in memMap) {
28
- if (memMap.hasOwnProperty(key)) {
28
+ if (Object.hasOwn(memMap, key)) {
29
29
  delete memMap[key];
30
30
  }
31
31
  }
@@ -14,7 +14,7 @@ const StorageController = {
14
14
  try {
15
15
  // @ts-ignore
16
16
  wx.setStorageSync(path, value);
17
- } catch (e) {
17
+ } catch (_) {
18
18
  // Quota exceeded
19
19
  }
20
20
  },
@@ -12,24 +12,12 @@ 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 run(name, data, options) {
16
- options = options || {};
17
17
  if (typeof name !== 'string' || name.length === 0) {
18
18
  throw new TypeError('Cloud function name must be a string.');
19
19
  }
20
- var requestOptions = {};
21
- if (options.useMasterKey) {
22
- requestOptions.useMasterKey = options.useMasterKey;
23
- }
24
- if (options.sessionToken) {
25
- requestOptions.sessionToken = options.sessionToken;
26
- }
27
- if (options.installationId) {
28
- requestOptions.installationId = options.installationId;
29
- }
30
- if (options.context && typeof options.context === 'object') {
31
- requestOptions.context = options.context;
32
- }
20
+ var requestOptions = _ParseObject.default._getRequestOptions(options);
33
21
  return _CoreManager.default.getCloudController().run(name, data, requestOptions);
34
22
  }
35
23
  function getJobsData() {
@@ -57,11 +45,11 @@ var DefaultController = {
57
45
  var payload = (0, _encode.default)(data, true);
58
46
  var request = RESTController.request('POST', 'functions/' + name, payload, options);
59
47
  return request.then(function (res) {
60
- if (typeof res === 'object' && Object.keys(res).length > 0 && !res.hasOwnProperty('result')) {
48
+ if (typeof res === 'object' && Object.keys(res).length > 0 && !Object.hasOwn(res, 'result')) {
61
49
  throw new _ParseError.default(_ParseError.default.INVALID_JSON, 'The server returned an invalid response.');
62
50
  }
63
51
  var decoded = (0, _decode.default)(res);
64
- if (decoded && decoded.hasOwnProperty('result')) {
52
+ if (decoded && Object.hasOwn(decoded, 'result')) {
65
53
  return Promise.resolve(decoded.result);
66
54
  }
67
55
  return Promise.resolve(undefined);
@@ -12,7 +12,7 @@ var config = {
12
12
  SERVER_AUTH_TOKEN: null,
13
13
  LIVEQUERY_SERVER_URL: null,
14
14
  ENCRYPTED_KEY: null,
15
- VERSION: 'js' + "5.3.0",
15
+ VERSION: 'js' + "6.0.0-alpha.2",
16
16
  APPLICATION_ID: null,
17
17
  JAVASCRIPT_KEY: null,
18
18
  MASTER_KEY: null,
@@ -33,7 +33,7 @@ function requireMethods(name, methods, controller) {
33
33
  }
34
34
  var CoreManager = {
35
35
  get: function (key) {
36
- if (config.hasOwnProperty(key)) {
36
+ if (Object.hasOwn(config, key)) {
37
37
  return config[key];
38
38
  }
39
39
  throw new Error('Configuration key not found: ' + key);
@@ -42,7 +42,7 @@ var CoreManager = {
42
42
  config[key] = value;
43
43
  },
44
44
  setIfNeeded: function (key, value) {
45
- if (!config.hasOwnProperty(key)) {
45
+ if (!Object.hasOwn(config, key)) {
46
46
  config[key] = value;
47
47
  }
48
48
  return config[key];
@@ -63,7 +63,7 @@ var LocalDatastoreController = {
63
63
  value = _pair[1];
64
64
  try {
65
65
  LDS[key] = JSON.parse(value);
66
- } catch (error) {
66
+ } catch (_) {
67
67
  LDS[key] = null;
68
68
  }
69
69
  });
@@ -249,7 +249,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
249
249
  }
250
250
  compareTo = parserResult.result;
251
251
  }
252
- if (toString.call(compareTo) === '[object Date]' || typeof compareTo === 'string' && new Date(compareTo) !== 'Invalid Date' && !isNaN(new Date(compareTo))) {
252
+ if (toString.call(compareTo) === '[object Date]' || typeof compareTo === 'string' && new Date(compareTo).toString() !== 'Invalid Date') {
253
253
  object[key] = new Date(object[key].iso ? object[key].iso : object[key]);
254
254
  }
255
255
  switch (condition) {
@@ -359,7 +359,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
359
359
  break;
360
360
  case '$select':
361
361
  {
362
- var subQueryObjects = objects.filter(function (obj, index, arr) {
362
+ var subQueryObjects = objects.filter(function (obj, _index, arr) {
363
363
  return matchesQuery(compareTo.query.className, obj, arr, compareTo.query.where);
364
364
  });
365
365
  for (var _i = 0; _i < subQueryObjects.length; _i += 1) {
@@ -370,7 +370,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
370
370
  }
371
371
  case '$dontSelect':
372
372
  {
373
- var _subQueryObjects = objects.filter(function (obj, index, arr) {
373
+ var _subQueryObjects = objects.filter(function (obj, _index, arr) {
374
374
  return matchesQuery(compareTo.query.className, obj, arr, compareTo.query.where);
375
375
  });
376
376
  for (var _i2 = 0; _i2 < _subQueryObjects.length; _i2 += 1) {
@@ -381,7 +381,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
381
381
  }
382
382
  case '$inQuery':
383
383
  {
384
- var _subQueryObjects2 = objects.filter(function (obj, index, arr) {
384
+ var _subQueryObjects2 = objects.filter(function (obj, _index, arr) {
385
385
  return matchesQuery(compareTo.className, obj, arr, compareTo.where);
386
386
  });
387
387
  for (var _i3 = 0; _i3 < _subQueryObjects2.length; _i3 += 1) {
@@ -394,7 +394,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
394
394
  }
395
395
  case '$notInQuery':
396
396
  {
397
- var _subQueryObjects3 = objects.filter(function (obj, index, arr) {
397
+ var _subQueryObjects3 = objects.filter(function (obj, _index, arr) {
398
398
  return matchesQuery(compareTo.className, obj, arr, compareTo.where);
399
399
  });
400
400
  for (var _i4 = 0; _i4 < _subQueryObjects3.length; _i4 += 1) {
@@ -77,7 +77,7 @@ function decodePayload(data) {
77
77
  if (json && typeof json === 'object') {
78
78
  return (0, _decode.default)(json);
79
79
  }
80
- } catch (e) {
80
+ } catch (_) {
81
81
  return null;
82
82
  }
83
83
  }
@@ -198,7 +198,7 @@ var ParseFile = function () {
198
198
  var destroyOptions = {
199
199
  useMasterKey: true
200
200
  };
201
- if (options.hasOwnProperty('useMasterKey')) {
201
+ if (Object.hasOwn(options, 'useMasterKey')) {
202
202
  destroyOptions.useMasterKey = !!options.useMasterKey;
203
203
  }
204
204
  var controller = _CoreManager.default.getFileController();