parse 5.1.1-alpha.1 → 5.2.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 (249) hide show
  1. package/dist/parse.js +10186 -14918
  2. package/dist/parse.min.js +2 -2
  3. package/dist/parse.weapp.js +10180 -15057
  4. package/dist/parse.weapp.min.js +2 -2
  5. package/lib/browser/Analytics.js +7 -11
  6. package/lib/browser/AnonymousUtils.js +17 -22
  7. package/lib/browser/Cloud.js +24 -46
  8. package/lib/browser/CoreManager.js +71 -79
  9. package/lib/browser/CryptoController.js +14 -9
  10. package/lib/browser/EventEmitter.js +9 -2
  11. package/lib/browser/EventuallyQueue.js +156 -357
  12. package/lib/browser/FacebookUtils.js +23 -28
  13. package/lib/browser/IndexedDBStorageController.js +18 -14
  14. package/lib/browser/InstallationController.js +55 -121
  15. package/lib/browser/LiveQueryClient.js +312 -446
  16. package/lib/browser/LiveQuerySubscription.js +25 -28
  17. package/lib/browser/LocalDatastore.js +254 -578
  18. package/lib/browser/LocalDatastoreController.default.js +48 -227
  19. package/lib/browser/LocalDatastoreController.js +11 -1
  20. package/lib/browser/LocalDatastoreController.react-native.js +72 -164
  21. package/lib/browser/LocalDatastoreUtils.js +4 -12
  22. package/lib/browser/ObjectStateMutations.js +89 -95
  23. package/lib/browser/OfflineQuery.js +106 -198
  24. package/lib/browser/Parse.js +45 -61
  25. package/lib/browser/ParseACL.js +242 -288
  26. package/lib/browser/ParseCLP.js +372 -580
  27. package/lib/browser/ParseConfig.js +115 -138
  28. package/lib/browser/ParseError.js +85 -182
  29. package/lib/browser/ParseFile.js +296 -444
  30. package/lib/browser/ParseGeoPoint.js +121 -140
  31. package/lib/browser/ParseHooks.js +12 -14
  32. package/lib/browser/ParseInstallation.js +226 -354
  33. package/lib/browser/ParseLiveQuery.js +74 -148
  34. package/lib/browser/ParseObject.js +2017 -2622
  35. package/lib/browser/ParseOp.js +343 -484
  36. package/lib/browser/ParsePolygon.js +101 -120
  37. package/lib/browser/ParseQuery.js +1722 -2068
  38. package/lib/browser/ParseRelation.js +99 -118
  39. package/lib/browser/ParseRole.js +88 -144
  40. package/lib/browser/ParseSchema.js +372 -434
  41. package/lib/browser/ParseSession.js +62 -110
  42. package/lib/browser/ParseUser.js +942 -1270
  43. package/lib/browser/Push.js +16 -44
  44. package/lib/browser/RESTController.js +85 -124
  45. package/lib/browser/SingleInstanceStateController.js +57 -86
  46. package/lib/browser/Socket.weapp.js +50 -33
  47. package/lib/browser/Storage.js +23 -28
  48. package/lib/browser/StorageController.browser.js +16 -13
  49. package/lib/browser/StorageController.default.js +15 -14
  50. package/lib/browser/StorageController.js +14 -1
  51. package/lib/browser/StorageController.react-native.js +31 -30
  52. package/lib/browser/StorageController.weapp.js +19 -13
  53. package/lib/browser/TaskQueue.js +37 -49
  54. package/lib/browser/UniqueInstanceStateController.js +65 -86
  55. package/lib/browser/WebSocketController.js +11 -4
  56. package/lib/browser/Xhr.weapp.js +90 -78
  57. package/lib/browser/arrayContainsObject.js +3 -3
  58. package/lib/browser/canBeSerialized.js +10 -11
  59. package/lib/browser/decode.js +11 -11
  60. package/lib/browser/encode.js +11 -11
  61. package/lib/browser/equals.js +9 -10
  62. package/lib/browser/escape.js +2 -2
  63. package/lib/browser/isRevocableSession.js +1 -1
  64. package/lib/browser/parseDate.js +10 -10
  65. package/lib/browser/promiseUtils.js +19 -19
  66. package/lib/browser/unique.js +4 -4
  67. package/lib/browser/unsavedChildren.js +20 -21
  68. package/lib/browser/uuid.js +2 -4
  69. package/lib/node/Analytics.js +2 -6
  70. package/lib/node/AnonymousUtils.js +7 -12
  71. package/lib/node/Cloud.js +8 -12
  72. package/lib/node/CoreManager.js +59 -67
  73. package/lib/node/CryptoController.js +8 -3
  74. package/lib/node/EventEmitter.js +7 -1
  75. package/lib/node/EventuallyQueue.js +18 -37
  76. package/lib/node/FacebookUtils.js +1 -5
  77. package/lib/node/IndexedDBStorageController.js +14 -10
  78. package/lib/node/InstallationController.js +7 -8
  79. package/lib/node/LiveQueryClient.js +20 -32
  80. package/lib/node/LiveQuerySubscription.js +3 -4
  81. package/lib/node/LocalDatastore.js +20 -24
  82. package/lib/node/LocalDatastoreController.default.js +12 -11
  83. package/lib/node/LocalDatastoreController.js +14 -1
  84. package/lib/node/LocalDatastoreController.react-native.js +27 -22
  85. package/lib/node/LocalDatastoreUtils.js +4 -12
  86. package/lib/node/ObjectStateMutations.js +52 -36
  87. package/lib/node/OfflineQuery.js +37 -23
  88. package/lib/node/Parse.js +35 -49
  89. package/lib/node/ParseACL.js +18 -27
  90. package/lib/node/ParseCLP.js +38 -50
  91. package/lib/node/ParseConfig.js +7 -14
  92. package/lib/node/ParseError.js +457 -458
  93. package/lib/node/ParseFile.js +33 -66
  94. package/lib/node/ParseGeoPoint.js +22 -17
  95. package/lib/node/ParseHooks.js +0 -2
  96. package/lib/node/ParseInstallation.js +21 -8
  97. package/lib/node/ParseLiveQuery.js +6 -11
  98. package/lib/node/ParseObject.js +138 -167
  99. package/lib/node/ParseOp.js +32 -44
  100. package/lib/node/ParsePolygon.js +11 -17
  101. package/lib/node/ParseQuery.js +118 -164
  102. package/lib/node/ParseRelation.js +7 -16
  103. package/lib/node/ParseRole.js +7 -13
  104. package/lib/node/ParseSchema.js +26 -39
  105. package/lib/node/ParseSession.js +7 -8
  106. package/lib/node/ParseUser.js +70 -76
  107. package/lib/node/Push.js +5 -15
  108. package/lib/node/RESTController.js +21 -33
  109. package/lib/node/SingleInstanceStateController.js +41 -69
  110. package/lib/node/Socket.weapp.js +23 -2
  111. package/lib/node/Storage.js +11 -16
  112. package/lib/node/StorageController.browser.js +10 -8
  113. package/lib/node/StorageController.default.js +9 -9
  114. package/lib/node/StorageController.js +16 -1
  115. package/lib/node/StorageController.react-native.js +17 -17
  116. package/lib/node/StorageController.weapp.js +14 -8
  117. package/lib/node/TaskQueue.js +8 -11
  118. package/lib/node/UniqueInstanceStateController.js +40 -60
  119. package/lib/node/WebSocketController.js +15 -2
  120. package/lib/node/Xhr.weapp.js +11 -2
  121. package/lib/node/arrayContainsObject.js +1 -1
  122. package/lib/node/canBeSerialized.js +2 -2
  123. package/lib/node/decode.js +1 -1
  124. package/lib/node/encode.js +2 -2
  125. package/lib/node/equals.js +1 -1
  126. package/lib/node/escape.js +1 -1
  127. package/lib/node/isRevocableSession.js +1 -1
  128. package/lib/node/parseDate.js +1 -1
  129. package/lib/node/promiseUtils.js +7 -7
  130. package/lib/node/unique.js +2 -2
  131. package/lib/node/unsavedChildren.js +2 -2
  132. package/lib/node/uuid.js +2 -4
  133. package/lib/react-native/Analytics.js +2 -2
  134. package/lib/react-native/AnonymousUtils.js +3 -4
  135. package/lib/react-native/Cloud.js +0 -1
  136. package/lib/react-native/CoreManager.js +2 -3
  137. package/lib/react-native/CryptoController.js +6 -1
  138. package/lib/react-native/EventEmitter.js +6 -1
  139. package/lib/react-native/EventuallyQueue.js +1 -2
  140. package/lib/react-native/FacebookUtils.js +1 -2
  141. package/lib/react-native/IndexedDBStorageController.js +11 -5
  142. package/lib/react-native/InstallationController.js +1 -2
  143. package/lib/react-native/LiveQueryClient.js +51 -36
  144. package/lib/react-native/LiveQuerySubscription.js +2 -4
  145. package/lib/react-native/LocalDatastore.js +41 -17
  146. package/lib/react-native/LocalDatastoreController.default.js +6 -1
  147. package/lib/react-native/LocalDatastoreController.js +11 -1
  148. package/lib/react-native/LocalDatastoreController.react-native.js +16 -11
  149. package/lib/react-native/LocalDatastoreUtils.js +3 -6
  150. package/lib/react-native/ObjectStateMutations.js +30 -9
  151. package/lib/react-native/OfflineQuery.js +25 -20
  152. package/lib/react-native/Parse.js +24 -38
  153. package/lib/react-native/ParseACL.js +4 -6
  154. package/lib/react-native/ParseCLP.js +5 -7
  155. package/lib/react-native/ParseConfig.js +4 -6
  156. package/lib/react-native/ParseError.js +13 -31
  157. package/lib/react-native/ParseFile.js +10 -10
  158. package/lib/react-native/ParseGeoPoint.js +2 -4
  159. package/lib/react-native/ParseInstallation.js +13 -30
  160. package/lib/react-native/ParseLiveQuery.js +2 -4
  161. package/lib/react-native/ParseObject.js +81 -90
  162. package/lib/react-native/ParseOp.js +41 -79
  163. package/lib/react-native/ParsePolygon.js +2 -4
  164. package/lib/react-native/ParseQuery.js +87 -81
  165. package/lib/react-native/ParseRelation.js +2 -4
  166. package/lib/react-native/ParseRole.js +14 -31
  167. package/lib/react-native/ParseSchema.js +3 -5
  168. package/lib/react-native/ParseSession.js +12 -29
  169. package/lib/react-native/ParseUser.js +32 -51
  170. package/lib/react-native/RESTController.js +10 -4
  171. package/lib/react-native/SingleInstanceStateController.js +23 -37
  172. package/lib/react-native/Socket.weapp.js +9 -4
  173. package/lib/react-native/Storage.js +1 -2
  174. package/lib/react-native/StorageController.browser.js +6 -1
  175. package/lib/react-native/StorageController.default.js +6 -1
  176. package/lib/react-native/StorageController.js +13 -1
  177. package/lib/react-native/StorageController.react-native.js +11 -6
  178. package/lib/react-native/StorageController.weapp.js +6 -1
  179. package/lib/react-native/TaskQueue.js +8 -4
  180. package/lib/react-native/UniqueInstanceStateController.js +23 -37
  181. package/lib/react-native/WebSocketController.js +9 -1
  182. package/lib/react-native/Xhr.weapp.js +9 -4
  183. package/lib/react-native/unsavedChildren.js +3 -3
  184. package/lib/react-native/uuid.js +1 -2
  185. package/lib/weapp/Analytics.js +7 -11
  186. package/lib/weapp/AnonymousUtils.js +17 -22
  187. package/lib/weapp/Cloud.js +24 -46
  188. package/lib/weapp/CoreManager.js +71 -79
  189. package/lib/weapp/CryptoController.js +14 -9
  190. package/lib/weapp/EventEmitter.js +9 -2
  191. package/lib/weapp/EventuallyQueue.js +156 -357
  192. package/lib/weapp/FacebookUtils.js +23 -28
  193. package/lib/weapp/IndexedDBStorageController.js +18 -14
  194. package/lib/weapp/InstallationController.js +55 -121
  195. package/lib/weapp/LiveQueryClient.js +312 -446
  196. package/lib/weapp/LiveQuerySubscription.js +25 -28
  197. package/lib/weapp/LocalDatastore.js +254 -578
  198. package/lib/weapp/LocalDatastoreController.default.js +48 -227
  199. package/lib/weapp/LocalDatastoreController.js +11 -1
  200. package/lib/weapp/LocalDatastoreController.react-native.js +72 -164
  201. package/lib/weapp/LocalDatastoreUtils.js +4 -12
  202. package/lib/weapp/ObjectStateMutations.js +89 -95
  203. package/lib/weapp/OfflineQuery.js +106 -198
  204. package/lib/weapp/Parse.js +45 -60
  205. package/lib/weapp/ParseACL.js +242 -288
  206. package/lib/weapp/ParseCLP.js +372 -580
  207. package/lib/weapp/ParseConfig.js +115 -138
  208. package/lib/weapp/ParseError.js +85 -182
  209. package/lib/weapp/ParseFile.js +297 -446
  210. package/lib/weapp/ParseGeoPoint.js +121 -140
  211. package/lib/weapp/ParseHooks.js +12 -14
  212. package/lib/weapp/ParseInstallation.js +226 -354
  213. package/lib/weapp/ParseLiveQuery.js +74 -148
  214. package/lib/weapp/ParseObject.js +2017 -2622
  215. package/lib/weapp/ParseOp.js +343 -484
  216. package/lib/weapp/ParsePolygon.js +101 -120
  217. package/lib/weapp/ParseQuery.js +1722 -2068
  218. package/lib/weapp/ParseRelation.js +99 -118
  219. package/lib/weapp/ParseRole.js +88 -144
  220. package/lib/weapp/ParseSchema.js +372 -434
  221. package/lib/weapp/ParseSession.js +62 -110
  222. package/lib/weapp/ParseUser.js +942 -1270
  223. package/lib/weapp/Push.js +16 -44
  224. package/lib/weapp/RESTController.js +86 -125
  225. package/lib/weapp/SingleInstanceStateController.js +57 -86
  226. package/lib/weapp/Socket.weapp.js +50 -33
  227. package/lib/weapp/Storage.js +23 -28
  228. package/lib/weapp/StorageController.browser.js +16 -13
  229. package/lib/weapp/StorageController.default.js +15 -14
  230. package/lib/weapp/StorageController.js +14 -1
  231. package/lib/weapp/StorageController.react-native.js +31 -30
  232. package/lib/weapp/StorageController.weapp.js +19 -13
  233. package/lib/weapp/TaskQueue.js +37 -49
  234. package/lib/weapp/UniqueInstanceStateController.js +65 -86
  235. package/lib/weapp/WebSocketController.js +11 -4
  236. package/lib/weapp/Xhr.weapp.js +90 -78
  237. package/lib/weapp/arrayContainsObject.js +3 -3
  238. package/lib/weapp/canBeSerialized.js +10 -11
  239. package/lib/weapp/decode.js +11 -11
  240. package/lib/weapp/encode.js +11 -11
  241. package/lib/weapp/equals.js +9 -10
  242. package/lib/weapp/escape.js +2 -2
  243. package/lib/weapp/isRevocableSession.js +1 -1
  244. package/lib/weapp/parseDate.js +10 -10
  245. package/lib/weapp/promiseUtils.js +19 -19
  246. package/lib/weapp/unique.js +4 -4
  247. package/lib/weapp/unsavedChildren.js +20 -21
  248. package/lib/weapp/uuid.js +6 -8
  249. package/package.json +23 -30
@@ -8,19 +8,12 @@ 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 };*/
24
17
  const CURRENT_USER_KEY = 'currentUser';
25
18
  let canUseCurrentUser = !_CoreManager.default.get('IS_NODE');
26
19
  let currentUserCacheMatchesDisk = false;
@@ -41,7 +34,7 @@ class ParseUser extends _ParseObject.default {
41
34
  /**
42
35
  * @param {object} attributes The initial set of data to store in the user.
43
36
  */
44
- constructor(attributes /*: ?AttributeMap*/) {
37
+ constructor(attributes) {
45
38
  super('_User');
46
39
  if (attributes && typeof attributes === 'object') {
47
40
  if (!this.set(attributes || {})) {
@@ -57,7 +50,7 @@ class ParseUser extends _ParseObject.default {
57
50
  * @returns {Promise} A promise that is resolved when the replacement
58
51
  * token has been fetched.
59
52
  */
60
- _upgradeToRevocableSession(options /*: RequestOptions*/) /*: Promise<void>*/{
53
+ _upgradeToRevocableSession(options) {
61
54
  options = options || {};
62
55
  const upgradeOptions = {};
63
56
  if (options.hasOwnProperty('useMasterKey')) {
@@ -75,6 +68,7 @@ class ParseUser extends _ParseObject.default {
75
68
  * @see {@link https://docs.parseplatform.org/js/guide/#linking-users Linking Users}
76
69
  * @param {string | AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
77
70
  * @param {object} options
71
+ * @param {object} [options.authData] AuthData to link with
78
72
  * <ul>
79
73
  * <li>If provider is string, options is {@link http://docs.parseplatform.org/parse-server/guide/#supported-3rd-party-authentications authData}
80
74
  * <li>If provider is AuthProvider, options is saveOpts
@@ -82,7 +76,7 @@ class ParseUser extends _ParseObject.default {
82
76
  * @param {object} saveOpts useMasterKey / sessionToken
83
77
  * @returns {Promise} A promise that is fulfilled with the user is linked
84
78
  */
85
- linkWith(provider /*: any*/, options /*: { authData?: AuthData }*/, saveOpts /*:: ?: FullOptions*/ = {}) /*: Promise<ParseUser>*/{
79
+ linkWith(provider, options, saveOpts = {}) {
86
80
  saveOpts.sessionToken = saveOpts.sessionToken || this.getSessionToken() || '';
87
81
  let authType;
88
82
  if (typeof provider === 'string') {
@@ -141,11 +135,12 @@ class ParseUser extends _ParseObject.default {
141
135
  /**
142
136
  * @param provider
143
137
  * @param options
138
+ * @param {object} [options.authData]
144
139
  * @param saveOpts
145
140
  * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith}
146
141
  * @returns {Promise}
147
142
  */
148
- _linkWith(provider /*: any*/, options /*: { authData?: AuthData }*/, saveOpts /*:: ?: FullOptions*/ = {}) /*: Promise<ParseUser>*/{
143
+ _linkWith(provider, options, saveOpts = {}) {
149
144
  return this.linkWith(provider, options, saveOpts);
150
145
  }
151
146
 
@@ -155,7 +150,7 @@ class ParseUser extends _ParseObject.default {
155
150
  *
156
151
  * @param provider
157
152
  */
158
- _synchronizeAuthData(provider /*: string*/) {
153
+ _synchronizeAuthData(provider) {
159
154
  if (!this.isCurrent() || !provider) {
160
155
  return;
161
156
  }
@@ -215,7 +210,7 @@ class ParseUser extends _ParseObject.default {
215
210
  * @returns {Promise} A promise that is fulfilled when the unlinking
216
211
  * finishes.
217
212
  */
218
- _unlinkFrom(provider /*: any*/, options /*:: ?: FullOptions*/) /*: Promise<ParseUser>*/{
213
+ _unlinkFrom(provider, options) {
219
214
  return this.linkWith(provider, {
220
215
  authData: null
221
216
  }, options).then(() => {
@@ -230,7 +225,7 @@ class ParseUser extends _ParseObject.default {
230
225
  * @param {object} provider service to link to
231
226
  * @returns {boolean} true if link was successful
232
227
  */
233
- _isLinked(provider /*: any*/) /*: boolean*/{
228
+ _isLinked(provider) {
234
229
  let authType;
235
230
  if (typeof provider === 'string') {
236
231
  authType = provider;
@@ -263,7 +258,7 @@ class ParseUser extends _ParseObject.default {
263
258
  *
264
259
  * @param {object} provider service to logout of
265
260
  */
266
- _logOutWith(provider /*: any*/) {
261
+ _logOutWith(provider) {
267
262
  if (!this.isCurrent()) {
268
263
  return;
269
264
  }
@@ -281,7 +276,7 @@ class ParseUser extends _ParseObject.default {
281
276
  *
282
277
  * @returns {object} sessionToken
283
278
  */
284
- _preserveFieldsOnFetch() /*: AttributeMap*/{
279
+ _preserveFieldsOnFetch() {
285
280
  return {
286
281
  sessionToken: this.get('sessionToken')
287
282
  };
@@ -292,7 +287,7 @@ class ParseUser extends _ParseObject.default {
292
287
  *
293
288
  * @returns {boolean} true if user is cached on disk
294
289
  */
295
- isCurrent() /*: boolean*/{
290
+ isCurrent() {
296
291
  const current = ParseUser.current();
297
292
  return !!current && current.id === this.id;
298
293
  }
@@ -302,7 +297,7 @@ class ParseUser extends _ParseObject.default {
302
297
  *
303
298
  * @returns {Promise<boolean>} true if user is cached on disk
304
299
  */
305
- async isCurrentAsync() /*: Promise<boolean>*/{
300
+ async isCurrentAsync() {
306
301
  const current = await ParseUser.currentAsync();
307
302
  return !!current && current.id === this.id;
308
303
  }
@@ -313,7 +308,7 @@ class ParseUser extends _ParseObject.default {
313
308
  authData.anonymous = null;
314
309
  }
315
310
  }
316
- restoreAnonimity(anonymousData /*: any*/) {
311
+ restoreAnonimity(anonymousData) {
317
312
  if (anonymousData) {
318
313
  const authData = this.get('authData');
319
314
  authData.anonymous = anonymousData;
@@ -325,7 +320,7 @@ class ParseUser extends _ParseObject.default {
325
320
  *
326
321
  * @returns {string}
327
322
  */
328
- getUsername() /*: ?string*/{
323
+ getUsername() {
329
324
  const username = this.get('username');
330
325
  if (username == null || typeof username === 'string') {
331
326
  return username;
@@ -338,7 +333,7 @@ class ParseUser extends _ParseObject.default {
338
333
  *
339
334
  * @param {string} username
340
335
  */
341
- setUsername(username /*: string*/) {
336
+ setUsername(username) {
342
337
  this.stripAnonymity();
343
338
  this.set('username', username);
344
339
  }
@@ -348,7 +343,7 @@ class ParseUser extends _ParseObject.default {
348
343
  *
349
344
  * @param {string} password User's Password
350
345
  */
351
- setPassword(password /*: string*/) {
346
+ setPassword(password) {
352
347
  this.set('password', password);
353
348
  }
354
349
 
@@ -357,7 +352,7 @@ class ParseUser extends _ParseObject.default {
357
352
  *
358
353
  * @returns {string} User's Email
359
354
  */
360
- getEmail() /*: ?string*/{
355
+ getEmail() {
361
356
  const email = this.get('email');
362
357
  if (email == null || typeof email === 'string') {
363
358
  return email;
@@ -371,7 +366,7 @@ class ParseUser extends _ParseObject.default {
371
366
  * @param {string} email
372
367
  * @returns {boolean}
373
368
  */
374
- setEmail(email /*: string*/) {
369
+ setEmail(email) {
375
370
  return this.set('email', email);
376
371
  }
377
372
 
@@ -382,7 +377,7 @@ class ParseUser extends _ParseObject.default {
382
377
  *
383
378
  * @returns {string} the session token, or undefined
384
379
  */
385
- getSessionToken() /*: ?string*/{
380
+ getSessionToken() {
386
381
  const token = this.get('sessionToken');
387
382
  if (token == null || typeof token === 'string') {
388
383
  return token;
@@ -395,7 +390,7 @@ class ParseUser extends _ParseObject.default {
395
390
  *
396
391
  * @returns {boolean} whether this user is the current user and is logged in.
397
392
  */
398
- authenticated() /*: boolean*/{
393
+ authenticated() {
399
394
  const current = ParseUser.current();
400
395
  return !!this.get('sessionToken') && !!current && current.id === this.id;
401
396
  }
@@ -413,7 +408,7 @@ class ParseUser extends _ParseObject.default {
413
408
  * @returns {Promise} A promise that is fulfilled when the signup
414
409
  * finishes.
415
410
  */
416
- signUp(attrs /*: AttributeMap*/, options /*:: ?: FullOptions*/) /*: Promise<ParseUser>*/{
411
+ signUp(attrs, options) {
417
412
  options = options || {};
418
413
  const signupOptions = {};
419
414
  if (options.hasOwnProperty('useMasterKey')) {
@@ -440,7 +435,7 @@ class ParseUser extends _ParseObject.default {
440
435
  * @returns {Promise} A promise that is fulfilled with the user when
441
436
  * the login is complete.
442
437
  */
443
- logIn(options /*:: ?: FullOptions*/) /*: Promise<ParseUser>*/{
438
+ logIn(options = {}) {
444
439
  options = options || {};
445
440
  const loginOptions = {
446
441
  usePost: true
@@ -468,7 +463,7 @@ class ParseUser extends _ParseObject.default {
468
463
  * @param {...any} args
469
464
  * @returns {Promise}
470
465
  */
471
- async save(...args /*: Array<any>*/) /*: Promise<ParseUser>*/{
466
+ async save(...args) {
472
467
  await super.save.apply(this, args);
473
468
  const current = await this.isCurrentAsync();
474
469
  if (current) {
@@ -484,7 +479,7 @@ class ParseUser extends _ParseObject.default {
484
479
  * @param {...any} args
485
480
  * @returns {Parse.User}
486
481
  */
487
- async destroy(...args /*: Array<any>*/) /*: Promise<ParseUser>*/{
482
+ async destroy(...args) {
488
483
  await super.destroy.apply(this, args);
489
484
  const current = await this.isCurrentAsync();
490
485
  if (current) {
@@ -500,7 +495,7 @@ class ParseUser extends _ParseObject.default {
500
495
  * @param {...any} args
501
496
  * @returns {Parse.User}
502
497
  */
503
- async fetch(...args /*: Array<any>*/) /*: Promise<ParseUser>*/{
498
+ async fetch(...args) {
504
499
  await super.fetch.apply(this, args);
505
500
  const current = await this.isCurrentAsync();
506
501
  if (current) {
@@ -516,7 +511,7 @@ class ParseUser extends _ParseObject.default {
516
511
  * @param {...any} args
517
512
  * @returns {Parse.User}
518
513
  */
519
- async fetchWithInclude(...args /*: Array<any>*/) /*: Promise<ParseUser>*/{
514
+ async fetchWithInclude(...args) {
520
515
  await super.fetchWithInclude.apply(this, args);
521
516
  const current = await this.isCurrentAsync();
522
517
  if (current) {
@@ -530,11 +525,11 @@ class ParseUser extends _ParseObject.default {
530
525
  *
531
526
  * @param {string} password The password to be verified.
532
527
  * @param {object} options The options.
533
- * @param {boolean} [options.ignoreEmailVerification=false] Set to `true` to bypass email verification and verify
528
+ * @param {boolean} [options.ignoreEmailVerification] Set to `true` to bypass email verification and verify
534
529
  * the password regardless of whether the email has been verified. This requires the master key.
535
530
  * @returns {Promise} A promise that is fulfilled with a user when the password is correct.
536
531
  */
537
- verifyPassword(password /*: string*/, options /*:: ?: RequestOptions*/) /*: Promise<ParseUser>*/{
532
+ verifyPassword(password, options) {
538
533
  const username = this.getUsername() || '';
539
534
  return ParseUser.verifyPassword(username, password, options);
540
535
  }
@@ -550,7 +545,7 @@ class ParseUser extends _ParseObject.default {
550
545
  * @static
551
546
  * @returns {Parse.User} The newly extended Parse.User class
552
547
  */
553
- static extend(protoProps /*: { [prop: string]: any }*/, classProps /*: { [prop: string]: any }*/) {
548
+ static extend(protoProps, classProps) {
554
549
  if (protoProps) {
555
550
  for (const prop in protoProps) {
556
551
  if (prop !== 'className') {
@@ -585,7 +580,7 @@ class ParseUser extends _ParseObject.default {
585
580
  * @static
586
581
  * @returns {Parse.Object} The currently logged in Parse.User.
587
582
  */
588
- static current() /*: ?ParseUser*/{
583
+ static current() {
589
584
  if (!canUseCurrentUser) {
590
585
  return null;
591
586
  }
@@ -600,7 +595,7 @@ class ParseUser extends _ParseObject.default {
600
595
  * @returns {Promise} A Promise that is resolved with the currently
601
596
  * logged in Parse User
602
597
  */
603
- static currentAsync() /*: Promise<?ParseUser>*/{
598
+ static currentAsync() {
604
599
  if (!canUseCurrentUser) {
605
600
  return Promise.resolve(null);
606
601
  }
@@ -622,7 +617,7 @@ class ParseUser extends _ParseObject.default {
622
617
  * @returns {Promise} A promise that is fulfilled with the user when
623
618
  * the signup completes.
624
619
  */
625
- static signUp(username /*: string*/, password /*: string*/, attrs /*: AttributeMap*/, options /*:: ?: FullOptions*/) {
620
+ static signUp(username, password, attrs, options) {
626
621
  attrs = attrs || {};
627
622
  attrs.username = username;
628
623
  attrs.password = password;
@@ -642,7 +637,7 @@ class ParseUser extends _ParseObject.default {
642
637
  * @returns {Promise} A promise that is fulfilled with the user when
643
638
  * the login completes.
644
639
  */
645
- static logIn(username /*: string*/, password /*: string*/, options /*:: ?: FullOptions*/) {
640
+ static logIn(username, password, options) {
646
641
  if (typeof username !== 'string') {
647
642
  return Promise.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
648
643
  } else if (typeof password !== 'string') {
@@ -669,7 +664,7 @@ class ParseUser extends _ParseObject.default {
669
664
  * @returns {Promise} A promise that is fulfilled with the user when
670
665
  * the login completes.
671
666
  */
672
- static logInWithAdditionalAuth(username /*: string*/, password /*: string*/, authData /*: AuthData*/, options /*:: ?: FullOptions*/) {
667
+ static logInWithAdditionalAuth(username, password, authData, options) {
673
668
  if (typeof username !== 'string') {
674
669
  return Promise.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
675
670
  }
@@ -698,7 +693,7 @@ class ParseUser extends _ParseObject.default {
698
693
  * @returns {Promise} A promise that is fulfilled with the user when
699
694
  * the login completes.
700
695
  */
701
- static loginAs(userId /*: string*/) {
696
+ static loginAs(userId) {
702
697
  if (!userId) {
703
698
  throw new _ParseError.default(_ParseError.default.USERNAME_MISSING, 'Cannot log in as user with an empty user id');
704
699
  }
@@ -718,12 +713,12 @@ class ParseUser extends _ParseObject.default {
718
713
  * @returns {Promise} A promise that is fulfilled with the user when
719
714
  * the login completes.
720
715
  */
721
- static become(sessionToken /*: string*/, options /*:: ?: RequestOptions*/) {
716
+ static become(sessionToken, options) {
722
717
  if (!canUseCurrentUser) {
723
718
  throw new Error('It is not memory-safe to become a user in a server environment');
724
719
  }
725
720
  options = options || {};
726
- const becomeOptions /*: RequestOptions*/ = {
721
+ const becomeOptions = {
727
722
  sessionToken: sessionToken
728
723
  };
729
724
  if (options.hasOwnProperty('useMasterKey')) {
@@ -742,9 +737,9 @@ class ParseUser extends _ParseObject.default {
742
737
  * @static
743
738
  * @returns {Promise} A promise that is fulfilled with the user is fetched.
744
739
  */
745
- static me(sessionToken /*: string*/, options /*:: ?: RequestOptions*/ = {}) {
740
+ static me(sessionToken, options = {}) {
746
741
  const controller = _CoreManager.default.getUserController();
747
- const meOptions /*: RequestOptions*/ = {
742
+ const meOptions = {
748
743
  sessionToken: sessionToken
749
744
  };
750
745
  if (options.useMasterKey) {
@@ -764,7 +759,7 @@ class ParseUser extends _ParseObject.default {
764
759
  * @returns {Promise} A promise that is fulfilled with the user when
765
760
  * the login completes.
766
761
  */
767
- static hydrate(userJSON /*: AttributeMap*/) {
762
+ static hydrate(userJSON) {
768
763
  const controller = _CoreManager.default.getUserController();
769
764
  const user = new this();
770
765
  return controller.hydrate(user, userJSON);
@@ -775,11 +770,12 @@ class ParseUser extends _ParseObject.default {
775
770
  *
776
771
  * @param provider
777
772
  * @param options
773
+ * @param {object} [options.authData]
778
774
  * @param saveOpts
779
775
  * @static
780
776
  * @returns {Promise}
781
777
  */
782
- static logInWith(provider /*: any*/, options /*: { authData?: AuthData }*/, saveOpts /*:: ?: FullOptions*/) /*: Promise<ParseUser>*/{
778
+ static logInWith(provider, options, saveOpts) {
783
779
  const user = new this();
784
780
  return user.linkWith(provider, options, saveOpts);
785
781
  }
@@ -794,7 +790,7 @@ class ParseUser extends _ParseObject.default {
794
790
  * @returns {Promise} A promise that is resolved when the session is
795
791
  * destroyed on the server.
796
792
  */
797
- static logOut(options /*: RequestOptions*/ = {}) {
793
+ static logOut(options = {}) {
798
794
  const controller = _CoreManager.default.getUserController();
799
795
  return controller.logOut(options);
800
796
  }
@@ -810,7 +806,7 @@ class ParseUser extends _ParseObject.default {
810
806
  * @static
811
807
  * @returns {Promise}
812
808
  */
813
- static requestPasswordReset(email /*: string*/, options /*:: ?: RequestOptions*/) {
809
+ static requestPasswordReset(email, options) {
814
810
  options = options || {};
815
811
  const requestOptions = {};
816
812
  if (options.hasOwnProperty('useMasterKey')) {
@@ -829,7 +825,7 @@ class ParseUser extends _ParseObject.default {
829
825
  * @static
830
826
  * @returns {Promise}
831
827
  */
832
- static requestEmailVerification(email /*: string*/, options /*:: ?: RequestOptions*/) {
828
+ static requestEmailVerification(email, options) {
833
829
  options = options || {};
834
830
  const requestOptions = {};
835
831
  if (options.hasOwnProperty('useMasterKey')) {
@@ -846,11 +842,11 @@ class ParseUser extends _ParseObject.default {
846
842
  * @param {string} username The username of the user whose password should be verified.
847
843
  * @param {string} password The password to be verified.
848
844
  * @param {object} options The options.
849
- * @param {boolean} [options.ignoreEmailVerification=false] Set to `true` to bypass email verification and verify
845
+ * @param {boolean} [options.ignoreEmailVerification] Set to `true` to bypass email verification and verify
850
846
  * the password regardless of whether the email has been verified. This requires the master key.
851
847
  * @returns {Promise} A promise that is fulfilled with a user when the password is correct.
852
848
  */
853
- static verifyPassword(username /*: string*/, password /*: string*/, options /*:: ?: RequestOptions*/) {
849
+ static verifyPassword(username, password, options) {
854
850
  if (typeof username !== 'string') {
855
851
  return Promise.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
856
852
  }
@@ -870,7 +866,7 @@ class ParseUser extends _ParseObject.default {
870
866
  * @param {boolean} isAllowed Whether or not to allow custom User class
871
867
  * @static
872
868
  */
873
- static allowCustomUserClass(isAllowed /*: boolean*/) {
869
+ static allowCustomUserClass(isAllowed) {
874
870
  _CoreManager.default.set('PERFORM_USER_REWRITE', !isAllowed);
875
871
  }
876
872
 
@@ -888,7 +884,7 @@ class ParseUser extends _ParseObject.default {
888
884
  * completed. If a replacement session token is requested, the promise
889
885
  * will be resolved after a new token has been fetched.
890
886
  */
891
- static enableRevocableSession(options /*:: ?: RequestOptions*/) {
887
+ static enableRevocableSession(options) {
892
888
  options = options || {};
893
889
  _CoreManager.default.set('FORCE_REVOCABLE_SESSION', true);
894
890
  if (canUseCurrentUser) {
@@ -934,7 +930,7 @@ class ParseUser extends _ParseObject.default {
934
930
  * @see {@link https://docs.parseplatform.org/js/guide/#custom-authentication-module Custom Authentication Module}
935
931
  * @static
936
932
  */
937
- static _registerAuthenticationProvider(provider /*: any*/) {
933
+ static _registerAuthenticationProvider(provider) {
938
934
  authProviders[provider.getAuthType()] = provider;
939
935
  // Synchronize the current user with the auth provider.
940
936
  ParseUser.currentAsync().then(current => {
@@ -947,12 +943,13 @@ class ParseUser extends _ParseObject.default {
947
943
  /**
948
944
  * @param provider
949
945
  * @param options
946
+ * @param {object} [options.authData]
950
947
  * @param saveOpts
951
948
  * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#logInWith logInWith}
952
949
  * @static
953
950
  * @returns {Promise}
954
951
  */
955
- static _logInWith(provider /*: any*/, options /*: { authData?: AuthData }*/, saveOpts /*:: ?: FullOptions*/) {
952
+ static _logInWith(provider, options, saveOpts) {
956
953
  const user = new this();
957
954
  return user.linkWith(provider, options, saveOpts);
958
955
  }
@@ -960,7 +957,7 @@ class ParseUser extends _ParseObject.default {
960
957
  currentUserCache = null;
961
958
  currentUserCacheMatchesDisk = false;
962
959
  }
963
- static _setCurrentUserCache(user /*: ParseUser*/) {
960
+ static _setCurrentUserCache(user) {
964
961
  currentUserCache = user;
965
962
  }
966
963
  }
@@ -992,7 +989,7 @@ const DefaultController = {
992
989
  user._synchronizeAllAuthData();
993
990
  return DefaultController.updateUserOnDisk(user);
994
991
  },
995
- currentUser() /*: ?ParseUser*/{
992
+ currentUser() {
996
993
  if (currentUserCache) {
997
994
  return currentUserCache;
998
995
  }
@@ -1032,7 +1029,7 @@ const DefaultController = {
1032
1029
  current._synchronizeAllAuthData();
1033
1030
  return current;
1034
1031
  },
1035
- currentUserAsync() /*: Promise<?ParseUser>*/{
1032
+ currentUserAsync() {
1036
1033
  if (currentUserCache) {
1037
1034
  return Promise.resolve(currentUserCache);
1038
1035
  }
@@ -1070,7 +1067,7 @@ const DefaultController = {
1070
1067
  return Promise.resolve(current);
1071
1068
  });
1072
1069
  },
1073
- signUp(user /*: ParseUser*/, attrs /*: AttributeMap*/, options /*: RequestOptions*/) /*: Promise<ParseUser>*/{
1070
+ signUp(user, attrs, options) {
1074
1071
  const username = attrs && attrs.username || user.get('username');
1075
1072
  const password = attrs && attrs.password || user.get('password');
1076
1073
  if (!username || !username.length) {
@@ -1090,7 +1087,7 @@ const DefaultController = {
1090
1087
  return user;
1091
1088
  });
1092
1089
  },
1093
- logIn(user /*: ParseUser*/, options /*: RequestOptions*/) /*: Promise<ParseUser>*/{
1090
+ logIn(user, options) {
1094
1091
  const RESTController = _CoreManager.default.getRESTController();
1095
1092
  const stateController = _CoreManager.default.getObjectStateController();
1096
1093
  const auth = {
@@ -1112,7 +1109,7 @@ const DefaultController = {
1112
1109
  return DefaultController.setCurrentUser(user);
1113
1110
  });
1114
1111
  },
1115
- loginAs(user /*: ParseUser*/, userId /*: string*/) /*: Promise<ParseUser>*/{
1112
+ loginAs(user, userId) {
1116
1113
  const RESTController = _CoreManager.default.getRESTController();
1117
1114
  return RESTController.request('POST', 'loginAs', {
1118
1115
  userId
@@ -1127,7 +1124,7 @@ const DefaultController = {
1127
1124
  return DefaultController.setCurrentUser(user);
1128
1125
  });
1129
1126
  },
1130
- become(user /*: ParseUser*/, options /*: RequestOptions*/) /*: Promise<ParseUser>*/{
1127
+ become(user, options) {
1131
1128
  const RESTController = _CoreManager.default.getRESTController();
1132
1129
  return RESTController.request('GET', 'users/me', {}, options).then(response => {
1133
1130
  user._finishFetch(response);
@@ -1135,7 +1132,7 @@ const DefaultController = {
1135
1132
  return DefaultController.setCurrentUser(user);
1136
1133
  });
1137
1134
  },
1138
- hydrate(user /*: ParseUser*/, userJSON /*: AttributeMap*/) /*: Promise<ParseUser>*/{
1135
+ hydrate(user, userJSON) {
1139
1136
  user._finishFetch(userJSON);
1140
1137
  user._setExisted(true);
1141
1138
  if (userJSON.sessionToken && canUseCurrentUser) {
@@ -1144,7 +1141,7 @@ const DefaultController = {
1144
1141
  return Promise.resolve(user);
1145
1142
  }
1146
1143
  },
1147
- me(user /*: ParseUser*/, options /*: RequestOptions*/) /*: Promise<ParseUser>*/{
1144
+ me(user, options) {
1148
1145
  const RESTController = _CoreManager.default.getRESTController();
1149
1146
  return RESTController.request('GET', 'users/me', {}, options).then(response => {
1150
1147
  user._finishFetch(response);
@@ -1152,7 +1149,7 @@ const DefaultController = {
1152
1149
  return user;
1153
1150
  });
1154
1151
  },
1155
- logOut(options /*: RequestOptions*/) /*: Promise<ParseUser>*/{
1152
+ logOut(options) {
1156
1153
  const RESTController = _CoreManager.default.getRESTController();
1157
1154
  if (options.sessionToken) {
1158
1155
  return RESTController.request('POST', 'logout', {}, options);
@@ -1179,13 +1176,13 @@ const DefaultController = {
1179
1176
  return promise;
1180
1177
  });
1181
1178
  },
1182
- requestPasswordReset(email /*: string*/, options /*: RequestOptions*/) {
1179
+ requestPasswordReset(email, options) {
1183
1180
  const RESTController = _CoreManager.default.getRESTController();
1184
1181
  return RESTController.request('POST', 'requestPasswordReset', {
1185
1182
  email: email
1186
1183
  }, options);
1187
1184
  },
1188
- async upgradeToRevocableSession(user /*: ParseUser*/, options /*: RequestOptions*/) {
1185
+ async upgradeToRevocableSession(user, options) {
1189
1186
  const token = user.getSessionToken();
1190
1187
  if (!token) {
1191
1188
  return Promise.reject(new _ParseError.default(_ParseError.default.SESSION_MISSING, 'Cannot upgrade a user with no session token'));
@@ -1193,10 +1190,8 @@ const DefaultController = {
1193
1190
  options.sessionToken = token;
1194
1191
  const RESTController = _CoreManager.default.getRESTController();
1195
1192
  const result = await RESTController.request('POST', 'upgradeToRevocableSession', {}, options);
1196
- const session = new _ParseSession.default();
1197
- session._finishFetch(result);
1198
1193
  user._finishFetch({
1199
- sessionToken: session.getSessionToken()
1194
+ sessionToken: (result === null || result === void 0 ? void 0 : result.sessionToken) || ''
1200
1195
  });
1201
1196
  const current = await user.isCurrentAsync();
1202
1197
  if (current) {
@@ -1204,7 +1199,7 @@ const DefaultController = {
1204
1199
  }
1205
1200
  return Promise.resolve(user);
1206
1201
  },
1207
- linkWith(user /*: ParseUser*/, authData /*: AuthData*/, options /*: FullOptions*/) {
1202
+ linkWith(user, authData, options) {
1208
1203
  return user.save({
1209
1204
  authData
1210
1205
  }, options).then(() => {
@@ -1214,7 +1209,7 @@ const DefaultController = {
1214
1209
  return user;
1215
1210
  });
1216
1211
  },
1217
- verifyPassword(username /*: string*/, password /*: string*/, options /*: RequestOptions*/) {
1212
+ verifyPassword(username, password, options) {
1218
1213
  const RESTController = _CoreManager.default.getRESTController();
1219
1214
  const data = {
1220
1215
  username,
@@ -1225,7 +1220,7 @@ const DefaultController = {
1225
1220
  };
1226
1221
  return RESTController.request('GET', 'verifyPassword', data, options);
1227
1222
  },
1228
- requestEmailVerification(email /*: string*/, options /*: RequestOptions*/) {
1223
+ requestEmailVerification(email, options) {
1229
1224
  const RESTController = _CoreManager.default.getRESTController();
1230
1225
  return RESTController.request('POST', 'verificationEmailRequest', {
1231
1226
  email: email
@@ -1234,5 +1229,4 @@ const DefaultController = {
1234
1229
  };
1235
1230
  _CoreManager.default.setParseUser(ParseUser);
1236
1231
  _CoreManager.default.setUserController(DefaultController);
1237
- var _default = ParseUser;
1238
- exports.default = _default;
1232
+ var _default = exports.default = ParseUser;
package/lib/node/Push.js CHANGED
@@ -12,17 +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
- /*:: export type PushData = {
21
- where?: WhereClause | ParseQuery,
22
- push_time?: Date | string,
23
- expiration_time?: Date | string,
24
- expiration_interval?: number,
25
- };*/
26
15
  /**
27
16
  * Contains functions to deal with Push in Parse.
28
17
  *
@@ -30,6 +19,7 @@ function _interopRequireDefault(obj) {
30
19
  * @static
31
20
  * @hideconstructor
32
21
  */
22
+
33
23
  /**
34
24
  * Sends a push notification.
35
25
  * **Available in Cloud Code only.**
@@ -56,9 +46,9 @@ function _interopRequireDefault(obj) {
56
46
  * be used for this request.
57
47
  * </ul>
58
48
  * @returns {Promise} A promise that is fulfilled when the push request
59
- * completes.
49
+ * completes and returns `pushStatusId`.
60
50
  */
61
- function send(data /*: PushData*/, options /*:: ?: FullOptions*/ = {}) /*: Promise*/{
51
+ function send(data, options = {}) {
62
52
  if (data.where && data.where instanceof _ParseQuery.default) {
63
53
  data.where = data.where.toJSON().where;
64
54
  }
@@ -93,7 +83,7 @@ function send(data /*: PushData*/, options /*:: ?: FullOptions*/ = {}) /*: Promi
93
83
  * </ul>
94
84
  * @returns {Parse.Object} Status of Push.
95
85
  */
96
- function getPushStatus(pushStatusId /*: string*/, options /*:: ?: FullOptions*/ = {}) /*: Promise<string>*/{
86
+ function getPushStatus(pushStatusId, options = {}) {
97
87
  const pushOptions = {
98
88
  useMasterKey: true
99
89
  };
@@ -104,7 +94,7 @@ function getPushStatus(pushStatusId /*: string*/, options /*:: ?: FullOptions*/
104
94
  return query.get(pushStatusId, pushOptions);
105
95
  }
106
96
  const DefaultController = {
107
- async send(data /*: PushData*/, options /*:: ?: FullOptions*/) {
97
+ async send(data, options) {
108
98
  var _response$_headers;
109
99
  options.returnStatus = true;
110
100
  const response = await _CoreManager.default.getRESTController().request('POST', 'push', data, options);