parse 4.1.0-alpha.1 → 4.1.0-alpha.3

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Parse JavaScript SDK v4.1.0-alpha.1
2
+ * Parse JavaScript SDK v4.1.0-alpha.3
3
3
  *
4
4
  * The source tree of this library can be found at
5
5
  * https://github.com/ParsePlatform/Parse-SDK-JS
@@ -531,7 +531,7 @@ var config /*: Config & { [key: string]: mixed }*/ = {
531
531
  SERVER_AUTH_TOKEN: null,
532
532
  LIVEQUERY_SERVER_URL: null,
533
533
  ENCRYPTED_KEY: null,
534
- VERSION: 'js' + "4.1.0-alpha.1",
534
+ VERSION: 'js' + "4.1.0-alpha.3",
535
535
  APPLICATION_ID: null,
536
536
  JAVASCRIPT_KEY: null,
537
537
  MASTER_KEY: null,
@@ -1853,21 +1853,25 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
1853
1853
  }, {
1854
1854
  key: "subscribe",
1855
1855
  value: function (query /*: Object*/, sessionToken /*: ?string*/) /*: LiveQuerySubscription*/{
1856
- var _this2 = this;
1856
+ var _queryJSON$keys,
1857
+ _queryJSON$watch,
1858
+ _this2 = this;
1857
1859
  if (!query) {
1858
1860
  return;
1859
1861
  }
1860
1862
  var className = query.className;
1861
1863
  var queryJSON = query.toJSON();
1862
1864
  var where = queryJSON.where;
1863
- var fields = (0, _keys.default)(queryJSON) ? (0, _keys.default)(queryJSON).split(',') : undefined;
1865
+ var fields = (_queryJSON$keys = (0, _keys.default)(queryJSON)) === null || _queryJSON$keys === void 0 ? void 0 : _queryJSON$keys.split(',');
1866
+ var watch = (_queryJSON$watch = queryJSON.watch) === null || _queryJSON$watch === void 0 ? void 0 : _queryJSON$watch.split(',');
1864
1867
  var subscribeRequest = {
1865
1868
  op: OP_TYPES.SUBSCRIBE,
1866
1869
  requestId: this.requestId,
1867
1870
  query: {
1868
1871
  className: className,
1869
1872
  where: where,
1870
- fields: fields
1873
+ fields: fields,
1874
+ watch: watch
1871
1875
  }
1872
1876
  };
1873
1877
  if (sessionToken) {
@@ -6880,6 +6884,7 @@ var ParseFile = /*#__PURE__*/function () {
6880
6884
  key: "cancel",
6881
6885
  value: function () {
6882
6886
  if (this._requestTask && typeof this._requestTask.abort === 'function') {
6887
+ this._requestTask._aborted = true;
6883
6888
  this._requestTask.abort();
6884
6889
  }
6885
6890
  this._requestTask = null;
@@ -11633,6 +11638,7 @@ var ParseQuery = /*#__PURE__*/function () {
11633
11638
  (0, _classCallCheck2.default)(this, ParseQuery);
11634
11639
  (0, _defineProperty2.default)(this, "className", void 0);
11635
11640
  (0, _defineProperty2.default)(this, "_where", void 0);
11641
+ (0, _defineProperty2.default)(this, "_watch", void 0);
11636
11642
  (0, _defineProperty2.default)(this, "_include", void 0);
11637
11643
  (0, _defineProperty2.default)(this, "_exclude", void 0);
11638
11644
  (0, _defineProperty2.default)(this, "_select", void 0);
@@ -11668,6 +11674,7 @@ var ParseQuery = /*#__PURE__*/function () {
11668
11674
  throw new TypeError('A ParseQuery must be constructed with a ParseObject or class name.');
11669
11675
  }
11670
11676
  this._where = {};
11677
+ this._watch = [];
11671
11678
  this._include = [];
11672
11679
  this._exclude = [];
11673
11680
  this._count = false;
@@ -11860,6 +11867,9 @@ var ParseQuery = /*#__PURE__*/function () {
11860
11867
  var params /*: QueryJSON*/ = {
11861
11868
  where: this._where
11862
11869
  };
11870
+ if (this._watch.length) {
11871
+ params.watch = this._watch.join(',');
11872
+ }
11863
11873
  if (this._include.length) {
11864
11874
  params.include = this._include.join(',');
11865
11875
  }
@@ -11929,6 +11939,9 @@ var ParseQuery = /*#__PURE__*/function () {
11929
11939
  if (json.where) {
11930
11940
  this._where = json.where;
11931
11941
  }
11942
+ if (json.watch) {
11943
+ this._watch = json.watch.split(',');
11944
+ }
11932
11945
  if (json.include) {
11933
11946
  this._include = json.include.split(',');
11934
11947
  }
@@ -13518,6 +13531,32 @@ var ParseQuery = /*#__PURE__*/function () {
13518
13531
  return this;
13519
13532
  }
13520
13533
 
13534
+ /**
13535
+ * Restricts live query to trigger only for watched fields.
13536
+ *
13537
+ * Requires Parse Server 6.0.0+
13538
+ *
13539
+ * @param {...string|Array<string>} keys The name(s) of the key(s) to watch.
13540
+ * @returns {Parse.Query} Returns the query, so you can chain this call.
13541
+ */
13542
+ }, {
13543
+ key: "watch",
13544
+ value: function () /*: ParseQuery*/{
13545
+ var _this14 = this;
13546
+ for (var _len8 = arguments.length, keys = new Array(_len8), _key12 = 0; _key12 < _len8; _key12++) {
13547
+ keys[_key12] = arguments[_key12];
13548
+ }
13549
+ (0, _forEach.default)(keys).call(keys, function (key) {
13550
+ if ((0, _isArray.default)(key)) {
13551
+ var _context22;
13552
+ _this14._watch = (0, _concat.default)(_context22 = _this14._watch).call(_context22, key);
13553
+ } else {
13554
+ _this14._watch.push(key);
13555
+ }
13556
+ });
13557
+ return this;
13558
+ }
13559
+
13521
13560
  /**
13522
13561
  * Changes the read preference that the backend will use when performing the query to the database.
13523
13562
  *
@@ -13547,30 +13586,30 @@ var ParseQuery = /*#__PURE__*/function () {
13547
13586
  value: function () {
13548
13587
  var _subscribe = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(sessionToken /*:: ?: string*/) {
13549
13588
  var currentUser, liveQueryClient, subscription;
13550
- return _regenerator.default.wrap(function (_context22) {
13551
- while (1) switch (_context22.prev = _context22.next) {
13589
+ return _regenerator.default.wrap(function (_context23) {
13590
+ while (1) switch (_context23.prev = _context23.next) {
13552
13591
  case 0:
13553
- _context22.next = 2;
13592
+ _context23.next = 2;
13554
13593
  return _CoreManager.default.getUserController().currentUserAsync();
13555
13594
  case 2:
13556
- currentUser = _context22.sent;
13595
+ currentUser = _context23.sent;
13557
13596
  if (!sessionToken) {
13558
13597
  sessionToken = currentUser ? currentUser.getSessionToken() : undefined;
13559
13598
  }
13560
- _context22.next = 6;
13599
+ _context23.next = 6;
13561
13600
  return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
13562
13601
  case 6:
13563
- liveQueryClient = _context22.sent;
13602
+ liveQueryClient = _context23.sent;
13564
13603
  if (liveQueryClient.shouldOpen()) {
13565
13604
  liveQueryClient.open();
13566
13605
  }
13567
13606
  subscription = liveQueryClient.subscribe(this, sessionToken);
13568
- return _context22.abrupt("return", subscription.subscribePromise.then(function () {
13607
+ return _context23.abrupt("return", subscription.subscribePromise.then(function () {
13569
13608
  return subscription;
13570
13609
  }));
13571
13610
  case 10:
13572
13611
  case "end":
13573
- return _context22.stop();
13612
+ return _context23.stop();
13574
13613
  }
13575
13614
  }, _callee7, this);
13576
13615
  }));
@@ -13652,7 +13691,7 @@ var ParseQuery = /*#__PURE__*/function () {
13652
13691
  }, {
13653
13692
  key: "cancel",
13654
13693
  value: function () /*: ParseQuery*/{
13655
- var _this14 = this;
13694
+ var _this15 = this;
13656
13695
  if (this._xhrRequest.task && typeof this._xhrRequest.task.abort === 'function') {
13657
13696
  this._xhrRequest.task._aborted = true;
13658
13697
  this._xhrRequest.task.abort();
@@ -13661,16 +13700,16 @@ var ParseQuery = /*#__PURE__*/function () {
13661
13700
  return this;
13662
13701
  }
13663
13702
  return this._xhrRequest.onchange = function () {
13664
- return _this14.cancel();
13703
+ return _this15.cancel();
13665
13704
  };
13666
13705
  }
13667
13706
  }, {
13668
13707
  key: "_setRequestTask",
13669
13708
  value: function (options) {
13670
- var _this15 = this;
13709
+ var _this16 = this;
13671
13710
  options.requestTask = function (task) {
13672
- _this15._xhrRequest.task = task;
13673
- _this15._xhrRequest.onchange();
13711
+ _this16._xhrRequest.task = task;
13712
+ _this16._xhrRequest.onchange();
13674
13713
  };
13675
13714
  }
13676
13715
  }], [{
@@ -13682,8 +13721,8 @@ var ParseQuery = /*#__PURE__*/function () {
13682
13721
  }, {
13683
13722
  key: "or",
13684
13723
  value: function () /*: ParseQuery*/{
13685
- for (var _len8 = arguments.length, queries = new Array(_len8), _key12 = 0; _key12 < _len8; _key12++) {
13686
- queries[_key12] = arguments[_key12];
13724
+ for (var _len9 = arguments.length, queries = new Array(_len9), _key13 = 0; _key13 < _len9; _key13++) {
13725
+ queries[_key13] = arguments[_key13];
13687
13726
  }
13688
13727
  var className = _getClassNameFromQueries(queries);
13689
13728
  var query = new ParseQuery(className);
@@ -13706,8 +13745,8 @@ var ParseQuery = /*#__PURE__*/function () {
13706
13745
  }, {
13707
13746
  key: "and",
13708
13747
  value: function () /*: ParseQuery*/{
13709
- for (var _len9 = arguments.length, queries = new Array(_len9), _key13 = 0; _key13 < _len9; _key13++) {
13710
- queries[_key13] = arguments[_key13];
13748
+ for (var _len10 = arguments.length, queries = new Array(_len10), _key14 = 0; _key14 < _len10; _key14++) {
13749
+ queries[_key14] = arguments[_key14];
13711
13750
  }
13712
13751
  var className = _getClassNameFromQueries(queries);
13713
13752
  var query = new ParseQuery(className);
@@ -13730,8 +13769,8 @@ var ParseQuery = /*#__PURE__*/function () {
13730
13769
  }, {
13731
13770
  key: "nor",
13732
13771
  value: function () /*: ParseQuery*/{
13733
- for (var _len10 = arguments.length, queries = new Array(_len10), _key14 = 0; _key14 < _len10; _key14++) {
13734
- queries[_key14] = arguments[_key14];
13772
+ for (var _len11 = arguments.length, queries = new Array(_len11), _key15 = 0; _key15 < _len11; _key15++) {
13773
+ queries[_key15] = arguments[_key15];
13735
13774
  }
13736
13775
  var className = _getClassNameFromQueries(queries);
13737
13776
  var query = new ParseQuery(className);