@autobe/agent 0.20.0 → 0.22.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 (320) hide show
  1. package/lib/agent/src/AutoBeAgent.js +2 -2
  2. package/lib/agent/src/AutoBeAgent.js.map +1 -1
  3. package/lib/agent/src/AutoBeMockAgent.js +1 -0
  4. package/lib/agent/src/AutoBeMockAgent.js.map +1 -1
  5. package/lib/agent/src/constants/AutoBeConfigConstant.d.ts +3 -0
  6. package/lib/agent/src/{orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.js → constants/AutoBeConfigConstant.js} +1 -1
  7. package/lib/agent/src/constants/AutoBeConfigConstant.js.map +1 -0
  8. package/lib/agent/src/constants/AutoBeSystemPromptConstant.d.ts +27 -26
  9. package/lib/agent/src/constants/AutoBeSystemPromptConstant.js.map +1 -1
  10. package/lib/agent/src/context/AutoBeContext.d.ts +3 -2
  11. package/lib/agent/src/context/AutoBeTokenUsageComponent.js +4 -3
  12. package/lib/agent/src/context/AutoBeTokenUsageComponent.js.map +1 -1
  13. package/lib/agent/src/factory/consentFunctionCall.js +4 -4
  14. package/lib/agent/src/factory/consentFunctionCall.js.map +1 -1
  15. package/lib/agent/src/factory/createAutoBeContext.js +16 -11
  16. package/lib/agent/src/factory/createAutoBeContext.js.map +1 -1
  17. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js +1 -1
  18. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js.map +1 -1
  19. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js +2 -2
  20. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js.map +1 -1
  21. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js +1 -1
  22. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js.map +1 -1
  23. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeReview.js +6 -6
  24. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeScenario.js +50 -8
  25. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeScenario.js.map +1 -1
  26. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeWrite.js +4 -4
  27. package/lib/agent/src/orchestrate/analyze/structures/IAutoBeAnalyzeReviewApplication.d.ts +6 -0
  28. package/lib/agent/src/orchestrate/analyze/structures/IAutoBeAnalyzeWriteApplication.d.ts +4 -0
  29. package/lib/agent/src/orchestrate/facade/transformFacadeStateMessage.js +1 -1
  30. package/lib/agent/src/orchestrate/facade/transformFacadeStateMessage.js.map +1 -1
  31. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js +19 -1
  32. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js.map +1 -1
  33. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceComplementHistories.js +3 -3
  34. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -1
  35. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.js +1 -1
  36. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.js.map +1 -1
  37. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.d.ts +4 -0
  38. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js +33 -0
  39. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js.map +1 -0
  40. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceGroupHistories.js +2 -2
  41. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceGroupHistories.js.map +1 -1
  42. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationHistories.js +1 -1
  43. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationHistories.js.map +1 -1
  44. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js +2 -2
  45. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js.map +1 -1
  46. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +1 -1
  47. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -1
  48. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.d.ts +1 -1
  49. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js +2 -2
  50. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js.map +1 -1
  51. package/lib/agent/src/orchestrate/interface/orchestrateInterface.js +5 -1
  52. package/lib/agent/src/orchestrate/interface/orchestrateInterface.js.map +1 -1
  53. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceAuthorizations.js +16 -10
  54. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceAuthorizations.js.map +1 -1
  55. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceComplement.d.ts +1 -1
  56. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceComplement.js +3731 -228
  57. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
  58. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpoints.js +5 -3
  59. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
  60. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpointsReview.d.ts +10 -0
  61. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpointsReview.js +365 -0
  62. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpointsReview.js.map +1 -0
  63. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperations.js +43 -63
  64. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
  65. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperationsReview.js +244 -176
  66. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperationsReview.js.map +1 -1
  67. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemas.js +3466 -103
  68. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -1
  69. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemasReview.d.ts +6 -1
  70. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemasReview.js +3672 -358
  71. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemasReview.js.map +1 -1
  72. package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceEndpointsReviewApplication.d.ts +60 -0
  73. package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceEndpointsReviewApplication.js +3 -0
  74. package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceEndpointsReviewApplication.js.map +1 -0
  75. package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.d.ts +0 -38
  76. package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.d.ts +48 -101
  77. package/lib/agent/src/orchestrate/interface/structures/IAutobeInterfaceSchemasReviewApplication.d.ts +29 -23
  78. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaFactory.d.ts +9 -0
  79. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaFactory.js +1385 -0
  80. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaFactory.js.map +1 -0
  81. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaNamingConvention.d.ts +5 -0
  82. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaNamingConvention.js +78 -0
  83. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaNamingConvention.js.map +1 -0
  84. package/lib/agent/src/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.d.ts +2 -0
  85. package/lib/agent/src/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.js +81 -0
  86. package/lib/agent/src/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.js.map +1 -0
  87. package/lib/agent/src/orchestrate/interface/utils/validateAuthorizationSchema.js.map +1 -1
  88. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.js +1 -1
  89. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.js.map +1 -1
  90. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaCorrectHistories.js +1 -1
  91. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaCorrectHistories.js.map +1 -1
  92. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaReviewHistories.js +2 -2
  93. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaReviewHistories.js.map +1 -1
  94. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.js +1 -1
  95. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.js.map +1 -1
  96. package/lib/agent/src/orchestrate/prisma/orchestratePrismaCorrect.d.ts +1 -1
  97. package/lib/agent/src/orchestrate/prisma/orchestratePrismaCorrect.js +2 -2
  98. package/lib/agent/src/orchestrate/prisma/orchestratePrismaCorrect.js.map +1 -1
  99. package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorization.js +1 -1
  100. package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorization.js.map +1 -1
  101. package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js +2 -2
  102. package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js.map +1 -1
  103. package/lib/agent/src/orchestrate/realize/histories/transformRealizeCorrectHistories.d.ts +6 -6
  104. package/lib/agent/src/orchestrate/realize/histories/transformRealizeCorrectHistories.js +22 -7
  105. package/lib/agent/src/orchestrate/realize/histories/transformRealizeCorrectHistories.js.map +1 -1
  106. package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.d.ts +5 -8
  107. package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.js +13 -29
  108. package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.js.map +1 -1
  109. package/lib/agent/src/orchestrate/realize/internal/compileRealizeFiles.d.ts +2 -2
  110. package/lib/agent/src/orchestrate/realize/internal/compileRealizeFiles.js +2 -8
  111. package/lib/agent/src/orchestrate/realize/internal/compileRealizeFiles.js.map +1 -1
  112. package/lib/agent/src/orchestrate/realize/orchestrateRealize.js +6 -49
  113. package/lib/agent/src/orchestrate/realize/orchestrateRealize.js.map +1 -1
  114. package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorization.js +4 -2
  115. package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorization.js.map +1 -1
  116. package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js +5 -3
  117. package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js.map +1 -1
  118. package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.d.ts +13 -6
  119. package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.js +206 -118
  120. package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
  121. package/lib/agent/src/orchestrate/realize/orchestrateRealizeScenario.d.ts +2 -2
  122. package/lib/agent/src/orchestrate/realize/orchestrateRealizeScenario.js +2 -2
  123. package/lib/agent/src/orchestrate/realize/orchestrateRealizeScenario.js.map +1 -1
  124. package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.d.ts +2 -2
  125. package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.js +24 -39
  126. package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.js.map +1 -1
  127. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.d.ts +17 -0
  128. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.d.ts +20 -0
  129. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.d.ts +33 -73
  130. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeFunctionFailure.d.ts +5 -0
  131. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeFunctionFailure.js +3 -0
  132. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeFunctionFailure.js.map +1 -0
  133. package/{src/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.ts → lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioResult.d.ts} +3 -10
  134. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioResult.js +3 -0
  135. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioResult.js.map +1 -0
  136. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +40 -24
  137. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.d.ts +31 -0
  138. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.js +86 -0
  139. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.js.map +1 -0
  140. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteDto.d.ts +4 -0
  141. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteDto.js +55 -0
  142. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteDto.js.map +1 -0
  143. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteImportStatements.d.ts +2 -0
  144. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteImportStatements.js +20 -0
  145. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteImportStatements.js.map +1 -0
  146. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteInputType.d.ts +30 -0
  147. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteInputType.js +73 -0
  148. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteInputType.js.map +1 -0
  149. package/lib/agent/src/orchestrate/realize/utils/replaceImportStatements.d.ts +6 -2
  150. package/lib/agent/src/orchestrate/realize/utils/replaceImportStatements.js +63 -69
  151. package/lib/agent/src/orchestrate/realize/utils/replaceImportStatements.js.map +1 -1
  152. package/lib/agent/src/orchestrate/test/compile/completeTestCode.js +15 -14
  153. package/lib/agent/src/orchestrate/test/compile/completeTestCode.js.map +1 -1
  154. package/lib/agent/src/orchestrate/test/compile/getTestExternalDeclarations.js +1 -1
  155. package/lib/agent/src/orchestrate/test/compile/getTestExternalDeclarations.js.map +1 -1
  156. package/lib/agent/src/orchestrate/test/compile/getTestImportStatements.d.ts +2 -0
  157. package/lib/agent/src/orchestrate/test/compile/getTestImportStatements.js +19 -0
  158. package/lib/agent/src/orchestrate/test/compile/getTestImportStatements.js.map +1 -0
  159. package/lib/agent/src/orchestrate/test/compile/getTestScenarioArtifacts.d.ts +1 -1
  160. package/lib/agent/src/orchestrate/test/compile/getTestScenarioArtifacts.js +2 -0
  161. package/lib/agent/src/orchestrate/test/compile/getTestScenarioArtifacts.js.map +1 -1
  162. package/lib/agent/src/orchestrate/test/compile/getTestTemplateCode.d.ts +2 -0
  163. package/lib/agent/src/orchestrate/test/compile/getTestTemplateCode.js +21 -0
  164. package/lib/agent/src/orchestrate/test/compile/getTestTemplateCode.js.map +1 -0
  165. package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.d.ts +4 -2
  166. package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.js +40 -25
  167. package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.js.map +1 -1
  168. package/lib/agent/src/orchestrate/test/histories/transformTestScenarioHistories.js +5 -4
  169. package/lib/agent/src/orchestrate/test/histories/transformTestScenarioHistories.js.map +1 -1
  170. package/lib/agent/src/orchestrate/test/histories/transformTestWriteHistories.d.ts +3 -1
  171. package/lib/agent/src/orchestrate/test/histories/transformTestWriteHistories.js +137 -96
  172. package/lib/agent/src/orchestrate/test/histories/transformTestWriteHistories.js.map +1 -1
  173. package/lib/agent/src/orchestrate/test/orchestrateTest.js +6 -0
  174. package/lib/agent/src/orchestrate/test/orchestrateTest.js.map +1 -1
  175. package/lib/agent/src/orchestrate/test/orchestrateTestCorrect.d.ts +1 -1
  176. package/lib/agent/src/orchestrate/test/orchestrateTestCorrect.js +126 -72
  177. package/lib/agent/src/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  178. package/lib/agent/src/orchestrate/test/orchestrateTestScenario.js +54 -48
  179. package/lib/agent/src/orchestrate/test/orchestrateTestScenario.js.map +1 -1
  180. package/lib/agent/src/orchestrate/test/orchestrateTestWrite.js +122 -43
  181. package/lib/agent/src/orchestrate/test/orchestrateTestWrite.js.map +1 -1
  182. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +48 -45
  183. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestFunctionFailure.d.ts +6 -0
  184. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestFunctionFailure.js +3 -0
  185. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestFunctionFailure.js.map +1 -0
  186. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestScenarioApplication.d.ts +28 -1
  187. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.d.ts +1 -0
  188. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +13 -0
  189. package/lib/agent/src/orchestrate/test/utils/getReferenceIds.d.ts +5 -0
  190. package/lib/agent/src/orchestrate/test/utils/getReferenceIds.js +28 -0
  191. package/lib/agent/src/orchestrate/test/utils/getReferenceIds.js.map +1 -0
  192. package/lib/agent/src/structures/IAutoBeConfig.d.ts +2 -0
  193. package/lib/constants/AutoBeConfigConstant.d.ts +3 -0
  194. package/lib/constants/AutoBeSystemPromptConstant.d.ts +27 -26
  195. package/lib/context/AutoBeContext.d.ts +3 -2
  196. package/lib/index.mjs +13778 -3055
  197. package/lib/index.mjs.map +1 -1
  198. package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeReviewApplication.d.ts +6 -0
  199. package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeWriteApplication.d.ts +4 -0
  200. package/lib/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.d.ts +4 -0
  201. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.d.ts +1 -1
  202. package/lib/orchestrate/interface/orchestrateInterfaceComplement.d.ts +1 -1
  203. package/lib/orchestrate/interface/orchestrateInterfaceEndpointsReview.d.ts +10 -0
  204. package/lib/orchestrate/interface/orchestrateInterfaceSchemasReview.d.ts +6 -1
  205. package/lib/orchestrate/interface/structures/IAutoBeInterfaceEndpointsReviewApplication.d.ts +60 -0
  206. package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.d.ts +0 -38
  207. package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.d.ts +48 -101
  208. package/lib/orchestrate/interface/structures/IAutobeInterfaceSchemasReviewApplication.d.ts +29 -23
  209. package/lib/orchestrate/interface/utils/JsonSchemaFactory.d.ts +9 -0
  210. package/lib/orchestrate/interface/utils/JsonSchemaNamingConvention.d.ts +5 -0
  211. package/lib/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.d.ts +2 -0
  212. package/lib/orchestrate/prisma/orchestratePrismaCorrect.d.ts +1 -1
  213. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.d.ts +6 -6
  214. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.d.ts +5 -8
  215. package/lib/orchestrate/realize/internal/compileRealizeFiles.d.ts +2 -2
  216. package/lib/orchestrate/realize/orchestrateRealizeCorrect.d.ts +13 -6
  217. package/lib/orchestrate/realize/orchestrateRealizeScenario.d.ts +2 -2
  218. package/lib/orchestrate/realize/orchestrateRealizeWrite.d.ts +2 -2
  219. package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.d.ts +17 -0
  220. package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.d.ts +20 -0
  221. package/lib/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.d.ts +33 -73
  222. package/lib/orchestrate/realize/structures/IAutoBeRealizeFunctionFailure.d.ts +5 -0
  223. package/lib/orchestrate/realize/structures/IAutoBeRealizeScenarioResult.d.ts +36 -0
  224. package/lib/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +40 -24
  225. package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.d.ts +31 -0
  226. package/lib/orchestrate/realize/utils/getRealizeWriteDto.d.ts +4 -0
  227. package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.d.ts +2 -0
  228. package/lib/orchestrate/realize/utils/getRealizeWriteInputType.d.ts +30 -0
  229. package/lib/orchestrate/realize/utils/replaceImportStatements.d.ts +6 -2
  230. package/lib/orchestrate/test/compile/getTestImportStatements.d.ts +2 -0
  231. package/lib/orchestrate/test/compile/getTestScenarioArtifacts.d.ts +1 -1
  232. package/lib/orchestrate/test/compile/getTestTemplateCode.d.ts +2 -0
  233. package/lib/orchestrate/test/histories/transformTestCorrectHistories.d.ts +4 -2
  234. package/lib/orchestrate/test/histories/transformTestWriteHistories.d.ts +3 -1
  235. package/lib/orchestrate/test/orchestrateTestCorrect.d.ts +1 -1
  236. package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +48 -45
  237. package/lib/orchestrate/test/structures/IAutoBeTestFunctionFailure.d.ts +6 -0
  238. package/lib/orchestrate/test/structures/IAutoBeTestScenarioApplication.d.ts +28 -1
  239. package/lib/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.d.ts +1 -0
  240. package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +13 -0
  241. package/lib/orchestrate/test/utils/getReferenceIds.d.ts +5 -0
  242. package/lib/structures/IAutoBeConfig.d.ts +2 -0
  243. package/package.json +6 -6
  244. package/src/AutoBeAgent.ts +2 -0
  245. package/src/AutoBeMockAgent.ts +1 -0
  246. package/src/constants/AutoBeConfigConstant.ts +3 -0
  247. package/src/constants/AutoBeSystemPromptConstant.ts +27 -26
  248. package/src/context/AutoBeContext.ts +3 -0
  249. package/src/context/AutoBeTokenUsageComponent.ts +3 -3
  250. package/src/factory/consentFunctionCall.ts +2 -0
  251. package/src/factory/createAutoBeContext.ts +145 -135
  252. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeReviewApplication.ts +6 -0
  253. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeWriteApplication.ts +4 -0
  254. package/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.ts +19 -1
  255. package/src/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.ts +39 -0
  256. package/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.ts +1 -4
  257. package/src/orchestrate/interface/orchestrateInterface.ts +15 -4
  258. package/src/orchestrate/interface/orchestrateInterfaceAuthorizations.ts +13 -5
  259. package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +58 -19
  260. package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +5 -1
  261. package/src/orchestrate/interface/orchestrateInterfaceEndpointsReview.ts +95 -0
  262. package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +11 -11
  263. package/src/orchestrate/interface/orchestrateInterfaceOperationsReview.ts +7 -3
  264. package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +33 -91
  265. package/src/orchestrate/interface/orchestrateInterfaceSchemasReview.ts +72 -95
  266. package/src/orchestrate/interface/structures/IAutoBeInterfaceEndpointsReviewApplication.ts +65 -0
  267. package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.ts +0 -39
  268. package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.ts +50 -104
  269. package/src/orchestrate/interface/structures/IAutobeInterfaceSchemasReviewApplication.ts +31 -27
  270. package/src/orchestrate/interface/utils/JsonSchemaFactory.ts +171 -0
  271. package/src/orchestrate/interface/utils/JsonSchemaNamingConvention.ts +83 -0
  272. package/src/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.ts +90 -0
  273. package/src/orchestrate/interface/utils/validateAuthorizationSchema.ts +2 -2
  274. package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +1 -2
  275. package/src/orchestrate/realize/histories/transformRealizeCorrectHistories.ts +30 -15
  276. package/src/orchestrate/realize/histories/transformRealizeWriteHistories.ts +27 -49
  277. package/src/orchestrate/realize/internal/compileRealizeFiles.ts +4 -11
  278. package/src/orchestrate/realize/orchestrateRealize.ts +19 -75
  279. package/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.ts +1 -1
  280. package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +114 -25
  281. package/src/orchestrate/realize/orchestrateRealizeScenario.ts +9 -5
  282. package/src/orchestrate/realize/orchestrateRealizeWrite.ts +11 -15
  283. package/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.ts +17 -0
  284. package/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.ts +20 -0
  285. package/src/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.ts +40 -74
  286. package/src/orchestrate/realize/structures/IAutoBeRealizeFunctionFailure.ts +9 -0
  287. package/src/orchestrate/realize/structures/IAutoBeRealizeScenarioResult.ts +45 -0
  288. package/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.ts +43 -27
  289. package/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.ts +97 -0
  290. package/src/orchestrate/realize/utils/getRealizeWriteDto.ts +64 -0
  291. package/src/orchestrate/realize/utils/getRealizeWriteImportStatements.ts +29 -0
  292. package/src/orchestrate/realize/utils/getRealizeWriteInputType.ts +82 -0
  293. package/src/orchestrate/realize/utils/replaceImportStatements.ts +101 -111
  294. package/src/orchestrate/test/compile/completeTestCode.ts +15 -26
  295. package/src/orchestrate/test/compile/getTestExternalDeclarations.ts +3 -0
  296. package/src/orchestrate/test/compile/getTestImportStatements.ts +25 -0
  297. package/src/orchestrate/test/compile/getTestScenarioArtifacts.ts +6 -1
  298. package/src/orchestrate/test/compile/getTestTemplateCode.ts +25 -0
  299. package/src/orchestrate/test/histories/transformTestCorrectHistories.ts +48 -36
  300. package/src/orchestrate/test/histories/transformTestScenarioHistories.ts +6 -5
  301. package/src/orchestrate/test/histories/transformTestWriteHistories.ts +43 -4
  302. package/src/orchestrate/test/orchestrateTest.ts +6 -0
  303. package/src/orchestrate/test/orchestrateTestCorrect.ts +46 -11
  304. package/src/orchestrate/test/orchestrateTestScenario.ts +52 -48
  305. package/src/orchestrate/test/orchestrateTestWrite.ts +24 -6
  306. package/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.ts +49 -46
  307. package/src/orchestrate/test/structures/IAutoBeTestFunctionFailure.ts +8 -0
  308. package/src/orchestrate/test/structures/IAutoBeTestScenarioApplication.ts +28 -1
  309. package/src/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.ts +1 -0
  310. package/src/orchestrate/test/structures/IAutoBeTestWriteApplication.ts +14 -0
  311. package/src/orchestrate/test/utils/getReferenceIds.ts +25 -0
  312. package/src/structures/IAutoBeConfig.ts +3 -0
  313. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.d.ts +0 -38
  314. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.js.map +0 -1
  315. package/lib/agent/src/orchestrate/test/histories/transformTestHistories.d.ts +0 -3
  316. package/lib/agent/src/orchestrate/test/histories/transformTestHistories.js +0 -75
  317. package/lib/agent/src/orchestrate/test/histories/transformTestHistories.js.map +0 -1
  318. package/lib/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.d.ts +0 -38
  319. package/lib/orchestrate/test/histories/transformTestHistories.d.ts +0 -3
  320. package/src/orchestrate/test/histories/transformTestHistories.ts +0 -78
@@ -1,11 +1,35 @@
1
1
  export interface IAutoBeRealizeWriteApplication {
2
+ /**
3
+ * Generates provider function implementation through multi-phase development.
4
+ *
5
+ * This method implements a systematic approach to generate NestJS provider
6
+ * functions that handle business logic for API operations. It follows a
7
+ * schema-first approach with multiple refinement phases to ensure type-safe,
8
+ * error-free code generation.
9
+ *
10
+ * The generation process includes:
11
+ * 1. Strategic planning based on Prisma schema analysis
12
+ * 2. Initial draft without Date type usage
13
+ * 3. Review and refinement for completeness
14
+ * 4. Compiler feedback integration if errors detected
15
+ * 5. Final implementation with all validations and type safety
16
+ *
17
+ * @param next Properties containing the multi-phase implementation plan and code
18
+ */
2
19
  coding: (next: IAutoBeRealizeWriteApplication.IProps) => void;
3
20
  }
4
21
 
5
22
  export namespace IAutoBeRealizeWriteApplication {
23
+ /**
24
+ * Properties for the Realize Write Application following Chain of Thinking (CoT).
25
+ *
26
+ * Each field represents a distinct phase in the reasoning and implementation process,
27
+ * building upon the previous step to create a complete, error-free implementation.
28
+ * This structured approach ensures clarity, debuggability, and systematic thinking.
29
+ */
6
30
  export interface IProps {
7
31
  /**
8
- * Step 1.
32
+ * Step 1 - Planning Phase (CoT: Initial Reasoning)
9
33
  *
10
34
  * 🧠 Provider Function Implementation Plan
11
35
  *
@@ -18,13 +42,18 @@ export namespace IAutoBeRealizeWriteApplication {
18
42
  * 📋 STEP 1 - PRISMA SCHEMA VERIFICATION:
19
43
  *
20
44
  * DO:
45
+ *
21
46
  * - Examine the actual Prisma schema model definition
22
47
  * - List EVERY field that exists in the model with exact types
23
48
  * - Explicitly note fields that DO NOT exist
24
- *
49
+ * - Verify database compatibility (PostgreSQL AND SQLite)
50
+ *
25
51
  * DO NOT:
52
+ *
26
53
  * - Assume common fields exist without verification
27
- * - Use fields like deleted_at, created_by, updated_by, is_deleted, is_active without checking
54
+ * - Use fields like deleted_at, created_by, updated_by, is_deleted, is_active
55
+ * without checking
56
+ * - Use PostgreSQL-specific features like mode: "insensitive"
28
57
  *
29
58
  * 📋 STEP 2 - FIELD INVENTORY:
30
59
  *
@@ -133,7 +162,7 @@ export namespace IAutoBeRealizeWriteApplication {
133
162
  plan: string;
134
163
 
135
164
  /**
136
- * Step 2.
165
+ * Step 2 - Schema Definition (CoT: Context Establishment)
137
166
  *
138
167
  * The Prisma schema string that will be used to validate the implementation
139
168
  * logic in this file.
@@ -155,13 +184,13 @@ export namespace IAutoBeRealizeWriteApplication {
155
184
  prisma_schemas: string;
156
185
 
157
186
  /**
158
- * Step 3.
187
+ * Step 3 - Initial Draft (CoT: First Implementation Attempt)
159
188
  *
160
189
  * Draft WITHOUT using native Date type.
161
190
  *
162
191
  * This is the initial drafting phase where you outline the basic skeleton
163
192
  * of the function.
164
- *
193
+ *
165
194
  * DO NOT: Use the native Date type.
166
195
  *
167
196
  * - The function signature must correctly include `user`, `parameters`, and
@@ -174,10 +203,12 @@ export namespace IAutoBeRealizeWriteApplication {
174
203
  * Import rules:
175
204
  *
176
205
  * DO NOT:
206
+ *
177
207
  * - Add any new import statements manually
178
208
  * - Write import statements directly (this causes compile errors)
179
- *
180
- * Note: All necessary imports are provided globally or by the system automatically.
209
+ *
210
+ * Note: All necessary imports are provided globally or by the system
211
+ * automatically.
181
212
  *
182
213
  * ✅ Requirements:
183
214
  *
@@ -190,7 +221,7 @@ export namespace IAutoBeRealizeWriteApplication {
190
221
  draft_without_date_type: string;
191
222
 
192
223
  /**
193
- * Step 4.
224
+ * Step 4 - Review and Refinement (CoT: Self-Reflection)
194
225
  *
195
226
  * A refined version of the draft with improved completeness.
196
227
  *
@@ -204,29 +235,13 @@ export namespace IAutoBeRealizeWriteApplication {
204
235
  * - Avoid unsafe `as` casts unless only for branding or literal narrowing.
205
236
  * - Use `toISOStringSafe()` for all date conversions (NOT `.toISOString()`).
206
237
  * - Ensure all object keys strictly conform to the expected type definitions.
238
+ * - NEVER use `mode: "insensitive"` in string operations (breaks SQLite).
207
239
  */
208
240
  review: string;
209
241
 
210
- /**
211
- * 🛠 Phase 4-2: With compiler feedback (optional)
212
- *
213
- * A correction pass that applies fixes for compile-time errors that arose
214
- * during the review stage (if any).
215
- *
216
- * ✅ Must:
217
- *
218
- * - Only include this field if TypeScript errors are detected in the Review
219
- * phase.
220
- * - Resolve all TypeScript errors without using `as any`.
221
- * - Provide safe brand casting only if required (e.g., `as string &
222
- * tags.Format<'uuid'>`).
223
- * - If no TypeScript errors exist, this field MUST contain the text: "No
224
- * TypeScript errors detected - skipping this phase"
225
- */
226
- withCompilerFeedback: string;
227
242
 
228
243
  /**
229
- * Step 5.
244
+ * Step 5 - Complete Implementation (CoT: Final Synthesis)
230
245
  *
231
246
  * The complete and fully correct TypeScript function implementation.
232
247
  *
@@ -238,6 +253,7 @@ export namespace IAutoBeRealizeWriteApplication {
238
253
  * - Uses only allowed imports (e.g., from `../api/structures` and
239
254
  * `MyGlobal.prisma`).
240
255
  * - NEVER creates intermediate variables for Prisma operations.
256
+ * - NEVER uses `mode: "insensitive"` (PostgreSQL-only, breaks SQLite).
241
257
  *
242
258
  * ⚠️ Fallback Behavior:
243
259
  *
@@ -0,0 +1,97 @@
1
+ import { AutoBeOpenApi, AutoBeRealizeAuthorization } from "@autobe/interface";
2
+ import { StringUtil } from "@autobe/utils";
3
+
4
+ import { IAutoBeRealizeScenarioResult } from "../structures/IAutoBeRealizeScenarioResult";
5
+ import { getRealizeWriteImportStatements } from "./getRealizeWriteImportStatements";
6
+
7
+ /**
8
+ * Generate a TypeScript function template for the Realize Agent to complete
9
+ *
10
+ * This utility creates a function skeleton with proper imports, parameters, and
11
+ * return type that the AI needs to implement. The template includes:
12
+ *
13
+ * - Import statements for required dependencies
14
+ * - Function signature with all parameters
15
+ * - Return type specification
16
+ *
17
+ * @example
18
+ * // Returns a template like:
19
+ * ```typescript
20
+ * import { MyGlobal } from "../MyGlobal";
21
+ * // ... other imports
22
+ *
23
+ * async function post__users_create(
24
+ * body: IUserCreateRequest
25
+ * ): Promise<IUserResponse> {
26
+ * ...
27
+ * }
28
+ * ```;
29
+ *
30
+ * @param scenario - The realize scenario containing function metadata
31
+ * @param operation - OpenAPI operation definition
32
+ * @param authorization - Authorization context if endpoint is authenticated
33
+ * @returns Complete TypeScript code template as a formatted string
34
+ */
35
+ export function getRealizeWriteCodeTemplate(
36
+ scenario: IAutoBeRealizeScenarioResult,
37
+ operation: AutoBeOpenApi.IOperation,
38
+ authorization: AutoBeRealizeAuthorization | null,
39
+ ): string {
40
+ // Collect all function parameters in order
41
+ const functionParameters: string[] = [];
42
+
43
+ // Add authentication parameter if needed (e.g., user: IUser, admin: IAdmin)
44
+ if (authorization && authorization.role.name) {
45
+ // Debug: Log the values to check what's being used
46
+ const authParameter = `${authorization.role.name}: ${authorization.payload.name}`;
47
+ functionParameters.push(authParameter);
48
+ }
49
+
50
+ // Add path parameters (e.g., id, postId, etc.)
51
+ const pathParameters = operation.parameters.map((param) => {
52
+ const paramType = param.schema.type;
53
+ const paramFormat =
54
+ "format" in param.schema
55
+ ? ` & tags.Format<'${param.schema.format}'>`
56
+ : "";
57
+ return `${param.name}: ${paramType}${paramFormat}`;
58
+ });
59
+ functionParameters.push(...pathParameters);
60
+
61
+ // Add request body parameter if present
62
+ if (operation.requestBody?.typeName) {
63
+ const bodyParameter = `body: ${operation.requestBody.typeName}`;
64
+ functionParameters.push(bodyParameter);
65
+ }
66
+
67
+ // Format parameters for props object
68
+ const hasParameters = functionParameters.length > 0;
69
+
70
+ let formattedSignature: string;
71
+ if (hasParameters) {
72
+ const propsFields = functionParameters
73
+ .map((param) => ` ${param}`)
74
+ .join(";\n");
75
+
76
+ formattedSignature = `props: {\n${propsFields};\n}`;
77
+ } else {
78
+ formattedSignature = "";
79
+ }
80
+
81
+ // Determine return type
82
+ const returnType = operation.responseBody?.typeName ?? "void";
83
+
84
+ // Generate the complete template
85
+ return StringUtil.trim`
86
+ Complete the code below, disregard the import part and return only the function part.
87
+
88
+ \`\`\`typescript
89
+ ${getRealizeWriteImportStatements(operation).join("\n")}
90
+
91
+ // ONLY YOU HAVE TO WRITE THIS, AND USE IMPORTED.
92
+ export async function ${scenario.functionName}(${formattedSignature}): Promise<${returnType}> {
93
+ ...
94
+ }
95
+ \`\`\`
96
+ `;
97
+ }
@@ -0,0 +1,64 @@
1
+ import { AutoBeOpenApi, IAutoBeCompiler } from "@autobe/interface";
2
+ import { ILlmSchema, OpenApiTypeChecker } from "@samchon/openapi";
3
+
4
+ import { AutoBeContext } from "../../../context/AutoBeContext";
5
+
6
+ export async function getRealizeWriteDto<Model extends ILlmSchema.Model>(
7
+ ctx: AutoBeContext<Model>,
8
+ operation: AutoBeOpenApi.IOperation,
9
+ ): Promise<Record<string, string>> {
10
+ const document: AutoBeOpenApi.IDocument = filterDocument(
11
+ operation,
12
+ ctx.state().interface!.document,
13
+ );
14
+
15
+ const compiler: IAutoBeCompiler = await ctx.compiler();
16
+ const entries: [string, string][] = Object.entries(
17
+ await compiler.interface.write(document),
18
+ );
19
+
20
+ const filter = (prefix: string, exclude?: string) => {
21
+ const result: [string, string][] = entries.filter(
22
+ ([key]) => key.startsWith(prefix) === true,
23
+ );
24
+ return Object.fromEntries(
25
+ exclude
26
+ ? result.filter(([key]) => key.startsWith(exclude) === false)
27
+ : result,
28
+ );
29
+ };
30
+
31
+ const dto: Record<string, string> = filter("src/api/structures");
32
+ return dto;
33
+ }
34
+
35
+ function filterDocument(
36
+ operation: AutoBeOpenApi.IOperation,
37
+ document: AutoBeOpenApi.IDocument,
38
+ ): AutoBeOpenApi.IDocument {
39
+ const components: AutoBeOpenApi.IComponents = {
40
+ authorization: document.components.authorization,
41
+ schemas: {},
42
+ };
43
+
44
+ const visit = (typeName: string) => {
45
+ OpenApiTypeChecker.visit({
46
+ components: document.components,
47
+ schema: { $ref: `#/components/schemas/${typeName}` },
48
+ closure: (s) => {
49
+ if (OpenApiTypeChecker.isReference(s)) {
50
+ const key: string = s.$ref.split("/").pop()!;
51
+ components.schemas[key] = document.components.schemas[key];
52
+ }
53
+ },
54
+ });
55
+ };
56
+
57
+ if (operation.requestBody) visit(operation.requestBody.typeName);
58
+ if (operation.responseBody) visit(operation.responseBody.typeName);
59
+
60
+ return {
61
+ operations: [operation],
62
+ components,
63
+ };
64
+ }
@@ -0,0 +1,29 @@
1
+ import { AutoBeOpenApi } from "@autobe/interface";
2
+
3
+ export function getRealizeWriteImportStatements(
4
+ operation: AutoBeOpenApi.IOperation,
5
+ ) {
6
+ const typeReferences: string[] = Array.from(
7
+ new Set(
8
+ [operation.requestBody, operation.responseBody]
9
+ .filter((el) => el !== null)
10
+ .map((el) => el.typeName.split(".")[0]!),
11
+ ),
12
+ );
13
+
14
+ // Build the standard imports
15
+ const imports = [
16
+ 'import jwt from "jsonwebtoken";',
17
+ 'import { MyGlobal } from "../MyGlobal";',
18
+ 'import typia, { tags } from "typia";',
19
+ 'import { Prisma } from "@prisma/client";',
20
+ 'import { v4 } from "uuid";',
21
+ 'import { toISOStringSafe } from "../util/toISOStringSafe"',
22
+ ...typeReferences.map(
23
+ (ref) =>
24
+ `import { ${ref} } from "@ORGANIZATION/PROJECT-api/lib/structures/${ref}";`,
25
+ ),
26
+ ];
27
+
28
+ return imports;
29
+ }
@@ -0,0 +1,82 @@
1
+ import { AutoBeOpenApi, AutoBeRealizeAuthorization } from "@autobe/interface";
2
+ import { StringUtil } from "@autobe/utils";
3
+
4
+ /**
5
+ * Generate TypeScript type definition string for provider function props
6
+ *
7
+ * This utility creates the exact props interface that the Realize Agent's
8
+ * generated provider functions must accept. It combines:
9
+ *
10
+ * - Authentication context (user/admin/member from authorization)
11
+ * - URL path parameters (e.g., id, boardId, postId)
12
+ * - Request body type (if applicable)
13
+ *
14
+ * The output is injected into REALIZE_WRITE_ARTIFACT.md template to tell the AI
15
+ * exactly what parameter type the function should accept.
16
+ *
17
+ * @example
18
+ * // For DELETE /posts/:id (authenticated)
19
+ * // Returns: "props: { user: IUser; id: string & tags.Format<'uuid'>; }"
20
+ *
21
+ * @example
22
+ * // For GET /public/info (no auth, no params)
23
+ * // Returns: "// No props parameter needed - function should have no parameters"
24
+ *
25
+ * @param operation - OpenAPI operation definition containing parameters and
26
+ * auth requirements
27
+ * @param authorization - Authorization context with user/role information (if
28
+ * authenticated endpoint)
29
+ * @returns TypeScript interface string like "props: { user: IUser; id: string;
30
+ * body: IRequest; }"
31
+ */
32
+ export function getRealizeWriteInputType(
33
+ operation: AutoBeOpenApi.IOperation,
34
+ authorization: AutoBeRealizeAuthorization | null,
35
+ ): string {
36
+ const functionParameterFields: string[] = [];
37
+
38
+ // Add authentication field (user/admin/member) if endpoint requires auth
39
+ const hasAuthentication = authorization && operation.authorizationRole;
40
+ if (hasAuthentication) {
41
+ const authFieldName = operation.authorizationRole;
42
+ const authFieldType = authorization.payload.name;
43
+ functionParameterFields.push(`${authFieldName}: ${authFieldType};`);
44
+ }
45
+
46
+ // Add URL path parameters (e.g., /posts/:id → id parameter)
47
+ const pathParameters = operation.parameters;
48
+ pathParameters.forEach((pathParam) => {
49
+ const paramName = pathParam.name;
50
+ const paramType = pathParam.schema.type;
51
+ const paramFormat =
52
+ "format" in pathParam.schema
53
+ ? ` & tags.Format<'${pathParam.schema.format}'>`
54
+ : "";
55
+
56
+ const parameterField = `${paramName}: ${paramType}${paramFormat};`;
57
+ functionParameterFields.push(parameterField);
58
+ });
59
+
60
+ // Add request body if present (POST/PUT/PATCH operations)
61
+ const hasRequestBody = operation.requestBody?.typeName;
62
+ if (hasRequestBody) {
63
+ const bodyTypeName = operation.requestBody?.typeName;
64
+ functionParameterFields.push(`body: ${bodyTypeName};`);
65
+ }
66
+
67
+ // Format as TypeScript props interface or indicate no parameters needed
68
+ const hasParameters = functionParameterFields.length > 0;
69
+
70
+ if (!hasParameters) {
71
+ return `// No props parameter needed - function should have no parameters`;
72
+ }
73
+
74
+ const formattedFields = functionParameterFields
75
+ .map((field) => ` ${field}`)
76
+ .join("\n");
77
+
78
+ return StringUtil.trim`
79
+ props: {
80
+ ${formattedFields}
81
+ }`;
82
+ }
@@ -1,133 +1,123 @@
1
- import { IAutoBeCompiler } from "@autobe/interface";
1
+ import { AutoBeOpenApi, IAutoBeCompiler } from "@autobe/interface";
2
2
  import { ILlmSchema } from "@samchon/openapi";
3
3
 
4
4
  import { AutoBeContext } from "../../../context/AutoBeContext";
5
- import { IAutoBeTestScenarioArtifacts } from "../../test/structures/IAutoBeTestScenarioArtifacts";
5
+ import { getRealizeWriteImportStatements } from "./getRealizeWriteImportStatements";
6
6
 
7
- export function replaceImportStatements<Model extends ILlmSchema.Model>(
7
+ export async function replaceImportStatements<Model extends ILlmSchema.Model>(
8
8
  ctx: AutoBeContext<Model>,
9
+ props: {
10
+ operation: AutoBeOpenApi.IOperation;
11
+ code: string;
12
+ decoratorType?: string;
13
+ },
9
14
  ) {
10
- return async function (
11
- artifacts: IAutoBeTestScenarioArtifacts,
12
- code: string,
13
- decoratorType?: string,
14
- ) {
15
- const typeReferences: string[] = Array.from(
16
- new Set(
17
- Object.keys(artifacts.document.components.schemas).map(
18
- (key) => key.split(".")[0]!,
19
- ),
20
- ),
21
- );
15
+ let { operation, code, decoratorType } = props;
22
16
 
23
- const compiler: IAutoBeCompiler = await ctx.compiler();
24
- code = await compiler.typescript.beautify(code);
25
- // Remove existing import statements using flexible regex patterns
26
- code = code
27
- .replace(
28
- /import\s*{\s*MyGlobal\s*}\s*from\s*["']\.\.\/MyGlobal["']\s*;?\s*/gm,
29
- "",
30
- )
31
- .replace(
32
- /import\s+typia\s*,\s*{\s*tags\s*}\s*from\s*["']typia["']\s*;?\s*/gm,
33
- "",
34
- )
35
- .replace(/import\s*{\s*tags\s*}\s*from\s*["']typia["']\s*;?\s*/gm, "")
36
- .replace(
37
- /import\s*{\s*tags\s*,\s*typia\s*}\s*from\s*["']typia["']\s*;?\s*/gm,
38
- "",
39
- )
40
- .replace(/import\s+typia\s*from\s*["']typia["']\s*;?\s*/gm, "")
41
- .replace(
42
- /import\s*{\s*Prisma\s*}\s*from\s*["']@prisma\/client["']\s*;?\s*/gm,
43
- "",
44
- )
45
- .replace(/import\s*{\s*v4\s*}\s*from\s*["']uuid["']\s*;?\s*/gm, "")
46
- .replace(
47
- /import\s*{\s*toISOStringSafe\s*}\s*from\s*["']\.\.\/util\/toISOStringSafe["']\s*;?\s*/gm,
48
- "",
49
- )
50
- // Remove JWT import if it exists (to prevent duplication)
51
- .replace(/import\s+jwt\s+from\s*["']jsonwebtoken["']\s*;?\s*/gm, "")
52
- .replace(
53
- /import\s*\*\s*as\s+jwt\s+from\s*["']jsonwebtoken["']\s*;?\s*/gm,
54
- "",
55
- );
17
+ const typeReferences: string[] = Array.from(
18
+ new Set(
19
+ [operation.requestBody, operation.responseBody]
20
+ .filter((el) => el !== null)
21
+ .map((el) => el.typeName.split(".")[0]!),
22
+ ),
23
+ );
56
24
 
57
- // Remove any existing API structure imports
58
- // Pattern 1: ../api/structures path
59
- code = code.replace(
60
- /import\s*(?:type\s*)?{\s*[^}]+\s*}\s*from\s*["']\.\.\/api\/structures\/[^"']+["']\s*;?\s*/gm,
25
+ const compiler: IAutoBeCompiler = await ctx.compiler();
26
+ code = await compiler.typescript.beautify(code);
27
+ // Remove existing import statements using flexible regex patterns
28
+ code = code
29
+ .replace(
30
+ /import\s*{\s*MyGlobal\s*}\s*from\s*["']\.\.\/MyGlobal["']\s*;?\s*/gm,
61
31
  "",
62
- );
63
- // Pattern 2: @ORGANIZATION/PROJECT-api/lib/structures path
64
- code = code.replace(
65
- /import\s*(?:type\s*)?{\s*[^}]+\s*}\s*from\s*["']@ORGANIZATION\/PROJECT-api\/lib\/structures\/[^"']+["']\s*;?\s*/gm,
32
+ )
33
+ .replace(
34
+ /import\s+typia\s*,\s*{\s*tags\s*}\s*from\s*["']typia["']\s*;?\s*/gm,
35
+ "",
36
+ )
37
+ .replace(/import\s*{\s*tags\s*}\s*from\s*["']typia["']\s*;?\s*/gm, "")
38
+ .replace(
39
+ /import\s*{\s*tags\s*,\s*typia\s*}\s*from\s*["']typia["']\s*;?\s*/gm,
40
+ "",
41
+ )
42
+ .replace(/import\s+typia\s*from\s*["']typia["']\s*;?\s*/gm, "")
43
+ .replace(
44
+ /import\s*{\s*Prisma\s*}\s*from\s*["']@prisma\/client["']\s*;?\s*/gm,
45
+ "",
46
+ )
47
+ .replace(/import\s*{\s*v4\s*}\s*from\s*["']uuid["']\s*;?\s*/gm, "")
48
+ .replace(
49
+ /import\s*{\s*toISOStringSafe\s*}\s*from\s*["']\.\.\/util\/toISOStringSafe["']\s*;?\s*/gm,
50
+ "",
51
+ )
52
+ // Remove JWT import if it exists (to prevent duplication)
53
+ .replace(/import\s+jwt\s+from\s*["']jsonwebtoken["']\s*;?\s*/gm, "")
54
+ .replace(
55
+ /import\s*\*\s*as\s+jwt\s+from\s*["']jsonwebtoken["']\s*;?\s*/gm,
66
56
  "",
67
57
  );
68
58
 
69
- // Remove specific type imports that match our typeReferences
70
- for (const ref of typeReferences) {
71
- // Remove any import of this specific type from any path
72
- const typeImportRegex = new RegExp(
73
- `import\\s*(?:type\\s*)?{\\s*${ref}\\s*}\\s*from\\s*["'][^"']+["']\\s*;?\\s*`,
74
- "gm",
75
- );
76
- code = code.replace(typeImportRegex, "");
77
- }
59
+ // Remove any existing API structure imports
60
+ // Pattern 1: ../api/structures path
61
+ code = code.replace(
62
+ /import\s*(?:type\s*)?{\s*[^}]+\s*}\s*from\s*["']\.\.\/api\/structures\/[^"']+["']\s*;?\s*/gm,
63
+ "",
64
+ );
65
+ // Pattern 2: @ORGANIZATION/PROJECT-api/lib/structures path
66
+ code = code.replace(
67
+ /import\s*(?:type\s*)?{\s*[^}]+\s*}\s*from\s*["']@ORGANIZATION\/PROJECT-api\/lib\/structures\/[^"']+["']\s*;?\s*/gm,
68
+ "",
69
+ );
78
70
 
79
- // Remove any existing decoratorType imports if LLM mistakenly added them
80
- if (decoratorType) {
81
- const decoratorTypeRegex = new RegExp(
82
- `import\\s*(?:type\\s*)?{\\s*${decoratorType}\\s*}\\s*from\\s*["']\\.\\.\/decorators\/payload\/${decoratorType}["']\\s*;?\\s*`,
83
- "gm",
84
- );
85
- code = code.replace(decoratorTypeRegex, "");
86
- }
71
+ // Remove specific type imports that match our typeReferences
72
+ for (const ref of typeReferences) {
73
+ // Remove any import of this specific type from any path
74
+ const typeImportRegex = new RegExp(
75
+ `import\\s*(?:type\\s*)?{\\s*${ref}\\s*}\\s*from\\s*["'][^"']+["']\\s*;?\\s*`,
76
+ "gm",
77
+ );
78
+ code = code.replace(typeImportRegex, "");
79
+ }
87
80
 
88
- // Build the standard imports
89
- const imports = [
90
- 'import jwt from "jsonwebtoken";',
91
- 'import { MyGlobal } from "../MyGlobal";',
92
- 'import typia, { tags } from "typia";',
93
- 'import { Prisma } from "@prisma/client";',
94
- 'import { v4 } from "uuid";',
95
- 'import { toISOStringSafe } from "../util/toISOStringSafe"',
96
- ...typeReferences.map(
97
- (ref) =>
98
- `import { ${ref} } from "@ORGANIZATION/PROJECT-api/lib/structures/${ref}";`,
99
- ),
100
- ];
81
+ // Remove any existing decoratorType imports if LLM mistakenly added them
82
+ if (decoratorType) {
83
+ const decoratorTypeRegex = new RegExp(
84
+ `import\\s*(?:type\\s*)?{\\s*${decoratorType}\\s*}\\s*from\\s*["']\\.\\.\/decorators\/payload\/${decoratorType}["']\\s*;?\\s*`,
85
+ "gm",
86
+ );
87
+ code = code.replace(decoratorTypeRegex, "");
88
+ }
101
89
 
102
- // Only add decoratorType import if it exists
103
- if (decoratorType) {
104
- imports.push(
105
- `import { ${decoratorType} } from "../decorators/payload/${decoratorType}"`,
106
- );
107
- }
90
+ // Build the standard imports
91
+ const imports = getRealizeWriteImportStatements(operation);
92
+
93
+ // Only add decoratorType import if it exists
94
+ if (decoratorType) {
95
+ imports.push(
96
+ `import { ${decoratorType} } from "../decorators/payload/${decoratorType}"`,
97
+ );
98
+ }
108
99
 
109
- code = [...imports, "", code].join("\n");
100
+ code = [...imports, "", code].join("\n");
110
101
 
111
- // Clean up formatting issues
112
- code =
113
- code
114
- // Remove lines with only whitespace
115
- .replace(/^\s+$/gm, "")
116
- // Replace 3+ consecutive newlines with exactly 2 newlines
117
- .replace(/\n{3,}/g, "\n\n")
118
- // Ensure proper spacing after import section
119
- .replace(/(import.*?;)(\s*)(\n(?!import|\s*$))/g, "$1\n\n$3")
120
- // Trim and ensure single trailing newline
121
- .trim() + "\n";
102
+ // Clean up formatting issues
103
+ code =
104
+ code
105
+ // Remove lines with only whitespace
106
+ .replace(/^\s+$/gm, "")
107
+ // Replace 3+ consecutive newlines with exactly 2 newlines
108
+ .replace(/\n{3,}/g, "\n\n")
109
+ // Ensure proper spacing after import section
110
+ .replace(/(import.*?;)(\s*)(\n(?!import|\s*$))/g, "$1\n\n$3")
111
+ // Trim and ensure single trailing newline
112
+ .trim() + "\n";
122
113
 
123
- // fix escaped codes
124
- code = code.replace(/\\n/g, "\n").replace(/\\"/g, '"').replace(/\\'/g, "'");
114
+ // fix escaped codes
115
+ code = code.replace(/\\n/g, "\n").replace(/\\"/g, '"').replace(/\\'/g, "'");
125
116
 
126
- // Apply final beautification
127
- code = await compiler.typescript.beautify(code);
117
+ // Apply final beautification
118
+ code = await compiler.typescript.beautify(code);
128
119
 
129
- code = code.replaceAll("typia.tags.assert", "typia.assert");
120
+ code = code.replaceAll("typia.tags.assert", "typia.assert");
130
121
 
131
- return code;
132
- };
122
+ return code;
133
123
  }