@autobe/agent 0.30.0-dev.20260315 → 0.30.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 (466) hide show
  1. package/LICENSE +661 -661
  2. package/lib/constants/AutoBeTemplateFileConstant.d.ts +1 -1
  3. package/lib/factory/consentFunctionCall.js +4 -4
  4. package/lib/factory/createAutoBeContext.js +24 -24
  5. package/lib/factory/createAutoBeMessageContent.js +6 -6
  6. package/lib/index.mjs +41 -41
  7. package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistory.js +18 -18
  8. package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioReviewHistory.js +13 -13
  9. package/lib/orchestrate/analyze/histories/transformAnalyzeSectionCrossFileReviewHistory.js +47 -47
  10. package/lib/orchestrate/analyze/histories/transformAnalyzeSectionReviewHistory.js +66 -66
  11. package/lib/orchestrate/analyze/histories/transformAnalyzeWriteSectionHistory.js +91 -91
  12. package/lib/orchestrate/analyze/histories/transformAnalyzeWriteSectionPatchHistory.js +46 -46
  13. package/lib/orchestrate/analyze/histories/transformAnalyzeWriteUnitHistory.js +72 -72
  14. package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.js +1 -1
  15. package/lib/orchestrate/analyze/orchestrateAnalyzeSectionCrossFileReview.js +1 -1
  16. package/lib/orchestrate/analyze/orchestrateAnalyzeSectionReview.js +1 -1
  17. package/lib/orchestrate/analyze/orchestrateAnalyzeWriteSection.js +1 -1
  18. package/lib/orchestrate/analyze/orchestrateAnalyzeWriteSectionPatch.js +1 -1
  19. package/lib/orchestrate/analyze/orchestrateAnalyzeWriteUnit.js +1 -1
  20. package/lib/orchestrate/common/histories/transformCommonCorrectCastingHistory.js +5 -5
  21. package/lib/orchestrate/common/histories/transformPreliminaryHistory.js +44 -44
  22. package/lib/orchestrate/common/histories/transformPreviousAndLatestCorrectHistory.js +44 -44
  23. package/lib/orchestrate/common/internal/fixPrelminaryApplication.js +22 -22
  24. package/lib/orchestrate/common/internal/validatePreliminary.js +116 -116
  25. package/lib/orchestrate/facade/createAutoBeFacadeController.js +3 -3
  26. package/lib/orchestrate/facade/structures/transformFacadeStateMessage.js +20 -20
  27. package/lib/orchestrate/interface/histories/transformInterfaceActionEndpointReviewHistory.js +34 -34
  28. package/lib/orchestrate/interface/histories/transformInterfaceActionEndpointWriteHistory.js +37 -37
  29. package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationHistory.js +56 -56
  30. package/lib/orchestrate/interface/histories/transformInterfaceBaseEndpointReviewHistory.js +26 -26
  31. package/lib/orchestrate/interface/histories/transformInterfaceBaseEndpointWriteHistory.js +28 -28
  32. package/lib/orchestrate/interface/histories/transformInterfaceEndpointAuthorizationSection.js +11 -11
  33. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistory.js +38 -38
  34. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistory.js +29 -29
  35. package/lib/orchestrate/interface/histories/transformInterfaceOperationParameterHistory.js +15 -15
  36. package/lib/orchestrate/interface/histories/transformInterfaceOperationReviewHistory.js +6 -6
  37. package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistory.js +25 -25
  38. package/lib/orchestrate/interface/histories/transformInterfaceSchemaCastingHistory.js +67 -67
  39. package/lib/orchestrate/interface/histories/transformInterfaceSchemaComplementHistory.js +60 -60
  40. package/lib/orchestrate/interface/histories/transformInterfaceSchemaRefineHistory.js +83 -83
  41. package/lib/orchestrate/interface/histories/transformInterfaceSchemaRenameHistory.js +29 -29
  42. package/lib/orchestrate/interface/histories/transformInterfaceSchemaReviewHistory.js +74 -74
  43. package/lib/orchestrate/interface/histories/transformInterfaceSchemaWriteHistory.js +46 -46
  44. package/lib/orchestrate/interface/orchestrateInterfaceAuthorization.js +1 -1
  45. package/lib/orchestrate/interface/orchestrateInterfaceEndpointReview.js +1 -1
  46. package/lib/orchestrate/interface/orchestrateInterfaceEndpointWrite.js +1 -1
  47. package/lib/orchestrate/interface/orchestrateInterfaceGroup.js +9 -9
  48. package/lib/orchestrate/interface/orchestrateInterfaceOperation.js +1 -1
  49. package/lib/orchestrate/interface/orchestrateInterfaceOperationReview.js +1 -1
  50. package/lib/orchestrate/interface/orchestrateInterfacePrerequisite.js +4 -4
  51. package/lib/orchestrate/interface/orchestrateInterfaceSchemaCasting.js +1 -1
  52. package/lib/orchestrate/interface/orchestrateInterfaceSchemaComplement.js +5 -5
  53. package/lib/orchestrate/interface/orchestrateInterfaceSchemaRefine.js +1 -1
  54. package/lib/orchestrate/interface/orchestrateInterfaceSchemaReview.js +1 -1
  55. package/lib/orchestrate/interface/orchestrateInterfaceSchemaWrite.js +1 -1
  56. package/lib/orchestrate/interface/programmers/AutoBeInterfaceAuthorizationProgrammer.js +90 -90
  57. package/lib/orchestrate/interface/programmers/AutoBeInterfaceEndpointProgrammer.js +6 -6
  58. package/lib/orchestrate/interface/programmers/AutoBeInterfaceEndpointReviewProgrammer.js +25 -25
  59. package/lib/orchestrate/interface/programmers/AutoBeInterfaceOperationProgrammer.js +71 -71
  60. package/lib/orchestrate/interface/programmers/AutoBeInterfacePrerequisiteProgrammer.js +162 -162
  61. package/lib/orchestrate/interface/programmers/AutoBeInterfaceSchemaProgrammer.js +11 -11
  62. package/lib/orchestrate/interface/programmers/AutoBeInterfaceSchemaPropertyReviseProgrammer.js +73 -73
  63. package/lib/orchestrate/interface/programmers/AutoBeInterfaceSchemaRefineProgrammer.js +35 -35
  64. package/lib/orchestrate/interface/programmers/AutoBeInterfaceSchemaReviewProgrammer.js +11 -11
  65. package/lib/orchestrate/interface/utils/AutoBeJsonSchemaFactory.js +4 -4
  66. package/lib/orchestrate/interface/utils/AutoBeJsonSchemaValidator.js +283 -283
  67. package/lib/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.js +76 -76
  68. package/lib/orchestrate/prisma/histories/transformPrismaAuthorizationHistory.js +76 -76
  69. package/lib/orchestrate/prisma/histories/transformPrismaAuthorizationReviewHistory.js +51 -51
  70. package/lib/orchestrate/prisma/histories/transformPrismaComponentReviewHistory.js +54 -54
  71. package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistory.js +83 -83
  72. package/lib/orchestrate/prisma/histories/transformPrismaCorrectHistory.js +6 -6
  73. package/lib/orchestrate/prisma/histories/transformPrismaGroupHistory.js +22 -22
  74. package/lib/orchestrate/prisma/histories/transformPrismaGroupReviewHistory.js +41 -41
  75. package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistory.js +39 -39
  76. package/lib/orchestrate/prisma/histories/transformPrismaSchemaReviewHistory.js +41 -41
  77. package/lib/orchestrate/prisma/orchestratePrismaAuthorization.js +1 -1
  78. package/lib/orchestrate/prisma/orchestratePrismaAuthorizationReview.js +1 -1
  79. package/lib/orchestrate/prisma/orchestratePrismaComponent.js +1 -1
  80. package/lib/orchestrate/prisma/orchestratePrismaComponentReview.js +1 -1
  81. package/lib/orchestrate/prisma/orchestratePrismaCorrect.js +1 -1
  82. package/lib/orchestrate/prisma/orchestratePrismaGroup.js +1 -1
  83. package/lib/orchestrate/prisma/orchestratePrismaGroupReview.js +1 -1
  84. package/lib/orchestrate/prisma/orchestratePrismaSchema.js +1 -1
  85. package/lib/orchestrate/prisma/orchestratePrismaSchemaReview.js +1 -1
  86. package/lib/orchestrate/prisma/programmers/AutoBeDatabaseAuthorizationProgrammer.js +23 -23
  87. package/lib/orchestrate/prisma/programmers/AutoBeDatabaseAuthorizationReviewProgrammer.js +7 -7
  88. package/lib/orchestrate/prisma/programmers/AutoBeDatabaseComponentProgrammer.js +5 -5
  89. package/lib/orchestrate/prisma/programmers/AutoBeDatabaseComponentReviewProgrammer.js +20 -20
  90. package/lib/orchestrate/prisma/programmers/AutoBeDatabaseGroupProgrammer.js +13 -13
  91. package/lib/orchestrate/prisma/programmers/AutoBeDatabaseGroupReviewProgrammer.js +51 -51
  92. package/lib/orchestrate/prisma/programmers/AutoBeDatabaseSchemaProgrammer.js +25 -25
  93. package/lib/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistory.js +28 -28
  94. package/lib/orchestrate/realize/histories/transformRealizeAuthorizationWriteHistory.js +14 -14
  95. package/lib/orchestrate/realize/histories/transformRealizeCollectorCorrectHistory.js +42 -42
  96. package/lib/orchestrate/realize/histories/transformRealizeCollectorPlanHistory.js +27 -27
  97. package/lib/orchestrate/realize/histories/transformRealizeCollectorWriteHistory.js +57 -57
  98. package/lib/orchestrate/realize/histories/transformRealizeCorrectCastingHistory.js +35 -35
  99. package/lib/orchestrate/realize/histories/transformRealizeOperationCorrectHistory.js +14 -14
  100. package/lib/orchestrate/realize/histories/transformRealizeOperationWriteHistory.js +37 -37
  101. package/lib/orchestrate/realize/histories/transformRealizeOperationWriteHistory.js.map +1 -1
  102. package/lib/orchestrate/realize/histories/transformRealizeTransformerCorrectHistory.js +47 -47
  103. package/lib/orchestrate/realize/histories/transformRealizeTransformerPlanHistory.js +27 -27
  104. package/lib/orchestrate/realize/histories/transformRealizeTransformerWriteHistory.js +51 -51
  105. package/lib/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js +1 -1
  106. package/lib/orchestrate/realize/orchestrateRealizeAuthorizationWrite.js +1 -1
  107. package/lib/orchestrate/realize/orchestrateRealizeCollectorCorrectOverall.js +1 -1
  108. package/lib/orchestrate/realize/orchestrateRealizeCollectorPlan.js +11 -11
  109. package/lib/orchestrate/realize/orchestrateRealizeCollectorWrite.js +1 -1
  110. package/lib/orchestrate/realize/orchestrateRealizeOperationCorrectOverall.js +1 -1
  111. package/lib/orchestrate/realize/orchestrateRealizeOperationWrite.js +1 -1
  112. package/lib/orchestrate/realize/orchestrateRealizeTransformerCorrectOverall.js +1 -1
  113. package/lib/orchestrate/realize/orchestrateRealizeTransformerPlan.js +11 -11
  114. package/lib/orchestrate/realize/orchestrateRealizeTransformerWrite.js +1 -1
  115. package/lib/orchestrate/realize/programmers/AutoBeRealizeCollectorProgrammer.js +41 -41
  116. package/lib/orchestrate/realize/programmers/AutoBeRealizeOperationProgrammer.js +21 -21
  117. package/lib/orchestrate/realize/programmers/AutoBeRealizeTransformerProgrammer.js +57 -57
  118. package/lib/orchestrate/realize/utils/getRealizeWriteInputType.js +3 -3
  119. package/lib/orchestrate/realize/utils/printErrorHints.js +5 -5
  120. package/lib/orchestrate/test/compile/getTestImportStatements.js +9 -9
  121. package/lib/orchestrate/test/histories/transformTestAuthorizeWriteHistory.js +38 -38
  122. package/lib/orchestrate/test/histories/transformTestGenerationWriteHistory.js +79 -79
  123. package/lib/orchestrate/test/histories/transformTestOperationWriteHistory.js +162 -162
  124. package/lib/orchestrate/test/histories/transformTestPrepareWriteHistory.js +54 -54
  125. package/lib/orchestrate/test/histories/transformTestScenarioHistory.js +31 -31
  126. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistory.js +27 -27
  127. package/lib/orchestrate/test/orchestrateTestScenario.js +1 -1
  128. package/lib/orchestrate/test/orchestrateTestScenarioReview.js +1 -1
  129. package/lib/orchestrate/test/programmers/AutoBeTestAuthorizeProgrammer.js +31 -31
  130. package/lib/orchestrate/test/programmers/AutoBeTestGenerateProgrammer.js +23 -23
  131. package/lib/orchestrate/test/programmers/AutoBeTestOperationProgrammer.js +6 -6
  132. package/lib/orchestrate/test/programmers/AutoBeTestPrepareProgrammer.js +34 -34
  133. package/lib/orchestrate/test/programmers/AutoBeTestScenarioProgrammer.js +39 -39
  134. package/lib/utils/predicateStateMessage.js +19 -19
  135. package/lib/utils/validateEmptyCode.js +16 -16
  136. package/package.json +5 -5
  137. package/src/AutoBeAgent.ts +374 -374
  138. package/src/AutoBeAgentBase.ts +126 -126
  139. package/src/AutoBeMockAgent.ts +254 -254
  140. package/src/constants/AutoBeConfigConstant.ts +173 -173
  141. package/src/constants/AutoBeTemplateFileConstant.ts +1 -1
  142. package/src/context/AutoBeContext.ts +107 -107
  143. package/src/context/AutoBeState.ts +66 -66
  144. package/src/context/AutoBeTokenUsage.ts +307 -307
  145. package/src/context/AutoBeTokenUsageComponent.ts +227 -227
  146. package/src/describe/describe.ts +47 -47
  147. package/src/describe/image/histories/transformImageDescribeDraftHistories.ts +16 -16
  148. package/src/describe/image/orchestrateImageDescribeDraft.ts +200 -200
  149. package/src/describe/image/structures/IAutoBeImageDescribeDraftApplication.ts +92 -92
  150. package/src/describe/imageDescribe.ts +64 -64
  151. package/src/factory/consentFunctionCall.ts +141 -141
  152. package/src/factory/createAgenticaHistory.ts +71 -71
  153. package/src/factory/createAutoBeContext.ts +584 -584
  154. package/src/factory/createAutoBeMessageContent.ts +36 -36
  155. package/src/factory/createAutoBeState.ts +20 -20
  156. package/src/factory/getAutoBeGenerated.ts +317 -317
  157. package/src/factory/getAutoBeRealizeGenerated.ts +31 -31
  158. package/src/factory/getCriticalCompiler.ts +52 -52
  159. package/src/factory/index.ts +1 -1
  160. package/src/factory/mergeSystemMessages.ts +60 -60
  161. package/src/factory/supportFunctionCallFallback.ts +214 -214
  162. package/src/factory/supportMistral.ts +138 -138
  163. package/src/index.ts +16 -16
  164. package/src/orchestrate/analyze/fillTocDeterministic.ts +280 -280
  165. package/src/orchestrate/analyze/histories/transformAnalyzeScenarioHistory.ts +55 -55
  166. package/src/orchestrate/analyze/histories/transformAnalyzeScenarioReviewHistory.ts +74 -74
  167. package/src/orchestrate/analyze/histories/transformAnalyzeSectionCrossFileReviewHistory.ts +179 -179
  168. package/src/orchestrate/analyze/histories/transformAnalyzeSectionReviewHistory.ts +163 -163
  169. package/src/orchestrate/analyze/histories/transformAnalyzeWriteSectionHistory.ts +191 -191
  170. package/src/orchestrate/analyze/histories/transformAnalyzeWriteSectionPatchHistory.ts +122 -122
  171. package/src/orchestrate/analyze/histories/transformAnalyzeWriteUnitHistory.ts +161 -161
  172. package/src/orchestrate/analyze/index.ts +7 -7
  173. package/src/orchestrate/analyze/orchestrateAnalyze.ts +1693 -1693
  174. package/src/orchestrate/analyze/orchestrateAnalyzeScenario.ts +267 -267
  175. package/src/orchestrate/analyze/orchestrateAnalyzeScenarioReview.ts +122 -122
  176. package/src/orchestrate/analyze/orchestrateAnalyzeSectionCrossFileReview.ts +146 -146
  177. package/src/orchestrate/analyze/orchestrateAnalyzeSectionReview.ts +154 -154
  178. package/src/orchestrate/analyze/orchestrateAnalyzeWriteSection.ts +388 -388
  179. package/src/orchestrate/analyze/orchestrateAnalyzeWriteSectionPatch.ts +407 -407
  180. package/src/orchestrate/analyze/orchestrateAnalyzeWriteUnit.ts +348 -348
  181. package/src/orchestrate/analyze/programmers/AutoBeAnalyzeProgrammer.ts +149 -149
  182. package/src/orchestrate/analyze/structures/FixedAnalyzeTemplate.ts +961 -961
  183. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeScenarioApplication.ts +141 -141
  184. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeScenarioReviewApplication.ts +96 -96
  185. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeSectionCrossFileReviewApplication.ts +160 -160
  186. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeSectionReviewApplication.ts +192 -192
  187. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeWriteSectionApplication.ts +142 -142
  188. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeWriteUnitApplication.ts +123 -123
  189. package/src/orchestrate/analyze/utils/buildConstraintConsistencyReport.ts +813 -813
  190. package/src/orchestrate/analyze/utils/buildErrorCodeRegistry.ts +324 -324
  191. package/src/orchestrate/analyze/utils/buildHardValidators.ts +88 -88
  192. package/src/orchestrate/analyze/utils/detectInventedEntities.ts +87 -87
  193. package/src/orchestrate/analyze/utils/detectProseConstraintConflicts.ts +319 -319
  194. package/src/orchestrate/analyze/utils/repairSectionReviewUtils.ts +181 -181
  195. package/src/orchestrate/analyze/utils/repairUtils.ts +60 -60
  196. package/src/orchestrate/analyze/utils/validateScenarioBasics.ts +104 -104
  197. package/src/orchestrate/common/AutoBePreliminaryController.ts +400 -400
  198. package/src/orchestrate/common/histories/transformCommonCorrectCastingHistory.ts +32 -32
  199. package/src/orchestrate/common/histories/transformPreliminaryHistory.ts +742 -742
  200. package/src/orchestrate/common/histories/transformPreviousAndLatestCorrectHistory.ts +77 -77
  201. package/src/orchestrate/common/internal/complementPreliminaryCollection.ts +263 -263
  202. package/src/orchestrate/common/internal/convertToSectionEntries.ts +57 -57
  203. package/src/orchestrate/common/internal/createPreliminaryCollection.ts +76 -76
  204. package/src/orchestrate/common/internal/fixPrelminaryApplication.ts +346 -346
  205. package/src/orchestrate/common/internal/validatePreliminary.ts +671 -671
  206. package/src/orchestrate/common/orchestrateCommonCorrectCasting.ts +223 -223
  207. package/src/orchestrate/common/orchestratePreliminary.ts +610 -610
  208. package/src/orchestrate/common/structures/AutoBePreliminaryRequest.ts +42 -42
  209. package/src/orchestrate/common/structures/IAnalysisSectionEntry.ts +35 -35
  210. package/src/orchestrate/common/structures/IAutoBeCommonCorrectCastingApplication.ts +72 -72
  211. package/src/orchestrate/common/structures/IAutoBeOrchestrateResult.ts +28 -28
  212. package/src/orchestrate/common/structures/IAutoBePreliminaryCollection.ts +52 -52
  213. package/src/orchestrate/common/structures/IAutoBePreliminaryGetAnalysisSections.ts +34 -34
  214. package/src/orchestrate/common/structures/IAutoBePreliminaryGetDatabaseSchemas.ts +31 -31
  215. package/src/orchestrate/common/structures/IAutoBePreliminaryGetInterfaceOperations.ts +32 -32
  216. package/src/orchestrate/common/structures/IAutoBePreliminaryGetInterfaceSchemas.ts +31 -31
  217. package/src/orchestrate/common/structures/IAutoBePreliminaryGetPreviousAnalysisSections.ts +28 -28
  218. package/src/orchestrate/common/structures/IAutoBePreliminaryGetPreviousDatabaseSchemas.ts +88 -88
  219. package/src/orchestrate/common/structures/IAutoBePreliminaryGetPreviousInterfaceOperations.ts +102 -102
  220. package/src/orchestrate/common/structures/IAutoBePreliminaryGetPreviousInterfaceSchemas.ts +105 -105
  221. package/src/orchestrate/common/structures/IAutoBePreliminaryGetRealizeCollectors.ts +32 -32
  222. package/src/orchestrate/common/structures/IAutoBePreliminaryGetRealizeTransformers.ts +32 -32
  223. package/src/orchestrate/facade/createAutoBeFacadeController.ts +118 -118
  224. package/src/orchestrate/facade/histories/IAutoBeFacadeApplication.ts +139 -139
  225. package/src/orchestrate/facade/histories/IAutoBeFacadeApplicationProps.ts +8 -8
  226. package/src/orchestrate/facade/histories/IAutoBeFacadeApplicationResult.ts +9 -9
  227. package/src/orchestrate/facade/structures/transformFacadeStateMessage.ts +59 -59
  228. package/src/orchestrate/index.ts +5 -5
  229. package/src/orchestrate/interface/histories/transformInterfaceActionEndpointReviewHistory.ts +83 -83
  230. package/src/orchestrate/interface/histories/transformInterfaceActionEndpointWriteHistory.ts +78 -78
  231. package/src/orchestrate/interface/histories/transformInterfaceAuthorizationHistory.ts +129 -129
  232. package/src/orchestrate/interface/histories/transformInterfaceBaseEndpointReviewHistory.ts +74 -74
  233. package/src/orchestrate/interface/histories/transformInterfaceBaseEndpointWriteHistory.ts +68 -68
  234. package/src/orchestrate/interface/histories/transformInterfaceCommonHistory.ts +64 -64
  235. package/src/orchestrate/interface/histories/transformInterfaceEndpointAuthorizationSection.ts +42 -42
  236. package/src/orchestrate/interface/histories/transformInterfaceGroupHistory.ts +103 -103
  237. package/src/orchestrate/interface/histories/transformInterfaceOperationHistory.ts +81 -81
  238. package/src/orchestrate/interface/histories/transformInterfaceOperationParameterHistory.ts +53 -53
  239. package/src/orchestrate/interface/histories/transformInterfaceOperationReviewHistory.ts +49 -49
  240. package/src/orchestrate/interface/histories/transformInterfacePrerequisiteHistory.ts +94 -94
  241. package/src/orchestrate/interface/histories/transformInterfaceSchemaCastingHistory.ts +122 -122
  242. package/src/orchestrate/interface/histories/transformInterfaceSchemaComplementHistory.ts +192 -192
  243. package/src/orchestrate/interface/histories/transformInterfaceSchemaRefineHistory.ts +189 -189
  244. package/src/orchestrate/interface/histories/transformInterfaceSchemaRenameHistory.ts +63 -63
  245. package/src/orchestrate/interface/histories/transformInterfaceSchemaReviewHistory.ts +173 -173
  246. package/src/orchestrate/interface/histories/transformInterfaceSchemaWriteHistory.ts +88 -88
  247. package/src/orchestrate/interface/index.ts +6 -6
  248. package/src/orchestrate/interface/orchestrateInterface.ts +118 -118
  249. package/src/orchestrate/interface/orchestrateInterfaceActionEndpoint.ts +58 -58
  250. package/src/orchestrate/interface/orchestrateInterfaceAuthorization.ts +208 -208
  251. package/src/orchestrate/interface/orchestrateInterfaceBaseEndpoint.ts +55 -55
  252. package/src/orchestrate/interface/orchestrateInterfaceEndpoint.ts +67 -67
  253. package/src/orchestrate/interface/orchestrateInterfaceEndpointOverall.ts +80 -80
  254. package/src/orchestrate/interface/orchestrateInterfaceEndpointReview.ts +212 -212
  255. package/src/orchestrate/interface/orchestrateInterfaceEndpointWrite.ts +236 -236
  256. package/src/orchestrate/interface/orchestrateInterfaceGroup.ts +166 -166
  257. package/src/orchestrate/interface/orchestrateInterfaceOperation.ts +322 -322
  258. package/src/orchestrate/interface/orchestrateInterfaceOperationReview.ts +245 -245
  259. package/src/orchestrate/interface/orchestrateInterfacePrerequisite.ts +240 -240
  260. package/src/orchestrate/interface/orchestrateInterfaceSchema.ts +191 -191
  261. package/src/orchestrate/interface/orchestrateInterfaceSchemaCasting.ts +274 -274
  262. package/src/orchestrate/interface/orchestrateInterfaceSchemaComplement.ts +329 -329
  263. package/src/orchestrate/interface/orchestrateInterfaceSchemaRefine.ts +292 -292
  264. package/src/orchestrate/interface/orchestrateInterfaceSchemaRename.ts +266 -266
  265. package/src/orchestrate/interface/orchestrateInterfaceSchemaReview.ts +310 -310
  266. package/src/orchestrate/interface/orchestrateInterfaceSchemaWrite.ts +283 -283
  267. package/src/orchestrate/interface/programmers/AutoBeInterfaceAuthorizationProgrammer.ts +260 -260
  268. package/src/orchestrate/interface/programmers/AutoBeInterfaceEndpointProgrammer.ts +155 -155
  269. package/src/orchestrate/interface/programmers/AutoBeInterfaceEndpointReviewProgrammer.ts +139 -139
  270. package/src/orchestrate/interface/programmers/AutoBeInterfaceOperationProgrammer.ts +277 -277
  271. package/src/orchestrate/interface/programmers/AutoBeInterfacePrerequisiteProgrammer.ts +259 -259
  272. package/src/orchestrate/interface/programmers/AutoBeInterfaceSchemaProgrammer.ts +152 -152
  273. package/src/orchestrate/interface/programmers/AutoBeInterfaceSchemaPropertyReviseProgrammer.ts +347 -347
  274. package/src/orchestrate/interface/programmers/AutoBeInterfaceSchemaRefineProgrammer.ts +183 -183
  275. package/src/orchestrate/interface/programmers/AutoBeInterfaceSchemaReviewProgrammer.ts +263 -263
  276. package/src/orchestrate/interface/structures/IAutoBeInterfaceAuthorizationApplication.ts +135 -135
  277. package/src/orchestrate/interface/structures/IAutoBeInterfaceEndpointReviewApplication.ts +128 -128
  278. package/src/orchestrate/interface/structures/IAutoBeInterfaceEndpointWriteApplication.ts +133 -133
  279. package/src/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.ts +122 -122
  280. package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.ts +178 -178
  281. package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationReviewApplication.ts +175 -175
  282. package/src/orchestrate/interface/structures/IAutoBeInterfacePrerequisiteApplication.ts +130 -130
  283. package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.ts +121 -121
  284. package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaCastingApplication.ts +153 -153
  285. package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaComplementApplication.ts +123 -123
  286. package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaRefineApplication.ts +181 -181
  287. package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaRenameApplication.ts +45 -45
  288. package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaReviewApplication.ts +108 -108
  289. package/src/orchestrate/interface/utils/AutoBeJsonSchemaCollection.ts +42 -42
  290. package/src/orchestrate/interface/utils/AutoBeJsonSchemaFactory.ts +714 -714
  291. package/src/orchestrate/interface/utils/AutoBeJsonSchemaNamingConvention.ts +86 -86
  292. package/src/orchestrate/interface/utils/AutoBeJsonSchemaValidator.ts +725 -725
  293. package/src/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.ts +219 -219
  294. package/src/orchestrate/prisma/histories/transformPrismaAuthorizationHistory.ts +144 -144
  295. package/src/orchestrate/prisma/histories/transformPrismaAuthorizationReviewHistory.ts +104 -104
  296. package/src/orchestrate/prisma/histories/transformPrismaComponentReviewHistory.ts +97 -97
  297. package/src/orchestrate/prisma/histories/transformPrismaComponentsHistory.ts +136 -136
  298. package/src/orchestrate/prisma/histories/transformPrismaCorrectHistory.ts +41 -41
  299. package/src/orchestrate/prisma/histories/transformPrismaGroupHistory.ts +63 -63
  300. package/src/orchestrate/prisma/histories/transformPrismaGroupReviewHistory.ts +79 -79
  301. package/src/orchestrate/prisma/histories/transformPrismaSchemaHistory.ts +97 -97
  302. package/src/orchestrate/prisma/histories/transformPrismaSchemaReviewHistory.ts +126 -126
  303. package/src/orchestrate/prisma/index.ts +7 -7
  304. package/src/orchestrate/prisma/orchestratePrisma.ts +296 -296
  305. package/src/orchestrate/prisma/orchestratePrismaAuthorization.ts +173 -173
  306. package/src/orchestrate/prisma/orchestratePrismaAuthorizationReview.ts +183 -183
  307. package/src/orchestrate/prisma/orchestratePrismaComponent.ts +205 -205
  308. package/src/orchestrate/prisma/orchestratePrismaComponentReview.ts +205 -205
  309. package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +265 -265
  310. package/src/orchestrate/prisma/orchestratePrismaGroup.ts +121 -121
  311. package/src/orchestrate/prisma/orchestratePrismaGroupReview.ts +141 -141
  312. package/src/orchestrate/prisma/orchestratePrismaSchema.ts +218 -218
  313. package/src/orchestrate/prisma/orchestratePrismaSchemaReview.ts +220 -220
  314. package/src/orchestrate/prisma/programmers/AutoBeDatabaseAuthorizationProgrammer.ts +86 -86
  315. package/src/orchestrate/prisma/programmers/AutoBeDatabaseAuthorizationReviewProgrammer.ts +103 -103
  316. package/src/orchestrate/prisma/programmers/AutoBeDatabaseComponentProgrammer.ts +80 -80
  317. package/src/orchestrate/prisma/programmers/AutoBeDatabaseComponentReviewProgrammer.ts +168 -168
  318. package/src/orchestrate/prisma/programmers/AutoBeDatabaseGroupProgrammer.ts +63 -63
  319. package/src/orchestrate/prisma/programmers/AutoBeDatabaseGroupReviewProgrammer.ts +210 -210
  320. package/src/orchestrate/prisma/programmers/AutoBeDatabaseModelProgrammer.ts +57 -57
  321. package/src/orchestrate/prisma/programmers/AutoBeDatabaseSchemaProgrammer.ts +92 -92
  322. package/src/orchestrate/prisma/structures/IAutoBeDatabaseAuthorizationApplication.ts +147 -147
  323. package/src/orchestrate/prisma/structures/IAutoBeDatabaseAuthorizationReviewApplication.ts +153 -153
  324. package/src/orchestrate/prisma/structures/IAutoBeDatabaseComponentApplication.ts +142 -142
  325. package/src/orchestrate/prisma/structures/IAutoBeDatabaseComponentReviewApplication.ts +151 -151
  326. package/src/orchestrate/prisma/structures/IAutoBeDatabaseCorrectApplication.ts +157 -157
  327. package/src/orchestrate/prisma/structures/IAutoBeDatabaseGroupApplication.ts +117 -117
  328. package/src/orchestrate/prisma/structures/IAutoBeDatabaseGroupReviewApplication.ts +154 -154
  329. package/src/orchestrate/prisma/structures/IAutoBeDatabaseSchemaApplication.ts +144 -144
  330. package/src/orchestrate/prisma/structures/IAutoBeDatabaseSchemaReviewApplication.ts +138 -138
  331. package/src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistory.ts +89 -89
  332. package/src/orchestrate/realize/histories/transformRealizeAuthorizationWriteHistory.ts +45 -45
  333. package/src/orchestrate/realize/histories/transformRealizeCollectorCorrectHistory.ts +137 -137
  334. package/src/orchestrate/realize/histories/transformRealizeCollectorPlanHistory.ts +64 -64
  335. package/src/orchestrate/realize/histories/transformRealizeCollectorWriteHistory.ts +147 -147
  336. package/src/orchestrate/realize/histories/transformRealizeCorrectCastingHistory.ts +69 -69
  337. package/src/orchestrate/realize/histories/transformRealizeOperationCorrectHistory.ts +94 -94
  338. package/src/orchestrate/realize/histories/transformRealizeOperationWriteHistory.ts +127 -127
  339. package/src/orchestrate/realize/histories/transformRealizeTransformerCorrectHistory.ts +147 -147
  340. package/src/orchestrate/realize/histories/transformRealizeTransformerPlanHistory.ts +61 -61
  341. package/src/orchestrate/realize/histories/transformRealizeTransformerWriteHistory.ts +133 -133
  342. package/src/orchestrate/realize/histories/transformRealizeWriteMembershipHistory.ts +30 -30
  343. package/src/orchestrate/realize/index.ts +3 -3
  344. package/src/orchestrate/realize/internal/orchestrateRealizeCorrectCasting.ts +444 -444
  345. package/src/orchestrate/realize/internal/orchestrateRealizeCorrectOverall.ts +449 -449
  346. package/src/orchestrate/realize/orchestrateRealize.ts +143 -143
  347. package/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.ts +207 -207
  348. package/src/orchestrate/realize/orchestrateRealizeAuthorizationWrite.ts +209 -209
  349. package/src/orchestrate/realize/orchestrateRealizeCollector.ts +41 -41
  350. package/src/orchestrate/realize/orchestrateRealizeCollectorCorrectCasting.ts +43 -43
  351. package/src/orchestrate/realize/orchestrateRealizeCollectorCorrectOverall.ts +157 -157
  352. package/src/orchestrate/realize/orchestrateRealizeCollectorPlan.ts +264 -264
  353. package/src/orchestrate/realize/orchestrateRealizeCollectorWrite.ts +225 -225
  354. package/src/orchestrate/realize/orchestrateRealizeOperation.ts +48 -48
  355. package/src/orchestrate/realize/orchestrateRealizeOperationCorrectCasting.ts +69 -69
  356. package/src/orchestrate/realize/orchestrateRealizeOperationCorrectOverall.ts +173 -173
  357. package/src/orchestrate/realize/orchestrateRealizeOperationWrite.ts +262 -262
  358. package/src/orchestrate/realize/orchestrateRealizeTransformer.ts +41 -41
  359. package/src/orchestrate/realize/orchestrateRealizeTransformerCorrectCasting.ts +38 -38
  360. package/src/orchestrate/realize/orchestrateRealizeTransformerCorrectOverall.ts +160 -160
  361. package/src/orchestrate/realize/orchestrateRealizeTransformerPlan.ts +254 -254
  362. package/src/orchestrate/realize/orchestrateRealizeTransformerWrite.ts +226 -226
  363. package/src/orchestrate/realize/programmers/AutoBeRealizeCollectorProgrammer.ts +424 -424
  364. package/src/orchestrate/realize/programmers/AutoBeRealizeOperationProgrammer.ts +409 -409
  365. package/src/orchestrate/realize/programmers/AutoBeRealizeTransformerProgrammer.ts +451 -451
  366. package/src/orchestrate/realize/programmers/compileRealizeFiles.ts +65 -65
  367. package/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.ts +119 -119
  368. package/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationWriteApplication.ts +167 -167
  369. package/src/orchestrate/realize/structures/IAutoBeRealizeCollectorCorrectApplication.ts +191 -191
  370. package/src/orchestrate/realize/structures/IAutoBeRealizeCollectorPlanApplication.ts +177 -177
  371. package/src/orchestrate/realize/structures/IAutoBeRealizeCollectorWriteApplication.ts +207 -207
  372. package/src/orchestrate/realize/structures/IAutoBeRealizeFunctionFailure.ts +11 -11
  373. package/src/orchestrate/realize/structures/IAutoBeRealizeOperationCorrectApplication.ts +134 -134
  374. package/src/orchestrate/realize/structures/IAutoBeRealizeOperationWriteApplication.ts +138 -138
  375. package/src/orchestrate/realize/structures/IAutoBeRealizeScenarioResult.ts +32 -32
  376. package/src/orchestrate/realize/structures/IAutoBeRealizeTransformerCorrectApplication.ts +248 -248
  377. package/src/orchestrate/realize/structures/IAutoBeRealizeTransformerPlanApplication.ts +150 -150
  378. package/src/orchestrate/realize/structures/IAutoBeRealizeTransformerWriteApplication.ts +278 -278
  379. package/src/orchestrate/realize/utils/AuthorizationFileSystem.ts +10 -10
  380. package/src/orchestrate/realize/utils/AutoBeRealizeAuthorizationFileSystem.ts +9 -9
  381. package/src/orchestrate/realize/utils/AutoBeRealizeAuthorizationReplaceImport.ts +62 -62
  382. package/src/orchestrate/realize/utils/InternalFileSystem.ts +12 -12
  383. package/src/orchestrate/realize/utils/ProviderFileSystem.ts +4 -4
  384. package/src/orchestrate/realize/utils/filterDiagnostics.ts +25 -25
  385. package/src/orchestrate/realize/utils/generateTS2339Hints.ts +54 -54
  386. package/src/orchestrate/realize/utils/getRealizeWriteImportStatements.ts +42 -42
  387. package/src/orchestrate/realize/utils/getRealizeWriteInputType.ts +88 -88
  388. package/src/orchestrate/realize/utils/printErrorHints.ts +54 -54
  389. package/src/orchestrate/test/compile/getTestArtifacts.ts +124 -124
  390. package/src/orchestrate/test/compile/getTestExternalDeclarations.ts +39 -39
  391. package/src/orchestrate/test/compile/getTestImportStatements.ts +27 -27
  392. package/src/orchestrate/test/experimental/orchestrateTestCorrect.ast +237 -237
  393. package/src/orchestrate/test/experimental/orchestrateTestWrite.ast +322 -322
  394. package/src/orchestrate/test/experimental/transformTestCorrectHistories.ast +52 -52
  395. package/src/orchestrate/test/histories/transformTestAuthorizeWriteHistory.ts +80 -80
  396. package/src/orchestrate/test/histories/transformTestCorrectOverallHistory.ts +116 -116
  397. package/src/orchestrate/test/histories/transformTestGenerationWriteHistory.ts +118 -118
  398. package/src/orchestrate/test/histories/transformTestOperationWriteHistory.ts +287 -287
  399. package/src/orchestrate/test/histories/transformTestPrepareWriteHistory.ts +95 -95
  400. package/src/orchestrate/test/histories/transformTestScenarioHistory.ts +120 -120
  401. package/src/orchestrate/test/histories/transformTestScenarioReviewHistory.ts +99 -99
  402. package/src/orchestrate/test/histories/transformTestValidateEvent.ts +11 -11
  403. package/src/orchestrate/test/index.ts +5 -5
  404. package/src/orchestrate/test/internal/orchestrateTestCorrectCasting.ts +96 -96
  405. package/src/orchestrate/test/internal/orchestrateTestCorrectOverall.ts +219 -219
  406. package/src/orchestrate/test/internal/orchestrateTestCorrectRequest.ts +206 -206
  407. package/src/orchestrate/test/orchestrateTest.ts +161 -161
  408. package/src/orchestrate/test/orchestrateTestAuthorize.ts +125 -125
  409. package/src/orchestrate/test/orchestrateTestAuthorizeWrite.ts +263 -263
  410. package/src/orchestrate/test/orchestrateTestGenerate.ts +121 -121
  411. package/src/orchestrate/test/orchestrateTestGenerateWrite.ts +211 -211
  412. package/src/orchestrate/test/orchestrateTestOperation.ts +133 -133
  413. package/src/orchestrate/test/orchestrateTestOperationWrite.ts +221 -221
  414. package/src/orchestrate/test/orchestrateTestPrepare.ts +117 -117
  415. package/src/orchestrate/test/orchestrateTestPrepareWrite.ts +264 -264
  416. package/src/orchestrate/test/orchestrateTestScenario.ts +290 -290
  417. package/src/orchestrate/test/orchestrateTestScenarioReview.ts +262 -262
  418. package/src/orchestrate/test/programmers/AutoBeTestAuthorizeProgrammer.ts +149 -149
  419. package/src/orchestrate/test/programmers/AutoBeTestFunctionProgrammer.ts +90 -90
  420. package/src/orchestrate/test/programmers/AutoBeTestGenerateProgrammer.ts +170 -170
  421. package/src/orchestrate/test/programmers/AutoBeTestOperationProgrammer.ts +168 -168
  422. package/src/orchestrate/test/programmers/AutoBeTestPrepareProgrammer.ts +261 -261
  423. package/src/orchestrate/test/programmers/AutoBeTestScenarioProgrammer.ts +316 -316
  424. package/src/orchestrate/test/structures/IAutoBeTestArtifacts.ts +8 -8
  425. package/src/orchestrate/test/structures/IAutoBeTestAuthorizationWriteApplication.ts +113 -113
  426. package/src/orchestrate/test/structures/IAutoBeTestAuthorizeWriteResult.ts +10 -10
  427. package/src/orchestrate/test/structures/IAutoBeTestCorrectOverallApplication.ts +134 -134
  428. package/src/orchestrate/test/structures/IAutoBeTestCorrectRequestApplication.ts +152 -152
  429. package/src/orchestrate/test/structures/IAutoBeTestFunction.ts +10 -10
  430. package/src/orchestrate/test/structures/IAutoBeTestFunctionFailure.ts +10 -10
  431. package/src/orchestrate/test/structures/IAutoBeTestGenerateProcedure.ts +15 -15
  432. package/src/orchestrate/test/structures/IAutoBeTestGenerationWriteApplication.ts +145 -145
  433. package/src/orchestrate/test/structures/IAutoBeTestOperationProcedure.ts +17 -17
  434. package/src/orchestrate/test/structures/IAutoBeTestOperationWriteApplication.ts +162 -162
  435. package/src/orchestrate/test/structures/IAutoBeTestPrepareCorrectOverallApplication.ts +194 -194
  436. package/src/orchestrate/test/structures/IAutoBeTestPrepareProcedure.ts +8 -8
  437. package/src/orchestrate/test/structures/IAutoBeTestPrepareWriteApplication.ts +147 -147
  438. package/src/orchestrate/test/structures/IAutoBeTestProcedure.ts +10 -10
  439. package/src/orchestrate/test/structures/IAutoBeTestScenarioApplication.ts +105 -105
  440. package/src/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.ts +8 -8
  441. package/src/orchestrate/test/structures/IAutoBeTestScenarioAuthorizationActor.ts +7 -7
  442. package/src/orchestrate/test/structures/IAutoBeTestScenarioReviewApplication.ts +133 -133
  443. package/src/orchestrate/test/utils/getPrerequisites.ts +51 -51
  444. package/src/orchestrate/test/utils/getReferenceIds.ts +26 -26
  445. package/src/orchestrate/test/utils/insertScriptToTestResult.ts +14 -14
  446. package/src/structures/IAutoBeConfig.ts +110 -110
  447. package/src/structures/IAutoBeOrchestrateHistory.ts +44 -44
  448. package/src/structures/IAutoBeProps.ts +102 -102
  449. package/src/structures/IAutoBeVendor.ts +113 -113
  450. package/src/utils/AutoBePreliminaryExhaustedError.ts +30 -30
  451. package/src/utils/AutoBeTimeoutError.ts +35 -35
  452. package/src/utils/EmbeddingProvider.ts +4 -4
  453. package/src/utils/LocalEmbeddingProvider.ts +145 -145
  454. package/src/utils/RAGRetrieval.ts +411 -411
  455. package/src/utils/TimedConversation.ts +125 -125
  456. package/src/utils/backoffRetry.ts +169 -169
  457. package/src/utils/divideArray.ts +35 -35
  458. package/src/utils/emplaceMap.ts +31 -31
  459. package/src/utils/executeCachedBatch.ts +67 -67
  460. package/src/utils/forceRetry.ts +15 -15
  461. package/src/utils/getEmbedder.ts +16 -16
  462. package/src/utils/parseTextFunctionCall.ts +437 -437
  463. package/src/utils/predicateStateMessage.ts +131 -131
  464. package/src/utils/validateEmptyCode.ts +73 -73
  465. package/src/utils/validateEnglishOnly.ts +224 -224
  466. package/README.md +0 -261
@@ -1,714 +1,714 @@
1
- import {
2
- AutoBeDatabase,
3
- AutoBeInterfaceSchemaDesign,
4
- AutoBeOpenApi,
5
- } from "@autobe/interface";
6
- import { AutoBeOpenApiTypeChecker, StringUtil } from "@autobe/utils";
7
- import { OpenApiConverter, OpenApiTypeChecker } from "@typia/utils";
8
- import typia, { OpenApi, tags } from "typia";
9
- import { v7 } from "uuid";
10
-
11
- import { AutoBeInterfaceSchemaProgrammer } from "../programmers/AutoBeInterfaceSchemaProgrammer";
12
- import { AutoBeJsonSchemaCollection } from "./AutoBeJsonSchemaCollection";
13
- import { AutoBeJsonSchemaValidator } from "./AutoBeJsonSchemaValidator";
14
-
15
- export namespace AutoBeJsonSchemaFactory {
16
- /* -----------------------------------------------------------
17
- ASSIGNMENTS
18
- ----------------------------------------------------------- */
19
- export const presets = (
20
- typeNames: Set<string>,
21
- ): Record<string, AutoBeOpenApi.IJsonSchemaDescriptive> => {
22
- const schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive> = {};
23
- for (const [key, value] of Object.entries(DEFAULT_SCHEMAS)) {
24
- schemas[key] = value;
25
- typeNames.delete(key);
26
- }
27
- for (const key of typeNames)
28
- if (AutoBeJsonSchemaValidator.isPage(key)) {
29
- const data: string = getPageName(key);
30
- schemas[key] = writePageSchema(data);
31
- typeNames.delete(key);
32
- typeNames.add(data);
33
- }
34
- return schemas;
35
- };
36
-
37
- export const fixPaginationSchemas = (
38
- schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>,
39
- ): void => {
40
- const pageRequest: AutoBeOpenApi.IJsonSchemaDescriptive.IObject =
41
- DEFAULT_SCHEMAS[
42
- "IPage.IRequest"
43
- ] as AutoBeOpenApi.IJsonSchemaDescriptive.IObject;
44
- for (const [key, value] of Object.entries(schemas)) {
45
- if (key.endsWith(".IRequest") === false) continue;
46
- else if (AutoBeOpenApiTypeChecker.isObject(value) === false) continue;
47
-
48
- if (value.properties.page === undefined)
49
- value.properties.page = pageRequest.properties.page;
50
- if (value.properties.limit === undefined)
51
- value.properties.limit = pageRequest.properties.limit;
52
- }
53
- };
54
-
55
- export const fixAuthorizationSchemas = (
56
- schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>,
57
- ): void => {
58
- for (const [key, value] of Object.entries(schemas)) {
59
- if (key.endsWith(".IAuthorized") === false) continue;
60
- else if (AutoBeOpenApiTypeChecker.isObject(value) === false) continue;
61
-
62
- const parent: AutoBeOpenApi.IJsonSchemaDescriptive | undefined =
63
- schemas[key.replace(".IAuthorized", "")];
64
- if (
65
- parent === undefined ||
66
- AutoBeOpenApiTypeChecker.isObject(parent) === false
67
- ) {
68
- value.properties.token = {
69
- "x-autobe-specification":
70
- "Authorization token comes from the session table.",
71
- description: "Authorization token.",
72
- $ref: "#/components/schemas/IAuthorizationToken",
73
- };
74
- if (value.required.includes("token") === false)
75
- value.required.push("token");
76
- } else {
77
- value.properties = {
78
- ...parent.properties,
79
- ...value.properties,
80
- };
81
- value.properties.token = {
82
- "x-autobe-specification":
83
- "Authorization token comes from the session table.",
84
- description: "Authorization token.",
85
- $ref: "#/components/schemas/IAuthorizationToken",
86
- };
87
- value.required = Array.from(
88
- new Set([...parent.required, ...value.required]),
89
- );
90
- if (value.required.includes("id") === false) value.required.push("id");
91
- if (value.required.includes("token") === false)
92
- value.required.push("token");
93
- }
94
- }
95
- };
96
-
97
- export const finalize = (props: {
98
- application: AutoBeDatabase.IApplication;
99
- operations: AutoBeOpenApi.IOperation[];
100
- collection: AutoBeJsonSchemaCollection;
101
- }): void => {
102
- removeDuplicated(props);
103
- fixTimestamps({
104
- application: props.application,
105
- document: {
106
- operations: props.operations,
107
- components: {
108
- schemas: props.collection.schemas,
109
- authorizations: [],
110
- },
111
- },
112
- });
113
- linkRelatedModels({
114
- application: props.application,
115
- document: {
116
- operations: props.operations,
117
- components: {
118
- schemas: props.collection.schemas,
119
- authorizations: [],
120
- },
121
- },
122
- });
123
- };
124
-
125
- export const removeUnused = (props: {
126
- operations: AutoBeOpenApi.IOperation[];
127
- schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>;
128
- }): void => {
129
- while (true) {
130
- const used: Set<string> = new Set();
131
- const visit = (schema: AutoBeOpenApi.IJsonSchema): void =>
132
- OpenApiTypeChecker.visit({
133
- components: { schemas: props.schemas },
134
- schema,
135
- closure: (next) => {
136
- if (OpenApiTypeChecker.isReference(next)) {
137
- const key: string = next.$ref.split("/").pop()!;
138
- used.add(key);
139
- }
140
- },
141
- });
142
- for (const op of props.operations) {
143
- if (op.requestBody !== null)
144
- visit({
145
- $ref: `#/components/schemas/${op.requestBody.typeName}`,
146
- });
147
- if (op.responseBody !== null)
148
- visit({
149
- $ref: `#/components/schemas/${op.responseBody.typeName}`,
150
- });
151
- }
152
-
153
- const complete: boolean =
154
- Object.keys(props.schemas).length === 0 ||
155
- Object.keys(props.schemas).every((key) => used.has(key) === true);
156
- if (complete === true) break;
157
- for (const key of Object.keys(props.schemas))
158
- if (used.has(key) === false) delete props.schemas[key];
159
- }
160
- };
161
-
162
- const removeDuplicated = (props: {
163
- operations: AutoBeOpenApi.IOperation[];
164
- collection: AutoBeJsonSchemaCollection;
165
- }): void => {
166
- // gather duplicated schemas
167
- const correct: Map<string, string> = new Map();
168
- for (const key of Object.keys(props.collection.schemas)) {
169
- if (key.includes(".") === false) continue;
170
- const dotRemoved: string = key.replace(".", "");
171
- if (props.collection.schemas[dotRemoved] === undefined) continue;
172
- correct.set(dotRemoved, key);
173
- }
174
-
175
- // fix operations' references
176
- for (const op of props.operations) {
177
- if (op.requestBody && correct.has(op.requestBody.typeName))
178
- op.requestBody.typeName = correct.get(op.requestBody.typeName)!;
179
- if (op.responseBody && correct.has(op.responseBody.typeName))
180
- op.responseBody.typeName = correct.get(op.responseBody.typeName)!;
181
- }
182
-
183
- // fix schemas' references
184
- const $refChangers: Map<OpenApi.IJsonSchema, () => void> = new Map();
185
- for (const value of Object.values(props.collection.schemas))
186
- OpenApiTypeChecker.visit({
187
- components: { schemas: props.collection.schemas },
188
- schema: value,
189
- closure: (next) => {
190
- if (OpenApiTypeChecker.isReference(next) === false) return;
191
- const x: string = next.$ref.split("/").pop()!;
192
- const y: string | undefined = correct.get(x);
193
- if (y === undefined) return;
194
- $refChangers.set(
195
- next,
196
- () => (next.$ref = `#/components/schemas/${y}`),
197
- );
198
- },
199
- });
200
- for (const fn of $refChangers.values()) fn();
201
-
202
- // remove duplicated schemas
203
- for (const key of correct.keys()) props.collection.delete(key);
204
- };
205
-
206
- const fixTimestamps = (props: {
207
- document: AutoBeOpenApi.IDocument;
208
- application: AutoBeDatabase.IApplication;
209
- }): void => {
210
- const entireModels: AutoBeDatabase.IModel[] = props.application.files
211
- .map((f) => f.models)
212
- .flat();
213
- for (const value of Object.values(props.document.components.schemas)) {
214
- if (AutoBeOpenApiTypeChecker.isObject(value) === false) continue;
215
-
216
- const model: AutoBeDatabase.IModel | undefined = value[
217
- "x-autobe-database-schema"
218
- ]
219
- ? entireModels.find((m) => m.name === value["x-autobe-database-schema"])
220
- : undefined;
221
- if (model === undefined) continue;
222
-
223
- const properties: string[] = Object.keys(value.properties);
224
- for (const key of properties) {
225
- if (
226
- key !== "created_at" &&
227
- key !== "updated_at" &&
228
- key !== "deleted_at"
229
- )
230
- continue;
231
- const column: AutoBeDatabase.IPlainField | undefined =
232
- model.plainFields.find((c) => c.name === key);
233
- if (column === undefined) delete value.properties[key];
234
- }
235
- }
236
- };
237
-
238
- const linkRelatedModels = (props: {
239
- document: AutoBeOpenApi.IDocument;
240
- application: AutoBeDatabase.IApplication;
241
- }): void => {
242
- const modelDict: Set<string> = new Set(
243
- props.application.files
244
- .map((f) => f.models)
245
- .flat()
246
- .map((m) => m.name),
247
- );
248
- for (const [key, value] of Object.entries(
249
- props.document.components.schemas,
250
- )) {
251
- if (
252
- AutoBeOpenApiTypeChecker.isObject(value) === false ||
253
- !!value["x-autobe-database-schema"]?.length
254
- )
255
- continue;
256
-
257
- const typeName: string = key.split(".")[0]!.substring(1);
258
- const modelName: string =
259
- AutoBeInterfaceSchemaProgrammer.getDatabaseSchemaName(typeName);
260
- if (modelDict.has(modelName) === true)
261
- value["x-autobe-database-schema"] = modelName;
262
- }
263
- };
264
-
265
- /* -----------------------------------------------------------
266
- PAGINATION
267
- ----------------------------------------------------------- */
268
- export const writePageSchema = (
269
- key: string,
270
- ): AutoBeOpenApi.IJsonSchemaDescriptive.IObject => ({
271
- type: "object",
272
- properties: {
273
- pagination: {
274
- "x-autobe-specification": "Pagination information for the page.",
275
- description: "Page information.",
276
- $ref: "#/components/schemas/IPage.IPagination",
277
- },
278
- data: {
279
- "x-autobe-specification": `List of records of type ${key}.`,
280
- description: "List of records.",
281
- type: "array",
282
- items: {
283
- $ref: `#/components/schemas/${key}`,
284
- },
285
- },
286
- },
287
- required: ["pagination", "data"],
288
- description: StringUtil.trim`
289
- A page.
290
-
291
- Collection of records with pagination information.
292
- `,
293
- "x-autobe-specification": `A page containing records of type ${key}.`,
294
- "x-autobe-database-schema": null, // filled by relation review agent
295
- });
296
-
297
- // export const fixPage = (path: string, input: unknown): void => {
298
- // if (isRecord(input) === false || isRecord(input[path]) === false) return;
299
- // if (input[path].description) delete input[path].description;
300
- // if (input[path].required) delete input[path].required;
301
-
302
- // for (const key of Object.keys(input[path]))
303
- // if (DEFAULT_SCHEMAS[key] !== undefined)
304
- // input[path][key] = DEFAULT_SCHEMAS[key];
305
- // else if (AutoBeJsonSchemaValidator.isPage(key) === true) {
306
- // const data: string = key.substring("IPage".length);
307
- // input[path][key] = writePageSchema(data);
308
- // }
309
- // };
310
-
311
- export const getPageName = (key: string): string =>
312
- key.substring("IPage".length);
313
-
314
- // const isRecord = (input: unknown): input is Record<string, unknown> =>
315
- // typeof input === "object" && input !== null;
316
-
317
- export const DEFAULT_SCHEMAS = (() => {
318
- const init: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive> =
319
- (typia.json.schemas<
320
- [IPage.IPagination, IPage.IRequest, IAuthorizationToken, IEntity]
321
- >().components?.schemas ?? {}) as Record<
322
- string,
323
- AutoBeOpenApi.IJsonSchemaDescriptive
324
- >;
325
- for (const value of Object.values(init))
326
- AutoBeOpenApiTypeChecker.visit({
327
- components: {
328
- schemas: init,
329
- authorizations: [],
330
- },
331
- schema: value,
332
- closure: (next) => {
333
- if (AutoBeOpenApiTypeChecker.isObject(next)) {
334
- next["x-autobe-database-schema"] = null;
335
- }
336
- },
337
- });
338
- return init;
339
- })();
340
-
341
- /* -----------------------------------------------------------
342
- PLUGIN
343
- ----------------------------------------------------------- */
344
- export const fixDesign = (
345
- design: AutoBeInterfaceSchemaDesign,
346
- ): AutoBeOpenApi.IJsonSchema => {
347
- const emended: AutoBeOpenApi.IJsonSchema = fixSchema(design.schema);
348
- const final: AutoBeOpenApi.IJsonSchema = {
349
- ...emended,
350
- ...({
351
- description: design.description,
352
- "x-autobe-specification": design.specification,
353
- } satisfies Pick<
354
- AutoBeOpenApi.IJsonSchemaDescriptive,
355
- "description" | "x-autobe-specification"
356
- >),
357
- };
358
- if (AutoBeOpenApiTypeChecker.isObject(final))
359
- final["x-autobe-database-schema"] = design.databaseSchema;
360
- return final;
361
- };
362
-
363
- export const fixSchema = <Schema extends AutoBeOpenApi.IJsonSchema>(
364
- schema: Schema,
365
- ): Schema => {
366
- const id: string = v7();
367
- const emended: AutoBeOpenApi.IJsonSchema = (
368
- (OpenApiConverter.upgradeComponents({
369
- schemas: {
370
- [id]: schema,
371
- },
372
- }).schemas ?? {}) as Record<string, AutoBeOpenApi.IJsonSchema>
373
- )[id];
374
-
375
- const visited: WeakSet<object> = new WeakSet();
376
- if (AutoBeOpenApiTypeChecker.isObject(emended)) {
377
- visited.add(emended);
378
- for (const v of Object.values(emended.properties)) visited.add(v);
379
- }
380
-
381
- AutoBeOpenApiTypeChecker.visit({
382
- components: {
383
- authorizations: [],
384
- schemas: {},
385
- },
386
- schema: emended,
387
- closure(next) {
388
- if (visited.has(next) === false)
389
- for (const k of Object.keys(next))
390
- if (k.startsWith("x-")) {
391
- // biome-ignore lint: intended
392
- delete (next as any)[k];
393
- }
394
- if (AutoBeOpenApiTypeChecker.isString(next)) fixStringSchema(next);
395
- else if (AutoBeOpenApiTypeChecker.isArray(next)) fixArraySchema(next);
396
- else if (AutoBeOpenApiTypeChecker.isInteger(next))
397
- fixIntegerSchema(next);
398
- else if (AutoBeOpenApiTypeChecker.isNumber(next)) fixNumberSchema(next);
399
- },
400
- });
401
-
402
- const result: Schema = emended as Schema;
403
- if (AutoBeOpenApiTypeChecker.isObject(result))
404
- for (const [key, value] of Object.entries(result.properties)) {
405
- if (key !== "id" && key.endsWith("_id") === false) continue;
406
- else if (AutoBeOpenApiTypeChecker.isString(value))
407
- fixReferenceIdSchema(value);
408
- else if (AutoBeOpenApiTypeChecker.isOneOf(value)) {
409
- const str: AutoBeOpenApi.IJsonSchema.IString | undefined =
410
- value.oneOf.find((v) => AutoBeOpenApiTypeChecker.isString(v));
411
- if (str !== undefined) fixReferenceIdSchema(str);
412
- }
413
- }
414
- return result;
415
- };
416
-
417
- const convertConst = (
418
- schema:
419
- | AutoBeOpenApi.IJsonSchema.INumber
420
- | AutoBeOpenApi.IJsonSchema.IInteger,
421
- value: number,
422
- ): void => {
423
- // biome-ignore lint: @todo
424
- const description: string | undefined = (schema as any).description;
425
-
426
- for (const key of Object.keys(schema)) {
427
- // biome-ignore lint: @todo
428
- delete (schema as any)[key];
429
- }
430
-
431
- // biome-ignore lint: @todo
432
- (schema as any).const = value;
433
- if (description !== undefined) {
434
- // biome-ignore lint: @todo
435
- (schema as any).description = description;
436
- }
437
- };
438
-
439
- const fixStringSchema = (schema: AutoBeOpenApi.IJsonSchema.IString): void => {
440
- if (schema.format !== undefined) {
441
- delete schema.pattern;
442
- if (
443
- schema.format === "uuid" ||
444
- schema.format === "ipv4" ||
445
- schema.format === "ipv6" ||
446
- schema.format === "date" ||
447
- schema.format === "date-time" ||
448
- schema.format === "time"
449
- ) {
450
- delete schema.minLength;
451
- delete schema.maxLength;
452
- delete schema.contentMediaType;
453
- }
454
- }
455
- if (schema.contentMediaType === "") delete schema.contentMediaType;
456
- if (schema.minLength === 0) delete schema.minLength;
457
- };
458
-
459
- const fixArraySchema = (schema: AutoBeOpenApi.IJsonSchema.IArray): void => {
460
- if (schema.minItems === 0) delete schema.minItems;
461
- };
462
-
463
- /**
464
- * Fix integer schema by converting single valid value ranges to const.
465
- *
466
- * Handles:
467
- *
468
- * - Minimum === maximum → const
469
- * - Minimum: N, exclusiveMaximum: N+1 → const N
470
- * - ExclusiveMinimum: N-1, maximum: N → const N
471
- * - ExclusiveMinimum: N-1, exclusiveMaximum: N+1 → const N
472
- */
473
- const fixIntegerSchema = (
474
- schema: AutoBeOpenApi.IJsonSchema.IInteger,
475
- ): void => {
476
- const value: number | undefined = (() => {
477
- if (schema.minimum !== undefined && schema.maximum === schema.minimum)
478
- return schema.minimum;
479
- if (
480
- schema.minimum !== undefined &&
481
- schema.exclusiveMaximum === schema.minimum + 1
482
- )
483
- return schema.minimum;
484
- if (
485
- schema.maximum !== undefined &&
486
- schema.exclusiveMinimum === schema.maximum - 1
487
- )
488
- return schema.maximum;
489
- if (
490
- schema.exclusiveMinimum !== undefined &&
491
- schema.exclusiveMaximum === schema.exclusiveMinimum + 2
492
- )
493
- return schema.exclusiveMinimum + 1;
494
- return undefined;
495
- })();
496
-
497
- if (value !== undefined) convertConst(schema, value);
498
- };
499
-
500
- /**
501
- * Fix number schema by converting single valid value ranges to const.
502
- *
503
- * Handles:
504
- *
505
- * - Minimum === maximum → const
506
- */
507
- const fixNumberSchema = (schema: AutoBeOpenApi.IJsonSchema.INumber): void => {
508
- // minimum === maximum → const
509
- if (
510
- schema.minimum !== undefined &&
511
- schema.maximum !== undefined &&
512
- schema.minimum === schema.maximum
513
- )
514
- return convertConst(schema, schema.minimum);
515
- };
516
-
517
- const fixReferenceIdSchema = (
518
- schema: AutoBeOpenApi.IJsonSchema.IString,
519
- ): void => {
520
- schema.format = "uuid";
521
- fixStringSchema(schema);
522
- };
523
- }
524
-
525
- namespace IPage {
526
- /**
527
- * Pagination metadata containing current page position and total data
528
- * statistics.
529
- *
530
- * This interface provides comprehensive pagination information returned
531
- * alongside paginated list data. It enables clients to implement navigation
532
- * controls, display progress indicators, and determine data boundaries for UI
533
- * rendering.
534
- *
535
- * @x-autobe-specification Pagination metadata for paginated list responses. Included in all list endpoint responses.
536
- */
537
- export interface IPagination {
538
- /**
539
- * Current page number being viewed (1-indexed).
540
- *
541
- * Indicates which page of results is currently being returned. Page
542
- * numbering starts from 1, so the first page is page 1 (not 0). This value
543
- * reflects the page parameter from the request after validation and bounds
544
- * checking.
545
- *
546
- * @x-autobe-specification 1-indexed current page number. Defaults to 1.
547
- */
548
- current: number & tags.Type<"uint32">;
549
-
550
- /**
551
- * Maximum number of records per page.
552
- *
553
- * Defines the upper bound on how many records can be returned in a single
554
- * page. This corresponds to the limit parameter from the request. The
555
- * actual number of records in the data array may be less than this value on
556
- * the final page or when total records are fewer than the limit.
557
- *
558
- * @x-autobe-specification Maximum records per page. Actual count may be less on last page.
559
- */
560
- limit: number & tags.Type<"uint32">;
561
-
562
- /**
563
- * Total count of all records matching the query criteria.
564
- *
565
- * Represents the complete number of records available across all pages, not
566
- * just the current page. This value is computed via a COUNT query and is
567
- * essential for calculating total pages and displaying pagination UI
568
- * elements like "Showing 1-10 of 150 results".
569
- *
570
- * @x-autobe-specification Total record count across all pages.
571
- */
572
- records: number & tags.Type<"uint32">;
573
-
574
- /**
575
- * Total number of pages available.
576
- *
577
- * Calculated as ceiling of {@link records} divided by {@link limit}. When
578
- * records is 0, pages will also be 0. This value enables clients to render
579
- * page navigation controls and validate page bounds.
580
- *
581
- * @x-autobe-specification Total pages. Calculated as Math.ceil(records / limit).
582
- */
583
- pages: number & tags.Type<"uint32">;
584
- }
585
-
586
- /**
587
- * Pagination request parameters for list endpoints.
588
- *
589
- * Defines the query parameters used to control pagination when requesting
590
- * list data. Both parameters are optional with sensible defaults, allowing
591
- * clients to fetch data without specifying pagination if default behavior is
592
- * acceptable.
593
- *
594
- * @x-autobe-specification Pagination query parameters for list endpoints. All fields optional.
595
- */
596
- export interface IRequest {
597
- /**
598
- * Target page number to retrieve (1-indexed).
599
- *
600
- * Specifies which page of results to return. Page numbering starts from 1.
601
- * If omitted, null, or undefined, defaults to page 1 (first page).
602
- * Requesting a page beyond the available range returns an empty data array
603
- * with valid pagination metadata reflecting the actual totals.
604
- *
605
- * @x-autobe-specification 1-indexed page number. Defaults to 1 if not provided.
606
- */
607
- page?: null | (number & tags.Type<"uint32">);
608
-
609
- /**
610
- * Maximum number of records to return per page.
611
- *
612
- * Controls how many records are included in each page response. If omitted,
613
- * null, or undefined, defaults to 100 records per page. The server may
614
- * enforce upper bounds to prevent excessive resource consumption on large
615
- * requests.
616
- *
617
- * @default 100
618
- *
619
- * @x-autobe-specification Maximum records per page. Defaults to 100 if not provided.
620
- */
621
- limit?: null | (number & tags.Type<"uint32">);
622
- }
623
- }
624
-
625
- /**
626
- * JWT-based authorization token pair with expiration metadata.
627
- *
628
- * Provides a complete authentication token structure containing both access and
629
- * refresh tokens along with their respective expiration timestamps. This
630
- * dual-token pattern enables secure, stateless authentication with automatic
631
- * session renewal capabilities.
632
- *
633
- * The access token is short-lived for security, while the refresh token allows
634
- * obtaining new access tokens without requiring the user to re-enter
635
- * credentials. This structure is automatically included in authentication
636
- * responses across all generated backend applications.
637
- *
638
- * @x-autobe-specification Dual-token authentication structure with access/refresh tokens and expiration info.
639
- */
640
- interface IAuthorizationToken {
641
- /**
642
- * Short-lived JWT access token for authenticating API requests.
643
- *
644
- * This token must be included in the Authorization header using the Bearer
645
- * scheme (e.g., `Authorization: Bearer {access}`) for all endpoints requiring
646
- * authentication. The token contains encoded claims including user identity,
647
- * roles, and permissions. Typically expires within 15-60 minutes for
648
- * security; use the refresh token to obtain a new access token when expired.
649
- *
650
- * @x-autobe-specification JWT access token. Use in Authorization header as "Bearer {access}".
651
- */
652
- access: string;
653
-
654
- /**
655
- * Long-lived refresh token for obtaining new access tokens.
656
- *
657
- * Used to request new access tokens when the current access token expires,
658
- * allowing session continuation without re-authentication. Should be stored
659
- * securely and transmitted only to the token refresh endpoint. Typical
660
- * lifetime ranges from 7 to 30 days depending on security requirements.
661
- *
662
- * @x-autobe-specification Refresh token for obtaining new access tokens without re-authentication.
663
- */
664
- refresh: string;
665
-
666
- /**
667
- * ISO 8601 timestamp when the access token expires.
668
- *
669
- * After this timestamp, the access token will be rejected by authenticated
670
- * endpoints. Clients should proactively refresh before expiration to maintain
671
- * seamless user experience. A common strategy is to refresh when remaining
672
- * time falls below 5 minutes. This timestamp is also embedded within the JWT
673
- * itself as the "exp" claim.
674
- *
675
- * @x-autobe-specification Access token expiration timestamp in ISO 8601 format.
676
- */
677
- expired_at: string & tags.Format<"date-time">;
678
-
679
- /**
680
- * ISO 8601 timestamp indicating the absolute session expiration deadline.
681
- *
682
- * Represents the latest possible time the refresh token can be used. Once
683
- * this timestamp is reached, the user must fully re-authenticate with
684
- * credentials. This defines the maximum session duration regardless of
685
- * activity. If refresh token rotation is enabled, this deadline may extend
686
- * with each successful refresh.
687
- *
688
- * @x-autobe-specification Refresh token expiration timestamp. Re-authentication required after this time.
689
- */
690
- refreshable_until: string & tags.Format<"date-time">;
691
- }
692
-
693
- /**
694
- * Base entity interface providing standard primary key identification.
695
- *
696
- * Serves as the foundational interface for all database entities in the
697
- * generated application. Every model and record type extends this interface,
698
- * ensuring consistent identification semantics across all database tables and
699
- * API responses.
700
- *
701
- * @x-autobe-specification Base interface for all database entities. Contains the primary key.
702
- */
703
- interface IEntity {
704
- /**
705
- * Unique identifier for this entity (UUID format).
706
- *
707
- * Auto-generated primary key using UUID format. This value is assigned by the
708
- * system upon record creation and cannot be modified afterward. All foreign
709
- * key relationships in the database reference this field.
710
- *
711
- * @x-autobe-specification Primary key in UUID format. Auto-generated, read-only.
712
- */
713
- id: string & tags.Format<"uuid">;
714
- }
1
+ import {
2
+ AutoBeDatabase,
3
+ AutoBeInterfaceSchemaDesign,
4
+ AutoBeOpenApi,
5
+ } from "@autobe/interface";
6
+ import { AutoBeOpenApiTypeChecker, StringUtil } from "@autobe/utils";
7
+ import { OpenApiConverter, OpenApiTypeChecker } from "@typia/utils";
8
+ import typia, { OpenApi, tags } from "typia";
9
+ import { v7 } from "uuid";
10
+
11
+ import { AutoBeInterfaceSchemaProgrammer } from "../programmers/AutoBeInterfaceSchemaProgrammer";
12
+ import { AutoBeJsonSchemaCollection } from "./AutoBeJsonSchemaCollection";
13
+ import { AutoBeJsonSchemaValidator } from "./AutoBeJsonSchemaValidator";
14
+
15
+ export namespace AutoBeJsonSchemaFactory {
16
+ /* -----------------------------------------------------------
17
+ ASSIGNMENTS
18
+ ----------------------------------------------------------- */
19
+ export const presets = (
20
+ typeNames: Set<string>,
21
+ ): Record<string, AutoBeOpenApi.IJsonSchemaDescriptive> => {
22
+ const schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive> = {};
23
+ for (const [key, value] of Object.entries(DEFAULT_SCHEMAS)) {
24
+ schemas[key] = value;
25
+ typeNames.delete(key);
26
+ }
27
+ for (const key of typeNames)
28
+ if (AutoBeJsonSchemaValidator.isPage(key)) {
29
+ const data: string = getPageName(key);
30
+ schemas[key] = writePageSchema(data);
31
+ typeNames.delete(key);
32
+ typeNames.add(data);
33
+ }
34
+ return schemas;
35
+ };
36
+
37
+ export const fixPaginationSchemas = (
38
+ schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>,
39
+ ): void => {
40
+ const pageRequest: AutoBeOpenApi.IJsonSchemaDescriptive.IObject =
41
+ DEFAULT_SCHEMAS[
42
+ "IPage.IRequest"
43
+ ] as AutoBeOpenApi.IJsonSchemaDescriptive.IObject;
44
+ for (const [key, value] of Object.entries(schemas)) {
45
+ if (key.endsWith(".IRequest") === false) continue;
46
+ else if (AutoBeOpenApiTypeChecker.isObject(value) === false) continue;
47
+
48
+ if (value.properties.page === undefined)
49
+ value.properties.page = pageRequest.properties.page;
50
+ if (value.properties.limit === undefined)
51
+ value.properties.limit = pageRequest.properties.limit;
52
+ }
53
+ };
54
+
55
+ export const fixAuthorizationSchemas = (
56
+ schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>,
57
+ ): void => {
58
+ for (const [key, value] of Object.entries(schemas)) {
59
+ if (key.endsWith(".IAuthorized") === false) continue;
60
+ else if (AutoBeOpenApiTypeChecker.isObject(value) === false) continue;
61
+
62
+ const parent: AutoBeOpenApi.IJsonSchemaDescriptive | undefined =
63
+ schemas[key.replace(".IAuthorized", "")];
64
+ if (
65
+ parent === undefined ||
66
+ AutoBeOpenApiTypeChecker.isObject(parent) === false
67
+ ) {
68
+ value.properties.token = {
69
+ "x-autobe-specification":
70
+ "Authorization token comes from the session table.",
71
+ description: "Authorization token.",
72
+ $ref: "#/components/schemas/IAuthorizationToken",
73
+ };
74
+ if (value.required.includes("token") === false)
75
+ value.required.push("token");
76
+ } else {
77
+ value.properties = {
78
+ ...parent.properties,
79
+ ...value.properties,
80
+ };
81
+ value.properties.token = {
82
+ "x-autobe-specification":
83
+ "Authorization token comes from the session table.",
84
+ description: "Authorization token.",
85
+ $ref: "#/components/schemas/IAuthorizationToken",
86
+ };
87
+ value.required = Array.from(
88
+ new Set([...parent.required, ...value.required]),
89
+ );
90
+ if (value.required.includes("id") === false) value.required.push("id");
91
+ if (value.required.includes("token") === false)
92
+ value.required.push("token");
93
+ }
94
+ }
95
+ };
96
+
97
+ export const finalize = (props: {
98
+ application: AutoBeDatabase.IApplication;
99
+ operations: AutoBeOpenApi.IOperation[];
100
+ collection: AutoBeJsonSchemaCollection;
101
+ }): void => {
102
+ removeDuplicated(props);
103
+ fixTimestamps({
104
+ application: props.application,
105
+ document: {
106
+ operations: props.operations,
107
+ components: {
108
+ schemas: props.collection.schemas,
109
+ authorizations: [],
110
+ },
111
+ },
112
+ });
113
+ linkRelatedModels({
114
+ application: props.application,
115
+ document: {
116
+ operations: props.operations,
117
+ components: {
118
+ schemas: props.collection.schemas,
119
+ authorizations: [],
120
+ },
121
+ },
122
+ });
123
+ };
124
+
125
+ export const removeUnused = (props: {
126
+ operations: AutoBeOpenApi.IOperation[];
127
+ schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>;
128
+ }): void => {
129
+ while (true) {
130
+ const used: Set<string> = new Set();
131
+ const visit = (schema: AutoBeOpenApi.IJsonSchema): void =>
132
+ OpenApiTypeChecker.visit({
133
+ components: { schemas: props.schemas },
134
+ schema,
135
+ closure: (next) => {
136
+ if (OpenApiTypeChecker.isReference(next)) {
137
+ const key: string = next.$ref.split("/").pop()!;
138
+ used.add(key);
139
+ }
140
+ },
141
+ });
142
+ for (const op of props.operations) {
143
+ if (op.requestBody !== null)
144
+ visit({
145
+ $ref: `#/components/schemas/${op.requestBody.typeName}`,
146
+ });
147
+ if (op.responseBody !== null)
148
+ visit({
149
+ $ref: `#/components/schemas/${op.responseBody.typeName}`,
150
+ });
151
+ }
152
+
153
+ const complete: boolean =
154
+ Object.keys(props.schemas).length === 0 ||
155
+ Object.keys(props.schemas).every((key) => used.has(key) === true);
156
+ if (complete === true) break;
157
+ for (const key of Object.keys(props.schemas))
158
+ if (used.has(key) === false) delete props.schemas[key];
159
+ }
160
+ };
161
+
162
+ const removeDuplicated = (props: {
163
+ operations: AutoBeOpenApi.IOperation[];
164
+ collection: AutoBeJsonSchemaCollection;
165
+ }): void => {
166
+ // gather duplicated schemas
167
+ const correct: Map<string, string> = new Map();
168
+ for (const key of Object.keys(props.collection.schemas)) {
169
+ if (key.includes(".") === false) continue;
170
+ const dotRemoved: string = key.replace(".", "");
171
+ if (props.collection.schemas[dotRemoved] === undefined) continue;
172
+ correct.set(dotRemoved, key);
173
+ }
174
+
175
+ // fix operations' references
176
+ for (const op of props.operations) {
177
+ if (op.requestBody && correct.has(op.requestBody.typeName))
178
+ op.requestBody.typeName = correct.get(op.requestBody.typeName)!;
179
+ if (op.responseBody && correct.has(op.responseBody.typeName))
180
+ op.responseBody.typeName = correct.get(op.responseBody.typeName)!;
181
+ }
182
+
183
+ // fix schemas' references
184
+ const $refChangers: Map<OpenApi.IJsonSchema, () => void> = new Map();
185
+ for (const value of Object.values(props.collection.schemas))
186
+ OpenApiTypeChecker.visit({
187
+ components: { schemas: props.collection.schemas },
188
+ schema: value,
189
+ closure: (next) => {
190
+ if (OpenApiTypeChecker.isReference(next) === false) return;
191
+ const x: string = next.$ref.split("/").pop()!;
192
+ const y: string | undefined = correct.get(x);
193
+ if (y === undefined) return;
194
+ $refChangers.set(
195
+ next,
196
+ () => (next.$ref = `#/components/schemas/${y}`),
197
+ );
198
+ },
199
+ });
200
+ for (const fn of $refChangers.values()) fn();
201
+
202
+ // remove duplicated schemas
203
+ for (const key of correct.keys()) props.collection.delete(key);
204
+ };
205
+
206
+ const fixTimestamps = (props: {
207
+ document: AutoBeOpenApi.IDocument;
208
+ application: AutoBeDatabase.IApplication;
209
+ }): void => {
210
+ const entireModels: AutoBeDatabase.IModel[] = props.application.files
211
+ .map((f) => f.models)
212
+ .flat();
213
+ for (const value of Object.values(props.document.components.schemas)) {
214
+ if (AutoBeOpenApiTypeChecker.isObject(value) === false) continue;
215
+
216
+ const model: AutoBeDatabase.IModel | undefined = value[
217
+ "x-autobe-database-schema"
218
+ ]
219
+ ? entireModels.find((m) => m.name === value["x-autobe-database-schema"])
220
+ : undefined;
221
+ if (model === undefined) continue;
222
+
223
+ const properties: string[] = Object.keys(value.properties);
224
+ for (const key of properties) {
225
+ if (
226
+ key !== "created_at" &&
227
+ key !== "updated_at" &&
228
+ key !== "deleted_at"
229
+ )
230
+ continue;
231
+ const column: AutoBeDatabase.IPlainField | undefined =
232
+ model.plainFields.find((c) => c.name === key);
233
+ if (column === undefined) delete value.properties[key];
234
+ }
235
+ }
236
+ };
237
+
238
+ const linkRelatedModels = (props: {
239
+ document: AutoBeOpenApi.IDocument;
240
+ application: AutoBeDatabase.IApplication;
241
+ }): void => {
242
+ const modelDict: Set<string> = new Set(
243
+ props.application.files
244
+ .map((f) => f.models)
245
+ .flat()
246
+ .map((m) => m.name),
247
+ );
248
+ for (const [key, value] of Object.entries(
249
+ props.document.components.schemas,
250
+ )) {
251
+ if (
252
+ AutoBeOpenApiTypeChecker.isObject(value) === false ||
253
+ !!value["x-autobe-database-schema"]?.length
254
+ )
255
+ continue;
256
+
257
+ const typeName: string = key.split(".")[0]!.substring(1);
258
+ const modelName: string =
259
+ AutoBeInterfaceSchemaProgrammer.getDatabaseSchemaName(typeName);
260
+ if (modelDict.has(modelName) === true)
261
+ value["x-autobe-database-schema"] = modelName;
262
+ }
263
+ };
264
+
265
+ /* -----------------------------------------------------------
266
+ PAGINATION
267
+ ----------------------------------------------------------- */
268
+ export const writePageSchema = (
269
+ key: string,
270
+ ): AutoBeOpenApi.IJsonSchemaDescriptive.IObject => ({
271
+ type: "object",
272
+ properties: {
273
+ pagination: {
274
+ "x-autobe-specification": "Pagination information for the page.",
275
+ description: "Page information.",
276
+ $ref: "#/components/schemas/IPage.IPagination",
277
+ },
278
+ data: {
279
+ "x-autobe-specification": `List of records of type ${key}.`,
280
+ description: "List of records.",
281
+ type: "array",
282
+ items: {
283
+ $ref: `#/components/schemas/${key}`,
284
+ },
285
+ },
286
+ },
287
+ required: ["pagination", "data"],
288
+ description: StringUtil.trim`
289
+ A page.
290
+
291
+ Collection of records with pagination information.
292
+ `,
293
+ "x-autobe-specification": `A page containing records of type ${key}.`,
294
+ "x-autobe-database-schema": null, // filled by relation review agent
295
+ });
296
+
297
+ // export const fixPage = (path: string, input: unknown): void => {
298
+ // if (isRecord(input) === false || isRecord(input[path]) === false) return;
299
+ // if (input[path].description) delete input[path].description;
300
+ // if (input[path].required) delete input[path].required;
301
+
302
+ // for (const key of Object.keys(input[path]))
303
+ // if (DEFAULT_SCHEMAS[key] !== undefined)
304
+ // input[path][key] = DEFAULT_SCHEMAS[key];
305
+ // else if (AutoBeJsonSchemaValidator.isPage(key) === true) {
306
+ // const data: string = key.substring("IPage".length);
307
+ // input[path][key] = writePageSchema(data);
308
+ // }
309
+ // };
310
+
311
+ export const getPageName = (key: string): string =>
312
+ key.substring("IPage".length);
313
+
314
+ // const isRecord = (input: unknown): input is Record<string, unknown> =>
315
+ // typeof input === "object" && input !== null;
316
+
317
+ export const DEFAULT_SCHEMAS = (() => {
318
+ const init: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive> =
319
+ (typia.json.schemas<
320
+ [IPage.IPagination, IPage.IRequest, IAuthorizationToken, IEntity]
321
+ >().components?.schemas ?? {}) as Record<
322
+ string,
323
+ AutoBeOpenApi.IJsonSchemaDescriptive
324
+ >;
325
+ for (const value of Object.values(init))
326
+ AutoBeOpenApiTypeChecker.visit({
327
+ components: {
328
+ schemas: init,
329
+ authorizations: [],
330
+ },
331
+ schema: value,
332
+ closure: (next) => {
333
+ if (AutoBeOpenApiTypeChecker.isObject(next)) {
334
+ next["x-autobe-database-schema"] = null;
335
+ }
336
+ },
337
+ });
338
+ return init;
339
+ })();
340
+
341
+ /* -----------------------------------------------------------
342
+ PLUGIN
343
+ ----------------------------------------------------------- */
344
+ export const fixDesign = (
345
+ design: AutoBeInterfaceSchemaDesign,
346
+ ): AutoBeOpenApi.IJsonSchema => {
347
+ const emended: AutoBeOpenApi.IJsonSchema = fixSchema(design.schema);
348
+ const final: AutoBeOpenApi.IJsonSchema = {
349
+ ...emended,
350
+ ...({
351
+ description: design.description,
352
+ "x-autobe-specification": design.specification,
353
+ } satisfies Pick<
354
+ AutoBeOpenApi.IJsonSchemaDescriptive,
355
+ "description" | "x-autobe-specification"
356
+ >),
357
+ };
358
+ if (AutoBeOpenApiTypeChecker.isObject(final))
359
+ final["x-autobe-database-schema"] = design.databaseSchema;
360
+ return final;
361
+ };
362
+
363
+ export const fixSchema = <Schema extends AutoBeOpenApi.IJsonSchema>(
364
+ schema: Schema,
365
+ ): Schema => {
366
+ const id: string = v7();
367
+ const emended: AutoBeOpenApi.IJsonSchema = (
368
+ (OpenApiConverter.upgradeComponents({
369
+ schemas: {
370
+ [id]: schema,
371
+ },
372
+ }).schemas ?? {}) as Record<string, AutoBeOpenApi.IJsonSchema>
373
+ )[id];
374
+
375
+ const visited: WeakSet<object> = new WeakSet();
376
+ if (AutoBeOpenApiTypeChecker.isObject(emended)) {
377
+ visited.add(emended);
378
+ for (const v of Object.values(emended.properties)) visited.add(v);
379
+ }
380
+
381
+ AutoBeOpenApiTypeChecker.visit({
382
+ components: {
383
+ authorizations: [],
384
+ schemas: {},
385
+ },
386
+ schema: emended,
387
+ closure(next) {
388
+ if (visited.has(next) === false)
389
+ for (const k of Object.keys(next))
390
+ if (k.startsWith("x-")) {
391
+ // biome-ignore lint: intended
392
+ delete (next as any)[k];
393
+ }
394
+ if (AutoBeOpenApiTypeChecker.isString(next)) fixStringSchema(next);
395
+ else if (AutoBeOpenApiTypeChecker.isArray(next)) fixArraySchema(next);
396
+ else if (AutoBeOpenApiTypeChecker.isInteger(next))
397
+ fixIntegerSchema(next);
398
+ else if (AutoBeOpenApiTypeChecker.isNumber(next)) fixNumberSchema(next);
399
+ },
400
+ });
401
+
402
+ const result: Schema = emended as Schema;
403
+ if (AutoBeOpenApiTypeChecker.isObject(result))
404
+ for (const [key, value] of Object.entries(result.properties)) {
405
+ if (key !== "id" && key.endsWith("_id") === false) continue;
406
+ else if (AutoBeOpenApiTypeChecker.isString(value))
407
+ fixReferenceIdSchema(value);
408
+ else if (AutoBeOpenApiTypeChecker.isOneOf(value)) {
409
+ const str: AutoBeOpenApi.IJsonSchema.IString | undefined =
410
+ value.oneOf.find((v) => AutoBeOpenApiTypeChecker.isString(v));
411
+ if (str !== undefined) fixReferenceIdSchema(str);
412
+ }
413
+ }
414
+ return result;
415
+ };
416
+
417
+ const convertConst = (
418
+ schema:
419
+ | AutoBeOpenApi.IJsonSchema.INumber
420
+ | AutoBeOpenApi.IJsonSchema.IInteger,
421
+ value: number,
422
+ ): void => {
423
+ // biome-ignore lint: @todo
424
+ const description: string | undefined = (schema as any).description;
425
+
426
+ for (const key of Object.keys(schema)) {
427
+ // biome-ignore lint: @todo
428
+ delete (schema as any)[key];
429
+ }
430
+
431
+ // biome-ignore lint: @todo
432
+ (schema as any).const = value;
433
+ if (description !== undefined) {
434
+ // biome-ignore lint: @todo
435
+ (schema as any).description = description;
436
+ }
437
+ };
438
+
439
+ const fixStringSchema = (schema: AutoBeOpenApi.IJsonSchema.IString): void => {
440
+ if (schema.format !== undefined) {
441
+ delete schema.pattern;
442
+ if (
443
+ schema.format === "uuid" ||
444
+ schema.format === "ipv4" ||
445
+ schema.format === "ipv6" ||
446
+ schema.format === "date" ||
447
+ schema.format === "date-time" ||
448
+ schema.format === "time"
449
+ ) {
450
+ delete schema.minLength;
451
+ delete schema.maxLength;
452
+ delete schema.contentMediaType;
453
+ }
454
+ }
455
+ if (schema.contentMediaType === "") delete schema.contentMediaType;
456
+ if (schema.minLength === 0) delete schema.minLength;
457
+ };
458
+
459
+ const fixArraySchema = (schema: AutoBeOpenApi.IJsonSchema.IArray): void => {
460
+ if (schema.minItems === 0) delete schema.minItems;
461
+ };
462
+
463
+ /**
464
+ * Fix integer schema by converting single valid value ranges to const.
465
+ *
466
+ * Handles:
467
+ *
468
+ * - Minimum === maximum → const
469
+ * - Minimum: N, exclusiveMaximum: N+1 → const N
470
+ * - ExclusiveMinimum: N-1, maximum: N → const N
471
+ * - ExclusiveMinimum: N-1, exclusiveMaximum: N+1 → const N
472
+ */
473
+ const fixIntegerSchema = (
474
+ schema: AutoBeOpenApi.IJsonSchema.IInteger,
475
+ ): void => {
476
+ const value: number | undefined = (() => {
477
+ if (schema.minimum !== undefined && schema.maximum === schema.minimum)
478
+ return schema.minimum;
479
+ if (
480
+ schema.minimum !== undefined &&
481
+ schema.exclusiveMaximum === schema.minimum + 1
482
+ )
483
+ return schema.minimum;
484
+ if (
485
+ schema.maximum !== undefined &&
486
+ schema.exclusiveMinimum === schema.maximum - 1
487
+ )
488
+ return schema.maximum;
489
+ if (
490
+ schema.exclusiveMinimum !== undefined &&
491
+ schema.exclusiveMaximum === schema.exclusiveMinimum + 2
492
+ )
493
+ return schema.exclusiveMinimum + 1;
494
+ return undefined;
495
+ })();
496
+
497
+ if (value !== undefined) convertConst(schema, value);
498
+ };
499
+
500
+ /**
501
+ * Fix number schema by converting single valid value ranges to const.
502
+ *
503
+ * Handles:
504
+ *
505
+ * - Minimum === maximum → const
506
+ */
507
+ const fixNumberSchema = (schema: AutoBeOpenApi.IJsonSchema.INumber): void => {
508
+ // minimum === maximum → const
509
+ if (
510
+ schema.minimum !== undefined &&
511
+ schema.maximum !== undefined &&
512
+ schema.minimum === schema.maximum
513
+ )
514
+ return convertConst(schema, schema.minimum);
515
+ };
516
+
517
+ const fixReferenceIdSchema = (
518
+ schema: AutoBeOpenApi.IJsonSchema.IString,
519
+ ): void => {
520
+ schema.format = "uuid";
521
+ fixStringSchema(schema);
522
+ };
523
+ }
524
+
525
+ namespace IPage {
526
+ /**
527
+ * Pagination metadata containing current page position and total data
528
+ * statistics.
529
+ *
530
+ * This interface provides comprehensive pagination information returned
531
+ * alongside paginated list data. It enables clients to implement navigation
532
+ * controls, display progress indicators, and determine data boundaries for UI
533
+ * rendering.
534
+ *
535
+ * @x-autobe-specification Pagination metadata for paginated list responses. Included in all list endpoint responses.
536
+ */
537
+ export interface IPagination {
538
+ /**
539
+ * Current page number being viewed (1-indexed).
540
+ *
541
+ * Indicates which page of results is currently being returned. Page
542
+ * numbering starts from 1, so the first page is page 1 (not 0). This value
543
+ * reflects the page parameter from the request after validation and bounds
544
+ * checking.
545
+ *
546
+ * @x-autobe-specification 1-indexed current page number. Defaults to 1.
547
+ */
548
+ current: number & tags.Type<"uint32">;
549
+
550
+ /**
551
+ * Maximum number of records per page.
552
+ *
553
+ * Defines the upper bound on how many records can be returned in a single
554
+ * page. This corresponds to the limit parameter from the request. The
555
+ * actual number of records in the data array may be less than this value on
556
+ * the final page or when total records are fewer than the limit.
557
+ *
558
+ * @x-autobe-specification Maximum records per page. Actual count may be less on last page.
559
+ */
560
+ limit: number & tags.Type<"uint32">;
561
+
562
+ /**
563
+ * Total count of all records matching the query criteria.
564
+ *
565
+ * Represents the complete number of records available across all pages, not
566
+ * just the current page. This value is computed via a COUNT query and is
567
+ * essential for calculating total pages and displaying pagination UI
568
+ * elements like "Showing 1-10 of 150 results".
569
+ *
570
+ * @x-autobe-specification Total record count across all pages.
571
+ */
572
+ records: number & tags.Type<"uint32">;
573
+
574
+ /**
575
+ * Total number of pages available.
576
+ *
577
+ * Calculated as ceiling of {@link records} divided by {@link limit}. When
578
+ * records is 0, pages will also be 0. This value enables clients to render
579
+ * page navigation controls and validate page bounds.
580
+ *
581
+ * @x-autobe-specification Total pages. Calculated as Math.ceil(records / limit).
582
+ */
583
+ pages: number & tags.Type<"uint32">;
584
+ }
585
+
586
+ /**
587
+ * Pagination request parameters for list endpoints.
588
+ *
589
+ * Defines the query parameters used to control pagination when requesting
590
+ * list data. Both parameters are optional with sensible defaults, allowing
591
+ * clients to fetch data without specifying pagination if default behavior is
592
+ * acceptable.
593
+ *
594
+ * @x-autobe-specification Pagination query parameters for list endpoints. All fields optional.
595
+ */
596
+ export interface IRequest {
597
+ /**
598
+ * Target page number to retrieve (1-indexed).
599
+ *
600
+ * Specifies which page of results to return. Page numbering starts from 1.
601
+ * If omitted, null, or undefined, defaults to page 1 (first page).
602
+ * Requesting a page beyond the available range returns an empty data array
603
+ * with valid pagination metadata reflecting the actual totals.
604
+ *
605
+ * @x-autobe-specification 1-indexed page number. Defaults to 1 if not provided.
606
+ */
607
+ page?: null | (number & tags.Type<"uint32">);
608
+
609
+ /**
610
+ * Maximum number of records to return per page.
611
+ *
612
+ * Controls how many records are included in each page response. If omitted,
613
+ * null, or undefined, defaults to 100 records per page. The server may
614
+ * enforce upper bounds to prevent excessive resource consumption on large
615
+ * requests.
616
+ *
617
+ * @default 100
618
+ *
619
+ * @x-autobe-specification Maximum records per page. Defaults to 100 if not provided.
620
+ */
621
+ limit?: null | (number & tags.Type<"uint32">);
622
+ }
623
+ }
624
+
625
+ /**
626
+ * JWT-based authorization token pair with expiration metadata.
627
+ *
628
+ * Provides a complete authentication token structure containing both access and
629
+ * refresh tokens along with their respective expiration timestamps. This
630
+ * dual-token pattern enables secure, stateless authentication with automatic
631
+ * session renewal capabilities.
632
+ *
633
+ * The access token is short-lived for security, while the refresh token allows
634
+ * obtaining new access tokens without requiring the user to re-enter
635
+ * credentials. This structure is automatically included in authentication
636
+ * responses across all generated backend applications.
637
+ *
638
+ * @x-autobe-specification Dual-token authentication structure with access/refresh tokens and expiration info.
639
+ */
640
+ interface IAuthorizationToken {
641
+ /**
642
+ * Short-lived JWT access token for authenticating API requests.
643
+ *
644
+ * This token must be included in the Authorization header using the Bearer
645
+ * scheme (e.g., `Authorization: Bearer {access}`) for all endpoints requiring
646
+ * authentication. The token contains encoded claims including user identity,
647
+ * roles, and permissions. Typically expires within 15-60 minutes for
648
+ * security; use the refresh token to obtain a new access token when expired.
649
+ *
650
+ * @x-autobe-specification JWT access token. Use in Authorization header as "Bearer {access}".
651
+ */
652
+ access: string;
653
+
654
+ /**
655
+ * Long-lived refresh token for obtaining new access tokens.
656
+ *
657
+ * Used to request new access tokens when the current access token expires,
658
+ * allowing session continuation without re-authentication. Should be stored
659
+ * securely and transmitted only to the token refresh endpoint. Typical
660
+ * lifetime ranges from 7 to 30 days depending on security requirements.
661
+ *
662
+ * @x-autobe-specification Refresh token for obtaining new access tokens without re-authentication.
663
+ */
664
+ refresh: string;
665
+
666
+ /**
667
+ * ISO 8601 timestamp when the access token expires.
668
+ *
669
+ * After this timestamp, the access token will be rejected by authenticated
670
+ * endpoints. Clients should proactively refresh before expiration to maintain
671
+ * seamless user experience. A common strategy is to refresh when remaining
672
+ * time falls below 5 minutes. This timestamp is also embedded within the JWT
673
+ * itself as the "exp" claim.
674
+ *
675
+ * @x-autobe-specification Access token expiration timestamp in ISO 8601 format.
676
+ */
677
+ expired_at: string & tags.Format<"date-time">;
678
+
679
+ /**
680
+ * ISO 8601 timestamp indicating the absolute session expiration deadline.
681
+ *
682
+ * Represents the latest possible time the refresh token can be used. Once
683
+ * this timestamp is reached, the user must fully re-authenticate with
684
+ * credentials. This defines the maximum session duration regardless of
685
+ * activity. If refresh token rotation is enabled, this deadline may extend
686
+ * with each successful refresh.
687
+ *
688
+ * @x-autobe-specification Refresh token expiration timestamp. Re-authentication required after this time.
689
+ */
690
+ refreshable_until: string & tags.Format<"date-time">;
691
+ }
692
+
693
+ /**
694
+ * Base entity interface providing standard primary key identification.
695
+ *
696
+ * Serves as the foundational interface for all database entities in the
697
+ * generated application. Every model and record type extends this interface,
698
+ * ensuring consistent identification semantics across all database tables and
699
+ * API responses.
700
+ *
701
+ * @x-autobe-specification Base interface for all database entities. Contains the primary key.
702
+ */
703
+ interface IEntity {
704
+ /**
705
+ * Unique identifier for this entity (UUID format).
706
+ *
707
+ * Auto-generated primary key using UUID format. This value is assigned by the
708
+ * system upon record creation and cannot be modified afterward. All foreign
709
+ * key relationships in the database reference this field.
710
+ *
711
+ * @x-autobe-specification Primary key in UUID format. Auto-generated, read-only.
712
+ */
713
+ id: string & tags.Format<"uuid">;
714
+ }