@izara_project/izara-core-generate-service-code 1.0.53 → 1.0.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -2
- package/src/codeGenerators/app/initial_setup/InitialSetupGenerator.js +1 -1
- package/src/codeGenerators/app/sls_yaml/FindDataYamlGenerator.js +23 -0
- package/src/codeGenerators/app/sls_yaml/FunctionYamlGenerator.js +1 -1
- package/src/codeGenerators/app/sls_yaml/ProcessLogicalYamlGenerator.js +11 -25
- package/src/codeGenerators/app/sls_yaml/RoleNameConfigGenerator.js +1 -1
- package/src/codeGenerators/app/sls_yaml/SharedResourceYamlGenerator.js +3 -3
- package/src/codeGenerators/app/sls_yaml/renderYamlTemplate.js +13 -0
- package/src/codeGenerators/app/sls_yaml/templates/SharedResource_Yaml.ejs +6 -2
- package/src/codeGenerators/app/src/generatedCode/FindData/FindDataGenerator.js +10 -44
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowEndpoints/EndpointsGenerator.js +119 -0
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/RbacFlowGenerator.js +91 -52
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowRelationshipEndpoints/RelationshipFlowGenerator.js +20 -16
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/StatusFieldGenerator.js +1 -1
- package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3Components/ConfirmAfterUploadS3Generator.js +2 -4
- package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3Components/CreateObjectGenerator.js +2 -4
- package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3Components/CreatePreSignUrlGenerator.js +2 -4
- package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3Components/ProcessAfterUploadS3Generator.js +5 -5
- package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3Components/ReservedLimitGenerator.js +2 -4
- package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowEntryPointBase.js +6 -6
- package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowMainFunctionBase.js +3 -3
- package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowStepBase.js +11 -11
- package/src/codeGenerators/app/src/generatedCode/ProcessLogical/ProcessLogicalGenerator.js +18 -15
- package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/{PaginateProcessLogical_HdrDsq.js → PaginateProcessLogical_HdrDsq.ejs} +1 -1
- package/src/codeGenerators/app/src/generatedCode/SystemFlowSchemas/RegisterGenerator.js +133 -149
- package/src/codeGenerators/app/src/generatedCode/libs/ConstsGenerator.js +16 -8
- package/src/codeGenerators/app/src/generatedCode/libs/GenerateCodeLibsGenerator.js +17 -9
- package/src/codeGenerators/resource/sls_yaml/FlowOutGenerator.js +11 -2
- package/src/codeGenerators/resource/sls_yaml/FlowResourceYamlGenerator.js +31 -4
- package/src/core/renderTemplateFile.js +22 -0
- package/src/generateCode.js +143 -110
- package/src/generateIntTest.js +45 -69
- package/src/generateResourceIntTest.js +22 -47
- package/src/intTestGeneratorShared.js +36 -0
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/flowSchemaMainFunction/data.js +0 -119
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/flowSchemaMainFunction/template.ejs +0 -89
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/flowSchemaMainFunction/templateByStatusType/statusFieldTemplate.ejs +0 -30
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/flowSchemaMainFunction/templateByStatusType/storedCacheTemplate.ejs +0 -26
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/flowSchemaMainFunction/templateByStatusType/triggerCacheTemplate.ejs +0 -44
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/index.js +0 -80
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/functionYaml/data.js +0 -129
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/functionYaml/template.ejs +0 -17
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/handler/data.js +0 -63
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/mainFunction/data.js +0 -54
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/mainFunction/template.ejs +0 -129
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/queue/data.js +0 -63
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/queue/template.ejs +0 -45
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObject/functionYaml/data.js +0 -117
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObject/functionYaml/template.ejs +0 -20
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObject/handler/data.js +0 -64
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObject/mainFunction/data.js +0 -64
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObject/mainFunction/template.ejs +0 -131
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/functionYaml/data.js +0 -122
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/functionYaml/template.ejs +0 -17
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/handler/data.js +0 -66
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/handler/template.ejs +0 -99
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/mainFunction/data.js +0 -64
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/mainFunction/template.ejs +0 -82
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/sns-sqs/data.js +0 -70
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/sns-sqs/template.ejs +0 -49
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/functionYaml/data.js +0 -139
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/functionYaml/template.ejs +0 -18
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/handler/data.js +0 -63
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/mainFunction/data.js +0 -63
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/mainFunction/template.ejs +0 -262
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/queue/data.js +0 -63
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/queue/template.ejs +0 -45
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/functionYaml/data.js +0 -146
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/functionYaml/template.ejs +0 -14
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/handler/data.js +0 -64
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/mainFunction/data.js +0 -59
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +0 -173
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/sqs/data.js +0 -67
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/sqs/template.ejs +0 -53
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/functionYml/HdrS3/data.js +0 -140
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/functionYml/HdrS3/template.ejs +0 -25
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/handler/handlerS3/data.js +0 -49
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/handler/handlerS3/template.ejs +0 -50
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/mainFunction/ProcessCsvtemplate.ejs +0 -182
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/mainFunction/data.js +0 -49
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/mainFunction/template.ejs +0 -66
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/queue/data.js +0 -77
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/queue/dsqTemplatePath.ejs +0 -32
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/queue/s3Template.ejs +0 -59
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/relate/S3/data.js +0 -61
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/relate/S3/template.ejs +0 -13
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/relate/sns-out/data.js +0 -70
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/websocket/dynamoDb/ReservedTableData.js +0 -69
- package/src/codeGenerators/app/src/generatedCode/Flow/SystemFlowDescriptorBuilder.js +0 -151
- /package/src/codeGenerators/app/{src/generatedCode/FindData → sls_yaml}/templates/FindData_Yaml.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared/endpoint → FlowEndpoints/templates}/FlowEndpointBeforeLogical_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/endpoint/FlowEndpoint_HdrWbs.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/endpoint/FlowEndpoint_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/endpoint/FlowEntryPoint_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/endpoint/FlowMain_Wbs.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/{s3Legacy/upload/confirmReserved/handler/template.ejs → s3/ConfirmReserved_HdrSqs.ejs} +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/{s3Legacy/upload/createObject/handler/template.ejs → s3/CreateObject_HdrWbs.ejs} +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/{s3Legacy/upload/preSignUrl/createPreSignUrl/handler/template.ejs → s3/CreatePreSignUrl_HdrSqs.ejs} +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/{s3Legacy/upload/preSignUrl/reservedLimit/handler/template.ejs → s3/ReservedLimit_HdrSqs.ejs} +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/FlowEndpointComplete_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/FlowStep_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/FlowStep_ByConfig_Awaiting_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/FlowStep_ByConfig_Paginated_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/FlowStep_PlugIn_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/FlowStep_RecievePlugIn_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/templateAwaitingStep.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/templateSendPlugin.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/BaseSqsHandler.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/eventBridge.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/extTopic.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/lambdaSyncApi.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/lambdaSyncInv.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/ownTopic.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/registry.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/handlers/FlowHandler_HdrApi.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/handlers/FlowHandler_HdrInv.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/handlers/FlowHandler_HdrSqs.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/eventTypes.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowClassifier.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowNaming.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowSelection.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowStepNormalizer.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowValidator.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/registry.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/triggerCacheBase.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/CheckTriggerCache_HdrSqs.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/CheckTriggerCache_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/ProcessTriggerCache_HdrSqs.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/ProcessTriggerCache_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/TriggerCacheComplete_HdrDsq.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/TriggerCacheComplete_HdrSqs.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/TriggerCacheComplete_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/TriggerCacheQueue_Yaml.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/yaml/SharedFunctionSqs_Yaml.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/{PaginateProcessLogical_HdrSqs.js → PaginateProcessLogical_HdrSqs.ejs} +0 -0
- /package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/{PaginateProcessLogical_Main.js → PaginateProcessLogical_Main.ejs} +0 -0
- /package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/{ProcessLogical_HdrSqs.js → ProcessLogical_HdrSqs.ejs} +0 -0
- /package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/{ProcessLogical_Main.js → ProcessLogical_Main.ejs} +0 -0
- /package/src/codeGenerators/app/src/generatedCode/libs/templates/{Consts.js → Consts.ejs} +0 -0
- /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.
|
|
3
|
+
"version": "1.0.54",
|
|
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/
|
|
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/
|
|
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);
|
|
@@ -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
|
-
|
|
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
|
-
|
|
19
|
-
|
|
11
|
+
if (!allSchemas.objects || allSchemas.objects.length === 0) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
20
14
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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/
|
|
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/
|
|
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
|
-
|
|
17
|
-
|
|
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
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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
|
-
|
|
239
|
-
|
|
240
|
-
|
|
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
|
-
|
|
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 {
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
48
|
+
let generatedCount = 0;
|
|
26
49
|
|
|
27
|
-
|
|
50
|
+
const rbacObjects = (allSchemas.objects || []).filter(hasRbacAddOn);
|
|
51
|
+
if (rbacObjects.length === 0) return;
|
|
28
52
|
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
33
|
-
|
|
57
|
+
const flowOutputDir = path.join(baseOutputDir, flowTag, 'source');
|
|
58
|
+
await fs.mkdir(flowOutputDir, { recursive: true });
|
|
34
59
|
|
|
35
|
-
|
|
36
|
-
|
|
60
|
+
// Generate Process Step for RBAC
|
|
61
|
+
const mainFileName = processMainFileName(flowTag);
|
|
37
62
|
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
52
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
109
|
+
console.log(
|
|
110
|
+
` [RbacFlowGenerator] Generated ${generatedCount} files for RBAC Flows.`
|
|
111
|
+
);
|
|
73
112
|
}
|
|
@@ -2,10 +2,16 @@ 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 {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import { processFunctionName, processMainFileName, upperFirst } from '../_shared/shared/flowNaming.js';
|
|
6
|
+
|
|
7
|
+
const RELATIONSHIP_ACTIONS = [
|
|
8
|
+
'CreateRelationship',
|
|
9
|
+
'UpdateRelationship',
|
|
10
|
+
'DeleteRelationship',
|
|
11
|
+
'GetRelationship',
|
|
12
|
+
'ChangeRelationship',
|
|
13
|
+
'MoveRelationship'
|
|
14
|
+
];
|
|
9
15
|
|
|
10
16
|
const __filename = fileURLToPath(import.meta.url);
|
|
11
17
|
const __dirname = path.dirname(__filename);
|
|
@@ -18,22 +24,19 @@ export async function generateRelationshipFlows(allSchemas, options) {
|
|
|
18
24
|
|
|
19
25
|
// Read standard handler templates for reuse
|
|
20
26
|
const templates = {
|
|
21
|
-
sqs: await fs.readFile(path.join(templateDir, 'FlowHandler_HdrSqs.ejs'), 'utf-8'),
|
|
22
|
-
api: await fs.readFile(path.join(templateDir, 'FlowHandler_HdrApi.ejs'), 'utf-8'),
|
|
23
|
-
inv: await fs.readFile(path.join(templateDir, 'FlowHandler_HdrInv.ejs'), 'utf-8')
|
|
27
|
+
sqs: await fs.readFile(path.join(templateDir, '..', '..', '_shared', 'handlers', 'FlowHandler_HdrSqs.ejs'), 'utf-8'),
|
|
28
|
+
api: await fs.readFile(path.join(templateDir, '..', '..', '_shared', 'handlers', 'FlowHandler_HdrApi.ejs'), 'utf-8'),
|
|
29
|
+
inv: await fs.readFile(path.join(templateDir, '..', '..', '_shared', 'handlers', 'FlowHandler_HdrInv.ejs'), 'utf-8')
|
|
24
30
|
};
|
|
25
31
|
|
|
26
32
|
let generatedCount = 0;
|
|
27
33
|
|
|
28
|
-
|
|
34
|
+
if (!allSchemas.relationships || allSchemas.relationships.length === 0) return;
|
|
29
35
|
|
|
30
|
-
for (const
|
|
31
|
-
const flowTag = flow.flowTag;
|
|
36
|
+
for (const flowTag of RELATIONSHIP_ACTIONS) {
|
|
32
37
|
const upperFlowTag = upperFirst(flowTag);
|
|
33
38
|
const processFunction = processFunctionName(flowTag);
|
|
34
39
|
|
|
35
|
-
if (!isRelationshipFlow(flowTag)) continue;
|
|
36
|
-
|
|
37
40
|
const flowOutputDir = path.join(baseOutputDir, 'FlowRelationshipEndpoints', upperFlowTag, 'source');
|
|
38
41
|
await fs.mkdir(flowOutputDir, { recursive: true });
|
|
39
42
|
|
|
@@ -53,8 +56,9 @@ export async function generateRelationshipFlows(allSchemas, options) {
|
|
|
53
56
|
console.warn(` [RelationshipFlowGenerator] Warning: Action template not found for ${flowTag}. Skipping.`);
|
|
54
57
|
}
|
|
55
58
|
|
|
56
|
-
// 2. Generate Action Step Handlers (based on
|
|
57
|
-
|
|
59
|
+
// 2. Generate Action Step Handlers (based on fixed event ['ownTopic'])
|
|
60
|
+
const events = ['ownTopic'];
|
|
61
|
+
for (const event of events) {
|
|
58
62
|
let handlerFileName, handlerContent, handlerFunctionName;
|
|
59
63
|
if (event === 'ownTopic' || event === 'extTopic') {
|
|
60
64
|
handlerFunctionName = `${processFunction}_HdrSqs`;
|
|
@@ -90,8 +94,8 @@ export async function generateRelationshipFlows(allSchemas, options) {
|
|
|
90
94
|
}
|
|
91
95
|
}
|
|
92
96
|
|
|
93
|
-
// 3. Generate Complete Step (
|
|
94
|
-
if (
|
|
97
|
+
// 3. Generate Complete Step (Always generated for Relationship flows)
|
|
98
|
+
if (true) {
|
|
95
99
|
const completeFunction = `${processFunction}Complete`;
|
|
96
100
|
const completeFileName = `${completeFunction}_Main`;
|
|
97
101
|
const completeTemplatePath = path.join(templateDir, 'relationship', `${completeFileName}.ejs`);
|
|
@@ -38,7 +38,7 @@ export async function generateStatusField(flowSchema, appPath, outputBaseDir) {
|
|
|
38
38
|
const templatesDir = path.join(__dirname, 'templates', 'statusField');
|
|
39
39
|
const mainTpl = await fs.readFile(path.join(templatesDir, 'CompleteStatusField_Main.ejs'), 'utf-8');
|
|
40
40
|
const handlerTpl = await fs.readFile(path.join(templatesDir, 'CompleteStatusField_HdrSqs.ejs'), 'utf-8');
|
|
41
|
-
const yamlTpl = await fs.readFile(path.join(__dirname, '..', '
|
|
41
|
+
const yamlTpl = await fs.readFile(path.join(__dirname, '..', '_shared', 'yaml', 'SharedFunctionSqs_Yaml.ejs'), 'utf-8');
|
|
42
42
|
const snsTpl = await fs.readFile(path.join(templatesDir, 'CompleteStatusFieldSns_Yaml.ejs'), 'utf-8');
|
|
43
43
|
|
|
44
44
|
// Shared variables
|
|
@@ -15,12 +15,10 @@ export default async function generateConfirmAfterUploadS3(flow, flowOutputDir)
|
|
|
15
15
|
const handlerFileName = `${functionName}_${handlerType}`;
|
|
16
16
|
|
|
17
17
|
const mainTemplatePath = path.join(
|
|
18
|
-
__dirname, '..', '..', '..', 'FlowSchemas', 'templates', '
|
|
19
|
-
'upload', 'confirmReserved', 'mainFunction', 'template.ejs'
|
|
18
|
+
__dirname, '..', '..', '..', 'FlowSchemas', 'templates', 's3', 'ConfirmReserved_Main.ejs'
|
|
20
19
|
);
|
|
21
20
|
const handlerTemplatePath = path.join(
|
|
22
|
-
__dirname, '..', '..', '..', 'FlowSchemas', 'templates', '
|
|
23
|
-
'upload', 'confirmReserved', 'handler', 'template.ejs'
|
|
21
|
+
__dirname, '..', '..', '..', 'FlowSchemas', 'templates', 's3', 'ConfirmReserved_HdrSqs.ejs'
|
|
24
22
|
);
|
|
25
23
|
|
|
26
24
|
let mainTemplateStr, handlerTemplateStr;
|