parse 4.0.0-alpha.1 → 4.0.0-alpha.10

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 (255) hide show
  1. package/LICENSE +167 -25
  2. package/NOTICE +10 -0
  3. package/README.md +6 -5
  4. package/dist/parse.js +12838 -21190
  5. package/dist/parse.min.js +7 -6
  6. package/dist/parse.weapp.js +7921 -17062
  7. package/dist/parse.weapp.min.js +7 -6
  8. package/lib/browser/Analytics.js +2 -27
  9. package/lib/browser/AnonymousUtils.js +6 -42
  10. package/lib/browser/Cloud.js +12 -77
  11. package/lib/browser/CloudCode.js +0 -3
  12. package/lib/browser/CoreManager.js +46 -191
  13. package/lib/browser/CryptoController.js +2 -16
  14. package/lib/browser/EventEmitter.js +1 -8
  15. package/lib/browser/EventuallyQueue.js +277 -824
  16. package/lib/browser/FacebookUtils.js +6 -42
  17. package/lib/browser/IndexedDBStorageController.js +3 -14
  18. package/lib/browser/InstallationController.js +2 -20
  19. package/lib/browser/LiveQueryClient.js +105 -213
  20. package/lib/browser/LiveQuerySubscription.js +10 -39
  21. package/lib/browser/LocalDatastore.js +451 -1081
  22. package/lib/browser/LocalDatastoreController.js +145 -602
  23. package/lib/browser/LocalDatastoreController.react-native.js +137 -573
  24. package/lib/browser/LocalDatastoreUtils.js +2 -19
  25. package/lib/browser/ObjectStateMutations.js +18 -121
  26. package/lib/browser/OfflineQuery.js +61 -222
  27. package/lib/browser/Parse.js +12 -115
  28. package/lib/browser/ParseACL.js +33 -148
  29. package/lib/browser/ParseCLP.js +96 -314
  30. package/lib/browser/ParseConfig.js +18 -95
  31. package/lib/browser/ParseError.js +63 -99
  32. package/lib/browser/ParseFile.js +128 -685
  33. package/lib/browser/ParseGeoPoint.js +23 -89
  34. package/lib/browser/ParseHooks.js +1 -34
  35. package/lib/browser/ParseInstallation.js +4 -32
  36. package/lib/browser/ParseLiveQuery.js +96 -505
  37. package/lib/browser/ParseObject.js +665 -1845
  38. package/lib/browser/ParseOp.js +41 -287
  39. package/lib/browser/ParsePolygon.js +13 -70
  40. package/lib/browser/ParseQuery.js +403 -1504
  41. package/lib/browser/ParseRelation.js +12 -68
  42. package/lib/browser/ParseRole.js +13 -75
  43. package/lib/browser/ParseSchema.js +49 -208
  44. package/lib/browser/ParseSession.js +11 -69
  45. package/lib/browser/ParseUser.js +274 -1127
  46. package/lib/browser/Push.js +7 -50
  47. package/lib/browser/RESTController.js +28 -157
  48. package/lib/browser/SingleInstanceStateController.js +19 -144
  49. package/lib/browser/Socket.weapp.js +0 -10
  50. package/lib/browser/Storage.js +10 -80
  51. package/lib/browser/StorageController.browser.js +4 -24
  52. package/lib/browser/StorageController.default.js +4 -24
  53. package/lib/browser/StorageController.react-native.js +6 -40
  54. package/lib/browser/StorageController.weapp.js +5 -23
  55. package/lib/browser/TaskQueue.js +1 -29
  56. package/lib/browser/UniqueInstanceStateController.js +19 -149
  57. package/lib/browser/Xhr.weapp.js +0 -17
  58. package/lib/browser/arrayContainsObject.js +2 -23
  59. package/lib/browser/canBeSerialized.js +3 -40
  60. package/lib/browser/decode.js +3 -40
  61. package/lib/browser/encode.js +9 -77
  62. package/lib/browser/equals.js +2 -34
  63. package/lib/browser/escape.js +1 -15
  64. package/lib/browser/isRevocableSession.js +2 -18
  65. package/lib/browser/parseDate.js +2 -20
  66. package/lib/browser/promiseUtils.js +3 -21
  67. package/lib/browser/unique.js +3 -24
  68. package/lib/browser/unsavedChildren.js +6 -57
  69. package/lib/browser/uuid.js +3 -1
  70. package/lib/node/Analytics.js +1 -25
  71. package/lib/node/AnonymousUtils.js +5 -44
  72. package/lib/node/Cloud.js +10 -73
  73. package/lib/node/CloudCode.js +0 -3
  74. package/lib/node/CoreManager.js +47 -227
  75. package/lib/node/CryptoController.js +2 -16
  76. package/lib/node/EventEmitter.js +1 -8
  77. package/lib/node/EventuallyQueue.js +16 -123
  78. package/lib/node/FacebookUtils.js +5 -44
  79. package/lib/node/IndexedDBStorageController.js +3 -19
  80. package/lib/node/InstallationController.js +2 -22
  81. package/lib/node/LiveQueryClient.js +72 -154
  82. package/lib/node/LiveQuerySubscription.js +7 -26
  83. package/lib/node/LocalDatastore.js +19 -182
  84. package/lib/node/LocalDatastoreController.js +6 -45
  85. package/lib/node/LocalDatastoreController.react-native.js +6 -52
  86. package/lib/node/LocalDatastoreUtils.js +1 -13
  87. package/lib/node/ObjectStateMutations.js +13 -100
  88. package/lib/node/OfflineQuery.js +27 -151
  89. package/lib/node/Parse.js +11 -108
  90. package/lib/node/ParseACL.js +32 -157
  91. package/lib/node/ParseCLP.js +69 -269
  92. package/lib/node/ParseConfig.js +16 -91
  93. package/lib/node/ParseError.js +61 -74
  94. package/lib/node/ParseFile.js +49 -212
  95. package/lib/node/ParseGeoPoint.js +21 -89
  96. package/lib/node/ParseHooks.js +0 -35
  97. package/lib/node/ParseInstallation.js +1 -17
  98. package/lib/node/ParseLiveQuery.js +10 -43
  99. package/lib/node/ParseObject.js +229 -964
  100. package/lib/node/ParseOp.js +31 -262
  101. package/lib/node/ParsePolygon.js +12 -69
  102. package/lib/node/ParseQuery.js +169 -888
  103. package/lib/node/ParseRelation.js +11 -68
  104. package/lib/node/ParseRole.js +10 -64
  105. package/lib/node/ParseSchema.js +46 -229
  106. package/lib/node/ParseSession.js +8 -57
  107. package/lib/node/ParseUser.js +107 -583
  108. package/lib/node/Push.js +4 -44
  109. package/lib/node/RESTController.js +18 -127
  110. package/lib/node/SingleInstanceStateController.js +17 -137
  111. package/lib/node/Socket.weapp.js +0 -7
  112. package/lib/node/Storage.js +10 -90
  113. package/lib/node/StorageController.browser.js +4 -30
  114. package/lib/node/StorageController.default.js +5 -28
  115. package/lib/node/StorageController.react-native.js +6 -47
  116. package/lib/node/StorageController.weapp.js +6 -28
  117. package/lib/node/TaskQueue.js +1 -24
  118. package/lib/node/UniqueInstanceStateController.js +16 -140
  119. package/lib/node/Xhr.weapp.js +0 -15
  120. package/lib/node/arrayContainsObject.js +1 -19
  121. package/lib/node/canBeSerialized.js +2 -35
  122. package/lib/node/decode.js +1 -33
  123. package/lib/node/encode.js +3 -61
  124. package/lib/node/equals.js +0 -27
  125. package/lib/node/escape.js +1 -13
  126. package/lib/node/isRevocableSession.js +1 -12
  127. package/lib/node/parseDate.js +1 -14
  128. package/lib/node/promiseUtils.js +2 -14
  129. package/lib/node/unique.js +1 -18
  130. package/lib/node/unsavedChildren.js +2 -45
  131. package/lib/node/uuid.js +6 -1
  132. package/lib/react-native/Analytics.js +0 -9
  133. package/lib/react-native/AnonymousUtils.js +0 -10
  134. package/lib/react-native/Cloud.js +0 -26
  135. package/lib/react-native/CoreManager.js +2 -6
  136. package/lib/react-native/CryptoController.js +0 -2
  137. package/lib/react-native/EventEmitter.js +0 -2
  138. package/lib/react-native/EventuallyQueue.js +156 -711
  139. package/lib/react-native/FacebookUtils.js +0 -22
  140. package/lib/react-native/IndexedDBStorageController.js +0 -1
  141. package/lib/react-native/InstallationController.js +0 -6
  142. package/lib/react-native/LiveQueryClient.js +46 -157
  143. package/lib/react-native/LiveQuerySubscription.js +3 -27
  144. package/lib/react-native/LocalDatastore.js +281 -948
  145. package/lib/react-native/LocalDatastoreController.js +71 -552
  146. package/lib/react-native/LocalDatastoreController.react-native.js +91 -526
  147. package/lib/react-native/LocalDatastoreUtils.js +0 -1
  148. package/lib/react-native/ObjectStateMutations.js +2 -65
  149. package/lib/react-native/OfflineQuery.js +25 -196
  150. package/lib/react-native/Parse.js +0 -65
  151. package/lib/react-native/ParseACL.js +0 -44
  152. package/lib/react-native/ParseCLP.js +23 -161
  153. package/lib/react-native/ParseConfig.js +0 -42
  154. package/lib/react-native/ParseError.js +1 -21
  155. package/lib/react-native/ParseFile.js +55 -529
  156. package/lib/react-native/ParseGeoPoint.js +0 -17
  157. package/lib/react-native/ParseHooks.js +0 -30
  158. package/lib/react-native/ParseInstallation.js +1 -23
  159. package/lib/react-native/ParseLiveQuery.js +55 -472
  160. package/lib/react-native/ParseObject.js +245 -1246
  161. package/lib/react-native/ParseOp.js +1 -138
  162. package/lib/react-native/ParsePolygon.js +0 -24
  163. package/lib/react-native/ParseQuery.js +182 -874
  164. package/lib/react-native/ParseRelation.js +0 -25
  165. package/lib/react-native/ParseRole.js +1 -36
  166. package/lib/react-native/ParseSchema.js +3 -54
  167. package/lib/react-native/ParseSession.js +1 -40
  168. package/lib/react-native/ParseUser.js +95 -773
  169. package/lib/react-native/Push.js +0 -16
  170. package/lib/react-native/RESTController.js +12 -109
  171. package/lib/react-native/SingleInstanceStateController.js +0 -44
  172. package/lib/react-native/Socket.weapp.js +0 -10
  173. package/lib/react-native/Storage.js +0 -24
  174. package/lib/react-native/StorageController.browser.js +0 -2
  175. package/lib/react-native/StorageController.default.js +0 -1
  176. package/lib/react-native/StorageController.react-native.js +0 -2
  177. package/lib/react-native/TaskQueue.js +0 -15
  178. package/lib/react-native/UniqueInstanceStateController.js +0 -47
  179. package/lib/react-native/Xhr.weapp.js +0 -16
  180. package/lib/react-native/arrayContainsObject.js +0 -5
  181. package/lib/react-native/canBeSerialized.js +0 -18
  182. package/lib/react-native/decode.js +0 -21
  183. package/lib/react-native/encode.js +0 -25
  184. package/lib/react-native/equals.js +0 -18
  185. package/lib/react-native/escape.js +0 -1
  186. package/lib/react-native/isRevocableSession.js +0 -1
  187. package/lib/react-native/parseDate.js +0 -3
  188. package/lib/react-native/promiseUtils.js +0 -13
  189. package/lib/react-native/unique.js +0 -4
  190. package/lib/react-native/unsavedChildren.js +0 -21
  191. package/lib/react-native/uuid.js +3 -1
  192. package/lib/weapp/Analytics.js +2 -27
  193. package/lib/weapp/AnonymousUtils.js +6 -42
  194. package/lib/weapp/Cloud.js +12 -77
  195. package/lib/weapp/CloudCode.js +0 -3
  196. package/lib/weapp/CoreManager.js +46 -191
  197. package/lib/weapp/CryptoController.js +2 -16
  198. package/lib/weapp/EventEmitter.js +1 -8
  199. package/lib/weapp/EventuallyQueue.js +277 -824
  200. package/lib/weapp/FacebookUtils.js +6 -42
  201. package/lib/weapp/IndexedDBStorageController.js +3 -14
  202. package/lib/weapp/InstallationController.js +2 -20
  203. package/lib/weapp/LiveQueryClient.js +105 -213
  204. package/lib/weapp/LiveQuerySubscription.js +10 -39
  205. package/lib/weapp/LocalDatastore.js +451 -1081
  206. package/lib/weapp/LocalDatastoreController.js +145 -602
  207. package/lib/weapp/LocalDatastoreController.react-native.js +137 -573
  208. package/lib/weapp/LocalDatastoreUtils.js +2 -19
  209. package/lib/weapp/ObjectStateMutations.js +18 -121
  210. package/lib/weapp/OfflineQuery.js +61 -222
  211. package/lib/weapp/Parse.js +12 -115
  212. package/lib/weapp/ParseACL.js +33 -148
  213. package/lib/weapp/ParseCLP.js +96 -314
  214. package/lib/weapp/ParseConfig.js +18 -95
  215. package/lib/weapp/ParseError.js +63 -99
  216. package/lib/weapp/ParseFile.js +129 -686
  217. package/lib/weapp/ParseGeoPoint.js +23 -89
  218. package/lib/weapp/ParseHooks.js +1 -34
  219. package/lib/weapp/ParseInstallation.js +4 -32
  220. package/lib/weapp/ParseLiveQuery.js +96 -505
  221. package/lib/weapp/ParseObject.js +665 -1845
  222. package/lib/weapp/ParseOp.js +41 -287
  223. package/lib/weapp/ParsePolygon.js +13 -70
  224. package/lib/weapp/ParseQuery.js +403 -1504
  225. package/lib/weapp/ParseRelation.js +12 -68
  226. package/lib/weapp/ParseRole.js +13 -75
  227. package/lib/weapp/ParseSchema.js +49 -208
  228. package/lib/weapp/ParseSession.js +11 -69
  229. package/lib/weapp/ParseUser.js +274 -1127
  230. package/lib/weapp/Push.js +7 -50
  231. package/lib/weapp/RESTController.js +28 -157
  232. package/lib/weapp/SingleInstanceStateController.js +19 -144
  233. package/lib/weapp/Socket.weapp.js +0 -10
  234. package/lib/weapp/Storage.js +10 -80
  235. package/lib/weapp/StorageController.browser.js +4 -24
  236. package/lib/weapp/StorageController.default.js +4 -24
  237. package/lib/weapp/StorageController.react-native.js +6 -40
  238. package/lib/weapp/StorageController.weapp.js +5 -23
  239. package/lib/weapp/TaskQueue.js +1 -29
  240. package/lib/weapp/UniqueInstanceStateController.js +19 -149
  241. package/lib/weapp/Xhr.weapp.js +0 -17
  242. package/lib/weapp/arrayContainsObject.js +2 -23
  243. package/lib/weapp/canBeSerialized.js +3 -40
  244. package/lib/weapp/decode.js +3 -40
  245. package/lib/weapp/encode.js +9 -77
  246. package/lib/weapp/equals.js +2 -34
  247. package/lib/weapp/escape.js +1 -15
  248. package/lib/weapp/isRevocableSession.js +2 -18
  249. package/lib/weapp/parseDate.js +2 -20
  250. package/lib/weapp/promiseUtils.js +3 -21
  251. package/lib/weapp/unique.js +3 -24
  252. package/lib/weapp/unsavedChildren.js +6 -57
  253. package/lib/weapp/uuid.js +1 -6
  254. package/package.json +34 -30
  255. package/PATENTS +0 -37
@@ -1,129 +1,65 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
-
5
- var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
6
-
7
- var _Array$isArray2 = require("@babel/runtime-corejs3/core-js-stable/array/is-array");
8
-
9
- var _getIteratorMethod = require("@babel/runtime-corejs3/core-js/get-iterator-method");
10
-
11
- var _Array$from = require("@babel/runtime-corejs3/core-js-stable/array/from");
12
-
13
- var _sliceInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/slice");
14
-
15
- var _reverseInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/reverse");
16
-
17
- var _Promise2 = require("@babel/runtime-corejs3/core-js-stable/promise");
18
-
19
- var _Object$setPrototypeOf = require("@babel/runtime-corejs3/core-js-stable/object/set-prototype-of");
20
-
21
3
  var _typeof3 = require("@babel/runtime-corejs3/helpers/typeof");
22
-
23
- var _Object$getPrototypeOf2 = require("@babel/runtime-corejs3/core-js-stable/object/get-prototype-of");
24
-
25
- var _Object$create2 = require("@babel/runtime-corejs3/core-js-stable/object/create");
26
-
27
- var _Symbol = require("@babel/runtime-corejs3/core-js-stable/symbol");
28
-
29
- var _Object$defineProperty2 = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
30
-
31
- var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
32
-
33
- var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
34
-
35
- var _forEachInstanceProperty2 = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
36
-
37
- var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
38
-
39
- var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
40
-
41
- var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
42
-
43
4
  var _Object$keys2 = require("@babel/runtime-corejs3/core-js-stable/object/keys");
44
-
5
+ var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
6
+ var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
7
+ var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
8
+ var _forEachInstanceProperty2 = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
9
+ var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
10
+ var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
11
+ var _Object$defineProperty2 = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
12
+ var _sliceInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/slice");
13
+ var _Array$from = require("@babel/runtime-corejs3/core-js-stable/array/from");
14
+ var _Symbol = require("@babel/runtime-corejs3/core-js-stable/symbol");
15
+ var _getIteratorMethod = require("@babel/runtime-corejs3/core-js/get-iterator-method");
16
+ var _Array$isArray2 = require("@babel/runtime-corejs3/core-js-stable/array/is-array");
17
+ var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
18
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
45
19
  _Object$defineProperty2(exports, "__esModule", {
46
20
  value: true
47
21
  });
48
-
49
22
  exports.default = void 0;
50
-
51
- var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
52
-
53
- var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
54
-
55
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/define-property"));
56
-
57
- var _create = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/create"));
58
-
59
- var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
60
-
61
- var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
62
-
23
+ var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator"));
24
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/toConsumableArray"));
63
25
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
64
-
65
- var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
66
-
67
- var _getPrototypeOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-prototype-of"));
68
-
69
- var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
70
-
71
- var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
72
-
73
- var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
74
-
75
- var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
76
-
77
- var _freeze = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/freeze"));
78
-
79
26
  var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
80
-
81
27
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
82
-
83
28
  var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
84
-
85
- var _defineProperty3 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
86
-
29
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
87
30
  var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
88
-
31
+ var _freeze = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/freeze"));
32
+ var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
33
+ var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
34
+ var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
35
+ var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
36
+ var _getPrototypeOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-prototype-of"));
37
+ var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
38
+ var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
39
+ var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
40
+ var _create = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/create"));
41
+ var _defineProperty3 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/define-property"));
42
+ var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
43
+ var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
89
44
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
90
-
91
45
  var _canBeSerialized = _interopRequireDefault(require("./canBeSerialized"));
92
-
93
46
  var _decode = _interopRequireDefault(require("./decode"));
94
-
95
47
  var _encode = _interopRequireDefault(require("./encode"));
96
-
97
48
  var _escape2 = _interopRequireDefault(require("./escape"));
98
-
99
49
  var _EventuallyQueue = _interopRequireDefault(require("./EventuallyQueue"));
100
-
101
50
  var _ParseACL = _interopRequireDefault(require("./ParseACL"));
102
-
103
51
  var _parseDate = _interopRequireDefault(require("./parseDate"));
104
-
105
52
  var _ParseError = _interopRequireDefault(require("./ParseError"));
106
-
107
53
  var _ParseFile = _interopRequireDefault(require("./ParseFile"));
108
-
109
54
  var _promiseUtils = require("./promiseUtils");
110
-
111
55
  var _LocalDatastoreUtils = require("./LocalDatastoreUtils");
112
-
113
56
  var _ParseOp = require("./ParseOp");
114
-
115
57
  var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
116
-
117
58
  var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
118
-
119
59
  var SingleInstanceStateController = _interopRequireWildcard(require("./SingleInstanceStateController"));
120
-
121
60
  var _unique = _interopRequireDefault(require("./unique"));
122
-
123
61
  var UniqueInstanceStateController = _interopRequireWildcard(require("./UniqueInstanceStateController"));
124
-
125
62
  var _unsavedChildren = _interopRequireDefault(require("./unsavedChildren"));
126
-
127
63
  function _getRequireWildcardCache(nodeInterop) {
128
64
  if (typeof _WeakMap !== "function") return null;
129
65
  var cacheBabelInterop = new _WeakMap();
@@ -132,30 +68,23 @@ function _getRequireWildcardCache(nodeInterop) {
132
68
  return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
133
69
  })(nodeInterop);
134
70
  }
135
-
136
71
  function _interopRequireWildcard(obj, nodeInterop) {
137
72
  if (!nodeInterop && obj && obj.__esModule) {
138
73
  return obj;
139
74
  }
140
-
141
75
  if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") {
142
76
  return {
143
77
  default: obj
144
78
  };
145
79
  }
146
-
147
80
  var cache = _getRequireWildcardCache(nodeInterop);
148
-
149
81
  if (cache && cache.has(obj)) {
150
82
  return cache.get(obj);
151
83
  }
152
-
153
84
  var newObj = {};
154
-
155
85
  for (var key in obj) {
156
86
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
157
87
  var desc = _Object$defineProperty2 && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null;
158
-
159
88
  if (desc && (desc.get || desc.set)) {
160
89
  _Object$defineProperty2(newObj, key, desc);
161
90
  } else {
@@ -163,26 +92,19 @@ function _interopRequireWildcard(obj, nodeInterop) {
163
92
  }
164
93
  }
165
94
  }
166
-
167
95
  newObj.default = obj;
168
-
169
96
  if (cache) {
170
97
  cache.set(obj, newObj);
171
98
  }
172
-
173
99
  return newObj;
174
100
  }
175
-
176
101
  function _createForOfIteratorHelper(o, allowArrayLike) {
177
102
  var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
178
-
179
103
  if (!it) {
180
104
  if (_Array$isArray2(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
181
105
  if (it) o = it;
182
106
  var i = 0;
183
-
184
107
  var F = function () {};
185
-
186
108
  return {
187
109
  s: F,
188
110
  n: function () {
@@ -200,13 +122,11 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
200
122
  f: F
201
123
  };
202
124
  }
203
-
204
125
  throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
205
126
  }
206
-
207
127
  var normalCompletion = true,
208
- didErr = false,
209
- err;
128
+ didErr = false,
129
+ err;
210
130
  return {
211
131
  s: function () {
212
132
  it = it.call(o);
@@ -229,462 +149,81 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
229
149
  }
230
150
  };
231
151
  }
232
-
233
152
  function _unsupportedIterableToArray(o, minLen) {
234
- var _context20;
235
-
236
- if (!o) return;
237
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
238
-
239
- var n = _sliceInstanceProperty(_context20 = Object.prototype.toString.call(o)).call(_context20, 8, -1);
240
-
241
- if (n === "Object" && o.constructor) n = o.constructor.name;
242
- if (n === "Map" || n === "Set") return _Array$from(o);
243
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
244
- }
245
-
246
- function _arrayLikeToArray(arr, len) {
247
- if (len == null || len > arr.length) len = arr.length;
248
-
249
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
250
- arr2[i] = arr[i];
251
- }
252
-
253
- return arr2;
254
- }
255
-
256
- function _regeneratorRuntime() {
257
- "use strict";
258
- /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
259
-
260
- _regeneratorRuntime = function () {
261
- return exports;
262
- };
263
-
264
- var exports = {},
265
- Op = Object.prototype,
266
- hasOwn = Op.hasOwnProperty,
267
- $Symbol = "function" == typeof _Symbol ? _Symbol : {},
268
- iteratorSymbol = $Symbol.iterator || "@@iterator",
269
- asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
270
- toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
271
-
272
- function define(obj, key, value) {
273
- return _Object$defineProperty2(obj, key, {
274
- value: value,
275
- enumerable: !0,
276
- configurable: !0,
277
- writable: !0
278
- }), obj[key];
279
- }
280
-
281
- try {
282
- define({}, "");
283
- } catch (err) {
284
- define = function (obj, key, value) {
285
- return obj[key] = value;
286
- };
287
- }
288
-
289
- function wrap(innerFn, outerFn, self, tryLocsList) {
290
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
291
- generator = _Object$create2(protoGenerator.prototype),
292
- context = new Context(tryLocsList || []);
293
-
294
- return generator._invoke = function (innerFn, self, context) {
295
- var state = "suspendedStart";
296
- return function (method, arg) {
297
- if ("executing" === state) throw new Error("Generator is already running");
298
-
299
- if ("completed" === state) {
300
- if ("throw" === method) throw arg;
301
- return doneResult();
302
- }
303
-
304
- for (context.method = method, context.arg = arg;;) {
305
- var delegate = context.delegate;
306
-
307
- if (delegate) {
308
- var delegateResult = maybeInvokeDelegate(delegate, context);
309
-
310
- if (delegateResult) {
311
- if (delegateResult === ContinueSentinel) continue;
312
- return delegateResult;
313
- }
314
- }
315
-
316
- if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
317
- if ("suspendedStart" === state) throw state = "completed", context.arg;
318
- context.dispatchException(context.arg);
319
- } else "return" === context.method && context.abrupt("return", context.arg);
320
- state = "executing";
321
- var record = tryCatch(innerFn, self, context);
322
-
323
- if ("normal" === record.type) {
324
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
325
- return {
326
- value: record.arg,
327
- done: context.done
328
- };
329
- }
330
-
331
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
332
- }
333
- };
334
- }(innerFn, self, context), generator;
335
- }
336
-
337
- function tryCatch(fn, obj, arg) {
338
- try {
339
- return {
340
- type: "normal",
341
- arg: fn.call(obj, arg)
342
- };
343
- } catch (err) {
344
- return {
345
- type: "throw",
346
- arg: err
347
- };
348
- }
349
- }
350
-
351
- exports.wrap = wrap;
352
- var ContinueSentinel = {};
353
-
354
- function Generator() {}
355
-
356
- function GeneratorFunction() {}
357
-
358
- function GeneratorFunctionPrototype() {}
359
-
360
- var IteratorPrototype = {};
361
- define(IteratorPrototype, iteratorSymbol, function () {
362
- return this;
363
- });
364
- var getProto = _Object$getPrototypeOf2,
365
- NativeIteratorPrototype = getProto && getProto(getProto(values([])));
366
- NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
367
-
368
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create2(IteratorPrototype);
369
-
370
- function defineIteratorMethods(prototype) {
371
- var _context18;
372
-
373
- _forEachInstanceProperty2(_context18 = ["next", "throw", "return"]).call(_context18, function (method) {
374
- define(prototype, method, function (arg) {
375
- return this._invoke(method, arg);
376
- });
377
- });
378
- }
379
-
380
- function AsyncIterator(generator, PromiseImpl) {
381
- function invoke(method, arg, resolve, reject) {
382
- var record = tryCatch(generator[method], generator, arg);
383
-
384
- if ("throw" !== record.type) {
385
- var result = record.arg,
386
- value = result.value;
387
- return value && "object" == _typeof3(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
388
- invoke("next", value, resolve, reject);
389
- }, function (err) {
390
- invoke("throw", err, resolve, reject);
391
- }) : PromiseImpl.resolve(value).then(function (unwrapped) {
392
- result.value = unwrapped, resolve(result);
393
- }, function (error) {
394
- return invoke("throw", error, resolve, reject);
395
- });
396
- }
397
-
398
- reject(record.arg);
399
- }
400
-
401
- var previousPromise;
402
-
403
- this._invoke = function (method, arg) {
404
- function callInvokeWithMethodAndArg() {
405
- return new PromiseImpl(function (resolve, reject) {
406
- invoke(method, arg, resolve, reject);
407
- });
408
- }
409
-
410
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
411
- };
412
- }
413
-
414
- function maybeInvokeDelegate(delegate, context) {
415
- var method = delegate.iterator[context.method];
416
-
417
- if (undefined === method) {
418
- if (context.delegate = null, "throw" === context.method) {
419
- if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
420
- context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
421
- }
422
-
423
- return ContinueSentinel;
424
- }
425
-
426
- var record = tryCatch(method, delegate.iterator, context.arg);
427
- if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
428
- var info = record.arg;
429
- 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);
430
- }
431
-
432
- function pushTryEntry(locs) {
433
- var entry = {
434
- tryLoc: locs[0]
435
- };
436
- 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
437
- }
438
-
439
- function resetTryEntry(entry) {
440
- var record = entry.completion || {};
441
- record.type = "normal", delete record.arg, entry.completion = record;
442
- }
443
-
444
- function Context(tryLocsList) {
445
- this.tryEntries = [{
446
- tryLoc: "root"
447
- }], _forEachInstanceProperty2(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0);
448
- }
449
-
450
- function values(iterable) {
451
- if (iterable) {
452
- var iteratorMethod = iterable[iteratorSymbol];
453
- if (iteratorMethod) return iteratorMethod.call(iterable);
454
- if ("function" == typeof iterable.next) return iterable;
455
-
456
- if (!isNaN(iterable.length)) {
457
- var i = -1,
458
- next = function next() {
459
- for (; ++i < iterable.length;) {
460
- if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
461
- }
462
-
463
- return next.value = undefined, next.done = !0, next;
464
- };
465
-
466
- return next.next = next;
467
- }
468
- }
469
-
470
- return {
471
- next: doneResult
472
- };
473
- }
474
-
475
- function doneResult() {
476
- return {
477
- value: undefined,
478
- done: !0
479
- };
480
- }
481
-
482
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
483
- var ctor = "function" == typeof genFun && genFun.constructor;
484
- return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
485
- }, exports.mark = function (genFun) {
486
- return _Object$setPrototypeOf ? _Object$setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = _Object$create2(Gp), genFun;
487
- }, exports.awrap = function (arg) {
488
- return {
489
- __await: arg
490
- };
491
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
492
- return this;
493
- }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
494
- void 0 === PromiseImpl && (PromiseImpl = _Promise2);
495
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
496
- return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
497
- return result.done ? result.value : iter.next();
498
- });
499
- }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
500
- return this;
501
- }), define(Gp, "toString", function () {
502
- return "[object Generator]";
503
- }), exports.keys = function (object) {
504
- var keys = [];
505
-
506
- for (var key in object) {
507
- keys.push(key);
508
- }
509
-
510
- return _reverseInstanceProperty(keys).call(keys), function next() {
511
- for (; keys.length;) {
512
- var key = keys.pop();
513
- if (key in object) return next.value = key, next.done = !1, next;
514
- }
515
-
516
- return next.done = !0, next;
517
- };
518
- }, exports.values = values, Context.prototype = {
519
- constructor: Context,
520
- reset: function (skipTempReset) {
521
- var _context19;
522
-
523
- if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, _forEachInstanceProperty2(_context19 = this.tryEntries).call(_context19, resetTryEntry), !skipTempReset) for (var name in this) {
524
- "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+_sliceInstanceProperty(name).call(name, 1)) && (this[name] = undefined);
525
- }
526
- },
527
- stop: function () {
528
- this.done = !0;
529
- var rootRecord = this.tryEntries[0].completion;
530
- if ("throw" === rootRecord.type) throw rootRecord.arg;
531
- return this.rval;
532
- },
533
- dispatchException: function (exception) {
534
- if (this.done) throw exception;
535
- var context = this;
536
-
537
- function handle(loc, caught) {
538
- return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
539
- }
540
-
541
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
542
- var entry = this.tryEntries[i],
543
- record = entry.completion;
544
- if ("root" === entry.tryLoc) return handle("end");
545
-
546
- if (entry.tryLoc <= this.prev) {
547
- var hasCatch = hasOwn.call(entry, "catchLoc"),
548
- hasFinally = hasOwn.call(entry, "finallyLoc");
549
-
550
- if (hasCatch && hasFinally) {
551
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
552
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
553
- } else if (hasCatch) {
554
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
555
- } else {
556
- if (!hasFinally) throw new Error("try statement without catch or finally");
557
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
558
- }
559
- }
560
- }
561
- },
562
- abrupt: function (type, arg) {
563
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
564
- var entry = this.tryEntries[i];
565
-
566
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
567
- var finallyEntry = entry;
568
- break;
569
- }
570
- }
571
-
572
- finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
573
- var record = finallyEntry ? finallyEntry.completion : {};
574
- return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
575
- },
576
- complete: function (record, afterLoc) {
577
- if ("throw" === record.type) throw record.arg;
578
- 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;
579
- },
580
- finish: function (finallyLoc) {
581
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
582
- var entry = this.tryEntries[i];
583
- if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
584
- }
585
- },
586
- catch: function (tryLoc) {
587
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
588
- var entry = this.tryEntries[i];
589
-
590
- if (entry.tryLoc === tryLoc) {
591
- var record = entry.completion;
592
-
593
- if ("throw" === record.type) {
594
- var thrown = record.arg;
595
- resetTryEntry(entry);
596
- }
597
-
598
- return thrown;
599
- }
600
- }
601
-
602
- throw new Error("illegal catch attempt");
603
- },
604
- delegateYield: function (iterable, resultName, nextLoc) {
605
- return this.delegate = {
606
- iterator: values(iterable),
607
- resultName: resultName,
608
- nextLoc: nextLoc
609
- }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
610
- }
611
- }, exports;
153
+ var _context19;
154
+ if (!o) return;
155
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
156
+ var n = _sliceInstanceProperty(_context19 = Object.prototype.toString.call(o)).call(_context19, 8, -1);
157
+ if (n === "Object" && o.constructor) n = o.constructor.name;
158
+ if (n === "Map" || n === "Set") return _Array$from(o);
159
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
160
+ }
161
+ function _arrayLikeToArray(arr, len) {
162
+ if (len == null || len > arr.length) len = arr.length;
163
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
164
+ return arr2;
612
165
  }
613
-
614
166
  function ownKeys(object, enumerableOnly) {
615
167
  var keys = _Object$keys2(object);
616
-
617
168
  if (_Object$getOwnPropertySymbols) {
618
169
  var symbols = _Object$getOwnPropertySymbols(object);
619
-
620
170
  enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
621
171
  return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
622
172
  })), keys.push.apply(keys, symbols);
623
173
  }
624
-
625
174
  return keys;
626
175
  }
627
-
628
176
  function _objectSpread(target) {
629
177
  for (var i = 1; i < arguments.length; i++) {
630
- var _context16, _context17;
631
-
178
+ var _context17, _context18;
632
179
  var source = null != arguments[i] ? arguments[i] : {};
633
- i % 2 ? _forEachInstanceProperty2(_context16 = ownKeys(Object(source), !0)).call(_context16, function (key) {
634
- (0, _defineProperty3.default)(target, key, source[key]);
635
- }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context17 = ownKeys(Object(source))).call(_context17, function (key) {
180
+ i % 2 ? _forEachInstanceProperty2(_context17 = ownKeys(Object(source), !0)).call(_context17, function (key) {
181
+ (0, _defineProperty2.default)(target, key, source[key]);
182
+ }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context18 = ownKeys(Object(source))).call(_context18, function (key) {
636
183
  _Object$defineProperty2(target, key, _Object$getOwnPropertyDescriptor(source, key));
637
184
  });
638
185
  }
639
-
640
186
  return target;
641
187
  }
642
-
643
188
  var uuidv4 = require('./uuid');
644
189
  /*:: export type Pointer = {
645
190
  __type: string,
646
191
  className: string,
647
192
  objectId: string,
648
193
  };*/
649
-
650
194
  /*:: type SaveParams = {
651
195
  method: string,
652
196
  path: string,
653
197
  body: AttributeMap,
654
198
  };*/
655
-
656
199
  /*:: export type SaveOptions = FullOptions & {
657
200
  cascadeSave?: boolean,
658
201
  context?: AttributeMap,
659
202
  };*/
660
203
  // Mapping of class names to constructors, so we can populate objects from the
661
204
  // server with appropriate subclasses of ParseObject
205
+ var classMap = {};
662
206
 
663
-
664
- var classMap = {}; // Global counter for generating unique Ids for non-single-instance objects
665
-
666
- var objectCount = 0; // On web clients, objects are single-instance: any two objects with the same Id
207
+ // Global counter for generating unique Ids for non-single-instance objects
208
+ var objectCount = 0;
209
+ // On web clients, objects are single-instance: any two objects with the same Id
667
210
  // will have the same attributes. However, this may be dangerous default
668
211
  // behavior in a server scenario
669
-
670
212
  var singleInstance = !_CoreManager.default.get('IS_NODE');
671
-
672
213
  if (singleInstance) {
673
214
  _CoreManager.default.setObjectStateController(SingleInstanceStateController);
674
215
  } else {
675
216
  _CoreManager.default.setObjectStateController(UniqueInstanceStateController);
676
217
  }
677
-
678
218
  function getServerUrlPath() {
679
219
  var serverUrl = _CoreManager.default.get('SERVER_URL');
680
-
681
220
  if (serverUrl[serverUrl.length - 1] !== '/') {
682
221
  serverUrl += '/';
683
222
  }
684
-
685
223
  var url = serverUrl.replace(/https?:\/\//, '');
686
224
  return url.substr((0, _indexOf.default)(url).call(url, '/'));
687
225
  }
226
+
688
227
  /**
689
228
  * Creates a new model with defined attributes.
690
229
  *
@@ -703,148 +242,118 @@ function getServerUrlPath() {
703
242
  *
704
243
  * @alias Parse.Object
705
244
  */
706
-
707
-
708
245
  var ParseObject = /*#__PURE__*/function () {
709
246
  /**
710
247
  * @param {string} className The class name for the object
711
248
  * @param {object} attributes The initial set of data to store in the object.
712
249
  * @param {object} options The options for this object instance.
713
250
  */
714
- function ParseObject(className
715
- /*: ?string | { className: string, [attr: string]: mixed }*/
716
- , attributes
717
- /*:: ?: { [attr: string]: mixed }*/
718
- , options
719
- /*:: ?: { ignoreValidation: boolean }*/
720
- ) {
251
+ function ParseObject(className /*: ?string | { className: string, [attr: string]: mixed }*/, attributes /*:: ?: { [attr: string]: mixed }*/, options /*:: ?: { ignoreValidation: boolean }*/) {
721
252
  (0, _classCallCheck2.default)(this, ParseObject);
722
- (0, _defineProperty3.default)(this, "id", void 0);
723
- (0, _defineProperty3.default)(this, "_localId", void 0);
724
- (0, _defineProperty3.default)(this, "_objCount", void 0);
725
- (0, _defineProperty3.default)(this, "className", void 0); // Enable legacy initializers
726
-
253
+ (0, _defineProperty2.default)(this, "id", void 0);
254
+ (0, _defineProperty2.default)(this, "_localId", void 0);
255
+ (0, _defineProperty2.default)(this, "_objCount", void 0);
256
+ (0, _defineProperty2.default)(this, "className", void 0);
257
+ // Enable legacy initializers
727
258
  if (typeof this.initialize === 'function') {
728
259
  this.initialize.apply(this, arguments);
729
260
  }
730
-
731
261
  var toSet = null;
732
262
  this._objCount = objectCount++;
733
-
734
263
  if (typeof className === 'string') {
735
264
  this.className = className;
736
-
737
265
  if (attributes && (0, _typeof2.default)(attributes) === 'object') {
738
266
  toSet = attributes;
739
267
  }
740
268
  } else if (className && (0, _typeof2.default)(className) === 'object') {
741
269
  this.className = className.className;
742
270
  toSet = {};
743
-
744
271
  for (var _attr in className) {
745
272
  if (_attr !== 'className') {
746
273
  toSet[_attr] = className[_attr];
747
274
  }
748
275
  }
749
-
750
276
  if (attributes && (0, _typeof2.default)(attributes) === 'object') {
751
277
  options = attributes;
752
278
  }
753
279
  }
754
-
755
280
  if (toSet && !this.set(toSet, options)) {
756
281
  throw new Error("Can't create an invalid Parse Object");
757
282
  }
758
283
  }
284
+
759
285
  /**
760
286
  * The ID of this object, unique within its class.
761
287
  *
762
288
  * @property {string} id
763
289
  */
764
-
765
-
766
290
  (0, _createClass2.default)(ParseObject, [{
767
291
  key: "attributes",
768
- get:
769
- /** Prototype getters / setters **/
770
- function ()
771
- /*: AttributeMap*/
772
- {
773
- var stateController = _CoreManager.default.getObjectStateController();
292
+ get: /* Prototype getters / setters */
774
293
 
294
+ function () /*: AttributeMap*/{
295
+ var stateController = _CoreManager.default.getObjectStateController();
775
296
  return (0, _freeze.default)(stateController.estimateAttributes(this._getStateIdentifier()));
776
297
  }
298
+
777
299
  /**
778
300
  * The first time this object was saved on the server.
779
301
  *
780
302
  * @property {Date} createdAt
781
303
  * @returns {Date}
782
304
  */
783
-
784
305
  }, {
785
306
  key: "createdAt",
786
- get: function ()
787
- /*: ?Date*/
788
- {
307
+ get: function () /*: ?Date*/{
789
308
  return this._getServerData().createdAt;
790
309
  }
310
+
791
311
  /**
792
312
  * The last time this object was updated on the server.
793
313
  *
794
314
  * @property {Date} updatedAt
795
315
  * @returns {Date}
796
316
  */
797
-
798
317
  }, {
799
318
  key: "updatedAt",
800
- get: function ()
801
- /*: ?Date*/
802
- {
319
+ get: function () /*: ?Date*/{
803
320
  return this._getServerData().updatedAt;
804
321
  }
805
- /** Private methods **/
322
+
323
+ /* Private methods */
806
324
 
807
325
  /**
808
326
  * Returns a local or server Id used uniquely identify this object
809
327
  *
810
328
  * @returns {string}
811
329
  */
812
-
813
330
  }, {
814
331
  key: "_getId",
815
- value: function ()
816
- /*: string*/
817
- {
332
+ value: function () /*: string*/{
818
333
  if (typeof this.id === 'string') {
819
334
  return this.id;
820
335
  }
821
-
822
336
  if (typeof this._localId === 'string') {
823
337
  return this._localId;
824
338
  }
825
-
826
339
  var localId = 'local' + uuidv4();
827
340
  this._localId = localId;
828
341
  return localId;
829
342
  }
343
+
830
344
  /**
831
345
  * Returns a unique identifier used to pull data from the State Controller.
832
346
  *
833
347
  * @returns {Parse.Object|object}
834
348
  */
835
-
836
349
  }, {
837
350
  key: "_getStateIdentifier",
838
- value: function ()
839
- /*: ParseObject | { id: string, className: string }*/
840
- {
351
+ value: function () /*: ParseObject | { id: string, className: string }*/{
841
352
  if (singleInstance) {
842
353
  var id = this.id;
843
-
844
354
  if (!id) {
845
355
  id = this._getId();
846
356
  }
847
-
848
357
  return {
849
358
  id: id,
850
359
  className: this.className
@@ -855,49 +364,36 @@ var ParseObject = /*#__PURE__*/function () {
855
364
  }
856
365
  }, {
857
366
  key: "_getServerData",
858
- value: function ()
859
- /*: AttributeMap*/
860
- {
367
+ value: function () /*: AttributeMap*/{
861
368
  var stateController = _CoreManager.default.getObjectStateController();
862
-
863
369
  return stateController.getServerData(this._getStateIdentifier());
864
370
  }
865
371
  }, {
866
372
  key: "_clearServerData",
867
373
  value: function () {
868
374
  var serverData = this._getServerData();
869
-
870
375
  var unset = {};
871
-
872
376
  for (var _attr2 in serverData) {
873
377
  unset[_attr2] = undefined;
874
378
  }
875
-
876
379
  var stateController = _CoreManager.default.getObjectStateController();
877
-
878
380
  stateController.setServerData(this._getStateIdentifier(), unset);
879
381
  }
880
382
  }, {
881
383
  key: "_getPendingOps",
882
- value: function ()
883
- /*: Array<OpsMap>*/
884
- {
384
+ value: function () /*: Array<OpsMap>*/{
885
385
  var stateController = _CoreManager.default.getObjectStateController();
886
-
887
386
  return stateController.getPendingOps(this._getStateIdentifier());
888
387
  }
388
+
889
389
  /**
890
390
  * @param {Array<string>} [keysToClear] - if specified, only ops matching
891
391
  * these fields will be cleared
892
392
  */
893
-
894
393
  }, {
895
394
  key: "_clearPendingOps",
896
- value: function (keysToClear
897
- /*:: ?: Array<string>*/
898
- ) {
395
+ value: function (keysToClear /*:: ?: Array<string>*/) {
899
396
  var pending = this._getPendingOps();
900
-
901
397
  var latest = pending[pending.length - 1];
902
398
  var keys = keysToClear || (0, _keys.default)(latest);
903
399
  (0, _forEach.default)(keys).call(keys, function (key) {
@@ -906,26 +402,19 @@ var ParseObject = /*#__PURE__*/function () {
906
402
  }
907
403
  }, {
908
404
  key: "_getDirtyObjectAttributes",
909
- value: function ()
910
- /*: AttributeMap*/
911
- {
405
+ value: function () /*: AttributeMap*/{
912
406
  var attributes = this.attributes;
913
-
914
407
  var stateController = _CoreManager.default.getObjectStateController();
915
-
916
408
  var objectCache = stateController.getObjectCache(this._getStateIdentifier());
917
409
  var dirty = {};
918
-
919
410
  for (var _attr3 in attributes) {
920
411
  var val = attributes[_attr3];
921
-
922
412
  if (val && (0, _typeof2.default)(val) === 'object' && !(val instanceof ParseObject) && !(val instanceof _ParseFile.default) && !(val instanceof _ParseRelation.default)) {
923
413
  // Due to the way browsers construct maps, the key order will not change
924
414
  // unless the object is changed
925
415
  try {
926
416
  var json = (0, _encode.default)(val, false, true);
927
417
  var stringified = (0, _stringify.default)(json);
928
-
929
418
  if (objectCache[_attr3] !== stringified) {
930
419
  dirty[_attr3] = val;
931
420
  }
@@ -936,45 +425,29 @@ var ParseObject = /*#__PURE__*/function () {
936
425
  }
937
426
  }
938
427
  }
939
-
940
428
  return dirty;
941
429
  }
942
430
  }, {
943
431
  key: "_toFullJSON",
944
- value: function (seen
945
- /*:: ?: Array<any>*/
946
- , offline
947
- /*:: ?: boolean*/
948
- )
949
- /*: AttributeMap*/
950
- {
951
- var json
952
- /*: { [key: string]: mixed }*/
953
- = this.toJSON(seen, offline);
432
+ value: function (seen /*:: ?: Array<any>*/, offline /*:: ?: boolean*/) /*: AttributeMap*/{
433
+ var json /*: { [key: string]: mixed }*/ = this.toJSON(seen, offline);
954
434
  json.__type = 'Object';
955
435
  json.className = this.className;
956
436
  return json;
957
437
  }
958
438
  }, {
959
439
  key: "_getSaveJSON",
960
- value: function ()
961
- /*: AttributeMap*/
962
- {
440
+ value: function () /*: AttributeMap*/{
963
441
  var pending = this._getPendingOps();
964
-
965
442
  var dirtyObjects = this._getDirtyObjectAttributes();
966
-
967
443
  var json = {};
968
-
969
444
  for (var attr in dirtyObjects) {
970
445
  var isDotNotation = false;
971
-
972
446
  for (var i = 0; i < pending.length; i += 1) {
973
447
  for (var field in pending[i]) {
974
448
  // Dot notation operations are handled later
975
449
  if ((0, _includes.default)(field).call(field, '.')) {
976
450
  var fieldName = field.split('.')[0];
977
-
978
451
  if (fieldName === attr) {
979
452
  isDotNotation = true;
980
453
  break;
@@ -982,29 +455,21 @@ var ParseObject = /*#__PURE__*/function () {
982
455
  }
983
456
  }
984
457
  }
985
-
986
458
  if (!isDotNotation) {
987
459
  json[attr] = new _ParseOp.SetOp(dirtyObjects[attr]).toJSON();
988
460
  }
989
461
  }
990
-
991
462
  for (attr in pending[0]) {
992
463
  json[attr] = pending[0][attr].toJSON();
993
464
  }
994
-
995
465
  return json;
996
466
  }
997
467
  }, {
998
468
  key: "_getSaveParams",
999
- value: function ()
1000
- /*: SaveParams*/
1001
- {
469
+ value: function () /*: SaveParams*/{
1002
470
  var method = this.id ? 'PUT' : 'POST';
1003
-
1004
471
  var body = this._getSaveJSON();
1005
-
1006
472
  var path = 'classes/' + this.className;
1007
-
1008
473
  if (_CoreManager.default.get('ALLOW_CUSTOM_OBJECT_ID')) {
1009
474
  if (!this.createdAt) {
1010
475
  method = 'POST';
@@ -1018,7 +483,6 @@ var ParseObject = /*#__PURE__*/function () {
1018
483
  } else if (this.className === '_User') {
1019
484
  path = 'users';
1020
485
  }
1021
-
1022
486
  return {
1023
487
  method: method,
1024
488
  body: body,
@@ -1027,70 +491,52 @@ var ParseObject = /*#__PURE__*/function () {
1027
491
  }
1028
492
  }, {
1029
493
  key: "_finishFetch",
1030
- value: function (serverData
1031
- /*: AttributeMap*/
1032
- ) {
494
+ value: function (serverData /*: AttributeMap*/) {
1033
495
  if (!this.id && serverData.objectId) {
1034
496
  this.id = serverData.objectId;
1035
497
  }
1036
-
1037
498
  var stateController = _CoreManager.default.getObjectStateController();
1038
-
1039
499
  stateController.initializeState(this._getStateIdentifier());
1040
500
  var decoded = {};
1041
-
1042
501
  for (var _attr4 in serverData) {
1043
502
  if (_attr4 === 'ACL') {
1044
503
  decoded[_attr4] = new _ParseACL.default(serverData[_attr4]);
1045
504
  } else if (_attr4 !== 'objectId') {
1046
505
  decoded[_attr4] = (0, _decode.default)(serverData[_attr4]);
1047
-
1048
506
  if (decoded[_attr4] instanceof _ParseRelation.default) {
1049
507
  decoded[_attr4]._ensureParentAndKey(this, _attr4);
1050
508
  }
1051
509
  }
1052
510
  }
1053
-
1054
511
  if (decoded.createdAt && typeof decoded.createdAt === 'string') {
1055
512
  decoded.createdAt = (0, _parseDate.default)(decoded.createdAt);
1056
513
  }
1057
-
1058
514
  if (decoded.updatedAt && typeof decoded.updatedAt === 'string') {
1059
515
  decoded.updatedAt = (0, _parseDate.default)(decoded.updatedAt);
1060
516
  }
1061
-
1062
517
  if (!decoded.updatedAt && decoded.createdAt) {
1063
518
  decoded.updatedAt = decoded.createdAt;
1064
519
  }
1065
-
1066
520
  stateController.commitServerChanges(this._getStateIdentifier(), decoded);
1067
521
  }
1068
522
  }, {
1069
523
  key: "_setExisted",
1070
- value: function (existed
1071
- /*: boolean*/
1072
- ) {
524
+ value: function (existed /*: boolean*/) {
1073
525
  var stateController = _CoreManager.default.getObjectStateController();
1074
-
1075
526
  var state = stateController.getState(this._getStateIdentifier());
1076
-
1077
527
  if (state) {
1078
528
  state.existed = existed;
1079
529
  }
1080
530
  }
1081
531
  }, {
1082
532
  key: "_migrateId",
1083
- value: function (serverId
1084
- /*: string*/
1085
- ) {
533
+ value: function (serverId /*: string*/) {
1086
534
  if (this._localId && serverId) {
1087
535
  if (singleInstance) {
1088
536
  var stateController = _CoreManager.default.getObjectStateController();
1089
-
1090
537
  var oldState = stateController.removeState(this._getStateIdentifier());
1091
538
  this.id = serverId;
1092
539
  delete this._localId;
1093
-
1094
540
  if (oldState) {
1095
541
  stateController.initializeState(this._getStateIdentifier(), oldState);
1096
542
  }
@@ -1102,17 +548,10 @@ var ParseObject = /*#__PURE__*/function () {
1102
548
  }
1103
549
  }, {
1104
550
  key: "_handleSaveResponse",
1105
- value: function (response
1106
- /*: AttributeMap*/
1107
- , status
1108
- /*: number*/
1109
- ) {
551
+ value: function (response /*: AttributeMap*/, status /*: number*/) {
1110
552
  var changes = {};
1111
-
1112
553
  var stateController = _CoreManager.default.getObjectStateController();
1113
-
1114
554
  var pending = stateController.popPendingState(this._getStateIdentifier());
1115
-
1116
555
  for (var attr in pending) {
1117
556
  if (pending[attr] instanceof _ParseOp.RelationOp) {
1118
557
  changes[attr] = pending[attr].applyTo(undefined, this, attr);
@@ -1121,7 +560,6 @@ var ParseObject = /*#__PURE__*/function () {
1121
560
  changes[attr] = pending[attr].applyTo(undefined);
1122
561
  }
1123
562
  }
1124
-
1125
563
  for (attr in response) {
1126
564
  if ((attr === 'createdAt' || attr === 'updatedAt') && typeof response[attr] === 'string') {
1127
565
  changes[attr] = (0, _parseDate.default)(response[attr]);
@@ -1129,44 +567,39 @@ var ParseObject = /*#__PURE__*/function () {
1129
567
  changes[attr] = new _ParseACL.default(response[attr]);
1130
568
  } else if (attr !== 'objectId') {
1131
569
  var val = (0, _decode.default)(response[attr]);
1132
-
1133
570
  if (val && (0, _getPrototypeOf.default)(val) === Object.prototype) {
1134
571
  changes[attr] = _objectSpread(_objectSpread({}, this.attributes[attr]), val);
1135
572
  } else {
1136
573
  changes[attr] = val;
1137
574
  }
1138
-
1139
575
  if (changes[attr] instanceof _ParseOp.UnsetOp) {
1140
576
  changes[attr] = undefined;
1141
577
  }
1142
578
  }
1143
579
  }
1144
-
1145
580
  if (changes.createdAt && !changes.updatedAt) {
1146
581
  changes.updatedAt = changes.createdAt;
1147
582
  }
1148
-
1149
583
  this._migrateId(response.objectId);
1150
-
1151
584
  if (status !== 201) {
1152
585
  this._setExisted(true);
1153
586
  }
1154
-
1155
587
  stateController.commitServerChanges(this._getStateIdentifier(), changes);
1156
588
  }
1157
589
  }, {
1158
590
  key: "_handleSaveError",
1159
591
  value: function () {
1160
592
  var stateController = _CoreManager.default.getObjectStateController();
1161
-
1162
593
  stateController.mergeFirstPendingState(this._getStateIdentifier());
1163
594
  }
1164
595
  }, {
1165
596
  key: "initialize",
1166
- value:
1167
- /** Public methods **/
1168
- function () {// NOOP
597
+ value: /* Public methods */
598
+
599
+ function () {
600
+ // NOOP
1169
601
  }
602
+
1170
603
  /**
1171
604
  * Returns a JSON version of the object suitable for saving to Parse.
1172
605
  *
@@ -1174,21 +607,13 @@ var ParseObject = /*#__PURE__*/function () {
1174
607
  * @param offline
1175
608
  * @returns {object}
1176
609
  */
1177
-
1178
610
  }, {
1179
611
  key: "toJSON",
1180
- value: function (seen
1181
- /*: Array<any> | void*/
1182
- , offline
1183
- /*:: ?: boolean*/
1184
- )
1185
- /*: AttributeMap*/
1186
- {
612
+ value: function (seen /*: Array<any> | void*/, offline /*:: ?: boolean*/) /*: AttributeMap*/{
1187
613
  var seenEntry = this.id ? this.className + ':' + this.id : this;
1188
614
  seen = seen || [seenEntry];
1189
615
  var json = {};
1190
616
  var attrs = this.attributes;
1191
-
1192
617
  for (var _attr5 in attrs) {
1193
618
  if ((_attr5 === 'createdAt' || _attr5 === 'updatedAt') && attrs[_attr5].toJSON) {
1194
619
  json[_attr5] = attrs[_attr5].toJSON();
@@ -1196,39 +621,31 @@ var ParseObject = /*#__PURE__*/function () {
1196
621
  json[_attr5] = (0, _encode.default)(attrs[_attr5], false, false, seen, offline);
1197
622
  }
1198
623
  }
1199
-
1200
624
  var pending = this._getPendingOps();
1201
-
1202
625
  for (var _attr6 in pending[0]) {
1203
626
  json[_attr6] = pending[0][_attr6].toJSON(offline);
1204
627
  }
1205
-
1206
628
  if (this.id) {
1207
629
  json.objectId = this.id;
1208
630
  }
1209
-
1210
631
  return json;
1211
632
  }
633
+
1212
634
  /**
1213
635
  * Determines whether this ParseObject is equal to another ParseObject
1214
636
  *
1215
637
  * @param {object} other - An other object ot compare
1216
638
  * @returns {boolean}
1217
639
  */
1218
-
1219
640
  }, {
1220
641
  key: "equals",
1221
- value: function (other
1222
- /*: mixed*/
1223
- )
1224
- /*: boolean*/
1225
- {
642
+ value: function (other /*: mixed*/) /*: boolean*/{
1226
643
  if (this === other) {
1227
644
  return true;
1228
645
  }
1229
-
1230
646
  return other instanceof ParseObject && this.className === other.className && this.id === other.id && typeof this.id !== 'undefined';
1231
647
  }
648
+
1232
649
  /**
1233
650
  * Returns true if this object has been modified since its last
1234
651
  * save/refresh. If an attribute is specified, it returns true only if that
@@ -1237,206 +654,158 @@ var ParseObject = /*#__PURE__*/function () {
1237
654
  * @param {string} attr An attribute name (optional).
1238
655
  * @returns {boolean}
1239
656
  */
1240
-
1241
657
  }, {
1242
658
  key: "dirty",
1243
- value: function (attr
1244
- /*:: ?: string*/
1245
- )
1246
- /*: boolean*/
1247
- {
659
+ value: function (attr /*:: ?: string*/) /*: boolean*/{
1248
660
  if (!this.id) {
1249
661
  return true;
1250
662
  }
1251
-
1252
663
  var pendingOps = this._getPendingOps();
1253
-
1254
664
  var dirtyObjects = this._getDirtyObjectAttributes();
1255
-
1256
665
  if (attr) {
1257
666
  if (dirtyObjects.hasOwnProperty(attr)) {
1258
667
  return true;
1259
668
  }
1260
-
1261
669
  for (var i = 0; i < pendingOps.length; i++) {
1262
670
  if (pendingOps[i].hasOwnProperty(attr)) {
1263
671
  return true;
1264
672
  }
1265
673
  }
1266
-
1267
674
  return false;
1268
675
  }
1269
-
1270
676
  if ((0, _keys.default)(pendingOps[0]).length !== 0) {
1271
677
  return true;
1272
678
  }
1273
-
1274
679
  if ((0, _keys.default)(dirtyObjects).length !== 0) {
1275
680
  return true;
1276
681
  }
1277
-
1278
682
  return false;
1279
683
  }
684
+
1280
685
  /**
1281
686
  * Returns an array of keys that have been modified since last save/refresh
1282
687
  *
1283
688
  * @returns {string[]}
1284
689
  */
1285
-
1286
690
  }, {
1287
691
  key: "dirtyKeys",
1288
- value: function ()
1289
- /*: Array<string>*/
1290
- {
692
+ value: function () /*: Array<string>*/{
1291
693
  var pendingOps = this._getPendingOps();
1292
-
1293
694
  var keys = {};
1294
-
1295
695
  for (var i = 0; i < pendingOps.length; i++) {
1296
696
  for (var _attr7 in pendingOps[i]) {
1297
697
  keys[_attr7] = true;
1298
698
  }
1299
699
  }
1300
-
1301
700
  var dirtyObjects = this._getDirtyObjectAttributes();
1302
-
1303
701
  for (var _attr8 in dirtyObjects) {
1304
702
  keys[_attr8] = true;
1305
703
  }
1306
-
1307
704
  return (0, _keys.default)(keys);
1308
705
  }
706
+
1309
707
  /**
1310
708
  * Returns true if the object has been fetched.
1311
709
  *
1312
710
  * @returns {boolean}
1313
711
  */
1314
-
1315
712
  }, {
1316
713
  key: "isDataAvailable",
1317
- value: function ()
1318
- /*: boolean*/
1319
- {
714
+ value: function () /*: boolean*/{
1320
715
  var serverData = this._getServerData();
1321
-
1322
716
  return !!(0, _keys.default)(serverData).length;
1323
717
  }
718
+
1324
719
  /**
1325
720
  * Gets a Pointer referencing this Object.
1326
721
  *
1327
722
  * @returns {Pointer}
1328
723
  */
1329
-
1330
724
  }, {
1331
725
  key: "toPointer",
1332
- value: function ()
1333
- /*: Pointer*/
1334
- {
726
+ value: function () /*: Pointer*/{
1335
727
  if (!this.id) {
1336
728
  throw new Error('Cannot create a pointer to an unsaved ParseObject');
1337
729
  }
1338
-
1339
730
  return {
1340
731
  __type: 'Pointer',
1341
732
  className: this.className,
1342
733
  objectId: this.id
1343
734
  };
1344
735
  }
736
+
1345
737
  /**
1346
738
  * Gets a Pointer referencing this Object.
1347
739
  *
1348
740
  * @returns {Pointer}
1349
741
  */
1350
-
1351
742
  }, {
1352
743
  key: "toOfflinePointer",
1353
- value: function ()
1354
- /*: Pointer*/
1355
- {
744
+ value: function () /*: Pointer*/{
1356
745
  if (!this._localId) {
1357
746
  throw new Error('Cannot create a offline pointer to a saved ParseObject');
1358
747
  }
1359
-
1360
748
  return {
1361
749
  __type: 'Object',
1362
750
  className: this.className,
1363
751
  _localId: this._localId
1364
752
  };
1365
753
  }
754
+
1366
755
  /**
1367
756
  * Gets the value of an attribute.
1368
757
  *
1369
758
  * @param {string} attr The string name of an attribute.
1370
759
  * @returns {*}
1371
760
  */
1372
-
1373
761
  }, {
1374
762
  key: "get",
1375
- value: function (attr
1376
- /*: string*/
1377
- )
1378
- /*: mixed*/
1379
- {
763
+ value: function (attr /*: string*/) /*: mixed*/{
1380
764
  return this.attributes[attr];
1381
765
  }
766
+
1382
767
  /**
1383
768
  * Gets a relation on the given class for the attribute.
1384
769
  *
1385
770
  * @param {string} attr The attribute to get the relation for.
1386
771
  * @returns {Parse.Relation}
1387
772
  */
1388
-
1389
773
  }, {
1390
774
  key: "relation",
1391
- value: function (attr
1392
- /*: string*/
1393
- )
1394
- /*: ParseRelation*/
1395
- {
775
+ value: function (attr /*: string*/) /*: ParseRelation*/{
1396
776
  var value = this.get(attr);
1397
-
1398
777
  if (value) {
1399
778
  if (!(value instanceof _ParseRelation.default)) {
1400
779
  throw new Error('Called relation() on non-relation field ' + attr);
1401
780
  }
1402
-
1403
781
  value._ensureParentAndKey(this, attr);
1404
-
1405
782
  return value;
1406
783
  }
1407
-
1408
784
  return new _ParseRelation.default(this, attr);
1409
785
  }
786
+
1410
787
  /**
1411
788
  * Gets the HTML-escaped value of an attribute.
1412
789
  *
1413
790
  * @param {string} attr The string name of an attribute.
1414
791
  * @returns {string}
1415
792
  */
1416
-
1417
793
  }, {
1418
794
  key: "escape",
1419
- value: function (attr
1420
- /*: string*/
1421
- )
1422
- /*: string*/
1423
- {
795
+ value: function (attr /*: string*/) /*: string*/{
1424
796
  var val = this.attributes[attr];
1425
-
1426
797
  if (val == null) {
1427
798
  return '';
1428
799
  }
1429
-
1430
800
  if (typeof val !== 'string') {
1431
801
  if (typeof val.toString !== 'function') {
1432
802
  return '';
1433
803
  }
1434
-
1435
804
  val = val.toString();
1436
805
  }
1437
-
1438
806
  return (0, _escape2.default)(val);
1439
807
  }
808
+
1440
809
  /**
1441
810
  * Returns <code>true</code> if the attribute contains a value that is not
1442
811
  * null or undefined.
@@ -1444,22 +813,16 @@ var ParseObject = /*#__PURE__*/function () {
1444
813
  * @param {string} attr The string name of the attribute.
1445
814
  * @returns {boolean}
1446
815
  */
1447
-
1448
816
  }, {
1449
817
  key: "has",
1450
- value: function (attr
1451
- /*: string*/
1452
- )
1453
- /*: boolean*/
1454
- {
818
+ value: function (attr /*: string*/) /*: boolean*/{
1455
819
  var attributes = this.attributes;
1456
-
1457
820
  if (attributes.hasOwnProperty(attr)) {
1458
821
  return attributes[attr] != null;
1459
822
  }
1460
-
1461
823
  return false;
1462
824
  }
825
+
1463
826
  /**
1464
827
  * Sets a hash of model attributes on the object.
1465
828
  *
@@ -1490,21 +853,11 @@ var ParseObject = /*#__PURE__*/function () {
1490
853
  * The only supported option is <code>error</code>.
1491
854
  * @returns {(ParseObject|boolean)} true if the set succeeded.
1492
855
  */
1493
-
1494
856
  }, {
1495
857
  key: "set",
1496
- value: function (key
1497
- /*: mixed*/
1498
- , value
1499
- /*: mixed*/
1500
- , options
1501
- /*:: ?: mixed*/
1502
- )
1503
- /*: ParseObject | boolean*/
1504
- {
858
+ value: function (key /*: mixed*/, value /*: mixed*/, options /*:: ?: mixed*/) /*: ParseObject | boolean*/{
1505
859
  var changes = {};
1506
860
  var newOps = {};
1507
-
1508
861
  if (key && (0, _typeof2.default)(key) === 'object') {
1509
862
  changes = key;
1510
863
  options = value;
@@ -1513,25 +866,20 @@ var ParseObject = /*#__PURE__*/function () {
1513
866
  } else {
1514
867
  return this;
1515
868
  }
1516
-
1517
869
  options = options || {};
1518
870
  var readonly = [];
1519
-
1520
871
  if (typeof this.constructor.readOnlyAttributes === 'function') {
1521
872
  readonly = (0, _concat.default)(readonly).call(readonly, this.constructor.readOnlyAttributes());
1522
873
  }
1523
-
1524
874
  for (var k in changes) {
1525
875
  if (k === 'createdAt' || k === 'updatedAt') {
1526
876
  // This property is read-only, but for legacy reasons we silently
1527
877
  // ignore it
1528
878
  continue;
1529
879
  }
1530
-
1531
880
  if ((0, _indexOf.default)(readonly).call(readonly, k) > -1) {
1532
881
  throw new Error('Cannot modify readonly attribute: ' + k);
1533
882
  }
1534
-
1535
883
  if (options.unset) {
1536
884
  newOps[k] = new _ParseOp.UnsetOp();
1537
885
  } else if (changes[k] instanceof _ParseOp.Op) {
@@ -1552,47 +900,40 @@ var ParseObject = /*#__PURE__*/function () {
1552
900
  newOps[k] = new _ParseOp.SetOp(changes[k]);
1553
901
  }
1554
902
  }
903
+ var currentAttributes = this.attributes;
1555
904
 
1556
- var currentAttributes = this.attributes; // Calculate new values
1557
-
905
+ // Calculate new values
1558
906
  var newValues = {};
1559
-
1560
907
  for (var _attr9 in newOps) {
1561
908
  if (newOps[_attr9] instanceof _ParseOp.RelationOp) {
1562
909
  newValues[_attr9] = newOps[_attr9].applyTo(currentAttributes[_attr9], this, _attr9);
1563
910
  } else if (!(newOps[_attr9] instanceof _ParseOp.UnsetOp)) {
1564
911
  newValues[_attr9] = newOps[_attr9].applyTo(currentAttributes[_attr9]);
1565
912
  }
1566
- } // Validate changes
1567
-
913
+ }
1568
914
 
915
+ // Validate changes
1569
916
  if (!options.ignoreValidation) {
1570
917
  var validation = this.validate(newValues);
1571
-
1572
918
  if (validation) {
1573
919
  if (typeof options.error === 'function') {
1574
920
  options.error(this, validation);
1575
921
  }
1576
-
1577
922
  return false;
1578
923
  }
1579
- } // Consolidate Ops
1580
-
924
+ }
1581
925
 
926
+ // Consolidate Ops
1582
927
  var pendingOps = this._getPendingOps();
1583
-
1584
928
  var last = pendingOps.length - 1;
1585
-
1586
929
  var stateController = _CoreManager.default.getObjectStateController();
1587
-
1588
930
  for (var _attr10 in newOps) {
1589
931
  var nextOp = newOps[_attr10].mergeWith(pendingOps[last][_attr10]);
1590
-
1591
932
  stateController.setPendingOp(this._getStateIdentifier(), _attr10, nextOp);
1592
933
  }
1593
-
1594
934
  return this;
1595
935
  }
936
+
1596
937
  /**
1597
938
  * Remove an attribute from the model. This is a noop if the attribute doesn't
1598
939
  * exist.
@@ -1601,20 +942,14 @@ var ParseObject = /*#__PURE__*/function () {
1601
942
  * @param options
1602
943
  * @returns {(ParseObject | boolean)}
1603
944
  */
1604
-
1605
945
  }, {
1606
946
  key: "unset",
1607
- value: function (attr
1608
- /*: string*/
1609
- , options
1610
- /*:: ?: { [opt: string]: mixed }*/
1611
- )
1612
- /*: ParseObject | boolean*/
1613
- {
947
+ value: function (attr /*: string*/, options /*:: ?: { [opt: string]: mixed }*/) /*: ParseObject | boolean*/{
1614
948
  options = options || {};
1615
949
  options.unset = true;
1616
950
  return this.set(attr, null, options);
1617
951
  }
952
+
1618
953
  /**
1619
954
  * Atomically increments the value of the given attribute the next time the
1620
955
  * object is saved. If no amount is specified, 1 is used by default.
@@ -1623,26 +958,18 @@ var ParseObject = /*#__PURE__*/function () {
1623
958
  * @param amount {Number} The amount to increment by (optional).
1624
959
  * @returns {(ParseObject|boolean)}
1625
960
  */
1626
-
1627
961
  }, {
1628
962
  key: "increment",
1629
- value: function (attr
1630
- /*: string*/
1631
- , amount
1632
- /*:: ?: number*/
1633
- )
1634
- /*: ParseObject | boolean*/
1635
- {
963
+ value: function (attr /*: string*/, amount /*:: ?: number*/) /*: ParseObject | boolean*/{
1636
964
  if (typeof amount === 'undefined') {
1637
965
  amount = 1;
1638
966
  }
1639
-
1640
967
  if (typeof amount !== 'number') {
1641
968
  throw new Error('Cannot increment by a non-numeric amount.');
1642
969
  }
1643
-
1644
970
  return this.set(attr, new _ParseOp.IncrementOp(amount));
1645
971
  }
972
+
1646
973
  /**
1647
974
  * Atomically decrements the value of the given attribute the next time the
1648
975
  * object is saved. If no amount is specified, 1 is used by default.
@@ -1651,26 +978,18 @@ var ParseObject = /*#__PURE__*/function () {
1651
978
  * @param amount {Number} The amount to decrement by (optional).
1652
979
  * @returns {(ParseObject | boolean)}
1653
980
  */
1654
-
1655
981
  }, {
1656
982
  key: "decrement",
1657
- value: function (attr
1658
- /*: string*/
1659
- , amount
1660
- /*:: ?: number*/
1661
- )
1662
- /*: ParseObject | boolean*/
1663
- {
983
+ value: function (attr /*: string*/, amount /*:: ?: number*/) /*: ParseObject | boolean*/{
1664
984
  if (typeof amount === 'undefined') {
1665
985
  amount = 1;
1666
986
  }
1667
-
1668
987
  if (typeof amount !== 'number') {
1669
988
  throw new Error('Cannot decrement by a non-numeric amount.');
1670
989
  }
1671
-
1672
990
  return this.set(attr, new _ParseOp.IncrementOp(amount * -1));
1673
991
  }
992
+
1674
993
  /**
1675
994
  * Atomically add an object to the end of the array associated with a given
1676
995
  * key.
@@ -1679,18 +998,12 @@ var ParseObject = /*#__PURE__*/function () {
1679
998
  * @param item {} The item to add.
1680
999
  * @returns {(ParseObject | boolean)}
1681
1000
  */
1682
-
1683
1001
  }, {
1684
1002
  key: "add",
1685
- value: function (attr
1686
- /*: string*/
1687
- , item
1688
- /*: mixed*/
1689
- )
1690
- /*: ParseObject | boolean*/
1691
- {
1003
+ value: function (attr /*: string*/, item /*: mixed*/) /*: ParseObject | boolean*/{
1692
1004
  return this.set(attr, new _ParseOp.AddOp([item]));
1693
1005
  }
1006
+
1694
1007
  /**
1695
1008
  * Atomically add the objects to the end of the array associated with a given
1696
1009
  * key.
@@ -1699,18 +1012,12 @@ var ParseObject = /*#__PURE__*/function () {
1699
1012
  * @param items {Object[]} The items to add.
1700
1013
  * @returns {(ParseObject | boolean)}
1701
1014
  */
1702
-
1703
1015
  }, {
1704
1016
  key: "addAll",
1705
- value: function (attr
1706
- /*: string*/
1707
- , items
1708
- /*: Array<mixed>*/
1709
- )
1710
- /*: ParseObject | boolean*/
1711
- {
1017
+ value: function (attr /*: string*/, items /*: Array<mixed>*/) /*: ParseObject | boolean*/{
1712
1018
  return this.set(attr, new _ParseOp.AddOp(items));
1713
1019
  }
1020
+
1714
1021
  /**
1715
1022
  * Atomically add an object to the array associated with a given key, only
1716
1023
  * if it is not already present in the array. The position of the insert is
@@ -1720,18 +1027,12 @@ var ParseObject = /*#__PURE__*/function () {
1720
1027
  * @param item {} The object to add.
1721
1028
  * @returns {(ParseObject | boolean)}
1722
1029
  */
1723
-
1724
1030
  }, {
1725
1031
  key: "addUnique",
1726
- value: function (attr
1727
- /*: string*/
1728
- , item
1729
- /*: mixed*/
1730
- )
1731
- /*: ParseObject | boolean*/
1732
- {
1032
+ value: function (attr /*: string*/, item /*: mixed*/) /*: ParseObject | boolean*/{
1733
1033
  return this.set(attr, new _ParseOp.AddUniqueOp([item]));
1734
1034
  }
1035
+
1735
1036
  /**
1736
1037
  * Atomically add the objects to the array associated with a given key, only
1737
1038
  * if it is not already present in the array. The position of the insert is
@@ -1741,18 +1042,12 @@ var ParseObject = /*#__PURE__*/function () {
1741
1042
  * @param items {Object[]} The objects to add.
1742
1043
  * @returns {(ParseObject | boolean)}
1743
1044
  */
1744
-
1745
1045
  }, {
1746
1046
  key: "addAllUnique",
1747
- value: function (attr
1748
- /*: string*/
1749
- , items
1750
- /*: Array<mixed>*/
1751
- )
1752
- /*: ParseObject | boolean*/
1753
- {
1047
+ value: function (attr /*: string*/, items /*: Array<mixed>*/) /*: ParseObject | boolean*/{
1754
1048
  return this.set(attr, new _ParseOp.AddUniqueOp(items));
1755
1049
  }
1050
+
1756
1051
  /**
1757
1052
  * Atomically remove all instances of an object from the array associated
1758
1053
  * with a given key.
@@ -1761,18 +1056,12 @@ var ParseObject = /*#__PURE__*/function () {
1761
1056
  * @param item {} The object to remove.
1762
1057
  * @returns {(ParseObject | boolean)}
1763
1058
  */
1764
-
1765
1059
  }, {
1766
1060
  key: "remove",
1767
- value: function (attr
1768
- /*: string*/
1769
- , item
1770
- /*: mixed*/
1771
- )
1772
- /*: ParseObject | boolean*/
1773
- {
1061
+ value: function (attr /*: string*/, item /*: mixed*/) /*: ParseObject | boolean*/{
1774
1062
  return this.set(attr, new _ParseOp.RemoveOp([item]));
1775
1063
  }
1064
+
1776
1065
  /**
1777
1066
  * Atomically remove all instances of the objects from the array associated
1778
1067
  * with a given key.
@@ -1781,18 +1070,12 @@ var ParseObject = /*#__PURE__*/function () {
1781
1070
  * @param items {Object[]} The object to remove.
1782
1071
  * @returns {(ParseObject | boolean)}
1783
1072
  */
1784
-
1785
1073
  }, {
1786
1074
  key: "removeAll",
1787
- value: function (attr
1788
- /*: string*/
1789
- , items
1790
- /*: Array<mixed>*/
1791
- )
1792
- /*: ParseObject | boolean*/
1793
- {
1075
+ value: function (attr /*: string*/, items /*: Array<mixed>*/) /*: ParseObject | boolean*/{
1794
1076
  return this.set(attr, new _ParseOp.RemoveOp(items));
1795
1077
  }
1078
+
1796
1079
  /**
1797
1080
  * Returns an instance of a subclass of Parse.Op describing what kind of
1798
1081
  * modification has been performed on this field since the last time it was
@@ -1800,99 +1083,79 @@ var ParseObject = /*#__PURE__*/function () {
1800
1083
  * object.op("x") would return an instance of Parse.Op.Increment.
1801
1084
  *
1802
1085
  * @param attr {String} The key.
1803
- * @returns {Parse.Op} The operation, or undefined if none.
1086
+ * @returns {Parse.Op | undefined} The operation, or undefined if none.
1804
1087
  */
1805
-
1806
1088
  }, {
1807
1089
  key: "op",
1808
- value: function (attr
1809
- /*: string*/
1810
- )
1811
- /*: ?Op*/
1812
- {
1090
+ value: function (attr /*: string*/) /*: ?Op*/{
1813
1091
  var pending = this._getPendingOps();
1814
-
1815
1092
  for (var i = pending.length; i--;) {
1816
1093
  if (pending[i][attr]) {
1817
1094
  return pending[i][attr];
1818
1095
  }
1819
1096
  }
1820
1097
  }
1098
+
1821
1099
  /**
1822
1100
  * Creates a new model with identical attributes to this one.
1823
1101
  *
1824
1102
  * @returns {Parse.Object}
1825
1103
  */
1826
-
1827
1104
  }, {
1828
1105
  key: "clone",
1829
- value: function clone()
1830
- /*: any*/
1831
- {
1106
+ value: function clone() /*: any*/{
1832
1107
  var clone = new this.constructor(this.className);
1833
1108
  var attributes = this.attributes;
1834
-
1835
1109
  if (typeof this.constructor.readOnlyAttributes === 'function') {
1836
- var readonly = this.constructor.readOnlyAttributes() || []; // Attributes are frozen, so we have to rebuild an object,
1110
+ var readonly = this.constructor.readOnlyAttributes() || [];
1111
+ // Attributes are frozen, so we have to rebuild an object,
1837
1112
  // rather than delete readonly keys
1838
-
1839
1113
  var copy = {};
1840
-
1841
1114
  for (var a in attributes) {
1842
1115
  if ((0, _indexOf.default)(readonly).call(readonly, a) < 0) {
1843
1116
  copy[a] = attributes[a];
1844
1117
  }
1845
1118
  }
1846
-
1847
1119
  attributes = copy;
1848
1120
  }
1849
-
1850
1121
  if (clone.set) {
1851
1122
  clone.set(attributes);
1852
1123
  }
1853
-
1854
1124
  return clone;
1855
1125
  }
1126
+
1856
1127
  /**
1857
1128
  * Creates a new instance of this object. Not to be confused with clone()
1858
1129
  *
1859
1130
  * @returns {Parse.Object}
1860
1131
  */
1861
-
1862
1132
  }, {
1863
1133
  key: "newInstance",
1864
- value: function ()
1865
- /*: any*/
1866
- {
1134
+ value: function () /*: any*/{
1867
1135
  var clone = new this.constructor(this.className);
1868
1136
  clone.id = this.id;
1869
-
1870
1137
  if (singleInstance) {
1871
1138
  // Just return an object with the right id
1872
1139
  return clone;
1873
1140
  }
1874
-
1875
1141
  var stateController = _CoreManager.default.getObjectStateController();
1876
-
1877
1142
  if (stateController) {
1878
1143
  stateController.duplicateState(this._getStateIdentifier(), clone._getStateIdentifier());
1879
1144
  }
1880
-
1881
1145
  return clone;
1882
1146
  }
1147
+
1883
1148
  /**
1884
1149
  * Returns true if this object has never been saved to Parse.
1885
1150
  *
1886
1151
  * @returns {boolean}
1887
1152
  */
1888
-
1889
1153
  }, {
1890
1154
  key: "isNew",
1891
- value: function ()
1892
- /*: boolean*/
1893
- {
1155
+ value: function () /*: boolean*/{
1894
1156
  return !this.id;
1895
1157
  }
1158
+
1896
1159
  /**
1897
1160
  * Returns true if this object was created by the Parse server when the
1898
1161
  * object might have already been there (e.g. in the case of a Facebook
@@ -1900,26 +1163,20 @@ var ParseObject = /*#__PURE__*/function () {
1900
1163
  *
1901
1164
  * @returns {boolean}
1902
1165
  */
1903
-
1904
1166
  }, {
1905
1167
  key: "existed",
1906
- value: function ()
1907
- /*: boolean*/
1908
- {
1168
+ value: function () /*: boolean*/{
1909
1169
  if (!this.id) {
1910
1170
  return false;
1911
1171
  }
1912
-
1913
1172
  var stateController = _CoreManager.default.getObjectStateController();
1914
-
1915
1173
  var state = stateController.getState(this._getStateIdentifier());
1916
-
1917
1174
  if (state) {
1918
1175
  return state.existed;
1919
1176
  }
1920
-
1921
1177
  return false;
1922
1178
  }
1179
+
1923
1180
  /**
1924
1181
  * Returns true if this object exists on the Server
1925
1182
  *
@@ -1932,60 +1189,45 @@ var ParseObject = /*#__PURE__*/function () {
1932
1189
  * </ul>
1933
1190
  * @returns {Promise<boolean>} A boolean promise that is fulfilled if object exists.
1934
1191
  */
1935
-
1936
1192
  }, {
1937
1193
  key: "exists",
1938
1194
  value: function () {
1939
- var _exists = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options
1940
- /*:: ?: RequestOptions*/
1941
- ) {
1195
+ var _exists = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(options /*:: ?: RequestOptions*/) {
1942
1196
  var query;
1943
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1944
- while (1) {
1945
- switch (_context.prev = _context.next) {
1946
- case 0:
1947
- if (this.id) {
1948
- _context.next = 2;
1949
- break;
1950
- }
1951
-
1952
- return _context.abrupt("return", false);
1953
-
1954
- case 2:
1955
- _context.prev = 2;
1956
- query = new _ParseQuery.default(this.className);
1957
- _context.next = 6;
1958
- return query.get(this.id, options);
1959
-
1960
- case 6:
1961
- return _context.abrupt("return", true);
1962
-
1963
- case 9:
1964
- _context.prev = 9;
1965
- _context.t0 = _context["catch"](2);
1966
-
1967
- if (!(_context.t0.code === _ParseError.default.OBJECT_NOT_FOUND)) {
1968
- _context.next = 13;
1969
- break;
1970
- }
1971
-
1972
- return _context.abrupt("return", false);
1973
-
1974
- case 13:
1975
- throw _context.t0;
1976
-
1977
- case 14:
1978
- case "end":
1979
- return _context.stop();
1980
- }
1197
+ return _regenerator.default.wrap(function (_context) {
1198
+ while (1) switch (_context.prev = _context.next) {
1199
+ case 0:
1200
+ if (this.id) {
1201
+ _context.next = 2;
1202
+ break;
1203
+ }
1204
+ return _context.abrupt("return", false);
1205
+ case 2:
1206
+ _context.prev = 2;
1207
+ query = new _ParseQuery.default(this.className);
1208
+ _context.next = 6;
1209
+ return query.get(this.id, options);
1210
+ case 6:
1211
+ return _context.abrupt("return", true);
1212
+ case 9:
1213
+ _context.prev = 9;
1214
+ _context.t0 = _context["catch"](2);
1215
+ if (!(_context.t0.code === _ParseError.default.OBJECT_NOT_FOUND)) {
1216
+ _context.next = 13;
1217
+ break;
1218
+ }
1219
+ return _context.abrupt("return", false);
1220
+ case 13:
1221
+ throw _context.t0;
1222
+ case 14:
1223
+ case "end":
1224
+ return _context.stop();
1981
1225
  }
1982
1226
  }, _callee, this, [[2, 9]]);
1983
1227
  }));
1984
-
1985
- function exists(_x) {
1228
+ function exists() {
1986
1229
  return _exists.apply(this, arguments);
1987
1230
  }
1988
-
1989
1231
  return exists;
1990
1232
  }()
1991
1233
  /**
@@ -1993,14 +1235,12 @@ var ParseObject = /*#__PURE__*/function () {
1993
1235
  *
1994
1236
  * @returns {boolean}
1995
1237
  */
1996
-
1997
1238
  }, {
1998
1239
  key: "isValid",
1999
- value: function isValid()
2000
- /*: boolean*/
2001
- {
1240
+ value: function () /*: boolean*/{
2002
1241
  return !this.validate(this.attributes);
2003
1242
  }
1243
+
2004
1244
  /**
2005
1245
  * You should not call this function directly unless you subclass
2006
1246
  * <code>Parse.Object</code>, in which case you can override this method
@@ -2011,46 +1251,36 @@ var ParseObject = /*#__PURE__*/function () {
2011
1251
  * @returns {Parse.Error|boolean} False if the data is valid. An error object otherwise.
2012
1252
  * @see Parse.Object#set
2013
1253
  */
2014
-
2015
1254
  }, {
2016
1255
  key: "validate",
2017
- value: function validate(attrs
2018
- /*: AttributeMap*/
2019
- )
2020
- /*: ParseError | boolean*/
2021
- {
1256
+ value: function (attrs /*: AttributeMap*/) /*: ParseError | boolean*/{
2022
1257
  if (attrs.hasOwnProperty('ACL') && !(attrs.ACL instanceof _ParseACL.default)) {
2023
1258
  return new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'ACL must be a Parse ACL.');
2024
1259
  }
2025
-
2026
1260
  for (var _key in attrs) {
2027
1261
  if (!/^[A-Za-z][0-9A-Za-z_.]*$/.test(_key)) {
2028
1262
  return new _ParseError.default(_ParseError.default.INVALID_KEY_NAME);
2029
1263
  }
2030
1264
  }
2031
-
2032
1265
  return false;
2033
1266
  }
1267
+
2034
1268
  /**
2035
1269
  * Returns the ACL for this object.
2036
1270
  *
2037
1271
  * @returns {Parse.ACL} An instance of Parse.ACL.
2038
1272
  * @see Parse.Object#get
2039
1273
  */
2040
-
2041
1274
  }, {
2042
1275
  key: "getACL",
2043
- value: function getACL()
2044
- /*: ?ParseACL*/
2045
- {
1276
+ value: function () /*: ?ParseACL*/{
2046
1277
  var acl = this.get('ACL');
2047
-
2048
1278
  if (acl instanceof _ParseACL.default) {
2049
1279
  return acl;
2050
1280
  }
2051
-
2052
1281
  return null;
2053
1282
  }
1283
+
2054
1284
  /**
2055
1285
  * Sets the ACL to be used for this object.
2056
1286
  *
@@ -2059,45 +1289,31 @@ var ParseObject = /*#__PURE__*/function () {
2059
1289
  * @returns {(ParseObject | boolean)} Whether the set passed validation.
2060
1290
  * @see Parse.Object#set
2061
1291
  */
2062
-
2063
1292
  }, {
2064
1293
  key: "setACL",
2065
- value: function setACL(acl
2066
- /*: ParseACL*/
2067
- , options
2068
- /*:: ?: mixed*/
2069
- )
2070
- /*: ParseObject | boolean*/
2071
- {
1294
+ value: function (acl /*: ParseACL*/, options /*:: ?: mixed*/) /*: ParseObject | boolean*/{
2072
1295
  return this.set('ACL', acl, options);
2073
1296
  }
1297
+
2074
1298
  /**
2075
1299
  * Clears any (or specific) changes to this object made since the last call to save()
2076
1300
  *
2077
1301
  * @param {string} [keys] - specify which fields to revert
2078
1302
  */
2079
-
2080
1303
  }, {
2081
1304
  key: "revert",
2082
- value: function revert()
2083
- /*: void*/
2084
- {
1305
+ value: function () /*: void*/{
2085
1306
  var keysToRevert;
2086
-
2087
1307
  for (var _len = arguments.length, keys = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {
2088
1308
  keys[_key2] = arguments[_key2];
2089
1309
  }
2090
-
2091
1310
  if (keys.length) {
2092
1311
  keysToRevert = [];
2093
-
2094
1312
  var _iterator = _createForOfIteratorHelper(keys),
2095
- _step;
2096
-
1313
+ _step;
2097
1314
  try {
2098
1315
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
2099
1316
  var _key3 = _step.value;
2100
-
2101
1317
  if (typeof _key3 === 'string') {
2102
1318
  keysToRevert.push(_key3);
2103
1319
  } else {
@@ -2110,38 +1326,33 @@ var ParseObject = /*#__PURE__*/function () {
2110
1326
  _iterator.f();
2111
1327
  }
2112
1328
  }
2113
-
2114
1329
  this._clearPendingOps(keysToRevert);
2115
1330
  }
1331
+
2116
1332
  /**
2117
1333
  * Clears all attributes on a model
2118
1334
  *
2119
1335
  * @returns {(ParseObject | boolean)}
2120
1336
  */
2121
-
2122
1337
  }, {
2123
1338
  key: "clear",
2124
- value: function clear()
2125
- /*: ParseObject | boolean*/
2126
- {
1339
+ value: function () /*: ParseObject | boolean*/{
2127
1340
  var attributes = this.attributes;
2128
1341
  var erasable = {};
2129
1342
  var readonly = ['createdAt', 'updatedAt'];
2130
-
2131
1343
  if (typeof this.constructor.readOnlyAttributes === 'function') {
2132
1344
  readonly = (0, _concat.default)(readonly).call(readonly, this.constructor.readOnlyAttributes());
2133
1345
  }
2134
-
2135
1346
  for (var _attr11 in attributes) {
2136
1347
  if ((0, _indexOf.default)(readonly).call(readonly, _attr11) < 0) {
2137
1348
  erasable[_attr11] = true;
2138
1349
  }
2139
1350
  }
2140
-
2141
1351
  return this.set(erasable, {
2142
1352
  unset: true
2143
1353
  });
2144
1354
  }
1355
+
2145
1356
  /**
2146
1357
  * Fetch the model from the server. If the server's representation of the
2147
1358
  * model differs from its current attributes, they will be overriden.
@@ -2159,39 +1370,27 @@ var ParseObject = /*#__PURE__*/function () {
2159
1370
  * @returns {Promise} A promise that is fulfilled when the fetch
2160
1371
  * completes.
2161
1372
  */
2162
-
2163
1373
  }, {
2164
1374
  key: "fetch",
2165
- value: function fetch(options
2166
- /*: RequestOptions*/
2167
- )
2168
- /*: Promise*/
2169
- {
1375
+ value: function (options /*: RequestOptions*/) /*: Promise*/{
2170
1376
  options = options || {};
2171
1377
  var fetchOptions = {};
2172
-
2173
1378
  if (options.hasOwnProperty('useMasterKey')) {
2174
1379
  fetchOptions.useMasterKey = options.useMasterKey;
2175
1380
  }
2176
-
2177
1381
  if (options.hasOwnProperty('sessionToken')) {
2178
1382
  fetchOptions.sessionToken = options.sessionToken;
2179
1383
  }
2180
-
2181
1384
  if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
2182
1385
  fetchOptions.context = options.context;
2183
1386
  }
2184
-
2185
1387
  if (options.hasOwnProperty('include')) {
2186
1388
  fetchOptions.include = [];
2187
-
2188
1389
  if ((0, _isArray.default)(options.include)) {
2189
1390
  var _context2;
2190
-
2191
1391
  (0, _forEach.default)(_context2 = options.include).call(_context2, function (key) {
2192
1392
  if ((0, _isArray.default)(key)) {
2193
1393
  var _context3;
2194
-
2195
1394
  fetchOptions.include = (0, _concat.default)(_context3 = fetchOptions.include).call(_context3, key);
2196
1395
  } else {
2197
1396
  fetchOptions.include.push(key);
@@ -2201,11 +1400,10 @@ var ParseObject = /*#__PURE__*/function () {
2201
1400
  fetchOptions.include.push(options.include);
2202
1401
  }
2203
1402
  }
2204
-
2205
1403
  var controller = _CoreManager.default.getObjectController();
2206
-
2207
1404
  return controller.fetch(this, true, fetchOptions);
2208
1405
  }
1406
+
2209
1407
  /**
2210
1408
  * Fetch the model from the server. If the server's representation of the
2211
1409
  * model differs from its current attributes, they will be overriden.
@@ -2224,20 +1422,14 @@ var ParseObject = /*#__PURE__*/function () {
2224
1422
  * @returns {Promise} A promise that is fulfilled when the fetch
2225
1423
  * completes.
2226
1424
  */
2227
-
2228
1425
  }, {
2229
1426
  key: "fetchWithInclude",
2230
- value: function fetchWithInclude(keys
2231
- /*: String | Array<string | Array<string>>*/
2232
- , options
2233
- /*: RequestOptions*/
2234
- )
2235
- /*: Promise*/
2236
- {
1427
+ value: function (keys /*: String | Array<string | Array<string>>*/, options /*: RequestOptions*/) /*: Promise*/{
2237
1428
  options = options || {};
2238
1429
  options.include = keys;
2239
1430
  return this.fetch(options);
2240
1431
  }
1432
+
2241
1433
  /**
2242
1434
  * Saves this object to the server at some unspecified time in the future,
2243
1435
  * even if Parse is currently inaccessible.
@@ -2262,55 +1454,41 @@ var ParseObject = /*#__PURE__*/function () {
2262
1454
  * @returns {Promise} A promise that is fulfilled when the save
2263
1455
  * completes.
2264
1456
  */
2265
-
2266
1457
  }, {
2267
1458
  key: "saveEventually",
2268
1459
  value: function () {
2269
- var _saveEventually = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options
2270
- /*: SaveOptions*/
2271
- ) {
2272
- return _regeneratorRuntime().wrap(function _callee2$(_context4) {
2273
- while (1) {
2274
- switch (_context4.prev = _context4.next) {
2275
- case 0:
2276
- _context4.prev = 0;
2277
- _context4.next = 3;
2278
- return this.save(null, options);
2279
-
2280
- case 3:
1460
+ var _saveEventually = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(options /*: SaveOptions*/) {
1461
+ return _regenerator.default.wrap(function (_context4) {
1462
+ while (1) switch (_context4.prev = _context4.next) {
1463
+ case 0:
1464
+ _context4.prev = 0;
1465
+ _context4.next = 3;
1466
+ return this.save(null, options);
1467
+ case 3:
1468
+ _context4.next = 11;
1469
+ break;
1470
+ case 5:
1471
+ _context4.prev = 5;
1472
+ _context4.t0 = _context4["catch"](0);
1473
+ if (!(_context4.t0.message === 'XMLHttpRequest failed: "Unable to connect to the Parse API"')) {
2281
1474
  _context4.next = 11;
2282
1475
  break;
2283
-
2284
- case 5:
2285
- _context4.prev = 5;
2286
- _context4.t0 = _context4["catch"](0);
2287
-
2288
- if (!(_context4.t0.message === 'XMLHttpRequest failed: "Unable to connect to the Parse API"')) {
2289
- _context4.next = 11;
2290
- break;
2291
- }
2292
-
2293
- _context4.next = 10;
2294
- return _EventuallyQueue.default.save(this, options);
2295
-
2296
- case 10:
2297
- _EventuallyQueue.default.poll();
2298
-
2299
- case 11:
2300
- return _context4.abrupt("return", this);
2301
-
2302
- case 12:
2303
- case "end":
2304
- return _context4.stop();
2305
- }
1476
+ }
1477
+ _context4.next = 10;
1478
+ return _EventuallyQueue.default.save(this, options);
1479
+ case 10:
1480
+ _EventuallyQueue.default.poll();
1481
+ case 11:
1482
+ return _context4.abrupt("return", this);
1483
+ case 12:
1484
+ case "end":
1485
+ return _context4.stop();
2306
1486
  }
2307
1487
  }, _callee2, this, [[0, 5]]);
2308
1488
  }));
2309
-
2310
- function saveEventually(_x2) {
1489
+ function saveEventually() {
2311
1490
  return _saveEventually.apply(this, arguments);
2312
1491
  }
2313
-
2314
1492
  return saveEventually;
2315
1493
  }()
2316
1494
  /**
@@ -2376,26 +1554,14 @@ var ParseObject = /*#__PURE__*/function () {
2376
1554
  * @returns {Promise} A promise that is fulfilled when the save
2377
1555
  * completes.
2378
1556
  */
2379
-
2380
1557
  }, {
2381
1558
  key: "save",
2382
- value: function save(arg1
2383
- /*: ?string | { [attr: string]: mixed }*/
2384
- , arg2
2385
- /*: SaveOptions | mixed*/
2386
- , arg3
2387
- /*:: ?: SaveOptions*/
2388
- )
2389
- /*: Promise*/
2390
- {
1559
+ value: function (arg1 /*: ?string | { [attr: string]: mixed }*/, arg2 /*: SaveOptions | mixed*/, arg3 /*:: ?: SaveOptions*/) /*: Promise*/{
2391
1560
  var _this = this;
2392
-
2393
1561
  var attrs;
2394
1562
  var options;
2395
-
2396
1563
  if ((0, _typeof2.default)(arg1) === 'object' || typeof arg1 === 'undefined') {
2397
1564
  attrs = arg1;
2398
-
2399
1565
  if ((0, _typeof2.default)(arg2) === 'object') {
2400
1566
  options = arg2;
2401
1567
  }
@@ -2404,43 +1570,34 @@ var ParseObject = /*#__PURE__*/function () {
2404
1570
  attrs[arg1] = arg2;
2405
1571
  options = arg3;
2406
1572
  }
2407
-
2408
1573
  if (attrs) {
2409
1574
  var validation = this.validate(attrs);
2410
-
2411
1575
  if (validation) {
2412
1576
  return _promise.default.reject(validation);
2413
1577
  }
2414
-
2415
1578
  this.set(attrs, options);
2416
1579
  }
2417
-
2418
1580
  options = options || {};
2419
1581
  var saveOptions = {};
2420
-
2421
1582
  if (options.hasOwnProperty('useMasterKey')) {
2422
1583
  saveOptions.useMasterKey = !!options.useMasterKey;
2423
1584
  }
2424
-
2425
1585
  if (options.hasOwnProperty('sessionToken') && typeof options.sessionToken === 'string') {
2426
1586
  saveOptions.sessionToken = options.sessionToken;
2427
1587
  }
2428
-
2429
1588
  if (options.hasOwnProperty('installationId') && typeof options.installationId === 'string') {
2430
1589
  saveOptions.installationId = options.installationId;
2431
1590
  }
2432
-
2433
1591
  if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
2434
1592
  saveOptions.context = options.context;
2435
1593
  }
2436
-
2437
1594
  var controller = _CoreManager.default.getObjectController();
2438
-
2439
1595
  var unsaved = options.cascadeSave !== false ? (0, _unsavedChildren.default)(this) : null;
2440
1596
  return controller.save(unsaved, saveOptions).then(function () {
2441
1597
  return controller.save(_this, saveOptions);
2442
1598
  });
2443
1599
  }
1600
+
2444
1601
  /**
2445
1602
  * Deletes this object from the server at some unspecified time in the future,
2446
1603
  * even if Parse is currently inaccessible.
@@ -2463,55 +1620,41 @@ var ParseObject = /*#__PURE__*/function () {
2463
1620
  * @returns {Promise} A promise that is fulfilled when the destroy
2464
1621
  * completes.
2465
1622
  */
2466
-
2467
1623
  }, {
2468
1624
  key: "destroyEventually",
2469
1625
  value: function () {
2470
- var _destroyEventually = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(options
2471
- /*: RequestOptions*/
2472
- ) {
2473
- return _regeneratorRuntime().wrap(function _callee3$(_context5) {
2474
- while (1) {
2475
- switch (_context5.prev = _context5.next) {
2476
- case 0:
2477
- _context5.prev = 0;
2478
- _context5.next = 3;
2479
- return this.destroy(options);
2480
-
2481
- case 3:
1626
+ var _destroyEventually = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(options /*: RequestOptions*/) {
1627
+ return _regenerator.default.wrap(function (_context5) {
1628
+ while (1) switch (_context5.prev = _context5.next) {
1629
+ case 0:
1630
+ _context5.prev = 0;
1631
+ _context5.next = 3;
1632
+ return this.destroy(options);
1633
+ case 3:
1634
+ _context5.next = 11;
1635
+ break;
1636
+ case 5:
1637
+ _context5.prev = 5;
1638
+ _context5.t0 = _context5["catch"](0);
1639
+ if (!(_context5.t0.message === 'XMLHttpRequest failed: "Unable to connect to the Parse API"')) {
2482
1640
  _context5.next = 11;
2483
1641
  break;
2484
-
2485
- case 5:
2486
- _context5.prev = 5;
2487
- _context5.t0 = _context5["catch"](0);
2488
-
2489
- if (!(_context5.t0.message === 'XMLHttpRequest failed: "Unable to connect to the Parse API"')) {
2490
- _context5.next = 11;
2491
- break;
2492
- }
2493
-
2494
- _context5.next = 10;
2495
- return _EventuallyQueue.default.destroy(this, options);
2496
-
2497
- case 10:
2498
- _EventuallyQueue.default.poll();
2499
-
2500
- case 11:
2501
- return _context5.abrupt("return", this);
2502
-
2503
- case 12:
2504
- case "end":
2505
- return _context5.stop();
2506
- }
1642
+ }
1643
+ _context5.next = 10;
1644
+ return _EventuallyQueue.default.destroy(this, options);
1645
+ case 10:
1646
+ _EventuallyQueue.default.poll();
1647
+ case 11:
1648
+ return _context5.abrupt("return", this);
1649
+ case 12:
1650
+ case "end":
1651
+ return _context5.stop();
2507
1652
  }
2508
1653
  }, _callee3, this, [[0, 5]]);
2509
1654
  }));
2510
-
2511
- function destroyEventually(_x3) {
1655
+ function destroyEventually() {
2512
1656
  return _destroyEventually.apply(this, arguments);
2513
1657
  }
2514
-
2515
1658
  return destroyEventually;
2516
1659
  }()
2517
1660
  /**
@@ -2528,35 +1671,26 @@ var ParseObject = /*#__PURE__*/function () {
2528
1671
  * @returns {Promise} A promise that is fulfilled when the destroy
2529
1672
  * completes.
2530
1673
  */
2531
-
2532
1674
  }, {
2533
1675
  key: "destroy",
2534
- value: function destroy(options
2535
- /*: RequestOptions*/
2536
- )
2537
- /*: Promise*/
2538
- {
1676
+ value: function (options /*: RequestOptions*/) /*: Promise*/{
2539
1677
  options = options || {};
2540
1678
  var destroyOptions = {};
2541
-
2542
1679
  if (options.hasOwnProperty('useMasterKey')) {
2543
1680
  destroyOptions.useMasterKey = options.useMasterKey;
2544
1681
  }
2545
-
2546
1682
  if (options.hasOwnProperty('sessionToken')) {
2547
1683
  destroyOptions.sessionToken = options.sessionToken;
2548
1684
  }
2549
-
2550
1685
  if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
2551
1686
  destroyOptions.context = options.context;
2552
1687
  }
2553
-
2554
1688
  if (!this.id) {
2555
1689
  return _promise.default.resolve();
2556
1690
  }
2557
-
2558
1691
  return _CoreManager.default.getObjectController().destroy(this, destroyOptions);
2559
1692
  }
1693
+
2560
1694
  /**
2561
1695
  * Asynchronously stores the object and every object it points to in the local datastore,
2562
1696
  * recursively, using a default pin name: _default.
@@ -2573,14 +1707,12 @@ var ParseObject = /*#__PURE__*/function () {
2573
1707
  *
2574
1708
  * @returns {Promise} A promise that is fulfilled when the pin completes.
2575
1709
  */
2576
-
2577
1710
  }, {
2578
1711
  key: "pin",
2579
- value: function pin()
2580
- /*: Promise<void>*/
2581
- {
1712
+ value: function () /*: Promise<void>*/{
2582
1713
  return ParseObject.pinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, [this]);
2583
1714
  }
1715
+
2584
1716
  /**
2585
1717
  * Asynchronously removes the object and every object it points to in the local datastore,
2586
1718
  * recursively, using a default pin name: _default.
@@ -2591,14 +1723,12 @@ var ParseObject = /*#__PURE__*/function () {
2591
1723
  *
2592
1724
  * @returns {Promise} A promise that is fulfilled when the unPin completes.
2593
1725
  */
2594
-
2595
1726
  }, {
2596
1727
  key: "unPin",
2597
- value: function unPin()
2598
- /*: Promise<void>*/
2599
- {
1728
+ value: function () /*: Promise<void>*/{
2600
1729
  return ParseObject.unPinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, [this]);
2601
1730
  }
1731
+
2602
1732
  /**
2603
1733
  * Asynchronously returns if the object is pinned
2604
1734
  *
@@ -2608,46 +1738,36 @@ var ParseObject = /*#__PURE__*/function () {
2608
1738
  *
2609
1739
  * @returns {Promise<boolean>} A boolean promise that is fulfilled if object is pinned.
2610
1740
  */
2611
-
2612
1741
  }, {
2613
1742
  key: "isPinned",
2614
1743
  value: function () {
2615
- var _isPinned = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
1744
+ var _isPinned = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
2616
1745
  var localDatastore, objectKey, pin;
2617
- return _regeneratorRuntime().wrap(function _callee4$(_context6) {
2618
- while (1) {
2619
- switch (_context6.prev = _context6.next) {
2620
- case 0:
2621
- localDatastore = _CoreManager.default.getLocalDatastore();
2622
-
2623
- if (localDatastore.isEnabled) {
2624
- _context6.next = 3;
2625
- break;
2626
- }
2627
-
2628
- return _context6.abrupt("return", _promise.default.reject('Parse.enableLocalDatastore() must be called first'));
2629
-
2630
- case 3:
2631
- objectKey = localDatastore.getKeyForObject(this);
2632
- _context6.next = 6;
2633
- return localDatastore.fromPinWithName(objectKey);
2634
-
2635
- case 6:
2636
- pin = _context6.sent;
2637
- return _context6.abrupt("return", pin.length > 0);
2638
-
2639
- case 8:
2640
- case "end":
2641
- return _context6.stop();
2642
- }
1746
+ return _regenerator.default.wrap(function (_context6) {
1747
+ while (1) switch (_context6.prev = _context6.next) {
1748
+ case 0:
1749
+ localDatastore = _CoreManager.default.getLocalDatastore();
1750
+ if (localDatastore.isEnabled) {
1751
+ _context6.next = 3;
1752
+ break;
1753
+ }
1754
+ return _context6.abrupt("return", _promise.default.reject('Parse.enableLocalDatastore() must be called first'));
1755
+ case 3:
1756
+ objectKey = localDatastore.getKeyForObject(this);
1757
+ _context6.next = 6;
1758
+ return localDatastore.fromPinWithName(objectKey);
1759
+ case 6:
1760
+ pin = _context6.sent;
1761
+ return _context6.abrupt("return", pin.length > 0);
1762
+ case 8:
1763
+ case "end":
1764
+ return _context6.stop();
2643
1765
  }
2644
1766
  }, _callee4, this);
2645
1767
  }));
2646
-
2647
1768
  function isPinned() {
2648
1769
  return _isPinned.apply(this, arguments);
2649
1770
  }
2650
-
2651
1771
  return isPinned;
2652
1772
  }()
2653
1773
  /**
@@ -2666,16 +1786,12 @@ var ParseObject = /*#__PURE__*/function () {
2666
1786
  * @param {string} name Name of Pin.
2667
1787
  * @returns {Promise} A promise that is fulfilled when the pin completes.
2668
1788
  */
2669
-
2670
1789
  }, {
2671
1790
  key: "pinWithName",
2672
- value: function pinWithName(name
2673
- /*: string*/
2674
- )
2675
- /*: Promise<void>*/
2676
- {
1791
+ value: function (name /*: string*/) /*: Promise<void>*/{
2677
1792
  return ParseObject.pinAllWithName(name, [this]);
2678
1793
  }
1794
+
2679
1795
  /**
2680
1796
  * Asynchronously removes the object and every object it points to in the local datastore, recursively.
2681
1797
  *
@@ -2686,16 +1802,12 @@ var ParseObject = /*#__PURE__*/function () {
2686
1802
  * @param {string} name Name of Pin.
2687
1803
  * @returns {Promise} A promise that is fulfilled when the unPin completes.
2688
1804
  */
2689
-
2690
1805
  }, {
2691
1806
  key: "unPinWithName",
2692
- value: function unPinWithName(name
2693
- /*: string*/
2694
- )
2695
- /*: Promise<void>*/
2696
- {
1807
+ value: function (name /*: string*/) /*: Promise<void>*/{
2697
1808
  return ParseObject.unPinAllWithName(name, [this]);
2698
1809
  }
1810
+
2699
1811
  /**
2700
1812
  * Asynchronously loads data from the local datastore into this object.
2701
1813
  *
@@ -2708,75 +1820,58 @@ var ParseObject = /*#__PURE__*/function () {
2708
1820
  *
2709
1821
  * @returns {Promise} A promise that is fulfilled when the fetch completes.
2710
1822
  */
2711
-
2712
1823
  }, {
2713
1824
  key: "fetchFromLocalDatastore",
2714
1825
  value: function () {
2715
- var _fetchFromLocalDatastore = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
1826
+ var _fetchFromLocalDatastore = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
2716
1827
  var localDatastore, objectKey, pinned, result;
2717
- return _regeneratorRuntime().wrap(function _callee5$(_context7) {
2718
- while (1) {
2719
- switch (_context7.prev = _context7.next) {
2720
- case 0:
2721
- localDatastore = _CoreManager.default.getLocalDatastore();
2722
-
2723
- if (localDatastore.isEnabled) {
2724
- _context7.next = 3;
2725
- break;
2726
- }
2727
-
2728
- throw new Error('Parse.enableLocalDatastore() must be called first');
2729
-
2730
- case 3:
2731
- objectKey = localDatastore.getKeyForObject(this);
2732
- _context7.next = 6;
2733
- return localDatastore._serializeObject(objectKey);
2734
-
2735
- case 6:
2736
- pinned = _context7.sent;
2737
-
2738
- if (pinned) {
2739
- _context7.next = 9;
2740
- break;
2741
- }
2742
-
2743
- throw new Error('Cannot fetch an unsaved ParseObject');
2744
-
2745
- case 9:
2746
- result = ParseObject.fromJSON(pinned);
2747
-
2748
- this._finishFetch(result.toJSON());
2749
-
2750
- return _context7.abrupt("return", this);
2751
-
2752
- case 12:
2753
- case "end":
2754
- return _context7.stop();
2755
- }
1828
+ return _regenerator.default.wrap(function (_context7) {
1829
+ while (1) switch (_context7.prev = _context7.next) {
1830
+ case 0:
1831
+ localDatastore = _CoreManager.default.getLocalDatastore();
1832
+ if (localDatastore.isEnabled) {
1833
+ _context7.next = 3;
1834
+ break;
1835
+ }
1836
+ throw new Error('Parse.enableLocalDatastore() must be called first');
1837
+ case 3:
1838
+ objectKey = localDatastore.getKeyForObject(this);
1839
+ _context7.next = 6;
1840
+ return localDatastore._serializeObject(objectKey);
1841
+ case 6:
1842
+ pinned = _context7.sent;
1843
+ if (pinned) {
1844
+ _context7.next = 9;
1845
+ break;
1846
+ }
1847
+ throw new Error('Cannot fetch an unsaved ParseObject');
1848
+ case 9:
1849
+ result = ParseObject.fromJSON(pinned);
1850
+ this._finishFetch(result.toJSON());
1851
+ return _context7.abrupt("return", this);
1852
+ case 12:
1853
+ case "end":
1854
+ return _context7.stop();
2756
1855
  }
2757
1856
  }, _callee5, this);
2758
1857
  }));
2759
-
2760
1858
  function fetchFromLocalDatastore() {
2761
1859
  return _fetchFromLocalDatastore.apply(this, arguments);
2762
1860
  }
2763
-
2764
1861
  return fetchFromLocalDatastore;
2765
- }()
2766
- /** Static methods **/
2767
-
1862
+ }() /* Static methods */
2768
1863
  }], [{
2769
1864
  key: "_getClassMap",
2770
- value: function _getClassMap() {
1865
+ value: function () {
2771
1866
  return classMap;
2772
1867
  }
2773
1868
  }, {
2774
1869
  key: "_clearAllState",
2775
- value: function _clearAllState() {
1870
+ value: function () {
2776
1871
  var stateController = _CoreManager.default.getObjectStateController();
2777
-
2778
1872
  stateController.clearAllState();
2779
1873
  }
1874
+
2780
1875
  /**
2781
1876
  * Fetches the given list of Parse.Object.
2782
1877
  * If any error is encountered, stops and calls the error handler.
@@ -2803,31 +1898,23 @@ var ParseObject = /*#__PURE__*/function () {
2803
1898
  * @static
2804
1899
  * @returns {Parse.Object[]}
2805
1900
  */
2806
-
2807
1901
  }, {
2808
1902
  key: "fetchAll",
2809
- value: function fetchAll(list
2810
- /*: Array<ParseObject>*/
2811
- ) {
2812
- var options
2813
- /*: RequestOptions*/
2814
- = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1903
+ value: function (list /*: Array<ParseObject>*/) {
1904
+ var options /*: RequestOptions*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2815
1905
  var queryOptions = {};
2816
-
2817
1906
  if (options.hasOwnProperty('useMasterKey')) {
2818
1907
  queryOptions.useMasterKey = options.useMasterKey;
2819
1908
  }
2820
-
2821
1909
  if (options.hasOwnProperty('sessionToken')) {
2822
1910
  queryOptions.sessionToken = options.sessionToken;
2823
1911
  }
2824
-
2825
1912
  if (options.hasOwnProperty('include')) {
2826
1913
  queryOptions.include = ParseObject.handleIncludeOptions(options);
2827
1914
  }
2828
-
2829
1915
  return _CoreManager.default.getObjectController().fetch(list, true, queryOptions);
2830
1916
  }
1917
+
2831
1918
  /**
2832
1919
  * Fetches the given list of Parse.Object.
2833
1920
  *
@@ -2857,20 +1944,14 @@ var ParseObject = /*#__PURE__*/function () {
2857
1944
  * @static
2858
1945
  * @returns {Parse.Object[]}
2859
1946
  */
2860
-
2861
1947
  }, {
2862
1948
  key: "fetchAllWithInclude",
2863
- value: function fetchAllWithInclude(list
2864
- /*: Array<ParseObject>*/
2865
- , keys
2866
- /*: String | Array<string | Array<string>>*/
2867
- , options
2868
- /*: RequestOptions*/
2869
- ) {
1949
+ value: function (list /*: Array<ParseObject>*/, keys /*: String | Array<string | Array<string>>*/, options /*: RequestOptions*/) {
2870
1950
  options = options || {};
2871
1951
  options.include = keys;
2872
1952
  return ParseObject.fetchAll(list, options);
2873
1953
  }
1954
+
2874
1955
  /**
2875
1956
  * Fetches the given list of Parse.Object if needed.
2876
1957
  * If any error is encountered, stops and calls the error handler.
@@ -2901,20 +1982,14 @@ var ParseObject = /*#__PURE__*/function () {
2901
1982
  * @static
2902
1983
  * @returns {Parse.Object[]}
2903
1984
  */
2904
-
2905
1985
  }, {
2906
1986
  key: "fetchAllIfNeededWithInclude",
2907
- value: function fetchAllIfNeededWithInclude(list
2908
- /*: Array<ParseObject>*/
2909
- , keys
2910
- /*: String | Array<string | Array<string>>*/
2911
- , options
2912
- /*: RequestOptions*/
2913
- ) {
1987
+ value: function (list /*: Array<ParseObject>*/, keys /*: String | Array<string | Array<string>>*/, options /*: RequestOptions*/) {
2914
1988
  options = options || {};
2915
1989
  options.include = keys;
2916
1990
  return ParseObject.fetchAllIfNeeded(list, options);
2917
1991
  }
1992
+
2918
1993
  /**
2919
1994
  * Fetches the given list of Parse.Object if needed.
2920
1995
  * If any error is encountered, stops and calls the error handler.
@@ -2933,37 +2008,28 @@ var ParseObject = /*#__PURE__*/function () {
2933
2008
  * @static
2934
2009
  * @returns {Parse.Object[]}
2935
2010
  */
2936
-
2937
2011
  }, {
2938
2012
  key: "fetchAllIfNeeded",
2939
- value: function fetchAllIfNeeded(list
2940
- /*: Array<ParseObject>*/
2941
- , options) {
2013
+ value: function (list /*: Array<ParseObject>*/, options) {
2942
2014
  options = options || {};
2943
2015
  var queryOptions = {};
2944
-
2945
2016
  if (options.hasOwnProperty('useMasterKey')) {
2946
2017
  queryOptions.useMasterKey = options.useMasterKey;
2947
2018
  }
2948
-
2949
2019
  if (options.hasOwnProperty('sessionToken')) {
2950
2020
  queryOptions.sessionToken = options.sessionToken;
2951
2021
  }
2952
-
2953
2022
  if (options.hasOwnProperty('include')) {
2954
2023
  queryOptions.include = ParseObject.handleIncludeOptions(options);
2955
2024
  }
2956
-
2957
2025
  return _CoreManager.default.getObjectController().fetch(list, false, queryOptions);
2958
2026
  }
2959
2027
  }, {
2960
2028
  key: "handleIncludeOptions",
2961
- value: function handleIncludeOptions(options) {
2029
+ value: function (options) {
2962
2030
  var include = [];
2963
-
2964
2031
  if ((0, _isArray.default)(options.include)) {
2965
2032
  var _context8;
2966
-
2967
2033
  (0, _forEach.default)(_context8 = options.include).call(_context8, function (key) {
2968
2034
  if ((0, _isArray.default)(key)) {
2969
2035
  include = (0, _concat.default)(include).call(include, key);
@@ -2974,9 +2040,9 @@ var ParseObject = /*#__PURE__*/function () {
2974
2040
  } else {
2975
2041
  include.push(options.include);
2976
2042
  }
2977
-
2978
2043
  return include;
2979
2044
  }
2045
+
2980
2046
  /**
2981
2047
  * Destroy the given list of models on the server if it was already persisted.
2982
2048
  *
@@ -3023,33 +2089,26 @@ var ParseObject = /*#__PURE__*/function () {
3023
2089
  * @returns {Promise} A promise that is fulfilled when the destroyAll
3024
2090
  * completes.
3025
2091
  */
3026
-
3027
2092
  }, {
3028
2093
  key: "destroyAll",
3029
- value: function destroyAll(list
3030
- /*: Array<ParseObject>*/
3031
- ) {
2094
+ value: function (list /*: Array<ParseObject>*/) {
3032
2095
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3033
2096
  var destroyOptions = {};
3034
-
3035
2097
  if (options.hasOwnProperty('useMasterKey')) {
3036
2098
  destroyOptions.useMasterKey = options.useMasterKey;
3037
2099
  }
3038
-
3039
2100
  if (options.hasOwnProperty('sessionToken')) {
3040
2101
  destroyOptions.sessionToken = options.sessionToken;
3041
2102
  }
3042
-
3043
2103
  if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
3044
2104
  destroyOptions.batchSize = options.batchSize;
3045
2105
  }
3046
-
3047
2106
  if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
3048
2107
  destroyOptions.context = options.context;
3049
2108
  }
3050
-
3051
2109
  return _CoreManager.default.getObjectController().destroy(list, destroyOptions);
3052
2110
  }
2111
+
3053
2112
  /**
3054
2113
  * Saves the given list of Parse.Object.
3055
2114
  * If any error is encountered, stops and calls the error handler.
@@ -3068,35 +2127,26 @@ var ParseObject = /*#__PURE__*/function () {
3068
2127
  * @static
3069
2128
  * @returns {Parse.Object[]}
3070
2129
  */
3071
-
3072
2130
  }, {
3073
2131
  key: "saveAll",
3074
- value: function saveAll(list
3075
- /*: Array<ParseObject>*/
3076
- ) {
3077
- var options
3078
- /*: RequestOptions*/
3079
- = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2132
+ value: function (list /*: Array<ParseObject>*/) {
2133
+ var options /*: RequestOptions*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3080
2134
  var saveOptions = {};
3081
-
3082
2135
  if (options.hasOwnProperty('useMasterKey')) {
3083
2136
  saveOptions.useMasterKey = options.useMasterKey;
3084
2137
  }
3085
-
3086
2138
  if (options.hasOwnProperty('sessionToken')) {
3087
2139
  saveOptions.sessionToken = options.sessionToken;
3088
2140
  }
3089
-
3090
2141
  if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
3091
2142
  saveOptions.batchSize = options.batchSize;
3092
2143
  }
3093
-
3094
2144
  if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
3095
2145
  saveOptions.context = options.context;
3096
2146
  }
3097
-
3098
2147
  return _CoreManager.default.getObjectController().save(list, saveOptions);
3099
2148
  }
2149
+
3100
2150
  /**
3101
2151
  * Creates a reference to a subclass of Parse.Object with the given id. This
3102
2152
  * does not exist on Parse.Object, only on subclasses.
@@ -3111,16 +2161,14 @@ var ParseObject = /*#__PURE__*/function () {
3111
2161
  * @static
3112
2162
  * @returns {Parse.Object} A Parse.Object reference.
3113
2163
  */
3114
-
3115
2164
  }, {
3116
2165
  key: "createWithoutData",
3117
- value: function createWithoutData(id
3118
- /*: string*/
3119
- ) {
2166
+ value: function (id /*: string*/) {
3120
2167
  var obj = new this();
3121
2168
  obj.id = id;
3122
2169
  return obj;
3123
2170
  }
2171
+
3124
2172
  /**
3125
2173
  * Creates a new instance of a Parse Object from a JSON representation.
3126
2174
  *
@@ -3131,61 +2179,44 @@ var ParseObject = /*#__PURE__*/function () {
3131
2179
  * @static
3132
2180
  * @returns {Parse.Object} A Parse.Object reference
3133
2181
  */
3134
-
3135
2182
  }, {
3136
2183
  key: "fromJSON",
3137
- value: function fromJSON(json
3138
- /*: any*/
3139
- , override
3140
- /*:: ?: boolean*/
3141
- , dirty
3142
- /*:: ?: boolean*/
3143
- ) {
2184
+ value: function (json /*: any*/, override /*:: ?: boolean*/, dirty /*:: ?: boolean*/) {
3144
2185
  if (!json.className) {
3145
2186
  throw new Error('Cannot create an object without a className');
3146
2187
  }
3147
-
3148
2188
  var constructor = classMap[json.className];
3149
2189
  var o = constructor ? new constructor(json.className) : new ParseObject(json.className);
3150
2190
  var otherAttributes = {};
3151
-
3152
2191
  for (var _attr12 in json) {
3153
2192
  if (_attr12 !== 'className' && _attr12 !== '__type') {
3154
2193
  otherAttributes[_attr12] = json[_attr12];
3155
-
3156
2194
  if (dirty) {
3157
2195
  o.set(_attr12, json[_attr12]);
3158
2196
  }
3159
2197
  }
3160
2198
  }
3161
-
3162
2199
  if (override) {
3163
2200
  // id needs to be set before clearServerData can work
3164
2201
  if (otherAttributes.objectId) {
3165
2202
  o.id = otherAttributes.objectId;
3166
2203
  }
3167
-
3168
2204
  var preserved = null;
3169
-
3170
2205
  if (typeof o._preserveFieldsOnFetch === 'function') {
3171
2206
  preserved = o._preserveFieldsOnFetch();
3172
2207
  }
3173
-
3174
2208
  o._clearServerData();
3175
-
3176
2209
  if (preserved) {
3177
2210
  o._finishFetch(preserved);
3178
2211
  }
3179
2212
  }
3180
-
3181
2213
  o._finishFetch(otherAttributes);
3182
-
3183
2214
  if (json.objectId) {
3184
2215
  o._setExisted(true);
3185
2216
  }
3186
-
3187
2217
  return o;
3188
2218
  }
2219
+
3189
2220
  /**
3190
2221
  * Registers a subclass of Parse.Object with a specific class name.
3191
2222
  * When objects of that class are retrieved from a query, they will be
@@ -3195,49 +2226,38 @@ var ParseObject = /*#__PURE__*/function () {
3195
2226
  * @param {string} className The class name of the subclass
3196
2227
  * @param {Function} constructor The subclass
3197
2228
  */
3198
-
3199
2229
  }, {
3200
2230
  key: "registerSubclass",
3201
- value: function registerSubclass(className
3202
- /*: string*/
3203
- , constructor
3204
- /*: any*/
3205
- ) {
2231
+ value: function (className /*: string*/, constructor /*: any*/) {
3206
2232
  if (typeof className !== 'string') {
3207
2233
  throw new TypeError('The first argument must be a valid class name.');
3208
2234
  }
3209
-
3210
2235
  if (typeof constructor === 'undefined') {
3211
2236
  throw new TypeError('You must supply a subclass constructor.');
3212
2237
  }
3213
-
3214
2238
  if (typeof constructor !== 'function') {
3215
2239
  throw new TypeError('You must register the subclass constructor. ' + 'Did you attempt to register an instance of the subclass?');
3216
2240
  }
3217
-
3218
2241
  classMap[className] = constructor;
3219
-
3220
2242
  if (!constructor.className) {
3221
2243
  constructor.className = className;
3222
2244
  }
3223
2245
  }
2246
+
3224
2247
  /**
3225
2248
  * Unegisters a subclass of Parse.Object with a specific class name.
3226
2249
  *
3227
2250
  * @param {string} className The class name of the subclass
3228
2251
  */
3229
-
3230
2252
  }, {
3231
2253
  key: "unregisterSubclass",
3232
- value: function unregisterSubclass(className
3233
- /*: string*/
3234
- ) {
2254
+ value: function (className /*: string*/) {
3235
2255
  if (typeof className !== 'string') {
3236
2256
  throw new TypeError('The first argument must be a valid class name.');
3237
2257
  }
3238
-
3239
2258
  delete classMap[className];
3240
2259
  }
2260
+
3241
2261
  /**
3242
2262
  * Creates a new subclass of Parse.Object for the given Parse class name.
3243
2263
  *
@@ -3275,16 +2295,9 @@ var ParseObject = /*#__PURE__*/function () {
3275
2295
  * this method.
3276
2296
  * @returns {Parse.Object} A new subclass of Parse.Object.
3277
2297
  */
3278
-
3279
2298
  }, {
3280
2299
  key: "extend",
3281
- value: function extend(className
3282
- /*: any*/
3283
- , protoProps
3284
- /*: any*/
3285
- , classProps
3286
- /*: any*/
3287
- ) {
2300
+ value: function (className /*: any*/, protoProps /*: any*/, classProps /*: any*/) {
3288
2301
  if (typeof className !== 'string') {
3289
2302
  if (className && typeof className.className === 'string') {
3290
2303
  return ParseObject.extend(className.className, className, protoProps);
@@ -3292,51 +2305,76 @@ var ParseObject = /*#__PURE__*/function () {
3292
2305
  throw new Error("Parse.Object.extend's first argument should be the className.");
3293
2306
  }
3294
2307
  }
3295
-
3296
2308
  var adjustedClassName = className;
3297
-
3298
2309
  if (adjustedClassName === 'User' && _CoreManager.default.get('PERFORM_USER_REWRITE')) {
3299
2310
  adjustedClassName = '_User';
3300
2311
  }
3301
-
3302
2312
  var parentProto = ParseObject.prototype;
3303
-
3304
2313
  if (this.hasOwnProperty('__super__') && this.__super__) {
3305
2314
  parentProto = this.prototype;
3306
- } else if (classMap[adjustedClassName]) {
3307
- parentProto = classMap[adjustedClassName].prototype;
3308
2315
  }
3309
-
3310
- var ParseObjectSubclass = function ParseObjectSubclass(attributes, options) {
2316
+ var ParseObjectSubclass = function (attributes, options) {
3311
2317
  this.className = adjustedClassName;
3312
- this._objCount = objectCount++; // Enable legacy initializers
3313
-
2318
+ this._objCount = objectCount++;
2319
+ // Enable legacy initializers
3314
2320
  if (typeof this.initialize === 'function') {
3315
2321
  this.initialize.apply(this, arguments);
3316
2322
  }
3317
-
2323
+ if (this._initializers) {
2324
+ var _iterator2 = _createForOfIteratorHelper(this._initializers),
2325
+ _step2;
2326
+ try {
2327
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
2328
+ var initializer = _step2.value;
2329
+ initializer.apply(this, arguments);
2330
+ }
2331
+ } catch (err) {
2332
+ _iterator2.e(err);
2333
+ } finally {
2334
+ _iterator2.f();
2335
+ }
2336
+ }
3318
2337
  if (attributes && (0, _typeof2.default)(attributes) === 'object') {
3319
2338
  if (!this.set(attributes || {}, options)) {
3320
2339
  throw new Error("Can't create an invalid Parse Object");
3321
2340
  }
3322
2341
  }
3323
2342
  };
3324
-
3325
- ParseObjectSubclass.className = adjustedClassName;
3326
- ParseObjectSubclass.__super__ = parentProto;
3327
- ParseObjectSubclass.prototype = (0, _create.default)(parentProto, {
3328
- constructor: {
3329
- value: ParseObjectSubclass,
3330
- enumerable: false,
3331
- writable: true,
3332
- configurable: true
3333
- }
3334
- });
3335
-
2343
+ if (classMap[adjustedClassName]) {
2344
+ ParseObjectSubclass = classMap[adjustedClassName];
2345
+ } else {
2346
+ ParseObjectSubclass.extend = function (name, protoProps, classProps) {
2347
+ if (typeof name === 'string') {
2348
+ return ParseObject.extend.call(ParseObjectSubclass, name, protoProps, classProps);
2349
+ }
2350
+ return ParseObject.extend.call(ParseObjectSubclass, adjustedClassName, name, protoProps);
2351
+ };
2352
+ ParseObjectSubclass.createWithoutData = ParseObject.createWithoutData;
2353
+ ParseObjectSubclass.className = adjustedClassName;
2354
+ ParseObjectSubclass.__super__ = parentProto;
2355
+ ParseObjectSubclass.prototype = (0, _create.default)(parentProto, {
2356
+ constructor: {
2357
+ value: ParseObjectSubclass,
2358
+ enumerable: false,
2359
+ writable: true,
2360
+ configurable: true
2361
+ }
2362
+ });
2363
+ }
3336
2364
  if (protoProps) {
3337
2365
  for (var prop in protoProps) {
2366
+ if (prop === 'initialize') {
2367
+ var _context9;
2368
+ (0, _defineProperty3.default)(ParseObjectSubclass.prototype, '_initializers', {
2369
+ value: (0, _concat.default)(_context9 = []).call(_context9, (0, _toConsumableArray2.default)(ParseObjectSubclass.prototype._initializers || []), [protoProps[prop]]),
2370
+ enumerable: false,
2371
+ writable: true,
2372
+ configurable: true
2373
+ });
2374
+ continue;
2375
+ }
3338
2376
  if (prop !== 'className') {
3339
- (0, _defineProperty2.default)(ParseObjectSubclass.prototype, prop, {
2377
+ (0, _defineProperty3.default)(ParseObjectSubclass.prototype, prop, {
3340
2378
  value: protoProps[prop],
3341
2379
  enumerable: false,
3342
2380
  writable: true,
@@ -3345,11 +2383,10 @@ var ParseObject = /*#__PURE__*/function () {
3345
2383
  }
3346
2384
  }
3347
2385
  }
3348
-
3349
2386
  if (classProps) {
3350
2387
  for (var _prop in classProps) {
3351
2388
  if (_prop !== 'className') {
3352
- (0, _defineProperty2.default)(ParseObjectSubclass, _prop, {
2389
+ (0, _defineProperty3.default)(ParseObjectSubclass, _prop, {
3353
2390
  value: classProps[_prop],
3354
2391
  enumerable: false,
3355
2392
  writable: true,
@@ -3358,19 +2395,10 @@ var ParseObject = /*#__PURE__*/function () {
3358
2395
  }
3359
2396
  }
3360
2397
  }
3361
-
3362
- ParseObjectSubclass.extend = function (name, protoProps, classProps) {
3363
- if (typeof name === 'string') {
3364
- return ParseObject.extend.call(ParseObjectSubclass, name, protoProps, classProps);
3365
- }
3366
-
3367
- return ParseObject.extend.call(ParseObjectSubclass, adjustedClassName, name, protoProps);
3368
- };
3369
-
3370
- ParseObjectSubclass.createWithoutData = ParseObject.createWithoutData;
3371
2398
  classMap[adjustedClassName] = ParseObjectSubclass;
3372
2399
  return ParseObjectSubclass;
3373
2400
  }
2401
+
3374
2402
  /**
3375
2403
  * Enable single instance objects, where any local objects with the same Id
3376
2404
  * share the same attributes, and stay synchronized with each other.
@@ -3379,14 +2407,13 @@ var ParseObject = /*#__PURE__*/function () {
3379
2407
  *
3380
2408
  * @static
3381
2409
  */
3382
-
3383
2410
  }, {
3384
2411
  key: "enableSingleInstance",
3385
- value: function enableSingleInstance() {
2412
+ value: function () {
3386
2413
  singleInstance = true;
3387
-
3388
2414
  _CoreManager.default.setObjectStateController(SingleInstanceStateController);
3389
2415
  }
2416
+
3390
2417
  /**
3391
2418
  * Disable single instance objects, where any local objects with the same Id
3392
2419
  * share the same attributes, and stay synchronized with each other.
@@ -3395,14 +2422,13 @@ var ParseObject = /*#__PURE__*/function () {
3395
2422
  *
3396
2423
  * @static
3397
2424
  */
3398
-
3399
2425
  }, {
3400
2426
  key: "disableSingleInstance",
3401
- value: function disableSingleInstance() {
2427
+ value: function () {
3402
2428
  singleInstance = false;
3403
-
3404
2429
  _CoreManager.default.setObjectStateController(UniqueInstanceStateController);
3405
2430
  }
2431
+
3406
2432
  /**
3407
2433
  * Asynchronously stores the objects and every object they point to in the local datastore,
3408
2434
  * recursively, using a default pin name: _default.
@@ -3421,22 +2447,16 @@ var ParseObject = /*#__PURE__*/function () {
3421
2447
  * @returns {Promise} A promise that is fulfilled when the pin completes.
3422
2448
  * @static
3423
2449
  */
3424
-
3425
2450
  }, {
3426
2451
  key: "pinAll",
3427
- value: function pinAll(objects
3428
- /*: Array<ParseObject>*/
3429
- )
3430
- /*: Promise<void>*/
3431
- {
2452
+ value: function (objects /*: Array<ParseObject>*/) /*: Promise<void>*/{
3432
2453
  var localDatastore = _CoreManager.default.getLocalDatastore();
3433
-
3434
2454
  if (!localDatastore.isEnabled) {
3435
2455
  return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
3436
2456
  }
3437
-
3438
2457
  return ParseObject.pinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, objects);
3439
2458
  }
2459
+
3440
2460
  /**
3441
2461
  * Asynchronously stores the objects and every object they point to in the local datastore, recursively.
3442
2462
  *
@@ -3455,24 +2475,16 @@ var ParseObject = /*#__PURE__*/function () {
3455
2475
  * @returns {Promise} A promise that is fulfilled when the pin completes.
3456
2476
  * @static
3457
2477
  */
3458
-
3459
2478
  }, {
3460
2479
  key: "pinAllWithName",
3461
- value: function pinAllWithName(name
3462
- /*: string*/
3463
- , objects
3464
- /*: Array<ParseObject>*/
3465
- )
3466
- /*: Promise<void>*/
3467
- {
2480
+ value: function (name /*: string*/, objects /*: Array<ParseObject>*/) /*: Promise<void>*/{
3468
2481
  var localDatastore = _CoreManager.default.getLocalDatastore();
3469
-
3470
2482
  if (!localDatastore.isEnabled) {
3471
2483
  return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
3472
2484
  }
3473
-
3474
2485
  return localDatastore._handlePinAllWithName(name, objects);
3475
2486
  }
2487
+
3476
2488
  /**
3477
2489
  * Asynchronously removes the objects and every object they point to in the local datastore,
3478
2490
  * recursively, using a default pin name: _default.
@@ -3485,22 +2497,16 @@ var ParseObject = /*#__PURE__*/function () {
3485
2497
  * @returns {Promise} A promise that is fulfilled when the unPin completes.
3486
2498
  * @static
3487
2499
  */
3488
-
3489
2500
  }, {
3490
2501
  key: "unPinAll",
3491
- value: function unPinAll(objects
3492
- /*: Array<ParseObject>*/
3493
- )
3494
- /*: Promise<void>*/
3495
- {
2502
+ value: function (objects /*: Array<ParseObject>*/) /*: Promise<void>*/{
3496
2503
  var localDatastore = _CoreManager.default.getLocalDatastore();
3497
-
3498
2504
  if (!localDatastore.isEnabled) {
3499
2505
  return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
3500
2506
  }
3501
-
3502
2507
  return ParseObject.unPinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, objects);
3503
2508
  }
2509
+
3504
2510
  /**
3505
2511
  * Asynchronously removes the objects and every object they point to in the local datastore, recursively.
3506
2512
  *
@@ -3513,24 +2519,16 @@ var ParseObject = /*#__PURE__*/function () {
3513
2519
  * @returns {Promise} A promise that is fulfilled when the unPin completes.
3514
2520
  * @static
3515
2521
  */
3516
-
3517
2522
  }, {
3518
2523
  key: "unPinAllWithName",
3519
- value: function unPinAllWithName(name
3520
- /*: string*/
3521
- , objects
3522
- /*: Array<ParseObject>*/
3523
- )
3524
- /*: Promise<void>*/
3525
- {
2524
+ value: function (name /*: string*/, objects /*: Array<ParseObject>*/) /*: Promise<void>*/{
3526
2525
  var localDatastore = _CoreManager.default.getLocalDatastore();
3527
-
3528
2526
  if (!localDatastore.isEnabled) {
3529
2527
  return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
3530
2528
  }
3531
-
3532
2529
  return localDatastore._handleUnPinAllWithName(name, objects);
3533
2530
  }
2531
+
3534
2532
  /**
3535
2533
  * Asynchronously removes all objects in the local datastore using a default pin name: _default.
3536
2534
  *
@@ -3541,20 +2539,16 @@ var ParseObject = /*#__PURE__*/function () {
3541
2539
  * @returns {Promise} A promise that is fulfilled when the unPin completes.
3542
2540
  * @static
3543
2541
  */
3544
-
3545
2542
  }, {
3546
2543
  key: "unPinAllObjects",
3547
- value: function unPinAllObjects()
3548
- /*: Promise<void>*/
3549
- {
2544
+ value: function () /*: Promise<void>*/{
3550
2545
  var localDatastore = _CoreManager.default.getLocalDatastore();
3551
-
3552
2546
  if (!localDatastore.isEnabled) {
3553
2547
  return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
3554
2548
  }
3555
-
3556
2549
  return localDatastore.unPinWithName(_LocalDatastoreUtils.DEFAULT_PIN);
3557
2550
  }
2551
+
3558
2552
  /**
3559
2553
  * Asynchronously removes all objects with the specified pin name.
3560
2554
  * Deletes the pin name also.
@@ -3567,43 +2561,25 @@ var ParseObject = /*#__PURE__*/function () {
3567
2561
  * @returns {Promise} A promise that is fulfilled when the unPin completes.
3568
2562
  * @static
3569
2563
  */
3570
-
3571
2564
  }, {
3572
2565
  key: "unPinAllObjectsWithName",
3573
- value: function unPinAllObjectsWithName(name
3574
- /*: string*/
3575
- )
3576
- /*: Promise<void>*/
3577
- {
2566
+ value: function (name /*: string*/) /*: Promise<void>*/{
3578
2567
  var localDatastore = _CoreManager.default.getLocalDatastore();
3579
-
3580
2568
  if (!localDatastore.isEnabled) {
3581
2569
  return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
3582
2570
  }
3583
-
3584
2571
  return localDatastore.unPinWithName(_LocalDatastoreUtils.PIN_PREFIX + name);
3585
2572
  }
3586
2573
  }]);
3587
2574
  return ParseObject;
3588
2575
  }();
3589
-
3590
2576
  var DefaultController = {
3591
- fetch: function fetch(target
3592
- /*: ParseObject | Array<ParseObject>*/
3593
- , forceFetch
3594
- /*: boolean*/
3595
- , options
3596
- /*: RequestOptions*/
3597
- )
3598
- /*: Promise<Array<void> | ParseObject>*/
3599
- {
2577
+ fetch: function (target /*: ParseObject | Array<ParseObject>*/, forceFetch /*: boolean*/, options /*: RequestOptions*/) /*: Promise<Array<void> | ParseObject>*/{
3600
2578
  var localDatastore = _CoreManager.default.getLocalDatastore();
3601
-
3602
2579
  if ((0, _isArray.default)(target)) {
3603
2580
  if (target.length < 1) {
3604
2581
  return _promise.default.resolve([]);
3605
2582
  }
3606
-
3607
2583
  var objs = [];
3608
2584
  var ids = [];
3609
2585
  var className = null;
@@ -3613,142 +2589,94 @@ var DefaultController = {
3613
2589
  if (error) {
3614
2590
  return;
3615
2591
  }
3616
-
3617
2592
  if (!className) {
3618
2593
  className = el.className;
3619
2594
  }
3620
-
3621
2595
  if (className !== el.className) {
3622
2596
  error = new _ParseError.default(_ParseError.default.INVALID_CLASS_NAME, 'All objects should be of the same class');
3623
2597
  }
3624
-
3625
2598
  if (!el.id) {
3626
2599
  error = new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'All objects must have an ID');
3627
2600
  }
3628
-
3629
2601
  if (forceFetch || !el.isDataAvailable()) {
3630
2602
  ids.push(el.id);
3631
2603
  objs.push(el);
3632
2604
  }
3633
-
3634
2605
  results.push(el);
3635
2606
  });
3636
-
3637
2607
  if (error) {
3638
2608
  return _promise.default.reject(error);
3639
2609
  }
3640
-
3641
2610
  var query = new _ParseQuery.default(className);
3642
2611
  query.containedIn('objectId', ids);
3643
-
3644
2612
  if (options && options.include) {
3645
2613
  query.include(options.include);
3646
2614
  }
3647
-
3648
2615
  query._limit = ids.length;
3649
2616
  return (0, _find.default)(query).call(query, options).then( /*#__PURE__*/function () {
3650
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(objects) {
3651
- var idMap, i, obj, _i, _obj, id, _iterator2, _step2, object;
3652
-
3653
- return _regeneratorRuntime().wrap(function _callee6$(_context9) {
3654
- while (1) {
3655
- switch (_context9.prev = _context9.next) {
3656
- case 0:
3657
- idMap = {};
3658
- (0, _forEach.default)(objects).call(objects, function (o) {
3659
- idMap[o.id] = o;
3660
- });
3661
- i = 0;
3662
-
3663
- case 3:
3664
- if (!(i < objs.length)) {
3665
- _context9.next = 11;
3666
- break;
3667
- }
3668
-
3669
- obj = objs[i];
3670
-
3671
- if (!(!obj || !obj.id || !idMap[obj.id])) {
3672
- _context9.next = 8;
3673
- break;
3674
- }
3675
-
3676
- if (!forceFetch) {
3677
- _context9.next = 8;
3678
- break;
3679
- }
3680
-
3681
- return _context9.abrupt("return", _promise.default.reject(new _ParseError.default(_ParseError.default.OBJECT_NOT_FOUND, 'All objects must exist on the server.')));
3682
-
3683
- case 8:
3684
- i++;
3685
- _context9.next = 3;
2617
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(objects) {
2618
+ var idMap, i, obj, _i, _obj, id, _i2, _results, object;
2619
+ return _regenerator.default.wrap(function (_context10) {
2620
+ while (1) switch (_context10.prev = _context10.next) {
2621
+ case 0:
2622
+ idMap = {};
2623
+ (0, _forEach.default)(objects).call(objects, function (o) {
2624
+ idMap[o.id] = o;
2625
+ });
2626
+ i = 0;
2627
+ case 3:
2628
+ if (!(i < objs.length)) {
2629
+ _context10.next = 11;
3686
2630
  break;
3687
-
3688
- case 11:
3689
- if (!singleInstance) {
3690
- // If single instance objects are disabled, we need to replace the
3691
- for (_i = 0; _i < results.length; _i++) {
3692
- _obj = results[_i];
3693
-
3694
- if (_obj && _obj.id && idMap[_obj.id]) {
3695
- id = _obj.id;
3696
-
3697
- _obj._finishFetch(idMap[id].toJSON());
3698
-
3699
- results[_i] = idMap[id];
3700
- }
2631
+ }
2632
+ obj = objs[i];
2633
+ if (!(!obj || !obj.id || !idMap[obj.id])) {
2634
+ _context10.next = 8;
2635
+ break;
2636
+ }
2637
+ if (!forceFetch) {
2638
+ _context10.next = 8;
2639
+ break;
2640
+ }
2641
+ return _context10.abrupt("return", _promise.default.reject(new _ParseError.default(_ParseError.default.OBJECT_NOT_FOUND, 'All objects must exist on the server.')));
2642
+ case 8:
2643
+ i++;
2644
+ _context10.next = 3;
2645
+ break;
2646
+ case 11:
2647
+ if (!singleInstance) {
2648
+ // If single instance objects are disabled, we need to replace the
2649
+ for (_i = 0; _i < results.length; _i++) {
2650
+ _obj = results[_i];
2651
+ if (_obj && _obj.id && idMap[_obj.id]) {
2652
+ id = _obj.id;
2653
+ _obj._finishFetch(idMap[id].toJSON());
2654
+ results[_i] = idMap[id];
3701
2655
  }
3702
2656
  }
3703
-
3704
- _iterator2 = _createForOfIteratorHelper(results);
3705
- _context9.prev = 13;
3706
-
3707
- _iterator2.s();
3708
-
3709
- case 15:
3710
- if ((_step2 = _iterator2.n()).done) {
3711
- _context9.next = 21;
3712
- break;
3713
- }
3714
-
3715
- object = _step2.value;
3716
- _context9.next = 19;
3717
- return localDatastore._updateObjectIfPinned(object);
3718
-
3719
- case 19:
3720
- _context9.next = 15;
3721
- break;
3722
-
3723
- case 21:
3724
- _context9.next = 26;
2657
+ }
2658
+ _i2 = 0, _results = results;
2659
+ case 13:
2660
+ if (!(_i2 < _results.length)) {
2661
+ _context10.next = 20;
3725
2662
  break;
3726
-
3727
- case 23:
3728
- _context9.prev = 23;
3729
- _context9.t0 = _context9["catch"](13);
3730
-
3731
- _iterator2.e(_context9.t0);
3732
-
3733
- case 26:
3734
- _context9.prev = 26;
3735
-
3736
- _iterator2.f();
3737
-
3738
- return _context9.finish(26);
3739
-
3740
- case 29:
3741
- return _context9.abrupt("return", _promise.default.resolve(results));
3742
-
3743
- case 30:
3744
- case "end":
3745
- return _context9.stop();
3746
- }
2663
+ }
2664
+ object = _results[_i2];
2665
+ _context10.next = 17;
2666
+ return localDatastore._updateObjectIfPinned(object);
2667
+ case 17:
2668
+ _i2++;
2669
+ _context10.next = 13;
2670
+ break;
2671
+ case 20:
2672
+ return _context10.abrupt("return", _promise.default.resolve(results));
2673
+ case 21:
2674
+ case "end":
2675
+ return _context10.stop();
3747
2676
  }
3748
- }, _callee6, null, [[13, 23, 26, 29]]);
2677
+ }, _callee6);
3749
2678
  }));
3750
-
3751
- return function (_x4) {
2679
+ return function () {
3752
2680
  return _ref.apply(this, arguments);
3753
2681
  };
3754
2682
  }());
@@ -3756,260 +2684,188 @@ var DefaultController = {
3756
2684
  if (!target.id) {
3757
2685
  return _promise.default.reject(new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'Object does not have an ID'));
3758
2686
  }
3759
-
3760
2687
  var RESTController = _CoreManager.default.getRESTController();
3761
-
3762
2688
  var params = {};
3763
-
3764
2689
  if (options && options.include) {
3765
2690
  params.include = options.include.join();
3766
2691
  }
3767
-
3768
2692
  return RESTController.request('GET', 'classes/' + target.className + '/' + target._getId(), params, options).then( /*#__PURE__*/function () {
3769
- var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(response) {
3770
- return _regeneratorRuntime().wrap(function _callee7$(_context10) {
3771
- while (1) {
3772
- switch (_context10.prev = _context10.next) {
3773
- case 0:
3774
- target._clearPendingOps();
3775
-
3776
- target._clearServerData();
3777
-
3778
- target._finishFetch(response);
3779
-
3780
- _context10.next = 5;
3781
- return localDatastore._updateObjectIfPinned(target);
3782
-
3783
- case 5:
3784
- return _context10.abrupt("return", target);
3785
-
3786
- case 6:
3787
- case "end":
3788
- return _context10.stop();
3789
- }
2693
+ var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(response) {
2694
+ return _regenerator.default.wrap(function (_context11) {
2695
+ while (1) switch (_context11.prev = _context11.next) {
2696
+ case 0:
2697
+ target._clearPendingOps();
2698
+ target._clearServerData();
2699
+ target._finishFetch(response);
2700
+ _context11.next = 5;
2701
+ return localDatastore._updateObjectIfPinned(target);
2702
+ case 5:
2703
+ return _context11.abrupt("return", target);
2704
+ case 6:
2705
+ case "end":
2706
+ return _context11.stop();
3790
2707
  }
3791
2708
  }, _callee7);
3792
2709
  }));
3793
-
3794
- return function (_x5) {
2710
+ return function () {
3795
2711
  return _ref2.apply(this, arguments);
3796
2712
  };
3797
2713
  }());
3798
2714
  }
3799
-
3800
2715
  return _promise.default.resolve();
3801
2716
  },
3802
- destroy: function destroy(target
3803
- /*: ParseObject | Array<ParseObject>*/
3804
- , options
3805
- /*: RequestOptions*/
3806
- )
3807
- /*: Promise<Array<void> | ParseObject>*/
3808
- {
3809
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
2717
+ destroy: function (target /*: ParseObject | Array<ParseObject>*/, options /*: RequestOptions*/) /*: Promise<Array<void> | ParseObject>*/{
2718
+ return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
3810
2719
  var batchSize, localDatastore, RESTController, batches, deleteCompleted, errors;
3811
- return _regeneratorRuntime().wrap(function _callee10$(_context13) {
3812
- while (1) {
3813
- switch (_context13.prev = _context13.next) {
3814
- case 0:
3815
- batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
3816
- localDatastore = _CoreManager.default.getLocalDatastore();
3817
- RESTController = _CoreManager.default.getRESTController();
3818
-
3819
- if (!(0, _isArray.default)(target)) {
3820
- _context13.next = 15;
3821
- break;
3822
- }
3823
-
3824
- if (!(target.length < 1)) {
3825
- _context13.next = 6;
3826
- break;
2720
+ return _regenerator.default.wrap(function (_context14) {
2721
+ while (1) switch (_context14.prev = _context14.next) {
2722
+ case 0:
2723
+ batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
2724
+ localDatastore = _CoreManager.default.getLocalDatastore();
2725
+ RESTController = _CoreManager.default.getRESTController();
2726
+ if (!(0, _isArray.default)(target)) {
2727
+ _context14.next = 15;
2728
+ break;
2729
+ }
2730
+ if (!(target.length < 1)) {
2731
+ _context14.next = 6;
2732
+ break;
2733
+ }
2734
+ return _context14.abrupt("return", _promise.default.resolve([]));
2735
+ case 6:
2736
+ batches = [[]];
2737
+ (0, _forEach.default)(target).call(target, function (obj) {
2738
+ if (!obj.id) {
2739
+ return;
3827
2740
  }
3828
-
3829
- return _context13.abrupt("return", _promise.default.resolve([]));
3830
-
3831
- case 6:
3832
- batches = [[]];
3833
- (0, _forEach.default)(target).call(target, function (obj) {
3834
- if (!obj.id) {
3835
- return;
3836
- }
3837
-
3838
- batches[batches.length - 1].push(obj);
3839
-
3840
- if (batches[batches.length - 1].length >= batchSize) {
3841
- batches.push([]);
3842
- }
3843
- });
3844
-
3845
- if (batches[batches.length - 1].length === 0) {
3846
- // If the last batch is empty, remove it
3847
- batches.pop();
2741
+ batches[batches.length - 1].push(obj);
2742
+ if (batches[batches.length - 1].length >= batchSize) {
2743
+ batches.push([]);
3848
2744
  }
3849
-
3850
- deleteCompleted = _promise.default.resolve();
3851
- errors = [];
3852
- (0, _forEach.default)(batches).call(batches, function (batch) {
3853
- deleteCompleted = deleteCompleted.then(function () {
3854
- return RESTController.request('POST', 'batch', {
3855
- requests: (0, _map.default)(batch).call(batch, function (obj) {
3856
- return {
3857
- method: 'DELETE',
3858
- path: getServerUrlPath() + 'classes/' + obj.className + '/' + obj._getId(),
3859
- body: {}
3860
- };
3861
- })
3862
- }, options).then(function (results) {
3863
- for (var i = 0; i < results.length; i++) {
3864
- if (results[i] && results[i].hasOwnProperty('error')) {
3865
- var err = new _ParseError.default(results[i].error.code, results[i].error.error);
3866
- err.object = batch[i];
3867
- errors.push(err);
3868
- }
2745
+ });
2746
+ if (batches[batches.length - 1].length === 0) {
2747
+ // If the last batch is empty, remove it
2748
+ batches.pop();
2749
+ }
2750
+ deleteCompleted = _promise.default.resolve();
2751
+ errors = [];
2752
+ (0, _forEach.default)(batches).call(batches, function (batch) {
2753
+ deleteCompleted = deleteCompleted.then(function () {
2754
+ return RESTController.request('POST', 'batch', {
2755
+ requests: (0, _map.default)(batch).call(batch, function (obj) {
2756
+ return {
2757
+ method: 'DELETE',
2758
+ path: getServerUrlPath() + 'classes/' + obj.className + '/' + obj._getId(),
2759
+ body: {}
2760
+ };
2761
+ })
2762
+ }, options).then(function (results) {
2763
+ for (var i = 0; i < results.length; i++) {
2764
+ if (results[i] && results[i].hasOwnProperty('error')) {
2765
+ var err = new _ParseError.default(results[i].error.code, results[i].error.error);
2766
+ err.object = batch[i];
2767
+ errors.push(err);
3869
2768
  }
3870
- });
2769
+ }
3871
2770
  });
3872
2771
  });
3873
- return _context13.abrupt("return", deleteCompleted.then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
3874
- var aggregate, _iterator3, _step3, object;
3875
-
3876
- return _regeneratorRuntime().wrap(function _callee8$(_context11) {
3877
- while (1) {
3878
- switch (_context11.prev = _context11.next) {
3879
- case 0:
3880
- if (!errors.length) {
3881
- _context11.next = 4;
3882
- break;
3883
- }
3884
-
3885
- aggregate = new _ParseError.default(_ParseError.default.AGGREGATE_ERROR);
3886
- aggregate.errors = errors;
3887
- return _context11.abrupt("return", _promise.default.reject(aggregate));
3888
-
3889
- case 4:
3890
- _iterator3 = _createForOfIteratorHelper(target);
3891
- _context11.prev = 5;
3892
-
3893
- _iterator3.s();
3894
-
3895
- case 7:
3896
- if ((_step3 = _iterator3.n()).done) {
3897
- _context11.next = 13;
3898
- break;
3899
- }
3900
-
3901
- object = _step3.value;
3902
- _context11.next = 11;
3903
- return localDatastore._destroyObjectIfPinned(object);
3904
-
3905
- case 11:
3906
- _context11.next = 7;
3907
- break;
3908
-
3909
- case 13:
3910
- _context11.next = 18;
3911
- break;
3912
-
3913
- case 15:
3914
- _context11.prev = 15;
3915
- _context11.t0 = _context11["catch"](5);
3916
-
3917
- _iterator3.e(_context11.t0);
3918
-
3919
- case 18:
3920
- _context11.prev = 18;
3921
-
3922
- _iterator3.f();
3923
-
3924
- return _context11.finish(18);
3925
-
3926
- case 21:
3927
- return _context11.abrupt("return", _promise.default.resolve(target));
3928
-
3929
- case 22:
3930
- case "end":
3931
- return _context11.stop();
2772
+ });
2773
+ return _context14.abrupt("return", deleteCompleted.then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
2774
+ var aggregate, _iterator3, _step3, object;
2775
+ return _regenerator.default.wrap(function (_context12) {
2776
+ while (1) switch (_context12.prev = _context12.next) {
2777
+ case 0:
2778
+ if (!errors.length) {
2779
+ _context12.next = 4;
2780
+ break;
3932
2781
  }
3933
- }
3934
- }, _callee8, null, [[5, 15, 18, 21]]);
3935
- }))));
3936
-
3937
- case 15:
3938
- if (!(target instanceof ParseObject)) {
3939
- _context13.next = 17;
3940
- break;
3941
- }
3942
-
3943
- return _context13.abrupt("return", RESTController.request('DELETE', 'classes/' + target.className + '/' + target._getId(), {}, options).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
3944
- return _regeneratorRuntime().wrap(function _callee9$(_context12) {
3945
- while (1) {
3946
- switch (_context12.prev = _context12.next) {
3947
- case 0:
3948
- _context12.next = 2;
3949
- return localDatastore._destroyObjectIfPinned(target);
3950
-
3951
- case 2:
3952
- return _context12.abrupt("return", _promise.default.resolve(target));
3953
-
3954
- case 3:
3955
- case "end":
3956
- return _context12.stop();
2782
+ aggregate = new _ParseError.default(_ParseError.default.AGGREGATE_ERROR);
2783
+ aggregate.errors = errors;
2784
+ return _context12.abrupt("return", _promise.default.reject(aggregate));
2785
+ case 4:
2786
+ _iterator3 = _createForOfIteratorHelper(target);
2787
+ _context12.prev = 5;
2788
+ _iterator3.s();
2789
+ case 7:
2790
+ if ((_step3 = _iterator3.n()).done) {
2791
+ _context12.next = 13;
2792
+ break;
3957
2793
  }
3958
- }
3959
- }, _callee9);
3960
- }))));
3961
-
3962
- case 17:
3963
- return _context13.abrupt("return", _promise.default.resolve(target));
3964
-
3965
- case 18:
3966
- case "end":
3967
- return _context13.stop();
3968
- }
2794
+ object = _step3.value;
2795
+ _context12.next = 11;
2796
+ return localDatastore._destroyObjectIfPinned(object);
2797
+ case 11:
2798
+ _context12.next = 7;
2799
+ break;
2800
+ case 13:
2801
+ _context12.next = 18;
2802
+ break;
2803
+ case 15:
2804
+ _context12.prev = 15;
2805
+ _context12.t0 = _context12["catch"](5);
2806
+ _iterator3.e(_context12.t0);
2807
+ case 18:
2808
+ _context12.prev = 18;
2809
+ _iterator3.f();
2810
+ return _context12.finish(18);
2811
+ case 21:
2812
+ return _context12.abrupt("return", _promise.default.resolve(target));
2813
+ case 22:
2814
+ case "end":
2815
+ return _context12.stop();
2816
+ }
2817
+ }, _callee8, null, [[5, 15, 18, 21]]);
2818
+ }))));
2819
+ case 15:
2820
+ if (!(target instanceof ParseObject)) {
2821
+ _context14.next = 17;
2822
+ break;
2823
+ }
2824
+ return _context14.abrupt("return", RESTController.request('DELETE', 'classes/' + target.className + '/' + target._getId(), {}, options).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
2825
+ return _regenerator.default.wrap(function (_context13) {
2826
+ while (1) switch (_context13.prev = _context13.next) {
2827
+ case 0:
2828
+ _context13.next = 2;
2829
+ return localDatastore._destroyObjectIfPinned(target);
2830
+ case 2:
2831
+ return _context13.abrupt("return", _promise.default.resolve(target));
2832
+ case 3:
2833
+ case "end":
2834
+ return _context13.stop();
2835
+ }
2836
+ }, _callee9);
2837
+ }))));
2838
+ case 17:
2839
+ return _context14.abrupt("return", _promise.default.resolve(target));
2840
+ case 18:
2841
+ case "end":
2842
+ return _context14.stop();
3969
2843
  }
3970
2844
  }, _callee10);
3971
2845
  }))();
3972
2846
  },
3973
- save: function save(target
3974
- /*: ParseObject | Array<ParseObject | ParseFile>*/
3975
- , options
3976
- /*: RequestOptions*/
3977
- ) {
2847
+ save: function (target /*: ParseObject | Array<ParseObject | ParseFile>*/, options /*: RequestOptions*/) {
3978
2848
  var batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
3979
-
3980
2849
  var localDatastore = _CoreManager.default.getLocalDatastore();
3981
-
3982
2850
  var mapIdForPin = {};
3983
-
3984
2851
  var RESTController = _CoreManager.default.getRESTController();
3985
-
3986
2852
  var stateController = _CoreManager.default.getObjectStateController();
3987
-
3988
2853
  var allowCustomObjectId = _CoreManager.default.get('ALLOW_CUSTOM_OBJECT_ID');
3989
-
3990
2854
  options = options || {};
3991
2855
  options.returnStatus = options.returnStatus || true;
3992
-
3993
2856
  if ((0, _isArray.default)(target)) {
3994
2857
  if (target.length < 1) {
3995
2858
  return _promise.default.resolve([]);
3996
2859
  }
3997
-
3998
2860
  var unsaved = (0, _concat.default)(target).call(target);
3999
-
4000
2861
  for (var i = 0; i < target.length; i++) {
4001
2862
  if (target[i] instanceof ParseObject) {
4002
2863
  unsaved = (0, _concat.default)(unsaved).call(unsaved, (0, _unsavedChildren.default)(target[i], true));
4003
2864
  }
4004
2865
  }
4005
-
4006
2866
  unsaved = (0, _unique.default)(unsaved);
4007
- var filesSaved
4008
- /*: Array<ParseFile>*/
4009
- = [];
4010
- var pending
4011
- /*: Array<ParseObject>*/
4012
- = [];
2867
+ var filesSaved /*: Array<ParseFile>*/ = [];
2868
+ var pending /*: Array<ParseObject>*/ = [];
4013
2869
  (0, _forEach.default)(unsaved).call(unsaved, function (el) {
4014
2870
  if (el instanceof _ParseFile.default) {
4015
2871
  filesSaved.push(el.save(options));
@@ -4028,7 +2884,6 @@ var DefaultController = {
4028
2884
  if (allowCustomObjectId && Object.prototype.hasOwnProperty.call(el, 'id') && !el.id) {
4029
2885
  throw new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'objectId must not be empty or null');
4030
2886
  }
4031
-
4032
2887
  if (batch.length < batchSize && (0, _canBeSerialized.default)(el)) {
4033
2888
  batch.push(el);
4034
2889
  } else {
@@ -4036,20 +2891,18 @@ var DefaultController = {
4036
2891
  }
4037
2892
  });
4038
2893
  pending = nextPending;
4039
-
4040
2894
  if (batch.length < 1) {
4041
2895
  return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Tried to save a batch with a cycle.'));
4042
- } // Queue up tasks for each object in the batch.
4043
- // When every task is ready, the API request will execute
4044
-
2896
+ }
4045
2897
 
2898
+ // Queue up tasks for each object in the batch.
2899
+ // When every task is ready, the API request will execute
4046
2900
  var batchReturned = new _promiseUtils.resolvingPromise();
4047
2901
  var batchReady = [];
4048
2902
  var batchTasks = [];
4049
2903
  (0, _forEach.default)(batch).call(batch, function (obj, index) {
4050
2904
  var ready = new _promiseUtils.resolvingPromise();
4051
2905
  batchReady.push(ready);
4052
-
4053
2906
  var task = function task() {
4054
2907
  ready.resolve();
4055
2908
  return batchReturned.then(function (responses) {
@@ -4058,21 +2911,18 @@ var DefaultController = {
4058
2911
  var status = responses[index]._status;
4059
2912
  delete responses[index]._status;
4060
2913
  mapIdForPin[objectId] = obj._localId;
4061
-
4062
2914
  obj._handleSaveResponse(responses[index].success, status);
4063
2915
  } else {
4064
2916
  if (!objectError && responses[index].hasOwnProperty('error')) {
4065
2917
  var serverError = responses[index].error;
4066
- objectError = new _ParseError.default(serverError.code, serverError.error); // Cancel the rest of the save
4067
-
2918
+ objectError = new _ParseError.default(serverError.code, serverError.error);
2919
+ // Cancel the rest of the save
4068
2920
  pending = [];
4069
2921
  }
4070
-
4071
2922
  obj._handleSaveError();
4072
2923
  }
4073
2924
  });
4074
2925
  };
4075
-
4076
2926
  stateController.pushPendingState(obj._getStateIdentifier());
4077
2927
  batchTasks.push(stateController.enqueueTask(obj._getStateIdentifier(), task));
4078
2928
  });
@@ -4081,7 +2931,6 @@ var DefaultController = {
4081
2931
  return RESTController.request('POST', 'batch', {
4082
2932
  requests: (0, _map.default)(batch).call(batch, function (obj) {
4083
2933
  var params = obj._getSaveParams();
4084
-
4085
2934
  params.path = getServerUrlPath() + params.path;
4086
2935
  return params;
4087
2936
  })
@@ -4090,131 +2939,102 @@ var DefaultController = {
4090
2939
  batchReturned.reject(new _ParseError.default(_ParseError.default.INCORRECT_TYPE, error.message));
4091
2940
  });
4092
2941
  return (0, _promiseUtils.when)(batchTasks);
4093
- }).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
2942
+ }).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
4094
2943
  var _iterator4, _step4, object;
4095
-
4096
- return _regeneratorRuntime().wrap(function _callee11$(_context14) {
4097
- while (1) {
4098
- switch (_context14.prev = _context14.next) {
4099
- case 0:
4100
- if (!objectError) {
4101
- _context14.next = 2;
4102
- break;
4103
- }
4104
-
4105
- return _context14.abrupt("return", _promise.default.reject(objectError));
4106
-
4107
- case 2:
4108
- _iterator4 = _createForOfIteratorHelper(target);
4109
- _context14.prev = 3;
4110
-
4111
- _iterator4.s();
4112
-
4113
- case 5:
4114
- if ((_step4 = _iterator4.n()).done) {
4115
- _context14.next = 13;
4116
- break;
4117
- }
4118
-
4119
- object = _step4.value;
4120
- _context14.next = 9;
4121
- return localDatastore._updateLocalIdForObject(mapIdForPin[object.id], object);
4122
-
4123
- case 9:
4124
- _context14.next = 11;
4125
- return localDatastore._updateObjectIfPinned(object);
4126
-
4127
- case 11:
4128
- _context14.next = 5;
2944
+ return _regenerator.default.wrap(function _callee11$(_context15) {
2945
+ while (1) switch (_context15.prev = _context15.next) {
2946
+ case 0:
2947
+ if (!objectError) {
2948
+ _context15.next = 2;
4129
2949
  break;
4130
-
4131
- case 13:
4132
- _context14.next = 18;
2950
+ }
2951
+ return _context15.abrupt("return", _promise.default.reject(objectError));
2952
+ case 2:
2953
+ _iterator4 = _createForOfIteratorHelper(target);
2954
+ _context15.prev = 3;
2955
+ _iterator4.s();
2956
+ case 5:
2957
+ if ((_step4 = _iterator4.n()).done) {
2958
+ _context15.next = 14;
4133
2959
  break;
4134
-
4135
- case 15:
4136
- _context14.prev = 15;
4137
- _context14.t0 = _context14["catch"](3);
4138
-
4139
- _iterator4.e(_context14.t0);
4140
-
4141
- case 18:
4142
- _context14.prev = 18;
4143
-
4144
- _iterator4.f();
4145
-
4146
- return _context14.finish(18);
4147
-
4148
- case 21:
4149
- return _context14.abrupt("return", _promise.default.resolve(target));
4150
-
4151
- case 22:
4152
- case "end":
4153
- return _context14.stop();
4154
- }
2960
+ }
2961
+ object = _step4.value;
2962
+ if (!(object instanceof ParseObject)) {
2963
+ _context15.next = 12;
2964
+ break;
2965
+ }
2966
+ _context15.next = 10;
2967
+ return localDatastore._updateLocalIdForObject(mapIdForPin[object.id], object);
2968
+ case 10:
2969
+ _context15.next = 12;
2970
+ return localDatastore._updateObjectIfPinned(object);
2971
+ case 12:
2972
+ _context15.next = 5;
2973
+ break;
2974
+ case 14:
2975
+ _context15.next = 19;
2976
+ break;
2977
+ case 16:
2978
+ _context15.prev = 16;
2979
+ _context15.t0 = _context15["catch"](3);
2980
+ _iterator4.e(_context15.t0);
2981
+ case 19:
2982
+ _context15.prev = 19;
2983
+ _iterator4.f();
2984
+ return _context15.finish(19);
2985
+ case 22:
2986
+ return _context15.abrupt("return", _promise.default.resolve(target));
2987
+ case 23:
2988
+ case "end":
2989
+ return _context15.stop();
4155
2990
  }
4156
- }, _callee11, null, [[3, 15, 18, 21]]);
2991
+ }, _callee11, null, [[3, 16, 19, 22]]);
4157
2992
  })));
4158
2993
  });
4159
2994
  } else if (target instanceof ParseObject) {
4160
2995
  if (allowCustomObjectId && Object.prototype.hasOwnProperty.call(target, 'id') && !target.id) {
4161
2996
  throw new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'objectId must not be empty or null');
4162
- } // generate _localId in case if cascadeSave=false
4163
-
4164
-
2997
+ }
2998
+ // generate _localId in case if cascadeSave=false
4165
2999
  target._getId();
4166
-
4167
- var localId = target._localId; // copying target lets Flow guarantee the pointer isn't modified elsewhere
4168
-
3000
+ var localId = target._localId;
3001
+ // copying target lets Flow guarantee the pointer isn't modified elsewhere
4169
3002
  var targetCopy = target;
4170
-
4171
3003
  var task = function task() {
4172
3004
  var params = targetCopy._getSaveParams();
4173
-
4174
3005
  return RESTController.request(params.method, params.path, params.body, options).then(function (response) {
4175
3006
  var status = response._status;
4176
3007
  delete response._status;
4177
-
4178
3008
  targetCopy._handleSaveResponse(response, status);
4179
3009
  }, function (error) {
4180
3010
  targetCopy._handleSaveError();
4181
-
4182
3011
  return _promise.default.reject(error);
4183
3012
  });
4184
3013
  };
4185
-
4186
3014
  stateController.pushPendingState(target._getStateIdentifier());
4187
- return stateController.enqueueTask(target._getStateIdentifier(), task).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
4188
- return _regeneratorRuntime().wrap(function _callee12$(_context15) {
4189
- while (1) {
4190
- switch (_context15.prev = _context15.next) {
4191
- case 0:
4192
- _context15.next = 2;
4193
- return localDatastore._updateLocalIdForObject(localId, target);
4194
-
4195
- case 2:
4196
- _context15.next = 4;
4197
- return localDatastore._updateObjectIfPinned(target);
4198
-
4199
- case 4:
4200
- return _context15.abrupt("return", target);
4201
-
4202
- case 5:
4203
- case "end":
4204
- return _context15.stop();
4205
- }
3015
+ return stateController.enqueueTask(target._getStateIdentifier(), task).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12() {
3016
+ return _regenerator.default.wrap(function _callee12$(_context16) {
3017
+ while (1) switch (_context16.prev = _context16.next) {
3018
+ case 0:
3019
+ _context16.next = 2;
3020
+ return localDatastore._updateLocalIdForObject(localId, target);
3021
+ case 2:
3022
+ _context16.next = 4;
3023
+ return localDatastore._updateObjectIfPinned(target);
3024
+ case 4:
3025
+ return _context16.abrupt("return", target);
3026
+ case 5:
3027
+ case "end":
3028
+ return _context16.stop();
4206
3029
  }
4207
3030
  }, _callee12);
4208
3031
  })), function (error) {
4209
3032
  return _promise.default.reject(error);
4210
3033
  });
4211
3034
  }
4212
-
4213
3035
  return _promise.default.resolve();
4214
3036
  }
4215
3037
  };
4216
-
4217
3038
  _CoreManager.default.setObjectController(DefaultController);
4218
-
4219
3039
  var _default = ParseObject;
4220
3040
  exports.default = _default;