@orpc/contract 0.0.0-next.80c9415 → 0.0.0-next.80df4d2
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 +6 -3
- package/dist/index.d.mts +42 -42
- package/dist/index.d.ts +42 -42
- package/dist/index.mjs +13 -12
- package/dist/plugins/index.d.mts +22 -3
- package/dist/plugins/index.d.ts +22 -3
- package/dist/plugins/index.mjs +41 -3
- package/dist/shared/{contract.CvRxURhn.d.mts → contract.TuRtB1Ca.d.mts} +18 -18
- package/dist/shared/{contract.CvRxURhn.d.ts → contract.TuRtB1Ca.d.ts} +18 -18
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<image align="center" src="https://orpc.
|
|
2
|
+
<image align="center" src="https://orpc.dev/logo.webp" width=280 alt="oRPC logo" />
|
|
3
3
|
</div>
|
|
4
4
|
|
|
5
5
|
<h1></h1>
|
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
<a href="https://discord.gg/TXEbwRBvQn">
|
|
18
18
|
<img alt="Discord" src="https://img.shields.io/discord/1308966753044398161?color=7389D8&label&logo=discord&logoColor=ffffff" />
|
|
19
19
|
</a>
|
|
20
|
+
<a href="https://deepwiki.com/unnoq/orpc">
|
|
21
|
+
<img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki">
|
|
22
|
+
</a>
|
|
20
23
|
</div>
|
|
21
24
|
|
|
22
25
|
<h3 align="center">Typesafe APIs Made Simple 🪄</h3>
|
|
@@ -42,7 +45,7 @@
|
|
|
42
45
|
|
|
43
46
|
## Documentation
|
|
44
47
|
|
|
45
|
-
You can find the full documentation [here](https://orpc.
|
|
48
|
+
You can find the full documentation [here](https://orpc.dev).
|
|
46
49
|
|
|
47
50
|
## Packages
|
|
48
51
|
|
|
@@ -63,7 +66,7 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
63
66
|
|
|
64
67
|
## `@orpc/contract`
|
|
65
68
|
|
|
66
|
-
Build your API contract. Read the [documentation](https://orpc.
|
|
69
|
+
Build your API contract. Read the [documentation](https://orpc.dev/docs/contract-first/define-contract) for more information.
|
|
67
70
|
|
|
68
71
|
```ts
|
|
69
72
|
export const PlanetSchema = z.object({
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { HTTPPath, HTTPMethod, ClientContext, Client } from '@orpc/client';
|
|
2
2
|
export { HTTPMethod, HTTPPath, ORPCError } from '@orpc/client';
|
|
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.
|
|
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.
|
|
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
5
|
import { AsyncIteratorClass } from '@orpc/shared';
|
|
6
|
-
export { Registry, ThrowableError } from '@orpc/shared';
|
|
6
|
+
export { AsyncIteratorClass, Registry, ThrowableError } from '@orpc/shared';
|
|
7
7
|
export { OpenAPIV3_1 as OpenAPI } from 'openapi-types';
|
|
8
8
|
import '@standard-schema/spec';
|
|
9
9
|
|
|
@@ -21,7 +21,7 @@ declare function enhanceContractRouter<T extends AnyContractRouter, TErrorMap ex
|
|
|
21
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
22
|
* This reduces the size of the contract and helps prevent leaking internal details of the router to the client.
|
|
23
23
|
*
|
|
24
|
-
* @see {@link https://orpc.
|
|
24
|
+
* @see {@link https://orpc.dev/docs/contract-first/router-to-contract#minify-export-the-contract-router-for-the-client Router to Contract Docs}
|
|
25
25
|
*/
|
|
26
26
|
declare function minifyContractRouter(router: AnyContractRouter): AnyContractRouter;
|
|
27
27
|
|
|
@@ -30,14 +30,14 @@ interface ContractProcedureBuilder<TInputSchema extends AnySchema, TOutputSchema
|
|
|
30
30
|
* Adds type-safe custom errors to the contract.
|
|
31
31
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
32
32
|
*
|
|
33
|
-
* @see {@link https://orpc.
|
|
33
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
34
34
|
*/
|
|
35
35
|
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
36
36
|
/**
|
|
37
37
|
* Sets or updates the metadata for the contract.
|
|
38
38
|
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
39
39
|
*
|
|
40
|
-
* @see {@link https://orpc.
|
|
40
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
41
41
|
*/
|
|
42
42
|
meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
43
43
|
/**
|
|
@@ -45,20 +45,20 @@ interface ContractProcedureBuilder<TInputSchema extends AnySchema, TOutputSchema
|
|
|
45
45
|
* The provided route is spared-merged with any existing route in the contract.
|
|
46
46
|
* This option is typically relevant when integrating with OpenAPI.
|
|
47
47
|
*
|
|
48
|
-
* @see {@link https://orpc.
|
|
49
|
-
* @see {@link https://orpc.
|
|
48
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
49
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
50
50
|
*/
|
|
51
51
|
route(route: Route): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
52
52
|
/**
|
|
53
53
|
* Defines the input validation schema for the contract.
|
|
54
54
|
*
|
|
55
|
-
* @see {@link https://orpc.
|
|
55
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs}
|
|
56
56
|
*/
|
|
57
57
|
input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>;
|
|
58
58
|
/**
|
|
59
59
|
* Defines the output validation schema for the contract.
|
|
60
60
|
*
|
|
61
|
-
* @see {@link https://orpc.
|
|
61
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs}
|
|
62
62
|
*/
|
|
63
63
|
output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>;
|
|
64
64
|
}
|
|
@@ -67,14 +67,14 @@ interface ContractProcedureBuilderWithInput<TInputSchema extends AnySchema, TOut
|
|
|
67
67
|
* Adds type-safe custom errors to the contract.
|
|
68
68
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
69
69
|
*
|
|
70
|
-
* @see {@link https://orpc.
|
|
70
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
71
71
|
*/
|
|
72
72
|
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
73
73
|
/**
|
|
74
74
|
* Sets or updates the metadata for the contract.
|
|
75
75
|
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
76
76
|
*
|
|
77
|
-
* @see {@link https://orpc.
|
|
77
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
78
78
|
*/
|
|
79
79
|
meta(meta: TMeta): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
80
80
|
/**
|
|
@@ -82,14 +82,14 @@ interface ContractProcedureBuilderWithInput<TInputSchema extends AnySchema, TOut
|
|
|
82
82
|
* The provided route is spared-merged with any existing route in the contract.
|
|
83
83
|
* This option is typically relevant when integrating with OpenAPI.
|
|
84
84
|
*
|
|
85
|
-
* @see {@link https://orpc.
|
|
86
|
-
* @see {@link https://orpc.
|
|
85
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
86
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
87
87
|
*/
|
|
88
88
|
route(route: Route): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
89
89
|
/**
|
|
90
90
|
* Defines the output validation schema for the contract.
|
|
91
91
|
*
|
|
92
|
-
* @see {@link https://orpc.
|
|
92
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs}
|
|
93
93
|
*/
|
|
94
94
|
output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInputOutput<TInputSchema, U, TErrorMap, TMeta>;
|
|
95
95
|
}
|
|
@@ -98,14 +98,14 @@ interface ContractProcedureBuilderWithOutput<TInputSchema extends AnySchema, TOu
|
|
|
98
98
|
* Adds type-safe custom errors to the contract.
|
|
99
99
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
100
100
|
*
|
|
101
|
-
* @see {@link https://orpc.
|
|
101
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
102
102
|
*/
|
|
103
103
|
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
104
104
|
/**
|
|
105
105
|
* Sets or updates the metadata for the contract.
|
|
106
106
|
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
107
107
|
*
|
|
108
|
-
* @see {@link https://orpc.
|
|
108
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
109
109
|
*/
|
|
110
110
|
meta(meta: TMeta): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
111
111
|
/**
|
|
@@ -113,14 +113,14 @@ interface ContractProcedureBuilderWithOutput<TInputSchema extends AnySchema, TOu
|
|
|
113
113
|
* The provided route is spared-merged with any existing route in the contract.
|
|
114
114
|
* This option is typically relevant when integrating with OpenAPI.
|
|
115
115
|
*
|
|
116
|
-
* @see {@link https://orpc.
|
|
117
|
-
* @see {@link https://orpc.
|
|
116
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
117
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
118
118
|
*/
|
|
119
119
|
route(route: Route): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
120
120
|
/**
|
|
121
121
|
* Defines the input validation schema for the contract.
|
|
122
122
|
*
|
|
123
|
-
* @see {@link https://orpc.
|
|
123
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs}
|
|
124
124
|
*/
|
|
125
125
|
input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInputOutput<U, TOutputSchema, TErrorMap, TMeta>;
|
|
126
126
|
}
|
|
@@ -129,14 +129,14 @@ interface ContractProcedureBuilderWithInputOutput<TInputSchema extends AnySchema
|
|
|
129
129
|
* Adds type-safe custom errors to the contract.
|
|
130
130
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
131
131
|
*
|
|
132
|
-
* @see {@link https://orpc.
|
|
132
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
133
133
|
*/
|
|
134
134
|
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
135
135
|
/**
|
|
136
136
|
* Sets or updates the metadata for the contract.
|
|
137
137
|
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
138
138
|
*
|
|
139
|
-
* @see {@link https://orpc.
|
|
139
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
140
140
|
*/
|
|
141
141
|
meta(meta: TMeta): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
142
142
|
/**
|
|
@@ -144,8 +144,8 @@ interface ContractProcedureBuilderWithInputOutput<TInputSchema extends AnySchema
|
|
|
144
144
|
* The provided route is spared-merged with any existing route in the contract.
|
|
145
145
|
* This option is typically relevant when integrating with OpenAPI.
|
|
146
146
|
*
|
|
147
|
-
* @see {@link https://orpc.
|
|
148
|
-
* @see {@link https://orpc.
|
|
147
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
148
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
149
149
|
*/
|
|
150
150
|
route(route: Route): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
151
151
|
}
|
|
@@ -158,7 +158,7 @@ interface ContractRouterBuilder<TErrorMap extends ErrorMap, TMeta extends Meta>
|
|
|
158
158
|
* Adds type-safe custom errors to the contract.
|
|
159
159
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
160
160
|
*
|
|
161
|
-
* @see {@link https://orpc.
|
|
161
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
162
162
|
*/
|
|
163
163
|
'errors'<U extends ErrorMap>(errors: U): ContractRouterBuilder<MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
164
164
|
/**
|
|
@@ -167,20 +167,20 @@ interface ContractRouterBuilder<TErrorMap extends ErrorMap, TMeta extends Meta>
|
|
|
167
167
|
*
|
|
168
168
|
* @note This option does not affect procedures that do not define a path in their route definition.
|
|
169
169
|
*
|
|
170
|
-
* @see {@link https://orpc.
|
|
170
|
+
* @see {@link https://orpc.dev/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
171
171
|
*/
|
|
172
172
|
'prefix'(prefix: HTTPPath): ContractRouterBuilder<TErrorMap, TMeta>;
|
|
173
173
|
/**
|
|
174
174
|
* Adds tags to all procedures in the contract router.
|
|
175
175
|
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
176
176
|
*
|
|
177
|
-
* @see {@link https://orpc.
|
|
177
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
178
178
|
*/
|
|
179
179
|
'tag'(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>;
|
|
180
180
|
/**
|
|
181
181
|
* Applies all of the previously defined options to the specified contract router.
|
|
182
182
|
*
|
|
183
|
-
* @see {@link https://orpc.
|
|
183
|
+
* @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs}
|
|
184
184
|
*/
|
|
185
185
|
'router'<T extends ContractRouter<TMeta>>(router: T): EnhancedContractRouter<T, TErrorMap>;
|
|
186
186
|
}
|
|
@@ -196,29 +196,29 @@ declare class ContractBuilder<TInputSchema extends AnySchema, TOutputSchema exte
|
|
|
196
196
|
/**
|
|
197
197
|
* Sets or overrides the initial meta.
|
|
198
198
|
*
|
|
199
|
-
* @see {@link https://orpc.
|
|
199
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
200
200
|
*/
|
|
201
201
|
$meta<U extends Meta>(initialMeta: U): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, U & Record<never, never>>;
|
|
202
202
|
/**
|
|
203
203
|
* Sets or overrides the initial route.
|
|
204
204
|
* This option is typically relevant when integrating with OpenAPI.
|
|
205
205
|
*
|
|
206
|
-
* @see {@link https://orpc.
|
|
207
|
-
* @see {@link https://orpc.
|
|
206
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
207
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
208
208
|
*/
|
|
209
209
|
$route(initialRoute: Route): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
210
210
|
/**
|
|
211
211
|
* Adds type-safe custom errors to the contract.
|
|
212
212
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
213
213
|
*
|
|
214
|
-
* @see {@link https://orpc.
|
|
214
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
215
215
|
*/
|
|
216
216
|
errors<U extends ErrorMap>(errors: U): ContractBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
217
217
|
/**
|
|
218
218
|
* Sets or updates the metadata for the contract.
|
|
219
219
|
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
220
220
|
*
|
|
221
|
-
* @see {@link https://orpc.
|
|
221
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
222
222
|
*/
|
|
223
223
|
meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
224
224
|
/**
|
|
@@ -226,20 +226,20 @@ declare class ContractBuilder<TInputSchema extends AnySchema, TOutputSchema exte
|
|
|
226
226
|
* The provided route is spared-merged with any existing route in the contract.
|
|
227
227
|
* This option is typically relevant when integrating with OpenAPI.
|
|
228
228
|
*
|
|
229
|
-
* @see {@link https://orpc.
|
|
230
|
-
* @see {@link https://orpc.
|
|
229
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
230
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
231
231
|
*/
|
|
232
232
|
route(route: Route): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
233
233
|
/**
|
|
234
234
|
* Defines the input validation schema for the contract.
|
|
235
235
|
*
|
|
236
|
-
* @see {@link https://orpc.
|
|
236
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs}
|
|
237
237
|
*/
|
|
238
238
|
input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>;
|
|
239
239
|
/**
|
|
240
240
|
* Defines the output validation schema for the contract.
|
|
241
241
|
*
|
|
242
|
-
* @see {@link https://orpc.
|
|
242
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs}
|
|
243
243
|
*/
|
|
244
244
|
output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>;
|
|
245
245
|
/**
|
|
@@ -248,20 +248,20 @@ declare class ContractBuilder<TInputSchema extends AnySchema, TOutputSchema exte
|
|
|
248
248
|
*
|
|
249
249
|
* @note This option does not affect procedures that do not define a path in their route definition.
|
|
250
250
|
*
|
|
251
|
-
* @see {@link https://orpc.
|
|
251
|
+
* @see {@link https://orpc.dev/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
252
252
|
*/
|
|
253
253
|
prefix(prefix: HTTPPath): ContractRouterBuilder<TErrorMap, TMeta>;
|
|
254
254
|
/**
|
|
255
255
|
* Adds tags to all procedures in the contract router.
|
|
256
256
|
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
257
257
|
*
|
|
258
|
-
* @see {@link https://orpc.
|
|
258
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
259
259
|
*/
|
|
260
260
|
tag(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>;
|
|
261
261
|
/**
|
|
262
262
|
* Applies all of the previously defined options to the specified contract router.
|
|
263
263
|
*
|
|
264
|
-
* @see {@link https://orpc.
|
|
264
|
+
* @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs}
|
|
265
265
|
*/
|
|
266
266
|
router<T extends ContractRouter<TMeta>>(router: T): EnhancedContractRouter<T, TErrorMap>;
|
|
267
267
|
}
|
|
@@ -283,7 +283,7 @@ interface EventIteratorSchemaDetails {
|
|
|
283
283
|
/**
|
|
284
284
|
* Define schema for an event iterator.
|
|
285
285
|
*
|
|
286
|
-
* @see {@link https://orpc.
|
|
286
|
+
* @see {@link https://orpc.dev/docs/event-iterator#validate-event-iterator Validate Event Iterator Docs}
|
|
287
287
|
*/
|
|
288
288
|
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>>;
|
|
289
289
|
declare function getEventIteratorSchemaDetails(schema: AnySchema | undefined): undefined | EventIteratorSchemaDetails;
|
|
@@ -291,7 +291,7 @@ declare function getEventIteratorSchemaDetails(schema: AnySchema | undefined): u
|
|
|
291
291
|
/**
|
|
292
292
|
* Help RPCLink automatically send requests using the specified HTTP method in the contract.
|
|
293
293
|
*
|
|
294
|
-
* @see {@link https://orpc.
|
|
294
|
+
* @see {@link https://orpc.dev/docs/client/rpc-link#custom-request-method RPCLink Custom Request Method}
|
|
295
295
|
*/
|
|
296
296
|
declare function inferRPCMethodFromContractRouter(contract: AnyContractRouter): (options: unknown, path: readonly string[]) => Exclude<HTTPMethod, 'HEAD'>;
|
|
297
297
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { HTTPPath, HTTPMethod, ClientContext, Client } from '@orpc/client';
|
|
2
2
|
export { HTTPMethod, HTTPPath, ORPCError } from '@orpc/client';
|
|
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.
|
|
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.
|
|
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.js';
|
|
4
|
+
export { o as AnyContractProcedure, k as ErrorMapItem, z as InferContractRouterErrorMap, x as InferContractRouterInputs, B as InferContractRouterMeta, y as InferContractRouterOutputs, l as ORPCErrorFromErrorMap, T as TypeRest, j as ValidationError, V as ValidationErrorOptions, w as enhanceRoute, p as isContractProcedure, m as mergeErrorMap, n as mergeMeta, s as mergePrefix, q as mergeRoute, t as mergeTags, r as prefixRoute, D as type, u as unshiftTagRoute, v as validateORPCError } from './shared/contract.TuRtB1Ca.js';
|
|
5
5
|
import { AsyncIteratorClass } from '@orpc/shared';
|
|
6
|
-
export { Registry, ThrowableError } from '@orpc/shared';
|
|
6
|
+
export { AsyncIteratorClass, Registry, ThrowableError } from '@orpc/shared';
|
|
7
7
|
export { OpenAPIV3_1 as OpenAPI } from 'openapi-types';
|
|
8
8
|
import '@standard-schema/spec';
|
|
9
9
|
|
|
@@ -21,7 +21,7 @@ declare function enhanceContractRouter<T extends AnyContractRouter, TErrorMap ex
|
|
|
21
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
22
|
* This reduces the size of the contract and helps prevent leaking internal details of the router to the client.
|
|
23
23
|
*
|
|
24
|
-
* @see {@link https://orpc.
|
|
24
|
+
* @see {@link https://orpc.dev/docs/contract-first/router-to-contract#minify-export-the-contract-router-for-the-client Router to Contract Docs}
|
|
25
25
|
*/
|
|
26
26
|
declare function minifyContractRouter(router: AnyContractRouter): AnyContractRouter;
|
|
27
27
|
|
|
@@ -30,14 +30,14 @@ interface ContractProcedureBuilder<TInputSchema extends AnySchema, TOutputSchema
|
|
|
30
30
|
* Adds type-safe custom errors to the contract.
|
|
31
31
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
32
32
|
*
|
|
33
|
-
* @see {@link https://orpc.
|
|
33
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
34
34
|
*/
|
|
35
35
|
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
36
36
|
/**
|
|
37
37
|
* Sets or updates the metadata for the contract.
|
|
38
38
|
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
39
39
|
*
|
|
40
|
-
* @see {@link https://orpc.
|
|
40
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
41
41
|
*/
|
|
42
42
|
meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
43
43
|
/**
|
|
@@ -45,20 +45,20 @@ interface ContractProcedureBuilder<TInputSchema extends AnySchema, TOutputSchema
|
|
|
45
45
|
* The provided route is spared-merged with any existing route in the contract.
|
|
46
46
|
* This option is typically relevant when integrating with OpenAPI.
|
|
47
47
|
*
|
|
48
|
-
* @see {@link https://orpc.
|
|
49
|
-
* @see {@link https://orpc.
|
|
48
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
49
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
50
50
|
*/
|
|
51
51
|
route(route: Route): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
52
52
|
/**
|
|
53
53
|
* Defines the input validation schema for the contract.
|
|
54
54
|
*
|
|
55
|
-
* @see {@link https://orpc.
|
|
55
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs}
|
|
56
56
|
*/
|
|
57
57
|
input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>;
|
|
58
58
|
/**
|
|
59
59
|
* Defines the output validation schema for the contract.
|
|
60
60
|
*
|
|
61
|
-
* @see {@link https://orpc.
|
|
61
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs}
|
|
62
62
|
*/
|
|
63
63
|
output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>;
|
|
64
64
|
}
|
|
@@ -67,14 +67,14 @@ interface ContractProcedureBuilderWithInput<TInputSchema extends AnySchema, TOut
|
|
|
67
67
|
* Adds type-safe custom errors to the contract.
|
|
68
68
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
69
69
|
*
|
|
70
|
-
* @see {@link https://orpc.
|
|
70
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
71
71
|
*/
|
|
72
72
|
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
73
73
|
/**
|
|
74
74
|
* Sets or updates the metadata for the contract.
|
|
75
75
|
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
76
76
|
*
|
|
77
|
-
* @see {@link https://orpc.
|
|
77
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
78
78
|
*/
|
|
79
79
|
meta(meta: TMeta): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
80
80
|
/**
|
|
@@ -82,14 +82,14 @@ interface ContractProcedureBuilderWithInput<TInputSchema extends AnySchema, TOut
|
|
|
82
82
|
* The provided route is spared-merged with any existing route in the contract.
|
|
83
83
|
* This option is typically relevant when integrating with OpenAPI.
|
|
84
84
|
*
|
|
85
|
-
* @see {@link https://orpc.
|
|
86
|
-
* @see {@link https://orpc.
|
|
85
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
86
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
87
87
|
*/
|
|
88
88
|
route(route: Route): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
89
89
|
/**
|
|
90
90
|
* Defines the output validation schema for the contract.
|
|
91
91
|
*
|
|
92
|
-
* @see {@link https://orpc.
|
|
92
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs}
|
|
93
93
|
*/
|
|
94
94
|
output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInputOutput<TInputSchema, U, TErrorMap, TMeta>;
|
|
95
95
|
}
|
|
@@ -98,14 +98,14 @@ interface ContractProcedureBuilderWithOutput<TInputSchema extends AnySchema, TOu
|
|
|
98
98
|
* Adds type-safe custom errors to the contract.
|
|
99
99
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
100
100
|
*
|
|
101
|
-
* @see {@link https://orpc.
|
|
101
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
102
102
|
*/
|
|
103
103
|
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
104
104
|
/**
|
|
105
105
|
* Sets or updates the metadata for the contract.
|
|
106
106
|
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
107
107
|
*
|
|
108
|
-
* @see {@link https://orpc.
|
|
108
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
109
109
|
*/
|
|
110
110
|
meta(meta: TMeta): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
111
111
|
/**
|
|
@@ -113,14 +113,14 @@ interface ContractProcedureBuilderWithOutput<TInputSchema extends AnySchema, TOu
|
|
|
113
113
|
* The provided route is spared-merged with any existing route in the contract.
|
|
114
114
|
* This option is typically relevant when integrating with OpenAPI.
|
|
115
115
|
*
|
|
116
|
-
* @see {@link https://orpc.
|
|
117
|
-
* @see {@link https://orpc.
|
|
116
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
117
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
118
118
|
*/
|
|
119
119
|
route(route: Route): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
120
120
|
/**
|
|
121
121
|
* Defines the input validation schema for the contract.
|
|
122
122
|
*
|
|
123
|
-
* @see {@link https://orpc.
|
|
123
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs}
|
|
124
124
|
*/
|
|
125
125
|
input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInputOutput<U, TOutputSchema, TErrorMap, TMeta>;
|
|
126
126
|
}
|
|
@@ -129,14 +129,14 @@ interface ContractProcedureBuilderWithInputOutput<TInputSchema extends AnySchema
|
|
|
129
129
|
* Adds type-safe custom errors to the contract.
|
|
130
130
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
131
131
|
*
|
|
132
|
-
* @see {@link https://orpc.
|
|
132
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
133
133
|
*/
|
|
134
134
|
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
135
135
|
/**
|
|
136
136
|
* Sets or updates the metadata for the contract.
|
|
137
137
|
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
138
138
|
*
|
|
139
|
-
* @see {@link https://orpc.
|
|
139
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
140
140
|
*/
|
|
141
141
|
meta(meta: TMeta): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
142
142
|
/**
|
|
@@ -144,8 +144,8 @@ interface ContractProcedureBuilderWithInputOutput<TInputSchema extends AnySchema
|
|
|
144
144
|
* The provided route is spared-merged with any existing route in the contract.
|
|
145
145
|
* This option is typically relevant when integrating with OpenAPI.
|
|
146
146
|
*
|
|
147
|
-
* @see {@link https://orpc.
|
|
148
|
-
* @see {@link https://orpc.
|
|
147
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
148
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
149
149
|
*/
|
|
150
150
|
route(route: Route): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
151
151
|
}
|
|
@@ -158,7 +158,7 @@ interface ContractRouterBuilder<TErrorMap extends ErrorMap, TMeta extends Meta>
|
|
|
158
158
|
* Adds type-safe custom errors to the contract.
|
|
159
159
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
160
160
|
*
|
|
161
|
-
* @see {@link https://orpc.
|
|
161
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
162
162
|
*/
|
|
163
163
|
'errors'<U extends ErrorMap>(errors: U): ContractRouterBuilder<MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
164
164
|
/**
|
|
@@ -167,20 +167,20 @@ interface ContractRouterBuilder<TErrorMap extends ErrorMap, TMeta extends Meta>
|
|
|
167
167
|
*
|
|
168
168
|
* @note This option does not affect procedures that do not define a path in their route definition.
|
|
169
169
|
*
|
|
170
|
-
* @see {@link https://orpc.
|
|
170
|
+
* @see {@link https://orpc.dev/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
171
171
|
*/
|
|
172
172
|
'prefix'(prefix: HTTPPath): ContractRouterBuilder<TErrorMap, TMeta>;
|
|
173
173
|
/**
|
|
174
174
|
* Adds tags to all procedures in the contract router.
|
|
175
175
|
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
176
176
|
*
|
|
177
|
-
* @see {@link https://orpc.
|
|
177
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
178
178
|
*/
|
|
179
179
|
'tag'(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>;
|
|
180
180
|
/**
|
|
181
181
|
* Applies all of the previously defined options to the specified contract router.
|
|
182
182
|
*
|
|
183
|
-
* @see {@link https://orpc.
|
|
183
|
+
* @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs}
|
|
184
184
|
*/
|
|
185
185
|
'router'<T extends ContractRouter<TMeta>>(router: T): EnhancedContractRouter<T, TErrorMap>;
|
|
186
186
|
}
|
|
@@ -196,29 +196,29 @@ declare class ContractBuilder<TInputSchema extends AnySchema, TOutputSchema exte
|
|
|
196
196
|
/**
|
|
197
197
|
* Sets or overrides the initial meta.
|
|
198
198
|
*
|
|
199
|
-
* @see {@link https://orpc.
|
|
199
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
200
200
|
*/
|
|
201
201
|
$meta<U extends Meta>(initialMeta: U): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, U & Record<never, never>>;
|
|
202
202
|
/**
|
|
203
203
|
* Sets or overrides the initial route.
|
|
204
204
|
* This option is typically relevant when integrating with OpenAPI.
|
|
205
205
|
*
|
|
206
|
-
* @see {@link https://orpc.
|
|
207
|
-
* @see {@link https://orpc.
|
|
206
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
207
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
208
208
|
*/
|
|
209
209
|
$route(initialRoute: Route): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
210
210
|
/**
|
|
211
211
|
* Adds type-safe custom errors to the contract.
|
|
212
212
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
213
213
|
*
|
|
214
|
-
* @see {@link https://orpc.
|
|
214
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
215
215
|
*/
|
|
216
216
|
errors<U extends ErrorMap>(errors: U): ContractBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
217
217
|
/**
|
|
218
218
|
* Sets or updates the metadata for the contract.
|
|
219
219
|
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
220
220
|
*
|
|
221
|
-
* @see {@link https://orpc.
|
|
221
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
222
222
|
*/
|
|
223
223
|
meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
224
224
|
/**
|
|
@@ -226,20 +226,20 @@ declare class ContractBuilder<TInputSchema extends AnySchema, TOutputSchema exte
|
|
|
226
226
|
* The provided route is spared-merged with any existing route in the contract.
|
|
227
227
|
* This option is typically relevant when integrating with OpenAPI.
|
|
228
228
|
*
|
|
229
|
-
* @see {@link https://orpc.
|
|
230
|
-
* @see {@link https://orpc.
|
|
229
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
230
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
231
231
|
*/
|
|
232
232
|
route(route: Route): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
233
233
|
/**
|
|
234
234
|
* Defines the input validation schema for the contract.
|
|
235
235
|
*
|
|
236
|
-
* @see {@link https://orpc.
|
|
236
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs}
|
|
237
237
|
*/
|
|
238
238
|
input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>;
|
|
239
239
|
/**
|
|
240
240
|
* Defines the output validation schema for the contract.
|
|
241
241
|
*
|
|
242
|
-
* @see {@link https://orpc.
|
|
242
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs}
|
|
243
243
|
*/
|
|
244
244
|
output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>;
|
|
245
245
|
/**
|
|
@@ -248,20 +248,20 @@ declare class ContractBuilder<TInputSchema extends AnySchema, TOutputSchema exte
|
|
|
248
248
|
*
|
|
249
249
|
* @note This option does not affect procedures that do not define a path in their route definition.
|
|
250
250
|
*
|
|
251
|
-
* @see {@link https://orpc.
|
|
251
|
+
* @see {@link https://orpc.dev/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
252
252
|
*/
|
|
253
253
|
prefix(prefix: HTTPPath): ContractRouterBuilder<TErrorMap, TMeta>;
|
|
254
254
|
/**
|
|
255
255
|
* Adds tags to all procedures in the contract router.
|
|
256
256
|
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
257
257
|
*
|
|
258
|
-
* @see {@link https://orpc.
|
|
258
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
259
259
|
*/
|
|
260
260
|
tag(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>;
|
|
261
261
|
/**
|
|
262
262
|
* Applies all of the previously defined options to the specified contract router.
|
|
263
263
|
*
|
|
264
|
-
* @see {@link https://orpc.
|
|
264
|
+
* @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs}
|
|
265
265
|
*/
|
|
266
266
|
router<T extends ContractRouter<TMeta>>(router: T): EnhancedContractRouter<T, TErrorMap>;
|
|
267
267
|
}
|
|
@@ -283,7 +283,7 @@ interface EventIteratorSchemaDetails {
|
|
|
283
283
|
/**
|
|
284
284
|
* Define schema for an event iterator.
|
|
285
285
|
*
|
|
286
|
-
* @see {@link https://orpc.
|
|
286
|
+
* @see {@link https://orpc.dev/docs/event-iterator#validate-event-iterator Validate Event Iterator Docs}
|
|
287
287
|
*/
|
|
288
288
|
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>>;
|
|
289
289
|
declare function getEventIteratorSchemaDetails(schema: AnySchema | undefined): undefined | EventIteratorSchemaDetails;
|
|
@@ -291,7 +291,7 @@ declare function getEventIteratorSchemaDetails(schema: AnySchema | undefined): u
|
|
|
291
291
|
/**
|
|
292
292
|
* Help RPCLink automatically send requests using the specified HTTP method in the contract.
|
|
293
293
|
*
|
|
294
|
-
* @see {@link https://orpc.
|
|
294
|
+
* @see {@link https://orpc.dev/docs/client/rpc-link#custom-request-method RPCLink Custom Request Method}
|
|
295
295
|
*/
|
|
296
296
|
declare function inferRPCMethodFromContractRouter(contract: AnyContractRouter): (options: unknown, path: readonly string[]) => Exclude<HTTPMethod, 'HEAD'>;
|
|
297
297
|
|
package/dist/index.mjs
CHANGED
|
@@ -3,6 +3,7 @@ export { v as validateORPCError } from './shared/contract.D_dZrO__.mjs';
|
|
|
3
3
|
import { mapEventIterator, ORPCError } from '@orpc/client';
|
|
4
4
|
export { ORPCError } from '@orpc/client';
|
|
5
5
|
import { isAsyncIteratorObject, get, isTypescriptObject, isPropertyKey } from '@orpc/shared';
|
|
6
|
+
export { AsyncIteratorClass } from '@orpc/shared';
|
|
6
7
|
|
|
7
8
|
function mergeMeta(meta1, meta2) {
|
|
8
9
|
return { ...meta1, ...meta2 };
|
|
@@ -99,7 +100,7 @@ class ContractBuilder extends ContractProcedure {
|
|
|
99
100
|
/**
|
|
100
101
|
* Sets or overrides the initial meta.
|
|
101
102
|
*
|
|
102
|
-
* @see {@link https://orpc.
|
|
103
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
103
104
|
*/
|
|
104
105
|
$meta(initialMeta) {
|
|
105
106
|
return new ContractBuilder({
|
|
@@ -111,8 +112,8 @@ class ContractBuilder extends ContractProcedure {
|
|
|
111
112
|
* Sets or overrides the initial route.
|
|
112
113
|
* This option is typically relevant when integrating with OpenAPI.
|
|
113
114
|
*
|
|
114
|
-
* @see {@link https://orpc.
|
|
115
|
-
* @see {@link https://orpc.
|
|
115
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
116
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
116
117
|
*/
|
|
117
118
|
$route(initialRoute) {
|
|
118
119
|
return new ContractBuilder({
|
|
@@ -124,7 +125,7 @@ class ContractBuilder extends ContractProcedure {
|
|
|
124
125
|
* Adds type-safe custom errors to the contract.
|
|
125
126
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
126
127
|
*
|
|
127
|
-
* @see {@link https://orpc.
|
|
128
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
128
129
|
*/
|
|
129
130
|
errors(errors) {
|
|
130
131
|
return new ContractBuilder({
|
|
@@ -136,7 +137,7 @@ class ContractBuilder extends ContractProcedure {
|
|
|
136
137
|
* Sets or updates the metadata for the contract.
|
|
137
138
|
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
138
139
|
*
|
|
139
|
-
* @see {@link https://orpc.
|
|
140
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
140
141
|
*/
|
|
141
142
|
meta(meta) {
|
|
142
143
|
return new ContractBuilder({
|
|
@@ -149,8 +150,8 @@ class ContractBuilder extends ContractProcedure {
|
|
|
149
150
|
* The provided route is spared-merged with any existing route in the contract.
|
|
150
151
|
* This option is typically relevant when integrating with OpenAPI.
|
|
151
152
|
*
|
|
152
|
-
* @see {@link https://orpc.
|
|
153
|
-
* @see {@link https://orpc.
|
|
153
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
154
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
154
155
|
*/
|
|
155
156
|
route(route) {
|
|
156
157
|
return new ContractBuilder({
|
|
@@ -161,7 +162,7 @@ class ContractBuilder extends ContractProcedure {
|
|
|
161
162
|
/**
|
|
162
163
|
* Defines the input validation schema for the contract.
|
|
163
164
|
*
|
|
164
|
-
* @see {@link https://orpc.
|
|
165
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs}
|
|
165
166
|
*/
|
|
166
167
|
input(schema) {
|
|
167
168
|
return new ContractBuilder({
|
|
@@ -172,7 +173,7 @@ class ContractBuilder extends ContractProcedure {
|
|
|
172
173
|
/**
|
|
173
174
|
* Defines the output validation schema for the contract.
|
|
174
175
|
*
|
|
175
|
-
* @see {@link https://orpc.
|
|
176
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs}
|
|
176
177
|
*/
|
|
177
178
|
output(schema) {
|
|
178
179
|
return new ContractBuilder({
|
|
@@ -186,7 +187,7 @@ class ContractBuilder extends ContractProcedure {
|
|
|
186
187
|
*
|
|
187
188
|
* @note This option does not affect procedures that do not define a path in their route definition.
|
|
188
189
|
*
|
|
189
|
-
* @see {@link https://orpc.
|
|
190
|
+
* @see {@link https://orpc.dev/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
190
191
|
*/
|
|
191
192
|
prefix(prefix) {
|
|
192
193
|
return new ContractBuilder({
|
|
@@ -198,7 +199,7 @@ class ContractBuilder extends ContractProcedure {
|
|
|
198
199
|
* Adds tags to all procedures in the contract router.
|
|
199
200
|
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
200
201
|
*
|
|
201
|
-
* @see {@link https://orpc.
|
|
202
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
202
203
|
*/
|
|
203
204
|
tag(...tags) {
|
|
204
205
|
return new ContractBuilder({
|
|
@@ -209,7 +210,7 @@ class ContractBuilder extends ContractProcedure {
|
|
|
209
210
|
/**
|
|
210
211
|
* Applies all of the previously defined options to the specified contract router.
|
|
211
212
|
*
|
|
212
|
-
* @see {@link https://orpc.
|
|
213
|
+
* @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs}
|
|
213
214
|
*/
|
|
214
215
|
router(router) {
|
|
215
216
|
return enhanceContractRouter(router, this["~orpc"]);
|
package/dist/plugins/index.d.mts
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
import { ClientContext } from '@orpc/client';
|
|
2
2
|
import { StandardLinkPlugin, StandardLinkOptions } from '@orpc/client/standard';
|
|
3
|
-
import { A as AnyContractRouter } from '../shared/contract.
|
|
3
|
+
import { A as AnyContractRouter } from '../shared/contract.TuRtB1Ca.mjs';
|
|
4
4
|
import '@orpc/shared';
|
|
5
5
|
import '@standard-schema/spec';
|
|
6
6
|
import 'openapi-types';
|
|
7
7
|
|
|
8
|
+
declare class RequestValidationPluginError extends Error {
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A link plugin that validates client requests against your contract schema,
|
|
12
|
+
* ensuring that data sent to your server matches the expected types defined in your contract.
|
|
13
|
+
*
|
|
14
|
+
* @throws {ORPCError} with code `BAD_REQUEST` (same as server side) if input doesn't match the expected schema
|
|
15
|
+
* @see {@link https://orpc.dev/docs/plugins/request-validation Request Validation Plugin Docs}
|
|
16
|
+
*/
|
|
17
|
+
declare class RequestValidationPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
18
|
+
private readonly contract;
|
|
19
|
+
constructor(contract: AnyContractRouter);
|
|
20
|
+
init(options: StandardLinkOptions<T>): void;
|
|
21
|
+
}
|
|
22
|
+
|
|
8
23
|
/**
|
|
9
24
|
* A link plugin that validates server responses against your contract schema,
|
|
10
25
|
* ensuring that data returned from your server matches the expected types defined in your contract.
|
|
@@ -12,13 +27,17 @@ import 'openapi-types';
|
|
|
12
27
|
* - Throws `ValidationError` if output doesn't match the expected schema
|
|
13
28
|
* - Converts mismatched defined errors to normal `ORPCError` instances
|
|
14
29
|
*
|
|
15
|
-
* @see {@link https://orpc.
|
|
30
|
+
* @see {@link https://orpc.dev/docs/plugins/response-validation Response Validation Plugin Docs}
|
|
16
31
|
*/
|
|
17
32
|
declare class ResponseValidationPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
18
33
|
private readonly contract;
|
|
19
34
|
constructor(contract: AnyContractRouter);
|
|
35
|
+
/**
|
|
36
|
+
* run before (validate after) retry plugin, because validation failed can't be retried
|
|
37
|
+
* run before (validate after) durable iterator plugin, because we expect durable iterator to validation (if user use it)
|
|
38
|
+
*/
|
|
20
39
|
order: number;
|
|
21
40
|
init(options: StandardLinkOptions<T>): void;
|
|
22
41
|
}
|
|
23
42
|
|
|
24
|
-
export { ResponseValidationPlugin };
|
|
43
|
+
export { RequestValidationPlugin, RequestValidationPluginError, ResponseValidationPlugin };
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
import { ClientContext } from '@orpc/client';
|
|
2
2
|
import { StandardLinkPlugin, StandardLinkOptions } from '@orpc/client/standard';
|
|
3
|
-
import { A as AnyContractRouter } from '../shared/contract.
|
|
3
|
+
import { A as AnyContractRouter } from '../shared/contract.TuRtB1Ca.js';
|
|
4
4
|
import '@orpc/shared';
|
|
5
5
|
import '@standard-schema/spec';
|
|
6
6
|
import 'openapi-types';
|
|
7
7
|
|
|
8
|
+
declare class RequestValidationPluginError extends Error {
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A link plugin that validates client requests against your contract schema,
|
|
12
|
+
* ensuring that data sent to your server matches the expected types defined in your contract.
|
|
13
|
+
*
|
|
14
|
+
* @throws {ORPCError} with code `BAD_REQUEST` (same as server side) if input doesn't match the expected schema
|
|
15
|
+
* @see {@link https://orpc.dev/docs/plugins/request-validation Request Validation Plugin Docs}
|
|
16
|
+
*/
|
|
17
|
+
declare class RequestValidationPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
18
|
+
private readonly contract;
|
|
19
|
+
constructor(contract: AnyContractRouter);
|
|
20
|
+
init(options: StandardLinkOptions<T>): void;
|
|
21
|
+
}
|
|
22
|
+
|
|
8
23
|
/**
|
|
9
24
|
* A link plugin that validates server responses against your contract schema,
|
|
10
25
|
* ensuring that data returned from your server matches the expected types defined in your contract.
|
|
@@ -12,13 +27,17 @@ import 'openapi-types';
|
|
|
12
27
|
* - Throws `ValidationError` if output doesn't match the expected schema
|
|
13
28
|
* - Converts mismatched defined errors to normal `ORPCError` instances
|
|
14
29
|
*
|
|
15
|
-
* @see {@link https://orpc.
|
|
30
|
+
* @see {@link https://orpc.dev/docs/plugins/response-validation Response Validation Plugin Docs}
|
|
16
31
|
*/
|
|
17
32
|
declare class ResponseValidationPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
18
33
|
private readonly contract;
|
|
19
34
|
constructor(contract: AnyContractRouter);
|
|
35
|
+
/**
|
|
36
|
+
* run before (validate after) retry plugin, because validation failed can't be retried
|
|
37
|
+
* run before (validate after) durable iterator plugin, because we expect durable iterator to validation (if user use it)
|
|
38
|
+
*/
|
|
20
39
|
order: number;
|
|
21
40
|
init(options: StandardLinkOptions<T>): void;
|
|
22
41
|
}
|
|
23
42
|
|
|
24
|
-
export { ResponseValidationPlugin };
|
|
43
|
+
export { RequestValidationPlugin, RequestValidationPluginError, ResponseValidationPlugin };
|
package/dist/plugins/index.mjs
CHANGED
|
@@ -2,12 +2,50 @@ import { ORPCError } from '@orpc/client';
|
|
|
2
2
|
import { get } from '@orpc/shared';
|
|
3
3
|
import { i as isContractProcedure, V as ValidationError, v as validateORPCError } from '../shared/contract.D_dZrO__.mjs';
|
|
4
4
|
|
|
5
|
+
class RequestValidationPluginError extends Error {
|
|
6
|
+
}
|
|
7
|
+
class RequestValidationPlugin {
|
|
8
|
+
constructor(contract) {
|
|
9
|
+
this.contract = contract;
|
|
10
|
+
}
|
|
11
|
+
init(options) {
|
|
12
|
+
options.interceptors ??= [];
|
|
13
|
+
options.interceptors.push(async ({ next, path, input }) => {
|
|
14
|
+
const procedure = get(this.contract, path);
|
|
15
|
+
if (!isContractProcedure(procedure)) {
|
|
16
|
+
throw new RequestValidationPluginError(`No valid procedure found at path "${path.join(".")}", this may happen when the contract router is not properly configured.`);
|
|
17
|
+
}
|
|
18
|
+
const inputSchema = procedure["~orpc"].inputSchema;
|
|
19
|
+
if (inputSchema) {
|
|
20
|
+
const result = await inputSchema["~standard"].validate(input);
|
|
21
|
+
if (result.issues) {
|
|
22
|
+
throw new ORPCError("BAD_REQUEST", {
|
|
23
|
+
message: "Input validation failed",
|
|
24
|
+
data: {
|
|
25
|
+
issues: result.issues
|
|
26
|
+
},
|
|
27
|
+
cause: new ValidationError({
|
|
28
|
+
message: "Input validation failed",
|
|
29
|
+
issues: result.issues,
|
|
30
|
+
data: input
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return await next();
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
5
40
|
class ResponseValidationPlugin {
|
|
6
41
|
constructor(contract) {
|
|
7
42
|
this.contract = contract;
|
|
8
43
|
}
|
|
9
|
-
|
|
10
|
-
|
|
44
|
+
/**
|
|
45
|
+
* run before (validate after) retry plugin, because validation failed can't be retried
|
|
46
|
+
* run before (validate after) durable iterator plugin, because we expect durable iterator to validation (if user use it)
|
|
47
|
+
*/
|
|
48
|
+
order = 12e5;
|
|
11
49
|
init(options) {
|
|
12
50
|
options.interceptors ??= [];
|
|
13
51
|
options.interceptors.push(async ({ next, path }) => {
|
|
@@ -40,4 +78,4 @@ class ResponseValidationPlugin {
|
|
|
40
78
|
}
|
|
41
79
|
}
|
|
42
80
|
|
|
43
|
-
export { ResponseValidationPlugin };
|
|
81
|
+
export { RequestValidationPlugin, RequestValidationPluginError, ResponseValidationPlugin };
|
|
@@ -13,7 +13,7 @@ type TypeRest<TInput, TOutput> = [map: (input: TInput) => Promisable<TOutput>] |
|
|
|
13
13
|
* The schema for things can be trust without validation.
|
|
14
14
|
* If the TInput and TOutput are different, you need pass a map function.
|
|
15
15
|
*
|
|
16
|
-
* @see {@link https://orpc.
|
|
16
|
+
* @see {@link https://orpc.dev/docs/procedure#type-utility Type Utility Docs}
|
|
17
17
|
*/
|
|
18
18
|
declare function type<TInput, TOutput = TInput>(...[map]: TypeRest<TInput, TOutput>): Schema<TInput, TOutput>;
|
|
19
19
|
|
|
@@ -28,7 +28,7 @@ interface ValidationErrorOptions extends ErrorOptions {
|
|
|
28
28
|
/**
|
|
29
29
|
* This errors usually used for ORPCError.cause when the error is a validation error.
|
|
30
30
|
*
|
|
31
|
-
* @see {@link https://orpc.
|
|
31
|
+
* @see {@link https://orpc.dev/docs/advanced/validation-errors Validation Errors Docs}
|
|
32
32
|
*/
|
|
33
33
|
declare class ValidationError extends Error {
|
|
34
34
|
readonly issues: readonly SchemaIssue[];
|
|
@@ -61,14 +61,14 @@ interface Route {
|
|
|
61
61
|
* The HTTP method of the procedure.
|
|
62
62
|
* This option is typically relevant when integrating with OpenAPI.
|
|
63
63
|
*
|
|
64
|
-
* @see {@link https://orpc.
|
|
64
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
65
65
|
*/
|
|
66
66
|
method?: HTTPMethod;
|
|
67
67
|
/**
|
|
68
68
|
* The HTTP path of the procedure.
|
|
69
69
|
* This option is typically relevant when integrating with OpenAPI.
|
|
70
70
|
*
|
|
71
|
-
* @see {@link https://orpc.
|
|
71
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
72
72
|
*/
|
|
73
73
|
path?: HTTPPath;
|
|
74
74
|
/**
|
|
@@ -82,28 +82,28 @@ interface Route {
|
|
|
82
82
|
* The summary of the procedure.
|
|
83
83
|
* This option is typically relevant when integrating with OpenAPI.
|
|
84
84
|
*
|
|
85
|
-
* @see {@link https://orpc.
|
|
85
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
86
86
|
*/
|
|
87
87
|
summary?: string;
|
|
88
88
|
/**
|
|
89
89
|
* The description of the procedure.
|
|
90
90
|
* This option is typically relevant when integrating with OpenAPI.
|
|
91
91
|
*
|
|
92
|
-
* @see {@link https://orpc.
|
|
92
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
93
93
|
*/
|
|
94
94
|
description?: string;
|
|
95
95
|
/**
|
|
96
96
|
* Marks the procedure as deprecated.
|
|
97
97
|
* This option is typically relevant when integrating with OpenAPI.
|
|
98
98
|
*
|
|
99
|
-
* @see {@link https://orpc.
|
|
99
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
100
100
|
*/
|
|
101
101
|
deprecated?: boolean;
|
|
102
102
|
/**
|
|
103
103
|
* The tags of the procedure.
|
|
104
104
|
* This option is typically relevant when integrating with OpenAPI.
|
|
105
105
|
*
|
|
106
|
-
* @see {@link https://orpc.
|
|
106
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
107
107
|
*/
|
|
108
108
|
tags?: readonly string[];
|
|
109
109
|
/**
|
|
@@ -111,7 +111,7 @@ interface Route {
|
|
|
111
111
|
* The status code must be in the 200-399 range.
|
|
112
112
|
* This option is typically relevant when integrating with OpenAPI.
|
|
113
113
|
*
|
|
114
|
-
* @see {@link https://orpc.
|
|
114
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
115
115
|
* @default 200
|
|
116
116
|
*/
|
|
117
117
|
successStatus?: number;
|
|
@@ -119,7 +119,7 @@ interface Route {
|
|
|
119
119
|
* The description of the response when the procedure is successful.
|
|
120
120
|
* This option is typically relevant when integrating with OpenAPI.
|
|
121
121
|
*
|
|
122
|
-
* @see {@link https://orpc.
|
|
122
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
123
123
|
* @default 'OK'
|
|
124
124
|
*/
|
|
125
125
|
successDescription?: string;
|
|
@@ -142,7 +142,7 @@ interface Route {
|
|
|
142
142
|
* }
|
|
143
143
|
* ```
|
|
144
144
|
*
|
|
145
|
-
* @see {@link https://orpc.
|
|
145
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
146
146
|
* @default 'compact'
|
|
147
147
|
*/
|
|
148
148
|
inputStructure?: InputStructure;
|
|
@@ -167,14 +167,14 @@ interface Route {
|
|
|
167
167
|
* };
|
|
168
168
|
* ```
|
|
169
169
|
*
|
|
170
|
-
* @see {@link https://orpc.
|
|
170
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
171
171
|
* @default 'compact'
|
|
172
172
|
*/
|
|
173
173
|
outputStructure?: OutputStructure;
|
|
174
174
|
/**
|
|
175
175
|
* Override entire auto-generated OpenAPI Operation Object Specification.
|
|
176
176
|
*
|
|
177
|
-
* @see {@link https://orpc.
|
|
177
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata Operation Metadata Docs}
|
|
178
178
|
*/
|
|
179
179
|
spec?: OpenAPIV3_1.OperationObject | ((current: OpenAPIV3_1.OperationObject) => OpenAPIV3_1.OperationObject);
|
|
180
180
|
}
|
|
@@ -199,7 +199,7 @@ interface ContractProcedureDef<TInputSchema extends AnySchema, TOutputSchema ext
|
|
|
199
199
|
/**
|
|
200
200
|
* This class represents a contract procedure.
|
|
201
201
|
*
|
|
202
|
-
* @see {@link https://orpc.
|
|
202
|
+
* @see {@link https://orpc.dev/docs/contract-first/define-contract#procedure-contract Contract Procedure Docs}
|
|
203
203
|
*/
|
|
204
204
|
declare class ContractProcedure<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
205
205
|
/**
|
|
@@ -215,7 +215,7 @@ declare function isContractProcedure(item: unknown): item is AnyContractProcedur
|
|
|
215
215
|
* Represents a contract router, which defines a hierarchical structure of contract procedures.
|
|
216
216
|
*
|
|
217
217
|
* @info A contract procedure is a contract router too.
|
|
218
|
-
* @see {@link https://orpc.
|
|
218
|
+
* @see {@link https://orpc.dev/docs/contract-first/define-contract#contract-router Contract Router Docs}
|
|
219
219
|
*/
|
|
220
220
|
type ContractRouter<TMeta extends Meta> = ContractProcedure<any, any, any, TMeta> | {
|
|
221
221
|
[k: string]: ContractRouter<TMeta>;
|
|
@@ -225,7 +225,7 @@ type AnyContractRouter = ContractRouter<any>;
|
|
|
225
225
|
* Infer all inputs of the contract router.
|
|
226
226
|
*
|
|
227
227
|
* @info A contract procedure is a contract router too.
|
|
228
|
-
* @see {@link https://orpc.
|
|
228
|
+
* @see {@link https://orpc.dev/docs/contract-first/define-contract#utilities Contract Utilities Docs}
|
|
229
229
|
*/
|
|
230
230
|
type InferContractRouterInputs<T extends AnyContractRouter> = T extends ContractProcedure<infer UInputSchema, any, any, any> ? InferSchemaInput<UInputSchema> : {
|
|
231
231
|
[K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterInputs<T[K]> : never;
|
|
@@ -234,7 +234,7 @@ type InferContractRouterInputs<T extends AnyContractRouter> = T extends Contract
|
|
|
234
234
|
* Infer all outputs of the contract router.
|
|
235
235
|
*
|
|
236
236
|
* @info A contract procedure is a contract router too.
|
|
237
|
-
* @see {@link https://orpc.
|
|
237
|
+
* @see {@link https://orpc.dev/docs/contract-first/define-contract#utilities Contract Utilities Docs}
|
|
238
238
|
*/
|
|
239
239
|
type InferContractRouterOutputs<T extends AnyContractRouter> = T extends ContractProcedure<any, infer UOutputSchema, any, any> ? InferSchemaOutput<UOutputSchema> : {
|
|
240
240
|
[K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterOutputs<T[K]> : never;
|
|
@@ -243,7 +243,7 @@ type InferContractRouterOutputs<T extends AnyContractRouter> = T extends Contrac
|
|
|
243
243
|
* Infer all errors of the contract router.
|
|
244
244
|
*
|
|
245
245
|
* @info A contract procedure is a contract router too.
|
|
246
|
-
* @see {@link https://orpc.
|
|
246
|
+
* @see {@link https://orpc.dev/docs/contract-first/define-contract#utilities Contract Utilities Docs}
|
|
247
247
|
*/
|
|
248
248
|
type InferContractRouterErrorMap<T extends AnyContractRouter> = T extends ContractProcedure<any, any, infer UErrorMap, any> ? UErrorMap : {
|
|
249
249
|
[K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterErrorMap<T[K]> : never;
|
|
@@ -13,7 +13,7 @@ type TypeRest<TInput, TOutput> = [map: (input: TInput) => Promisable<TOutput>] |
|
|
|
13
13
|
* The schema for things can be trust without validation.
|
|
14
14
|
* If the TInput and TOutput are different, you need pass a map function.
|
|
15
15
|
*
|
|
16
|
-
* @see {@link https://orpc.
|
|
16
|
+
* @see {@link https://orpc.dev/docs/procedure#type-utility Type Utility Docs}
|
|
17
17
|
*/
|
|
18
18
|
declare function type<TInput, TOutput = TInput>(...[map]: TypeRest<TInput, TOutput>): Schema<TInput, TOutput>;
|
|
19
19
|
|
|
@@ -28,7 +28,7 @@ interface ValidationErrorOptions extends ErrorOptions {
|
|
|
28
28
|
/**
|
|
29
29
|
* This errors usually used for ORPCError.cause when the error is a validation error.
|
|
30
30
|
*
|
|
31
|
-
* @see {@link https://orpc.
|
|
31
|
+
* @see {@link https://orpc.dev/docs/advanced/validation-errors Validation Errors Docs}
|
|
32
32
|
*/
|
|
33
33
|
declare class ValidationError extends Error {
|
|
34
34
|
readonly issues: readonly SchemaIssue[];
|
|
@@ -61,14 +61,14 @@ interface Route {
|
|
|
61
61
|
* The HTTP method of the procedure.
|
|
62
62
|
* This option is typically relevant when integrating with OpenAPI.
|
|
63
63
|
*
|
|
64
|
-
* @see {@link https://orpc.
|
|
64
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
65
65
|
*/
|
|
66
66
|
method?: HTTPMethod;
|
|
67
67
|
/**
|
|
68
68
|
* The HTTP path of the procedure.
|
|
69
69
|
* This option is typically relevant when integrating with OpenAPI.
|
|
70
70
|
*
|
|
71
|
-
* @see {@link https://orpc.
|
|
71
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
72
72
|
*/
|
|
73
73
|
path?: HTTPPath;
|
|
74
74
|
/**
|
|
@@ -82,28 +82,28 @@ interface Route {
|
|
|
82
82
|
* The summary of the procedure.
|
|
83
83
|
* This option is typically relevant when integrating with OpenAPI.
|
|
84
84
|
*
|
|
85
|
-
* @see {@link https://orpc.
|
|
85
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
86
86
|
*/
|
|
87
87
|
summary?: string;
|
|
88
88
|
/**
|
|
89
89
|
* The description of the procedure.
|
|
90
90
|
* This option is typically relevant when integrating with OpenAPI.
|
|
91
91
|
*
|
|
92
|
-
* @see {@link https://orpc.
|
|
92
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
93
93
|
*/
|
|
94
94
|
description?: string;
|
|
95
95
|
/**
|
|
96
96
|
* Marks the procedure as deprecated.
|
|
97
97
|
* This option is typically relevant when integrating with OpenAPI.
|
|
98
98
|
*
|
|
99
|
-
* @see {@link https://orpc.
|
|
99
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
100
100
|
*/
|
|
101
101
|
deprecated?: boolean;
|
|
102
102
|
/**
|
|
103
103
|
* The tags of the procedure.
|
|
104
104
|
* This option is typically relevant when integrating with OpenAPI.
|
|
105
105
|
*
|
|
106
|
-
* @see {@link https://orpc.
|
|
106
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
107
107
|
*/
|
|
108
108
|
tags?: readonly string[];
|
|
109
109
|
/**
|
|
@@ -111,7 +111,7 @@ interface Route {
|
|
|
111
111
|
* The status code must be in the 200-399 range.
|
|
112
112
|
* This option is typically relevant when integrating with OpenAPI.
|
|
113
113
|
*
|
|
114
|
-
* @see {@link https://orpc.
|
|
114
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
115
115
|
* @default 200
|
|
116
116
|
*/
|
|
117
117
|
successStatus?: number;
|
|
@@ -119,7 +119,7 @@ interface Route {
|
|
|
119
119
|
* The description of the response when the procedure is successful.
|
|
120
120
|
* This option is typically relevant when integrating with OpenAPI.
|
|
121
121
|
*
|
|
122
|
-
* @see {@link https://orpc.
|
|
122
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
123
123
|
* @default 'OK'
|
|
124
124
|
*/
|
|
125
125
|
successDescription?: string;
|
|
@@ -142,7 +142,7 @@ interface Route {
|
|
|
142
142
|
* }
|
|
143
143
|
* ```
|
|
144
144
|
*
|
|
145
|
-
* @see {@link https://orpc.
|
|
145
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
146
146
|
* @default 'compact'
|
|
147
147
|
*/
|
|
148
148
|
inputStructure?: InputStructure;
|
|
@@ -167,14 +167,14 @@ interface Route {
|
|
|
167
167
|
* };
|
|
168
168
|
* ```
|
|
169
169
|
*
|
|
170
|
-
* @see {@link https://orpc.
|
|
170
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
171
171
|
* @default 'compact'
|
|
172
172
|
*/
|
|
173
173
|
outputStructure?: OutputStructure;
|
|
174
174
|
/**
|
|
175
175
|
* Override entire auto-generated OpenAPI Operation Object Specification.
|
|
176
176
|
*
|
|
177
|
-
* @see {@link https://orpc.
|
|
177
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata Operation Metadata Docs}
|
|
178
178
|
*/
|
|
179
179
|
spec?: OpenAPIV3_1.OperationObject | ((current: OpenAPIV3_1.OperationObject) => OpenAPIV3_1.OperationObject);
|
|
180
180
|
}
|
|
@@ -199,7 +199,7 @@ interface ContractProcedureDef<TInputSchema extends AnySchema, TOutputSchema ext
|
|
|
199
199
|
/**
|
|
200
200
|
* This class represents a contract procedure.
|
|
201
201
|
*
|
|
202
|
-
* @see {@link https://orpc.
|
|
202
|
+
* @see {@link https://orpc.dev/docs/contract-first/define-contract#procedure-contract Contract Procedure Docs}
|
|
203
203
|
*/
|
|
204
204
|
declare class ContractProcedure<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
205
205
|
/**
|
|
@@ -215,7 +215,7 @@ declare function isContractProcedure(item: unknown): item is AnyContractProcedur
|
|
|
215
215
|
* Represents a contract router, which defines a hierarchical structure of contract procedures.
|
|
216
216
|
*
|
|
217
217
|
* @info A contract procedure is a contract router too.
|
|
218
|
-
* @see {@link https://orpc.
|
|
218
|
+
* @see {@link https://orpc.dev/docs/contract-first/define-contract#contract-router Contract Router Docs}
|
|
219
219
|
*/
|
|
220
220
|
type ContractRouter<TMeta extends Meta> = ContractProcedure<any, any, any, TMeta> | {
|
|
221
221
|
[k: string]: ContractRouter<TMeta>;
|
|
@@ -225,7 +225,7 @@ type AnyContractRouter = ContractRouter<any>;
|
|
|
225
225
|
* Infer all inputs of the contract router.
|
|
226
226
|
*
|
|
227
227
|
* @info A contract procedure is a contract router too.
|
|
228
|
-
* @see {@link https://orpc.
|
|
228
|
+
* @see {@link https://orpc.dev/docs/contract-first/define-contract#utilities Contract Utilities Docs}
|
|
229
229
|
*/
|
|
230
230
|
type InferContractRouterInputs<T extends AnyContractRouter> = T extends ContractProcedure<infer UInputSchema, any, any, any> ? InferSchemaInput<UInputSchema> : {
|
|
231
231
|
[K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterInputs<T[K]> : never;
|
|
@@ -234,7 +234,7 @@ type InferContractRouterInputs<T extends AnyContractRouter> = T extends Contract
|
|
|
234
234
|
* Infer all outputs of the contract router.
|
|
235
235
|
*
|
|
236
236
|
* @info A contract procedure is a contract router too.
|
|
237
|
-
* @see {@link https://orpc.
|
|
237
|
+
* @see {@link https://orpc.dev/docs/contract-first/define-contract#utilities Contract Utilities Docs}
|
|
238
238
|
*/
|
|
239
239
|
type InferContractRouterOutputs<T extends AnyContractRouter> = T extends ContractProcedure<any, infer UOutputSchema, any, any> ? InferSchemaOutput<UOutputSchema> : {
|
|
240
240
|
[K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterOutputs<T[K]> : never;
|
|
@@ -243,7 +243,7 @@ type InferContractRouterOutputs<T extends AnyContractRouter> = T extends Contrac
|
|
|
243
243
|
* Infer all errors of the contract router.
|
|
244
244
|
*
|
|
245
245
|
* @info A contract procedure is a contract router too.
|
|
246
|
-
* @see {@link https://orpc.
|
|
246
|
+
* @see {@link https://orpc.dev/docs/contract-first/define-contract#utilities Contract Utilities Docs}
|
|
247
247
|
*/
|
|
248
248
|
type InferContractRouterErrorMap<T extends AnyContractRouter> = T extends ContractProcedure<any, any, infer UErrorMap, any> ? UErrorMap : {
|
|
249
249
|
[K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterErrorMap<T[K]> : never;
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/contract",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.80df4d2",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"homepage": "https://orpc.
|
|
6
|
+
"homepage": "https://orpc.dev",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/unnoq/orpc.git",
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@standard-schema/spec": "^1.0.0",
|
|
33
33
|
"openapi-types": "^12.1.3",
|
|
34
|
-
"@orpc/client": "0.0.0-next.
|
|
35
|
-
"@orpc/shared": "0.0.0-next.
|
|
34
|
+
"@orpc/client": "0.0.0-next.80df4d2",
|
|
35
|
+
"@orpc/shared": "0.0.0-next.80df4d2"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"arktype": "2.1.
|
|
39
|
-
"valibot": "^1.
|
|
40
|
-
"zod": "^4.1.
|
|
38
|
+
"arktype": "2.1.27",
|
|
39
|
+
"valibot": "^1.2.0",
|
|
40
|
+
"zod": "^4.1.12"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "unbuild",
|