From 73c01c3da85c74084d869620c0522692de9eb6ab Mon Sep 17 00:00:00 2001 From: Jakob Westhoff Date: Fri, 21 Jul 2017 11:03:08 +0200 Subject: [PATCH 1/5] Bumped pouchdb to test against to 6.3.4 --- package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index c85a0ed..5a4bee3 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "inherits": "2.0.1", "lie": "3.0.4", "pouchdb-extend": "0.1.2", - "pouchdb-promise": "5.4.3", + "pouchdb-promise": "6.3.4", "pouchdb-wrappers": "1.3.6", "immediate": "~3.0.5" }, @@ -51,11 +51,11 @@ "jshint": "~2.8.0", "mocha": "^2.4.5", "phantomjs-prebuilt": "^2.1.7", - "pouchdb-adapter-http": "^5.4.4", - "pouchdb-adapter-memory": "^5.4.4", - "pouchdb-core": "^5.4.4", - "pouchdb-mapreduce": "^5.4.4", - "pouchdb-replication": "^5.4.4", + "pouchdb-adapter-http": "6.3.4", + "pouchdb-adapter-memory": "6.3.4", + "pouchdb-core": "6.3.4", + "pouchdb-mapreduce": "6.3.4", + "pouchdb-replication": "6.3.4", "request": "^2.36.0", "sauce-connect-launcher": "^0.14.0", "selenium-standalone": "^5.1.0", From d33bc61e770f0dbacdbbd9fd20d5a74ad1b0c39a Mon Sep 17 00:00:00 2001 From: Jakob Westhoff Date: Fri, 21 Jul 2017 11:07:36 +0200 Subject: [PATCH 2/5] Bumped pouchdb-wrappers to branch with fixed race condition Until the corresponding PR is merged into the project, this branch should do the trick. It is a version 1.3.6 + the race condition fix. Once the PR is merged and a new release is issued this needs to be switched back to the real realease. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5a4bee3..661772d 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "lie": "3.0.4", "pouchdb-extend": "0.1.2", "pouchdb-promise": "6.3.4", - "pouchdb-wrappers": "1.3.6", + "pouchdb-wrappers": "jakobwesthoff/pouchdb-wrappers#taskqueue-race", "immediate": "~3.0.5" }, "devDependencies": { From 6bdaebc47bd1438847b6ac1e7981c29ba95950a7 Mon Sep 17 00:00:00 2001 From: Jakob Westhoff Date: Fri, 21 Jul 2017 12:05:58 +0200 Subject: [PATCH 3/5] All Promises should use `util.Promise` --- index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/index.js b/index.js index 15ee6a6..5ed43d0 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,5 @@ 'use strict'; -var Promise = require('lie'); var utils = require('./pouch-utils'); var wrappers = require('pouchdb-wrappers'); var immediate = require('immediate'); @@ -93,7 +92,7 @@ exports.transform = exports.filter = function transform(config) { for (var i = 0; i < args.docs.length; i++) { args.docs[i] = incoming(args.docs[i]); } - return Promise.all(args.docs).then(function (docs) { + return utils.Promise.all(args.docs).then(function (docs) { args.docs = docs; return orig(); }); From 56719eb3e9678cbfb8cd06deb7798a280eab99e1 Mon Sep 17 00:00:00 2001 From: Jakob Westhoff Date: Fri, 21 Jul 2017 12:06:24 +0200 Subject: [PATCH 4/5] Fixed transformation for adapters with dedicated `put` implementation --- index.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/index.js b/index.js index 5ed43d0..a915c8a 100644 --- a/index.js +++ b/index.js @@ -88,6 +88,26 @@ exports.transform = exports.filter = function transform(config) { }); }; + handlers.put = function (orig, args) { + if (args.base._put) { + // Not all adapters have a dedicated put implementation. + // Some reuse the bulkDocs API for that. Unfortunately not all. + // Therefore only adapters with a specific PUT implementation + // are overwritten here. Others are already handled through the + // bulkDocs overwrite. + return utils.Promise.resolve() + .then(function() { + return incoming(args.doc); + }) + .then(function(transformedDocument) { + args.doc = transformedDocument; + return orig(); + }); + } else { + return orig(); + } + }; + handlers.bulkDocs = function (orig, args) { for (var i = 0; i < args.docs.length; i++) { args.docs[i] = incoming(args.docs[i]); From ac4123adebdae3f8a8ce8d503e875e5bf6900f14 Mon Sep 17 00:00:00 2001 From: Jakob Westhoff Date: Mon, 24 Jul 2017 10:34:53 +0200 Subject: [PATCH 5/5] Fixed PhantomJS test runs by including Promise polyfill --- package.json | 6 +++--- test/test.js | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 661772d..8e59e8f 100644 --- a/package.json +++ b/package.json @@ -34,12 +34,11 @@ "dependencies": { "argsarray": "0.0.1", "es3ify": "0.2.2", + "immediate": "~3.0.5", "inherits": "2.0.1", - "lie": "3.0.4", "pouchdb-extend": "0.1.2", "pouchdb-promise": "6.3.4", - "pouchdb-wrappers": "jakobwesthoff/pouchdb-wrappers#taskqueue-race", - "immediate": "~3.0.5" + "pouchdb-wrappers": "jakobwesthoff/pouchdb-wrappers#taskqueue-race" }, "devDependencies": { "bluebird": "^1.0.7", @@ -49,6 +48,7 @@ "http-server": "~0.5.5", "istanbul": "^0.2.7", "jshint": "~2.8.0", + "lie": "^3.1.1", "mocha": "^2.4.5", "phantomjs-prebuilt": "^2.1.7", "pouchdb-adapter-http": "6.3.4", diff --git a/test/test.js b/test/test.js index f199bad..c2cd651 100644 --- a/test/test.js +++ b/test/test.js @@ -1,6 +1,9 @@ /*jshint expr:true */ 'use strict'; +// PhantomJs does not support native Promises +require('lie/polyfill'); + var Pouch = require('pouchdb-core') .plugin(require('pouchdb-mapreduce')) .plugin(require('pouchdb-replication'))