@orpc/contract 0.0.0-next.eae6003 → 0.0.0-next.eaec0b2

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.mts CHANGED
@@ -1,259 +1,58 @@
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';
4
- export { Registry, ThrowableError } from '@orpc/shared';
5
- import { StandardSchemaV1 } from '@standard-schema/spec';
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.TuRtB1Ca.mjs';
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.TuRtB1Ca.mjs';
5
+ import { AsyncIteratorClass } from '@orpc/shared';
6
+ export { AsyncIteratorClass, Registry, ThrowableError } from '@orpc/shared';
7
+ export { OpenAPIV3_1 as OpenAPI } from 'openapi-types';
8
+ import '@standard-schema/spec';
6
9
 
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
- /**
14
- * The schema for things can be trust without validation.
15
- * If the TInput and TOutput are different, you need pass a map function.
16
- *
17
- * @see {@link https://orpc.unnoq.com/docs/procedure#type-utility Type Utility Docs}
18
- */
19
- declare function type<TInput, TOutput = TInput>(...[map]: TypeRest<TInput, TOutput>): Schema<TInput, TOutput>;
20
-
21
- interface ValidationErrorOptions extends ErrorOptions {
22
- message: string;
23
- issues: readonly SchemaIssue[];
24
- }
25
- /**
26
- * This errors usually used for ORPCError.cause when the error is a validation error.
27
- *
28
- * @see {@link https://orpc.unnoq.com/docs/advanced/validation-errors Validation Errors Docs}
29
- */
30
- declare class ValidationError extends Error {
31
- readonly issues: readonly SchemaIssue[];
32
- constructor(options: ValidationErrorOptions);
33
- }
34
- interface ErrorMapItem<TDataSchema extends AnySchema> {
35
- status?: number;
36
- message?: string;
37
- data?: TDataSchema;
38
- }
39
- type ErrorMap = {
40
- [key in ORPCErrorCode]?: ErrorMapItem<AnySchema>;
10
+ declare function getContractRouter(router: AnyContractRouter, path: readonly string[]): AnyContractRouter | undefined;
11
+ 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> : {
12
+ [K in keyof T]: T[K] extends AnyContractRouter ? EnhancedContractRouter<T[K], TErrorMap> : never;
41
13
  };
42
- type MergedErrorMap<T1 extends ErrorMap, T2 extends ErrorMap> = Omit<T1, keyof T2> & T2;
43
- declare function mergeErrorMap<T1 extends ErrorMap, T2 extends ErrorMap>(errorMap1: T1, errorMap2: T2): MergedErrorMap<T1, T2>;
44
- type ORPCErrorFromErrorMap<TErrorMap extends ErrorMap> = {
45
- [K in keyof TErrorMap]: K extends string ? TErrorMap[K] extends ErrorMapItem<infer TDataSchema extends Schema<unknown, unknown>> ? ORPCError<K, InferSchemaOutput<TDataSchema>> : never : never;
46
- }[keyof TErrorMap];
47
- type ErrorFromErrorMap<TErrorMap extends ErrorMap> = ORPCErrorFromErrorMap<TErrorMap> | ThrowableError;
48
-
49
- type Meta = Record<string, any>;
50
- declare function mergeMeta<T extends Meta>(meta1: T, meta2: T): T;
51
-
52
- type InputStructure = 'compact' | 'detailed';
53
- type OutputStructure = 'compact' | 'detailed';
54
- interface Route {
55
- /**
56
- * The HTTP method of the procedure.
57
- * This option is typically relevant when integrating with OpenAPI.
58
- *
59
- * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
60
- */
61
- method?: HTTPMethod;
62
- /**
63
- * The HTTP path of the procedure.
64
- * This option is typically relevant when integrating with OpenAPI.
65
- *
66
- * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
67
- */
68
- path?: HTTPPath;
69
- /**
70
- * The summary of the procedure.
71
- * This option is typically relevant when integrating with OpenAPI.
72
- *
73
- * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
74
- */
75
- summary?: string;
76
- /**
77
- * The description of the procedure.
78
- * This option is typically relevant when integrating with OpenAPI.
79
- *
80
- * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
81
- */
82
- description?: string;
83
- /**
84
- * Marks the procedure as deprecated.
85
- * This option is typically relevant when integrating with OpenAPI.
86
- *
87
- * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
88
- */
89
- deprecated?: boolean;
90
- /**
91
- * The tags of the procedure.
92
- * This option is typically relevant when integrating with OpenAPI.
93
- *
94
- * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
95
- */
96
- tags?: readonly string[];
97
- /**
98
- * The status code of the response when the procedure is successful.
99
- * The status code must be in the 200-399 range.
100
- * This option is typically relevant when integrating with OpenAPI.
101
- *
102
- * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
103
- * @default 200
104
- */
105
- successStatus?: number;
106
- /**
107
- * The description of the response when the procedure is successful.
108
- * This option is typically relevant when integrating with OpenAPI.
109
- *
110
- * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
111
- * @default 'OK'
112
- */
113
- successDescription?: string;
114
- /**
115
- * Determines how the input should be structured based on `params`, `query`, `headers`, and `body`.
116
- *
117
- * @option 'compact'
118
- * Combines `params` and either `query` or `body` (depending on the HTTP method) into a single object.
119
- *
120
- * @option 'detailed'
121
- * Keeps each part of the request (`params`, `query`, `headers`, and `body`) as separate fields in the input object.
122
- *
123
- * Example:
124
- * ```ts
125
- * const input = {
126
- * params: { id: 1 },
127
- * query: { search: 'hello' },
128
- * headers: { 'Content-Type': 'application/json' },
129
- * body: { name: 'John' },
130
- * }
131
- * ```
132
- *
133
- * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
134
- * @default 'compact'
135
- */
136
- inputStructure?: InputStructure;
137
- /**
138
- * Determines how the response should be structured based on the output.
139
- *
140
- * @option 'compact'
141
- * The output data is directly returned as the response body.
142
- *
143
- * @option 'detailed'
144
- * Return an object with optional properties:
145
- * - `status`: The response status (must be in 200-399 range) if not set fallback to `successStatus`.
146
- * - `headers`: Custom headers to merge with the response headers (`Record<string, string | string[] | undefined>`)
147
- * - `body`: The response body.
148
- *
149
- * Example:
150
- * ```ts
151
- * const output = {
152
- * status: 201,
153
- * headers: { 'x-custom-header': 'value' },
154
- * body: { message: 'Hello, world!' },
155
- * };
156
- * ```
157
- *
158
- * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
159
- * @default 'compact'
160
- */
161
- outputStructure?: OutputStructure;
162
- }
163
- declare function mergeRoute(a: Route, b: Route): Route;
164
- declare function prefixRoute(route: Route, prefix: HTTPPath): Route;
165
- declare function unshiftTagRoute(route: Route, tags: readonly string[]): Route;
166
- declare function mergePrefix(a: HTTPPath | undefined, b: HTTPPath): HTTPPath;
167
- declare function mergeTags(a: readonly string[] | undefined, b: readonly string[]): readonly string[];
168
- interface EnhanceRouteOptions {
169
- prefix?: HTTPPath;
170
- tags?: readonly string[];
171
- }
172
- declare function enhanceRoute(route: Route, options: EnhanceRouteOptions): Route;
173
-
174
- interface ContractProcedureDef<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
175
- meta: TMeta;
176
- route: Route;
177
- inputSchema?: TInputSchema;
178
- outputSchema?: TOutputSchema;
14
+ interface EnhanceContractRouterOptions<TErrorMap extends ErrorMap> extends EnhanceRouteOptions {
179
15
  errorMap: TErrorMap;
180
16
  }
17
+ declare function enhanceContractRouter<T extends AnyContractRouter, TErrorMap extends ErrorMap>(router: T, options: EnhanceContractRouterOptions<TErrorMap>): EnhancedContractRouter<T, TErrorMap>;
181
18
  /**
182
- * This class represents a contract procedure.
19
+ * Minify a contract router into a smaller object.
183
20
  *
184
- * @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#procedure-contract Contract Procedure Docs}
185
- */
186
- declare class ContractProcedure<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
187
- /**
188
- * This property holds the defined options for the contract procedure.
189
- */
190
- '~orpc': ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
191
- constructor(def: ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>);
192
- }
193
- type AnyContractProcedure = ContractProcedure<any, any, any, any>;
194
- declare function isContractProcedure(item: unknown): item is AnyContractProcedure;
195
-
196
- /**
197
- * Represents a contract router, which defines a hierarchical structure of contract procedures.
21
+ * 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.
22
+ * This reduces the size of the contract and helps prevent leaking internal details of the router to the client.
198
23
  *
199
- * @info A contract procedure is a contract router too.
200
- * @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#contract-router Contract Router Docs}
24
+ * @see {@link https://orpc.dev/docs/contract-first/router-to-contract#minify-export-the-contract-router-for-the-client Router to Contract Docs}
201
25
  */
202
- type ContractRouter<TMeta extends Meta> = ContractProcedure<any, any, any, TMeta> | {
203
- [k: string]: ContractRouter<TMeta>;
204
- };
205
- type AnyContractRouter = ContractRouter<any>;
206
- /**
207
- * Infer all inputs of the contract router.
208
- *
209
- * @info A contract procedure is a contract router too.
210
- * @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#utilities Contract Utilities Docs}
211
- */
212
- type InferContractRouterInputs<T extends AnyContractRouter> = T extends ContractProcedure<infer UInputSchema, any, any, any> ? InferSchemaInput<UInputSchema> : {
213
- [K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterInputs<T[K]> : never;
26
+ declare function minifyContractRouter(router: AnyContractRouter): AnyContractRouter;
27
+ type PopulatedContractRouterPaths<T extends AnyContractRouter> = T extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrors, infer UMeta> ? ContractProcedure<UInputSchema, UOutputSchema, UErrors, UMeta> : {
28
+ [K in keyof T]: T[K] extends AnyContractRouter ? PopulatedContractRouterPaths<T[K]> : never;
214
29
  };
30
+ interface PopulateContractRouterPathsOptions {
31
+ path?: readonly string[];
32
+ }
215
33
  /**
216
- * Infer all outputs of the contract router.
34
+ * Automatically populates missing route paths using the router's nested keys.
217
35
  *
218
- * @info A contract procedure is a contract router too.
219
- * @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#utilities Contract Utilities Docs}
220
- */
221
- type InferContractRouterOutputs<T extends AnyContractRouter> = T extends ContractProcedure<any, infer UOutputSchema, any, any> ? InferSchemaOutput<UOutputSchema> : {
222
- [K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterOutputs<T[K]> : never;
223
- };
224
- /**
225
- * Infer all errors of the contract router.
36
+ * Constructs paths by joining router keys with `/`.
37
+ * Useful for NestJS integration that require explicit route paths.
226
38
  *
227
- * @info A contract procedure is a contract router too.
228
- * @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#utilities Contract Utilities Docs}
39
+ * @see {@link https://orpc.dev/docs/openapi/integrations/implement-contract-in-nest#define-your-contract NestJS Implement Contract Docs}
229
40
  */
230
- type InferContractRouterErrorMap<T extends AnyContractRouter> = T extends ContractProcedure<any, any, infer UErrorMap, any> ? UErrorMap : {
231
- [K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterErrorMap<T[K]> : never;
232
- }[keyof T];
233
- type InferContractRouterMeta<T extends AnyContractRouter> = T extends ContractRouter<infer UMeta> ? UMeta : never;
234
-
235
- declare function getContractRouter(router: AnyContractRouter, path: readonly string[]): AnyContractRouter | undefined;
236
- 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> : {
237
- [K in keyof T]: T[K] extends AnyContractRouter ? EnhancedContractRouter<T[K], TErrorMap> : never;
238
- };
239
- interface EnhanceContractRouterOptions<TErrorMap extends ErrorMap> extends EnhanceRouteOptions {
240
- errorMap: TErrorMap;
241
- }
242
- declare function enhanceContractRouter<T extends AnyContractRouter, TErrorMap extends ErrorMap>(router: T, options: EnhanceContractRouterOptions<TErrorMap>): EnhancedContractRouter<T, TErrorMap>;
41
+ declare function populateContractRouterPaths<T extends AnyContractRouter>(router: T, options?: PopulateContractRouterPathsOptions): PopulatedContractRouterPaths<T>;
243
42
 
244
43
  interface ContractProcedureBuilder<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
245
44
  /**
246
45
  * Adds type-safe custom errors to the contract.
247
46
  * The provided errors are spared-merged with any existing errors in the contract.
248
47
  *
249
- * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
48
+ * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
250
49
  */
251
50
  errors<U extends ErrorMap>(errors: U): ContractProcedureBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
252
51
  /**
253
52
  * Sets or updates the metadata for the contract.
254
53
  * The provided metadata is spared-merged with any existing metadata in the contract.
255
54
  *
256
- * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
55
+ * @see {@link https://orpc.dev/docs/metadata Metadata Docs}
257
56
  */
258
57
  meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
259
58
  /**
@@ -261,20 +60,20 @@ interface ContractProcedureBuilder<TInputSchema extends AnySchema, TOutputSchema
261
60
  * The provided route is spared-merged with any existing route in the contract.
262
61
  * This option is typically relevant when integrating with OpenAPI.
263
62
  *
264
- * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
265
- * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
63
+ * @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
64
+ * @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
266
65
  */
267
66
  route(route: Route): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
268
67
  /**
269
68
  * Defines the input validation schema for the contract.
270
69
  *
271
- * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
70
+ * @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs}
272
71
  */
273
72
  input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>;
274
73
  /**
275
74
  * Defines the output validation schema for the contract.
276
75
  *
277
- * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
76
+ * @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs}
278
77
  */
279
78
  output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>;
280
79
  }
@@ -283,14 +82,14 @@ interface ContractProcedureBuilderWithInput<TInputSchema extends AnySchema, TOut
283
82
  * Adds type-safe custom errors to the contract.
284
83
  * The provided errors are spared-merged with any existing errors in the contract.
285
84
  *
286
- * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
85
+ * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
287
86
  */
288
87
  errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
289
88
  /**
290
89
  * Sets or updates the metadata for the contract.
291
90
  * The provided metadata is spared-merged with any existing metadata in the contract.
292
91
  *
293
- * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
92
+ * @see {@link https://orpc.dev/docs/metadata Metadata Docs}
294
93
  */
295
94
  meta(meta: TMeta): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
296
95
  /**
@@ -298,14 +97,14 @@ interface ContractProcedureBuilderWithInput<TInputSchema extends AnySchema, TOut
298
97
  * The provided route is spared-merged with any existing route in the contract.
299
98
  * This option is typically relevant when integrating with OpenAPI.
300
99
  *
301
- * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
302
- * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
100
+ * @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
101
+ * @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
303
102
  */
304
103
  route(route: Route): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
305
104
  /**
306
105
  * Defines the output validation schema for the contract.
307
106
  *
308
- * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
107
+ * @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs}
309
108
  */
310
109
  output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInputOutput<TInputSchema, U, TErrorMap, TMeta>;
311
110
  }
@@ -314,14 +113,14 @@ interface ContractProcedureBuilderWithOutput<TInputSchema extends AnySchema, TOu
314
113
  * Adds type-safe custom errors to the contract.
315
114
  * The provided errors are spared-merged with any existing errors in the contract.
316
115
  *
317
- * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
116
+ * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
318
117
  */
319
118
  errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
320
119
  /**
321
120
  * Sets or updates the metadata for the contract.
322
121
  * The provided metadata is spared-merged with any existing metadata in the contract.
323
122
  *
324
- * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
123
+ * @see {@link https://orpc.dev/docs/metadata Metadata Docs}
325
124
  */
326
125
  meta(meta: TMeta): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
327
126
  /**
@@ -329,14 +128,14 @@ interface ContractProcedureBuilderWithOutput<TInputSchema extends AnySchema, TOu
329
128
  * The provided route is spared-merged with any existing route in the contract.
330
129
  * This option is typically relevant when integrating with OpenAPI.
331
130
  *
332
- * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
333
- * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
131
+ * @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
132
+ * @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
334
133
  */
335
134
  route(route: Route): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
336
135
  /**
337
136
  * Defines the input validation schema for the contract.
338
137
  *
339
- * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
138
+ * @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs}
340
139
  */
341
140
  input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInputOutput<U, TOutputSchema, TErrorMap, TMeta>;
342
141
  }
@@ -345,14 +144,14 @@ interface ContractProcedureBuilderWithInputOutput<TInputSchema extends AnySchema
345
144
  * Adds type-safe custom errors to the contract.
346
145
  * The provided errors are spared-merged with any existing errors in the contract.
347
146
  *
348
- * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
147
+ * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
349
148
  */
350
149
  errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
351
150
  /**
352
151
  * Sets or updates the metadata for the contract.
353
152
  * The provided metadata is spared-merged with any existing metadata in the contract.
354
153
  *
355
- * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
154
+ * @see {@link https://orpc.dev/docs/metadata Metadata Docs}
356
155
  */
357
156
  meta(meta: TMeta): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
358
157
  /**
@@ -360,8 +159,8 @@ interface ContractProcedureBuilderWithInputOutput<TInputSchema extends AnySchema
360
159
  * The provided route is spared-merged with any existing route in the contract.
361
160
  * This option is typically relevant when integrating with OpenAPI.
362
161
  *
363
- * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
364
- * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
162
+ * @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
163
+ * @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
365
164
  */
366
165
  route(route: Route): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
367
166
  }
@@ -374,7 +173,7 @@ interface ContractRouterBuilder<TErrorMap extends ErrorMap, TMeta extends Meta>
374
173
  * Adds type-safe custom errors to the contract.
375
174
  * The provided errors are spared-merged with any existing errors in the contract.
376
175
  *
377
- * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
176
+ * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
378
177
  */
379
178
  'errors'<U extends ErrorMap>(errors: U): ContractRouterBuilder<MergedErrorMap<TErrorMap, U>, TMeta>;
380
179
  /**
@@ -383,20 +182,20 @@ interface ContractRouterBuilder<TErrorMap extends ErrorMap, TMeta extends Meta>
383
182
  *
384
183
  * @note This option does not affect procedures that do not define a path in their route definition.
385
184
  *
386
- * @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
185
+ * @see {@link https://orpc.dev/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
387
186
  */
388
187
  'prefix'(prefix: HTTPPath): ContractRouterBuilder<TErrorMap, TMeta>;
389
188
  /**
390
189
  * Adds tags to all procedures in the contract router.
391
190
  * This helpful when you want to group procedures together in the OpenAPI specification.
392
191
  *
393
- * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
192
+ * @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
394
193
  */
395
194
  'tag'(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>;
396
195
  /**
397
196
  * Applies all of the previously defined options to the specified contract router.
398
197
  *
399
- * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
198
+ * @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs}
400
199
  */
401
200
  'router'<T extends ContractRouter<TMeta>>(router: T): EnhancedContractRouter<T, TErrorMap>;
402
201
  }
@@ -412,29 +211,35 @@ declare class ContractBuilder<TInputSchema extends AnySchema, TOutputSchema exte
412
211
  /**
413
212
  * Sets or overrides the initial meta.
414
213
  *
415
- * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
214
+ * @see {@link https://orpc.dev/docs/metadata Metadata Docs}
416
215
  */
417
216
  $meta<U extends Meta>(initialMeta: U): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, U & Record<never, never>>;
418
217
  /**
419
218
  * Sets or overrides the initial route.
420
219
  * This option is typically relevant when integrating with OpenAPI.
421
220
  *
422
- * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
423
- * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
221
+ * @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
222
+ * @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
424
223
  */
425
224
  $route(initialRoute: Route): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
225
+ /**
226
+ * Sets or overrides the initial input schema.
227
+ *
228
+ * @see {@link https://orpc.dev/docs/procedure#initial-configuration Initial Procedure Configuration Docs}
229
+ */
230
+ $input<U extends AnySchema>(initialInputSchema?: U): ContractBuilder<U, TOutputSchema, TErrorMap, TMeta>;
426
231
  /**
427
232
  * Adds type-safe custom errors to the contract.
428
233
  * The provided errors are spared-merged with any existing errors in the contract.
429
234
  *
430
- * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
235
+ * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
431
236
  */
432
237
  errors<U extends ErrorMap>(errors: U): ContractBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
433
238
  /**
434
239
  * Sets or updates the metadata for the contract.
435
240
  * The provided metadata is spared-merged with any existing metadata in the contract.
436
241
  *
437
- * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
242
+ * @see {@link https://orpc.dev/docs/metadata Metadata Docs}
438
243
  */
439
244
  meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
440
245
  /**
@@ -442,20 +247,20 @@ declare class ContractBuilder<TInputSchema extends AnySchema, TOutputSchema exte
442
247
  * The provided route is spared-merged with any existing route in the contract.
443
248
  * This option is typically relevant when integrating with OpenAPI.
444
249
  *
445
- * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
446
- * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
250
+ * @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
251
+ * @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
447
252
  */
448
253
  route(route: Route): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
449
254
  /**
450
255
  * Defines the input validation schema for the contract.
451
256
  *
452
- * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
257
+ * @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs}
453
258
  */
454
259
  input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>;
455
260
  /**
456
261
  * Defines the output validation schema for the contract.
457
262
  *
458
- * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
263
+ * @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs}
459
264
  */
460
265
  output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>;
461
266
  /**
@@ -464,20 +269,20 @@ declare class ContractBuilder<TInputSchema extends AnySchema, TOutputSchema exte
464
269
  *
465
270
  * @note This option does not affect procedures that do not define a path in their route definition.
466
271
  *
467
- * @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
272
+ * @see {@link https://orpc.dev/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
468
273
  */
469
274
  prefix(prefix: HTTPPath): ContractRouterBuilder<TErrorMap, TMeta>;
470
275
  /**
471
276
  * Adds tags to all procedures in the contract router.
472
277
  * This helpful when you want to group procedures together in the OpenAPI specification.
473
278
  *
474
- * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
279
+ * @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
475
280
  */
476
281
  tag(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>;
477
282
  /**
478
283
  * Applies all of the previously defined options to the specified contract router.
479
284
  *
480
- * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
285
+ * @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs}
481
286
  */
482
287
  router<T extends ContractRouter<TMeta>>(router: T): EnhancedContractRouter<T, TErrorMap>;
483
288
  }
@@ -499,16 +304,25 @@ interface EventIteratorSchemaDetails {
499
304
  /**
500
305
  * Define schema for an event iterator.
501
306
  *
502
- * @see {@link https://orpc.unnoq.com/docs/event-iterator#validate-event-iterator Validate Event Iterator Docs}
307
+ * @see {@link https://orpc.dev/docs/event-iterator#validate-event-iterator Validate Event Iterator Docs}
503
308
  */
504
- 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>>;
309
+ 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>>;
505
310
  declare function getEventIteratorSchemaDetails(schema: AnySchema | undefined): undefined | EventIteratorSchemaDetails;
506
311
 
312
+ /**
313
+ * Help RPCLink automatically send requests using the specified HTTP method in the contract.
314
+ *
315
+ * @see {@link https://orpc.dev/docs/client/rpc-link#custom-request-method RPCLink Custom Request Method}
316
+ */
317
+ declare function inferRPCMethodFromContractRouter(contract: AnyContractRouter): (options: unknown, path: readonly string[]) => Exclude<HTTPMethod, 'HEAD'>;
318
+
507
319
  type ContractProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
508
320
 
509
321
  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> : {
510
322
  [K in keyof TRouter]: TRouter[K] extends AnyContractRouter ? ContractRouterClient<TRouter[K], TClientContext> : never;
511
323
  };
512
324
 
513
- export { ContractBuilder, ContractProcedure, ValidationError, enhanceContractRouter, enhanceRoute, eventIterator, fallbackContractConfig, getContractRouter, getEventIteratorSchemaDetails, isContractProcedure, mergeErrorMap, mergeMeta, mergePrefix, mergeRoute, mergeTags, oc, prefixRoute, type, unshiftTagRoute };
514
- 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 };
325
+ declare function isSchemaIssue(issue: unknown): issue is SchemaIssue;
326
+
327
+ 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 };
328
+ export type { ContractBuilderDef, ContractConfig, ContractProcedureBuilder, ContractProcedureBuilderWithInput, ContractProcedureBuilderWithInputOutput, ContractProcedureBuilderWithOutput, ContractProcedureClient, ContractRouterBuilder, ContractRouterClient, EnhanceContractRouterOptions, EnhancedContractRouter, EventIteratorSchemaDetails, PopulateContractRouterPathsOptions, PopulatedContractRouterPaths };