/** * Minimal OpenAPI 3.1 document type. The emitter targets the 3.1 * spec; the type is intentionally a structural subset rather than * the full surface from `openapi-types` so callers can post-process * without fighting the type system. Cast to a fuller type from * `openapi-types` when downstream consumers need it. */ export type OpenAPIDocument = { readonly openapi: "3.1.0"; readonly info: OpenAPIInfo; readonly servers?: ReadonlyArray; readonly paths: Record; readonly components: OpenAPIComponents; }; /** * Per-call options for {@link openapi}. The host supplies the * document-shape fields the registry can't derive (title, version, * servers) and toggles for the cross-cutting headers that the live * REST API may accept. * * - `info` — required. `title` and `version` must be non-empty; * `info` may carry any other top-level OpenAPI info fields. * - `servers` — optional. Each entry's `url` may contain * `{variable}` template syntax; bare URLs are validated through * `URL`'s parser and reject malformed inputs. * - `basePath` — optional, default `/api`. Mirrors the Hono * sibling's default so the doc describes the same paths the * generated REST surface serves. * - `idempotency` — optional, default `false`. When `true`, every * mutation operation documents a **required** `Idempotency-Key` * request header (the generated route fail-closes with 400 when the * header is absent, so the doc marks it required, not optional). * - `expectedVersion` — optional, default `false`. When `true`, * every mutation operation documents an optional `If-Match` * request header carrying the expected stream version. */ export type OpenAPIOptions = { readonly info: OpenAPIInfo; readonly servers?: ReadonlyArray; readonly basePath?: string; readonly idempotency?: boolean; readonly expectedVersion?: boolean; }; export type OpenAPIInfo = { readonly title: string; readonly version: string; readonly description?: string; readonly summary?: string; readonly termsOfService?: string; readonly contact?: { readonly name?: string; readonly url?: string; readonly email?: string; }; readonly license?: { readonly name: string; readonly identifier?: string; readonly url?: string; }; }; export type OpenAPIServer = { readonly url: string; readonly description?: string; readonly variables?: Record; readonly description?: string; }>; }; export type OpenAPIPathItem = { readonly post?: OpenAPIOperation; }; export type OpenAPIOperation = { readonly operationId: string; readonly summary: string; readonly tags: ReadonlyArray; readonly parameters?: ReadonlyArray; readonly requestBody?: OpenAPIRequestBody; readonly responses: Record; }; export type OpenAPIParameter = { readonly name: string; readonly in: "header" | "query" | "path" | "cookie"; readonly required?: boolean; readonly description?: string; readonly schema?: Record; }; export type OpenAPIRequestBody = { readonly required?: boolean; readonly content: Record; }>; }; export type OpenAPIResponse = { readonly description: string; readonly content?: Record; }>; } | { readonly $ref: string; }; export type OpenAPIComponents = { readonly schemas: Record>; readonly responses: Record; }; /** * Build an OpenAPI 3.1 document describing a built `Act` instance's * action surface. * * Walks `app.registry.actions` once and emits a `POST * /actions/` operation per action, deriving * the request-body schema from each action's Zod definition via * `z.toJSONSchema` (Zod 4's native JSON Schema 2020-12 emitter, * which is the OpenAPI 3.1 schema dialect — no conversion layer * needed). Error responses reference the shared * `#/components/responses/ApiError` so a single envelope shape * covers every error path. * * @param app A built `Act` orchestrator. Required. * @param options Document-shape fields (`info.title`, `info.version`, * servers, base path) and toggles for the cross-cutting headers * the live REST API may accept (`Idempotency-Key`, `If-Match`). * @returns A valid OpenAPI 3.1 document object — serve as * `/openapi.json`, ship to a CDN, write to disk during CI, or * pipe to a codegen tool. * * @throws Error if `info.title` / `info.version` is missing or * empty, or if any `servers[].url` fails URL parsing after * `{variable}` substitution. */ /** * Structural shape of the Act surface this emitter walks. Letting * TApp infer to the caller's concrete `Act` instead * of forcing it to fit a narrow framework-typed upper bound keeps * the caller's variance from leaking — and avoids `any` in the * signature. * * @internal */ type ActRegistryView = { readonly registry: { actions: Record; }>; }; }; export declare function openapi(app: TApp, options: OpenAPIOptions): OpenAPIDocument; export {}; //# sourceMappingURL=index.d.ts.map