@autobe/utils 0.29.1 → 0.30.0-dev.20260315
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/README.md +261 -0
- package/lib/AutoBeEscaper.d.ts +4 -0
- package/lib/AutoBeEscaper.js +85 -0
- package/lib/AutoBeEscaper.js.map +1 -0
- package/lib/StringUtil.d.ts +1 -0
- package/lib/StringUtil.js +15 -36
- package/lib/StringUtil.js.map +1 -1
- package/lib/aggregate/AutoBeProcessAggregateFactory.js +9 -0
- package/lib/aggregate/AutoBeProcessAggregateFactory.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/interface/AutoBeOpenApiEndpointComparator.d.ts +1 -0
- package/lib/interface/AutoBeOpenApiEndpointComparator.js +4 -0
- package/lib/interface/AutoBeOpenApiEndpointComparator.js.map +1 -1
- package/lib/interface/AutoBeOpenApiTypeChecker.d.ts +14 -0
- package/lib/interface/AutoBeOpenApiTypeChecker.js +67 -0
- package/lib/interface/AutoBeOpenApiTypeChecker.js.map +1 -1
- package/lib/interface/invertOpenApiDocument.d.ts +1 -1
- package/lib/interface/invertOpenApiDocument.js +22 -7
- package/lib/interface/invertOpenApiDocument.js.map +1 -1
- package/lib/interface/missedOpenApiSchemas.js +3 -3
- package/lib/interface/missedOpenApiSchemas.js.map +1 -1
- package/lib/interface/revertOpenApiAccessor.js +2 -2
- package/lib/interface/revertOpenApiAccessor.js.map +1 -1
- package/lib/interface/transformOpenApiDocument.d.ts +2 -2
- package/lib/interface/transformOpenApiDocument.js +14 -11
- package/lib/interface/transformOpenApiDocument.js.map +1 -1
- package/lib/prisma/writePrismaApplication.d.ts +2 -2
- package/lib/prisma/writePrismaApplication.js +75 -66
- package/lib/prisma/writePrismaApplication.js.map +1 -1
- package/lib/test/validateTestExpression.js +3 -1
- package/lib/test/validateTestExpression.js.map +1 -1
- package/lib/test/validateTestStatement.js +3 -1
- package/lib/test/validateTestStatement.js.map +1 -1
- package/package.json +5 -5
- package/src/ArrayUtil.ts +21 -21
- package/src/AutoBeEscaper.ts +83 -0
- package/src/MapUtil.ts +10 -10
- package/src/StringUtil.ts +34 -59
- package/src/aggregate/AutoBeFunctionCallingMetricFactory.ts +44 -44
- package/src/aggregate/AutoBeProcessAggregateFactory.ts +161 -152
- package/src/aggregate/TokenUsageComputer.ts +49 -49
- package/src/aggregate/index.ts +3 -3
- package/src/index.ts +10 -9
- package/src/interface/AutoBeOpenApiEndpointComparator.ts +27 -20
- package/src/interface/AutoBeOpenApiTypeChecker.ts +127 -43
- package/src/interface/index.ts +6 -6
- package/src/interface/invertOpenApiDocument.ts +80 -68
- package/src/interface/missedOpenApiSchemas.ts +25 -25
- package/src/interface/revertOpenApiAccessor.ts +25 -25
- package/src/interface/transformOpenApiDocument.ts +94 -91
- package/src/prisma/index.ts +1 -1
- package/src/prisma/writePrismaApplication.ts +456 -439
- 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 -10
- package/src/test/validateTestFunction.ts +7 -7
- package/src/test/validateTestStatement.ts +16 -10
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validateTestStatement = void 0;
|
|
4
4
|
const AutoBeTestStatementValidator_1 = require("./AutoBeTestStatementValidator");
|
|
5
|
-
const validateTestStatement = (ctx, item, path) => AutoBeTestStatementValidator_1.AutoBeTestStatementValidator[item.type](ctx,
|
|
5
|
+
const validateTestStatement = (ctx, item, path) => AutoBeTestStatementValidator_1.AutoBeTestStatementValidator[item.type](ctx,
|
|
6
|
+
// biome-ignore lint: intended
|
|
7
|
+
item, path);
|
|
6
8
|
exports.validateTestStatement = validateTestStatement;
|
|
7
9
|
//# sourceMappingURL=validateTestStatement.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateTestStatement.js","sourceRoot":"","sources":["../../src/test/validateTestStatement.ts"],"names":[],"mappings":";;;AAEA,iFAA8E;AAGvE,MAAM,qBAAqB,GAAG,CACnC,GAA+B,EAC/B,IAA2B,EAC3B,IAAY,EACN,EAAE,
|
|
1
|
+
{"version":3,"file":"validateTestStatement.js","sourceRoot":"","sources":["../../src/test/validateTestStatement.ts"],"names":[],"mappings":";;;AAEA,iFAA8E;AAGvE,MAAM,qBAAqB,GAAG,CACnC,GAA+B,EAC/B,IAA2B,EAC3B,IAAY,EACN,EAAE,CACR,2DAA4B,CAAC,IAAI,CAAC,IAAI,CAAC,CACrC,GAAG;AACH,8BAA8B;AAC9B,IAAW,EACX,IAAI,CACL,CAAC;AAVS,QAAA,qBAAqB,yBAU9B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autobe/utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.0-dev.20260315",
|
|
4
4
|
"description": "AI backend server code generator",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"keywords": [],
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@
|
|
27
|
+
"@typia/interface": "^12.0.1",
|
|
28
|
+
"@typia/utils": "^12.0.1",
|
|
28
29
|
"tstl": "^3.0.0",
|
|
29
|
-
"typia": "^
|
|
30
|
-
"@autobe/interface": "^0.
|
|
30
|
+
"typia": "^12.0.1",
|
|
31
|
+
"@autobe/interface": "^0.30.0-dev.20260315"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@types/node": "^24.10.1",
|
|
34
35
|
"rimraf": "^6.0.1",
|
|
35
|
-
"ts-patch": "^3.3.0",
|
|
36
36
|
"typescript": "~5.9.3"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
package/src/ArrayUtil.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
export namespace ArrayUtil {
|
|
2
|
-
export async function asyncMap<T, U>(
|
|
3
|
-
array: T[],
|
|
4
|
-
callback: (value: T, index: number, array: T[]) => Promise<U>,
|
|
5
|
-
): Promise<U[]> {
|
|
6
|
-
const result: U[] = new Array(array.length);
|
|
7
|
-
for (let i = 0; i < array.length; i++)
|
|
8
|
-
result[i] = await callback(array[i], i, array);
|
|
9
|
-
return result;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function paddle(contents: string[][]): string[] {
|
|
13
|
-
const output: string[] = [];
|
|
14
|
-
contents.forEach((c) => {
|
|
15
|
-
if (c.length === 0) return;
|
|
16
|
-
else if (output.length === 0) output.push(...c);
|
|
17
|
-
else output.push("", ...c);
|
|
18
|
-
});
|
|
19
|
-
return output;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
1
|
+
export namespace ArrayUtil {
|
|
2
|
+
export async function asyncMap<T, U>(
|
|
3
|
+
array: T[],
|
|
4
|
+
callback: (value: T, index: number, array: T[]) => Promise<U>,
|
|
5
|
+
): Promise<U[]> {
|
|
6
|
+
const result: U[] = new Array(array.length);
|
|
7
|
+
for (let i = 0; i < array.length; i++)
|
|
8
|
+
result[i] = await callback(array[i], i, array);
|
|
9
|
+
return result;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function paddle(contents: string[][]): string[] {
|
|
13
|
+
const output: string[] = [];
|
|
14
|
+
contents.forEach((c) => {
|
|
15
|
+
if (c.length === 0) return;
|
|
16
|
+
else if (output.length === 0) output.push(...c);
|
|
17
|
+
else output.push("", ...c);
|
|
18
|
+
});
|
|
19
|
+
return output;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export namespace AutoBeEscaper {
|
|
2
|
+
export const variable = (str: string): boolean =>
|
|
3
|
+
reserved(str) === false && /^[a-zA-Z_$][a-zA-Z_$0-9]*$/g.test(str);
|
|
4
|
+
|
|
5
|
+
export const reserved = (str: string): boolean => KEYWORDS.includes(str);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const KEYWORDS = [
|
|
9
|
+
// data types
|
|
10
|
+
"boolean",
|
|
11
|
+
"byte",
|
|
12
|
+
"char",
|
|
13
|
+
"double",
|
|
14
|
+
"float",
|
|
15
|
+
"int",
|
|
16
|
+
"long",
|
|
17
|
+
"short",
|
|
18
|
+
"void",
|
|
19
|
+
// literals
|
|
20
|
+
"false",
|
|
21
|
+
"null",
|
|
22
|
+
"true",
|
|
23
|
+
// variable declarations
|
|
24
|
+
"let",
|
|
25
|
+
"const",
|
|
26
|
+
"var",
|
|
27
|
+
// control flow
|
|
28
|
+
"break",
|
|
29
|
+
"case",
|
|
30
|
+
"continue",
|
|
31
|
+
"default",
|
|
32
|
+
"do",
|
|
33
|
+
"else",
|
|
34
|
+
"for",
|
|
35
|
+
"if",
|
|
36
|
+
"return",
|
|
37
|
+
"switch",
|
|
38
|
+
"while",
|
|
39
|
+
"with",
|
|
40
|
+
// class related
|
|
41
|
+
"class",
|
|
42
|
+
"extends",
|
|
43
|
+
"implements",
|
|
44
|
+
"instanceof",
|
|
45
|
+
"interface",
|
|
46
|
+
"new",
|
|
47
|
+
"package",
|
|
48
|
+
"super",
|
|
49
|
+
"this",
|
|
50
|
+
// function related
|
|
51
|
+
"function",
|
|
52
|
+
// modifiers
|
|
53
|
+
"abstract",
|
|
54
|
+
"final",
|
|
55
|
+
"native",
|
|
56
|
+
"private",
|
|
57
|
+
"protected",
|
|
58
|
+
"public",
|
|
59
|
+
"static",
|
|
60
|
+
"strictfp",
|
|
61
|
+
"synchronized",
|
|
62
|
+
"transient",
|
|
63
|
+
"volatile",
|
|
64
|
+
// exception handling
|
|
65
|
+
"assert",
|
|
66
|
+
"catch",
|
|
67
|
+
"finally",
|
|
68
|
+
"throw",
|
|
69
|
+
"throws",
|
|
70
|
+
"try",
|
|
71
|
+
// module system
|
|
72
|
+
"export",
|
|
73
|
+
"import",
|
|
74
|
+
"module",
|
|
75
|
+
// operators
|
|
76
|
+
"delete",
|
|
77
|
+
"in",
|
|
78
|
+
"typeof",
|
|
79
|
+
// debugging
|
|
80
|
+
"debugger",
|
|
81
|
+
// other
|
|
82
|
+
"enum",
|
|
83
|
+
];
|
package/src/MapUtil.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export namespace MapUtil {
|
|
2
|
-
export function take<K, V>(map: Map<K, V>, key: K, value: () => V): V {
|
|
3
|
-
if (map.has(key)) {
|
|
4
|
-
return map.get(key) as V;
|
|
5
|
-
}
|
|
6
|
-
const newValue = value();
|
|
7
|
-
map.set(key, newValue);
|
|
8
|
-
return newValue;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
1
|
+
export namespace MapUtil {
|
|
2
|
+
export function take<K, V>(map: Map<K, V>, key: K, value: () => V): V {
|
|
3
|
+
if (map.has(key)) {
|
|
4
|
+
return map.get(key) as V;
|
|
5
|
+
}
|
|
6
|
+
const newValue = value();
|
|
7
|
+
map.set(key, newValue);
|
|
8
|
+
return newValue;
|
|
9
|
+
}
|
|
10
|
+
}
|
package/src/StringUtil.ts
CHANGED
|
@@ -1,59 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const dedentedLines = lines.map((line) => {
|
|
36
|
-
if (line.trim() === "") return "";
|
|
37
|
-
return line.slice(minIndent);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// placeholder를 실제 값으로 교체
|
|
41
|
-
let result = dedentedLines.join("\n");
|
|
42
|
-
for (let i = 0; i < values.length; i++) {
|
|
43
|
-
result = result.replace(`__PLACEHOLDER_${i}__`, String(values[i]));
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return result;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function singleLine(
|
|
50
|
-
strings: TemplateStringsArray,
|
|
51
|
-
...values: any[]
|
|
52
|
-
): string {
|
|
53
|
-
let result: string = strings[0];
|
|
54
|
-
for (let i = 0; i < values.length; i++) {
|
|
55
|
-
result += String(values[i]) + strings[i + 1];
|
|
56
|
-
}
|
|
57
|
-
return result.replace(/\n/g, " ").replace(/\s+/g, " ").trim();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
1
|
+
import { dedent } from "@typia/utils";
|
|
2
|
+
|
|
3
|
+
export namespace StringUtil {
|
|
4
|
+
export function trim(
|
|
5
|
+
strings: TemplateStringsArray,
|
|
6
|
+
// biome-ignore lint: intended
|
|
7
|
+
...values: any[]
|
|
8
|
+
): string {
|
|
9
|
+
return dedent(strings, ...values);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function singleLine(
|
|
13
|
+
strings: TemplateStringsArray,
|
|
14
|
+
// biome-ignore lint: intended
|
|
15
|
+
...values: any[]
|
|
16
|
+
): string {
|
|
17
|
+
let result: string = strings[0];
|
|
18
|
+
for (let i = 0; i < values.length; i++) {
|
|
19
|
+
result += String(values[i]) + strings[i + 1];
|
|
20
|
+
}
|
|
21
|
+
return result.replace(/\n/g, " ").replace(/\s+/g, " ").trim();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function summary(description: string): string {
|
|
25
|
+
const newLine: number = description.indexOf("\n");
|
|
26
|
+
const dot: number = description.indexOf(".");
|
|
27
|
+
const minimum: number = Math.min(
|
|
28
|
+
newLine === -1 ? Number.MAX_SAFE_INTEGER : newLine,
|
|
29
|
+
dot === -1 ? Number.MAX_SAFE_INTEGER : dot,
|
|
30
|
+
description.length,
|
|
31
|
+
);
|
|
32
|
+
return description.substring(0, minimum);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { AutoBeFunctionCallingMetric } from "@autobe/interface";
|
|
2
|
-
|
|
3
|
-
export namespace AutoBeFunctionCallingMetricFactory {
|
|
4
|
-
export const create = (): AutoBeFunctionCallingMetric => ({
|
|
5
|
-
attempt: 0,
|
|
6
|
-
success: 0,
|
|
7
|
-
consent: 0,
|
|
8
|
-
validationFailure: 0,
|
|
9
|
-
invalidJson: 0,
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
export const increment = (
|
|
13
|
-
x: AutoBeFunctionCallingMetric,
|
|
14
|
-
y: AutoBeFunctionCallingMetric,
|
|
15
|
-
): void => {
|
|
16
|
-
x.attempt += y.attempt;
|
|
17
|
-
x.success += y.success;
|
|
18
|
-
x.consent += y.consent;
|
|
19
|
-
x.validationFailure += y.validationFailure;
|
|
20
|
-
x.invalidJson += y.invalidJson;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const plus = (
|
|
24
|
-
x: AutoBeFunctionCallingMetric,
|
|
25
|
-
y: AutoBeFunctionCallingMetric,
|
|
26
|
-
): AutoBeFunctionCallingMetric => ({
|
|
27
|
-
attempt: x.attempt + y.attempt,
|
|
28
|
-
success: x.success + y.success,
|
|
29
|
-
consent: x.consent + y.consent,
|
|
30
|
-
validationFailure: x.validationFailure + y.validationFailure,
|
|
31
|
-
invalidJson: x.invalidJson + y.invalidJson,
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
export const minus = (
|
|
35
|
-
x: AutoBeFunctionCallingMetric,
|
|
36
|
-
y: AutoBeFunctionCallingMetric,
|
|
37
|
-
): AutoBeFunctionCallingMetric => ({
|
|
38
|
-
attempt: x.attempt - y.attempt,
|
|
39
|
-
success: x.success - y.success,
|
|
40
|
-
consent: x.consent - y.consent,
|
|
41
|
-
validationFailure: x.validationFailure - y.validationFailure,
|
|
42
|
-
invalidJson: x.invalidJson - y.invalidJson,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
1
|
+
import { AutoBeFunctionCallingMetric } from "@autobe/interface";
|
|
2
|
+
|
|
3
|
+
export namespace AutoBeFunctionCallingMetricFactory {
|
|
4
|
+
export const create = (): AutoBeFunctionCallingMetric => ({
|
|
5
|
+
attempt: 0,
|
|
6
|
+
success: 0,
|
|
7
|
+
consent: 0,
|
|
8
|
+
validationFailure: 0,
|
|
9
|
+
invalidJson: 0,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const increment = (
|
|
13
|
+
x: AutoBeFunctionCallingMetric,
|
|
14
|
+
y: AutoBeFunctionCallingMetric,
|
|
15
|
+
): void => {
|
|
16
|
+
x.attempt += y.attempt;
|
|
17
|
+
x.success += y.success;
|
|
18
|
+
x.consent += y.consent;
|
|
19
|
+
x.validationFailure += y.validationFailure;
|
|
20
|
+
x.invalidJson += y.invalidJson;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const plus = (
|
|
24
|
+
x: AutoBeFunctionCallingMetric,
|
|
25
|
+
y: AutoBeFunctionCallingMetric,
|
|
26
|
+
): AutoBeFunctionCallingMetric => ({
|
|
27
|
+
attempt: x.attempt + y.attempt,
|
|
28
|
+
success: x.success + y.success,
|
|
29
|
+
consent: x.consent + y.consent,
|
|
30
|
+
validationFailure: x.validationFailure + y.validationFailure,
|
|
31
|
+
invalidJson: x.invalidJson + y.invalidJson,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export const minus = (
|
|
35
|
+
x: AutoBeFunctionCallingMetric,
|
|
36
|
+
y: AutoBeFunctionCallingMetric,
|
|
37
|
+
): AutoBeFunctionCallingMetric => ({
|
|
38
|
+
attempt: x.attempt - y.attempt,
|
|
39
|
+
success: x.success - y.success,
|
|
40
|
+
consent: x.consent - y.consent,
|
|
41
|
+
validationFailure: x.validationFailure - y.validationFailure,
|
|
42
|
+
invalidJson: x.invalidJson - y.invalidJson,
|
|
43
|
+
});
|
|
44
|
+
}
|