@gjsify/http-client 0.0.0-stage → 0.64.53

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 gjsify contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,38 @@
1
- # Temporary Holding Version
1
+ # @gjsify/http-client
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A small JSON-over-HTTP client for REST adapters. Plain `fetch`, so it runs on GJS (gjsify's Soup fetch) and Node.
4
+
5
+ Part of the [gjsify](https://github.com/gjsify/gjsify) project. **Tier 3 (experimental, ADR 0003)**: tested against a fake `fetch`, not yet against live servers.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ gjsify install @gjsify/http-client
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ import { HttpClient, paginateAll } from '@gjsify/http-client';
17
+
18
+ const client = new HttpClient({
19
+ baseUrl: 'https://cloud.example.org/index.php/apps/deck/api/v1.1/',
20
+ auth: { type: 'app-password', username: 'user@example.org', password }, // or basic / bearer / header
21
+ });
22
+ const result = await client.getJson<Board[]>('boards', { etag }); // ok | unchanged (304)
23
+ const cards = await paginateAll<Card>(client, 'cards', { style: 'offset', pageSize: 50 });
24
+ ```
25
+
26
+ - `HttpClient`: base URL, auth (basic, app-password, bearer, or a named header), per-request `timeoutMs` (AbortController), `getJson` with `If-None-Match`; a 304 returns `{ status: 'unchanged' }`. `postJson` and `sendJson` send a JSON body (no ETag revalidation).
27
+ - Errors extend `@gjsify/pim`'s `BackendError` (`domain: 'http'`, status in `code`): `UnauthorizedError` (a `BackendAuthError`), `ForbiddenError`, `NotFoundError`, `RateLimitedError` (`retryAfterMs` from `Retry-After`), `ServerError`, `TimeoutError`, `NetworkError`, `ResponseFormatError`.
28
+ - `paginate` / `paginateAll`: `Link: rel="next"` (never leaves the origin) and offset/pageSize (`offsetUnit: 'pages'` when the offset is a page number), with a page cap.
29
+ - `HostLimiter`: per-host concurrency (default 2) and optional minimum interval.
30
+ - Credentials never appear in messages, `toJSON`, or URLs; a request off the base origin is refused.
31
+
32
+ ## What it does not do
33
+
34
+ No retries (a 401/403 is a decision, a 429 or timeout is the caller's schedule), no robots.txt or compliance gate. The name is `@gjsify/http-client` to stay clear of the Node `http` polyfill (`@gjsify/http`).
35
+
36
+ ## License
37
+
38
+ MIT
@@ -0,0 +1 @@
1
+ var e=Object.defineProperty,__name=(t,n)=>e(t,`name`,{value:n,configurable:!0});export{__name};
@@ -0,0 +1 @@
1
+ import"./_virtual/_rolldown/runtime.js";import{ForbiddenError as e,HttpError as t,NetworkError as n,NotFoundError as r,RateLimitedError as i,ResponseFormatError as a,ServerError as o,TimeoutError as s,UnauthorizedError as c}from"./errors.js";import{HostLimiter as l}from"./limiter.js";const u=new l({maxConcurrent:2});function parseRetryAfter(e,t=Date.now()){let n=e?.trim();if(!n)return;if(/^\d+$/.test(n))return Number(n)*1e3;let r=Date.parse(n);return Number.isNaN(r)?void 0:Math.max(0,r-t)}function toBase64(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n)}var HttpClient=class{baseUrl;#e;#t=[];#n;#r;#i;#a;constructor(e){let t=new URL(e.baseUrl);if(t.username||t.password)throw TypeError("baseUrl must not contain credentials; pass `auth` instead");t.pathname.endsWith(`/`)||(t.pathname+=`/`),t.search=``,t.hash=``,this.baseUrl=t.href;let n=e.auth;if(n?.type===`bearer`)this.#e=[`Authorization`,`Bearer ${n.token}`],this.#t.push(n.token);else if(n?.type===`header`)this.#e=[n.name,n.value],this.#t.push(n.value);else if(n){let e=toBase64(`${n.username}:${n.password}`);this.#e=[`Authorization`,`Basic ${e}`],this.#t.push(n.password,e)}this.#n={...e.headers},this.#r=e.timeoutMs??2e4,this.#i=e.limiter??u,this.#a=e.fetch??globalThis.fetch.bind(globalThis)}toJSON(){return{baseUrl:this.baseUrl}}get origin(){return new URL(this.baseUrl).origin}resolve(e,t){let n=/^[a-z][a-z0-9+.-]*:/i.test(e)?new URL(e):new URL(e.replace(/^\/+/,``),this.baseUrl);if(n.origin!==this.origin)throw TypeError(`refusing to leave ${this.origin}`);for(let[e,r]of Object.entries(t??{}))r!==void 0&&n.searchParams.set(e,String(r));return n}async getJson(e,t={}){return this.#o(`GET`,e,void 0,t)}async postJson(e,t,n={}){return this.#o(`POST`,e,JSON.stringify(t),n)}async sendJson(e,t,n,r={}){return this.#o(e,t,JSON.stringify(n),r)}async#o(e,t,n,r){let i=this.resolve(t,r.query),o=`${i.origin}${i.pathname}`,s={Accept:`application/json`,"Accept-Encoding":`gzip, deflate`,...this.#n,...r.headers};n!==void 0&&(s[`Content-Type`]=`application/json`),r.etag&&(s[`If-None-Match`]=r.etag),this.#e&&(s[this.#e[0]]=this.#e[1]);let c=await this.#i.run(i.host,()=>this.#s(e,i,o,s,r,n));if(c.status===304)return{status:`unchanged`,etag:c.headers.get(`etag`)??r.etag};if(c.status<200||c.status>299)throw this.#c(e,c,o);if(c.text.trim()===``){if(r.allowEmpty)return{status:`ok`,data:void 0,etag:c.headers.get(`etag`)??void 0,headers:c.headers};throw new a(`${e} ${o} answered HTTP ${c.status} with an empty body`,{status:c.status,url:o})}try{return{status:`ok`,data:JSON.parse(c.text),etag:c.headers.get(`etag`)??void 0,headers:c.headers}}catch{throw new a(`${e} ${o} answered HTTP ${c.status} with a body that is not JSON`,{status:c.status,url:o})}}async#s(e,t,r,i,a,o){let c=a.timeoutMs??this.#r,l=new AbortController,u=!1,d=setTimeout(()=>{u=!0,l.abort()},c),relay=()=>l.abort(),f=a.signal;f?.addEventListener(`abort`,relay,{once:!0}),f?.aborted&&l.abort();try{let n=await this.#a(t.href,{method:e,headers:i,body:o,signal:l.signal}),r=n.status===304?``:await n.text();return{status:n.status,headers:n.headers,text:r}}catch(t){throw u?new s(`${e} ${r} timed out after ${c} ms`,{url:r}):f?.aborted?t:new n(`${e} ${r} failed: ${t instanceof Error?this.#l(t.message):`unknown error`}`,{url:r})}finally{clearTimeout(d),f?.removeEventListener(`abort`,relay)}}#c(n,a,s){let l=a.status,u=parseRetryAfter(a.headers.get(`retry-after`)),d=`${n} ${s} answered HTTP ${l}`,f=u===void 0?{status:l,url:s}:{status:l,url:s,retryAfterMs:u};return l===401?new c(d,f):l===403?new e(d,f):l===404?new r(d,f):l===429?new i(d,f):l>=500?new o(d,f):new t(d,f)}#l(e){let t=e;for(let e of this.#t)e&&(t=t.split(e).join(`[redacted]`));return t}};function createHttpClient(e){return new HttpClient(e)}export{HttpClient,createHttpClient,parseRetryAfter};
@@ -0,0 +1 @@
1
+ import"./_virtual/_rolldown/runtime.js";import{BackendAuthError as e,BackendError as t}from"@gjsify/pim";var HttpError=class extends t{status;url;retryAfterMs;constructor(e,t){super(e,`http`,t.status),this.status=t.status,this.url=t.url,this.retryAfterMs=t.retryAfterMs}},UnauthorizedError=class extends e{status;url;retryAfterMs;constructor(e,t){super(e,`http`,t.status),this.status=t.status,this.url=t.url,this.retryAfterMs=t.retryAfterMs}},ForbiddenError=class extends HttpError{},NotFoundError=class extends HttpError{},RateLimitedError=class extends HttpError{},ServerError=class extends HttpError{},TimeoutError=class extends HttpError{},NetworkError=class extends HttpError{},ResponseFormatError=class extends HttpError{};function isHttpFailure(e){return e instanceof HttpError||e instanceof UnauthorizedError}export{ForbiddenError,HttpError,NetworkError,NotFoundError,RateLimitedError,ResponseFormatError,ServerError,TimeoutError,UnauthorizedError,isHttpFailure};
@@ -0,0 +1 @@
1
+ import{ForbiddenError as e,HttpError as t,NetworkError as n,NotFoundError as r,RateLimitedError as i,ResponseFormatError as a,ServerError as o,TimeoutError as s,UnauthorizedError as c,isHttpFailure as l}from"./errors.js";import{HostLimiter as u}from"./limiter.js";import{HttpClient as d,createHttpClient as f,parseRetryAfter as p}from"./client.js";import{paginate as m,paginateAll as h,parseLinkHeader as g}from"./paginate.js";export{e as ForbiddenError,u as HostLimiter,d as HttpClient,t as HttpError,n as NetworkError,r as NotFoundError,i as RateLimitedError,a as ResponseFormatError,o as ServerError,s as TimeoutError,c as UnauthorizedError,f as createHttpClient,l as isHttpFailure,m as paginate,h as paginateAll,g as parseLinkHeader,p as parseRetryAfter};
@@ -0,0 +1 @@
1
+ import"./_virtual/_rolldown/runtime.js";var HostLimiter=class{#e;#t;#n;#r;#i=new Map;constructor(e={}){let t=e.maxConcurrent??2;if(!Number.isInteger(t)||t<1)throw RangeError(`maxConcurrent must be an integer >= 1`);this.#e=t,this.#t=Math.max(0,e.minIntervalMs??0),this.#n=e.sleep??(e=>new Promise(t=>setTimeout(t,e))),this.#r=e.now??(()=>Date.now())}async run(e,t){let n=this.#i.get(e);n||(n={active:0,waiting:[],nextStart:0},this.#i.set(e,n)),n.active>=this.#e?await new Promise(e=>n.waiting.push(e)):n.active+=1;try{if(this.#t>0){let e=this.#r(),t=Math.max(e,n.nextStart);n.nextStart=t+this.#t,t>e&&await this.#n(t-e)}return await t()}finally{let e=n.waiting.shift();e?e():--n.active}}};export{HostLimiter};
@@ -0,0 +1 @@
1
+ import"./_virtual/_rolldown/runtime.js";import{ResponseFormatError as e}from"./errors.js";function parseLinkHeader(e){let t=[];if(!e)return t;for(let n of e.matchAll(/<([^>]*)>((?:\s*;\s*[^;,]+)*)/g)){let e=/rel\s*=\s*"?([^";]+)"?/i.exec(n[2]??``)?.[1];t.push({url:n[1]??``,rel:e?e.trim().toLowerCase().split(/\s+/):[]})}return t}async function*paginate(t,n,r){let i=r.maxPages??100,a=r.items??(n=>{if(Array.isArray(n))return n;throw new e(`a page body is not an array`,{url:t.origin})}),o={headers:r.headers,signal:r.signal,timeoutMs:r.timeoutMs};if(r.style===`link`){let s=n;for(let n=0;s;n+=1){if(n>=i)throw new e(`more than ${i} pages`,{url:t.origin});let c=t.resolve(s),l=await t.getJson(s,{...o,query:n===0?r.query:void 0});if(l.status===`unchanged`)return;yield a(l.data);let u=parseLinkHeader(l.headers.get(`link`)).find(e=>e.rel.includes(`next`));if(!u)return;let d=new URL(u.url,c);if(d.origin!==t.origin)throw new e(`the next page link leaves the server`,{url:t.origin});s=d.href}return}let s=r.offsetParam??`offset`,c=r.limitParam??`pageSize`,l=r.offsetUnit===`pages`,u=+!!l;for(let d=0;;d+=1){if(d>=i)throw new e(`more than ${i} pages`,{url:t.origin});let f={...r.query,[c]:r.pageSize,[s]:u},p=await t.getJson(n,{...o,query:f});if(p.status===`unchanged`)return;let m=a(p.data);if(m.length>0&&(yield m),m.length<r.pageSize)return;u+=l?1:m.length}}async function paginateAll(e,t,n){let r=[];for await(let i of paginate(e,t,n))r.push(...i);return r}export{paginate,paginateAll,parseLinkHeader};
@@ -0,0 +1,88 @@
1
+ /**
2
+ * The one way a REST adapter talks to its server. Plain `fetch`, so it runs on GJS (gjsify's Soup
3
+ * fetch) and Node alike.
4
+ *
5
+ * What it does NOT do, on purpose: retry. A 401 or 403 is a decision, and a 429 or a timeout is
6
+ * the caller's schedule to back off on (the sync service owns that). It reports what happened as a
7
+ * typed error and leaves the next attempt to someone who knows the budget.
8
+ */
9
+ import { HostLimiter } from './limiter.js';
10
+ export type HttpAuth = {
11
+ readonly type: 'basic';
12
+ readonly username: string;
13
+ readonly password: string;
14
+ }
15
+ /** Nextcloud-style app password: Basic on the wire, kept apart so config can say what it holds. */
16
+ | {
17
+ readonly type: 'app-password';
18
+ readonly username: string;
19
+ readonly password: string;
20
+ } | {
21
+ readonly type: 'bearer';
22
+ readonly token: string;
23
+ }
24
+ /** A key in a header of its own (Zenkit's `Zenkit-API-Key`); scrubbed from errors like any secret. */
25
+ | {
26
+ readonly type: 'header';
27
+ readonly name: string;
28
+ readonly value: string;
29
+ };
30
+ export type QueryValue = string | number | boolean | undefined;
31
+ export interface HttpClientOptions {
32
+ /** Server root, e.g. `https://cloud.example.org/index.php/apps/deck/api/v1.1/`. No credentials in it. */
33
+ readonly baseUrl: string;
34
+ readonly auth?: HttpAuth;
35
+ /** Sent with every request (User-Agent, OCS-APIRequest …). */
36
+ readonly headers?: Record<string, string>;
37
+ /** Per request, queue wait excluded. Default 20 000. */
38
+ readonly timeoutMs?: number;
39
+ /** Shared by default (two requests per host, process-wide); pass your own to change that. */
40
+ readonly limiter?: HostLimiter;
41
+ /** Injected for tests; defaults to global fetch. */
42
+ readonly fetch?: typeof fetch;
43
+ }
44
+ export interface GetJsonOptions {
45
+ /** Sent as `If-None-Match`; a 304 then comes back as `unchanged`. */
46
+ readonly etag?: string;
47
+ readonly query?: Record<string, QueryValue>;
48
+ readonly headers?: Record<string, string>;
49
+ readonly signal?: AbortSignal;
50
+ readonly timeoutMs?: number;
51
+ /** A 2xx with an empty body is `ok` with `data` undefined, not a format error (writes that answer "200 Success"). */
52
+ readonly allowEmpty?: boolean;
53
+ }
54
+ export type JsonResult<T> = {
55
+ readonly status: 'ok';
56
+ readonly data: T;
57
+ readonly etag: string | undefined;
58
+ readonly headers: Headers;
59
+ } | {
60
+ readonly status: 'unchanged';
61
+ readonly etag: string | undefined;
62
+ };
63
+ /** Seconds or an HTTP date → milliseconds from `now`; undefined when absent or unreadable. */
64
+ export declare function parseRetryAfter(value: string | null | undefined, now?: number): number | undefined;
65
+ export declare class HttpClient {
66
+ #private;
67
+ readonly baseUrl: string;
68
+ constructor(options: HttpClientOptions);
69
+ /** Serialising a client never reveals its credentials. */
70
+ toJSON(): {
71
+ baseUrl: string;
72
+ };
73
+ get origin(): string;
74
+ /**
75
+ * Relative paths hang off the base URL; an absolute URL must stay on the server's origin — the
76
+ * credentials go wherever this resolves, so a link the server hands out cannot redirect them.
77
+ */
78
+ resolve(path: string, query?: Record<string, QueryValue>): URL;
79
+ getJson<T>(path: string, options?: GetJsonOptions): Promise<JsonResult<T>>;
80
+ /**
81
+ * A JSON body in, JSON out. For query-style POSTs (Zenkit's entry filter); there is no ETag
82
+ * revalidation on it, so `unchanged` never comes back.
83
+ */
84
+ postJson<T>(path: string, body: unknown, options?: GetJsonOptions): Promise<JsonResult<T>>;
85
+ /** A JSON body with PUT or PATCH (board writes); like `postJson`, no ETag revalidation. */
86
+ sendJson<T>(method: 'PUT' | 'PATCH' | 'POST', path: string, body: unknown, options?: GetJsonOptions): Promise<JsonResult<T>>;
87
+ }
88
+ export declare function createHttpClient(options: HttpClientOptions): HttpClient;
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * One failure, one type. Every error extends the port's `BackendError` (401 extends
3
+ * `BackendAuthError`) with `domain: 'http'` and the status in `code`, so a sync service that
4
+ * classifies backend failures needs no second code path for REST sources.
5
+ *
6
+ * Messages carry method, origin, path and status — never a header, a query string, a response
7
+ * body or a credential.
8
+ */
9
+ import { BackendAuthError, BackendError } from '@gjsify/pim';
10
+ export interface HttpErrorDetails {
11
+ /** HTTP status; absent for a timeout or a network failure. */
12
+ readonly status?: number;
13
+ /** Origin + path of the request, without query or credentials. */
14
+ readonly url: string;
15
+ /** The server's Retry-After in milliseconds, when it sent one. */
16
+ readonly retryAfterMs?: number;
17
+ }
18
+ export interface HttpFailure {
19
+ readonly status: number | undefined;
20
+ readonly url: string;
21
+ readonly retryAfterMs: number | undefined;
22
+ }
23
+ /** Any other non-success answer (400, 409, 410 …); the specific classes below extend it. */
24
+ export declare class HttpError extends BackendError implements HttpFailure {
25
+ readonly status: number | undefined;
26
+ readonly url: string;
27
+ readonly retryAfterMs: number | undefined;
28
+ constructor(message: string, details: HttpErrorDetails);
29
+ }
30
+ /** 401: the credentials were rejected. Retrying with the same ones cannot help. */
31
+ export declare class UnauthorizedError extends BackendAuthError implements HttpFailure {
32
+ readonly status: number | undefined;
33
+ readonly url: string;
34
+ readonly retryAfterMs: number | undefined;
35
+ constructor(message: string, details: HttpErrorDetails);
36
+ }
37
+ /** 403: authenticated, but not allowed. A decision of the server, not a hiccup. */
38
+ export declare class ForbiddenError extends HttpError {
39
+ }
40
+ export declare class NotFoundError extends HttpError {
41
+ }
42
+ /** 429; `retryAfterMs` is set when the server named a wait. */
43
+ export declare class RateLimitedError extends HttpError {
44
+ }
45
+ /** 5xx; `retryAfterMs` is set when the server named a wait (a 503 with one is a rate limit). */
46
+ export declare class ServerError extends HttpError {
47
+ }
48
+ export declare class TimeoutError extends HttpError {
49
+ }
50
+ /** No answer at all: refused, reset, DNS. */
51
+ export declare class NetworkError extends HttpError {
52
+ }
53
+ /** A 2xx whose body is not what was asked for (not JSON, empty, a page that is not an array). */
54
+ export declare class ResponseFormatError extends HttpError {
55
+ }
56
+ export declare function isHttpFailure(err: unknown): err is HttpError | UnauthorizedError;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * `@gjsify/http-client` — a small JSON-over-HTTP client for REST adapters, on GJS and Node.
3
+ * See README.md for what it covers and what it leaves to the caller.
4
+ */
5
+ export * from './client.js';
6
+ export * from './errors.js';
7
+ export * from './limiter.js';
8
+ export * from './paginate.js';
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Per-host pacing: at most `maxConcurrent` requests in flight to one host, and optionally a gap
3
+ * between the starts of two. Hosts are independent. Slots are handed over directly, so a waiter
4
+ * never races a newcomer for the slot a finished request frees.
5
+ */
6
+ export interface HostLimiterOptions {
7
+ /** Requests in flight per host. Default 2. */
8
+ readonly maxConcurrent?: number;
9
+ /** Minimum gap between two request starts on one host, in ms. Default 0. */
10
+ readonly minIntervalMs?: number;
11
+ /** Injected for tests. */
12
+ readonly sleep?: (ms: number) => Promise<void>;
13
+ readonly now?: () => number;
14
+ }
15
+ export declare class HostLimiter {
16
+ #private;
17
+ constructor(options?: HostLimiterOptions);
18
+ run<T>(host: string, task: () => Promise<T>): Promise<T>;
19
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Pagination as an async generator of pages, so a caller can stop early and nothing is fetched
3
+ * ahead. Two styles cover the three target servers: `Link: <…>; rel="next"` and offset + page size.
4
+ * A runaway server is an error, never a silently truncated list.
5
+ */
6
+ import type { HttpClient, QueryValue } from './client.js';
7
+ export interface PageOptions<T> {
8
+ /** Items of one response body. Default: the body itself, which must be an array. */
9
+ readonly items?: (body: unknown) => T[];
10
+ /** More pages than this is an error. Default 100. */
11
+ readonly maxPages?: number;
12
+ readonly query?: Record<string, QueryValue>;
13
+ readonly headers?: Record<string, string>;
14
+ readonly signal?: AbortSignal;
15
+ readonly timeoutMs?: number;
16
+ }
17
+ export interface LinkPagination<T> extends PageOptions<T> {
18
+ readonly style: 'link';
19
+ }
20
+ export interface OffsetPagination<T> extends PageOptions<T> {
21
+ readonly style: 'offset';
22
+ readonly pageSize: number;
23
+ /** Default `offset`. */
24
+ readonly offsetParam?: string;
25
+ /** Default `pageSize`. */
26
+ readonly limitParam?: string;
27
+ /**
28
+ * What the offset parameter counts. `items` (default): elements skipped, starting at 0.
29
+ * `pages`: a page number starting at 1 — OpenProject's `offset` works this way.
30
+ */
31
+ readonly offsetUnit?: 'items' | 'pages';
32
+ }
33
+ export interface LinkRef {
34
+ readonly url: string;
35
+ readonly rel: string[];
36
+ }
37
+ export declare function parseLinkHeader(header: string | null | undefined): LinkRef[];
38
+ export declare function paginate<T>(client: HttpClient, path: string, options: LinkPagination<T> | OffsetPagination<T>): AsyncGenerator<T[], void, undefined>;
39
+ /** Every item of every page; the page cap still applies. */
40
+ export declare function paginateAll<T>(client: HttpClient, path: string, options: LinkPagination<T> | OffsetPagination<T>): Promise<T[]>;
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,69 @@
1
1
  {
2
- "name": "@gjsify/http-client",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@gjsify/http-client",
3
+ "version": "0.64.53",
4
+ "description": "A small JSON-over-HTTP client for REST adapters: base URL, basic/bearer/app-password auth, ETag revalidation (304 = unchanged), typed errors with Retry-After, per-request timeout, Link and offset pagination, per-host concurrency limit. Plain fetch.",
5
+ "module": "lib/esm/index.js",
6
+ "types": "lib/types/index.d.ts",
7
+ "type": "module",
8
+ "sideEffects": false,
9
+ "exports": {
10
+ ".": {
11
+ "types": "./lib/types/index.d.ts",
12
+ "default": "./lib/esm/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "lib",
17
+ "!lib/types/**/*.spec.d.ts"
18
+ ],
19
+ "scripts": {
20
+ "clear": "gjsify clear lib tmp tsconfig.tsbuildinfo test.gjs.mjs test.node.mjs",
21
+ "check": "gjsify tsc --noEmit",
22
+ "build": "gjsify run build:gjsify && gjsify run build:types",
23
+ "build:gjsify": "gjsify build --library 'src/**/*.{ts,js}' --exclude 'src/**/*.spec.{mts,ts}' 'src/test.{mts,ts}'",
24
+ "build:types": "gjsify tsc",
25
+ "build:test": "gjsify run build:test:gjs && gjsify run build:test:node",
26
+ "build:test:gjs": "gjsify build src/test.mts --app gjs --outfile test.gjs.mjs",
27
+ "build:test:node": "gjsify build src/test.mts --app node --outfile test.node.mjs",
28
+ "test": "gjsify run build:gjsify && gjsify run build:test && gjsify run test:node && gjsify run test:gjs",
29
+ "test:gjs": "gjsify run test.gjs.mjs",
30
+ "test:node": "node test.node.mjs"
31
+ },
32
+ "keywords": [
33
+ "http",
34
+ "fetch",
35
+ "json",
36
+ "rest",
37
+ "etag",
38
+ "pagination"
39
+ ],
40
+ "dependencies": {
41
+ "@gjsify/pim": "^0.64.52"
42
+ },
43
+ "devDependencies": {
44
+ "@gjsify/cli": "^0.64.53",
45
+ "@gjsify/unit": "^0.64.53",
46
+ "@types/node": "^25.9.2",
47
+ "typescript": "^6.0.3"
48
+ },
49
+ "license": "MIT",
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://github.com/gjsify/gjsify.git",
53
+ "directory": "packages/gjs/http-client"
54
+ },
55
+ "bugs": {
56
+ "url": "https://github.com/gjsify/gjsify/issues"
57
+ },
58
+ "homepage": "https://github.com/gjsify/gjsify/tree/main/packages/gjs/http-client#readme",
59
+ "gjsify": {
60
+ "tier": 3,
61
+ "runtimes": {
62
+ "gjs": "polyfill",
63
+ "node": "none",
64
+ "browser": "none",
65
+ "nativescript": "none"
66
+ },
67
+ "headless": true
68
+ }
69
+ }