Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement β†’
Sign In

@orpc/contract

Package Overview
Dependencies
Maintainers
1
Versions
1076
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@orpc/contract - npm Package Compare versions

Comparing version
0.0.0-next.68378b4
to
0.0.0-next.683f2ee
+43
dist/plugins/index.d.mts
import { ClientContext } from '@orpc/client';
import { StandardLinkPlugin, StandardLinkOptions } from '@orpc/client/standard';
import { A as AnyContractRouter } from '../shared/contract.TuRtB1Ca.mjs';
import '@orpc/shared';
import '@standard-schema/spec';
import 'openapi-types';
declare class RequestValidationPluginError extends Error {
}
/**
* A link plugin that validates client requests against your contract schema,
* ensuring that data sent to your server matches the expected types defined in your contract.
*
* @throws {ORPCError} with code `BAD_REQUEST` (same as server side) if input doesn't match the expected schema
* @see {@link https://orpc.dev/docs/plugins/request-validation Request Validation Plugin Docs}
*/
declare class RequestValidationPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
private readonly contract;
constructor(contract: AnyContractRouter);
init(options: StandardLinkOptions<T>): void;
}
/**
* A link plugin that validates server responses against your contract schema,
* ensuring that data returned from your server matches the expected types defined in your contract.
*
* - Throws `ValidationError` if output doesn't match the expected schema
* - Converts mismatched defined errors to normal `ORPCError` instances
*
* @see {@link https://orpc.dev/docs/plugins/response-validation Response Validation Plugin Docs}
*/
declare class ResponseValidationPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
private readonly contract;
constructor(contract: AnyContractRouter);
/**
* run before (validate after) retry plugin, because validation failed can't be retried
* run before (validate after) durable iterator plugin, because we expect durable iterator to validation (if user use it)
*/
order: number;
init(options: StandardLinkOptions<T>): void;
}
export { RequestValidationPlugin, RequestValidationPluginError, ResponseValidationPlugin };
import { ClientContext } from '@orpc/client';
import { StandardLinkPlugin, StandardLinkOptions } from '@orpc/client/standard';
import { A as AnyContractRouter } from '../shared/contract.TuRtB1Ca.js';
import '@orpc/shared';
import '@standard-schema/spec';
import 'openapi-types';
declare class RequestValidationPluginError extends Error {
}
/**
* A link plugin that validates client requests against your contract schema,
* ensuring that data sent to your server matches the expected types defined in your contract.
*
* @throws {ORPCError} with code `BAD_REQUEST` (same as server side) if input doesn't match the expected schema
* @see {@link https://orpc.dev/docs/plugins/request-validation Request Validation Plugin Docs}
*/
declare class RequestValidationPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
private readonly contract;
constructor(contract: AnyContractRouter);
init(options: StandardLinkOptions<T>): void;
}
/**
* A link plugin that validates server responses against your contract schema,
* ensuring that data returned from your server matches the expected types defined in your contract.
*
* - Throws `ValidationError` if output doesn't match the expected schema
* - Converts mismatched defined errors to normal `ORPCError` instances
*
* @see {@link https://orpc.dev/docs/plugins/response-validation Response Validation Plugin Docs}
*/
declare class ResponseValidationPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
private readonly contract;
constructor(contract: AnyContractRouter);
/**
* run before (validate after) retry plugin, because validation failed can't be retried
* run before (validate after) durable iterator plugin, because we expect durable iterator to validation (if user use it)
*/
order: number;
init(options: StandardLinkOptions<T>): void;
}
export { RequestValidationPlugin, RequestValidationPluginError, ResponseValidationPlugin };
import { ORPCError } from '@orpc/client';
import { get } from '@orpc/shared';
import { i as isContractProcedure, V as ValidationError, v as validateORPCError } from '../shared/contract.D_dZrO__.mjs';
class RequestValidationPluginError extends Error {
}
class RequestValidationPlugin {
constructor(contract) {
this.contract = contract;
}
init(options) {
options.interceptors ??= [];
options.interceptors.push(async ({ next, path, input }) => {
const procedure = get(this.contract, path);
if (!isContractProcedure(procedure)) {
throw new RequestValidationPluginError(`No valid procedure found at path "${path.join(".")}", this may happen when the contract router is not properly configured.`);
}
const inputSchema = procedure["~orpc"].inputSchema;
if (inputSchema) {
const result = await inputSchema["~standard"].validate(input);
if (result.issues) {
throw new ORPCError("BAD_REQUEST", {
message: "Input validation failed",
data: {
issues: result.issues
},
cause: new ValidationError({
message: "Input validation failed",
issues: result.issues,
data: input
})
});
}
}
return await next();
});
}
}
class ResponseValidationPlugin {
constructor(contract) {
this.contract = contract;
}
/**
* run before (validate after) retry plugin, because validation failed can't be retried
* run before (validate after) durable iterator plugin, because we expect durable iterator to validation (if user use it)
*/
order = 12e5;
init(options) {
options.interceptors ??= [];
options.interceptors.push(async ({ next, path }) => {
const procedure = get(this.contract, path);
if (!isContractProcedure(procedure)) {
throw new Error(`[ResponseValidationPlugin] no valid procedure found at path "${path.join(".")}", this may happen when the contract router is not properly configured.`);
}
try {
const output = await next();
const outputSchema = procedure["~orpc"].outputSchema;
if (!outputSchema) {
return output;
}
const result = await outputSchema["~standard"].validate(output);
if (result.issues) {
throw new ValidationError({
message: "Server response output does not match expected schema",
issues: result.issues,
data: output
});
}
return result.value;
} catch (e) {
if (e instanceof ORPCError) {
throw await validateORPCError(procedure["~orpc"].errorMap, e);
}
throw e;
}
});
}
}
export { RequestValidationPlugin, RequestValidationPluginError, ResponseValidationPlugin };
import { fallbackORPCErrorStatus, ORPCError, isORPCErrorStatus } from '@orpc/client';
class ValidationError extends Error {
issues;
data;
constructor(options) {
super(options.message, options);
this.issues = options.issues;
this.data = options.data;
}
}
function mergeErrorMap(errorMap1, errorMap2) {
return { ...errorMap1, ...errorMap2 };
}
async function validateORPCError(map, error) {
const { code, status, message, data, cause, defined } = error;
const config = map?.[error.code];
if (!config || fallbackORPCErrorStatus(error.code, config.status) !== error.status) {
return defined ? new ORPCError(code, { defined: false, status, message, data, cause }) : error;
}
if (!config.data) {
return defined ? error : new ORPCError(code, { defined: true, status, message, data, cause });
}
const validated = await config.data["~standard"].validate(error.data);
if (validated.issues) {
return defined ? new ORPCError(code, { defined: false, status, message, data, cause }) : error;
}
return new ORPCError(code, { defined: true, status, message, data: validated.value, cause });
}
class ContractProcedure {
/**
* This property holds the defined options for the contract procedure.
*/
"~orpc";
constructor(def) {
if (def.route?.successStatus && isORPCErrorStatus(def.route.successStatus)) {
throw new Error("[ContractProcedure] Invalid successStatus.");
}
if (Object.values(def.errorMap).some((val) => val && val.status && !isORPCErrorStatus(val.status))) {
throw new Error("[ContractProcedure] Invalid error status code.");
}
this["~orpc"] = def;
}
}
function isContractProcedure(item) {
if (item instanceof ContractProcedure) {
return true;
}
return (typeof item === "object" || typeof item === "function") && item !== null && "~orpc" in item && typeof item["~orpc"] === "object" && item["~orpc"] !== null && "errorMap" in item["~orpc"] && "route" in item["~orpc"] && "meta" in item["~orpc"];
}
export { ContractProcedure as C, ValidationError as V, isContractProcedure as i, mergeErrorMap as m, validateORPCError as v };
import { ORPCErrorCode, ORPCError, HTTPMethod, HTTPPath } from '@orpc/client';
import { Promisable, IsEqual, ThrowableError } from '@orpc/shared';
import { StandardSchemaV1 } from '@standard-schema/spec';
import { OpenAPIV3_1 } 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.dev/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[];
/**
* @todo require this field in v2
*/
data?: unknown;
}
/**
* This errors usually used for ORPCError.cause when the error is a validation error.
*
* @see {@link https://orpc.dev/docs/advanced/validation-errors Validation Errors Docs}
*/
declare class ValidationError extends Error {
readonly issues: readonly SchemaIssue[];
readonly data: unknown;
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;
declare function validateORPCError(map: ErrorMap, error: ORPCError<any, any>): Promise<ORPCError<string, unknown>>;
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.dev/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.dev/docs/openapi/routing OpenAPI Routing Docs}
*/
path?: HTTPPath;
/**
* The operation ID of the endpoint.
* This option is typically relevant when integrating with OpenAPI.
*
* @default Concatenation of router segments
*/
operationId?: string;
/**
* The summary of the procedure.
* This option is typically relevant when integrating with OpenAPI.
*
* @see {@link https://orpc.dev/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.dev/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.dev/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.dev/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.dev/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.dev/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.dev/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.dev/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.dev/docs/openapi/openapi-specification#operation-metadata Operation Metadata Docs}
*/
spec?: OpenAPIV3_1.OperationObject | ((current: OpenAPIV3_1.OperationObject) => 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.dev/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.dev/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.dev/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.dev/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.dev/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;
export { ContractProcedure as C, type as D, ValidationError as j, mergeErrorMap as m, mergeMeta as n, isContractProcedure as p, mergeRoute as q, prefixRoute as r, mergePrefix as s, mergeTags as t, unshiftTagRoute as u, validateORPCError as v, enhanceRoute as w };
export type { AnyContractRouter as A, InferContractRouterMeta as B, ErrorMap as E, InputStructure as I, MergedErrorMap as M, OutputStructure as O, Route as R, Schema as S, TypeRest as T, ValidationErrorOptions as V, EnhanceRouteOptions as a, AnySchema as b, Meta as c, ContractRouter as d, ContractProcedureDef as e, InferSchemaInput as f, InferSchemaOutput as g, ErrorFromErrorMap as h, SchemaIssue as i, ErrorMapItem as k, ORPCErrorFromErrorMap as l, AnyContractProcedure as o, InferContractRouterInputs as x, InferContractRouterOutputs as y, InferContractRouterErrorMap as z };
import { ORPCErrorCode, ORPCError, HTTPMethod, HTTPPath } from '@orpc/client';
import { Promisable, IsEqual, ThrowableError } from '@orpc/shared';
import { StandardSchemaV1 } from '@standard-schema/spec';
import { OpenAPIV3_1 } 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.dev/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[];
/**
* @todo require this field in v2
*/
data?: unknown;
}
/**
* This errors usually used for ORPCError.cause when the error is a validation error.
*
* @see {@link https://orpc.dev/docs/advanced/validation-errors Validation Errors Docs}
*/
declare class ValidationError extends Error {
readonly issues: readonly SchemaIssue[];
readonly data: unknown;
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;
declare function validateORPCError(map: ErrorMap, error: ORPCError<any, any>): Promise<ORPCError<string, unknown>>;
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.dev/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.dev/docs/openapi/routing OpenAPI Routing Docs}
*/
path?: HTTPPath;
/**
* The operation ID of the endpoint.
* This option is typically relevant when integrating with OpenAPI.
*
* @default Concatenation of router segments
*/
operationId?: string;
/**
* The summary of the procedure.
* This option is typically relevant when integrating with OpenAPI.
*
* @see {@link https://orpc.dev/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.dev/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.dev/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.dev/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.dev/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.dev/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.dev/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.dev/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.dev/docs/openapi/openapi-specification#operation-metadata Operation Metadata Docs}
*/
spec?: OpenAPIV3_1.OperationObject | ((current: OpenAPIV3_1.OperationObject) => 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.dev/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.dev/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.dev/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.dev/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.dev/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;
export { ContractProcedure as C, type as D, ValidationError as j, mergeErrorMap as m, mergeMeta as n, isContractProcedure as p, mergeRoute as q, prefixRoute as r, mergePrefix as s, mergeTags as t, unshiftTagRoute as u, validateORPCError as v, enhanceRoute as w };
export type { AnyContractRouter as A, InferContractRouterMeta as B, ErrorMap as E, InputStructure as I, MergedErrorMap as M, OutputStructure as O, Route as R, Schema as S, TypeRest as T, ValidationErrorOptions as V, EnhanceRouteOptions as a, AnySchema as b, Meta as c, ContractRouter as d, ContractProcedureDef as e, InferSchemaInput as f, InferSchemaOutput as g, ErrorFromErrorMap as h, SchemaIssue as i, ErrorMapItem as k, ORPCErrorFromErrorMap as l, AnyContractProcedure as o, InferContractRouterInputs as x, InferContractRouterOutputs as y, InferContractRouterErrorMap as z };
+263
-168

@@ -1,211 +0,290 @@

import { ORPCErrorCode, ORPCError, ClientContext, Client } from '@orpc/client';
export { ORPCError } from '@orpc/client';
import { StandardSchemaV1 } from '@standard-schema/spec';
import { Promisable, IsEqual } from '@orpc/shared';
import { HTTPPath, HTTPMethod, ClientContext, Client } from '@orpc/client';
export { HTTPMethod, HTTPPath, ORPCError } from '@orpc/client';
import { E as ErrorMap, a as EnhanceRouteOptions, A as AnyContractRouter, C as ContractProcedure, M as MergedErrorMap, b as AnySchema, c as Meta, R as Route, d as ContractRouter, e as ContractProcedureDef, S as Schema, I as InputStructure, O as OutputStructure, f as InferSchemaInput, g as InferSchemaOutput, h as ErrorFromErrorMap, i as SchemaIssue } from './shared/contract.TuRtB1Ca.mjs';
export { o as AnyContractProcedure, k as ErrorMapItem, z as InferContractRouterErrorMap, x as InferContractRouterInputs, B as InferContractRouterMeta, y as InferContractRouterOutputs, l as ORPCErrorFromErrorMap, T as TypeRest, j as ValidationError, V as ValidationErrorOptions, w as enhanceRoute, p as isContractProcedure, m as mergeErrorMap, n as mergeMeta, s as mergePrefix, q as mergeRoute, t as mergeTags, r as prefixRoute, D as type, u as unshiftTagRoute, v as validateORPCError } from './shared/contract.TuRtB1Ca.mjs';
import { AsyncIteratorClass } from '@orpc/shared';
export { AsyncIteratorClass, Registry, ThrowableError } from '@orpc/shared';
export { OpenAPIV3_1 as OpenAPI } from 'openapi-types';
import '@standard-schema/spec';
type Schema = StandardSchemaV1 | undefined;
type SchemaInput<TSchema extends Schema, TFallback = unknown> = TSchema extends undefined ? TFallback : TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferInput<TSchema> : TFallback;
type SchemaOutput<TSchema extends Schema, TFallback = unknown> = TSchema extends undefined ? TFallback : TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TSchema> : TFallback;
type TypeRest<TInput, TOutput> = [map: (input: TInput) => Promisable<TOutput>] | (IsEqual<TInput, TOutput> extends true ? [] : never);
declare function type<TInput, TOutput = TInput>(...[map]: TypeRest<TInput, TOutput>): StandardSchemaV1<TInput, TOutput>;
interface ValidationErrorOptions extends ErrorOptions {
message: string;
issues: readonly StandardSchemaV1.Issue[];
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 class ValidationError extends Error {
readonly issues: readonly StandardSchemaV1.Issue[];
constructor(options: ValidationErrorOptions);
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.dev/docs/contract-first/router-to-contract#minify-export-the-contract-router-for-the-client Router to Contract Docs}
*/
declare function minifyContractRouter(router: AnyContractRouter): AnyContractRouter;
type PopulatedContractRouterPaths<T extends AnyContractRouter> = T extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrors, infer UMeta> ? ContractProcedure<UInputSchema, UOutputSchema, UErrors, UMeta> : {
[K in keyof T]: T[K] extends AnyContractRouter ? PopulatedContractRouterPaths<T[K]> : never;
};
interface PopulateContractRouterPathsOptions {
path?: readonly string[];
}
interface ErrorMapItem<TDataSchema extends Schema> {
status?: number;
message?: string;
description?: string;
data?: TDataSchema;
}
type ErrorMap = {
[key in ORPCErrorCode]?: ErrorMapItem<Schema>;
};
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> ? ORPCError<K, SchemaOutput<TDataSchema>> : never : never;
}[keyof TErrorMap];
type ErrorFromErrorMap<TErrorMap extends ErrorMap> = Error | ORPCErrorFromErrorMap<TErrorMap>;
/**
* Automatically populates missing route paths using the router's nested keys.
*
* Constructs paths by joining router keys with `/`.
* Useful for NestJS integration that require explicit route paths.
*
* @see {@link https://orpc.dev/docs/openapi/integrations/implement-contract-in-nest#define-your-contract NestJS Implement Contract Docs}
*/
declare function populateContractRouterPaths<T extends AnyContractRouter>(router: T, options?: PopulateContractRouterPathsOptions): PopulatedContractRouterPaths<T>;
type Meta = Record<string, any>;
declare function mergeMeta<T extends Meta>(meta1: T, meta2: T): T;
type HTTPPath = `/${string}`;
type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
type InputStructure = 'compact' | 'detailed';
type OutputStructure = 'compact' | 'detailed';
interface Route {
method?: HTTPMethod;
path?: HTTPPath;
summary?: string;
description?: string;
deprecated?: boolean;
tags?: readonly string[];
interface ContractProcedureBuilder<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
/**
* The status code of the response when the procedure is successful.
* Adds type-safe custom errors to the contract.
* The provided errors are spared-merged with any existing errors in the contract.
*
* @default 200
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
*/
successStatus?: number;
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
/**
* The description of the response when the procedure is successful.
* Sets or updates the metadata for the contract.
* The provided metadata is spared-merged with any existing metadata in the contract.
*
* @default 'OK'
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
*/
successDescription?: string;
meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
/**
* Determines how the input should be structured based on `params`, `query`, `headers`, and `body`.
* 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.
*
* @option 'compact'
* Combines `params` and either `query` or `body` (depending on the HTTP method) into a single object.
* @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): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
/**
* Defines the input validation schema for the contract.
*
* @option 'detailed'
* Keeps each part of the request (`params`, `query`, `headers`, and `body`) as separate fields in the input object.
* @see {@link https://orpc.dev/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.
*
* Example:
* ```ts
* const input = {
* params: { id: 1 },
* query: { search: 'hello' },
* headers: { 'Content-Type': 'application/json' },
* body: { name: 'John' },
* }
* ```
* @see {@link https://orpc.dev/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.
*
* @default 'compact'
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
*/
inputStructure?: InputStructure;
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
/**
* Determines how the response should be structured based on the output.
* Sets or updates the metadata for the contract.
* The provided metadata is spared-merged with any existing metadata in the contract.
*
* @option 'compact'
* Includes only the body data, encoded directly in the response.
* @see {@link https://orpc.dev/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.
*
* @option 'detailed'
* Separates the output into `headers` and `body` fields.
* - `headers`: Custom headers to merge with the response headers.
* - `body`: The response data.
* @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): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
/**
* Defines the output validation schema for the contract.
*
* Example:
* ```ts
* const output = {
* headers: { 'x-custom-header': 'value' },
* body: { message: 'Hello, world!' },
* };
* ```
* @see {@link https://orpc.dev/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.
*
* @default 'compact'
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
*/
outputStructure?: OutputStructure;
}
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 AdaptRouteOptions {
prefix?: HTTPPath;
tags?: readonly string[];
}
declare function adaptRoute(route: Route, options: AdaptRouteOptions): Route;
interface ContractProcedureDef<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
meta: TMeta;
route: Route;
inputSchema: TInputSchema;
outputSchema: TOutputSchema;
errorMap: TErrorMap;
}
declare class ContractProcedure<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
'~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;
type ContractRouter<TMeta extends Meta> = ContractProcedure<any, any, any, TMeta> | {
[k: string]: ContractRouter<TMeta>;
};
type AnyContractRouter = ContractRouter<any>;
type AdaptedContractRouter<TContract extends AnyContractRouter, TErrorMap extends ErrorMap> = {
[K in keyof TContract]: TContract[K] extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrors, infer UMeta> ? ContractProcedure<UInputSchema, UOutputSchema, MergedErrorMap<TErrorMap, UErrors>, UMeta> : TContract[K] extends AnyContractRouter ? AdaptedContractRouter<TContract[K], TErrorMap> : never;
};
interface AdaptContractRouterOptions<TErrorMap extends ErrorMap> {
errorMap: TErrorMap;
prefix?: HTTPPath;
tags?: readonly string[];
}
declare function adaptContractRouter<TRouter extends ContractRouter<any>, TErrorMap extends ErrorMap>(contract: TRouter, options: AdaptContractRouterOptions<TErrorMap>): AdaptedContractRouter<TRouter, TErrorMap>;
type InferContractRouterInputs<T extends AnyContractRouter> = T extends ContractProcedure<infer UInputSchema, any, any, any> ? SchemaInput<UInputSchema> : {
[K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterInputs<T[K]> : never;
};
type InferContractRouterOutputs<T extends AnyContractRouter> = T extends ContractProcedure<any, infer UOutputSchema, any, any> ? SchemaOutput<UOutputSchema> : {
[K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterOutputs<T[K]> : never;
};
type ContractRouterToErrorMap<T extends AnyContractRouter> = T extends ContractProcedure<any, any, infer UErrorMap, any> ? UErrorMap : {
[K in keyof T]: T[K] extends AnyContractRouter ? ContractRouterToErrorMap<T[K]> : never;
}[keyof T];
type ContractRouterToMeta<T extends AnyContractRouter> = T extends ContractRouter<infer UMeta> ? UMeta : never;
interface ContractProcedureBuilder<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
route(route: Route): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
input<U extends Schema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>;
output<U extends Schema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>;
}
interface ContractProcedureBuilderWithInput<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
meta(meta: TMeta): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
route(route: Route): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
output<U extends Schema>(schema: U): ContractProcedureBuilderWithInputOutput<TInputSchema, U, TErrorMap, TMeta>;
}
interface ContractProcedureBuilderWithOutput<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
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.dev/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.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): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
input<U extends Schema>(schema: U): ContractProcedureBuilderWithInputOutput<U, TOutputSchema, TErrorMap, TMeta>;
/**
* Defines the input validation schema for the contract.
*
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs}
*/
input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInputOutput<U, TOutputSchema, TErrorMap, TMeta>;
}
interface ContractProcedureBuilderWithInputOutput<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, 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.dev/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.dev/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.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): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
}
interface ContractRouterBuilder<TErrorMap extends ErrorMap, TMeta extends Meta> {
'~orpc': AdaptContractRouterOptions<TErrorMap>;
/**
* 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.dev/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.dev/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.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
*/
'tag'(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>;
'router'<T extends ContractRouter<TMeta>>(router: T): AdaptedContractRouter<T, TErrorMap>;
/**
* Applies all of the previously defined options to the specified contract router.
*
* @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs}
*/
'router'<T extends ContractRouter<TMeta>>(router: T): EnhancedContractRouter<T, TErrorMap>;
}
interface ContractBuilderDef<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>, AdaptContractRouterOptions<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 Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
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>);
/**
* Reset initial meta
* Sets or overrides the initial meta.
*
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
*/
$meta<U extends Meta>(initialMeta: U): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, U>;
$meta<U extends Meta>(initialMeta: U): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, U & Record<never, never>>;
/**
* Reset initial route
* 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): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
/**
* Sets or overrides the initial input schema.
*
* @see {@link https://orpc.dev/docs/procedure#initial-configuration Initial Procedure Configuration Docs}
*/
$input<U extends AnySchema>(initialInputSchema?: U): ContractBuilder<U, 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.dev/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.dev/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.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): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
input<U extends Schema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>;
output<U extends Schema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>;
/**
* Defines the input validation schema for the contract.
*
* @see {@link https://orpc.dev/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.dev/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.dev/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.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
*/
tag(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>;
router<T extends ContractRouter<TMeta>>(router: T): AdaptedContractRouter<T, TErrorMap>;
/**
* Applies all of the previously defined options to the specified contract router.
*
* @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs}
*/
router<T extends ContractRouter<TMeta>>(router: T): EnhancedContractRouter<T, TErrorMap>;
}
declare const oc: ContractBuilder<undefined, undefined, {}, {}>;
declare const oc: ContractBuilder<Schema<unknown, unknown>, Schema<unknown, unknown>, Record<never, never>, Record<never, never>>;

@@ -217,14 +296,27 @@ interface ContractConfig {

defaultInputStructure: InputStructure;
defaultOutputStructure: InputStructure;
defaultOutputStructure: OutputStructure;
}
declare function fallbackContractConfig<T extends keyof ContractConfig>(key: T, value: ContractConfig[T] | undefined): ContractConfig[T];
declare function eventIterator<TYieldIn, TYieldOut, TReturnIn = unknown, TReturnOut = unknown>(yields: StandardSchemaV1<TYieldIn, TYieldOut>, returns?: StandardSchemaV1<TReturnIn, TReturnOut>): StandardSchemaV1<AsyncIteratorObject<TYieldIn, TReturnIn, void>, AsyncIteratorObject<TYieldOut, TReturnOut, void>>;
declare function getEventIteratorSchemaDetails(schema: Schema): undefined | {
yields: Schema;
returns: Schema;
};
interface EventIteratorSchemaDetails {
yields: AnySchema;
returns?: AnySchema;
}
/**
* Define schema for an event iterator.
*
* @see {@link https://orpc.dev/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>, AsyncIteratorClass<TYieldOut, TReturnOut, void>>;
declare function getEventIteratorSchemaDetails(schema: AnySchema | undefined): undefined | EventIteratorSchemaDetails;
type ContractProcedureClient<TClientContext extends ClientContext, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap> = Client<TClientContext, SchemaInput<TInputSchema>, SchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
/**
* Help RPCLink automatically send requests using the specified HTTP method in the contract.
*
* @see {@link https://orpc.dev/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> : {

@@ -234,2 +326,5 @@ [K in keyof TRouter]: TRouter[K] extends AnyContractRouter ? ContractRouterClient<TRouter[K], TClientContext> : never;

export { type AdaptContractRouterOptions, type AdaptRouteOptions, type AdaptedContractRouter, type AnyContractProcedure, type AnyContractRouter, ContractBuilder, type ContractBuilderDef, type ContractConfig, ContractProcedure, type ContractProcedureBuilder, type ContractProcedureBuilderWithInput, type ContractProcedureBuilderWithInputOutput, type ContractProcedureBuilderWithOutput, type ContractProcedureClient, type ContractProcedureDef, type ContractRouter, type ContractRouterBuilder, type ContractRouterClient, type ContractRouterToErrorMap, type ContractRouterToMeta, type ErrorFromErrorMap, type ErrorMap, type ErrorMapItem, type HTTPMethod, type HTTPPath, type InferContractRouterInputs, type InferContractRouterOutputs, type InputStructure, type MergedErrorMap, type Meta, type ORPCErrorFromErrorMap, type OutputStructure, type Route, type Schema, type SchemaInput, type SchemaOutput, type TypeRest, ValidationError, type ValidationErrorOptions, adaptContractRouter, adaptRoute, eventIterator, fallbackContractConfig, getEventIteratorSchemaDetails, isContractProcedure, mergeErrorMap, mergeMeta, mergePrefix, mergeRoute, mergeTags, oc, prefixRoute, type, unshiftTagRoute };
declare function isSchemaIssue(issue: unknown): issue is SchemaIssue;
export { AnyContractRouter, AnySchema, ContractBuilder, ContractProcedure, ContractProcedureDef, ContractRouter, EnhanceRouteOptions, ErrorFromErrorMap, ErrorMap, InferSchemaInput, InferSchemaOutput, InputStructure, MergedErrorMap, Meta, OutputStructure, Route, Schema, SchemaIssue, enhanceContractRouter, eventIterator, fallbackContractConfig, getContractRouter, getEventIteratorSchemaDetails, inferRPCMethodFromContractRouter, isSchemaIssue, minifyContractRouter, oc, populateContractRouterPaths };
export type { ContractBuilderDef, ContractConfig, ContractProcedureBuilder, ContractProcedureBuilderWithInput, ContractProcedureBuilderWithInputOutput, ContractProcedureBuilderWithOutput, ContractProcedureClient, ContractRouterBuilder, ContractRouterClient, EnhanceContractRouterOptions, EnhancedContractRouter, EventIteratorSchemaDetails, PopulateContractRouterPathsOptions, PopulatedContractRouterPaths };

@@ -1,211 +0,290 @@

import { ORPCErrorCode, ORPCError, ClientContext, Client } from '@orpc/client';
export { ORPCError } from '@orpc/client';
import { StandardSchemaV1 } from '@standard-schema/spec';
import { Promisable, IsEqual } from '@orpc/shared';
import { HTTPPath, HTTPMethod, ClientContext, Client } from '@orpc/client';
export { HTTPMethod, HTTPPath, ORPCError } from '@orpc/client';
import { E as ErrorMap, a as EnhanceRouteOptions, A as AnyContractRouter, C as ContractProcedure, M as MergedErrorMap, b as AnySchema, c as Meta, R as Route, d as ContractRouter, e as ContractProcedureDef, S as Schema, I as InputStructure, O as OutputStructure, f as InferSchemaInput, g as InferSchemaOutput, h as ErrorFromErrorMap, i as SchemaIssue } from './shared/contract.TuRtB1Ca.js';
export { o as AnyContractProcedure, k as ErrorMapItem, z as InferContractRouterErrorMap, x as InferContractRouterInputs, B as InferContractRouterMeta, y as InferContractRouterOutputs, l as ORPCErrorFromErrorMap, T as TypeRest, j as ValidationError, V as ValidationErrorOptions, w as enhanceRoute, p as isContractProcedure, m as mergeErrorMap, n as mergeMeta, s as mergePrefix, q as mergeRoute, t as mergeTags, r as prefixRoute, D as type, u as unshiftTagRoute, v as validateORPCError } from './shared/contract.TuRtB1Ca.js';
import { AsyncIteratorClass } from '@orpc/shared';
export { AsyncIteratorClass, Registry, ThrowableError } from '@orpc/shared';
export { OpenAPIV3_1 as OpenAPI } from 'openapi-types';
import '@standard-schema/spec';
type Schema = StandardSchemaV1 | undefined;
type SchemaInput<TSchema extends Schema, TFallback = unknown> = TSchema extends undefined ? TFallback : TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferInput<TSchema> : TFallback;
type SchemaOutput<TSchema extends Schema, TFallback = unknown> = TSchema extends undefined ? TFallback : TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TSchema> : TFallback;
type TypeRest<TInput, TOutput> = [map: (input: TInput) => Promisable<TOutput>] | (IsEqual<TInput, TOutput> extends true ? [] : never);
declare function type<TInput, TOutput = TInput>(...[map]: TypeRest<TInput, TOutput>): StandardSchemaV1<TInput, TOutput>;
interface ValidationErrorOptions extends ErrorOptions {
message: string;
issues: readonly StandardSchemaV1.Issue[];
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 class ValidationError extends Error {
readonly issues: readonly StandardSchemaV1.Issue[];
constructor(options: ValidationErrorOptions);
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.dev/docs/contract-first/router-to-contract#minify-export-the-contract-router-for-the-client Router to Contract Docs}
*/
declare function minifyContractRouter(router: AnyContractRouter): AnyContractRouter;
type PopulatedContractRouterPaths<T extends AnyContractRouter> = T extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrors, infer UMeta> ? ContractProcedure<UInputSchema, UOutputSchema, UErrors, UMeta> : {
[K in keyof T]: T[K] extends AnyContractRouter ? PopulatedContractRouterPaths<T[K]> : never;
};
interface PopulateContractRouterPathsOptions {
path?: readonly string[];
}
interface ErrorMapItem<TDataSchema extends Schema> {
status?: number;
message?: string;
description?: string;
data?: TDataSchema;
}
type ErrorMap = {
[key in ORPCErrorCode]?: ErrorMapItem<Schema>;
};
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> ? ORPCError<K, SchemaOutput<TDataSchema>> : never : never;
}[keyof TErrorMap];
type ErrorFromErrorMap<TErrorMap extends ErrorMap> = Error | ORPCErrorFromErrorMap<TErrorMap>;
/**
* Automatically populates missing route paths using the router's nested keys.
*
* Constructs paths by joining router keys with `/`.
* Useful for NestJS integration that require explicit route paths.
*
* @see {@link https://orpc.dev/docs/openapi/integrations/implement-contract-in-nest#define-your-contract NestJS Implement Contract Docs}
*/
declare function populateContractRouterPaths<T extends AnyContractRouter>(router: T, options?: PopulateContractRouterPathsOptions): PopulatedContractRouterPaths<T>;
type Meta = Record<string, any>;
declare function mergeMeta<T extends Meta>(meta1: T, meta2: T): T;
type HTTPPath = `/${string}`;
type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
type InputStructure = 'compact' | 'detailed';
type OutputStructure = 'compact' | 'detailed';
interface Route {
method?: HTTPMethod;
path?: HTTPPath;
summary?: string;
description?: string;
deprecated?: boolean;
tags?: readonly string[];
interface ContractProcedureBuilder<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
/**
* The status code of the response when the procedure is successful.
* Adds type-safe custom errors to the contract.
* The provided errors are spared-merged with any existing errors in the contract.
*
* @default 200
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
*/
successStatus?: number;
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
/**
* The description of the response when the procedure is successful.
* Sets or updates the metadata for the contract.
* The provided metadata is spared-merged with any existing metadata in the contract.
*
* @default 'OK'
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
*/
successDescription?: string;
meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
/**
* Determines how the input should be structured based on `params`, `query`, `headers`, and `body`.
* 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.
*
* @option 'compact'
* Combines `params` and either `query` or `body` (depending on the HTTP method) into a single object.
* @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): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
/**
* Defines the input validation schema for the contract.
*
* @option 'detailed'
* Keeps each part of the request (`params`, `query`, `headers`, and `body`) as separate fields in the input object.
* @see {@link https://orpc.dev/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.
*
* Example:
* ```ts
* const input = {
* params: { id: 1 },
* query: { search: 'hello' },
* headers: { 'Content-Type': 'application/json' },
* body: { name: 'John' },
* }
* ```
* @see {@link https://orpc.dev/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.
*
* @default 'compact'
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
*/
inputStructure?: InputStructure;
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
/**
* Determines how the response should be structured based on the output.
* Sets or updates the metadata for the contract.
* The provided metadata is spared-merged with any existing metadata in the contract.
*
* @option 'compact'
* Includes only the body data, encoded directly in the response.
* @see {@link https://orpc.dev/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.
*
* @option 'detailed'
* Separates the output into `headers` and `body` fields.
* - `headers`: Custom headers to merge with the response headers.
* - `body`: The response data.
* @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): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
/**
* Defines the output validation schema for the contract.
*
* Example:
* ```ts
* const output = {
* headers: { 'x-custom-header': 'value' },
* body: { message: 'Hello, world!' },
* };
* ```
* @see {@link https://orpc.dev/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.
*
* @default 'compact'
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
*/
outputStructure?: OutputStructure;
}
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 AdaptRouteOptions {
prefix?: HTTPPath;
tags?: readonly string[];
}
declare function adaptRoute(route: Route, options: AdaptRouteOptions): Route;
interface ContractProcedureDef<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
meta: TMeta;
route: Route;
inputSchema: TInputSchema;
outputSchema: TOutputSchema;
errorMap: TErrorMap;
}
declare class ContractProcedure<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
'~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;
type ContractRouter<TMeta extends Meta> = ContractProcedure<any, any, any, TMeta> | {
[k: string]: ContractRouter<TMeta>;
};
type AnyContractRouter = ContractRouter<any>;
type AdaptedContractRouter<TContract extends AnyContractRouter, TErrorMap extends ErrorMap> = {
[K in keyof TContract]: TContract[K] extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrors, infer UMeta> ? ContractProcedure<UInputSchema, UOutputSchema, MergedErrorMap<TErrorMap, UErrors>, UMeta> : TContract[K] extends AnyContractRouter ? AdaptedContractRouter<TContract[K], TErrorMap> : never;
};
interface AdaptContractRouterOptions<TErrorMap extends ErrorMap> {
errorMap: TErrorMap;
prefix?: HTTPPath;
tags?: readonly string[];
}
declare function adaptContractRouter<TRouter extends ContractRouter<any>, TErrorMap extends ErrorMap>(contract: TRouter, options: AdaptContractRouterOptions<TErrorMap>): AdaptedContractRouter<TRouter, TErrorMap>;
type InferContractRouterInputs<T extends AnyContractRouter> = T extends ContractProcedure<infer UInputSchema, any, any, any> ? SchemaInput<UInputSchema> : {
[K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterInputs<T[K]> : never;
};
type InferContractRouterOutputs<T extends AnyContractRouter> = T extends ContractProcedure<any, infer UOutputSchema, any, any> ? SchemaOutput<UOutputSchema> : {
[K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterOutputs<T[K]> : never;
};
type ContractRouterToErrorMap<T extends AnyContractRouter> = T extends ContractProcedure<any, any, infer UErrorMap, any> ? UErrorMap : {
[K in keyof T]: T[K] extends AnyContractRouter ? ContractRouterToErrorMap<T[K]> : never;
}[keyof T];
type ContractRouterToMeta<T extends AnyContractRouter> = T extends ContractRouter<infer UMeta> ? UMeta : never;
interface ContractProcedureBuilder<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
route(route: Route): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
input<U extends Schema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>;
output<U extends Schema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>;
}
interface ContractProcedureBuilderWithInput<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
meta(meta: TMeta): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
route(route: Route): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
output<U extends Schema>(schema: U): ContractProcedureBuilderWithInputOutput<TInputSchema, U, TErrorMap, TMeta>;
}
interface ContractProcedureBuilderWithOutput<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
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.dev/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.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): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
input<U extends Schema>(schema: U): ContractProcedureBuilderWithInputOutput<U, TOutputSchema, TErrorMap, TMeta>;
/**
* Defines the input validation schema for the contract.
*
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs}
*/
input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInputOutput<U, TOutputSchema, TErrorMap, TMeta>;
}
interface ContractProcedureBuilderWithInputOutput<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, 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.dev/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.dev/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.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): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
}
interface ContractRouterBuilder<TErrorMap extends ErrorMap, TMeta extends Meta> {
'~orpc': AdaptContractRouterOptions<TErrorMap>;
/**
* 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.dev/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.dev/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.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
*/
'tag'(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>;
'router'<T extends ContractRouter<TMeta>>(router: T): AdaptedContractRouter<T, TErrorMap>;
/**
* Applies all of the previously defined options to the specified contract router.
*
* @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs}
*/
'router'<T extends ContractRouter<TMeta>>(router: T): EnhancedContractRouter<T, TErrorMap>;
}
interface ContractBuilderDef<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>, AdaptContractRouterOptions<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 Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
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>);
/**
* Reset initial meta
* Sets or overrides the initial meta.
*
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
*/
$meta<U extends Meta>(initialMeta: U): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, U>;
$meta<U extends Meta>(initialMeta: U): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, U & Record<never, never>>;
/**
* Reset initial route
* 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): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
/**
* Sets or overrides the initial input schema.
*
* @see {@link https://orpc.dev/docs/procedure#initial-configuration Initial Procedure Configuration Docs}
*/
$input<U extends AnySchema>(initialInputSchema?: U): ContractBuilder<U, 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.dev/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.dev/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.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): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
input<U extends Schema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>;
output<U extends Schema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>;
/**
* Defines the input validation schema for the contract.
*
* @see {@link https://orpc.dev/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.dev/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.dev/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.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
*/
tag(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>;
router<T extends ContractRouter<TMeta>>(router: T): AdaptedContractRouter<T, TErrorMap>;
/**
* Applies all of the previously defined options to the specified contract router.
*
* @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs}
*/
router<T extends ContractRouter<TMeta>>(router: T): EnhancedContractRouter<T, TErrorMap>;
}
declare const oc: ContractBuilder<undefined, undefined, {}, {}>;
declare const oc: ContractBuilder<Schema<unknown, unknown>, Schema<unknown, unknown>, Record<never, never>, Record<never, never>>;

@@ -217,14 +296,27 @@ interface ContractConfig {

defaultInputStructure: InputStructure;
defaultOutputStructure: InputStructure;
defaultOutputStructure: OutputStructure;
}
declare function fallbackContractConfig<T extends keyof ContractConfig>(key: T, value: ContractConfig[T] | undefined): ContractConfig[T];
declare function eventIterator<TYieldIn, TYieldOut, TReturnIn = unknown, TReturnOut = unknown>(yields: StandardSchemaV1<TYieldIn, TYieldOut>, returns?: StandardSchemaV1<TReturnIn, TReturnOut>): StandardSchemaV1<AsyncIteratorObject<TYieldIn, TReturnIn, void>, AsyncIteratorObject<TYieldOut, TReturnOut, void>>;
declare function getEventIteratorSchemaDetails(schema: Schema): undefined | {
yields: Schema;
returns: Schema;
};
interface EventIteratorSchemaDetails {
yields: AnySchema;
returns?: AnySchema;
}
/**
* Define schema for an event iterator.
*
* @see {@link https://orpc.dev/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>, AsyncIteratorClass<TYieldOut, TReturnOut, void>>;
declare function getEventIteratorSchemaDetails(schema: AnySchema | undefined): undefined | EventIteratorSchemaDetails;
type ContractProcedureClient<TClientContext extends ClientContext, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap> = Client<TClientContext, SchemaInput<TInputSchema>, SchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
/**
* Help RPCLink automatically send requests using the specified HTTP method in the contract.
*
* @see {@link https://orpc.dev/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> : {

@@ -234,2 +326,5 @@ [K in keyof TRouter]: TRouter[K] extends AnyContractRouter ? ContractRouterClient<TRouter[K], TClientContext> : never;

export { type AdaptContractRouterOptions, type AdaptRouteOptions, type AdaptedContractRouter, type AnyContractProcedure, type AnyContractRouter, ContractBuilder, type ContractBuilderDef, type ContractConfig, ContractProcedure, type ContractProcedureBuilder, type ContractProcedureBuilderWithInput, type ContractProcedureBuilderWithInputOutput, type ContractProcedureBuilderWithOutput, type ContractProcedureClient, type ContractProcedureDef, type ContractRouter, type ContractRouterBuilder, type ContractRouterClient, type ContractRouterToErrorMap, type ContractRouterToMeta, type ErrorFromErrorMap, type ErrorMap, type ErrorMapItem, type HTTPMethod, type HTTPPath, type InferContractRouterInputs, type InferContractRouterOutputs, type InputStructure, type MergedErrorMap, type Meta, type ORPCErrorFromErrorMap, type OutputStructure, type Route, type Schema, type SchemaInput, type SchemaOutput, type TypeRest, ValidationError, type ValidationErrorOptions, adaptContractRouter, adaptRoute, eventIterator, fallbackContractConfig, getEventIteratorSchemaDetails, isContractProcedure, mergeErrorMap, mergeMeta, mergePrefix, mergeRoute, mergeTags, oc, prefixRoute, type, unshiftTagRoute };
declare function isSchemaIssue(issue: unknown): issue is SchemaIssue;
export { AnyContractRouter, AnySchema, ContractBuilder, ContractProcedure, ContractProcedureDef, ContractRouter, EnhanceRouteOptions, ErrorFromErrorMap, ErrorMap, InferSchemaInput, InferSchemaOutput, InputStructure, MergedErrorMap, Meta, OutputStructure, Route, Schema, SchemaIssue, enhanceContractRouter, eventIterator, fallbackContractConfig, getContractRouter, getEventIteratorSchemaDetails, inferRPCMethodFromContractRouter, isSchemaIssue, minifyContractRouter, oc, populateContractRouterPaths };
export type { ContractBuilderDef, ContractConfig, ContractProcedureBuilder, ContractProcedureBuilderWithInput, ContractProcedureBuilderWithInputOutput, ContractProcedureBuilderWithOutput, ContractProcedureClient, ContractRouterBuilder, ContractRouterClient, EnhanceContractRouterOptions, EnhancedContractRouter, EventIteratorSchemaDetails, PopulateContractRouterPathsOptions, PopulatedContractRouterPaths };

@@ -0,16 +1,9 @@

import { i as isContractProcedure, C as ContractProcedure, m as mergeErrorMap, V as ValidationError } from './shared/contract.D_dZrO__.mjs';
export { v as validateORPCError } from './shared/contract.D_dZrO__.mjs';
import { toHttpPath } from '@orpc/client/standard';
import { toArray, isAsyncIteratorObject, get, isTypescriptObject, isPropertyKey } from '@orpc/shared';
export { AsyncIteratorClass } from '@orpc/shared';
import { mapEventIterator, ORPCError } from '@orpc/client';
export { ORPCError } from '@orpc/client';
import { isAsyncIteratorObject } from '@orpc/shared';
class ValidationError extends Error {
issues;
constructor(options) {
super(options.message, options);
this.issues = options.issues;
}
}
function mergeErrorMap(errorMap1, errorMap2) {
return { ...errorMap1, ...errorMap2 };
}
function mergeMeta(meta1, meta2) {

@@ -20,21 +13,2 @@ return { ...meta1, ...meta2 };

class ContractProcedure {
"~orpc";
constructor(def) {
if (def.route?.successStatus && (def.route.successStatus < 200 || def.route?.successStatus > 299)) {
throw new Error("[ContractProcedure] The successStatus must be between 200 and 299");
}
if (Object.values(def.errorMap).some((val) => val && val.status && (val.status < 400 || val.status > 599))) {
throw new Error("[ContractProcedure] The error status code must be in the 400-599 range.");
}
this["~orpc"] = def;
}
}
function isContractProcedure(item) {
if (item instanceof ContractProcedure) {
return true;
}
return (typeof item === "object" || typeof item === "function") && item !== null && "~orpc" in item && typeof item["~orpc"] === "object" && item["~orpc"] !== null && "inputSchema" in item["~orpc"] && "outputSchema" in item["~orpc"] && "errorMap" in item["~orpc"] && "route" in item["~orpc"] && "meta" in item["~orpc"];
}
function mergeRoute(a, b) {

@@ -64,3 +38,3 @@ return { ...a, ...b };

}
function adaptRoute(route, options) {
function enhanceRoute(route, options) {
let router = route;

@@ -70,3 +44,3 @@ if (options.prefix) {

}
if (options.tags) {
if (options.tags?.length) {
router = unshiftTagRoute(router, options.tags);

@@ -77,17 +51,80 @@ }

function adaptContractRouter(contract, options) {
if (isContractProcedure(contract)) {
const adapted2 = new ContractProcedure({
...contract["~orpc"],
errorMap: mergeErrorMap(options.errorMap, contract["~orpc"].errorMap),
route: adaptRoute(contract["~orpc"].route, options)
function getContractRouter(router, path) {
let current = router;
for (let i = 0; i < path.length; i++) {
const segment = path[i];
if (!current) {
return void 0;
}
if (isContractProcedure(current)) {
return void 0;
}
if (typeof current !== "object") {
return void 0;
}
current = current[segment];
}
return current;
}
function enhanceContractRouter(router, options) {
if (isContractProcedure(router)) {
const enhanced2 = new ContractProcedure({
...router["~orpc"],
errorMap: mergeErrorMap(options.errorMap, router["~orpc"].errorMap),
route: enhanceRoute(router["~orpc"].route, options)
});
return adapted2;
return enhanced2;
}
const adapted = {};
for (const key in contract) {
adapted[key] = adaptContractRouter(contract[key], options);
if (typeof router !== "object" || router === null) {
return router;
}
return adapted;
const enhanced = {};
for (const key in router) {
enhanced[key] = enhanceContractRouter(router[key], options);
}
return enhanced;
}
function minifyContractRouter(router) {
if (isContractProcedure(router)) {
const procedure = {
"~orpc": {
errorMap: {},
meta: router["~orpc"].meta,
route: router["~orpc"].route
}
};
return procedure;
}
if (typeof router !== "object" || router === null) {
return router;
}
const json = {};
for (const key in router) {
json[key] = minifyContractRouter(router[key]);
}
return json;
}
function populateContractRouterPaths(router, options = {}) {
const path = toArray(options.path);
if (isContractProcedure(router)) {
if (router["~orpc"].route.path === void 0) {
return new ContractProcedure({
...router["~orpc"],
route: {
...router["~orpc"].route,
path: toHttpPath(path)
}
});
}
return router;
}
if (typeof router !== "object" || router === null) {
return router;
}
const populated = {};
for (const key in router) {
populated[key] = populateContractRouterPaths(router[key], { ...options, path: [...path, key] });
}
return populated;
}

@@ -101,3 +138,5 @@ class ContractBuilder extends ContractProcedure {

/**
* Reset initial meta
* Sets or overrides the initial meta.
*
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
*/

@@ -111,3 +150,7 @@ $meta(initialMeta) {

/**
* Reset initial route
* 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}
*/

@@ -120,2 +163,19 @@ $route(initialRoute) {

}
/**
* Sets or overrides the initial input schema.
*
* @see {@link https://orpc.dev/docs/procedure#initial-configuration Initial Procedure Configuration Docs}
*/
$input(initialInputSchema) {
return new ContractBuilder({
...this["~orpc"],
inputSchema: initialInputSchema
});
}
/**
* 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.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
*/
errors(errors) {

@@ -127,2 +187,8 @@ return new ContractBuilder({

}
/**
* 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.dev/docs/metadata Metadata Docs}
*/
meta(meta) {

@@ -134,2 +200,10 @@ return new ContractBuilder({

}
/**
* 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.dev/docs/openapi/routing OpenAPI Routing Docs}
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
*/
route(route) {

@@ -141,2 +215,7 @@ return new ContractBuilder({

}
/**
* Defines the input validation schema for the contract.
*
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs}
*/
input(schema) {

@@ -148,2 +227,7 @@ return new ContractBuilder({

}
/**
* Defines the output validation schema for the contract.
*
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs}
*/
output(schema) {

@@ -155,2 +239,10 @@ return new ContractBuilder({

}
/**
* 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.dev/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
*/
prefix(prefix) {

@@ -162,2 +254,8 @@ return new ContractBuilder({

}
/**
* 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.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
*/
tag(...tags) {

@@ -169,4 +267,9 @@ return new ContractBuilder({

}
/**
* Applies all of the previously defined options to the specified contract router.
*
* @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs}
*/
router(router) {
return adaptContractRouter(router, this["~orpc"]);
return enhanceContractRouter(router, this["~orpc"]);
}

@@ -176,4 +279,2 @@ }

errorMap: {},
inputSchema: void 0,
outputSchema: void 0,
route: {},

@@ -197,7 +298,7 @@ meta: {}

const EVENT_ITERATOR_SCHEMA_SYMBOL = Symbol("ORPC_EVENT_ITERATOR_SCHEMA");
const EVENT_ITERATOR_DETAILS_SYMBOL = Symbol("ORPC_EVENT_ITERATOR_DETAILS");
function eventIterator(yields, returns) {
return {
"~standard": {
[EVENT_ITERATOR_SCHEMA_SYMBOL]: { yields, returns },
[EVENT_ITERATOR_DETAILS_SYMBOL]: { yields, returns },
vendor: "orpc",

@@ -221,3 +322,4 @@ version: 1,

issues: result.issues,
message: "Event iterator validation failed"
message: "Event iterator validation failed",
data: value
})

@@ -239,5 +341,18 @@ });

}
return schema["~standard"][EVENT_ITERATOR_SCHEMA_SYMBOL];
return schema["~standard"][EVENT_ITERATOR_DETAILS_SYMBOL];
}
function inferRPCMethodFromContractRouter(contract) {
return (_, path) => {
const procedure = get(contract, path);
if (!isContractProcedure(procedure)) {
throw new Error(
`[inferRPCMethodFromContractRouter] No valid procedure found at path "${path.join(".")}". This may happen when the contract router is not properly configured.`
);
}
const method = fallbackContractConfig("defaultMethod", procedure["~orpc"].route.method);
return method === "HEAD" ? "GET" : method;
};
}
function type(...[map]) {

@@ -258,2 +373,17 @@ return {

export { ContractBuilder, ContractProcedure, ValidationError, adaptContractRouter, adaptRoute, eventIterator, fallbackContractConfig, getEventIteratorSchemaDetails, isContractProcedure, mergeErrorMap, mergeMeta, mergePrefix, mergeRoute, mergeTags, oc, prefixRoute, type, unshiftTagRoute };
function isSchemaIssue(issue) {
if (!isTypescriptObject(issue) || typeof issue.message !== "string") {
return false;
}
if (issue.path !== void 0) {
if (!Array.isArray(issue.path)) {
return false;
}
if (!issue.path.every((segment) => isPropertyKey(segment) || isTypescriptObject(segment) && isPropertyKey(segment.key))) {
return false;
}
}
return true;
}
export { ContractBuilder, ContractProcedure, ValidationError, enhanceContractRouter, enhanceRoute, eventIterator, fallbackContractConfig, getContractRouter, getEventIteratorSchemaDetails, inferRPCMethodFromContractRouter, isContractProcedure, isSchemaIssue, mergeErrorMap, mergeMeta, mergePrefix, mergeRoute, mergeTags, minifyContractRouter, oc, populateContractRouterPaths, prefixRoute, type, unshiftTagRoute };
{
"name": "@orpc/contract",
"type": "module",
"version": "0.0.0-next.68378b4",
"version": "0.0.0-next.683f2ee",
"license": "MIT",
"homepage": "https://orpc.unnoq.com",
"homepage": "https://orpc.dev",
"repository": {
"type": "git",
"url": "git+https://github.com/unnoq/orpc.git",
"url": "git+https://github.com/middleapi/orpc.git",
"directory": "packages/contract"
},
"keywords": [
"unnoq",
"orpc"
],
"sideEffects": false,
"exports": {

@@ -21,2 +21,7 @@ ".": {

"default": "./dist/index.mjs"
},
"./plugins": {
"types": "./dist/plugins/index.d.mts",
"import": "./dist/plugins/index.mjs",
"default": "./dist/plugins/index.mjs"
}

@@ -28,11 +33,11 @@ },

"dependencies": {
"@standard-schema/spec": "^1.0.0",
"@orpc/client": "0.0.0-next.68378b4",
"@orpc/shared": "0.0.0-next.68378b4",
"@orpc/standard-server": "0.0.0-next.68378b4"
"@standard-schema/spec": "^1.1.0",
"openapi-types": "^12.1.3",
"@orpc/client": "0.0.0-next.683f2ee",
"@orpc/shared": "0.0.0-next.683f2ee"
},
"devDependencies": {
"arktype": "2.0.0-rc.26",
"valibot": "1.0.0-beta.9",
"zod": "^3.24.1"
"arktype": "2.2.0",
"valibot": "^1.2.0",
"zod": "^4.3.6"
},

@@ -39,0 +44,0 @@ "scripts": {

+148
-28
<div align="center">
<image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 alt="oRPC logo" />
<image align="center" src="https://orpc.dev/logo.webp" width=280 alt="oRPC logo" />
</div>

@@ -8,4 +8,4 @@

<div align="center">
<a href="https://codecov.io/gh/unnoq/orpc">
<img alt="codecov" src="https://codecov.io/gh/unnoq/orpc/branch/main/graph/badge.svg">
<a href="https://codecov.io/gh/middleapi/orpc">
<img alt="codecov" src="https://codecov.io/gh/middleapi/orpc/branch/main/graph/badge.svg">
</a>

@@ -15,4 +15,4 @@ <a href="https://www.npmjs.com/package/@orpc/contract">

</a>
<a href="https://github.com/unnoq/orpc/blob/main/LICENSE">
<img alt="MIT License" src="https://img.shields.io/github/license/unnoq/orpc?logo=open-source-initiative" />
<a href="https://github.com/middleapi/orpc/blob/main/LICENSE">
<img alt="MIT License" src="https://img.shields.io/github/license/middleapi/orpc?logo=open-source-initiative" />
</a>

@@ -22,2 +22,5 @@ <a href="https://discord.gg/TXEbwRBvQn">

</a>
<a href="https://deepwiki.com/middleapi/orpc">
<img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki">
</a>
</div>

@@ -27,3 +30,3 @@

**oRPC is a powerful combination of RPC and OpenAPI**, makes it easy to build APIs that are end-to-end type-safe and adhere to OpenAPI standards, ensuring a smooth and enjoyable developer experience.
**oRPC is a powerful combination of RPC and OpenAPI**, makes it easy to build APIs that are end-to-end type-safe and adhere to OpenAPI standards

@@ -34,22 +37,18 @@ ---

- **End-to-End Type Safety πŸ”’**: Ensure complete type safety from inputs to outputs and errors, bridging server and client seamlessly.
- **First-Class OpenAPI πŸ“„**: Adheres to the OpenAPI standard out of the box, ensuring seamless integration and comprehensive API documentation.
- **Contract-First Development πŸ“œ**: (Optional) Define your API contract upfront and implement it with confidence.
- **Exceptional Developer Experience ✨**: Enjoy a streamlined workflow with robust typing and clear, in-code documentation.
- **Multi-Runtime Support 🌍**: Run your code seamlessly on Cloudflare, Deno, Bun, Node.js, and more.
- **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue), Pinia Colada, and more.
- **Server Actions ⚑️**: Fully compatible with React Server Actions on Next.js, TanStack Start, and more.
- **Standard Schema Support πŸ—‚οΈ**: Effortlessly work with Zod, Valibot, ArkType, and others right out of the box.
- **Fast & Lightweight πŸ’¨**: Built on native APIs across all runtimes – optimized for speed and efficiency.
- **Native Types πŸ“¦**: Enjoy built-in support for Date, File, Blob, BigInt, URL and more with no extra setup.
- **Lazy Router ⏱️**: Improve cold start times with our lazy routing feature.
- **SSE & Streaming πŸ“‘**: Provides SSE and streaming features – perfect for real-time notifications and AI-powered streaming responses.
- **Reusability πŸ”„**: Write once and reuse your code across multiple purposes effortlessly.
- **Extendability πŸ”Œ**: Easily enhance oRPC with plugins, middleware, and interceptors.
- **Reliability πŸ›‘οΈ**: Well-tested, fully TypeScript, production-ready, and MIT licensed for peace of mind.
- **Simplicity πŸ’‘**: Enjoy straightforward, clean code with no hidden magic.
- **πŸ”— End-to-End Type Safety**: Ensure type-safe inputs, outputs, and errors from client to server.
- **πŸ“˜ First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard.
- **πŸ“ Contract-First Development**: Optionally define your API contract before implementation.
- **πŸ” First-Class OpenTelemetry**: Seamlessly integrate with OpenTelemetry for observability.
- **βš™οΈ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more.
- **πŸš€ Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
- **πŸ”  Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
- **πŸ—ƒοΈ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
- **⏱️ Lazy Router**: Enhance cold start times with our lazy routing feature.
- **πŸ“‘ SSE & Streaming**: Enjoy full type-safe support for SSE and streaming.
- **🌍 Multi-Runtime Support**: Fast and lightweight on Cloudflare, Deno, Bun, Node.js, and beyond.
- **πŸ”Œ Extendability**: Easily extend functionality with plugins, middleware, and interceptors.
## Documentation
You can find the full documentation [here](https://orpc.unnoq.com).
You can find the full documentation [here](https://orpc.dev).

@@ -61,11 +60,17 @@ ## Packages

- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
- [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).
- [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
- [@orpc/otel](https://www.npmjs.com/package/@orpc/otel): [OpenTelemetry](https://opentelemetry.io/) integration for observability.
- [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with [NestJS](https://nestjs.com/).
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
- [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query): [TanStack Query](https://tanstack.com/query/latest) integration.
- [@orpc/experimental-react-swr](https://www.npmjs.com/package/@orpc/experimental-react-swr): [SWR](https://swr.vercel.app/) integration.
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
- [@orpc/hey-api](https://www.npmjs.com/package/@orpc/hey-api): [Hey API](https://heyapi.dev/) integration.
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
- [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
- [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
## `@orpc/contract`
Build your API contract. Read the [documentation](https://orpc.unnoq.com/docs/contract-first/define-contract) for more information.
Build your API contract. Read the [documentation](https://orpc.dev/docs/contract-first/define-contract) for more information.

@@ -105,4 +110,119 @@ ```ts

## Sponsors
If you find oRPC valuable and would like to support its development, you can do so here: [GitHub Sponsors](https://github.com/sponsors/dinwwwh).
### πŸ† Platinum Sponsor
<table>
<tr>
<td align="center"><a href="https://screenshotone.com/?ref=orpc" target="_blank" rel="noopener" title="ScreenshotOne.com"><img src="https://avatars.githubusercontent.com/u/97035603?v=4" width="279" alt="ScreenshotOne.com"/><br />ScreenshotOne.com</a></td>
</tr>
</table>
### πŸ₯ˆ Silver Sponsor
<table>
<tr>
<td align="center"><a href="https://misskey.io/?ref=orpc" target="_blank" rel="noopener" title="ζ‘δΈŠγ•γ‚“"><img src="https://avatars.githubusercontent.com/u/37681609?u=0dd4c7e4ba937cbb52b068c55914b1d8164dc0c7&amp;v=4" width="209" alt="ζ‘δΈŠγ•γ‚“"/><br />ζ‘δΈŠγ•γ‚“</a></td>
</tr>
</table>
### Generous Sponsors
<table>
<tr>
<td align="center"><a href="https://github.com/ln-markets?ref=orpc" target="_blank" rel="noopener" title="LN Markets"><img src="https://avatars.githubusercontent.com/u/70597625?v=4" width="167" alt="LN Markets"/><br />LN Markets</a></td>
</tr>
</table>
### Sponsors
<table>
<tr>
<td align="center"><a href="https://github.com/hrmcdonald?ref=orpc" target="_blank" rel="noopener" title="Reece McDonald"><img src="https://avatars.githubusercontent.com/u/39349270?v=4" width="139" alt="Reece McDonald"/><br />Reece McDonald</a></td>
<td align="center"><a href="https://github.com/nicognaW?ref=orpc" target="_blank" rel="noopener" title="nk"><img src="https://avatars.githubusercontent.com/u/66731869?u=4699bda3a9092d3ec34fbd959450767bcc8b8b6d&amp;v=4" width="139" alt="nk"/><br />nk</a></td>
<td align="center"><a href="https://github.com/supastarter?ref=orpc" target="_blank" rel="noopener" title="supastarter"><img src="https://avatars.githubusercontent.com/u/110960143?v=4" width="139" alt="supastarter"/><br />supastarter</a></td>
<td align="center"><a href="https://github.com/divmgl?ref=orpc" target="_blank" rel="noopener" title="Dexter Miguel"><img src="https://avatars.githubusercontent.com/u/5452298?u=645993204be8696c085ecf0d228c3062efe2ed65&amp;v=4" width="139" alt="Dexter Miguel"/><br />Dexter Miguel</a></td>
<td align="center"><a href="https://github.com/herrfugbaum?ref=orpc" target="_blank" rel="noopener" title="herrfugbaum"><img src="https://avatars.githubusercontent.com/u/12859776?u=644dc1666d0220bc0468eb0de3c56b919f635b16&amp;v=4" width="139" alt="herrfugbaum"/><br />herrfugbaum</a></td>
<td align="center"><a href="https://github.com/ryota-murakami?ref=orpc" target="_blank" rel="noopener" title="Ryota Murakami"><img src="https://avatars.githubusercontent.com/u/5501268?u=599389e03340734325726ca3f8f423c021d47d7f&amp;v=4" width="139" alt="Ryota Murakami"/><br />Ryota Murakami</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/dcramer?ref=orpc" target="_blank" rel="noopener" title="David Cramer"><img src="https://avatars.githubusercontent.com/u/23610?v=4" width="139" alt="David Cramer"/><br />David Cramer</a></td>
<td align="center"><a href="https://github.com/valerii15298?ref=orpc" target="_blank" rel="noopener" title="Valerii Petryniak"><img src="https://avatars.githubusercontent.com/u/44531564?u=88ac74d9bacd20401518441907acad21063cd397&amp;v=4" width="139" alt="Valerii Petryniak"/><br />Valerii Petryniak</a></td>
<td align="center"><a href="https://github.com/letstri?ref=orpc" target="_blank" rel="noopener" title="Valerii Strilets"><img src="https://avatars.githubusercontent.com/u/13253748?u=c7b10399ccc8f8081e24db94ec32cd9858e86ac3&amp;v=4" width="139" alt="Valerii Strilets"/><br />Valerii Strilets</a></td>
<td align="center"><a href="https://github.com/K-Mistele?ref=orpc" target="_blank" rel="noopener" title="Kyle Mistele"><img src="https://avatars.githubusercontent.com/u/18430555?u=3afebeb81de666e35aaac3ed46f14159d7603ffb&amp;v=4" width="139" alt="Kyle Mistele"/><br />Kyle Mistele</a></td>
<td align="center"><a href="https://github.com/andrewpeters9?ref=orpc" target="_blank" rel="noopener" title="Andrew Peters"><img src="https://avatars.githubusercontent.com/u/36251325?v=4" width="139" alt="Andrew Peters"/><br />Andrew Peters</a></td>
<td align="center"><a href="https://github.com/R44VC0RP?ref=orpc" target="_blank" rel="noopener" title="Ryan Vogel"><img src="https://avatars.githubusercontent.com/u/89211796?u=1857347b9787d8d8a7ea5bfc333f96be92d5a683&amp;v=4" width="139" alt="Ryan Vogel"/><br />Ryan Vogel</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/christ12938?ref=orpc" target="_blank" rel="noopener" title="christ12938"><img src="https://avatars.githubusercontent.com/u/25758598?v=4" width="139" alt="christ12938"/><br />christ12938</a></td>
<td align="center"><a href="https://github.com/peter-adam-dy?ref=orpc" target="_blank" rel="noopener" title="Peter Adam"><img src="https://avatars.githubusercontent.com/u/132129459?u=4f3dbbb3b443990b56acb7d6a5d11ed2c555f6db&amp;v=4" width="139" alt="Peter Adam"/><br />Peter Adam</a></td>
<td align="center"><a href="https://github.com/yukimotochern?ref=orpc" target="_blank" rel="noopener" title="Chen, Zhi-Yuan"><img src="https://avatars.githubusercontent.com/u/20896173?u=945c33fc21725e4d566a0d02afc54b136ca1d67a&amp;v=4" width="139" alt="Chen, Zhi-Yuan"/><br />Chen, Zhi-Yuan</a></td>
<td align="center"><a href="https://github.com/Ryanjso?ref=orpc" target="_blank" rel="noopener" title="Ryan Soderberg"><img src="https://avatars.githubusercontent.com/u/39172778?u=5ed913c31d57e7221b75784abcad48c7ebddde27&amp;v=4" width="139" alt="Ryan Soderberg"/><br />Ryan Soderberg</a></td>
</tr>
</table>
### Backers
<table>
<tr>
<td align="center"><a href="https://github.com/rhinodavid?ref=orpc" target="_blank" rel="noopener" title="David Walsh"><img src="https://avatars.githubusercontent.com/u/5778036?u=b5521f07d2f88c3db2a0dae62b5f2f8357214af0&amp;v=4" width="119" alt="David Walsh"/><br />David Walsh</a></td>
<td align="center"><a href="https://github.com/Robbe95?ref=orpc" target="_blank" rel="noopener" title="Robbe Vaes"><img src="https://avatars.githubusercontent.com/u/44748019?u=e0232402c045ad4eac7cbd217f1f47e083103b89&amp;v=4" width="119" alt="Robbe Vaes"/><br />Robbe Vaes</a></td>
<td align="center"><a href="https://github.com/aidansunbury?ref=orpc" target="_blank" rel="noopener" title="Aidan Sunbury"><img src="https://avatars.githubusercontent.com/u/64103161?v=4" width="119" alt="Aidan Sunbury"/><br />Aidan Sunbury</a></td>
<td align="center"><a href="https://github.com/soonoo?ref=orpc" target="_blank" rel="noopener" title="soonoo"><img src="https://avatars.githubusercontent.com/u/5436405?u=5d0b4aa955c87e30e6bda7f0cccae5402da99528&amp;v=4" width="119" alt="soonoo"/><br />soonoo</a></td>
<td align="center"><a href="https://github.com/kporten?ref=orpc" target="_blank" rel="noopener" title="Kevin Porten"><img src="https://avatars.githubusercontent.com/u/1839345?u=dc2263d5cfe0d927ce1a0be04a1d55dd6b55405c&amp;v=4" width="119" alt="Kevin Porten"/><br />Kevin Porten</a></td>
<td align="center"><a href="https://github.com/pumpkinlink?ref=orpc" target="_blank" rel="noopener" title="Denis"><img src="https://avatars.githubusercontent.com/u/11864620?u=5f47bbe6c65d0f6f5cf011021490238e4b0593d0&amp;v=4" width="119" alt="Denis"/><br />Denis</a></td>
<td align="center"><a href="https://github.com/christopher-kapic?ref=orpc" target="_blank" rel="noopener" title="Christopher Kapic"><img src="https://avatars.githubusercontent.com/u/59740769?u=e7ad4b72b5bf6c9eb1644c26dbf3332a8f987377&amp;v=4" width="119" alt="Christopher Kapic"/><br />Christopher Kapic</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/thomasballinger?ref=orpc" target="_blank" rel="noopener" title="Tom Ballinger"><img src="https://avatars.githubusercontent.com/u/458879?u=4b045ac75d721b6ac2b42a74d7d37f61f0414031&amp;v=4" width="119" alt="Tom Ballinger"/><br />Tom Ballinger</a></td>
<td align="center"><a href="https://github.com/SSam0419?ref=orpc" target="_blank" rel="noopener" title="Sam"><img src="https://avatars.githubusercontent.com/u/102863520?u=3c89611f549d5070be232eb4532f690c8f2e7a65&amp;v=4" width="119" alt="Sam"/><br />Sam</a></td>
<td align="center"><a href="https://github.com/Titoine?ref=orpc" target="_blank" rel="noopener" title="Titoine"><img src="https://avatars.githubusercontent.com/u/3514286?u=1bb1e86b0c99c8a1121372e56d51a177eea12191&amp;v=4" width="119" alt="Titoine"/><br />Titoine</a></td>
<td align="center"><a href="https://github.com/Mnigos?ref=orpc" target="_blank" rel="noopener" title="Igor Makowski"><img src="https://avatars.githubusercontent.com/u/56691628?u=ee8c879478f7c151b9156aef6c74243fa3e247a8&amp;v=4" width="119" alt="Igor Makowski"/><br />Igor Makowski</a></td>
<td align="center"><a href="https://github.com/steelbrain?ref=orpc" target="_blank" rel="noopener" title="Anees Iqbal"><img src="https://avatars.githubusercontent.com/u/4278113?u=22b80b5399eed68ac76cd58b02961b0481f1db11&amp;v=4" width="119" alt="Anees Iqbal"/><br />Anees Iqbal</a></td>
<td align="center"><a href="https://github.com/hanayashiki?ref=orpc" target="_blank" rel="noopener" title="wang chenyu"><img src="https://avatars.githubusercontent.com/u/26056783?u=06c3b9205a16fd41a871e82da1cc2a09306d53f5&amp;v=4" width="119" alt="wang chenyu"/><br />wang chenyu</a></td>
<td align="center"><a href="https://github.com/piscis?ref=orpc" target="_blank" rel="noopener" title="Alex"><img src="https://avatars.githubusercontent.com/u/326163?u=b245f368bd940cf51d08c0b6bf55f8257f359437&amp;v=4" width="119" alt="Alex"/><br />Alex</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/nattstack?ref=orpc" target="_blank" rel="noopener" title="nattstack"><img src="https://avatars.githubusercontent.com/u/31426677?u=fa9dbb8b3e66eb0ea3c88db5dc07f31c8c5418fe&amp;v=4" width="119" alt="nattstack"/><br />nattstack</a></td>
</tr>
</table>
### Past Sponsors
<p>
<a href="https://github.com/MrMaxie?ref=orpc" target="_blank" rel="noopener" title="Maxie"><img src="https://avatars.githubusercontent.com/u/3857836?u=5e6b57973d4385d655663ffdd836e487856f2984&amp;v=4" width="32" height="32" alt="Maxie" /></a>
<a href="https://github.com/Stijn-Timmer?ref=orpc" target="_blank" rel="noopener" title="Stijn Timmer"><img src="https://avatars.githubusercontent.com/u/100147665?u=106b2c18e9c98a61861b4ee7fc100f5b9906a6c9&amp;v=4" width="32" height="32" alt="Stijn Timmer" /></a>
<a href="https://github.com/u1-liquid?ref=orpc" target="_blank" rel="noopener" title="あわわわとーにゅ"><img src="https://avatars.githubusercontent.com/u/17376330?u=de3353804be889f009f7e0a1582daf04d0ab292d&amp;v=4" width="32" height="32" alt="あわわわとーにゅ" /></a>
<a href="https://github.com/zuplo?ref=orpc" target="_blank" rel="noopener" title="Zuplo"><img src="https://avatars.githubusercontent.com/u/85497839?v=4" width="32" height="32" alt="Zuplo" /></a>
<a href="https://github.com/motopods?ref=orpc" target="_blank" rel="noopener" title="motopods"><img src="https://avatars.githubusercontent.com/u/58200641?u=18833983d65b481ae90a4adec2373064ec58bcf3&amp;v=4" width="32" height="32" alt="motopods" /></a>
<a href="https://github.com/franciscohermida?ref=orpc" target="_blank" rel="noopener" title="Francisco Hermida"><img src="https://avatars.githubusercontent.com/u/483242?u=bbcbc80eb9d8781ff401f7dafc3b59cd7bea0561&amp;v=4" width="32" height="32" alt="Francisco Hermida" /></a>
<a href="https://github.com/theoludwig?ref=orpc" target="_blank" rel="noopener" title="ThΓ©o LUDWIG"><img src="https://avatars.githubusercontent.com/u/25207499?u=a6a9653725a2f574c07893748806668e0598cdbe&amp;v=4" width="32" height="32" alt="ThΓ©o LUDWIG" /></a>
<a href="https://github.com/abhay-ramesh?ref=orpc" target="_blank" rel="noopener" title="Abhay Ramesh"><img src="https://avatars.githubusercontent.com/u/66196314?u=c5c2b0327b26606c2efcfaf17046ab18c3d25c57&amp;v=4" width="32" height="32" alt="Abhay Ramesh" /></a>
<a href="https://github.com/shr-ink?ref=orpc" target="_blank" rel="noopener" title="shr.ink oΓΌ"><img src="https://avatars.githubusercontent.com/u/139700438?v=4" width="32" height="32" alt="shr.ink oΓΌ" /></a>
<a href="https://github.com/johngerome?ref=orpc" target="_blank" rel="noopener" title="0x4e32"><img src="https://avatars.githubusercontent.com/u/2002000?u=24e8dd943cfc862aa284d858a023532c75071ade&amp;v=4" width="32" height="32" alt="0x4e32" /></a>
<a href="https://github.com/yzuyr?ref=orpc" target="_blank" rel="noopener" title="Ryuz"><img src="https://avatars.githubusercontent.com/u/196539378?u=d38374588d219b6748b16406982f6559411466d4&amp;v=4" width="32" height="32" alt="Ryuz" /></a>
<a href="https://github.com/happyboy2022?ref=orpc" target="_blank" rel="noopener" title="happyboy"><img src="https://avatars.githubusercontent.com/u/103669586?u=65b49c4b893ed3703909fbb3a7a22313f3f9c121&amp;v=4" width="32" height="32" alt="happyboy" /></a>
<a href="https://github.com/YiCChi?ref=orpc" target="_blank" rel="noopener" title="yicchi"><img src="https://avatars.githubusercontent.com/u/86967274?u=6c2756f09fe15dd94d572f560e979cd157982852&amp;v=4" width="32" height="32" alt="yicchi" /></a>
<a href="https://github.com/cloudycotton?ref=orpc" target="_blank" rel="noopener" title="Saksham"><img src="https://avatars.githubusercontent.com/u/168998965?u=9b9634a5aed66a51c1b880663272725b00b92b14&amp;v=4" width="32" height="32" alt="Saksham" /></a>
<a href="https://github.com/hrynevychroman?ref=orpc" target="_blank" rel="noopener" title="Roman Hrynevych"><img src="https://avatars.githubusercontent.com/u/82209198?u=1a1d111ab3d589855b9cc8a7fefb1b5c6a4fbbaf&amp;v=4" width="32" height="32" alt="Roman Hrynevych" /></a>
<a href="https://github.com/rokitgg?ref=orpc" target="_blank" rel="noopener" title="rokitg"><img src="https://avatars.githubusercontent.com/u/125133357?u=06c74aefaa2236b06a2e5fba5a5c612339f45912&amp;v=4" width="32" height="32" alt="rokitg" /></a>
<a href="https://github.com/omarkhatibgg?ref=orpc" target="_blank" rel="noopener" title="Omar Khatib"><img src="https://avatars.githubusercontent.com/u/9054278?u=afbba7331b85c51b8eee4130f5fd31b1017dc919&amp;v=4" width="32" height="32" alt="Omar Khatib" /></a>
<a href="https://github.com/YuSabo90002?ref=orpc" target="_blank" rel="noopener" title="Yu-Sabo"><img src="https://avatars.githubusercontent.com/u/13120582?v=4" width="32" height="32" alt="Yu-Sabo" /></a>
<a href="https://github.com/bapspatil?ref=orpc" target="_blank" rel="noopener" title="Bapusaheb Patil"><img src="https://avatars.githubusercontent.com/u/16699418?v=4" width="32" height="32" alt="Bapusaheb Patil" /></a>
<a href="https://github.com/ripgrim?ref=orpc" target="_blank" rel="noopener" title="grim"><img src="https://avatars.githubusercontent.com/u/75869731?u=b17c42ec2309552fdb822a86b25a2f99146a4d72&amp;v=4" width="32" height="32" alt="grim" /></a>
<a href="https://github.com/nelsonlaidev?ref=orpc" target="_blank" rel="noopener" title="Nelson Lai"><img src="https://avatars.githubusercontent.com/u/75498339?u=2fc0e0b95dd184c5ffb744df977cb15a18b60672&amp;v=4" width="32" height="32" alt="Nelson Lai" /></a>
<a href="https://github.com/nguyenlc1993?ref=orpc" target="_blank" rel="noopener" title="LΓͺ Cao NguyΓͺn"><img src="https://avatars.githubusercontent.com/u/13871971?u=83c8b69d9e35b589c4e1f066cc113b1d9461386f&amp;v=4" width="32" height="32" alt="LΓͺ Cao NguyΓͺn" /></a>
<a href="https://github.com/wobsoriano?ref=orpc" target="_blank" rel="noopener" title="Robert Soriano"><img src="https://avatars.githubusercontent.com/u/13049130?u=6d72104182e7c9ed25934815313fb69107332111&amp;v=4" width="32" height="32" alt="Robert Soriano" /></a>
<a href="https://github.com/SKostyukovich?ref=orpc" target="_blank" rel="noopener" title="SKostyukovich"><img src="https://avatars.githubusercontent.com/u/10700067?v=4" width="32" height="32" alt="SKostyukovich" /></a>
<a href="https://github.com/FabworksHQ?ref=orpc" target="_blank" rel="noopener" title="Fabworks"><img src="https://avatars.githubusercontent.com/u/160179500?v=4" width="32" height="32" alt="Fabworks" /></a>
<a href="https://github.com/NovakAnton?ref=orpc" target="_blank" rel="noopener" title="Novak Antonijevic"><img src="https://avatars.githubusercontent.com/u/157126729?u=ae49fa22292d55c0434ff0ca008206155b18663b&amp;v=4" width="32" height="32" alt="Novak Antonijevic" /></a>
<a href="https://github.com/laduniestu?ref=orpc" target="_blank" rel="noopener" title="Laduni Estu Syalwa"><img src="https://avatars.githubusercontent.com/u/44757637?u=a2fc1ea8f7d827a96721176f79d30592d1c48059&amp;v=4" width="32" height="32" alt="Laduni Estu Syalwa" /></a>
<a href="https://github.com/illarionvk?ref=orpc" target="_blank" rel="noopener" title="Illarion Koperski"><img src="https://avatars.githubusercontent.com/u/5012724?u=7cfa13652f7ac5fb3c56d880e3eb3fbe40c3ea34&amp;v=4" width="32" height="32" alt="Illarion Koperski" /></a>
<a href="https://github.com/Scrumplex?ref=orpc" target="_blank" rel="noopener" title="Sefa Eyeoglu"><img src="https://avatars.githubusercontent.com/u/11587657?u=ab503582165c0bbff0cca47ce31c9450bb1553c9&amp;v=4" width="32" height="32" alt="Sefa Eyeoglu" /></a>
</p>
## License
Distributed under the MIT License. See [LICENSE](https://github.com/unnoq/orpc/blob/main/LICENSE) for more information.
Distributed under the MIT License. See [LICENSE](https://github.com/middleapi/orpc/blob/main/LICENSE) for more information.