@orpc/openapi 1.14.11 → 1.14.12

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 (48) hide show
  1. package/README.md +71 -52
  2. package/dist/adapters/aws-lambda/index.d.mts +20 -0
  3. package/dist/adapters/aws-lambda/index.d.ts +20 -0
  4. package/dist/adapters/aws-lambda/index.mjs +18 -0
  5. package/dist/adapters/fastify/index.d.mts +23 -0
  6. package/dist/adapters/fastify/index.d.ts +23 -0
  7. package/dist/adapters/fastify/index.mjs +18 -0
  8. package/dist/adapters/fetch/index.d.mts +16 -20
  9. package/dist/adapters/fetch/index.d.ts +16 -20
  10. package/dist/adapters/fetch/index.mjs +8 -24
  11. package/dist/adapters/node/index.d.mts +13 -8
  12. package/dist/adapters/node/index.d.ts +13 -8
  13. package/dist/adapters/node/index.mjs +7 -10
  14. package/dist/adapters/standard/index.d.mts +16 -46
  15. package/dist/adapters/standard/index.d.ts +16 -46
  16. package/dist/adapters/standard/index.mjs +6 -9
  17. package/dist/index.d.mts +105 -117
  18. package/dist/index.d.ts +105 -117
  19. package/dist/index.mjs +32 -850
  20. package/dist/plugins/index.d.mts +51 -55
  21. package/dist/plugins/index.d.ts +51 -55
  22. package/dist/plugins/index.mjs +142 -147
  23. package/dist/shared/openapi.BGy4N6eR.d.mts +120 -0
  24. package/dist/shared/openapi.BGy4N6eR.d.ts +120 -0
  25. package/dist/shared/openapi.BwdtJjDu.mjs +878 -0
  26. package/dist/shared/openapi.CdeSk3f7.d.mts +54 -0
  27. package/dist/shared/openapi.CdeSk3f7.d.ts +54 -0
  28. package/dist/shared/openapi.DPiCV5hl.mjs +208 -0
  29. package/package.json +24 -46
  30. package/dist/extensions/route.d.mts +0 -43
  31. package/dist/extensions/route.d.ts +0 -43
  32. package/dist/extensions/route.mjs +0 -14
  33. package/dist/helpers/index.d.mts +0 -51
  34. package/dist/helpers/index.d.ts +0 -51
  35. package/dist/helpers/index.mjs +0 -39
  36. package/dist/shared/openapi.B6hEbRyF.d.ts +0 -83
  37. package/dist/shared/openapi.B9PQzqBn.mjs +0 -49
  38. package/dist/shared/openapi.BOOA-bde.d.mts +0 -142
  39. package/dist/shared/openapi.BOOA-bde.d.ts +0 -142
  40. package/dist/shared/openapi.BafbB3uM.d.mts +0 -83
  41. package/dist/shared/openapi.Bt87OzTt.mjs +0 -131
  42. package/dist/shared/openapi.ByT4oUeY.d.mts +0 -18
  43. package/dist/shared/openapi.ByT4oUeY.d.ts +0 -18
  44. package/dist/shared/openapi.C-p_Q2lb.mjs +0 -359
  45. package/dist/shared/openapi.CVgUshDP.mjs +0 -318
  46. package/dist/shared/openapi.DNNo0V-l.d.ts +0 -313
  47. package/dist/shared/openapi.hg_rhZ4x.d.mts +0 -313
  48. package/dist/shared/openapi.zZH_UksW.mjs +0 -278
@@ -1,50 +1,20 @@
1
- export { a as OpenAPIHandlerCodec, b as OpenAPIHandlerCodecCore, c as OpenAPIHandlerCodecCoreOptions, O as OpenAPIHandlerCodecOptions, d as OpenAPIMatcher, e as OpenAPIMatcherOptions } from '../../shared/openapi.B6hEbRyF.js';
2
- import { ClientContext, ClientOptions, AnyORPCError } from '@orpc/client';
3
- import { StandardLinkCodec, StandardLinkCodecDecodedResponse } from '@orpc/client/standard';
4
- import { RouterContract } from '@orpc/contract';
5
- import { Value, Promisable } from '@orpc/shared';
6
- import { StandardUrl, StandardHeaders, StandardLazyResponse, StandardRequest } from '@standardserver/core';
7
- import { O as OpenAPISerializer } from '../../shared/openapi.BOOA-bde.js';
1
+ export { a as StandardOpenAPICodec, S as StandardOpenAPICodecOptions, c as StandardOpenAPIHandler, b as StandardOpenAPIHandlerOptions, e as StandardOpenAPIMatcher, d as StandardOpenAPIMatcherOptions } from '../../shared/openapi.CdeSk3f7.js';
2
+ import { HTTPPath } from '@orpc/client';
3
+ import '@orpc/openapi-client/standard';
8
4
  import '@orpc/server';
9
5
  import '@orpc/server/standard';
6
+ import '@orpc/standard-server';
7
+ import '@orpc/shared';
10
8
 
11
- declare class OpenAPILinkCodecError extends TypeError {
12
- }
13
- interface OpenAPILinkCodecOptions<T extends ClientContext> {
14
- /**
15
- * Base URL for all requests, without origin. Should match the OpenAPI handler mount path.
16
- *
17
- * @example '/api'
18
- * @default '/'
19
- */
20
- url?: Value<Promisable<StandardUrl>, [options: ClientOptions<T>, path: string[], input: unknown]>;
21
- /**
22
- * Inject headers into the request.
23
- */
24
- headers?: Value<Promisable<StandardHeaders | Headers>, [options: ClientOptions<T>, path: string[], input: unknown]>;
25
- /**
26
- * Override the default OpenAPI serializer.
27
- */
28
- serializer?: Pick<OpenAPISerializer, keyof OpenAPISerializer>;
29
- /**
30
- * Customize how an error response body is converted into an ORPC error.
31
- * Return `null` or `undefined` to fall back to the default decoding behavior.
32
- */
33
- customErrorResponseBodyDecoder?: (deserializedBody: unknown, response: StandardLazyResponse) => AnyORPCError | null | undefined;
34
- }
35
- declare class OpenAPILinkCodec<T extends ClientContext> implements StandardLinkCodec<T> {
36
- private readonly router;
37
- private readonly baseUrl;
38
- private readonly headers;
39
- private readonly serializer;
40
- private readonly customErrorResponseBodyDecoder;
41
- constructor(router: RouterContract, options?: OpenAPILinkCodecOptions<T>);
42
- encodeInput(input: unknown, path: string[], options: ClientOptions<T>): Promise<StandardRequest>;
43
- private encodePathParam;
44
- private serializeQueryString;
45
- decodeResponse(response: StandardLazyResponse, path: string[], _options: ClientOptions<T>): Promise<StandardLinkCodecDecodedResponse>;
46
- private resolveProcedure;
47
- }
9
+ /**
10
+ * {@link https://github.com/unjs/rou3}
11
+ *
12
+ * @internal
13
+ */
14
+ declare function toRou3Pattern(path: HTTPPath): string;
15
+ /**
16
+ * @internal
17
+ */
18
+ declare function decodeParams(params: Record<string, string>): Record<string, string>;
48
19
 
49
- export { OpenAPILinkCodec, OpenAPILinkCodecError };
50
- export type { OpenAPILinkCodecOptions };
20
+ export { decodeParams, toRou3Pattern };
@@ -1,12 +1,9 @@
1
- export { O as OpenAPIHandlerCodec, a as OpenAPIHandlerCodecCore, b as OpenAPIMatcher } from '../../shared/openapi.CVgUshDP.mjs';
2
- export { O as OpenAPILinkCodec, a as OpenAPILinkCodecError } from '../../shared/openapi.C-p_Q2lb.mjs';
1
+ export { S as StandardOpenAPICodec, a as StandardOpenAPIHandler, b as StandardOpenAPIMatcher, d as decodeParams, t as toRou3Pattern } from '../../shared/openapi.DPiCV5hl.mjs';
2
+ import '@orpc/openapi-client/standard';
3
+ import '@orpc/server/standard';
3
4
  import '@orpc/client';
4
- import '@orpc/server';
5
+ import '@orpc/contract';
5
6
  import '@orpc/shared';
6
- import '@standardserver/core';
7
- import '../../shared/openapi.zZH_UksW.mjs';
8
- import '../../shared/openapi.Bt87OzTt.mjs';
9
- import '../../shared/openapi.B9PQzqBn.mjs';
7
+ import '@orpc/client/standard';
8
+ import '@orpc/server';
10
9
  import 'rou3';
11
- import '@orpc/contract';
12
- import '@standardserver/fetch';
package/dist/index.d.mts CHANGED
@@ -1,129 +1,117 @@
1
- import { O as OpenAPISerializer } from './shared/openapi.BOOA-bde.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.BOOA-bde.mjs';
3
- import { ClientContext, ORPCClientOptions, ClientLink } from '@orpc/client';
4
- export { COMMON_ERROR_STATUS_MAP } from '@orpc/client';
5
- import { RouterContract, RouterContractClient, AnyProcedureContract, ProcedureContract } from '@orpc/contract';
6
- import { J as JsonifiedClient, a as OpenAPIDocument } from './shared/openapi.ByT4oUeY.mjs';
7
- export { b as JsonifiedArray, c as JsonifiedClientError, d as JsonifiedValue, O as OpenAPIOperationObject } from './shared/openapi.ByT4oUeY.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.hg_rhZ4x.mjs';
9
- import { JsonSchema, JsonSchemaConverter } from '@orpc/json-schema';
10
- import { AnyRouter, AnyProcedure } from '@orpc/server';
11
- import { Value } from '@orpc/shared';
12
- export { StandardBodyHint } from '@standardserver/core';
13
- import '@hey-api/spec-types';
1
+ import { OpenAPI, AnyContractProcedure } from '@orpc/contract';
2
+ export { OpenAPI } from '@orpc/contract';
3
+ export { e as CompositeSchemaConverter, C as ConditionalSchemaConverter, b as OpenAPIGenerator, a as OpenAPIGeneratorGenerateOptions, O as OpenAPIGeneratorOptions, c as SchemaConvertOptions, d as SchemaConverter, S as SchemaConverterComponent } from './shared/openapi.BGy4N6eR.mjs';
4
+ import { HTTPPath, HTTPMethod } from '@orpc/client';
5
+ import { JSONSchema } from 'json-schema-typed/draft-2020-12';
6
+ export { JSONSchema, ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from 'json-schema-typed/draft-2020-12';
7
+ import { JsonifiedClient } from '@orpc/openapi-client';
8
+ import { AnyRouter, ClientContext, Lazyable, CreateProcedureClientOptions, InferRouterInitialContext, Schema, ErrorMap, Meta, RouterClient } from '@orpc/server';
9
+ import { MaybeOptionalOptions } from '@orpc/shared';
10
+ import '@orpc/openapi-client/standard';
14
11
 
15
- interface ContractJsonifiedClientFactory<TClientContext extends ClientContext> {
16
- <T extends RouterContract>(contract: T): JsonifiedClient<RouterContractClient<T, TClientContext>>;
17
- }
18
- interface ContractJsonifiedClientFactoryOptions<TClientContext extends ClientContext> extends Pick<ORPCClientOptions<JsonifiedClient<RouterContractClient<RouterContract, TClientContext>>>, 'interceptors' | 'scoped'> {
19
- /**
20
- * An optional reference to the root router-contract.
21
- * When provided, the client factory will automatically register the passed contract
22
- * into the router at the path defined by `meta.path`.
23
- */
24
- contractRef?: undefined | RouterContract;
25
- }
26
- declare function createContractJsonifiedClientFactory<TClientContext extends ClientContext>(link: ClientLink<TClientContext>, options?: ContractJsonifiedClientFactoryOptions<TClientContext>): ContractJsonifiedClientFactory<TClientContext>;
12
+ type OverrideOperationValue = Partial<OpenAPI.OperationObject> | ((current: OpenAPI.OperationObject, procedure: AnyContractProcedure) => OpenAPI.OperationObject);
13
+ /**
14
+ * Customize The Operation Object by proxy an error map item or a middleware.
15
+ *
16
+ * @see {@link https://orpc.dev/docs/openapi/openapi-specification#customizing-operation-objects Customizing Operation Objects Docs}
17
+ */
18
+ declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
19
+ declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
20
+ declare function applyCustomOpenAPIOperation(operation: OpenAPI.OperationObject, contract: AnyContractProcedure): OpenAPI.OperationObject;
27
21
 
28
- declare const DEFAULT_OPENAPI_METHOD = "POST";
29
- declare const DEFAULT_OPENAPI_SUCCESS_DESCRIPTION = "OK";
30
- declare const DEFAULT_OPENAPI_INPUT_STRUCTURE = "compact";
31
- declare const DEFAULT_OPENAPI_OUTPUT_STRUCTURE = "compact";
22
+ /**
23
+ * @internal
24
+ */
25
+ type ObjectSchema = JSONSchema & {
26
+ type: 'object';
27
+ } & object;
28
+ /**
29
+ * @internal
30
+ */
31
+ type FileSchema = JSONSchema & {
32
+ type: 'string';
33
+ contentMediaType: string;
34
+ } & object;
35
+ /**
36
+ * @internal
37
+ */
38
+ declare const LOGIC_KEYWORDS: string[];
32
39
 
33
40
  /**
34
- * GET and HEAD requests cannot carry a request body,
35
- * so their compact input maps to query parameters instead.
41
+ * @internal
42
+ */
43
+ declare function toOpenAPIPath(path: HTTPPath): string;
44
+ /**
45
+ * @internal
46
+ */
47
+ declare function toOpenAPIMethod(method: HTTPMethod): Lowercase<HTTPMethod>;
48
+ /**
49
+ * @internal
50
+ */
51
+ declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPI.MediaTypeObject>;
52
+ /**
53
+ * @internal
54
+ */
55
+ declare function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema]): Record<string, OpenAPI.MediaTypeObject>;
56
+ /**
57
+ * @internal
58
+ */
59
+ declare function toOpenAPIParameters(schema: ObjectSchema, parameterIn: 'path' | 'query' | 'header' | 'cookie'): OpenAPI.ParameterObject[];
60
+ /**
61
+ * @internal
36
62
  */
37
- declare function isBodylessMethod(method: string): boolean;
63
+ declare function checkParamsSchema(schema: ObjectSchema, params: string[]): boolean;
38
64
  /**
39
- * Dynamic parameters are always returned in path order.
65
+ * @internal
40
66
  */
41
- declare function getDynamicPathParams(path: `/${string}`): {
42
- segment: string;
43
- startIndex: number;
44
- parameterName: string;
45
- allowsSlash: boolean;
46
- }[] | undefined;
67
+ declare function toOpenAPISchema(schema: JSONSchema): OpenAPI.SchemaObject & object;
68
+ declare function resolveOpenAPIJsonSchemaRef(doc: OpenAPI.Document, schema: JSONSchema): JSONSchema;
69
+ /**
70
+ * Simplifies composed object JSON Schemas (using anyOf, oneOf, allOf) by flattening nested compositions
71
+ *
72
+ * @warning The result is looser than the original schema and may not fully validate the same data.
73
+ */
74
+ declare function simplifyComposedObjectJsonSchemasAndRefs(schema: JSONSchema, doc?: OpenAPI.Document): JSONSchema;
47
75
 
48
- declare class OpenAPIGeneratorError extends TypeError {
49
- }
50
- interface OpenAPIErrorBodyDefinition {
51
- code: string;
52
- defaultMessage: string | undefined;
53
- dataOptional: boolean;
54
- dataJsonSchema: JsonSchema;
55
- }
76
+ declare function createJsonifiedRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>, Schema<unknown, unknown>, ErrorMap, Meta, TClientContext>>): JsonifiedClient<RouterClient<T, TClientContext>>;
56
77
 
57
- interface OpenAPIGeneratorOptions {
58
- converters?: JsonSchemaConverter[] | undefined;
59
- /**
60
- * The serializer used to serialize the generated OpenAPI documentation
61
- */
62
- serializer?: Pick<OpenAPISerializer, keyof OpenAPISerializer> | undefined;
63
- }
64
- interface OpenAPIGeneratorGenerateOptions {
65
- base?: Partial<OpenAPIDocument> | undefined;
66
- /**
67
- * Root-level `$defs` are always moved into `components.schemas`.
68
- * Use this to customize the component name of a hoisted def.
69
- *
70
- * @remarks
71
- * - The returned name is a preference, conflicting names are still postfixed (`Planet`, `PlanetInput`, `Planet2`, ...).
72
- * - Return `undefined` to keep the original def name.
73
- *
74
- * @default defName => defName
75
- */
76
- customComponentName?: (defName: string, defSchema: JsonSchema) => string | undefined;
77
- /**
78
- * Filter procedures. Return `false` to exclude a procedure from the OpenAPI specification.
79
- *
80
- * @default true
81
- */
82
- filter?: Value<boolean, [contract: AnyProcedureContract | AnyProcedure, path: string[]]>;
83
- /**
84
- * Define a custom JSON schema for the error response body when using
85
- * type-safe errors. Helps align ORPC error formatting with existing API
86
- * response standards or conventions.
87
- *
88
- * @remarks
89
- * - Return `null | undefined` to use the default error response body shaper.
90
- */
91
- customErrorResponseBodySchema?: Value<JsonSchema | undefined | null, [
92
- definedErrors: OpenAPIErrorBodyDefinition[],
93
- status: number
94
- ]>;
95
- /**
96
- * Mapping ORPCError Code -> HTTP Status Code
97
- *
98
- * @default COMMON_ERROR_STATUS_MAP
99
- */
100
- errorStatusMap?: Record<string, number> | undefined;
101
- }
102
- declare class OpenAPIGenerator {
103
- private readonly serializer;
104
- private readonly converter;
105
- constructor(options?: OpenAPIGeneratorOptions);
106
- generate(router: RouterContract | AnyRouter, options?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPIDocument>;
107
- private convertSchema;
108
- private convertSchemas;
109
- }
78
+ /**
79
+ *@internal
80
+ */
81
+ declare function isFileSchema(schema: JSONSchema): schema is FileSchema;
82
+ /**
83
+ * @internal
84
+ */
85
+ declare function isObjectSchema(schema: JSONSchema): schema is ObjectSchema;
86
+ /**
87
+ * @internal
88
+ */
89
+ declare function isAnySchema(schema: JSONSchema): boolean;
90
+ declare function isNeverSchema(schema: JSONSchema): boolean;
91
+ /**
92
+ * @internal
93
+ */
94
+ declare function separateObjectSchema(schema: ObjectSchema, separatedProperties: string[]): [matched: ObjectSchema, rest: ObjectSchema];
95
+ /**
96
+ * @internal
97
+ */
98
+ declare function filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
99
+ declare function applySchemaOptionality(required: boolean, schema: JSONSchema): JSONSchema;
100
+ /**
101
+ * Takes a JSON schema and, if it's primarily a union type (anyOf, oneOf),
102
+ * recursively expands it into an array of its constituent, non-union base schemas.
103
+ * If the schema is not a simple union or is a base type, it's returned as a single-element array.
104
+ */
105
+ declare function expandUnionSchema(schema: JSONSchema): JSONSchema[];
106
+ declare function expandArrayableSchema(schema: JSONSchema): undefined | [items: JSONSchema, array: JSONSchema & {
107
+ type: 'array';
108
+ items?: JSONSchema;
109
+ }];
110
+ declare function isPrimitiveSchema(schema: JSONSchema): boolean;
110
111
 
111
- type PopulatedContractRouterOpenAPIPaths<T extends RouterContract> = T extends ProcedureContract<infer UInputSchema, infer UOutputSchema, infer UErrors> ? ProcedureContract<UInputSchema, UOutputSchema, UErrors> : {
112
- [K in keyof T]: T[K] extends RouterContract ? PopulatedContractRouterOpenAPIPaths<T[K]> : never;
112
+ declare const oo: {
113
+ spec: typeof customOpenAPIOperation;
113
114
  };
114
- interface PopulateRouterContractOpenAPIPathsOptions {
115
- /**
116
- * Base path segments.
117
- */
118
- path?: undefined | string[];
119
- }
120
- /**
121
- * Automatically populates missing openapi.path using router structure.
122
- *
123
- * Builds paths by joining router keys with `/`.
124
- * Useful when you want to ensure all contracts define openapi.path, such as for NestJS integration requirements.
125
- */
126
- declare function populateRouterContractOpenAPIPaths<T extends RouterContract>(router: T, options?: PopulateRouterContractOpenAPIPathsOptions): PopulatedContractRouterOpenAPIPaths<T>;
127
115
 
128
- export { DEFAULT_OPENAPI_INPUT_STRUCTURE, DEFAULT_OPENAPI_METHOD, DEFAULT_OPENAPI_OUTPUT_STRUCTURE, DEFAULT_OPENAPI_SUCCESS_DESCRIPTION, JsonifiedClient, OpenAPIDocument, OpenAPIGenerator, OpenAPIGeneratorError, OpenAPISerializer, createContractJsonifiedClientFactory, getDynamicPathParams, isBodylessMethod, populateRouterContractOpenAPIPaths };
129
- export type { ContractJsonifiedClientFactory, ContractJsonifiedClientFactoryOptions, OpenAPIErrorBodyDefinition, OpenAPIGeneratorGenerateOptions, OpenAPIGeneratorOptions, PopulateRouterContractOpenAPIPathsOptions, PopulatedContractRouterOpenAPIPaths };
116
+ export { LOGIC_KEYWORDS, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, createJsonifiedRouterClient, customOpenAPIOperation, expandArrayableSchema, expandUnionSchema, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isNeverSchema, isObjectSchema, isPrimitiveSchema, oo, resolveOpenAPIJsonSchemaRef, separateObjectSchema, simplifyComposedObjectJsonSchemasAndRefs, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
117
+ export type { FileSchema, ObjectSchema, OverrideOperationValue };
package/dist/index.d.ts CHANGED
@@ -1,129 +1,117 @@
1
- import { O as OpenAPISerializer } from './shared/openapi.BOOA-bde.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.BOOA-bde.js';
3
- import { ClientContext, ORPCClientOptions, ClientLink } from '@orpc/client';
4
- export { COMMON_ERROR_STATUS_MAP } from '@orpc/client';
5
- import { RouterContract, RouterContractClient, AnyProcedureContract, ProcedureContract } from '@orpc/contract';
6
- import { J as JsonifiedClient, a as OpenAPIDocument } from './shared/openapi.ByT4oUeY.js';
7
- export { b as JsonifiedArray, c as JsonifiedClientError, d as JsonifiedValue, O as OpenAPIOperationObject } from './shared/openapi.ByT4oUeY.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.DNNo0V-l.js';
9
- import { JsonSchema, JsonSchemaConverter } from '@orpc/json-schema';
10
- import { AnyRouter, AnyProcedure } from '@orpc/server';
11
- import { Value } from '@orpc/shared';
12
- export { StandardBodyHint } from '@standardserver/core';
13
- import '@hey-api/spec-types';
1
+ import { OpenAPI, AnyContractProcedure } from '@orpc/contract';
2
+ export { OpenAPI } from '@orpc/contract';
3
+ export { e as CompositeSchemaConverter, C as ConditionalSchemaConverter, b as OpenAPIGenerator, a as OpenAPIGeneratorGenerateOptions, O as OpenAPIGeneratorOptions, c as SchemaConvertOptions, d as SchemaConverter, S as SchemaConverterComponent } from './shared/openapi.BGy4N6eR.js';
4
+ import { HTTPPath, HTTPMethod } from '@orpc/client';
5
+ import { JSONSchema } from 'json-schema-typed/draft-2020-12';
6
+ export { JSONSchema, ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from 'json-schema-typed/draft-2020-12';
7
+ import { JsonifiedClient } from '@orpc/openapi-client';
8
+ import { AnyRouter, ClientContext, Lazyable, CreateProcedureClientOptions, InferRouterInitialContext, Schema, ErrorMap, Meta, RouterClient } from '@orpc/server';
9
+ import { MaybeOptionalOptions } from '@orpc/shared';
10
+ import '@orpc/openapi-client/standard';
14
11
 
15
- interface ContractJsonifiedClientFactory<TClientContext extends ClientContext> {
16
- <T extends RouterContract>(contract: T): JsonifiedClient<RouterContractClient<T, TClientContext>>;
17
- }
18
- interface ContractJsonifiedClientFactoryOptions<TClientContext extends ClientContext> extends Pick<ORPCClientOptions<JsonifiedClient<RouterContractClient<RouterContract, TClientContext>>>, 'interceptors' | 'scoped'> {
19
- /**
20
- * An optional reference to the root router-contract.
21
- * When provided, the client factory will automatically register the passed contract
22
- * into the router at the path defined by `meta.path`.
23
- */
24
- contractRef?: undefined | RouterContract;
25
- }
26
- declare function createContractJsonifiedClientFactory<TClientContext extends ClientContext>(link: ClientLink<TClientContext>, options?: ContractJsonifiedClientFactoryOptions<TClientContext>): ContractJsonifiedClientFactory<TClientContext>;
12
+ type OverrideOperationValue = Partial<OpenAPI.OperationObject> | ((current: OpenAPI.OperationObject, procedure: AnyContractProcedure) => OpenAPI.OperationObject);
13
+ /**
14
+ * Customize The Operation Object by proxy an error map item or a middleware.
15
+ *
16
+ * @see {@link https://orpc.dev/docs/openapi/openapi-specification#customizing-operation-objects Customizing Operation Objects Docs}
17
+ */
18
+ declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
19
+ declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
20
+ declare function applyCustomOpenAPIOperation(operation: OpenAPI.OperationObject, contract: AnyContractProcedure): OpenAPI.OperationObject;
27
21
 
28
- declare const DEFAULT_OPENAPI_METHOD = "POST";
29
- declare const DEFAULT_OPENAPI_SUCCESS_DESCRIPTION = "OK";
30
- declare const DEFAULT_OPENAPI_INPUT_STRUCTURE = "compact";
31
- declare const DEFAULT_OPENAPI_OUTPUT_STRUCTURE = "compact";
22
+ /**
23
+ * @internal
24
+ */
25
+ type ObjectSchema = JSONSchema & {
26
+ type: 'object';
27
+ } & object;
28
+ /**
29
+ * @internal
30
+ */
31
+ type FileSchema = JSONSchema & {
32
+ type: 'string';
33
+ contentMediaType: string;
34
+ } & object;
35
+ /**
36
+ * @internal
37
+ */
38
+ declare const LOGIC_KEYWORDS: string[];
32
39
 
33
40
  /**
34
- * GET and HEAD requests cannot carry a request body,
35
- * so their compact input maps to query parameters instead.
41
+ * @internal
42
+ */
43
+ declare function toOpenAPIPath(path: HTTPPath): string;
44
+ /**
45
+ * @internal
46
+ */
47
+ declare function toOpenAPIMethod(method: HTTPMethod): Lowercase<HTTPMethod>;
48
+ /**
49
+ * @internal
50
+ */
51
+ declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPI.MediaTypeObject>;
52
+ /**
53
+ * @internal
54
+ */
55
+ declare function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema]): Record<string, OpenAPI.MediaTypeObject>;
56
+ /**
57
+ * @internal
58
+ */
59
+ declare function toOpenAPIParameters(schema: ObjectSchema, parameterIn: 'path' | 'query' | 'header' | 'cookie'): OpenAPI.ParameterObject[];
60
+ /**
61
+ * @internal
36
62
  */
37
- declare function isBodylessMethod(method: string): boolean;
63
+ declare function checkParamsSchema(schema: ObjectSchema, params: string[]): boolean;
38
64
  /**
39
- * Dynamic parameters are always returned in path order.
65
+ * @internal
40
66
  */
41
- declare function getDynamicPathParams(path: `/${string}`): {
42
- segment: string;
43
- startIndex: number;
44
- parameterName: string;
45
- allowsSlash: boolean;
46
- }[] | undefined;
67
+ declare function toOpenAPISchema(schema: JSONSchema): OpenAPI.SchemaObject & object;
68
+ declare function resolveOpenAPIJsonSchemaRef(doc: OpenAPI.Document, schema: JSONSchema): JSONSchema;
69
+ /**
70
+ * Simplifies composed object JSON Schemas (using anyOf, oneOf, allOf) by flattening nested compositions
71
+ *
72
+ * @warning The result is looser than the original schema and may not fully validate the same data.
73
+ */
74
+ declare function simplifyComposedObjectJsonSchemasAndRefs(schema: JSONSchema, doc?: OpenAPI.Document): JSONSchema;
47
75
 
48
- declare class OpenAPIGeneratorError extends TypeError {
49
- }
50
- interface OpenAPIErrorBodyDefinition {
51
- code: string;
52
- defaultMessage: string | undefined;
53
- dataOptional: boolean;
54
- dataJsonSchema: JsonSchema;
55
- }
76
+ declare function createJsonifiedRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>, Schema<unknown, unknown>, ErrorMap, Meta, TClientContext>>): JsonifiedClient<RouterClient<T, TClientContext>>;
56
77
 
57
- interface OpenAPIGeneratorOptions {
58
- converters?: JsonSchemaConverter[] | undefined;
59
- /**
60
- * The serializer used to serialize the generated OpenAPI documentation
61
- */
62
- serializer?: Pick<OpenAPISerializer, keyof OpenAPISerializer> | undefined;
63
- }
64
- interface OpenAPIGeneratorGenerateOptions {
65
- base?: Partial<OpenAPIDocument> | undefined;
66
- /**
67
- * Root-level `$defs` are always moved into `components.schemas`.
68
- * Use this to customize the component name of a hoisted def.
69
- *
70
- * @remarks
71
- * - The returned name is a preference, conflicting names are still postfixed (`Planet`, `PlanetInput`, `Planet2`, ...).
72
- * - Return `undefined` to keep the original def name.
73
- *
74
- * @default defName => defName
75
- */
76
- customComponentName?: (defName: string, defSchema: JsonSchema) => string | undefined;
77
- /**
78
- * Filter procedures. Return `false` to exclude a procedure from the OpenAPI specification.
79
- *
80
- * @default true
81
- */
82
- filter?: Value<boolean, [contract: AnyProcedureContract | AnyProcedure, path: string[]]>;
83
- /**
84
- * Define a custom JSON schema for the error response body when using
85
- * type-safe errors. Helps align ORPC error formatting with existing API
86
- * response standards or conventions.
87
- *
88
- * @remarks
89
- * - Return `null | undefined` to use the default error response body shaper.
90
- */
91
- customErrorResponseBodySchema?: Value<JsonSchema | undefined | null, [
92
- definedErrors: OpenAPIErrorBodyDefinition[],
93
- status: number
94
- ]>;
95
- /**
96
- * Mapping ORPCError Code -> HTTP Status Code
97
- *
98
- * @default COMMON_ERROR_STATUS_MAP
99
- */
100
- errorStatusMap?: Record<string, number> | undefined;
101
- }
102
- declare class OpenAPIGenerator {
103
- private readonly serializer;
104
- private readonly converter;
105
- constructor(options?: OpenAPIGeneratorOptions);
106
- generate(router: RouterContract | AnyRouter, options?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPIDocument>;
107
- private convertSchema;
108
- private convertSchemas;
109
- }
78
+ /**
79
+ *@internal
80
+ */
81
+ declare function isFileSchema(schema: JSONSchema): schema is FileSchema;
82
+ /**
83
+ * @internal
84
+ */
85
+ declare function isObjectSchema(schema: JSONSchema): schema is ObjectSchema;
86
+ /**
87
+ * @internal
88
+ */
89
+ declare function isAnySchema(schema: JSONSchema): boolean;
90
+ declare function isNeverSchema(schema: JSONSchema): boolean;
91
+ /**
92
+ * @internal
93
+ */
94
+ declare function separateObjectSchema(schema: ObjectSchema, separatedProperties: string[]): [matched: ObjectSchema, rest: ObjectSchema];
95
+ /**
96
+ * @internal
97
+ */
98
+ declare function filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
99
+ declare function applySchemaOptionality(required: boolean, schema: JSONSchema): JSONSchema;
100
+ /**
101
+ * Takes a JSON schema and, if it's primarily a union type (anyOf, oneOf),
102
+ * recursively expands it into an array of its constituent, non-union base schemas.
103
+ * If the schema is not a simple union or is a base type, it's returned as a single-element array.
104
+ */
105
+ declare function expandUnionSchema(schema: JSONSchema): JSONSchema[];
106
+ declare function expandArrayableSchema(schema: JSONSchema): undefined | [items: JSONSchema, array: JSONSchema & {
107
+ type: 'array';
108
+ items?: JSONSchema;
109
+ }];
110
+ declare function isPrimitiveSchema(schema: JSONSchema): boolean;
110
111
 
111
- type PopulatedContractRouterOpenAPIPaths<T extends RouterContract> = T extends ProcedureContract<infer UInputSchema, infer UOutputSchema, infer UErrors> ? ProcedureContract<UInputSchema, UOutputSchema, UErrors> : {
112
- [K in keyof T]: T[K] extends RouterContract ? PopulatedContractRouterOpenAPIPaths<T[K]> : never;
112
+ declare const oo: {
113
+ spec: typeof customOpenAPIOperation;
113
114
  };
114
- interface PopulateRouterContractOpenAPIPathsOptions {
115
- /**
116
- * Base path segments.
117
- */
118
- path?: undefined | string[];
119
- }
120
- /**
121
- * Automatically populates missing openapi.path using router structure.
122
- *
123
- * Builds paths by joining router keys with `/`.
124
- * Useful when you want to ensure all contracts define openapi.path, such as for NestJS integration requirements.
125
- */
126
- declare function populateRouterContractOpenAPIPaths<T extends RouterContract>(router: T, options?: PopulateRouterContractOpenAPIPathsOptions): PopulatedContractRouterOpenAPIPaths<T>;
127
115
 
128
- export { DEFAULT_OPENAPI_INPUT_STRUCTURE, DEFAULT_OPENAPI_METHOD, DEFAULT_OPENAPI_OUTPUT_STRUCTURE, DEFAULT_OPENAPI_SUCCESS_DESCRIPTION, JsonifiedClient, OpenAPIDocument, OpenAPIGenerator, OpenAPIGeneratorError, OpenAPISerializer, createContractJsonifiedClientFactory, getDynamicPathParams, isBodylessMethod, populateRouterContractOpenAPIPaths };
129
- export type { ContractJsonifiedClientFactory, ContractJsonifiedClientFactoryOptions, OpenAPIErrorBodyDefinition, OpenAPIGeneratorGenerateOptions, OpenAPIGeneratorOptions, PopulateRouterContractOpenAPIPathsOptions, PopulatedContractRouterOpenAPIPaths };
116
+ export { LOGIC_KEYWORDS, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, createJsonifiedRouterClient, customOpenAPIOperation, expandArrayableSchema, expandUnionSchema, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isNeverSchema, isObjectSchema, isPrimitiveSchema, oo, resolveOpenAPIJsonSchemaRef, separateObjectSchema, simplifyComposedObjectJsonSchemasAndRefs, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
117
+ export type { FileSchema, ObjectSchema, OverrideOperationValue };