import { ORPCErrorCode, ORPCError, HTTPMethod, HTTPPath, ClientContext, Client } from '@orpc/client';
export { HTTPMethod, HTTPPath, ORPCError } from '@orpc/client';
import { Promisable, IsEqual, ThrowableError } from '@orpc/shared';
export { Registry, ThrowableError } from '@orpc/shared';
import { StandardSchemaV1 } from '@standard-schema/spec';
import { OpenAPIV3_1 } from 'openapi-types';
export { OpenAPIV3_1 as OpenAPI } from 'openapi-types';

type Schema<TInput, TOutput> = StandardSchemaV1<TInput, TOutput>;
type AnySchema = Schema<any, any>;
type SchemaIssue = StandardSchemaV1.Issue;
type InferSchemaInput<T extends AnySchema> = T extends StandardSchemaV1<infer UInput, any> ? UInput : never;
type InferSchemaOutput<T extends AnySchema> = T extends StandardSchemaV1<any, infer UOutput> ? UOutput : never;
type TypeRest<TInput, TOutput> = [map: (input: TInput) => Promisable<TOutput>] | (IsEqual<TInput, TOutput> extends true ? [] : never);
/**
 * The schema for things can be trust without validation.
 * If the TInput and TOutput are different, you need pass a map function.
 *
 * @see {@link https://orpc.unnoq.com/docs/procedure#type-utility Type Utility Docs}
 */
declare function type<TInput, TOutput = TInput>(...[map]: TypeRest<TInput, TOutput>): Schema<TInput, TOutput>;

interface ValidationErrorOptions extends ErrorOptions {
    message: string;
    issues: readonly SchemaIssue[];
}
/**
 * This errors usually used for ORPCError.cause when the error is a validation error.
 *
 * @see {@link https://orpc.unnoq.com/docs/advanced/validation-errors Validation Errors Docs}
 */
declare class ValidationError extends Error {
    readonly issues: readonly SchemaIssue[];
    constructor(options: ValidationErrorOptions);
}
interface ErrorMapItem<TDataSchema extends AnySchema> {
    status?: number;
    message?: string;
    data?: TDataSchema;
}
type ErrorMap = {
    [key in ORPCErrorCode]?: ErrorMapItem<AnySchema>;
};
type MergedErrorMap<T1 extends ErrorMap, T2 extends ErrorMap> = Omit<T1, keyof T2> & T2;
declare function mergeErrorMap<T1 extends ErrorMap, T2 extends ErrorMap>(errorMap1: T1, errorMap2: T2): MergedErrorMap<T1, T2>;
type ORPCErrorFromErrorMap<TErrorMap extends ErrorMap> = {
    [K in keyof TErrorMap]: K extends string ? TErrorMap[K] extends ErrorMapItem<infer TDataSchema extends Schema<unknown, unknown>> ? ORPCError<K, InferSchemaOutput<TDataSchema>> : never : never;
}[keyof TErrorMap];
type ErrorFromErrorMap<TErrorMap extends ErrorMap> = ORPCErrorFromErrorMap<TErrorMap> | ThrowableError;

type Meta = Record<string, any>;
declare function mergeMeta<T extends Meta>(meta1: T, meta2: T): T;

type InputStructure = 'compact' | 'detailed';
type OutputStructure = 'compact' | 'detailed';
interface Route {
    /**
     * The HTTP method of the procedure.
     * This option is typically relevant when integrating with OpenAPI.
     *
     * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
     */
    method?: HTTPMethod;
    /**
     * The HTTP path of the procedure.
     * This option is typically relevant when integrating with OpenAPI.
     *
     * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
     */
    path?: HTTPPath;
    /**
     * The summary of the procedure.
     * This option is typically relevant when integrating with OpenAPI.
     *
     * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
     */
    summary?: string;
    /**
     * The description of the procedure.
     * This option is typically relevant when integrating with OpenAPI.
     *
     * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
     */
    description?: string;
    /**
     * Marks the procedure as deprecated.
     * This option is typically relevant when integrating with OpenAPI.
     *
     * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
     */
    deprecated?: boolean;
    /**
     * The tags of the procedure.
     * This option is typically relevant when integrating with OpenAPI.
     *
     * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
     */
    tags?: readonly string[];
    /**
     * The status code of the response when the procedure is successful.
     * The status code must be in the 200-399 range.
     * This option is typically relevant when integrating with OpenAPI.
     *
     * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
     * @default 200
     */
    successStatus?: number;
    /**
     * The description of the response when the procedure is successful.
     *  This option is typically relevant when integrating with OpenAPI.
     *
     * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
     * @default 'OK'
     */
    successDescription?: string;
    /**
     * Determines how the input should be structured based on `params`, `query`, `headers`, and `body`.
     *
     * @option 'compact'
     * Combines `params` and either `query` or `body` (depending on the HTTP method) into a single object.
     *
     * @option 'detailed'
     * Keeps each part of the request (`params`, `query`, `headers`, and `body`) as separate fields in the input object.
     *
     * Example:
     * ```ts
     * const input = {
     *   params: { id: 1 },
     *   query: { search: 'hello' },
     *   headers: { 'Content-Type': 'application/json' },
     *   body: { name: 'John' },
     * }
     * ```
     *
     * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
     * @default 'compact'
     */
    inputStructure?: InputStructure;
    /**
     * Determines how the response should be structured based on the output.
     *
     * @option 'compact'
     * The output data is directly returned as the response body.
     *
     * @option 'detailed'
     * Return an object with optional properties:
     * - `status`: The response status (must be in 200-399 range) if not set fallback to `successStatus`.
     * - `headers`: Custom headers to merge with the response headers (`Record<string, string | string[] | undefined>`)
     * - `body`: The response body.
     *
     * Example:
     * ```ts
     * const output = {
     *   status: 201,
     *   headers: { 'x-custom-header': 'value' },
     *   body: { message: 'Hello, world!' },
     * };
     * ```
     *
     * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
     * @default 'compact'
     */
    outputStructure?: OutputStructure;
    /**
     * Override entire auto-generated OpenAPI Operation Object Specification.
     *
     * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata Operation Metadata Docs}
     */
    spec?: OpenAPIV3_1.OperationObject;
}
declare function mergeRoute(a: Route, b: Route): Route;
declare function prefixRoute(route: Route, prefix: HTTPPath): Route;
declare function unshiftTagRoute(route: Route, tags: readonly string[]): Route;
declare function mergePrefix(a: HTTPPath | undefined, b: HTTPPath): HTTPPath;
declare function mergeTags(a: readonly string[] | undefined, b: readonly string[]): readonly string[];
interface EnhanceRouteOptions {
    prefix?: HTTPPath;
    tags?: readonly string[];
}
declare function enhanceRoute(route: Route, options: EnhanceRouteOptions): Route;

interface ContractProcedureDef<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
    meta: TMeta;
    route: Route;
    inputSchema?: TInputSchema;
    outputSchema?: TOutputSchema;
    errorMap: TErrorMap;
}
/**
 * This class represents a contract procedure.
 *
 * @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#procedure-contract Contract Procedure Docs}
 */
declare class ContractProcedure<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
    /**
     * This property holds the defined options for the contract procedure.
     */
    '~orpc': ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
    constructor(def: ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>);
}
type AnyContractProcedure = ContractProcedure<any, any, any, any>;
declare function isContractProcedure(item: unknown): item is AnyContractProcedure;

/**
 * Represents a contract router, which defines a hierarchical structure of contract procedures.
 *
 * @info A contract procedure is a contract router too.
 * @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#contract-router Contract Router Docs}
 */
type ContractRouter<TMeta extends Meta> = ContractProcedure<any, any, any, TMeta> | {
    [k: string]: ContractRouter<TMeta>;
};
type AnyContractRouter = ContractRouter<any>;
/**
 * Infer all inputs of the contract router.
 *
 * @info A contract procedure is a contract router too.
 * @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#utilities Contract Utilities Docs}
 */
type InferContractRouterInputs<T extends AnyContractRouter> = T extends ContractProcedure<infer UInputSchema, any, any, any> ? InferSchemaInput<UInputSchema> : {
    [K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterInputs<T[K]> : never;
};
/**
 * Infer all outputs of the contract router.
 *
 * @info A contract procedure is a contract router too.
 * @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#utilities Contract Utilities Docs}
 */
type InferContractRouterOutputs<T extends AnyContractRouter> = T extends ContractProcedure<any, infer UOutputSchema, any, any> ? InferSchemaOutput<UOutputSchema> : {
    [K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterOutputs<T[K]> : never;
};
/**
 * Infer all errors of the contract router.
 *
 * @info A contract procedure is a contract router too.
 * @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#utilities Contract Utilities Docs}
 */
type InferContractRouterErrorMap<T extends AnyContractRouter> = T extends ContractProcedure<any, any, infer UErrorMap, any> ? UErrorMap : {
    [K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterErrorMap<T[K]> : never;
}[keyof T];
type InferContractRouterMeta<T extends AnyContractRouter> = T extends ContractRouter<infer UMeta> ? UMeta : never;

declare function getContractRouter(router: AnyContractRouter, path: readonly string[]): AnyContractRouter | undefined;
type EnhancedContractRouter<T extends AnyContractRouter, TErrorMap extends ErrorMap> = T extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrors, infer UMeta> ? ContractProcedure<UInputSchema, UOutputSchema, MergedErrorMap<TErrorMap, UErrors>, UMeta> : {
    [K in keyof T]: T[K] extends AnyContractRouter ? EnhancedContractRouter<T[K], TErrorMap> : never;
};
interface EnhanceContractRouterOptions<TErrorMap extends ErrorMap> extends EnhanceRouteOptions {
    errorMap: TErrorMap;
}
declare function enhanceContractRouter<T extends AnyContractRouter, TErrorMap extends ErrorMap>(router: T, options: EnhanceContractRouterOptions<TErrorMap>): EnhancedContractRouter<T, TErrorMap>;
/**
 * Minify a contract router into a smaller object.
 *
 * You should export the result to a JSON file. On the client side, you can import this JSON file and use it as a contract router.
 * This reduces the size of the contract and helps prevent leaking internal details of the router to the client.
 *
 * @see {@link https://orpc.unnoq.com/docs/contract-first/router-to-contract#minify-export-the-contract-router-for-the-client Router to Contract Docs}
 */
declare function minifyContractRouter(router: AnyContractRouter): AnyContractRouter;

interface ContractProcedureBuilder<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
    /**
     * Adds type-safe custom errors to the contract.
     * The provided errors are spared-merged with any existing errors in the contract.
     *
     * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
     */
    errors<U extends ErrorMap>(errors: U): ContractProcedureBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
    /**
     * Sets or updates the metadata for the contract.
     * The provided metadata is spared-merged with any existing metadata in the contract.
     *
     * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
     */
    meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
    /**
     * Sets or updates the route definition for the contract.
     * The provided route is spared-merged with any existing route in the contract.
     * This option is typically relevant when integrating with OpenAPI.
     *
     * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
     * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
     */
    route(route: Route): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
    /**
     * Defines the input validation schema for the contract.
     *
     * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
     */
    input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>;
    /**
     * Defines the output validation schema for the contract.
     *
     * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
     */
    output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>;
}
interface ContractProcedureBuilderWithInput<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
    /**
     * Adds type-safe custom errors to the contract.
     * The provided errors are spared-merged with any existing errors in the contract.
     *
     * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
     */
    errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
    /**
     * Sets or updates the metadata for the contract.
     * The provided metadata is spared-merged with any existing metadata in the contract.
     *
     * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
     */
    meta(meta: TMeta): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
    /**
     * Sets or updates the route definition for the contract.
     * The provided route is spared-merged with any existing route in the contract.
     * This option is typically relevant when integrating with OpenAPI.
     *
     * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
     * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
     */
    route(route: Route): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
    /**
     * Defines the output validation schema for the contract.
     *
     * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
     */
    output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInputOutput<TInputSchema, U, TErrorMap, TMeta>;
}
interface ContractProcedureBuilderWithOutput<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
    /**
     * Adds type-safe custom errors to the contract.
     * The provided errors are spared-merged with any existing errors in the contract.
     *
     * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
     */
    errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
    /**
     * Sets or updates the metadata for the contract.
     * The provided metadata is spared-merged with any existing metadata in the contract.
     *
     * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
     */
    meta(meta: TMeta): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
    /**
     * Sets or updates the route definition for the contract.
     * The provided route is spared-merged with any existing route in the contract.
     * This option is typically relevant when integrating with OpenAPI.
     *
     * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
     * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
     */
    route(route: Route): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
    /**
     * Defines the input validation schema for the contract.
     *
     * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
     */
    input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInputOutput<U, TOutputSchema, TErrorMap, TMeta>;
}
interface ContractProcedureBuilderWithInputOutput<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
    /**
     * Adds type-safe custom errors to the contract.
     * The provided errors are spared-merged with any existing errors in the contract.
     *
     * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
     */
    errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
    /**
     * Sets or updates the metadata for the contract.
     * The provided metadata is spared-merged with any existing metadata in the contract.
     *
     * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
     */
    meta(meta: TMeta): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
    /**
     * Sets or updates the route definition for the contract.
     * The provided route is spared-merged with any existing route in the contract.
     * This option is typically relevant when integrating with OpenAPI.
     *
     * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
     * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
     */
    route(route: Route): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
}
interface ContractRouterBuilder<TErrorMap extends ErrorMap, TMeta extends Meta> {
    /**
     * This property holds the defined options for the contract router.
     */
    '~orpc': EnhanceContractRouterOptions<TErrorMap>;
    /**
     * Adds type-safe custom errors to the contract.
     * The provided errors are spared-merged with any existing errors in the contract.
     *
     * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
     */
    'errors'<U extends ErrorMap>(errors: U): ContractRouterBuilder<MergedErrorMap<TErrorMap, U>, TMeta>;
    /**
     * Prefixes all procedures in the contract router.
     * The provided prefix is post-appended to any existing router prefix.
     *
     * @note This option does not affect procedures that do not define a path in their route definition.
     *
     * @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
     */
    'prefix'(prefix: HTTPPath): ContractRouterBuilder<TErrorMap, TMeta>;
    /**
     * Adds tags to all procedures in the contract router.
     * This helpful when you want to group procedures together in the OpenAPI specification.
     *
     * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
     */
    'tag'(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>;
    /**
     * Applies all of the previously defined options to the specified contract router.
     *
     * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
     */
    'router'<T extends ContractRouter<TMeta>>(router: T): EnhancedContractRouter<T, TErrorMap>;
}

interface ContractBuilderDef<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>, EnhanceContractRouterOptions<TErrorMap> {
}
declare class ContractBuilder<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
    /**
     * This property holds the defined options for the contract.
     */
    '~orpc': ContractBuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
    constructor(def: ContractBuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>);
    /**
     * Sets or overrides the initial meta.
     *
     * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
     */
    $meta<U extends Meta>(initialMeta: U): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, U & Record<never, never>>;
    /**
     * Sets or overrides the initial route.
     * This option is typically relevant when integrating with OpenAPI.
     *
     * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
     * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
     */
    $route(initialRoute: Route): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
    /**
     * Adds type-safe custom errors to the contract.
     * The provided errors are spared-merged with any existing errors in the contract.
     *
     * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
     */
    errors<U extends ErrorMap>(errors: U): ContractBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
    /**
     * Sets or updates the metadata for the contract.
     * The provided metadata is spared-merged with any existing metadata in the contract.
     *
     * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
     */
    meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
    /**
     * Sets or updates the route definition for the contract.
     * The provided route is spared-merged with any existing route in the contract.
     * This option is typically relevant when integrating with OpenAPI.
     *
     * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
     * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
     */
    route(route: Route): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
    /**
     * Defines the input validation schema for the contract.
     *
     * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
     */
    input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>;
    /**
     * Defines the output validation schema for the contract.
     *
     * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
     */
    output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>;
    /**
     * Prefixes all procedures in the contract router.
     * The provided prefix is post-appended to any existing router prefix.
     *
     * @note This option does not affect procedures that do not define a path in their route definition.
     *
     * @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
     */
    prefix(prefix: HTTPPath): ContractRouterBuilder<TErrorMap, TMeta>;
    /**
     * Adds tags to all procedures in the contract router.
     * This helpful when you want to group procedures together in the OpenAPI specification.
     *
     * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
     */
    tag(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>;
    /**
     * Applies all of the previously defined options to the specified contract router.
     *
     * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
     */
    router<T extends ContractRouter<TMeta>>(router: T): EnhancedContractRouter<T, TErrorMap>;
}
declare const oc: ContractBuilder<Schema<unknown, unknown>, Schema<unknown, unknown>, Record<never, never>, Record<never, never>>;

interface ContractConfig {
    defaultMethod: HTTPMethod;
    defaultSuccessStatus: number;
    defaultSuccessDescription: string;
    defaultInputStructure: InputStructure;
    defaultOutputStructure: OutputStructure;
}
declare function fallbackContractConfig<T extends keyof ContractConfig>(key: T, value: ContractConfig[T] | undefined): ContractConfig[T];

interface EventIteratorSchemaDetails {
    yields: AnySchema;
    returns?: AnySchema;
}
/**
 * Define schema for an event iterator.
 *
 * @see {@link https://orpc.unnoq.com/docs/event-iterator#validate-event-iterator Validate Event Iterator Docs}
 */
declare function eventIterator<TYieldIn, TYieldOut, TReturnIn = unknown, TReturnOut = unknown>(yields: Schema<TYieldIn, TYieldOut>, returns?: Schema<TReturnIn, TReturnOut>): Schema<AsyncIteratorObject<TYieldIn, TReturnIn, void>, AsyncIteratorObject<TYieldOut, TReturnOut, void>>;
declare function getEventIteratorSchemaDetails(schema: AnySchema | undefined): undefined | EventIteratorSchemaDetails;

/**
 * Help RPCLink automatically send requests using the specified HTTP method in the contract.
 *
 * @see {@link https://orpc.unnoq.com/docs/client/rpc-link#custom-request-method RPCLink Custom Request Method}
 */
declare function inferRPCMethodFromContractRouter(contract: AnyContractRouter): (options: unknown, path: readonly string[]) => Exclude<HTTPMethod, 'HEAD'>;

type ContractProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;

type ContractRouterClient<TRouter extends AnyContractRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, any> ? ContractProcedureClient<TClientContext, UInputSchema, UOutputSchema, UErrorMap> : {
    [K in keyof TRouter]: TRouter[K] extends AnyContractRouter ? ContractRouterClient<TRouter[K], TClientContext> : never;
};

declare function isSchemaIssue(issue: unknown): issue is SchemaIssue;

export { ContractBuilder, ContractProcedure, ValidationError, enhanceContractRouter, enhanceRoute, eventIterator, fallbackContractConfig, getContractRouter, getEventIteratorSchemaDetails, inferRPCMethodFromContractRouter, isContractProcedure, isSchemaIssue, mergeErrorMap, mergeMeta, mergePrefix, mergeRoute, mergeTags, minifyContractRouter, oc, prefixRoute, type, unshiftTagRoute };
export type { AnyContractProcedure, AnyContractRouter, AnySchema, ContractBuilderDef, ContractConfig, ContractProcedureBuilder, ContractProcedureBuilderWithInput, ContractProcedureBuilderWithInputOutput, ContractProcedureBuilderWithOutput, ContractProcedureClient, ContractProcedureDef, ContractRouter, ContractRouterBuilder, ContractRouterClient, EnhanceContractRouterOptions, EnhanceRouteOptions, EnhancedContractRouter, ErrorFromErrorMap, ErrorMap, ErrorMapItem, EventIteratorSchemaDetails, InferContractRouterErrorMap, InferContractRouterInputs, InferContractRouterMeta, InferContractRouterOutputs, InferSchemaInput, InferSchemaOutput, InputStructure, MergedErrorMap, Meta, ORPCErrorFromErrorMap, OutputStructure, Route, Schema, SchemaIssue, TypeRest, ValidationErrorOptions };
