parse 4.1.0 → 4.2.0-alpha.2

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 (88) hide show
  1. package/dist/parse.js +1594 -1142
  2. package/dist/parse.min.js +2 -2
  3. package/dist/parse.weapp.js +1577 -1125
  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/EventEmitter.js +1 -1
  57. package/lib/react-native/LiveQueryClient.js +7 -3
  58. package/lib/react-native/ParseCLP.js +2 -2
  59. package/lib/react-native/ParseFile.js +1 -0
  60. package/lib/react-native/ParseQuery.js +34 -11
  61. package/lib/react-native/ParseUser.js +25 -0
  62. package/lib/weapp/AnonymousUtils.js +1 -1
  63. package/lib/weapp/Cloud.js +1 -2
  64. package/lib/weapp/CoreManager.js +1 -1
  65. package/lib/weapp/EventuallyQueue.js +13 -1
  66. package/lib/weapp/LiveQueryClient.js +8 -4
  67. package/lib/weapp/LocalDatastore.js +3 -1
  68. package/lib/weapp/LocalDatastoreController.js +3 -1
  69. package/lib/weapp/ObjectStateMutations.js +14 -1
  70. package/lib/weapp/ParseACL.js +2 -1
  71. package/lib/weapp/ParseCLP.js +6 -1
  72. package/lib/weapp/ParseConfig.js +1 -0
  73. package/lib/weapp/ParseFile.js +5 -1
  74. package/lib/weapp/ParseInstallation.js +4 -1
  75. package/lib/weapp/ParseObject.js +10 -7
  76. package/lib/weapp/ParseOp.js +3 -1
  77. package/lib/weapp/ParseQuery.js +79 -24
  78. package/lib/weapp/ParseRole.js +5 -1
  79. package/lib/weapp/ParseSchema.js +1 -1
  80. package/lib/weapp/ParseSession.js +5 -1
  81. package/lib/weapp/ParseUser.js +42 -1
  82. package/lib/weapp/Push.js +8 -2
  83. package/lib/weapp/RESTController.js +20 -0
  84. package/lib/weapp/SingleInstanceStateController.js +6 -1
  85. package/lib/weapp/TaskQueue.js +4 -0
  86. package/lib/weapp/UniqueInstanceStateController.js +3 -1
  87. package/lib/weapp/unsavedChildren.js +4 -1
  88. package/package.json +20 -20
@@ -10,7 +10,7 @@ var _ParseUser = _interopRequireDefault(require("./ParseUser"));
10
10
  /**
11
11
  * @flow-weak
12
12
  */
13
-
13
+ /*:: import type { RequestOptions } from './RESTController';*/
14
14
  var uuidv4 = require('./uuid');
15
15
  var registered = false;
16
16
 
@@ -21,7 +21,7 @@ var _ParseObject = _interopRequireDefault(require("./ParseObject"));
21
21
  /**
22
22
  * @flow
23
23
  */
24
-
24
+ /*:: import type { RequestOptions } from './RESTController';*/
25
25
  /**
26
26
  * Contains functions for calling and declaring
27
27
  * <a href="/docs/cloud_code_guide#functions">cloud functions</a>.
@@ -33,7 +33,6 @@ var _ParseObject = _interopRequireDefault(require("./ParseObject"));
33
33
  * @static
34
34
  * @hideconstructor
35
35
  */
36
-
37
36
  /**
38
37
  * Makes a call to a cloud function.
39
38
  *
@@ -182,7 +182,7 @@ var config /*: Config & { [key: string]: mixed }*/ = {
182
182
  SERVER_AUTH_TOKEN: null,
183
183
  LIVEQUERY_SERVER_URL: null,
184
184
  ENCRYPTED_KEY: null,
185
- VERSION: 'js' + "4.1.0",
185
+ VERSION: 'js' + "4.2.0-alpha.2",
186
186
  APPLICATION_ID: null,
187
187
  JAVASCRIPT_KEY: null,
188
188
  MASTER_KEY: null,
@@ -18,7 +18,19 @@ var _Storage = _interopRequireDefault(require("./Storage"));
18
18
  *
19
19
  * @flow
20
20
  */
21
-
21
+ /*:: import type { SaveOptions } from './ParseObject';*/
22
+ /*:: import type { RequestOptions } from './RESTController';*/
23
+ /*:: type QueueObject = {
24
+ queueId: string,
25
+ action: string,
26
+ object: ParseObject,
27
+ serverOptions: SaveOptions | RequestOptions,
28
+ id: string,
29
+ className: string,
30
+ hash: string,
31
+ createdAt: Date,
32
+ };*/
33
+ /*:: type Queue = Array<QueueObject>;*/
22
34
  var QUEUE_KEY = 'Parse/Eventually/Queue';
23
35
  var queueCache = [];
24
36
  var dirtyCache = true;
@@ -123,7 +123,7 @@ function _isNativeReflectConstruct() {
123
123
  } catch (e) {
124
124
  return false;
125
125
  }
126
- }
126
+ } /* global WebSocket */
127
127
  // The LiveQuery client inner state
128
128
  var CLIENT_STATE = {
129
129
  INITIALIZED: 'initialized',
@@ -303,21 +303,25 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
303
303
  }, {
304
304
  key: "subscribe",
305
305
  value: function (query /*: Object*/, sessionToken /*: ?string*/) /*: LiveQuerySubscription*/{
306
- var _this2 = this;
306
+ var _queryJSON$keys,
307
+ _queryJSON$watch,
308
+ _this2 = this;
307
309
  if (!query) {
308
310
  return;
309
311
  }
310
312
  var className = query.className;
311
313
  var queryJSON = query.toJSON();
312
314
  var where = queryJSON.where;
313
- var fields = (0, _keys.default)(queryJSON) ? (0, _keys.default)(queryJSON).split(',') : undefined;
315
+ var fields = (_queryJSON$keys = (0, _keys.default)(queryJSON)) === null || _queryJSON$keys === void 0 ? void 0 : _queryJSON$keys.split(',');
316
+ var watch = (_queryJSON$watch = queryJSON.watch) === null || _queryJSON$watch === void 0 ? void 0 : _queryJSON$watch.split(',');
314
317
  var subscribeRequest = {
315
318
  op: OP_TYPES.SUBSCRIBE,
316
319
  requestId: this.requestId,
317
320
  query: {
318
321
  className: className,
319
322
  where: where,
320
- fields: fields
323
+ fields: fields,
324
+ watch: watch
321
325
  }
322
326
  };
323
327
  if (sessionToken) {
@@ -89,7 +89,9 @@ function _arrayLikeToArray(arr, len) {
89
89
  if (len == null || len > arr.length) len = arr.length;
90
90
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
91
91
  return arr2;
92
- }
92
+ } /**
93
+ * @flow
94
+ */ /*:: import type ParseObject from './ParseObject';*/
93
95
  /**
94
96
  * Provides a local datastore which can be used to store and retrieve <code>Parse.Object</code>. <br />
95
97
  * To enable this functionality, call <code>Parse.enableLocalDatastore()</code>.
@@ -78,7 +78,9 @@ function _arrayLikeToArray(arr, len) {
78
78
  if (len == null || len > arr.length) len = arr.length;
79
79
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
80
80
  return arr2;
81
- }
81
+ } /**
82
+ * @flow
83
+ */
82
84
  var LocalDatastoreController = {
83
85
  fromPinWithName: function (name /*: string*/) /*: Array<Object>*/{
84
86
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
@@ -52,7 +52,20 @@ function _objectSpread(target) {
52
52
  });
53
53
  }
54
54
  return target;
55
- }
55
+ } /**
56
+ * @flow
57
+ */
58
+ /*:: import type { Op } from './ParseOp';*/
59
+ /*:: export type AttributeMap = { [attr: string]: any };*/
60
+ /*:: export type OpsMap = { [attr: string]: Op };*/
61
+ /*:: export type ObjectCache = { [attr: string]: string };*/
62
+ /*:: export type State = {
63
+ serverData: AttributeMap,
64
+ pendingOps: Array<OpsMap>,
65
+ objectCache: ObjectCache,
66
+ tasks: TaskQueue,
67
+ existed: boolean,
68
+ };*/
56
69
  function defaultState() /*: State*/{
57
70
  return {
58
71
  serverData: {},
@@ -16,7 +16,8 @@ var _ParseUser = _interopRequireDefault(require("./ParseUser"));
16
16
  /**
17
17
  * @flow
18
18
  */
19
-
19
+ /*:: type PermissionsMap = { [permission: string]: boolean };*/
20
+ /*:: type ByIdMap = { [userId: string]: PermissionsMap };*/
20
21
  var PUBLIC_KEY = '*';
21
22
 
22
23
  /**
@@ -119,7 +119,12 @@ function _arrayLikeToArray(arr, len) {
119
119
  if (len == null || len > arr.length) len = arr.length;
120
120
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
121
121
  return arr2;
122
- }
122
+ } /**
123
+ * @flow
124
+ */
125
+ /*:: type Entity = Entity;*/
126
+ /*:: type UsersMap = { [userId: string]: boolean | any };*/
127
+ /*:: export type PermissionsMap = { [permission: string]: UsersMap };*/
123
128
  var PUBLIC_KEY = '*';
124
129
  var VALID_PERMISSIONS /*: Map<string, UsersMap>*/ = new _map.default(
125
130
  /*:: <string, UsersMap>*/
@@ -21,6 +21,7 @@ var _Storage = _interopRequireDefault(require("./Storage"));
21
21
  /**
22
22
  * @flow
23
23
  */
24
+ /*:: import type { RequestOptions } from './RESTController';*/
24
25
  /**
25
26
  * Parse.Config is a local representation of configuration data that
26
27
  * can be set from the Parse dashboard.
@@ -48,7 +48,10 @@ function _objectSpread(target) {
48
48
  });
49
49
  }
50
50
  return target;
51
- }
51
+ } /**
52
+ * @flow
53
+ */ /* global XMLHttpRequest, Blob */
54
+ /*:: import type { FullOptions } from './RESTController';*/
52
55
  var ParseError = require('./ParseError').default;
53
56
  var XHR = null;
54
57
  if (typeof XMLHttpRequest !== 'undefined') {
@@ -369,6 +372,7 @@ var ParseFile = /*#__PURE__*/function () {
369
372
  key: "cancel",
370
373
  value: function () {
371
374
  if (this._requestTask && typeof this._requestTask.abort === 'function') {
375
+ this._requestTask._aborted = true;
372
376
  this._requestTask.abort();
373
377
  }
374
378
  this._requestTask = null;
@@ -38,7 +38,10 @@ function _isNativeReflectConstruct() {
38
38
  } catch (e) {
39
39
  return false;
40
40
  }
41
- }
41
+ } /**
42
+ * @flow
43
+ */
44
+ /*:: import type { AttributeMap } from './ObjectStateMutations';*/
42
45
  var Installation = /*#__PURE__*/function (_ParseObject) {
43
46
  (0, _inherits2.default)(Installation, _ParseObject);
44
47
  var _super = _createSuper(Installation);
@@ -184,7 +184,11 @@ function _objectSpread(target) {
184
184
  });
185
185
  }
186
186
  return target;
187
- }
187
+ } /**
188
+ * @flow
189
+ */
190
+ /*:: import type { AttributeMap, OpsMap } from './ObjectStateMutations';*/
191
+ /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
188
192
  var uuidv4 = require('./uuid');
189
193
  /*:: export type Pointer = {
190
194
  __type: string,
@@ -250,6 +254,11 @@ var ParseObject = /*#__PURE__*/function () {
250
254
  */
251
255
  function ParseObject(className /*: ?string | { className: string, [attr: string]: mixed }*/, attributes /*:: ?: { [attr: string]: mixed }*/, options /*:: ?: { ignoreValidation: boolean }*/) {
252
256
  (0, _classCallCheck2.default)(this, ParseObject);
257
+ /**
258
+ * The ID of this object, unique within its class.
259
+ *
260
+ * @property {string} id
261
+ */
253
262
  (0, _defineProperty2.default)(this, "id", void 0);
254
263
  (0, _defineProperty2.default)(this, "_localId", void 0);
255
264
  (0, _defineProperty2.default)(this, "_objCount", void 0);
@@ -281,12 +290,6 @@ var ParseObject = /*#__PURE__*/function () {
281
290
  throw new Error("Can't create an invalid Parse Object");
282
291
  }
283
292
  }
284
-
285
- /**
286
- * The ID of this object, unique within its class.
287
- *
288
- * @property {string} id
289
- */
290
293
  (0, _createClass2.default)(ParseObject, [{
291
294
  key: "attributes",
292
295
  get: /* Prototype getters / setters */
@@ -51,7 +51,9 @@ function _isNativeReflectConstruct() {
51
51
  } catch (e) {
52
52
  return false;
53
53
  }
54
- }
54
+ } /**
55
+ * @flow
56
+ */
55
57
  function opFromJSON(json /*: { [key: string]: any }*/) /*: ?Op*/{
56
58
  if (!json || !json.__op) {
57
59
  return null;
@@ -40,7 +40,29 @@ var _LocalDatastoreUtils = require("./LocalDatastoreUtils");
40
40
  /*
41
41
  * @flow
42
42
  */
43
-
43
+ /*:: import type LiveQuerySubscription from './LiveQuerySubscription';*/
44
+ /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
45
+ /*:: type BatchOptions = FullOptions & { batchSize?: number };*/
46
+ /*:: export type WhereClause = {
47
+ [attr: string]: mixed,
48
+ };*/
49
+ /*:: export type QueryJSON = {
50
+ where: WhereClause,
51
+ watch?: string,
52
+ include?: string,
53
+ excludeKeys?: string,
54
+ keys?: string,
55
+ limit?: number,
56
+ skip?: number,
57
+ order?: string,
58
+ className?: string,
59
+ count?: number,
60
+ hint?: mixed,
61
+ explain?: boolean,
62
+ readPreference?: string,
63
+ includeReadPreference?: string,
64
+ subqueryReadPreference?: string,
65
+ };*/
44
66
  /**
45
67
  * Converts a string into a regex that matches it.
46
68
  * Surrounding with \Q .. \E does this, we just need to escape any \E's in
@@ -215,17 +237,17 @@ function handleOfflineSort(a, b, sorts) {
215
237
  * @alias Parse.Query
216
238
  */
217
239
  var ParseQuery = /*#__PURE__*/function () {
218
- /**
219
- * @property {string} className
220
- */
221
-
222
240
  /**
223
241
  * @param {(string | Parse.Object)} objectClass An instance of a subclass of Parse.Object, or a Parse className string.
224
242
  */
225
243
  function ParseQuery(objectClass /*: string | ParseObject*/) {
226
244
  (0, _classCallCheck2.default)(this, ParseQuery);
245
+ /**
246
+ * @property {string} className
247
+ */
227
248
  (0, _defineProperty2.default)(this, "className", void 0);
228
249
  (0, _defineProperty2.default)(this, "_where", void 0);
250
+ (0, _defineProperty2.default)(this, "_watch", void 0);
229
251
  (0, _defineProperty2.default)(this, "_include", void 0);
230
252
  (0, _defineProperty2.default)(this, "_exclude", void 0);
231
253
  (0, _defineProperty2.default)(this, "_select", void 0);
@@ -261,6 +283,7 @@ var ParseQuery = /*#__PURE__*/function () {
261
283
  throw new TypeError('A ParseQuery must be constructed with a ParseObject or class name.');
262
284
  }
263
285
  this._where = {};
286
+ this._watch = [];
264
287
  this._include = [];
265
288
  this._exclude = [];
266
289
  this._count = false;
@@ -453,6 +476,9 @@ var ParseQuery = /*#__PURE__*/function () {
453
476
  var params /*: QueryJSON*/ = {
454
477
  where: this._where
455
478
  };
479
+ if (this._watch.length) {
480
+ params.watch = this._watch.join(',');
481
+ }
456
482
  if (this._include.length) {
457
483
  params.include = this._include.join(',');
458
484
  }
@@ -522,6 +548,9 @@ var ParseQuery = /*#__PURE__*/function () {
522
548
  if (json.where) {
523
549
  this._where = json.where;
524
550
  }
551
+ if (json.watch) {
552
+ this._watch = json.watch.split(',');
553
+ }
525
554
  if (json.include) {
526
555
  this._include = json.include.split(',');
527
556
  }
@@ -2111,6 +2140,32 @@ var ParseQuery = /*#__PURE__*/function () {
2111
2140
  return this;
2112
2141
  }
2113
2142
 
2143
+ /**
2144
+ * Restricts live query to trigger only for watched fields.
2145
+ *
2146
+ * Requires Parse Server 6.0.0+
2147
+ *
2148
+ * @param {...string|Array<string>} keys The name(s) of the key(s) to watch.
2149
+ * @returns {Parse.Query} Returns the query, so you can chain this call.
2150
+ */
2151
+ }, {
2152
+ key: "watch",
2153
+ value: function () /*: ParseQuery*/{
2154
+ var _this14 = this;
2155
+ for (var _len8 = arguments.length, keys = new Array(_len8), _key12 = 0; _key12 < _len8; _key12++) {
2156
+ keys[_key12] = arguments[_key12];
2157
+ }
2158
+ (0, _forEach.default)(keys).call(keys, function (key) {
2159
+ if ((0, _isArray.default)(key)) {
2160
+ var _context22;
2161
+ _this14._watch = (0, _concat.default)(_context22 = _this14._watch).call(_context22, key);
2162
+ } else {
2163
+ _this14._watch.push(key);
2164
+ }
2165
+ });
2166
+ return this;
2167
+ }
2168
+
2114
2169
  /**
2115
2170
  * Changes the read preference that the backend will use when performing the query to the database.
2116
2171
  *
@@ -2140,30 +2195,30 @@ var ParseQuery = /*#__PURE__*/function () {
2140
2195
  value: function () {
2141
2196
  var _subscribe = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(sessionToken /*:: ?: string*/) {
2142
2197
  var currentUser, liveQueryClient, subscription;
2143
- return _regenerator.default.wrap(function (_context22) {
2144
- while (1) switch (_context22.prev = _context22.next) {
2198
+ return _regenerator.default.wrap(function (_context23) {
2199
+ while (1) switch (_context23.prev = _context23.next) {
2145
2200
  case 0:
2146
- _context22.next = 2;
2201
+ _context23.next = 2;
2147
2202
  return _CoreManager.default.getUserController().currentUserAsync();
2148
2203
  case 2:
2149
- currentUser = _context22.sent;
2204
+ currentUser = _context23.sent;
2150
2205
  if (!sessionToken) {
2151
2206
  sessionToken = currentUser ? currentUser.getSessionToken() : undefined;
2152
2207
  }
2153
- _context22.next = 6;
2208
+ _context23.next = 6;
2154
2209
  return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
2155
2210
  case 6:
2156
- liveQueryClient = _context22.sent;
2211
+ liveQueryClient = _context23.sent;
2157
2212
  if (liveQueryClient.shouldOpen()) {
2158
2213
  liveQueryClient.open();
2159
2214
  }
2160
2215
  subscription = liveQueryClient.subscribe(this, sessionToken);
2161
- return _context22.abrupt("return", subscription.subscribePromise.then(function () {
2216
+ return _context23.abrupt("return", subscription.subscribePromise.then(function () {
2162
2217
  return subscription;
2163
2218
  }));
2164
2219
  case 10:
2165
2220
  case "end":
2166
- return _context22.stop();
2221
+ return _context23.stop();
2167
2222
  }
2168
2223
  }, _callee7, this);
2169
2224
  }));
@@ -2245,7 +2300,7 @@ var ParseQuery = /*#__PURE__*/function () {
2245
2300
  }, {
2246
2301
  key: "cancel",
2247
2302
  value: function () /*: ParseQuery*/{
2248
- var _this14 = this;
2303
+ var _this15 = this;
2249
2304
  if (this._xhrRequest.task && typeof this._xhrRequest.task.abort === 'function') {
2250
2305
  this._xhrRequest.task._aborted = true;
2251
2306
  this._xhrRequest.task.abort();
@@ -2254,16 +2309,16 @@ var ParseQuery = /*#__PURE__*/function () {
2254
2309
  return this;
2255
2310
  }
2256
2311
  return this._xhrRequest.onchange = function () {
2257
- return _this14.cancel();
2312
+ return _this15.cancel();
2258
2313
  };
2259
2314
  }
2260
2315
  }, {
2261
2316
  key: "_setRequestTask",
2262
2317
  value: function (options) {
2263
- var _this15 = this;
2318
+ var _this16 = this;
2264
2319
  options.requestTask = function (task) {
2265
- _this15._xhrRequest.task = task;
2266
- _this15._xhrRequest.onchange();
2320
+ _this16._xhrRequest.task = task;
2321
+ _this16._xhrRequest.onchange();
2267
2322
  };
2268
2323
  }
2269
2324
  }], [{
@@ -2275,8 +2330,8 @@ var ParseQuery = /*#__PURE__*/function () {
2275
2330
  }, {
2276
2331
  key: "or",
2277
2332
  value: function () /*: ParseQuery*/{
2278
- for (var _len8 = arguments.length, queries = new Array(_len8), _key12 = 0; _key12 < _len8; _key12++) {
2279
- queries[_key12] = arguments[_key12];
2333
+ for (var _len9 = arguments.length, queries = new Array(_len9), _key13 = 0; _key13 < _len9; _key13++) {
2334
+ queries[_key13] = arguments[_key13];
2280
2335
  }
2281
2336
  var className = _getClassNameFromQueries(queries);
2282
2337
  var query = new ParseQuery(className);
@@ -2299,8 +2354,8 @@ var ParseQuery = /*#__PURE__*/function () {
2299
2354
  }, {
2300
2355
  key: "and",
2301
2356
  value: function () /*: ParseQuery*/{
2302
- for (var _len9 = arguments.length, queries = new Array(_len9), _key13 = 0; _key13 < _len9; _key13++) {
2303
- queries[_key13] = arguments[_key13];
2357
+ for (var _len10 = arguments.length, queries = new Array(_len10), _key14 = 0; _key14 < _len10; _key14++) {
2358
+ queries[_key14] = arguments[_key14];
2304
2359
  }
2305
2360
  var className = _getClassNameFromQueries(queries);
2306
2361
  var query = new ParseQuery(className);
@@ -2323,8 +2378,8 @@ var ParseQuery = /*#__PURE__*/function () {
2323
2378
  }, {
2324
2379
  key: "nor",
2325
2380
  value: function () /*: ParseQuery*/{
2326
- for (var _len10 = arguments.length, queries = new Array(_len10), _key14 = 0; _key14 < _len10; _key14++) {
2327
- queries[_key14] = arguments[_key14];
2381
+ for (var _len11 = arguments.length, queries = new Array(_len11), _key15 = 0; _key15 < _len11; _key15++) {
2382
+ queries[_key15] = arguments[_key15];
2328
2383
  }
2329
2384
  var className = _getClassNameFromQueries(queries);
2330
2385
  var query = new ParseQuery(className);
@@ -40,7 +40,11 @@ function _isNativeReflectConstruct() {
40
40
  } catch (e) {
41
41
  return false;
42
42
  }
43
- }
43
+ } /**
44
+ * @flow
45
+ */
46
+ /*:: import type { AttributeMap } from './ObjectStateMutations';*/
47
+ /*:: import type ParseRelation from './ParseRelation';*/
44
48
  /**
45
49
  * Represents a Role on the Parse server. Roles represent groupings of
46
50
  * Users for the purposes of granting permissions (e.g. specifying an ACL
@@ -16,7 +16,7 @@ var _ParseCLP = _interopRequireDefault(require("./ParseCLP"));
16
16
  /**
17
17
  * @flow
18
18
  */
19
-
19
+ /*:: import type { PermissionsMap } from './ParseCLP';*/
20
20
  var FIELD_TYPES = ['String', 'Number', 'Boolean', 'Date', 'File', 'GeoPoint', 'Polygon', 'Array', 'Object', 'Pointer', 'Relation'];
21
21
  /*:: type FieldOptions = {
22
22
  required: boolean,
@@ -42,7 +42,11 @@ function _isNativeReflectConstruct() {
42
42
  } catch (e) {
43
43
  return false;
44
44
  }
45
- }
45
+ } /**
46
+ * @flow
47
+ */
48
+ /*:: import type { AttributeMap } from './ObjectStateMutations';*/
49
+ /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
46
50
  /**
47
51
  * <p>A Parse.Session object is a local representation of a revocable session.
48
52
  * This class is a subclass of a Parse.Object, and retains the same
@@ -49,7 +49,12 @@ function _isNativeReflectConstruct() {
49
49
  } catch (e) {
50
50
  return false;
51
51
  }
52
- }
52
+ } /**
53
+ * @flow
54
+ */
55
+ /*:: import type { AttributeMap } from './ObjectStateMutations';*/
56
+ /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
57
+ /*:: export type AuthData = ?{ [key: string]: mixed };*/
53
58
  var CURRENT_USER_KEY = 'currentUser';
54
59
  var canUseCurrentUser = !_CoreManager.default.get('IS_NODE');
55
60
  var currentUserCacheMatchesDisk = false;
@@ -875,6 +880,27 @@ var ParseUser = /*#__PURE__*/function (_ParseObject) {
875
880
  return user.logIn(options);
876
881
  }
877
882
 
883
+ /**
884
+ * Logs in a user with an objectId. On success, this saves the session
885
+ * to disk, so you can retrieve the currently logged in user using
886
+ * <code>current</code>.
887
+ *
888
+ * @param {string} userId The objectId for the user.
889
+ * @static
890
+ * @returns {Promise} A promise that is fulfilled with the user when
891
+ * the login completes.
892
+ */
893
+ }, {
894
+ key: "loginAs",
895
+ value: function (userId /*: string*/) {
896
+ if (!userId) {
897
+ throw new _ParseError.default(_ParseError.default.USERNAME_MISSING, 'Cannot log in as user with an empty user id');
898
+ }
899
+ var controller = _CoreManager.default.getUserController();
900
+ var user = new this();
901
+ return controller.loginAs(user, userId);
902
+ }
903
+
878
904
  /**
879
905
  * Logs in a user with a session token. On success, this saves the session
880
906
  * to disk, so you can retrieve the currently logged in user using
@@ -1319,6 +1345,21 @@ var DefaultController = {
1319
1345
  return DefaultController.setCurrentUser(user);
1320
1346
  });
1321
1347
  },
1348
+ loginAs: function (user /*: ParseUser*/, userId /*: string*/) /*: Promise<ParseUser>*/{
1349
+ var RESTController = _CoreManager.default.getRESTController();
1350
+ return RESTController.request('POST', 'loginAs', {
1351
+ userId: userId
1352
+ }, {
1353
+ useMasterKey: true
1354
+ }).then(function (response) {
1355
+ user._finishFetch(response);
1356
+ user._setExisted(true);
1357
+ if (!canUseCurrentUser) {
1358
+ return _promise.default.resolve(user);
1359
+ }
1360
+ return DefaultController.setCurrentUser(user);
1361
+ });
1362
+ },
1322
1363
  become: function (user /*: ParseUser*/, options /*: RequestOptions*/) /*: Promise<ParseUser>*/{
1323
1364
  var RESTController = _CoreManager.default.getRESTController();
1324
1365
  return RESTController.request('GET', 'users/me', {}, options).then(function (response) {
@@ -13,7 +13,14 @@ var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
13
13
  /**
14
14
  * @flow
15
15
  */
16
-
16
+ /*:: import type { WhereClause } from './ParseQuery';*/
17
+ /*:: import type { FullOptions } from './RESTController';*/
18
+ /*:: export type PushData = {
19
+ where?: WhereClause | ParseQuery,
20
+ push_time?: Date | string,
21
+ expiration_time?: Date | string,
22
+ expiration_interval?: number,
23
+ };*/
17
24
  /**
18
25
  * Contains functions to deal with Push in Parse.
19
26
  *
@@ -21,7 +28,6 @@ var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
21
28
  * @static
22
29
  * @hideconstructor
23
30
  */
24
-
25
31
  /**
26
32
  * Sends a push notification.
27
33
  * **Available in Cloud Code only.**
@@ -45,6 +45,26 @@ function _objectSpread(target) {
45
45
  */
46
46
  /* global XMLHttpRequest, XDomainRequest */
47
47
  var uuidv4 = require('./uuid');
48
+ /*:: export type RequestOptions = {
49
+ useMasterKey?: boolean,
50
+ sessionToken?: string,
51
+ installationId?: string,
52
+ returnStatus?: boolean,
53
+ batchSize?: number,
54
+ include?: any,
55
+ progress?: any,
56
+ context?: any,
57
+ usePost?: boolean,
58
+ };*/
59
+ /*:: export type FullOptions = {
60
+ success?: any,
61
+ error?: any,
62
+ useMasterKey?: boolean,
63
+ sessionToken?: string,
64
+ installationId?: string,
65
+ progress?: any,
66
+ usePost?: boolean,
67
+ };*/
48
68
  var XHR = null;
49
69
  if (typeof XMLHttpRequest !== 'undefined') {
50
70
  XHR = XMLHttpRequest;
@@ -66,7 +66,12 @@ function _interopRequireWildcard(obj, nodeInterop) {
66
66
  /**
67
67
  * @flow
68
68
  */
69
-
69
+ /*:: import type { Op } from './ParseOp';*/
70
+ /*:: import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';*/
71
+ /*:: type ObjectIdentifier = {
72
+ className: string,
73
+ id: string,
74
+ };*/
70
75
  var objectState
71
76
  /*: {
72
77
  [className: string]: {
@@ -8,6 +8,10 @@ var _promiseUtils = require("./promiseUtils");
8
8
  /**
9
9
  * @flow
10
10
  */
11
+ /*:: type Task = {
12
+ task: () => Promise,
13
+ _completion: Promise,
14
+ };*/
11
15
  var TaskQueue = /*#__PURE__*/function () {
12
16
  function TaskQueue() {
13
17
  (0, _classCallCheck2.default)(this, TaskQueue);
@@ -69,7 +69,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
69
69
  /**
70
70
  * @flow
71
71
  */
72
-
72
+ /*:: import type { Op } from './ParseOp';*/
73
+ /*:: import type ParseObject from './ParseObject';*/
74
+ /*:: import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';*/
73
75
  var objectState = new _weakMap.default();
74
76
  function getState(obj /*: ParseObject*/) /*: ?State*/{
75
77
  var classData = objectState.get(obj);