parse 5.1.0 → 5.2.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 (143) hide show
  1. package/dist/parse.js +1556 -1309
  2. package/dist/parse.min.js +2 -2
  3. package/dist/parse.weapp.js +1560 -1313
  4. package/dist/parse.weapp.min.js +2 -2
  5. package/lib/browser/Cloud.js +7 -11
  6. package/lib/browser/CoreManager.js +10 -10
  7. package/lib/browser/EventuallyQueue.js +1 -1
  8. package/lib/browser/InstallationController.js +3 -3
  9. package/lib/browser/LiveQueryClient.js +102 -60
  10. package/lib/browser/LocalDatastore.js +189 -147
  11. package/lib/browser/LocalDatastoreController.default.js +14 -9
  12. package/lib/browser/LocalDatastoreController.react-native.js +14 -12
  13. package/lib/browser/LocalDatastoreUtils.js +0 -5
  14. package/lib/browser/ObjectStateMutations.js +57 -21
  15. package/lib/browser/Parse.js +2 -2
  16. package/lib/browser/ParseCLP.js +9 -17
  17. package/lib/browser/ParseFile.js +27 -31
  18. package/lib/browser/ParseGeoPoint.js +9 -3
  19. package/lib/browser/ParseHooks.js +13 -13
  20. package/lib/browser/ParseInstallation.js +117 -9
  21. package/lib/browser/ParseObject.js +19 -17
  22. package/lib/browser/ParseOp.js +17 -17
  23. package/lib/browser/ParsePolygon.js +1 -1
  24. package/lib/browser/ParseQuery.js +147 -149
  25. package/lib/browser/ParseRole.js +5 -9
  26. package/lib/browser/ParseSchema.js +1 -1
  27. package/lib/browser/ParseUser.js +66 -51
  28. package/lib/browser/Push.js +5 -10
  29. package/lib/browser/RESTController.js +1 -1
  30. package/lib/browser/SingleInstanceStateController.js +1 -1
  31. package/lib/browser/TaskQueue.js +10 -10
  32. package/lib/browser/UniqueInstanceStateController.js +1 -1
  33. package/lib/browser/arrayContainsObject.js +0 -4
  34. package/lib/browser/canBeSerialized.js +0 -4
  35. package/lib/browser/decode.js +0 -7
  36. package/lib/browser/encode.js +3 -7
  37. package/lib/browser/equals.js +1 -1
  38. package/lib/browser/escape.js +0 -4
  39. package/lib/browser/isRevocableSession.js +0 -4
  40. package/lib/browser/parseDate.js +1 -5
  41. package/lib/browser/promiseUtils.js +11 -10
  42. package/lib/browser/unique.js +1 -5
  43. package/lib/browser/unsavedChildren.js +0 -8
  44. package/lib/browser/uuid.js +2 -2
  45. package/lib/node/Cloud.js +7 -11
  46. package/lib/node/CoreManager.js +10 -10
  47. package/lib/node/EventuallyQueue.js +1 -1
  48. package/lib/node/InstallationController.js +3 -3
  49. package/lib/node/LiveQueryClient.js +14 -24
  50. package/lib/node/LocalDatastore.js +7 -11
  51. package/lib/node/LocalDatastoreController.default.js +12 -10
  52. package/lib/node/LocalDatastoreController.react-native.js +13 -12
  53. package/lib/node/LocalDatastoreUtils.js +0 -5
  54. package/lib/node/ObjectStateMutations.js +45 -19
  55. package/lib/node/Parse.js +2 -2
  56. package/lib/node/ParseCLP.js +8 -18
  57. package/lib/node/ParseFile.js +27 -40
  58. package/lib/node/ParseGeoPoint.js +9 -3
  59. package/lib/node/ParseHooks.js +13 -13
  60. package/lib/node/ParseInstallation.js +60 -2
  61. package/lib/node/ParseObject.js +19 -17
  62. package/lib/node/ParseOp.js +21 -21
  63. package/lib/node/ParsePolygon.js +1 -1
  64. package/lib/node/ParseQuery.js +84 -107
  65. package/lib/node/ParseRole.js +3 -8
  66. package/lib/node/ParseSchema.js +4 -4
  67. package/lib/node/ParseUser.js +42 -37
  68. package/lib/node/Push.js +3 -8
  69. package/lib/node/RESTController.js +1 -1
  70. package/lib/node/SingleInstanceStateController.js +1 -1
  71. package/lib/node/TaskQueue.js +9 -11
  72. package/lib/node/UniqueInstanceStateController.js +1 -1
  73. package/lib/node/arrayContainsObject.js +0 -4
  74. package/lib/node/canBeSerialized.js +0 -4
  75. package/lib/node/decode.js +0 -7
  76. package/lib/node/encode.js +3 -7
  77. package/lib/node/equals.js +1 -1
  78. package/lib/node/escape.js +0 -4
  79. package/lib/node/isRevocableSession.js +0 -4
  80. package/lib/node/parseDate.js +1 -5
  81. package/lib/node/promiseUtils.js +11 -10
  82. package/lib/node/unique.js +1 -5
  83. package/lib/node/unsavedChildren.js +0 -8
  84. package/lib/node/uuid.js +2 -2
  85. package/lib/react-native/Cloud.js +0 -1
  86. package/lib/react-native/CoreManager.js +1 -1
  87. package/lib/react-native/LiveQueryClient.js +49 -32
  88. package/lib/react-native/LocalDatastore.js +38 -14
  89. package/lib/react-native/LocalDatastoreController.default.js +7 -1
  90. package/lib/react-native/LocalDatastoreController.react-native.js +7 -1
  91. package/lib/react-native/ObjectStateMutations.js +30 -9
  92. package/lib/react-native/ParseCLP.js +3 -3
  93. package/lib/react-native/ParseFile.js +7 -6
  94. package/lib/react-native/ParseInstallation.js +51 -3
  95. package/lib/react-native/ParseObject.js +6 -5
  96. package/lib/react-native/ParseQuery.js +45 -37
  97. package/lib/react-native/ParseRole.js +1 -1
  98. package/lib/react-native/ParseUser.js +22 -16
  99. package/lib/react-native/TaskQueue.js +8 -2
  100. package/lib/react-native/decode.js +0 -1
  101. package/lib/react-native/promiseUtils.js +5 -4
  102. package/lib/react-native/uuid.js +1 -2
  103. package/lib/weapp/Cloud.js +7 -11
  104. package/lib/weapp/CoreManager.js +10 -10
  105. package/lib/weapp/EventuallyQueue.js +1 -1
  106. package/lib/weapp/InstallationController.js +3 -3
  107. package/lib/weapp/LiveQueryClient.js +102 -60
  108. package/lib/weapp/LocalDatastore.js +189 -147
  109. package/lib/weapp/LocalDatastoreController.default.js +14 -9
  110. package/lib/weapp/LocalDatastoreController.react-native.js +14 -12
  111. package/lib/weapp/LocalDatastoreUtils.js +0 -5
  112. package/lib/weapp/ObjectStateMutations.js +57 -21
  113. package/lib/weapp/Parse.js +2 -2
  114. package/lib/weapp/ParseCLP.js +9 -17
  115. package/lib/weapp/ParseFile.js +27 -31
  116. package/lib/weapp/ParseGeoPoint.js +9 -3
  117. package/lib/weapp/ParseHooks.js +13 -13
  118. package/lib/weapp/ParseInstallation.js +117 -9
  119. package/lib/weapp/ParseObject.js +19 -17
  120. package/lib/weapp/ParseOp.js +17 -17
  121. package/lib/weapp/ParsePolygon.js +1 -1
  122. package/lib/weapp/ParseQuery.js +147 -149
  123. package/lib/weapp/ParseRole.js +5 -9
  124. package/lib/weapp/ParseSchema.js +1 -1
  125. package/lib/weapp/ParseUser.js +66 -51
  126. package/lib/weapp/Push.js +5 -10
  127. package/lib/weapp/RESTController.js +1 -1
  128. package/lib/weapp/SingleInstanceStateController.js +1 -1
  129. package/lib/weapp/TaskQueue.js +10 -10
  130. package/lib/weapp/UniqueInstanceStateController.js +1 -1
  131. package/lib/weapp/arrayContainsObject.js +0 -4
  132. package/lib/weapp/canBeSerialized.js +0 -4
  133. package/lib/weapp/decode.js +0 -7
  134. package/lib/weapp/encode.js +3 -7
  135. package/lib/weapp/equals.js +1 -1
  136. package/lib/weapp/escape.js +0 -4
  137. package/lib/weapp/isRevocableSession.js +0 -4
  138. package/lib/weapp/parseDate.js +1 -5
  139. package/lib/weapp/promiseUtils.js +11 -10
  140. package/lib/weapp/unique.js +1 -5
  141. package/lib/weapp/unsavedChildren.js +0 -8
  142. package/lib/weapp/uuid.js +3 -3
  143. package/package.json +5 -6
@@ -8,24 +8,27 @@ var _CoreManager = _interopRequireDefault(require("./CoreManager"));
8
8
  var _isRevocableSession = _interopRequireDefault(require("./isRevocableSession"));
9
9
  var _ParseError = _interopRequireDefault(require("./ParseError"));
10
10
  var _ParseObject = _interopRequireDefault(require("./ParseObject"));
11
- var _ParseSession = _interopRequireDefault(require("./ParseSession"));
12
11
  var _Storage = _interopRequireDefault(require("./Storage"));
13
12
  function _interopRequireDefault(obj) {
14
13
  return obj && obj.__esModule ? obj : {
15
14
  default: obj
16
15
  };
17
16
  }
18
- /**
19
- * @flow
20
- */
21
- /*:: import type { AttributeMap } from './ObjectStateMutations';*/
22
- /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
23
- /*:: export type AuthData = ?{ [key: string]: mixed };*/
17
+ /*:: export type AuthData = { [key: string]: any };*/
18
+ /*:: export type AuthProviderType = {
19
+ authenticate?(options: {
20
+ error?: (provider: AuthProviderType, error: string | any) => void,
21
+ success?: (provider: AuthProviderType, result: AuthData) => void,
22
+ }): void,
23
+ restoreAuthentication(authData: any): boolean;
24
+ getAuthType(): string;
25
+ deauthenticate?(): void;
26
+ };*/
24
27
  const CURRENT_USER_KEY = 'currentUser';
25
28
  let canUseCurrentUser = !_CoreManager.default.get('IS_NODE');
26
29
  let currentUserCacheMatchesDisk = false;
27
- let currentUserCache = null;
28
- const authProviders = {};
30
+ let currentUserCache /*: ParseUser | null*/ = null;
31
+ const authProviders /*: { [key: string]: AuthProviderType }*/ = {};
29
32
 
30
33
  /**
31
34
  * <p>A Parse.User object is a local representation of a user persisted to the
@@ -41,7 +44,7 @@ class ParseUser extends _ParseObject.default {
41
44
  /**
42
45
  * @param {object} attributes The initial set of data to store in the user.
43
46
  */
44
- constructor(attributes /*: ?AttributeMap*/) {
47
+ constructor(attributes /*:: ?: AttributeMap*/) {
45
48
  super('_User');
46
49
  if (attributes && typeof attributes === 'object') {
47
50
  if (!this.set(attributes || {})) {
@@ -59,7 +62,7 @@ class ParseUser extends _ParseObject.default {
59
62
  */
60
63
  _upgradeToRevocableSession(options /*: RequestOptions*/) /*: Promise<void>*/{
61
64
  options = options || {};
62
- const upgradeOptions = {};
65
+ const upgradeOptions /*: RequestOptions*/ = {};
63
66
  if (options.hasOwnProperty('useMasterKey')) {
64
67
  upgradeOptions.useMasterKey = options.useMasterKey;
65
68
  }
@@ -75,6 +78,7 @@ class ParseUser extends _ParseObject.default {
75
78
  * @see {@link https://docs.parseplatform.org/js/guide/#linking-users Linking Users}
76
79
  * @param {string | AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
77
80
  * @param {object} options
81
+ * @param {object} [options.authData] AuthData to link with
78
82
  * <ul>
79
83
  * <li>If provider is string, options is {@link http://docs.parseplatform.org/parse-server/guide/#supported-3rd-party-authentications authData}
80
84
  * <li>If provider is AuthProvider, options is saveOpts
@@ -82,7 +86,7 @@ class ParseUser extends _ParseObject.default {
82
86
  * @param {object} saveOpts useMasterKey / sessionToken
83
87
  * @returns {Promise} A promise that is fulfilled with the user is linked
84
88
  */
85
- linkWith(provider /*: any*/, options /*: { authData?: AuthData }*/, saveOpts /*:: ?: FullOptions*/ = {}) /*: Promise<ParseUser>*/{
89
+ linkWith(provider /*: AuthProviderType*/, options /*: { authData?: AuthData }*/, saveOpts /*: FullOptions*/ = {}) /*: Promise<ParseUser>*/{
86
90
  saveOpts.sessionToken = saveOpts.sessionToken || this.getSessionToken() || '';
87
91
  let authType;
88
92
  if (typeof provider === 'string') {
@@ -122,7 +126,7 @@ class ParseUser extends _ParseObject.default {
122
126
  return new Promise((resolve, reject) => {
123
127
  provider.authenticate({
124
128
  success: (provider, result) => {
125
- const opts = {};
129
+ const opts /*: { authData?: AuthData }*/ = {};
126
130
  opts.authData = result;
127
131
  this.linkWith(provider, opts, saveOpts).then(() => {
128
132
  resolve(this);
@@ -141,11 +145,12 @@ class ParseUser extends _ParseObject.default {
141
145
  /**
142
146
  * @param provider
143
147
  * @param options
148
+ * @param {object} [options.authData]
144
149
  * @param saveOpts
145
150
  * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith}
146
151
  * @returns {Promise}
147
152
  */
148
- _linkWith(provider /*: any*/, options /*: { authData?: AuthData }*/, saveOpts /*:: ?: FullOptions*/ = {}) /*: Promise<ParseUser>*/{
153
+ _linkWith(provider /*: any*/, options /*: { authData?: AuthData }*/, saveOpts /*: FullOptions*/ = {}) /*: Promise<ParseUser>*/{
149
154
  return this.linkWith(provider, options, saveOpts);
150
155
  }
151
156
 
@@ -155,7 +160,7 @@ class ParseUser extends _ParseObject.default {
155
160
  *
156
161
  * @param provider
157
162
  */
158
- _synchronizeAuthData(provider /*: string*/) {
163
+ _synchronizeAuthData(provider /*: string | AuthProviderType*/) {
159
164
  if (!this.isCurrent() || !provider) {
160
165
  return;
161
166
  }
@@ -325,7 +330,7 @@ class ParseUser extends _ParseObject.default {
325
330
  *
326
331
  * @returns {string}
327
332
  */
328
- getUsername() /*: ?string*/{
333
+ getUsername() /*: string | null*/{
329
334
  const username = this.get('username');
330
335
  if (username == null || typeof username === 'string') {
331
336
  return username;
@@ -357,7 +362,7 @@ class ParseUser extends _ParseObject.default {
357
362
  *
358
363
  * @returns {string} User's Email
359
364
  */
360
- getEmail() /*: ?string*/{
365
+ getEmail() /*: string | null*/{
361
366
  const email = this.get('email');
362
367
  if (email == null || typeof email === 'string') {
363
368
  return email;
@@ -382,7 +387,7 @@ class ParseUser extends _ParseObject.default {
382
387
  *
383
388
  * @returns {string} the session token, or undefined
384
389
  */
385
- getSessionToken() /*: ?string*/{
390
+ getSessionToken() /*: string | null*/{
386
391
  const token = this.get('sessionToken');
387
392
  if (token == null || typeof token === 'string') {
388
393
  return token;
@@ -413,9 +418,9 @@ class ParseUser extends _ParseObject.default {
413
418
  * @returns {Promise} A promise that is fulfilled when the signup
414
419
  * finishes.
415
420
  */
416
- signUp(attrs /*: AttributeMap*/, options /*:: ?: FullOptions*/) /*: Promise<ParseUser>*/{
421
+ signUp(attrs /*: AttributeMap*/, options /*:: ?: FullOptions & { context?: AttributeMap }*/) /*: Promise<ParseUser>*/{
417
422
  options = options || {};
418
- const signupOptions = {};
423
+ const signupOptions /*: FullOptions & { context?: AttributeMap }*/ = {};
419
424
  if (options.hasOwnProperty('useMasterKey')) {
420
425
  signupOptions.useMasterKey = options.useMasterKey;
421
426
  }
@@ -440,9 +445,9 @@ class ParseUser extends _ParseObject.default {
440
445
  * @returns {Promise} A promise that is fulfilled with the user when
441
446
  * the login is complete.
442
447
  */
443
- logIn(options /*:: ?: FullOptions*/) /*: Promise<ParseUser>*/{
448
+ logIn(options /*: FullOptions & { context?: AttributeMap }*/ = {}) /*: Promise<ParseUser>*/{
444
449
  options = options || {};
445
- const loginOptions = {
450
+ const loginOptions /*: FullOptions & { context?: AttributeMap }*/ = {
446
451
  usePost: true
447
452
  };
448
453
  if (options.hasOwnProperty('useMasterKey')) {
@@ -468,7 +473,7 @@ class ParseUser extends _ParseObject.default {
468
473
  * @param {...any} args
469
474
  * @returns {Promise}
470
475
  */
471
- async save(...args /*: Array<any>*/) /*: Promise<ParseUser>*/{
476
+ async save(...args) /*: Promise<this>*/{
472
477
  await super.save.apply(this, args);
473
478
  const current = await this.isCurrentAsync();
474
479
  if (current) {
@@ -484,7 +489,7 @@ class ParseUser extends _ParseObject.default {
484
489
  * @param {...any} args
485
490
  * @returns {Parse.User}
486
491
  */
487
- async destroy(...args /*: Array<any>*/) /*: Promise<ParseUser>*/{
492
+ async destroy(...args) /*: Promise<ParseUser | void>*/{
488
493
  await super.destroy.apply(this, args);
489
494
  const current = await this.isCurrentAsync();
490
495
  if (current) {
@@ -500,7 +505,7 @@ class ParseUser extends _ParseObject.default {
500
505
  * @param {...any} args
501
506
  * @returns {Parse.User}
502
507
  */
503
- async fetch(...args /*: Array<any>*/) /*: Promise<ParseUser>*/{
508
+ async fetch(...args) /*: Promise<ParseUser>*/{
504
509
  await super.fetch.apply(this, args);
505
510
  const current = await this.isCurrentAsync();
506
511
  if (current) {
@@ -516,7 +521,7 @@ class ParseUser extends _ParseObject.default {
516
521
  * @param {...any} args
517
522
  * @returns {Parse.User}
518
523
  */
519
- async fetchWithInclude(...args /*: Array<any>*/) /*: Promise<ParseUser>*/{
524
+ async fetchWithInclude(...args) /*: Promise<ParseUser>*/{
520
525
  await super.fetchWithInclude.apply(this, args);
521
526
  const current = await this.isCurrentAsync();
522
527
  if (current) {
@@ -585,7 +590,7 @@ class ParseUser extends _ParseObject.default {
585
590
  * @static
586
591
  * @returns {Parse.Object} The currently logged in Parse.User.
587
592
  */
588
- static current() /*: ?ParseUser*/{
593
+ static current() /*: ParseUser | null*/{
589
594
  if (!canUseCurrentUser) {
590
595
  return null;
591
596
  }
@@ -600,7 +605,7 @@ class ParseUser extends _ParseObject.default {
600
605
  * @returns {Promise} A Promise that is resolved with the currently
601
606
  * logged in Parse User
602
607
  */
603
- static currentAsync() /*: Promise<?ParseUser>*/{
608
+ static currentAsync() /*: Promise<ParseUser | null>*/{
604
609
  if (!canUseCurrentUser) {
605
610
  return Promise.resolve(null);
606
611
  }
@@ -742,7 +747,7 @@ class ParseUser extends _ParseObject.default {
742
747
  * @static
743
748
  * @returns {Promise} A promise that is fulfilled with the user is fetched.
744
749
  */
745
- static me(sessionToken /*: string*/, options /*:: ?: RequestOptions*/ = {}) {
750
+ static me(sessionToken /*: string*/, options /*: RequestOptions*/ = {}) {
746
751
  const controller = _CoreManager.default.getUserController();
747
752
  const meOptions /*: RequestOptions*/ = {
748
753
  sessionToken: sessionToken
@@ -775,6 +780,7 @@ class ParseUser extends _ParseObject.default {
775
780
  *
776
781
  * @param provider
777
782
  * @param options
783
+ * @param {object} [options.authData]
778
784
  * @param saveOpts
779
785
  * @static
780
786
  * @returns {Promise}
@@ -812,7 +818,7 @@ class ParseUser extends _ParseObject.default {
812
818
  */
813
819
  static requestPasswordReset(email /*: string*/, options /*:: ?: RequestOptions*/) {
814
820
  options = options || {};
815
- const requestOptions = {};
821
+ const requestOptions /*: RequestOptions*/ = {};
816
822
  if (options.hasOwnProperty('useMasterKey')) {
817
823
  requestOptions.useMasterKey = options.useMasterKey;
818
824
  }
@@ -831,7 +837,7 @@ class ParseUser extends _ParseObject.default {
831
837
  */
832
838
  static requestEmailVerification(email /*: string*/, options /*:: ?: RequestOptions*/) {
833
839
  options = options || {};
834
- const requestOptions = {};
840
+ const requestOptions /*: RequestOptions*/ = {};
835
841
  if (options.hasOwnProperty('useMasterKey')) {
836
842
  requestOptions.useMasterKey = options.useMasterKey;
837
843
  }
@@ -947,6 +953,7 @@ class ParseUser extends _ParseObject.default {
947
953
  /**
948
954
  * @param provider
949
955
  * @param options
956
+ * @param {object} [options.authData]
950
957
  * @param saveOpts
951
958
  * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#logInWith logInWith}
952
959
  * @static
@@ -992,7 +999,7 @@ const DefaultController = {
992
999
  user._synchronizeAllAuthData();
993
1000
  return DefaultController.updateUserOnDisk(user);
994
1001
  },
995
- currentUser() /*: ?ParseUser*/{
1002
+ currentUser() /*: ParseUser | null*/{
996
1003
  if (currentUserCache) {
997
1004
  return currentUserCache;
998
1005
  }
@@ -1032,7 +1039,7 @@ const DefaultController = {
1032
1039
  current._synchronizeAllAuthData();
1033
1040
  return current;
1034
1041
  },
1035
- currentUserAsync() /*: Promise<?ParseUser>*/{
1042
+ currentUserAsync() /*: Promise<ParseUser | null>*/{
1036
1043
  if (currentUserCache) {
1037
1044
  return Promise.resolve(currentUserCache);
1038
1045
  }
@@ -1152,7 +1159,7 @@ const DefaultController = {
1152
1159
  return user;
1153
1160
  });
1154
1161
  },
1155
- logOut(options /*: RequestOptions*/) /*: Promise<ParseUser>*/{
1162
+ logOut(options /*: RequestOptions*/) /*: Promise<void>*/{
1156
1163
  const RESTController = _CoreManager.default.getRESTController();
1157
1164
  if (options.sessionToken) {
1158
1165
  return RESTController.request('POST', 'logout', {}, options);
@@ -1193,10 +1200,8 @@ const DefaultController = {
1193
1200
  options.sessionToken = token;
1194
1201
  const RESTController = _CoreManager.default.getRESTController();
1195
1202
  const result = await RESTController.request('POST', 'upgradeToRevocableSession', {}, options);
1196
- const session = new _ParseSession.default();
1197
- session._finishFetch(result);
1198
1203
  user._finishFetch({
1199
- sessionToken: session.getSessionToken()
1204
+ sessionToken: (result === null || result === void 0 ? void 0 : result.sessionToken) || ''
1200
1205
  });
1201
1206
  const current = await user.isCurrentAsync();
1202
1207
  if (current) {
package/lib/node/Push.js CHANGED
@@ -12,11 +12,6 @@ function _interopRequireDefault(obj) {
12
12
  default: obj
13
13
  };
14
14
  }
15
- /**
16
- * @flow
17
- */
18
- /*:: import type { WhereClause } from './ParseQuery';*/
19
- /*:: import type { FullOptions } from './RESTController';*/
20
15
  /*:: export type PushData = {
21
16
  where?: WhereClause | ParseQuery,
22
17
  push_time?: Date | string,
@@ -56,9 +51,9 @@ function _interopRequireDefault(obj) {
56
51
  * be used for this request.
57
52
  * </ul>
58
53
  * @returns {Promise} A promise that is fulfilled when the push request
59
- * completes.
54
+ * completes and returns `pushStatusId`.
60
55
  */
61
- function send(data /*: PushData*/, options /*:: ?: FullOptions*/ = {}) /*: Promise*/{
56
+ function send(data /*: PushData*/, options /*: FullOptions*/ = {}) /*: Promise<string>*/{
62
57
  if (data.where && data.where instanceof _ParseQuery.default) {
63
58
  data.where = data.where.toJSON().where;
64
59
  }
@@ -93,7 +88,7 @@ function send(data /*: PushData*/, options /*:: ?: FullOptions*/ = {}) /*: Promi
93
88
  * </ul>
94
89
  * @returns {Parse.Object} Status of Push.
95
90
  */
96
- function getPushStatus(pushStatusId /*: string*/, options /*:: ?: FullOptions*/ = {}) /*: Promise<string>*/{
91
+ function getPushStatus(pushStatusId /*: string*/, options /*: FullOptions*/ = {}) /*: Promise<ParseObject>*/{
97
92
  const pushOptions = {
98
93
  useMasterKey: true
99
94
  };
@@ -202,7 +202,7 @@ const RESTController = {
202
202
  dispatch();
203
203
  return promise;
204
204
  },
205
- request(method /*: string*/, path /*: string*/, data /*: mixed*/, options /*:: ?: RequestOptions*/) {
205
+ request(method /*: string*/, path /*: string*/, data /*: any*/, options /*:: ?: RequestOptions*/) {
206
206
  options = options || {};
207
207
  let url = _CoreManager.default.get('SERVER_URL');
208
208
  if (url[url.length - 1] !== '/') {
@@ -145,7 +145,7 @@ function getObjectCache(obj /*: ObjectIdentifier*/) /*: ObjectCache*/{
145
145
  }
146
146
  return {};
147
147
  }
148
- function estimateAttribute(obj /*: ObjectIdentifier*/, attr /*: string*/) /*: mixed*/{
148
+ function estimateAttribute(obj /*: ObjectIdentifier*/, attr /*: string*/) /*: any*/{
149
149
  const serverData = getServerData(obj);
150
150
  const pendingOps = getPendingOps(obj);
151
151
  return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj, attr);
@@ -1,20 +1,16 @@
1
1
  "use strict";
2
2
 
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
3
7
  var _promiseUtils = require("./promiseUtils");
4
- /**
5
- * @flow
6
- */
7
- /*:: type Task = {
8
- task: () => Promise,
9
- _completion: Promise,
10
- };*/
11
8
  class TaskQueue {
12
- /*:: queue: Array<Task>;*/
13
9
  constructor() {
14
10
  this.queue = [];
15
11
  }
16
- enqueue(task /*: () => Promise*/) /*: Promise*/{
17
- const taskComplete = new _promiseUtils.resolvingPromise();
12
+ enqueue(task /*: () => Promise<void>*/) /*: Promise<void>*/{
13
+ const taskComplete = (0, _promiseUtils.resolvingPromise)();
18
14
  this.queue.push({
19
15
  task: task,
20
16
  _completion: taskComplete
@@ -44,4 +40,6 @@ class TaskQueue {
44
40
  }
45
41
  }
46
42
  }
47
- module.exports = TaskQueue;
43
+ module.exports = TaskQueue;
44
+ var _default = TaskQueue;
45
+ exports.default = _default;
@@ -144,7 +144,7 @@ function getObjectCache(obj /*: ParseObject*/) /*: ObjectCache*/{
144
144
  }
145
145
  return {};
146
146
  }
147
- function estimateAttribute(obj /*: ParseObject*/, attr /*: string*/) /*: mixed*/{
147
+ function estimateAttribute(obj /*: ParseObject*/, attr /*: string*/) /*: any*/{
148
148
  const serverData = getServerData(obj);
149
149
  const pendingOps = getPendingOps(obj);
150
150
  return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj, attr);
@@ -10,10 +10,6 @@ function _interopRequireDefault(obj) {
10
10
  default: obj
11
11
  };
12
12
  }
13
- /**
14
- * @flow
15
- */
16
- /*:: import type ParseObject from './ParseObject';*/
17
13
  function arrayContainsObject(array /*: Array<any>*/, object /*: ParseObject*/) /*: boolean*/{
18
14
  if (array.indexOf(object) > -1) {
19
15
  return true;
@@ -12,10 +12,6 @@ function _interopRequireDefault(obj) {
12
12
  default: obj
13
13
  };
14
14
  }
15
- /**
16
- * @flow
17
- */
18
- /*:: import type ParseObject from './ParseObject';*/
19
15
  function canBeSerialized(obj /*: ParseObject*/) /*: boolean*/{
20
16
  const ParseObject = _CoreManager.default.getParseObject();
21
17
  if (!(obj instanceof ParseObject)) {
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = decode;
7
7
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
8
- var _ParseACL = _interopRequireDefault(require("./ParseACL"));
9
8
  var _ParseFile = _interopRequireDefault(require("./ParseFile"));
10
9
  var _ParseGeoPoint = _interopRequireDefault(require("./ParseGeoPoint"));
11
10
  var _ParsePolygon = _interopRequireDefault(require("./ParsePolygon"));
@@ -15,12 +14,6 @@ function _interopRequireDefault(obj) {
15
14
  default: obj
16
15
  };
17
16
  }
18
- /**
19
- * @flow
20
- */
21
-
22
- // eslint-disable-line no-unused-vars
23
-
24
17
  function decode(value /*: any*/) /*: any*/{
25
18
  if (value === null || typeof value !== 'object' || value instanceof Date) {
26
19
  return value;
@@ -15,11 +15,7 @@ function _interopRequireDefault(obj) {
15
15
  default: obj
16
16
  };
17
17
  }
18
- /**
19
- * @flow
20
- */
21
-
22
- function encode(value /*: mixed*/, disallowObjects /*: boolean*/, forcePointers /*: boolean*/, seen /*: Array<mixed>*/, offline /*: boolean*/) /*: any*/{
18
+ function encode(value /*: any*/, disallowObjects /*: boolean*/, forcePointers /*: boolean*/, seen /*: Array<any>*/, offline /*: boolean*/) /*: any*/{
23
19
  const ParseObject = _CoreManager.default.getParseObject();
24
20
  if (value instanceof ParseObject) {
25
21
  if (disallowObjects) {
@@ -53,7 +49,7 @@ function encode(value /*: mixed*/, disallowObjects /*: boolean*/, forcePointers
53
49
  }
54
50
  return {
55
51
  __type: 'Date',
56
- iso: value /*: any*/.toJSON()
52
+ iso: value.toJSON()
57
53
  };
58
54
  }
59
55
  if (Object.prototype.toString.call(value) === '[object RegExp]' && typeof value.source === 'string') {
@@ -73,6 +69,6 @@ function encode(value /*: mixed*/, disallowObjects /*: boolean*/, forcePointers
73
69
  }
74
70
  return value;
75
71
  }
76
- function _default(value /*: mixed*/, disallowObjects /*:: ?: boolean*/, forcePointers /*:: ?: boolean*/, seen /*:: ?: Array<mixed>*/, offline /*:: ?: boolean*/) /*: any*/{
72
+ function _default(value /*: any*/, disallowObjects /*:: ?: boolean*/, forcePointers /*:: ?: boolean*/, seen /*:: ?: Array<any>*/, offline /*:: ?: boolean*/) /*: any*/{
77
73
  return encode(value, !!disallowObjects, !!forcePointers, seen || [], offline);
78
74
  }
@@ -13,7 +13,7 @@ function _interopRequireDefault(obj) {
13
13
  default: obj
14
14
  };
15
15
  }
16
- function equals(a, b) {
16
+ function equals(a /*: any*/, b /*: any*/) /*: boolean*/{
17
17
  const toString = Object.prototype.toString;
18
18
  if (toString.call(a) === '[object Date]' || toString.call(b) === '[object Date]') {
19
19
  const dateA = new Date(a);
@@ -4,10 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = escape;
7
- /*
8
- * @flow
9
- */
10
-
11
7
  const encoded = {
12
8
  '&': '&amp;',
13
9
  '<': '&lt;',
@@ -4,10 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = isRevocableSession;
7
- /**
8
- * @flow
9
- */
10
-
11
7
  function isRevocableSession(token /*: string*/) /*: boolean*/{
12
8
  return token.indexOf('r:') > -1;
13
9
  }
@@ -4,11 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = parseDate;
7
- /**
8
- * @flow
9
- */
10
-
11
- function parseDate(iso8601 /*: string*/) /*: ?Date*/{
7
+ function parseDate(iso8601 /*: string*/) /*: Date | null*/{
12
8
  const regexp = new RegExp('^([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2})' + 'T' + '([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})' + '(.([0-9]+))?' + 'Z$');
13
9
  const match = regexp.exec(iso8601);
14
10
  if (!match) {
@@ -7,18 +7,19 @@ exports.continueWhile = continueWhile;
7
7
  exports.resolvingPromise = resolvingPromise;
8
8
  exports.when = when;
9
9
  // Create Deferred Promise
10
- function resolvingPromise() {
11
- let res;
12
- let rej;
10
+ function resolvingPromise /*:: <T = any>*/() {
11
+ let res /*: (value: T) => void*/;
12
+ let rej /*: (error: T) => void*/;
13
13
  const promise = new Promise((resolve, reject) => {
14
14
  res = resolve;
15
15
  rej = reject;
16
16
  });
17
- promise.resolve = res;
18
- promise.reject = rej;
19
- return promise;
17
+ const defer /*: typeof promise & { resolve: (res: T) => void, reject: (err: any) => void }*/ = promise;
18
+ defer.resolve = res;
19
+ defer.reject = rej;
20
+ return defer;
20
21
  }
21
- function when(promises) {
22
+ function when(promises /*: any*/) {
22
23
  let objects;
23
24
  const arrayArgument = Array.isArray(promises);
24
25
  if (arrayArgument) {
@@ -36,7 +37,7 @@ function when(promises) {
36
37
  if (total === 0) {
37
38
  return Promise.resolve(returnValue);
38
39
  }
39
- const promise = new resolvingPromise();
40
+ const promise = resolvingPromise();
40
41
  const resolveOne = function () {
41
42
  total--;
42
43
  if (total <= 0) {
@@ -47,7 +48,7 @@ function when(promises) {
47
48
  }
48
49
  }
49
50
  };
50
- const chain = function (object, index) {
51
+ const chain = function (object /*: Promise<any>*/, index /*: number*/) {
51
52
  if (object && typeof object.then === 'function') {
52
53
  object.then(function (result) {
53
54
  results[index] = result;
@@ -67,7 +68,7 @@ function when(promises) {
67
68
  }
68
69
  return promise;
69
70
  }
70
- function continueWhile(test, emitter) {
71
+ function continueWhile(test /*: () => any*/, emitter /*: () => Promise<any>*/) {
71
72
  if (test()) {
72
73
  return emitter().then(() => {
73
74
  return continueWhile(test, emitter);
@@ -11,12 +11,8 @@ function _interopRequireDefault(obj) {
11
11
  default: obj
12
12
  };
13
13
  }
14
- /**
15
- * @flow
16
- */
17
-
18
14
  function unique /*:: <T>*/(arr /*: Array<T>*/) /*: Array<T>*/{
19
- const uniques = [];
15
+ const uniques /*: T[]*/ = [];
20
16
  arr.forEach(value => {
21
17
  const ParseObject = _CoreManager.default.getParseObject();
22
18
  if (value instanceof ParseObject) {
@@ -12,14 +12,6 @@ function _interopRequireDefault(obj) {
12
12
  default: obj
13
13
  };
14
14
  }
15
- /**
16
- * @flow
17
- */
18
- /*:: import type ParseObject from './ParseObject';*/
19
- /*:: type EncounterMap = {
20
- objects: { [identifier: string]: ParseObject | boolean },
21
- files: Array<ParseFile>,
22
- };*/
23
15
  /**
24
16
  * Return an array of unsaved children, which are either Parse Objects or Files.
25
17
  * If it encounters any dirty Objects without Ids, it will throw an exception.
package/lib/node/uuid.js CHANGED
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _uuid = require("uuid");
8
- let uuid /*: () => string*/ = null;
9
- uuid = _uuid.v4;
8
+ let uuid = _uuid.v4 /*: () => string*/;
9
+
10
10
  module.exports = uuid;
11
11
  var _default = uuid;
12
12
  exports.default = _default;
@@ -12,7 +12,6 @@ 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"));
16
15
  function run(name, data, options) {
17
16
  options = options || {};
18
17
  if (typeof name !== 'string' || name.length === 0) {
@@ -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.1.0",
15
+ VERSION: 'js' + "5.2.0-alpha.1",
16
16
  APPLICATION_ID: null,
17
17
  JAVASCRIPT_KEY: null,
18
18
  MASTER_KEY: null,