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

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 (35) hide show
  1. package/README.md +100 -62
  2. package/dist/adapters/aws-lambda/index.d.mts +2 -1
  3. package/dist/adapters/aws-lambda/index.d.ts +2 -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 +43 -9
  15. package/dist/adapters/standard/index.d.ts +43 -9
  16. package/dist/adapters/standard/index.mjs +3 -3
  17. package/dist/index.d.mts +23 -20
  18. package/dist/index.d.ts +23 -20
  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.BCrrWRbv.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.1UQkZGBs.d.ts → openapi.BkjX_6hE.d.ts} +6 -5
  27. package/dist/shared/{openapi.BTq9wym2.d.mts → openapi.Covi8zVE.d.mts} +1 -1
  28. package/dist/shared/{openapi.BTq9wym2.d.ts → openapi.Covi8zVE.d.ts} +1 -1
  29. package/dist/shared/{openapi.DjMM672U.mjs → openapi.DXqJL3gB.mjs} +4 -10
  30. package/dist/shared/{openapi.PXVenYpE.mjs → openapi.E3ZBiweM.mjs} +12 -13
  31. package/dist/shared/{openapi.DjGhiceP.d.mts → openapi.YMRD3b4R.d.mts} +15 -10
  32. package/dist/shared/{openapi.DjGhiceP.d.ts → openapi.YMRD3b4R.d.ts} +15 -10
  33. package/package.json +13 -13
  34. package/dist/shared/openapi.BVt3NPfo.d.mts +0 -45
  35. package/dist/shared/openapi.aoP0G_Bv.d.ts +0 -45
package/dist/index.d.mts CHANGED
@@ -1,12 +1,13 @@
1
- import { O as OpenAPISerializer } from './shared/openapi.DjGhiceP.mjs';
2
- export { B as BracketNotationSerializeResult, a as BracketNotationSerializer, b as BracketNotationSerializerOptions, c as OpenAPIJsonSerialization, d as OpenAPIJsonSerializer, e as OpenAPIJsonSerializerHandler, f as OpenAPIJsonSerializerOptions, g as OpenAPISerializerOptions, h as OpenAPISerializerSerializeOptions } from './shared/openapi.DjGhiceP.mjs';
1
+ import { a as OpenAPIJsonSerializer } from './shared/openapi.YMRD3b4R.mjs';
2
+ export { B as BracketNotationSerializeResult, b as BracketNotationSerializer, c as BracketNotationSerializerOptions, d as OpenAPIJsonSerialization, e as OpenAPIJsonSerializerHandler, f as OpenAPIJsonSerializerOptions, O as OpenAPISerializer, g as OpenAPISerializerOptions, h as OpenAPISerializerSerializeOptions } from './shared/openapi.YMRD3b4R.mjs';
3
3
  import { ClientContext, ORPCClientOptions, ClientLink } from '@orpc/client';
4
4
  export { COMMON_ERROR_STATUS_MAP } from '@orpc/client';
5
5
  import { RouterContract, RouterContractClient, AnyProcedureContract, ProcedureContract } from '@orpc/contract';
6
- import { J as JsonifiedClient, O as OpenAPIVersion, a as OpenAPIDocument } from './shared/openapi.BTq9wym2.mjs';
7
- export { b as JsonifiedArray, c as JsonifiedClientError, d as JsonifiedValue } from './shared/openapi.BTq9wym2.mjs';
8
- export { a as OpenAPIFunction, O as OpenAPIMeta, b as OpenAPIMetaPlugin, c as OpenAPIMethodMetaPlugin, d as OpenAPIPathMetaPlugin, e as OpenAPIPrefixMetaPlugin, f as OpenAPISpecMetaPlugin, g as getOpenAPIMeta, o as openapi } from './shared/openapi.r98bZ3Ig.mjs';
6
+ import { J as JsonifiedClient, a as OpenAPIVersion, O as OpenAPIDocument } from './shared/openapi.Covi8zVE.mjs';
7
+ export { b as JsonifiedArray, c as JsonifiedClientError, d as JsonifiedValue } from './shared/openapi.Covi8zVE.mjs';
8
+ export { a as OpenAPIFunction, O as OpenAPIMeta, b as OpenAPIMetaPlugin, c as OpenAPIMethodMetaPlugin, d as OpenAPIPathMetaPlugin, e as OpenAPIPrefixMetaPlugin, f as OpenAPISpecMetaPlugin, g as getOpenAPIMeta, o as openapi } from './shared/openapi.B_SoJfYz.mjs';
9
9
  import { JsonSchema, JsonSchemaConverter } from '@orpc/json-schema';
10
+ export { JsonSchema } from '@orpc/json-schema';
10
11
  import { AnyRouter, AnyProcedure } from '@orpc/server';
11
12
  import { Public, Value } from '@orpc/shared';
12
13
  import * as OpenAPIV3_2 from '@openapi-spec/types/v3.2';
@@ -26,20 +27,21 @@ interface ContractJsonifiedClientFactoryOptions<TClientContext extends ClientCon
26
27
  * When provided, the client factory will automatically register the passed contract
27
28
  * into the router at the path defined by `meta.path`.
28
29
  */
29
- contractRef?: undefined | RouterContract;
30
+ contractRef?: RouterContract | undefined;
30
31
  }
32
+ /**
33
+ * Like `createContractClientFactory`, but the clients it builds are typed as `JsonifiedClient`,
34
+ * for links that require it, such as OpenAPI Link.
35
+ *
36
+ * @remarks
37
+ * **Warning**: Every procedure contract passed to the factory must define `meta.path` matching its location in the root contract.
38
+ *
39
+ * @see {@link https://orpc.dev/docs/contract/client-factory | Contract Client Factory}
40
+ */
31
41
  declare function createContractJsonifiedClientFactory<TClientContext extends ClientContext>(link: ClientLink<TClientContext>, options?: ContractJsonifiedClientFactoryOptions<TClientContext>): ContractJsonifiedClientFactory<TClientContext>;
32
42
 
33
43
  declare const DEFAULT_OPENAPI_METHOD = "POST";
34
- declare const DEFAULT_OPENAPI_SUCCESS_DESCRIPTION = "OK";
35
- declare const DEFAULT_OPENAPI_INPUT_STRUCTURE = "compact";
36
- declare const DEFAULT_OPENAPI_OUTPUT_STRUCTURE = "compact";
37
44
 
38
- /**
39
- * GET and HEAD requests cannot carry a request body,
40
- * so their compact input maps to query parameters instead.
41
- */
42
- declare function isBodylessMethod(method: string): boolean;
43
45
  /**
44
46
  * Dynamic parameters are always returned in path order.
45
47
  */
@@ -64,7 +66,7 @@ interface OpenAPIGeneratorOptions {
64
66
  /**
65
67
  * The serializer used to serialize the generated OpenAPI documentation
66
68
  */
67
- serializer?: Public<OpenAPISerializer> | undefined;
69
+ serializer?: Public<OpenAPIJsonSerializer> | undefined;
68
70
  }
69
71
  interface OpenAPIGeneratorGenerateOptions<TVersion extends OpenAPIVersion> {
70
72
  /**
@@ -91,13 +93,13 @@ interface OpenAPIGeneratorGenerateOptions<TVersion extends OpenAPIVersion> {
91
93
  *
92
94
  * @default defName => defName
93
95
  */
94
- customComponentName?: (defName: string, defSchema: JsonSchema) => string | undefined;
96
+ customComponentName?: ((defName: string, defSchema: JsonSchema) => string | undefined) | undefined;
95
97
  /**
96
98
  * Filter procedures. Return `false` to exclude a procedure from the OpenAPI specification.
97
99
  *
98
100
  * @default true
99
101
  */
100
- filter?: Value<boolean, [contract: AnyProcedureContract | AnyProcedure, path: string[]]>;
102
+ filter?: Value<boolean, [contract: AnyProcedureContract | AnyProcedure, path: string[]]> | undefined;
101
103
  /**
102
104
  * Define a custom JSON schema for the error response body when using
103
105
  * type-safe errors. Helps align ORPC error formatting with existing API
@@ -110,9 +112,10 @@ interface OpenAPIGeneratorGenerateOptions<TVersion extends OpenAPIVersion> {
110
112
  customErrorResponseBodySchema?: Value<JsonSchema | undefined | null, [
111
113
  definedErrors: OpenAPIErrorBodyDefinition[],
112
114
  status: number
113
- ]>;
115
+ ]> | undefined;
114
116
  /**
115
117
  * Mapping ORPCError Code -> HTTP Status Code
118
+ * Codes missing from the map fall back to `DEFAULT_ERROR_STATUS` (400).
116
119
  *
117
120
  * @default COMMON_ERROR_STATUS_MAP
118
121
  */
@@ -140,7 +143,7 @@ interface PopulateRouterContractOpenAPIPathsOptions {
140
143
  /**
141
144
  * Base path segments.
142
145
  */
143
- path?: undefined | string[];
146
+ path?: string[] | undefined;
144
147
  }
145
148
  /**
146
149
  * Automatically populates missing openapi.path using router structure.
@@ -152,5 +155,5 @@ interface PopulateRouterContractOpenAPIPathsOptions {
152
155
  */
153
156
  declare function populateRouterContractOpenAPIPaths<T extends RouterContract>(router: T, options?: PopulateRouterContractOpenAPIPathsOptions): PopulatedContractRouterOpenAPIPaths<T>;
154
157
 
155
- export { DEFAULT_OPENAPI_INPUT_STRUCTURE, DEFAULT_OPENAPI_METHOD, DEFAULT_OPENAPI_OUTPUT_STRUCTURE, DEFAULT_OPENAPI_SUCCESS_DESCRIPTION, JsonifiedClient, OpenAPIDocument, OpenAPIGenerator, OpenAPIGeneratorError, OpenAPISerializer, OpenAPIVersion, createContractJsonifiedClientFactory, getDynamicPathParams, isBodylessMethod, populateRouterContractOpenAPIPaths };
158
+ export { DEFAULT_OPENAPI_METHOD, JsonifiedClient, OpenAPIDocument, OpenAPIGenerator, OpenAPIGeneratorError, OpenAPIJsonSerializer, OpenAPIVersion, createContractJsonifiedClientFactory, getDynamicPathParams, populateRouterContractOpenAPIPaths };
156
159
  export type { ContractJsonifiedClientFactory, ContractJsonifiedClientFactoryOptions, OpenAPIErrorBodyDefinition, OpenAPIGeneratorGenerateOptions, OpenAPIGeneratorOptions, PopulateRouterContractOpenAPIPathsOptions, PopulatedContractRouterOpenAPIPaths };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,13 @@
1
- import { O as OpenAPISerializer } from './shared/openapi.DjGhiceP.js';
2
- export { B as BracketNotationSerializeResult, a as BracketNotationSerializer, b as BracketNotationSerializerOptions, c as OpenAPIJsonSerialization, d as OpenAPIJsonSerializer, e as OpenAPIJsonSerializerHandler, f as OpenAPIJsonSerializerOptions, g as OpenAPISerializerOptions, h as OpenAPISerializerSerializeOptions } from './shared/openapi.DjGhiceP.js';
1
+ import { a as OpenAPIJsonSerializer } from './shared/openapi.YMRD3b4R.js';
2
+ export { B as BracketNotationSerializeResult, b as BracketNotationSerializer, c as BracketNotationSerializerOptions, d as OpenAPIJsonSerialization, e as OpenAPIJsonSerializerHandler, f as OpenAPIJsonSerializerOptions, O as OpenAPISerializer, g as OpenAPISerializerOptions, h as OpenAPISerializerSerializeOptions } from './shared/openapi.YMRD3b4R.js';
3
3
  import { ClientContext, ORPCClientOptions, ClientLink } from '@orpc/client';
4
4
  export { COMMON_ERROR_STATUS_MAP } from '@orpc/client';
5
5
  import { RouterContract, RouterContractClient, AnyProcedureContract, ProcedureContract } from '@orpc/contract';
6
- import { J as JsonifiedClient, O as OpenAPIVersion, a as OpenAPIDocument } from './shared/openapi.BTq9wym2.js';
7
- export { b as JsonifiedArray, c as JsonifiedClientError, d as JsonifiedValue } from './shared/openapi.BTq9wym2.js';
8
- export { a as OpenAPIFunction, O as OpenAPIMeta, b as OpenAPIMetaPlugin, c as OpenAPIMethodMetaPlugin, d as OpenAPIPathMetaPlugin, e as OpenAPIPrefixMetaPlugin, f as OpenAPISpecMetaPlugin, g as getOpenAPIMeta, o as openapi } from './shared/openapi.r98bZ3Ig.js';
6
+ import { J as JsonifiedClient, a as OpenAPIVersion, O as OpenAPIDocument } from './shared/openapi.Covi8zVE.js';
7
+ export { b as JsonifiedArray, c as JsonifiedClientError, d as JsonifiedValue } from './shared/openapi.Covi8zVE.js';
8
+ export { a as OpenAPIFunction, O as OpenAPIMeta, b as OpenAPIMetaPlugin, c as OpenAPIMethodMetaPlugin, d as OpenAPIPathMetaPlugin, e as OpenAPIPrefixMetaPlugin, f as OpenAPISpecMetaPlugin, g as getOpenAPIMeta, o as openapi } from './shared/openapi.B_SoJfYz.js';
9
9
  import { JsonSchema, JsonSchemaConverter } from '@orpc/json-schema';
10
+ export { JsonSchema } from '@orpc/json-schema';
10
11
  import { AnyRouter, AnyProcedure } from '@orpc/server';
11
12
  import { Public, Value } from '@orpc/shared';
12
13
  import * as OpenAPIV3_2 from '@openapi-spec/types/v3.2';
@@ -26,20 +27,21 @@ interface ContractJsonifiedClientFactoryOptions<TClientContext extends ClientCon
26
27
  * When provided, the client factory will automatically register the passed contract
27
28
  * into the router at the path defined by `meta.path`.
28
29
  */
29
- contractRef?: undefined | RouterContract;
30
+ contractRef?: RouterContract | undefined;
30
31
  }
32
+ /**
33
+ * Like `createContractClientFactory`, but the clients it builds are typed as `JsonifiedClient`,
34
+ * for links that require it, such as OpenAPI Link.
35
+ *
36
+ * @remarks
37
+ * **Warning**: Every procedure contract passed to the factory must define `meta.path` matching its location in the root contract.
38
+ *
39
+ * @see {@link https://orpc.dev/docs/contract/client-factory | Contract Client Factory}
40
+ */
31
41
  declare function createContractJsonifiedClientFactory<TClientContext extends ClientContext>(link: ClientLink<TClientContext>, options?: ContractJsonifiedClientFactoryOptions<TClientContext>): ContractJsonifiedClientFactory<TClientContext>;
32
42
 
33
43
  declare const DEFAULT_OPENAPI_METHOD = "POST";
34
- declare const DEFAULT_OPENAPI_SUCCESS_DESCRIPTION = "OK";
35
- declare const DEFAULT_OPENAPI_INPUT_STRUCTURE = "compact";
36
- declare const DEFAULT_OPENAPI_OUTPUT_STRUCTURE = "compact";
37
44
 
38
- /**
39
- * GET and HEAD requests cannot carry a request body,
40
- * so their compact input maps to query parameters instead.
41
- */
42
- declare function isBodylessMethod(method: string): boolean;
43
45
  /**
44
46
  * Dynamic parameters are always returned in path order.
45
47
  */
@@ -64,7 +66,7 @@ interface OpenAPIGeneratorOptions {
64
66
  /**
65
67
  * The serializer used to serialize the generated OpenAPI documentation
66
68
  */
67
- serializer?: Public<OpenAPISerializer> | undefined;
69
+ serializer?: Public<OpenAPIJsonSerializer> | undefined;
68
70
  }
69
71
  interface OpenAPIGeneratorGenerateOptions<TVersion extends OpenAPIVersion> {
70
72
  /**
@@ -91,13 +93,13 @@ interface OpenAPIGeneratorGenerateOptions<TVersion extends OpenAPIVersion> {
91
93
  *
92
94
  * @default defName => defName
93
95
  */
94
- customComponentName?: (defName: string, defSchema: JsonSchema) => string | undefined;
96
+ customComponentName?: ((defName: string, defSchema: JsonSchema) => string | undefined) | undefined;
95
97
  /**
96
98
  * Filter procedures. Return `false` to exclude a procedure from the OpenAPI specification.
97
99
  *
98
100
  * @default true
99
101
  */
100
- filter?: Value<boolean, [contract: AnyProcedureContract | AnyProcedure, path: string[]]>;
102
+ filter?: Value<boolean, [contract: AnyProcedureContract | AnyProcedure, path: string[]]> | undefined;
101
103
  /**
102
104
  * Define a custom JSON schema for the error response body when using
103
105
  * type-safe errors. Helps align ORPC error formatting with existing API
@@ -110,9 +112,10 @@ interface OpenAPIGeneratorGenerateOptions<TVersion extends OpenAPIVersion> {
110
112
  customErrorResponseBodySchema?: Value<JsonSchema | undefined | null, [
111
113
  definedErrors: OpenAPIErrorBodyDefinition[],
112
114
  status: number
113
- ]>;
115
+ ]> | undefined;
114
116
  /**
115
117
  * Mapping ORPCError Code -> HTTP Status Code
118
+ * Codes missing from the map fall back to `DEFAULT_ERROR_STATUS` (400).
116
119
  *
117
120
  * @default COMMON_ERROR_STATUS_MAP
118
121
  */
@@ -140,7 +143,7 @@ interface PopulateRouterContractOpenAPIPathsOptions {
140
143
  /**
141
144
  * Base path segments.
142
145
  */
143
- path?: undefined | string[];
146
+ path?: string[] | undefined;
144
147
  }
145
148
  /**
146
149
  * Automatically populates missing openapi.path using router structure.
@@ -152,5 +155,5 @@ interface PopulateRouterContractOpenAPIPathsOptions {
152
155
  */
153
156
  declare function populateRouterContractOpenAPIPaths<T extends RouterContract>(router: T, options?: PopulateRouterContractOpenAPIPathsOptions): PopulatedContractRouterOpenAPIPaths<T>;
154
157
 
155
- export { DEFAULT_OPENAPI_INPUT_STRUCTURE, DEFAULT_OPENAPI_METHOD, DEFAULT_OPENAPI_OUTPUT_STRUCTURE, DEFAULT_OPENAPI_SUCCESS_DESCRIPTION, JsonifiedClient, OpenAPIDocument, OpenAPIGenerator, OpenAPIGeneratorError, OpenAPISerializer, OpenAPIVersion, createContractJsonifiedClientFactory, getDynamicPathParams, isBodylessMethod, populateRouterContractOpenAPIPaths };
158
+ export { DEFAULT_OPENAPI_METHOD, JsonifiedClient, OpenAPIDocument, OpenAPIGenerator, OpenAPIGeneratorError, OpenAPIJsonSerializer, OpenAPIVersion, createContractJsonifiedClientFactory, getDynamicPathParams, populateRouterContractOpenAPIPaths };
156
159
  export type { ContractJsonifiedClientFactory, ContractJsonifiedClientFactoryOptions, OpenAPIErrorBodyDefinition, OpenAPIGeneratorGenerateOptions, OpenAPIGeneratorOptions, PopulateRouterContractOpenAPIPathsOptions, PopulatedContractRouterOpenAPIPaths };
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_METHOD, OpenAPIGenerator, OpenAPIGeneratorError, OpenAPIJsonSerializer, createContractJsonifiedClientFactory, getDynamicPathParams, getOpenAPIMeta, 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 { O as OpenAPISerializer } from './openapi.YMRD3b4R.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
  *