parse 5.3.0 → 6.0.0-alpha.1

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 (77) hide show
  1. package/README.md +6 -5
  2. package/dist/parse.js +822 -877
  3. package/dist/parse.min.js +2 -2
  4. package/dist/parse.weapp.js +822 -875
  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/ParseInstallation.js +3 -1
  15. package/lib/browser/ParseObject.js +160 -163
  16. package/lib/browser/ParseQuery.js +22 -89
  17. package/lib/browser/ParseSession.js +4 -6
  18. package/lib/browser/ParseUser.js +44 -58
  19. package/lib/browser/Push.js +2 -2
  20. package/lib/browser/RESTController.js +2 -2
  21. package/lib/browser/Storage.js +1 -1
  22. package/lib/browser/StorageController.default.js +2 -2
  23. package/lib/browser/StorageController.weapp.js +1 -1
  24. package/lib/node/Cloud.js +12 -16
  25. package/lib/node/CoreManager.js +3 -3
  26. package/lib/node/FacebookUtils.js +1 -1
  27. package/lib/node/LocalDatastoreController.react-native.js +1 -1
  28. package/lib/node/OfflineQuery.js +5 -9
  29. package/lib/node/Parse.js +1 -1
  30. package/lib/node/ParseConfig.js +1 -1
  31. package/lib/node/ParseFile.js +1 -2
  32. package/lib/node/ParseInstallation.js +3 -1
  33. package/lib/node/ParseObject.js +155 -158
  34. package/lib/node/ParseQuery.js +22 -89
  35. package/lib/node/ParseSession.js +4 -6
  36. package/lib/node/ParseUser.js +44 -58
  37. package/lib/node/Push.js +2 -2
  38. package/lib/node/RESTController.js +2 -2
  39. package/lib/node/Storage.js +1 -1
  40. package/lib/node/StorageController.default.js +2 -2
  41. package/lib/node/StorageController.weapp.js +1 -1
  42. package/lib/react-native/Cloud.js +4 -16
  43. package/lib/react-native/CoreManager.js +3 -3
  44. package/lib/react-native/LocalDatastoreController.react-native.js +1 -1
  45. package/lib/react-native/OfflineQuery.js +5 -5
  46. package/lib/react-native/ParseConfig.js +1 -1
  47. package/lib/react-native/ParseFile.js +1 -1
  48. package/lib/react-native/ParseInstallation.js +14 -6
  49. package/lib/react-native/ParseObject.js +147 -163
  50. package/lib/react-native/ParseQuery.js +21 -89
  51. package/lib/react-native/ParseRole.js +8 -2
  52. package/lib/react-native/ParseSession.js +4 -6
  53. package/lib/react-native/ParseUser.js +28 -63
  54. package/lib/react-native/Push.js +2 -2
  55. package/lib/react-native/RESTController.js +11 -10
  56. package/lib/react-native/Storage.js +1 -1
  57. package/lib/react-native/StorageController.default.js +2 -2
  58. package/lib/react-native/StorageController.weapp.js +1 -1
  59. package/lib/weapp/Cloud.js +12 -16
  60. package/lib/weapp/CoreManager.js +3 -3
  61. package/lib/weapp/FacebookUtils.js +1 -1
  62. package/lib/weapp/LocalDatastoreController.react-native.js +1 -1
  63. package/lib/weapp/OfflineQuery.js +5 -9
  64. package/lib/weapp/Parse.js +1 -1
  65. package/lib/weapp/ParseConfig.js +1 -1
  66. package/lib/weapp/ParseFile.js +1 -2
  67. package/lib/weapp/ParseInstallation.js +3 -1
  68. package/lib/weapp/ParseObject.js +160 -163
  69. package/lib/weapp/ParseQuery.js +22 -89
  70. package/lib/weapp/ParseSession.js +4 -6
  71. package/lib/weapp/ParseUser.js +44 -58
  72. package/lib/weapp/Push.js +2 -2
  73. package/lib/weapp/RESTController.js +2 -2
  74. package/lib/weapp/Storage.js +1 -1
  75. package/lib/weapp/StorageController.default.js +2 -2
  76. package/lib/weapp/StorageController.weapp.js +1 -1
  77. package/package.json +30 -28
@@ -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 && !data.hasOwnProperty(field)) {
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 && !obj.hasOwnProperty(component)) {
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 (src.hasOwnProperty(key) && !dest.hasOwnProperty(key)) {
121
+ if (Object.hasOwn(src, key) && !Object.hasOwn(dest, key)) {
122
122
  dest[key] = src[key];
123
123
  }
124
124
  }
@@ -342,7 +342,7 @@ class ParseQuery {
342
342
  _OfflineQuery.default.validateQuery(this);
343
343
  const localDatastore = _CoreManager.default.getLocalDatastore();
344
344
  const objects = await localDatastore._serializeObjectsFromPinName(this._localDatastorePinName);
345
- let results = (0, _filter.default)(_context = (0, _map.default)(objects).call(objects, (json, index, arr) => {
345
+ let results = (0, _filter.default)(_context = (0, _map.default)(objects).call(objects, (json, _index, arr) => {
346
346
  const object = _ParseObject.default.fromJSON(json, false);
347
347
  if (json._localId && !json.objectId) {
348
348
  object._localId = json._localId;
@@ -522,7 +522,7 @@ class ParseQuery {
522
522
  this._comment = json.comment;
523
523
  }
524
524
  for (const key in json) {
525
- if (json.hasOwnProperty(key)) {
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
- options = options || {};
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 (options.json) {
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 (options.hasOwnProperty('sessionToken')) {
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 (options.hasOwnProperty('sessionToken')) {
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 (options.json) {
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 = new ParseQuery(this.className);
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
- const findOptions = {};
900
- if (options.hasOwnProperty('useMasterKey')) {
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
- query.greaterThan('objectId', results[results.length - 1].id);
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));
@@ -26,7 +26,9 @@ class ParseSession extends _ParseObject.default {
26
26
  constructor(attributes) {
27
27
  super('_Session');
28
28
  if (attributes && typeof attributes === 'object') {
29
- if (!this.set(attributes || {})) {
29
+ try {
30
+ this.set(attributes || {});
31
+ } catch (_) {
30
32
  throw new Error("Can't create an invalid Session");
31
33
  }
32
34
  }
@@ -58,12 +60,8 @@ class ParseSession extends _ParseObject.default {
58
60
  * promise will be rejected.
59
61
  */
60
62
  static current(options) {
61
- options = options || {};
62
63
  const controller = _CoreManager.default.getSessionController();
63
- const sessionOptions = {};
64
- if (options.hasOwnProperty('useMasterKey')) {
65
- sessionOptions.useMasterKey = options.useMasterKey;
66
- }
64
+ const sessionOptions = _ParseObject.default._getRequestOptions(options);
67
65
  return _ParseUser.default.currentAsync().then(user => {
68
66
  if (!user) {
69
67
  return _promise.default.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
  }
@@ -99,7 +101,7 @@ class ParseUser extends _ParseObject.default {
99
101
  } else {
100
102
  authType = provider.getAuthType();
101
103
  }
102
- if (options && options.hasOwnProperty('authData')) {
104
+ if (options && Object.hasOwn(options, 'authData')) {
103
105
  const authData = this.get('authData') || {};
104
106
  if (typeof authData !== 'object') {
105
107
  throw new Error('Invalid type: authData field should be an object');
@@ -125,7 +127,7 @@ class ParseUser extends _ParseObject.default {
125
127
  reject(error);
126
128
  });
127
129
  },
128
- error: (provider, error) => {
130
+ error: (_provider, error) => {
129
131
  reject(error);
130
132
  }
131
133
  });
@@ -305,7 +307,7 @@ class ParseUser extends _ParseObject.default {
305
307
  }
306
308
  stripAnonymity() {
307
309
  const authData = this.get('authData');
308
- if (authData && typeof authData === 'object' && authData.hasOwnProperty('anonymous')) {
310
+ if (authData && typeof authData === 'object' && Object.hasOwn(authData, 'anonymous')) {
309
311
  // We need to set anonymous to null instead of deleting it in order to remove it from Parse.
310
312
  authData.anonymous = null;
311
313
  }
@@ -407,21 +409,17 @@ class ParseUser extends _ParseObject.default {
407
409
  *
408
410
  * @param {object} attrs Extra fields to set on the new user, or null.
409
411
  * @param {object} options
412
+ * Valid options are:<ul>
413
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
414
+ * be used for this request.
415
+ * <li>installationId: the installationId which made the request
416
+ * <li>context: A dictionary that is accessible in Cloud Code `beforeLogin` and `afterLogin` triggers.
417
+ * </ul>
410
418
  * @returns {Promise} A promise that is fulfilled when the signup
411
419
  * finishes.
412
420
  */
413
421
  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
- }
422
+ const signupOptions = _ParseObject.default._getRequestOptions(options);
425
423
  const controller = _CoreManager.default.getUserController();
426
424
  return controller.signUp(this, attrs, signupOptions);
427
425
  }
@@ -434,26 +432,21 @@ class ParseUser extends _ParseObject.default {
434
432
  * <p>A username and password must be set before calling logIn.</p>
435
433
  *
436
434
  * @param {object} options
435
+ * Valid options are:<ul>
436
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
437
+ * be used for this request.
438
+ * <li>usePost: Use POST method to make the request (default: true)
439
+ * <li>installationId: the installationId which made the request
440
+ * <li>context: A dictionary that is accessible in Cloud Code `beforeLogin` and `afterLogin` triggers.
441
+ * </ul>
437
442
  * @returns {Promise} A promise that is fulfilled with the user when
438
443
  * the login is complete.
439
444
  */
440
445
  logIn() {
441
446
  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;
447
+ const loginOptions = _ParseObject.default._getRequestOptions(options);
448
+ if (!Object.hasOwn(loginOptions, 'usePost')) {
449
+ loginOptions.usePost = true;
457
450
  }
458
451
  const controller = _CoreManager.default.getUserController();
459
452
  return controller.logIn(this, loginOptions);
@@ -724,6 +717,7 @@ class ParseUser extends _ParseObject.default {
724
717
  *
725
718
  * @param {string} sessionToken The sessionToken to log in with.
726
719
  * @param {object} options
720
+ * @param {boolean} [options.useMasterKey]
727
721
  * @static
728
722
  * @returns {Promise} A promise that is fulfilled with the user when
729
723
  * the login completes.
@@ -732,13 +726,8 @@ class ParseUser extends _ParseObject.default {
732
726
  if (!canUseCurrentUser) {
733
727
  throw new Error('It is not memory-safe to become a user in a server environment');
734
728
  }
735
- options = options || {};
736
- const becomeOptions = {
737
- sessionToken: sessionToken
738
- };
739
- if (options.hasOwnProperty('useMasterKey')) {
740
- becomeOptions.useMasterKey = options.useMasterKey;
741
- }
729
+ const becomeOptions = _ParseObject.default._getRequestOptions(options);
730
+ becomeOptions.sessionToken = sessionToken;
742
731
  const controller = _CoreManager.default.getUserController();
743
732
  const user = new this();
744
733
  return controller.become(user, becomeOptions);
@@ -749,18 +738,15 @@ class ParseUser extends _ParseObject.default {
749
738
  *
750
739
  * @param {string} sessionToken The sessionToken to get user with.
751
740
  * @param {object} options
741
+ * @param {boolean} [options.useMasterKey]
752
742
  * @static
753
743
  * @returns {Promise} A promise that is fulfilled with the user is fetched.
754
744
  */
755
745
  static me(sessionToken) {
756
746
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
757
747
  const controller = _CoreManager.default.getUserController();
758
- const meOptions = {
759
- sessionToken: sessionToken
760
- };
761
- if (options.useMasterKey) {
762
- meOptions.useMasterKey = options.useMasterKey;
763
- }
748
+ const meOptions = _ParseObject.default._getRequestOptions(options);
749
+ meOptions.sessionToken = sessionToken;
764
750
  const user = new this();
765
751
  return controller.me(user, meOptions);
766
752
  }
@@ -820,15 +806,15 @@ class ParseUser extends _ParseObject.default {
820
806
  * @param {string} email The email address associated with the user that
821
807
  * forgot their password.
822
808
  * @param {object} options
809
+ * Valid options are:<ul>
810
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
811
+ * be used for this request.
812
+ * </ul>
823
813
  * @static
824
814
  * @returns {Promise}
825
815
  */
826
816
  static requestPasswordReset(email, options) {
827
- options = options || {};
828
- const requestOptions = {};
829
- if (options.hasOwnProperty('useMasterKey')) {
830
- requestOptions.useMasterKey = options.useMasterKey;
831
- }
817
+ const requestOptions = _ParseObject.default._getRequestOptions(options);
832
818
  const controller = _CoreManager.default.getUserController();
833
819
  return controller.requestPasswordReset(email, requestOptions);
834
820
  }
@@ -839,15 +825,15 @@ class ParseUser extends _ParseObject.default {
839
825
  * @param {string} email The email address associated with the user that
840
826
  * needs to verify their email.
841
827
  * @param {object} options
828
+ * Valid options are:<ul>
829
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
830
+ * be used for this request.
831
+ * </ul>
842
832
  * @static
843
833
  * @returns {Promise}
844
834
  */
845
835
  static requestEmailVerification(email, options) {
846
- options = options || {};
847
- const requestOptions = {};
848
- if (options.hasOwnProperty('useMasterKey')) {
849
- requestOptions.useMasterKey = options.useMasterKey;
850
- }
836
+ const requestOptions = _ParseObject.default._getRequestOptions(options);
851
837
  const controller = _CoreManager.default.getUserController();
852
838
  return controller.requestEmailVerification(email, requestOptions);
853
839
  }
@@ -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');
@@ -28,7 +28,7 @@ let useXDomainRequest = false;
28
28
  if (typeof XDomainRequest !== 'undefined' && !('withCredentials' in new XMLHttpRequest())) {
29
29
  useXDomainRequest = true;
30
30
  }
31
- function ajaxIE9(method, url, data, headers, options) {
31
+ function ajaxIE9(method, url, data, _headers, options) {
32
32
  return new _promise.default((resolve, reject) => {
33
33
  // @ts-ignore
34
34
  const xdr = new XDomainRequest();
@@ -291,7 +291,7 @@ const RESTController = {
291
291
  try {
292
292
  const errorJSON = JSON.parse(response.responseText);
293
293
  error = new _ParseError.default(errorJSON.code, errorJSON.error);
294
- } catch (e) {
294
+ } catch (_) {
295
295
  // If we fail to parse the error text, that's okay.
296
296
  error = new _ParseError.default(_ParseError.default.INVALID_JSON, 'Received an error with invalid JSON from Parse: ' + response.responseText);
297
297
  }
@@ -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
  }
@@ -17,7 +17,7 @@ const StorageController = {
17
17
  try {
18
18
  // @ts-ignore
19
19
  wx.setStorageSync(path, value);
20
- } catch (e) {
20
+ } catch (_) {
21
21
  // Quota exceeded
22
22
  }
23
23
  },
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.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",
19
+ VERSION: 'js' + "6.0.0-alpha.1",
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];
@@ -106,7 +106,7 @@ const FacebookUtils = {
106
106
  }
107
107
  }
108
108
  if (initOptions.status && typeof console !== 'undefined') {
109
- const warn = console.warn || console.log || function () {}; // eslint-disable-line no-console
109
+ const warn = console.warn || console.log || function () {};
110
110
  warn.call(console, 'The "status" flag passed into' + ' FB.init, when set to true, can interfere with Parse Facebook' + ' integration, so it has been suppressed. Please call' + ' FB.getLoginStatus() explicitly if you require this behavior.');
111
111
  }
112
112
  initOptions.status = false;
@@ -53,7 +53,7 @@ const LocalDatastoreController = {
53
53
  const [key, value] = pair;
54
54
  try {
55
55
  LDS[key] = JSON.parse(value);
56
- } catch (error) {
56
+ } catch (_) {
57
57
  LDS[key] = null;
58
58
  }
59
59
  });