@autobe/agent 0.21.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 (291) 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/constants/AutoBeConfigConstant.d.ts +3 -0
  4. package/lib/agent/src/{orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.js → constants/AutoBeConfigConstant.js} +1 -1
  5. package/lib/agent/src/constants/AutoBeConfigConstant.js.map +1 -0
  6. package/lib/agent/src/constants/AutoBeSystemPromptConstant.d.ts +27 -27
  7. package/lib/agent/src/context/AutoBeContext.d.ts +1 -0
  8. package/lib/agent/src/context/AutoBeTokenUsageComponent.js +4 -3
  9. package/lib/agent/src/context/AutoBeTokenUsageComponent.js.map +1 -1
  10. package/lib/agent/src/factory/consentFunctionCall.js +4 -4
  11. package/lib/agent/src/factory/consentFunctionCall.js.map +1 -1
  12. package/lib/agent/src/factory/createAutoBeContext.js +13 -10
  13. package/lib/agent/src/factory/createAutoBeContext.js.map +1 -1
  14. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js +1 -1
  15. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js.map +1 -1
  16. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js +2 -2
  17. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js.map +1 -1
  18. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js +1 -1
  19. package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js.map +1 -1
  20. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeReview.js +6 -6
  21. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeScenario.js +50 -8
  22. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeScenario.js.map +1 -1
  23. package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeWrite.js +4 -4
  24. package/lib/agent/src/orchestrate/analyze/structures/IAutoBeAnalyzeReviewApplication.d.ts +6 -0
  25. package/lib/agent/src/orchestrate/analyze/structures/IAutoBeAnalyzeWriteApplication.d.ts +4 -0
  26. package/lib/agent/src/orchestrate/facade/transformFacadeStateMessage.js +1 -1
  27. package/lib/agent/src/orchestrate/facade/transformFacadeStateMessage.js.map +1 -1
  28. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js +19 -1
  29. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js.map +1 -1
  30. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceComplementHistories.js +3 -3
  31. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -1
  32. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.js +1 -1
  33. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.js.map +1 -1
  34. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js +2 -2
  35. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js.map +1 -1
  36. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceGroupHistories.js +2 -2
  37. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceGroupHistories.js.map +1 -1
  38. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationHistories.js +1 -1
  39. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationHistories.js.map +1 -1
  40. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js +2 -2
  41. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js.map +1 -1
  42. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +1 -1
  43. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -1
  44. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.d.ts +1 -1
  45. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js +2 -2
  46. package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js.map +1 -1
  47. package/lib/agent/src/orchestrate/interface/orchestrateInterface.js +5 -1
  48. package/lib/agent/src/orchestrate/interface/orchestrateInterface.js.map +1 -1
  49. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceAuthorizations.js +16 -10
  50. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceAuthorizations.js.map +1 -1
  51. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceComplement.d.ts +1 -1
  52. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceComplement.js +3731 -228
  53. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
  54. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpoints.js +2 -2
  55. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpointsReview.js +2 -2
  56. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperations.js +43 -63
  57. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
  58. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperationsReview.js +1261 -1628
  59. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperationsReview.js.map +1 -1
  60. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemas.js +3466 -103
  61. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -1
  62. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemasReview.d.ts +6 -1
  63. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemasReview.js +3672 -358
  64. package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemasReview.js.map +1 -1
  65. package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.d.ts +0 -38
  66. package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.d.ts +48 -141
  67. package/lib/agent/src/orchestrate/interface/structures/IAutobeInterfaceSchemasReviewApplication.d.ts +29 -23
  68. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaFactory.d.ts +9 -0
  69. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaFactory.js +1385 -0
  70. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaFactory.js.map +1 -0
  71. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaNamingConvention.d.ts +5 -0
  72. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaNamingConvention.js +78 -0
  73. package/lib/agent/src/orchestrate/interface/utils/JsonSchemaNamingConvention.js.map +1 -0
  74. package/lib/agent/src/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.d.ts +2 -0
  75. package/lib/agent/src/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.js +81 -0
  76. package/lib/agent/src/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.js.map +1 -0
  77. package/lib/agent/src/orchestrate/interface/utils/validateAuthorizationSchema.js.map +1 -1
  78. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.js +1 -1
  79. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.js.map +1 -1
  80. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaCorrectHistories.js +1 -1
  81. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaCorrectHistories.js.map +1 -1
  82. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaReviewHistories.js +2 -2
  83. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaReviewHistories.js.map +1 -1
  84. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.js +1 -1
  85. package/lib/agent/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.js.map +1 -1
  86. package/lib/agent/src/orchestrate/prisma/orchestratePrismaCorrect.d.ts +1 -1
  87. package/lib/agent/src/orchestrate/prisma/orchestratePrismaCorrect.js +2 -2
  88. package/lib/agent/src/orchestrate/prisma/orchestratePrismaCorrect.js.map +1 -1
  89. package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorization.js +1 -1
  90. package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorization.js.map +1 -1
  91. package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js +2 -2
  92. package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js.map +1 -1
  93. package/lib/agent/src/orchestrate/realize/histories/transformRealizeCorrectHistories.d.ts +6 -6
  94. package/lib/agent/src/orchestrate/realize/histories/transformRealizeCorrectHistories.js +22 -7
  95. package/lib/agent/src/orchestrate/realize/histories/transformRealizeCorrectHistories.js.map +1 -1
  96. package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.d.ts +5 -8
  97. package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.js +13 -29
  98. package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.js.map +1 -1
  99. package/lib/agent/src/orchestrate/realize/internal/compileRealizeFiles.d.ts +2 -2
  100. package/lib/agent/src/orchestrate/realize/internal/compileRealizeFiles.js +2 -8
  101. package/lib/agent/src/orchestrate/realize/internal/compileRealizeFiles.js.map +1 -1
  102. package/lib/agent/src/orchestrate/realize/orchestrateRealize.js +6 -49
  103. package/lib/agent/src/orchestrate/realize/orchestrateRealize.js.map +1 -1
  104. package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorization.js +4 -2
  105. package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorization.js.map +1 -1
  106. package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js +5 -3
  107. package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js.map +1 -1
  108. package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.d.ts +13 -6
  109. package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.js +206 -118
  110. package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
  111. package/lib/agent/src/orchestrate/realize/orchestrateRealizeScenario.d.ts +2 -2
  112. package/lib/agent/src/orchestrate/realize/orchestrateRealizeScenario.js.map +1 -1
  113. package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.d.ts +2 -2
  114. package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.js +24 -39
  115. package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.js.map +1 -1
  116. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.d.ts +17 -0
  117. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.d.ts +20 -0
  118. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.d.ts +33 -73
  119. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeFunctionFailure.d.ts +5 -0
  120. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeFunctionFailure.js +3 -0
  121. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeFunctionFailure.js.map +1 -0
  122. package/{src/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.ts → lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioResult.d.ts} +2 -13
  123. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioResult.js +3 -0
  124. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioResult.js.map +1 -0
  125. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +33 -22
  126. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.d.ts +31 -0
  127. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.js +86 -0
  128. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.js.map +1 -0
  129. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteDto.d.ts +4 -0
  130. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteDto.js +55 -0
  131. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteDto.js.map +1 -0
  132. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteImportStatements.d.ts +2 -0
  133. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteImportStatements.js +20 -0
  134. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteImportStatements.js.map +1 -0
  135. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteInputType.d.ts +30 -0
  136. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteInputType.js +73 -0
  137. package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteInputType.js.map +1 -0
  138. package/lib/agent/src/orchestrate/realize/utils/replaceImportStatements.d.ts +6 -2
  139. package/lib/agent/src/orchestrate/realize/utils/replaceImportStatements.js +63 -69
  140. package/lib/agent/src/orchestrate/realize/utils/replaceImportStatements.js.map +1 -1
  141. package/lib/agent/src/orchestrate/test/compile/completeTestCode.js +15 -14
  142. package/lib/agent/src/orchestrate/test/compile/completeTestCode.js.map +1 -1
  143. package/lib/agent/src/orchestrate/test/compile/getTestExternalDeclarations.js +1 -1
  144. package/lib/agent/src/orchestrate/test/compile/getTestExternalDeclarations.js.map +1 -1
  145. package/lib/agent/src/orchestrate/test/compile/getTestImportStatements.d.ts +2 -0
  146. package/lib/agent/src/orchestrate/test/compile/getTestImportStatements.js +19 -0
  147. package/lib/agent/src/orchestrate/test/compile/getTestImportStatements.js.map +1 -0
  148. package/lib/agent/src/orchestrate/test/compile/getTestScenarioArtifacts.d.ts +1 -1
  149. package/lib/agent/src/orchestrate/test/compile/getTestScenarioArtifacts.js +2 -0
  150. package/lib/agent/src/orchestrate/test/compile/getTestScenarioArtifacts.js.map +1 -1
  151. package/lib/agent/src/orchestrate/test/compile/getTestTemplateCode.d.ts +2 -0
  152. package/lib/agent/src/orchestrate/test/compile/getTestTemplateCode.js +21 -0
  153. package/lib/agent/src/orchestrate/test/compile/getTestTemplateCode.js.map +1 -0
  154. package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.d.ts +2 -2
  155. package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.js +16 -17
  156. package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.js.map +1 -1
  157. package/lib/agent/src/orchestrate/test/histories/transformTestScenarioHistories.js +5 -4
  158. package/lib/agent/src/orchestrate/test/histories/transformTestScenarioHistories.js.map +1 -1
  159. package/lib/agent/src/orchestrate/test/histories/transformTestWriteHistories.js +21 -2
  160. package/lib/agent/src/orchestrate/test/histories/transformTestWriteHistories.js.map +1 -1
  161. package/lib/agent/src/orchestrate/test/orchestrateTest.js +6 -0
  162. package/lib/agent/src/orchestrate/test/orchestrateTest.js.map +1 -1
  163. package/lib/agent/src/orchestrate/test/orchestrateTestCorrect.d.ts +1 -1
  164. package/lib/agent/src/orchestrate/test/orchestrateTestCorrect.js +126 -72
  165. package/lib/agent/src/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  166. package/lib/agent/src/orchestrate/test/orchestrateTestScenario.js +46 -40
  167. package/lib/agent/src/orchestrate/test/orchestrateTestScenario.js.map +1 -1
  168. package/lib/agent/src/orchestrate/test/orchestrateTestWrite.js +121 -42
  169. package/lib/agent/src/orchestrate/test/orchestrateTestWrite.js.map +1 -1
  170. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +48 -45
  171. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestFunctionFailure.d.ts +6 -0
  172. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestFunctionFailure.js +3 -0
  173. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestFunctionFailure.js.map +1 -0
  174. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.d.ts +1 -0
  175. package/lib/agent/src/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +13 -0
  176. package/lib/agent/src/orchestrate/test/utils/getReferenceIds.d.ts +5 -0
  177. package/lib/agent/src/orchestrate/test/utils/getReferenceIds.js +28 -0
  178. package/lib/agent/src/orchestrate/test/utils/getReferenceIds.js.map +1 -0
  179. package/lib/agent/src/structures/IAutoBeConfig.d.ts +2 -0
  180. package/lib/constants/AutoBeConfigConstant.d.ts +3 -0
  181. package/lib/constants/AutoBeSystemPromptConstant.d.ts +27 -27
  182. package/lib/context/AutoBeContext.d.ts +1 -0
  183. package/lib/index.mjs +13805 -3871
  184. package/lib/index.mjs.map +1 -1
  185. package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeReviewApplication.d.ts +6 -0
  186. package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeWriteApplication.d.ts +4 -0
  187. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.d.ts +1 -1
  188. package/lib/orchestrate/interface/orchestrateInterfaceComplement.d.ts +1 -1
  189. package/lib/orchestrate/interface/orchestrateInterfaceSchemasReview.d.ts +6 -1
  190. package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.d.ts +0 -38
  191. package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.d.ts +48 -141
  192. package/lib/orchestrate/interface/structures/IAutobeInterfaceSchemasReviewApplication.d.ts +29 -23
  193. package/lib/orchestrate/interface/utils/JsonSchemaFactory.d.ts +9 -0
  194. package/lib/orchestrate/interface/utils/JsonSchemaNamingConvention.d.ts +5 -0
  195. package/lib/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.d.ts +2 -0
  196. package/lib/orchestrate/prisma/orchestratePrismaCorrect.d.ts +1 -1
  197. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.d.ts +6 -6
  198. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.d.ts +5 -8
  199. package/lib/orchestrate/realize/internal/compileRealizeFiles.d.ts +2 -2
  200. package/lib/orchestrate/realize/orchestrateRealizeCorrect.d.ts +13 -6
  201. package/lib/orchestrate/realize/orchestrateRealizeScenario.d.ts +2 -2
  202. package/lib/orchestrate/realize/orchestrateRealizeWrite.d.ts +2 -2
  203. package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.d.ts +17 -0
  204. package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.d.ts +20 -0
  205. package/lib/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.d.ts +33 -73
  206. package/lib/orchestrate/realize/structures/IAutoBeRealizeFunctionFailure.d.ts +5 -0
  207. package/lib/orchestrate/realize/structures/IAutoBeRealizeScenarioResult.d.ts +36 -0
  208. package/lib/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +33 -22
  209. package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.d.ts +31 -0
  210. package/lib/orchestrate/realize/utils/getRealizeWriteDto.d.ts +4 -0
  211. package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.d.ts +2 -0
  212. package/lib/orchestrate/realize/utils/getRealizeWriteInputType.d.ts +30 -0
  213. package/lib/orchestrate/realize/utils/replaceImportStatements.d.ts +6 -2
  214. package/lib/orchestrate/test/compile/getTestImportStatements.d.ts +2 -0
  215. package/lib/orchestrate/test/compile/getTestScenarioArtifacts.d.ts +1 -1
  216. package/lib/orchestrate/test/compile/getTestTemplateCode.d.ts +2 -0
  217. package/lib/orchestrate/test/histories/transformTestCorrectHistories.d.ts +2 -2
  218. package/lib/orchestrate/test/orchestrateTestCorrect.d.ts +1 -1
  219. package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +48 -45
  220. package/lib/orchestrate/test/structures/IAutoBeTestFunctionFailure.d.ts +6 -0
  221. package/lib/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.d.ts +1 -0
  222. package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +13 -0
  223. package/lib/orchestrate/test/utils/getReferenceIds.d.ts +5 -0
  224. package/lib/structures/IAutoBeConfig.d.ts +2 -0
  225. package/package.json +5 -5
  226. package/src/AutoBeAgent.ts +2 -0
  227. package/src/constants/AutoBeConfigConstant.ts +3 -0
  228. package/src/constants/AutoBeSystemPromptConstant.ts +27 -27
  229. package/src/context/AutoBeContext.ts +1 -0
  230. package/src/context/AutoBeTokenUsageComponent.ts +3 -3
  231. package/src/factory/consentFunctionCall.ts +2 -0
  232. package/src/factory/createAutoBeContext.ts +145 -136
  233. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeReviewApplication.ts +6 -0
  234. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeWriteApplication.ts +4 -0
  235. package/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.ts +19 -1
  236. package/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.ts +1 -4
  237. package/src/orchestrate/interface/orchestrateInterface.ts +15 -4
  238. package/src/orchestrate/interface/orchestrateInterfaceAuthorizations.ts +13 -5
  239. package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +58 -19
  240. package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +11 -11
  241. package/src/orchestrate/interface/orchestrateInterfaceOperationsReview.ts +13 -117
  242. package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +33 -91
  243. package/src/orchestrate/interface/orchestrateInterfaceSchemasReview.ts +72 -95
  244. package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.ts +0 -39
  245. package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.ts +50 -146
  246. package/src/orchestrate/interface/structures/IAutobeInterfaceSchemasReviewApplication.ts +31 -27
  247. package/src/orchestrate/interface/utils/JsonSchemaFactory.ts +171 -0
  248. package/src/orchestrate/interface/utils/JsonSchemaNamingConvention.ts +83 -0
  249. package/src/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.ts +90 -0
  250. package/src/orchestrate/interface/utils/validateAuthorizationSchema.ts +2 -2
  251. package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +1 -2
  252. package/src/orchestrate/realize/histories/transformRealizeCorrectHistories.ts +30 -15
  253. package/src/orchestrate/realize/histories/transformRealizeWriteHistories.ts +27 -49
  254. package/src/orchestrate/realize/internal/compileRealizeFiles.ts +4 -11
  255. package/src/orchestrate/realize/orchestrateRealize.ts +19 -75
  256. package/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.ts +1 -1
  257. package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +114 -25
  258. package/src/orchestrate/realize/orchestrateRealizeScenario.ts +2 -2
  259. package/src/orchestrate/realize/orchestrateRealizeWrite.ts +11 -15
  260. package/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.ts +17 -0
  261. package/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.ts +20 -0
  262. package/src/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.ts +40 -74
  263. package/src/orchestrate/realize/structures/IAutoBeRealizeFunctionFailure.ts +9 -0
  264. package/src/orchestrate/realize/structures/IAutoBeRealizeScenarioResult.ts +45 -0
  265. package/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.ts +33 -22
  266. package/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.ts +97 -0
  267. package/src/orchestrate/realize/utils/getRealizeWriteDto.ts +64 -0
  268. package/src/orchestrate/realize/utils/getRealizeWriteImportStatements.ts +29 -0
  269. package/src/orchestrate/realize/utils/getRealizeWriteInputType.ts +82 -0
  270. package/src/orchestrate/realize/utils/replaceImportStatements.ts +101 -111
  271. package/src/orchestrate/test/compile/completeTestCode.ts +15 -26
  272. package/src/orchestrate/test/compile/getTestExternalDeclarations.ts +1 -0
  273. package/src/orchestrate/test/compile/getTestImportStatements.ts +25 -0
  274. package/src/orchestrate/test/compile/getTestScenarioArtifacts.ts +6 -1
  275. package/src/orchestrate/test/compile/getTestTemplateCode.ts +25 -0
  276. package/src/orchestrate/test/histories/transformTestCorrectHistories.ts +26 -26
  277. package/src/orchestrate/test/histories/transformTestScenarioHistories.ts +6 -5
  278. package/src/orchestrate/test/histories/transformTestWriteHistories.ts +19 -0
  279. package/src/orchestrate/test/orchestrateTest.ts +6 -0
  280. package/src/orchestrate/test/orchestrateTestCorrect.ts +46 -15
  281. package/src/orchestrate/test/orchestrateTestScenario.ts +52 -48
  282. package/src/orchestrate/test/orchestrateTestWrite.ts +23 -5
  283. package/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.ts +49 -46
  284. package/src/orchestrate/test/structures/IAutoBeTestFunctionFailure.ts +8 -0
  285. package/src/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.ts +1 -0
  286. package/src/orchestrate/test/structures/IAutoBeTestWriteApplication.ts +14 -0
  287. package/src/orchestrate/test/utils/getReferenceIds.ts +25 -0
  288. package/src/structures/IAutoBeConfig.ts +3 -0
  289. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.d.ts +0 -38
  290. package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.js.map +0 -1
  291. package/lib/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.d.ts +0 -38
@@ -5,19 +5,21 @@ import { AutoBeOpenApi } from "@autobe/interface";
5
5
  *
6
6
  * Provides functionality to systematically review generated API operations
7
7
  * against business requirements, technical specifications, and OpenAPI
8
- * standards. The review process ensures each operation meets quality criteria
9
- * before proceeding to implementation.
8
+ * standards. The review process outputs a structured thinking process with
9
+ * analytical findings and actionable improvements, along with the final
10
+ * enhanced operations ready for implementation.
10
11
  */
11
12
  export interface IAutoBeInterfaceOperationsReviewApplication {
12
13
  /**
13
14
  * Reviews a batch of API operations for quality and correctness.
14
15
  *
15
- * Validates each operation's request/response schemas, authentication
16
- * handling, error responses, and documentation completeness. Operations are
17
- * marked as passed or failed based on compliance with enterprise standards.
16
+ * Analyzes operations for security vulnerabilities, schema compliance,
17
+ * logical consistency, and standard adherence. Outputs a structured thinking
18
+ * process containing review findings and improvement plans, plus the final
19
+ * production-ready operations with all critical issues resolved.
18
20
  *
19
- * @param input Collection of operations to review with their validation
20
- * results
21
+ * @param input Properties containing the thinking process (review & plan)
22
+ * and the enhanced operations content
21
23
  */
22
24
  reviewOperations(
23
25
  input: IAutoBeInterfaceOperationsReviewApplication.IProps,
@@ -33,6 +35,47 @@ export namespace IAutoBeInterfaceOperationsReviewApplication {
33
35
  * of the AutoBeInterfaceOperationsReviewEvent.
34
36
  */
35
37
  export interface IProps {
38
+ /**
39
+ * Comprehensive thinking process for API operation review.
40
+ *
41
+ * Encapsulates the agent's analytical review findings and actionable
42
+ * improvement plan. This structured thinking process ensures systematic
43
+ * evaluation of API operations against AutoBE's quality standards before
44
+ * generating the final enhanced operations.
45
+ */
46
+ think: IThink;
47
+
48
+ /**
49
+ * Production-ready operations with all critical issues resolved.
50
+ *
51
+ * Final API operations after systematic enhancement:
52
+ *
53
+ * - **Security Fixes Applied**: All authentication boundaries enforced,
54
+ * sensitive data removed from responses, proper authorization
55
+ * implemented
56
+ * - **Logic Corrections Made**: Return types match operation intent, HTTP
57
+ * methods align with semantics, parameters properly utilized
58
+ * - **Schema Alignment Verified**: All fields exist in Prisma schema, types
59
+ * correctly mapped, relationships properly defined
60
+ * - **Quality Improvements Added**: Enhanced documentation, format
61
+ * specifications, validation rules, consistent naming patterns
62
+ *
63
+ * If no issues were found during review, this contains the exact original
64
+ * operations unchanged. These operations are validated and ready for schema
65
+ * generation and subsequent implementation phases.
66
+ */
67
+ content: AutoBeOpenApi.IOperation[];
68
+ }
69
+
70
+ /**
71
+ * Structured thinking process for comprehensive API operation review.
72
+ *
73
+ * Combines analytical review findings with actionable improvement planning
74
+ * to guide the systematic enhancement of API operations. This thinking
75
+ * structure ensures all aspects of API quality are evaluated and addressed
76
+ * before producing the final operations.
77
+ */
78
+ export interface IThink {
36
79
  /**
37
80
  * Comprehensive review analysis with prioritized findings.
38
81
  *
@@ -77,144 +120,5 @@ export namespace IAutoBeInterfaceOperationsReviewApplication {
77
120
  * needed, and the rationale for the modification.
78
121
  */
79
122
  plan: string;
80
-
81
- /**
82
- * Production-ready operations with all critical issues resolved.
83
- *
84
- * Final API operations after systematic enhancement:
85
- *
86
- * - **Security Fixes Applied**: All authentication boundaries enforced,
87
- * sensitive data removed from responses, proper authorization
88
- * implemented
89
- * - **Logic Corrections Made**: Return types match operation intent, HTTP
90
- * methods align with semantics, parameters properly utilized
91
- * - **Schema Alignment Verified**: All fields exist in Prisma schema, types
92
- * correctly mapped, relationships properly defined
93
- * - **Quality Improvements Added**: Enhanced documentation, format
94
- * specifications, validation rules, consistent naming patterns
95
- *
96
- * If no issues were found during review, this contains the exact original
97
- * operations unchanged. These operations are validated and ready for schema
98
- * generation and subsequent implementation phases.
99
- */
100
- content: IOperation[];
101
- }
102
-
103
- /**
104
- * Operation of the Restful API.
105
- *
106
- * This interface defines a single API endpoint with its HTTP {@link method},
107
- * {@link path}, {@link parameters path parameters},
108
- * {@link requestBody request body}, and {@link responseBody} structure. It
109
- * corresponds to an individual operation in the paths section of an OpenAPI
110
- * document.
111
- *
112
- * Each operation requires a detailed explanation of its purpose through the
113
- * reason and description fields, making it clear why the API was designed and
114
- * how it should be used.
115
- *
116
- * All request bodies and responses for this operation must be object types
117
- * and must reference named types defined in the components section. The
118
- * content-type is always `application/json`. For file upload/download
119
- * operations, use `string & tags.Format<"uri">` in the appropriate schema
120
- * instead of binary data formats.
121
- *
122
- * In OpenAPI, this might represent:
123
- *
124
- * ```json
125
- * {
126
- * "/shoppings/customers/orders": {
127
- * "post": {
128
- * "description": "Create a new order application from shopping cart...",
129
- * "parameters": [...],
130
- * "requestBody": {...},
131
- * "responses": {...}
132
- * }
133
- * }
134
- * }
135
- * ```
136
- */
137
- export interface IOperation
138
- extends Omit<AutoBeOpenApi.IOperation, "authorizationType"> {
139
- /**
140
- * Prisma schema models relevant to this operation.
141
- *
142
- * Contains the complete Prisma schema definitions for all entities involved
143
- * in this operation, including their fields, relations, and database
144
- * constraints. This enables comprehensive validation and schema-aware
145
- * operation design.
146
- *
147
- * The schema information serves multiple critical purposes:
148
- *
149
- * - **Field Verification**: Ensures all referenced fields actually exist in
150
- * the database schema and have the correct types
151
- * - **Relationship Validation**: Confirms that entity relationships are
152
- * properly defined and can support the operation's data access patterns
153
- * - **Soft-Delete Detection**: For DELETE operations, identifies whether
154
- * entities have soft-delete fields (deleted_at, is_deleted, etc.) to
155
- * determine if the operation should perform logical deletion instead of
156
- * physical removal
157
- * - **Constraint Awareness**: Understands unique constraints, required
158
- * fields, and default values to generate accurate request/response
159
- * schemas
160
- *
161
- * Example content might include:
162
- *
163
- * ```prisma
164
- * model User {
165
- * id String @id @default(uuid())
166
- * email String @unique
167
- * name String
168
- * deleted_at DateTime? // Indicates soft-delete capability
169
- * posts Post[]
170
- * }
171
- * ```
172
- *
173
- * This schema context ensures operations are fully aligned with the actual
174
- * database structure and business logic requirements.
175
- */
176
- prisma_schemas: string;
177
-
178
- /**
179
- * Primary Prisma model name for this operation.
180
- *
181
- * Identifies the main database table/model that this operation targets.
182
- * This must match exactly with the Prisma model name defined in the schema.
183
- * When soft deletion is specified, this model name indicates which table
184
- * should be soft-deleted.
185
- *
186
- * For example:
187
- * - In a "GET /users/:id" operation, this would be "User"
188
- * - In a "POST /articles" operation, this would be "Article"
189
- * - In a "DELETE /comments/:id" with soft delete, this specifies the "Comment" model to soft-delete
190
- *
191
- * This property is essential for:
192
- * - Determining the primary entity for CRUD operations
193
- * - Identifying which table to apply soft deletion to
194
- * - Validating operations against the correct Prisma model
195
- * - Generating appropriate database queries and validations
196
- */
197
- model_name: string;
198
-
199
- /**
200
- * Soft delete column name for the Prisma models.
201
- *
202
- * Specifies the column name used for soft deletion in the database tables
203
- * associated with this operation. When set to a non-null value, it indicates
204
- * that the related entities support soft deletion through this column
205
- * (typically a timestamp field like `deleted_at` or `deletedAt`).
206
- *
207
- * When null, it means the entities involved in this operation use hard
208
- * deletion or don't support deletion at all. This information is crucial
209
- * for generating appropriate CRUD operations and ensuring data integrity
210
- * policies are correctly implemented.
211
- *
212
- * Common soft delete patterns:
213
- * - `"deleted_at"`: Records deletion timestamp
214
- * - `"deletedAt"`: Camel-cased deletion timestamp
215
- * - `"is_deleted"`: Boolean flag for deletion status
216
- * - `null`: No soft deletion (hard delete only)
217
- */
218
- soft_delete_column: string | null;
219
123
  }
220
124
  }
@@ -29,15 +29,44 @@ export namespace IAutoBeInterfaceSchemasReviewApplication {
29
29
  * interface to understand what outputs are required.
30
30
  */
31
31
  export interface IProps {
32
+ think: IThink;
33
+
34
+ /**
35
+ * Final validated and enhanced schemas ready for production use.
36
+ *
37
+ * DO:
38
+ *
39
+ * - Include valid OpenAPI schema definitions
40
+ * - Include all entities that were in the original input
41
+ * - Provide fixed versions if original schemas have issues
42
+ * - Rename entities correctly if names are wrong
43
+ * - Include created variants if schemas are missing them
44
+ *
45
+ * DO NOT:
46
+ *
47
+ * - Return an empty object {} (this will delete all schemas)
48
+ * - Return undefined or null
49
+ * - Include explanations or excuses in schema descriptions
50
+ * - Leave broken schemas unfixed
51
+ *
52
+ * When original schemas are beyond repair, recreate them properly based on
53
+ * entity names and context. This field becomes the final schemas used by
54
+ * the system, so it must always contain complete, valid schemas.
55
+ */
56
+ content: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>;
57
+ }
58
+
59
+ export interface IThink {
32
60
  /**
33
61
  * Issues and problems found during schema analysis.
34
62
  *
35
- * DO: Document only problems that need fixing.
36
- * DO NOT: Include positive feedback, compliments, or confirmations
63
+ * DO: Document only problems that need fixing. DO NOT: Include positive
64
+ * feedback, compliments, or confirmations
37
65
  *
38
66
  * Focus exclusively on issues organized by severity:
39
67
  *
40
68
  * Severity levels:
69
+ *
41
70
  * - Security vulnerabilities (exposed passwords, missing auth boundaries)
42
71
  * - Missing required variants, incorrect type mappings
43
72
  * - Missing format specifications, incomplete relationships
@@ -63,30 +92,5 @@ export namespace IAutoBeInterfaceSchemasReviewApplication {
63
92
  * field.
64
93
  */
65
94
  plan: string;
66
-
67
- /**
68
- * Final validated and enhanced schemas ready for production use.
69
- *
70
- * DO:
71
- * - Include valid OpenAPI schema definitions
72
- * - Include all entities that were in the original input
73
- * - Provide fixed versions if original schemas have issues
74
- * - Rename entities correctly if names are wrong
75
- * - Include created variants if schemas are missing them
76
- *
77
- * DO NOT:
78
- * - Return an empty object {} (this will delete all schemas)
79
- * - Return undefined or null
80
- * - Include explanations or excuses in schema descriptions
81
- * - Leave broken schemas unfixed
82
- *
83
- * When original schemas are beyond repair, recreate them properly based on
84
- * entity names and context. This field becomes the final schemas used by
85
- * the system, so it must always contain complete, valid schemas.
86
- */
87
- content: Record<
88
- string,
89
- AutoBeOpenApi.IJsonSchemaDescriptive<AutoBeOpenApi.IJsonSchema>
90
- >;
91
95
  }
92
96
  }
@@ -0,0 +1,171 @@
1
+ import { AutoBeOpenApi } from "@autobe/interface";
2
+ import { AutoBeOpenApiTypeChecker, StringUtil } from "@autobe/utils";
3
+ import typia, { tags } from "typia";
4
+
5
+ export namespace JsonSchemaFactory {
6
+ export const presets = (
7
+ typeNames: Set<string>,
8
+ ): Record<string, AutoBeOpenApi.IJsonSchemaDescriptive> => {
9
+ const schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive> = {};
10
+ for (const [key, value] of Object.entries(DEFAULT_SCHEMAS)) {
11
+ schemas[key] = value;
12
+ typeNames.delete(key);
13
+ }
14
+ for (const key of typeNames)
15
+ if (isPage(key)) {
16
+ const data: string = getPageName(key);
17
+ schemas[key] = page(data);
18
+ typeNames.delete(key);
19
+ typeNames.add(data);
20
+ }
21
+ return schemas;
22
+ };
23
+
24
+ export const authorize = (
25
+ schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>,
26
+ ): void => {
27
+ for (const [key, value] of Object.entries(schemas)) {
28
+ if (key.endsWith(".IAuthorized") === false) continue;
29
+ else if (AutoBeOpenApiTypeChecker.isObject(value) === false) continue;
30
+
31
+ const parent: AutoBeOpenApi.IJsonSchemaDescriptive | undefined =
32
+ schemas[key.substring(0, key.length - ".IAuthorized".length)];
33
+ if (parent === undefined) continue;
34
+ else if (AutoBeOpenApiTypeChecker.isObject(parent) === false) continue;
35
+
36
+ value.properties = {
37
+ ...parent.properties,
38
+ ...value.properties,
39
+ };
40
+ value.required = [...parent.required];
41
+ if (value.required.includes("id") === false) value.required.push("id");
42
+ if (value.required.includes("token") === false)
43
+ value.required.push("token");
44
+ }
45
+ };
46
+
47
+ export const page = (
48
+ key: string,
49
+ ): AutoBeOpenApi.IJsonSchemaDescriptive.IObject => ({
50
+ type: "object",
51
+ properties: {
52
+ pagination: {
53
+ $ref: "#/components/schemas/IPage.IPagination",
54
+ description: "Page information.",
55
+ },
56
+ data: {
57
+ type: "array",
58
+ items: {
59
+ $ref: `#/components/schemas/${key}`,
60
+ },
61
+ description: "List of records.",
62
+ },
63
+ },
64
+ required: ["pagination", "data"],
65
+ description: StringUtil.trim`
66
+ A page.
67
+
68
+ Collection of records with pagination information.
69
+ `,
70
+ });
71
+
72
+ export const fix = (path: string, input: unknown): void => {
73
+ if (isRecord(input) === false || isRecord(input[path]) === false) return;
74
+
75
+ if (input[path].description) delete input[path].description;
76
+ if (input[path].required) delete input[path].required;
77
+
78
+ for (const key of Object.keys(input[path]))
79
+ if (DEFAULT_SCHEMAS[key] !== undefined)
80
+ input[path][key] = DEFAULT_SCHEMAS[key];
81
+ else if (isPage(key) === true) {
82
+ const data: string = key.substring("IPage".length);
83
+ input[path][key] = page(data);
84
+ }
85
+ };
86
+
87
+ export const isPage = (key: string): boolean =>
88
+ key.startsWith("IPage") === true &&
89
+ key.startsWith("IPage.") === false &&
90
+ key !== "IPage";
91
+
92
+ export const getPageName = (key: string): string =>
93
+ key.substring("IPage".length);
94
+
95
+ const isRecord = (input: unknown): input is Record<string, unknown> =>
96
+ typeof input === "object" && input !== null;
97
+ }
98
+
99
+ const DEFAULT_SCHEMAS = typia.assertEquals<
100
+ Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>
101
+ >(
102
+ typia.json.schemas<[IPage.IPagination, IAuthorizationToken]>().components
103
+ ?.schemas,
104
+ );
105
+
106
+ namespace IPage {
107
+ /** Page information. */
108
+ export interface IPagination {
109
+ /** Current page number. */
110
+ current: number & tags.Type<"uint32">;
111
+
112
+ /** Limitation of records per a page. */
113
+ limit: number & tags.Type<"uint32">;
114
+
115
+ /** Total records in the database. */
116
+ records: number & tags.Type<"uint32">;
117
+
118
+ /**
119
+ * Total pages.
120
+ *
121
+ * Equal to {@link records} / {@link limit} with ceiling.
122
+ */
123
+ pages: number & tags.Type<"uint32">;
124
+ }
125
+ }
126
+
127
+ /**
128
+ * Authorization token response structure.
129
+ *
130
+ * This interface defines the structure of the authorization token response
131
+ * returned after successful user authentication. It contains both access and
132
+ * refresh tokens along with their expiration information.
133
+ *
134
+ * This token structure is automatically included in API schemas when the system
135
+ * detects authorization roles in the requirements analysis phase. It provides a
136
+ * standard format for JWT-based authentication across the generated backend
137
+ * applications.
138
+ */
139
+ interface IAuthorizationToken {
140
+ /**
141
+ * JWT access token for authenticated requests.
142
+ *
143
+ * This token should be included in the Authorization header for subsequent
144
+ * authenticated API requests as `Bearer {token}`.
145
+ */
146
+ access: string;
147
+
148
+ /**
149
+ * Refresh token for obtaining new access tokens.
150
+ *
151
+ * This token can be used to request new access tokens when the current access
152
+ * token expires, extending the user's session.
153
+ */
154
+ refresh: string;
155
+
156
+ /**
157
+ * Access token expiration timestamp.
158
+ *
159
+ * ISO 8601 date-time string indicating when the access token will expire and
160
+ * can no longer be used for authentication.
161
+ */
162
+ expired_at: string & tags.Format<"date-time">;
163
+
164
+ /**
165
+ * Refresh token expiration timestamp.
166
+ *
167
+ * ISO 8601 date-time string indicating the latest time until which the
168
+ * refresh token can be used to obtain new access tokens.
169
+ */
170
+ refreshable_until: string & tags.Format<"date-time">;
171
+ }
@@ -0,0 +1,83 @@
1
+ import { AutoBeOpenApi } from "@autobe/interface";
2
+ import { MapUtil } from "@autobe/utils";
3
+ import { OpenApiTypeChecker } from "@samchon/openapi";
4
+
5
+ export namespace JsonSchemaNamingConvention {
6
+ export const operations = (operations: AutoBeOpenApi.IOperation[]): void => {
7
+ const typeNames: Set<string> = new Set();
8
+ operate(typeNames, operations);
9
+ };
10
+
11
+ export const schemas = (
12
+ operations: AutoBeOpenApi.IOperation[],
13
+ ...componentSchemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>[]
14
+ ): void => {
15
+ const typeNames: Set<string> = new Set();
16
+ for (const schemas of componentSchemas)
17
+ for (const key of Object.keys(schemas)) typeNames.add(key);
18
+ const answer = operate(typeNames, operations);
19
+
20
+ for (const dict of componentSchemas)
21
+ for (const x of Object.keys(dict)) {
22
+ const y: string = answer(x);
23
+ if (x === y) continue;
24
+ dict[y] = dict[x]!;
25
+ delete dict[x];
26
+ }
27
+ for (const dict of componentSchemas)
28
+ for (const x of Object.values(dict)) {
29
+ OpenApiTypeChecker.visit({
30
+ components: { schemas: dict },
31
+ schema: x,
32
+ closure: (s) => {
33
+ if (OpenApiTypeChecker.isReference(s) === false) return;
34
+ s.$ref = `#/components/schemas/${answer(s.$ref.split("/").pop()!)}`;
35
+ },
36
+ });
37
+ }
38
+ };
39
+
40
+ const operate = (
41
+ typeNames: Set<string>,
42
+ operations: AutoBeOpenApi.IOperation[],
43
+ ): ((v: string) => string) => {
44
+ for (const op of operations) {
45
+ if (op.requestBody) typeNames.add(op.requestBody.typeName);
46
+ if (op.responseBody) typeNames.add(op.responseBody.typeName);
47
+ }
48
+ const answer = prepare(typeNames);
49
+ for (const op of operations) {
50
+ if (op.requestBody)
51
+ op.requestBody.typeName = answer(op.requestBody.typeName);
52
+ if (op.responseBody)
53
+ op.responseBody.typeName = answer(op.responseBody.typeName);
54
+ }
55
+ return answer;
56
+ };
57
+
58
+ const prepare = (typeNames: Set<string>): ((v: string) => string) => {
59
+ const similar: Map<string, string[]> = new Map();
60
+ const getKey = (v: string) => v.split(".")[0]!.toLowerCase();
61
+ const getValue = (v: string) => v.split(".")[0]!;
62
+ const emplace = (v: string) =>
63
+ MapUtil.take(similar, getKey(v), () => []).push(getValue(v));
64
+
65
+ for (const v of typeNames) emplace(v);
66
+
67
+ const solution: Map<string, string> = new Map();
68
+ for (const [key, values] of similar) {
69
+ if (values.length === 1) continue;
70
+ const winner: string = values.sort(
71
+ (a, b) => countCapitalLetters(b) - countCapitalLetters(a),
72
+ )[0]!;
73
+ solution.set(key, winner);
74
+ }
75
+ return (v: string) => {
76
+ const key: string = getKey(v);
77
+ if (solution.has(key) === false) return v;
78
+ return [solution.get(key), ...v.split(".").slice(1)].join(".");
79
+ };
80
+ };
81
+ }
82
+
83
+ const countCapitalLetters = (str: string) => (str.match(/[A-Z]/g) || []).length;
@@ -0,0 +1,90 @@
1
+ import { StringUtil } from "@autobe/utils";
2
+ import { IValidation } from "typia";
3
+
4
+ export const fulfillJsonSchemaErrorMessages = (
5
+ errors: IValidation.IError[],
6
+ ): void => {
7
+ for (const e of errors)
8
+ if (
9
+ // type := ["number", "string", ...] case
10
+ isInvalidJsonSchema(e) &&
11
+ typeof e.value === "object" &&
12
+ e.value !== null &&
13
+ "type" in e.value &&
14
+ Array.isArray(e.value.type)
15
+ )
16
+ e.description = StringUtil.trim`
17
+ You have defined the JSON schema's type property value as an
18
+ array type listing up the every types what you want, but it is not
19
+ allowed in the JSON schema.
20
+
21
+ The JSON schema's type property value must be a single string type.
22
+ In your case, you have to change it to an "oneOf" type which
23
+ represents an union type.
24
+
25
+ So, please change the value as below:
26
+
27
+ \`\`\`
28
+ {
29
+ oneOf: [
30
+ ${e.value.type.map((t) => ` { "type": ${JSON.stringify(t)}, ... },`).join("\n")}
31
+ ],${"description" in e.value ? `\n description: ${JSON.stringify(e.value.description)},` : ""}
32
+ }
33
+ \`\`\`
34
+ `;
35
+ else if (
36
+ isInvalidJsonSchema(e) &&
37
+ typeof e.value === "object" &&
38
+ e.value !== null &&
39
+ "enum" in e.value &&
40
+ Array.isArray(e.value.enum)
41
+ )
42
+ e.description = StringUtil.trim`
43
+ You have defined only enum property, but it is not allowed in the
44
+ JSON schema. You have to define it as oneOf type containing multiple
45
+ const types like below:
46
+
47
+ \`\`\`
48
+ {
49
+ oneOf: [
50
+ ${e.value.enum.map((t) => ` { "const": ${JSON.stringify(t)} },`).join("\n")}
51
+ ],${"description" in e.value ? `\n description: ${JSON.stringify(e.value.description)},` : ""}
52
+ }
53
+ \`\`\`
54
+ `;
55
+ else if (e.value === undefined && e.path.endsWith(".description"))
56
+ // no description
57
+ e.description = StringUtil.trim`
58
+ You have missed the "description" property in the JSON schema.
59
+
60
+ Please fill it with detailed description about the type.
61
+ `;
62
+ else if (
63
+ e.value === undefined &&
64
+ e.path.endsWith(".required") &&
65
+ e.expected === "Array<string>"
66
+ )
67
+ e.description = StringUtil.trim`
68
+ You have missed the "required" property in the JSON schema of object type.
69
+
70
+ When defining the object type, you have to fill the "required" property
71
+ which lists up the every required property names.
72
+
73
+ Please fill it with the required fields. If you think that there is
74
+ not any required fields at all, you still have to fill the
75
+ "required" property even though it becomes an empty array.
76
+ `;
77
+ };
78
+
79
+ const isInvalidJsonSchema = (e: IValidation.IError): boolean =>
80
+ e.expected.startsWith("(") &&
81
+ e.expected.endsWith(")") &&
82
+ e.expected.includes("|") &&
83
+ e.expected
84
+ .split("|")
85
+ .map((s) => s.trim())
86
+ .every(
87
+ (s) =>
88
+ s.startsWith("AutoBeOpenApi.IJsonSchema.") ||
89
+ s.startsWith("AutoBeOpenApi.IJsonSchemaDescriptive."),
90
+ );
@@ -25,7 +25,7 @@ export const validateAuthorizationSchema = (props: {
25
25
  value.properties["token"] = {
26
26
  $ref: "#/components/schemas/IAuthorizationToken",
27
27
  description: "JWT token information for authentication",
28
- } as AutoBeOpenApi.IJsonSchemaDescriptive<AutoBeOpenApi.IJsonSchema.IReference>;
28
+ } as AutoBeOpenApi.IJsonSchemaDescriptive.IReference;
29
29
 
30
30
  value.required ??= [];
31
31
  if (value.required.includes("token") === false) {
@@ -36,6 +36,6 @@ export const validateAuthorizationSchema = (props: {
36
36
 
37
37
  const isObjectSchema = (
38
38
  schema: AutoBeOpenApi.IJsonSchemaDescriptive,
39
- ): schema is AutoBeOpenApi.IJsonSchemaDescriptive<AutoBeOpenApi.IJsonSchema.IObject> => {
39
+ ): schema is AutoBeOpenApi.IJsonSchemaDescriptive.IObject => {
40
40
  return "type" in schema && schema.type === "object";
41
41
  };
@@ -18,7 +18,6 @@ import { IAutoBePrismaCorrectApplication } from "./structures/IAutoBePrismaCorre
18
18
  export function orchestratePrismaCorrect<Model extends ILlmSchema.Model>(
19
19
  ctx: AutoBeContext<Model>,
20
20
  application: AutoBePrisma.IApplication,
21
- life: number = 4,
22
21
  ): Promise<IAutoBePrismaValidation> {
23
22
  const unique: Set<string> = new Set();
24
23
  for (const file of application.files)
@@ -28,7 +27,7 @@ export function orchestratePrismaCorrect<Model extends ILlmSchema.Model>(
28
27
  return true;
29
28
  });
30
29
  application.files = application.files.filter((f) => f.models.length !== 0);
31
- return iterate(ctx, application, life);
30
+ return iterate(ctx, application, ctx.retry);
32
31
  }
33
32
 
34
33
  async function iterate<Model extends ILlmSchema.Model>(