@theholocron/http-client 1.58.0-alpha.1 → 1.58.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +6 -0
- package/dist/index.mjs +1 -0
- package/dist/testing.d.mts +1 -0
- package/dist/testing.mjs +8 -2
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -111,6 +111,12 @@ interface RequestOptions {
|
|
|
111
111
|
query?: Record<string, string>;
|
|
112
112
|
/** Return `undefined` without parsing even on a 200 response. */
|
|
113
113
|
expectNoContent?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Called with the response headers of a successful (2xx) response, before the body is read. For a value the
|
|
116
|
+
* vendor returns in a header rather than the body (GitHub's token expiry). A failed response throws as before
|
|
117
|
+
* and does not call it.
|
|
118
|
+
*/
|
|
119
|
+
onResponse?: (headers: Headers) => void;
|
|
114
120
|
}
|
|
115
121
|
interface RestClient {
|
|
116
122
|
readonly baseUrl: string;
|
package/dist/index.mjs
CHANGED
|
@@ -213,6 +213,7 @@ function createRestClient(config) {
|
|
|
213
213
|
path,
|
|
214
214
|
status: res.status
|
|
215
215
|
}, "response");
|
|
216
|
+
opts.onResponse?.(res.headers);
|
|
216
217
|
if (opts.expectNoContent || res.status === 204) return void 0;
|
|
217
218
|
const text = await res.text();
|
|
218
219
|
if (!text) return void 0;
|
package/dist/testing.d.mts
CHANGED
package/dist/testing.mjs
CHANGED
|
@@ -21,9 +21,15 @@ function stubFetch(responses) {
|
|
|
21
21
|
body: {}
|
|
22
22
|
};
|
|
23
23
|
const status = next.status ?? 200;
|
|
24
|
-
if (status === 204) return new Response(null, {
|
|
24
|
+
if (status === 204) return new Response(null, {
|
|
25
|
+
status,
|
|
26
|
+
headers: next.headers
|
|
27
|
+
});
|
|
25
28
|
const text = next.text ?? JSON.stringify(next.body ?? {});
|
|
26
|
-
return new Response(text, {
|
|
29
|
+
return new Response(text, {
|
|
30
|
+
status,
|
|
31
|
+
headers: next.headers
|
|
32
|
+
});
|
|
27
33
|
}),
|
|
28
34
|
calls
|
|
29
35
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/http-client",
|
|
3
|
-
"version": "1.58.0-alpha.
|
|
3
|
+
"version": "1.58.0-alpha.3",
|
|
4
4
|
"description": "Shared HTTP primitives for theholocron — REST client factory, auth resolver, and error types",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"dist"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@theholocron/
|
|
40
|
-
"@theholocron/
|
|
39
|
+
"@theholocron/env-utils": "^1.16.1-alpha.1",
|
|
40
|
+
"@theholocron/observability": "^0.6.1-alpha.1"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "^26",
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"tsdown": "^0.23.3",
|
|
50
50
|
"typescript": "^5.9.3",
|
|
51
51
|
"vitest": "^5.0.5",
|
|
52
|
-
"@theholocron/
|
|
52
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.3",
|
|
53
53
|
"@theholocron/tsdown-config": "^8.9.0-alpha.3",
|
|
54
|
-
"@theholocron/
|
|
55
|
-
"@theholocron/
|
|
54
|
+
"@theholocron/eslint-config": "^8.9.0-alpha.3",
|
|
55
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.3"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"vitest": ">=4.0.0"
|