@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.
- package/README.md +71 -52
- package/dist/adapters/aws-lambda/index.d.mts +20 -0
- package/dist/adapters/aws-lambda/index.d.ts +20 -0
- package/dist/adapters/aws-lambda/index.mjs +18 -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 +18 -0
- package/dist/adapters/fetch/index.d.mts +16 -20
- package/dist/adapters/fetch/index.d.ts +16 -20
- package/dist/adapters/fetch/index.mjs +8 -24
- package/dist/adapters/node/index.d.mts +13 -8
- package/dist/adapters/node/index.d.ts +13 -8
- package/dist/adapters/node/index.mjs +7 -10
- package/dist/adapters/standard/index.d.mts +16 -46
- package/dist/adapters/standard/index.d.ts +16 -46
- package/dist/adapters/standard/index.mjs +6 -9
- package/dist/index.d.mts +105 -117
- package/dist/index.d.ts +105 -117
- package/dist/index.mjs +32 -850
- package/dist/plugins/index.d.mts +51 -55
- package/dist/plugins/index.d.ts +51 -55
- package/dist/plugins/index.mjs +142 -147
- package/dist/shared/openapi.BGy4N6eR.d.mts +120 -0
- package/dist/shared/openapi.BGy4N6eR.d.ts +120 -0
- package/dist/shared/openapi.BwdtJjDu.mjs +878 -0
- package/dist/shared/openapi.CdeSk3f7.d.mts +54 -0
- package/dist/shared/openapi.CdeSk3f7.d.ts +54 -0
- package/dist/shared/openapi.DPiCV5hl.mjs +208 -0
- package/package.json +24 -46
- package/dist/extensions/route.d.mts +0 -43
- package/dist/extensions/route.d.ts +0 -43
- package/dist/extensions/route.mjs +0 -14
- package/dist/helpers/index.d.mts +0 -51
- package/dist/helpers/index.d.ts +0 -51
- package/dist/helpers/index.mjs +0 -39
- package/dist/shared/openapi.B6hEbRyF.d.ts +0 -83
- package/dist/shared/openapi.B9PQzqBn.mjs +0 -49
- package/dist/shared/openapi.BOOA-bde.d.mts +0 -142
- package/dist/shared/openapi.BOOA-bde.d.ts +0 -142
- package/dist/shared/openapi.BafbB3uM.d.mts +0 -83
- package/dist/shared/openapi.Bt87OzTt.mjs +0 -131
- package/dist/shared/openapi.ByT4oUeY.d.mts +0 -18
- package/dist/shared/openapi.ByT4oUeY.d.ts +0 -18
- package/dist/shared/openapi.C-p_Q2lb.mjs +0 -359
- package/dist/shared/openapi.CVgUshDP.mjs +0 -318
- package/dist/shared/openapi.DNNo0V-l.d.ts +0 -313
- package/dist/shared/openapi.hg_rhZ4x.d.mts +0 -313
- package/dist/shared/openapi.zZH_UksW.mjs +0 -278
|
@@ -1,50 +1,20 @@
|
|
|
1
|
-
export { a as
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
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
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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 {
|
|
50
|
-
export type { OpenAPILinkCodecOptions };
|
|
20
|
+
export { decodeParams, toRou3Pattern };
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
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/
|
|
5
|
+
import '@orpc/contract';
|
|
5
6
|
import '@orpc/shared';
|
|
6
|
-
import '@
|
|
7
|
-
import '
|
|
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 {
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
*
|
|
35
|
-
|
|
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
|
|
63
|
+
declare function checkParamsSchema(schema: ObjectSchema, params: string[]): boolean;
|
|
38
64
|
/**
|
|
39
|
-
*
|
|
65
|
+
* @internal
|
|
40
66
|
*/
|
|
41
|
-
declare function
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
|
|
112
|
-
|
|
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 {
|
|
129
|
-
export type {
|
|
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 {
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
*
|
|
35
|
-
|
|
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
|
|
63
|
+
declare function checkParamsSchema(schema: ObjectSchema, params: string[]): boolean;
|
|
38
64
|
/**
|
|
39
|
-
*
|
|
65
|
+
* @internal
|
|
40
66
|
*/
|
|
41
|
-
declare function
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
|
|
112
|
-
|
|
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 {
|
|
129
|
-
export type {
|
|
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 };
|