parse 4.0.1 → 4.1.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (251) hide show
  1. package/dist/parse.js +17995 -26193
  2. package/dist/parse.min.js +2 -2
  3. package/dist/parse.weapp.js +8739 -17728
  4. package/dist/parse.weapp.min.js +2 -2
  5. package/lib/browser/Analytics.js +2 -20
  6. package/lib/browser/AnonymousUtils.js +6 -35
  7. package/lib/browser/Cloud.js +12 -70
  8. package/lib/browser/CloudCode.js +0 -3
  9. package/lib/browser/CoreManager.js +46 -184
  10. package/lib/browser/CryptoController.js +2 -16
  11. package/lib/browser/EventEmitter.js +1 -1
  12. package/lib/browser/EventuallyQueue.js +277 -824
  13. package/lib/browser/FacebookUtils.js +6 -35
  14. package/lib/browser/IndexedDBStorageController.js +3 -14
  15. package/lib/browser/InstallationController.js +2 -13
  16. package/lib/browser/LiveQueryClient.js +87 -204
  17. package/lib/browser/LiveQuerySubscription.js +10 -39
  18. package/lib/browser/LocalDatastore.js +451 -1081
  19. package/lib/browser/LocalDatastoreController.js +145 -602
  20. package/lib/browser/LocalDatastoreController.react-native.js +137 -573
  21. package/lib/browser/LocalDatastoreUtils.js +2 -12
  22. package/lib/browser/ObjectStateMutations.js +18 -121
  23. package/lib/browser/OfflineQuery.js +42 -222
  24. package/lib/browser/Parse.js +12 -106
  25. package/lib/browser/ParseACL.js +33 -141
  26. package/lib/browser/ParseCLP.js +96 -314
  27. package/lib/browser/ParseConfig.js +18 -88
  28. package/lib/browser/ParseError.js +63 -90
  29. package/lib/browser/ParseFile.js +129 -685
  30. package/lib/browser/ParseGeoPoint.js +23 -82
  31. package/lib/browser/ParseHooks.js +1 -34
  32. package/lib/browser/ParseInstallation.js +4 -32
  33. package/lib/browser/ParseLiveQuery.js +96 -505
  34. package/lib/browser/ParseObject.js +628 -1840
  35. package/lib/browser/ParseOp.js +41 -287
  36. package/lib/browser/ParsePolygon.js +13 -63
  37. package/lib/browser/ParseQuery.js +404 -1505
  38. package/lib/browser/ParseRelation.js +12 -61
  39. package/lib/browser/ParseRole.js +13 -75
  40. package/lib/browser/ParseSchema.js +49 -201
  41. package/lib/browser/ParseSession.js +11 -69
  42. package/lib/browser/ParseUser.js +274 -1127
  43. package/lib/browser/Push.js +7 -43
  44. package/lib/browser/RESTController.js +18 -140
  45. package/lib/browser/SingleInstanceStateController.js +19 -137
  46. package/lib/browser/Socket.weapp.js +2 -12
  47. package/lib/browser/Storage.js +10 -73
  48. package/lib/browser/StorageController.browser.js +4 -17
  49. package/lib/browser/StorageController.default.js +4 -17
  50. package/lib/browser/StorageController.react-native.js +6 -33
  51. package/lib/browser/StorageController.weapp.js +5 -16
  52. package/lib/browser/TaskQueue.js +1 -22
  53. package/lib/browser/UniqueInstanceStateController.js +19 -142
  54. package/lib/browser/Xhr.weapp.js +0 -17
  55. package/lib/browser/arrayContainsObject.js +2 -16
  56. package/lib/browser/canBeSerialized.js +3 -33
  57. package/lib/browser/decode.js +3 -33
  58. package/lib/browser/encode.js +9 -70
  59. package/lib/browser/equals.js +2 -25
  60. package/lib/browser/escape.js +1 -8
  61. package/lib/browser/isRevocableSession.js +2 -11
  62. package/lib/browser/parseDate.js +2 -13
  63. package/lib/browser/promiseUtils.js +3 -21
  64. package/lib/browser/unique.js +3 -17
  65. package/lib/browser/unsavedChildren.js +6 -50
  66. package/lib/browser/uuid.js +3 -1
  67. package/lib/node/Analytics.js +1 -18
  68. package/lib/node/AnonymousUtils.js +5 -37
  69. package/lib/node/Cloud.js +10 -66
  70. package/lib/node/CloudCode.js +0 -3
  71. package/lib/node/CoreManager.js +47 -220
  72. package/lib/node/CryptoController.js +2 -16
  73. package/lib/node/EventEmitter.js +1 -1
  74. package/lib/node/EventuallyQueue.js +16 -123
  75. package/lib/node/FacebookUtils.js +5 -37
  76. package/lib/node/IndexedDBStorageController.js +3 -19
  77. package/lib/node/InstallationController.js +2 -15
  78. package/lib/node/LiveQueryClient.js +56 -136
  79. package/lib/node/LiveQuerySubscription.js +7 -16
  80. package/lib/node/LocalDatastore.js +19 -175
  81. package/lib/node/LocalDatastoreController.js +6 -38
  82. package/lib/node/LocalDatastoreController.react-native.js +6 -45
  83. package/lib/node/LocalDatastoreUtils.js +1 -6
  84. package/lib/node/ObjectStateMutations.js +13 -93
  85. package/lib/node/OfflineQuery.js +20 -152
  86. package/lib/node/Parse.js +11 -99
  87. package/lib/node/ParseACL.js +32 -150
  88. package/lib/node/ParseCLP.js +69 -262
  89. package/lib/node/ParseConfig.js +16 -84
  90. package/lib/node/ParseError.js +61 -65
  91. package/lib/node/ParseFile.js +50 -205
  92. package/lib/node/ParseGeoPoint.js +21 -82
  93. package/lib/node/ParseHooks.js +0 -35
  94. package/lib/node/ParseInstallation.js +1 -10
  95. package/lib/node/ParseLiveQuery.js +10 -36
  96. package/lib/node/ParseObject.js +193 -939
  97. package/lib/node/ParseOp.js +31 -255
  98. package/lib/node/ParsePolygon.js +12 -62
  99. package/lib/node/ParseQuery.js +170 -882
  100. package/lib/node/ParseRelation.js +11 -61
  101. package/lib/node/ParseRole.js +10 -57
  102. package/lib/node/ParseSchema.js +46 -222
  103. package/lib/node/ParseSession.js +8 -50
  104. package/lib/node/ParseUser.js +107 -576
  105. package/lib/node/Push.js +4 -37
  106. package/lib/node/RESTController.js +8 -110
  107. package/lib/node/SingleInstanceStateController.js +17 -130
  108. package/lib/node/Socket.weapp.js +2 -9
  109. package/lib/node/Storage.js +10 -83
  110. package/lib/node/StorageController.browser.js +4 -23
  111. package/lib/node/StorageController.default.js +5 -21
  112. package/lib/node/StorageController.react-native.js +6 -40
  113. package/lib/node/StorageController.weapp.js +6 -21
  114. package/lib/node/TaskQueue.js +1 -17
  115. package/lib/node/UniqueInstanceStateController.js +16 -133
  116. package/lib/node/Xhr.weapp.js +0 -15
  117. package/lib/node/arrayContainsObject.js +1 -12
  118. package/lib/node/canBeSerialized.js +2 -28
  119. package/lib/node/decode.js +1 -26
  120. package/lib/node/encode.js +3 -54
  121. package/lib/node/equals.js +0 -18
  122. package/lib/node/escape.js +1 -6
  123. package/lib/node/isRevocableSession.js +1 -5
  124. package/lib/node/parseDate.js +1 -7
  125. package/lib/node/promiseUtils.js +2 -14
  126. package/lib/node/unique.js +1 -11
  127. package/lib/node/unsavedChildren.js +2 -38
  128. package/lib/node/uuid.js +6 -1
  129. package/lib/react-native/Analytics.js +0 -9
  130. package/lib/react-native/AnonymousUtils.js +0 -10
  131. package/lib/react-native/Cloud.js +0 -26
  132. package/lib/react-native/CoreManager.js +1 -5
  133. package/lib/react-native/CryptoController.js +0 -2
  134. package/lib/react-native/EventEmitter.js +0 -2
  135. package/lib/react-native/EventuallyQueue.js +4 -52
  136. package/lib/react-native/FacebookUtils.js +0 -22
  137. package/lib/react-native/IndexedDBStorageController.js +0 -1
  138. package/lib/react-native/InstallationController.js +0 -6
  139. package/lib/react-native/LiveQueryClient.js +24 -101
  140. package/lib/react-native/LiveQuerySubscription.js +3 -27
  141. package/lib/react-native/LocalDatastore.js +6 -113
  142. package/lib/react-native/LocalDatastoreController.js +0 -21
  143. package/lib/react-native/LocalDatastoreController.react-native.js +4 -31
  144. package/lib/react-native/LocalDatastoreUtils.js +0 -1
  145. package/lib/react-native/ObjectStateMutations.js +0 -34
  146. package/lib/react-native/OfflineQuery.js +2 -137
  147. package/lib/react-native/Parse.js +0 -65
  148. package/lib/react-native/ParseACL.js +0 -44
  149. package/lib/react-native/ParseCLP.js +32 -96
  150. package/lib/react-native/ParseConfig.js +0 -42
  151. package/lib/react-native/ParseError.js +1 -21
  152. package/lib/react-native/ParseFile.js +4 -72
  153. package/lib/react-native/ParseGeoPoint.js +0 -17
  154. package/lib/react-native/ParseHooks.js +0 -30
  155. package/lib/react-native/ParseInstallation.js +1 -23
  156. package/lib/react-native/ParseLiveQuery.js +3 -25
  157. package/lib/react-native/ParseObject.js +4 -371
  158. package/lib/react-native/ParseOp.js +1 -138
  159. package/lib/react-native/ParsePolygon.js +0 -24
  160. package/lib/react-native/ParseQuery.js +6 -262
  161. package/lib/react-native/ParseRelation.js +0 -25
  162. package/lib/react-native/ParseRole.js +1 -36
  163. package/lib/react-native/ParseSchema.js +0 -51
  164. package/lib/react-native/ParseSession.js +1 -40
  165. package/lib/react-native/ParseUser.js +1 -224
  166. package/lib/react-native/Push.js +0 -16
  167. package/lib/react-native/RESTController.js +1 -70
  168. package/lib/react-native/SingleInstanceStateController.js +0 -44
  169. package/lib/react-native/Socket.weapp.js +2 -12
  170. package/lib/react-native/Storage.js +0 -24
  171. package/lib/react-native/StorageController.browser.js +0 -2
  172. package/lib/react-native/StorageController.default.js +0 -1
  173. package/lib/react-native/StorageController.react-native.js +0 -2
  174. package/lib/react-native/TaskQueue.js +0 -15
  175. package/lib/react-native/UniqueInstanceStateController.js +0 -47
  176. package/lib/react-native/Xhr.weapp.js +0 -16
  177. package/lib/react-native/arrayContainsObject.js +0 -5
  178. package/lib/react-native/canBeSerialized.js +0 -18
  179. package/lib/react-native/decode.js +0 -21
  180. package/lib/react-native/encode.js +0 -25
  181. package/lib/react-native/equals.js +0 -18
  182. package/lib/react-native/escape.js +0 -1
  183. package/lib/react-native/isRevocableSession.js +0 -1
  184. package/lib/react-native/parseDate.js +0 -3
  185. package/lib/react-native/promiseUtils.js +0 -13
  186. package/lib/react-native/unique.js +0 -4
  187. package/lib/react-native/unsavedChildren.js +0 -21
  188. package/lib/react-native/uuid.js +3 -1
  189. package/lib/weapp/Analytics.js +2 -20
  190. package/lib/weapp/AnonymousUtils.js +6 -35
  191. package/lib/weapp/Cloud.js +12 -70
  192. package/lib/weapp/CloudCode.js +0 -3
  193. package/lib/weapp/CoreManager.js +46 -184
  194. package/lib/weapp/CryptoController.js +2 -16
  195. package/lib/weapp/EventEmitter.js +1 -1
  196. package/lib/weapp/EventuallyQueue.js +277 -824
  197. package/lib/weapp/FacebookUtils.js +6 -35
  198. package/lib/weapp/IndexedDBStorageController.js +3 -14
  199. package/lib/weapp/InstallationController.js +2 -13
  200. package/lib/weapp/LiveQueryClient.js +87 -204
  201. package/lib/weapp/LiveQuerySubscription.js +10 -39
  202. package/lib/weapp/LocalDatastore.js +451 -1081
  203. package/lib/weapp/LocalDatastoreController.js +145 -602
  204. package/lib/weapp/LocalDatastoreController.react-native.js +137 -573
  205. package/lib/weapp/LocalDatastoreUtils.js +2 -12
  206. package/lib/weapp/ObjectStateMutations.js +18 -121
  207. package/lib/weapp/OfflineQuery.js +42 -222
  208. package/lib/weapp/Parse.js +12 -106
  209. package/lib/weapp/ParseACL.js +33 -141
  210. package/lib/weapp/ParseCLP.js +96 -314
  211. package/lib/weapp/ParseConfig.js +18 -88
  212. package/lib/weapp/ParseError.js +63 -90
  213. package/lib/weapp/ParseFile.js +130 -686
  214. package/lib/weapp/ParseGeoPoint.js +23 -82
  215. package/lib/weapp/ParseHooks.js +1 -34
  216. package/lib/weapp/ParseInstallation.js +4 -32
  217. package/lib/weapp/ParseLiveQuery.js +96 -505
  218. package/lib/weapp/ParseObject.js +628 -1840
  219. package/lib/weapp/ParseOp.js +41 -287
  220. package/lib/weapp/ParsePolygon.js +13 -63
  221. package/lib/weapp/ParseQuery.js +404 -1505
  222. package/lib/weapp/ParseRelation.js +12 -61
  223. package/lib/weapp/ParseRole.js +13 -75
  224. package/lib/weapp/ParseSchema.js +49 -201
  225. package/lib/weapp/ParseSession.js +11 -69
  226. package/lib/weapp/ParseUser.js +274 -1127
  227. package/lib/weapp/Push.js +7 -43
  228. package/lib/weapp/RESTController.js +18 -140
  229. package/lib/weapp/SingleInstanceStateController.js +19 -137
  230. package/lib/weapp/Socket.weapp.js +2 -12
  231. package/lib/weapp/Storage.js +10 -73
  232. package/lib/weapp/StorageController.browser.js +4 -17
  233. package/lib/weapp/StorageController.default.js +4 -17
  234. package/lib/weapp/StorageController.react-native.js +6 -33
  235. package/lib/weapp/StorageController.weapp.js +5 -16
  236. package/lib/weapp/TaskQueue.js +1 -22
  237. package/lib/weapp/UniqueInstanceStateController.js +19 -142
  238. package/lib/weapp/Xhr.weapp.js +0 -17
  239. package/lib/weapp/arrayContainsObject.js +2 -16
  240. package/lib/weapp/canBeSerialized.js +3 -33
  241. package/lib/weapp/decode.js +3 -33
  242. package/lib/weapp/encode.js +9 -70
  243. package/lib/weapp/equals.js +2 -25
  244. package/lib/weapp/escape.js +1 -8
  245. package/lib/weapp/isRevocableSession.js +2 -11
  246. package/lib/weapp/parseDate.js +2 -13
  247. package/lib/weapp/promiseUtils.js +3 -21
  248. package/lib/weapp/unique.js +3 -17
  249. package/lib/weapp/unsavedChildren.js +6 -50
  250. package/lib/weapp/uuid.js +1 -6
  251. package/package.json +45 -43
@@ -6,32 +6,17 @@ var _LocalDatastoreUtils = require("./LocalDatastoreUtils");
6
6
  * @private
7
7
  */
8
8
 
9
-
10
9
  const RNStorage = require('./StorageController.react-native');
11
-
12
10
  const LocalDatastoreController = {
13
- async fromPinWithName(name
14
- /*: string*/
15
- )
16
- /*: Promise<Array<Object>>*/
17
- {
11
+ async fromPinWithName(name /*: string*/) /*: Promise<Array<Object>>*/{
18
12
  const values = await RNStorage.getItemAsync(name);
19
-
20
13
  if (!values) {
21
14
  return [];
22
15
  }
23
-
24
16
  const objects = JSON.parse(values);
25
17
  return objects;
26
18
  },
27
-
28
- async pinWithName(name
29
- /*: string*/
30
- , value
31
- /*: any*/
32
- )
33
- /*: Promise<void>*/
34
- {
19
+ async pinWithName(name /*: string*/, value /*: any*/) /*: Promise<void>*/{
35
20
  try {
36
21
  const values = JSON.stringify(value);
37
22
  await RNStorage.setItemAsync(name, values);
@@ -40,42 +25,28 @@ const LocalDatastoreController = {
40
25
  console.error(e.message);
41
26
  }
42
27
  },
43
-
44
- unPinWithName(name
45
- /*: string*/
46
- )
47
- /*: Promise<void>*/
48
- {
28
+ unPinWithName(name /*: string*/) /*: Promise<void>*/{
49
29
  return RNStorage.removeItemAsync(name);
50
30
  },
51
-
52
- async getAllContents()
53
- /*: Promise<Object>*/
54
- {
31
+ async getAllContents() /*: Promise<Object>*/{
55
32
  const keys = await RNStorage.getAllKeysAsync();
56
33
  const batch = [];
57
-
58
34
  for (let i = 0; i < keys.length; i += 1) {
59
35
  const key = keys[i];
60
-
61
36
  if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
62
37
  batch.push(key);
63
38
  }
64
39
  }
65
-
66
40
  const LDS = {};
67
41
  let results = [];
68
-
69
42
  try {
70
43
  results = await RNStorage.multiGet(batch);
71
44
  } catch (error) {
72
45
  console.error('Error getAllContents: ', error);
73
46
  return {};
74
47
  }
75
-
76
48
  results.forEach(pair => {
77
49
  const [key, value] = pair;
78
-
79
50
  try {
80
51
  LDS[key] = JSON.parse(value);
81
52
  } catch (error) {
@@ -84,11 +55,8 @@ const LocalDatastoreController = {
84
55
  });
85
56
  return LDS;
86
57
  },
87
-
88
58
  // Used for testing
89
- async getRawStorage()
90
- /*: Promise<Object>*/
91
- {
59
+ async getRawStorage() /*: Promise<Object>*/{
92
60
  const keys = await RNStorage.getAllKeysAsync();
93
61
  const storage = {};
94
62
  const results = await RNStorage.multiGet(keys);
@@ -98,23 +66,16 @@ const LocalDatastoreController = {
98
66
  });
99
67
  return storage;
100
68
  },
101
-
102
- async clear()
103
- /*: Promise<void>*/
104
- {
69
+ async clear() /*: Promise<void>*/{
105
70
  const keys = await RNStorage.getAllKeysAsync();
106
71
  const batch = [];
107
-
108
72
  for (let i = 0; i < keys.length; i += 1) {
109
73
  const key = keys[i];
110
-
111
74
  if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
112
75
  batch.push(key);
113
76
  }
114
77
  }
115
-
116
78
  return RNStorage.multiRemove(batch).catch(error => console.error('Error clearing local datastore: ', error));
117
79
  }
118
-
119
80
  };
120
81
  module.exports = LocalDatastoreController;
@@ -16,11 +16,6 @@ const PIN_PREFIX = 'parsePin_';
16
16
  exports.PIN_PREFIX = PIN_PREFIX;
17
17
  const OBJECT_PREFIX = 'Parse_LDS_';
18
18
  exports.OBJECT_PREFIX = OBJECT_PREFIX;
19
-
20
- function isLocalDatastoreKey(key
21
- /*: string*/
22
- )
23
- /*: boolean*/
24
- {
19
+ function isLocalDatastoreKey(key /*: string*/) /*: boolean*/{
25
20
  return !!(key && (key === DEFAULT_PIN || key.startsWith(PIN_PREFIX) || key.startsWith(OBJECT_PREFIX)));
26
21
  }
@@ -12,19 +12,12 @@ 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
@@ -34,10 +27,7 @@ function _interopRequireDefault(obj) {
34
27
  * @flow
35
28
  */
36
29
 
37
-
38
- function defaultState()
39
- /*: State*/
40
- {
30
+ function defaultState() /*: State*/{
41
31
  return {
42
32
  serverData: {},
43
33
  pendingOps: [{}],
@@ -46,12 +36,7 @@ function defaultState()
46
36
  existed: false
47
37
  };
48
38
  }
49
-
50
- function setServerData(serverData
51
- /*: AttributeMap*/
52
- , attributes
53
- /*: AttributeMap*/
54
- ) {
39
+ function setServerData(serverData /*: AttributeMap*/, attributes /*: AttributeMap*/) {
55
40
  for (const attr in attributes) {
56
41
  if (typeof attributes[attr] !== 'undefined') {
57
42
  serverData[attr] = attributes[attr];
@@ -60,53 +45,30 @@ function setServerData(serverData
60
45
  }
61
46
  }
62
47
  }
63
-
64
- function setPendingOp(pendingOps
65
- /*: Array<OpsMap>*/
66
- , attr
67
- /*: string*/
68
- , op
69
- /*: ?Op*/
70
- ) {
48
+ function setPendingOp(pendingOps /*: Array<OpsMap>*/, attr /*: string*/, op /*: ?Op*/) {
71
49
  const last = pendingOps.length - 1;
72
-
73
50
  if (op) {
74
51
  pendingOps[last][attr] = op;
75
52
  } else {
76
53
  delete pendingOps[last][attr];
77
54
  }
78
55
  }
79
-
80
- function pushPendingState(pendingOps
81
- /*: Array<OpsMap>*/
82
- ) {
56
+ function pushPendingState(pendingOps /*: Array<OpsMap>*/) {
83
57
  pendingOps.push({});
84
58
  }
85
-
86
- function popPendingState(pendingOps
87
- /*: Array<OpsMap>*/
88
- )
89
- /*: OpsMap*/
90
- {
59
+ function popPendingState(pendingOps /*: Array<OpsMap>*/) /*: OpsMap*/{
91
60
  const first = pendingOps.shift();
92
-
93
61
  if (!pendingOps.length) {
94
62
  pendingOps[0] = {};
95
63
  }
96
-
97
64
  return first;
98
65
  }
99
-
100
- function mergeFirstPendingState(pendingOps
101
- /*: Array<OpsMap>*/
102
- ) {
66
+ function mergeFirstPendingState(pendingOps /*: Array<OpsMap>*/) {
103
67
  const first = popPendingState(pendingOps);
104
68
  const next = pendingOps[0];
105
-
106
69
  for (const attr in first) {
107
70
  if (next[attr] && first[attr]) {
108
71
  const merged = next[attr].mergeWith(first[attr]);
109
-
110
72
  if (merged) {
111
73
  next[attr] = merged;
112
74
  }
@@ -115,22 +77,8 @@ function mergeFirstPendingState(pendingOps
115
77
  }
116
78
  }
117
79
  }
118
-
119
- function estimateAttribute(serverData
120
- /*: AttributeMap*/
121
- , pendingOps
122
- /*: Array<OpsMap>*/
123
- , className
124
- /*: string*/
125
- , id
126
- /*: ?string*/
127
- , attr
128
- /*: string*/
129
- )
130
- /*: mixed*/
131
- {
80
+ function estimateAttribute(serverData /*: AttributeMap*/, pendingOps /*: Array<OpsMap>*/, className /*: string*/, id /*: ?string*/, attr /*: string*/) /*: mixed*/{
132
81
  let value = serverData[attr];
133
-
134
82
  for (let i = 0; i < pendingOps.length; i++) {
135
83
  if (pendingOps[i][attr]) {
136
84
  if (pendingOps[i][attr] instanceof _ParseOp.RelationOp) {
@@ -145,27 +93,13 @@ function estimateAttribute(serverData
145
93
  }
146
94
  }
147
95
  }
148
-
149
96
  return value;
150
97
  }
151
-
152
- function estimateAttributes(serverData
153
- /*: AttributeMap*/
154
- , pendingOps
155
- /*: Array<OpsMap>*/
156
- , className
157
- /*: string*/
158
- , id
159
- /*: ?string*/
160
- )
161
- /*: AttributeMap*/
162
- {
98
+ function estimateAttributes(serverData /*: AttributeMap*/, pendingOps /*: Array<OpsMap>*/, className /*: string*/, id /*: ?string*/) /*: AttributeMap*/{
163
99
  const data = {};
164
-
165
100
  for (var attr in serverData) {
166
101
  data[attr] = serverData[attr];
167
102
  }
168
-
169
103
  for (let i = 0; i < pendingOps.length; i++) {
170
104
  for (attr in pendingOps[i]) {
171
105
  if (pendingOps[i][attr] instanceof _ParseOp.RelationOp) {
@@ -181,21 +115,19 @@ function estimateAttributes(serverData
181
115
  const fields = attr.split('.');
182
116
  const first = fields[0];
183
117
  const last = fields[fields.length - 1];
184
- data[first] = { ...serverData[first]
118
+ data[first] = {
119
+ ...serverData[first]
185
120
  };
186
- let object = { ...data
121
+ let object = {
122
+ ...data
187
123
  };
188
-
189
124
  for (let i = 0; i < fields.length - 1; i++) {
190
125
  const key = fields[i];
191
-
192
126
  if (!(key in object)) {
193
127
  object[key] = {};
194
128
  }
195
-
196
129
  object = object[key];
197
130
  }
198
-
199
131
  object[last] = pendingOps[i][attr].applyTo(object[last]);
200
132
  } else {
201
133
  data[attr] = pendingOps[i][attr].applyTo(data[attr]);
@@ -203,36 +135,24 @@ function estimateAttributes(serverData
203
135
  }
204
136
  }
205
137
  }
206
-
207
138
  return data;
208
139
  }
209
-
210
140
  function nestedSet(obj, key, value) {
211
141
  const path = key.split('.');
212
-
213
142
  for (let i = 0; i < path.length - 1; i++) {
214
143
  if (!(path[i] in obj)) obj[path[i]] = {};
215
144
  obj = obj[path[i]];
216
145
  }
217
-
218
146
  if (typeof value === 'undefined') {
219
147
  delete obj[path[path.length - 1]];
220
148
  } else {
221
149
  obj[path[path.length - 1]] = value;
222
150
  }
223
151
  }
224
-
225
- function commitServerChanges(serverData
226
- /*: AttributeMap*/
227
- , objectCache
228
- /*: ObjectCache*/
229
- , changes
230
- /*: AttributeMap*/
231
- ) {
152
+ function commitServerChanges(serverData /*: AttributeMap*/, objectCache /*: ObjectCache*/, changes /*: AttributeMap*/) {
232
153
  for (const attr in changes) {
233
154
  const val = changes[attr];
234
155
  nestedSet(serverData, attr, val);
235
-
236
156
  if (val && typeof val === 'object' && !(val instanceof _ParseObject.default) && !(val instanceof _ParseFile.default) && !(val instanceof _ParseRelation.default)) {
237
157
  const json = (0, _encode.default)(val, false, true);
238
158
  objectCache[attr] = JSON.stringify(json);