parse 4.1.0-alpha.2 → 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.
package/dist/parse.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Parse JavaScript SDK v4.1.0-alpha.2
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.2",
534
+ VERSION: 'js' + "4.1.0-alpha.3",
535
535
  APPLICATION_ID: null,
536
536
  JAVASCRIPT_KEY: null,
537
537
  MASTER_KEY: null,
@@ -1888,21 +1888,25 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
1888
1888
  }, {
1889
1889
  key: "subscribe",
1890
1890
  value: function (query /*: Object*/, sessionToken /*: ?string*/) /*: LiveQuerySubscription*/{
1891
- var _this2 = this;
1891
+ var _queryJSON$keys,
1892
+ _queryJSON$watch,
1893
+ _this2 = this;
1892
1894
  if (!query) {
1893
1895
  return;
1894
1896
  }
1895
1897
  var className = query.className;
1896
1898
  var queryJSON = query.toJSON();
1897
1899
  var where = queryJSON.where;
1898
- var fields = (0, _keys.default)(queryJSON) ? (0, _keys.default)(queryJSON).split(',') : undefined;
1900
+ var fields = (_queryJSON$keys = (0, _keys.default)(queryJSON)) === null || _queryJSON$keys === void 0 ? void 0 : _queryJSON$keys.split(',');
1901
+ var watch = (_queryJSON$watch = queryJSON.watch) === null || _queryJSON$watch === void 0 ? void 0 : _queryJSON$watch.split(',');
1899
1902
  var subscribeRequest = {
1900
1903
  op: OP_TYPES.SUBSCRIBE,
1901
1904
  requestId: this.requestId,
1902
1905
  query: {
1903
1906
  className: className,
1904
1907
  where: where,
1905
- fields: fields
1908
+ fields: fields,
1909
+ watch: watch
1906
1910
  }
1907
1911
  };
1908
1912
  if (sessionToken) {
@@ -11676,6 +11680,7 @@ var ParseQuery = /*#__PURE__*/function () {
11676
11680
  (0, _classCallCheck2.default)(this, ParseQuery);
11677
11681
  (0, _defineProperty2.default)(this, "className", void 0);
11678
11682
  (0, _defineProperty2.default)(this, "_where", void 0);
11683
+ (0, _defineProperty2.default)(this, "_watch", void 0);
11679
11684
  (0, _defineProperty2.default)(this, "_include", void 0);
11680
11685
  (0, _defineProperty2.default)(this, "_exclude", void 0);
11681
11686
  (0, _defineProperty2.default)(this, "_select", void 0);
@@ -11711,6 +11716,7 @@ var ParseQuery = /*#__PURE__*/function () {
11711
11716
  throw new TypeError('A ParseQuery must be constructed with a ParseObject or class name.');
11712
11717
  }
11713
11718
  this._where = {};
11719
+ this._watch = [];
11714
11720
  this._include = [];
11715
11721
  this._exclude = [];
11716
11722
  this._count = false;
@@ -11903,6 +11909,9 @@ var ParseQuery = /*#__PURE__*/function () {
11903
11909
  var params /*: QueryJSON*/ = {
11904
11910
  where: this._where
11905
11911
  };
11912
+ if (this._watch.length) {
11913
+ params.watch = this._watch.join(',');
11914
+ }
11906
11915
  if (this._include.length) {
11907
11916
  params.include = this._include.join(',');
11908
11917
  }
@@ -11972,6 +11981,9 @@ var ParseQuery = /*#__PURE__*/function () {
11972
11981
  if (json.where) {
11973
11982
  this._where = json.where;
11974
11983
  }
11984
+ if (json.watch) {
11985
+ this._watch = json.watch.split(',');
11986
+ }
11975
11987
  if (json.include) {
11976
11988
  this._include = json.include.split(',');
11977
11989
  }
@@ -13561,6 +13573,32 @@ var ParseQuery = /*#__PURE__*/function () {
13561
13573
  return this;
13562
13574
  }
13563
13575
 
13576
+ /**
13577
+ * Restricts live query to trigger only for watched fields.
13578
+ *
13579
+ * Requires Parse Server 6.0.0+
13580
+ *
13581
+ * @param {...string|Array<string>} keys The name(s) of the key(s) to watch.
13582
+ * @returns {Parse.Query} Returns the query, so you can chain this call.
13583
+ */
13584
+ }, {
13585
+ key: "watch",
13586
+ value: function () /*: ParseQuery*/{
13587
+ var _this14 = this;
13588
+ for (var _len8 = arguments.length, keys = new Array(_len8), _key12 = 0; _key12 < _len8; _key12++) {
13589
+ keys[_key12] = arguments[_key12];
13590
+ }
13591
+ (0, _forEach.default)(keys).call(keys, function (key) {
13592
+ if ((0, _isArray.default)(key)) {
13593
+ var _context22;
13594
+ _this14._watch = (0, _concat.default)(_context22 = _this14._watch).call(_context22, key);
13595
+ } else {
13596
+ _this14._watch.push(key);
13597
+ }
13598
+ });
13599
+ return this;
13600
+ }
13601
+
13564
13602
  /**
13565
13603
  * Changes the read preference that the backend will use when performing the query to the database.
13566
13604
  *
@@ -13590,30 +13628,30 @@ var ParseQuery = /*#__PURE__*/function () {
13590
13628
  value: function () {
13591
13629
  var _subscribe = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(sessionToken /*:: ?: string*/) {
13592
13630
  var currentUser, liveQueryClient, subscription;
13593
- return _regenerator.default.wrap(function (_context22) {
13594
- while (1) switch (_context22.prev = _context22.next) {
13631
+ return _regenerator.default.wrap(function (_context23) {
13632
+ while (1) switch (_context23.prev = _context23.next) {
13595
13633
  case 0:
13596
- _context22.next = 2;
13634
+ _context23.next = 2;
13597
13635
  return _CoreManager.default.getUserController().currentUserAsync();
13598
13636
  case 2:
13599
- currentUser = _context22.sent;
13637
+ currentUser = _context23.sent;
13600
13638
  if (!sessionToken) {
13601
13639
  sessionToken = currentUser ? currentUser.getSessionToken() : undefined;
13602
13640
  }
13603
- _context22.next = 6;
13641
+ _context23.next = 6;
13604
13642
  return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
13605
13643
  case 6:
13606
- liveQueryClient = _context22.sent;
13644
+ liveQueryClient = _context23.sent;
13607
13645
  if (liveQueryClient.shouldOpen()) {
13608
13646
  liveQueryClient.open();
13609
13647
  }
13610
13648
  subscription = liveQueryClient.subscribe(this, sessionToken);
13611
- return _context22.abrupt("return", subscription.subscribePromise.then(function () {
13649
+ return _context23.abrupt("return", subscription.subscribePromise.then(function () {
13612
13650
  return subscription;
13613
13651
  }));
13614
13652
  case 10:
13615
13653
  case "end":
13616
- return _context22.stop();
13654
+ return _context23.stop();
13617
13655
  }
13618
13656
  }, _callee7, this);
13619
13657
  }));
@@ -13695,7 +13733,7 @@ var ParseQuery = /*#__PURE__*/function () {
13695
13733
  }, {
13696
13734
  key: "cancel",
13697
13735
  value: function () /*: ParseQuery*/{
13698
- var _this14 = this;
13736
+ var _this15 = this;
13699
13737
  if (this._xhrRequest.task && typeof this._xhrRequest.task.abort === 'function') {
13700
13738
  this._xhrRequest.task._aborted = true;
13701
13739
  this._xhrRequest.task.abort();
@@ -13704,16 +13742,16 @@ var ParseQuery = /*#__PURE__*/function () {
13704
13742
  return this;
13705
13743
  }
13706
13744
  return this._xhrRequest.onchange = function () {
13707
- return _this14.cancel();
13745
+ return _this15.cancel();
13708
13746
  };
13709
13747
  }
13710
13748
  }, {
13711
13749
  key: "_setRequestTask",
13712
13750
  value: function (options) {
13713
- var _this15 = this;
13751
+ var _this16 = this;
13714
13752
  options.requestTask = function (task) {
13715
- _this15._xhrRequest.task = task;
13716
- _this15._xhrRequest.onchange();
13753
+ _this16._xhrRequest.task = task;
13754
+ _this16._xhrRequest.onchange();
13717
13755
  };
13718
13756
  }
13719
13757
  }], [{
@@ -13725,8 +13763,8 @@ var ParseQuery = /*#__PURE__*/function () {
13725
13763
  }, {
13726
13764
  key: "or",
13727
13765
  value: function () /*: ParseQuery*/{
13728
- for (var _len8 = arguments.length, queries = new Array(_len8), _key12 = 0; _key12 < _len8; _key12++) {
13729
- queries[_key12] = arguments[_key12];
13766
+ for (var _len9 = arguments.length, queries = new Array(_len9), _key13 = 0; _key13 < _len9; _key13++) {
13767
+ queries[_key13] = arguments[_key13];
13730
13768
  }
13731
13769
  var className = _getClassNameFromQueries(queries);
13732
13770
  var query = new ParseQuery(className);
@@ -13749,8 +13787,8 @@ var ParseQuery = /*#__PURE__*/function () {
13749
13787
  }, {
13750
13788
  key: "and",
13751
13789
  value: function () /*: ParseQuery*/{
13752
- for (var _len9 = arguments.length, queries = new Array(_len9), _key13 = 0; _key13 < _len9; _key13++) {
13753
- queries[_key13] = arguments[_key13];
13790
+ for (var _len10 = arguments.length, queries = new Array(_len10), _key14 = 0; _key14 < _len10; _key14++) {
13791
+ queries[_key14] = arguments[_key14];
13754
13792
  }
13755
13793
  var className = _getClassNameFromQueries(queries);
13756
13794
  var query = new ParseQuery(className);
@@ -13773,8 +13811,8 @@ var ParseQuery = /*#__PURE__*/function () {
13773
13811
  }, {
13774
13812
  key: "nor",
13775
13813
  value: function () /*: ParseQuery*/{
13776
- for (var _len10 = arguments.length, queries = new Array(_len10), _key14 = 0; _key14 < _len10; _key14++) {
13777
- queries[_key14] = arguments[_key14];
13814
+ for (var _len11 = arguments.length, queries = new Array(_len11), _key15 = 0; _key15 < _len11; _key15++) {
13815
+ queries[_key15] = arguments[_key15];
13778
13816
  }
13779
13817
  var className = _getClassNameFromQueries(queries);
13780
13818
  var query = new ParseQuery(className);