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

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 (146) 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 +16 -16
  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 +2 -9
  15. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/WebSocketGenerator.js +1 -7
  16. package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/BaseSqsHandler.js +3 -3
  17. package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3Components/ConfirmAfterUploadS3Generator.js +2 -4
  18. package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3Components/CreateObjectGenerator.js +2 -4
  19. package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3Components/CreatePreSignUrlGenerator.js +2 -4
  20. package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3Components/ProcessAfterUploadS3Generator.js +5 -5
  21. package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3Components/ReservedLimitGenerator.js +2 -4
  22. package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowEntryPointBase.js +6 -6
  23. package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowMainFunctionBase.js +3 -3
  24. package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowStepBase.js +11 -11
  25. package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/triggerCacheBase.js +1 -7
  26. package/src/codeGenerators/app/src/generatedCode/ProcessLogical/ProcessLogicalGenerator.js +18 -15
  27. package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/{PaginateProcessLogical_HdrDsq.js → PaginateProcessLogical_HdrDsq.ejs} +1 -1
  28. package/src/codeGenerators/app/src/generatedCode/SystemFlowSchemas/RegisterGenerator.js +127 -149
  29. package/src/codeGenerators/app/src/generatedCode/libs/ConstsGenerator.js +16 -8
  30. package/src/codeGenerators/app/src/generatedCode/libs/GenerateCodeLibsGenerator.js +17 -9
  31. package/src/codeGenerators/resource/sls_yaml/DynamoDBGenerator.js +8 -8
  32. package/src/codeGenerators/resource/sls_yaml/FlowOutGenerator.js +60 -43
  33. package/src/codeGenerators/resource/sls_yaml/FlowResourceYamlGenerator.js +151 -151
  34. package/src/codeGenerators/resource/sls_yaml/templates/crud/ResourceYaml.ejs +10 -10
  35. package/src/core/renderTemplateFile.js +22 -0
  36. package/src/generateCode.js +146 -81
  37. package/src/generateIntTest.js +45 -69
  38. package/src/generateResourceIntTest.js +22 -47
  39. package/src/intTestGeneratorShared.js +36 -0
  40. package/src/schemaGenerators/app/src/schemas/FlowSchemas/templates/DynamicFlowSchemaTemplate.ejs +12 -10
  41. package/src/schemaGenerators/app/src/schemas/FlowSchemas/templates/RelationshipFlowSchemaTemplate.ejs +6 -5
  42. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/flowSchemaMainFunction/data.js +0 -119
  43. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/flowSchemaMainFunction/template.ejs +0 -89
  44. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/flowSchemaMainFunction/templateByStatusType/statusFieldTemplate.ejs +0 -30
  45. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/flowSchemaMainFunction/templateByStatusType/storedCacheTemplate.ejs +0 -26
  46. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/flowSchemaMainFunction/templateByStatusType/triggerCacheTemplate.ejs +0 -44
  47. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/index.js +0 -80
  48. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/functionYaml/data.js +0 -129
  49. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/functionYaml/template.ejs +0 -17
  50. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/handler/data.js +0 -63
  51. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/mainFunction/data.js +0 -54
  52. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/mainFunction/template.ejs +0 -129
  53. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/queue/data.js +0 -63
  54. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/queue/template.ejs +0 -45
  55. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObject/functionYaml/data.js +0 -117
  56. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObject/functionYaml/template.ejs +0 -20
  57. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObject/handler/data.js +0 -64
  58. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObject/mainFunction/data.js +0 -64
  59. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObject/mainFunction/template.ejs +0 -131
  60. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/functionYaml/data.js +0 -122
  61. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/functionYaml/template.ejs +0 -17
  62. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/handler/data.js +0 -66
  63. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/handler/template.ejs +0 -99
  64. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/mainFunction/data.js +0 -64
  65. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/mainFunction/template.ejs +0 -82
  66. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/sns-sqs/data.js +0 -70
  67. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/sns-sqs/template.ejs +0 -49
  68. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/functionYaml/data.js +0 -139
  69. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/functionYaml/template.ejs +0 -18
  70. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/handler/data.js +0 -63
  71. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/mainFunction/data.js +0 -63
  72. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/mainFunction/template.ejs +0 -262
  73. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/queue/data.js +0 -63
  74. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/queue/template.ejs +0 -45
  75. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/functionYaml/data.js +0 -146
  76. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/functionYaml/template.ejs +0 -14
  77. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/handler/data.js +0 -64
  78. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/mainFunction/data.js +0 -59
  79. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +0 -173
  80. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/sqs/data.js +0 -67
  81. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/sqs/template.ejs +0 -53
  82. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/functionYml/HdrS3/data.js +0 -140
  83. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/functionYml/HdrS3/template.ejs +0 -25
  84. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/handler/handlerS3/data.js +0 -49
  85. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/handler/handlerS3/template.ejs +0 -50
  86. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/mainFunction/ProcessCsvtemplate.ejs +0 -182
  87. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/mainFunction/data.js +0 -49
  88. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/mainFunction/template.ejs +0 -66
  89. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/queue/data.js +0 -77
  90. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/queue/dsqTemplatePath.ejs +0 -32
  91. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/queue/s3Template.ejs +0 -59
  92. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/relate/S3/data.js +0 -61
  93. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/relate/S3/template.ejs +0 -13
  94. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/relate/sns-out/data.js +0 -70
  95. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/websocket/dynamoDb/ReservedTableData.js +0 -69
  96. package/src/codeGenerators/app/src/generatedCode/Flow/SystemFlowDescriptorBuilder.js +0 -151
  97. /package/src/codeGenerators/app/{src/generatedCode/FindData → sls_yaml}/templates/FindData_Yaml.ejs +0 -0
  98. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared/endpoint → FlowEndpoints/templates}/FlowEndpointBeforeLogical_Main.ejs +0 -0
  99. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/endpoint/FlowEndpoint_HdrWbs.ejs +0 -0
  100. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/endpoint/FlowEndpoint_Main.ejs +0 -0
  101. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/endpoint/FlowEntryPoint_Main.ejs +0 -0
  102. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/endpoint/FlowMain_Wbs.ejs +0 -0
  103. /package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/{s3Legacy/upload/confirmReserved/handler/template.ejs → s3/ConfirmReserved_HdrSqs.ejs} +0 -0
  104. /package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/{s3Legacy/upload/createObject/handler/template.ejs → s3/CreateObject_HdrWbs.ejs} +0 -0
  105. /package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/{s3Legacy/upload/preSignUrl/createPreSignUrl/handler/template.ejs → s3/CreatePreSignUrl_HdrSqs.ejs} +0 -0
  106. /package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/{s3Legacy/upload/preSignUrl/reservedLimit/handler/template.ejs → s3/ReservedLimit_HdrSqs.ejs} +0 -0
  107. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/FlowEndpointComplete_Main.ejs +0 -0
  108. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/FlowStep_Main.ejs +0 -0
  109. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/FlowStep_ByConfig_Awaiting_Main.ejs +0 -0
  110. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/FlowStep_ByConfig_Paginated_Main.ejs +0 -0
  111. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/FlowStep_PlugIn_Main.ejs +0 -0
  112. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/FlowStep_RecievePlugIn_Main.ejs +0 -0
  113. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/templateAwaitingStep.ejs +0 -0
  114. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/templateSendPlugin.ejs +0 -0
  115. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/eventBridge.js +0 -0
  116. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/extTopic.js +0 -0
  117. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/lambdaSyncApi.js +0 -0
  118. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/lambdaSyncInv.js +0 -0
  119. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/ownTopic.js +0 -0
  120. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/registry.js +0 -0
  121. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3.js +0 -0
  122. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/handlers/FlowHandler_HdrApi.ejs +0 -0
  123. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/handlers/FlowHandler_HdrInv.ejs +0 -0
  124. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/handlers/FlowHandler_HdrSqs.ejs +0 -0
  125. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/eventTypes.js +0 -0
  126. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowClassifier.js +0 -0
  127. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowNaming.js +0 -0
  128. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowSelection.js +0 -0
  129. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowStepNormalizer.js +0 -0
  130. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowValidator.js +0 -0
  131. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/registry.js +0 -0
  132. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/CheckTriggerCache_HdrSqs.ejs +0 -0
  133. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/CheckTriggerCache_Main.ejs +0 -0
  134. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/ProcessTriggerCache_HdrSqs.ejs +0 -0
  135. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/ProcessTriggerCache_Main.ejs +0 -0
  136. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/TriggerCacheComplete_HdrDsq.ejs +0 -0
  137. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/TriggerCacheComplete_HdrSqs.ejs +0 -0
  138. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/TriggerCacheComplete_Main.ejs +0 -0
  139. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/TriggerCacheQueue_Yaml.ejs +0 -0
  140. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/yaml/SharedFunctionSqs_Yaml.ejs +0 -0
  141. /package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/{PaginateProcessLogical_HdrSqs.js → PaginateProcessLogical_HdrSqs.ejs} +0 -0
  142. /package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/{PaginateProcessLogical_Main.js → PaginateProcessLogical_Main.ejs} +0 -0
  143. /package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/{ProcessLogical_HdrSqs.js → ProcessLogical_HdrSqs.ejs} +0 -0
  144. /package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/{ProcessLogical_Main.js → ProcessLogical_Main.ejs} +0 -0
  145. /package/src/codeGenerators/app/src/generatedCode/libs/templates/{Consts.js → Consts.ejs} +0 -0
  146. /package/src/codeGenerators/app/src/generatedCode/libs/templates/{GenerateCodeLibs.js → GenerateCodeLibs.ejs} +0 -0
@@ -5,17 +5,17 @@ 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';
8
+ import { generateFlowEntryPoint } from './codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowEntryPointBase.js';
9
+ import { generateFlowMainFunction } from './codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowMainFunctionBase.js';
10
+ import { generateFlowSteps } from './codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowStepBase.js';
9
11
 
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';
12
+ import { generateEndpointsFlow } from './codeGenerators/app/src/generatedCode/Flow/FlowEndpoints/EndpointsGenerator.js';
13
13
  import { generateFlowOut } from './codeGenerators/resource/sls_yaml/FlowOutGenerator.js';
14
14
  import { generateFlowResourceYaml } from './codeGenerators/resource/sls_yaml/FlowResourceYamlGenerator.js';
15
15
  import { generateRbacFlows } from './codeGenerators/app/src/generatedCode/Flow/FlowRbac/RbacFlowGenerator.js';
16
16
  import { generateRelationshipFlows } from './codeGenerators/app/src/generatedCode/Flow/FlowRelationshipEndpoints/RelationshipFlowGenerator.js';
17
17
  import { generateWebSocket } from './codeGenerators/app/src/generatedCode/Flow/FlowSchemas/WebSocketGenerator.js';
18
- import { validateFlowsForGeneration } from './codeGenerators/app/src/generatedCode/Flow/_internal/shared/flowValidator.js';
18
+ import { validateFlowsForGeneration } from './codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowValidator.js';
19
19
  import { generateRegisterFlow } from './codeGenerators/app/src/generatedCode/SystemFlowSchemas/RegisterGenerator.js';
20
20
  import { generateDynamoDBTables } from './codeGenerators/resource/sls_yaml/DynamoDBGenerator.js';
21
21
  import { generateFindData } from './codeGenerators/app/src/generatedCode/FindData/FindDataGenerator.js';
@@ -27,47 +27,108 @@ import { generateConsts } from './codeGenerators/app/src/generatedCode/libs/Cons
27
27
  import { generateProcessLogical } from './codeGenerators/app/src/generatedCode/ProcessLogical/ProcessLogicalGenerator.js';
28
28
  import { generateProcessLogicalYaml } from './codeGenerators/app/sls_yaml/ProcessLogicalYamlGenerator.js';
29
29
  import { generateSharedResourceYaml } from './codeGenerators/app/sls_yaml/SharedResourceYamlGenerator.js';
30
+ import { generateFindDataYaml } from './codeGenerators/app/sls_yaml/FindDataYamlGenerator.js';
30
31
  import { policyRegistry } from './codeGenerators/app/sls_yaml/_policy/PolicyRegistry.js';
31
32
  import { emitManagedPolicies } from './codeGenerators/app/sls_yaml/_policy/PolicyEmitter.js';
32
33
 
33
- export async function generateCode(rootPath, options) {
34
+ function createGeneratorOptions(rootPath, options = {}) {
35
+ return {
36
+ outputPath: options.outputPath || rootPath
37
+ };
38
+ }
39
+
40
+ export async function generateCode(rootPath, options = {}) {
34
41
  console.log(
35
42
  '[INFO] [generateCode] STATUS=STARTING | Generating code files from all schemas...'
36
43
  );
37
44
 
45
+ const generatorOptions = createGeneratorOptions(rootPath, options);
46
+ const { outputPath } = generatorOptions;
47
+
38
48
  // Clean workspace
39
- const outputPath = options.outputPath || rootPath;
40
- const generatedCodePath = path.join(outputPath, 'app', 'src', 'generatedCode');
49
+ const generatedCodePath = path.join(
50
+ outputPath,
51
+ 'app',
52
+ 'src',
53
+ 'generatedCode'
54
+ );
41
55
 
42
56
  // Backup existing hook files to prevent them from being wiped out
43
57
  const hookBackups = [];
44
- function backupHooks(currentDir) {
58
+ const hookDirs = new Set();
59
+
60
+ function getHookTagMatchers(filePath) {
61
+ if (filePath.endsWith('.js')) {
62
+ return {
63
+ anyTag: /\/\/\(<(\w+)>\)([\s\S]*?)\/\/\(<\/\1>\)/gm,
64
+ tagPattern: name =>
65
+ new RegExp(
66
+ `\\/\\/\\(<${name}>\\)([\\s\\S]*?)\\/\\/\\(<\\/${name}>\\)`,
67
+ 'gm'
68
+ )
69
+ };
70
+ }
71
+
72
+ if (filePath.endsWith('.yml') || filePath.endsWith('.yaml')) {
73
+ return {
74
+ anyTag: /#<#(\w+)#>([\s\S]*?)#<#\/\1#>/gm,
75
+ tagPattern: name =>
76
+ new RegExp(`#<#${name}#>([\\s\\S]*?)#<#\\/${name}#>`, 'gm')
77
+ };
78
+ }
79
+
80
+ return null;
81
+ }
82
+
83
+ function mergeHookIntoSource(sourceContent, hookContent, filePath) {
84
+ const matchers = getHookTagMatchers(filePath);
85
+ if (!matchers) return hookContent;
86
+
87
+ return sourceContent.replace(
88
+ matchers.anyTag,
89
+ (match, tagName) =>
90
+ hookContent.match(matchers.tagPattern(tagName))?.[0] ?? match
91
+ );
92
+ }
93
+
94
+ function collectHookBackups(currentDir) {
45
95
  if (!fs.existsSync(currentDir)) return;
96
+
46
97
  const items = fs.readdirSync(currentDir, { withFileTypes: true });
98
+ const hasSource = items.some(
99
+ item => item.isDirectory() && item.name === 'source'
100
+ );
101
+ const hasHook = items.some(
102
+ item => item.isDirectory() && item.name === 'hook'
103
+ );
47
104
 
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
- }
105
+ if (hasSource && hasHook) {
106
+ const hookPath = path.join(currentDir, 'hook');
107
+ hookDirs.add(path.relative(outputPath, hookPath));
108
+ const hookItems = fs.readdirSync(hookPath, { withFileTypes: true });
109
+
110
+ for (const hookItem of hookItems) {
111
+ if (!hookItem.isFile()) continue;
112
+ const hookFilePath = path.join(hookPath, hookItem.name);
113
+ hookBackups.push({
114
+ relativePath: path.relative(outputPath, hookPath),
115
+ name: hookItem.name,
116
+ content: fs.readFileSync(hookFilePath)
117
+ });
65
118
  }
66
119
  }
120
+
121
+ for (const item of items) {
122
+ if (!item.isDirectory() || item.name === 'source' || item.name === 'hook')
123
+ continue;
124
+ collectHookBackups(path.join(currentDir, item.name));
125
+ }
67
126
  }
68
-
69
- console.log('[INFO] [generateCode] STATUS=BACKUP | Backing up existing hook files...');
70
- backupHooks(generatedCodePath);
127
+
128
+ console.log(
129
+ '[INFO] [generateCode] STATUS=BACKUP | Backing up existing hook files...'
130
+ );
131
+ collectHookBackups(outputPath);
71
132
 
72
133
  console.log(
73
134
  '[INFO] [generateCode] STATUS=CLEANUP | Removing old generatedCode and resource directories...'
@@ -97,38 +158,19 @@ export async function generateCode(rootPath, options) {
97
158
  console.log('[INFO] [generateCode] STATUS=PARSING | FlowSchemas...');
98
159
  const flowData = await parseFlowSchemas(rootPath, objectData, options);
99
160
 
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
161
  // The 'allSchemas' object contains the fully hydrated Memory Objects
108
162
  const allSchemas = {
109
163
  objects: objectData.objects,
110
164
  relationships: relationshipData.relationships,
111
165
  flows: flowData.flows,
112
- systemFlows: systemFlowData.flows,
113
- flowsForGeneration: [
114
- ...(flowData.flows || []),
115
- ...(systemFlowData.flows || [])
116
- ]
166
+ flowsForGeneration: flowData.flows || []
117
167
  };
118
168
 
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
169
  console.log('[INFO] [generateCode] STATUS=VALIDATING | Validating Flows...');
127
170
  validateFlowsForGeneration(allSchemas.flowsForGeneration);
128
171
 
129
- const generatorOptions = { outputPath: options.outputPath || rootPath };
130
-
131
172
  // 2. Generation Pipeline
173
+ await generateEndpointsFlow(allSchemas, generatorOptions);
132
174
  await generateFlowMainFunction(allSchemas, generatorOptions);
133
175
  await generateFlowEntryPoint(allSchemas, generatorOptions);
134
176
  await generateFlowSteps(allSchemas, generatorOptions);
@@ -136,11 +178,19 @@ export async function generateCode(rootPath, options) {
136
178
  await generateFlowResourceYaml(allSchemas, generatorOptions);
137
179
  await generateRbacFlows(allSchemas, generatorOptions);
138
180
  await generateRelationshipFlows(allSchemas, generatorOptions);
139
- await generateWebSocket(allSchemas.flowsForGeneration, '', generatorOptions.outputPath);
140
- await generateRegisterFlow(allSchemas.flowsForGeneration, '', generatorOptions.outputPath);
181
+ await generateWebSocket(
182
+ allSchemas.flowsForGeneration,
183
+ '',
184
+ generatorOptions.outputPath
185
+ );
186
+ await generateRegisterFlow(
187
+ allSchemas.flowsForGeneration,
188
+ '',
189
+ generatorOptions.outputPath
190
+ );
141
191
 
142
192
  // Call FunctionYamlGenerator after all Handlers have been generated
143
- await generateFunctionYaml(allSchemas, options);
193
+ await generateFunctionYaml(allSchemas, generatorOptions);
144
194
  await generateDynamoDBTables(allSchemas, generatorOptions);
145
195
  await generateFindData(allSchemas, generatorOptions);
146
196
  await generateCodeLibs(generatorOptions);
@@ -148,6 +198,7 @@ export async function generateCode(rootPath, options) {
148
198
  await generateProcessLogical(generatorOptions);
149
199
  await generateRoleNameConfig(allSchemas, generatorOptions);
150
200
  await generateProcessLogicalYaml(allSchemas, generatorOptions);
201
+ await generateFindDataYaml(generatorOptions);
151
202
  await generateSharedResourceYaml(allSchemas, generatorOptions);
152
203
  await generateInitialSetup(allSchemas, generatorOptions);
153
204
 
@@ -158,51 +209,65 @@ export async function generateCode(rootPath, options) {
158
209
 
159
210
  function processSourceHooks(currentDir) {
160
211
  if (!fs.existsSync(currentDir)) return;
161
- const items = fs.readdirSync(currentDir, { withFileTypes: true });
162
212
 
213
+ const items = fs.readdirSync(currentDir, { withFileTypes: true });
163
214
  const hasSource = items.some(
164
215
  item => item.isDirectory() && item.name === 'source'
165
216
  );
166
- if (hasSource) {
217
+ const hasHook = items.some(
218
+ item => item.isDirectory() && item.name === 'hook'
219
+ );
220
+
221
+ if (hasSource && hasHook) {
167
222
  const sourcePath = path.join(currentDir, 'source');
168
223
  const hookPath = path.join(currentDir, 'hook');
224
+ const hookItems = fs.readdirSync(hookPath, { withFileTypes: true });
225
+
226
+ for (const hookItem of hookItems) {
227
+ if (!hookItem.isFile()) continue;
169
228
 
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
- }
229
+ const hookFile = path.join(hookPath, hookItem.name);
230
+ const sourceFile = path.join(sourcePath, hookItem.name);
231
+
232
+ if (!fs.existsSync(sourceFile)) {
233
+ fs.copyFileSync(hookFile, sourceFile);
234
+ console.log(
235
+ `[INFO] [generateCode] HOOK APPLIED: Created ${hookItem.name} from hook.`
236
+ );
237
+ continue;
183
238
  }
239
+
240
+ const mergedContent = mergeHookIntoSource(
241
+ fs.readFileSync(sourceFile, 'utf8'),
242
+ fs.readFileSync(hookFile, 'utf8'),
243
+ sourceFile
244
+ );
245
+ fs.writeFileSync(sourceFile, mergedContent);
246
+ console.log(
247
+ `[INFO] [generateCode] HOOK APPLIED: Merged ${hookItem.name} into source.`
248
+ );
184
249
  }
250
+ } else if (hasSource) {
251
+ fs.mkdirSync(path.join(currentDir, 'hook'), { recursive: true });
185
252
  }
186
253
 
187
254
  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
- }
255
+ if (!item.isDirectory() || item.name === 'source' || item.name === 'hook')
256
+ continue;
257
+ processSourceHooks(path.join(currentDir, item.name));
195
258
  }
196
259
  }
197
260
 
198
261
  // Restore backed-up hooks
199
- if (hookBackups.length > 0) {
200
- console.log(`[INFO] [generateCode] STATUS=RESTORE | Restoring ${hookBackups.length} hook files...`);
262
+ if (hookDirs.size > 0 || hookBackups.length > 0) {
263
+ console.log(
264
+ `[INFO] [generateCode] STATUS=RESTORE | Restoring ${hookBackups.length} hook files...`
265
+ );
266
+ for (const relativeHookDir of hookDirs) {
267
+ fs.mkdirSync(path.join(outputPath, relativeHookDir), { recursive: true });
268
+ }
201
269
  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
- }
270
+ const hookDir = path.join(outputPath, backup.relativePath);
206
271
  fs.writeFileSync(path.join(hookDir, backup.name), backup.content);
207
272
  }
208
273
  }
@@ -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 };
@@ -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,33 +7,33 @@ 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, mkdirSync, existsSync, rmSync } from 'fs';
17
+ import { 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
 
23
21
  import generateResourceTemplate from './generateResources/IntTest/generateResources/generateResources.js';
22
+ import { getServiceTag, runTemplateItems } from './intTestGeneratorShared.js';
24
23
 
25
- // Minimal writeSource for resource generation (no hook support, no beautify — resources are .json)
26
24
  function writeSource({ templatePath, templateData, setting }, { checkCreateSourcePass = false } = {}) {
27
25
  if (!templatePath || !templateData || !setting) {
28
26
  throw new Error('Invalid IntTest resource item: missing templatePath/templateData/setting');
29
27
  }
28
+
30
29
  const { savePath, saveFileName, fileExtension } = setting;
31
30
 
32
31
  if (checkCreateSourcePass) {
33
32
  try {
34
33
  ejs.compile(readFileSync(templatePath, 'utf8'))(templateData);
35
34
  return [true, {}];
36
- } catch (err) {
37
- return [false, err];
35
+ } catch (error) {
36
+ return [false, error];
38
37
  }
39
38
  }
40
39
 
@@ -43,59 +42,35 @@ function writeSource({ templatePath, templateData, setting }, { checkCreateSourc
43
42
 
44
43
  const dataToSave = ejs.compile(readFileSync(templatePath, 'utf8'))(templateData);
45
44
  writeFileSync(filePath, dataToSave, 'utf8');
45
+ return [true, {}];
46
46
  }
47
47
 
48
- function getServiceTag(rootPath) {
49
- const configPath = join(rootPath, 'config', 'serverless.config.yml');
50
- const config = yaml.parse(readFileSync(configPath, 'utf8'));
51
- return config?.main_config?.iz_serviceTag;
52
- }
53
-
54
- /**
55
- * Generate integration test shared resources (tableNames + function components) for the service.
56
- * Result-Driven refactor: flat pipeline, no createSource/libs dependencies.
57
- *
58
- * @param {string} rootPath - Service root path containing /config and /app
59
- * @param {Object} [options]
60
- * @param {string} [options.outputPath] - Where to write (default: rootPath)
61
- * @param {Object} [options._izContext] - Logger context (default: silent logger)
62
- * @returns {Promise<{ serviceTag: string, count: number, durationMs: number }>}
63
- */
64
48
  export async function generateResourceIntTest(rootPath, options = {}) {
65
49
  const {
66
50
  outputPath = rootPath,
67
- _izContext = { logger: { debug: () => {}, info: console.info, warn: console.warn, error: console.error } }
51
+ _izContext = {
52
+ logger: {
53
+ debug: () => {},
54
+ info: console.info,
55
+ warn: console.warn,
56
+ error: console.error
57
+ }
58
+ }
68
59
  } = options;
69
60
 
70
61
  const startTime = Date.now();
71
62
  const serviceTag = getServiceTag(rootPath);
72
63
  if (!serviceTag) {
73
- throw new Error('Missing iz_serviceTag in serverless.config.yml — required for IntTest resource generation');
64
+ throw new Error('Missing iz_serviceTag in serverless.config.yml — required IntTest resource generation');
74
65
  }
75
66
 
76
67
  const savePath = join(outputPath, 'src', 'generateIntegrationTest');
77
-
78
- // Get IntTest resource data from sub-orchestrator
79
68
  const items = await generateResourceTemplate(_izContext, savePath, { serviceTag });
80
69
 
81
- // Validate phase
82
- for (const item of items) {
83
- if (!item || !item.templatePath || !item.templateData || !item.setting) {
84
- throw new Error('Invalid IntTest resource item: missing templatePath/templateData/setting');
85
- }
86
- const [status, errors] = writeSource(item, { checkCreateSourcePass: true });
87
- if (!status) {
88
- throw new Error(`IntTest resource template validation failed: ${errors?.message || errors}`);
89
- }
90
- }
91
-
92
- // Write phase
93
- for (const item of items) {
94
- if (item.setting?.savePath && existsSync(item.setting.savePath)) {
95
- rmSync(item.setting.savePath, { recursive: true, force: true });
96
- }
97
- writeSource(item, { checkCreateSourcePass: false });
98
- }
70
+ await runTemplateItems(items, {
71
+ writeSource,
72
+ errorPrefix: 'IntTest resource'
73
+ });
99
74
 
100
75
  const durationMs = Date.now() - startTime;
101
76
  return { serviceTag, count: items.length, durationMs };