@orpc/openapi 2.0.0-beta.44 → 2.0.0-beta.45

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 (33) hide show
  1. package/README.md +55 -48
  2. package/dist/adapters/aws-lambda/index.d.mts +1 -1
  3. package/dist/adapters/aws-lambda/index.d.ts +1 -1
  4. package/dist/adapters/aws-lambda/index.mjs +2 -2
  5. package/dist/adapters/fastify/index.d.mts +1 -1
  6. package/dist/adapters/fastify/index.d.ts +1 -1
  7. package/dist/adapters/fastify/index.mjs +2 -2
  8. package/dist/adapters/fetch/index.d.mts +1 -1
  9. package/dist/adapters/fetch/index.d.ts +1 -1
  10. package/dist/adapters/fetch/index.mjs +3 -3
  11. package/dist/adapters/node/index.d.mts +1 -1
  12. package/dist/adapters/node/index.d.ts +1 -1
  13. package/dist/adapters/node/index.mjs +2 -2
  14. package/dist/adapters/standard/index.d.mts +5 -5
  15. package/dist/adapters/standard/index.d.ts +5 -5
  16. package/dist/adapters/standard/index.mjs +3 -3
  17. package/dist/index.d.mts +11 -10
  18. package/dist/index.d.ts +11 -10
  19. package/dist/index.mjs +15 -36
  20. package/dist/plugins/index.d.mts +12 -12
  21. package/dist/plugins/index.d.ts +12 -12
  22. package/dist/shared/{openapi.BSLqRCwO.d.mts → openapi.B8v9IrIK.d.mts} +6 -5
  23. package/dist/shared/{openapi.DdjvA5Xo.mjs → openapi.BNe1y1cD.mjs} +9 -4
  24. package/dist/shared/{openapi.r98bZ3Ig.d.ts → openapi.B_SoJfYz.d.mts} +1 -1
  25. package/dist/shared/{openapi.r98bZ3Ig.d.mts → openapi.B_SoJfYz.d.ts} +1 -1
  26. package/dist/shared/{openapi.aoP0G_Bv.d.ts → openapi.C1MLxqih.d.ts} +5 -5
  27. package/dist/shared/{openapi.BVt3NPfo.d.mts → openapi.CCZPbgOq.d.mts} +5 -5
  28. package/dist/shared/{openapi.1UQkZGBs.d.ts → openapi.C_r_fZl2.d.ts} +6 -5
  29. package/dist/shared/{openapi.DjGhiceP.d.mts → openapi.D42Ps1fQ.d.mts} +9 -10
  30. package/dist/shared/{openapi.DjGhiceP.d.ts → openapi.D42Ps1fQ.d.ts} +9 -10
  31. package/dist/shared/{openapi.DjMM672U.mjs → openapi.DXqJL3gB.mjs} +4 -10
  32. package/dist/shared/{openapi.PXVenYpE.mjs → openapi.E3ZBiweM.mjs} +12 -13
  33. package/package.json +13 -13
package/dist/index.mjs CHANGED
@@ -1,14 +1,14 @@
1
1
  export { B as BracketNotationSerializer } from './shared/openapi.DtEVcxuW.mjs';
2
- import { createContractClientFactory, getAsyncIteratorObjectSchemaDetails, ProcedureContract, resolveMetaPlugins } from '@orpc/contract';
3
- import { D as DEFAULT_OPENAPI_METHOD, a as DEFAULT_OPENAPI_INPUT_STRUCTURE, c as DEFAULT_OPENAPI_SUCCESS_DESCRIPTION, b as DEFAULT_OPENAPI_OUTPUT_STRUCTURE, i as isBodylessMethod, O as OpenAPISerializer, g as getDynamicPathParams } from './shared/openapi.PXVenYpE.mjs';
4
- export { d as OpenAPIJsonSerializer } from './shared/openapi.PXVenYpE.mjs';
2
+ import { createContractClientFactory, getAsyncIteratorObjectSchemasDetails, ProcedureContract, resolveMetaPlugins } from '@orpc/contract';
3
+ import { D as DEFAULT_OPENAPI_METHOD, a as DEFAULT_OPENAPI_INPUT_STRUCTURE, c as DEFAULT_OPENAPI_SUCCESS_DESCRIPTION, b as DEFAULT_OPENAPI_OUTPUT_STRUCTURE, i as isBodylessMethod, d as OpenAPIJsonSerializer, g as getDynamicPathParams } from './shared/openapi.E3ZBiweM.mjs';
4
+ export { O as OpenAPISerializer } from './shared/openapi.E3ZBiweM.mjs';
5
5
  import { g as getOpenAPIMeta, o as openapi } from './shared/openapi.B9PQzqBn.mjs';
6
6
  import { downgradeSpecV32ToV31, downgradeSpecV31ToV30 } from '@openapi-spec/downgrader';
7
7
  import { COMMON_ERROR_STATUS_MAP } from '@orpc/client';
8
8
  export { COMMON_ERROR_STATUS_MAP } from '@orpc/client';
9
- import { encodeJsonPointerSegment, ensureJsonSchemaObject, mapJsonSchemaRefs, decodeJsonPointerSegment, isUnconstrainedSchema, combineJsonSchemasWithComposition, extractJsonObjectSchemaEntries, combineJsonObjectSchemaEntries, flattenJsonUnionSchema, isJsonPrimitiveSchema, matchArrayableJsonSchema, isJsonFileSchema, DelegatingJsonSchemaConverter, StandardJsonSchemaConverter, hoistRecursiveRefToDef } from '@orpc/json-schema';
9
+ import { encodeJsonPointerSegment, ensureJsonSchemaObject, mapJsonSchemaRefs, decodeJsonPointerSegment, isUnconstrainedSchema, combineJsonSchemasWithComposition, extractJsonObjectSchemaEntries, combineJsonObjectSchemaEntries, flattenJsonUnionSchema, isJsonPrimitiveSchema, matchArrayableJsonSchema, isJsonFileSchema, containsJsonFileSchema, DelegatingJsonSchemaConverter, StandardJsonSchemaConverter, hoistRecursiveRefToDef } from '@orpc/json-schema';
10
10
  import { DEFAULT_SUCCESS_STATUS, DEFAULT_ERROR_STATUS, walkProcedureContractsAsync } from '@orpc/server';
11
- import { setOwn, getOwn, isDeepEqual, isPlainObject, value, findDeepMatches, stringifyJSON, toArray, clone, pathToHttpPath, mergeHttpPath, isTypescriptObject } from '@orpc/shared';
11
+ import { setOwn, getOwn, isDeepEqual, isPlainObject, value, stringifyJSON, toArray, clone, pathToHttpPath, mergeHttpPath, isTypescriptObject } from '@orpc/shared';
12
12
  import '@standard-server/core';
13
13
 
14
14
  function createContractJsonifiedClientFactory(link, options = {}) {
@@ -233,15 +233,15 @@ function buildRequest(ctx, operation, def, meta, dynamicPathParams) {
233
233
  const method = meta?.method ?? DEFAULT_OPENAPI_METHOD;
234
234
  const inputStructure = meta?.inputStructure ?? DEFAULT_OPENAPI_INPUT_STRUCTURE;
235
235
  if (inputStructure === "compact") {
236
- const iteratorDetails = getAsyncIteratorObjectDetails(def.inputSchemas);
236
+ const iteratorDetails = getAsyncIteratorObjectSchemasDetails(def.inputSchemas);
237
237
  if (iteratorDetails) {
238
238
  operation.requestBody = {
239
239
  required: true,
240
240
  content: toAsyncIteratorObjectContent(
241
241
  ctx,
242
242
  "input",
243
- ctx.convertSchemas(iteratorDetails[0], "input"),
244
- ctx.convertSchemas(iteratorDetails[1], "input")
243
+ ctx.convertSchemas(iteratorDetails.yieldSchemas, "input"),
244
+ ctx.convertSchemas(iteratorDetails.returnSchemas, "input")
245
245
  )
246
246
  };
247
247
  return;
@@ -395,7 +395,7 @@ function buildSuccessResponse(ctx, operation, def, meta) {
395
395
  const description = meta?.successDescription ?? DEFAULT_OPENAPI_SUCCESS_DESCRIPTION;
396
396
  const outputStructure = meta?.outputStructure ?? DEFAULT_OPENAPI_OUTPUT_STRUCTURE;
397
397
  if (outputStructure === "compact") {
398
- const iteratorDetails = getAsyncIteratorObjectDetails(def.outputSchemas);
398
+ const iteratorDetails = getAsyncIteratorObjectSchemasDetails(def.outputSchemas);
399
399
  if (iteratorDetails) {
400
400
  operation.responses ??= {};
401
401
  operation.responses[toResponseStatusKey(status)] = {
@@ -403,8 +403,8 @@ function buildSuccessResponse(ctx, operation, def, meta) {
403
403
  content: toAsyncIteratorObjectContent(
404
404
  ctx,
405
405
  "output",
406
- ctx.convertSchemas(iteratorDetails[0], "output"),
407
- ctx.convertSchemas(iteratorDetails[1], "output")
406
+ ctx.convertSchemas(iteratorDetails.yieldSchemas, "output"),
407
+ ctx.convertSchemas(iteratorDetails.returnSchemas, "output")
408
408
  )
409
409
  };
410
410
  return;
@@ -574,24 +574,6 @@ function toErrorComponentName(code) {
574
574
  }).join("");
575
575
  return name || "Error";
576
576
  }
577
- function getAsyncIteratorObjectDetails(schemas) {
578
- if (!schemas || schemas.length === 0) {
579
- return void 0;
580
- }
581
- const yieldSchemas = [];
582
- const returnSchemas = [];
583
- for (const s of schemas) {
584
- const details = getAsyncIteratorObjectSchemaDetails(s);
585
- if (!details) {
586
- return void 0;
587
- }
588
- yieldSchemas.push(details.yieldSchema);
589
- if (details.returnSchema) {
590
- returnSchemas.push(details.returnSchema);
591
- }
592
- }
593
- return [yieldSchemas, returnSchemas];
594
- }
595
577
  function toAsyncIteratorObjectContent(ctx, direction, [yieldSchema, yieldOptional], [returnSchema, returnOptional]) {
596
578
  const schema = combineJsonSchemasWithComposition("oneOf", [
597
579
  combineJsonObjectSchemaEntries([
@@ -641,10 +623,7 @@ function toBodyContent(ctx, direction, schema) {
641
623
  const content = {};
642
624
  if (rest.length > 0) {
643
625
  const restSchema = fileSchemasByMediaType.size ? combineJsonSchemasWithComposition("anyOf", rest) : schema;
644
- const hasNestedFiles = findDeepMatches(
645
- (v) => isPlainObject(v) && isJsonFileSchema(v),
646
- restSchema
647
- ).values.length > 0;
626
+ const hasNestedFiles = containsJsonFileSchema(restSchema);
648
627
  const contentType = hasNestedFiles ? "multipart/form-data" : "application/json";
649
628
  const fileSchemas = fileSchemasByMediaType.get(contentType);
650
629
  fileSchemasByMediaType.delete(contentType);
@@ -664,7 +643,7 @@ class OpenAPIGenerator {
664
643
  serializer;
665
644
  converter;
666
645
  constructor(options = {}) {
667
- this.serializer = options.serializer ?? new OpenAPISerializer();
646
+ this.serializer = options.serializer ?? new OpenAPIJsonSerializer();
668
647
  this.converter = new DelegatingJsonSchemaConverter([
669
648
  ...toArray(options.converters),
670
649
  new StandardJsonSchemaConverter()
@@ -737,7 +716,7 @@ ${errors.join("\n\n")}`
737
716
  );
738
717
  }
739
718
  const versioned = toVersionedOpenAPIDocument(doc, version);
740
- return this.serializer.serialize(versioned, { asFormData: false, useFormDataForBlobFields: false });
719
+ return this.serializer.serializeJson(versioned).json;
741
720
  }
742
721
  convertSchema(schema, direction) {
743
722
  const [jsonSchema, optional] = this.converter.convert(schema, direction);
@@ -796,4 +775,4 @@ function populateRouterContractOpenAPIPaths(router, options = {}) {
796
775
  return populated;
797
776
  }
798
777
 
799
- export { DEFAULT_OPENAPI_INPUT_STRUCTURE, DEFAULT_OPENAPI_METHOD, DEFAULT_OPENAPI_OUTPUT_STRUCTURE, DEFAULT_OPENAPI_SUCCESS_DESCRIPTION, OpenAPIGenerator, OpenAPIGeneratorError, OpenAPISerializer, createContractJsonifiedClientFactory, getDynamicPathParams, getOpenAPIMeta, isBodylessMethod, openapi, populateRouterContractOpenAPIPaths };
778
+ export { DEFAULT_OPENAPI_INPUT_STRUCTURE, DEFAULT_OPENAPI_METHOD, DEFAULT_OPENAPI_OUTPUT_STRUCTURE, DEFAULT_OPENAPI_SUCCESS_DESCRIPTION, OpenAPIGenerator, OpenAPIGeneratorError, OpenAPIJsonSerializer, createContractJsonifiedClientFactory, getDynamicPathParams, getOpenAPIMeta, isBodylessMethod, openapi, populateRouterContractOpenAPIPaths };
@@ -14,21 +14,21 @@ type OpenAPIReferenceHandlerPluginProvider = 'scalar' | 'swagger';
14
14
  interface OpenAPIReferenceHandlerPluginScalarConfig extends Partial<ApiReferenceConfiguration> {
15
15
  }
16
16
  interface OpenAPIReferenceHandlerPluginSwaggerConfig extends Partial<Omit<SwaggerUIOptions, 'dom_id' | 'presets' | 'plugins'>> {
17
- dom_id?: undefined | never;
17
+ dom_id?: undefined;
18
18
  /**
19
19
  * Paths to global variables holding the presets, resolved in the browser,
20
20
  * e.g. `'SwaggerUIBundle.presets.apis'`. Load custom presets through `docsHead`.
21
21
  *
22
22
  * @default ['SwaggerUIBundle.presets.apis']
23
23
  */
24
- presets?: undefined | string[];
24
+ presets?: string[] | undefined;
25
25
  /**
26
26
  * Paths to global variables holding the plugins, resolved in the browser,
27
27
  * e.g. `'SwaggerUIBundle.plugins.DownloadUrl'`. Load custom plugins through `docsHead`.
28
28
  *
29
29
  * @default ['SwaggerUIBundle.plugins.DownloadUrl']
30
30
  */
31
- plugins?: undefined | string[];
31
+ plugins?: string[] | undefined;
32
32
  }
33
33
  interface OpenAPIReferenceHandlerPluginOptions<T extends Context, TProvider extends OpenAPIReferenceHandlerPluginProvider> {
34
34
  /**
@@ -42,55 +42,55 @@ interface OpenAPIReferenceHandlerPluginOptions<T extends Context, TProvider exte
42
42
  * as if the plugin were not installed. Useful for restricting access
43
43
  * to authenticated users.
44
44
  */
45
- allow?: Value<Promisable<boolean>, [StandardHandlerRoutingInterceptorOptions<T>]>;
45
+ allow?: Value<Promisable<boolean>, [StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
46
46
  /**
47
47
  * The URL path at which to serve the OpenAPI JSON.
48
48
  *
49
49
  * @default '/spec.json'
50
50
  */
51
- specPath?: StandardUrl;
51
+ specPath?: StandardUrl | undefined;
52
52
  /**
53
53
  * The UI provider to use for rendering the API reference.
54
54
  *
55
55
  * @default 'scalar'
56
56
  */
57
- provider?: TProvider;
57
+ provider?: TProvider | undefined;
58
58
  /**
59
59
  * Provider-specific configuration passed directly to the chosen UI library.
60
60
  * Options differ depending on `provider`.
61
61
  */
62
- providerConfig?: undefined | (TProvider extends 'swagger' ? OpenAPIReferenceHandlerPluginSwaggerConfig : OpenAPIReferenceHandlerPluginScalarConfig);
62
+ providerConfig?: (TProvider extends 'swagger' ? OpenAPIReferenceHandlerPluginSwaggerConfig : OpenAPIReferenceHandlerPluginScalarConfig) | undefined;
63
63
  /**
64
64
  * URL for the provider's main script bundle.
65
65
  *
66
66
  * @default 'https://cdn.jsdelivr.net/npm/@scalar/api-reference' | 'https://unpkg.com/swagger-ui-dist/swagger-ui-bundle.js'
67
67
  */
68
- providerScriptUrl?: undefined | string;
68
+ providerScriptUrl?: string | undefined;
69
69
  /**
70
70
  * URL for the provider's stylesheet.
71
71
  *
72
72
  * @default undefined | 'https://unpkg.com/swagger-ui-dist/swagger-ui.css'
73
73
  */
74
- providerCssUrl?: undefined | string;
74
+ providerCssUrl?: string | undefined;
75
75
  /**
76
76
  * The URL path at which to serve the API reference UI.
77
77
  *
78
78
  * @default '/'
79
79
  */
80
- docsPath?: StandardUrl;
80
+ docsPath?: StandardUrl | undefined;
81
81
  /**
82
82
  * The document title for the API reference UI.
83
83
  *
84
84
  * @default spec.info.title
85
85
  */
86
- docsTitle?: Value<Promisable<string>, [StandardHandlerRoutingInterceptorOptions<T>]>;
86
+ docsTitle?: Value<Promisable<string>, [StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
87
87
  /**
88
88
  * Raw HTML to inject into the `<head>` of the API reference page.
89
89
  * Useful for custom stylesheets, meta tags, or scripts.
90
90
  *
91
91
  * @default ''
92
92
  */
93
- docsHead?: Value<Promisable<string>, [StandardHandlerRoutingInterceptorOptions<T>]>;
93
+ docsHead?: Value<Promisable<string>, [StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
94
94
  }
95
95
  /**
96
96
  * Serves API reference documentation powered by Scalar or Swagger UI,
@@ -14,21 +14,21 @@ type OpenAPIReferenceHandlerPluginProvider = 'scalar' | 'swagger';
14
14
  interface OpenAPIReferenceHandlerPluginScalarConfig extends Partial<ApiReferenceConfiguration> {
15
15
  }
16
16
  interface OpenAPIReferenceHandlerPluginSwaggerConfig extends Partial<Omit<SwaggerUIOptions, 'dom_id' | 'presets' | 'plugins'>> {
17
- dom_id?: undefined | never;
17
+ dom_id?: undefined;
18
18
  /**
19
19
  * Paths to global variables holding the presets, resolved in the browser,
20
20
  * e.g. `'SwaggerUIBundle.presets.apis'`. Load custom presets through `docsHead`.
21
21
  *
22
22
  * @default ['SwaggerUIBundle.presets.apis']
23
23
  */
24
- presets?: undefined | string[];
24
+ presets?: string[] | undefined;
25
25
  /**
26
26
  * Paths to global variables holding the plugins, resolved in the browser,
27
27
  * e.g. `'SwaggerUIBundle.plugins.DownloadUrl'`. Load custom plugins through `docsHead`.
28
28
  *
29
29
  * @default ['SwaggerUIBundle.plugins.DownloadUrl']
30
30
  */
31
- plugins?: undefined | string[];
31
+ plugins?: string[] | undefined;
32
32
  }
33
33
  interface OpenAPIReferenceHandlerPluginOptions<T extends Context, TProvider extends OpenAPIReferenceHandlerPluginProvider> {
34
34
  /**
@@ -42,55 +42,55 @@ interface OpenAPIReferenceHandlerPluginOptions<T extends Context, TProvider exte
42
42
  * as if the plugin were not installed. Useful for restricting access
43
43
  * to authenticated users.
44
44
  */
45
- allow?: Value<Promisable<boolean>, [StandardHandlerRoutingInterceptorOptions<T>]>;
45
+ allow?: Value<Promisable<boolean>, [StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
46
46
  /**
47
47
  * The URL path at which to serve the OpenAPI JSON.
48
48
  *
49
49
  * @default '/spec.json'
50
50
  */
51
- specPath?: StandardUrl;
51
+ specPath?: StandardUrl | undefined;
52
52
  /**
53
53
  * The UI provider to use for rendering the API reference.
54
54
  *
55
55
  * @default 'scalar'
56
56
  */
57
- provider?: TProvider;
57
+ provider?: TProvider | undefined;
58
58
  /**
59
59
  * Provider-specific configuration passed directly to the chosen UI library.
60
60
  * Options differ depending on `provider`.
61
61
  */
62
- providerConfig?: undefined | (TProvider extends 'swagger' ? OpenAPIReferenceHandlerPluginSwaggerConfig : OpenAPIReferenceHandlerPluginScalarConfig);
62
+ providerConfig?: (TProvider extends 'swagger' ? OpenAPIReferenceHandlerPluginSwaggerConfig : OpenAPIReferenceHandlerPluginScalarConfig) | undefined;
63
63
  /**
64
64
  * URL for the provider's main script bundle.
65
65
  *
66
66
  * @default 'https://cdn.jsdelivr.net/npm/@scalar/api-reference' | 'https://unpkg.com/swagger-ui-dist/swagger-ui-bundle.js'
67
67
  */
68
- providerScriptUrl?: undefined | string;
68
+ providerScriptUrl?: string | undefined;
69
69
  /**
70
70
  * URL for the provider's stylesheet.
71
71
  *
72
72
  * @default undefined | 'https://unpkg.com/swagger-ui-dist/swagger-ui.css'
73
73
  */
74
- providerCssUrl?: undefined | string;
74
+ providerCssUrl?: string | undefined;
75
75
  /**
76
76
  * The URL path at which to serve the API reference UI.
77
77
  *
78
78
  * @default '/'
79
79
  */
80
- docsPath?: StandardUrl;
80
+ docsPath?: StandardUrl | undefined;
81
81
  /**
82
82
  * The document title for the API reference UI.
83
83
  *
84
84
  * @default spec.info.title
85
85
  */
86
- docsTitle?: Value<Promisable<string>, [StandardHandlerRoutingInterceptorOptions<T>]>;
86
+ docsTitle?: Value<Promisable<string>, [StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
87
87
  /**
88
88
  * Raw HTML to inject into the `<head>` of the API reference page.
89
89
  * Useful for custom stylesheets, meta tags, or scripts.
90
90
  *
91
91
  * @default ''
92
92
  */
93
- docsHead?: Value<Promisable<string>, [StandardHandlerRoutingInterceptorOptions<T>]>;
93
+ docsHead?: Value<Promisable<string>, [StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
94
94
  }
95
95
  /**
96
96
  * Serves API reference documentation powered by Scalar or Swagger UI,
@@ -4,7 +4,7 @@ import { StandardHandlerCodec, ResolvedStandardHandlerHandleOptions, StandardHan
4
4
  import { Value, Public, Promisable } from '@orpc/shared';
5
5
  import { StandardLazyRequest, StandardResponse } from '@standard-server/core';
6
6
  import { AnyProcedureContract } from '@orpc/contract';
7
- import { O as OpenAPISerializer } from './openapi.DjGhiceP.mjs';
7
+ import { a as OpenAPISerializer } from './openapi.D42Ps1fQ.mjs';
8
8
 
9
9
  interface OpenAPIMatcherOptions {
10
10
  /**
@@ -12,7 +12,7 @@ interface OpenAPIMatcherOptions {
12
12
  *
13
13
  * @default true
14
14
  */
15
- filter?: Value<boolean, [contract: AnyProcedureContract | AnyProcedure, path: string[]]>;
15
+ filter?: Value<boolean, [contract: AnyProcedureContract | AnyProcedure, path: string[]]> | undefined;
16
16
  }
17
17
  declare class OpenAPIMatcher {
18
18
  private readonly filter;
@@ -38,10 +38,11 @@ interface OpenAPIHandlerCodecCoreOptions<_T extends Context> {
38
38
  /**
39
39
  * Override the default OpenAPI serializer.
40
40
  */
41
- serializer?: Public<OpenAPISerializer>;
41
+ serializer?: Public<OpenAPISerializer> | undefined;
42
42
  /**
43
43
  * Mapping ORPCError Code -> HTTP Status Code
44
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).
45
46
  *
46
47
  * @default COMMON_ERROR_STATUS_MAP
47
48
  */
@@ -55,7 +56,7 @@ interface OpenAPIHandlerCodecCoreOptions<_T extends Context> {
55
56
  *
56
57
  * @default ((e) => e.toJSON())
57
58
  */
58
- customErrorResponseBodyEncoder?: (error: AnyORPCError) => unknown;
59
+ customErrorResponseBodyEncoder?: ((error: AnyORPCError) => unknown) | undefined;
59
60
  }
60
61
  declare class OpenAPIHandlerCodecCore<T extends Context> {
61
62
  private readonly serializer;
@@ -64,7 +65,7 @@ declare class OpenAPIHandlerCodecCore<T extends Context> {
64
65
  constructor(options?: OpenAPIHandlerCodecCoreOptions<T>);
65
66
  decodeInput(matched: {
66
67
  procedure: AnyProcedure;
67
- params?: undefined | Record<string, string>;
68
+ params?: Record<string, string> | undefined;
68
69
  }, request: StandardLazyRequest): Promise<unknown>;
69
70
  /**
70
71
  * @throws {TypeError} If `outputStructure` is "detailed" and the output doesn't match the expected structure.
@@ -1,12 +1,12 @@
1
- import { MalformedResponseError, isORPCErrorJson, createORPCErrorFromJson } from '@orpc/client';
1
+ import { MalformedResponseError, isORPCErrorJson, createORPCErrorFromJson, ResponseError } from '@orpc/client';
2
2
  import { getRouterContract, ProcedureContract } from '@orpc/contract';
3
3
  import { unlazy } from '@orpc/server';
4
4
  import { value, pathToHttpPath, mergeHttpPath, isTypescriptObject, stringifyJSON, safeEncodeURIComponent } from '@orpc/shared';
5
5
  import { mergeStandardHeaders, parseStandardUrl } from '@standard-server/core';
6
6
  import { toStandardHeaders } from '@standard-server/fetch';
7
- import { O as OpenAPISerializer, D as DEFAULT_OPENAPI_METHOD, a as DEFAULT_OPENAPI_INPUT_STRUCTURE, g as getDynamicPathParams, i as isBodylessMethod, b as DEFAULT_OPENAPI_OUTPUT_STRUCTURE } from './openapi.PXVenYpE.mjs';
7
+ import { O as OpenAPISerializer, D as DEFAULT_OPENAPI_METHOD, a as DEFAULT_OPENAPI_INPUT_STRUCTURE, g as getDynamicPathParams, i as isBodylessMethod, b as DEFAULT_OPENAPI_OUTPUT_STRUCTURE } from './openapi.E3ZBiweM.mjs';
8
8
  import { g as getOpenAPIMeta } from './openapi.B9PQzqBn.mjs';
9
- import { s as serializeHeaders } from './openapi.DjMM672U.mjs';
9
+ import { s as serializeHeaders } from './openapi.DXqJL3gB.mjs';
10
10
 
11
11
  const END_SLASH_REGEX = /\/$/;
12
12
  const DOT_SEGMENT_REGEX = /(?:^|\/)\.{1,2}(?:\/|$)/;
@@ -270,7 +270,12 @@ class OpenAPILinkCodec {
270
270
  return { kind: "error", error: customError };
271
271
  }
272
272
  if (isORPCErrorJson(deserialized)) {
273
- return { kind: "error", error: createORPCErrorFromJson(deserialized) };
273
+ return {
274
+ kind: "error",
275
+ error: createORPCErrorFromJson(deserialized, {
276
+ cause: new ResponseError({ response: { status: response.status, headers: response.headers, body } })
277
+ })
278
+ };
274
279
  }
275
280
  throw new MalformedResponseError({ response: { headers: response.headers, status: response.status, body } });
276
281
  }
@@ -278,7 +278,7 @@ interface OpenAPIMeta {
278
278
  *
279
279
  * Explicitly setting `undefined` resets the spec instead of merging.
280
280
  */
281
- spec?: Value<OpenAPIV3_2.OperationObject, [current: OpenAPIV3_2.OperationObject]>;
281
+ spec?: Value<OpenAPIV3_2.OperationObject, [current: OpenAPIV3_2.OperationObject]> | undefined;
282
282
  /**
283
283
  * Prefix for the path. Useful when you want to apply a common path prefix across multiple procedures.
284
284
  *
@@ -278,7 +278,7 @@ interface OpenAPIMeta {
278
278
  *
279
279
  * Explicitly setting `undefined` resets the spec instead of merging.
280
280
  */
281
- spec?: Value<OpenAPIV3_2.OperationObject, [current: OpenAPIV3_2.OperationObject]>;
281
+ spec?: Value<OpenAPIV3_2.OperationObject, [current: OpenAPIV3_2.OperationObject]> | undefined;
282
282
  /**
283
283
  * Prefix for the path. Useful when you want to apply a common path prefix across multiple procedures.
284
284
  *
@@ -3,7 +3,7 @@ import { StandardLinkCodec, StandardLinkCodecDecodedResponse } from '@orpc/clien
3
3
  import { RouterContract } from '@orpc/contract';
4
4
  import { Value, Promisable, Public } from '@orpc/shared';
5
5
  import { StandardUrl, StandardHeaders, StandardLazyResponse, StandardRequest } from '@standard-server/core';
6
- import { O as OpenAPISerializer } from './openapi.DjGhiceP.js';
6
+ import { a as OpenAPISerializer } from './openapi.D42Ps1fQ.js';
7
7
 
8
8
  interface OpenAPILinkCodecOptions<T extends ClientContext> {
9
9
  /**
@@ -12,20 +12,20 @@ interface OpenAPILinkCodecOptions<T extends ClientContext> {
12
12
  * @example '/api'
13
13
  * @default '/'
14
14
  */
15
- url?: Value<Promisable<StandardUrl>, [options: ClientOptions<T>, path: string[], input: unknown]>;
15
+ url?: Value<Promisable<StandardUrl>, [options: ClientOptions<T>, path: string[], input: unknown]> | undefined;
16
16
  /**
17
17
  * Inject headers into the request.
18
18
  */
19
- headers?: Value<Promisable<StandardHeaders | Headers>, [options: ClientOptions<T>, path: string[], input: unknown]>;
19
+ headers?: Value<Promisable<StandardHeaders | Headers>, [options: ClientOptions<T>, path: string[], input: unknown]> | undefined;
20
20
  /**
21
21
  * Override the default OpenAPI serializer.
22
22
  */
23
- serializer?: Public<OpenAPISerializer>;
23
+ serializer?: Public<OpenAPISerializer> | undefined;
24
24
  /**
25
25
  * Customize how an error response body is converted into an ORPC error.
26
26
  * Return `null` or `undefined` to fall back to the default decoding behavior.
27
27
  */
28
- customErrorResponseBodyDecoder?: (deserializedBody: unknown, response: StandardLazyResponse) => AnyORPCError | null | undefined;
28
+ customErrorResponseBodyDecoder?: ((deserializedBody: unknown, response: StandardLazyResponse) => AnyORPCError | null | undefined) | undefined;
29
29
  }
30
30
  declare class OpenAPILinkCodec<T extends ClientContext> implements StandardLinkCodec<T> {
31
31
  private readonly router;
@@ -3,7 +3,7 @@ import { StandardLinkCodec, StandardLinkCodecDecodedResponse } from '@orpc/clien
3
3
  import { RouterContract } from '@orpc/contract';
4
4
  import { Value, Promisable, Public } from '@orpc/shared';
5
5
  import { StandardUrl, StandardHeaders, StandardLazyResponse, StandardRequest } from '@standard-server/core';
6
- import { O as OpenAPISerializer } from './openapi.DjGhiceP.mjs';
6
+ import { a as OpenAPISerializer } from './openapi.D42Ps1fQ.mjs';
7
7
 
8
8
  interface OpenAPILinkCodecOptions<T extends ClientContext> {
9
9
  /**
@@ -12,20 +12,20 @@ interface OpenAPILinkCodecOptions<T extends ClientContext> {
12
12
  * @example '/api'
13
13
  * @default '/'
14
14
  */
15
- url?: Value<Promisable<StandardUrl>, [options: ClientOptions<T>, path: string[], input: unknown]>;
15
+ url?: Value<Promisable<StandardUrl>, [options: ClientOptions<T>, path: string[], input: unknown]> | undefined;
16
16
  /**
17
17
  * Inject headers into the request.
18
18
  */
19
- headers?: Value<Promisable<StandardHeaders | Headers>, [options: ClientOptions<T>, path: string[], input: unknown]>;
19
+ headers?: Value<Promisable<StandardHeaders | Headers>, [options: ClientOptions<T>, path: string[], input: unknown]> | undefined;
20
20
  /**
21
21
  * Override the default OpenAPI serializer.
22
22
  */
23
- serializer?: Public<OpenAPISerializer>;
23
+ serializer?: Public<OpenAPISerializer> | undefined;
24
24
  /**
25
25
  * Customize how an error response body is converted into an ORPC error.
26
26
  * Return `null` or `undefined` to fall back to the default decoding behavior.
27
27
  */
28
- customErrorResponseBodyDecoder?: (deserializedBody: unknown, response: StandardLazyResponse) => AnyORPCError | null | undefined;
28
+ customErrorResponseBodyDecoder?: ((deserializedBody: unknown, response: StandardLazyResponse) => AnyORPCError | null | undefined) | undefined;
29
29
  }
30
30
  declare class OpenAPILinkCodec<T extends ClientContext> implements StandardLinkCodec<T> {
31
31
  private readonly router;
@@ -4,7 +4,7 @@ import { StandardHandlerCodec, ResolvedStandardHandlerHandleOptions, StandardHan
4
4
  import { Value, Public, Promisable } from '@orpc/shared';
5
5
  import { StandardLazyRequest, StandardResponse } from '@standard-server/core';
6
6
  import { AnyProcedureContract } from '@orpc/contract';
7
- import { O as OpenAPISerializer } from './openapi.DjGhiceP.js';
7
+ import { a as OpenAPISerializer } from './openapi.D42Ps1fQ.js';
8
8
 
9
9
  interface OpenAPIMatcherOptions {
10
10
  /**
@@ -12,7 +12,7 @@ interface OpenAPIMatcherOptions {
12
12
  *
13
13
  * @default true
14
14
  */
15
- filter?: Value<boolean, [contract: AnyProcedureContract | AnyProcedure, path: string[]]>;
15
+ filter?: Value<boolean, [contract: AnyProcedureContract | AnyProcedure, path: string[]]> | undefined;
16
16
  }
17
17
  declare class OpenAPIMatcher {
18
18
  private readonly filter;
@@ -38,10 +38,11 @@ interface OpenAPIHandlerCodecCoreOptions<_T extends Context> {
38
38
  /**
39
39
  * Override the default OpenAPI serializer.
40
40
  */
41
- serializer?: Public<OpenAPISerializer>;
41
+ serializer?: Public<OpenAPISerializer> | undefined;
42
42
  /**
43
43
  * Mapping ORPCError Code -> HTTP Status Code
44
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).
45
46
  *
46
47
  * @default COMMON_ERROR_STATUS_MAP
47
48
  */
@@ -55,7 +56,7 @@ interface OpenAPIHandlerCodecCoreOptions<_T extends Context> {
55
56
  *
56
57
  * @default ((e) => e.toJSON())
57
58
  */
58
- customErrorResponseBodyEncoder?: (error: AnyORPCError) => unknown;
59
+ customErrorResponseBodyEncoder?: ((error: AnyORPCError) => unknown) | undefined;
59
60
  }
60
61
  declare class OpenAPIHandlerCodecCore<T extends Context> {
61
62
  private readonly serializer;
@@ -64,7 +65,7 @@ declare class OpenAPIHandlerCodecCore<T extends Context> {
64
65
  constructor(options?: OpenAPIHandlerCodecCoreOptions<T>);
65
66
  decodeInput(matched: {
66
67
  procedure: AnyProcedure;
67
- params?: undefined | Record<string, string>;
68
+ params?: Record<string, string> | undefined;
68
69
  }, request: StandardLazyRequest): Promise<unknown>;
69
70
  /**
70
71
  * @throws {TypeError} If `outputStructure` is "detailed" and the output doesn't match the expected structure.
@@ -15,7 +15,7 @@ interface BracketNotationSerializerOptions {
15
15
  *
16
16
  * @default 1_000
17
17
  */
18
- maxDeserializingEmptySlots?: number;
18
+ maxDeserializingEmptySlots?: number | undefined;
19
19
  }
20
20
  declare class BracketNotationSerializer {
21
21
  private readonly maxDeserializingEmptySlots;
@@ -47,7 +47,7 @@ interface OpenAPIJsonSerializerHandler {
47
47
  *
48
48
  * @default false
49
49
  */
50
- isTerminal?: boolean;
50
+ isTerminal?: boolean | undefined;
51
51
  }
52
52
  interface OpenAPIJsonSerializerOptions {
53
53
  /**
@@ -98,13 +98,13 @@ declare class OpenAPIJsonSerializer {
98
98
  private readonly handlerEntries;
99
99
  private readonly omitUndefinedProperties;
100
100
  constructor(options?: OpenAPIJsonSerializerOptions);
101
- serialize(data: unknown): OpenAPIJsonSerialization;
101
+ serializeJson(data: unknown): OpenAPIJsonSerialization;
102
102
  /**
103
103
  * `segments` is a shared mutable stack (push/pop while walking),
104
104
  * so it must be copied before being stored in `maps`.
105
105
  */
106
106
  private serializeValue;
107
- deserialize(serialized: OpenAPIJsonSerialization): unknown;
107
+ deserializeJson(serialized: OpenAPIJsonSerialization): unknown;
108
108
  }
109
109
 
110
110
  interface OpenAPISerializerSerializeOptions {
@@ -114,7 +114,7 @@ interface OpenAPISerializerSerializeOptions {
114
114
  *
115
115
  * @default true
116
116
  */
117
- useFormDataForBlobFields?: boolean;
117
+ useFormDataForBlobFields?: boolean | undefined;
118
118
  /**
119
119
  * When enabled, the serialized output is always returned as a FormData instance using bracket notation.
120
120
  *
@@ -138,15 +138,14 @@ interface OpenAPISerializerOptions extends OpenAPIJsonSerializerOptions {
138
138
  *
139
139
  * @see {@link https://orpc.dev/docs/openapi/serializer | OpenAPI Serializer}
140
140
  */
141
- declare class OpenAPISerializer {
142
- private readonly jsonSerializer;
141
+ declare class OpenAPISerializer extends OpenAPIJsonSerializer {
143
142
  private readonly bracketNotation;
144
143
  private readonly defaultSerializeOptions;
145
144
  constructor({ bracketNotation, serialize, ...options }?: OpenAPISerializerOptions);
146
145
  serialize(data: unknown, options?: OpenAPISerializerSerializeOptions): StandardBody;
147
- private serializeValue;
146
+ private serializePayload;
148
147
  deserialize(data: StandardBody): unknown;
149
148
  }
150
149
 
151
- export { OpenAPISerializer as O, BracketNotationSerializer as a, OpenAPIJsonSerializer as d };
152
- export type { BracketNotationSerializeResult as B, BracketNotationSerializerOptions as b, OpenAPIJsonSerialization as c, OpenAPIJsonSerializerHandler as e, OpenAPIJsonSerializerOptions as f, OpenAPISerializerOptions as g, OpenAPISerializerSerializeOptions as h };
150
+ export { OpenAPIJsonSerializer as O, OpenAPISerializer as a, BracketNotationSerializer as b };
151
+ export type { BracketNotationSerializeResult as B, BracketNotationSerializerOptions as c, OpenAPIJsonSerialization as d, OpenAPIJsonSerializerHandler as e, OpenAPIJsonSerializerOptions as f, OpenAPISerializerOptions as g, OpenAPISerializerSerializeOptions as h };
@@ -15,7 +15,7 @@ interface BracketNotationSerializerOptions {
15
15
  *
16
16
  * @default 1_000
17
17
  */
18
- maxDeserializingEmptySlots?: number;
18
+ maxDeserializingEmptySlots?: number | undefined;
19
19
  }
20
20
  declare class BracketNotationSerializer {
21
21
  private readonly maxDeserializingEmptySlots;
@@ -47,7 +47,7 @@ interface OpenAPIJsonSerializerHandler {
47
47
  *
48
48
  * @default false
49
49
  */
50
- isTerminal?: boolean;
50
+ isTerminal?: boolean | undefined;
51
51
  }
52
52
  interface OpenAPIJsonSerializerOptions {
53
53
  /**
@@ -98,13 +98,13 @@ declare class OpenAPIJsonSerializer {
98
98
  private readonly handlerEntries;
99
99
  private readonly omitUndefinedProperties;
100
100
  constructor(options?: OpenAPIJsonSerializerOptions);
101
- serialize(data: unknown): OpenAPIJsonSerialization;
101
+ serializeJson(data: unknown): OpenAPIJsonSerialization;
102
102
  /**
103
103
  * `segments` is a shared mutable stack (push/pop while walking),
104
104
  * so it must be copied before being stored in `maps`.
105
105
  */
106
106
  private serializeValue;
107
- deserialize(serialized: OpenAPIJsonSerialization): unknown;
107
+ deserializeJson(serialized: OpenAPIJsonSerialization): unknown;
108
108
  }
109
109
 
110
110
  interface OpenAPISerializerSerializeOptions {
@@ -114,7 +114,7 @@ interface OpenAPISerializerSerializeOptions {
114
114
  *
115
115
  * @default true
116
116
  */
117
- useFormDataForBlobFields?: boolean;
117
+ useFormDataForBlobFields?: boolean | undefined;
118
118
  /**
119
119
  * When enabled, the serialized output is always returned as a FormData instance using bracket notation.
120
120
  *
@@ -138,15 +138,14 @@ interface OpenAPISerializerOptions extends OpenAPIJsonSerializerOptions {
138
138
  *
139
139
  * @see {@link https://orpc.dev/docs/openapi/serializer | OpenAPI Serializer}
140
140
  */
141
- declare class OpenAPISerializer {
142
- private readonly jsonSerializer;
141
+ declare class OpenAPISerializer extends OpenAPIJsonSerializer {
143
142
  private readonly bracketNotation;
144
143
  private readonly defaultSerializeOptions;
145
144
  constructor({ bracketNotation, serialize, ...options }?: OpenAPISerializerOptions);
146
145
  serialize(data: unknown, options?: OpenAPISerializerSerializeOptions): StandardBody;
147
- private serializeValue;
146
+ private serializePayload;
148
147
  deserialize(data: StandardBody): unknown;
149
148
  }
150
149
 
151
- export { OpenAPISerializer as O, BracketNotationSerializer as a, OpenAPIJsonSerializer as d };
152
- export type { BracketNotationSerializeResult as B, BracketNotationSerializerOptions as b, OpenAPIJsonSerialization as c, OpenAPIJsonSerializerHandler as e, OpenAPIJsonSerializerOptions as f, OpenAPISerializerOptions as g, OpenAPISerializerSerializeOptions as h };
150
+ export { OpenAPIJsonSerializer as O, OpenAPISerializer as a, BracketNotationSerializer as b };
151
+ export type { BracketNotationSerializeResult as B, BracketNotationSerializerOptions as c, OpenAPIJsonSerialization as d, OpenAPIJsonSerializerHandler as e, OpenAPIJsonSerializerOptions as f, OpenAPISerializerOptions as g, OpenAPISerializerSerializeOptions as h };