@turbopuffer/turbopuffer
Advanced tools
Comparing version 0.5.5 to 0.5.6
@@ -13,2 +13,3 @@ /// <reference types="node" /> | ||
body_read_time: number; | ||
deserialize_time: number; | ||
}; | ||
@@ -15,0 +16,0 @@ export type RequestResponse<T> = Promise<{ |
@@ -156,3 +156,8 @@ "use strict"; | ||
} | ||
const json = (await response.json()); | ||
// internally json() will read the full body, decode utf-8, and allocate a string, | ||
// so splitting it up into text() and JSON.parse() has no performance impact | ||
const body_text = await response.text(); | ||
const body_read_end = performance.now(); | ||
const json = JSON.parse(body_text); | ||
const deserialize_end = performance.now(); | ||
if (json.status && json.status === "error") { | ||
@@ -163,7 +168,6 @@ throw new TurbopufferError(json.error || json, { | ||
} | ||
let response_end = performance.now(); | ||
return { | ||
body: json, | ||
headers: response.headers, | ||
request_timing: make_request_timing(request_start, response_start, response_end), | ||
request_timing: make_request_timing(request_start, response_start, body_read_end, deserialize_end), | ||
}; | ||
@@ -189,8 +193,9 @@ } | ||
} | ||
function make_request_timing(request_start, response_start, response_end) { | ||
function make_request_timing(request_start, response_start, body_read_end, deserialize_end) { | ||
return { | ||
response_time: response_start - request_start, | ||
body_read_time: response_end ? response_end - response_start : 0, | ||
body_read_time: body_read_end ? body_read_end - response_start : 0, | ||
deserialize_time: deserialize_end && body_read_end ? deserialize_end - body_read_end : 0, | ||
}; | ||
} | ||
//# sourceMappingURL=httpClient.js.map |
@@ -42,3 +42,3 @@ /** | ||
}[]; | ||
export type QueryMetrics = { | ||
export interface QueryMetrics { | ||
approx_namespace_size: number; | ||
@@ -51,3 +51,4 @@ cache_hit_ratio: number; | ||
body_read_time: number; | ||
}; | ||
deserialize_time: number; | ||
} | ||
export interface NamespaceMetadata { | ||
@@ -54,0 +55,0 @@ id: string; |
@@ -25,11 +25,11 @@ "use strict"; | ||
function parseServerTiming(value) { | ||
let output = {}; | ||
const output = {}; | ||
const sections = value.split(", "); | ||
for (let section of sections) { | ||
let tokens = section.split(";"); | ||
let base_key = tokens.shift(); | ||
for (let token of tokens) { | ||
let components = token.split("="); | ||
let key = base_key + "." + components[0]; | ||
let value = components[1]; | ||
for (const section of sections) { | ||
const tokens = section.split(";"); | ||
const base_key = tokens.shift(); | ||
for (const token of tokens) { | ||
const components = token.split("="); | ||
const key = base_key + "." + components[0]; | ||
const value = components[1]; | ||
output[key] = value; | ||
@@ -126,3 +126,3 @@ } | ||
var params = __rest(_a, []); | ||
let resultsWithMetrics = await this.queryWithMetrics(params); | ||
const resultsWithMetrics = await this.queryWithMetrics(params); | ||
return resultsWithMetrics.results; | ||
@@ -136,3 +136,3 @@ } | ||
var params = __rest(_a, []); | ||
let response = await this.client.http.doRequest({ | ||
const response = await this.client.http.doRequest({ | ||
method: "POST", | ||
@@ -158,2 +158,3 @@ path: `/v1/vectors/${this.id}/query`, | ||
body_read_time: response.request_timing.body_read_time, | ||
deserialize_time: response.request_timing.deserialize_time, | ||
}, | ||
@@ -257,6 +258,6 @@ }; | ||
function fromColumnar(cv) { | ||
var _a; | ||
const res = new Array(cv.ids.length); | ||
const attributeEntries = Object.entries((_a = cv.attributes) !== null && _a !== void 0 ? _a : {}); | ||
for (let i = 0; i < cv.ids.length; i++) { | ||
var _a, _b, _c; | ||
const res = new Array((_a = cv.ids) === null || _a === void 0 ? void 0 : _a.length); | ||
const attributeEntries = Object.entries((_b = cv.attributes) !== null && _b !== void 0 ? _b : {}); | ||
for (let i = 0; i < ((_c = cv.ids) === null || _c === void 0 ? void 0 : _c.length); i++) { | ||
res[i] = { | ||
@@ -263,0 +264,0 @@ id: cv.ids[i], |
{ | ||
"name": "@turbopuffer/turbopuffer", | ||
"version": "0.5.5", | ||
"version": "0.5.6", | ||
"description": "Official Typescript API client library for turbopuffer.com", | ||
@@ -5,0 +5,0 @@ "scripts": { |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46540
689