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
@@ -5,45 +5,20 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
8
+ var _ParseError = _interopRequireDefault(require("./ParseError"));
9
+ var _Xhr = _interopRequireDefault(require("./Xhr.weapp"));
8
10
  function _interopRequireDefault(obj) {
9
11
  return obj && obj.__esModule ? obj : {
10
12
  default: obj
11
13
  };
12
14
  }
13
- /**
14
- * @flow
15
- */
16
15
  /* global XMLHttpRequest, Blob */
17
- /*:: import type { FullOptions } from './RESTController';*/
18
- const ParseError = require('./ParseError').default;
16
+
19
17
  let XHR = null;
20
18
  if (typeof XMLHttpRequest !== 'undefined') {
21
19
  XHR = XMLHttpRequest;
22
20
  }
23
- /*:: type Base64 = { base64: string };*/
24
- /*:: type Uri = { uri: string };*/
25
- /*:: type FileData = Array<number> | Base64 | Blob | Uri;*/
26
- /*:: export type FileSaveOptions = FullOptions & {
27
- metadata?: { [key: string]: any },
28
- tags?: { [key: string]: any },
29
- };*/
30
- /*:: export type FileSource =
31
- | {
32
- format: 'file',
33
- file: Blob,
34
- type: string,
35
- }
36
- | {
37
- format: 'base64',
38
- base64: string,
39
- type: string,
40
- }
41
- | {
42
- format: 'uri',
43
- uri: string,
44
- type: string,
45
- };*/
46
- function b64Digit(number /*: number*/) /*: string*/{
21
+ function b64Digit(number) {
47
22
  if (number < 26) {
48
23
  return String.fromCharCode(65 + number);
49
24
  }
@@ -69,14 +44,6 @@ function b64Digit(number /*: number*/) /*: string*/{
69
44
  * @alias Parse.File
70
45
  */
71
46
  class ParseFile {
72
- /*:: _name: string;*/
73
- /*:: _url: ?string;*/
74
- /*:: _source: FileSource;*/
75
- /*:: _previousSave: ?Promise<ParseFile>;*/
76
- /*:: _data: ?string;*/
77
- /*:: _requestTask: ?any;*/
78
- /*:: _metadata: ?Object;*/
79
- /*:: _tags: ?Object;*/
80
47
  /**
81
48
  * @param name {String} The file's name. This will be prefixed by a unique
82
49
  * value once the file has finished saving. The file name must begin with
@@ -104,10 +71,10 @@ class ParseFile {
104
71
  * @param type {String} Optional Content-Type header to use for the file. If
105
72
  * this is omitted, the content type will be inferred from the name's
106
73
  * extension.
107
- * @param metadata {Object} Optional key value pairs to be stored with file object
108
- * @param tags {Object} Optional key value pairs to be stored with file object
74
+ * @param metadata {object} Optional key value pairs to be stored with file object
75
+ * @param tags {object} Optional key value pairs to be stored with file object
109
76
  */
110
- constructor(name /*: string*/, data /*:: ?: FileData*/, type /*:: ?: string*/, metadata /*:: ?: Object*/, tags /*:: ?: Object*/) {
77
+ constructor(name, data, type, metadata, tags) {
111
78
  const specifiedType = type || '';
112
79
  this._name = name;
113
80
  this._metadata = metadata || {};
@@ -154,7 +121,7 @@ class ParseFile {
154
121
  *
155
122
  * @returns {Promise} Promise that is resolve with base64 data
156
123
  */
157
- async getData() /*: Promise<String>*/{
124
+ async getData() {
158
125
  if (this._data) {
159
126
  return this._data;
160
127
  }
@@ -176,7 +143,7 @@ class ParseFile {
176
143
  *
177
144
  * @returns {string}
178
145
  */
179
- name() /*: string*/{
146
+ name() {
180
147
  return this._name;
181
148
  }
182
149
 
@@ -185,9 +152,10 @@ class ParseFile {
185
152
  * after you get the file from a Parse.Object.
186
153
  *
187
154
  * @param {object} options An object to specify url options
155
+ * @param {boolean} [options.forceSecure] force the url to be secure
188
156
  * @returns {string | undefined}
189
157
  */
190
- url(options /*:: ?: { forceSecure?: boolean }*/) /*: ?string*/{
158
+ url(options) {
191
159
  options = options || {};
192
160
  if (!this._url) {
193
161
  return;
@@ -204,7 +172,7 @@ class ParseFile {
204
172
  *
205
173
  * @returns {object}
206
174
  */
207
- metadata() /*: Object*/{
175
+ metadata() {
208
176
  return this._metadata;
209
177
  }
210
178
 
@@ -213,7 +181,7 @@ class ParseFile {
213
181
  *
214
182
  * @returns {object}
215
183
  */
216
- tags() /*: Object*/{
184
+ tags() {
217
185
  return this._tags;
218
186
  }
219
187
 
@@ -240,7 +208,7 @@ class ParseFile {
240
208
  * </ul>
241
209
  * @returns {Promise | undefined} Promise that is resolved when the save finishes.
242
210
  */
243
- save(options /*:: ?: FullOptions*/) /*: ?Promise*/{
211
+ save(options) {
244
212
  options = options || {};
245
213
  options.requestTask = task => this._requestTask = task;
246
214
  options.metadata = this._metadata;
@@ -310,31 +278,31 @@ class ParseFile {
310
278
  * <pre>
311
279
  * @returns {Promise} Promise that is resolved when the delete finishes.
312
280
  */
313
- destroy(options /*:: ?: FullOptions*/ = {}) {
281
+ destroy(options = {}) {
314
282
  if (!this._name) {
315
- throw new ParseError(ParseError.FILE_DELETE_UNNAMED_ERROR, 'Cannot delete an unnamed file.');
283
+ throw new _ParseError.default(_ParseError.default.FILE_DELETE_UNNAMED_ERROR, 'Cannot delete an unnamed file.');
316
284
  }
317
285
  const destroyOptions = {
318
286
  useMasterKey: true
319
287
  };
320
288
  if (options.hasOwnProperty('useMasterKey')) {
321
- destroyOptions.useMasterKey = options.useMasterKey;
289
+ destroyOptions.useMasterKey = !!options.useMasterKey;
322
290
  }
323
291
  const controller = _CoreManager.default.getFileController();
324
292
  return controller.deleteFile(this._name, destroyOptions).then(() => {
325
- this._data = null;
293
+ this._data = undefined;
326
294
  this._requestTask = null;
327
295
  return this;
328
296
  });
329
297
  }
330
- toJSON() /*: { name: ?string, url: ?string }*/{
298
+ toJSON() {
331
299
  return {
332
300
  __type: 'File',
333
301
  name: this._name,
334
302
  url: this._url
335
303
  };
336
304
  }
337
- equals(other /*: mixed*/) /*: boolean*/{
305
+ equals(other) {
338
306
  if (this === other) {
339
307
  return true;
340
308
  }
@@ -347,7 +315,7 @@ class ParseFile {
347
315
  *
348
316
  * @param {object} metadata Key value pairs to be stored with file object
349
317
  */
350
- setMetadata(metadata /*: any*/) {
318
+ setMetadata(metadata) {
351
319
  if (metadata && typeof metadata === 'object') {
352
320
  Object.keys(metadata).forEach(key => {
353
321
  this.addMetadata(key, metadata[key]);
@@ -361,7 +329,7 @@ class ParseFile {
361
329
  * @param {string} key key to store the metadata
362
330
  * @param {*} value metadata
363
331
  */
364
- addMetadata(key /*: string*/, value /*: any*/) {
332
+ addMetadata(key, value) {
365
333
  if (typeof key === 'string') {
366
334
  this._metadata[key] = value;
367
335
  }
@@ -372,7 +340,7 @@ class ParseFile {
372
340
  *
373
341
  * @param {object} tags Key value pairs to be stored with file object
374
342
  */
375
- setTags(tags /*: any*/) {
343
+ setTags(tags) {
376
344
  if (tags && typeof tags === 'object') {
377
345
  Object.keys(tags).forEach(key => {
378
346
  this.addTag(key, tags[key]);
@@ -386,12 +354,12 @@ class ParseFile {
386
354
  * @param {string} key key to store tags
387
355
  * @param {*} value tag
388
356
  */
389
- addTag(key /*: string*/, value /*: string*/) {
357
+ addTag(key, value) {
390
358
  if (typeof key === 'string') {
391
359
  this._tags[key] = value;
392
360
  }
393
361
  }
394
- static fromJSON(obj) /*: ParseFile*/{
362
+ static fromJSON(obj) {
395
363
  if (obj.__type !== 'File') {
396
364
  throw new TypeError('JSON object does not represent a ParseFile');
397
365
  }
@@ -399,7 +367,7 @@ class ParseFile {
399
367
  file._url = obj.url;
400
368
  return file;
401
369
  }
402
- static encodeBase64(bytes /*: Array<number>*/) /*: string*/{
370
+ static encodeBase64(bytes) {
403
371
  const chunks = [];
404
372
  chunks.length = Math.ceil(bytes.length / 3);
405
373
  for (let i = 0; i < chunks.length; i++) {
@@ -414,7 +382,7 @@ class ParseFile {
414
382
  }
415
383
  }
416
384
  const DefaultController = {
417
- saveFile: async function (name /*: string*/, source /*: FileSource*/, options /*:: ?: FullOptions*/) {
385
+ saveFile: async function (name, source, options) {
418
386
  if (source.format !== 'file') {
419
387
  throw new Error('saveFile can only be used with File-type sources.');
420
388
  }
@@ -434,15 +402,15 @@ const DefaultController = {
434
402
  const newSource = {
435
403
  format: 'base64',
436
404
  base64: data,
437
- type: source.type || (source.file ? source.file.type : null)
405
+ type: source.type || (source.file ? source.file.type : undefined)
438
406
  };
439
407
  return await DefaultController.saveBase64(name, newSource, options);
440
408
  },
441
- saveBase64: function (name /*: string*/, source /*: FileSource*/, options /*:: ?: FullOptions*/) {
409
+ saveBase64: function (name, source, options = {}) {
442
410
  if (source.format !== 'base64') {
443
411
  throw new Error('saveBase64 can only be used with Base64-type sources.');
444
412
  }
445
- const data /*: { base64: any, _ContentType?: any, fileData: Object }*/ = {
413
+ const data = {
446
414
  base64: source.base64,
447
415
  fileData: {
448
416
  metadata: {
@@ -510,7 +478,7 @@ const DefaultController = {
510
478
  xhr.send();
511
479
  });
512
480
  },
513
- deleteFile: function (name /*: string*/, options /*:: ?: FullOptions*/) {
481
+ deleteFile: function (name, options) {
514
482
  const headers = {
515
483
  'X-Parse-Application-ID': _CoreManager.default.get('APPLICATION_ID')
516
484
  };
@@ -531,7 +499,7 @@ const DefaultController = {
531
499
  }
532
500
  });
533
501
  },
534
- _setXHR(xhr /*: any*/) {
502
+ _setXHR(xhr) {
535
503
  XHR = xhr;
536
504
  },
537
505
  _getXHR() {
@@ -539,6 +507,5 @@ const DefaultController = {
539
507
  }
540
508
  };
541
509
  _CoreManager.default.setFileController(DefaultController);
542
- var _default = ParseFile;
543
- exports.default = _default;
510
+ var _default = exports.default = ParseFile;
544
511
  exports.b64Digit = b64Digit;
@@ -33,7 +33,7 @@ class ParseGeoPoint {
33
33
  * @param {(number[] | object | number)} arg1 Either a list of coordinate pairs, an object with `latitude`, `longitude`, or the latitude or the point.
34
34
  * @param {number} arg2 The longitude of the GeoPoint
35
35
  */
36
- constructor(arg1 /*: Array<number> | { latitude: number, longitude: number } | number*/, arg2 /*:: ?: number*/) {
36
+ constructor(arg1, arg2) {
37
37
  if (Array.isArray(arg1)) {
38
38
  ParseGeoPoint._validate(arg1[0], arg1[1]);
39
39
  this._latitude = arg1[0];
@@ -59,10 +59,10 @@ class ParseGeoPoint {
59
59
  * @property {number} latitude
60
60
  * @returns {number}
61
61
  */
62
- get latitude() /*: number*/{
62
+ get latitude() {
63
63
  return this._latitude;
64
64
  }
65
- set latitude(val /*: number*/) {
65
+ set latitude(val) {
66
66
  ParseGeoPoint._validate(val, this.longitude);
67
67
  this._latitude = val;
68
68
  }
@@ -74,10 +74,10 @@ class ParseGeoPoint {
74
74
  * @property {number} longitude
75
75
  * @returns {number}
76
76
  */
77
- get longitude() /*: number*/{
77
+ get longitude() {
78
78
  return this._longitude;
79
79
  }
80
- set longitude(val /*: number*/) {
80
+ set longitude(val) {
81
81
  ParseGeoPoint._validate(this.latitude, val);
82
82
  this._longitude = val;
83
83
  }
@@ -87,7 +87,7 @@ class ParseGeoPoint {
87
87
  *
88
88
  * @returns {object}
89
89
  */
90
- toJSON() /*: { __type: string, latitude: number, longitude: number }*/{
90
+ toJSON() {
91
91
  ParseGeoPoint._validate(this._latitude, this._longitude);
92
92
  return {
93
93
  __type: 'GeoPoint',
@@ -95,7 +95,7 @@ class ParseGeoPoint {
95
95
  longitude: this._longitude
96
96
  };
97
97
  }
98
- equals(other /*: any*/) /*: boolean*/{
98
+ equals(other) {
99
99
  return other instanceof ParseGeoPoint && this.latitude === other.latitude && this.longitude === other.longitude;
100
100
  }
101
101
 
@@ -105,7 +105,7 @@ class ParseGeoPoint {
105
105
  * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
106
106
  * @returns {number}
107
107
  */
108
- radiansTo(point /*: ParseGeoPoint*/) /*: number*/{
108
+ radiansTo(point) {
109
109
  const d2r = Math.PI / 180.0;
110
110
  const lat1rad = this.latitude * d2r;
111
111
  const long1rad = this.longitude * d2r;
@@ -125,7 +125,7 @@ class ParseGeoPoint {
125
125
  * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
126
126
  * @returns {number}
127
127
  */
128
- kilometersTo(point /*: ParseGeoPoint*/) /*: number*/{
128
+ kilometersTo(point) {
129
129
  return this.radiansTo(point) * 6371.0;
130
130
  }
131
131
 
@@ -135,14 +135,14 @@ class ParseGeoPoint {
135
135
  * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
136
136
  * @returns {number}
137
137
  */
138
- milesTo(point /*: ParseGeoPoint*/) /*: number*/{
138
+ milesTo(point) {
139
139
  return this.radiansTo(point) * 3958.8;
140
140
  }
141
141
 
142
142
  /*
143
143
  * Throws an exception if the given lat-long is out of bounds.
144
144
  */
145
- static _validate(latitude /*: number*/, longitude /*: number*/) {
145
+ static _validate(latitude, longitude) {
146
146
  if (isNaN(latitude) || isNaN(longitude) || typeof latitude !== 'number' || typeof longitude !== 'number') {
147
147
  throw new TypeError('GeoPoint latitude and longitude must be valid numbers');
148
148
  }
@@ -164,13 +164,19 @@ class ParseGeoPoint {
164
164
  * Creates a GeoPoint with the user's current location, if available.
165
165
  *
166
166
  * @param {object} options The options.
167
- * @param {boolean} [options.enableHighAccuracy=false] A boolean value that indicates the application would like to receive the best possible results. If true and if the device is able to provide a more accurate position, it will do so. Note that this can result in slower response times or increased power consumption (with a GPS chip on a mobile device for example). On the other hand, if false, the device can take the liberty to save resources by responding more quickly and/or using less power. Default: false.
168
- * @param {number} [options.timeout=Infinity] A positive long value representing the maximum length of time (in milliseconds) the device is allowed to take in order to return a position. The default value is Infinity, meaning that getCurrentPosition() won't return until the position is available.
169
- * @param {number} [options.maximumAge=0] A positive long value indicating the maximum age in milliseconds of a possible cached position that is acceptable to return. If set to 0, it means that the device cannot use a cached position and must attempt to retrieve the real current position. If set to Infinity the device must return a cached position regardless of its age. Default: 0.
167
+ * @param {boolean} [options.enableHighAccuracy] A boolean value that indicates the application would like to receive the best possible results.
168
+ * If true and if the device is able to provide a more accurate position, it will do so.
169
+ * Note that this can result in slower response times or increased power consumption (with a GPS chip on a mobile device for example).
170
+ * On the other hand, if false, the device can take the liberty to save resources by responding more quickly and/or using less power. Default: false.
171
+ * @param {number} [options.timeout] A positive long value representing the maximum length of time (in milliseconds) the device is allowed to take in order to return a position.
172
+ * The default value is Infinity, meaning that getCurrentPosition() won't return until the position is available.
173
+ * @param {number} [options.maximumAge] A positive long value indicating the maximum age in milliseconds of a possible cached position that is acceptable to return.
174
+ * If set to 0, it means that the device cannot use a cached position and must attempt to retrieve the real current position.
175
+ * If set to Infinity the device must return a cached position regardless of its age. Default: 0.
170
176
  * @static
171
177
  * @returns {Promise<Parse.GeoPoint>} User's current location
172
178
  */
173
- static current(options) /*: Promise<ParseGeoPoint>*/{
179
+ static current(options) {
174
180
  return new Promise((resolve, reject) => {
175
181
  navigator.geolocation.getCurrentPosition(location => {
176
182
  resolve(new ParseGeoPoint(location.coords.latitude, location.coords.longitude));
@@ -178,5 +184,4 @@ class ParseGeoPoint {
178
184
  });
179
185
  }
180
186
  }
181
- var _default = ParseGeoPoint;
182
- exports.default = _default;
187
+ var _default = exports.default = ParseGeoPoint;
@@ -24,8 +24,6 @@ function _interopRequireDefault(obj) {
24
24
  default: obj
25
25
  };
26
26
  }
27
- /*:: export type HookDeclaration = { functionName: string, url: string } | { className: string, triggerName: string, url: string };*/
28
- /*:: export type HookDeleteArg = { functionName: string } | { className: string, triggerName: string };*/
29
27
  function getFunctions() {
30
28
  return _CoreManager.default.getHooksController().get('functions');
31
29
  }
@@ -12,7 +12,7 @@ function _interopRequireDefault(obj) {
12
12
  default: obj
13
13
  };
14
14
  }
15
- const DEVICE_TYPES /*: DeviceInterface*/ = {
15
+ const DEVICE_TYPES = {
16
16
  IOS: 'ios',
17
17
  MACOS: 'macos',
18
18
  TVOS: 'tvos',
@@ -36,7 +36,7 @@ class ParseInstallation extends _ParseObject.default {
36
36
  /**
37
37
  * @param {object} attributes The initial set of data to store in the object.
38
38
  */
39
- constructor(attributes /*:: ?: AttributeMap*/) {
39
+ constructor(attributes) {
40
40
  super('_Installation');
41
41
  if (attributes && typeof attributes === 'object') {
42
42
  if (!this.set(attributes)) {
@@ -50,6 +50,7 @@ class ParseInstallation extends _ParseObject.default {
50
50
  *
51
51
  * @property {string} appIdentifier
52
52
  * @static
53
+ * @returns {string}
53
54
  */
54
55
  get appIdentifier() {
55
56
  return this.get('appIdentifier');
@@ -60,6 +61,7 @@ class ParseInstallation extends _ParseObject.default {
60
61
  *
61
62
  * @property {string} appVersion
62
63
  * @static
64
+ * @returns {string}
63
65
  */
64
66
  get appVersion() {
65
67
  return this.get('appVersion');
@@ -70,6 +72,7 @@ class ParseInstallation extends _ParseObject.default {
70
72
  *
71
73
  * @property {string} appName
72
74
  * @static
75
+ * @returns {string}
73
76
  */
74
77
  get appName() {
75
78
  return this.get('appName');
@@ -82,6 +85,7 @@ class ParseInstallation extends _ParseObject.default {
82
85
  *
83
86
  * @property {number} badge
84
87
  * @static
88
+ * @returns {number}
85
89
  */
86
90
  get badge() {
87
91
  return this.get('badge');
@@ -92,6 +96,7 @@ class ParseInstallation extends _ParseObject.default {
92
96
  *
93
97
  * @property {string[]} channels
94
98
  * @static
99
+ * @returns {string[]}
95
100
  */
96
101
  get channels() {
97
102
  return this.get('channels');
@@ -102,6 +107,7 @@ class ParseInstallation extends _ParseObject.default {
102
107
  *
103
108
  * @property {string} deviceToken
104
109
  * @static
110
+ * @returns {string}
105
111
  */
106
112
  get deviceToken() {
107
113
  return this.get('deviceToken');
@@ -112,6 +118,7 @@ class ParseInstallation extends _ParseObject.default {
112
118
  *
113
119
  * @property {string} deviceType
114
120
  * @static
121
+ * @returns {string}
115
122
  */
116
123
  get deviceType() {
117
124
  return this.get('deviceType');
@@ -122,6 +129,7 @@ class ParseInstallation extends _ParseObject.default {
122
129
  *
123
130
  * @property {string} GCMSenderId
124
131
  * @static
132
+ * @returns {string}
125
133
  */
126
134
  get GCMSenderId() {
127
135
  return this.get('GCMSenderId');
@@ -132,6 +140,7 @@ class ParseInstallation extends _ParseObject.default {
132
140
  *
133
141
  * @property {string} installationId
134
142
  * @static
143
+ * @returns {string}
135
144
  */
136
145
  get installationId() {
137
146
  return this.get('installationId');
@@ -142,6 +151,7 @@ class ParseInstallation extends _ParseObject.default {
142
151
  *
143
152
  * @property {string} localeIdentifier
144
153
  * @static
154
+ * @returns {string}
145
155
  */
146
156
  get localeIdentifier() {
147
157
  return this.get('localeIdentifier');
@@ -152,6 +162,7 @@ class ParseInstallation extends _ParseObject.default {
152
162
  *
153
163
  * @property {string} parseVersion
154
164
  * @static
165
+ * @returns {string}
155
166
  */
156
167
  get parseVersion() {
157
168
  return this.get('parseVersion');
@@ -162,6 +173,7 @@ class ParseInstallation extends _ParseObject.default {
162
173
  *
163
174
  * @property {string} pushType
164
175
  * @static
176
+ * @returns {string}
165
177
  */
166
178
  get pushType() {
167
179
  return this.get('pushType');
@@ -172,6 +184,7 @@ class ParseInstallation extends _ParseObject.default {
172
184
  *
173
185
  * @property {string} timeZone
174
186
  * @static
187
+ * @returns {string}
175
188
  */
176
189
  get timeZone() {
177
190
  return this.get('timeZone');
@@ -191,8 +204,9 @@ class ParseInstallation extends _ParseObject.default {
191
204
  *
192
205
  * @property {object} DEVICE_TYPES
193
206
  * @static
207
+ * @returns {object}
194
208
  */
195
- static get DEVICE_TYPES() /*: DeviceInterface*/{
209
+ static get DEVICE_TYPES() {
196
210
  return DEVICE_TYPES;
197
211
  }
198
212
 
@@ -203,7 +217,7 @@ class ParseInstallation extends _ParseObject.default {
203
217
  * @param {...any} args
204
218
  * @returns {Promise}
205
219
  */
206
- async fetch(...args) /*: Promise<ParseInstallation>*/{
220
+ async fetch(...args) {
207
221
  try {
208
222
  await super.fetch.apply(this, args);
209
223
  } catch (e) {
@@ -228,7 +242,7 @@ class ParseInstallation extends _ParseObject.default {
228
242
  * @param {...any} args
229
243
  * @returns {Promise}
230
244
  */
231
- async save(...args) /*: Promise<this>*/{
245
+ async save(...args) {
232
246
  try {
233
247
  await super.save.apply(this, args);
234
248
  } catch (e) {
@@ -262,11 +276,10 @@ class ParseInstallation extends _ParseObject.default {
262
276
  *
263
277
  * @returns {Promise} A promise that resolves to the local installation object.
264
278
  */
265
- static currentInstallation() /*: Promise<ParseInstallation>*/{
279
+ static currentInstallation() {
266
280
  return _CoreManager.default.getInstallationController().currentInstallation();
267
281
  }
268
282
  }
269
283
  _ParseObject.default.registerSubclass('_Installation', ParseInstallation);
270
284
  module.exports = ParseInstallation;
271
- var _default = ParseInstallation;
272
- exports.default = _default;
285
+ var _default = exports.default = ParseInstallation;
@@ -11,11 +11,7 @@ function _interopRequireDefault(obj) {
11
11
  default: obj
12
12
  };
13
13
  }
14
- /**
15
- * @flow
16
- */
17
-
18
- function getLiveQueryClient() /*: Promise<LiveQueryClient>*/{
14
+ function getLiveQueryClient() {
19
15
  return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
20
16
  }
21
17
 
@@ -61,7 +57,7 @@ class LiveQuery {
61
57
  * After open is called, the LiveQuery will try to send a connect request
62
58
  * to the LiveQuery server.
63
59
  */
64
- async open() /*: void*/{
60
+ async open() {
65
61
  const liveQueryClient = await getLiveQueryClient();
66
62
  liveQueryClient.open();
67
63
  }
@@ -73,19 +69,18 @@ class LiveQuery {
73
69
  * If you call query.subscribe() after this, we'll create a new WebSocket
74
70
  * connection to the LiveQuery server.
75
71
  */
76
- async close() /*: void*/{
72
+ async close() {
77
73
  const liveQueryClient = await getLiveQueryClient();
78
74
  liveQueryClient.close();
79
75
  }
80
76
  }
81
- var _default = LiveQuery;
82
- exports.default = _default;
77
+ var _default = exports.default = LiveQuery;
83
78
  let defaultLiveQueryClient;
84
79
  const DefaultLiveQueryController = {
85
- setDefaultLiveQueryClient(liveQueryClient /*: LiveQueryClient*/) {
80
+ setDefaultLiveQueryClient(liveQueryClient) {
86
81
  defaultLiveQueryClient = liveQueryClient;
87
82
  },
88
- async getDefaultLiveQueryClient() /*: Promise<LiveQueryClient>*/{
83
+ async getDefaultLiveQueryClient() {
89
84
  if (defaultLiveQueryClient) {
90
85
  return defaultLiveQueryClient;
91
86
  }