@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.
- 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 +16 -16
- 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 +2 -9
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/WebSocketGenerator.js +1 -7
- package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/BaseSqsHandler.js +3 -3
- 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/Flow/{_internal → _shared}/shared/triggerCacheBase.js +1 -7
- 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 +127 -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/DynamoDBGenerator.js +8 -8
- package/src/codeGenerators/resource/sls_yaml/FlowOutGenerator.js +60 -43
- package/src/codeGenerators/resource/sls_yaml/FlowResourceYamlGenerator.js +151 -151
- package/src/codeGenerators/resource/sls_yaml/templates/crud/ResourceYaml.ejs +10 -10
- package/src/core/renderTemplateFile.js +22 -0
- package/src/generateCode.js +146 -81
- package/src/generateIntTest.js +45 -69
- package/src/generateResourceIntTest.js +22 -47
- package/src/intTestGeneratorShared.js +36 -0
- package/src/schemaGenerators/app/src/schemas/FlowSchemas/templates/DynamicFlowSchemaTemplate.ejs +12 -10
- package/src/schemaGenerators/app/src/schemas/FlowSchemas/templates/RelationshipFlowSchemaTemplate.ejs +6 -5
- 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/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}/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/src/generateCode.js
CHANGED
|
@@ -5,17 +5,17 @@ import { parseObjectSchemas } from './parsers/objectSchemaParser.js';
|
|
|
5
5
|
import { parseRelationshipSchemas } from './parsers/relationshipSchemaParser.js';
|
|
6
6
|
import { parseFlowSchemas } from './parsers/flowSchemaParser.js';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { generateFlowEntryPoint } from './codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowEntryPointBase.js';
|
|
9
|
+
import { generateFlowMainFunction } from './codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowMainFunctionBase.js';
|
|
10
|
+
import { generateFlowSteps } from './codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowStepBase.js';
|
|
9
11
|
|
|
10
|
-
import {
|
|
11
|
-
import { generateFlowMainFunction } from './codeGenerators/app/src/generatedCode/Flow/_internal/shared/flowMainFunctionBase.js';
|
|
12
|
-
import { generateFlowSteps } from './codeGenerators/app/src/generatedCode/Flow/_internal/shared/flowStepBase.js';
|
|
12
|
+
import { generateEndpointsFlow } from './codeGenerators/app/src/generatedCode/Flow/FlowEndpoints/EndpointsGenerator.js';
|
|
13
13
|
import { generateFlowOut } from './codeGenerators/resource/sls_yaml/FlowOutGenerator.js';
|
|
14
14
|
import { generateFlowResourceYaml } from './codeGenerators/resource/sls_yaml/FlowResourceYamlGenerator.js';
|
|
15
15
|
import { generateRbacFlows } from './codeGenerators/app/src/generatedCode/Flow/FlowRbac/RbacFlowGenerator.js';
|
|
16
16
|
import { generateRelationshipFlows } from './codeGenerators/app/src/generatedCode/Flow/FlowRelationshipEndpoints/RelationshipFlowGenerator.js';
|
|
17
17
|
import { generateWebSocket } from './codeGenerators/app/src/generatedCode/Flow/FlowSchemas/WebSocketGenerator.js';
|
|
18
|
-
import { validateFlowsForGeneration } from './codeGenerators/app/src/generatedCode/Flow/
|
|
18
|
+
import { validateFlowsForGeneration } from './codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowValidator.js';
|
|
19
19
|
import { generateRegisterFlow } from './codeGenerators/app/src/generatedCode/SystemFlowSchemas/RegisterGenerator.js';
|
|
20
20
|
import { generateDynamoDBTables } from './codeGenerators/resource/sls_yaml/DynamoDBGenerator.js';
|
|
21
21
|
import { generateFindData } from './codeGenerators/app/src/generatedCode/FindData/FindDataGenerator.js';
|
|
@@ -27,47 +27,108 @@ import { generateConsts } from './codeGenerators/app/src/generatedCode/libs/Cons
|
|
|
27
27
|
import { generateProcessLogical } from './codeGenerators/app/src/generatedCode/ProcessLogical/ProcessLogicalGenerator.js';
|
|
28
28
|
import { generateProcessLogicalYaml } from './codeGenerators/app/sls_yaml/ProcessLogicalYamlGenerator.js';
|
|
29
29
|
import { generateSharedResourceYaml } from './codeGenerators/app/sls_yaml/SharedResourceYamlGenerator.js';
|
|
30
|
+
import { generateFindDataYaml } from './codeGenerators/app/sls_yaml/FindDataYamlGenerator.js';
|
|
30
31
|
import { policyRegistry } from './codeGenerators/app/sls_yaml/_policy/PolicyRegistry.js';
|
|
31
32
|
import { emitManagedPolicies } from './codeGenerators/app/sls_yaml/_policy/PolicyEmitter.js';
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
function createGeneratorOptions(rootPath, options = {}) {
|
|
35
|
+
return {
|
|
36
|
+
outputPath: options.outputPath || rootPath
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function generateCode(rootPath, options = {}) {
|
|
34
41
|
console.log(
|
|
35
42
|
'[INFO] [generateCode] STATUS=STARTING | Generating code files from all schemas...'
|
|
36
43
|
);
|
|
37
44
|
|
|
45
|
+
const generatorOptions = createGeneratorOptions(rootPath, options);
|
|
46
|
+
const { outputPath } = generatorOptions;
|
|
47
|
+
|
|
38
48
|
// Clean workspace
|
|
39
|
-
const
|
|
40
|
-
|
|
49
|
+
const generatedCodePath = path.join(
|
|
50
|
+
outputPath,
|
|
51
|
+
'app',
|
|
52
|
+
'src',
|
|
53
|
+
'generatedCode'
|
|
54
|
+
);
|
|
41
55
|
|
|
42
56
|
// Backup existing hook files to prevent them from being wiped out
|
|
43
57
|
const hookBackups = [];
|
|
44
|
-
|
|
58
|
+
const hookDirs = new Set();
|
|
59
|
+
|
|
60
|
+
function getHookTagMatchers(filePath) {
|
|
61
|
+
if (filePath.endsWith('.js')) {
|
|
62
|
+
return {
|
|
63
|
+
anyTag: /\/\/\(<(\w+)>\)([\s\S]*?)\/\/\(<\/\1>\)/gm,
|
|
64
|
+
tagPattern: name =>
|
|
65
|
+
new RegExp(
|
|
66
|
+
`\\/\\/\\(<${name}>\\)([\\s\\S]*?)\\/\\/\\(<\\/${name}>\\)`,
|
|
67
|
+
'gm'
|
|
68
|
+
)
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (filePath.endsWith('.yml') || filePath.endsWith('.yaml')) {
|
|
73
|
+
return {
|
|
74
|
+
anyTag: /#<#(\w+)#>([\s\S]*?)#<#\/\1#>/gm,
|
|
75
|
+
tagPattern: name =>
|
|
76
|
+
new RegExp(`#<#${name}#>([\\s\\S]*?)#<#\\/${name}#>`, 'gm')
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function mergeHookIntoSource(sourceContent, hookContent, filePath) {
|
|
84
|
+
const matchers = getHookTagMatchers(filePath);
|
|
85
|
+
if (!matchers) return hookContent;
|
|
86
|
+
|
|
87
|
+
return sourceContent.replace(
|
|
88
|
+
matchers.anyTag,
|
|
89
|
+
(match, tagName) =>
|
|
90
|
+
hookContent.match(matchers.tagPattern(tagName))?.[0] ?? match
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function collectHookBackups(currentDir) {
|
|
45
95
|
if (!fs.existsSync(currentDir)) return;
|
|
96
|
+
|
|
46
97
|
const items = fs.readdirSync(currentDir, { withFileTypes: true });
|
|
98
|
+
const hasSource = items.some(
|
|
99
|
+
item => item.isDirectory() && item.name === 'source'
|
|
100
|
+
);
|
|
101
|
+
const hasHook = items.some(
|
|
102
|
+
item => item.isDirectory() && item.name === 'hook'
|
|
103
|
+
);
|
|
47
104
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
} else if (item.name !== 'source') {
|
|
63
|
-
backupHooks(path.join(currentDir, item.name));
|
|
64
|
-
}
|
|
105
|
+
if (hasSource && hasHook) {
|
|
106
|
+
const hookPath = path.join(currentDir, 'hook');
|
|
107
|
+
hookDirs.add(path.relative(outputPath, hookPath));
|
|
108
|
+
const hookItems = fs.readdirSync(hookPath, { withFileTypes: true });
|
|
109
|
+
|
|
110
|
+
for (const hookItem of hookItems) {
|
|
111
|
+
if (!hookItem.isFile()) continue;
|
|
112
|
+
const hookFilePath = path.join(hookPath, hookItem.name);
|
|
113
|
+
hookBackups.push({
|
|
114
|
+
relativePath: path.relative(outputPath, hookPath),
|
|
115
|
+
name: hookItem.name,
|
|
116
|
+
content: fs.readFileSync(hookFilePath)
|
|
117
|
+
});
|
|
65
118
|
}
|
|
66
119
|
}
|
|
120
|
+
|
|
121
|
+
for (const item of items) {
|
|
122
|
+
if (!item.isDirectory() || item.name === 'source' || item.name === 'hook')
|
|
123
|
+
continue;
|
|
124
|
+
collectHookBackups(path.join(currentDir, item.name));
|
|
125
|
+
}
|
|
67
126
|
}
|
|
68
|
-
|
|
69
|
-
console.log(
|
|
70
|
-
|
|
127
|
+
|
|
128
|
+
console.log(
|
|
129
|
+
'[INFO] [generateCode] STATUS=BACKUP | Backing up existing hook files...'
|
|
130
|
+
);
|
|
131
|
+
collectHookBackups(outputPath);
|
|
71
132
|
|
|
72
133
|
console.log(
|
|
73
134
|
'[INFO] [generateCode] STATUS=CLEANUP | Removing old generatedCode and resource directories...'
|
|
@@ -97,38 +158,19 @@ export async function generateCode(rootPath, options) {
|
|
|
97
158
|
console.log('[INFO] [generateCode] STATUS=PARSING | FlowSchemas...');
|
|
98
159
|
const flowData = await parseFlowSchemas(rootPath, objectData, options);
|
|
99
160
|
|
|
100
|
-
// Build fixed system flows in memory instead of writing generated FlowSchema files.
|
|
101
|
-
const systemFlowData = buildSystemFlowDescriptors(
|
|
102
|
-
objectData,
|
|
103
|
-
relationshipData,
|
|
104
|
-
flowData
|
|
105
|
-
);
|
|
106
|
-
|
|
107
161
|
// The 'allSchemas' object contains the fully hydrated Memory Objects
|
|
108
162
|
const allSchemas = {
|
|
109
163
|
objects: objectData.objects,
|
|
110
164
|
relationships: relationshipData.relationships,
|
|
111
165
|
flows: flowData.flows,
|
|
112
|
-
|
|
113
|
-
flowsForGeneration: [
|
|
114
|
-
...(flowData.flows || []),
|
|
115
|
-
...(systemFlowData.flows || [])
|
|
116
|
-
]
|
|
166
|
+
flowsForGeneration: flowData.flows || []
|
|
117
167
|
};
|
|
118
168
|
|
|
119
|
-
// DEBUG: Dump the hydrated allSchemas to a file so we can inspect it
|
|
120
|
-
const dumpPath = path.join(
|
|
121
|
-
options.outputPath || rootPath,
|
|
122
|
-
'allSchemas_debug.json'
|
|
123
|
-
);
|
|
124
|
-
fs.writeFileSync(dumpPath, JSON.stringify(allSchemas, null, 2));
|
|
125
|
-
|
|
126
169
|
console.log('[INFO] [generateCode] STATUS=VALIDATING | Validating Flows...');
|
|
127
170
|
validateFlowsForGeneration(allSchemas.flowsForGeneration);
|
|
128
171
|
|
|
129
|
-
const generatorOptions = { outputPath: options.outputPath || rootPath };
|
|
130
|
-
|
|
131
172
|
// 2. Generation Pipeline
|
|
173
|
+
await generateEndpointsFlow(allSchemas, generatorOptions);
|
|
132
174
|
await generateFlowMainFunction(allSchemas, generatorOptions);
|
|
133
175
|
await generateFlowEntryPoint(allSchemas, generatorOptions);
|
|
134
176
|
await generateFlowSteps(allSchemas, generatorOptions);
|
|
@@ -136,11 +178,19 @@ export async function generateCode(rootPath, options) {
|
|
|
136
178
|
await generateFlowResourceYaml(allSchemas, generatorOptions);
|
|
137
179
|
await generateRbacFlows(allSchemas, generatorOptions);
|
|
138
180
|
await generateRelationshipFlows(allSchemas, generatorOptions);
|
|
139
|
-
await generateWebSocket(
|
|
140
|
-
|
|
181
|
+
await generateWebSocket(
|
|
182
|
+
allSchemas.flowsForGeneration,
|
|
183
|
+
'',
|
|
184
|
+
generatorOptions.outputPath
|
|
185
|
+
);
|
|
186
|
+
await generateRegisterFlow(
|
|
187
|
+
allSchemas.flowsForGeneration,
|
|
188
|
+
'',
|
|
189
|
+
generatorOptions.outputPath
|
|
190
|
+
);
|
|
141
191
|
|
|
142
192
|
// Call FunctionYamlGenerator after all Handlers have been generated
|
|
143
|
-
await generateFunctionYaml(allSchemas,
|
|
193
|
+
await generateFunctionYaml(allSchemas, generatorOptions);
|
|
144
194
|
await generateDynamoDBTables(allSchemas, generatorOptions);
|
|
145
195
|
await generateFindData(allSchemas, generatorOptions);
|
|
146
196
|
await generateCodeLibs(generatorOptions);
|
|
@@ -148,6 +198,7 @@ export async function generateCode(rootPath, options) {
|
|
|
148
198
|
await generateProcessLogical(generatorOptions);
|
|
149
199
|
await generateRoleNameConfig(allSchemas, generatorOptions);
|
|
150
200
|
await generateProcessLogicalYaml(allSchemas, generatorOptions);
|
|
201
|
+
await generateFindDataYaml(generatorOptions);
|
|
151
202
|
await generateSharedResourceYaml(allSchemas, generatorOptions);
|
|
152
203
|
await generateInitialSetup(allSchemas, generatorOptions);
|
|
153
204
|
|
|
@@ -158,51 +209,65 @@ export async function generateCode(rootPath, options) {
|
|
|
158
209
|
|
|
159
210
|
function processSourceHooks(currentDir) {
|
|
160
211
|
if (!fs.existsSync(currentDir)) return;
|
|
161
|
-
const items = fs.readdirSync(currentDir, { withFileTypes: true });
|
|
162
212
|
|
|
213
|
+
const items = fs.readdirSync(currentDir, { withFileTypes: true });
|
|
163
214
|
const hasSource = items.some(
|
|
164
215
|
item => item.isDirectory() && item.name === 'source'
|
|
165
216
|
);
|
|
166
|
-
|
|
217
|
+
const hasHook = items.some(
|
|
218
|
+
item => item.isDirectory() && item.name === 'hook'
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
if (hasSource && hasHook) {
|
|
167
222
|
const sourcePath = path.join(currentDir, 'source');
|
|
168
223
|
const hookPath = path.join(currentDir, 'hook');
|
|
224
|
+
const hookItems = fs.readdirSync(hookPath, { withFileTypes: true });
|
|
225
|
+
|
|
226
|
+
for (const hookItem of hookItems) {
|
|
227
|
+
if (!hookItem.isFile()) continue;
|
|
169
228
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
console.log(
|
|
180
|
-
`[INFO] [generateCode] HOOK APPLIED: Copied ${hookItem.name} to source.`
|
|
181
|
-
);
|
|
182
|
-
}
|
|
229
|
+
const hookFile = path.join(hookPath, hookItem.name);
|
|
230
|
+
const sourceFile = path.join(sourcePath, hookItem.name);
|
|
231
|
+
|
|
232
|
+
if (!fs.existsSync(sourceFile)) {
|
|
233
|
+
fs.copyFileSync(hookFile, sourceFile);
|
|
234
|
+
console.log(
|
|
235
|
+
`[INFO] [generateCode] HOOK APPLIED: Created ${hookItem.name} from hook.`
|
|
236
|
+
);
|
|
237
|
+
continue;
|
|
183
238
|
}
|
|
239
|
+
|
|
240
|
+
const mergedContent = mergeHookIntoSource(
|
|
241
|
+
fs.readFileSync(sourceFile, 'utf8'),
|
|
242
|
+
fs.readFileSync(hookFile, 'utf8'),
|
|
243
|
+
sourceFile
|
|
244
|
+
);
|
|
245
|
+
fs.writeFileSync(sourceFile, mergedContent);
|
|
246
|
+
console.log(
|
|
247
|
+
`[INFO] [generateCode] HOOK APPLIED: Merged ${hookItem.name} into source.`
|
|
248
|
+
);
|
|
184
249
|
}
|
|
250
|
+
} else if (hasSource) {
|
|
251
|
+
fs.mkdirSync(path.join(currentDir, 'hook'), { recursive: true });
|
|
185
252
|
}
|
|
186
253
|
|
|
187
254
|
for (const item of items) {
|
|
188
|
-
if (
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
item.name !== 'hook'
|
|
192
|
-
) {
|
|
193
|
-
processSourceHooks(path.join(currentDir, item.name));
|
|
194
|
-
}
|
|
255
|
+
if (!item.isDirectory() || item.name === 'source' || item.name === 'hook')
|
|
256
|
+
continue;
|
|
257
|
+
processSourceHooks(path.join(currentDir, item.name));
|
|
195
258
|
}
|
|
196
259
|
}
|
|
197
260
|
|
|
198
261
|
// Restore backed-up hooks
|
|
199
|
-
if (hookBackups.length > 0) {
|
|
200
|
-
console.log(
|
|
262
|
+
if (hookDirs.size > 0 || hookBackups.length > 0) {
|
|
263
|
+
console.log(
|
|
264
|
+
`[INFO] [generateCode] STATUS=RESTORE | Restoring ${hookBackups.length} hook files...`
|
|
265
|
+
);
|
|
266
|
+
for (const relativeHookDir of hookDirs) {
|
|
267
|
+
fs.mkdirSync(path.join(outputPath, relativeHookDir), { recursive: true });
|
|
268
|
+
}
|
|
201
269
|
for (const backup of hookBackups) {
|
|
202
|
-
const hookDir = path.join(
|
|
203
|
-
if (!fs.existsSync(hookDir)) {
|
|
204
|
-
fs.mkdirSync(hookDir, { recursive: true });
|
|
205
|
-
}
|
|
270
|
+
const hookDir = path.join(outputPath, backup.relativePath);
|
|
206
271
|
fs.writeFileSync(path.join(hookDir, backup.name), backup.content);
|
|
207
272
|
}
|
|
208
273
|
}
|
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 };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
1
|
+
/* Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
2
|
|
|
4
3
|
This program is free software: you can redistribute it and/or modify
|
|
5
4
|
it under the terms of the GNU Affero General Public License as
|
|
@@ -8,33 +7,33 @@ License, or (at your option) any later version.
|
|
|
8
7
|
|
|
9
8
|
This program is distributed in the hope that it will be useful,
|
|
10
9
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
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 { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
19
18
|
import { join } from 'path';
|
|
20
|
-
import yaml from 'yaml';
|
|
21
19
|
import ejs from 'ejs';
|
|
22
20
|
|
|
23
21
|
import generateResourceTemplate from './generateResources/IntTest/generateResources/generateResources.js';
|
|
22
|
+
import { getServiceTag, runTemplateItems } from './intTestGeneratorShared.js';
|
|
24
23
|
|
|
25
|
-
// Minimal writeSource for resource generation (no hook support, no beautify — resources are .json)
|
|
26
24
|
function writeSource({ templatePath, templateData, setting }, { checkCreateSourcePass = false } = {}) {
|
|
27
25
|
if (!templatePath || !templateData || !setting) {
|
|
28
26
|
throw new Error('Invalid IntTest resource item: missing templatePath/templateData/setting');
|
|
29
27
|
}
|
|
28
|
+
|
|
30
29
|
const { savePath, saveFileName, fileExtension } = setting;
|
|
31
30
|
|
|
32
31
|
if (checkCreateSourcePass) {
|
|
33
32
|
try {
|
|
34
33
|
ejs.compile(readFileSync(templatePath, 'utf8'))(templateData);
|
|
35
34
|
return [true, {}];
|
|
36
|
-
} catch (
|
|
37
|
-
return [false,
|
|
35
|
+
} catch (error) {
|
|
36
|
+
return [false, error];
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
39
|
|
|
@@ -43,59 +42,35 @@ function writeSource({ templatePath, templateData, setting }, { checkCreateSourc
|
|
|
43
42
|
|
|
44
43
|
const dataToSave = ejs.compile(readFileSync(templatePath, 'utf8'))(templateData);
|
|
45
44
|
writeFileSync(filePath, dataToSave, 'utf8');
|
|
45
|
+
return [true, {}];
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
function getServiceTag(rootPath) {
|
|
49
|
-
const configPath = join(rootPath, 'config', 'serverless.config.yml');
|
|
50
|
-
const config = yaml.parse(readFileSync(configPath, 'utf8'));
|
|
51
|
-
return config?.main_config?.iz_serviceTag;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Generate integration test shared resources (tableNames + function components) for the service.
|
|
56
|
-
* Result-Driven refactor: flat pipeline, no createSource/libs dependencies.
|
|
57
|
-
*
|
|
58
|
-
* @param {string} rootPath - Service root path containing /config and /app
|
|
59
|
-
* @param {Object} [options]
|
|
60
|
-
* @param {string} [options.outputPath] - Where to write (default: rootPath)
|
|
61
|
-
* @param {Object} [options._izContext] - Logger context (default: silent logger)
|
|
62
|
-
* @returns {Promise<{ serviceTag: string, count: number, durationMs: number }>}
|
|
63
|
-
*/
|
|
64
48
|
export async function generateResourceIntTest(rootPath, options = {}) {
|
|
65
49
|
const {
|
|
66
50
|
outputPath = rootPath,
|
|
67
|
-
_izContext = {
|
|
51
|
+
_izContext = {
|
|
52
|
+
logger: {
|
|
53
|
+
debug: () => {},
|
|
54
|
+
info: console.info,
|
|
55
|
+
warn: console.warn,
|
|
56
|
+
error: console.error
|
|
57
|
+
}
|
|
58
|
+
}
|
|
68
59
|
} = options;
|
|
69
60
|
|
|
70
61
|
const startTime = Date.now();
|
|
71
62
|
const serviceTag = getServiceTag(rootPath);
|
|
72
63
|
if (!serviceTag) {
|
|
73
|
-
throw new Error('Missing iz_serviceTag in serverless.config.yml — required
|
|
64
|
+
throw new Error('Missing iz_serviceTag in serverless.config.yml — required IntTest resource generation');
|
|
74
65
|
}
|
|
75
66
|
|
|
76
67
|
const savePath = join(outputPath, 'src', 'generateIntegrationTest');
|
|
77
|
-
|
|
78
|
-
// Get IntTest resource data from sub-orchestrator
|
|
79
68
|
const items = await generateResourceTemplate(_izContext, savePath, { serviceTag });
|
|
80
69
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
const [status, errors] = writeSource(item, { checkCreateSourcePass: true });
|
|
87
|
-
if (!status) {
|
|
88
|
-
throw new Error(`IntTest resource template validation failed: ${errors?.message || errors}`);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Write phase
|
|
93
|
-
for (const item of items) {
|
|
94
|
-
if (item.setting?.savePath && existsSync(item.setting.savePath)) {
|
|
95
|
-
rmSync(item.setting.savePath, { recursive: true, force: true });
|
|
96
|
-
}
|
|
97
|
-
writeSource(item, { checkCreateSourcePass: false });
|
|
98
|
-
}
|
|
70
|
+
await runTemplateItems(items, {
|
|
71
|
+
writeSource,
|
|
72
|
+
errorPrefix: 'IntTest resource'
|
|
73
|
+
});
|
|
99
74
|
|
|
100
75
|
const durationMs = Date.now() - startTime;
|
|
101
76
|
return { serviceTag, count: items.length, durationMs };
|