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

@turbopuffer/turbopuffer

Package Overview
Dependencies
Maintainers
3
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turbopuffer/turbopuffer - npm Package Compare versions

Comparing version 0.5.7 to 0.5.8

10

dist/httpClient.d.ts

@@ -9,8 +9,9 @@ export interface RequestParams {

}
export type RequestTiming = {
export interface RequestTiming {
response_time: number;
body_read_time: number;
decompress_time: number;
compress_time: number;
deserialize_time: number;
};
}
export type RequestResponse<T> = Promise<{

@@ -33,3 +34,3 @@ body?: T;

*/
export declare const createHTTPClient: (baseUrl: string, apiKey: string, connectTimeout: number, idleTimeout: number, warmConnections: number) => DefaultHTTPClient;
export declare const createHTTPClient: (baseUrl: string, apiKey: string, connectTimeout: number, idleTimeout: number, warmConnections: number, compression: boolean) => DefaultHTTPClient;
declare class DefaultHTTPClient implements HTTPClient {

@@ -41,3 +42,4 @@ private agent;

readonly userAgent: string;
constructor(baseUrl: string, apiKey: string, connectTimeout: number, idleTimeout: number, warmConnections: number);
private compression;
constructor(baseUrl: string, apiKey: string, connectTimeout: number, idleTimeout: number, warmConnections: number, compression: boolean);
doRequest<T>({ method, path, query, body, compress, retryable, }: RequestParams): RequestResponse<T>;

@@ -44,0 +46,0 @@ }

20

dist/httpClient.js

@@ -19,6 +19,6 @@ "use strict";

*/
const createHTTPClient = (baseUrl, apiKey, connectTimeout, idleTimeout, warmConnections) => new DefaultHTTPClient(baseUrl, apiKey, connectTimeout, idleTimeout, warmConnections);
const createHTTPClient = (baseUrl, apiKey, connectTimeout, idleTimeout, warmConnections, compression) => new DefaultHTTPClient(baseUrl, apiKey, connectTimeout, idleTimeout, warmConnections, compression);
exports.createHTTPClient = createHTTPClient;
class DefaultHTTPClient {
constructor(baseUrl, apiKey, connectTimeout, idleTimeout, warmConnections) {
constructor(baseUrl, apiKey, connectTimeout, idleTimeout, warmConnections, compression) {
this.userAgent = `tpuf-typescript/${package_json_1.version}`;

@@ -29,2 +29,3 @@ this.baseUrl = baseUrl;

this.apiKey = apiKey;
this.compression = compression;
this.agent = new undici_1.Agent({

@@ -62,4 +63,2 @@ keepAliveTimeout: idleTimeout, // how long a socket can be idle for before it is closed

// eslint-disable-next-line @typescript-eslint/naming-convention
"Accept-Encoding": "gzip",
// eslint-disable-next-line @typescript-eslint/naming-convention
Authorization: `Bearer ${this.apiKey}`,

@@ -69,9 +68,15 @@ // eslint-disable-next-line @typescript-eslint/naming-convention

};
if (this.compression) {
headers["Accept-Encoding"] = "gzip";
}
if (body) {
headers["Content-Type"] = "application/json";
}
let requestCompressionDuration;
let requestBody = null;
if (body && compress) {
if (body && compress && this.compression) {
headers["Content-Encoding"] = "gzip";
const beforeRequestCompression = performance.now();
requestBody = await gzipAsync(JSON.stringify(body));
requestCompressionDuration = performance.now() - beforeRequestCompression;
}

@@ -171,3 +176,3 @@ else if (body) {

headers: convertHeadersType(response.headers),
request_timing: make_request_timing(request_start, response_start, body_read_end, decompress_end, deserialize_end),
request_timing: make_request_timing(request_start, response_start, body_read_end, decompress_end, deserialize_end, requestCompressionDuration),
};

@@ -193,6 +198,7 @@ }

}
function make_request_timing(request_start, response_start, body_read_end, decompress_end, deserialize_end) {
function make_request_timing(request_start, response_start, body_read_end, decompress_end, deserialize_end, requestCompressionDuration) {
return {
response_time: response_start - request_start,
body_read_time: body_read_end ? body_read_end - response_start : 0,
compress_time: requestCompressionDuration ? requestCompressionDuration : 0,
decompress_time: decompress_end && body_read_end ? decompress_end - body_read_end : 0,

@@ -199,0 +205,0 @@ deserialize_time: deserialize_end && decompress_end ? deserialize_end - decompress_end : 0,

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

decompress_time: number;
compress_time: number;
}

@@ -75,3 +76,4 @@ export interface NamespaceMetadata {

connectionIdleTimeout, // socket idle timeout in ms, default 1 minute
warmConnections, }: {
warmConnections, // number of connections to open initially when creating a new client
compression, }: {
apiKey: string;

@@ -82,2 +84,3 @@ baseUrl?: string;

warmConnections?: number;
compression?: boolean;
});

@@ -84,0 +87,0 @@ /**

@@ -50,4 +50,4 @@ "use strict";

warmConnections = 0, // number of connections to open initially when creating a new client
}) {
this.http = (0, httpClient_1.createHTTPClient)(baseUrl, apiKey, connectTimeout, connectionIdleTimeout, warmConnections);
compression = true, }) {
this.http = (0, httpClient_1.createHTTPClient)(baseUrl, apiKey, connectTimeout, connectionIdleTimeout, warmConnections, compression);
}

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

deserialize_time: response.request_timing.deserialize_time,
compress_time: response.request_timing.compress_time,
},

@@ -160,0 +161,0 @@ };

{
"name": "@turbopuffer/turbopuffer",
"version": "0.5.7",
"version": "0.5.8",
"description": "Official Typescript API client library for turbopuffer.com",

@@ -42,3 +42,3 @@ "scripts": {

"jest": "^29.7.0",
"prettier": "^3.2.5",
"prettier": "^3.3.3",
"ts-jest": "^29.1.2",

@@ -45,0 +45,0 @@ "typescript": "^5.4.3"

@@ -62,4 +62,3 @@ The **official TypeScript SDK** for Turbopuffer.

```bash
npm publish --access public
```
1. Bump version in `package.json`
2. `npm publish --access public`

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