parse 5.2.0-alpha.1 → 5.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 (247) hide show
  1. package/dist/parse.js +10102 -15029
  2. package/dist/parse.min.js +2 -2
  3. package/dist/parse.weapp.js +10093 -15165
  4. package/dist/parse.weapp.min.js +2 -2
  5. package/lib/browser/Analytics.js +7 -11
  6. package/lib/browser/AnonymousUtils.js +17 -22
  7. package/lib/browser/Cloud.js +23 -41
  8. package/lib/browser/CoreManager.js +71 -79
  9. package/lib/browser/CryptoController.js +14 -9
  10. package/lib/browser/EventEmitter.js +9 -2
  11. package/lib/browser/EventuallyQueue.js +156 -357
  12. package/lib/browser/FacebookUtils.js +23 -28
  13. package/lib/browser/IndexedDBStorageController.js +18 -14
  14. package/lib/browser/InstallationController.js +55 -121
  15. package/lib/browser/LiveQueryClient.js +308 -484
  16. package/lib/browser/LiveQuerySubscription.js +25 -28
  17. package/lib/browser/LocalDatastore.js +258 -624
  18. package/lib/browser/LocalDatastoreController.default.js +42 -226
  19. package/lib/browser/LocalDatastoreController.js +11 -1
  20. package/lib/browser/LocalDatastoreController.react-native.js +66 -160
  21. package/lib/browser/LocalDatastoreUtils.js +4 -7
  22. package/lib/browser/ObjectStateMutations.js +54 -96
  23. package/lib/browser/OfflineQuery.js +106 -198
  24. package/lib/browser/Parse.js +44 -60
  25. package/lib/browser/ParseACL.js +242 -288
  26. package/lib/browser/ParseCLP.js +372 -572
  27. package/lib/browser/ParseConfig.js +115 -138
  28. package/lib/browser/ParseError.js +85 -182
  29. package/lib/browser/ParseFile.js +294 -438
  30. package/lib/browser/ParseGeoPoint.js +121 -146
  31. package/lib/browser/ParseHooks.js +23 -25
  32. package/lib/browser/ParseInstallation.js +225 -367
  33. package/lib/browser/ParseLiveQuery.js +74 -148
  34. package/lib/browser/ParseObject.js +2014 -2621
  35. package/lib/browser/ParseOp.js +343 -484
  36. package/lib/browser/ParsePolygon.js +101 -120
  37. package/lib/browser/ParseQuery.js +1708 -2052
  38. package/lib/browser/ParseRelation.js +99 -118
  39. package/lib/browser/ParseRole.js +88 -140
  40. package/lib/browser/ParseSchema.js +372 -434
  41. package/lib/browser/ParseSession.js +62 -110
  42. package/lib/browser/ParseUser.js +941 -1284
  43. package/lib/browser/Push.js +15 -38
  44. package/lib/browser/RESTController.js +85 -124
  45. package/lib/browser/SingleInstanceStateController.js +57 -86
  46. package/lib/browser/Socket.weapp.js +50 -33
  47. package/lib/browser/Storage.js +23 -28
  48. package/lib/browser/StorageController.browser.js +16 -13
  49. package/lib/browser/StorageController.default.js +15 -14
  50. package/lib/browser/StorageController.js +14 -1
  51. package/lib/browser/StorageController.react-native.js +31 -30
  52. package/lib/browser/StorageController.weapp.js +19 -13
  53. package/lib/browser/TaskQueue.js +31 -43
  54. package/lib/browser/UniqueInstanceStateController.js +65 -86
  55. package/lib/browser/WebSocketController.js +11 -4
  56. package/lib/browser/Xhr.weapp.js +90 -78
  57. package/lib/browser/arrayContainsObject.js +3 -3
  58. package/lib/browser/canBeSerialized.js +10 -11
  59. package/lib/browser/decode.js +11 -11
  60. package/lib/browser/encode.js +11 -11
  61. package/lib/browser/equals.js +9 -10
  62. package/lib/browser/escape.js +2 -2
  63. package/lib/browser/isRevocableSession.js +1 -1
  64. package/lib/browser/parseDate.js +10 -10
  65. package/lib/browser/promiseUtils.js +19 -19
  66. package/lib/browser/unique.js +4 -4
  67. package/lib/browser/unsavedChildren.js +20 -21
  68. package/lib/browser/uuid.js +2 -4
  69. package/lib/node/Analytics.js +2 -6
  70. package/lib/node/AnonymousUtils.js +7 -12
  71. package/lib/node/Cloud.js +8 -8
  72. package/lib/node/CoreManager.js +59 -67
  73. package/lib/node/CryptoController.js +8 -3
  74. package/lib/node/EventEmitter.js +7 -1
  75. package/lib/node/EventuallyQueue.js +17 -36
  76. package/lib/node/FacebookUtils.js +1 -5
  77. package/lib/node/IndexedDBStorageController.js +14 -10
  78. package/lib/node/InstallationController.js +9 -10
  79. package/lib/node/LiveQueryClient.js +12 -14
  80. package/lib/node/LiveQuerySubscription.js +3 -4
  81. package/lib/node/LocalDatastore.js +20 -20
  82. package/lib/node/LocalDatastoreController.default.js +8 -9
  83. package/lib/node/LocalDatastoreController.js +14 -1
  84. package/lib/node/LocalDatastoreController.react-native.js +25 -21
  85. package/lib/node/LocalDatastoreUtils.js +4 -7
  86. package/lib/node/ObjectStateMutations.js +9 -19
  87. package/lib/node/OfflineQuery.js +37 -23
  88. package/lib/node/Parse.js +33 -47
  89. package/lib/node/ParseACL.js +18 -27
  90. package/lib/node/ParseCLP.js +35 -37
  91. package/lib/node/ParseConfig.js +7 -14
  92. package/lib/node/ParseError.js +457 -458
  93. package/lib/node/ParseFile.js +24 -44
  94. package/lib/node/ParseGeoPoint.js +16 -17
  95. package/lib/node/ParseHooks.js +13 -15
  96. package/lib/node/ParseInstallation.js +7 -8
  97. package/lib/node/ParseLiveQuery.js +6 -11
  98. package/lib/node/ParseObject.js +139 -170
  99. package/lib/node/ParseOp.js +32 -44
  100. package/lib/node/ParsePolygon.js +11 -17
  101. package/lib/node/ParseQuery.js +97 -120
  102. package/lib/node/ParseRelation.js +7 -16
  103. package/lib/node/ParseRole.js +7 -8
  104. package/lib/node/ParseSchema.js +26 -39
  105. package/lib/node/ParseSession.js +7 -8
  106. package/lib/node/ParseUser.js +73 -84
  107. package/lib/node/Push.js +4 -9
  108. package/lib/node/RESTController.js +21 -33
  109. package/lib/node/SingleInstanceStateController.js +41 -69
  110. package/lib/node/Socket.weapp.js +23 -2
  111. package/lib/node/Storage.js +11 -16
  112. package/lib/node/StorageController.browser.js +10 -8
  113. package/lib/node/StorageController.default.js +9 -9
  114. package/lib/node/StorageController.js +16 -1
  115. package/lib/node/StorageController.react-native.js +17 -17
  116. package/lib/node/StorageController.weapp.js +14 -8
  117. package/lib/node/TaskQueue.js +2 -3
  118. package/lib/node/UniqueInstanceStateController.js +40 -60
  119. package/lib/node/WebSocketController.js +15 -2
  120. package/lib/node/Xhr.weapp.js +11 -2
  121. package/lib/node/arrayContainsObject.js +1 -1
  122. package/lib/node/canBeSerialized.js +2 -2
  123. package/lib/node/decode.js +1 -1
  124. package/lib/node/encode.js +2 -2
  125. package/lib/node/equals.js +1 -1
  126. package/lib/node/escape.js +1 -1
  127. package/lib/node/isRevocableSession.js +1 -1
  128. package/lib/node/parseDate.js +1 -1
  129. package/lib/node/promiseUtils.js +7 -7
  130. package/lib/node/unique.js +2 -2
  131. package/lib/node/unsavedChildren.js +2 -2
  132. package/lib/node/uuid.js +2 -4
  133. package/lib/react-native/Analytics.js +2 -2
  134. package/lib/react-native/AnonymousUtils.js +3 -4
  135. package/lib/react-native/CoreManager.js +2 -3
  136. package/lib/react-native/CryptoController.js +6 -1
  137. package/lib/react-native/EventEmitter.js +6 -1
  138. package/lib/react-native/EventuallyQueue.js +1 -2
  139. package/lib/react-native/FacebookUtils.js +1 -2
  140. package/lib/react-native/IndexedDBStorageController.js +11 -5
  141. package/lib/react-native/InstallationController.js +1 -2
  142. package/lib/react-native/LiveQueryClient.js +2 -4
  143. package/lib/react-native/LiveQuerySubscription.js +2 -4
  144. package/lib/react-native/LocalDatastore.js +3 -3
  145. package/lib/react-native/LocalDatastoreController.default.js +1 -2
  146. package/lib/react-native/LocalDatastoreController.js +11 -1
  147. package/lib/react-native/LocalDatastoreController.react-native.js +11 -12
  148. package/lib/react-native/LocalDatastoreUtils.js +3 -6
  149. package/lib/react-native/OfflineQuery.js +25 -20
  150. package/lib/react-native/Parse.js +24 -38
  151. package/lib/react-native/ParseACL.js +4 -6
  152. package/lib/react-native/ParseCLP.js +2 -4
  153. package/lib/react-native/ParseConfig.js +4 -6
  154. package/lib/react-native/ParseError.js +13 -31
  155. package/lib/react-native/ParseFile.js +3 -4
  156. package/lib/react-native/ParseGeoPoint.js +2 -4
  157. package/lib/react-native/ParseInstallation.js +13 -30
  158. package/lib/react-native/ParseLiveQuery.js +2 -4
  159. package/lib/react-native/ParseObject.js +77 -87
  160. package/lib/react-native/ParseOp.js +41 -79
  161. package/lib/react-native/ParsePolygon.js +2 -4
  162. package/lib/react-native/ParseQuery.js +43 -45
  163. package/lib/react-native/ParseRelation.js +2 -4
  164. package/lib/react-native/ParseRole.js +13 -30
  165. package/lib/react-native/ParseSchema.js +3 -5
  166. package/lib/react-native/ParseSession.js +12 -29
  167. package/lib/react-native/ParseUser.js +24 -49
  168. package/lib/react-native/RESTController.js +10 -4
  169. package/lib/react-native/SingleInstanceStateController.js +23 -37
  170. package/lib/react-native/Socket.weapp.js +9 -4
  171. package/lib/react-native/Storage.js +1 -2
  172. package/lib/react-native/StorageController.browser.js +6 -1
  173. package/lib/react-native/StorageController.default.js +6 -1
  174. package/lib/react-native/StorageController.js +13 -1
  175. package/lib/react-native/StorageController.react-native.js +11 -6
  176. package/lib/react-native/StorageController.weapp.js +6 -1
  177. package/lib/react-native/TaskQueue.js +2 -4
  178. package/lib/react-native/UniqueInstanceStateController.js +23 -37
  179. package/lib/react-native/WebSocketController.js +9 -1
  180. package/lib/react-native/Xhr.weapp.js +9 -4
  181. package/lib/react-native/unsavedChildren.js +3 -3
  182. package/lib/react-native/uuid.js +1 -2
  183. package/lib/weapp/Analytics.js +7 -11
  184. package/lib/weapp/AnonymousUtils.js +17 -22
  185. package/lib/weapp/Cloud.js +23 -41
  186. package/lib/weapp/CoreManager.js +71 -79
  187. package/lib/weapp/CryptoController.js +14 -9
  188. package/lib/weapp/EventEmitter.js +9 -2
  189. package/lib/weapp/EventuallyQueue.js +156 -357
  190. package/lib/weapp/FacebookUtils.js +23 -28
  191. package/lib/weapp/IndexedDBStorageController.js +18 -14
  192. package/lib/weapp/InstallationController.js +55 -121
  193. package/lib/weapp/LiveQueryClient.js +308 -484
  194. package/lib/weapp/LiveQuerySubscription.js +25 -28
  195. package/lib/weapp/LocalDatastore.js +258 -624
  196. package/lib/weapp/LocalDatastoreController.default.js +42 -226
  197. package/lib/weapp/LocalDatastoreController.js +11 -1
  198. package/lib/weapp/LocalDatastoreController.react-native.js +66 -160
  199. package/lib/weapp/LocalDatastoreUtils.js +4 -7
  200. package/lib/weapp/ObjectStateMutations.js +54 -96
  201. package/lib/weapp/OfflineQuery.js +106 -198
  202. package/lib/weapp/Parse.js +44 -59
  203. package/lib/weapp/ParseACL.js +242 -288
  204. package/lib/weapp/ParseCLP.js +372 -572
  205. package/lib/weapp/ParseConfig.js +115 -138
  206. package/lib/weapp/ParseError.js +85 -182
  207. package/lib/weapp/ParseFile.js +295 -440
  208. package/lib/weapp/ParseGeoPoint.js +121 -146
  209. package/lib/weapp/ParseHooks.js +23 -25
  210. package/lib/weapp/ParseInstallation.js +225 -367
  211. package/lib/weapp/ParseLiveQuery.js +74 -148
  212. package/lib/weapp/ParseObject.js +2014 -2621
  213. package/lib/weapp/ParseOp.js +343 -484
  214. package/lib/weapp/ParsePolygon.js +101 -120
  215. package/lib/weapp/ParseQuery.js +1708 -2052
  216. package/lib/weapp/ParseRelation.js +99 -118
  217. package/lib/weapp/ParseRole.js +88 -140
  218. package/lib/weapp/ParseSchema.js +372 -434
  219. package/lib/weapp/ParseSession.js +62 -110
  220. package/lib/weapp/ParseUser.js +941 -1284
  221. package/lib/weapp/Push.js +15 -38
  222. package/lib/weapp/RESTController.js +86 -125
  223. package/lib/weapp/SingleInstanceStateController.js +57 -86
  224. package/lib/weapp/Socket.weapp.js +50 -33
  225. package/lib/weapp/Storage.js +23 -28
  226. package/lib/weapp/StorageController.browser.js +16 -13
  227. package/lib/weapp/StorageController.default.js +15 -14
  228. package/lib/weapp/StorageController.js +14 -1
  229. package/lib/weapp/StorageController.react-native.js +31 -30
  230. package/lib/weapp/StorageController.weapp.js +19 -13
  231. package/lib/weapp/TaskQueue.js +31 -43
  232. package/lib/weapp/UniqueInstanceStateController.js +65 -86
  233. package/lib/weapp/WebSocketController.js +11 -4
  234. package/lib/weapp/Xhr.weapp.js +90 -78
  235. package/lib/weapp/arrayContainsObject.js +3 -3
  236. package/lib/weapp/canBeSerialized.js +10 -11
  237. package/lib/weapp/decode.js +11 -11
  238. package/lib/weapp/encode.js +11 -11
  239. package/lib/weapp/equals.js +9 -10
  240. package/lib/weapp/escape.js +2 -2
  241. package/lib/weapp/isRevocableSession.js +1 -1
  242. package/lib/weapp/parseDate.js +10 -10
  243. package/lib/weapp/promiseUtils.js +19 -19
  244. package/lib/weapp/unique.js +4 -4
  245. package/lib/weapp/unsavedChildren.js +20 -21
  246. package/lib/weapp/uuid.js +6 -8
  247. package/package.json +19 -25
@@ -1,102 +1,27 @@
1
1
  "use strict";
2
2
 
3
- var _sliceInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/slice");
4
- var _Array$from = require("@babel/runtime-corejs3/core-js-stable/array/from");
5
- var _Symbol = require("@babel/runtime-corejs3/core-js-stable/symbol");
6
- var _getIteratorMethod = require("@babel/runtime-corejs3/core-js/get-iterator-method");
7
- var _Array$isArray = require("@babel/runtime-corejs3/core-js-stable/array/is-array");
8
3
  var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
9
4
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
10
5
  _Object$defineProperty(exports, "__esModule", {
11
6
  value: true
12
7
  });
13
8
  exports.default = void 0;
14
- var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator"));
15
9
  var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
16
10
  var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/map"));
17
- var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
18
11
  var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/keys"));
19
12
  var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
20
13
  var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
21
14
  var _values = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/values"));
22
15
  var _setTimeout2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set-timeout"));
23
16
  var _bind = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/bind"));
24
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
25
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
26
- var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
27
17
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
28
18
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
29
19
  var _ParseObject = _interopRequireDefault(require("./ParseObject"));
30
20
  var _LiveQuerySubscription = _interopRequireDefault(require("./LiveQuerySubscription"));
31
21
  var _promiseUtils = require("./promiseUtils");
32
22
  var _ParseError = _interopRequireDefault(require("./ParseError"));
33
- function _createForOfIteratorHelper(o, allowArrayLike) {
34
- var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
35
- if (!it) {
36
- if (_Array$isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
37
- if (it) o = it;
38
- var i = 0;
39
- var F = function () {};
40
- return {
41
- s: F,
42
- n: function () {
43
- if (i >= o.length) return {
44
- done: true
45
- };
46
- return {
47
- done: false,
48
- value: o[i++]
49
- };
50
- },
51
- e: function (_e) {
52
- throw _e;
53
- },
54
- f: F
55
- };
56
- }
57
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
58
- }
59
- var normalCompletion = true,
60
- didErr = false,
61
- err;
62
- return {
63
- s: function () {
64
- it = it.call(o);
65
- },
66
- n: function () {
67
- var step = it.next();
68
- normalCompletion = step.done;
69
- return step;
70
- },
71
- e: function (_e2) {
72
- didErr = true;
73
- err = _e2;
74
- },
75
- f: function () {
76
- try {
77
- if (!normalCompletion && it.return != null) it.return();
78
- } finally {
79
- if (didErr) throw err;
80
- }
81
- }
82
- };
83
- }
84
- function _unsupportedIterableToArray(o, minLen) {
85
- var _context9;
86
- if (!o) return;
87
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
88
- var n = _sliceInstanceProperty(_context9 = Object.prototype.toString.call(o)).call(_context9, 8, -1);
89
- if (n === "Object" && o.constructor) n = o.constructor.name;
90
- if (n === "Map" || n === "Set") return _Array$from(o);
91
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
92
- }
93
- function _arrayLikeToArray(arr, len) {
94
- if (len == null || len > arr.length) len = arr.length;
95
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
96
- return arr2;
97
- }
98
23
  // The LiveQuery client inner state
99
- var CLIENT_STATE = {
24
+ const CLIENT_STATE = {
100
25
  INITIALIZED: 'initialized',
101
26
  CONNECTING: 'connecting',
102
27
  CONNECTED: 'connected',
@@ -106,7 +31,7 @@ var CLIENT_STATE = {
106
31
  };
107
32
 
108
33
  // The event type the LiveQuery client should sent to server
109
- var OP_TYPES = {
34
+ const OP_TYPES = {
110
35
  CONNECT: 'connect',
111
36
  SUBSCRIBE: 'subscribe',
112
37
  UNSUBSCRIBE: 'unsubscribe',
@@ -114,7 +39,7 @@ var OP_TYPES = {
114
39
  };
115
40
 
116
41
  // The event we get back from LiveQuery server
117
- var OP_EVENTS = {
42
+ const OP_EVENTS = {
118
43
  CONNECTED: 'connected',
119
44
  SUBSCRIBED: 'subscribed',
120
45
  UNSUBSCRIBED: 'unsubscribed',
@@ -127,14 +52,14 @@ var OP_EVENTS = {
127
52
  };
128
53
 
129
54
  // The event the LiveQuery client should emit
130
- var CLIENT_EMMITER_TYPES = {
55
+ const CLIENT_EMMITER_TYPES = {
131
56
  CLOSE: 'close',
132
57
  ERROR: 'error',
133
58
  OPEN: 'open'
134
59
  };
135
60
 
136
61
  // The event the LiveQuery subscription should emit
137
- var SUBSCRIPTION_EMMITER_TYPES = {
62
+ const SUBSCRIPTION_EMMITER_TYPES = {
138
63
  OPEN: 'open',
139
64
  CLOSE: 'close',
140
65
  ERROR: 'error',
@@ -144,7 +69,7 @@ var SUBSCRIPTION_EMMITER_TYPES = {
144
69
  LEAVE: 'leave',
145
70
  DELETE: 'delete'
146
71
  };
147
- var generateInterval = function (k) {
72
+ const generateInterval = k => {
148
73
  return Math.random() * Math.min(30, Math.pow(2, k) - 1) * 1000;
149
74
  };
150
75
 
@@ -161,9 +86,8 @@ var generateInterval = function (k) {
161
86
  * We expose three events to help you monitor the status of the LiveQueryClient.
162
87
  *
163
88
  * <pre>
164
- * let Parse = require('parse/node');
165
- * let LiveQueryClient = Parse.LiveQueryClient;
166
- * let client = new LiveQueryClient({
89
+ * const LiveQueryClient = Parse.LiveQueryClient;
90
+ * const client = new LiveQueryClient({
167
91
  * applicationId: '',
168
92
  * serverURL: '',
169
93
  * javascriptKey: '',
@@ -191,7 +115,7 @@ var generateInterval = function (k) {
191
115
  *
192
116
  * @alias Parse.LiveQueryClient
193
117
  */
194
- var LiveQueryClient = /*#__PURE__*/function () {
118
+ class LiveQueryClient {
195
119
  /**
196
120
  * @param {object} options
197
121
  * @param {string} options.applicationId - applicationId of your Parse app
@@ -201,15 +125,16 @@ var LiveQueryClient = /*#__PURE__*/function () {
201
125
  * @param {string} options.sessionToken (optional)
202
126
  * @param {string} options.installationId (optional)
203
127
  */
204
- function LiveQueryClient(_ref) {
128
+ constructor(_ref) {
205
129
  var _this = this;
206
- var applicationId = _ref.applicationId,
207
- serverURL = _ref.serverURL,
208
- javascriptKey = _ref.javascriptKey,
209
- masterKey = _ref.masterKey,
210
- sessionToken = _ref.sessionToken,
211
- installationId = _ref.installationId;
212
- (0, _classCallCheck2.default)(this, LiveQueryClient);
130
+ let {
131
+ applicationId,
132
+ serverURL,
133
+ javascriptKey,
134
+ masterKey,
135
+ sessionToken,
136
+ installationId
137
+ } = _ref;
213
138
  (0, _defineProperty2.default)(this, "attempts", void 0);
214
139
  (0, _defineProperty2.default)(this, "id", void 0);
215
140
  (0, _defineProperty2.default)(this, "requestId", void 0);
@@ -245,436 +170,335 @@ var LiveQueryClient = /*#__PURE__*/function () {
245
170
  this.connectPromise = (0, _promiseUtils.resolvingPromise)();
246
171
  this.subscriptions = new _map.default();
247
172
  this.state = CLIENT_STATE.INITIALIZED;
248
- var EventEmitter = _CoreManager.default.getEventEmitter();
173
+ const EventEmitter = _CoreManager.default.getEventEmitter();
249
174
  this.emitter = new EventEmitter();
250
- this.on = function (eventName, listener) {
251
- return _this.emitter.on(eventName, listener);
252
- };
175
+ this.on = (eventName, listener) => this.emitter.on(eventName, listener);
253
176
  this.emit = function (eventName) {
254
- var _this$emitter, _context;
255
177
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
256
178
  args[_key - 1] = arguments[_key];
257
179
  }
258
- return (_this$emitter = _this.emitter).emit.apply(_this$emitter, (0, _concat.default)(_context = [eventName]).call(_context, args));
180
+ return _this.emitter.emit(eventName, ...args);
259
181
  };
260
182
  // adding listener so process does not crash
261
183
  // best practice is for developer to register their own listener
262
- this.on('error', function () {});
184
+ this.on('error', () => {});
185
+ }
186
+ shouldOpen() {
187
+ return this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED;
263
188
  }
264
- (0, _createClass2.default)(LiveQueryClient, [{
265
- key: "shouldOpen",
266
- value: function () /*: any*/{
267
- return this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED;
189
+
190
+ /**
191
+ * Subscribes to a ParseQuery
192
+ *
193
+ * If you provide the sessionToken, when the LiveQuery server gets ParseObject's
194
+ * updates from parse server, it'll try to check whether the sessionToken fulfills
195
+ * the ParseObject's ACL. The LiveQuery server will only send updates to clients whose
196
+ * sessionToken is fit for the ParseObject's ACL. You can check the LiveQuery protocol
197
+ * <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
198
+ * from our Standard API.
199
+ *
200
+ * @param {ParseQuery} query - the ParseQuery you want to subscribe to
201
+ * @param {string} sessionToken (optional)
202
+ * @returns {LiveQuerySubscription | undefined}
203
+ */
204
+ subscribe(query, sessionToken) {
205
+ if (!query) {
206
+ return;
268
207
  }
208
+ const className = query.className;
209
+ const queryJSON = query.toJSON();
210
+ const where = queryJSON.where;
211
+ const keys = (0, _keys.default)(queryJSON)?.split(',');
212
+ const watch = queryJSON.watch?.split(',');
213
+ const subscribeRequest = {
214
+ op: OP_TYPES.SUBSCRIBE,
215
+ requestId: this.requestId,
216
+ query: {
217
+ className,
218
+ where,
219
+ keys,
220
+ watch
221
+ },
222
+ sessionToken: undefined
223
+ };
224
+ if (sessionToken) {
225
+ subscribeRequest.sessionToken = sessionToken;
226
+ }
227
+ const subscription = new _LiveQuerySubscription.default(this.requestId, query, sessionToken);
228
+ this.subscriptions.set(this.requestId, subscription);
229
+ this.requestId += 1;
230
+ this.connectPromise.then(() => {
231
+ this.socket.send((0, _stringify.default)(subscribeRequest));
232
+ }).catch(error => {
233
+ subscription.subscribePromise.reject(error);
234
+ });
235
+ return subscription;
236
+ }
269
237
 
270
- /**
271
- * Subscribes to a ParseQuery
272
- *
273
- * If you provide the sessionToken, when the LiveQuery server gets ParseObject's
274
- * updates from parse server, it'll try to check whether the sessionToken fulfills
275
- * the ParseObject's ACL. The LiveQuery server will only send updates to clients whose
276
- * sessionToken is fit for the ParseObject's ACL. You can check the LiveQuery protocol
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
278
- * from our Standard API.
279
- *
280
- * @param {ParseQuery} query - the ParseQuery you want to subscribe to
281
- * @param {string} sessionToken (optional)
282
- * @returns {LiveQuerySubscription | undefined}
283
- */
284
- }, {
285
- key: "subscribe",
286
- value: function (query /*: ParseQuery*/, sessionToken /*:: ?: string*/) /*: LiveQuerySubscription | undefined*/{
287
- var _queryJSON$keys,
288
- _queryJSON$watch,
289
- _this2 = this;
290
- if (!query) {
291
- return;
292
- }
293
- var className = query.className;
294
- var queryJSON = query.toJSON();
295
- var where = queryJSON.where;
296
- var keys = (_queryJSON$keys = (0, _keys.default)(queryJSON)) === null || _queryJSON$keys === void 0 ? void 0 : _queryJSON$keys.split(',');
297
- var watch = (_queryJSON$watch = queryJSON.watch) === null || _queryJSON$watch === void 0 ? void 0 : _queryJSON$watch.split(',');
298
- var subscribeRequest = {
238
+ /**
239
+ * After calling unsubscribe you'll stop receiving events from the subscription object.
240
+ *
241
+ * @param {object} subscription - subscription you would like to unsubscribe from.
242
+ * @returns {Promise | undefined}
243
+ */
244
+ async unsubscribe(subscription) {
245
+ if (!subscription) {
246
+ return;
247
+ }
248
+ const unsubscribeRequest = {
249
+ op: OP_TYPES.UNSUBSCRIBE,
250
+ requestId: subscription.id
251
+ };
252
+ return this.connectPromise.then(() => {
253
+ return this.socket.send((0, _stringify.default)(unsubscribeRequest));
254
+ }).then(() => {
255
+ return subscription.unsubscribePromise;
256
+ });
257
+ }
258
+
259
+ /**
260
+ * After open is called, the LiveQueryClient will try to send a connect request
261
+ * to the LiveQuery server.
262
+ *
263
+ */
264
+ open() {
265
+ const WebSocketImplementation = _CoreManager.default.getWebSocketController();
266
+ if (!WebSocketImplementation) {
267
+ this.emit(CLIENT_EMMITER_TYPES.ERROR, 'Can not find WebSocket implementation');
268
+ return;
269
+ }
270
+ if (this.state !== CLIENT_STATE.RECONNECTING) {
271
+ this.state = CLIENT_STATE.CONNECTING;
272
+ }
273
+ this.socket = new WebSocketImplementation(this.serverURL);
274
+ this.socket.closingPromise = (0, _promiseUtils.resolvingPromise)();
275
+
276
+ // Bind WebSocket callbacks
277
+ this.socket.onopen = () => {
278
+ this._handleWebSocketOpen();
279
+ };
280
+ this.socket.onmessage = event => {
281
+ this._handleWebSocketMessage(event);
282
+ };
283
+ this.socket.onclose = event => {
284
+ this.socket.closingPromise?.resolve(event);
285
+ this._handleWebSocketClose();
286
+ };
287
+ this.socket.onerror = error => {
288
+ this._handleWebSocketError(error);
289
+ };
290
+ }
291
+ resubscribe() {
292
+ var _context;
293
+ (0, _forEach.default)(_context = this.subscriptions).call(_context, (subscription, requestId) => {
294
+ const query = subscription.query;
295
+ const queryJSON = query.toJSON();
296
+ const where = queryJSON.where;
297
+ const fields = (0, _keys.default)(queryJSON) ? (0, _keys.default)(queryJSON).split(',') : undefined;
298
+ const className = query.className;
299
+ const sessionToken = subscription.sessionToken;
300
+ const subscribeRequest = {
299
301
  op: OP_TYPES.SUBSCRIBE,
300
- requestId: this.requestId,
302
+ requestId,
301
303
  query: {
302
- className: className,
303
- where: where,
304
- keys: keys,
305
- watch: watch
304
+ className,
305
+ where,
306
+ fields
306
307
  },
307
308
  sessionToken: undefined
308
309
  };
309
310
  if (sessionToken) {
310
311
  subscribeRequest.sessionToken = sessionToken;
311
312
  }
312
- var subscription = new _LiveQuerySubscription.default(this.requestId, query, sessionToken);
313
- this.subscriptions.set(this.requestId, subscription);
314
- this.requestId += 1;
315
- this.connectPromise.then(function () {
316
- _this2.socket.send((0, _stringify.default)(subscribeRequest));
317
- }).catch(function (error) {
318
- subscription.subscribePromise.reject(error);
313
+ this.connectPromise.then(() => {
314
+ this.socket.send((0, _stringify.default)(subscribeRequest));
319
315
  });
320
- return subscription;
321
- }
322
-
323
- /**
324
- * After calling unsubscribe you'll stop receiving events from the subscription object.
325
- *
326
- * @param {object} subscription - subscription you would like to unsubscribe from.
327
- * @returns {Promise | undefined}
328
- */
329
- }, {
330
- key: "unsubscribe",
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);
361
- }
362
- return unsubscribe;
363
- }()
364
- /**
365
- * After open is called, the LiveQueryClient will try to send a connect request
366
- * to the LiveQuery server.
367
- *
368
- */
369
- }, {
370
- key: "open",
371
- value: function () {
372
- var _this4 = this;
373
- var WebSocketImplementation = _CoreManager.default.getWebSocketController();
374
- if (!WebSocketImplementation) {
375
- this.emit(CLIENT_EMMITER_TYPES.ERROR, 'Can not find WebSocket implementation');
376
- return;
377
- }
378
- if (this.state !== CLIENT_STATE.RECONNECTING) {
379
- this.state = CLIENT_STATE.CONNECTING;
380
- }
381
- this.socket = new WebSocketImplementation(this.serverURL);
382
- this.socket.closingPromise = (0, _promiseUtils.resolvingPromise)();
316
+ });
317
+ }
383
318
 
384
- // Bind WebSocket callbacks
385
- this.socket.onopen = function () {
386
- _this4._handleWebSocketOpen();
387
- };
388
- this.socket.onmessage = function (event) {
389
- _this4._handleWebSocketMessage(event);
390
- };
391
- this.socket.onclose = function (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);
394
- _this4._handleWebSocketClose();
395
- };
396
- this.socket.onerror = function (error) {
397
- _this4._handleWebSocketError(error);
398
- };
319
+ /**
320
+ * This method will close the WebSocket connection to this LiveQueryClient,
321
+ * cancel the auto reconnect and unsubscribe all subscriptions based on it.
322
+ *
323
+ * @returns {Promise | undefined} CloseEvent {@link https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close_event}
324
+ */
325
+ async close() {
326
+ if (this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED) {
327
+ return;
399
328
  }
400
- }, {
401
- key: "resubscribe",
402
- value: function () {
403
- var _context3,
404
- _this5 = this;
405
- (0, _forEach.default)(_context3 = this.subscriptions).call(_context3, function (subscription, requestId) {
406
- var query = subscription.query;
407
- var queryJSON = query.toJSON();
408
- var where = queryJSON.where;
409
- var fields = (0, _keys.default)(queryJSON) ? (0, _keys.default)(queryJSON).split(',') : undefined;
410
- var className = query.className;
411
- var sessionToken = subscription.sessionToken;
412
- var subscribeRequest = {
413
- op: OP_TYPES.SUBSCRIBE,
414
- requestId: requestId,
415
- query: {
416
- className: className,
417
- where: where,
418
- fields: fields
419
- },
420
- sessionToken: undefined
421
- };
422
- if (sessionToken) {
423
- subscribeRequest.sessionToken = sessionToken;
424
- }
425
- _this5.connectPromise.then(function () {
426
- _this5.socket.send((0, _stringify.default)(subscribeRequest));
427
- });
428
- });
329
+ this.state = CLIENT_STATE.DISCONNECTED;
330
+ this.socket?.close();
331
+ // Notify each subscription about the close
332
+ for (const subscription of (0, _values.default)(_context2 = this.subscriptions).call(_context2)) {
333
+ var _context2;
334
+ subscription.subscribed = false;
335
+ subscription.emit(SUBSCRIPTION_EMMITER_TYPES.CLOSE);
429
336
  }
337
+ this._handleReset();
338
+ this.emit(CLIENT_EMMITER_TYPES.CLOSE);
339
+ return this.socket?.closingPromise;
340
+ }
430
341
 
431
- /**
432
- * This method will close the WebSocket connection to this LiveQueryClient,
433
- * cancel the auto reconnect and unsubscribe all subscriptions based on it.
434
- *
435
- * @returns {Promise | undefined} CloseEvent {@link https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close_event}
436
- */
437
- }, {
438
- key: "close",
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);
478
- }
479
- return close;
480
- }() // ensure we start with valid state if connect is called again after close
481
- }, {
482
- key: "_handleReset",
483
- value: function () {
484
- this.attempts = 1;
485
- this.id = 0;
486
- this.requestId = 1;
487
- this.connectPromise = (0, _promiseUtils.resolvingPromise)();
488
- this.subscriptions = new _map.default();
342
+ // ensure we start with valid state if connect is called again after close
343
+ _handleReset() {
344
+ this.attempts = 1;
345
+ this.id = 0;
346
+ this.requestId = 1;
347
+ this.connectPromise = (0, _promiseUtils.resolvingPromise)();
348
+ this.subscriptions = new _map.default();
349
+ }
350
+ _handleWebSocketOpen() {
351
+ this.attempts = 1;
352
+ const connectRequest = {
353
+ op: OP_TYPES.CONNECT,
354
+ applicationId: this.applicationId,
355
+ javascriptKey: this.javascriptKey,
356
+ masterKey: this.masterKey,
357
+ sessionToken: this.sessionToken,
358
+ installationId: undefined
359
+ };
360
+ if (this.additionalProperties) {
361
+ connectRequest.installationId = this.installationId;
489
362
  }
490
- }, {
491
- key: "_handleWebSocketOpen",
492
- value: function () {
493
- this.attempts = 1;
494
- var connectRequest = {
495
- op: OP_TYPES.CONNECT,
496
- applicationId: this.applicationId,
497
- javascriptKey: this.javascriptKey,
498
- masterKey: this.masterKey,
499
- sessionToken: this.sessionToken,
500
- installationId: undefined
501
- };
502
- if (this.additionalProperties) {
503
- connectRequest.installationId = this.installationId;
504
- }
505
- this.socket.send((0, _stringify.default)(connectRequest));
363
+ this.socket.send((0, _stringify.default)(connectRequest));
364
+ }
365
+ _handleWebSocketMessage(event) {
366
+ let data = event.data;
367
+ if (typeof data === 'string') {
368
+ data = JSON.parse(data);
506
369
  }
507
- }, {
508
- key: "_handleWebSocketMessage",
509
- value: function (event /*: any*/) {
510
- var data = event.data;
511
- if (typeof data === 'string') {
512
- data = JSON.parse(data);
513
- }
514
- var subscription /*: null | LiveQuerySubscription*/ = null;
515
- if (data.requestId) {
516
- subscription = this.subscriptions.get(data.requestId) || null;
517
- }
518
- var response = {
519
- clientId: data.clientId,
520
- installationId: data.installationId
521
- };
522
- switch (data.op) {
523
- case OP_EVENTS.CONNECTED:
524
- if (this.state === CLIENT_STATE.RECONNECTING) {
525
- this.resubscribe();
370
+ let subscription = null;
371
+ if (data.requestId) {
372
+ subscription = this.subscriptions.get(data.requestId) || null;
373
+ }
374
+ const response = {
375
+ clientId: data.clientId,
376
+ installationId: data.installationId
377
+ };
378
+ switch (data.op) {
379
+ case OP_EVENTS.CONNECTED:
380
+ if (this.state === CLIENT_STATE.RECONNECTING) {
381
+ this.resubscribe();
382
+ }
383
+ this.emit(CLIENT_EMMITER_TYPES.OPEN);
384
+ this.id = data.clientId;
385
+ this.connectPromise.resolve();
386
+ this.state = CLIENT_STATE.CONNECTED;
387
+ break;
388
+ case OP_EVENTS.SUBSCRIBED:
389
+ if (subscription) {
390
+ subscription.subscribed = true;
391
+ subscription.subscribePromise.resolve();
392
+ (0, _setTimeout2.default)(() => subscription.emit(SUBSCRIPTION_EMMITER_TYPES.OPEN, response), 200);
393
+ }
394
+ break;
395
+ case OP_EVENTS.ERROR:
396
+ {
397
+ const parseError = new _ParseError.default(data.code, data.error);
398
+ if (!this.id) {
399
+ this.connectPromise.reject(parseError);
400
+ this.state = CLIENT_STATE.DISCONNECTED;
401
+ }
402
+ if (data.requestId) {
403
+ if (subscription) {
404
+ subscription.subscribePromise.reject(parseError);
405
+ (0, _setTimeout2.default)(() => subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, data.error), 200);
406
+ }
407
+ } else {
408
+ this.emit(CLIENT_EMMITER_TYPES.ERROR, data.error);
409
+ }
410
+ if (data.error === 'Additional properties not allowed') {
411
+ this.additionalProperties = false;
412
+ }
413
+ if (data.reconnect) {
414
+ this._handleReconnect();
526
415
  }
527
- this.emit(CLIENT_EMMITER_TYPES.OPEN);
528
- this.id = data.clientId;
529
- this.connectPromise.resolve();
530
- this.state = CLIENT_STATE.CONNECTED;
531
416
  break;
532
- case OP_EVENTS.SUBSCRIBED:
417
+ }
418
+ case OP_EVENTS.UNSUBSCRIBED:
419
+ {
533
420
  if (subscription) {
534
- subscription.subscribed = true;
535
- subscription.subscribePromise.resolve();
536
- (0, _setTimeout2.default)(function () {
537
- return subscription.emit(SUBSCRIPTION_EMMITER_TYPES.OPEN, response);
538
- }, 200);
421
+ this.subscriptions.delete(data.requestId);
422
+ subscription.subscribed = false;
423
+ subscription.unsubscribePromise.resolve();
539
424
  }
540
425
  break;
541
- case OP_EVENTS.ERROR:
542
- {
543
- var parseError = new _ParseError.default(data.code, data.error);
544
- if (!this.id) {
545
- this.connectPromise.reject(parseError);
546
- this.state = CLIENT_STATE.DISCONNECTED;
547
- }
548
- if (data.requestId) {
549
- if (subscription) {
550
- subscription.subscribePromise.reject(parseError);
551
- (0, _setTimeout2.default)(function () {
552
- return subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, data.error);
553
- }, 200);
554
- }
555
- } else {
556
- this.emit(CLIENT_EMMITER_TYPES.ERROR, data.error);
557
- }
558
- if (data.error === 'Additional properties not allowed') {
559
- this.additionalProperties = false;
560
- }
561
- if (data.reconnect) {
562
- this._handleReconnect();
563
- }
564
- break;
565
- }
566
- case OP_EVENTS.UNSUBSCRIBED:
567
- {
568
- if (subscription) {
569
- this.subscriptions.delete(data.requestId);
570
- subscription.subscribed = false;
571
- subscription.unsubscribePromise.resolve();
572
- }
426
+ }
427
+ default:
428
+ {
429
+ // create, update, enter, leave, delete cases
430
+ if (!subscription) {
573
431
  break;
574
432
  }
575
- default:
576
- {
577
- // create, update, enter, leave, delete cases
578
- if (!subscription) {
579
- break;
580
- }
581
- var override = false;
582
- if (data.original) {
583
- override = true;
584
- delete data.original.__type;
585
- // Check for removed fields
586
- for (var field in data.original) {
587
- if (!(field in data.object)) {
588
- data.object[field] = undefined;
589
- }
433
+ let override = false;
434
+ if (data.original) {
435
+ override = true;
436
+ delete data.original.__type;
437
+ // Check for removed fields
438
+ for (const field in data.original) {
439
+ if (!(field in data.object)) {
440
+ data.object[field] = undefined;
590
441
  }
591
- data.original = _ParseObject.default.fromJSON(data.original, false);
592
- }
593
- delete data.object.__type;
594
- var parseObject = _ParseObject.default.fromJSON(data.object, !(subscription.query && subscription.query._select) ? override : false);
595
- if (data.original) {
596
- subscription.emit(data.op, parseObject, data.original, response);
597
- } else {
598
- subscription.emit(data.op, parseObject, response);
599
- }
600
- var localDatastore = _CoreManager.default.getLocalDatastore();
601
- if (override && localDatastore.isEnabled) {
602
- localDatastore._updateObjectIfPinned(parseObject).then(function () {});
603
442
  }
443
+ data.original = _ParseObject.default.fromJSON(data.original, false);
444
+ }
445
+ delete data.object.__type;
446
+ const parseObject = _ParseObject.default.fromJSON(data.object, !(subscription.query && subscription.query._select) ? override : false);
447
+ if (data.original) {
448
+ subscription.emit(data.op, parseObject, data.original, response);
449
+ } else {
450
+ subscription.emit(data.op, parseObject, response);
451
+ }
452
+ const localDatastore = _CoreManager.default.getLocalDatastore();
453
+ if (override && localDatastore.isEnabled) {
454
+ localDatastore._updateObjectIfPinned(parseObject).then(() => {});
604
455
  }
605
- }
606
- }
607
- }, {
608
- key: "_handleWebSocketClose",
609
- value: function () {
610
- var _context6;
611
- if (this.state === CLIENT_STATE.DISCONNECTED) {
612
- return;
613
- }
614
- this.state = CLIENT_STATE.CLOSED;
615
- this.emit(CLIENT_EMMITER_TYPES.CLOSE);
616
- // Notify each subscription about the close
617
- var _iterator2 = _createForOfIteratorHelper((0, _values.default)(_context6 = this.subscriptions).call(_context6)),
618
- _step2;
619
- try {
620
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
621
- var subscription = _step2.value;
622
- subscription.emit(SUBSCRIPTION_EMMITER_TYPES.CLOSE);
623
456
  }
624
- } catch (err) {
625
- _iterator2.e(err);
626
- } finally {
627
- _iterator2.f();
628
- }
629
- this._handleReconnect();
630
457
  }
631
- }, {
632
- key: "_handleWebSocketError",
633
- value: function (error /*: any*/) {
634
- var _context7;
635
- this.emit(CLIENT_EMMITER_TYPES.ERROR, error);
636
- var _iterator3 = _createForOfIteratorHelper((0, _values.default)(_context7 = this.subscriptions).call(_context7)),
637
- _step3;
638
- try {
639
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
640
- var subscription = _step3.value;
641
- subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, error);
642
- }
643
- } catch (err) {
644
- _iterator3.e(err);
645
- } finally {
646
- _iterator3.f();
647
- }
648
- this._handleReconnect();
458
+ }
459
+ _handleWebSocketClose() {
460
+ if (this.state === CLIENT_STATE.DISCONNECTED) {
461
+ return;
649
462
  }
650
- }, {
651
- key: "_handleReconnect",
652
- value: function () {
653
- var _context8,
654
- _this6 = this;
655
- // if closed or currently reconnecting we stop attempting to reconnect
656
- if (this.state === CLIENT_STATE.DISCONNECTED) {
657
- return;
658
- }
659
- this.state = CLIENT_STATE.RECONNECTING;
660
- var time = generateInterval(this.attempts);
463
+ this.state = CLIENT_STATE.CLOSED;
464
+ this.emit(CLIENT_EMMITER_TYPES.CLOSE);
465
+ // Notify each subscription about the close
466
+ for (const subscription of (0, _values.default)(_context3 = this.subscriptions).call(_context3)) {
467
+ var _context3;
468
+ subscription.emit(SUBSCRIPTION_EMMITER_TYPES.CLOSE);
469
+ }
470
+ this._handleReconnect();
471
+ }
472
+ _handleWebSocketError(error) {
473
+ this.emit(CLIENT_EMMITER_TYPES.ERROR, error);
474
+ for (const subscription of (0, _values.default)(_context4 = this.subscriptions).call(_context4)) {
475
+ var _context4;
476
+ subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, error);
477
+ }
478
+ this._handleReconnect();
479
+ }
480
+ _handleReconnect() {
481
+ var _context5;
482
+ // if closed or currently reconnecting we stop attempting to reconnect
483
+ if (this.state === CLIENT_STATE.DISCONNECTED) {
484
+ return;
485
+ }
486
+ this.state = CLIENT_STATE.RECONNECTING;
487
+ const time = generateInterval(this.attempts);
661
488
 
662
- // handle case when both close/error occur at frequent rates we ensure we do not reconnect unnecessarily.
663
- // we're unable to distinguish different between close/error when we're unable to reconnect therefore
664
- // we try to reconnect in both cases
665
- // server side ws and browser WebSocket behave differently in when close/error get triggered
489
+ // handle case when both close/error occur at frequent rates we ensure we do not reconnect unnecessarily.
490
+ // we're unable to distinguish different between close/error when we're unable to reconnect therefore
491
+ // we try to reconnect in both cases
492
+ // server side ws and browser WebSocket behave differently in when close/error get triggered
666
493
 
667
- if (this.reconnectHandle) {
668
- clearTimeout(this.reconnectHandle);
669
- }
670
- this.reconnectHandle = (0, _setTimeout2.default)((0, _bind.default)(_context8 = function () {
671
- _this6.attempts++;
672
- _this6.connectPromise = (0, _promiseUtils.resolvingPromise)();
673
- _this6.open();
674
- }).call(_context8, this), time);
494
+ if (this.reconnectHandle) {
495
+ clearTimeout(this.reconnectHandle);
675
496
  }
676
- }]);
677
- return LiveQueryClient;
678
- }();
679
- var _default = LiveQueryClient;
680
- exports.default = _default;
497
+ this.reconnectHandle = (0, _setTimeout2.default)((0, _bind.default)(_context5 = () => {
498
+ this.attempts++;
499
+ this.connectPromise = (0, _promiseUtils.resolvingPromise)();
500
+ this.open();
501
+ }).call(_context5, this), time);
502
+ }
503
+ }
504
+ var _default = exports.default = LiveQueryClient;