@orpc/openapi 0.0.0-next.e7d7758 → 0.0.0-next.e98b833
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 +92 -0
- package/dist/adapters/fetch/index.d.mts +13 -0
- package/dist/adapters/fetch/index.d.ts +13 -0
- package/dist/adapters/fetch/index.mjs +11 -0
- package/dist/adapters/hono/index.d.mts +6 -0
- package/dist/adapters/hono/index.d.ts +6 -0
- package/dist/adapters/hono/index.mjs +11 -0
- package/dist/adapters/next/index.d.mts +6 -0
- package/dist/adapters/next/index.d.ts +6 -0
- package/dist/adapters/next/index.mjs +11 -0
- package/dist/adapters/node/index.d.mts +13 -0
- package/dist/adapters/node/index.d.ts +13 -0
- package/dist/adapters/node/index.mjs +33 -0
- package/dist/adapters/standard/index.d.mts +34 -0
- package/dist/adapters/standard/index.d.ts +34 -0
- package/dist/adapters/standard/index.mjs +7 -0
- package/dist/index.d.mts +119 -0
- package/dist/index.d.ts +119 -0
- package/dist/index.mjs +303 -0
- package/dist/shared/openapi.CJTe38Ya.mjs +145 -0
- package/dist/shared/openapi.CbzTVvGL.mjs +31 -0
- package/dist/shared/openapi.DZzpQAb-.mjs +231 -0
- package/package.json +37 -30
- package/dist/chunk-KNYXLM77.js +0 -107
- package/dist/chunk-YXHH6XHB.js +0 -642
- package/dist/fetch.js +0 -46
- package/dist/index.js +0 -490
- package/dist/node.js +0 -46
- package/dist/src/adapters/fetch/bracket-notation.d.ts +0 -84
- package/dist/src/adapters/fetch/index.d.ts +0 -10
- package/dist/src/adapters/fetch/input-structure-compact.d.ts +0 -6
- package/dist/src/adapters/fetch/input-structure-detailed.d.ts +0 -11
- package/dist/src/adapters/fetch/openapi-handler-server.d.ts +0 -7
- package/dist/src/adapters/fetch/openapi-handler-serverless.d.ts +0 -7
- package/dist/src/adapters/fetch/openapi-handler.d.ts +0 -33
- package/dist/src/adapters/fetch/openapi-payload-codec.d.ts +0 -15
- package/dist/src/adapters/fetch/openapi-procedure-matcher.d.ts +0 -19
- package/dist/src/adapters/fetch/schema-coercer.d.ts +0 -10
- package/dist/src/adapters/node/index.d.ts +0 -5
- package/dist/src/adapters/node/openapi-handler-server.d.ts +0 -7
- package/dist/src/adapters/node/openapi-handler-serverless.d.ts +0 -7
- package/dist/src/adapters/node/openapi-handler.d.ts +0 -12
- package/dist/src/adapters/node/types.d.ts +0 -2
- 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-error.d.ts +0 -3
- package/dist/src/openapi-generator.d.ts +0 -60
- package/dist/src/openapi-input-structure-parser.d.ts +0 -22
- package/dist/src/openapi-output-structure-parser.d.ts +0 -18
- package/dist/src/openapi-parameters-builder.d.ts +0 -12
- 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,231 @@
|
|
|
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 };
|
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.e98b833",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -15,50 +15,57 @@
|
|
|
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
|
+
"./standard": {
|
|
23
|
+
"types": "./dist/adapters/standard/index.d.mts",
|
|
24
|
+
"import": "./dist/adapters/standard/index.mjs",
|
|
25
|
+
"default": "./dist/adapters/standard/index.mjs"
|
|
21
26
|
},
|
|
22
27
|
"./fetch": {
|
|
23
|
-
"types": "./dist/
|
|
24
|
-
"import": "./dist/fetch.
|
|
25
|
-
"default": "./dist/fetch.
|
|
28
|
+
"types": "./dist/adapters/fetch/index.d.mts",
|
|
29
|
+
"import": "./dist/adapters/fetch/index.mjs",
|
|
30
|
+
"default": "./dist/adapters/fetch/index.mjs"
|
|
26
31
|
},
|
|
27
|
-
"./
|
|
28
|
-
"types": "./dist/
|
|
29
|
-
"import": "./dist/
|
|
30
|
-
"default": "./dist/
|
|
32
|
+
"./hono": {
|
|
33
|
+
"types": "./dist/adapters/hono/index.d.mts",
|
|
34
|
+
"import": "./dist/adapters/hono/index.mjs",
|
|
35
|
+
"default": "./dist/adapters/hono/index.mjs"
|
|
31
36
|
},
|
|
32
|
-
"
|
|
33
|
-
"types": "./dist/
|
|
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
|
+
"./node": {
|
|
43
|
+
"types": "./dist/adapters/node/index.d.mts",
|
|
44
|
+
"import": "./dist/adapters/node/index.mjs",
|
|
45
|
+
"default": "./dist/adapters/node/index.mjs"
|
|
34
46
|
}
|
|
35
47
|
},
|
|
36
48
|
"files": [
|
|
37
|
-
"!**/*.map",
|
|
38
|
-
"!**/*.tsbuildinfo",
|
|
39
49
|
"dist"
|
|
40
50
|
],
|
|
41
51
|
"dependencies": {
|
|
42
|
-
"@mjackson/node-fetch-server": "^0.5.0",
|
|
43
|
-
"@standard-schema/spec": "1.0.0-beta.4",
|
|
44
|
-
"@types/content-disposition": "^0.5.8",
|
|
45
|
-
"content-disposition": "^0.5.4",
|
|
46
|
-
"escape-string-regexp": "^5.0.0",
|
|
47
|
-
"fast-content-type-parse": "^2.0.0",
|
|
48
|
-
"hono": "^4.6.12",
|
|
49
52
|
"json-schema-typed": "^8.0.1",
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"@orpc/
|
|
53
|
-
"@orpc/contract": "0.0.0-next.
|
|
54
|
-
"@orpc/
|
|
53
|
+
"openapi-types": "^12.1.3",
|
|
54
|
+
"rou3": "^0.5.1",
|
|
55
|
+
"@orpc/client": "0.0.0-next.e98b833",
|
|
56
|
+
"@orpc/contract": "0.0.0-next.e98b833",
|
|
57
|
+
"@orpc/openapi-client": "0.0.0-next.e98b833",
|
|
58
|
+
"@orpc/server": "0.0.0-next.e98b833",
|
|
59
|
+
"@orpc/shared": "0.0.0-next.e98b833",
|
|
60
|
+
"@orpc/standard-server-fetch": "0.0.0-next.e98b833",
|
|
61
|
+
"@orpc/standard-server": "0.0.0-next.e98b833",
|
|
62
|
+
"@orpc/standard-server-node": "0.0.0-next.e98b833"
|
|
55
63
|
},
|
|
56
64
|
"devDependencies": {
|
|
57
|
-
"
|
|
58
|
-
"zod": "^3.24.1"
|
|
65
|
+
"zod": "^3.24.2"
|
|
59
66
|
},
|
|
60
67
|
"scripts": {
|
|
61
|
-
"build": "
|
|
68
|
+
"build": "unbuild",
|
|
62
69
|
"build:watch": "pnpm run build --watch",
|
|
63
70
|
"type:check": "tsc -b"
|
|
64
71
|
}
|
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
|