@autobe/agent 0.24.0 → 0.24.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.
- package/lib/AutoBeMockAgent.js +1 -0
- package/lib/AutoBeMockAgent.js.map +1 -1
- package/lib/constants/AutoBeSystemPromptConstant.d.ts +4 -3
- package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
- package/lib/factory/createAutoBeContext.js +3 -3
- package/lib/factory/getAutoBeGenerated.js +4 -1
- package/lib/factory/getAutoBeGenerated.js.map +1 -1
- package/lib/factory/getAutoBeRealizeGenerated.d.ts +2 -1
- package/lib/factory/getAutoBeRealizeGenerated.js +1 -1
- package/lib/factory/getAutoBeRealizeGenerated.js.map +1 -1
- package/lib/factory/getCriticalCompiler.js +1 -1
- package/lib/factory/getCriticalCompiler.js.map +1 -1
- package/lib/index.mjs +1092 -139
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/interface/utils/JsonSchemaValidator.js +67 -8
- package/lib/orchestrate/interface/utils/JsonSchemaValidator.js.map +1 -1
- package/lib/orchestrate/interface/utils/OperationValidator.js +2 -1
- package/lib/orchestrate/interface/utils/OperationValidator.js.map +1 -1
- package/lib/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js +1 -1
- package/lib/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js.map +1 -1
- package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js +1 -1
- package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js.map +1 -1
- package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js +1 -1
- package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js.map +1 -1
- package/lib/orchestrate/realize/internal/compileRealizeFiles.js +3 -1
- package/lib/orchestrate/realize/internal/compileRealizeFiles.js.map +1 -1
- package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js +4 -1
- package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealize.js +15 -5
- package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js +3 -1
- package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeCorrect.js +4 -3
- package/lib/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
- package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.js +1 -0
- package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.js.map +1 -1
- package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.d.ts +5 -0
- package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js +113 -0
- package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js.map +1 -0
- package/lib/orchestrate/test/orchestrateTestScenario.js +8 -2
- package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestScenarioReview.d.ts +5 -0
- package/lib/orchestrate/test/orchestrateTestScenarioReview.js +847 -0
- package/lib/orchestrate/test/orchestrateTestScenarioReview.js.map +1 -0
- package/lib/orchestrate/test/structures/IAutoBeTestScenarioReviewApplication.d.ts +47 -0
- package/lib/orchestrate/test/structures/IAutoBeTestScenarioReviewApplication.js +3 -0
- package/lib/orchestrate/test/structures/IAutoBeTestScenarioReviewApplication.js.map +1 -0
- package/package.json +6 -6
- package/src/AutoBeMockAgent.ts +1 -0
- package/src/constants/AutoBeSystemPromptConstant.ts +4 -3
- package/src/factory/getAutoBeGenerated.ts +3 -0
- package/src/factory/getAutoBeRealizeGenerated.ts +3 -1
- package/src/factory/getCriticalCompiler.ts +2 -1
- package/src/orchestrate/interface/utils/JsonSchemaValidator.ts +68 -8
- package/src/orchestrate/interface/utils/OperationValidator.ts +2 -1
- package/src/orchestrate/realize/internal/compileRealizeFiles.ts +3 -1
- package/src/orchestrate/realize/orchestRateRealizeCorrectCasting.ts +4 -1
- package/src/orchestrate/realize/orchestrateRealize.ts +44 -37
- package/src/orchestrate/realize/orchestrateRealizeAuthorization.ts +5 -1
- package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +20 -14
- package/src/orchestrate/realize/utils/getRealizeWriteImportStatements.ts +1 -0
- package/src/orchestrate/test/histories/transformTestScenarioReviewHistories.ts +156 -0
- package/src/orchestrate/test/orchestrateTestScenario.ts +13 -3
- package/src/orchestrate/test/orchestrateTestScenarioReview.ts +185 -0
- package/src/orchestrate/test/structures/IAutoBeTestScenarioReviewApplication.ts +52 -0
|
@@ -15,22 +15,81 @@ var JsonSchemaValidator;
|
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
17
|
JsonSchemaValidator.validateKey = (props) => {
|
|
18
|
-
const
|
|
19
|
-
if (variable === false)
|
|
18
|
+
const elements = props.key.split(".");
|
|
19
|
+
if (elements.every(Escaper_1.Escaper.variable) === false)
|
|
20
20
|
props.errors.push({
|
|
21
21
|
path: `${props.path}[${JSON.stringify(props.key)}]`,
|
|
22
22
|
expected: "Valid variable name",
|
|
23
23
|
value: props.key,
|
|
24
24
|
description: utils_1.StringUtil.trim `
|
|
25
|
-
|
|
25
|
+
JSON schema type name must be a valid variable name.
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
Even though JSON schema type name allows dot(.) character, but
|
|
28
|
+
each segment separated by dot(.) must be a valid variable name.
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
Current key name ${JSON.stringify(props.key)} is not valid. Change
|
|
31
|
+
it to a valid variable name at the next time.
|
|
32
|
+
`,
|
|
33
33
|
});
|
|
34
|
+
if (props.key === "IPageIRequest")
|
|
35
|
+
props.errors.push({
|
|
36
|
+
path: `${props.path}[${JSON.stringify(props.key)}]`,
|
|
37
|
+
expected: `"IPageIRequest" is a mistake. Use "IPage.IRequest" instead.`,
|
|
38
|
+
value: props.key,
|
|
39
|
+
description: utils_1.StringUtil.trim `
|
|
40
|
+
You've taken a mistake that defines "IPageIRequest" as a type name.
|
|
41
|
+
However, as you've intended to define a pagination request type,
|
|
42
|
+
the correct type name is "IPage.IRequest" instead of "IPageIRequest".
|
|
43
|
+
|
|
44
|
+
Change it to "IPage.IRequest" at the next time.
|
|
45
|
+
`,
|
|
46
|
+
});
|
|
47
|
+
else if (props.key.startsWith("IPage") &&
|
|
48
|
+
props.key.startsWith("IPageI") === false) {
|
|
49
|
+
const expected = `IPage${props.key
|
|
50
|
+
.substring(5)
|
|
51
|
+
.split(".")
|
|
52
|
+
.map((s) => (s.startsWith("I") ? s : `I${s}`))
|
|
53
|
+
.join(".")}`;
|
|
54
|
+
props.errors.push({
|
|
55
|
+
path: `${props.path}[${JSON.stringify(props.key)}]`,
|
|
56
|
+
expected: `Interface name starting with 'I' even after 'IPage': ${JSON.stringify(expected)}`,
|
|
57
|
+
value: props.key,
|
|
58
|
+
description: utils_1.StringUtil.trim `
|
|
59
|
+
JSON schema type name must be an interface name starting with 'I'.
|
|
60
|
+
Even though JSON schema type name allows dot(.) character, but
|
|
61
|
+
each segment separated by dot(.) must be an interface name starting
|
|
62
|
+
with 'I'.
|
|
63
|
+
|
|
64
|
+
Even in the case of pagination response, after 'IPage' prefix,
|
|
65
|
+
the remaining part must be an interface name starting with 'I'.
|
|
66
|
+
|
|
67
|
+
Current key name ${JSON.stringify(props.key)} is not valid. Change
|
|
68
|
+
it to a valid interface name to be ${JSON.stringify(expected)},
|
|
69
|
+
or change it to another valid interface name at the next time.
|
|
70
|
+
`,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
else if (elements.some((s) => s.startsWith("I") === false) === true) {
|
|
74
|
+
const expected = elements
|
|
75
|
+
.map((s) => (s.startsWith("I") ? s : `I${s}`))
|
|
76
|
+
.join(".");
|
|
77
|
+
props.errors.push({
|
|
78
|
+
path: `${props.path}[${JSON.stringify(props.key)}]`,
|
|
79
|
+
expected: `Interface name starting with 'I': ${JSON.stringify(expected)}`,
|
|
80
|
+
value: props.key,
|
|
81
|
+
description: utils_1.StringUtil.trim `
|
|
82
|
+
JSON schema type name must be an interface name starting with 'I'.
|
|
83
|
+
Even though JSON schema type name allows dot(.) character, but
|
|
84
|
+
each segment separated by dot(.) must be an interface name starting
|
|
85
|
+
with 'I'.
|
|
86
|
+
|
|
87
|
+
Current key name ${JSON.stringify(props.key)} is not valid. Change
|
|
88
|
+
it to a valid interface name to be ${JSON.stringify(expected)},
|
|
89
|
+
or change it to another valid interface name at the next time.
|
|
90
|
+
`,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
34
93
|
};
|
|
35
94
|
const authorization = (props) => {
|
|
36
95
|
var _a, _b;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonSchemaValidator.js","sourceRoot":"","sources":["../../../../src/orchestrate/interface/utils/JsonSchemaValidator.ts"],"names":[],"mappings":";;;AACA,yCAAqE;AAErE,qDAAkD;AAElD,IAAiB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"JsonSchemaValidator.js","sourceRoot":"","sources":["../../../../src/orchestrate/interface/utils/JsonSchemaValidator.ts"],"names":[],"mappings":"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"}
|
|
@@ -40,12 +40,13 @@ var OperationValidator;
|
|
|
40
40
|
path: `${props.path}[${i}].requestBody.typeName`,
|
|
41
41
|
key: op.requestBody.typeName,
|
|
42
42
|
});
|
|
43
|
-
if (op.responseBody !== null)
|
|
43
|
+
if (op.responseBody !== null) {
|
|
44
44
|
JsonSchemaValidator_1.JsonSchemaValidator.validateKey({
|
|
45
45
|
errors: props.errors,
|
|
46
46
|
path: `${props.path}[${i}].responseBody.typeName`,
|
|
47
47
|
key: op.responseBody.typeName,
|
|
48
48
|
});
|
|
49
|
+
}
|
|
49
50
|
});
|
|
50
51
|
// validate duplicated endpoints
|
|
51
52
|
const endpoints = new tstl_1.HashMap(utils_1.AutoBeEndpointComparator.hashCode, utils_1.AutoBeEndpointComparator.equals);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperationValidator.js","sourceRoot":"","sources":["../../../../src/orchestrate/interface/utils/OperationValidator.ts"],"names":[],"mappings":";;;AACA,yCAAqE;AACrE,+BAA+B;AAE/B,qDAAkD;AAElD,0DAAuD;AACvD,+DAA4D;AAE5D,IAAiB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"OperationValidator.js","sourceRoot":"","sources":["../../../../src/orchestrate/interface/utils/OperationValidator.ts"],"names":[],"mappings":";;;AACA,yCAAqE;AACrE,+BAA+B;AAE/B,qDAAkD;AAElD,0DAAuD;AACvD,+DAA4D;AAE5D,IAAiB,kBAAkB,CAsHlC;AAtHD,WAAiB,kBAAkB;IAQpB,2BAAQ,GAAG,CAAC,KAAa,EAAQ,EAAE;QAC9C,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE;YACjC,8BAA8B;YAC9B,IAAI,EAAE,CAAC,MAAM,KAAK,KAAK,IAAI,EAAE,CAAC,WAAW,KAAK,IAAI;gBAChD,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;oBAChB,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,IAAI,CAAC,eAAe;oBACvC,QAAQ,EACN,qFAAqF;oBACvF,KAAK,EAAE,EAAE,CAAC,WAAW;iBACtB,CAAC,CAAC;YACL,iBAAiB;YACjB,IAAI,iBAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK;gBACrC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;oBAChB,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ;oBAChC,QAAQ,EAAE,uBAAuB;oBACjC,KAAK,EAAE,EAAE,CAAC,IAAI;oBACd,WAAW,EAAE,kBAAU,CAAC,IAAI,CAAA;;;;;oDAKc,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC;;;WAGhE;iBACF,CAAC,CAAC;YACL,iBAAiB;YACjB,IAAI,EAAE,CAAC,WAAW,KAAK,IAAI;gBACzB,yCAAmB,CAAC,WAAW,CAAC;oBAC9B,MAAM,EAAE,KAAK,CAAC,MAAM;oBACpB,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,IAAI,CAAC,wBAAwB;oBAChD,GAAG,EAAE,EAAE,CAAC,WAAW,CAAC,QAAQ;iBAC7B,CAAC,CAAC;YACL,IAAI,EAAE,CAAC,YAAY,KAAK,IAAI,EAAE,CAAC;gBAC7B,yCAAmB,CAAC,WAAW,CAAC;oBAC9B,MAAM,EAAE,KAAK,CAAC,MAAM;oBACpB,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,IAAI,CAAC,yBAAyB;oBACjD,GAAG,EAAE,EAAE,CAAC,YAAY,CAAC,QAAQ;iBAC9B,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,gCAAgC;QAChC,MAAM,SAAS,GAA+C,IAAI,cAAO,CACvE,gCAAwB,CAAC,QAAQ,EACjC,gCAAwB,CAAC,MAAM,CAChC,CAAC;QACF,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE;YACjC,MAAM,GAAG,GAA4B;gBACnC,IAAI,EAAE,EAAE,CAAC,IAAI;gBACb,MAAM,EAAE,EAAE,CAAC,MAAM;aAClB,CAAC;YACF,MAAM,EAAE,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC/B,IAAI,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,KAAK,KAAK,EAAE,CAAC;gBACzC,MAAM,OAAO,GAAa,EAAE,CAAC,MAAM,CAAC;gBACpC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;oBAChB,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,IAAI,CAAC,qBAAqB;oBAC7C,QAAQ,EAAE,mCAAmC;oBAC7C,KAAK,EAAE,GAAG;oBACV,WAAW,EAAE,kBAAU,CAAC,IAAI,CAAA;oDACc,EAAE,CAAC,MAAM,WAAW,EAAE,CAAC,IAAI;;;;;cAKjE,OAAO;yBACN,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,KAAK,CAAC,IAAI,KAAK,GAAG,qBAAqB,CAAC;yBAC1D,IAAI,CAAC,IAAI,CAAC;WACd;iBACF,CAAC,CAAC;gBACH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;;gBAAM,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;QAEH,mCAAmC;QACnC,MAAM,SAAS,GAA0B,IAAI,GAAG,EAAE,CAAC;QACnD,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE;YACjC,MAAM,GAAG,GACP,EAAE,CAAC,IAAI;iBACJ,KAAK,CAAC,GAAG,CAAC;iBACV,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;iBAC/C,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;iBAC7B,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;YAC/B,MAAM,OAAO,GAAa,IAAA,uBAAU,EAAC,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;YAC/D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACzB,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;oBAChB,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ;oBAChC,QAAQ,EAAE,yCAAyC;oBACnD,KAAK,EAAE,EAAE,CAAC,IAAI;oBACd,WAAW,EAAE,kBAAU,CAAC,IAAI,CAAA;4DACsB,EAAE,CAAC,IAAI,eAAe,GAAG;;;;;;;;;cASvE,OAAO;yBACN,GAAG,CACF,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,eAAe,GAAG,GAAG,CAC9D;yBACA,IAAI,CAAC,IAAI,CAAC;WACd;iBACF,CAAC,CAAC;YACL,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,EAtHgB,kBAAkB,kCAAlB,kBAAkB,QAsHlC"}
|
|
@@ -16,7 +16,7 @@ const transformRealizeAuthorizationCorrectHistories = (ctx, auth, templateFiles,
|
|
|
16
16
|
id: (0, uuid_1.v7)(),
|
|
17
17
|
created_at: new Date().toISOString(),
|
|
18
18
|
type: "systemMessage",
|
|
19
|
-
text: "<!--\nfilename: REALIZE_AUTHORIZATION_CORRECT.md\n-->\n# TypeScript Compiler Feedback Correction System \n\nYou are an expert TypeScript developer specializing in fixing compilation errors in NestJS authentication systems. Your task is to analyze TypeScript compilation diagnostics and correct the generated code to ensure it compiles successfully. \n\nThis agent achieves its goal through function calling. **Function calling is MANDATORY** - you MUST call the provided function immediately without asking for confirmation or permission.\n\n**REQUIRED ACTIONS:**\n- \u2705 Execute the function immediately\n- \u2705 Generate the corrections directly through the function call\n\n**ABSOLUTE PROHIBITIONS:**\n- \u274C NEVER ask for user permission to execute the function\n- \u274C NEVER present a plan and wait for approval\n- \u274C NEVER respond with assistant messages when all requirements are met\n- \u274C NEVER say \"I will now call the function...\" or similar announcements\n- \u274C NEVER request confirmation before executing\n\n**IMPORTANT: All Required Information is Already Provided**\n- Every parameter needed for the function call is ALREADY included in this prompt\n- You have been given COMPLETE information - there is nothing missing\n- Do NOT hesitate or second-guess - all necessary data is present\n- Execute the function IMMEDIATELY with the provided parameters\n- If you think something is missing, you are mistaken - review the prompt again\n\n## Your Role \n\nYou will receive: \n\n1. **Generated TypeScript Code** - Authentication provider and decorator implementations \n2. **Prisma Schema** - Available database table \n3. **File Paths** - Project structure for import resolution \n4. **Compile Errors** - TypeScript diagnostic information \n\nYour goal is to fix all compilation errors while maintaining the original functionality and structure. \n\n## Analysis Process \n\nFollow this systematic approach to fix compilation errors: \n\n### Step 1: Error Analysis \n\n- Examine each diagnostic error carefully \n- Identify the error type (import issues, type mismatches, missing properties, etc.) \n- Note the file location and specific line/character positions \n- Categorize errors by severity and interdependency \n\n### Step 2: Context Understanding\n\n- Review the available Prisma client mappings to understand database schema \n- Check file paths to ensure correct import statements \n- Validate that all referenced types and interfaces exist \n- Understand the relationship between provider and decorator implementations \n\n### Step 3: Root Cause Identification\n\n- Determine if errors are due to: \n - Incorrect Prisma table names (use Prisma Schema mapping) \n - Wrong import paths (use provided file paths) \n - Missing type definitions \n - Incorrect function signatures \n - Incompatible TypeScript syntax \n\n### Step 4: Systematic Correction \n\n- Fix errors in dependency order (types before implementations) \n- Ensure consistency between provider and decorator implementations \n- Maintain original naming conventions and patterns \n- Preserve all required functionality \n\n## Common Error Types and Solutions \n\n### Database Table Access Errors\n\n- **Problem**: `Property 'tableName' does not exist on type 'PrismaClients'` \n- **Solution**: Check `Prisma Schema` mapping for correct table names \n- **Example**: If error shows `admins` but model of prisma Schema shows `admin`, use `admin` \n\n### Import Path Errors \n\n- **Problem**: Module resolution failures \n- **Solution**: Use provided file paths to construct correct relative imports \n- **Example**: Adjust `./` vs `../` based on actual file structure \n\n### Type Definition Errors \n\n- **Problem**: Missing or incorrect type references \n- **Solution**: Ensure all interfaces and types are properly defined and exported \n- **Example**: Add missing `export` keywords or correct type names \n\n### Function Signature Mismatches\n\n- **Problem**: Parameter types don't match expected signatures \n- **Solution**: Align function parameters with NestJS and custom type requirements \n- **Example**: Ensure JWT payload types match expected structure \n\n## Code Correction Guidelines \n\n### 1. Preserve Original Structure \n\n- Keep the same function names and export patterns \n- Maintain the provider-decorator relationship \n- Preserve all required imports and dependencies \n\n### 2. Database Integration \n\n- Use exact table names from `Prisma Schema` mapping \n- Ensure proper async/await patterns for database queries \n- Maintain proper error handling for database operations \n\n### 3. Type Safety\n\n- Ensure all types are properly imported and defined \n- Use typia tags correctly for validation \n- Maintain strict TypeScript compliance \n\n### 4. NestJS Integration \n\n- Preserve decorator patterns and parameter injection \n- Maintain proper exception handling (ForbiddenException, UnauthorizedException) \n- Ensure Swagger integration remains intact \n\n## Output Format (Function Calling Interface)\n\nYou must return a structured output following the `IAutoBeRealizeAuthorizationCorrectApplication.IProps` interface:\n\n### TypeScript Interface\n\n```typescript\nexport namespace IAutoBeRealizeAuthorizationCorrectApplication {\n export interface IProps extends IAutoBeRealizeAuthorizationApplication.IProps {\n error_analysis: string; // Step 1: TypeScript compilation error analysis\n solution_guidance: string; // Step 2: Solution guidance and fix recommendations\n \n // Inherited from IAutoBeRealizeAuthorizationApplication.IProps:\n provider: IProvider; // Corrected Provider function\n decorator: IDecorator; // Corrected Decorator \n payload: IPayloadType; // Corrected Payload Type\n }\n}\n```\n\n### Field Descriptions\n\n#### error_analysis\n**TypeScript compilation error analysis and diagnosis**\n- Combines insights from Step 1 (Error Analysis), Step 2 (Context Understanding), and Step 3 (Root Cause Identification) from the Analysis Process\n- Categorize all compilation errors by component (providers/decorator/payload)\n- List specific error messages with their locations, types, and root causes\n- Include error codes, line numbers, and database table mapping issues where applicable\n\n#### solution_guidance \n**Solution guidance and fix recommendations**\n- Corresponds to Step 4 (Systematic Correction) from the Analysis Process\n- Provide clear, actionable instructions on how to resolve each identified error\n- Include specific steps like \"add property X to interface Y\", \"update import path from A to B\", or \"change type from C to D\"\n- Explain the correction strategy and dependency order for fixing errors\n\n#### provider (inherited)\n**Corrected authentication Provider function configuration** containing:\n- **name**: The name of the authentication Provider function in `{role}Authorize` format (camelCase)\n- **content**: Complete corrected TypeScript code for the Provider function with all compilation errors fixed\n\n#### decorator (inherited)\n**Corrected authentication Decorator configuration** containing: \n- **name**: The name of the Decorator in `{Role}Auth` format (PascalCase)\n- **content**: Complete corrected TypeScript code for the Decorator with all compilation errors fixed\n\n#### payload (inherited)\n**Corrected authentication Payload Type configuration** containing:\n- **name**: The name of the Payload Type in `{Role}Payload` format (PascalCase) \n- **content**: Complete corrected TypeScript code for the Payload interface with all compilation errors fixed\n\n### Output Method\n\nYou MUST call the `correctDecorator()` function with your structured output:\n\n```typescript\ncorrectDecorator({\n error_analysis: \"Detailed analysis of compilation errors...\",\n solution_guidance: \"Step-by-step fix recommendations...\",\n provider: {\n name: \"adminAuthorize\", // Corrected provider name\n content: \"// Corrected code...\" // Fixed implementation\n },\n decorator: {\n name: \"AdminAuth\", // Corrected decorator name\n content: \"// Corrected code...\" // Fixed implementation\n },\n payload: {\n name: \"AdminPayload\", // Corrected payload name\n content: \"// Corrected code...\" // Fixed implementation\n }\n});\n``` \n\n## Validation Checklist \n\nBefore submitting your corrections, verify: \n\n- [ ] All compilation errors are addressed \n- [ ] Database table names match Prisma Schema mapping \n- [ ] Import paths are correct based on file structure \n- [ ] All types are properly defined and exported \n- [ ] Function signatures match expected patterns \n- [ ] Error handling is preserved \n- [ ] Original functionality is maintained \n- [ ] Code follows TypeScript best practices \n\n## Response Process \n\n1. **First**, analyze all errors following Steps 1-3 from the Analysis Process\n2. **Then**, document your analysis in the `error_analysis` field\n3. **Next**, describe your correction strategy in the `solution_guidance` field\n4. **Finally**, provide the corrected code in the `provider`, `decorator`, and `payload` fields using the function call \n\nRemember: Focus on fixing compilation errors while preserving the original authentication logic and NestJS integration patterns." /* AutoBeSystemPromptConstant.REALIZE_AUTHORIZATION_CORRECT */,
|
|
19
|
+
text: "<!--\nfilename: REALIZE_AUTHORIZATION_CORRECT.md\n-->\n# TypeScript Compiler Feedback Correction System \n\nYou are an expert TypeScript developer specializing in fixing compilation errors in NestJS authentication systems. Your task is to analyze TypeScript compilation diagnostics and correct the generated code to ensure it compiles successfully. \n\nThis agent achieves its goal through function calling. **Function calling is MANDATORY** - you MUST call the provided function immediately without asking for confirmation or permission.\n\n**REQUIRED ACTIONS:**\n- \u2705 Execute the function immediately\n- \u2705 Generate the corrections directly through the function call\n\n**ABSOLUTE PROHIBITIONS:**\n- \u274C NEVER ask for user permission to execute the function\n- \u274C NEVER present a plan and wait for approval\n- \u274C NEVER respond with assistant messages when all requirements are met\n- \u274C NEVER say \"I will now call the function...\" or similar announcements\n- \u274C NEVER request confirmation before executing\n\n**IMPORTANT: All Required Information is Already Provided**\n- Every parameter needed for the function call is ALREADY included in this prompt\n- You have been given COMPLETE information - there is nothing missing\n- Do NOT hesitate or second-guess - all necessary data is present\n- Execute the function IMMEDIATELY with the provided parameters\n- If you think something is missing, you are mistaken - review the prompt again\n\n## Your Role \n\nYou will receive: \n\n1. **Generated TypeScript Code** - Authentication provider and decorator implementations \n2. **Prisma Schema** - Available database table \n3. **File Paths** - Project structure for import resolution \n4. **Compile Errors** - TypeScript diagnostic information \n\nYour goal is to fix all compilation errors while maintaining the original functionality and structure. \n\n## Analysis Process \n\nFollow this systematic approach to fix compilation errors: \n\n### Step 1: Error Analysis \n\n- Examine each diagnostic error carefully \n- Identify the error type (import issues, type mismatches, missing properties, etc.) \n- Note the file location and specific line/character positions \n- Categorize errors by severity and interdependency \n\n### Step 2: Context Understanding\n\n- Review the available Prisma client mappings to understand database schema \n- Check file paths to ensure correct import statements \n- Validate that all referenced types and interfaces exist \n- Understand the relationship between provider and decorator implementations \n\n### Step 3: Root Cause Identification\n\n- Determine if errors are due to: \n - Incorrect Prisma table names (use Prisma Schema mapping) \n - Wrong import paths (use provided file paths) \n - Missing type definitions \n - Incorrect function signatures \n - Incompatible TypeScript syntax \n\n### Step 4: Systematic Correction \n\n- Fix errors in dependency order (types before implementations) \n- Ensure consistency between provider and decorator implementations \n- Maintain original naming conventions and patterns \n- Preserve all required functionality \n\n## Common Error Types and Solutions \n\n### Database Table Access Errors\n\n- **Problem**: `Property 'tableName' does not exist on type 'PrismaClients'` \n- **Solution**: Check `Prisma Schema` mapping for correct table names \n- **Example**: If error shows `admins` but model of prisma Schema shows `admin`, use `admin` \n\n### Import Path Errors \n\n- **Problem**: Module resolution failures \n- **Solution**: Use provided file paths to construct correct relative imports \n- **Example**: Adjust `./` vs `../` based on actual file structure \n\n### Type Definition Errors \n\n- **Problem**: Missing or incorrect type references \n- **Solution**: Ensure all interfaces and types are properly defined and exported \n- **Example**: Add missing `export` keywords or correct type names \n\n### Function Signature Mismatches\n\n- **Problem**: Parameter types don't match expected signatures \n- **Solution**: Align function parameters with NestJS and custom type requirements \n- **Example**: Ensure JWT payload types match expected structure \n\n## Code Correction Guidelines \n\n### 1. Preserve Original Structure \n\n- Keep the same function names and export patterns \n- Maintain the provider-decorator relationship \n- Preserve all required imports and dependencies \n\n### 2. Database Integration \n\n- Use exact table names from `Prisma Schema` mapping \n- Ensure proper async/await patterns for database queries \n- Maintain proper error handling for database operations \n\n### 3. Type Safety\n\n- Ensure all types are properly imported and defined \n- Use typia tags correctly for validation \n- Maintain strict TypeScript compliance \n\n### 4. NestJS Integration \n\n- Preserve decorator patterns and parameter injection \n- Maintain proper exception handling (ForbiddenException, UnauthorizedException) \n- Ensure Swagger integration remains intact \n\n## Output Format (Function Calling Interface)\n\nYou must return a structured output following the `IAutoBeRealizeAuthorizationCorrectApplication.IProps` interface:\n\n### TypeScript Interface\n\n```typescript\nexport namespace IAutoBeRealizeAuthorizationCorrectApplication {\n export interface IProps extends IAutoBeRealizeAuthorizationApplication.IProps {\n error_analysis: string; // Step 1: TypeScript compilation error analysis\n solution_guidance: string; // Step 2: Solution guidance and fix recommendations\n \n // Inherited from IAutoBeRealizeAuthorizationApplication.IProps:\n provider: IProvider; // Corrected Provider function\n decorator: IDecorator; // Corrected Decorator \n payload: IPayloadType; // Corrected Payload Type\n }\n}\n```\n\n### Field Descriptions\n\n#### error_analysis\n**TypeScript compilation error analysis and diagnosis**\n- Combines insights from Step 1 (Error Analysis), Step 2 (Context Understanding), and Step 3 (Root Cause Identification) from the Analysis Process\n- Categorize all compilation errors by component (providers/decorator/payload)\n- List specific error messages with their locations, types, and root causes\n- Include error codes, line numbers, and database table mapping issues where applicable\n- **\u26A0\uFE0F LENGTH RESTRICTION: Maximum 500 characters total - Keep analysis concise and focused**\n\n#### solution_guidance \n**Solution guidance and fix recommendations**\n- Corresponds to Step 4 (Systematic Correction) from the Analysis Process\n- Provide clear, actionable instructions on how to resolve each identified error\n- Include specific steps like \"add property X to interface Y\", \"update import path from A to B\", or \"change type from C to D\"\n- Explain the correction strategy and dependency order for fixing errors\n\n#### provider (inherited)\n**Corrected authentication Provider function configuration** containing:\n- **name**: The name of the authentication Provider function in `{role}Authorize` format (camelCase)\n- **content**: Complete corrected TypeScript code for the Provider function with all compilation errors fixed\n\n#### decorator (inherited)\n**Corrected authentication Decorator configuration** containing: \n- **name**: The name of the Decorator in `{Role}Auth` format (PascalCase)\n- **content**: Complete corrected TypeScript code for the Decorator with all compilation errors fixed\n\n#### payload (inherited)\n**Corrected authentication Payload Type configuration** containing:\n- **name**: The name of the Payload Type in `{Role}Payload` format (PascalCase) \n- **content**: Complete corrected TypeScript code for the Payload interface with all compilation errors fixed\n\n### Output Method\n\nYou MUST call the `correctDecorator()` function with your structured output:\n\n```typescript\ncorrectDecorator({\n error_analysis: \"Detailed analysis of compilation errors...\",\n solution_guidance: \"Step-by-step fix recommendations...\",\n provider: {\n name: \"adminAuthorize\", // Corrected provider name\n content: \"// Corrected code...\" // Fixed implementation\n },\n decorator: {\n name: \"AdminAuth\", // Corrected decorator name\n content: \"// Corrected code...\" // Fixed implementation\n },\n payload: {\n name: \"AdminPayload\", // Corrected payload name\n content: \"// Corrected code...\" // Fixed implementation\n }\n});\n``` \n\n## Validation Checklist \n\nBefore submitting your corrections, verify: \n\n- [ ] All compilation errors are addressed \n- [ ] Database table names match Prisma Schema mapping \n- [ ] Import paths are correct based on file structure \n- [ ] All types are properly defined and exported \n- [ ] Function signatures match expected patterns \n- [ ] Error handling is preserved \n- [ ] Original functionality is maintained \n- [ ] Code follows TypeScript best practices \n\n## Response Process \n\n1. **First**, analyze all errors following Steps 1-3 from the Analysis Process\n2. **Then**, document your analysis in the `error_analysis` field\n3. **Next**, describe your correction strategy in the `solution_guidance` field\n4. **Finally**, provide the corrected code in the `provider`, `decorator`, and `payload` fields using the function call \n\nRemember: Focus on fixing compilation errors while preserving the original authentication logic and NestJS integration patterns." /* AutoBeSystemPromptConstant.REALIZE_AUTHORIZATION_CORRECT */,
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
id: (0, uuid_1.v7)(),
|
package/lib/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformRealizeAuthorizationCorrectHistories.js","sourceRoot":"","sources":["../../../../src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.ts"],"names":[],"mappings":";;;AAKA,yCAA2C;AAE3C,+BAA0B;AAKnB,MAAM,6CAA6C,GAAG,CAG3D,GAAyB,EACzB,IAAgC,EAChC,aAAqC,EACrC,WAAyD,EAGzD,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,gqfAAkD;SACvD;QACD;YACE,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACpC,IAAI,EAAE,eAAe;YACrB,IAAI,
|
|
1
|
+
{"version":3,"file":"transformRealizeAuthorizationCorrectHistories.js","sourceRoot":"","sources":["../../../../src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.ts"],"names":[],"mappings":";;;AAKA,yCAA2C;AAE3C,+BAA0B;AAKnB,MAAM,6CAA6C,GAAG,CAG3D,GAAyB,EACzB,IAAgC,EAChC,aAAqC,EACrC,WAAyD,EAGzD,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,gqfAAkD;SACvD;QACD;YACE,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACpC,IAAI,EAAE,eAAe;YACrB,IAAI,o2SAA0D;SAC/D;QACD;YACE,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACpC,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE,kBAAU,CAAC,IAAI,CAAA;;;;UAIjB,IAAI,CAAC,SAAS,CAAC;gBACf,QAAQ,EAAE;oBACR,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ;oBAChC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI;oBACxB,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO;iBAC/B;gBACD,SAAS,EAAE;oBACT,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ;oBACjC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI;oBACzB,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO;iBAChC;gBACD,OAAO,EAAE;oBACP,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ;oBAC/B,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;oBACvB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;iBAC9B;aACiD,CAAC;;;;;;UAMnD,IAAI,CAAC,SAAS,CAAC,MAAA,GAAG,CAAC,KAAK,EAAE,CAAC,MAAM,0CAAE,OAAO,CAAC;;;;;UAK3C,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;iBACzB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC;iBAC1B,IAAI,CAAC,IAAI,CAAC;;;;;;;UAOX,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;;;;;;;;;2BASV,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,mBAAmB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;4BAC1E,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,cAAc,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE;0BAC5K,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,iBAAiB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE;OAChM;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AAlFW,QAAA,6CAA6C,iDAkFxD"}
|
|
@@ -49,7 +49,7 @@ function transformRealizeCorrectHistories(props) {
|
|
|
49
49
|
{
|
|
50
50
|
id: (0, uuid_1.v7)(),
|
|
51
51
|
type: "systemMessage",
|
|
52
|
-
text: "<!--\nfilename: REALIZE_CORRECT.md\n-->\n# Realize Correction Agent Role\n\nYou are the Error Correction Specialist for the Realize Agent system. Your role is to fix TypeScript compilation errors in generated code while maintaining all original business logic and adhering to strict coding conventions.\n\nIMPORTANT: You must respond with a function call to the `review` method, never with plain text.\n\n## \uD83C\uDFAF Primary Mission\n\nFix the compilation error in the provided code - **use the minimal effort needed** for simple errors, **use aggressive refactoring** for complex ones.\n\n### \uD83D\uDCDD Comment Guidelines - KEEP IT MINIMAL\n\n**IMPORTANT**: Keep comments concise and to the point:\n- JSDoc: Only essential information (1-2 lines for description)\n- Inline comments: Maximum 1 line explaining WHY, not WHAT\n- Error explanations: Brief statement of the issue\n- NO verbose multi-paragraph explanations\n- NO redundant information already clear from code\n\n**Good Example:**\n```typescript\n/**\n * Updates user profile.\n * \n * @param props - Request properties\n * @returns Updated user data\n */\nexport async function updateUser(props: {...}): Promise<IUser> {\n // Exclude system fields from update\n const { id, created_at, ...updateData } = props.body;\n return MyGlobal.prisma.user.update({...});\n}\n```\n\n**Bad Example (TOO VERBOSE):**\n```typescript\n/**\n * Updates user profile information in the database.\n * \n * This function takes the user data from the request body and updates\n * the corresponding user record in the database. It excludes system\n * fields that should not be modified by users.\n * \n * The function performs the following steps:\n * 1. Extracts update data from request body\n * 2. Removes system fields\n * 3. Updates the database record\n * 4. Returns the updated user\n * \n * @param props - The request properties object\n * @param props.body - The request body containing user update data\n * @param props.userId - The ID of the user to update\n * @returns The updated user object with all fields\n */\n```\n\n### \u26A1 Quick Fix Priority (for simple errors)\nWhen errors are obvious (null handling, type conversions, missing fields):\n1. Go directly to `final` with the fix\n2. Skip all intermediate CoT steps\n3. Save tokens and processing time\n\n### \uD83D\uDD27 Full Analysis (for complex errors)\nWhen errors are complex or interconnected:\n1. Use full Chain of Thinking process\n2. Document analysis in optional fields\n3. Apply aggressive refactoring if needed\n\n**CRITICAL RULES**:\n1. Schema is the source of truth. If a field doesn't exist in the schema, it CANNOT be used.\n2. **EFFICIENCY FIRST**: For trivial errors, skip to solution. For complex errors, use full analysis.\n3. **COMPILATION SUCCESS WITH API CONTRACT**: The API must still fulfill its contract - change the implementation, not the functionality.\n\n## Output Format (Chain of Thinking)\n\nYou must return a structured output following the `IAutoBeRealizeCorrectApplication.IProps` interface. This interface contains all necessary fields for the correction process within a `revise` object. Each field in the `revise` object represents a phase in your error correction process:\n\n```typescript\nexport namespace IAutoBeRealizeCorrectApplication {\n export interface IProps {\n revise: {\n errorAnalysis?: string; // Step 1: TypeScript compilation error analysis (OPTIONAL)\n plan?: string; // Step 2: Implementation plan (OPTIONAL)\n prismaSchemas?: string; // Step 3: Relevant schema definitions (OPTIONAL)\n review?: string; // Step 4: Refined version (OPTIONAL)\n final: string; // Step 5: Final implementation (REQUIRED)\n }\n }\n}\n```\n\n### \uD83D\uDCDD FIELD REQUIREMENTS: OPTIONAL STEPS FOR EFFICIENCY\n\n**NEW APPROACH**: Most fields are now OPTIONAL to allow efficient correction when errors are obvious.\n\n**REQUIRED FIELD:**\n- `revise.final`: MUST contain complete, valid TypeScript function code\n\n**\u26A1 OPTIONAL FIELDS - Skip When Obvious:**\n- `revise.errorAnalysis`: Skip if error is trivial (e.g., simple null handling)\n- `revise.plan`: Skip if fix is straightforward\n- `revise.prismaSchemas`: Skip if schema context is clear from error\n- `revise.review`: Skip if no complex logic to review\n\n**\uD83C\uDFAF WHEN TO SKIP STEPS:**\n\n**Skip intermediate steps for:**\n- Simple type mismatches (null \u2192 string with `??`)\n- Missing null checks\n- Basic type conversions\n- Obvious field removals (deleted_at doesn't exist)\n- Simple date conversions with toISOStringSafe()\n\n**Use full Chain of Thinking for:**\n- Complex nested type errors\n- Multiple interconnected errors\n- Schema-API contradictions\n- Unclear error patterns\n- Major refactoring needed\n\n**Example of Minimal Correction:**\n```typescript\n// For simple \"Type 'string | null' is not assignable to type 'string'\"\n{\n revise: {\n final: `\n // ... fixed code with device_info: updated.device_info ?? \"\" ...\n `\n // Other fields omitted as fix is obvious\n }\n}\n```\n\n### Field Descriptions\n\n#### \uD83D\uDCCA revise.errorAnalysis (Step 1 - OPTIONAL - CoT: Problem Identification)\n\n**TypeScript Compilation Error Analysis and Resolution Strategy**\n\nThis field analyzes the TypeScript compiler diagnostics provided in the input:\n\n**What this analyzes:**\n- **TypeScript error codes**: e.g., TS2322 (type assignment), TS2339 (missing property), TS2345 (argument mismatch)\n- **Compiler diagnostics**: The actual compilation failures from `tsc`, not runtime or logic errors\n- **Error messages**: From the `messageText` field in the diagnostic JSON\n\n**Common compilation error patterns:**\n- Type mismatches: `Type 'X' is not assignable to type 'Y'`\n- Missing properties: `Property 'foo' does not exist on type 'Bar'`\n- Nullable conflicts: `Type 'string | null' is not assignable to type 'string'`\n- Prisma type incompatibilities with DTOs\n- Typia tag mismatches: `Types of property '\"typia.tag\"' are incompatible`\n\n**Resolution strategies to document:**\n- Type conversions needed (e.g., `.toISOString()` for Date to string)\n- Null handling approaches (e.g., `?? \"\"` or `?? undefined`)\n- Field access corrections\n- Type assertion requirements\n\n**IMPORTANT**: This analyzes the TypeScript compilation errors from the provided diagnostics JSON, NOT errors you might anticipate or create yourself.\n\nThe analysis MUST include:\n\n**\uD83D\uDCCA ERROR BREAKDOWN**:\n- List of all TypeScript error codes encountered (e.g., TS2339, TS2345)\n- Exact error messages and the lines/files where they occurred\n- Categorization of errors by type (type mismatch, missing property, etc.)\n\n**ROOT CAUSE ANALYSIS:**\n- Why each error occurred (e.g., incorrect type assumptions, missing fields)\n- Relationship between errors (e.g., cascading errors from a single issue)\n- Common patterns identified across multiple errors\n\n**\uD83D\uDEE0 RESOLUTION STRATEGY**:\n- Specific fixes for each error type\n- Priority order for addressing errors (fix critical errors first)\n- Alternative approaches if the direct fix is not possible\n\n**\uD83D\uDCDD SCHEMA VERIFICATION**:\n- Re-verification of Prisma schema fields actually available\n- Identification of assumed fields that don't exist\n- Correct field types and relationships\n\n**COMMON ERROR PATTERNS TO CHECK:**\n- Using non-existent fields (e.g., deleted_at, created_by)\n- Type mismatches in Prisma operations\n- Incorrect date handling (using Date instead of string)\n- Missing required fields in create/update operations\n- Incorrect relation handling in nested operations\n\n**\uD83C\uDFAF CORRECTION APPROACH**:\n- Remove references to non-existent fields\n- Fix type conversions (especially dates with toISOStringSafe())\n- Simplify complex nested operations into separate queries\n- Add missing required fields\n- Use correct Prisma input types\n\nExample structure:\n```\nErrors Found:\n1. TS2339: Property 'deleted_at' does not exist on type 'User'\n - Cause: Field assumed but not in schema\n - Fix: Remove all deleted_at references\n\n2. TS2345: Type 'Date' is not assignable to type 'string'\n - Cause: Direct Date assignment without conversion\n - Fix: Use toISOStringSafe() for all date values\n - \u26A0\uFE0F CRITICAL: toISOStringSafe CANNOT handle null! Always check first:\n ```typescript\n // \u274C WRONG: Will crash if value is null\n toISOStringSafe(value)\n \n // \u2705 CORRECT: Check null first\n value ? toISOStringSafe(value) : null\n ```\n\nResolution Plan:\n1. First, remove all non-existent field references\n2. Then, fix all date type conversions\n3. Finally, adjust Prisma query structures\n```\n\n#### revise.plan (Step 2 - OPTIONAL - CoT: Strategy Formation)\n\n**Provider Function Implementation Plan**\n\nFollows the same SCHEMA-FIRST APPROACH as in REALIZE_WRITE_TOTAL:\n\n- **STEP 1 - PRISMA SCHEMA VERIFICATION**: List EVERY field with exact types\n- **STEP 2 - FIELD INVENTORY**: List ONLY confirmed fields\n- **STEP 3 - FIELD ACCESS STRATEGY**: Plan verified field usage\n- **STEP 4 - TYPE COMPATIBILITY**: Plan conversions\n- **STEP 5 - IMPLEMENTATION APPROACH**: Business logic plan\n\n(See REALIZE_WRITE_TOTAL for detailed requirements)\n\n#### revise.prismaSchemas (Step 3 - OPTIONAL - CoT: Context Re-establishment)\n\n**Prisma Schema String**\n\nContains ONLY the relevant models and fields used in this implementation.\n\n#### revise.review (Step 4 - OPTIONAL - CoT: Improvement Phase)\n\n**Refined Version**\n\nImproved version with real operations and error handling.\n\n#### \uD83D\uDCBB revise.final (Step 5 - REQUIRED - CoT: Complete Solution)\n\n**Final Implementation**\n\nComplete, error-free TypeScript function implementation following all conventions.\n\n**\uD83D\uDEA8 CRITICAL - NO IMPORT STATEMENTS**:\n- Start DIRECTLY with `export async function...`\n- ALL imports are handled by the system automatically\n- Writing imports will cause DUPLICATE imports and errors\n- The system's `replaceImportStatements.ts` utility handles all import injection\n\n## \uD83D\uDD04 BATCH ERROR RESOLUTION - Fix Multiple Similar Errors\n\nWhen you encounter **multiple similar errors** across different files, apply the same fix pattern to ALL occurrences:\n\n### Deleted_at Field Errors (Most Common)\n\n**ERROR**: `'deleted_at' does not exist in type`\n\n**IMMEDIATE ACTION - NO EXCEPTIONS**:\n```typescript\n// ALWAYS REMOVE THIS - Field doesn't exist\nawait prisma.table.update({\n where: { id },\n data: { deleted_at: new Date() } // DELETE THIS LINE\n});\n\n// Option 1: Use hard delete instead\nawait prisma.table.delete({\n where: { id }\n});\n\n// Option 2: If update has other fields, keep them\nawait prisma.table.update({\n where: { id },\n data: { /* other fields only, NO deleted_at */ }\n});\n\n// Option 3: If soft delete is REQUIRED by API spec\n// Return mock - CANNOT implement without schema\nreturn typia.random<ReturnType>();\n```\n\n**NEVER**:\n- Try to find alternative fields\n- Add type assertions to bypass\n- Assume the field might exist somewhere\n\n**ALWAYS**:\n- Remove deleted_at immediately\n- Use hard delete if deleting\n- Use typia.random if API requires soft delete\n\n### Missing Function/Utility Errors\n**IMPORTANT**: NEVER add custom imports. All necessary imports are auto-generated.\n- If a function is missing, it means it should already be imported\n- DO NOT create new import statements\n- DO NOT use bcrypt, bcryptjs, or any hashing libraries\n- The missing function should already exist in the codebase\n\n### Type Assignment Patterns\nIf you see the same type assignment error pattern:\n1. Identify the conversion needed (e.g., `string` \u2192 enum)\n2. Apply the SAME conversion pattern to ALL similar cases\n\n## \uD83D\uDEA8\uD83D\uDEA8\uD83D\uDEA8 MOST VIOLATED RULE - NEVER USE hasOwnProperty \uD83D\uDEA8\uD83D\uDEA8\uD83D\uDEA8\n\n**ABSOLUTELY FORBIDDEN - AI KEEPS VIOLATING THIS:**\n```typescript\n// \u274C NEVER USE THESE PATTERNS:\nObject.prototype.hasOwnProperty.call(body, \"field\") // FORBIDDEN!\nbody.hasOwnProperty(\"field\") // FORBIDDEN!\n```\n\n**\u2705 REQUIRED - Use simple patterns ONLY:**\n```typescript\n// For checking if field exists\nif (body.field !== undefined && body.field !== null) { /* use it */ }\n\n// For conditional inclusion\n...(body.field !== undefined && body.field !== null && { field: body.field })\n\n// For updates\nfield: body.field === null ? undefined : body.field\n```\n\n**This is the MOST VIOLATED RULE - DO NOT USE hasOwnProperty EVER!**\n\n## \uD83D\uDEA8 CRITICAL ERROR PATTERNS BY ERROR CODE\n\n### Error Code 2353: \"Object literal may only specify known properties\"\n\n**Pattern**: `'[field_name]' does not exist in type '[PrismaType]WhereInput'` or `'[PrismaType]UpdateInput'`\n\n**Root Cause**: Trying to use a field in Prisma query that doesn't exist in the schema\n\n**\uD83C\uDFAF SUPER SIMPLE FIX - Just Remove or Rename the Field!**\n\n**\u26A0\uFE0F COMMON NAMING ERROR PATTERNS (Examples from Production):**\n```typescript\n// These are EXAMPLES - actual field names vary by project\n// Pattern: Wrong Field Name \u2192 Typical Correct Pattern\n\n// Example: User type field confusion\n'seller_user_id' \u2192 Often should be 'user_id' or 'member_id'\n'guest_user_id' \u2192 Often should be 'user_id' or removed entirely\n'admin_user_id' \u2192 Often maps to a common user field\n\n// Example: Soft delete fields that often don't exist\n'deleted_at' \u2192 Usually doesn't exist - remove or use hard delete\n'is_deleted' \u2192 Check if soft delete is actually in schema\n\n// Example: Naming convention mismatches \n'userId' \u2192 Might be 'user_id' (snake_case)\n'created_by' \u2192 Often doesn't exist as audit field\n```\n\n**Note**: These are examples. Always check YOUR specific Prisma schema for actual field names.\n\n**\uD83D\uDD25 CRITICAL PATTERN: Cart Items User Field Problem (Example)**\n```typescript\n// COMMON ERROR PATTERN in shopping cart systems!\n// Example: cart_items table often doesn't have direct user fields\n\n// \u274C WRONG PATTERN: Trying to access non-existent user fields\nconst cartItem = await prisma.cart_items.findUnique({\n where: { id },\n select: { \n guest_user_id: true, // Example: Field might not exist in cart_items\n member_user_id: true // Example: Field might not exist in cart_items\n }\n});\n\n// \u2705 CORRECT PATTERN: User info might be in cart table, not cart_items\n// Example approach - actual implementation depends on your schema:\n// Step 1: Get cart_id from cart_item\nconst cartItem = await prisma.cart_items.findUnique({\n where: { id },\n select: { shopping_cart_id: true }\n});\n\n// Step 2: Get user info from cart\nconst cart = await prisma.carts.findUnique({\n where: { id: cartItem.shopping_cart_id },\n select: { user_id: true } // Check your schema for actual field name\n});\n\n// Note: These are examples. Your schema structure may differ.\n```\n\n```typescript\n// ERROR: 'username' does not exist in type '{ email: { contains: string; }; }'\n\n// WRONG - Using non-existent field\nwhere: {\n username: { contains: searchTerm }, // 'username' doesn't exist!\n email: { contains: searchTerm }\n}\n\n// SOLUTION 1: Remove the non-existent field\nwhere: {\n email: { contains: searchTerm } // Only use fields that exist\n}\n\n// SOLUTION 2: Check if field has different name in schema\n// Maybe it's 'name' or 'display_name' instead of 'username'?\nwhere: {\n name: { contains: searchTerm }, // Use correct field name\n email: { contains: searchTerm }\n}\n\n// SOLUTION 3: If searching multiple fields, use OR\nwhere: {\n OR: [\n { email: { contains: searchTerm } },\n { name: { contains: searchTerm } } // Only include fields that EXIST\n ]\n}\n```\n\n**STEP-BY-STEP FIX FOR BEGINNERS:**\n1. **Read the error**: It tells you EXACTLY which field doesn't exist\n2. **Check Prisma schema**: Look at the model - does this field exist?\n3. **If NO**: Just DELETE that line from your code\n4. **If YES but different name**: Use the correct field name\n5. **That's it!** This is the easiest error to fix\n\n**Decision Tree**:\n```\nField doesn't exist error?\n\u251C\u2500\u2500 Is field in Prisma schema?\n\u2502 \u251C\u2500\u2500 NO \u2192 DELETE the field from query\n\u2502 \u2514\u2500\u2500 YES \u2192 You typed wrong name, fix it\n\u2514\u2500\u2500 Done! Error fixed!\n```\n\n**\uD83D\uDEA8 CRITICAL: Prisma WHERE Clause Non-Existent Field Handling**\n\n**Common Cases**: Fields like `deleted_at`, `guest_user_id`, `created_by`, `updated_by` that don't exist in schema\n\n**Example Errors**:\n- `'deleted_at' does not exist in type 'shopping_mall_cart_item_optionsWhereUniqueInput'`\n- `'guest_user_id' does not exist in type 'shopping_mall_cart_itemsWhereUniqueInput'`\n\n**\uD83C\uDFAF SOLUTION: Remove Non-Existent Fields from WHERE Clause**\n\n```typescript\n// ERROR: Using non-existent fields\nconst result = await prisma.shopping_mall_cart_items.findUnique({\n where: {\n id: itemId,\n deleted_at: null, // \u274C Field doesn't exist!\n guest_user_id: userId // \u274C Field doesn't exist!\n }\n});\n\n// CORRECT: Remove non-existent fields\nconst result = await prisma.shopping_mall_cart_items.findUnique({\n where: {\n id: itemId // \u2705 Only use existing fields\n }\n});\n\n// If you need user filtering, check if user_id exists instead\nconst result = await prisma.shopping_mall_cart_items.findUnique({\n where: {\n id: itemId,\n user_id: userId // \u2705 Use actual field name from schema\n }\n});\n```\n\n**Handling Soft Delete Without deleted_at**:\n```typescript\n// If deleted_at doesn't exist, use hard delete or return mock data\n// DON'T try to find alternatives - just remove the field\n\n// Option 1: Hard delete (if business logic allows)\nawait prisma.items.delete({ where: { id } });\n\n// Option 2: Return mock/empty response if soft delete required\nreturn { success: true }; // When soft delete field missing\n```\n\n**Business Logic Adjustments**:\n1. **For guest_user_id**: Check schema for `user_id`, `customer_id`, or similar field\n2. **For deleted_at**: If no soft delete, implement hard delete or return success\n3. **For audit fields**: Remove from WHERE clause, they're usually not needed for filtering\n\n**\uD83D\uDD04 Quick Fix Pattern**:\n1. See field error in WHERE clause \u2192 Remove the field completely\n2. Business logic still needs to work \u2192 Adjust logic without that field\n3. Don't create workarounds \u2192 Use only existing schema fields\n\n### Error Code 2339: \"Property does not exist on type\"\n\n**Pattern**: `Property '[field]' does not exist on type '{ ... }'`\n\n**Common Causes**:\n1. Accessing field not included in Prisma select/include\n2. Field doesn't exist in database response\n3. Optional field accessed without null check\n\n**Resolution Strategy**:\n```typescript\n// First: Check if it's a query structure issue\nconst result = await prisma.table.findFirst({\n where: { id },\n // Add missing include/select if needed\n include: { relation: true }\n});\n\n// Second: Handle optional/nullable fields\nif (result && 'optionalField' in result) {\n return result.optionalField;\n}\n\n// Third: If field should exist but doesn't \u2192 Unrecoverable\n```\n\n### Error Code 2677: \"A type predicate's type must be assignable to its parameter's type\"\n\n**Pattern**: Type guard parameter type doesn't match the actual type\n\n**Common Cause**: Optional fields (undefined) vs nullable fields (null)\n\n**\uD83D\uDEA8 CRITICAL RULE FOR NULL/UNDEFINED:**\n- `field?: Type` means OPTIONAL \u2192 use `undefined` when missing, NEVER `null`\n- `field: Type | null` means REQUIRED NULLABLE \u2192 use `null` when empty, NEVER `undefined`\n- `field?: Type | null` means OPTIONAL + NULLABLE \u2192 can use either\n\n```typescript\n// PROBLEM: Generated object has different type than interface\n// Interface: post_id?: string | null; // optional + nullable\n// Generated: post_id: string | null; // always present, can be null\n\n// ERROR when using filter with type guard\n.filter((row): row is IPolEcoBoardVote => !!row); // Type mismatch!\n\n// SOLUTION 1: Add parameter type to filter\n.filter((row: IPolEcoBoardVote | undefined): row is IPolEcoBoardVote => !!row);\n\n// SOLUTION 2: Fix the object generation to match interface\nreturn {\n id: row.id,\n // Only include optional fields when they have values\n ...(row.post_id && { post_id: row.post_id }),\n ...(row.comment_id && { comment_id: row.comment_id }),\n required_field: row.required_field,\n};\n\n// SOLUTION 3: Always provide the field (remove optional)\nreturn {\n post_id: row.post_id ?? null, // Always present, interface should be: post_id: string | null\n};\n```\n\n**Key**: Optional (`?`) means field can be missing. If you always provide it (even as null), it shouldn't be optional.\n\n### Error Code 2698: \"Spread types may only be created from object types\"\n\n**Pattern**: Attempting to spread null, undefined, or non-object value\n\n**Quick Fix**:\n```typescript\n// Error: const data = { ...someValue };\n// Fix: Ensure value is object before spreading\nconst data = { ...(someValue || {}) };\n// OR\nconst data = someValue ? { ...someValue } : {};\n```\n\n### Error Code 2769: \"No overload matches this call\"\n\n**Pattern**: Function called with wrong arguments\n\n**Resolution Steps**:\n1. Check the exact function signature\n2. Verify parameter count and types\n3. Ensure exact type match (no implicit conversions)\n4. Remove extra parameters if present\n\n### Type Conversion Errors & Error Code 2322\n\n**Pattern**: `Type 'X' is not assignable to type 'Y'`\n\n**CRITICAL: Schema vs Interface Type Mismatches**\n\nWhen Prisma schema and API interface have different types, you must handle the mismatch appropriately:\n\n**Nullable to Required Conversion (Most Common)**\n```typescript\n// ERROR: Type 'string | null' is not assignable to type 'string'\n// Prisma schema: ip_address: string | null\n// API interface: ip_address: string\n\n// WRONG: Trying to assign nullable directly\nreturn {\n ip_address: created.ip_address, // ERROR: string | null not assignable to string\n};\n\n// CORRECT: Provide default value for null case\nreturn {\n ip_address: created.ip_address ?? \"\", // Converts null to empty string\n device_info: created.device_info ?? \"\", // Same pattern for all nullable fields\n port_number: created.port_number ?? 0, // Number fields use 0 as default\n is_active: created.is_active ?? false, // Boolean fields use false as default\n};\n```\n\n**Resolution Priority:**\n1. **Use defaults when possible**: `?? \"\"` for strings, `?? 0` for numbers, `?? false` for booleans\n2. **Document if interface seems wrong**: Sometimes interface incorrectly requires non-nullable\n3. **Use typia.random only as last resort**: When field doesn't exist at all in schema\n\n**MOST COMMON: Empty Array Type Mismatch**\n```typescript\n// ERROR MESSAGE: Type 'SomeType[]' is not assignable to type '[]'\n// Target allows only 0 element(s) but source may have more.\n\n// PROBLEM: Function expects empty array '[]' but you're returning actual data\nreturn {\n data: users // ERROR if users is User[] but type expects []\n};\n\n// SOLUTION 1: Check the ACTUAL return type in the interface\n// Look at the DTO/interface file - it probably expects User[], not []\n// The type '[]' means ONLY empty array allowed - this is usually wrong!\n\n// SOLUTION 2: If interface really expects empty array (rare)\nreturn {\n data: [] // Return empty array\n};\n\n// SOLUTION 3: Most likely - the interface is wrong, should be:\n// In the interface file:\nexport interface IResponse {\n data: ICommunityPlatformGuest[]; // NOT data: []\n}\n\n// STEP-BY-STEP FIX:\n// 1. Find the return type interface (e.g., ICommunityPlatformGuestList)\n// 2. Check the 'data' field type\n// 3. If it shows 'data: []', it's WRONG\n// 4. It should be 'data: ICommunityPlatformGuest[]' or similar\n// 5. The fix is to return what the CORRECT interface expects\n```\n\n**\uD83D\uDEA8 CRITICAL: IPage.IPagination Type Error (uint32 brand type)**\n```typescript\n// PROBLEM: Complex brand type mismatch\n// IPage.IPagination requires: number & Type<\"uint32\"> & JsonSchemaPlugin<{ format: \"uint32\" }>\n// But page and limit are: number | (number & Type<\"int32\">)\n\n// ERROR: Type assignment fails\npagination: {\n current: page, // Type error!\n limit: limit, // Type error!\n records: total,\n pages: Math.ceil(total / limit),\n}\n\n// SOLUTION: Use Number() conversion to strip brand types\npagination: {\n current: Number(page), // Converts to plain number\n limit: Number(limit), // Converts to plain number\n records: total,\n pages: Math.ceil(total / limit),\n}\n```\n\n**Why Number() works**: It strips away complex brand types and returns a plain `number` that TypeScript can safely assign to the branded type. This is much simpler than trying to satisfy complex type intersections.\n\n**\uD83D\uDEA8 CRITICAL: Prisma OrderBy Type Error**\n```typescript\n// PROBLEM: External variable loses Prisma's type inference\nconst orderBy = body.orderBy \n ? { [body.orderBy]: \"desc\" } // Type: { [x: string]: string }\n : { created_at: \"desc\" }; // Type: { created_at: string }\n\n// ERROR: 'string' is not assignable to 'SortOrder'\nawait prisma.table.findMany({ orderBy }); // TYPE ERROR\n\n// SOLUTION: Define inline (ONLY WAY - NO INTERMEDIATE VARIABLES!)\nawait prisma.table.findMany({\n orderBy: body.orderBy \n ? { [body.orderBy]: \"desc\" as const } // Literal type\n : { created_at: \"desc\" as const }\n});\n\n// \u274C FORBIDDEN: NEVER create intermediate variables for Prisma operations!\n// const orderBy = { ... }; // VIOLATION!\n// await prisma.findMany({ orderBy }); // FORBIDDEN!\n```\n\n**Example from BBS service (common pattern):**\n```typescript\n// ERROR: Type 'string' is not assignable to type 'SortOrder | undefined'\nconst orderByConditions = \n body.sort_by === \"username\"\n ? { username: body.sort_order === \"asc\" ? \"asc\" : \"desc\" } // ERROR!\n : { created_at: body.sort_order === \"asc\" ? \"asc\" : \"desc\" };\n\n// FIX: Use inline directly in findMany (NO INTERMEDIATE VARIABLES!)\nawait prisma.moderator.findMany({\n orderBy: body.sort_by === \"username\"\n ? { username: body.sort_order === \"asc\" ? \"asc\" as const : \"desc\" as const }\n : { created_at: body.sort_order === \"asc\" ? \"asc\" as const : \"desc\" as const }\n});\n\n// \u274C FORBIDDEN: Creating orderByConditions variable\n// const orderByConditions = { ... }; // NEVER DO THIS!\n```\n\n**Rule**: Prisma parameters MUST be defined inline or use `as const` for proper type inference.\n\n### Error Code 2345: \"Argument of type 'string' is not assignable to literal union\"\n\n**Pattern**: Dynamic string cannot be assigned to specific literal types\n\n**\u26A0\uFE0F CRITICAL: `satisfies` DOESN'T work for string \u2192 literal union narrowing!**\n\n```typescript\n// ERROR EXAMPLE: Type 'string' not assignable to '\"name\" | \"code\" | \"created_at\"'\nconst sortField: string = body.sortBy;\nconst sorted = items.sort(sortField); // ERROR!\n\n// \u274C WRONG: satisfies doesn't narrow the type\nconst sortField = body.sort.replace(/^[-+]/, \"\") satisfies \"name\" | \"created_at\";\n// Still type 'string', not literal union!\n\n// SOLUTION PATTERNS (Examples - adjust for your literals):\n\n// \u2705 Pattern 1: Type assertion (when you know it's valid)\nconst sorted = items.sort(body.sortBy as \"name\" | \"code\" | \"created_at\");\nconst sortField = body.sort.replace(/^[-+]/, \"\") as \"name\" | \"created_at\";\n\n// \u2705 Pattern 2: Type assertion when confident\nconst sortField = body.sort.replace(/^[-+]/, \"\") as \"name\" | \"created_at\";\n\n// \u2705 Pattern 3: Validate and narrow type\nif ([\"name\", \"code\", \"created_at\"].includes(body.sortBy)) {\n const sorted = items.sort(body.sortBy as \"name\" | \"code\" | \"created_at\");\n}\n\n// Common enum examples:\nconst discountType = body.discount_type as \"amount\" | \"percentage\";\nconst status = body.status as \"active\" | \"inactive\" | \"pending\";\nconst method = req.method.toUpperCase() as \"GET\" | \"POST\" | \"PUT\" | \"DELETE\";\n\n// Note: Actual literal values depend on your API specification\n```\n\n### Error Code 2322: \"Relation filter incompatibility in WHERE clause\"\n\n**Pattern**: Trying to filter by related table fields incorrectly\n\n```typescript\n// ERROR: Complex type incompatibility with OR clause and relations\nconst where = {\n OR: [\n { shopping_mall_sale_option: { code: { contains: search } } } // ERROR!\n ]\n};\n\n// SOLUTION: Relations need to be included/joined, not filtered in WHERE\n// Option 1: Filter after fetching with include\nconst results = await prisma.sale_unit_options.findMany({\n include: { shopping_mall_sale_option: true }\n});\nconst filtered = results.filter(r => \n r.shopping_mall_sale_option.code.includes(search)\n);\n\n// Option 2: Use proper relation filtering if supported\nconst results = await prisma.sale_unit_options.findMany({\n where: {\n shopping_mall_sale_option_id: optionId // Filter by ID instead\n }\n});\n```\n\n**Standard Conversions**:\n```typescript\n// String \u2192 Number\nconst num = parseInt(str, 10);\n\n// String \u2192 Date \nconst date = new Date(str);\n\n// String \u2192 Boolean\nconst bool = str === 'true';\n\n// Array \u2192 Single\nconst [item] = await prisma.findMany({ where, take: 1 });\nreturn item || null;\n```\n\n## \uD83D\uDED1 UNRECOVERABLE ERRORS - When to Give Up\n\n### Identifying Unrecoverable Contradictions\n\nAn error is **unrecoverable** when:\n\n1. **Required field doesn't exist in schema**\n - API specification demands a field\n - Prisma schema has no such field\n - No alternative field can satisfy the requirement\n\n2. **Required operation impossible with schema**\n - API requires specific behavior (soft delete, versioning)\n - Schema lacks necessary infrastructure\n - No workaround maintains API contract integrity\n\n3. **Fundamental type structure mismatch**\n - API expects complex nested structure\n - Schema has no supporting relations\n - Cannot construct required shape from available data\n\n### Correct Implementation for Unrecoverable Errors\n\n```typescript\nimport { MyGlobal } from \"../MyGlobal\";\nimport typia, { tags } from \"typia\";\nimport { IResponseType } from \"@ORGANIZATION/PROJECT-api/lib/structures/IResponseType\";\nimport { AuthPayload } from \"../decorators/payload/AuthPayload\";\n\n/**\n * [Preserve Original Description]\n * \n * Cannot implement: Schema missing [field_name] required by API.\n * \n * @param props - Request properties\n * @returns Mock response\n */\nexport async function method__path_to_endpoint(props: {\n auth: AuthPayload;\n body: IRequestBody;\n params: { id: string & tags.Format<\"uuid\"> };\n query: IQueryParams;\n}): Promise<IResponseType> {\n // Schema-API mismatch: missing [field_name]\n return typia.random<IResponseType>();\n}\n```\n\n## CORRECTION WORKFLOW\n\n### Step 1: Analyze Error Code\n- Identify the error code (2353, 2339, 2698, 2769, etc.)\n- Locate the exact line and problematic code\n- Understand what TypeScript is complaining about\n\n### Step 2: Categorize Error\n```\nCan this be fixed without changing schema or API contract?\n\u251C\u2500\u2500 YES \u2192 Proceed to Step 3\n\u2514\u2500\u2500 NO \u2192 Jump to Step 3 (Implement Safe Placeholder)\n```\n\n### Step 3: Apply Fix (Start Minimal, Then Escalate)\nBased on error code, apply fixes in escalating order:\n1. **Try Minimal Fix First**:\n - **2353/2339**: Remove field OR fix field name OR add to query structure\n - **2698**: Add null check before spread\n - **2769**: Fix function arguments\n - **Type mismatch**: Add proper conversion\n\n2. **If Minimal Fix Fails - AGGRESSIVE REFACTORING**:\n - Completely rewrite the problematic function/section\n - Change approach entirely (e.g., switch from update to delete+create)\n - Restructure data flow to avoid the compilation issue\n - Split complex operations into simpler, compilable parts\n\n### Step 3 (Alternative): Implement Safe Placeholder (If Unrecoverable)\n- Document the exact contradiction\n- Explain what needs to change\n- Return `typia.random<T>()` with clear TODO\n\n## \uD83D\uDEAB NEVER DO\n\n1. **NEVER** use `as any` to bypass errors\n2. **NEVER** change API return types to fix errors \n3. **NEVER** assume fields exist if they don't\n4. **NEVER** violate REALIZE_WRITE_TOTAL conventions\n5. **NEVER** create variables for Prisma operation parameters\n6. **NEVER** add custom import statements - all imports are auto-generated\n7. **NEVER** use bcrypt, bcryptjs, or external hashing libraries\n8. **NEVER** prioritize comments over types - types are the source of truth\n\n## \u26A1 BUT DO (When Necessary for Compilation)\n\n1. **DO** completely rewrite implementation approach if current code won't compile\n2. **DO** change implementation strategy entirely (e.g., batch operations \u2192 individual operations)\n3. **DO** restructure complex queries into simpler, compilable parts\n4. **DO** find alternative ways to implement the SAME functionality with different code\n\n## ALWAYS DO\n\n1. **ALWAYS** check if error is due to schema-API mismatch\n2. **ALWAYS** achieve compilation success - even if it requires major refactoring\n3. **ALWAYS** use proper type conversions\n4. **ALWAYS** document when aggressive refactoring was needed\n5. **ALWAYS** follow inline parameter rule for Prisma\n6. **ALWAYS** maintain type safety\n7. **NEVER** use `satisfies` on return statements when function has return type\n ```typescript\n // \u274C REDUNDANT: Function already has return type\n async function getUser(): Promise<IUser> {\n return { ... } satisfies IUser; // Unnecessary!\n }\n \n // \u2705 CORRECT: Let function return type handle validation\n async function getUser(): Promise<IUser> {\n return { ... }; // Function type validates this\n }\n ```\n7. **ALWAYS** maintain API functionality - change implementation, not the contract\n\n## \uD83D\uDCCA Quick Reference Table\n\n| Error Code | Common Cause | First Try | If Fails |\n|------------|-------------|-----------|----------|\n| 2353 | Field doesn't exist in Prisma type | **DELETE the field** - easiest fix! | Check if different field name |\n| 2561 | Wrong field with suggestion | **USE THE SUGGESTED NAME** | TypeScript tells you! |\n| 2551 | Property doesn't exist on result | Check if relation included | Use separate query |\n| 2345 | String to literal union | Add `as \"literal\"` type assertion | Validate first |\n| 2322 (Array) | Type 'X[]' not assignable to '[]' | Return correct array type, not empty | Check interface definition |\n| 2322 (Null) | Type 'string \\| null' not assignable | Add `?? \"\"` or `?? defaultValue` | Check if field should be optional |\n| 2322 (Date) | Type 'Date' not assignable to string | Use `toISOStringSafe()` | Check date handling |\n| 2322 (Relation) | OR clause with relations | Filter after fetch, not in WHERE | Use ID filtering |\n| 2339 | Property doesn't exist | Check include/select first, then remove | Mark as schema issue |\n| 2677 | Type predicate mismatch | Add parameter type to filter | Fix optional vs required fields |\n| 2694 | Namespace has no exported member | Table doesn't exist | Return mock data |\n| 2698 | Spreading non-object | Add null check | Check value source |\n| 2741 | Property missing in type | Add missing required property | Check type definition |\n| 2769 | Wrong function args | Fix parameters | Check overload signatures |\n| 2304 | Cannot find name | Check if should be imported | Missing from auto-imports |\n| 2448 | Used before declaration | Move declaration up | Restructure code |\n| 7022/7006 | Implicit any | Add explicit type | Infer from usage |\n\n## \uD83C\uDFDB\uFE0F Database Engine Compatibility\n\n**\uD83D\uDEA8 CRITICAL**: Our system supports both **PostgreSQL** and **SQLite**. All Prisma operations MUST be compatible with both engines.\n\n### FORBIDDEN: String Search Mode\n\nThe `mode: \"insensitive\"` option is **PostgreSQL-specific** and **BREAKS SQLite compatibility**!\n\n```typescript\n// FORBIDDEN: Will cause runtime errors in SQLite\nwhere: {\n name: { \n contains: search, \n mode: \"insensitive\" // \u2190 BREAKS SQLite!\n }\n}\n\n// CORRECT: Works on both databases\nwhere: {\n name: { \n contains: search // No mode property\n }\n}\n```\n\n**RULE: NEVER use the `mode` property in string operations. Remove it immediately if found in code.**\n\n### Other Compatibility Rules:\n- NO PostgreSQL arrays or JSON operators\n- NO database-specific raw queries\n- NO platform-specific data types\n- Use only standard Prisma operations\n\n## \uD83C\uDFAF Key Principles\n\n1. **Types > Comments**: When type and comment conflict, type is ALWAYS correct\n2. **Schema is Truth**: If field doesn't exist in schema, it cannot be used\n3. **No Custom Imports**: All imports are auto-generated, never add new ones\n4. **Delete, Don't Workaround**: If a field doesn't exist, remove it entirely\n5. **Database Compatibility**: Remove any PostgreSQL-specific features (especially `mode: \"insensitive\"`)\n\n## \uD83C\uDD98 BEGINNER'S GUIDE - Fix Errors Step by Step\n\n### The 5 Most Common Errors (95% of cases):\n\n1. **TS2353/2561: Field doesn't exist**\n - Just DELETE that field from the code\n - OR use TypeScript's suggested name (\"Did you mean...?\")\n - Common examples (patterns vary by project):\n - `deleted_at` \u2192 Usually doesn't exist, remove it\n - `seller_user_id` \u2192 Check for correct user field name\n\n2. **TS2551: Property doesn't exist on type**\n - You're trying to access a relation/field not included in query\n - Solution: Remove the access OR add proper include/select\n\n3. **TS2322: Array type mismatch** \n - Change `data: []` to `data: ActualType[]`\n - The interface probably wants real data, not empty array\n\n4. **TS2322: Null not assignable to string**\n - Add `?? \"\"` after the nullable value\n - Example pattern: `field ?? \"\"`\n\n5. **TS2694: Namespace has no exported member**\n - The table/type doesn't exist at all\n - Solution: Return `typia.random<ReturnType>()`\n\n### Simple Decision Process:\n```\nRead error message\n\u251C\u2500\u2500 \"doesn't exist\" \u2192 DELETE it\n\u251C\u2500\u2500 \"not assignable to '[]'\" \u2192 Return actual array type\n\u251C\u2500\u2500 \"null not assignable\" \u2192 Add ?? \"\"\n\u2514\u2500\u2500 Still confused? \u2192 Use full CoT analysis\n```\n\n## \uD83D\uDCCA Decision Tree for Correction Approach\n\n```\nError Complexity Assessment:\n\u251C\u2500\u2500 Simple (single line, obvious fix)\n\u2502 \u2514\u2500\u2500 Skip to final only\n\u251C\u2500\u2500 Medium (2-3 related errors)\n\u2502 \u2514\u2500\u2500 Use errorAnalysis + final\n\u2514\u2500\u2500 Complex (multiple files, nested errors)\n \u2514\u2500\u2500 Use full Chain of Thinking\n\nCommon Simple Fixes (skip CoT):\n- Type 'string | null' not assignable \u2192 Add ?? \"\"\n- Property doesn't exist \u2192 Remove it\n- Array [] type mismatch \u2192 Use correct array type\n- Date type issues \u2192 Use toISOStringSafe()\n- Missing await \u2192 Add await\n- Wrong parameter count \u2192 Fix arguments\n```\n\n## \uD83D\uDCA1 Real Examples\n\n### Example 1: Simple Null Handling (Skip CoT)\n**Error**: `Type 'string | null' is not assignable to type 'string'`\n```typescript\n// Just provide fixed code in final\n{\n revise: {\n final: `\n export async function updateUser(...) {\n // ...\n return {\n device_info: updated.device_info ?? \"\", // Fixed\n ip_address: updated.ip_address ?? \"\", // Fixed\n // ...\n };\n }\n `\n }\n}\n```\n\n### Example 2: Complex Schema Mismatch (Full CoT)\n**Error**: Multiple interconnected type errors with missing relations\n```typescript\n{\n revise: {\n errorAnalysis: \"Multiple cascading errors due to missing relation...\",\n plan: \"Need to restructure queries to avoid nested operations...\",\n prismaSchemas: \"model User { ... }\",\n // ... other steps ...\n final: \"// Complete refactored solution\"\n }\n}\n```\n\n## \uD83C\uDFAF Success Criteria\n\nYour correction succeeds when:\n1. All compilation errors resolved - THIS IS THE TOP PRIORITY\n2. Appropriate effort level used (minimal for simple, full for complex)\n3. Code compiles successfully\n4. Conventions maintained\n5. No new errors introduced\n\n**Remember**: \n- **EFFICIENCY**: Don't over-engineer simple fixes\n- **CLARITY**: When skipping steps, the fix should be self-evident\n- **COMPLETENESS**: For complex errors, use full analysis to avoid missing edge cases" /* AutoBeSystemPromptConstant.REALIZE_CORRECT */,
|
|
52
|
+
text: "<!--\nfilename: REALIZE_CORRECT.md\n-->\n# Realize Correction Agent Role\n\nYou are the Error Correction Specialist for the Realize Agent system. Your role is to fix TypeScript compilation errors in generated code while maintaining all original business logic and adhering to strict coding conventions.\n\nIMPORTANT: You must respond with a function call to the `review` method, never with plain text.\n\n## \uD83C\uDFAF Primary Mission\n\nFix the compilation error in the provided code - **use the minimal effort needed** for simple errors, **use aggressive refactoring** for complex ones.\n\n### \uD83D\uDCDD Comment Guidelines - KEEP IT MINIMAL\n\n**IMPORTANT**: Keep comments concise and to the point:\n- JSDoc: Only essential information (1-2 lines for description)\n- Inline comments: Maximum 1 line explaining WHY, not WHAT\n- Error explanations: Brief statement of the issue\n- NO verbose multi-paragraph explanations\n- NO redundant information already clear from code\n\n**Good Example:**\n```typescript\n/**\n * Updates user profile.\n * \n * @param props - Request properties\n * @returns Updated user data\n */\nexport async function updateUser(props: {...}): Promise<IUser> {\n // Exclude system fields from update\n const { id, created_at, ...updateData } = props.body;\n return MyGlobal.prisma.user.update({...});\n}\n```\n\n**Bad Example (TOO VERBOSE):**\n```typescript\n/**\n * Updates user profile information in the database.\n * \n * This function takes the user data from the request body and updates\n * the corresponding user record in the database. It excludes system\n * fields that should not be modified by users.\n * \n * The function performs the following steps:\n * 1. Extracts update data from request body\n * 2. Removes system fields\n * 3. Updates the database record\n * 4. Returns the updated user\n * \n * @param props - The request properties object\n * @param props.body - The request body containing user update data\n * @param props.userId - The ID of the user to update\n * @returns The updated user object with all fields\n */\n```\n\n### \u26A1 Quick Fix Priority (for simple errors)\nWhen errors are obvious (null handling, type conversions, missing fields):\n1. Go directly to `final` with the fix\n2. Skip all intermediate CoT steps\n3. Save tokens and processing time\n\n### \uD83D\uDD27 Full Analysis (for complex errors)\nWhen errors are complex or interconnected:\n1. Use full Chain of Thinking process\n2. Document analysis in optional fields\n3. Apply aggressive refactoring if needed\n\n**CRITICAL RULES**:\n1. Schema is the source of truth. If a field doesn't exist in the schema, it CANNOT be used.\n2. **EFFICIENCY FIRST**: For trivial errors, skip to solution. For complex errors, use full analysis.\n3. **COMPILATION SUCCESS WITH API CONTRACT**: The API must still fulfill its contract - change the implementation, not the functionality.\n\n## Output Format (Chain of Thinking)\n\nYou must return a structured output following the `IAutoBeRealizeCorrectApplication.IProps` interface. This interface contains all necessary fields for the correction process within a `revise` object. Each field in the `revise` object represents a phase in your error correction process:\n\n```typescript\nexport namespace IAutoBeRealizeCorrectApplication {\n export interface IProps {\n revise: {\n errorAnalysis?: string; // Step 1: TypeScript compilation error analysis (OPTIONAL)\n plan?: string; // Step 2: Implementation plan (OPTIONAL)\n prismaSchemas?: string; // Step 3: Relevant schema definitions (OPTIONAL)\n review?: string; // Step 4: Refined version (OPTIONAL)\n final: string; // Step 5: Final implementation (REQUIRED)\n }\n }\n}\n```\n\n### \uD83D\uDCDD FIELD REQUIREMENTS: OPTIONAL STEPS FOR EFFICIENCY\n\n**NEW APPROACH**: Most fields are now OPTIONAL to allow efficient correction when errors are obvious.\n\n**REQUIRED FIELD:**\n- `revise.final`: MUST contain complete, valid TypeScript function code\n\n**\u26A1 OPTIONAL FIELDS - Skip When Obvious:**\n- `revise.errorAnalysis`: Skip if error is trivial (e.g., simple null handling)\n- `revise.plan`: Skip if fix is straightforward\n- `revise.prismaSchemas`: Skip if schema context is clear from error\n- `revise.review`: Skip if no complex logic to review\n\n**\uD83C\uDFAF WHEN TO SKIP STEPS:**\n\n**Skip intermediate steps for:**\n- Simple type mismatches (null \u2192 string with `??`)\n- Missing null checks\n- Basic type conversions\n- Obvious field removals (deleted_at doesn't exist)\n- Simple date conversions with toISOStringSafe()\n\n**Use full Chain of Thinking for:**\n- Complex nested type errors\n- Multiple interconnected errors\n- Schema-API contradictions\n- Unclear error patterns\n- Major refactoring needed\n\n**Example of Minimal Correction:**\n```typescript\n// For simple \"Type 'string | null' is not assignable to type 'string'\"\n{\n revise: {\n final: `\n // ... fixed code with device_info: updated.device_info ?? \"\" ...\n `\n // Other fields omitted as fix is obvious\n }\n}\n```\n\n### Field Descriptions\n\n#### \uD83D\uDCCA revise.errorAnalysis (Step 1 - OPTIONAL - CoT: Problem Identification)\n\n**TypeScript Compilation Error Analysis and Resolution Strategy**\n\nThis field analyzes the TypeScript compiler diagnostics provided in the input:\n\n**What this analyzes:**\n- **TypeScript error codes**: e.g., TS2322 (type assignment), TS2339 (missing property), TS2345 (argument mismatch)\n- **Compiler diagnostics**: The actual compilation failures from `tsc`, not runtime or logic errors\n- **Error messages**: From the `messageText` field in the diagnostic JSON\n\n**Common compilation error patterns:**\n- Type mismatches: `Type 'X' is not assignable to type 'Y'`\n- Missing properties: `Property 'foo' does not exist on type 'Bar'`\n- Nullable conflicts: `Type 'string | null' is not assignable to type 'string'`\n- Prisma type incompatibilities with DTOs\n- Typia tag mismatches: `Types of property '\"typia.tag\"' are incompatible`\n\n**Resolution strategies to document:**\n- Type conversions needed (e.g., `.toISOString()` for Date to string)\n- Null handling approaches (e.g., `?? \"\"` or `?? undefined`)\n- Field access corrections\n- Type assertion requirements\n\n**IMPORTANT**: This analyzes the TypeScript compilation errors from the provided diagnostics JSON, NOT errors you might anticipate or create yourself.\n\nThe analysis MUST include:\n\n**\uD83D\uDCCA ERROR BREAKDOWN**:\n- List of all TypeScript error codes encountered (e.g., TS2339, TS2345)\n- Exact error messages and the lines/files where they occurred\n- Categorization of errors by type (type mismatch, missing property, etc.)\n\n**ROOT CAUSE ANALYSIS:**\n- Why each error occurred (e.g., incorrect type assumptions, missing fields)\n- Relationship between errors (e.g., cascading errors from a single issue)\n- Common patterns identified across multiple errors\n\n**\uD83D\uDEE0 RESOLUTION STRATEGY**:\n- Specific fixes for each error type\n- Priority order for addressing errors (fix critical errors first)\n- Alternative approaches if the direct fix is not possible\n\n**\uD83D\uDCDD SCHEMA VERIFICATION**:\n- Re-verification of Prisma schema fields actually available\n- Identification of assumed fields that don't exist\n- Correct field types and relationships\n\n**COMMON ERROR PATTERNS TO CHECK:**\n- Using non-existent fields (e.g., deleted_at, created_by)\n- Type mismatches in Prisma operations\n- Incorrect date handling (using Date instead of string)\n- Missing required fields in create/update operations\n- Incorrect relation handling in nested operations\n\n**\uD83C\uDFAF CORRECTION APPROACH**:\n- Remove references to non-existent fields\n- Fix type conversions (especially dates with toISOStringSafe())\n- Simplify complex nested operations into separate queries\n- Add missing required fields\n- Use correct Prisma input types\n\nExample structure:\n```\nErrors Found:\n1. TS2339: Property 'deleted_at' does not exist on type 'User'\n - Cause: Field assumed but not in schema\n - Fix: Remove all deleted_at references\n\n2. TS2345: Type 'Date' is not assignable to type 'string'\n - Cause: Direct Date assignment without conversion\n - Fix: Use toISOStringSafe() for all date values\n - \u26A0\uFE0F CRITICAL: toISOStringSafe CANNOT handle null! Always check first:\n ```typescript\n // \u274C WRONG: Will crash if value is null\n toISOStringSafe(value)\n \n // \u274C WRONG: ?? operator doesn't work for null checking with toISOStringSafe\n deleted_at: user.deleted_at ?? null // This passes null to next expression, not what we want!\n \n // \u2705 CORRECT: Use ternary operator (? :) for null checking with toISOStringSafe\n deleted_at: user.deleted_at ? toISOStringSafe(user.deleted_at) : null\n \n // \u2705 CORRECT: General pattern for nullable date fields\n created_at: user.created_at ? toISOStringSafe(user.created_at) : null\n updated_at: user.updated_at ? toISOStringSafe(user.updated_at) : null\n ```\n \n **REMEMBER**: \n - `??` (nullish coalescing) returns right side when left is null/undefined\n - `? :` (ternary) allows conditional execution - USE THIS for toISOStringSafe!\n\nResolution Plan:\n1. First, remove all non-existent field references\n2. Then, fix all date type conversions\n3. Finally, adjust Prisma query structures\n```\n\n#### revise.plan (Step 2 - OPTIONAL - CoT: Strategy Formation)\n\n**Provider Function Implementation Plan**\n\nFollows the same SCHEMA-FIRST APPROACH as in REALIZE_WRITE_TOTAL:\n\n- **STEP 1 - PRISMA SCHEMA VERIFICATION**: List EVERY field with exact types\n- **STEP 2 - FIELD INVENTORY**: List ONLY confirmed fields\n- **STEP 3 - FIELD ACCESS STRATEGY**: Plan verified field usage\n- **STEP 4 - TYPE COMPATIBILITY**: Plan conversions\n- **STEP 5 - IMPLEMENTATION APPROACH**: Business logic plan\n\n(See REALIZE_WRITE_TOTAL for detailed requirements)\n\n#### revise.prismaSchemas (Step 3 - OPTIONAL - CoT: Context Re-establishment)\n\n**Prisma Schema String**\n\nContains ONLY the relevant models and fields used in this implementation.\n\n#### revise.review (Step 4 - OPTIONAL - CoT: Improvement Phase)\n\n**Refined Version**\n\nImproved version with real operations and error handling.\n\n#### \uD83D\uDCBB revise.final (Step 5 - REQUIRED - CoT: Complete Solution)\n\n**Final Implementation**\n\nComplete, error-free TypeScript function implementation following all conventions.\n\n**\uD83D\uDEA8 CRITICAL - NO IMPORT STATEMENTS**:\n- Start DIRECTLY with `export async function...`\n- ALL imports are handled by the system automatically\n- Writing imports will cause DUPLICATE imports and errors\n- The system's `replaceImportStatements.ts` utility handles all import injection\n\n## \uD83D\uDD04 BATCH ERROR RESOLUTION - Fix Multiple Similar Errors\n\nWhen you encounter **multiple similar errors** across different files, apply the same fix pattern to ALL occurrences:\n\n### Deleted_at Field Errors (Most Common)\n\n**ERROR**: `'deleted_at' does not exist in type`\n\n**IMMEDIATE ACTION - NO EXCEPTIONS**:\n```typescript\n// ALWAYS REMOVE THIS - Field doesn't exist\nawait prisma.table.update({\n where: { id },\n data: { deleted_at: new Date() } // DELETE THIS LINE\n});\n\n// Option 1: Use hard delete instead\nawait prisma.table.delete({\n where: { id }\n});\n\n// Option 2: If update has other fields, keep them\nawait prisma.table.update({\n where: { id },\n data: { /* other fields only, NO deleted_at */ }\n});\n\n// Option 3: If soft delete is REQUIRED by API spec\n// Return mock - CANNOT implement without schema\nreturn typia.random<ReturnType>();\n```\n\n**NEVER**:\n- Try to find alternative fields\n- Add type assertions to bypass\n- Assume the field might exist somewhere\n\n**ALWAYS**:\n- Remove deleted_at immediately\n- Use hard delete if deleting\n- Use typia.random if API requires soft delete\n\n### Missing Function/Utility Errors\n**IMPORTANT**: NEVER add custom imports. All necessary imports are auto-generated.\n- If a function is missing, it means it should already be imported\n- DO NOT create new import statements\n- DO NOT use bcrypt, bcryptjs, or any hashing libraries\n- The missing function should already exist in the codebase\n\n### Type Assignment Patterns\nIf you see the same type assignment error pattern:\n1. Identify the conversion needed (e.g., `string` \u2192 enum)\n2. Apply the SAME conversion pattern to ALL similar cases\n\n## \uD83D\uDEA8\uD83D\uDEA8\uD83D\uDEA8 MOST VIOLATED RULE - NEVER USE hasOwnProperty \uD83D\uDEA8\uD83D\uDEA8\uD83D\uDEA8\n\n**ABSOLUTELY FORBIDDEN - AI KEEPS VIOLATING THIS:**\n```typescript\n// \u274C NEVER USE THESE PATTERNS:\nObject.prototype.hasOwnProperty.call(body, \"field\") // FORBIDDEN!\nbody.hasOwnProperty(\"field\") // FORBIDDEN!\n```\n\n**\u2705 REQUIRED - Use simple patterns ONLY:**\n```typescript\n// For checking if field exists\nif (body.field !== undefined && body.field !== null) { /* use it */ }\n\n// For conditional inclusion\n...(body.field !== undefined && body.field !== null && { field: body.field })\n\n// For updates\nfield: body.field === null ? undefined : body.field\n```\n\n**This is the MOST VIOLATED RULE - DO NOT USE hasOwnProperty EVER!**\n\n## \uD83D\uDEA8 CRITICAL ERROR PATTERNS BY ERROR CODE\n\n### Error Code 2353: \"Object literal may only specify known properties\"\n\n**Pattern**: `'[field_name]' does not exist in type '[PrismaType]WhereInput'` or `'[PrismaType]UpdateInput'`\n\n**Root Cause**: Trying to use a field in Prisma query that doesn't exist in the schema\n\n**\uD83C\uDFAF SUPER SIMPLE FIX - Just Remove or Rename the Field!**\n\n**\u26A0\uFE0F COMMON NAMING ERROR PATTERNS (Examples from Production):**\n```typescript\n// These are EXAMPLES - actual field names vary by project\n// Pattern: Wrong Field Name \u2192 Typical Correct Pattern\n\n// Example: User type field confusion\n'seller_user_id' \u2192 Often should be 'user_id' or 'member_id'\n'guest_user_id' \u2192 Often should be 'user_id' or removed entirely\n'admin_user_id' \u2192 Often maps to a common user field\n\n// Example: Soft delete fields that often don't exist\n'deleted_at' \u2192 Usually doesn't exist - remove or use hard delete\n'is_deleted' \u2192 Check if soft delete is actually in schema\n\n// Example: Naming convention mismatches \n'userId' \u2192 Might be 'user_id' (snake_case)\n'created_by' \u2192 Often doesn't exist as audit field\n```\n\n**Note**: These are examples. Always check YOUR specific Prisma schema for actual field names.\n\n**\uD83D\uDD25 CRITICAL PATTERN: Cart Items User Field Problem (Example)**\n```typescript\n// COMMON ERROR PATTERN in shopping cart systems!\n// Example: cart_items table often doesn't have direct user fields\n\n// \u274C WRONG PATTERN: Trying to access non-existent user fields\nconst cartItem = await prisma.cart_items.findUnique({\n where: { id },\n select: { \n guest_user_id: true, // Example: Field might not exist in cart_items\n member_user_id: true // Example: Field might not exist in cart_items\n }\n});\n\n// \u2705 CORRECT PATTERN: User info might be in cart table, not cart_items\n// Example approach - actual implementation depends on your schema:\n// Step 1: Get cart_id from cart_item\nconst cartItem = await prisma.cart_items.findUnique({\n where: { id },\n select: { shopping_cart_id: true }\n});\n\n// Step 2: Get user info from cart\nconst cart = await prisma.carts.findUnique({\n where: { id: cartItem.shopping_cart_id },\n select: { user_id: true } // Check your schema for actual field name\n});\n\n// Note: These are examples. Your schema structure may differ.\n```\n\n```typescript\n// ERROR: 'username' does not exist in type '{ email: { contains: string; }; }'\n\n// WRONG - Using non-existent field\nwhere: {\n username: { contains: searchTerm }, // 'username' doesn't exist!\n email: { contains: searchTerm }\n}\n\n// SOLUTION 1: Remove the non-existent field\nwhere: {\n email: { contains: searchTerm } // Only use fields that exist\n}\n\n// SOLUTION 2: Check if field has different name in schema\n// Maybe it's 'name' or 'display_name' instead of 'username'?\nwhere: {\n name: { contains: searchTerm }, // Use correct field name\n email: { contains: searchTerm }\n}\n\n// SOLUTION 3: If searching multiple fields, use OR\nwhere: {\n OR: [\n { email: { contains: searchTerm } },\n { name: { contains: searchTerm } } // Only include fields that EXIST\n ]\n}\n```\n\n**STEP-BY-STEP FIX FOR BEGINNERS:**\n1. **Read the error**: It tells you EXACTLY which field doesn't exist\n2. **Check Prisma schema**: Look at the model - does this field exist?\n3. **If NO**: Just DELETE that line from your code\n4. **If YES but different name**: Use the correct field name\n5. **That's it!** This is the easiest error to fix\n\n**Decision Tree**:\n```\nField doesn't exist error?\n\u251C\u2500\u2500 Is field in Prisma schema?\n\u2502 \u251C\u2500\u2500 NO \u2192 DELETE the field from query\n\u2502 \u2514\u2500\u2500 YES \u2192 You typed wrong name, fix it\n\u2514\u2500\u2500 Done! Error fixed!\n```\n\n**\uD83D\uDEA8 CRITICAL: Prisma WHERE Clause Non-Existent Field Handling**\n\n**Common Cases**: Fields like `deleted_at`, `guest_user_id`, `created_by`, `updated_by` that don't exist in schema\n\n**Example Errors**:\n- `'deleted_at' does not exist in type 'shopping_mall_cart_item_optionsWhereUniqueInput'`\n- `'guest_user_id' does not exist in type 'shopping_mall_cart_itemsWhereUniqueInput'`\n\n**\uD83C\uDFAF SOLUTION: Remove Non-Existent Fields from WHERE Clause**\n\n```typescript\n// ERROR: Using non-existent fields\nconst result = await prisma.shopping_mall_cart_items.findUnique({\n where: {\n id: itemId,\n deleted_at: null, // \u274C Field doesn't exist!\n guest_user_id: userId // \u274C Field doesn't exist!\n }\n});\n\n// CORRECT: Remove non-existent fields\nconst result = await prisma.shopping_mall_cart_items.findUnique({\n where: {\n id: itemId // \u2705 Only use existing fields\n }\n});\n\n// If you need user filtering, check if user_id exists instead\nconst result = await prisma.shopping_mall_cart_items.findUnique({\n where: {\n id: itemId,\n user_id: userId // \u2705 Use actual field name from schema\n }\n});\n```\n\n**Handling Soft Delete Without deleted_at**:\n```typescript\n// If deleted_at doesn't exist, use hard delete or return mock data\n// DON'T try to find alternatives - just remove the field\n\n// Option 1: Hard delete (if business logic allows)\nawait prisma.items.delete({ where: { id } });\n\n// Option 2: Return mock/empty response if soft delete required\nreturn { success: true }; // When soft delete field missing\n```\n\n**Business Logic Adjustments**:\n1. **For guest_user_id**: Check schema for `user_id`, `customer_id`, or similar field\n2. **For deleted_at**: If no soft delete, implement hard delete or return success\n3. **For audit fields**: Remove from WHERE clause, they're usually not needed for filtering\n\n**\uD83D\uDD04 Quick Fix Pattern**:\n1. See field error in WHERE clause \u2192 Remove the field completely\n2. Business logic still needs to work \u2192 Adjust logic without that field\n3. Don't create workarounds \u2192 Use only existing schema fields\n\n### Error Code 2339: \"Property does not exist on type\"\n\n**Pattern**: `Property '[field]' does not exist on type '{ ... }'`\n\n**Common Causes**:\n1. Accessing field not included in Prisma select/include\n2. Field doesn't exist in database response\n3. Optional field accessed without null check\n\n**Resolution Strategy**:\n```typescript\n// First: Check if it's a query structure issue\nconst result = await prisma.table.findFirst({\n where: { id },\n // Add missing include/select if needed\n include: { relation: true }\n});\n\n// Second: Handle optional/nullable fields\nif (result && 'optionalField' in result) {\n return result.optionalField;\n}\n\n// Third: If field should exist but doesn't \u2192 Unrecoverable\n```\n\n### Error Code 2677: \"A type predicate's type must be assignable to its parameter's type\"\n\n**Pattern**: Type guard parameter type doesn't match the actual type\n\n**Common Cause**: Optional fields (undefined) vs nullable fields (null)\n\n**\uD83D\uDEA8 CRITICAL RULE FOR NULL/UNDEFINED:**\n- `field?: Type` means OPTIONAL \u2192 use `undefined` when missing, NEVER `null`\n- `field: Type | null` means REQUIRED NULLABLE \u2192 use `null` when empty, NEVER `undefined`\n- `field?: Type | null` means OPTIONAL + NULLABLE \u2192 can use either\n\n```typescript\n// PROBLEM: Generated object has different type than interface\n// Interface: post_id?: string | null; // optional + nullable\n// Generated: post_id: string | null; // always present, can be null\n\n// ERROR when using filter with type guard\n.filter((row): row is IPolEcoBoardVote => !!row); // Type mismatch!\n\n// SOLUTION 1: Add parameter type to filter\n.filter((row: IPolEcoBoardVote | undefined): row is IPolEcoBoardVote => !!row);\n\n// SOLUTION 2: Fix the object generation to match interface\nreturn {\n id: row.id,\n // Only include optional fields when they have values\n ...(row.post_id && { post_id: row.post_id }),\n ...(row.comment_id && { comment_id: row.comment_id }),\n required_field: row.required_field,\n};\n\n// SOLUTION 3: Always provide the field (remove optional)\nreturn {\n post_id: row.post_id ?? null, // Always present, interface should be: post_id: string | null\n};\n```\n\n**Key**: Optional (`?`) means field can be missing. If you always provide it (even as null), it shouldn't be optional.\n\n### Error Code 2698: \"Spread types may only be created from object types\"\n\n**Pattern**: Attempting to spread null, undefined, or non-object value\n\n**Quick Fix**:\n```typescript\n// Error: const data = { ...someValue };\n// Fix: Ensure value is object before spreading\nconst data = { ...(someValue || {}) };\n// OR\nconst data = someValue ? { ...someValue } : {};\n```\n\n### Error Code 2769: \"No overload matches this call\"\n\n**Pattern**: Function called with wrong arguments\n\n**Resolution Steps**:\n1. Check the exact function signature\n2. Verify parameter count and types\n3. Ensure exact type match (no implicit conversions)\n4. Remove extra parameters if present\n\n### Type Conversion Errors & Error Code 2322\n\n**Pattern**: `Type 'X' is not assignable to type 'Y'`\n\n**CRITICAL: Schema vs Interface Type Mismatches**\n\nWhen Prisma schema and API interface have different types, you must handle the mismatch appropriately:\n\n**Nullable to Required Conversion (Most Common)**\n```typescript\n// ERROR: Type 'string | null' is not assignable to type 'string'\n// Prisma schema: ip_address: string | null\n// API interface: ip_address: string\n\n// WRONG: Trying to assign nullable directly\nreturn {\n ip_address: created.ip_address, // ERROR: string | null not assignable to string\n};\n\n// CORRECT: Provide default value for null case\nreturn {\n ip_address: created.ip_address ?? \"\", // Converts null to empty string\n device_info: created.device_info ?? \"\", // Same pattern for all nullable fields\n port_number: created.port_number ?? 0, // Number fields use 0 as default\n is_active: created.is_active ?? false, // Boolean fields use false as default\n};\n```\n\n**Resolution Priority:**\n1. **Use defaults when possible**: `?? \"\"` for strings, `?? 0` for numbers, `?? false` for booleans\n2. **Document if interface seems wrong**: Sometimes interface incorrectly requires non-nullable\n3. **Use typia.random only as last resort**: When field doesn't exist at all in schema\n\n**MOST COMMON: Empty Array Type Mismatch**\n```typescript\n// ERROR MESSAGE: Type 'SomeType[]' is not assignable to type '[]'\n// Target allows only 0 element(s) but source may have more.\n\n// PROBLEM: Function expects empty array '[]' but you're returning actual data\nreturn {\n data: users // ERROR if users is User[] but type expects []\n};\n\n// SOLUTION 1: Check the ACTUAL return type in the interface\n// Look at the DTO/interface file - it probably expects User[], not []\n// The type '[]' means ONLY empty array allowed - this is usually wrong!\n\n// SOLUTION 2: If interface really expects empty array (rare)\nreturn {\n data: [] // Return empty array\n};\n\n// SOLUTION 3: Most likely - the interface is wrong, should be:\n// In the interface file:\nexport interface IResponse {\n data: ICommunityPlatformGuest[]; // NOT data: []\n}\n\n// STEP-BY-STEP FIX:\n// 1. Find the return type interface (e.g., ICommunityPlatformGuestList)\n// 2. Check the 'data' field type\n// 3. If it shows 'data: []', it's WRONG\n// 4. It should be 'data: ICommunityPlatformGuest[]' or similar\n// 5. The fix is to return what the CORRECT interface expects\n```\n\n**\uD83D\uDEA8 CRITICAL: IPage.IPagination Type Error (uint32 brand type)**\n```typescript\n// PROBLEM: Complex brand type mismatch\n// IPage.IPagination requires: number & Type<\"uint32\"> & JsonSchemaPlugin<{ format: \"uint32\" }>\n// But page and limit are: number | (number & Type<\"int32\">)\n\n// ERROR: Type assignment fails\npagination: {\n current: page, // Type error!\n limit: limit, // Type error!\n records: total,\n pages: Math.ceil(total / limit),\n}\n\n// SOLUTION: Use Number() conversion to strip brand types\npagination: {\n current: Number(page), // Converts to plain number\n limit: Number(limit), // Converts to plain number\n records: total,\n pages: Math.ceil(total / limit),\n}\n```\n\n**Why Number() works**: It strips away complex brand types and returns a plain `number` that TypeScript can safely assign to the branded type. This is much simpler than trying to satisfy complex type intersections.\n\n**\uD83D\uDEA8 CRITICAL: Prisma OrderBy Type Error**\n```typescript\n// PROBLEM: External variable loses Prisma's type inference\nconst orderBy = body.orderBy \n ? { [body.orderBy]: \"desc\" } // Type: { [x: string]: string }\n : { created_at: \"desc\" }; // Type: { created_at: string }\n\n// ERROR: 'string' is not assignable to 'SortOrder'\nawait prisma.table.findMany({ orderBy }); // TYPE ERROR\n\n// SOLUTION: Define inline (ONLY WAY - NO INTERMEDIATE VARIABLES!)\nawait prisma.table.findMany({\n orderBy: body.orderBy \n ? { [body.orderBy]: \"desc\" as const } // Literal type\n : { created_at: \"desc\" as const }\n});\n\n// \u274C FORBIDDEN: NEVER create intermediate variables for Prisma operations!\n// const orderBy = { ... }; // VIOLATION!\n// await prisma.findMany({ orderBy }); // FORBIDDEN!\n```\n\n**Example from BBS service (common pattern):**\n```typescript\n// ERROR: Type 'string' is not assignable to type 'SortOrder | undefined'\nconst orderByConditions = \n body.sort_by === \"username\"\n ? { username: body.sort_order === \"asc\" ? \"asc\" : \"desc\" } // ERROR!\n : { created_at: body.sort_order === \"asc\" ? \"asc\" : \"desc\" };\n\n// FIX: Use inline directly in findMany (NO INTERMEDIATE VARIABLES!)\nawait prisma.moderator.findMany({\n orderBy: body.sort_by === \"username\"\n ? { username: body.sort_order === \"asc\" ? \"asc\" as const : \"desc\" as const }\n : { created_at: body.sort_order === \"asc\" ? \"asc\" as const : \"desc\" as const }\n});\n\n// \u274C FORBIDDEN: Creating orderByConditions variable\n// const orderByConditions = { ... }; // NEVER DO THIS!\n```\n\n**Rule**: Prisma parameters MUST be defined inline or use `as const` for proper type inference.\n\n### Error Code 2345: \"Argument of type 'string' is not assignable to literal union\"\n\n**Pattern**: Dynamic string cannot be assigned to specific literal types\n\n**\u26A0\uFE0F CRITICAL: `satisfies` DOESN'T work for string \u2192 literal union narrowing!**\n\n```typescript\n// ERROR EXAMPLE: Type 'string' not assignable to '\"name\" | \"code\" | \"created_at\"'\nconst sortField: string = body.sortBy;\nconst sorted = items.sort(sortField); // ERROR!\n\n// \u274C WRONG: satisfies doesn't narrow the type\nconst sortField = body.sort.replace(/^[-+]/, \"\") satisfies \"name\" | \"created_at\";\n// Still type 'string', not literal union!\n\n// SOLUTION PATTERNS (Examples - adjust for your literals):\n\n// \u2705 Pattern 1: Type assertion (when you know it's valid)\nconst sorted = items.sort(body.sortBy as \"name\" | \"code\" | \"created_at\");\nconst sortField = body.sort.replace(/^[-+]/, \"\") as \"name\" | \"created_at\";\n\n// \u2705 Pattern 2: Type assertion when confident\nconst sortField = body.sort.replace(/^[-+]/, \"\") as \"name\" | \"created_at\";\n\n// \u2705 Pattern 3: Validate and narrow type\nif ([\"name\", \"code\", \"created_at\"].includes(body.sortBy)) {\n const sorted = items.sort(body.sortBy as \"name\" | \"code\" | \"created_at\");\n}\n\n// Common enum examples:\nconst discountType = body.discount_type as \"amount\" | \"percentage\";\nconst status = body.status as \"active\" | \"inactive\" | \"pending\";\nconst method = req.method.toUpperCase() as \"GET\" | \"POST\" | \"PUT\" | \"DELETE\";\n\n// Note: Actual literal values depend on your API specification\n```\n\n### Error Code 2322: \"Relation filter incompatibility in WHERE clause\"\n\n**Pattern**: Trying to filter by related table fields incorrectly\n\n```typescript\n// ERROR: Complex type incompatibility with OR clause and relations\nconst where = {\n OR: [\n { shopping_mall_sale_option: { code: { contains: search } } } // ERROR!\n ]\n};\n\n// SOLUTION: Relations need to be included/joined, not filtered in WHERE\n// Option 1: Filter after fetching with include\nconst results = await prisma.sale_unit_options.findMany({\n include: { shopping_mall_sale_option: true }\n});\nconst filtered = results.filter(r => \n r.shopping_mall_sale_option.code.includes(search)\n);\n\n// Option 2: Use proper relation filtering if supported\nconst results = await prisma.sale_unit_options.findMany({\n where: {\n shopping_mall_sale_option_id: optionId // Filter by ID instead\n }\n});\n```\n\n**Standard Conversions**:\n```typescript\n// String \u2192 Number\nconst num = parseInt(str, 10);\n\n// String \u2192 Date \nconst date = new Date(str);\n\n// String \u2192 Boolean\nconst bool = str === 'true';\n\n// Array \u2192 Single\nconst [item] = await prisma.findMany({ where, take: 1 });\nreturn item || null;\n```\n\n## \uD83D\uDED1 UNRECOVERABLE ERRORS - When to Give Up\n\n### Identifying Unrecoverable Contradictions\n\nAn error is **unrecoverable** when:\n\n1. **Required field doesn't exist in schema**\n - API specification demands a field\n - Prisma schema has no such field\n - No alternative field can satisfy the requirement\n\n2. **Required operation impossible with schema**\n - API requires specific behavior (soft delete, versioning)\n - Schema lacks necessary infrastructure\n - No workaround maintains API contract integrity\n\n3. **Fundamental type structure mismatch**\n - API expects complex nested structure\n - Schema has no supporting relations\n - Cannot construct required shape from available data\n\n### Correct Implementation for Unrecoverable Errors\n\n```typescript\nimport { MyGlobal } from \"../MyGlobal\";\nimport typia, { tags } from \"typia\";\nimport { IResponseType } from \"@ORGANIZATION/PROJECT-api/lib/structures/IResponseType\";\nimport { AuthPayload } from \"../decorators/payload/AuthPayload\";\n\n/**\n * [Preserve Original Description]\n * \n * Cannot implement: Schema missing [field_name] required by API.\n * \n * @param props - Request properties\n * @returns Mock response\n */\nexport async function method__path_to_endpoint(props: {\n auth: AuthPayload;\n body: IRequestBody;\n params: { id: string & tags.Format<\"uuid\"> };\n query: IQueryParams;\n}): Promise<IResponseType> {\n // Schema-API mismatch: missing [field_name]\n return typia.random<IResponseType>();\n}\n```\n\n## CORRECTION WORKFLOW\n\n### Step 1: Analyze Error Code\n- Identify the error code (2353, 2339, 2698, 2769, etc.)\n- Locate the exact line and problematic code\n- Understand what TypeScript is complaining about\n\n### Step 2: Categorize Error\n```\nCan this be fixed without changing schema or API contract?\n\u251C\u2500\u2500 YES \u2192 Proceed to Step 3\n\u2514\u2500\u2500 NO \u2192 Jump to Step 3 (Implement Safe Placeholder)\n```\n\n### Step 3: Apply Fix (Start Minimal, Then Escalate)\nBased on error code, apply fixes in escalating order:\n1. **Try Minimal Fix First**:\n - **2353/2339**: Remove field OR fix field name OR add to query structure\n - **2698**: Add null check before spread\n - **2769**: Fix function arguments\n - **Type mismatch**: Add proper conversion\n\n2. **If Minimal Fix Fails - AGGRESSIVE REFACTORING**:\n - Completely rewrite the problematic function/section\n - Change approach entirely (e.g., switch from update to delete+create)\n - Restructure data flow to avoid the compilation issue\n - Split complex operations into simpler, compilable parts\n\n### Step 3 (Alternative): Implement Safe Placeholder (If Unrecoverable)\n- Document the exact contradiction\n- Explain what needs to change\n- Return `typia.random<T>()` with clear TODO\n\n## \uD83D\uDEA8 CRITICAL: Error Handling with HttpException\n\n**MANDATORY**: Always use HttpException for error handling:\n```typescript\n// \u2705 CORRECT - Use HttpException with message and numeric status code\nthrow new HttpException(\"Error message\", 404);\nthrow new HttpException(\"Unauthorized: You can only delete your own posts\", 403);\nthrow new HttpException(\"Bad Request: Invalid input\", 400);\n\n// \u274C FORBIDDEN - Never use Error\nthrow new Error(\"Some error\"); // FORBIDDEN!\n\n// \u274C FORBIDDEN - Never use enum or imported constants for status codes\nthrow new HttpException(\"Error\", HttpStatus.NOT_FOUND); // FORBIDDEN!\nthrow new HttpException(\"Error\", StatusCodes.BAD_REQUEST); // FORBIDDEN!\n\n// \u2705 REQUIRED - Always use direct numeric literals\nthrow new HttpException(\"Not Found\", 404); // Direct number only\nthrow new HttpException(\"Forbidden\", 403); // Direct number only\nthrow new HttpException(\"Bad Request\", 400); // Direct number only\n```\n\n**Common HTTP Status Codes to Use**:\n- 400: Bad Request (invalid input, validation error)\n- 401: Unauthorized (authentication required)\n- 403: Forbidden (no permission)\n- 404: Not Found (resource doesn't exist)\n- 409: Conflict (duplicate resource, state conflict)\n- 500: Internal Server Error (unexpected error)\n\n## \uD83D\uDEAB NEVER DO\n\n1. **NEVER** use `as any` to bypass errors\n2. **NEVER** change API return types to fix errors \n3. **NEVER** assume fields exist if they don't\n4. **NEVER** violate REALIZE_WRITE_TOTAL conventions\n5. **NEVER** create variables for Prisma operation parameters\n6. **NEVER** add custom import statements - all imports are auto-generated\n7. **NEVER** use bcrypt, bcryptjs, or external hashing libraries\n8. **NEVER** prioritize comments over types - types are the source of truth\n9. **NEVER** use `throw new Error()` - always use `throw new HttpException(message, statusCode)`\n10. **NEVER** use enum or imported constants for HttpException status codes - use numeric literals only\n\n## \u26A1 BUT DO (When Necessary for Compilation)\n\n1. **DO** completely rewrite implementation approach if current code won't compile\n2. **DO** change implementation strategy entirely (e.g., batch operations \u2192 individual operations)\n3. **DO** restructure complex queries into simpler, compilable parts\n4. **DO** find alternative ways to implement the SAME functionality with different code\n\n## ALWAYS DO\n\n1. **ALWAYS** check if error is due to schema-API mismatch\n2. **ALWAYS** achieve compilation success - even if it requires major refactoring\n3. **ALWAYS** use proper type conversions\n4. **ALWAYS** document when aggressive refactoring was needed\n5. **ALWAYS** follow inline parameter rule for Prisma\n6. **ALWAYS** maintain type safety\n7. **NEVER** use `satisfies` on return statements when function has return type\n ```typescript\n // \u274C REDUNDANT: Function already has return type\n async function getUser(): Promise<IUser> {\n return { ... } satisfies IUser; // Unnecessary!\n }\n \n // \u2705 CORRECT: Let function return type handle validation\n async function getUser(): Promise<IUser> {\n return { ... }; // Function type validates this\n }\n ```\n7. **ALWAYS** maintain API functionality - change implementation, not the contract\n\n## \uD83D\uDCCA Quick Reference Table\n\n| Error Code | Common Cause | First Try | If Fails |\n|------------|-------------|-----------|----------|\n| 2353 | Field doesn't exist in Prisma type | **DELETE the field** - easiest fix! | Check if different field name |\n| 2561 | Wrong field with suggestion | **USE THE SUGGESTED NAME** | TypeScript tells you! |\n| 2551 | Property doesn't exist on result | Check if relation included | Use separate query |\n| 2345 | String to literal union | Add `as \"literal\"` type assertion | Validate first |\n| 2322 (Array) | Type 'X[]' not assignable to '[]' | Return correct array type, not empty | Check interface definition |\n| 2322 (Null) | Type 'string \\| null' not assignable | Add `?? \"\"` or `?? defaultValue` | Check if field should be optional |\n| 2322 (Date) | Type 'Date' not assignable to string | Use `toISOStringSafe()` | Check date handling |\n| 2322 (Relation) | OR clause with relations | Filter after fetch, not in WHERE | Use ID filtering |\n| 2339 | Property doesn't exist | Check include/select first, then remove | Mark as schema issue |\n| 2677 | Type predicate mismatch | Add parameter type to filter | Fix optional vs required fields |\n| 2694 | Namespace has no exported member | Table doesn't exist | Return mock data |\n| 2698 | Spreading non-object | Add null check | Check value source |\n| 2741 | Property missing in type | Add missing required property | Check type definition |\n| 2769 | Wrong function args | Fix parameters | Check overload signatures |\n| 2304 | Cannot find name | Check if should be imported | Missing from auto-imports |\n| 2448 | Used before declaration | Move declaration up | Restructure code |\n| 7022/7006 | Implicit any | Add explicit type | Infer from usage |\n\n## \uD83C\uDFDB\uFE0F Database Engine Compatibility\n\n**\uD83D\uDEA8 CRITICAL**: Our system supports both **PostgreSQL** and **SQLite**. All Prisma operations MUST be compatible with both engines.\n\n### FORBIDDEN: String Search Mode\n\nThe `mode: \"insensitive\"` option is **PostgreSQL-specific** and **BREAKS SQLite compatibility**!\n\n```typescript\n// FORBIDDEN: Will cause runtime errors in SQLite\nwhere: {\n name: { \n contains: search, \n mode: \"insensitive\" // \u2190 BREAKS SQLite!\n }\n}\n\n// CORRECT: Works on both databases\nwhere: {\n name: { \n contains: search // No mode property\n }\n}\n```\n\n**RULE: NEVER use the `mode` property in string operations. Remove it immediately if found in code.**\n\n### Other Compatibility Rules:\n- NO PostgreSQL arrays or JSON operators\n- NO database-specific raw queries\n- NO platform-specific data types\n- Use only standard Prisma operations\n\n## \uD83C\uDFAF Key Principles\n\n1. **Types > Comments**: When type and comment conflict, type is ALWAYS correct\n2. **Schema is Truth**: If field doesn't exist in schema, it cannot be used\n3. **No Custom Imports**: All imports are auto-generated, never add new ones\n4. **Delete, Don't Workaround**: If a field doesn't exist, remove it entirely\n5. **Database Compatibility**: Remove any PostgreSQL-specific features (especially `mode: \"insensitive\"`)\n\n## \uD83C\uDD98 BEGINNER'S GUIDE - Fix Errors Step by Step\n\n### The 5 Most Common Errors (95% of cases):\n\n1. **TS2353/2561: Field doesn't exist**\n - Just DELETE that field from the code\n - OR use TypeScript's suggested name (\"Did you mean...?\")\n - Common examples (patterns vary by project):\n - `deleted_at` \u2192 Usually doesn't exist, remove it\n - `seller_user_id` \u2192 Check for correct user field name\n\n2. **TS2551: Property doesn't exist on type**\n - You're trying to access a relation/field not included in query\n - Solution: Remove the access OR add proper include/select\n\n3. **TS2322: Array type mismatch** \n - Change `data: []` to `data: ActualType[]`\n - The interface probably wants real data, not empty array\n\n4. **TS2322: Null not assignable to string**\n - Add `?? \"\"` after the nullable value\n - Example pattern: `field ?? \"\"`\n\n5. **TS2694: Namespace has no exported member**\n - The table/type doesn't exist at all\n - Solution: Return `typia.random<ReturnType>()`\n\n### Simple Decision Process:\n```\nRead error message\n\u251C\u2500\u2500 \"doesn't exist\" \u2192 DELETE it\n\u251C\u2500\u2500 \"not assignable to '[]'\" \u2192 Return actual array type\n\u251C\u2500\u2500 \"null not assignable\" \u2192 Add ?? \"\"\n\u2514\u2500\u2500 Still confused? \u2192 Use full CoT analysis\n```\n\n## \uD83D\uDCCA Decision Tree for Correction Approach\n\n```\nError Complexity Assessment:\n\u251C\u2500\u2500 Simple (single line, obvious fix)\n\u2502 \u2514\u2500\u2500 Skip to final only\n\u251C\u2500\u2500 Medium (2-3 related errors)\n\u2502 \u2514\u2500\u2500 Use errorAnalysis + final\n\u2514\u2500\u2500 Complex (multiple files, nested errors)\n \u2514\u2500\u2500 Use full Chain of Thinking\n\nCommon Simple Fixes (skip CoT):\n- Type 'string | null' not assignable \u2192 Add ?? \"\"\n- Property doesn't exist \u2192 Remove it\n- Array [] type mismatch \u2192 Use correct array type\n- Date type issues \u2192 Use toISOStringSafe()\n- Missing await \u2192 Add await\n- Wrong parameter count \u2192 Fix arguments\n```\n\n## \uD83D\uDCA1 Real Examples\n\n### Example 1: Simple Null Handling (Skip CoT)\n**Error**: `Type 'string | null' is not assignable to type 'string'`\n```typescript\n// Just provide fixed code in final\n{\n revise: {\n final: `\n export async function updateUser(...) {\n // ...\n return {\n device_info: updated.device_info ?? \"\", // Fixed\n ip_address: updated.ip_address ?? \"\", // Fixed\n // ...\n };\n }\n `\n }\n}\n```\n\n### Example 2: Complex Schema Mismatch (Full CoT)\n**Error**: Multiple interconnected type errors with missing relations\n```typescript\n{\n revise: {\n errorAnalysis: \"Multiple cascading errors due to missing relation...\",\n plan: \"Need to restructure queries to avoid nested operations...\",\n prismaSchemas: \"model User { ... }\",\n // ... other steps ...\n final: \"// Complete refactored solution\"\n }\n}\n```\n\n## \uD83C\uDFAF Success Criteria\n\nYour correction succeeds when:\n1. All compilation errors resolved - THIS IS THE TOP PRIORITY\n2. Appropriate effort level used (minimal for simple, full for complex)\n3. Code compiles successfully\n4. Conventions maintained\n5. No new errors introduced\n\n**Remember**: \n- **EFFICIENCY**: Don't over-engineer simple fixes\n- **CLARITY**: When skipping steps, the fix should be self-evident\n- **COMPLETENESS**: For complex errors, use full analysis to avoid missing edge cases" /* AutoBeSystemPromptConstant.REALIZE_CORRECT */,
|
|
53
53
|
created_at: new Date().toISOString(),
|
|
54
54
|
},
|
|
55
55
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformRealizeCorrectHistories.js","sourceRoot":"","sources":["../../../../src/orchestrate/realize/histories/transformRealizeCorrectHistories.ts"],"names":[],"mappings":";;AAWA,4EA8DC;AAvED,yCAA2C;AAC3C,+BAA0B;AAM1B,qFAAkF;AAElF,SAAgB,gCAAgC,CAAC,KAQhD;IAGC,OAAO;QACL,GAAG,IAAA,+DAA8B,EAAC,KAAK,CAAC;QACxC;YACE,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACpC,IAAI,EAAE,eAAe;YACrB,IAAI,uq4CAAmD;SACxD;QACD;YACE,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE,kBAAU,CAAC,IAAI,CAAA;;;;UAIjB,KAAK,CAAC,IAAI;;OAEb;YACD,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACrC;QACD,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CACnB,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC;YACC,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE,kBAAU,CAAC,IAAI,CAAA;;;;;QAKvB,CAAC,CAAC,QAAQ,CAAC,OAAO;;;;;;;;QAQlB,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC;;OAE9B;YACG,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACrC,CAAkD,CACtD;QACD;YACE,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,IAAI,EAAE,eAAe;YACrB,IAAI,
|
|
1
|
+
{"version":3,"file":"transformRealizeCorrectHistories.js","sourceRoot":"","sources":["../../../../src/orchestrate/realize/histories/transformRealizeCorrectHistories.ts"],"names":[],"mappings":";;AAWA,4EA8DC;AAvED,yCAA2C;AAC3C,+BAA0B;AAM1B,qFAAkF;AAElF,SAAgB,gCAAgC,CAAC,KAQhD;IAGC,OAAO;QACL,GAAG,IAAA,+DAA8B,EAAC,KAAK,CAAC;QACxC;YACE,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACpC,IAAI,EAAE,eAAe;YACrB,IAAI,uq4CAAmD;SACxD;QACD;YACE,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE,kBAAU,CAAC,IAAI,CAAA;;;;UAIjB,KAAK,CAAC,IAAI;;OAEb;YACD,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACrC;QACD,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CACnB,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC;YACC,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE,kBAAU,CAAC,IAAI,CAAA;;;;;QAKvB,CAAC,CAAC,QAAQ,CAAC,OAAO;;;;;;;;QAQlB,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC;;OAE9B;YACG,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACrC,CAAkD,CACtD;QACD;YACE,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,IAAI,EAAE,eAAe;YACrB,IAAI,u90CAA4C;YAChD,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACrC;KACF,CAAC;AACJ,CAAC"}
|