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
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _Reflect$construct = require("@babel/runtime-corejs3/core-js-stable/reflect/construct");
4
3
  var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
5
4
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
6
5
  _Object$defineProperty(exports, "__esModule", {
@@ -8,13 +7,7 @@ _Object$defineProperty(exports, "__esModule", {
8
7
  });
9
8
  exports.UnsetOp = exports.SetOp = exports.RemoveOp = exports.RelationOp = exports.Op = exports.IncrementOp = exports.AddUniqueOp = exports.AddOp = void 0;
10
9
  exports.opFromJSON = opFromJSON;
11
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/assertThisInitialized"));
12
- var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/inherits"));
13
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
14
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/getPrototypeOf"));
15
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
16
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
17
- var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
18
11
  var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
19
12
  var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
20
13
  var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
@@ -27,34 +20,7 @@ var _encode = _interopRequireDefault(require("./encode"));
27
20
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
28
21
  var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
29
22
  var _unique = _interopRequireDefault(require("./unique"));
30
- function _createSuper(Derived) {
31
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
32
- return function () {
33
- var Super = (0, _getPrototypeOf2.default)(Derived),
34
- result;
35
- if (hasNativeReflectConstruct) {
36
- var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
37
- result = _Reflect$construct(Super, arguments, NewTarget);
38
- } else {
39
- result = Super.apply(this, arguments);
40
- }
41
- return (0, _possibleConstructorReturn2.default)(this, result);
42
- };
43
- }
44
- function _isNativeReflectConstruct() {
45
- if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
46
- if (_Reflect$construct.sham) return false;
47
- if (typeof Proxy === "function") return true;
48
- try {
49
- Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
50
- return true;
51
- } catch (e) {
52
- return false;
53
- }
54
- } /**
55
- * @flow
56
- */ /*:: import type ParseObject from './ParseObject';*/
57
- function opFromJSON(json /*: { [key: string]: any }*/) /*: ?Op*/{
23
+ function opFromJSON(json) {
58
24
  if (!json || !json.__op) {
59
25
  return null;
60
26
  }
@@ -71,7 +37,7 @@ function opFromJSON(json /*: { [key: string]: any }*/) /*: ?Op*/{
71
37
  return new RemoveOp((0, _decode.default)(json.objects));
72
38
  case 'AddRelation':
73
39
  {
74
- var toAdd = (0, _decode.default)(json.objects);
40
+ const toAdd = (0, _decode.default)(json.objects);
75
41
  if (!(0, _isArray.default)(toAdd)) {
76
42
  return new RelationOp([], []);
77
43
  }
@@ -79,7 +45,7 @@ function opFromJSON(json /*: { [key: string]: any }*/) /*: ?Op*/{
79
45
  }
80
46
  case 'RemoveRelation':
81
47
  {
82
- var toRemove = (0, _decode.default)(json.objects);
48
+ const toRemove = (0, _decode.default)(json.objects);
83
49
  if (!(0, _isArray.default)(toRemove)) {
84
50
  return new RelationOp([], []);
85
51
  }
@@ -87,508 +53,401 @@ function opFromJSON(json /*: { [key: string]: any }*/) /*: ?Op*/{
87
53
  }
88
54
  case 'Batch':
89
55
  {
90
- var _toAdd = [];
91
- var _toRemove = [];
92
- for (var i = 0; i < json.ops.length; i++) {
56
+ let toAdd = [];
57
+ let toRemove = [];
58
+ for (let i = 0; i < json.ops.length; i++) {
93
59
  if (json.ops[i].__op === 'AddRelation') {
94
- _toAdd = (0, _concat.default)(_toAdd).call(_toAdd, (0, _decode.default)(json.ops[i].objects));
60
+ toAdd = (0, _concat.default)(toAdd).call(toAdd, (0, _decode.default)(json.ops[i].objects));
95
61
  } else if (json.ops[i].__op === 'RemoveRelation') {
96
- _toRemove = (0, _concat.default)(_toRemove).call(_toRemove, (0, _decode.default)(json.ops[i].objects));
62
+ toRemove = (0, _concat.default)(toRemove).call(toRemove, (0, _decode.default)(json.ops[i].objects));
97
63
  }
98
64
  }
99
- return new RelationOp(_toAdd, _toRemove);
65
+ return new RelationOp(toAdd, toRemove);
100
66
  }
101
67
  }
102
68
  return null;
103
69
  }
104
- var Op = /*#__PURE__*/function () {
105
- function Op() {
106
- (0, _classCallCheck2.default)(this, Op);
107
- }
108
- (0, _createClass2.default)(Op, [{
109
- key: "applyTo",
110
- value:
111
- // Empty parent class
112
- function () /*: mixed*/{} /* eslint-disable-line no-unused-vars */
113
- }, {
114
- key: "mergeWith",
115
- value: function () /*: ?Op*/{} /* eslint-disable-line no-unused-vars */
116
- }, {
117
- key: "toJSON",
118
- value: function () /*: mixed*/{}
119
- }]);
120
- return Op;
121
- }();
70
+ class Op {
71
+ // Empty parent class
72
+ applyTo() {} /* eslint-disable-line @typescript-eslint/no-unused-vars */
73
+ mergeWith() {} /* eslint-disable-line @typescript-eslint/no-unused-vars */
74
+ toJSON() {} /* eslint-disable-line @typescript-eslint/no-unused-vars */
75
+ }
122
76
  exports.Op = Op;
123
- var SetOp = /*#__PURE__*/function (_Op) {
124
- (0, _inherits2.default)(SetOp, _Op);
125
- var _super = _createSuper(SetOp);
126
- function SetOp(value /*: mixed*/) {
127
- var _this;
128
- (0, _classCallCheck2.default)(this, SetOp);
129
- _this = _super.call(this);
130
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_value", void 0);
131
- _this._value = value;
132
- return _this;
77
+ class SetOp extends Op {
78
+ constructor(value) {
79
+ super();
80
+ (0, _defineProperty2.default)(this, "_value", void 0);
81
+ this._value = value;
133
82
  }
134
- (0, _createClass2.default)(SetOp, [{
135
- key: "applyTo",
136
- value: function () /*: mixed*/{
137
- return this._value;
138
- }
139
- }, {
140
- key: "mergeWith",
141
- value: function () /*: SetOp*/{
142
- return new SetOp(this._value);
143
- }
144
- }, {
145
- key: "toJSON",
146
- value: function (offline /*:: ?: boolean*/) {
147
- return (0, _encode.default)(this._value, false, true, undefined, offline);
148
- }
149
- }]);
150
- return SetOp;
151
- }(Op);
83
+ applyTo() {
84
+ return this._value;
85
+ }
86
+ mergeWith() {
87
+ return new SetOp(this._value);
88
+ }
89
+ toJSON(offline) {
90
+ return (0, _encode.default)(this._value, false, true, undefined, offline);
91
+ }
92
+ }
152
93
  exports.SetOp = SetOp;
153
- var UnsetOp = /*#__PURE__*/function (_Op2) {
154
- (0, _inherits2.default)(UnsetOp, _Op2);
155
- var _super2 = _createSuper(UnsetOp);
156
- function UnsetOp() {
157
- (0, _classCallCheck2.default)(this, UnsetOp);
158
- return _super2.apply(this, arguments);
94
+ class UnsetOp extends Op {
95
+ applyTo() {
96
+ return undefined;
159
97
  }
160
- (0, _createClass2.default)(UnsetOp, [{
161
- key: "applyTo",
162
- value: function () {
163
- return undefined;
164
- }
165
- }, {
166
- key: "mergeWith",
167
- value: function () /*: UnsetOp*/{
168
- return new UnsetOp();
169
- }
170
- }, {
171
- key: "toJSON",
172
- value: function () /*: { __op: string }*/{
173
- return {
174
- __op: 'Delete'
175
- };
176
- }
177
- }]);
178
- return UnsetOp;
179
- }(Op);
98
+ mergeWith() {
99
+ return new UnsetOp();
100
+ }
101
+ toJSON() {
102
+ return {
103
+ __op: 'Delete'
104
+ };
105
+ }
106
+ }
180
107
  exports.UnsetOp = UnsetOp;
181
- var IncrementOp = /*#__PURE__*/function (_Op3) {
182
- (0, _inherits2.default)(IncrementOp, _Op3);
183
- var _super3 = _createSuper(IncrementOp);
184
- function IncrementOp(amount /*: number*/) {
185
- var _this2;
186
- (0, _classCallCheck2.default)(this, IncrementOp);
187
- _this2 = _super3.call(this);
188
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "_amount", void 0);
108
+ class IncrementOp extends Op {
109
+ constructor(amount) {
110
+ super();
111
+ (0, _defineProperty2.default)(this, "_amount", void 0);
189
112
  if (typeof amount !== 'number') {
190
113
  throw new TypeError('Increment Op must be initialized with a numeric amount.');
191
114
  }
192
- _this2._amount = amount;
193
- return _this2;
115
+ this._amount = amount;
194
116
  }
195
- (0, _createClass2.default)(IncrementOp, [{
196
- key: "applyTo",
197
- value: function (value /*: ?mixed*/) /*: number*/{
198
- if (typeof value === 'undefined') {
199
- return this._amount;
200
- }
201
- if (typeof value !== 'number') {
202
- throw new TypeError('Cannot increment a non-numeric value.');
203
- }
204
- return this._amount + value;
117
+ applyTo(value) {
118
+ if (typeof value === 'undefined') {
119
+ return this._amount;
205
120
  }
206
- }, {
207
- key: "mergeWith",
208
- value: function (previous /*: Op*/) /*: Op*/{
209
- if (!previous) {
210
- return this;
211
- }
212
- if (previous instanceof SetOp) {
213
- return new SetOp(this.applyTo(previous._value));
214
- }
215
- if (previous instanceof UnsetOp) {
216
- return new SetOp(this._amount);
217
- }
218
- if (previous instanceof IncrementOp) {
219
- return new IncrementOp(this.applyTo(previous._amount));
220
- }
221
- throw new Error('Cannot merge Increment Op with the previous Op');
121
+ if (typeof value !== 'number') {
122
+ throw new TypeError('Cannot increment a non-numeric value.');
222
123
  }
223
- }, {
224
- key: "toJSON",
225
- value: function () /*: { __op: string, amount: number }*/{
226
- return {
227
- __op: 'Increment',
228
- amount: this._amount
229
- };
124
+ return this._amount + value;
125
+ }
126
+ mergeWith(previous) {
127
+ if (!previous) {
128
+ return this;
129
+ }
130
+ if (previous instanceof SetOp) {
131
+ return new SetOp(this.applyTo(previous._value));
132
+ }
133
+ if (previous instanceof UnsetOp) {
134
+ return new SetOp(this._amount);
230
135
  }
231
- }]);
232
- return IncrementOp;
233
- }(Op);
136
+ if (previous instanceof IncrementOp) {
137
+ return new IncrementOp(this.applyTo(previous._amount));
138
+ }
139
+ throw new Error('Cannot merge Increment Op with the previous Op');
140
+ }
141
+ toJSON() {
142
+ return {
143
+ __op: 'Increment',
144
+ amount: this._amount
145
+ };
146
+ }
147
+ }
234
148
  exports.IncrementOp = IncrementOp;
235
- var AddOp = /*#__PURE__*/function (_Op4) {
236
- (0, _inherits2.default)(AddOp, _Op4);
237
- var _super4 = _createSuper(AddOp);
238
- function AddOp(value /*: mixed | Array<mixed>*/) {
239
- var _this3;
240
- (0, _classCallCheck2.default)(this, AddOp);
241
- _this3 = _super4.call(this);
242
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this3), "_value", void 0);
243
- _this3._value = (0, _isArray.default)(value) ? value : [value];
244
- return _this3;
149
+ class AddOp extends Op {
150
+ constructor(value) {
151
+ super();
152
+ (0, _defineProperty2.default)(this, "_value", void 0);
153
+ this._value = (0, _isArray.default)(value) ? value : [value];
245
154
  }
246
- (0, _createClass2.default)(AddOp, [{
247
- key: "applyTo",
248
- value: function (value /*: mixed*/) /*: Array<mixed>*/{
249
- if (value == null) {
250
- return this._value;
251
- }
252
- if ((0, _isArray.default)(value)) {
253
- return (0, _concat.default)(value).call(value, this._value);
254
- }
255
- throw new Error('Cannot add elements to a non-array value');
155
+ applyTo(value) {
156
+ if (value == null) {
157
+ return this._value;
256
158
  }
257
- }, {
258
- key: "mergeWith",
259
- value: function (previous /*: Op*/) /*: Op*/{
260
- if (!previous) {
261
- return this;
262
- }
263
- if (previous instanceof SetOp) {
264
- return new SetOp(this.applyTo(previous._value));
265
- }
266
- if (previous instanceof UnsetOp) {
267
- return new SetOp(this._value);
268
- }
269
- if (previous instanceof AddOp) {
270
- return new AddOp(this.applyTo(previous._value));
271
- }
272
- throw new Error('Cannot merge Add Op with the previous Op');
159
+ if ((0, _isArray.default)(value)) {
160
+ return (0, _concat.default)(value).call(value, this._value);
273
161
  }
274
- }, {
275
- key: "toJSON",
276
- value: function () /*: { __op: string, objects: mixed }*/{
277
- return {
278
- __op: 'Add',
279
- objects: (0, _encode.default)(this._value, false, true)
280
- };
162
+ throw new Error('Cannot add elements to a non-array value');
163
+ }
164
+ mergeWith(previous) {
165
+ if (!previous) {
166
+ return this;
167
+ }
168
+ if (previous instanceof SetOp) {
169
+ return new SetOp(this.applyTo(previous._value));
170
+ }
171
+ if (previous instanceof UnsetOp) {
172
+ return new SetOp(this._value);
281
173
  }
282
- }]);
283
- return AddOp;
284
- }(Op);
174
+ if (previous instanceof AddOp) {
175
+ return new AddOp(this.applyTo(previous._value));
176
+ }
177
+ throw new Error('Cannot merge Add Op with the previous Op');
178
+ }
179
+ toJSON() {
180
+ return {
181
+ __op: 'Add',
182
+ objects: (0, _encode.default)(this._value, false, true)
183
+ };
184
+ }
185
+ }
285
186
  exports.AddOp = AddOp;
286
- var AddUniqueOp = /*#__PURE__*/function (_Op5) {
287
- (0, _inherits2.default)(AddUniqueOp, _Op5);
288
- var _super5 = _createSuper(AddUniqueOp);
289
- function AddUniqueOp(value /*: mixed | Array<mixed>*/) {
290
- var _this4;
291
- (0, _classCallCheck2.default)(this, AddUniqueOp);
292
- _this4 = _super5.call(this);
293
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this4), "_value", void 0);
294
- _this4._value = (0, _unique.default)((0, _isArray.default)(value) ? value : [value]);
295
- return _this4;
187
+ class AddUniqueOp extends Op {
188
+ constructor(value) {
189
+ super();
190
+ (0, _defineProperty2.default)(this, "_value", void 0);
191
+ this._value = (0, _unique.default)((0, _isArray.default)(value) ? value : [value]);
296
192
  }
297
- (0, _createClass2.default)(AddUniqueOp, [{
298
- key: "applyTo",
299
- value: function (value /*: mixed | Array<mixed>*/) /*: Array<mixed>*/{
300
- if (value == null) {
301
- return this._value || [];
302
- }
303
- if ((0, _isArray.default)(value)) {
304
- var _context;
305
- var ParseObject = _CoreManager.default.getParseObject();
306
- var toAdd = [];
307
- (0, _forEach.default)(_context = this._value).call(_context, function (v) {
308
- if (v instanceof ParseObject) {
309
- if (!(0, _arrayContainsObject.default)(value, v)) {
310
- toAdd.push(v);
311
- }
312
- } else {
313
- if ((0, _indexOf.default)(value).call(value, v) < 0) {
314
- toAdd.push(v);
315
- }
193
+ applyTo(value) {
194
+ if (value == null) {
195
+ return this._value || [];
196
+ }
197
+ if ((0, _isArray.default)(value)) {
198
+ var _context;
199
+ const ParseObject = _CoreManager.default.getParseObject();
200
+ const toAdd = [];
201
+ (0, _forEach.default)(_context = this._value).call(_context, v => {
202
+ if (v instanceof ParseObject) {
203
+ if (!(0, _arrayContainsObject.default)(value, v)) {
204
+ toAdd.push(v);
316
205
  }
317
- });
318
- return (0, _concat.default)(value).call(value, toAdd);
319
- }
320
- throw new Error('Cannot add elements to a non-array value');
206
+ } else {
207
+ if ((0, _indexOf.default)(value).call(value, v) < 0) {
208
+ toAdd.push(v);
209
+ }
210
+ }
211
+ });
212
+ return (0, _concat.default)(value).call(value, toAdd);
321
213
  }
322
- }, {
323
- key: "mergeWith",
324
- value: function (previous /*: Op*/) /*: Op*/{
325
- if (!previous) {
326
- return this;
327
- }
328
- if (previous instanceof SetOp) {
329
- return new SetOp(this.applyTo(previous._value));
330
- }
331
- if (previous instanceof UnsetOp) {
332
- return new SetOp(this._value);
333
- }
334
- if (previous instanceof AddUniqueOp) {
335
- return new AddUniqueOp(this.applyTo(previous._value));
336
- }
337
- throw new Error('Cannot merge AddUnique Op with the previous Op');
214
+ throw new Error('Cannot add elements to a non-array value');
215
+ }
216
+ mergeWith(previous) {
217
+ if (!previous) {
218
+ return this;
338
219
  }
339
- }, {
340
- key: "toJSON",
341
- value: function () /*: { __op: string, objects: mixed }*/{
342
- return {
343
- __op: 'AddUnique',
344
- objects: (0, _encode.default)(this._value, false, true)
345
- };
220
+ if (previous instanceof SetOp) {
221
+ return new SetOp(this.applyTo(previous._value));
222
+ }
223
+ if (previous instanceof UnsetOp) {
224
+ return new SetOp(this._value);
225
+ }
226
+ if (previous instanceof AddUniqueOp) {
227
+ return new AddUniqueOp(this.applyTo(previous._value));
346
228
  }
347
- }]);
348
- return AddUniqueOp;
349
- }(Op);
229
+ throw new Error('Cannot merge AddUnique Op with the previous Op');
230
+ }
231
+ toJSON() {
232
+ return {
233
+ __op: 'AddUnique',
234
+ objects: (0, _encode.default)(this._value, false, true)
235
+ };
236
+ }
237
+ }
350
238
  exports.AddUniqueOp = AddUniqueOp;
351
- var RemoveOp = /*#__PURE__*/function (_Op6) {
352
- (0, _inherits2.default)(RemoveOp, _Op6);
353
- var _super6 = _createSuper(RemoveOp);
354
- function RemoveOp(value /*: mixed | Array<mixed>*/) {
355
- var _this5;
356
- (0, _classCallCheck2.default)(this, RemoveOp);
357
- _this5 = _super6.call(this);
358
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this5), "_value", void 0);
359
- _this5._value = (0, _unique.default)((0, _isArray.default)(value) ? value : [value]);
360
- return _this5;
239
+ class RemoveOp extends Op {
240
+ constructor(value) {
241
+ super();
242
+ (0, _defineProperty2.default)(this, "_value", void 0);
243
+ this._value = (0, _unique.default)((0, _isArray.default)(value) ? value : [value]);
361
244
  }
362
- (0, _createClass2.default)(RemoveOp, [{
363
- key: "applyTo",
364
- value: function (value /*: mixed | Array<mixed>*/) /*: Array<mixed>*/{
365
- if (value == null) {
366
- return [];
367
- }
368
- if ((0, _isArray.default)(value)) {
369
- var ParseObject = _CoreManager.default.getParseObject();
370
- // var i = value.indexOf(this._value);
371
- var removed = (0, _concat.default)(value).call(value, []);
372
- for (var i = 0; i < this._value.length; i++) {
373
- var index = (0, _indexOf.default)(removed).call(removed, this._value[i]);
374
- while (index > -1) {
375
- (0, _splice.default)(removed).call(removed, index, 1);
376
- index = (0, _indexOf.default)(removed).call(removed, this._value[i]);
377
- }
378
- if (this._value[i] instanceof ParseObject && this._value[i].id) {
379
- for (var j = 0; j < removed.length; j++) {
380
- if (removed[j] instanceof ParseObject && this._value[i].id === removed[j].id) {
381
- (0, _splice.default)(removed).call(removed, j, 1);
382
- j--;
383
- }
245
+ applyTo(value) {
246
+ if (value == null) {
247
+ return [];
248
+ }
249
+ if ((0, _isArray.default)(value)) {
250
+ const ParseObject = _CoreManager.default.getParseObject();
251
+ // var i = value.indexOf(this._value);
252
+ const removed = (0, _concat.default)(value).call(value, []);
253
+ for (let i = 0; i < this._value.length; i++) {
254
+ let index = (0, _indexOf.default)(removed).call(removed, this._value[i]);
255
+ while (index > -1) {
256
+ (0, _splice.default)(removed).call(removed, index, 1);
257
+ index = (0, _indexOf.default)(removed).call(removed, this._value[i]);
258
+ }
259
+ if (this._value[i] instanceof ParseObject && this._value[i].id) {
260
+ for (let j = 0; j < removed.length; j++) {
261
+ if (removed[j] instanceof ParseObject && this._value[i].id === removed[j].id) {
262
+ (0, _splice.default)(removed).call(removed, j, 1);
263
+ j--;
384
264
  }
385
265
  }
386
266
  }
387
- return removed;
388
267
  }
389
- throw new Error('Cannot remove elements from a non-array value');
268
+ return removed;
390
269
  }
391
- }, {
392
- key: "mergeWith",
393
- value: function (previous /*: Op*/) /*: Op*/{
394
- if (!previous) {
395
- return this;
396
- }
397
- if (previous instanceof SetOp) {
398
- return new SetOp(this.applyTo(previous._value));
399
- }
400
- if (previous instanceof UnsetOp) {
401
- return new UnsetOp();
402
- }
403
- if (previous instanceof RemoveOp) {
404
- var _context2;
405
- var ParseObject = _CoreManager.default.getParseObject();
406
- var uniques = (0, _concat.default)(_context2 = previous._value).call(_context2, []);
407
- for (var i = 0; i < this._value.length; i++) {
408
- if (this._value[i] instanceof ParseObject) {
409
- if (!(0, _arrayContainsObject.default)(uniques, this._value[i])) {
410
- uniques.push(this._value[i]);
411
- }
412
- } else {
413
- if ((0, _indexOf.default)(uniques).call(uniques, this._value[i]) < 0) {
414
- uniques.push(this._value[i]);
415
- }
270
+ throw new Error('Cannot remove elements from a non-array value');
271
+ }
272
+ mergeWith(previous) {
273
+ if (!previous) {
274
+ return this;
275
+ }
276
+ if (previous instanceof SetOp) {
277
+ return new SetOp(this.applyTo(previous._value));
278
+ }
279
+ if (previous instanceof UnsetOp) {
280
+ return new UnsetOp();
281
+ }
282
+ if (previous instanceof RemoveOp) {
283
+ var _context2;
284
+ const ParseObject = _CoreManager.default.getParseObject();
285
+ const uniques = (0, _concat.default)(_context2 = previous._value).call(_context2, []);
286
+ for (let i = 0; i < this._value.length; i++) {
287
+ if (this._value[i] instanceof ParseObject) {
288
+ if (!(0, _arrayContainsObject.default)(uniques, this._value[i])) {
289
+ uniques.push(this._value[i]);
290
+ }
291
+ } else {
292
+ if ((0, _indexOf.default)(uniques).call(uniques, this._value[i]) < 0) {
293
+ uniques.push(this._value[i]);
416
294
  }
417
295
  }
418
- return new RemoveOp(uniques);
419
296
  }
420
- throw new Error('Cannot merge Remove Op with the previous Op');
421
- }
422
- }, {
423
- key: "toJSON",
424
- value: function () /*: { __op: string, objects: mixed }*/{
425
- return {
426
- __op: 'Remove',
427
- objects: (0, _encode.default)(this._value, false, true)
428
- };
297
+ return new RemoveOp(uniques);
429
298
  }
430
- }]);
431
- return RemoveOp;
432
- }(Op);
299
+ throw new Error('Cannot merge Remove Op with the previous Op');
300
+ }
301
+ toJSON() {
302
+ return {
303
+ __op: 'Remove',
304
+ objects: (0, _encode.default)(this._value, false, true)
305
+ };
306
+ }
307
+ }
433
308
  exports.RemoveOp = RemoveOp;
434
- var RelationOp = /*#__PURE__*/function (_Op7) {
435
- (0, _inherits2.default)(RelationOp, _Op7);
436
- var _super7 = _createSuper(RelationOp);
437
- function RelationOp(adds /*: Array<ParseObject | string>*/, removes /*: Array<ParseObject | string>*/) {
438
- var _this6;
439
- (0, _classCallCheck2.default)(this, RelationOp);
440
- _this6 = _super7.call(this);
441
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "_targetClassName", void 0);
442
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "relationsToAdd", void 0);
443
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "relationsToRemove", void 0);
444
- _this6._targetClassName = null;
309
+ class RelationOp extends Op {
310
+ constructor(adds, removes) {
311
+ super();
312
+ (0, _defineProperty2.default)(this, "_targetClassName", void 0);
313
+ (0, _defineProperty2.default)(this, "relationsToAdd", void 0);
314
+ (0, _defineProperty2.default)(this, "relationsToRemove", void 0);
315
+ this._targetClassName = null;
445
316
  if ((0, _isArray.default)(adds)) {
446
- _this6.relationsToAdd = (0, _unique.default)((0, _map.default)(adds).call(adds, _this6._extractId, (0, _assertThisInitialized2.default)(_this6)));
317
+ this.relationsToAdd = (0, _unique.default)((0, _map.default)(adds).call(adds, this._extractId, this));
447
318
  }
448
319
  if ((0, _isArray.default)(removes)) {
449
- _this6.relationsToRemove = (0, _unique.default)((0, _map.default)(removes).call(removes, _this6._extractId, (0, _assertThisInitialized2.default)(_this6)));
320
+ this.relationsToRemove = (0, _unique.default)((0, _map.default)(removes).call(removes, this._extractId, this));
450
321
  }
451
- return _this6;
452
322
  }
453
- (0, _createClass2.default)(RelationOp, [{
454
- key: "_extractId",
455
- value: function (obj /*: string | ParseObject*/) /*: string*/{
456
- if (typeof obj === 'string') {
457
- return obj;
458
- }
459
- if (!obj.id) {
460
- throw new Error('You cannot add or remove an unsaved Parse Object from a relation');
461
- }
462
- if (!this._targetClassName) {
463
- this._targetClassName = obj.className;
464
- }
465
- if (this._targetClassName !== obj.className) {
466
- throw new Error('Tried to create a Relation with 2 different object types: ' + this._targetClassName + ' and ' + obj.className + '.');
467
- }
468
- return obj.id;
469
- }
470
- }, {
471
- key: "applyTo",
472
- value: function (value /*: mixed*/, parent /*: ParseObject*/, key /*:: ?: string*/) /*: ?ParseRelation*/{
473
- if (!value) {
474
- if (!parent || !key) {
475
- throw new Error('Cannot apply a RelationOp without either a previous value, or an object and a key');
476
- }
477
- var relation = new _ParseRelation.default(parent, key);
478
- relation.targetClassName = this._targetClassName;
479
- return relation;
480
- }
481
- if (value instanceof _ParseRelation.default) {
482
- if (this._targetClassName) {
483
- if (value.targetClassName) {
484
- if (this._targetClassName !== value.targetClassName) {
485
- throw new Error('Related object must be a ' + value.targetClassName + ', but a ' + this._targetClassName + ' was passed in.');
486
- }
487
- } else {
488
- value.targetClassName = this._targetClassName;
323
+ _extractId(obj) {
324
+ if (typeof obj === 'string') {
325
+ return obj;
326
+ }
327
+ if (!obj.id) {
328
+ throw new Error('You cannot add or remove an unsaved Parse Object from a relation');
329
+ }
330
+ if (!this._targetClassName) {
331
+ this._targetClassName = obj.className;
332
+ }
333
+ if (this._targetClassName !== obj.className) {
334
+ throw new Error('Tried to create a Relation with 2 different object types: ' + this._targetClassName + ' and ' + obj.className + '.');
335
+ }
336
+ return obj.id;
337
+ }
338
+ applyTo(value, parent, key) {
339
+ if (!value) {
340
+ if (!parent || !key) {
341
+ throw new Error('Cannot apply a RelationOp without either a previous value, or an object and a key');
342
+ }
343
+ const relation = new _ParseRelation.default(parent, key);
344
+ relation.targetClassName = this._targetClassName;
345
+ return relation;
346
+ }
347
+ if (value instanceof _ParseRelation.default) {
348
+ if (this._targetClassName) {
349
+ if (value.targetClassName) {
350
+ if (this._targetClassName !== value.targetClassName) {
351
+ throw new Error('Related object must be a ' + value.targetClassName + ', but a ' + this._targetClassName + ' was passed in.');
489
352
  }
353
+ } else {
354
+ value.targetClassName = this._targetClassName;
490
355
  }
491
- return value;
492
- } else {
493
- throw new Error('Relation cannot be applied to a non-relation field');
494
356
  }
357
+ return value;
358
+ } else {
359
+ throw new Error('Relation cannot be applied to a non-relation field');
495
360
  }
496
- }, {
497
- key: "mergeWith",
498
- value: function (previous /*: Op*/) /*: Op*/{
499
- if (!previous) {
500
- return this;
501
- } else if (previous instanceof UnsetOp) {
502
- throw new Error('You cannot modify a relation after deleting it.');
503
- } else if (previous instanceof SetOp && previous._value instanceof _ParseRelation.default) {
504
- return this;
505
- } else if (previous instanceof RelationOp) {
506
- var _context3, _context4, _context5, _context6, _context7, _context8;
507
- if (previous._targetClassName && previous._targetClassName !== this._targetClassName) {
508
- throw new Error('Related object must be of class ' + previous._targetClassName + ', but ' + (this._targetClassName || 'null') + ' was passed in.');
361
+ }
362
+ mergeWith(previous) {
363
+ if (!previous) {
364
+ return this;
365
+ } else if (previous instanceof UnsetOp) {
366
+ throw new Error('You cannot modify a relation after deleting it.');
367
+ } else if (previous instanceof SetOp && previous._value instanceof _ParseRelation.default) {
368
+ return this;
369
+ } else if (previous instanceof RelationOp) {
370
+ var _context3, _context4, _context5, _context6, _context7, _context8;
371
+ if (previous._targetClassName && previous._targetClassName !== this._targetClassName) {
372
+ throw new Error('Related object must be of class ' + previous._targetClassName + ', but ' + (this._targetClassName || 'null') + ' was passed in.');
373
+ }
374
+ const newAdd = (0, _concat.default)(_context3 = previous.relationsToAdd).call(_context3, []);
375
+ (0, _forEach.default)(_context4 = this.relationsToRemove).call(_context4, r => {
376
+ const index = (0, _indexOf.default)(newAdd).call(newAdd, r);
377
+ if (index > -1) {
378
+ (0, _splice.default)(newAdd).call(newAdd, index, 1);
509
379
  }
510
- var newAdd = (0, _concat.default)(_context3 = previous.relationsToAdd).call(_context3, []);
511
- (0, _forEach.default)(_context4 = this.relationsToRemove).call(_context4, function (r) {
512
- var index = (0, _indexOf.default)(newAdd).call(newAdd, r);
513
- if (index > -1) {
514
- (0, _splice.default)(newAdd).call(newAdd, index, 1);
515
- }
516
- });
517
- (0, _forEach.default)(_context5 = this.relationsToAdd).call(_context5, function (r) {
518
- var index = (0, _indexOf.default)(newAdd).call(newAdd, r);
519
- if (index < 0) {
520
- newAdd.push(r);
521
- }
522
- });
523
- var newRemove = (0, _concat.default)(_context6 = previous.relationsToRemove).call(_context6, []);
524
- (0, _forEach.default)(_context7 = this.relationsToAdd).call(_context7, function (r) {
525
- var index = (0, _indexOf.default)(newRemove).call(newRemove, r);
526
- if (index > -1) {
527
- (0, _splice.default)(newRemove).call(newRemove, index, 1);
528
- }
529
- });
530
- (0, _forEach.default)(_context8 = this.relationsToRemove).call(_context8, function (r) {
531
- var index = (0, _indexOf.default)(newRemove).call(newRemove, r);
532
- if (index < 0) {
533
- newRemove.push(r);
534
- }
535
- });
536
- var newRelation = new RelationOp(newAdd, newRemove);
537
- newRelation._targetClassName = this._targetClassName;
538
- return newRelation;
539
- }
540
- throw new Error('Cannot merge Relation Op with the previous Op');
541
- }
542
- }, {
543
- key: "toJSON",
544
- value: function () /*: { __op?: string, objects?: mixed, ops?: mixed }*/{
545
- var _this7 = this;
546
- var idToPointer = function (id) {
547
- return {
548
- __type: 'Pointer',
549
- className: _this7._targetClassName,
550
- objectId: id
551
- };
380
+ });
381
+ (0, _forEach.default)(_context5 = this.relationsToAdd).call(_context5, r => {
382
+ const index = (0, _indexOf.default)(newAdd).call(newAdd, r);
383
+ if (index < 0) {
384
+ newAdd.push(r);
385
+ }
386
+ });
387
+ const newRemove = (0, _concat.default)(_context6 = previous.relationsToRemove).call(_context6, []);
388
+ (0, _forEach.default)(_context7 = this.relationsToAdd).call(_context7, r => {
389
+ const index = (0, _indexOf.default)(newRemove).call(newRemove, r);
390
+ if (index > -1) {
391
+ (0, _splice.default)(newRemove).call(newRemove, index, 1);
392
+ }
393
+ });
394
+ (0, _forEach.default)(_context8 = this.relationsToRemove).call(_context8, r => {
395
+ const index = (0, _indexOf.default)(newRemove).call(newRemove, r);
396
+ if (index < 0) {
397
+ newRemove.push(r);
398
+ }
399
+ });
400
+ const newRelation = new RelationOp(newAdd, newRemove);
401
+ newRelation._targetClassName = this._targetClassName;
402
+ return newRelation;
403
+ }
404
+ throw new Error('Cannot merge Relation Op with the previous Op');
405
+ }
406
+ toJSON() {
407
+ const idToPointer = id => {
408
+ return {
409
+ __type: 'Pointer',
410
+ className: this._targetClassName,
411
+ objectId: id
412
+ };
413
+ };
414
+ let pointers = null;
415
+ let adds = null;
416
+ let removes = null;
417
+ if (this.relationsToAdd.length > 0) {
418
+ var _context9;
419
+ pointers = (0, _map.default)(_context9 = this.relationsToAdd).call(_context9, idToPointer);
420
+ adds = {
421
+ __op: 'AddRelation',
422
+ objects: pointers
423
+ };
424
+ }
425
+ if (this.relationsToRemove.length > 0) {
426
+ var _context10;
427
+ pointers = (0, _map.default)(_context10 = this.relationsToRemove).call(_context10, idToPointer);
428
+ removes = {
429
+ __op: 'RemoveRelation',
430
+ objects: pointers
431
+ };
432
+ }
433
+ if (adds && removes) {
434
+ return {
435
+ __op: 'Batch',
436
+ ops: [adds, removes]
552
437
  };
553
- var adds = null;
554
- var removes = null;
555
- var pointers = null;
556
- if (this.relationsToAdd.length > 0) {
557
- var _context9;
558
- pointers = (0, _map.default)(_context9 = this.relationsToAdd).call(_context9, idToPointer);
559
- adds = {
560
- __op: 'AddRelation',
561
- objects: pointers
562
- };
563
- }
564
- if (this.relationsToRemove.length > 0) {
565
- var _context10;
566
- pointers = (0, _map.default)(_context10 = this.relationsToRemove).call(_context10, idToPointer);
567
- removes = {
568
- __op: 'RemoveRelation',
569
- objects: pointers
570
- };
571
- }
572
- if (adds && removes) {
573
- return {
574
- __op: 'Batch',
575
- ops: [adds, removes]
576
- };
577
- }
578
- return adds || removes || {};
579
438
  }
580
- }]);
581
- return RelationOp;
582
- }(Op);
439
+ return adds || removes || {};
440
+ }
441
+ }
583
442
  exports.RelationOp = RelationOp;
584
443
  _CoreManager.default.setParseOp({
585
- Op: Op,
586
- opFromJSON: opFromJSON,
587
- SetOp: SetOp,
588
- UnsetOp: UnsetOp,
589
- IncrementOp: IncrementOp,
590
- AddOp: AddOp,
591
- RelationOp: RelationOp,
592
- RemoveOp: RemoveOp,
593
- AddUniqueOp: AddUniqueOp
444
+ Op,
445
+ opFromJSON,
446
+ SetOp,
447
+ UnsetOp,
448
+ IncrementOp,
449
+ AddOp,
450
+ RelationOp,
451
+ RemoveOp,
452
+ AddUniqueOp
594
453
  });