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
@@ -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;
@@ -1673,7 +1684,7 @@ function _isNativeReflectConstruct() {
1673
1684
  } catch (e) {
1674
1685
  return false;
1675
1686
  }
1676
- }
1687
+ } /* global WebSocket */
1677
1688
  // The LiveQuery client inner state
1678
1689
  var CLIENT_STATE = {
1679
1690
  INITIALIZED: 'initialized',
@@ -1853,21 +1864,25 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
1853
1864
  }, {
1854
1865
  key: "subscribe",
1855
1866
  value: function (query /*: Object*/, sessionToken /*: ?string*/) /*: LiveQuerySubscription*/{
1856
- var _this2 = this;
1867
+ var _queryJSON$keys,
1868
+ _queryJSON$watch,
1869
+ _this2 = this;
1857
1870
  if (!query) {
1858
1871
  return;
1859
1872
  }
1860
1873
  var className = query.className;
1861
1874
  var queryJSON = query.toJSON();
1862
1875
  var where = queryJSON.where;
1863
- var fields = (0, _keys.default)(queryJSON) ? (0, _keys.default)(queryJSON).split(',') : undefined;
1876
+ var fields = (_queryJSON$keys = (0, _keys.default)(queryJSON)) === null || _queryJSON$keys === void 0 ? void 0 : _queryJSON$keys.split(',');
1877
+ var watch = (_queryJSON$watch = queryJSON.watch) === null || _queryJSON$watch === void 0 ? void 0 : _queryJSON$watch.split(',');
1864
1878
  var subscribeRequest = {
1865
1879
  op: OP_TYPES.SUBSCRIBE,
1866
1880
  requestId: this.requestId,
1867
1881
  query: {
1868
1882
  className: className,
1869
1883
  where: where,
1870
- fields: fields
1884
+ fields: fields,
1885
+ watch: watch
1871
1886
  }
1872
1887
  };
1873
1888
  if (sessionToken) {
@@ -2472,7 +2487,9 @@ function _arrayLikeToArray(arr, len) {
2472
2487
  if (len == null || len > arr.length) len = arr.length;
2473
2488
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
2474
2489
  return arr2;
2475
- }
2490
+ } /**
2491
+ * @flow
2492
+ */ /*:: import type ParseObject from './ParseObject';*/
2476
2493
  /**
2477
2494
  * Provides a local datastore which can be used to store and retrieve <code>Parse.Object</code>. <br />
2478
2495
  * To enable this functionality, call <code>Parse.enableLocalDatastore()</code>.
@@ -3163,7 +3180,9 @@ function _arrayLikeToArray(arr, len) {
3163
3180
  if (len == null || len > arr.length) len = arr.length;
3164
3181
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
3165
3182
  return arr2;
3166
- }
3183
+ } /**
3184
+ * @flow
3185
+ */
3167
3186
  var LocalDatastoreController = {
3168
3187
  fromPinWithName: function (name /*: string*/) /*: Array<Object>*/{
3169
3188
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
@@ -3409,7 +3428,20 @@ function _objectSpread(target) {
3409
3428
  });
3410
3429
  }
3411
3430
  return target;
3412
- }
3431
+ } /**
3432
+ * @flow
3433
+ */
3434
+ /*:: import type { Op } from './ParseOp';*/
3435
+ /*:: export type AttributeMap = { [attr: string]: any };*/
3436
+ /*:: export type OpsMap = { [attr: string]: Op };*/
3437
+ /*:: export type ObjectCache = { [attr: string]: string };*/
3438
+ /*:: export type State = {
3439
+ serverData: AttributeMap,
3440
+ pendingOps: Array<OpsMap>,
3441
+ objectCache: ObjectCache,
3442
+ tasks: TaskQueue,
3443
+ existed: boolean,
3444
+ };*/
3413
3445
  function defaultState() /*: State*/{
3414
3446
  return {
3415
3447
  serverData: {},
@@ -4560,7 +4592,8 @@ var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
4560
4592
  /**
4561
4593
  * @flow
4562
4594
  */
4563
-
4595
+ /*:: type PermissionsMap = { [permission: string]: boolean };*/
4596
+ /*:: type ByIdMap = { [userId: string]: PermissionsMap };*/
4564
4597
  var PUBLIC_KEY = '*';
4565
4598
 
4566
4599
  /**
@@ -5024,7 +5057,12 @@ function _arrayLikeToArray(arr, len) {
5024
5057
  if (len == null || len > arr.length) len = arr.length;
5025
5058
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
5026
5059
  return arr2;
5027
- }
5060
+ } /**
5061
+ * @flow
5062
+ */
5063
+ /*:: type Entity = Entity;*/
5064
+ /*:: type UsersMap = { [userId: string]: boolean | any };*/
5065
+ /*:: export type PermissionsMap = { [permission: string]: UsersMap };*/
5028
5066
  var PUBLIC_KEY = '*';
5029
5067
  var VALID_PERMISSIONS /*: Map<string, UsersMap>*/ = new _map.default(
5030
5068
  /*:: <string, UsersMap>*/
@@ -5706,6 +5744,7 @@ var _Storage = _interopRequireDefault(_dereq_("./Storage"));
5706
5744
  /**
5707
5745
  * @flow
5708
5746
  */
5747
+ /*:: import type { RequestOptions } from './RESTController';*/
5709
5748
  /**
5710
5749
  * Parse.Config is a local representation of configuration data that
5711
5750
  * can be set from the Parse dashboard.
@@ -6557,7 +6596,10 @@ function _objectSpread(target) {
6557
6596
  });
6558
6597
  }
6559
6598
  return target;
6560
- }
6599
+ } /**
6600
+ * @flow
6601
+ */ /* global XMLHttpRequest, Blob */
6602
+ /*:: import type { FullOptions } from './RESTController';*/
6561
6603
  var ParseError = _dereq_('./ParseError').default;
6562
6604
  var XHR = null;
6563
6605
  if (typeof XMLHttpRequest !== 'undefined') {
@@ -7411,7 +7453,10 @@ function _isNativeReflectConstruct() {
7411
7453
  } catch (e) {
7412
7454
  return false;
7413
7455
  }
7414
- }
7456
+ } /**
7457
+ * @flow
7458
+ */
7459
+ /*:: import type { AttributeMap } from './ObjectStateMutations';*/
7415
7460
  var Installation = /*#__PURE__*/function (_ParseObject) {
7416
7461
  (0, _inherits2.default)(Installation, _ParseObject);
7417
7462
  var _super = _createSuper(Installation);
@@ -7793,7 +7838,11 @@ function _objectSpread(target) {
7793
7838
  });
7794
7839
  }
7795
7840
  return target;
7796
- }
7841
+ } /**
7842
+ * @flow
7843
+ */
7844
+ /*:: import type { AttributeMap, OpsMap } from './ObjectStateMutations';*/
7845
+ /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
7797
7846
  var uuidv4 = _dereq_('./uuid');
7798
7847
  /*:: export type Pointer = {
7799
7848
  __type: string,
@@ -7859,6 +7908,11 @@ var ParseObject = /*#__PURE__*/function () {
7859
7908
  */
7860
7909
  function ParseObject(className /*: ?string | { className: string, [attr: string]: mixed }*/, attributes /*:: ?: { [attr: string]: mixed }*/, options /*:: ?: { ignoreValidation: boolean }*/) {
7861
7910
  (0, _classCallCheck2.default)(this, ParseObject);
7911
+ /**
7912
+ * The ID of this object, unique within its class.
7913
+ *
7914
+ * @property {string} id
7915
+ */
7862
7916
  (0, _defineProperty2.default)(this, "id", void 0);
7863
7917
  (0, _defineProperty2.default)(this, "_localId", void 0);
7864
7918
  (0, _defineProperty2.default)(this, "_objCount", void 0);
@@ -7890,12 +7944,6 @@ var ParseObject = /*#__PURE__*/function () {
7890
7944
  throw new Error("Can't create an invalid Parse Object");
7891
7945
  }
7892
7946
  }
7893
-
7894
- /**
7895
- * The ID of this object, unique within its class.
7896
- *
7897
- * @property {string} id
7898
- */
7899
7947
  (0, _createClass2.default)(ParseObject, [{
7900
7948
  key: "attributes",
7901
7949
  get: /* Prototype getters / setters */
@@ -10701,7 +10749,9 @@ function _isNativeReflectConstruct() {
10701
10749
  } catch (e) {
10702
10750
  return false;
10703
10751
  }
10704
- }
10752
+ } /**
10753
+ * @flow
10754
+ */
10705
10755
  function opFromJSON(json /*: { [key: string]: any }*/) /*: ?Op*/{
10706
10756
  if (!json || !json.__op) {
10707
10757
  return null;
@@ -11448,7 +11498,29 @@ var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
11448
11498
  /*
11449
11499
  * @flow
11450
11500
  */
11451
-
11501
+ /*:: import type LiveQuerySubscription from './LiveQuerySubscription';*/
11502
+ /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
11503
+ /*:: type BatchOptions = FullOptions & { batchSize?: number };*/
11504
+ /*:: export type WhereClause = {
11505
+ [attr: string]: mixed,
11506
+ };*/
11507
+ /*:: export type QueryJSON = {
11508
+ where: WhereClause,
11509
+ watch?: string,
11510
+ include?: string,
11511
+ excludeKeys?: string,
11512
+ keys?: string,
11513
+ limit?: number,
11514
+ skip?: number,
11515
+ order?: string,
11516
+ className?: string,
11517
+ count?: number,
11518
+ hint?: mixed,
11519
+ explain?: boolean,
11520
+ readPreference?: string,
11521
+ includeReadPreference?: string,
11522
+ subqueryReadPreference?: string,
11523
+ };*/
11452
11524
  /**
11453
11525
  * Converts a string into a regex that matches it.
11454
11526
  * Surrounding with \Q .. \E does this, we just need to escape any \E's in
@@ -11623,17 +11695,17 @@ function handleOfflineSort(a, b, sorts) {
11623
11695
  * @alias Parse.Query
11624
11696
  */
11625
11697
  var ParseQuery = /*#__PURE__*/function () {
11626
- /**
11627
- * @property {string} className
11628
- */
11629
-
11630
11698
  /**
11631
11699
  * @param {(string | Parse.Object)} objectClass An instance of a subclass of Parse.Object, or a Parse className string.
11632
11700
  */
11633
11701
  function ParseQuery(objectClass /*: string | ParseObject*/) {
11634
11702
  (0, _classCallCheck2.default)(this, ParseQuery);
11703
+ /**
11704
+ * @property {string} className
11705
+ */
11635
11706
  (0, _defineProperty2.default)(this, "className", void 0);
11636
11707
  (0, _defineProperty2.default)(this, "_where", void 0);
11708
+ (0, _defineProperty2.default)(this, "_watch", void 0);
11637
11709
  (0, _defineProperty2.default)(this, "_include", void 0);
11638
11710
  (0, _defineProperty2.default)(this, "_exclude", void 0);
11639
11711
  (0, _defineProperty2.default)(this, "_select", void 0);
@@ -11669,6 +11741,7 @@ var ParseQuery = /*#__PURE__*/function () {
11669
11741
  throw new TypeError('A ParseQuery must be constructed with a ParseObject or class name.');
11670
11742
  }
11671
11743
  this._where = {};
11744
+ this._watch = [];
11672
11745
  this._include = [];
11673
11746
  this._exclude = [];
11674
11747
  this._count = false;
@@ -11861,6 +11934,9 @@ var ParseQuery = /*#__PURE__*/function () {
11861
11934
  var params /*: QueryJSON*/ = {
11862
11935
  where: this._where
11863
11936
  };
11937
+ if (this._watch.length) {
11938
+ params.watch = this._watch.join(',');
11939
+ }
11864
11940
  if (this._include.length) {
11865
11941
  params.include = this._include.join(',');
11866
11942
  }
@@ -11930,6 +12006,9 @@ var ParseQuery = /*#__PURE__*/function () {
11930
12006
  if (json.where) {
11931
12007
  this._where = json.where;
11932
12008
  }
12009
+ if (json.watch) {
12010
+ this._watch = json.watch.split(',');
12011
+ }
11933
12012
  if (json.include) {
11934
12013
  this._include = json.include.split(',');
11935
12014
  }
@@ -13519,6 +13598,32 @@ var ParseQuery = /*#__PURE__*/function () {
13519
13598
  return this;
13520
13599
  }
13521
13600
 
13601
+ /**
13602
+ * Restricts live query to trigger only for watched fields.
13603
+ *
13604
+ * Requires Parse Server 6.0.0+
13605
+ *
13606
+ * @param {...string|Array<string>} keys The name(s) of the key(s) to watch.
13607
+ * @returns {Parse.Query} Returns the query, so you can chain this call.
13608
+ */
13609
+ }, {
13610
+ key: "watch",
13611
+ value: function () /*: ParseQuery*/{
13612
+ var _this14 = this;
13613
+ for (var _len8 = arguments.length, keys = new Array(_len8), _key12 = 0; _key12 < _len8; _key12++) {
13614
+ keys[_key12] = arguments[_key12];
13615
+ }
13616
+ (0, _forEach.default)(keys).call(keys, function (key) {
13617
+ if ((0, _isArray.default)(key)) {
13618
+ var _context22;
13619
+ _this14._watch = (0, _concat.default)(_context22 = _this14._watch).call(_context22, key);
13620
+ } else {
13621
+ _this14._watch.push(key);
13622
+ }
13623
+ });
13624
+ return this;
13625
+ }
13626
+
13522
13627
  /**
13523
13628
  * Changes the read preference that the backend will use when performing the query to the database.
13524
13629
  *
@@ -13548,30 +13653,30 @@ var ParseQuery = /*#__PURE__*/function () {
13548
13653
  value: function () {
13549
13654
  var _subscribe = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(sessionToken /*:: ?: string*/) {
13550
13655
  var currentUser, liveQueryClient, subscription;
13551
- return _regenerator.default.wrap(function (_context22) {
13552
- while (1) switch (_context22.prev = _context22.next) {
13656
+ return _regenerator.default.wrap(function (_context23) {
13657
+ while (1) switch (_context23.prev = _context23.next) {
13553
13658
  case 0:
13554
- _context22.next = 2;
13659
+ _context23.next = 2;
13555
13660
  return _CoreManager.default.getUserController().currentUserAsync();
13556
13661
  case 2:
13557
- currentUser = _context22.sent;
13662
+ currentUser = _context23.sent;
13558
13663
  if (!sessionToken) {
13559
13664
  sessionToken = currentUser ? currentUser.getSessionToken() : undefined;
13560
13665
  }
13561
- _context22.next = 6;
13666
+ _context23.next = 6;
13562
13667
  return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
13563
13668
  case 6:
13564
- liveQueryClient = _context22.sent;
13669
+ liveQueryClient = _context23.sent;
13565
13670
  if (liveQueryClient.shouldOpen()) {
13566
13671
  liveQueryClient.open();
13567
13672
  }
13568
13673
  subscription = liveQueryClient.subscribe(this, sessionToken);
13569
- return _context22.abrupt("return", subscription.subscribePromise.then(function () {
13674
+ return _context23.abrupt("return", subscription.subscribePromise.then(function () {
13570
13675
  return subscription;
13571
13676
  }));
13572
13677
  case 10:
13573
13678
  case "end":
13574
- return _context22.stop();
13679
+ return _context23.stop();
13575
13680
  }
13576
13681
  }, _callee7, this);
13577
13682
  }));
@@ -13653,7 +13758,7 @@ var ParseQuery = /*#__PURE__*/function () {
13653
13758
  }, {
13654
13759
  key: "cancel",
13655
13760
  value: function () /*: ParseQuery*/{
13656
- var _this14 = this;
13761
+ var _this15 = this;
13657
13762
  if (this._xhrRequest.task && typeof this._xhrRequest.task.abort === 'function') {
13658
13763
  this._xhrRequest.task._aborted = true;
13659
13764
  this._xhrRequest.task.abort();
@@ -13662,16 +13767,16 @@ var ParseQuery = /*#__PURE__*/function () {
13662
13767
  return this;
13663
13768
  }
13664
13769
  return this._xhrRequest.onchange = function () {
13665
- return _this14.cancel();
13770
+ return _this15.cancel();
13666
13771
  };
13667
13772
  }
13668
13773
  }, {
13669
13774
  key: "_setRequestTask",
13670
13775
  value: function (options) {
13671
- var _this15 = this;
13776
+ var _this16 = this;
13672
13777
  options.requestTask = function (task) {
13673
- _this15._xhrRequest.task = task;
13674
- _this15._xhrRequest.onchange();
13778
+ _this16._xhrRequest.task = task;
13779
+ _this16._xhrRequest.onchange();
13675
13780
  };
13676
13781
  }
13677
13782
  }], [{
@@ -13683,8 +13788,8 @@ var ParseQuery = /*#__PURE__*/function () {
13683
13788
  }, {
13684
13789
  key: "or",
13685
13790
  value: function () /*: ParseQuery*/{
13686
- for (var _len8 = arguments.length, queries = new Array(_len8), _key12 = 0; _key12 < _len8; _key12++) {
13687
- queries[_key12] = arguments[_key12];
13791
+ for (var _len9 = arguments.length, queries = new Array(_len9), _key13 = 0; _key13 < _len9; _key13++) {
13792
+ queries[_key13] = arguments[_key13];
13688
13793
  }
13689
13794
  var className = _getClassNameFromQueries(queries);
13690
13795
  var query = new ParseQuery(className);
@@ -13707,8 +13812,8 @@ var ParseQuery = /*#__PURE__*/function () {
13707
13812
  }, {
13708
13813
  key: "and",
13709
13814
  value: function () /*: ParseQuery*/{
13710
- for (var _len9 = arguments.length, queries = new Array(_len9), _key13 = 0; _key13 < _len9; _key13++) {
13711
- queries[_key13] = arguments[_key13];
13815
+ for (var _len10 = arguments.length, queries = new Array(_len10), _key14 = 0; _key14 < _len10; _key14++) {
13816
+ queries[_key14] = arguments[_key14];
13712
13817
  }
13713
13818
  var className = _getClassNameFromQueries(queries);
13714
13819
  var query = new ParseQuery(className);
@@ -13731,8 +13836,8 @@ var ParseQuery = /*#__PURE__*/function () {
13731
13836
  }, {
13732
13837
  key: "nor",
13733
13838
  value: function () /*: ParseQuery*/{
13734
- for (var _len10 = arguments.length, queries = new Array(_len10), _key14 = 0; _key14 < _len10; _key14++) {
13735
- queries[_key14] = arguments[_key14];
13839
+ for (var _len11 = arguments.length, queries = new Array(_len11), _key15 = 0; _key15 < _len11; _key15++) {
13840
+ queries[_key15] = arguments[_key15];
13736
13841
  }
13737
13842
  var className = _getClassNameFromQueries(queries);
13738
13843
  var query = new ParseQuery(className);
@@ -13965,7 +14070,11 @@ function _isNativeReflectConstruct() {
13965
14070
  } catch (e) {
13966
14071
  return false;
13967
14072
  }
13968
- }
14073
+ } /**
14074
+ * @flow
14075
+ */
14076
+ /*:: import type { AttributeMap } from './ObjectStateMutations';*/
14077
+ /*:: import type ParseRelation from './ParseRelation';*/
13969
14078
  /**
13970
14079
  * Represents a Role on the Parse server. Roles represent groupings of
13971
14080
  * Users for the purposes of granting permissions (e.g. specifying an ACL
@@ -14129,7 +14238,7 @@ var _ParseCLP = _interopRequireDefault(_dereq_("./ParseCLP"));
14129
14238
  /**
14130
14239
  * @flow
14131
14240
  */
14132
-
14241
+ /*:: import type { PermissionsMap } from './ParseCLP';*/
14133
14242
  var FIELD_TYPES = ['String', 'Number', 'Boolean', 'Date', 'File', 'GeoPoint', 'Polygon', 'Array', 'Object', 'Pointer', 'Relation'];
14134
14243
  /*:: type FieldOptions = {
14135
14244
  required: boolean,
@@ -14670,7 +14779,11 @@ function _isNativeReflectConstruct() {
14670
14779
  } catch (e) {
14671
14780
  return false;
14672
14781
  }
14673
- }
14782
+ } /**
14783
+ * @flow
14784
+ */
14785
+ /*:: import type { AttributeMap } from './ObjectStateMutations';*/
14786
+ /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
14674
14787
  /**
14675
14788
  * <p>A Parse.Session object is a local representation of a revocable session.
14676
14789
  * This class is a subclass of a Parse.Object, and retains the same
@@ -14833,7 +14946,12 @@ function _isNativeReflectConstruct() {
14833
14946
  } catch (e) {
14834
14947
  return false;
14835
14948
  }
14836
- }
14949
+ } /**
14950
+ * @flow
14951
+ */
14952
+ /*:: import type { AttributeMap } from './ObjectStateMutations';*/
14953
+ /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
14954
+ /*:: export type AuthData = ?{ [key: string]: mixed };*/
14837
14955
  var CURRENT_USER_KEY = 'currentUser';
14838
14956
  var canUseCurrentUser = !_CoreManager.default.get('IS_NODE');
14839
14957
  var currentUserCacheMatchesDisk = false;
@@ -15659,6 +15777,27 @@ var ParseUser = /*#__PURE__*/function (_ParseObject) {
15659
15777
  return user.logIn(options);
15660
15778
  }
15661
15779
 
15780
+ /**
15781
+ * Logs in a user with an objectId. On success, this saves the session
15782
+ * to disk, so you can retrieve the currently logged in user using
15783
+ * <code>current</code>.
15784
+ *
15785
+ * @param {string} userId The objectId for the user.
15786
+ * @static
15787
+ * @returns {Promise} A promise that is fulfilled with the user when
15788
+ * the login completes.
15789
+ */
15790
+ }, {
15791
+ key: "loginAs",
15792
+ value: function (userId /*: string*/) {
15793
+ if (!userId) {
15794
+ throw new _ParseError.default(_ParseError.default.USERNAME_MISSING, 'Cannot log in as user with an empty user id');
15795
+ }
15796
+ var controller = _CoreManager.default.getUserController();
15797
+ var user = new this();
15798
+ return controller.loginAs(user, userId);
15799
+ }
15800
+
15662
15801
  /**
15663
15802
  * Logs in a user with a session token. On success, this saves the session
15664
15803
  * to disk, so you can retrieve the currently logged in user using
@@ -16103,6 +16242,21 @@ var DefaultController = {
16103
16242
  return DefaultController.setCurrentUser(user);
16104
16243
  });
16105
16244
  },
16245
+ loginAs: function (user /*: ParseUser*/, userId /*: string*/) /*: Promise<ParseUser>*/{
16246
+ var RESTController = _CoreManager.default.getRESTController();
16247
+ return RESTController.request('POST', 'loginAs', {
16248
+ userId: userId
16249
+ }, {
16250
+ useMasterKey: true
16251
+ }).then(function (response) {
16252
+ user._finishFetch(response);
16253
+ user._setExisted(true);
16254
+ if (!canUseCurrentUser) {
16255
+ return _promise.default.resolve(user);
16256
+ }
16257
+ return DefaultController.setCurrentUser(user);
16258
+ });
16259
+ },
16106
16260
  become: function (user /*: ParseUser*/, options /*: RequestOptions*/) /*: Promise<ParseUser>*/{
16107
16261
  var RESTController = _CoreManager.default.getRESTController();
16108
16262
  return RESTController.request('GET', 'users/me', {}, options).then(function (response) {
@@ -16246,7 +16400,14 @@ var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
16246
16400
  /**
16247
16401
  * @flow
16248
16402
  */
16249
-
16403
+ /*:: import type { WhereClause } from './ParseQuery';*/
16404
+ /*:: import type { FullOptions } from './RESTController';*/
16405
+ /*:: export type PushData = {
16406
+ where?: WhereClause | ParseQuery,
16407
+ push_time?: Date | string,
16408
+ expiration_time?: Date | string,
16409
+ expiration_interval?: number,
16410
+ };*/
16250
16411
  /**
16251
16412
  * Contains functions to deal with Push in Parse.
16252
16413
  *
@@ -16254,7 +16415,6 @@ var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
16254
16415
  * @static
16255
16416
  * @hideconstructor
16256
16417
  */
16257
-
16258
16418
  /**
16259
16419
  * Sends a push notification.
16260
16420
  * **Available in Cloud Code only.**
@@ -16385,6 +16545,26 @@ function _objectSpread(target) {
16385
16545
  */
16386
16546
  /* global XMLHttpRequest, XDomainRequest */
16387
16547
  var uuidv4 = _dereq_('./uuid');
16548
+ /*:: export type RequestOptions = {
16549
+ useMasterKey?: boolean,
16550
+ sessionToken?: string,
16551
+ installationId?: string,
16552
+ returnStatus?: boolean,
16553
+ batchSize?: number,
16554
+ include?: any,
16555
+ progress?: any,
16556
+ context?: any,
16557
+ usePost?: boolean,
16558
+ };*/
16559
+ /*:: export type FullOptions = {
16560
+ success?: any,
16561
+ error?: any,
16562
+ useMasterKey?: boolean,
16563
+ sessionToken?: string,
16564
+ installationId?: string,
16565
+ progress?: any,
16566
+ usePost?: boolean,
16567
+ };*/
16388
16568
  var XHR = null;
16389
16569
  if (typeof XMLHttpRequest !== 'undefined') {
16390
16570
  XHR = XMLHttpRequest;
@@ -16731,7 +16911,12 @@ function _interopRequireWildcard(obj, nodeInterop) {
16731
16911
  /**
16732
16912
  * @flow
16733
16913
  */
16734
-
16914
+ /*:: import type { Op } from './ParseOp';*/
16915
+ /*:: import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';*/
16916
+ /*:: type ObjectIdentifier = {
16917
+ className: string,
16918
+ id: string,
16919
+ };*/
16735
16920
  var objectState
16736
16921
  /*: {
16737
16922
  [className: string]: {
@@ -17014,6 +17199,10 @@ var _promiseUtils = _dereq_("./promiseUtils");
17014
17199
  /**
17015
17200
  * @flow
17016
17201
  */
17202
+ /*:: type Task = {
17203
+ task: () => Promise,
17204
+ _completion: Promise,
17205
+ };*/
17017
17206
  var TaskQueue = /*#__PURE__*/function () {
17018
17207
  function TaskQueue() {
17019
17208
  (0, _classCallCheck2.default)(this, TaskQueue);
@@ -17132,7 +17321,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
17132
17321
  /**
17133
17322
  * @flow
17134
17323
  */
17135
-
17324
+ /*:: import type { Op } from './ParseOp';*/
17325
+ /*:: import type ParseObject from './ParseObject';*/
17326
+ /*:: import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';*/
17136
17327
  var objectState = new _weakMap.default();
17137
17328
  function getState(obj /*: ParseObject*/) /*: ?State*/{
17138
17329
  var classData = objectState.get(obj);
@@ -17851,7 +18042,10 @@ var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
17851
18042
  /**
17852
18043
  * @flow
17853
18044
  */
17854
-
18045
+ /*:: type EncounterMap = {
18046
+ objects: { [identifier: string]: ParseObject | boolean },
18047
+ files: Array<ParseFile>,
18048
+ };*/
17855
18049
  /**
17856
18050
  * Return an array of unsaved children, which are either Parse Objects or Files.
17857
18051
  * If it encounters any dirty Objects without Ids, it will throw an exception.