parse 4.2.0-beta.1 → 4.3.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/parse.js +2108 -1717
  2. package/dist/parse.min.js +2 -2
  3. package/dist/parse.weapp.js +2104 -1713
  4. package/dist/parse.weapp.min.js +2 -2
  5. package/lib/browser/Cloud.js +3 -0
  6. package/lib/browser/CoreManager.js +31 -4
  7. package/lib/browser/EventEmitter.js +7 -2
  8. package/lib/browser/EventuallyQueue.js +11 -3
  9. package/lib/browser/LiveQueryClient.js +52 -86
  10. package/lib/browser/LiveQuerySubscription.js +16 -51
  11. package/lib/browser/LocalDatastore.js +7 -0
  12. package/lib/browser/ObjectStateMutations.js +3 -1
  13. package/lib/browser/OfflineQuery.js +1 -1
  14. package/lib/browser/Parse.js +171 -135
  15. package/lib/browser/ParseError.js +12 -1
  16. package/lib/browser/ParseLiveQuery.js +79 -51
  17. package/lib/browser/ParseObject.js +1 -1
  18. package/lib/browser/ParseQuery.js +53 -58
  19. package/lib/browser/ParseSchema.js +22 -1
  20. package/lib/browser/ParseSession.js +2 -6
  21. package/lib/browser/ParseUser.js +65 -8
  22. package/lib/browser/Storage.js +7 -0
  23. package/lib/node/Cloud.js +3 -0
  24. package/lib/node/CoreManager.js +30 -4
  25. package/lib/node/EventEmitter.js +7 -1
  26. package/lib/node/EventuallyQueue.js +10 -3
  27. package/lib/node/LiveQueryClient.js +5 -5
  28. package/lib/node/LiveQuerySubscription.js +5 -7
  29. package/lib/node/LocalDatastore.js +6 -0
  30. package/lib/node/ObjectStateMutations.js +3 -1
  31. package/lib/node/OfflineQuery.js +1 -1
  32. package/lib/node/Parse.js +162 -126
  33. package/lib/node/ParseError.js +15 -1
  34. package/lib/node/ParseLiveQuery.js +32 -24
  35. package/lib/node/ParseObject.js +1 -1
  36. package/lib/node/ParseQuery.js +3 -6
  37. package/lib/node/ParseSchema.js +20 -1
  38. package/lib/node/ParseSession.js +1 -6
  39. package/lib/node/ParseUser.js +58 -8
  40. package/lib/node/Storage.js +6 -0
  41. package/lib/react-native/Cloud.js +3 -0
  42. package/lib/react-native/CoreManager.js +30 -4
  43. package/lib/react-native/EventEmitter.js +8 -5
  44. package/lib/react-native/EventuallyQueue.js +10 -3
  45. package/lib/react-native/LiveQueryClient.js +38 -68
  46. package/lib/react-native/LiveQuerySubscription.js +16 -46
  47. package/lib/react-native/LocalDatastore.js +6 -0
  48. package/lib/react-native/ObjectStateMutations.js +3 -1
  49. package/lib/react-native/OfflineQuery.js +1 -1
  50. package/lib/react-native/Parse.js +127 -90
  51. package/lib/react-native/ParseError.js +8 -1
  52. package/lib/react-native/ParseLiveQuery.js +39 -11
  53. package/lib/react-native/ParseQuery.js +3 -6
  54. package/lib/react-native/ParseSchema.js +14 -1
  55. package/lib/react-native/ParseUser.js +49 -6
  56. package/lib/react-native/Storage.js +6 -0
  57. package/lib/weapp/Cloud.js +3 -0
  58. package/lib/weapp/CoreManager.js +31 -4
  59. package/lib/weapp/EventEmitter.js +7 -2
  60. package/lib/weapp/EventuallyQueue.js +11 -3
  61. package/lib/weapp/LiveQueryClient.js +52 -86
  62. package/lib/weapp/LiveQuerySubscription.js +16 -51
  63. package/lib/weapp/LocalDatastore.js +7 -0
  64. package/lib/weapp/ObjectStateMutations.js +3 -1
  65. package/lib/weapp/OfflineQuery.js +1 -1
  66. package/lib/weapp/Parse.js +170 -134
  67. package/lib/weapp/ParseError.js +12 -1
  68. package/lib/weapp/ParseLiveQuery.js +79 -51
  69. package/lib/weapp/ParseObject.js +1 -1
  70. package/lib/weapp/ParseQuery.js +53 -58
  71. package/lib/weapp/ParseSchema.js +22 -1
  72. package/lib/weapp/ParseSession.js +2 -6
  73. package/lib/weapp/ParseUser.js +65 -8
  74. package/lib/weapp/Storage.js +7 -0
  75. package/package.json +21 -17
@@ -13,11 +13,6 @@ function _interopRequireDefault(obj) {
13
13
  default: obj
14
14
  };
15
15
  }
16
- /**
17
- * @flow
18
- */
19
- /*:: import type { AttributeMap } from './ObjectStateMutations';*/
20
- /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
21
16
  /**
22
17
  * <p>A Parse.Session object is a local representation of a revocable session.
23
18
  * This class is a subclass of a Parse.Object, and retains the same
@@ -30,7 +25,7 @@ class ParseSession extends _ParseObject.default {
30
25
  /**
31
26
  * @param {object} attributes The initial set of data to store in the user.
32
27
  */
33
- constructor(attributes /*: ?AttributeMap*/) {
28
+ constructor(attributes /*:: ?: any*/) {
34
29
  super('_Session');
35
30
  if (attributes && typeof attributes === 'object') {
36
31
  if (!this.set(attributes || {})) {
@@ -110,8 +110,14 @@ class ParseUser extends _ParseObject.default {
110
110
  throw new Error('Invalid type: authData field should be an object');
111
111
  }
112
112
  authData[authType] = options.authData;
113
+ const oldAnonymousData = authData.anonymous;
114
+ this.stripAnonymity();
113
115
  const controller = _CoreManager.default.getUserController();
114
- return controller.linkWith(this, authData, saveOpts);
116
+ return controller.linkWith(this, authData, saveOpts).catch(e => {
117
+ delete authData[authType];
118
+ this.restoreAnonimity(oldAnonymousData);
119
+ throw e;
120
+ });
115
121
  } else {
116
122
  return new Promise((resolve, reject) => {
117
123
  provider.authenticate({
@@ -300,6 +306,19 @@ class ParseUser extends _ParseObject.default {
300
306
  const current = await ParseUser.currentAsync();
301
307
  return !!current && current.id === this.id;
302
308
  }
309
+ stripAnonymity() {
310
+ const authData = this.get('authData');
311
+ if (authData && typeof authData === 'object' && authData.hasOwnProperty('anonymous')) {
312
+ // We need to set anonymous to null instead of deleting it in order to remove it from Parse.
313
+ authData.anonymous = null;
314
+ }
315
+ }
316
+ restoreAnonimity(anonymousData /*: any*/) {
317
+ if (anonymousData) {
318
+ const authData = this.get('authData');
319
+ authData.anonymous = anonymousData;
320
+ }
321
+ }
303
322
 
304
323
  /**
305
324
  * Returns get("username").
@@ -320,12 +339,7 @@ class ParseUser extends _ParseObject.default {
320
339
  * @param {string} username
321
340
  */
322
341
  setUsername(username /*: string*/) {
323
- // Strip anonymity
324
- const authData = this.get('authData');
325
- if (authData && typeof authData === 'object' && authData.hasOwnProperty('anonymous')) {
326
- // We need to set anonymous to null instead of deleting it in order to remove it from Parse.
327
- authData.anonymous = null;
328
- }
342
+ this.stripAnonymity();
329
343
  this.set('username', username);
330
344
  }
331
345
 
@@ -440,6 +454,9 @@ class ParseUser extends _ParseObject.default {
440
454
  if (options.hasOwnProperty('usePost')) {
441
455
  loginOptions.usePost = options.usePost;
442
456
  }
457
+ if (options.hasOwnProperty('context') && Object.prototype.toString.call(options.context) === '[object Object]') {
458
+ loginOptions.context = options.context;
459
+ }
443
460
  const controller = _CoreManager.default.getUserController();
444
461
  return controller.logIn(this, loginOptions);
445
462
  }
@@ -638,6 +655,38 @@ class ParseUser extends _ParseObject.default {
638
655
  return user.logIn(options);
639
656
  }
640
657
 
658
+ /**
659
+ * Logs in a user with a username (or email) and password, and authData. On success, this
660
+ * saves the session to disk, so you can retrieve the currently logged in
661
+ * user using <code>current</code>.
662
+ *
663
+ * @param {string} username The username (or email) to log in with.
664
+ * @param {string} password The password to log in with.
665
+ * @param {object} authData The authData to log in with.
666
+ * @param {object} options
667
+ * @static
668
+ * @returns {Promise} A promise that is fulfilled with the user when
669
+ * the login completes.
670
+ */
671
+ static logInWithAdditionalAuth(username /*: string*/, password /*: string*/, authData /*: AuthData*/, options /*:: ?: FullOptions*/) {
672
+ if (typeof username !== 'string') {
673
+ return Promise.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
674
+ }
675
+ if (typeof password !== 'string') {
676
+ return Promise.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Password must be a string.'));
677
+ }
678
+ if (Object.prototype.toString.call(authData) !== '[object Object]') {
679
+ return Promise.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Auth must be an object.'));
680
+ }
681
+ const user = new this();
682
+ user._finishFetch({
683
+ username: username,
684
+ password: password,
685
+ authData
686
+ });
687
+ return user.logIn(options);
688
+ }
689
+
641
690
  /**
642
691
  * Logs in a user with an objectId. On success, this saves the session
643
692
  * to disk, so you can retrieve the currently logged in user using
@@ -1049,7 +1098,8 @@ const DefaultController = {
1049
1098
  const stateController = _CoreManager.default.getObjectStateController();
1050
1099
  const auth = {
1051
1100
  username: user.get('username'),
1052
- password: user.get('password')
1101
+ password: user.get('password'),
1102
+ authData: user.get('authData')
1053
1103
  };
1054
1104
  return RESTController.request(options.usePost ? 'POST' : 'GET', 'login', auth, options).then(response => {
1055
1105
  user._migrateId(response.objectId);
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
2
 
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
3
7
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
4
8
  function _interopRequireDefault(obj) {
5
9
  return obj && obj.__esModule ? obj : {
@@ -91,4 +95,6 @@ const Storage = {
91
95
  }
92
96
  };
93
97
  module.exports = Storage;
98
+ var _default = Storage;
99
+ exports.default = _default;
94
100
  _CoreManager.default.setStorageController(require('./StorageController.default'));
@@ -24,6 +24,9 @@ function run(name, data, options) {
24
24
  if (options.sessionToken) {
25
25
  requestOptions.sessionToken = options.sessionToken;
26
26
  }
27
+ if (options.installationId) {
28
+ requestOptions.installationId = options.installationId;
29
+ }
27
30
  if (options.context && typeof options.context === 'object') {
28
31
  requestOptions.context = options.context;
29
32
  }
@@ -1,3 +1,7 @@
1
+ Object.defineProperty(exports, "__esModule", {
2
+ value: true
3
+ });
4
+ exports.default = void 0;
1
5
  var config = {
2
6
  IS_NODE: typeof process !== 'undefined' && !!process.versions && !!process.versions.node && !process.versions.electron,
3
7
  REQUEST_ATTEMPT_LIMIT: 5,
@@ -8,7 +12,7 @@ var config = {
8
12
  SERVER_AUTH_TOKEN: null,
9
13
  LIVEQUERY_SERVER_URL: null,
10
14
  ENCRYPTED_KEY: null,
11
- VERSION: 'js' + "4.2.0-beta.1",
15
+ VERSION: 'js' + "4.3.0-beta.1",
12
16
  APPLICATION_ID: null,
13
17
  JAVASCRIPT_KEY: null,
14
18
  MASTER_KEY: null,
@@ -17,7 +21,8 @@ var config = {
17
21
  FORCE_REVOCABLE_SESSION: false,
18
22
  ENCRYPTED_USER: false,
19
23
  IDEMPOTENCY: false,
20
- ALLOW_CUSTOM_OBJECT_ID: false
24
+ ALLOW_CUSTOM_OBJECT_ID: false,
25
+ PARSE_ERRORS: []
21
26
  };
22
27
  function requireMethods(name, methods, controller) {
23
28
  methods.forEach(function (func) {
@@ -26,7 +31,7 @@ function requireMethods(name, methods, controller) {
26
31
  }
27
32
  });
28
33
  }
29
- module.exports = {
34
+ var CoreManager = {
30
35
  get: function (key) {
31
36
  if (config.hasOwnProperty(key)) {
32
37
  return config[key];
@@ -36,6 +41,12 @@ module.exports = {
36
41
  set: function (key, value) {
37
42
  config[key] = value;
38
43
  },
44
+ setIfNeeded: function (key, value) {
45
+ if (!config.hasOwnProperty(key)) {
46
+ config[key] = value;
47
+ }
48
+ return config[key];
49
+ },
39
50
  setAnalyticsController: function (controller) {
40
51
  requireMethods('AnalyticsController', ['track'], controller);
41
52
  config['AnalyticsController'] = controller;
@@ -64,6 +75,12 @@ module.exports = {
64
75
  getCryptoController: function () {
65
76
  return config['CryptoController'];
66
77
  },
78
+ setEventEmitter: function (eventEmitter) {
79
+ config['EventEmitter'] = eventEmitter;
80
+ },
81
+ getEventEmitter: function () {
82
+ return config['EventEmitter'];
83
+ },
67
84
  setFileController: function (controller) {
68
85
  requireMethods('FileController', ['saveFile', 'saveBase64'], controller);
69
86
  config['FileController'] = controller;
@@ -78,6 +95,12 @@ module.exports = {
78
95
  getInstallationController: function () {
79
96
  return config['InstallationController'];
80
97
  },
98
+ setLiveQuery: function (liveQuery) {
99
+ config['LiveQuery'] = liveQuery;
100
+ },
101
+ getLiveQuery: function () {
102
+ return config['LiveQuery'];
103
+ },
81
104
  setObjectController: function (controller) {
82
105
  requireMethods('ObjectController', ['save', 'fetch', 'destroy'], controller);
83
106
  config['ObjectController'] = controller;
@@ -184,4 +207,7 @@ module.exports = {
184
207
  getHooksController: function () {
185
208
  return config['HooksController'];
186
209
  }
187
- };
210
+ };
211
+ module.exports = CoreManager;
212
+ var _default = CoreManager;
213
+ exports.default = _default;
@@ -1,6 +1,9 @@
1
- var EventEmitter = require('../../../react-native/Libraries/vendor/emitter/EventEmitter');
2
- if (EventEmitter.default) {
3
- EventEmitter = EventEmitter.default;
4
- }
5
- EventEmitter.prototype.on = EventEmitter.prototype.addListener;
1
+ var EventEmitter;
2
+ try {
3
+ EventEmitter = require('react-native/Libraries/vendor/emitter/EventEmitter');
4
+ if (EventEmitter.default) {
5
+ EventEmitter = EventEmitter.default;
6
+ }
7
+ EventEmitter.prototype.on = EventEmitter.prototype.addListener;
8
+ } catch (_) {}
6
9
  module.exports = EventEmitter;
@@ -1,7 +1,12 @@
1
1
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.default = void 0;
2
6
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
3
7
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
4
8
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
9
+ var _ParseError = _interopRequireDefault(require("./ParseError"));
5
10
  var _ParseObject = _interopRequireDefault(require("./ParseObject"));
6
11
  var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
7
12
  var _Storage = _interopRequireDefault(require("./Storage"));
@@ -155,7 +160,7 @@ var EventuallyQueue = {
155
160
  yield object.save(queueObject.object, queueObject.serverOptions);
156
161
  yield this.remove(queueObject.queueId);
157
162
  } catch (e) {
158
- if (e.message !== 'XMLHttpRequest failed: "Unable to connect to the Parse API"') {
163
+ if (e.code !== _ParseError.default.CONNECTION_FAILED) {
159
164
  yield this.remove(queueObject.queueId);
160
165
  }
161
166
  }
@@ -165,7 +170,7 @@ var EventuallyQueue = {
165
170
  yield object.destroy(queueObject.serverOptions);
166
171
  yield this.remove(queueObject.queueId);
167
172
  } catch (e) {
168
- if (e.message !== 'XMLHttpRequest failed: "Unable to connect to the Parse API"') {
173
+ if (e.code !== _ParseError.default.CONNECTION_FAILED) {
169
174
  yield this.remove(queueObject.queueId);
170
175
  }
171
176
  }
@@ -246,4 +251,6 @@ var EventuallyQueue = {
246
251
  }()
247
252
  }
248
253
  };
249
- module.exports = EventuallyQueue;
254
+ module.exports = EventuallyQueue;
255
+ var _default = EventuallyQueue;
256
+ exports.default = _default;
@@ -5,40 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  exports.default = void 0;
6
6
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
7
7
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
8
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
9
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
10
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
11
8
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
12
- var _EventEmitter2 = _interopRequireDefault(require("./EventEmitter"));
13
9
  var _ParseObject = _interopRequireDefault(require("./ParseObject"));
14
10
  var _LiveQuerySubscription = _interopRequireDefault(require("./LiveQuerySubscription"));
15
11
  var _promiseUtils = require("./promiseUtils");
16
12
  var _ParseError = _interopRequireDefault(require("./ParseError"));
17
- function _createSuper(Derived) {
18
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
19
- return function () {
20
- var Super = (0, _getPrototypeOf2.default)(Derived),
21
- result;
22
- if (hasNativeReflectConstruct) {
23
- var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
24
- result = Reflect.construct(Super, arguments, NewTarget);
25
- } else {
26
- result = Super.apply(this, arguments);
27
- }
28
- return (0, _possibleConstructorReturn2.default)(this, result);
29
- };
30
- }
31
- function _isNativeReflectConstruct() {
32
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
33
- if (Reflect.construct.sham) return false;
34
- if (typeof Proxy === "function") return true;
35
- try {
36
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
37
- return true;
38
- } catch (e) {
39
- return false;
40
- }
41
- }
42
13
  var CLIENT_STATE = {
43
14
  INITIALIZED: 'initialized',
44
15
  CONNECTING: 'connecting',
@@ -82,11 +53,8 @@ var SUBSCRIPTION_EMMITER_TYPES = {
82
53
  var generateInterval = function (k) {
83
54
  return Math.random() * Math.min(30, Math.pow(2, k) - 1) * 1000;
84
55
  };
85
- var LiveQueryClient = function (_EventEmitter) {
86
- (0, _inherits2.default)(LiveQueryClient, _EventEmitter);
87
- var _super = _createSuper(LiveQueryClient);
56
+ var LiveQueryClient = function () {
88
57
  function LiveQueryClient(_ref) {
89
- var _this;
90
58
  var applicationId = _ref.applicationId,
91
59
  serverURL = _ref.serverURL,
92
60
  javascriptKey = _ref.javascriptKey,
@@ -94,26 +62,28 @@ var LiveQueryClient = function (_EventEmitter) {
94
62
  sessionToken = _ref.sessionToken,
95
63
  installationId = _ref.installationId;
96
64
  (0, _classCallCheck2.default)(this, LiveQueryClient);
97
- _this = _super.call(this);
98
65
  if (!serverURL || serverURL.indexOf('ws') !== 0) {
99
66
  throw new Error('You need to set a proper Parse LiveQuery server url before using LiveQueryClient');
100
67
  }
101
- _this.reconnectHandle = null;
102
- _this.attempts = 1;
103
- _this.id = 0;
104
- _this.requestId = 1;
105
- _this.serverURL = serverURL;
106
- _this.applicationId = applicationId;
107
- _this.javascriptKey = javascriptKey || undefined;
108
- _this.masterKey = masterKey || undefined;
109
- _this.sessionToken = sessionToken || undefined;
110
- _this.installationId = installationId || undefined;
111
- _this.additionalProperties = true;
112
- _this.connectPromise = (0, _promiseUtils.resolvingPromise)();
113
- _this.subscriptions = new Map();
114
- _this.state = CLIENT_STATE.INITIALIZED;
115
- _this.on('error', function () {});
116
- return _this;
68
+ this.reconnectHandle = null;
69
+ this.attempts = 1;
70
+ this.id = 0;
71
+ this.requestId = 1;
72
+ this.serverURL = serverURL;
73
+ this.applicationId = applicationId;
74
+ this.javascriptKey = javascriptKey || undefined;
75
+ this.masterKey = masterKey || undefined;
76
+ this.sessionToken = sessionToken || undefined;
77
+ this.installationId = installationId || undefined;
78
+ this.additionalProperties = true;
79
+ this.connectPromise = (0, _promiseUtils.resolvingPromise)();
80
+ this.subscriptions = new Map();
81
+ this.state = CLIENT_STATE.INITIALIZED;
82
+ var EventEmitter = _CoreManager.default.getEventEmitter();
83
+ this.emitter = new EventEmitter();
84
+ this.on = this.emitter.on;
85
+ this.emit = this.emitter.emit;
86
+ this.on('error', function () {});
117
87
  }
118
88
  (0, _createClass2.default)(LiveQueryClient, [{
119
89
  key: "shouldOpen",
@@ -125,7 +95,7 @@ var LiveQueryClient = function (_EventEmitter) {
125
95
  value: function (query, sessionToken) {
126
96
  var _queryJSON$keys,
127
97
  _queryJSON$watch,
128
- _this2 = this;
98
+ _this = this;
129
99
  if (!query) {
130
100
  return;
131
101
  }
@@ -151,7 +121,7 @@ var LiveQueryClient = function (_EventEmitter) {
151
121
  this.subscriptions.set(this.requestId, subscription);
152
122
  this.requestId += 1;
153
123
  this.connectPromise.then(function () {
154
- _this2.socket.send(JSON.stringify(subscribeRequest));
124
+ _this.socket.send(JSON.stringify(subscribeRequest));
155
125
  }).catch(function (error) {
156
126
  subscription.subscribePromise.reject(error);
157
127
  });
@@ -160,7 +130,7 @@ var LiveQueryClient = function (_EventEmitter) {
160
130
  }, {
161
131
  key: "unsubscribe",
162
132
  value: function (subscription) {
163
- var _this3 = this;
133
+ var _this2 = this;
164
134
  if (!subscription) {
165
135
  return;
166
136
  }
@@ -169,7 +139,7 @@ var LiveQueryClient = function (_EventEmitter) {
169
139
  requestId: subscription.id
170
140
  };
171
141
  return this.connectPromise.then(function () {
172
- return _this3.socket.send(JSON.stringify(unsubscribeRequest));
142
+ return _this2.socket.send(JSON.stringify(unsubscribeRequest));
173
143
  }).then(function () {
174
144
  return subscription.unsubscribePromise;
175
145
  });
@@ -177,7 +147,7 @@ var LiveQueryClient = function (_EventEmitter) {
177
147
  }, {
178
148
  key: "open",
179
149
  value: function () {
180
- var _this4 = this;
150
+ var _this3 = this;
181
151
  var WebSocketImplementation = _CoreManager.default.getWebSocketController();
182
152
  if (!WebSocketImplementation) {
183
153
  this.emit(CLIENT_EMMITER_TYPES.ERROR, 'Can not find WebSocket implementation');
@@ -189,23 +159,23 @@ var LiveQueryClient = function (_EventEmitter) {
189
159
  this.socket = new WebSocketImplementation(this.serverURL);
190
160
  this.socket.closingPromise = (0, _promiseUtils.resolvingPromise)();
191
161
  this.socket.onopen = function () {
192
- _this4._handleWebSocketOpen();
162
+ _this3._handleWebSocketOpen();
193
163
  };
194
164
  this.socket.onmessage = function (event) {
195
- _this4._handleWebSocketMessage(event);
165
+ _this3._handleWebSocketMessage(event);
196
166
  };
197
167
  this.socket.onclose = function (event) {
198
- _this4.socket.closingPromise.resolve(event);
199
- _this4._handleWebSocketClose();
168
+ _this3.socket.closingPromise.resolve(event);
169
+ _this3._handleWebSocketClose();
200
170
  };
201
171
  this.socket.onerror = function (error) {
202
- _this4._handleWebSocketError(error);
172
+ _this3._handleWebSocketError(error);
203
173
  };
204
174
  }
205
175
  }, {
206
176
  key: "resubscribe",
207
177
  value: function () {
208
- var _this5 = this;
178
+ var _this4 = this;
209
179
  this.subscriptions.forEach(function (subscription, requestId) {
210
180
  var query = subscription.query;
211
181
  var queryJSON = query.toJSON();
@@ -225,8 +195,8 @@ var LiveQueryClient = function (_EventEmitter) {
225
195
  if (sessionToken) {
226
196
  subscribeRequest.sessionToken = sessionToken;
227
197
  }
228
- _this5.connectPromise.then(function () {
229
- _this5.socket.send(JSON.stringify(subscribeRequest));
198
+ _this4.connectPromise.then(function () {
199
+ _this4.socket.send(JSON.stringify(subscribeRequest));
230
200
  });
231
201
  });
232
202
  }
@@ -395,7 +365,7 @@ var LiveQueryClient = function (_EventEmitter) {
395
365
  }, {
396
366
  key: "_handleReconnect",
397
367
  value: function () {
398
- var _this6 = this;
368
+ var _this5 = this;
399
369
  if (this.state === CLIENT_STATE.DISCONNECTED) {
400
370
  return;
401
371
  }
@@ -405,14 +375,14 @@ var LiveQueryClient = function (_EventEmitter) {
405
375
  clearTimeout(this.reconnectHandle);
406
376
  }
407
377
  this.reconnectHandle = setTimeout(function () {
408
- _this6.attempts++;
409
- _this6.connectPromise = (0, _promiseUtils.resolvingPromise)();
410
- _this6.open();
378
+ _this5.attempts++;
379
+ _this5.connectPromise = (0, _promiseUtils.resolvingPromise)();
380
+ _this5.open();
411
381
  }.bind(this), time);
412
382
  }
413
383
  }]);
414
384
  return LiveQueryClient;
415
- }(_EventEmitter2.default);
385
+ }();
416
386
  _CoreManager.default.setWebSocketController(WebSocket);
417
387
  var _default = LiveQueryClient;
418
388
  exports.default = _default;
@@ -5,64 +5,34 @@ Object.defineProperty(exports, "__esModule", {
5
5
  exports.default = void 0;
6
6
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
7
7
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
8
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
9
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
10
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
11
- var _EventEmitter2 = _interopRequireDefault(require("./EventEmitter"));
12
8
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
13
9
  var _promiseUtils = require("./promiseUtils");
14
- function _createSuper(Derived) {
15
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
16
- return function () {
17
- var Super = (0, _getPrototypeOf2.default)(Derived),
18
- result;
19
- if (hasNativeReflectConstruct) {
20
- var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
21
- result = Reflect.construct(Super, arguments, NewTarget);
22
- } else {
23
- result = Super.apply(this, arguments);
24
- }
25
- return (0, _possibleConstructorReturn2.default)(this, result);
26
- };
27
- }
28
- function _isNativeReflectConstruct() {
29
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
30
- if (Reflect.construct.sham) return false;
31
- if (typeof Proxy === "function") return true;
32
- try {
33
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
34
- return true;
35
- } catch (e) {
36
- return false;
37
- }
38
- }
39
- var Subscription = function (_EventEmitter) {
40
- (0, _inherits2.default)(Subscription, _EventEmitter);
41
- var _super = _createSuper(Subscription);
10
+ var Subscription = function () {
42
11
  function Subscription(id, query, sessionToken) {
43
- var _this;
44
12
  (0, _classCallCheck2.default)(this, Subscription);
45
- _this = _super.call(this);
46
- _this.id = id;
47
- _this.query = query;
48
- _this.sessionToken = sessionToken;
49
- _this.subscribePromise = (0, _promiseUtils.resolvingPromise)();
50
- _this.unsubscribePromise = (0, _promiseUtils.resolvingPromise)();
51
- _this.subscribed = false;
52
- _this.on('error', function () {});
53
- return _this;
13
+ this.id = id;
14
+ this.query = query;
15
+ this.sessionToken = sessionToken;
16
+ this.subscribePromise = (0, _promiseUtils.resolvingPromise)();
17
+ this.unsubscribePromise = (0, _promiseUtils.resolvingPromise)();
18
+ this.subscribed = false;
19
+ var EventEmitter = _CoreManager.default.getEventEmitter();
20
+ this.emitter = new EventEmitter();
21
+ this.on = this.emitter.on;
22
+ this.emit = this.emitter.emit;
23
+ this.on('error', function () {});
54
24
  }
55
25
  (0, _createClass2.default)(Subscription, [{
56
26
  key: "unsubscribe",
57
27
  value: function () {
58
- var _this2 = this;
28
+ var _this = this;
59
29
  return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient().then(function (liveQueryClient) {
60
- _this2.emit('close');
61
- return liveQueryClient.unsubscribe(_this2);
30
+ _this.emit('close');
31
+ return liveQueryClient.unsubscribe(_this);
62
32
  });
63
33
  }
64
34
  }]);
65
35
  return Subscription;
66
- }(_EventEmitter2.default);
36
+ }();
67
37
  var _default = Subscription;
68
38
  exports.default = _default;
@@ -1,4 +1,8 @@
1
1
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.default = void 0;
2
6
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
3
7
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
4
8
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
@@ -380,5 +384,7 @@ var LocalDatastore = {
380
384
  }
381
385
  };
382
386
  module.exports = LocalDatastore;
387
+ var _default = LocalDatastore;
388
+ exports.default = _default;
383
389
  _CoreManager.default.setLocalDatastoreController(require('./LocalDatastoreController.react-native'));
384
390
  _CoreManager.default.setLocalDatastore(LocalDatastore);
@@ -125,7 +125,9 @@ function estimateAttributes(serverData, pendingOps, className, id) {
125
125
  function nestedSet(obj, key, value) {
126
126
  var path = key.split('.');
127
127
  for (var i = 0; i < path.length - 1; i++) {
128
- if (!(path[i] in obj)) obj[path[i]] = {};
128
+ if (!(path[i] in obj)) {
129
+ obj[path[i]] = {};
130
+ }
129
131
  obj = obj[path[i]];
130
132
  }
131
133
  if (typeof value === 'undefined') {
@@ -430,7 +430,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
430
430
  var _distance = point.radiansTo(centerPoint);
431
431
  return _distance <= maxDistance;
432
432
  }
433
- break;
433
+ return false;
434
434
  }
435
435
  case '$geoIntersects':
436
436
  {