@orpc/openapi 2.0.0-beta.46 → 2.0.0-beta.48

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.
Files changed (88) hide show
  1. package/README.md +6 -4
  2. package/dist/adapters/aws-lambda/index.d.mts +14 -26
  3. package/dist/adapters/aws-lambda/index.mjs +1 -21
  4. package/dist/adapters/aws-lambda/openapi-handler.d.mts +17 -0
  5. package/dist/adapters/aws-lambda/openapi-handler.mjs +11 -0
  6. package/dist/adapters/fastify/index.d.mts +1 -23
  7. package/dist/adapters/fastify/index.mjs +1 -21
  8. package/dist/adapters/fastify/openapi-handler.d.mts +14 -0
  9. package/dist/adapters/fastify/openapi-handler.mjs +11 -0
  10. package/dist/adapters/fetch/index.d.mts +2 -37
  11. package/dist/adapters/fetch/index.mjs +2 -34
  12. package/dist/adapters/fetch/openapi-handler.d.mts +14 -0
  13. package/dist/adapters/fetch/openapi-handler.mjs +11 -0
  14. package/dist/adapters/fetch/openapi-link.d.mts +15 -0
  15. package/dist/adapters/fetch/openapi-link.mjs +11 -0
  16. package/dist/adapters/node/index.d.mts +1 -23
  17. package/dist/adapters/node/index.mjs +1 -21
  18. package/dist/adapters/node/openapi-handler.d.mts +14 -0
  19. package/dist/adapters/node/openapi-handler.mjs +11 -0
  20. package/dist/adapters/standard/index.d.mts +3 -48
  21. package/dist/adapters/standard/index.mjs +3 -12
  22. package/dist/adapters/standard/openapi-handler-codec.d.mts +61 -0
  23. package/dist/adapters/standard/openapi-handler-codec.mjs +203 -0
  24. package/dist/adapters/standard/openapi-link-codec.d.mts +53 -0
  25. package/dist/adapters/standard/openapi-link-codec.mjs +356 -0
  26. package/dist/adapters/standard/openapi-matcher.d.mts +29 -0
  27. package/dist/adapters/standard/openapi-matcher.mjs +105 -0
  28. package/dist/adapters/standard/utils.d.mts +4 -0
  29. package/dist/adapters/standard/utils.mjs +36 -0
  30. package/dist/bracket-notation.d.mts +26 -0
  31. package/dist/bracket-notation.mjs +156 -0
  32. package/dist/client-factory.d.mts +24 -0
  33. package/dist/client-factory.mjs +5 -0
  34. package/dist/constants.d.mts +4 -0
  35. package/dist/constants.mjs +4 -0
  36. package/dist/extensions/route.d.mts +74 -39
  37. package/dist/extensions/route.mjs +8 -10
  38. package/dist/helpers/form-data.d.mts +57 -0
  39. package/dist/helpers/form-data.mjs +36 -0
  40. package/dist/helpers/index.d.mts +1 -59
  41. package/dist/helpers/index.mjs +1 -39
  42. package/dist/index.d.mts +13 -159
  43. package/dist/index.mjs +11 -778
  44. package/dist/meta.d.mts +345 -0
  45. package/dist/meta.mjs +56 -0
  46. package/dist/openapi-generator-components.d.mts +24 -0
  47. package/dist/openapi-generator-components.mjs +227 -0
  48. package/dist/openapi-generator-operation.d.mts +29 -0
  49. package/dist/openapi-generator-operation.mjs +447 -0
  50. package/dist/openapi-generator.d.mts +87 -0
  51. package/dist/openapi-generator.mjs +115 -0
  52. package/dist/openapi-json-serializer.d.mts +86 -0
  53. package/dist/openapi-json-serializer.mjs +229 -0
  54. package/dist/openapi-serializer.d.mts +43 -0
  55. package/dist/openapi-serializer.mjs +87 -0
  56. package/dist/plugins/index.d.mts +1 -121
  57. package/dist/plugins/index.mjs +1 -167
  58. package/dist/plugins/openapi-reference.d.mts +118 -0
  59. package/dist/plugins/openapi-reference.mjs +157 -0
  60. package/dist/router-utils.d.mts +18 -0
  61. package/dist/router-utils.mjs +29 -0
  62. package/dist/types.d.mts +27 -0
  63. package/dist/types.mjs +1 -0
  64. package/dist/utils.d.mts +14 -0
  65. package/dist/utils.mjs +40 -0
  66. package/package.json +15 -15
  67. package/dist/adapters/aws-lambda/index.d.ts +0 -27
  68. package/dist/adapters/fastify/index.d.ts +0 -23
  69. package/dist/adapters/fetch/index.d.ts +0 -37
  70. package/dist/adapters/node/index.d.ts +0 -23
  71. package/dist/adapters/standard/index.d.ts +0 -48
  72. package/dist/extensions/route.d.ts +0 -41
  73. package/dist/helpers/index.d.ts +0 -59
  74. package/dist/index.d.ts +0 -159
  75. package/dist/plugins/index.d.ts +0 -121
  76. package/dist/shared/openapi.B9PQzqBn.mjs +0 -49
  77. package/dist/shared/openapi.BCrrWRbv.d.mts +0 -87
  78. package/dist/shared/openapi.BNe1y1cD.mjs +0 -360
  79. package/dist/shared/openapi.B_SoJfYz.d.mts +0 -328
  80. package/dist/shared/openapi.B_SoJfYz.d.ts +0 -328
  81. package/dist/shared/openapi.BkjX_6hE.d.ts +0 -87
  82. package/dist/shared/openapi.Covi8zVE.d.mts +0 -33
  83. package/dist/shared/openapi.Covi8zVE.d.ts +0 -33
  84. package/dist/shared/openapi.DXqJL3gB.mjs +0 -408
  85. package/dist/shared/openapi.DtEVcxuW.mjs +0 -149
  86. package/dist/shared/openapi.E3ZBiweM.mjs +0 -353
  87. package/dist/shared/openapi.YMRD3b4R.d.mts +0 -157
  88. package/dist/shared/openapi.YMRD3b4R.d.ts +0 -157
@@ -1,328 +0,0 @@
1
- import { AnySchema, ErrorMap, MetaPlugin, AnyProcedureContract } from '@orpc/contract';
2
- import { Lazy } from '@orpc/server';
3
- import { Value } from '@orpc/shared';
4
- import { StandardBodyHint } from '@standard-server/core';
5
- import * as OpenAPIV3_2 from '@openapi-spec/types/v3.2';
6
-
7
- interface OpenAPIMeta {
8
- /**
9
- * HTTP method accepted by this procedure.
10
- *
11
- * @default 'POST'
12
- */
13
- method?: 'HEAD' | 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'QUERY' | undefined;
14
- /**
15
- * URL path for this procedure. Supports dynamic parameters via `{param}` syntax,
16
- * and `{+param}` to allow slashes in the matched value.
17
- *
18
- * @example `/users`, `/users/{id}`, `/files/{+path}`
19
- * @default Router segments joined by `'/`
20
- */
21
- path?: `/${string}` | undefined;
22
- /**
23
- * Unique identifier for this operation in the OpenAPI spec.
24
- *
25
- * @default Router segments joined by `.`
26
- */
27
- operationId?: string | undefined;
28
- /**
29
- * Short summary of the procedure, used as the operation summary in the generated spec.
30
- */
31
- summary?: string | undefined;
32
- /**
33
- * Detailed description of the procedure, used as the operation description in the generated spec.
34
- */
35
- description?: string | undefined;
36
- /**
37
- * Marks the procedure as deprecated in the generated spec.
38
- */
39
- deprecated?: boolean | undefined;
40
- /**
41
- * Tags associated with this procedure.
42
- *
43
- * **Merging**: When defined multiple times, tags are concatenated in definition order.
44
- * Explicitly setting `undefined` resets the tags instead of merging.
45
- */
46
- tags?: string[] | undefined;
47
- /**
48
- * HTTP status code returned on success.
49
- * Should be in the `2xx` range and must be less than `400`.
50
- *
51
- * @default 200
52
- */
53
- successStatus?: number | undefined;
54
- /**
55
- * Description of the successful response.
56
- *
57
- * @default 'OK'
58
- */
59
- successDescription?: string | undefined;
60
- /**
61
- * Controls how individual path parameters are decoded.
62
- *
63
- * **Merging**: When defined multiple times, styles are merged per parameter.
64
- * The most recent style defined for a parameter wins.
65
- * Explicitly setting `undefined` resets the styles instead of merging.
66
- *
67
- * Each key maps a path parameter name to one of the following strategies:
68
- *
69
- * | Strategy | Encoded path segment | Decoded | OpenAPI Parameter Style |
70
- * |--------------------------|----------------------|------------------------------|----------------------------------|
71
- * | `primitive` *(default)* | `/users/42` | `{ id: '42' }` | `simple` |
72
- * | `comma-delimited-array` | `/users/a,b,c` | `{ id: ['a', 'b', 'c'] }` | `simple` |
73
- * | `comma-delimited-object` | `/users/a,1,b,2` | `{ id: { a: '1', b: '2' } }` | `simple` |
74
- *
75
- * **Strategy details:**
76
- *
77
- * - **`primitive`**: Keeps the decoded path segment as a string.
78
- * - **`comma-delimited-array`**: Splits the decoded path segment on `,` into an array.
79
- * - **`comma-delimited-object`**: Splits the decoded path segment on `,` into alternating key-value pairs.
80
- *
81
- * **Note**: `*-delimited-*` strategies do not support keys or values containing the delimiter character.
82
- *
83
- * @example
84
- * ```ts
85
- * // openapi.path = '/users/{id}/{tags}/{filters}'
86
- * // GET /users/42/red,blue/size,large,brand,nike
87
- *
88
- * const paramsStyles = {
89
- * id: 'primitive',
90
- * tags: 'comma-delimited-array',
91
- * filters: 'comma-delimited-object',
92
- * }
93
- *
94
- * const inputSchema = z.object({
95
- * id: z.string(),
96
- * tags: z.array(z.string()),
97
- * filters: z.object({
98
- * size: z.string(),
99
- * brand: z.string(),
100
- * }),
101
- * })
102
- * ```
103
- *
104
- * @default `primitive` for all parameters
105
- */
106
- paramsStyles?: Record<string, 'primitive' | 'comma-delimited-array' | 'comma-delimited-object' | undefined> | undefined;
107
- /**
108
- * Controls how individual query parameters are encoding/decoding.
109
- *
110
- * **Merging**: When defined multiple times, styles are merged per parameter.
111
- * The most recent style defined for a parameter wins.
112
- * Explicitly setting `undefined` resets the styles instead of merging.
113
- *
114
- * Each key maps a query parameter name to one of the following strategies:
115
- *
116
- * | Strategy | Encoded | Decoded | OpenAPI Parameter Style |
117
- * |--------------------------|---------------------------|--------------------------------|------------------------------------|
118
- * | `primitive` | `?a=1&a=2` | `{ a: '2' }` | `form` / `explode: false` |
119
- * | `array` | `?a=1&a=2` | `{ a: ['1', '2'] }` | `form` / `explode: true` |
120
- * | `comma-delimited-array` | `?a=1,2,3` | `{ a: ['1', '2', '3'] }` | `form` / `explode: false` |
121
- * | `comma-delimited-object` | `?a=A,1,B,2` | `{ a: { A: '1', B: '2' } }` | `form` / `explode: false` |
122
- * | `space-delimited-array` | `?a=1 2 3` | `{ a: ['1', '2', '3'] }` | `spaceDelimited` / `explode: false`|
123
- * | `space-delimited-object` | `?a=A 1 B 2` | `{ a: { A: '1', B: '2' } }` | `spaceDelimited` / `explode: false`|
124
- * | `pipe-delimited-array` | `?a=1\|2\|3` | `{ a: ['1', '2', '3'] }` | `pipeDelimited` / `explode: false` |
125
- * | `pipe-delimited-object` | `?a=A\|1\|B\|2` | `{ a: { A: '1', B: '2' } }` | `pipeDelimited` / `explode: false` |
126
- * | `json` | `?meta={"key":"value"}` | `{ meta: { key: 'value' } }` | `content: application/json` |
127
- * | _default_ | `?a[]=1&a[]=2&b=3&c[d]=4` | `{a:['1', '2'], b:3, c:{d:4}}` | `deepObject` / `explode: true` |
128
- *
129
- * **Strategy details:**
130
- *
131
- * - **`primitive`**: Takes the last occurrence of a repeated parameter.
132
- * - **`array`**: Always produces an array, even for a single occurrence.
133
- * - **`*-delimited-array`**: Splits the last value on the delimiter (`,`, space, or `|`) into an array.
134
- * - **`*-delimited-object`**: Splits the last value on the delimiter into alternating key–value pairs.
135
- * - **`json`**: Parses the last value as JSON; falls back to the raw string if parsing fails.
136
- * - **`undefined`**: Standard bracket-notation decoding This is the default.
137
- *
138
- * **Note**: `*-delimited-*` strategies do not support keys or values containing the delimiter character.
139
- *
140
- * @example
141
- * ```ts
142
- * // GET /search?keyword=abc&tags=a,b,c&meta={"key":"value"}
143
- * const queryParsing = {
144
- * keyword: 'primitive',
145
- * tags: 'comma-delimited-array',
146
- * meta: 'json',
147
- * }
148
- *
149
- * const inputSchema = z.object({
150
- * keyword: z.string(),
151
- * tags: z.array(z.string()),
152
- * meta: z.object({ key: z.string() }),
153
- * })
154
- * ```
155
- *
156
- * @default `undefined` for all parameters (bracket-notation decoding)
157
- */
158
- queryStyles?: Record<string, 'primitive' | 'array' | 'comma-delimited-array' | 'comma-delimited-object' | 'space-delimited-array' | 'space-delimited-object' | 'pipe-delimited-array' | 'pipe-delimited-object' | 'json' | undefined> | undefined;
159
- /**
160
- * Hint for how to parse the incoming request body.
161
- *
162
- * Note: The `standard-server` `Content-Type` header takes priority over this option.
163
- * `form-data` and `url-search-params` are decoded using bracket notation,
164
- * so the resulting value will be an object or array.
165
- *
166
- * @default Inferred from `Content-Type`, `Content-Disposition`, and `Content-Length`
167
- */
168
- requestBodyHint?: StandardBodyHint | undefined;
169
- /**
170
- * Hint for how to parse the response body.
171
- *
172
- * Note: The `standard-server` `Content-Type` header takes priority over this option.
173
- * `form-data` and `url-search-params` are decoded using bracket notation,
174
- * so the resulting value will be an object or array.
175
- *
176
- * @default Inferred from `Content-Type`, `Content-Disposition`, and `Content-Length`
177
- */
178
- responseBodyHint?: StandardBodyHint | undefined;
179
- /**
180
- * Determines how the input should be structured
181
- * based on params, query, headers, and body.
182
- *
183
- * - `compact` — Merges params with either query or body
184
- * (depending on the HTTP method) into a single flat object.
185
- * Use this when you don't need access to headers and your
186
- * param/query/body keys don't conflict.
187
- *
188
- * ```ts
189
- * // GET /users/42?search=hello
190
- * const inputValue = { id: 42, search: 'hello' }
191
- *
192
- * const inputSchema = z.object({
193
- * id: z.coerce.number(), // from params
194
- * search: z.string(), // from query
195
- * })
196
- * ```
197
- *
198
- * - `detailed` — Keeps each part of the request as a
199
- * separate nested field. Use this when you need access
200
- * to headers, or when params and query/body keys
201
- * might conflict.
202
- *
203
- * ```ts
204
- * const inputValue = {
205
- * params: { id: 1 },
206
- * query: { search: 'hello' },
207
- * headers: { 'content-type': 'application/json' },
208
- * body: 'body value',
209
- * }
210
- *
211
- * const inputSchema = z.object({
212
- * params: z.object({ id: z.coerce.number() }),
213
- * query: z.object({ search: z.string() }),
214
- * headers: z.object({ 'content-type': z.string() }),
215
- * body: z.string(),
216
- * })
217
- * ```
218
- *
219
- * @default 'compact'
220
- */
221
- inputStructure?: 'compact' | 'detailed' | undefined;
222
- /**
223
- * Determines how the output should be structured
224
- * into the HTTP response.
225
- *
226
- * - `compact` — The return value is sent directly as the
227
- * response body. Status code comes from successStatus.
228
- *
229
- * ```ts
230
- * const outputValue = { id: 1, name: 'Alice' }
231
- *
232
- * const outputSchema = z.object({
233
- * id: z.number(),
234
- * name: z.string(),
235
- * })
236
- * ```
237
- *
238
- * - `detailed` — Return an object with optional properties:
239
- * - status: HTTP status code (200–399). Defaults to
240
- * successStatus if omitted. Use a literal type
241
- * (e.g. z.literal(201)) so the generated spec can reflects
242
- * the exact code.
243
- * - headers: Custom headers to merge into the response
244
- * (Record<string, string | string[] | undefined>).
245
- * - body: The response body.
246
- *
247
- * ```ts
248
- * const outputValue = {
249
- * status: 201,
250
- * headers: { 'x-custom-header': 'value' },
251
- * body: 'body value',
252
- * }
253
- *
254
- * const outputSchema = z.object({
255
- * status: z.literal(201).meta({ description: 'Record Created' }),
256
- * headers: z.object({ 'x-custom-header': z.string() }),
257
- * body: z.string(),
258
- * })
259
- * ```
260
- *
261
- * @default 'compact'
262
- */
263
- outputStructure?: 'compact' | 'detailed' | undefined;
264
- /**
265
- * Override or extend the generated OpenAPI operation object for this procedure.
266
- *
267
- * Pass a plain object to replace entire operation object, or a function that receives the current
268
- * operation object and returns the modified version.
269
- *
270
- * The operation object always follows OpenAPI 3.2, `OpenAPIGenerator` downgrades it with the
271
- * rest of the document when an older version is requested.
272
- *
273
- * **Merging**: When defined multiple times:
274
- *
275
- * - Two functions are chained: the most recent function receives the result of the previous one.
276
- * - A function combined with an object: the function is applied to that object.
277
- * - Two objects: the most recent object wins.
278
- *
279
- * Explicitly setting `undefined` resets the spec instead of merging.
280
- */
281
- spec?: Value<OpenAPIV3_2.OperationObject, [current: OpenAPIV3_2.OperationObject]> | undefined;
282
- /**
283
- * Prefix for the path. Useful when you want to apply a common path prefix across multiple procedures.
284
- *
285
- * **Merging**: When defined multiple times, prefixes are concatenated in definition order.
286
- * Explicitly setting `undefined` resets the prefix instead of merging.
287
- */
288
- prefix?: `/${string}` | undefined;
289
- }
290
- interface OpenAPIMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
291
- name: '~openapi';
292
- }
293
- interface OpenAPIMethodMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
294
- name: '~openapi/method';
295
- }
296
- interface OpenAPIPathMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
297
- name: '~openapi/path';
298
- }
299
- interface OpenAPISpecMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
300
- name: '~openapi/spec';
301
- }
302
- interface OpenAPIPrefixMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
303
- name: '~openapi/prefix';
304
- }
305
- interface OpenAPIFunction {
306
- (meta: OpenAPIMeta): OpenAPIMetaPlugin<any, any, any>;
307
- method(method: OpenAPIMeta['method']): OpenAPIMethodMetaPlugin<any, any, any>;
308
- path(method: OpenAPIMeta['path']): OpenAPIPathMetaPlugin<any, any, any>;
309
- spec(method: OpenAPIMeta['spec']): OpenAPISpecMetaPlugin<any, any, any>;
310
- prefix(method: OpenAPIMeta['prefix']): OpenAPIPrefixMetaPlugin<any, any, any>;
311
- }
312
- /**
313
- * Creates OpenAPI meta plugins that control how a procedure is exposed over HTTP,
314
- * such as its method, path, prefix, and OpenAPI operation spec.
315
- *
316
- * @see {@link https://orpc.dev/docs/openapi/routing | OpenAPI Routing}
317
- * @see {@link https://orpc.dev/docs/openapi/specification | OpenAPI Specification}
318
- */
319
- declare const openapi: OpenAPIFunction;
320
- /**
321
- * Retrieves the OpenAPI metadata attached to a procedure or router, or `undefined` if not set.
322
- *
323
- * @see {@link https://orpc.dev/docs/rpc/handler#enabling-the-get-method | RPC Handler - Enabling the GET Method}
324
- */
325
- declare function getOpenAPIMeta(procedureOrLazy: AnyProcedureContract | Lazy<any>): OpenAPIMeta | undefined;
326
-
327
- export { getOpenAPIMeta as g, openapi as o };
328
- export type { OpenAPIMeta as O, OpenAPIFunction as a, OpenAPIMetaPlugin as b, OpenAPIMethodMetaPlugin as c, OpenAPIPathMetaPlugin as d, OpenAPIPrefixMetaPlugin as e, OpenAPISpecMetaPlugin as f };
@@ -1,87 +0,0 @@
1
- import { AnyORPCError } from '@orpc/client';
2
- import { AnyProcedure, AnyRouter, Context } from '@orpc/server';
3
- import { StandardHandlerCodec, ResolvedStandardHandlerHandleOptions, StandardHandlerCodecResolvedProcedure } from '@orpc/server/standard';
4
- import { Value, Public, Promisable } from '@orpc/shared';
5
- import { StandardLazyRequest, StandardResponse } from '@standard-server/core';
6
- import { AnyProcedureContract } from '@orpc/contract';
7
- import { O as OpenAPISerializer } from './openapi.YMRD3b4R.js';
8
-
9
- interface OpenAPIMatcherOptions {
10
- /**
11
- * Filter which procedures are exposed for matching. Return `false` to exclude.
12
- *
13
- * @default true
14
- */
15
- filter?: Value<boolean, [contract: AnyProcedureContract | AnyProcedure, path: string[]]> | undefined;
16
- }
17
- declare class OpenAPIMatcher {
18
- private readonly filter;
19
- private readonly rootRouter;
20
- private readonly tree;
21
- private readonly pendingLazyRouters;
22
- constructor(router: AnyRouter, options?: OpenAPIMatcherOptions);
23
- private index;
24
- match(method: string, pathname: `/${string}`, prefix: `/${string}` | undefined): Promise<{
25
- path: string[];
26
- procedure: AnyProcedure;
27
- params?: Record<string, string> | undefined;
28
- } | undefined>;
29
- private findMatch;
30
- private resolvePendingLazyRouters;
31
- private loadPendingLazyRouters;
32
- private loadPendingLazyRouter;
33
- private indexPendingLazyRouter;
34
- private resolveProcedure;
35
- }
36
-
37
- interface OpenAPIHandlerCodecCoreOptions<_T extends Context> {
38
- /**
39
- * Override the default OpenAPI serializer.
40
- */
41
- serializer?: Public<OpenAPISerializer> | undefined;
42
- /**
43
- * Mapping ORPCError Code -> HTTP Status Code
44
- * The status code should be in the `4xx` or `5xx` range (must be greater than or equal to `400`).
45
- * Codes missing from the map fall back to `DEFAULT_ERROR_STATUS` (400).
46
- *
47
- * @default COMMON_ERROR_STATUS_MAP
48
- */
49
- errorStatusMap?: Record<string, number> | undefined;
50
- /**
51
- * Customize how an ORPC error is serialized into a response body.
52
- * Use this if your API needs a different error output structure.
53
- *
54
- * @remarks
55
- * - Return `null | undefined` to fallback to default behavior
56
- *
57
- * @default ((e) => e.toJSON())
58
- */
59
- customErrorResponseBodyEncoder?: ((error: AnyORPCError) => unknown) | undefined;
60
- }
61
- declare class OpenAPIHandlerCodecCore<T extends Context> {
62
- private readonly serializer;
63
- private readonly errorStatusMap;
64
- private readonly customErrorResponseBodySerializer;
65
- constructor(options?: OpenAPIHandlerCodecCoreOptions<T>);
66
- decodeInput(matched: {
67
- procedure: AnyProcedure;
68
- params?: Record<string, string> | undefined;
69
- }, request: StandardLazyRequest): Promise<unknown>;
70
- /**
71
- * @throws {TypeError} If `outputStructure` is "detailed" and the output doesn't match the expected structure.
72
- */
73
- encodeOutput(output: unknown, procedure: AnyProcedure, path: string[]): Promisable<StandardResponse>;
74
- encodeError(error: AnyORPCError): Promisable<StandardResponse>;
75
- private deserializeQuery;
76
- private deserializeParams;
77
- }
78
- interface OpenAPIHandlerCodecOptions<T extends Context> extends OpenAPIHandlerCodecCoreOptions<T>, OpenAPIMatcherOptions {
79
- }
80
- declare class OpenAPIHandlerCodec<T extends Context> extends OpenAPIHandlerCodecCore<T> implements StandardHandlerCodec<T> {
81
- private readonly matcher;
82
- constructor(router: AnyRouter, options?: OpenAPIHandlerCodecOptions<T>);
83
- resolveProcedure(request: StandardLazyRequest, options: ResolvedStandardHandlerHandleOptions<T>): Promise<StandardHandlerCodecResolvedProcedure | undefined>;
84
- }
85
-
86
- export { OpenAPIHandlerCodec as a, OpenAPIHandlerCodecCore as b, OpenAPIMatcher as d };
87
- export type { OpenAPIHandlerCodecOptions as O, OpenAPIHandlerCodecCoreOptions as c, OpenAPIMatcherOptions as e };
@@ -1,33 +0,0 @@
1
- import * as OpenAPIV3_0 from '@openapi-spec/types/v3.0';
2
- import * as OpenAPIV3_1 from '@openapi-spec/types/v3.1';
3
- import * as OpenAPIV3_2 from '@openapi-spec/types/v3.2';
4
- import { AnyNestedClient, Client, ORPCError } from '@orpc/client';
5
- import { AsyncIteratorClass } from '@orpc/shared';
6
-
7
- /**
8
- * An OpenAPI version `OpenAPIGenerator` can target: any `3.0.x`, `3.1.x`, or `3.2.x` value.
9
- *
10
- * @see {@link https://orpc.dev/docs/openapi/specification#openapi-version | OpenAPI Specification - OpenAPI Version}
11
- */
12
- type OpenAPIVersion = `3.0.${number}` | `3.1.${number}` | `3.2.${number}`;
13
- /**
14
- * The OpenAPI document of the given version.
15
- *
16
- * @see {@link https://orpc.dev/docs/openapi/specification#openapi-version | OpenAPI Specification - OpenAPI Version}
17
- */
18
- type OpenAPIDocument<TVersion extends OpenAPIVersion> = TVersion extends `3.0.${string}` ? OpenAPIV3_0.OpenAPIObject : TVersion extends `3.1.${string}` ? OpenAPIV3_1.OpenAPIObject : OpenAPIV3_2.OpenAPIObject;
19
- type JsonifiedValue<T> = T extends string | number | boolean | null | undefined ? T : T extends Date | bigint | URL ? string : T extends ReadonlyArray<unknown> ? JsonifiedArray<T> : T extends Blob | ReadonlyMap<any, any> | ReadonlySet<any> | AsyncIteratorObject<any, any, any> | Function ? T extends File ? File : T extends Blob ? Blob : T extends ReadonlyMap<infer K, infer V> ? JsonifiedArray<[K, V][]> : T extends ReadonlySet<infer U> ? JsonifiedArray<U[]> : T extends AsyncIteratorClass<infer U, infer V> ? AsyncIteratorClass<JsonifiedValue<U>, JsonifiedValue<V>> : T extends AsyncGenerator<infer U, infer V> ? AsyncGenerator<JsonifiedValue<U>, JsonifiedValue<V>> : T extends AsyncIteratorObject<infer U, infer V> ? AsyncIteratorObject<JsonifiedValue<U>, JsonifiedValue<V>> : unknown : T extends object ? {
20
- [K in keyof T]: JsonifiedValue<T[K]>;
21
- } : unknown;
22
- type JsonifiedArray<T extends ReadonlyArray<unknown>> = T extends readonly [] ? [] : T extends readonly [infer U, ...infer V] ? [U extends undefined ? null : JsonifiedValue<U>, ...JsonifiedArray<V>] : T extends ReadonlyArray<infer U> ? Array<JsonifiedValue<U>> : unknown;
23
- type JsonifiedClientError<T> = T extends ORPCError<infer UCode, infer UData> ? ORPCError<UCode, JsonifiedValue<UData>> : T;
24
- /**
25
- * Client type whose outputs and error data replace types JSON cannot represent with their JSON equivalents.
26
- *
27
- * @see {@link https://orpc.dev/docs/openapi/link | OpenAPI Link}
28
- */
29
- type JsonifiedClient<T extends AnyNestedClient> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? Client<UClientContext, UInput, JsonifiedValue<UOutput>, JsonifiedClientError<UError>> : {
30
- [K in keyof T]: T[K] extends AnyNestedClient ? JsonifiedClient<T[K]> : T[K];
31
- };
32
-
33
- export type { JsonifiedClient as J, OpenAPIDocument as O, OpenAPIVersion as a, JsonifiedArray as b, JsonifiedClientError as c, JsonifiedValue as d };
@@ -1,33 +0,0 @@
1
- import * as OpenAPIV3_0 from '@openapi-spec/types/v3.0';
2
- import * as OpenAPIV3_1 from '@openapi-spec/types/v3.1';
3
- import * as OpenAPIV3_2 from '@openapi-spec/types/v3.2';
4
- import { AnyNestedClient, Client, ORPCError } from '@orpc/client';
5
- import { AsyncIteratorClass } from '@orpc/shared';
6
-
7
- /**
8
- * An OpenAPI version `OpenAPIGenerator` can target: any `3.0.x`, `3.1.x`, or `3.2.x` value.
9
- *
10
- * @see {@link https://orpc.dev/docs/openapi/specification#openapi-version | OpenAPI Specification - OpenAPI Version}
11
- */
12
- type OpenAPIVersion = `3.0.${number}` | `3.1.${number}` | `3.2.${number}`;
13
- /**
14
- * The OpenAPI document of the given version.
15
- *
16
- * @see {@link https://orpc.dev/docs/openapi/specification#openapi-version | OpenAPI Specification - OpenAPI Version}
17
- */
18
- type OpenAPIDocument<TVersion extends OpenAPIVersion> = TVersion extends `3.0.${string}` ? OpenAPIV3_0.OpenAPIObject : TVersion extends `3.1.${string}` ? OpenAPIV3_1.OpenAPIObject : OpenAPIV3_2.OpenAPIObject;
19
- type JsonifiedValue<T> = T extends string | number | boolean | null | undefined ? T : T extends Date | bigint | URL ? string : T extends ReadonlyArray<unknown> ? JsonifiedArray<T> : T extends Blob | ReadonlyMap<any, any> | ReadonlySet<any> | AsyncIteratorObject<any, any, any> | Function ? T extends File ? File : T extends Blob ? Blob : T extends ReadonlyMap<infer K, infer V> ? JsonifiedArray<[K, V][]> : T extends ReadonlySet<infer U> ? JsonifiedArray<U[]> : T extends AsyncIteratorClass<infer U, infer V> ? AsyncIteratorClass<JsonifiedValue<U>, JsonifiedValue<V>> : T extends AsyncGenerator<infer U, infer V> ? AsyncGenerator<JsonifiedValue<U>, JsonifiedValue<V>> : T extends AsyncIteratorObject<infer U, infer V> ? AsyncIteratorObject<JsonifiedValue<U>, JsonifiedValue<V>> : unknown : T extends object ? {
20
- [K in keyof T]: JsonifiedValue<T[K]>;
21
- } : unknown;
22
- type JsonifiedArray<T extends ReadonlyArray<unknown>> = T extends readonly [] ? [] : T extends readonly [infer U, ...infer V] ? [U extends undefined ? null : JsonifiedValue<U>, ...JsonifiedArray<V>] : T extends ReadonlyArray<infer U> ? Array<JsonifiedValue<U>> : unknown;
23
- type JsonifiedClientError<T> = T extends ORPCError<infer UCode, infer UData> ? ORPCError<UCode, JsonifiedValue<UData>> : T;
24
- /**
25
- * Client type whose outputs and error data replace types JSON cannot represent with their JSON equivalents.
26
- *
27
- * @see {@link https://orpc.dev/docs/openapi/link | OpenAPI Link}
28
- */
29
- type JsonifiedClient<T extends AnyNestedClient> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? Client<UClientContext, UInput, JsonifiedValue<UOutput>, JsonifiedClientError<UError>> : {
30
- [K in keyof T]: T[K] extends AnyNestedClient ? JsonifiedClient<T[K]> : T[K];
31
- };
32
-
33
- export type { JsonifiedClient as J, OpenAPIDocument as O, OpenAPIVersion as a, JsonifiedArray as b, JsonifiedClientError as c, JsonifiedValue as d };