parse 5.1.1-alpha.1 → 5.2.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (249) hide show
  1. package/dist/parse.js +10186 -14918
  2. package/dist/parse.min.js +2 -2
  3. package/dist/parse.weapp.js +10180 -15057
  4. package/dist/parse.weapp.min.js +2 -2
  5. package/lib/browser/Analytics.js +7 -11
  6. package/lib/browser/AnonymousUtils.js +17 -22
  7. package/lib/browser/Cloud.js +24 -46
  8. package/lib/browser/CoreManager.js +71 -79
  9. package/lib/browser/CryptoController.js +14 -9
  10. package/lib/browser/EventEmitter.js +9 -2
  11. package/lib/browser/EventuallyQueue.js +156 -357
  12. package/lib/browser/FacebookUtils.js +23 -28
  13. package/lib/browser/IndexedDBStorageController.js +18 -14
  14. package/lib/browser/InstallationController.js +55 -121
  15. package/lib/browser/LiveQueryClient.js +312 -446
  16. package/lib/browser/LiveQuerySubscription.js +25 -28
  17. package/lib/browser/LocalDatastore.js +254 -578
  18. package/lib/browser/LocalDatastoreController.default.js +48 -227
  19. package/lib/browser/LocalDatastoreController.js +11 -1
  20. package/lib/browser/LocalDatastoreController.react-native.js +72 -164
  21. package/lib/browser/LocalDatastoreUtils.js +4 -12
  22. package/lib/browser/ObjectStateMutations.js +89 -95
  23. package/lib/browser/OfflineQuery.js +106 -198
  24. package/lib/browser/Parse.js +45 -61
  25. package/lib/browser/ParseACL.js +242 -288
  26. package/lib/browser/ParseCLP.js +372 -580
  27. package/lib/browser/ParseConfig.js +115 -138
  28. package/lib/browser/ParseError.js +85 -182
  29. package/lib/browser/ParseFile.js +296 -444
  30. package/lib/browser/ParseGeoPoint.js +121 -140
  31. package/lib/browser/ParseHooks.js +12 -14
  32. package/lib/browser/ParseInstallation.js +226 -354
  33. package/lib/browser/ParseLiveQuery.js +74 -148
  34. package/lib/browser/ParseObject.js +2017 -2622
  35. package/lib/browser/ParseOp.js +343 -484
  36. package/lib/browser/ParsePolygon.js +101 -120
  37. package/lib/browser/ParseQuery.js +1722 -2068
  38. package/lib/browser/ParseRelation.js +99 -118
  39. package/lib/browser/ParseRole.js +88 -144
  40. package/lib/browser/ParseSchema.js +372 -434
  41. package/lib/browser/ParseSession.js +62 -110
  42. package/lib/browser/ParseUser.js +942 -1270
  43. package/lib/browser/Push.js +16 -44
  44. package/lib/browser/RESTController.js +85 -124
  45. package/lib/browser/SingleInstanceStateController.js +57 -86
  46. package/lib/browser/Socket.weapp.js +50 -33
  47. package/lib/browser/Storage.js +23 -28
  48. package/lib/browser/StorageController.browser.js +16 -13
  49. package/lib/browser/StorageController.default.js +15 -14
  50. package/lib/browser/StorageController.js +14 -1
  51. package/lib/browser/StorageController.react-native.js +31 -30
  52. package/lib/browser/StorageController.weapp.js +19 -13
  53. package/lib/browser/TaskQueue.js +37 -49
  54. package/lib/browser/UniqueInstanceStateController.js +65 -86
  55. package/lib/browser/WebSocketController.js +11 -4
  56. package/lib/browser/Xhr.weapp.js +90 -78
  57. package/lib/browser/arrayContainsObject.js +3 -3
  58. package/lib/browser/canBeSerialized.js +10 -11
  59. package/lib/browser/decode.js +11 -11
  60. package/lib/browser/encode.js +11 -11
  61. package/lib/browser/equals.js +9 -10
  62. package/lib/browser/escape.js +2 -2
  63. package/lib/browser/isRevocableSession.js +1 -1
  64. package/lib/browser/parseDate.js +10 -10
  65. package/lib/browser/promiseUtils.js +19 -19
  66. package/lib/browser/unique.js +4 -4
  67. package/lib/browser/unsavedChildren.js +20 -21
  68. package/lib/browser/uuid.js +2 -4
  69. package/lib/node/Analytics.js +2 -6
  70. package/lib/node/AnonymousUtils.js +7 -12
  71. package/lib/node/Cloud.js +8 -12
  72. package/lib/node/CoreManager.js +59 -67
  73. package/lib/node/CryptoController.js +8 -3
  74. package/lib/node/EventEmitter.js +7 -1
  75. package/lib/node/EventuallyQueue.js +18 -37
  76. package/lib/node/FacebookUtils.js +1 -5
  77. package/lib/node/IndexedDBStorageController.js +14 -10
  78. package/lib/node/InstallationController.js +7 -8
  79. package/lib/node/LiveQueryClient.js +20 -32
  80. package/lib/node/LiveQuerySubscription.js +3 -4
  81. package/lib/node/LocalDatastore.js +20 -24
  82. package/lib/node/LocalDatastoreController.default.js +12 -11
  83. package/lib/node/LocalDatastoreController.js +14 -1
  84. package/lib/node/LocalDatastoreController.react-native.js +27 -22
  85. package/lib/node/LocalDatastoreUtils.js +4 -12
  86. package/lib/node/ObjectStateMutations.js +52 -36
  87. package/lib/node/OfflineQuery.js +37 -23
  88. package/lib/node/Parse.js +35 -49
  89. package/lib/node/ParseACL.js +18 -27
  90. package/lib/node/ParseCLP.js +38 -50
  91. package/lib/node/ParseConfig.js +7 -14
  92. package/lib/node/ParseError.js +457 -458
  93. package/lib/node/ParseFile.js +33 -66
  94. package/lib/node/ParseGeoPoint.js +22 -17
  95. package/lib/node/ParseHooks.js +0 -2
  96. package/lib/node/ParseInstallation.js +21 -8
  97. package/lib/node/ParseLiveQuery.js +6 -11
  98. package/lib/node/ParseObject.js +138 -167
  99. package/lib/node/ParseOp.js +32 -44
  100. package/lib/node/ParsePolygon.js +11 -17
  101. package/lib/node/ParseQuery.js +118 -164
  102. package/lib/node/ParseRelation.js +7 -16
  103. package/lib/node/ParseRole.js +7 -13
  104. package/lib/node/ParseSchema.js +26 -39
  105. package/lib/node/ParseSession.js +7 -8
  106. package/lib/node/ParseUser.js +70 -76
  107. package/lib/node/Push.js +5 -15
  108. package/lib/node/RESTController.js +21 -33
  109. package/lib/node/SingleInstanceStateController.js +41 -69
  110. package/lib/node/Socket.weapp.js +23 -2
  111. package/lib/node/Storage.js +11 -16
  112. package/lib/node/StorageController.browser.js +10 -8
  113. package/lib/node/StorageController.default.js +9 -9
  114. package/lib/node/StorageController.js +16 -1
  115. package/lib/node/StorageController.react-native.js +17 -17
  116. package/lib/node/StorageController.weapp.js +14 -8
  117. package/lib/node/TaskQueue.js +8 -11
  118. package/lib/node/UniqueInstanceStateController.js +40 -60
  119. package/lib/node/WebSocketController.js +15 -2
  120. package/lib/node/Xhr.weapp.js +11 -2
  121. package/lib/node/arrayContainsObject.js +1 -1
  122. package/lib/node/canBeSerialized.js +2 -2
  123. package/lib/node/decode.js +1 -1
  124. package/lib/node/encode.js +2 -2
  125. package/lib/node/equals.js +1 -1
  126. package/lib/node/escape.js +1 -1
  127. package/lib/node/isRevocableSession.js +1 -1
  128. package/lib/node/parseDate.js +1 -1
  129. package/lib/node/promiseUtils.js +7 -7
  130. package/lib/node/unique.js +2 -2
  131. package/lib/node/unsavedChildren.js +2 -2
  132. package/lib/node/uuid.js +2 -4
  133. package/lib/react-native/Analytics.js +2 -2
  134. package/lib/react-native/AnonymousUtils.js +3 -4
  135. package/lib/react-native/Cloud.js +0 -1
  136. package/lib/react-native/CoreManager.js +2 -3
  137. package/lib/react-native/CryptoController.js +6 -1
  138. package/lib/react-native/EventEmitter.js +6 -1
  139. package/lib/react-native/EventuallyQueue.js +1 -2
  140. package/lib/react-native/FacebookUtils.js +1 -2
  141. package/lib/react-native/IndexedDBStorageController.js +11 -5
  142. package/lib/react-native/InstallationController.js +1 -2
  143. package/lib/react-native/LiveQueryClient.js +51 -36
  144. package/lib/react-native/LiveQuerySubscription.js +2 -4
  145. package/lib/react-native/LocalDatastore.js +41 -17
  146. package/lib/react-native/LocalDatastoreController.default.js +6 -1
  147. package/lib/react-native/LocalDatastoreController.js +11 -1
  148. package/lib/react-native/LocalDatastoreController.react-native.js +16 -11
  149. package/lib/react-native/LocalDatastoreUtils.js +3 -6
  150. package/lib/react-native/ObjectStateMutations.js +30 -9
  151. package/lib/react-native/OfflineQuery.js +25 -20
  152. package/lib/react-native/Parse.js +24 -38
  153. package/lib/react-native/ParseACL.js +4 -6
  154. package/lib/react-native/ParseCLP.js +5 -7
  155. package/lib/react-native/ParseConfig.js +4 -6
  156. package/lib/react-native/ParseError.js +13 -31
  157. package/lib/react-native/ParseFile.js +10 -10
  158. package/lib/react-native/ParseGeoPoint.js +2 -4
  159. package/lib/react-native/ParseInstallation.js +13 -30
  160. package/lib/react-native/ParseLiveQuery.js +2 -4
  161. package/lib/react-native/ParseObject.js +81 -90
  162. package/lib/react-native/ParseOp.js +41 -79
  163. package/lib/react-native/ParsePolygon.js +2 -4
  164. package/lib/react-native/ParseQuery.js +87 -81
  165. package/lib/react-native/ParseRelation.js +2 -4
  166. package/lib/react-native/ParseRole.js +14 -31
  167. package/lib/react-native/ParseSchema.js +3 -5
  168. package/lib/react-native/ParseSession.js +12 -29
  169. package/lib/react-native/ParseUser.js +32 -51
  170. package/lib/react-native/RESTController.js +10 -4
  171. package/lib/react-native/SingleInstanceStateController.js +23 -37
  172. package/lib/react-native/Socket.weapp.js +9 -4
  173. package/lib/react-native/Storage.js +1 -2
  174. package/lib/react-native/StorageController.browser.js +6 -1
  175. package/lib/react-native/StorageController.default.js +6 -1
  176. package/lib/react-native/StorageController.js +13 -1
  177. package/lib/react-native/StorageController.react-native.js +11 -6
  178. package/lib/react-native/StorageController.weapp.js +6 -1
  179. package/lib/react-native/TaskQueue.js +8 -4
  180. package/lib/react-native/UniqueInstanceStateController.js +23 -37
  181. package/lib/react-native/WebSocketController.js +9 -1
  182. package/lib/react-native/Xhr.weapp.js +9 -4
  183. package/lib/react-native/unsavedChildren.js +3 -3
  184. package/lib/react-native/uuid.js +1 -2
  185. package/lib/weapp/Analytics.js +7 -11
  186. package/lib/weapp/AnonymousUtils.js +17 -22
  187. package/lib/weapp/Cloud.js +24 -46
  188. package/lib/weapp/CoreManager.js +71 -79
  189. package/lib/weapp/CryptoController.js +14 -9
  190. package/lib/weapp/EventEmitter.js +9 -2
  191. package/lib/weapp/EventuallyQueue.js +156 -357
  192. package/lib/weapp/FacebookUtils.js +23 -28
  193. package/lib/weapp/IndexedDBStorageController.js +18 -14
  194. package/lib/weapp/InstallationController.js +55 -121
  195. package/lib/weapp/LiveQueryClient.js +312 -446
  196. package/lib/weapp/LiveQuerySubscription.js +25 -28
  197. package/lib/weapp/LocalDatastore.js +254 -578
  198. package/lib/weapp/LocalDatastoreController.default.js +48 -227
  199. package/lib/weapp/LocalDatastoreController.js +11 -1
  200. package/lib/weapp/LocalDatastoreController.react-native.js +72 -164
  201. package/lib/weapp/LocalDatastoreUtils.js +4 -12
  202. package/lib/weapp/ObjectStateMutations.js +89 -95
  203. package/lib/weapp/OfflineQuery.js +106 -198
  204. package/lib/weapp/Parse.js +45 -60
  205. package/lib/weapp/ParseACL.js +242 -288
  206. package/lib/weapp/ParseCLP.js +372 -580
  207. package/lib/weapp/ParseConfig.js +115 -138
  208. package/lib/weapp/ParseError.js +85 -182
  209. package/lib/weapp/ParseFile.js +297 -446
  210. package/lib/weapp/ParseGeoPoint.js +121 -140
  211. package/lib/weapp/ParseHooks.js +12 -14
  212. package/lib/weapp/ParseInstallation.js +226 -354
  213. package/lib/weapp/ParseLiveQuery.js +74 -148
  214. package/lib/weapp/ParseObject.js +2017 -2622
  215. package/lib/weapp/ParseOp.js +343 -484
  216. package/lib/weapp/ParsePolygon.js +101 -120
  217. package/lib/weapp/ParseQuery.js +1722 -2068
  218. package/lib/weapp/ParseRelation.js +99 -118
  219. package/lib/weapp/ParseRole.js +88 -144
  220. package/lib/weapp/ParseSchema.js +372 -434
  221. package/lib/weapp/ParseSession.js +62 -110
  222. package/lib/weapp/ParseUser.js +942 -1270
  223. package/lib/weapp/Push.js +16 -44
  224. package/lib/weapp/RESTController.js +86 -125
  225. package/lib/weapp/SingleInstanceStateController.js +57 -86
  226. package/lib/weapp/Socket.weapp.js +50 -33
  227. package/lib/weapp/Storage.js +23 -28
  228. package/lib/weapp/StorageController.browser.js +16 -13
  229. package/lib/weapp/StorageController.default.js +15 -14
  230. package/lib/weapp/StorageController.js +14 -1
  231. package/lib/weapp/StorageController.react-native.js +31 -30
  232. package/lib/weapp/StorageController.weapp.js +19 -13
  233. package/lib/weapp/TaskQueue.js +37 -49
  234. package/lib/weapp/UniqueInstanceStateController.js +65 -86
  235. package/lib/weapp/WebSocketController.js +11 -4
  236. package/lib/weapp/Xhr.weapp.js +90 -78
  237. package/lib/weapp/arrayContainsObject.js +3 -3
  238. package/lib/weapp/canBeSerialized.js +10 -11
  239. package/lib/weapp/decode.js +11 -11
  240. package/lib/weapp/encode.js +11 -11
  241. package/lib/weapp/equals.js +9 -10
  242. package/lib/weapp/escape.js +2 -2
  243. package/lib/weapp/isRevocableSession.js +1 -1
  244. package/lib/weapp/parseDate.js +10 -10
  245. package/lib/weapp/promiseUtils.js +19 -19
  246. package/lib/weapp/unique.js +4 -4
  247. package/lib/weapp/unsavedChildren.js +20 -21
  248. package/lib/weapp/uuid.js +6 -8
  249. package/package.json +23 -30
@@ -16,11 +16,7 @@ function _interopRequireDefault(obj) {
16
16
  default: obj
17
17
  };
18
18
  }
19
- /**
20
- * @flow
21
- */
22
- /*:: import type ParseObject from './ParseObject';*/
23
- function opFromJSON(json /*: { [key: string]: any }*/) /*: ?Op*/{
19
+ function opFromJSON(json) {
24
20
  if (!json || !json.__op) {
25
21
  return null;
26
22
  }
@@ -69,24 +65,23 @@ function opFromJSON(json /*: { [key: string]: any }*/) /*: ?Op*/{
69
65
  }
70
66
  class Op {
71
67
  // Empty parent class
72
- applyTo() /*: mixed*/{} /* eslint-disable-line no-unused-vars */
73
- mergeWith() /*: ?Op*/{} /* eslint-disable-line no-unused-vars */
74
- toJSON() /*: mixed*/{}
68
+ applyTo() {} /* eslint-disable-line @typescript-eslint/no-unused-vars */
69
+ mergeWith() {} /* eslint-disable-line @typescript-eslint/no-unused-vars */
70
+ toJSON() {} /* eslint-disable-line @typescript-eslint/no-unused-vars */
75
71
  }
76
72
  exports.Op = Op;
77
73
  class SetOp extends Op {
78
- /*:: _value: ?mixed;*/
79
- constructor(value /*: mixed*/) {
74
+ constructor(value) {
80
75
  super();
81
76
  this._value = value;
82
77
  }
83
- applyTo() /*: mixed*/{
78
+ applyTo() {
84
79
  return this._value;
85
80
  }
86
- mergeWith() /*: SetOp*/{
81
+ mergeWith() {
87
82
  return new SetOp(this._value);
88
83
  }
89
- toJSON(offline /*:: ?: boolean*/) {
84
+ toJSON(offline) {
90
85
  return (0, _encode.default)(this._value, false, true, undefined, offline);
91
86
  }
92
87
  }
@@ -95,10 +90,10 @@ class UnsetOp extends Op {
95
90
  applyTo() {
96
91
  return undefined;
97
92
  }
98
- mergeWith() /*: UnsetOp*/{
93
+ mergeWith() {
99
94
  return new UnsetOp();
100
95
  }
101
- toJSON() /*: { __op: string }*/{
96
+ toJSON() {
102
97
  return {
103
98
  __op: 'Delete'
104
99
  };
@@ -106,15 +101,14 @@ class UnsetOp extends Op {
106
101
  }
107
102
  exports.UnsetOp = UnsetOp;
108
103
  class IncrementOp extends Op {
109
- /*:: _amount: number;*/
110
- constructor(amount /*: number*/) {
104
+ constructor(amount) {
111
105
  super();
112
106
  if (typeof amount !== 'number') {
113
107
  throw new TypeError('Increment Op must be initialized with a numeric amount.');
114
108
  }
115
109
  this._amount = amount;
116
110
  }
117
- applyTo(value /*: ?mixed*/) /*: number*/{
111
+ applyTo(value) {
118
112
  if (typeof value === 'undefined') {
119
113
  return this._amount;
120
114
  }
@@ -123,7 +117,7 @@ class IncrementOp extends Op {
123
117
  }
124
118
  return this._amount + value;
125
119
  }
126
- mergeWith(previous /*: Op*/) /*: Op*/{
120
+ mergeWith(previous) {
127
121
  if (!previous) {
128
122
  return this;
129
123
  }
@@ -138,7 +132,7 @@ class IncrementOp extends Op {
138
132
  }
139
133
  throw new Error('Cannot merge Increment Op with the previous Op');
140
134
  }
141
- toJSON() /*: { __op: string, amount: number }*/{
135
+ toJSON() {
142
136
  return {
143
137
  __op: 'Increment',
144
138
  amount: this._amount
@@ -147,12 +141,11 @@ class IncrementOp extends Op {
147
141
  }
148
142
  exports.IncrementOp = IncrementOp;
149
143
  class AddOp extends Op {
150
- /*:: _value: Array<mixed>;*/
151
- constructor(value /*: mixed | Array<mixed>*/) {
144
+ constructor(value) {
152
145
  super();
153
146
  this._value = Array.isArray(value) ? value : [value];
154
147
  }
155
- applyTo(value /*: mixed*/) /*: Array<mixed>*/{
148
+ applyTo(value) {
156
149
  if (value == null) {
157
150
  return this._value;
158
151
  }
@@ -161,7 +154,7 @@ class AddOp extends Op {
161
154
  }
162
155
  throw new Error('Cannot add elements to a non-array value');
163
156
  }
164
- mergeWith(previous /*: Op*/) /*: Op*/{
157
+ mergeWith(previous) {
165
158
  if (!previous) {
166
159
  return this;
167
160
  }
@@ -176,7 +169,7 @@ class AddOp extends Op {
176
169
  }
177
170
  throw new Error('Cannot merge Add Op with the previous Op');
178
171
  }
179
- toJSON() /*: { __op: string, objects: mixed }*/{
172
+ toJSON() {
180
173
  return {
181
174
  __op: 'Add',
182
175
  objects: (0, _encode.default)(this._value, false, true)
@@ -185,12 +178,11 @@ class AddOp extends Op {
185
178
  }
186
179
  exports.AddOp = AddOp;
187
180
  class AddUniqueOp extends Op {
188
- /*:: _value: Array<mixed>;*/
189
- constructor(value /*: mixed | Array<mixed>*/) {
181
+ constructor(value) {
190
182
  super();
191
183
  this._value = (0, _unique.default)(Array.isArray(value) ? value : [value]);
192
184
  }
193
- applyTo(value /*: mixed | Array<mixed>*/) /*: Array<mixed>*/{
185
+ applyTo(value) {
194
186
  if (value == null) {
195
187
  return this._value || [];
196
188
  }
@@ -212,7 +204,7 @@ class AddUniqueOp extends Op {
212
204
  }
213
205
  throw new Error('Cannot add elements to a non-array value');
214
206
  }
215
- mergeWith(previous /*: Op*/) /*: Op*/{
207
+ mergeWith(previous) {
216
208
  if (!previous) {
217
209
  return this;
218
210
  }
@@ -227,7 +219,7 @@ class AddUniqueOp extends Op {
227
219
  }
228
220
  throw new Error('Cannot merge AddUnique Op with the previous Op');
229
221
  }
230
- toJSON() /*: { __op: string, objects: mixed }*/{
222
+ toJSON() {
231
223
  return {
232
224
  __op: 'AddUnique',
233
225
  objects: (0, _encode.default)(this._value, false, true)
@@ -236,12 +228,11 @@ class AddUniqueOp extends Op {
236
228
  }
237
229
  exports.AddUniqueOp = AddUniqueOp;
238
230
  class RemoveOp extends Op {
239
- /*:: _value: Array<mixed>;*/
240
- constructor(value /*: mixed | Array<mixed>*/) {
231
+ constructor(value) {
241
232
  super();
242
233
  this._value = (0, _unique.default)(Array.isArray(value) ? value : [value]);
243
234
  }
244
- applyTo(value /*: mixed | Array<mixed>*/) /*: Array<mixed>*/{
235
+ applyTo(value) {
245
236
  if (value == null) {
246
237
  return [];
247
238
  }
@@ -268,7 +259,7 @@ class RemoveOp extends Op {
268
259
  }
269
260
  throw new Error('Cannot remove elements from a non-array value');
270
261
  }
271
- mergeWith(previous /*: Op*/) /*: Op*/{
262
+ mergeWith(previous) {
272
263
  if (!previous) {
273
264
  return this;
274
265
  }
@@ -296,7 +287,7 @@ class RemoveOp extends Op {
296
287
  }
297
288
  throw new Error('Cannot merge Remove Op with the previous Op');
298
289
  }
299
- toJSON() /*: { __op: string, objects: mixed }*/{
290
+ toJSON() {
300
291
  return {
301
292
  __op: 'Remove',
302
293
  objects: (0, _encode.default)(this._value, false, true)
@@ -305,10 +296,7 @@ class RemoveOp extends Op {
305
296
  }
306
297
  exports.RemoveOp = RemoveOp;
307
298
  class RelationOp extends Op {
308
- /*:: _targetClassName: ?string;*/
309
- /*:: relationsToAdd: Array<string>;*/
310
- /*:: relationsToRemove: Array<string>;*/
311
- constructor(adds /*: Array<ParseObject | string>*/, removes /*: Array<ParseObject | string>*/) {
299
+ constructor(adds, removes) {
312
300
  super();
313
301
  this._targetClassName = null;
314
302
  if (Array.isArray(adds)) {
@@ -318,7 +306,7 @@ class RelationOp extends Op {
318
306
  this.relationsToRemove = (0, _unique.default)(removes.map(this._extractId, this));
319
307
  }
320
308
  }
321
- _extractId(obj /*: string | ParseObject*/) /*: string*/{
309
+ _extractId(obj) {
322
310
  if (typeof obj === 'string') {
323
311
  return obj;
324
312
  }
@@ -333,7 +321,7 @@ class RelationOp extends Op {
333
321
  }
334
322
  return obj.id;
335
323
  }
336
- applyTo(value /*: mixed*/, parent /*: ParseObject*/, key /*:: ?: string*/) /*: ?ParseRelation*/{
324
+ applyTo(value, parent, key) {
337
325
  if (!value) {
338
326
  if (!parent || !key) {
339
327
  throw new Error('Cannot apply a RelationOp without either a previous value, or an object and a key');
@@ -357,7 +345,7 @@ class RelationOp extends Op {
357
345
  throw new Error('Relation cannot be applied to a non-relation field');
358
346
  }
359
347
  }
360
- mergeWith(previous /*: Op*/) /*: Op*/{
348
+ mergeWith(previous) {
361
349
  if (!previous) {
362
350
  return this;
363
351
  } else if (previous instanceof UnsetOp) {
@@ -400,7 +388,7 @@ class RelationOp extends Op {
400
388
  }
401
389
  throw new Error('Cannot merge Relation Op with the previous Op');
402
390
  }
403
- toJSON() /*: { __op?: string, objects?: mixed, ops?: mixed }*/{
391
+ toJSON() {
404
392
  const idToPointer = id => {
405
393
  return {
406
394
  __type: 'Pointer',
@@ -408,9 +396,9 @@ class RelationOp extends Op {
408
396
  objectId: id
409
397
  };
410
398
  };
399
+ let pointers = null;
411
400
  let adds = null;
412
401
  let removes = null;
413
- let pointers = null;
414
402
  if (this.relationsToAdd.length > 0) {
415
403
  pointers = this.relationsToAdd.map(idToPointer);
416
404
  adds = {
@@ -10,10 +10,6 @@ function _interopRequireDefault(obj) {
10
10
  default: obj
11
11
  };
12
12
  }
13
- /**
14
- * @flow
15
- */
16
-
17
13
  /**
18
14
  * Creates a new Polygon with any of the following forms:<br>
19
15
  * <pre>
@@ -34,11 +30,10 @@ function _interopRequireDefault(obj) {
34
30
  * @alias Parse.Polygon
35
31
  */
36
32
  class ParsePolygon {
37
- /*:: _coordinates: Array<Array<number>>;*/
38
33
  /**
39
- * @param {(number[][] | Parse.GeoPoint[])} coordinates An Array of coordinate pairs
34
+ * @param {(Coordinates | Parse.GeoPoint[])} coordinates An Array of coordinate pairs
40
35
  */
41
- constructor(coordinates /*: Array<Array<number>> | Array<ParseGeoPoint>*/) {
36
+ constructor(coordinates) {
42
37
  this._coordinates = ParsePolygon._validate(coordinates);
43
38
  }
44
39
 
@@ -46,13 +41,13 @@ class ParsePolygon {
46
41
  * Coordinates value for this Polygon.
47
42
  * Throws an exception if not valid type.
48
43
  *
49
- * @property {(number[][] | Parse.GeoPoint[])} coordinates list of coordinates
50
- * @returns {number[][]}
44
+ * @property {(Coordinates | Parse.GeoPoint[])} coordinates list of coordinates
45
+ * @returns {Coordinates}
51
46
  */
52
- get coordinates() /*: Array<Array<number>>*/{
47
+ get coordinates() {
53
48
  return this._coordinates;
54
49
  }
55
- set coordinates(coords /*: Array<Array<number>> | Array<ParseGeoPoint>*/) {
50
+ set coordinates(coords) {
56
51
  this._coordinates = ParsePolygon._validate(coords);
57
52
  }
58
53
 
@@ -61,7 +56,7 @@ class ParsePolygon {
61
56
  *
62
57
  * @returns {object}
63
58
  */
64
- toJSON() /*: { __type: string, coordinates: Array<Array<number>> }*/{
59
+ toJSON() {
65
60
  ParsePolygon._validate(this._coordinates);
66
61
  return {
67
62
  __type: 'Polygon',
@@ -75,7 +70,7 @@ class ParsePolygon {
75
70
  * @param {(Parse.Polygon | object)} other
76
71
  * @returns {boolean}
77
72
  */
78
- equals(other /*: mixed*/) /*: boolean*/{
73
+ equals(other) {
79
74
  if (!(other instanceof ParsePolygon) || this.coordinates.length !== other.coordinates.length) {
80
75
  return false;
81
76
  }
@@ -94,7 +89,7 @@ class ParsePolygon {
94
89
  * @param {Parse.GeoPoint} point
95
90
  * @returns {boolean} Returns if the point is contained in the polygon
96
91
  */
97
- containsPoint(point /*: ParseGeoPoint*/) /*: boolean*/{
92
+ containsPoint(point) {
98
93
  let minX = this._coordinates[0][0];
99
94
  let maxX = this._coordinates[0][0];
100
95
  let minY = this._coordinates[0][1];
@@ -131,7 +126,7 @@ class ParsePolygon {
131
126
  * @throws {TypeError}
132
127
  * @returns {number[][]} Array of coordinates if validated.
133
128
  */
134
- static _validate(coords /*: Array<Array<number>> | Array<ParseGeoPoint>*/) /*: Array<Array<number>>*/{
129
+ static _validate(coords) {
135
130
  if (!Array.isArray(coords)) {
136
131
  throw new TypeError('Coordinates must be an Array');
137
132
  }
@@ -154,5 +149,4 @@ class ParsePolygon {
154
149
  return points;
155
150
  }
156
151
  }
157
- var _default = ParsePolygon;
158
- exports.default = _default;
152
+ var _default = exports.default = ParsePolygon;