cloudant-nano
Advanced tools
Comparing version 6.4.1 to 6.5.0
@@ -1,8 +0,18 @@ | ||
# DCO | ||
# Contributing to nano | ||
To contribute to this project you must accept our [developer certificate of origin](https://github.com/dscape/nano/blob/master/README.md) | ||
Please take a moment to review this document in order to make the contribution | ||
process easy and effective for everyone involved. | ||
Following these guidelines helps to communicate that you respect the time of | ||
the developers managing and developing this open source project. In return, | ||
they should reciprocate that respect in addressing your issue, assessing | ||
changes, and helping you finalize your pull requests. | ||
Contributions to CouchDB are governed by our [Code of Conduct][6] and a set of | ||
[Project Bylaws][7]. Apache CouchDB itself also has a [CONTRIBUTING.md][9] if | ||
you want to help with the larger project. Come join us! | ||
# Contributing | ||
Everyone is welcome to contribute with patches, bug-fixes and new features | ||
Everyone is welcome to contribute with patches, bug-fixes and new features. | ||
@@ -18,3 +28,3 @@ 1. Create an [issue][2] on github so the community can comment on your idea | ||
to run tests make sure you npm test but also run tests without mocks: | ||
To run tests, make sure you run `npm test` but also run tests without mocks: | ||
@@ -43,2 +53,6 @@ ``` sh | ||
[2]: http://github.com/dscape/nano/issues | ||
[2]: http://github.com/apache/couchdb-nano/issues | ||
[6]: http://couchdb.apache.org/conduct.html | ||
[7]: http://couchdb.apache.org/bylaws.html | ||
[9]: https://github.com/apache/couchdb/blob/master/CONTRIBUTING.md | ||
@@ -21,3 +21,3 @@ // Licensed under the Apache License, Version 2.0 (the 'License'); you may not | ||
var _ = require('underscore'); | ||
var follow = require('follow'); | ||
var follow = require('cloudant-follow'); | ||
var logger = require('./logger'); | ||
@@ -29,2 +29,3 @@ | ||
var serverScope = {}; | ||
var replications = {}; | ||
@@ -194,3 +195,3 @@ if (typeof cfg === 'string') { | ||
return httpAgent(req, function(e, h, b) { | ||
return httpAgent(req, function(e, h, b) { | ||
rh = h && h.headers || {}; | ||
@@ -336,2 +337,3 @@ rh.statusCode = h && h.statusCode || 500; | ||
qs = qs || {}; | ||
qs.db = urlResolveFix(cfg.url, encodeURIComponent(dbName)); | ||
@@ -360,3 +362,3 @@ | ||
} | ||
// _replicate | ||
opts.source = _serializeAsUrl(source); | ||
@@ -378,2 +380,33 @@ opts.target = _serializeAsUrl(target); | ||
// http://guide.couchdb.org/draft/replication.html | ||
function enableReplication(source, target, opts, callback) { | ||
if (typeof opts === 'function') { | ||
callback = opts; | ||
opts = {}; | ||
} | ||
// _replicator | ||
opts.source = _serializeAsUrl(source); | ||
opts.target = _serializeAsUrl(target); | ||
return relax({db: '_replicator', body: opts, method: 'POST'}, callback); | ||
} | ||
// http://guide.couchdb.org/draft/replication.html | ||
function queryReplication(id, opts, callback) { | ||
if (typeof opts === 'function') { | ||
callback = opts; | ||
opts = {}; | ||
} | ||
return relax({db: '_replicator', method: 'GET', path: id}, callback); | ||
} | ||
// http://guide.couchdb.org/draft/replication.html | ||
function disableReplication(id, rev, opts, callback) { | ||
if (typeof opts === 'function') { | ||
callback = opts; | ||
opts = {}; | ||
} | ||
return relax({db: '_replicator', method: 'DELETE', path: id, qs: {rev: rev}}, callback); | ||
} | ||
function docModule(dbName) { | ||
@@ -523,2 +556,3 @@ var docScope = {}; | ||
} | ||
qs = qs || {}; | ||
@@ -631,2 +665,3 @@ var viewPath = '_design/' + ddoc + '/_' + meta.type + '/' + viewName; | ||
} | ||
qs = qs || {}; | ||
@@ -671,2 +706,3 @@ var docName = qs.docName; | ||
} | ||
qs = qs || {}; | ||
@@ -772,3 +808,15 @@ qs.attachments = true; | ||
view: viewDocs, | ||
viewWithList: viewWithList | ||
viewWithList: viewWithList, | ||
server: serverScope, | ||
replication: { | ||
enable: function(target, opts, cb) { | ||
return enableReplication(dbName, target, opts, cb); | ||
}, | ||
disable: function(id, revision, opts, cb) { | ||
return disableReplication(id, revision, opts, cb); | ||
}, | ||
query: function(id, opts, cb) { | ||
return queryReplication(id, opts, cb); | ||
} | ||
} | ||
}; | ||
@@ -794,2 +842,7 @@ | ||
replicate: replicateDb, | ||
replication: { | ||
enable: enableReplication, | ||
disable: disableReplication, | ||
query: queryReplication | ||
}, | ||
changes: changesDb, | ||
@@ -796,0 +849,0 @@ follow: followDb, |
{ | ||
"name": "cloudant-nano", | ||
"description": "A Cloudant-specific fork of the official CouchDB client for Node.js", | ||
"description": "A minimalistic Cloudant/CouchDB driver for Node.js", | ||
"license": "Apache-2.0", | ||
"homepage": "http://github.com/cloudant-labs/cloudant-nano", | ||
"repository": "git://github.com/cloudant-labs/cloudant-nano", | ||
"version": "6.4.1", | ||
"author": "Glynn Bird <glynn.bird@gmail.com>", | ||
"homepage": "https://github.com/cloudant-labs/cloudant-nano", | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:cloudant-labs/cloudant-nano.git" | ||
}, | ||
"version": "6.5.0", | ||
"author": { | ||
"name": "IBM Cloudant", | ||
"email": "support@cloudant.com" | ||
}, | ||
"keywords": [ | ||
"cloudant", | ||
"couchdb", | ||
@@ -20,4 +27,4 @@ "data", | ||
"dependencies": { | ||
"request": "^2.76.0", | ||
"follow": "^0.12.1", | ||
"request": "^2.81.0", | ||
"cloudant-follow": "^0.13.0", | ||
"errs": "^0.3.2", | ||
@@ -38,3 +45,3 @@ "underscore": "^1.8.3", | ||
"scripts": { | ||
"test": "bash scripts/run_couchdb_on_travis.sh; npm run mocha; bash scripts/stop_couchdb_on_travis.sh", | ||
"test": "bash scripts/run_couchdb_on_travis.sh && npm run mocha && bash scripts/stop_couchdb_on_travis.sh", | ||
"mocha": "DEBUG=* NOCK_OFF=true istanbul cover tape tests/*/*/*.js", | ||
@@ -41,0 +48,0 @@ "unmocked": "NOCK_OFF=true tape tests/*/*/*.js", |
124
README.md
@@ -1,18 +0,7 @@ | ||
[](http://yld.io/contact?source=github-nano)[](https://gitter.im/dscape/nano)[](https://travis-ci.org/dscape/nano)[](https://david-dm.org/dscape/nano)[](http://browsenpm.org/package/nano) | ||
[](https://travis-ci.org/apache/couchdb-nano)[](https://david-dm.org/apache/couchdb-nano)[](https://www.npmjs.com/package/nano) | ||
# cloudant-nano | ||
# nano | ||
minimalistic couchdb driver for node.js | ||
------------------------------------------------- | ||
This is a fork of the [Apache CouchDB Nano](https://github.com/apache/couchdb-nano) project. Which can be used with `npm install nano`. *This* fork | ||
is maintained here because the [Cloudant Node.js Library](https://github.com/cloudant/nodejs-cloudant) is dependent on the Nano and we (Cloudant) | ||
needed a version of this library with up-to-date Travis tests, newer dependency versions and some bug fixes. The changes found in this repo may | ||
eventually make their way into the Apache project, when Apache CouchDB Nano is properly open for business. | ||
This library is usually consumed by using the [Cloudant npm package](https://www.npmjs.com/package/cloudant) e.g. `npm install cloudant`. | ||
------------------------------------------------- | ||
`nano` features: | ||
@@ -43,2 +32,5 @@ | ||
- [nano.db.replicate(source, target, [opts], [callback])](#nanodbreplicatesource-target-opts-callback) | ||
- [nano.db.replication.enable(source, target, [opts], [callback])](#nanodbreplicatorenablesource-target-opts-callback) | ||
- [nano.db.replication.query(id, [opts], [callback])](#nanodbreplicatorquery-id-opts-callback) | ||
- [nano.db.replication.disable(id, [opts], [callback])](#nanodbreplicatordisable-id-opts-callback) | ||
- [nano.db.changes(name, [params], [callback])](#nanodbchangesname-params-callback) | ||
@@ -289,2 +281,51 @@ - [nano.db.follow(name, [params], [callback])](#nanodbfollowname-params-callback) | ||
### nano.db.replication.enable(source, target, [opts], [callback]) | ||
enables replication using the new couchdb api from `source` to `target` | ||
with options `opts`. `target` has to exist, add `create_target:true` to | ||
`opts` to create it prior to replication. | ||
replication will survive server restarts. | ||
``` js | ||
nano.db.replication.enable('alice', 'http://admin:password@otherhost.com:5984/alice', | ||
{ create_target:true }, function(err, body) { | ||
if (!err) | ||
console.log(body); | ||
}); | ||
``` | ||
### nano.db.replication.query(id, [opts], [callback]) | ||
queries the state of replication using the new couchdb api. `id` comes from the response | ||
given by the call to enable. | ||
``` js | ||
nano.db.replication.enable('alice', 'http://admin:password@otherhost.com:5984/alice', | ||
{ create_target:true }, function(err, body) { | ||
if (!err) { | ||
nano.db.replication.query(body.id, function(error, reply) { | ||
if (!err) | ||
console.log(reply); | ||
} | ||
} | ||
}); | ||
``` | ||
### nano.db.replication.disable(id, [opts], [callback]) | ||
disables replication using the new couchdb api. `id` comes from the response given | ||
by the call to enable. | ||
``` js | ||
nano.db.replication.enable('alice', 'http://admin:password@otherhost.com:5984/alice', | ||
{ create_target:true }, function(err, body) { | ||
if (!err) { | ||
nano.db.replication.disable(body.id, function(error, reply) { | ||
if (!err) | ||
console.log(reply); | ||
} | ||
} | ||
}); | ||
``` | ||
### nano.db.changes(name, [params], [callback]) | ||
@@ -651,2 +692,29 @@ | ||
``` js | ||
alice.view('characters', 'crazy_ones', { | ||
'key': 'Tea Party', | ||
'include_docs': true | ||
}, function(err, body) { | ||
if (!err) { | ||
body.rows.forEach(function(doc) { | ||
console.log(doc.value); | ||
}); | ||
} | ||
}); | ||
``` | ||
``` js | ||
alice.view('characters', 'soldiers', { | ||
'keys': ['Hearts', 'Clubs'] | ||
}, function(err, body) { | ||
if (!err) { | ||
body.rows.forEach(function(doc) { | ||
console.log(doc.value); | ||
}); | ||
} | ||
}); | ||
``` | ||
When `params` is not supplied, or no keys are specified, it will simply return all docs in the view. | ||
``` js | ||
alice.view('characters', 'crazy_ones', function(err, body) { | ||
@@ -661,2 +729,12 @@ if (!err) { | ||
``` js | ||
alice.view('characters', 'crazy_ones', { include_docs: true }, function(err, body) { | ||
if (!err) { | ||
body.rows.forEach(function(doc) { | ||
console.log(doc.value); | ||
}); | ||
} | ||
}); | ||
``` | ||
### db.viewWithList(designname, viewname, listname, [params], [callback]) | ||
@@ -892,15 +970,13 @@ | ||
* code: `git clone git://github.com/dscape/nano.git` | ||
* home: <http://github.com/dscape/nano> | ||
* bugs: <http://github.com/dscape/nano/issues> | ||
* build: [](http://travis-ci.org/dscape/nano) | ||
* deps: [](https://david-dm.org/dscape/nano) | ||
* chat: <https://gitter.im/dscape/nano> | ||
* code: `git clone git://github.com/apache/couchdb-nano.git` | ||
* home: <http://github.com/apache/couchdb-nano> | ||
* bugs: <http://github.com/apache/couchdb-nano/issues> | ||
* build: [](https://travis-ci.org/apache/couchdb-nano) | ||
* deps: [](https://david-dm.org/apache/couchdb-nano) | ||
* chat: [Freenode IRC @ #couchdb-dev][8] | ||
`(oo)--',-` in [caos][3] | ||
[1]: http://npmjs.org | ||
[2]: http://github.com/dscape/nano/issues | ||
[3]: http://caos.di.uminho.pt/ | ||
[4]: https://github.com/dscape/nano/blob/master/cfg/couch.example.js | ||
[2]: http://github.com/apache/couchdb-nano/issues | ||
[4]: https://github.com/apache/couchdb-nano/blob/master/cfg/couch.example.js | ||
[8]: http://webchat.freenode.net?channels=%23couchdb-dev | ||
[follow]: https://github.com/jhs/follow | ||
@@ -907,0 +983,0 @@ [request]: https://github.com/request/request |
[ | ||
{ "method" : "get" | ||
, "path" : "/uuids?count=3" | ||
{ "method" : "put" | ||
, "path" : "/util_uuid" | ||
, "status" : 201 | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
, { "method" : "get" | ||
, "path" : "/_uuids?count=3" | ||
, "status" : 200 | ||
@@ -8,6 +13,11 @@ , "response" : "{ \"uuids\": [\"1\",\"2\",\"3\"] }" | ||
, { "method" : "get" | ||
, "path" : "/uuids" | ||
, "path" : "/_uuids?count=1" | ||
, "status" : 200 | ||
, "response" : "{ \"uuids\": [\"1\"] }" | ||
} | ||
, { "method" : "delete" | ||
, "path" : "/util_uuid" | ||
, "status" : 200 | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
] |
@@ -59,3 +59,14 @@ // Licensed under the Apache License, Version 2.0 (the 'License'); you may not | ||
if(method[0] === 'database') { | ||
f = cli.server.db[method[1]]; | ||
// | ||
// Due to the way this harness is designed we cannot differentiate between different methods | ||
// when those methods are embedded on an object. | ||
// We have two options, either we hardcode the resolution or we write a full harness that | ||
// can differentiate between methods embedded on an object. | ||
// I go the hardcoded route for now. | ||
// | ||
if (method[1] === 'replicator') { | ||
f = cli.server.db.replication.enable; | ||
} else { | ||
f = cli.server.db[method[1]]; | ||
} | ||
} else if(method[0] === 'view' && method[1] === 'compact') { | ||
@@ -62,0 +73,0 @@ f = cli.view.compact; |
@@ -26,4 +26,5 @@ // Licensed under the Apache License, Version 2.0 (the 'License'); you may not | ||
assert.equal(error, null, 'should generate uuids'); | ||
assert.ok(data, 'got response'); | ||
assert.ok(data.uuids, 'got uuids'); | ||
assert.equal(data.uuids.count, 3, 'got 3'); | ||
assert.equal(data.uuids.length, 3, 'got 3'); | ||
assert.end(); | ||
@@ -36,6 +37,7 @@ }); | ||
assert.equal(error, null, 'should generate uuids'); | ||
assert.ok(data.uuids, 'got uuids'); | ||
assert.equal(data.uuids.count, 1, 'got 1'); | ||
assert.ok(data, 'got response'); | ||
assert.ok(data.uuids, 'got uuid'); | ||
assert.equal(data.uuids.length, 1, 'got 1'); | ||
assert.end(); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
241654
134
5558
995
6
1
+ Addedcloudant-follow@^0.13.0
+ Addedajv@4.11.8(transitive)
+ Addedassert-plus@0.2.0(transitive)
+ Addedaws-sign2@0.6.0(transitive)
+ Addedcall-bind@1.0.8(transitive)
+ Addedcall-bind-apply-helpers@1.0.2(transitive)
+ Addedcall-bound@1.0.3(transitive)
+ Addedcloudant-follow@0.13.0(transitive)
+ Addedco@4.6.0(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddunder-proto@1.0.1(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.1.1(transitive)
+ Addedform-data@2.1.4(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.3.0(transitive)
+ Addedget-proto@1.0.1(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhar-schema@1.0.5(transitive)
+ Addedhar-validator@4.2.1(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhawk@3.1.3(transitive)
+ Addedhttp-signature@1.1.1(transitive)
+ Addedisarray@2.0.5(transitive)
+ Addedjson-stable-stringify@1.2.1(transitive)
+ Addedjsonify@0.0.1(transitive)
+ Addedmath-intrinsics@1.1.0(transitive)
+ Addedoauth-sign@0.8.2(transitive)
+ Addedobject-keys@1.1.1(transitive)
+ Addedperformance-now@0.2.0(transitive)
+ Addedpunycode@1.4.1(transitive)
+ Addedqs@6.4.1(transitive)
+ Addedrequest@2.81.0(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedtough-cookie@2.3.4(transitive)
- Removedfollow@^0.12.1
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedasn1@0.1.11(transitive)
- Removedassert-plus@0.1.5(transitive)
- Removedasync@0.9.2(transitive)
- Removedaws-sign2@0.5.0(transitive)
- Removedbl@0.9.5(transitive)
- Removedbluebird@2.11.0(transitive)
- Removedcaseless@0.9.0(transitive)
- Removedchalk@1.1.3(transitive)
- Removedcombined-stream@0.0.7(transitive)
- Removedcommander@2.20.3(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removedctype@0.5.3(transitive)
- Removeddelayed-stream@0.0.5(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedfollow@0.12.1(transitive)
- Removedform-data@0.2.0(transitive)
- Removedgenerate-function@2.3.1(transitive)
- Removedgenerate-object-property@1.2.0(transitive)
- Removedhar-validator@1.8.0(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedhawk@2.3.1(transitive)
- Removedhttp-signature@0.10.1(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-my-ip-valid@1.0.1(transitive)
- Removedis-my-json-valid@2.20.6(transitive)
- Removedis-property@1.0.2(transitive)
- Removedisarray@0.0.1(transitive)
- Removedjsonpointer@5.0.1(transitive)
- Removedmime-db@1.12.0(transitive)
- Removedmime-types@2.0.14(transitive)
- Removednode-uuid@1.4.8(transitive)
- Removedoauth-sign@0.6.0(transitive)
- Removedqs@2.4.2(transitive)
- Removedreadable-stream@1.0.34(transitive)
- Removedrequest@2.55.0(transitive)
- Removedstring_decoder@0.10.31(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsupports-color@2.0.0(transitive)
- Removedtldts@6.1.79(transitive)
- Removedtldts-core@6.1.79(transitive)
- Removedtough-cookie@5.1.1(transitive)
- Removedtunnel-agent@0.4.3(transitive)
- Removedxtend@4.0.2(transitive)
Updatedrequest@^2.81.0