parse 3.5.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 +20 -7
  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 +18 -134
  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 +73 -302
  92. package/lib/node/ParseConfig.js +16 -91
  93. package/lib/node/ParseError.js +61 -74
  94. package/lib/node/ParseFile.js +55 -244
  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 +234 -997
  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 +19 -169
  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 +37 -30
  255. package/PATENTS +0 -37
@@ -2,43 +2,21 @@
2
2
 
3
3
  var _LocalDatastoreUtils = require("./LocalDatastoreUtils");
4
4
  /**
5
- * Copyright (c) 2015-present, Parse, LLC.
6
- * All rights reserved.
7
- *
8
- * This source code is licensed under the BSD-style license found in the
9
- * LICENSE file in the root directory of this source tree. An additional grant
10
- * of patent rights can be found in the PATENTS file in the same directory.
11
- *
12
5
  * @flow
13
6
  * @private
14
7
  */
15
8
 
16
-
17
9
  const RNStorage = require('./StorageController.react-native');
18
-
19
10
  const LocalDatastoreController = {
20
- async fromPinWithName(name
21
- /*: string*/
22
- )
23
- /*: Promise<Array<Object>>*/
24
- {
11
+ async fromPinWithName(name /*: string*/) /*: Promise<Array<Object>>*/{
25
12
  const values = await RNStorage.getItemAsync(name);
26
-
27
13
  if (!values) {
28
14
  return [];
29
15
  }
30
-
31
16
  const objects = JSON.parse(values);
32
17
  return objects;
33
18
  },
34
-
35
- async pinWithName(name
36
- /*: string*/
37
- , value
38
- /*: any*/
39
- )
40
- /*: Promise<void>*/
41
- {
19
+ async pinWithName(name /*: string*/, value /*: any*/) /*: Promise<void>*/{
42
20
  try {
43
21
  const values = JSON.stringify(value);
44
22
  await RNStorage.setItemAsync(name, values);
@@ -47,42 +25,28 @@ const LocalDatastoreController = {
47
25
  console.error(e.message);
48
26
  }
49
27
  },
50
-
51
- unPinWithName(name
52
- /*: string*/
53
- )
54
- /*: Promise<void>*/
55
- {
28
+ unPinWithName(name /*: string*/) /*: Promise<void>*/{
56
29
  return RNStorage.removeItemAsync(name);
57
30
  },
58
-
59
- async getAllContents()
60
- /*: Promise<Object>*/
61
- {
31
+ async getAllContents() /*: Promise<Object>*/{
62
32
  const keys = await RNStorage.getAllKeysAsync();
63
33
  const batch = [];
64
-
65
34
  for (let i = 0; i < keys.length; i += 1) {
66
35
  const key = keys[i];
67
-
68
36
  if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
69
37
  batch.push(key);
70
38
  }
71
39
  }
72
-
73
40
  const LDS = {};
74
41
  let results = [];
75
-
76
42
  try {
77
43
  results = await RNStorage.multiGet(batch);
78
44
  } catch (error) {
79
45
  console.error('Error getAllContents: ', error);
80
46
  return {};
81
47
  }
82
-
83
48
  results.forEach(pair => {
84
49
  const [key, value] = pair;
85
-
86
50
  try {
87
51
  LDS[key] = JSON.parse(value);
88
52
  } catch (error) {
@@ -91,11 +55,8 @@ const LocalDatastoreController = {
91
55
  });
92
56
  return LDS;
93
57
  },
94
-
95
58
  // Used for testing
96
- async getRawStorage()
97
- /*: Promise<Object>*/
98
- {
59
+ async getRawStorage() /*: Promise<Object>*/{
99
60
  const keys = await RNStorage.getAllKeysAsync();
100
61
  const storage = {};
101
62
  const results = await RNStorage.multiGet(keys);
@@ -105,23 +66,16 @@ const LocalDatastoreController = {
105
66
  });
106
67
  return storage;
107
68
  },
108
-
109
- async clear()
110
- /*: Promise<void>*/
111
- {
69
+ async clear() /*: Promise<void>*/{
112
70
  const keys = await RNStorage.getAllKeysAsync();
113
71
  const batch = [];
114
-
115
72
  for (let i = 0; i < keys.length; i += 1) {
116
73
  const key = keys[i];
117
-
118
74
  if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
119
75
  batch.push(key);
120
76
  }
121
77
  }
122
-
123
78
  return RNStorage.multiRemove(batch).catch(error => console.error('Error clearing local datastore: ', error));
124
79
  }
125
-
126
80
  };
127
81
  module.exports = LocalDatastoreController;
@@ -6,13 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.PIN_PREFIX = exports.OBJECT_PREFIX = exports.DEFAULT_PIN = void 0;
7
7
  exports.isLocalDatastoreKey = isLocalDatastoreKey;
8
8
  /**
9
- * Copyright (c) 2015-present, Parse, LLC.
10
- * All rights reserved.
11
- *
12
- * This source code is licensed under the BSD-style license found in the
13
- * LICENSE file in the root directory of this source tree. An additional grant
14
- * of patent rights can be found in the PATENTS file in the same directory.
15
- *
16
9
  * @flow
17
10
  * @private
18
11
  */
@@ -23,11 +16,6 @@ const PIN_PREFIX = 'parsePin_';
23
16
  exports.PIN_PREFIX = PIN_PREFIX;
24
17
  const OBJECT_PREFIX = 'Parse_LDS_';
25
18
  exports.OBJECT_PREFIX = OBJECT_PREFIX;
26
-
27
- function isLocalDatastoreKey(key
28
- /*: string*/
29
- )
30
- /*: boolean*/
31
- {
19
+ function isLocalDatastoreKey(key /*: string*/) /*: boolean*/{
32
20
  return !!(key && (key === DEFAULT_PIN || key.startsWith(PIN_PREFIX) || key.startsWith(OBJECT_PREFIX)));
33
21
  }
@@ -12,69 +12,22 @@ exports.popPendingState = popPendingState;
12
12
  exports.pushPendingState = pushPendingState;
13
13
  exports.setPendingOp = setPendingOp;
14
14
  exports.setServerData = setServerData;
15
-
16
15
  var _encode = _interopRequireDefault(require("./encode"));
17
-
18
16
  var _ParseFile = _interopRequireDefault(require("./ParseFile"));
19
-
20
17
  var _ParseObject = _interopRequireDefault(require("./ParseObject"));
21
-
22
18
  var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
23
-
24
19
  var _TaskQueue = _interopRequireDefault(require("./TaskQueue"));
25
-
26
20
  var _ParseOp = require("./ParseOp");
27
-
28
21
  function _interopRequireDefault(obj) {
29
22
  return obj && obj.__esModule ? obj : {
30
23
  default: obj
31
24
  };
32
25
  }
26
+ /**
27
+ * @flow
28
+ */
33
29
 
34
- function ownKeys(object, enumerableOnly) {
35
- var keys = Object.keys(object);
36
-
37
- if (Object.getOwnPropertySymbols) {
38
- var symbols = Object.getOwnPropertySymbols(object);
39
- enumerableOnly && (symbols = symbols.filter(function (sym) {
40
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
41
- })), keys.push.apply(keys, symbols);
42
- }
43
-
44
- return keys;
45
- }
46
-
47
- function _objectSpread(target) {
48
- for (var i = 1; i < arguments.length; i++) {
49
- var source = null != arguments[i] ? arguments[i] : {};
50
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
51
- _defineProperty(target, key, source[key]);
52
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
53
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
54
- });
55
- }
56
-
57
- return target;
58
- }
59
-
60
- function _defineProperty(obj, key, value) {
61
- if (key in obj) {
62
- Object.defineProperty(obj, key, {
63
- value: value,
64
- enumerable: true,
65
- configurable: true,
66
- writable: true
67
- });
68
- } else {
69
- obj[key] = value;
70
- }
71
-
72
- return obj;
73
- }
74
-
75
- function defaultState()
76
- /*: State*/
77
- {
30
+ function defaultState() /*: State*/{
78
31
  return {
79
32
  serverData: {},
80
33
  pendingOps: [{}],
@@ -83,12 +36,7 @@ function defaultState()
83
36
  existed: false
84
37
  };
85
38
  }
86
-
87
- function setServerData(serverData
88
- /*: AttributeMap*/
89
- , attributes
90
- /*: AttributeMap*/
91
- ) {
39
+ function setServerData(serverData /*: AttributeMap*/, attributes /*: AttributeMap*/) {
92
40
  for (const attr in attributes) {
93
41
  if (typeof attributes[attr] !== 'undefined') {
94
42
  serverData[attr] = attributes[attr];
@@ -97,53 +45,30 @@ function setServerData(serverData
97
45
  }
98
46
  }
99
47
  }
100
-
101
- function setPendingOp(pendingOps
102
- /*: Array<OpsMap>*/
103
- , attr
104
- /*: string*/
105
- , op
106
- /*: ?Op*/
107
- ) {
48
+ function setPendingOp(pendingOps /*: Array<OpsMap>*/, attr /*: string*/, op /*: ?Op*/) {
108
49
  const last = pendingOps.length - 1;
109
-
110
50
  if (op) {
111
51
  pendingOps[last][attr] = op;
112
52
  } else {
113
53
  delete pendingOps[last][attr];
114
54
  }
115
55
  }
116
-
117
- function pushPendingState(pendingOps
118
- /*: Array<OpsMap>*/
119
- ) {
56
+ function pushPendingState(pendingOps /*: Array<OpsMap>*/) {
120
57
  pendingOps.push({});
121
58
  }
122
-
123
- function popPendingState(pendingOps
124
- /*: Array<OpsMap>*/
125
- )
126
- /*: OpsMap*/
127
- {
59
+ function popPendingState(pendingOps /*: Array<OpsMap>*/) /*: OpsMap*/{
128
60
  const first = pendingOps.shift();
129
-
130
61
  if (!pendingOps.length) {
131
62
  pendingOps[0] = {};
132
63
  }
133
-
134
64
  return first;
135
65
  }
136
-
137
- function mergeFirstPendingState(pendingOps
138
- /*: Array<OpsMap>*/
139
- ) {
66
+ function mergeFirstPendingState(pendingOps /*: Array<OpsMap>*/) {
140
67
  const first = popPendingState(pendingOps);
141
68
  const next = pendingOps[0];
142
-
143
69
  for (const attr in first) {
144
70
  if (next[attr] && first[attr]) {
145
71
  const merged = next[attr].mergeWith(first[attr]);
146
-
147
72
  if (merged) {
148
73
  next[attr] = merged;
149
74
  }
@@ -152,22 +77,8 @@ function mergeFirstPendingState(pendingOps
152
77
  }
153
78
  }
154
79
  }
155
-
156
- function estimateAttribute(serverData
157
- /*: AttributeMap*/
158
- , pendingOps
159
- /*: Array<OpsMap>*/
160
- , className
161
- /*: string*/
162
- , id
163
- /*: ?string*/
164
- , attr
165
- /*: string*/
166
- )
167
- /*: mixed*/
168
- {
80
+ function estimateAttribute(serverData /*: AttributeMap*/, pendingOps /*: Array<OpsMap>*/, className /*: string*/, id /*: ?string*/, attr /*: string*/) /*: mixed*/{
169
81
  let value = serverData[attr];
170
-
171
82
  for (let i = 0; i < pendingOps.length; i++) {
172
83
  if (pendingOps[i][attr]) {
173
84
  if (pendingOps[i][attr] instanceof _ParseOp.RelationOp) {
@@ -182,27 +93,13 @@ function estimateAttribute(serverData
182
93
  }
183
94
  }
184
95
  }
185
-
186
96
  return value;
187
97
  }
188
-
189
- function estimateAttributes(serverData
190
- /*: AttributeMap*/
191
- , pendingOps
192
- /*: Array<OpsMap>*/
193
- , className
194
- /*: string*/
195
- , id
196
- /*: ?string*/
197
- )
198
- /*: AttributeMap*/
199
- {
98
+ function estimateAttributes(serverData /*: AttributeMap*/, pendingOps /*: Array<OpsMap>*/, className /*: string*/, id /*: ?string*/) /*: AttributeMap*/{
200
99
  const data = {};
201
-
202
100
  for (var attr in serverData) {
203
101
  data[attr] = serverData[attr];
204
102
  }
205
-
206
103
  for (let i = 0; i < pendingOps.length; i++) {
207
104
  for (attr in pendingOps[i]) {
208
105
  if (pendingOps[i][attr] instanceof _ParseOp.RelationOp) {
@@ -218,20 +115,19 @@ function estimateAttributes(serverData
218
115
  const fields = attr.split('.');
219
116
  const first = fields[0];
220
117
  const last = fields[fields.length - 1];
221
- data[first] = _objectSpread({}, serverData[first]);
222
-
223
- let object = _objectSpread({}, data);
224
-
118
+ data[first] = {
119
+ ...serverData[first]
120
+ };
121
+ let object = {
122
+ ...data
123
+ };
225
124
  for (let i = 0; i < fields.length - 1; i++) {
226
125
  const key = fields[i];
227
-
228
126
  if (!(key in object)) {
229
127
  object[key] = {};
230
128
  }
231
-
232
129
  object = object[key];
233
130
  }
234
-
235
131
  object[last] = pendingOps[i][attr].applyTo(object[last]);
236
132
  } else {
237
133
  data[attr] = pendingOps[i][attr].applyTo(data[attr]);
@@ -239,36 +135,24 @@ function estimateAttributes(serverData
239
135
  }
240
136
  }
241
137
  }
242
-
243
138
  return data;
244
139
  }
245
-
246
140
  function nestedSet(obj, key, value) {
247
141
  const path = key.split('.');
248
-
249
142
  for (let i = 0; i < path.length - 1; i++) {
250
143
  if (!(path[i] in obj)) obj[path[i]] = {};
251
144
  obj = obj[path[i]];
252
145
  }
253
-
254
146
  if (typeof value === 'undefined') {
255
147
  delete obj[path[path.length - 1]];
256
148
  } else {
257
149
  obj[path[path.length - 1]] = value;
258
150
  }
259
151
  }
260
-
261
- function commitServerChanges(serverData
262
- /*: AttributeMap*/
263
- , objectCache
264
- /*: ObjectCache*/
265
- , changes
266
- /*: AttributeMap*/
267
- ) {
152
+ function commitServerChanges(serverData /*: AttributeMap*/, objectCache /*: ObjectCache*/, changes /*: AttributeMap*/) {
268
153
  for (const attr in changes) {
269
154
  const val = changes[attr];
270
155
  nestedSet(serverData, attr, val);
271
-
272
156
  if (val && typeof val === 'object' && !(val instanceof _ParseObject.default) && !(val instanceof _ParseFile.default) && !(val instanceof _ParseRelation.default)) {
273
157
  const json = (0, _encode.default)(val, false, true);
274
158
  objectCache[attr] = JSON.stringify(json);