import type { Client } from "../client/client/index.js"; import { type Deadline } from "./deadline.js"; import { type NeonResult } from "./result.js"; import { type WaitBudget } from "./wait.js"; /** Fully-resolved runtime configuration shared by every resource namespace. */ export interface ResolvedConfig { client: Client; throwOnError: boolean; retries: number; /** `Infinity` when calls are unbounded, which is the default. */ requestTimeoutMs: number; /** * Unset and `false` stay distinct. Create-family methods default polling on when * this is unset; collapsing them in `resolveConfig` made a client `false` a no-op. */ waitForReadiness: boolean | undefined; waitOptions: WaitBudget; orgId?: string; } /** Per-call overrides accepted by every ergonomic method. */ export interface CallOptions { /** Override the client's `throwOnError` for this call. */ throwOnError?: Throw; /** Override the client's `waitForReadiness` for this call (mutations only). */ waitForReadiness?: boolean; /** * Deadline for this request and its retries. `Infinity` opts out of a client-wide * value; readiness polling keeps its own `wait` budget either way. */ requestTimeoutMs?: number; /** * Override the client's `wait` budget for this call's readiness polling. * Does not turn polling on; pair it with `waitForReadiness` when the method * would not wait otherwise. */ wait?: WaitBudget; /** Cancel the call. Surfaces as a `NeonAbortError` (`kind: "aborted"`). */ signal?: AbortSignal; } interface RawResult { data?: D | undefined; error?: unknown; response?: Response | undefined; } /** Every generated call the ergonomic layer makes, given the client and the call's signal. */ type Exec = (client: Client, signal: AbortSignal | undefined) => Promise>; /** * Shared execution core: runs a raw client call under a deadline and with retries, maps * its envelope to the ergonomic resource shape, optionally waits for provisioning * operations, and applies the resolved `throwOnError` policy. Returns the bare value * (throwing) or a {@link NeonResult}. */ export declare class RequestContext { #private; constructor(config: ResolvedConfig); get client(): Client; get defaults(): ResolvedConfig; /** * The deadline for one call: the per-call timeout if given, else the client's. * * A per-call value is validated the same way the client's was. Skipping that left * `requestTimeoutMs: NaN` meaning *unbounded* and a value past `setTimeout`'s range * meaning *1ms*, both silently. */ deadlineFor(opts: CallOptions | undefined): Deadline; /** Per-call, then client, then the method's own default. */ resolveWait(opts: CallOptions | undefined, methodDefault: boolean): boolean; /** The `throwOnError` policy for one call: the per-call override if given, else the client's. */ shouldThrow(opts: CallOptions | undefined): boolean; /** Run a raw call and map its body; applies the resolved `throwOnError` policy. */ run(opts: CallOptions | undefined, exec: Exec, map: (data: D) => T): Promise>; /** Like {@link run} but for endpoints that may return an empty (204) body. */ runVoid(opts: CallOptions | undefined, exec: Exec): Promise>; /** Like {@link execute} for an empty body; returns the envelope without throwing. */ executeVoid(opts: CallOptions | undefined, exec: Exec): Promise>; /** * Run a raw call and map its body, returning the {@link NeonResult} envelope (no * throw). Used by `run` and by workflows that post-process the result. */ execute(opts: CallOptions | undefined, exec: Exec, map: (data: D) => T): Promise>; } export {}; //# sourceMappingURL=context.d.ts.map