@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-core-generate-service-code",
3
- "version": "1.0.53",
3
+ "version": "1.0.55",
4
4
  "description": "Code for locally generating per service files",
5
5
  "homepage": "https://bitbucket.org/izara-core-support-services/izara-core-support-services-generate-service-code#readme",
6
6
  "repository": {
@@ -28,7 +28,6 @@
28
28
  "@izara_project/izara-shared-service-schemas": "^1.0.64",
29
29
  "ejs": "^5.0.1",
30
30
  "js-beautify": "^1.15.4",
31
- "lodash": "^4.18.1",
32
31
  "yaml": "^2.9.0"
33
32
  },
34
33
  "devDependencies": {
@@ -2,7 +2,7 @@ import path from 'path';
2
2
  import fs from 'fs/promises';
3
3
  import ejs from 'ejs';
4
4
  import { fileURLToPath } from 'url';
5
- import { getFlowsForGeneration } from '../src/generatedCode/Flow/_internal/shared/flowSelection.js';
5
+ import { getFlowsForGeneration } from '../src/generatedCode/Flow/_shared/shared/flowSelection.js';
6
6
 
7
7
  const __filename = fileURLToPath(import.meta.url);
8
8
  const __dirname = path.dirname(__filename);
@@ -0,0 +1,23 @@
1
+ import path from 'path';
2
+ import { fileURLToPath } from 'url';
3
+ import { renderYamlTemplate } from './renderYamlTemplate.js';
4
+
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = path.dirname(__filename);
7
+
8
+ export async function generateFindDataYaml(options) {
9
+ console.log(' [FindDataYamlGenerator] Generating FindData YAML...');
10
+
11
+ await renderYamlTemplate(
12
+ path.join(__dirname, 'templates', 'FindData_Yaml.ejs'),
13
+ path.join(options.outputPath, 'app', 'sls_yaml', 'generatedCode', 'source', 'find-data.yml'),
14
+ {
15
+ functionName: 'FindData',
16
+ handlerPath: 'src/generatedCode/FindData/source/FindData_HdrSqs.main',
17
+ roleName: 'ProcFindData',
18
+ upperFunctionName: 'FINDDATA',
19
+ upperHandlerType: 'HDRSQS'
20
+ },
21
+ 'FindDataYamlGenerator'
22
+ );
23
+ }
@@ -2,7 +2,7 @@ import fs from 'fs/promises';
2
2
  import path from 'path';
3
3
  import ejs from 'ejs';
4
4
  import { fileURLToPath } from 'url';
5
- import { getFlowsForGeneration } from '../src/generatedCode/Flow/_internal/shared/flowSelection.js';
5
+ import { getFlowsForGeneration } from '../src/generatedCode/Flow/_shared/shared/flowSelection.js';
6
6
 
7
7
  const __filename = fileURLToPath(import.meta.url);
8
8
  const __dirname = path.dirname(__filename);
@@ -103,7 +103,7 @@ export async function generateFunctionYaml(allSchemas, options) {
103
103
 
104
104
  // Function Name Config
105
105
  // e.g. ProcessCreateSqs or CreateCompleteSqs or GetApi
106
- let suffixType = handlerSuffix.replace('Hdr', ''); // Sqs, Api, Inv
106
+ let suffixType = handlerSuffix.startsWith('Hdr') ? handlerSuffix : handlerSuffix.replace('Hdr', '');
107
107
  let functionNameConfig = `${handlerBaseName}${suffixType}`;
108
108
  if (isCrud && handlerBaseName === `Process${upperCase(flowTag)}`) {
109
109
  // Legacy matches: CreateSqs, GetApi instead of ProcessCreateSqs
@@ -133,19 +133,19 @@ export async function generateFunctionYaml(allSchemas, options) {
133
133
 
134
134
  if (isCrud || isRel) {
135
135
  queueName = handlerBaseName.replace('Process', '');
136
- if (handlerSuffix === 'HdrSqs' || handlerSuffix === 'HdrDsq') {
137
- queueName += handlerSuffix.replace('Hdr', '');
138
- }
136
+ if (handlerSuffix === 'HdrSqs' || handlerSuffix === 'HdrDsq') {
137
+ queueName += handlerSuffix;
138
+ }
139
139
  } else {
140
140
  // For Custom Flows (e.g. OwnTopicFlowProcess, ProcessExtTopicFlow)
141
141
  // The queue name exactly matches the handler name without the underscore.
142
142
  if (handlerSuffix === 'HdrSqs' || handlerSuffix === 'HdrDsq') {
143
143
  if (handlerBaseName === `Process${upperCase(flowTag)}` && flowDefForQueue && flowDefForQueue.event && flowDefForQueue.event.includes('ownTopic')) {
144
144
  // ownTopic flows in FlowResourceYamlGenerator omit 'Process' for the queue
145
- queueName = flowTag + handlerSuffix.replace('Hdr', '');
146
- } else {
147
- queueName = handlerBaseName + handlerSuffix.replace('Hdr', '');
148
- }
145
+ queueName = flowTag + handlerSuffix;
146
+ } else {
147
+ queueName = handlerBaseName + handlerSuffix;
148
+ }
149
149
  } else {
150
150
  queueName = handlerBaseName;
151
151
  }
@@ -153,7 +153,7 @@ export async function generateFunctionYaml(allSchemas, options) {
153
153
 
154
154
  // Api routes
155
155
  let apiRoutes = [];
156
- if (suffixType === 'Api') {
156
+ if (suffixType === 'HdrApi' || suffixType === 'Api') {
157
157
  const routesList = isCrud ? crudApiRoutes : (isRel ? relApiRoutes : []);
158
158
  const actionPath = flowTag.toLowerCase().replace('relationship', '');
159
159
  apiRoutes = routesList.map(r => ({
@@ -166,7 +166,7 @@ export async function generateFunctionYaml(allSchemas, options) {
166
166
  const handlerPath = `src/generatedCode/${subDir}/${flowTag}/source/${fileNameWithoutExt}.main`;
167
167
 
168
168
  let filterPatterns = '';
169
- if (handlerBaseName.endsWith('Complete') && (suffixType === 'Sqs' || suffixType === 'Dsq')) {
169
+ if (handlerBaseName.endsWith('Complete') && (suffixType === 'HdrSqs' || suffixType === 'HdrDsq' || suffixType === 'Sqs' || suffixType === 'Dsq')) {
170
170
  filterPatterns = ` filterPatterns: #**** need to update serverless framework upper v.2.69.1
171
171
  - body: {"MessageAttributes":{"callingFlow":{"Value":["\${self:custom.iz_resourcePrefix}${functionNameConfig}"]}}} # functionName of callingFlow
172
172
  - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}`;
@@ -190,15 +190,15 @@ export async function generateFunctionYaml(allSchemas, options) {
190
190
  };
191
191
 
192
192
  let yamlBlock = '';
193
- if (schedules.length > 0 && suffixType === 'Inv') {
193
+ if (schedules.length > 0 && (suffixType === 'HdrInv' || suffixType === 'Inv')) {
194
194
  yamlBlock = ejs.render(templates.eventBridge, renderVars);
195
- } else if (suffixType === 'Sqs' || suffixType === 'Dsq') {
195
+ } else if (suffixType === 'HdrSqs' || suffixType === 'HdrDsq' || suffixType === 'Sqs' || suffixType === 'Dsq') {
196
196
  yamlBlock = ejs.render(templates.sqs, renderVars);
197
- } else if (suffixType === 'Inv') {
197
+ } else if (suffixType === 'HdrInv' || suffixType === 'Inv') {
198
198
  yamlBlock = ejs.render(templates.inv, renderVars);
199
- } else if (suffixType === 'Api') {
199
+ } else if (suffixType === 'HdrApi' || suffixType === 'Api') {
200
200
  yamlBlock = ejs.render(templates.api, renderVars);
201
- } else if (suffixType === 'Wbs') {
201
+ } else if (suffixType === 'HdrWbs' || suffixType === 'Wbs') {
202
202
  renderVars.routeName = flowTag;
203
203
  yamlBlock = ejs.render(templates.wbs, renderVars);
204
204
  } else {
@@ -1,35 +1,21 @@
1
- import fs from 'fs/promises';
2
1
  import path from 'path';
3
- import ejs from 'ejs';
4
2
  import { fileURLToPath } from 'url';
3
+ import { renderYamlTemplate } from './renderYamlTemplate.js';
5
4
 
6
5
  const __filename = fileURLToPath(import.meta.url);
7
6
  const __dirname = path.dirname(__filename);
8
7
 
9
8
  export async function generateProcessLogicalYaml(allSchemas, options) {
10
- console.log(' [ProcessLogicalYamlGenerator] Generating ProcessLogical YAML...');
11
-
12
- // We only generate if ProcessLogical actually exists in the schemas or if there are objects.
13
- // In most cases, if there are objects, ProcessLogical is needed.
14
- if (!allSchemas.objects || allSchemas.objects.length === 0) {
15
- return;
16
- }
9
+ console.log(' [ProcessLogicalYamlGenerator] Generating ProcessLogical YAML...');
17
10
 
18
- const slsYamlDir = path.join(options.outputPath, 'app', 'sls_yaml', 'generatedCode', 'source');
19
- await fs.mkdir(slsYamlDir, { recursive: true });
11
+ if (!allSchemas.objects || allSchemas.objects.length === 0) {
12
+ return;
13
+ }
20
14
 
21
- const templatePath = path.join(__dirname, 'templates', 'ProcessLogical_Yaml.ejs');
22
- let templateString;
23
- try {
24
- templateString = await fs.readFile(templatePath, 'utf-8');
25
- } catch (e) {
26
- console.error('Error reading ProcessLogical YAML template:', e);
27
- return;
28
- }
29
-
30
- const fileContent = ejs.render(templateString, {});
31
- const outputPath = path.join(slsYamlDir, 'process-logical.yml');
32
-
33
- await fs.writeFile(outputPath, fileContent, 'utf-8');
34
- console.log(` [ProcessLogicalYamlGenerator] Wrote process-logical.yml to ${outputPath}`);
15
+ await renderYamlTemplate(
16
+ path.join(__dirname, 'templates', 'ProcessLogical_Yaml.ejs'),
17
+ path.join(options.outputPath, 'app', 'sls_yaml', 'generatedCode', 'source', 'process-logical.yml'),
18
+ {},
19
+ 'ProcessLogicalYamlGenerator'
20
+ );
35
21
  }
@@ -2,7 +2,7 @@ import fs from 'fs/promises';
2
2
  import path from 'path';
3
3
  import ejs from 'ejs';
4
4
  import { fileURLToPath } from 'url';
5
- import { getFlowsForGeneration } from '../src/generatedCode/Flow/_internal/shared/flowSelection.js';
5
+ import { getFlowsForGeneration } from '../src/generatedCode/Flow/_shared/shared/flowSelection.js';
6
6
 
7
7
  const __filename = fileURLToPath(import.meta.url);
8
8
  const __dirname = path.dirname(__filename);
@@ -3,7 +3,7 @@ import path from 'path';
3
3
  import ejs from 'ejs';
4
4
  import { fileURLToPath } from 'url';
5
5
  import { policyRegistry } from './_policy/PolicyRegistry.js';
6
- import { getFlowsForGeneration } from '../src/generatedCode/Flow/_internal/shared/flowSelection.js';
6
+ import { getFlowsForGeneration } from '../src/generatedCode/Flow/_shared/shared/flowSelection.js';
7
7
 
8
8
  const __filename = fileURLToPath(import.meta.url);
9
9
  const __dirname = path.dirname(__filename);
@@ -460,8 +460,8 @@ export async function generateSharedResourceYaml(allSchemas, options) {
460
460
  .join('\n');
461
461
 
462
462
  normalizedContent = normalizedContent
463
- .replace(/^ [A-Za-z0-9]+:/gm, '\n$&')
464
- .replace(/^Resources:\n+ /, 'Resources:\n ') + '\n';
463
+ .replace(/^ [A-Za-z0-9]+:/gm, '\n\n$&')
464
+ .replace(/^Resources:\n+ /, 'Resources:\n\n ') + '\n';
465
465
 
466
466
  const outputPath = path.join(slsYamlDir, 'generate-shared-resource.yml');
467
467
  await fs.writeFile(outputPath, normalizedContent, 'utf-8');
@@ -0,0 +1,13 @@
1
+ import path from 'path';
2
+ import { writeRenderedTemplate } from '../../../core/renderTemplateFile.js';
3
+
4
+ async function renderYamlTemplate(templatePath, outputPath, templateData, logLabel) {
5
+ try {
6
+ await writeRenderedTemplate(templatePath, outputPath, templateData);
7
+ console.log(` [${logLabel}] Wrote ${path.basename(outputPath)} to ${outputPath}`);
8
+ } catch (error) {
9
+ console.error(` [${logLabel}] Error rendering ${path.basename(templatePath)}:`, error);
10
+ }
11
+ }
12
+
13
+ export { renderYamlTemplate };
@@ -11,10 +11,12 @@ Resources:
11
11
  Principal:
12
12
  Service: "lambda.amazonaws.com"
13
13
  Action: sts:AssumeRole
14
+ #<#<%- roleName %>AssumeRoleStatementHookCode#>
15
+ #<#/<%- roleName %>AssumeRoleStatementHookCode#>
14
16
  ManagedPolicyArns:
15
17
  - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
16
- //(<<%- roleName %>ManagedPolicyArns>)
17
- //(</<%- roleName %>ManagedPolicyArns>)
18
+ #<#<%- roleName %>ManagedPolicyArns#>
19
+ #<#/<%- roleName %>ManagedPolicyArns#>
18
20
  Policies:
19
21
  - PolicyName: ${self:custom.iz_resourcePrefix}<%- roleName %>Policy
20
22
  PolicyDocument:
@@ -31,5 +33,7 @@ Resources:
31
33
  - "<%- r %>"
32
34
  <% }) %>
33
35
  <% }) %>
36
+ #<#<%- roleName %>StatementHookCode#>
37
+ #<#/<%- roleName %>StatementHookCode#>
34
38
 
35
39
  <% }) %>
@@ -2,6 +2,7 @@ import fs from 'fs/promises';
2
2
  import path from 'path';
3
3
  import ejs from 'ejs';
4
4
  import { fileURLToPath } from 'url';
5
+ import { writeRenderedTemplate } from '../../../../../core/renderTemplateFile.js';
5
6
 
6
7
  const __filename = fileURLToPath(import.meta.url);
7
8
  const __dirname = path.dirname(__filename);
@@ -22,16 +23,7 @@ export async function generateFindData(allSchemas, generatorOptions) {
22
23
  'FindData',
23
24
  'source'
24
25
  );
25
- const yamlOutputPath = path.join(
26
- generatorOptions.outputPath,
27
- 'app',
28
- 'sls_yaml',
29
- 'generatedCode',
30
- 'source'
31
- );
32
-
33
26
  await fs.mkdir(outputPath, { recursive: true });
34
- await fs.mkdir(yamlOutputPath, { recursive: true });
35
27
 
36
28
  const datas = [];
37
29
 
@@ -229,44 +221,18 @@ export async function generateFindData(allSchemas, generatorOptions) {
229
221
  objectTypeBlocks += `\n }\n //(<additionalObjectType>)\n //(</additionalObjectType>)\n else {\n errorsFound.push('unrecognized objectType');\n standardErrorParams.push(errorsFound);\n await findDataSharedLib.completeFindDataMain(...standardErrorParams);\n return { returnResponse: 'Function FindData Error' };\n }`;
230
222
  }
231
223
 
232
- // Generate FindData_Main.js
233
- const mainTemplatePath = path.join(
234
- __dirname,
235
- 'templates',
236
- 'FindData_Main.ejs'
224
+ await writeRenderedTemplate(
225
+ path.join(__dirname, 'templates', 'FindData_Main.ejs'),
226
+ path.join(outputPath, 'FindData_Main.js'),
227
+ { objectTypeBlocks }
237
228
  );
238
- const mainTemplate = await fs.readFile(mainTemplatePath, 'utf8');
239
- const mainContent = ejs.render(mainTemplate, { objectTypeBlocks });
240
- await fs.writeFile(path.join(outputPath, 'FindData_Main.js'), mainContent);
241
-
242
- // Generate FindData_HdrSqs.js
243
- const sqsTemplatePath = path.join(
244
- __dirname,
245
- 'templates',
246
- 'FindData_HdrSqs.ejs'
229
+ await writeRenderedTemplate(
230
+ path.join(__dirname, 'templates', 'FindData_HdrSqs.ejs'),
231
+ path.join(outputPath, 'FindData_HdrSqs.js'),
232
+ {}
247
233
  );
248
- const sqsTemplate = await fs.readFile(sqsTemplatePath, 'utf8');
249
- const sqsContent = ejs.render(sqsTemplate, {});
250
- await fs.writeFile(path.join(outputPath, 'FindData_HdrSqs.js'), sqsContent);
251
234
 
252
- // Generate FindData YAML
253
- const yamlTemplatePath = path.join(
254
- __dirname,
255
- 'templates',
256
- 'FindData_Yaml.ejs'
257
- );
258
- const yamlTemplate = await fs.readFile(yamlTemplatePath, 'utf8');
259
- const yamlContent = ejs.render(yamlTemplate, {
260
- functionName: 'FindData',
261
- handlerPath: 'src/generatedCode/FindData/source/FindData_HdrSqs.main',
262
- roleName: 'ProcFindData',
263
- upperFunctionName: 'FINDDATA',
264
- upperHandlerType: 'HDRSQS'
265
- });
266
- await fs.writeFile(
267
- path.join(yamlOutputPath, 'find-data.yml'),
268
- yamlContent
269
- );
235
+
270
236
 
271
237
  console.log(' [FindDataGenerator] Finished generating FindData logic.');
272
238
  }
@@ -0,0 +1,119 @@
1
+ import path from 'path';
2
+ import fs from 'fs/promises';
3
+ import { fileURLToPath } from 'url';
4
+ import ejs from 'ejs';
5
+ import { processFunctionName, processMainFileName, upperFirst } from '../_shared/shared/flowNaming.js';
6
+ import { EVENT_HANDLERS } from '../_shared/events/registry.js';
7
+ import { getGeneratedCodeConfigs } from '../_shared/shared/flowSelection.js';
8
+
9
+ const CRUD_ACTIONS = ['Create', 'Update', 'Delete', 'Get'];
10
+ const CRUD_ASYNC_ACTIONS = ['Create', 'Update', 'Delete'];
11
+
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = path.dirname(__filename);
14
+
15
+ export async function generateEndpointsFlow(allSchemas, options) {
16
+ console.log(' [EndpointsGenerator] Generating CRUD Endpoint Flows...');
17
+ const baseOutputDir = path.join(options.outputPath, 'app', 'src', 'generatedCode');
18
+ const templateDir = path.join(__dirname, 'templates');
19
+
20
+ let generatedCount = 0;
21
+
22
+ // We only generate CRUD if there's at least one applicable object
23
+ const hasApplicableObject = (allSchemas.objects || []).some(
24
+ obj => obj.generatedBy === 'userGenerated' || obj.generatedBy === 'systemGenerated'
25
+ );
26
+ if (!hasApplicableObject) return;
27
+
28
+ const sharedTemplates = {
29
+ sqs: await fs.readFile(path.join(__dirname, '..', '_shared', 'handlers', 'FlowHandler_HdrSqs.ejs'), 'utf-8'),
30
+ api: await fs.readFile(path.join(__dirname, '..', '_shared', 'handlers', 'FlowHandler_HdrApi.ejs'), 'utf-8'),
31
+ inv: await fs.readFile(path.join(__dirname, '..', '_shared', 'handlers', 'FlowHandler_HdrInv.ejs'), 'utf-8'),
32
+ wbsMain: await fs.readFile(path.join(__dirname, '..', 'FlowSchemas', 'templates', 'endpoint', 'FlowMain_Wbs.ejs'), 'utf-8').catch(() => ''),
33
+ endpointHdrWbs: await fs.readFile(path.join(__dirname, '..', 'FlowSchemas', 'templates', 'endpoint', 'FlowEndpoint_HdrWbs.ejs'), 'utf-8').catch(() => '')
34
+ };
35
+
36
+ // We need to pass a mock flows array to getGeneratedCodeConfigs if it expects it
37
+ // Since we are decoupling, we will just use allSchemas.flows for custom logic filtering
38
+ const customFlows = allSchemas.flows || [];
39
+
40
+ for (const action of CRUD_ACTIONS) {
41
+ const isAsync = CRUD_ASYNC_ACTIONS.includes(action);
42
+ const upperAction = upperFirst(action);
43
+ const flowOutputDir = path.join(baseOutputDir, 'FlowEndpoints', upperAction, 'source');
44
+ await fs.mkdir(flowOutputDir, { recursive: true });
45
+
46
+ const mainFileName = processMainFileName(action);
47
+ const processFunction = processFunctionName(action);
48
+
49
+ // Mock flow object for registry handlers if needed
50
+ const mockFlow = {
51
+ flowTag: action,
52
+ event: isAsync ? ['ownTopic'] : ['lambdaSyncInv', 'lambdaSyncApi']
53
+ };
54
+
55
+ const generateCode = getGeneratedCodeConfigs(customFlows, action, { includeFlowTag: true });
56
+
57
+ // 1. Generate Main Logic File
58
+ const mainTemplatePath = path.join(templateDir, 'crud', `${action}Endpoint_Main.ejs`);
59
+ let mainTemplateStr;
60
+ try {
61
+ mainTemplateStr = await fs.readFile(mainTemplatePath, 'utf-8');
62
+ } catch (err) {
63
+ console.warn(` [EndpointsGenerator] Warning: Main template not found for ${action}.`);
64
+ continue;
65
+ }
66
+
67
+ const mainContent = ejs.render(mainTemplateStr, {
68
+ flowTag: action,
69
+ upperCaseFlowTag: upperAction,
70
+ topicArn: `${upperAction}_In`,
71
+ generateCode: generateCode,
72
+ flow: mockFlow,
73
+ inTagConfig: null
74
+ });
75
+ await fs.writeFile(path.join(flowOutputDir, `${mainFileName}.js`), mainContent, 'utf-8');
76
+ generatedCount++;
77
+
78
+ // 2. Generate BeforeLogical Main Logic File if needed
79
+ const beforeLogicalConfigs = generateCode.filter(c => c.codeHookTag === 'beforeLogical');
80
+ if (beforeLogicalConfigs.length > 0) {
81
+ const beforeLogicalTemplateStr = await fs.readFile(
82
+ path.join(templateDir, 'FlowEndpointBeforeLogical_Main.ejs'),
83
+ 'utf-8'
84
+ );
85
+ const beforeLogicalFileName = `${upperAction}BeforeLogical_Main`;
86
+ const beforeLogicalContent = ejs.render(beforeLogicalTemplateStr, {
87
+ flowTag: action,
88
+ upperCaseFlowTag: upperAction,
89
+ generateCode: generateCode,
90
+ flow: mockFlow,
91
+ inTagConfig: null
92
+ });
93
+ await fs.writeFile(path.join(flowOutputDir, `${beforeLogicalFileName}.js`), beforeLogicalContent, 'utf-8');
94
+ generatedCount++;
95
+
96
+ // BeforeLogical SQS Handler
97
+ const sqsContent = ejs.render(sharedTemplates.sqs, {
98
+ flowTag: action,
99
+ flowStepName: '',
100
+ mainFileName: beforeLogicalFileName,
101
+ functionName: `${action}BeforeLogicalMain`,
102
+ queueName: `${action}BeforeLogicalHdrSqs`
103
+ });
104
+ await fs.writeFile(path.join(flowOutputDir, `${upperAction}BeforeLogical_HdrSqs.js`), sqsContent, 'utf-8');
105
+ generatedCount++;
106
+ }
107
+
108
+ // 3. Generate Handlers based on event array using Registry
109
+ for (const ev of mockFlow.event) {
110
+ const handlerGenerator = EVENT_HANDLERS[ev];
111
+ if (handlerGenerator) {
112
+ await handlerGenerator(mockFlow, '', flowOutputDir, mainFileName, sharedTemplates, generateCode);
113
+ generatedCount++;
114
+ }
115
+ }
116
+ }
117
+
118
+ console.log(` [EndpointsGenerator] Generated ${generatedCount} files for CRUD Endpoints.`);
119
+ }
@@ -2,72 +2,111 @@ 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 { isRbacFlow } from '../_internal/shared/flowClassifier.js';
6
- import { getFlowsForGeneration } from '../_internal/shared/flowSelection.js';
7
- import { processFunctionName, processMainFileName, upperFirst } from '../_internal/shared/flowNaming.js';
5
+ import { processFunctionName, processMainFileName, upperFirst } from '../_shared/shared/flowNaming.js';
6
+
7
+ const RBAC_FLOW_DEFINITIONS = [
8
+ 'CreateTargetRole', 'ListTargetRole', 'DeleteTargetRole',
9
+ 'CreateRolePermissions', 'ListRolePermissions', 'DeleteRolePermissions',
10
+ 'CreateUserRole', 'ListUserInRoles', 'DeleteUserFromRole'
11
+ ];
12
+
13
+ function hasRbacAddOn(obj) {
14
+ return Array.isArray(obj.addOnDataStructure) && obj.addOnDataStructure.some(addOn => addOn.type === 'rbac');
15
+ }
8
16
 
9
17
  const __filename = fileURLToPath(import.meta.url);
10
18
  const __dirname = path.dirname(__filename);
11
19
 
12
20
  export async function generateRbacFlows(allSchemas, options) {
13
- console.log(' [RbacFlowGenerator] Generating Custom RBAC Flows...');
14
- const baseOutputDir = path.join(options.outputPath, 'app', 'src', 'generatedCode', 'FlowRbac');
15
- // Local templates/ folder (3-way shared handlers via symlink + rbac/ specific templates)
16
- const templateDir = path.join(__dirname, 'templates');
21
+ console.log(' [RbacFlowGenerator] Generating Custom RBAC Flows...');
22
+ const baseOutputDir = path.join(
23
+ options.outputPath,
24
+ 'app',
25
+ 'src',
26
+ 'generatedCode',
27
+ 'FlowRbac'
28
+ );
29
+ // Local templates/ folder (3-way shared handlers via symlink + rbac/ specific templates)
30
+ const templateDir = path.join(__dirname, 'templates');
17
31
 
18
- // Read handler templates
19
- const templates = {
20
- sqs: await fs.readFile(path.join(templateDir, 'FlowHandler_HdrSqs.ejs'), 'utf-8'),
21
- api: await fs.readFile(path.join(templateDir, 'FlowHandler_HdrApi.ejs'), 'utf-8'),
22
- inv: await fs.readFile(path.join(templateDir, 'FlowHandler_HdrInv.ejs'), 'utf-8')
23
- };
32
+ // Read handler templates
33
+ const templates = {
34
+ sqs: await fs.readFile(
35
+ path.join(templateDir, '..', '..', '_shared', 'handlers', 'FlowHandler_HdrSqs.ejs'),
36
+ 'utf-8'
37
+ ),
38
+ api: await fs.readFile(
39
+ path.join(templateDir, '..', '..', '_shared', 'handlers', 'FlowHandler_HdrApi.ejs'),
40
+ 'utf-8'
41
+ ),
42
+ inv: await fs.readFile(
43
+ path.join(templateDir, '..', '..', '_shared', 'handlers', 'FlowHandler_HdrInv.ejs'),
44
+ 'utf-8'
45
+ )
46
+ };
24
47
 
25
- let generatedCount = 0;
48
+ let generatedCount = 0;
26
49
 
27
- const flows = getFlowsForGeneration(allSchemas);
50
+ const rbacObjects = (allSchemas.objects || []).filter(hasRbacAddOn);
51
+ if (rbacObjects.length === 0) return;
28
52
 
29
- for (const flow of flows) {
30
- const flowTag = flow.flowTag;
53
+ // Since RBAC templates are generic, we only need to generate them once
54
+ // even if multiple objects have the rbac addOn.
55
+ for (const flowTag of RBAC_FLOW_DEFINITIONS) {
31
56
 
32
- // Process only if it's an RBAC flow
33
- if (!isRbacFlow(flowTag)) continue;
57
+ const flowOutputDir = path.join(baseOutputDir, flowTag, 'source');
58
+ await fs.mkdir(flowOutputDir, { recursive: true });
34
59
 
35
- const flowOutputDir = path.join(baseOutputDir, flowTag, 'source');
36
- await fs.mkdir(flowOutputDir, { recursive: true });
60
+ // Generate Process Step for RBAC
61
+ const mainFileName = processMainFileName(flowTag);
37
62
 
38
- // Generate Process Step for RBAC
39
- const mainFileName = processMainFileName(flowTag);
63
+ // 1. Generate Main Logic File (from specific RBAC templates)
64
+ const templatePath = path.join(
65
+ __dirname,
66
+ 'templates',
67
+ 'rbac',
68
+ `${flowTag}.ejs`
69
+ );
70
+ let mainTemplateStr;
71
+ try {
72
+ mainTemplateStr = await fs.readFile(templatePath, 'utf-8');
73
+ } catch (err) {
74
+ console.warn(
75
+ ` [RbacFlowGenerator] Warning: RBAC template not found for ${flowTag}. Skipping.`
76
+ );
77
+ continue;
78
+ }
40
79
 
41
- // 1. Generate Main Logic File (from specific RBAC templates)
42
- const templatePath = path.join(__dirname, 'templates', 'rbac', `${flowTag}.ejs`);
43
- let mainTemplateStr;
44
- try {
45
- mainTemplateStr = await fs.readFile(templatePath, 'utf-8');
46
- } catch (err) {
47
- console.warn(` [RbacFlowGenerator] Warning: RBAC template not found for ${flowTag}. Skipping.`);
48
- continue;
49
- }
80
+ const mainContent = ejs.render(mainTemplateStr, {
81
+ flowTag: flowTag
82
+ });
83
+ await fs.writeFile(
84
+ path.join(flowOutputDir, `${mainFileName}.js`),
85
+ mainContent,
86
+ 'utf-8'
87
+ );
88
+ generatedCount++;
50
89
 
51
- const mainContent = ejs.render(mainTemplateStr, {
52
- flowTag: flowTag
53
- });
54
- await fs.writeFile(path.join(flowOutputDir, `${mainFileName}.js`), mainContent, 'utf-8');
55
- generatedCount++;
90
+ // 2. Generate SQS Handler for Process Step
91
+ const handlerFileName = `Process${flowTag}_HdrSqs`;
56
92
 
57
- // 2. Generate SQS Handler for Process Step
58
- const handlerFileName = `Process${flowTag}_HdrSqs`;
59
-
60
- // Ensure to pass functionName that matches what the template exports
61
- const handlerContent = ejs.render(templates.sqs, {
62
- flowTag: flowTag,
63
- flowStepName: '',
64
- mainFileName: mainFileName,
65
- functionName: processFunctionName(flowTag),
66
- queueName: `Process${upperFirst(flowTag)}HdrSqs`
67
- });
68
- await fs.writeFile(path.join(flowOutputDir, `${handlerFileName}.js`), handlerContent, 'utf-8');
69
- generatedCount++;
70
- }
93
+ // Ensure to pass functionName that matches what the template exports
94
+ const handlerContent = ejs.render(templates.sqs, {
95
+ flowTag: flowTag,
96
+ flowStepName: '',
97
+ mainFileName: mainFileName,
98
+ functionName: processFunctionName(flowTag),
99
+ queueName: `Process${upperFirst(flowTag)}HdrSqs`
100
+ });
101
+ await fs.writeFile(
102
+ path.join(flowOutputDir, `${handlerFileName}.js`),
103
+ handlerContent,
104
+ 'utf-8'
105
+ );
106
+ generatedCount++;
107
+ }
71
108
 
72
- console.log(` [RbacFlowGenerator] Generated ${generatedCount} files for RBAC Flows.`);
109
+ console.log(
110
+ ` [RbacFlowGenerator] Generated ${generatedCount} files for RBAC Flows.`
111
+ );
73
112
  }