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