parse 5.2.0-alpha.1 → 5.2.0-alpha.3

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 +10519 -15246
  2. package/dist/parse.min.js +2 -2
  3. package/dist/parse.weapp.js +10499 -15371
  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 +312 -485
  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 +5 -9
  70. package/lib/node/AnonymousUtils.js +10 -15
  71. package/lib/node/Cloud.js +11 -11
  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 +20 -39
  76. package/lib/node/FacebookUtils.js +4 -8
  77. package/lib/node/IndexedDBStorageController.js +14 -10
  78. package/lib/node/InstallationController.js +12 -13
  79. package/lib/node/LiveQueryClient.js +23 -21
  80. package/lib/node/LiveQuerySubscription.js +6 -7
  81. package/lib/node/LocalDatastore.js +23 -23
  82. package/lib/node/LocalDatastoreController.default.js +11 -12
  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 +12 -22
  87. package/lib/node/OfflineQuery.js +37 -23
  88. package/lib/node/Parse.js +36 -50
  89. package/lib/node/ParseACL.js +21 -30
  90. package/lib/node/ParseCLP.js +38 -40
  91. package/lib/node/ParseConfig.js +10 -17
  92. package/lib/node/ParseError.js +460 -461
  93. package/lib/node/ParseFile.js +27 -47
  94. package/lib/node/ParseGeoPoint.js +16 -17
  95. package/lib/node/ParseHooks.js +16 -18
  96. package/lib/node/ParseInstallation.js +10 -11
  97. package/lib/node/ParseLiveQuery.js +9 -14
  98. package/lib/node/ParseObject.js +142 -173
  99. package/lib/node/ParseOp.js +35 -47
  100. package/lib/node/ParsePolygon.js +14 -20
  101. package/lib/node/ParseQuery.js +100 -123
  102. package/lib/node/ParseRelation.js +10 -19
  103. package/lib/node/ParseRole.js +10 -11
  104. package/lib/node/ParseSchema.js +29 -42
  105. package/lib/node/ParseSession.js +10 -11
  106. package/lib/node/ParseUser.js +76 -87
  107. package/lib/node/Push.js +7 -12
  108. package/lib/node/RESTController.js +24 -36
  109. package/lib/node/SingleInstanceStateController.js +41 -69
  110. package/lib/node/Socket.weapp.js +23 -2
  111. package/lib/node/Storage.js +14 -19
  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 +20 -20
  116. package/lib/node/StorageController.weapp.js +14 -8
  117. package/lib/node/TaskQueue.js +2 -3
  118. package/lib/node/UniqueInstanceStateController.js +43 -63
  119. package/lib/node/WebSocketController.js +15 -2
  120. package/lib/node/Xhr.weapp.js +11 -2
  121. package/lib/node/arrayContainsObject.js +4 -4
  122. package/lib/node/canBeSerialized.js +5 -5
  123. package/lib/node/decode.js +4 -4
  124. package/lib/node/encode.js +5 -5
  125. package/lib/node/equals.js +4 -4
  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 +5 -5
  131. package/lib/node/unsavedChildren.js +5 -5
  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 +8 -7
  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 +312 -485
  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 +24 -30
@@ -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,9 @@ var SUBSCRIPTION_EMMITER_TYPES = {
144
69
  LEAVE: 'leave',
145
70
  DELETE: 'delete'
146
71
  };
147
- var generateInterval = function (k) {
72
+
73
+ // Exponentially-growing random delay
74
+ const generateInterval = k => {
148
75
  return Math.random() * Math.min(30, Math.pow(2, k) - 1) * 1000;
149
76
  };
150
77
 
@@ -161,9 +88,8 @@ var generateInterval = function (k) {
161
88
  * We expose three events to help you monitor the status of the LiveQueryClient.
162
89
  *
163
90
  * <pre>
164
- * let Parse = require('parse/node');
165
- * let LiveQueryClient = Parse.LiveQueryClient;
166
- * let client = new LiveQueryClient({
91
+ * const LiveQueryClient = Parse.LiveQueryClient;
92
+ * const client = new LiveQueryClient({
167
93
  * applicationId: '',
168
94
  * serverURL: '',
169
95
  * javascriptKey: '',
@@ -191,7 +117,7 @@ var generateInterval = function (k) {
191
117
  *
192
118
  * @alias Parse.LiveQueryClient
193
119
  */
194
- var LiveQueryClient = /*#__PURE__*/function () {
120
+ class LiveQueryClient {
195
121
  /**
196
122
  * @param {object} options
197
123
  * @param {string} options.applicationId - applicationId of your Parse app
@@ -201,15 +127,16 @@ var LiveQueryClient = /*#__PURE__*/function () {
201
127
  * @param {string} options.sessionToken (optional)
202
128
  * @param {string} options.installationId (optional)
203
129
  */
204
- function LiveQueryClient(_ref) {
130
+ constructor(_ref) {
205
131
  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);
132
+ let {
133
+ applicationId,
134
+ serverURL,
135
+ javascriptKey,
136
+ masterKey,
137
+ sessionToken,
138
+ installationId
139
+ } = _ref;
213
140
  (0, _defineProperty2.default)(this, "attempts", void 0);
214
141
  (0, _defineProperty2.default)(this, "id", void 0);
215
142
  (0, _defineProperty2.default)(this, "requestId", void 0);
@@ -245,436 +172,336 @@ var LiveQueryClient = /*#__PURE__*/function () {
245
172
  this.connectPromise = (0, _promiseUtils.resolvingPromise)();
246
173
  this.subscriptions = new _map.default();
247
174
  this.state = CLIENT_STATE.INITIALIZED;
248
- var EventEmitter = _CoreManager.default.getEventEmitter();
175
+ const EventEmitter = _CoreManager.default.getEventEmitter();
249
176
  this.emitter = new EventEmitter();
250
- this.on = function (eventName, listener) {
251
- return _this.emitter.on(eventName, listener);
252
- };
177
+ this.on = (eventName, listener) => this.emitter.on(eventName, listener);
253
178
  this.emit = function (eventName) {
254
- var _this$emitter, _context;
255
179
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
256
180
  args[_key - 1] = arguments[_key];
257
181
  }
258
- return (_this$emitter = _this.emitter).emit.apply(_this$emitter, (0, _concat.default)(_context = [eventName]).call(_context, args));
182
+ return _this.emitter.emit(eventName, ...args);
259
183
  };
260
184
  // adding listener so process does not crash
261
185
  // best practice is for developer to register their own listener
262
- this.on('error', function () {});
186
+ this.on('error', () => {});
263
187
  }
264
- (0, _createClass2.default)(LiveQueryClient, [{
265
- key: "shouldOpen",
266
- value: function () /*: any*/{
267
- return this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED;
188
+ shouldOpen() {
189
+ return this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED;
190
+ }
191
+
192
+ /**
193
+ * Subscribes to a ParseQuery
194
+ *
195
+ * If you provide the sessionToken, when the LiveQuery server gets ParseObject's
196
+ * updates from parse server, it'll try to check whether the sessionToken fulfills
197
+ * the ParseObject's ACL. The LiveQuery server will only send updates to clients whose
198
+ * sessionToken is fit for the ParseObject's ACL. You can check the LiveQuery protocol
199
+ * <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
200
+ * from our Standard API.
201
+ *
202
+ * @param {ParseQuery} query - the ParseQuery you want to subscribe to
203
+ * @param {string} sessionToken (optional)
204
+ * @returns {LiveQuerySubscription | undefined}
205
+ */
206
+ subscribe(query, sessionToken) {
207
+ if (!query) {
208
+ return;
209
+ }
210
+ const className = query.className;
211
+ const queryJSON = query.toJSON();
212
+ const where = queryJSON.where;
213
+ const keys = (0, _keys.default)(queryJSON)?.split(',');
214
+ const watch = queryJSON.watch?.split(',');
215
+ const subscribeRequest = {
216
+ op: OP_TYPES.SUBSCRIBE,
217
+ requestId: this.requestId,
218
+ query: {
219
+ className,
220
+ where,
221
+ keys,
222
+ watch
223
+ },
224
+ sessionToken: undefined
225
+ };
226
+ if (sessionToken) {
227
+ subscribeRequest.sessionToken = sessionToken;
268
228
  }
229
+ const subscription = new _LiveQuerySubscription.default(this.requestId, query, sessionToken);
230
+ this.subscriptions.set(this.requestId, subscription);
231
+ this.requestId += 1;
232
+ this.connectPromise.then(() => {
233
+ this.socket.send((0, _stringify.default)(subscribeRequest));
234
+ }).catch(error => {
235
+ subscription.subscribePromise.reject(error);
236
+ });
237
+ return subscription;
238
+ }
269
239
 
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 = {
240
+ /**
241
+ * After calling unsubscribe you'll stop receiving events from the subscription object.
242
+ *
243
+ * @param {object} subscription - subscription you would like to unsubscribe from.
244
+ * @returns {Promise | undefined}
245
+ */
246
+ async unsubscribe(subscription) {
247
+ if (!subscription) {
248
+ return;
249
+ }
250
+ const unsubscribeRequest = {
251
+ op: OP_TYPES.UNSUBSCRIBE,
252
+ requestId: subscription.id
253
+ };
254
+ return this.connectPromise.then(() => {
255
+ return this.socket.send((0, _stringify.default)(unsubscribeRequest));
256
+ }).then(() => {
257
+ return subscription.unsubscribePromise;
258
+ });
259
+ }
260
+
261
+ /**
262
+ * After open is called, the LiveQueryClient will try to send a connect request
263
+ * to the LiveQuery server.
264
+ *
265
+ */
266
+ open() {
267
+ const WebSocketImplementation = _CoreManager.default.getWebSocketController();
268
+ if (!WebSocketImplementation) {
269
+ this.emit(CLIENT_EMMITER_TYPES.ERROR, 'Can not find WebSocket implementation');
270
+ return;
271
+ }
272
+ if (this.state !== CLIENT_STATE.RECONNECTING) {
273
+ this.state = CLIENT_STATE.CONNECTING;
274
+ }
275
+ this.socket = new WebSocketImplementation(this.serverURL);
276
+ this.socket.closingPromise = (0, _promiseUtils.resolvingPromise)();
277
+
278
+ // Bind WebSocket callbacks
279
+ this.socket.onopen = () => {
280
+ this._handleWebSocketOpen();
281
+ };
282
+ this.socket.onmessage = event => {
283
+ this._handleWebSocketMessage(event);
284
+ };
285
+ this.socket.onclose = event => {
286
+ this.socket.closingPromise?.resolve(event);
287
+ this._handleWebSocketClose();
288
+ };
289
+ this.socket.onerror = error => {
290
+ this._handleWebSocketError(error);
291
+ };
292
+ }
293
+ resubscribe() {
294
+ var _context;
295
+ (0, _forEach.default)(_context = this.subscriptions).call(_context, (subscription, requestId) => {
296
+ const query = subscription.query;
297
+ const queryJSON = query.toJSON();
298
+ const where = queryJSON.where;
299
+ const keys = (0, _keys.default)(queryJSON)?.split(',');
300
+ const watch = queryJSON.watch?.split(',');
301
+ const className = query.className;
302
+ const sessionToken = subscription.sessionToken;
303
+ const subscribeRequest = {
299
304
  op: OP_TYPES.SUBSCRIBE,
300
- requestId: this.requestId,
305
+ requestId,
301
306
  query: {
302
- className: className,
303
- where: where,
304
- keys: keys,
305
- watch: watch
307
+ className,
308
+ where,
309
+ keys,
310
+ watch
306
311
  },
307
312
  sessionToken: undefined
308
313
  };
309
314
  if (sessionToken) {
310
315
  subscribeRequest.sessionToken = sessionToken;
311
316
  }
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);
317
+ this.connectPromise.then(() => {
318
+ this.socket.send((0, _stringify.default)(subscribeRequest));
319
319
  });
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)();
320
+ });
321
+ }
383
322
 
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
- };
323
+ /**
324
+ * This method will close the WebSocket connection to this LiveQueryClient,
325
+ * cancel the auto reconnect and unsubscribe all subscriptions based on it.
326
+ *
327
+ * @returns {Promise | undefined} CloseEvent {@link https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close_event}
328
+ */
329
+ async close() {
330
+ if (this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED) {
331
+ return;
399
332
  }
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
- });
333
+ this.state = CLIENT_STATE.DISCONNECTED;
334
+ this.socket?.close();
335
+ // Notify each subscription about the close
336
+ for (const subscription of (0, _values.default)(_context2 = this.subscriptions).call(_context2)) {
337
+ var _context2;
338
+ subscription.subscribed = false;
339
+ subscription.emit(SUBSCRIPTION_EMMITER_TYPES.CLOSE);
429
340
  }
341
+ this._handleReset();
342
+ this.emit(CLIENT_EMMITER_TYPES.CLOSE);
343
+ return this.socket?.closingPromise;
344
+ }
430
345
 
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();
346
+ // ensure we start with valid state if connect is called again after close
347
+ _handleReset() {
348
+ this.attempts = 1;
349
+ this.id = 0;
350
+ this.requestId = 1;
351
+ this.connectPromise = (0, _promiseUtils.resolvingPromise)();
352
+ this.subscriptions = new _map.default();
353
+ }
354
+ _handleWebSocketOpen() {
355
+ const connectRequest = {
356
+ op: OP_TYPES.CONNECT,
357
+ applicationId: this.applicationId,
358
+ javascriptKey: this.javascriptKey,
359
+ masterKey: this.masterKey,
360
+ sessionToken: this.sessionToken,
361
+ installationId: undefined
362
+ };
363
+ if (this.additionalProperties) {
364
+ connectRequest.installationId = this.installationId;
489
365
  }
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));
366
+ this.socket.send((0, _stringify.default)(connectRequest));
367
+ }
368
+ _handleWebSocketMessage(event) {
369
+ let data = event.data;
370
+ if (typeof data === 'string') {
371
+ data = JSON.parse(data);
506
372
  }
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();
373
+ let subscription = null;
374
+ if (data.requestId) {
375
+ subscription = this.subscriptions.get(data.requestId) || null;
376
+ }
377
+ const response = {
378
+ clientId: data.clientId,
379
+ installationId: data.installationId
380
+ };
381
+ switch (data.op) {
382
+ case OP_EVENTS.CONNECTED:
383
+ if (this.state === CLIENT_STATE.RECONNECTING) {
384
+ this.resubscribe();
385
+ }
386
+ this.emit(CLIENT_EMMITER_TYPES.OPEN);
387
+ this.id = data.clientId;
388
+ this.connectPromise.resolve();
389
+ this.state = CLIENT_STATE.CONNECTED;
390
+ break;
391
+ case OP_EVENTS.SUBSCRIBED:
392
+ if (subscription) {
393
+ this.attempts = 1;
394
+ subscription.subscribed = true;
395
+ subscription.subscribePromise.resolve();
396
+ (0, _setTimeout2.default)(() => subscription.emit(SUBSCRIPTION_EMMITER_TYPES.OPEN, response), 200);
397
+ }
398
+ break;
399
+ case OP_EVENTS.ERROR:
400
+ {
401
+ const parseError = new _ParseError.default(data.code, data.error);
402
+ if (!this.id) {
403
+ this.connectPromise.reject(parseError);
404
+ this.state = CLIENT_STATE.DISCONNECTED;
405
+ }
406
+ if (data.requestId) {
407
+ if (subscription) {
408
+ subscription.subscribePromise.reject(parseError);
409
+ (0, _setTimeout2.default)(() => subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, data.error), 200);
410
+ }
411
+ } else {
412
+ this.emit(CLIENT_EMMITER_TYPES.ERROR, data.error);
413
+ }
414
+ if (data.error === 'Additional properties not allowed') {
415
+ this.additionalProperties = false;
416
+ }
417
+ if (data.reconnect) {
418
+ this._handleReconnect();
526
419
  }
527
- this.emit(CLIENT_EMMITER_TYPES.OPEN);
528
- this.id = data.clientId;
529
- this.connectPromise.resolve();
530
- this.state = CLIENT_STATE.CONNECTED;
531
420
  break;
532
- case OP_EVENTS.SUBSCRIBED:
421
+ }
422
+ case OP_EVENTS.UNSUBSCRIBED:
423
+ {
533
424
  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);
425
+ this.subscriptions.delete(data.requestId);
426
+ subscription.subscribed = false;
427
+ subscription.unsubscribePromise.resolve();
539
428
  }
540
429
  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
- }
430
+ }
431
+ default:
432
+ {
433
+ // create, update, enter, leave, delete cases
434
+ if (!subscription) {
573
435
  break;
574
436
  }
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
- }
437
+ let override = false;
438
+ if (data.original) {
439
+ override = true;
440
+ delete data.original.__type;
441
+ // Check for removed fields
442
+ for (const field in data.original) {
443
+ if (!(field in data.object)) {
444
+ data.object[field] = undefined;
590
445
  }
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
446
  }
447
+ data.original = _ParseObject.default.fromJSON(data.original, false);
448
+ }
449
+ delete data.object.__type;
450
+ const parseObject = _ParseObject.default.fromJSON(data.object, !(subscription.query && subscription.query._select) ? override : false);
451
+ if (data.original) {
452
+ subscription.emit(data.op, parseObject, data.original, response);
453
+ } else {
454
+ subscription.emit(data.op, parseObject, response);
455
+ }
456
+ const localDatastore = _CoreManager.default.getLocalDatastore();
457
+ if (override && localDatastore.isEnabled) {
458
+ localDatastore._updateObjectIfPinned(parseObject).then(() => {});
604
459
  }
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
460
  }
624
- } catch (err) {
625
- _iterator2.e(err);
626
- } finally {
627
- _iterator2.f();
628
- }
629
- this._handleReconnect();
630
461
  }
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();
462
+ }
463
+ _handleWebSocketClose() {
464
+ if (this.state === CLIENT_STATE.DISCONNECTED) {
465
+ return;
649
466
  }
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);
661
-
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
467
+ this.state = CLIENT_STATE.CLOSED;
468
+ this.emit(CLIENT_EMMITER_TYPES.CLOSE);
469
+ // Notify each subscription about the close
470
+ for (const subscription of (0, _values.default)(_context3 = this.subscriptions).call(_context3)) {
471
+ var _context3;
472
+ subscription.emit(SUBSCRIPTION_EMMITER_TYPES.CLOSE);
473
+ }
474
+ this._handleReconnect();
475
+ }
476
+ _handleWebSocketError(error) {
477
+ this.emit(CLIENT_EMMITER_TYPES.ERROR, error);
478
+ for (const subscription of (0, _values.default)(_context4 = this.subscriptions).call(_context4)) {
479
+ var _context4;
480
+ subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, error);
481
+ }
482
+ this._handleReconnect();
483
+ }
484
+ _handleReconnect() {
485
+ var _context5;
486
+ // if closed or currently reconnecting we stop attempting to reconnect
487
+ if (this.state === CLIENT_STATE.DISCONNECTED) {
488
+ return;
489
+ }
490
+ this.state = CLIENT_STATE.RECONNECTING;
491
+ const time = generateInterval(this.attempts);
666
492
 
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);
493
+ // handle case when both close/error occur at frequent rates we ensure we do not reconnect unnecessarily.
494
+ // we're unable to distinguish different between close/error when we're unable to reconnect therefore
495
+ // we try to reconnect in both cases
496
+ // server side ws and browser WebSocket behave differently in when close/error get triggered
497
+ if (this.reconnectHandle) {
498
+ clearTimeout(this.reconnectHandle);
675
499
  }
676
- }]);
677
- return LiveQueryClient;
678
- }();
679
- var _default = LiveQueryClient;
680
- exports.default = _default;
500
+ this.reconnectHandle = (0, _setTimeout2.default)((0, _bind.default)(_context5 = () => {
501
+ this.attempts++;
502
+ this.connectPromise = (0, _promiseUtils.resolvingPromise)();
503
+ this.open();
504
+ }).call(_context5, this), time);
505
+ }
506
+ }
507
+ var _default = exports.default = LiveQueryClient;