@autobe/utils 0.24.1 → 0.25.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/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/replay/AutoBePlaygroundReplayUtil.d.ts +9 -0
- package/lib/replay/AutoBePlaygroundReplayUtil.js +58 -0
- package/lib/replay/AutoBePlaygroundReplayUtil.js.map +1 -0
- package/lib/replay/index.d.ts +1 -0
- package/lib/replay/index.js +18 -0
- package/lib/replay/index.js.map +1 -0
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/replay/AutoBePlaygroundReplayUtil.ts +117 -0
- package/src/replay/index.ts +1 -0
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./interface"), exports);
|
|
18
18
|
__exportStar(require("./test"), exports);
|
|
19
|
+
__exportStar(require("./replay"), exports);
|
|
19
20
|
__exportStar(require("./MapUtil"), exports);
|
|
20
21
|
__exportStar(require("./StringUtil"), exports);
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,yCAAuB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,yCAAuB;AACvB,2CAAyB;AAEzB,4CAA0B;AAC1B,+CAA6B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AutoBeHistory, IAutoBePlaygroundReplay, IAutoBeTokenUsageJson } from "@autobe/interface";
|
|
2
|
+
export declare namespace AutoBePlaygroundReplayUtil {
|
|
3
|
+
const summarize: (props: {
|
|
4
|
+
vendor: string;
|
|
5
|
+
project: string;
|
|
6
|
+
histories: AutoBeHistory[];
|
|
7
|
+
tokenUsage: IAutoBeTokenUsageJson;
|
|
8
|
+
}) => IAutoBePlaygroundReplay.ISummary | null;
|
|
9
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AutoBePlaygroundReplayUtil = void 0;
|
|
4
|
+
var AutoBePlaygroundReplayUtil;
|
|
5
|
+
(function (AutoBePlaygroundReplayUtil) {
|
|
6
|
+
AutoBePlaygroundReplayUtil.summarize = (props) => {
|
|
7
|
+
var _a;
|
|
8
|
+
const predicate = (type, success, aggregate) => {
|
|
9
|
+
var _a;
|
|
10
|
+
const reversed = props.histories.slice().reverse();
|
|
11
|
+
const step = (_a = reversed.find((h) => h.type === "analyze")) === null || _a === void 0 ? void 0 : _a.step;
|
|
12
|
+
if (step === undefined)
|
|
13
|
+
return null;
|
|
14
|
+
const history = reversed.find((h) => h.type === type && h.step === step);
|
|
15
|
+
if (history === undefined)
|
|
16
|
+
return null;
|
|
17
|
+
return {
|
|
18
|
+
success: success(history),
|
|
19
|
+
aggregate: aggregate(history),
|
|
20
|
+
elapsed: new Date(history.completed_at).getTime() -
|
|
21
|
+
new Date(history.created_at).getTime(),
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
const phaseStates = {
|
|
25
|
+
analyze: predicate("analyze", () => true, (h) => ({
|
|
26
|
+
actors: h.roles.length,
|
|
27
|
+
documents: h.files.length,
|
|
28
|
+
})),
|
|
29
|
+
prisma: predicate("prisma", (h) => h.compiled.type === "success", (h) => ({
|
|
30
|
+
namespaces: h.result.data.files.length,
|
|
31
|
+
models: h.result.data.files.map((f) => f.models).flat().length,
|
|
32
|
+
})),
|
|
33
|
+
interface: predicate("interface", () => true, (h) => ({
|
|
34
|
+
operations: h.document.operations.length,
|
|
35
|
+
schemas: Object.keys(h.document.components.schemas).length,
|
|
36
|
+
})),
|
|
37
|
+
test: predicate("test", (h) => h.compiled.type === "success", (h) => (Object.assign({ functions: h.files.length }, (h.compiled.type === "failure"
|
|
38
|
+
? {
|
|
39
|
+
errors: new Set(h.compiled.diagnostics.map((d) => { var _a; return (_a = d.file) !== null && _a !== void 0 ? _a : ""; }))
|
|
40
|
+
.size,
|
|
41
|
+
}
|
|
42
|
+
: {})))),
|
|
43
|
+
realize: predicate("realize", (h) => h.compiled.type === "success", (h) => (Object.assign({ functions: h.functions.length }, (h.compiled.type === "failure"
|
|
44
|
+
? {
|
|
45
|
+
errors: new Set(h.compiled.diagnostics.map((d) => { var _a; return (_a = d.file) !== null && _a !== void 0 ? _a : ""; }))
|
|
46
|
+
.size,
|
|
47
|
+
}
|
|
48
|
+
: {})))),
|
|
49
|
+
};
|
|
50
|
+
const phase = (_a = ["realize", "test", "interface", "prisma", "analyze"].find((key) => phaseStates[key] !== null)) !== null && _a !== void 0 ? _a : null;
|
|
51
|
+
return Object.assign(Object.assign({ vendor: props.vendor, project: props.project, tokenUsage: props.tokenUsage, elapsed: props.histories
|
|
52
|
+
.filter((h) => h.type !== "userMessage" && h.type !== "assistantMessage")
|
|
53
|
+
.map((h) => new Date(h.completed_at).getTime() -
|
|
54
|
+
new Date(h.created_at).getTime())
|
|
55
|
+
.reduce((a, b) => a + b, 0) }, phaseStates), { phase });
|
|
56
|
+
};
|
|
57
|
+
})(AutoBePlaygroundReplayUtil || (exports.AutoBePlaygroundReplayUtil = AutoBePlaygroundReplayUtil = {}));
|
|
58
|
+
//# sourceMappingURL=AutoBePlaygroundReplayUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutoBePlaygroundReplayUtil.js","sourceRoot":"","sources":["../../src/replay/AutoBePlaygroundReplayUtil.ts"],"names":[],"mappings":";;;AAOA,IAAiB,0BAA0B,CA6G1C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,CAAC,CAAC;AACJ,CAAC,EA7GgB,0BAA0B,0CAA1B,0BAA0B,QA6G1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./AutoBePlaygroundReplayUtil";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./AutoBePlaygroundReplayUtil"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/replay/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+DAA6C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autobe/utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"description": "AI backend server code generator",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"keywords": [],
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@samchon/openapi": "^4.7.1",
|
|
28
28
|
"tstl": "^3.0.0",
|
|
29
29
|
"typia": "^9.7.2",
|
|
30
|
-
"@autobe/interface": "^0.
|
|
30
|
+
"@autobe/interface": "^0.25.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"rimraf": "^6.0.1",
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AutoBeHistory,
|
|
3
|
+
AutoBePhase,
|
|
4
|
+
IAutoBePlaygroundReplay,
|
|
5
|
+
IAutoBeTokenUsageJson,
|
|
6
|
+
} from "@autobe/interface";
|
|
7
|
+
|
|
8
|
+
export namespace AutoBePlaygroundReplayUtil {
|
|
9
|
+
export const summarize = (props: {
|
|
10
|
+
vendor: string;
|
|
11
|
+
project: string;
|
|
12
|
+
histories: AutoBeHistory[];
|
|
13
|
+
tokenUsage: IAutoBeTokenUsageJson;
|
|
14
|
+
}): IAutoBePlaygroundReplay.ISummary | null => {
|
|
15
|
+
const predicate = <Type extends AutoBePhase>(
|
|
16
|
+
type: Type,
|
|
17
|
+
success: (history: AutoBeHistory.Mapper[Type]) => boolean,
|
|
18
|
+
aggregate: (
|
|
19
|
+
history: AutoBeHistory.Mapper[Type],
|
|
20
|
+
) => Record<string, number>,
|
|
21
|
+
): IAutoBePlaygroundReplay.IPhaseState | null => {
|
|
22
|
+
const reversed: AutoBeHistory[] = props.histories.slice().reverse();
|
|
23
|
+
const step: number | undefined = reversed.find(
|
|
24
|
+
(h) => h.type === "analyze",
|
|
25
|
+
)?.step;
|
|
26
|
+
if (step === undefined) return null;
|
|
27
|
+
|
|
28
|
+
const history: AutoBeHistory.Mapper[Type] | undefined = reversed.find(
|
|
29
|
+
(h) => h.type === type && h.step === step,
|
|
30
|
+
) as AutoBeHistory.Mapper[Type] | undefined;
|
|
31
|
+
if (history === undefined) return null;
|
|
32
|
+
return {
|
|
33
|
+
success: success(history),
|
|
34
|
+
aggregate: aggregate(history),
|
|
35
|
+
elapsed:
|
|
36
|
+
new Date(history.completed_at).getTime() -
|
|
37
|
+
new Date(history.created_at).getTime(),
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
const phaseStates: Record<
|
|
41
|
+
AutoBePhase,
|
|
42
|
+
IAutoBePlaygroundReplay.IPhaseState | null
|
|
43
|
+
> = {
|
|
44
|
+
analyze: predicate(
|
|
45
|
+
"analyze",
|
|
46
|
+
() => true,
|
|
47
|
+
(h) => ({
|
|
48
|
+
actors: h.roles.length,
|
|
49
|
+
documents: h.files.length,
|
|
50
|
+
}),
|
|
51
|
+
),
|
|
52
|
+
prisma: predicate(
|
|
53
|
+
"prisma",
|
|
54
|
+
(h) => h.compiled.type === "success",
|
|
55
|
+
(h) => ({
|
|
56
|
+
namespaces: h.result.data.files.length,
|
|
57
|
+
models: h.result.data.files.map((f) => f.models).flat().length,
|
|
58
|
+
}),
|
|
59
|
+
),
|
|
60
|
+
interface: predicate(
|
|
61
|
+
"interface",
|
|
62
|
+
() => true,
|
|
63
|
+
(h) => ({
|
|
64
|
+
operations: h.document.operations.length,
|
|
65
|
+
schemas: Object.keys(h.document.components.schemas).length,
|
|
66
|
+
}),
|
|
67
|
+
),
|
|
68
|
+
test: predicate(
|
|
69
|
+
"test",
|
|
70
|
+
(h) => h.compiled.type === "success",
|
|
71
|
+
(h) => ({
|
|
72
|
+
functions: h.files.length,
|
|
73
|
+
...(h.compiled.type === "failure"
|
|
74
|
+
? {
|
|
75
|
+
errors: new Set(h.compiled.diagnostics.map((d) => d.file ?? ""))
|
|
76
|
+
.size,
|
|
77
|
+
}
|
|
78
|
+
: {}),
|
|
79
|
+
}),
|
|
80
|
+
),
|
|
81
|
+
realize: predicate(
|
|
82
|
+
"realize",
|
|
83
|
+
(h) => h.compiled.type === "success",
|
|
84
|
+
(h) => ({
|
|
85
|
+
functions: h.functions.length,
|
|
86
|
+
...(h.compiled.type === "failure"
|
|
87
|
+
? {
|
|
88
|
+
errors: new Set(h.compiled.diagnostics.map((d) => d.file ?? ""))
|
|
89
|
+
.size,
|
|
90
|
+
}
|
|
91
|
+
: {}),
|
|
92
|
+
}),
|
|
93
|
+
),
|
|
94
|
+
};
|
|
95
|
+
const phase: AutoBePhase | null =
|
|
96
|
+
(["realize", "test", "interface", "prisma", "analyze"] as const).find(
|
|
97
|
+
(key) => phaseStates[key] !== null,
|
|
98
|
+
) ?? null;
|
|
99
|
+
return {
|
|
100
|
+
vendor: props.vendor,
|
|
101
|
+
project: props.project,
|
|
102
|
+
tokenUsage: props.tokenUsage,
|
|
103
|
+
elapsed: props.histories
|
|
104
|
+
.filter(
|
|
105
|
+
(h) => h.type !== "userMessage" && h.type !== "assistantMessage",
|
|
106
|
+
)
|
|
107
|
+
.map(
|
|
108
|
+
(h) =>
|
|
109
|
+
new Date(h.completed_at).getTime() -
|
|
110
|
+
new Date(h.created_at).getTime(),
|
|
111
|
+
)
|
|
112
|
+
.reduce((a, b) => a + b, 0),
|
|
113
|
+
...phaseStates,
|
|
114
|
+
phase,
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./AutoBePlaygroundReplayUtil";
|