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.1.0 to 1.1.1-0

dist/api/fetch-h2-fetcher.js

2

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

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

timeout ?? (timeout = this.fetchCtx.maxTimeMS ?? (12 * 60 * 1000));
return new timeout_managers_1.TimeoutManager(timeout, (info) => new errors_1.DevOpsAPITimeoutError(info.url, timeout));
return new timeout_managers_1.TimeoutManager(timeout, (url) => new errors_1.DevOpsAPITimeoutError(url, timeout));
}

@@ -137,0 +137,0 @@ }

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

const constants_1 = require("../api/constants");
const fetch_h2_1 = require("fetch-h2");
/**

@@ -86,3 +85,3 @@ * @internal

if (info.timeoutManager.msRemaining <= 0) {
throw info.timeoutManager.mkTimeoutError(info);
throw info.timeoutManager.mkTimeoutError(info.url);
}

@@ -94,18 +93,8 @@ const params = info.params ?? {};

: info.url;
try {
const resp = await this.fetchCtx.preferred.fetch(url, {
body: info.data,
method: info.method,
timeout: info.timeoutManager.msRemaining,
headers: this.baseHeaders,
});
resp.body = await resp.text();
return resp;
}
catch (e) {
if (e instanceof fetch_h2_1.TimeoutError) {
throw info.timeoutManager.mkTimeoutError(info);
}
throw e;
}
return await this.fetchCtx.preferred.fetch(url, {
body: info.data,
method: info.method,
timeoutManager: info.timeoutManager,
headers: this.baseHeaders,
});
}

@@ -112,0 +101,0 @@ }

@@ -27,5 +27,2 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _DataAPIClient_options, _a;

@@ -36,6 +33,5 @@ Object.defineProperty(exports, "__esModule", { value: true });

const astra_admin_1 = require("../devops/astra-admin");
const events_1 = __importDefault(require("events"));
const events_1 = require("events");
const utils_1 = require("../data-api/utils");
const fetch_h2_1 = require("fetch-h2");
const api_1 = require("../api");
const fetch_native_fetcher_1 = require("../api/fetch-native-fetcher");
/**

@@ -48,3 +44,3 @@ * The base class for the {@link DataAPIClient} event emitter to make it properly typed.

*/
exports.DataAPIClientEventEmitterBase = events_1.default;
exports.DataAPIClientEventEmitterBase = events_1.EventEmitter;
/**

@@ -123,31 +119,5 @@ * The main entrypoint into working with the Data API. It sits at the top of the

validateRootOpts(options);
const baseCtxOptions = {
userAgent: (0, api_1.buildUserAgent)(options?.caller),
overwriteUserAgent: true,
http1: {
keepAlive: options?.httpOptions?.http1?.keepAlive,
keepAliveMsecs: options?.httpOptions?.http1?.keepAliveMS,
maxSockets: options?.httpOptions?.http1?.maxSockets,
maxFreeSockets: options?.httpOptions?.http1?.maxFreeSockets,
},
};
const http1Ctx = (0, fetch_h2_1.context)({
...baseCtxOptions,
httpsProtocols: ['http1'],
});
const preferHttp2 = options?.httpOptions?.preferHttp2 ?? getDeprecatedPrefersHttp2(options) ?? true;
const preferredCtx = (preferHttp2)
? (0, fetch_h2_1.context)(baseCtxOptions)
: http1Ctx;
__classPrivateFieldSet(this, _DataAPIClient_options, {
...options,
fetchCtx: {
http1: http1Ctx,
preferred: preferredCtx,
preferredType: (preferHttp2)
? 'http2'
: 'http1',
closed: { ref: false },
maxTimeMS: options?.httpOptions?.maxTimeMS,
},
fetchCtx: buildFetchCtx(options || undefined),
dbOptions: {

@@ -227,3 +197,49 @@ monitorCommands: false,

_DataAPIClient_options = new WeakMap(), _a = Symbol.asyncDispose;
// Shuts the linter up about 'preferHttp2' not being deprecated
function getDefaultHttpClient() {
const isNode = globalThis.process?.release?.name === 'node';
const isBun = !!globalThis['Bun'] || !!globalThis.process?.versions?.bun;
const isDeno = !!globalThis['Deno'];
return (isNode && !isBun && !isDeno)
? 'default'
: 'fetch';
}
function buildFetchCtx(options) {
const clientType = (options?.httpOptions)
? options.httpOptions.client
: getDefaultHttpClient();
const preferHttp2 = (options?.httpOptions && options.httpOptions.client !== 'fetch')
? options.httpOptions.preferHttp2 ?? getDeprecatedPrefersHttp2(options) ?? true
: false;
const [http1Ctx, preferredCtx] = (() => {
if (clientType !== 'fetch') {
try {
// Complicated expression to stop Next.js and such from tracing require and trying to load the fetch-h2 client
const [indirectRequire] = [require].map(x => Math.random() > 10 ? null : x);
const { FetchH2Fetcher } = indirectRequire('../api/fetch-h2-fetcher');
const http1Ctx = new FetchH2Fetcher(options, false);
const preferredCtx = (preferHttp2)
? new FetchH2Fetcher(options, true)
: http1Ctx;
return [http1Ctx, preferredCtx];
}
catch (e) {
throw new Error('Error loading the fetch-h2 client for the DataAPIClient... try setting httpOptions.client to \'fetch\'');
}
}
else {
const deceiver = new fetch_native_fetcher_1.FetchNativeFetcher(options);
return [deceiver, deceiver];
}
})();
return {
http1: http1Ctx,
preferred: preferredCtx,
preferredType: (preferHttp2)
? 'http2'
: 'http1',
closed: { ref: false },
maxTimeMS: options?.httpOptions?.maxTimeMS,
};
}
// Shuts the linter up about 'preferHttp2' being deprecated
function getDeprecatedPrefersHttp2(opts) {

@@ -248,10 +264,17 @@ return opts?.['preferHttp2'];

}
(0, utils_1.validateOption)('preferHttp2 option', opts.preferHttp2, 'boolean');
(0, utils_1.validateOption)('client option', opts.client, 'string', (client) => {
if (client !== 'fetch' && client !== 'default') {
throw new Error('Invalid httpOptions.client; expected \'fetch\' or \'default\'');
}
});
(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');
});
if (opts.client !== 'fetch') {
(0, utils_1.validateOption)('preferHttp2 option', opts.preferHttp2, 'boolean');
(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');
});
}
}

@@ -258,0 +281,0 @@ function validateCaller(caller) {

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

exports.mkRespErrorFromResponses = exports.mkRespErrorFromResponse = exports.BulkWriteError = exports.UpdateManyError = exports.DeleteManyError = exports.InsertManyError = exports.CumulativeDataAPIError = exports.DataAPIResponseError = exports.CollectionAlreadyExistsError = exports.CollectionNotFoundError = exports.CursorIsStartedError = exports.TooManyDocumentsToCountError = exports.DataAPITimeoutError = exports.DataAPIHttpError = exports.DataAPIError = void 0;
const utils_1 = require("../api/utils");
/**

@@ -74,3 +73,3 @@ * An abstract class representing *some* exception that occurred related to the Data API. This is the base class for all

this.body = resp.body;
this.raw = (0, utils_1.toCuratedApiResponse)(resp);
this.raw = resp;
this.name = 'DataAPIHttpError';

@@ -77,0 +76,0 @@ }

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

}, {
id: (resp) => resp.headers.get('location'),
id: (resp) => resp.headers.location,
target: 'ACTIVE',

@@ -209,3 +209,3 @@ legalStates: ['INITIALIZING', 'PENDING'],

});
const db = (0, db_1.mkDb)(__classPrivateFieldGet(this, _AstraAdmin_defaultOpts, "f"), resp.headers.get('location'), definition.region, { ...options?.dbOptions, namespace: definition.keyspace });
const db = (0, db_1.mkDb)(__classPrivateFieldGet(this, _AstraAdmin_defaultOpts, "f"), resp.headers.location, definition.region, { ...options?.dbOptions, namespace: definition.keyspace });
return db.admin(__classPrivateFieldGet(this, _AstraAdmin_defaultOpts, "f").adminOptions);

@@ -212,0 +212,0 @@ }

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

exports.DevOpsUnexpectedStateError = exports.DevOpsAPIResponseError = exports.DevOpsAPITimeoutError = exports.DevOpsAPIError = void 0;
const utils_1 = require("../api/utils");
/**

@@ -120,3 +119,3 @@ * An abstract class representing *some* exception that occurred related to the DevOps API. This is the base class for all

this.status = resp.status;
this.raw = (0, utils_1.toCuratedApiResponse)(resp);
this.raw = resp;
this.name = 'DevOpsAPIResponseError';

@@ -123,0 +122,0 @@ }

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

exports.LIB_NAME = 'astra-db-ts';
exports.LIB_VERSION = "1.1.0";
exports.LIB_VERSION = "1.1.1-0";
//# sourceMappingURL=version.js.map
{
"name": "@datastax/astra-db-ts",
"version": "1.1.0",
"version": "1.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 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

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