import type { ErrorDef, InferErrorData } from '@ts-pf/contract'; /** * Continues the middleware chain. `next({ context })` **merges** into the * current context (`{ ...ctx, ...added }`); `next({ input })` replaces the * input. Compare `CallInterceptor`'s `next()`, which replaces `context` * entirely. */ export type NextFn = (opts?: { /** Merged into the current context; added keys are not inferred. */ context?: Partial; /** Replaces the input for the rest of the chain. */ input?: TInput; }) => Promise; export type MiddlewareFn = (opts: { context: TCtx; input: TInput; next: NextFn; errors: ErrorFactory; path: string[]; }) => Promise; export type ErrorFactory = Record> = string extends keyof E ? { [K in keyof E]: (data?: unknown) => never; } : { [K in keyof E]: [InferErrorData>] extends [never] ? () => never : (data: InferErrorData>) => never; }; //# sourceMappingURL=middleware.d.ts.map