@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
package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/ProcessLogical_Main.ejs
DELETED
|
@@ -1,450 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
-
|
|
4
|
-
This program is free software: you can redistribute it and/or modify
|
|
5
|
-
it under the terms of the GNU Affero General Public License as
|
|
6
|
-
published by the Free Software Foundation, either version 3 of the
|
|
7
|
-
License, or (at your option) any later version.
|
|
8
|
-
|
|
9
|
-
This program is distributed in the hope that it will be useful,
|
|
10
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
GNU Affero General Public License for more details.
|
|
13
|
-
|
|
14
|
-
You should have received a copy of the GNU Affero General Public License
|
|
15
|
-
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
|
|
19
|
-
import snsSharedLib from '@izara_project/izara-core-library-sns';
|
|
20
|
-
import logicalResultsSharedLib from '@izara_project/izara-core-library-logical-result';
|
|
21
|
-
import searchResultSharedLib from '@izara_project/izara-core-library-search-result';
|
|
22
|
-
import { sns } from '@izara_project/izara-core-library-external-request';
|
|
23
|
-
|
|
24
|
-
import {
|
|
25
|
-
getObjectSchema,
|
|
26
|
-
serviceConfig,
|
|
27
|
-
consts,
|
|
28
|
-
utils
|
|
29
|
-
} from '@izara_project/izara-core-library-service-schemas';
|
|
30
|
-
import { NoRetryError } from '@izara_project/izara-core-library-core';
|
|
31
|
-
const { STORAGE_TYPES } = consts;
|
|
32
|
-
const { getUsedFieldNamesOfIdentifiers } = utils;
|
|
33
|
-
|
|
34
|
-
//(<additionalModule>)
|
|
35
|
-
import { identifiersObject as identifierObj } from '@izara_project/izara-core-library-service-schemas';
|
|
36
|
-
//(</additionalModule>)
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* performs the logical operation/filter/search in the element, saves into LogicalResultsData table
|
|
40
|
-
* @param {Object} _izContext
|
|
41
|
-
* @param {Object} objType - contain objectType and serviceTag
|
|
42
|
-
* @param {Object} element - logical element
|
|
43
|
-
* @param {Object} element.filterType - 'logical'
|
|
44
|
-
* @param {string} element.logicalType - contain 'identifier' | 'partitionKey' // 'identifier' is ##removed## so not use logicalType
|
|
45
|
-
* @param {Object} [element.partitionKeyValues] - value of fieldNames that is partitionKey.
|
|
46
|
-
* @param {Object} [element.sortKeyValues] - value of fieldNames that is sortKey. (optional)
|
|
47
|
-
* @param {string} [element.comparison] - use for query in queryElements.sortKeyCondition. (optional)
|
|
48
|
-
* @param {string} [element.conditionalFieldValues] - user after query for filter data before save to logicalData table. (optional)
|
|
49
|
-
* @param {boolean} overWriteCache
|
|
50
|
-
*
|
|
51
|
-
* @returns {string} description of return value
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
|
-
export default async function processLogical(
|
|
55
|
-
_izContext,
|
|
56
|
-
objType,
|
|
57
|
-
element,
|
|
58
|
-
overWriteCache,
|
|
59
|
-
callingFlow
|
|
60
|
-
) {
|
|
61
|
-
try {
|
|
62
|
-
_izContext.logger.debug('----- ProcessLogical event params -----', {
|
|
63
|
-
objType: objType,
|
|
64
|
-
element: element,
|
|
65
|
-
overWriteCache: overWriteCache,
|
|
66
|
-
callingFlow: callingFlow
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
let removeAttributes = ['paginateProcessLogicalUniqueRequestId'];
|
|
70
|
-
|
|
71
|
-
//(<removeAttributes>)
|
|
72
|
-
//(</removeAttributes>)
|
|
73
|
-
|
|
74
|
-
// Check/Create logicalResultsMain
|
|
75
|
-
let [logicalResultsMainStatus, logicalResultId, logicalResultMain] =
|
|
76
|
-
await logicalResultsSharedLib.checkLogicalMainStatus(
|
|
77
|
-
_izContext,
|
|
78
|
-
element, // for create logicalResultId
|
|
79
|
-
objType,
|
|
80
|
-
callingFlow,
|
|
81
|
-
removeAttributes,
|
|
82
|
-
overWriteCache
|
|
83
|
-
);
|
|
84
|
-
_izContext.logger.debug('After check logicalMainStatus: ', {
|
|
85
|
-
logicalResultsMainStatus: logicalResultsMainStatus,
|
|
86
|
-
logicalResultId: logicalResultId,
|
|
87
|
-
logicalResultMain: logicalResultMain
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
if (logicalResultsMainStatus !== 'process') {
|
|
91
|
-
_izContext.logger.debug(
|
|
92
|
-
`logicalResultsMainStatus status isn't process :${logicalResultsMainStatus}`
|
|
93
|
-
);
|
|
94
|
-
return {
|
|
95
|
-
returnResponse: 'logicalResultsMainStatus status is not process'
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
let errorsFound = [];
|
|
100
|
-
|
|
101
|
-
let standardErrorParams = [
|
|
102
|
-
_izContext,
|
|
103
|
-
logicalResultId,
|
|
104
|
-
logicalResultMain.logicalElement,
|
|
105
|
-
logicalResultMain.objType,
|
|
106
|
-
overWriteCache,
|
|
107
|
-
callingFlow,
|
|
108
|
-
'error'
|
|
109
|
-
];
|
|
110
|
-
|
|
111
|
-
if (
|
|
112
|
-
element.comparison &&
|
|
113
|
-
!searchResultSharedLib.consts.POSSIBLE_COMPARISON_SORTID.includes(
|
|
114
|
-
element.comparison
|
|
115
|
-
)
|
|
116
|
-
) {
|
|
117
|
-
errorsFound.push('comparison is not possible comparison');
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// validate partitionKeyValues
|
|
121
|
-
if (!element.hasOwnProperty('partitionKeyValues')) {
|
|
122
|
-
_izContext.logger.debug('element not have partitionKeyValues');
|
|
123
|
-
errorsFound.push('element not have partitionKeyValues');
|
|
124
|
-
} else if (Object.keys(element.partitionKeyValues).length === 0) {
|
|
125
|
-
_izContext.logger.debug('partitionKeyValues is empty');
|
|
126
|
-
errorsFound.push('partitionKeyValues is empty');
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const objectSchemas = await getObjectSchema.getObjSchemaS3WithHierarchy(
|
|
130
|
-
_izContext,
|
|
131
|
-
objType
|
|
132
|
-
);
|
|
133
|
-
_izContext.logger.debug('objectSchemas: ', objectSchemas);
|
|
134
|
-
|
|
135
|
-
let partitionKeyFieldName = null;
|
|
136
|
-
let tableName = null;
|
|
137
|
-
let sortKeyFieldName = null;
|
|
138
|
-
|
|
139
|
-
for (const schemasIdentifier of objectSchemas.identifiers) {
|
|
140
|
-
if (schemasIdentifier.type === 'partitionKey') {
|
|
141
|
-
if (partitionKeyFieldName === null) {
|
|
142
|
-
if (schemasIdentifier.hasOwnProperty('fieldName')) {
|
|
143
|
-
partitionKeyFieldName = schemasIdentifier.fieldName;
|
|
144
|
-
} else {
|
|
145
|
-
partitionKeyFieldName = schemasIdentifier.name;
|
|
146
|
-
}
|
|
147
|
-
} else {
|
|
148
|
-
throw new NoRetryError(
|
|
149
|
-
'Invalid object schemas have more than one partitionKey'
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (schemasIdentifier.type === 'sortKey') {
|
|
155
|
-
if (sortKeyFieldName === null) {
|
|
156
|
-
if (schemasIdentifier.hasOwnProperty('fieldName')) {
|
|
157
|
-
sortKeyFieldName = schemasIdentifier.fieldName;
|
|
158
|
-
} else {
|
|
159
|
-
sortKeyFieldName = schemasIdentifier.name;
|
|
160
|
-
}
|
|
161
|
-
} else {
|
|
162
|
-
throw new NoRetryError(
|
|
163
|
-
'Invalid object schemas have more than one sortKey'
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
_izContext.logger.debug('have sortKeyFieldName: ', sortKeyFieldName);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const storageResources = objectSchemas.storageResources;
|
|
171
|
-
|
|
172
|
-
storageResourcesLoop: for (const storageResourceTag of Object.keys(
|
|
173
|
-
storageResources
|
|
174
|
-
)) {
|
|
175
|
-
_izContext.logger.debug('check storageResourceTag: ', storageResourceTag);
|
|
176
|
-
|
|
177
|
-
if (
|
|
178
|
-
storageResources[storageResourceTag].storageType ===
|
|
179
|
-
STORAGE_TYPES.dynamoDB
|
|
180
|
-
) {
|
|
181
|
-
if (
|
|
182
|
-
storageResources[storageResourceTag].hasOwnProperty(
|
|
183
|
-
'groupByPartitionKeyField'
|
|
184
|
-
)
|
|
185
|
-
) {
|
|
186
|
-
if (element.hasOwnProperty('sortKeyValues')) {
|
|
187
|
-
// atleast 1 storageResourceTag is not set groupByPartitionKeyField
|
|
188
|
-
continue;
|
|
189
|
-
} else {
|
|
190
|
-
errorsFound.push(
|
|
191
|
-
'schema error: dynamo storageResource set to groupByPartitionKeyField but no sortKey'
|
|
192
|
-
);
|
|
193
|
-
break;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// validate conditionalFieldValues
|
|
198
|
-
if (
|
|
199
|
-
element.hasOwnProperty('conditionalFieldValues') &&
|
|
200
|
-
element.conditionalFieldValues.length > 0
|
|
201
|
-
) {
|
|
202
|
-
conditionalFieldValuesLoop: for (const conditionalFieldValue of element.conditionalFieldValues) {
|
|
203
|
-
let conditionalFieldName = conditionalFieldValue.fieldName;
|
|
204
|
-
let storageResourceTagsFieldName =
|
|
205
|
-
objectSchemas.fieldNames[conditionalFieldName]
|
|
206
|
-
.storageResourceTags;
|
|
207
|
-
|
|
208
|
-
if (storageResourceTagsFieldName.includes(storageResourceTag)) {
|
|
209
|
-
continue conditionalFieldValuesLoop;
|
|
210
|
-
} else {
|
|
211
|
-
continue storageResourcesLoop;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
tableName = storageResources[storageResourceTag].tableName;
|
|
217
|
-
_izContext.logger.debug('found tableName: ', tableName);
|
|
218
|
-
break;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
if (!tableName) {
|
|
223
|
-
errorsFound.push('no valid dynamo storageResource found');
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
if (
|
|
227
|
-
element.hasOwnProperty('sortKeyValues') &&
|
|
228
|
-
Object.keys(element.sortKeyValues).length > 0 &&
|
|
229
|
-
!sortKeyFieldName
|
|
230
|
-
) {
|
|
231
|
-
_izContext.logger.debug(
|
|
232
|
-
'element have sortKeyValues but cannot find sortKey in object schemas'
|
|
233
|
-
);
|
|
234
|
-
errorsFound.push(
|
|
235
|
-
'element have sortKeyValues but cannot find sortKey in object schemas'
|
|
236
|
-
);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
if (errorsFound.length > 0) {
|
|
240
|
-
_izContext.logger.debug('Have errorsFound: ', errorsFound);
|
|
241
|
-
standardErrorParams.push(errorsFound);
|
|
242
|
-
await logicalResultsSharedLib.completeLogicalResultsMain(
|
|
243
|
-
...standardErrorParams
|
|
244
|
-
);
|
|
245
|
-
return {
|
|
246
|
-
returnResponse: 'Have errorsFound'
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// concatenate partitionKey
|
|
251
|
-
let partitionKeyReqIdentifiers = {};
|
|
252
|
-
for (const [fieldName, fieldNameValue] of Object.entries(
|
|
253
|
-
element.partitionKeyValues
|
|
254
|
-
)) {
|
|
255
|
-
partitionKeyReqIdentifiers[fieldName] = fieldNameValue.value;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// concatenate sortKey
|
|
259
|
-
if (element.hasOwnProperty('sortKeyValues')) {
|
|
260
|
-
for (const [fieldName, fieldNameValue] of Object.entries(
|
|
261
|
-
element.sortKeyValues
|
|
262
|
-
)) {
|
|
263
|
-
partitionKeyReqIdentifiers[fieldName] = fieldNameValue.value;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
_izContext.logger.debug(
|
|
267
|
-
'partitionKeyReqIdentifiers: ',
|
|
268
|
-
partitionKeyReqIdentifiers
|
|
269
|
-
);
|
|
270
|
-
|
|
271
|
-
let dynamoDbIdentifiers =
|
|
272
|
-
await identifierObj.dynamoDbIdentifiersByStorageResource(
|
|
273
|
-
_izContext,
|
|
274
|
-
objectSchemas,
|
|
275
|
-
storageResources,
|
|
276
|
-
partitionKeyReqIdentifiers
|
|
277
|
-
);
|
|
278
|
-
_izContext.logger.debug('dynamoDbIdentifiers: ', dynamoDbIdentifiers);
|
|
279
|
-
|
|
280
|
-
if (element.hasOwnProperty('sortKeyValues')) {
|
|
281
|
-
let comparison = 'equals';
|
|
282
|
-
if (element.comparison && element.comparison !== 'equals') {
|
|
283
|
-
comparison = element.comparison;
|
|
284
|
-
let sentMessageToPaginateProcessLogical = {
|
|
285
|
-
Message: JSON.stringify({
|
|
286
|
-
logicalResultId: logicalResultId,
|
|
287
|
-
tableName: tableName,
|
|
288
|
-
partitionKeyFieldName: partitionKeyFieldName,
|
|
289
|
-
sortKeyFieldName: sortKeyFieldName,
|
|
290
|
-
dynamoDbIdentifiers: dynamoDbIdentifiers,
|
|
291
|
-
comparison: comparison,
|
|
292
|
-
overWriteCache: overWriteCache,
|
|
293
|
-
callingFlow: callingFlow
|
|
294
|
-
}),
|
|
295
|
-
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(
|
|
296
|
-
_izContext,
|
|
297
|
-
'PaginateProcessLogical_In'
|
|
298
|
-
)
|
|
299
|
-
};
|
|
300
|
-
_izContext.logger.debug(
|
|
301
|
-
'Request params before send to topic PaginateProcessLogical_In: ',
|
|
302
|
-
sentMessageToPaginateProcessLogical
|
|
303
|
-
);
|
|
304
|
-
|
|
305
|
-
let resSNS = await sns.publishAsync(
|
|
306
|
-
_izContext,
|
|
307
|
-
sentMessageToPaginateProcessLogical
|
|
308
|
-
);
|
|
309
|
-
_izContext.logger.debug(
|
|
310
|
-
'resSNS send to topic ProcessSortResult finish!',
|
|
311
|
-
resSNS
|
|
312
|
-
);
|
|
313
|
-
|
|
314
|
-
return {
|
|
315
|
-
returnResponse: 'Send message to PaginateProcessLogical_In'
|
|
316
|
-
};
|
|
317
|
-
} else {
|
|
318
|
-
let queryDatas = await dynamodbSharedLib.query(
|
|
319
|
-
_izContext,
|
|
320
|
-
dynamodbSharedLib.tableName(_izContext, tableName),
|
|
321
|
-
{
|
|
322
|
-
[partitionKeyFieldName]: dynamoDbIdentifiers[partitionKeyFieldName]
|
|
323
|
-
},
|
|
324
|
-
{
|
|
325
|
-
sortKeyCondition: {
|
|
326
|
-
comparison: comparison,
|
|
327
|
-
name: sortKeyFieldName,
|
|
328
|
-
value: dynamoDbIdentifiers[sortKeyFieldName]
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
);
|
|
332
|
-
_izContext.logger.debug('queryDatas result: ', queryDatas);
|
|
333
|
-
|
|
334
|
-
if (queryDatas.Items.length == 0) {
|
|
335
|
-
_izContext.logger.debug(`can't find data in ${tableName}`);
|
|
336
|
-
errorsFound.push(`can't find data in ${tableName}`);
|
|
337
|
-
standardErrorParams.push(errorsFound);
|
|
338
|
-
await logicalResultsSharedLib.completeLogicalResultsMain(
|
|
339
|
-
...standardErrorParams
|
|
340
|
-
);
|
|
341
|
-
return {
|
|
342
|
-
returnResponse: 'Cannot find data in table'
|
|
343
|
-
};
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
for (const objInstanceBase of queryDatas.Items) {
|
|
347
|
-
await logicalResultsSharedLib.saveLogicalData(
|
|
348
|
-
_izContext,
|
|
349
|
-
logicalResultId,
|
|
350
|
-
logicalResultMain.objType,
|
|
351
|
-
objInstanceBase
|
|
352
|
-
);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
} else {
|
|
356
|
-
// element don't have sortKey
|
|
357
|
-
|
|
358
|
-
if (sortKeyFieldName) {
|
|
359
|
-
_izContext.logger.debug(
|
|
360
|
-
'identifiers have sortKey: query dynamo in PaginateProcessLogical'
|
|
361
|
-
);
|
|
362
|
-
|
|
363
|
-
let sentMessageToPaginateProcessLogical = {
|
|
364
|
-
Message: JSON.stringify({
|
|
365
|
-
logicalResultId: logicalResultId,
|
|
366
|
-
tableName: tableName,
|
|
367
|
-
partitionKeyFieldName: partitionKeyFieldName,
|
|
368
|
-
sortKeyFieldName: sortKeyFieldName,
|
|
369
|
-
dynamoDbIdentifiers: dynamoDbIdentifiers,
|
|
370
|
-
overWriteCache: overWriteCache,
|
|
371
|
-
callingFlow: callingFlow
|
|
372
|
-
}),
|
|
373
|
-
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(
|
|
374
|
-
_izContext,
|
|
375
|
-
'PaginateProcessLogical_In'
|
|
376
|
-
)
|
|
377
|
-
};
|
|
378
|
-
_izContext.logger.debug(
|
|
379
|
-
'Request params before send to topic PaginateProcessLogical_In: ',
|
|
380
|
-
sentMessageToPaginateProcessLogical
|
|
381
|
-
);
|
|
382
|
-
|
|
383
|
-
let resSNS = await sns.publishAsync(
|
|
384
|
-
_izContext,
|
|
385
|
-
sentMessageToPaginateProcessLogical
|
|
386
|
-
);
|
|
387
|
-
_izContext.logger.debug(
|
|
388
|
-
'resSNS send to topic ProcessSortResult finish!',
|
|
389
|
-
resSNS
|
|
390
|
-
);
|
|
391
|
-
|
|
392
|
-
return {
|
|
393
|
-
returnResponse: 'Send message to PaginateProcessLogical_In'
|
|
394
|
-
};
|
|
395
|
-
} else {
|
|
396
|
-
_izContext.logger.debug('identifiers not have sortKey: save dataId');
|
|
397
|
-
|
|
398
|
-
let getDataByPartitionKey = await dynamodbSharedLib.getItem(
|
|
399
|
-
_izContext,
|
|
400
|
-
dynamodbSharedLib.tableName(_izContext, tableName),
|
|
401
|
-
{
|
|
402
|
-
[partitionKeyFieldName]: dynamoDbIdentifiers[partitionKeyFieldName]
|
|
403
|
-
}
|
|
404
|
-
);
|
|
405
|
-
|
|
406
|
-
if (getDataByPartitionKey) {
|
|
407
|
-
await logicalResultsSharedLib.saveLogicalData(
|
|
408
|
-
_izContext,
|
|
409
|
-
logicalResultId,
|
|
410
|
-
objType,
|
|
411
|
-
getDataByPartitionKey
|
|
412
|
-
);
|
|
413
|
-
} else {
|
|
414
|
-
// throw error or set errorsFound
|
|
415
|
-
_izContext.logger.debug(`can't find data in ${tableName}`);
|
|
416
|
-
errorsFound.push(`can't find data in ${tableName}`);
|
|
417
|
-
standardErrorParams.push(errorsFound);
|
|
418
|
-
await logicalResultsSharedLib.completeLogicalResultsMain(
|
|
419
|
-
...standardErrorParams
|
|
420
|
-
);
|
|
421
|
-
return {
|
|
422
|
-
returnResponse: 'Cannot find data in table'
|
|
423
|
-
};
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
// complete processLogical and send message Out
|
|
429
|
-
await logicalResultsSharedLib.completeLogicalResultsMain(
|
|
430
|
-
_izContext,
|
|
431
|
-
logicalResultId,
|
|
432
|
-
element,
|
|
433
|
-
objType,
|
|
434
|
-
overWriteCache,
|
|
435
|
-
callingFlow,
|
|
436
|
-
'complete',
|
|
437
|
-
[]
|
|
438
|
-
);
|
|
439
|
-
|
|
440
|
-
//(<additionalProcessLogical>)
|
|
441
|
-
//(</additionalProcessLogical>)
|
|
442
|
-
|
|
443
|
-
return {
|
|
444
|
-
returnResponse: 'Function ProcessLogical is Finished'
|
|
445
|
-
};
|
|
446
|
-
} catch (err) {
|
|
447
|
-
_izContext.logger.error('error ProcessLogicalMain: ', err);
|
|
448
|
-
throw err;
|
|
449
|
-
}
|
|
450
|
-
}
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { fileURLToPath } from 'url';
|
|
3
|
-
import {
|
|
4
|
-
appendRenderedTemplate,
|
|
5
|
-
writeRenderedTemplate
|
|
6
|
-
} from '../../../../../core/renderTemplateFile.js';
|
|
7
|
-
|
|
8
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
-
const __dirname = path.dirname(__filename);
|
|
10
|
-
|
|
11
|
-
function upperCase(str) {
|
|
12
|
-
if (!str) return str;
|
|
13
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function shortNameHandler(handlerType) {
|
|
17
|
-
return handlerType;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export async function generateRegisterFlow(allLocalFlowSchemas, _appPath, outputBaseDir) {
|
|
21
|
-
if (!allLocalFlowSchemas.some((flow) => flow.flowTag === 'Register')) {
|
|
22
|
-
console.log(' [RegisterGenerator] No Register flow descriptor found. Skipping.');
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
console.log(' [RegisterGenerator] Generating Register flow files...');
|
|
27
|
-
|
|
28
|
-
const templatesDir = path.join(__dirname, 'templates', 'register');
|
|
29
|
-
const wsTemplatesDir = path.join(__dirname, '..', 'Flow', 'FlowSchemas', 'templates', 'webSocket');
|
|
30
|
-
const registerDir = path.join(
|
|
31
|
-
outputBaseDir,
|
|
32
|
-
'app',
|
|
33
|
-
'src',
|
|
34
|
-
'generatedCode',
|
|
35
|
-
'SystemFlowSchemas',
|
|
36
|
-
'Register',
|
|
37
|
-
'source'
|
|
38
|
-
);
|
|
39
|
-
const flowSchemaPath = path.join(
|
|
40
|
-
outputBaseDir,
|
|
41
|
-
'app',
|
|
42
|
-
'sls_yaml',
|
|
43
|
-
'generatedCode',
|
|
44
|
-
'source',
|
|
45
|
-
'flow-schema.yml'
|
|
46
|
-
);
|
|
47
|
-
const resourceYamlPath = path.join(
|
|
48
|
-
outputBaseDir,
|
|
49
|
-
'resource',
|
|
50
|
-
'sls_yaml',
|
|
51
|
-
'generatedCode',
|
|
52
|
-
'source',
|
|
53
|
-
'generated-sns-in-sqs.yml'
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
const wbsFunctionName = 'Register';
|
|
57
|
-
await writeRenderedTemplate(
|
|
58
|
-
path.join(templatesDir, 'Register_Main.ejs'),
|
|
59
|
-
path.join(registerDir, `${wbsFunctionName}_Main.js`),
|
|
60
|
-
{ functionMain: `${wbsFunctionName}_Main` }
|
|
61
|
-
);
|
|
62
|
-
await writeRenderedTemplate(
|
|
63
|
-
path.join(templatesDir, 'Register_HdrWbs.ejs'),
|
|
64
|
-
path.join(registerDir, `${wbsFunctionName}_HdrWbs.js`),
|
|
65
|
-
{ routeName: 'register' }
|
|
66
|
-
);
|
|
67
|
-
await appendRenderedTemplate(
|
|
68
|
-
path.join(__dirname, '..', '..', '..', 'sls_yaml', 'templates', 'FunctionYaml_Wbs.ejs'),
|
|
69
|
-
flowSchemaPath,
|
|
70
|
-
{
|
|
71
|
-
functionNameConfig: `${wbsFunctionName}Wbs`,
|
|
72
|
-
handlerPath: `src/generatedCode/SystemFlowSchemas/Register/source/${wbsFunctionName}_HdrWbs.main`,
|
|
73
|
-
roleName: 'RegisterRole',
|
|
74
|
-
routeName: 'register'
|
|
75
|
-
}
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
const completeFunctionName = 'RegisterComplete';
|
|
79
|
-
const completeData = {
|
|
80
|
-
functionName: completeFunctionName,
|
|
81
|
-
handlerType: 'HdrSqs',
|
|
82
|
-
queueName: completeFunctionName,
|
|
83
|
-
handlerFilePath: `src/generatedCode/SystemFlowSchemas/Register/source/${completeFunctionName}_HdrSqs`,
|
|
84
|
-
roleName: 'RegisterComplete',
|
|
85
|
-
upperFunctionName: upperCase(completeFunctionName),
|
|
86
|
-
upperHandlerType: 'HDRSQS',
|
|
87
|
-
upperQueueName: upperCase(completeFunctionName),
|
|
88
|
-
functionNameConfig: `${upperCase(completeFunctionName)}${upperCase(shortNameHandler('HdrSqs'))}`
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
await writeRenderedTemplate(
|
|
92
|
-
path.join(templatesDir, 'RegisterComplete_Main.ejs'),
|
|
93
|
-
path.join(registerDir, `${completeFunctionName}_Main.js`),
|
|
94
|
-
completeData
|
|
95
|
-
);
|
|
96
|
-
await writeRenderedTemplate(
|
|
97
|
-
path.join(templatesDir, 'RegisterComplete_HdrSqs.ejs'),
|
|
98
|
-
path.join(registerDir, `${completeFunctionName}_HdrSqs.js`),
|
|
99
|
-
completeData
|
|
100
|
-
);
|
|
101
|
-
await writeRenderedTemplate(
|
|
102
|
-
path.join(templatesDir, 'RegisterComplete_HdrSqs.ejs'),
|
|
103
|
-
path.join(registerDir, `${completeFunctionName}_HdrDsq.js`),
|
|
104
|
-
{ ...completeData, handlerType: 'HdrDsq' }
|
|
105
|
-
);
|
|
106
|
-
await appendRenderedTemplate(
|
|
107
|
-
path.join(wsTemplatesDir, 'ProcessWebSocketFlow_Yaml.ejs'),
|
|
108
|
-
flowSchemaPath,
|
|
109
|
-
completeData
|
|
110
|
-
);
|
|
111
|
-
await appendRenderedTemplate(
|
|
112
|
-
path.join(wsTemplatesDir, 'ProcessWebSocketFlow_Yaml.ejs'),
|
|
113
|
-
flowSchemaPath,
|
|
114
|
-
{
|
|
115
|
-
...completeData,
|
|
116
|
-
handlerType: 'HdrDsq',
|
|
117
|
-
upperHandlerType: 'HDRDSQ',
|
|
118
|
-
functionNameConfig: `${upperCase(completeFunctionName)}Dsq`,
|
|
119
|
-
handlerFilePath: `src/generatedCode/SystemFlowSchemas/Register/source/${completeFunctionName}_HdrDsq`
|
|
120
|
-
}
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
await appendRenderedTemplate(
|
|
124
|
-
path.join(wsTemplatesDir, 'ProcessWebSocket_Yaml.ejs'),
|
|
125
|
-
resourceYamlPath,
|
|
126
|
-
completeData
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
const processedTopics = new Set();
|
|
130
|
-
for (const flowSchema of allLocalFlowSchemas) {
|
|
131
|
-
if (!flowSchema.outputTopic) continue;
|
|
132
|
-
|
|
133
|
-
const topicOut = upperCase(flowSchema.flowTag);
|
|
134
|
-
if (processedTopics.has(topicOut)) continue;
|
|
135
|
-
processedTopics.add(topicOut);
|
|
136
|
-
|
|
137
|
-
await appendRenderedTemplate(
|
|
138
|
-
path.join(wsTemplatesDir, 'ProcessWebSocketSub_Yaml.ejs'),
|
|
139
|
-
resourceYamlPath,
|
|
140
|
-
{
|
|
141
|
-
subscribeTo: topicOut,
|
|
142
|
-
queueName: completeFunctionName,
|
|
143
|
-
upperQueueName: upperCase(completeFunctionName)
|
|
144
|
-
}
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
console.log(' [RegisterGenerator] Finished generating Register flow files.');
|
|
149
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
-
|
|
4
|
-
This program is free software: you can redistribute it and/or modify
|
|
5
|
-
it under the terms of the GNU Affero General Public License as
|
|
6
|
-
published by the Free Software Foundation, either version 3 of the
|
|
7
|
-
License, or (at your option) any later version.
|
|
8
|
-
|
|
9
|
-
This program is distributed in the hope that it will be useful,
|
|
10
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
GNU Affero General Public License for more details.
|
|
13
|
-
|
|
14
|
-
You should have received a copy of the GNU Affero General Public License
|
|
15
|
-
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
import { middlewareHandler } from "@izara_project/izara-middleware";
|
|
21
|
-
import Logger from '@izara_project/izara-core-library-logger';
|
|
22
|
-
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
23
|
-
import { recordHandlerSharedLib } from "@izara_project/izara-core-library-record-handler";
|
|
24
|
-
|
|
25
|
-
import <%- functionName %> from './<%- upperFunctionName %>_Main.js';
|
|
26
|
-
|
|
27
|
-
// validate event properties in body.Message of sqs event
|
|
28
|
-
middlewareHandler.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
|
|
29
|
-
let perRecordsValidatorSchema = {}
|
|
30
|
-
export const main = middlewareHandler.wrap(async (event, context) => {
|
|
31
|
-
|
|
32
|
-
try {
|
|
33
|
-
|
|
34
|
-
let recordPromises = [];
|
|
35
|
-
|
|
36
|
-
// loop each record and send to mainFunction
|
|
37
|
-
await Promise.all(event.Records.map(async record => { // promise.all for map() function
|
|
38
|
-
|
|
39
|
-
let passOnProperties = []
|
|
40
|
-
record._izContext.logger.debug('record ReceiveMsgOutHdrSqs', record);
|
|
41
|
-
|
|
42
|
-
//validate message (and MessageAttributes)
|
|
43
|
-
await recordHandlerSharedLib.validateRecord(
|
|
44
|
-
record, // one record will send to mainFunction
|
|
45
|
-
"<%- queueName %>", // queue name that need to retry or send to dlq
|
|
46
|
-
perRecordsValidatorSchema, // schema for record.Message
|
|
47
|
-
// messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
// add argument (to invoke lambda) to passOnProperties[]
|
|
51
|
-
passOnProperties.push(record.body.TopicArn)
|
|
52
|
-
passOnProperties.push(record.body.Message)
|
|
53
|
-
//(<additionalParams>)
|
|
54
|
-
//(</additionalParams>)
|
|
55
|
-
passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
|
|
56
|
-
record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
|
|
57
|
-
|
|
58
|
-
// call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
|
|
59
|
-
let recordPromise = recordHandlerSharedLib.recordHandler(
|
|
60
|
-
record, // one record will send to mainFunction
|
|
61
|
-
<%- functionName %>Main, // mainFunction that need to invoke.
|
|
62
|
-
'<%- queueName %>', // queue name that need to retry or send to dlq
|
|
63
|
-
passOnProperties, // all parameters that mainFunction needed.
|
|
64
|
-
);
|
|
65
|
-
record._izContext.logger.debug('after recordPromise in handler');
|
|
66
|
-
recordPromises.push(recordPromise); // push promise to recordPromises
|
|
67
|
-
}))
|
|
68
|
-
|
|
69
|
-
Logger.debug('before Promise.all(recordPromises) in handler');
|
|
70
|
-
try {
|
|
71
|
-
// --- main await all promises
|
|
72
|
-
await Promise.all(recordPromises); // await all promises
|
|
73
|
-
|
|
74
|
-
return event.Records // return all for local testing
|
|
75
|
-
|
|
76
|
-
} catch {
|
|
77
|
-
Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did no resolve');
|
|
78
|
-
}
|
|
79
|
-
Logger.debug('after Promise.all(recordPromises) in handler');
|
|
80
|
-
|
|
81
|
-
} catch (err) {
|
|
82
|
-
Logger.error('Unhandled Error, <%- functionName%>: ', err);
|
|
83
|
-
throw (err);
|
|
84
|
-
}
|
|
85
|
-
});
|