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

documentdb

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

documentdb - npm Package Compare versions

Comparing version 1.13.0 to 1.14.0

lib/resourceId.js

54

Gruntfile.js

@@ -27,2 +27,3 @@ /*

module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-mocha-test');
require("time-grunt")(grunt);

@@ -33,17 +34,44 @@ // Load grunt tasks automatically

grunt.initConfig({
eslint: {
src: [
"lib/*.js",
"lib/hash/*.js",
"lib/queryExecutionContext/*.js",
"lib/routing/*.js",
"test/*.js"],
options: {
configFile: ".eslintrc"
}
eslint: {
src: [
"lib/*.js",
"lib/hash/*.js",
"lib/queryExecutionContext/*.js",
"lib/routing/*.js",
"test/*.js"],
options: {
configFile: ".eslintrc"
}
},
mochaTest: {
test: {
options: {
reporter: 'mocha-multi-reporters',
reporterOptions: {
"reporterEnabled": "mocha-junit-reporter, tap",
"mochaJunitReporterReporterOptions": {
"mochaFile": "TEST-nodejs.xml"
}
},
// Require blanket wrapper here to instrument other required
// files on the fly.
//
// NB. We cannot require blanket directly as it
// detects that we are not running mocha cli and loads differently.
//
// NNB. As mocha is 'clever' enough to only run the tests once for
// each file the following coverage task does not actually run any
// tests which is why the coverage instrumentation has to be done here
// require: 'coverage/blanket'
timeout: 20000,
},
src: ['test/**/*.js']
}
}
});
grunt.registerTask("lint", ["eslint"]);
grunt.registerTask("default", "lint");
};
// TODO: we should have lint enabled
// grunt.registerTask("default", "lint");
grunt.registerTask('tests', 'mochaTest');
};

@@ -41,3 +41,3 @@ /*

},
HttpMethods: {

@@ -51,3 +51,3 @@ Get: "GET",

},
HttpHeaders: {

@@ -100,11 +100,11 @@ Authorization: "authorization",

Referer: "referer",
// Query
Query: "x-ms-documentdb-query",
IsQuery: "x-ms-documentdb-isquery",
// Our custom DocumentDB headers
Continuation: "x-ms-continuation",
PageSize: "x-ms-max-item-count",
// Request sender generated. Simply echoed by backend.

@@ -132,3 +132,9 @@ ActivityId: "x-ms-activity-id",

Version: "x-ms-version",
//Owner name
OwnerFullName: "x-ms-alt-content-path",
// Owner ID used for name based request in session token.
OwnerId: "x-ms-content-path",
// Partition Key

@@ -148,3 +154,3 @@ PartitionKey: "x-ms-documentdb-partitionkey",

MaxResourceQuota: "x-ms-resource-quota",
// Offer header

@@ -162,3 +168,3 @@ OfferType: "x-ms-offer-type",

LazyIndexingProgress: "x-ms-documentdb-collection-lazy-indexing-progress",
// Upsert header

@@ -174,3 +180,3 @@ IsUpsert: "x-ms-documentdb-is-upsert",

},
// GlobalDB related constants

@@ -181,11 +187,11 @@ WritableLocations: 'writableLocations',

DatabaseAccountEndpoint: 'databaseAccountEndpoint',
// Client generated retry count response header
ThrottleRetryCount: "x-ms-throttle-retry-count",
ThrottleRetryWaitTimeInMs: "x-ms-throttle-retry-wait-time-ms",
CurrentVersion: "2017-01-19",
CurrentVersion: "2017-11-15",
SDKName: "documentdb-nodejs-sdk",
SDKVersion: "1.13.0",
SDKVersion: "1.14.0",

@@ -198,7 +204,7 @@ DefaultPrecisions: {

},
ConsistentHashRing: {
DefaultVirtualNodesPerCollection: 128
},
RegularExpressions: {

@@ -227,3 +233,13 @@ TrimLeftSlashes: new RegExp("^[/]+"),

SchemasPathSegment: "schemas"
}
},
OperationTypes: {
Create: "create",
Replace: "replace",
Upsert: "upsert",
Delete: "delete",
Read: "read",
Query: "query",
},
};

@@ -230,0 +246,0 @@

@@ -57,3 +57,3 @@ /*

function createRequestObject(connectionPolicy, requestOptions, callback){
function createRequestObject(connectionPolicy, requestOptions, callback) {
function onTimeout() {

@@ -64,4 +64,4 @@ httpsRequest.abort();

var isMedia = (requestOptions.path.indexOf("//media") === 0);
var httpsRequest = https.request(requestOptions, function(response) {
var httpsRequest = https.request(requestOptions, function (response) {
// In case of media response, return the stream to the user and the user will need to handle reading the stream.

@@ -79,9 +79,9 @@ if (isMedia && connectionPolicy.MediaReadMode === Documents.MediaReadMode.Streamed) {

response.on("data", function(chunk) {
response.on("data", function (chunk) {
data += chunk;
});
response.on("end", function() {
response.on("end", function () {
if (response.statusCode >= 400) {
return callback(getErrorBody(response, data), undefined, response.headers);
}
}

@@ -103,3 +103,3 @@ var result;

httpsRequest.once("socket", function(socket) {
httpsRequest.once("socket", function (socket) {
if (isMedia) {

@@ -128,12 +128,12 @@ socket.setTimeout(connectionPolicy.MediaRequestTimeout);

function getErrorBody(response, data) {
var errorBody = { code: response.statusCode, body: data };
if (Constants.HttpHeaders.ActivityId in response.headers) {
errorBody.activityId = response.headers[Constants.HttpHeaders.ActivityId];
}
var errorBody = { code: response.statusCode, body: data };
if (Constants.HttpHeaders.ActivityId in response.headers) {
errorBody.activityId = response.headers[Constants.HttpHeaders.ActivityId];
}
if (Constants.HttpHeaders.SubStatus in response.headers) {
errorBody.substatus = parseInt(response.headers[Constants.HttpHeaders.SubStatus]);
}
if (Constants.HttpHeaders.RetryAfterInMilliseconds in response.headers) {

@@ -163,5 +163,6 @@ errorBody.retryAfterInMilliseconds = parseInt(response.headers[Constants.HttpHeaders.RetryAfterInMilliseconds]);

*/
request: function (globalEndpointManager, connectionPolicy, method, url, path, data, queryParams, headers, callback) {
request: function (globalEndpointManager, connectionPolicy, method, url, request, data, queryParams, headers, callback) {
var path = request.path == undefined ? request : request.path;
var body;
if (data) {

@@ -171,3 +172,3 @@ body = bodyFromData(data);

}
var buffer;

@@ -184,6 +185,6 @@ var stream;

} else {
callback({ message: "body must be string, Buffer, or stream" });
return callback({ message: "body must be string, Buffer, or stream" });
}
}
var requestOptions = parse(url);

@@ -203,10 +204,10 @@ requestOptions.method = method;

}
if (buffer) {
requestOptions.headers[Constants.HttpHeaders.ContentLength] = buffer.length;
RetryUtility.execute(globalEndpointManager, { buffer: buffer, stream: null }, this._createRequestObjectStub, connectionPolicy, requestOptions, callback);
RetryUtility.execute(globalEndpointManager, { buffer: buffer, stream: null }, this._createRequestObjectStub, connectionPolicy, requestOptions, request, callback);
} else if (stream) {
RetryUtility.execute(globalEndpointManager, { buffer: null, stream: stream }, this._createRequestObjectStub, connectionPolicy, requestOptions, callback);
RetryUtility.execute(globalEndpointManager, { buffer: null, stream: stream }, this._createRequestObjectStub, connectionPolicy, requestOptions, request, callback);
} else {
RetryUtility.execute(globalEndpointManager, { buffer: null, stream: null }, this._createRequestObjectStub, connectionPolicy, requestOptions, callback);
RetryUtility.execute(globalEndpointManager, { buffer: null, stream: null }, this._createRequestObjectStub, connectionPolicy, requestOptions, request, callback);
}

@@ -213,0 +214,0 @@ }

@@ -29,3 +29,4 @@ /*

EndpointDiscoveryRetryPolicy = require("./endpointDiscoveryRetryPolicy"),
ResourceThrottleRetryPolicy = require("./resourceThrottleRetryPolicy");
ResourceThrottleRetryPolicy = require("./resourceThrottleRetryPolicy"),
SessionReadRetryPolicy = require("./sessionReadRetryPolicy");

@@ -43,11 +44,14 @@ //SCRIPT START

*/
execute: function (globalEndpointManager, body, createRequestObjectFunc, connectionPolicy, requestOptions, callback) {
execute: function (globalEndpointManager, body, createRequestObjectFunc, connectionPolicy, requestOptions, request, callback) {
var request = typeof request !== 'string' ? request : { "path": "", "operationType": "nonReadOps", "client": null };
var endpointDiscoveryRetryPolicy = new EndpointDiscoveryRetryPolicy(globalEndpointManager);
var resourceThrottleRetryPolicy = new ResourceThrottleRetryPolicy(connectionPolicy.RetryOptions.MaxRetryAttemptCount,
connectionPolicy.RetryOptions.FixedRetryIntervalInMilliseconds,
connectionPolicy.RetryOptions.MaxWaitTimeInSeconds);
var resourceThrottleRetryPolicy = new ResourceThrottleRetryPolicy(connectionPolicy.RetryOptions.MaxRetryAttemptCount,
connectionPolicy.RetryOptions.FixedRetryIntervalInMilliseconds,
connectionPolicy.RetryOptions.MaxWaitTimeInSeconds);
var sessionReadRetryPolicy = new SessionReadRetryPolicy(globalEndpointManager, request)
this.apply(body, createRequestObjectFunc, connectionPolicy, requestOptions, endpointDiscoveryRetryPolicy, resourceThrottleRetryPolicy, callback);
this.apply(body, createRequestObjectFunc, connectionPolicy, requestOptions, endpointDiscoveryRetryPolicy, resourceThrottleRetryPolicy, sessionReadRetryPolicy, callback);
},
/**

@@ -63,3 +67,3 @@ * Applies the retry policy for the created request object.

*/
apply: function (body, createRequestObjectFunc, connectionPolicy, requestOptions, endpointDiscoveryRetryPolicy, resourceThrottleRetryPolicy, callback) {
apply: function (body, createRequestObjectFunc, connectionPolicy, requestOptions, endpointDiscoveryRetryPolicy, resourceThrottleRetryPolicy, sessionReadRetryPolicy, callback) {
var that = this;

@@ -74,5 +78,7 @@ var httpsRequest = createRequestObjectFunc(connectionPolicy, requestOptions, function (err, response, headers) {

retryPolicy = resourceThrottleRetryPolicy;
} else if (err.code === SessionReadRetryPolicy.NOT_FOUND_STATUS_CODE && err.substatus === SessionReadRetryPolicy.READ_SESSION_NOT_AVAILABLE_SUB_STATUS_CODE) {
retryPolicy = sessionReadRetryPolicy;
}
if (retryPolicy) {
retryPolicy.shouldRetry(err, function (shouldRetry) {
retryPolicy.shouldRetry(err, function (shouldRetry, newUrl) {
if (!shouldRetry) {

@@ -84,3 +90,5 @@ headers[Constants.ThrottleRetryCount] = resourceThrottleRetryPolicy.currentRetryAttemptCount;

setTimeout(function () {
that.apply(body, createRequestObjectFunc, connectionPolicy, requestOptions, endpointDiscoveryRetryPolicy, resourceThrottleRetryPolicy, callback);
if (typeof newUrl !== 'undefined')
requestOptions = that.modifyRequestOptions(requestOptions, newUrl);
that.apply(body, createRequestObjectFunc, connectionPolicy, requestOptions, endpointDiscoveryRetryPolicy, resourceThrottleRetryPolicy, sessionReadRetryPolicy, callback);
}, retryPolicy.retryAfterInMilliseconds);

@@ -97,3 +105,3 @@ return;

});
if (httpsRequest) {

@@ -109,2 +117,11 @@ if (body["stream"] !== null) {

}
},
modifyRequestOptions: function (oldRequestOptions, newUrl) {
var properties = Object.keys(newUrl);
for (var index in properties) {
if (properties[index] !== "path")
oldRequestOptions[properties[index]] = newUrl[properties[index]];
}
return oldRequestOptions;
}

@@ -111,0 +128,0 @@ }

@@ -12,3 +12,3 @@ {

],
"version": "1.13.0",
"version": "1.14.0",
"author": "Microsoft Corporation",

@@ -27,6 +27,12 @@ "main": "./index.js",

"mocha": "*",
"sinon": "^3.2.1",
"time-grunt": "^1.2.0",
"child_process" : "*"
"grunt-mocha-test": "^0.13.3",
"mocha-multi-reporters": "^1.1.6",
"mocha-junit-reporter": "^1.15.0",
"child_process": "*"
},
"dependencies": {
"big-integer": "^1.6.25",
"int64-buffer": "^0.1.9",
"binary-search-bounds": "2.0.3",

@@ -33,0 +39,0 @@ "priorityqueuejs": "1.0.0",

@@ -1,2 +0,2 @@

# Microsoft Azure DocumentDB Node.js SDK
# Node.js SDK for DocumentDB APIs of Azure Cosmos DB

@@ -7,6 +7,8 @@ ![](https://img.shields.io/npm/v/documentdb.svg)

This project provides a node module that makes it easy to interact with Azure DocumentDB.
Node.js SDK for DocumentDB APIs for Microsoft Azure Cosmos DB Service.
For documentation please see the Microsoft Azure [Node.js Developer Center](http://azure.microsoft.com/en-us/develop/nodejs/) and the [Microsoft Azure DocumentDB Node.js SDK Documentation](http://azure.github.io/azure-documentdb-node/).
This project provides a node module that makes it easy to interact with DocumentDB APIs of Azure Cosmos DB (cosmosdb) Service.
For documentation please see the Microsoft Azure [Node.js Developer Center](http://azure.microsoft.com/en-us/develop/nodejs/) and the [ Node.js SDK Documentation](http://azure.github.io/azure-documentdb-node/).
## Installation

@@ -22,8 +24,8 @@ ### Core Module

To use this SDK to call Azure DocumentDB, you need to first [create an account](http://azure.microsoft.com/en-us/documentation/articles/documentdb-create-account/).
To use this SDK to call DocumentDB APIs of Azure Cosmos DB, you need to first [create an account](https://docs.microsoft.com/en-us/azure/cosmos-db/create-documentdb-nodejs).
You can follow this [tutorial](http://azure.microsoft.com/en-us/documentation/articles/documentdb-nodejs-application/) to help you get started.
You can follow this [tutorial](https://docs.microsoft.com/en-us/azure/cosmos-db/documentdb-nodejs-application) to help you get started.
#### Note:
When connecting to the [emulator](https://docs.microsoft.com/en-us/azure/documentdb/documentdb-nosql-local-emulator) from the SDK, SSL verification is disabled.
When connecting to the [emulator](https://docs.microsoft.com/en-us/azure/cosmos-db/local-emulator) from the SDK, SSL verification is disabled.

@@ -70,9 +72,9 @@ ## Examples

Getting started with Azure DocumentDB on Node.js:
Getting started with DocumentDB Node.js SDK:
[![Azure Demo: Getting started with Azure DocumentDB on Node.js](http://img.youtube.com/vi/UAE7h9PCZjA/0.jpg)](http://www.youtube.com/watch?v=UAE7h9PCZjA)
[![Azure Demo: Getting started with DocumentDB Node.js SDK](http://img.youtube.com/vi/UAE7h9PCZjA/0.jpg)](http://www.youtube.com/watch?v=UAE7h9PCZjA)
## Need Help?
Be sure to check out the Microsoft Azure [Developer Forums on MSDN](https://social.msdn.microsoft.com/forums/azure/en-US/home?forum=AzureDocumentDB) or the [Developer Forums on Stack Overflow](http://stackoverflow.com/questions/tagged/azure-documentdb) if you have trouble with the provided code.
Be sure to check out the Microsoft Azure [Developer Forums on MSDN](https://social.msdn.microsoft.com/forums/azure/en-US/home?forum=AzureDocumentDB) or the [Developer Forums on Stack Overflow](https://stackoverflow.com/questions/tagged/azure-cosmosdb) if you have trouble with the provided code.

@@ -88,4 +90,4 @@ ## Contribute Code or Provide Feedback

* [Azure Developer Center](http://azure.microsoft.com/en-us/develop/nodejs)
* [Azure DocumentDB Node.js SDK Documentation](http://azure.github.io/azure-documentdb-node/)
* [Azure DocumentDB Service](http://azure.microsoft.com/en-us/documentation/services/documentdb/)
* [Azure DocumentDB Community Page](https://azure.microsoft.com/en-us/documentation/articles/documentdb-community/)
* [Node.js SDK Documentation for using DocumentDB APIs of Azure Cosmos DB Service.](http://azure.github.io/azure-documentdb-node/)
* [Azure Cosmos DB Service](https://azure.microsoft.com/en-us/blog/dear-documentdb-customers-welcome-to-azure-cosmos-db/)
* [Azure Cosmos DB Community Page](https://docs.microsoft.com/en-us/azure/cosmos-db/community)

@@ -0,0 +0,0 @@ // Generated by typings

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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