@turbopuffer/turbopuffer
Advanced tools
Comparing version 0.5.1 to 0.5.2
@@ -10,5 +10,10 @@ /// <reference types="node" /> | ||
} | ||
export type RequestTiming = { | ||
response_time: number; | ||
body_read_time: number; | ||
}; | ||
export type RequestResponse<T> = Promise<{ | ||
body?: T; | ||
headers: Headers; | ||
request_timing: RequestTiming; | ||
}>; | ||
@@ -15,0 +20,0 @@ export interface HTTPClient { |
@@ -74,4 +74,7 @@ "use strict"; | ||
let error = null; | ||
let request_start; | ||
let response_start; | ||
for (let attempt = 0; attempt < maxAttempts; attempt++) { | ||
error = null; | ||
request_start = performance.now(); | ||
try { | ||
@@ -105,2 +108,3 @@ response = await (0, undici_1.fetch)(url.toString(), { | ||
} | ||
response_start = performance.now(); | ||
if (!error && response.status >= 400) { | ||
@@ -148,5 +152,6 @@ let message = undefined; | ||
} | ||
if (!response.body) { | ||
if (method === "HEAD" || !response.body) { | ||
return { | ||
headers: response.headers, | ||
request_timing: make_request_timing(request_start, response_start), | ||
}; | ||
@@ -160,5 +165,7 @@ } | ||
} | ||
let response_end = performance.now(); | ||
return { | ||
body: json, | ||
headers: response.headers, | ||
request_timing: make_request_timing(request_start, response_start, response_end), | ||
}; | ||
@@ -184,2 +191,8 @@ } | ||
} | ||
function make_request_timing(request_start, response_start, response_end) { | ||
return { | ||
response_time: response_start - request_start, | ||
body_read_time: response_end ? response_end - response_start : 0, | ||
}; | ||
} | ||
//# sourceMappingURL=httpClient.js.map |
@@ -40,2 +40,4 @@ /** | ||
exhaustive_search_count: number; | ||
response_time: number; | ||
body_read_time: number; | ||
}; | ||
@@ -42,0 +44,0 @@ export interface NamespaceMetadata { |
@@ -151,2 +151,4 @@ "use strict"; | ||
exhaustive_search_count: parseIntMetric(serverTiming["exhaustive_search.count"]), | ||
response_time: response.request_timing.response_time, | ||
body_read_time: response.request_timing.body_read_time, | ||
}, | ||
@@ -153,0 +155,0 @@ }; |
{ | ||
"name": "@turbopuffer/turbopuffer", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "Official Typescript API client library for turbopuffer.com", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -62,3 +62,4 @@ The **official TypeScript SDK** for Turbopuffer. | ||
1. Bump version | ||
2. Release it `npm publish --access public` | ||
```bash | ||
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
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
44576
668
65
0