twilio-sync
Advanced tools
Comparing version 0.4.2-dev.8 to 0.4.2-dev.9
@@ -42,3 +42,8 @@ "use strict"; | ||
value: function reportFailure(err) { | ||
this.emit('failure', err); | ||
if (err.status === 404) { | ||
// assume that 404 means that entity has been removed while we were away | ||
this.onRemoved(false); | ||
} else { | ||
this.emit('failure', err); | ||
} | ||
} | ||
@@ -45,0 +50,0 @@ /** |
@@ -83,2 +83,5 @@ "use strict"; | ||
value: function markAsFailed(error) { | ||
if (this.pendingPokeTimer) { | ||
clearTimeout(this.pendingPokeTimer); | ||
} | ||
this.rejectedWithError = error; | ||
@@ -603,3 +606,3 @@ } | ||
logger_1.default.error("Failed to subscribe on " + subscription.sid, message.error); | ||
subscriptionIntent.reportFailure(new syncerror_1.SyncError('Failed to subscribe on service events')); | ||
subscriptionIntent.reportFailure(new syncerror_1.SyncError('Failed to subscribe on service events: ' + message.error.message, message.error.status)); | ||
} | ||
@@ -606,0 +609,0 @@ } else if (!subscriptionIntent && subscription) { |
@@ -610,3 +610,3 @@ "use strict"; | ||
case 3: | ||
this._onRemoved(true); | ||
this.onRemoved(true); | ||
@@ -622,4 +622,4 @@ case 4: | ||
}, { | ||
key: "_onRemoved", | ||
value: function _onRemoved(locally) { | ||
key: "onRemoved", | ||
value: function onRemoved(locally) { | ||
this._unsubscribe(); | ||
@@ -659,3 +659,3 @@ // Should also do some cleanup here | ||
if (_context15.t0.status === 404) { | ||
this._onRemoved(false); | ||
this.onRemoved(false); | ||
} else { | ||
@@ -710,3 +710,3 @@ logger_1.default.error("Can't get updates for " + this.sid + ":", _context15.t0); | ||
{ | ||
this._onRemoved(false); | ||
this.onRemoved(false); | ||
} | ||
@@ -713,0 +713,0 @@ break; |
/// <reference types="node" /> | ||
import { EventEmitter } from 'events'; | ||
import { Services, Network, Router } from './interfaces/services'; | ||
import { SyncError } from './syncerror'; | ||
interface EntityServices { | ||
@@ -16,3 +17,4 @@ network: Network; | ||
abstract _update(update: any): void; | ||
reportFailure(err: Error): void; | ||
protected abstract onRemoved(locally: boolean): void; | ||
reportFailure(err: SyncError): void; | ||
/** | ||
@@ -19,0 +21,0 @@ * Subscribe to changes of data entity |
@@ -9,3 +9,9 @@ "use strict"; | ||
reportFailure(err) { | ||
this.emit('failure', err); | ||
if (err.status === 404) { | ||
// assume that 404 means that entity has been removed while we were away | ||
this.onRemoved(false); | ||
} | ||
else { | ||
this.emit('failure', err); | ||
} | ||
} | ||
@@ -12,0 +18,0 @@ /** |
@@ -33,2 +33,5 @@ "use strict"; | ||
markAsFailed(error) { | ||
if (this.pendingPokeTimer) { | ||
clearTimeout(this.pendingPokeTimer); | ||
} | ||
this.rejectedWithError = error; | ||
@@ -325,3 +328,3 @@ } | ||
logger_1.default.error(`Failed to subscribe on ${subscription.sid}`, message.error); | ||
subscriptionIntent.reportFailure(new syncerror_1.SyncError('Failed to subscribe on service events')); | ||
subscriptionIntent.reportFailure(new syncerror_1.SyncError('Failed to subscribe on service events: ' + message.error.message, message.error.status)); | ||
} | ||
@@ -328,0 +331,0 @@ } |
@@ -97,3 +97,3 @@ import { SyncEntity, EntityServices } from './entity'; | ||
*/ | ||
private onRemoved(locally); | ||
protected onRemoved(locally: boolean): void; | ||
/** | ||
@@ -100,0 +100,0 @@ * Removes document from service |
@@ -129,3 +129,3 @@ import { SyncEntity, EntityServices } from './entity'; | ||
removeList(): Promise<void>; | ||
_onRemoved(locally: any): void; | ||
protected onRemoved(locally: boolean): void; | ||
/** | ||
@@ -132,0 +132,0 @@ * Force to check for modifications on server |
@@ -271,6 +271,6 @@ "use strict"; | ||
yield this.services.network.delete(this.uri); | ||
this._onRemoved(true); | ||
this.onRemoved(true); | ||
}); | ||
} | ||
_onRemoved(locally) { | ||
onRemoved(locally) { | ||
this._unsubscribe(); | ||
@@ -295,3 +295,3 @@ // Should also do some cleanup here | ||
if (err.status === 404) { | ||
this._onRemoved(false); | ||
this.onRemoved(false); | ||
} | ||
@@ -336,3 +336,3 @@ else { | ||
{ | ||
this._onRemoved(false); | ||
this.onRemoved(false); | ||
} | ||
@@ -339,0 +339,0 @@ break; |
@@ -171,3 +171,3 @@ import { SyncEntity, EntityServices } from './entity'; | ||
protected _handleContextUpdate(data: any, eventId: any): void; | ||
private onRemoved(locally); | ||
protected onRemoved(locally: boolean): void; | ||
/** | ||
@@ -174,0 +174,0 @@ * Delete map from server. It will be impossible to restore it. |
{ | ||
"name": "twilio-sync", | ||
"version": "0.4.2-dev.8", | ||
"version": "0.4.2-dev.9", | ||
"description": "Twilio Sync client library", | ||
@@ -14,3 +14,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"babel-runtime": "^6.22.0", | ||
"babel-runtime": "^6.23.0", | ||
"karibu": "^1.0.1", | ||
@@ -20,6 +20,6 @@ "loglevel": "^1.4.1", | ||
"rfc6902": "^1.3.0", | ||
"twilio-ems-client": "^0.1.5-dev.2", | ||
"twilio-ems-client": "^0.1.5", | ||
"twilio-notifications": "^0.3.0-dev.1", | ||
"twilio-transport": "^0.1.1", | ||
"twilsock": "^0.2.1", | ||
"twilsock": "^0.2.2", | ||
"uuid": "^3.0.1" | ||
@@ -31,16 +31,16 @@ }, | ||
"@types/loglevel": "^1.4.29", | ||
"@types/mocha": "^2.2.38", | ||
"@types/node": "^7.0.4", | ||
"@types/sinon": "^1.16.34", | ||
"@types/mocha": "^2.2.39", | ||
"@types/node": "^7.0.5", | ||
"@types/sinon": "^1.16.35", | ||
"@types/sinon-as-promised": "^4.0.5", | ||
"@types/sinon-chai": "^2.7.27", | ||
"async-test-tools": "^1.0.6", | ||
"babel-cli": "^6.22.2", | ||
"babel-cli": "^6.23.0", | ||
"babel-plugin-add-module-exports": "^0.2.1", | ||
"babel-plugin-transform-object-assign": "^6.22.0", | ||
"babel-plugin-transform-runtime": "^6.22.0", | ||
"babel-plugin-transform-runtime": "^6.23.0", | ||
"babel-preset-es2015": "^6.22.0", | ||
"babelify": "^7.3.0", | ||
"backoff": "^2.5.0", | ||
"browserify": "^14.0.0", | ||
"browserify": "^14.1.0", | ||
"chai": "^3.5.0", | ||
@@ -61,3 +61,3 @@ "chai-as-promised": "^6.0.0", | ||
"gulp-tap": "^0.1.3", | ||
"gulp-tslint": "^7.0.1", | ||
"gulp-tslint": "^7.1.0", | ||
"gulp-typescript": "^3.1.4", | ||
@@ -69,3 +69,3 @@ "gulp-uglify": "^2.0.1", | ||
"jsdoc": "^3.4.3", | ||
"jsonwebtoken": "^7.2.1", | ||
"jsonwebtoken": "^7.3.0", | ||
"karma": "^1.4.1", | ||
@@ -80,6 +80,6 @@ "karma-browserify": "^5.1.1", | ||
"sinon-chai": "^2.8.0", | ||
"ts-node": "^2.0.0", | ||
"ts-node": "^2.1.0", | ||
"tslint": "^4.4.2", | ||
"twilio": "^3.3.0-edge", | ||
"typescript": "^2.1.5", | ||
"typescript": "^2.1.6", | ||
"underscore": "^1.8.3", | ||
@@ -86,0 +86,0 @@ "vinyl-buffer": "^1.0.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2006918
108
29419
Updatedbabel-runtime@^6.23.0
Updatedtwilio-ems-client@^0.1.5
Updatedtwilsock@^0.2.2