@orpc/contract 0.0.0-next.589c5b1 → 0.0.0-next.5a170fe

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,210 +1,267 @@
1
- import { ORPCErrorCode, ORPCError, HTTPMethod, HTTPPath, ClientContext, Client } from '@orpc/client';
1
+ import { HTTPPath, HTTPMethod, ClientContext, Client } from '@orpc/client';
2
2
  export { HTTPMethod, HTTPPath, ORPCError } from '@orpc/client';
3
- import { Promisable, IsEqual, ThrowableError } from '@orpc/shared';
3
+ 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';
4
+ 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';
5
+ export { OpenAPIV3_1 as OpenAPI } from 'openapi-types';
4
6
  export { Registry, ThrowableError } from '@orpc/shared';
5
- import { StandardSchemaV1 } from '@standard-schema/spec';
7
+ import '@standard-schema/spec';
6
8
 
7
- type Schema<TInput, TOutput> = StandardSchemaV1<TInput, TOutput>;
8
- type AnySchema = Schema<any, any>;
9
- type SchemaIssue = StandardSchemaV1.Issue;
10
- type InferSchemaInput<T extends AnySchema> = T extends StandardSchemaV1<infer UInput, any> ? UInput : never;
11
- type InferSchemaOutput<T extends AnySchema> = T extends StandardSchemaV1<any, infer UOutput> ? UOutput : never;
12
- type TypeRest<TInput, TOutput> = [map: (input: TInput) => Promisable<TOutput>] | (IsEqual<TInput, TOutput> extends true ? [] : never);
13
- declare function type<TInput, TOutput = TInput>(...[map]: TypeRest<TInput, TOutput>): Schema<TInput, TOutput>;
14
-
15
- interface ValidationErrorOptions extends ErrorOptions {
16
- message: string;
17
- issues: readonly SchemaIssue[];
18
- }
19
- declare class ValidationError extends Error {
20
- readonly issues: readonly SchemaIssue[];
21
- constructor(options: ValidationErrorOptions);
22
- }
23
- interface ErrorMapItem<TDataSchema extends AnySchema> {
24
- status?: number;
25
- message?: string;
26
- data?: TDataSchema;
27
- }
28
- type ErrorMap = {
29
- [key in ORPCErrorCode]?: ErrorMapItem<AnySchema>;
9
+ declare function getContractRouter(router: AnyContractRouter, path: readonly string[]): AnyContractRouter | undefined;
10
+ type EnhancedContractRouter<T extends AnyContractRouter, TErrorMap extends ErrorMap> = T extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrors, infer UMeta> ? ContractProcedure<UInputSchema, UOutputSchema, MergedErrorMap<TErrorMap, UErrors>, UMeta> : {
11
+ [K in keyof T]: T[K] extends AnyContractRouter ? EnhancedContractRouter<T[K], TErrorMap> : never;
30
12
  };
31
- type MergedErrorMap<T1 extends ErrorMap, T2 extends ErrorMap> = Omit<T1, keyof T2> & T2;
32
- declare function mergeErrorMap<T1 extends ErrorMap, T2 extends ErrorMap>(errorMap1: T1, errorMap2: T2): MergedErrorMap<T1, T2>;
33
- type ORPCErrorFromErrorMap<TErrorMap extends ErrorMap> = {
34
- [K in keyof TErrorMap]: K extends string ? TErrorMap[K] extends ErrorMapItem<infer TDataSchema extends Schema<unknown, unknown>> ? ORPCError<K, InferSchemaOutput<TDataSchema>> : never : never;
35
- }[keyof TErrorMap];
36
- type ErrorFromErrorMap<TErrorMap extends ErrorMap> = ORPCErrorFromErrorMap<TErrorMap> | ThrowableError;
37
-
38
- type Meta = Record<string, any>;
39
- declare function mergeMeta<T extends Meta>(meta1: T, meta2: T): T;
13
+ interface EnhanceContractRouterOptions<TErrorMap extends ErrorMap> extends EnhanceRouteOptions {
14
+ errorMap: TErrorMap;
15
+ }
16
+ declare function enhanceContractRouter<T extends AnyContractRouter, TErrorMap extends ErrorMap>(router: T, options: EnhanceContractRouterOptions<TErrorMap>): EnhancedContractRouter<T, TErrorMap>;
17
+ /**
18
+ * Minify a contract router into a smaller object.
19
+ *
20
+ * You should export the result to a JSON file. On the client side, you can import this JSON file and use it as a contract router.
21
+ * This reduces the size of the contract and helps prevent leaking internal details of the router to the client.
22
+ *
23
+ * @see {@link https://orpc.unnoq.com/docs/contract-first/router-to-contract#minify-export-the-contract-router-for-the-client Router to Contract Docs}
24
+ */
25
+ declare function minifyContractRouter(router: AnyContractRouter): AnyContractRouter;
40
26
 
41
- type InputStructure = 'compact' | 'detailed';
42
- type OutputStructure = 'compact' | 'detailed';
43
- interface Route {
44
- method?: HTTPMethod;
45
- path?: HTTPPath;
46
- summary?: string;
47
- description?: string;
48
- deprecated?: boolean;
49
- tags?: readonly string[];
27
+ interface ContractProcedureBuilder<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
50
28
  /**
51
- * The status code of the response when the procedure is successful.
29
+ * Adds type-safe custom errors to the contract.
30
+ * The provided errors are spared-merged with any existing errors in the contract.
52
31
  *
53
- * @default 200
32
+ * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
54
33
  */
55
- successStatus?: number;
34
+ errors<U extends ErrorMap>(errors: U): ContractProcedureBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
56
35
  /**
57
- * The description of the response when the procedure is successful.
36
+ * Sets or updates the metadata for the contract.
37
+ * The provided metadata is spared-merged with any existing metadata in the contract.
58
38
  *
59
- * @default 'OK'
39
+ * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
60
40
  */
61
- successDescription?: string;
41
+ meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
62
42
  /**
63
- * Determines how the input should be structured based on `params`, `query`, `headers`, and `body`.
64
- *
65
- * @option 'compact'
66
- * Combines `params` and either `query` or `body` (depending on the HTTP method) into a single object.
43
+ * Sets or updates the route definition for the contract.
44
+ * The provided route is spared-merged with any existing route in the contract.
45
+ * This option is typically relevant when integrating with OpenAPI.
67
46
  *
68
- * @option 'detailed'
69
- * Keeps each part of the request (`params`, `query`, `headers`, and `body`) as separate fields in the input object.
70
- *
71
- * Example:
72
- * ```ts
73
- * const input = {
74
- * params: { id: 1 },
75
- * query: { search: 'hello' },
76
- * headers: { 'Content-Type': 'application/json' },
77
- * body: { name: 'John' },
78
- * }
79
- * ```
80
- *
81
- * @default 'compact'
47
+ * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
48
+ * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
82
49
  */
83
- inputStructure?: InputStructure;
50
+ route(route: Route): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
84
51
  /**
85
- * Determines how the response should be structured based on the output.
86
- *
87
- * @option 'compact'
88
- * Includes only the body data, encoded directly in the response.
52
+ * Defines the input validation schema for the contract.
89
53
  *
90
- * @option 'detailed'
91
- * Separates the output into `headers` and `body` fields.
92
- * - `headers`: Custom headers to merge with the response headers.
93
- * - `body`: The response data.
94
- *
95
- * Example:
96
- * ```ts
97
- * const output = {
98
- * headers: { 'x-custom-header': 'value' },
99
- * body: { message: 'Hello, world!' },
100
- * };
101
- * ```
102
- *
103
- * @default 'compact'
54
+ * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
104
55
  */
105
- outputStructure?: OutputStructure;
106
- }
107
- declare function mergeRoute(a: Route, b: Route): Route;
108
- declare function prefixRoute(route: Route, prefix: HTTPPath): Route;
109
- declare function unshiftTagRoute(route: Route, tags: readonly string[]): Route;
110
- declare function mergePrefix(a: HTTPPath | undefined, b: HTTPPath): HTTPPath;
111
- declare function mergeTags(a: readonly string[] | undefined, b: readonly string[]): readonly string[];
112
- interface EnhanceRouteOptions {
113
- prefix?: HTTPPath;
114
- tags?: readonly string[];
115
- }
116
- declare function enhanceRoute(route: Route, options: EnhanceRouteOptions): Route;
117
-
118
- interface ContractProcedureDef<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
119
- meta: TMeta;
120
- route: Route;
121
- inputSchema?: TInputSchema;
122
- outputSchema?: TOutputSchema;
123
- errorMap: TErrorMap;
124
- }
125
- declare class ContractProcedure<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
126
- '~orpc': ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
127
- constructor(def: ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>);
128
- }
129
- type AnyContractProcedure = ContractProcedure<any, any, any, any>;
130
- declare function isContractProcedure(item: unknown): item is AnyContractProcedure;
131
-
132
- type ContractRouter<TMeta extends Meta> = ContractProcedure<any, any, any, TMeta> | {
133
- [k: string]: ContractRouter<TMeta>;
134
- };
135
- type AnyContractRouter = ContractRouter<any>;
136
- type InferContractRouterInputs<T extends AnyContractRouter> = T extends ContractProcedure<infer UInputSchema, any, any, any> ? InferSchemaInput<UInputSchema> : {
137
- [K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterInputs<T[K]> : never;
138
- };
139
- type InferContractRouterOutputs<T extends AnyContractRouter> = T extends ContractProcedure<any, infer UOutputSchema, any, any> ? InferSchemaOutput<UOutputSchema> : {
140
- [K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterOutputs<T[K]> : never;
141
- };
142
- type InferContractRouterErrorMap<T extends AnyContractRouter> = T extends ContractProcedure<any, any, infer UErrorMap, any> ? UErrorMap : {
143
- [K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterErrorMap<T[K]> : never;
144
- }[keyof T];
145
- type InferContractRouterMeta<T extends AnyContractRouter> = T extends ContractRouter<infer UMeta> ? UMeta : never;
146
-
147
- declare function getContractRouter(router: AnyContractRouter, path: readonly string[]): AnyContractRouter | undefined;
148
- type EnhancedContractRouter<T extends AnyContractRouter, TErrorMap extends ErrorMap> = T extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrors, infer UMeta> ? ContractProcedure<UInputSchema, UOutputSchema, MergedErrorMap<TErrorMap, UErrors>, UMeta> : {
149
- [K in keyof T]: T[K] extends AnyContractRouter ? EnhancedContractRouter<T[K], TErrorMap> : never;
150
- };
151
- interface EnhanceContractRouterOptions<TErrorMap extends ErrorMap> extends EnhanceRouteOptions {
152
- errorMap: TErrorMap;
153
- }
154
- declare function enhanceContractRouter<T extends AnyContractRouter, TErrorMap extends ErrorMap>(router: T, options: EnhanceContractRouterOptions<TErrorMap>): EnhancedContractRouter<T, TErrorMap>;
155
-
156
- interface ContractProcedureBuilder<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
157
- errors<U extends ErrorMap>(errors: U): ContractProcedureBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
158
- meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
159
- route(route: Route): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
160
56
  input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>;
57
+ /**
58
+ * Defines the output validation schema for the contract.
59
+ *
60
+ * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
61
+ */
161
62
  output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>;
162
63
  }
163
64
  interface ContractProcedureBuilderWithInput<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
65
+ /**
66
+ * Adds type-safe custom errors to the contract.
67
+ * The provided errors are spared-merged with any existing errors in the contract.
68
+ *
69
+ * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
70
+ */
164
71
  errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
72
+ /**
73
+ * Sets or updates the metadata for the contract.
74
+ * The provided metadata is spared-merged with any existing metadata in the contract.
75
+ *
76
+ * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
77
+ */
165
78
  meta(meta: TMeta): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
79
+ /**
80
+ * Sets or updates the route definition for the contract.
81
+ * The provided route is spared-merged with any existing route in the contract.
82
+ * This option is typically relevant when integrating with OpenAPI.
83
+ *
84
+ * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
85
+ * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
86
+ */
166
87
  route(route: Route): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
88
+ /**
89
+ * Defines the output validation schema for the contract.
90
+ *
91
+ * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
92
+ */
167
93
  output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInputOutput<TInputSchema, U, TErrorMap, TMeta>;
168
94
  }
169
95
  interface ContractProcedureBuilderWithOutput<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
96
+ /**
97
+ * Adds type-safe custom errors to the contract.
98
+ * The provided errors are spared-merged with any existing errors in the contract.
99
+ *
100
+ * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
101
+ */
170
102
  errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
103
+ /**
104
+ * Sets or updates the metadata for the contract.
105
+ * The provided metadata is spared-merged with any existing metadata in the contract.
106
+ *
107
+ * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
108
+ */
171
109
  meta(meta: TMeta): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
110
+ /**
111
+ * Sets or updates the route definition for the contract.
112
+ * The provided route is spared-merged with any existing route in the contract.
113
+ * This option is typically relevant when integrating with OpenAPI.
114
+ *
115
+ * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
116
+ * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
117
+ */
172
118
  route(route: Route): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
119
+ /**
120
+ * Defines the input validation schema for the contract.
121
+ *
122
+ * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
123
+ */
173
124
  input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInputOutput<U, TOutputSchema, TErrorMap, TMeta>;
174
125
  }
175
126
  interface ContractProcedureBuilderWithInputOutput<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
127
+ /**
128
+ * Adds type-safe custom errors to the contract.
129
+ * The provided errors are spared-merged with any existing errors in the contract.
130
+ *
131
+ * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
132
+ */
176
133
  errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
134
+ /**
135
+ * Sets or updates the metadata for the contract.
136
+ * The provided metadata is spared-merged with any existing metadata in the contract.
137
+ *
138
+ * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
139
+ */
177
140
  meta(meta: TMeta): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
141
+ /**
142
+ * Sets or updates the route definition for the contract.
143
+ * The provided route is spared-merged with any existing route in the contract.
144
+ * This option is typically relevant when integrating with OpenAPI.
145
+ *
146
+ * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
147
+ * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
148
+ */
178
149
  route(route: Route): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
179
150
  }
180
151
  interface ContractRouterBuilder<TErrorMap extends ErrorMap, TMeta extends Meta> {
152
+ /**
153
+ * This property holds the defined options for the contract router.
154
+ */
181
155
  '~orpc': EnhanceContractRouterOptions<TErrorMap>;
156
+ /**
157
+ * Adds type-safe custom errors to the contract.
158
+ * The provided errors are spared-merged with any existing errors in the contract.
159
+ *
160
+ * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
161
+ */
182
162
  'errors'<U extends ErrorMap>(errors: U): ContractRouterBuilder<MergedErrorMap<TErrorMap, U>, TMeta>;
163
+ /**
164
+ * Prefixes all procedures in the contract router.
165
+ * The provided prefix is post-appended to any existing router prefix.
166
+ *
167
+ * @note This option does not affect procedures that do not define a path in their route definition.
168
+ *
169
+ * @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
170
+ */
183
171
  'prefix'(prefix: HTTPPath): ContractRouterBuilder<TErrorMap, TMeta>;
172
+ /**
173
+ * Adds tags to all procedures in the contract router.
174
+ * This helpful when you want to group procedures together in the OpenAPI specification.
175
+ *
176
+ * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
177
+ */
184
178
  'tag'(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>;
179
+ /**
180
+ * Applies all of the previously defined options to the specified contract router.
181
+ *
182
+ * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
183
+ */
185
184
  'router'<T extends ContractRouter<TMeta>>(router: T): EnhancedContractRouter<T, TErrorMap>;
186
185
  }
187
186
 
188
187
  interface ContractBuilderDef<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>, EnhanceContractRouterOptions<TErrorMap> {
189
188
  }
190
189
  declare class ContractBuilder<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
190
+ /**
191
+ * This property holds the defined options for the contract.
192
+ */
191
193
  '~orpc': ContractBuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
192
194
  constructor(def: ContractBuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>);
193
195
  /**
194
- * Reset initial meta
196
+ * Sets or overrides the initial meta.
197
+ *
198
+ * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
195
199
  */
196
200
  $meta<U extends Meta>(initialMeta: U): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, U & Record<never, never>>;
197
201
  /**
198
- * Reset initial route
202
+ * Sets or overrides the initial route.
203
+ * This option is typically relevant when integrating with OpenAPI.
204
+ *
205
+ * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
206
+ * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
199
207
  */
200
208
  $route(initialRoute: Route): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
209
+ /**
210
+ * Adds type-safe custom errors to the contract.
211
+ * The provided errors are spared-merged with any existing errors in the contract.
212
+ *
213
+ * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
214
+ */
201
215
  errors<U extends ErrorMap>(errors: U): ContractBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
216
+ /**
217
+ * Sets or updates the metadata for the contract.
218
+ * The provided metadata is spared-merged with any existing metadata in the contract.
219
+ *
220
+ * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
221
+ */
202
222
  meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
223
+ /**
224
+ * Sets or updates the route definition for the contract.
225
+ * The provided route is spared-merged with any existing route in the contract.
226
+ * This option is typically relevant when integrating with OpenAPI.
227
+ *
228
+ * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
229
+ * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
230
+ */
203
231
  route(route: Route): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
232
+ /**
233
+ * Defines the input validation schema for the contract.
234
+ *
235
+ * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
236
+ */
204
237
  input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>;
238
+ /**
239
+ * Defines the output validation schema for the contract.
240
+ *
241
+ * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
242
+ */
205
243
  output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>;
244
+ /**
245
+ * Prefixes all procedures in the contract router.
246
+ * The provided prefix is post-appended to any existing router prefix.
247
+ *
248
+ * @note This option does not affect procedures that do not define a path in their route definition.
249
+ *
250
+ * @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
251
+ */
206
252
  prefix(prefix: HTTPPath): ContractRouterBuilder<TErrorMap, TMeta>;
253
+ /**
254
+ * Adds tags to all procedures in the contract router.
255
+ * This helpful when you want to group procedures together in the OpenAPI specification.
256
+ *
257
+ * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
258
+ */
207
259
  tag(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>;
260
+ /**
261
+ * Applies all of the previously defined options to the specified contract router.
262
+ *
263
+ * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
264
+ */
208
265
  router<T extends ContractRouter<TMeta>>(router: T): EnhancedContractRouter<T, TErrorMap>;
209
266
  }
210
267
  declare const oc: ContractBuilder<Schema<unknown, unknown>, Schema<unknown, unknown>, Record<never, never>, Record<never, never>>;
@@ -222,14 +279,28 @@ interface EventIteratorSchemaDetails {
222
279
  yields: AnySchema;
223
280
  returns?: AnySchema;
224
281
  }
282
+ /**
283
+ * Define schema for an event iterator.
284
+ *
285
+ * @see {@link https://orpc.unnoq.com/docs/event-iterator#validate-event-iterator Validate Event Iterator Docs}
286
+ */
225
287
  declare function eventIterator<TYieldIn, TYieldOut, TReturnIn = unknown, TReturnOut = unknown>(yields: Schema<TYieldIn, TYieldOut>, returns?: Schema<TReturnIn, TReturnOut>): Schema<AsyncIteratorObject<TYieldIn, TReturnIn, void>, AsyncIteratorObject<TYieldOut, TReturnOut, void>>;
226
288
  declare function getEventIteratorSchemaDetails(schema: AnySchema | undefined): undefined | EventIteratorSchemaDetails;
227
289
 
290
+ /**
291
+ * Help RPCLink automatically send requests using the specified HTTP method in the contract.
292
+ *
293
+ * @see {@link https://orpc.unnoq.com/docs/client/rpc-link#custom-request-method RPCLink Custom Request Method}
294
+ */
295
+ declare function inferRPCMethodFromContractRouter(contract: AnyContractRouter): (options: unknown, path: readonly string[]) => Exclude<HTTPMethod, 'HEAD'>;
296
+
228
297
  type ContractProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
229
298
 
230
299
  type ContractRouterClient<TRouter extends AnyContractRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, any> ? ContractProcedureClient<TClientContext, UInputSchema, UOutputSchema, UErrorMap> : {
231
300
  [K in keyof TRouter]: TRouter[K] extends AnyContractRouter ? ContractRouterClient<TRouter[K], TClientContext> : never;
232
301
  };
233
302
 
234
- export { ContractBuilder, ContractProcedure, ValidationError, enhanceContractRouter, enhanceRoute, eventIterator, fallbackContractConfig, getContractRouter, getEventIteratorSchemaDetails, isContractProcedure, mergeErrorMap, mergeMeta, mergePrefix, mergeRoute, mergeTags, oc, prefixRoute, type, unshiftTagRoute };
235
- export type { AnyContractProcedure, AnyContractRouter, AnySchema, ContractBuilderDef, ContractConfig, ContractProcedureBuilder, ContractProcedureBuilderWithInput, ContractProcedureBuilderWithInputOutput, ContractProcedureBuilderWithOutput, ContractProcedureClient, ContractProcedureDef, ContractRouter, ContractRouterBuilder, ContractRouterClient, EnhanceContractRouterOptions, EnhanceRouteOptions, EnhancedContractRouter, ErrorFromErrorMap, ErrorMap, ErrorMapItem, EventIteratorSchemaDetails, InferContractRouterErrorMap, InferContractRouterInputs, InferContractRouterMeta, InferContractRouterOutputs, InferSchemaInput, InferSchemaOutput, InputStructure, MergedErrorMap, Meta, ORPCErrorFromErrorMap, OutputStructure, Route, Schema, SchemaIssue, TypeRest, ValidationErrorOptions };
303
+ declare function isSchemaIssue(issue: unknown): issue is SchemaIssue;
304
+
305
+ 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 };
306
+ export type { ContractBuilderDef, ContractConfig, ContractProcedureBuilder, ContractProcedureBuilderWithInput, ContractProcedureBuilderWithInputOutput, ContractProcedureBuilderWithOutput, ContractProcedureClient, ContractRouterBuilder, ContractRouterClient, EnhanceContractRouterOptions, EnhancedContractRouter, EventIteratorSchemaDetails };