@orpc/openapi 0.0.0-next.eb37cbe → 0.0.0-next.ec7d801
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 +99 -0
- 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 +17 -0
- package/dist/adapters/fetch/index.d.ts +17 -0
- package/dist/adapters/fetch/index.mjs +18 -0
- package/dist/adapters/node/index.d.mts +17 -0
- package/dist/adapters/node/index.d.ts +17 -0
- package/dist/adapters/node/index.mjs +18 -0
- package/dist/adapters/standard/index.d.mts +35 -0
- package/dist/adapters/standard/index.d.ts +35 -0
- package/dist/adapters/standard/index.mjs +9 -0
- package/dist/index.d.mts +109 -0
- package/dist/index.d.ts +109 -0
- package/dist/index.mjs +41 -0
- 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_UtQ8Us.mjs +179 -0
- package/dist/shared/openapi.D3j94c9n.d.mts +12 -0
- package/dist/shared/openapi.D3j94c9n.d.ts +12 -0
- package/dist/shared/openapi.DaYgbD_w.mjs +652 -0
- package/dist/shared/openapi.qZLdpE0a.d.mts +52 -0
- package/dist/shared/openapi.qZLdpE0a.d.ts +52 -0
- package/package.json +35 -25
- package/dist/chunk-KNYXLM77.js +0 -107
- package/dist/fetch.js +0 -594
- package/dist/index.js +0 -362
- package/dist/src/fetch/bracket-notation.d.ts +0 -84
- package/dist/src/fetch/index.d.ts +0 -10
- package/dist/src/fetch/input-builder-full.d.ts +0 -11
- package/dist/src/fetch/input-builder-simple.d.ts +0 -6
- package/dist/src/fetch/openapi-handler-server.d.ts +0 -7
- package/dist/src/fetch/openapi-handler-serverless.d.ts +0 -7
- package/dist/src/fetch/openapi-handler.d.ts +0 -30
- package/dist/src/fetch/openapi-payload-codec.d.ts +0 -15
- package/dist/src/fetch/openapi-procedure-matcher.d.ts +0 -19
- package/dist/src/fetch/schema-coercer.d.ts +0 -10
- package/dist/src/index.d.ts +0 -12
- package/dist/src/json-serializer.d.ts +0 -5
- package/dist/src/openapi-content-builder.d.ts +0 -10
- package/dist/src/openapi-generator.d.ts +0 -51
- package/dist/src/openapi-parameters-builder.d.ts +0 -9
- package/dist/src/openapi-path-parser.d.ts +0 -8
- package/dist/src/openapi.d.ts +0 -3
- package/dist/src/schema-converter.d.ts +0 -16
- package/dist/src/schema-utils.d.ts +0 -11
- package/dist/src/schema.d.ts +0 -12
- package/dist/src/utils.d.ts +0 -18
|
@@ -0,0 +1,52 @@
|
|
|
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 SchemaConvertOptions {
|
|
8
|
+
strategy: 'input' | 'output';
|
|
9
|
+
}
|
|
10
|
+
interface SchemaConverter {
|
|
11
|
+
convert(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<[required: boolean, jsonSchema: JSONSchema]>;
|
|
12
|
+
}
|
|
13
|
+
interface ConditionalSchemaConverter extends SchemaConverter {
|
|
14
|
+
condition(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<boolean>;
|
|
15
|
+
}
|
|
16
|
+
declare class CompositeSchemaConverter implements SchemaConverter {
|
|
17
|
+
private readonly converters;
|
|
18
|
+
constructor(converters: ConditionalSchemaConverter[]);
|
|
19
|
+
convert(schema: AnySchema | undefined, options: SchemaConvertOptions): Promise<[required: boolean, jsonSchema: JSONSchema]>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface OpenAPIGeneratorOptions extends StandardOpenAPIJsonSerializerOptions {
|
|
23
|
+
schemaConverters?: ConditionalSchemaConverter[];
|
|
24
|
+
}
|
|
25
|
+
interface OpenAPIGeneratorGenerateOptions extends Partial<Omit<OpenAPI.Document, 'openapi'>> {
|
|
26
|
+
/**
|
|
27
|
+
* Exclude procedures from the OpenAPI specification.
|
|
28
|
+
*
|
|
29
|
+
* @default () => false
|
|
30
|
+
*/
|
|
31
|
+
exclude?: (procedure: AnyProcedure | AnyContractProcedure, path: readonly string[]) => boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The generator that converts oRPC routers/contracts to OpenAPI specifications.
|
|
35
|
+
*
|
|
36
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
|
|
37
|
+
*/
|
|
38
|
+
declare class OpenAPIGenerator {
|
|
39
|
+
#private;
|
|
40
|
+
private readonly serializer;
|
|
41
|
+
private readonly converter;
|
|
42
|
+
constructor(options?: OpenAPIGeneratorOptions);
|
|
43
|
+
/**
|
|
44
|
+
* Generates OpenAPI specifications from oRPC routers/contracts.
|
|
45
|
+
*
|
|
46
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
|
|
47
|
+
*/
|
|
48
|
+
generate(router: AnyContractRouter | AnyRouter, options?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPI.Document>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { OpenAPIGenerator as b, CompositeSchemaConverter as d };
|
|
52
|
+
export type { ConditionalSchemaConverter as C, OpenAPIGeneratorOptions as O, SchemaConvertOptions as S, OpenAPIGeneratorGenerateOptions as a, SchemaConverter as c };
|
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.ec7d801",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -15,44 +15,54 @@
|
|
|
15
15
|
],
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
18
|
-
"types": "./dist/
|
|
19
|
-
"import": "./dist/index.
|
|
20
|
-
"default": "./dist/index.
|
|
18
|
+
"types": "./dist/index.d.mts",
|
|
19
|
+
"import": "./dist/index.mjs",
|
|
20
|
+
"default": "./dist/index.mjs"
|
|
21
|
+
},
|
|
22
|
+
"./plugins": {
|
|
23
|
+
"types": "./dist/plugins/index.d.mts",
|
|
24
|
+
"import": "./dist/plugins/index.mjs",
|
|
25
|
+
"default": "./dist/plugins/index.mjs"
|
|
26
|
+
},
|
|
27
|
+
"./standard": {
|
|
28
|
+
"types": "./dist/adapters/standard/index.d.mts",
|
|
29
|
+
"import": "./dist/adapters/standard/index.mjs",
|
|
30
|
+
"default": "./dist/adapters/standard/index.mjs"
|
|
21
31
|
},
|
|
22
32
|
"./fetch": {
|
|
23
|
-
"types": "./dist/
|
|
24
|
-
"import": "./dist/fetch.
|
|
25
|
-
"default": "./dist/fetch.
|
|
33
|
+
"types": "./dist/adapters/fetch/index.d.mts",
|
|
34
|
+
"import": "./dist/adapters/fetch/index.mjs",
|
|
35
|
+
"default": "./dist/adapters/fetch/index.mjs"
|
|
36
|
+
},
|
|
37
|
+
"./node": {
|
|
38
|
+
"types": "./dist/adapters/node/index.d.mts",
|
|
39
|
+
"import": "./dist/adapters/node/index.mjs",
|
|
40
|
+
"default": "./dist/adapters/node/index.mjs"
|
|
26
41
|
},
|
|
27
|
-
"
|
|
28
|
-
"types": "./dist/
|
|
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"
|
|
29
46
|
}
|
|
30
47
|
},
|
|
31
48
|
"files": [
|
|
32
|
-
"!**/*.map",
|
|
33
|
-
"!**/*.tsbuildinfo",
|
|
34
49
|
"dist"
|
|
35
50
|
],
|
|
36
51
|
"dependencies": {
|
|
37
|
-
"@standard-schema/spec": "1.0.0-beta.4",
|
|
38
|
-
"@types/content-disposition": "^0.5.8",
|
|
39
|
-
"content-disposition": "^0.5.4",
|
|
40
|
-
"escape-string-regexp": "^5.0.0",
|
|
41
|
-
"fast-content-type-parse": "^2.0.0",
|
|
42
|
-
"hono": "^4.6.12",
|
|
43
52
|
"json-schema-typed": "^8.0.1",
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"@orpc/
|
|
47
|
-
"@orpc/
|
|
48
|
-
"@orpc/shared": "0.0.0-next.
|
|
53
|
+
"rou3": "^0.6.0",
|
|
54
|
+
"@orpc/client": "0.0.0-next.ec7d801",
|
|
55
|
+
"@orpc/openapi-client": "0.0.0-next.ec7d801",
|
|
56
|
+
"@orpc/contract": "0.0.0-next.ec7d801",
|
|
57
|
+
"@orpc/shared": "0.0.0-next.ec7d801",
|
|
58
|
+
"@orpc/server": "0.0.0-next.ec7d801",
|
|
59
|
+
"@orpc/standard-server": "0.0.0-next.ec7d801"
|
|
49
60
|
},
|
|
50
61
|
"devDependencies": {
|
|
51
|
-
"
|
|
52
|
-
"zod": "^3.24.1"
|
|
62
|
+
"zod": "^3.25.57"
|
|
53
63
|
},
|
|
54
64
|
"scripts": {
|
|
55
|
-
"build": "
|
|
65
|
+
"build": "unbuild",
|
|
56
66
|
"build:watch": "pnpm run build --watch",
|
|
57
67
|
"type:check": "tsc -b"
|
|
58
68
|
}
|
package/dist/chunk-KNYXLM77.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
// src/json-serializer.ts
|
|
2
|
-
import { isPlainObject } from "@orpc/shared";
|
|
3
|
-
var JSONSerializer = class {
|
|
4
|
-
serialize(payload) {
|
|
5
|
-
if (payload instanceof Set)
|
|
6
|
-
return this.serialize([...payload]);
|
|
7
|
-
if (payload instanceof Map)
|
|
8
|
-
return this.serialize([...payload.entries()]);
|
|
9
|
-
if (Array.isArray(payload)) {
|
|
10
|
-
return payload.map((v) => v === void 0 ? "undefined" : this.serialize(v));
|
|
11
|
-
}
|
|
12
|
-
if (Number.isNaN(payload))
|
|
13
|
-
return "NaN";
|
|
14
|
-
if (typeof payload === "bigint")
|
|
15
|
-
return payload.toString();
|
|
16
|
-
if (payload instanceof Date && Number.isNaN(payload.getTime())) {
|
|
17
|
-
return "Invalid Date";
|
|
18
|
-
}
|
|
19
|
-
if (payload instanceof RegExp)
|
|
20
|
-
return payload.toString();
|
|
21
|
-
if (payload instanceof URL)
|
|
22
|
-
return payload.toString();
|
|
23
|
-
if (!isPlainObject(payload))
|
|
24
|
-
return payload;
|
|
25
|
-
return Object.keys(payload).reduce(
|
|
26
|
-
(carry, key) => {
|
|
27
|
-
const val = payload[key];
|
|
28
|
-
carry[key] = this.serialize(val);
|
|
29
|
-
return carry;
|
|
30
|
-
},
|
|
31
|
-
{}
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
// src/utils.ts
|
|
37
|
-
import { isContractProcedure } from "@orpc/contract";
|
|
38
|
-
import { getRouterContract, isLazy, isProcedure, unlazy } from "@orpc/server";
|
|
39
|
-
function forEachContractProcedure(options, callback, result = [], isCurrentRouterContract = false) {
|
|
40
|
-
const hiddenContract = getRouterContract(options.router);
|
|
41
|
-
if (!isCurrentRouterContract && hiddenContract) {
|
|
42
|
-
return forEachContractProcedure(
|
|
43
|
-
{
|
|
44
|
-
path: options.path,
|
|
45
|
-
router: hiddenContract
|
|
46
|
-
},
|
|
47
|
-
callback,
|
|
48
|
-
result,
|
|
49
|
-
true
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
if (isLazy(options.router)) {
|
|
53
|
-
result.push({
|
|
54
|
-
router: options.router,
|
|
55
|
-
path: options.path
|
|
56
|
-
});
|
|
57
|
-
} else if (isProcedure(options.router)) {
|
|
58
|
-
callback({
|
|
59
|
-
contract: options.router["~orpc"].contract,
|
|
60
|
-
path: options.path
|
|
61
|
-
});
|
|
62
|
-
} else if (isContractProcedure(options.router)) {
|
|
63
|
-
callback({
|
|
64
|
-
contract: options.router,
|
|
65
|
-
path: options.path
|
|
66
|
-
});
|
|
67
|
-
} else {
|
|
68
|
-
for (const key in options.router) {
|
|
69
|
-
forEachContractProcedure(
|
|
70
|
-
{
|
|
71
|
-
router: options.router[key],
|
|
72
|
-
path: [...options.path, key]
|
|
73
|
-
},
|
|
74
|
-
callback,
|
|
75
|
-
result
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return result;
|
|
80
|
-
}
|
|
81
|
-
async function forEachAllContractProcedure(router, callback) {
|
|
82
|
-
const pending = [{
|
|
83
|
-
path: [],
|
|
84
|
-
router
|
|
85
|
-
}];
|
|
86
|
-
for (const item of pending) {
|
|
87
|
-
const lazies = forEachContractProcedure(item, callback);
|
|
88
|
-
for (const lazy of lazies) {
|
|
89
|
-
const { default: router2 } = await unlazy(lazy.router);
|
|
90
|
-
pending.push({
|
|
91
|
-
path: lazy.path,
|
|
92
|
-
router: router2
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function standardizeHTTPPath(path) {
|
|
98
|
-
return `/${path.replace(/\/{2,}/g, "/").replace(/^\/|\/$/g, "")}`;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export {
|
|
102
|
-
JSONSerializer,
|
|
103
|
-
forEachContractProcedure,
|
|
104
|
-
forEachAllContractProcedure,
|
|
105
|
-
standardizeHTTPPath
|
|
106
|
-
};
|
|
107
|
-
//# sourceMappingURL=chunk-KNYXLM77.js.map
|