@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
|
@@ -0,0 +1,67 @@
|
|
|
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 } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
23
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase } = require("../../../../../MainLibs/src/Utils")
|
|
24
|
+
const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH } = require("../../../libs/Consts");
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* receive objectSchema
|
|
31
|
+
* create data for hdrInv template
|
|
32
|
+
*
|
|
33
|
+
* @param {Object} objectSchema
|
|
34
|
+
* @return {{ templatePath, templateData, setting } }
|
|
35
|
+
*/
|
|
36
|
+
async function data(_izContext, objectSchema, srcPath) {
|
|
37
|
+
if (objectSchema.overwriteGeneratedMainFunction?.length
|
|
38
|
+
&& objectSchema.overwriteGeneratedMainFunction.includes(ACTIONS.create)
|
|
39
|
+
) {
|
|
40
|
+
return [];
|
|
41
|
+
} else {
|
|
42
|
+
return [await createParamForCreateSource(_izContext, objectSchema, ACTIONS.create, srcPath)]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function createParamForCreateSource(_izContext, objectSchema, action, srcPath) {
|
|
47
|
+
let objectType = objectSchema.objectType;
|
|
48
|
+
let actionHandler = action;
|
|
49
|
+
let functionName = objectType + upperCase(action);
|
|
50
|
+
return {
|
|
51
|
+
templatePath: templatePath,
|
|
52
|
+
templateData: {
|
|
53
|
+
functionName: functionName,
|
|
54
|
+
objectType: objectType,
|
|
55
|
+
actionHandler: actionHandler,
|
|
56
|
+
},
|
|
57
|
+
setting: {
|
|
58
|
+
savePath: path.join(srcPath, SOURCE_PATH.lambdaPerAction),
|
|
59
|
+
saveFileName: `${upperCase(objectSchema.objectType)}${upperCase(action)}_Main`,
|
|
60
|
+
fileExtension: '.js',
|
|
61
|
+
isAppend: false
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
module.exports = data;
|
|
File without changes
|
|
@@ -0,0 +1,581 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2021 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 asyncFlowSharedLib = require('@izara_project/izara-shared/src/AsyncFlowSharedLib');
|
|
20
|
+
const dynamodbSharedLib = require('@izara_project/izara-shared/src/DynamodbSharedLib');
|
|
21
|
+
const lambdaSharedLib = require('@izara_project/izara-shared/src/LambdaSharedLib')
|
|
22
|
+
const callingFlowSharedLib = require('@izara_project/izara-shared/src/CallingFlowSharedLib');
|
|
23
|
+
|
|
24
|
+
const sns = require('@izara_project/izara-core-library-external-request/src/resources/Sns');
|
|
25
|
+
const snsSharedLib = require('@izara_project/izara-shared/src/SnsSharedLib');
|
|
26
|
+
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
|
|
27
|
+
const serviceConfigLib = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig')
|
|
28
|
+
|
|
29
|
+
const uploadUseCase = require('@izara_project/izara-core-library-service-schemas/src/libs/UploadUseCase')
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
const hash = require("object-hash")
|
|
33
|
+
const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
|
|
34
|
+
const path = require('path')
|
|
35
|
+
const schemasPath = path.join(__dirname, '../schemas');
|
|
36
|
+
const consts = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
37
|
+
const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
|
|
38
|
+
|
|
39
|
+
const {
|
|
40
|
+
generateDynamoDbIdentifiers,
|
|
41
|
+
dynamoDbIdentifiersByStorageResource,
|
|
42
|
+
collectGetData
|
|
43
|
+
} = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
|
|
44
|
+
|
|
45
|
+
const {
|
|
46
|
+
getGraphServiceTagWithCache,
|
|
47
|
+
getServiceNameWithCache
|
|
48
|
+
} = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig');
|
|
49
|
+
|
|
50
|
+
//-----------------------------------------------------------------------------------------------------------
|
|
51
|
+
const PREFIX = {
|
|
52
|
+
ONE: "one",
|
|
53
|
+
MANY: "many",
|
|
54
|
+
CREATE_OBJECT_ASYNC: "createObjectAsync",
|
|
55
|
+
CREATE_OBJECT_ASYNC_COMPLETE: "createObjectAsyncComplete"
|
|
56
|
+
}
|
|
57
|
+
//-----------------------------------------------------------------------------------------------------------
|
|
58
|
+
|
|
59
|
+
const { createDataDetailsLib } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs')
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
- all storageType( DB and Graph) use objInstance({identifiers,fields})
|
|
63
|
+
- storageType[DB] async
|
|
64
|
+
- storageType[Graph] sync (should be have lambda complete)
|
|
65
|
+
-- before DB and Graph have boolend check (allStorageTagComplete = true) if storageType == graph set allStorageTagComplete = false,
|
|
66
|
+
and save awaitingMultiplastep prefix(serviceTag_CreateObject{identifierId})
|
|
67
|
+
|
|
68
|
+
>>> in lambdaComplete resive message from GrapHandler
|
|
69
|
+
1.1 check have returnValue.errorsFould.length > 0
|
|
70
|
+
-- Delete all awitingMultiplestep and senf message to callingFlow have errorFound.
|
|
71
|
+
1.2 check awaitingmultipleStepall finish
|
|
72
|
+
-- Delete awaitingStep in come if have other multiplestep(not finish)== not send message.
|
|
73
|
+
--- if check awaitingmultipleStepall finish not have record ===> sendmessage to callingFlow.
|
|
74
|
+
*/
|
|
75
|
+
//=========================================================================================
|
|
76
|
+
/**
|
|
77
|
+
*
|
|
78
|
+
* @param {*} _izContext
|
|
79
|
+
* @param {Object} requestParams = {fieldNames,relationships = []}
|
|
80
|
+
* @param {*} callingFlowConfig
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
module.exports.<%- functionName %>Main = async (
|
|
84
|
+
_izContext,
|
|
85
|
+
requestParams,
|
|
86
|
+
callingFlowConfig
|
|
87
|
+
) => {
|
|
88
|
+
try {
|
|
89
|
+
_izContext.logger.debug("function <%- functionName %>:", {
|
|
90
|
+
requestParams,
|
|
91
|
+
callingFlowConfig
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
_izContext.correlationIds.set(coreConsts.BASE_USER_ID, "BasDev");
|
|
95
|
+
|
|
96
|
+
const OBJECT_TYPE = "<%- objectType %>";
|
|
97
|
+
const SERVICE_TAG = process.env.iz_serviceTag;
|
|
98
|
+
//(<beforeQuery>)
|
|
99
|
+
//(</beforeQuery>)
|
|
100
|
+
|
|
101
|
+
const MAIN_OBJTYPE = {
|
|
102
|
+
objectType: OBJECT_TYPE,
|
|
103
|
+
serviceTag: SERVICE_TAG
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
let objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(
|
|
107
|
+
_izContext,
|
|
108
|
+
{
|
|
109
|
+
objectType: OBJECT_TYPE,
|
|
110
|
+
serviceTag: SERVICE_TAG
|
|
111
|
+
},
|
|
112
|
+
);
|
|
113
|
+
_izContext.logger.debug("objectSchema:", objectSchema)
|
|
114
|
+
|
|
115
|
+
let objectSchemas = uploadUseCase.generateObjectSchemaForGraphHandler(
|
|
116
|
+
_izContext,
|
|
117
|
+
objectSchema
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
let createDataDetails = await createCreateDataDetailsV2(_izContext, objectSchemas);
|
|
121
|
+
_izContext.logger.debug("createDataDetails is =", createDataDetails);
|
|
122
|
+
|
|
123
|
+
let objInstance = {
|
|
124
|
+
identifiers: {},
|
|
125
|
+
fields: {}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
let listOfRequriedOnCreate = [];
|
|
129
|
+
let listOfOptionalOnCreate = [];
|
|
130
|
+
|
|
131
|
+
let allAwaitingStepsId = [];
|
|
132
|
+
let errorsFound = [];
|
|
133
|
+
|
|
134
|
+
if (objectSchemas.identifiers.length === 1 && !identifier.hasOwnProperty("fieldNames")) {
|
|
135
|
+
|
|
136
|
+
const identifier = objectSchemas.identifiers[0];
|
|
137
|
+
_izContext.logger.debug(":::::case single identifer:::::", identifier);
|
|
138
|
+
|
|
139
|
+
if (objectSchemas.fieldNames[identifier.fieldName].hasOwnProperty("randomOnCreate")) {
|
|
140
|
+
|
|
141
|
+
if ((objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == true)) {
|
|
142
|
+
if ((objectSchemas.fieldNames[identifier.fieldName].requiredOnCreate == false) &&
|
|
143
|
+
(objectSchemas.fieldNames[identifier.fieldName].optionalOnCreate == false) &&
|
|
144
|
+
(objectSchemas.fieldNames[identifier.fieldName].canUpdate == false)
|
|
145
|
+
) {
|
|
146
|
+
|
|
147
|
+
Object.assign(requestParams.fieldNames, {
|
|
148
|
+
[identifier.fieldName]: hash({
|
|
149
|
+
fieldNames: identifier, //
|
|
150
|
+
uniqueRequestId: _izContext.uniqueRequestId,
|
|
151
|
+
callingFlowConfig: callingFlowConfig
|
|
152
|
+
})
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
} else if ((objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == false)) {
|
|
158
|
+
|
|
159
|
+
if ((objectSchemas.fieldNames[identifier.fieldName].requiredOnCreate == true) &&
|
|
160
|
+
((objectSchemas.fieldNames[identifier.fieldName].optionalOnCreate == false) || objectSchemas.fieldNames[identifier.fieldName].optionalOnCreate == true) &&
|
|
161
|
+
(objectSchemas.fieldNames[identifier.fieldName].canUpdate == false)) {
|
|
162
|
+
// check Fns have resive
|
|
163
|
+
|
|
164
|
+
if (requestParams.fieldNames.hasOwnProperty([identifier.fieldName])) {
|
|
165
|
+
_izContext.logger.debug("identifier is exist:", {
|
|
166
|
+
[identifier.fieldName]: requestParams.fieldNames[identifier.fieldName]
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
} else {
|
|
170
|
+
errorsFound.push("[invalid]requestParams not have data fieldNames of requriedOnCreate");
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
} else {
|
|
175
|
+
if ((objectSchemas.fieldNames[identifier.fieldName].requiredOnCreate == false) &&
|
|
176
|
+
(objectSchemas.fieldNames[identifier.fieldName].optionalOnCreate == false) &&
|
|
177
|
+
(objectSchemas.fieldNames[identifier.fieldName].canUpdate == false)) {
|
|
178
|
+
errorsFound.push("[invalid]case single identifier invalid objectSchemass");
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
_izContext.logger.debug("requestParams is:", requestParams);
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
// check settingObjSchemas
|
|
189
|
+
for (let [keyFieldNames, valueFieldNames] of Object.entries(objectSchemas.fieldNames)) {
|
|
190
|
+
|
|
191
|
+
if (valueFieldNames.hasOwnProperty("randomOnCreate") && valueFieldNames.randomOnCreate === true) {
|
|
192
|
+
listOfRequriedOnCreate.push(keyFieldNames)
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
if (valueFieldNames.hasOwnProperty("requiredOnCreate") && valueFieldNames.requiredOnCreate === true) {
|
|
196
|
+
listOfRequriedOnCreate.push(keyFieldNames)
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
if (valueFieldNames.hasOwnProperty("optionalOnCreate") && valueFieldNames.optionalOnCreate === true) {
|
|
200
|
+
if ((valueFieldNames.requiredOnCreate === false) && valueFieldNames.optionalOnCreate === true) {
|
|
201
|
+
listOfOptionalOnCreate.push(keyFieldNames)
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
}; // end iteration of fieldNames
|
|
206
|
+
|
|
207
|
+
for (let fieldName of Object.keys(requestParams.fieldNames)) {
|
|
208
|
+
|
|
209
|
+
if (!listOfRequriedOnCreate.includes(fieldName)) {
|
|
210
|
+
if (!listOfOptionalOnCreate.includes(fieldName)) {
|
|
211
|
+
errorsFound.push("[invalid] over fieldNames create object");
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
if (listOfOptionalOnCreate.length > 0 && listOfRequriedOnCreate.includes(fieldName)) {
|
|
216
|
+
// HookCode
|
|
217
|
+
// HookCode
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
/*
|
|
221
|
+
fix version if change objInstance initial
|
|
222
|
+
can delete condition if (listOfRequriedOnCreate.includes(fieldName))
|
|
223
|
+
*/
|
|
224
|
+
|
|
225
|
+
// if (objectSchemas.identifierFieldNames.includes(fieldName)) {
|
|
226
|
+
// _izContext.logger.debug("identifiers is", fieldName);
|
|
227
|
+
// Object.assign(objInstance.identifiers, {
|
|
228
|
+
// [fieldName]: requestParams.fieldNames[fieldName]
|
|
229
|
+
// });
|
|
230
|
+
// };
|
|
231
|
+
|
|
232
|
+
if (errorsFound.length > 0) {
|
|
233
|
+
_izContext.logger.debug("HaveError::", errorsFound);
|
|
234
|
+
break
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
}; // end loop
|
|
238
|
+
|
|
239
|
+
let listOfObjectForCreates = [];
|
|
240
|
+
let serviceName;
|
|
241
|
+
let createDataDetail;
|
|
242
|
+
if (errorsFound.length == 0) {
|
|
243
|
+
|
|
244
|
+
for ([serviceName, createDataDetail] of Object.entries(createDataDetails)) {
|
|
245
|
+
|
|
246
|
+
for (let fieldNames of Object.keys(requestParams.fieldNames)) {
|
|
247
|
+
|
|
248
|
+
if (createDataDetail.fieldNames.includes(fieldNames) && listOfRequriedOnCreate.includes(fieldNames)) {
|
|
249
|
+
_izContext.logger.debug("fieldNames match in detail is:", fieldNames);
|
|
250
|
+
|
|
251
|
+
if (objInstance.hasOwnProperty("fields")) {
|
|
252
|
+
Object.assign(objInstance.fields, {
|
|
253
|
+
[fieldNames]: requestParams.fieldNames[fieldNames]
|
|
254
|
+
})
|
|
255
|
+
} else {
|
|
256
|
+
Object.assign(objInstance, {
|
|
257
|
+
fields: {
|
|
258
|
+
[fieldNames]: requestParams.fieldNames[fieldNames]
|
|
259
|
+
}
|
|
260
|
+
})
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
if (createDataDetail.storageType == consts.STORAGE_TYPES.dynamoDB) {
|
|
266
|
+
_izContext.logger.debug("::::::DynamoDB::::::", { serviceName, objInstance });
|
|
267
|
+
|
|
268
|
+
let identifiersForCreateData = await dynamoDbIdentifiersByStorageResource(
|
|
269
|
+
_izContext,
|
|
270
|
+
objectSchema,
|
|
271
|
+
createDataDetails,
|
|
272
|
+
requestParams.fieldNames
|
|
273
|
+
)
|
|
274
|
+
_izContext.logger.debug("identifiersForCreateData", identifiersForCreateData);
|
|
275
|
+
|
|
276
|
+
await dynamodbSharedLib.putItem(
|
|
277
|
+
_izContext,
|
|
278
|
+
await dynamodbSharedLib.tableName(
|
|
279
|
+
_izContext,
|
|
280
|
+
createDataDetail.tableName
|
|
281
|
+
),
|
|
282
|
+
identifiersForCreateData
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
} else if (createDataDetail.storageType == consts.STORAGE_TYPES.graph) {
|
|
287
|
+
_izContext.logger.debug("::::::Graphanler::::::", { serviceName, objInstance });
|
|
288
|
+
|
|
289
|
+
// allStorageTagComplete = false;
|
|
290
|
+
allAwaitingStepsId.push(asyncFlowSharedLib.createAwaitingStepId(
|
|
291
|
+
(hash({
|
|
292
|
+
objType: MAIN_OBJTYPE,
|
|
293
|
+
graphServerTag: serviceName,
|
|
294
|
+
identifiers: objInstance.identifiers
|
|
295
|
+
})),
|
|
296
|
+
PREFIX.CREATE_OBJECT_ASYNC
|
|
297
|
+
));
|
|
298
|
+
listOfObjectForCreates.push({
|
|
299
|
+
[serviceName]: {
|
|
300
|
+
objInstance: {
|
|
301
|
+
identifiers: objInstance.identifiers,
|
|
302
|
+
fields: objInstance.fields
|
|
303
|
+
},
|
|
304
|
+
allStorageTagComplete: false
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
_izContext.logger.debug("FIRST", listOfObjectForCreates)
|
|
309
|
+
|
|
310
|
+
};
|
|
311
|
+
_izContext.logger.debug("[1]listOfObjectForCreates:::", listOfObjectForCreates);
|
|
312
|
+
|
|
313
|
+
delete objInstance.fields
|
|
314
|
+
};
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
/// step save awiatingMultipleStep of storageType graph ...........................................................
|
|
318
|
+
|
|
319
|
+
await asyncFlowSharedLib.createAwaitingMultipleSteps(
|
|
320
|
+
_izContext,
|
|
321
|
+
allAwaitingStepsId,
|
|
322
|
+
asyncFlowSharedLib.createPendingStepId((hash({ objType: MAIN_OBJTYPE, identifiers: objInstance.identifiers })), PREFIX.CREATE_OBJECT_ASYNC_COMPLETE)
|
|
323
|
+
);
|
|
324
|
+
//............................................................................................................
|
|
325
|
+
|
|
326
|
+
// process storageType : graph
|
|
327
|
+
let messageObject = {};
|
|
328
|
+
for (let objectCreate of listOfObjectForCreates) {
|
|
329
|
+
|
|
330
|
+
for (let [graphServiceName, objecForCreate] of Object.entries(objectCreate)) {
|
|
331
|
+
_izContext.logger.debug("Loop each graph:", {
|
|
332
|
+
[graphServiceName]: objecForCreate
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
if (objecForCreate.allStorageTagComplete == false) { // needless check because in listOfObjectForCreates push case graph only!
|
|
336
|
+
|
|
337
|
+
messageObject = {
|
|
338
|
+
objType: MAIN_OBJTYPE,
|
|
339
|
+
objInstance: objecForCreate.objInstance,
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
/*
|
|
343
|
+
seagame: should getRequiredOnCreateLinksGraphHandler before match with requestParams.relationships
|
|
344
|
+
this condition will miss validation when objType have requiredOnCreateLink but not send relationships from requestParams
|
|
345
|
+
*/
|
|
346
|
+
|
|
347
|
+
if (requestParams.hasOwnProperty("relationships") && requestParams.relationships.length > 0) {
|
|
348
|
+
_izContext.logger.debug("SHOW RELATIONSHIP:", requestParams.relationships);
|
|
349
|
+
|
|
350
|
+
// validate relationship only.
|
|
351
|
+
let getRelationhsipSchemas = await getObjectSchema.getRequiredOnCreateLinksGraphHandler(
|
|
352
|
+
_izContext,
|
|
353
|
+
{
|
|
354
|
+
objectType: OBJECT_TYPE,
|
|
355
|
+
serviceTag: SERVICE_TAG
|
|
356
|
+
}
|
|
357
|
+
);
|
|
358
|
+
|
|
359
|
+
_izContext.logger.debug("getRelationhsipSchemas is:::", getRelationhsipSchemas);
|
|
360
|
+
|
|
361
|
+
if (Object.keys(getRelationhsipSchemas).length !== requestParams.relationships.length) {
|
|
362
|
+
errorsFound.push("[invalid]relationships missmatch requiredOnCreateLink form relationshipschemas");
|
|
363
|
+
} else {
|
|
364
|
+
|
|
365
|
+
for (let eachRelationships of requestParams.relationships) {
|
|
366
|
+
_izContext.logger.debug("eachRelationships is:", eachRelationships);
|
|
367
|
+
|
|
368
|
+
// validate porperty in relatoinships.
|
|
369
|
+
if (!eachRelationships.hasOwnProperty("relType") || Object.keys(eachRelationships.relType).length == 0) {
|
|
370
|
+
errorsFound.push("[invalid relationsips] property relType in relationsips");
|
|
371
|
+
};
|
|
372
|
+
if (!eachRelationships.hasOwnProperty("targetObjType") || Object.keys(eachRelationships.targetObjType).length == 0) {
|
|
373
|
+
errorsFound.push("[invalid relationsips] property targetObjType in relationsips");
|
|
374
|
+
};
|
|
375
|
+
if (!eachRelationships.hasOwnProperty("targetIdentifiers") || Object.keys(eachRelationships.targetIdentifiers).length == 0) {
|
|
376
|
+
errorsFound.push("[invalid relationsips] property targetIdentifiers in relationsips");
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
let relationshipTag = eachRelationships.relType.relationshipTag
|
|
380
|
+
let eachRelationhsipSchemas = getRelationhsipSchemas[eachRelationships.relType.relationshipTag]
|
|
381
|
+
let targetObjType = eachRelationships.targetObjType
|
|
382
|
+
|
|
383
|
+
_izContext.logger.debug("each Relationhsip is:::::", {
|
|
384
|
+
relationshipTag,
|
|
385
|
+
eachRelationhsipSchemas: eachRelationhsipSchemas,
|
|
386
|
+
targetObjType
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
if (!eachRelationhsipSchemas) {
|
|
390
|
+
errorsFound.push("misMatch relationhsipSchemas requriOnCreate");
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
if (errorsFound.length > 0) {
|
|
394
|
+
break
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
let objTypeRequiredOnCreate = null;
|
|
398
|
+
for (let link of eachRelationhsipSchemas.links) {
|
|
399
|
+
/*
|
|
400
|
+
seagame: one relationshipSchema probably have 2 or more links that contain mainObjType but have difference targetObjType
|
|
401
|
+
*/
|
|
402
|
+
|
|
403
|
+
let objectSides = {
|
|
404
|
+
from: MAIN_OBJTYPE,
|
|
405
|
+
to: targetObjType
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
if (link.from.objType.serviceTag == targetObjType.serviceTag &&
|
|
409
|
+
link.from.objType.objectType == targetObjType.objectType) {
|
|
410
|
+
objectSides = {
|
|
411
|
+
from: targetObjType,
|
|
412
|
+
to: MAIN_OBJTYPE
|
|
413
|
+
};
|
|
414
|
+
};
|
|
415
|
+
_izContext.logger.debug("check side:", objectSides);
|
|
416
|
+
|
|
417
|
+
// test both sides of link
|
|
418
|
+
// let otherLinkConfigKey = "from";
|
|
419
|
+
for (let linkKey of Object.keys(link)) {
|
|
420
|
+
// _izContext.logger.debug("linkKey is:", linkKey);
|
|
421
|
+
if (linkKey == "to" || linkKey == "from") {
|
|
422
|
+
// set other side key
|
|
423
|
+
let otherLinkConfigKey = "from";
|
|
424
|
+
if (linkKey == "from") {
|
|
425
|
+
otherLinkConfigKey = "to";
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// case ONE-to-ONE
|
|
429
|
+
if (link[linkKey].linkType == "one" &&
|
|
430
|
+
link[otherLinkConfigKey].linkType == "one") {
|
|
431
|
+
_izContext.logger.debug("case ONE-to-ONE");
|
|
432
|
+
if (link[linkKey].requiredOnCreate == true) {
|
|
433
|
+
|
|
434
|
+
objTypeRequiredOnCreate = objectSides[linkKey];
|
|
435
|
+
};
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
// case ONE-to-MANY
|
|
439
|
+
if (link[linkKey].linkType == "many" &&
|
|
440
|
+
link[otherLinkConfigKey].linkType == "one") {
|
|
441
|
+
_izContext.logger.debug("case ONE-to-MANY");
|
|
442
|
+
|
|
443
|
+
if (link[linkKey].requiredOnCreate == true) {
|
|
444
|
+
|
|
445
|
+
objTypeRequiredOnCreate = objectSides[linkKey];
|
|
446
|
+
};
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
if ((objTypeRequiredOnCreate !== null && link[otherLinkConfigKey].objType !== null)) {
|
|
450
|
+
/*
|
|
451
|
+
seagame: one relationshipSchema probably have 2 or more links that contain mainObjType but have difference targetObjType
|
|
452
|
+
if check other side with targetObjType will cause errors
|
|
453
|
+
*/
|
|
454
|
+
if (
|
|
455
|
+
((objTypeRequiredOnCreate.objectType == MAIN_OBJTYPE.objectType) && (objTypeRequiredOnCreate.serviceTag == MAIN_OBJTYPE.serviceTag)) &&
|
|
456
|
+
((link[otherLinkConfigKey].objType.objectType == targetObjType.objectType) && (link[otherLinkConfigKey].objType.serviceTag == targetObjType.serviceTag))) {
|
|
457
|
+
|
|
458
|
+
// seagame:
|
|
459
|
+
// this line will re assign every time when validate requestParams.relationships
|
|
460
|
+
// should finished validate all requestParams.relationships before assign to messageObject
|
|
461
|
+
Object.assign(messageObject, { relationships: requestParams.relationships });
|
|
462
|
+
_izContext.logger.debug("messageObject case relationships", messageObject)
|
|
463
|
+
|
|
464
|
+
} else {
|
|
465
|
+
errorsFound.push("[Invalid]main objType is not requriOnCreate")
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
if (errorsFound.length > 0) {
|
|
471
|
+
break
|
|
472
|
+
};
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
}; // end check linkKey.
|
|
477
|
+
}; // end links
|
|
478
|
+
}; // end loop requestParams.relationships
|
|
479
|
+
}; // end eachRelationships
|
|
480
|
+
|
|
481
|
+
if (errorsFound.length > 0) {
|
|
482
|
+
break
|
|
483
|
+
};
|
|
484
|
+
}; // case relationships
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
if (errorsFound.length > 0) {
|
|
488
|
+
break;
|
|
489
|
+
} else {
|
|
490
|
+
_izContext.logger.debug("SENT MESSAGE EACH GRAPH::::", { graphServiceName, messageObject, callingFlowConfig })
|
|
491
|
+
|
|
492
|
+
Object.assign(messageObject, {
|
|
493
|
+
settings: { updatePropertiesOnMatch: false },
|
|
494
|
+
originTimestamp: Date.now()
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
// seagame: not need to check callingFlow before send to graph, Just add callingFlow and parent callingFlow before send to graph
|
|
498
|
+
if (callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]) {
|
|
499
|
+
_izContext.logger.debug("Have callingFlow", callingFlowConfig);
|
|
500
|
+
_izContext.logger.debug("callingFlowProperties", callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOWPROPERTIES_PROPERTYNAME])
|
|
501
|
+
|
|
502
|
+
messageObject = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
|
|
503
|
+
messageObject,
|
|
504
|
+
callingFlowSharedLib.addParentCallingFlowConfig(
|
|
505
|
+
callingFlowConfig, // resive parent callingFlowConfig.
|
|
506
|
+
callingFlowSharedLib.createCallingFlowConfig( // callinfflow own service
|
|
507
|
+
await lambdaSharedLib.lambdaFunctionName(_izContext, "CreateObjectCompleteHdrSqs"),
|
|
508
|
+
)
|
|
509
|
+
)
|
|
510
|
+
);
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
let messageToCreateObject = {
|
|
514
|
+
Message: JSON.stringify(messageObject),
|
|
515
|
+
TopicArn: await snsSharedLib.snsTopicArn(_izContext, "InCreateNodeV2", graphServiceName)
|
|
516
|
+
};
|
|
517
|
+
_izContext.logger.debug("RequestParams before send to sqs messageToCreateObject ::::::: ", messageToCreateObject);
|
|
518
|
+
await sns.publishAsync(_izContext, messageToCreateObject);
|
|
519
|
+
};
|
|
520
|
+
}; // end loop of objectCreate.
|
|
521
|
+
if (errorsFound.length > 0) {
|
|
522
|
+
break;
|
|
523
|
+
}
|
|
524
|
+
}; // end loop listOfObjectForCreates
|
|
525
|
+
|
|
526
|
+
if (errorsFound.length > 0) {
|
|
527
|
+
_izContext.logger.debug("Case have errorFound:::", errorsFound);
|
|
528
|
+
|
|
529
|
+
// remove awaitngMultiplestep. [[[[[[[open when not test lolcal.]]]]]]]
|
|
530
|
+
await asyncFlowSharedLib.clearAllAwaitingSteps(
|
|
531
|
+
_izContext,
|
|
532
|
+
asyncFlowSharedLib.createPendingStepId((hash({
|
|
533
|
+
objType: MAIN_OBJTYPE,
|
|
534
|
+
identifiers: objInstance.identifiers
|
|
535
|
+
})), PREFIX.CREATE_OBJECT_ASYNC_COMPLETE)); // pendingStepId
|
|
536
|
+
|
|
537
|
+
// send message to OutCreateObjectComplete.
|
|
538
|
+
//..
|
|
539
|
+
messageObject = {
|
|
540
|
+
objType: MAIN_OBJTYPE,
|
|
541
|
+
identifiers: null, // or {}
|
|
542
|
+
errorsFound: errorsFound
|
|
543
|
+
};
|
|
544
|
+
|
|
545
|
+
// pass back property.
|
|
546
|
+
messageObject = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(callingFlowConfig, messageObject);
|
|
547
|
+
let messageAttributes = callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(callingFlowConfig, {});
|
|
548
|
+
|
|
549
|
+
let sendMessageOutCreateObjectComplete = {
|
|
550
|
+
Message: JSON.stringify(messageObject),
|
|
551
|
+
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
552
|
+
TopicArn: await snsSharedLib.snsTopicArn(_izContext, "OutCreateObjectComplete")
|
|
553
|
+
};
|
|
554
|
+
_izContext.logger.debug("Send message to OutCreateObjectComplete :::>", sendMessageOutCreateObjectComplete)
|
|
555
|
+
await sns.publishAsync(_izContext, sendMessageOutCreateObjectComplete);
|
|
556
|
+
|
|
557
|
+
return { returnValue: "function DeliveryMetodStandate have errorFounds" }
|
|
558
|
+
}
|
|
559
|
+
_izContext.logger.debug("end errorsFound is:", errorsFound);
|
|
560
|
+
|
|
561
|
+
} catch (err) {
|
|
562
|
+
throw (err)
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
/*
|
|
568
|
+
example return
|
|
569
|
+
* identifierFieldNames will not includes inside fieldNames of createObjectDetails
|
|
570
|
+
{
|
|
571
|
+
dynamoDBStorageTag:{
|
|
572
|
+
storageType:"dynamoDB",
|
|
573
|
+
tableName:"xxx",
|
|
574
|
+
fieldNames:[...fieldName]
|
|
575
|
+
},
|
|
576
|
+
GraphServiceTag:{
|
|
577
|
+
storageType: 'graph',
|
|
578
|
+
fieldNames: [ 'bookId2', 'bookName' ]
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
*/
|