@autobe/agent 0.25.0 → 0.25.2

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 (199) hide show
  1. package/lib/AutoBeAgent.js +11 -1
  2. package/lib/AutoBeAgent.js.map +1 -1
  3. package/lib/AutoBeMockAgent.js +1 -0
  4. package/lib/AutoBeMockAgent.js.map +1 -1
  5. package/lib/constants/AutoBeConfigConstant.d.ts +1 -1
  6. package/lib/constants/AutoBeSystemPromptConstant.d.ts +13 -13
  7. package/lib/factory/createAutoBeContext.js +32 -3
  8. package/lib/factory/createAutoBeContext.js.map +1 -1
  9. package/lib/index.mjs +2585 -1009
  10. package/lib/index.mjs.map +1 -1
  11. package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.js +8 -8
  12. package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeScenarioApplication.d.ts +2 -2
  13. package/lib/orchestrate/common/histories/transformCommonCorrectCastingHistories.js +1 -1
  14. package/lib/orchestrate/common/histories/transformCommonCorrectCastingHistories.js.map +1 -1
  15. package/lib/orchestrate/common/orchestrateCommonCorrectCasting.js +36 -23
  16. package/lib/orchestrate/common/orchestrateCommonCorrectCasting.js.map +1 -1
  17. package/lib/orchestrate/common/structures/IAutoBeCommonCorrectCastingApplication.d.ts +22 -42
  18. package/lib/orchestrate/interface/histories/transformInterfaceCommonPrerequisiteHistories.d.ts +3 -0
  19. package/lib/orchestrate/interface/histories/{transformInterfacePrerequisiteHistories.js → transformInterfaceCommonPrerequisiteHistories.js} +4 -4
  20. package/lib/orchestrate/interface/histories/transformInterfaceCommonPrerequisiteHistories.js.map +1 -0
  21. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js +2 -2
  22. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -1
  23. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js +3 -3
  24. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js.map +1 -1
  25. package/lib/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.d.ts +3 -0
  26. package/lib/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.js +102 -0
  27. package/lib/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.js.map +1 -0
  28. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +1 -1
  29. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -1
  30. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js +2 -2
  31. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js.map +1 -1
  32. package/lib/orchestrate/interface/orchestrateInterface.js +25 -9
  33. package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
  34. package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.js +278 -47
  35. package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.js.map +1 -1
  36. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +96 -70
  37. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
  38. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +3 -3
  39. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
  40. package/lib/orchestrate/interface/orchestrateInterfaceGroups.js +2 -2
  41. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +29 -30
  42. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
  43. package/lib/orchestrate/interface/orchestrateInterfaceOperationsReview.js +278 -47
  44. package/lib/orchestrate/interface/orchestrateInterfaceOperationsReview.js.map +1 -1
  45. package/lib/orchestrate/interface/orchestrateInterfacePrerequisites.d.ts +5 -0
  46. package/lib/orchestrate/interface/orchestrateInterfacePrerequisites.js +713 -0
  47. package/lib/orchestrate/interface/orchestrateInterfacePrerequisites.js.map +1 -0
  48. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js +88 -42
  49. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -1
  50. package/lib/orchestrate/interface/orchestrateInterfaceSchemasReview.js +82 -14
  51. package/lib/orchestrate/interface/orchestrateInterfaceSchemasReview.js.map +1 -1
  52. package/lib/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.d.ts +0 -38
  53. package/lib/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.d.ts +6 -10
  54. package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.d.ts +3 -3
  55. package/lib/orchestrate/interface/structures/IAutoBeInterfacePrerequisitesApplication.d.ts +52 -0
  56. package/lib/orchestrate/interface/structures/IAutoBeInterfacePrerequisitesApplication.js +3 -0
  57. package/lib/orchestrate/interface/structures/IAutoBeInterfacePrerequisitesApplication.js.map +1 -0
  58. package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.d.ts +0 -33
  59. package/lib/orchestrate/interface/utils/JsonSchemaFactory.d.ts +6 -2
  60. package/lib/orchestrate/interface/utils/JsonSchemaFactory.js +114 -9
  61. package/lib/orchestrate/interface/utils/JsonSchemaFactory.js.map +1 -1
  62. package/lib/orchestrate/interface/utils/JsonSchemaValidator.js +46 -3
  63. package/lib/orchestrate/interface/utils/JsonSchemaValidator.js.map +1 -1
  64. package/lib/orchestrate/interface/utils/OperationValidator.d.ts +3 -4
  65. package/lib/orchestrate/interface/utils/OperationValidator.js +1 -1
  66. package/lib/orchestrate/interface/utils/OperationValidator.js.map +1 -1
  67. package/lib/orchestrate/prisma/orchestratePrismaComponent.js +8 -8
  68. package/lib/orchestrate/prisma/orchestratePrismaCorrect.js +20 -20
  69. package/lib/orchestrate/prisma/orchestratePrismaReview.js +20 -20
  70. package/lib/orchestrate/prisma/orchestratePrismaSchemas.js +30 -30
  71. package/lib/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.js +9 -10
  72. package/lib/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.js.map +1 -1
  73. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js +14 -22
  74. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js.map +1 -1
  75. package/lib/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.js +6 -6
  76. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js +8 -2
  77. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js.map +1 -1
  78. package/lib/orchestrate/realize/internal/compileRealizeFiles.js +1 -2
  79. package/lib/orchestrate/realize/internal/compileRealizeFiles.js.map +1 -1
  80. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.d.ts +2 -1
  81. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js +103 -40
  82. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js.map +1 -1
  83. package/lib/orchestrate/realize/orchestrateRealize.js +79 -45
  84. package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
  85. package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js +16 -16
  86. package/lib/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js +12 -12
  87. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js +117 -87
  88. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
  89. package/lib/orchestrate/realize/orchestrateRealizeWrite.d.ts +2 -1
  90. package/lib/orchestrate/realize/orchestrateRealizeWrite.js +117 -54
  91. package/lib/orchestrate/realize/orchestrateRealizeWrite.js.map +1 -1
  92. package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.d.ts +21 -13
  93. package/lib/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.d.ts +52 -26
  94. package/lib/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +44 -34
  95. package/lib/orchestrate/realize/utils/InternalFileSystem.js +1 -1
  96. package/lib/orchestrate/realize/utils/InternalFileSystem.js.map +1 -1
  97. package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.d.ts +8 -3
  98. package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.js +44 -17
  99. package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.js.map +1 -1
  100. package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.d.ts +4 -1
  101. package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.js +24 -9
  102. package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.js.map +1 -1
  103. package/lib/orchestrate/realize/utils/printErrorHints.d.ts +8 -0
  104. package/lib/orchestrate/realize/utils/printErrorHints.js +48 -0
  105. package/lib/orchestrate/realize/utils/printErrorHints.js.map +1 -0
  106. package/lib/orchestrate/realize/utils/replaceImportStatements.d.ts +1 -0
  107. package/lib/orchestrate/realize/utils/replaceImportStatements.js +93 -55
  108. package/lib/orchestrate/realize/utils/replaceImportStatements.js.map +1 -1
  109. package/lib/orchestrate/test/histories/transformTestCorrectHistories.js +1 -1
  110. package/lib/orchestrate/test/histories/transformTestCorrectHistories.js.map +1 -1
  111. package/lib/orchestrate/test/histories/transformTestCorrectInvalidRequestHistories.js +1 -1
  112. package/lib/orchestrate/test/histories/transformTestCorrectInvalidRequestHistories.js.map +1 -1
  113. package/lib/orchestrate/test/histories/transformTestScenarioHistories.js +10 -79
  114. package/lib/orchestrate/test/histories/transformTestScenarioHistories.js.map +1 -1
  115. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js +15 -65
  116. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js.map +1 -1
  117. package/lib/orchestrate/test/histories/transformTestWriteHistories.js +1 -1
  118. package/lib/orchestrate/test/histories/transformTestWriteHistories.js.map +1 -1
  119. package/lib/orchestrate/test/orchestrateTestCorrect.js +32 -17
  120. package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  121. package/lib/orchestrate/test/orchestrateTestCorrectInvalidRequest.js +31 -13
  122. package/lib/orchestrate/test/orchestrateTestCorrectInvalidRequest.js.map +1 -1
  123. package/lib/orchestrate/test/orchestrateTestScenario.d.ts +1 -1
  124. package/lib/orchestrate/test/orchestrateTestScenario.js +5 -5
  125. package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
  126. package/lib/orchestrate/test/orchestrateTestScenarioReview.js +1 -1
  127. package/lib/orchestrate/test/orchestrateTestScenarioReview.js.map +1 -1
  128. package/lib/orchestrate/test/orchestrateTestWrite.js +37 -21
  129. package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -1
  130. package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +9 -5
  131. package/lib/orchestrate/test/structures/IAutoBeTestCorrectInvalidRequestApplication.d.ts +8 -2
  132. package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +11 -7
  133. package/lib/orchestrate/test/utils/getPrerequisites.d.ts +5 -0
  134. package/lib/orchestrate/test/utils/getPrerequisites.js +36 -0
  135. package/lib/orchestrate/test/utils/getPrerequisites.js.map +1 -0
  136. package/lib/orchestrate/test/utils/getReferenceIds.js +1 -1
  137. package/lib/orchestrate/test/utils/getReferenceIds.js.map +1 -1
  138. package/package.json +5 -5
  139. package/src/AutoBeAgent.ts +17 -1
  140. package/src/AutoBeMockAgent.ts +1 -0
  141. package/src/constants/AutoBeConfigConstant.ts +1 -1
  142. package/src/constants/AutoBeSystemPromptConstant.ts +13 -13
  143. package/src/factory/createAutoBeContext.ts +33 -3
  144. package/src/orchestrate/analyze/structures/IAutoBeAnalyzeScenarioApplication.ts +2 -2
  145. package/src/orchestrate/common/orchestrateCommonCorrectCasting.ts +2 -2
  146. package/src/orchestrate/common/structures/IAutoBeCommonCorrectCastingApplication.ts +25 -45
  147. package/src/orchestrate/interface/histories/{transformInterfacePrerequisiteHistories.ts → transformInterfaceCommonPrerequisiteHistories.ts} +1 -1
  148. package/src/orchestrate/interface/histories/transformInterfaceGroupHistories.ts +4 -2
  149. package/src/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.ts +118 -0
  150. package/src/orchestrate/interface/orchestrateInterface.ts +43 -17
  151. package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +12 -33
  152. package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +5 -5
  153. package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +7 -6
  154. package/src/orchestrate/interface/orchestrateInterfacePrerequisites.ts +274 -0
  155. package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +1 -1
  156. package/src/orchestrate/interface/orchestrateInterfaceSchemasReview.ts +1 -1
  157. package/src/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.ts +0 -39
  158. package/src/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.ts +6 -10
  159. package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.ts +4 -5
  160. package/src/orchestrate/interface/structures/IAutoBeInterfacePrerequisitesApplication.ts +58 -0
  161. package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.ts +0 -34
  162. package/src/orchestrate/interface/utils/JsonSchemaFactory.ts +92 -4
  163. package/src/orchestrate/interface/utils/JsonSchemaValidator.ts +49 -3
  164. package/src/orchestrate/interface/utils/OperationValidator.ts +9 -7
  165. package/src/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.ts +9 -10
  166. package/src/orchestrate/realize/histories/transformRealizeCorrectHistories.ts +13 -24
  167. package/src/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.ts +6 -6
  168. package/src/orchestrate/realize/histories/transformRealizeWriteHistories.ts +6 -4
  169. package/src/orchestrate/realize/internal/compileRealizeFiles.ts +1 -5
  170. package/src/orchestrate/realize/orchestRateRealizeCorrectCasting.ts +84 -17
  171. package/src/orchestrate/realize/orchestrateRealize.ts +123 -74
  172. package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +33 -6
  173. package/src/orchestrate/realize/orchestrateRealizeWrite.ts +14 -4
  174. package/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.ts +21 -13
  175. package/src/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.ts +54 -29
  176. package/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.ts +46 -35
  177. package/src/orchestrate/realize/utils/InternalFileSystem.ts +1 -1
  178. package/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.ts +54 -22
  179. package/src/orchestrate/realize/utils/getRealizeWriteImportStatements.ts +28 -16
  180. package/src/orchestrate/realize/utils/printErrorHints.ts +55 -0
  181. package/src/orchestrate/realize/utils/replaceImportStatements.ts +99 -102
  182. package/src/orchestrate/test/histories/transformTestScenarioHistories.ts +18 -91
  183. package/src/orchestrate/test/histories/transformTestScenarioReviewHistories.ts +17 -90
  184. package/src/orchestrate/test/orchestrateTestCorrect.ts +7 -6
  185. package/src/orchestrate/test/orchestrateTestCorrectInvalidRequest.ts +13 -1
  186. package/src/orchestrate/test/orchestrateTestScenario.ts +12 -6
  187. package/src/orchestrate/test/orchestrateTestScenarioReview.ts +3 -3
  188. package/src/orchestrate/test/orchestrateTestWrite.ts +7 -6
  189. package/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.ts +9 -228
  190. package/src/orchestrate/test/structures/IAutoBeTestCorrectInvalidRequestApplication.ts +8 -2
  191. package/src/orchestrate/test/structures/IAutoBeTestWriteApplication.ts +11 -78
  192. package/src/orchestrate/test/utils/getPrerequisites.ts +51 -0
  193. package/src/orchestrate/test/utils/getReferenceIds.ts +2 -1
  194. package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.d.ts +0 -3
  195. package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.js.map +0 -1
  196. package/lib/orchestrate/interface/utils/OpenApiEndpointComparator.d.ts +0 -6
  197. package/lib/orchestrate/interface/utils/OpenApiEndpointComparator.js +0 -22
  198. package/lib/orchestrate/interface/utils/OpenApiEndpointComparator.js.map +0 -1
  199. package/src/orchestrate/interface/utils/OpenApiEndpointComparator.ts +0 -23
@@ -19,9 +19,9 @@ const getRealizeWriteImportStatements_1 = require("./getRealizeWriteImportStatem
19
19
  * import { MyGlobal } from "../MyGlobal";
20
20
  * // ... other imports
21
21
  *
22
- * async function post__users_create(
22
+ * async function post__users_create(props: {
23
23
  * body: IUserCreateRequest
24
- * ): Promise<IUserResponse> {
24
+ * }): Promise<IUserResponse> {
25
25
  * ...
26
26
  * }
27
27
  * ```;
@@ -31,28 +31,24 @@ const getRealizeWriteImportStatements_1 = require("./getRealizeWriteImportStatem
31
31
  * @param authorization - Authorization context if endpoint is authenticated
32
32
  * @returns Complete TypeScript code template as a formatted string
33
33
  */
34
- function getRealizeWriteCodeTemplate(scenario, operation, authorization) {
34
+ function getRealizeWriteCodeTemplate(props) {
35
35
  var _a, _b, _c;
36
36
  // Collect all function parameters in order
37
37
  const functionParameters = [];
38
38
  // Add authentication parameter if needed (e.g., user: IUser, admin: IAdmin)
39
- if (authorization && authorization.role.name) {
39
+ if (props.authorization && props.authorization.role.name) {
40
40
  // Debug: Log the values to check what's being used
41
- const authParameter = `${authorization.role.name}: ${authorization.payload.name}`;
41
+ const authParameter = `${props.authorization.role.name}: ${props.authorization.payload.name}`;
42
42
  functionParameters.push(authParameter);
43
43
  }
44
44
  // Add path parameters (e.g., id, postId, etc.)
45
- const pathParameters = operation.parameters.map((param) => {
46
- const paramType = param.schema.type;
47
- const paramFormat = "format" in param.schema
48
- ? ` & tags.Format<'${param.schema.format}'>`
49
- : "";
50
- return `${param.name}: ${paramType}${paramFormat}`;
45
+ const pathParameters = props.operation.parameters.map((param) => {
46
+ return `${param.name}: ${writeParameterType(param.schema)}`;
51
47
  });
52
48
  functionParameters.push(...pathParameters);
53
49
  // Add request body parameter if present
54
- if ((_a = operation.requestBody) === null || _a === void 0 ? void 0 : _a.typeName) {
55
- const bodyParameter = `body: ${operation.requestBody.typeName}`;
50
+ if ((_a = props.operation.requestBody) === null || _a === void 0 ? void 0 : _a.typeName) {
51
+ const bodyParameter = `body: ${props.operation.requestBody.typeName}`;
56
52
  functionParameters.push(bodyParameter);
57
53
  }
58
54
  // Format parameters for props object
@@ -68,19 +64,50 @@ function getRealizeWriteCodeTemplate(scenario, operation, authorization) {
68
64
  formattedSignature = "";
69
65
  }
70
66
  // Determine return type
71
- const returnType = (_c = (_b = operation.responseBody) === null || _b === void 0 ? void 0 : _b.typeName) !== null && _c !== void 0 ? _c : "void";
67
+ const returnType = (_c = (_b = props.operation.responseBody) === null || _b === void 0 ? void 0 : _b.typeName) !== null && _c !== void 0 ? _c : "void";
72
68
  // Generate the complete template
73
69
  return utils_1.StringUtil.trim `
74
70
  Complete the code below, disregard the import part and return only the function part.
75
71
 
76
72
  \`\`\`typescript
77
- ${(0, getRealizeWriteImportStatements_1.getRealizeWriteImportStatements)(operation).join("\n")}
73
+ ${(0, getRealizeWriteImportStatements_1.getRealizeWriteImportStatements)(props).join("\n")}
78
74
 
79
- // ONLY YOU HAVE TO WRITE THIS, AND USE IMPORTED.
80
- export async function ${scenario.functionName}(${formattedSignature}): Promise<${returnType}> {
75
+ // DON'T CHANGE FUNCTION NAME AND PARAMETERS,
76
+ // ONLY YOU HAVE TO WRITE THIS FUNCTION BODY, AND USE IMPORTED.
77
+ export async function ${props.scenario.functionName}(${formattedSignature}): Promise<${returnType}> {
81
78
  ...
82
79
  }
83
80
  \`\`\`
84
81
  `;
85
82
  }
83
+ const writeParameterType = (schema) => {
84
+ const elements = schema.type === "integer"
85
+ ? ["number", `tags.Type<"int32">`]
86
+ : [schema.type];
87
+ if (schema.type === "number") {
88
+ if (schema.minimum !== undefined)
89
+ elements.push(`tags.Minimum<${schema.minimum}>`);
90
+ if (schema.maximum !== undefined)
91
+ elements.push(`tags.Maximum<${schema.maximum}>`);
92
+ if (schema.exclusiveMinimum !== undefined)
93
+ elements.push(`tags.ExclusiveMinimum<${schema.exclusiveMinimum}>`);
94
+ if (schema.exclusiveMaximum !== undefined)
95
+ elements.push(`tags.ExclusiveMaximum<${schema.exclusiveMaximum}>`);
96
+ if (schema.multipleOf !== undefined)
97
+ elements.push(`tags.MultipleOf<${schema.multipleOf}>`);
98
+ }
99
+ else if (schema.type === "string") {
100
+ if (schema.format !== undefined)
101
+ elements.push(`tags.Format<${JSON.stringify(schema.format)}>`);
102
+ if (schema.contentMediaType !== undefined)
103
+ elements.push(`tags.ContentMediaType<${JSON.stringify(schema.contentMediaType)}>`);
104
+ if (schema.pattern !== undefined)
105
+ elements.push(`tags.Pattern<${JSON.stringify(schema.pattern)}>`);
106
+ if (schema.minLength !== undefined)
107
+ elements.push(`tags.MinLength<${schema.minLength}>`);
108
+ if (schema.maxLength !== undefined)
109
+ elements.push(`tags.MaxLength<${schema.maxLength}>`);
110
+ }
111
+ return elements.join(" & ");
112
+ };
86
113
  //# sourceMappingURL=getRealizeWriteCodeTemplate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getRealizeWriteCodeTemplate.js","sourceRoot":"","sources":["../../../../src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.ts"],"names":[],"mappings":";;AAkCA,kEA8DC;AA/FD,yCAA2C;AAG3C,uFAAoF;AAEpF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,2BAA2B,CACzC,QAAsC,EACtC,SAAmC,EACnC,aAAgD;;IAEhD,2CAA2C;IAC3C,MAAM,kBAAkB,GAAa,EAAE,CAAC;IAExC,4EAA4E;IAC5E,IAAI,aAAa,IAAI,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAC7C,mDAAmD;QACnD,MAAM,aAAa,GAAG,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,KAAK,aAAa,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAClF,kBAAkB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACzC,CAAC;IAED,+CAA+C;IAC/C,MAAM,cAAc,GAAG,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACxD,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;QACpC,MAAM,WAAW,GACf,QAAQ,IAAI,KAAK,CAAC,MAAM;YACtB,CAAC,CAAC,mBAAmB,KAAK,CAAC,MAAM,CAAC,MAAM,IAAI;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,GAAG,CAAC,CAAC;QACrE,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS;YACjC,QAAQ,CAAC,IAAI,CAAC,mBAAmB,MAAM,CAAC,UAAU,GAAG,CAAC,CAAC;IAC3D,CAAC;SAAM,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACpC,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS;YAC7B,QAAQ,CAAC,IAAI,CAAC,eAAe,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,IAAI,MAAM,CAAC,gBAAgB,KAAK,SAAS;YACvC,QAAQ,CAAC,IAAI,CACX,yBAAyB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,gBAAgB,CAAC,GAAG,CACpE,CAAC;QACJ,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS;YAC9B,QAAQ,CAAC,IAAI,CAAC,gBAAgB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACnE,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS;YAChC,QAAQ,CAAC,IAAI,CAAC,kBAAkB,MAAM,CAAC,SAAS,GAAG,CAAC,CAAC;QACvD,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS;YAChC,QAAQ,CAAC,IAAI,CAAC,kBAAkB,MAAM,CAAC,SAAS,GAAG,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC,CAAC"}
@@ -1,2 +1,5 @@
1
1
  import { AutoBeOpenApi } from "@autobe/interface";
2
- export declare function getRealizeWriteImportStatements(operation: AutoBeOpenApi.IOperation): string[];
2
+ export declare function getRealizeWriteImportStatements(props: {
3
+ operation: AutoBeOpenApi.IOperation;
4
+ schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>;
5
+ }): string[];
@@ -1,20 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getRealizeWriteImportStatements = getRealizeWriteImportStatements;
4
- function getRealizeWriteImportStatements(operation) {
5
- const typeReferences = Array.from(new Set([operation.requestBody, operation.responseBody]
6
- .filter((el) => el !== null)
7
- .map((el) => el.typeName.split(".")[0])));
4
+ const openapi_1 = require("@samchon/openapi");
5
+ function getRealizeWriteImportStatements(props) {
6
+ const typeReferences = new Set();
7
+ const visit = (key) => openapi_1.OpenApiTypeChecker.visit({
8
+ schema: {
9
+ $ref: `#/components/schemas/${key}`,
10
+ },
11
+ components: { schemas: props.schemas },
12
+ closure: (next) => {
13
+ if (openapi_1.OpenApiTypeChecker.isReference(next))
14
+ typeReferences.add(next.$ref.split("/").pop().split(".")[0]);
15
+ },
16
+ });
17
+ if (props.operation.requestBody)
18
+ visit(props.operation.requestBody.typeName);
19
+ if (props.operation.responseBody)
20
+ visit(props.operation.responseBody.typeName);
8
21
  // Build the standard imports
9
22
  const imports = [
23
+ 'import { HttpException } from "@nestjs/common";',
24
+ 'import { Prisma } from "@prisma/client";',
10
25
  'import jwt from "jsonwebtoken";',
11
- 'import { MyGlobal } from "../MyGlobal";',
12
26
  'import typia, { tags } from "typia";',
13
- 'import { Prisma } from "@prisma/client";',
14
27
  'import { v4 } from "uuid";',
15
- 'import { toISOStringSafe } from "../util/toISOStringSafe"',
16
- 'import { HttpException } from "@nestjs/common";',
17
- ...typeReferences.map((ref) => `import { ${ref} } from "@ORGANIZATION/PROJECT-api/lib/structures/${ref}";`),
28
+ 'import { MyGlobal } from "../MyGlobal";',
29
+ 'import { PasswordUtil } from "../utils/PasswordUtil";',
30
+ 'import { toISOStringSafe } from "../utils/toISOStringSafe"',
31
+ "",
32
+ ...Array.from(typeReferences).map((ref) => `import { ${ref} } from "@ORGANIZATION/PROJECT-api/lib/structures/${ref}";`),
18
33
  ];
19
34
  return imports;
20
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getRealizeWriteImportStatements.js","sourceRoot":"","sources":["../../../../src/orchestrate/realize/utils/getRealizeWriteImportStatements.ts"],"names":[],"mappings":";;AAEA,0EA2BC;AA3BD,SAAgB,+BAA+B,CAC7C,SAAmC;IAEnC,MAAM,cAAc,GAAa,KAAK,CAAC,IAAI,CACzC,IAAI,GAAG,CACL,CAAC,SAAS,CAAC,WAAW,EAAE,SAAS,CAAC,YAAY,CAAC;SAC5C,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;SAC3B,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC,CAC3C,CACF,CAAC;IAEF,6BAA6B;IAC7B,MAAM,OAAO,GAAG;QACd,iCAAiC;QACjC,yCAAyC;QACzC,sCAAsC;QACtC,0CAA0C;QAC1C,4BAA4B;QAC5B,2DAA2D;QAC3D,iDAAiD;QACjD,GAAG,cAAc,CAAC,GAAG,CACnB,CAAC,GAAG,EAAE,EAAE,CACN,YAAY,GAAG,qDAAqD,GAAG,IAAI,CAC9E;KACF,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC"}
1
+ {"version":3,"file":"getRealizeWriteImportStatements.js","sourceRoot":"","sources":["../../../../src/orchestrate/realize/utils/getRealizeWriteImportStatements.ts"],"names":[],"mappings":";;AAGA,0EAsCC;AAxCD,8CAAsD;AAEtD,SAAgB,+BAA+B,CAAC,KAG/C;IACC,MAAM,cAAc,GAAgB,IAAI,GAAG,EAAE,CAAC;IAC9C,MAAM,KAAK,GAAG,CAAC,GAAW,EAAE,EAAE,CAC5B,4BAAkB,CAAC,KAAK,CAAC;QACvB,MAAM,EAAE;YACN,IAAI,EAAE,wBAAwB,GAAG,EAAE;SACpC;QACD,UAAU,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE;QACtC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YAChB,IAAI,4BAAkB,CAAC,WAAW,CAAC,IAAI,CAAC;gBACtC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC;QACnE,CAAC;KACF,CAAC,CAAC;IACL,IAAI,KAAK,CAAC,SAAS,CAAC,WAAW;QAAE,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC7E,IAAI,KAAK,CAAC,SAAS,CAAC,YAAY;QAC9B,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAE/C,6BAA6B;IAC7B,MAAM,OAAO,GAAG;QACd,iDAAiD;QACjD,0CAA0C;QAC1C,iCAAiC;QACjC,sCAAsC;QACtC,4BAA4B;QAE5B,yCAAyC;QACzC,uDAAuD;QACvD,4DAA4D;QAC5D,EAAE;QACF,GAAG,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,GAAG,CAC/B,CAAC,GAAG,EAAE,EAAE,CACN,YAAY,GAAG,qDAAqD,GAAG,IAAI,CAC9E;KACF,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { IAutoBeTypeScriptCompileResult } from "@autobe/interface";
2
+ /**
3
+ * Prints error hints for a given code and its diagnostics.
4
+ *
5
+ * @param code The code to analyze.
6
+ * @param diagnostics The diagnostics to use for error hinting.
7
+ */
8
+ export declare function printErrorHints(code: string, diagnostics: IAutoBeTypeScriptCompileResult.IDiagnostic[]): string;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.printErrorHints = printErrorHints;
4
+ const utils_1 = require("@autobe/utils");
5
+ /**
6
+ * Prints error hints for a given code and its diagnostics.
7
+ *
8
+ * @param code The code to analyze.
9
+ * @param diagnostics The diagnostics to use for error hinting.
10
+ */
11
+ function printErrorHints(code, diagnostics) {
12
+ const lines = code.split("\n");
13
+ let cursor = 0;
14
+ const hints = [];
15
+ lines.forEach((line, index, arr) => {
16
+ const lineStart = cursor;
17
+ cursor += line.length + 1; // +1 for the newline character
18
+ diagnostics.forEach((diag) => {
19
+ if (diag.start === null || diag.start === undefined) {
20
+ return;
21
+ }
22
+ // Check if the diagnostic start position falls within the current line
23
+ if (diag.start >= lineStart && diag.start < cursor) {
24
+ // Handle multi-line error messages by escaping newlines
25
+ const errorMessage = String(diag.messageText).replace(/\n/g, "\\n");
26
+ const targetLine = line + " // error: " + errorMessage;
27
+ // targetLine만 덮어써서 새로운 배열을 만들어야 한다.
28
+ const hint = arr
29
+ .slice(0, index)
30
+ .concat(targetLine)
31
+ .concat(arr.slice(index + 1))
32
+ .join("\n");
33
+ hints.push(hint);
34
+ }
35
+ });
36
+ });
37
+ return hints
38
+ .map((h, i) => {
39
+ return utils_1.StringUtil.trim `
40
+ hint #${i + 1}:
41
+ \`\`\`typescript
42
+ ${h}
43
+ \`\`\`
44
+ `;
45
+ })
46
+ .join("\n");
47
+ }
48
+ //# sourceMappingURL=printErrorHints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"printErrorHints.js","sourceRoot":"","sources":["../../../../src/orchestrate/realize/utils/printErrorHints.ts"],"names":[],"mappings":";;AASA,0CA6CC;AArDD,yCAA2C;AAE3C;;;;;GAKG;AACH,SAAgB,eAAe,CAC7B,IAAY,EACZ,WAAyD;IAEzD,MAAM,KAAK,GAAa,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAEzC,IAAI,MAAM,GAAW,CAAC,CAAC;IACvB,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QACjC,MAAM,SAAS,GAAG,MAAM,CAAC;QACzB,MAAM,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,+BAA+B;QAE1D,WAAW,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAC3B,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;gBACpD,OAAO;YACT,CAAC;YAED,uEAAuE;YACvE,IAAI,IAAI,CAAC,KAAK,IAAI,SAAS,IAAI,IAAI,CAAC,KAAK,GAAG,MAAM,EAAE,CAAC;gBACnD,wDAAwD;gBACxD,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;gBACpE,MAAM,UAAU,GAAG,IAAI,GAAG,aAAa,GAAG,YAAY,CAAC;gBAEvD,oCAAoC;gBACpC,MAAM,IAAI,GAAW,GAAG;qBACrB,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC;qBACf,MAAM,CAAC,UAAU,CAAC;qBAClB,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;qBAC5B,IAAI,CAAC,IAAI,CAAC,CAAC;gBAEd,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACnB,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK;SACT,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACZ,OAAO,kBAAU,CAAC,IAAI,CAAA;gBACZ,CAAC,GAAG,CAAC;;UAEX,CAAC;;OAEJ,CAAC;IACJ,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
@@ -3,6 +3,7 @@ import { ILlmSchema } from "@samchon/openapi";
3
3
  import { AutoBeContext } from "../../../context/AutoBeContext";
4
4
  export declare function replaceImportStatements<Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>, props: {
5
5
  operation: AutoBeOpenApi.IOperation;
6
+ schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>;
6
7
  code: string;
7
8
  decoratorType?: string;
8
9
  }): Promise<string>;
@@ -11,68 +11,106 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.replaceImportStatements = replaceImportStatements;
13
13
  const getRealizeWriteImportStatements_1 = require("./getRealizeWriteImportStatements");
14
- /**
15
- * Removes all import statements that LLM might have incorrectly added. This
16
- * includes standard library imports, auto-injected imports, and any API
17
- * structure imports with wrong paths.
18
- *
19
- * @param code - The code containing imports to remove
20
- * @param typeReferences - List of type names to specifically remove
21
- * @param decoratorType - Optional decorator type to remove
22
- * @returns Code with all imports removed
23
- */
24
- function removeAllImports(code, typeReferences, decoratorType) {
25
- // Remove standard library and auto-injected imports
26
- let cleanedCode = code
27
- // MyGlobal - often with wrong path
28
- .replace(/import\s*{\s*MyGlobal\s*}\s*from\s*["']\.\.\/MyGlobal["']\s*;?\s*/gm, "")
29
- // typia - various import patterns
30
- .replace(/import\s+typia\s*,\s*{\s*tags\s*}\s*from\s*["']typia["']\s*;?\s*/gm, "")
31
- .replace(/import\s*{\s*tags\s*}\s*from\s*["']typia["']\s*;?\s*/gm, "")
32
- .replace(/import\s*{\s*tags\s*,\s*typia\s*}\s*from\s*["']typia["']\s*;?\s*/gm, "")
33
- .replace(/import\s+typia\s*from\s*["']typia["']\s*;?\s*/gm, "")
34
- // Prisma client
35
- .replace(/import\s*{\s*Prisma\s*}\s*from\s*["']@prisma\/client["']\s*;?\s*/gm, "")
36
- // uuid
37
- .replace(/import\s*{\s*v4\s*}\s*from\s*["']uuid["']\s*;?\s*/gm, "")
38
- // toISOStringSafe utility
39
- .replace(/import\s*{\s*toISOStringSafe\s*}\s*from\s*["']\.\.\/util\/toISOStringSafe["']\s*;?\s*/gm, "")
40
- // JWT imports (if LLM adds them)
41
- .replace(/import\s+jwt\s+from\s*["']jsonwebtoken["']\s*;?\s*/gm, "")
42
- .replace(/import\s*\*\s*as\s+jwt\s+from\s*["']jsonwebtoken["']\s*;?\s*/gm, "")
43
- // NestJS HttpException
44
- .replace(/import\s*{\s*HttpException\s*}\s*from\s*["']@nestjs\/common["']\s*;?\s*/gm, "");
45
- // Remove API structure imports with wrong paths
46
- // Pattern 1: ../api/structures path (LLM often uses this wrong path)
47
- cleanedCode = cleanedCode.replace(/import\s*(?:type\s*)?{\s*[^}]+\s*}\s*from\s*["']\.\.\/api\/structures\/[^"']+["']\s*;?\s*/gm, "");
48
- // Pattern 2: @ORGANIZATION/PROJECT-api path (correct path but LLM shouldn't write it)
49
- cleanedCode = cleanedCode.replace(/import\s*(?:type\s*)?{\s*[^}]+\s*}\s*from\s*["']@ORGANIZATION\/PROJECT-api\/lib\/structures\/[^"']+["']\s*;?\s*/gm, "");
50
- // Remove specific type imports that match our typeReferences
51
- for (const ref of typeReferences) {
52
- const typeImportRegex = new RegExp(`import\\s*(?:type\\s*)?{\\s*${ref}\\s*}\\s*from\\s*["'][^"']+["']\\s*;?\\s*`, "gm");
53
- cleanedCode = cleanedCode.replace(typeImportRegex, "");
54
- }
55
- // Remove decorator type imports if LLM mistakenly added them
56
- if (decoratorType) {
57
- const decoratorTypeRegex = new RegExp(`import\\s*(?:type\\s*)?{\\s*${decoratorType}\\s*}\\s*from\\s*["']\\.\\.\/decorators\/payload\/${decoratorType}["']\\s*;?\\s*`, "gm");
58
- cleanedCode = cleanedCode.replace(decoratorTypeRegex, "");
59
- }
60
- return cleanedCode;
61
- }
14
+ // /**
15
+ // * Removes all import statements that LLM might have incorrectly added. This
16
+ // * includes standard library imports, auto-injected imports, and any API
17
+ // * structure imports with wrong paths.
18
+ // *
19
+ // * @param code - The code containing imports to remove
20
+ // * @param typeReferences - List of type names to specifically remove
21
+ // * @param decoratorType - Optional decorator type to remove
22
+ // * @returns Code with all imports removed
23
+ // */
24
+ // function removeAllImports(
25
+ // code: string,
26
+ // typeReferences: string[],
27
+ // decoratorType?: string,
28
+ // ): string {
29
+ // // Remove standard library and auto-injected imports
30
+ // let cleanedCode = code
31
+ // // MyGlobal - often with wrong path
32
+ // .replace(
33
+ // /import\s*{\s*MyGlobal\s*}\s*from\s*["']\.\.\/MyGlobal["']\s*;?\s*/gm,
34
+ // "",
35
+ // )
36
+ // // typia - various import patterns
37
+ // .replace(
38
+ // /import\s+typia\s*,\s*{\s*tags\s*}\s*from\s*["']typia["']\s*;?\s*/gm,
39
+ // "",
40
+ // )
41
+ // .replace(/import\s*{\s*tags\s*}\s*from\s*["']typia["']\s*;?\s*/gm, "")
42
+ // .replace(
43
+ // /import\s*{\s*tags\s*,\s*typia\s*}\s*from\s*["']typia["']\s*;?\s*/gm,
44
+ // "",
45
+ // )
46
+ // .replace(/import\s+typia\s*from\s*["']typia["']\s*;?\s*/gm, "")
47
+ // // Prisma client
48
+ // .replace(
49
+ // /import\s*{\s*Prisma\s*}\s*from\s*["']@prisma\/client["']\s*;?\s*/gm,
50
+ // "",
51
+ // )
52
+ // // uuid
53
+ // .replace(/import\s*{\s*v4\s*}\s*from\s*["']uuid["']\s*;?\s*/gm, "")
54
+ // // toISOStringSafe utility
55
+ // .replace(
56
+ // /import\s*{\s*toISOStringSafe\s*}\s*from\s*["']\.\.\/utils\/toISOStringSafe["']\s*;?\s*/gm,
57
+ // "",
58
+ // )
59
+ // // JWT imports (if LLM adds them)
60
+ // .replace(/import\s+jwt\s+from\s*["']jsonwebtoken["']\s*;?\s*/gm, "")
61
+ // .replace(
62
+ // /import\s*\*\s*as\s+jwt\s+from\s*["']jsonwebtoken["']\s*;?\s*/gm,
63
+ // "",
64
+ // )
65
+ // // NestJS HttpException
66
+ // .replace(
67
+ // /import\s*{\s*HttpException\s*}\s*from\s*["']@nestjs\/common["']\s*;?\s*/gm,
68
+ // "",
69
+ // );
70
+ // // Remove API structure imports with wrong paths
71
+ // // Pattern 1: ../api/structures path (LLM often uses this wrong path)
72
+ // cleanedCode = cleanedCode.replace(
73
+ // /import\s*(?:type\s*)?{\s*[^}]+\s*}\s*from\s*["']\.\.\/api\/structures\/[^"']+["']\s*;?\s*/gm,
74
+ // "",
75
+ // );
76
+ // // Pattern 2: @ORGANIZATION/PROJECT-api path (correct path but LLM shouldn't write it)
77
+ // cleanedCode = cleanedCode.replace(
78
+ // /import\s*(?:type\s*)?{\s*[^}]+\s*}\s*from\s*["']@ORGANIZATION\/PROJECT-api\/lib\/structures\/[^"']+["']\s*;?\s*/gm,
79
+ // "",
80
+ // );
81
+ // // Remove specific type imports that match our typeReferences
82
+ // for (const ref of typeReferences) {
83
+ // const typeImportRegex = new RegExp(
84
+ // `import\\s*(?:type\\s*)?{\\s*${ref}\\s*}\\s*from\\s*["'][^"']+["']\\s*;?\\s*`,
85
+ // "gm",
86
+ // );
87
+ // cleanedCode = cleanedCode.replace(typeImportRegex, "");
88
+ // }
89
+ // // Remove decorator type imports if LLM mistakenly added them
90
+ // if (decoratorType) {
91
+ // const decoratorTypeRegex = new RegExp(
92
+ // `import\\s*(?:type\\s*)?{\\s*${decoratorType}\\s*}\\s*from\\s*["']\\.\\.\/decorators\/payload\/${decoratorType}["']\\s*;?\\s*`,
93
+ // "gm",
94
+ // );
95
+ // cleanedCode = cleanedCode.replace(decoratorTypeRegex, "");
96
+ // }
97
+ // return cleanedCode;
98
+ // }
62
99
  function replaceImportStatements(ctx, props) {
63
100
  return __awaiter(this, void 0, void 0, function* () {
64
- let { operation, code, decoratorType } = props;
65
- // Extract type references from operation
66
- const typeReferences = Array.from(new Set([operation.requestBody, operation.responseBody]
67
- .filter((el) => el !== null)
68
- .map((el) => el.typeName.split(".")[0])));
101
+ let { code, decoratorType } = props;
69
102
  // Beautify code first for consistent formatting
70
103
  const compiler = yield ctx.compiler();
71
104
  code = yield compiler.typescript.beautify(code);
72
105
  // Remove all LLM-generated imports
73
- code = removeAllImports(code, typeReferences, decoratorType);
106
+ code = code
107
+ .split("\r\n")
108
+ .join("\n")
109
+ .split("\n")
110
+ .filter((str) => str.trim().startsWith("import") === false)
111
+ .join("\n");
74
112
  // Build the standard imports
75
- const imports = (0, getRealizeWriteImportStatements_1.getRealizeWriteImportStatements)(operation);
113
+ const imports = (0, getRealizeWriteImportStatements_1.getRealizeWriteImportStatements)(props);
76
114
  // Only add decoratorType import if it exists
77
115
  if (decoratorType) {
78
116
  imports.push(`import { ${decoratorType} } from "../decorators/payload/${decoratorType}"`);
@@ -1 +1 @@
1
- {"version":3,"file":"replaceImportStatements.js","sourceRoot":"","sources":["../../../../src/orchestrate/realize/utils/replaceImportStatements.ts"],"names":[],"mappings":";;;;;;;;;;;AAgGA,0DA2DC;AAvJD,uFAAoF;AAEpF;;;;;;;;;GASG;AACH,SAAS,gBAAgB,CACvB,IAAY,EACZ,cAAwB,EACxB,aAAsB;IAEtB,oDAAoD;IACpD,IAAI,WAAW,GAAG,IAAI;QACpB,mCAAmC;SAClC,OAAO,CACN,qEAAqE,EACrE,EAAE,CACH;QACD,kCAAkC;SACjC,OAAO,CACN,oEAAoE,EACpE,EAAE,CACH;SACA,OAAO,CAAC,wDAAwD,EAAE,EAAE,CAAC;SACrE,OAAO,CACN,oEAAoE,EACpE,EAAE,CACH;SACA,OAAO,CAAC,iDAAiD,EAAE,EAAE,CAAC;QAC/D,gBAAgB;SACf,OAAO,CACN,oEAAoE,EACpE,EAAE,CACH;QACD,OAAO;SACN,OAAO,CAAC,qDAAqD,EAAE,EAAE,CAAC;QACnE,0BAA0B;SACzB,OAAO,CACN,yFAAyF,EACzF,EAAE,CACH;QACD,iCAAiC;SAChC,OAAO,CAAC,sDAAsD,EAAE,EAAE,CAAC;SACnE,OAAO,CACN,gEAAgE,EAChE,EAAE,CACH;QACD,uBAAuB;SACtB,OAAO,CACN,2EAA2E,EAC3E,EAAE,CACH,CAAC;IAEJ,gDAAgD;IAChD,qEAAqE;IACrE,WAAW,GAAG,WAAW,CAAC,OAAO,CAC/B,6FAA6F,EAC7F,EAAE,CACH,CAAC;IACF,sFAAsF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IAAI,GAAG,gBAAgB,CAAC,IAAI,EAAE,cAAc,EAAE,aAAa,CAAC,CAAC;QAE7D,6BAA6B;QAC7B,MAAM,OAAO,GAAG,IAAA,iEAA+B,EAAC,SAAS,CAAC,CAAC;QAE3D,6CAA6C;QAC7C,IAAI,aAAa,EAAE,CAAC;YAClB,OAAO,CAAC,IAAI,CACV,YAAY,aAAa,kCAAkC,aAAa,GAAG,CAC5E,CAAC;QACJ,CAAC;QAED,IAAI,GAAG,CAAC,GAAG,OAAO,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEzC,6BAA6B;QAC7B,IAAI;YACF,IAAI;gBACF,oCAAoC;iBACnC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;gBACvB,0DAA0D;iBACzD,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC;gBAC3B,6CAA6C;iBAC5C,OAAO,CAAC,uCAAuC,EAAE,UAAU,CAAC;gBAC7D,0CAA0C;iBACzC,IAAI,EAAE,GAAG,IAAI,CAAC;QAEnB,oBAAoB;QACpB,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAE5E,6BAA6B;QAC7B,IAAI,GAAG,MAAM,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEhD,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,mBAAmB,EAAE,cAAc,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC;IACd,CAAC;CAAA"}
1
+ {"version":3,"file":"replaceImportStatements.js","sourceRoot":"","sources":["../../../../src/orchestrate/realize/utils/replaceImportStatements.ts"],"names":[],"mappings":";;;;;;;;;;;AAgGA,0DAwDC;AApJD,uFAAoF;AAEpF,MAAM;AACN,+EAA+E;AAC/E,2EAA2E;AAC3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