@autobe/agent 0.30.4-dev.20260324 → 0.30.5

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 (221) hide show
  1. package/LICENSE +661 -661
  2. package/lib/constants/AutoBeSystemPromptConstant.d.ts +5 -4
  3. package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
  4. package/lib/describe/image/orchestrateImageDescribeDraft.js +6 -6
  5. package/lib/describe/image/structures/IAutoBeImageDescribeDraftApplication.d.ts +12 -63
  6. package/lib/index.mjs +2918 -2842
  7. package/lib/index.mjs.map +1 -1
  8. package/lib/orchestrate/analyze/orchestrateAnalyzeExtractDecisions.js +8 -8
  9. package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.js +36 -37
  10. package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.js.map +1 -1
  11. package/lib/orchestrate/analyze/orchestrateAnalyzeScenarioReview.js +7 -7
  12. package/lib/orchestrate/analyze/orchestrateAnalyzeSectionCrossFileReview.js +55 -42
  13. package/lib/orchestrate/analyze/orchestrateAnalyzeSectionCrossFileReview.js.map +1 -1
  14. package/lib/orchestrate/analyze/orchestrateAnalyzeSectionReview.js +67 -54
  15. package/lib/orchestrate/analyze/orchestrateAnalyzeSectionReview.js.map +1 -1
  16. package/lib/orchestrate/analyze/orchestrateAnalyzeWriteSection.js +24 -25
  17. package/lib/orchestrate/analyze/orchestrateAnalyzeWriteSection.js.map +1 -1
  18. package/lib/orchestrate/analyze/orchestrateAnalyzeWriteSectionPatch.js +24 -25
  19. package/lib/orchestrate/analyze/orchestrateAnalyzeWriteSectionPatch.js.map +1 -1
  20. package/lib/orchestrate/analyze/orchestrateAnalyzeWriteUnit.js +30 -31
  21. package/lib/orchestrate/analyze/orchestrateAnalyzeWriteUnit.js.map +1 -1
  22. package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeExtractDecisionsApplication.d.ts +14 -52
  23. package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeScenarioApplication.d.ts +23 -96
  24. package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeScenarioReviewApplication.d.ts +12 -40
  25. package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeSectionCrossFileReviewApplication.d.ts +30 -88
  26. package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeSectionReviewApplication.d.ts +35 -94
  27. package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeWriteSectionApplication.d.ts +23 -93
  28. package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeWriteUnitApplication.d.ts +15 -88
  29. package/lib/orchestrate/common/histories/transformPreviousAndLatestCorrectHistory.js +76 -31
  30. package/lib/orchestrate/common/histories/transformPreviousAndLatestCorrectHistory.js.map +1 -1
  31. package/lib/orchestrate/common/orchestrateCommonCorrectCasting.js +7 -7
  32. package/lib/orchestrate/common/structures/IAnalysisSectionEntry.d.ts +2 -8
  33. package/lib/orchestrate/common/structures/IAutoBeCommonCorrectCastingApplication.d.ts +8 -50
  34. package/lib/orchestrate/common/structures/IAutoBePreliminaryCollection.d.ts +1 -9
  35. package/lib/orchestrate/common/structures/IAutoBePreliminaryGetAnalysisSections.d.ts +4 -23
  36. package/lib/orchestrate/common/structures/IAutoBePreliminaryGetDatabaseSchemas.d.ts +3 -21
  37. package/lib/orchestrate/common/structures/IAutoBePreliminaryGetInterfaceOperations.d.ts +4 -22
  38. package/lib/orchestrate/common/structures/IAutoBePreliminaryGetInterfaceSchemas.d.ts +4 -22
  39. package/lib/orchestrate/common/structures/IAutoBePreliminaryGetPreviousAnalysisSections.d.ts +5 -17
  40. package/lib/orchestrate/common/structures/IAutoBePreliminaryGetPreviousDatabaseSchemas.d.ts +7 -76
  41. package/lib/orchestrate/common/structures/IAutoBePreliminaryGetPreviousInterfaceOperations.d.ts +6 -89
  42. package/lib/orchestrate/common/structures/IAutoBePreliminaryGetPreviousInterfaceSchemas.d.ts +7 -93
  43. package/lib/orchestrate/common/structures/IAutoBePreliminaryGetRealizeCollectors.d.ts +3 -22
  44. package/lib/orchestrate/common/structures/IAutoBePreliminaryGetRealizeTransformers.d.ts +3 -22
  45. package/lib/orchestrate/interface/orchestrateInterfaceAuthorization.js +114 -139
  46. package/lib/orchestrate/interface/orchestrateInterfaceAuthorization.js.map +1 -1
  47. package/lib/orchestrate/interface/orchestrateInterfaceEndpointReview.js +90 -91
  48. package/lib/orchestrate/interface/orchestrateInterfaceEndpointReview.js.map +1 -1
  49. package/lib/orchestrate/interface/orchestrateInterfaceEndpointWrite.js +58 -59
  50. package/lib/orchestrate/interface/orchestrateInterfaceEndpointWrite.js.map +1 -1
  51. package/lib/orchestrate/interface/orchestrateInterfaceGroup.js +58 -59
  52. package/lib/orchestrate/interface/orchestrateInterfaceGroup.js.map +1 -1
  53. package/lib/orchestrate/interface/orchestrateInterfaceOperation.js +108 -132
  54. package/lib/orchestrate/interface/orchestrateInterfaceOperation.js.map +1 -1
  55. package/lib/orchestrate/interface/orchestrateInterfaceOperationReview.js +72 -72
  56. package/lib/orchestrate/interface/orchestrateInterfacePrerequisite.js +76 -77
  57. package/lib/orchestrate/interface/orchestrateInterfacePrerequisite.js.map +1 -1
  58. package/lib/orchestrate/interface/orchestrateInterfaceSchemaCasting.js +130 -159
  59. package/lib/orchestrate/interface/orchestrateInterfaceSchemaCasting.js.map +1 -1
  60. package/lib/orchestrate/interface/orchestrateInterfaceSchemaComplement.js +126 -155
  61. package/lib/orchestrate/interface/orchestrateInterfaceSchemaComplement.js.map +1 -1
  62. package/lib/orchestrate/interface/orchestrateInterfaceSchemaRefine.js +114 -142
  63. package/lib/orchestrate/interface/orchestrateInterfaceSchemaRefine.js.map +1 -1
  64. package/lib/orchestrate/interface/orchestrateInterfaceSchemaRename.js +5 -5
  65. package/lib/orchestrate/interface/orchestrateInterfaceSchemaReview.js +100 -129
  66. package/lib/orchestrate/interface/orchestrateInterfaceSchemaReview.js.map +1 -1
  67. package/lib/orchestrate/interface/orchestrateInterfaceSchemaWrite.js +120 -149
  68. package/lib/orchestrate/interface/orchestrateInterfaceSchemaWrite.js.map +1 -1
  69. package/lib/orchestrate/interface/structures/IAutoBeInterfaceAuthorizationApplication.d.ts +10 -97
  70. package/lib/orchestrate/interface/structures/IAutoBeInterfaceEndpointReviewApplication.d.ts +14 -83
  71. package/lib/orchestrate/interface/structures/IAutoBeInterfaceEndpointWriteApplication.d.ts +12 -90
  72. package/lib/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.d.ts +12 -80
  73. package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.d.ts +21 -116
  74. package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationReviewApplication.d.ts +24 -112
  75. package/lib/orchestrate/interface/structures/IAutoBeInterfacePrerequisiteApplication.d.ts +11 -83
  76. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.d.ts +11 -76
  77. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaCastingApplication.d.ts +18 -96
  78. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaComplementApplication.d.ts +11 -76
  79. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaRefineApplication.d.ts +25 -107
  80. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaRenameApplication.d.ts +5 -31
  81. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaReviewApplication.d.ts +6 -42
  82. package/lib/orchestrate/interface/utils/AutoBeJsonSchemaValidator.js +283 -283
  83. package/lib/orchestrate/prisma/orchestratePrismaAuthorization.js +41 -41
  84. package/lib/orchestrate/prisma/orchestratePrismaAuthorizationReview.js +62 -63
  85. package/lib/orchestrate/prisma/orchestratePrismaAuthorizationReview.js.map +1 -1
  86. package/lib/orchestrate/prisma/orchestratePrismaComponent.js +40 -41
  87. package/lib/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -1
  88. package/lib/orchestrate/prisma/orchestratePrismaComponentReview.js +60 -61
  89. package/lib/orchestrate/prisma/orchestratePrismaComponentReview.js.map +1 -1
  90. package/lib/orchestrate/prisma/orchestratePrismaCorrect.js +112 -116
  91. package/lib/orchestrate/prisma/orchestratePrismaCorrect.js.map +1 -1
  92. package/lib/orchestrate/prisma/orchestratePrismaGroup.js +48 -49
  93. package/lib/orchestrate/prisma/orchestratePrismaGroup.js.map +1 -1
  94. package/lib/orchestrate/prisma/orchestratePrismaGroupReview.js +70 -71
  95. package/lib/orchestrate/prisma/orchestratePrismaGroupReview.js.map +1 -1
  96. package/lib/orchestrate/prisma/orchestratePrismaSchema.js +118 -122
  97. package/lib/orchestrate/prisma/orchestratePrismaSchema.js.map +1 -1
  98. package/lib/orchestrate/prisma/orchestratePrismaSchemaReview.js +126 -131
  99. package/lib/orchestrate/prisma/orchestratePrismaSchemaReview.js.map +1 -1
  100. package/lib/orchestrate/prisma/structures/IAutoBeDatabaseAuthorizationApplication.d.ts +22 -99
  101. package/lib/orchestrate/prisma/structures/IAutoBeDatabaseAuthorizationReviewApplication.d.ts +12 -109
  102. package/lib/orchestrate/prisma/structures/IAutoBeDatabaseComponentApplication.d.ts +14 -100
  103. package/lib/orchestrate/prisma/structures/IAutoBeDatabaseComponentReviewApplication.d.ts +15 -108
  104. package/lib/orchestrate/prisma/structures/IAutoBeDatabaseCorrectApplication.d.ts +24 -106
  105. package/lib/orchestrate/prisma/structures/IAutoBeDatabaseGroupApplication.d.ts +13 -76
  106. package/lib/orchestrate/prisma/structures/IAutoBeDatabaseGroupReviewApplication.d.ts +13 -111
  107. package/lib/orchestrate/prisma/structures/IAutoBeDatabaseSchemaApplication.d.ts +26 -97
  108. package/lib/orchestrate/prisma/structures/IAutoBeDatabaseSchemaReviewApplication.d.ts +16 -93
  109. package/lib/orchestrate/realize/histories/transformRealizeOperationCorrectHistory.js +1 -1
  110. package/lib/orchestrate/realize/histories/transformRealizeOperationCorrectHistory.js.map +1 -1
  111. package/lib/orchestrate/realize/histories/transformRealizeOperationWriteHistory.js +1 -1
  112. package/lib/orchestrate/realize/histories/transformRealizeOperationWriteHistory.js.map +1 -1
  113. package/lib/orchestrate/realize/histories/transformRealizeTransformerCorrectHistory.js +20 -2
  114. package/lib/orchestrate/realize/histories/transformRealizeTransformerCorrectHistory.js.map +1 -1
  115. package/lib/orchestrate/realize/histories/transformRealizeTransformerWriteHistory.js +22 -2
  116. package/lib/orchestrate/realize/histories/transformRealizeTransformerWriteHistory.js.map +1 -1
  117. package/lib/orchestrate/realize/internal/orchestrateRealizeCorrectCasting.js +7 -7
  118. package/lib/orchestrate/realize/internal/orchestrateRealizeCorrectOverall.js +86 -6
  119. package/lib/orchestrate/realize/internal/orchestrateRealizeCorrectOverall.js.map +1 -1
  120. package/lib/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js +38 -38
  121. package/lib/orchestrate/realize/orchestrateRealizeAuthorizationWrite.js +34 -34
  122. package/lib/orchestrate/realize/orchestrateRealizeCollectorCorrectOverall.js +38 -38
  123. package/lib/orchestrate/realize/orchestrateRealizeCollectorPlan.js +54 -54
  124. package/lib/orchestrate/realize/orchestrateRealizeCollectorWrite.js +36 -36
  125. package/lib/orchestrate/realize/orchestrateRealizeOperationCorrectOverall.js +44 -44
  126. package/lib/orchestrate/realize/orchestrateRealizeOperationWrite.js +42 -42
  127. package/lib/orchestrate/realize/orchestrateRealizeTransformerCorrectCasting.js +1 -0
  128. package/lib/orchestrate/realize/orchestrateRealizeTransformerCorrectCasting.js.map +1 -1
  129. package/lib/orchestrate/realize/orchestrateRealizeTransformerCorrectOverall.js +46 -46
  130. package/lib/orchestrate/realize/orchestrateRealizeTransformerPlan.js +36 -36
  131. package/lib/orchestrate/realize/orchestrateRealizeTransformerWrite.js +44 -44
  132. package/lib/orchestrate/realize/programmers/AutoBeRealizeTransformerProgrammer.d.ts +18 -0
  133. package/lib/orchestrate/realize/programmers/AutoBeRealizeTransformerProgrammer.js +167 -8
  134. package/lib/orchestrate/realize/programmers/AutoBeRealizeTransformerProgrammer.js.map +1 -1
  135. package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.d.ts +17 -71
  136. package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationWriteApplication.d.ts +32 -92
  137. package/lib/orchestrate/realize/structures/IAutoBeRealizeCollectorCorrectApplication.d.ts +32 -114
  138. package/lib/orchestrate/realize/structures/IAutoBeRealizeCollectorPlanApplication.d.ts +29 -106
  139. package/lib/orchestrate/realize/structures/IAutoBeRealizeCollectorWriteApplication.d.ts +38 -131
  140. package/lib/orchestrate/realize/structures/IAutoBeRealizeOperationCorrectApplication.d.ts +16 -71
  141. package/lib/orchestrate/realize/structures/IAutoBeRealizeOperationWriteApplication.d.ts +16 -73
  142. package/lib/orchestrate/realize/structures/IAutoBeRealizeTransformerCorrectApplication.d.ts +37 -155
  143. package/lib/orchestrate/realize/structures/IAutoBeRealizeTransformerPlanApplication.d.ts +25 -88
  144. package/lib/orchestrate/realize/structures/IAutoBeRealizeTransformerWriteApplication.d.ts +48 -181
  145. package/lib/orchestrate/realize/utils/generateTS2339Hints.d.ts +5 -3
  146. package/lib/orchestrate/realize/utils/generateTS2339Hints.js +37 -19
  147. package/lib/orchestrate/realize/utils/generateTS2339Hints.js.map +1 -1
  148. package/lib/orchestrate/test/histories/transformTestOperationWriteHistory.js +2 -2
  149. package/lib/orchestrate/test/orchestrateTestScenario.js +22 -22
  150. package/lib/orchestrate/test/orchestrateTestScenarioReview.js +22 -22
  151. package/package.json +5 -5
  152. package/src/AutoBeMockAgent.ts +283 -283
  153. package/src/constants/AutoBeSystemPromptConstant.ts +5 -4
  154. package/src/describe/image/structures/IAutoBeImageDescribeDraftApplication.ts +12 -63
  155. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeExtractDecisionsApplication.ts +14 -52
  156. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeScenarioApplication.ts +23 -96
  157. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeScenarioReviewApplication.ts +12 -40
  158. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeSectionCrossFileReviewApplication.ts +30 -88
  159. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeSectionReviewApplication.ts +35 -94
  160. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeWriteSectionApplication.ts +23 -93
  161. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeWriteUnitApplication.ts +15 -88
  162. package/src/orchestrate/common/histories/transformPreviousAndLatestCorrectHistory.ts +92 -31
  163. package/src/orchestrate/common/structures/IAnalysisSectionEntry.ts +2 -8
  164. package/src/orchestrate/common/structures/IAutoBeCommonCorrectCastingApplication.ts +8 -50
  165. package/src/orchestrate/common/structures/IAutoBePreliminaryCollection.ts +1 -9
  166. package/src/orchestrate/common/structures/IAutoBePreliminaryGetAnalysisSections.ts +4 -23
  167. package/src/orchestrate/common/structures/IAutoBePreliminaryGetDatabaseSchemas.ts +3 -21
  168. package/src/orchestrate/common/structures/IAutoBePreliminaryGetInterfaceOperations.ts +4 -22
  169. package/src/orchestrate/common/structures/IAutoBePreliminaryGetInterfaceSchemas.ts +4 -22
  170. package/src/orchestrate/common/structures/IAutoBePreliminaryGetPreviousAnalysisSections.ts +5 -17
  171. package/src/orchestrate/common/structures/IAutoBePreliminaryGetPreviousDatabaseSchemas.ts +7 -76
  172. package/src/orchestrate/common/structures/IAutoBePreliminaryGetPreviousInterfaceOperations.ts +6 -89
  173. package/src/orchestrate/common/structures/IAutoBePreliminaryGetPreviousInterfaceSchemas.ts +7 -93
  174. package/src/orchestrate/common/structures/IAutoBePreliminaryGetRealizeCollectors.ts +3 -22
  175. package/src/orchestrate/common/structures/IAutoBePreliminaryGetRealizeTransformers.ts +3 -22
  176. package/src/orchestrate/interface/orchestrateInterfaceSchemaRefine.ts +291 -291
  177. package/src/orchestrate/interface/orchestrateInterfaceSchemaReview.ts +309 -309
  178. package/src/orchestrate/interface/structures/IAutoBeInterfaceAuthorizationApplication.ts +10 -97
  179. package/src/orchestrate/interface/structures/IAutoBeInterfaceEndpointReviewApplication.ts +14 -83
  180. package/src/orchestrate/interface/structures/IAutoBeInterfaceEndpointWriteApplication.ts +12 -90
  181. package/src/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.ts +12 -80
  182. package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.ts +21 -116
  183. package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationReviewApplication.ts +24 -112
  184. package/src/orchestrate/interface/structures/IAutoBeInterfacePrerequisiteApplication.ts +11 -83
  185. package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.ts +11 -76
  186. package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaCastingApplication.ts +18 -96
  187. package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaComplementApplication.ts +11 -76
  188. package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaRefineApplication.ts +25 -107
  189. package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaRenameApplication.ts +5 -31
  190. package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaReviewApplication.ts +6 -42
  191. package/src/orchestrate/interface/utils/AutoBeJsonSchemaValidator.ts +763 -763
  192. package/src/orchestrate/prisma/structures/IAutoBeDatabaseAuthorizationApplication.ts +22 -99
  193. package/src/orchestrate/prisma/structures/IAutoBeDatabaseAuthorizationReviewApplication.ts +12 -109
  194. package/src/orchestrate/prisma/structures/IAutoBeDatabaseComponentApplication.ts +14 -100
  195. package/src/orchestrate/prisma/structures/IAutoBeDatabaseComponentReviewApplication.ts +15 -108
  196. package/src/orchestrate/prisma/structures/IAutoBeDatabaseCorrectApplication.ts +24 -106
  197. package/src/orchestrate/prisma/structures/IAutoBeDatabaseGroupApplication.ts +13 -76
  198. package/src/orchestrate/prisma/structures/IAutoBeDatabaseGroupReviewApplication.ts +13 -111
  199. package/src/orchestrate/prisma/structures/IAutoBeDatabaseSchemaApplication.ts +26 -97
  200. package/src/orchestrate/prisma/structures/IAutoBeDatabaseSchemaReviewApplication.ts +16 -93
  201. package/src/orchestrate/realize/histories/transformRealizeTransformerCorrectHistory.ts +21 -1
  202. package/src/orchestrate/realize/histories/transformRealizeTransformerWriteHistory.ts +26 -4
  203. package/src/orchestrate/realize/internal/orchestrateRealizeCorrectOverall.ts +125 -9
  204. package/src/orchestrate/realize/orchestrateRealizeTransformerCorrectCasting.ts +1 -0
  205. package/src/orchestrate/realize/programmers/AutoBeRealizeTransformerProgrammer.ts +210 -7
  206. package/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.ts +17 -71
  207. package/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationWriteApplication.ts +32 -92
  208. package/src/orchestrate/realize/structures/IAutoBeRealizeCollectorCorrectApplication.ts +32 -114
  209. package/src/orchestrate/realize/structures/IAutoBeRealizeCollectorPlanApplication.ts +29 -106
  210. package/src/orchestrate/realize/structures/IAutoBeRealizeCollectorWriteApplication.ts +38 -131
  211. package/src/orchestrate/realize/structures/IAutoBeRealizeOperationCorrectApplication.ts +16 -71
  212. package/src/orchestrate/realize/structures/IAutoBeRealizeOperationWriteApplication.ts +16 -73
  213. package/src/orchestrate/realize/structures/IAutoBeRealizeTransformerCorrectApplication.ts +37 -155
  214. package/src/orchestrate/realize/structures/IAutoBeRealizeTransformerPlanApplication.ts +25 -88
  215. package/src/orchestrate/realize/structures/IAutoBeRealizeTransformerWriteApplication.ts +48 -181
  216. package/src/orchestrate/realize/utils/generateTS2339Hints.ts +39 -19
  217. package/src/orchestrate/test/experimental/orchestrateTestCorrect.ast +237 -237
  218. package/src/orchestrate/test/experimental/orchestrateTestWrite.ast +322 -322
  219. package/src/orchestrate/test/experimental/transformTestCorrectHistories.ast +52 -52
  220. package/src/structures/IAutoBeVendor.ts +127 -127
  221. package/README.md +0 -261
@@ -58,6 +58,67 @@ export namespace AutoBeRealizeTransformerProgrammer {
58
58
  return Array.from(unique);
59
59
  }
60
60
 
61
+ export function getRelationMappingTable(props: {
62
+ application: AutoBeDatabase.IApplication;
63
+ model: AutoBeDatabase.IModel;
64
+ }): Array<{
65
+ propertyKey: string;
66
+ targetModel: string;
67
+ relationType: string;
68
+ fkColumns: string;
69
+ }> {
70
+ const result: Array<{
71
+ propertyKey: string;
72
+ targetModel: string;
73
+ relationType: string;
74
+ fkColumns: string;
75
+ }> = [];
76
+
77
+ // belongsTo relations (forward FK on this model)
78
+ for (const f of props.model.foreignFields) {
79
+ result.push({
80
+ propertyKey: f.relation.name,
81
+ targetModel: f.relation.targetModel,
82
+ relationType: "belongsTo",
83
+ fkColumns: f.name,
84
+ });
85
+ }
86
+
87
+ // hasMany/hasOne relations (FK on the other model pointing to this model)
88
+ for (const file of props.application.files) {
89
+ for (const om of file.models) {
90
+ for (const fk of om.foreignFields) {
91
+ if (fk.relation.targetModel === props.model.name) {
92
+ result.push({
93
+ propertyKey: fk.relation.oppositeName,
94
+ targetModel: om.name,
95
+ relationType: fk.unique ? "hasOne" : "hasMany",
96
+ fkColumns: fk.name,
97
+ });
98
+ }
99
+ }
100
+ }
101
+ }
102
+
103
+ return result;
104
+ }
105
+
106
+ export function formatRelationMappingTable(props: {
107
+ application: AutoBeDatabase.IApplication;
108
+ model: AutoBeDatabase.IModel;
109
+ }): string {
110
+ const relations = getRelationMappingTable(props);
111
+ if (relations.length === 0) return "(no relations)";
112
+ return [
113
+ "| propertyKey | Target Model | Relation Type | FK Column(s) |",
114
+ "|---|---|---|---|",
115
+ ...relations.map(
116
+ (r) =>
117
+ `| ${r.propertyKey} | ${r.targetModel} | ${r.relationType} | ${r.fkColumns} |`,
118
+ ),
119
+ ].join("\n");
120
+ }
121
+
61
122
  export function getSelectMappingMetadata(props: {
62
123
  application: AutoBeDatabase.IApplication;
63
124
  model: AutoBeDatabase.IModel;
@@ -81,24 +142,108 @@ export namespace AutoBeRealizeTransformerProgrammer {
81
142
  export function writeTemplate(props: {
82
143
  plan: AutoBeRealizeTransformerPlan;
83
144
  schema: AutoBeOpenApi.IJsonSchemaDescriptive.IObject;
145
+ schemas: Record<string, AutoBeOpenApi.IJsonSchema>;
84
146
  }): string {
147
+ const recursive: string | null = getRecursiveProperty({
148
+ schemas: props.schemas,
149
+ typeName: props.plan.dtoTypeName,
150
+ });
151
+ return recursive !== null
152
+ ? writeRecursiveTemplate({ ...props, recursiveProperty: recursive })
153
+ : writeNormalTemplate(props);
154
+ }
155
+
156
+ function writeNormalTemplate(props: {
157
+ plan: AutoBeRealizeTransformerPlan;
158
+ schema: AutoBeOpenApi.IJsonSchemaDescriptive.IObject;
159
+ }): string {
160
+ const name: string = getName(props.plan.dtoTypeName);
161
+ const dto: string = props.plan.dtoTypeName;
162
+ const table: string = props.plan.databaseSchemaName;
163
+ const properties: string = Object.keys(props.schema.properties)
164
+ .map((k) => ` ${k}: ...,`)
165
+ .join("\n");
85
166
  return StringUtil.trim`
86
- export namespace ${getName(props.plan.dtoTypeName)} {
87
- export type Payload = Prisma.${props.plan.databaseSchemaName}GetPayload<ReturnType<typeof select>>;
167
+ export namespace ${name} {
168
+ export type Payload = Prisma.${table}GetPayload<ReturnType<typeof select>>;
88
169
 
89
170
  export function select() {
171
+ // implicit return type for better type inference
90
172
  return {
91
173
  ...
92
- } satisfies Prisma.${props.plan.databaseSchemaName}FindManyArgs;
174
+ } satisfies Prisma.${table}FindManyArgs;
175
+ }
176
+
177
+ export async function transform(input: Payload): Promise<${dto}> {
178
+ return {
179
+ ${properties}
180
+ };
181
+ }
182
+ }
183
+ `;
184
+ }
185
+
186
+ function writeRecursiveTemplate(props: {
187
+ plan: AutoBeRealizeTransformerPlan;
188
+ schema: AutoBeOpenApi.IJsonSchemaDescriptive.IObject;
189
+ recursiveProperty: string;
190
+ }): string {
191
+ const name: string = getName(props.plan.dtoTypeName);
192
+ const dto: string = props.plan.dtoTypeName;
193
+ const table: string = props.plan.databaseSchemaName;
194
+ const rp: string = props.recursiveProperty;
195
+ const fk: string = `${rp}_id`;
196
+ const properties: string = Object.keys(props.schema.properties)
197
+ .map((k) =>
198
+ k === rp
199
+ ? ` ${k}: input.${fk} ? await cache.get(input.${fk}) : null,`
200
+ : ` ${k}: ...,`,
201
+ )
202
+ .join("\n");
203
+ return StringUtil.trim`
204
+ export namespace ${name} {
205
+ export type Payload = Prisma.${table}GetPayload<ReturnType<typeof select>>;
206
+
207
+ export function select() {
208
+ // implicit return type for better type inference
209
+ return {
210
+ select: {
211
+ ...
212
+ ${fk}: true,
213
+ ${rp}: undefined, // DO NOT select recursive relation
214
+ },
215
+ } satisfies Prisma.${table}FindManyArgs;
93
216
  }
94
217
 
95
- export async function transform(input: Payload): Promise<${props.plan.dtoTypeName}> {
218
+ export async function transform(
219
+ input: Payload,
220
+ cache: VariadicSingleton<Promise<${dto}>, [string]> = createCache(),
221
+ ): Promise<${dto}> {
96
222
  return {
97
- ${Object.keys(props.schema.properties)
98
- .map((k) => ` ${k}: ...,`)
99
- .join("\n")}
223
+ ${properties}
100
224
  };
101
225
  }
226
+
227
+ export async function transformAll(
228
+ inputs: Payload[],
229
+ ): Promise<${dto}[]> {
230
+ const cache = createCache();
231
+ return await ArrayUtil.asyncMap(inputs, (x) => transform(x, cache));
232
+ }
233
+
234
+ function createCache() {
235
+ const cache = new VariadicSingleton(
236
+ async (id: string): Promise<${dto}> => {
237
+ const record =
238
+ await MyGlobal.prisma.${table}.findFirstOrThrow({
239
+ ...select(),
240
+ where: { id },
241
+ });
242
+ return transform(record, cache);
243
+ },
244
+ );
245
+ return cache;
246
+ }
102
247
  }
103
248
  `;
104
249
  }
@@ -150,6 +295,7 @@ ${Object.keys(props.schema.properties)
150
295
  };
151
296
  }): IValidation.IError[] {
152
297
  const errors: IValidation.IError[] = [];
298
+ // mapping plans
153
299
  validateTransformMappings({
154
300
  document: props.document,
155
301
  errors,
@@ -162,6 +308,8 @@ ${Object.keys(props.schema.properties)
162
308
  plan: props.plan,
163
309
  selectMappings: props.selectMappings,
164
310
  });
311
+
312
+ // validate draft
165
313
  validateEmptyCode({
166
314
  plan: props.plan,
167
315
  content: props.draft,
@@ -175,6 +323,13 @@ ${Object.keys(props.schema.properties)
175
323
  path: "$input.request.draft",
176
324
  errors,
177
325
  });
326
+ validateSelectReturnType({
327
+ content: props.draft,
328
+ path: "$input.request.draft",
329
+ errors,
330
+ });
331
+
332
+ // validate final
178
333
  if (props.revise.final !== null) {
179
334
  validateEmptyCode({
180
335
  plan: props.plan,
@@ -189,6 +344,11 @@ ${Object.keys(props.schema.properties)
189
344
  path: "$input.request.revise.final",
190
345
  errors,
191
346
  });
347
+ validateSelectReturnType({
348
+ content: props.revise.final,
349
+ path: "$input.request.revise.final",
350
+ errors,
351
+ });
192
352
  }
193
353
  return errors;
194
354
  }
@@ -337,6 +497,7 @@ ${Object.keys(props.schema.properties)
337
497
  const imports: string[] = [
338
498
  `import { Prisma } from "@prisma/sdk";`,
339
499
  `import { ArrayUtil } from "@nestia/e2e";`,
500
+ `import { VariadicSingleton } from "tstl";`,
340
501
  `import typia, { tags } from "typia";`,
341
502
  "",
342
503
  `import { IEntity } from "@ORGANIZATION/PROJECT-api/lib/structures/IEntity";`,
@@ -345,6 +506,7 @@ ${Object.keys(props.schema.properties)
345
506
  `import { ${ref} } from "@ORGANIZATION/PROJECT-api/lib/structures/${ref}";`,
346
507
  ),
347
508
  "",
509
+ 'import { MyGlobal } from "../MyGlobal";',
348
510
  `import { toISOStringSafe } from "../utils/toISOStringSafe";`,
349
511
  ];
350
512
  return imports;
@@ -366,6 +528,26 @@ ${Object.keys(props.schema.properties)
366
528
  });
367
529
  }
368
530
 
531
+ function validateSelectReturnType(props: {
532
+ content: string;
533
+ path: string;
534
+ errors: IValidation.IError[];
535
+ }): void {
536
+ if (/function\s+select\s*\(\s*\)\s*:/.test(props.content))
537
+ props.errors.push({
538
+ path: props.path,
539
+ expected:
540
+ "select() must use inferred return type (no explicit annotation).",
541
+ value: props.content,
542
+ description: StringUtil.trim`
543
+ select() has an explicit return type annotation. This widens the
544
+ literal type and destroys Prisma GetPayload inference, causing
545
+ cascading type errors. Remove the return type — use satisfies
546
+ on the return value instead.
547
+ `,
548
+ });
549
+ }
550
+
369
551
  function validateNeighbors(props: {
370
552
  plan: AutoBeRealizeTransformerPlan;
371
553
  neighbors: AutoBeRealizeTransformerPlan[];
@@ -396,6 +578,27 @@ ${Object.keys(props.schema.properties)
396
578
  });
397
579
  }
398
580
 
581
+ export function getRecursiveProperty(props: {
582
+ schemas: Record<string, AutoBeOpenApi.IJsonSchema>;
583
+ typeName: string;
584
+ }): string | null {
585
+ const schema: AutoBeOpenApi.IJsonSchema | undefined =
586
+ props.schemas[props.typeName];
587
+ if (schema === undefined || !AutoBeOpenApiTypeChecker.isObject(schema))
588
+ return null;
589
+
590
+ const selfRef: string = `#/components/schemas/${props.typeName}`;
591
+ const hasSelfRef = (s: AutoBeOpenApi.IJsonSchema): boolean => {
592
+ if (AutoBeOpenApiTypeChecker.isReference(s)) return s.$ref === selfRef;
593
+ if (AutoBeOpenApiTypeChecker.isOneOf(s))
594
+ return s.oneOf.some((sub) => hasSelfRef(sub));
595
+ return false;
596
+ };
597
+ for (const [key, value] of Object.entries(schema.properties))
598
+ if (value && hasSelfRef(value)) return key;
599
+ return null;
600
+ }
601
+
399
602
  export const fixApplication = (props: {
400
603
  definition: ILlmApplication;
401
604
  application: AutoBeDatabase.IApplication;
@@ -3,12 +3,7 @@ import { IAutoBeRealizeAuthorizationWriteApplication } from "./IAutoBeRealizeAut
3
3
 
4
4
  export interface IAutoBeRealizeAuthorizationCorrectApplication {
5
5
  /**
6
- * Process authentication component correction task or preliminary data
7
- * requests.
8
- *
9
- * Fixes TypeScript compilation errors in authentication components through
10
- * systematic error diagnosis. Provides error analysis, solution guidance, and
11
- * corrected versions while preserving authentication logic.
6
+ * Process authentication correction task or preliminary data requests.
12
7
  *
13
8
  * @param next Request containing either preliminary data request or complete
14
9
  * task
@@ -21,98 +16,49 @@ export namespace IAutoBeRealizeAuthorizationCorrectApplication {
21
16
  /**
22
17
  * Think before you act.
23
18
  *
24
- * Before requesting preliminary data or completing your task, reflect on
25
- * your current state and explain your reasoning:
26
- *
27
- * For preliminary requests (getAnalysisSections, getDatabaseSchemas, etc.):
28
- *
29
- * - What critical information is missing that you don't already have?
30
- * - Why do you need it specifically right now?
31
- * - Be brief - state the gap, don't list everything you have.
32
- *
33
- * For completion (complete):
19
+ * For preliminary requests: what critical information is missing?
34
20
  *
35
- * - What key assets did you acquire?
36
- * - What did you accomplish?
37
- * - Why is it sufficient to complete?
38
- * - Summarize - don't enumerate every single item.
39
- *
40
- * This reflection helps you avoid duplicate requests and premature
41
- * completion.
21
+ * For completion: what did you acquire, what did you accomplish, why is it
22
+ * sufficient?
42
23
  */
43
24
  thinking: string;
44
25
 
45
26
  /**
46
- * Type discriminator for the request.
47
- *
48
- * Determines which action to perform: preliminary data retrieval
49
- * (getDatabaseSchemas) or final error correction (complete). When
50
- * preliminary returns empty array, that type is removed from the union,
51
- * physically preventing repeated calls.
27
+ * Action to perform. Exhausted preliminary types are removed from the
28
+ * union, physically preventing repeated calls.
52
29
  */
53
30
  request: IComplete | IAutoBePreliminaryGetDatabaseSchemas;
54
31
  }
55
32
 
56
- /**
57
- * Request to fix authentication component errors.
58
- *
59
- * Executes targeted error correction to resolve TypeScript compilation issues
60
- * in provider, decorator, and payload type. Applies systematic fixes while
61
- * preserving all authentication logic and business requirements.
62
- */
33
+ /** Request to fix authentication component compilation errors. */
63
34
  export interface IComplete {
64
- /**
65
- * Type discriminator for the request.
66
- *
67
- * Determines which action to perform: preliminary data retrieval or actual
68
- * task execution. Value "complete" indicates this is the final task
69
- * execution request.
70
- */
35
+ /** Type discriminator for completion request. */
71
36
  type: "complete";
72
37
 
73
38
  /**
74
- * Step 1: TypeScript compilation error analysis and diagnosis.
75
- *
76
- * AI identifies and categorizes all compilation errors (type mismatches,
77
- * import issues, syntax errors) by component (providers/decorator/payload).
78
- * Lists specific error messages with their locations and types for
79
- * systematic troubleshooting.
39
+ * Categorize all compilation errors by component
40
+ * (provider/decorator/payload) with locations.
80
41
  */
81
42
  error_analysis: string;
82
43
 
83
- /**
84
- * Step 2: Solution guidance and fix recommendations.
85
- *
86
- * AI provides clear, actionable instructions on how to resolve each
87
- * identified error. Includes specific steps like "add property X to
88
- * interface Y", "update import path from A to B", or "change type from C to
89
- * D". Focus on guidance rather than generating complete code
90
- * implementations.
91
- */
44
+ /** Actionable fix instructions for each identified error. */
92
45
  solution_guidance: string;
93
46
 
94
47
  /**
95
- * Authentication Provider function configuration containing the function
96
- * name and implementation code. The Provider handles JWT token
97
- * verification, role validation, and database queries to authenticate
98
- * users.
48
+ * Authentication Provider function (JWT verification, role validation, DB
49
+ * queries).
99
50
  */
100
51
  provider: IAutoBeRealizeAuthorizationWriteApplication.IProvider;
101
52
 
102
53
  /**
103
- * Authentication Decorator configuration containing the decorator name and
104
- * implementation code. The Decorator integrates with NestJS parameter
105
- * decorators to automatically inject authenticated user data into
106
- * Controller methods.
54
+ * Authentication Decorator (NestJS parameter decorator injecting
55
+ * authenticated user data).
107
56
  */
108
57
  decorator: IAutoBeRealizeAuthorizationWriteApplication.IDecorator;
109
58
 
110
59
  /**
111
- * Authentication Payload Type configuration containing the payload type
112
- * name and implementation code. The Payload Type is used to define the
113
- * structure of the authenticated user data that will be injected into
114
- * Controller methods when using the decorator. It serves as the TypeScript
115
- * type for the parameter in Controller method signatures.
60
+ * Authentication Payload Type (TypeScript type for authenticated user data
61
+ * in Controller methods).
116
62
  */
117
63
  payload: IAutoBeRealizeAuthorizationWriteApplication.IPayloadType;
118
64
  }
@@ -2,14 +2,13 @@ import { CamelCasePattern, PascalCasePattern } from "@autobe/interface";
2
2
 
3
3
  import { IAutoBePreliminaryGetDatabaseSchemas } from "../../common/structures/IAutoBePreliminaryGetDatabaseSchemas";
4
4
 
5
+ /**
6
+ * Generates authentication components (provider, decorator, payload) for an
7
+ * actor type.
8
+ */
5
9
  export interface IAutoBeRealizeAuthorizationWriteApplication {
6
10
  /**
7
- * Process authentication component generation task or preliminary data
8
- * requests.
9
- *
10
- * Generates JWT-based authentication infrastructure (provider, decorator,
11
- * payload) for role-based authorization. Integrates with NestJS patterns and
12
- * jwtAuthorize utility.
11
+ * Process authentication generation task or preliminary data requests.
13
12
  *
14
13
  * @param next Request containing either preliminary data request or complete
15
14
  * task
@@ -22,145 +21,86 @@ export namespace IAutoBeRealizeAuthorizationWriteApplication {
22
21
  /**
23
22
  * Think before you act.
24
23
  *
25
- * Before requesting preliminary data or completing your task, reflect on
26
- * your current state and explain your reasoning:
27
- *
28
- * For preliminary requests (getAnalysisSections, getDatabaseSchemas, etc.):
29
- *
30
- * - What critical information is missing that you don't already have?
31
- * - Why do you need it specifically right now?
32
- * - Be brief - state the gap, don't list everything you have.
33
- *
34
- * For completion (complete):
24
+ * For preliminary requests: what database schemas are missing and why?
35
25
  *
36
- * - What key assets did you acquire?
37
- * - What did you accomplish?
38
- * - Why is it sufficient to complete?
39
- * - Summarize - don't enumerate every single item.
40
- *
41
- * This reflection helps you avoid duplicate requests and premature
42
- * completion.
26
+ * For completion: what schemas did you acquire, what authentication
27
+ * patterns did you implement, why is it sufficient?
43
28
  */
44
29
  thinking: string;
45
30
 
46
31
  /**
47
- * Type discriminator for the request.
48
- *
49
- * Determines which action to perform: preliminary data retrieval
50
- * (getDatabaseSchemas) or final authentication generation (complete). When
51
- * preliminary returns empty array, that type is removed from the union,
52
- * physically preventing repeated calls.
32
+ * Action to perform. Exhausted preliminary types are removed from the
33
+ * union, physically preventing repeated calls.
53
34
  */
54
35
  request: IComplete | IAutoBePreliminaryGetDatabaseSchemas;
55
36
  }
56
37
 
57
38
  /**
58
- * Request to generate authentication components.
59
- *
60
- * Executes authentication generation to create provider function, decorator,
61
- * and payload type for the specified role. All components work together to
62
- * provide JWT-based authentication and authorization.
39
+ * Request to generate authentication components (provider, decorator,
40
+ * payload).
63
41
  */
64
42
  export interface IComplete {
65
- /**
66
- * Type discriminator for the request.
67
- *
68
- * Determines which action to perform: preliminary data retrieval or actual
69
- * task execution. Value "complete" indicates this is the final task
70
- * execution request.
71
- */
43
+ /** Type discriminator for completion request. */
72
44
  type: "complete";
73
45
 
74
46
  /**
75
- * Authentication Provider function configuration containing the function
76
- * name and implementation code. The Provider handles JWT token
77
- * verification, role validation, and database queries to authenticate
78
- * users.
47
+ * Authentication Provider function (JWT verification, role validation, DB
48
+ * queries).
79
49
  */
80
50
  provider: IAutoBeRealizeAuthorizationWriteApplication.IProvider;
81
51
 
82
52
  /**
83
- * Authentication Decorator configuration containing the decorator name and
84
- * implementation code. The Decorator integrates with NestJS parameter
85
- * decorators to automatically inject authenticated user data into
86
- * Controller methods.
53
+ * Authentication Decorator (NestJS parameter decorator injecting
54
+ * authenticated user data).
87
55
  */
88
56
  decorator: IAutoBeRealizeAuthorizationWriteApplication.IDecorator;
89
57
 
90
58
  /**
91
- * Authentication Payload Type configuration containing the payload type
92
- * name and implementation code. The Payload Type is used to define the
93
- * structure of the authenticated user data that will be injected into
94
- * Controller methods when using the decorator. It serves as the TypeScript
95
- * type for the parameter in Controller method signatures.
59
+ * Authentication Payload Type (TypeScript type for authenticated user data
60
+ * in Controller methods).
96
61
  */
97
62
  payload: IAutoBeRealizeAuthorizationWriteApplication.IPayloadType;
98
63
  }
99
64
 
100
65
  export interface IProvider {
101
66
  /**
102
- * The name of the authentication Provider function in {role}Authorize
103
- * format (e.g., adminAuthorize, userAuthorize). This function will be
104
- * called by the decorator to verify JWT tokens and return authenticated
105
- * user information for the specified role.
106
- *
107
- * DO: Use camelCase naming convention.
67
+ * Provider function name in {role}Authorize format (e.g., adminAuthorize).
68
+ * MUST use camelCase.
108
69
  */
109
70
  name: string & CamelCasePattern;
110
71
 
111
72
  /**
112
- * Complete TypeScript code for the authentication Provider function. Must
113
- * include: JWT token verification using jwtAuthorize function, role type
114
- * checking against payload.type, database query using
115
- * MyGlobal.prisma.{tableName} pattern to verify user existence, and proper
116
- * error handling with ForbiddenException and UnauthorizedException. The
117
- * function should return the authenticated user payload data.
73
+ * Complete TypeScript code. MUST include: jwtAuthorize call, role type
74
+ * check, MyGlobal.prisma.{tableName} query,
75
+ * ForbiddenException/UnauthorizedException handling.
118
76
  */
119
77
  content: string;
120
78
  }
121
79
 
122
80
  export interface IDecorator {
123
81
  /**
124
- * The name of the Decorator to be generated in {Actor}Auth format (e.g.,
125
- * AdminAuth, UserAuth). This decorator will be used as a parameter
126
- * decorator in Controller methods to automatically authenticate and
127
- * authorize users for the specific role, injecting the authenticated user
128
- * payload as a method parameter.
129
- *
130
- * DO: Use PascalCase naming convention.
82
+ * Decorator name in {Actor}Auth format (e.g., AdminAuth, UserAuth). MUST
83
+ * use PascalCase.
131
84
  */
132
85
  name: string & PascalCasePattern;
133
86
 
134
87
  /**
135
- * Complete TypeScript code for the authentication Decorator implementation.
136
- * Must include: SwaggerCustomizer integration to add bearer token security
137
- * schema to API documentation, createParamDecorator implementation that
138
- * calls the corresponding Provider function for authentication, Singleton
139
- * pattern using tstl library for efficient decorator instance management,
140
- * and proper TypeScript typing for the ParameterDecorator interface.
88
+ * Complete TypeScript code. MUST include: SwaggerCustomizer integration,
89
+ * createParamDecorator calling Provider, Singleton pattern via tstl.
141
90
  */
142
91
  content: string;
143
92
  }
144
93
 
145
94
  export interface IPayloadType {
146
95
  /**
147
- * The name of the Payload type to be generated in {Actor}Payload format
148
- * (e.g., AdminPayload, UserPayload). This type defines the structure of the
149
- * authenticated user data that will be injected into Controller methods
150
- * when using the decorator.
151
- *
152
- * DO: Use PascalCase naming convention.
96
+ * Payload type name in {Actor}Payload format (e.g., AdminPayload,
97
+ * UserPayload). MUST use PascalCase.
153
98
  */
154
99
  name: string & PascalCasePattern;
155
100
 
156
101
  /**
157
- * Complete TypeScript code for the Payload type interface in {Actor}Payload
158
- * format (e.g., AdminPayload, UserPayload). Must include: id field with
159
- * UUID format validation, type field as role discriminator, and proper
160
- * typia tags for validation. This interface defines the structure of the
161
- * authenticated user data that will be injected into Controller methods
162
- * when using the decorator and serves as the TypeScript type for the
163
- * parameter in Controller method signatures.
102
+ * Complete TypeScript code. MUST include: id field with UUID validation,
103
+ * type field as role discriminator, typia tags.
164
104
  */
165
105
  content: string;
166
106
  }