import { type Door } from '@fougere/core'; import type { ResponseResult } from '@fougere/http'; import type { RouteDefinition } from './routes/RouteDefinition.js'; /** What a host hands the REST door for one matched route — the body still to read, so the door reads it. */ export interface RestRequest { /** The op the route names — what a link bound to a handler answers by a method of that name. */ operation: string; headers: Headers; params: Record; query: Record; body: () => Promise; state: Record; } /** * An answer a link at REST's door may give in the op's place, declared in its return type — the status * and the headers are what the contract reads, in the vocabulary of OpenAPI's `responses`. */ export interface RestResponse = Record, Body = null> extends ResponseResult { status: Status; headers: Headers; data: Body; } /** * What stands at REST's door, the port its links stand in front of. `implements Partial`, asking * for `inner: Rest`, stands around every route of its frond; `extends Rest`, handing its * `inner` to `super`, stands around that handler's routes alone, one method per op it names — an op it * names nothing for goes straight through. Two are ordered by `ports: { Rest: [...] }`. * * Throwing before `inner.answer` refuses the request, which the door says in its own shape — before * the body is read, since the door reads it inside. * * Documented: [surfaces](https://fougere.dev/docs/infra/surfaces). */ export declare abstract class Rest { protected readonly inner?: Rest | undefined; private readonly standsAt?; constructor(inner?: Rest | undefined); /** The request, answered by the method named after its op when there is one, by what comes next otherwise. */ answer(request: RestRequest): Promise; } /** What a route's op is called with. */ export interface RestInvocation { params: Record; query: Record; input: unknown; state: Record; } /** * REST's edges for one route: the body read within the cycle, the op called, and the answer written * as HTTP — the one place REST decides a status, read off the contract and never off the op's name. * Every host runs it, whoever matched the route: a router by its own paths, a web host by `matchRoute`. */ export declare function restDoor(route: RouteDefinition): Door; //# sourceMappingURL=door.d.ts.map