parse 5.1.0 → 5.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 (143) hide show
  1. package/dist/parse.js +1556 -1309
  2. package/dist/parse.min.js +2 -2
  3. package/dist/parse.weapp.js +1560 -1313
  4. package/dist/parse.weapp.min.js +2 -2
  5. package/lib/browser/Cloud.js +7 -11
  6. package/lib/browser/CoreManager.js +10 -10
  7. package/lib/browser/EventuallyQueue.js +1 -1
  8. package/lib/browser/InstallationController.js +3 -3
  9. package/lib/browser/LiveQueryClient.js +102 -60
  10. package/lib/browser/LocalDatastore.js +189 -147
  11. package/lib/browser/LocalDatastoreController.default.js +14 -9
  12. package/lib/browser/LocalDatastoreController.react-native.js +14 -12
  13. package/lib/browser/LocalDatastoreUtils.js +0 -5
  14. package/lib/browser/ObjectStateMutations.js +57 -21
  15. package/lib/browser/Parse.js +2 -2
  16. package/lib/browser/ParseCLP.js +9 -17
  17. package/lib/browser/ParseFile.js +27 -31
  18. package/lib/browser/ParseGeoPoint.js +9 -3
  19. package/lib/browser/ParseHooks.js +13 -13
  20. package/lib/browser/ParseInstallation.js +117 -9
  21. package/lib/browser/ParseObject.js +19 -17
  22. package/lib/browser/ParseOp.js +17 -17
  23. package/lib/browser/ParsePolygon.js +1 -1
  24. package/lib/browser/ParseQuery.js +147 -149
  25. package/lib/browser/ParseRole.js +5 -9
  26. package/lib/browser/ParseSchema.js +1 -1
  27. package/lib/browser/ParseUser.js +66 -51
  28. package/lib/browser/Push.js +5 -10
  29. package/lib/browser/RESTController.js +1 -1
  30. package/lib/browser/SingleInstanceStateController.js +1 -1
  31. package/lib/browser/TaskQueue.js +10 -10
  32. package/lib/browser/UniqueInstanceStateController.js +1 -1
  33. package/lib/browser/arrayContainsObject.js +0 -4
  34. package/lib/browser/canBeSerialized.js +0 -4
  35. package/lib/browser/decode.js +0 -7
  36. package/lib/browser/encode.js +3 -7
  37. package/lib/browser/equals.js +1 -1
  38. package/lib/browser/escape.js +0 -4
  39. package/lib/browser/isRevocableSession.js +0 -4
  40. package/lib/browser/parseDate.js +1 -5
  41. package/lib/browser/promiseUtils.js +11 -10
  42. package/lib/browser/unique.js +1 -5
  43. package/lib/browser/unsavedChildren.js +0 -8
  44. package/lib/browser/uuid.js +2 -2
  45. package/lib/node/Cloud.js +7 -11
  46. package/lib/node/CoreManager.js +10 -10
  47. package/lib/node/EventuallyQueue.js +1 -1
  48. package/lib/node/InstallationController.js +3 -3
  49. package/lib/node/LiveQueryClient.js +14 -24
  50. package/lib/node/LocalDatastore.js +7 -11
  51. package/lib/node/LocalDatastoreController.default.js +12 -10
  52. package/lib/node/LocalDatastoreController.react-native.js +13 -12
  53. package/lib/node/LocalDatastoreUtils.js +0 -5
  54. package/lib/node/ObjectStateMutations.js +45 -19
  55. package/lib/node/Parse.js +2 -2
  56. package/lib/node/ParseCLP.js +8 -18
  57. package/lib/node/ParseFile.js +27 -40
  58. package/lib/node/ParseGeoPoint.js +9 -3
  59. package/lib/node/ParseHooks.js +13 -13
  60. package/lib/node/ParseInstallation.js +60 -2
  61. package/lib/node/ParseObject.js +19 -17
  62. package/lib/node/ParseOp.js +21 -21
  63. package/lib/node/ParsePolygon.js +1 -1
  64. package/lib/node/ParseQuery.js +84 -107
  65. package/lib/node/ParseRole.js +3 -8
  66. package/lib/node/ParseSchema.js +4 -4
  67. package/lib/node/ParseUser.js +42 -37
  68. package/lib/node/Push.js +3 -8
  69. package/lib/node/RESTController.js +1 -1
  70. package/lib/node/SingleInstanceStateController.js +1 -1
  71. package/lib/node/TaskQueue.js +9 -11
  72. package/lib/node/UniqueInstanceStateController.js +1 -1
  73. package/lib/node/arrayContainsObject.js +0 -4
  74. package/lib/node/canBeSerialized.js +0 -4
  75. package/lib/node/decode.js +0 -7
  76. package/lib/node/encode.js +3 -7
  77. package/lib/node/equals.js +1 -1
  78. package/lib/node/escape.js +0 -4
  79. package/lib/node/isRevocableSession.js +0 -4
  80. package/lib/node/parseDate.js +1 -5
  81. package/lib/node/promiseUtils.js +11 -10
  82. package/lib/node/unique.js +1 -5
  83. package/lib/node/unsavedChildren.js +0 -8
  84. package/lib/node/uuid.js +2 -2
  85. package/lib/react-native/Cloud.js +0 -1
  86. package/lib/react-native/CoreManager.js +1 -1
  87. package/lib/react-native/LiveQueryClient.js +49 -32
  88. package/lib/react-native/LocalDatastore.js +38 -14
  89. package/lib/react-native/LocalDatastoreController.default.js +7 -1
  90. package/lib/react-native/LocalDatastoreController.react-native.js +7 -1
  91. package/lib/react-native/ObjectStateMutations.js +30 -9
  92. package/lib/react-native/ParseCLP.js +3 -3
  93. package/lib/react-native/ParseFile.js +7 -6
  94. package/lib/react-native/ParseInstallation.js +51 -3
  95. package/lib/react-native/ParseObject.js +6 -5
  96. package/lib/react-native/ParseQuery.js +45 -37
  97. package/lib/react-native/ParseRole.js +1 -1
  98. package/lib/react-native/ParseUser.js +22 -16
  99. package/lib/react-native/TaskQueue.js +8 -2
  100. package/lib/react-native/decode.js +0 -1
  101. package/lib/react-native/promiseUtils.js +5 -4
  102. package/lib/react-native/uuid.js +1 -2
  103. package/lib/weapp/Cloud.js +7 -11
  104. package/lib/weapp/CoreManager.js +10 -10
  105. package/lib/weapp/EventuallyQueue.js +1 -1
  106. package/lib/weapp/InstallationController.js +3 -3
  107. package/lib/weapp/LiveQueryClient.js +102 -60
  108. package/lib/weapp/LocalDatastore.js +189 -147
  109. package/lib/weapp/LocalDatastoreController.default.js +14 -9
  110. package/lib/weapp/LocalDatastoreController.react-native.js +14 -12
  111. package/lib/weapp/LocalDatastoreUtils.js +0 -5
  112. package/lib/weapp/ObjectStateMutations.js +57 -21
  113. package/lib/weapp/Parse.js +2 -2
  114. package/lib/weapp/ParseCLP.js +9 -17
  115. package/lib/weapp/ParseFile.js +27 -31
  116. package/lib/weapp/ParseGeoPoint.js +9 -3
  117. package/lib/weapp/ParseHooks.js +13 -13
  118. package/lib/weapp/ParseInstallation.js +117 -9
  119. package/lib/weapp/ParseObject.js +19 -17
  120. package/lib/weapp/ParseOp.js +17 -17
  121. package/lib/weapp/ParsePolygon.js +1 -1
  122. package/lib/weapp/ParseQuery.js +147 -149
  123. package/lib/weapp/ParseRole.js +5 -9
  124. package/lib/weapp/ParseSchema.js +1 -1
  125. package/lib/weapp/ParseUser.js +66 -51
  126. package/lib/weapp/Push.js +5 -10
  127. package/lib/weapp/RESTController.js +1 -1
  128. package/lib/weapp/SingleInstanceStateController.js +1 -1
  129. package/lib/weapp/TaskQueue.js +10 -10
  130. package/lib/weapp/UniqueInstanceStateController.js +1 -1
  131. package/lib/weapp/arrayContainsObject.js +0 -4
  132. package/lib/weapp/canBeSerialized.js +0 -4
  133. package/lib/weapp/decode.js +0 -7
  134. package/lib/weapp/encode.js +3 -7
  135. package/lib/weapp/equals.js +1 -1
  136. package/lib/weapp/escape.js +0 -4
  137. package/lib/weapp/isRevocableSession.js +0 -4
  138. package/lib/weapp/parseDate.js +1 -5
  139. package/lib/weapp/promiseUtils.js +11 -10
  140. package/lib/weapp/unique.js +1 -5
  141. package/lib/weapp/unsavedChildren.js +0 -8
  142. package/lib/weapp/uuid.js +3 -3
  143. package/package.json +5 -6
@@ -19,11 +19,6 @@ var _decode = _interopRequireDefault(require("./decode"));
19
19
  var _encode = _interopRequireDefault(require("./encode"));
20
20
  var _ParseError = _interopRequireDefault(require("./ParseError"));
21
21
  var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
22
- var _ParseObject = _interopRequireDefault(require("./ParseObject"));
23
- /**
24
- * @flow
25
- */
26
- /*:: import type { RequestOptions } from './RESTController';*/
27
22
  /**
28
23
  * Contains functions for calling and declaring
29
24
  * <a href="/docs/cloud_code_guide#functions">cloud functions</a>.
@@ -35,6 +30,7 @@ var _ParseObject = _interopRequireDefault(require("./ParseObject"));
35
30
  * @static
36
31
  * @hideconstructor
37
32
  */
33
+
38
34
  /**
39
35
  * Makes a call to a cloud function.
40
36
  *
@@ -46,12 +42,12 @@ var _ParseObject = _interopRequireDefault(require("./ParseObject"));
46
42
  * @returns {Promise} A promise that will be resolved with the result
47
43
  * of the function.
48
44
  */
49
- function run(name /*: string*/, data /*: mixed*/, options /*: RequestOptions*/) /*: Promise<mixed>*/{
45
+ function run(name /*: string*/, data /*: any*/, options /*: RequestOptions*/) /*: Promise<any>*/{
50
46
  options = options || {};
51
47
  if (typeof name !== 'string' || name.length === 0) {
52
48
  throw new TypeError('Cloud function name must be a string.');
53
49
  }
54
- var requestOptions = {};
50
+ var requestOptions /*: RequestOptions*/ = {};
55
51
  if (options.useMasterKey) {
56
52
  requestOptions.useMasterKey = options.useMasterKey;
57
53
  }
@@ -75,7 +71,7 @@ function run(name /*: string*/, data /*: mixed*/, options /*: RequestOptions*/)
75
71
  * @returns {Promise} A promise that will be resolved with the result
76
72
  * of the function.
77
73
  */
78
- function getJobsData() /*: Promise<Object>*/{
74
+ function getJobsData() /*: Promise<any>*/{
79
75
  return _CoreManager.default.getCloudController().getJobsData({
80
76
  useMasterKey: true
81
77
  });
@@ -91,7 +87,7 @@ function getJobsData() /*: Promise<Object>*/{
91
87
  * @returns {Promise} A promise that will be resolved with the jobStatusId
92
88
  * of the job.
93
89
  */
94
- function startJob(name /*: string*/, data /*: mixed*/) /*: Promise<string>*/{
90
+ function startJob(name /*: string*/, data /*: any*/) /*: Promise<string>*/{
95
91
  if (typeof name !== 'string' || name.length === 0) {
96
92
  throw new TypeError('Cloud job name must be a string.');
97
93
  }
@@ -115,7 +111,7 @@ function getJobStatus(jobStatusId /*: string*/) /*: Promise<ParseObject>*/{
115
111
  });
116
112
  }
117
113
  var DefaultController = {
118
- run: function (name, data, options /*: RequestOptions*/) {
114
+ run: function (name /*: string*/, data /*: any*/, options /*: RequestOptions*/) {
119
115
  var RESTController = _CoreManager.default.getRESTController();
120
116
  var payload = (0, _encode.default)(data, true);
121
117
  var request = RESTController.request('POST', 'functions/' + name, payload, options);
@@ -134,7 +130,7 @@ var DefaultController = {
134
130
  var RESTController = _CoreManager.default.getRESTController();
135
131
  return RESTController.request('GET', 'cloud_code/jobs/data', null, options);
136
132
  },
137
- startJob: function (name, data, options /*: RequestOptions*/) {
133
+ startJob: function (name /*: string*/, data /*: any*/, options /*: RequestOptions*/) {
138
134
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
139
135
  var _response$_headers;
140
136
  var RESTController, payload, response;
@@ -27,7 +27,7 @@ var config /*: Config & { [key: string]: any }*/ = {
27
27
  SERVER_AUTH_TOKEN: null,
28
28
  LIVEQUERY_SERVER_URL: null,
29
29
  ENCRYPTED_KEY: null,
30
- VERSION: 'js' + "5.1.0",
30
+ VERSION: 'js' + "5.2.0-alpha.1",
31
31
  APPLICATION_ID: null,
32
32
  JAVASCRIPT_KEY: null,
33
33
  MASTER_KEY: null,
@@ -230,34 +230,34 @@ var CoreManager = {
230
230
  getHooksController: function () /*: HooksController*/{
231
231
  return config['HooksController'];
232
232
  },
233
- setParseOp: function (op /*: typeof ParseOp*/) {
233
+ setParseOp: function (op /*: any*/) {
234
234
  config['ParseOp'] = op;
235
235
  },
236
236
  getParseOp: function () {
237
237
  return config['ParseOp'];
238
238
  },
239
- setParseObject: function (object /*: typeof ParseObject*/) {
239
+ setParseObject: function (object /*: any*/) {
240
240
  config['ParseObject'] = object;
241
241
  },
242
- getParseObject: function () /*: ParseObject*/{
242
+ getParseObject: function () {
243
243
  return config['ParseObject'];
244
244
  },
245
- setParseQuery: function (query /*: typeof ParseQuery*/) {
245
+ setParseQuery: function (query /*: any*/) {
246
246
  config['ParseQuery'] = query;
247
247
  },
248
- getParseQuery: function () /*: ParseQuery*/{
248
+ getParseQuery: function () {
249
249
  return config['ParseQuery'];
250
250
  },
251
- setParseRole: function (role /*: typeof ParseRole*/) {
251
+ setParseRole: function (role /*: any*/) {
252
252
  config['ParseRole'] = role;
253
253
  },
254
- getParseRole: function () /*: ParseRole*/{
254
+ getParseRole: function () {
255
255
  return config['ParseRole'];
256
256
  },
257
- setParseUser: function (user /*: typeof ParseUser*/) {
257
+ setParseUser: function (user /*: any*/) {
258
258
  config['ParseUser'] = user;
259
259
  },
260
- getParseUser: function () /*: ParseUser*/{
260
+ getParseUser: function () {
261
261
  return config['ParseUser'];
262
262
  }
263
263
  };
@@ -454,7 +454,7 @@ var EventuallyQueue = {
454
454
  */
455
455
  poll: function () {
456
456
  var _this7 = this;
457
- var ms /*:: ?: number*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2000;
457
+ var ms = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2000;
458
458
  if (polling) {
459
459
  return;
460
460
  }
@@ -16,7 +16,7 @@ var _uuid = _interopRequireDefault(require("./uuid"));
16
16
  var CURRENT_INSTALLATION_KEY = 'currentInstallation';
17
17
  var CURRENT_INSTALLATION_ID_KEY = 'currentInstallationId';
18
18
  var iidCache /*: string | null*/ = null;
19
- var currentInstallationCache = null;
19
+ var currentInstallationCache /*: ParseInstallation | null*/ = null;
20
20
  var currentInstallationCacheMatchesDisk = false;
21
21
  var InstallationController = {
22
22
  updateInstallationOnDisk: function (installation /*: ParseInstallation*/) /*: Promise<void>*/{
@@ -97,7 +97,7 @@ var InstallationController = {
97
97
  _context3.next = 7;
98
98
  return _Storage.default.getItemAsync(path);
99
99
  case 7:
100
- installationData = _context3.sent;
100
+ installationData /*: any*/ = _context3.sent;
101
101
  currentInstallationCacheMatchesDisk = true;
102
102
  if (!installationData) {
103
103
  _context3.next = 15;
@@ -138,7 +138,7 @@ var InstallationController = {
138
138
  iidCache = iid;
139
139
  },
140
140
  _setCurrentInstallationCache: function (installation /*: ParseInstallation*/) {
141
- var matchesDisk /*: boolean*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
141
+ var matchesDisk = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
142
142
  currentInstallationCache = installation;
143
143
  currentInstallationCacheMatchesDisk = matchesDisk;
144
144
  }
@@ -11,6 +11,7 @@ _Object$defineProperty(exports, "__esModule", {
11
11
  value: true
12
12
  });
13
13
  exports.default = void 0;
14
+ var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator"));
14
15
  var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
15
16
  var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/map"));
16
17
  var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
@@ -20,6 +21,7 @@ var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-st
20
21
  var _values = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/values"));
21
22
  var _setTimeout2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set-timeout"));
22
23
  var _bind = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/bind"));
24
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
23
25
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
24
26
  var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
25
27
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
@@ -80,10 +82,10 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
80
82
  };
81
83
  }
82
84
  function _unsupportedIterableToArray(o, minLen) {
83
- var _context7;
85
+ var _context9;
84
86
  if (!o) return;
85
87
  if (typeof o === "string") return _arrayLikeToArray(o, minLen);
86
- var n = _sliceInstanceProperty(_context7 = Object.prototype.toString.call(o)).call(_context7, 8, -1);
88
+ var n = _sliceInstanceProperty(_context9 = Object.prototype.toString.call(o)).call(_context9, 8, -1);
87
89
  if (n === "Object" && o.constructor) n = o.constructor.name;
88
90
  if (n === "Map" || n === "Set") return _Array$from(o);
89
91
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
@@ -222,6 +224,10 @@ var LiveQueryClient = /*#__PURE__*/function () {
222
224
  (0, _defineProperty2.default)(this, "subscriptions", void 0);
223
225
  (0, _defineProperty2.default)(this, "socket", void 0);
224
226
  (0, _defineProperty2.default)(this, "state", void 0);
227
+ (0, _defineProperty2.default)(this, "reconnectHandle", void 0);
228
+ (0, _defineProperty2.default)(this, "emitter", void 0);
229
+ (0, _defineProperty2.default)(this, "on", void 0);
230
+ (0, _defineProperty2.default)(this, "emit", void 0);
225
231
  if (!serverURL || (0, _indexOf.default)(serverURL).call(serverURL, 'ws') !== 0) {
226
232
  throw new Error('You need to set a proper Parse LiveQuery server url before using LiveQueryClient');
227
233
  }
@@ -271,13 +277,13 @@ var LiveQueryClient = /*#__PURE__*/function () {
271
277
  * <a href="https://github.com/parse-community/parse-server/wiki/Parse-LiveQuery-Protocol-Specification">here</a> for more details. The subscription you get is the same subscription you get
272
278
  * from our Standard API.
273
279
  *
274
- * @param {object} query - the ParseQuery you want to subscribe to
280
+ * @param {ParseQuery} query - the ParseQuery you want to subscribe to
275
281
  * @param {string} sessionToken (optional)
276
282
  * @returns {LiveQuerySubscription | undefined}
277
283
  */
278
284
  }, {
279
285
  key: "subscribe",
280
- value: function (query /*: Object*/, sessionToken /*: ?string*/) /*: LiveQuerySubscription*/{
286
+ value: function (query /*: ParseQuery*/, sessionToken /*:: ?: string*/) /*: LiveQuerySubscription | undefined*/{
281
287
  var _queryJSON$keys,
282
288
  _queryJSON$watch,
283
289
  _this2 = this;
@@ -297,7 +303,8 @@ var LiveQueryClient = /*#__PURE__*/function () {
297
303
  where: where,
298
304
  keys: keys,
299
305
  watch: watch
300
- }
306
+ },
307
+ sessionToken: undefined
301
308
  };
302
309
  if (sessionToken) {
303
310
  subscribeRequest.sessionToken = sessionToken;
@@ -321,22 +328,39 @@ var LiveQueryClient = /*#__PURE__*/function () {
321
328
  */
322
329
  }, {
323
330
  key: "unsubscribe",
324
- value: function (subscription /*: Object*/) /*: ?Promise*/{
325
- var _this3 = this;
326
- if (!subscription) {
327
- return;
331
+ value: function () {
332
+ var _unsubscribe = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(subscription /*: LiveQuerySubscription*/) {
333
+ var _this3 = this;
334
+ var unsubscribeRequest;
335
+ return _regenerator.default.wrap(function (_context2) {
336
+ while (1) switch (_context2.prev = _context2.next) {
337
+ case 0:
338
+ if (subscription) {
339
+ _context2.next = 2;
340
+ break;
341
+ }
342
+ return _context2.abrupt("return");
343
+ case 2:
344
+ unsubscribeRequest = {
345
+ op: OP_TYPES.UNSUBSCRIBE,
346
+ requestId: subscription.id
347
+ };
348
+ return _context2.abrupt("return", this.connectPromise.then(function () {
349
+ return _this3.socket.send((0, _stringify.default)(unsubscribeRequest));
350
+ }).then(function () {
351
+ return subscription.unsubscribePromise;
352
+ }));
353
+ case 4:
354
+ case "end":
355
+ return _context2.stop();
356
+ }
357
+ }, _callee, this);
358
+ }));
359
+ function unsubscribe() {
360
+ return _unsubscribe.apply(this, arguments);
328
361
  }
329
- var unsubscribeRequest = {
330
- op: OP_TYPES.UNSUBSCRIBE,
331
- requestId: subscription.id
332
- };
333
- return this.connectPromise.then(function () {
334
- return _this3.socket.send((0, _stringify.default)(unsubscribeRequest));
335
- }).then(function () {
336
- return subscription.unsubscribePromise;
337
- });
338
- }
339
-
362
+ return unsubscribe;
363
+ }()
340
364
  /**
341
365
  * After open is called, the LiveQueryClient will try to send a connect request
342
366
  * to the LiveQuery server.
@@ -365,7 +389,8 @@ var LiveQueryClient = /*#__PURE__*/function () {
365
389
  _this4._handleWebSocketMessage(event);
366
390
  };
367
391
  this.socket.onclose = function (event) {
368
- _this4.socket.closingPromise.resolve(event);
392
+ var _this4$socket$closing;
393
+ (_this4$socket$closing = _this4.socket.closingPromise) === null || _this4$socket$closing === void 0 ? void 0 : _this4$socket$closing.resolve(event);
369
394
  _this4._handleWebSocketClose();
370
395
  };
371
396
  this.socket.onerror = function (error) {
@@ -375,9 +400,9 @@ var LiveQueryClient = /*#__PURE__*/function () {
375
400
  }, {
376
401
  key: "resubscribe",
377
402
  value: function () {
378
- var _context2,
403
+ var _context3,
379
404
  _this5 = this;
380
- (0, _forEach.default)(_context2 = this.subscriptions).call(_context2, function (subscription, requestId) {
405
+ (0, _forEach.default)(_context3 = this.subscriptions).call(_context3, function (subscription, requestId) {
381
406
  var query = subscription.query;
382
407
  var queryJSON = query.toJSON();
383
408
  var where = queryJSON.where;
@@ -391,7 +416,8 @@ var LiveQueryClient = /*#__PURE__*/function () {
391
416
  className: className,
392
417
  where: where,
393
418
  fields: fields
394
- }
419
+ },
420
+ sessionToken: undefined
395
421
  };
396
422
  if (sessionToken) {
397
423
  subscribeRequest.sessionToken = sessionToken;
@@ -410,33 +436,48 @@ var LiveQueryClient = /*#__PURE__*/function () {
410
436
  */
411
437
  }, {
412
438
  key: "close",
413
- value: function () /*: ?Promise*/{
414
- var _this$socket, _this$socket2, _context3;
415
- if (this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED) {
416
- return;
417
- }
418
- this.state = CLIENT_STATE.DISCONNECTED;
419
- (_this$socket = this.socket) === null || _this$socket === void 0 ? void 0 : _this$socket.close();
420
- // Notify each subscription about the close
421
- var _iterator = _createForOfIteratorHelper((0, _values.default)(_context3 = this.subscriptions).call(_context3)),
422
- _step;
423
- try {
424
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
425
- var subscription = _step.value;
426
- subscription.subscribed = false;
427
- subscription.emit(SUBSCRIPTION_EMMITER_TYPES.CLOSE);
428
- }
429
- } catch (err) {
430
- _iterator.e(err);
431
- } finally {
432
- _iterator.f();
439
+ value: function () {
440
+ var _close = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
441
+ var _this$socket, _this$socket2, _context4;
442
+ var _iterator, _step, subscription;
443
+ return _regenerator.default.wrap(function (_context5) {
444
+ while (1) switch (_context5.prev = _context5.next) {
445
+ case 0:
446
+ if (!(this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED)) {
447
+ _context5.next = 2;
448
+ break;
449
+ }
450
+ return _context5.abrupt("return");
451
+ case 2:
452
+ this.state = CLIENT_STATE.DISCONNECTED;
453
+ (_this$socket = this.socket) === null || _this$socket === void 0 ? void 0 : _this$socket.close();
454
+ // Notify each subscription about the close
455
+ _iterator = _createForOfIteratorHelper((0, _values.default)(_context4 = this.subscriptions).call(_context4));
456
+ try {
457
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
458
+ subscription = _step.value;
459
+ subscription.subscribed = false;
460
+ subscription.emit(SUBSCRIPTION_EMMITER_TYPES.CLOSE);
461
+ }
462
+ } catch (err) {
463
+ _iterator.e(err);
464
+ } finally {
465
+ _iterator.f();
466
+ }
467
+ this._handleReset();
468
+ this.emit(CLIENT_EMMITER_TYPES.CLOSE);
469
+ return _context5.abrupt("return", (_this$socket2 = this.socket) === null || _this$socket2 === void 0 ? void 0 : _this$socket2.closingPromise);
470
+ case 9:
471
+ case "end":
472
+ return _context5.stop();
473
+ }
474
+ }, _callee2, this);
475
+ }));
476
+ function close() {
477
+ return _close.apply(this, arguments);
433
478
  }
434
- this._handleReset();
435
- this.emit(CLIENT_EMMITER_TYPES.CLOSE);
436
- return (_this$socket2 = this.socket) === null || _this$socket2 === void 0 ? void 0 : _this$socket2.closingPromise;
437
- }
438
-
439
- // ensure we start with valid state if connect is called again after close
479
+ return close;
480
+ }() // ensure we start with valid state if connect is called again after close
440
481
  }, {
441
482
  key: "_handleReset",
442
483
  value: function () {
@@ -455,7 +496,8 @@ var LiveQueryClient = /*#__PURE__*/function () {
455
496
  applicationId: this.applicationId,
456
497
  javascriptKey: this.javascriptKey,
457
498
  masterKey: this.masterKey,
458
- sessionToken: this.sessionToken
499
+ sessionToken: this.sessionToken,
500
+ installationId: undefined
459
501
  };
460
502
  if (this.additionalProperties) {
461
503
  connectRequest.installationId = this.installationId;
@@ -469,9 +511,9 @@ var LiveQueryClient = /*#__PURE__*/function () {
469
511
  if (typeof data === 'string') {
470
512
  data = JSON.parse(data);
471
513
  }
472
- var subscription = null;
514
+ var subscription /*: null | LiveQuerySubscription*/ = null;
473
515
  if (data.requestId) {
474
- subscription = this.subscriptions.get(data.requestId);
516
+ subscription = this.subscriptions.get(data.requestId) || null;
475
517
  }
476
518
  var response = {
477
519
  clientId: data.clientId,
@@ -565,14 +607,14 @@ var LiveQueryClient = /*#__PURE__*/function () {
565
607
  }, {
566
608
  key: "_handleWebSocketClose",
567
609
  value: function () {
568
- var _context4;
610
+ var _context6;
569
611
  if (this.state === CLIENT_STATE.DISCONNECTED) {
570
612
  return;
571
613
  }
572
614
  this.state = CLIENT_STATE.CLOSED;
573
615
  this.emit(CLIENT_EMMITER_TYPES.CLOSE);
574
616
  // Notify each subscription about the close
575
- var _iterator2 = _createForOfIteratorHelper((0, _values.default)(_context4 = this.subscriptions).call(_context4)),
617
+ var _iterator2 = _createForOfIteratorHelper((0, _values.default)(_context6 = this.subscriptions).call(_context6)),
576
618
  _step2;
577
619
  try {
578
620
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
@@ -589,9 +631,9 @@ var LiveQueryClient = /*#__PURE__*/function () {
589
631
  }, {
590
632
  key: "_handleWebSocketError",
591
633
  value: function (error /*: any*/) {
592
- var _context5;
634
+ var _context7;
593
635
  this.emit(CLIENT_EMMITER_TYPES.ERROR, error);
594
- var _iterator3 = _createForOfIteratorHelper((0, _values.default)(_context5 = this.subscriptions).call(_context5)),
636
+ var _iterator3 = _createForOfIteratorHelper((0, _values.default)(_context7 = this.subscriptions).call(_context7)),
595
637
  _step3;
596
638
  try {
597
639
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
@@ -608,7 +650,7 @@ var LiveQueryClient = /*#__PURE__*/function () {
608
650
  }, {
609
651
  key: "_handleReconnect",
610
652
  value: function () {
611
- var _context6,
653
+ var _context8,
612
654
  _this6 = this;
613
655
  // if closed or currently reconnecting we stop attempting to reconnect
614
656
  if (this.state === CLIENT_STATE.DISCONNECTED) {
@@ -625,11 +667,11 @@ var LiveQueryClient = /*#__PURE__*/function () {
625
667
  if (this.reconnectHandle) {
626
668
  clearTimeout(this.reconnectHandle);
627
669
  }
628
- this.reconnectHandle = (0, _setTimeout2.default)((0, _bind.default)(_context6 = function () {
670
+ this.reconnectHandle = (0, _setTimeout2.default)((0, _bind.default)(_context8 = function () {
629
671
  _this6.attempts++;
630
672
  _this6.connectPromise = (0, _promiseUtils.resolvingPromise)();
631
673
  _this6.open();
632
- }).call(_context6, this), time);
674
+ }).call(_context8, this), time);
633
675
  }
634
676
  }]);
635
677
  return LiveQueryClient;