@orpc/contract 1.0.0-beta.7 → 1.0.3
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/README.md +13 -17
- package/dist/index.d.mts +278 -2
- package/dist/index.d.ts +278 -2
- package/dist/index.mjs +60 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -21,28 +21,24 @@
|
|
|
21
21
|
|
|
22
22
|
<h3 align="center">Typesafe APIs Made Simple 🪄</h3>
|
|
23
23
|
|
|
24
|
-
**oRPC is a powerful combination of RPC and OpenAPI**, makes it easy to build APIs that are end-to-end type-safe and adhere to OpenAPI standards
|
|
24
|
+
**oRPC is a powerful combination of RPC and OpenAPI**, makes it easy to build APIs that are end-to-end type-safe and adhere to OpenAPI standards
|
|
25
25
|
|
|
26
26
|
---
|
|
27
27
|
|
|
28
28
|
## Highlights
|
|
29
29
|
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
- **Reusability 🔄**: Write once and reuse your code across multiple purposes effortlessly.
|
|
43
|
-
- **Extendability 🔌**: Easily enhance oRPC with plugins, middleware, and interceptors.
|
|
44
|
-
- **Reliability 🛡️**: Well-tested, fully TypeScript, production-ready, and MIT licensed for peace of mind.
|
|
45
|
-
- **Simplicity 💡**: Enjoy straightforward, clean code with no hidden magic.
|
|
30
|
+
- **🔗 End-to-End Type Safety**: Ensure type-safe inputs, outputs, and errors from client to server.
|
|
31
|
+
- **📘 First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard.
|
|
32
|
+
- **📝 Contract-First Development**: Optionally define your API contract before implementation.
|
|
33
|
+
- **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
|
|
34
|
+
- **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
|
|
35
|
+
- **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
|
|
36
|
+
- **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
|
|
37
|
+
- **⏱️ Lazy Router**: Enhance cold start times with our lazy routing feature.
|
|
38
|
+
- **📡 SSE & Streaming**: Enjoy full type-safe support for SSE and streaming.
|
|
39
|
+
- **🌍 Multi-Runtime Support**: Fast and lightweight on Cloudflare, Deno, Bun, Node.js, and beyond.
|
|
40
|
+
- **🔌 Extendability**: Easily extend functionality with plugins, middleware, and interceptors.
|
|
41
|
+
- **🛡️ Reliability**: Well-tested, TypeScript-based, production-ready, and MIT licensed.
|
|
46
42
|
|
|
47
43
|
## Documentation
|
|
48
44
|
|
package/dist/index.d.mts
CHANGED
|
@@ -10,12 +10,23 @@ type SchemaIssue = StandardSchemaV1.Issue;
|
|
|
10
10
|
type InferSchemaInput<T extends AnySchema> = T extends StandardSchemaV1<infer UInput, any> ? UInput : never;
|
|
11
11
|
type InferSchemaOutput<T extends AnySchema> = T extends StandardSchemaV1<any, infer UOutput> ? UOutput : never;
|
|
12
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
|
+
*/
|
|
13
19
|
declare function type<TInput, TOutput = TInput>(...[map]: TypeRest<TInput, TOutput>): Schema<TInput, TOutput>;
|
|
14
20
|
|
|
15
21
|
interface ValidationErrorOptions extends ErrorOptions {
|
|
16
22
|
message: string;
|
|
17
23
|
issues: readonly SchemaIssue[];
|
|
18
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
|
+
*/
|
|
19
30
|
declare class ValidationError extends Error {
|
|
20
31
|
readonly issues: readonly SchemaIssue[];
|
|
21
32
|
constructor(options: ValidationErrorOptions);
|
|
@@ -41,21 +52,61 @@ declare function mergeMeta<T extends Meta>(meta1: T, meta2: T): T;
|
|
|
41
52
|
type InputStructure = 'compact' | 'detailed';
|
|
42
53
|
type OutputStructure = 'compact' | 'detailed';
|
|
43
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
|
+
*/
|
|
44
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
|
+
*/
|
|
45
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
|
+
*/
|
|
46
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
|
+
*/
|
|
47
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
|
+
*/
|
|
48
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
|
+
*/
|
|
49
96
|
tags?: readonly string[];
|
|
50
97
|
/**
|
|
51
98
|
* The status code of the response when the procedure is successful.
|
|
99
|
+
* This option is typically relevant when integrating with OpenAPI.
|
|
52
100
|
*
|
|
101
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
53
102
|
* @default 200
|
|
54
103
|
*/
|
|
55
104
|
successStatus?: number;
|
|
56
105
|
/**
|
|
57
106
|
* The description of the response when the procedure is successful.
|
|
107
|
+
* This option is typically relevant when integrating with OpenAPI.
|
|
58
108
|
*
|
|
109
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
59
110
|
* @default 'OK'
|
|
60
111
|
*/
|
|
61
112
|
successDescription?: string;
|
|
@@ -78,6 +129,7 @@ interface Route {
|
|
|
78
129
|
* }
|
|
79
130
|
* ```
|
|
80
131
|
*
|
|
132
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
81
133
|
* @default 'compact'
|
|
82
134
|
*/
|
|
83
135
|
inputStructure?: InputStructure;
|
|
@@ -100,6 +152,7 @@ interface Route {
|
|
|
100
152
|
* };
|
|
101
153
|
* ```
|
|
102
154
|
*
|
|
155
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
103
156
|
* @default 'compact'
|
|
104
157
|
*/
|
|
105
158
|
outputStructure?: OutputStructure;
|
|
@@ -122,23 +175,55 @@ interface ContractProcedureDef<TInputSchema extends AnySchema, TOutputSchema ext
|
|
|
122
175
|
outputSchema?: TOutputSchema;
|
|
123
176
|
errorMap: TErrorMap;
|
|
124
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* This class represents a contract procedure.
|
|
180
|
+
*
|
|
181
|
+
* @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#procedure-contract Contract Procedure Docs}
|
|
182
|
+
*/
|
|
125
183
|
declare class ContractProcedure<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
184
|
+
/**
|
|
185
|
+
* This property holds the defined options for the contract procedure.
|
|
186
|
+
*/
|
|
126
187
|
'~orpc': ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
127
188
|
constructor(def: ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>);
|
|
128
189
|
}
|
|
129
190
|
type AnyContractProcedure = ContractProcedure<any, any, any, any>;
|
|
130
191
|
declare function isContractProcedure(item: unknown): item is AnyContractProcedure;
|
|
131
192
|
|
|
193
|
+
/**
|
|
194
|
+
* Represents a contract router, which defines a hierarchical structure of contract procedures.
|
|
195
|
+
*
|
|
196
|
+
* @info A contract procedure is a contract router too.
|
|
197
|
+
* @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#contract-router Contract Router Docs}
|
|
198
|
+
*/
|
|
132
199
|
type ContractRouter<TMeta extends Meta> = ContractProcedure<any, any, any, TMeta> | {
|
|
133
200
|
[k: string]: ContractRouter<TMeta>;
|
|
134
201
|
};
|
|
135
202
|
type AnyContractRouter = ContractRouter<any>;
|
|
203
|
+
/**
|
|
204
|
+
* Infer all inputs of the contract router.
|
|
205
|
+
*
|
|
206
|
+
* @info A contract procedure is a contract router too.
|
|
207
|
+
* @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#utilities Contract Utilities Docs}
|
|
208
|
+
*/
|
|
136
209
|
type InferContractRouterInputs<T extends AnyContractRouter> = T extends ContractProcedure<infer UInputSchema, any, any, any> ? InferSchemaInput<UInputSchema> : {
|
|
137
210
|
[K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterInputs<T[K]> : never;
|
|
138
211
|
};
|
|
212
|
+
/**
|
|
213
|
+
* Infer all outputs of the contract router.
|
|
214
|
+
*
|
|
215
|
+
* @info A contract procedure is a contract router too.
|
|
216
|
+
* @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#utilities Contract Utilities Docs}
|
|
217
|
+
*/
|
|
139
218
|
type InferContractRouterOutputs<T extends AnyContractRouter> = T extends ContractProcedure<any, infer UOutputSchema, any, any> ? InferSchemaOutput<UOutputSchema> : {
|
|
140
219
|
[K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterOutputs<T[K]> : never;
|
|
141
220
|
};
|
|
221
|
+
/**
|
|
222
|
+
* Infer all errors of the contract router.
|
|
223
|
+
*
|
|
224
|
+
* @info A contract procedure is a contract router too.
|
|
225
|
+
* @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#utilities Contract Utilities Docs}
|
|
226
|
+
*/
|
|
142
227
|
type InferContractRouterErrorMap<T extends AnyContractRouter> = T extends ContractProcedure<any, any, infer UErrorMap, any> ? UErrorMap : {
|
|
143
228
|
[K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterErrorMap<T[K]> : never;
|
|
144
229
|
}[keyof T];
|
|
@@ -154,57 +239,243 @@ interface EnhanceContractRouterOptions<TErrorMap extends ErrorMap> extends Enhan
|
|
|
154
239
|
declare function enhanceContractRouter<T extends AnyContractRouter, TErrorMap extends ErrorMap>(router: T, options: EnhanceContractRouterOptions<TErrorMap>): EnhancedContractRouter<T, TErrorMap>;
|
|
155
240
|
|
|
156
241
|
interface ContractProcedureBuilder<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
|
242
|
+
/**
|
|
243
|
+
* Adds type-safe custom errors to the contract.
|
|
244
|
+
* The provided errors are spared-merged with any existing errors in the contract.
|
|
245
|
+
*
|
|
246
|
+
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
247
|
+
*/
|
|
157
248
|
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
249
|
+
/**
|
|
250
|
+
* Sets or updates the metadata for the contract.
|
|
251
|
+
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
252
|
+
*
|
|
253
|
+
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
254
|
+
*/
|
|
158
255
|
meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
256
|
+
/**
|
|
257
|
+
* Sets or updates the route definition for the contract.
|
|
258
|
+
* The provided route is spared-merged with any existing route in the contract.
|
|
259
|
+
* This option is typically relevant when integrating with OpenAPI.
|
|
260
|
+
*
|
|
261
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
262
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
263
|
+
*/
|
|
159
264
|
route(route: Route): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
265
|
+
/**
|
|
266
|
+
* Defines the input validation schema for the contract.
|
|
267
|
+
*
|
|
268
|
+
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
|
|
269
|
+
*/
|
|
160
270
|
input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>;
|
|
271
|
+
/**
|
|
272
|
+
* Defines the output validation schema for the contract.
|
|
273
|
+
*
|
|
274
|
+
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
|
|
275
|
+
*/
|
|
161
276
|
output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>;
|
|
162
277
|
}
|
|
163
278
|
interface ContractProcedureBuilderWithInput<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
|
279
|
+
/**
|
|
280
|
+
* Adds type-safe custom errors to the contract.
|
|
281
|
+
* The provided errors are spared-merged with any existing errors in the contract.
|
|
282
|
+
*
|
|
283
|
+
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
284
|
+
*/
|
|
164
285
|
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
286
|
+
/**
|
|
287
|
+
* Sets or updates the metadata for the contract.
|
|
288
|
+
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
289
|
+
*
|
|
290
|
+
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
291
|
+
*/
|
|
165
292
|
meta(meta: TMeta): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
293
|
+
/**
|
|
294
|
+
* Sets or updates the route definition for the contract.
|
|
295
|
+
* The provided route is spared-merged with any existing route in the contract.
|
|
296
|
+
* This option is typically relevant when integrating with OpenAPI.
|
|
297
|
+
*
|
|
298
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
299
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
300
|
+
*/
|
|
166
301
|
route(route: Route): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
302
|
+
/**
|
|
303
|
+
* Defines the output validation schema for the contract.
|
|
304
|
+
*
|
|
305
|
+
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
|
|
306
|
+
*/
|
|
167
307
|
output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInputOutput<TInputSchema, U, TErrorMap, TMeta>;
|
|
168
308
|
}
|
|
169
309
|
interface ContractProcedureBuilderWithOutput<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
|
310
|
+
/**
|
|
311
|
+
* Adds type-safe custom errors to the contract.
|
|
312
|
+
* The provided errors are spared-merged with any existing errors in the contract.
|
|
313
|
+
*
|
|
314
|
+
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
315
|
+
*/
|
|
170
316
|
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
317
|
+
/**
|
|
318
|
+
* Sets or updates the metadata for the contract.
|
|
319
|
+
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
320
|
+
*
|
|
321
|
+
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
322
|
+
*/
|
|
171
323
|
meta(meta: TMeta): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
324
|
+
/**
|
|
325
|
+
* Sets or updates the route definition for the contract.
|
|
326
|
+
* The provided route is spared-merged with any existing route in the contract.
|
|
327
|
+
* This option is typically relevant when integrating with OpenAPI.
|
|
328
|
+
*
|
|
329
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
330
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
331
|
+
*/
|
|
172
332
|
route(route: Route): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
333
|
+
/**
|
|
334
|
+
* Defines the input validation schema for the contract.
|
|
335
|
+
*
|
|
336
|
+
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
|
|
337
|
+
*/
|
|
173
338
|
input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInputOutput<U, TOutputSchema, TErrorMap, TMeta>;
|
|
174
339
|
}
|
|
175
340
|
interface ContractProcedureBuilderWithInputOutput<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
|
341
|
+
/**
|
|
342
|
+
* Adds type-safe custom errors to the contract.
|
|
343
|
+
* The provided errors are spared-merged with any existing errors in the contract.
|
|
344
|
+
*
|
|
345
|
+
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
346
|
+
*/
|
|
176
347
|
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
348
|
+
/**
|
|
349
|
+
* Sets or updates the metadata for the contract.
|
|
350
|
+
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
351
|
+
*
|
|
352
|
+
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
353
|
+
*/
|
|
177
354
|
meta(meta: TMeta): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
355
|
+
/**
|
|
356
|
+
* Sets or updates the route definition for the contract.
|
|
357
|
+
* The provided route is spared-merged with any existing route in the contract.
|
|
358
|
+
* This option is typically relevant when integrating with OpenAPI.
|
|
359
|
+
*
|
|
360
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
361
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
362
|
+
*/
|
|
178
363
|
route(route: Route): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
179
364
|
}
|
|
180
365
|
interface ContractRouterBuilder<TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
366
|
+
/**
|
|
367
|
+
* This property holds the defined options for the contract router.
|
|
368
|
+
*/
|
|
181
369
|
'~orpc': EnhanceContractRouterOptions<TErrorMap>;
|
|
370
|
+
/**
|
|
371
|
+
* Adds type-safe custom errors to the contract.
|
|
372
|
+
* The provided errors are spared-merged with any existing errors in the contract.
|
|
373
|
+
*
|
|
374
|
+
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
375
|
+
*/
|
|
182
376
|
'errors'<U extends ErrorMap>(errors: U): ContractRouterBuilder<MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
377
|
+
/**
|
|
378
|
+
* Prefixes all procedures in the contract router.
|
|
379
|
+
* The provided prefix is post-appended to any existing router prefix.
|
|
380
|
+
*
|
|
381
|
+
* @note This option does not affect procedures that do not define a path in their route definition.
|
|
382
|
+
*
|
|
383
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
384
|
+
*/
|
|
183
385
|
'prefix'(prefix: HTTPPath): ContractRouterBuilder<TErrorMap, TMeta>;
|
|
386
|
+
/**
|
|
387
|
+
* Adds tags to all procedures in the contract router.
|
|
388
|
+
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
389
|
+
*
|
|
390
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
391
|
+
*/
|
|
184
392
|
'tag'(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>;
|
|
393
|
+
/**
|
|
394
|
+
* Applies all of the previously defined options to the specified contract router.
|
|
395
|
+
*
|
|
396
|
+
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
397
|
+
*/
|
|
185
398
|
'router'<T extends ContractRouter<TMeta>>(router: T): EnhancedContractRouter<T, TErrorMap>;
|
|
186
399
|
}
|
|
187
400
|
|
|
188
401
|
interface ContractBuilderDef<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>, EnhanceContractRouterOptions<TErrorMap> {
|
|
189
402
|
}
|
|
190
403
|
declare class ContractBuilder<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
|
404
|
+
/**
|
|
405
|
+
* This property holds the defined options for the contract.
|
|
406
|
+
*/
|
|
191
407
|
'~orpc': ContractBuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
192
408
|
constructor(def: ContractBuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>);
|
|
193
409
|
/**
|
|
194
|
-
*
|
|
410
|
+
* Sets or overrides the initial meta.
|
|
411
|
+
*
|
|
412
|
+
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
195
413
|
*/
|
|
196
414
|
$meta<U extends Meta>(initialMeta: U): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, U & Record<never, never>>;
|
|
197
415
|
/**
|
|
198
|
-
*
|
|
416
|
+
* Sets or overrides the initial route.
|
|
417
|
+
* This option is typically relevant when integrating with OpenAPI.
|
|
418
|
+
*
|
|
419
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
420
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
199
421
|
*/
|
|
200
422
|
$route(initialRoute: Route): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
423
|
+
/**
|
|
424
|
+
* Adds type-safe custom errors to the contract.
|
|
425
|
+
* The provided errors are spared-merged with any existing errors in the contract.
|
|
426
|
+
*
|
|
427
|
+
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
428
|
+
*/
|
|
201
429
|
errors<U extends ErrorMap>(errors: U): ContractBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
430
|
+
/**
|
|
431
|
+
* Sets or updates the metadata for the contract.
|
|
432
|
+
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
433
|
+
*
|
|
434
|
+
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
435
|
+
*/
|
|
202
436
|
meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
437
|
+
/**
|
|
438
|
+
* Sets or updates the route definition for the contract.
|
|
439
|
+
* The provided route is spared-merged with any existing route in the contract.
|
|
440
|
+
* This option is typically relevant when integrating with OpenAPI.
|
|
441
|
+
*
|
|
442
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
443
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
444
|
+
*/
|
|
203
445
|
route(route: Route): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
446
|
+
/**
|
|
447
|
+
* Defines the input validation schema for the contract.
|
|
448
|
+
*
|
|
449
|
+
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
|
|
450
|
+
*/
|
|
204
451
|
input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>;
|
|
452
|
+
/**
|
|
453
|
+
* Defines the output validation schema for the contract.
|
|
454
|
+
*
|
|
455
|
+
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
|
|
456
|
+
*/
|
|
205
457
|
output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>;
|
|
458
|
+
/**
|
|
459
|
+
* Prefixes all procedures in the contract router.
|
|
460
|
+
* The provided prefix is post-appended to any existing router prefix.
|
|
461
|
+
*
|
|
462
|
+
* @note This option does not affect procedures that do not define a path in their route definition.
|
|
463
|
+
*
|
|
464
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
465
|
+
*/
|
|
206
466
|
prefix(prefix: HTTPPath): ContractRouterBuilder<TErrorMap, TMeta>;
|
|
467
|
+
/**
|
|
468
|
+
* Adds tags to all procedures in the contract router.
|
|
469
|
+
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
470
|
+
*
|
|
471
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
472
|
+
*/
|
|
207
473
|
tag(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>;
|
|
474
|
+
/**
|
|
475
|
+
* Applies all of the previously defined options to the specified contract router.
|
|
476
|
+
*
|
|
477
|
+
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
478
|
+
*/
|
|
208
479
|
router<T extends ContractRouter<TMeta>>(router: T): EnhancedContractRouter<T, TErrorMap>;
|
|
209
480
|
}
|
|
210
481
|
declare const oc: ContractBuilder<Schema<unknown, unknown>, Schema<unknown, unknown>, Record<never, never>, Record<never, never>>;
|
|
@@ -222,6 +493,11 @@ interface EventIteratorSchemaDetails {
|
|
|
222
493
|
yields: AnySchema;
|
|
223
494
|
returns?: AnySchema;
|
|
224
495
|
}
|
|
496
|
+
/**
|
|
497
|
+
* Define schema for an event iterator.
|
|
498
|
+
*
|
|
499
|
+
* @see {@link https://orpc.unnoq.com/docs/event-iterator#validate-event-iterator Validate Event Iterator Docs}
|
|
500
|
+
*/
|
|
225
501
|
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
502
|
declare function getEventIteratorSchemaDetails(schema: AnySchema | undefined): undefined | EventIteratorSchemaDetails;
|
|
227
503
|
|
package/dist/index.d.ts
CHANGED
|
@@ -10,12 +10,23 @@ type SchemaIssue = StandardSchemaV1.Issue;
|
|
|
10
10
|
type InferSchemaInput<T extends AnySchema> = T extends StandardSchemaV1<infer UInput, any> ? UInput : never;
|
|
11
11
|
type InferSchemaOutput<T extends AnySchema> = T extends StandardSchemaV1<any, infer UOutput> ? UOutput : never;
|
|
12
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
|
+
*/
|
|
13
19
|
declare function type<TInput, TOutput = TInput>(...[map]: TypeRest<TInput, TOutput>): Schema<TInput, TOutput>;
|
|
14
20
|
|
|
15
21
|
interface ValidationErrorOptions extends ErrorOptions {
|
|
16
22
|
message: string;
|
|
17
23
|
issues: readonly SchemaIssue[];
|
|
18
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
|
+
*/
|
|
19
30
|
declare class ValidationError extends Error {
|
|
20
31
|
readonly issues: readonly SchemaIssue[];
|
|
21
32
|
constructor(options: ValidationErrorOptions);
|
|
@@ -41,21 +52,61 @@ declare function mergeMeta<T extends Meta>(meta1: T, meta2: T): T;
|
|
|
41
52
|
type InputStructure = 'compact' | 'detailed';
|
|
42
53
|
type OutputStructure = 'compact' | 'detailed';
|
|
43
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
|
+
*/
|
|
44
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
|
+
*/
|
|
45
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
|
+
*/
|
|
46
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
|
+
*/
|
|
47
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
|
+
*/
|
|
48
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
|
+
*/
|
|
49
96
|
tags?: readonly string[];
|
|
50
97
|
/**
|
|
51
98
|
* The status code of the response when the procedure is successful.
|
|
99
|
+
* This option is typically relevant when integrating with OpenAPI.
|
|
52
100
|
*
|
|
101
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
53
102
|
* @default 200
|
|
54
103
|
*/
|
|
55
104
|
successStatus?: number;
|
|
56
105
|
/**
|
|
57
106
|
* The description of the response when the procedure is successful.
|
|
107
|
+
* This option is typically relevant when integrating with OpenAPI.
|
|
58
108
|
*
|
|
109
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
59
110
|
* @default 'OK'
|
|
60
111
|
*/
|
|
61
112
|
successDescription?: string;
|
|
@@ -78,6 +129,7 @@ interface Route {
|
|
|
78
129
|
* }
|
|
79
130
|
* ```
|
|
80
131
|
*
|
|
132
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
81
133
|
* @default 'compact'
|
|
82
134
|
*/
|
|
83
135
|
inputStructure?: InputStructure;
|
|
@@ -100,6 +152,7 @@ interface Route {
|
|
|
100
152
|
* };
|
|
101
153
|
* ```
|
|
102
154
|
*
|
|
155
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
103
156
|
* @default 'compact'
|
|
104
157
|
*/
|
|
105
158
|
outputStructure?: OutputStructure;
|
|
@@ -122,23 +175,55 @@ interface ContractProcedureDef<TInputSchema extends AnySchema, TOutputSchema ext
|
|
|
122
175
|
outputSchema?: TOutputSchema;
|
|
123
176
|
errorMap: TErrorMap;
|
|
124
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* This class represents a contract procedure.
|
|
180
|
+
*
|
|
181
|
+
* @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#procedure-contract Contract Procedure Docs}
|
|
182
|
+
*/
|
|
125
183
|
declare class ContractProcedure<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
184
|
+
/**
|
|
185
|
+
* This property holds the defined options for the contract procedure.
|
|
186
|
+
*/
|
|
126
187
|
'~orpc': ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
127
188
|
constructor(def: ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>);
|
|
128
189
|
}
|
|
129
190
|
type AnyContractProcedure = ContractProcedure<any, any, any, any>;
|
|
130
191
|
declare function isContractProcedure(item: unknown): item is AnyContractProcedure;
|
|
131
192
|
|
|
193
|
+
/**
|
|
194
|
+
* Represents a contract router, which defines a hierarchical structure of contract procedures.
|
|
195
|
+
*
|
|
196
|
+
* @info A contract procedure is a contract router too.
|
|
197
|
+
* @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#contract-router Contract Router Docs}
|
|
198
|
+
*/
|
|
132
199
|
type ContractRouter<TMeta extends Meta> = ContractProcedure<any, any, any, TMeta> | {
|
|
133
200
|
[k: string]: ContractRouter<TMeta>;
|
|
134
201
|
};
|
|
135
202
|
type AnyContractRouter = ContractRouter<any>;
|
|
203
|
+
/**
|
|
204
|
+
* Infer all inputs of the contract router.
|
|
205
|
+
*
|
|
206
|
+
* @info A contract procedure is a contract router too.
|
|
207
|
+
* @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#utilities Contract Utilities Docs}
|
|
208
|
+
*/
|
|
136
209
|
type InferContractRouterInputs<T extends AnyContractRouter> = T extends ContractProcedure<infer UInputSchema, any, any, any> ? InferSchemaInput<UInputSchema> : {
|
|
137
210
|
[K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterInputs<T[K]> : never;
|
|
138
211
|
};
|
|
212
|
+
/**
|
|
213
|
+
* Infer all outputs of the contract router.
|
|
214
|
+
*
|
|
215
|
+
* @info A contract procedure is a contract router too.
|
|
216
|
+
* @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#utilities Contract Utilities Docs}
|
|
217
|
+
*/
|
|
139
218
|
type InferContractRouterOutputs<T extends AnyContractRouter> = T extends ContractProcedure<any, infer UOutputSchema, any, any> ? InferSchemaOutput<UOutputSchema> : {
|
|
140
219
|
[K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterOutputs<T[K]> : never;
|
|
141
220
|
};
|
|
221
|
+
/**
|
|
222
|
+
* Infer all errors of the contract router.
|
|
223
|
+
*
|
|
224
|
+
* @info A contract procedure is a contract router too.
|
|
225
|
+
* @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#utilities Contract Utilities Docs}
|
|
226
|
+
*/
|
|
142
227
|
type InferContractRouterErrorMap<T extends AnyContractRouter> = T extends ContractProcedure<any, any, infer UErrorMap, any> ? UErrorMap : {
|
|
143
228
|
[K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterErrorMap<T[K]> : never;
|
|
144
229
|
}[keyof T];
|
|
@@ -154,57 +239,243 @@ interface EnhanceContractRouterOptions<TErrorMap extends ErrorMap> extends Enhan
|
|
|
154
239
|
declare function enhanceContractRouter<T extends AnyContractRouter, TErrorMap extends ErrorMap>(router: T, options: EnhanceContractRouterOptions<TErrorMap>): EnhancedContractRouter<T, TErrorMap>;
|
|
155
240
|
|
|
156
241
|
interface ContractProcedureBuilder<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
|
242
|
+
/**
|
|
243
|
+
* Adds type-safe custom errors to the contract.
|
|
244
|
+
* The provided errors are spared-merged with any existing errors in the contract.
|
|
245
|
+
*
|
|
246
|
+
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
247
|
+
*/
|
|
157
248
|
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
249
|
+
/**
|
|
250
|
+
* Sets or updates the metadata for the contract.
|
|
251
|
+
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
252
|
+
*
|
|
253
|
+
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
254
|
+
*/
|
|
158
255
|
meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
256
|
+
/**
|
|
257
|
+
* Sets or updates the route definition for the contract.
|
|
258
|
+
* The provided route is spared-merged with any existing route in the contract.
|
|
259
|
+
* This option is typically relevant when integrating with OpenAPI.
|
|
260
|
+
*
|
|
261
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
262
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
263
|
+
*/
|
|
159
264
|
route(route: Route): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
265
|
+
/**
|
|
266
|
+
* Defines the input validation schema for the contract.
|
|
267
|
+
*
|
|
268
|
+
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
|
|
269
|
+
*/
|
|
160
270
|
input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>;
|
|
271
|
+
/**
|
|
272
|
+
* Defines the output validation schema for the contract.
|
|
273
|
+
*
|
|
274
|
+
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
|
|
275
|
+
*/
|
|
161
276
|
output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>;
|
|
162
277
|
}
|
|
163
278
|
interface ContractProcedureBuilderWithInput<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
|
279
|
+
/**
|
|
280
|
+
* Adds type-safe custom errors to the contract.
|
|
281
|
+
* The provided errors are spared-merged with any existing errors in the contract.
|
|
282
|
+
*
|
|
283
|
+
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
284
|
+
*/
|
|
164
285
|
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
286
|
+
/**
|
|
287
|
+
* Sets or updates the metadata for the contract.
|
|
288
|
+
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
289
|
+
*
|
|
290
|
+
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
291
|
+
*/
|
|
165
292
|
meta(meta: TMeta): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
293
|
+
/**
|
|
294
|
+
* Sets or updates the route definition for the contract.
|
|
295
|
+
* The provided route is spared-merged with any existing route in the contract.
|
|
296
|
+
* This option is typically relevant when integrating with OpenAPI.
|
|
297
|
+
*
|
|
298
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
299
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
300
|
+
*/
|
|
166
301
|
route(route: Route): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
302
|
+
/**
|
|
303
|
+
* Defines the output validation schema for the contract.
|
|
304
|
+
*
|
|
305
|
+
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
|
|
306
|
+
*/
|
|
167
307
|
output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInputOutput<TInputSchema, U, TErrorMap, TMeta>;
|
|
168
308
|
}
|
|
169
309
|
interface ContractProcedureBuilderWithOutput<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
|
310
|
+
/**
|
|
311
|
+
* Adds type-safe custom errors to the contract.
|
|
312
|
+
* The provided errors are spared-merged with any existing errors in the contract.
|
|
313
|
+
*
|
|
314
|
+
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
315
|
+
*/
|
|
170
316
|
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
317
|
+
/**
|
|
318
|
+
* Sets or updates the metadata for the contract.
|
|
319
|
+
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
320
|
+
*
|
|
321
|
+
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
322
|
+
*/
|
|
171
323
|
meta(meta: TMeta): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
324
|
+
/**
|
|
325
|
+
* Sets or updates the route definition for the contract.
|
|
326
|
+
* The provided route is spared-merged with any existing route in the contract.
|
|
327
|
+
* This option is typically relevant when integrating with OpenAPI.
|
|
328
|
+
*
|
|
329
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
330
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
331
|
+
*/
|
|
172
332
|
route(route: Route): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
333
|
+
/**
|
|
334
|
+
* Defines the input validation schema for the contract.
|
|
335
|
+
*
|
|
336
|
+
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
|
|
337
|
+
*/
|
|
173
338
|
input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInputOutput<U, TOutputSchema, TErrorMap, TMeta>;
|
|
174
339
|
}
|
|
175
340
|
interface ContractProcedureBuilderWithInputOutput<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
|
341
|
+
/**
|
|
342
|
+
* Adds type-safe custom errors to the contract.
|
|
343
|
+
* The provided errors are spared-merged with any existing errors in the contract.
|
|
344
|
+
*
|
|
345
|
+
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
346
|
+
*/
|
|
176
347
|
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
348
|
+
/**
|
|
349
|
+
* Sets or updates the metadata for the contract.
|
|
350
|
+
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
351
|
+
*
|
|
352
|
+
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
353
|
+
*/
|
|
177
354
|
meta(meta: TMeta): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
355
|
+
/**
|
|
356
|
+
* Sets or updates the route definition for the contract.
|
|
357
|
+
* The provided route is spared-merged with any existing route in the contract.
|
|
358
|
+
* This option is typically relevant when integrating with OpenAPI.
|
|
359
|
+
*
|
|
360
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
361
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
362
|
+
*/
|
|
178
363
|
route(route: Route): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
179
364
|
}
|
|
180
365
|
interface ContractRouterBuilder<TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
366
|
+
/**
|
|
367
|
+
* This property holds the defined options for the contract router.
|
|
368
|
+
*/
|
|
181
369
|
'~orpc': EnhanceContractRouterOptions<TErrorMap>;
|
|
370
|
+
/**
|
|
371
|
+
* Adds type-safe custom errors to the contract.
|
|
372
|
+
* The provided errors are spared-merged with any existing errors in the contract.
|
|
373
|
+
*
|
|
374
|
+
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
375
|
+
*/
|
|
182
376
|
'errors'<U extends ErrorMap>(errors: U): ContractRouterBuilder<MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
377
|
+
/**
|
|
378
|
+
* Prefixes all procedures in the contract router.
|
|
379
|
+
* The provided prefix is post-appended to any existing router prefix.
|
|
380
|
+
*
|
|
381
|
+
* @note This option does not affect procedures that do not define a path in their route definition.
|
|
382
|
+
*
|
|
383
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
384
|
+
*/
|
|
183
385
|
'prefix'(prefix: HTTPPath): ContractRouterBuilder<TErrorMap, TMeta>;
|
|
386
|
+
/**
|
|
387
|
+
* Adds tags to all procedures in the contract router.
|
|
388
|
+
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
389
|
+
*
|
|
390
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
391
|
+
*/
|
|
184
392
|
'tag'(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>;
|
|
393
|
+
/**
|
|
394
|
+
* Applies all of the previously defined options to the specified contract router.
|
|
395
|
+
*
|
|
396
|
+
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
397
|
+
*/
|
|
185
398
|
'router'<T extends ContractRouter<TMeta>>(router: T): EnhancedContractRouter<T, TErrorMap>;
|
|
186
399
|
}
|
|
187
400
|
|
|
188
401
|
interface ContractBuilderDef<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>, EnhanceContractRouterOptions<TErrorMap> {
|
|
189
402
|
}
|
|
190
403
|
declare class ContractBuilder<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
|
404
|
+
/**
|
|
405
|
+
* This property holds the defined options for the contract.
|
|
406
|
+
*/
|
|
191
407
|
'~orpc': ContractBuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
192
408
|
constructor(def: ContractBuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>);
|
|
193
409
|
/**
|
|
194
|
-
*
|
|
410
|
+
* Sets or overrides the initial meta.
|
|
411
|
+
*
|
|
412
|
+
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
195
413
|
*/
|
|
196
414
|
$meta<U extends Meta>(initialMeta: U): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, U & Record<never, never>>;
|
|
197
415
|
/**
|
|
198
|
-
*
|
|
416
|
+
* Sets or overrides the initial route.
|
|
417
|
+
* This option is typically relevant when integrating with OpenAPI.
|
|
418
|
+
*
|
|
419
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
420
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
199
421
|
*/
|
|
200
422
|
$route(initialRoute: Route): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
423
|
+
/**
|
|
424
|
+
* Adds type-safe custom errors to the contract.
|
|
425
|
+
* The provided errors are spared-merged with any existing errors in the contract.
|
|
426
|
+
*
|
|
427
|
+
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
428
|
+
*/
|
|
201
429
|
errors<U extends ErrorMap>(errors: U): ContractBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
430
|
+
/**
|
|
431
|
+
* Sets or updates the metadata for the contract.
|
|
432
|
+
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
433
|
+
*
|
|
434
|
+
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
435
|
+
*/
|
|
202
436
|
meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
437
|
+
/**
|
|
438
|
+
* Sets or updates the route definition for the contract.
|
|
439
|
+
* The provided route is spared-merged with any existing route in the contract.
|
|
440
|
+
* This option is typically relevant when integrating with OpenAPI.
|
|
441
|
+
*
|
|
442
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
443
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
444
|
+
*/
|
|
203
445
|
route(route: Route): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
446
|
+
/**
|
|
447
|
+
* Defines the input validation schema for the contract.
|
|
448
|
+
*
|
|
449
|
+
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
|
|
450
|
+
*/
|
|
204
451
|
input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>;
|
|
452
|
+
/**
|
|
453
|
+
* Defines the output validation schema for the contract.
|
|
454
|
+
*
|
|
455
|
+
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
|
|
456
|
+
*/
|
|
205
457
|
output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>;
|
|
458
|
+
/**
|
|
459
|
+
* Prefixes all procedures in the contract router.
|
|
460
|
+
* The provided prefix is post-appended to any existing router prefix.
|
|
461
|
+
*
|
|
462
|
+
* @note This option does not affect procedures that do not define a path in their route definition.
|
|
463
|
+
*
|
|
464
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
465
|
+
*/
|
|
206
466
|
prefix(prefix: HTTPPath): ContractRouterBuilder<TErrorMap, TMeta>;
|
|
467
|
+
/**
|
|
468
|
+
* Adds tags to all procedures in the contract router.
|
|
469
|
+
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
470
|
+
*
|
|
471
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
472
|
+
*/
|
|
207
473
|
tag(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>;
|
|
474
|
+
/**
|
|
475
|
+
* Applies all of the previously defined options to the specified contract router.
|
|
476
|
+
*
|
|
477
|
+
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
478
|
+
*/
|
|
208
479
|
router<T extends ContractRouter<TMeta>>(router: T): EnhancedContractRouter<T, TErrorMap>;
|
|
209
480
|
}
|
|
210
481
|
declare const oc: ContractBuilder<Schema<unknown, unknown>, Schema<unknown, unknown>, Record<never, never>, Record<never, never>>;
|
|
@@ -222,6 +493,11 @@ interface EventIteratorSchemaDetails {
|
|
|
222
493
|
yields: AnySchema;
|
|
223
494
|
returns?: AnySchema;
|
|
224
495
|
}
|
|
496
|
+
/**
|
|
497
|
+
* Define schema for an event iterator.
|
|
498
|
+
*
|
|
499
|
+
* @see {@link https://orpc.unnoq.com/docs/event-iterator#validate-event-iterator Validate Event Iterator Docs}
|
|
500
|
+
*/
|
|
225
501
|
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
502
|
declare function getEventIteratorSchemaDetails(schema: AnySchema | undefined): undefined | EventIteratorSchemaDetails;
|
|
227
503
|
|
package/dist/index.mjs
CHANGED
|
@@ -18,6 +18,9 @@ function mergeMeta(meta1, meta2) {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
class ContractProcedure {
|
|
21
|
+
/**
|
|
22
|
+
* This property holds the defined options for the contract procedure.
|
|
23
|
+
*/
|
|
21
24
|
"~orpc";
|
|
22
25
|
constructor(def) {
|
|
23
26
|
if (def.route?.successStatus && isORPCErrorStatus(def.route.successStatus)) {
|
|
@@ -108,7 +111,9 @@ class ContractBuilder extends ContractProcedure {
|
|
|
108
111
|
this["~orpc"].tags = def.tags;
|
|
109
112
|
}
|
|
110
113
|
/**
|
|
111
|
-
*
|
|
114
|
+
* Sets or overrides the initial meta.
|
|
115
|
+
*
|
|
116
|
+
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
112
117
|
*/
|
|
113
118
|
$meta(initialMeta) {
|
|
114
119
|
return new ContractBuilder({
|
|
@@ -117,7 +122,11 @@ class ContractBuilder extends ContractProcedure {
|
|
|
117
122
|
});
|
|
118
123
|
}
|
|
119
124
|
/**
|
|
120
|
-
*
|
|
125
|
+
* Sets or overrides the initial route.
|
|
126
|
+
* This option is typically relevant when integrating with OpenAPI.
|
|
127
|
+
*
|
|
128
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
129
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
121
130
|
*/
|
|
122
131
|
$route(initialRoute) {
|
|
123
132
|
return new ContractBuilder({
|
|
@@ -125,48 +134,97 @@ class ContractBuilder extends ContractProcedure {
|
|
|
125
134
|
route: initialRoute
|
|
126
135
|
});
|
|
127
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Adds type-safe custom errors to the contract.
|
|
139
|
+
* The provided errors are spared-merged with any existing errors in the contract.
|
|
140
|
+
*
|
|
141
|
+
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
142
|
+
*/
|
|
128
143
|
errors(errors) {
|
|
129
144
|
return new ContractBuilder({
|
|
130
145
|
...this["~orpc"],
|
|
131
146
|
errorMap: mergeErrorMap(this["~orpc"].errorMap, errors)
|
|
132
147
|
});
|
|
133
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Sets or updates the metadata for the contract.
|
|
151
|
+
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
152
|
+
*
|
|
153
|
+
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
154
|
+
*/
|
|
134
155
|
meta(meta) {
|
|
135
156
|
return new ContractBuilder({
|
|
136
157
|
...this["~orpc"],
|
|
137
158
|
meta: mergeMeta(this["~orpc"].meta, meta)
|
|
138
159
|
});
|
|
139
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Sets or updates the route definition for the contract.
|
|
163
|
+
* The provided route is spared-merged with any existing route in the contract.
|
|
164
|
+
* This option is typically relevant when integrating with OpenAPI.
|
|
165
|
+
*
|
|
166
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
167
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
168
|
+
*/
|
|
140
169
|
route(route) {
|
|
141
170
|
return new ContractBuilder({
|
|
142
171
|
...this["~orpc"],
|
|
143
172
|
route: mergeRoute(this["~orpc"].route, route)
|
|
144
173
|
});
|
|
145
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* Defines the input validation schema for the contract.
|
|
177
|
+
*
|
|
178
|
+
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
|
|
179
|
+
*/
|
|
146
180
|
input(schema) {
|
|
147
181
|
return new ContractBuilder({
|
|
148
182
|
...this["~orpc"],
|
|
149
183
|
inputSchema: schema
|
|
150
184
|
});
|
|
151
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* Defines the output validation schema for the contract.
|
|
188
|
+
*
|
|
189
|
+
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
|
|
190
|
+
*/
|
|
152
191
|
output(schema) {
|
|
153
192
|
return new ContractBuilder({
|
|
154
193
|
...this["~orpc"],
|
|
155
194
|
outputSchema: schema
|
|
156
195
|
});
|
|
157
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Prefixes all procedures in the contract router.
|
|
199
|
+
* The provided prefix is post-appended to any existing router prefix.
|
|
200
|
+
*
|
|
201
|
+
* @note This option does not affect procedures that do not define a path in their route definition.
|
|
202
|
+
*
|
|
203
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
204
|
+
*/
|
|
158
205
|
prefix(prefix) {
|
|
159
206
|
return new ContractBuilder({
|
|
160
207
|
...this["~orpc"],
|
|
161
208
|
prefix: mergePrefix(this["~orpc"].prefix, prefix)
|
|
162
209
|
});
|
|
163
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Adds tags to all procedures in the contract router.
|
|
213
|
+
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
214
|
+
*
|
|
215
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
216
|
+
*/
|
|
164
217
|
tag(...tags) {
|
|
165
218
|
return new ContractBuilder({
|
|
166
219
|
...this["~orpc"],
|
|
167
220
|
tags: mergeTags(this["~orpc"].tags, tags)
|
|
168
221
|
});
|
|
169
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Applies all of the previously defined options to the specified contract router.
|
|
225
|
+
*
|
|
226
|
+
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
227
|
+
*/
|
|
170
228
|
router(router) {
|
|
171
229
|
return enhanceContractRouter(router, this["~orpc"]);
|
|
172
230
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/contract",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@standard-schema/spec": "^1.0.0",
|
|
28
|
-
"@orpc/
|
|
29
|
-
"@orpc/
|
|
28
|
+
"@orpc/client": "1.0.3",
|
|
29
|
+
"@orpc/shared": "1.0.3"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"arktype": "2.1.19",
|