Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nano

Package Overview
Dependencies
Maintainers
7
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nano - npm Package Compare versions

Comparing version 8.0.1 to 8.1.0

19

lib/nano.d.ts

@@ -55,5 +55,11 @@ // Type definitions for nano 6.4

interface DatabaseCreateParams {
n?: number;
partitioned?: boolean;
q?: number;
}
interface DatabaseScope {
// http://docs.couchdb.org/en/latest/api/database/common.html#put--db
create(name: string, callback?: Callback<DatabaseCreateResponse>): Promise<DatabaseCreateResponse>;
create(name: string, params?: DatabaseCreateParams, callback?: Callback<DatabaseCreateResponse>): Promise<DatabaseCreateResponse>;
// http://docs.couchdb.org/en/latest/api/database/common.html#get--db

@@ -238,2 +244,9 @@ get(name: string, callback?: Callback<DatabaseGetResponse>): Promise<DatabaseGetResponse>;

): Request;
baseView<V>(
designname: string,
viewname: string,
meta: any,
params?: any,
callback?: Callback<any>
): Promise<any>;
// http://docs.couchdb.org/en/latest/api/ddoc/views.html#get--db-_design-ddoc-_view-view

@@ -1167,3 +1180,3 @@ // http://docs.couchdb.org/en/latest/api/ddoc/views.html#post--db-_design-ddoc-_view-view

value: V;
doc?: D;
doc?: D & Document;
}>;

@@ -1178,3 +1191,3 @@

type MangoValue = number | string | Date | boolean;
type MangoValue = number | string | Date | boolean | null;

@@ -1181,0 +1194,0 @@ // http://docs.couchdb.org/en/latest/api/database/find.html#selector-syntax

170

lib/nano.js

@@ -43,6 +43,6 @@ // Licensed under the Apache License, Version 2.0 (the 'License'); you may not

if (typeof cfg === 'string') {
cfg = {url: cfg}
cfg = { url: cfg }
}
assert.equal(typeof cfg, 'object',
assert.strictEqual(typeof cfg, 'object',
'You must specify the endpoint url when invoking this module')

@@ -92,3 +92,3 @@ assert.ok(/^https?:/.test(cfg.url), 'url is not valid')

if (err) {
log({err: 'socket', body: body, headers: responseHeaders})
log({ err: 'socket', body: body, headers: responseHeaders })
const returnError = errs.merge(err, {

@@ -118,3 +118,3 @@ message: 'error happened in your connection',

if (responseHeaders.statusCode >= 200 && responseHeaders.statusCode < 400) {
log({err: null, body: parsed, headers: responseHeaders})
log({ err: null, body: parsed, headers: responseHeaders })
if (resolve) {

@@ -129,7 +129,7 @@ resolve(parsed)

log({err: 'couch', body: parsed, headers: responseHeaders})
log({ err: 'couch', body: parsed, headers: responseHeaders })
// cloudant stacktrace
if (typeof parsed === 'string') {
parsed = {message: parsed}
parsed = { message: parsed }
}

@@ -172,11 +172,11 @@

callback = opts
opts = {path: ''}
opts = { path: '' }
}
if (typeof opts === 'string') {
opts = {path: opts}
opts = { path: opts }
}
if (!opts) {
opts = {path: ''}
opts = { path: '' }
callback = null

@@ -322,3 +322,3 @@ }

function session (callback) {
return relax({db: '_session'}, callback)
return relax({ db: '_session' }, callback)
}

@@ -328,3 +328,3 @@

function updates (qs0, callback0) {
const {opts, callback} = getCallback(qs0, callback0)
const { opts, callback } = getCallback(qs0, callback0)
return relax({

@@ -341,4 +341,5 @@ db: '_db_updates',

// http://docs.couchdb.org/en/latest/api/database/common.html#put--db
function createDb (dbName, callback) {
return relax({db: dbName, method: 'PUT'}, callback)
function createDb (dbName, qs0, callback0) {
const { opts, callback } = getCallback(qs0, callback0)
return relax({ db: dbName, method: 'PUT', qs: opts }, callback)
}

@@ -348,3 +349,3 @@

function destroyDb (dbName, callback) {
return relax({db: dbName, method: 'DELETE'}, callback)
return relax({ db: dbName, method: 'DELETE' }, callback)
}

@@ -354,3 +355,3 @@

function getDb (dbName, callback) {
return relax({db: dbName}, callback)
return relax({ db: dbName }, callback)
}

@@ -360,3 +361,3 @@

function listDbs (callback) {
return relax({db: '_all_dbs'}, callback)
return relax({ db: '_all_dbs' }, callback)
}

@@ -366,3 +367,3 @@

function listDbsAsStream () {
return relax({db: '_all_dbs', stream: true})
return relax({ db: '_all_dbs', stream: true })
}

@@ -386,12 +387,12 @@

function changesDb (dbName, qs0, callback0) {
const {opts, callback} = getCallback(qs0, callback0)
return relax({db: dbName, path: '_changes', qs: opts}, callback)
const { opts, callback } = getCallback(qs0, callback0)
return relax({ db: dbName, path: '_changes', qs: opts }, callback)
}
function changesDbAsStream (dbName, opts) {
return relax({db: dbName, path: '_changes', stream: true, qs: opts})
return relax({ db: dbName, path: '_changes', stream: true, qs: opts })
}
function followDb (dbName, qs0, callback0) {
const {opts, callback} = getCallback(qs0, callback0)
const { opts, callback } = getCallback(qs0, callback0)
opts.db = urlResolveFix(cfg.url, encodeURIComponent(dbName))

@@ -421,3 +422,3 @@ opts.httpAgent = httpAgent

function replicateDb (source, target, opts0, callback0) {
const {opts, callback} = getCallback(opts0, callback0)
const { opts, callback } = getCallback(opts0, callback0)

@@ -428,3 +429,3 @@ // _replicate

return relax({db: '_replicate', body: opts, method: 'POST'}, callback)
return relax({ db: '_replicate', body: opts, method: 'POST' }, callback)
}

@@ -438,3 +439,3 @@

}
return relax({method: 'GET', path: '_uuids', qs: {count: count}}, callback)
return relax({ method: 'GET', path: '_uuids', qs: { count: count } }, callback)
}

@@ -444,3 +445,3 @@

function enableReplication (source, target, opts0, callback0) {
const {opts, callback} = getCallback(opts0, callback0)
const { opts, callback } = getCallback(opts0, callback0)

@@ -451,3 +452,3 @@ // _replicator

return relax({db: '_replicator', body: opts, method: 'POST'}, callback)
return relax({ db: '_replicator', body: opts, method: 'POST' }, callback)
}

@@ -457,4 +458,4 @@

function queryReplication (id, opts0, callback0) {
const {opts, callback} = getCallback(opts0, callback0)
return relax({db: '_replicator', method: 'GET', path: id, qs: opts}, callback)
const { opts, callback } = getCallback(opts0, callback0)
return relax({ db: '_replicator', method: 'GET', path: id, qs: opts }, callback)
}

@@ -464,3 +465,3 @@

function disableReplication (id, rev, opts0, callback0) {
const {opts, callback} = getCallback(opts0, callback0)
const { opts, callback } = getCallback(opts0, callback0)
const req = {

@@ -470,3 +471,3 @@ db: '_replicator',

path: id,
qs: Object.assign(opts, {rev: rev})
qs: Object.assign(opts, { rev: rev })
}

@@ -483,8 +484,8 @@ return relax(req, callback)

function insertDoc (doc, qs0, callback0) {
const req = {db: dbName, body: doc, method: 'POST'}
const req = { db: dbName, body: doc, method: 'POST' }
let {opts, callback} = getCallback(qs0, callback0)
let { opts, callback } = getCallback(qs0, callback0)
if (typeof opts === 'string') {
opts = {docName: opts}
opts = { docName: opts }
}

@@ -518,3 +519,3 @@

method: 'DELETE',
qs: {rev: rev}
qs: { rev: rev }
}, callback)

@@ -526,3 +527,3 @@ }

function getDoc (docName, qs0, callback0) {
const {opts, callback} = getCallback(qs0, callback0)
const { opts, callback } = getCallback(qs0, callback0)

@@ -532,3 +533,3 @@ if (!docName) {

} else {
return relax({db: dbName, doc: docName, qs: opts}, callback)
return relax({ db: dbName, doc: docName, qs: opts }, callback)
}

@@ -568,3 +569,3 @@ }

function copyDoc (docSrc, docDest, opts0, callback0) {
const {opts, callback} = getCallback(opts0, callback0)
const { opts, callback } = getCallback(opts0, callback0)

@@ -575,3 +576,3 @@ const qs = {

method: 'COPY',
headers: {'Destination': docDest}
headers: { 'Destination': docDest }
}

@@ -610,4 +611,4 @@

function listDoc (qs0, callback0) {
const {opts, callback} = getCallback(qs0, callback0)
return relax({db: dbName, path: '_all_docs', qs: opts}, callback)
const { opts, callback } = getCallback(qs0, callback0)
return relax({ db: dbName, path: '_all_docs', qs: opts }, callback)
}

@@ -617,3 +618,3 @@

function listDocAsStream (opts) {
return relax({db: dbName, path: '_all_docs', qs: opts, stream: true})
return relax({ db: dbName, path: '_all_docs', qs: opts, stream: true })
}

@@ -623,3 +624,3 @@

function fetchDocs (docNames, qs0, callback0) {
const {opts, callback} = getCallback(qs0, callback0)
const { opts, callback } = getCallback(qs0, callback0)
opts['include_docs'] = true

@@ -637,3 +638,3 @@

function fetchRevs (docNames, qs0, callback0) {
const {opts, callback} = getCallback(qs0, callback0)
const { opts, callback } = getCallback(qs0, callback0)
return relax({

@@ -649,3 +650,3 @@ db: dbName,

function view (ddoc, viewName, meta, qs0, callback0) {
const {opts, callback} = getCallback(qs0, callback0)
const { opts, callback } = getCallback(qs0, callback0)

@@ -659,43 +660,15 @@ if (typeof meta.stream !== 'boolean') {

const viewPath = '_design/' + ddoc + '/_' + meta.type + '/' + viewName
const viewPath = meta.viewPath || '_design/' + ddoc + '/_' + meta.type +
'/' + viewName
// Several search parameters must be JSON-encoded; but since this is an
// object API, several parameters need JSON endoding.
const paramsToEncode = ['counts', 'group_sort', 'ranges', 'sort']
paramsToEncode.forEach(function (param) {
if (param in qs1) {
if (typeof qs1[param] !== 'string') {
qs1[param] = JSON.stringify(qs1[param])
} else {
// if the parameter is not already encoded, encode it
try {
JSON.parse(qs1[param])
} catch (e) {
qs1[param] = JSON.stringify(qs1[param])
}
}
}
})
// the drilldown parameter needs special treatment. It can either be:
// - a single array of strings e.g. ['author', 'Dickens']
// - an array of arrays e.g. [['author','Dickens']['publisher','Penguin']]
// The former should be JSON.stringified the latter should be an array of
// JSON.stringified arrays(!).
if (qs1['drilldown']) {
// if this is an array of arrays
if (Array.isArray(qs1['drilldown']) &&
qs1['drilldown'].length > 0 &&
Array.isArray(qs1['drilldown'][0])) {
// JSON stringify each element of the array
qs1['drilldown'] = qs1['drilldown'].map(function (val) {
return JSON.stringify(val)
})
} else if (Array.isArray(qs1['drilldown'])) {
qs1['drilldown'] = JSON.stringify(qs1['drilldown'])
}
}
if (qs1 && qs1.keys) {
const body = {keys: qs1.keys}
if (meta.type === 'search') {
return relax({
db: dbName,
path: viewPath,
method: 'POST',
body: qs1,
stream: meta.stream
}, callback)
} else if (qs1 && qs1.keys) {
const body = { keys: qs1.keys }
delete qs1.keys

@@ -711,3 +684,3 @@ return relax({

} else if (qs1 && qs1.queries) {
const body = {queries: qs1.queries}
const body = { queries: qs1.queries }
delete qs1.queries

@@ -740,3 +713,3 @@ return relax({

function viewDocs (ddoc, viewName, qs, callback) {
return view(ddoc, viewName, {type: 'view'}, qs, callback)
return view(ddoc, viewName, { type: 'view' }, qs, callback)
}

@@ -746,3 +719,3 @@

function viewDocsAsStream (ddoc, viewName, qs) {
return view(ddoc, viewName, {type: 'view', stream: true}, qs)
return view(ddoc, viewName, { type: 'view', stream: true }, qs)
}

@@ -752,3 +725,3 @@

function viewSearch (ddoc, viewName, qs, callback) {
return view(ddoc, viewName, {type: 'search'}, qs, callback)
return view(ddoc, viewName, { type: 'search' }, qs, callback)
}

@@ -758,3 +731,3 @@

function viewSearchAsStream (ddoc, viewName, qs) {
return view(ddoc, viewName, {type: 'search', stream: true}, qs)
return view(ddoc, viewName, { type: 'search', stream: true }, qs)
}

@@ -764,3 +737,3 @@

function showDoc (ddoc, viewName, docName, qs, callback) {
return view(ddoc, viewName + '/' + docName, {type: 'show'}, qs, callback)
return view(ddoc, viewName + '/' + docName, { type: 'show' }, qs, callback)
}

@@ -789,3 +762,3 @@

function bulksDoc (docs, qs0, callback0) {
const {opts, callback} = getCallback(qs0, callback0)
const { opts, callback } = getCallback(qs0, callback0)
return relax({

@@ -803,3 +776,3 @@ db: dbName,

if (typeof qs === 'string') {
qs = {docName: qs}
qs = { docName: qs }
}

@@ -811,3 +784,3 @@ qs = qs || {}

doc = Object.assign({_attachments: {}}, doc)
doc = Object.assign({ _attachments: {} }, doc)

@@ -824,3 +797,3 @@ const multipart = []

}
multipart.push({body: att.data})
multipart.push({ body: att.data })
})

@@ -844,3 +817,3 @@

function getMultipart (docName, qs0, callback0) {
const {opts, callback} = getCallback(qs0, callback0)
const { opts, callback } = getCallback(qs0, callback0)
opts.attachments = true

@@ -858,3 +831,3 @@

function insertAtt (docName, attName, att, contentType, qs0, callback0) {
const {opts, callback} = getCallback(qs0, callback0)
const { opts, callback } = getCallback(qs0, callback0)
return relax({

@@ -887,3 +860,3 @@ db: dbName,

function getAtt (docName, attName, qs0, callback0) {
const {opts, callback} = getCallback(qs0, callback0)
const { opts, callback } = getCallback(qs0, callback0)
return relax({

@@ -981,3 +954,3 @@ db: dbName,

fetchRevs: fetchRevs,
config: {url: cfg.url, db: dbName},
config: { url: cfg.url, db: dbName },
multipart: {

@@ -997,2 +970,3 @@ insert: insertMultipart,

updateWithHandler: updateWithHandler,
baseView: view,
search: viewSearch,

@@ -999,0 +973,0 @@ searchAsStream: viewSearchAsStream,

@@ -7,3 +7,3 @@ {

"repository": "http://github.com/apache/couchdb-nano",
"version": "8.0.1",
"version": "8.1.0",
"author": "Apache CouchDB <dev@couchdb.apache.org> (http://couchdb.apache.org)",

@@ -22,13 +22,13 @@ "keywords": [

"@types/request": "^2.47.1",
"cloudant-follow": "^0.18.0",
"debug": "^2.2.0",
"cloudant-follow": "^0.18.1",
"debug": "^4.1.1",
"errs": "^0.3.2",
"request": "^2.85.0"
"request": "^2.88.0"
},
"devDependencies": {
"async": "^2.1.2",
"async": "^2.6.2",
"istanbul": "^0.4.5",
"nock": "^9.6.1",
"standard": "^11.0.1",
"tape": "^4.6.2"
"nock": "^10.0.6",
"standard": "^12.0.1",
"tape": "^4.10.1"
},

@@ -35,0 +35,0 @@ "scripts": {

@@ -653,3 +653,3 @@ [![Build Status](https://travis-ci.org/apache/couchdb-nano.svg?branch=master)](https://travis-ci.org/apache/couchdb-nano)![Coverage](https://img.shields.io/badge/coverage-100%-ff69b4.svg)[![dependencies Status](https://david-dm.org/apache/couchdb-nano/status.svg)](https://david-dm.org/apache/couchdb-nano)[![NPM](http://img.shields.io/npm/v/nano.svg?style=flat-square)](https://www.npmjs.com/package/nano)

body.rows.forEach((doc) => {
// output eacj document's body
// output each document's body
console.log(doc.doc);

@@ -656,0 +656,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc