import type { ContractBuilder } from './builder.js'; import type { ErrorMap, InferErrorData } from './errors.js'; import type { ContractProcedure } from './procedure.js'; import type { ValidationIssue } from './schema-types.js'; type InferProc = T extends ContractBuilder ? { input: I; output: O; errors: E; meta: M; } : T extends ContractProcedure ? { input: I; output: O; errors: E; meta: M; } : never; export type InferContractInputs = { [K in keyof T as K extends '~pf' ? never : K]: InferProc extends never ? InferContractInputs : InferProc['input']; }; export type InferContractOutputs = { [K in keyof T as K extends '~pf' ? never : K]: InferProc extends never ? InferContractOutputs : InferProc['output']; }; export type InferContractErrorCodes = { [K in keyof T as K extends '~pf' ? never : K]: InferProc extends never ? InferContractErrorCodes : keyof InferProc['errors']; }; type ProtocolErrorCode = 'BAD_REQUEST' | 'VALIDATION' | 'NOT_FOUND' | 'INTERNAL' | 'METHOD_NOT_ALLOWED' | 'PAYLOAD_TOO_LARGE'; type DeclaredClientError = { [K in keyof E & string]: [InferErrorData] extends [never] ? { code: K; status: number; message: string; data?: undefined; } : { code: K; status: number; message: string; data: InferErrorData; }; }[keyof E & string]; type ProtocolErrorByCode = C extends 'VALIDATION' ? { code: 'VALIDATION'; status: number; message: string; data: { issues: ValidationIssue[]; }; } : { code: C; status: number; message: string; data?: unknown; }; type ProtocolClientError = ProtocolErrorByCode; export type ClientError = ([keyof E] extends [never] ? never : DeclaredClientError) | Exclude; export type InferContractErrors = { [K in keyof T as K extends '~pf' ? never : K]: InferProc extends never ? InferContractErrors : ClientError['errors']>; }; export interface ContractResultPromise extends Promise { readonly '~pfError'?: E; } export type CallOptions = { signal?: AbortSignal; }; export type ProcedureClient = I extends void ? (opts?: CallOptions) => ContractResultPromise> : (input: I, opts?: CallOptions) => ContractResultPromise>; export type ContractClient = { [K in keyof T as K extends '~pf' ? never : K]: InferProc extends never ? ContractClient : ProcedureClient['input'], InferProc['output'], InferProc['errors']>; }; export {}; //# sourceMappingURL=infer.d.ts.map