@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
|
@@ -2,7 +2,7 @@ import path from 'path';
|
|
|
2
2
|
import fs from 'fs/promises';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import ejs from 'ejs';
|
|
5
|
-
import { getFlowsForGeneration } from '../../app/src/generatedCode/Flow/
|
|
5
|
+
import { getFlowsForGeneration } from '../../app/src/generatedCode/Flow/_shared/shared/flowSelection.js';
|
|
6
6
|
|
|
7
7
|
const __filename = fileURLToPath(import.meta.url);
|
|
8
8
|
const __dirname = path.dirname(__filename);
|
|
@@ -144,6 +144,34 @@ export async function generateFlowResourceYaml(allSchemas, options) {
|
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
// Add hardcoded ownTopic flows for CRUD, RBAC, Relationship
|
|
148
|
+
const systemOwnTopicFlows = [
|
|
149
|
+
'Create', 'Update', 'Delete', // CRUD
|
|
150
|
+
'CreateRelationship', 'UpdateRelationship', 'DeleteRelationship', 'ChangeRelationship', 'MoveRelationship', // Relationship
|
|
151
|
+
'CreateTargetRole', 'DeleteTargetRole', 'CreateRolePermissions', 'DeleteRolePermissions', 'CreateUserRole', 'DeleteUserFromRole' // RBAC
|
|
152
|
+
];
|
|
153
|
+
for (const flowTag of systemOwnTopicFlows) {
|
|
154
|
+
const yamlContent = ejs.render(resourceYamlTpl, { queueName: flowTag });
|
|
155
|
+
await appendToFile(yamlOutputPath, yamlContent);
|
|
156
|
+
generatedCount++;
|
|
157
|
+
|
|
158
|
+
// BeforeLogical queues for CRUD
|
|
159
|
+
if (['Create', 'Update', 'Delete'].includes(flowTag)) {
|
|
160
|
+
// Since we don't have beforeLogical configs here, we assume we might need them or we can just generate a generic one?
|
|
161
|
+
// For now, only custom flows generate beforeLogical dynamically above.
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Generate Dsq queues for Relationship
|
|
166
|
+
const relationshipActions = ['CreateRelationship', 'UpdateRelationship', 'DeleteRelationship', 'GetRelationship', 'ChangeRelationship', 'MoveRelationship'];
|
|
167
|
+
const resourceSqsYamlTplPath = path.join(__dirname, 'templates', 'crud', 'ResourceSqsYaml.ejs');
|
|
168
|
+
const resourceSqsYamlTpl = await fs.readFile(resourceSqsYamlTplPath, 'utf-8');
|
|
169
|
+
for (const action of relationshipActions) {
|
|
170
|
+
const yamlContent = ejs.render(resourceSqsYamlTpl, { queueName: action + 'Dsq' });
|
|
171
|
+
await appendToFile(yamlOutputPath, yamlContent);
|
|
172
|
+
generatedCount++;
|
|
173
|
+
}
|
|
174
|
+
|
|
147
175
|
// Add System Queues
|
|
148
176
|
const systemQueues = [
|
|
149
177
|
'ProcessLogical',
|
|
@@ -157,11 +185,10 @@ export async function generateFlowResourceYaml(allSchemas, options) {
|
|
|
157
185
|
'GetNodeComplete'
|
|
158
186
|
];
|
|
159
187
|
|
|
160
|
-
const
|
|
161
|
-
const resourceSqsYamlTpl = await fs.readFile(resourceSqsYamlTplPath, 'utf-8');
|
|
188
|
+
const resourceSqsYamlTplGlobal = await fs.readFile(resourceSqsYamlTplPath, 'utf-8');
|
|
162
189
|
|
|
163
190
|
for (const sysQueue of systemQueues) {
|
|
164
|
-
const yamlContent = ejs.render(
|
|
191
|
+
const yamlContent = ejs.render(resourceSqsYamlTplGlobal, {
|
|
165
192
|
queueName: sysQueue
|
|
166
193
|
});
|
|
167
194
|
await appendToFile(yamlOutputPath, yamlContent);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import ejs from 'ejs';
|
|
4
|
+
|
|
5
|
+
async function renderTemplateFile(templatePath, templateData = {}, { views } = {}) {
|
|
6
|
+
const template = await fs.readFile(templatePath, 'utf8');
|
|
7
|
+
return ejs.render(template, templateData, views ? { views } : undefined);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async function writeRenderedTemplate(templatePath, outputPath, templateData = {}, options = {}) {
|
|
11
|
+
const content = await renderTemplateFile(templatePath, templateData, options);
|
|
12
|
+
await fs.mkdir(path.dirname(outputPath), { recursive: true });
|
|
13
|
+
await fs.writeFile(outputPath, content, 'utf8');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function appendRenderedTemplate(templatePath, outputPath, templateData = {}, options = {}) {
|
|
17
|
+
const content = await renderTemplateFile(templatePath, templateData, options);
|
|
18
|
+
await fs.mkdir(path.dirname(outputPath), { recursive: true });
|
|
19
|
+
await fs.appendFile(outputPath, `\n${content}`, 'utf8');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { appendRenderedTemplate, renderTemplateFile, writeRenderedTemplate };
|
package/src/generateCode.js
CHANGED
|
@@ -5,17 +5,19 @@ import { parseObjectSchemas } from './parsers/objectSchemaParser.js';
|
|
|
5
5
|
import { parseRelationshipSchemas } from './parsers/relationshipSchemaParser.js';
|
|
6
6
|
import { parseFlowSchemas } from './parsers/flowSchemaParser.js';
|
|
7
7
|
|
|
8
|
-
import { buildSystemFlowDescriptors } from './codeGenerators/app/src/generatedCode/Flow/SystemFlowDescriptorBuilder.js';
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
9
|
+
|
|
10
|
+
import { generateFlowEntryPoint } from './codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowEntryPointBase.js';
|
|
11
|
+
import { generateFlowMainFunction } from './codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowMainFunctionBase.js';
|
|
12
|
+
import { generateFlowSteps } from './codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowStepBase.js';
|
|
13
|
+
|
|
14
|
+
import { generateEndpointsFlow } from './codeGenerators/app/src/generatedCode/Flow/FlowEndpoints/EndpointsGenerator.js';
|
|
13
15
|
import { generateFlowOut } from './codeGenerators/resource/sls_yaml/FlowOutGenerator.js';
|
|
14
16
|
import { generateFlowResourceYaml } from './codeGenerators/resource/sls_yaml/FlowResourceYamlGenerator.js';
|
|
15
17
|
import { generateRbacFlows } from './codeGenerators/app/src/generatedCode/Flow/FlowRbac/RbacFlowGenerator.js';
|
|
16
18
|
import { generateRelationshipFlows } from './codeGenerators/app/src/generatedCode/Flow/FlowRelationshipEndpoints/RelationshipFlowGenerator.js';
|
|
17
19
|
import { generateWebSocket } from './codeGenerators/app/src/generatedCode/Flow/FlowSchemas/WebSocketGenerator.js';
|
|
18
|
-
import { validateFlowsForGeneration } from './codeGenerators/app/src/generatedCode/Flow/
|
|
20
|
+
import { validateFlowsForGeneration } from './codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowValidator.js';
|
|
19
21
|
import { generateRegisterFlow } from './codeGenerators/app/src/generatedCode/SystemFlowSchemas/RegisterGenerator.js';
|
|
20
22
|
import { generateDynamoDBTables } from './codeGenerators/resource/sls_yaml/DynamoDBGenerator.js';
|
|
21
23
|
import { generateFindData } from './codeGenerators/app/src/generatedCode/FindData/FindDataGenerator.js';
|
|
@@ -27,6 +29,7 @@ import { generateConsts } from './codeGenerators/app/src/generatedCode/libs/Cons
|
|
|
27
29
|
import { generateProcessLogical } from './codeGenerators/app/src/generatedCode/ProcessLogical/ProcessLogicalGenerator.js';
|
|
28
30
|
import { generateProcessLogicalYaml } from './codeGenerators/app/sls_yaml/ProcessLogicalYamlGenerator.js';
|
|
29
31
|
import { generateSharedResourceYaml } from './codeGenerators/app/sls_yaml/SharedResourceYamlGenerator.js';
|
|
32
|
+
import { generateFindDataYaml } from './codeGenerators/app/sls_yaml/FindDataYamlGenerator.js';
|
|
30
33
|
import { policyRegistry } from './codeGenerators/app/sls_yaml/_policy/PolicyRegistry.js';
|
|
31
34
|
import { emitManagedPolicies } from './codeGenerators/app/sls_yaml/_policy/PolicyEmitter.js';
|
|
32
35
|
|
|
@@ -40,36 +43,75 @@ export async function generateCode(rootPath, options) {
|
|
|
40
43
|
const generatedCodePath = path.join(outputPath, 'app', 'src', 'generatedCode');
|
|
41
44
|
|
|
42
45
|
// Backup existing hook files to prevent them from being wiped out
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
46
|
+
const hookBackups = [];
|
|
47
|
+
const hookDirs = new Set();
|
|
48
|
+
|
|
49
|
+
function getHookTagMatchers(filePath) {
|
|
50
|
+
if (filePath.endsWith('.js')) {
|
|
51
|
+
return {
|
|
52
|
+
anyTag: /\/\/\(<(\w+)>\)([\s\S]*?)\/\/\(<\/\1>\)/gm,
|
|
53
|
+
tagPattern: (name) => new RegExp(
|
|
54
|
+
`\\/\\/\\(<${name}>\\)([\\s\\S]*?)\\/\\/\\(<\\/${name}>\\)`,
|
|
55
|
+
'gm'
|
|
56
|
+
)
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (filePath.endsWith('.yml') || filePath.endsWith('.yaml')) {
|
|
61
|
+
return {
|
|
62
|
+
anyTag: /#<#(\w+)#>([\s\S]*?)#<#\/\1#>/gm,
|
|
63
|
+
tagPattern: (name) => new RegExp(
|
|
64
|
+
`#<#${name}#>([\\s\\S]*?)#<#\\/${name}#>`,
|
|
65
|
+
'gm'
|
|
66
|
+
)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function mergeHookIntoSource(sourceContent, hookContent, filePath) {
|
|
74
|
+
const matchers = getHookTagMatchers(filePath);
|
|
75
|
+
if (!matchers) return hookContent;
|
|
76
|
+
|
|
77
|
+
return sourceContent.replace(matchers.anyTag, (match, tagName) => (
|
|
78
|
+
hookContent.match(matchers.tagPattern(tagName))?.[0] ?? match
|
|
79
|
+
));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function collectHookBackups(currentDir) {
|
|
83
|
+
if (!fs.existsSync(currentDir)) return;
|
|
84
|
+
|
|
85
|
+
const items = fs.readdirSync(currentDir, { withFileTypes: true });
|
|
86
|
+
const hasSource = items.some((item) => item.isDirectory() && item.name === 'source');
|
|
87
|
+
const hasHook = items.some((item) => item.isDirectory() && item.name === 'hook');
|
|
88
|
+
|
|
89
|
+
if (hasSource && hasHook) {
|
|
90
|
+
const hookPath = path.join(currentDir, 'hook');
|
|
91
|
+
hookDirs.add(path.relative(outputPath, hookPath));
|
|
92
|
+
const hookItems = fs.readdirSync(hookPath, { withFileTypes: true });
|
|
93
|
+
|
|
94
|
+
for (const hookItem of hookItems) {
|
|
95
|
+
if (!hookItem.isFile()) continue;
|
|
96
|
+
const hookFilePath = path.join(hookPath, hookItem.name);
|
|
97
|
+
hookBackups.push({
|
|
98
|
+
relativePath: path.relative(outputPath, hookPath),
|
|
99
|
+
name: hookItem.name,
|
|
100
|
+
content: fs.readFileSync(hookFilePath)
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
for (const item of items) {
|
|
106
|
+
if (!item.isDirectory() || item.name === 'source' || item.name === 'hook') continue;
|
|
107
|
+
collectHookBackups(path.join(currentDir, item.name));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
console.log('[INFO] [generateCode] STATUS=BACKUP | Backing up existing hook files...');
|
|
112
|
+
collectHookBackups(outputPath);
|
|
113
|
+
|
|
114
|
+
console.log(
|
|
73
115
|
'[INFO] [generateCode] STATUS=CLEANUP | Removing old generatedCode and resource directories...'
|
|
74
116
|
);
|
|
75
117
|
await fs.promises.rm(generatedCodePath, {
|
|
@@ -97,38 +139,21 @@ export async function generateCode(rootPath, options) {
|
|
|
97
139
|
console.log('[INFO] [generateCode] STATUS=PARSING | FlowSchemas...');
|
|
98
140
|
const flowData = await parseFlowSchemas(rootPath, objectData, options);
|
|
99
141
|
|
|
100
|
-
// Build fixed system flows in memory instead of writing generated FlowSchema files.
|
|
101
|
-
const systemFlowData = buildSystemFlowDescriptors(
|
|
102
|
-
objectData,
|
|
103
|
-
relationshipData,
|
|
104
|
-
flowData
|
|
105
|
-
);
|
|
106
|
-
|
|
107
142
|
// The 'allSchemas' object contains the fully hydrated Memory Objects
|
|
108
143
|
const allSchemas = {
|
|
109
144
|
objects: objectData.objects,
|
|
110
145
|
relationships: relationshipData.relationships,
|
|
111
146
|
flows: flowData.flows,
|
|
112
|
-
|
|
113
|
-
flowsForGeneration: [
|
|
114
|
-
...(flowData.flows || []),
|
|
115
|
-
...(systemFlowData.flows || [])
|
|
116
|
-
]
|
|
147
|
+
flowsForGeneration: flowData.flows || []
|
|
117
148
|
};
|
|
118
149
|
|
|
119
|
-
// DEBUG: Dump the hydrated allSchemas to a file so we can inspect it
|
|
120
|
-
const dumpPath = path.join(
|
|
121
|
-
options.outputPath || rootPath,
|
|
122
|
-
'allSchemas_debug.json'
|
|
123
|
-
);
|
|
124
|
-
fs.writeFileSync(dumpPath, JSON.stringify(allSchemas, null, 2));
|
|
125
|
-
|
|
126
150
|
console.log('[INFO] [generateCode] STATUS=VALIDATING | Validating Flows...');
|
|
127
151
|
validateFlowsForGeneration(allSchemas.flowsForGeneration);
|
|
128
152
|
|
|
129
153
|
const generatorOptions = { outputPath: options.outputPath || rootPath };
|
|
130
154
|
|
|
131
155
|
// 2. Generation Pipeline
|
|
156
|
+
await generateEndpointsFlow(allSchemas, generatorOptions);
|
|
132
157
|
await generateFlowMainFunction(allSchemas, generatorOptions);
|
|
133
158
|
await generateFlowEntryPoint(allSchemas, generatorOptions);
|
|
134
159
|
await generateFlowSteps(allSchemas, generatorOptions);
|
|
@@ -148,66 +173,74 @@ export async function generateCode(rootPath, options) {
|
|
|
148
173
|
await generateProcessLogical(generatorOptions);
|
|
149
174
|
await generateRoleNameConfig(allSchemas, generatorOptions);
|
|
150
175
|
await generateProcessLogicalYaml(allSchemas, generatorOptions);
|
|
176
|
+
await generateFindDataYaml(generatorOptions);
|
|
151
177
|
await generateSharedResourceYaml(allSchemas, generatorOptions);
|
|
152
178
|
await generateInitialSetup(allSchemas, generatorOptions);
|
|
153
179
|
|
|
154
180
|
// 3. Hook Integration
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
181
|
+
console.log(
|
|
182
|
+
'[INFO] [generateCode] STATUS=HOOKS | Processing hook folders beside source folders...'
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
function processSourceHooks(currentDir) {
|
|
186
|
+
if (!fs.existsSync(currentDir)) return;
|
|
187
|
+
|
|
188
|
+
const items = fs.readdirSync(currentDir, { withFileTypes: true });
|
|
189
|
+
const hasSource = items.some((item) => item.isDirectory() && item.name === 'source');
|
|
190
|
+
const hasHook = items.some((item) => item.isDirectory() && item.name === 'hook');
|
|
191
|
+
|
|
192
|
+
if (hasSource && hasHook) {
|
|
193
|
+
const sourcePath = path.join(currentDir, 'source');
|
|
194
|
+
const hookPath = path.join(currentDir, 'hook');
|
|
195
|
+
const hookItems = fs.readdirSync(hookPath, { withFileTypes: true });
|
|
196
|
+
|
|
197
|
+
for (const hookItem of hookItems) {
|
|
198
|
+
if (!hookItem.isFile()) continue;
|
|
199
|
+
|
|
200
|
+
const hookFile = path.join(hookPath, hookItem.name);
|
|
201
|
+
const sourceFile = path.join(sourcePath, hookItem.name);
|
|
202
|
+
|
|
203
|
+
if (!fs.existsSync(sourceFile)) {
|
|
204
|
+
fs.copyFileSync(hookFile, sourceFile);
|
|
205
|
+
console.log(
|
|
206
|
+
`[INFO] [generateCode] HOOK APPLIED: Created ${hookItem.name} from hook.`
|
|
207
|
+
);
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const mergedContent = mergeHookIntoSource(
|
|
212
|
+
fs.readFileSync(sourceFile, 'utf8'),
|
|
213
|
+
fs.readFileSync(hookFile, 'utf8'),
|
|
214
|
+
sourceFile
|
|
215
|
+
);
|
|
216
|
+
fs.writeFileSync(sourceFile, mergedContent);
|
|
217
|
+
console.log(
|
|
218
|
+
`[INFO] [generateCode] HOOK APPLIED: Merged ${hookItem.name} into source.`
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
} else if (hasSource) {
|
|
222
|
+
fs.mkdirSync(path.join(currentDir, 'hook'), { recursive: true });
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
for (const item of items) {
|
|
226
|
+
if (!item.isDirectory() || item.name === 'source' || item.name === 'hook') continue;
|
|
227
|
+
processSourceHooks(path.join(currentDir, item.name));
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Restore backed-up hooks
|
|
232
|
+
if (hookDirs.size > 0 || hookBackups.length > 0) {
|
|
233
|
+
console.log(`[INFO] [generateCode] STATUS=RESTORE | Restoring ${hookBackups.length} hook files...`);
|
|
234
|
+
for (const relativeHookDir of hookDirs) {
|
|
235
|
+
fs.mkdirSync(path.join(outputPath, relativeHookDir), { recursive: true });
|
|
236
|
+
}
|
|
237
|
+
for (const backup of hookBackups) {
|
|
238
|
+
const hookDir = path.join(outputPath, backup.relativePath);
|
|
239
|
+
fs.writeFileSync(path.join(hookDir, backup.name), backup.content);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
processSourceHooks(generatorOptions.outputPath);
|
|
211
244
|
|
|
212
245
|
console.log(
|
|
213
246
|
'[INFO] [generateCode] STATUS=FINISHED | Code generation complete.'
|
package/src/generateIntTest.js
CHANGED
|
@@ -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.
|
|
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.
|
|
14
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
15
|
*/
|
|
17
16
|
|
|
18
|
-
import {
|
|
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 {
|
|
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 (
|
|
51
|
-
return [false,
|
|
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('
|
|
73
|
+
? new RegExp('\\/\\/\\(<(\\w+)>\\)([\\s\\S]*?)\\/\\/\\(<\\/\\1>\\)', 'gm')
|
|
72
74
|
: isYml
|
|
73
|
-
? new RegExp('\\#<#(\\w+)#>([
|
|
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(
|
|
78
|
+
? (name) => new RegExp(`\\/\\/\\(<${name}>\\)([\\s\\S]*?)\\/\\/\\(<\\/${name}>\\)`, 'gm')
|
|
78
79
|
: isYml
|
|
79
|
-
? (name) => new RegExp(`\\#<#${name}#>([
|
|
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 =
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
103
|
-
|
|
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 = {
|
|
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
|
|
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
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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 };
|