parse 5.1.1-alpha.1 → 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 +1411 -1216
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +1414 -1219
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/Cloud.js +7 -11
- package/lib/browser/CoreManager.js +1 -1
- 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 +14 -0
- package/lib/browser/ParseObject.js +15 -13
- 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/node/Cloud.js +7 -11
- package/lib/node/CoreManager.js +1 -1
- 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 +14 -0
- package/lib/node/ParseObject.js +15 -13
- 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/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/ParseObject.js +4 -3
- 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/weapp/Cloud.js +7 -11
- package/lib/weapp/CoreManager.js +1 -1
- 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 +14 -0
- package/lib/weapp/ParseObject.js +15 -13
- 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/package.json +5 -6
|
@@ -11,6 +11,7 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
11
11
|
value: true
|
|
12
12
|
});
|
|
13
13
|
exports.default = void 0;
|
|
14
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator"));
|
|
14
15
|
var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
|
|
15
16
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/map"));
|
|
16
17
|
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
@@ -20,6 +21,7 @@ var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-st
|
|
|
20
21
|
var _values = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/values"));
|
|
21
22
|
var _setTimeout2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set-timeout"));
|
|
22
23
|
var _bind = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/bind"));
|
|
24
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
|
|
23
25
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
24
26
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
25
27
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
@@ -80,10 +82,10 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
|
80
82
|
};
|
|
81
83
|
}
|
|
82
84
|
function _unsupportedIterableToArray(o, minLen) {
|
|
83
|
-
var
|
|
85
|
+
var _context9;
|
|
84
86
|
if (!o) return;
|
|
85
87
|
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
86
|
-
var n = _sliceInstanceProperty(
|
|
88
|
+
var n = _sliceInstanceProperty(_context9 = Object.prototype.toString.call(o)).call(_context9, 8, -1);
|
|
87
89
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
88
90
|
if (n === "Map" || n === "Set") return _Array$from(o);
|
|
89
91
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
@@ -222,6 +224,10 @@ var LiveQueryClient = /*#__PURE__*/function () {
|
|
|
222
224
|
(0, _defineProperty2.default)(this, "subscriptions", void 0);
|
|
223
225
|
(0, _defineProperty2.default)(this, "socket", void 0);
|
|
224
226
|
(0, _defineProperty2.default)(this, "state", void 0);
|
|
227
|
+
(0, _defineProperty2.default)(this, "reconnectHandle", void 0);
|
|
228
|
+
(0, _defineProperty2.default)(this, "emitter", void 0);
|
|
229
|
+
(0, _defineProperty2.default)(this, "on", void 0);
|
|
230
|
+
(0, _defineProperty2.default)(this, "emit", void 0);
|
|
225
231
|
if (!serverURL || (0, _indexOf.default)(serverURL).call(serverURL, 'ws') !== 0) {
|
|
226
232
|
throw new Error('You need to set a proper Parse LiveQuery server url before using LiveQueryClient');
|
|
227
233
|
}
|
|
@@ -271,13 +277,13 @@ var LiveQueryClient = /*#__PURE__*/function () {
|
|
|
271
277
|
* <a href="https://github.com/parse-community/parse-server/wiki/Parse-LiveQuery-Protocol-Specification">here</a> for more details. The subscription you get is the same subscription you get
|
|
272
278
|
* from our Standard API.
|
|
273
279
|
*
|
|
274
|
-
* @param {
|
|
280
|
+
* @param {ParseQuery} query - the ParseQuery you want to subscribe to
|
|
275
281
|
* @param {string} sessionToken (optional)
|
|
276
282
|
* @returns {LiveQuerySubscription | undefined}
|
|
277
283
|
*/
|
|
278
284
|
}, {
|
|
279
285
|
key: "subscribe",
|
|
280
|
-
value: function (query /*:
|
|
286
|
+
value: function (query /*: ParseQuery*/, sessionToken /*:: ?: string*/) /*: LiveQuerySubscription | undefined*/{
|
|
281
287
|
var _queryJSON$keys,
|
|
282
288
|
_queryJSON$watch,
|
|
283
289
|
_this2 = this;
|
|
@@ -297,7 +303,8 @@ var LiveQueryClient = /*#__PURE__*/function () {
|
|
|
297
303
|
where: where,
|
|
298
304
|
keys: keys,
|
|
299
305
|
watch: watch
|
|
300
|
-
}
|
|
306
|
+
},
|
|
307
|
+
sessionToken: undefined
|
|
301
308
|
};
|
|
302
309
|
if (sessionToken) {
|
|
303
310
|
subscribeRequest.sessionToken = sessionToken;
|
|
@@ -321,22 +328,39 @@ var LiveQueryClient = /*#__PURE__*/function () {
|
|
|
321
328
|
*/
|
|
322
329
|
}, {
|
|
323
330
|
key: "unsubscribe",
|
|
324
|
-
value: function (
|
|
325
|
-
var
|
|
326
|
-
|
|
327
|
-
|
|
331
|
+
value: function () {
|
|
332
|
+
var _unsubscribe = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(subscription /*: LiveQuerySubscription*/) {
|
|
333
|
+
var _this3 = this;
|
|
334
|
+
var unsubscribeRequest;
|
|
335
|
+
return _regenerator.default.wrap(function (_context2) {
|
|
336
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
337
|
+
case 0:
|
|
338
|
+
if (subscription) {
|
|
339
|
+
_context2.next = 2;
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
return _context2.abrupt("return");
|
|
343
|
+
case 2:
|
|
344
|
+
unsubscribeRequest = {
|
|
345
|
+
op: OP_TYPES.UNSUBSCRIBE,
|
|
346
|
+
requestId: subscription.id
|
|
347
|
+
};
|
|
348
|
+
return _context2.abrupt("return", this.connectPromise.then(function () {
|
|
349
|
+
return _this3.socket.send((0, _stringify.default)(unsubscribeRequest));
|
|
350
|
+
}).then(function () {
|
|
351
|
+
return subscription.unsubscribePromise;
|
|
352
|
+
}));
|
|
353
|
+
case 4:
|
|
354
|
+
case "end":
|
|
355
|
+
return _context2.stop();
|
|
356
|
+
}
|
|
357
|
+
}, _callee, this);
|
|
358
|
+
}));
|
|
359
|
+
function unsubscribe() {
|
|
360
|
+
return _unsubscribe.apply(this, arguments);
|
|
328
361
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
requestId: subscription.id
|
|
332
|
-
};
|
|
333
|
-
return this.connectPromise.then(function () {
|
|
334
|
-
return _this3.socket.send((0, _stringify.default)(unsubscribeRequest));
|
|
335
|
-
}).then(function () {
|
|
336
|
-
return subscription.unsubscribePromise;
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
|
|
362
|
+
return unsubscribe;
|
|
363
|
+
}()
|
|
340
364
|
/**
|
|
341
365
|
* After open is called, the LiveQueryClient will try to send a connect request
|
|
342
366
|
* to the LiveQuery server.
|
|
@@ -365,7 +389,8 @@ var LiveQueryClient = /*#__PURE__*/function () {
|
|
|
365
389
|
_this4._handleWebSocketMessage(event);
|
|
366
390
|
};
|
|
367
391
|
this.socket.onclose = function (event) {
|
|
368
|
-
_this4
|
|
392
|
+
var _this4$socket$closing;
|
|
393
|
+
(_this4$socket$closing = _this4.socket.closingPromise) === null || _this4$socket$closing === void 0 ? void 0 : _this4$socket$closing.resolve(event);
|
|
369
394
|
_this4._handleWebSocketClose();
|
|
370
395
|
};
|
|
371
396
|
this.socket.onerror = function (error) {
|
|
@@ -375,9 +400,9 @@ var LiveQueryClient = /*#__PURE__*/function () {
|
|
|
375
400
|
}, {
|
|
376
401
|
key: "resubscribe",
|
|
377
402
|
value: function () {
|
|
378
|
-
var
|
|
403
|
+
var _context3,
|
|
379
404
|
_this5 = this;
|
|
380
|
-
(0, _forEach.default)(
|
|
405
|
+
(0, _forEach.default)(_context3 = this.subscriptions).call(_context3, function (subscription, requestId) {
|
|
381
406
|
var query = subscription.query;
|
|
382
407
|
var queryJSON = query.toJSON();
|
|
383
408
|
var where = queryJSON.where;
|
|
@@ -391,7 +416,8 @@ var LiveQueryClient = /*#__PURE__*/function () {
|
|
|
391
416
|
className: className,
|
|
392
417
|
where: where,
|
|
393
418
|
fields: fields
|
|
394
|
-
}
|
|
419
|
+
},
|
|
420
|
+
sessionToken: undefined
|
|
395
421
|
};
|
|
396
422
|
if (sessionToken) {
|
|
397
423
|
subscribeRequest.sessionToken = sessionToken;
|
|
@@ -410,33 +436,48 @@ var LiveQueryClient = /*#__PURE__*/function () {
|
|
|
410
436
|
*/
|
|
411
437
|
}, {
|
|
412
438
|
key: "close",
|
|
413
|
-
value: function ()
|
|
414
|
-
var
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
439
|
+
value: function () {
|
|
440
|
+
var _close = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
441
|
+
var _this$socket, _this$socket2, _context4;
|
|
442
|
+
var _iterator, _step, subscription;
|
|
443
|
+
return _regenerator.default.wrap(function (_context5) {
|
|
444
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
445
|
+
case 0:
|
|
446
|
+
if (!(this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED)) {
|
|
447
|
+
_context5.next = 2;
|
|
448
|
+
break;
|
|
449
|
+
}
|
|
450
|
+
return _context5.abrupt("return");
|
|
451
|
+
case 2:
|
|
452
|
+
this.state = CLIENT_STATE.DISCONNECTED;
|
|
453
|
+
(_this$socket = this.socket) === null || _this$socket === void 0 ? void 0 : _this$socket.close();
|
|
454
|
+
// Notify each subscription about the close
|
|
455
|
+
_iterator = _createForOfIteratorHelper((0, _values.default)(_context4 = this.subscriptions).call(_context4));
|
|
456
|
+
try {
|
|
457
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
458
|
+
subscription = _step.value;
|
|
459
|
+
subscription.subscribed = false;
|
|
460
|
+
subscription.emit(SUBSCRIPTION_EMMITER_TYPES.CLOSE);
|
|
461
|
+
}
|
|
462
|
+
} catch (err) {
|
|
463
|
+
_iterator.e(err);
|
|
464
|
+
} finally {
|
|
465
|
+
_iterator.f();
|
|
466
|
+
}
|
|
467
|
+
this._handleReset();
|
|
468
|
+
this.emit(CLIENT_EMMITER_TYPES.CLOSE);
|
|
469
|
+
return _context5.abrupt("return", (_this$socket2 = this.socket) === null || _this$socket2 === void 0 ? void 0 : _this$socket2.closingPromise);
|
|
470
|
+
case 9:
|
|
471
|
+
case "end":
|
|
472
|
+
return _context5.stop();
|
|
473
|
+
}
|
|
474
|
+
}, _callee2, this);
|
|
475
|
+
}));
|
|
476
|
+
function close() {
|
|
477
|
+
return _close.apply(this, arguments);
|
|
433
478
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
return (_this$socket2 = this.socket) === null || _this$socket2 === void 0 ? void 0 : _this$socket2.closingPromise;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
// ensure we start with valid state if connect is called again after close
|
|
479
|
+
return close;
|
|
480
|
+
}() // ensure we start with valid state if connect is called again after close
|
|
440
481
|
}, {
|
|
441
482
|
key: "_handleReset",
|
|
442
483
|
value: function () {
|
|
@@ -455,7 +496,8 @@ var LiveQueryClient = /*#__PURE__*/function () {
|
|
|
455
496
|
applicationId: this.applicationId,
|
|
456
497
|
javascriptKey: this.javascriptKey,
|
|
457
498
|
masterKey: this.masterKey,
|
|
458
|
-
sessionToken: this.sessionToken
|
|
499
|
+
sessionToken: this.sessionToken,
|
|
500
|
+
installationId: undefined
|
|
459
501
|
};
|
|
460
502
|
if (this.additionalProperties) {
|
|
461
503
|
connectRequest.installationId = this.installationId;
|
|
@@ -469,9 +511,9 @@ var LiveQueryClient = /*#__PURE__*/function () {
|
|
|
469
511
|
if (typeof data === 'string') {
|
|
470
512
|
data = JSON.parse(data);
|
|
471
513
|
}
|
|
472
|
-
var subscription = null;
|
|
514
|
+
var subscription /*: null | LiveQuerySubscription*/ = null;
|
|
473
515
|
if (data.requestId) {
|
|
474
|
-
subscription = this.subscriptions.get(data.requestId);
|
|
516
|
+
subscription = this.subscriptions.get(data.requestId) || null;
|
|
475
517
|
}
|
|
476
518
|
var response = {
|
|
477
519
|
clientId: data.clientId,
|
|
@@ -565,14 +607,14 @@ var LiveQueryClient = /*#__PURE__*/function () {
|
|
|
565
607
|
}, {
|
|
566
608
|
key: "_handleWebSocketClose",
|
|
567
609
|
value: function () {
|
|
568
|
-
var
|
|
610
|
+
var _context6;
|
|
569
611
|
if (this.state === CLIENT_STATE.DISCONNECTED) {
|
|
570
612
|
return;
|
|
571
613
|
}
|
|
572
614
|
this.state = CLIENT_STATE.CLOSED;
|
|
573
615
|
this.emit(CLIENT_EMMITER_TYPES.CLOSE);
|
|
574
616
|
// Notify each subscription about the close
|
|
575
|
-
var _iterator2 = _createForOfIteratorHelper((0, _values.default)(
|
|
617
|
+
var _iterator2 = _createForOfIteratorHelper((0, _values.default)(_context6 = this.subscriptions).call(_context6)),
|
|
576
618
|
_step2;
|
|
577
619
|
try {
|
|
578
620
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
@@ -589,9 +631,9 @@ var LiveQueryClient = /*#__PURE__*/function () {
|
|
|
589
631
|
}, {
|
|
590
632
|
key: "_handleWebSocketError",
|
|
591
633
|
value: function (error /*: any*/) {
|
|
592
|
-
var
|
|
634
|
+
var _context7;
|
|
593
635
|
this.emit(CLIENT_EMMITER_TYPES.ERROR, error);
|
|
594
|
-
var _iterator3 = _createForOfIteratorHelper((0, _values.default)(
|
|
636
|
+
var _iterator3 = _createForOfIteratorHelper((0, _values.default)(_context7 = this.subscriptions).call(_context7)),
|
|
595
637
|
_step3;
|
|
596
638
|
try {
|
|
597
639
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
@@ -608,7 +650,7 @@ var LiveQueryClient = /*#__PURE__*/function () {
|
|
|
608
650
|
}, {
|
|
609
651
|
key: "_handleReconnect",
|
|
610
652
|
value: function () {
|
|
611
|
-
var
|
|
653
|
+
var _context8,
|
|
612
654
|
_this6 = this;
|
|
613
655
|
// if closed or currently reconnecting we stop attempting to reconnect
|
|
614
656
|
if (this.state === CLIENT_STATE.DISCONNECTED) {
|
|
@@ -625,11 +667,11 @@ var LiveQueryClient = /*#__PURE__*/function () {
|
|
|
625
667
|
if (this.reconnectHandle) {
|
|
626
668
|
clearTimeout(this.reconnectHandle);
|
|
627
669
|
}
|
|
628
|
-
this.reconnectHandle = (0, _setTimeout2.default)((0, _bind.default)(
|
|
670
|
+
this.reconnectHandle = (0, _setTimeout2.default)((0, _bind.default)(_context8 = function () {
|
|
629
671
|
_this6.attempts++;
|
|
630
672
|
_this6.connectPromise = (0, _promiseUtils.resolvingPromise)();
|
|
631
673
|
_this6.open();
|
|
632
|
-
}).call(
|
|
674
|
+
}).call(_context8, this), time);
|
|
633
675
|
}
|
|
634
676
|
}]);
|
|
635
677
|
return LiveQueryClient;
|