@orpc/openapi 0.0.0-next.a05fbfd → 0.0.0-next.a09e9be
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 +27 -17
- package/dist/adapters/fetch/index.d.mts +12 -9
- package/dist/adapters/fetch/index.d.ts +12 -9
- package/dist/adapters/fetch/index.mjs +13 -6
- package/dist/adapters/node/index.d.mts +12 -9
- package/dist/adapters/node/index.d.ts +12 -9
- package/dist/adapters/node/index.mjs +8 -20
- package/dist/adapters/standard/index.d.mts +21 -11
- package/dist/adapters/standard/index.d.ts +21 -11
- package/dist/adapters/standard/index.mjs +4 -3
- package/dist/index.d.mts +85 -155
- package/dist/index.d.ts +85 -155
- package/dist/index.mjs +34 -654
- package/dist/plugins/index.d.mts +70 -0
- package/dist/plugins/index.d.ts +70 -0
- package/dist/plugins/index.mjs +108 -0
- package/dist/shared/openapi.D3j94c9n.d.mts +12 -0
- package/dist/shared/openapi.D3j94c9n.d.ts +12 -0
- package/dist/shared/openapi.DP97kr00.d.mts +47 -0
- package/dist/shared/openapi.DP97kr00.d.ts +47 -0
- package/dist/shared/openapi.fMEQd3Yd.mjs +544 -0
- package/dist/shared/{openapi.CDsfPHgw.mjs → openapi.p5tsmBXx.mjs} +34 -24
- package/package.json +15 -22
- package/dist/adapters/hono/index.d.mts +0 -7
- package/dist/adapters/hono/index.d.ts +0 -7
- package/dist/adapters/hono/index.mjs +0 -10
- package/dist/adapters/next/index.d.mts +0 -7
- package/dist/adapters/next/index.d.ts +0 -7
- package/dist/adapters/next/index.mjs +0 -10
- package/dist/shared/openapi.BHG_gu5Z.mjs +0 -8
- package/dist/shared/openapi.D0VMNR6V.mjs +0 -25
- package/dist/shared/openapi.Dz_6xooR.d.mts +0 -7
- package/dist/shared/openapi.Dz_6xooR.d.ts +0 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,169 +1,99 @@
|
|
|
1
|
-
import { AnyContractProcedure
|
|
2
|
-
import
|
|
3
|
-
export { OpenAPI };
|
|
4
|
-
export {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
export { Format as JSONSchemaFormat } from 'json-schema-typed/draft-2020-12';
|
|
8
|
-
import {
|
|
9
|
-
import { AnyRouter } from '@orpc/server';
|
|
1
|
+
import { AnyContractProcedure } from '@orpc/contract';
|
|
2
|
+
import { OpenAPIV3_1 } from 'openapi-types';
|
|
3
|
+
export { OpenAPIV3_1 as OpenAPI } from 'openapi-types';
|
|
4
|
+
export { d as CompositeSchemaConverter, C as ConditionalSchemaConverter, b as OpenAPIGenerator, a as OpenAPIGeneratorGenerateOptions, O as OpenAPIGeneratorOptions, S as SchemaConvertOptions, c as SchemaConverter } from './shared/openapi.DP97kr00.js';
|
|
5
|
+
import { HTTPPath, HTTPMethod } from '@orpc/client';
|
|
6
|
+
import { JSONSchema } from 'json-schema-typed/draft-2020-12';
|
|
7
|
+
export { JSONSchema, ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat } from 'json-schema-typed/draft-2020-12';
|
|
8
|
+
import { JsonifiedClient } from '@orpc/openapi-client';
|
|
9
|
+
import { AnyRouter, ClientContext, Lazyable, CreateProcedureClientOptions, InferRouterInitialContext, Schema, ErrorMap, Meta, RouterClient } from '@orpc/server';
|
|
10
|
+
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
11
|
+
import '@orpc/openapi-client/standard';
|
|
10
12
|
|
|
11
|
-
type OverrideOperationValue =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
type OverrideOperationValue = Partial<OpenAPIV3_1.OperationObject> | ((current: OpenAPIV3_1.OperationObject, procedure: AnyContractProcedure) => OpenAPIV3_1.OperationObject);
|
|
14
|
+
/**
|
|
15
|
+
* Customize The Operation Object by proxy an error map item or a middleware.
|
|
16
|
+
*
|
|
17
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#customizing-operation-objects Customizing Operation Objects Docs}
|
|
18
|
+
*/
|
|
19
|
+
declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
|
|
20
|
+
declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
|
|
21
|
+
declare function applyCustomOpenAPIOperation(operation: OpenAPIV3_1.OperationObject, contract: AnyContractProcedure): OpenAPIV3_1.OperationObject;
|
|
15
22
|
|
|
16
|
-
|
|
23
|
+
/**
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
type ObjectSchema = JSONSchema & {
|
|
17
27
|
type: 'object';
|
|
18
28
|
} & object;
|
|
19
|
-
|
|
29
|
+
/**
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
type FileSchema = JSONSchema & {
|
|
20
33
|
type: 'string';
|
|
21
34
|
contentMediaType: string;
|
|
22
35
|
} & object;
|
|
23
|
-
|
|
36
|
+
/**
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
declare const LOGIC_KEYWORDS: string[];
|
|
24
40
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
41
|
+
/**
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
declare function toOpenAPIPath(path: HTTPPath): string;
|
|
45
|
+
/**
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
declare function toOpenAPIMethod(method: HTTPMethod): Lowercase<HTTPMethod>;
|
|
49
|
+
/**
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPIV3_1.MediaTypeObject>;
|
|
53
|
+
/**
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
declare function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema]): Record<string, OpenAPIV3_1.MediaTypeObject>;
|
|
57
|
+
/**
|
|
58
|
+
* @internal
|
|
59
|
+
*/
|
|
60
|
+
declare function toOpenAPIParameters(schema: ObjectSchema, parameterIn: 'path' | 'query' | 'header' | 'cookie'): OpenAPIV3_1.ParameterObject[];
|
|
61
|
+
/**
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
declare function checkParamsSchema(schema: ObjectSchema, params: string[]): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
68
|
+
declare function toOpenAPISchema(schema: JSONSchema): OpenAPIV3_1.SchemaObject & object;
|
|
34
69
|
|
|
35
|
-
declare
|
|
36
|
-
private readonly schemaUtils;
|
|
37
|
-
constructor(schemaUtils: PublicSchemaUtils);
|
|
38
|
-
build(jsonSchema: JSONSchema.JSONSchema, options?: Partial<OpenAPI.MediaTypeObject>): OpenAPI.ContentObject;
|
|
39
|
-
}
|
|
40
|
-
type PublicOpenAPIContentBuilder = Pick<OpenAPIContentBuilder, keyof OpenAPIContentBuilder>;
|
|
70
|
+
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>>;
|
|
41
71
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
declare
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
interface OpenAPIInputStructureParseResult {
|
|
65
|
-
paramsSchema: ObjectSchema | undefined;
|
|
66
|
-
querySchema: ObjectSchema | undefined;
|
|
67
|
-
headersSchema: ObjectSchema | undefined;
|
|
68
|
-
bodySchema: JSONSchema.JSONSchema | undefined;
|
|
69
|
-
}
|
|
70
|
-
declare class OpenAPIInputStructureParser {
|
|
71
|
-
private readonly schemaConverter;
|
|
72
|
-
private readonly schemaUtils;
|
|
73
|
-
private readonly pathParser;
|
|
74
|
-
constructor(schemaConverter: SchemaConverter, schemaUtils: PublicSchemaUtils, pathParser: PublicOpenAPIPathParser);
|
|
75
|
-
parse(contract: AnyContractProcedure, structure: 'compact' | 'detailed'): OpenAPIInputStructureParseResult;
|
|
76
|
-
private parseDetailedSchema;
|
|
77
|
-
private parseCompactSchema;
|
|
78
|
-
}
|
|
79
|
-
type PublicOpenAPIInputStructureParser = Pick<OpenAPIInputStructureParser, keyof OpenAPIInputStructureParser>;
|
|
80
|
-
|
|
81
|
-
interface OpenAPIOutputStructureParseResult {
|
|
82
|
-
headersSchema: ObjectSchema | undefined;
|
|
83
|
-
bodySchema: JSONSchema.JSONSchema | undefined;
|
|
84
|
-
}
|
|
85
|
-
declare class OpenAPIOutputStructureParser {
|
|
86
|
-
private readonly schemaConverter;
|
|
87
|
-
private readonly schemaUtils;
|
|
88
|
-
constructor(schemaConverter: SchemaConverter, schemaUtils: PublicSchemaUtils);
|
|
89
|
-
parse(contract: AnyContractProcedure, structure: 'compact' | 'detailed'): OpenAPIOutputStructureParseResult;
|
|
90
|
-
private parseDetailedSchema;
|
|
91
|
-
private parseCompactSchema;
|
|
92
|
-
}
|
|
93
|
-
type PublicOpenAPIOutputStructureParser = Pick<OpenAPIOutputStructureParser, keyof OpenAPIOutputStructureParser>;
|
|
94
|
-
|
|
95
|
-
declare class OpenAPIParametersBuilder {
|
|
96
|
-
build(paramIn: OpenAPI.ParameterObject['in'], jsonSchema: JSONSchema.JSONSchema & {
|
|
97
|
-
type: 'object';
|
|
98
|
-
} & object, options?: Pick<OpenAPI.ParameterObject, 'example' | 'style' | 'required'>): OpenAPI.ParameterObject[];
|
|
99
|
-
buildHeadersObject(jsonSchema: JSONSchema.JSONSchema & {
|
|
100
|
-
type: 'object';
|
|
101
|
-
} & object, options?: Pick<OpenAPI.ParameterObject, 'example' | 'style' | 'required'>): OpenAPI.HeadersObject;
|
|
102
|
-
}
|
|
103
|
-
type PublicOpenAPIParametersBuilder = Pick<OpenAPIParametersBuilder, keyof OpenAPIParametersBuilder>;
|
|
104
|
-
|
|
105
|
-
type ErrorHandlerStrategy = 'throw' | 'log' | 'ignore';
|
|
106
|
-
interface OpenAPIGeneratorOptions {
|
|
107
|
-
contentBuilder?: PublicOpenAPIContentBuilder;
|
|
108
|
-
parametersBuilder?: PublicOpenAPIParametersBuilder;
|
|
109
|
-
schemaConverters?: SchemaConverter[];
|
|
110
|
-
schemaUtils?: PublicSchemaUtils;
|
|
111
|
-
jsonSerializer?: OpenAPIJsonSerializer;
|
|
112
|
-
pathParser?: PublicOpenAPIPathParser;
|
|
113
|
-
inputStructureParser?: PublicOpenAPIInputStructureParser;
|
|
114
|
-
outputStructureParser?: PublicOpenAPIOutputStructureParser;
|
|
115
|
-
/**
|
|
116
|
-
* Throw error when you missing define tag definition on OpenAPI root tags
|
|
117
|
-
*
|
|
118
|
-
* Example: if procedure has tags ['foo', 'bar'], and OpenAPI root tags is ['foo'], then error will be thrown
|
|
119
|
-
* Because OpenAPI root tags is missing 'bar' tag
|
|
120
|
-
*
|
|
121
|
-
* @default false
|
|
122
|
-
*/
|
|
123
|
-
considerMissingTagDefinitionAsError?: boolean;
|
|
124
|
-
/**
|
|
125
|
-
* Weather ignore procedures that has no path defined.
|
|
126
|
-
*
|
|
127
|
-
* @default false
|
|
128
|
-
*/
|
|
129
|
-
ignoreUndefinedPathProcedures?: boolean;
|
|
130
|
-
/**
|
|
131
|
-
* What to do when we found an error with our router
|
|
132
|
-
*
|
|
133
|
-
* @default 'throw'
|
|
134
|
-
*/
|
|
135
|
-
errorHandlerStrategy?: ErrorHandlerStrategy;
|
|
136
|
-
/**
|
|
137
|
-
* Strict error response
|
|
138
|
-
*
|
|
139
|
-
* @default true
|
|
140
|
-
*/
|
|
141
|
-
strictErrorResponses?: boolean;
|
|
142
|
-
}
|
|
143
|
-
declare class OpenAPIGenerator {
|
|
144
|
-
private readonly contentBuilder;
|
|
145
|
-
private readonly parametersBuilder;
|
|
146
|
-
private readonly schemaConverter;
|
|
147
|
-
private readonly schemaUtils;
|
|
148
|
-
private readonly jsonSerializer;
|
|
149
|
-
private readonly pathParser;
|
|
150
|
-
private readonly inputStructureParser;
|
|
151
|
-
private readonly outputStructureParser;
|
|
152
|
-
private readonly errorHandlerStrategy;
|
|
153
|
-
private readonly ignoreUndefinedPathProcedures;
|
|
154
|
-
private readonly considerMissingTagDefinitionAsError;
|
|
155
|
-
private readonly strictErrorResponses;
|
|
156
|
-
constructor(options?: OpenAPIGeneratorOptions);
|
|
157
|
-
generate(router: ContractRouter<any> | AnyRouter, doc: Omit<OpenAPI.OpenAPIObject, 'openapi'>): Promise<OpenAPI.OpenAPIObject>;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
declare function standardizeHTTPPath(path: HTTPPath): HTTPPath;
|
|
161
|
-
declare function toOpenAPI31RoutePattern(path: HTTPPath): string;
|
|
162
|
-
|
|
163
|
-
/** unnoq */
|
|
72
|
+
/**
|
|
73
|
+
*@internal
|
|
74
|
+
*/
|
|
75
|
+
declare function isFileSchema(schema: JSONSchema): schema is FileSchema;
|
|
76
|
+
/**
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
declare function isObjectSchema(schema: JSONSchema): schema is ObjectSchema;
|
|
80
|
+
/**
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
declare function isAnySchema(schema: JSONSchema): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
87
|
+
declare function separateObjectSchema(schema: ObjectSchema, separatedProperties: string[]): [matched: ObjectSchema, rest: ObjectSchema];
|
|
88
|
+
/**
|
|
89
|
+
* @internal
|
|
90
|
+
*/
|
|
91
|
+
declare function filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
|
|
92
|
+
declare function applySchemaOptionality(required: boolean, schema: JSONSchema): JSONSchema;
|
|
164
93
|
|
|
165
94
|
declare const oo: {
|
|
166
|
-
spec: typeof
|
|
95
|
+
spec: typeof customOpenAPIOperation;
|
|
167
96
|
};
|
|
168
97
|
|
|
169
|
-
export {
|
|
98
|
+
export { LOGIC_KEYWORDS, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, createJsonifiedRouterClient, customOpenAPIOperation, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, oo, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
|
|
99
|
+
export type { FileSchema, ObjectSchema, OverrideOperationValue };
|