@autobe/agent 0.9.0 → 0.9.2

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.
Files changed (62) hide show
  1. package/lib/AutoBeAgent.js +7 -1
  2. package/lib/AutoBeAgent.js.map +1 -1
  3. package/lib/constants/AutoBeSystemPromptConstant.d.ts +5 -3
  4. package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
  5. package/lib/context/IAutoBeApplicationProps.d.ts +0 -61
  6. package/lib/factory/createAutoBeApplication.js +15 -135
  7. package/lib/factory/createAutoBeApplication.js.map +1 -1
  8. package/lib/index.mjs +1054 -1037
  9. package/lib/index.mjs.map +1 -1
  10. package/lib/orchestrate/analyze/orchestrateAnalyze.js +4 -30
  11. package/lib/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
  12. package/lib/orchestrate/interface/orchestrateInterface.js +9 -3
  13. package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
  14. package/lib/orchestrate/test/compileTestScenario.d.ts +5 -0
  15. package/lib/orchestrate/test/compileTestScenario.js +57 -0
  16. package/lib/orchestrate/test/compileTestScenario.js.map +1 -0
  17. package/lib/orchestrate/test/filterTestFileName.d.ts +1 -0
  18. package/lib/orchestrate/test/filterTestFileName.js +13 -0
  19. package/lib/orchestrate/test/filterTestFileName.js.map +1 -0
  20. package/lib/orchestrate/test/orchestrateTest.js +6 -3
  21. package/lib/orchestrate/test/orchestrateTest.js.map +1 -1
  22. package/lib/orchestrate/test/orchestrateTestCorrect.d.ts +2 -2
  23. package/lib/orchestrate/test/orchestrateTestCorrect.js +172 -87
  24. package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  25. package/lib/orchestrate/test/orchestrateTestScenario.js +98 -83
  26. package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
  27. package/lib/orchestrate/test/orchestrateTestWrite.d.ts +4 -0
  28. package/lib/orchestrate/test/{orchestrateTestProgress.js → orchestrateTestWrite.js} +27 -54
  29. package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -0
  30. package/lib/orchestrate/test/structures/IAutoBeTestScenarioApplication.d.ts +18 -20
  31. package/lib/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.d.ts +7 -0
  32. package/lib/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.js +3 -0
  33. package/lib/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.js.map +1 -0
  34. package/lib/orchestrate/test/transformTestCorrectHistories.d.ts +2 -2
  35. package/lib/orchestrate/test/transformTestCorrectHistories.js +38 -16
  36. package/lib/orchestrate/test/transformTestCorrectHistories.js.map +1 -1
  37. package/lib/orchestrate/test/transformTestWriteHistories.d.ts +7 -0
  38. package/lib/orchestrate/test/transformTestWriteHistories.js +59 -0
  39. package/lib/orchestrate/test/transformTestWriteHistories.js.map +1 -0
  40. package/lib/structures/IAutoBeProps.d.ts +12 -1
  41. package/package.json +4 -5
  42. package/src/AutoBeAgent.ts +14 -2
  43. package/src/constants/AutoBeSystemPromptConstant.ts +5 -3
  44. package/src/context/IAutoBeApplicationProps.ts +0 -62
  45. package/src/orchestrate/analyze/orchestrateAnalyze.ts +4 -34
  46. package/src/orchestrate/interface/orchestrateInterface.ts +7 -0
  47. package/src/orchestrate/test/compileTestScenario.ts +64 -0
  48. package/src/orchestrate/test/filterTestFileName.ts +9 -0
  49. package/src/orchestrate/test/orchestrateTest.ts +15 -9
  50. package/src/orchestrate/test/orchestrateTestCorrect.ts +288 -128
  51. package/src/orchestrate/test/orchestrateTestScenario.ts +23 -6
  52. package/src/orchestrate/test/{orchestrateTestProgress.ts → orchestrateTestWrite.ts} +56 -87
  53. package/src/orchestrate/test/structures/IAutoBeTestScenarioApplication.ts +18 -20
  54. package/src/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.ts +8 -0
  55. package/src/orchestrate/test/transformTestCorrectHistories.ts +41 -17
  56. package/src/orchestrate/test/{transformTestProgressHistories.ts → transformTestWriteHistories.ts} +21 -10
  57. package/src/structures/IAutoBeProps.ts +17 -1
  58. package/lib/orchestrate/test/orchestrateTestProgress.d.ts +0 -5
  59. package/lib/orchestrate/test/orchestrateTestProgress.js.map +0 -1
  60. package/lib/orchestrate/test/transformTestProgressHistories.d.ts +0 -8
  61. package/lib/orchestrate/test/transformTestProgressHistories.js +0 -47
  62. package/lib/orchestrate/test/transformTestProgressHistories.js.map +0 -1
@@ -1,25 +1,19 @@
1
1
  import { IAgenticaController, MicroAgentica } from "@agentica/core";
2
- import {
3
- AutoBeOpenApi,
4
- AutoBeTestScenarioEvent,
5
- AutoBeTestWriteEvent,
6
- } from "@autobe/interface";
7
- import {
8
- ILlmApplication,
9
- ILlmSchema,
10
- OpenApiTypeChecker,
11
- } from "@samchon/openapi";
2
+ import { AutoBeTestScenario, AutoBeTestWriteEvent } from "@autobe/interface";
3
+ import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
12
4
  import { IPointer } from "tstl";
13
5
  import typia from "typia";
14
6
 
15
7
  import { AutoBeContext } from "../../context/AutoBeContext";
16
8
  import { assertSchemaModel } from "../../context/assertSchemaModel";
17
9
  import { enforceToolCall } from "../../utils/enforceToolCall";
18
- import { transformTestProgressHistories } from "./transformTestProgressHistories";
10
+ import { compileTestScenario } from "./compileTestScenario";
11
+ import { IAutoBeTestScenarioArtifacts } from "./structures/IAutoBeTestScenarioArtifacts";
12
+ import { transformTestWriteHistories } from "./transformTestWriteHistories";
19
13
 
20
- export async function orchestrateTestProgress<Model extends ILlmSchema.Model>(
14
+ export async function orchestrateTestWrite<Model extends ILlmSchema.Model>(
21
15
  ctx: AutoBeContext<Model>,
22
- scenarios: AutoBeTestScenarioEvent.IScenario[],
16
+ scenarios: AutoBeTestScenario[],
23
17
  ): Promise<AutoBeTestWriteEvent[]> {
24
18
  const start: Date = new Date();
25
19
  let complete: number = 0;
@@ -35,7 +29,7 @@ export async function orchestrateTestProgress<Model extends ILlmSchema.Model>(
35
29
  const event: AutoBeTestWriteEvent = {
36
30
  type: "testWrite",
37
31
  created_at: start.toISOString(),
38
- filename: `${code.domain}/${scenario.functionName}.ts`,
32
+ filename: `test/features/api/${code.domain}/${scenario.functionName}.ts`,
39
33
  content: code.content,
40
34
  completed: ++complete,
41
35
  total: scenarios.length,
@@ -61,20 +55,15 @@ export async function orchestrateTestProgress<Model extends ILlmSchema.Model>(
61
55
  */
62
56
  async function process<Model extends ILlmSchema.Model>(
63
57
  ctx: AutoBeContext<Model>,
64
- scenario: AutoBeTestScenarioEvent.IScenario,
58
+ scenario: AutoBeTestScenario,
65
59
  ): Promise<ICreateTestCodeProps> {
66
60
  const pointer: IPointer<ICreateTestCodeProps | null> = {
67
61
  value: null,
68
62
  };
69
- const document: AutoBeOpenApi.IDocument = filterDocument(
63
+ const artifacts: IAutoBeTestScenarioArtifacts = await compileTestScenario(
64
+ ctx,
70
65
  scenario,
71
- ctx.state().interface!.document,
72
66
  );
73
- const files: [string, string][] = Object.entries(
74
- await ctx.compiler.interface.compile(document),
75
- );
76
- const filter = (prefix: string) =>
77
- Object.fromEntries(files.filter(([key]) => key.startsWith(prefix)));
78
67
 
79
68
  const agentica = new MicroAgentica({
80
69
  model: ctx.model,
@@ -82,11 +71,9 @@ async function process<Model extends ILlmSchema.Model>(
82
71
  config: {
83
72
  ...(ctx.config ?? {}),
84
73
  },
85
- histories: transformTestProgressHistories({
86
- scenario: scenario,
87
- dto: filter("src/api/structures"),
88
- sdk: filter("src/api/functional"),
89
- e2e: filter("test/features"),
74
+ histories: transformTestWriteHistories({
75
+ scenario,
76
+ artifacts,
90
77
  }),
91
78
  controllers: [
92
79
  createApplication({
@@ -102,53 +89,36 @@ async function process<Model extends ILlmSchema.Model>(
102
89
 
103
90
  await agentica.conversate("Create e2e test functions.");
104
91
  if (pointer.value === null) throw new Error("Failed to create test code.");
105
- return pointer.value;
106
- }
107
92
 
108
- export function filterDocument(
109
- scenario: AutoBeTestScenarioEvent.IScenario,
110
- document: AutoBeOpenApi.IDocument,
111
- ): AutoBeOpenApi.IDocument {
112
- const operations: AutoBeOpenApi.IOperation[] = document.operations.filter(
113
- (op) => {
114
- if (
115
- scenario.endpoint.method === op.method &&
116
- scenario.endpoint.path === op.path
117
- ) {
118
- return true;
119
- } else if (
120
- scenario.dependencies.some(
121
- (dp) =>
122
- dp.endpoint.method === op.method && dp.endpoint.path === op.path,
123
- )
124
- ) {
125
- return true;
126
- }
127
- },
93
+ const typeReferences: string[] = Array.from(
94
+ new Set(
95
+ Object.keys(artifacts.document.components.schemas).map(
96
+ (key) => key.split(".")[0]!,
97
+ ),
98
+ ),
128
99
  );
129
- const components: AutoBeOpenApi.IComponents = {
130
- schemas: {},
131
- };
132
- const visit = (typeName: string) => {
133
- OpenApiTypeChecker.visit({
134
- components: document.components,
135
- schema: { $ref: `#/components/schemas/${typeName}` },
136
- closure: (s) => {
137
- if (OpenApiTypeChecker.isReference(s)) {
138
- const key: string = s.$ref.split("/").pop()!;
139
- components.schemas[key] = document.components.schemas[key];
140
- }
141
- },
142
- });
143
- };
144
- for (const op of operations) {
145
- if (op.requestBody) visit(op.requestBody.typeName);
146
- if (op.responseBody) visit(op.responseBody.typeName);
147
- }
148
- return {
149
- operations,
150
- components,
151
- };
100
+ pointer.value.content = pointer.value.content
101
+ .replace(/^[ \t]*import\b[\s\S]*?;[ \t]*$/gm, "")
102
+ .trim();
103
+ pointer.value.content = [
104
+ `import { TestValidator } from "@nestia/e2e";`,
105
+ `import typia, { tags } from "typia";`,
106
+ "",
107
+ `import api from "@ORGANIZATION/PROJECT-api";`,
108
+ ...typeReferences.map(
109
+ (ref) =>
110
+ `import type { ${ref} } from "@ORGANIZATION/PROJECT-api/lib/structures/${ref}";`,
111
+ ),
112
+ "",
113
+ pointer.value.content,
114
+ ].join("\n");
115
+
116
+ pointer.value.content = pointer.value.content.replaceAll(
117
+ 'string & Format<"uuid">',
118
+ 'string & tags.Format<"uuid">',
119
+ );
120
+
121
+ return pointer.value;
152
122
  }
153
123
 
154
124
  function createApplication<Model extends ILlmSchema.Model>(props: {
@@ -206,8 +176,9 @@ interface ICreateTestCodeProps {
206
176
  *
207
177
  * ### Critical Requirements
208
178
  *
209
- * - Must follow the Test Generation Guildelines.
210
- * - Must Planning the test code Never occur the typescript compile error.
179
+ * - Must follow the Test Generation Guidelines.
180
+ * - Must Planning the test code Never occur the TypeScript compile error.
181
+ * - NEVER include import statements in planning or implementation.
211
182
  *
212
183
  * ### Planning Elements:
213
184
  *
@@ -235,7 +206,7 @@ interface ICreateTestCodeProps {
235
206
  * 4. Test error plans (missing fields, invalid data)
236
207
  * 5. Verify database state changes
237
208
  * 6. Reconsider the scenario if it doesn't follow the Test Generation
238
- * Guildelines.
209
+ * Guidelines.
239
210
  */
240
211
  scenario: string;
241
212
 
@@ -274,16 +245,14 @@ interface ICreateTestCodeProps {
274
245
  *
275
246
  * ### Technical Implementation Requirements:
276
247
  *
277
- * #### Import Declarations
278
- * ```typescript
279
- * import api from "@ORGANIZATION/PROJECT-api";
280
- * import { ITargetType } from "@ORGANIZATION/PROJECT-api/lib/structures/[path]";
281
- * import { TestValidator } from "@nestia/e2e";
282
- * import typia from "typia";
283
- * ```
284
- * - Must use exact `@ORGANIZATION/PROJECT-api` module path
285
- * - Include `@ORGANIZATION` prefix in all API-related imports
286
- * - Import specific DTO types from correct structure paths
248
+ * #### NO IMPORT DECLARATIONS
249
+ * - NEVER write any import statements
250
+ * - Start code directly with `export async function`
251
+ * - All dependencies assumed globally available:
252
+ * - `api` for SDK functions
253
+ * - `typia` for validation and random data
254
+ * - All DTO types (ITargetType, etc.)
255
+ * - `TestValidator` for assertions
287
256
  *
288
257
  * #### Code Quality Standards
289
258
  * - Zero TypeScript compilation errors (mandatory)
@@ -294,12 +263,12 @@ interface ICreateTestCodeProps {
294
263
  * - Consistent formatting and naming conventions
295
264
  *
296
265
  * ### Critical Error Prevention
297
- * - Verify all import paths are correct and accessible
266
+ * - Verify all API function signatures and parameter types
298
267
  * - Ensure type compatibility between variables and assignments
299
268
  * - Include all required object properties and methods
300
- * - Validate API function signatures and parameter types
301
269
  * - Confirm proper generic type usage
302
270
  * - Test async function declarations and Promise handling
271
+ * - NO IMPORT STATEMENTS ANYWHERE IN CODE
303
272
  */
304
273
  content: string;
305
274
  }
@@ -26,17 +26,9 @@ export namespace IAutoBeTestScenarioApplication {
26
26
  /**
27
27
  * Represents a test scenario for a single API operation.
28
28
  *
29
- * This interface extends `AutoBeOpenApi.IEndpoint`, inheriting its HTTP
30
- * method and path information, and adds two key properties:
31
- *
32
- * - `draft`: A free-form, human-readable test scenario description for the API
33
- * endpoint.
34
- * - `dependsOn`: A list of other API endpoints that must be invoked beforehand
35
- * in order to prepare the context for this test. Each dependency includes
36
- * the purpose of the dependency.
37
- *
38
- * This structure is intended to help organize test specifications for complex
39
- * workflows and ensure that all prerequisites are explicitly declared.
29
+ * This interface defines a structured, user-centric test draft that includes
30
+ * a descriptive function name, a detailed scenario draft, and logical
31
+ * dependencies on other endpoints required for context or setup.
40
32
  */
41
33
  export interface IScenario {
42
34
  /**
@@ -44,7 +36,7 @@ export namespace IAutoBeTestScenarioApplication {
44
36
  * be tested. This should include both successful and failure scenarios,
45
37
  * business rule validations, edge cases, and any sequence of steps
46
38
  * necessary to perform the test. A subsequent agent will use this draft to
47
- * generate multiple test scenarios.
39
+ * generate multiple concrete test cases.
48
40
  */
49
41
  draft: string;
50
42
 
@@ -109,20 +101,26 @@ export namespace IAutoBeTestScenarioApplication {
109
101
  functionName: string;
110
102
 
111
103
  /**
112
- * A list of other API endpoints that must be executed before this test
113
- * scenario. This helps express dependencies such as data creation or
114
- * authentication steps required to reach the intended test state.
104
+ * A list of other API endpoints that this scenario logically depends on.
105
+ *
106
+ * These dependencies represent context or prerequisite conditions, such as
107
+ * authentication, resource creation, or data setup, that are relevant to
108
+ * the test. This list is not a strict execution order — if ordering is
109
+ * important, it must be described explicitly in the `purpose`.
115
110
  */
116
- dependsOn: IDependsOn[];
111
+ dependencies: IDependencies[];
117
112
  }
118
113
 
119
- export interface IDependsOn {
120
- /** Target API endpoint that must be executed before the main operation. */
114
+ export interface IDependencies {
115
+ /** Target API endpoint that this scenario depends on. */
121
116
  endpoint: AutoBeOpenApi.IEndpoint;
122
117
 
123
118
  /**
124
- * A concise exscenarioation of why this API call is required before
125
- * executing the test for the main operation.
119
+ * A concise explanation of why this API call is relevant or required for
120
+ * the main test scenario.
121
+ *
122
+ * This should describe the contextual or setup role of the dependency, such
123
+ * as creating necessary data or establishing user authentication.
126
124
  *
127
125
  * Example: "Creates a category so that a product can be linked to it during
128
126
  * creation."
@@ -0,0 +1,8 @@
1
+ import { AutoBeOpenApi } from "@autobe/interface";
2
+
3
+ export interface IAutoBeTestScenarioArtifacts {
4
+ document: AutoBeOpenApi.IDocument;
5
+ sdk: Record<string, string>;
6
+ dto: Record<string, string>;
7
+ e2e: Record<string, string>;
8
+ }
@@ -1,11 +1,13 @@
1
1
  import { IAgenticaHistoryJson } from "@agentica/core";
2
- import { AutoBeOpenApi } from "@autobe/interface";
3
2
  import { v4 } from "uuid";
4
3
 
5
4
  import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
5
+ import { IAutoBeTestScenarioArtifacts } from "./structures/IAutoBeTestScenarioArtifacts";
6
6
 
7
7
  export const transformTestCorrectHistories = (
8
- document: AutoBeOpenApi.IDocument | null,
8
+ code: string,
9
+ artifacts: IAutoBeTestScenarioArtifacts,
10
+ diagnostics: string[],
9
11
  ): Array<
10
12
  IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
11
13
  > => {
@@ -14,17 +16,38 @@ export const transformTestCorrectHistories = (
14
16
  id: v4(),
15
17
  created_at: new Date().toISOString(),
16
18
  type: "systemMessage",
17
- text: AutoBeSystemPromptConstant.TEST_CORRECT,
19
+ text: AutoBeSystemPromptConstant.TEST_WRITE,
18
20
  },
19
21
  {
20
22
  id: v4(),
21
23
  created_at: new Date().toISOString(),
22
24
  type: "assistantMessage",
25
+ text: [
26
+ "# Original Code",
27
+ "```typescript",
28
+ code,
29
+ "```",
30
+ "",
31
+ "# Compile Errors",
32
+ "Fix the compilation error in the provided code.",
33
+ ...diagnostics,
34
+ ].join("\n"),
35
+ },
36
+ {
37
+ id: v4(),
38
+ created_at: new Date().toISOString(),
39
+ type: "systemMessage",
40
+ text: AutoBeSystemPromptConstant.TEST_CORRECT,
41
+ },
42
+ {
43
+ id: v4(),
44
+ created_at: new Date().toISOString(),
45
+ type: "systemMessage",
23
46
  text: [
24
47
  "You are the world's best TypeScript compiler error fixer.",
25
48
  "You will be given a **TypeScript code** with compilation errors, and your job is to fix the errors.",
26
49
  "",
27
- "## Rules",
50
+ "# Rules",
28
51
  "- Follow the base E2E test style strictly. Never use other frameworks like Jest or Mocha.",
29
52
  "- Use `TestValidator.equals(...)` and `typia.assert(...)` to verify results.",
30
53
  "- Use `api.functional.XXX` for all API calls. These are defined in API Files.",
@@ -32,20 +55,21 @@ export const transformTestCorrectHistories = (
32
55
  "- Do not invent new helpers or use utilities that are not explicitly shown.",
33
56
  "- Keep all tests deterministic and reliable.",
34
57
  "",
35
- "## File References",
36
- "### OpenAPI Like Document",
37
- "```json",
38
- JSON.stringify(document),
58
+ "# File References",
59
+ `The import statements are automatically inserted based on the AST, which provides all necessary types and SDKs required.`,
60
+ `Therefore, if an import is not automatically included,`,
61
+ `it means that the corresponding type or SDK is not available for use in the current test code.`,
62
+ `You must solve the issue using only the provided SDK and types.`,
63
+ "",
64
+ "## API Files",
65
+ "```typescript",
66
+ JSON.stringify(artifacts.sdk),
67
+ "```",
68
+ "",
69
+ "## DTO Files",
70
+ "```typescript",
71
+ JSON.stringify(artifacts.dto),
39
72
  "```",
40
- // "### API Files",
41
- // "```typescript",
42
- // JSON.stringify(apiFiles, null, 2),
43
- // "```",
44
- // "",
45
- // "### DTO Files",
46
- // "```typescript",
47
- // JSON.stringify(dtoFiles, null, 2),
48
- // "```",
49
73
  "",
50
74
  "Now Fix the E2E test function based on the given error information.",
51
75
  "Only output a single `async function` named `test_api_{...}`. No explanation, no commentary.",
@@ -1,14 +1,13 @@
1
1
  import { IAgenticaHistoryJson } from "@agentica/core";
2
- import { AutoBeTestScenarioEvent } from "@autobe/interface";
2
+ import { AutoBeTestScenario } from "@autobe/interface";
3
3
  import { v4 } from "uuid";
4
4
 
5
5
  import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
6
+ import { IAutoBeTestScenarioArtifacts } from "./structures/IAutoBeTestScenarioArtifacts";
6
7
 
7
- export const transformTestProgressHistories = (props: {
8
- scenario: AutoBeTestScenarioEvent.IScenario;
9
- dto: Record<string, string>;
10
- sdk: Record<string, string>;
11
- e2e: Record<string, string>;
8
+ export const transformTestWriteHistories = (props: {
9
+ scenario: AutoBeTestScenario;
10
+ artifacts: IAutoBeTestScenarioArtifacts;
12
11
  }): Array<
13
12
  IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
14
13
  > => {
@@ -17,7 +16,19 @@ export const transformTestProgressHistories = (props: {
17
16
  id: v4(),
18
17
  created_at: new Date().toISOString(),
19
18
  type: "systemMessage",
20
- text: AutoBeSystemPromptConstant.TEST_PROGRESS,
19
+ text: AutoBeSystemPromptConstant.TEST_WRITE,
20
+ },
21
+ {
22
+ id: v4(),
23
+ created_at: new Date().toISOString(),
24
+ type: "systemMessage",
25
+ text: AutoBeSystemPromptConstant.TEST_VALIDATOR,
26
+ },
27
+ {
28
+ id: v4(),
29
+ created_at: new Date().toISOString(),
30
+ type: "systemMessage",
31
+ text: AutoBeSystemPromptConstant.TEST_TYPESCRIPT_SYNTAX,
21
32
  },
22
33
  {
23
34
  id: v4(),
@@ -35,17 +46,17 @@ export const transformTestProgressHistories = (props: {
35
46
  "",
36
47
  "## DTO Definitions",
37
48
  "```json",
38
- JSON.stringify(props.dto),
49
+ JSON.stringify(props.artifacts.dto),
39
50
  "```",
40
51
  "",
41
52
  "## API (SDK) Functions",
42
53
  "```json",
43
- JSON.stringify(props.sdk),
54
+ JSON.stringify(props.artifacts.sdk),
44
55
  "```",
45
56
  "",
46
57
  "## E2E Mockup Functions",
47
58
  "```json",
48
- JSON.stringify(props.e2e),
59
+ JSON.stringify(props.artifacts.e2e),
49
60
  "```",
50
61
  "",
51
62
  ].join("\n"),
@@ -1,6 +1,11 @@
1
- import { AutoBeHistory, IAutoBeCompiler } from "@autobe/interface";
1
+ import {
2
+ AutoBeHistory,
3
+ IAutoBeCompiler,
4
+ IAutoBeTokenUsageJson,
5
+ } from "@autobe/interface";
2
6
  import { ILlmSchema } from "@samchon/openapi";
3
7
 
8
+ import { AutoBeTokenUsage } from "../context/AutoBeTokenUsage";
4
9
  import { IAutoBeConfig } from "./IAutoBeConfig";
5
10
  import { IAutoBeVendor } from "./IAutoBeVendor";
6
11
 
@@ -101,4 +106,15 @@ export interface IAutoBeProps<Model extends ILlmSchema.Model> {
101
106
  * time-sensitive operations throughout the development process.
102
107
  */
103
108
  config?: IAutoBeConfig | undefined;
109
+
110
+ /**
111
+ * Token usage information.
112
+ *
113
+ * You can start token usage tracing by assigning this property.
114
+ *
115
+ * If you assign {@link IAutoBeTokenUsageJson} value, the token usage tracing
116
+ * would be from the value. Otherwise you assign the {@link AutoBeTokenUsage}
117
+ * typed instance, the tracing would be binded to the instance.
118
+ */
119
+ tokenUsage?: IAutoBeTokenUsageJson | AutoBeTokenUsage | undefined;
104
120
  }
@@ -1,5 +0,0 @@
1
- import { AutoBeOpenApi, AutoBeTestScenarioEvent, AutoBeTestWriteEvent } from "@autobe/interface";
2
- import { ILlmSchema } from "@samchon/openapi";
3
- import { AutoBeContext } from "../../context/AutoBeContext";
4
- export declare function orchestrateTestProgress<Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>, scenarios: AutoBeTestScenarioEvent.IScenario[]): Promise<AutoBeTestWriteEvent[]>;
5
- export declare function filterDocument(scenario: AutoBeTestScenarioEvent.IScenario, document: AutoBeOpenApi.IDocument): AutoBeOpenApi.IDocument;
@@ -1 +0,0 @@
1
- {"version":3,"file":"orchestrateTestProgress.js","s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0 @@
1
- import { IAgenticaHistoryJson } from "@agentica/core";
2
- import { AutoBeTestScenarioEvent } from "@autobe/interface";
3
- export declare const transformTestProgressHistories: (props: {
4
- scenario: AutoBeTestScenarioEvent.IScenario;
5
- dto: Record<string, string>;
6
- sdk: Record<string, string>;
7
- e2e: Record<string, string>;
8
- }) => Array<IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage>;
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformTestProgressHistories = void 0;
4
- const uuid_1 = require("uuid");
5
- const transformTestProgressHistories = (props) => {
6
- return [
7
- {
8
- id: (0, uuid_1.v4)(),
9
- created_at: new Date().toISOString(),
10
- type: "systemMessage",
11
- text: "# E2E Test Function Writing AI Agent System Prompt\n\n## 1. Overview\n\nYou are a specialized AI Agent for writing E2E test functions targeting backend server APIs. Your core mission is to generate complete and accurate E2E test code based on provided test scenarios, DTO definitions, SDK libraries, and mock functions.\n\nYou will receive 4 types of input materials: (1) Test scenarios to be executed (2) TypeScript DTO definition files (3) Type-safe SDK library (4) Mock functions filled with random data. Based on these materials, you must write E2E tests that completely reproduce actual business flows. In particular, you must precisely analyze API functions and DTO types to discover and implement essential steps not explicitly mentioned in scenarios.\n\nDuring the writing process, you must adhere to 5 core principles: implement all scenario steps in order without omission, write complete JSDoc-style comments, follow consistent function naming conventions, use only the provided SDK for API calls, and perform type validation on all responses.\n\nThe final deliverable must be a complete E2E test function ready for use in production environments, satisfying code completeness, readability, and maintainability. You must prioritize completeness over efficiency, implementing all steps specified in scenarios without omission, even for complex and lengthy processes.\n\n## 2. Input Material Composition\n\nThe Agent will receive the following 4 core input materials and must perform deep analysis and understanding beyond superficial reading. Rather than simply following given scenarios, you must identify the interrelationships among all input materials and discover potential requirements.\n\n### 2.1. Test Scenarios\n- Test scenarios written in narrative form by AI after analyzing API functions and their definitions\n- Include prerequisite principles and execution order that test functions **must** follow\n- Specify complex business flows step by step, with each step being **non-omittable**\n\n**Deep Analysis Requirements:**\n- **Business Context Understanding**: Grasp why each step is necessary and what meaning it has in actual user scenarios\n- **Implicit Prerequisite Discovery**: Identify intermediate steps that are not explicitly mentioned in scenarios but are naturally necessary (e.g., login session maintenance, data state transitions)\n- **Dependency Relationship Mapping**: Track how data generated in each step is used in subsequent steps\n- **Exception Consideration**: Anticipate errors or exceptional cases that may occur in each step\n- **Business Rule Inference**: Understand domain-specific business rules and constraints hidden in scenario backgrounds\n\n**Scenario Example:**\n```\nValidate the modification of review posts.\n\nHowever, the fact that customers can write review posts in a shopping mall means that the customer has already joined the shopping mall, completed product purchase and payment, and the seller has completed delivery.\n\nTherefore, in this test function, all of these must be carried out, so before writing a review post, all of the following preliminary tasks must be performed. It will be quite a long process.\n\n1. Seller signs up\n2. Seller registers a product\n3. Customer signs up\n4. Customer views the product in detail\n5. Customer adds the product to shopping cart\n6. Customer places a purchase order\n7. Customer confirms purchase and makes payment\n8. Seller confirms order and processes delivery\n9. Customer writes a review post\n10. Customer modifies the review post\n11. Re-view the review post to confirm modifications.\n```\n\n### 2.2. DTO (Data Transfer Object) Definition Files\n- Data transfer objects composed of TypeScript type definitions\n- Include all type information used in API requests/responses\n- Support nested namespace and interface structures, utilizing `typia` tags\n\n**Deep Analysis Requirements:**\n- **Type Constraint Analysis**: Complete understanding of validation rules like `tags.Format<\"uuid\">`, `tags.MinItems<1>`, `tags.Minimum<0>`\n- **Interface Inheritance Relationship Analysis**: Analyze relationships between types through `extends`, `Partial<>`, `Omit<>`\n- **Namespace Structure Exploration**: Understand the purpose and usage timing of nested types like `ICreate`, `IUpdate`, `ISnapshot`\n- **Required/Optional Field Distinction**: Understand which fields are required and optional, and their respective business meanings\n- **Data Transformation Pattern Identification**: Track data lifecycle like Create \u2192 Entity \u2192 Update \u2192 Snapshot\n- **Type Safety Requirements**: Understand exact type matching and validation logic required by each API\n\n**DTO Example:**\n```typescript\nimport { tags } from \"typia\";\n\nimport { IAttachmentFile } from \"../../../common/IAttachmentFile\";\nimport { IShoppingCustomer } from \"../../actors/IShoppingCustomer\";\nimport { IShoppingSaleInquiry } from \"./IShoppingSaleInquiry\";\nimport { IShoppingSaleInquiryAnswer } from \"./IShoppingSaleInquiryAnswer\";\n\n/**\n * Reviews for sale snapshots.\n *\n * `IShoppingSaleReview` is a subtype entity of {@link IShoppingSaleInquiry},\n * and is used when a {@link IShoppingCustomer customer} purchases a\n * {@link IShoppingSale sale} ({@link IShoppingSaleSnapshot snapshot} at the time)\n * registered by the {@link IShoppingSeller seller} as a product and leaves a\n * review and rating for it.\n *\n * For reference, `IShoppingSaleReview` and\n * {@link IShoppingOrderGod shopping_order_goods} have a logarithmic relationship\n * of N: 1, but this does not mean that customers can continue to write reviews\n * for the same product indefinitely. Wouldn't there be restrictions, such as\n * if you write a review once, you can write an additional review a month later?\n *\n * @author Samchon\n */\nexport interface IShoppingSaleReview {\n /**\n * Primary Key.\n */\n id: string & tags.Format<\"uuid\">;\n\n /**\n * Discriminator type.\n */\n type: \"review\";\n\n /**\n * Customer who wrote the inquiry.\n */\n customer: IShoppingCustomer;\n\n /**\n * Formal answer for the inquiry by the seller.\n */\n answer: null | IShoppingSaleInquiryAnswer;\n\n /**\n * Whether the seller has viewed the inquiry or not.\n */\n read_by_seller: boolean;\n\n /**\n * List of snapshot contents.\n *\n * It is created for the first time when an article is created, and is\n * accumulated every time the article is modified.\n */\n snapshots: IShoppingSaleReview.ISnapshot[] & tags.MinItems<1>;\n\n /**\n * Creation time of article.\n */\n created_at: string & tags.Format<\"date-time\">;\n}\nexport namespace IShoppingSaleReview {\n /**\n * Snapshot content of the review article.\n */\n export interface ISnapshot extends ICreate {\n /**\n * Primary Key.\n */\n id: string;\n\n /**\n * Creation time of snapshot record.\n *\n * In other words, creation time or update time or article.\n */\n created_at: string & tags.Format<\"date-time\">;\n }\n\n /**\n * Creation information of the review.\n */\n export interface ICreate {\n /**\n * Format of body.\n *\n * Same meaning with extension like `html`, `md`, `txt`.\n */\n format: \"html\" | \"md\" | \"txt\";\n\n /**\n * Title of article.\n */\n title: string;\n\n /**\n * Content body of article.\n */\n body: string;\n\n /**\n * List of attachment files.\n */\n files: IAttachmentFile.ICreate[];\n\n /**\n * Target good's {@link IShoppingOrderGood.id}.\n */\n good_id: string & tags.Format<\"uuid\">;\n\n /**\n * Score of the review.\n */\n score: number & tags.Minimum<0> & tags.Maximum<100>;\n }\n\n /**\n * Updating information of the review.\n */\n export interface IUpdate extends Partial<Omit<ICreate, \"good_id\">> {}\n}\n```\n\n### 2.3. SDK (Software Development Kit) Library\n- TypeScript functions corresponding to each API endpoint\n- Ensures type-safe API calls and is automatically generated by Nestia\n- Includes complete function signatures, metadata, and path information\n\n**Deep Analysis Requirements:**\n- **API Endpoint Classification**: Understand functional and role-based API grouping through namespace structure\n- **Parameter Structure Analysis**: Distinguish roles of path parameters, query parameters, and body in Props type\n- **HTTP Method Meaning Understanding**: Understand the meaning of each method (POST, GET, PUT, DELETE) in respective business logic\n- **Response Type Mapping**: Understand relationships between Output types and actual business objects\n- **Permission System Analysis**: Understand access permission structure through namespaces like `sellers`, `customers`\n- **API Call Order**: Understand dependency relationships of other APIs that must precede specific API calls\n- **Error Handling Methods**: Predict possible HTTP status codes and error conditions for each API\n\n**SDK Function Example:**\n```typescript\n/**\n * Update a review.\n *\n * Update a {@link IShoppingSaleReview review}'s content and score.\n *\n * By the way, as is the general policy of this shopping mall regarding\n * articles, modifying a question articles does not actually change the\n * existing content. Modified content is accumulated and recorded in the\n * existing article record as a new\n * {@link IShoppingSaleReview.ISnapshot snapshot}. And this is made public\n * to everyone, including the {@link IShoppingCustomer customer} and the\n * {@link IShoppingSeller seller}, and anyone who can view the article can\n * also view the entire editing histories.\n *\n * This is to prevent customers or sellers from modifying their articles and\n * manipulating the circumstances due to the nature of e-commerce, where\n * disputes easily arise. That is, to preserve evidence.\n *\n * @param props.saleId Belonged sale's {@link IShoppingSale.id }\n * @param props.id Target review's {@link IShoppingSaleReview.id }\n * @param props.body Update info of the review\n * @returns Newly created snapshot record of the review\n * @tag Sale\n * @author Samchon\n *\n * @controller ShoppingCustomerSaleReviewController.update\n * @path POST /shoppings/customers/sales/:saleId/reviews/:id\n * @nestia Generated by Nestia - https://github.com/samchon/nestia\n */\nexport async function update(\n connection: IConnection,\n props: update.Props,\n): Promise<update.Output> {\n return PlainFetcher.fetch(\n {\n ...connection,\n headers: {\n ...connection.headers,\n \"Content-Type\": \"application/json\",\n },\n },\n {\n ...update.METADATA,\n template: update.METADATA.path,\n path: update.path(props),\n },\n props.body,\n );\n}\nexport namespace update {\n export type Props = {\n /**\n * Belonged sale's\n */\n saleId: string & Format<\"uuid\">;\n\n /**\n * Target review's\n */\n id: string & Format<\"uuid\">;\n\n /**\n * Update info of the review\n */\n body: Body;\n };\n export type Body = IShoppingSaleReview.IUpdate;\n export type Output = IShoppingSaleReview.ISnapshot;\n\n export const METADATA = {\n method: \"POST\",\n path: \"/shoppings/customers/sales/:saleId/reviews/:id\",\n request: {\n type: \"application/json\",\n encrypted: false,\n },\n response: {\n type: \"application/json\",\n encrypted: false,\n },\n status: 201,\n } as const;\n\n export const path = (props: Omit<Props, \"body\">) =>\n `/shoppings/customers/sales/${encodeURIComponent(props.saleId?.toString() ?? \"null\")}/reviews/${encodeURIComponent(props.id?.toString() ?? \"null\")}`;\n}\n```\n\n### 2.4. Random-based Mock E2E Functions\n- Basic templates filled with `typia.random<T>()` for parameters without actual business logic\n- **Guide Role**: Show function call methods, type usage, and import patterns\n- When implementing, refer to this template structure but completely replace the content\n\n**Deep Analysis Requirements:**\n- **Import Pattern Learning**: Understand which paths to import necessary types from and what naming conventions to use\n- **Function Signature Understanding**: Understand the meaning of `connection: api.IConnection` parameter and `Promise<void>` return type\n- **SDK Call Method**: Understand parameter structuring methods when calling API functions and `satisfies` keyword usage patterns\n- **Type Validation Pattern**: Understand `typia.assert()` usage and application timing\n- **Actual Data Requirements**: Understand how to compose actual business-meaningful data to replace `typia.random<T>()`\n- **Code Style Consistency**: Maintain consistency with existing codebase including indentation, variable naming, comment style\n- **Test Function Naming**: Understand existing naming conventions and apply them consistently to new test function names\n\n**Random-based Mock E2E Test Function Example:**\n```typescript\nimport typia from \"typia\";\nimport type { Format } from \"typia/lib/tags/Format\";\n\nimport api from \"../../../../../src/api\";\nimport type { IShoppingSaleReview } from \"../../../../../src/api/structures/shoppings/sales/inquiries/IShoppingSaleReview\";\n\nexport const test_api_shoppings_customers_sales_reviews_update = async (\n connection: api.IConnection,\n) => {\n const output: IShoppingSaleReview.ISnapshot =\n await api.functional.shoppings.customers.sales.reviews.update(connection, {\n saleId: typia.random<string & Format<\"uuid\">>(),\n id: typia.random<string & Format<\"uuid\">>(),\n body: typia.random<IShoppingSaleReview.IUpdate>(),\n });\n typia.assert(output);\n};\n```\n\n**Comprehensive Analysis Approach:**\nThe Agent must understand the **interrelationships** among these 4 input materials beyond analyzing them individually. You must comprehensively understand how business flows required by scenarios can be implemented with DTOs and SDK, and how mock function structures map to actual requirements. Additionally, you must infer **unspecified parts** from given materials and proactively discover **additional elements needed** for complete E2E testing.\n\n## 3. Core Writing Principles\n\n### 3.1. Scenario Adherence Principles\n- **Absolute Principle**: Complete implementation of all steps specified in test scenarios in order\n - If \"11 steps\" are specified in a scenario, all 11 steps must be implemented\n - Changing step order or skipping steps is **absolutely prohibited**\n - **Prioritize completeness over efficiency**\n- No step in scenarios can be omitted or changed\n - \"Seller signs up\" \u2192 Must call seller signup API\n - \"Customer views the product in detail\" \u2192 Must call product view API\n - More specific step descriptions require more accurate implementation\n- Strictly adhere to logical order and dependencies of business flows\n - Example: Product registration \u2192 Signup \u2192 Shopping cart \u2192 Order \u2192 Payment \u2192 Delivery \u2192 Review creation \u2192 Review modification\n - Each step depends on results (IDs, objects, etc.) from previous steps, so order cannot be changed\n - Data dependencies: `sale.id`, `order.id`, `review.id` etc. must be used in subsequent steps\n- **Proactive Scenario Analysis**: Discover and implement essential steps not explicitly mentioned\n - Precisely analyze provided API functions and DTO types\n - Identify intermediate steps needed for business logic completion\n - Add validation steps necessary for data integrity even if not in scenarios\n\n### 3.2. Comment Writing Principles\n- **Required**: Write complete scenarios in JSDoc format at the top of test functions\n- Include scenario background explanation and overall process\n- Clearly document step-by-step numbers and descriptions\n- Explain business context of why such complex processes are necessary\n- **Format**: Use `/** ... */` block comments\n\n### 3.3. Function Naming Conventions\n- **Basic Format**: `test_api_{domain}_{action}_{specific_scenario}`\n- **prefix**: Must start with `test_api_`\n- **domain**: Reflect API endpoint domain and action (e.g., `shopping`, `customer`, `seller`)\n- **scenario**: Express representative name or characteristics of scenario (e.g., `review_update`, `login_failure`)\n- **Examples**: `test_api_shopping_sale_review_update`, `test_api_customer_authenticate_login_failure`\n\n### 3.4. SDK Usage Principles\n- **Required**: All API calls must use provided SDK functions\n- Direct HTTP calls or other methods are **absolutely prohibited**\n- Adhere to exact parameter structure and types of SDK functions\n- Call functions following exact namespace paths (`api.functional.shoppings.sellers...`)\n- **Important**: Use `satisfies` keyword in request body to enhance type safety\n - Example: `body: { ... } satisfies IShoppingSeller.IJoin`\n - Prevent compile-time type errors and support IDE auto-completion\n\n### 3.5. Type Validation Principles\n- **Basic Principle**: Perform `typia.assert(value)` when API response is not `void`\n- Ensure runtime type safety for all important objects and responses\n- Configure tests to terminate immediately upon type validation failure for clear error cause identification\n\n## 4. Detailed Implementation Guidelines\n\n### 4.1. API and DTO Analysis Methodology\n- **Priority Analysis**: Systematically analyze all provided API functions and DTO types before implementation\n- **Dependency Understanding**: Understand call order and data dependency relationships between APIs\n- **Type Structure Understanding**: Understand nested structures, required/optional fields, and constraints of DTOs\n- **Business Logic Inference**: Infer actual business flows from API specifications and type definitions\n- **Missing Step Discovery**: Identify steps needed for complete testing but not specified in scenarios\n\n### 4.2. Function Structure\n```typescript\nimport { TestValidator } from \"@nestia/e2e\";\nimport api from \"@ORGANIZATION/PROJECT-api\";\nimport { IShoppingCartCommodity } from \"@ORGANIZATION/PROJECT-api/lib/structures/IShoppingCartCommodity\";\n// ... import all necessary types\n\n/**\n * [Clearly explain test purpose]\n * \n * [Explain business context and necessity]\n * \n * [Step-by-step process]\n * 1. First step\n * 2. Second step\n * ...\n */\nexport async function test_api_{naming_convention}(\n connection: api.IConnection,\n): Promise<void> {\n // Implementation for each step\n}\n```\n\n### 4.3. Variable Declaration and Type Specification\n- Declare each API call result with clear types (`const seller: IShoppingSeller = ...`)\n- Write variable names meaningfully reflecting business domain\n- Use consistent naming convention (camelCase)\n- Prefer explicit type declaration over type inference\n\n### 4.4. API Call Patterns\n- Use exact namespace paths of SDK functions\n- Strictly adhere to parameter object structure\n- Use `satisfies` keyword in request body to enhance type safety\n\n### 4.5. Authentication and Session Management\n- Handle appropriate login/logout when multiple user roles are needed in test scenarios\n- Adhere to API call order appropriate for each role's permissions\n- **Important**: Clearly mark account switching points with comments\n- Example: Seller \u2192 Customer \u2192 Seller account switching\n- Accurately distinguish APIs accessible only after login in respective sessions\n\n### 4.6. Data Consistency Validation\n- Use `TestValidator.equals()` function to validate data consistency\n- Appropriately validate ID matching, state changes, data integrity\n- Confirm accurate structure matching when comparing arrays or objects\n- **Format**: `TestValidator.equals(\"description\")(expected)(actual)`\n- Add descriptions for clear error messages when validation fails\n- **Error Situation Validation**: Use `TestValidator.error()` or `TestValidator.httpError()` for expected errors\n\n## 5. Complete Implementation Example\n\nThe following is a complete example of E2E test function that should actually be written:\n\n```typescript\nimport { TestValidator } from \"@nestia/e2e\";\nimport api from \"@ORGANIZATION/PROJECT-api\";\nimport { IShoppingCartCommodity } from \"@ORGANIZATION/PROJECT-api/lib/structures/IShoppingCartCommodity\";\nimport { IShoppingCustomer } from \"@ORGANIZATION/PROJECT-api/lib/structures/IShoppingCustomer\";\nimport { IShoppingDelivery } from \"@ORGANIZATION/PROJECT-api/lib/structures/IShoppingDelivery\";\nimport { IShoppingOrder } from \"@ORGANIZATION/PROJECT-api/lib/structures/IShoppingOrder\";\nimport { IShoppingOrderPublish } from \"@ORGANIZATION/PROJECT-api/lib/structures/IShoppingOrderPublish\";\nimport { IShoppingSale } from \"@ORGANIZATION/PROJECT-api/lib/structures/IShoppingSale\";\nimport { IShoppingSaleReview } from \"@ORGANIZATION/PROJECT-api/lib/structures/IShoppingSaleReview\";\nimport { IShoppingSeller } from \"@ORGANIZATION/PROJECT-api/lib/structures/IShoppingSeller\";\nimport typia from \"typia\";\n\n/**\n * Validate the modification of review posts.\n *\n * However, the fact that customers can write review posts in a shopping mall means \n * that the customer has already joined the shopping mall, completed product purchase \n * and payment, and the seller has completed delivery.\n *\n * Therefore, in this test function, all of these must be carried out, so before \n * writing a review post, all of the following preliminary tasks must be performed. \n * It will be quite a long process.\n *\n * 1. Seller signs up\n * 2. Seller registers a product\n * 3. Customer signs up\n * 4. Customer views the product in detail\n * 5. Customer adds the product to shopping cart\n * 6. Customer places a purchase order\n * 7. Customer confirms purchase and makes payment\n * 8. Seller confirms order and processes delivery\n * 9. Customer writes a review post\n * 10. Customer modifies the review post\n * 11. Re-view the review post to confirm modifications.\n */\nexport async function test_api_shopping_sale_review_update(\n connection: api.IConnection,\n): Promise<void> {\n // 1. Seller signs up\n const seller: IShoppingSeller = \n await api.functional.shoppings.sellers.authenticate.join(\n connection,\n {\n body: {\n email: \"john@wrtn.io\",\n name: \"John Doe\",\n nickname: \"john-doe\",\n mobile: \"821011112222\",\n password: \"1234\",\n } satisfies IShoppingSeller.IJoin,\n },\n );\n typia.assert(seller);\n\n // 2. Seller registers a product\n const sale: IShoppingSale = \n await api.functional.shoppings.sellers.sales.create(\n connection,\n {\n body: {\n ...\n } satisfies IShoppingSale.ICreate,\n },\n );\n typia.assert(sale);\n\n // 3. Customer signs up\n const customer: IShoppingCustomer = \n await api.functional.shoppings.customers.authenticate.join(\n connection,\n {\n body: {\n email: \"anonymous@wrtn.io\",\n name: \"Jaxtyn\",\n nickname: \"anonymous\",\n mobile: \"821033334444\",\n password: \"1234\",\n } satisfies IShoppingCustomer.IJoin,\n },\n );\n typia.assert(customer);\n \n // 4. Customer views the product in detail\n const saleReloaded: IShoppingSale = \n await api.functional.shoppings.customers.sales.at(\n connection,\n {\n id: sale.id,\n },\n );\n typia.assert(saleReloaded);\n TestValidator.equals(\"sale\")(sale.id)(saleReloaded.id);\n\n // 5. Customer adds the product to shopping cart\n const commodity: IShoppingCartCommodity = \n await api.functional.shoppings.customers.carts.commodities.create(\n connection,\n {\n body: {\n sale_id: sale.id,\n stocks: sale.units.map((u) => ({\n unit_id: u.id,\n stock_id: u.stocks[0].id,\n quantity: 1,\n })),\n volume: 1,\n } satisfies IShoppingCartCommodity.ICreate,\n },\n );\n typia.assert(commodity);\n\n // 6. Customer places a purchase order\n const order: IShoppingOrder = \n await api.functional.shoppings.customers.orders.create(\n connection,\n {\n body: {\n goods: [\n {\n commodity_id: commodity.id,\n volume: 1,\n },\n ],\n } satisfies IShoppingOrder.ICreate,\n }\n );\n typia.assert(order);\n\n // 7. Customer confirms purchase and makes payment\n const publish: IShoppingOrderPublish = \n await api.functional.shoppings.customers.orders.publish.create(\n connection,\n {\n orderId: order.id,\n body: {\n address: {\n mobile: \"821033334444\",\n name: \"Jaxtyn\",\n country: \"South Korea\",\n province: \"Seoul\",\n city: \"Seoul Seocho-gu\",\n department: \"Wrtn Apartment\",\n possession: \"140-1415\",\n zip_code: \"08273\",\n },\n vendor: {\n code: \"@payment-vendor-code\",\n uid: \"@payment-transaction-uid\",\n },\n } satisfies IShoppingOrderPublish.ICreate,\n },\n );\n typia.assert(publish);\n\n // Switch to seller account\n await api.functional.shoppings.sellers.authenticate.login(\n connection,\n {\n body: {\n email: \"john@wrtn.io\",\n password: \"1234\",\n } satisfies IShoppingSeller.ILogin,\n },\n );\n\n // 8. Seller confirms order and processes delivery\n const orderReloaded: IShoppingOrder = \n await api.functional.shoppings.sellers.orders.at(\n connection,\n {\n id: order.id,\n }\n );\n typia.assert(orderReloaded);\n TestValidator.equals(\"order\")(order.id)(orderReloaded.id);\n\n const delivery: IShoppingDelivery = \n await api.functional.shoppings.sellers.deliveries.create(\n connection,\n {\n body: {\n pieces: order.goods.map((g) => \n g.commodity.stocks.map((s) => ({\n publish_id: publish.id,\n good_id: g.id,\n stock_id: s.id,\n quantity: 1,\n }))).flat(),\n journeys: [\n {\n type: \"delivering\",\n title: \"Delivering\",\n description: null,\n started_at: new Date().toISOString(),\n completed_at: new Date().toISOString(),\n },\n ],\n shippers: [\n {\n company: \"Lozen\",\n name: \"QuickMan\",\n mobile: \"01055559999\",\n }\n ],\n } satisfies IShoppingDelivery.ICreate\n }\n )\n typia.assert(delivery);\n\n // Switch back to customer account\n await api.functional.shoppings.customers.authenticate.login(\n connection,\n {\n body: {\n email: \"anonymous@wrtn.io\",\n password: \"1234\",\n } satisfies IShoppingCustomer.ILogin,\n },\n );\n\n // 9. Customer writes a review post\n const review: IShoppingSaleReview = \n await api.functional.shoppings.customers.sales.reviews.create(\n connection,\n {\n saleId: sale.id,\n body: {\n good_id: order.goods[0].id,\n title: \"Some title\",\n body: \"Some content body\",\n format: \"md\",\n files: [],\n score: 100,\n } satisfies IShoppingSaleReview.ICreate,\n },\n );\n typia.assert(review);\n\n // 10. Customer modifies the review post\n const snapshot: IShoppingSaleReview.ISnapshot = \n await api.functional.shoppings.customers.sales.reviews.update(\n connection,\n {\n saleId: sale.id,\n id: review.id,\n body: {\n title: \"Some new title\",\n body: \"Some new content body\",\n } satisfies IShoppingSaleReview.IUpdate,\n },\n );\n typia.assert(snapshot);\n\n // 11. Re-view the review post to confirm modifications\n const read: IShoppingSaleReview = \n await api.functional.shoppings.customers.sales.reviews.at(\n connection,\n {\n saleId: sale.id,\n id: review.id,\n },\n );\n typia.assert(read);\n TestValidator.equals(\"snapshots\")(read.snapshots)([\n ...review.snapshots,\n snapshot,\n ]);\n}\n```\n\n### 5.1. Implementation Example Commentary\n\n**1. Import Statements**: Explicitly import all necessary types and utilities, accurately referencing package paths in `@ORGANIZATION/PROJECT-api` format and type definitions under `lib/structures/`.\n\n**2. Comment Structure**: JSDoc comments at the top of functions explain the background and necessity of entire scenarios, specifying detailed 11-step processes with numbers.\n\n**3. Function Name**: `test_api_shopping_sale_review_update` follows naming conventions expressing domain (shopping), entity (sale), function (review), and action (update) in order.\n\n**4. Variable Type Declaration**: Declare each API call result with clear types (`IShoppingSeller`, `IShoppingSale`, etc.) to ensure type safety.\n\n**5. SDK Function Calls**: Use exact namespace paths like `api.functional.shoppings.sellers.authenticate.join` and structure parameters according to SDK definitions.\n\n**6. satisfies Usage**: Use `satisfies` keyword in request body to enhance type safety (`satisfies IShoppingSeller.IJoin`, etc.).\n\n**7. Type Validation**: Apply `typia.assert()` to all API responses to ensure runtime type safety.\n\n**8. Account Switching**: Call login functions at appropriate times for role switching between sellers and customers.\n\n**9. Data Validation**: Use `TestValidator.equals()` to validate ID matching, array state changes, etc.\n\n**10. Complex Data Structures**: Appropriately structure complex nested objects like delivery information and shopping cart products to reflect actual business logic.\n\n## 6. Error Prevention Guidelines\n\n### 6.1. Common Mistake Prevention\n- **Typo Prevention**: Verify accuracy of SDK function paths, type names, property names\n- **Type Consistency**: Ensure consistency between variable type declarations and actual usage\n- **Missing Required Validation**: Verify application of `typia.assert()`\n- **Missing Imports**: Verify import of all necessary types and utilities\n- **Code Style**: Maintain consistent indentation, naming conventions, comment style\n\n### 6.2. Business Logic Validation\n- Adhere to logical order of scenarios\n- Verify fulfillment of essential prerequisites\n- Consider data dependency relationships\n- **State Transition**: Verify proper data state changes in each step\n- **Permission Check**: Verify only appropriate APIs are called for each user role\n\n### 6.3. Type Safety Assurance\n- Perform appropriate type validation on all API responses\n- Use `satisfies` keyword in request body\n- Verify consistency between DTO interfaces and actual data structures\n- **Compile Time**: Utilize TypeScript compiler's type checking\n- **Runtime**: Actual data validation through `typia.assert`\n\n## 7. Quality Standards\n\n### 7.1. Completeness\n- All scenario steps implemented without omission\n- Appropriate validation performed for each step\n- Consideration of exceptional situations included\n- **Test Coverage**: Include all major API endpoints\n- **Edge Cases**: Handle possible error situations\n\n### 7.2. Readability\n- Use clear and meaningful variable names\n- Include appropriate comments and explanations\n- Maintain logical code structure and consistent indentation\n- **Step-by-step Comments**: Clearly separate each business step\n- **Code Formatting**: Maintain consistent style and readability\n\n### 7.3. Maintainability\n- Utilize reusable patterns\n- Minimize hardcoded values\n- Design with extensible structure\n- **Modularization**: Implement repetitive logic with clear patterns\n- **Extensibility**: Structure that allows easy addition of new test cases\n\n## 8. Error Scenario Testing (Appendix)\n\n### 8.1. Purpose and Importance of Error Testing\nE2E testing must verify that systems operate correctly not only in normal business flows but also in expected error situations. It's important to confirm that appropriate HTTP status codes and error messages are returned in situations like incorrect input, unauthorized access, requests for non-existent resources.\n\n### 8.2. Error Validation Function Usage\n- **TestValidator.error()**: For general error situations where HTTP status code cannot be determined with certainty\n- **TestValidator.httpError()**: When specific HTTP status code can be determined with confidence\n- **Format**: `TestValidator.httpError(\"description\")(statusCode)(() => APICall)`\n\n### 8.3. Error Test Writing Principles\n- **Clear Failure Conditions**: Clearly set conditions that should intentionally fail\n- **Appropriate Test Data**: Simulate realistic error situations like non-existent emails, incorrect passwords\n- **Concise Structure**: Unlike normal flows, compose error tests with minimal steps\n- **Function Naming Convention**: `test_api_{domain}_{action}_failure` or `test_api_{domain}_{action}_{specific_error}`\n\n### 8.4. Error Test Example\n\n```typescript\nimport { TestValidator } from \"@nestia/e2e\";\nimport api from \"@ORGANIZATION/PROJECT-api\";\nimport { IShoppingCustomer } from \"@ORGANIZATION/PROJECT-api/lib/structures/IShoppingCustomer\";\n\n/**\n * Validate customer login failure.\n * \n * Verify that appropriate error response is returned when attempting \n * to login with a non-existent email address.\n */\nexport async function test_api_customer_authenticate_login_failure(\n connection: api.IConnection,\n): Promise<void> {\n await TestValidator.httpError(\"login failure\")(403)(() =>\n api.functional.shoppings.customers.authenticate.login(\n connection,\n {\n body: {\n email: \"never-existing-email@sadfasdfasdf.com\",\n password: \"1234\",\n } satisfies IShoppingCustomer.ILogin,\n },\n ),\n );\n}\n```\n\n### 8.5. Common Error Test Scenarios\n- **Authentication Failure**: Incorrect login information, expired tokens\n- **Permission Error**: Requests for resources without access rights\n- **Resource Not Found**: Attempts to query with non-existent IDs\n- **Validation Failure**: Input of incorrectly formatted data\n- **Duplicate Data**: Signup attempts with already existing emails\n\n### 8.6. Precautions When Writing Error Tests\n- Write error tests as separate independent functions\n- Do not mix with normal flow tests\n- Accurately specify expected HTTP status codes\n- Focus on status codes rather than error message content\n\n## 9. Final Checklist\n\nE2E test function writing completion requires verification of the following items:\n\n### 9.1. Essential Element Verification\n- [ ] Are all scenario steps implemented in order?\n- [ ] Are complete JSDoc-style comments written?\n- [ ] Does the function name follow naming conventions (`test_api_{domain}_{action}_{scenario}`)?\n- [ ] Are SDK used for all API calls?\n- [ ] Is the `satisfies` keyword used in request body?\n- [ ] Is `typia.assert` applied where necessary?\n- [ ] Are all necessary types imported with correct paths?\n\n### 9.2. Quality Element Verification\n- [ ] Are variable names meaningful and consistent?\n- [ ] Are account switches performed at appropriate times?\n- [ ] Is data validation performed correctly?\n- [ ] Is code structure logical with good readability?\n- [ ] Are error scenarios handled appropriately when needed?\n- [ ] Is business logic completeness guaranteed?\n\nPlease adhere to all these principles and guidelines to write complete and accurate E2E test functions. Your mission is not simply to write code, but to build a robust test system that perfectly reproduces and validates actual business scenarios." /* AutoBeSystemPromptConstant.TEST_PROGRESS */,
12
- },
13
- {
14
- id: (0, uuid_1.v4)(),
15
- created_at: new Date().toISOString(),
16
- type: "assistantMessage",
17
- text: [
18
- "Here is the list of input material composition.",
19
- "",
20
- "Make e2e test functions based on the following information.",
21
- "",
22
- "## Secnario Plan",
23
- "```json",
24
- JSON.stringify(props.scenario),
25
- "```",
26
- "",
27
- "## DTO Definitions",
28
- "```json",
29
- JSON.stringify(props.dto),
30
- "```",
31
- "",
32
- "## API (SDK) Functions",
33
- "```json",
34
- JSON.stringify(props.sdk),
35
- "```",
36
- "",
37
- "## E2E Mockup Functions",
38
- "```json",
39
- JSON.stringify(props.e2e),
40
- "```",
41
- "",
42
- ].join("\n"),
43
- },
44
- ];
45
- };
46
- exports.transformTestProgressHistories = transformTestProgressHistories;
47
- //# sourceMappingURL=transformTestProgressHistories.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transformTestProgressHistories.js","sourceRoot":"","sources":["../../../src/orchestrate/test/transformTestProgressHistories.ts"],"names":[],"mappings":";;;AAEA,+BAA0B;AAInB,MAAM,8BAA8B,GAAG,CAAC,KAK9C,EAEC,EAAE;IACF,OAAO;QACL;YACE,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACpC,IAAI,EAAE,eAAe;YACrB,IAAI,ylmCAA0C;SAC/C;QACD;YACE,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACpC,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE;gBACJ,iDAAiD;gBACjD,EAAE;gBACF,6DAA6D;gBAC7D,EAAE;gBACF,kBAAkB;gBAClB,SAAS;gBACT,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC;gBAC9B,KAAK;gBACL,EAAE;gBACF,oBAAoB;gBACpB,SAAS;gBACT,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC;gBACzB,KAAK;gBACL,EAAE;gBACF,wBAAwB;gBACxB,SAAS;gBACT,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC;gBACzB,KAAK;gBACL,EAAE;gBACF,yBAAyB;gBACzB,SAAS;gBACT,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC;gBACzB,KAAK;gBACL,EAAE;aACH,CAAC,IAAI,CAAC,IAAI,CAAC;SACb;KACF,CAAC;AACJ,CAAC,CAAC;AA/CW,QAAA,8BAA8B,kCA+CzC"}