@orpc/contract
Advanced tools
| 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 }; |
+64
-43
| 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.CvRxURhn.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.CvRxURhn.mjs'; | ||
| 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'; | ||
@@ -24,5 +24,20 @@ export { AsyncIteratorClass, Registry, ThrowableError } from '@orpc/shared'; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/contract-first/router-to-contract#minify-export-the-contract-router-for-the-client Router to Contract Docs} | ||
| * @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[]; | ||
| } | ||
| /** | ||
| * 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>; | ||
@@ -34,3 +49,3 @@ interface ContractProcedureBuilder<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> { | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} | ||
| * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} | ||
| */ | ||
@@ -42,3 +57,3 @@ errors<U extends ErrorMap>(errors: U): ContractProcedureBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs} | ||
| * @see {@link https://orpc.dev/docs/metadata Metadata Docs} | ||
| */ | ||
@@ -51,4 +66,4 @@ meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs} | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs} | ||
| * @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} | ||
| */ | ||
@@ -59,3 +74,3 @@ route(route: Route): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs} | ||
| * @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs} | ||
| */ | ||
@@ -66,3 +81,3 @@ input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs} | ||
| * @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs} | ||
| */ | ||
@@ -76,3 +91,3 @@ output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} | ||
| * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} | ||
| */ | ||
@@ -84,3 +99,3 @@ errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs} | ||
| * @see {@link https://orpc.dev/docs/metadata Metadata Docs} | ||
| */ | ||
@@ -93,4 +108,4 @@ meta(meta: TMeta): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs} | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs} | ||
| * @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} | ||
| */ | ||
@@ -101,3 +116,3 @@ route(route: Route): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs} | ||
| * @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs} | ||
| */ | ||
@@ -111,3 +126,3 @@ output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInputOutput<TInputSchema, U, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} | ||
| * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} | ||
| */ | ||
@@ -119,3 +134,3 @@ errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs} | ||
| * @see {@link https://orpc.dev/docs/metadata Metadata Docs} | ||
| */ | ||
@@ -128,4 +143,4 @@ meta(meta: TMeta): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs} | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs} | ||
| * @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} | ||
| */ | ||
@@ -136,3 +151,3 @@ route(route: Route): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs} | ||
| * @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs} | ||
| */ | ||
@@ -146,3 +161,3 @@ input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInputOutput<U, TOutputSchema, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} | ||
| * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} | ||
| */ | ||
@@ -154,3 +169,3 @@ errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs} | ||
| * @see {@link https://orpc.dev/docs/metadata Metadata Docs} | ||
| */ | ||
@@ -163,4 +178,4 @@ meta(meta: TMeta): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs} | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs} | ||
| * @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} | ||
| */ | ||
@@ -178,3 +193,3 @@ route(route: Route): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} | ||
| * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} | ||
| */ | ||
@@ -188,3 +203,3 @@ 'errors'<U extends ErrorMap>(errors: U): ContractRouterBuilder<MergedErrorMap<TErrorMap, U>, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs} | ||
| * @see {@link https://orpc.dev/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs} | ||
| */ | ||
@@ -196,3 +211,3 @@ 'prefix'(prefix: HTTPPath): ContractRouterBuilder<TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs} | ||
| * @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs} | ||
| */ | ||
@@ -203,3 +218,3 @@ 'tag'(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs} | ||
| * @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs} | ||
| */ | ||
@@ -220,3 +235,3 @@ 'router'<T extends ContractRouter<TMeta>>(router: T): EnhancedContractRouter<T, TErrorMap>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs} | ||
| * @see {@link https://orpc.dev/docs/metadata Metadata Docs} | ||
| */ | ||
@@ -228,11 +243,17 @@ $meta<U extends Meta>(initialMeta: U): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, U & Record<never, never>>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs} | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs} | ||
| * @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.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} | ||
| * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} | ||
| */ | ||
@@ -244,3 +265,3 @@ errors<U extends ErrorMap>(errors: U): ContractBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs} | ||
| * @see {@link https://orpc.dev/docs/metadata Metadata Docs} | ||
| */ | ||
@@ -253,4 +274,4 @@ meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs} | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs} | ||
| * @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} | ||
| */ | ||
@@ -261,3 +282,3 @@ route(route: Route): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs} | ||
| * @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs} | ||
| */ | ||
@@ -268,3 +289,3 @@ input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs} | ||
| * @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs} | ||
| */ | ||
@@ -278,3 +299,3 @@ output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs} | ||
| * @see {@link https://orpc.dev/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs} | ||
| */ | ||
@@ -286,3 +307,3 @@ prefix(prefix: HTTPPath): ContractRouterBuilder<TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs} | ||
| * @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs} | ||
| */ | ||
@@ -293,3 +314,3 @@ tag(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs} | ||
| * @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs} | ||
| */ | ||
@@ -316,3 +337,3 @@ router<T extends ContractRouter<TMeta>>(router: T): EnhancedContractRouter<T, TErrorMap>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/event-iterator#validate-event-iterator Validate Event Iterator Docs} | ||
| * @see {@link https://orpc.dev/docs/event-iterator#validate-event-iterator Validate Event Iterator Docs} | ||
| */ | ||
@@ -325,3 +346,3 @@ 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>>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/client/rpc-link#custom-request-method RPCLink Custom Request Method} | ||
| * @see {@link https://orpc.dev/docs/client/rpc-link#custom-request-method RPCLink Custom Request Method} | ||
| */ | ||
@@ -338,3 +359,3 @@ declare function inferRPCMethodFromContractRouter(contract: AnyContractRouter): (options: unknown, path: readonly string[]) => Exclude<HTTPMethod, 'HEAD'>; | ||
| 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 }; | ||
| export type { ContractBuilderDef, ContractConfig, ContractProcedureBuilder, ContractProcedureBuilderWithInput, ContractProcedureBuilderWithInputOutput, ContractProcedureBuilderWithOutput, ContractProcedureClient, ContractRouterBuilder, ContractRouterClient, EnhanceContractRouterOptions, EnhancedContractRouter, EventIteratorSchemaDetails }; | ||
| 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 }; |
+64
-43
| 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.CvRxURhn.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.CvRxURhn.js'; | ||
| 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'; | ||
@@ -24,5 +24,20 @@ export { AsyncIteratorClass, Registry, ThrowableError } from '@orpc/shared'; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/contract-first/router-to-contract#minify-export-the-contract-router-for-the-client Router to Contract Docs} | ||
| * @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[]; | ||
| } | ||
| /** | ||
| * 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>; | ||
@@ -34,3 +49,3 @@ interface ContractProcedureBuilder<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> { | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} | ||
| * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} | ||
| */ | ||
@@ -42,3 +57,3 @@ errors<U extends ErrorMap>(errors: U): ContractProcedureBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs} | ||
| * @see {@link https://orpc.dev/docs/metadata Metadata Docs} | ||
| */ | ||
@@ -51,4 +66,4 @@ meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs} | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs} | ||
| * @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} | ||
| */ | ||
@@ -59,3 +74,3 @@ route(route: Route): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs} | ||
| * @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs} | ||
| */ | ||
@@ -66,3 +81,3 @@ input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs} | ||
| * @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs} | ||
| */ | ||
@@ -76,3 +91,3 @@ output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} | ||
| * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} | ||
| */ | ||
@@ -84,3 +99,3 @@ errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs} | ||
| * @see {@link https://orpc.dev/docs/metadata Metadata Docs} | ||
| */ | ||
@@ -93,4 +108,4 @@ meta(meta: TMeta): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs} | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs} | ||
| * @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} | ||
| */ | ||
@@ -101,3 +116,3 @@ route(route: Route): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs} | ||
| * @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs} | ||
| */ | ||
@@ -111,3 +126,3 @@ output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInputOutput<TInputSchema, U, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} | ||
| * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} | ||
| */ | ||
@@ -119,3 +134,3 @@ errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs} | ||
| * @see {@link https://orpc.dev/docs/metadata Metadata Docs} | ||
| */ | ||
@@ -128,4 +143,4 @@ meta(meta: TMeta): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs} | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs} | ||
| * @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} | ||
| */ | ||
@@ -136,3 +151,3 @@ route(route: Route): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs} | ||
| * @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs} | ||
| */ | ||
@@ -146,3 +161,3 @@ input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInputOutput<U, TOutputSchema, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} | ||
| * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} | ||
| */ | ||
@@ -154,3 +169,3 @@ errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs} | ||
| * @see {@link https://orpc.dev/docs/metadata Metadata Docs} | ||
| */ | ||
@@ -163,4 +178,4 @@ meta(meta: TMeta): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs} | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs} | ||
| * @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} | ||
| */ | ||
@@ -178,3 +193,3 @@ route(route: Route): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} | ||
| * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} | ||
| */ | ||
@@ -188,3 +203,3 @@ 'errors'<U extends ErrorMap>(errors: U): ContractRouterBuilder<MergedErrorMap<TErrorMap, U>, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs} | ||
| * @see {@link https://orpc.dev/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs} | ||
| */ | ||
@@ -196,3 +211,3 @@ 'prefix'(prefix: HTTPPath): ContractRouterBuilder<TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs} | ||
| * @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs} | ||
| */ | ||
@@ -203,3 +218,3 @@ 'tag'(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs} | ||
| * @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs} | ||
| */ | ||
@@ -220,3 +235,3 @@ 'router'<T extends ContractRouter<TMeta>>(router: T): EnhancedContractRouter<T, TErrorMap>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs} | ||
| * @see {@link https://orpc.dev/docs/metadata Metadata Docs} | ||
| */ | ||
@@ -228,11 +243,17 @@ $meta<U extends Meta>(initialMeta: U): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, U & Record<never, never>>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs} | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs} | ||
| * @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.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} | ||
| * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} | ||
| */ | ||
@@ -244,3 +265,3 @@ errors<U extends ErrorMap>(errors: U): ContractBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs} | ||
| * @see {@link https://orpc.dev/docs/metadata Metadata Docs} | ||
| */ | ||
@@ -253,4 +274,4 @@ meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs} | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs} | ||
| * @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} | ||
| */ | ||
@@ -261,3 +282,3 @@ route(route: Route): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs} | ||
| * @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs} | ||
| */ | ||
@@ -268,3 +289,3 @@ input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs} | ||
| * @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs} | ||
| */ | ||
@@ -278,3 +299,3 @@ output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs} | ||
| * @see {@link https://orpc.dev/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs} | ||
| */ | ||
@@ -286,3 +307,3 @@ prefix(prefix: HTTPPath): ContractRouterBuilder<TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs} | ||
| * @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs} | ||
| */ | ||
@@ -293,3 +314,3 @@ tag(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs} | ||
| * @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs} | ||
| */ | ||
@@ -316,3 +337,3 @@ router<T extends ContractRouter<TMeta>>(router: T): EnhancedContractRouter<T, TErrorMap>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/event-iterator#validate-event-iterator Validate Event Iterator Docs} | ||
| * @see {@link https://orpc.dev/docs/event-iterator#validate-event-iterator Validate Event Iterator Docs} | ||
| */ | ||
@@ -325,3 +346,3 @@ 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>>; | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/client/rpc-link#custom-request-method RPCLink Custom Request Method} | ||
| * @see {@link https://orpc.dev/docs/client/rpc-link#custom-request-method RPCLink Custom Request Method} | ||
| */ | ||
@@ -338,3 +359,3 @@ declare function inferRPCMethodFromContractRouter(contract: AnyContractRouter): (options: unknown, path: readonly string[]) => Exclude<HTTPMethod, 'HEAD'>; | ||
| 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 }; | ||
| export type { ContractBuilderDef, ContractConfig, ContractProcedureBuilder, ContractProcedureBuilderWithInput, ContractProcedureBuilderWithInputOutput, ContractProcedureBuilderWithOutput, ContractProcedureClient, ContractRouterBuilder, ContractRouterClient, EnhanceContractRouterOptions, EnhancedContractRouter, EventIteratorSchemaDetails }; | ||
| 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 }; |
+59
-15
| 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, get, isTypescriptObject, isPropertyKey } from '@orpc/shared'; | ||
| export { AsyncIteratorClass } from '@orpc/shared'; | ||
@@ -57,2 +58,5 @@ function mergeMeta(meta1, meta2) { | ||
| } | ||
| if (typeof current !== "object") { | ||
| return void 0; | ||
| } | ||
| current = current[segment]; | ||
@@ -71,2 +75,5 @@ } | ||
| } | ||
| if (typeof router !== "object" || router === null) { | ||
| return router; | ||
| } | ||
| const enhanced = {}; | ||
@@ -89,2 +96,5 @@ for (const key in router) { | ||
| } | ||
| if (typeof router !== "object" || router === null) { | ||
| return router; | ||
| } | ||
| const json = {}; | ||
@@ -96,2 +106,25 @@ for (const key in router) { | ||
| } | ||
| 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; | ||
| } | ||
@@ -107,3 +140,3 @@ class ContractBuilder extends ContractProcedure { | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs} | ||
| * @see {@link https://orpc.dev/docs/metadata Metadata Docs} | ||
| */ | ||
@@ -120,4 +153,4 @@ $meta(initialMeta) { | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs} | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs} | ||
| * @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} | ||
| */ | ||
@@ -131,6 +164,17 @@ $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.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} | ||
| * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs} | ||
| */ | ||
@@ -147,3 +191,3 @@ errors(errors) { | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs} | ||
| * @see {@link https://orpc.dev/docs/metadata Metadata Docs} | ||
| */ | ||
@@ -161,4 +205,4 @@ meta(meta) { | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs} | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs} | ||
| * @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} | ||
| */ | ||
@@ -174,3 +218,3 @@ route(route) { | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs} | ||
| * @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs} | ||
| */ | ||
@@ -186,3 +230,3 @@ input(schema) { | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs} | ||
| * @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs} | ||
| */ | ||
@@ -201,3 +245,3 @@ output(schema) { | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs} | ||
| * @see {@link https://orpc.dev/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs} | ||
| */ | ||
@@ -214,3 +258,3 @@ prefix(prefix) { | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs} | ||
| * @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs} | ||
| */ | ||
@@ -226,3 +270,3 @@ tag(...tags) { | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs} | ||
| * @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs} | ||
| */ | ||
@@ -340,2 +384,2 @@ router(router) { | ||
| export { ContractBuilder, ContractProcedure, ValidationError, enhanceContractRouter, enhanceRoute, eventIterator, fallbackContractConfig, getContractRouter, getEventIteratorSchemaDetails, inferRPCMethodFromContractRouter, isContractProcedure, isSchemaIssue, mergeErrorMap, mergeMeta, mergePrefix, mergeRoute, mergeTags, minifyContractRouter, oc, prefixRoute, type, unshiftTagRoute }; | ||
| export { ContractBuilder, ContractProcedure, ValidationError, enhanceContractRouter, enhanceRoute, eventIterator, fallbackContractConfig, getContractRouter, getEventIteratorSchemaDetails, inferRPCMethodFromContractRouter, isContractProcedure, isSchemaIssue, mergeErrorMap, mergeMeta, mergePrefix, mergeRoute, mergeTags, minifyContractRouter, oc, populateContractRouterPaths, prefixRoute, type, unshiftTagRoute }; |
| import { ClientContext } from '@orpc/client'; | ||
| import { StandardLinkPlugin, StandardLinkOptions } from '@orpc/client/standard'; | ||
| import { A as AnyContractRouter } from '../shared/contract.CvRxURhn.mjs'; | ||
| import { A as AnyContractRouter } from '../shared/contract.TuRtB1Ca.mjs'; | ||
| import '@orpc/shared'; | ||
@@ -15,3 +15,3 @@ import '@standard-schema/spec'; | ||
| * @throws {ORPCError} with code `BAD_REQUEST` (same as server side) if input doesn't match the expected schema | ||
| * @see {@link https://orpc.unnoq.com/docs/plugins/request-validation Request Validation Plugin Docs} | ||
| * @see {@link https://orpc.dev/docs/plugins/request-validation Request Validation Plugin Docs} | ||
| */ | ||
@@ -31,3 +31,3 @@ declare class RequestValidationPlugin<T extends ClientContext> implements StandardLinkPlugin<T> { | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/plugins/response-validation Response Validation Plugin Docs} | ||
| * @see {@link https://orpc.dev/docs/plugins/response-validation Response Validation Plugin Docs} | ||
| */ | ||
@@ -34,0 +34,0 @@ declare class ResponseValidationPlugin<T extends ClientContext> implements StandardLinkPlugin<T> { |
| import { ClientContext } from '@orpc/client'; | ||
| import { StandardLinkPlugin, StandardLinkOptions } from '@orpc/client/standard'; | ||
| import { A as AnyContractRouter } from '../shared/contract.CvRxURhn.js'; | ||
| import { A as AnyContractRouter } from '../shared/contract.TuRtB1Ca.js'; | ||
| import '@orpc/shared'; | ||
@@ -15,3 +15,3 @@ import '@standard-schema/spec'; | ||
| * @throws {ORPCError} with code `BAD_REQUEST` (same as server side) if input doesn't match the expected schema | ||
| * @see {@link https://orpc.unnoq.com/docs/plugins/request-validation Request Validation Plugin Docs} | ||
| * @see {@link https://orpc.dev/docs/plugins/request-validation Request Validation Plugin Docs} | ||
| */ | ||
@@ -31,3 +31,3 @@ declare class RequestValidationPlugin<T extends ClientContext> implements StandardLinkPlugin<T> { | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/plugins/response-validation Response Validation Plugin Docs} | ||
| * @see {@link https://orpc.dev/docs/plugins/response-validation Response Validation Plugin Docs} | ||
| */ | ||
@@ -34,0 +34,0 @@ declare class ResponseValidationPlugin<T extends ClientContext> implements StandardLinkPlugin<T> { |
+9
-10
| { | ||
| "name": "@orpc/contract", | ||
| "type": "module", | ||
| "version": "0.0.0-next.907c00c", | ||
| "version": "0.0.0-next.90a4d22", | ||
| "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" | ||
@@ -32,11 +31,11 @@ ], | ||
| "dependencies": { | ||
| "@standard-schema/spec": "^1.0.0", | ||
| "@standard-schema/spec": "^1.1.0", | ||
| "openapi-types": "^12.1.3", | ||
| "@orpc/client": "0.0.0-next.907c00c", | ||
| "@orpc/shared": "0.0.0-next.907c00c" | ||
| "@orpc/client": "0.0.0-next.90a4d22", | ||
| "@orpc/shared": "0.0.0-next.90a4d22" | ||
| }, | ||
| "devDependencies": { | ||
| "arktype": "2.1.22", | ||
| "valibot": "^1.1.0", | ||
| "zod": "^4.1.11" | ||
| "arktype": "2.2.0", | ||
| "valibot": "^1.2.0", | ||
| "zod": "^4.3.6" | ||
| }, | ||
@@ -43,0 +42,0 @@ "scripts": { |
+115
-13
| <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,3 +22,3 @@ <a href="https://discord.gg/TXEbwRBvQn"> | ||
| </a> | ||
| <a href="https://deepwiki.com/unnoq/orpc"> | ||
| <a href="https://deepwiki.com/middleapi/orpc"> | ||
| <img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki"> | ||
@@ -51,3 +51,3 @@ </a> | ||
| You can find the full documentation [here](https://orpc.unnoq.com). | ||
| You can find the full documentation [here](https://orpc.dev). | ||
@@ -73,3 +73,3 @@ ## Packages | ||
| 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. | ||
@@ -111,6 +111,108 @@ ```ts | ||
| <p align="center"> | ||
| <a href="https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg"> | ||
| <img src='https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg'/> | ||
| </a> | ||
| 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> | ||
| ### 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="209" 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="167" 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&v=4" width="167" 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="167" 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&v=4" width="167" 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&v=4" width="167" alt="herrfugbaum"/><br />herrfugbaum</a></td> | ||
| </tr> | ||
| <tr> | ||
| <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&v=4" width="167" alt="Ryota Murakami"/><br />Ryota Murakami</a></td> | ||
| <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="167" 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&v=4" width="167" 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&v=4" width="167" 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&v=4" width="167" alt="Kyle Mistele"/><br />Kyle Mistele</a></td> | ||
| </tr> | ||
| <tr> | ||
| <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="167" 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&v=4" width="167" alt="Ryan Vogel"/><br />Ryan Vogel</a></td> | ||
| <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="167" 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&v=4" width="167" 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&v=4" width="167" alt="Chen, Zhi-Yuan"/><br />Chen, Zhi-Yuan</a></td> | ||
| </tr> | ||
| <tr> | ||
| <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&v=4" width="167" 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&v=4" width="139" 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&v=4" width="139" 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="139" 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&v=4" width="139" 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&v=4" width="139" 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&v=4" width="139" alt="Denis"/><br />Denis</a></td> | ||
| </tr> | ||
| <tr> | ||
| <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&v=4" width="139" alt="Christopher Kapic"/><br />Christopher Kapic</a></td> | ||
| <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&v=4" width="139" 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&v=4" width="139" 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&v=4" width="139" 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&v=4" width="139" 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&v=4" width="139" alt="Anees Iqbal"/><br />Anees Iqbal</a></td> | ||
| </tr> | ||
| <tr> | ||
| <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&v=4" width="139" 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&v=4" width="139" alt="Alex"/><br />Alex</a></td> | ||
| <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&v=4" width="139" 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&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&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&v=4" width="32" height="32" alt="あわわわとーにゅ" /></a> | ||
| <a href="https://github.com/SanMurakami?ref=orpc" target="_blank" rel="noopener" title="村上さん"><img src="https://avatars.githubusercontent.com/u/37681609?u=0dd4c7e4ba937cbb52b068c55914b1d8164dc0c7&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&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&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&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&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&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&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&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&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&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&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&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&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&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&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&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&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&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&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&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&v=4" width="32" height="32" alt="Sefa Eyeoglu" /></a> | ||
| </p> | ||
@@ -120,2 +222,2 @@ | ||
| 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. |
| 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.unnoq.com/docs/procedure#type-utility Type Utility Docs} | ||
| */ | ||
| declare function type<TInput, TOutput = TInput>(...[map]: TypeRest<TInput, TOutput>): Schema<TInput, TOutput>; | ||
| interface ValidationErrorOptions extends ErrorOptions { | ||
| message: string; | ||
| issues: readonly SchemaIssue[]; | ||
| /** | ||
| * @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.unnoq.com/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.unnoq.com/docs/openapi/routing OpenAPI Routing Docs} | ||
| */ | ||
| method?: HTTPMethod; | ||
| /** | ||
| * The HTTP path of the procedure. | ||
| * This option is typically relevant when integrating with OpenAPI. | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs} | ||
| */ | ||
| path?: HTTPPath; | ||
| /** | ||
| * The 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.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs} | ||
| */ | ||
| summary?: string; | ||
| /** | ||
| * The description of the procedure. | ||
| * This option is typically relevant when integrating with OpenAPI. | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs} | ||
| */ | ||
| description?: string; | ||
| /** | ||
| * Marks the procedure as deprecated. | ||
| * This option is typically relevant when integrating with OpenAPI. | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs} | ||
| */ | ||
| deprecated?: boolean; | ||
| /** | ||
| * The tags of the procedure. | ||
| * This option is typically relevant when integrating with OpenAPI. | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs} | ||
| */ | ||
| tags?: readonly string[]; | ||
| /** | ||
| * The status code of the response when the procedure is successful. | ||
| * The status code must be in the 200-399 range. | ||
| * This option is typically relevant when integrating with OpenAPI. | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs} | ||
| * @default 200 | ||
| */ | ||
| successStatus?: number; | ||
| /** | ||
| * The description of the response when the procedure is successful. | ||
| * This option is typically relevant when integrating with OpenAPI. | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs} | ||
| * @default 'OK' | ||
| */ | ||
| successDescription?: string; | ||
| /** | ||
| * Determines how the input should be structured based on `params`, `query`, `headers`, and `body`. | ||
| * | ||
| * @option 'compact' | ||
| * Combines `params` and either `query` or `body` (depending on the HTTP method) into a single object. | ||
| * | ||
| * @option 'detailed' | ||
| * Keeps each part of the request (`params`, `query`, `headers`, and `body`) as separate fields in the input object. | ||
| * | ||
| * Example: | ||
| * ```ts | ||
| * const input = { | ||
| * params: { id: 1 }, | ||
| * query: { search: 'hello' }, | ||
| * headers: { 'Content-Type': 'application/json' }, | ||
| * body: { name: 'John' }, | ||
| * } | ||
| * ``` | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs} | ||
| * @default 'compact' | ||
| */ | ||
| inputStructure?: InputStructure; | ||
| /** | ||
| * Determines how the response should be structured based on the output. | ||
| * | ||
| * @option 'compact' | ||
| * The output data is directly returned as the response body. | ||
| * | ||
| * @option 'detailed' | ||
| * Return an object with optional properties: | ||
| * - `status`: The response status (must be in 200-399 range) if not set fallback to `successStatus`. | ||
| * - `headers`: Custom headers to merge with the response headers (`Record<string, string | string[] | undefined>`) | ||
| * - `body`: The response body. | ||
| * | ||
| * Example: | ||
| * ```ts | ||
| * const output = { | ||
| * status: 201, | ||
| * headers: { 'x-custom-header': 'value' }, | ||
| * body: { message: 'Hello, world!' }, | ||
| * }; | ||
| * ``` | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs} | ||
| * @default 'compact' | ||
| */ | ||
| outputStructure?: OutputStructure; | ||
| /** | ||
| * Override entire auto-generated OpenAPI Operation Object Specification. | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata Operation Metadata Docs} | ||
| */ | ||
| spec?: OpenAPIV3_1.OperationObject | ((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.unnoq.com/docs/contract-first/define-contract#procedure-contract Contract Procedure Docs} | ||
| */ | ||
| declare class ContractProcedure<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> { | ||
| /** | ||
| * This property holds the defined options for the contract procedure. | ||
| */ | ||
| '~orpc': ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
| constructor(def: ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>); | ||
| } | ||
| type AnyContractProcedure = ContractProcedure<any, any, any, any>; | ||
| declare function isContractProcedure(item: unknown): item is AnyContractProcedure; | ||
| /** | ||
| * Represents a contract router, which defines a hierarchical structure of contract procedures. | ||
| * | ||
| * @info A contract procedure is a contract router too. | ||
| * @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#contract-router Contract Router Docs} | ||
| */ | ||
| type ContractRouter<TMeta extends Meta> = ContractProcedure<any, any, any, TMeta> | { | ||
| [k: string]: ContractRouter<TMeta>; | ||
| }; | ||
| type AnyContractRouter = ContractRouter<any>; | ||
| /** | ||
| * Infer all inputs of the contract router. | ||
| * | ||
| * @info A contract procedure is a contract router too. | ||
| * @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#utilities Contract Utilities Docs} | ||
| */ | ||
| type InferContractRouterInputs<T extends AnyContractRouter> = T extends ContractProcedure<infer UInputSchema, any, any, any> ? InferSchemaInput<UInputSchema> : { | ||
| [K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterInputs<T[K]> : never; | ||
| }; | ||
| /** | ||
| * Infer all outputs of the contract router. | ||
| * | ||
| * @info A contract procedure is a contract router too. | ||
| * @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#utilities Contract Utilities Docs} | ||
| */ | ||
| type InferContractRouterOutputs<T extends AnyContractRouter> = T extends ContractProcedure<any, infer UOutputSchema, any, any> ? InferSchemaOutput<UOutputSchema> : { | ||
| [K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterOutputs<T[K]> : never; | ||
| }; | ||
| /** | ||
| * Infer all errors of the contract router. | ||
| * | ||
| * @info A contract procedure is a contract router too. | ||
| * @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#utilities Contract Utilities Docs} | ||
| */ | ||
| type InferContractRouterErrorMap<T extends AnyContractRouter> = T extends ContractProcedure<any, any, infer UErrorMap, any> ? UErrorMap : { | ||
| [K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterErrorMap<T[K]> : never; | ||
| }[keyof T]; | ||
| type InferContractRouterMeta<T extends AnyContractRouter> = T extends ContractRouter<infer UMeta> ? UMeta : never; | ||
| 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.unnoq.com/docs/procedure#type-utility Type Utility Docs} | ||
| */ | ||
| declare function type<TInput, TOutput = TInput>(...[map]: TypeRest<TInput, TOutput>): Schema<TInput, TOutput>; | ||
| interface ValidationErrorOptions extends ErrorOptions { | ||
| message: string; | ||
| issues: readonly SchemaIssue[]; | ||
| /** | ||
| * @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.unnoq.com/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.unnoq.com/docs/openapi/routing OpenAPI Routing Docs} | ||
| */ | ||
| method?: HTTPMethod; | ||
| /** | ||
| * The HTTP path of the procedure. | ||
| * This option is typically relevant when integrating with OpenAPI. | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs} | ||
| */ | ||
| path?: HTTPPath; | ||
| /** | ||
| * The 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.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs} | ||
| */ | ||
| summary?: string; | ||
| /** | ||
| * The description of the procedure. | ||
| * This option is typically relevant when integrating with OpenAPI. | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs} | ||
| */ | ||
| description?: string; | ||
| /** | ||
| * Marks the procedure as deprecated. | ||
| * This option is typically relevant when integrating with OpenAPI. | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs} | ||
| */ | ||
| deprecated?: boolean; | ||
| /** | ||
| * The tags of the procedure. | ||
| * This option is typically relevant when integrating with OpenAPI. | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs} | ||
| */ | ||
| tags?: readonly string[]; | ||
| /** | ||
| * The status code of the response when the procedure is successful. | ||
| * The status code must be in the 200-399 range. | ||
| * This option is typically relevant when integrating with OpenAPI. | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs} | ||
| * @default 200 | ||
| */ | ||
| successStatus?: number; | ||
| /** | ||
| * The description of the response when the procedure is successful. | ||
| * This option is typically relevant when integrating with OpenAPI. | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs} | ||
| * @default 'OK' | ||
| */ | ||
| successDescription?: string; | ||
| /** | ||
| * Determines how the input should be structured based on `params`, `query`, `headers`, and `body`. | ||
| * | ||
| * @option 'compact' | ||
| * Combines `params` and either `query` or `body` (depending on the HTTP method) into a single object. | ||
| * | ||
| * @option 'detailed' | ||
| * Keeps each part of the request (`params`, `query`, `headers`, and `body`) as separate fields in the input object. | ||
| * | ||
| * Example: | ||
| * ```ts | ||
| * const input = { | ||
| * params: { id: 1 }, | ||
| * query: { search: 'hello' }, | ||
| * headers: { 'Content-Type': 'application/json' }, | ||
| * body: { name: 'John' }, | ||
| * } | ||
| * ``` | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs} | ||
| * @default 'compact' | ||
| */ | ||
| inputStructure?: InputStructure; | ||
| /** | ||
| * Determines how the response should be structured based on the output. | ||
| * | ||
| * @option 'compact' | ||
| * The output data is directly returned as the response body. | ||
| * | ||
| * @option 'detailed' | ||
| * Return an object with optional properties: | ||
| * - `status`: The response status (must be in 200-399 range) if not set fallback to `successStatus`. | ||
| * - `headers`: Custom headers to merge with the response headers (`Record<string, string | string[] | undefined>`) | ||
| * - `body`: The response body. | ||
| * | ||
| * Example: | ||
| * ```ts | ||
| * const output = { | ||
| * status: 201, | ||
| * headers: { 'x-custom-header': 'value' }, | ||
| * body: { message: 'Hello, world!' }, | ||
| * }; | ||
| * ``` | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs} | ||
| * @default 'compact' | ||
| */ | ||
| outputStructure?: OutputStructure; | ||
| /** | ||
| * Override entire auto-generated OpenAPI Operation Object Specification. | ||
| * | ||
| * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata Operation Metadata Docs} | ||
| */ | ||
| spec?: OpenAPIV3_1.OperationObject | ((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.unnoq.com/docs/contract-first/define-contract#procedure-contract Contract Procedure Docs} | ||
| */ | ||
| declare class ContractProcedure<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> { | ||
| /** | ||
| * This property holds the defined options for the contract procedure. | ||
| */ | ||
| '~orpc': ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
| constructor(def: ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>); | ||
| } | ||
| type AnyContractProcedure = ContractProcedure<any, any, any, any>; | ||
| declare function isContractProcedure(item: unknown): item is AnyContractProcedure; | ||
| /** | ||
| * Represents a contract router, which defines a hierarchical structure of contract procedures. | ||
| * | ||
| * @info A contract procedure is a contract router too. | ||
| * @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#contract-router Contract Router Docs} | ||
| */ | ||
| type ContractRouter<TMeta extends Meta> = ContractProcedure<any, any, any, TMeta> | { | ||
| [k: string]: ContractRouter<TMeta>; | ||
| }; | ||
| type AnyContractRouter = ContractRouter<any>; | ||
| /** | ||
| * Infer all inputs of the contract router. | ||
| * | ||
| * @info A contract procedure is a contract router too. | ||
| * @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#utilities Contract Utilities Docs} | ||
| */ | ||
| type InferContractRouterInputs<T extends AnyContractRouter> = T extends ContractProcedure<infer UInputSchema, any, any, any> ? InferSchemaInput<UInputSchema> : { | ||
| [K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterInputs<T[K]> : never; | ||
| }; | ||
| /** | ||
| * Infer all outputs of the contract router. | ||
| * | ||
| * @info A contract procedure is a contract router too. | ||
| * @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#utilities Contract Utilities Docs} | ||
| */ | ||
| type InferContractRouterOutputs<T extends AnyContractRouter> = T extends ContractProcedure<any, infer UOutputSchema, any, any> ? InferSchemaOutput<UOutputSchema> : { | ||
| [K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterOutputs<T[K]> : never; | ||
| }; | ||
| /** | ||
| * Infer all errors of the contract router. | ||
| * | ||
| * @info A contract procedure is a contract router too. | ||
| * @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#utilities Contract Utilities Docs} | ||
| */ | ||
| type InferContractRouterErrorMap<T extends AnyContractRouter> = T extends ContractProcedure<any, any, infer UErrorMap, any> ? UErrorMap : { | ||
| [K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterErrorMap<T[K]> : never; | ||
| }[keyof T]; | ||
| type InferContractRouterMeta<T extends AnyContractRouter> = T extends ContractRouter<infer UMeta> ? UMeta : never; | ||
| 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 }; |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
108724
22.77%1102
6.27%217
88.7%0
-100%5
400%+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
Updated