import type { AuthStrategy } from '../../auth/auth/types.js'; import type { AuthEnricher, TenantResolver } from '../../auth/auth/chain.js'; import type { Handler, HttpMethod } from '../di/types.js'; import type { HealthCheck } from '../../core/lifecycle/types.js'; import type { TenantConfig } from '../../auth/tenant/types.js'; import type { Rbac } from '../../auth/rbac/types.js'; import type { OpenAPIInfo } from '../openapi/generate.js'; import type { LoggingConfig } from '../../core/logging/types.js'; import type { PipeworkLogger } from '../../core/logging/types.js'; /** Fastify request with pipework extensions — req.id (UUID), typed headers. */ export interface HttpRequest { readonly headers: Readonly>; readonly rawBody?: Buffer; } /** Fastify reply with pipework extensions. */ export interface HttpResponse { header(name: string, value: string): void; } /** CORS configuration — origin, methods, headers, credentials, maxAge. */ export interface CorsConfig { origin?: string | string[] | boolean | RegExp | ((origin: string) => boolean); methods?: string[]; allowedHeaders?: string[]; exposedHeaders?: string[]; credentials?: boolean; maxAge?: number; } /** Security header configuration — passed to @fastify/helmet. */ export interface SecurityConfig { contentSecurityPolicy?: boolean | Record; crossOriginEmbedderPolicy?: boolean; crossOriginOpenerPolicy?: boolean | { policy: string; }; crossOriginResourcePolicy?: boolean | { policy: string; }; dnsPrefetchControl?: boolean; frameguard?: boolean | { action: string; }; hidePoweredBy?: boolean; hsts?: boolean | { maxAge: number; includeSubDomains?: boolean; }; ieNoOpen?: boolean; noSniff?: boolean; referrerPolicy?: boolean | { policy: string; }; xssFilter?: boolean; } /** Rate limiting configuration — max requests, time window, key generator. */ export interface RateLimitConfig { max?: number; timeWindow?: string | number; keyGenerator?: (request: HttpRequest) => string; allowList?: string[]; ban?: number; } /** Options for server.inject() — method, url, headers, payload for testing without HTTP. */ export interface InjectOptions { method: string; url: string; headers?: Record; payload?: unknown; query?: Record; } /** Response from server.inject() — statusCode, headers, body, json() helper. */ export interface InjectResponse { statusCode: number; headers: Record; body: string; json(): unknown; } /** Configuration for http.createServer() — CORS, security headers, rate limiting, transaction timeout. */ export interface ServerConfig { port?: number; host?: string; gracefulShutdownMs?: number; trustProxy?: boolean; logger?: PipeworkLogger | false; health?: boolean; healthPath?: string; readyPath?: string; healthChecks?: HealthCheck[]; transactionPerRequest?: boolean | string[]; transactionTimeoutMs?: number; /** Maximum request body size in bytes. Forwarded to Fastify (default 1 MiB). A per-route `.route(m, p, { bodyLimit })` overrides this for that route. */ bodyLimit?: number; auth?: ServerAuthConfig; tenant?: TenantConfig | null; rbac?: Rbac; cors?: CorsConfig | false; security?: SecurityConfig | false; rateLimit?: RateLimitConfig | false; openapi?: OpenAPIInfo; openApiPath?: string; logging?: LoggingConfig; managed?: boolean; exposeErrorDetails?: boolean; } /** Server-level auth configuration — strategy, session config, optional enricher. */ export type ServerAuthConfig = { strategy: AuthStrategy; optional?: boolean; } | { strategies: AuthStrategy[]; enrichers?: AuthEnricher[]; tenantResolver?: TenantResolver; optional?: boolean; }; /** Internal route registration record — used by OpenAPI generation to discover routes. */ export interface RouteRegistration { method: HttpMethod; path: string; handler: Handler, unknown>; } /** Standard handler response shape — statusCode, headers, body. */ export interface HandlerResponse { readonly status: number; readonly body?: unknown; } /** Standard error response shape — { error: { code, message }, statusCode }. */ export interface ErrorResponse { error: { code: string; message: string; fields?: Record; details?: { name: string; message: string; }; }; } //# sourceMappingURL=types.d.ts.map