import type { PythiaClientOptions } from "./types.js"; /** A parsed HTTP response: the numeric status plus the JSON-decoded body. */ export interface ParsedResponse { status: number; body: unknown; } /** * A thin typed transport over an injected `fetchImpl` (default global `fetch`). * Builds the request URL from `baseUrl` + path + query, issues the method, and * returns the parsed JSON body alongside the status so the caller can decide * how to map non-2xx responses. Owns no error-mapping policy itself. */ export declare class Transport { private readonly baseUrl; private readonly fetchImpl; private readonly pythiaKey; constructor(options: PythiaClientOptions); /** * Resolve the `x-pythia-key` gated-access header value for THIS request. A * static string is used as-is; a supplier function is called (and awaited) * fresh every time, so a connector's rotating ephemeral secret is picked up * on each call rather than cached at construction. Returns `undefined` when * no `pythiaKey` option was given, or the supplier itself resolves to * `undefined` — either way, no header is sent. */ private resolvePythiaKey; /** True when a parsed response is the gateway's "your gated key is dead" 401 AND * we hold a refreshable key that can re-mint — i.e. this request is self-healable. */ private isSelfHealable401; private buildUrl; /** * Read the response body defensively. The gateway relays node responses * verbatim, so a node/gateway 5xx can arrive as HTML or an empty body. We read * `.text()` and JSON.parse inside a try/catch: on a parse failure we return the * raw text as the body so the caller maps by HTTP status rather than crashing * on an untyped SyntaxError. An empty body decodes to the empty string. */ private parseBody; /** GET `path` with optional query params; returns status + parsed body. */ get(path: string, query?: Record): Promise; /** POST `path` with a JSON body; returns status + parsed body. On a * self-healable gated `401` (dead ephemeral key + a refreshable key source), * invalidate → re-mint → retry EXACTLY ONCE with the fresh key. A second 401 * surfaces (no loop). Concurrent 401s collapse to one re-mint because the * connector's `refresh()` is in-flight-deduped. */ postJson(path: string, body: unknown): Promise; private doPostJson; }