@orpc/openapi 0.0.0-next.f4d410a → 0.0.0-next.f50512c
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 -22
- package/dist/adapters/aws-lambda/index.d.mts +19 -0
- package/dist/adapters/aws-lambda/index.d.ts +19 -0
- package/dist/adapters/aws-lambda/index.mjs +18 -0
- package/dist/adapters/fetch/index.d.mts +13 -9
- package/dist/adapters/fetch/index.d.ts +13 -9
- package/dist/adapters/fetch/index.mjs +14 -7
- package/dist/adapters/node/index.d.mts +13 -9
- package/dist/adapters/node/index.d.ts +13 -9
- package/dist/adapters/node/index.mjs +9 -26
- package/dist/adapters/standard/index.d.mts +7 -13
- package/dist/adapters/standard/index.d.ts +7 -13
- package/dist/adapters/standard/index.mjs +5 -3
- package/dist/index.d.mts +37 -47
- package/dist/index.d.ts +37 -47
- 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.BNHmrMe2.mjs → openapi.BkBlt1Qf.mjs} +53 -11
- package/dist/shared/openapi.BtoY8ZFF.mjs +742 -0
- package/dist/shared/openapi.CQmjvnb0.d.mts +31 -0
- package/dist/shared/openapi.CQmjvnb0.d.ts +31 -0
- package/dist/shared/openapi.DPAN3GVs.d.mts +108 -0
- package/dist/shared/openapi.DPAN3GVs.d.ts +108 -0
- package/package.json +19 -22
- package/dist/adapters/hono/index.d.mts +0 -8
- package/dist/adapters/hono/index.d.ts +0 -8
- package/dist/adapters/hono/index.mjs +0 -11
- package/dist/adapters/next/index.d.mts +0 -8
- package/dist/adapters/next/index.d.ts +0 -8
- package/dist/adapters/next/index.mjs +0 -11
- package/dist/shared/openapi.DZzpQAb-.mjs +0 -231
- package/dist/shared/openapi.Dv-KT_Bx.mjs +0 -33
- package/dist/shared/openapi.IfmmOyba.d.mts +0 -8
- package/dist/shared/openapi.IfmmOyba.d.ts +0 -8
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { StandardOpenAPIJsonSerializerOptions, StandardBracketNotationSerializerOptions } from '@orpc/openapi-client/standard';
|
|
2
|
+
import { TraverseContractProcedureCallbackOptions, AnyRouter, Context, Router } from '@orpc/server';
|
|
3
|
+
import { StandardMatcher, StandardMatchResult, StandardHandlerOptions, StandardHandler } from '@orpc/server/standard';
|
|
4
|
+
import { HTTPPath } from '@orpc/client';
|
|
5
|
+
import { Value } from '@orpc/shared';
|
|
6
|
+
|
|
7
|
+
interface StandardOpenAPIMatcherOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Filter procedures. Return `false` to exclude a procedure from matching.
|
|
10
|
+
*
|
|
11
|
+
* @default true
|
|
12
|
+
*/
|
|
13
|
+
filter?: Value<boolean, [options: TraverseContractProcedureCallbackOptions]>;
|
|
14
|
+
}
|
|
15
|
+
declare class StandardOpenAPIMatcher implements StandardMatcher {
|
|
16
|
+
private readonly filter;
|
|
17
|
+
private readonly tree;
|
|
18
|
+
private pendingRouters;
|
|
19
|
+
constructor(options?: StandardOpenAPIMatcherOptions);
|
|
20
|
+
init(router: AnyRouter, path?: readonly string[]): void;
|
|
21
|
+
match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface StandardOpenAPIHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardOpenAPIJsonSerializerOptions, StandardBracketNotationSerializerOptions, StandardOpenAPIMatcherOptions {
|
|
25
|
+
}
|
|
26
|
+
declare class StandardOpenAPIHandler<T extends Context> extends StandardHandler<T> {
|
|
27
|
+
constructor(router: Router<any, T>, options: NoInfer<StandardOpenAPIHandlerOptions<T>>);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { StandardOpenAPIHandler as a, StandardOpenAPIMatcher as c };
|
|
31
|
+
export type { StandardOpenAPIHandlerOptions as S, StandardOpenAPIMatcherOptions as b };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { StandardOpenAPIJsonSerializerOptions, StandardBracketNotationSerializerOptions } from '@orpc/openapi-client/standard';
|
|
2
|
+
import { TraverseContractProcedureCallbackOptions, AnyRouter, Context, Router } from '@orpc/server';
|
|
3
|
+
import { StandardMatcher, StandardMatchResult, StandardHandlerOptions, StandardHandler } from '@orpc/server/standard';
|
|
4
|
+
import { HTTPPath } from '@orpc/client';
|
|
5
|
+
import { Value } from '@orpc/shared';
|
|
6
|
+
|
|
7
|
+
interface StandardOpenAPIMatcherOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Filter procedures. Return `false` to exclude a procedure from matching.
|
|
10
|
+
*
|
|
11
|
+
* @default true
|
|
12
|
+
*/
|
|
13
|
+
filter?: Value<boolean, [options: TraverseContractProcedureCallbackOptions]>;
|
|
14
|
+
}
|
|
15
|
+
declare class StandardOpenAPIMatcher implements StandardMatcher {
|
|
16
|
+
private readonly filter;
|
|
17
|
+
private readonly tree;
|
|
18
|
+
private pendingRouters;
|
|
19
|
+
constructor(options?: StandardOpenAPIMatcherOptions);
|
|
20
|
+
init(router: AnyRouter, path?: readonly string[]): void;
|
|
21
|
+
match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface StandardOpenAPIHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardOpenAPIJsonSerializerOptions, StandardBracketNotationSerializerOptions, StandardOpenAPIMatcherOptions {
|
|
25
|
+
}
|
|
26
|
+
declare class StandardOpenAPIHandler<T extends Context> extends StandardHandler<T> {
|
|
27
|
+
constructor(router: Router<any, T>, options: NoInfer<StandardOpenAPIHandlerOptions<T>>);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { StandardOpenAPIHandler as a, StandardOpenAPIMatcher as c };
|
|
31
|
+
export type { StandardOpenAPIHandlerOptions as S, StandardOpenAPIMatcherOptions as b };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { AnySchema, OpenAPI, AnyContractProcedure, AnyContractRouter } from '@orpc/contract';
|
|
2
|
+
import { StandardOpenAPIJsonSerializerOptions } from '@orpc/openapi-client/standard';
|
|
3
|
+
import { AnyProcedure, TraverseContractProcedureCallbackOptions, AnyRouter } from '@orpc/server';
|
|
4
|
+
import { Promisable, Value } from '@orpc/shared';
|
|
5
|
+
import { JSONSchema } from 'json-schema-typed/draft-2020-12';
|
|
6
|
+
|
|
7
|
+
interface SchemaConverterComponent {
|
|
8
|
+
allowedStrategies: readonly 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?: readonly 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: readonly 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
|
+
* @deprecated Use `filter` option instead.
|
|
48
|
+
* @default () => false
|
|
49
|
+
*/
|
|
50
|
+
exclude?: (procedure: AnyProcedure | AnyContractProcedure, path: readonly string[]) => boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Filter procedures. Return `false` to exclude a procedure from the OpenAPI specification.
|
|
53
|
+
*
|
|
54
|
+
* @default true
|
|
55
|
+
*/
|
|
56
|
+
filter?: Value<boolean, [options: TraverseContractProcedureCallbackOptions]>;
|
|
57
|
+
/**
|
|
58
|
+
* Common schemas to be used for $ref resolution.
|
|
59
|
+
*/
|
|
60
|
+
commonSchemas?: Record<string, {
|
|
61
|
+
/**
|
|
62
|
+
* Determines which schema definition to use when input and output schemas differ.
|
|
63
|
+
* This is needed because some schemas transform data differently between input and output,
|
|
64
|
+
* making it impossible to use a single $ref for both cases.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* // This schema transforms a string input into a number output
|
|
69
|
+
* const Schema = z.string()
|
|
70
|
+
* .transform(v => Number(v))
|
|
71
|
+
* .pipe(z.number())
|
|
72
|
+
*
|
|
73
|
+
* // Input schema: { type: 'string' }
|
|
74
|
+
* // Output schema: { type: 'number' }
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* When schemas differ between input and output, you must explicitly choose
|
|
78
|
+
* which version to use for the OpenAPI specification.
|
|
79
|
+
*
|
|
80
|
+
* @default 'input' - Uses the input schema definition by default
|
|
81
|
+
*/
|
|
82
|
+
strategy?: SchemaConvertOptions['strategy'];
|
|
83
|
+
schema: AnySchema;
|
|
84
|
+
} | {
|
|
85
|
+
error: 'UndefinedError';
|
|
86
|
+
schema?: never;
|
|
87
|
+
}>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The generator that converts oRPC routers/contracts to OpenAPI specifications.
|
|
91
|
+
*
|
|
92
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
|
|
93
|
+
*/
|
|
94
|
+
declare class OpenAPIGenerator {
|
|
95
|
+
#private;
|
|
96
|
+
private readonly serializer;
|
|
97
|
+
private readonly converter;
|
|
98
|
+
constructor(options?: OpenAPIGeneratorOptions);
|
|
99
|
+
/**
|
|
100
|
+
* Generates OpenAPI specifications from oRPC routers/contracts.
|
|
101
|
+
*
|
|
102
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
|
|
103
|
+
*/
|
|
104
|
+
generate(router: AnyContractRouter | AnyRouter, options?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPI.Document>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export { OpenAPIGenerator as b, CompositeSchemaConverter as e };
|
|
108
|
+
export type { ConditionalSchemaConverter as C, OpenAPIGeneratorOptions as O, SchemaConverterComponent as S, OpenAPIGeneratorGenerateOptions as a, SchemaConvertOptions as c, SchemaConverter as d };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { AnySchema, OpenAPI, AnyContractProcedure, AnyContractRouter } from '@orpc/contract';
|
|
2
|
+
import { StandardOpenAPIJsonSerializerOptions } from '@orpc/openapi-client/standard';
|
|
3
|
+
import { AnyProcedure, TraverseContractProcedureCallbackOptions, AnyRouter } from '@orpc/server';
|
|
4
|
+
import { Promisable, Value } from '@orpc/shared';
|
|
5
|
+
import { JSONSchema } from 'json-schema-typed/draft-2020-12';
|
|
6
|
+
|
|
7
|
+
interface SchemaConverterComponent {
|
|
8
|
+
allowedStrategies: readonly 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?: readonly 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: readonly 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
|
+
* @deprecated Use `filter` option instead.
|
|
48
|
+
* @default () => false
|
|
49
|
+
*/
|
|
50
|
+
exclude?: (procedure: AnyProcedure | AnyContractProcedure, path: readonly string[]) => boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Filter procedures. Return `false` to exclude a procedure from the OpenAPI specification.
|
|
53
|
+
*
|
|
54
|
+
* @default true
|
|
55
|
+
*/
|
|
56
|
+
filter?: Value<boolean, [options: TraverseContractProcedureCallbackOptions]>;
|
|
57
|
+
/**
|
|
58
|
+
* Common schemas to be used for $ref resolution.
|
|
59
|
+
*/
|
|
60
|
+
commonSchemas?: Record<string, {
|
|
61
|
+
/**
|
|
62
|
+
* Determines which schema definition to use when input and output schemas differ.
|
|
63
|
+
* This is needed because some schemas transform data differently between input and output,
|
|
64
|
+
* making it impossible to use a single $ref for both cases.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* // This schema transforms a string input into a number output
|
|
69
|
+
* const Schema = z.string()
|
|
70
|
+
* .transform(v => Number(v))
|
|
71
|
+
* .pipe(z.number())
|
|
72
|
+
*
|
|
73
|
+
* // Input schema: { type: 'string' }
|
|
74
|
+
* // Output schema: { type: 'number' }
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* When schemas differ between input and output, you must explicitly choose
|
|
78
|
+
* which version to use for the OpenAPI specification.
|
|
79
|
+
*
|
|
80
|
+
* @default 'input' - Uses the input schema definition by default
|
|
81
|
+
*/
|
|
82
|
+
strategy?: SchemaConvertOptions['strategy'];
|
|
83
|
+
schema: AnySchema;
|
|
84
|
+
} | {
|
|
85
|
+
error: 'UndefinedError';
|
|
86
|
+
schema?: never;
|
|
87
|
+
}>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The generator that converts oRPC routers/contracts to OpenAPI specifications.
|
|
91
|
+
*
|
|
92
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
|
|
93
|
+
*/
|
|
94
|
+
declare class OpenAPIGenerator {
|
|
95
|
+
#private;
|
|
96
|
+
private readonly serializer;
|
|
97
|
+
private readonly converter;
|
|
98
|
+
constructor(options?: OpenAPIGeneratorOptions);
|
|
99
|
+
/**
|
|
100
|
+
* Generates OpenAPI specifications from oRPC routers/contracts.
|
|
101
|
+
*
|
|
102
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
|
|
103
|
+
*/
|
|
104
|
+
generate(router: AnyContractRouter | AnyRouter, options?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPI.Document>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export { OpenAPIGenerator as b, CompositeSchemaConverter as e };
|
|
108
|
+
export type { ConditionalSchemaConverter as C, OpenAPIGeneratorOptions as O, SchemaConverterComponent as S, OpenAPIGeneratorGenerateOptions as a, SchemaConvertOptions as c, SchemaConverter as d };
|
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.f50512c",
|
|
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/
|
|
57
|
-
"@orpc/
|
|
58
|
-
"@orpc/
|
|
59
|
-
"@orpc/server": "0.0.0-next.
|
|
60
|
-
"@orpc/standard-server": "0.0.0-next.f4d410a",
|
|
61
|
-
"@orpc/standard-server-fetch": "0.0.0-next.f4d410a",
|
|
62
|
-
"@orpc/standard-server-node": "0.0.0-next.f4d410a"
|
|
53
|
+
"rou3": "^0.7.3",
|
|
54
|
+
"@orpc/contract": "0.0.0-next.f50512c",
|
|
55
|
+
"@orpc/openapi-client": "0.0.0-next.f50512c",
|
|
56
|
+
"@orpc/client": "0.0.0-next.f50512c",
|
|
57
|
+
"@orpc/server": "0.0.0-next.f50512c",
|
|
58
|
+
"@orpc/shared": "0.0.0-next.f50512c",
|
|
59
|
+
"@orpc/standard-server": "0.0.0-next.f50512c"
|
|
63
60
|
},
|
|
64
61
|
"devDependencies": {
|
|
65
|
-
"zod": "^
|
|
62
|
+
"zod": "^4.0.5"
|
|
66
63
|
},
|
|
67
64
|
"scripts": {
|
|
68
65
|
"build": "unbuild",
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { OpenAPIHandler } from '../fetch/index.mjs';
|
|
2
|
-
import '@orpc/server';
|
|
3
|
-
import '@orpc/server/fetch';
|
|
4
|
-
import '@orpc/server/standard';
|
|
5
|
-
import '@orpc/shared';
|
|
6
|
-
import '@orpc/standard-server-fetch';
|
|
7
|
-
import '../../shared/openapi.IfmmOyba.mjs';
|
|
8
|
-
import '@orpc/openapi-client/standard';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { OpenAPIHandler } from '../fetch/index.js';
|
|
2
|
-
import '@orpc/server';
|
|
3
|
-
import '@orpc/server/fetch';
|
|
4
|
-
import '@orpc/server/standard';
|
|
5
|
-
import '@orpc/shared';
|
|
6
|
-
import '@orpc/standard-server-fetch';
|
|
7
|
-
import '../../shared/openapi.IfmmOyba.js';
|
|
8
|
-
import '@orpc/openapi-client/standard';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { O as OpenAPIHandler } from '../../shared/openapi.Dv-KT_Bx.mjs';
|
|
2
|
-
import '@orpc/openapi-client/standard';
|
|
3
|
-
import '@orpc/server/standard';
|
|
4
|
-
import '@orpc/standard-server-fetch';
|
|
5
|
-
import '../../shared/openapi.BNHmrMe2.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,8 +0,0 @@
|
|
|
1
|
-
export { OpenAPIHandler } from '../fetch/index.mjs';
|
|
2
|
-
import '@orpc/server';
|
|
3
|
-
import '@orpc/server/fetch';
|
|
4
|
-
import '@orpc/server/standard';
|
|
5
|
-
import '@orpc/shared';
|
|
6
|
-
import '@orpc/standard-server-fetch';
|
|
7
|
-
import '../../shared/openapi.IfmmOyba.mjs';
|
|
8
|
-
import '@orpc/openapi-client/standard';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { OpenAPIHandler } from '../fetch/index.js';
|
|
2
|
-
import '@orpc/server';
|
|
3
|
-
import '@orpc/server/fetch';
|
|
4
|
-
import '@orpc/server/standard';
|
|
5
|
-
import '@orpc/shared';
|
|
6
|
-
import '@orpc/standard-server-fetch';
|
|
7
|
-
import '../../shared/openapi.IfmmOyba.js';
|
|
8
|
-
import '@orpc/openapi-client/standard';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { O as OpenAPIHandler } from '../../shared/openapi.Dv-KT_Bx.mjs';
|
|
2
|
-
import '@orpc/openapi-client/standard';
|
|
3
|
-
import '@orpc/server/standard';
|
|
4
|
-
import '@orpc/standard-server-fetch';
|
|
5
|
-
import '../../shared/openapi.BNHmrMe2.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,231 +0,0 @@
|
|
|
1
|
-
import { isObject, findDeepMatches } from '@orpc/shared';
|
|
2
|
-
import 'json-schema-typed/draft-2020-12';
|
|
3
|
-
|
|
4
|
-
const LOGIC_KEYWORDS = [
|
|
5
|
-
"$dynamicRef",
|
|
6
|
-
"$ref",
|
|
7
|
-
"additionalItems",
|
|
8
|
-
"additionalProperties",
|
|
9
|
-
"allOf",
|
|
10
|
-
"anyOf",
|
|
11
|
-
"const",
|
|
12
|
-
"contains",
|
|
13
|
-
"contentEncoding",
|
|
14
|
-
"contentMediaType",
|
|
15
|
-
"contentSchema",
|
|
16
|
-
"dependencies",
|
|
17
|
-
"dependentRequired",
|
|
18
|
-
"dependentSchemas",
|
|
19
|
-
"else",
|
|
20
|
-
"enum",
|
|
21
|
-
"exclusiveMaximum",
|
|
22
|
-
"exclusiveMinimum",
|
|
23
|
-
"format",
|
|
24
|
-
"if",
|
|
25
|
-
"items",
|
|
26
|
-
"maxContains",
|
|
27
|
-
"maximum",
|
|
28
|
-
"maxItems",
|
|
29
|
-
"maxLength",
|
|
30
|
-
"maxProperties",
|
|
31
|
-
"minContains",
|
|
32
|
-
"minimum",
|
|
33
|
-
"minItems",
|
|
34
|
-
"minLength",
|
|
35
|
-
"minProperties",
|
|
36
|
-
"multipleOf",
|
|
37
|
-
"not",
|
|
38
|
-
"oneOf",
|
|
39
|
-
"pattern",
|
|
40
|
-
"patternProperties",
|
|
41
|
-
"prefixItems",
|
|
42
|
-
"properties",
|
|
43
|
-
"propertyNames",
|
|
44
|
-
"required",
|
|
45
|
-
"then",
|
|
46
|
-
"type",
|
|
47
|
-
"unevaluatedItems",
|
|
48
|
-
"unevaluatedProperties",
|
|
49
|
-
"uniqueItems"
|
|
50
|
-
];
|
|
51
|
-
|
|
52
|
-
function isFileSchema(schema) {
|
|
53
|
-
return isObject(schema) && schema.type === "string" && typeof schema.contentMediaType === "string";
|
|
54
|
-
}
|
|
55
|
-
function isObjectSchema(schema) {
|
|
56
|
-
return isObject(schema) && schema.type === "object";
|
|
57
|
-
}
|
|
58
|
-
function isAnySchema(schema) {
|
|
59
|
-
if (schema === true) {
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
if (Object.keys(schema).every((k) => !LOGIC_KEYWORDS.includes(k))) {
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
function separateObjectSchema(schema, separatedProperties) {
|
|
68
|
-
if (Object.keys(schema).some((k) => k !== "type" && k !== "properties" && k !== "required" && LOGIC_KEYWORDS.includes(k))) {
|
|
69
|
-
return [{ type: "object" }, schema];
|
|
70
|
-
}
|
|
71
|
-
const matched = { ...schema };
|
|
72
|
-
const rest = { ...schema };
|
|
73
|
-
matched.properties = schema.properties && Object.entries(schema.properties).filter(([key]) => separatedProperties.includes(key)).reduce((acc, [key, value]) => {
|
|
74
|
-
acc[key] = value;
|
|
75
|
-
return acc;
|
|
76
|
-
}, {});
|
|
77
|
-
matched.required = schema.required?.filter((key) => separatedProperties.includes(key));
|
|
78
|
-
matched.examples = schema.examples?.map((example) => {
|
|
79
|
-
if (!isObject(example)) {
|
|
80
|
-
return example;
|
|
81
|
-
}
|
|
82
|
-
return Object.entries(example).reduce((acc, [key, value]) => {
|
|
83
|
-
if (separatedProperties.includes(key)) {
|
|
84
|
-
acc[key] = value;
|
|
85
|
-
}
|
|
86
|
-
return acc;
|
|
87
|
-
}, {});
|
|
88
|
-
});
|
|
89
|
-
rest.properties = schema.properties && Object.entries(schema.properties).filter(([key]) => !separatedProperties.includes(key)).reduce((acc, [key, value]) => {
|
|
90
|
-
acc[key] = value;
|
|
91
|
-
return acc;
|
|
92
|
-
}, {});
|
|
93
|
-
rest.required = schema.required?.filter((key) => !separatedProperties.includes(key));
|
|
94
|
-
rest.examples = schema.examples?.map((example) => {
|
|
95
|
-
if (!isObject(example)) {
|
|
96
|
-
return example;
|
|
97
|
-
}
|
|
98
|
-
return Object.entries(example).reduce((acc, [key, value]) => {
|
|
99
|
-
if (!separatedProperties.includes(key)) {
|
|
100
|
-
acc[key] = value;
|
|
101
|
-
}
|
|
102
|
-
return acc;
|
|
103
|
-
}, {});
|
|
104
|
-
});
|
|
105
|
-
return [matched, rest];
|
|
106
|
-
}
|
|
107
|
-
function filterSchemaBranches(schema, check, matches = []) {
|
|
108
|
-
if (check(schema)) {
|
|
109
|
-
matches.push(schema);
|
|
110
|
-
return [matches, void 0];
|
|
111
|
-
}
|
|
112
|
-
if (isObject(schema)) {
|
|
113
|
-
for (const keyword of ["anyOf", "oneOf"]) {
|
|
114
|
-
if (schema[keyword] && Object.keys(schema).every(
|
|
115
|
-
(k) => k === keyword || !LOGIC_KEYWORDS.includes(k)
|
|
116
|
-
)) {
|
|
117
|
-
const rest = schema[keyword].map((s) => filterSchemaBranches(s, check, matches)[1]).filter((v) => !!v);
|
|
118
|
-
if (rest.length === 1 && typeof rest[0] === "object") {
|
|
119
|
-
return [matches, { ...schema, [keyword]: void 0, ...rest[0] }];
|
|
120
|
-
}
|
|
121
|
-
return [matches, { ...schema, [keyword]: rest }];
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return [matches, schema];
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function standardizeHTTPPath(path) {
|
|
129
|
-
return `/${path.replace(/\/{2,}/g, "/").replace(/^\/|\/$/g, "")}`;
|
|
130
|
-
}
|
|
131
|
-
function toOpenAPIPath(path) {
|
|
132
|
-
return standardizeHTTPPath(path).replace(/\/\{\+([^}]+)\}/g, "/{$1}");
|
|
133
|
-
}
|
|
134
|
-
function toOpenAPIMethod(method) {
|
|
135
|
-
return method.toLocaleLowerCase();
|
|
136
|
-
}
|
|
137
|
-
function getDynamicParams(path) {
|
|
138
|
-
return path ? standardizeHTTPPath(path).match(/\/\{([^}]+)\}/g)?.map((v) => v.match(/\{\+?([^}]+)\}/)[1]) : void 0;
|
|
139
|
-
}
|
|
140
|
-
function toOpenAPIContent(schema) {
|
|
141
|
-
const content = {};
|
|
142
|
-
const [matches, restSchema] = filterSchemaBranches(schema, isFileSchema);
|
|
143
|
-
for (const file of matches) {
|
|
144
|
-
content[file.contentMediaType] = {
|
|
145
|
-
schema: toOpenAPISchema(file)
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
if (restSchema !== void 0) {
|
|
149
|
-
content["application/json"] = {
|
|
150
|
-
schema: toOpenAPISchema(restSchema)
|
|
151
|
-
};
|
|
152
|
-
const isStillHasFileSchema = findDeepMatches((v) => isObject(v) && isFileSchema(v), restSchema).values.length > 0;
|
|
153
|
-
if (isStillHasFileSchema) {
|
|
154
|
-
content["multipart/form-data"] = {
|
|
155
|
-
schema: toOpenAPISchema(restSchema)
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
return content;
|
|
160
|
-
}
|
|
161
|
-
function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema], [returnsRequired, returnsSchema]) {
|
|
162
|
-
return {
|
|
163
|
-
"text/event-stream": {
|
|
164
|
-
schema: toOpenAPISchema({
|
|
165
|
-
oneOf: [
|
|
166
|
-
{
|
|
167
|
-
type: "object",
|
|
168
|
-
properties: {
|
|
169
|
-
event: { const: "message" },
|
|
170
|
-
data: yieldsSchema,
|
|
171
|
-
id: { type: "string" },
|
|
172
|
-
retry: { type: "number" }
|
|
173
|
-
},
|
|
174
|
-
required: yieldsRequired ? ["event", "data"] : ["event"]
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
type: "object",
|
|
178
|
-
properties: {
|
|
179
|
-
event: { const: "done" },
|
|
180
|
-
data: returnsSchema,
|
|
181
|
-
id: { type: "string" },
|
|
182
|
-
retry: { type: "number" }
|
|
183
|
-
},
|
|
184
|
-
required: returnsRequired ? ["event", "data"] : ["event"]
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
type: "object",
|
|
188
|
-
properties: {
|
|
189
|
-
event: { const: "error" },
|
|
190
|
-
data: {},
|
|
191
|
-
id: { type: "string" },
|
|
192
|
-
retry: { type: "number" }
|
|
193
|
-
},
|
|
194
|
-
required: ["event"]
|
|
195
|
-
}
|
|
196
|
-
]
|
|
197
|
-
})
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
function toOpenAPIParameters(schema, parameterIn) {
|
|
202
|
-
const parameters = [];
|
|
203
|
-
for (const key in schema.properties) {
|
|
204
|
-
const keySchema = schema.properties[key];
|
|
205
|
-
parameters.push({
|
|
206
|
-
name: key,
|
|
207
|
-
in: parameterIn,
|
|
208
|
-
required: schema.required?.includes(key),
|
|
209
|
-
style: parameterIn === "query" ? "deepObject" : void 0,
|
|
210
|
-
explode: parameterIn === "query" ? true : void 0,
|
|
211
|
-
schema: toOpenAPISchema(keySchema)
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
return parameters;
|
|
215
|
-
}
|
|
216
|
-
function checkParamsSchema(schema, params) {
|
|
217
|
-
const properties = Object.keys(schema.properties ?? {});
|
|
218
|
-
const required = schema.required ?? [];
|
|
219
|
-
if (properties.length !== params.length || properties.some((v) => !params.includes(v))) {
|
|
220
|
-
return false;
|
|
221
|
-
}
|
|
222
|
-
if (required.length !== params.length || required.some((v) => !params.includes(v))) {
|
|
223
|
-
return false;
|
|
224
|
-
}
|
|
225
|
-
return true;
|
|
226
|
-
}
|
|
227
|
-
function toOpenAPISchema(schema) {
|
|
228
|
-
return schema === true ? {} : schema === false ? { not: {} } : schema;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
export { LOGIC_KEYWORDS as L, toOpenAPIPath as a, toOpenAPIEventIteratorContent as b, isObjectSchema as c, separateObjectSchema as d, checkParamsSchema as e, toOpenAPIParameters as f, getDynamicParams as g, toOpenAPIContent as h, isAnySchema as i, toOpenAPISchema as j, isFileSchema as k, filterSchemaBranches as l, standardizeHTTPPath as s, toOpenAPIMethod as t };
|