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,79 +1,50 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
-
5
- var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
6
-
7
3
  var _Reflect$construct = require("@babel/runtime-corejs3/core-js-stable/reflect/construct");
8
-
4
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
5
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
9
6
  _Object$defineProperty(exports, "__esModule", {
10
7
  value: true
11
8
  });
12
-
13
9
  exports.UnsetOp = exports.SetOp = exports.RemoveOp = exports.RelationOp = exports.Op = exports.IncrementOp = exports.AddUniqueOp = exports.AddOp = void 0;
14
10
  exports.opFromJSON = opFromJSON;
15
-
16
- var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
17
-
18
- var _splice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/splice"));
19
-
20
- var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
21
-
22
- var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
23
-
24
11
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/assertThisInitialized"));
25
-
26
12
  var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/inherits"));
27
-
28
13
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
29
-
30
14
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/getPrototypeOf"));
31
-
32
15
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
33
-
34
16
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
35
-
36
17
  var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
37
-
38
- var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
39
-
40
18
  var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
41
-
19
+ var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
20
+ var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
21
+ var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
22
+ var _splice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/splice"));
23
+ var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
42
24
  var _arrayContainsObject = _interopRequireDefault(require("./arrayContainsObject"));
43
-
44
25
  var _decode = _interopRequireDefault(require("./decode"));
45
-
46
26
  var _encode = _interopRequireDefault(require("./encode"));
47
-
48
27
  var _ParseObject = _interopRequireDefault(require("./ParseObject"));
49
-
50
28
  var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
51
-
52
29
  var _unique = _interopRequireDefault(require("./unique"));
53
-
54
30
  function _createSuper(Derived) {
55
31
  var hasNativeReflectConstruct = _isNativeReflectConstruct();
56
-
57
32
  return function () {
58
33
  var Super = (0, _getPrototypeOf2.default)(Derived),
59
- result;
60
-
34
+ result;
61
35
  if (hasNativeReflectConstruct) {
62
36
  var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
63
37
  result = _Reflect$construct(Super, arguments, NewTarget);
64
38
  } else {
65
39
  result = Super.apply(this, arguments);
66
40
  }
67
-
68
41
  return (0, _possibleConstructorReturn2.default)(this, result);
69
42
  };
70
43
  }
71
-
72
44
  function _isNativeReflectConstruct() {
73
45
  if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
74
46
  if (_Reflect$construct.sham) return false;
75
47
  if (typeof Proxy === "function") return true;
76
-
77
48
  try {
78
49
  Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
79
50
  return true;
@@ -81,59 +52,41 @@ function _isNativeReflectConstruct() {
81
52
  return false;
82
53
  }
83
54
  }
84
-
85
- function opFromJSON(json
86
- /*: { [key: string]: any }*/
87
- )
88
- /*: ?Op*/
89
- {
55
+ function opFromJSON(json /*: { [key: string]: any }*/) /*: ?Op*/{
90
56
  if (!json || !json.__op) {
91
57
  return null;
92
58
  }
93
-
94
59
  switch (json.__op) {
95
60
  case 'Delete':
96
61
  return new UnsetOp();
97
-
98
62
  case 'Increment':
99
63
  return new IncrementOp(json.amount);
100
-
101
64
  case 'Add':
102
65
  return new AddOp((0, _decode.default)(json.objects));
103
-
104
66
  case 'AddUnique':
105
67
  return new AddUniqueOp((0, _decode.default)(json.objects));
106
-
107
68
  case 'Remove':
108
69
  return new RemoveOp((0, _decode.default)(json.objects));
109
-
110
70
  case 'AddRelation':
111
71
  {
112
72
  var toAdd = (0, _decode.default)(json.objects);
113
-
114
73
  if (!(0, _isArray.default)(toAdd)) {
115
74
  return new RelationOp([], []);
116
75
  }
117
-
118
76
  return new RelationOp(toAdd, []);
119
77
  }
120
-
121
78
  case 'RemoveRelation':
122
79
  {
123
80
  var toRemove = (0, _decode.default)(json.objects);
124
-
125
81
  if (!(0, _isArray.default)(toRemove)) {
126
82
  return new RelationOp([], []);
127
83
  }
128
-
129
84
  return new RelationOp([], toRemove);
130
85
  }
131
-
132
86
  case 'Batch':
133
87
  {
134
88
  var _toAdd = [];
135
89
  var _toRemove = [];
136
-
137
90
  for (var i = 0; i < json.ops.length; i++) {
138
91
  if (json.ops[i].__op === 'AddRelation') {
139
92
  _toAdd = (0, _concat.default)(_toAdd).call(_toAdd, (0, _decode.default)(json.ops[i].objects));
@@ -141,99 +94,67 @@ function opFromJSON(json
141
94
  _toRemove = (0, _concat.default)(_toRemove).call(_toRemove, (0, _decode.default)(json.ops[i].objects));
142
95
  }
143
96
  }
144
-
145
97
  return new RelationOp(_toAdd, _toRemove);
146
98
  }
147
99
  }
148
-
149
100
  return null;
150
101
  }
151
-
152
102
  var Op = /*#__PURE__*/function () {
153
103
  function Op() {
154
104
  (0, _classCallCheck2.default)(this, Op);
155
105
  }
156
-
157
106
  (0, _createClass2.default)(Op, [{
158
107
  key: "applyTo",
159
- value: // Empty parent class
160
- function ()
161
- /*: mixed*/
162
- {}
163
- /* eslint-disable-line no-unused-vars */
164
-
108
+ value:
109
+ // Empty parent class
110
+ function () /*: mixed*/{} /* eslint-disable-line no-unused-vars */
165
111
  }, {
166
112
  key: "mergeWith",
167
- value: function ()
168
- /*: ?Op*/
169
- {}
170
- /* eslint-disable-line no-unused-vars */
171
-
113
+ value: function () /*: ?Op*/{} /* eslint-disable-line no-unused-vars */
172
114
  }, {
173
115
  key: "toJSON",
174
- value: function ()
175
- /*: mixed*/
176
- {}
116
+ value: function () /*: mixed*/{}
177
117
  }]);
178
118
  return Op;
179
119
  }();
180
-
181
120
  exports.Op = Op;
182
-
183
121
  var SetOp = /*#__PURE__*/function (_Op) {
184
122
  (0, _inherits2.default)(SetOp, _Op);
185
-
186
123
  var _super = _createSuper(SetOp);
187
-
188
- function SetOp(value
189
- /*: mixed*/
190
- ) {
124
+ function SetOp(value /*: mixed*/) {
191
125
  var _this;
192
-
193
126
  (0, _classCallCheck2.default)(this, SetOp);
194
127
  _this = _super.call(this);
195
128
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_value", void 0);
196
129
  _this._value = value;
197
130
  return _this;
198
131
  }
199
-
200
132
  (0, _createClass2.default)(SetOp, [{
201
133
  key: "applyTo",
202
- value: function ()
203
- /*: mixed*/
204
- {
134
+ value: function () /*: mixed*/{
205
135
  return this._value;
206
136
  }
207
137
  }, {
208
138
  key: "mergeWith",
209
- value: function ()
210
- /*: SetOp*/
211
- {
139
+ value: function () /*: SetOp*/{
212
140
  return new SetOp(this._value);
213
141
  }
214
142
  }, {
215
143
  key: "toJSON",
216
- value: function (offline
217
- /*:: ?: boolean*/
218
- ) {
144
+ value: function (offline /*:: ?: boolean*/) {
219
145
  return (0, _encode.default)(this._value, false, true, undefined, offline);
220
146
  }
221
147
  }]);
222
148
  return SetOp;
223
149
  }(Op);
224
-
225
150
  exports.SetOp = SetOp;
226
-
227
151
  var UnsetOp = /*#__PURE__*/function (_Op2) {
228
152
  (0, _inherits2.default)(UnsetOp, _Op2);
229
-
230
153
  var _super2 = _createSuper(UnsetOp);
231
-
232
154
  function UnsetOp() {
233
155
  (0, _classCallCheck2.default)(this, UnsetOp);
234
156
  return _super2.apply(this, arguments);
235
157
  }
236
-
237
158
  (0, _createClass2.default)(UnsetOp, [{
238
159
  key: "applyTo",
239
160
  value: function () {
@@ -241,16 +162,12 @@ var UnsetOp = /*#__PURE__*/function (_Op2) {
241
162
  }
242
163
  }, {
243
164
  key: "mergeWith",
244
- value: function ()
245
- /*: UnsetOp*/
246
- {
165
+ value: function () /*: UnsetOp*/{
247
166
  return new UnsetOp();
248
167
  }
249
168
  }, {
250
169
  key: "toJSON",
251
- value: function ()
252
- /*: { __op: string }*/
253
- {
170
+ value: function () /*: { __op: string }*/{
254
171
  return {
255
172
  __op: 'Delete'
256
173
  };
@@ -258,78 +175,52 @@ var UnsetOp = /*#__PURE__*/function (_Op2) {
258
175
  }]);
259
176
  return UnsetOp;
260
177
  }(Op);
261
-
262
178
  exports.UnsetOp = UnsetOp;
263
-
264
179
  var IncrementOp = /*#__PURE__*/function (_Op3) {
265
180
  (0, _inherits2.default)(IncrementOp, _Op3);
266
-
267
181
  var _super3 = _createSuper(IncrementOp);
268
-
269
- function IncrementOp(amount
270
- /*: number*/
271
- ) {
182
+ function IncrementOp(amount /*: number*/) {
272
183
  var _this2;
273
-
274
184
  (0, _classCallCheck2.default)(this, IncrementOp);
275
185
  _this2 = _super3.call(this);
276
186
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "_amount", void 0);
277
-
278
187
  if (typeof amount !== 'number') {
279
188
  throw new TypeError('Increment Op must be initialized with a numeric amount.');
280
189
  }
281
-
282
190
  _this2._amount = amount;
283
191
  return _this2;
284
192
  }
285
-
286
193
  (0, _createClass2.default)(IncrementOp, [{
287
194
  key: "applyTo",
288
- value: function (value
289
- /*: ?mixed*/
290
- )
291
- /*: number*/
292
- {
195
+ value: function (value /*: ?mixed*/) /*: number*/{
293
196
  if (typeof value === 'undefined') {
294
197
  return this._amount;
295
198
  }
296
-
297
199
  if (typeof value !== 'number') {
298
200
  throw new TypeError('Cannot increment a non-numeric value.');
299
201
  }
300
-
301
202
  return this._amount + value;
302
203
  }
303
204
  }, {
304
205
  key: "mergeWith",
305
- value: function (previous
306
- /*: Op*/
307
- )
308
- /*: Op*/
309
- {
206
+ value: function (previous /*: Op*/) /*: Op*/{
310
207
  if (!previous) {
311
208
  return this;
312
209
  }
313
-
314
210
  if (previous instanceof SetOp) {
315
211
  return new SetOp(this.applyTo(previous._value));
316
212
  }
317
-
318
213
  if (previous instanceof UnsetOp) {
319
214
  return new SetOp(this._amount);
320
215
  }
321
-
322
216
  if (previous instanceof IncrementOp) {
323
217
  return new IncrementOp(this.applyTo(previous._amount));
324
218
  }
325
-
326
219
  throw new Error('Cannot merge Increment Op with the previous Op');
327
220
  }
328
221
  }, {
329
222
  key: "toJSON",
330
- value: function ()
331
- /*: { __op: string, amount: number }*/
332
- {
223
+ value: function () /*: { __op: string, amount: number }*/{
333
224
  return {
334
225
  __op: 'Increment',
335
226
  amount: this._amount
@@ -338,73 +229,49 @@ var IncrementOp = /*#__PURE__*/function (_Op3) {
338
229
  }]);
339
230
  return IncrementOp;
340
231
  }(Op);
341
-
342
232
  exports.IncrementOp = IncrementOp;
343
-
344
233
  var AddOp = /*#__PURE__*/function (_Op4) {
345
234
  (0, _inherits2.default)(AddOp, _Op4);
346
-
347
235
  var _super4 = _createSuper(AddOp);
348
-
349
- function AddOp(value
350
- /*: mixed | Array<mixed>*/
351
- ) {
236
+ function AddOp(value /*: mixed | Array<mixed>*/) {
352
237
  var _this3;
353
-
354
238
  (0, _classCallCheck2.default)(this, AddOp);
355
239
  _this3 = _super4.call(this);
356
240
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this3), "_value", void 0);
357
241
  _this3._value = (0, _isArray.default)(value) ? value : [value];
358
242
  return _this3;
359
243
  }
360
-
361
244
  (0, _createClass2.default)(AddOp, [{
362
245
  key: "applyTo",
363
- value: function (value
364
- /*: mixed*/
365
- )
366
- /*: Array<mixed>*/
367
- {
246
+ value: function (value /*: mixed*/) /*: Array<mixed>*/{
368
247
  if (value == null) {
369
248
  return this._value;
370
249
  }
371
-
372
250
  if ((0, _isArray.default)(value)) {
373
251
  return (0, _concat.default)(value).call(value, this._value);
374
252
  }
375
-
376
253
  throw new Error('Cannot add elements to a non-array value');
377
254
  }
378
255
  }, {
379
256
  key: "mergeWith",
380
- value: function (previous
381
- /*: Op*/
382
- )
383
- /*: Op*/
384
- {
257
+ value: function (previous /*: Op*/) /*: Op*/{
385
258
  if (!previous) {
386
259
  return this;
387
260
  }
388
-
389
261
  if (previous instanceof SetOp) {
390
262
  return new SetOp(this.applyTo(previous._value));
391
263
  }
392
-
393
264
  if (previous instanceof UnsetOp) {
394
265
  return new SetOp(this._value);
395
266
  }
396
-
397
267
  if (previous instanceof AddOp) {
398
268
  return new AddOp(this.applyTo(previous._value));
399
269
  }
400
-
401
270
  throw new Error('Cannot merge Add Op with the previous Op');
402
271
  }
403
272
  }, {
404
273
  key: "toJSON",
405
- value: function ()
406
- /*: { __op: string, objects: mixed }*/
407
- {
274
+ value: function () /*: { __op: string, objects: mixed }*/{
408
275
  return {
409
276
  __op: 'Add',
410
277
  objects: (0, _encode.default)(this._value, false, true)
@@ -413,40 +280,26 @@ var AddOp = /*#__PURE__*/function (_Op4) {
413
280
  }]);
414
281
  return AddOp;
415
282
  }(Op);
416
-
417
283
  exports.AddOp = AddOp;
418
-
419
284
  var AddUniqueOp = /*#__PURE__*/function (_Op5) {
420
285
  (0, _inherits2.default)(AddUniqueOp, _Op5);
421
-
422
286
  var _super5 = _createSuper(AddUniqueOp);
423
-
424
- function AddUniqueOp(value
425
- /*: mixed | Array<mixed>*/
426
- ) {
287
+ function AddUniqueOp(value /*: mixed | Array<mixed>*/) {
427
288
  var _this4;
428
-
429
289
  (0, _classCallCheck2.default)(this, AddUniqueOp);
430
290
  _this4 = _super5.call(this);
431
291
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this4), "_value", void 0);
432
292
  _this4._value = (0, _unique.default)((0, _isArray.default)(value) ? value : [value]);
433
293
  return _this4;
434
294
  }
435
-
436
295
  (0, _createClass2.default)(AddUniqueOp, [{
437
296
  key: "applyTo",
438
- value: function (value
439
- /*: mixed | Array<mixed>*/
440
- )
441
- /*: Array<mixed>*/
442
- {
297
+ value: function (value /*: mixed | Array<mixed>*/) /*: Array<mixed>*/{
443
298
  if (value == null) {
444
299
  return this._value || [];
445
300
  }
446
-
447
301
  if ((0, _isArray.default)(value)) {
448
302
  var _context;
449
-
450
303
  var toAdd = [];
451
304
  (0, _forEach.default)(_context = this._value).call(_context, function (v) {
452
305
  if (v instanceof _ParseObject.default) {
@@ -461,39 +314,28 @@ var AddUniqueOp = /*#__PURE__*/function (_Op5) {
461
314
  });
462
315
  return (0, _concat.default)(value).call(value, toAdd);
463
316
  }
464
-
465
317
  throw new Error('Cannot add elements to a non-array value');
466
318
  }
467
319
  }, {
468
320
  key: "mergeWith",
469
- value: function (previous
470
- /*: Op*/
471
- )
472
- /*: Op*/
473
- {
321
+ value: function (previous /*: Op*/) /*: Op*/{
474
322
  if (!previous) {
475
323
  return this;
476
324
  }
477
-
478
325
  if (previous instanceof SetOp) {
479
326
  return new SetOp(this.applyTo(previous._value));
480
327
  }
481
-
482
328
  if (previous instanceof UnsetOp) {
483
329
  return new SetOp(this._value);
484
330
  }
485
-
486
331
  if (previous instanceof AddUniqueOp) {
487
332
  return new AddUniqueOp(this.applyTo(previous._value));
488
333
  }
489
-
490
334
  throw new Error('Cannot merge AddUnique Op with the previous Op');
491
335
  }
492
336
  }, {
493
337
  key: "toJSON",
494
- value: function ()
495
- /*: { __op: string, objects: mixed }*/
496
- {
338
+ value: function () /*: { __op: string, objects: mixed }*/{
497
339
  return {
498
340
  __op: 'AddUnique',
499
341
  objects: (0, _encode.default)(this._value, false, true)
@@ -502,49 +344,33 @@ var AddUniqueOp = /*#__PURE__*/function (_Op5) {
502
344
  }]);
503
345
  return AddUniqueOp;
504
346
  }(Op);
505
-
506
347
  exports.AddUniqueOp = AddUniqueOp;
507
-
508
348
  var RemoveOp = /*#__PURE__*/function (_Op6) {
509
349
  (0, _inherits2.default)(RemoveOp, _Op6);
510
-
511
350
  var _super6 = _createSuper(RemoveOp);
512
-
513
- function RemoveOp(value
514
- /*: mixed | Array<mixed>*/
515
- ) {
351
+ function RemoveOp(value /*: mixed | Array<mixed>*/) {
516
352
  var _this5;
517
-
518
353
  (0, _classCallCheck2.default)(this, RemoveOp);
519
354
  _this5 = _super6.call(this);
520
355
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this5), "_value", void 0);
521
356
  _this5._value = (0, _unique.default)((0, _isArray.default)(value) ? value : [value]);
522
357
  return _this5;
523
358
  }
524
-
525
359
  (0, _createClass2.default)(RemoveOp, [{
526
360
  key: "applyTo",
527
- value: function (value
528
- /*: mixed | Array<mixed>*/
529
- )
530
- /*: Array<mixed>*/
531
- {
361
+ value: function (value /*: mixed | Array<mixed>*/) /*: Array<mixed>*/{
532
362
  if (value == null) {
533
363
  return [];
534
364
  }
535
-
536
365
  if ((0, _isArray.default)(value)) {
537
366
  // var i = value.indexOf(this._value);
538
367
  var removed = (0, _concat.default)(value).call(value, []);
539
-
540
368
  for (var i = 0; i < this._value.length; i++) {
541
369
  var index = (0, _indexOf.default)(removed).call(removed, this._value[i]);
542
-
543
370
  while (index > -1) {
544
371
  (0, _splice.default)(removed).call(removed, index, 1);
545
372
  index = (0, _indexOf.default)(removed).call(removed, this._value[i]);
546
373
  }
547
-
548
374
  if (this._value[i] instanceof _ParseObject.default && this._value[i].id) {
549
375
  for (var j = 0; j < removed.length; j++) {
550
376
  if (removed[j] instanceof _ParseObject.default && this._value[i].id === removed[j].id) {
@@ -554,36 +380,25 @@ var RemoveOp = /*#__PURE__*/function (_Op6) {
554
380
  }
555
381
  }
556
382
  }
557
-
558
383
  return removed;
559
384
  }
560
-
561
385
  throw new Error('Cannot remove elements from a non-array value');
562
386
  }
563
387
  }, {
564
388
  key: "mergeWith",
565
- value: function (previous
566
- /*: Op*/
567
- )
568
- /*: Op*/
569
- {
389
+ value: function (previous /*: Op*/) /*: Op*/{
570
390
  if (!previous) {
571
391
  return this;
572
392
  }
573
-
574
393
  if (previous instanceof SetOp) {
575
394
  return new SetOp(this.applyTo(previous._value));
576
395
  }
577
-
578
396
  if (previous instanceof UnsetOp) {
579
397
  return new UnsetOp();
580
398
  }
581
-
582
399
  if (previous instanceof RemoveOp) {
583
400
  var _context2;
584
-
585
401
  var uniques = (0, _concat.default)(_context2 = previous._value).call(_context2, []);
586
-
587
402
  for (var i = 0; i < this._value.length; i++) {
588
403
  if (this._value[i] instanceof _ParseObject.default) {
589
404
  if (!(0, _arrayContainsObject.default)(uniques, this._value[i])) {
@@ -595,17 +410,13 @@ var RemoveOp = /*#__PURE__*/function (_Op6) {
595
410
  }
596
411
  }
597
412
  }
598
-
599
413
  return new RemoveOp(uniques);
600
414
  }
601
-
602
415
  throw new Error('Cannot merge Remove Op with the previous Op');
603
416
  }
604
417
  }, {
605
418
  key: "toJSON",
606
- value: function ()
607
- /*: { __op: string, objects: mixed }*/
608
- {
419
+ value: function () /*: { __op: string, objects: mixed }*/{
609
420
  return {
610
421
  __op: 'Remove',
611
422
  objects: (0, _encode.default)(this._value, false, true)
@@ -614,95 +425,61 @@ var RemoveOp = /*#__PURE__*/function (_Op6) {
614
425
  }]);
615
426
  return RemoveOp;
616
427
  }(Op);
617
-
618
428
  exports.RemoveOp = RemoveOp;
619
-
620
429
  var RelationOp = /*#__PURE__*/function (_Op7) {
621
430
  (0, _inherits2.default)(RelationOp, _Op7);
622
-
623
431
  var _super7 = _createSuper(RelationOp);
624
-
625
- function RelationOp(adds
626
- /*: Array<ParseObject | string>*/
627
- , removes
628
- /*: Array<ParseObject | string>*/
629
- ) {
432
+ function RelationOp(adds /*: Array<ParseObject | string>*/, removes /*: Array<ParseObject | string>*/) {
630
433
  var _this6;
631
-
632
434
  (0, _classCallCheck2.default)(this, RelationOp);
633
435
  _this6 = _super7.call(this);
634
436
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "_targetClassName", void 0);
635
437
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "relationsToAdd", void 0);
636
438
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "relationsToRemove", void 0);
637
439
  _this6._targetClassName = null;
638
-
639
440
  if ((0, _isArray.default)(adds)) {
640
441
  _this6.relationsToAdd = (0, _unique.default)((0, _map.default)(adds).call(adds, _this6._extractId, (0, _assertThisInitialized2.default)(_this6)));
641
442
  }
642
-
643
443
  if ((0, _isArray.default)(removes)) {
644
444
  _this6.relationsToRemove = (0, _unique.default)((0, _map.default)(removes).call(removes, _this6._extractId, (0, _assertThisInitialized2.default)(_this6)));
645
445
  }
646
-
647
446
  return _this6;
648
447
  }
649
-
650
448
  (0, _createClass2.default)(RelationOp, [{
651
449
  key: "_extractId",
652
- value: function (obj
653
- /*: string | ParseObject*/
654
- )
655
- /*: string*/
656
- {
450
+ value: function (obj /*: string | ParseObject*/) /*: string*/{
657
451
  if (typeof obj === 'string') {
658
452
  return obj;
659
453
  }
660
-
661
454
  if (!obj.id) {
662
455
  throw new Error('You cannot add or remove an unsaved Parse Object from a relation');
663
456
  }
664
-
665
457
  if (!this._targetClassName) {
666
458
  this._targetClassName = obj.className;
667
459
  }
668
-
669
460
  if (this._targetClassName !== obj.className) {
670
461
  throw new Error('Tried to create a Relation with 2 different object types: ' + this._targetClassName + ' and ' + obj.className + '.');
671
462
  }
672
-
673
463
  return obj.id;
674
464
  }
675
465
  }, {
676
466
  key: "applyTo",
677
- value: function (value
678
- /*: mixed*/
679
- , object
680
- /*:: ?: { className: string, id: ?string }*/
681
- , key
682
- /*:: ?: string*/
683
- )
684
- /*: ?ParseRelation*/
685
- {
467
+ value: function (value /*: mixed*/, object /*:: ?: { className: string, id: ?string }*/, key /*:: ?: string*/) /*: ?ParseRelation*/{
686
468
  if (!value) {
687
469
  var _context3;
688
-
689
470
  if (!object || !key) {
690
471
  throw new Error('Cannot apply a RelationOp without either a previous value, or an object and a key');
691
472
  }
692
-
693
473
  var parent = new _ParseObject.default(object.className);
694
-
695
474
  if (object.id && (0, _indexOf.default)(_context3 = object.id).call(_context3, 'local') === 0) {
696
475
  parent._localId = object.id;
697
476
  } else if (object.id) {
698
477
  parent.id = object.id;
699
478
  }
700
-
701
479
  var relation = new _ParseRelation.default(parent, key);
702
480
  relation.targetClassName = this._targetClassName;
703
481
  return relation;
704
482
  }
705
-
706
483
  if (value instanceof _ParseRelation.default) {
707
484
  if (this._targetClassName) {
708
485
  if (value.targetClassName) {
@@ -713,7 +490,6 @@ var RelationOp = /*#__PURE__*/function (_Op7) {
713
490
  value.targetClassName = this._targetClassName;
714
491
  }
715
492
  }
716
-
717
493
  return value;
718
494
  } else {
719
495
  throw new Error('Relation cannot be applied to a non-relation field');
@@ -721,11 +497,7 @@ var RelationOp = /*#__PURE__*/function (_Op7) {
721
497
  }
722
498
  }, {
723
499
  key: "mergeWith",
724
- value: function (previous
725
- /*: Op*/
726
- )
727
- /*: Op*/
728
- {
500
+ value: function (previous /*: Op*/) /*: Op*/{
729
501
  if (!previous) {
730
502
  return this;
731
503
  } else if (previous instanceof UnsetOp) {
@@ -734,22 +506,18 @@ var RelationOp = /*#__PURE__*/function (_Op7) {
734
506
  return this;
735
507
  } else if (previous instanceof RelationOp) {
736
508
  var _context4, _context5, _context6, _context7, _context8, _context9;
737
-
738
509
  if (previous._targetClassName && previous._targetClassName !== this._targetClassName) {
739
510
  throw new Error('Related object must be of class ' + previous._targetClassName + ', but ' + (this._targetClassName || 'null') + ' was passed in.');
740
511
  }
741
-
742
512
  var newAdd = (0, _concat.default)(_context4 = previous.relationsToAdd).call(_context4, []);
743
513
  (0, _forEach.default)(_context5 = this.relationsToRemove).call(_context5, function (r) {
744
514
  var index = (0, _indexOf.default)(newAdd).call(newAdd, r);
745
-
746
515
  if (index > -1) {
747
516
  (0, _splice.default)(newAdd).call(newAdd, index, 1);
748
517
  }
749
518
  });
750
519
  (0, _forEach.default)(_context6 = this.relationsToAdd).call(_context6, function (r) {
751
520
  var index = (0, _indexOf.default)(newAdd).call(newAdd, r);
752
-
753
521
  if (index < 0) {
754
522
  newAdd.push(r);
755
523
  }
@@ -757,14 +525,12 @@ var RelationOp = /*#__PURE__*/function (_Op7) {
757
525
  var newRemove = (0, _concat.default)(_context7 = previous.relationsToRemove).call(_context7, []);
758
526
  (0, _forEach.default)(_context8 = this.relationsToAdd).call(_context8, function (r) {
759
527
  var index = (0, _indexOf.default)(newRemove).call(newRemove, r);
760
-
761
528
  if (index > -1) {
762
529
  (0, _splice.default)(newRemove).call(newRemove, index, 1);
763
530
  }
764
531
  });
765
532
  (0, _forEach.default)(_context9 = this.relationsToRemove).call(_context9, function (r) {
766
533
  var index = (0, _indexOf.default)(newRemove).call(newRemove, r);
767
-
768
534
  if (index < 0) {
769
535
  newRemove.push(r);
770
536
  }
@@ -773,16 +539,12 @@ var RelationOp = /*#__PURE__*/function (_Op7) {
773
539
  newRelation._targetClassName = this._targetClassName;
774
540
  return newRelation;
775
541
  }
776
-
777
542
  throw new Error('Cannot merge Relation Op with the previous Op');
778
543
  }
779
544
  }, {
780
545
  key: "toJSON",
781
- value: function ()
782
- /*: { __op?: string, objects?: mixed, ops?: mixed }*/
783
- {
546
+ value: function () /*: { __op?: string, objects?: mixed, ops?: mixed }*/{
784
547
  var _this7 = this;
785
-
786
548
  var idToPointer = function (id) {
787
549
  return {
788
550
  __type: 'Pointer',
@@ -790,42 +552,34 @@ var RelationOp = /*#__PURE__*/function (_Op7) {
790
552
  objectId: id
791
553
  };
792
554
  };
793
-
794
555
  var adds = null;
795
556
  var removes = null;
796
557
  var pointers = null;
797
-
798
558
  if (this.relationsToAdd.length > 0) {
799
559
  var _context10;
800
-
801
560
  pointers = (0, _map.default)(_context10 = this.relationsToAdd).call(_context10, idToPointer);
802
561
  adds = {
803
562
  __op: 'AddRelation',
804
563
  objects: pointers
805
564
  };
806
565
  }
807
-
808
566
  if (this.relationsToRemove.length > 0) {
809
567
  var _context11;
810
-
811
568
  pointers = (0, _map.default)(_context11 = this.relationsToRemove).call(_context11, idToPointer);
812
569
  removes = {
813
570
  __op: 'RemoveRelation',
814
571
  objects: pointers
815
572
  };
816
573
  }
817
-
818
574
  if (adds && removes) {
819
575
  return {
820
576
  __op: 'Batch',
821
577
  ops: [adds, removes]
822
578
  };
823
579
  }
824
-
825
580
  return adds || removes || {};
826
581
  }
827
582
  }]);
828
583
  return RelationOp;
829
584
  }(Op);
830
-
831
585
  exports.RelationOp = RelationOp;