parse 4.0.0-alpha.7 → 4.0.0-alpha.9

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 (197) hide show
  1. package/LICENSE +167 -25
  2. package/NOTICE +10 -0
  3. package/README.md +1 -3
  4. package/dist/parse.js +3942 -6528
  5. package/dist/parse.min.js +7 -6
  6. package/dist/parse.weapp.js +3103 -6459
  7. package/dist/parse.weapp.min.js +7 -6
  8. package/lib/browser/Analytics.js +4 -11
  9. package/lib/browser/AnonymousUtils.js +2 -9
  10. package/lib/browser/Cloud.js +4 -11
  11. package/lib/browser/CloudCode.js +0 -1
  12. package/lib/browser/CoreManager.js +3 -10
  13. package/lib/browser/EventEmitter.js +0 -7
  14. package/lib/browser/EventuallyQueue.js +282 -668
  15. package/lib/browser/FacebookUtils.js +2 -9
  16. package/lib/browser/InstallationController.js +0 -7
  17. package/lib/browser/LiveQueryClient.js +35 -26
  18. package/lib/browser/LiveQuerySubscription.js +5 -4
  19. package/lib/browser/LocalDatastore.js +472 -864
  20. package/lib/browser/LocalDatastoreController.js +161 -547
  21. package/lib/browser/LocalDatastoreController.react-native.js +156 -537
  22. package/lib/browser/LocalDatastoreUtils.js +2 -9
  23. package/lib/browser/ObjectStateMutations.js +25 -25
  24. package/lib/browser/OfflineQuery.js +31 -33
  25. package/lib/browser/Parse.js +4 -13
  26. package/lib/browser/ParseACL.js +9 -16
  27. package/lib/browser/ParseCLP.js +46 -48
  28. package/lib/browser/ParseConfig.js +6 -13
  29. package/lib/browser/ParseError.js +2 -11
  30. package/lib/browser/ParseFile.js +107 -482
  31. package/lib/browser/ParseGeoPoint.js +4 -11
  32. package/lib/browser/ParseHooks.js +2 -2
  33. package/lib/browser/ParseInstallation.js +2 -2
  34. package/lib/browser/ParseLiveQuery.js +104 -480
  35. package/lib/browser/ParseObject.js +549 -935
  36. package/lib/browser/ParseOp.js +11 -11
  37. package/lib/browser/ParsePolygon.js +5 -12
  38. package/lib/browser/ParseQuery.js +365 -758
  39. package/lib/browser/ParseRelation.js +2 -9
  40. package/lib/browser/ParseRole.js +2 -2
  41. package/lib/browser/ParseSchema.js +2 -9
  42. package/lib/browser/ParseSession.js +2 -2
  43. package/lib/browser/ParseUser.js +221 -607
  44. package/lib/browser/Push.js +2 -9
  45. package/lib/browser/RESTController.js +12 -19
  46. package/lib/browser/SingleInstanceStateController.js +4 -11
  47. package/lib/browser/Storage.js +0 -7
  48. package/lib/browser/StorageController.browser.js +0 -7
  49. package/lib/browser/StorageController.default.js +0 -7
  50. package/lib/browser/StorageController.react-native.js +0 -7
  51. package/lib/browser/StorageController.weapp.js +0 -7
  52. package/lib/browser/TaskQueue.js +0 -7
  53. package/lib/browser/UniqueInstanceStateController.js +8 -15
  54. package/lib/browser/arrayContainsObject.js +2 -9
  55. package/lib/browser/canBeSerialized.js +2 -9
  56. package/lib/browser/decode.js +4 -11
  57. package/lib/browser/encode.js +8 -15
  58. package/lib/browser/equals.js +4 -13
  59. package/lib/browser/escape.js +0 -7
  60. package/lib/browser/isRevocableSession.js +2 -9
  61. package/lib/browser/parseDate.js +2 -9
  62. package/lib/browser/promiseUtils.js +4 -4
  63. package/lib/browser/unique.js +4 -11
  64. package/lib/browser/unsavedChildren.js +6 -13
  65. package/lib/browser/uuid.js +5 -1
  66. package/lib/node/Analytics.js +0 -7
  67. package/lib/node/AnonymousUtils.js +0 -7
  68. package/lib/node/Cloud.js +0 -7
  69. package/lib/node/CloudCode.js +0 -1
  70. package/lib/node/CoreManager.js +1 -8
  71. package/lib/node/EventEmitter.js +0 -7
  72. package/lib/node/FacebookUtils.js +0 -7
  73. package/lib/node/InstallationController.js +0 -7
  74. package/lib/node/LiveQueryClient.js +18 -17
  75. package/lib/node/LiveQuerySubscription.js +2 -11
  76. package/lib/node/LocalDatastore.js +0 -7
  77. package/lib/node/LocalDatastoreController.js +0 -7
  78. package/lib/node/LocalDatastoreController.react-native.js +0 -7
  79. package/lib/node/LocalDatastoreUtils.js +0 -7
  80. package/lib/node/ObjectStateMutations.js +0 -7
  81. package/lib/node/Parse.js +0 -9
  82. package/lib/node/ParseACL.js +0 -7
  83. package/lib/node/ParseCLP.js +0 -7
  84. package/lib/node/ParseConfig.js +0 -7
  85. package/lib/node/ParseError.js +0 -9
  86. package/lib/node/ParseFile.js +7 -12
  87. package/lib/node/ParseGeoPoint.js +0 -7
  88. package/lib/node/ParseInstallation.js +0 -7
  89. package/lib/node/ParseLiveQuery.js +0 -7
  90. package/lib/node/ParseObject.js +10 -14
  91. package/lib/node/ParseOp.js +0 -7
  92. package/lib/node/ParsePolygon.js +0 -7
  93. package/lib/node/ParseQuery.js +3 -18
  94. package/lib/node/ParseRelation.js +0 -7
  95. package/lib/node/ParseRole.js +0 -7
  96. package/lib/node/ParseSchema.js +0 -7
  97. package/lib/node/ParseSession.js +0 -7
  98. package/lib/node/ParseUser.js +0 -7
  99. package/lib/node/Push.js +0 -7
  100. package/lib/node/RESTController.js +0 -7
  101. package/lib/node/SingleInstanceStateController.js +0 -7
  102. package/lib/node/Storage.js +0 -7
  103. package/lib/node/StorageController.browser.js +0 -7
  104. package/lib/node/StorageController.default.js +0 -7
  105. package/lib/node/StorageController.react-native.js +0 -7
  106. package/lib/node/StorageController.weapp.js +0 -7
  107. package/lib/node/TaskQueue.js +0 -7
  108. package/lib/node/UniqueInstanceStateController.js +0 -7
  109. package/lib/node/arrayContainsObject.js +0 -7
  110. package/lib/node/canBeSerialized.js +0 -7
  111. package/lib/node/decode.js +0 -7
  112. package/lib/node/encode.js +0 -7
  113. package/lib/node/equals.js +0 -9
  114. package/lib/node/escape.js +0 -7
  115. package/lib/node/isRevocableSession.js +0 -7
  116. package/lib/node/parseDate.js +0 -7
  117. package/lib/node/unique.js +0 -7
  118. package/lib/node/unsavedChildren.js +0 -7
  119. package/lib/node/uuid.js +7 -1
  120. package/lib/react-native/CoreManager.js +2 -2
  121. package/lib/react-native/EventuallyQueue.js +169 -676
  122. package/lib/react-native/LiveQueryClient.js +16 -50
  123. package/lib/react-native/LiveQuerySubscription.js +3 -2
  124. package/lib/react-native/LocalDatastore.js +303 -863
  125. package/lib/react-native/LocalDatastoreController.js +75 -535
  126. package/lib/react-native/LocalDatastoreController.react-native.js +95 -503
  127. package/lib/react-native/ObjectStateMutations.js +2 -31
  128. package/lib/react-native/OfflineQuery.js +17 -63
  129. package/lib/react-native/ParseCLP.js +55 -129
  130. package/lib/react-native/ParseFile.js +63 -468
  131. package/lib/react-native/ParseLiveQuery.js +60 -455
  132. package/lib/react-native/ParseObject.js +225 -878
  133. package/lib/react-native/ParseQuery.js +207 -643
  134. package/lib/react-native/ParseSchema.js +3 -3
  135. package/lib/react-native/ParseUser.js +118 -573
  136. package/lib/react-native/RESTController.js +1 -29
  137. package/lib/react-native/uuid.js +5 -1
  138. package/lib/weapp/Analytics.js +4 -11
  139. package/lib/weapp/AnonymousUtils.js +2 -9
  140. package/lib/weapp/Cloud.js +4 -11
  141. package/lib/weapp/CloudCode.js +0 -1
  142. package/lib/weapp/CoreManager.js +3 -10
  143. package/lib/weapp/EventEmitter.js +0 -7
  144. package/lib/weapp/EventuallyQueue.js +282 -668
  145. package/lib/weapp/FacebookUtils.js +2 -9
  146. package/lib/weapp/InstallationController.js +0 -7
  147. package/lib/weapp/LiveQueryClient.js +35 -26
  148. package/lib/weapp/LiveQuerySubscription.js +5 -4
  149. package/lib/weapp/LocalDatastore.js +472 -864
  150. package/lib/weapp/LocalDatastoreController.js +161 -547
  151. package/lib/weapp/LocalDatastoreController.react-native.js +156 -537
  152. package/lib/weapp/LocalDatastoreUtils.js +2 -9
  153. package/lib/weapp/ObjectStateMutations.js +25 -25
  154. package/lib/weapp/OfflineQuery.js +31 -33
  155. package/lib/weapp/Parse.js +4 -13
  156. package/lib/weapp/ParseACL.js +9 -16
  157. package/lib/weapp/ParseCLP.js +46 -48
  158. package/lib/weapp/ParseConfig.js +6 -13
  159. package/lib/weapp/ParseError.js +2 -11
  160. package/lib/weapp/ParseFile.js +107 -482
  161. package/lib/weapp/ParseGeoPoint.js +4 -11
  162. package/lib/weapp/ParseHooks.js +2 -2
  163. package/lib/weapp/ParseInstallation.js +2 -2
  164. package/lib/weapp/ParseLiveQuery.js +104 -480
  165. package/lib/weapp/ParseObject.js +549 -935
  166. package/lib/weapp/ParseOp.js +11 -11
  167. package/lib/weapp/ParsePolygon.js +5 -12
  168. package/lib/weapp/ParseQuery.js +365 -758
  169. package/lib/weapp/ParseRelation.js +2 -9
  170. package/lib/weapp/ParseRole.js +2 -2
  171. package/lib/weapp/ParseSchema.js +2 -9
  172. package/lib/weapp/ParseSession.js +2 -2
  173. package/lib/weapp/ParseUser.js +221 -607
  174. package/lib/weapp/Push.js +2 -9
  175. package/lib/weapp/RESTController.js +12 -19
  176. package/lib/weapp/SingleInstanceStateController.js +4 -11
  177. package/lib/weapp/Storage.js +0 -7
  178. package/lib/weapp/StorageController.browser.js +0 -7
  179. package/lib/weapp/StorageController.default.js +0 -7
  180. package/lib/weapp/StorageController.react-native.js +0 -7
  181. package/lib/weapp/StorageController.weapp.js +0 -7
  182. package/lib/weapp/TaskQueue.js +0 -7
  183. package/lib/weapp/UniqueInstanceStateController.js +8 -15
  184. package/lib/weapp/arrayContainsObject.js +2 -9
  185. package/lib/weapp/canBeSerialized.js +2 -9
  186. package/lib/weapp/decode.js +4 -11
  187. package/lib/weapp/encode.js +8 -15
  188. package/lib/weapp/equals.js +4 -13
  189. package/lib/weapp/escape.js +0 -7
  190. package/lib/weapp/isRevocableSession.js +2 -9
  191. package/lib/weapp/parseDate.js +2 -9
  192. package/lib/weapp/promiseUtils.js +4 -4
  193. package/lib/weapp/unique.js +4 -11
  194. package/lib/weapp/unsavedChildren.js +6 -13
  195. package/lib/weapp/uuid.js +2 -0
  196. package/package.json +24 -24
  197. package/PATENTS +0 -37
@@ -7,7 +7,7 @@ exports.default = void 0;
7
7
 
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
9
 
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
11
 
12
12
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
13
 
@@ -101,423 +101,6 @@ function _interopRequireWildcard(obj, nodeInterop) {
101
101
  return newObj;
102
102
  }
103
103
 
104
- function _createForOfIteratorHelperLoose(o, allowArrayLike) {
105
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
106
- if (it) return (it = it.call(o)).next.bind(it);
107
-
108
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
109
- if (it) o = it;
110
- var i = 0;
111
- return function () {
112
- if (i >= o.length) return {
113
- done: true
114
- };
115
- return {
116
- done: false,
117
- value: o[i++]
118
- };
119
- };
120
- }
121
-
122
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
123
- }
124
-
125
- function _unsupportedIterableToArray(o, minLen) {
126
- if (!o) return;
127
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
128
- var n = Object.prototype.toString.call(o).slice(8, -1);
129
- if (n === "Object" && o.constructor) n = o.constructor.name;
130
- if (n === "Map" || n === "Set") return Array.from(o);
131
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
132
- }
133
-
134
- function _arrayLikeToArray(arr, len) {
135
- if (len == null || len > arr.length) len = arr.length;
136
-
137
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
138
- arr2[i] = arr[i];
139
- }
140
-
141
- return arr2;
142
- }
143
-
144
- function _regeneratorRuntime() {
145
- "use strict";
146
-
147
- _regeneratorRuntime = function () {
148
- return exports;
149
- };
150
-
151
- var exports = {},
152
- Op = Object.prototype,
153
- hasOwn = Op.hasOwnProperty,
154
- $Symbol = "function" == typeof Symbol ? Symbol : {},
155
- iteratorSymbol = $Symbol.iterator || "@@iterator",
156
- asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
157
- toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
158
-
159
- function define(obj, key, value) {
160
- return Object.defineProperty(obj, key, {
161
- value: value,
162
- enumerable: !0,
163
- configurable: !0,
164
- writable: !0
165
- }), obj[key];
166
- }
167
-
168
- try {
169
- define({}, "");
170
- } catch (err) {
171
- define = function (obj, key, value) {
172
- return obj[key] = value;
173
- };
174
- }
175
-
176
- function wrap(innerFn, outerFn, self, tryLocsList) {
177
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
178
- generator = Object.create(protoGenerator.prototype),
179
- context = new Context(tryLocsList || []);
180
- return generator._invoke = function (innerFn, self, context) {
181
- var state = "suspendedStart";
182
- return function (method, arg) {
183
- if ("executing" === state) throw new Error("Generator is already running");
184
-
185
- if ("completed" === state) {
186
- if ("throw" === method) throw arg;
187
- return doneResult();
188
- }
189
-
190
- for (context.method = method, context.arg = arg;;) {
191
- var delegate = context.delegate;
192
-
193
- if (delegate) {
194
- var delegateResult = maybeInvokeDelegate(delegate, context);
195
-
196
- if (delegateResult) {
197
- if (delegateResult === ContinueSentinel) continue;
198
- return delegateResult;
199
- }
200
- }
201
-
202
- if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
203
- if ("suspendedStart" === state) throw state = "completed", context.arg;
204
- context.dispatchException(context.arg);
205
- } else "return" === context.method && context.abrupt("return", context.arg);
206
- state = "executing";
207
- var record = tryCatch(innerFn, self, context);
208
-
209
- if ("normal" === record.type) {
210
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
211
- return {
212
- value: record.arg,
213
- done: context.done
214
- };
215
- }
216
-
217
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
218
- }
219
- };
220
- }(innerFn, self, context), generator;
221
- }
222
-
223
- function tryCatch(fn, obj, arg) {
224
- try {
225
- return {
226
- type: "normal",
227
- arg: fn.call(obj, arg)
228
- };
229
- } catch (err) {
230
- return {
231
- type: "throw",
232
- arg: err
233
- };
234
- }
235
- }
236
-
237
- exports.wrap = wrap;
238
- var ContinueSentinel = {};
239
-
240
- function Generator() {}
241
-
242
- function GeneratorFunction() {}
243
-
244
- function GeneratorFunctionPrototype() {}
245
-
246
- var IteratorPrototype = {};
247
- define(IteratorPrototype, iteratorSymbol, function () {
248
- return this;
249
- });
250
- var getProto = Object.getPrototypeOf,
251
- NativeIteratorPrototype = getProto && getProto(getProto(values([])));
252
- NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
253
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
254
-
255
- function defineIteratorMethods(prototype) {
256
- ["next", "throw", "return"].forEach(function (method) {
257
- define(prototype, method, function (arg) {
258
- return this._invoke(method, arg);
259
- });
260
- });
261
- }
262
-
263
- function AsyncIterator(generator, PromiseImpl) {
264
- function invoke(method, arg, resolve, reject) {
265
- var record = tryCatch(generator[method], generator, arg);
266
-
267
- if ("throw" !== record.type) {
268
- var result = record.arg,
269
- value = result.value;
270
- return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
271
- invoke("next", value, resolve, reject);
272
- }, function (err) {
273
- invoke("throw", err, resolve, reject);
274
- }) : PromiseImpl.resolve(value).then(function (unwrapped) {
275
- result.value = unwrapped, resolve(result);
276
- }, function (error) {
277
- return invoke("throw", error, resolve, reject);
278
- });
279
- }
280
-
281
- reject(record.arg);
282
- }
283
-
284
- var previousPromise;
285
-
286
- this._invoke = function (method, arg) {
287
- function callInvokeWithMethodAndArg() {
288
- return new PromiseImpl(function (resolve, reject) {
289
- invoke(method, arg, resolve, reject);
290
- });
291
- }
292
-
293
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
294
- };
295
- }
296
-
297
- function maybeInvokeDelegate(delegate, context) {
298
- var method = delegate.iterator[context.method];
299
-
300
- if (undefined === method) {
301
- if (context.delegate = null, "throw" === context.method) {
302
- if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
303
- context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
304
- }
305
-
306
- return ContinueSentinel;
307
- }
308
-
309
- var record = tryCatch(method, delegate.iterator, context.arg);
310
- if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
311
- var info = record.arg;
312
- return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
313
- }
314
-
315
- function pushTryEntry(locs) {
316
- var entry = {
317
- tryLoc: locs[0]
318
- };
319
- 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
320
- }
321
-
322
- function resetTryEntry(entry) {
323
- var record = entry.completion || {};
324
- record.type = "normal", delete record.arg, entry.completion = record;
325
- }
326
-
327
- function Context(tryLocsList) {
328
- this.tryEntries = [{
329
- tryLoc: "root"
330
- }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
331
- }
332
-
333
- function values(iterable) {
334
- if (iterable) {
335
- var iteratorMethod = iterable[iteratorSymbol];
336
- if (iteratorMethod) return iteratorMethod.call(iterable);
337
- if ("function" == typeof iterable.next) return iterable;
338
-
339
- if (!isNaN(iterable.length)) {
340
- var i = -1,
341
- next = function next() {
342
- for (; ++i < iterable.length;) {
343
- if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
344
- }
345
-
346
- return next.value = undefined, next.done = !0, next;
347
- };
348
-
349
- return next.next = next;
350
- }
351
- }
352
-
353
- return {
354
- next: doneResult
355
- };
356
- }
357
-
358
- function doneResult() {
359
- return {
360
- value: undefined,
361
- done: !0
362
- };
363
- }
364
-
365
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
366
- var ctor = "function" == typeof genFun && genFun.constructor;
367
- return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
368
- }, exports.mark = function (genFun) {
369
- return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
370
- }, exports.awrap = function (arg) {
371
- return {
372
- __await: arg
373
- };
374
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
375
- return this;
376
- }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
377
- void 0 === PromiseImpl && (PromiseImpl = Promise);
378
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
379
- return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
380
- return result.done ? result.value : iter.next();
381
- });
382
- }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
383
- return this;
384
- }), define(Gp, "toString", function () {
385
- return "[object Generator]";
386
- }), exports.keys = function (object) {
387
- var keys = [];
388
-
389
- for (var key in object) {
390
- keys.push(key);
391
- }
392
-
393
- return keys.reverse(), function next() {
394
- for (; keys.length;) {
395
- var key = keys.pop();
396
- if (key in object) return next.value = key, next.done = !1, next;
397
- }
398
-
399
- return next.done = !0, next;
400
- };
401
- }, exports.values = values, Context.prototype = {
402
- constructor: Context,
403
- reset: function (skipTempReset) {
404
- if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
405
- "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
406
- }
407
- },
408
- stop: function () {
409
- this.done = !0;
410
- var rootRecord = this.tryEntries[0].completion;
411
- if ("throw" === rootRecord.type) throw rootRecord.arg;
412
- return this.rval;
413
- },
414
- dispatchException: function (exception) {
415
- if (this.done) throw exception;
416
- var context = this;
417
-
418
- function handle(loc, caught) {
419
- return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
420
- }
421
-
422
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
423
- var entry = this.tryEntries[i],
424
- record = entry.completion;
425
- if ("root" === entry.tryLoc) return handle("end");
426
-
427
- if (entry.tryLoc <= this.prev) {
428
- var hasCatch = hasOwn.call(entry, "catchLoc"),
429
- hasFinally = hasOwn.call(entry, "finallyLoc");
430
-
431
- if (hasCatch && hasFinally) {
432
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
433
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
434
- } else if (hasCatch) {
435
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
436
- } else {
437
- if (!hasFinally) throw new Error("try statement without catch or finally");
438
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
439
- }
440
- }
441
- }
442
- },
443
- abrupt: function (type, arg) {
444
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
445
- var entry = this.tryEntries[i];
446
-
447
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
448
- var finallyEntry = entry;
449
- break;
450
- }
451
- }
452
-
453
- finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
454
- var record = finallyEntry ? finallyEntry.completion : {};
455
- return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
456
- },
457
- complete: function (record, afterLoc) {
458
- if ("throw" === record.type) throw record.arg;
459
- return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
460
- },
461
- finish: function (finallyLoc) {
462
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
463
- var entry = this.tryEntries[i];
464
- if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
465
- }
466
- },
467
- catch: function (tryLoc) {
468
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
469
- var entry = this.tryEntries[i];
470
-
471
- if (entry.tryLoc === tryLoc) {
472
- var record = entry.completion;
473
-
474
- if ("throw" === record.type) {
475
- var thrown = record.arg;
476
- resetTryEntry(entry);
477
- }
478
-
479
- return thrown;
480
- }
481
- }
482
-
483
- throw new Error("illegal catch attempt");
484
- },
485
- delegateYield: function (iterable, resultName, nextLoc) {
486
- return this.delegate = {
487
- iterator: values(iterable),
488
- resultName: resultName,
489
- nextLoc: nextLoc
490
- }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
491
- }
492
- }, exports;
493
- }
494
-
495
- function ownKeys(object, enumerableOnly) {
496
- var keys = Object.keys(object);
497
-
498
- if (Object.getOwnPropertySymbols) {
499
- var symbols = Object.getOwnPropertySymbols(object);
500
- enumerableOnly && (symbols = symbols.filter(function (sym) {
501
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
502
- })), keys.push.apply(keys, symbols);
503
- }
504
-
505
- return keys;
506
- }
507
-
508
- function _objectSpread(target) {
509
- for (var i = 1; i < arguments.length; i++) {
510
- var source = null != arguments[i] ? arguments[i] : {};
511
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
512
- (0, _defineProperty2.default)(target, key, source[key]);
513
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
514
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
515
- });
516
- }
517
-
518
- return target;
519
- }
520
-
521
104
  var uuidv4 = require('./uuid');
522
105
 
523
106
  var classMap = {};
@@ -865,7 +448,7 @@ var ParseObject = function () {
865
448
  var val = (0, _decode.default)(response[attr]);
866
449
 
867
450
  if (val && Object.getPrototypeOf(val) === Object.prototype) {
868
- changes[attr] = _objectSpread(_objectSpread({}, this.attributes[attr]), val);
451
+ changes[attr] = Object.assign({}, this.attributes[attr], val);
869
452
  } else {
870
453
  changes[attr] = val;
871
454
  }
@@ -1306,49 +889,31 @@ var ParseObject = function () {
1306
889
  }
1307
890
  }, {
1308
891
  key: "exists",
1309
- value: function (options) {
1310
- var query;
1311
- return _regeneratorRuntime().async(function (_context) {
1312
- while (1) {
1313
- switch (_context.prev = _context.next) {
1314
- case 0:
1315
- if (this.id) {
1316
- _context.next = 2;
1317
- break;
1318
- }
1319
-
1320
- return _context.abrupt("return", false);
1321
-
1322
- case 2:
1323
- _context.prev = 2;
1324
- query = new _ParseQuery.default(this.className);
1325
- _context.next = 6;
1326
- return _regeneratorRuntime().awrap(query.get(this.id, options));
1327
-
1328
- case 6:
1329
- return _context.abrupt("return", true);
1330
-
1331
- case 9:
1332
- _context.prev = 9;
1333
- _context.t0 = _context["catch"](2);
892
+ value: function () {
893
+ var _exists = (0, _asyncToGenerator2.default)(function* (options) {
894
+ if (!this.id) {
895
+ return false;
896
+ }
1334
897
 
1335
- if (!(_context.t0.code === _ParseError.default.OBJECT_NOT_FOUND)) {
1336
- _context.next = 13;
1337
- break;
1338
- }
898
+ try {
899
+ var query = new _ParseQuery.default(this.className);
900
+ yield query.get(this.id, options);
901
+ return true;
902
+ } catch (e) {
903
+ if (e.code === _ParseError.default.OBJECT_NOT_FOUND) {
904
+ return false;
905
+ }
1339
906
 
1340
- return _context.abrupt("return", false);
907
+ throw e;
908
+ }
909
+ });
1341
910
 
1342
- case 13:
1343
- throw _context.t0;
911
+ function exists() {
912
+ return _exists.apply(this, arguments);
913
+ }
1344
914
 
1345
- case 14:
1346
- case "end":
1347
- return _context.stop();
1348
- }
1349
- }
1350
- }, null, this, [[2, 9]], Promise);
1351
- }
915
+ return exists;
916
+ }()
1352
917
  }, {
1353
918
  key: "isValid",
1354
919
  value: function () {
@@ -1397,9 +962,7 @@ var ParseObject = function () {
1397
962
  if (keys.length) {
1398
963
  keysToRevert = [];
1399
964
 
1400
- for (var _iterator = _createForOfIteratorHelperLoose(keys), _step; !(_step = _iterator()).done;) {
1401
- var _key3 = _step.value;
1402
-
965
+ for (var _key3 of keys) {
1403
966
  if (typeof _key3 === 'string') {
1404
967
  keysToRevert.push(_key3);
1405
968
  } else {
@@ -1478,44 +1041,27 @@ var ParseObject = function () {
1478
1041
  }
1479
1042
  }, {
1480
1043
  key: "saveEventually",
1481
- value: function (options) {
1482
- return _regeneratorRuntime().async(function (_context2) {
1483
- while (1) {
1484
- switch (_context2.prev = _context2.next) {
1485
- case 0:
1486
- _context2.prev = 0;
1487
- _context2.next = 3;
1488
- return _regeneratorRuntime().awrap(this.save(null, options));
1489
-
1490
- case 3:
1491
- _context2.next = 11;
1492
- break;
1493
-
1494
- case 5:
1495
- _context2.prev = 5;
1496
- _context2.t0 = _context2["catch"](0);
1497
-
1498
- if (!(_context2.t0.message === 'XMLHttpRequest failed: "Unable to connect to the Parse API"')) {
1499
- _context2.next = 11;
1500
- break;
1501
- }
1502
-
1503
- _context2.next = 10;
1504
- return _regeneratorRuntime().awrap(_EventuallyQueue.default.save(this, options));
1044
+ value: function () {
1045
+ var _saveEventually = (0, _asyncToGenerator2.default)(function* (options) {
1046
+ try {
1047
+ yield this.save(null, options);
1048
+ } catch (e) {
1049
+ if (e.message === 'XMLHttpRequest failed: "Unable to connect to the Parse API"') {
1050
+ yield _EventuallyQueue.default.save(this, options);
1051
+
1052
+ _EventuallyQueue.default.poll();
1053
+ }
1054
+ }
1505
1055
 
1506
- case 10:
1507
- _EventuallyQueue.default.poll();
1056
+ return this;
1057
+ });
1508
1058
 
1509
- case 11:
1510
- return _context2.abrupt("return", this);
1059
+ function saveEventually() {
1060
+ return _saveEventually.apply(this, arguments);
1061
+ }
1511
1062
 
1512
- case 12:
1513
- case "end":
1514
- return _context2.stop();
1515
- }
1516
- }
1517
- }, null, this, [[0, 5]], Promise);
1518
- }
1063
+ return saveEventually;
1064
+ }()
1519
1065
  }, {
1520
1066
  key: "save",
1521
1067
  value: function (arg1, arg2, arg3) {
@@ -1574,44 +1120,27 @@ var ParseObject = function () {
1574
1120
  }
1575
1121
  }, {
1576
1122
  key: "destroyEventually",
1577
- value: function (options) {
1578
- return _regeneratorRuntime().async(function (_context3) {
1579
- while (1) {
1580
- switch (_context3.prev = _context3.next) {
1581
- case 0:
1582
- _context3.prev = 0;
1583
- _context3.next = 3;
1584
- return _regeneratorRuntime().awrap(this.destroy(options));
1585
-
1586
- case 3:
1587
- _context3.next = 11;
1588
- break;
1589
-
1590
- case 5:
1591
- _context3.prev = 5;
1592
- _context3.t0 = _context3["catch"](0);
1593
-
1594
- if (!(_context3.t0.message === 'XMLHttpRequest failed: "Unable to connect to the Parse API"')) {
1595
- _context3.next = 11;
1596
- break;
1597
- }
1598
-
1599
- _context3.next = 10;
1600
- return _regeneratorRuntime().awrap(_EventuallyQueue.default.destroy(this, options));
1123
+ value: function () {
1124
+ var _destroyEventually = (0, _asyncToGenerator2.default)(function* (options) {
1125
+ try {
1126
+ yield this.destroy(options);
1127
+ } catch (e) {
1128
+ if (e.message === 'XMLHttpRequest failed: "Unable to connect to the Parse API"') {
1129
+ yield _EventuallyQueue.default.destroy(this, options);
1130
+
1131
+ _EventuallyQueue.default.poll();
1132
+ }
1133
+ }
1601
1134
 
1602
- case 10:
1603
- _EventuallyQueue.default.poll();
1135
+ return this;
1136
+ });
1604
1137
 
1605
- case 11:
1606
- return _context3.abrupt("return", this);
1138
+ function destroyEventually() {
1139
+ return _destroyEventually.apply(this, arguments);
1140
+ }
1607
1141
 
1608
- case 12:
1609
- case "end":
1610
- return _context3.stop();
1611
- }
1612
- }
1613
- }, null, this, [[0, 5]], Promise);
1614
- }
1142
+ return destroyEventually;
1143
+ }()
1615
1144
  }, {
1616
1145
  key: "destroy",
1617
1146
  value: function (options) {
@@ -1649,36 +1178,24 @@ var ParseObject = function () {
1649
1178
  }, {
1650
1179
  key: "isPinned",
1651
1180
  value: function () {
1652
- var localDatastore, objectKey, pin;
1653
- return _regeneratorRuntime().async(function (_context4) {
1654
- while (1) {
1655
- switch (_context4.prev = _context4.next) {
1656
- case 0:
1657
- localDatastore = _CoreManager.default.getLocalDatastore();
1658
-
1659
- if (localDatastore.isEnabled) {
1660
- _context4.next = 3;
1661
- break;
1662
- }
1181
+ var _isPinned = (0, _asyncToGenerator2.default)(function* () {
1182
+ var localDatastore = _CoreManager.default.getLocalDatastore();
1663
1183
 
1664
- return _context4.abrupt("return", Promise.reject('Parse.enableLocalDatastore() must be called first'));
1184
+ if (!localDatastore.isEnabled) {
1185
+ return Promise.reject('Parse.enableLocalDatastore() must be called first');
1186
+ }
1665
1187
 
1666
- case 3:
1667
- objectKey = localDatastore.getKeyForObject(this);
1668
- _context4.next = 6;
1669
- return _regeneratorRuntime().awrap(localDatastore.fromPinWithName(objectKey));
1188
+ var objectKey = localDatastore.getKeyForObject(this);
1189
+ var pin = yield localDatastore.fromPinWithName(objectKey);
1190
+ return pin.length > 0;
1191
+ });
1670
1192
 
1671
- case 6:
1672
- pin = _context4.sent;
1673
- return _context4.abrupt("return", pin.length > 0);
1193
+ function isPinned() {
1194
+ return _isPinned.apply(this, arguments);
1195
+ }
1674
1196
 
1675
- case 8:
1676
- case "end":
1677
- return _context4.stop();
1678
- }
1679
- }
1680
- }, null, this, null, Promise);
1681
- }
1197
+ return isPinned;
1198
+ }()
1682
1199
  }, {
1683
1200
  key: "pinWithName",
1684
1201
  value: function (name) {
@@ -1692,49 +1209,33 @@ var ParseObject = function () {
1692
1209
  }, {
1693
1210
  key: "fetchFromLocalDatastore",
1694
1211
  value: function () {
1695
- var localDatastore, objectKey, pinned, result;
1696
- return _regeneratorRuntime().async(function (_context5) {
1697
- while (1) {
1698
- switch (_context5.prev = _context5.next) {
1699
- case 0:
1700
- localDatastore = _CoreManager.default.getLocalDatastore();
1701
-
1702
- if (localDatastore.isEnabled) {
1703
- _context5.next = 3;
1704
- break;
1705
- }
1706
-
1707
- throw new Error('Parse.enableLocalDatastore() must be called first');
1212
+ var _fetchFromLocalDatastore = (0, _asyncToGenerator2.default)(function* () {
1213
+ var localDatastore = _CoreManager.default.getLocalDatastore();
1708
1214
 
1709
- case 3:
1710
- objectKey = localDatastore.getKeyForObject(this);
1711
- _context5.next = 6;
1712
- return _regeneratorRuntime().awrap(localDatastore._serializeObject(objectKey));
1215
+ if (!localDatastore.isEnabled) {
1216
+ throw new Error('Parse.enableLocalDatastore() must be called first');
1217
+ }
1713
1218
 
1714
- case 6:
1715
- pinned = _context5.sent;
1219
+ var objectKey = localDatastore.getKeyForObject(this);
1220
+ var pinned = yield localDatastore._serializeObject(objectKey);
1716
1221
 
1717
- if (pinned) {
1718
- _context5.next = 9;
1719
- break;
1720
- }
1222
+ if (!pinned) {
1223
+ throw new Error('Cannot fetch an unsaved ParseObject');
1224
+ }
1721
1225
 
1722
- throw new Error('Cannot fetch an unsaved ParseObject');
1226
+ var result = ParseObject.fromJSON(pinned);
1723
1227
 
1724
- case 9:
1725
- result = ParseObject.fromJSON(pinned);
1228
+ this._finishFetch(result.toJSON());
1726
1229
 
1727
- this._finishFetch(result.toJSON());
1230
+ return this;
1231
+ });
1728
1232
 
1729
- return _context5.abrupt("return", this);
1233
+ function fetchFromLocalDatastore() {
1234
+ return _fetchFromLocalDatastore.apply(this, arguments);
1235
+ }
1730
1236
 
1731
- case 12:
1732
- case "end":
1733
- return _context5.stop();
1734
- }
1735
- }
1736
- }, null, this, null, Promise);
1737
- }
1237
+ return fetchFromLocalDatastore;
1238
+ }()
1738
1239
  }], [{
1739
1240
  key: "_getClassMap",
1740
1241
  value: function () {
@@ -1984,8 +1485,7 @@ var ParseObject = function () {
1984
1485
  }
1985
1486
 
1986
1487
  if (this._initializers) {
1987
- for (var _iterator2 = _createForOfIteratorHelperLoose(this._initializers), _step2; !(_step2 = _iterator2()).done;) {
1988
- var initializer = _step2.value;
1488
+ for (var initializer of this._initializers) {
1989
1489
  initializer.apply(this, arguments);
1990
1490
  }
1991
1491
  }
@@ -2195,85 +1695,48 @@ var DefaultController = {
2195
1695
  }
2196
1696
 
2197
1697
  query._limit = ids.length;
2198
- return query.find(options).then(function (objects) {
2199
- var idMap, i, obj, _i, _obj, id, _iterator3, _step3, object;
2200
-
2201
- return _regeneratorRuntime().async(function (_context6) {
2202
- while (1) {
2203
- switch (_context6.prev = _context6.next) {
2204
- case 0:
2205
- idMap = {};
2206
- objects.forEach(function (o) {
2207
- idMap[o.id] = o;
2208
- });
2209
- i = 0;
2210
-
2211
- case 3:
2212
- if (!(i < objs.length)) {
2213
- _context6.next = 11;
2214
- break;
2215
- }
2216
-
2217
- obj = objs[i];
2218
-
2219
- if (!(!obj || !obj.id || !idMap[obj.id])) {
2220
- _context6.next = 8;
2221
- break;
2222
- }
2223
-
2224
- if (!forceFetch) {
2225
- _context6.next = 8;
2226
- break;
2227
- }
2228
-
2229
- return _context6.abrupt("return", Promise.reject(new _ParseError.default(_ParseError.default.OBJECT_NOT_FOUND, 'All objects must exist on the server.')));
2230
-
2231
- case 8:
2232
- i++;
2233
- _context6.next = 3;
2234
- break;
1698
+ return query.find(options).then(function () {
1699
+ var _ref = (0, _asyncToGenerator2.default)(function* (objects) {
1700
+ var idMap = {};
1701
+ objects.forEach(function (o) {
1702
+ idMap[o.id] = o;
1703
+ });
2235
1704
 
2236
- case 11:
2237
- if (!singleInstance) {
2238
- for (_i = 0; _i < results.length; _i++) {
2239
- _obj = results[_i];
1705
+ for (var i = 0; i < objs.length; i++) {
1706
+ var obj = objs[i];
2240
1707
 
2241
- if (_obj && _obj.id && idMap[_obj.id]) {
2242
- id = _obj.id;
1708
+ if (!obj || !obj.id || !idMap[obj.id]) {
1709
+ if (forceFetch) {
1710
+ return Promise.reject(new _ParseError.default(_ParseError.default.OBJECT_NOT_FOUND, 'All objects must exist on the server.'));
1711
+ }
1712
+ }
1713
+ }
2243
1714
 
2244
- _obj._finishFetch(idMap[id].toJSON());
1715
+ if (!singleInstance) {
1716
+ for (var _i = 0; _i < results.length; _i++) {
1717
+ var _obj = results[_i];
2245
1718
 
2246
- results[_i] = idMap[id];
2247
- }
2248
- }
2249
- }
1719
+ if (_obj && _obj.id && idMap[_obj.id]) {
1720
+ var id = _obj.id;
2250
1721
 
2251
- _iterator3 = _createForOfIteratorHelperLoose(results);
1722
+ _obj._finishFetch(idMap[id].toJSON());
2252
1723
 
2253
- case 13:
2254
- if ((_step3 = _iterator3()).done) {
2255
- _context6.next = 19;
2256
- break;
2257
- }
2258
-
2259
- object = _step3.value;
2260
- _context6.next = 17;
2261
- return _regeneratorRuntime().awrap(localDatastore._updateObjectIfPinned(object));
1724
+ results[_i] = idMap[id];
1725
+ }
1726
+ }
1727
+ }
2262
1728
 
2263
- case 17:
2264
- _context6.next = 13;
2265
- break;
1729
+ for (var object of results) {
1730
+ yield localDatastore._updateObjectIfPinned(object);
1731
+ }
2266
1732
 
2267
- case 19:
2268
- return _context6.abrupt("return", Promise.resolve(results));
1733
+ return Promise.resolve(results);
1734
+ });
2269
1735
 
2270
- case 20:
2271
- case "end":
2272
- return _context6.stop();
2273
- }
2274
- }
2275
- }, null, null, null, Promise);
2276
- });
1736
+ return function () {
1737
+ return _ref.apply(this, arguments);
1738
+ };
1739
+ }());
2277
1740
  } else if (target instanceof ParseObject) {
2278
1741
  if (!target.id) {
2279
1742
  return Promise.reject(new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'Object does not have an ID'));
@@ -2287,176 +1750,108 @@ var DefaultController = {
2287
1750
  params.include = options.include.join();
2288
1751
  }
2289
1752
 
2290
- return RESTController.request('GET', 'classes/' + target.className + '/' + target._getId(), params, options).then(function (response) {
2291
- return _regeneratorRuntime().async(function (_context7) {
2292
- while (1) {
2293
- switch (_context7.prev = _context7.next) {
2294
- case 0:
2295
- target._clearPendingOps();
2296
-
2297
- target._clearServerData();
1753
+ return RESTController.request('GET', 'classes/' + target.className + '/' + target._getId(), params, options).then(function () {
1754
+ var _ref2 = (0, _asyncToGenerator2.default)(function* (response) {
1755
+ target._clearPendingOps();
2298
1756
 
2299
- target._finishFetch(response);
1757
+ target._clearServerData();
2300
1758
 
2301
- _context7.next = 5;
2302
- return _regeneratorRuntime().awrap(localDatastore._updateObjectIfPinned(target));
1759
+ target._finishFetch(response);
2303
1760
 
2304
- case 5:
2305
- return _context7.abrupt("return", target);
1761
+ yield localDatastore._updateObjectIfPinned(target);
1762
+ return target;
1763
+ });
2306
1764
 
2307
- case 6:
2308
- case "end":
2309
- return _context7.stop();
2310
- }
2311
- }
2312
- }, null, null, null, Promise);
2313
- });
1765
+ return function () {
1766
+ return _ref2.apply(this, arguments);
1767
+ };
1768
+ }());
2314
1769
  }
2315
1770
 
2316
1771
  return Promise.resolve();
2317
1772
  },
2318
- destroy: function (target, options) {
2319
- var batchSize, localDatastore, RESTController, batches, deleteCompleted, errors;
2320
- return _regeneratorRuntime().async(function (_context10) {
2321
- while (1) {
2322
- switch (_context10.prev = _context10.next) {
2323
- case 0:
2324
- batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
2325
- localDatastore = _CoreManager.default.getLocalDatastore();
2326
- RESTController = _CoreManager.default.getRESTController();
2327
-
2328
- if (!Array.isArray(target)) {
2329
- _context10.next = 15;
2330
- break;
2331
- }
1773
+ destroy: function () {
1774
+ var _destroy = (0, _asyncToGenerator2.default)(function* (target, options) {
1775
+ var batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
2332
1776
 
2333
- if (!(target.length < 1)) {
2334
- _context10.next = 6;
2335
- break;
2336
- }
1777
+ var localDatastore = _CoreManager.default.getLocalDatastore();
2337
1778
 
2338
- return _context10.abrupt("return", Promise.resolve([]));
1779
+ var RESTController = _CoreManager.default.getRESTController();
2339
1780
 
2340
- case 6:
2341
- batches = [[]];
2342
- target.forEach(function (obj) {
2343
- if (!obj.id) {
2344
- return;
2345
- }
1781
+ if (Array.isArray(target)) {
1782
+ if (target.length < 1) {
1783
+ return Promise.resolve([]);
1784
+ }
2346
1785
 
2347
- batches[batches.length - 1].push(obj);
1786
+ var batches = [[]];
1787
+ target.forEach(function (obj) {
1788
+ if (!obj.id) {
1789
+ return;
1790
+ }
2348
1791
 
2349
- if (batches[batches.length - 1].length >= batchSize) {
2350
- batches.push([]);
2351
- }
2352
- });
1792
+ batches[batches.length - 1].push(obj);
2353
1793
 
2354
- if (batches[batches.length - 1].length === 0) {
2355
- batches.pop();
2356
- }
1794
+ if (batches[batches.length - 1].length >= batchSize) {
1795
+ batches.push([]);
1796
+ }
1797
+ });
2357
1798
 
2358
- deleteCompleted = Promise.resolve();
2359
- errors = [];
2360
- batches.forEach(function (batch) {
2361
- deleteCompleted = deleteCompleted.then(function () {
2362
- return RESTController.request('POST', 'batch', {
2363
- requests: batch.map(function (obj) {
2364
- return {
2365
- method: 'DELETE',
2366
- path: getServerUrlPath() + 'classes/' + obj.className + '/' + obj._getId(),
2367
- body: {}
2368
- };
2369
- })
2370
- }, options).then(function (results) {
2371
- for (var i = 0; i < results.length; i++) {
2372
- if (results[i] && results[i].hasOwnProperty('error')) {
2373
- var err = new _ParseError.default(results[i].error.code, results[i].error.error);
2374
- err.object = batch[i];
2375
- errors.push(err);
2376
- }
2377
- }
2378
- });
2379
- });
2380
- });
2381
- return _context10.abrupt("return", deleteCompleted.then(function () {
2382
- var aggregate, _iterator4, _step4, object;
2383
-
2384
- return _regeneratorRuntime().async(function (_context8) {
2385
- while (1) {
2386
- switch (_context8.prev = _context8.next) {
2387
- case 0:
2388
- if (!errors.length) {
2389
- _context8.next = 4;
2390
- break;
2391
- }
2392
-
2393
- aggregate = new _ParseError.default(_ParseError.default.AGGREGATE_ERROR);
2394
- aggregate.errors = errors;
2395
- return _context8.abrupt("return", Promise.reject(aggregate));
2396
-
2397
- case 4:
2398
- _iterator4 = _createForOfIteratorHelperLoose(target);
2399
-
2400
- case 5:
2401
- if ((_step4 = _iterator4()).done) {
2402
- _context8.next = 11;
2403
- break;
2404
- }
2405
-
2406
- object = _step4.value;
2407
- _context8.next = 9;
2408
- return _regeneratorRuntime().awrap(localDatastore._destroyObjectIfPinned(object));
2409
-
2410
- case 9:
2411
- _context8.next = 5;
2412
- break;
2413
-
2414
- case 11:
2415
- return _context8.abrupt("return", Promise.resolve(target));
2416
-
2417
- case 12:
2418
- case "end":
2419
- return _context8.stop();
2420
- }
2421
- }
2422
- }, null, null, null, Promise);
2423
- }));
1799
+ if (batches[batches.length - 1].length === 0) {
1800
+ batches.pop();
1801
+ }
2424
1802
 
2425
- case 15:
2426
- if (!(target instanceof ParseObject)) {
2427
- _context10.next = 17;
2428
- break;
2429
- }
1803
+ var deleteCompleted = Promise.resolve();
1804
+ var errors = [];
1805
+ batches.forEach(function (batch) {
1806
+ deleteCompleted = deleteCompleted.then(function () {
1807
+ return RESTController.request('POST', 'batch', {
1808
+ requests: batch.map(function (obj) {
1809
+ return {
1810
+ method: 'DELETE',
1811
+ path: getServerUrlPath() + 'classes/' + obj.className + '/' + obj._getId(),
1812
+ body: {}
1813
+ };
1814
+ })
1815
+ }, options).then(function (results) {
1816
+ for (var i = 0; i < results.length; i++) {
1817
+ if (results[i] && results[i].hasOwnProperty('error')) {
1818
+ var err = new _ParseError.default(results[i].error.code, results[i].error.error);
1819
+ err.object = batch[i];
1820
+ errors.push(err);
1821
+ }
1822
+ }
1823
+ });
1824
+ });
1825
+ });
1826
+ return deleteCompleted.then((0, _asyncToGenerator2.default)(function* () {
1827
+ if (errors.length) {
1828
+ var aggregate = new _ParseError.default(_ParseError.default.AGGREGATE_ERROR);
1829
+ aggregate.errors = errors;
1830
+ return Promise.reject(aggregate);
1831
+ }
2430
1832
 
2431
- return _context10.abrupt("return", RESTController.request('DELETE', 'classes/' + target.className + '/' + target._getId(), {}, options).then(function () {
2432
- return _regeneratorRuntime().async(function (_context9) {
2433
- while (1) {
2434
- switch (_context9.prev = _context9.next) {
2435
- case 0:
2436
- _context9.next = 2;
2437
- return _regeneratorRuntime().awrap(localDatastore._destroyObjectIfPinned(target));
1833
+ for (var object of target) {
1834
+ yield localDatastore._destroyObjectIfPinned(object);
1835
+ }
2438
1836
 
2439
- case 2:
2440
- return _context9.abrupt("return", Promise.resolve(target));
1837
+ return Promise.resolve(target);
1838
+ }));
1839
+ } else if (target instanceof ParseObject) {
1840
+ return RESTController.request('DELETE', 'classes/' + target.className + '/' + target._getId(), {}, options).then((0, _asyncToGenerator2.default)(function* () {
1841
+ yield localDatastore._destroyObjectIfPinned(target);
1842
+ return Promise.resolve(target);
1843
+ }));
1844
+ }
2441
1845
 
2442
- case 3:
2443
- case "end":
2444
- return _context9.stop();
2445
- }
2446
- }
2447
- }, null, null, null, Promise);
2448
- }));
1846
+ return Promise.resolve(target);
1847
+ });
2449
1848
 
2450
- case 17:
2451
- return _context10.abrupt("return", Promise.resolve(target));
1849
+ function destroy() {
1850
+ return _destroy.apply(this, arguments);
1851
+ }
2452
1852
 
2453
- case 18:
2454
- case "end":
2455
- return _context10.stop();
2456
- }
2457
- }
2458
- }, null, null, null, Promise);
2459
- },
1853
+ return destroy;
1854
+ }(),
2460
1855
  save: function (target, options) {
2461
1856
  var batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
2462
1857
 
@@ -2565,51 +1960,20 @@ var DefaultController = {
2565
1960
  batchReturned.reject(new _ParseError.default(_ParseError.default.INCORRECT_TYPE, error.message));
2566
1961
  });
2567
1962
  return (0, _promiseUtils.when)(batchTasks);
2568
- }).then(function _callee5() {
2569
- var _iterator5, _step5, object;
2570
-
2571
- return _regeneratorRuntime().async(function _callee5$(_context11) {
2572
- while (1) {
2573
- switch (_context11.prev = _context11.next) {
2574
- case 0:
2575
- if (!objectError) {
2576
- _context11.next = 2;
2577
- break;
2578
- }
2579
-
2580
- return _context11.abrupt("return", Promise.reject(objectError));
2581
-
2582
- case 2:
2583
- _iterator5 = _createForOfIteratorHelperLoose(target);
2584
-
2585
- case 3:
2586
- if ((_step5 = _iterator5()).done) {
2587
- _context11.next = 11;
2588
- break;
2589
- }
2590
-
2591
- object = _step5.value;
2592
- _context11.next = 7;
2593
- return _regeneratorRuntime().awrap(localDatastore._updateLocalIdForObject(mapIdForPin[object.id], object));
2594
-
2595
- case 7:
2596
- _context11.next = 9;
2597
- return _regeneratorRuntime().awrap(localDatastore._updateObjectIfPinned(object));
2598
-
2599
- case 9:
2600
- _context11.next = 3;
2601
- break;
2602
-
2603
- case 11:
2604
- return _context11.abrupt("return", Promise.resolve(target));
1963
+ }).then((0, _asyncToGenerator2.default)(function* () {
1964
+ if (objectError) {
1965
+ return Promise.reject(objectError);
1966
+ }
2605
1967
 
2606
- case 12:
2607
- case "end":
2608
- return _context11.stop();
2609
- }
1968
+ for (var object of target) {
1969
+ if (object instanceof ParseObject) {
1970
+ yield localDatastore._updateLocalIdForObject(mapIdForPin[object.id], object);
1971
+ yield localDatastore._updateObjectIfPinned(object);
2610
1972
  }
2611
- }, null, null, null, Promise);
2612
- });
1973
+ }
1974
+
1975
+ return Promise.resolve(target);
1976
+ }));
2613
1977
  });
2614
1978
  } else if (target instanceof ParseObject) {
2615
1979
  if (allowCustomObjectId && Object.prototype.hasOwnProperty.call(target, 'id') && !target.id) {
@@ -2637,28 +2001,11 @@ var DefaultController = {
2637
2001
  };
2638
2002
 
2639
2003
  stateController.pushPendingState(target._getStateIdentifier());
2640
- return stateController.enqueueTask(target._getStateIdentifier(), task).then(function _callee6() {
2641
- return _regeneratorRuntime().async(function _callee6$(_context12) {
2642
- while (1) {
2643
- switch (_context12.prev = _context12.next) {
2644
- case 0:
2645
- _context12.next = 2;
2646
- return _regeneratorRuntime().awrap(localDatastore._updateLocalIdForObject(localId, target));
2647
-
2648
- case 2:
2649
- _context12.next = 4;
2650
- return _regeneratorRuntime().awrap(localDatastore._updateObjectIfPinned(target));
2651
-
2652
- case 4:
2653
- return _context12.abrupt("return", target);
2654
-
2655
- case 5:
2656
- case "end":
2657
- return _context12.stop();
2658
- }
2659
- }
2660
- }, null, null, null, Promise);
2661
- }, function (error) {
2004
+ return stateController.enqueueTask(target._getStateIdentifier(), task).then((0, _asyncToGenerator2.default)(function* () {
2005
+ yield localDatastore._updateLocalIdForObject(localId, target);
2006
+ yield localDatastore._updateObjectIfPinned(target);
2007
+ return target;
2008
+ }), function (error) {
2662
2009
  return Promise.reject(error);
2663
2010
  });
2664
2011
  }