parse 4.1.0-alpha.2 → 4.1.0-alpha.4

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.
Files changed (86) hide show
  1. package/dist/parse.js +252 -58
  2. package/dist/parse.min.js +2 -2
  3. package/dist/parse.weapp.js +252 -58
  4. package/dist/parse.weapp.min.js +2 -2
  5. package/lib/browser/AnonymousUtils.js +1 -1
  6. package/lib/browser/Cloud.js +1 -2
  7. package/lib/browser/CoreManager.js +1 -1
  8. package/lib/browser/EventuallyQueue.js +13 -1
  9. package/lib/browser/LiveQueryClient.js +8 -4
  10. package/lib/browser/LocalDatastore.js +3 -1
  11. package/lib/browser/LocalDatastoreController.js +3 -1
  12. package/lib/browser/ObjectStateMutations.js +14 -1
  13. package/lib/browser/ParseACL.js +2 -1
  14. package/lib/browser/ParseCLP.js +6 -1
  15. package/lib/browser/ParseConfig.js +1 -0
  16. package/lib/browser/ParseFile.js +4 -1
  17. package/lib/browser/ParseInstallation.js +4 -1
  18. package/lib/browser/ParseObject.js +10 -7
  19. package/lib/browser/ParseOp.js +3 -1
  20. package/lib/browser/ParseQuery.js +79 -24
  21. package/lib/browser/ParseRole.js +5 -1
  22. package/lib/browser/ParseSchema.js +1 -1
  23. package/lib/browser/ParseSession.js +5 -1
  24. package/lib/browser/ParseUser.js +42 -1
  25. package/lib/browser/Push.js +8 -2
  26. package/lib/browser/RESTController.js +20 -0
  27. package/lib/browser/SingleInstanceStateController.js +6 -1
  28. package/lib/browser/TaskQueue.js +4 -0
  29. package/lib/browser/UniqueInstanceStateController.js +3 -1
  30. package/lib/browser/unsavedChildren.js +4 -1
  31. package/lib/node/AnonymousUtils.js +1 -1
  32. package/lib/node/Cloud.js +1 -2
  33. package/lib/node/CoreManager.js +1 -1
  34. package/lib/node/EventuallyQueue.js +13 -1
  35. package/lib/node/LiveQueryClient.js +5 -2
  36. package/lib/node/LocalDatastore.js +1 -1
  37. package/lib/node/ObjectStateMutations.js +11 -1
  38. package/lib/node/ParseACL.js +2 -1
  39. package/lib/node/ParseCLP.js +3 -1
  40. package/lib/node/ParseConfig.js +1 -2
  41. package/lib/node/ParseFile.js +1 -1
  42. package/lib/node/ParseInstallation.js +1 -1
  43. package/lib/node/ParseObject.js +2 -1
  44. package/lib/node/ParseQuery.js +50 -1
  45. package/lib/node/ParseRole.js +2 -1
  46. package/lib/node/ParseSchema.js +1 -1
  47. package/lib/node/ParseSession.js +2 -1
  48. package/lib/node/ParseUser.js +37 -1
  49. package/lib/node/Push.js +8 -2
  50. package/lib/node/RESTController.js +20 -0
  51. package/lib/node/SingleInstanceStateController.js +6 -1
  52. package/lib/node/TaskQueue.js +4 -1
  53. package/lib/node/UniqueInstanceStateController.js +3 -1
  54. package/lib/node/unsavedChildren.js +4 -1
  55. package/lib/react-native/CoreManager.js +1 -1
  56. package/lib/react-native/LiveQueryClient.js +7 -3
  57. package/lib/react-native/ParseCLP.js +2 -2
  58. package/lib/react-native/ParseQuery.js +34 -11
  59. package/lib/react-native/ParseUser.js +25 -0
  60. package/lib/weapp/AnonymousUtils.js +1 -1
  61. package/lib/weapp/Cloud.js +1 -2
  62. package/lib/weapp/CoreManager.js +1 -1
  63. package/lib/weapp/EventuallyQueue.js +13 -1
  64. package/lib/weapp/LiveQueryClient.js +8 -4
  65. package/lib/weapp/LocalDatastore.js +3 -1
  66. package/lib/weapp/LocalDatastoreController.js +3 -1
  67. package/lib/weapp/ObjectStateMutations.js +14 -1
  68. package/lib/weapp/ParseACL.js +2 -1
  69. package/lib/weapp/ParseCLP.js +6 -1
  70. package/lib/weapp/ParseConfig.js +1 -0
  71. package/lib/weapp/ParseFile.js +4 -1
  72. package/lib/weapp/ParseInstallation.js +4 -1
  73. package/lib/weapp/ParseObject.js +10 -7
  74. package/lib/weapp/ParseOp.js +3 -1
  75. package/lib/weapp/ParseQuery.js +79 -24
  76. package/lib/weapp/ParseRole.js +5 -1
  77. package/lib/weapp/ParseSchema.js +1 -1
  78. package/lib/weapp/ParseSession.js +5 -1
  79. package/lib/weapp/ParseUser.js +42 -1
  80. package/lib/weapp/Push.js +8 -2
  81. package/lib/weapp/RESTController.js +20 -0
  82. package/lib/weapp/SingleInstanceStateController.js +6 -1
  83. package/lib/weapp/TaskQueue.js +4 -0
  84. package/lib/weapp/UniqueInstanceStateController.js +3 -1
  85. package/lib/weapp/unsavedChildren.js +4 -1
  86. package/package.json +18 -18
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.4
3
3
  *
4
4
  * The source tree of this library can be found at
5
5
  * https://github.com/ParsePlatform/Parse-SDK-JS
@@ -94,7 +94,7 @@ var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
94
94
  /**
95
95
  * @flow-weak
96
96
  */
97
-
97
+ /*:: import type { RequestOptions } from './RESTController';*/
98
98
  var uuidv4 = _dereq_('./uuid');
99
99
  var registered = false;
100
100
 
@@ -229,7 +229,7 @@ var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
229
229
  /**
230
230
  * @flow
231
231
  */
232
-
232
+ /*:: import type { RequestOptions } from './RESTController';*/
233
233
  /**
234
234
  * Contains functions for calling and declaring
235
235
  * <a href="/docs/cloud_code_guide#functions">cloud functions</a>.
@@ -241,7 +241,6 @@ var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
241
241
  * @static
242
242
  * @hideconstructor
243
243
  */
244
-
245
244
  /**
246
245
  * Makes a call to a cloud function.
247
246
  *
@@ -531,7 +530,7 @@ var config /*: Config & { [key: string]: mixed }*/ = {
531
530
  SERVER_AUTH_TOKEN: null,
532
531
  LIVEQUERY_SERVER_URL: null,
533
532
  ENCRYPTED_KEY: null,
534
- VERSION: 'js' + "4.1.0-alpha.2",
533
+ VERSION: 'js' + "4.1.0-alpha.4",
535
534
  APPLICATION_ID: null,
536
535
  JAVASCRIPT_KEY: null,
537
536
  MASTER_KEY: null,
@@ -760,7 +759,19 @@ var _Storage = _interopRequireDefault(_dereq_("./Storage"));
760
759
  *
761
760
  * @flow
762
761
  */
763
-
762
+ /*:: import type { SaveOptions } from './ParseObject';*/
763
+ /*:: import type { RequestOptions } from './RESTController';*/
764
+ /*:: type QueueObject = {
765
+ queueId: string,
766
+ action: string,
767
+ object: ParseObject,
768
+ serverOptions: SaveOptions | RequestOptions,
769
+ id: string,
770
+ className: string,
771
+ hash: string,
772
+ createdAt: Date,
773
+ };*/
774
+ /*:: type Queue = Array<QueueObject>;*/
764
775
  var QUEUE_KEY = 'Parse/Eventually/Queue';
765
776
  var queueCache = [];
766
777
  var dirtyCache = true;
@@ -1708,7 +1719,7 @@ function _isNativeReflectConstruct() {
1708
1719
  } catch (e) {
1709
1720
  return false;
1710
1721
  }
1711
- }
1722
+ } /* global WebSocket */
1712
1723
  // The LiveQuery client inner state
1713
1724
  var CLIENT_STATE = {
1714
1725
  INITIALIZED: 'initialized',
@@ -1888,21 +1899,25 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
1888
1899
  }, {
1889
1900
  key: "subscribe",
1890
1901
  value: function (query /*: Object*/, sessionToken /*: ?string*/) /*: LiveQuerySubscription*/{
1891
- var _this2 = this;
1902
+ var _queryJSON$keys,
1903
+ _queryJSON$watch,
1904
+ _this2 = this;
1892
1905
  if (!query) {
1893
1906
  return;
1894
1907
  }
1895
1908
  var className = query.className;
1896
1909
  var queryJSON = query.toJSON();
1897
1910
  var where = queryJSON.where;
1898
- var fields = (0, _keys.default)(queryJSON) ? (0, _keys.default)(queryJSON).split(',') : undefined;
1911
+ var fields = (_queryJSON$keys = (0, _keys.default)(queryJSON)) === null || _queryJSON$keys === void 0 ? void 0 : _queryJSON$keys.split(',');
1912
+ var watch = (_queryJSON$watch = queryJSON.watch) === null || _queryJSON$watch === void 0 ? void 0 : _queryJSON$watch.split(',');
1899
1913
  var subscribeRequest = {
1900
1914
  op: OP_TYPES.SUBSCRIBE,
1901
1915
  requestId: this.requestId,
1902
1916
  query: {
1903
1917
  className: className,
1904
1918
  where: where,
1905
- fields: fields
1919
+ fields: fields,
1920
+ watch: watch
1906
1921
  }
1907
1922
  };
1908
1923
  if (sessionToken) {
@@ -2507,7 +2522,9 @@ function _arrayLikeToArray(arr, len) {
2507
2522
  if (len == null || len > arr.length) len = arr.length;
2508
2523
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
2509
2524
  return arr2;
2510
- }
2525
+ } /**
2526
+ * @flow
2527
+ */ /*:: import type ParseObject from './ParseObject';*/
2511
2528
  /**
2512
2529
  * Provides a local datastore which can be used to store and retrieve <code>Parse.Object</code>. <br />
2513
2530
  * To enable this functionality, call <code>Parse.enableLocalDatastore()</code>.
@@ -3198,7 +3215,9 @@ function _arrayLikeToArray(arr, len) {
3198
3215
  if (len == null || len > arr.length) len = arr.length;
3199
3216
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
3200
3217
  return arr2;
3201
- }
3218
+ } /**
3219
+ * @flow
3220
+ */
3202
3221
  var LocalDatastoreController = {
3203
3222
  fromPinWithName: function (name /*: string*/) /*: Array<Object>*/{
3204
3223
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
@@ -3444,7 +3463,20 @@ function _objectSpread(target) {
3444
3463
  });
3445
3464
  }
3446
3465
  return target;
3447
- }
3466
+ } /**
3467
+ * @flow
3468
+ */
3469
+ /*:: import type { Op } from './ParseOp';*/
3470
+ /*:: export type AttributeMap = { [attr: string]: any };*/
3471
+ /*:: export type OpsMap = { [attr: string]: Op };*/
3472
+ /*:: export type ObjectCache = { [attr: string]: string };*/
3473
+ /*:: export type State = {
3474
+ serverData: AttributeMap,
3475
+ pendingOps: Array<OpsMap>,
3476
+ objectCache: ObjectCache,
3477
+ tasks: TaskQueue,
3478
+ existed: boolean,
3479
+ };*/
3448
3480
  function defaultState() /*: State*/{
3449
3481
  return {
3450
3482
  serverData: {},
@@ -4604,7 +4636,8 @@ var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
4604
4636
  /**
4605
4637
  * @flow
4606
4638
  */
4607
-
4639
+ /*:: type PermissionsMap = { [permission: string]: boolean };*/
4640
+ /*:: type ByIdMap = { [userId: string]: PermissionsMap };*/
4608
4641
  var PUBLIC_KEY = '*';
4609
4642
 
4610
4643
  /**
@@ -5068,7 +5101,12 @@ function _arrayLikeToArray(arr, len) {
5068
5101
  if (len == null || len > arr.length) len = arr.length;
5069
5102
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
5070
5103
  return arr2;
5071
- }
5104
+ } /**
5105
+ * @flow
5106
+ */
5107
+ /*:: type Entity = Entity;*/
5108
+ /*:: type UsersMap = { [userId: string]: boolean | any };*/
5109
+ /*:: export type PermissionsMap = { [permission: string]: UsersMap };*/
5072
5110
  var PUBLIC_KEY = '*';
5073
5111
  var VALID_PERMISSIONS /*: Map<string, UsersMap>*/ = new _map.default(
5074
5112
  /*:: <string, UsersMap>*/
@@ -5750,6 +5788,7 @@ var _Storage = _interopRequireDefault(_dereq_("./Storage"));
5750
5788
  /**
5751
5789
  * @flow
5752
5790
  */
5791
+ /*:: import type { RequestOptions } from './RESTController';*/
5753
5792
  /**
5754
5793
  * Parse.Config is a local representation of configuration data that
5755
5794
  * can be set from the Parse dashboard.
@@ -6601,7 +6640,10 @@ function _objectSpread(target) {
6601
6640
  });
6602
6641
  }
6603
6642
  return target;
6604
- }
6643
+ } /**
6644
+ * @flow
6645
+ */ /* global XMLHttpRequest, Blob */
6646
+ /*:: import type { FullOptions } from './RESTController';*/
6605
6647
  var ParseError = _dereq_('./ParseError').default;
6606
6648
  var XHR = null;
6607
6649
  if (typeof XMLHttpRequest !== 'undefined') {
@@ -7453,7 +7495,10 @@ function _isNativeReflectConstruct() {
7453
7495
  } catch (e) {
7454
7496
  return false;
7455
7497
  }
7456
- }
7498
+ } /**
7499
+ * @flow
7500
+ */
7501
+ /*:: import type { AttributeMap } from './ObjectStateMutations';*/
7457
7502
  var Installation = /*#__PURE__*/function (_ParseObject) {
7458
7503
  (0, _inherits2.default)(Installation, _ParseObject);
7459
7504
  var _super = _createSuper(Installation);
@@ -7835,7 +7880,11 @@ function _objectSpread(target) {
7835
7880
  });
7836
7881
  }
7837
7882
  return target;
7838
- }
7883
+ } /**
7884
+ * @flow
7885
+ */
7886
+ /*:: import type { AttributeMap, OpsMap } from './ObjectStateMutations';*/
7887
+ /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
7839
7888
  var uuidv4 = _dereq_('./uuid');
7840
7889
  /*:: export type Pointer = {
7841
7890
  __type: string,
@@ -7901,6 +7950,11 @@ var ParseObject = /*#__PURE__*/function () {
7901
7950
  */
7902
7951
  function ParseObject(className /*: ?string | { className: string, [attr: string]: mixed }*/, attributes /*:: ?: { [attr: string]: mixed }*/, options /*:: ?: { ignoreValidation: boolean }*/) {
7903
7952
  (0, _classCallCheck2.default)(this, ParseObject);
7953
+ /**
7954
+ * The ID of this object, unique within its class.
7955
+ *
7956
+ * @property {string} id
7957
+ */
7904
7958
  (0, _defineProperty2.default)(this, "id", void 0);
7905
7959
  (0, _defineProperty2.default)(this, "_localId", void 0);
7906
7960
  (0, _defineProperty2.default)(this, "_objCount", void 0);
@@ -7932,12 +7986,6 @@ var ParseObject = /*#__PURE__*/function () {
7932
7986
  throw new Error("Can't create an invalid Parse Object");
7933
7987
  }
7934
7988
  }
7935
-
7936
- /**
7937
- * The ID of this object, unique within its class.
7938
- *
7939
- * @property {string} id
7940
- */
7941
7989
  (0, _createClass2.default)(ParseObject, [{
7942
7990
  key: "attributes",
7943
7991
  get: /* Prototype getters / setters */
@@ -10743,7 +10791,9 @@ function _isNativeReflectConstruct() {
10743
10791
  } catch (e) {
10744
10792
  return false;
10745
10793
  }
10746
- }
10794
+ } /**
10795
+ * @flow
10796
+ */
10747
10797
  function opFromJSON(json /*: { [key: string]: any }*/) /*: ?Op*/{
10748
10798
  if (!json || !json.__op) {
10749
10799
  return null;
@@ -11490,7 +11540,29 @@ var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
11490
11540
  /*
11491
11541
  * @flow
11492
11542
  */
11493
-
11543
+ /*:: import type LiveQuerySubscription from './LiveQuerySubscription';*/
11544
+ /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
11545
+ /*:: type BatchOptions = FullOptions & { batchSize?: number };*/
11546
+ /*:: export type WhereClause = {
11547
+ [attr: string]: mixed,
11548
+ };*/
11549
+ /*:: export type QueryJSON = {
11550
+ where: WhereClause,
11551
+ watch?: string,
11552
+ include?: string,
11553
+ excludeKeys?: string,
11554
+ keys?: string,
11555
+ limit?: number,
11556
+ skip?: number,
11557
+ order?: string,
11558
+ className?: string,
11559
+ count?: number,
11560
+ hint?: mixed,
11561
+ explain?: boolean,
11562
+ readPreference?: string,
11563
+ includeReadPreference?: string,
11564
+ subqueryReadPreference?: string,
11565
+ };*/
11494
11566
  /**
11495
11567
  * Converts a string into a regex that matches it.
11496
11568
  * Surrounding with \Q .. \E does this, we just need to escape any \E's in
@@ -11665,17 +11737,17 @@ function handleOfflineSort(a, b, sorts) {
11665
11737
  * @alias Parse.Query
11666
11738
  */
11667
11739
  var ParseQuery = /*#__PURE__*/function () {
11668
- /**
11669
- * @property {string} className
11670
- */
11671
-
11672
11740
  /**
11673
11741
  * @param {(string | Parse.Object)} objectClass An instance of a subclass of Parse.Object, or a Parse className string.
11674
11742
  */
11675
11743
  function ParseQuery(objectClass /*: string | ParseObject*/) {
11676
11744
  (0, _classCallCheck2.default)(this, ParseQuery);
11745
+ /**
11746
+ * @property {string} className
11747
+ */
11677
11748
  (0, _defineProperty2.default)(this, "className", void 0);
11678
11749
  (0, _defineProperty2.default)(this, "_where", void 0);
11750
+ (0, _defineProperty2.default)(this, "_watch", void 0);
11679
11751
  (0, _defineProperty2.default)(this, "_include", void 0);
11680
11752
  (0, _defineProperty2.default)(this, "_exclude", void 0);
11681
11753
  (0, _defineProperty2.default)(this, "_select", void 0);
@@ -11711,6 +11783,7 @@ var ParseQuery = /*#__PURE__*/function () {
11711
11783
  throw new TypeError('A ParseQuery must be constructed with a ParseObject or class name.');
11712
11784
  }
11713
11785
  this._where = {};
11786
+ this._watch = [];
11714
11787
  this._include = [];
11715
11788
  this._exclude = [];
11716
11789
  this._count = false;
@@ -11903,6 +11976,9 @@ var ParseQuery = /*#__PURE__*/function () {
11903
11976
  var params /*: QueryJSON*/ = {
11904
11977
  where: this._where
11905
11978
  };
11979
+ if (this._watch.length) {
11980
+ params.watch = this._watch.join(',');
11981
+ }
11906
11982
  if (this._include.length) {
11907
11983
  params.include = this._include.join(',');
11908
11984
  }
@@ -11972,6 +12048,9 @@ var ParseQuery = /*#__PURE__*/function () {
11972
12048
  if (json.where) {
11973
12049
  this._where = json.where;
11974
12050
  }
12051
+ if (json.watch) {
12052
+ this._watch = json.watch.split(',');
12053
+ }
11975
12054
  if (json.include) {
11976
12055
  this._include = json.include.split(',');
11977
12056
  }
@@ -13561,6 +13640,32 @@ var ParseQuery = /*#__PURE__*/function () {
13561
13640
  return this;
13562
13641
  }
13563
13642
 
13643
+ /**
13644
+ * Restricts live query to trigger only for watched fields.
13645
+ *
13646
+ * Requires Parse Server 6.0.0+
13647
+ *
13648
+ * @param {...string|Array<string>} keys The name(s) of the key(s) to watch.
13649
+ * @returns {Parse.Query} Returns the query, so you can chain this call.
13650
+ */
13651
+ }, {
13652
+ key: "watch",
13653
+ value: function () /*: ParseQuery*/{
13654
+ var _this14 = this;
13655
+ for (var _len8 = arguments.length, keys = new Array(_len8), _key12 = 0; _key12 < _len8; _key12++) {
13656
+ keys[_key12] = arguments[_key12];
13657
+ }
13658
+ (0, _forEach.default)(keys).call(keys, function (key) {
13659
+ if ((0, _isArray.default)(key)) {
13660
+ var _context22;
13661
+ _this14._watch = (0, _concat.default)(_context22 = _this14._watch).call(_context22, key);
13662
+ } else {
13663
+ _this14._watch.push(key);
13664
+ }
13665
+ });
13666
+ return this;
13667
+ }
13668
+
13564
13669
  /**
13565
13670
  * Changes the read preference that the backend will use when performing the query to the database.
13566
13671
  *
@@ -13590,30 +13695,30 @@ var ParseQuery = /*#__PURE__*/function () {
13590
13695
  value: function () {
13591
13696
  var _subscribe = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(sessionToken /*:: ?: string*/) {
13592
13697
  var currentUser, liveQueryClient, subscription;
13593
- return _regenerator.default.wrap(function (_context22) {
13594
- while (1) switch (_context22.prev = _context22.next) {
13698
+ return _regenerator.default.wrap(function (_context23) {
13699
+ while (1) switch (_context23.prev = _context23.next) {
13595
13700
  case 0:
13596
- _context22.next = 2;
13701
+ _context23.next = 2;
13597
13702
  return _CoreManager.default.getUserController().currentUserAsync();
13598
13703
  case 2:
13599
- currentUser = _context22.sent;
13704
+ currentUser = _context23.sent;
13600
13705
  if (!sessionToken) {
13601
13706
  sessionToken = currentUser ? currentUser.getSessionToken() : undefined;
13602
13707
  }
13603
- _context22.next = 6;
13708
+ _context23.next = 6;
13604
13709
  return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
13605
13710
  case 6:
13606
- liveQueryClient = _context22.sent;
13711
+ liveQueryClient = _context23.sent;
13607
13712
  if (liveQueryClient.shouldOpen()) {
13608
13713
  liveQueryClient.open();
13609
13714
  }
13610
13715
  subscription = liveQueryClient.subscribe(this, sessionToken);
13611
- return _context22.abrupt("return", subscription.subscribePromise.then(function () {
13716
+ return _context23.abrupt("return", subscription.subscribePromise.then(function () {
13612
13717
  return subscription;
13613
13718
  }));
13614
13719
  case 10:
13615
13720
  case "end":
13616
- return _context22.stop();
13721
+ return _context23.stop();
13617
13722
  }
13618
13723
  }, _callee7, this);
13619
13724
  }));
@@ -13695,7 +13800,7 @@ var ParseQuery = /*#__PURE__*/function () {
13695
13800
  }, {
13696
13801
  key: "cancel",
13697
13802
  value: function () /*: ParseQuery*/{
13698
- var _this14 = this;
13803
+ var _this15 = this;
13699
13804
  if (this._xhrRequest.task && typeof this._xhrRequest.task.abort === 'function') {
13700
13805
  this._xhrRequest.task._aborted = true;
13701
13806
  this._xhrRequest.task.abort();
@@ -13704,16 +13809,16 @@ var ParseQuery = /*#__PURE__*/function () {
13704
13809
  return this;
13705
13810
  }
13706
13811
  return this._xhrRequest.onchange = function () {
13707
- return _this14.cancel();
13812
+ return _this15.cancel();
13708
13813
  };
13709
13814
  }
13710
13815
  }, {
13711
13816
  key: "_setRequestTask",
13712
13817
  value: function (options) {
13713
- var _this15 = this;
13818
+ var _this16 = this;
13714
13819
  options.requestTask = function (task) {
13715
- _this15._xhrRequest.task = task;
13716
- _this15._xhrRequest.onchange();
13820
+ _this16._xhrRequest.task = task;
13821
+ _this16._xhrRequest.onchange();
13717
13822
  };
13718
13823
  }
13719
13824
  }], [{
@@ -13725,8 +13830,8 @@ var ParseQuery = /*#__PURE__*/function () {
13725
13830
  }, {
13726
13831
  key: "or",
13727
13832
  value: function () /*: ParseQuery*/{
13728
- for (var _len8 = arguments.length, queries = new Array(_len8), _key12 = 0; _key12 < _len8; _key12++) {
13729
- queries[_key12] = arguments[_key12];
13833
+ for (var _len9 = arguments.length, queries = new Array(_len9), _key13 = 0; _key13 < _len9; _key13++) {
13834
+ queries[_key13] = arguments[_key13];
13730
13835
  }
13731
13836
  var className = _getClassNameFromQueries(queries);
13732
13837
  var query = new ParseQuery(className);
@@ -13749,8 +13854,8 @@ var ParseQuery = /*#__PURE__*/function () {
13749
13854
  }, {
13750
13855
  key: "and",
13751
13856
  value: function () /*: ParseQuery*/{
13752
- for (var _len9 = arguments.length, queries = new Array(_len9), _key13 = 0; _key13 < _len9; _key13++) {
13753
- queries[_key13] = arguments[_key13];
13857
+ for (var _len10 = arguments.length, queries = new Array(_len10), _key14 = 0; _key14 < _len10; _key14++) {
13858
+ queries[_key14] = arguments[_key14];
13754
13859
  }
13755
13860
  var className = _getClassNameFromQueries(queries);
13756
13861
  var query = new ParseQuery(className);
@@ -13773,8 +13878,8 @@ var ParseQuery = /*#__PURE__*/function () {
13773
13878
  }, {
13774
13879
  key: "nor",
13775
13880
  value: function () /*: ParseQuery*/{
13776
- for (var _len10 = arguments.length, queries = new Array(_len10), _key14 = 0; _key14 < _len10; _key14++) {
13777
- queries[_key14] = arguments[_key14];
13881
+ for (var _len11 = arguments.length, queries = new Array(_len11), _key15 = 0; _key15 < _len11; _key15++) {
13882
+ queries[_key15] = arguments[_key15];
13778
13883
  }
13779
13884
  var className = _getClassNameFromQueries(queries);
13780
13885
  var query = new ParseQuery(className);
@@ -14007,7 +14112,11 @@ function _isNativeReflectConstruct() {
14007
14112
  } catch (e) {
14008
14113
  return false;
14009
14114
  }
14010
- }
14115
+ } /**
14116
+ * @flow
14117
+ */
14118
+ /*:: import type { AttributeMap } from './ObjectStateMutations';*/
14119
+ /*:: import type ParseRelation from './ParseRelation';*/
14011
14120
  /**
14012
14121
  * Represents a Role on the Parse server. Roles represent groupings of
14013
14122
  * Users for the purposes of granting permissions (e.g. specifying an ACL
@@ -14171,7 +14280,7 @@ var _ParseCLP = _interopRequireDefault(_dereq_("./ParseCLP"));
14171
14280
  /**
14172
14281
  * @flow
14173
14282
  */
14174
-
14283
+ /*:: import type { PermissionsMap } from './ParseCLP';*/
14175
14284
  var FIELD_TYPES = ['String', 'Number', 'Boolean', 'Date', 'File', 'GeoPoint', 'Polygon', 'Array', 'Object', 'Pointer', 'Relation'];
14176
14285
  /*:: type FieldOptions = {
14177
14286
  required: boolean,
@@ -14712,7 +14821,11 @@ function _isNativeReflectConstruct() {
14712
14821
  } catch (e) {
14713
14822
  return false;
14714
14823
  }
14715
- }
14824
+ } /**
14825
+ * @flow
14826
+ */
14827
+ /*:: import type { AttributeMap } from './ObjectStateMutations';*/
14828
+ /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
14716
14829
  /**
14717
14830
  * <p>A Parse.Session object is a local representation of a revocable session.
14718
14831
  * This class is a subclass of a Parse.Object, and retains the same
@@ -14875,7 +14988,12 @@ function _isNativeReflectConstruct() {
14875
14988
  } catch (e) {
14876
14989
  return false;
14877
14990
  }
14878
- }
14991
+ } /**
14992
+ * @flow
14993
+ */
14994
+ /*:: import type { AttributeMap } from './ObjectStateMutations';*/
14995
+ /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
14996
+ /*:: export type AuthData = ?{ [key: string]: mixed };*/
14879
14997
  var CURRENT_USER_KEY = 'currentUser';
14880
14998
  var canUseCurrentUser = !_CoreManager.default.get('IS_NODE');
14881
14999
  var currentUserCacheMatchesDisk = false;
@@ -15701,6 +15819,27 @@ var ParseUser = /*#__PURE__*/function (_ParseObject) {
15701
15819
  return user.logIn(options);
15702
15820
  }
15703
15821
 
15822
+ /**
15823
+ * Logs in a user with an objectId. On success, this saves the session
15824
+ * to disk, so you can retrieve the currently logged in user using
15825
+ * <code>current</code>.
15826
+ *
15827
+ * @param {string} userId The objectId for the user.
15828
+ * @static
15829
+ * @returns {Promise} A promise that is fulfilled with the user when
15830
+ * the login completes.
15831
+ */
15832
+ }, {
15833
+ key: "loginAs",
15834
+ value: function (userId /*: string*/) {
15835
+ if (!userId) {
15836
+ throw new _ParseError.default(_ParseError.default.USERNAME_MISSING, 'Cannot log in as user with an empty user id');
15837
+ }
15838
+ var controller = _CoreManager.default.getUserController();
15839
+ var user = new this();
15840
+ return controller.loginAs(user, userId);
15841
+ }
15842
+
15704
15843
  /**
15705
15844
  * Logs in a user with a session token. On success, this saves the session
15706
15845
  * to disk, so you can retrieve the currently logged in user using
@@ -16145,6 +16284,21 @@ var DefaultController = {
16145
16284
  return DefaultController.setCurrentUser(user);
16146
16285
  });
16147
16286
  },
16287
+ loginAs: function (user /*: ParseUser*/, userId /*: string*/) /*: Promise<ParseUser>*/{
16288
+ var RESTController = _CoreManager.default.getRESTController();
16289
+ return RESTController.request('POST', 'loginAs', {
16290
+ userId: userId
16291
+ }, {
16292
+ useMasterKey: true
16293
+ }).then(function (response) {
16294
+ user._finishFetch(response);
16295
+ user._setExisted(true);
16296
+ if (!canUseCurrentUser) {
16297
+ return _promise.default.resolve(user);
16298
+ }
16299
+ return DefaultController.setCurrentUser(user);
16300
+ });
16301
+ },
16148
16302
  become: function (user /*: ParseUser*/, options /*: RequestOptions*/) /*: Promise<ParseUser>*/{
16149
16303
  var RESTController = _CoreManager.default.getRESTController();
16150
16304
  return RESTController.request('GET', 'users/me', {}, options).then(function (response) {
@@ -16288,7 +16442,14 @@ var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
16288
16442
  /**
16289
16443
  * @flow
16290
16444
  */
16291
-
16445
+ /*:: import type { WhereClause } from './ParseQuery';*/
16446
+ /*:: import type { FullOptions } from './RESTController';*/
16447
+ /*:: export type PushData = {
16448
+ where?: WhereClause | ParseQuery,
16449
+ push_time?: Date | string,
16450
+ expiration_time?: Date | string,
16451
+ expiration_interval?: number,
16452
+ };*/
16292
16453
  /**
16293
16454
  * Contains functions to deal with Push in Parse.
16294
16455
  *
@@ -16296,7 +16457,6 @@ var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
16296
16457
  * @static
16297
16458
  * @hideconstructor
16298
16459
  */
16299
-
16300
16460
  /**
16301
16461
  * Sends a push notification.
16302
16462
  * **Available in Cloud Code only.**
@@ -16427,6 +16587,26 @@ function _objectSpread(target) {
16427
16587
  */
16428
16588
  /* global XMLHttpRequest, XDomainRequest */
16429
16589
  var uuidv4 = _dereq_('./uuid');
16590
+ /*:: export type RequestOptions = {
16591
+ useMasterKey?: boolean,
16592
+ sessionToken?: string,
16593
+ installationId?: string,
16594
+ returnStatus?: boolean,
16595
+ batchSize?: number,
16596
+ include?: any,
16597
+ progress?: any,
16598
+ context?: any,
16599
+ usePost?: boolean,
16600
+ };*/
16601
+ /*:: export type FullOptions = {
16602
+ success?: any,
16603
+ error?: any,
16604
+ useMasterKey?: boolean,
16605
+ sessionToken?: string,
16606
+ installationId?: string,
16607
+ progress?: any,
16608
+ usePost?: boolean,
16609
+ };*/
16430
16610
  var XHR = null;
16431
16611
  if (typeof XMLHttpRequest !== 'undefined') {
16432
16612
  XHR = XMLHttpRequest;
@@ -16772,7 +16952,12 @@ function _interopRequireWildcard(obj, nodeInterop) {
16772
16952
  /**
16773
16953
  * @flow
16774
16954
  */
16775
-
16955
+ /*:: import type { Op } from './ParseOp';*/
16956
+ /*:: import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';*/
16957
+ /*:: type ObjectIdentifier = {
16958
+ className: string,
16959
+ id: string,
16960
+ };*/
16776
16961
  var objectState
16777
16962
  /*: {
16778
16963
  [className: string]: {
@@ -17012,6 +17197,10 @@ var _promiseUtils = _dereq_("./promiseUtils");
17012
17197
  /**
17013
17198
  * @flow
17014
17199
  */
17200
+ /*:: type Task = {
17201
+ task: () => Promise,
17202
+ _completion: Promise,
17203
+ };*/
17015
17204
  var TaskQueue = /*#__PURE__*/function () {
17016
17205
  function TaskQueue() {
17017
17206
  (0, _classCallCheck2.default)(this, TaskQueue);
@@ -17130,7 +17319,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
17130
17319
  /**
17131
17320
  * @flow
17132
17321
  */
17133
-
17322
+ /*:: import type { Op } from './ParseOp';*/
17323
+ /*:: import type ParseObject from './ParseObject';*/
17324
+ /*:: import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';*/
17134
17325
  var objectState = new _weakMap.default();
17135
17326
  function getState(obj /*: ParseObject*/) /*: ?State*/{
17136
17327
  var classData = objectState.get(obj);
@@ -17747,7 +17938,10 @@ var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
17747
17938
  /**
17748
17939
  * @flow
17749
17940
  */
17750
-
17941
+ /*:: type EncounterMap = {
17942
+ objects: { [identifier: string]: ParseObject | boolean },
17943
+ files: Array<ParseFile>,
17944
+ };*/
17751
17945
  /**
17752
17946
  * Return an array of unsaved children, which are either Parse Objects or Files.
17753
17947
  * If it encounters any dirty Objects without Ids, it will throw an exception.