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
@@ -17,7 +17,10 @@ var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
17
17
  /**
18
18
  * @flow
19
19
  */
20
-
20
+ /*:: type EncounterMap = {
21
+ objects: { [identifier: string]: ParseObject | boolean },
22
+ files: Array<ParseFile>,
23
+ };*/
21
24
  /**
22
25
  * Return an array of unsaved children, which are either Parse Objects or Files.
23
26
  * If it encounters any dirty Objects without Ids, it will throw an exception.
@@ -13,7 +13,7 @@ function _interopRequireDefault(obj) {
13
13
  /**
14
14
  * @flow-weak
15
15
  */
16
-
16
+ /*:: import type { RequestOptions } from './RESTController';*/
17
17
  const uuidv4 = require('./uuid');
18
18
  let registered = false;
19
19
 
package/lib/node/Cloud.js CHANGED
@@ -21,7 +21,7 @@ function _interopRequireDefault(obj) {
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 @@ function _interopRequireDefault(obj) {
33
33
  * @static
34
34
  * @hideconstructor
35
35
  */
36
-
37
36
  /**
38
37
  * Makes a call to a cloud function.
39
38
  *
@@ -179,7 +179,7 @@ const config /*: Config & { [key: string]: mixed }*/ = {
179
179
  SERVER_AUTH_TOKEN: null,
180
180
  LIVEQUERY_SERVER_URL: null,
181
181
  ENCRYPTED_KEY: null,
182
- VERSION: 'js' + "4.1.0-alpha.2",
182
+ VERSION: 'js' + "4.1.0-alpha.4",
183
183
  APPLICATION_ID: null,
184
184
  JAVASCRIPT_KEY: null,
185
185
  MASTER_KEY: null,
@@ -14,7 +14,19 @@ function _interopRequireDefault(obj) {
14
14
  *
15
15
  * @flow
16
16
  */
17
-
17
+ /*:: import type { SaveOptions } from './ParseObject';*/
18
+ /*:: import type { RequestOptions } from './RESTController';*/
19
+ /*:: type QueueObject = {
20
+ queueId: string,
21
+ action: string,
22
+ object: ParseObject,
23
+ serverOptions: SaveOptions | RequestOptions,
24
+ id: string,
25
+ className: string,
26
+ hash: string,
27
+ createdAt: Date,
28
+ };*/
29
+ /*:: type Queue = Array<QueueObject>;*/
18
30
  const QUEUE_KEY = 'Parse/Eventually/Queue';
19
31
  let queueCache = [];
20
32
  let dirtyCache = true;
@@ -188,20 +188,23 @@ class LiveQueryClient extends _EventEmitter.default {
188
188
  * @returns {LiveQuerySubscription | undefined}
189
189
  */
190
190
  subscribe(query /*: Object*/, sessionToken /*: ?string*/) /*: LiveQuerySubscription*/{
191
+ var _queryJSON$keys, _queryJSON$watch;
191
192
  if (!query) {
192
193
  return;
193
194
  }
194
195
  const className = query.className;
195
196
  const queryJSON = query.toJSON();
196
197
  const where = queryJSON.where;
197
- const fields = queryJSON.keys ? queryJSON.keys.split(',') : undefined;
198
+ const fields = (_queryJSON$keys = queryJSON.keys) === null || _queryJSON$keys === void 0 ? void 0 : _queryJSON$keys.split(',');
199
+ const watch = (_queryJSON$watch = queryJSON.watch) === null || _queryJSON$watch === void 0 ? void 0 : _queryJSON$watch.split(',');
198
200
  const subscribeRequest = {
199
201
  op: OP_TYPES.SUBSCRIBE,
200
202
  requestId: this.requestId,
201
203
  query: {
202
204
  className,
203
205
  where,
204
- fields
206
+ fields,
207
+ watch
205
208
  }
206
209
  };
207
210
  if (sessionToken) {
@@ -11,7 +11,7 @@ function _interopRequireDefault(obj) {
11
11
  /**
12
12
  * @flow
13
13
  */
14
-
14
+ /*:: import type ParseObject from './ParseObject';*/
15
15
  /**
16
16
  * Provides a local datastore which can be used to store and retrieve <code>Parse.Object</code>. <br />
17
17
  * To enable this functionality, call <code>Parse.enableLocalDatastore()</code>.
@@ -26,7 +26,17 @@ function _interopRequireDefault(obj) {
26
26
  /**
27
27
  * @flow
28
28
  */
29
-
29
+ /*:: import type { Op } from './ParseOp';*/
30
+ /*:: export type AttributeMap = { [attr: string]: any };*/
31
+ /*:: export type OpsMap = { [attr: string]: Op };*/
32
+ /*:: export type ObjectCache = { [attr: string]: string };*/
33
+ /*:: export type State = {
34
+ serverData: AttributeMap,
35
+ pendingOps: Array<OpsMap>,
36
+ objectCache: ObjectCache,
37
+ tasks: TaskQueue,
38
+ existed: boolean,
39
+ };*/
30
40
  function defaultState() /*: State*/{
31
41
  return {
32
42
  serverData: {},
@@ -14,7 +14,8 @@ function _interopRequireDefault(obj) {
14
14
  /**
15
15
  * @flow
16
16
  */
17
-
17
+ /*:: type PermissionsMap = { [permission: string]: boolean };*/
18
+ /*:: type ByIdMap = { [userId: string]: PermissionsMap };*/
18
19
  const PUBLIC_KEY = '*';
19
20
 
20
21
  /**
@@ -14,7 +14,9 @@ function _interopRequireDefault(obj) {
14
14
  /**
15
15
  * @flow
16
16
  */
17
-
17
+ /*:: type Entity = Entity;*/
18
+ /*:: type UsersMap = { [userId: string]: boolean | any };*/
19
+ /*:: export type PermissionsMap = { [permission: string]: UsersMap };*/
18
20
  const PUBLIC_KEY = '*';
19
21
  const VALID_PERMISSIONS /*: Map<string, UsersMap>*/ = new Map(
20
22
  /*:: <string, UsersMap>*/
@@ -18,14 +18,13 @@ function _interopRequireDefault(obj) {
18
18
  /**
19
19
  * @flow
20
20
  */
21
-
21
+ /*:: import type { RequestOptions } from './RESTController';*/
22
22
  /**
23
23
  * Parse.Config is a local representation of configuration data that
24
24
  * can be set from the Parse dashboard.
25
25
  *
26
26
  * @alias Parse.Config
27
27
  */
28
-
29
28
  class ParseConfig {
30
29
  /*:: attributes: { [key: string]: any };*/
31
30
  /*:: _escapedAttributes: { [key: string]: any };*/
@@ -14,7 +14,7 @@ function _interopRequireDefault(obj) {
14
14
  * @flow
15
15
  */
16
16
  /* global XMLHttpRequest, Blob */
17
-
17
+ /*:: import type { FullOptions } from './RESTController';*/
18
18
  const ParseError = require('./ParseError').default;
19
19
  let XHR = null;
20
20
  if (typeof XMLHttpRequest !== 'undefined') {
@@ -13,7 +13,7 @@ function _interopRequireDefault(obj) {
13
13
  /**
14
14
  * @flow
15
15
  */
16
-
16
+ /*:: import type { AttributeMap } from './ObjectStateMutations';*/
17
17
  class Installation extends _ParseObject.default {
18
18
  constructor(attributes /*: ?AttributeMap*/) {
19
19
  super('_Installation');
@@ -70,7 +70,8 @@ function _interopRequireDefault(obj) {
70
70
  /**
71
71
  * @flow
72
72
  */
73
-
73
+ /*:: import type { AttributeMap, OpsMap } from './ObjectStateMutations';*/
74
+ /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
74
75
  const uuidv4 = require('./uuid');
75
76
  /*:: export type Pointer = {
76
77
  __type: string,
@@ -20,7 +20,29 @@ function _interopRequireDefault(obj) {
20
20
  /*
21
21
  * @flow
22
22
  */
23
-
23
+ /*:: import type LiveQuerySubscription from './LiveQuerySubscription';*/
24
+ /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
25
+ /*:: type BatchOptions = FullOptions & { batchSize?: number };*/
26
+ /*:: export type WhereClause = {
27
+ [attr: string]: mixed,
28
+ };*/
29
+ /*:: export type QueryJSON = {
30
+ where: WhereClause,
31
+ watch?: string,
32
+ include?: string,
33
+ excludeKeys?: string,
34
+ keys?: string,
35
+ limit?: number,
36
+ skip?: number,
37
+ order?: string,
38
+ className?: string,
39
+ count?: number,
40
+ hint?: mixed,
41
+ explain?: boolean,
42
+ readPreference?: string,
43
+ includeReadPreference?: string,
44
+ subqueryReadPreference?: string,
45
+ };*/
24
46
  /**
25
47
  * Converts a string into a regex that matches it.
26
48
  * Surrounding with \Q .. \E does this, we just need to escape any \E's in
@@ -200,6 +222,7 @@ class ParseQuery {
200
222
  */
201
223
  /*:: className: string;*/
202
224
  /*:: _where: any;*/
225
+ /*:: _watch: Array<string>;*/
203
226
  /*:: _include: Array<string>;*/
204
227
  /*:: _exclude: Array<string>;*/
205
228
  /*:: _select: Array<string>;*/
@@ -239,6 +262,7 @@ class ParseQuery {
239
262
  throw new TypeError('A ParseQuery must be constructed with a ParseObject or class name.');
240
263
  }
241
264
  this._where = {};
265
+ this._watch = [];
242
266
  this._include = [];
243
267
  this._exclude = [];
244
268
  this._count = false;
@@ -391,6 +415,9 @@ class ParseQuery {
391
415
  const params /*: QueryJSON*/ = {
392
416
  where: this._where
393
417
  };
418
+ if (this._watch.length) {
419
+ params.watch = this._watch.join(',');
420
+ }
394
421
  if (this._include.length) {
395
422
  params.include = this._include.join(',');
396
423
  }
@@ -458,6 +485,9 @@ class ParseQuery {
458
485
  if (json.where) {
459
486
  this._where = json.where;
460
487
  }
488
+ if (json.watch) {
489
+ this._watch = json.watch.split(',');
490
+ }
461
491
  if (json.include) {
462
492
  this._include = json.include.split(',');
463
493
  }
@@ -1795,6 +1825,25 @@ class ParseQuery {
1795
1825
  return this;
1796
1826
  }
1797
1827
 
1828
+ /**
1829
+ * Restricts live query to trigger only for watched fields.
1830
+ *
1831
+ * Requires Parse Server 6.0.0+
1832
+ *
1833
+ * @param {...string|Array<string>} keys The name(s) of the key(s) to watch.
1834
+ * @returns {Parse.Query} Returns the query, so you can chain this call.
1835
+ */
1836
+ watch(...keys /*: Array<string | Array<string>>*/) /*: ParseQuery*/{
1837
+ keys.forEach(key => {
1838
+ if (Array.isArray(key)) {
1839
+ this._watch = this._watch.concat(key);
1840
+ } else {
1841
+ this._watch.push(key);
1842
+ }
1843
+ });
1844
+ return this;
1845
+ }
1846
+
1798
1847
  /**
1799
1848
  * Changes the read preference that the backend will use when performing the query to the database.
1800
1849
  *
@@ -15,7 +15,8 @@ function _interopRequireDefault(obj) {
15
15
  /**
16
16
  * @flow
17
17
  */
18
-
18
+ /*:: import type { AttributeMap } from './ObjectStateMutations';*/
19
+ /*:: import type ParseRelation from './ParseRelation';*/
19
20
  /**
20
21
  * Represents a Role on the Parse server. Roles represent groupings of
21
22
  * Users for the purposes of granting permissions (e.g. specifying an ACL
@@ -15,7 +15,7 @@ function _interopRequireDefault(obj) {
15
15
  /**
16
16
  * @flow
17
17
  */
18
-
18
+ /*:: import type { PermissionsMap } from './ParseCLP';*/
19
19
  const FIELD_TYPES = ['String', 'Number', 'Boolean', 'Date', 'File', 'GeoPoint', 'Polygon', 'Array', 'Object', 'Pointer', 'Relation'];
20
20
  /*:: type FieldOptions = {
21
21
  required: boolean,
@@ -16,7 +16,8 @@ function _interopRequireDefault(obj) {
16
16
  /**
17
17
  * @flow
18
18
  */
19
-
19
+ /*:: import type { AttributeMap } from './ObjectStateMutations';*/
20
+ /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
20
21
  /**
21
22
  * <p>A Parse.Session object is a local representation of a revocable session.
22
23
  * This class is a subclass of a Parse.Object, and retains the same
@@ -18,7 +18,9 @@ function _interopRequireDefault(obj) {
18
18
  /**
19
19
  * @flow
20
20
  */
21
-
21
+ /*:: import type { AttributeMap } from './ObjectStateMutations';*/
22
+ /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
23
+ /*:: export type AuthData = ?{ [key: string]: mixed };*/
22
24
  const CURRENT_USER_KEY = 'currentUser';
23
25
  let canUseCurrentUser = !_CoreManager.default.get('IS_NODE');
24
26
  let currentUserCacheMatchesDisk = false;
@@ -636,6 +638,25 @@ class ParseUser extends _ParseObject.default {
636
638
  return user.logIn(options);
637
639
  }
638
640
 
641
+ /**
642
+ * Logs in a user with an objectId. On success, this saves the session
643
+ * to disk, so you can retrieve the currently logged in user using
644
+ * <code>current</code>.
645
+ *
646
+ * @param {string} userId The objectId for the user.
647
+ * @static
648
+ * @returns {Promise} A promise that is fulfilled with the user when
649
+ * the login completes.
650
+ */
651
+ static loginAs(userId /*: string*/) {
652
+ if (!userId) {
653
+ throw new _ParseError.default(_ParseError.default.USERNAME_MISSING, 'Cannot log in as user with an empty user id');
654
+ }
655
+ const controller = _CoreManager.default.getUserController();
656
+ const user = new this();
657
+ return controller.loginAs(user, userId);
658
+ }
659
+
639
660
  /**
640
661
  * Logs in a user with a session token. On success, this saves the session
641
662
  * to disk, so you can retrieve the currently logged in user using
@@ -1044,6 +1065,21 @@ const DefaultController = {
1044
1065
  return DefaultController.setCurrentUser(user);
1045
1066
  });
1046
1067
  },
1068
+ loginAs(user /*: ParseUser*/, userId /*: string*/) /*: Promise<ParseUser>*/{
1069
+ const RESTController = _CoreManager.default.getRESTController();
1070
+ return RESTController.request('POST', 'loginAs', {
1071
+ userId
1072
+ }, {
1073
+ useMasterKey: true
1074
+ }).then(response => {
1075
+ user._finishFetch(response);
1076
+ user._setExisted(true);
1077
+ if (!canUseCurrentUser) {
1078
+ return Promise.resolve(user);
1079
+ }
1080
+ return DefaultController.setCurrentUser(user);
1081
+ });
1082
+ },
1047
1083
  become(user /*: ParseUser*/, options /*: RequestOptions*/) /*: Promise<ParseUser>*/{
1048
1084
  const RESTController = _CoreManager.default.getRESTController();
1049
1085
  return RESTController.request('GET', 'users/me', {}, options).then(response => {
package/lib/node/Push.js CHANGED
@@ -15,7 +15,14 @@ function _interopRequireDefault(obj) {
15
15
  /**
16
16
  * @flow
17
17
  */
18
-
18
+ /*:: import type { WhereClause } from './ParseQuery';*/
19
+ /*:: import type { FullOptions } from './RESTController';*/
20
+ /*:: export type PushData = {
21
+ where?: WhereClause | ParseQuery,
22
+ push_time?: Date | string,
23
+ expiration_time?: Date | string,
24
+ expiration_interval?: number,
25
+ };*/
19
26
  /**
20
27
  * Contains functions to deal with Push in Parse.
21
28
  *
@@ -23,7 +30,6 @@ function _interopRequireDefault(obj) {
23
30
  * @static
24
31
  * @hideconstructor
25
32
  */
26
-
27
33
  /**
28
34
  * Sends a push notification.
29
35
  * **Available in Cloud Code only.**
@@ -13,6 +13,26 @@ function _interopRequireDefault(obj) {
13
13
  */
14
14
  /* global XMLHttpRequest, XDomainRequest */
15
15
  const uuidv4 = require('./uuid');
16
+ /*:: export type RequestOptions = {
17
+ useMasterKey?: boolean,
18
+ sessionToken?: string,
19
+ installationId?: string,
20
+ returnStatus?: boolean,
21
+ batchSize?: number,
22
+ include?: any,
23
+ progress?: any,
24
+ context?: any,
25
+ usePost?: boolean,
26
+ };*/
27
+ /*:: export type FullOptions = {
28
+ success?: any,
29
+ error?: any,
30
+ useMasterKey?: boolean,
31
+ sessionToken?: string,
32
+ installationId?: string,
33
+ progress?: any,
34
+ usePost?: boolean,
35
+ };*/
16
36
  let XHR = null;
17
37
  if (typeof XMLHttpRequest !== 'undefined') {
18
38
  XHR = XMLHttpRequest;
@@ -63,7 +63,12 @@ function _interopRequireWildcard(obj, nodeInterop) {
63
63
  /**
64
64
  * @flow
65
65
  */
66
-
66
+ /*:: import type { Op } from './ParseOp';*/
67
+ /*:: import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';*/
68
+ /*:: type ObjectIdentifier = {
69
+ className: string,
70
+ id: string,
71
+ };*/
67
72
  let objectState
68
73
  /*: {
69
74
  [className: string]: {
@@ -4,7 +4,10 @@ var _promiseUtils = require("./promiseUtils");
4
4
  /**
5
5
  * @flow
6
6
  */
7
-
7
+ /*:: type Task = {
8
+ task: () => Promise,
9
+ _completion: Promise,
10
+ };*/
8
11
  class TaskQueue {
9
12
  /*:: queue: Array<Task>;*/
10
13
  constructor() {
@@ -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
  let objectState = new WeakMap();
74
76
  function getState(obj /*: ParseObject*/) /*: ?State*/{
75
77
  const classData = objectState.get(obj);
@@ -15,7 +15,10 @@ function _interopRequireDefault(obj) {
15
15
  /**
16
16
  * @flow
17
17
  */
18
-
18
+ /*:: type EncounterMap = {
19
+ objects: { [identifier: string]: ParseObject | boolean },
20
+ files: Array<ParseFile>,
21
+ };*/
19
22
  /**
20
23
  * Return an array of unsaved children, which are either Parse Objects or Files.
21
24
  * If it encounters any dirty Objects without Ids, it will throw an exception.
@@ -8,7 +8,7 @@ var config = {
8
8
  SERVER_AUTH_TOKEN: null,
9
9
  LIVEQUERY_SERVER_URL: null,
10
10
  ENCRYPTED_KEY: null,
11
- VERSION: 'js' + "4.1.0-alpha.2",
11
+ VERSION: 'js' + "4.1.0-alpha.4",
12
12
  APPLICATION_ID: null,
13
13
  JAVASCRIPT_KEY: null,
14
14
  MASTER_KEY: null,
@@ -123,21 +123,25 @@ var LiveQueryClient = function (_EventEmitter) {
123
123
  }, {
124
124
  key: "subscribe",
125
125
  value: function (query, sessionToken) {
126
- var _this2 = this;
126
+ var _queryJSON$keys,
127
+ _queryJSON$watch,
128
+ _this2 = this;
127
129
  if (!query) {
128
130
  return;
129
131
  }
130
132
  var className = query.className;
131
133
  var queryJSON = query.toJSON();
132
134
  var where = queryJSON.where;
133
- var fields = queryJSON.keys ? queryJSON.keys.split(',') : undefined;
135
+ var fields = (_queryJSON$keys = queryJSON.keys) == null ? void 0 : _queryJSON$keys.split(',');
136
+ var watch = (_queryJSON$watch = queryJSON.watch) == null ? void 0 : _queryJSON$watch.split(',');
134
137
  var subscribeRequest = {
135
138
  op: OP_TYPES.SUBSCRIBE,
136
139
  requestId: this.requestId,
137
140
  query: {
138
141
  className: className,
139
142
  where: where,
140
- fields: fields
143
+ fields: fields,
144
+ watch: watch
141
145
  }
142
146
  };
143
147
  if (sessionToken) {
@@ -24,7 +24,7 @@ var ParseCLP = function () {
24
24
  var _this = this;
25
25
  (0, _classCallCheck2.default)(this, ParseCLP);
26
26
  this.permissionsMap = {};
27
- var _loop = function _loop(operation, group) {
27
+ var _loop = function _loop(operation) {
28
28
  _this.permissionsMap[operation] = Object.assign({}, group);
29
29
  var action = operation.charAt(0).toUpperCase() + operation.slice(1);
30
30
  _this[`get${action}RequiresAuthentication`] = function () {
@@ -62,7 +62,7 @@ var ParseCLP = function () {
62
62
  var _ref2 = (0, _slicedToArray2.default)(_ref, 2);
63
63
  var operation = _ref2[0];
64
64
  var group = _ref2[1];
65
- _loop(operation, group);
65
+ _loop(operation);
66
66
  }
67
67
  for (var _ref3 of VALID_PERMISSIONS_EXTENDED.entries()) {
68
68
  var _ref4 = (0, _slicedToArray2.default)(_ref3, 2);
@@ -131,6 +131,7 @@ var ParseQuery = function () {
131
131
  throw new TypeError('A ParseQuery must be constructed with a ParseObject or class name.');
132
132
  }
133
133
  this._where = {};
134
+ this._watch = [];
134
135
  this._include = [];
135
136
  this._exclude = [];
136
137
  this._count = false;
@@ -262,6 +263,9 @@ var ParseQuery = function () {
262
263
  var params = {
263
264
  where: this._where
264
265
  };
266
+ if (this._watch.length) {
267
+ params.watch = this._watch.join(',');
268
+ }
265
269
  if (this._include.length) {
266
270
  params.include = this._include.join(',');
267
271
  }
@@ -309,6 +313,9 @@ var ParseQuery = function () {
309
313
  if (json.where) {
310
314
  this._where = json.where;
311
315
  }
316
+ if (json.watch) {
317
+ this._watch = json.watch.split(',');
318
+ }
312
319
  if (json.include) {
313
320
  this._include = json.include.split(',');
314
321
  }
@@ -1144,6 +1151,22 @@ var ParseQuery = function () {
1144
1151
  });
1145
1152
  return this;
1146
1153
  }
1154
+ }, {
1155
+ key: "watch",
1156
+ value: function () {
1157
+ var _this14 = this;
1158
+ for (var _len8 = arguments.length, keys = new Array(_len8), _key12 = 0; _key12 < _len8; _key12++) {
1159
+ keys[_key12] = arguments[_key12];
1160
+ }
1161
+ keys.forEach(function (key) {
1162
+ if (Array.isArray(key)) {
1163
+ _this14._watch = _this14._watch.concat(key);
1164
+ } else {
1165
+ _this14._watch.push(key);
1166
+ }
1167
+ });
1168
+ return this;
1169
+ }
1147
1170
  }, {
1148
1171
  key: "readPreference",
1149
1172
  value: function (_readPreference, includeReadPreference, subqueryReadPreference) {
@@ -1204,7 +1227,7 @@ var ParseQuery = function () {
1204
1227
  }, {
1205
1228
  key: "cancel",
1206
1229
  value: function () {
1207
- var _this14 = this;
1230
+ var _this15 = this;
1208
1231
  if (this._xhrRequest.task && typeof this._xhrRequest.task.abort === 'function') {
1209
1232
  this._xhrRequest.task._aborted = true;
1210
1233
  this._xhrRequest.task.abort();
@@ -1213,16 +1236,16 @@ var ParseQuery = function () {
1213
1236
  return this;
1214
1237
  }
1215
1238
  return this._xhrRequest.onchange = function () {
1216
- return _this14.cancel();
1239
+ return _this15.cancel();
1217
1240
  };
1218
1241
  }
1219
1242
  }, {
1220
1243
  key: "_setRequestTask",
1221
1244
  value: function (options) {
1222
- var _this15 = this;
1245
+ var _this16 = this;
1223
1246
  options.requestTask = function (task) {
1224
- _this15._xhrRequest.task = task;
1225
- _this15._xhrRequest.onchange();
1247
+ _this16._xhrRequest.task = task;
1248
+ _this16._xhrRequest.onchange();
1226
1249
  };
1227
1250
  }
1228
1251
  }], [{
@@ -1234,8 +1257,8 @@ var ParseQuery = function () {
1234
1257
  }, {
1235
1258
  key: "or",
1236
1259
  value: function () {
1237
- for (var _len8 = arguments.length, queries = new Array(_len8), _key12 = 0; _key12 < _len8; _key12++) {
1238
- queries[_key12] = arguments[_key12];
1260
+ for (var _len9 = arguments.length, queries = new Array(_len9), _key13 = 0; _key13 < _len9; _key13++) {
1261
+ queries[_key13] = arguments[_key13];
1239
1262
  }
1240
1263
  var className = _getClassNameFromQueries(queries);
1241
1264
  var query = new ParseQuery(className);
@@ -1245,8 +1268,8 @@ var ParseQuery = function () {
1245
1268
  }, {
1246
1269
  key: "and",
1247
1270
  value: function () {
1248
- for (var _len9 = arguments.length, queries = new Array(_len9), _key13 = 0; _key13 < _len9; _key13++) {
1249
- queries[_key13] = arguments[_key13];
1271
+ for (var _len10 = arguments.length, queries = new Array(_len10), _key14 = 0; _key14 < _len10; _key14++) {
1272
+ queries[_key14] = arguments[_key14];
1250
1273
  }
1251
1274
  var className = _getClassNameFromQueries(queries);
1252
1275
  var query = new ParseQuery(className);
@@ -1256,8 +1279,8 @@ var ParseQuery = function () {
1256
1279
  }, {
1257
1280
  key: "nor",
1258
1281
  value: function () {
1259
- for (var _len10 = arguments.length, queries = new Array(_len10), _key14 = 0; _key14 < _len10; _key14++) {
1260
- queries[_key14] = arguments[_key14];
1282
+ for (var _len11 = arguments.length, queries = new Array(_len11), _key15 = 0; _key15 < _len11; _key15++) {
1283
+ queries[_key15] = arguments[_key15];
1261
1284
  }
1262
1285
  var className = _getClassNameFromQueries(queries);
1263
1286
  var query = new ParseQuery(className);