@orpc/openapi 0.0.0-next.4534675 → 0.0.0-next.460b50b
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 +28 -20
- package/dist/adapters/aws-lambda/index.d.mts +17 -0
- package/dist/adapters/aws-lambda/index.d.ts +17 -0
- package/dist/adapters/aws-lambda/index.mjs +18 -0
- package/dist/adapters/fetch/index.d.mts +12 -8
- package/dist/adapters/fetch/index.d.ts +12 -8
- package/dist/adapters/fetch/index.mjs +14 -7
- package/dist/adapters/node/index.d.mts +12 -8
- package/dist/adapters/node/index.d.ts +12 -8
- package/dist/adapters/node/index.mjs +9 -24
- package/dist/adapters/standard/index.d.mts +9 -8
- package/dist/adapters/standard/index.d.ts +9 -8
- package/dist/adapters/standard/index.mjs +5 -3
- package/dist/index.d.mts +37 -46
- package/dist/index.d.ts +37 -46
- package/dist/index.mjs +30 -292
- package/dist/plugins/index.d.mts +69 -0
- package/dist/plugins/index.d.ts +69 -0
- package/dist/plugins/index.mjs +108 -0
- package/dist/shared/openapi.C_3bk7bB.mjs +725 -0
- package/dist/shared/{openapi.DFXD6scT.mjs → openapi.C_UtQ8Us.mjs} +54 -23
- package/dist/shared/openapi.CbIlrReM.d.mts +98 -0
- package/dist/shared/openapi.CbIlrReM.d.ts +98 -0
- package/dist/shared/openapi.D3j94c9n.d.mts +12 -0
- package/dist/shared/openapi.D3j94c9n.d.ts +12 -0
- package/package.json +19 -22
- package/dist/adapters/hono/index.d.mts +0 -6
- package/dist/adapters/hono/index.d.ts +0 -6
- package/dist/adapters/hono/index.mjs +0 -11
- package/dist/adapters/next/index.d.mts +0 -6
- package/dist/adapters/next/index.d.ts +0 -6
- package/dist/adapters/next/index.mjs +0 -11
- package/dist/shared/openapi.C015V43J.mjs +0 -31
- package/dist/shared/openapi.DZzpQAb-.mjs +0 -231
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import { standardizeHTTPPath, StandardOpenAPIJsonSerializer, StandardBracketNotationSerializer, StandardOpenAPISerializer } from '@orpc/openapi-client/standard';
|
|
2
|
+
import { StandardHandler } from '@orpc/server/standard';
|
|
3
|
+
import { isORPCErrorStatus } from '@orpc/client';
|
|
1
4
|
import { fallbackContractConfig } from '@orpc/contract';
|
|
2
|
-
import { isObject } from '@orpc/shared';
|
|
3
|
-
import {
|
|
5
|
+
import { isObject, stringifyJSON } from '@orpc/shared';
|
|
6
|
+
import { toHttpPath } from '@orpc/client/standard';
|
|
7
|
+
import { traverseContractProcedures, isProcedure, getLazyMeta, unlazy, getRouter, createContractedProcedure } from '@orpc/server';
|
|
4
8
|
import { createRouter, addRoute, findRoute } from 'rou3';
|
|
5
|
-
import { s as standardizeHTTPPath } from './openapi.DZzpQAb-.mjs';
|
|
6
9
|
|
|
7
|
-
class
|
|
10
|
+
class StandardOpenAPICodec {
|
|
8
11
|
constructor(serializer) {
|
|
9
12
|
this.serializer = serializer;
|
|
10
13
|
}
|
|
@@ -50,13 +53,21 @@ class OpenAPICodec {
|
|
|
50
53
|
body: this.serializer.serialize(output)
|
|
51
54
|
};
|
|
52
55
|
}
|
|
53
|
-
if (!
|
|
54
|
-
throw new Error(
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
if (!this.#isDetailedOutput(output)) {
|
|
57
|
+
throw new Error(`
|
|
58
|
+
Invalid "detailed" output structure:
|
|
59
|
+
\u2022 Expected an object with optional properties:
|
|
60
|
+
- status (number 200-399)
|
|
61
|
+
- headers (Record<string, string | string[]>)
|
|
62
|
+
- body (any)
|
|
63
|
+
\u2022 No extra keys allowed.
|
|
64
|
+
|
|
65
|
+
Actual value:
|
|
66
|
+
${stringifyJSON(output)}
|
|
67
|
+
`);
|
|
57
68
|
}
|
|
58
69
|
return {
|
|
59
|
-
status: successStatus,
|
|
70
|
+
status: output.status ?? successStatus,
|
|
60
71
|
headers: output.headers ?? {},
|
|
61
72
|
body: this.serializer.serialize(output.body)
|
|
62
73
|
};
|
|
@@ -65,9 +76,21 @@ class OpenAPICodec {
|
|
|
65
76
|
return {
|
|
66
77
|
status: error.status,
|
|
67
78
|
headers: {},
|
|
68
|
-
body: this.serializer.serialize(error.toJSON())
|
|
79
|
+
body: this.serializer.serialize(error.toJSON(), { outputFormat: "plain" })
|
|
69
80
|
};
|
|
70
81
|
}
|
|
82
|
+
#isDetailedOutput(output) {
|
|
83
|
+
if (!isObject(output)) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
if (output.headers && !isObject(output.headers)) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
if (output.status !== void 0 && (typeof output.status !== "number" || !Number.isInteger(output.status) || isORPCErrorStatus(output.status))) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
71
94
|
}
|
|
72
95
|
|
|
73
96
|
function toRou3Pattern(path) {
|
|
@@ -77,16 +100,13 @@ function decodeParams(params) {
|
|
|
77
100
|
return Object.fromEntries(Object.entries(params).map(([key, value]) => [key, decodeURIComponent(value)]));
|
|
78
101
|
}
|
|
79
102
|
|
|
80
|
-
class
|
|
103
|
+
class StandardOpenAPIMatcher {
|
|
81
104
|
tree = createRouter();
|
|
82
105
|
pendingRouters = [];
|
|
83
106
|
init(router, path = []) {
|
|
84
|
-
const laziedOptions =
|
|
85
|
-
router,
|
|
86
|
-
path
|
|
87
|
-
}, ({ path: path2, contract }) => {
|
|
107
|
+
const laziedOptions = traverseContractProcedures({ router, path }, ({ path: path2, contract }) => {
|
|
88
108
|
const method = fallbackContractConfig("defaultMethod", contract["~orpc"].route.method);
|
|
89
|
-
const httpPath =
|
|
109
|
+
const httpPath = toRou3Pattern(contract["~orpc"].route.path ?? toHttpPath(path2));
|
|
90
110
|
if (isProcedure(contract)) {
|
|
91
111
|
addRoute(this.tree, method, httpPath, {
|
|
92
112
|
path: path2,
|
|
@@ -106,8 +126,8 @@ class OpenAPIMatcher {
|
|
|
106
126
|
});
|
|
107
127
|
this.pendingRouters.push(...laziedOptions.map((option) => ({
|
|
108
128
|
...option,
|
|
109
|
-
httpPathPrefix:
|
|
110
|
-
laziedPrefix:
|
|
129
|
+
httpPathPrefix: toHttpPath(option.path),
|
|
130
|
+
laziedPrefix: getLazyMeta(option.router).prefix
|
|
111
131
|
})));
|
|
112
132
|
}
|
|
113
133
|
async match(method, pathname) {
|
|
@@ -115,7 +135,7 @@ class OpenAPIMatcher {
|
|
|
115
135
|
const newPendingRouters = [];
|
|
116
136
|
for (const pendingRouter of this.pendingRouters) {
|
|
117
137
|
if (!pendingRouter.laziedPrefix || pathname.startsWith(pendingRouter.laziedPrefix) || pathname.startsWith(pendingRouter.httpPathPrefix)) {
|
|
118
|
-
const { default: router } = await unlazy(pendingRouter.
|
|
138
|
+
const { default: router } = await unlazy(pendingRouter.router);
|
|
119
139
|
this.init(router, pendingRouter.path);
|
|
120
140
|
} else {
|
|
121
141
|
newPendingRouters.push(pendingRouter);
|
|
@@ -128,14 +148,14 @@ class OpenAPIMatcher {
|
|
|
128
148
|
return void 0;
|
|
129
149
|
}
|
|
130
150
|
if (!match.data.procedure) {
|
|
131
|
-
const { default: maybeProcedure } = await unlazy(
|
|
151
|
+
const { default: maybeProcedure } = await unlazy(getRouter(match.data.router, match.data.path));
|
|
132
152
|
if (!isProcedure(maybeProcedure)) {
|
|
133
153
|
throw new Error(`
|
|
134
|
-
[Contract-First] Missing or invalid implementation for procedure at path: ${
|
|
154
|
+
[Contract-First] Missing or invalid implementation for procedure at path: ${toHttpPath(match.data.path)}.
|
|
135
155
|
Ensure that the procedure is correctly defined and matches the expected contract.
|
|
136
156
|
`);
|
|
137
157
|
}
|
|
138
|
-
match.data.procedure = createContractedProcedure(match.data.contract
|
|
158
|
+
match.data.procedure = createContractedProcedure(maybeProcedure, match.data.contract);
|
|
139
159
|
}
|
|
140
160
|
return {
|
|
141
161
|
path: match.data.path,
|
|
@@ -145,4 +165,15 @@ class OpenAPIMatcher {
|
|
|
145
165
|
}
|
|
146
166
|
}
|
|
147
167
|
|
|
148
|
-
|
|
168
|
+
class StandardOpenAPIHandler extends StandardHandler {
|
|
169
|
+
constructor(router, options) {
|
|
170
|
+
const jsonSerializer = new StandardOpenAPIJsonSerializer(options);
|
|
171
|
+
const bracketNotationSerializer = new StandardBracketNotationSerializer();
|
|
172
|
+
const serializer = new StandardOpenAPISerializer(jsonSerializer, bracketNotationSerializer);
|
|
173
|
+
const matcher = new StandardOpenAPIMatcher();
|
|
174
|
+
const codec = new StandardOpenAPICodec(serializer);
|
|
175
|
+
super(router, matcher, codec, options);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export { StandardOpenAPICodec as S, StandardOpenAPIHandler as a, StandardOpenAPIMatcher as b, decodeParams as d, toRou3Pattern as t };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { AnySchema, OpenAPI, AnyContractProcedure, AnyContractRouter } from '@orpc/contract';
|
|
2
|
+
import { StandardOpenAPIJsonSerializerOptions } from '@orpc/openapi-client/standard';
|
|
3
|
+
import { AnyProcedure, AnyRouter } from '@orpc/server';
|
|
4
|
+
import { Promisable } from '@orpc/shared';
|
|
5
|
+
import { JSONSchema } from 'json-schema-typed/draft-2020-12';
|
|
6
|
+
|
|
7
|
+
interface SchemaConverterComponent {
|
|
8
|
+
allowedStrategies: SchemaConvertOptions['strategy'][];
|
|
9
|
+
schema: AnySchema;
|
|
10
|
+
required: boolean;
|
|
11
|
+
ref: string;
|
|
12
|
+
}
|
|
13
|
+
interface SchemaConvertOptions {
|
|
14
|
+
strategy: 'input' | 'output';
|
|
15
|
+
/**
|
|
16
|
+
* Common components should use `$ref` to represent themselves if matched.
|
|
17
|
+
*/
|
|
18
|
+
components?: SchemaConverterComponent[];
|
|
19
|
+
/**
|
|
20
|
+
* Minimum schema structure depth required before using `$ref` for components.
|
|
21
|
+
*
|
|
22
|
+
* For example, if set to 2, `$ref` will only be used for schemas nested at depth 2 or greater.
|
|
23
|
+
*
|
|
24
|
+
* @default 0 - No depth limit;
|
|
25
|
+
*/
|
|
26
|
+
minStructureDepthForRef?: number;
|
|
27
|
+
}
|
|
28
|
+
interface SchemaConverter {
|
|
29
|
+
convert(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<[required: boolean, jsonSchema: JSONSchema]>;
|
|
30
|
+
}
|
|
31
|
+
interface ConditionalSchemaConverter extends SchemaConverter {
|
|
32
|
+
condition(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<boolean>;
|
|
33
|
+
}
|
|
34
|
+
declare class CompositeSchemaConverter implements SchemaConverter {
|
|
35
|
+
private readonly converters;
|
|
36
|
+
constructor(converters: ConditionalSchemaConverter[]);
|
|
37
|
+
convert(schema: AnySchema | undefined, options: SchemaConvertOptions): Promise<[required: boolean, jsonSchema: JSONSchema]>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface OpenAPIGeneratorOptions extends StandardOpenAPIJsonSerializerOptions {
|
|
41
|
+
schemaConverters?: ConditionalSchemaConverter[];
|
|
42
|
+
}
|
|
43
|
+
interface OpenAPIGeneratorGenerateOptions extends Partial<Omit<OpenAPI.Document, 'openapi'>> {
|
|
44
|
+
/**
|
|
45
|
+
* Exclude procedures from the OpenAPI specification.
|
|
46
|
+
*
|
|
47
|
+
* @default () => false
|
|
48
|
+
*/
|
|
49
|
+
exclude?: (procedure: AnyProcedure | AnyContractProcedure, path: readonly string[]) => boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Common schemas to be used for $ref resolution.
|
|
52
|
+
*/
|
|
53
|
+
commonSchemas?: Record<string, {
|
|
54
|
+
/**
|
|
55
|
+
* Determines which schema definition to use when input and output schemas differ.
|
|
56
|
+
* This is needed because some schemas transform data differently between input and output,
|
|
57
|
+
* making it impossible to use a single $ref for both cases.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* // This schema transforms a string input into a number output
|
|
62
|
+
* const Schema = z.string()
|
|
63
|
+
* .transform(v => Number(v))
|
|
64
|
+
* .pipe(z.number())
|
|
65
|
+
*
|
|
66
|
+
* // Input schema: { type: 'string' }
|
|
67
|
+
* // Output schema: { type: 'number' }
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* When schemas differ between input and output, you must explicitly choose
|
|
71
|
+
* which version to use for the OpenAPI specification.
|
|
72
|
+
*
|
|
73
|
+
* @default 'input' - Uses the input schema definition by default
|
|
74
|
+
*/
|
|
75
|
+
strategy?: SchemaConvertOptions['strategy'];
|
|
76
|
+
schema: AnySchema;
|
|
77
|
+
}>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The generator that converts oRPC routers/contracts to OpenAPI specifications.
|
|
81
|
+
*
|
|
82
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
|
|
83
|
+
*/
|
|
84
|
+
declare class OpenAPIGenerator {
|
|
85
|
+
#private;
|
|
86
|
+
private readonly serializer;
|
|
87
|
+
private readonly converter;
|
|
88
|
+
constructor(options?: OpenAPIGeneratorOptions);
|
|
89
|
+
/**
|
|
90
|
+
* Generates OpenAPI specifications from oRPC routers/contracts.
|
|
91
|
+
*
|
|
92
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
|
|
93
|
+
*/
|
|
94
|
+
generate(router: AnyContractRouter | AnyRouter, options?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPI.Document>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export { OpenAPIGenerator as b, CompositeSchemaConverter as e };
|
|
98
|
+
export type { ConditionalSchemaConverter as C, OpenAPIGeneratorOptions as O, SchemaConverterComponent as S, OpenAPIGeneratorGenerateOptions as a, SchemaConvertOptions as c, SchemaConverter as d };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { AnySchema, OpenAPI, AnyContractProcedure, AnyContractRouter } from '@orpc/contract';
|
|
2
|
+
import { StandardOpenAPIJsonSerializerOptions } from '@orpc/openapi-client/standard';
|
|
3
|
+
import { AnyProcedure, AnyRouter } from '@orpc/server';
|
|
4
|
+
import { Promisable } from '@orpc/shared';
|
|
5
|
+
import { JSONSchema } from 'json-schema-typed/draft-2020-12';
|
|
6
|
+
|
|
7
|
+
interface SchemaConverterComponent {
|
|
8
|
+
allowedStrategies: SchemaConvertOptions['strategy'][];
|
|
9
|
+
schema: AnySchema;
|
|
10
|
+
required: boolean;
|
|
11
|
+
ref: string;
|
|
12
|
+
}
|
|
13
|
+
interface SchemaConvertOptions {
|
|
14
|
+
strategy: 'input' | 'output';
|
|
15
|
+
/**
|
|
16
|
+
* Common components should use `$ref` to represent themselves if matched.
|
|
17
|
+
*/
|
|
18
|
+
components?: SchemaConverterComponent[];
|
|
19
|
+
/**
|
|
20
|
+
* Minimum schema structure depth required before using `$ref` for components.
|
|
21
|
+
*
|
|
22
|
+
* For example, if set to 2, `$ref` will only be used for schemas nested at depth 2 or greater.
|
|
23
|
+
*
|
|
24
|
+
* @default 0 - No depth limit;
|
|
25
|
+
*/
|
|
26
|
+
minStructureDepthForRef?: number;
|
|
27
|
+
}
|
|
28
|
+
interface SchemaConverter {
|
|
29
|
+
convert(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<[required: boolean, jsonSchema: JSONSchema]>;
|
|
30
|
+
}
|
|
31
|
+
interface ConditionalSchemaConverter extends SchemaConverter {
|
|
32
|
+
condition(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<boolean>;
|
|
33
|
+
}
|
|
34
|
+
declare class CompositeSchemaConverter implements SchemaConverter {
|
|
35
|
+
private readonly converters;
|
|
36
|
+
constructor(converters: ConditionalSchemaConverter[]);
|
|
37
|
+
convert(schema: AnySchema | undefined, options: SchemaConvertOptions): Promise<[required: boolean, jsonSchema: JSONSchema]>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface OpenAPIGeneratorOptions extends StandardOpenAPIJsonSerializerOptions {
|
|
41
|
+
schemaConverters?: ConditionalSchemaConverter[];
|
|
42
|
+
}
|
|
43
|
+
interface OpenAPIGeneratorGenerateOptions extends Partial<Omit<OpenAPI.Document, 'openapi'>> {
|
|
44
|
+
/**
|
|
45
|
+
* Exclude procedures from the OpenAPI specification.
|
|
46
|
+
*
|
|
47
|
+
* @default () => false
|
|
48
|
+
*/
|
|
49
|
+
exclude?: (procedure: AnyProcedure | AnyContractProcedure, path: readonly string[]) => boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Common schemas to be used for $ref resolution.
|
|
52
|
+
*/
|
|
53
|
+
commonSchemas?: Record<string, {
|
|
54
|
+
/**
|
|
55
|
+
* Determines which schema definition to use when input and output schemas differ.
|
|
56
|
+
* This is needed because some schemas transform data differently between input and output,
|
|
57
|
+
* making it impossible to use a single $ref for both cases.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* // This schema transforms a string input into a number output
|
|
62
|
+
* const Schema = z.string()
|
|
63
|
+
* .transform(v => Number(v))
|
|
64
|
+
* .pipe(z.number())
|
|
65
|
+
*
|
|
66
|
+
* // Input schema: { type: 'string' }
|
|
67
|
+
* // Output schema: { type: 'number' }
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* When schemas differ between input and output, you must explicitly choose
|
|
71
|
+
* which version to use for the OpenAPI specification.
|
|
72
|
+
*
|
|
73
|
+
* @default 'input' - Uses the input schema definition by default
|
|
74
|
+
*/
|
|
75
|
+
strategy?: SchemaConvertOptions['strategy'];
|
|
76
|
+
schema: AnySchema;
|
|
77
|
+
}>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The generator that converts oRPC routers/contracts to OpenAPI specifications.
|
|
81
|
+
*
|
|
82
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
|
|
83
|
+
*/
|
|
84
|
+
declare class OpenAPIGenerator {
|
|
85
|
+
#private;
|
|
86
|
+
private readonly serializer;
|
|
87
|
+
private readonly converter;
|
|
88
|
+
constructor(options?: OpenAPIGeneratorOptions);
|
|
89
|
+
/**
|
|
90
|
+
* Generates OpenAPI specifications from oRPC routers/contracts.
|
|
91
|
+
*
|
|
92
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
|
|
93
|
+
*/
|
|
94
|
+
generate(router: AnyContractRouter | AnyRouter, options?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPI.Document>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export { OpenAPIGenerator as b, CompositeSchemaConverter as e };
|
|
98
|
+
export type { ConditionalSchemaConverter as C, OpenAPIGeneratorOptions as O, SchemaConverterComponent as S, OpenAPIGeneratorGenerateOptions as a, SchemaConvertOptions as c, SchemaConverter as d };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StandardOpenAPIJsonSerializerOptions } from '@orpc/openapi-client/standard';
|
|
2
|
+
import { Context, Router } from '@orpc/server';
|
|
3
|
+
import { StandardHandlerOptions, StandardHandler } from '@orpc/server/standard';
|
|
4
|
+
|
|
5
|
+
interface StandardOpenAPIHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardOpenAPIJsonSerializerOptions {
|
|
6
|
+
}
|
|
7
|
+
declare class StandardOpenAPIHandler<T extends Context> extends StandardHandler<T> {
|
|
8
|
+
constructor(router: Router<any, T>, options: NoInfer<StandardOpenAPIHandlerOptions<T>>);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { StandardOpenAPIHandler as a };
|
|
12
|
+
export type { StandardOpenAPIHandlerOptions as S };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StandardOpenAPIJsonSerializerOptions } from '@orpc/openapi-client/standard';
|
|
2
|
+
import { Context, Router } from '@orpc/server';
|
|
3
|
+
import { StandardHandlerOptions, StandardHandler } from '@orpc/server/standard';
|
|
4
|
+
|
|
5
|
+
interface StandardOpenAPIHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardOpenAPIJsonSerializerOptions {
|
|
6
|
+
}
|
|
7
|
+
declare class StandardOpenAPIHandler<T extends Context> extends StandardHandler<T> {
|
|
8
|
+
constructor(router: Router<any, T>, options: NoInfer<StandardOpenAPIHandlerOptions<T>>);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { StandardOpenAPIHandler as a };
|
|
12
|
+
export type { StandardOpenAPIHandlerOptions as S };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/openapi",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.460b50b",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -19,6 +19,11 @@
|
|
|
19
19
|
"import": "./dist/index.mjs",
|
|
20
20
|
"default": "./dist/index.mjs"
|
|
21
21
|
},
|
|
22
|
+
"./plugins": {
|
|
23
|
+
"types": "./dist/plugins/index.d.mts",
|
|
24
|
+
"import": "./dist/plugins/index.mjs",
|
|
25
|
+
"default": "./dist/plugins/index.mjs"
|
|
26
|
+
},
|
|
22
27
|
"./standard": {
|
|
23
28
|
"types": "./dist/adapters/standard/index.d.mts",
|
|
24
29
|
"import": "./dist/adapters/standard/index.mjs",
|
|
@@ -29,20 +34,15 @@
|
|
|
29
34
|
"import": "./dist/adapters/fetch/index.mjs",
|
|
30
35
|
"default": "./dist/adapters/fetch/index.mjs"
|
|
31
36
|
},
|
|
32
|
-
"./hono": {
|
|
33
|
-
"types": "./dist/adapters/hono/index.d.mts",
|
|
34
|
-
"import": "./dist/adapters/hono/index.mjs",
|
|
35
|
-
"default": "./dist/adapters/hono/index.mjs"
|
|
36
|
-
},
|
|
37
|
-
"./next": {
|
|
38
|
-
"types": "./dist/adapters/next/index.d.mts",
|
|
39
|
-
"import": "./dist/adapters/next/index.mjs",
|
|
40
|
-
"default": "./dist/adapters/next/index.mjs"
|
|
41
|
-
},
|
|
42
37
|
"./node": {
|
|
43
38
|
"types": "./dist/adapters/node/index.d.mts",
|
|
44
39
|
"import": "./dist/adapters/node/index.mjs",
|
|
45
40
|
"default": "./dist/adapters/node/index.mjs"
|
|
41
|
+
},
|
|
42
|
+
"./aws-lambda": {
|
|
43
|
+
"types": "./dist/adapters/aws-lambda/index.d.mts",
|
|
44
|
+
"import": "./dist/adapters/aws-lambda/index.mjs",
|
|
45
|
+
"default": "./dist/adapters/aws-lambda/index.mjs"
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"files": [
|
|
@@ -50,19 +50,16 @@
|
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"json-schema-typed": "^8.0.1",
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"@orpc/client": "0.0.0-next.
|
|
56
|
-
"@orpc/contract": "0.0.0-next.
|
|
57
|
-
"@orpc/
|
|
58
|
-
"@orpc/
|
|
59
|
-
"@orpc/server": "0.0.0-next.
|
|
60
|
-
"@orpc/shared": "0.0.0-next.4534675",
|
|
61
|
-
"@orpc/standard-server-node": "0.0.0-next.4534675",
|
|
62
|
-
"@orpc/standard-server-fetch": "0.0.0-next.4534675"
|
|
53
|
+
"rou3": "^0.6.0",
|
|
54
|
+
"@orpc/client": "0.0.0-next.460b50b",
|
|
55
|
+
"@orpc/openapi-client": "0.0.0-next.460b50b",
|
|
56
|
+
"@orpc/contract": "0.0.0-next.460b50b",
|
|
57
|
+
"@orpc/server": "0.0.0-next.460b50b",
|
|
58
|
+
"@orpc/shared": "0.0.0-next.460b50b",
|
|
59
|
+
"@orpc/standard-server": "0.0.0-next.460b50b"
|
|
63
60
|
},
|
|
64
61
|
"devDependencies": {
|
|
65
|
-
"zod": "^3.
|
|
62
|
+
"zod": "^3.25.63"
|
|
66
63
|
},
|
|
67
64
|
"scripts": {
|
|
68
65
|
"build": "unbuild",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { O as OpenAPIHandler } from '../../shared/openapi.C015V43J.mjs';
|
|
2
|
-
import '@orpc/openapi-client/standard';
|
|
3
|
-
import '@orpc/server/standard';
|
|
4
|
-
import '@orpc/standard-server-fetch';
|
|
5
|
-
import '../../shared/openapi.DFXD6scT.mjs';
|
|
6
|
-
import '@orpc/contract';
|
|
7
|
-
import '@orpc/shared';
|
|
8
|
-
import '@orpc/server';
|
|
9
|
-
import 'rou3';
|
|
10
|
-
import '../../shared/openapi.DZzpQAb-.mjs';
|
|
11
|
-
import 'json-schema-typed/draft-2020-12';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { O as OpenAPIHandler } from '../../shared/openapi.C015V43J.mjs';
|
|
2
|
-
import '@orpc/openapi-client/standard';
|
|
3
|
-
import '@orpc/server/standard';
|
|
4
|
-
import '@orpc/standard-server-fetch';
|
|
5
|
-
import '../../shared/openapi.DFXD6scT.mjs';
|
|
6
|
-
import '@orpc/contract';
|
|
7
|
-
import '@orpc/shared';
|
|
8
|
-
import '@orpc/server';
|
|
9
|
-
import 'rou3';
|
|
10
|
-
import '../../shared/openapi.DZzpQAb-.mjs';
|
|
11
|
-
import 'json-schema-typed/draft-2020-12';
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { OpenAPISerializer } from '@orpc/openapi-client/standard';
|
|
2
|
-
import { StandardHandler } from '@orpc/server/standard';
|
|
3
|
-
import { toStandardLazyRequest, toFetchResponse } from '@orpc/standard-server-fetch';
|
|
4
|
-
import { a as OpenAPIMatcher, O as OpenAPICodec } from './openapi.DFXD6scT.mjs';
|
|
5
|
-
import '@orpc/shared';
|
|
6
|
-
import 'json-schema-typed/draft-2020-12';
|
|
7
|
-
|
|
8
|
-
class OpenAPIHandler {
|
|
9
|
-
standardHandler;
|
|
10
|
-
constructor(router, options = {}) {
|
|
11
|
-
const serializer = new OpenAPISerializer();
|
|
12
|
-
const matcher = new OpenAPIMatcher();
|
|
13
|
-
const codec = new OpenAPICodec(serializer);
|
|
14
|
-
this.standardHandler = new StandardHandler(router, matcher, codec, options);
|
|
15
|
-
}
|
|
16
|
-
async handle(request, ...[
|
|
17
|
-
options = {}
|
|
18
|
-
]) {
|
|
19
|
-
const standardRequest = toStandardLazyRequest(request);
|
|
20
|
-
const result = await this.standardHandler.handle(standardRequest, options);
|
|
21
|
-
if (!result.matched) {
|
|
22
|
-
return result;
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
matched: true,
|
|
26
|
-
response: toFetchResponse(result.response, options)
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export { OpenAPIHandler as O };
|