@izara_project/izara-market-library-service-schemas 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/GenerateCodeLibs/index.js +2 -1
- package/src/GenerateCodeLibs/src/Consts.js +20 -5
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +298 -12
- package/src/GenerateCodeLibs/src/TranslateIdsLibs.js +89 -0
- package/src/MainLibs/src/Utils.js +10 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrApi/data.js +119 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrDsq/data.js +133 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrInv/data.js +120 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrSqs/data.js +133 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/mainFunction/data.js +59 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/mainFunction/template.ejs +340 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrApi/data.js +58 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrApi/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrApi/template.ejs +120 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrDsq/data.js +59 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrDsq/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrDsq/template.ejs +167 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrInv/data.js +60 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrInv/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrInv/template.ejs +107 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrSqs/data.js +60 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrSqs/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrSqs/template.ejs +146 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/request.json +30 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/sns-in-sqs/data.js +78 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/functionYaml/data.js +133 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/functionYaml/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/functionYaml/template.ejs +33 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/handler/HdrSqs/data.js +61 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/handler/HdrSqs/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/handler/HdrSqs/template.ejs +125 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/mainFunction/data.js +56 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/mainFunction/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/mainFunction/template.ejs +137 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-in-sqs/data.js +72 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-in-sqs/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-in-sqs/template.ejs +47 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-out/data.js +72 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-out/request.json +0 -0
- package/src/TemplateManager/src/FindData/FindDataYaml/data.js +188 -0
- package/src/TemplateManager/src/FindData/FindDataYaml/template.ejs +27 -0
- package/src/TemplateManager/src/FindData/GetByStorage/getByDynamo.ejs +53 -0
- package/src/TemplateManager/src/FindData/GetByStorage/getByGraph.ejs +99 -0
- package/src/TemplateManager/src/FindData/Handler/data.js +48 -0
- package/src/TemplateManager/src/FindData/Handler/template.ejs +140 -0
- package/src/TemplateManager/src/FindData/mainFunction/data.js +279 -0
- package/src/TemplateManager/src/FindData/mainFunction/template.ejs +155 -0
- package/src/TemplateManager/src/GenerateCode(Old).js +1 -1
- package/src/TemplateManager/src/GenerateCode.js +205 -45
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/functionYaml/data.js +98 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/functionYaml/template.ejs +33 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/handler/data.js +0 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/handler/template.ejs +0 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/createObjectComplete_main.js +172 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/data.js +0 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/template.ejs +0 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-in-sqs/data.js +0 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-in-sqs/template.ejs +0 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-out/data.js +0 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-out/template.ejs +0 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/functionYaml/data.js +98 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/functionYaml/template.ejs +33 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/handler/data.js +59 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/handler/template.ejs +129 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/mainFunction/data.js +53 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/mainFunction/template.ejs +126 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/sns-out/data.js +62 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/sqs-in-sns/data.js +58 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/sqs-in-sns/template.ejs +47 -0
- package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrApi/data.js +24 -20
- package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrApi/template.ejs +2 -2
- package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrDsq/data.js +27 -20
- package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrInv/data.js +54 -22
- package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrSqs/data.js +28 -23
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrSqs/template.ejs +30 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/data.js +6 -22
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/getTemplate.ejs +76 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/updateTemplate.ejs +67 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/data.js +47 -37
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/getTemplate.ejs +105 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/updateTemplate.ejs +109 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/createTemplate.ejs +75 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/data.js +68 -33
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/getTemplate.ejs +82 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/updateTemplate.ejs +75 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/data.js +46 -30
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/getTemplate.ejs +124 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/updateTemplate.ejs +133 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/CreateObject_main.js +760 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/data.js +67 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/request.json +0 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/template.ejs +581 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/data.js +0 -21
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/template.ejs +34 -31
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/testParam.json +5 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/data.js +61 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/request.json +0 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/template.ejs +267 -0
- package/src/TemplateManager/src/ProcessLogical/Handler/data.js +49 -0
- package/src/TemplateManager/src/ProcessLogical/Handler/template.ejs +129 -0
- package/src/TemplateManager/src/ProcessLogical/ProcessLogicalYaml/data.js +175 -0
- package/src/TemplateManager/src/ProcessLogical/ProcessLogicalYaml/template.ejs +25 -0
- package/src/TemplateManager/src/ProcessLogical/mainFunction/data.js +47 -0
- package/src/TemplateManager/src/ProcessLogical/mainFunction/template.ejs +421 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/DsqYaml/data.js +50 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/DsqYaml/template.ejs +32 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrDsq/data.js +167 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrDsq/template.ejs +25 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrSqs/data.js +169 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrSqs/template.ejs +25 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/Handler/HdrDsq/data.js +48 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/Handler/HdrDsq/template.ejs +163 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/Handler/HdrSqs/data.js +48 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/Handler/HdrSqs/template.ejs +146 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/mainFunction/data.js +48 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/mainFunction/template.ejs +212 -0
- package/src/TemplateManager/src/ResourceYaml/CreateSourceData.js +2 -2
- package/src/TemplateManager/src/ResourceYaml/dynamodb/awaitingMultipleStepData.js +5 -8
- package/src/TemplateManager/src/ResourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +4 -26
- package/src/TemplateManager/src/ResourceYaml/dynamodb/processLogicalAndFindData.js +6 -10
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical.js +28 -16
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/snsAndSqsPerActiondata.js +5 -5
- package/src/TemplateManager/src/ResourceYaml/sns-out/data.js +3 -3
- package/src/TemplateManager/src/ResourceYaml/sns-out/defaultSnsOutForFindDataAndProcessLogical.js +75 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/functionYaml/data.js +95 -0
- package/src/TemplateManager/src/{FunctionYaml/HdrSqs → TranslateIdReq/ProcessingTranslateIds/functionYaml}/template.ejs +1 -1
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/handler/dataHdrDsq.js +52 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/handler/template.ejs +194 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/mainFunction/data.js +48 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/mainFunction/template.ejs +330 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/sns-out/data.js +47 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/sqs-sns/data.js +58 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/sqs-sns/template.ejs +43 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/functionYaml/HdrDsq/data.js +116 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/functionYaml/HdrSqs/data.js +116 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/handler/HdrDsq/data.js +60 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/handler/HdrDsq/template.ejs +157 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/handler/HdrSqs/data.js +59 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/handler/HdrSqs/template.ejs +175 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/mainFunction/data.js +61 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/mainFunction/template.ejs +155 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/resourceYaml/dynamoDb/data.js +120 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/resourceYaml/sns-sqs/data.js +75 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/data.js +8 -24
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/handler/HdrSqs/data.js +7 -21
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/data.js +4 -3
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-in-sqs/data.js +10 -13
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-in-sqs/template.ejs +1 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-out/data.js +6 -5
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/data.js +13 -21
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/data.js +11 -29
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/data.js +16 -21
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/data.js +12 -27
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/mainFunction/data.js +3 -18
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/mainFunction/template.ejs +18 -11
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/data.js +5 -18
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/data.js +5 -19
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/data.js +7 -18
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/data.js +6 -20
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/request.json +3 -4
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-in-sqs/data.js +5 -6
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-out/data.js +4 -4
- package/src/TemplateManager/src/externalService/LambdaRole/data.js +181 -59
- package/src/TemplateManager/src/externalService/LambdaRole/template.ejs +17 -15
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/data.js +56 -44
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/template.ejs +3 -4
- package/src/TemplateManager/src/libs/Consts.js +162 -13
- package/src/TemplateManager/src/PerActionEndpoint/Handler/testRequest.json +0 -5
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrApi/request.json +0 -0
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrDsq/request.json +0 -0
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrDsq/template.ejs +0 -0
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrInv/example req.js +0 -0
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrInv/request.json +0 -0
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrInv/template.ejs +0 -0
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrSqs/request.json +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@izara_project/izara-market-library-service-schemas",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Schemas for Izara Market project",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@izara_project/izara-core-library-core": "^1.0.13",
|
|
24
24
|
"@izara_project/izara-core-library-logger": "^1.0.5",
|
|
25
|
-
"@izara_project/izara-core-library-service-schemas": "^1.0.
|
|
25
|
+
"@izara_project/izara-core-library-service-schemas": "^1.0.13",
|
|
26
26
|
"@izara_project/izara-shared": "^1.0.96",
|
|
27
27
|
"ejs": "^3.1.10",
|
|
28
28
|
"js-beautify": "^1.15.1",
|
|
@@ -20,5 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
20
20
|
// contain functions that use with generated code in each services
|
|
21
21
|
console.log("./src/GenerateCodeLibs")
|
|
22
22
|
module.exports = {
|
|
23
|
-
generateCodeLibs: require("./src/GenerateCodeLibs")
|
|
23
|
+
generateCodeLibs: require("./src/GenerateCodeLibs"),
|
|
24
|
+
translateIdsLibs: require('./src/TranslateIdsLibs'),
|
|
24
25
|
}
|
|
@@ -17,19 +17,34 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
|
|
|
17
17
|
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
20
|
-
// constant for updateRelationship
|
|
20
|
+
// constant for updateRelationship and createRelationship
|
|
21
21
|
|
|
22
22
|
const PREFIX = {
|
|
23
|
-
updateRel: "updateRelationshipEndpoint"
|
|
23
|
+
updateRel: "updateRelationshipEndpoint",
|
|
24
|
+
createRel: "createRelationshipEndpoint",
|
|
25
|
+
updateNode: "updateNodeEndpoint"
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
const TOPIC_NAME_GRAPH_HANDLER = {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
inUpdateRel: "InUpdateRelationship",
|
|
30
|
+
inCreateRel: "InCreateRelationshipV2",
|
|
31
|
+
outUpdateRel: "OutUpdateRelationship",
|
|
32
|
+
outCreateRel: "OutCreateRelationship",
|
|
33
|
+
inUpdateNode: "InUpdateNode",
|
|
34
|
+
outUpdateNode: "OutUpdateNode",
|
|
35
|
+
inCreateNode: "InCreateNode",
|
|
36
|
+
outCreateNode: "OutCreateNode"
|
|
29
37
|
}
|
|
30
38
|
|
|
31
39
|
const TOPIC_NAME_GENERATE_CODE = {
|
|
32
|
-
updateRelComplete: "UpdateRelationshipComplete"
|
|
40
|
+
updateRelComplete: "UpdateRelationshipComplete",
|
|
41
|
+
createRelComplete: "CreateRelationshipComplete",
|
|
42
|
+
outUpdateRelComplete: "OutUpdateRelationshipComplete",
|
|
43
|
+
outCreateRelComplete: "OutCreateRelationshipComplete",
|
|
44
|
+
updateNodeComplete: "UpdateNodeComplete",
|
|
45
|
+
outUpdateNodeComplete: "OutUpdateNodeComplete",
|
|
46
|
+
createNodeComplete: "CreateNodeComplete",
|
|
47
|
+
outCreateNodeComplete: "OutCreateNodeComplete"
|
|
33
48
|
}
|
|
34
49
|
|
|
35
50
|
|
|
@@ -59,6 +59,7 @@ const schemaFunctionPerAction = {
|
|
|
59
59
|
const explodeDataPerAction = {
|
|
60
60
|
[consts.ACTIONS.create]: explodedReqParams.explodedDataForCreate,
|
|
61
61
|
[consts.ACTIONS.get]: explodedReqParams.explodedDataForIdentifiers,
|
|
62
|
+
[consts.ACTIONS.update]: explodedReqParams.explodedDataForUpdate
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
|
|
@@ -526,27 +527,56 @@ function collectGetData(_izContext, getDataResult, getDataDetail) {
|
|
|
526
527
|
|
|
527
528
|
let collectedData = {};
|
|
528
529
|
|
|
530
|
+
// if (getDataDetail.storageType === consts.STORAGE_TYPES.graph) {
|
|
531
|
+
// // collect return data form main node only form properties
|
|
532
|
+
// if (getDataResult.properties) {
|
|
533
|
+
// for (let [mainFieldName, mainFieldNameValue] of Object.entries(getDataResult.properties)) {
|
|
534
|
+
// if (getDataDetail.fieldNames.includes(mainFieldName)) {
|
|
535
|
+
// Object.assign(collectedData, { [mainFieldName]: mainFieldNameValue });
|
|
536
|
+
// }
|
|
537
|
+
// }
|
|
538
|
+
// }
|
|
529
539
|
if (getDataDetail.storageType === consts.STORAGE_TYPES.graph) {
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
540
|
+
if (getDataResult.objInstance) {
|
|
541
|
+
for (let [identifiersField, identifiersValues] of Object.entries(getDataResult.objInstance)) {
|
|
542
|
+
for (let [mainFieldName, mainFieldNameValue] of Object.entries(identifiersValues)) {
|
|
543
|
+
Object.assign(collectedData, {
|
|
544
|
+
[getDataDetail.graphServiceTag]: {
|
|
545
|
+
objType: {
|
|
546
|
+
|
|
547
|
+
},
|
|
548
|
+
objInstance: {
|
|
549
|
+
[mainFieldName]: mainFieldNameValue
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
})
|
|
535
553
|
}
|
|
536
554
|
}
|
|
537
555
|
}
|
|
538
556
|
|
|
557
|
+
|
|
539
558
|
// collect data from versionedData
|
|
540
559
|
if (getDataDetail.hasOwnProperty("versionedDatas") && Object.keys(getDataDetail.versionedDatas).length) {
|
|
560
|
+
_izContext.logger.debug("getDataDetail has versionedData")
|
|
561
|
+
|
|
541
562
|
let versionedDataLabels = Object.keys(getDataDetail.versionedDatas);
|
|
542
563
|
|
|
543
564
|
for (let versionedDataLabel of versionedDataLabels) {
|
|
544
|
-
if (getDataResult[versionedDataLabel]?.nodeProperties && Object.keys(getDataResult[versionedDataLabel].nodeProperties).length) {
|
|
545
|
-
let neededVersionedDataFieldNames = getDataDetail.versionedDatas[versionedDataLabel];
|
|
546
565
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
566
|
+
_izContext.logger.debug(`per versionedData:${versionedDataLabel}`);
|
|
567
|
+
|
|
568
|
+
if (getDataResult.versionedDatas[versionedDataLabel]?.properties
|
|
569
|
+
&& Object.keys(getDataResult.versionedDatas[versionedDataLabel].properties).length
|
|
570
|
+
) {
|
|
571
|
+
|
|
572
|
+
_izContext.logger.debug(`has versionedData result:${versionedDataLabel}`);
|
|
573
|
+
|
|
574
|
+
// let neededVersionedDataFieldNames = Object.keys(getDataDetail.versionedDatas[versionedDataLabel]);
|
|
575
|
+
|
|
576
|
+
for (let neededVersionedDataFieldName of getDataDetail.versionedDatas[versionedDataLabel]) {
|
|
577
|
+
_izContext.logger.debug(`per needed versionedData fieldName:${versionedDataLabel}`);
|
|
578
|
+
if (getDataResult.versionedDatas[versionedDataLabel].properties.hasOwnProperty(neededVersionedDataFieldName)) {
|
|
579
|
+
Object.assign(collectedData, { [neededVersionedDataFieldName]: getDataResult.versionedDatas[versionedDataLabel].properties[neededVersionedDataFieldName] });
|
|
550
580
|
}
|
|
551
581
|
}
|
|
552
582
|
}
|
|
@@ -555,9 +585,17 @@ function collectGetData(_izContext, getDataResult, getDataDetail) {
|
|
|
555
585
|
|
|
556
586
|
} else if (getDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB) {
|
|
557
587
|
|
|
588
|
+
// for (let [dynamoDbKey, dynamoDbValue] of Object.entries(getDataResult)) {
|
|
589
|
+
// if (getDataDetail.fieldNames.includes(dynamoDbKey)) {
|
|
590
|
+
// Object.assign(collectedData, { [dynamoDbKey]: dynamoDbValue });
|
|
591
|
+
// }
|
|
592
|
+
// }
|
|
593
|
+
|
|
558
594
|
for (let [dynamoDbKey, dynamoDbValue] of Object.entries(getDataResult)) {
|
|
595
|
+
// _izContext.logger.debug("dynamoDbKey::", dynamoDbKey);
|
|
596
|
+
// _izContext.logger.debug("dynamoDbValue::", dynamoDbValue);
|
|
559
597
|
if (getDataDetail.fieldNames.includes(dynamoDbKey)) {
|
|
560
|
-
Object.assign(collectedData, { [dynamoDbKey]: dynamoDbValue });
|
|
598
|
+
Object.assign(collectedData, { [getDataDetail.tableName]: { [dynamoDbKey]: dynamoDbValue } });
|
|
561
599
|
}
|
|
562
600
|
}
|
|
563
601
|
|
|
@@ -568,7 +606,252 @@ function collectGetData(_izContext, getDataResult, getDataDetail) {
|
|
|
568
606
|
return collectedData
|
|
569
607
|
}
|
|
570
608
|
|
|
609
|
+
// old
|
|
610
|
+
// function collectGetData(_izContext, getDataResult, getDataDetail) {
|
|
611
|
+
|
|
612
|
+
// if (!getDataResult) {
|
|
613
|
+
// return {};
|
|
614
|
+
// }
|
|
615
|
+
|
|
616
|
+
// let collectedData = {};
|
|
617
|
+
|
|
618
|
+
// if (getDataDetail.storageType === consts.STORAGE_TYPES.graph) {
|
|
619
|
+
// // collect return data form main node
|
|
620
|
+
// if (getDataResult.nodeProperties) {
|
|
621
|
+
// for (let [mainFieldName, mainFieldNameValue] of Object.entries(getDataResult.nodeProperties)) {
|
|
622
|
+
// if (getDataDetail.fieldNames.includes(mainFieldName)) {
|
|
623
|
+
// Object.assign(collectedData, { [mainFieldName]: mainFieldNameValue });
|
|
624
|
+
// }
|
|
625
|
+
// }
|
|
626
|
+
// }
|
|
627
|
+
|
|
628
|
+
// // collect data from versionedData
|
|
629
|
+
// if (getDataDetail.hasOwnProperty("versionedDatas") && Object.keys(getDataDetail.versionedDatas).length) {
|
|
630
|
+
// let versionedDataLabels = Object.keys(getDataDetail.versionedDatas);
|
|
631
|
+
|
|
632
|
+
// for (let versionedDataLabel of versionedDataLabels) {
|
|
633
|
+
// if (getDataResult[versionedDataLabel]?.nodeProperties && Object.keys(getDataResult[versionedDataLabel].nodeProperties).length) {
|
|
634
|
+
// let neededVersionedDataFieldNames = getDataDetail.versionedDatas[versionedDataLabel];
|
|
635
|
+
|
|
636
|
+
// for (let neededVersionedDataFieldName of neededVersionedDataFieldNames) {
|
|
637
|
+
// if (getDataResult[versionedDataLabel].nodeProperties[neededVersionedDataFieldName]) {
|
|
638
|
+
// Object.assign(collectedData, { [neededVersionedDataFieldName]: getDataResult[versionedDataLabel].nodeProperties[neededVersionedDataFieldName] });
|
|
639
|
+
// }
|
|
640
|
+
// }
|
|
641
|
+
// }
|
|
642
|
+
// }
|
|
643
|
+
// }
|
|
644
|
+
|
|
645
|
+
// } else if (getDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB) {
|
|
646
|
+
|
|
647
|
+
// for (let [dynamoDbKey, dynamoDbValue] of Object.entries(getDataResult)) {
|
|
648
|
+
// if (getDataDetail.fieldNames.includes(dynamoDbKey)) {
|
|
649
|
+
// Object.assign(collectedData, { [dynamoDbKey]: dynamoDbValue });
|
|
650
|
+
// }
|
|
651
|
+
// }
|
|
652
|
+
|
|
653
|
+
// } else {
|
|
654
|
+
// throw new NoRetryError(`Unhandled storageType:${getDataDetail.storageType}`);
|
|
655
|
+
// }
|
|
656
|
+
|
|
657
|
+
// return collectedData
|
|
658
|
+
// }
|
|
659
|
+
|
|
660
|
+
async function createUpdateDataDetail(_izContext, objectSchema) {
|
|
661
|
+
let getGraphDataDetails = {};
|
|
662
|
+
let getDynamoDbDataDetails = {};
|
|
663
|
+
let allUpdateDataDetail = {};
|
|
664
|
+
for (let [storageTag, storageProperties] of Object.entries(objectSchema.storageResources)) {
|
|
665
|
+
let storageFieldNames = [];
|
|
666
|
+
for (let [fieldName, fieldNameProperties] of Object.entries(objectSchema.fieldNames)) {
|
|
667
|
+
if (fieldNameProperties.storageResourceTags.includes(storageTag)) {
|
|
668
|
+
storageFieldNames.push(fieldName)
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
if (storageProperties.storageType === consts.STORAGE_TYPES.graph) {
|
|
672
|
+
let graphStorageTagPerGraphServiceTag = {}
|
|
673
|
+
let useStorageTag = storageTag;
|
|
674
|
+
let graphServiceName = await serviceConfig.getGraphServiceTagWithCache(_izContext, storageProperties.graphServerTag)
|
|
675
|
+
if (!graphStorageTagPerGraphServiceTag.hasOwnProperty(graphServiceName)) {
|
|
676
|
+
graphStorageTagPerGraphServiceTag[graphServiceName] = storageTag;
|
|
677
|
+
_izContext.logger.debug("graphStorageTagPerGraphServiceTag", graphStorageTagPerGraphServiceTag)
|
|
678
|
+
} else {
|
|
679
|
+
_izContext.logger.debug("current storageTag", storageTag)
|
|
680
|
+
_izContext.logger.debug("used storageTag", useStorageTag)
|
|
681
|
+
useStorageTag = graphStorageTagPerGraphServiceTag[graphServiceName]
|
|
682
|
+
}
|
|
683
|
+
if (!getGraphDataDetails.hasOwnProperty(useStorageTag)) {
|
|
684
|
+
getGraphDataDetails[graphServiceName] =
|
|
685
|
+
{
|
|
686
|
+
storageType: storageProperties.storageType,
|
|
687
|
+
fieldNames: storageFieldNames
|
|
688
|
+
}
|
|
689
|
+
} else {
|
|
690
|
+
getGraphDataDetails[graphServiceName].fieldNames = [...new Set(getGraphDataDetails[useStorageTag].fieldNames.concat(storageFieldNames))]
|
|
691
|
+
}
|
|
692
|
+
} else if (storageProperties.storageType === consts.STORAGE_TYPES.dynamoDB) {
|
|
693
|
+
|
|
694
|
+
Object.assign(getDynamoDbDataDetails, {
|
|
695
|
+
[storageTag]: {
|
|
696
|
+
storageType: storageProperties.storageType,
|
|
697
|
+
tableName: storageProperties.tableName,
|
|
698
|
+
fieldNames: storageFieldNames
|
|
699
|
+
}
|
|
700
|
+
})
|
|
701
|
+
|
|
702
|
+
if (storageTag.groupByPartitionKeyField) {
|
|
703
|
+
Object.assign(
|
|
704
|
+
getDynamoDbDataDetails[storageTag],
|
|
705
|
+
{
|
|
706
|
+
groupByPartitionKeyField: storageProperties.groupByPartitionKeyField
|
|
707
|
+
}
|
|
708
|
+
)
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
_izContext.logger.debug("getGraphDataDetails", getGraphDataDetails);
|
|
714
|
+
_izContext.logger.debug("getDynamoDataDetail", getDynamoDbDataDetails);
|
|
715
|
+
_izContext.logger.debug("allUpdateDataDetail", allUpdateDataDetail)
|
|
716
|
+
|
|
717
|
+
Object.assign(allUpdateDataDetail, getDynamoDbDataDetails, getGraphDataDetails)
|
|
718
|
+
|
|
719
|
+
return allUpdateDataDetail
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
async function createDataDetailsLib(
|
|
723
|
+
_izContext,
|
|
724
|
+
objectSchemas
|
|
725
|
+
) {
|
|
726
|
+
_izContext.logger.debug("Lib: createDataDetailsLib:", { objectSchemas: objectSchemas });
|
|
727
|
+
|
|
728
|
+
let createDataDetails = {};
|
|
729
|
+
|
|
730
|
+
let storageResources = objectSchemas.storageResources;
|
|
731
|
+
_izContext.logger.debug("storageResources:", storageResources);
|
|
732
|
+
|
|
733
|
+
for (let [keyFieldName, settingFieldName] of Object.entries(objectSchemas.fieldNames)) {
|
|
734
|
+
// _izContext.logger.debug("Loop fieldNamesObjectSchemas", { keyFieldName });
|
|
735
|
+
|
|
736
|
+
// check fiend is identifier
|
|
737
|
+
if (objectSchemas.identifierFieldNames.includes(keyFieldName)) {
|
|
738
|
+
continue
|
|
739
|
+
};
|
|
740
|
+
// validate storageResourceTags.
|
|
741
|
+
_izContext.logger.debug("storageResourceTags is", settingFieldName.storageResourceTags);
|
|
742
|
+
|
|
743
|
+
for (let eachStorageResourceTags of settingFieldName.storageResourceTags) {
|
|
744
|
+
_izContext.logger.debug("Loop eachStorageResourceTags", eachStorageResourceTags);
|
|
571
745
|
|
|
746
|
+
if (!storageResources.hasOwnProperty(eachStorageResourceTags)) {
|
|
747
|
+
throw new Error("storageResources is'n exist"); // should be validata in step uplode in s3
|
|
748
|
+
} else {
|
|
749
|
+
|
|
750
|
+
if (storageResources[eachStorageResourceTags].storageType == consts.STORAGE_TYPES.dynamoDB) {
|
|
751
|
+
if (createDataDetails.hasOwnProperty(eachStorageResourceTags)) {
|
|
752
|
+
_izContext.logger.debug("SAME STG DB", eachStorageResourceTags);
|
|
753
|
+
createDataDetails[eachStorageResourceTags].fieldNames.push(keyFieldName);
|
|
754
|
+
|
|
755
|
+
} else {
|
|
756
|
+
_izContext.logger.debug("NEW STG DB", eachStorageResourceTags);
|
|
757
|
+
Object.assign(createDataDetails, {
|
|
758
|
+
[eachStorageResourceTags]: {
|
|
759
|
+
storageType: consts.STORAGE_TYPES.dynamoDB,
|
|
760
|
+
tableName: storageResources[eachStorageResourceTags].tableName,
|
|
761
|
+
fieldNames: [keyFieldName]
|
|
762
|
+
}
|
|
763
|
+
});
|
|
764
|
+
|
|
765
|
+
if (storageResources[eachStorageResourceTags].hasOwnProperty("groupByPartitionKeyField")) {
|
|
766
|
+
Object.assign(createDataDetails[eachStorageResourceTags], {
|
|
767
|
+
groupByPartitionKeyField: storageResources[eachStorageResourceTags].groupByPartitionKeyField
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
} else if (storageResources[eachStorageResourceTags].storageType == consts.STORAGE_TYPES.graph) {
|
|
773
|
+
let checkGraphServerTags = await serviceConfigLib.getGraphServiceTag(
|
|
774
|
+
_izContext,
|
|
775
|
+
storageResources[eachStorageResourceTags].graphServerTag
|
|
776
|
+
);
|
|
777
|
+
if (checkGraphServerTags) {
|
|
778
|
+
if (createDataDetails.hasOwnProperty(checkGraphServerTags)) {
|
|
779
|
+
_izContext.logger.debug("SAME STG", checkGraphServerTags);
|
|
780
|
+
createDataDetails[checkGraphServerTags].fieldNames.push(keyFieldName)
|
|
781
|
+
|
|
782
|
+
} else {
|
|
783
|
+
_izContext.logger.debug("NEW STG", checkGraphServerTags);
|
|
784
|
+
Object.assign(createDataDetails, {
|
|
785
|
+
[checkGraphServerTags]: {
|
|
786
|
+
storageType: consts.STORAGE_TYPES.graph,
|
|
787
|
+
fieldNames: [keyFieldName]
|
|
788
|
+
}
|
|
789
|
+
});
|
|
790
|
+
};
|
|
791
|
+
};
|
|
792
|
+
};
|
|
793
|
+
};
|
|
794
|
+
}; // end loop storageResourceTags
|
|
795
|
+
|
|
796
|
+
}; // end loop
|
|
797
|
+
_izContext.logger.debug("_______All createDataDetails_____", createDataDetails);
|
|
798
|
+
return createDataDetails;
|
|
799
|
+
};
|
|
800
|
+
|
|
801
|
+
async function createCreateDataDetailsV2(_izContext, objectSchema) {
|
|
802
|
+
let allCreateDataDetail = {};
|
|
803
|
+
let graphDataDetail = {};
|
|
804
|
+
let dynamoDbDataDetail = {};
|
|
805
|
+
|
|
806
|
+
for (let [storageTag, storageProperties] of Object.entries(objectSchema.storageResources)) {
|
|
807
|
+
let storageFieldNames = [];
|
|
808
|
+
if (consts.STORAGE_TYPES.hasOwnProperty(storageProperties.storageType)) {
|
|
809
|
+
for (let [fieldName, fieldNameProperties] of Object.entries(objectSchema.fieldNames)) {
|
|
810
|
+
if (fieldNameProperties.storageResourceTags.includes(storageTag)) {
|
|
811
|
+
storageFieldNames.push(fieldName);
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
if (storageProperties.storageType === consts.STORAGE_TYPES.graph) {
|
|
815
|
+
let graphStorageTagPerGraphServiceTag = {};
|
|
816
|
+
let useStorageTag = storageTag;
|
|
817
|
+
let graphServiceName = await serviceConfig.getGraphServiceTagWithCache(_izContext, storageProperties.graphServerTag)
|
|
818
|
+
if (!graphStorageTagPerGraphServiceTag.hasOwnProperty(graphServiceName)) {
|
|
819
|
+
graphStorageTagPerGraphServiceTag[graphServiceName] = storageTag;
|
|
820
|
+
} else {
|
|
821
|
+
useStorageTag = graphStorageTagPerGraphServiceTag[graphServiceName]
|
|
822
|
+
}
|
|
823
|
+
if (!graphDataDetail.hasOwnProperty(useStorageTag)) {
|
|
824
|
+
graphDataDetail[graphServiceName] = {
|
|
825
|
+
storageType: storageProperties.storageType,
|
|
826
|
+
fieldNames: storageFieldNames
|
|
827
|
+
}
|
|
828
|
+
} else {
|
|
829
|
+
graphDataDetail[graphServiceName].fieldNames = [new Set(graphDataDetail[useStorageTag].fieldNames.concat(storageFieldNames))]
|
|
830
|
+
}
|
|
831
|
+
} else if (storageProperties.storageType === consts.STORAGE_TYPES.dynamoDB) {
|
|
832
|
+
Object.assign(dynamoDbDataDetail, {
|
|
833
|
+
[storageTag]: {
|
|
834
|
+
storageType: storageProperties.storageType,
|
|
835
|
+
tableName: storageProperties.tableName,
|
|
836
|
+
fieldNames: storageFieldNames
|
|
837
|
+
}
|
|
838
|
+
})
|
|
839
|
+
|
|
840
|
+
if (storageTag.groupByPartitionKeyField) {
|
|
841
|
+
Object.assign(
|
|
842
|
+
dynamoDbDataDetail[storageTag], {
|
|
843
|
+
groupByPartitionKeyField: storageProperties.groupByPartitionKeyField
|
|
844
|
+
}
|
|
845
|
+
)
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
_izContext.logger.debug("storageFieldNames")
|
|
850
|
+
};
|
|
851
|
+
Object.assign(allCreateDataDetail, graphDataDetail, dynamoDbDataDetail)
|
|
852
|
+
_izContext.logger.debug("allCreateDataDetail before return ::", allCreateDataDetail)
|
|
853
|
+
return allCreateDataDetail
|
|
854
|
+
}
|
|
572
855
|
|
|
573
856
|
|
|
574
857
|
module.exports = {
|
|
@@ -582,7 +865,10 @@ module.exports = {
|
|
|
582
865
|
generateDynamoDbIdentifiers,
|
|
583
866
|
generateDynamoDbIdentifiersWithCache,
|
|
584
867
|
dynamoDbIdentifiersByStorageResource,
|
|
585
|
-
collectGetData
|
|
868
|
+
collectGetData,
|
|
869
|
+
createUpdateDataDetail,
|
|
870
|
+
createDataDetailsLib,
|
|
871
|
+
createCreateDataDetailsV2
|
|
586
872
|
}
|
|
587
873
|
|
|
588
874
|
|
|
@@ -0,0 +1,89 @@
|
|
|
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
|
+
'use strict';
|
|
19
|
+
const getObjectSchema = require("@izara_project/izara-core-library-service-schemas/src/GetObjectSchema")
|
|
20
|
+
const identifiersObject = require("@izara_project/izara-core-library-service-schemas/src/IdentifiersObject")
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param {object} fromType
|
|
24
|
+
* @param {string} fromType.objectType
|
|
25
|
+
* @param {string} fromType.serviceTag
|
|
26
|
+
* @param {object} toType
|
|
27
|
+
* @param {string} toType.objectType
|
|
28
|
+
* @param {string} toType.serviceTag
|
|
29
|
+
* @param {object} relType
|
|
30
|
+
* @param {string} relType.relationshipTag
|
|
31
|
+
* @param {string} relType.serviceTag
|
|
32
|
+
* @returns {boolean}
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
async function validateFromTypeToToTypeWithRelType(_izContext, fromType, toType, relType) {
|
|
36
|
+
let validateStatus;
|
|
37
|
+
let relationshipSchema = await getObjectSchema.getRelationshipSchemaWithCache(_izContext, relType);
|
|
38
|
+
let fromObjType = relationshipSchema.links[0].from.objType
|
|
39
|
+
let toObjType = relationshipSchema.links[0].to.objType
|
|
40
|
+
|
|
41
|
+
if (fromObjType.objectType === fromType.objectType &&
|
|
42
|
+
toObjType.objectType === toType.objectType &&
|
|
43
|
+
toObjType.serviceTag === toType.serviceTag) {
|
|
44
|
+
validateStatus = true
|
|
45
|
+
} else {
|
|
46
|
+
validateStatus = false
|
|
47
|
+
}
|
|
48
|
+
return validateStatus
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function validateObjtypesAndRelType(
|
|
52
|
+
_izContext,
|
|
53
|
+
objTypes,
|
|
54
|
+
relType,
|
|
55
|
+
) {
|
|
56
|
+
_izContext.logger.debug("findRelationshipLink: ", {
|
|
57
|
+
objTypes,
|
|
58
|
+
relType
|
|
59
|
+
})
|
|
60
|
+
let relationshipSchema = await getObjectSchema.getRelationshipSchemaWithCache(_izContext, relType)
|
|
61
|
+
|
|
62
|
+
const { serviceTag: firstServiceTag, objectType: firstObjectType } = objTypes[0]
|
|
63
|
+
const { serviceTag: secondServiceTag, objectType: secondObjectType } = objTypes[1]
|
|
64
|
+
|
|
65
|
+
for (const link of relationshipSchema.links) {
|
|
66
|
+
const { serviceTag: fromServiceTag, objectType: fromObjectType } = link.from.objType;
|
|
67
|
+
const { serviceTag: toServiceTag, objectType: toObjectType } = link.to.objType;
|
|
68
|
+
|
|
69
|
+
if (firstObjectType && secondObjectType) {
|
|
70
|
+
// create direction incoming or outgoing
|
|
71
|
+
if (
|
|
72
|
+
(firstServiceTag === fromServiceTag && firstObjectType === fromObjectType
|
|
73
|
+
&& secondServiceTag === toServiceTag && secondObjectType === toObjectType)
|
|
74
|
+
||
|
|
75
|
+
(secondServiceTag === fromServiceTag && secondObjectType === fromObjectType
|
|
76
|
+
&& firstServiceTag === toServiceTag && firstObjectType === toObjectType)
|
|
77
|
+
) {
|
|
78
|
+
return link
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
module.exports = {
|
|
87
|
+
validateFromTypeToToTypeWithRelType,
|
|
88
|
+
validateObjtypesAndRelType
|
|
89
|
+
}
|
|
@@ -24,4 +24,14 @@ module.exports.firstLetterUpperCase = (text) => {
|
|
|
24
24
|
|
|
25
25
|
module.exports.firstLetterLowerCase = (str) => {
|
|
26
26
|
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports.checkOverWriteGenerateMainFunction = (objectSchema, action) => {
|
|
30
|
+
let overWriteStatus;
|
|
31
|
+
if (objectSchema.overwriteGenerateMainFunction?.length && objectSchema.overwriteGenerateMainFunction.includes(action)) {
|
|
32
|
+
overWriteStatus = true
|
|
33
|
+
} else {
|
|
34
|
+
overWriteStatus = false
|
|
35
|
+
}
|
|
36
|
+
return overWriteStatus
|
|
27
37
|
}
|
package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrApi/data.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
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
|
+
'use strict';
|
|
19
|
+
const path = require('path');
|
|
20
|
+
const fs = require('fs');
|
|
21
|
+
|
|
22
|
+
const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
23
|
+
|
|
24
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils")
|
|
25
|
+
const { DEFAULT_HANDLER_PER_ACTION, createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SQS_RESOURCE, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, SNS_RESOURCE, DYNAMO_RESOURCE } = require("../../../../libs/Consts");
|
|
26
|
+
|
|
27
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
28
|
+
|
|
29
|
+
function defaultIamRolePerAction() {
|
|
30
|
+
|
|
31
|
+
let defaultIamRole = [];
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
defaultIamRole.push(
|
|
35
|
+
createIamRole(
|
|
36
|
+
{
|
|
37
|
+
[RESOURCE_CLASSES.s3]: ["GetObject", "GetObjectVersion"],
|
|
38
|
+
},
|
|
39
|
+
[
|
|
40
|
+
resourceNames(RESOURCE_CLASSES.s3, "object-schema/perServiceSchemas/*"),
|
|
41
|
+
resourceNames(RESOURCE_CLASSES.s3, "object-schema/serviceConfig/ServiceNameConfig.json"),
|
|
42
|
+
resourceNames(RESOURCE_CLASSES.s3, "object-schema/serviceConfig/GraphServerTags.json"),
|
|
43
|
+
]
|
|
44
|
+
)
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
defaultIamRole.push(
|
|
48
|
+
createIamRole(
|
|
49
|
+
{ [RESOURCE_CLASSES.s3]: ["ListBucket"] },
|
|
50
|
+
[
|
|
51
|
+
resourceNames(RESOURCE_CLASSES.s3, "object-schema"),
|
|
52
|
+
]
|
|
53
|
+
)
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
return defaultIamRole
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* receive objectSchema
|
|
61
|
+
* create data for updateRelationshipSchema
|
|
62
|
+
*
|
|
63
|
+
* @param {Object} objectSchema
|
|
64
|
+
* @return {{ templatePath, templateData, setting } }
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
function data(_izContext, srcPath) {
|
|
68
|
+
let createSourceArray = [];
|
|
69
|
+
|
|
70
|
+
const createSourceParam = createParamForCreateSource(srcPath);
|
|
71
|
+
createSourceArray.push(createSourceParam);
|
|
72
|
+
// console.log("createSourceArrayInUpdaterelationShipSchemahdrSqs", createSourceArray)
|
|
73
|
+
return createSourceArray
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
function createParamForCreateSource(srcPath) {
|
|
78
|
+
|
|
79
|
+
let handlerType = HANDLER.hdrApi
|
|
80
|
+
let functionName = FUNCTION_NAME.createRel
|
|
81
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
82
|
+
|
|
83
|
+
additionalResourcePermission.push(
|
|
84
|
+
createIamRole(
|
|
85
|
+
{ [RESOURCE_CLASSES.dynamoDbTable]: [DYNAMO_RESOURCE.putItem] },
|
|
86
|
+
[
|
|
87
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "AwaitingMultipleSteps"),
|
|
88
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "AwaitingMultipleStepByPending")
|
|
89
|
+
]
|
|
90
|
+
))
|
|
91
|
+
|
|
92
|
+
additionalResourcePermission.push(
|
|
93
|
+
createIamRole(
|
|
94
|
+
{
|
|
95
|
+
[RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
|
|
96
|
+
},
|
|
97
|
+
resourceNames(RESOURCE_CLASSES.sns, "Out" + upperCase(FUNCTION_NAME.createRelComplete))
|
|
98
|
+
)
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
templatePath: templatePath,
|
|
103
|
+
templateData: {
|
|
104
|
+
functionName,
|
|
105
|
+
handlerType,
|
|
106
|
+
additionalResourcePermission,
|
|
107
|
+
resourceLocation: SOURCE_PATH.resourceLocationUpdateRelationshipSchema
|
|
108
|
+
},
|
|
109
|
+
setting: {
|
|
110
|
+
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
111
|
+
saveFileName: SAVE_FILE_NAME.functionRelationshipYaml,
|
|
112
|
+
fileExtension: '.yml',
|
|
113
|
+
isAppend: true
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
module.exports = data;
|