parse 5.1.0 → 5.2.0-alpha.1
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 +1556 -1309
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +1560 -1313
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/Cloud.js +7 -11
- package/lib/browser/CoreManager.js +10 -10
- package/lib/browser/EventuallyQueue.js +1 -1
- package/lib/browser/InstallationController.js +3 -3
- package/lib/browser/LiveQueryClient.js +102 -60
- package/lib/browser/LocalDatastore.js +189 -147
- package/lib/browser/LocalDatastoreController.default.js +14 -9
- package/lib/browser/LocalDatastoreController.react-native.js +14 -12
- package/lib/browser/LocalDatastoreUtils.js +0 -5
- package/lib/browser/ObjectStateMutations.js +57 -21
- package/lib/browser/Parse.js +2 -2
- package/lib/browser/ParseCLP.js +9 -17
- package/lib/browser/ParseFile.js +27 -31
- package/lib/browser/ParseGeoPoint.js +9 -3
- package/lib/browser/ParseHooks.js +13 -13
- package/lib/browser/ParseInstallation.js +117 -9
- package/lib/browser/ParseObject.js +19 -17
- package/lib/browser/ParseOp.js +17 -17
- package/lib/browser/ParsePolygon.js +1 -1
- package/lib/browser/ParseQuery.js +147 -149
- package/lib/browser/ParseRole.js +5 -9
- package/lib/browser/ParseSchema.js +1 -1
- package/lib/browser/ParseUser.js +66 -51
- package/lib/browser/Push.js +5 -10
- package/lib/browser/RESTController.js +1 -1
- package/lib/browser/SingleInstanceStateController.js +1 -1
- package/lib/browser/TaskQueue.js +10 -10
- package/lib/browser/UniqueInstanceStateController.js +1 -1
- package/lib/browser/arrayContainsObject.js +0 -4
- package/lib/browser/canBeSerialized.js +0 -4
- package/lib/browser/decode.js +0 -7
- package/lib/browser/encode.js +3 -7
- package/lib/browser/equals.js +1 -1
- package/lib/browser/escape.js +0 -4
- package/lib/browser/isRevocableSession.js +0 -4
- package/lib/browser/parseDate.js +1 -5
- package/lib/browser/promiseUtils.js +11 -10
- package/lib/browser/unique.js +1 -5
- package/lib/browser/unsavedChildren.js +0 -8
- package/lib/browser/uuid.js +2 -2
- package/lib/node/Cloud.js +7 -11
- package/lib/node/CoreManager.js +10 -10
- package/lib/node/EventuallyQueue.js +1 -1
- package/lib/node/InstallationController.js +3 -3
- package/lib/node/LiveQueryClient.js +14 -24
- package/lib/node/LocalDatastore.js +7 -11
- package/lib/node/LocalDatastoreController.default.js +12 -10
- package/lib/node/LocalDatastoreController.react-native.js +13 -12
- package/lib/node/LocalDatastoreUtils.js +0 -5
- package/lib/node/ObjectStateMutations.js +45 -19
- package/lib/node/Parse.js +2 -2
- package/lib/node/ParseCLP.js +8 -18
- package/lib/node/ParseFile.js +27 -40
- package/lib/node/ParseGeoPoint.js +9 -3
- package/lib/node/ParseHooks.js +13 -13
- package/lib/node/ParseInstallation.js +60 -2
- package/lib/node/ParseObject.js +19 -17
- package/lib/node/ParseOp.js +21 -21
- package/lib/node/ParsePolygon.js +1 -1
- package/lib/node/ParseQuery.js +84 -107
- package/lib/node/ParseRole.js +3 -8
- package/lib/node/ParseSchema.js +4 -4
- package/lib/node/ParseUser.js +42 -37
- package/lib/node/Push.js +3 -8
- package/lib/node/RESTController.js +1 -1
- package/lib/node/SingleInstanceStateController.js +1 -1
- package/lib/node/TaskQueue.js +9 -11
- package/lib/node/UniqueInstanceStateController.js +1 -1
- package/lib/node/arrayContainsObject.js +0 -4
- package/lib/node/canBeSerialized.js +0 -4
- package/lib/node/decode.js +0 -7
- package/lib/node/encode.js +3 -7
- package/lib/node/equals.js +1 -1
- package/lib/node/escape.js +0 -4
- package/lib/node/isRevocableSession.js +0 -4
- package/lib/node/parseDate.js +1 -5
- package/lib/node/promiseUtils.js +11 -10
- package/lib/node/unique.js +1 -5
- package/lib/node/unsavedChildren.js +0 -8
- package/lib/node/uuid.js +2 -2
- package/lib/react-native/Cloud.js +0 -1
- package/lib/react-native/CoreManager.js +1 -1
- package/lib/react-native/LiveQueryClient.js +49 -32
- package/lib/react-native/LocalDatastore.js +38 -14
- package/lib/react-native/LocalDatastoreController.default.js +7 -1
- package/lib/react-native/LocalDatastoreController.react-native.js +7 -1
- package/lib/react-native/ObjectStateMutations.js +30 -9
- package/lib/react-native/ParseCLP.js +3 -3
- package/lib/react-native/ParseFile.js +7 -6
- package/lib/react-native/ParseInstallation.js +51 -3
- package/lib/react-native/ParseObject.js +6 -5
- package/lib/react-native/ParseQuery.js +45 -37
- package/lib/react-native/ParseRole.js +1 -1
- package/lib/react-native/ParseUser.js +22 -16
- package/lib/react-native/TaskQueue.js +8 -2
- package/lib/react-native/decode.js +0 -1
- package/lib/react-native/promiseUtils.js +5 -4
- package/lib/react-native/uuid.js +1 -2
- package/lib/weapp/Cloud.js +7 -11
- package/lib/weapp/CoreManager.js +10 -10
- package/lib/weapp/EventuallyQueue.js +1 -1
- package/lib/weapp/InstallationController.js +3 -3
- package/lib/weapp/LiveQueryClient.js +102 -60
- package/lib/weapp/LocalDatastore.js +189 -147
- package/lib/weapp/LocalDatastoreController.default.js +14 -9
- package/lib/weapp/LocalDatastoreController.react-native.js +14 -12
- package/lib/weapp/LocalDatastoreUtils.js +0 -5
- package/lib/weapp/ObjectStateMutations.js +57 -21
- package/lib/weapp/Parse.js +2 -2
- package/lib/weapp/ParseCLP.js +9 -17
- package/lib/weapp/ParseFile.js +27 -31
- package/lib/weapp/ParseGeoPoint.js +9 -3
- package/lib/weapp/ParseHooks.js +13 -13
- package/lib/weapp/ParseInstallation.js +117 -9
- package/lib/weapp/ParseObject.js +19 -17
- package/lib/weapp/ParseOp.js +17 -17
- package/lib/weapp/ParsePolygon.js +1 -1
- package/lib/weapp/ParseQuery.js +147 -149
- package/lib/weapp/ParseRole.js +5 -9
- package/lib/weapp/ParseSchema.js +1 -1
- package/lib/weapp/ParseUser.js +66 -51
- package/lib/weapp/Push.js +5 -10
- package/lib/weapp/RESTController.js +1 -1
- package/lib/weapp/SingleInstanceStateController.js +1 -1
- package/lib/weapp/TaskQueue.js +10 -10
- package/lib/weapp/UniqueInstanceStateController.js +1 -1
- package/lib/weapp/arrayContainsObject.js +0 -4
- package/lib/weapp/canBeSerialized.js +0 -4
- package/lib/weapp/decode.js +0 -7
- package/lib/weapp/encode.js +3 -7
- package/lib/weapp/equals.js +1 -1
- package/lib/weapp/escape.js +0 -4
- package/lib/weapp/isRevocableSession.js +0 -4
- package/lib/weapp/parseDate.js +1 -5
- package/lib/weapp/promiseUtils.js +11 -10
- package/lib/weapp/unique.js +1 -5
- package/lib/weapp/unsavedChildren.js +0 -8
- package/lib/weapp/uuid.js +3 -3
- package/package.json +5 -6
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
8
|
+
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
8
9
|
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
9
10
|
function _interopRequireDefault(obj) {
|
|
10
11
|
return obj && obj.__esModule ? obj : {
|
|
@@ -49,6 +50,7 @@ class ParseInstallation extends _ParseObject.default {
|
|
|
49
50
|
*
|
|
50
51
|
* @property {string} appIdentifier
|
|
51
52
|
* @static
|
|
53
|
+
* @returns {string}
|
|
52
54
|
*/
|
|
53
55
|
get appIdentifier() {
|
|
54
56
|
return this.get('appIdentifier');
|
|
@@ -59,6 +61,7 @@ class ParseInstallation extends _ParseObject.default {
|
|
|
59
61
|
*
|
|
60
62
|
* @property {string} appVersion
|
|
61
63
|
* @static
|
|
64
|
+
* @returns {string}
|
|
62
65
|
*/
|
|
63
66
|
get appVersion() {
|
|
64
67
|
return this.get('appVersion');
|
|
@@ -69,6 +72,7 @@ class ParseInstallation extends _ParseObject.default {
|
|
|
69
72
|
*
|
|
70
73
|
* @property {string} appName
|
|
71
74
|
* @static
|
|
75
|
+
* @returns {string}
|
|
72
76
|
*/
|
|
73
77
|
get appName() {
|
|
74
78
|
return this.get('appName');
|
|
@@ -81,6 +85,7 @@ class ParseInstallation extends _ParseObject.default {
|
|
|
81
85
|
*
|
|
82
86
|
* @property {number} badge
|
|
83
87
|
* @static
|
|
88
|
+
* @returns {number}
|
|
84
89
|
*/
|
|
85
90
|
get badge() {
|
|
86
91
|
return this.get('badge');
|
|
@@ -91,6 +96,7 @@ class ParseInstallation extends _ParseObject.default {
|
|
|
91
96
|
*
|
|
92
97
|
* @property {string[]} channels
|
|
93
98
|
* @static
|
|
99
|
+
* @returns {string[]}
|
|
94
100
|
*/
|
|
95
101
|
get channels() {
|
|
96
102
|
return this.get('channels');
|
|
@@ -101,6 +107,7 @@ class ParseInstallation extends _ParseObject.default {
|
|
|
101
107
|
*
|
|
102
108
|
* @property {string} deviceToken
|
|
103
109
|
* @static
|
|
110
|
+
* @returns {string}
|
|
104
111
|
*/
|
|
105
112
|
get deviceToken() {
|
|
106
113
|
return this.get('deviceToken');
|
|
@@ -111,6 +118,7 @@ class ParseInstallation extends _ParseObject.default {
|
|
|
111
118
|
*
|
|
112
119
|
* @property {string} deviceType
|
|
113
120
|
* @static
|
|
121
|
+
* @returns {string}
|
|
114
122
|
*/
|
|
115
123
|
get deviceType() {
|
|
116
124
|
return this.get('deviceType');
|
|
@@ -121,6 +129,7 @@ class ParseInstallation extends _ParseObject.default {
|
|
|
121
129
|
*
|
|
122
130
|
* @property {string} GCMSenderId
|
|
123
131
|
* @static
|
|
132
|
+
* @returns {string}
|
|
124
133
|
*/
|
|
125
134
|
get GCMSenderId() {
|
|
126
135
|
return this.get('GCMSenderId');
|
|
@@ -131,6 +140,7 @@ class ParseInstallation extends _ParseObject.default {
|
|
|
131
140
|
*
|
|
132
141
|
* @property {string} installationId
|
|
133
142
|
* @static
|
|
143
|
+
* @returns {string}
|
|
134
144
|
*/
|
|
135
145
|
get installationId() {
|
|
136
146
|
return this.get('installationId');
|
|
@@ -141,6 +151,7 @@ class ParseInstallation extends _ParseObject.default {
|
|
|
141
151
|
*
|
|
142
152
|
* @property {string} localeIdentifier
|
|
143
153
|
* @static
|
|
154
|
+
* @returns {string}
|
|
144
155
|
*/
|
|
145
156
|
get localeIdentifier() {
|
|
146
157
|
return this.get('localeIdentifier');
|
|
@@ -151,6 +162,7 @@ class ParseInstallation extends _ParseObject.default {
|
|
|
151
162
|
*
|
|
152
163
|
* @property {string} parseVersion
|
|
153
164
|
* @static
|
|
165
|
+
* @returns {string}
|
|
154
166
|
*/
|
|
155
167
|
get parseVersion() {
|
|
156
168
|
return this.get('parseVersion');
|
|
@@ -161,6 +173,7 @@ class ParseInstallation extends _ParseObject.default {
|
|
|
161
173
|
*
|
|
162
174
|
* @property {string} pushType
|
|
163
175
|
* @static
|
|
176
|
+
* @returns {string}
|
|
164
177
|
*/
|
|
165
178
|
get pushType() {
|
|
166
179
|
return this.get('pushType');
|
|
@@ -171,6 +184,7 @@ class ParseInstallation extends _ParseObject.default {
|
|
|
171
184
|
*
|
|
172
185
|
* @property {string} timeZone
|
|
173
186
|
* @static
|
|
187
|
+
* @returns {string}
|
|
174
188
|
*/
|
|
175
189
|
get timeZone() {
|
|
176
190
|
return this.get('timeZone');
|
|
@@ -190,22 +204,66 @@ class ParseInstallation extends _ParseObject.default {
|
|
|
190
204
|
*
|
|
191
205
|
* @property {object} DEVICE_TYPES
|
|
192
206
|
* @static
|
|
207
|
+
* @returns {object}
|
|
193
208
|
*/
|
|
194
209
|
static get DEVICE_TYPES() /*: DeviceInterface*/{
|
|
195
210
|
return DEVICE_TYPES;
|
|
196
211
|
}
|
|
197
212
|
|
|
198
213
|
/**
|
|
199
|
-
* Wrap the default
|
|
214
|
+
* Wrap the default fetch behavior with functionality to update local storage.
|
|
215
|
+
* If the installation is deleted on the server, retry the fetch as a save operation.
|
|
216
|
+
*
|
|
217
|
+
* @param {...any} args
|
|
218
|
+
* @returns {Promise}
|
|
219
|
+
*/
|
|
220
|
+
async fetch(...args) /*: Promise<ParseInstallation>*/{
|
|
221
|
+
try {
|
|
222
|
+
await super.fetch.apply(this, args);
|
|
223
|
+
} catch (e) {
|
|
224
|
+
if (e.code !== _ParseError.default.OBJECT_NOT_FOUND) {
|
|
225
|
+
throw e;
|
|
226
|
+
}
|
|
227
|
+
// The installation was deleted from the server.
|
|
228
|
+
// We always want fetch to succeed.
|
|
229
|
+
delete this.id;
|
|
230
|
+
this._getId(); // Generate localId
|
|
231
|
+
this._markAllFieldsDirty();
|
|
232
|
+
await super.save.apply(this, args);
|
|
233
|
+
}
|
|
234
|
+
await _CoreManager.default.getInstallationController().updateInstallationOnDisk(this);
|
|
235
|
+
return this;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Wrap the default save behavior with functionality to update the local storage.
|
|
240
|
+
* If the installation is deleted on the server, retry saving a new installation.
|
|
200
241
|
*
|
|
201
242
|
* @param {...any} args
|
|
202
243
|
* @returns {Promise}
|
|
203
244
|
*/
|
|
204
245
|
async save(...args) /*: Promise<this>*/{
|
|
205
|
-
|
|
246
|
+
try {
|
|
247
|
+
await super.save.apply(this, args);
|
|
248
|
+
} catch (e) {
|
|
249
|
+
if (e.code !== _ParseError.default.OBJECT_NOT_FOUND) {
|
|
250
|
+
throw e;
|
|
251
|
+
}
|
|
252
|
+
// The installation was deleted from the server.
|
|
253
|
+
// We always want save to succeed.
|
|
254
|
+
delete this.id;
|
|
255
|
+
this._getId(); // Generate localId
|
|
256
|
+
this._markAllFieldsDirty();
|
|
257
|
+
await super.save.apply(this, args);
|
|
258
|
+
}
|
|
206
259
|
await _CoreManager.default.getInstallationController().updateInstallationOnDisk(this);
|
|
207
260
|
return this;
|
|
208
261
|
}
|
|
262
|
+
_markAllFieldsDirty() {
|
|
263
|
+
for (const [key, value] of Object.entries(this.attributes)) {
|
|
264
|
+
this.set(key, value);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
209
267
|
|
|
210
268
|
/**
|
|
211
269
|
* Get the current Parse.Installation from disk. If doesn't exists, create an new installation.
|
package/lib/node/ParseObject.js
CHANGED
|
@@ -124,6 +124,7 @@ class ParseObject {
|
|
|
124
124
|
* @param {string} className The class name for the object
|
|
125
125
|
* @param {object} attributes The initial set of data to store in the object.
|
|
126
126
|
* @param {object} options The options for this object instance.
|
|
127
|
+
* @param {boolean} [options.ignoreValidation=false] Set to `true` ignore any attribute validation errors.
|
|
127
128
|
*/
|
|
128
129
|
constructor(className /*:: ?: string | { className: string, [attr: string]: any }*/, attributes /*:: ?: { [attr: string]: any }*/, options /*:: ?: { ignoreValidation: boolean }*/) {
|
|
129
130
|
// Enable legacy initializers
|
|
@@ -1167,7 +1168,7 @@ class ParseObject {
|
|
|
1167
1168
|
* @returns {Promise} A promise that is fulfilled when the fetch
|
|
1168
1169
|
* completes.
|
|
1169
1170
|
*/
|
|
1170
|
-
fetchWithInclude(keys /*:
|
|
1171
|
+
fetchWithInclude(keys /*: string | Array<string | Array<string>>*/, options /*: RequestOptions*/) /*: Promise<any>*/{
|
|
1171
1172
|
options = options || {};
|
|
1172
1173
|
options.include = keys;
|
|
1173
1174
|
return this.fetch(options);
|
|
@@ -1572,7 +1573,7 @@ class ParseObject {
|
|
|
1572
1573
|
* @static
|
|
1573
1574
|
* @returns {Parse.Object[]}
|
|
1574
1575
|
*/
|
|
1575
|
-
static fetchAllWithInclude(list /*: Array<ParseObject>*/, keys /*:
|
|
1576
|
+
static fetchAllWithInclude(list /*: Array<ParseObject>*/, keys /*: string | Array<string | Array<string>>*/, options /*: RequestOptions*/) {
|
|
1576
1577
|
options = options || {};
|
|
1577
1578
|
options.include = keys;
|
|
1578
1579
|
return ParseObject.fetchAll(list, options);
|
|
@@ -1608,7 +1609,7 @@ class ParseObject {
|
|
|
1608
1609
|
* @static
|
|
1609
1610
|
* @returns {Parse.Object[]}
|
|
1610
1611
|
*/
|
|
1611
|
-
static fetchAllIfNeededWithInclude(list /*: Array<ParseObject>*/, keys /*:
|
|
1612
|
+
static fetchAllIfNeededWithInclude(list /*: Array<ParseObject>*/, keys /*: string | Array<string | Array<string>>*/, options /*: RequestOptions*/) {
|
|
1612
1613
|
options = options || {};
|
|
1613
1614
|
options.include = keys;
|
|
1614
1615
|
return ParseObject.fetchAllIfNeeded(list, options);
|
|
@@ -2155,11 +2156,11 @@ const DefaultController = {
|
|
|
2155
2156
|
if (target.length < 1) {
|
|
2156
2157
|
return Promise.resolve([]);
|
|
2157
2158
|
}
|
|
2158
|
-
const objs = [];
|
|
2159
|
-
const ids = [];
|
|
2160
|
-
let className = null;
|
|
2161
|
-
const results = [];
|
|
2162
|
-
let error = null;
|
|
2159
|
+
const objs /*: ParseObject[]*/ = [];
|
|
2160
|
+
const ids /*: string[]*/ = [];
|
|
2161
|
+
let className /*: string | null*/ = null;
|
|
2162
|
+
const results /*: ParseObject[]*/ = [];
|
|
2163
|
+
let error /*: ParseError | null*/ = null;
|
|
2163
2164
|
target.forEach(el => {
|
|
2164
2165
|
if (error) {
|
|
2165
2166
|
return;
|
|
@@ -2301,7 +2302,7 @@ const DefaultController = {
|
|
|
2301
2302
|
}
|
|
2302
2303
|
return Promise.resolve(target);
|
|
2303
2304
|
},
|
|
2304
|
-
save(target /*: ParseObject | Array<ParseObject | ParseFile>*/, options /*: RequestOptions*/) /*: Promise<ParseObject | Array<ParseObject> | ParseFile>*/{
|
|
2305
|
+
save(target /*: ParseObject | null | Array<ParseObject | ParseFile>*/, options /*: RequestOptions*/) /*: Promise<ParseObject | Array<ParseObject> | ParseFile | undefined>*/{
|
|
2305
2306
|
const batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
|
|
2306
2307
|
const localDatastore = _CoreManager.default.getLocalDatastore();
|
|
2307
2308
|
const mapIdForPin = {};
|
|
@@ -2316,12 +2317,13 @@ const DefaultController = {
|
|
|
2316
2317
|
}
|
|
2317
2318
|
let unsaved = target.concat();
|
|
2318
2319
|
for (let i = 0; i < target.length; i++) {
|
|
2319
|
-
|
|
2320
|
-
|
|
2320
|
+
const target_i = target[i];
|
|
2321
|
+
if (target_i instanceof ParseObject) {
|
|
2322
|
+
unsaved = unsaved.concat((0, _unsavedChildren.default)(target_i, true));
|
|
2321
2323
|
}
|
|
2322
2324
|
}
|
|
2323
2325
|
unsaved = (0, _unique.default)(unsaved);
|
|
2324
|
-
const filesSaved /*: Array<ParseFile>*/ = [];
|
|
2326
|
+
const filesSaved /*: Array<Promise<ParseFile> | undefined>*/ = [];
|
|
2325
2327
|
let pending /*: Array<ParseObject>*/ = [];
|
|
2326
2328
|
unsaved.forEach(el => {
|
|
2327
2329
|
if (el instanceof _ParseFile.default) {
|
|
@@ -2354,11 +2356,11 @@ const DefaultController = {
|
|
|
2354
2356
|
|
|
2355
2357
|
// Queue up tasks for each object in the batch.
|
|
2356
2358
|
// When every task is ready, the API request will execute
|
|
2357
|
-
const batchReturned =
|
|
2358
|
-
const batchReady = [];
|
|
2359
|
-
const batchTasks = [];
|
|
2359
|
+
const batchReturned = (0, _promiseUtils.resolvingPromise)();
|
|
2360
|
+
const batchReady /*: ReturnType<typeof resolvingPromise<void>>[]*/ = [];
|
|
2361
|
+
const batchTasks /*: Promise<void>[]*/ = [];
|
|
2360
2362
|
batch.forEach((obj, index) => {
|
|
2361
|
-
const ready =
|
|
2363
|
+
const ready = (0, _promiseUtils.resolvingPromise)();
|
|
2362
2364
|
batchReady.push(ready);
|
|
2363
2365
|
stateController.pushPendingState(obj._getStateIdentifier());
|
|
2364
2366
|
batchTasks.push(stateController.enqueueTask(obj._getStateIdentifier(), function () {
|
|
@@ -2442,7 +2444,7 @@ const DefaultController = {
|
|
|
2442
2444
|
return Promise.reject(error);
|
|
2443
2445
|
});
|
|
2444
2446
|
}
|
|
2445
|
-
return Promise.resolve();
|
|
2447
|
+
return Promise.resolve(undefined);
|
|
2446
2448
|
}
|
|
2447
2449
|
};
|
|
2448
2450
|
_CoreManager.default.setParseObject(ParseObject);
|
package/lib/node/ParseOp.js
CHANGED
|
@@ -69,18 +69,18 @@ function opFromJSON(json /*: { [key: string]: any }*/) /*: ?Op*/{
|
|
|
69
69
|
}
|
|
70
70
|
class Op {
|
|
71
71
|
// Empty parent class
|
|
72
|
-
applyTo() /*:
|
|
73
|
-
mergeWith() /*: ?Op*/{} /* eslint-disable-line no-unused-vars */
|
|
74
|
-
toJSON() /*:
|
|
72
|
+
applyTo() /*: any*/{} /* eslint-disable-line @typescript-eslint/no-unused-vars */
|
|
73
|
+
mergeWith() /*: ?Op*/{} /* eslint-disable-line @typescript-eslint/no-unused-vars */
|
|
74
|
+
toJSON() /*: any*/{}
|
|
75
75
|
}
|
|
76
76
|
exports.Op = Op;
|
|
77
77
|
class SetOp extends Op {
|
|
78
|
-
/*:: _value: ?
|
|
79
|
-
constructor(value /*:
|
|
78
|
+
/*:: _value: ?any;*/
|
|
79
|
+
constructor(value /*: any*/) {
|
|
80
80
|
super();
|
|
81
81
|
this._value = value;
|
|
82
82
|
}
|
|
83
|
-
applyTo() /*:
|
|
83
|
+
applyTo() /*: any*/{
|
|
84
84
|
return this._value;
|
|
85
85
|
}
|
|
86
86
|
mergeWith() /*: SetOp*/{
|
|
@@ -114,7 +114,7 @@ class IncrementOp extends Op {
|
|
|
114
114
|
}
|
|
115
115
|
this._amount = amount;
|
|
116
116
|
}
|
|
117
|
-
applyTo(value /*: ?
|
|
117
|
+
applyTo(value /*: ?any*/) /*: number*/{
|
|
118
118
|
if (typeof value === 'undefined') {
|
|
119
119
|
return this._amount;
|
|
120
120
|
}
|
|
@@ -147,12 +147,12 @@ class IncrementOp extends Op {
|
|
|
147
147
|
}
|
|
148
148
|
exports.IncrementOp = IncrementOp;
|
|
149
149
|
class AddOp extends Op {
|
|
150
|
-
/*:: _value: Array<
|
|
151
|
-
constructor(value /*:
|
|
150
|
+
/*:: _value: Array<any>;*/
|
|
151
|
+
constructor(value /*: any | Array<any>*/) {
|
|
152
152
|
super();
|
|
153
153
|
this._value = Array.isArray(value) ? value : [value];
|
|
154
154
|
}
|
|
155
|
-
applyTo(value /*:
|
|
155
|
+
applyTo(value /*: any*/) /*: Array<any>*/{
|
|
156
156
|
if (value == null) {
|
|
157
157
|
return this._value;
|
|
158
158
|
}
|
|
@@ -176,7 +176,7 @@ class AddOp extends Op {
|
|
|
176
176
|
}
|
|
177
177
|
throw new Error('Cannot merge Add Op with the previous Op');
|
|
178
178
|
}
|
|
179
|
-
toJSON() /*: { __op: string, objects:
|
|
179
|
+
toJSON() /*: { __op: string, objects: any }*/{
|
|
180
180
|
return {
|
|
181
181
|
__op: 'Add',
|
|
182
182
|
objects: (0, _encode.default)(this._value, false, true)
|
|
@@ -185,12 +185,12 @@ class AddOp extends Op {
|
|
|
185
185
|
}
|
|
186
186
|
exports.AddOp = AddOp;
|
|
187
187
|
class AddUniqueOp extends Op {
|
|
188
|
-
/*:: _value: Array<
|
|
189
|
-
constructor(value /*:
|
|
188
|
+
/*:: _value: Array<any>;*/
|
|
189
|
+
constructor(value /*: any | Array<any>*/) {
|
|
190
190
|
super();
|
|
191
191
|
this._value = (0, _unique.default)(Array.isArray(value) ? value : [value]);
|
|
192
192
|
}
|
|
193
|
-
applyTo(value /*:
|
|
193
|
+
applyTo(value /*: any | Array<any>*/) /*: Array<any>*/{
|
|
194
194
|
if (value == null) {
|
|
195
195
|
return this._value || [];
|
|
196
196
|
}
|
|
@@ -227,7 +227,7 @@ class AddUniqueOp extends Op {
|
|
|
227
227
|
}
|
|
228
228
|
throw new Error('Cannot merge AddUnique Op with the previous Op');
|
|
229
229
|
}
|
|
230
|
-
toJSON() /*: { __op: string, objects:
|
|
230
|
+
toJSON() /*: { __op: string, objects: any }*/{
|
|
231
231
|
return {
|
|
232
232
|
__op: 'AddUnique',
|
|
233
233
|
objects: (0, _encode.default)(this._value, false, true)
|
|
@@ -236,12 +236,12 @@ class AddUniqueOp extends Op {
|
|
|
236
236
|
}
|
|
237
237
|
exports.AddUniqueOp = AddUniqueOp;
|
|
238
238
|
class RemoveOp extends Op {
|
|
239
|
-
/*:: _value: Array<
|
|
240
|
-
constructor(value /*:
|
|
239
|
+
/*:: _value: Array<any>;*/
|
|
240
|
+
constructor(value /*: any | Array<any>*/) {
|
|
241
241
|
super();
|
|
242
242
|
this._value = (0, _unique.default)(Array.isArray(value) ? value : [value]);
|
|
243
243
|
}
|
|
244
|
-
applyTo(value /*:
|
|
244
|
+
applyTo(value /*: any | Array<any>*/) /*: Array<any>*/{
|
|
245
245
|
if (value == null) {
|
|
246
246
|
return [];
|
|
247
247
|
}
|
|
@@ -296,7 +296,7 @@ class RemoveOp extends Op {
|
|
|
296
296
|
}
|
|
297
297
|
throw new Error('Cannot merge Remove Op with the previous Op');
|
|
298
298
|
}
|
|
299
|
-
toJSON() /*: { __op: string, objects:
|
|
299
|
+
toJSON() /*: { __op: string, objects: any }*/{
|
|
300
300
|
return {
|
|
301
301
|
__op: 'Remove',
|
|
302
302
|
objects: (0, _encode.default)(this._value, false, true)
|
|
@@ -333,7 +333,7 @@ class RelationOp extends Op {
|
|
|
333
333
|
}
|
|
334
334
|
return obj.id;
|
|
335
335
|
}
|
|
336
|
-
applyTo(value /*:
|
|
336
|
+
applyTo(value /*: any*/, parent /*: ParseObject*/, key /*:: ?: string*/) /*: ?ParseRelation*/{
|
|
337
337
|
if (!value) {
|
|
338
338
|
if (!parent || !key) {
|
|
339
339
|
throw new Error('Cannot apply a RelationOp without either a previous value, or an object and a key');
|
|
@@ -400,7 +400,7 @@ class RelationOp extends Op {
|
|
|
400
400
|
}
|
|
401
401
|
throw new Error('Cannot merge Relation Op with the previous Op');
|
|
402
402
|
}
|
|
403
|
-
toJSON() /*: { __op?: string, objects?:
|
|
403
|
+
toJSON() /*: { __op?: string, objects?: any, ops?: any }*/{
|
|
404
404
|
const idToPointer = id => {
|
|
405
405
|
return {
|
|
406
406
|
__type: 'Pointer',
|
package/lib/node/ParsePolygon.js
CHANGED
|
@@ -75,7 +75,7 @@ class ParsePolygon {
|
|
|
75
75
|
* @param {(Parse.Polygon | object)} other
|
|
76
76
|
* @returns {boolean}
|
|
77
77
|
*/
|
|
78
|
-
equals(other /*:
|
|
78
|
+
equals(other /*: any*/) /*: boolean*/{
|
|
79
79
|
if (!(other instanceof ParsePolygon) || this.coordinates.length !== other.coordinates.length) {
|
|
80
80
|
return false;
|
|
81
81
|
}
|