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.
- package/dist/parse.js +10186 -14918
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +10180 -15057
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/Analytics.js +7 -11
- package/lib/browser/AnonymousUtils.js +17 -22
- package/lib/browser/Cloud.js +24 -46
- package/lib/browser/CoreManager.js +71 -79
- package/lib/browser/CryptoController.js +14 -9
- package/lib/browser/EventEmitter.js +9 -2
- package/lib/browser/EventuallyQueue.js +156 -357
- package/lib/browser/FacebookUtils.js +23 -28
- package/lib/browser/IndexedDBStorageController.js +18 -14
- package/lib/browser/InstallationController.js +55 -121
- package/lib/browser/LiveQueryClient.js +312 -446
- package/lib/browser/LiveQuerySubscription.js +25 -28
- package/lib/browser/LocalDatastore.js +254 -578
- package/lib/browser/LocalDatastoreController.default.js +48 -227
- package/lib/browser/LocalDatastoreController.js +11 -1
- package/lib/browser/LocalDatastoreController.react-native.js +72 -164
- package/lib/browser/LocalDatastoreUtils.js +4 -12
- package/lib/browser/ObjectStateMutations.js +89 -95
- package/lib/browser/OfflineQuery.js +106 -198
- package/lib/browser/Parse.js +45 -61
- package/lib/browser/ParseACL.js +242 -288
- package/lib/browser/ParseCLP.js +372 -580
- package/lib/browser/ParseConfig.js +115 -138
- package/lib/browser/ParseError.js +85 -182
- package/lib/browser/ParseFile.js +296 -444
- package/lib/browser/ParseGeoPoint.js +121 -140
- package/lib/browser/ParseHooks.js +12 -14
- package/lib/browser/ParseInstallation.js +226 -354
- package/lib/browser/ParseLiveQuery.js +74 -148
- package/lib/browser/ParseObject.js +2017 -2622
- package/lib/browser/ParseOp.js +343 -484
- package/lib/browser/ParsePolygon.js +101 -120
- package/lib/browser/ParseQuery.js +1722 -2068
- package/lib/browser/ParseRelation.js +99 -118
- package/lib/browser/ParseRole.js +88 -144
- package/lib/browser/ParseSchema.js +372 -434
- package/lib/browser/ParseSession.js +62 -110
- package/lib/browser/ParseUser.js +942 -1270
- package/lib/browser/Push.js +16 -44
- package/lib/browser/RESTController.js +85 -124
- package/lib/browser/SingleInstanceStateController.js +57 -86
- package/lib/browser/Socket.weapp.js +50 -33
- package/lib/browser/Storage.js +23 -28
- package/lib/browser/StorageController.browser.js +16 -13
- package/lib/browser/StorageController.default.js +15 -14
- package/lib/browser/StorageController.js +14 -1
- package/lib/browser/StorageController.react-native.js +31 -30
- package/lib/browser/StorageController.weapp.js +19 -13
- package/lib/browser/TaskQueue.js +37 -49
- package/lib/browser/UniqueInstanceStateController.js +65 -86
- package/lib/browser/WebSocketController.js +11 -4
- package/lib/browser/Xhr.weapp.js +90 -78
- package/lib/browser/arrayContainsObject.js +3 -3
- package/lib/browser/canBeSerialized.js +10 -11
- package/lib/browser/decode.js +11 -11
- package/lib/browser/encode.js +11 -11
- package/lib/browser/equals.js +9 -10
- package/lib/browser/escape.js +2 -2
- package/lib/browser/isRevocableSession.js +1 -1
- package/lib/browser/parseDate.js +10 -10
- package/lib/browser/promiseUtils.js +19 -19
- package/lib/browser/unique.js +4 -4
- package/lib/browser/unsavedChildren.js +20 -21
- package/lib/browser/uuid.js +2 -4
- package/lib/node/Analytics.js +2 -6
- package/lib/node/AnonymousUtils.js +7 -12
- package/lib/node/Cloud.js +8 -12
- package/lib/node/CoreManager.js +59 -67
- package/lib/node/CryptoController.js +8 -3
- package/lib/node/EventEmitter.js +7 -1
- package/lib/node/EventuallyQueue.js +18 -37
- package/lib/node/FacebookUtils.js +1 -5
- package/lib/node/IndexedDBStorageController.js +14 -10
- package/lib/node/InstallationController.js +7 -8
- package/lib/node/LiveQueryClient.js +20 -32
- package/lib/node/LiveQuerySubscription.js +3 -4
- package/lib/node/LocalDatastore.js +20 -24
- package/lib/node/LocalDatastoreController.default.js +12 -11
- package/lib/node/LocalDatastoreController.js +14 -1
- package/lib/node/LocalDatastoreController.react-native.js +27 -22
- package/lib/node/LocalDatastoreUtils.js +4 -12
- package/lib/node/ObjectStateMutations.js +52 -36
- package/lib/node/OfflineQuery.js +37 -23
- package/lib/node/Parse.js +35 -49
- package/lib/node/ParseACL.js +18 -27
- package/lib/node/ParseCLP.js +38 -50
- package/lib/node/ParseConfig.js +7 -14
- package/lib/node/ParseError.js +457 -458
- package/lib/node/ParseFile.js +33 -66
- package/lib/node/ParseGeoPoint.js +22 -17
- package/lib/node/ParseHooks.js +0 -2
- package/lib/node/ParseInstallation.js +21 -8
- package/lib/node/ParseLiveQuery.js +6 -11
- package/lib/node/ParseObject.js +138 -167
- package/lib/node/ParseOp.js +32 -44
- package/lib/node/ParsePolygon.js +11 -17
- package/lib/node/ParseQuery.js +118 -164
- package/lib/node/ParseRelation.js +7 -16
- package/lib/node/ParseRole.js +7 -13
- package/lib/node/ParseSchema.js +26 -39
- package/lib/node/ParseSession.js +7 -8
- package/lib/node/ParseUser.js +70 -76
- package/lib/node/Push.js +5 -15
- package/lib/node/RESTController.js +21 -33
- package/lib/node/SingleInstanceStateController.js +41 -69
- package/lib/node/Socket.weapp.js +23 -2
- package/lib/node/Storage.js +11 -16
- package/lib/node/StorageController.browser.js +10 -8
- package/lib/node/StorageController.default.js +9 -9
- package/lib/node/StorageController.js +16 -1
- package/lib/node/StorageController.react-native.js +17 -17
- package/lib/node/StorageController.weapp.js +14 -8
- package/lib/node/TaskQueue.js +8 -11
- package/lib/node/UniqueInstanceStateController.js +40 -60
- package/lib/node/WebSocketController.js +15 -2
- package/lib/node/Xhr.weapp.js +11 -2
- package/lib/node/arrayContainsObject.js +1 -1
- package/lib/node/canBeSerialized.js +2 -2
- package/lib/node/decode.js +1 -1
- package/lib/node/encode.js +2 -2
- package/lib/node/equals.js +1 -1
- package/lib/node/escape.js +1 -1
- package/lib/node/isRevocableSession.js +1 -1
- package/lib/node/parseDate.js +1 -1
- package/lib/node/promiseUtils.js +7 -7
- package/lib/node/unique.js +2 -2
- package/lib/node/unsavedChildren.js +2 -2
- package/lib/node/uuid.js +2 -4
- package/lib/react-native/Analytics.js +2 -2
- package/lib/react-native/AnonymousUtils.js +3 -4
- package/lib/react-native/Cloud.js +0 -1
- package/lib/react-native/CoreManager.js +2 -3
- package/lib/react-native/CryptoController.js +6 -1
- package/lib/react-native/EventEmitter.js +6 -1
- package/lib/react-native/EventuallyQueue.js +1 -2
- package/lib/react-native/FacebookUtils.js +1 -2
- package/lib/react-native/IndexedDBStorageController.js +11 -5
- package/lib/react-native/InstallationController.js +1 -2
- package/lib/react-native/LiveQueryClient.js +51 -36
- package/lib/react-native/LiveQuerySubscription.js +2 -4
- package/lib/react-native/LocalDatastore.js +41 -17
- package/lib/react-native/LocalDatastoreController.default.js +6 -1
- package/lib/react-native/LocalDatastoreController.js +11 -1
- package/lib/react-native/LocalDatastoreController.react-native.js +16 -11
- package/lib/react-native/LocalDatastoreUtils.js +3 -6
- package/lib/react-native/ObjectStateMutations.js +30 -9
- package/lib/react-native/OfflineQuery.js +25 -20
- package/lib/react-native/Parse.js +24 -38
- package/lib/react-native/ParseACL.js +4 -6
- package/lib/react-native/ParseCLP.js +5 -7
- package/lib/react-native/ParseConfig.js +4 -6
- package/lib/react-native/ParseError.js +13 -31
- package/lib/react-native/ParseFile.js +10 -10
- package/lib/react-native/ParseGeoPoint.js +2 -4
- package/lib/react-native/ParseInstallation.js +13 -30
- package/lib/react-native/ParseLiveQuery.js +2 -4
- package/lib/react-native/ParseObject.js +81 -90
- package/lib/react-native/ParseOp.js +41 -79
- package/lib/react-native/ParsePolygon.js +2 -4
- package/lib/react-native/ParseQuery.js +87 -81
- package/lib/react-native/ParseRelation.js +2 -4
- package/lib/react-native/ParseRole.js +14 -31
- package/lib/react-native/ParseSchema.js +3 -5
- package/lib/react-native/ParseSession.js +12 -29
- package/lib/react-native/ParseUser.js +32 -51
- package/lib/react-native/RESTController.js +10 -4
- package/lib/react-native/SingleInstanceStateController.js +23 -37
- package/lib/react-native/Socket.weapp.js +9 -4
- package/lib/react-native/Storage.js +1 -2
- package/lib/react-native/StorageController.browser.js +6 -1
- package/lib/react-native/StorageController.default.js +6 -1
- package/lib/react-native/StorageController.js +13 -1
- package/lib/react-native/StorageController.react-native.js +11 -6
- package/lib/react-native/StorageController.weapp.js +6 -1
- package/lib/react-native/TaskQueue.js +8 -4
- package/lib/react-native/UniqueInstanceStateController.js +23 -37
- package/lib/react-native/WebSocketController.js +9 -1
- package/lib/react-native/Xhr.weapp.js +9 -4
- package/lib/react-native/unsavedChildren.js +3 -3
- package/lib/react-native/uuid.js +1 -2
- package/lib/weapp/Analytics.js +7 -11
- package/lib/weapp/AnonymousUtils.js +17 -22
- package/lib/weapp/Cloud.js +24 -46
- package/lib/weapp/CoreManager.js +71 -79
- package/lib/weapp/CryptoController.js +14 -9
- package/lib/weapp/EventEmitter.js +9 -2
- package/lib/weapp/EventuallyQueue.js +156 -357
- package/lib/weapp/FacebookUtils.js +23 -28
- package/lib/weapp/IndexedDBStorageController.js +18 -14
- package/lib/weapp/InstallationController.js +55 -121
- package/lib/weapp/LiveQueryClient.js +312 -446
- package/lib/weapp/LiveQuerySubscription.js +25 -28
- package/lib/weapp/LocalDatastore.js +254 -578
- package/lib/weapp/LocalDatastoreController.default.js +48 -227
- package/lib/weapp/LocalDatastoreController.js +11 -1
- package/lib/weapp/LocalDatastoreController.react-native.js +72 -164
- package/lib/weapp/LocalDatastoreUtils.js +4 -12
- package/lib/weapp/ObjectStateMutations.js +89 -95
- package/lib/weapp/OfflineQuery.js +106 -198
- package/lib/weapp/Parse.js +45 -60
- package/lib/weapp/ParseACL.js +242 -288
- package/lib/weapp/ParseCLP.js +372 -580
- package/lib/weapp/ParseConfig.js +115 -138
- package/lib/weapp/ParseError.js +85 -182
- package/lib/weapp/ParseFile.js +297 -446
- package/lib/weapp/ParseGeoPoint.js +121 -140
- package/lib/weapp/ParseHooks.js +12 -14
- package/lib/weapp/ParseInstallation.js +226 -354
- package/lib/weapp/ParseLiveQuery.js +74 -148
- package/lib/weapp/ParseObject.js +2017 -2622
- package/lib/weapp/ParseOp.js +343 -484
- package/lib/weapp/ParsePolygon.js +101 -120
- package/lib/weapp/ParseQuery.js +1722 -2068
- package/lib/weapp/ParseRelation.js +99 -118
- package/lib/weapp/ParseRole.js +88 -144
- package/lib/weapp/ParseSchema.js +372 -434
- package/lib/weapp/ParseSession.js +62 -110
- package/lib/weapp/ParseUser.js +942 -1270
- package/lib/weapp/Push.js +16 -44
- package/lib/weapp/RESTController.js +86 -125
- package/lib/weapp/SingleInstanceStateController.js +57 -86
- package/lib/weapp/Socket.weapp.js +50 -33
- package/lib/weapp/Storage.js +23 -28
- package/lib/weapp/StorageController.browser.js +16 -13
- package/lib/weapp/StorageController.default.js +15 -14
- package/lib/weapp/StorageController.js +14 -1
- package/lib/weapp/StorageController.react-native.js +31 -30
- package/lib/weapp/StorageController.weapp.js +19 -13
- package/lib/weapp/TaskQueue.js +37 -49
- package/lib/weapp/UniqueInstanceStateController.js +65 -86
- package/lib/weapp/WebSocketController.js +11 -4
- package/lib/weapp/Xhr.weapp.js +90 -78
- package/lib/weapp/arrayContainsObject.js +3 -3
- package/lib/weapp/canBeSerialized.js +10 -11
- package/lib/weapp/decode.js +11 -11
- package/lib/weapp/encode.js +11 -11
- package/lib/weapp/equals.js +9 -10
- package/lib/weapp/escape.js +2 -2
- package/lib/weapp/isRevocableSession.js +1 -1
- package/lib/weapp/parseDate.js +10 -10
- package/lib/weapp/promiseUtils.js +19 -19
- package/lib/weapp/unique.js +4 -4
- package/lib/weapp/unsavedChildren.js +20 -21
- package/lib/weapp/uuid.js +6 -8
- package/package.json +23 -30
package/lib/weapp/ParseOp.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
for (
|
|
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
|
-
|
|
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
|
-
|
|
62
|
+
toRemove = (0, _concat.default)(toRemove).call(toRemove, (0, _decode.default)(json.ops[i].objects));
|
|
97
63
|
}
|
|
98
64
|
}
|
|
99
|
-
return new RelationOp(
|
|
65
|
+
return new RelationOp(toAdd, toRemove);
|
|
100
66
|
}
|
|
101
67
|
}
|
|
102
68
|
return null;
|
|
103
69
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
(
|
|
109
|
-
|
|
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
|
-
|
|
124
|
-
(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
|
|
154
|
-
(
|
|
155
|
-
|
|
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
|
-
(
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
-
|
|
182
|
-
(
|
|
183
|
-
|
|
184
|
-
|
|
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
|
-
|
|
193
|
-
return _this2;
|
|
115
|
+
this._amount = amount;
|
|
194
116
|
}
|
|
195
|
-
(
|
|
196
|
-
|
|
197
|
-
|
|
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
|
-
|
|
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
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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
|
-
|
|
233
|
-
}
|
|
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
|
-
|
|
236
|
-
(
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
-
(
|
|
247
|
-
|
|
248
|
-
|
|
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
|
-
|
|
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
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
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
|
-
|
|
284
|
-
}
|
|
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
|
-
|
|
287
|
-
(
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
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
|
-
(
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
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
|
-
|
|
319
|
-
|
|
320
|
-
|
|
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
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
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
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
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
|
-
|
|
349
|
-
|
|
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
|
-
|
|
352
|
-
(
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
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
|
-
(
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
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
|
-
|
|
268
|
+
return removed;
|
|
390
269
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
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
|
-
|
|
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
|
-
|
|
432
|
-
|
|
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
|
-
|
|
435
|
-
(
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
(0,
|
|
440
|
-
|
|
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
|
-
|
|
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
|
-
|
|
320
|
+
this.relationsToRemove = (0, _unique.default)((0, _map.default)(removes).call(removes, this._extractId, this));
|
|
450
321
|
}
|
|
451
|
-
return _this6;
|
|
452
322
|
}
|
|
453
|
-
(
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
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
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
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
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
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
|
-
|
|
582
|
-
}
|
|
439
|
+
return adds || removes || {};
|
|
440
|
+
}
|
|
441
|
+
}
|
|
583
442
|
exports.RelationOp = RelationOp;
|
|
584
443
|
_CoreManager.default.setParseOp({
|
|
585
|
-
Op
|
|
586
|
-
opFromJSON
|
|
587
|
-
SetOp
|
|
588
|
-
UnsetOp
|
|
589
|
-
IncrementOp
|
|
590
|
-
AddOp
|
|
591
|
-
RelationOp
|
|
592
|
-
RemoveOp
|
|
593
|
-
AddUniqueOp
|
|
444
|
+
Op,
|
|
445
|
+
opFromJSON,
|
|
446
|
+
SetOp,
|
|
447
|
+
UnsetOp,
|
|
448
|
+
IncrementOp,
|
|
449
|
+
AddOp,
|
|
450
|
+
RelationOp,
|
|
451
|
+
RemoveOp,
|
|
452
|
+
AddUniqueOp
|
|
594
453
|
});
|