@orpc/openapi 2.0.0-beta.43 → 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 +56 -57
  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 +19 -43
  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.C6KG7fwg.mjs → openapi.BNe1y1cD.mjs} +14 -9
  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.DcQKf6ur.mjs → openapi.DXqJL3gB.mjs} +11 -22
  32. package/dist/shared/{openapi.PXVenYpE.mjs → openapi.E3ZBiweM.mjs} +12 -13
  33. package/package.json +13 -13
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
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 { O as OpenAPIJsonSerializer } from './shared/openapi.D42Ps1fQ.js';
2
+ export { B as BracketNotationSerializeResult, b as BracketNotationSerializer, c as BracketNotationSerializerOptions, d as OpenAPIJsonSerialization, e as OpenAPIJsonSerializerHandler, f as OpenAPIJsonSerializerOptions, a as OpenAPISerializer, g as OpenAPISerializerOptions, h as OpenAPISerializerSerializeOptions } from './shared/openapi.D42Ps1fQ.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
6
  import { J as JsonifiedClient, O as OpenAPIVersion, a as OpenAPIDocument } from './shared/openapi.BTq9wym2.js';
7
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';
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
10
  import { AnyRouter, AnyProcedure } from '@orpc/server';
11
11
  import { Public, Value } from '@orpc/shared';
@@ -26,7 +26,7 @@ interface ContractJsonifiedClientFactoryOptions<TClientContext extends ClientCon
26
26
  * When provided, the client factory will automatically register the passed contract
27
27
  * into the router at the path defined by `meta.path`.
28
28
  */
29
- contractRef?: undefined | RouterContract;
29
+ contractRef?: RouterContract | undefined;
30
30
  }
31
31
  declare function createContractJsonifiedClientFactory<TClientContext extends ClientContext>(link: ClientLink<TClientContext>, options?: ContractJsonifiedClientFactoryOptions<TClientContext>): ContractJsonifiedClientFactory<TClientContext>;
32
32
 
@@ -64,7 +64,7 @@ interface OpenAPIGeneratorOptions {
64
64
  /**
65
65
  * The serializer used to serialize the generated OpenAPI documentation
66
66
  */
67
- serializer?: Public<OpenAPISerializer> | undefined;
67
+ serializer?: Public<OpenAPIJsonSerializer> | undefined;
68
68
  }
69
69
  interface OpenAPIGeneratorGenerateOptions<TVersion extends OpenAPIVersion> {
70
70
  /**
@@ -91,13 +91,13 @@ interface OpenAPIGeneratorGenerateOptions<TVersion extends OpenAPIVersion> {
91
91
  *
92
92
  * @default defName => defName
93
93
  */
94
- customComponentName?: (defName: string, defSchema: JsonSchema) => string | undefined;
94
+ customComponentName?: ((defName: string, defSchema: JsonSchema) => string | undefined) | undefined;
95
95
  /**
96
96
  * Filter procedures. Return `false` to exclude a procedure from the OpenAPI specification.
97
97
  *
98
98
  * @default true
99
99
  */
100
- filter?: Value<boolean, [contract: AnyProcedureContract | AnyProcedure, path: string[]]>;
100
+ filter?: Value<boolean, [contract: AnyProcedureContract | AnyProcedure, path: string[]]> | undefined;
101
101
  /**
102
102
  * Define a custom JSON schema for the error response body when using
103
103
  * type-safe errors. Helps align ORPC error formatting with existing API
@@ -110,9 +110,10 @@ interface OpenAPIGeneratorGenerateOptions<TVersion extends OpenAPIVersion> {
110
110
  customErrorResponseBodySchema?: Value<JsonSchema | undefined | null, [
111
111
  definedErrors: OpenAPIErrorBodyDefinition[],
112
112
  status: number
113
- ]>;
113
+ ]> | undefined;
114
114
  /**
115
115
  * Mapping ORPCError Code -> HTTP Status Code
116
+ * Codes missing from the map fall back to `DEFAULT_ERROR_STATUS` (400).
116
117
  *
117
118
  * @default COMMON_ERROR_STATUS_MAP
118
119
  */
@@ -140,7 +141,7 @@ interface PopulateRouterContractOpenAPIPathsOptions {
140
141
  /**
141
142
  * Base path segments.
142
143
  */
143
- path?: undefined | string[];
144
+ path?: string[] | undefined;
144
145
  }
145
146
  /**
146
147
  * Automatically populates missing openapi.path using router structure.
@@ -152,5 +153,5 @@ interface PopulateRouterContractOpenAPIPathsOptions {
152
153
  */
153
154
  declare function populateRouterContractOpenAPIPaths<T extends RouterContract>(router: T, options?: PopulateRouterContractOpenAPIPathsOptions): PopulatedContractRouterOpenAPIPaths<T>;
154
155
 
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 };
156
+ export { DEFAULT_OPENAPI_INPUT_STRUCTURE, DEFAULT_OPENAPI_METHOD, DEFAULT_OPENAPI_OUTPUT_STRUCTURE, DEFAULT_OPENAPI_SUCCESS_DESCRIPTION, JsonifiedClient, OpenAPIDocument, OpenAPIGenerator, OpenAPIGeneratorError, OpenAPIJsonSerializer, OpenAPIVersion, createContractJsonifiedClientFactory, getDynamicPathParams, isBodylessMethod, populateRouterContractOpenAPIPaths };
156
157
  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, value, findDeepMatches, isPlainObject, 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 = {}) {
@@ -127,17 +127,14 @@ function componentNameCandidate(preferredName, direction, attempt) {
127
127
  function definedKeysOf(object) {
128
128
  return Object.keys(object).filter((key) => object[key] !== void 0).sort();
129
129
  }
130
+ function isSchemaContainer(value) {
131
+ return Array.isArray(value) || isPlainObject(value);
132
+ }
130
133
  function areSchemasEquivalentForReuse(candidate, existing, ctx) {
131
134
  if (candidate === existing) {
132
135
  return true;
133
136
  }
134
- if (typeof candidate !== typeof existing) {
135
- return false;
136
- }
137
- if (candidate === null || existing === null) {
138
- return candidate === existing;
139
- }
140
- if (typeof candidate !== "object" || typeof existing !== "object") {
137
+ if (!isSchemaContainer(candidate) || !isSchemaContainer(existing)) {
141
138
  return isDeepEqual(candidate, existing);
142
139
  }
143
140
  const seenExisting = ctx.visited.get(candidate);
@@ -236,15 +233,15 @@ function buildRequest(ctx, operation, def, meta, dynamicPathParams) {
236
233
  const method = meta?.method ?? DEFAULT_OPENAPI_METHOD;
237
234
  const inputStructure = meta?.inputStructure ?? DEFAULT_OPENAPI_INPUT_STRUCTURE;
238
235
  if (inputStructure === "compact") {
239
- const iteratorDetails = getAsyncIteratorObjectDetails(def.inputSchemas);
236
+ const iteratorDetails = getAsyncIteratorObjectSchemasDetails(def.inputSchemas);
240
237
  if (iteratorDetails) {
241
238
  operation.requestBody = {
242
239
  required: true,
243
240
  content: toAsyncIteratorObjectContent(
244
241
  ctx,
245
242
  "input",
246
- ctx.convertSchemas(iteratorDetails[0], "input"),
247
- ctx.convertSchemas(iteratorDetails[1], "input")
243
+ ctx.convertSchemas(iteratorDetails.yieldSchemas, "input"),
244
+ ctx.convertSchemas(iteratorDetails.returnSchemas, "input")
248
245
  )
249
246
  };
250
247
  return;
@@ -398,7 +395,7 @@ function buildSuccessResponse(ctx, operation, def, meta) {
398
395
  const description = meta?.successDescription ?? DEFAULT_OPENAPI_SUCCESS_DESCRIPTION;
399
396
  const outputStructure = meta?.outputStructure ?? DEFAULT_OPENAPI_OUTPUT_STRUCTURE;
400
397
  if (outputStructure === "compact") {
401
- const iteratorDetails = getAsyncIteratorObjectDetails(def.outputSchemas);
398
+ const iteratorDetails = getAsyncIteratorObjectSchemasDetails(def.outputSchemas);
402
399
  if (iteratorDetails) {
403
400
  operation.responses ??= {};
404
401
  operation.responses[toResponseStatusKey(status)] = {
@@ -406,8 +403,8 @@ function buildSuccessResponse(ctx, operation, def, meta) {
406
403
  content: toAsyncIteratorObjectContent(
407
404
  ctx,
408
405
  "output",
409
- ctx.convertSchemas(iteratorDetails[0], "output"),
410
- ctx.convertSchemas(iteratorDetails[1], "output")
406
+ ctx.convertSchemas(iteratorDetails.yieldSchemas, "output"),
407
+ ctx.convertSchemas(iteratorDetails.returnSchemas, "output")
411
408
  )
412
409
  };
413
410
  return;
@@ -577,24 +574,6 @@ function toErrorComponentName(code) {
577
574
  }).join("");
578
575
  return name || "Error";
579
576
  }
580
- function getAsyncIteratorObjectDetails(schemas) {
581
- if (!schemas || schemas.length === 0) {
582
- return void 0;
583
- }
584
- const yieldSchemas = [];
585
- const returnSchemas = [];
586
- for (const s of schemas) {
587
- const details = getAsyncIteratorObjectSchemaDetails(s);
588
- if (!details) {
589
- return void 0;
590
- }
591
- yieldSchemas.push(details.yieldSchema);
592
- if (details.returnSchema) {
593
- returnSchemas.push(details.returnSchema);
594
- }
595
- }
596
- return [yieldSchemas, returnSchemas];
597
- }
598
577
  function toAsyncIteratorObjectContent(ctx, direction, [yieldSchema, yieldOptional], [returnSchema, returnOptional]) {
599
578
  const schema = combineJsonSchemasWithComposition("oneOf", [
600
579
  combineJsonObjectSchemaEntries([
@@ -644,10 +623,7 @@ function toBodyContent(ctx, direction, schema) {
644
623
  const content = {};
645
624
  if (rest.length > 0) {
646
625
  const restSchema = fileSchemasByMediaType.size ? combineJsonSchemasWithComposition("anyOf", rest) : schema;
647
- const hasNestedFiles = findDeepMatches(
648
- (v) => isPlainObject(v) && isJsonFileSchema(v),
649
- restSchema
650
- ).values.length > 0;
626
+ const hasNestedFiles = containsJsonFileSchema(restSchema);
651
627
  const contentType = hasNestedFiles ? "multipart/form-data" : "application/json";
652
628
  const fileSchemas = fileSchemasByMediaType.get(contentType);
653
629
  fileSchemasByMediaType.delete(contentType);
@@ -667,7 +643,7 @@ class OpenAPIGenerator {
667
643
  serializer;
668
644
  converter;
669
645
  constructor(options = {}) {
670
- this.serializer = options.serializer ?? new OpenAPISerializer();
646
+ this.serializer = options.serializer ?? new OpenAPIJsonSerializer();
671
647
  this.converter = new DelegatingJsonSchemaConverter([
672
648
  ...toArray(options.converters),
673
649
  new StandardJsonSchemaConverter()
@@ -740,7 +716,7 @@ ${errors.join("\n\n")}`
740
716
  );
741
717
  }
742
718
  const versioned = toVersionedOpenAPIDocument(doc, version);
743
- return this.serializer.serialize(versioned, { asFormData: false, useFormDataForBlobFields: false });
719
+ return this.serializer.serializeJson(versioned).json;
744
720
  }
745
721
  convertSchema(schema, direction) {
746
722
  const [jsonSchema, optional] = this.converter.convert(schema, direction);
@@ -799,4 +775,4 @@ function populateRouterContractOpenAPIPaths(router, options = {}) {
799
775
  return populated;
800
776
  }
801
777
 
802
- 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 { createORPCErrorFromMalformedResponse, 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.DcQKf6ur.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}(?:\/|$)/;
@@ -149,6 +149,9 @@ class OpenAPILinkCodec {
149
149
  if (DOT_SEGMENT_REGEX.test(encoded)) {
150
150
  throw new TypeError(`Path param "${param.parameterName}" cannot contain "." or ".." segments in call to procedure (${path.join(".")}).`);
151
151
  }
152
+ if (encoded.startsWith("/")) {
153
+ encoded = `%2F${encoded.slice(1)}`;
154
+ }
152
155
  return encoded;
153
156
  }
154
157
  serializeQueryString(data, queryStyles) {
@@ -254,7 +257,7 @@ class OpenAPILinkCodec {
254
257
  try {
255
258
  return this.serializer.deserialize(body);
256
259
  } catch (error) {
257
- throw createORPCErrorFromMalformedResponse({
260
+ throw new MalformedResponseError({
258
261
  message: "Invalid OpenAPI response format.",
259
262
  response: { status: response.status, headers: response.headers, body },
260
263
  cause: error
@@ -267,12 +270,14 @@ class OpenAPILinkCodec {
267
270
  return { kind: "error", error: customError };
268
271
  }
269
272
  if (isORPCErrorJson(deserialized)) {
270
- 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
+ };
271
279
  }
272
- return {
273
- kind: "error",
274
- error: createORPCErrorFromMalformedResponse({ response: { headers: response.headers, status: response.status, body } })
275
- };
280
+ throw new MalformedResponseError({ response: { headers: response.headers, status: response.status, body } });
276
281
  }
277
282
  const outputStructure = meta?.outputStructure ?? DEFAULT_OPENAPI_OUTPUT_STRUCTURE;
278
283
  return outputStructure === "compact" ? { kind: "output", output: deserialized } : {
@@ -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.