@orpc/contract 0.0.0-next.dbce934 → 0.0.0-next.dc2afcb
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 +11 -8
- package/dist/index.d.mts +65 -44
- package/dist/index.d.ts +65 -44
- package/dist/index.mjs +47 -14
- 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 +9 -10
package/README.md
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
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>
|
|
6
6
|
|
|
7
7
|
<div align="center">
|
|
8
|
-
<a href="https://codecov.io/gh/
|
|
9
|
-
<img alt="codecov" src="https://codecov.io/gh/
|
|
8
|
+
<a href="https://codecov.io/gh/middleapi/orpc">
|
|
9
|
+
<img alt="codecov" src="https://codecov.io/gh/middleapi/orpc/branch/main/graph/badge.svg">
|
|
10
10
|
</a>
|
|
11
11
|
<a href="https://www.npmjs.com/package/@orpc/contract">
|
|
12
12
|
<img alt="weekly downloads" src="https://img.shields.io/npm/dw/%40orpc%2Fcontract?logo=npm" />
|
|
13
13
|
</a>
|
|
14
|
-
<a href="https://github.com/
|
|
15
|
-
<img alt="MIT License" src="https://img.shields.io/github/license/
|
|
14
|
+
<a href="https://github.com/middleapi/orpc/blob/main/LICENSE">
|
|
15
|
+
<img alt="MIT License" src="https://img.shields.io/github/license/middleapi/orpc?logo=open-source-initiative" />
|
|
16
16
|
</a>
|
|
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/middleapi/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({
|
|
@@ -108,4 +111,4 @@ export const contract = {
|
|
|
108
111
|
|
|
109
112
|
## License
|
|
110
113
|
|
|
111
|
-
Distributed under the MIT License. See [LICENSE](https://github.com/
|
|
114
|
+
Distributed under the MIT License. See [LICENSE](https://github.com/middleapi/orpc/blob/main/LICENSE) for more information.
|
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,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 };
|