import { RouteBuilderImpl } from './RouteBuilderImpl'; import { ApiClient } from './ApiClient'; /** * ApiClientFactory - THE piece that wires api → Proxy → filters → controller. * * For an API prototype (its @ApiPath/@Endpoint decorators) it builds a proxy whose methods * invoke the composed filter chain (via RouteBuilder.createRouteInvoker) — that proxy IS what * createApiClient() returns. {@link apiClients} reuses the SAME proxy per registered api, so the * express layer binds each method through it. There is no express dependency here, so the proxy * is the single invocation path for BOTH in-process (tests) and HTTP. * * Establishing the request scope is a PRECONDITION of calling in here, never this class's job. The * caller above the api boundary opens `RequestContext.run(...)`, publishes the inbound * `HttpRequest`, and calls `RequestContextHeaders.fillFromRequest()` to move its headers into the * context. `WebpiecesMiddleware` does all three for you; a non-webpieces transport (or a test * driving `createApiClient` directly) must do the same. This proxy only CHECKS that it happened — * manufacturing a context here would hide a missing filter and silently strip every request id. * * @provideFrameworkSingleton so WebpiecesRouter can inject it (it shares the one RouteBuilder). */ export declare class ApiClientFactory { private readonly routeBuilder; constructor(routeBuilder: RouteBuilderImpl); /** * Create an API client proxy (cast to the API interface T). The proxy's methods run the full * filter chain + controller; used by tests in-process AND driven by the express adapter. */ createApiClient(apiPrototype: abstract new (...args: any[]) => T): T; /** * Reify every registered API as an {@link ApiClient} — the contract + its proxy (the * createApiClient object). The transport reads the api's decorators to bind each endpoint to * the proxy's matching method, so no route metadata needs to leave here. */ apiClients(): ApiClient[]; /** Build the proxy record (method name → invoker) from the API prototype's decorators. */ private buildProxy; private runMethod; }