import type { Promisable } from '@ariestools/sdk';
import type { z } from 'zod/mini';
import type { RpcSchemaMap } from '../../types/index.js';
import type { RpcMiddleware } from './RpcContext.js';
/**
 * Handler record whose signatures are derived directly from a schema map.
 *
 *   params:  `z.output<params.from>` — the in-memory shape that
 *            `params.from` produces by parsing the wire request on the
 *            server. This is what the handler actually receives.
 *
 *   result:  `z.input<result.to>` — the in-memory shape the handler
 *            returns, which `result.to` then encodes for the wire. For
 *            schemas without a `.transform()`, `z.input` and `z.output`
 *            are identical; for transform pipes (e.g. `BigIntToJsonZod`
 *            mapping `bigint` → `BrandedHex`) they diverge, and the
 *            handler must produce the pre-transform `bigint`/AttoXL1.
 *
 * A schema change forces a corresponding handler update (and vice versa).
 *
 * @example
 *   const handlers: TypedRpcHandlerRecord<typeof FinalizationViewerRpcSchemas> = {
 *     finalizationViewer_head: () => viewer.head(),
 *   }
 */
export type TypedRpcHandlerRecord<TSchemas extends RpcSchemaMap> = {
    [K in keyof TSchemas]: (params: z.output<TSchemas[K]['params']['from']>) => Promisable<z.input<TSchemas[K]['result']['to']>>;
};
/**
 * Builds a scaffold middleware that dispatches by method name to the matching
 * handler. `handlers` is constrained at the type level against `TSchemas` so
 * adding/removing/retyping a method in the schema map forces a corresponding
 * handler update (and vice versa). The `schemas` runtime argument exists only
 * to drive type inference — it's not consumed at runtime; each request's
 * schema entry is read from `MiddlewareContext` after upstream validation.
 */
export declare const createTypedHandlerMiddleware: <TSchemas extends RpcSchemaMap>(_schemas: TSchemas, handlers: TypedRpcHandlerRecord<TSchemas>) => RpcMiddleware;
//# sourceMappingURL=createHandlerMiddleware.d.ts.map