@izara_project/izara-core-generate-service-code 1.0.53 → 1.0.54

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 (141) hide show
  1. package/package.json +1 -2
  2. package/src/codeGenerators/app/initial_setup/InitialSetupGenerator.js +1 -1
  3. package/src/codeGenerators/app/sls_yaml/FindDataYamlGenerator.js +23 -0
  4. package/src/codeGenerators/app/sls_yaml/FunctionYamlGenerator.js +1 -1
  5. package/src/codeGenerators/app/sls_yaml/ProcessLogicalYamlGenerator.js +11 -25
  6. package/src/codeGenerators/app/sls_yaml/RoleNameConfigGenerator.js +1 -1
  7. package/src/codeGenerators/app/sls_yaml/SharedResourceYamlGenerator.js +3 -3
  8. package/src/codeGenerators/app/sls_yaml/renderYamlTemplate.js +13 -0
  9. package/src/codeGenerators/app/sls_yaml/templates/SharedResource_Yaml.ejs +6 -2
  10. package/src/codeGenerators/app/src/generatedCode/FindData/FindDataGenerator.js +10 -44
  11. package/src/codeGenerators/app/src/generatedCode/Flow/FlowEndpoints/EndpointsGenerator.js +119 -0
  12. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/RbacFlowGenerator.js +91 -52
  13. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRelationshipEndpoints/RelationshipFlowGenerator.js +20 -16
  14. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/StatusFieldGenerator.js +1 -1
  15. package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3Components/ConfirmAfterUploadS3Generator.js +2 -4
  16. package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3Components/CreateObjectGenerator.js +2 -4
  17. package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3Components/CreatePreSignUrlGenerator.js +2 -4
  18. package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3Components/ProcessAfterUploadS3Generator.js +5 -5
  19. package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3Components/ReservedLimitGenerator.js +2 -4
  20. package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowEntryPointBase.js +6 -6
  21. package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowMainFunctionBase.js +3 -3
  22. package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowStepBase.js +11 -11
  23. package/src/codeGenerators/app/src/generatedCode/ProcessLogical/ProcessLogicalGenerator.js +18 -15
  24. package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/{PaginateProcessLogical_HdrDsq.js → PaginateProcessLogical_HdrDsq.ejs} +1 -1
  25. package/src/codeGenerators/app/src/generatedCode/SystemFlowSchemas/RegisterGenerator.js +133 -149
  26. package/src/codeGenerators/app/src/generatedCode/libs/ConstsGenerator.js +16 -8
  27. package/src/codeGenerators/app/src/generatedCode/libs/GenerateCodeLibsGenerator.js +17 -9
  28. package/src/codeGenerators/resource/sls_yaml/FlowOutGenerator.js +11 -2
  29. package/src/codeGenerators/resource/sls_yaml/FlowResourceYamlGenerator.js +31 -4
  30. package/src/core/renderTemplateFile.js +22 -0
  31. package/src/generateCode.js +143 -110
  32. package/src/generateIntTest.js +45 -69
  33. package/src/generateResourceIntTest.js +22 -47
  34. package/src/intTestGeneratorShared.js +36 -0
  35. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/flowSchemaMainFunction/data.js +0 -119
  36. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/flowSchemaMainFunction/template.ejs +0 -89
  37. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/flowSchemaMainFunction/templateByStatusType/statusFieldTemplate.ejs +0 -30
  38. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/flowSchemaMainFunction/templateByStatusType/storedCacheTemplate.ejs +0 -26
  39. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/flowSchemaMainFunction/templateByStatusType/triggerCacheTemplate.ejs +0 -44
  40. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/index.js +0 -80
  41. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/functionYaml/data.js +0 -129
  42. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/functionYaml/template.ejs +0 -17
  43. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/handler/data.js +0 -63
  44. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/mainFunction/data.js +0 -54
  45. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/mainFunction/template.ejs +0 -129
  46. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/queue/data.js +0 -63
  47. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/queue/template.ejs +0 -45
  48. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObject/functionYaml/data.js +0 -117
  49. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObject/functionYaml/template.ejs +0 -20
  50. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObject/handler/data.js +0 -64
  51. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObject/mainFunction/data.js +0 -64
  52. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObject/mainFunction/template.ejs +0 -131
  53. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/functionYaml/data.js +0 -122
  54. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/functionYaml/template.ejs +0 -17
  55. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/handler/data.js +0 -66
  56. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/handler/template.ejs +0 -99
  57. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/mainFunction/data.js +0 -64
  58. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/mainFunction/template.ejs +0 -82
  59. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/sns-sqs/data.js +0 -70
  60. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/sns-sqs/template.ejs +0 -49
  61. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/functionYaml/data.js +0 -139
  62. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/functionYaml/template.ejs +0 -18
  63. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/handler/data.js +0 -63
  64. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/mainFunction/data.js +0 -63
  65. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/mainFunction/template.ejs +0 -262
  66. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/queue/data.js +0 -63
  67. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/queue/template.ejs +0 -45
  68. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/functionYaml/data.js +0 -146
  69. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/functionYaml/template.ejs +0 -14
  70. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/handler/data.js +0 -64
  71. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/mainFunction/data.js +0 -59
  72. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +0 -173
  73. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/sqs/data.js +0 -67
  74. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/sqs/template.ejs +0 -53
  75. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/functionYml/HdrS3/data.js +0 -140
  76. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/functionYml/HdrS3/template.ejs +0 -25
  77. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/handler/handlerS3/data.js +0 -49
  78. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/handler/handlerS3/template.ejs +0 -50
  79. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/mainFunction/ProcessCsvtemplate.ejs +0 -182
  80. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/mainFunction/data.js +0 -49
  81. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/mainFunction/template.ejs +0 -66
  82. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/queue/data.js +0 -77
  83. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/queue/dsqTemplatePath.ejs +0 -32
  84. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/queue/s3Template.ejs +0 -59
  85. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/relate/S3/data.js +0 -61
  86. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/relate/S3/template.ejs +0 -13
  87. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/relate/sns-out/data.js +0 -70
  88. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/websocket/dynamoDb/ReservedTableData.js +0 -69
  89. package/src/codeGenerators/app/src/generatedCode/Flow/SystemFlowDescriptorBuilder.js +0 -151
  90. /package/src/codeGenerators/app/{src/generatedCode/FindData → sls_yaml}/templates/FindData_Yaml.ejs +0 -0
  91. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared/endpoint → FlowEndpoints/templates}/FlowEndpointBeforeLogical_Main.ejs +0 -0
  92. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/endpoint/FlowEndpoint_HdrWbs.ejs +0 -0
  93. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/endpoint/FlowEndpoint_Main.ejs +0 -0
  94. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/endpoint/FlowEntryPoint_Main.ejs +0 -0
  95. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/endpoint/FlowMain_Wbs.ejs +0 -0
  96. /package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/{s3Legacy/upload/confirmReserved/handler/template.ejs → s3/ConfirmReserved_HdrSqs.ejs} +0 -0
  97. /package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/{s3Legacy/upload/createObject/handler/template.ejs → s3/CreateObject_HdrWbs.ejs} +0 -0
  98. /package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/{s3Legacy/upload/preSignUrl/createPreSignUrl/handler/template.ejs → s3/CreatePreSignUrl_HdrSqs.ejs} +0 -0
  99. /package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/{s3Legacy/upload/preSignUrl/reservedLimit/handler/template.ejs → s3/ReservedLimit_HdrSqs.ejs} +0 -0
  100. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/FlowEndpointComplete_Main.ejs +0 -0
  101. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/FlowStep_Main.ejs +0 -0
  102. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/FlowStep_ByConfig_Awaiting_Main.ejs +0 -0
  103. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/FlowStep_ByConfig_Paginated_Main.ejs +0 -0
  104. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/FlowStep_PlugIn_Main.ejs +0 -0
  105. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/FlowStep_RecievePlugIn_Main.ejs +0 -0
  106. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/templateAwaitingStep.ejs +0 -0
  107. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/templateSendPlugin.ejs +0 -0
  108. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/BaseSqsHandler.js +0 -0
  109. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/eventBridge.js +0 -0
  110. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/extTopic.js +0 -0
  111. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/lambdaSyncApi.js +0 -0
  112. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/lambdaSyncInv.js +0 -0
  113. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/ownTopic.js +0 -0
  114. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/registry.js +0 -0
  115. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3.js +0 -0
  116. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/handlers/FlowHandler_HdrApi.ejs +0 -0
  117. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/handlers/FlowHandler_HdrInv.ejs +0 -0
  118. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/handlers/FlowHandler_HdrSqs.ejs +0 -0
  119. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/eventTypes.js +0 -0
  120. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowClassifier.js +0 -0
  121. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowNaming.js +0 -0
  122. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowSelection.js +0 -0
  123. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowStepNormalizer.js +0 -0
  124. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowValidator.js +0 -0
  125. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/registry.js +0 -0
  126. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/triggerCacheBase.js +0 -0
  127. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/CheckTriggerCache_HdrSqs.ejs +0 -0
  128. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/CheckTriggerCache_Main.ejs +0 -0
  129. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/ProcessTriggerCache_HdrSqs.ejs +0 -0
  130. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/ProcessTriggerCache_Main.ejs +0 -0
  131. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/TriggerCacheComplete_HdrDsq.ejs +0 -0
  132. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/TriggerCacheComplete_HdrSqs.ejs +0 -0
  133. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/TriggerCacheComplete_Main.ejs +0 -0
  134. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/TriggerCacheQueue_Yaml.ejs +0 -0
  135. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/yaml/SharedFunctionSqs_Yaml.ejs +0 -0
  136. /package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/{PaginateProcessLogical_HdrSqs.js → PaginateProcessLogical_HdrSqs.ejs} +0 -0
  137. /package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/{PaginateProcessLogical_Main.js → PaginateProcessLogical_Main.ejs} +0 -0
  138. /package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/{ProcessLogical_HdrSqs.js → ProcessLogical_HdrSqs.ejs} +0 -0
  139. /package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/{ProcessLogical_Main.js → ProcessLogical_Main.ejs} +0 -0
  140. /package/src/codeGenerators/app/src/generatedCode/libs/templates/{Consts.js → Consts.ejs} +0 -0
  141. /package/src/codeGenerators/app/src/generatedCode/libs/templates/{GenerateCodeLibs.js → GenerateCodeLibs.ejs} +0 -0
@@ -2,7 +2,7 @@ import path from 'path';
2
2
  import fs from 'fs/promises';
3
3
  import { fileURLToPath } from 'url';
4
4
  import ejs from 'ejs';
5
- import { getFlowsForGeneration } from '../../app/src/generatedCode/Flow/_internal/shared/flowSelection.js';
5
+ import { getFlowsForGeneration } from '../../app/src/generatedCode/Flow/_shared/shared/flowSelection.js';
6
6
 
7
7
  const __filename = fileURLToPath(import.meta.url);
8
8
  const __dirname = path.dirname(__filename);
@@ -144,6 +144,34 @@ export async function generateFlowResourceYaml(allSchemas, options) {
144
144
  }
145
145
  }
146
146
 
147
+ // Add hardcoded ownTopic flows for CRUD, RBAC, Relationship
148
+ const systemOwnTopicFlows = [
149
+ 'Create', 'Update', 'Delete', // CRUD
150
+ 'CreateRelationship', 'UpdateRelationship', 'DeleteRelationship', 'ChangeRelationship', 'MoveRelationship', // Relationship
151
+ 'CreateTargetRole', 'DeleteTargetRole', 'CreateRolePermissions', 'DeleteRolePermissions', 'CreateUserRole', 'DeleteUserFromRole' // RBAC
152
+ ];
153
+ for (const flowTag of systemOwnTopicFlows) {
154
+ const yamlContent = ejs.render(resourceYamlTpl, { queueName: flowTag });
155
+ await appendToFile(yamlOutputPath, yamlContent);
156
+ generatedCount++;
157
+
158
+ // BeforeLogical queues for CRUD
159
+ if (['Create', 'Update', 'Delete'].includes(flowTag)) {
160
+ // Since we don't have beforeLogical configs here, we assume we might need them or we can just generate a generic one?
161
+ // For now, only custom flows generate beforeLogical dynamically above.
162
+ }
163
+ }
164
+
165
+ // Generate Dsq queues for Relationship
166
+ const relationshipActions = ['CreateRelationship', 'UpdateRelationship', 'DeleteRelationship', 'GetRelationship', 'ChangeRelationship', 'MoveRelationship'];
167
+ const resourceSqsYamlTplPath = path.join(__dirname, 'templates', 'crud', 'ResourceSqsYaml.ejs');
168
+ const resourceSqsYamlTpl = await fs.readFile(resourceSqsYamlTplPath, 'utf-8');
169
+ for (const action of relationshipActions) {
170
+ const yamlContent = ejs.render(resourceSqsYamlTpl, { queueName: action + 'Dsq' });
171
+ await appendToFile(yamlOutputPath, yamlContent);
172
+ generatedCount++;
173
+ }
174
+
147
175
  // Add System Queues
148
176
  const systemQueues = [
149
177
  'ProcessLogical',
@@ -157,11 +185,10 @@ export async function generateFlowResourceYaml(allSchemas, options) {
157
185
  'GetNodeComplete'
158
186
  ];
159
187
 
160
- const resourceSqsYamlTplPath = path.join(__dirname, 'templates', 'crud', 'ResourceSqsYaml.ejs');
161
- const resourceSqsYamlTpl = await fs.readFile(resourceSqsYamlTplPath, 'utf-8');
188
+ const resourceSqsYamlTplGlobal = await fs.readFile(resourceSqsYamlTplPath, 'utf-8');
162
189
 
163
190
  for (const sysQueue of systemQueues) {
164
- const yamlContent = ejs.render(resourceSqsYamlTpl, {
191
+ const yamlContent = ejs.render(resourceSqsYamlTplGlobal, {
165
192
  queueName: sysQueue
166
193
  });
167
194
  await appendToFile(yamlOutputPath, yamlContent);
@@ -0,0 +1,22 @@
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ import ejs from 'ejs';
4
+
5
+ async function renderTemplateFile(templatePath, templateData = {}, { views } = {}) {
6
+ const template = await fs.readFile(templatePath, 'utf8');
7
+ return ejs.render(template, templateData, views ? { views } : undefined);
8
+ }
9
+
10
+ async function writeRenderedTemplate(templatePath, outputPath, templateData = {}, options = {}) {
11
+ const content = await renderTemplateFile(templatePath, templateData, options);
12
+ await fs.mkdir(path.dirname(outputPath), { recursive: true });
13
+ await fs.writeFile(outputPath, content, 'utf8');
14
+ }
15
+
16
+ async function appendRenderedTemplate(templatePath, outputPath, templateData = {}, options = {}) {
17
+ const content = await renderTemplateFile(templatePath, templateData, options);
18
+ await fs.mkdir(path.dirname(outputPath), { recursive: true });
19
+ await fs.appendFile(outputPath, `\n${content}`, 'utf8');
20
+ }
21
+
22
+ export { appendRenderedTemplate, renderTemplateFile, writeRenderedTemplate };
@@ -5,17 +5,19 @@ import { parseObjectSchemas } from './parsers/objectSchemaParser.js';
5
5
  import { parseRelationshipSchemas } from './parsers/relationshipSchemaParser.js';
6
6
  import { parseFlowSchemas } from './parsers/flowSchemaParser.js';
7
7
 
8
- import { buildSystemFlowDescriptors } from './codeGenerators/app/src/generatedCode/Flow/SystemFlowDescriptorBuilder.js';
9
8
 
10
- import { generateFlowEntryPoint } from './codeGenerators/app/src/generatedCode/Flow/_internal/shared/flowEntryPointBase.js';
11
- import { generateFlowMainFunction } from './codeGenerators/app/src/generatedCode/Flow/_internal/shared/flowMainFunctionBase.js';
12
- import { generateFlowSteps } from './codeGenerators/app/src/generatedCode/Flow/_internal/shared/flowStepBase.js';
9
+
10
+ import { generateFlowEntryPoint } from './codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowEntryPointBase.js';
11
+ import { generateFlowMainFunction } from './codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowMainFunctionBase.js';
12
+ import { generateFlowSteps } from './codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowStepBase.js';
13
+
14
+ import { generateEndpointsFlow } from './codeGenerators/app/src/generatedCode/Flow/FlowEndpoints/EndpointsGenerator.js';
13
15
  import { generateFlowOut } from './codeGenerators/resource/sls_yaml/FlowOutGenerator.js';
14
16
  import { generateFlowResourceYaml } from './codeGenerators/resource/sls_yaml/FlowResourceYamlGenerator.js';
15
17
  import { generateRbacFlows } from './codeGenerators/app/src/generatedCode/Flow/FlowRbac/RbacFlowGenerator.js';
16
18
  import { generateRelationshipFlows } from './codeGenerators/app/src/generatedCode/Flow/FlowRelationshipEndpoints/RelationshipFlowGenerator.js';
17
19
  import { generateWebSocket } from './codeGenerators/app/src/generatedCode/Flow/FlowSchemas/WebSocketGenerator.js';
18
- import { validateFlowsForGeneration } from './codeGenerators/app/src/generatedCode/Flow/_internal/shared/flowValidator.js';
20
+ import { validateFlowsForGeneration } from './codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowValidator.js';
19
21
  import { generateRegisterFlow } from './codeGenerators/app/src/generatedCode/SystemFlowSchemas/RegisterGenerator.js';
20
22
  import { generateDynamoDBTables } from './codeGenerators/resource/sls_yaml/DynamoDBGenerator.js';
21
23
  import { generateFindData } from './codeGenerators/app/src/generatedCode/FindData/FindDataGenerator.js';
@@ -27,6 +29,7 @@ import { generateConsts } from './codeGenerators/app/src/generatedCode/libs/Cons
27
29
  import { generateProcessLogical } from './codeGenerators/app/src/generatedCode/ProcessLogical/ProcessLogicalGenerator.js';
28
30
  import { generateProcessLogicalYaml } from './codeGenerators/app/sls_yaml/ProcessLogicalYamlGenerator.js';
29
31
  import { generateSharedResourceYaml } from './codeGenerators/app/sls_yaml/SharedResourceYamlGenerator.js';
32
+ import { generateFindDataYaml } from './codeGenerators/app/sls_yaml/FindDataYamlGenerator.js';
30
33
  import { policyRegistry } from './codeGenerators/app/sls_yaml/_policy/PolicyRegistry.js';
31
34
  import { emitManagedPolicies } from './codeGenerators/app/sls_yaml/_policy/PolicyEmitter.js';
32
35
 
@@ -40,36 +43,75 @@ export async function generateCode(rootPath, options) {
40
43
  const generatedCodePath = path.join(outputPath, 'app', 'src', 'generatedCode');
41
44
 
42
45
  // Backup existing hook files to prevent them from being wiped out
43
- const hookBackups = [];
44
- function backupHooks(currentDir) {
45
- if (!fs.existsSync(currentDir)) return;
46
- const items = fs.readdirSync(currentDir, { withFileTypes: true });
47
-
48
- for (const item of items) {
49
- if (item.isDirectory()) {
50
- if (item.name === 'hook') {
51
- const hookPath = path.join(currentDir, 'hook');
52
- const hookItems = fs.readdirSync(hookPath, { withFileTypes: true });
53
- for (const hookItem of hookItems) {
54
- if (hookItem.isFile()) {
55
- hookBackups.push({
56
- relativePath: path.relative(generatedCodePath, hookPath),
57
- name: hookItem.name,
58
- content: fs.readFileSync(path.join(hookPath, hookItem.name))
59
- });
60
- }
61
- }
62
- } else if (item.name !== 'source') {
63
- backupHooks(path.join(currentDir, item.name));
64
- }
65
- }
66
- }
67
- }
68
-
69
- console.log('[INFO] [generateCode] STATUS=BACKUP | Backing up existing hook files...');
70
- backupHooks(generatedCodePath);
71
-
72
- console.log(
46
+ const hookBackups = [];
47
+ const hookDirs = new Set();
48
+
49
+ function getHookTagMatchers(filePath) {
50
+ if (filePath.endsWith('.js')) {
51
+ return {
52
+ anyTag: /\/\/\(<(\w+)>\)([\s\S]*?)\/\/\(<\/\1>\)/gm,
53
+ tagPattern: (name) => new RegExp(
54
+ `\\/\\/\\(<${name}>\\)([\\s\\S]*?)\\/\\/\\(<\\/${name}>\\)`,
55
+ 'gm'
56
+ )
57
+ };
58
+ }
59
+
60
+ if (filePath.endsWith('.yml') || filePath.endsWith('.yaml')) {
61
+ return {
62
+ anyTag: /#<#(\w+)#>([\s\S]*?)#<#\/\1#>/gm,
63
+ tagPattern: (name) => new RegExp(
64
+ `#<#${name}#>([\\s\\S]*?)#<#\\/${name}#>`,
65
+ 'gm'
66
+ )
67
+ };
68
+ }
69
+
70
+ return null;
71
+ }
72
+
73
+ function mergeHookIntoSource(sourceContent, hookContent, filePath) {
74
+ const matchers = getHookTagMatchers(filePath);
75
+ if (!matchers) return hookContent;
76
+
77
+ return sourceContent.replace(matchers.anyTag, (match, tagName) => (
78
+ hookContent.match(matchers.tagPattern(tagName))?.[0] ?? match
79
+ ));
80
+ }
81
+
82
+ function collectHookBackups(currentDir) {
83
+ if (!fs.existsSync(currentDir)) return;
84
+
85
+ const items = fs.readdirSync(currentDir, { withFileTypes: true });
86
+ const hasSource = items.some((item) => item.isDirectory() && item.name === 'source');
87
+ const hasHook = items.some((item) => item.isDirectory() && item.name === 'hook');
88
+
89
+ if (hasSource && hasHook) {
90
+ const hookPath = path.join(currentDir, 'hook');
91
+ hookDirs.add(path.relative(outputPath, hookPath));
92
+ const hookItems = fs.readdirSync(hookPath, { withFileTypes: true });
93
+
94
+ for (const hookItem of hookItems) {
95
+ if (!hookItem.isFile()) continue;
96
+ const hookFilePath = path.join(hookPath, hookItem.name);
97
+ hookBackups.push({
98
+ relativePath: path.relative(outputPath, hookPath),
99
+ name: hookItem.name,
100
+ content: fs.readFileSync(hookFilePath)
101
+ });
102
+ }
103
+ }
104
+
105
+ for (const item of items) {
106
+ if (!item.isDirectory() || item.name === 'source' || item.name === 'hook') continue;
107
+ collectHookBackups(path.join(currentDir, item.name));
108
+ }
109
+ }
110
+
111
+ console.log('[INFO] [generateCode] STATUS=BACKUP | Backing up existing hook files...');
112
+ collectHookBackups(outputPath);
113
+
114
+ console.log(
73
115
  '[INFO] [generateCode] STATUS=CLEANUP | Removing old generatedCode and resource directories...'
74
116
  );
75
117
  await fs.promises.rm(generatedCodePath, {
@@ -97,38 +139,21 @@ export async function generateCode(rootPath, options) {
97
139
  console.log('[INFO] [generateCode] STATUS=PARSING | FlowSchemas...');
98
140
  const flowData = await parseFlowSchemas(rootPath, objectData, options);
99
141
 
100
- // Build fixed system flows in memory instead of writing generated FlowSchema files.
101
- const systemFlowData = buildSystemFlowDescriptors(
102
- objectData,
103
- relationshipData,
104
- flowData
105
- );
106
-
107
142
  // The 'allSchemas' object contains the fully hydrated Memory Objects
108
143
  const allSchemas = {
109
144
  objects: objectData.objects,
110
145
  relationships: relationshipData.relationships,
111
146
  flows: flowData.flows,
112
- systemFlows: systemFlowData.flows,
113
- flowsForGeneration: [
114
- ...(flowData.flows || []),
115
- ...(systemFlowData.flows || [])
116
- ]
147
+ flowsForGeneration: flowData.flows || []
117
148
  };
118
149
 
119
- // DEBUG: Dump the hydrated allSchemas to a file so we can inspect it
120
- const dumpPath = path.join(
121
- options.outputPath || rootPath,
122
- 'allSchemas_debug.json'
123
- );
124
- fs.writeFileSync(dumpPath, JSON.stringify(allSchemas, null, 2));
125
-
126
150
  console.log('[INFO] [generateCode] STATUS=VALIDATING | Validating Flows...');
127
151
  validateFlowsForGeneration(allSchemas.flowsForGeneration);
128
152
 
129
153
  const generatorOptions = { outputPath: options.outputPath || rootPath };
130
154
 
131
155
  // 2. Generation Pipeline
156
+ await generateEndpointsFlow(allSchemas, generatorOptions);
132
157
  await generateFlowMainFunction(allSchemas, generatorOptions);
133
158
  await generateFlowEntryPoint(allSchemas, generatorOptions);
134
159
  await generateFlowSteps(allSchemas, generatorOptions);
@@ -148,66 +173,74 @@ export async function generateCode(rootPath, options) {
148
173
  await generateProcessLogical(generatorOptions);
149
174
  await generateRoleNameConfig(allSchemas, generatorOptions);
150
175
  await generateProcessLogicalYaml(allSchemas, generatorOptions);
176
+ await generateFindDataYaml(generatorOptions);
151
177
  await generateSharedResourceYaml(allSchemas, generatorOptions);
152
178
  await generateInitialSetup(allSchemas, generatorOptions);
153
179
 
154
180
  // 3. Hook Integration
155
- console.log(
156
- '[INFO] [generateCode] STATUS=HOOKS | Processing hook folders beside source folders...'
157
- );
158
-
159
- function processSourceHooks(currentDir) {
160
- if (!fs.existsSync(currentDir)) return;
161
- const items = fs.readdirSync(currentDir, { withFileTypes: true });
162
-
163
- const hasSource = items.some(
164
- item => item.isDirectory() && item.name === 'source'
165
- );
166
- if (hasSource) {
167
- const sourcePath = path.join(currentDir, 'source');
168
- const hookPath = path.join(currentDir, 'hook');
169
-
170
- if (!fs.existsSync(hookPath)) {
171
- fs.mkdirSync(hookPath, { recursive: true });
172
- } else {
173
- const hookItems = fs.readdirSync(hookPath, { withFileTypes: true });
174
- for (const hookItem of hookItems) {
175
- if (hookItem.isFile()) {
176
- const srcFile = path.join(hookPath, hookItem.name);
177
- const dstFile = path.join(sourcePath, hookItem.name);
178
- fs.copyFileSync(srcFile, dstFile);
179
- console.log(
180
- `[INFO] [generateCode] HOOK APPLIED: Copied ${hookItem.name} to source.`
181
- );
182
- }
183
- }
184
- }
185
- }
186
-
187
- for (const item of items) {
188
- if (
189
- item.isDirectory() &&
190
- item.name !== 'source' &&
191
- item.name !== 'hook'
192
- ) {
193
- processSourceHooks(path.join(currentDir, item.name));
194
- }
195
- }
196
- }
197
-
198
- // Restore backed-up hooks
199
- if (hookBackups.length > 0) {
200
- console.log(`[INFO] [generateCode] STATUS=RESTORE | Restoring ${hookBackups.length} hook files...`);
201
- for (const backup of hookBackups) {
202
- const hookDir = path.join(generatedCodePath, backup.relativePath);
203
- if (!fs.existsSync(hookDir)) {
204
- fs.mkdirSync(hookDir, { recursive: true });
205
- }
206
- fs.writeFileSync(path.join(hookDir, backup.name), backup.content);
207
- }
208
- }
209
-
210
- processSourceHooks(generatorOptions.outputPath);
181
+ console.log(
182
+ '[INFO] [generateCode] STATUS=HOOKS | Processing hook folders beside source folders...'
183
+ );
184
+
185
+ function processSourceHooks(currentDir) {
186
+ if (!fs.existsSync(currentDir)) return;
187
+
188
+ const items = fs.readdirSync(currentDir, { withFileTypes: true });
189
+ const hasSource = items.some((item) => item.isDirectory() && item.name === 'source');
190
+ const hasHook = items.some((item) => item.isDirectory() && item.name === 'hook');
191
+
192
+ if (hasSource && hasHook) {
193
+ const sourcePath = path.join(currentDir, 'source');
194
+ const hookPath = path.join(currentDir, 'hook');
195
+ const hookItems = fs.readdirSync(hookPath, { withFileTypes: true });
196
+
197
+ for (const hookItem of hookItems) {
198
+ if (!hookItem.isFile()) continue;
199
+
200
+ const hookFile = path.join(hookPath, hookItem.name);
201
+ const sourceFile = path.join(sourcePath, hookItem.name);
202
+
203
+ if (!fs.existsSync(sourceFile)) {
204
+ fs.copyFileSync(hookFile, sourceFile);
205
+ console.log(
206
+ `[INFO] [generateCode] HOOK APPLIED: Created ${hookItem.name} from hook.`
207
+ );
208
+ continue;
209
+ }
210
+
211
+ const mergedContent = mergeHookIntoSource(
212
+ fs.readFileSync(sourceFile, 'utf8'),
213
+ fs.readFileSync(hookFile, 'utf8'),
214
+ sourceFile
215
+ );
216
+ fs.writeFileSync(sourceFile, mergedContent);
217
+ console.log(
218
+ `[INFO] [generateCode] HOOK APPLIED: Merged ${hookItem.name} into source.`
219
+ );
220
+ }
221
+ } else if (hasSource) {
222
+ fs.mkdirSync(path.join(currentDir, 'hook'), { recursive: true });
223
+ }
224
+
225
+ for (const item of items) {
226
+ if (!item.isDirectory() || item.name === 'source' || item.name === 'hook') continue;
227
+ processSourceHooks(path.join(currentDir, item.name));
228
+ }
229
+ }
230
+
231
+ // Restore backed-up hooks
232
+ if (hookDirs.size > 0 || hookBackups.length > 0) {
233
+ console.log(`[INFO] [generateCode] STATUS=RESTORE | Restoring ${hookBackups.length} hook files...`);
234
+ for (const relativeHookDir of hookDirs) {
235
+ fs.mkdirSync(path.join(outputPath, relativeHookDir), { recursive: true });
236
+ }
237
+ for (const backup of hookBackups) {
238
+ const hookDir = path.join(outputPath, backup.relativePath);
239
+ fs.writeFileSync(path.join(hookDir, backup.name), backup.content);
240
+ }
241
+ }
242
+
243
+ processSourceHooks(generatorOptions.outputPath);
211
244
 
212
245
  console.log(
213
246
  '[INFO] [generateCode] STATUS=FINISHED | Code generation complete.'
@@ -1,5 +1,4 @@
1
- /*
2
- Copyright (C) 2020 Sven Mason <http://izara.io>
1
+ /* Copyright (C) 2020 Sven Mason <http://izara.io>
3
2
 
4
3
  This program is free software: you can redistribute it and/or modify
5
4
  it under the terms of the GNU Affero General Public License as
@@ -8,20 +7,20 @@ License, or (at your option) any later version.
8
7
 
9
8
  This program is distributed in the hope that it will be useful,
10
9
  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
11
  GNU Affero General Public License for more details.
13
12
 
14
13
  You should have received a copy of the GNU Affero General Public License
15
- along with this program. If not, see <http://www.gnu.org/licenses/>.
14
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
15
  */
17
16
 
18
- import { readFileSync, writeFileSync, appendFileSync, mkdirSync, existsSync, rmSync } from 'fs';
17
+ import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
19
18
  import { join } from 'path';
20
- import yaml from 'yaml';
21
19
  import ejs from 'ejs';
22
20
  import beautify from 'js-beautify/js/index.js';
23
21
 
24
22
  import generateTestTemplate from './generateResources/IntTest/generateTests/generateTemplate.js';
23
+ import { getServiceTag, runTemplateItems } from './intTestGeneratorShared.js';
25
24
 
26
25
  const BEAUTIFY_SETTING = {
27
26
  indent_size: '2',
@@ -33,22 +32,27 @@ const BEAUTIFY_SETTING = {
33
32
  space_before_conditional: true
34
33
  };
35
34
 
36
- // Inline replacement for legacy createSource (no longer imported).
37
- // Renders an EJS template with data, applies hook overrides, beautifies JS, and writes/appends to file.
38
35
  async function writeSource({ templatePath, templateData, setting }, { checkCreateSourcePass = false } = {}) {
39
36
  if (!templatePath || !templateData || !setting) {
40
37
  throw new Error('Invalid IntTest source item: missing templatePath/templateData/setting');
41
38
  }
42
39
 
43
- const { savePath, hookPath, saveFileName, fileExtension, isAppend = false, initialData, generateHookFile = true } = setting;
40
+ const {
41
+ savePath,
42
+ hookPath,
43
+ saveFileName,
44
+ fileExtension,
45
+ isAppend = false,
46
+ initialData,
47
+ generateHookFile = true
48
+ } = setting;
44
49
 
45
50
  if (checkCreateSourcePass) {
46
- // Validate phase: compile template to check for errors, no write
47
51
  try {
48
52
  ejs.compile(readFileSync(templatePath, 'utf8'))(templateData);
49
53
  return [true, {}];
50
- } catch (err) {
51
- return [false, err];
54
+ } catch (error) {
55
+ return [false, error];
52
56
  }
53
57
  }
54
58
 
@@ -63,26 +67,23 @@ async function writeSource({ templatePath, templateData, setting }, { checkCreat
63
67
 
64
68
  let dataToSave = ejs.compile(readFileSync(templatePath, 'utf8'))(templateData);
65
69
 
66
- // Apply hook overrides (regex-based, matches legacy CreateSource.js behavior)
67
70
  if (existsSync(hookFilePath)) {
68
71
  const hookData = readFileSync(hookFilePath, 'utf8');
69
- // anyDoubleTag: matches //(<tagName>)...//(</tagName>) (JS) or #<#tagName#>...#<#/tagName#> (YML)
70
72
  const anyDoubleTag = isJs
71
- ? new RegExp('\\/\\/\\\\(<(\\w+)>\\\\)([\\\\s\\\\S]*?)\\/\\/\\\\(<\\/\\\\1>\\\\)', 'gm')
73
+ ? new RegExp('\\/\\/\\(<(\\w+)>\\)([\\s\\S]*?)\\/\\/\\(<\\/\\1>\\)', 'gm')
72
74
  : isYml
73
- ? new RegExp('\\#<#(\\w+)#>([\\\\s\\\\S]*?)\\#<#\\/\\1#>', 'gm')
75
+ ? new RegExp('\\#<#(\\w+)#>([\\s\\S]*?)\\#<#\\/\\1#>', 'gm')
74
76
  : null;
75
- // doubleTag(name): extracts content between //(<name>) and //(</name>) (or YML equivalent)
76
77
  const doubleTag = isJs
77
- ? (name) => new RegExp(`\\/\\/\\\\(<${name}>\\\\)([\\\\s\\\\S]*?)\\/\\/\\\\(<\\/${name}>\\\\)`, 'gm')
78
+ ? (name) => new RegExp(`\\/\\/\\(<${name}>\\)([\\s\\S]*?)\\/\\/\\(<\\/${name}>\\)`, 'gm')
78
79
  : isYml
79
- ? (name) => new RegExp(`\\#<#${name}#>([\\\\s\\\\S]*?)\\#<#\\/${name}#>`, 'gm')
80
+ ? (name) => new RegExp(`\\#<#${name}#>([\\s\\S]*?)\\#<#\\/${name}#>`, 'gm')
80
81
  : null;
81
82
 
82
83
  if (anyDoubleTag && doubleTag) {
83
- dataToSave = dataToSave.replace(anyDoubleTag, (match, tagName) =>
84
+ dataToSave = dataToSave.replace(anyDoubleTag, (match, tagName) => (
84
85
  hookData.match(doubleTag(tagName)) ?? match
85
- );
86
+ ));
86
87
  }
87
88
  }
88
89
 
@@ -90,76 +91,51 @@ async function writeSource({ templatePath, templateData, setting }, { checkCreat
90
91
 
91
92
  if (isAppend) {
92
93
  const shouldWriteWithInitial = !existsSync(filePath) && initialData;
93
- const content = (shouldWriteWithInitial ? initialData : '') + dataToSave + '\n\n';
94
- shouldWriteWithInitial
95
- ? writeFileSync(filePath, content, 'utf8')
96
- : appendFileSync(filePath, dataToSave + '\n\n', 'utf8');
97
- } else {
98
- writeFileSync(filePath, dataToSave, 'utf8');
94
+ const content = `${shouldWriteWithInitial ? initialData : ''}${dataToSave}\n\n`;
95
+
96
+ if (shouldWriteWithInitial) {
97
+ writeFileSync(filePath, content, 'utf8');
98
+ } else {
99
+ appendFileSync(filePath, `${dataToSave}\n\n`, 'utf8');
100
+ }
101
+ return [true, {}];
99
102
  }
100
- }
101
103
 
102
- // Inline replacement for legacy getLocalConfig('iz_serviceTag') — reads from rootPath instead of process.cwd().
103
- function getServiceTag(rootPath) {
104
- const configPath = join(rootPath, 'config', 'serverless.config.yml');
105
- const config = yaml.parse(readFileSync(configPath, 'utf8'));
106
- return config?.main_config?.iz_serviceTag;
104
+ writeFileSync(filePath, dataToSave, 'utf8');
105
+ return [true, {}];
107
106
  }
108
107
 
109
- /**
110
- * Generate integration test files (events, tests, pathIntTest) for the service.
111
- * Result-Driven refactor: flat pipeline, no createSource/libs dependencies.
112
- *
113
- * @param {string} rootPath - Service root path containing /config and /app
114
- * @param {Object} [options]
115
- * @param {string} [options.outputPath] - Where to write (default: rootPath)
116
- * @param {string} [options.s3Prefix] - S3 prefix for IntTest config (optional)
117
- * @param {Object} [options._izContext] - Logger context (default: silent logger)
118
- * @returns {Promise<{ serviceTag: string, count: number, durationMs: number }>}
119
- */
120
108
  export async function generateIntTest(rootPath, options = {}) {
121
109
  const {
122
110
  outputPath = rootPath,
123
111
  s3Prefix = null,
124
- _izContext = { logger: { debug: () => {}, info: console.info, warn: console.warn, error: console.error } }
112
+ _izContext = {
113
+ logger: {
114
+ debug: () => {},
115
+ info: console.info,
116
+ warn: console.warn,
117
+ error: console.error
118
+ }
119
+ }
125
120
  } = options;
126
121
 
127
122
  const startTime = Date.now();
128
123
  const serviceTag = getServiceTag(rootPath);
129
124
  if (!serviceTag) {
130
- throw new Error('Missing iz_serviceTag in serverless.config.yml — required for IntTest generation');
125
+ throw new Error('Missing iz_serviceTag in serverless.config.yml — required IntTest generation');
131
126
  }
132
127
 
133
128
  const savePath = join(outputPath, 'src', 'generateIntegrationTest');
134
-
135
- // Get IntTest data (events + tests + pathIntTest) from sub-orchestrator
136
129
  const items = await generateTestTemplate(_izContext, savePath, {
137
130
  serviceTag,
138
131
  rootPath,
139
132
  s3Prefix
140
133
  });
141
134
 
142
- // Validate phase: compile each template to catch errors early
143
- for (const item of items) {
144
- if (!item || !item.templatePath || !item.templateData || !item.setting) {
145
- throw new Error('Invalid IntTest source item: missing templatePath/templateData/setting');
146
- }
147
- const [status, errors] = await writeSource(item, { checkCreateSourcePass: true });
148
- if (!status) {
149
- throw new Error(`IntTest template validation failed: ${errors?.message || errors}`);
150
- }
151
- }
152
-
153
- // Write phase: render + write each file (mirrors legacy two-pass pattern)
154
- for (const item of items) {
155
- if (item.setting?.savePath && existsSync(item.setting.savePath)) {
156
- rmSync(item.setting.savePath, { recursive: true, force: true });
157
- }
158
- await writeSource(item, { checkCreateSourcePass: false });
159
- }
160
-
161
- // Note: legacy `uploadLib.uploadTos3(...)` was called here. S3 upload is intentionally
162
- // skipped in this refactor — downstream services can upload manually if needed.
135
+ await runTemplateItems(items, {
136
+ writeSource,
137
+ errorPrefix: 'IntTest source'
138
+ });
163
139
 
164
140
  const durationMs = Date.now() - startTime;
165
141
  return { serviceTag, count: items.length, durationMs };