import { ORPCErrorJSON, ORPCError, Client, ClientContext, HTTPPath, HTTPMethod, ClientOptions, ClientPromiseResult } from '@orpc/client'; export { ClientContext, HTTPMethod, HTTPPath, ORPCError, isDefinedError, safe } from '@orpc/client'; import { AnySchema, ErrorMap, InferSchemaInput, InferSchemaOutput, ErrorFromErrorMap, Meta, MergedErrorMap, Route, Schema, ContractRouter, ContractProcedureDef, AnyContractRouter, ContractProcedure, InferContractRouterErrorMap, InferContractRouterMeta, AnyContractProcedure } from '@orpc/contract'; export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, InputStructure, MergedErrorMap, Meta, OutputStructure, Route, Schema, ValidationError, eventIterator, type, validateORPCError } from '@orpc/contract'; import { ThrowableError, IntersectPick, MaybeOptionalOptions } from '@orpc/shared'; export { AsyncIteratorClass, EventPublisher, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, IntersectPick, Registry, ThrowableError, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared'; import { C as Context, P as Procedure, e as Middleware, O as ORPCErrorConstructorMap, M as MergedInitialContext, f as MergedCurrentContext, g as MapInputMiddleware, h as CreateProcedureClientOptions, i as ProcedureClient, j as ProcedureHandler, R as Router, c as Lazy, a as AnyMiddleware, b as AnyRouter, A as AnyProcedure, L as Lazyable, I as InferRouterInitialContext } from './shared/server.qKsRrdxW.js'; export { H as InferRouterCurrentContexts, G as InferRouterInitialContexts, J as InferRouterInputs, K as InferRouterOutputs, o as LAZY_SYMBOL, p as LazyMeta, w as MiddlewareNextFn, v as MiddlewareNextFnOptions, y as MiddlewareOptions, x as MiddlewareOutputFn, t as MiddlewareResult, l as ORPCErrorConstructorMapItem, k as ORPCErrorConstructorMapItemOptions, d as ProcedureClientInterceptorOptions, D as ProcedureDef, B as ProcedureHandlerOptions, n as createORPCErrorConstructorMap, F as createProcedureClient, s as getLazyMeta, r as isLazy, E as isProcedure, q as lazy, m as mergeCurrentContext, z as middlewareOutputFn, u as unlazy } from './shared/server.qKsRrdxW.js'; import { E as EnhanceRouterOptions, a as EnhancedRouter } from './shared/server.ChyoA9XY.js'; export { A as AccessibleLazyRouter, C as ContractProcedureCallbackOptions, L as LazyTraverseContractProceduresOptions, T as TraverseContractProcedureCallbackOptions, b as TraverseContractProceduresOptions, U as UnlaziedRouter, c as createAccessibleLazyRouter, e as enhanceRouter, g as getRouter, r as resolveContractProcedures, t as traverseContractProcedures, u as unlazyRouter } from './shared/server.ChyoA9XY.js'; export { ErrorEvent, EventMeta, getEventMeta, withEventMeta } from '@orpc/standard-server'; type ActionableError = T extends ORPCError ? ORPCErrorJSON & { defined: true; } : ORPCErrorJSON & { defined: false; }; type UnactionableError = T extends { defined: true; } & ORPCErrorJSON ? ORPCError : ThrowableError; type ActionableClientRest = [input: TInput] | (undefined extends TInput ? [input?: TInput] : [input: TInput]); type ActionableClientResult> = [error: null, data: TOutput] | [error: TError, data: undefined]; interface ActionableClient> { (...rest: ActionableClientRest): Promise>; } type ProcedureActionableClient = ActionableClient, InferSchemaOutput, ActionableError>>; declare function createActionableClient(client: Client, TInput, TOutput, TError>): ActionableClient>; declare class DecoratedProcedure extends Procedure { /** * Adds type-safe custom errors. * The provided errors are spared-merged with any existing errors. * * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} */ errors(errors: U): DecoratedProcedure, TMeta>; /** * Sets or updates the metadata. * The provided metadata is spared-merged with any existing metadata. * * @see {@link https://orpc.dev/docs/metadata Metadata Docs} */ meta(meta: TMeta): DecoratedProcedure; /** * Sets or updates the route definition. * The provided route is spared-merged with any existing route. * This option is typically relevant when integrating with OpenAPI. * * @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs} * @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs} */ route(route: Route): DecoratedProcedure; /** * Uses a middleware to modify the context or improve the pipeline. * * @info Supports both normal middleware and inline middleware implementations. * @info Pass second argument to map the input. * @note The current context must be satisfy middleware dependent-context * @see {@link https://orpc.dev/docs/middleware Middleware Docs} */ use, UInContext extends Context = TCurrentContext>(middleware: Middleware, InferSchemaInput, ORPCErrorConstructorMap, TMeta>): DecoratedProcedure, MergedCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>; /** * Uses a middleware to modify the context or improve the pipeline. * * @info Supports both normal middleware and inline middleware implementations. * @info Pass second argument to map the input. * @note The current context must be satisfy middleware dependent-context * @see {@link https://orpc.dev/docs/middleware Middleware Docs} */ use, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware, ORPCErrorConstructorMap, TMeta>, mapInput: MapInputMiddleware, UInput>): DecoratedProcedure, MergedCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>; /** * Make this procedure callable (works like a function while still being a procedure). * * @see {@link https://orpc.dev/docs/client/server-side Server-side Client Docs} */ callable(...rest: MaybeOptionalOptions>): DecoratedProcedure & ProcedureClient; /** * Make this procedure compatible with server action. * * @see {@link https://orpc.dev/docs/server-action Server Action Docs} */ actionable(...rest: MaybeOptionalOptions>>): DecoratedProcedure & ProcedureActionableClient; } interface BuilderWithMiddlewares { /** * This property holds the defined options. */ '~orpc': BuilderDef; /** * Adds type-safe custom errors. * The provided errors are spared-merged with any existing errors. * * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} */ 'errors'(errors: U): BuilderWithMiddlewares, TMeta>; /** * Uses a middleware to modify the context or improve the pipeline. * * @info Supports both normal middleware and inline middleware implementations. * @note The current context must be satisfy middleware dependent-context * @see {@link https://orpc.dev/docs/middleware Middleware Docs} */ 'use', UInContext extends Context = TCurrentContext>(middleware: Middleware, TMeta>): BuilderWithMiddlewares, MergedCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>; /** * Sets or updates the metadata. * The provided metadata is spared-merged with any existing metadata. * * @see {@link https://orpc.dev/docs/metadata Metadata Docs} */ 'meta'(meta: TMeta): BuilderWithMiddlewares; /** * Sets or updates the route definition. * The provided route is spared-merged with any existing route. * This option is typically relevant when integrating with OpenAPI. * * @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs} * @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs} */ 'route'(route: Route): ProcedureBuilder; /** * Defines the input validation schema. * * @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs} */ 'input'(schema: USchema): ProcedureBuilderWithInput; /** * Defines the output validation schema. * * @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs} */ 'output'(schema: USchema): ProcedureBuilderWithOutput; /** * Defines the handler of the procedure. * * @see {@link https://orpc.dev/docs/procedure Procedure Docs} */ 'handler'(handler: ProcedureHandler): DecoratedProcedure, TErrorMap, TMeta>; /** * Prefixes all procedures in the 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.dev/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs} */ 'prefix'(prefix: HTTPPath): RouterBuilder; /** * Adds tags to all procedures in the router. * This helpful when you want to group procedures together in the OpenAPI specification. * * @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs} */ 'tag'(...tags: string[]): RouterBuilder; /** * Applies all of the previously defined options to the specified router. * * @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs} */ 'router', TCurrentContext>>(router: U): EnhancedRouter; /** * Create a lazy router * And applies all of the previously defined options to the specified router. * * @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs} */ 'lazy', TCurrentContext>>(loader: () => Promise<{ default: U; }>): EnhancedRouter, TInitialContext, TCurrentContext, TErrorMap>; } interface ProcedureBuilder { /** * This property holds the defined options. */ '~orpc': BuilderDef; /** * Adds type-safe custom errors. * The provided errors are spared-merged with any existing errors. * * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} */ 'errors'(errors: U): ProcedureBuilder, TMeta>; /** * Uses a middleware to modify the context or improve the pipeline. * * @info Supports both normal middleware and inline middleware implementations. * @note The current context must be satisfy middleware dependent-context * @see {@link https://orpc.dev/docs/middleware Middleware Docs} */ 'use', UInContext extends Context = TCurrentContext>(middleware: Middleware, TMeta>): ProcedureBuilder, MergedCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>; /** * Sets or updates the metadata. * The provided metadata is spared-merged with any existing metadata. * * @see {@link https://orpc.dev/docs/metadata Metadata Docs} */ 'meta'(meta: TMeta): ProcedureBuilder; /** * Sets or updates the route definition. * The provided route is spared-merged with any existing route. * This option is typically relevant when integrating with OpenAPI. * * @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs} * @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs} */ 'route'(route: Route): ProcedureBuilder; /** * Defines the input validation schema. * * @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs} */ 'input'(schema: USchema): ProcedureBuilderWithInput; /** * Defines the output validation schema. * * @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs} */ 'output'(schema: USchema): ProcedureBuilderWithOutput; /** * Defines the handler of the procedure. * * @see {@link https://orpc.dev/docs/procedure Procedure Docs} */ 'handler'(handler: ProcedureHandler): DecoratedProcedure, TErrorMap, TMeta>; } interface ProcedureBuilderWithInput { /** * This property holds the defined options. */ '~orpc': BuilderDef; /** * Adds type-safe custom errors. * The provided errors are spared-merged with any existing errors. * * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} */ 'errors'(errors: U): ProcedureBuilderWithInput, TMeta>; /** * Uses a middleware to modify the context or improve the pipeline. * * @info Supports both normal middleware and inline middleware implementations. * @info Pass second argument to map the input. * @note The current context must be satisfy middleware dependent-context * @see {@link https://orpc.dev/docs/middleware Middleware Docs} */ 'use', UInContext extends Context = TCurrentContext>(middleware: Middleware, unknown, ORPCErrorConstructorMap, TMeta>): ProcedureBuilderWithInput, MergedCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>; /** * Uses a middleware to modify the context or improve the pipeline. * * @info Supports both normal middleware and inline middleware implementations. * @info Pass second argument to map the input. * @note The current context must be satisfy middleware dependent-context * @see {@link https://orpc.dev/docs/middleware Middleware Docs} */ 'use', UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware, TMeta>, mapInput: MapInputMiddleware, UInput>): ProcedureBuilderWithInput, MergedCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>; /** * Sets or updates the metadata. * The provided metadata is spared-merged with any existing metadata. * * @see {@link https://orpc.dev/docs/metadata Metadata Docs} */ 'meta'(meta: TMeta): ProcedureBuilderWithInput; /** * Sets or updates the route definition. * The provided route is spared-merged with any existing route. * This option is typically relevant when integrating with OpenAPI. * * @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs} * @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs} */ 'route'(route: Route): ProcedureBuilderWithInput; /** * Defines the output validation schema. * * @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs} */ 'output'(schema: USchema): ProcedureBuilderWithInputOutput; /** * Defines the handler of the procedure. * * @see {@link https://orpc.dev/docs/procedure Procedure Docs} */ 'handler'(handler: ProcedureHandler, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure, TErrorMap, TMeta>; } interface ProcedureBuilderWithOutput { /** * This property holds the defined options. */ '~orpc': BuilderDef; /** * Adds type-safe custom errors. * The provided errors are spared-merged with any existing errors. * * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} */ 'errors'(errors: U): ProcedureBuilderWithOutput, TMeta>; /** * Uses a middleware to modify the context or improve the pipeline. * * @info Supports both normal middleware and inline middleware implementations. * @note The current context must be satisfy middleware dependent-context * @see {@link https://orpc.dev/docs/middleware Middleware Docs} */ 'use', UInContext extends Context = TCurrentContext>(middleware: Middleware, ORPCErrorConstructorMap, TMeta>): ProcedureBuilderWithOutput, MergedCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>; /** * Sets or updates the metadata. * The provided metadata is spared-merged with any existing metadata. * * @see {@link https://orpc.dev/docs/metadata Metadata Docs} */ 'meta'(meta: TMeta): ProcedureBuilderWithOutput; /** * Sets or updates the route definition. * The provided route is spared-merged with any existing route. * This option is typically relevant when integrating with OpenAPI. * * @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs} * @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs} */ 'route'(route: Route): ProcedureBuilderWithOutput; /** * Defines the input validation schema. * * @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs} */ 'input'(schema: USchema): ProcedureBuilderWithInputOutput; /** * Defines the handler of the procedure. * * @see {@link https://orpc.dev/docs/procedure Procedure Docs} */ 'handler'(handler: ProcedureHandler, TErrorMap, TMeta>): DecoratedProcedure; } interface ProcedureBuilderWithInputOutput { /** * This property holds the defined options. */ '~orpc': BuilderDef; /** * Adds type-safe custom errors. * The provided errors are spared-merged with any existing errors. * * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} */ 'errors'(errors: U): ProcedureBuilderWithInputOutput, TMeta>; /** * Uses a middleware to modify the context or improve the pipeline. * * @info Supports both normal middleware and inline middleware implementations. * @info Pass second argument to map the input. * @note The current context must be satisfy middleware dependent-context * @see {@link https://orpc.dev/docs/middleware Middleware Docs} */ 'use', UInContext extends Context = TCurrentContext>(middleware: Middleware, InferSchemaInput, ORPCErrorConstructorMap, TMeta>): ProcedureBuilderWithInputOutput, MergedCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>; /** * Uses a middleware to modify the context or improve the pipeline. * * @info Supports both normal middleware and inline middleware implementations. * @info Pass second argument to map the input. * @note The current context must be satisfy middleware dependent-context * @see {@link https://orpc.dev/docs/middleware Middleware Docs} */ 'use', UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware, ORPCErrorConstructorMap, TMeta>, mapInput: MapInputMiddleware, UInput>): ProcedureBuilderWithInputOutput, MergedCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>; /** * Sets or updates the metadata. * The provided metadata is spared-merged with any existing metadata. * * @see {@link https://orpc.dev/docs/metadata Metadata Docs} */ 'meta'(meta: TMeta): ProcedureBuilderWithInputOutput; /** * Sets or updates the route definition. * The provided route is spared-merged with any existing route. * This option is typically relevant when integrating with OpenAPI. * * @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs} * @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs} */ 'route'(route: Route): ProcedureBuilderWithInputOutput; /** * Defines the handler of the procedure. * * @see {@link https://orpc.dev/docs/procedure Procedure Docs} */ 'handler'(handler: ProcedureHandler, InferSchemaInput, TErrorMap, TMeta>): DecoratedProcedure; } interface RouterBuilder { /** * This property holds the defined options. */ '~orpc': EnhanceRouterOptions; /** * Adds type-safe custom errors. * The provided errors are spared-merged with any existing errors. * * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} */ 'errors'(errors: U): RouterBuilder, TMeta>; /** * Uses a middleware to modify the context or improve the pipeline. * * @info Supports both normal middleware and inline middleware implementations. * @note The current context must be satisfy middleware dependent-context * @see {@link https://orpc.dev/docs/middleware Middleware Docs} */ 'use', UInContext extends Context = TCurrentContext>(middleware: Middleware, TMeta>): RouterBuilder, MergedCurrentContext, TErrorMap, TMeta>; /** * Prefixes all procedures in the 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.dev/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs} */ 'prefix'(prefix: HTTPPath): RouterBuilder; /** * Adds tags to all procedures in the router. * This helpful when you want to group procedures together in the OpenAPI specification. * * @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs} */ 'tag'(...tags: string[]): RouterBuilder; /** * Applies all of the previously defined options to the specified router. * * @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs} */ 'router', TCurrentContext>>(router: U): EnhancedRouter; /** * Create a lazy router * And applies all of the previously defined options to the specified router. * * @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs} */ 'lazy', TCurrentContext>>(loader: () => Promise<{ default: U; }>): EnhancedRouter, TInitialContext, TCurrentContext, TErrorMap>; } interface DecoratedMiddleware, TMeta extends Meta> extends Middleware { /** * Change the expected input type by providing a map function. */ mapInput(map: MapInputMiddleware): DecoratedMiddleware; /** * Concatenates two middlewares. * * @info Pass second argument to map the input. * @see {@link https://orpc.dev/docs/middleware#concatenation Middleware Concatenation Docs} */ concat, UOutContext>, UInput extends TInput, UInContext extends Context = MergedCurrentContext>(middleware: Middleware, UOutContext, UInput, TOutput, TErrorConstructorMap, TMeta>): DecoratedMiddleware>, MergedCurrentContext, UInput, TOutput, TErrorConstructorMap, TMeta>; /** * Concatenates two middlewares. * * @info Pass second argument to map the input. * @see {@link https://orpc.dev/docs/middleware#concatenation Middleware Concatenation Docs} */ concat, UOutContext>, UInput extends TInput, UMappedInput, UInContext extends Context = MergedCurrentContext>(middleware: Middleware, UOutContext, UMappedInput, TOutput, TErrorConstructorMap, TMeta>, mapInput: MapInputMiddleware): DecoratedMiddleware>, MergedCurrentContext, UInput, TOutput, TErrorConstructorMap, TMeta>; } declare function decorateMiddleware, TMeta extends Meta>(middleware: Middleware): DecoratedMiddleware; interface BuilderConfig { initialInputValidationIndex?: number; initialOutputValidationIndex?: number; dedupeLeadingMiddlewares?: boolean; } interface BuilderDef extends ContractProcedureDef, EnhanceRouterOptions { middlewares: readonly AnyMiddleware[]; inputValidationIndex: number; outputValidationIndex: number; config: BuilderConfig; } declare class Builder { /** * This property holds the defined options. */ '~orpc': BuilderDef; constructor(def: BuilderDef); /** * Sets or overrides the config. * * @see {@link https://orpc.dev/docs/client/server-side#middlewares-order Middlewares Order Docs} * @see {@link https://orpc.dev/docs/best-practices/dedupe-middleware#configuration Dedupe Middleware Docs} */ $config(config: BuilderConfig): Builder; /** * Set or override the initial context. * * @see {@link https://orpc.dev/docs/context Context Docs} */ $context(): Builder, U, TInputSchema, TOutputSchema, TErrorMap, TMeta>; /** * Sets or overrides the initial meta. * * @see {@link https://orpc.dev/docs/metadata Metadata Docs} */ $meta(initialMeta: U): Builder>; /** * Sets or overrides the initial route. * This option is typically relevant when integrating with OpenAPI. * * @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs} * @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs} */ $route(initialRoute: Route): Builder; /** * Sets or overrides the initial input schema. * * @see {@link https://orpc.dev/docs/procedure#initial-configuration Initial Procedure Configuration Docs} */ $input(initialInputSchema?: U): Builder; /** * Creates a middleware. * * @see {@link https://orpc.dev/docs/middleware Middleware Docs} */ middleware, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default middleware: Middleware, TMeta>): DecoratedMiddleware; /** * Adds type-safe custom errors. * The provided errors are spared-merged with any existing errors. * * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} */ errors(errors: U): Builder, TMeta>; /** * Uses a middleware to modify the context or improve the pipeline. * * @info Supports both normal middleware and inline middleware implementations. * @note The current context must be satisfy middleware dependent-context * @see {@link https://orpc.dev/docs/middleware Middleware Docs} */ use, UInContext extends Context = TCurrentContext>(middleware: Middleware, TMeta>): BuilderWithMiddlewares, MergedCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>; /** * Sets or updates the metadata. * The provided metadata is spared-merged with any existing metadata. * * @see {@link https://orpc.dev/docs/metadata Metadata Docs} */ meta(meta: TMeta): ProcedureBuilder; /** * Sets or updates the route definition. * The provided route is spared-merged with any existing route. * This option is typically relevant when integrating with OpenAPI. * * @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs} * @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs} */ route(route: Route): ProcedureBuilder; /** * Defines the input validation schema. * * @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs} */ input(schema: USchema): ProcedureBuilderWithInput; /** * Defines the output validation schema. * * @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs} */ output(schema: USchema): ProcedureBuilderWithOutput; /** * Defines the handler of the procedure. * * @see {@link https://orpc.dev/docs/procedure Procedure Docs} */ handler(handler: ProcedureHandler): DecoratedProcedure, TErrorMap, TMeta>; /** * Prefixes all procedures in the 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.dev/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs} */ prefix(prefix: HTTPPath): RouterBuilder; /** * Adds tags to all procedures in the router. * This helpful when you want to group procedures together in the OpenAPI specification. * * @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs} */ tag(...tags: string[]): RouterBuilder; /** * Applies all of the previously defined options to the specified router. * * @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs} */ router, TCurrentContext>>(router: U): EnhancedRouter; /** * Create a lazy router * And applies all of the previously defined options to the specified router. * * @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs} */ lazy, TCurrentContext>>(loader: () => Promise<{ default: U; }>): EnhancedRouter, TInitialContext, TCurrentContext, TErrorMap>; } declare const os: Builder, Record, Schema, Schema, Record, Record>; interface Config { initialInputValidationIndex: number; initialOutputValidationIndex: number; dedupeLeadingMiddlewares: boolean; } declare function fallbackConfig(key: T, value?: Config[T]): Config[T]; /** * Like `DecoratedProcedure`, but removed all method that can change the contract. */ interface ImplementedProcedure extends Procedure { /** * Uses a middleware to modify the context or improve the pipeline. * * @info Supports both normal middleware and inline middleware implementations. * @info Pass second argument to map the input. * @note The current context must be satisfy middleware dependent-context * @see {@link https://orpc.dev/docs/middleware Middleware Docs} */ use, UInContext extends Context = TCurrentContext>(middleware: Middleware, InferSchemaInput, ORPCErrorConstructorMap, TMeta>): ImplementedProcedure, MergedCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>; /** * Uses a middleware to modify the context or improve the pipeline. * * @info Supports both normal middleware and inline middleware implementations. * @info Pass second argument to map the input. * @note The current context must be satisfy middleware dependent-context * @see {@link https://orpc.dev/docs/middleware Middleware Docs} */ use, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware, ORPCErrorConstructorMap, TMeta>, mapInput: MapInputMiddleware, UInput>): ImplementedProcedure, MergedCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>; /** * Make this procedure callable (works like a function while still being a procedure). * * @see {@link https://orpc.dev/docs/client/server-side Server-side Client Docs} */ callable(...rest: MaybeOptionalOptions>): ImplementedProcedure & ProcedureClient; /** * Make this procedure compatible with server action. * * @see {@link https://orpc.dev/docs/server-action Server Action Docs} */ actionable(...rest: MaybeOptionalOptions>>): ImplementedProcedure & ProcedureActionableClient; } /** * Like `ProcedureBuilderWithoutHandler`, but removed all method that can change the contract. */ interface ProcedureImplementer { '~orpc': BuilderDef; /** * Uses a middleware to modify the context or improve the pipeline. * * @info Supports both normal middleware and inline middleware implementations. * @info Pass second argument to map the input. * @note The current context must be satisfy middleware dependent-context * @see {@link https://orpc.dev/docs/middleware Middleware Docs} */ 'use', UInContext extends Context = TCurrentContext>(middleware: Middleware, InferSchemaInput, ORPCErrorConstructorMap, TMeta>): ProcedureImplementer, MergedCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>; /** * Uses a middleware to modify the context or improve the pipeline. * * @info Supports both normal middleware and inline middleware implementations. * @info Pass second argument to map the input. * @note The current context must be satisfy middleware dependent-context * @see {@link https://orpc.dev/docs/middleware Middleware Docs} */ 'use', UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware, ORPCErrorConstructorMap, TMeta>, mapInput: MapInputMiddleware, UInput>): ProcedureImplementer, MergedCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>; /** * Defines the handler of the procedure. * * @see {@link https://orpc.dev/docs/procedure Procedure Docs} */ 'handler'(handler: ProcedureHandler, InferSchemaInput, TErrorMap, TMeta>): ImplementedProcedure; } interface RouterImplementerWithMiddlewares { /** * Uses a middleware to modify the context or improve the pipeline. * * @info Supports both normal middleware and inline middleware implementations. * @note The current context must be satisfy middleware dependent-context * @see {@link https://orpc.dev/docs/middleware Middleware Docs} */ use, UInContext extends Context = TCurrentContext>(middleware: Middleware>, InferContractRouterMeta>): ImplementerInternalWithMiddlewares, MergedCurrentContext>; /** * Applies all of the previously defined options to the specified router. * And enforces the router match the contract. * * @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs} */ router>(router: U): EnhancedRouter>; /** * Create a lazy router * And applies all of the previously defined options to the specified router. * And enforces the router match the contract. * * @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs} */ lazy>(loader: () => Promise<{ default: U; }>): EnhancedRouter, TInitialContext, TCurrentContext, Record>; } type ImplementerInternalWithMiddlewares = TContract extends ContractProcedure ? ProcedureImplementer : RouterImplementerWithMiddlewares & { [K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternalWithMiddlewares : never; }; interface RouterImplementer { /** * Creates a middleware. * * @see {@link https://orpc.dev/docs/middleware Middleware Docs} */ middleware, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default middleware: Middleware>, InferContractRouterMeta>): DecoratedMiddleware>; /** * Uses a middleware to modify the context or improve the pipeline. * * @info Supports both normal middleware and inline middleware implementations. * @note The current context must be satisfy middleware dependent-context * @see {@link https://orpc.dev/docs/middleware Middleware Docs} */ use, UInContext extends Context = TCurrentContext>(middleware: Middleware>, InferContractRouterMeta>): ImplementerInternalWithMiddlewares, MergedCurrentContext>; /** * Applies all of the previously defined options to the specified router. * And enforces the router match the contract. * * @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs} */ router>(router: U): EnhancedRouter>; /** * Create a lazy router * And applies all of the previously defined options to the specified router. * And enforces the router match the contract. * * @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs} */ lazy>(loader: () => Promise<{ default: U; }>): EnhancedRouter, TInitialContext, TCurrentContext, Record>; } type ImplementerInternal = TContract extends ContractProcedure ? ProcedureImplementer : RouterImplementer & { [K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternal : never; }; declare function implementerInternal(contract: T, config: BuilderConfig, middlewares: AnyMiddleware[]): ImplementerInternal; type Implementer = { /** * Set or override the initial context. * * @see {@link https://orpc.dev/docs/context Context Docs} */ $context(): Implementer, U>; /** * Sets or overrides the config. * * @see {@link https://orpc.dev/docs/client/server-side#middlewares-order Middlewares Order Docs} * @see {@link https://orpc.dev/docs/best-practices/dedupe-middleware#configuration Dedupe Middleware Docs} */ $config(config: BuilderConfig): Implementer; } & ImplementerInternal; declare function implement>(contract: T, config?: BuilderConfig): Implementer; /** * Help RPCLink automatically send requests using the specified HTTP method in the router. */ declare function inferRPCMethodFromRouter(router: AnyRouter): (options: unknown, path: readonly string[]) => Promise>; declare function isStartWithMiddlewares(middlewares: readonly AnyMiddleware[], compare: readonly AnyMiddleware[]): boolean; declare function mergeMiddlewares(first: readonly AnyMiddleware[], second: readonly AnyMiddleware[], options: { dedupeLeading: boolean; }): readonly AnyMiddleware[]; declare function addMiddleware(middlewares: readonly AnyMiddleware[], addition: AnyMiddleware): AnyMiddleware[]; declare function createAssertedLazyProcedure(lazied: Lazy): Lazy; /** * Create a new procedure that ensure the contract is applied to the procedure. */ declare function createContractedProcedure(procedure: AnyProcedure, contract: AnyContractProcedure): AnyProcedure; /** * Directly call a procedure without creating a client. * * @example * ```ts * const output = await call(getting, 'input') * const output = await call(getting, 'input', { context: { db: 'postgres' } }) * ``` * */ declare function call(procedure: Lazyable>, input: InferSchemaInput, ...rest: MaybeOptionalOptions> & Omit>, 'context'>>): ClientPromiseResult, ErrorFromErrorMap>; type RouterClient> = TRouter extends Procedure ? ProcedureClient : { [K in keyof TRouter]: TRouter[K] extends Lazyable ? RouterClient : never; }; /** * Create Server-side client from a router. * * @see {@link https://orpc.dev/docs/client/server-side Server-side Client Docs} */ declare function createRouterClient(router: Lazyable, ...rest: MaybeOptionalOptions, Schema, ErrorMap, Meta, TClientContext>>): RouterClient; declare function setHiddenRouterContract>(router: T, contract: AnyContractRouter): T; declare function getHiddenRouterContract(router: Lazyable): AnyContractRouter | undefined; export { AnyMiddleware, AnyProcedure, AnyRouter, Builder, Context, CreateProcedureClientOptions, DecoratedProcedure, EnhanceRouterOptions, EnhancedRouter, InferRouterInitialContext, Lazy, Lazyable, MapInputMiddleware, MergedCurrentContext, MergedInitialContext, Middleware, ORPCErrorConstructorMap, Procedure, ProcedureClient, ProcedureHandler, Router, addMiddleware, call, createActionableClient, createAssertedLazyProcedure, createContractedProcedure, createRouterClient, decorateMiddleware, fallbackConfig, getHiddenRouterContract, implement, implementerInternal, inferRPCMethodFromRouter, isStartWithMiddlewares, mergeMiddlewares, os, setHiddenRouterContract }; export type { ActionableClient, ActionableClientRest, ActionableClientResult, ActionableError, BuilderConfig, BuilderDef, BuilderWithMiddlewares, Config, DecoratedMiddleware, ImplementedProcedure, Implementer, ImplementerInternal, ImplementerInternalWithMiddlewares, ProcedureActionableClient, ProcedureBuilder, ProcedureBuilderWithInput, ProcedureBuilderWithInputOutput, ProcedureBuilderWithOutput, ProcedureImplementer, RouterBuilder, RouterClient, RouterImplementer, RouterImplementerWithMiddlewares, UnactionableError };