@theholocron/http-client 1.58.0-alpha.1 → 1.58.0-alpha.2

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 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;
@@ -8,6 +8,7 @@ export declare function stubFetch(responses: Array<{
8
8
  status?: number;
9
9
  body?: unknown;
10
10
  text?: string;
11
+ headers?: Record<string, string>;
11
12
  }>): {
12
13
  fetch: typeof fetch;
13
14
  calls: FetchCall[];
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, { status });
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, { status });
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.1",
3
+ "version": "1.58.0-alpha.2",
4
4
  "description": "Shared HTTP primitives for theholocron — REST client factory, auth resolver, and error types",
5
5
  "keywords": [
6
6
  "typescript",