@autobe/utils 0.30.0-dev.20260315 → 0.30.0
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/LICENSE +661 -661
- package/lib/prisma/writePrismaApplication.js +49 -49
- package/package.json +2 -2
- package/src/ArrayUtil.ts +21 -21
- package/src/AutoBeEscaper.ts +83 -83
- package/src/MapUtil.ts +10 -10
- package/src/StringUtil.ts +34 -34
- package/src/aggregate/AutoBeFunctionCallingMetricFactory.ts +44 -44
- package/src/aggregate/AutoBeProcessAggregateFactory.ts +161 -161
- package/src/aggregate/TokenUsageComputer.ts +49 -49
- package/src/aggregate/index.ts +3 -3
- package/src/index.ts +10 -10
- package/src/interface/AutoBeOpenApiEndpointComparator.ts +27 -27
- package/src/interface/AutoBeOpenApiTypeChecker.ts +127 -127
- package/src/interface/index.ts +6 -6
- package/src/interface/invertOpenApiDocument.ts +80 -80
- package/src/interface/missedOpenApiSchemas.ts +25 -25
- package/src/interface/revertOpenApiAccessor.ts +25 -25
- package/src/interface/transformOpenApiDocument.ts +94 -94
- package/src/prisma/index.ts +1 -1
- package/src/prisma/writePrismaApplication.ts +456 -456
- package/src/test/AutoBeTestExpressionValidator.ts +253 -253
- package/src/test/AutoBeTestStatementValidator.ts +72 -72
- package/src/test/IAutoBeTextValidateContext.ts +10 -10
- package/src/test/index.ts +2 -2
- package/src/test/validateTestApiOperateStatement.ts +92 -92
- package/src/test/validateTestExpression.ts +16 -16
- package/src/test/validateTestFunction.ts +7 -7
- package/src/test/validateTestStatement.ts +16 -16
- package/README.md +0 -261
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
import { AutoBeOpenApi } from "@autobe/interface";
|
|
2
|
-
import {
|
|
3
|
-
IHttpMigrateApplication,
|
|
4
|
-
OpenApi,
|
|
5
|
-
OpenApiV3_2,
|
|
6
|
-
} from "@typia/interface";
|
|
7
|
-
import { HttpMigration, OpenApiConverter } from "@typia/utils";
|
|
8
|
-
import { HashMap } from "tstl";
|
|
9
|
-
|
|
10
|
-
import { StringUtil } from "../StringUtil";
|
|
11
|
-
import { AutoBeOpenApiEndpointComparator } from "./AutoBeOpenApiEndpointComparator";
|
|
12
|
-
|
|
13
|
-
export function transformOpenApiDocument(
|
|
14
|
-
input: AutoBeOpenApi.IDocument,
|
|
15
|
-
): OpenApi.IDocument {
|
|
16
|
-
const dict: HashMap<AutoBeOpenApi.IEndpoint, string> = new HashMap(
|
|
17
|
-
AutoBeOpenApiEndpointComparator.hashCode,
|
|
18
|
-
AutoBeOpenApiEndpointComparator.equals,
|
|
19
|
-
);
|
|
20
|
-
const paths: Record<string, OpenApi.IPath> = {};
|
|
21
|
-
|
|
22
|
-
for (const op of input.operations) {
|
|
23
|
-
dict.set(op, op.name);
|
|
24
|
-
paths[op.path] ??= {};
|
|
25
|
-
paths[op.path][op.method] = {
|
|
26
|
-
summary: StringUtil.summary(op.description),
|
|
27
|
-
description:
|
|
28
|
-
op.description +
|
|
29
|
-
(op.authorizationType !== null &&
|
|
30
|
-
op.responseBody?.typeName.endsWith(".IAuthorized") === true
|
|
31
|
-
? "\n\n@setHeader token.access Authorization"
|
|
32
|
-
: ""),
|
|
33
|
-
parameters: op.parameters.map((p) => ({
|
|
34
|
-
name: p.name,
|
|
35
|
-
in: "path",
|
|
36
|
-
schema: p.schema,
|
|
37
|
-
required: true,
|
|
38
|
-
description: p.description,
|
|
39
|
-
})),
|
|
40
|
-
requestBody: op.requestBody
|
|
41
|
-
? {
|
|
42
|
-
content: {
|
|
43
|
-
"application/json": {
|
|
44
|
-
schema: {
|
|
45
|
-
$ref: `#/components/schemas/${op.requestBody.typeName}`,
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
description: op.requestBody.description,
|
|
50
|
-
required: true,
|
|
51
|
-
}
|
|
52
|
-
: undefined,
|
|
53
|
-
responses: op.responseBody
|
|
54
|
-
? {
|
|
55
|
-
[op.method === "post" ? 201 : 200]: {
|
|
56
|
-
content: {
|
|
57
|
-
"application/json": {
|
|
58
|
-
schema: {
|
|
59
|
-
$ref: `#/components/schemas/${op.responseBody.typeName}`,
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
description: op.responseBody.description,
|
|
64
|
-
},
|
|
65
|
-
}
|
|
66
|
-
: undefined,
|
|
67
|
-
...{
|
|
68
|
-
"x-autobe-authorization-type": op.authorizationType,
|
|
69
|
-
"x-autobe-authorization-actor": op.authorizationActor,
|
|
70
|
-
"x-autobe-prerequisites": op.prerequisites,
|
|
71
|
-
"x-samchon-accessor": op.accessor,
|
|
72
|
-
"x-autobe-specification": op.specification,
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const document: OpenApi.IDocument = OpenApiConverter.upgradeDocument({
|
|
78
|
-
openapi: "3.2.0",
|
|
79
|
-
paths,
|
|
80
|
-
components: input.components,
|
|
81
|
-
} as OpenApiV3_2.IDocument);
|
|
82
|
-
const migrate: IHttpMigrateApplication = HttpMigration.application(document);
|
|
83
|
-
migrate.routes.forEach((r) => {
|
|
84
|
-
if (r.method === "head") return;
|
|
85
|
-
const name: string = dict.get({
|
|
86
|
-
method: r.method as "post",
|
|
87
|
-
path: r.path,
|
|
88
|
-
});
|
|
89
|
-
if (r.accessor.length >= 2 && r.accessor.at(-2) === name) r.accessor.pop();
|
|
90
|
-
r.accessor[r.accessor.length - 1] = name;
|
|
91
|
-
r.operation()["x-samchon-accessor"] = r.accessor;
|
|
92
|
-
});
|
|
93
|
-
return document;
|
|
94
|
-
}
|
|
1
|
+
import { AutoBeOpenApi } from "@autobe/interface";
|
|
2
|
+
import {
|
|
3
|
+
IHttpMigrateApplication,
|
|
4
|
+
OpenApi,
|
|
5
|
+
OpenApiV3_2,
|
|
6
|
+
} from "@typia/interface";
|
|
7
|
+
import { HttpMigration, OpenApiConverter } from "@typia/utils";
|
|
8
|
+
import { HashMap } from "tstl";
|
|
9
|
+
|
|
10
|
+
import { StringUtil } from "../StringUtil";
|
|
11
|
+
import { AutoBeOpenApiEndpointComparator } from "./AutoBeOpenApiEndpointComparator";
|
|
12
|
+
|
|
13
|
+
export function transformOpenApiDocument(
|
|
14
|
+
input: AutoBeOpenApi.IDocument,
|
|
15
|
+
): OpenApi.IDocument {
|
|
16
|
+
const dict: HashMap<AutoBeOpenApi.IEndpoint, string> = new HashMap(
|
|
17
|
+
AutoBeOpenApiEndpointComparator.hashCode,
|
|
18
|
+
AutoBeOpenApiEndpointComparator.equals,
|
|
19
|
+
);
|
|
20
|
+
const paths: Record<string, OpenApi.IPath> = {};
|
|
21
|
+
|
|
22
|
+
for (const op of input.operations) {
|
|
23
|
+
dict.set(op, op.name);
|
|
24
|
+
paths[op.path] ??= {};
|
|
25
|
+
paths[op.path][op.method] = {
|
|
26
|
+
summary: StringUtil.summary(op.description),
|
|
27
|
+
description:
|
|
28
|
+
op.description +
|
|
29
|
+
(op.authorizationType !== null &&
|
|
30
|
+
op.responseBody?.typeName.endsWith(".IAuthorized") === true
|
|
31
|
+
? "\n\n@setHeader token.access Authorization"
|
|
32
|
+
: ""),
|
|
33
|
+
parameters: op.parameters.map((p) => ({
|
|
34
|
+
name: p.name,
|
|
35
|
+
in: "path",
|
|
36
|
+
schema: p.schema,
|
|
37
|
+
required: true,
|
|
38
|
+
description: p.description,
|
|
39
|
+
})),
|
|
40
|
+
requestBody: op.requestBody
|
|
41
|
+
? {
|
|
42
|
+
content: {
|
|
43
|
+
"application/json": {
|
|
44
|
+
schema: {
|
|
45
|
+
$ref: `#/components/schemas/${op.requestBody.typeName}`,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
description: op.requestBody.description,
|
|
50
|
+
required: true,
|
|
51
|
+
}
|
|
52
|
+
: undefined,
|
|
53
|
+
responses: op.responseBody
|
|
54
|
+
? {
|
|
55
|
+
[op.method === "post" ? 201 : 200]: {
|
|
56
|
+
content: {
|
|
57
|
+
"application/json": {
|
|
58
|
+
schema: {
|
|
59
|
+
$ref: `#/components/schemas/${op.responseBody.typeName}`,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
description: op.responseBody.description,
|
|
64
|
+
},
|
|
65
|
+
}
|
|
66
|
+
: undefined,
|
|
67
|
+
...{
|
|
68
|
+
"x-autobe-authorization-type": op.authorizationType,
|
|
69
|
+
"x-autobe-authorization-actor": op.authorizationActor,
|
|
70
|
+
"x-autobe-prerequisites": op.prerequisites,
|
|
71
|
+
"x-samchon-accessor": op.accessor,
|
|
72
|
+
"x-autobe-specification": op.specification,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const document: OpenApi.IDocument = OpenApiConverter.upgradeDocument({
|
|
78
|
+
openapi: "3.2.0",
|
|
79
|
+
paths,
|
|
80
|
+
components: input.components,
|
|
81
|
+
} as OpenApiV3_2.IDocument);
|
|
82
|
+
const migrate: IHttpMigrateApplication = HttpMigration.application(document);
|
|
83
|
+
migrate.routes.forEach((r) => {
|
|
84
|
+
if (r.method === "head") return;
|
|
85
|
+
const name: string = dict.get({
|
|
86
|
+
method: r.method as "post",
|
|
87
|
+
path: r.path,
|
|
88
|
+
});
|
|
89
|
+
if (r.accessor.length >= 2 && r.accessor.at(-2) === name) r.accessor.pop();
|
|
90
|
+
r.accessor[r.accessor.length - 1] = name;
|
|
91
|
+
r.operation()["x-samchon-accessor"] = r.accessor;
|
|
92
|
+
});
|
|
93
|
+
return document;
|
|
94
|
+
}
|
package/src/prisma/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./writePrismaApplication";
|
|
1
|
+
export * from "./writePrismaApplication";
|