@orpc/contract 0.0.0-next.c112960 → 0.0.0-next.c20c3b4
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 +3 -3
- package/dist/index.d.mts +64 -43
- package/dist/index.d.ts +64 -43
- package/dist/index.mjs +47 -15
- package/dist/plugins/index.d.mts +3 -3
- package/dist/plugins/index.d.ts +3 -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>
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
|
|
46
46
|
## Documentation
|
|
47
47
|
|
|
48
|
-
You can find the full documentation [here](https://orpc.
|
|
48
|
+
You can find the full documentation [here](https://orpc.dev).
|
|
49
49
|
|
|
50
50
|
## Packages
|
|
51
51
|
|
|
@@ -66,7 +66,7 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
66
66
|
|
|
67
67
|
## `@orpc/contract`
|
|
68
68
|
|
|
69
|
-
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.
|
|
70
70
|
|
|
71
71
|
```ts
|
|
72
72
|
export const PlanetSchema = z.object({
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
6
|
export { AsyncIteratorClass, Registry, ThrowableError } from '@orpc/shared';
|
|
7
7
|
export { OpenAPIV3_1 as OpenAPI } from 'openapi-types';
|
|
@@ -21,23 +21,38 @@ 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
|
+
type PopulatedContractRouterPaths<T extends AnyContractRouter> = T extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrors, infer UMeta> ? ContractProcedure<UInputSchema, UOutputSchema, UErrors, UMeta> : {
|
|
28
|
+
[K in keyof T]: T[K] extends AnyContractRouter ? PopulatedContractRouterPaths<T[K]> : never;
|
|
29
|
+
};
|
|
30
|
+
interface PopulateContractRouterPathsOptions {
|
|
31
|
+
path?: readonly string[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Automatically populates missing route paths using the router's nested keys.
|
|
35
|
+
*
|
|
36
|
+
* Constructs paths by joining router keys with `/`.
|
|
37
|
+
* Useful for NestJS integration that require explicit route paths.
|
|
38
|
+
*
|
|
39
|
+
* @see {@link https://orpc.dev/docs/openapi/integrations/implement-contract-in-nest#define-your-contract NestJS Implement Contract Docs}
|
|
40
|
+
*/
|
|
41
|
+
declare function populateContractRouterPaths<T extends AnyContractRouter>(router: T, options?: PopulateContractRouterPathsOptions): PopulatedContractRouterPaths<T>;
|
|
27
42
|
|
|
28
43
|
interface ContractProcedureBuilder<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
|
29
44
|
/**
|
|
30
45
|
* Adds type-safe custom errors to the contract.
|
|
31
46
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
32
47
|
*
|
|
33
|
-
* @see {@link https://orpc.
|
|
48
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
34
49
|
*/
|
|
35
50
|
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
36
51
|
/**
|
|
37
52
|
* Sets or updates the metadata for the contract.
|
|
38
53
|
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
39
54
|
*
|
|
40
|
-
* @see {@link https://orpc.
|
|
55
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
41
56
|
*/
|
|
42
57
|
meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
43
58
|
/**
|
|
@@ -45,20 +60,20 @@ interface ContractProcedureBuilder<TInputSchema extends AnySchema, TOutputSchema
|
|
|
45
60
|
* The provided route is spared-merged with any existing route in the contract.
|
|
46
61
|
* This option is typically relevant when integrating with OpenAPI.
|
|
47
62
|
*
|
|
48
|
-
* @see {@link https://orpc.
|
|
49
|
-
* @see {@link https://orpc.
|
|
63
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
64
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
50
65
|
*/
|
|
51
66
|
route(route: Route): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
52
67
|
/**
|
|
53
68
|
* Defines the input validation schema for the contract.
|
|
54
69
|
*
|
|
55
|
-
* @see {@link https://orpc.
|
|
70
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs}
|
|
56
71
|
*/
|
|
57
72
|
input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>;
|
|
58
73
|
/**
|
|
59
74
|
* Defines the output validation schema for the contract.
|
|
60
75
|
*
|
|
61
|
-
* @see {@link https://orpc.
|
|
76
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs}
|
|
62
77
|
*/
|
|
63
78
|
output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>;
|
|
64
79
|
}
|
|
@@ -67,14 +82,14 @@ interface ContractProcedureBuilderWithInput<TInputSchema extends AnySchema, TOut
|
|
|
67
82
|
* Adds type-safe custom errors to the contract.
|
|
68
83
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
69
84
|
*
|
|
70
|
-
* @see {@link https://orpc.
|
|
85
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
71
86
|
*/
|
|
72
87
|
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
73
88
|
/**
|
|
74
89
|
* Sets or updates the metadata for the contract.
|
|
75
90
|
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
76
91
|
*
|
|
77
|
-
* @see {@link https://orpc.
|
|
92
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
78
93
|
*/
|
|
79
94
|
meta(meta: TMeta): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
80
95
|
/**
|
|
@@ -82,14 +97,14 @@ interface ContractProcedureBuilderWithInput<TInputSchema extends AnySchema, TOut
|
|
|
82
97
|
* The provided route is spared-merged with any existing route in the contract.
|
|
83
98
|
* This option is typically relevant when integrating with OpenAPI.
|
|
84
99
|
*
|
|
85
|
-
* @see {@link https://orpc.
|
|
86
|
-
* @see {@link https://orpc.
|
|
100
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
101
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
87
102
|
*/
|
|
88
103
|
route(route: Route): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
89
104
|
/**
|
|
90
105
|
* Defines the output validation schema for the contract.
|
|
91
106
|
*
|
|
92
|
-
* @see {@link https://orpc.
|
|
107
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs}
|
|
93
108
|
*/
|
|
94
109
|
output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInputOutput<TInputSchema, U, TErrorMap, TMeta>;
|
|
95
110
|
}
|
|
@@ -98,14 +113,14 @@ interface ContractProcedureBuilderWithOutput<TInputSchema extends AnySchema, TOu
|
|
|
98
113
|
* Adds type-safe custom errors to the contract.
|
|
99
114
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
100
115
|
*
|
|
101
|
-
* @see {@link https://orpc.
|
|
116
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
102
117
|
*/
|
|
103
118
|
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
104
119
|
/**
|
|
105
120
|
* Sets or updates the metadata for the contract.
|
|
106
121
|
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
107
122
|
*
|
|
108
|
-
* @see {@link https://orpc.
|
|
123
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
109
124
|
*/
|
|
110
125
|
meta(meta: TMeta): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
111
126
|
/**
|
|
@@ -113,14 +128,14 @@ interface ContractProcedureBuilderWithOutput<TInputSchema extends AnySchema, TOu
|
|
|
113
128
|
* The provided route is spared-merged with any existing route in the contract.
|
|
114
129
|
* This option is typically relevant when integrating with OpenAPI.
|
|
115
130
|
*
|
|
116
|
-
* @see {@link https://orpc.
|
|
117
|
-
* @see {@link https://orpc.
|
|
131
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
132
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
118
133
|
*/
|
|
119
134
|
route(route: Route): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
120
135
|
/**
|
|
121
136
|
* Defines the input validation schema for the contract.
|
|
122
137
|
*
|
|
123
|
-
* @see {@link https://orpc.
|
|
138
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs}
|
|
124
139
|
*/
|
|
125
140
|
input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInputOutput<U, TOutputSchema, TErrorMap, TMeta>;
|
|
126
141
|
}
|
|
@@ -129,14 +144,14 @@ interface ContractProcedureBuilderWithInputOutput<TInputSchema extends AnySchema
|
|
|
129
144
|
* Adds type-safe custom errors to the contract.
|
|
130
145
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
131
146
|
*
|
|
132
|
-
* @see {@link https://orpc.
|
|
147
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
133
148
|
*/
|
|
134
149
|
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
135
150
|
/**
|
|
136
151
|
* Sets or updates the metadata for the contract.
|
|
137
152
|
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
138
153
|
*
|
|
139
|
-
* @see {@link https://orpc.
|
|
154
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
140
155
|
*/
|
|
141
156
|
meta(meta: TMeta): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
142
157
|
/**
|
|
@@ -144,8 +159,8 @@ interface ContractProcedureBuilderWithInputOutput<TInputSchema extends AnySchema
|
|
|
144
159
|
* The provided route is spared-merged with any existing route in the contract.
|
|
145
160
|
* This option is typically relevant when integrating with OpenAPI.
|
|
146
161
|
*
|
|
147
|
-
* @see {@link https://orpc.
|
|
148
|
-
* @see {@link https://orpc.
|
|
162
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
163
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
149
164
|
*/
|
|
150
165
|
route(route: Route): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
151
166
|
}
|
|
@@ -158,7 +173,7 @@ interface ContractRouterBuilder<TErrorMap extends ErrorMap, TMeta extends Meta>
|
|
|
158
173
|
* Adds type-safe custom errors to the contract.
|
|
159
174
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
160
175
|
*
|
|
161
|
-
* @see {@link https://orpc.
|
|
176
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
162
177
|
*/
|
|
163
178
|
'errors'<U extends ErrorMap>(errors: U): ContractRouterBuilder<MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
164
179
|
/**
|
|
@@ -167,20 +182,20 @@ interface ContractRouterBuilder<TErrorMap extends ErrorMap, TMeta extends Meta>
|
|
|
167
182
|
*
|
|
168
183
|
* @note This option does not affect procedures that do not define a path in their route definition.
|
|
169
184
|
*
|
|
170
|
-
* @see {@link https://orpc.
|
|
185
|
+
* @see {@link https://orpc.dev/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
171
186
|
*/
|
|
172
187
|
'prefix'(prefix: HTTPPath): ContractRouterBuilder<TErrorMap, TMeta>;
|
|
173
188
|
/**
|
|
174
189
|
* Adds tags to all procedures in the contract router.
|
|
175
190
|
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
176
191
|
*
|
|
177
|
-
* @see {@link https://orpc.
|
|
192
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
178
193
|
*/
|
|
179
194
|
'tag'(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>;
|
|
180
195
|
/**
|
|
181
196
|
* Applies all of the previously defined options to the specified contract router.
|
|
182
197
|
*
|
|
183
|
-
* @see {@link https://orpc.
|
|
198
|
+
* @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs}
|
|
184
199
|
*/
|
|
185
200
|
'router'<T extends ContractRouter<TMeta>>(router: T): EnhancedContractRouter<T, TErrorMap>;
|
|
186
201
|
}
|
|
@@ -196,29 +211,35 @@ declare class ContractBuilder<TInputSchema extends AnySchema, TOutputSchema exte
|
|
|
196
211
|
/**
|
|
197
212
|
* Sets or overrides the initial meta.
|
|
198
213
|
*
|
|
199
|
-
* @see {@link https://orpc.
|
|
214
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
200
215
|
*/
|
|
201
216
|
$meta<U extends Meta>(initialMeta: U): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, U & Record<never, never>>;
|
|
202
217
|
/**
|
|
203
218
|
* Sets or overrides the initial route.
|
|
204
219
|
* This option is typically relevant when integrating with OpenAPI.
|
|
205
220
|
*
|
|
206
|
-
* @see {@link https://orpc.
|
|
207
|
-
* @see {@link https://orpc.
|
|
221
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
222
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
208
223
|
*/
|
|
209
224
|
$route(initialRoute: Route): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
225
|
+
/**
|
|
226
|
+
* Sets or overrides the initial input schema.
|
|
227
|
+
*
|
|
228
|
+
* @see {@link https://orpc.dev/docs/procedure#initial-configuration Initial Procedure Configuration Docs}
|
|
229
|
+
*/
|
|
230
|
+
$input<U extends AnySchema>(initialInputSchema?: U): ContractBuilder<U, TOutputSchema, TErrorMap, TMeta>;
|
|
210
231
|
/**
|
|
211
232
|
* Adds type-safe custom errors to the contract.
|
|
212
233
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
213
234
|
*
|
|
214
|
-
* @see {@link https://orpc.
|
|
235
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
215
236
|
*/
|
|
216
237
|
errors<U extends ErrorMap>(errors: U): ContractBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
217
238
|
/**
|
|
218
239
|
* Sets or updates the metadata for the contract.
|
|
219
240
|
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
220
241
|
*
|
|
221
|
-
* @see {@link https://orpc.
|
|
242
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
222
243
|
*/
|
|
223
244
|
meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
224
245
|
/**
|
|
@@ -226,20 +247,20 @@ declare class ContractBuilder<TInputSchema extends AnySchema, TOutputSchema exte
|
|
|
226
247
|
* The provided route is spared-merged with any existing route in the contract.
|
|
227
248
|
* This option is typically relevant when integrating with OpenAPI.
|
|
228
249
|
*
|
|
229
|
-
* @see {@link https://orpc.
|
|
230
|
-
* @see {@link https://orpc.
|
|
250
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
251
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
231
252
|
*/
|
|
232
253
|
route(route: Route): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
233
254
|
/**
|
|
234
255
|
* Defines the input validation schema for the contract.
|
|
235
256
|
*
|
|
236
|
-
* @see {@link https://orpc.
|
|
257
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs}
|
|
237
258
|
*/
|
|
238
259
|
input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>;
|
|
239
260
|
/**
|
|
240
261
|
* Defines the output validation schema for the contract.
|
|
241
262
|
*
|
|
242
|
-
* @see {@link https://orpc.
|
|
263
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs}
|
|
243
264
|
*/
|
|
244
265
|
output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>;
|
|
245
266
|
/**
|
|
@@ -248,20 +269,20 @@ declare class ContractBuilder<TInputSchema extends AnySchema, TOutputSchema exte
|
|
|
248
269
|
*
|
|
249
270
|
* @note This option does not affect procedures that do not define a path in their route definition.
|
|
250
271
|
*
|
|
251
|
-
* @see {@link https://orpc.
|
|
272
|
+
* @see {@link https://orpc.dev/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
252
273
|
*/
|
|
253
274
|
prefix(prefix: HTTPPath): ContractRouterBuilder<TErrorMap, TMeta>;
|
|
254
275
|
/**
|
|
255
276
|
* Adds tags to all procedures in the contract router.
|
|
256
277
|
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
257
278
|
*
|
|
258
|
-
* @see {@link https://orpc.
|
|
279
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
259
280
|
*/
|
|
260
281
|
tag(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>;
|
|
261
282
|
/**
|
|
262
283
|
* Applies all of the previously defined options to the specified contract router.
|
|
263
284
|
*
|
|
264
|
-
* @see {@link https://orpc.
|
|
285
|
+
* @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs}
|
|
265
286
|
*/
|
|
266
287
|
router<T extends ContractRouter<TMeta>>(router: T): EnhancedContractRouter<T, TErrorMap>;
|
|
267
288
|
}
|
|
@@ -283,7 +304,7 @@ interface EventIteratorSchemaDetails {
|
|
|
283
304
|
/**
|
|
284
305
|
* Define schema for an event iterator.
|
|
285
306
|
*
|
|
286
|
-
* @see {@link https://orpc.
|
|
307
|
+
* @see {@link https://orpc.dev/docs/event-iterator#validate-event-iterator Validate Event Iterator Docs}
|
|
287
308
|
*/
|
|
288
309
|
declare function eventIterator<TYieldIn, TYieldOut, TReturnIn = unknown, TReturnOut = unknown>(yields: Schema<TYieldIn, TYieldOut>, returns?: Schema<TReturnIn, TReturnOut>): Schema<AsyncIteratorObject<TYieldIn, TReturnIn, void>, AsyncIteratorClass<TYieldOut, TReturnOut, void>>;
|
|
289
310
|
declare function getEventIteratorSchemaDetails(schema: AnySchema | undefined): undefined | EventIteratorSchemaDetails;
|
|
@@ -291,7 +312,7 @@ declare function getEventIteratorSchemaDetails(schema: AnySchema | undefined): u
|
|
|
291
312
|
/**
|
|
292
313
|
* Help RPCLink automatically send requests using the specified HTTP method in the contract.
|
|
293
314
|
*
|
|
294
|
-
* @see {@link https://orpc.
|
|
315
|
+
* @see {@link https://orpc.dev/docs/client/rpc-link#custom-request-method RPCLink Custom Request Method}
|
|
295
316
|
*/
|
|
296
317
|
declare function inferRPCMethodFromContractRouter(contract: AnyContractRouter): (options: unknown, path: readonly string[]) => Exclude<HTTPMethod, 'HEAD'>;
|
|
297
318
|
|
|
@@ -303,5 +324,5 @@ type ContractRouterClient<TRouter extends AnyContractRouter, TClientContext exte
|
|
|
303
324
|
|
|
304
325
|
declare function isSchemaIssue(issue: unknown): issue is SchemaIssue;
|
|
305
326
|
|
|
306
|
-
export { AnyContractRouter, AnySchema, ContractBuilder, ContractProcedure, ContractProcedureDef, ContractRouter, EnhanceRouteOptions, ErrorFromErrorMap, ErrorMap, InferSchemaInput, InferSchemaOutput, InputStructure, MergedErrorMap, Meta, OutputStructure, Route, Schema, SchemaIssue, enhanceContractRouter, eventIterator, fallbackContractConfig, getContractRouter, getEventIteratorSchemaDetails, inferRPCMethodFromContractRouter, isSchemaIssue, minifyContractRouter, oc };
|
|
307
|
-
export type { ContractBuilderDef, ContractConfig, ContractProcedureBuilder, ContractProcedureBuilderWithInput, ContractProcedureBuilderWithInputOutput, ContractProcedureBuilderWithOutput, ContractProcedureClient, ContractRouterBuilder, ContractRouterClient, EnhanceContractRouterOptions, EnhancedContractRouter, EventIteratorSchemaDetails };
|
|
327
|
+
export { AnyContractRouter, AnySchema, ContractBuilder, ContractProcedure, ContractProcedureDef, ContractRouter, EnhanceRouteOptions, ErrorFromErrorMap, ErrorMap, InferSchemaInput, InferSchemaOutput, InputStructure, MergedErrorMap, Meta, OutputStructure, Route, Schema, SchemaIssue, enhanceContractRouter, eventIterator, fallbackContractConfig, getContractRouter, getEventIteratorSchemaDetails, inferRPCMethodFromContractRouter, isSchemaIssue, minifyContractRouter, oc, populateContractRouterPaths };
|
|
328
|
+
export type { ContractBuilderDef, ContractConfig, ContractProcedureBuilder, ContractProcedureBuilderWithInput, ContractProcedureBuilderWithInputOutput, ContractProcedureBuilderWithOutput, ContractProcedureClient, ContractRouterBuilder, ContractRouterClient, EnhanceContractRouterOptions, EnhancedContractRouter, EventIteratorSchemaDetails, PopulateContractRouterPathsOptions, PopulatedContractRouterPaths };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
6
|
export { AsyncIteratorClass, Registry, ThrowableError } from '@orpc/shared';
|
|
7
7
|
export { OpenAPIV3_1 as OpenAPI } from 'openapi-types';
|
|
@@ -21,23 +21,38 @@ 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
|
+
type PopulatedContractRouterPaths<T extends AnyContractRouter> = T extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrors, infer UMeta> ? ContractProcedure<UInputSchema, UOutputSchema, UErrors, UMeta> : {
|
|
28
|
+
[K in keyof T]: T[K] extends AnyContractRouter ? PopulatedContractRouterPaths<T[K]> : never;
|
|
29
|
+
};
|
|
30
|
+
interface PopulateContractRouterPathsOptions {
|
|
31
|
+
path?: readonly string[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Automatically populates missing route paths using the router's nested keys.
|
|
35
|
+
*
|
|
36
|
+
* Constructs paths by joining router keys with `/`.
|
|
37
|
+
* Useful for NestJS integration that require explicit route paths.
|
|
38
|
+
*
|
|
39
|
+
* @see {@link https://orpc.dev/docs/openapi/integrations/implement-contract-in-nest#define-your-contract NestJS Implement Contract Docs}
|
|
40
|
+
*/
|
|
41
|
+
declare function populateContractRouterPaths<T extends AnyContractRouter>(router: T, options?: PopulateContractRouterPathsOptions): PopulatedContractRouterPaths<T>;
|
|
27
42
|
|
|
28
43
|
interface ContractProcedureBuilder<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
|
29
44
|
/**
|
|
30
45
|
* Adds type-safe custom errors to the contract.
|
|
31
46
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
32
47
|
*
|
|
33
|
-
* @see {@link https://orpc.
|
|
48
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
34
49
|
*/
|
|
35
50
|
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
36
51
|
/**
|
|
37
52
|
* Sets or updates the metadata for the contract.
|
|
38
53
|
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
39
54
|
*
|
|
40
|
-
* @see {@link https://orpc.
|
|
55
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
41
56
|
*/
|
|
42
57
|
meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
43
58
|
/**
|
|
@@ -45,20 +60,20 @@ interface ContractProcedureBuilder<TInputSchema extends AnySchema, TOutputSchema
|
|
|
45
60
|
* The provided route is spared-merged with any existing route in the contract.
|
|
46
61
|
* This option is typically relevant when integrating with OpenAPI.
|
|
47
62
|
*
|
|
48
|
-
* @see {@link https://orpc.
|
|
49
|
-
* @see {@link https://orpc.
|
|
63
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
64
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
50
65
|
*/
|
|
51
66
|
route(route: Route): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
52
67
|
/**
|
|
53
68
|
* Defines the input validation schema for the contract.
|
|
54
69
|
*
|
|
55
|
-
* @see {@link https://orpc.
|
|
70
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs}
|
|
56
71
|
*/
|
|
57
72
|
input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>;
|
|
58
73
|
/**
|
|
59
74
|
* Defines the output validation schema for the contract.
|
|
60
75
|
*
|
|
61
|
-
* @see {@link https://orpc.
|
|
76
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs}
|
|
62
77
|
*/
|
|
63
78
|
output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>;
|
|
64
79
|
}
|
|
@@ -67,14 +82,14 @@ interface ContractProcedureBuilderWithInput<TInputSchema extends AnySchema, TOut
|
|
|
67
82
|
* Adds type-safe custom errors to the contract.
|
|
68
83
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
69
84
|
*
|
|
70
|
-
* @see {@link https://orpc.
|
|
85
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
71
86
|
*/
|
|
72
87
|
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
73
88
|
/**
|
|
74
89
|
* Sets or updates the metadata for the contract.
|
|
75
90
|
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
76
91
|
*
|
|
77
|
-
* @see {@link https://orpc.
|
|
92
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
78
93
|
*/
|
|
79
94
|
meta(meta: TMeta): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
80
95
|
/**
|
|
@@ -82,14 +97,14 @@ interface ContractProcedureBuilderWithInput<TInputSchema extends AnySchema, TOut
|
|
|
82
97
|
* The provided route is spared-merged with any existing route in the contract.
|
|
83
98
|
* This option is typically relevant when integrating with OpenAPI.
|
|
84
99
|
*
|
|
85
|
-
* @see {@link https://orpc.
|
|
86
|
-
* @see {@link https://orpc.
|
|
100
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
101
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
87
102
|
*/
|
|
88
103
|
route(route: Route): ContractProcedureBuilderWithInput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
89
104
|
/**
|
|
90
105
|
* Defines the output validation schema for the contract.
|
|
91
106
|
*
|
|
92
|
-
* @see {@link https://orpc.
|
|
107
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs}
|
|
93
108
|
*/
|
|
94
109
|
output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInputOutput<TInputSchema, U, TErrorMap, TMeta>;
|
|
95
110
|
}
|
|
@@ -98,14 +113,14 @@ interface ContractProcedureBuilderWithOutput<TInputSchema extends AnySchema, TOu
|
|
|
98
113
|
* Adds type-safe custom errors to the contract.
|
|
99
114
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
100
115
|
*
|
|
101
|
-
* @see {@link https://orpc.
|
|
116
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
102
117
|
*/
|
|
103
118
|
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
104
119
|
/**
|
|
105
120
|
* Sets or updates the metadata for the contract.
|
|
106
121
|
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
107
122
|
*
|
|
108
|
-
* @see {@link https://orpc.
|
|
123
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
109
124
|
*/
|
|
110
125
|
meta(meta: TMeta): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
111
126
|
/**
|
|
@@ -113,14 +128,14 @@ interface ContractProcedureBuilderWithOutput<TInputSchema extends AnySchema, TOu
|
|
|
113
128
|
* The provided route is spared-merged with any existing route in the contract.
|
|
114
129
|
* This option is typically relevant when integrating with OpenAPI.
|
|
115
130
|
*
|
|
116
|
-
* @see {@link https://orpc.
|
|
117
|
-
* @see {@link https://orpc.
|
|
131
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
132
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
118
133
|
*/
|
|
119
134
|
route(route: Route): ContractProcedureBuilderWithOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
120
135
|
/**
|
|
121
136
|
* Defines the input validation schema for the contract.
|
|
122
137
|
*
|
|
123
|
-
* @see {@link https://orpc.
|
|
138
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs}
|
|
124
139
|
*/
|
|
125
140
|
input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInputOutput<U, TOutputSchema, TErrorMap, TMeta>;
|
|
126
141
|
}
|
|
@@ -129,14 +144,14 @@ interface ContractProcedureBuilderWithInputOutput<TInputSchema extends AnySchema
|
|
|
129
144
|
* Adds type-safe custom errors to the contract.
|
|
130
145
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
131
146
|
*
|
|
132
|
-
* @see {@link https://orpc.
|
|
147
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
133
148
|
*/
|
|
134
149
|
errors<U extends ErrorMap>(errors: U): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
135
150
|
/**
|
|
136
151
|
* Sets or updates the metadata for the contract.
|
|
137
152
|
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
138
153
|
*
|
|
139
|
-
* @see {@link https://orpc.
|
|
154
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
140
155
|
*/
|
|
141
156
|
meta(meta: TMeta): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
142
157
|
/**
|
|
@@ -144,8 +159,8 @@ interface ContractProcedureBuilderWithInputOutput<TInputSchema extends AnySchema
|
|
|
144
159
|
* The provided route is spared-merged with any existing route in the contract.
|
|
145
160
|
* This option is typically relevant when integrating with OpenAPI.
|
|
146
161
|
*
|
|
147
|
-
* @see {@link https://orpc.
|
|
148
|
-
* @see {@link https://orpc.
|
|
162
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
163
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
149
164
|
*/
|
|
150
165
|
route(route: Route): ContractProcedureBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
151
166
|
}
|
|
@@ -158,7 +173,7 @@ interface ContractRouterBuilder<TErrorMap extends ErrorMap, TMeta extends Meta>
|
|
|
158
173
|
* Adds type-safe custom errors to the contract.
|
|
159
174
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
160
175
|
*
|
|
161
|
-
* @see {@link https://orpc.
|
|
176
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
162
177
|
*/
|
|
163
178
|
'errors'<U extends ErrorMap>(errors: U): ContractRouterBuilder<MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
164
179
|
/**
|
|
@@ -167,20 +182,20 @@ interface ContractRouterBuilder<TErrorMap extends ErrorMap, TMeta extends Meta>
|
|
|
167
182
|
*
|
|
168
183
|
* @note This option does not affect procedures that do not define a path in their route definition.
|
|
169
184
|
*
|
|
170
|
-
* @see {@link https://orpc.
|
|
185
|
+
* @see {@link https://orpc.dev/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
171
186
|
*/
|
|
172
187
|
'prefix'(prefix: HTTPPath): ContractRouterBuilder<TErrorMap, TMeta>;
|
|
173
188
|
/**
|
|
174
189
|
* Adds tags to all procedures in the contract router.
|
|
175
190
|
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
176
191
|
*
|
|
177
|
-
* @see {@link https://orpc.
|
|
192
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
178
193
|
*/
|
|
179
194
|
'tag'(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>;
|
|
180
195
|
/**
|
|
181
196
|
* Applies all of the previously defined options to the specified contract router.
|
|
182
197
|
*
|
|
183
|
-
* @see {@link https://orpc.
|
|
198
|
+
* @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs}
|
|
184
199
|
*/
|
|
185
200
|
'router'<T extends ContractRouter<TMeta>>(router: T): EnhancedContractRouter<T, TErrorMap>;
|
|
186
201
|
}
|
|
@@ -196,29 +211,35 @@ declare class ContractBuilder<TInputSchema extends AnySchema, TOutputSchema exte
|
|
|
196
211
|
/**
|
|
197
212
|
* Sets or overrides the initial meta.
|
|
198
213
|
*
|
|
199
|
-
* @see {@link https://orpc.
|
|
214
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
200
215
|
*/
|
|
201
216
|
$meta<U extends Meta>(initialMeta: U): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, U & Record<never, never>>;
|
|
202
217
|
/**
|
|
203
218
|
* Sets or overrides the initial route.
|
|
204
219
|
* This option is typically relevant when integrating with OpenAPI.
|
|
205
220
|
*
|
|
206
|
-
* @see {@link https://orpc.
|
|
207
|
-
* @see {@link https://orpc.
|
|
221
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
222
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
208
223
|
*/
|
|
209
224
|
$route(initialRoute: Route): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
225
|
+
/**
|
|
226
|
+
* Sets or overrides the initial input schema.
|
|
227
|
+
*
|
|
228
|
+
* @see {@link https://orpc.dev/docs/procedure#initial-configuration Initial Procedure Configuration Docs}
|
|
229
|
+
*/
|
|
230
|
+
$input<U extends AnySchema>(initialInputSchema?: U): ContractBuilder<U, TOutputSchema, TErrorMap, TMeta>;
|
|
210
231
|
/**
|
|
211
232
|
* Adds type-safe custom errors to the contract.
|
|
212
233
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
213
234
|
*
|
|
214
|
-
* @see {@link https://orpc.
|
|
235
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
215
236
|
*/
|
|
216
237
|
errors<U extends ErrorMap>(errors: U): ContractBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
217
238
|
/**
|
|
218
239
|
* Sets or updates the metadata for the contract.
|
|
219
240
|
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
220
241
|
*
|
|
221
|
-
* @see {@link https://orpc.
|
|
242
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
222
243
|
*/
|
|
223
244
|
meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
224
245
|
/**
|
|
@@ -226,20 +247,20 @@ declare class ContractBuilder<TInputSchema extends AnySchema, TOutputSchema exte
|
|
|
226
247
|
* The provided route is spared-merged with any existing route in the contract.
|
|
227
248
|
* This option is typically relevant when integrating with OpenAPI.
|
|
228
249
|
*
|
|
229
|
-
* @see {@link https://orpc.
|
|
230
|
-
* @see {@link https://orpc.
|
|
250
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
251
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
231
252
|
*/
|
|
232
253
|
route(route: Route): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
233
254
|
/**
|
|
234
255
|
* Defines the input validation schema for the contract.
|
|
235
256
|
*
|
|
236
|
-
* @see {@link https://orpc.
|
|
257
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs}
|
|
237
258
|
*/
|
|
238
259
|
input<U extends AnySchema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>;
|
|
239
260
|
/**
|
|
240
261
|
* Defines the output validation schema for the contract.
|
|
241
262
|
*
|
|
242
|
-
* @see {@link https://orpc.
|
|
263
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs}
|
|
243
264
|
*/
|
|
244
265
|
output<U extends AnySchema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>;
|
|
245
266
|
/**
|
|
@@ -248,20 +269,20 @@ declare class ContractBuilder<TInputSchema extends AnySchema, TOutputSchema exte
|
|
|
248
269
|
*
|
|
249
270
|
* @note This option does not affect procedures that do not define a path in their route definition.
|
|
250
271
|
*
|
|
251
|
-
* @see {@link https://orpc.
|
|
272
|
+
* @see {@link https://orpc.dev/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
252
273
|
*/
|
|
253
274
|
prefix(prefix: HTTPPath): ContractRouterBuilder<TErrorMap, TMeta>;
|
|
254
275
|
/**
|
|
255
276
|
* Adds tags to all procedures in the contract router.
|
|
256
277
|
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
257
278
|
*
|
|
258
|
-
* @see {@link https://orpc.
|
|
279
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
259
280
|
*/
|
|
260
281
|
tag(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>;
|
|
261
282
|
/**
|
|
262
283
|
* Applies all of the previously defined options to the specified contract router.
|
|
263
284
|
*
|
|
264
|
-
* @see {@link https://orpc.
|
|
285
|
+
* @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs}
|
|
265
286
|
*/
|
|
266
287
|
router<T extends ContractRouter<TMeta>>(router: T): EnhancedContractRouter<T, TErrorMap>;
|
|
267
288
|
}
|
|
@@ -283,7 +304,7 @@ interface EventIteratorSchemaDetails {
|
|
|
283
304
|
/**
|
|
284
305
|
* Define schema for an event iterator.
|
|
285
306
|
*
|
|
286
|
-
* @see {@link https://orpc.
|
|
307
|
+
* @see {@link https://orpc.dev/docs/event-iterator#validate-event-iterator Validate Event Iterator Docs}
|
|
287
308
|
*/
|
|
288
309
|
declare function eventIterator<TYieldIn, TYieldOut, TReturnIn = unknown, TReturnOut = unknown>(yields: Schema<TYieldIn, TYieldOut>, returns?: Schema<TReturnIn, TReturnOut>): Schema<AsyncIteratorObject<TYieldIn, TReturnIn, void>, AsyncIteratorClass<TYieldOut, TReturnOut, void>>;
|
|
289
310
|
declare function getEventIteratorSchemaDetails(schema: AnySchema | undefined): undefined | EventIteratorSchemaDetails;
|
|
@@ -291,7 +312,7 @@ declare function getEventIteratorSchemaDetails(schema: AnySchema | undefined): u
|
|
|
291
312
|
/**
|
|
292
313
|
* Help RPCLink automatically send requests using the specified HTTP method in the contract.
|
|
293
314
|
*
|
|
294
|
-
* @see {@link https://orpc.
|
|
315
|
+
* @see {@link https://orpc.dev/docs/client/rpc-link#custom-request-method RPCLink Custom Request Method}
|
|
295
316
|
*/
|
|
296
317
|
declare function inferRPCMethodFromContractRouter(contract: AnyContractRouter): (options: unknown, path: readonly string[]) => Exclude<HTTPMethod, 'HEAD'>;
|
|
297
318
|
|
|
@@ -303,5 +324,5 @@ type ContractRouterClient<TRouter extends AnyContractRouter, TClientContext exte
|
|
|
303
324
|
|
|
304
325
|
declare function isSchemaIssue(issue: unknown): issue is SchemaIssue;
|
|
305
326
|
|
|
306
|
-
export { AnyContractRouter, AnySchema, ContractBuilder, ContractProcedure, ContractProcedureDef, ContractRouter, EnhanceRouteOptions, ErrorFromErrorMap, ErrorMap, InferSchemaInput, InferSchemaOutput, InputStructure, MergedErrorMap, Meta, OutputStructure, Route, Schema, SchemaIssue, enhanceContractRouter, eventIterator, fallbackContractConfig, getContractRouter, getEventIteratorSchemaDetails, inferRPCMethodFromContractRouter, isSchemaIssue, minifyContractRouter, oc };
|
|
307
|
-
export type { ContractBuilderDef, ContractConfig, ContractProcedureBuilder, ContractProcedureBuilderWithInput, ContractProcedureBuilderWithInputOutput, ContractProcedureBuilderWithOutput, ContractProcedureClient, ContractRouterBuilder, ContractRouterClient, EnhanceContractRouterOptions, EnhancedContractRouter, EventIteratorSchemaDetails };
|
|
327
|
+
export { AnyContractRouter, AnySchema, ContractBuilder, ContractProcedure, ContractProcedureDef, ContractRouter, EnhanceRouteOptions, ErrorFromErrorMap, ErrorMap, InferSchemaInput, InferSchemaOutput, InputStructure, MergedErrorMap, Meta, OutputStructure, Route, Schema, SchemaIssue, enhanceContractRouter, eventIterator, fallbackContractConfig, getContractRouter, getEventIteratorSchemaDetails, inferRPCMethodFromContractRouter, isSchemaIssue, minifyContractRouter, oc, populateContractRouterPaths };
|
|
328
|
+
export type { ContractBuilderDef, ContractConfig, ContractProcedureBuilder, ContractProcedureBuilderWithInput, ContractProcedureBuilderWithInputOutput, ContractProcedureBuilderWithOutput, ContractProcedureClient, ContractRouterBuilder, ContractRouterClient, EnhanceContractRouterOptions, EnhancedContractRouter, EventIteratorSchemaDetails, PopulateContractRouterPathsOptions, PopulatedContractRouterPaths };
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { i as isContractProcedure, C as ContractProcedure, m as mergeErrorMap, V as ValidationError } from './shared/contract.D_dZrO__.mjs';
|
|
2
2
|
export { v as validateORPCError } from './shared/contract.D_dZrO__.mjs';
|
|
3
|
+
import { toHttpPath } from '@orpc/client/standard';
|
|
4
|
+
import { toArray, isAsyncIteratorObject, get, isTypescriptObject, isPropertyKey } from '@orpc/shared';
|
|
5
|
+
export { AsyncIteratorClass } from '@orpc/shared';
|
|
3
6
|
import { mapEventIterator, ORPCError } from '@orpc/client';
|
|
4
7
|
export { ORPCError } from '@orpc/client';
|
|
5
|
-
import { isAsyncIteratorObject, get, isTypescriptObject, isPropertyKey } from '@orpc/shared';
|
|
6
|
-
export { AsyncIteratorClass } from '@orpc/shared';
|
|
7
8
|
|
|
8
9
|
function mergeMeta(meta1, meta2) {
|
|
9
10
|
return { ...meta1, ...meta2 };
|
|
@@ -90,6 +91,26 @@ function minifyContractRouter(router) {
|
|
|
90
91
|
}
|
|
91
92
|
return json;
|
|
92
93
|
}
|
|
94
|
+
function populateContractRouterPaths(router, options = {}) {
|
|
95
|
+
const path = toArray(options.path);
|
|
96
|
+
if (isContractProcedure(router)) {
|
|
97
|
+
if (router["~orpc"].route.path === void 0) {
|
|
98
|
+
return new ContractProcedure({
|
|
99
|
+
...router["~orpc"],
|
|
100
|
+
route: {
|
|
101
|
+
...router["~orpc"].route,
|
|
102
|
+
path: toHttpPath(path)
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return router;
|
|
107
|
+
}
|
|
108
|
+
const populated = {};
|
|
109
|
+
for (const key in router) {
|
|
110
|
+
populated[key] = populateContractRouterPaths(router[key], { ...options, path: [...path, key] });
|
|
111
|
+
}
|
|
112
|
+
return populated;
|
|
113
|
+
}
|
|
93
114
|
|
|
94
115
|
class ContractBuilder extends ContractProcedure {
|
|
95
116
|
constructor(def) {
|
|
@@ -100,7 +121,7 @@ class ContractBuilder extends ContractProcedure {
|
|
|
100
121
|
/**
|
|
101
122
|
* Sets or overrides the initial meta.
|
|
102
123
|
*
|
|
103
|
-
* @see {@link https://orpc.
|
|
124
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
104
125
|
*/
|
|
105
126
|
$meta(initialMeta) {
|
|
106
127
|
return new ContractBuilder({
|
|
@@ -112,8 +133,8 @@ class ContractBuilder extends ContractProcedure {
|
|
|
112
133
|
* Sets or overrides the initial route.
|
|
113
134
|
* This option is typically relevant when integrating with OpenAPI.
|
|
114
135
|
*
|
|
115
|
-
* @see {@link https://orpc.
|
|
116
|
-
* @see {@link https://orpc.
|
|
136
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
137
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
117
138
|
*/
|
|
118
139
|
$route(initialRoute) {
|
|
119
140
|
return new ContractBuilder({
|
|
@@ -121,11 +142,22 @@ class ContractBuilder extends ContractProcedure {
|
|
|
121
142
|
route: initialRoute
|
|
122
143
|
});
|
|
123
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Sets or overrides the initial input schema.
|
|
147
|
+
*
|
|
148
|
+
* @see {@link https://orpc.dev/docs/procedure#initial-configuration Initial Procedure Configuration Docs}
|
|
149
|
+
*/
|
|
150
|
+
$input(initialInputSchema) {
|
|
151
|
+
return new ContractBuilder({
|
|
152
|
+
...this["~orpc"],
|
|
153
|
+
inputSchema: initialInputSchema
|
|
154
|
+
});
|
|
155
|
+
}
|
|
124
156
|
/**
|
|
125
157
|
* Adds type-safe custom errors to the contract.
|
|
126
158
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
127
159
|
*
|
|
128
|
-
* @see {@link https://orpc.
|
|
160
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
129
161
|
*/
|
|
130
162
|
errors(errors) {
|
|
131
163
|
return new ContractBuilder({
|
|
@@ -137,7 +169,7 @@ class ContractBuilder extends ContractProcedure {
|
|
|
137
169
|
* Sets or updates the metadata for the contract.
|
|
138
170
|
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
139
171
|
*
|
|
140
|
-
* @see {@link https://orpc.
|
|
172
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
141
173
|
*/
|
|
142
174
|
meta(meta) {
|
|
143
175
|
return new ContractBuilder({
|
|
@@ -150,8 +182,8 @@ class ContractBuilder extends ContractProcedure {
|
|
|
150
182
|
* The provided route is spared-merged with any existing route in the contract.
|
|
151
183
|
* This option is typically relevant when integrating with OpenAPI.
|
|
152
184
|
*
|
|
153
|
-
* @see {@link https://orpc.
|
|
154
|
-
* @see {@link https://orpc.
|
|
185
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
186
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
155
187
|
*/
|
|
156
188
|
route(route) {
|
|
157
189
|
return new ContractBuilder({
|
|
@@ -162,7 +194,7 @@ class ContractBuilder extends ContractProcedure {
|
|
|
162
194
|
/**
|
|
163
195
|
* Defines the input validation schema for the contract.
|
|
164
196
|
*
|
|
165
|
-
* @see {@link https://orpc.
|
|
197
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs}
|
|
166
198
|
*/
|
|
167
199
|
input(schema) {
|
|
168
200
|
return new ContractBuilder({
|
|
@@ -173,7 +205,7 @@ class ContractBuilder extends ContractProcedure {
|
|
|
173
205
|
/**
|
|
174
206
|
* Defines the output validation schema for the contract.
|
|
175
207
|
*
|
|
176
|
-
* @see {@link https://orpc.
|
|
208
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs}
|
|
177
209
|
*/
|
|
178
210
|
output(schema) {
|
|
179
211
|
return new ContractBuilder({
|
|
@@ -187,7 +219,7 @@ class ContractBuilder extends ContractProcedure {
|
|
|
187
219
|
*
|
|
188
220
|
* @note This option does not affect procedures that do not define a path in their route definition.
|
|
189
221
|
*
|
|
190
|
-
* @see {@link https://orpc.
|
|
222
|
+
* @see {@link https://orpc.dev/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
191
223
|
*/
|
|
192
224
|
prefix(prefix) {
|
|
193
225
|
return new ContractBuilder({
|
|
@@ -199,7 +231,7 @@ class ContractBuilder extends ContractProcedure {
|
|
|
199
231
|
* Adds tags to all procedures in the contract router.
|
|
200
232
|
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
201
233
|
*
|
|
202
|
-
* @see {@link https://orpc.
|
|
234
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
203
235
|
*/
|
|
204
236
|
tag(...tags) {
|
|
205
237
|
return new ContractBuilder({
|
|
@@ -210,7 +242,7 @@ class ContractBuilder extends ContractProcedure {
|
|
|
210
242
|
/**
|
|
211
243
|
* Applies all of the previously defined options to the specified contract router.
|
|
212
244
|
*
|
|
213
|
-
* @see {@link https://orpc.
|
|
245
|
+
* @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs}
|
|
214
246
|
*/
|
|
215
247
|
router(router) {
|
|
216
248
|
return enhanceContractRouter(router, this["~orpc"]);
|
|
@@ -323,4 +355,4 @@ function isSchemaIssue(issue) {
|
|
|
323
355
|
return true;
|
|
324
356
|
}
|
|
325
357
|
|
|
326
|
-
export { ContractBuilder, ContractProcedure, ValidationError, enhanceContractRouter, enhanceRoute, eventIterator, fallbackContractConfig, getContractRouter, getEventIteratorSchemaDetails, inferRPCMethodFromContractRouter, isContractProcedure, isSchemaIssue, mergeErrorMap, mergeMeta, mergePrefix, mergeRoute, mergeTags, minifyContractRouter, oc, prefixRoute, type, unshiftTagRoute };
|
|
358
|
+
export { ContractBuilder, ContractProcedure, ValidationError, enhanceContractRouter, enhanceRoute, eventIterator, fallbackContractConfig, getContractRouter, getEventIteratorSchemaDetails, inferRPCMethodFromContractRouter, isContractProcedure, isSchemaIssue, mergeErrorMap, mergeMeta, mergePrefix, mergeRoute, mergeTags, minifyContractRouter, oc, populateContractRouterPaths, prefixRoute, type, unshiftTagRoute };
|
package/dist/plugins/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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';
|
|
@@ -12,7 +12,7 @@ declare class RequestValidationPluginError extends Error {
|
|
|
12
12
|
* ensuring that data sent to your server matches the expected types defined in your contract.
|
|
13
13
|
*
|
|
14
14
|
* @throws {ORPCError} with code `BAD_REQUEST` (same as server side) if input doesn't match the expected schema
|
|
15
|
-
* @see {@link https://orpc.
|
|
15
|
+
* @see {@link https://orpc.dev/docs/plugins/request-validation Request Validation Plugin Docs}
|
|
16
16
|
*/
|
|
17
17
|
declare class RequestValidationPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
18
18
|
private readonly contract;
|
|
@@ -27,7 +27,7 @@ declare class RequestValidationPlugin<T extends ClientContext> implements Standa
|
|
|
27
27
|
* - Throws `ValidationError` if output doesn't match the expected schema
|
|
28
28
|
* - Converts mismatched defined errors to normal `ORPCError` instances
|
|
29
29
|
*
|
|
30
|
-
* @see {@link https://orpc.
|
|
30
|
+
* @see {@link https://orpc.dev/docs/plugins/response-validation Response Validation Plugin Docs}
|
|
31
31
|
*/
|
|
32
32
|
declare class ResponseValidationPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
33
33
|
private readonly contract;
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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';
|
|
@@ -12,7 +12,7 @@ declare class RequestValidationPluginError extends Error {
|
|
|
12
12
|
* ensuring that data sent to your server matches the expected types defined in your contract.
|
|
13
13
|
*
|
|
14
14
|
* @throws {ORPCError} with code `BAD_REQUEST` (same as server side) if input doesn't match the expected schema
|
|
15
|
-
* @see {@link https://orpc.
|
|
15
|
+
* @see {@link https://orpc.dev/docs/plugins/request-validation Request Validation Plugin Docs}
|
|
16
16
|
*/
|
|
17
17
|
declare class RequestValidationPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
18
18
|
private readonly contract;
|
|
@@ -27,7 +27,7 @@ declare class RequestValidationPlugin<T extends ClientContext> implements Standa
|
|
|
27
27
|
* - Throws `ValidationError` if output doesn't match the expected schema
|
|
28
28
|
* - Converts mismatched defined errors to normal `ORPCError` instances
|
|
29
29
|
*
|
|
30
|
-
* @see {@link https://orpc.
|
|
30
|
+
* @see {@link https://orpc.dev/docs/plugins/response-validation Response Validation Plugin Docs}
|
|
31
31
|
*/
|
|
32
32
|
declare class ResponseValidationPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
33
33
|
private readonly contract;
|
|
@@ -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.c20c3b4",
|
|
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.c20c3b4",
|
|
35
|
+
"@orpc/shared": "0.0.0-next.c20c3b4"
|
|
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",
|