parse 4.0.0-alpha.1 → 4.0.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.
@@ -224,7 +224,7 @@ var config
224
224
  SERVER_AUTH_TOKEN: null,
225
225
  LIVEQUERY_SERVER_URL: null,
226
226
  ENCRYPTED_KEY: null,
227
- VERSION: 'js' + "4.0.0-alpha.1",
227
+ VERSION: 'js' + "4.0.0-alpha.2",
228
228
  APPLICATION_ID: null,
229
229
  JAVASCRIPT_KEY: null,
230
230
  MASTER_KEY: null,
@@ -64,6 +64,8 @@ var _LiveQuerySubscription = _interopRequireDefault(require("./LiveQuerySubscrip
64
64
 
65
65
  var _promiseUtils = require("./promiseUtils");
66
66
 
67
+ var _ParseError = _interopRequireDefault(require("./ParseError"));
68
+
67
69
  function _createForOfIteratorHelper(o, allowArrayLike) {
68
70
  var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
69
71
 
@@ -396,6 +398,8 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
396
398
  this.requestId += 1;
397
399
  this.connectPromise.then(function () {
398
400
  _this2.socket.send((0, _stringify.default)(subscribeRequest));
401
+ }).catch(function (error) {
402
+ subscription.subscribePromise.reject(error);
399
403
  });
400
404
  return subscription;
401
405
  }
@@ -608,26 +612,35 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
608
612
  break;
609
613
 
610
614
  case OP_EVENTS.ERROR:
611
- if (data.requestId) {
612
- if (subscription) {
613
- subscription.subscribePromise.resolve();
614
- (0, _setTimeout2.default)(function () {
615
- return subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, data.error);
616
- }, 200);
615
+ {
616
+ var parseError = new _ParseError.default(data.code, data.error);
617
+
618
+ if (!this.id) {
619
+ this.connectPromise.reject(parseError);
620
+ this.state = CLIENT_STATE.DISCONNECTED;
617
621
  }
618
- } else {
619
- this.emit(CLIENT_EMMITER_TYPES.ERROR, data.error);
620
- }
621
622
 
622
- if (data.error === 'Additional properties not allowed') {
623
- this.additionalProperties = false;
624
- }
623
+ if (data.requestId) {
624
+ if (subscription) {
625
+ subscription.subscribePromise.reject(parseError);
626
+ (0, _setTimeout2.default)(function () {
627
+ return subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, data.error);
628
+ }, 200);
629
+ }
630
+ } else {
631
+ this.emit(CLIENT_EMMITER_TYPES.ERROR, data.error);
632
+ }
625
633
 
626
- if (data.reconnect) {
627
- this._handleReconnect();
628
- }
634
+ if (data.error === 'Additional properties not allowed') {
635
+ this.additionalProperties = false;
636
+ }
629
637
 
630
- break;
638
+ if (data.reconnect) {
639
+ this._handleReconnect();
640
+ }
641
+
642
+ break;
643
+ }
631
644
 
632
645
  case OP_EVENTS.UNSUBSCRIBED:
633
646
  // We have already deleted subscription in unsubscribe(), do nothing here
@@ -217,7 +217,7 @@ const config
217
217
  SERVER_AUTH_TOKEN: null,
218
218
  LIVEQUERY_SERVER_URL: null,
219
219
  ENCRYPTED_KEY: null,
220
- VERSION: 'js' + "4.0.0-alpha.1",
220
+ VERSION: 'js' + "4.0.0-alpha.2",
221
221
  APPLICATION_ID: null,
222
222
  JAVASCRIPT_KEY: null,
223
223
  MASTER_KEY: null,
@@ -15,6 +15,8 @@ var _LiveQuerySubscription = _interopRequireDefault(require("./LiveQuerySubscrip
15
15
 
16
16
  var _promiseUtils = require("./promiseUtils");
17
17
 
18
+ var _ParseError = _interopRequireDefault(require("./ParseError"));
19
+
18
20
  function _interopRequireDefault(obj) {
19
21
  return obj && obj.__esModule ? obj : {
20
22
  default: obj
@@ -254,6 +256,8 @@ class LiveQueryClient extends _EventEmitter.default {
254
256
  this.requestId += 1;
255
257
  this.connectPromise.then(() => {
256
258
  this.socket.send(JSON.stringify(subscribeRequest));
259
+ }).catch(error => {
260
+ subscription.subscribePromise.reject(error);
257
261
  });
258
262
  return subscription;
259
263
  }
@@ -438,24 +442,33 @@ class LiveQueryClient extends _EventEmitter.default {
438
442
  break;
439
443
 
440
444
  case OP_EVENTS.ERROR:
441
- if (data.requestId) {
442
- if (subscription) {
443
- subscription.subscribePromise.resolve();
444
- setTimeout(() => subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, data.error), 200);
445
+ {
446
+ const parseError = new _ParseError.default(data.code, data.error);
447
+
448
+ if (!this.id) {
449
+ this.connectPromise.reject(parseError);
450
+ this.state = CLIENT_STATE.DISCONNECTED;
445
451
  }
446
- } else {
447
- this.emit(CLIENT_EMMITER_TYPES.ERROR, data.error);
448
- }
449
452
 
450
- if (data.error === 'Additional properties not allowed') {
451
- this.additionalProperties = false;
452
- }
453
+ if (data.requestId) {
454
+ if (subscription) {
455
+ subscription.subscribePromise.reject(parseError);
456
+ setTimeout(() => subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, data.error), 200);
457
+ }
458
+ } else {
459
+ this.emit(CLIENT_EMMITER_TYPES.ERROR, data.error);
460
+ }
453
461
 
454
- if (data.reconnect) {
455
- this._handleReconnect();
456
- }
462
+ if (data.error === 'Additional properties not allowed') {
463
+ this.additionalProperties = false;
464
+ }
457
465
 
458
- break;
466
+ if (data.reconnect) {
467
+ this._handleReconnect();
468
+ }
469
+
470
+ break;
471
+ }
459
472
 
460
473
  case OP_EVENTS.UNSUBSCRIBED:
461
474
  // We have already deleted subscription in unsubscribe(), do nothing here
@@ -8,7 +8,7 @@ var config = {
8
8
  SERVER_AUTH_TOKEN: null,
9
9
  LIVEQUERY_SERVER_URL: null,
10
10
  ENCRYPTED_KEY: null,
11
- VERSION: 'js' + "4.0.0-alpha.1",
11
+ VERSION: 'js' + "4.0.0-alpha.2",
12
12
  APPLICATION_ID: null,
13
13
  JAVASCRIPT_KEY: null,
14
14
  MASTER_KEY: null,
@@ -25,6 +25,8 @@ var _LiveQuerySubscription = _interopRequireDefault(require("./LiveQuerySubscrip
25
25
 
26
26
  var _promiseUtils = require("./promiseUtils");
27
27
 
28
+ var _ParseError = _interopRequireDefault(require("./ParseError"));
29
+
28
30
  function _createForOfIteratorHelperLoose(o, allowArrayLike) {
29
31
  var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
30
32
  if (it) return (it = it.call(o)).next.bind(it);
@@ -219,6 +221,8 @@ var LiveQueryClient = function (_EventEmitter) {
219
221
  this.requestId += 1;
220
222
  this.connectPromise.then(function () {
221
223
  _this2.socket.send(JSON.stringify(subscribeRequest));
224
+ }).catch(function (error) {
225
+ subscription.subscribePromise.reject(error);
222
226
  });
223
227
  return subscription;
224
228
  }
@@ -396,26 +400,35 @@ var LiveQueryClient = function (_EventEmitter) {
396
400
  break;
397
401
 
398
402
  case OP_EVENTS.ERROR:
399
- if (data.requestId) {
400
- if (subscription) {
401
- subscription.subscribePromise.resolve();
402
- setTimeout(function () {
403
- return subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, data.error);
404
- }, 200);
403
+ {
404
+ var parseError = new _ParseError.default(data.code, data.error);
405
+
406
+ if (!this.id) {
407
+ this.connectPromise.reject(parseError);
408
+ this.state = CLIENT_STATE.DISCONNECTED;
405
409
  }
406
- } else {
407
- this.emit(CLIENT_EMMITER_TYPES.ERROR, data.error);
408
- }
409
410
 
410
- if (data.error === 'Additional properties not allowed') {
411
- this.additionalProperties = false;
412
- }
411
+ if (data.requestId) {
412
+ if (subscription) {
413
+ subscription.subscribePromise.reject(parseError);
414
+ setTimeout(function () {
415
+ return subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, data.error);
416
+ }, 200);
417
+ }
418
+ } else {
419
+ this.emit(CLIENT_EMMITER_TYPES.ERROR, data.error);
420
+ }
413
421
 
414
- if (data.reconnect) {
415
- this._handleReconnect();
416
- }
422
+ if (data.error === 'Additional properties not allowed') {
423
+ this.additionalProperties = false;
424
+ }
417
425
 
418
- break;
426
+ if (data.reconnect) {
427
+ this._handleReconnect();
428
+ }
429
+
430
+ break;
431
+ }
419
432
 
420
433
  case OP_EVENTS.UNSUBSCRIBED:
421
434
  break;
@@ -224,7 +224,7 @@ var config
224
224
  SERVER_AUTH_TOKEN: null,
225
225
  LIVEQUERY_SERVER_URL: null,
226
226
  ENCRYPTED_KEY: null,
227
- VERSION: 'js' + "4.0.0-alpha.1",
227
+ VERSION: 'js' + "4.0.0-alpha.2",
228
228
  APPLICATION_ID: null,
229
229
  JAVASCRIPT_KEY: null,
230
230
  MASTER_KEY: null,
@@ -64,6 +64,8 @@ var _LiveQuerySubscription = _interopRequireDefault(require("./LiveQuerySubscrip
64
64
 
65
65
  var _promiseUtils = require("./promiseUtils");
66
66
 
67
+ var _ParseError = _interopRequireDefault(require("./ParseError"));
68
+
67
69
  function _createForOfIteratorHelper(o, allowArrayLike) {
68
70
  var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
69
71
 
@@ -396,6 +398,8 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
396
398
  this.requestId += 1;
397
399
  this.connectPromise.then(function () {
398
400
  _this2.socket.send((0, _stringify.default)(subscribeRequest));
401
+ }).catch(function (error) {
402
+ subscription.subscribePromise.reject(error);
399
403
  });
400
404
  return subscription;
401
405
  }
@@ -608,26 +612,35 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
608
612
  break;
609
613
 
610
614
  case OP_EVENTS.ERROR:
611
- if (data.requestId) {
612
- if (subscription) {
613
- subscription.subscribePromise.resolve();
614
- (0, _setTimeout2.default)(function () {
615
- return subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, data.error);
616
- }, 200);
615
+ {
616
+ var parseError = new _ParseError.default(data.code, data.error);
617
+
618
+ if (!this.id) {
619
+ this.connectPromise.reject(parseError);
620
+ this.state = CLIENT_STATE.DISCONNECTED;
617
621
  }
618
- } else {
619
- this.emit(CLIENT_EMMITER_TYPES.ERROR, data.error);
620
- }
621
622
 
622
- if (data.error === 'Additional properties not allowed') {
623
- this.additionalProperties = false;
624
- }
623
+ if (data.requestId) {
624
+ if (subscription) {
625
+ subscription.subscribePromise.reject(parseError);
626
+ (0, _setTimeout2.default)(function () {
627
+ return subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, data.error);
628
+ }, 200);
629
+ }
630
+ } else {
631
+ this.emit(CLIENT_EMMITER_TYPES.ERROR, data.error);
632
+ }
625
633
 
626
- if (data.reconnect) {
627
- this._handleReconnect();
628
- }
634
+ if (data.error === 'Additional properties not allowed') {
635
+ this.additionalProperties = false;
636
+ }
629
637
 
630
- break;
638
+ if (data.reconnect) {
639
+ this._handleReconnect();
640
+ }
641
+
642
+ break;
643
+ }
631
644
 
632
645
  case OP_EVENTS.UNSUBSCRIBED:
633
646
  // We have already deleted subscription in unsubscribe(), do nothing here
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "parse",
3
- "version": "4.0.0-alpha.1",
3
+ "version": "4.0.0-alpha.2",
4
4
  "description": "The Parse JavaScript SDK",
5
5
  "homepage": "https://parseplatform.org/",
6
6
  "keywords": [