From ec4e64738f5bed31a424c897a18c798931f2524f Mon Sep 17 00:00:00 2001 From: Greg Kubisa Date: Fri, 20 Jul 2018 12:28:54 +0200 Subject: [PATCH 1/2] Warn about using deprecated features --- README.md | 1 - lib/backend.js | 12 ++++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6e65f0187..2c8985db5 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,6 @@ Register a new middleware. One of: * `'connect'`: A new client connected to the server. * `'op'`: An operation was loaded from the database. - * `'doc'`: DEPRECATED: A snapshot was loaded from the database. Please use 'readSnapshots' * `'readSnapshots'`: Snapshot(s) were loaded from the database for a fetch or subscribe of a query or document * `'query'`: A query is about to be sent to the database * `'submit'`: An operation is about to be submitted to the database diff --git a/lib/backend.js b/lib/backend.js index 3156cfc82..7b29d9104 100644 --- a/lib/backend.js +++ b/lib/backend.js @@ -9,6 +9,8 @@ var projections = require('./projections'); var QueryEmitter = require('./query-emitter'); var StreamSocket = require('./stream-socket'); var SubmitRequest = require('./submit-request'); +var warnDeprecatedDoc = true; +var warnDeprecatedAfterSubmit = true; function Backend(options) { if (!(this instanceof Backend)) return new Backend(options); @@ -71,6 +73,11 @@ Backend.prototype.MIDDLEWARE_ACTIONS = { }; Backend.prototype._shimDocAction = function() { + if (warnDeprecatedDoc) { + warnDeprecatedDoc = false; + console.warn('DEPRECATED: "doc" middleware action. Use "readSnapshots" instead. Pass `disableDocAction: true` option to ShareDB to disable the "doc" action and this warning.'); + } + var backend = this; this.use(this.MIDDLEWARE_ACTIONS.readSnapshots, function(request, callback) { async.each(request.snapshots, function(snapshot, eachCb) { @@ -83,6 +90,11 @@ Backend.prototype._shimDocAction = function() { // Shim for backwards compatibility with deprecated middleware action name. // The action 'after submit' is now 'afterSubmit'. Backend.prototype._shimAfterSubmit = function() { + if (warnDeprecatedAfterSubmit) { + warnDeprecatedAfterSubmit = false; + console.warn('DEPRECATED: "after submit" middleware action. Use "afterSubmit" instead. Pass `disableSpaceDelimitedActions: true` option to ShareDB to disable the "after submit" action and this warning.'); + } + var backend = this; this.use(backend.MIDDLEWARE_ACTIONS.afterSubmit, function(request, callback) { backend.trigger(backend.MIDDLEWARE_ACTIONS['after submit'], request.agent, request, callback); From f1571310fce79825ba318c0fab56e66b00b3a98d Mon Sep 17 00:00:00 2001 From: Greg Kubisa Date: Fri, 20 Jul 2018 12:42:28 +0200 Subject: [PATCH 2/2] Add workaround for circular dependency --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7bd066b20..736e5fe78 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,8 @@ language: node_js node_js: - "10" - - "9" - "8" - "6" - - "4" -script: "npm run jshint && npm run test-cover" +script: "ln -s .. node_modules/sharedb; npm run jshint && npm run test-cover" # Send coverage data to Coveralls after_script: "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"