@autobe/agent 0.19.1 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/lib/agent/src/AutoBeAgent.js +3 -2
  2. package/lib/agent/src/AutoBeAgent.js.map +1 -1
  3. package/lib/agent/src/AutoBeMockAgent.js +3 -3
  4. package/lib/agent/src/constants/AutoBeSystemPromptConstant.d.ts +6 -6
  5. package/lib/agent/src/context/AutoBeContext.d.ts +1 -0
  6. package/lib/agent/src/factory/consentFunctionCall.js +3 -2
  7. package/lib/agent/src/factory/consentFunctionCall.js.map +1 -1
  8. package/lib/agent/src/factory/createAutoBeContext.js +8 -5
  9. package/lib/agent/src/factory/createAutoBeContext.js.map +1 -1
  10. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeReviewHistories.d.ts +6 -0
  11. package/lib/agent/src/orchestrate/analyze/histories/{transformAnalyzeReviewerHistories.js → transformAnalyzeReviewHistories.js} +24 -29
  12. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js.map +1 -0
  13. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js +12 -9
  14. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js.map +1 -1
  15. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js +31 -29
  16. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js.map +1 -1
  17. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyze.js +19 -5
  18. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
  19. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeReview.d.ts +7 -1
  20. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeReview.js +9 -6
  21. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeReview.js.map +1 -1
  22. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeScenario.js +11 -9
  23. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeScenario.js.map +1 -1
  24. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeWrite.d.ts +6 -4
  25. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeWrite.js +5 -1
  26. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeWrite.js.map +1 -1
  27. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceAssetHistories.js +45 -46
  28. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceAssetHistories.js.map +1 -1
  29. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js +13 -13
  30. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js.map +1 -1
  31. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceComplementHistories.js +31 -30
  32. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -1
  33. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.js +23 -22
  34. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.js.map +1 -1
  35. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceGroupHistories.js +2 -2
  36. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationHistories.js +27 -26
  37. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationHistories.js.map +1 -1
  38. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js +13 -12
  39. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js.map +1 -1
  40. package/lib/agent/src/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.js +4 -4
  41. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +11 -10
  42. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -1
  43. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js +31 -30
  44. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js.map +1 -1
  45. package/lib/agent/src/orchestrate/interface/orchestrateInterface.js +3 -1
  46. package/lib/agent/src/orchestrate/interface/orchestrateInterface.js.map +1 -1
  47. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceAuthorizations.js +22 -18
  48. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceAuthorizations.js.map +1 -1
  49. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceComplement.js +2 -0
  50. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
  51. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpoints.js +6 -2
  52. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
  53. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceGroups.js +2 -0
  54. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceGroups.js.map +1 -1
  55. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperations.js +74 -48
  56. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
  57. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperationsReview.js +24 -4
  58. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperationsReview.js.map +1 -1
  59. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemas.js +30 -24
  60. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -1
  61. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemasReview.d.ts +2 -5
  62. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemasReview.js +178 -0
  63. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemasReview.js.map +1 -1
  64. package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.d.ts +38 -0
  65. package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.d.ts +38 -0
  66. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.js +54 -54
  67. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.js.map +1 -1
  68. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaCorrectHistories.js +18 -29
  69. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaCorrectHistories.js.map +1 -1
  70. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaReviewHistories.js +37 -34
  71. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaReviewHistories.js.map +1 -1
  72. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.js +38 -25
  73. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.js.map +1 -1
  74. package/lib/agent/src/orchestrate/prisma/orchestratePrisma.js +3 -1
  75. package/lib/agent/src/orchestrate/prisma/orchestratePrisma.js.map +1 -1
  76. package/lib/agent/src/orchestrate/prisma/orchestratePrismaComponent.js +2 -0
  77. package/lib/agent/src/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -1
  78. package/lib/agent/src/orchestrate/prisma/orchestratePrismaCorrect.js +3 -0
  79. package/lib/agent/src/orchestrate/prisma/orchestratePrismaCorrect.js.map +1 -1
  80. package/lib/agent/src/orchestrate/prisma/orchestratePrismaReview.js +19 -9
  81. package/lib/agent/src/orchestrate/prisma/orchestratePrismaReview.js.map +1 -1
  82. package/lib/agent/src/orchestrate/prisma/orchestratePrismaSchemas.js +28 -21
  83. package/lib/agent/src/orchestrate/prisma/orchestratePrismaSchemas.js.map +1 -1
  84. package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorization.js +24 -21
  85. package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorization.js.map +1 -1
  86. package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js +58 -56
  87. package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js.map +1 -1
  88. package/lib/agent/src/orchestrate/realize/histories/transformRealizeCorrectHistories.js +17 -13
  89. package/lib/agent/src/orchestrate/realize/histories/transformRealizeCorrectHistories.js.map +1 -1
  90. package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.js +12 -3
  91. package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.js.map +1 -1
  92. package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.js +35 -30
  93. package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.js.map +1 -1
  94. package/lib/{orchestrate/realize/internal/compile.d.ts → agent/src/orchestrate/realize/internal/compileRealizeFiles.d.ts} +1 -1
  95. package/lib/agent/src/orchestrate/realize/internal/{compile.js → compileRealizeFiles.js} +6 -6
  96. package/lib/agent/src/orchestrate/realize/internal/compileRealizeFiles.js.map +1 -0
  97. package/lib/agent/src/orchestrate/realize/orchestrateRealize.js +26 -12
  98. package/lib/agent/src/orchestrate/realize/orchestrateRealize.js.map +1 -1
  99. package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorization.js +9 -3
  100. package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorization.js.map +1 -1
  101. package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js +3 -1
  102. package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js.map +1 -1
  103. package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.d.ts +2 -6
  104. package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.js +8 -4
  105. package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
  106. package/lib/agent/src/orchestrate/realize/orchestrateRealizeScenario.d.ts +0 -66
  107. package/lib/agent/src/orchestrate/realize/orchestrateRealizeScenario.js.map +1 -1
  108. package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.d.ts +3 -6
  109. package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.js +21 -17
  110. package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.js.map +1 -1
  111. package/lib/agent/src/orchestrate/test/compile/completeTestCode.js +13 -10
  112. package/lib/agent/src/orchestrate/test/compile/completeTestCode.js.map +1 -1
  113. package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.js +16 -15
  114. package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.js.map +1 -1
  115. package/lib/agent/src/orchestrate/test/histories/transformTestHistories.js +33 -32
  116. package/lib/agent/src/orchestrate/test/histories/transformTestHistories.js.map +1 -1
  117. package/lib/agent/src/orchestrate/test/histories/transformTestScenarioHistories.js +62 -59
  118. package/lib/agent/src/orchestrate/test/histories/transformTestScenarioHistories.js.map +1 -1
  119. package/lib/agent/src/orchestrate/test/histories/transformTestWriteHistories.js +2 -2
  120. package/lib/agent/src/orchestrate/test/orchestrateTest.js +6 -5
  121. package/lib/agent/src/orchestrate/test/orchestrateTest.js.map +1 -1
  122. package/lib/agent/src/orchestrate/test/orchestrateTestCorrect.js +16 -7
  123. package/lib/agent/src/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  124. package/lib/agent/src/orchestrate/test/orchestrateTestScenario.js +20 -8
  125. package/lib/agent/src/orchestrate/test/orchestrateTestScenario.js.map +1 -1
  126. package/lib/agent/src/orchestrate/test/orchestrateTestWrite.js +17 -17
  127. package/lib/agent/src/orchestrate/test/orchestrateTestWrite.js.map +1 -1
  128. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +2 -2
  129. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +2 -2
  130. package/lib/agent/src/utils/executeCachedBatch.d.ts +1 -0
  131. package/lib/agent/src/utils/executeCachedBatch.js +23 -0
  132. package/lib/agent/src/utils/executeCachedBatch.js.map +1 -0
  133. package/lib/constants/AutoBeSystemPromptConstant.d.ts +6 -6
  134. package/lib/context/AutoBeContext.d.ts +1 -0
  135. package/lib/index.mjs +1044 -270
  136. package/lib/index.mjs.map +1 -1
  137. package/lib/orchestrate/analyze/histories/transformAnalyzeReviewHistories.d.ts +6 -0
  138. package/lib/orchestrate/analyze/orchestrateAnalyzeReview.d.ts +7 -1
  139. package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.d.ts +6 -4
  140. package/lib/orchestrate/interface/orchestrateInterfaceSchemasReview.d.ts +2 -5
  141. package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.d.ts +38 -0
  142. package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.d.ts +38 -0
  143. package/lib/{agent/src/orchestrate/realize/internal/compile.d.ts → orchestrate/realize/internal/compileRealizeFiles.d.ts} +1 -1
  144. package/lib/orchestrate/realize/orchestrateRealizeCorrect.d.ts +2 -6
  145. package/lib/orchestrate/realize/orchestrateRealizeScenario.d.ts +0 -66
  146. package/lib/orchestrate/realize/orchestrateRealizeWrite.d.ts +3 -6
  147. package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +2 -2
  148. package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +2 -2
  149. package/lib/utils/executeCachedBatch.d.ts +1 -0
  150. package/package.json +6 -6
  151. package/src/AutoBeAgent.ts +4 -3
  152. package/src/AutoBeMockAgent.ts +4 -4
  153. package/src/constants/AutoBeSystemPromptConstant.ts +6 -6
  154. package/src/context/AutoBeContext.ts +1 -0
  155. package/src/factory/consentFunctionCall.ts +4 -3
  156. package/src/factory/createAutoBeContext.ts +9 -6
  157. package/src/orchestrate/analyze/histories/{transformAnalyzeReviewerHistories.ts → transformAnalyzeReviewHistories.ts} +23 -30
  158. package/src/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.ts +13 -10
  159. package/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.ts +60 -61
  160. package/src/orchestrate/analyze/orchestrateAnalyze.ts +20 -13
  161. package/src/orchestrate/analyze/orchestrateAnalyzeReview.ts +20 -9
  162. package/src/orchestrate/analyze/orchestrateAnalyzeScenario.ts +13 -11
  163. package/src/orchestrate/analyze/orchestrateAnalyzeWrite.ts +10 -5
  164. package/src/orchestrate/interface/histories/transformInterfaceAssetHistories.ts +47 -48
  165. package/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.ts +14 -14
  166. package/src/orchestrate/interface/histories/transformInterfaceComplementHistories.ts +31 -30
  167. package/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.ts +20 -19
  168. package/src/orchestrate/interface/histories/transformInterfaceGroupHistories.ts +3 -3
  169. package/src/orchestrate/interface/histories/transformInterfaceOperationHistories.ts +23 -22
  170. package/src/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.ts +12 -11
  171. package/src/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.ts +5 -5
  172. package/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.ts +11 -10
  173. package/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.ts +31 -30
  174. package/src/orchestrate/interface/orchestrateInterface.ts +4 -2
  175. package/src/orchestrate/interface/orchestrateInterfaceAuthorizations.ts +36 -29
  176. package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +2 -0
  177. package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +13 -9
  178. package/src/orchestrate/interface/orchestrateInterfaceGroups.ts +2 -0
  179. package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +53 -50
  180. package/src/orchestrate/interface/orchestrateInterfaceOperationsReview.ts +2 -0
  181. package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +47 -23
  182. package/src/orchestrate/interface/orchestrateInterfaceSchemasReview.ts +85 -1
  183. package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.ts +39 -0
  184. package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.ts +40 -1
  185. package/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.ts +57 -55
  186. package/src/orchestrate/prisma/histories/transformPrismaCorrectHistories.ts +19 -30
  187. package/src/orchestrate/prisma/histories/transformPrismaReviewHistories.ts +38 -35
  188. package/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.ts +36 -23
  189. package/src/orchestrate/prisma/orchestratePrisma.ts +4 -2
  190. package/src/orchestrate/prisma/orchestratePrismaComponent.ts +2 -0
  191. package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +3 -0
  192. package/src/orchestrate/prisma/orchestratePrismaReview.ts +26 -13
  193. package/src/orchestrate/prisma/orchestratePrismaSchemas.ts +25 -17
  194. package/src/orchestrate/realize/histories/transformRealizeAuthorization.ts +24 -21
  195. package/src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.ts +42 -40
  196. package/src/orchestrate/realize/histories/transformRealizeCorrectHistories.ts +17 -13
  197. package/src/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.ts +14 -5
  198. package/src/orchestrate/realize/histories/transformRealizeWriteHistories.ts +35 -30
  199. package/src/orchestrate/realize/internal/{compile.ts → compileRealizeFiles.ts} +15 -11
  200. package/src/orchestrate/realize/orchestrateRealize.ts +59 -40
  201. package/src/orchestrate/realize/orchestrateRealizeAuthorization.ts +19 -10
  202. package/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.ts +3 -0
  203. package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +10 -10
  204. package/src/orchestrate/realize/orchestrateRealizeScenario.ts +0 -74
  205. package/src/orchestrate/realize/orchestrateRealizeWrite.ts +24 -23
  206. package/src/orchestrate/test/compile/completeTestCode.ts +17 -13
  207. package/src/orchestrate/test/experimental/transformTestCorrectHistories.ast +4 -4
  208. package/src/orchestrate/test/histories/transformTestCorrectHistories.ts +17 -16
  209. package/src/orchestrate/test/histories/transformTestHistories.ts +35 -34
  210. package/src/orchestrate/test/histories/transformTestScenarioHistories.ts +62 -57
  211. package/src/orchestrate/test/histories/transformTestWriteHistories.ts +3 -3
  212. package/src/orchestrate/test/orchestrateTest.ts +7 -9
  213. package/src/orchestrate/test/orchestrateTestCorrect.ts +34 -24
  214. package/src/orchestrate/test/orchestrateTestScenario.ts +28 -21
  215. package/src/orchestrate/test/orchestrateTestWrite.ts +16 -17
  216. package/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.ts +3 -3
  217. package/src/orchestrate/test/structures/IAutoBeTestWriteApplication.ts +2 -2
  218. package/src/utils/executeCachedBatch.ts +15 -0
  219. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeReviewerHistories.d.ts +0 -6
  220. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeReviewerHistories.js.map +0 -1
  221. package/lib/agent/src/orchestrate/realize/internal/compile.js.map +0 -1
  222. package/lib/orchestrate/analyze/histories/transformAnalyzeReviewerHistories.d.ts +0 -6
@@ -1,38 +1,41 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.transformRealizeAuthorizationHistories = void 0;
4
+ const utils_1 = require("@autobe/utils");
4
5
  const uuid_1 = require("uuid");
5
6
  const transformRealizeAuthorizationHistories = (ctx, role) => {
6
7
  var _a;
7
8
  return [
8
9
  {
9
- id: (0, uuid_1.v4)(),
10
+ id: (0, uuid_1.v7)(),
10
11
  created_at: new Date().toISOString(),
11
12
  type: "systemMessage",
12
- text: "# NestJS Authentication Provider & Decorator Generation AI Agent \n\n## Naming Conventions\n\n### Notation Types\nThe following naming conventions (notations) are used throughout the system:\n- **camelCase**: First word lowercase, subsequent words capitalized (e.g., `userAccount`, `productItem`)\n- **PascalCase**: All words capitalized (e.g., `UserAccount`, `ProductItem`)\n- **snake_case**: All lowercase with underscores between words (e.g., `user_account`, `product_item`)\n\n### Specific Property Notations\n- **IAutoBeRealizeAuthorizationApplication.IProvider.name**: Use camelCase notation (format: `{Role.name(PascalCase)}Authorize`)\n- **IAutoBeRealizeAuthorizationApplication.IDecorator.name**: Use PascalCase notation (format: `{Role.name(PascalCase)}Auth`)\n- **IAutoBeRealizeAuthorizationApplication.IPayloadType.name**: Use PascalCase notation (format: `{Role.name(PascalCase)}Payload`)\n\nYou are a world-class NestJS expert and TypeScript developer. Your role is to automatically generate Provider functions and Decorators for JWT authentication based on given Role information and Prisma Schema. \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 authorization implementation 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## Core Mission \n\nGenerate authentication Provider and Decorator code specialized for specific Roles based on Role information provided by users. \n\n## Input Information \n\n- **Role Name**: The authentication role to generate (e.g., admin, user, manager, etc.) \n- **Prisma Schema**: Database table information.\n\n## File Structure\n\n**IMPORTANT: Understanding the file structure is crucial for correct import paths:**\n\n```\nsrc/\n\u251C\u2500\u2500 MyGlobal.ts\n\u251C\u2500\u2500 decorators/\n\u2502 \u251C\u2500\u2500 AdminAuth.ts\n\u2502 \u251C\u2500\u2500 UserAuth.ts\n\u2502 \u2514\u2500\u2500 payload/\n\u2502 \u251C\u2500\u2500 AdminPayload.ts\n\u2502 \u2514\u2500\u2500 UserPayload.ts\n\u2514\u2500\u2500 providers/\n \u2514\u2500\u2500 authorize/\n \u251C\u2500\u2500 jwtAuthorize.ts \u2190 Shared JWT verification function\n \u251C\u2500\u2500 adminAuthorize.ts \u2190 Same directory as jwtAuthorize\n \u2514\u2500\u2500 userAuthorize.ts \u2190 Same directory as jwtAuthorize\n```\n\n## Code Generation Rules \n\n### 1. Provider Function Generation Rules \n\n- Function name: `{Role.name(PascalCase)}Authorize` format (e.g., adminAuthorize, userAuthorize) \n- Must use the `jwtAuthorize` function for JWT token verification \n- **\u26A0\uFE0F CRITICAL: Import jwtAuthorize using `import { jwtAuthorize } from \"./jwtAuthorize\";` (NOT from \"../../providers/authorize/jwtAuthorize\" or any other path)**\n- Verify payload type and check if `payload.type` matches the correct role \n- Query database using `MyGlobal.prisma.{tableName}` format to fetch **only the authorization model itself** - do not include relations or business logic models (no `include` statements for profile, etc.) \n- Verify that the user actually exists in the database \n- Function return type should be `{Role.name(PascalCase)}Payload` interface \n- Return the `payload` variable whenever feasible in provider functions. \n- **Always check the Prisma schema for validation columns (e.g., `deleted_at`, status fields) within the authorization model and include them in the `where` clause to ensure the user is valid and active.** \n\n### 2. Payload Interface Generation Rules \n\n- Interface name: `{Role.name(PascalCase)}Payload` format (e.g., AdminPayload, UserPayload) \n- Required fields: \n - `id: string & tags.Format<\"uuid\">`: User ID (UUID format) \n - `type: \"{role}\"`: Discriminator for role identification \n- Additional fields should be generated according to Role characteristics and \"Prisma Schema\" \n\n### 3. Decorator Generation Rules \n\n- Decorator name: `{Role.name(PascalCase)}Auth` format (e.g., AdminAuth, UserAuth) \n- Use SwaggerCustomizer to add bearer token security schema to API documentation \n- Use createParamDecorator to implement actual authentication logic \n- Use Singleton pattern to manage decorator instances \n\n### 4. Code Style and Structure\n\n- Comply with TypeScript strict mode \n- Utilize NestJS Exception classes (ForbiddenException, UnauthorizedException) \n- Ensure type safety using typia tags \n- Add appropriate JSDoc comments \n\n## Reference Functions and Examples \n\n### JWT Authentication Function \n\n```typescript\n// File path: src/providers/authorize/jwtAuthorize.ts\nimport { ForbiddenException, UnauthorizedException } from \"@nestjs/common\";\nimport jwt from \"jsonwebtoken\";\n\nimport { MyGlobal } from \"../../MyGlobal\";\n\nexport function jwtAuthorize(props: {\n request: {\n headers: { authorization?: string };\n };\n}) {\n if (!props.request.headers.authorization)\n throw new ForbiddenException(\"No token value exists\");\n else if (\n props.request.headers.authorization.startsWith(BEARER_PREFIX) === false\n )\n throw new UnauthorizedException(\"Invalid token\");\n\n // PARSE TOKEN\n try {\n const token: string = props.request.headers.authorization.substring(\n BEARER_PREFIX.length,\n );\n\n const verified = jwt.verify(token, MyGlobal.env.JWT_SECRET_KEY);\n\n return verified;\n } catch {\n throw new UnauthorizedException(\"Invalid token\");\n }\n}\n\nconst BEARER_PREFIX = \"Bearer \";\n``` \n\n### Provider Function Example \n\n**\u26A0\uFE0F CRITICAL IMPORT PATHS:**\n- `jwtAuthorize` MUST be imported from `\"./jwtAuthorize\"` (same directory)\n- NOT `\"../../providers/authorize/jwtAuthorize\"` \u274C\n- NOT `\"../jwtAuthorize\"` \u274C\n- ONLY `\"./jwtAuthorize\"` \u2705\n\n```typescript\n// File path: src/providers/authorize/adminAuthorize.ts\nimport { ForbiddenException } from \"@nestjs/common\";\n\nimport { MyGlobal } from \"../../MyGlobal\";\nimport { jwtAuthorize } from \"./jwtAuthorize\"; // \u2190 CORRECT: Same directory import\nimport { AdminPayload } from \"../../decorators/payload/AdminPayload\";\n\nexport async function adminAuthorize(request: {\n headers: {\n authorization?: string;\n };\n}): Promise<AdminPayload> {\n const payload: AdminPayload = jwtAuthorize({ request }) as AdminPayload;\n\n if (payload.type !== \"admin\") {\n throw new ForbiddenException(`You're not ${payload.type}`);\n }\n\n const admin = await MyGlobal.prisma.admins.findFirst({\n where: {\n id: payload.id,\n user: {\n deleted_at: null,\n is_banned: false,\n },\n },\n });\n\n if (admin === null) {\n throw new ForbiddenException(\"You're not enrolled\");\n }\n\n return payload;\n}\n``` \n\n### Decorator Example\n\n```typescript\n// File path: src/decorators/AdminAuth.ts\nimport { SwaggerCustomizer } from \"@nestia/core\";\nimport { ExecutionContext, createParamDecorator } from \"@nestjs/common\";\nimport { Singleton } from \"tstl\";\n\nimport { adminAuthorize } from \"../providers/authorize/adminAuthorize\";\n\nexport const AdminAuth =\n (): ParameterDecorator =>\n (\n target: object,\n propertyKey: string | symbol | undefined,\n parameterIndex: number,\n ): void => {\n SwaggerCustomizer((props) => {\n props.route.security ??= [];\n props.route.security.push({\n bearer: [],\n });\n })(target, propertyKey as string, undefined!);\n singleton.get()(target, propertyKey, parameterIndex);\n };\n\nconst singleton = new Singleton(() =>\n createParamDecorator(async (_0: unknown, ctx: ExecutionContext) => {\n const request = ctx.switchToHttp().getRequest();\n return adminAuthorize(request);\n })(),\n);\n``` \n\n### Decorator Type Example \n\nIn case of the columns related to Date type like `created_at`, `updated_at`, `deleted_at`, must use the `string & tags.Format<'date-time'>` Type instead of Date type. \n\n```typescript\n// File path: src/decorators/payload/AdminPayload.ts\nimport { tags } from \"typia\";\n\nexport interface AdminPayload {\n /**\n * Admin ID.\n */\n id: string & tags.Format<\"uuid\">;\n\n /**\n * Discriminator for the discriminated union type.\n */\n type: \"admin\";\n}\n``` \n\n## Output Format \n\nYou must provide your response in a structured JSON format containing the following nested structure: \n\n**provider**: An object containing the authentication Provider function configuration \n\n- **name**: The name of the authentication Provider function in `{Role.name(PascalCase)}Authorize` format (e.g., adminAuthorize, userAuthorize). This function verifies JWT tokens and returns user information for the specified role. \n- **code**: Complete TypeScript code for the authentication Provider function only. Must include JWT verification, role checking, database query logic, and proper import statements for the Payload interface.\n\n**decorator**: An object containing the authentication Decorator configuration \n\n- **name**: The name of the Decorator to be generated in `{Role.name(PascalCase)}Auth` format (e.g., AdminAuth, UserAuth). The decorator name used in Controller method parameters. \n- **code**: Complete TypeScript code for the Decorator. Must include complete authentication decorator implementation using SwaggerCustomizer, createParamDecorator, and Singleton pattern.\n\n**decoratorType**: An object containing the Decorator Type configuration\n\n- **name**: The name of the Decorator Type in `{Role.name(PascalCase)}Payload` format (e.g., AdminPayload, UserPayload). Used as the TypeScript type for the authenticated user data.\n- **code**: Complete TypeScript code for the Payload type interface. Must include proper field definitions with typia tags for type safety.\n\n## Work Process \n\n1. Analyze the input Role name \n2. Generate Provider function for the Role \n3. Define Payload interface \n4. Implement Decorator \n5. Verify that all code follows example patterns \n6. Generate response in specified format \n\n## Quality Standards \n\n- Ensure type safety \n- Follow NestJS conventions \n- Complete error handling \n- Code reusability \n- Complete documentation \n\n## Common Mistakes to Avoid\n\n1. **\u274C INCORRECT jwtAuthorize import paths:**\n ```typescript\n // WRONG - Do not use these:\n import { jwtAuthorize } from \"../../providers/authorize/jwtAuthorize\";\n import { jwtAuthorize } from \"../authorize/jwtAuthorize\";\n import { jwtAuthorize } from \"../../providers/jwtAuthorize\";\n ```\n\n2. **\u2705 CORRECT jwtAuthorize import path:**\n ```typescript\n // CORRECT - Always use this:\n import { jwtAuthorize } from \"./jwtAuthorize\";\n ```\n\nWhen users provide Role information, generate complete and practical authentication code according to the above rules." /* AutoBeSystemPromptConstant.REALIZE_AUTHORIZATION */,
13
+ text: "# NestJS Authentication Provider & Decorator Generation AI Agent \n\n## Naming Conventions\n\n### Notation Types\nThe following naming conventions (notations) are used throughout the system:\n- **camelCase**: First word lowercase, subsequent words capitalized (e.g., `userAccount`, `productItem`)\n- **PascalCase**: All words capitalized (e.g., `UserAccount`, `ProductItem`)\n- **snake_case**: All lowercase with underscores between words (e.g., `user_account`, `product_item`)\n\n### Specific Property Notations\n- **IAutoBeRealizeAuthorizationApplication.IProvider.name**: Use camelCase notation (format: `{Role.name(PascalCase)}Authorize`)\n- **IAutoBeRealizeAuthorizationApplication.IDecorator.name**: Use PascalCase notation (format: `{Role.name(PascalCase)}Auth`)\n- **IAutoBeRealizeAuthorizationApplication.IPayloadType.name**: Use PascalCase notation (format: `{Role.name(PascalCase)}Payload`)\n\nYou are a world-class NestJS expert and TypeScript developer. Your role is to automatically generate Provider functions and Decorators for JWT authentication based on given Role information and Prisma Schema. \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 authorization implementation 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## Core Mission \n\nGenerate authentication Provider and Decorator code specialized for specific Roles based on Role information provided by users. \n\n## Input Information \n\n- **Role Name**: The authentication role to generate (e.g., admin, user, manager, etc.) \n- **Prisma Schema**: Database table information.\n\n## File Structure\n\n**IMPORTANT: Understanding the file structure is crucial for correct import paths:**\n\n```\nsrc/\n\u251C\u2500\u2500 MyGlobal.ts\n\u251C\u2500\u2500 decorators/\n\u2502 \u251C\u2500\u2500 AdminAuth.ts\n\u2502 \u251C\u2500\u2500 UserAuth.ts\n\u2502 \u2514\u2500\u2500 payload/\n\u2502 \u251C\u2500\u2500 AdminPayload.ts\n\u2502 \u2514\u2500\u2500 UserPayload.ts\n\u2514\u2500\u2500 providers/\n \u2514\u2500\u2500 authorize/\n \u251C\u2500\u2500 jwtAuthorize.ts \u2190 Shared JWT verification function\n \u251C\u2500\u2500 adminAuthorize.ts \u2190 Same directory as jwtAuthorize\n \u2514\u2500\u2500 userAuthorize.ts \u2190 Same directory as jwtAuthorize\n```\n\n## Code Generation Rules \n\n### 1. Provider Function Generation Rules \n\n- Function name: `{Role.name(PascalCase)}Authorize` format (e.g., adminAuthorize, userAuthorize) \n- Must use the `jwtAuthorize` function for JWT token verification \n- **\u26A0\uFE0F CRITICAL: Import jwtAuthorize using `import { jwtAuthorize } from \"./jwtAuthorize\";` (NOT from \"../../providers/authorize/jwtAuthorize\" or any other path)**\n- Verify payload type and check if `payload.type` matches the correct role \n- Query database using `MyGlobal.prisma.{tableName}` format to fetch **only the authorization model itself** - do not include relations or business logic models (no `include` statements for profile, etc.) \n- Verify that the user actually exists in the database \n- Function return type should be `{Role.name(PascalCase)}Payload` interface \n- Return the `payload` variable whenever feasible in provider functions. \n- **Always check the Prisma schema for validation columns (e.g., `deleted_at`, status fields) within the authorization model and include them in the `where` clause to ensure the user is valid and active.** \n- **Database Query Strategy - CRITICAL for JWT Token Structure:**\n - **Analyze the Prisma Schema to determine table relationships**\n - **payload.id ALWAYS contains the top-level user table ID** (most fundamental user entity in your schema)\n - **If role table extends a user table (has foreign key like `user_id`):** Use the foreign key field: `where: { user_id: payload.id }`\n - **If role table is standalone (no foreign key to user table):** Use primary key field: `where: { id: payload.id }`\n\n### 2. Payload Interface Generation Rules \n\n- Interface name: `{Role.name(PascalCase)}Payload` format (e.g., AdminPayload, UserPayload) \n- Required fields: \n - `id: string & tags.Format<\"uuid\">`: **ALWAYS contains the top-level user table ID** - this is the most fundamental user identifier in your system, not the role table's own ID\n - `type: \"{role}\"`: Discriminator for role identification \n- Additional fields should be generated according to Role characteristics and \"Prisma Schema\" \n\n### 3. Decorator Generation Rules \n\n- Decorator name: `{Role.name(PascalCase)}Auth` format (e.g., AdminAuth, UserAuth) \n- Use SwaggerCustomizer to add bearer token security schema to API documentation \n- Use createParamDecorator to implement actual authentication logic \n- Use Singleton pattern to manage decorator instances \n\n### 4. Code Style and Structure\n\n- Comply with TypeScript strict mode \n- Utilize NestJS Exception classes (ForbiddenException, UnauthorizedException) \n- Ensure type safety using typia tags \n- Add appropriate JSDoc comments \n\n## Reference Functions and Examples \n\n### JWT Authentication Function \n\n```typescript\n// File path: src/providers/authorize/jwtAuthorize.ts\nimport { ForbiddenException, UnauthorizedException } from \"@nestjs/common\";\nimport jwt from \"jsonwebtoken\";\n\nimport { MyGlobal } from \"../../MyGlobal\";\n\nexport function jwtAuthorize(props: {\n request: {\n headers: { authorization?: string };\n };\n}) {\n if (!props.request.headers.authorization)\n throw new ForbiddenException(\"No token value exists\");\n else if (\n props.request.headers.authorization.startsWith(BEARER_PREFIX) === false\n )\n throw new UnauthorizedException(\"Invalid token\");\n\n // PARSE TOKEN\n try {\n const token: string = props.request.headers.authorization.substring(\n BEARER_PREFIX.length,\n );\n\n const verified = jwt.verify(token, MyGlobal.env.JWT_SECRET_KEY);\n\n return verified;\n } catch {\n throw new UnauthorizedException(\"Invalid token\");\n }\n}\n\nconst BEARER_PREFIX = \"Bearer \";\n``` \n\n### Provider Function Example \n\n**\u26A0\uFE0F CRITICAL IMPORT PATHS:**\n- `jwtAuthorize` MUST be imported from `\"./jwtAuthorize\"` (same directory)\n- NOT `\"../../providers/authorize/jwtAuthorize\"` \u274C\n- NOT `\"../jwtAuthorize\"` \u274C\n- ONLY `\"./jwtAuthorize\"` \u2705\n\n```typescript\n// File path: src/providers/authorize/adminAuthorize.ts\nimport { ForbiddenException } from \"@nestjs/common\";\n\nimport { MyGlobal } from \"../../MyGlobal\";\nimport { jwtAuthorize } from \"./jwtAuthorize\"; // \u2190 CORRECT: Same directory import\nimport { AdminPayload } from \"../../decorators/payload/AdminPayload\";\n\nexport async function adminAuthorize(request: {\n headers: {\n authorization?: string;\n };\n}): Promise<AdminPayload> {\n const payload: AdminPayload = jwtAuthorize({ request }) as AdminPayload;\n\n if (payload.type !== \"admin\") {\n throw new ForbiddenException(`You're not ${payload.type}`);\n }\n\n // payload.id contains top-level user table ID\n // Query using appropriate field based on schema structure\n const admin = await MyGlobal.prisma.admins.findFirst({\n where: {\n user_id: payload.id, // \u2190 Use foreign key if Admin extends User\n user: {\n deleted_at: null,\n is_banned: false,\n },\n },\n });\n\n if (admin === null) {\n throw new ForbiddenException(\"You're not enrolled\");\n }\n\n return payload;\n}\n``` \n\n### Decorator Example\n\n```typescript\n// File path: src/decorators/AdminAuth.ts\nimport { SwaggerCustomizer } from \"@nestia/core\";\nimport { ExecutionContext, createParamDecorator } from \"@nestjs/common\";\nimport { Singleton } from \"tstl\";\n\nimport { adminAuthorize } from \"../providers/authorize/adminAuthorize\";\n\nexport const AdminAuth =\n (): ParameterDecorator =>\n (\n target: object,\n propertyKey: string | symbol | undefined,\n parameterIndex: number,\n ): void => {\n SwaggerCustomizer((props) => {\n props.route.security ??= [];\n props.route.security.push({\n bearer: [],\n });\n })(target, propertyKey as string, undefined!);\n singleton.get()(target, propertyKey, parameterIndex);\n };\n\nconst singleton = new Singleton(() =>\n createParamDecorator(async (_0: unknown, ctx: ExecutionContext) => {\n const request = ctx.switchToHttp().getRequest();\n return adminAuthorize(request);\n })(),\n);\n``` \n\n### Decorator Type Example \n\nIn case of the columns related to Date type like `created_at`, `updated_at`, `deleted_at`, must use the `string & tags.Format<'date-time'>` Type instead of Date type. \n\n```typescript\n// File path: src/decorators/payload/AdminPayload.ts\nimport { tags } from \"typia\";\n\nexport interface AdminPayload {\n /**\n * Top-level user table ID (the fundamental user identifier in the system).\n */\n id: string & tags.Format<\"uuid\">;\n\n /**\n * Discriminator for the discriminated union type.\n */\n type: \"admin\";\n}\n``` \n\n## JWT Token Structure Context\n\n**IMPORTANT: Understanding how JWT tokens are structured in this system**\n\nThe JWT payload will always contain:\n- `id`: The top-level user table ID (most fundamental user entity)\n- `type`: The role type (\"admin\", \"user\", \"manager\", etc.)\n\n**Example scenarios:**\n1. **If Admin extends User table:**\n - JWT payload.id = User.id (top-level user ID)\n - Database query: `where: { user_id: payload.id }`\n\n2. **If Customer is standalone:**\n - JWT payload.id = Customer.id (Customer is the top-level user)\n - Database query: `where: { id: payload.id }`\n\n## Output Format \n\nYou must provide your response in a structured JSON format containing the following nested structure: \n\n**provider**: An object containing the authentication Provider function configuration \n\n- **name**: The name of the authentication Provider function in `{Role.name(PascalCase)}Authorize` format (e.g., adminAuthorize, userAuthorize). This function verifies JWT tokens and returns user information for the specified role. \n- **code**: Complete TypeScript code for the authentication Provider function only. Must include JWT verification, role checking, database query logic with proper top-level user ID handling, and proper import statements for the Payload interface.\n\n**decorator**: An object containing the authentication Decorator configuration \n\n- **name**: The name of the Decorator to be generated in `{Role.name(PascalCase)}Auth` format (e.g., AdminAuth, UserAuth). The decorator name used in Controller method parameters. \n- **code**: Complete TypeScript code for the Decorator. Must include complete authentication decorator implementation using SwaggerCustomizer, createParamDecorator, and Singleton pattern.\n\n**decoratorType**: An object containing the Decorator Type configuration\n\n- **name**: The name of the Decorator Type in `{Role.name(PascalCase)}Payload` format (e.g., AdminPayload, UserPayload). Used as the TypeScript type for the authenticated user data.\n- **code**: Complete TypeScript code for the Payload type interface. Must include proper field definitions with typia tags for type safety.\n\n## Work Process \n\n1. Analyze the input Role name \n2. **Analyze the Prisma Schema to identify table relationships and determine the top-level user table**\n3. **Determine appropriate database query strategy based on whether role table extends user table or is standalone**\n4. Generate Provider function for the Role with correct database query field\n5. Define Payload interface with top-level user table ID\n6. Implement Decorator \n7. Verify that all code follows example patterns \n8. Generate response in specified format \n\n## Quality Standards \n\n- Ensure type safety \n- Follow NestJS conventions \n- Complete error handling \n- Code reusability \n- Complete documentation \n- **Correct handling of top-level user table ID throughout all components**\n\n## Common Mistakes to Avoid\n\n1. **\u274C INCORRECT jwtAuthorize import paths:**\n ```typescript\n // WRONG - Do not use these:\n import { jwtAuthorize } from \"../../providers/authorize/jwtAuthorize\";\n import { jwtAuthorize } from \"../authorize/jwtAuthorize\";\n import { jwtAuthorize } from \"../../providers/jwtAuthorize\";\n ```\n\n2. **\u2705 CORRECT jwtAuthorize import path:**\n ```typescript\n // CORRECT - Always use this:\n import { jwtAuthorize } from \"./jwtAuthorize\";\n ```\n\n3. **\u274C INCORRECT database query field selection:**\n ```typescript\n // WRONG - Always using 'id' field without analyzing schema:\n const admin = await MyGlobal.prisma.admins.findFirst({\n where: { id: payload.id } // Wrong if Admin extends User\n });\n ```\n\n4. **\u2705 CORRECT database query field selection:**\n ```typescript\n // CORRECT - Using appropriate field based on schema structure:\n const admin = await MyGlobal.prisma.admins.findFirst({\n where: { user_id: payload.id } // Correct if Admin extends User\n });\n ```\n \nWhen users provide Role information, generate complete and practical authentication code according to the above rules." /* AutoBeSystemPromptConstant.REALIZE_AUTHORIZATION */,
13
14
  },
14
15
  {
15
- id: (0, uuid_1.v4)(),
16
+ id: (0, uuid_1.v7)(),
16
17
  created_at: new Date().toISOString(),
17
18
  type: "systemMessage",
18
- text: [
19
- "## Role",
20
- "```json",
21
- JSON.stringify(role),
22
- "```",
23
- "",
24
- "## Prisma Schema",
25
- "",
26
- JSON.stringify((_a = ctx.state().prisma) === null || _a === void 0 ? void 0 : _a.schemas),
27
- "",
28
- "## Component Naming Convention",
29
- "",
30
- "Please follow this naming convention for the authorization components:",
31
- "",
32
- `- Provider Name: ${role.name}Authorize (e.g. ${role.name}Authorize)`,
33
- `- Decorator Name: ${role.name.charAt(0).toUpperCase() + role.name.slice(1)}Auth (e.g. ${role.name.charAt(0).toUpperCase() + role.name.slice(1)}Auth)`,
34
- `- Payload Name: ${role.name.charAt(0).toUpperCase() + role.name.slice(1)}Payload (e.g. ${role.name.charAt(0).toUpperCase() + role.name.slice(1)}Payload)`,
35
- ].join("\n"),
19
+ text: utils_1.StringUtil.trim `
20
+ ## Role
21
+ \`\`\`json
22
+ ${JSON.stringify(role)}
23
+ \`\`\`
24
+
25
+ ## Prisma Schema
26
+
27
+ \`\`\`json
28
+ ${JSON.stringify((_a = ctx.state().prisma) === null || _a === void 0 ? void 0 : _a.schemas)}
29
+ \`\`\`
30
+
31
+ ## Component Naming Convention
32
+
33
+ Please follow this naming convention for the authorization components:
34
+
35
+ - Provider Name: ${role.name}Authorize (e.g. ${role.name}Authorize)
36
+ - Decorator Name: ${role.name.charAt(0).toUpperCase() + role.name.slice(1)}Auth (e.g. ${role.name.charAt(0).toUpperCase() + role.name.slice(1)}Auth)
37
+ - Payload Name: ${role.name.charAt(0).toUpperCase() + role.name.slice(1)}Payload (e.g. ${role.name.charAt(0).toUpperCase() + role.name.slice(1)}Payload)
38
+ `,
36
39
  },
37
40
  ];
38
41
  };
@@ -1 +1 @@
1
- {"version":3,"file":"transformRealizeAuthorization.js","sourceRoot":"","sources":["../../../../../../src/orchestrate/realize/histories/transformRealizeAuthorization.ts"],"names":[],"mappings":";;;AAGA,+BAA0B;AAKnB,MAAM,sCAAsC,GAAG,CAGpD,GAAyB,EACzB,IAAuB,EAGvB,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,2kXAAkD;SACvD;QACD;YACE,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACpC,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE;gBACJ,SAAS;gBACT,SAAS;gBACT,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBACpB,KAAK;gBACL,EAAE;gBACF,kBAAkB;gBAClB,EAAE;gBACF,IAAI,CAAC,SAAS,CAAC,MAAA,GAAG,CAAC,KAAK,EAAE,CAAC,MAAM,0CAAE,OAAO,CAAC;gBAC3C,EAAE;gBACF,gCAAgC;gBAChC,EAAE;gBACF,wEAAwE;gBACxE,EAAE;gBACF,oBAAoB,IAAI,CAAC,IAAI,mBAAmB,IAAI,CAAC,IAAI,YAAY;gBACrE,qBAAqB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO;gBACtJ,mBAAmB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,iBAAiB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU;aAC3J,CAAC,IAAI,CAAC,IAAI,CAAC;SACb;KACF,CAAC;AACJ,CAAC,CAAC;AAvCW,QAAA,sCAAsC,0CAuCjD"}
1
+ {"version":3,"file":"transformRealizeAuthorization.js","sourceRoot":"","sources":["../../../../../../src/orchestrate/realize/histories/transformRealizeAuthorization.ts"],"names":[],"mappings":";;;AAEA,yCAA2C;AAE3C,+BAA0B;AAKnB,MAAM,sCAAsC,GAAG,CAGpD,GAAyB,EACzB,IAAuB,EAGvB,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,s8bAAkD;SACvD;QACD;YACE,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACpC,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,kBAAU,CAAC,IAAI,CAAA;;;UAGjB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;;;;;;UAMpB,IAAI,CAAC,SAAS,CAAC,MAAA,GAAG,CAAC,KAAK,EAAE,CAAC,MAAM,0CAAE,OAAO,CAAC;;;;;;;2BAO1B,IAAI,CAAC,IAAI,mBAAmB,IAAI,CAAC,IAAI;4BACpC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;0BAC5H,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,iBAAiB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;OAChJ;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AAzCW,QAAA,sCAAsC,0CAyCjD"}
@@ -1,78 +1,80 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.transformRealizeAuthorizationCorrectHistories = void 0;
4
+ const utils_1 = require("@autobe/utils");
4
5
  const uuid_1 = require("uuid");
5
6
  const transformRealizeAuthorizationCorrectHistories = (ctx, auth, templateFiles, diagnostics) => {
6
7
  var _a;
7
8
  return [
8
9
  {
9
- id: (0, uuid_1.v4)(),
10
+ id: (0, uuid_1.v7)(),
10
11
  created_at: new Date().toISOString(),
11
12
  type: "systemMessage",
12
- text: "# NestJS Authentication Provider & Decorator Generation AI Agent \n\n## Naming Conventions\n\n### Notation Types\nThe following naming conventions (notations) are used throughout the system:\n- **camelCase**: First word lowercase, subsequent words capitalized (e.g., `userAccount`, `productItem`)\n- **PascalCase**: All words capitalized (e.g., `UserAccount`, `ProductItem`)\n- **snake_case**: All lowercase with underscores between words (e.g., `user_account`, `product_item`)\n\n### Specific Property Notations\n- **IAutoBeRealizeAuthorizationApplication.IProvider.name**: Use camelCase notation (format: `{Role.name(PascalCase)}Authorize`)\n- **IAutoBeRealizeAuthorizationApplication.IDecorator.name**: Use PascalCase notation (format: `{Role.name(PascalCase)}Auth`)\n- **IAutoBeRealizeAuthorizationApplication.IPayloadType.name**: Use PascalCase notation (format: `{Role.name(PascalCase)}Payload`)\n\nYou are a world-class NestJS expert and TypeScript developer. Your role is to automatically generate Provider functions and Decorators for JWT authentication based on given Role information and Prisma Schema. \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 authorization implementation 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## Core Mission \n\nGenerate authentication Provider and Decorator code specialized for specific Roles based on Role information provided by users. \n\n## Input Information \n\n- **Role Name**: The authentication role to generate (e.g., admin, user, manager, etc.) \n- **Prisma Schema**: Database table information.\n\n## File Structure\n\n**IMPORTANT: Understanding the file structure is crucial for correct import paths:**\n\n```\nsrc/\n\u251C\u2500\u2500 MyGlobal.ts\n\u251C\u2500\u2500 decorators/\n\u2502 \u251C\u2500\u2500 AdminAuth.ts\n\u2502 \u251C\u2500\u2500 UserAuth.ts\n\u2502 \u2514\u2500\u2500 payload/\n\u2502 \u251C\u2500\u2500 AdminPayload.ts\n\u2502 \u2514\u2500\u2500 UserPayload.ts\n\u2514\u2500\u2500 providers/\n \u2514\u2500\u2500 authorize/\n \u251C\u2500\u2500 jwtAuthorize.ts \u2190 Shared JWT verification function\n \u251C\u2500\u2500 adminAuthorize.ts \u2190 Same directory as jwtAuthorize\n \u2514\u2500\u2500 userAuthorize.ts \u2190 Same directory as jwtAuthorize\n```\n\n## Code Generation Rules \n\n### 1. Provider Function Generation Rules \n\n- Function name: `{Role.name(PascalCase)}Authorize` format (e.g., adminAuthorize, userAuthorize) \n- Must use the `jwtAuthorize` function for JWT token verification \n- **\u26A0\uFE0F CRITICAL: Import jwtAuthorize using `import { jwtAuthorize } from \"./jwtAuthorize\";` (NOT from \"../../providers/authorize/jwtAuthorize\" or any other path)**\n- Verify payload type and check if `payload.type` matches the correct role \n- Query database using `MyGlobal.prisma.{tableName}` format to fetch **only the authorization model itself** - do not include relations or business logic models (no `include` statements for profile, etc.) \n- Verify that the user actually exists in the database \n- Function return type should be `{Role.name(PascalCase)}Payload` interface \n- Return the `payload` variable whenever feasible in provider functions. \n- **Always check the Prisma schema for validation columns (e.g., `deleted_at`, status fields) within the authorization model and include them in the `where` clause to ensure the user is valid and active.** \n\n### 2. Payload Interface Generation Rules \n\n- Interface name: `{Role.name(PascalCase)}Payload` format (e.g., AdminPayload, UserPayload) \n- Required fields: \n - `id: string & tags.Format<\"uuid\">`: User ID (UUID format) \n - `type: \"{role}\"`: Discriminator for role identification \n- Additional fields should be generated according to Role characteristics and \"Prisma Schema\" \n\n### 3. Decorator Generation Rules \n\n- Decorator name: `{Role.name(PascalCase)}Auth` format (e.g., AdminAuth, UserAuth) \n- Use SwaggerCustomizer to add bearer token security schema to API documentation \n- Use createParamDecorator to implement actual authentication logic \n- Use Singleton pattern to manage decorator instances \n\n### 4. Code Style and Structure\n\n- Comply with TypeScript strict mode \n- Utilize NestJS Exception classes (ForbiddenException, UnauthorizedException) \n- Ensure type safety using typia tags \n- Add appropriate JSDoc comments \n\n## Reference Functions and Examples \n\n### JWT Authentication Function \n\n```typescript\n// File path: src/providers/authorize/jwtAuthorize.ts\nimport { ForbiddenException, UnauthorizedException } from \"@nestjs/common\";\nimport jwt from \"jsonwebtoken\";\n\nimport { MyGlobal } from \"../../MyGlobal\";\n\nexport function jwtAuthorize(props: {\n request: {\n headers: { authorization?: string };\n };\n}) {\n if (!props.request.headers.authorization)\n throw new ForbiddenException(\"No token value exists\");\n else if (\n props.request.headers.authorization.startsWith(BEARER_PREFIX) === false\n )\n throw new UnauthorizedException(\"Invalid token\");\n\n // PARSE TOKEN\n try {\n const token: string = props.request.headers.authorization.substring(\n BEARER_PREFIX.length,\n );\n\n const verified = jwt.verify(token, MyGlobal.env.JWT_SECRET_KEY);\n\n return verified;\n } catch {\n throw new UnauthorizedException(\"Invalid token\");\n }\n}\n\nconst BEARER_PREFIX = \"Bearer \";\n``` \n\n### Provider Function Example \n\n**\u26A0\uFE0F CRITICAL IMPORT PATHS:**\n- `jwtAuthorize` MUST be imported from `\"./jwtAuthorize\"` (same directory)\n- NOT `\"../../providers/authorize/jwtAuthorize\"` \u274C\n- NOT `\"../jwtAuthorize\"` \u274C\n- ONLY `\"./jwtAuthorize\"` \u2705\n\n```typescript\n// File path: src/providers/authorize/adminAuthorize.ts\nimport { ForbiddenException } from \"@nestjs/common\";\n\nimport { MyGlobal } from \"../../MyGlobal\";\nimport { jwtAuthorize } from \"./jwtAuthorize\"; // \u2190 CORRECT: Same directory import\nimport { AdminPayload } from \"../../decorators/payload/AdminPayload\";\n\nexport async function adminAuthorize(request: {\n headers: {\n authorization?: string;\n };\n}): Promise<AdminPayload> {\n const payload: AdminPayload = jwtAuthorize({ request }) as AdminPayload;\n\n if (payload.type !== \"admin\") {\n throw new ForbiddenException(`You're not ${payload.type}`);\n }\n\n const admin = await MyGlobal.prisma.admins.findFirst({\n where: {\n id: payload.id,\n user: {\n deleted_at: null,\n is_banned: false,\n },\n },\n });\n\n if (admin === null) {\n throw new ForbiddenException(\"You're not enrolled\");\n }\n\n return payload;\n}\n``` \n\n### Decorator Example\n\n```typescript\n// File path: src/decorators/AdminAuth.ts\nimport { SwaggerCustomizer } from \"@nestia/core\";\nimport { ExecutionContext, createParamDecorator } from \"@nestjs/common\";\nimport { Singleton } from \"tstl\";\n\nimport { adminAuthorize } from \"../providers/authorize/adminAuthorize\";\n\nexport const AdminAuth =\n (): ParameterDecorator =>\n (\n target: object,\n propertyKey: string | symbol | undefined,\n parameterIndex: number,\n ): void => {\n SwaggerCustomizer((props) => {\n props.route.security ??= [];\n props.route.security.push({\n bearer: [],\n });\n })(target, propertyKey as string, undefined!);\n singleton.get()(target, propertyKey, parameterIndex);\n };\n\nconst singleton = new Singleton(() =>\n createParamDecorator(async (_0: unknown, ctx: ExecutionContext) => {\n const request = ctx.switchToHttp().getRequest();\n return adminAuthorize(request);\n })(),\n);\n``` \n\n### Decorator Type Example \n\nIn case of the columns related to Date type like `created_at`, `updated_at`, `deleted_at`, must use the `string & tags.Format<'date-time'>` Type instead of Date type. \n\n```typescript\n// File path: src/decorators/payload/AdminPayload.ts\nimport { tags } from \"typia\";\n\nexport interface AdminPayload {\n /**\n * Admin ID.\n */\n id: string & tags.Format<\"uuid\">;\n\n /**\n * Discriminator for the discriminated union type.\n */\n type: \"admin\";\n}\n``` \n\n## Output Format \n\nYou must provide your response in a structured JSON format containing the following nested structure: \n\n**provider**: An object containing the authentication Provider function configuration \n\n- **name**: The name of the authentication Provider function in `{Role.name(PascalCase)}Authorize` format (e.g., adminAuthorize, userAuthorize). This function verifies JWT tokens and returns user information for the specified role. \n- **code**: Complete TypeScript code for the authentication Provider function only. Must include JWT verification, role checking, database query logic, and proper import statements for the Payload interface.\n\n**decorator**: An object containing the authentication Decorator configuration \n\n- **name**: The name of the Decorator to be generated in `{Role.name(PascalCase)}Auth` format (e.g., AdminAuth, UserAuth). The decorator name used in Controller method parameters. \n- **code**: Complete TypeScript code for the Decorator. Must include complete authentication decorator implementation using SwaggerCustomizer, createParamDecorator, and Singleton pattern.\n\n**decoratorType**: An object containing the Decorator Type configuration\n\n- **name**: The name of the Decorator Type in `{Role.name(PascalCase)}Payload` format (e.g., AdminPayload, UserPayload). Used as the TypeScript type for the authenticated user data.\n- **code**: Complete TypeScript code for the Payload type interface. Must include proper field definitions with typia tags for type safety.\n\n## Work Process \n\n1. Analyze the input Role name \n2. Generate Provider function for the Role \n3. Define Payload interface \n4. Implement Decorator \n5. Verify that all code follows example patterns \n6. Generate response in specified format \n\n## Quality Standards \n\n- Ensure type safety \n- Follow NestJS conventions \n- Complete error handling \n- Code reusability \n- Complete documentation \n\n## Common Mistakes to Avoid\n\n1. **\u274C INCORRECT jwtAuthorize import paths:**\n ```typescript\n // WRONG - Do not use these:\n import { jwtAuthorize } from \"../../providers/authorize/jwtAuthorize\";\n import { jwtAuthorize } from \"../authorize/jwtAuthorize\";\n import { jwtAuthorize } from \"../../providers/jwtAuthorize\";\n ```\n\n2. **\u2705 CORRECT jwtAuthorize import path:**\n ```typescript\n // CORRECT - Always use this:\n import { jwtAuthorize } from \"./jwtAuthorize\";\n ```\n\nWhen users provide Role information, generate complete and practical authentication code according to the above rules." /* AutoBeSystemPromptConstant.REALIZE_AUTHORIZATION */,
13
+ text: "# NestJS Authentication Provider & Decorator Generation AI Agent \n\n## Naming Conventions\n\n### Notation Types\nThe following naming conventions (notations) are used throughout the system:\n- **camelCase**: First word lowercase, subsequent words capitalized (e.g., `userAccount`, `productItem`)\n- **PascalCase**: All words capitalized (e.g., `UserAccount`, `ProductItem`)\n- **snake_case**: All lowercase with underscores between words (e.g., `user_account`, `product_item`)\n\n### Specific Property Notations\n- **IAutoBeRealizeAuthorizationApplication.IProvider.name**: Use camelCase notation (format: `{Role.name(PascalCase)}Authorize`)\n- **IAutoBeRealizeAuthorizationApplication.IDecorator.name**: Use PascalCase notation (format: `{Role.name(PascalCase)}Auth`)\n- **IAutoBeRealizeAuthorizationApplication.IPayloadType.name**: Use PascalCase notation (format: `{Role.name(PascalCase)}Payload`)\n\nYou are a world-class NestJS expert and TypeScript developer. Your role is to automatically generate Provider functions and Decorators for JWT authentication based on given Role information and Prisma Schema. \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 authorization implementation 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## Core Mission \n\nGenerate authentication Provider and Decorator code specialized for specific Roles based on Role information provided by users. \n\n## Input Information \n\n- **Role Name**: The authentication role to generate (e.g., admin, user, manager, etc.) \n- **Prisma Schema**: Database table information.\n\n## File Structure\n\n**IMPORTANT: Understanding the file structure is crucial for correct import paths:**\n\n```\nsrc/\n\u251C\u2500\u2500 MyGlobal.ts\n\u251C\u2500\u2500 decorators/\n\u2502 \u251C\u2500\u2500 AdminAuth.ts\n\u2502 \u251C\u2500\u2500 UserAuth.ts\n\u2502 \u2514\u2500\u2500 payload/\n\u2502 \u251C\u2500\u2500 AdminPayload.ts\n\u2502 \u2514\u2500\u2500 UserPayload.ts\n\u2514\u2500\u2500 providers/\n \u2514\u2500\u2500 authorize/\n \u251C\u2500\u2500 jwtAuthorize.ts \u2190 Shared JWT verification function\n \u251C\u2500\u2500 adminAuthorize.ts \u2190 Same directory as jwtAuthorize\n \u2514\u2500\u2500 userAuthorize.ts \u2190 Same directory as jwtAuthorize\n```\n\n## Code Generation Rules \n\n### 1. Provider Function Generation Rules \n\n- Function name: `{Role.name(PascalCase)}Authorize` format (e.g., adminAuthorize, userAuthorize) \n- Must use the `jwtAuthorize` function for JWT token verification \n- **\u26A0\uFE0F CRITICAL: Import jwtAuthorize using `import { jwtAuthorize } from \"./jwtAuthorize\";` (NOT from \"../../providers/authorize/jwtAuthorize\" or any other path)**\n- Verify payload type and check if `payload.type` matches the correct role \n- Query database using `MyGlobal.prisma.{tableName}` format to fetch **only the authorization model itself** - do not include relations or business logic models (no `include` statements for profile, etc.) \n- Verify that the user actually exists in the database \n- Function return type should be `{Role.name(PascalCase)}Payload` interface \n- Return the `payload` variable whenever feasible in provider functions. \n- **Always check the Prisma schema for validation columns (e.g., `deleted_at`, status fields) within the authorization model and include them in the `where` clause to ensure the user is valid and active.** \n- **Database Query Strategy - CRITICAL for JWT Token Structure:**\n - **Analyze the Prisma Schema to determine table relationships**\n - **payload.id ALWAYS contains the top-level user table ID** (most fundamental user entity in your schema)\n - **If role table extends a user table (has foreign key like `user_id`):** Use the foreign key field: `where: { user_id: payload.id }`\n - **If role table is standalone (no foreign key to user table):** Use primary key field: `where: { id: payload.id }`\n\n### 2. Payload Interface Generation Rules \n\n- Interface name: `{Role.name(PascalCase)}Payload` format (e.g., AdminPayload, UserPayload) \n- Required fields: \n - `id: string & tags.Format<\"uuid\">`: **ALWAYS contains the top-level user table ID** - this is the most fundamental user identifier in your system, not the role table's own ID\n - `type: \"{role}\"`: Discriminator for role identification \n- Additional fields should be generated according to Role characteristics and \"Prisma Schema\" \n\n### 3. Decorator Generation Rules \n\n- Decorator name: `{Role.name(PascalCase)}Auth` format (e.g., AdminAuth, UserAuth) \n- Use SwaggerCustomizer to add bearer token security schema to API documentation \n- Use createParamDecorator to implement actual authentication logic \n- Use Singleton pattern to manage decorator instances \n\n### 4. Code Style and Structure\n\n- Comply with TypeScript strict mode \n- Utilize NestJS Exception classes (ForbiddenException, UnauthorizedException) \n- Ensure type safety using typia tags \n- Add appropriate JSDoc comments \n\n## Reference Functions and Examples \n\n### JWT Authentication Function \n\n```typescript\n// File path: src/providers/authorize/jwtAuthorize.ts\nimport { ForbiddenException, UnauthorizedException } from \"@nestjs/common\";\nimport jwt from \"jsonwebtoken\";\n\nimport { MyGlobal } from \"../../MyGlobal\";\n\nexport function jwtAuthorize(props: {\n request: {\n headers: { authorization?: string };\n };\n}) {\n if (!props.request.headers.authorization)\n throw new ForbiddenException(\"No token value exists\");\n else if (\n props.request.headers.authorization.startsWith(BEARER_PREFIX) === false\n )\n throw new UnauthorizedException(\"Invalid token\");\n\n // PARSE TOKEN\n try {\n const token: string = props.request.headers.authorization.substring(\n BEARER_PREFIX.length,\n );\n\n const verified = jwt.verify(token, MyGlobal.env.JWT_SECRET_KEY);\n\n return verified;\n } catch {\n throw new UnauthorizedException(\"Invalid token\");\n }\n}\n\nconst BEARER_PREFIX = \"Bearer \";\n``` \n\n### Provider Function Example \n\n**\u26A0\uFE0F CRITICAL IMPORT PATHS:**\n- `jwtAuthorize` MUST be imported from `\"./jwtAuthorize\"` (same directory)\n- NOT `\"../../providers/authorize/jwtAuthorize\"` \u274C\n- NOT `\"../jwtAuthorize\"` \u274C\n- ONLY `\"./jwtAuthorize\"` \u2705\n\n```typescript\n// File path: src/providers/authorize/adminAuthorize.ts\nimport { ForbiddenException } from \"@nestjs/common\";\n\nimport { MyGlobal } from \"../../MyGlobal\";\nimport { jwtAuthorize } from \"./jwtAuthorize\"; // \u2190 CORRECT: Same directory import\nimport { AdminPayload } from \"../../decorators/payload/AdminPayload\";\n\nexport async function adminAuthorize(request: {\n headers: {\n authorization?: string;\n };\n}): Promise<AdminPayload> {\n const payload: AdminPayload = jwtAuthorize({ request }) as AdminPayload;\n\n if (payload.type !== \"admin\") {\n throw new ForbiddenException(`You're not ${payload.type}`);\n }\n\n // payload.id contains top-level user table ID\n // Query using appropriate field based on schema structure\n const admin = await MyGlobal.prisma.admins.findFirst({\n where: {\n user_id: payload.id, // \u2190 Use foreign key if Admin extends User\n user: {\n deleted_at: null,\n is_banned: false,\n },\n },\n });\n\n if (admin === null) {\n throw new ForbiddenException(\"You're not enrolled\");\n }\n\n return payload;\n}\n``` \n\n### Decorator Example\n\n```typescript\n// File path: src/decorators/AdminAuth.ts\nimport { SwaggerCustomizer } from \"@nestia/core\";\nimport { ExecutionContext, createParamDecorator } from \"@nestjs/common\";\nimport { Singleton } from \"tstl\";\n\nimport { adminAuthorize } from \"../providers/authorize/adminAuthorize\";\n\nexport const AdminAuth =\n (): ParameterDecorator =>\n (\n target: object,\n propertyKey: string | symbol | undefined,\n parameterIndex: number,\n ): void => {\n SwaggerCustomizer((props) => {\n props.route.security ??= [];\n props.route.security.push({\n bearer: [],\n });\n })(target, propertyKey as string, undefined!);\n singleton.get()(target, propertyKey, parameterIndex);\n };\n\nconst singleton = new Singleton(() =>\n createParamDecorator(async (_0: unknown, ctx: ExecutionContext) => {\n const request = ctx.switchToHttp().getRequest();\n return adminAuthorize(request);\n })(),\n);\n``` \n\n### Decorator Type Example \n\nIn case of the columns related to Date type like `created_at`, `updated_at`, `deleted_at`, must use the `string & tags.Format<'date-time'>` Type instead of Date type. \n\n```typescript\n// File path: src/decorators/payload/AdminPayload.ts\nimport { tags } from \"typia\";\n\nexport interface AdminPayload {\n /**\n * Top-level user table ID (the fundamental user identifier in the system).\n */\n id: string & tags.Format<\"uuid\">;\n\n /**\n * Discriminator for the discriminated union type.\n */\n type: \"admin\";\n}\n``` \n\n## JWT Token Structure Context\n\n**IMPORTANT: Understanding how JWT tokens are structured in this system**\n\nThe JWT payload will always contain:\n- `id`: The top-level user table ID (most fundamental user entity)\n- `type`: The role type (\"admin\", \"user\", \"manager\", etc.)\n\n**Example scenarios:**\n1. **If Admin extends User table:**\n - JWT payload.id = User.id (top-level user ID)\n - Database query: `where: { user_id: payload.id }`\n\n2. **If Customer is standalone:**\n - JWT payload.id = Customer.id (Customer is the top-level user)\n - Database query: `where: { id: payload.id }`\n\n## Output Format \n\nYou must provide your response in a structured JSON format containing the following nested structure: \n\n**provider**: An object containing the authentication Provider function configuration \n\n- **name**: The name of the authentication Provider function in `{Role.name(PascalCase)}Authorize` format (e.g., adminAuthorize, userAuthorize). This function verifies JWT tokens and returns user information for the specified role. \n- **code**: Complete TypeScript code for the authentication Provider function only. Must include JWT verification, role checking, database query logic with proper top-level user ID handling, and proper import statements for the Payload interface.\n\n**decorator**: An object containing the authentication Decorator configuration \n\n- **name**: The name of the Decorator to be generated in `{Role.name(PascalCase)}Auth` format (e.g., AdminAuth, UserAuth). The decorator name used in Controller method parameters. \n- **code**: Complete TypeScript code for the Decorator. Must include complete authentication decorator implementation using SwaggerCustomizer, createParamDecorator, and Singleton pattern.\n\n**decoratorType**: An object containing the Decorator Type configuration\n\n- **name**: The name of the Decorator Type in `{Role.name(PascalCase)}Payload` format (e.g., AdminPayload, UserPayload). Used as the TypeScript type for the authenticated user data.\n- **code**: Complete TypeScript code for the Payload type interface. Must include proper field definitions with typia tags for type safety.\n\n## Work Process \n\n1. Analyze the input Role name \n2. **Analyze the Prisma Schema to identify table relationships and determine the top-level user table**\n3. **Determine appropriate database query strategy based on whether role table extends user table or is standalone**\n4. Generate Provider function for the Role with correct database query field\n5. Define Payload interface with top-level user table ID\n6. Implement Decorator \n7. Verify that all code follows example patterns \n8. Generate response in specified format \n\n## Quality Standards \n\n- Ensure type safety \n- Follow NestJS conventions \n- Complete error handling \n- Code reusability \n- Complete documentation \n- **Correct handling of top-level user table ID throughout all components**\n\n## Common Mistakes to Avoid\n\n1. **\u274C INCORRECT jwtAuthorize import paths:**\n ```typescript\n // WRONG - Do not use these:\n import { jwtAuthorize } from \"../../providers/authorize/jwtAuthorize\";\n import { jwtAuthorize } from \"../authorize/jwtAuthorize\";\n import { jwtAuthorize } from \"../../providers/jwtAuthorize\";\n ```\n\n2. **\u2705 CORRECT jwtAuthorize import path:**\n ```typescript\n // CORRECT - Always use this:\n import { jwtAuthorize } from \"./jwtAuthorize\";\n ```\n\n3. **\u274C INCORRECT database query field selection:**\n ```typescript\n // WRONG - Always using 'id' field without analyzing schema:\n const admin = await MyGlobal.prisma.admins.findFirst({\n where: { id: payload.id } // Wrong if Admin extends User\n });\n ```\n\n4. **\u2705 CORRECT database query field selection:**\n ```typescript\n // CORRECT - Using appropriate field based on schema structure:\n const admin = await MyGlobal.prisma.admins.findFirst({\n where: { user_id: payload.id } // Correct if Admin extends User\n });\n ```\n \nWhen users provide Role information, generate complete and practical authentication code according to the above rules." /* AutoBeSystemPromptConstant.REALIZE_AUTHORIZATION */,
13
14
  },
14
15
  {
15
- id: (0, uuid_1.v4)(),
16
+ id: (0, uuid_1.v7)(),
16
17
  created_at: new Date().toISOString(),
17
18
  type: "systemMessage",
18
19
  text: "# 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 \n\nProvide your corrected code in the following JSON format: \n\n```json\n{\n \"provider\": {\n \"name\": \"corrected_provider_name\",\n \"code\": \"corrected_provider_code\"\n },\n \"decorator\": {\n \"name\": \"corrected_decorator_name\", \n \"code\": \"corrected_decorator_code\"\n }\n \"decoratorType\": {\n \"name\": \"corrected_payload_type_name\",\n \"code\": \"corrected_payload_type_code\"\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 and identify patterns \n2. **Then**, explain your understanding of the issues \n3. **Next**, describe your correction strategy \n4. **Finally**, provide the corrected code in the specified JSON format \n\nRemember: Focus on fixing compilation errors while preserving the original authentication logic and NestJS integration patterns." /* AutoBeSystemPromptConstant.REALIZE_AUTHORIZATION_CORRECT */,
19
20
  },
20
21
  {
21
- id: (0, uuid_1.v4)(),
22
+ id: (0, uuid_1.v7)(),
22
23
  created_at: new Date().toISOString(),
23
24
  type: "assistantMessage",
24
- text: [
25
- "## Generated TypeScript Code",
26
- "",
27
- "```json",
28
- `${JSON.stringify({
29
- provider: {
30
- location: auth.provider.location,
31
- name: auth.provider.name,
32
- content: auth.provider.content,
33
- },
34
- decorator: {
35
- location: auth.decorator.location,
36
- name: auth.decorator.name,
37
- content: auth.decorator.content,
38
- },
39
- payload: {
40
- location: auth.payload.location,
41
- name: auth.payload.name,
42
- content: auth.payload.content,
43
- },
44
- })}`,
45
- "```",
46
- "",
47
- "## Prisma Schema",
48
- "",
49
- "```json",
50
- `${JSON.stringify((_a = ctx.state().prisma) === null || _a === void 0 ? void 0 : _a.schemas)}`,
51
- "```",
52
- "",
53
- "## File Paths",
54
- "",
55
- Object.keys(templateFiles)
56
- .map((path) => `- ${path}`)
57
- .join("\n"),
58
- "",
59
- "## Compile Errors",
60
- "",
61
- "Fix the compilation error in the provided code.",
62
- "",
63
- "```json",
64
- JSON.stringify(diagnostics),
65
- "```",
66
- "## Component Naming Convention",
67
- "",
68
- "If the name of the component is not correct, please correct it.",
69
- "",
70
- "Please follow this naming convention for the authorization components:",
71
- "",
72
- `- Provider Name: ${auth.role.name.toLowerCase()}Authorize (e.g. ${auth.role.name.toLowerCase()}Authorize)`,
73
- `- Decorator Name: ${auth.role.name.charAt(0).toUpperCase() + auth.role.name.slice(1).toLowerCase()}Auth (e.g. ${auth.role.name.charAt(0).toUpperCase() + auth.role.name.slice(1).toLowerCase()}Auth)`,
74
- `- Payload Name: ${auth.role.name.charAt(0).toUpperCase() + auth.role.name.slice(1).toLowerCase()}Payload (e.g. ${auth.role.name.charAt(0).toUpperCase() + auth.role.name.slice(1).toLowerCase()}Payload)`,
75
- ].join("\n"),
25
+ text: utils_1.StringUtil.trim `
26
+ ## Generated TypeScript Code
27
+
28
+ \`\`\`json
29
+ ${JSON.stringify({
30
+ provider: {
31
+ location: auth.provider.location,
32
+ name: auth.provider.name,
33
+ content: auth.provider.content,
34
+ },
35
+ decorator: {
36
+ location: auth.decorator.location,
37
+ name: auth.decorator.name,
38
+ content: auth.decorator.content,
39
+ },
40
+ payload: {
41
+ location: auth.payload.location,
42
+ name: auth.payload.name,
43
+ content: auth.payload.content,
44
+ },
45
+ })}
46
+ \`\`\`
47
+
48
+ ## Prisma Schema
49
+
50
+ \`\`\`json
51
+ ${JSON.stringify((_a = ctx.state().prisma) === null || _a === void 0 ? void 0 : _a.schemas)}
52
+ \`\`\`
53
+
54
+ ## File Paths
55
+
56
+ ${Object.keys(templateFiles)
57
+ .map((path) => `- ${path}`)
58
+ .join("\n")}
59
+
60
+ ## Compile Errors
61
+
62
+ Fix the compilation error in the provided code.
63
+
64
+ \`\`\`json
65
+ ${JSON.stringify(diagnostics)}
66
+ \`\`\`
67
+
68
+ ## Component Naming Convention
69
+
70
+ If the name of the component is not correct, please correct it.
71
+
72
+ Please follow this naming convention for the authorization components:
73
+
74
+ - Provider Name: ${auth.role.name.toLowerCase()}Authorize (e.g. ${auth.role.name.toLowerCase()}Authorize)
75
+ - Decorator Name: ${auth.role.name.charAt(0).toUpperCase() + auth.role.name.slice(1).toLowerCase()}Auth (e.g. ${auth.role.name.charAt(0).toUpperCase() + auth.role.name.slice(1).toLowerCase()}Auth)
76
+ - Payload Name: ${auth.role.name.charAt(0).toUpperCase() + auth.role.name.slice(1).toLowerCase()}Payload (e.g. ${auth.role.name.charAt(0).toUpperCase() + auth.role.name.slice(1).toLowerCase()}Payload)
77
+ `,
76
78
  },
77
79
  ];
78
80
  };
@@ -1 +1 @@
1
- {"version":3,"file":"transformRealizeAuthorizationCorrectHistories.js","sourceRoot":"","sources":["../../../../../../src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.ts"],"names":[],"mappings":";;;AAMA,+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,2kXAAkD;SACvD;QACD;YACE,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACpC,IAAI,EAAE,eAAe;YACrB,IAAI,+vMAA0D;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;gBACJ,8BAA8B;gBAC9B,EAAE;gBACF,SAAS;gBACT,GAAG,IAAI,CAAC,SAAS,CAAC;oBAChB,QAAQ,EAAE;wBACR,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ;wBAChC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI;wBACxB,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO;qBAC/B;oBACD,SAAS,EAAE;wBACT,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ;wBACjC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI;wBACzB,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO;qBAChC;oBACD,OAAO,EAAE;wBACP,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ;wBAC/B,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;wBACvB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;qBAC9B;iBACiD,CAAC,EAAE;gBACvD,KAAK;gBACL,EAAE;gBACF,kBAAkB;gBAClB,EAAE;gBACF,SAAS;gBACT,GAAG,IAAI,CAAC,SAAS,CAAC,MAAA,GAAG,CAAC,KAAK,EAAE,CAAC,MAAM,0CAAE,OAAO,CAAC,EAAE;gBAChD,KAAK;gBACL,EAAE;gBACF,eAAe;gBACf,EAAE;gBACF,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;qBACvB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC;qBAC1B,IAAI,CAAC,IAAI,CAAC;gBACb,EAAE;gBACF,mBAAmB;gBACnB,EAAE;gBACF,iDAAiD;gBACjD,EAAE;gBACF,SAAS;gBACT,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;gBAC3B,KAAK;gBACL,gCAAgC;gBAChC,EAAE;gBACF,iEAAiE;gBACjE,EAAE;gBACF,wEAAwE;gBACxE,EAAE;gBACF,oBAAoB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,mBAAmB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,YAAY;gBAC3G,qBAAqB,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,OAAO;gBACtM,mBAAmB,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,UAAU;aAC3M,CAAC,IAAI,CAAC,IAAI,CAAC;SACb;KACF,CAAC;AACJ,CAAC,CAAC;AAjFW,QAAA,6CAA6C,iDAiFxD"}
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,s8bAAkD;SACvD;QACD;YACE,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACpC,IAAI,EAAE,eAAe;YACrB,IAAI,+vMAA0D;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"}
@@ -1,30 +1,34 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.transformRealizeCorrectHistories = transformRealizeCorrectHistories;
4
+ const utils_1 = require("@autobe/utils");
4
5
  const uuid_1 = require("uuid");
5
6
  const transformRealizeWriteHistories_1 = require("./transformRealizeWriteHistories");
6
7
  function transformRealizeCorrectHistories(props) {
7
8
  return [
8
9
  ...(0, transformRealizeWriteHistories_1.transformRealizeWriteHistories)(props),
9
10
  {
10
- id: (0, uuid_1.v4)(),
11
+ id: (0, uuid_1.v7)(),
11
12
  type: "assistantMessage",
12
- text: [
13
- `Below is the code you made before. It's also something to review.`,
14
- "```typescript",
15
- props.code,
16
- "```",
17
- `The code has a compilation error:`,
18
- "```json",
19
- JSON.stringify(props.diagnostic),
20
- "",
21
- ].join("\n"),
13
+ text: utils_1.StringUtil.trim `
14
+ Below is the code you made before. It's also something to review.
15
+
16
+ \`\`\`typescript
17
+ ${props.code}
18
+ \`\`\`
19
+
20
+ The code has a compilation error:
21
+
22
+ \`\`\`json
23
+ ${JSON.stringify(props.diagnostic)}
24
+ \`\`\`
25
+ `,
22
26
  created_at: new Date().toISOString(),
23
27
  },
24
28
  {
25
- id: (0, uuid_1.v4)(),
29
+ id: (0, uuid_1.v7)(),
26
30
  type: "systemMessage",
27
- text: "# \uD83D\uDD27 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\n## \uD83C\uDFAF Primary Mission\n\nFix the compilation error in the provided code with **minimal changes** while preserving:\n- Original business logic and flow (EXCEPT when impossible due to missing schema)\n- API contract requirements (EXCEPT when schema doesn't support them)\n- Database operation patterns\n- Type safety and conventions\n\n**CRITICAL RULE**: Schema is the source of truth. If a field doesn't exist in the schema, it CANNOT be used, regardless of what the comments or API specification says.\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// \u274C 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// \u2705 Option 1: Use hard delete instead\nawait prisma.table.delete({\n where: { id }\n});\n\n// \u2705 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// \u2705 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 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**Decision Tree**:\n```\nIs this field absolutely required by the API specification?\n\u251C\u2500\u2500 YES \u2192 Check if field exists with different name\n\u2502 \u251C\u2500\u2500 YES \u2192 Use correct field name\n\u2502 \u2514\u2500\u2500 NO \u2192 SCHEMA-API CONTRADICTION (Unrecoverable)\n\u2514\u2500\u2500 NO \u2192 Simply remove the field from query\n```\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```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**\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 }); // \u274C TYPE ERROR\n\n// SOLUTION 1: Define inline (BEST)\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// SOLUTION 2: If variable needed, use 'as const' everywhere\nconst orderBy = body.orderBy \n ? { [body.orderBy]: \"desc\" as const }\n : { created_at: \"desc\" as const };\n\n// SOLUTION 3: Type assertion (LAST RESORT)\nconst orderBy: any = body.orderBy \n ? { [body.orderBy]: \"desc\" }\n : { created_at: \"desc\" };\n```\n\n**Rule**: Prisma parameters MUST be defined inline or use `as const` for proper type inference.\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 * IMPLEMENTATION BLOCKED - SCHEMA-API CONTRADICTION\n * \n * Required by API specification:\n * - [Specific requirement that cannot be met]\n * \n * Missing from Prisma schema:\n * - [Specific missing field/relation]\n * \n * Resolution options:\n * 1. Add [field_name] to [table_name] in schema\n * 2. Remove [requirement] from API specification\n * \n * Current implementation returns type-safe mock data.\n * \n * @param props - Request properties\n * @param props.auth - Authentication payload\n * @param props.body - Request body\n * @param props.params - Path parameters\n * @param props.query - Query parameters\n * @returns Mock response matching expected type\n * @todo Resolve schema-API contradiction\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 // Implementation impossible due to schema-API contradiction\n // See function documentation for details\n return typia.random<IResponseType>();\n}\n```\n\n## \u2705 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 4 (Implement Safe Placeholder)\n```\n\n### Step 3: Apply Minimal Fix\nBased on error code, apply the appropriate fix:\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\n### Step 4: 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** remove business logic to make code compile\n5. **NEVER** violate REALIZE_WRITE_TOTAL conventions\n6. **NEVER** create variables for Prisma operation parameters\n7. **NEVER** add custom import statements - all imports are auto-generated\n8. **NEVER** use bcrypt, bcryptjs, or external hashing libraries\n9. **NEVER** prioritize comments over types - types are the source of truth\n\n## \u2705 ALWAYS DO\n\n1. **ALWAYS** check if error is due to schema-API mismatch\n2. **ALWAYS** preserve original business intent\n3. **ALWAYS** use proper type conversions\n4. **ALWAYS** document unrecoverable contradictions\n5. **ALWAYS** follow inline parameter rule for Prisma\n6. **ALWAYS** maintain type safety\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 | Remove field immediately | Use typia.random if required |\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| 2698 | Spreading non-object | Add null check | Check value source |\n| 2769 | Wrong function args | Fix parameters | Check overload signatures |\n| 2322 | Type not assignable | Add type assertion or 'as const' | Check if conversion possible |\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\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\n\n## \uD83C\uDFAF Success Criteria\n\nYour correction succeeds when:\n1. \u2705 All compilation errors resolved\n2. \u2705 Business logic unchanged\n3. \u2705 Conventions maintained\n4. \u2705 Unrecoverable errors documented with `typia.random<T>()`\n5. \u2705 No new errors introduced\n\n**Remember**: When facing a schema-API contradiction, it's professional to document and use `typia.random<T>()` rather than attempting impossible implementations." /* AutoBeSystemPromptConstant.REALIZE_CORRECT */,
31
+ text: "# \uD83D\uDD27 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\n## \uD83C\uDFAF Primary Mission\n\nFix the compilation error in the provided code with **minimal changes** while preserving:\n- Original business logic and flow (EXCEPT when impossible due to missing schema)\n- API contract requirements (EXCEPT when schema doesn't support them)\n- Database operation patterns\n- Type safety and conventions\n\n**CRITICAL RULE**: Schema is the source of truth. If a field doesn't exist in the schema, it CANNOT be used, regardless of what the comments or API specification says.\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// \u274C 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// \u2705 Option 1: Use hard delete instead\nawait prisma.table.delete({\n where: { id }\n});\n\n// \u2705 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// \u2705 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 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**Decision Tree**:\n```\nIs this field absolutely required by the API specification?\n\u251C\u2500\u2500 YES \u2192 Check if field exists with different name\n\u2502 \u251C\u2500\u2500 YES \u2192 Use correct field name\n\u2502 \u2514\u2500\u2500 NO \u2192 SCHEMA-API CONTRADICTION (Unrecoverable)\n\u2514\u2500\u2500 NO \u2192 Simply remove the field from query\n```\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```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**\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// \u274C ERROR: Type assignment fails\npagination: {\n current: page, // \u274C Type error!\n limit: limit, // \u274C Type error!\n records: total,\n pages: Math.ceil(total / limit),\n}\n\n// \u2705 SOLUTION: Use Number() conversion to strip brand types\npagination: {\n current: Number(page), // \u2705 Converts to plain number\n limit: Number(limit), // \u2705 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 }); // \u274C TYPE ERROR\n\n// SOLUTION 1: Define inline (BEST)\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// SOLUTION 2: If variable needed, use 'as const' everywhere\nconst orderBy = body.orderBy \n ? { [body.orderBy]: \"desc\" as const }\n : { created_at: \"desc\" as const };\n\n// SOLUTION 3: Type assertion (LAST RESORT)\nconst orderBy: any = body.orderBy \n ? { [body.orderBy]: \"desc\" }\n : { created_at: \"desc\" };\n```\n\n**Rule**: Prisma parameters MUST be defined inline or use `as const` for proper type inference.\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 * IMPLEMENTATION BLOCKED - SCHEMA-API CONTRADICTION\n * \n * Required by API specification:\n * - [Specific requirement that cannot be met]\n * \n * Missing from Prisma schema:\n * - [Specific missing field/relation]\n * \n * Resolution options:\n * 1. Add [field_name] to [table_name] in schema\n * 2. Remove [requirement] from API specification\n * \n * Current implementation returns type-safe mock data.\n * \n * @param props - Request properties\n * @param props.auth - Authentication payload\n * @param props.body - Request body\n * @param props.params - Path parameters\n * @param props.query - Query parameters\n * @returns Mock response matching expected type\n * @todo Resolve schema-API contradiction\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 // Implementation impossible due to schema-API contradiction\n // See function documentation for details\n return typia.random<IResponseType>();\n}\n```\n\n## \u2705 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 4 (Implement Safe Placeholder)\n```\n\n### Step 3: Apply Minimal Fix\nBased on error code, apply the appropriate fix:\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\n### Step 4: 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** remove business logic to make code compile\n5. **NEVER** violate REALIZE_WRITE_TOTAL conventions\n6. **NEVER** create variables for Prisma operation parameters\n7. **NEVER** add custom import statements - all imports are auto-generated\n8. **NEVER** use bcrypt, bcryptjs, or external hashing libraries\n9. **NEVER** prioritize comments over types - types are the source of truth\n\n## \u2705 ALWAYS DO\n\n1. **ALWAYS** check if error is due to schema-API mismatch\n2. **ALWAYS** preserve original business intent\n3. **ALWAYS** use proper type conversions\n4. **ALWAYS** document unrecoverable contradictions\n5. **ALWAYS** follow inline parameter rule for Prisma\n6. **ALWAYS** maintain type safety\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 | Remove field immediately | Use typia.random if required |\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| 2698 | Spreading non-object | Add null check | Check value source |\n| 2769 | Wrong function args | Fix parameters | Check overload signatures |\n| 2322 | Type not assignable | Add type assertion or 'as const' | Check if conversion possible |\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\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\n\n## \uD83C\uDFAF Success Criteria\n\nYour correction succeeds when:\n1. \u2705 All compilation errors resolved\n2. \u2705 Business logic unchanged\n3. \u2705 Conventions maintained\n4. \u2705 Unrecoverable errors documented with `typia.random<T>()`\n5. \u2705 No new errors introduced\n\n**Remember**: When facing a schema-API contradiction, it's professional to document and use `typia.random<T>()` rather than attempting impossible implementations." /* AutoBeSystemPromptConstant.REALIZE_CORRECT */,
28
32
  created_at: new Date().toISOString(),
29
33
  },
30
34
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"transformRealizeCorrectHistories.js","sourceRoot":"","sources":["../../../../../../src/orchestrate/realize/histories/transformRealizeCorrectHistories.ts"],"names":[],"mappings":";;AAaA,4EAmCC;AA3CD,+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,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE;gBACJ,mEAAmE;gBACnE,eAAe;gBACf,KAAK,CAAC,IAAI;gBACV,KAAK;gBACL,mCAAmC;gBACnC,SAAS;gBACT,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC;gBAChC,EAAE;aACH,CAAC,IAAI,CAAC,IAAI,CAAC;YACZ,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACrC;QACD;YACE,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,IAAI,EAAE,eAAe;YACrB,IAAI,k4ZAA4C;YAChD,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACrC;KACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"transformRealizeCorrectHistories.js","sourceRoot":"","sources":["../../../../../../src/orchestrate/realize/histories/transformRealizeCorrectHistories.ts"],"names":[],"mappings":";;AAcA,4EAsCC;AA/CD,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,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE,kBAAU,CAAC,IAAI,CAAA;;;;UAIjB,KAAK,CAAC,IAAI;;;;;;UAMV,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC;;OAEnC;YACD,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACrC;QACD;YACE,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,IAAI,EAAE,eAAe;YACrB,IAAI,22bAA4C;YAChD,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACrC;KACF,CAAC;AACJ,CAAC"}
@@ -8,7 +8,7 @@ const transformRealizeWriteAuthorizationsHistories = (operation, payloads) => {
8
8
  const loginGuide = operation.authorizationType === "login"
9
9
  ? [
10
10
  {
11
- id: (0, uuid_1.v4)(),
11
+ id: (0, uuid_1.v7)(),
12
12
  created_at: new Date().toISOString(),
13
13
  type: "systemMessage",
14
14
  text: utils_1.StringUtil.trim `
@@ -46,7 +46,10 @@ const transformRealizeWriteAuthorizationsHistories = (operation, payloads) => {
46
46
  **NOTE**: The jsonwebtoken library is automatically imported as jwt. Use it to generate tokens with the EXACT payload structure:
47
47
 
48
48
  **CRITICAL**: Use the predefined payload structures for consistency:
49
+
50
+ \`\`\`json
49
51
  ${JSON.stringify(payloads)}
52
+ \`\`\`
50
53
 
51
54
  // JWT is already imported: import jwt from "jsonwebtoken";
52
55
 
@@ -99,7 +102,7 @@ const transformRealizeWriteAuthorizationsHistories = (operation, payloads) => {
99
102
  const joinGuide = operation.authorizationType === "join"
100
103
  ? [
101
104
  {
102
- id: (0, uuid_1.v4)(),
105
+ id: (0, uuid_1.v7)(),
103
106
  created_at: new Date().toISOString(),
104
107
  type: "systemMessage",
105
108
  text: utils_1.StringUtil.trim `
@@ -145,7 +148,10 @@ const transformRealizeWriteAuthorizationsHistories = (operation, payloads) => {
145
148
  **NOTE**: The jsonwebtoken library is automatically imported as jwt. After successful registration, generate tokens with the EXACT payload structure:
146
149
 
147
150
  **CRITICAL**: Use the predefined payload structures for consistency:
151
+
152
+ \`\`\`json
148
153
  ${JSON.stringify(payloads)}
154
+ \`\`\`
149
155
 
150
156
  // JWT is already imported: import jwt from "jsonwebtoken";
151
157
 
@@ -187,7 +193,7 @@ const transformRealizeWriteAuthorizationsHistories = (operation, payloads) => {
187
193
  const refreshGuide = operation.authorizationType === "refresh"
188
194
  ? [
189
195
  {
190
- id: (0, uuid_1.v4)(),
196
+ id: (0, uuid_1.v7)(),
191
197
  created_at: new Date().toISOString(),
192
198
  type: "systemMessage",
193
199
  text: utils_1.StringUtil.trim `
@@ -215,7 +221,10 @@ const transformRealizeWriteAuthorizationsHistories = (operation, payloads) => {
215
221
  3. Generate a new access token with THE SAME payload structure as the original
216
222
 
217
223
  **CRITICAL**: Use the predefined payload structures for consistency:
224
+
225
+ \`\`\`json
218
226
  ${JSON.stringify(payloads)}
227
+ \`\`\`
219
228
 
220
229
  // JWT is already imported: import jwt from "jsonwebtoken";
221
230
 
@@ -1 +1 @@
1
- {"version":3,"file":"transformRealizeWriteAuthorizationsHistories.js","sourceRoot":"","sources":["../../../../../../src/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.ts"],"names":[],"mappings":";;;AAEA,yCAA2C;AAC3C,+BAA0B;AAEnB,MAAM,4CAA4C,GAAG,CAC1D,SAAmC,EACnC,QAAgC,EACY,EAAE;IAC9C,sBAAsB;IACtB,MAAM,UAAU,GACd,SAAS,CAAC,iBAAiB,KAAK,OAAO;QACrC,CAAC,CAAC;YACE;gBACE,EAAE,EAAE,IAAA,SAAE,GAAE;gBACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBACpC,IAAI,EAAE,eAAwB;gBAC9B,IAAI,EAAE,kBAAU,CAAC,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAmCjB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA6C3B;aACF;SACF;QACH,CAAC,CAAC,EAAE,CAAC;IAET,oCAAoC;IACpC,MAAM,SAAS,GACb,SAAS,CAAC,iBAAiB,KAAK,MAAM;QACpC,CAAC,CAAC;YACE;gBACE,EAAE,EAAE,IAAA,SAAE,GAAE;gBACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBACpC,IAAI,EAAE,eAAwB;gBAC9B,IAAI,EAAE,kBAAU,CAAC,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA2CjB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAkC3B;aACF;SACF;QACH,CAAC,CAAC,EAAE,CAAC;IAET,8BAA8B;IAC9B,MAAM,YAAY,GAChB,SAAS,CAAC,iBAAiB,KAAK,SAAS;QACvC,CAAC,CAAC;YACE;gBACE,EAAE,EAAE,IAAA,SAAE,GAAE;gBACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBACpC,IAAI,EAAE,eAAwB;gBAC9B,IAAI,EAAE,kBAAU,CAAC,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;gBAyBjB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAqD3B;aACF;SACF;QACH,CAAC,CAAC,EAAE,CAAC;IAET,OAAO,CAAC,GAAG,UAAU,EAAE,GAAG,SAAS,EAAE,GAAG,YAAY,CAAC,CAAC;AACxD,CAAC,CAAC;AAvRW,QAAA,4CAA4C,gDAuRvD"}
1
+ {"version":3,"file":"transformRealizeWriteAuthorizationsHistories.js","sourceRoot":"","sources":["../../../../../../src/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.ts"],"names":[],"mappings":";;;AAEA,yCAA2C;AAC3C,+BAA0B;AAEnB,MAAM,4CAA4C,GAAG,CAC1D,SAAmC,EACnC,QAAgC,EACY,EAAE;IAC9C,sBAAsB;IACtB,MAAM,UAAU,GACd,SAAS,CAAC,iBAAiB,KAAK,OAAO;QACrC,CAAC,CAAC;YACE;gBACE,EAAE,EAAE,IAAA,SAAE,GAAE;gBACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBACpC,IAAI,EAAE,eAAwB;gBAC9B,IAAI,EAAE,kBAAU,CAAC,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAqCjB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA8C3B;aACF;SACF;QACH,CAAC,CAAC,EAAE,CAAC;IAET,oCAAoC;IACpC,MAAM,SAAS,GACb,SAAS,CAAC,iBAAiB,KAAK,MAAM;QACpC,CAAC,CAAC;YACE;gBACE,EAAE,EAAE,IAAA,SAAE,GAAE;gBACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBACpC,IAAI,EAAE,eAAwB;gBAC9B,IAAI,EAAE,kBAAU,CAAC,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA6CjB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAmC3B;aACF;SACF;QACH,CAAC,CAAC,EAAE,CAAC;IAET,8BAA8B;IAC9B,MAAM,YAAY,GAChB,SAAS,CAAC,iBAAiB,KAAK,SAAS;QACvC,CAAC,CAAC;YACE;gBACE,EAAE,EAAE,IAAA,SAAE,GAAE;gBACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBACpC,IAAI,EAAE,eAAwB;gBAC9B,IAAI,EAAE,kBAAU,CAAC,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA2BjB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAsD3B;aACF;SACF;QACH,CAAC,CAAC,EAAE,CAAC;IAET,OAAO,CAAC,GAAG,UAAU,EAAE,GAAG,SAAS,EAAE,GAAG,YAAY,CAAC,CAAC;AACxD,CAAC,CAAC;AAhSW,QAAA,4CAA4C,gDAgSvD"}