@orpc/openapi 2.0.0-beta.4 → 2.0.0-beta.40
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 +97 -94
- package/dist/adapters/aws-lambda/index.d.mts +26 -0
- package/dist/adapters/aws-lambda/index.d.ts +26 -0
- package/dist/adapters/aws-lambda/index.mjs +21 -0
- package/dist/adapters/fastify/index.d.mts +23 -0
- package/dist/adapters/fastify/index.d.ts +23 -0
- package/dist/adapters/fastify/index.mjs +21 -0
- package/dist/adapters/fetch/index.d.mts +15 -5
- package/dist/adapters/fetch/index.d.ts +15 -5
- package/dist/adapters/fetch/index.mjs +6 -6
- package/dist/adapters/node/index.d.mts +9 -4
- package/dist/adapters/node/index.d.ts +9 -4
- package/dist/adapters/node/index.mjs +4 -4
- package/dist/adapters/standard/index.d.mts +10 -46
- package/dist/adapters/standard/index.d.ts +10 -46
- package/dist/adapters/standard/index.mjs +6 -6
- package/dist/extensions/route.d.mts +5 -7
- package/dist/extensions/route.d.ts +5 -7
- package/dist/helpers/index.d.mts +9 -1
- package/dist/helpers/index.d.ts +9 -1
- package/dist/helpers/index.mjs +1 -1
- package/dist/index.d.mts +77 -45
- package/dist/index.d.ts +77 -45
- package/dist/index.mjs +694 -750
- package/dist/plugins/index.d.mts +21 -4
- package/dist/plugins/index.d.ts +21 -4
- package/dist/plugins/index.mjs +7 -2
- package/dist/shared/{openapi.DmAa7YPO.mjs → openapi.B1LWf28E.mjs} +134 -64
- package/dist/shared/openapi.B2G-HeFn.mjs +123 -0
- package/dist/shared/{openapi.B2SK0ZAr.mjs → openapi.BdClbrwk.mjs} +27 -35
- package/dist/shared/openapi.BwNINoeN.d.ts +45 -0
- package/dist/shared/{openapi.BQzzr4-4.d.ts → openapi.Cem81Zhm.d.mts} +41 -12
- package/dist/shared/{openapi.BcEtAxQj.d.mts → openapi.Cem81Zhm.d.ts} +41 -12
- package/dist/shared/openapi.DE5kXinS.d.mts +45 -0
- package/dist/shared/openapi.DI21x5Yo.d.mts +31 -0
- package/dist/shared/openapi.DI21x5Yo.d.ts +31 -0
- package/dist/shared/{openapi.C7m7NAmH.d.mts → openapi.Dl3gew1x.d.mts} +16 -5
- package/dist/shared/{openapi.C7m7NAmH.d.ts → openapi.Dl3gew1x.d.ts} +16 -5
- package/dist/shared/{openapi.7vgmPxca.d.ts → openapi.EM8eC1Xn.d.ts} +12 -9
- package/dist/shared/{openapi.CX6Ri5dP.d.mts → openapi.fnBK1ELE.d.mts} +12 -9
- package/dist/shared/{openapi.CTlpLuKN.mjs → openapi.wQKxWEI2.mjs} +97 -48
- package/package.json +57 -17
- package/dist/shared/openapi.Bt87OzTt.mjs +0 -131
- package/dist/shared/openapi.CYgMBSUF.d.mts +0 -18
- package/dist/shared/openapi.CYgMBSUF.d.ts +0 -18
package/dist/index.d.ts
CHANGED
|
@@ -1,52 +1,93 @@
|
|
|
1
|
-
import { O as OpenAPISerializer } from './shared/openapi.
|
|
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.
|
|
3
|
-
import { ClientContext,
|
|
1
|
+
import { O as OpenAPISerializer } from './shared/openapi.Dl3gew1x.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.Dl3gew1x.js';
|
|
3
|
+
import { ClientContext, ORPCClientOptions, ClientLink } from '@orpc/client';
|
|
4
4
|
export { COMMON_ERROR_STATUS_MAP } from '@orpc/client';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
|
|
10
|
-
import { JsonSchemaConverter, JsonSchema } from '@orpc/json-schema';
|
|
5
|
+
import { RouterContract, RouterContractClient, AnyProcedureContract, ProcedureContract } from '@orpc/contract';
|
|
6
|
+
import { J as JsonifiedClient, O as OpenAPIVersion, a as OpenAPIDocument } from './shared/openapi.DI21x5Yo.js';
|
|
7
|
+
export { b as JsonifiedArray, c as JsonifiedClientError, d as JsonifiedValue } from './shared/openapi.DI21x5Yo.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.Cem81Zhm.js';
|
|
9
|
+
import { JsonSchema, JsonSchemaConverter } from '@orpc/json-schema';
|
|
11
10
|
import { AnyRouter, AnyProcedure } from '@orpc/server';
|
|
12
|
-
|
|
13
|
-
import '@
|
|
11
|
+
import { Public, Value } from '@orpc/shared';
|
|
12
|
+
import { OpenAPIV3_2 } from '@openapi-spec/types';
|
|
13
|
+
export { OpenAPIV3_0, OpenAPIV3_1, OpenAPIV3_2 } from '@openapi-spec/types';
|
|
14
|
+
export { StandardBodyHint } from '@standard-server/core';
|
|
14
15
|
|
|
15
|
-
interface
|
|
16
|
-
<
|
|
16
|
+
interface ContractJsonifiedClientFactory<TClientContext extends ClientContext> {
|
|
17
|
+
<T extends RouterContract>(contract: T): JsonifiedClient<RouterContractClient<T, TClientContext>>;
|
|
17
18
|
}
|
|
18
|
-
interface
|
|
19
|
+
interface ContractJsonifiedClientFactoryOptions<TClientContext extends ClientContext> extends Pick<ORPCClientOptions<JsonifiedClient<RouterContractClient<RouterContract, TClientContext>>>, 'interceptors' | 'scoped'> {
|
|
19
20
|
/**
|
|
20
21
|
* An optional reference to the root router-contract.
|
|
21
|
-
* When provided, the
|
|
22
|
+
* When provided, the client factory will automatically register the passed contract
|
|
22
23
|
* into the router at the path defined by `meta.path`.
|
|
23
24
|
*/
|
|
24
25
|
contractRef?: undefined | RouterContract;
|
|
25
26
|
}
|
|
26
|
-
declare function
|
|
27
|
+
declare function createContractJsonifiedClientFactory<TClientContext extends ClientContext>(link: ClientLink<TClientContext>, options?: ContractJsonifiedClientFactoryOptions<TClientContext>): ContractJsonifiedClientFactory<TClientContext>;
|
|
27
28
|
|
|
28
29
|
declare const DEFAULT_OPENAPI_METHOD = "POST";
|
|
29
30
|
declare const DEFAULT_OPENAPI_SUCCESS_DESCRIPTION = "OK";
|
|
30
31
|
declare const DEFAULT_OPENAPI_INPUT_STRUCTURE = "compact";
|
|
31
32
|
declare const DEFAULT_OPENAPI_OUTPUT_STRUCTURE = "compact";
|
|
32
33
|
|
|
34
|
+
/**
|
|
35
|
+
* GET and HEAD requests cannot carry a request body,
|
|
36
|
+
* so their compact input maps to query parameters instead.
|
|
37
|
+
*/
|
|
38
|
+
declare function isBodylessMethod(method: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Dynamic parameters are always returned in path order.
|
|
41
|
+
*/
|
|
42
|
+
declare function getDynamicPathParams(path: `/${string}`): {
|
|
43
|
+
segment: string;
|
|
44
|
+
startIndex: number;
|
|
45
|
+
parameterName: string;
|
|
46
|
+
allowsSlash: boolean;
|
|
47
|
+
}[] | undefined;
|
|
48
|
+
|
|
33
49
|
declare class OpenAPIGeneratorError extends TypeError {
|
|
34
50
|
}
|
|
51
|
+
interface OpenAPIErrorBodyDefinition {
|
|
52
|
+
code: string;
|
|
53
|
+
defaultMessage: string | undefined;
|
|
54
|
+
dataOptional: boolean;
|
|
55
|
+
dataJsonSchema: JsonSchema;
|
|
56
|
+
}
|
|
57
|
+
|
|
35
58
|
interface OpenAPIGeneratorOptions {
|
|
36
59
|
converters?: JsonSchemaConverter[] | undefined;
|
|
37
60
|
/**
|
|
38
61
|
* The serializer used to serialize the generated OpenAPI documentation
|
|
39
62
|
*/
|
|
40
|
-
serializer?:
|
|
63
|
+
serializer?: Public<OpenAPISerializer> | undefined;
|
|
41
64
|
}
|
|
42
|
-
interface OpenAPIGeneratorGenerateOptions {
|
|
43
|
-
base?: Partial<OpenAPIDocument> | undefined;
|
|
65
|
+
interface OpenAPIGeneratorGenerateOptions<TVersion extends OpenAPIVersion> {
|
|
44
66
|
/**
|
|
45
|
-
*
|
|
67
|
+
* The OpenAPI version of the generated document.
|
|
68
|
+
* The document is generated as OpenAPI 3.2 and downgraded when an older version is requested.
|
|
69
|
+
* The minor version selects the conversion, the document carries the exact value, such as `3.1.0`.
|
|
46
70
|
*
|
|
47
|
-
* @default
|
|
71
|
+
* @default '3.2.0'
|
|
72
|
+
*/
|
|
73
|
+
version?: TVersion | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* OpenAPI 3.2 document fields to start from, such as `info`, `servers`, or `components`.
|
|
76
|
+
* They are downgraded with the rest of the document when an older `version` is requested.
|
|
77
|
+
* The `openapi` field is derived from `version`.
|
|
78
|
+
*/
|
|
79
|
+
base?: Partial<Omit<OpenAPIV3_2.OpenAPIObject, 'openapi'>> | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Root-level `$defs` are always moved into `components.schemas`.
|
|
82
|
+
* Use this to customize the component name of a hoisted def.
|
|
83
|
+
*
|
|
84
|
+
* @remarks
|
|
85
|
+
* - The returned name is a preference, conflicting names are still postfixed (`Planet`, `PlanetInput`, `Planet2`, ...).
|
|
86
|
+
* - Return `undefined` to keep the original def name.
|
|
87
|
+
*
|
|
88
|
+
* @default defName => defName
|
|
48
89
|
*/
|
|
49
|
-
|
|
90
|
+
customComponentName?: (defName: string, defSchema: JsonSchema) => string | undefined;
|
|
50
91
|
/**
|
|
51
92
|
* Filter procedures. Return `false` to exclude a procedure from the OpenAPI specification.
|
|
52
93
|
*
|
|
@@ -60,33 +101,32 @@ interface OpenAPIGeneratorGenerateOptions {
|
|
|
60
101
|
*
|
|
61
102
|
* @remarks
|
|
62
103
|
* - Return `null | undefined` to use the default error response body shaper.
|
|
104
|
+
* - The schema is an OpenAPI 3.2 Schema Object, it is downgraded with the rest of the document when an older `version` is requested.
|
|
63
105
|
*/
|
|
64
106
|
customErrorResponseBodySchema?: Value<JsonSchema | undefined | null, [
|
|
65
|
-
definedErrors:
|
|
66
|
-
code: string;
|
|
67
|
-
defaultMessage: string | undefined;
|
|
68
|
-
dataOptional: boolean;
|
|
69
|
-
dataJsonSchema: JsonSchema;
|
|
70
|
-
}[],
|
|
107
|
+
definedErrors: OpenAPIErrorBodyDefinition[],
|
|
71
108
|
status: number
|
|
72
109
|
]>;
|
|
73
110
|
/**
|
|
74
111
|
* Mapping ORPCError Code -> HTTP Status Code
|
|
75
112
|
*
|
|
76
|
-
* @default COMMON_ERROR_STATUS_MAP
|
|
113
|
+
* @default COMMON_ERROR_STATUS_MAP
|
|
77
114
|
*/
|
|
78
115
|
errorStatusMap?: Record<string, number> | undefined;
|
|
79
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Generates an OpenAPI document from a contract or router.
|
|
119
|
+
* Relies on JSON schema converters to translate input, output, and error schemas into JSON Schemas.
|
|
120
|
+
*
|
|
121
|
+
* @see {@link https://orpc.dev/docs/openapi/specification#openapi-generator | OpenAPI Specification - OpenAPI Generator}
|
|
122
|
+
*/
|
|
80
123
|
declare class OpenAPIGenerator {
|
|
81
124
|
private readonly serializer;
|
|
82
125
|
private readonly converter;
|
|
83
126
|
constructor(options?: OpenAPIGeneratorOptions);
|
|
84
|
-
generate(router: RouterContract | AnyRouter, options?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPIDocument
|
|
127
|
+
generate<TVersion extends OpenAPIVersion = '3.2.0'>(router: RouterContract | AnyRouter, options?: OpenAPIGeneratorGenerateOptions<TVersion>): Promise<OpenAPIDocument<TVersion>>;
|
|
85
128
|
private convertSchema;
|
|
86
129
|
private convertSchemas;
|
|
87
|
-
private request;
|
|
88
|
-
private successResponse;
|
|
89
|
-
private errorResponse;
|
|
90
130
|
}
|
|
91
131
|
|
|
92
132
|
type PopulatedContractRouterOpenAPIPaths<T extends RouterContract> = T extends ProcedureContract<infer UInputSchema, infer UOutputSchema, infer UErrors> ? ProcedureContract<UInputSchema, UOutputSchema, UErrors> : {
|
|
@@ -103,18 +143,10 @@ interface PopulateRouterContractOpenAPIPathsOptions {
|
|
|
103
143
|
*
|
|
104
144
|
* Builds paths by joining router keys with `/`.
|
|
105
145
|
* Useful when you want to ensure all contracts define openapi.path, such as for NestJS integration requirements.
|
|
146
|
+
*
|
|
147
|
+
* @see {@link https://orpc.dev/docs/integrations/nest | Implement oRPC contract with NestJS}
|
|
106
148
|
*/
|
|
107
149
|
declare function populateRouterContractOpenAPIPaths<T extends RouterContract>(router: T, options?: PopulateRouterContractOpenAPIPathsOptions): PopulatedContractRouterOpenAPIPaths<T>;
|
|
108
150
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
*/
|
|
112
|
-
declare function getDynamicPathParams(path: `/${string}`): {
|
|
113
|
-
segment: string;
|
|
114
|
-
startIndex: number;
|
|
115
|
-
parameterName: string;
|
|
116
|
-
allowsSlash: boolean;
|
|
117
|
-
}[] | undefined;
|
|
118
|
-
|
|
119
|
-
export { DEFAULT_OPENAPI_INPUT_STRUCTURE, DEFAULT_OPENAPI_METHOD, DEFAULT_OPENAPI_OUTPUT_STRUCTURE, DEFAULT_OPENAPI_SUCCESS_DESCRIPTION, JsonifiedClient, JsonifiedClientError, JsonifiedValue, OpenAPIDocument, OpenAPIGenerator, OpenAPIGeneratorError, OpenAPISerializer, createContractJsonifiedCaller, getDynamicPathParams, populateRouterContractOpenAPIPaths };
|
|
120
|
-
export type { ContractJsonifiedCaller, ContractJsonifiedCallerOptions, OpenAPIGeneratorGenerateOptions, OpenAPIGeneratorOptions, PopulateRouterContractOpenAPIPathsOptions, PopulatedContractRouterOpenAPIPaths };
|
|
151
|
+
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 };
|
|
152
|
+
export type { ContractJsonifiedClientFactory, ContractJsonifiedClientFactoryOptions, OpenAPIErrorBodyDefinition, OpenAPIGeneratorGenerateOptions, OpenAPIGeneratorOptions, PopulateRouterContractOpenAPIPathsOptions, PopulatedContractRouterOpenAPIPaths };
|