@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,10 +1,34 @@
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
  export declare namespace IAutoBeRealizeWriteApplication {
22
+ /**
23
+ * Properties for the Realize Write Application following Chain of Thinking (CoT).
24
+ *
25
+ * Each field represents a distinct phase in the reasoning and implementation process,
26
+ * building upon the previous step to create a complete, error-free implementation.
27
+ * This structured approach ensures clarity, debuggability, and systematic thinking.
28
+ */
5
29
  interface IProps {
6
30
  /**
7
- * Step 1.
31
+ * Step 1 - Planning Phase (CoT: Initial Reasoning)
8
32
  *
9
33
  * 🧠 Provider Function Implementation Plan
10
34
  *
@@ -17,13 +41,18 @@ export declare namespace IAutoBeRealizeWriteApplication {
17
41
  * 📋 STEP 1 - PRISMA SCHEMA VERIFICATION:
18
42
  *
19
43
  * DO:
44
+ *
20
45
  * - Examine the actual Prisma schema model definition
21
46
  * - List EVERY field that exists in the model with exact types
22
47
  * - Explicitly note fields that DO NOT exist
48
+ * - Verify database compatibility (PostgreSQL AND SQLite)
23
49
  *
24
50
  * DO NOT:
51
+ *
25
52
  * - Assume common fields exist without verification
26
- * - Use fields like deleted_at, created_by, updated_by, is_deleted, is_active without checking
53
+ * - Use fields like deleted_at, created_by, updated_by, is_deleted, is_active
54
+ * without checking
55
+ * - Use PostgreSQL-specific features like mode: "insensitive"
27
56
  *
28
57
  * 📋 STEP 2 - FIELD INVENTORY:
29
58
  *
@@ -131,7 +160,7 @@ export declare namespace IAutoBeRealizeWriteApplication {
131
160
  */
132
161
  plan: string;
133
162
  /**
134
- * Step 2.
163
+ * Step 2 - Schema Definition (CoT: Context Establishment)
135
164
  *
136
165
  * The Prisma schema string that will be used to validate the implementation
137
166
  * logic in this file.
@@ -152,7 +181,7 @@ export declare namespace IAutoBeRealizeWriteApplication {
152
181
  */
153
182
  prisma_schemas: string;
154
183
  /**
155
- * Step 3.
184
+ * Step 3 - Initial Draft (CoT: First Implementation Attempt)
156
185
  *
157
186
  * Draft WITHOUT using native Date type.
158
187
  *
@@ -171,10 +200,12 @@ export declare namespace IAutoBeRealizeWriteApplication {
171
200
  * Import rules:
172
201
  *
173
202
  * DO NOT:
203
+ *
174
204
  * - Add any new import statements manually
175
205
  * - Write import statements directly (this causes compile errors)
176
206
  *
177
- * Note: All necessary imports are provided globally or by the system automatically.
207
+ * Note: All necessary imports are provided globally or by the system
208
+ * automatically.
178
209
  *
179
210
  * ✅ Requirements:
180
211
  *
@@ -186,7 +217,7 @@ export declare namespace IAutoBeRealizeWriteApplication {
186
217
  */
187
218
  draft_without_date_type: string;
188
219
  /**
189
- * Step 4.
220
+ * Step 4 - Review and Refinement (CoT: Self-Reflection)
190
221
  *
191
222
  * A refined version of the draft with improved completeness.
192
223
  *
@@ -200,27 +231,11 @@ export declare namespace IAutoBeRealizeWriteApplication {
200
231
  * - Avoid unsafe `as` casts unless only for branding or literal narrowing.
201
232
  * - Use `toISOStringSafe()` for all date conversions (NOT `.toISOString()`).
202
233
  * - Ensure all object keys strictly conform to the expected type definitions.
234
+ * - NEVER use `mode: "insensitive"` in string operations (breaks SQLite).
203
235
  */
204
236
  review: string;
205
237
  /**
206
- * 🛠 Phase 4-2: With compiler feedback (optional)
207
- *
208
- * A correction pass that applies fixes for compile-time errors that arose
209
- * during the review stage (if any).
210
- *
211
- * ✅ Must:
212
- *
213
- * - Only include this field if TypeScript errors are detected in the Review
214
- * phase.
215
- * - Resolve all TypeScript errors without using `as any`.
216
- * - Provide safe brand casting only if required (e.g., `as string &
217
- * tags.Format<'uuid'>`).
218
- * - If no TypeScript errors exist, this field MUST contain the text: "No
219
- * TypeScript errors detected - skipping this phase"
220
- */
221
- withCompilerFeedback: string;
222
- /**
223
- * Step 5.
238
+ * Step 5 - Complete Implementation (CoT: Final Synthesis)
224
239
  *
225
240
  * The complete and fully correct TypeScript function implementation.
226
241
  *
@@ -232,6 +247,7 @@ export declare namespace IAutoBeRealizeWriteApplication {
232
247
  * - Uses only allowed imports (e.g., from `../api/structures` and
233
248
  * `MyGlobal.prisma`).
234
249
  * - NEVER creates intermediate variables for Prisma operations.
250
+ * - NEVER uses `mode: "insensitive"` (PostgreSQL-only, breaks SQLite).
235
251
  *
236
252
  * ⚠️ Fallback Behavior:
237
253
  *
@@ -0,0 +1,31 @@
1
+ import { AutoBeOpenApi, AutoBeRealizeAuthorization } from "@autobe/interface";
2
+ import { IAutoBeRealizeScenarioResult } from "../structures/IAutoBeRealizeScenarioResult";
3
+ /**
4
+ * Generate a TypeScript function template for the Realize Agent to complete
5
+ *
6
+ * This utility creates a function skeleton with proper imports, parameters, and
7
+ * return type that the AI needs to implement. The template includes:
8
+ *
9
+ * - Import statements for required dependencies
10
+ * - Function signature with all parameters
11
+ * - Return type specification
12
+ *
13
+ * @example
14
+ * // Returns a template like:
15
+ * ```typescript
16
+ * import { MyGlobal } from "../MyGlobal";
17
+ * // ... other imports
18
+ *
19
+ * async function post__users_create(
20
+ * body: IUserCreateRequest
21
+ * ): Promise<IUserResponse> {
22
+ * ...
23
+ * }
24
+ * ```;
25
+ *
26
+ * @param scenario - The realize scenario containing function metadata
27
+ * @param operation - OpenAPI operation definition
28
+ * @param authorization - Authorization context if endpoint is authenticated
29
+ * @returns Complete TypeScript code template as a formatted string
30
+ */
31
+ export declare function getRealizeWriteCodeTemplate(scenario: IAutoBeRealizeScenarioResult, operation: AutoBeOpenApi.IOperation, authorization: AutoBeRealizeAuthorization | null): string;
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRealizeWriteCodeTemplate = getRealizeWriteCodeTemplate;
4
+ const utils_1 = require("@autobe/utils");
5
+ const getRealizeWriteImportStatements_1 = require("./getRealizeWriteImportStatements");
6
+ /**
7
+ * Generate a TypeScript function template for the Realize Agent to complete
8
+ *
9
+ * This utility creates a function skeleton with proper imports, parameters, and
10
+ * return type that the AI needs to implement. The template includes:
11
+ *
12
+ * - Import statements for required dependencies
13
+ * - Function signature with all parameters
14
+ * - Return type specification
15
+ *
16
+ * @example
17
+ * // Returns a template like:
18
+ * ```typescript
19
+ * import { MyGlobal } from "../MyGlobal";
20
+ * // ... other imports
21
+ *
22
+ * async function post__users_create(
23
+ * body: IUserCreateRequest
24
+ * ): Promise<IUserResponse> {
25
+ * ...
26
+ * }
27
+ * ```;
28
+ *
29
+ * @param scenario - The realize scenario containing function metadata
30
+ * @param operation - OpenAPI operation definition
31
+ * @param authorization - Authorization context if endpoint is authenticated
32
+ * @returns Complete TypeScript code template as a formatted string
33
+ */
34
+ function getRealizeWriteCodeTemplate(scenario, operation, authorization) {
35
+ var _a, _b, _c;
36
+ // Collect all function parameters in order
37
+ const functionParameters = [];
38
+ // Add authentication parameter if needed (e.g., user: IUser, admin: IAdmin)
39
+ if (authorization && authorization.role.name) {
40
+ // Debug: Log the values to check what's being used
41
+ const authParameter = `${authorization.role.name}: ${authorization.payload.name}`;
42
+ functionParameters.push(authParameter);
43
+ }
44
+ // Add path parameters (e.g., id, postId, etc.)
45
+ const pathParameters = operation.parameters.map((param) => {
46
+ const paramType = param.schema.type;
47
+ const paramFormat = "format" in param.schema
48
+ ? ` & tags.Format<'${param.schema.format}'>`
49
+ : "";
50
+ return `${param.name}: ${paramType}${paramFormat}`;
51
+ });
52
+ functionParameters.push(...pathParameters);
53
+ // Add request body parameter if present
54
+ if ((_a = operation.requestBody) === null || _a === void 0 ? void 0 : _a.typeName) {
55
+ const bodyParameter = `body: ${operation.requestBody.typeName}`;
56
+ functionParameters.push(bodyParameter);
57
+ }
58
+ // Format parameters for props object
59
+ const hasParameters = functionParameters.length > 0;
60
+ let formattedSignature;
61
+ if (hasParameters) {
62
+ const propsFields = functionParameters
63
+ .map((param) => ` ${param}`)
64
+ .join(";\n");
65
+ formattedSignature = `props: {\n${propsFields};\n}`;
66
+ }
67
+ else {
68
+ formattedSignature = "";
69
+ }
70
+ // Determine return type
71
+ const returnType = (_c = (_b = operation.responseBody) === null || _b === void 0 ? void 0 : _b.typeName) !== null && _c !== void 0 ? _c : "void";
72
+ // Generate the complete template
73
+ return utils_1.StringUtil.trim `
74
+ Complete the code below, disregard the import part and return only the function part.
75
+
76
+ \`\`\`typescript
77
+ ${(0, getRealizeWriteImportStatements_1.getRealizeWriteImportStatements)(operation).join("\n")}
78
+
79
+ // ONLY YOU HAVE TO WRITE THIS, AND USE IMPORTED.
80
+ export async function ${scenario.functionName}(${formattedSignature}): Promise<${returnType}> {
81
+ ...
82
+ }
83
+ \`\`\`
84
+ `;
85
+ }
86
+ //# sourceMappingURL=getRealizeWriteCodeTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRealizeWriteCodeTemplate.js","sourceRoot":"","sources":["../../../../../../src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.ts"],"names":[],"mappings":";;AAkCA,kEA8DC;AA/FD,yCAA2C;AAG3C,uFAAoF;AAEpF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,2BAA2B,CACzC,QAAsC,EACtC,SAAmC,EACnC,aAAgD;;IAEhD,2CAA2C;IAC3C,MAAM,kBAAkB,GAAa,EAAE,CAAC;IAExC,4EAA4E;IAC5E,IAAI,aAAa,IAAI,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAC7C,mDAAmD;QACnD,MAAM,aAAa,GAAG,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,KAAK,aAAa,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAClF,kBAAkB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACzC,CAAC;IAED,+CAA+C;IAC/C,MAAM,cAAc,GAAG,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACxD,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;QACpC,MAAM,WAAW,GACf,QAAQ,IAAI,KAAK,CAAC,MAAM;YACtB,CAAC,CAAC,mBAAmB,KAAK,CAAC,MAAM,CAAC,MAAM,IAAI;YAC5C,CAAC,CAAC,EAAE,CAAC;QACT,OAAO,GAAG,KAAK,CAAC,IAAI,KAAK,SAAS,GAAG,WAAW,EAAE,CAAC;IACrD,CAAC,CAAC,CAAC;IACH,kBAAkB,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC;IAE3C,wCAAwC;IACxC,IAAI,MAAA,SAAS,CAAC,WAAW,0CAAE,QAAQ,EAAE,CAAC;QACpC,MAAM,aAAa,GAAG,SAAS,SAAS,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;QAChE,kBAAkB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACzC,CAAC;IAED,qCAAqC;IACrC,MAAM,aAAa,GAAG,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC;IAEpD,IAAI,kBAA0B,CAAC;IAC/B,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,WAAW,GAAG,kBAAkB;aACnC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,EAAE,CAAC;aAC5B,IAAI,CAAC,KAAK,CAAC,CAAC;QAEf,kBAAkB,GAAG,aAAa,WAAW,MAAM,CAAC;IACtD,CAAC;SAAM,CAAC;QACN,kBAAkB,GAAG,EAAE,CAAC;IAC1B,CAAC;IAED,wBAAwB;IACxB,MAAM,UAAU,GAAG,MAAA,MAAA,SAAS,CAAC,YAAY,0CAAE,QAAQ,mCAAI,MAAM,CAAC;IAE9D,iCAAiC;IACjC,OAAO,kBAAU,CAAC,IAAI,CAAA;;;;MAIlB,IAAA,iEAA+B,EAAC,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;;4BAG/B,QAAQ,CAAC,YAAY,IAAI,kBAAkB,cAAc,UAAU;;;;GAI5F,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { AutoBeOpenApi } from "@autobe/interface";
2
+ import { ILlmSchema } from "@samchon/openapi";
3
+ import { AutoBeContext } from "../../../context/AutoBeContext";
4
+ export declare function getRealizeWriteDto<Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>, operation: AutoBeOpenApi.IOperation): Promise<Record<string, string>>;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getRealizeWriteDto = getRealizeWriteDto;
13
+ const openapi_1 = require("@samchon/openapi");
14
+ function getRealizeWriteDto(ctx, operation) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ const document = filterDocument(operation, ctx.state().interface.document);
17
+ const compiler = yield ctx.compiler();
18
+ const entries = Object.entries(yield compiler.interface.write(document));
19
+ const filter = (prefix, exclude) => {
20
+ const result = entries.filter(([key]) => key.startsWith(prefix) === true);
21
+ return Object.fromEntries(exclude
22
+ ? result.filter(([key]) => key.startsWith(exclude) === false)
23
+ : result);
24
+ };
25
+ const dto = filter("src/api/structures");
26
+ return dto;
27
+ });
28
+ }
29
+ function filterDocument(operation, document) {
30
+ const components = {
31
+ authorization: document.components.authorization,
32
+ schemas: {},
33
+ };
34
+ const visit = (typeName) => {
35
+ openapi_1.OpenApiTypeChecker.visit({
36
+ components: document.components,
37
+ schema: { $ref: `#/components/schemas/${typeName}` },
38
+ closure: (s) => {
39
+ if (openapi_1.OpenApiTypeChecker.isReference(s)) {
40
+ const key = s.$ref.split("/").pop();
41
+ components.schemas[key] = document.components.schemas[key];
42
+ }
43
+ },
44
+ });
45
+ };
46
+ if (operation.requestBody)
47
+ visit(operation.requestBody.typeName);
48
+ if (operation.responseBody)
49
+ visit(operation.responseBody.typeName);
50
+ return {
51
+ operations: [operation],
52
+ components,
53
+ };
54
+ }
55
+ //# sourceMappingURL=getRealizeWriteDto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRealizeWriteDto.js","sourceRoot":"","sources":["../../../../../../src/orchestrate/realize/utils/getRealizeWriteDto.ts"],"names":[],"mappings":";;;;;;;;;;;AAKA,gDA2BC;AA/BD,8CAAkE;AAIlE,SAAsB,kBAAkB,CACtC,GAAyB,EACzB,SAAmC;;QAEnC,MAAM,QAAQ,GAA4B,cAAc,CACtD,SAAS,EACT,GAAG,CAAC,KAAK,EAAE,CAAC,SAAU,CAAC,QAAQ,CAChC,CAAC;QAEF,MAAM,QAAQ,GAAoB,MAAM,GAAG,CAAC,QAAQ,EAAE,CAAC;QACvD,MAAM,OAAO,GAAuB,MAAM,CAAC,OAAO,CAChD,MAAM,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CACzC,CAAC;QAEF,MAAM,MAAM,GAAG,CAAC,MAAc,EAAE,OAAgB,EAAE,EAAE;YAClD,MAAM,MAAM,GAAuB,OAAO,CAAC,MAAM,CAC/C,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,IAAI,CAC3C,CAAC;YACF,OAAO,MAAM,CAAC,WAAW,CACvB,OAAO;gBACL,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,KAAK,CAAC;gBAC7D,CAAC,CAAC,MAAM,CACX,CAAC;QACJ,CAAC,CAAC;QAEF,MAAM,GAAG,GAA2B,MAAM,CAAC,oBAAoB,CAAC,CAAC;QACjE,OAAO,GAAG,CAAC;IACb,CAAC;CAAA;AAED,SAAS,cAAc,CACrB,SAAmC,EACnC,QAAiC;IAEjC,MAAM,UAAU,GAA8B;QAC5C,aAAa,EAAE,QAAQ,CAAC,UAAU,CAAC,aAAa;QAChD,OAAO,EAAE,EAAE;KACZ,CAAC;IAEF,MAAM,KAAK,GAAG,CAAC,QAAgB,EAAE,EAAE;QACjC,4BAAkB,CAAC,KAAK,CAAC;YACvB,UAAU,EAAE,QAAQ,CAAC,UAAU;YAC/B,MAAM,EAAE,EAAE,IAAI,EAAE,wBAAwB,QAAQ,EAAE,EAAE;YACpD,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;gBACb,IAAI,4BAAkB,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;oBACtC,MAAM,GAAG,GAAW,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAG,CAAC;oBAC7C,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;gBAC7D,CAAC;YACH,CAAC;SACF,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,IAAI,SAAS,CAAC,WAAW;QAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACjE,IAAI,SAAS,CAAC,YAAY;QAAE,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAEnE,OAAO;QACL,UAAU,EAAE,CAAC,SAAS,CAAC;QACvB,UAAU;KACX,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { AutoBeOpenApi } from "@autobe/interface";
2
+ export declare function getRealizeWriteImportStatements(operation: AutoBeOpenApi.IOperation): string[];
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRealizeWriteImportStatements = getRealizeWriteImportStatements;
4
+ function getRealizeWriteImportStatements(operation) {
5
+ const typeReferences = Array.from(new Set([operation.requestBody, operation.responseBody]
6
+ .filter((el) => el !== null)
7
+ .map((el) => el.typeName.split(".")[0])));
8
+ // Build the standard imports
9
+ const imports = [
10
+ 'import jwt from "jsonwebtoken";',
11
+ 'import { MyGlobal } from "../MyGlobal";',
12
+ 'import typia, { tags } from "typia";',
13
+ 'import { Prisma } from "@prisma/client";',
14
+ 'import { v4 } from "uuid";',
15
+ 'import { toISOStringSafe } from "../util/toISOStringSafe"',
16
+ ...typeReferences.map((ref) => `import { ${ref} } from "@ORGANIZATION/PROJECT-api/lib/structures/${ref}";`),
17
+ ];
18
+ return imports;
19
+ }
20
+ //# sourceMappingURL=getRealizeWriteImportStatements.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRealizeWriteImportStatements.js","sourceRoot":"","sources":["../../../../../../src/orchestrate/realize/utils/getRealizeWriteImportStatements.ts"],"names":[],"mappings":";;AAEA,0EA0BC;AA1BD,SAAgB,+BAA+B,CAC7C,SAAmC;IAEnC,MAAM,cAAc,GAAa,KAAK,CAAC,IAAI,CACzC,IAAI,GAAG,CACL,CAAC,SAAS,CAAC,WAAW,EAAE,SAAS,CAAC,YAAY,CAAC;SAC5C,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;SAC3B,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC,CAC3C,CACF,CAAC;IAEF,6BAA6B;IAC7B,MAAM,OAAO,GAAG;QACd,iCAAiC;QACjC,yCAAyC;QACzC,sCAAsC;QACtC,0CAA0C;QAC1C,4BAA4B;QAC5B,2DAA2D;QAC3D,GAAG,cAAc,CAAC,GAAG,CACnB,CAAC,GAAG,EAAE,EAAE,CACN,YAAY,GAAG,qDAAqD,GAAG,IAAI,CAC9E;KACF,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { AutoBeOpenApi, AutoBeRealizeAuthorization } from "@autobe/interface";
2
+ /**
3
+ * Generate TypeScript type definition string for provider function props
4
+ *
5
+ * This utility creates the exact props interface that the Realize Agent's
6
+ * generated provider functions must accept. It combines:
7
+ *
8
+ * - Authentication context (user/admin/member from authorization)
9
+ * - URL path parameters (e.g., id, boardId, postId)
10
+ * - Request body type (if applicable)
11
+ *
12
+ * The output is injected into REALIZE_WRITE_ARTIFACT.md template to tell the AI
13
+ * exactly what parameter type the function should accept.
14
+ *
15
+ * @example
16
+ * // For DELETE /posts/:id (authenticated)
17
+ * // Returns: "props: { user: IUser; id: string & tags.Format<'uuid'>; }"
18
+ *
19
+ * @example
20
+ * // For GET /public/info (no auth, no params)
21
+ * // Returns: "// No props parameter needed - function should have no parameters"
22
+ *
23
+ * @param operation - OpenAPI operation definition containing parameters and
24
+ * auth requirements
25
+ * @param authorization - Authorization context with user/role information (if
26
+ * authenticated endpoint)
27
+ * @returns TypeScript interface string like "props: { user: IUser; id: string;
28
+ * body: IRequest; }"
29
+ */
30
+ export declare function getRealizeWriteInputType(operation: AutoBeOpenApi.IOperation, authorization: AutoBeRealizeAuthorization | null): string;
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRealizeWriteInputType = getRealizeWriteInputType;
4
+ const utils_1 = require("@autobe/utils");
5
+ /**
6
+ * Generate TypeScript type definition string for provider function props
7
+ *
8
+ * This utility creates the exact props interface that the Realize Agent's
9
+ * generated provider functions must accept. It combines:
10
+ *
11
+ * - Authentication context (user/admin/member from authorization)
12
+ * - URL path parameters (e.g., id, boardId, postId)
13
+ * - Request body type (if applicable)
14
+ *
15
+ * The output is injected into REALIZE_WRITE_ARTIFACT.md template to tell the AI
16
+ * exactly what parameter type the function should accept.
17
+ *
18
+ * @example
19
+ * // For DELETE /posts/:id (authenticated)
20
+ * // Returns: "props: { user: IUser; id: string & tags.Format<'uuid'>; }"
21
+ *
22
+ * @example
23
+ * // For GET /public/info (no auth, no params)
24
+ * // Returns: "// No props parameter needed - function should have no parameters"
25
+ *
26
+ * @param operation - OpenAPI operation definition containing parameters and
27
+ * auth requirements
28
+ * @param authorization - Authorization context with user/role information (if
29
+ * authenticated endpoint)
30
+ * @returns TypeScript interface string like "props: { user: IUser; id: string;
31
+ * body: IRequest; }"
32
+ */
33
+ function getRealizeWriteInputType(operation, authorization) {
34
+ var _a, _b;
35
+ const functionParameterFields = [];
36
+ // Add authentication field (user/admin/member) if endpoint requires auth
37
+ const hasAuthentication = authorization && operation.authorizationRole;
38
+ if (hasAuthentication) {
39
+ const authFieldName = operation.authorizationRole;
40
+ const authFieldType = authorization.payload.name;
41
+ functionParameterFields.push(`${authFieldName}: ${authFieldType};`);
42
+ }
43
+ // Add URL path parameters (e.g., /posts/:id → id parameter)
44
+ const pathParameters = operation.parameters;
45
+ pathParameters.forEach((pathParam) => {
46
+ const paramName = pathParam.name;
47
+ const paramType = pathParam.schema.type;
48
+ const paramFormat = "format" in pathParam.schema
49
+ ? ` & tags.Format<'${pathParam.schema.format}'>`
50
+ : "";
51
+ const parameterField = `${paramName}: ${paramType}${paramFormat};`;
52
+ functionParameterFields.push(parameterField);
53
+ });
54
+ // Add request body if present (POST/PUT/PATCH operations)
55
+ const hasRequestBody = (_a = operation.requestBody) === null || _a === void 0 ? void 0 : _a.typeName;
56
+ if (hasRequestBody) {
57
+ const bodyTypeName = (_b = operation.requestBody) === null || _b === void 0 ? void 0 : _b.typeName;
58
+ functionParameterFields.push(`body: ${bodyTypeName};`);
59
+ }
60
+ // Format as TypeScript props interface or indicate no parameters needed
61
+ const hasParameters = functionParameterFields.length > 0;
62
+ if (!hasParameters) {
63
+ return `// No props parameter needed - function should have no parameters`;
64
+ }
65
+ const formattedFields = functionParameterFields
66
+ .map((field) => ` ${field}`)
67
+ .join("\n");
68
+ return utils_1.StringUtil.trim `
69
+ props: {
70
+ ${formattedFields}
71
+ }`;
72
+ }
73
+ //# sourceMappingURL=getRealizeWriteInputType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRealizeWriteInputType.js","sourceRoot":"","sources":["../../../../../../src/orchestrate/realize/utils/getRealizeWriteInputType.ts"],"names":[],"mappings":";;AA+BA,4DAkDC;AAhFD,yCAA2C;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,wBAAwB,CACtC,SAAmC,EACnC,aAAgD;;IAEhD,MAAM,uBAAuB,GAAa,EAAE,CAAC;IAE7C,yEAAyE;IACzE,MAAM,iBAAiB,GAAG,aAAa,IAAI,SAAS,CAAC,iBAAiB,CAAC;IACvE,IAAI,iBAAiB,EAAE,CAAC;QACtB,MAAM,aAAa,GAAG,SAAS,CAAC,iBAAiB,CAAC;QAClD,MAAM,aAAa,GAAG,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC;QACjD,uBAAuB,CAAC,IAAI,CAAC,GAAG,aAAa,KAAK,aAAa,GAAG,CAAC,CAAC;IACtE,CAAC;IAED,4DAA4D;IAC5D,MAAM,cAAc,GAAG,SAAS,CAAC,UAAU,CAAC;IAC5C,cAAc,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;QACnC,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC;QACjC,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC;QACxC,MAAM,WAAW,GACf,QAAQ,IAAI,SAAS,CAAC,MAAM;YAC1B,CAAC,CAAC,mBAAmB,SAAS,CAAC,MAAM,CAAC,MAAM,IAAI;YAChD,CAAC,CAAC,EAAE,CAAC;QAET,MAAM,cAAc,GAAG,GAAG,SAAS,KAAK,SAAS,GAAG,WAAW,GAAG,CAAC;QACnE,uBAAuB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,0DAA0D;IAC1D,MAAM,cAAc,GAAG,MAAA,SAAS,CAAC,WAAW,0CAAE,QAAQ,CAAC;IACvD,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,YAAY,GAAG,MAAA,SAAS,CAAC,WAAW,0CAAE,QAAQ,CAAC;QACrD,uBAAuB,CAAC,IAAI,CAAC,SAAS,YAAY,GAAG,CAAC,CAAC;IACzD,CAAC;IAED,wEAAwE;IACxE,MAAM,aAAa,GAAG,uBAAuB,CAAC,MAAM,GAAG,CAAC,CAAC;IAEzD,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,mEAAmE,CAAC;IAC7E,CAAC;IAED,MAAM,eAAe,GAAG,uBAAuB;SAC5C,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,EAAE,CAAC;SAC5B,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,OAAO,kBAAU,CAAC,IAAI,CAAA;;MAElB,eAAe;MACf,CAAC;AACP,CAAC"}
@@ -1,4 +1,8 @@
1
+ import { AutoBeOpenApi } from "@autobe/interface";
1
2
  import { ILlmSchema } from "@samchon/openapi";
2
3
  import { AutoBeContext } from "../../../context/AutoBeContext";
3
- import { IAutoBeTestScenarioArtifacts } from "../../test/structures/IAutoBeTestScenarioArtifacts";
4
- export declare function replaceImportStatements<Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>): (artifacts: IAutoBeTestScenarioArtifacts, code: string, decoratorType?: string) => Promise<string>;
4
+ export declare function replaceImportStatements<Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>, props: {
5
+ operation: AutoBeOpenApi.IOperation;
6
+ code: string;
7
+ decoratorType?: string;
8
+ }): Promise<string>;
@@ -10,74 +10,68 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.replaceImportStatements = replaceImportStatements;
13
- function replaceImportStatements(ctx) {
14
- return function (artifacts, code, decoratorType) {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- const typeReferences = Array.from(new Set(Object.keys(artifacts.document.components.schemas).map((key) => key.split(".")[0])));
17
- const compiler = yield ctx.compiler();
18
- code = yield compiler.typescript.beautify(code);
19
- // Remove existing import statements using flexible regex patterns
20
- code = code
21
- .replace(/import\s*{\s*MyGlobal\s*}\s*from\s*["']\.\.\/MyGlobal["']\s*;?\s*/gm, "")
22
- .replace(/import\s+typia\s*,\s*{\s*tags\s*}\s*from\s*["']typia["']\s*;?\s*/gm, "")
23
- .replace(/import\s*{\s*tags\s*}\s*from\s*["']typia["']\s*;?\s*/gm, "")
24
- .replace(/import\s*{\s*tags\s*,\s*typia\s*}\s*from\s*["']typia["']\s*;?\s*/gm, "")
25
- .replace(/import\s+typia\s*from\s*["']typia["']\s*;?\s*/gm, "")
26
- .replace(/import\s*{\s*Prisma\s*}\s*from\s*["']@prisma\/client["']\s*;?\s*/gm, "")
27
- .replace(/import\s*{\s*v4\s*}\s*from\s*["']uuid["']\s*;?\s*/gm, "")
28
- .replace(/import\s*{\s*toISOStringSafe\s*}\s*from\s*["']\.\.\/util\/toISOStringSafe["']\s*;?\s*/gm, "")
29
- // Remove JWT import if it exists (to prevent duplication)
30
- .replace(/import\s+jwt\s+from\s*["']jsonwebtoken["']\s*;?\s*/gm, "")
31
- .replace(/import\s*\*\s*as\s+jwt\s+from\s*["']jsonwebtoken["']\s*;?\s*/gm, "");
32
- // Remove any existing API structure imports
33
- // Pattern 1: ../api/structures path
34
- code = code.replace(/import\s*(?:type\s*)?{\s*[^}]+\s*}\s*from\s*["']\.\.\/api\/structures\/[^"']+["']\s*;?\s*/gm, "");
35
- // Pattern 2: @ORGANIZATION/PROJECT-api/lib/structures path
36
- code = code.replace(/import\s*(?:type\s*)?{\s*[^}]+\s*}\s*from\s*["']@ORGANIZATION\/PROJECT-api\/lib\/structures\/[^"']+["']\s*;?\s*/gm, "");
37
- // Remove specific type imports that match our typeReferences
38
- for (const ref of typeReferences) {
39
- // Remove any import of this specific type from any path
40
- const typeImportRegex = new RegExp(`import\\s*(?:type\\s*)?{\\s*${ref}\\s*}\\s*from\\s*["'][^"']+["']\\s*;?\\s*`, "gm");
41
- code = code.replace(typeImportRegex, "");
42
- }
43
- // Remove any existing decoratorType imports if LLM mistakenly added them
44
- if (decoratorType) {
45
- const decoratorTypeRegex = new RegExp(`import\\s*(?:type\\s*)?{\\s*${decoratorType}\\s*}\\s*from\\s*["']\\.\\.\/decorators\/payload\/${decoratorType}["']\\s*;?\\s*`, "gm");
46
- code = code.replace(decoratorTypeRegex, "");
47
- }
48
- // Build the standard imports
49
- const imports = [
50
- 'import jwt from "jsonwebtoken";',
51
- 'import { MyGlobal } from "../MyGlobal";',
52
- 'import typia, { tags } from "typia";',
53
- 'import { Prisma } from "@prisma/client";',
54
- 'import { v4 } from "uuid";',
55
- 'import { toISOStringSafe } from "../util/toISOStringSafe"',
56
- ...typeReferences.map((ref) => `import { ${ref} } from "@ORGANIZATION/PROJECT-api/lib/structures/${ref}";`),
57
- ];
58
- // Only add decoratorType import if it exists
59
- if (decoratorType) {
60
- imports.push(`import { ${decoratorType} } from "../decorators/payload/${decoratorType}"`);
61
- }
62
- code = [...imports, "", code].join("\n");
63
- // Clean up formatting issues
64
- code =
65
- code
66
- // Remove lines with only whitespace
67
- .replace(/^\s+$/gm, "")
68
- // Replace 3+ consecutive newlines with exactly 2 newlines
69
- .replace(/\n{3,}/g, "\n\n")
70
- // Ensure proper spacing after import section
71
- .replace(/(import.*?;)(\s*)(\n(?!import|\s*$))/g, "$1\n\n$3")
72
- // Trim and ensure single trailing newline
73
- .trim() + "\n";
74
- // fix escaped codes
75
- code = code.replace(/\\n/g, "\n").replace(/\\"/g, '"').replace(/\\'/g, "'");
76
- // Apply final beautification
77
- code = yield compiler.typescript.beautify(code);
78
- code = code.replaceAll("typia.tags.assert", "typia.assert");
79
- return code;
80
- });
81
- };
13
+ const getRealizeWriteImportStatements_1 = require("./getRealizeWriteImportStatements");
14
+ function replaceImportStatements(ctx, props) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ let { operation, code, decoratorType } = props;
17
+ const typeReferences = Array.from(new Set([operation.requestBody, operation.responseBody]
18
+ .filter((el) => el !== null)
19
+ .map((el) => el.typeName.split(".")[0])));
20
+ const compiler = yield ctx.compiler();
21
+ code = yield compiler.typescript.beautify(code);
22
+ // Remove existing import statements using flexible regex patterns
23
+ code = code
24
+ .replace(/import\s*{\s*MyGlobal\s*}\s*from\s*["']\.\.\/MyGlobal["']\s*;?\s*/gm, "")
25
+ .replace(/import\s+typia\s*,\s*{\s*tags\s*}\s*from\s*["']typia["']\s*;?\s*/gm, "")
26
+ .replace(/import\s*{\s*tags\s*}\s*from\s*["']typia["']\s*;?\s*/gm, "")
27
+ .replace(/import\s*{\s*tags\s*,\s*typia\s*}\s*from\s*["']typia["']\s*;?\s*/gm, "")
28
+ .replace(/import\s+typia\s*from\s*["']typia["']\s*;?\s*/gm, "")
29
+ .replace(/import\s*{\s*Prisma\s*}\s*from\s*["']@prisma\/client["']\s*;?\s*/gm, "")
30
+ .replace(/import\s*{\s*v4\s*}\s*from\s*["']uuid["']\s*;?\s*/gm, "")
31
+ .replace(/import\s*{\s*toISOStringSafe\s*}\s*from\s*["']\.\.\/util\/toISOStringSafe["']\s*;?\s*/gm, "")
32
+ // Remove JWT import if it exists (to prevent duplication)
33
+ .replace(/import\s+jwt\s+from\s*["']jsonwebtoken["']\s*;?\s*/gm, "")
34
+ .replace(/import\s*\*\s*as\s+jwt\s+from\s*["']jsonwebtoken["']\s*;?\s*/gm, "");
35
+ // Remove any existing API structure imports
36
+ // Pattern 1: ../api/structures path
37
+ code = code.replace(/import\s*(?:type\s*)?{\s*[^}]+\s*}\s*from\s*["']\.\.\/api\/structures\/[^"']+["']\s*;?\s*/gm, "");
38
+ // Pattern 2: @ORGANIZATION/PROJECT-api/lib/structures path
39
+ code = code.replace(/import\s*(?:type\s*)?{\s*[^}]+\s*}\s*from\s*["']@ORGANIZATION\/PROJECT-api\/lib\/structures\/[^"']+["']\s*;?\s*/gm, "");
40
+ // Remove specific type imports that match our typeReferences
41
+ for (const ref of typeReferences) {
42
+ // Remove any import of this specific type from any path
43
+ const typeImportRegex = new RegExp(`import\\s*(?:type\\s*)?{\\s*${ref}\\s*}\\s*from\\s*["'][^"']+["']\\s*;?\\s*`, "gm");
44
+ code = code.replace(typeImportRegex, "");
45
+ }
46
+ // Remove any existing decoratorType imports if LLM mistakenly added them
47
+ if (decoratorType) {
48
+ const decoratorTypeRegex = new RegExp(`import\\s*(?:type\\s*)?{\\s*${decoratorType}\\s*}\\s*from\\s*["']\\.\\.\/decorators\/payload\/${decoratorType}["']\\s*;?\\s*`, "gm");
49
+ code = code.replace(decoratorTypeRegex, "");
50
+ }
51
+ // Build the standard imports
52
+ const imports = (0, getRealizeWriteImportStatements_1.getRealizeWriteImportStatements)(operation);
53
+ // Only add decoratorType import if it exists
54
+ if (decoratorType) {
55
+ imports.push(`import { ${decoratorType} } from "../decorators/payload/${decoratorType}"`);
56
+ }
57
+ code = [...imports, "", code].join("\n");
58
+ // Clean up formatting issues
59
+ code =
60
+ code
61
+ // Remove lines with only whitespace
62
+ .replace(/^\s+$/gm, "")
63
+ // Replace 3+ consecutive newlines with exactly 2 newlines
64
+ .replace(/\n{3,}/g, "\n\n")
65
+ // Ensure proper spacing after import section
66
+ .replace(/(import.*?;)(\s*)(\n(?!import|\s*$))/g, "$1\n\n$3")
67
+ // Trim and ensure single trailing newline
68
+ .trim() + "\n";
69
+ // fix escaped codes
70
+ code = code.replace(/\\n/g, "\n").replace(/\\"/g, '"').replace(/\\'/g, "'");
71
+ // Apply final beautification
72
+ code = yield compiler.typescript.beautify(code);
73
+ code = code.replaceAll("typia.tags.assert", "typia.assert");
74
+ return code;
75
+ });
82
76
  }
83
77
  //# sourceMappingURL=replaceImportStatements.js.map