Socket
Socket
Sign inDemoInstall

@ibm-cloud/cloudant

Package Overview
Dependencies
Maintainers
2
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ibm-cloud/cloudant - npm Package Compare versions

Comparing version 0.0.13 to 0.0.14

4

auth/couchdbSessionAuthenticator.d.ts
/**
* © Copyright IBM Corporation 2020.
* © Copyright IBM Corporation 2021. All Rights Reserved.
*

@@ -39,3 +39,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

protected tokenManager: SessionTokenManager;
protected requiredOptions: ["username", "password"];
protected requiredOptions: ['username', 'password'];
private tokenOptions;

@@ -42,0 +42,0 @@ /**

"use strict";
/**
* © Copyright IBM Corporation 2020.
* © Copyright IBM Corporation 2021. All Rights Reserved.
*

@@ -21,3 +21,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -24,0 +24,0 @@ };

/**
* © Copyright IBM Corporation 2020.
* © Copyright IBM Corporation 2020. All Rights Reserved.
*

@@ -4,0 +4,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

"use strict";
/**
* © Copyright IBM Corporation 2020.
* © Copyright IBM Corporation 2020. All Rights Reserved.
*

@@ -18,2 +18,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

Object.defineProperty(exports, "__esModule", { value: true });
exports.SessionTokenManager = exports.CouchdbSessionAuthenticator = exports.getAuthenticatorFromEnvironment = exports.IamTokenManager = exports.IamAuthenticator = exports.BasicAuthenticator = exports.NoAuthAuthenticator = void 0;
var ibm_cloud_sdk_core_1 = require("ibm-cloud-sdk-core");

@@ -20,0 +21,0 @@ Object.defineProperty(exports, "NoAuthAuthenticator", { enumerable: true, get: function () { return ibm_cloud_sdk_core_1.NoAuthAuthenticator; } });

/**
* © Copyright IBM Corporation 2020.
* © Copyright IBM Corporation 2020. All Rights Reserved.
*

@@ -17,3 +17,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

/// <reference types="node" />
import { OutgoingHttpHeaders } from "http";
import { OutgoingHttpHeaders } from 'http';
import { TokenManager, UserOptions } from 'ibm-cloud-sdk-core';

@@ -20,0 +20,0 @@ /** Configuration options for CouchDB session token retrieval. */

"use strict";
/**
* © Copyright IBM Corporation 2020.
* © Copyright IBM Corporation 2020. All Rights Reserved.
*

@@ -21,3 +21,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -60,3 +60,8 @@ };

var _this = _super.call(this, options) || this;
_this.requiredOptions = ['username', 'password', 'serviceUrl', 'jar'];
_this.requiredOptions = [
'username',
'password',
'serviceUrl',
'jar',
];
ibm_cloud_sdk_core_1.validateInput(options, _this.requiredOptions);

@@ -94,5 +99,5 @@ _this.options = options;

username: this.options.username,
password: this.options.password
}
}
password: this.options.password,
},
},
};

@@ -139,3 +144,4 @@ return this.requestWrapperInstance.sendRequest(parameters);

this.expireTime = Number(refreshTime[1]) + ibm_cloud_sdk_core_1.getCurrentTime();
this.refreshTime = (Number(refreshTime[1]) * fractionOfTtl) + ibm_cloud_sdk_core_1.getCurrentTime();
this.refreshTime =
Number(refreshTime[1]) * fractionOfTtl + ibm_cloud_sdk_core_1.getCurrentTime();
}

@@ -148,3 +154,3 @@ }

var timeToLive = this.expireTime - ibm_cloud_sdk_core_1.getCurrentTime();
this.refreshTime = this.expireTime - (timeToLive * (1.0 - fractionOfTtl));
this.refreshTime = this.expireTime - timeToLive * (1.0 - fractionOfTtl);
}

@@ -151,0 +157,0 @@ };

/**
* © Copyright IBM Corporation 2020.
* © Copyright IBM Corporation 2020. All Rights Reserved.
*

@@ -19,3 +19,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

*/
export import CloudantV1 = require("./cloudant/v1");
export { BasicAuthenticator, IamAuthenticator, CouchdbSessionAuthenticator } from './auth';
export import CloudantV1 = require('./cloudant/v1');
export { BasicAuthenticator, IamAuthenticator, CouchdbSessionAuthenticator, } from './auth';
"use strict";
/**
* © Copyright IBM Corporation 2020.
* © Copyright IBM Corporation 2020. All Rights Reserved.
*

@@ -18,5 +18,7 @@ * Licensed under the Apache License, Version 2.0 (the "License");

Object.defineProperty(exports, "__esModule", { value: true });
exports.CouchdbSessionAuthenticator = exports.IamAuthenticator = exports.BasicAuthenticator = void 0;
/**
* @module cloudant-node-sdk
*/
// eslint-disable-next-line no-unused-vars
exports.CloudantV1 = require("./cloudant/v1");

@@ -23,0 +25,0 @@ var auth_1 = require("./auth");

/**
* © Copyright IBM Corporation 2020.
* © Copyright IBM Corporation 2020. All Rights Reserved.
*

@@ -16,3 +16,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

*/
import { BaseService, UserOptions } from "ibm-cloud-sdk-core";
import { BaseService, UserOptions } from 'ibm-cloud-sdk-core';
/**

@@ -51,2 +51,10 @@ * Cloudant specific service that extends the base service functions.

/**
* Turn request body compression on or off.
* Cloudant specific extensions:
* - Apply the gzip compression option on CouchdbSessionAuthenticator.
*
* @param {boolean} setting Will turn it on if 'true', off if 'false'.
*/
setEnableGzipCompression(setting: boolean): void;
/**
* In case of CouchdbSessionAuthenticator

@@ -53,0 +61,0 @@ * the service options should be applied on it.

"use strict";
/**
* © Copyright IBM Corporation 2020.
* © Copyright IBM Corporation 2020. All Rights Reserved.
*

@@ -21,3 +21,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -34,2 +34,3 @@ };

var ibm_cloud_sdk_core_1 = require("ibm-cloud-sdk-core");
// eslint-disable-next-line node/no-unpublished-import
var tough_cookie_1 = require("tough-cookie");

@@ -87,2 +88,15 @@ var auth_1 = require("../auth");

/**
* Turn request body compression on or off.
* Cloudant specific extensions:
* - Apply the gzip compression option on CouchdbSessionAuthenticator.
*
* @param {boolean} setting Will turn it on if 'true', off if 'false'.
*/
CloudantBaseService.prototype.setEnableGzipCompression = function (setting) {
// Read external configuration and set as request defaults.
_super.prototype.setEnableGzipCompression.call(this, setting);
this.baseOptions.enableGzipCompression = setting;
this.configureSessionAuthenticator();
};
/**
* In case of CouchdbSessionAuthenticator

@@ -89,0 +103,0 @@ * the service options should be applied on it.

/**
* © Copyright IBM Corporation 2020.
* © Copyright IBM Corporation 2020. All Rights Reserved.
*

@@ -4,0 +4,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

"use strict";
/**
* © Copyright IBM Corporation 2020.
* © Copyright IBM Corporation 2020. All Rights Reserved.
*

@@ -5,0 +5,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

/**
* © Copyright IBM Corporation 2020.
* © Copyright IBM Corporation 2020. All Rights Reserved.
*

@@ -16,3 +16,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

*/
import { Authenticator } from "ibm-cloud-sdk-core";
import { Authenticator } from 'ibm-cloud-sdk-core';
/**

@@ -19,0 +19,0 @@ * Extend the creating Authenticator from external configuration function with

"use strict";
/**
* © Copyright IBM Corporation 2020.
* © Copyright IBM Corporation 2020. All Rights Reserved.
*

@@ -5,0 +5,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

{
"name": "@ibm-cloud/cloudant",
"version": "0.0.13",
"version": "0.0.14",
"description": "IBM Cloudant Node.js SDK",

@@ -16,8 +16,6 @@ "main": "index.js",

"scripts": {
"eslint:fix": "eslint . --fix",
"eslint:check": "eslint . --cache",
"tslint:fix": "tslint --fix -p . -c tslint.json",
"tslint:check": "tslint -p . -c ./tslint.json",
"lint": "npm run eslint:check && npm run tslint:check",
"lint-fix": "npm run eslint:fix && npm run tslint:fix",
"eslint:fix": "eslint . --ext .ts,.js --fix",
"eslint:check": "eslint . --ext .ts,.js --cache",
"lint": "npm run eslint:check",
"lint-fix": "npm run eslint:fix",
"build": "tsc && cp package.json dist/",

@@ -43,3 +41,3 @@ "version": "bump2version --allow-dirty --new-version $npm_package_version patch && git add README.md .bumpversion.cfg",

"extend": "^3.0.2",
"ibm-cloud-sdk-core": "~2.7.0"
"ibm-cloud-sdk-core": "~2.8.0"
},

@@ -46,0 +44,0 @@ "jest": {

@@ -17,3 +17,3 @@ <!--

# IBM Cloudant Node.js SDK Version 0.0.13
# IBM Cloudant Node.js SDK Version 0.0.14

@@ -106,4 +106,3 @@ IBM Cloudant Node.js SDK is a client library that interacts with the

server.
- **Node.js 10, 12, 14**: This SDK is tested with Node.js versions 10, 12, and 14.
It may work on other versions but those are not officially supported.
- Node.js 10, 12 or 14.

@@ -210,3 +209,3 @@ ## Installation

documentation in the
[Cloudant API docs](https://cloud.ibm.com/apidocs/cloudant?code=python#programmatic-authentication)
[Cloudant API docs](https://cloud.ibm.com/apidocs/cloudant?code=node#programmatic-authentication)
or in the

@@ -260,39 +259,39 @@ [Node.js SDK Core document](https://github.com/IBM/node-sdk-core/blob/master/Authentication.md) about authentication.

// 1. Create a Cloudant client with "EXAMPLES" service name ===================
const client =
CloudantV1.newInstance({serviceName:"EXAMPLES"});
const client = CloudantV1.newInstance({ serviceName: 'EXAMPLES' });
// 2. Get server information ==================================================
// call service without parameters:
client.getServerInformation()
.then(serverInformation => {
const version = serverInformation.result.version;
console.log(`Server version ${version}`);
});
client.getServerInformation().then((serverInformation) => {
const version = serverInformation.result.version;
console.log(`Server version ${version}`);
});
// 3. Get database information for "animaldb" =================================
const dbName = "animaldb";
const dbName = 'animaldb';
// call service with embedded parameters:
client.getDatabaseInformation({db: dbName})
.then(dbInfo => {
const documentCount = dbInfo.result.doc_count;
const dbNameResult = dbInfo.result.db_name;
client.getDatabaseInformation({ db: dbName }).then((dbInfo) => {
const documentCount = dbInfo.result.doc_count;
const dbNameResult = dbInfo.result.db_name;
// 4. Show document count in database =================================
console.log(`Document count in "${dbNameResult}" database is ` +
documentCount + ".");
});
// 4. Show document count in database =================================
console.log(
`Document count in "${dbNameResult}" database is ` + documentCount + '.'
);
});
// 5. Get zebra document out of the database by document id ===================
const getDocParams:
CloudantV1.GetDocumentParams = {db: dbName, docId: "zebra"};
const getDocParams: CloudantV1.GetDocumentParams = {
db: dbName,
docId: 'zebra',
};
// call service with predefined parameters:
client.getDocument(getDocParams)
.then(documentAboutZebra => {
// result object is defined as a Document here:
const result: CloudantV1.Document = documentAboutZebra.result;
console.log("Document retrieved from database:\n" +
JSON.stringify(result, null, 2));
});
client.getDocument(getDocParams).then((documentAboutZebra) => {
// result object is defined as a Document here:
const result: CloudantV1.Document = documentAboutZebra.result;
console.log(
'Document retrieved from database:\n' + JSON.stringify(result, null, 2)
);
});
```

@@ -327,3 +326,5 @@ </details>

// 4. Show document count in database =================================
console.log(`Document count in "${dbNameResult}" database is ` + documentCount + '.');
console.log(
`Document count in "${dbNameResult}" database is ` + documentCount + '.'
);

@@ -339,3 +340,5 @@ // 5. Get zebra document out of the database by document id ===================

console.log('Document retrieved from database:\n' + JSON.stringify(result, null, 2));
console.log(
'Document retrieved from database:\n' + JSON.stringify(result, null, 2)
);
};

@@ -389,6 +392,6 @@

interface OrderDocument extends CloudantV1.Document {
name?: string;
joined?: string;
_id: string;
_rev?: string;
name?: string;
joined?: string;
_id: string;
_rev?: string;
}

@@ -400,39 +403,45 @@

// 2. Create a database =======================================================
const exampleDbName = "orders";
const exampleDbName = 'orders';
// Try to create database if it doesn't exist
const createDb = client.putDatabase({db: exampleDbName})
.then(putDatabaseResult => {
if (putDatabaseResult.result.ok) {
console.log(`"${exampleDbName}" database created."`);
}
})
.catch(err => {
if (err.code === 412){
console.log("Cannot create \"" + exampleDbName +
"\" database, it already exists.");
}
});
const createDb = client
.putDatabase({ db: exampleDbName })
.then((putDatabaseResult) => {
if (putDatabaseResult.result.ok) {
console.log(`"${exampleDbName}" database created."`);
}
})
.catch((err) => {
if (err.code === 412) {
console.log(
'Cannot create "' + exampleDbName + '" database, it already exists.'
);
}
});
// 3. Create a document =======================================================
// Create a document object with "example" id
const exampleDocId = "example";
const exampleDocId = 'example';
// set required _id property on exampleDocument:
const exampleDocument: OrderDocument = {_id: exampleDocId};
const exampleDocument: OrderDocument = { _id: exampleDocId };
// Add "name" and "joined" fields to the document
exampleDocument.name = "Bob Smith";
exampleDocument.joined = "2019-01-24T10:42:99.000Z";
exampleDocument.name = 'Bob Smith';
exampleDocument.joined = '2019-01-24T10:42:99.000Z';
// Save the document in the database
createDb.then(() => {
client.postDocument({
db: exampleDbName,
document: exampleDocument
}).then(createDocumentResponse => {
// Keep track with the revision number of the document object
exampleDocument._rev = createDocumentResponse.result.rev;
console.log("You have created the document:\n" +
JSON.stringify(exampleDocument, null, 2));
client
.postDocument({
db: exampleDbName,
document: exampleDocument,
})
.then((createDocumentResponse) => {
// Keep track with the revision number of the document object
exampleDocument._rev = createDocumentResponse.result.rev;
console.log(
'You have created the document:\n' +
JSON.stringify(exampleDocument, null, 2)
);
});

@@ -470,3 +479,5 @@ });

if (err.code === 412) {
console.log('Cannot create "' + exampleDbName + '" database, it already exists.');
console.log(
'Cannot create "' + exampleDbName + '" database, it already exists.'
);
}

@@ -493,3 +504,6 @@ }

exampleDocument._rev = createDocumentResponse.result.rev;
console.log('You have created the document:\n' + JSON.stringify(exampleDocument, null, 2));
console.log(
'You have created the document:\n' +
JSON.stringify(exampleDocument, null, 2)
);
};

@@ -539,6 +553,6 @@

interface OrderDocument extends CloudantV1.Document {
address?: string;
joined?: string;
_id?: string;
_rev?: string;
address?: string;
joined?: string;
_id?: string;
_rev?: string;
}

@@ -550,37 +564,41 @@

// Set the options to get the document out of the database if it exists
const exampleDbName = "orders";
const exampleDbName = 'orders';
// Try to get the document if it previously existed in the database
const getDocParams: CloudantV1.GetDocumentParams =
{docId: "example", db: exampleDbName};
const getDocParams: CloudantV1.GetDocumentParams = {
docId: 'example',
db: exampleDbName,
};
client.getDocument(getDocParams)
.then(docResult => {
// using OrderDocument on getDocument result:
const document: OrderDocument = docResult.result;
client
.getDocument(getDocParams)
.then((docResult) => {
// using OrderDocument on getDocument result:
const document: OrderDocument = docResult.result;
// Add Bob Smith's address to the document
document.address = "19 Front Street, Darlington, DL5 1TY";
// Add Bob Smith's address to the document
document.address = '19 Front Street, Darlington, DL5 1TY';
// Remove the joined property from document object
delete document.joined;
// Remove the joined property from document object
delete document.joined;
// Update the document in the database
client.postDocument({db: exampleDbName, document})
.then(res => {
// Keeping track with the revision number of the document object:
document._rev = res.result.rev;
console.log("You have updated the document:\n" +
JSON.stringify(document, null, 2));
});
})
.catch(err => {
if (err.code === 404) {
console.log(
"Cannot update document because either \"" +
exampleDbName + "\" database or the \"example\" " +
"document was not found."
);
}
// Update the document in the database
client.postDocument({ db: exampleDbName, document }).then((res) => {
// Keeping track with the revision number of the document object:
document._rev = res.result.rev;
console.log(
'You have updated the document:\n' + JSON.stringify(document, null, 2)
);
});
})
.catch((err) => {
if (err.code === 404) {
console.log(
'Cannot update document because either "' +
exampleDbName +
'" database or the "example" ' +
'document was not found.'
);
}
});
```

@@ -627,3 +645,5 @@ </details>

console.log('You have updated the document:\n' + JSON.stringify(document, null, 2));
console.log(
'You have updated the document:\n' + JSON.stringify(document, null, 2)
);
} catch (err) {

@@ -682,7 +702,7 @@ if (err.code === 404) {

interface OrderDocument extends CloudantV1.Document {
name?: string;
address?: string;
joined?: string;
_id?: string;
_rev?: string;
name?: string;
address?: string;
joined?: string;
_id?: string;
_rev?: string;
}

@@ -695,29 +715,36 @@

// Set the options to get the document out of the database if it exists
const exampleDbName = "orders";
const exampleDocId = "example";
const exampleDbName = 'orders';
const exampleDocId = 'example';
// Try to get the document if it previously existed in the database
const getDocParams: CloudantV1.GetDocumentParams =
{docId: exampleDocId, db: exampleDbName};
const getDocParams: CloudantV1.GetDocumentParams = {
docId: exampleDocId,
db: exampleDbName,
};
client.getDocument(getDocParams)
.then(docResult => {
const document: OrderDocument = docResult.result;
client
.getDocument(getDocParams)
.then((docResult) => {
const document: OrderDocument = docResult.result;
client.deleteDocument({
db: exampleDbName,
docId: document._id,
rev: document._rev}).then(() => {
console.log("You have deleted the document.");
});
})
.catch(err => {
if (err.code === 404) {
console.log(
"Cannot delete document because either \"" +
exampleDbName + "\" database or the \"example\" " +
"document was not found."
);
}
});
client
.deleteDocument({
db: exampleDbName,
docId: document._id,
rev: document._rev,
})
.then(() => {
console.log('You have deleted the document.');
});
})
.catch((err) => {
if (err.code === 404) {
console.log(
'Cannot delete document because either "' +
exampleDbName +
'" database or the "example" ' +
'document was not found.'
);
}
});
```

@@ -724,0 +751,0 @@ </details>

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

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

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