@izara_project/izara-core-generate-service-code 1.0.2 → 1.0.4
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/index.js +0 -2
- package/package.json +3 -3
- package/src/GenerateCode.js +5 -4
- package/src/GenerateResources.js +4 -3
- package/src/GenerateTests.js +6 -7
- package/src/TemplateConfig.js +18 -18
- package/src/TemplateData/EndpointPerService/generateTemplateData.js +1 -1
- package/src/TemplateData/EndpointPerService/mainFunction/create/template.ejs +37 -39
- package/src/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +7 -12
- package/src/TemplateData/EndpointPerService/mainFunction/get/template.ejs +7 -10
- package/src/TemplateData/EndpointPerService/mainFunction/update/template.ejs +24 -31
- package/src/TemplateData/IntTest/generateResources/generateResources.js +4 -3
- package/src/TemplateData/IntTest/generateTests/events/data.js +3 -1
- package/src/TemplateData/IntTest/generateTests/generateTemplate.js +4 -2
- package/src/TemplateData/IntTest/generateTests/pathIntTest/data.js +2 -2
- package/src/TemplateData/IntTest/generateTests/tests/data.js +9 -8
- package/src/TemplateData/IntTest/libs/libs.js +4 -35
- package/src/TemplateData/IntTest/upload/uploadIntTest.js +4 -3
- package/src/TemplateData/externalService/lambdaRole/template.ejs +1 -3
- package/src/TemplateData/externalService/snsTopicSubscriptions/template.ejs +0 -2
- package/src/TemplateData/findData/findDataYaml/data.js +2 -1
- package/src/TemplateData/findData/mainFunction/data.js +1 -1
- package/src/TemplateData/flowSchema/CreateRecordComplete/functionYaml/data.js +9 -5
- package/src/TemplateData/flowSchema/CreateRecordComplete/handler/data.js +3 -3
- package/src/TemplateData/flowSchema/CreateRecordComplete/mainFunction/data.js +3 -3
- package/src/TemplateData/flowSchema/CreateRecordComplete/queue/data.js +3 -3
- package/src/TemplateData/flowSchema/components/upload/confirmReserved/functionYaml/data.js +11 -8
- package/src/TemplateData/flowSchema/components/upload/confirmReserved/handler/data.js +3 -3
- package/src/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/data.js +1 -1
- package/src/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +1 -1
- package/src/TemplateData/flowSchema/components/upload/confirmReserved/queue/data.js +3 -2
- package/src/TemplateData/flowSchema/components/upload/createObject/functionYaml/data.js +11 -7
- package/src/TemplateData/flowSchema/components/upload/createObject/handler/data.js +3 -3
- package/src/TemplateData/flowSchema/components/upload/createObject/mainFunction/data.js +4 -3
- package/src/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +2 -2
- package/src/TemplateData/flowSchema/components/upload/createObjectComplete/functionYaml/data.js +9 -7
- package/src/TemplateData/flowSchema/components/upload/createObjectComplete/handler/data.js +3 -3
- package/src/TemplateData/flowSchema/components/upload/createObjectComplete/mainFunction/data.js +3 -3
- package/src/TemplateData/flowSchema/components/upload/createObjectComplete/sns-sqs/data.js +3 -3
- package/src/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/functionYaml/data.js +11 -7
- package/src/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/handler/data.js +3 -3
- package/src/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/data.js +3 -3
- package/src/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +2 -2
- package/src/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/queue/data.js +2 -4
- package/src/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/data.js +15 -9
- package/src/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/handler/data.js +3 -3
- package/src/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/data.js +2 -1
- package/src/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +1 -1
- package/src/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/sqs/data.js +3 -5
- package/src/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrS3/data.js +10 -5
- package/src/TemplateData/flowSchema/components/upload/processFile/handler/handlerS3/data.js +2 -1
- package/src/TemplateData/flowSchema/components/upload/processFile/mainFunction/data.js +2 -1
- package/src/TemplateData/flowSchema/components/upload/processFile/mainFunction/template.ejs +0 -2
- package/src/TemplateData/flowSchema/components/upload/processFile/queue/data.js +1 -1
- package/src/TemplateData/flowSchema/components/upload/relate/S3/data.js +1 -1
- package/src/TemplateData/flowSchema/components/upload/relate/libs/data.js +1 -1
- package/src/TemplateData/flowSchema/components/upload/relate/sns-out/data.js +2 -1
- package/src/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +9 -4
- package/src/TemplateData/flowSchema/components/websocket/connect/handler/data.js +1 -1
- package/src/TemplateData/flowSchema/components/websocket/dynamoDb/ReservedTableData.js +1 -2
- package/src/TemplateData/flowSchema/components/websocket/dynamoDb/WebSocketTaskData.js +1 -1
- package/src/TemplateData/flowSchema/components/websocket/dynamoDb/userUploadRecords.js +1 -1
- package/src/TemplateData/flowSchema/dynamoDb/data.js +2 -1
- package/src/TemplateData/flowSchema/eventBridge/functionYaml/data.js +9 -4
- package/src/TemplateData/flowSchema/eventBridge/handler/inv/data.js +2 -1
- package/src/TemplateData/flowSchema/eventBridge/mainFunction/data.js +2 -1
- package/src/TemplateData/flowSchema/externalTopic/Complete/functionYaml/data.js +9 -6
- package/src/TemplateData/flowSchema/externalTopic/Complete/handler/data.js +2 -19
- package/src/TemplateData/flowSchema/externalTopic/Complete/mainFunction/data.js +3 -1
- package/src/TemplateData/flowSchema/externalTopic/Process/functionYaml/data.js +12 -5
- package/src/TemplateData/flowSchema/externalTopic/Process/handler/data.js +4 -1
- package/src/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +3 -1
- package/src/TemplateData/flowSchema/externalTopic/sns-out/data.js +5 -6
- package/src/TemplateData/flowSchema/flowSchemaMainFunction/data.js +5 -9
- package/src/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/data.js +10 -5
- package/src/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/handler/data.js +3 -3
- package/src/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/data.js +3 -3
- package/src/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +65 -58
- package/src/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/template.ejs +0 -4
- package/src/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/DsqHandlerTemplate.ejs +91 -0
- package/src/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +31 -16
- package/src/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +10 -5
- package/src/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/data.js +4 -3
- package/src/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +5 -6
- package/src/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +3 -1
- package/src/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +3 -3
- package/src/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +3 -3
- package/src/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +3 -3
- package/src/TemplateData/flowSchema/flowStep/functionYaml/data.js +13 -8
- package/src/TemplateData/flowSchema/flowStep/handler/data.js +3 -3
- package/src/TemplateData/flowSchema/flowStep/mainFunction/data.js +2 -1
- package/src/TemplateData/flowSchema/flowStep/sns-in/data.js +3 -3
- package/src/TemplateData/flowSchema/generateTemplateData.js +1 -6
- package/src/TemplateData/flowSchema/lambdaSync/Api/functionYaml/data.js +10 -3
- package/src/TemplateData/flowSchema/lambdaSync/Api/handler/data.js +3 -1
- package/src/TemplateData/flowSchema/lambdaSync/Inv/functionYaml/data.js +9 -3
- package/src/TemplateData/flowSchema/lambdaSync/Inv/handler/data.js +2 -1
- package/src/TemplateData/flowSchema/register/complete/functionYaml/data.js +11 -5
- package/src/TemplateData/flowSchema/register/complete/handler/data.js +2 -1
- package/src/TemplateData/flowSchema/register/complete/mainFunction/data.js +2 -1
- package/src/TemplateData/flowSchema/register/dynamoDB/register.js +2 -4
- package/src/TemplateData/flowSchema/register/sns-in/data.js +3 -4
- package/src/TemplateData/flowSchema/register/subscriptionOutAll/data.js +3 -3
- package/src/TemplateData/flowSchema/register/wbs/functionYaml/data.js +10 -5
- package/src/TemplateData/flowSchema/register/wbs/handler/data.js +2 -1
- package/src/TemplateData/flowSchema/register/wbs/mainFunction/data.js +2 -1
- package/src/TemplateData/flowSchema/statusFieldComponent/FunctionYaml/data.js +14 -6
- package/src/TemplateData/flowSchema/statusFieldComponent/Handler/data.js +4 -7
- package/src/TemplateData/flowSchema/statusFieldComponent/MainFunction/data.js +4 -3
- package/src/TemplateData/flowSchema/statusFieldComponent/sns/data.js +3 -3
- package/src/TemplateData/flowSchema/triggerCacheComponent/checkTriggerCacheComplete/functionYaml/data.js +12 -8
- package/src/TemplateData/flowSchema/triggerCacheComponent/checkTriggerCacheComplete/handler/data.js +3 -3
- package/src/TemplateData/flowSchema/triggerCacheComponent/checkTriggerCacheComplete/mainFunction/data.js +3 -3
- package/src/TemplateData/flowSchema/triggerCacheComponent/processTriggerCache/functionYaml/data.js +12 -6
- package/src/TemplateData/flowSchema/triggerCacheComponent/processTriggerCache/handler/data.js +2 -1
- package/src/TemplateData/flowSchema/triggerCacheComponent/processTriggerCache/mainFunction/data.js +2 -1
- package/src/TemplateData/flowSchema/triggerCacheComponent/triggerCacheComplete/functionYaml/data.js +11 -8
- package/src/TemplateData/flowSchema/triggerCacheComponent/triggerCacheComplete/handler/data.js +2 -1
- package/src/TemplateData/flowSchema/triggerCacheComponent/triggerCacheComplete/mainFunction/data.js +3 -3
- package/src/TemplateData/flowSchema/triggerCacheComponent/triggerCacheComplete/mainFunction/template.ejs +10 -4
- package/src/TemplateData/flowSchema/triggerCacheComponent/triggerCacheQueue/data.js +4 -11
- package/src/TemplateData/flowSchema/webSocketComplete/functionYaml/data.js +11 -8
- package/src/TemplateData/flowSchema/webSocketComplete/handler/data.js +2 -1
- package/src/TemplateData/flowSchema/webSocketComplete/mainFunction/data.js +1 -1
- package/src/TemplateData/flowSchema/webSocketComplete/sqs/data.js +3 -3
- package/src/TemplateData/generateRole/data.js +7 -2
- package/src/TemplateData/perActionComplete/create/handler/data.js +3 -3
- package/src/TemplateData/perActionComplete/create/mainFunction/data.js +3 -3
- package/src/TemplateData/perActionComplete/create/mainFunction/template.ejs +2 -2
- package/src/TemplateData/perActionComplete/create/sns-in-sqs/data.js +3 -3
- package/src/TemplateData/perActionComplete/create/sns-out/data.js +3 -3
- package/src/TemplateData/perActionComplete/create/yaml/data.js +11 -7
- package/src/TemplateData/perActionComplete/delete/handler/data.js +3 -3
- package/src/TemplateData/perActionComplete/delete/mainFunction/data.js +4 -3
- package/src/TemplateData/perActionComplete/delete/mainFunction/template.ejs +3 -4
- package/src/TemplateData/perActionComplete/delete/sns-in-sqs/data.js +4 -3
- package/src/TemplateData/perActionComplete/delete/sns-out/data.js +3 -3
- package/src/TemplateData/perActionComplete/delete/yaml/data.js +11 -7
- package/src/TemplateData/perActionComplete/get/handler/data.js +3 -3
- package/src/TemplateData/perActionComplete/get/mainFunction/data.js +3 -4
- package/src/TemplateData/perActionComplete/get/mainFunction/template.ejs +2 -2
- package/src/TemplateData/perActionComplete/get/sns-in-sqs/data.js +3 -3
- package/src/TemplateData/perActionComplete/get/sns-out/data.js +3 -3
- package/src/TemplateData/perActionComplete/get/yaml/data.js +12 -7
- package/src/TemplateData/perActionComplete/update/handler/data.js +3 -3
- package/src/TemplateData/perActionComplete/update/mainFunction/data.js +3 -3
- package/src/TemplateData/perActionComplete/update/mainFunction/template.ejs +2 -2
- package/src/TemplateData/perActionComplete/update/sns-in-sqs/data.js +3 -3
- package/src/TemplateData/perActionComplete/update/sns-out/data.js +4 -6
- package/src/TemplateData/perActionComplete/update/yaml/data.js +11 -7
- package/src/TemplateData/processLogical/handler/data.js +3 -3
- package/src/TemplateData/processLogical/mainFunction/data.js +2 -1
- package/src/TemplateData/processLogical/yaml/data.js +10 -7
- package/src/TemplateData/processLogicalPagination/DsqYaml/data.js +1 -1
- package/src/TemplateData/processLogicalPagination/handler/dsq/data.js +2 -1
- package/src/TemplateData/processLogicalPagination/handler/sqs/data.js +2 -1
- package/src/TemplateData/processLogicalPagination/mainFunction/data.js +2 -1
- package/src/TemplateData/processLogicalPagination/yaml/dsq/data.js +11 -7
- package/src/TemplateData/processLogicalPagination/yaml/sqs/data.js +9 -6
- package/src/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/data.js +12 -7
- package/src/TemplateData/relationshipPerAction/changeRelationship/action/handler/data.js +3 -3
- package/src/TemplateData/relationshipPerAction/changeRelationship/action/mainFunction/data.js +3 -3
- package/src/TemplateData/relationshipPerAction/changeRelationship/action/mainFunction/template.ejs +2 -2
- package/src/TemplateData/relationshipPerAction/changeRelationship/action/sns-in-sqs/data.js +5 -3
- package/src/TemplateData/relationshipPerAction/changeRelationship/complete/functionYaml/data.js +11 -7
- package/src/TemplateData/relationshipPerAction/changeRelationship/complete/handler/sqs/data.js +3 -3
- package/src/TemplateData/relationshipPerAction/changeRelationship/complete/mainFunction/data.js +3 -3
- package/src/TemplateData/relationshipPerAction/changeRelationship/complete/mainFunction/template.ejs +12 -11
- package/src/TemplateData/relationshipPerAction/changeRelationship/complete/sns-in-sqs/data.js +3 -3
- package/src/TemplateData/relationshipPerAction/changeRelationship/complete/sns-out/data.js +2 -1
- package/src/TemplateData/relationshipPerAction/create/action/functionYaml/data.js +20 -15
- package/src/TemplateData/relationshipPerAction/create/action/handler/data.js +4 -3
- package/src/TemplateData/relationshipPerAction/create/action/mainFunction/data.js +4 -3
- package/src/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +2 -2
- package/src/TemplateData/relationshipPerAction/create/action/sns-in-sqs/data.js +6 -4
- package/src/TemplateData/relationshipPerAction/create/complete/functionYaml/data.js +14 -10
- package/src/TemplateData/relationshipPerAction/create/complete/handler/sqs/data.js +3 -3
- package/src/TemplateData/relationshipPerAction/create/complete/mainFunction/data.js +3 -3
- package/src/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +3 -2
- package/src/TemplateData/relationshipPerAction/create/complete/sns-in-sqs/data.js +3 -3
- package/src/TemplateData/relationshipPerAction/create/complete/sns-out/data.js +3 -4
- package/src/TemplateData/relationshipPerAction/delete/action/functionYaml/data.js +20 -15
- package/src/TemplateData/relationshipPerAction/delete/action/handler/data.js +4 -4
- package/src/TemplateData/relationshipPerAction/delete/action/mainFunction/data.js +4 -7
- package/src/TemplateData/relationshipPerAction/delete/action/mainFunction/template.ejs +2 -2
- package/src/TemplateData/relationshipPerAction/delete/action/sns-in-sqs/data.js +5 -3
- package/src/TemplateData/relationshipPerAction/delete/complete/functionYaml/data.js +11 -7
- package/src/TemplateData/relationshipPerAction/delete/complete/handler/sqs/data.js +2 -1
- package/src/TemplateData/relationshipPerAction/delete/complete/mainFunction/data.js +3 -3
- package/src/TemplateData/relationshipPerAction/delete/complete/mainFunction/template.ejs +4 -5
- package/src/TemplateData/relationshipPerAction/delete/complete/sns-in-sqs/data.js +3 -3
- package/src/TemplateData/relationshipPerAction/delete/complete/sns-out/data.js +3 -3
- package/src/TemplateData/relationshipPerAction/generateTemplateData.js +1 -1
- package/src/TemplateData/relationshipPerAction/get/action/functionYaml/data.js +19 -16
- package/src/TemplateData/relationshipPerAction/get/action/handler/data.js +4 -4
- package/src/TemplateData/relationshipPerAction/get/action/mainFunction/data.js +3 -4
- package/src/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +6 -3
- package/src/TemplateData/relationshipPerAction/get/action/sns-in-sqs/data.js +5 -3
- package/src/TemplateData/relationshipPerAction/get/complete/functionYaml/data.js +13 -9
- package/src/TemplateData/relationshipPerAction/get/complete/handler/sqs/data.js +2 -1
- package/src/TemplateData/relationshipPerAction/get/complete/mainFunction/data.js +3 -3
- package/src/TemplateData/relationshipPerAction/get/complete/mainFunction/template.ejs +3 -2
- package/src/TemplateData/relationshipPerAction/get/complete/sns-in-sqs/data.js +2 -1
- package/src/TemplateData/relationshipPerAction/get/complete/sns-out/data.js +3 -3
- package/src/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/data.js +17 -13
- package/src/TemplateData/relationshipPerAction/moveRelationship/action/handler/data.js +4 -3
- package/src/TemplateData/relationshipPerAction/moveRelationship/action/mainFunction/data.js +6 -4
- package/src/TemplateData/relationshipPerAction/moveRelationship/action/mainFunction/template.ejs +6 -3
- package/src/TemplateData/relationshipPerAction/moveRelationship/action/sns-in-sqs/data.js +6 -4
- package/src/TemplateData/relationshipPerAction/moveRelationship/complete/functionYaml/data.js +13 -9
- package/src/TemplateData/relationshipPerAction/moveRelationship/complete/handler/sqs/data.js +3 -3
- package/src/TemplateData/relationshipPerAction/moveRelationship/complete/mainFunction/data.js +3 -3
- package/src/TemplateData/relationshipPerAction/moveRelationship/complete/mainFunction/template.ejs +3 -2
- package/src/TemplateData/relationshipPerAction/moveRelationship/complete/sns-in-sqs/data.js +3 -3
- package/src/TemplateData/relationshipPerAction/moveRelationship/complete/sns-out/data.js +3 -3
- package/src/TemplateData/relationshipPerAction/update/action/functionYaml/data.js +20 -15
- package/src/TemplateData/relationshipPerAction/update/action/handler/data.js +4 -4
- package/src/TemplateData/relationshipPerAction/update/action/mainFunction/data.js +4 -4
- package/src/TemplateData/relationshipPerAction/update/action/mainFunction/template.ejs +6 -3
- package/src/TemplateData/relationshipPerAction/update/action/sns-in-sqs/data.js +4 -3
- package/src/TemplateData/relationshipPerAction/update/action/sns-out/data.js +5 -6
- package/src/TemplateData/relationshipPerAction/update/complete/functionYaml/data.js +13 -10
- package/src/TemplateData/relationshipPerAction/update/complete/handler/sqs/data.js +3 -3
- package/src/TemplateData/relationshipPerAction/update/complete/mainFunction/data.js +2 -1
- package/src/TemplateData/relationshipPerAction/update/complete/mainFunction/template.ejs +3 -2
- package/src/TemplateData/relationshipPerAction/update/complete/sns-in-sqs/data.js +3 -3
- package/src/TemplateData/relationshipPerAction/update/complete/sns-out/data.js +3 -3
- package/src/TemplateData/resourceYaml/dynamodb/defaultDynamoDbTable.js +1 -1
- package/src/TemplateData/resourceYaml/dynamodb/generateDynamoPerLink.js +7 -3
- package/src/TemplateData/resourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +2 -1
- package/src/TemplateData/resourceYaml/filterGenerateResource/data.js +5 -3
- package/src/TemplateData/resourceYaml/generateTemplateData.js +5 -2
- package/src/TemplateData/resourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical.js +3 -3
- package/src/TemplateData/resourceYaml/sns-in-sqs/snsAndSqsPerActionData.js +4 -3
- package/src/TemplateData/resourceYaml/sns-out/data.js +3 -3
- package/src/TemplateData/resourceYaml/sns-out/defaultSnsOutForFindDataAndProcessLogical.js +2 -1
- package/src/libs/GenerateCodeLibs.js +1 -1
- package/src/libs/Libs.js +22 -0
- package/src/libs/Utils.js +4 -4
- package/src/GenerateSchema.js +0 -164
- package/src/SchemaConfig.js +0 -23
- package/src/TemplateData/EndpointPerService/mainFunction/create/backupTemplate.ejs +0 -358
- package/src/TemplateData/perActionEndpoint/generateTemplateData.js +0 -112
- package/src/TemplateData/perActionEndpoint/handler/api/data.js +0 -109
- package/src/TemplateData/perActionEndpoint/handler/api/request.json +0 -7
- package/src/TemplateData/perActionEndpoint/handler/api/template.ejs +0 -36
- package/src/TemplateData/perActionEndpoint/handler/dsq/data.js +0 -118
- package/src/TemplateData/perActionEndpoint/handler/dsq/request.json +0 -7
- package/src/TemplateData/perActionEndpoint/handler/dsq/template.ejs +0 -55
- package/src/TemplateData/perActionEndpoint/handler/inv/data.js +0 -112
- package/src/TemplateData/perActionEndpoint/handler/inv/request.json +0 -7
- package/src/TemplateData/perActionEndpoint/handler/inv/template.ejs +0 -37
- package/src/TemplateData/perActionEndpoint/handler/sqs/data.js +0 -116
- package/src/TemplateData/perActionEndpoint/handler/sqs/request.json +0 -7
- package/src/TemplateData/perActionEndpoint/handler/sqs/template.ejs +0 -57
- package/src/TemplateData/perActionEndpoint/handler/webSocket/data.js +0 -94
- package/src/TemplateData/perActionEndpoint/handler/webSocket/template.ejs +0 -61
- package/src/TemplateData/perActionEndpoint/handler/webSocketConnect/data.js +0 -54
- package/src/TemplateData/perActionEndpoint/handler/webSocketConnect/template.ejs +0 -55
- package/src/TemplateData/perActionEndpoint/libs/data.js +0 -60
- package/src/TemplateData/perActionEndpoint/libs/template.ejs +0 -46
- package/src/TemplateData/perActionEndpoint/mainFunction/create/data.js +0 -91
- package/src/TemplateData/perActionEndpoint/mainFunction/create/request.json +0 -0
- package/src/TemplateData/perActionEndpoint/mainFunction/create/template.ejs +0 -339
- package/src/TemplateData/perActionEndpoint/mainFunction/delete/data.js +0 -91
- package/src/TemplateData/perActionEndpoint/mainFunction/delete/template.ejs +0 -99
- package/src/TemplateData/perActionEndpoint/mainFunction/get/data.js +0 -92
- package/src/TemplateData/perActionEndpoint/mainFunction/get/request.json +0 -5
- package/src/TemplateData/perActionEndpoint/mainFunction/get/template.ejs +0 -116
- package/src/TemplateData/perActionEndpoint/mainFunction/get/testParam.json +0 -5
- package/src/TemplateData/perActionEndpoint/mainFunction/update/data.js +0 -85
- package/src/TemplateData/perActionEndpoint/mainFunction/update/request.json +0 -0
- package/src/TemplateData/perActionEndpoint/mainFunction/update/template.ejs +0 -166
- package/src/TemplateData/perActionEndpoint/yaml/api/data.js +0 -229
- package/src/TemplateData/perActionEndpoint/yaml/api/request.json +0 -14
- package/src/TemplateData/perActionEndpoint/yaml/api/template.ejs +0 -20
- package/src/TemplateData/perActionEndpoint/yaml/dsq/data.js +0 -234
- package/src/TemplateData/perActionEndpoint/yaml/dsq/request.json +0 -19
- package/src/TemplateData/perActionEndpoint/yaml/dsq/template.ejs +0 -17
- package/src/TemplateData/perActionEndpoint/yaml/inv/data.js +0 -207
- package/src/TemplateData/perActionEndpoint/yaml/inv/example req.js +0 -15
- package/src/TemplateData/perActionEndpoint/yaml/inv/request.json +0 -14
- package/src/TemplateData/perActionEndpoint/yaml/inv/template.ejs +0 -13
- package/src/TemplateData/perActionEndpoint/yaml/sqs/data.js +0 -237
- package/src/TemplateData/perActionEndpoint/yaml/sqs/request.json +0 -19
- package/src/TemplateData/perActionEndpoint/yaml/sqs/template.ejs +0 -17
- package/src/TemplateData/perActionEndpoint/yaml/wbs/data.js +0 -204
- package/src/TemplateData/perActionEndpoint/yaml/wbs/request.json +0 -19
- package/src/TemplateData/perActionEndpoint/yaml/wbs/template.ejs +0 -29
- package/src/TemplateData/perActionEndpoint/yaml/webSocketConnect/data.js +0 -58
- package/src/TemplateData/perActionEndpoint/yaml/webSocketConnect/template.ejs +0 -10
- package/src/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/api/data.js +0 -146
- package/src/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/api/template.ejs +0 -20
- package/src/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/dsq/data.js +0 -146
- package/src/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/dsq/template.ejs +0 -17
- package/src/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/inv/data.js +0 -146
- package/src/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/inv/template.ejs +0 -13
- package/src/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/sqs/data.js +0 -147
- package/src/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/sqs/template.ejs +0 -17
- package/src/TemplateData/relationshipPerAction/changeRelationship/action/handler/api/data.js +0 -62
- package/src/TemplateData/relationshipPerAction/changeRelationship/action/handler/api/template.ejs +0 -59
- package/src/TemplateData/relationshipPerAction/changeRelationship/action/handler/dsq/data.js +0 -63
- package/src/TemplateData/relationshipPerAction/changeRelationship/action/handler/dsq/template.ejs +0 -202
- package/src/TemplateData/relationshipPerAction/changeRelationship/action/handler/inv/data.js +0 -64
- package/src/TemplateData/relationshipPerAction/changeRelationship/action/handler/inv/template.ejs +0 -144
- package/src/TemplateData/relationshipPerAction/changeRelationship/action/handler/sqs/data.js +0 -64
- package/src/TemplateData/relationshipPerAction/changeRelationship/action/handler/sqs/template.ejs +0 -77
- package/src/TemplateData/relationshipPerAction/create/action/functionYaml/api/data.js +0 -175
- package/src/TemplateData/relationshipPerAction/create/action/functionYaml/api/template.ejs +0 -20
- package/src/TemplateData/relationshipPerAction/create/action/functionYaml/dsq/data.js +0 -176
- package/src/TemplateData/relationshipPerAction/create/action/functionYaml/dsq/template.ejs +0 -17
- package/src/TemplateData/relationshipPerAction/create/action/functionYaml/inv/data.js +0 -175
- package/src/TemplateData/relationshipPerAction/create/action/functionYaml/inv/template.ejs +0 -13
- package/src/TemplateData/relationshipPerAction/create/action/functionYaml/sqs/data.js +0 -177
- package/src/TemplateData/relationshipPerAction/create/action/functionYaml/sqs/template.ejs +0 -17
- package/src/TemplateData/relationshipPerAction/create/action/handler/api/data.js +0 -62
- package/src/TemplateData/relationshipPerAction/create/action/handler/api/request.json +0 -0
- package/src/TemplateData/relationshipPerAction/create/action/handler/api/template.ejs +0 -57
- package/src/TemplateData/relationshipPerAction/create/action/handler/dsq/data.js +0 -63
- package/src/TemplateData/relationshipPerAction/create/action/handler/dsq/request.json +0 -0
- package/src/TemplateData/relationshipPerAction/create/action/handler/dsq/template.ejs +0 -184
- package/src/TemplateData/relationshipPerAction/create/action/handler/inv/data.js +0 -64
- package/src/TemplateData/relationshipPerAction/create/action/handler/inv/request.json +0 -0
- package/src/TemplateData/relationshipPerAction/create/action/handler/inv/template.ejs +0 -126
- package/src/TemplateData/relationshipPerAction/create/action/handler/sqs/data.js +0 -64
- package/src/TemplateData/relationshipPerAction/create/action/handler/sqs/request.json +0 -0
- package/src/TemplateData/relationshipPerAction/create/action/handler/sqs/template.ejs +0 -75
- package/src/TemplateData/relationshipPerAction/delete/action/functionYaml/api/data.js +0 -178
- package/src/TemplateData/relationshipPerAction/delete/action/functionYaml/api/template.ejs +0 -20
- package/src/TemplateData/relationshipPerAction/delete/action/functionYaml/dsq/data.js +0 -176
- package/src/TemplateData/relationshipPerAction/delete/action/functionYaml/dsq/template.ejs +0 -17
- package/src/TemplateData/relationshipPerAction/delete/action/functionYaml/inv/data.js +0 -178
- package/src/TemplateData/relationshipPerAction/delete/action/functionYaml/inv/template.ejs +0 -13
- package/src/TemplateData/relationshipPerAction/delete/action/functionYaml/sqs/data.js +0 -176
- package/src/TemplateData/relationshipPerAction/delete/action/functionYaml/sqs/template.ejs +0 -17
- package/src/TemplateData/relationshipPerAction/delete/action/handler/api/data.js +0 -62
- package/src/TemplateData/relationshipPerAction/delete/action/handler/api/request.json +0 -0
- package/src/TemplateData/relationshipPerAction/delete/action/handler/api/template.ejs +0 -139
- package/src/TemplateData/relationshipPerAction/delete/action/handler/dsq/data.js +0 -63
- package/src/TemplateData/relationshipPerAction/delete/action/handler/dsq/request.json +0 -0
- package/src/TemplateData/relationshipPerAction/delete/action/handler/dsq/template.ejs +0 -182
- package/src/TemplateData/relationshipPerAction/delete/action/handler/inv/data.js +0 -64
- package/src/TemplateData/relationshipPerAction/delete/action/handler/inv/request.json +0 -0
- package/src/TemplateData/relationshipPerAction/delete/action/handler/inv/template.ejs +0 -124
- package/src/TemplateData/relationshipPerAction/delete/action/handler/sqs/data.js +0 -64
- package/src/TemplateData/relationshipPerAction/delete/action/handler/sqs/request.json +0 -0
- package/src/TemplateData/relationshipPerAction/delete/action/handler/sqs/template.ejs +0 -162
- package/src/TemplateData/relationshipPerAction/get/action/functionYaml/api/data.js +0 -168
- package/src/TemplateData/relationshipPerAction/get/action/functionYaml/api/template.ejs +0 -20
- package/src/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/data.js +0 -177
- package/src/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/template.ejs +0 -17
- package/src/TemplateData/relationshipPerAction/get/action/functionYaml/inv/data.js +0 -167
- package/src/TemplateData/relationshipPerAction/get/action/functionYaml/inv/template.ejs +0 -13
- package/src/TemplateData/relationshipPerAction/get/action/functionYaml/sqs/data.js +0 -166
- package/src/TemplateData/relationshipPerAction/get/action/functionYaml/sqs/template.ejs +0 -17
- package/src/TemplateData/relationshipPerAction/get/action/handler/api/data.js +0 -62
- package/src/TemplateData/relationshipPerAction/get/action/handler/api/request.json +0 -0
- package/src/TemplateData/relationshipPerAction/get/action/handler/api/template.ejs +0 -138
- package/src/TemplateData/relationshipPerAction/get/action/handler/dsq/data.js +0 -63
- package/src/TemplateData/relationshipPerAction/get/action/handler/dsq/request.json +0 -0
- package/src/TemplateData/relationshipPerAction/get/action/handler/dsq/template.ejs +0 -185
- package/src/TemplateData/relationshipPerAction/get/action/handler/inv/data.js +0 -64
- package/src/TemplateData/relationshipPerAction/get/action/handler/inv/request.json +0 -0
- package/src/TemplateData/relationshipPerAction/get/action/handler/inv/template.ejs +0 -127
- package/src/TemplateData/relationshipPerAction/get/action/handler/sqs/data.js +0 -64
- package/src/TemplateData/relationshipPerAction/get/action/handler/sqs/request.json +0 -0
- package/src/TemplateData/relationshipPerAction/get/action/handler/sqs/template.ejs +0 -165
- package/src/TemplateData/relationshipPerAction/update/action/functionYaml/api/data.js +0 -167
- package/src/TemplateData/relationshipPerAction/update/action/functionYaml/api/request.json +0 -0
- package/src/TemplateData/relationshipPerAction/update/action/functionYaml/api/template.ejs +0 -20
- package/src/TemplateData/relationshipPerAction/update/action/functionYaml/dsq/data.js +0 -196
- package/src/TemplateData/relationshipPerAction/update/action/functionYaml/dsq/request.json +0 -0
- package/src/TemplateData/relationshipPerAction/update/action/functionYaml/dsq/template.ejs +0 -17
- package/src/TemplateData/relationshipPerAction/update/action/functionYaml/inv/data.js +0 -186
- package/src/TemplateData/relationshipPerAction/update/action/functionYaml/inv/request.json +0 -0
- package/src/TemplateData/relationshipPerAction/update/action/functionYaml/inv/template.ejs +0 -13
- package/src/TemplateData/relationshipPerAction/update/action/functionYaml/sqs/data.js +0 -187
- package/src/TemplateData/relationshipPerAction/update/action/functionYaml/sqs/request.json +0 -0
- package/src/TemplateData/relationshipPerAction/update/action/functionYaml/sqs/template.ejs +0 -17
- package/src/TemplateData/relationshipPerAction/update/action/handler/api/data.js +0 -78
- package/src/TemplateData/relationshipPerAction/update/action/handler/api/request.json +0 -7
- package/src/TemplateData/relationshipPerAction/update/action/handler/api/template.ejs +0 -142
- package/src/TemplateData/relationshipPerAction/update/action/handler/dsq/data.js +0 -79
- package/src/TemplateData/relationshipPerAction/update/action/handler/dsq/request.json +0 -7
- package/src/TemplateData/relationshipPerAction/update/action/handler/dsq/template.ejs +0 -188
- package/src/TemplateData/relationshipPerAction/update/action/handler/inv/data.js +0 -80
- package/src/TemplateData/relationshipPerAction/update/action/handler/inv/request.json +0 -5
- package/src/TemplateData/relationshipPerAction/update/action/handler/inv/template.ejs +0 -147
- package/src/TemplateData/relationshipPerAction/update/action/handler/sqs/data.js +0 -79
- package/src/TemplateData/relationshipPerAction/update/action/handler/sqs/request.json +0 -7
- package/src/TemplateData/relationshipPerAction/update/action/handler/sqs/template.ejs +0 -163
- package/src/TemplateData/resourceYaml/CreateSourceData.js +0 -79
- /package/src/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/{template.ejs → SqsHandlerTemplate.ejs} +0 -0
package/src/GenerateSchema.js
DELETED
|
@@ -1,164 +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 { join } from 'path';
|
|
19
|
-
import { readFileSync } from 'fs';
|
|
20
|
-
|
|
21
|
-
import { validatePathWithRootServicePath } from './libs/GenerateCodeLibs.js';
|
|
22
|
-
|
|
23
|
-
import { schemaConfig } from './SchemaConfig.js';
|
|
24
|
-
|
|
25
|
-
// SourceManager
|
|
26
|
-
import { utils, createSource } from '../../izara-market-library-service-schemas/src/SourceManager/index.js';
|
|
27
|
-
const { deleteFileInDir } = utils;
|
|
28
|
-
|
|
29
|
-
async function generateSchema(
|
|
30
|
-
_izContext,
|
|
31
|
-
objSchemaPath,
|
|
32
|
-
generateSchemaSettings
|
|
33
|
-
) {
|
|
34
|
-
try {
|
|
35
|
-
// console.log('generateSchema', { objSchemaPath, generateSchemaSettings });
|
|
36
|
-
// --------- Prepare path -------------
|
|
37
|
-
// point to app/src
|
|
38
|
-
let saveFilePath = join(objSchemaPath, `../`);
|
|
39
|
-
// console.log("saveFilePath: ", saveFilePath);
|
|
40
|
-
|
|
41
|
-
// point to root folder of service
|
|
42
|
-
let localServicePath = join(saveFilePath, '../../');
|
|
43
|
-
// console.log("localServicePath: ", localServicePath);
|
|
44
|
-
|
|
45
|
-
//------ Start Create Source ------
|
|
46
|
-
|
|
47
|
-
// collect all result of template data for execute createSource
|
|
48
|
-
let allCreateSource = [];
|
|
49
|
-
// collect all path that need to empty before createSource
|
|
50
|
-
let allEmptyPath = new Set();
|
|
51
|
-
|
|
52
|
-
// Validate that all generateNames in generateSettings are present in the schemaConfig
|
|
53
|
-
const generateNameSet = new Set(Object.keys(schemaConfig.TemplateAndData));
|
|
54
|
-
|
|
55
|
-
// Find any missing generateNames that are not in the schemaConfig
|
|
56
|
-
let missingGenerateName = generateSchemaSettings.filter(
|
|
57
|
-
({ generateName }) => !generateNameSet.has(generateName)
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
// If there are missing generateNames, throw an error with the list of missing names
|
|
61
|
-
if (missingGenerateName.length) {
|
|
62
|
-
throw Error(
|
|
63
|
-
`Invalid generateName:[ ${missingGenerateName.map(({ generateName }) => generateName).join(', ')} ]`
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// start create generateSchema depend on
|
|
68
|
-
for (const generateSetting of generateSchemaSettings) {
|
|
69
|
-
console.log('Loading template:', generateSetting.generateName);
|
|
70
|
-
console.log('Setting data:', generateSetting);
|
|
71
|
-
// console.log('schemaPath:', schemaConfig.TemplateAndData[generateSetting.generateName]);
|
|
72
|
-
// console.log('schemaPath:', join(__dirname, schemaConfig.TemplateAndData[generateSetting.generateName]));
|
|
73
|
-
|
|
74
|
-
// get generateSchema template depend on generateName
|
|
75
|
-
let generateSchemaData = (
|
|
76
|
-
await import(
|
|
77
|
-
join(
|
|
78
|
-
__dirname,
|
|
79
|
-
schemaConfig.TemplateAndData[generateSetting.generateName]
|
|
80
|
-
)
|
|
81
|
-
)
|
|
82
|
-
).default;
|
|
83
|
-
// sources[eventSourceTag] = await import(`../MiddlewareCore/EventSources/${eventSourceTag}.js`);
|
|
84
|
-
let createSourceResult = await generateSchemaData(
|
|
85
|
-
_izContext,
|
|
86
|
-
objSchemaPath,
|
|
87
|
-
generateSchemaSettings
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
// Filter out empty or invalid objects before adding to allCreateSource
|
|
91
|
-
if (Array.isArray(createSourceResult)) {
|
|
92
|
-
const validResults = createSourceResult.filter(
|
|
93
|
-
item => item && item.templatePath && item.templateData && item.setting
|
|
94
|
-
);
|
|
95
|
-
allCreateSource.push(...validResults);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// check each allCreateSource valid
|
|
100
|
-
for (let item of allCreateSource) {
|
|
101
|
-
// throw Error('Skipping invalid source item:', item);
|
|
102
|
-
if (!item || !item.templatePath || !item.templateData || !item.setting) {
|
|
103
|
-
console.log('throw Error Skipping invalid source item:', item);
|
|
104
|
-
throw Error('Skipping invalid source item:', item);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const {
|
|
108
|
-
templatePath,
|
|
109
|
-
templateData,
|
|
110
|
-
setting,
|
|
111
|
-
emptyPath: returnEmptyPath
|
|
112
|
-
} = item;
|
|
113
|
-
setting.checkCreateSourcePass = true;
|
|
114
|
-
|
|
115
|
-
let [status, errors] = await createSource.createSource(
|
|
116
|
-
readFileSync(templatePath, 'utf8'),
|
|
117
|
-
templateData,
|
|
118
|
-
setting
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
if (status === false) {
|
|
122
|
-
throw Error(errors);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
allEmptyPath.add(setting.savePath);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// validate path before empty folder
|
|
129
|
-
for (let emptyPath of allEmptyPath) {
|
|
130
|
-
// console.log("emptyPath: ", emptyPath);
|
|
131
|
-
validatePathWithRootServicePath(localServicePath, emptyPath);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
for (let emptyPath of allEmptyPath) {
|
|
135
|
-
await deleteFileInDir(emptyPath);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// generate all source
|
|
139
|
-
for (let item of allCreateSource) {
|
|
140
|
-
// throw error if item is invalid
|
|
141
|
-
if (!item || !item.templatePath || !item.templateData || !item.setting) {
|
|
142
|
-
console.log('Throwing invalid source item:', item);
|
|
143
|
-
throw Error('Throwing invalid source item:', item);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const { templatePath, templateData, setting } = item;
|
|
147
|
-
setting.checkCreateSourcePass = false;
|
|
148
|
-
|
|
149
|
-
await createSource(
|
|
150
|
-
readFileSync(templatePath, 'utf8'),
|
|
151
|
-
templateData,
|
|
152
|
-
setting
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
console.log('Generated all source files successfully');
|
|
157
|
-
return 'return values';
|
|
158
|
-
} catch (error) {
|
|
159
|
-
console.error('Error generating code:', error);
|
|
160
|
-
throw error;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export default generateSchema;
|
package/src/SchemaConfig.js
DELETED
|
@@ -1,23 +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
|
-
export const schemaConfig = {
|
|
19
|
-
TemplateAndData: {
|
|
20
|
-
propertyValue: './TemplateData/propertyValueSchema/generateTemplateData.js'
|
|
21
|
-
},
|
|
22
|
-
Plugin: {}
|
|
23
|
-
};
|
|
@@ -1,358 +0,0 @@
|
|
|
1
|
-
/* Copyright (C) 2021 Sven Mason <http://izara.io> This program is free
|
|
2
|
-
software: you can redistribute it and/or modify it under the terms of the GNU
|
|
3
|
-
Affero General Public License as published by the Free Software Foundation,
|
|
4
|
-
either version 3 of the License, or (at your option) any later version. This
|
|
5
|
-
program is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
6
|
-
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
7
|
-
PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
|
8
|
-
You should have received a copy of the GNU Affero General Public License along
|
|
9
|
-
with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
10
|
-
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
|
|
11
|
-
const snsSharedLib = require('@izara_project/izara-core-library-sns'); const
|
|
12
|
-
asyncFlowSharedLib =
|
|
13
|
-
require('@izara_project/izara-core-library-asynchronous-flow'); const
|
|
14
|
-
callingFlowSharedLib =
|
|
15
|
-
require('@izara_project/izara-core-library-calling-flow'); const lambdaSharedLib
|
|
16
|
-
= require('@izara_project/izara-core-library-lambda'); const externalRequest =
|
|
17
|
-
require('@izara_project/izara-core-library-external-request'); const sns =
|
|
18
|
-
externalRequest.sns; const lambda = externalRequest.lambda const getObjectSchema
|
|
19
|
-
=
|
|
20
|
-
require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
|
|
21
|
-
const serviceConfigLib =
|
|
22
|
-
require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig')
|
|
23
|
-
const uploadUseCase =
|
|
24
|
-
require('@izara_project/izara-core-library-service-schemas/src/libs/UploadUseCase')
|
|
25
|
-
const hash = require('@izara_project/izara-shared-core').objectHash; const
|
|
26
|
-
NoRetryError =
|
|
27
|
-
require('@izara_project/izara-core-library-core/src/NoRetryError'); const path =
|
|
28
|
-
require('path') const schemasPath = path.join(__dirname, '../schemas'); const
|
|
29
|
-
consts =
|
|
30
|
-
require('@izara_project/izara-core-library-service-schemas/src/Consts'); const
|
|
31
|
-
coreConsts = require("@izara_project/izara-core-library-core/src/Consts"); const
|
|
32
|
-
{ generateDynamoDbIdentifiers, dynamoDbIdentifiersByStorageResource,
|
|
33
|
-
collectGetData } =
|
|
34
|
-
require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs/index.js');
|
|
35
|
-
const { getGraphServiceTagWithCache, getServiceNameWithCache } =
|
|
36
|
-
require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig');
|
|
37
|
-
//-----------------------------------------------------------------------------------------------------------
|
|
38
|
-
const PREFIX = { ONE: "one", MANY: "many", CREATE_OBJECT_ASYNC:
|
|
39
|
-
"createObjectAsync", CREATE_OBJECT_ASYNC_COMPLETE: "createObjectAsyncComplete" }
|
|
40
|
-
//-----------------------------------------------------------------------------------------------------------
|
|
41
|
-
const { TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER,
|
|
42
|
-
GRAPH_HANDLER_SERVICE_NAME } =
|
|
43
|
-
require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
|
|
44
|
-
const { createDataDetailsLib } =
|
|
45
|
-
require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs/index.js')
|
|
46
|
-
const { createLinkTypeId, createObjType } =
|
|
47
|
-
require('@izara_project/izara-core-library-service-schemas/src/Utils'); const {
|
|
48
|
-
findLinksByObjTypes } =
|
|
49
|
-
require("@izara_project/izara-core-library-service-schemas/src/libs/RelSchemaLib")
|
|
50
|
-
const lodash = require("lodash") const { createRelTypeConcat } =
|
|
51
|
-
require('@izara_project/izara-core-library-service-schemas').utils
|
|
52
|
-
//(<optionalRequire>) //(</optionalRequire>) /** * * @param {*} _izContext *
|
|
53
|
-
@param {Object} requestParams = {fieldNames,relationships = []} * @param {*}
|
|
54
|
-
callingFlowConfig */ module.exports.createMain = async ( _izContext,
|
|
55
|
-
requestParams, callingFlowConfig ) => { try { _izContext.logger.debug("function
|
|
56
|
-
CreateMain:", { requestParams, callingFlowConfig }); let errorsFound = []; const
|
|
57
|
-
userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID); const targetId
|
|
58
|
-
= _izContext.correlationIds.get(coreConsts.TARGET_ID) if (!userId) {
|
|
59
|
-
errorsFound.push("Not have userId") } //(<beforeQuery>) //(</beforeQuery>) const
|
|
60
|
-
objType = createObjType(requestParams.objectType); let objectSchema = await
|
|
61
|
-
getObjectSchema.getObjSchemaS3WithHierarchy( _izContext, objType );
|
|
62
|
-
_izContext.logger.debug("objectSchema", objectSchema); let objectSchemas =
|
|
63
|
-
uploadUseCase.generateObjectSchemaForCombineFieldNames( _izContext, objectSchema
|
|
64
|
-
); _izContext.logger.debug("objectSchemas", objectSchemas); if
|
|
65
|
-
(objectSchema.hasOwnProperty("belongTo") && !targetId) { errorsFound.push('not
|
|
66
|
-
have targetId') } let createDataDetails = await createDataDetailsLib(_izContext,
|
|
67
|
-
objectSchemas); _izContext.logger.debug("createDataDetails is =",
|
|
68
|
-
createDataDetails); let checkCorrectLinks = []; //validate linkType if
|
|
69
|
-
((requestParams.hasOwnProperty("relationships")) &&
|
|
70
|
-
(requestParams.relationships.length > 0)) { //(<beforeValidateRelationships
|
|
71
|
-
>) //(</beforeValidateRelationships
|
|
72
|
-
>) for (let relationshipProperties of requestParams.relationships) {
|
|
73
|
-
_izContext.logger.debug("relationshipProperties", relationshipProperties);
|
|
74
|
-
_izContext.logger.debug("relType", relationshipProperties.relType); let
|
|
75
|
-
getObjectRelationship = await getObjectSchema.getRelationshipSchemaWithCache(
|
|
76
|
-
_izContext, relationshipProperties.relType )
|
|
77
|
-
_izContext.logger.debug("getObjectRelationship", getObjectRelationship) for
|
|
78
|
-
(const relationshipLink of Object.values(getObjectRelationship.links)) { if
|
|
79
|
-
(relationshipLink.from.linkType === "many" && relationshipLink.to.linkType ===
|
|
80
|
-
"many") { if (relationshipLink.from.requiredOnCreate === true ||
|
|
81
|
-
relationshipLink.to.requiredOnCreate === true) { errorsFound.push("error many to
|
|
82
|
-
many linkType can't have requireOnCreate === true") } } } const links = await
|
|
83
|
-
findLinksByObjTypes(_izContext, [objType, relationshipProperties.targetObjType],
|
|
84
|
-
getObjectRelationship.links); _izContext.logger.debug("links", links) if
|
|
85
|
-
(!links.length) { errorsFound.push(`not found link between ${JSON.stringify({
|
|
86
|
-
mainObjType: objType })} and ${JSON.stringify({ toObjType:
|
|
87
|
-
relationshipProperties.targetObjType })} `) } for (let link of links) { const {
|
|
88
|
-
serviceTag: fromServiceTag, objectType: fromObjectType } = objType; const {
|
|
89
|
-
serviceTag: toServiceTag, objectType: toObjectType } =
|
|
90
|
-
relationshipProperties.targetObjType const { serviceTag: firstServiceTag,
|
|
91
|
-
objectType: firstObjectType } = link.from.objType; const { serviceTag:
|
|
92
|
-
secondServiceTag, objectType: secondObjectType } = link.to.objType const
|
|
93
|
-
matchesFromTo = fromServiceTag === firstServiceTag && fromObjectType ===
|
|
94
|
-
firstObjectType && toServiceTag === secondServiceTag && toObjectType ===
|
|
95
|
-
secondObjectType; const matchesToFrom = fromServiceTag === secondServiceTag &&
|
|
96
|
-
fromObjectType === secondObjectType && toServiceTag === firstServiceTag &&
|
|
97
|
-
toObjectType === firstObjectType if
|
|
98
|
-
((relationshipProperties.relationshipDirection === "from" && matchesFromTo) ||
|
|
99
|
-
(relationshipProperties.relationshipDirection === "to" && matchesToFrom)) {
|
|
100
|
-
checkCorrectLinks.push(true) } else { checkCorrectLinks.push(false) } } } } for
|
|
101
|
-
(const [index, checkCorrectLink] of checkCorrectLinks.entries()) { if
|
|
102
|
-
(checkCorrectLink === false) { errorsFound.push(`relationship direction
|
|
103
|
-
${JSON.stringify(requestParams.relationships[index])} is invalid`) } }
|
|
104
|
-
_izContext.logger.debug("finish validate Relationships from RequestParams"); let
|
|
105
|
-
requiredOnCreateLink = new Set(); let nonRequiredOnCreateLink = new Set(); //
|
|
106
|
-
validate relationships link let objectRelationshipSchema = await
|
|
107
|
-
getObjectSchema.getObjectRelationshipWithCache(_izContext, objType);
|
|
108
|
-
_izContext.logger.debug("objectRelationshipSchema", objectRelationshipSchema);
|
|
109
|
-
for (const objectRelLinks of objectRelationshipSchema) { if
|
|
110
|
-
(objectRelLinks.relType.serviceTag === "UserAccount") { continue } const
|
|
111
|
-
relRequired = objectRelLinks.base if
|
|
112
|
-
(relRequired.hasOwnProperty("requiredOnCreate") && relRequired.requiredOnCreate
|
|
113
|
-
=== true) { requiredOnCreateLink.add(objectRelLinks); } else if
|
|
114
|
-
(relRequired.requiredOnCreate === false) {
|
|
115
|
-
nonRequiredOnCreateLink.add(objectRelLinks); } else {
|
|
116
|
-
errorsFound.push(`requiredOnCreate should be true or false, not found
|
|
117
|
-
${objectRelLinks}`); } } _izContext.logger.debug("requiredOnCreateLink=>",
|
|
118
|
-
requiredOnCreateLink); _izContext.logger.debug("nonRequiredOnCreateLink=> ",
|
|
119
|
-
nonRequiredOnCreateLink); function groupLinkByRequiredOnCreate(_izContext,
|
|
120
|
-
links) { let groupLink = {}; for (let link of links) { let relTypeConcat =
|
|
121
|
-
createRelTypeConcat(_izContext, link.relType); if
|
|
122
|
-
(!groupLink.hasOwnProperty(relTypeConcat)) { groupLink[relTypeConcat] = { from:
|
|
123
|
-
[], to: [] } } if (link.base.direction === "from") {
|
|
124
|
-
groupLink[relTypeConcat].from.push(link) } else if (link.other.direction ===
|
|
125
|
-
"to") { groupLink[relTypeConcat].to.push(link) } } return groupLink } //**** set
|
|
126
|
-
requiredOncreateLinkGroup = {RelType, Direction} **** let
|
|
127
|
-
requiredOnCreateLinkGroup = groupLinkByRequiredOnCreate(_izContext,
|
|
128
|
-
requiredOnCreateLink); let nonRequiredOnCreateLinkGroup =
|
|
129
|
-
groupLinkByRequiredOnCreate(_izContext, nonRequiredOnCreateLink)
|
|
130
|
-
_izContext.logger.debug("requiredOnCreateLinkGroup:",
|
|
131
|
-
requiredOnCreateLinkGroup);
|
|
132
|
-
_izContext.logger.debug("nonRequiredOnCreateLinkGroup=",
|
|
133
|
-
nonRequiredOnCreateLinkGroup); // collect requiredOnCreate linkTypeIds let
|
|
134
|
-
createLinkTypeIds = []; // for (const requireLink of objectRelationshipSchema) {
|
|
135
|
-
function createLinkTypeIdFromLinkGroup(_izContext, links) { let
|
|
136
|
-
requiredOnCreateLinkSet = new Set(); for (const [relTypeConcat,
|
|
137
|
-
objectRelationshipGroup] of Object.entries(links)) { for (const objectRelFrom of
|
|
138
|
-
objectRelationshipGroup.from) { requiredOnCreateLinkSet.add(createLinkTypeId(
|
|
139
|
-
_izContext, objectRelFrom.base.objType, objectRelFrom.other.objType,
|
|
140
|
-
objectRelFrom.relType, objectRelFrom.base.direction )) } } return
|
|
141
|
-
[...requiredOnCreateLinkSet] } let requiredOnCreateLinks =
|
|
142
|
-
createLinkTypeIdFromLinkGroup(_izContext, requiredOnCreateLinkGroup); let
|
|
143
|
-
nonRequiredOnCreateLinks = createLinkTypeIdFromLinkGroup(_izContext,
|
|
144
|
-
nonRequiredOnCreateLinkGroup) _izContext.logger.debug("requiredOnCreateLinks::",
|
|
145
|
-
requiredOnCreateLinks); _izContext.logger.debug("nonRequiredOnCreateLinks::",
|
|
146
|
-
nonRequiredOnCreateLinks) for (const relationship of
|
|
147
|
-
requestParams?.relationships) { const onCreateLinkTypeId = createLinkTypeId(
|
|
148
|
-
_izContext, objType, relationship.targetObjType, relationship.relType,
|
|
149
|
-
relationship.relationshipDirection ) createLinkTypeIds.push(onCreateLinkTypeId)
|
|
150
|
-
}; _izContext.logger.debug("createLinkTypeIds::", createLinkTypeIds) return //
|
|
151
|
-
end validate let objInstanceFull = { identifiers: {}, fields: {} };
|
|
152
|
-
//(<optionalObjInstanceFull>) //(</optionalObjInstanceFull>) let
|
|
153
|
-
listOfRequiredOnCreate = []; let listOfOptionalOnCreate = []; let
|
|
154
|
-
allAwaitingStepsId = []; // validate single identifiers if
|
|
155
|
-
(objectSchemas.identifiers.length === 1 &&
|
|
156
|
-
!objectSchemas.identifiers[0].hasOwnProperty("fieldNames")) { const identifier =
|
|
157
|
-
objectSchemas.identifiers[0]; _izContext.logger.debug(":::::case single
|
|
158
|
-
identifer:::::", identifier); if
|
|
159
|
-
(objectSchemas.fieldNames[identifier.fieldName].hasOwnProperty("randomOnCreate"))
|
|
160
|
-
{ if ((objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == true)) {
|
|
161
|
-
Object.assign(requestParams.fieldNames, { [identifier.fieldName]: hash({
|
|
162
|
-
fieldNames: identifier, // uniqueRequestId: _izContext.uniqueRequestId,
|
|
163
|
-
callingFlowConfig: callingFlowConfig }) }); _izContext.logger.debug("Assign
|
|
164
|
-
requestParams", requestParams) } else if
|
|
165
|
-
((objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == false) ||
|
|
166
|
-
(objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == null)) { if
|
|
167
|
-
((objectSchemas.fieldNames[identifier.fieldName].requiredOnCreate == true) &&
|
|
168
|
-
(objectSchemas.fieldNames[identifier.fieldName].canUpdate == false)) { // check
|
|
169
|
-
Fns have resive if
|
|
170
|
-
(requestParams.fieldNames.hasOwnProperty([identifier.fieldName])) {
|
|
171
|
-
_izContext.logger.debug("identifier is exist:", { [identifier.fieldName]:
|
|
172
|
-
requestParams.fieldNames[identifier.fieldName] }); } else {
|
|
173
|
-
errorsFound.push("[invalid]requestParams not have data fieldNames of
|
|
174
|
-
requriedOnCreate"); } } }; } else if
|
|
175
|
-
(objectSchemas.fieldNames[identifier.fieldName].hasOwnProperty("hashOnCreate"))
|
|
176
|
-
{ if (objectSchemas.fieldNames[identifier.fieldName].hashOnCreate.length &&
|
|
177
|
-
objectSchemas.fieldNames[identifier.fieldName].hashOnCreate.length > 0) { for
|
|
178
|
-
(const fieldName of objectSchemas.fieldNames[identifier.fieldName].hashOnCreate)
|
|
179
|
-
{ Object.assign( requestParams.fieldNames, { [identifier.fieldName]: hash({
|
|
180
|
-
[fieldName]: requestParams.fieldNames[fieldName] }) } ) } } else {
|
|
181
|
-
errorsFound.push("[invalid] no data to hash for create") } } else { if
|
|
182
|
-
((objectSchemas.fieldNames[identifier.fieldName].requiredOnCreate === false) &&
|
|
183
|
-
(objectSchemas.fieldNames[identifier.fieldName].optionalOnCreate === false) &&
|
|
184
|
-
(objectSchemas.fieldNames[identifier.fieldName].canUpdate === false) &&
|
|
185
|
-
objectSchemas.fieldNames[identifier.fieldName].hashOnCreate === false) {
|
|
186
|
-
errorsFound.push("[invalid]case single identifier invalid objectSchemas"); }; };
|
|
187
|
-
} _izContext.logger.debug("requestParams is:", requestParams); // check
|
|
188
|
-
settingObjSchemas for (let [keyFieldNames, valueFieldNames] of
|
|
189
|
-
Object.entries(objectSchemas.fieldNames)) { if
|
|
190
|
-
(valueFieldNames.hasOwnProperty("randomOnCreate") &&
|
|
191
|
-
valueFieldNames.randomOnCreate === true) {
|
|
192
|
-
listOfRequiredOnCreate.push(keyFieldNames) }; if
|
|
193
|
-
(valueFieldNames.hasOwnProperty("requiredOnCreate") &&
|
|
194
|
-
valueFieldNames.requiredOnCreate === true) {
|
|
195
|
-
listOfRequiredOnCreate.push(keyFieldNames) }; if
|
|
196
|
-
(valueFieldNames.hasOwnProperty("hashOnCreate") &&
|
|
197
|
-
valueFieldNames.hashOnCreate.length) {
|
|
198
|
-
listOfRequiredOnCreate.push(keyFieldNames) } if
|
|
199
|
-
(valueFieldNames.hasOwnProperty("optionalOnCreate") &&
|
|
200
|
-
valueFieldNames.optionalOnCreate === true) { if
|
|
201
|
-
((valueFieldNames.requiredOnCreate === false) &&
|
|
202
|
-
valueFieldNames.optionalOnCreate === true) {
|
|
203
|
-
listOfOptionalOnCreate.push(keyFieldNames) }; }; }; // end iteration of
|
|
204
|
-
fieldNames _izContext.logger.debug("listOfRequiredOnCreate",
|
|
205
|
-
listOfRequiredOnCreate); _izContext.logger.debug("listOfOptionalOnCreate",
|
|
206
|
-
listOfOptionalOnCreate); for (let fieldName of
|
|
207
|
-
Object.keys(requestParams.fieldNames)) { if
|
|
208
|
-
(!listOfRequiredOnCreate.includes(fieldName)) { if
|
|
209
|
-
(!listOfOptionalOnCreate.includes(fieldName)) { errorsFound.push("[invalid] over
|
|
210
|
-
fieldNames create object"); } }; if (listOfOptionalOnCreate.length > 0 &&
|
|
211
|
-
listOfRequiredOnCreate.includes(fieldName)) { //(<optionalParams
|
|
212
|
-
>) //(</optionalParams
|
|
213
|
-
>) }; if (objectSchemas.identifierFieldNames.includes(fieldName)) {
|
|
214
|
-
_izContext.logger.debug("identifiers is", fieldName);
|
|
215
|
-
Object.assign(objInstanceFull.identifiers, { [fieldName]:
|
|
216
|
-
requestParams.fieldNames[fieldName] }); }; if (errorsFound.length > 0) {
|
|
217
|
-
_izContext.logger.debug("HaveError::", errorsFound); break }; }; // end loop let
|
|
218
|
-
listOfObjectForCreates = []; let objInstanceFullForDynamoDb =
|
|
219
|
-
lodash.cloneDeep(objInstanceFull) let objInstanceFullForGraph =
|
|
220
|
-
lodash.cloneDeep(objInstanceFull) if (errorsFound.length == 0) { for (let
|
|
221
|
-
[storageTag, createDataDetail] of Object.entries(createDataDetails)) {
|
|
222
|
-
//(<beforeCreate>) //(</beforeCreate>) if (createDataDetail.storageType ==
|
|
223
|
-
consts.STORAGE_TYPES.dynamoDB) { //(<beforeCreateRecordDynamo
|
|
224
|
-
>) //(</beforeCreateRecordDynamo
|
|
225
|
-
>) _izContext.logger.debug("::::::DynamoDB::::::", { storageTag, objInstanceFull
|
|
226
|
-
}); Object.assign(objInstanceFullForDynamoDb.fields,
|
|
227
|
-
createObjInstanceFullFieldsByStorageTag(_izContext, storageTag,
|
|
228
|
-
createDataDetail)) _izContext.logger.debug("objInstanceFull before create item
|
|
229
|
-
in dynamoDB", objInstanceFullForDynamoDb) let identifiersForCreateData = await
|
|
230
|
-
dynamoDbIdentifiersByStorageResource( _izContext, objectSchema,
|
|
231
|
-
createDataDetails, objInstanceFullForDynamoDb.identifiers )
|
|
232
|
-
_izContext.logger.debug("identifiersForCreateData", identifiersForCreateData);
|
|
233
|
-
await dynamodbSharedLib.putItem( _izContext, await dynamodbSharedLib.tableName(
|
|
234
|
-
_izContext, createDataDetail.tableName ), { ...identifiersForCreateData,
|
|
235
|
-
...objInstanceFullForDynamoDb.fields } ); } else if
|
|
236
|
-
(createDataDetail.storageType == consts.STORAGE_TYPES.graph) {
|
|
237
|
-
//(<beforeCreateNode>) //(</beforeCreateNode>)
|
|
238
|
-
_izContext.logger.debug("::::::Graph::::::", { storageTag, objInstanceFull });
|
|
239
|
-
Object.assign(objInstanceFullForGraph.fields,
|
|
240
|
-
createObjInstanceFullFieldsByStorageTag(_izContext, storageTag,
|
|
241
|
-
createDataDetail)) _izContext.logger.debug("objInstanceFull before send to
|
|
242
|
-
Graph", objInstanceFullForGraph) // allStorageTagComplete = false;
|
|
243
|
-
allAwaitingStepsId.push(await asyncFlowSharedLib.createAwaitingStepId( (hash({
|
|
244
|
-
objType: objType, graphServerTag: storageTag, identifiers:
|
|
245
|
-
objInstanceFullForGraph.identifiers })), PREFIX.CREATE_OBJECT_ASYNC ));
|
|
246
|
-
listOfObjectForCreates.push({ [storageTag]: { objInstanceFull: { identifiers:
|
|
247
|
-
objInstanceFullForGraph.identifiers, fields: objInstanceFullForGraph.fields },
|
|
248
|
-
allStorageTagComplete: false } }); _izContext.logger.debug("FIRST",
|
|
249
|
-
listOfObjectForCreates) };
|
|
250
|
-
_izContext.logger.debug("[1]listOfObjectForCreates:::", listOfObjectForCreates);
|
|
251
|
-
}; }; function createObjInstanceFullFieldsByStorageTag(_izContext, storageTag,
|
|
252
|
-
createDataDetail) {
|
|
253
|
-
_izContext.logger.debug("createObjInstanceFullFieldsByStorageTag : ", {
|
|
254
|
-
storageTag, createDataDetail }) let fields = {}; for (let fieldName of
|
|
255
|
-
Object.keys(requestParams.fieldNames)) { if
|
|
256
|
-
((createDataDetails[storageTag].fieldNames.includes(fieldName)) &&
|
|
257
|
-
(createDataDetail.fieldNames.includes(fieldName))) { if
|
|
258
|
-
(!objInstanceFull.identifiers.hasOwnProperty(fieldName)) { if
|
|
259
|
-
(!fields.hasOwnProperty(fieldName)) { Object.assign(fields, { [fieldName]:
|
|
260
|
-
requestParams.fieldNames[fieldName] }) } } } } _izContext.logger.debug({ fields
|
|
261
|
-
}) return fields } /// step save awaitingMultipleStep of storageType graph
|
|
262
|
-
........................................................... await
|
|
263
|
-
asyncFlowSharedLib.createAwaitingMultipleSteps( _izContext, allAwaitingStepsId,
|
|
264
|
-
asyncFlowSharedLib.createPendingStepId((hash({ objType: objType, identifiers:
|
|
265
|
-
objInstanceFull.identifiers })), PREFIX.CREATE_OBJECT_ASYNC_COMPLETE) );
|
|
266
|
-
//............................................................................................................
|
|
267
|
-
// process storageType : graph let messageObject = {}; for (let objectCreate of
|
|
268
|
-
listOfObjectForCreates) { for (let [graphServiceName, objectForCreate] of
|
|
269
|
-
Object.entries(objectCreate)) { _izContext.logger.debug("Loop each graph:", {
|
|
270
|
-
[graphServiceName]: objectForCreate }); if
|
|
271
|
-
(objectForCreate.allStorageTagComplete == false) { // needless check because in
|
|
272
|
-
listOfObjectForCreates push case graph only! //(<beforeSendMessageToGraph
|
|
273
|
-
>) //(</beforeSendMessageToGraph
|
|
274
|
-
>) messageObject = { objType: objType, objInstanceFull:
|
|
275
|
-
objectForCreate.objInstanceFull, relationships: requestParams.relationships ||
|
|
276
|
-
[] }; }; if (errorsFound.length > 0) { break; } else {
|
|
277
|
-
_izContext.logger.debug("SENT MESSAGE EACH GRAPH::::", { graphServiceName,
|
|
278
|
-
messageObject, callingFlowConfig }) Object.assign(messageObject, { settings: {
|
|
279
|
-
updatePropertiesOnMatch: false }, originTimestamp: Date.now() }); messageObject
|
|
280
|
-
= callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject( messageObject,
|
|
281
|
-
callingFlowSharedLib.addParentCallingFlowConfig( callingFlowConfig, // receive
|
|
282
|
-
parent callingFlowConfig. callingFlowSharedLib.createCallingFlowConfig( //
|
|
283
|
-
calling flow own service await lambdaSharedLib.lambdaFunctionName(_izContext,
|
|
284
|
-
TOPIC_NAME_GENERATE_CODE.createNodeComplete), {} ) ) ); let
|
|
285
|
-
messageToCreateObject = { Message: JSON.stringify(messageObject), TopicArn:
|
|
286
|
-
await snsSharedLib.snsTopicArnByFlowSchema(_izContext,
|
|
287
|
-
TOPIC_NAME_GRAPH_HANDLER.inCreateNode, graphServiceName) };
|
|
288
|
-
_izContext.logger.debug("RequestParams before send to sqs messageToCreateObject
|
|
289
|
-
::::::: ", messageToCreateObject); await sns.publishAsync(_izContext,
|
|
290
|
-
messageToCreateObject); //(<afterSendMessageToGraph
|
|
291
|
-
>) //(</afterSendMessageToGraph
|
|
292
|
-
>) return { objType: objType, objInstanceFull: objInstanceFullForGraph,
|
|
293
|
-
relationships: requestParams.relationships || [], status: "complete",
|
|
294
|
-
errorsFound: errorsFound } }; }; // end loop of objectCreate. if
|
|
295
|
-
(errorsFound.length > 0) { break; } }; // end loop listOfObjectForCreates if
|
|
296
|
-
(errorsFound.length > 0) { _izContext.logger.debug("Case have errorFound:::",
|
|
297
|
-
errorsFound); // remove awaitngMultiplestep. [[[[[[[open when not test
|
|
298
|
-
lolcal.]]]]]]] await asyncFlowSharedLib.clearAllAwaitingSteps( _izContext,
|
|
299
|
-
asyncFlowSharedLib.createPendingStepId((hash({ objType: objType, identifiers:
|
|
300
|
-
objInstanceFull.identifiers })), PREFIX.CREATE_OBJECT_ASYNC_COMPLETE)); //
|
|
301
|
-
pendingStepId // send message to OutCreateObjectComplete. //.. messageObject = {
|
|
302
|
-
objType: objType, identifiers: null, // or {} errorsFound: errorsFound }; //
|
|
303
|
-
pass back property. messageObject =
|
|
304
|
-
callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(callingFlowConfig,
|
|
305
|
-
messageObject); let messageAttributes =
|
|
306
|
-
callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(callingFlowConfig,
|
|
307
|
-
{}); let sendMessageOutCreateObjectComplete = { Message:
|
|
308
|
-
JSON.stringify(messageObject), MessageAttributes:
|
|
309
|
-
sns.createStringMessageAttributes(_izContext, messageAttributes), TopicArn:
|
|
310
|
-
await snsSharedLib.snsTopicArnByFlowSchema(_izContext,
|
|
311
|
-
TOPIC_NAME_GENERATE_CODE.outCreateNodeComplete) }; _izContext.logger.debug("Send
|
|
312
|
-
message to OutCreateObjectComplete :::>", sendMessageOutCreateObjectComplete)
|
|
313
|
-
await sns.publishAsync(_izContext, sendMessageOutCreateObjectComplete); return {
|
|
314
|
-
objType: objType, objInstanceFull: objInstanceFull, relationships:
|
|
315
|
-
requestParams.relationships || [], status: "error", errorsFound: errorsFound } }
|
|
316
|
-
else { if (allAwaitingStepsId.length == 0 && listOfObjectForCreates.length == 0)
|
|
317
|
-
{ let messageObject = { objType: { objectType: OBJECT_TYPE, serviceTag:
|
|
318
|
-
SERVICE_TAG }, objInstanceFull: { identifiers:
|
|
319
|
-
objInstanceFullForDynamoDb.identifiers, fields:
|
|
320
|
-
objInstanceFullForDynamoDb.fields } } if
|
|
321
|
-
(callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]) { //
|
|
322
|
-
send message to SNS OutCreateNodeComplete _izContext.logger.debug("HAVE
|
|
323
|
-
CallingFlow"); messageObject =
|
|
324
|
-
callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(callingFlowConfig,
|
|
325
|
-
messageObject); let messageAttributes =
|
|
326
|
-
callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(callingFlowConfig,
|
|
327
|
-
{}); let outCreateNodeCompleteTopic = await
|
|
328
|
-
snsSharedLib.snsTopicArnByFlowSchema(_izContext,
|
|
329
|
-
TOPIC_NAME_GENERATE_CODE.outCreateNodeComplete) let messageParams = { Message:
|
|
330
|
-
JSON.stringify(messageObject), MessageAttributes:
|
|
331
|
-
sns.createStringMessageAttributes(_izContext, messageAttributes), TopicArn:
|
|
332
|
-
outCreateNodeCompleteTopic, }; _izContext.logger.debug("messageParams
|
|
333
|
-
OutCreateNode ::::::: ", messageParams); await sns.publishAsync(_izContext,
|
|
334
|
-
messageParams); } } return { objType: objType, objInstanceFull:
|
|
335
|
-
objInstanceFullForDynamoDb, relationships: requestParams.relationships || [],
|
|
336
|
-
status: "complete", errorsFound: errorsFound } } } catch (err) { throw (err) } }
|
|
337
|
-
const correlationIds =
|
|
338
|
-
require("@izara_project/izara-core-library-correlation-ids"); const logger =
|
|
339
|
-
require("@izara_project/izara-core-library-logger"); const integrationTestDetail
|
|
340
|
-
= require("@izara_project/izara-core-library-integration-tests"); const
|
|
341
|
-
resourceUse = require("@izara_project/izara-core-library-resource-use"); const {
|
|
342
|
-
link } = require('fs'); const izaraAttributeTree =
|
|
343
|
-
require('@izara_project/izara-attribute-tree'); let _izContext = {
|
|
344
|
-
correlationIds: correlationIds, logger: logger, integrationTestDetail:
|
|
345
|
-
integrationTestDetail, resourceUse: resourceUse }
|
|
346
|
-
_izContext.correlationIds.set(coreConsts.BASE_USER_ID, "BasDev")
|
|
347
|
-
_izContext.correlationIds.set(coreConsts.TARGET_ID, "BasDevTargetId")
|
|
348
|
-
this.createMain(_izContext, { "fieldNames": { "address": "585/2" },
|
|
349
|
-
"relationships": [ { "relType": { "serviceTag": "GCTpBas", "relationshipTag":
|
|
350
|
-
"hasHouse" }, "relationshipProperties": { "createTimestamp": 1746758956635 },
|
|
351
|
-
"relationshipDirection": "to", "targetObjType": { "serviceTag": "GCTpBas",
|
|
352
|
-
"objectType": "person" }, "targetIdentifiers": { "personId":
|
|
353
|
-
"05b29b450a6d11ff1f79a0ea6531d32423af3260" } }, { "relType": { "serviceTag":
|
|
354
|
-
"GCTpBas", "relationshipTag": "hasHouse" }, "relationshipProperties": {
|
|
355
|
-
"createTimestamp": 1746758956635 }, "relationshipDirection": "to",
|
|
356
|
-
"targetObjType": { "serviceTag": "GCTpBas", "objectType": "person" },
|
|
357
|
-
"targetIdentifiers": { "personId": "5d3add2de5fdbd9611864fb529c5091f511e5985" }
|
|
358
|
-
} ], "objectType": "house" }, "callingFlowBasDev" )
|
|
@@ -1,112 +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
|
-
const { join } = require('path');
|
|
19
|
-
const {
|
|
20
|
-
getAllLocalObjectSchemasWithHierarchy
|
|
21
|
-
} = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
|
|
22
|
-
|
|
23
|
-
// Import handlers and generators
|
|
24
|
-
const modules = {
|
|
25
|
-
handlers: {
|
|
26
|
-
inv: require('./handler/inv/data'),
|
|
27
|
-
api: require('./handler/api/data'),
|
|
28
|
-
sqs: require('./handler/sqs/data'),
|
|
29
|
-
dsq: require('./handler/dsq/data')
|
|
30
|
-
},
|
|
31
|
-
mainFunctions: {
|
|
32
|
-
get: require('./mainFunction/get/data'),
|
|
33
|
-
update: require('./mainFunction/update/data'),
|
|
34
|
-
create: require('./mainFunction/create/data'),
|
|
35
|
-
delete: require('./mainFunction/delete/data')
|
|
36
|
-
},
|
|
37
|
-
yamlGenerators: {
|
|
38
|
-
inv: require('./yaml/inv/data'),
|
|
39
|
-
api: require('./yaml/api/data'),
|
|
40
|
-
sqs: require('./yaml/sqs/data'),
|
|
41
|
-
dsq: require('./yaml/dsq/data')
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// Import code libs generator
|
|
46
|
-
const createGenerateCodeLibs = require('./libs/data');
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Generates code from templates based on object schemas
|
|
50
|
-
* @param {Object} _izContext - Context object
|
|
51
|
-
* @param {string} objSchemaPath - Path to object schema
|
|
52
|
-
* @returns {Promise<Array>} - Array of parameter objects for code generation
|
|
53
|
-
*/
|
|
54
|
-
async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
55
|
-
try {
|
|
56
|
-
const saveFilePath = join(objSchemaPath, `../`);
|
|
57
|
-
const allObjSchemas = await getAllLocalObjectSchemasWithHierarchy(
|
|
58
|
-
_izContext,
|
|
59
|
-
objSchemaPath
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
const createSourceParams = [];
|
|
63
|
-
|
|
64
|
-
for (const objectSchema of allObjSchemas.records) {
|
|
65
|
-
try {
|
|
66
|
-
// Generate handlers
|
|
67
|
-
const handlerParams = Object.entries(modules.handlers).flatMap(
|
|
68
|
-
([type, handlerFn]) =>
|
|
69
|
-
handlerFn(_izContext, objectSchema, saveFilePath)
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
// Generate main functions
|
|
73
|
-
const functionParams = (
|
|
74
|
-
await Promise.all(
|
|
75
|
-
Object.entries(modules.mainFunctions).map(([action, functionFn]) =>
|
|
76
|
-
functionFn(_izContext, objectSchema, saveFilePath)
|
|
77
|
-
)
|
|
78
|
-
)
|
|
79
|
-
).flat();
|
|
80
|
-
|
|
81
|
-
// Generate function YAML files
|
|
82
|
-
const yamlParams = Object.entries(modules.yamlGenerators).flatMap(
|
|
83
|
-
([type, yamlFn]) => yamlFn(_izContext, objectSchema, saveFilePath)
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
// Generate code libs
|
|
87
|
-
const libsParam = createGenerateCodeLibs(_izContext, saveFilePath);
|
|
88
|
-
|
|
89
|
-
createSourceParams.push(
|
|
90
|
-
...handlerParams,
|
|
91
|
-
...functionParams,
|
|
92
|
-
...yamlParams,
|
|
93
|
-
libsParam
|
|
94
|
-
);
|
|
95
|
-
} catch (error) {
|
|
96
|
-
_izContext.logger.error(
|
|
97
|
-
`Error processing schema ${objectSchema.name || 'unknown'}: ${error}`
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return createSourceParams;
|
|
103
|
-
} catch (error) {
|
|
104
|
-
_izContext.logger.error(
|
|
105
|
-
'Error generating code with template perActionEndpoint:',
|
|
106
|
-
error
|
|
107
|
-
);
|
|
108
|
-
return [];
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
module.exports = generateCodeWithTemplate;
|