@orpc/openapi 2.0.0-beta.2 → 2.0.0-beta.21
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 +32 -21
- package/dist/adapters/fetch/index.d.mts +2 -2
- package/dist/adapters/fetch/index.d.ts +2 -2
- package/dist/adapters/fetch/index.mjs +3 -3
- package/dist/adapters/node/index.d.mts +2 -2
- package/dist/adapters/node/index.d.ts +2 -2
- package/dist/adapters/node/index.mjs +2 -2
- package/dist/adapters/standard/index.d.mts +2 -2
- package/dist/adapters/standard/index.d.ts +2 -2
- package/dist/adapters/standard/index.mjs +3 -3
- package/dist/extensions/route.d.mts +2 -2
- package/dist/extensions/route.d.ts +2 -2
- package/dist/index.d.mts +63 -37
- package/dist/index.d.ts +63 -37
- package/dist/index.mjs +711 -753
- package/dist/plugins/index.d.mts +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/shared/{openapi.BYcWgK1j.d.ts → openapi.B6hEbRyF.d.ts} +18 -14
- package/dist/shared/{openapi.C7m7NAmH.d.mts → openapi.BOOA-bde.d.mts} +1 -1
- package/dist/shared/{openapi.C7m7NAmH.d.ts → openapi.BOOA-bde.d.ts} +1 -1
- package/dist/shared/{openapi.XeW6_5tm.d.mts → openapi.BafbB3uM.d.mts} +18 -14
- package/dist/shared/{openapi.CYgMBSUF.d.mts → openapi.ByT4oUeY.d.mts} +2 -2
- package/dist/shared/{openapi.CYgMBSUF.d.ts → openapi.ByT4oUeY.d.ts} +2 -2
- package/dist/shared/{openapi.B2SK0ZAr.mjs → openapi.C-p_Q2lb.mjs} +4 -4
- package/dist/shared/{openapi.DR-y5p-D.mjs → openapi.CVgUshDP.mjs} +28 -25
- package/dist/shared/{openapi.BQzzr4-4.d.ts → openapi.DNNo0V-l.d.ts} +23 -9
- package/dist/shared/{openapi.BcEtAxQj.d.mts → openapi.hg_rhZ4x.d.mts} +23 -9
- package/dist/shared/{openapi.DmAa7YPO.mjs → openapi.zZH_UksW.mjs} +7 -4
- package/package.json +29 -13
package/dist/index.d.ts
CHANGED
|
@@ -1,37 +1,59 @@
|
|
|
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.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
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, 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';
|
|
11
10
|
import { AnyRouter, AnyProcedure } from '@orpc/server';
|
|
12
|
-
import '@
|
|
11
|
+
import { Value } from '@orpc/shared';
|
|
12
|
+
export { StandardBodyHint } from '@standardserver/core';
|
|
13
13
|
import '@hey-api/spec-types';
|
|
14
14
|
|
|
15
|
-
interface
|
|
16
|
-
<
|
|
15
|
+
interface ContractJsonifiedClientFactory<TClientContext extends ClientContext> {
|
|
16
|
+
<T extends RouterContract>(contract: T): JsonifiedClient<RouterContractClient<T, TClientContext>>;
|
|
17
17
|
}
|
|
18
|
-
interface
|
|
18
|
+
interface ContractJsonifiedClientFactoryOptions<TClientContext extends ClientContext> extends Pick<ORPCClientOptions<JsonifiedClient<RouterContractClient<RouterContract, TClientContext>>>, 'interceptors' | 'scoped'> {
|
|
19
19
|
/**
|
|
20
20
|
* An optional reference to the root router-contract.
|
|
21
|
-
* When provided, the
|
|
21
|
+
* When provided, the client factory will automatically register the passed contract
|
|
22
22
|
* into the router at the path defined by `meta.path`.
|
|
23
23
|
*/
|
|
24
24
|
contractRef?: undefined | RouterContract;
|
|
25
25
|
}
|
|
26
|
-
declare function
|
|
26
|
+
declare function createContractJsonifiedClientFactory<TClientContext extends ClientContext>(link: ClientLink<TClientContext>, options?: ContractJsonifiedClientFactoryOptions<TClientContext>): ContractJsonifiedClientFactory<TClientContext>;
|
|
27
27
|
|
|
28
28
|
declare const DEFAULT_OPENAPI_METHOD = "POST";
|
|
29
29
|
declare const DEFAULT_OPENAPI_SUCCESS_DESCRIPTION = "OK";
|
|
30
30
|
declare const DEFAULT_OPENAPI_INPUT_STRUCTURE = "compact";
|
|
31
31
|
declare const DEFAULT_OPENAPI_OUTPUT_STRUCTURE = "compact";
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* GET and HEAD requests cannot carry a request body,
|
|
35
|
+
* so their compact input maps to query parameters instead.
|
|
36
|
+
*/
|
|
37
|
+
declare function isBodylessMethod(method: string): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Dynamic parameters are always returned in path order.
|
|
40
|
+
*/
|
|
41
|
+
declare function getDynamicPathParams(path: `/${string}`): {
|
|
42
|
+
segment: string;
|
|
43
|
+
startIndex: number;
|
|
44
|
+
parameterName: string;
|
|
45
|
+
allowsSlash: boolean;
|
|
46
|
+
}[] | undefined;
|
|
47
|
+
|
|
33
48
|
declare class OpenAPIGeneratorError extends TypeError {
|
|
34
49
|
}
|
|
50
|
+
interface OpenAPIErrorBodyDefinition {
|
|
51
|
+
code: string;
|
|
52
|
+
defaultMessage: string | undefined;
|
|
53
|
+
dataOptional: boolean;
|
|
54
|
+
dataJsonSchema: JsonSchema;
|
|
55
|
+
}
|
|
56
|
+
|
|
35
57
|
interface OpenAPIGeneratorOptions {
|
|
36
58
|
converters?: JsonSchemaConverter[] | undefined;
|
|
37
59
|
/**
|
|
@@ -42,11 +64,16 @@ interface OpenAPIGeneratorOptions {
|
|
|
42
64
|
interface OpenAPIGeneratorGenerateOptions {
|
|
43
65
|
base?: Partial<OpenAPIDocument> | undefined;
|
|
44
66
|
/**
|
|
45
|
-
*
|
|
67
|
+
* Root-level `$defs` are always moved into `components.schemas`.
|
|
68
|
+
* Use this to customize the component name of a hoisted def.
|
|
46
69
|
*
|
|
47
|
-
* @
|
|
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
|
|
48
75
|
*/
|
|
49
|
-
|
|
76
|
+
customComponentName?: (defName: string, defSchema: JsonSchema) => string | undefined;
|
|
50
77
|
/**
|
|
51
78
|
* Filter procedures. Return `false` to exclude a procedure from the OpenAPI specification.
|
|
52
79
|
*
|
|
@@ -62,18 +89,13 @@ interface OpenAPIGeneratorGenerateOptions {
|
|
|
62
89
|
* - Return `null | undefined` to use the default error response body shaper.
|
|
63
90
|
*/
|
|
64
91
|
customErrorResponseBodySchema?: Value<JsonSchema | undefined | null, [
|
|
65
|
-
definedErrors:
|
|
66
|
-
code: string;
|
|
67
|
-
defaultMessage: string | undefined;
|
|
68
|
-
dataOptional: boolean;
|
|
69
|
-
dataJsonSchema: JsonSchema;
|
|
70
|
-
}[],
|
|
92
|
+
definedErrors: OpenAPIErrorBodyDefinition[],
|
|
71
93
|
status: number
|
|
72
94
|
]>;
|
|
73
95
|
/**
|
|
74
96
|
* Mapping ORPCError Code -> HTTP Status Code
|
|
75
97
|
*
|
|
76
|
-
* @default COMMON_ERROR_STATUS_MAP
|
|
98
|
+
* @default COMMON_ERROR_STATUS_MAP
|
|
77
99
|
*/
|
|
78
100
|
errorStatusMap?: Record<string, number> | undefined;
|
|
79
101
|
}
|
|
@@ -84,20 +106,24 @@ declare class OpenAPIGenerator {
|
|
|
84
106
|
generate(router: RouterContract | AnyRouter, options?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPIDocument>;
|
|
85
107
|
private convertSchema;
|
|
86
108
|
private convertSchemas;
|
|
87
|
-
private request;
|
|
88
|
-
private successResponse;
|
|
89
|
-
private errorResponse;
|
|
90
109
|
}
|
|
91
110
|
|
|
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;
|
|
113
|
+
};
|
|
114
|
+
interface PopulateRouterContractOpenAPIPathsOptions {
|
|
115
|
+
/**
|
|
116
|
+
* Base path segments.
|
|
117
|
+
*/
|
|
118
|
+
path?: undefined | string[];
|
|
119
|
+
}
|
|
92
120
|
/**
|
|
93
|
-
*
|
|
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.
|
|
94
125
|
*/
|
|
95
|
-
declare function
|
|
96
|
-
segment: string;
|
|
97
|
-
startIndex: number;
|
|
98
|
-
parameterName: string;
|
|
99
|
-
allowsSlash: boolean;
|
|
100
|
-
}[] | undefined;
|
|
126
|
+
declare function populateRouterContractOpenAPIPaths<T extends RouterContract>(router: T, options?: PopulateRouterContractOpenAPIPathsOptions): PopulatedContractRouterOpenAPIPaths<T>;
|
|
101
127
|
|
|
102
|
-
export { DEFAULT_OPENAPI_INPUT_STRUCTURE, DEFAULT_OPENAPI_METHOD, DEFAULT_OPENAPI_OUTPUT_STRUCTURE, DEFAULT_OPENAPI_SUCCESS_DESCRIPTION, JsonifiedClient,
|
|
103
|
-
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 };
|