import type { Request } from 'express'; import type { Pred } from 'runtyp'; export type RouteMeta = { summary: string; /** Optional prose — schemas, errors, and summary already surface in docs UI. */ description?: string; tags: readonly string[]; }; export type McpRouteConfig = true | { name?: string; annotations?: Record; }; export type RouteAuth = 'none' | 'bearer'; /** Whether a route is on the public contract. Private routes still mount; they appear on docs/specs when visibility is `all`. */ export type RouteScope = 'public' | 'private'; /** Default HTTP status for domain route errors when `status` is omitted. */ export declare const DEFAULT_ROUTE_ERROR_STATUS = 400; export type RouteErrorSpec = { status?: number; data?: Pred; }; export type RouteErrorDef = { status: number; data?: Pred; }; /** Declared route failure — return from handlers via `defineErrors` / `err` handles. */ export type RouteFailure = { ok: false; code: string; status: number; data?: unknown; }; export type RouteHandler = (input: TInput, ctx: Ctx) => Promise | TOutput | TFailure; export type RouteDef = { input: Pred; output: Pred; errors?: Record; meta: RouteMeta; auth: RouteAuth; scope: RouteScope; mcp?: McpRouteConfig; handler: RouteHandler; }; /** Wired route — returned from `route({ …, handler })`; required by `spec`. */ export type WiredRoute = RouteDef & { readonly __callspecWired: true; }; export type RoutesMap = Record>; type CallspecLogo = { light?: string; dark?: string; }; type CallspecWebsite = { url: string; label?: string; }; export type CallspecUiTheme = { accent?: string; background?: string; surface?: string; fontFamily?: string; fontUrls?: string[]; }; /** Plain-text banner above the top header (no custom HTML in message). */ type CallspecUiNoticeLink = { label: string; href: string; external?: boolean; }; export type CallspecUiNotice = { title?: string; message: string; /** Optional CLI command shown in monospace after the message. */ command?: string; /** Optional inline links after the message (label + href only). */ links?: CallspecUiNoticeLink[]; }; export type CallspecNavbarLink = { label: string; href: string; external?: boolean; }; export type CallspecUiFooter = { /** Show “Powered by callspec”. Default true when omitted. */ poweredBy?: boolean; }; export type Authenticate = (token: string, req: Request) => Ctx | undefined | Promise; export type CallspecMeta = { title?: string; version?: string; intro?: string; website?: CallspecWebsite; logo?: CallspecLogo; authHint?: string; mcpInstructions?: string; theme?: CallspecUiTheme; navbarLinks?: CallspecNavbarLink[]; footer?: CallspecUiFooter; favicon?: string; /** Plain-text notice above the top header (e.g. static preview hint). */ notice?: CallspecUiNotice; /** Static SDK install hint on the docs home page (e.g. `npm i @acme/sdk`). */ sdkInstall?: string; }; export type Callspec = { meta: CallspecMeta; routes: RoutesMap; exports?: Record>; authenticate?: Authenticate; }; export {};