/** * Live registry of `RestBinding` instances for operation-backed REST routes. * * Each entry is a REST route whose dispatch flows through the shared * `executeOperation` pipeline. The router (handleRequest) checks reserved * direct meta and discovery routes first; remaining requests then match * these operation-backed bindings. * * Statically-configured operations and bindings live in * `operations/static-registrations.ts`; this module owns the heterogeneous * binding type, the per-server factory wiring (metrics, workers, task * queues, diagnostics), and the composed live registry/binding builders. * * @module server/rest-bindings */ import type { MetricsCollector } from '../observability/metrics.ts'; import type { WorkerRegistry } from '../worker/registry.ts'; import { type OperationRegistry } from './operation-catalog.ts'; import type { RestBinding } from './rest-binding.ts'; import type { TaskQueue } from './task-queue.ts'; /** * The router stores heterogeneous bindings whose `Input`/`Output` pairs * all differ. `RestBinding` is strictly-typed at the * author boundary (so `defineOperation` + binding factories catch * mistakes), but at the router level those generics are irrelevant — * every binding produces a `Response` regardless of its output type. * * `RestBinding` is the idiomatic way to express "a binding * with SOME Input/Output pair the router doesn't care about." A stricter * `unknown, unknown` form fails under `exactOptionalPropertyTypes` * because `shapeSuccess: (Output) => Response` cannot be safely widened * to `(unknown) => Response` (function parameters are contravariant). */ export type UnknownRestBinding = RestBinding; /** * Static REST bindings for all operations that do not need per-server * configuration. The `weft.system.metrics` binding is excluded because its * factory receives the per-server metrics collector. * Use `createLiveRestBindings()` to get the full set for a given server. */ export declare const REST_BINDINGS: ReadonlyArray; /** * Build the full REST binding set for a server instance. Appends the * `weft.system.metrics`, `weft.workers.list`, and `weft.task.queues.list` * bindings. Each takes no per-server data on the binding side; the * runtime dependencies (metrics collector, worker registry, task queue) * are wired into the operations through {@link createLiveOperationRegistry}. */ export declare function createLiveRestBindings(): ReadonlyArray; /** * Create the live operation registry for a server instance. * * Live `serve()` passes `workerRegistry` and `taskQueue` so the * infrastructure-observability operations (`weft.workers.list`, * `weft.task.queues.list`) bind their `invoke` to real server state. * * Callers that build the registry for **discovery only** * (`openapi.ts`, `asyncapi.ts`) omit both. The operations are still * registered with full metadata so the catalog matches the live wire * surface, but their `invoke` paths throw if reached — no discovery-only * registry is ever used to serve real requests. */ type LiveOperationRegistryOptions = { metricsCollector?: MetricsCollector; workerRegistry?: WorkerRegistry; taskQueue?: TaskQueue; clock?: () => number; }; export declare function createLiveOperationRegistry(options?: LiveOperationRegistryOptions): OperationRegistry; export {};