import type { Promisable } from './common.js'; import type { RoutePattern } from '@remix-run/route-pattern'; import type { RouteOptions } from './types/args.js'; import type { RouteSchema } from './types/schema.js'; /** Runtime key carried by response plugin markers. */ export declare const responsePluginMarker: unique symbol; /** * Compile-time response marker handled by a client/router response plugin pair. * * @remarks `TClient` is the value returned by generated client action * functions. `TRouter` is the non-`Response` value accepted from route handlers. * Plugin markers may be used directly as an action response or as success * entries in a status-keyed response map. */ export type ResponsePluginMarker = Record & { readonly [responsePluginMarker]: { readonly id: TId; readonly client: TClient; readonly router: TRouter; }; }; /** Client-side response plugin used by `createClient({ plugins })`. */ export type ClientResponsePlugin = { /** Stable response codec id matched against route response markers. */ readonly id: string; /** Decode a successful `Response` into the client action result. */ decode(response: Response, context: { marker: ResponsePluginMarker; request: ClientResponsePluginRequest; }): Promisable; }; /** Request metadata passed to client response plugins. */ export type ClientResponsePluginRequest = { schema: RouteSchema; path: RoutePattern; method: string; input?: unknown; options?: RouteOptions; }; /** Router-side response plugin used by `createRouter({ plugins })`. */ export type RouterResponsePlugin = { /** Stable response codec id matched against route response markers. */ readonly id: string; /** Encode a handler result into the HTTP response. */ encode(value: unknown, context: { marker: ResponsePluginMarker; request: Request; }): Promisable; }; /** Create a response marker for a response plugin. */ export declare function createResponsePluginMarker(id: TId): ResponsePluginMarker; /** Get the response plugin id from a plugin marker, if present. */ export declare function getResponsePluginMarkerId(value: unknown): string | undefined; /** Return true when a route response marker is handled by a response plugin. */ export declare function isResponsePluginMarker(value: unknown): value is ResponsePluginMarker; /** Create a plugin lookup map and reject duplicate plugin ids. */ export declare function createResponsePluginMap(plugins?: readonly TPlugin[], label?: string): Map;