New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@datastax/astra-db-ts

Package Overview
Dependencies
Maintainers
6
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datastax/astra-db-ts - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

19

dist/api/data-api-http-client.js

@@ -43,6 +43,2 @@ "use strict";

mkAuthHeader: (token) => ({ [api_1.DEFAULT_DATA_API_AUTH_HEADER]: token }),
fetchCtx: {
preferred: props.fetchCtx.preferred,
closed: props.fetchCtx.closed,
},
});

@@ -72,6 +68,6 @@ Object.defineProperty(this, "collection", {

timeoutManager(timeoutMs) {
return mkTimeoutManager(timeoutMs);
return this._mkTimeoutManager(timeoutMs);
}
async executeCommand(command, options) {
const timeoutManager = options?.timeoutManager ?? mkTimeoutManager(options?.maxTimeMS);
const timeoutManager = options?.timeoutManager ?? this._mkTimeoutManager(options?.maxTimeMS);
return await this._requestDataAPI({

@@ -135,12 +131,9 @@ url: this.baseUrl,

}
_mkTimeoutManager(timeout) {
timeout ?? (timeout = this.fetchCtx.maxTimeMS ?? api_1.DEFAULT_TIMEOUT);
return new timeout_managers_1.TimeoutManager(timeout, () => new data_api_1.DataAPITimeoutError(timeout));
}
}
exports.DataAPIHttpClient = DataAPIHttpClient;
_DataAPIHttpClient_props = new WeakMap();
const mkTimeoutManager = (maxMs) => {
const timeout = maxMs ?? api_1.DEFAULT_TIMEOUT;
return new timeout_managers_1.TimeoutManager(timeout, mkTimeoutErrorMaker(timeout));
};
const mkTimeoutErrorMaker = (timeout) => {
return () => new data_api_1.DataAPITimeoutError(timeout);
};
const mkFauxErroredResponse = (message) => {

@@ -147,0 +140,0 @@ return { errors: [{ message }] };

@@ -32,5 +32,5 @@ "use strict";

fetchCtx: {
...props.fetchCtx,
preferred: props.fetchCtx.http1,
closed: props.fetchCtx.closed,
}
},
});

@@ -41,3 +41,3 @@ }

try {
const timeoutManager = options?.timeoutManager ?? mkTimeoutManager(options?.maxTimeMS);
const timeoutManager = options?.timeoutManager ?? this._mkTimeoutManager(options?.maxTimeMS);
const url = this.baseUrl + req.path;

@@ -79,3 +79,3 @@ if (this.monitorCommands && !isLongRunning) {

async requestLongRunning(req, info) {
const timeoutManager = mkTimeoutManager(info.options?.maxTimeMS);
const timeoutManager = this._mkTimeoutManager(info.options?.maxTimeMS);
const isLongRunning = info?.options?.blocking !== false;

@@ -135,11 +135,8 @@ if (this.monitorCommands) {

}
_mkTimeoutManager(timeout) {
timeout ?? (timeout = this.fetchCtx.maxTimeMS ?? (12 * 60 * 1000));
return new timeout_managers_1.TimeoutManager(timeout, (info) => new errors_1.DevOpsAPITimeoutError(info.url, timeout));
}
}
exports.DevOpsAPIHttpClient = DevOpsAPIHttpClient;
const mkTimeoutManager = (maxMs) => {
const timeout = maxMs ?? 0;
return new timeout_managers_1.TimeoutManager(timeout, mkTimeoutErrorMaker(timeout));
};
const mkTimeoutErrorMaker = (timeout) => {
return (info) => new errors_1.DevOpsAPITimeoutError(info.url, timeout);
};
//# sourceMappingURL=devops-api-http-client.js.map

@@ -15,2 +15,3 @@ "use strict";

// limitations under the License.
// noinspection JSDeprecatedSymbols
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {

@@ -123,2 +124,8 @@ if (kind === "m") throw new TypeError("Private method is not writable");

overwriteUserAgent: true,
http1: {
keepAlive: options?.httpOptions?.http1?.keepAlive,
keepAliveMsecs: options?.httpOptions?.http1?.keepAliveMS,
maxSockets: options?.httpOptions?.http1?.maxSockets,
maxFreeSockets: options?.httpOptions?.http1?.maxFreeSockets,
},
};

@@ -129,3 +136,4 @@ const http1Ctx = (0, fetch_h2_1.context)({

});
const preferredCtx = (options?.preferHttp2 !== false)
const preferHttp2 = options?.httpOptions?.preferHttp2 ?? getDeprecatedPrefersHttp2(options) ?? true;
const preferredCtx = (preferHttp2)
? (0, fetch_h2_1.context)(baseCtxOptions)

@@ -138,6 +146,7 @@ : http1Ctx;

preferred: preferredCtx,
preferredType: (options?.preferHttp2 !== false)
preferredType: (preferHttp2)
? 'http2'
: 'http1',
closed: { ref: false },
maxTimeMS: options?.httpOptions?.maxTimeMS,
},

@@ -218,2 +227,6 @@ dbOptions: {

_DataAPIClient_options = new WeakMap(), _a = Symbol.asyncDispose;
// Shuts the linter up about 'preferHttp2' not being deprecated
function getDeprecatedPrefersHttp2(opts) {
return opts?.['preferHttp2'];
}
function validateRootOpts(opts) {

@@ -225,6 +238,21 @@ (0, utils_1.validateOption)('root client options', opts, 'object');

(0, utils_1.validateOption)('caller', opts.caller, 'object', validateCaller);
(0, utils_1.validateOption)('preferHttp2 option', opts.preferHttp2, 'boolean');
(0, utils_1.validateOption)('preferHttp2 option', getDeprecatedPrefersHttp2(opts), 'boolean');
(0, db_1.validateDbOpts)(opts.dbOptions);
(0, astra_admin_1.validateAdminOpts)(opts.adminOptions);
validateHttpOpts(opts.httpOptions);
}
function validateHttpOpts(opts) {
(0, utils_1.validateOption)('http options', opts, 'object');
if (!opts) {
return;
}
(0, utils_1.validateOption)('preferHttp2 option', opts.preferHttp2, 'boolean');
(0, utils_1.validateOption)('maxTimeMS option', opts.maxTimeMS, 'number');
(0, utils_1.validateOption)('http1 options', opts.http1, 'object', (http1) => {
(0, utils_1.validateOption)('http1.keepAlive option', http1.keepAlive, 'boolean');
(0, utils_1.validateOption)('http1.keepAliveMS option', http1.keepAliveMS, 'number');
(0, utils_1.validateOption)('http1.maxSockets option', http1.maxSockets, 'number');
(0, utils_1.validateOption)('http1.maxFreeSockets option', http1.maxFreeSockets, 'number');
});
}
function validateCaller(caller) {

@@ -231,0 +259,0 @@ if (!Array.isArray(caller)) {

@@ -913,2 +913,23 @@ "use strict";

}
/**
* Gets an estimate of the count of documents in a collection.
*
* This operation is faster than {@link Collection.countDocuments} but may not be as accurate, and doesn't
* accept a filter. Unlike the former, **It can handle more than 1000 documents.**
*
* @remarks
* This gives a very rough estimate of the number of documents in the collection. It is not guaranteed to be
* accurate, and should not be used as a source of truth for the number of documents in the collection.
*
* @param options - The options for this operation.
*
* @returns The estimated number of documents in the collection
*/
async estimatedDocumentCount(options) {
const command = {
estimatedDocumentCount: {},
};
const resp = await this._httpClient.executeCommand(command, options);
return resp.status?.count;
}
async findOneAndReplace(filter, replacement, options) {

@@ -915,0 +936,0 @@ options = coalesceVectorSpecialsIntoSort(options);

@@ -80,2 +80,21 @@ "use strict";

/**
* Fetches the complete information about the database, such as the database name, IDs, region, status, actions, and
* other metadata.
*
* @example
* ```typescript
* const info = await admin.info('<db_id>');
* console.log(info.info.name, info.creationTime);
* ```
*
* @returns A promise that resolves to the complete database information.
*/
async dbInfo(id, options) {
const resp = await this._httpClient.request({
method: api_1.HttpMethods.Get,
path: `/databases/${id}`,
}, options);
return resp.data;
}
/**
* Lists all databases in the current org/account, matching the optionally provided filter.

@@ -82,0 +101,0 @@ *

@@ -104,3 +104,2 @@ "use strict";

*
*
* @example

@@ -107,0 +106,0 @@ * ```typescript

@@ -5,3 +5,3 @@ "use strict";

exports.LIB_NAME = 'astra-db-ts';
exports.LIB_VERSION = "1.0.2";
exports.LIB_VERSION = "1.1.0";
//# sourceMappingURL=version.js.map
{
"name": "@datastax/astra-db-ts",
"version": "1.0.2",
"version": "1.1.0",
"description": "Astra DB TS Client",

@@ -5,0 +5,0 @@ "contributors": [

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 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

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