parse 4.1.0-beta.1 → 4.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.
Files changed (87) hide show
  1. package/dist/parse.js +253 -58
  2. package/dist/parse.min.js +2 -2
  3. package/dist/parse.weapp.js +253 -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 +5 -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 +2 -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/ParseFile.js +1 -0
  59. package/lib/react-native/ParseQuery.js +34 -11
  60. package/lib/react-native/ParseUser.js +25 -0
  61. package/lib/weapp/AnonymousUtils.js +1 -1
  62. package/lib/weapp/Cloud.js +1 -2
  63. package/lib/weapp/CoreManager.js +1 -1
  64. package/lib/weapp/EventuallyQueue.js +13 -1
  65. package/lib/weapp/LiveQueryClient.js +8 -4
  66. package/lib/weapp/LocalDatastore.js +3 -1
  67. package/lib/weapp/LocalDatastoreController.js +3 -1
  68. package/lib/weapp/ObjectStateMutations.js +14 -1
  69. package/lib/weapp/ParseACL.js +2 -1
  70. package/lib/weapp/ParseCLP.js +6 -1
  71. package/lib/weapp/ParseConfig.js +1 -0
  72. package/lib/weapp/ParseFile.js +5 -1
  73. package/lib/weapp/ParseInstallation.js +4 -1
  74. package/lib/weapp/ParseObject.js +10 -7
  75. package/lib/weapp/ParseOp.js +3 -1
  76. package/lib/weapp/ParseQuery.js +79 -24
  77. package/lib/weapp/ParseRole.js +5 -1
  78. package/lib/weapp/ParseSchema.js +1 -1
  79. package/lib/weapp/ParseSession.js +5 -1
  80. package/lib/weapp/ParseUser.js +42 -1
  81. package/lib/weapp/Push.js +8 -2
  82. package/lib/weapp/RESTController.js +20 -0
  83. package/lib/weapp/SingleInstanceStateController.js +6 -1
  84. package/lib/weapp/TaskQueue.js +4 -0
  85. package/lib/weapp/UniqueInstanceStateController.js +3 -1
  86. package/lib/weapp/unsavedChildren.js +4 -1
  87. package/package.json +18 -18
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Parse JavaScript SDK v4.1.0-beta.1
2
+ * Parse JavaScript SDK v4.2.0-alpha.1
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-beta.1",
533
+ VERSION: 'js' + "4.2.0-alpha.1",
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') {
@@ -6880,6 +6922,7 @@ var ParseFile = /*#__PURE__*/function () {
6880
6922
  key: "cancel",
6881
6923
  value: function () {
6882
6924
  if (this._requestTask && typeof this._requestTask.abort === 'function') {
6925
+ this._requestTask._aborted = true;
6883
6926
  this._requestTask.abort();
6884
6927
  }
6885
6928
  this._requestTask = null;
@@ -7410,7 +7453,10 @@ function _isNativeReflectConstruct() {
7410
7453
  } catch (e) {
7411
7454
  return false;
7412
7455
  }
7413
- }
7456
+ } /**
7457
+ * @flow
7458
+ */
7459
+ /*:: import type { AttributeMap } from './ObjectStateMutations';*/
7414
7460
  var Installation = /*#__PURE__*/function (_ParseObject) {
7415
7461
  (0, _inherits2.default)(Installation, _ParseObject);
7416
7462
  var _super = _createSuper(Installation);
@@ -7792,7 +7838,11 @@ function _objectSpread(target) {
7792
7838
  });
7793
7839
  }
7794
7840
  return target;
7795
- }
7841
+ } /**
7842
+ * @flow
7843
+ */
7844
+ /*:: import type { AttributeMap, OpsMap } from './ObjectStateMutations';*/
7845
+ /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
7796
7846
  var uuidv4 = _dereq_('./uuid');
7797
7847
  /*:: export type Pointer = {
7798
7848
  __type: string,
@@ -7858,6 +7908,11 @@ var ParseObject = /*#__PURE__*/function () {
7858
7908
  */
7859
7909
  function ParseObject(className /*: ?string | { className: string, [attr: string]: mixed }*/, attributes /*:: ?: { [attr: string]: mixed }*/, options /*:: ?: { ignoreValidation: boolean }*/) {
7860
7910
  (0, _classCallCheck2.default)(this, ParseObject);
7911
+ /**
7912
+ * The ID of this object, unique within its class.
7913
+ *
7914
+ * @property {string} id
7915
+ */
7861
7916
  (0, _defineProperty2.default)(this, "id", void 0);
7862
7917
  (0, _defineProperty2.default)(this, "_localId", void 0);
7863
7918
  (0, _defineProperty2.default)(this, "_objCount", void 0);
@@ -7889,12 +7944,6 @@ var ParseObject = /*#__PURE__*/function () {
7889
7944
  throw new Error("Can't create an invalid Parse Object");
7890
7945
  }
7891
7946
  }
7892
-
7893
- /**
7894
- * The ID of this object, unique within its class.
7895
- *
7896
- * @property {string} id
7897
- */
7898
7947
  (0, _createClass2.default)(ParseObject, [{
7899
7948
  key: "attributes",
7900
7949
  get: /* Prototype getters / setters */
@@ -10700,7 +10749,9 @@ function _isNativeReflectConstruct() {
10700
10749
  } catch (e) {
10701
10750
  return false;
10702
10751
  }
10703
- }
10752
+ } /**
10753
+ * @flow
10754
+ */
10704
10755
  function opFromJSON(json /*: { [key: string]: any }*/) /*: ?Op*/{
10705
10756
  if (!json || !json.__op) {
10706
10757
  return null;
@@ -11447,7 +11498,29 @@ var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
11447
11498
  /*
11448
11499
  * @flow
11449
11500
  */
11450
-
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
+ };*/
11451
11524
  /**
11452
11525
  * Converts a string into a regex that matches it.
11453
11526
  * Surrounding with \Q .. \E does this, we just need to escape any \E's in
@@ -11622,17 +11695,17 @@ function handleOfflineSort(a, b, sorts) {
11622
11695
  * @alias Parse.Query
11623
11696
  */
11624
11697
  var ParseQuery = /*#__PURE__*/function () {
11625
- /**
11626
- * @property {string} className
11627
- */
11628
-
11629
11698
  /**
11630
11699
  * @param {(string | Parse.Object)} objectClass An instance of a subclass of Parse.Object, or a Parse className string.
11631
11700
  */
11632
11701
  function ParseQuery(objectClass /*: string | ParseObject*/) {
11633
11702
  (0, _classCallCheck2.default)(this, ParseQuery);
11703
+ /**
11704
+ * @property {string} className
11705
+ */
11634
11706
  (0, _defineProperty2.default)(this, "className", void 0);
11635
11707
  (0, _defineProperty2.default)(this, "_where", void 0);
11708
+ (0, _defineProperty2.default)(this, "_watch", void 0);
11636
11709
  (0, _defineProperty2.default)(this, "_include", void 0);
11637
11710
  (0, _defineProperty2.default)(this, "_exclude", void 0);
11638
11711
  (0, _defineProperty2.default)(this, "_select", void 0);
@@ -11668,6 +11741,7 @@ var ParseQuery = /*#__PURE__*/function () {
11668
11741
  throw new TypeError('A ParseQuery must be constructed with a ParseObject or class name.');
11669
11742
  }
11670
11743
  this._where = {};
11744
+ this._watch = [];
11671
11745
  this._include = [];
11672
11746
  this._exclude = [];
11673
11747
  this._count = false;
@@ -11860,6 +11934,9 @@ var ParseQuery = /*#__PURE__*/function () {
11860
11934
  var params /*: QueryJSON*/ = {
11861
11935
  where: this._where
11862
11936
  };
11937
+ if (this._watch.length) {
11938
+ params.watch = this._watch.join(',');
11939
+ }
11863
11940
  if (this._include.length) {
11864
11941
  params.include = this._include.join(',');
11865
11942
  }
@@ -11929,6 +12006,9 @@ var ParseQuery = /*#__PURE__*/function () {
11929
12006
  if (json.where) {
11930
12007
  this._where = json.where;
11931
12008
  }
12009
+ if (json.watch) {
12010
+ this._watch = json.watch.split(',');
12011
+ }
11932
12012
  if (json.include) {
11933
12013
  this._include = json.include.split(',');
11934
12014
  }
@@ -13518,6 +13598,32 @@ var ParseQuery = /*#__PURE__*/function () {
13518
13598
  return this;
13519
13599
  }
13520
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
+
13521
13627
  /**
13522
13628
  * Changes the read preference that the backend will use when performing the query to the database.
13523
13629
  *
@@ -13547,30 +13653,30 @@ var ParseQuery = /*#__PURE__*/function () {
13547
13653
  value: function () {
13548
13654
  var _subscribe = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(sessionToken /*:: ?: string*/) {
13549
13655
  var currentUser, liveQueryClient, subscription;
13550
- return _regenerator.default.wrap(function (_context22) {
13551
- while (1) switch (_context22.prev = _context22.next) {
13656
+ return _regenerator.default.wrap(function (_context23) {
13657
+ while (1) switch (_context23.prev = _context23.next) {
13552
13658
  case 0:
13553
- _context22.next = 2;
13659
+ _context23.next = 2;
13554
13660
  return _CoreManager.default.getUserController().currentUserAsync();
13555
13661
  case 2:
13556
- currentUser = _context22.sent;
13662
+ currentUser = _context23.sent;
13557
13663
  if (!sessionToken) {
13558
13664
  sessionToken = currentUser ? currentUser.getSessionToken() : undefined;
13559
13665
  }
13560
- _context22.next = 6;
13666
+ _context23.next = 6;
13561
13667
  return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
13562
13668
  case 6:
13563
- liveQueryClient = _context22.sent;
13669
+ liveQueryClient = _context23.sent;
13564
13670
  if (liveQueryClient.shouldOpen()) {
13565
13671
  liveQueryClient.open();
13566
13672
  }
13567
13673
  subscription = liveQueryClient.subscribe(this, sessionToken);
13568
- return _context22.abrupt("return", subscription.subscribePromise.then(function () {
13674
+ return _context23.abrupt("return", subscription.subscribePromise.then(function () {
13569
13675
  return subscription;
13570
13676
  }));
13571
13677
  case 10:
13572
13678
  case "end":
13573
- return _context22.stop();
13679
+ return _context23.stop();
13574
13680
  }
13575
13681
  }, _callee7, this);
13576
13682
  }));
@@ -13652,7 +13758,7 @@ var ParseQuery = /*#__PURE__*/function () {
13652
13758
  }, {
13653
13759
  key: "cancel",
13654
13760
  value: function () /*: ParseQuery*/{
13655
- var _this14 = this;
13761
+ var _this15 = this;
13656
13762
  if (this._xhrRequest.task && typeof this._xhrRequest.task.abort === 'function') {
13657
13763
  this._xhrRequest.task._aborted = true;
13658
13764
  this._xhrRequest.task.abort();
@@ -13661,16 +13767,16 @@ var ParseQuery = /*#__PURE__*/function () {
13661
13767
  return this;
13662
13768
  }
13663
13769
  return this._xhrRequest.onchange = function () {
13664
- return _this14.cancel();
13770
+ return _this15.cancel();
13665
13771
  };
13666
13772
  }
13667
13773
  }, {
13668
13774
  key: "_setRequestTask",
13669
13775
  value: function (options) {
13670
- var _this15 = this;
13776
+ var _this16 = this;
13671
13777
  options.requestTask = function (task) {
13672
- _this15._xhrRequest.task = task;
13673
- _this15._xhrRequest.onchange();
13778
+ _this16._xhrRequest.task = task;
13779
+ _this16._xhrRequest.onchange();
13674
13780
  };
13675
13781
  }
13676
13782
  }], [{
@@ -13682,8 +13788,8 @@ var ParseQuery = /*#__PURE__*/function () {
13682
13788
  }, {
13683
13789
  key: "or",
13684
13790
  value: function () /*: ParseQuery*/{
13685
- for (var _len8 = arguments.length, queries = new Array(_len8), _key12 = 0; _key12 < _len8; _key12++) {
13686
- queries[_key12] = arguments[_key12];
13791
+ for (var _len9 = arguments.length, queries = new Array(_len9), _key13 = 0; _key13 < _len9; _key13++) {
13792
+ queries[_key13] = arguments[_key13];
13687
13793
  }
13688
13794
  var className = _getClassNameFromQueries(queries);
13689
13795
  var query = new ParseQuery(className);
@@ -13706,8 +13812,8 @@ var ParseQuery = /*#__PURE__*/function () {
13706
13812
  }, {
13707
13813
  key: "and",
13708
13814
  value: function () /*: ParseQuery*/{
13709
- for (var _len9 = arguments.length, queries = new Array(_len9), _key13 = 0; _key13 < _len9; _key13++) {
13710
- queries[_key13] = arguments[_key13];
13815
+ for (var _len10 = arguments.length, queries = new Array(_len10), _key14 = 0; _key14 < _len10; _key14++) {
13816
+ queries[_key14] = arguments[_key14];
13711
13817
  }
13712
13818
  var className = _getClassNameFromQueries(queries);
13713
13819
  var query = new ParseQuery(className);
@@ -13730,8 +13836,8 @@ var ParseQuery = /*#__PURE__*/function () {
13730
13836
  }, {
13731
13837
  key: "nor",
13732
13838
  value: function () /*: ParseQuery*/{
13733
- for (var _len10 = arguments.length, queries = new Array(_len10), _key14 = 0; _key14 < _len10; _key14++) {
13734
- queries[_key14] = arguments[_key14];
13839
+ for (var _len11 = arguments.length, queries = new Array(_len11), _key15 = 0; _key15 < _len11; _key15++) {
13840
+ queries[_key15] = arguments[_key15];
13735
13841
  }
13736
13842
  var className = _getClassNameFromQueries(queries);
13737
13843
  var query = new ParseQuery(className);
@@ -13964,7 +14070,11 @@ function _isNativeReflectConstruct() {
13964
14070
  } catch (e) {
13965
14071
  return false;
13966
14072
  }
13967
- }
14073
+ } /**
14074
+ * @flow
14075
+ */
14076
+ /*:: import type { AttributeMap } from './ObjectStateMutations';*/
14077
+ /*:: import type ParseRelation from './ParseRelation';*/
13968
14078
  /**
13969
14079
  * Represents a Role on the Parse server. Roles represent groupings of
13970
14080
  * Users for the purposes of granting permissions (e.g. specifying an ACL
@@ -14128,7 +14238,7 @@ var _ParseCLP = _interopRequireDefault(_dereq_("./ParseCLP"));
14128
14238
  /**
14129
14239
  * @flow
14130
14240
  */
14131
-
14241
+ /*:: import type { PermissionsMap } from './ParseCLP';*/
14132
14242
  var FIELD_TYPES = ['String', 'Number', 'Boolean', 'Date', 'File', 'GeoPoint', 'Polygon', 'Array', 'Object', 'Pointer', 'Relation'];
14133
14243
  /*:: type FieldOptions = {
14134
14244
  required: boolean,
@@ -14669,7 +14779,11 @@ function _isNativeReflectConstruct() {
14669
14779
  } catch (e) {
14670
14780
  return false;
14671
14781
  }
14672
- }
14782
+ } /**
14783
+ * @flow
14784
+ */
14785
+ /*:: import type { AttributeMap } from './ObjectStateMutations';*/
14786
+ /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
14673
14787
  /**
14674
14788
  * <p>A Parse.Session object is a local representation of a revocable session.
14675
14789
  * This class is a subclass of a Parse.Object, and retains the same
@@ -14832,7 +14946,12 @@ function _isNativeReflectConstruct() {
14832
14946
  } catch (e) {
14833
14947
  return false;
14834
14948
  }
14835
- }
14949
+ } /**
14950
+ * @flow
14951
+ */
14952
+ /*:: import type { AttributeMap } from './ObjectStateMutations';*/
14953
+ /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
14954
+ /*:: export type AuthData = ?{ [key: string]: mixed };*/
14836
14955
  var CURRENT_USER_KEY = 'currentUser';
14837
14956
  var canUseCurrentUser = !_CoreManager.default.get('IS_NODE');
14838
14957
  var currentUserCacheMatchesDisk = false;
@@ -15658,6 +15777,27 @@ var ParseUser = /*#__PURE__*/function (_ParseObject) {
15658
15777
  return user.logIn(options);
15659
15778
  }
15660
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
+
15661
15801
  /**
15662
15802
  * Logs in a user with a session token. On success, this saves the session
15663
15803
  * to disk, so you can retrieve the currently logged in user using
@@ -16102,6 +16242,21 @@ var DefaultController = {
16102
16242
  return DefaultController.setCurrentUser(user);
16103
16243
  });
16104
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
+ },
16105
16260
  become: function (user /*: ParseUser*/, options /*: RequestOptions*/) /*: Promise<ParseUser>*/{
16106
16261
  var RESTController = _CoreManager.default.getRESTController();
16107
16262
  return RESTController.request('GET', 'users/me', {}, options).then(function (response) {
@@ -16245,7 +16400,14 @@ var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
16245
16400
  /**
16246
16401
  * @flow
16247
16402
  */
16248
-
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
+ };*/
16249
16411
  /**
16250
16412
  * Contains functions to deal with Push in Parse.
16251
16413
  *
@@ -16253,7 +16415,6 @@ var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
16253
16415
  * @static
16254
16416
  * @hideconstructor
16255
16417
  */
16256
-
16257
16418
  /**
16258
16419
  * Sends a push notification.
16259
16420
  * **Available in Cloud Code only.**
@@ -16384,6 +16545,26 @@ function _objectSpread(target) {
16384
16545
  */
16385
16546
  /* global XMLHttpRequest, XDomainRequest */
16386
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
+ };*/
16387
16568
  var XHR = null;
16388
16569
  if (typeof XMLHttpRequest !== 'undefined') {
16389
16570
  XHR = XMLHttpRequest;
@@ -16730,7 +16911,12 @@ function _interopRequireWildcard(obj, nodeInterop) {
16730
16911
  /**
16731
16912
  * @flow
16732
16913
  */
16733
-
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
+ };*/
16734
16920
  var objectState
16735
16921
  /*: {
16736
16922
  [className: string]: {
@@ -17013,6 +17199,10 @@ var _promiseUtils = _dereq_("./promiseUtils");
17013
17199
  /**
17014
17200
  * @flow
17015
17201
  */
17202
+ /*:: type Task = {
17203
+ task: () => Promise,
17204
+ _completion: Promise,
17205
+ };*/
17016
17206
  var TaskQueue = /*#__PURE__*/function () {
17017
17207
  function TaskQueue() {
17018
17208
  (0, _classCallCheck2.default)(this, TaskQueue);
@@ -17131,7 +17321,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
17131
17321
  /**
17132
17322
  * @flow
17133
17323
  */
17134
-
17324
+ /*:: import type { Op } from './ParseOp';*/
17325
+ /*:: import type ParseObject from './ParseObject';*/
17326
+ /*:: import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';*/
17135
17327
  var objectState = new _weakMap.default();
17136
17328
  function getState(obj /*: ParseObject*/) /*: ?State*/{
17137
17329
  var classData = objectState.get(obj);
@@ -17850,7 +18042,10 @@ var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
17850
18042
  /**
17851
18043
  * @flow
17852
18044
  */
17853
-
18045
+ /*:: type EncounterMap = {
18046
+ objects: { [identifier: string]: ParseObject | boolean },
18047
+ files: Array<ParseFile>,
18048
+ };*/
17854
18049
  /**
17855
18050
  * Return an array of unsaved children, which are either Parse Objects or Files.
17856
18051
  * If it encounters any dirty Objects without Ids, it will throw an exception.