@izara_project/izara-core-generate-service-code 1.0.65 → 1.0.67
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/README.md +73 -11
- package/docs/TriggeredCache Flow.drawio +193 -0
- package/docs/test.mmd +47 -0
- package/docs/test.png +0 -0
- package/index.js +0 -5
- package/package.json +7 -6
- package/src/compile/compileProject.js +26 -0
- package/src/compile/loadSchemas.js +50 -0
- package/src/emit/crud/dynamicCrudFlowSchemaTemplate.js +11 -0
- package/src/emit/crud/emitCrudApplicationArtifacts.js +161 -0
- package/src/emit/crud/emitDynamicCrudFlowSchemas.js +84 -0
- package/src/emit/crud/generateCrudApplicationArtifacts.js +16 -0
- package/src/emit/crud/generateDynamicCrudFlowSchemas.js +21 -0
- package/src/emit/crud/loadLocalSchemaArrays.js +8 -0
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowObjects/templates/crud → emit/crud/templates}/CreateEndpoint_Main.ejs +6 -6
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowObjects/templates/crud → emit/crud/templates}/DeleteEndpoint_Main.ejs +6 -6
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowObjects/templates/step → emit/crud/templates}/FlowEndpointBeforeLogical_Main.ejs +2 -2
- package/src/emit/crud/templates/FlowEndpointComplete_Main.ejs +96 -0
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/endpoint → emit/crud/templates}/FlowEndpoint_HdrWbs.ejs +1 -1
- package/src/emit/crud/templates/FlowHandler_HdrApi.ejs +69 -0
- package/src/{codeGenerators/app/src/generatedCode/ProcessLogical/templates/ProcessLogical_HdrSqs.ejs → emit/crud/templates/FlowHandler_HdrSqs.ejs} +52 -56
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/endpoint → emit/crud/templates}/FlowMain_Wbs.ejs +1 -3
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowObjects/templates/crud → emit/crud/templates}/GetEndpoint_Main.ejs +2 -2
- package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +127 -0
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowObjects/templates/crud → emit/crud/templates}/UpdateEndpoint_Main.ejs +11 -9
- package/src/emit/custom/customFlows.js +121 -0
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +325 -0
- package/src/emit/custom/generateCustomFlowApplicationArtifacts.js +22 -0
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/endpoint → emit/custom/templates}/FlowEndpoint_Main.ejs +5 -5
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/step → emit/custom/templates}/FlowStep_Main.ejs +1 -1
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/ConfirmReserved_Main.ejs +5 -5
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/CreateObject_HdrWbs.ejs +1 -1
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/CreateObject_Main.ejs +3 -3
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/CreatePreSignUrl_Main.ejs +4 -5
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/FlowHandler_HdrS3.ejs +2 -8
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/ProcessS3File_Main.ejs +1 -1
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/ReservedLimit_Main.ejs +5 -6
- package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +32 -0
- package/src/emit/custom/templates/triggerCache/CheckTriggerCache_Main.ejs +63 -0
- package/src/emit/custom/templates/triggerCache/TriggerCacheComplete_Main.ejs +35 -0
- package/src/emit/custom/templates/triggerCache/TriggerCache_Main.ejs +16 -0
- package/src/emit/function/functionYamlArtifact.js +125 -0
- package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +117 -0
- package/src/emit/rbac/emitRbacApplicationArtifacts.js +270 -0
- package/src/emit/rbac/generateCreateTargetRoleHandler.js +19 -0
- package/src/emit/rbac/generateDynamicRbacFlowSchemas.js +21 -0
- package/src/emit/rbac/rbacFlowTag.js +7 -0
- package/src/emit/rbac/templates/CreateTargetRole_HdrSqs.ejs +24 -0
- package/src/emit/rbac/templates/CreateTargetRole_Main.ejs +25 -0
- package/src/emit/rbac/templates/DynamicRbacFlowSchema.ejs +5 -0
- package/src/emit/rbac/templates/ListRbac_HdrApi.ejs +17 -0
- package/src/emit/rbac/templates/ListRbac_HdrSqs.ejs +13 -0
- package/src/emit/rbac/templates/ListRbac_Main.ejs +29 -0
- package/src/emit/rbac/templates/RbacMutation_Main.ejs +22 -0
- package/src/emit/rbac/templates/UserRbacFlow_HdrInv.ejs +10 -0
- package/src/emit/rbac/templates/UserRbacFlow_Main.ejs +44 -0
- package/src/emit/rbac/templates/UserRoleMutation_Main.ejs +33 -0
- package/src/emit/relationship/dynamicRelationshipFlowSchemaTemplate.js +11 -0
- package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +66 -0
- package/src/emit/relationship/emitRelationshipApplicationArtifacts.js +148 -0
- package/src/emit/relationship/generateDynamicRelationshipFlowSchemas.js +23 -0
- package/src/emit/relationship/generateRelationshipApplicationArtifacts.js +22 -0
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessChangeRelationshipComplete_Main.ejs → emit/relationship/templates/ChangeRelationshipComplete_Main.ejs} +1 -1
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessChangeRelationship_Main.ejs → emit/relationship/templates/ChangeRelationship_Main.ejs} +12 -4
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessCreateRelationshipComplete_Main.ejs → emit/relationship/templates/CreateRelationshipComplete_Main.ejs} +1 -1
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessCreateRelationship_Main.ejs → emit/relationship/templates/CreateRelationship_Main.ejs} +1 -1
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessDeleteRelationshipComplete_Main.ejs → emit/relationship/templates/DeleteRelationshipComplete_Main.ejs} +1 -1
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessDeleteRelationship_Main.ejs → emit/relationship/templates/DeleteRelationship_Main.ejs} +1 -1
- package/src/{codeGenerators/app/src/generatedCode/Flow/_shared/handlers → emit/relationship/templates}/FlowHandler_HdrDsq.ejs +1 -1
- package/src/emit/relationship/templates/FlowHandler_HdrInv.ejs +45 -0
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessGetRelationshipComplete_Main.ejs → emit/relationship/templates/GetRelationshipComplete_Main.ejs} +1 -1
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessGetRelationship_Main.ejs → emit/relationship/templates/GetRelationship_Main.ejs} +1 -1
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessMoveRelationship_Main.ejs → emit/relationship/templates/MoveRelationship_Main.ejs} +9 -1
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessUpdateRelationshipComplete_Main.ejs → emit/relationship/templates/UpdateRelationshipComplete_Main.ejs} +1 -1
- package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessUpdateRelationship_Main.ejs → emit/relationship/templates/UpdateRelationship_Main.ejs} +1 -1
- package/src/emit/resource/emitResourceArtifacts.js +595 -0
- package/src/emit/resource/generateResourceArtifacts.js +20 -0
- package/src/{codeGenerators/resource/sls_yaml/templates/crud → emit/resource/templates}/ResourceBeforeLogicalYaml.ejs +1 -1
- package/src/{codeGenerators/resource/sls_yaml/templates/crud → emit/resource/templates}/ResourceSqsYaml.ejs +6 -6
- package/src/{codeGenerators/app/sls_yaml → emit/resource}/templates/SharedResource_Yaml.ejs +8 -8
- package/src/emit/system/emitSystemWebSocketArtifacts.js +183 -0
- package/src/generate.js +60 -126
- package/src/output/commitArtifacts.js +213 -0
- package/src/output/mergeHooks.js +55 -0
- package/src/output/validateArtifacts.js +62 -0
- package/src/plan/buildGenerationPlan.js +50 -0
- package/test/core.test.js +159 -0
- package/test/createTargetRoleHandler.test.js +68 -0
- package/test/crudApplicationArtifacts.test.js +107 -0
- package/test/customFlowApplicationArtifacts.test.js +297 -0
- package/test/dynamicCrudFlowSchemas.test.js +136 -0
- package/test/dynamicRbacFlowSchemas.test.js +101 -0
- package/test/dynamicRelationshipFlowSchemas.test.js +99 -0
- package/test/functionYamlArtifact.test.js +34 -0
- package/test/intTestApi.test.js +29 -0
- package/test/publicApi.test.js +209 -0
- package/test/relationshipApplicationArtifacts.test.js +68 -0
- package/test/resourceArtifacts.test.js +121 -0
- package/jsconfig.json +0 -9
- package/src/__tests__/getIntTestConfig.test.js +0 -51
- package/src/__tests__/intTestGeneratorShared.test.cjs +0 -169
- package/src/__tests__/pathIntTest.test.js +0 -103
- package/src/codeGenerators/app/initial_setup/InitialSetupGenerator.js +0 -199
- package/src/codeGenerators/app/initial_setup/templates/InitialSetup_LambdaRole.ejs +0 -50
- package/src/codeGenerators/app/initial_setup/templates/InitialSetup_SnsService.ejs +0 -15
- package/src/codeGenerators/app/initial_setup/templates/InitialSetup_TableName.ejs +0 -9
- package/src/codeGenerators/app/sls_yaml/FindDataYamlGenerator.js +0 -23
- package/src/codeGenerators/app/sls_yaml/FunctionYamlGenerator.js +0 -332
- package/src/codeGenerators/app/sls_yaml/ProcessLogicalYamlGenerator.js +0 -21
- package/src/codeGenerators/app/sls_yaml/RoleNameConfigGenerator.js +0 -48
- package/src/codeGenerators/app/sls_yaml/SharedResourceYamlGenerator.js +0 -503
- package/src/codeGenerators/app/sls_yaml/__tests__/SharedResourceYamlGenerator.test.js +0 -235
- package/src/codeGenerators/app/sls_yaml/_policy/PolicyRegistry.js +0 -56
- package/src/codeGenerators/app/sls_yaml/_policy/__tests__/PolicyRegistry.test.js +0 -33
- package/src/codeGenerators/app/sls_yaml/renderYamlTemplate.js +0 -13
- package/src/codeGenerators/app/sls_yaml/templates/FindData_Yaml.ejs +0 -10
- package/src/codeGenerators/app/sls_yaml/templates/FunctionYaml_Api.ejs +0 -21
- package/src/codeGenerators/app/sls_yaml/templates/FunctionYaml_EventBridge.ejs +0 -14
- package/src/codeGenerators/app/sls_yaml/templates/FunctionYaml_Inv.ejs +0 -6
- package/src/codeGenerators/app/sls_yaml/templates/FunctionYaml_Sqs.ejs +0 -11
- package/src/codeGenerators/app/sls_yaml/templates/FunctionYaml_Wbs.ejs +0 -11
- package/src/codeGenerators/app/sls_yaml/templates/ProcessLogical_Yaml.ejs +0 -32
- package/src/codeGenerators/app/sls_yaml/templates/RoleNameConfig_Yaml.ejs +0 -5
- package/src/codeGenerators/app/src/generatedCode/FindData/FindDataGenerator.js +0 -238
- package/src/codeGenerators/app/src/generatedCode/FindData/templates/FindData_HdrSqs.ejs +0 -87
- package/src/codeGenerators/app/src/generatedCode/FindData/templates/FindData_Main.ejs +0 -108
- package/src/codeGenerators/app/src/generatedCode/FindData/templates/GetByStorage/getByDynamo.ejs +0 -32
- package/src/codeGenerators/app/src/generatedCode/FindData/templates/GetByStorage/getByGraph.ejs +0 -87
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowObjects/.gitkeep +0 -0
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowObjects/EndpointsGenerator.js +0 -120
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowObjects/templates/step/FlowEndpointComplete_Main.ejs +0 -313
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/RbacFlowGenerator.js +0 -116
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/CreateRolePermissions.ejs +0 -135
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/CreateTargetRole.ejs +0 -131
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/CreateUserRole.ejs +0 -150
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/DeleteRolePermissions.ejs +0 -132
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/DeleteTargetRole.ejs +0 -132
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/DeleteUserFromRole.ejs +0 -150
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/FlowRbac_Main.ejs +0 -252
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/ListRolePermissions.ejs +0 -120
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/ListTargetRole.ejs +0 -122
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/ListUserInRoles.ejs +0 -117
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowRelationships/RelationshipFlowGenerator.js +0 -148
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/.gitkeep +0 -0
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/StatusFieldGenerator.js +0 -109
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/WebSocketGenerator.js +0 -122
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/endpoint/FlowEntryPoint_Main.ejs +0 -38
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/statusField/CompleteStatusFieldSns_Yaml.ejs +0 -52
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/statusField/CompleteStatusField_HdrSqs.ejs +0 -84
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/statusField/CompleteStatusField_Main.ejs +0 -78
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/step/plugIns/FlowStep_ByConfig_Awaiting_Main.ejs +0 -123
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/step/plugIns/FlowStep_ByConfig_Paginated_Main.ejs +0 -59
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/step/plugIns/FlowStep_PlugIn_Main.ejs +0 -72
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/step/plugIns/FlowStep_RecievePlugIn_Main.ejs +0 -76
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/step/plugIns/templateAwaitingStep.ejs +0 -41
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/step/plugIns/templateSendPlugin.ejs +0 -18
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/webSocket/ProcessWebSocketFlow_Yaml.ejs +0 -26
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/webSocket/ProcessWebSocketSub_Yaml.ejs +0 -7
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/webSocket/ProcessWebSocket_HdrSqs.ejs +0 -66
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/webSocket/ProcessWebSocket_Main.ejs +0 -115
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/webSocket/ProcessWebSocket_Yaml.ejs +0 -36
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/webSocket/WebSocketConnect_Main.ejs +0 -52
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/webSocket/WebSocketConnect_Yaml.ejs +0 -13
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/webSocket/WebSocketDynamoDb_Yaml.ejs +0 -28
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/BaseDsqHandler.js +0 -63
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/BaseSqsHandler.js +0 -66
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/__tests__/BaseDsqHandler.test.js +0 -94
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/dsq.js +0 -5
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/eventBridge.js +0 -33
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/extTopic.js +0 -6
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/lambdaSyncApi.js +0 -51
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/lambdaSyncInv.js +0 -51
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/ownTopic.js +0 -54
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/registry.js +0 -17
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/s3.js +0 -56
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/s3Components/ConfirmAfterUploadS3Generator.js +0 -46
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/s3Components/CreateObjectGenerator.js +0 -50
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/s3Components/CreatePreSignUrlGenerator.js +0 -48
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/s3Components/ProcessAfterUploadS3Generator.js +0 -49
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/s3Components/ReservedLimitGenerator.js +0 -47
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/eventTypes.js +0 -23
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowClassifier.js +0 -50
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowEntryPointBase.js +0 -106
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowMainFunctionBase.js +0 -172
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowNaming.js +0 -37
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowSelection.js +0 -19
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowStepBase.js +0 -235
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowStepNormalizer.js +0 -75
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowValidator.js +0 -267
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/propertyNormalizer.js +0 -18
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/registry.js +0 -7
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/roleNameDetection.js +0 -49
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/triggerCacheBase.js +0 -177
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/triggerCache/CheckTriggerCache_HdrSqs.ejs +0 -89
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/triggerCache/CheckTriggerCache_Main.ejs +0 -83
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/triggerCache/ProcessTriggerCache_HdrSqs.ejs +0 -103
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/triggerCache/ProcessTriggerCache_Main.ejs +0 -58
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/triggerCache/TriggerCacheComplete_HdrDsq.ejs +0 -104
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/triggerCache/TriggerCacheComplete_HdrSqs.ejs +0 -88
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/triggerCache/TriggerCacheComplete_Main.ejs +0 -80
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/triggerCache/TriggerCacheQueue_Yaml.ejs +0 -36
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/yaml/SharedFunctionSqs_Yaml.ejs +0 -13
- package/src/codeGenerators/app/src/generatedCode/ProcessLogical/ProcessLogicalGenerator.js +0 -29
- package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/PaginateProcessLogical_HdrDsq.ejs +0 -177
- package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/PaginateProcessLogical_HdrSqs.ejs +0 -155
- package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/PaginateProcessLogical_Main.ejs +0 -268
- package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/ProcessLogical_Main.ejs +0 -450
- package/src/codeGenerators/app/src/generatedCode/SystemFlowSchemas/RegisterGenerator.js +0 -149
- package/src/codeGenerators/app/src/generatedCode/SystemFlowSchemas/templates/register/RegisterComplete_HdrSqs.ejs +0 -85
- package/src/codeGenerators/app/src/generatedCode/SystemFlowSchemas/templates/register/RegisterComplete_Main.ejs +0 -176
- package/src/codeGenerators/app/src/generatedCode/SystemFlowSchemas/templates/register/Register_HdrWbs.ejs +0 -80
- package/src/codeGenerators/app/src/generatedCode/SystemFlowSchemas/templates/register/Register_Main.ejs +0 -164
- package/src/codeGenerators/app/src/generatedCode/libs/ConstsGenerator.js +0 -28
- package/src/codeGenerators/app/src/generatedCode/libs/GenerateCodeLibsGenerator.js +0 -28
- package/src/codeGenerators/app/src/generatedCode/libs/templates/Consts.ejs +0 -448
- package/src/codeGenerators/app/src/generatedCode/libs/templates/GenerateCodeLibs.ejs +0 -124
- package/src/codeGenerators/resource/sls_yaml/DynamoDBGenerator.js +0 -87
- package/src/codeGenerators/resource/sls_yaml/FlowOutGenerator.js +0 -70
- package/src/codeGenerators/resource/sls_yaml/FlowResourceYamlGenerator.js +0 -182
- package/src/core/renderTemplateFile.js +0 -22
- package/src/core/validate.js +0 -165
- package/src/generateCode.js +0 -357
- package/src/generateSchema.js +0 -123
- package/src/parsers/flowSchemaParser.js +0 -112
- package/src/parsers/objectSchemaParser.js +0 -39
- package/src/parsers/relationshipSchemaParser.js +0 -51
- package/src/schemaGenerators/app/src/schemas/FlowSchemas/FlowSchemaGenerator.js +0 -107
- package/src/schemaGenerators/app/src/schemas/FlowSchemas/RbacFlowSchemaGenerator.js +0 -98
- package/src/schemaGenerators/app/src/schemas/FlowSchemas/RelationshipFlowSchemaGenerator.js +0 -89
- package/src/schemaGenerators/app/src/schemas/FlowSchemas/templates/DynamicFlowSchemaTemplate.ejs +0 -41
- package/src/schemaGenerators/app/src/schemas/FlowSchemas/templates/DynamicRbacFlowSchemaTemplate.ejs +0 -20
- package/src/schemaGenerators/app/src/schemas/FlowSchemas/templates/RelationshipFlowSchemaTemplate.ejs +0 -33
- package/src/schemaGenerators/app/src/schemas/FlowSchemas/templates/UserRbacFlowSchemaTemplate.ejs +0 -22
- package/src/schemaGenerators/app/src/schemas/ObjectSchemas/AttributeTreeSchemaGenerator.js +0 -124
- package/src/schemaGenerators/app/src/schemas/ObjectSchemas/PropertyValueSchemaGenerator.js +0 -119
- package/src/schemaGenerators/app/src/schemas/ObjectSchemas/templates/DynamicAttributeTreeManagerSchemaTemplate.ejs +0 -14
- package/src/schemaGenerators/app/src/schemas/ObjectSchemas/templates/DynamicAttributeTreeStandardSchemaTemplate.ejs +0 -13
- package/src/schemaGenerators/app/src/schemas/ObjectSchemas/templates/DynamicPropertyValueSchemaTemplate.ejs +0 -15
- package/src/schemaGenerators/app/src/schemas/RelationshipSchemas/AttributeTreeRelationshipSchemaGenerator.js +0 -109
- package/src/schemaGenerators/app/src/schemas/RelationshipSchemas/PropertyValueRelationshipSchemaGenerator.js +0 -103
- package/src/schemaGenerators/app/src/schemas/RelationshipSchemas/__tests__/relationshipSchemaHelpers.test.js +0 -38
- package/src/schemaGenerators/app/src/schemas/RelationshipSchemas/relationshipSchemaHelpers.js +0 -40
- package/src/schemaGenerators/app/src/schemas/RelationshipSchemas/templates/DynamicAttributeTreeRelationshipSchemaTemplate.ejs +0 -7
- package/src/schemaGenerators/app/src/schemas/RelationshipSchemas/templates/DynamicPropertyValueRelationshipSchemaTemplate.ejs +0 -7
- package/src/schemaGenerators/app/src/schemas/SystemTextSchemas/SystemTextGenerator.js +0 -102
- package/src/schemaGenerators/app/src/schemas/SystemTextSchemas/templates/SystemText_Template.ejs +0 -10
- /package/src/{codeGenerators/app/src/generatedCode/Flow/_shared/handlers → emit/crud/templates}/FlowHandler_HdrInv.ejs +0 -0
- /package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/ConfirmReserved_HdrSqs.ejs +0 -0
- /package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/CreatePreSignUrl_HdrSqs.ejs +0 -0
- /package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/ReservedLimit_HdrSqs.ejs +0 -0
- /package/src/{codeGenerators/app/src/generatedCode/Flow/_shared/handlers → emit/relationship/templates}/FlowHandler_HdrApi.ejs +0 -0
- /package/src/{codeGenerators/app/src/generatedCode/Flow/_shared/handlers → emit/relationship/templates}/FlowHandler_HdrSqs.ejs +0 -0
- /package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessMoveRelationshipComplete_Main.ejs → emit/relationship/templates/MoveRelationshipComplete_Main.ejs} +0 -0
- /package/src/{codeGenerators/resource/sls_yaml → emit/resource}/templates/DynamoDBTable_Yaml.ejs +0 -0
- /package/src/{codeGenerators/resource/sls_yaml → emit/resource}/templates/FlowOut_Yaml.ejs +0 -0
- /package/src/{codeGenerators/resource/sls_yaml/templates/crud → emit/resource/templates}/ResourceYaml.ejs +0 -0
- /package/src/{codeGenerators/resource/sls_yaml → emit/resource}/templates/SystemDynamoDB_Yaml.ejs +0 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import ejs from 'ejs';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
renderApiFunctionYaml,
|
|
6
|
+
renderInvFunctionYaml,
|
|
7
|
+
renderSqsFunctionYaml,
|
|
8
|
+
renderWbsFunctionYaml
|
|
9
|
+
} from '../function/functionYamlArtifact.js';
|
|
10
|
+
|
|
11
|
+
const ACTIONS = ['Create', 'Update', 'Delete', 'Get'];
|
|
12
|
+
const YAML_PATH = 'app/sls_yaml/generatedCode/source/flow-objects.yml';
|
|
13
|
+
const TEMPLATE_URL = new URL('./templates/', import.meta.url);
|
|
14
|
+
|
|
15
|
+
export async function emitCrudApplicationArtifacts({ objects, flows = [], serviceTag }) {
|
|
16
|
+
if (!Array.isArray(objects) || !Array.isArray(flows)) {
|
|
17
|
+
throw new TypeError('objects and flows must be arrays');
|
|
18
|
+
}
|
|
19
|
+
if (!objects.some(isCrudObject)) return [];
|
|
20
|
+
|
|
21
|
+
const handlers = await Promise.all(ACTIONS.map(action => emitAction(action, objects, flows, serviceTag)));
|
|
22
|
+
return [
|
|
23
|
+
...handlers.flatMap(handler => handler.artifacts),
|
|
24
|
+
{
|
|
25
|
+
path: YAML_PATH,
|
|
26
|
+
content: handlers.flatMap(handler => handler.functions).map(renderFunction).join('\n')
|
|
27
|
+
}
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function crudApplicationManagedPaths() {
|
|
32
|
+
return [
|
|
33
|
+
...ACTIONS.flatMap(action => {
|
|
34
|
+
const source = `app/src/generatedCode/FlowObjects/${action}/source`;
|
|
35
|
+
const paths = [`${source}/${action}_Main.js`];
|
|
36
|
+
if (action === 'Get') {
|
|
37
|
+
paths.push(`${source}/Get_HdrInv.js`, `${source}/Get_HdrApi.js`);
|
|
38
|
+
paths.push(`${source}/GetRange_Main.js`, `${source}/GetRange_HdrApi.js`);
|
|
39
|
+
} else {
|
|
40
|
+
paths.push(
|
|
41
|
+
`${source}/${action}_HdrSqs.js`,
|
|
42
|
+
`${source}/${action}_WbsMain.js`,
|
|
43
|
+
`${source}/${action}_HdrWbs.js`,
|
|
44
|
+
`${source}/${action}BeforeLogical_Main.js`,
|
|
45
|
+
`${source}/${action}BeforeLogical_HdrSqs.js`
|
|
46
|
+
);
|
|
47
|
+
paths.push(`${source}/${action}Complete_Main.js`, `${source}/${action}Complete_HdrSqs.js`);
|
|
48
|
+
}
|
|
49
|
+
return paths;
|
|
50
|
+
}),
|
|
51
|
+
YAML_PATH
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function emitAction(action, objects, flows, serviceTag) {
|
|
56
|
+
const source = `app/src/generatedCode/FlowObjects/${action}/source`;
|
|
57
|
+
const handlerRoot = `src/generatedCode/FlowObjects/${action}/source`;
|
|
58
|
+
const generateCode = flows
|
|
59
|
+
.filter(flow => flow?.generatedCodeConfig?.generatedCodeTag?.toLowerCase() === action.toLowerCase())
|
|
60
|
+
.map(flow => ({ ...flow.generatedCodeConfig, flowTag: flow.flowTag }));
|
|
61
|
+
const mainFileName = `${action}_Main`;
|
|
62
|
+
const shared = {
|
|
63
|
+
flowTag: action,
|
|
64
|
+
upperCaseFlowTag: action,
|
|
65
|
+
topicArn: `${action}_In`,
|
|
66
|
+
generateCode,
|
|
67
|
+
flow: null,
|
|
68
|
+
flowStepName: '',
|
|
69
|
+
startConfig: null
|
|
70
|
+
};
|
|
71
|
+
const artifacts = [{
|
|
72
|
+
path: `${source}/${mainFileName}.js`,
|
|
73
|
+
content: await render(`${action}Endpoint_Main.ejs`, shared)
|
|
74
|
+
}];
|
|
75
|
+
|
|
76
|
+
if (action === 'Get') {
|
|
77
|
+
artifacts.push(
|
|
78
|
+
{ path: `${source}/Get_HdrInv.js`, content: await render('FlowHandler_HdrInv.ejs', { ...shared, mainFileName, functionName: 'Get', queueName: 'GetHdrInv' }) },
|
|
79
|
+
{ path: `${source}/Get_HdrApi.js`, content: await render('FlowHandler_HdrApi.ejs', { ...shared, mainFileName, functionName: 'Get', queueName: 'GetHdrApi' }) },
|
|
80
|
+
{ path: `${source}/GetRange_Main.js`, content: await render('GetRangeEndpoint_Main.ejs', { ...shared, mainFileName: 'GetRange_Main', functionName: 'GetRange' }) },
|
|
81
|
+
{ path: `${source}/GetRange_HdrApi.js`, content: await render('FlowHandler_HdrApi.ejs', { ...shared, mainFileName: 'GetRange_Main', functionName: 'GetRange', queueName: 'GetRangeHdrApi' }) }
|
|
82
|
+
);
|
|
83
|
+
return {
|
|
84
|
+
artifacts,
|
|
85
|
+
functions: [
|
|
86
|
+
{ type: 'inv', functionName: 'GetHdrInv', handlerPath: `${handlerRoot}/Get_HdrInv.main`, roleName: 'FlowObjectsRole', flowTag: action, flowStepName: '' },
|
|
87
|
+
{
|
|
88
|
+
type: 'api',
|
|
89
|
+
functionName: 'GetHdrApi',
|
|
90
|
+
handlerPath: `${handlerRoot}/Get_HdrApi.main`,
|
|
91
|
+
roleName: 'FlowObjectsRole',
|
|
92
|
+
flowTag: action,
|
|
93
|
+
flowStepName: '',
|
|
94
|
+
routes: objects.filter(isCrudObject).map(object => ({
|
|
95
|
+
path: `/${serviceTag ?? '${self:custom.iz_serviceName}'}/${object.objectType}/get`,
|
|
96
|
+
upperName: upperFirst(object.objectType)
|
|
97
|
+
}))
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
type: 'api',
|
|
101
|
+
functionName: 'GetRangeHdrApi',
|
|
102
|
+
handlerPath: `${handlerRoot}/GetRange_HdrApi.main`,
|
|
103
|
+
roleName: 'FlowObjectsRole',
|
|
104
|
+
flowTag: 'GetRange',
|
|
105
|
+
flowStepName: '',
|
|
106
|
+
routes: objects.filter(isCrudObject)
|
|
107
|
+
.filter(object => object.identifiers && object.identifiers.some(i => i.type === 'sortKey'))
|
|
108
|
+
.map(object => ({
|
|
109
|
+
path: `/${serviceTag ?? '${self:custom.iz_serviceName}'}/${object.objectType}/getRange`,
|
|
110
|
+
upperName: upperFirst(object.objectType)
|
|
111
|
+
}))
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
artifacts.push(
|
|
118
|
+
{ path: `${source}/${action}_HdrSqs.js`, content: await render('FlowHandler_HdrSqs.ejs', { ...shared, mainFileName, functionName: action, queueName: `${action}HdrSqs` }) },
|
|
119
|
+
{ path: `${source}/${action}_WbsMain.js`, content: await render('FlowMain_Wbs.ejs', { ...shared, functionName: action }) },
|
|
120
|
+
{ path: `${source}/${action}_HdrWbs.js`, content: await render('FlowEndpoint_HdrWbs.ejs', { ...shared, mainFileName: `${action}_WbsMain`, functionName: action, route: action }) }
|
|
121
|
+
);
|
|
122
|
+
const functions = [
|
|
123
|
+
{ type: 'wbs', functionName: `${action}HdrWbs`, handlerPath: `${handlerRoot}/${action}_HdrWbs.main`, roleName: 'FlowObjectsRole', routeName: action, flowTag: action, flowStepName: '' },
|
|
124
|
+
{ type: 'sqs', functionName: `${action}HdrSqs`, handlerPath: `${handlerRoot}/${action}_HdrSqs.main`, roleName: 'FlowObjectsRole', queueName: `${action}HdrSqs`, flowTag: action, flowStepName: '' }
|
|
125
|
+
];
|
|
126
|
+
const complete = `${action}Complete`;
|
|
127
|
+
artifacts.push(
|
|
128
|
+
{ path: `${source}/${complete}_Main.js`, content: await render('FlowEndpointComplete_Main.ejs', { action }) },
|
|
129
|
+
{ path: `${source}/${complete}_HdrSqs.js`, content: await render('FlowHandler_HdrSqs.ejs', { ...shared, mainFileName: `${complete}_Main`, functionName: complete, queueName: `${action}CompleteHdrSqs` }) }
|
|
130
|
+
);
|
|
131
|
+
functions.push({ type: 'sqs', functionName: `${action}CompleteHdrSqs`, handlerPath: `${handlerRoot}/${complete}_HdrSqs.main`, roleName: 'FlowObjectsRole', queueName: `${action}CompleteHdrSqs`, flowTag: action, flowStepName: 'Complete' });
|
|
132
|
+
if (generateCode.some(config => config.codeHookTag === 'beforeLogical')) {
|
|
133
|
+
const beforeMain = `${action}BeforeLogical_Main`;
|
|
134
|
+
artifacts.push(
|
|
135
|
+
{ path: `${source}/${beforeMain}.js`, content: await render('FlowEndpointBeforeLogical_Main.ejs', shared) },
|
|
136
|
+
{ path: `${source}/${action}BeforeLogical_HdrSqs.js`, content: await render('FlowHandler_HdrSqs.ejs', { ...shared, mainFileName: beforeMain, functionName: `${action}BeforeLogicalMain`, queueName: `${action}BeforeLogicalHdrSqs` }) }
|
|
137
|
+
);
|
|
138
|
+
functions.push({ type: 'sqs', functionName: `${action}BeforeLogicalHdrSqs`, handlerPath: `${handlerRoot}/${action}BeforeLogical_HdrSqs.main`, roleName: 'FlowObjectsRole', queueName: `${action}BeforeLogicalHdrSqs`, flowTag: action, flowStepName: 'BeforeLogical' });
|
|
139
|
+
}
|
|
140
|
+
return { artifacts, functions };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function isCrudObject(object) {
|
|
144
|
+
return object?.generatedBy === 'userGenerated' || object?.generatedBy === 'systemGenerated';
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function upperFirst(value) {
|
|
148
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async function render(templateName, data) {
|
|
152
|
+
const template = await readFile(new URL(templateName, TEMPLATE_URL), 'utf8');
|
|
153
|
+
return ejs.render(template, data);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function renderFunction(descriptor) {
|
|
157
|
+
if (descriptor.type === 'api') return renderApiFunctionYaml(descriptor);
|
|
158
|
+
if (descriptor.type === 'inv') return renderInvFunctionYaml(descriptor);
|
|
159
|
+
if (descriptor.type === 'wbs') return renderWbsFunctionYaml(descriptor);
|
|
160
|
+
return renderSqsFunctionYaml(descriptor);
|
|
161
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { renderDynamicCrudFlowSchema } from './dynamicCrudFlowSchemaTemplate.js';
|
|
2
|
+
|
|
3
|
+
const ACTIONS = ['Create', 'Update', 'Delete', 'Get'];
|
|
4
|
+
const MESSAGE_ATTRIBUTES = ['userId', 'correlationId'];
|
|
5
|
+
|
|
6
|
+
export const dynamicCrudFlowSchemaPaths = ACTIONS.map(
|
|
7
|
+
action => `app/src/schemas/FlowSchemas/generateCode/${action}.js`
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
export function emitDynamicCrudFlowSchemas({ objects, flows = [] }) {
|
|
11
|
+
if (!Array.isArray(objects) || !Array.isArray(flows)) {
|
|
12
|
+
throw new TypeError('objects and flows must be arrays');
|
|
13
|
+
}
|
|
14
|
+
if (!objects.some(object => object?.generatedBy === 'userGenerated' || object?.generatedBy === 'systemGenerated')) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return ACTIONS.map((action, index) => {
|
|
19
|
+
const flow = createDynamicFlow(action, hasBeforeLogicalStep(flows, action));
|
|
20
|
+
return {
|
|
21
|
+
path: dynamicCrudFlowSchemaPaths[index],
|
|
22
|
+
content: renderDynamicCrudFlowSchema(action, flow)
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function createDynamicFlow(action, hasBeforeLogicalStep) {
|
|
28
|
+
const outputTopic = action !== 'Get';
|
|
29
|
+
const flowSteps = [
|
|
30
|
+
{
|
|
31
|
+
stepName: 'start',
|
|
32
|
+
properties: [],
|
|
33
|
+
messageAttributes: MESSAGE_ATTRIBUTES,
|
|
34
|
+
...(outputTopic ? {
|
|
35
|
+
returnValues: {
|
|
36
|
+
properties: [],
|
|
37
|
+
messageAttributes: MESSAGE_ATTRIBUTES
|
|
38
|
+
}
|
|
39
|
+
} : {})
|
|
40
|
+
}
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
if (hasBeforeLogicalStep) {
|
|
44
|
+
flowSteps.push({
|
|
45
|
+
stepName: 'BeforeLogical',
|
|
46
|
+
event: ['extTopic'],
|
|
47
|
+
properties: [],
|
|
48
|
+
messageAttributes: MESSAGE_ATTRIBUTES
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (action !== 'Get') {
|
|
52
|
+
flowSteps.push({
|
|
53
|
+
stepName: 'Complete',
|
|
54
|
+
event: ['extTopic'],
|
|
55
|
+
properties: [],
|
|
56
|
+
messageAttributes: MESSAGE_ATTRIBUTES
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
flowTag: action,
|
|
62
|
+
isDynamicObjectType: true,
|
|
63
|
+
initiateBy: 'system',
|
|
64
|
+
handleObj: 'one',
|
|
65
|
+
statusType: 'none',
|
|
66
|
+
event: outputTopic ? ['ownTopic'] : ['lambdaSyncInv', 'lambdaSyncApi'],
|
|
67
|
+
outputTopic,
|
|
68
|
+
stepMessageAttributes: {
|
|
69
|
+
userId: { propertyName: 'x-correlation-base-user-id', type: 'string' },
|
|
70
|
+
correlationId: { propertyName: 'x-correlation-id', type: 'string' }
|
|
71
|
+
},
|
|
72
|
+
flowSteps
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function hasBeforeLogicalStep(flows, action) {
|
|
77
|
+
return flows.some(flow => {
|
|
78
|
+
const config = flow?.generatedCodeConfig;
|
|
79
|
+
return config?.generatedCodeTag === action.toLowerCase()
|
|
80
|
+
&& config.codeHookTag === 'beforeLogical'
|
|
81
|
+
&& Array.isArray(flow.event)
|
|
82
|
+
&& flow.event.includes(config.invocationType);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { buildGenerationPlan } from '../../plan/buildGenerationPlan.js';
|
|
2
|
+
import { commitArtifacts } from '../../output/commitArtifacts.js';
|
|
3
|
+
import { compileProject } from '../../compile/compileProject.js';
|
|
4
|
+
import { loadLocalSchemaArrays } from './loadLocalSchemaArrays.js';
|
|
5
|
+
import { crudApplicationManagedPaths, emitCrudApplicationArtifacts } from './emitCrudApplicationArtifacts.js';
|
|
6
|
+
|
|
7
|
+
export async function generateCrudApplicationArtifacts(rootPath, options = {}) {
|
|
8
|
+
const project = compileProject({ ...options, rootPath });
|
|
9
|
+
const schemas = await loadLocalSchemaArrays(project);
|
|
10
|
+
const artifacts = await emitCrudApplicationArtifacts({ ...schemas, serviceTag: project.serviceTag });
|
|
11
|
+
const files = await commitArtifacts(buildGenerationPlan(project, artifacts, {
|
|
12
|
+
managedPaths: crudApplicationManagedPaths(),
|
|
13
|
+
managedScope: 'crud-application'
|
|
14
|
+
}));
|
|
15
|
+
return { project, files };
|
|
16
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { buildGenerationPlan } from '../../plan/buildGenerationPlan.js';
|
|
2
|
+
import { commitArtifacts } from '../../output/commitArtifacts.js';
|
|
3
|
+
import { compileProject } from '../../compile/compileProject.js';
|
|
4
|
+
import {
|
|
5
|
+
dynamicCrudFlowSchemaPaths,
|
|
6
|
+
emitDynamicCrudFlowSchemas
|
|
7
|
+
} from './emitDynamicCrudFlowSchemas.js';
|
|
8
|
+
import { loadLocalSchemaArrays } from './loadLocalSchemaArrays.js';
|
|
9
|
+
|
|
10
|
+
export async function generateDynamicCrudFlowSchemas(rootPath, options = {}) {
|
|
11
|
+
const project = compileProject({ ...options, rootPath });
|
|
12
|
+
const schemaInputs = await loadLocalSchemaArrays(project);
|
|
13
|
+
const plan = buildGenerationPlan(
|
|
14
|
+
project,
|
|
15
|
+
emitDynamicCrudFlowSchemas(schemaInputs),
|
|
16
|
+
{ managedPaths: dynamicCrudFlowSchemaPaths, managedScope: 'crud-flow-schemas' }
|
|
17
|
+
);
|
|
18
|
+
const files = await commitArtifacts(plan);
|
|
19
|
+
|
|
20
|
+
return { project, files };
|
|
21
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { loadLocalSchemaDirectory } from '../../compile/loadSchemas.js';
|
|
2
|
+
|
|
3
|
+
export async function loadLocalSchemaArrays(project) {
|
|
4
|
+
return {
|
|
5
|
+
objects: await loadLocalSchemaDirectory(project, 'ObjectSchemas'),
|
|
6
|
+
flows: await loadLocalSchemaDirectory(project, 'FlowSchemas')
|
|
7
|
+
};
|
|
8
|
+
}
|
|
@@ -63,7 +63,7 @@ export async function <%- flowTag %>MainLogical(
|
|
|
63
63
|
beforeLogicalResults = {}
|
|
64
64
|
) {
|
|
65
65
|
try {
|
|
66
|
-
_izContext.logger.debug('
|
|
66
|
+
_izContext.logger.debug('[<%- flowTag %>MainLogical] started', {
|
|
67
67
|
requestParams,
|
|
68
68
|
callingFlowConfig,
|
|
69
69
|
beforeLogicalResults
|
|
@@ -406,7 +406,7 @@ export default async function <%- flowTag %>(
|
|
|
406
406
|
//(</additionalParams>)
|
|
407
407
|
) {
|
|
408
408
|
try {
|
|
409
|
-
_izContext.logger.debug('createMain:', { requestParams, callingFlowConfig });
|
|
409
|
+
_izContext.logger.debug('[<%- flowTag %>] createMain:', { requestParams, callingFlowConfig });
|
|
410
410
|
|
|
411
411
|
const errorsFound = [];
|
|
412
412
|
const objType = createObjType(requestParams.objectType);
|
|
@@ -606,13 +606,13 @@ export default async function <%- flowTag %>(
|
|
|
606
606
|
}
|
|
607
607
|
<%_ } _%>
|
|
608
608
|
|
|
609
|
-
await asyncFlowSharedLib.
|
|
609
|
+
await asyncFlowSharedLib.createAwaitingMultipleSteps(
|
|
610
610
|
_izContext,
|
|
611
|
-
awaitingMultipleStepIds,
|
|
612
611
|
asyncFlowSharedLib.createPendingStepId(
|
|
613
612
|
_izContext.uniqueRequestId,
|
|
614
613
|
'beforeLogical_<%= objectType %>'
|
|
615
|
-
)
|
|
614
|
+
),
|
|
615
|
+
awaitingMultipleStepIds
|
|
616
616
|
);
|
|
617
617
|
|
|
618
618
|
//(<beforePublish_<%= objectType %>>)
|
|
@@ -670,4 +670,4 @@ export default async function <%- flowTag %>(
|
|
|
670
670
|
} catch (err) {
|
|
671
671
|
throw err;
|
|
672
672
|
}
|
|
673
|
-
}
|
|
673
|
+
}
|
|
@@ -53,7 +53,7 @@ export async function <%- flowTag %>MainLogical(
|
|
|
53
53
|
beforeLogicalResults = {}
|
|
54
54
|
) {
|
|
55
55
|
try {
|
|
56
|
-
_izContext.logger.debug('
|
|
56
|
+
_izContext.logger.debug('[<%- flowTag %>MainLogical] started', { requestParams, callingFlowConfig, beforeLogicalResults });
|
|
57
57
|
|
|
58
58
|
//(<beforeDeleteMainLogical>)
|
|
59
59
|
//(</beforeDeleteMainLogical>)
|
|
@@ -157,7 +157,7 @@ export default async function <%- flowTag %>(
|
|
|
157
157
|
//(</additionalParams>)
|
|
158
158
|
) {
|
|
159
159
|
try {
|
|
160
|
-
_izContext.logger.debug('
|
|
160
|
+
_izContext.logger.debug('[<%- flowTag %>]', { requestParams, callingFlowConfig });
|
|
161
161
|
|
|
162
162
|
const errorsFound = [];
|
|
163
163
|
const objType = createObjType(requestParams.objectType);
|
|
@@ -281,13 +281,13 @@ export default async function <%- flowTag %>(
|
|
|
281
281
|
}
|
|
282
282
|
<%_ } _%>
|
|
283
283
|
|
|
284
|
-
await asyncFlowSharedLib.
|
|
284
|
+
await asyncFlowSharedLib.createAwaitingMultipleSteps(
|
|
285
285
|
_izContext,
|
|
286
|
-
awaitingMultipleStepIds,
|
|
287
286
|
asyncFlowSharedLib.createPendingStepId(
|
|
288
287
|
hash(identifiers),
|
|
289
288
|
'beforeLogical_<%= objectType %>'
|
|
290
|
-
)
|
|
289
|
+
),
|
|
290
|
+
awaitingMultipleStepIds
|
|
291
291
|
);
|
|
292
292
|
|
|
293
293
|
//(<beforePublish_<%= objectType %>>)
|
|
@@ -346,4 +346,4 @@ export default async function <%- flowTag %>(
|
|
|
346
346
|
} catch (err) {
|
|
347
347
|
throw err;
|
|
348
348
|
}
|
|
349
|
-
}
|
|
349
|
+
}
|
|
@@ -67,7 +67,7 @@ export default async function <%- flowTag %>BeforeLogicalMain(
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
_izContext.logger.debug('identifiers:::: ', identifiers);
|
|
70
|
-
|
|
70
|
+
|
|
71
71
|
// build parentFlowId
|
|
72
72
|
<%_ if (flowTag === 'Create') { _%>
|
|
73
73
|
const parentFlowId = identifierUuid();
|
|
@@ -155,4 +155,4 @@ export default async function <%- flowTag %>BeforeLogicalMain(
|
|
|
155
155
|
} catch (err) {
|
|
156
156
|
throw err;
|
|
157
157
|
}
|
|
158
|
-
}
|
|
158
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-flow';
|
|
2
|
+
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
3
|
+
import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
|
|
4
|
+
import snsSharedLib from '@izara_project/izara-core-library-sns';
|
|
5
|
+
import { sns } from '@izara_project/izara-core-library-external-request';
|
|
6
|
+
import { consts } from '@izara_project/izara-core-library-service-schemas';
|
|
7
|
+
import { NoRetryError } from '@izara_project/izara-core-library-core';
|
|
8
|
+
|
|
9
|
+
const { TOPIC_NAME_GENERATE_CODE, PREFIX: _constPrefix } = consts;
|
|
10
|
+
<%_ if (action === 'Create') { _%>
|
|
11
|
+
const PREFIX = { ASYNC: _constPrefix.CREATE_OBJECT_ASYNC };
|
|
12
|
+
<%_ } else if (action === 'Update') { _%>
|
|
13
|
+
const PREFIX = { ASYNC: _constPrefix.updateNode };
|
|
14
|
+
<%_ } else { _%>
|
|
15
|
+
const PREFIX = { ASYNC: '<%- action %>AsyncEndpoint' };
|
|
16
|
+
<%_ } _%>
|
|
17
|
+
|
|
18
|
+
function empty(value) {
|
|
19
|
+
return value == null || (typeof value === 'object' && Object.keys(value).length === 0);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function validateInput(returnValue, status, graphServiceTag, errorsFound) {
|
|
23
|
+
if (!returnValue?.queryResult) errorsFound.push('message is not have property queryResult, should be not happen');
|
|
24
|
+
if (!returnValue?.requestParams?.objType) errorsFound.push('message is not have property objType, should be not happen');
|
|
25
|
+
if (!returnValue?.requestParams?.objInstanceFull) errorsFound.push('message is not have property objInstance, should be not objInstance');
|
|
26
|
+
if (status === 'error' && errorsFound.length === 0) errorsFound.push('[invalid]status is error not have errorsFound form graphService');
|
|
27
|
+
if (status === 'complete' && errorsFound.length > 0) errorsFound.push('[Invalid] status is complete should be not have errorsFound');
|
|
28
|
+
if (graphServiceTag == null) errorsFound.push('[Invalid] graphServerTag is not empty string');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default async function <%- action %>Complete(_izContext, requestParams, passBackProperties) {
|
|
32
|
+
try {
|
|
33
|
+
_izContext.logger.debug('[<%- action %>Complete] started', { requestParams });
|
|
34
|
+
const { returnValue, status, errorsFound = [], graphServiceTag, parentFlowId } = requestParams;
|
|
35
|
+
if (empty(returnValue?.requestParams)) throw new NoRetryError('message not an object');
|
|
36
|
+
validateInput(returnValue, status, graphServiceTag, errorsFound);
|
|
37
|
+
if (errorsFound.length > 0) errorsFound.push(errorsFound.join(','));
|
|
38
|
+
|
|
39
|
+
const awaitingStepId = await asyncFlowSharedLib.createAwaitingStepId(parentFlowId, PREFIX.ASYNC);
|
|
40
|
+
const pending = await asyncFlowSharedLib.findPendingStepAwaitingMultipleSteps(_izContext, awaitingStepId);
|
|
41
|
+
_izContext.logger.debug('[<%- action %>Complete] awaiting step', {
|
|
42
|
+
awaitingStepId,
|
|
43
|
+
pending
|
|
44
|
+
});
|
|
45
|
+
if (!pending) {
|
|
46
|
+
_izContext.logger.warn(`No pending step found for awaitingStepId: ${awaitingStepId}`);
|
|
47
|
+
return { returnValue, status, errorsFound };
|
|
48
|
+
}
|
|
49
|
+
const result = await asyncFlowSharedLib.checkAllAwaitingStepsFinishedWithReturnParams(
|
|
50
|
+
_izContext, pending.pendingStepId, awaitingStepId, errorsFound
|
|
51
|
+
);
|
|
52
|
+
_izContext.logger.debug('[<%- action %>Complete] all awaiting steps result', { isComplete: result.isComplete, awaitingStepId, pendingStepId: pending.pendingStepId });
|
|
53
|
+
|
|
54
|
+
if (result.isComplete) {
|
|
55
|
+
const nodeResultKey = `return<%- action %>dNode`;
|
|
56
|
+
const fallbackNodeResultKey = `return<%- action %>Node`;
|
|
57
|
+
const nodeResult = returnValue.queryResult[nodeResultKey] ?? returnValue.queryResult[fallbackNodeResultKey] ?? {};
|
|
58
|
+
const node = nodeResult[`<%- action.toLowerCase() %>NodeResult`] ?? nodeResult;
|
|
59
|
+
const existsNode = node.existsNode && Object.keys(node.existsNode).length
|
|
60
|
+
? { objType: returnValue.requestParams.objType, objInstanceFull: node.existsNode.objInstanceFull }
|
|
61
|
+
: null;
|
|
62
|
+
if (status === 'complete') {
|
|
63
|
+
await Promise.all((pending.listOfRecords ?? []).flatMap(records => Object.values(records).map(async record =>
|
|
64
|
+
dynamodbSharedLib.putItem(_izContext, await dynamodbSharedLib.tableName(_izContext, record.tableName, record.serviceTag), {
|
|
65
|
+
...record.objInstanceFull.identifiers,
|
|
66
|
+
...record.objInstanceFull.fields
|
|
67
|
+
})
|
|
68
|
+
)));
|
|
69
|
+
}
|
|
70
|
+
const message = callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(passBackProperties, {
|
|
71
|
+
objType: returnValue.requestParams.objType,
|
|
72
|
+
objInstanceFull: node.objInstanceFull,
|
|
73
|
+
relationships: node.relationships,
|
|
74
|
+
parentFlowId: returnValue.parentFlowId,
|
|
75
|
+
existsNode,
|
|
76
|
+
status,
|
|
77
|
+
errorsFound
|
|
78
|
+
});
|
|
79
|
+
const messageAttributes = callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(passBackProperties, {});
|
|
80
|
+
const topicArn = await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.out<%- action %>NodeComplete);
|
|
81
|
+
_izContext.logger.debug('[<%- action %>Complete] publishing to SNS', { TopicArn: topicArn, message });
|
|
82
|
+
await sns.publishAsync(_izContext, {
|
|
83
|
+
Message: JSON.stringify(message),
|
|
84
|
+
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
85
|
+
TopicArn: topicArn
|
|
86
|
+
});
|
|
87
|
+
//(<afterSendMessage>)
|
|
88
|
+
//(</afterSendMessage>)
|
|
89
|
+
}
|
|
90
|
+
await asyncFlowSharedLib.removeAwaitingMultipleStep(_izContext, awaitingStepId, pending.pendingStepId, errorsFound);
|
|
91
|
+
return { returnValue, status, errorsFound };
|
|
92
|
+
} catch (error) {
|
|
93
|
+
_izContext.logger.error('[<%- action %>Complete] error:', error);
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { middlewareHandler as middleware, response } from "@izara_project/izara-middleware";
|
|
2
|
+
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
3
|
+
|
|
4
|
+
import <%= functionName %> from './<%= mainFileName %>.js';
|
|
5
|
+
|
|
6
|
+
const validatorSchema = {
|
|
7
|
+
//(<validatorSchema>)
|
|
8
|
+
<% if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.properties && startConfig.properties.length > 0) { -%>
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
<% startConfig.properties.forEach(prop => { -%>
|
|
12
|
+
<%- prop.propertyName %>: { type: '<%- prop.type || 'string' %>' },
|
|
13
|
+
<% }) -%>
|
|
14
|
+
},
|
|
15
|
+
required: [ <%- startConfig.properties.filter(p => p.required !== false).map(p => `'${p.propertyName}'`).join(', ') %> ]
|
|
16
|
+
<% } -%>
|
|
17
|
+
//(</validatorSchema>)
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
middleware.setValidatorSchema(validatorSchema, { noAuthorizer: true });
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* GENERATED HANDLER: <%= flowStepName %> (Flow: <%= flowTag %>)
|
|
24
|
+
* Triggered by: API Gateway
|
|
25
|
+
*/
|
|
26
|
+
export const main = middleware.wrap(async (event, context) => {
|
|
27
|
+
event._izContext?.logger?.debug(`[${context.awsRequestId}] Received API request in <%= flowStepName %>`);
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
let objectType;
|
|
31
|
+
if (event.routeKey) {
|
|
32
|
+
const path = event.routeKey.split(' ')[1];
|
|
33
|
+
if (path) {
|
|
34
|
+
const segments = path.split('/');
|
|
35
|
+
const serviceName = process.env.iz_serviceName;
|
|
36
|
+
const serviceIndex = segments.indexOf(serviceName);
|
|
37
|
+
if (serviceIndex !== -1 && segments.length > serviceIndex + 1) {
|
|
38
|
+
objectType = segments[serviceIndex + 1];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (objectType) {
|
|
44
|
+
event.body = event.body || {};
|
|
45
|
+
event.body.objectType = objectType;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const passOnProperties = [
|
|
49
|
+
event.body,
|
|
50
|
+
//(<additionalParams>)
|
|
51
|
+
//(</additionalParams>)
|
|
52
|
+
callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
const lambdaFunctionResponse = await <%= functionName %>(
|
|
56
|
+
event._izContext,
|
|
57
|
+
...passOnProperties
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
if (lambdaFunctionResponse instanceof Error) {
|
|
61
|
+
return response.failure(lambdaFunctionResponse);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return response.success(lambdaFunctionResponse);
|
|
65
|
+
} catch (err) {
|
|
66
|
+
event._izContext?.logger?.error('Unhandled Error in <%= flowStepName %> API:', err);
|
|
67
|
+
return response.failure(err);
|
|
68
|
+
}
|
|
69
|
+
});
|