@orpc/openapi 1.14.10 → 1.14.11
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.
- package/README.md +52 -71
- package/dist/adapters/fetch/index.d.mts +20 -16
- package/dist/adapters/fetch/index.d.ts +20 -16
- package/dist/adapters/fetch/index.mjs +24 -8
- package/dist/adapters/node/index.d.mts +8 -13
- package/dist/adapters/node/index.d.ts +8 -13
- package/dist/adapters/node/index.mjs +10 -7
- package/dist/adapters/standard/index.d.mts +46 -16
- package/dist/adapters/standard/index.d.ts +46 -16
- package/dist/adapters/standard/index.mjs +9 -6
- package/dist/extensions/route.d.mts +43 -0
- package/dist/extensions/route.d.ts +43 -0
- package/dist/extensions/route.mjs +14 -0
- package/dist/helpers/index.d.mts +51 -0
- package/dist/helpers/index.d.ts +51 -0
- package/dist/helpers/index.mjs +39 -0
- package/dist/index.d.mts +117 -105
- package/dist/index.d.ts +117 -105
- package/dist/index.mjs +850 -32
- package/dist/plugins/index.d.mts +55 -51
- package/dist/plugins/index.d.ts +55 -51
- package/dist/plugins/index.mjs +147 -142
- package/dist/shared/openapi.B6hEbRyF.d.ts +83 -0
- package/dist/shared/openapi.B9PQzqBn.mjs +49 -0
- package/dist/shared/openapi.BOOA-bde.d.mts +142 -0
- package/dist/shared/openapi.BOOA-bde.d.ts +142 -0
- package/dist/shared/openapi.BafbB3uM.d.mts +83 -0
- package/dist/shared/openapi.Bt87OzTt.mjs +131 -0
- package/dist/shared/openapi.ByT4oUeY.d.mts +18 -0
- package/dist/shared/openapi.ByT4oUeY.d.ts +18 -0
- package/dist/shared/openapi.C-p_Q2lb.mjs +359 -0
- package/dist/shared/openapi.CVgUshDP.mjs +318 -0
- package/dist/shared/openapi.DNNo0V-l.d.ts +313 -0
- package/dist/shared/openapi.hg_rhZ4x.d.mts +313 -0
- package/dist/shared/openapi.zZH_UksW.mjs +278 -0
- package/package.json +46 -24
- package/dist/adapters/aws-lambda/index.d.mts +0 -20
- package/dist/adapters/aws-lambda/index.d.ts +0 -20
- package/dist/adapters/aws-lambda/index.mjs +0 -18
- package/dist/adapters/fastify/index.d.mts +0 -23
- package/dist/adapters/fastify/index.d.ts +0 -23
- package/dist/adapters/fastify/index.mjs +0 -18
- package/dist/shared/openapi.BB-W-NKv.mjs +0 -204
- package/dist/shared/openapi.BGy4N6eR.d.mts +0 -120
- package/dist/shared/openapi.BGy4N6eR.d.ts +0 -120
- package/dist/shared/openapi.BwdtJjDu.mjs +0 -878
- package/dist/shared/openapi.DwaweYRb.d.mts +0 -54
- package/dist/shared/openapi.DwaweYRb.d.ts +0 -54
package/dist/index.d.ts
CHANGED
|
@@ -1,117 +1,129 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
import '@orpc/
|
|
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';
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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>;
|
|
21
27
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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[];
|
|
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";
|
|
39
32
|
|
|
40
33
|
/**
|
|
41
|
-
*
|
|
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
|
|
34
|
+
* GET and HEAD requests cannot carry a request body,
|
|
35
|
+
* so their compact input maps to query parameters instead.
|
|
62
36
|
*/
|
|
63
|
-
declare function
|
|
37
|
+
declare function isBodylessMethod(method: string): boolean;
|
|
64
38
|
/**
|
|
65
|
-
*
|
|
39
|
+
* Dynamic parameters are always returned in path order.
|
|
66
40
|
*/
|
|
67
|
-
declare function
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
*/
|
|
74
|
-
declare function simplifyComposedObjectJsonSchemasAndRefs(schema: JSONSchema, doc?: OpenAPI.Document): JSONSchema;
|
|
41
|
+
declare function getDynamicPathParams(path: `/${string}`): {
|
|
42
|
+
segment: string;
|
|
43
|
+
startIndex: number;
|
|
44
|
+
parameterName: string;
|
|
45
|
+
allowsSlash: boolean;
|
|
46
|
+
}[] | undefined;
|
|
75
47
|
|
|
76
|
-
declare
|
|
48
|
+
declare class OpenAPIGeneratorError extends TypeError {
|
|
49
|
+
}
|
|
50
|
+
interface OpenAPIErrorBodyDefinition {
|
|
51
|
+
code: string;
|
|
52
|
+
defaultMessage: string | undefined;
|
|
53
|
+
dataOptional: boolean;
|
|
54
|
+
dataJsonSchema: JsonSchema;
|
|
55
|
+
}
|
|
77
56
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
+
}
|
|
111
110
|
|
|
112
|
-
|
|
113
|
-
|
|
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;
|
|
114
113
|
};
|
|
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>;
|
|
115
127
|
|
|
116
|
-
export {
|
|
117
|
-
export type {
|
|
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 };
|