@orpc/openapi 1.14.6 → 2.0.0-beta.10
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 +78 -110
- 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 +111 -108
- package/dist/index.d.ts +111 -108
- package/dist/index.mjs +922 -33
- 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.7vgmPxca.d.ts +82 -0
- package/dist/shared/openapi.B2SK0ZAr.mjs +359 -0
- package/dist/shared/openapi.B9PQzqBn.mjs +49 -0
- package/dist/shared/openapi.BQzzr4-4.d.ts +299 -0
- package/dist/shared/openapi.BcEtAxQj.d.mts +299 -0
- package/dist/shared/openapi.Bt87OzTt.mjs +131 -0
- package/dist/shared/openapi.C7m7NAmH.d.mts +142 -0
- package/dist/shared/openapi.C7m7NAmH.d.ts +142 -0
- package/dist/shared/openapi.CTlpLuKN.mjs +318 -0
- package/dist/shared/openapi.CX6Ri5dP.d.mts +82 -0
- package/dist/shared/openapi.CYgMBSUF.d.mts +18 -0
- package/dist/shared/openapi.CYgMBSUF.d.ts +18 -0
- package/dist/shared/openapi.DmAa7YPO.mjs +275 -0
- package/package.json +30 -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,120 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import { JsonifiedClient } from '
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import '@orpc/
|
|
1
|
+
import { O as OpenAPISerializer } from './shared/openapi.C7m7NAmH.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.C7m7NAmH.js';
|
|
3
|
+
import { ClientContext, ClientRest, ThrowableError, ORPCClientOptions, ClientLink } from '@orpc/client';
|
|
4
|
+
export { COMMON_ERROR_STATUS_MAP } from '@orpc/client';
|
|
5
|
+
import { AnySchema, ErrorMap, ProcedureContract, InferSchemaInput, InferSchemaOutput, ORPCErrorFromErrorMap, RouterContractClient, RouterContract, AnyProcedureContract } from '@orpc/contract';
|
|
6
|
+
import { PromiseWithError, Value } from '@orpc/shared';
|
|
7
|
+
import { J as JsonifiedValue, b as JsonifiedClientError, c as JsonifiedClient, a as OpenAPIDocument } from './shared/openapi.CYgMBSUF.js';
|
|
8
|
+
export { d as JsonifiedArray, O as OpenAPIOperationObject } from './shared/openapi.CYgMBSUF.js';
|
|
9
|
+
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.BQzzr4-4.js';
|
|
10
|
+
import { JsonSchemaConverter, JsonSchema } from '@orpc/json-schema';
|
|
11
|
+
import { AnyRouter, AnyProcedure } from '@orpc/server';
|
|
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 ContractJsonifiedCaller<TClientContext extends ClientContext> {
|
|
16
|
+
<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>(procedure: ProcedureContract<TInputSchema, TOutputSchema, TErrorMap>, ...rest: ClientRest<TClientContext, InferSchemaInput<TInputSchema>>): PromiseWithError<JsonifiedValue<InferSchemaOutput<TOutputSchema>>, JsonifiedClientError<ORPCErrorFromErrorMap<TErrorMap> | ThrowableError>>;
|
|
17
|
+
}
|
|
18
|
+
interface ContractJsonifiedCallerOptions<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 caller will automatically register the called procedure-contract
|
|
22
|
+
* into the router at the path defined by `meta.path`.
|
|
23
|
+
*/
|
|
24
|
+
contractRef?: undefined | RouterContract;
|
|
25
|
+
}
|
|
26
|
+
declare function createContractJsonifiedCaller<TClientContext extends ClientContext>(link: ClientLink<TClientContext>, options?: ContractJsonifiedCallerOptions<TClientContext>): ContractJsonifiedCaller<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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
33
|
+
declare class OpenAPIGeneratorError extends TypeError {
|
|
34
|
+
}
|
|
35
|
+
interface OpenAPIGeneratorOptions {
|
|
36
|
+
converters?: JsonSchemaConverter[] | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* The serializer used to serialize the generated OpenAPI documentation
|
|
39
|
+
*/
|
|
40
|
+
serializer?: Pick<OpenAPISerializer, keyof OpenAPISerializer> | undefined;
|
|
41
|
+
}
|
|
42
|
+
interface OpenAPIGeneratorGenerateOptions {
|
|
43
|
+
base?: Partial<OpenAPIDocument> | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Controls whether a generated json schema `$defs` at root-level should be moved into `components.schemas`.
|
|
46
|
+
*
|
|
47
|
+
* @default true
|
|
48
|
+
*/
|
|
49
|
+
shouldHoistDef?: Value<boolean, [defName: string, defSchema: JsonSchema]>;
|
|
50
|
+
/**
|
|
51
|
+
* Filter procedures. Return `false` to exclude a procedure from the OpenAPI specification.
|
|
52
|
+
*
|
|
53
|
+
* @default true
|
|
54
|
+
*/
|
|
55
|
+
filter?: Value<boolean, [contract: AnyProcedureContract | AnyProcedure, path: string[]]>;
|
|
56
|
+
/**
|
|
57
|
+
* Define a custom JSON schema for the error response body when using
|
|
58
|
+
* type-safe errors. Helps align ORPC error formatting with existing API
|
|
59
|
+
* response standards or conventions.
|
|
60
|
+
*
|
|
61
|
+
* @remarks
|
|
62
|
+
* - Return `null | undefined` to use the default error response body shaper.
|
|
63
|
+
*/
|
|
64
|
+
customErrorResponseBodySchema?: Value<JsonSchema | undefined | null, [
|
|
65
|
+
definedErrors: {
|
|
66
|
+
code: string;
|
|
67
|
+
defaultMessage: string | undefined;
|
|
68
|
+
dataOptional: boolean;
|
|
69
|
+
dataJsonSchema: JsonSchema;
|
|
70
|
+
}[],
|
|
71
|
+
status: number
|
|
72
|
+
]>;
|
|
73
|
+
/**
|
|
74
|
+
* Mapping ORPCError Code -> HTTP Status Code
|
|
75
|
+
*
|
|
76
|
+
* @default COMMON_ERROR_STATUS_MAP, DEFAULT_ERROR_STATUS
|
|
77
|
+
*/
|
|
78
|
+
errorStatusMap?: Record<string, number> | undefined;
|
|
79
|
+
}
|
|
80
|
+
declare class OpenAPIGenerator {
|
|
81
|
+
private readonly serializer;
|
|
82
|
+
private readonly converter;
|
|
83
|
+
constructor(options?: OpenAPIGeneratorOptions);
|
|
84
|
+
generate(router: RouterContract | AnyRouter, options?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPIDocument>;
|
|
85
|
+
private convertSchema;
|
|
86
|
+
private convertSchemas;
|
|
87
|
+
private request;
|
|
88
|
+
private successResponse;
|
|
89
|
+
private errorResponse;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
type PopulatedContractRouterOpenAPIPaths<T extends RouterContract> = T extends ProcedureContract<infer UInputSchema, infer UOutputSchema, infer UErrors> ? ProcedureContract<UInputSchema, UOutputSchema, UErrors> : {
|
|
93
|
+
[K in keyof T]: T[K] extends RouterContract ? PopulatedContractRouterOpenAPIPaths<T[K]> : never;
|
|
94
|
+
};
|
|
95
|
+
interface PopulateRouterContractOpenAPIPathsOptions {
|
|
96
|
+
/**
|
|
97
|
+
* Base path segments.
|
|
98
|
+
*/
|
|
99
|
+
path?: undefined | string[];
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Automatically populates missing openapi.path using router structure.
|
|
71
103
|
*
|
|
72
|
-
*
|
|
104
|
+
* Builds paths by joining router keys with `/`.
|
|
105
|
+
* Useful when you want to ensure all contracts define openapi.path, such as for NestJS integration requirements.
|
|
73
106
|
*/
|
|
74
|
-
declare function
|
|
75
|
-
|
|
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>>;
|
|
107
|
+
declare function populateRouterContractOpenAPIPaths<T extends RouterContract>(router: T, options?: PopulateRouterContractOpenAPIPathsOptions): PopulatedContractRouterOpenAPIPaths<T>;
|
|
77
108
|
|
|
78
109
|
/**
|
|
79
|
-
|
|
110
|
+
* Dynamic parameters are always returned in path order.
|
|
80
111
|
*/
|
|
81
|
-
declare function
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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;
|
|
111
|
-
|
|
112
|
-
declare const oo: {
|
|
113
|
-
spec: typeof customOpenAPIOperation;
|
|
114
|
-
};
|
|
112
|
+
declare function getDynamicPathParams(path: `/${string}`): {
|
|
113
|
+
segment: string;
|
|
114
|
+
startIndex: number;
|
|
115
|
+
parameterName: string;
|
|
116
|
+
allowsSlash: boolean;
|
|
117
|
+
}[] | undefined;
|
|
115
118
|
|
|
116
|
-
export {
|
|
117
|
-
export type {
|
|
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 };
|