parse 4.0.0-alpha.1 → 4.0.0-alpha.11

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 +35 -31
  255. package/PATENTS +0 -37
@@ -1,58 +1,39 @@
1
1
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
3
  value: true
5
4
  });
6
5
  exports.UnsetOp = exports.SetOp = exports.RemoveOp = exports.RelationOp = exports.Op = exports.IncrementOp = exports.AddUniqueOp = exports.AddOp = void 0;
7
6
  exports.opFromJSON = opFromJSON;
8
-
9
7
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
10
-
11
8
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
12
-
13
9
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
14
-
15
10
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
16
-
17
11
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
18
-
19
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
20
-
21
13
  var _arrayContainsObject = _interopRequireDefault(require("./arrayContainsObject"));
22
-
23
14
  var _decode = _interopRequireDefault(require("./decode"));
24
-
25
15
  var _encode = _interopRequireDefault(require("./encode"));
26
-
27
16
  var _ParseObject = _interopRequireDefault(require("./ParseObject"));
28
-
29
17
  var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
30
-
31
18
  var _unique = _interopRequireDefault(require("./unique"));
32
-
33
19
  function _createSuper(Derived) {
34
20
  var hasNativeReflectConstruct = _isNativeReflectConstruct();
35
-
36
21
  return function () {
37
22
  var Super = (0, _getPrototypeOf2.default)(Derived),
38
- result;
39
-
23
+ result;
40
24
  if (hasNativeReflectConstruct) {
41
25
  var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
42
26
  result = Reflect.construct(Super, arguments, NewTarget);
43
27
  } else {
44
28
  result = Super.apply(this, arguments);
45
29
  }
46
-
47
30
  return (0, _possibleConstructorReturn2.default)(this, result);
48
31
  };
49
32
  }
50
-
51
33
  function _isNativeReflectConstruct() {
52
34
  if (typeof Reflect === "undefined" || !Reflect.construct) return false;
53
35
  if (Reflect.construct.sham) return false;
54
36
  if (typeof Proxy === "function") return true;
55
-
56
37
  try {
57
38
  Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
58
39
  return true;
@@ -60,55 +41,41 @@ function _isNativeReflectConstruct() {
60
41
  return false;
61
42
  }
62
43
  }
63
-
64
44
  function opFromJSON(json) {
65
45
  if (!json || !json.__op) {
66
46
  return null;
67
47
  }
68
-
69
48
  switch (json.__op) {
70
49
  case 'Delete':
71
50
  return new UnsetOp();
72
-
73
51
  case 'Increment':
74
52
  return new IncrementOp(json.amount);
75
-
76
53
  case 'Add':
77
54
  return new AddOp((0, _decode.default)(json.objects));
78
-
79
55
  case 'AddUnique':
80
56
  return new AddUniqueOp((0, _decode.default)(json.objects));
81
-
82
57
  case 'Remove':
83
58
  return new RemoveOp((0, _decode.default)(json.objects));
84
-
85
59
  case 'AddRelation':
86
60
  {
87
61
  var toAdd = (0, _decode.default)(json.objects);
88
-
89
62
  if (!Array.isArray(toAdd)) {
90
63
  return new RelationOp([], []);
91
64
  }
92
-
93
65
  return new RelationOp(toAdd, []);
94
66
  }
95
-
96
67
  case 'RemoveRelation':
97
68
  {
98
69
  var toRemove = (0, _decode.default)(json.objects);
99
-
100
70
  if (!Array.isArray(toRemove)) {
101
71
  return new RelationOp([], []);
102
72
  }
103
-
104
73
  return new RelationOp([], toRemove);
105
74
  }
106
-
107
75
  case 'Batch':
108
76
  {
109
77
  var _toAdd = [];
110
78
  var _toRemove = [];
111
-
112
79
  for (var i = 0; i < json.ops.length; i++) {
113
80
  if (json.ops[i].__op === 'AddRelation') {
114
81
  _toAdd = _toAdd.concat((0, _decode.default)(json.ops[i].objects));
@@ -116,19 +83,15 @@ function opFromJSON(json) {
116
83
  _toRemove = _toRemove.concat((0, _decode.default)(json.ops[i].objects));
117
84
  }
118
85
  }
119
-
120
86
  return new RelationOp(_toAdd, _toRemove);
121
87
  }
122
88
  }
123
-
124
89
  return null;
125
90
  }
126
-
127
91
  var Op = function () {
128
92
  function Op() {
129
93
  (0, _classCallCheck2.default)(this, Op);
130
94
  }
131
-
132
95
  (0, _createClass2.default)(Op, [{
133
96
  key: "applyTo",
134
97
  value: function () {}
@@ -141,23 +104,17 @@ var Op = function () {
141
104
  }]);
142
105
  return Op;
143
106
  }();
144
-
145
107
  exports.Op = Op;
146
-
147
108
  var SetOp = function (_Op) {
148
109
  (0, _inherits2.default)(SetOp, _Op);
149
-
150
110
  var _super = _createSuper(SetOp);
151
-
152
111
  function SetOp(value) {
153
112
  var _this;
154
-
155
113
  (0, _classCallCheck2.default)(this, SetOp);
156
114
  _this = _super.call(this);
157
115
  _this._value = value;
158
116
  return _this;
159
117
  }
160
-
161
118
  (0, _createClass2.default)(SetOp, [{
162
119
  key: "applyTo",
163
120
  value: function () {
@@ -176,19 +133,14 @@ var SetOp = function (_Op) {
176
133
  }]);
177
134
  return SetOp;
178
135
  }(Op);
179
-
180
136
  exports.SetOp = SetOp;
181
-
182
137
  var UnsetOp = function (_Op2) {
183
138
  (0, _inherits2.default)(UnsetOp, _Op2);
184
-
185
139
  var _super2 = _createSuper(UnsetOp);
186
-
187
140
  function UnsetOp() {
188
141
  (0, _classCallCheck2.default)(this, UnsetOp);
189
142
  return _super2.apply(this, arguments);
190
143
  }
191
-
192
144
  (0, _createClass2.default)(UnsetOp, [{
193
145
  key: "applyTo",
194
146
  value: function () {
@@ -209,39 +161,29 @@ var UnsetOp = function (_Op2) {
209
161
  }]);
210
162
  return UnsetOp;
211
163
  }(Op);
212
-
213
164
  exports.UnsetOp = UnsetOp;
214
-
215
165
  var IncrementOp = function (_Op3) {
216
166
  (0, _inherits2.default)(IncrementOp, _Op3);
217
-
218
167
  var _super3 = _createSuper(IncrementOp);
219
-
220
168
  function IncrementOp(amount) {
221
169
  var _this2;
222
-
223
170
  (0, _classCallCheck2.default)(this, IncrementOp);
224
171
  _this2 = _super3.call(this);
225
-
226
172
  if (typeof amount !== 'number') {
227
173
  throw new TypeError('Increment Op must be initialized with a numeric amount.');
228
174
  }
229
-
230
175
  _this2._amount = amount;
231
176
  return _this2;
232
177
  }
233
-
234
178
  (0, _createClass2.default)(IncrementOp, [{
235
179
  key: "applyTo",
236
180
  value: function (value) {
237
181
  if (typeof value === 'undefined') {
238
182
  return this._amount;
239
183
  }
240
-
241
184
  if (typeof value !== 'number') {
242
185
  throw new TypeError('Cannot increment a non-numeric value.');
243
186
  }
244
-
245
187
  return this._amount + value;
246
188
  }
247
189
  }, {
@@ -250,19 +192,15 @@ var IncrementOp = function (_Op3) {
250
192
  if (!previous) {
251
193
  return this;
252
194
  }
253
-
254
195
  if (previous instanceof SetOp) {
255
196
  return new SetOp(this.applyTo(previous._value));
256
197
  }
257
-
258
198
  if (previous instanceof UnsetOp) {
259
199
  return new SetOp(this._amount);
260
200
  }
261
-
262
201
  if (previous instanceof IncrementOp) {
263
202
  return new IncrementOp(this.applyTo(previous._amount));
264
203
  }
265
-
266
204
  throw new Error('Cannot merge Increment Op with the previous Op');
267
205
  }
268
206
  }, {
@@ -276,34 +214,26 @@ var IncrementOp = function (_Op3) {
276
214
  }]);
277
215
  return IncrementOp;
278
216
  }(Op);
279
-
280
217
  exports.IncrementOp = IncrementOp;
281
-
282
218
  var AddOp = function (_Op4) {
283
219
  (0, _inherits2.default)(AddOp, _Op4);
284
-
285
220
  var _super4 = _createSuper(AddOp);
286
-
287
221
  function AddOp(value) {
288
222
  var _this3;
289
-
290
223
  (0, _classCallCheck2.default)(this, AddOp);
291
224
  _this3 = _super4.call(this);
292
225
  _this3._value = Array.isArray(value) ? value : [value];
293
226
  return _this3;
294
227
  }
295
-
296
228
  (0, _createClass2.default)(AddOp, [{
297
229
  key: "applyTo",
298
230
  value: function (value) {
299
231
  if (value == null) {
300
232
  return this._value;
301
233
  }
302
-
303
234
  if (Array.isArray(value)) {
304
235
  return value.concat(this._value);
305
236
  }
306
-
307
237
  throw new Error('Cannot add elements to a non-array value');
308
238
  }
309
239
  }, {
@@ -312,19 +242,15 @@ var AddOp = function (_Op4) {
312
242
  if (!previous) {
313
243
  return this;
314
244
  }
315
-
316
245
  if (previous instanceof SetOp) {
317
246
  return new SetOp(this.applyTo(previous._value));
318
247
  }
319
-
320
248
  if (previous instanceof UnsetOp) {
321
249
  return new SetOp(this._value);
322
250
  }
323
-
324
251
  if (previous instanceof AddOp) {
325
252
  return new AddOp(this.applyTo(previous._value));
326
253
  }
327
-
328
254
  throw new Error('Cannot merge Add Op with the previous Op');
329
255
  }
330
256
  }, {
@@ -338,33 +264,25 @@ var AddOp = function (_Op4) {
338
264
  }]);
339
265
  return AddOp;
340
266
  }(Op);
341
-
342
267
  exports.AddOp = AddOp;
343
-
344
268
  var AddUniqueOp = function (_Op5) {
345
269
  (0, _inherits2.default)(AddUniqueOp, _Op5);
346
-
347
270
  var _super5 = _createSuper(AddUniqueOp);
348
-
349
271
  function AddUniqueOp(value) {
350
272
  var _this4;
351
-
352
273
  (0, _classCallCheck2.default)(this, AddUniqueOp);
353
274
  _this4 = _super5.call(this);
354
275
  _this4._value = (0, _unique.default)(Array.isArray(value) ? value : [value]);
355
276
  return _this4;
356
277
  }
357
-
358
278
  (0, _createClass2.default)(AddUniqueOp, [{
359
279
  key: "applyTo",
360
280
  value: function (value) {
361
281
  if (value == null) {
362
282
  return this._value || [];
363
283
  }
364
-
365
284
  if (Array.isArray(value)) {
366
285
  var toAdd = [];
367
-
368
286
  this._value.forEach(function (v) {
369
287
  if (v instanceof _ParseObject.default) {
370
288
  if (!(0, _arrayContainsObject.default)(value, v)) {
@@ -376,10 +294,8 @@ var AddUniqueOp = function (_Op5) {
376
294
  }
377
295
  }
378
296
  });
379
-
380
297
  return value.concat(toAdd);
381
298
  }
382
-
383
299
  throw new Error('Cannot add elements to a non-array value');
384
300
  }
385
301
  }, {
@@ -388,19 +304,15 @@ var AddUniqueOp = function (_Op5) {
388
304
  if (!previous) {
389
305
  return this;
390
306
  }
391
-
392
307
  if (previous instanceof SetOp) {
393
308
  return new SetOp(this.applyTo(previous._value));
394
309
  }
395
-
396
310
  if (previous instanceof UnsetOp) {
397
311
  return new SetOp(this._value);
398
312
  }
399
-
400
313
  if (previous instanceof AddUniqueOp) {
401
314
  return new AddUniqueOp(this.applyTo(previous._value));
402
315
  }
403
-
404
316
  throw new Error('Cannot merge AddUnique Op with the previous Op');
405
317
  }
406
318
  }, {
@@ -414,41 +326,31 @@ var AddUniqueOp = function (_Op5) {
414
326
  }]);
415
327
  return AddUniqueOp;
416
328
  }(Op);
417
-
418
329
  exports.AddUniqueOp = AddUniqueOp;
419
-
420
330
  var RemoveOp = function (_Op6) {
421
331
  (0, _inherits2.default)(RemoveOp, _Op6);
422
-
423
332
  var _super6 = _createSuper(RemoveOp);
424
-
425
333
  function RemoveOp(value) {
426
334
  var _this5;
427
-
428
335
  (0, _classCallCheck2.default)(this, RemoveOp);
429
336
  _this5 = _super6.call(this);
430
337
  _this5._value = (0, _unique.default)(Array.isArray(value) ? value : [value]);
431
338
  return _this5;
432
339
  }
433
-
434
340
  (0, _createClass2.default)(RemoveOp, [{
435
341
  key: "applyTo",
436
342
  value: function (value) {
437
343
  if (value == null) {
438
344
  return [];
439
345
  }
440
-
441
346
  if (Array.isArray(value)) {
442
347
  var removed = value.concat([]);
443
-
444
348
  for (var i = 0; i < this._value.length; i++) {
445
349
  var index = removed.indexOf(this._value[i]);
446
-
447
350
  while (index > -1) {
448
351
  removed.splice(index, 1);
449
352
  index = removed.indexOf(this._value[i]);
450
353
  }
451
-
452
354
  if (this._value[i] instanceof _ParseObject.default && this._value[i].id) {
453
355
  for (var j = 0; j < removed.length; j++) {
454
356
  if (removed[j] instanceof _ParseObject.default && this._value[i].id === removed[j].id) {
@@ -458,10 +360,8 @@ var RemoveOp = function (_Op6) {
458
360
  }
459
361
  }
460
362
  }
461
-
462
363
  return removed;
463
364
  }
464
-
465
365
  throw new Error('Cannot remove elements from a non-array value');
466
366
  }
467
367
  }, {
@@ -470,18 +370,14 @@ var RemoveOp = function (_Op6) {
470
370
  if (!previous) {
471
371
  return this;
472
372
  }
473
-
474
373
  if (previous instanceof SetOp) {
475
374
  return new SetOp(this.applyTo(previous._value));
476
375
  }
477
-
478
376
  if (previous instanceof UnsetOp) {
479
377
  return new UnsetOp();
480
378
  }
481
-
482
379
  if (previous instanceof RemoveOp) {
483
380
  var uniques = previous._value.concat([]);
484
-
485
381
  for (var i = 0; i < this._value.length; i++) {
486
382
  if (this._value[i] instanceof _ParseObject.default) {
487
383
  if (!(0, _arrayContainsObject.default)(uniques, this._value[i])) {
@@ -493,10 +389,8 @@ var RemoveOp = function (_Op6) {
493
389
  }
494
390
  }
495
391
  }
496
-
497
392
  return new RemoveOp(uniques);
498
393
  }
499
-
500
394
  throw new Error('Cannot merge Remove Op with the previous Op');
501
395
  }
502
396
  }, {
@@ -510,51 +404,38 @@ var RemoveOp = function (_Op6) {
510
404
  }]);
511
405
  return RemoveOp;
512
406
  }(Op);
513
-
514
407
  exports.RemoveOp = RemoveOp;
515
-
516
408
  var RelationOp = function (_Op7) {
517
409
  (0, _inherits2.default)(RelationOp, _Op7);
518
-
519
410
  var _super7 = _createSuper(RelationOp);
520
-
521
411
  function RelationOp(adds, removes) {
522
412
  var _this6;
523
-
524
413
  (0, _classCallCheck2.default)(this, RelationOp);
525
414
  _this6 = _super7.call(this);
526
415
  _this6._targetClassName = null;
527
-
528
416
  if (Array.isArray(adds)) {
529
417
  _this6.relationsToAdd = (0, _unique.default)(adds.map(_this6._extractId, (0, _assertThisInitialized2.default)(_this6)));
530
418
  }
531
-
532
419
  if (Array.isArray(removes)) {
533
420
  _this6.relationsToRemove = (0, _unique.default)(removes.map(_this6._extractId, (0, _assertThisInitialized2.default)(_this6)));
534
421
  }
535
-
536
422
  return _this6;
537
423
  }
538
-
539
424
  (0, _createClass2.default)(RelationOp, [{
540
425
  key: "_extractId",
541
426
  value: function (obj) {
542
427
  if (typeof obj === 'string') {
543
428
  return obj;
544
429
  }
545
-
546
430
  if (!obj.id) {
547
431
  throw new Error('You cannot add or remove an unsaved Parse Object from a relation');
548
432
  }
549
-
550
433
  if (!this._targetClassName) {
551
434
  this._targetClassName = obj.className;
552
435
  }
553
-
554
436
  if (this._targetClassName !== obj.className) {
555
437
  throw new Error('Tried to create a Relation with 2 different object types: ' + this._targetClassName + ' and ' + obj.className + '.');
556
438
  }
557
-
558
439
  return obj.id;
559
440
  }
560
441
  }, {
@@ -564,20 +445,16 @@ var RelationOp = function (_Op7) {
564
445
  if (!object || !key) {
565
446
  throw new Error('Cannot apply a RelationOp without either a previous value, or an object and a key');
566
447
  }
567
-
568
448
  var parent = new _ParseObject.default(object.className);
569
-
570
449
  if (object.id && object.id.indexOf('local') === 0) {
571
450
  parent._localId = object.id;
572
451
  } else if (object.id) {
573
452
  parent.id = object.id;
574
453
  }
575
-
576
454
  var relation = new _ParseRelation.default(parent, key);
577
455
  relation.targetClassName = this._targetClassName;
578
456
  return relation;
579
457
  }
580
-
581
458
  if (value instanceof _ParseRelation.default) {
582
459
  if (this._targetClassName) {
583
460
  if (value.targetClassName) {
@@ -588,7 +465,6 @@ var RelationOp = function (_Op7) {
588
465
  value.targetClassName = this._targetClassName;
589
466
  }
590
467
  }
591
-
592
468
  return value;
593
469
  } else {
594
470
  throw new Error('Relation cannot be applied to a non-relation field');
@@ -607,18 +483,15 @@ var RelationOp = function (_Op7) {
607
483
  if (previous._targetClassName && previous._targetClassName !== this._targetClassName) {
608
484
  throw new Error('Related object must be of class ' + previous._targetClassName + ', but ' + (this._targetClassName || 'null') + ' was passed in.');
609
485
  }
610
-
611
486
  var newAdd = previous.relationsToAdd.concat([]);
612
487
  this.relationsToRemove.forEach(function (r) {
613
488
  var index = newAdd.indexOf(r);
614
-
615
489
  if (index > -1) {
616
490
  newAdd.splice(index, 1);
617
491
  }
618
492
  });
619
493
  this.relationsToAdd.forEach(function (r) {
620
494
  var index = newAdd.indexOf(r);
621
-
622
495
  if (index < 0) {
623
496
  newAdd.push(r);
624
497
  }
@@ -626,14 +499,12 @@ var RelationOp = function (_Op7) {
626
499
  var newRemove = previous.relationsToRemove.concat([]);
627
500
  this.relationsToAdd.forEach(function (r) {
628
501
  var index = newRemove.indexOf(r);
629
-
630
502
  if (index > -1) {
631
503
  newRemove.splice(index, 1);
632
504
  }
633
505
  });
634
506
  this.relationsToRemove.forEach(function (r) {
635
507
  var index = newRemove.indexOf(r);
636
-
637
508
  if (index < 0) {
638
509
  newRemove.push(r);
639
510
  }
@@ -642,14 +513,12 @@ var RelationOp = function (_Op7) {
642
513
  newRelation._targetClassName = this._targetClassName;
643
514
  return newRelation;
644
515
  }
645
-
646
516
  throw new Error('Cannot merge Relation Op with the previous Op');
647
517
  }
648
518
  }, {
649
519
  key: "toJSON",
650
520
  value: function () {
651
521
  var _this7 = this;
652
-
653
522
  var idToPointer = function (id) {
654
523
  return {
655
524
  __type: 'Pointer',
@@ -657,11 +526,9 @@ var RelationOp = function (_Op7) {
657
526
  objectId: id
658
527
  };
659
528
  };
660
-
661
529
  var adds = null;
662
530
  var removes = null;
663
531
  var pointers = null;
664
-
665
532
  if (this.relationsToAdd.length > 0) {
666
533
  pointers = this.relationsToAdd.map(idToPointer);
667
534
  adds = {
@@ -669,7 +536,6 @@ var RelationOp = function (_Op7) {
669
536
  objects: pointers
670
537
  };
671
538
  }
672
-
673
539
  if (this.relationsToRemove.length > 0) {
674
540
  pointers = this.relationsToRemove.map(idToPointer);
675
541
  removes = {
@@ -677,18 +543,15 @@ var RelationOp = function (_Op7) {
677
543
  objects: pointers
678
544
  };
679
545
  }
680
-
681
546
  if (adds && removes) {
682
547
  return {
683
548
  __op: 'Batch',
684
549
  ops: [adds, removes]
685
550
  };
686
551
  }
687
-
688
552
  return adds || removes || {};
689
553
  }
690
554
  }]);
691
555
  return RelationOp;
692
556
  }(Op);
693
-
694
557
  exports.RelationOp = RelationOp;
@@ -1,22 +1,16 @@
1
1
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
3
  value: true
5
4
  });
6
5
  exports.default = void 0;
7
-
8
6
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
-
10
7
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
-
12
8
  var _ParseGeoPoint = _interopRequireDefault(require("./ParseGeoPoint"));
13
-
14
9
  var ParsePolygon = function () {
15
10
  function ParsePolygon(coordinates) {
16
11
  (0, _classCallCheck2.default)(this, ParsePolygon);
17
12
  this._coordinates = ParsePolygon._validate(coordinates);
18
13
  }
19
-
20
14
  (0, _createClass2.default)(ParsePolygon, [{
21
15
  key: "coordinates",
22
16
  get: function () {
@@ -29,7 +23,6 @@ var ParsePolygon = function () {
29
23
  key: "toJSON",
30
24
  value: function () {
31
25
  ParsePolygon._validate(this._coordinates);
32
-
33
26
  return {
34
27
  __type: 'Polygon',
35
28
  coordinates: this._coordinates
@@ -41,16 +34,13 @@ var ParsePolygon = function () {
41
34
  if (!(other instanceof ParsePolygon) || this.coordinates.length !== other.coordinates.length) {
42
35
  return false;
43
36
  }
44
-
45
37
  var isEqual = true;
46
-
47
38
  for (var i = 1; i < this._coordinates.length; i += 1) {
48
39
  if (this._coordinates[i][0] != other.coordinates[i][0] || this._coordinates[i][1] != other.coordinates[i][1]) {
49
40
  isEqual = false;
50
41
  break;
51
42
  }
52
43
  }
53
-
54
44
  return isEqual;
55
45
  }
56
46
  }, {
@@ -60,7 +50,6 @@ var ParsePolygon = function () {
60
50
  var maxX = this._coordinates[0][0];
61
51
  var minY = this._coordinates[0][1];
62
52
  var maxY = this._coordinates[0][1];
63
-
64
53
  for (var i = 1; i < this._coordinates.length; i += 1) {
65
54
  var p = this._coordinates[i];
66
55
  minX = Math.min(p[0], minX);
@@ -68,27 +57,21 @@ var ParsePolygon = function () {
68
57
  minY = Math.min(p[1], minY);
69
58
  maxY = Math.max(p[1], maxY);
70
59
  }
71
-
72
60
  var outside = point.latitude < minX || point.latitude > maxX || point.longitude < minY || point.longitude > maxY;
73
-
74
61
  if (outside) {
75
62
  return false;
76
63
  }
77
-
78
64
  var inside = false;
79
-
80
65
  for (var _i = 0, j = this._coordinates.length - 1; _i < this._coordinates.length; j = _i++) {
81
66
  var startX = this._coordinates[_i][0];
82
67
  var startY = this._coordinates[_i][1];
83
68
  var endX = this._coordinates[j][0];
84
69
  var endY = this._coordinates[j][1];
85
70
  var intersect = startY > point.longitude != endY > point.longitude && point.latitude < (endX - startX) * (point.longitude - startY) / (endY - startY) + startX;
86
-
87
71
  if (intersect) {
88
72
  inside = !inside;
89
73
  }
90
74
  }
91
-
92
75
  return inside;
93
76
  }
94
77
  }], [{
@@ -97,17 +80,13 @@ var ParsePolygon = function () {
97
80
  if (!Array.isArray(coords)) {
98
81
  throw new TypeError('Coordinates must be an Array');
99
82
  }
100
-
101
83
  if (coords.length < 3) {
102
84
  throw new TypeError('Polygon must have at least 3 GeoPoints or Points');
103
85
  }
104
-
105
86
  var points = [];
106
-
107
87
  for (var i = 0; i < coords.length; i += 1) {
108
88
  var coord = coords[i];
109
89
  var geoPoint = void 0;
110
-
111
90
  if (coord instanceof _ParseGeoPoint.default) {
112
91
  geoPoint = coord;
113
92
  } else if (Array.isArray(coord) && coord.length === 2) {
@@ -115,15 +94,12 @@ var ParsePolygon = function () {
115
94
  } else {
116
95
  throw new TypeError('Coordinates must be an Array of GeoPoints or Points');
117
96
  }
118
-
119
97
  points.push([geoPoint.latitude, geoPoint.longitude]);
120
98
  }
121
-
122
99
  return points;
123
100
  }
124
101
  }]);
125
102
  return ParsePolygon;
126
103
  }();
127
-
128
104
  var _default = ParsePolygon;
129
105
  exports.default = _default;