/** * The HTTP seam for the `/outpost/*` control plane. * * Every request the client makes goes through an injected {@link OutpostTransport} * rather than calling `fetch` directly. That indirection is the whole reason this * module is portable: * * - hq-cli passes its own `vaultApiFetch`, keeping Sentry breadcrumbs, the * `hqk_` API-key path rewrite table, plan-gate decoding, and plan-limit * peeking exactly as they were before this code moved out of the CLI. * - a Next.js app (server action / route handler) passes * {@link createOutpostTransport}, which is a thin authenticated `fetch` with * no Node built-ins and no ambient state. * - a test passes a stub and asserts on the request shape. * * The option bag deliberately matches hq-cli's `VaultApiOptions` field-for-field * so `vaultApiFetch` satisfies `OutpostTransport` structurally — no adapter, no * chance of the two drifting into a subtle mismatch. */ /** The subset of `fetch` this module needs. Lets callers inject a wrapper. */ export type FetchLike = (input: string, init?: RequestInit) => Promise; /** One control-plane request, described declaratively so any transport can serve it. */ export interface OutpostRequest { /** Bearer token. A Cognito JWT, or an `hqk_` vault API key. */ token: string; /** Control-plane path, e.g. `/outpost/list`. Always absolute, always leading slash. */ path: string; /** Defaults to `GET`. */ method?: string; /** JSON request body. Serialized by the transport, not by the caller. */ body?: Record; /** Query parameters appended to the URL. */ query?: Record; /** Origin override. Transports that own their base URL may ignore this. */ baseUrl?: string; signal?: AbortSignal; } /** * A function that performs an {@link OutpostRequest} and resolves with the raw * `Response` — non-2xx included. Decoding and error mapping happen in the * client, so a transport never needs to understand hq-pro's error envelopes. */ export type OutpostTransport = (request: OutpostRequest) => Promise; export declare function defaultOutpostApiUrl(env?: Record): string; /** * Build a plain authenticated-`fetch` transport. This is the default wiring for * any non-CLI consumer — notably a Next.js server action or route handler. * * Uses no Node built-ins and keeps no module-level state, so it works unchanged * on the Node and edge runtimes. Never attach this to a client component: the * bearer token must stay server-side. * * ```ts * // app/outposts/actions.ts * "use server"; * import { OutpostsClient, createOutpostTransport } from "@indigoai-us/hq-cloud/outposts"; * * const client = new OutpostsClient({ * transport: createOutpostTransport(), * token: async () => (await auth())!.idToken, * }); * * export async function listMyOutposts() { * return client.list(); * } * ``` */ export declare function createOutpostTransport(options?: { /** Control-plane origin. Defaults to {@link defaultOutpostApiUrl}. */ baseUrl?: string; /** Injectable `fetch`. Defaults to the platform global. */ fetch?: FetchLike; /** Extra headers on every request — e.g. client-identification headers. */ headers?: Record; }): OutpostTransport; //# sourceMappingURL=transport.d.ts.map