@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/src/TemplateManager/src/CreateRelationship/createRelationship/mainFunction/template.ejs
ADDED
|
@@ -0,0 +1,340 @@
|
|
|
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
|
+
|
|
20
|
+
const hash = require("object-hash");
|
|
21
|
+
|
|
22
|
+
const callingFlowSharedLib = require('@izara_project/izara-shared/src/CallingFlowSharedLib');
|
|
23
|
+
const lambdaSharedLib = require('@izara_project/izara-shared/src/LambdaSharedLib');
|
|
24
|
+
|
|
25
|
+
const snsSharedLib = require('@izara_project/izara-shared/src/SnsSharedLib');
|
|
26
|
+
const sns = require("@izara_project/izara-core-library-external-request/src/resources/Sns");
|
|
27
|
+
|
|
28
|
+
const asyncFlowSharedLib = require('@izara_project/izara-shared/src/AsyncFlowSharedLib');
|
|
29
|
+
|
|
30
|
+
// const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
const {
|
|
36
|
+
getRelationshipSchemaWithCache,
|
|
37
|
+
getObjSchemaS3WithHierarchy
|
|
38
|
+
} = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
|
|
39
|
+
|
|
40
|
+
const {
|
|
41
|
+
createLinkTypeId
|
|
42
|
+
} = require('@izara_project/izara-core-library-service-schemas/src/Utils');
|
|
43
|
+
|
|
44
|
+
const {
|
|
45
|
+
getGraphServiceTagWithCache
|
|
46
|
+
} = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig');
|
|
47
|
+
|
|
48
|
+
const consts = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
49
|
+
const {
|
|
50
|
+
PREFIX,
|
|
51
|
+
TOPIC_NAME_GENERATE_CODE,
|
|
52
|
+
TOPIC_NAME_GRAPH_HANDLER
|
|
53
|
+
} = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* update relationship endpoint
|
|
57
|
+
*
|
|
58
|
+
* @param {Object} _izContext
|
|
59
|
+
* @param {CorrelationIds} _izContext.correlationIds - property of _izContext
|
|
60
|
+
* @param {Logger} _izContext.logger - property of _izContext
|
|
61
|
+
* @param {Object} requestParams - request params
|
|
62
|
+
* @param {Object} callingFlowConfig
|
|
63
|
+
*
|
|
64
|
+
* @returns {object} description of return value
|
|
65
|
+
*/
|
|
66
|
+
module.exports.createRelationship = async (
|
|
67
|
+
_izContext,
|
|
68
|
+
requestParams,
|
|
69
|
+
callingFlowConfig = {},
|
|
70
|
+
//(<additionalParams>)
|
|
71
|
+
//(</additionalParams>)
|
|
72
|
+
) => {
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
_izContext.logger.debug('createRelationship _izContext: ', _izContext);
|
|
77
|
+
_izContext.logger.debug('createRelationship requestParams: ', requestParams);
|
|
78
|
+
_izContext.logger.debug('createRelationship callingFlowConfig: ', callingFlowConfig);
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
const {
|
|
82
|
+
objects,
|
|
83
|
+
relType,
|
|
84
|
+
relationshipProperties
|
|
85
|
+
//(<requestparamCreateRel>)
|
|
86
|
+
//(</requestparamCreateRel>)
|
|
87
|
+
} = requestParams;
|
|
88
|
+
|
|
89
|
+
let errorsFound = [];
|
|
90
|
+
|
|
91
|
+
//(<beforeValidateCreateRel>)
|
|
92
|
+
//(</beforeValidateCreateRel>)
|
|
93
|
+
// validate object and identifiers
|
|
94
|
+
async function validateIdentifiersExists(_izContext, objType, identifiersObject) {
|
|
95
|
+
|
|
96
|
+
const objTypeString = `objType:{ serviceTag:${objType.serviceTag}, objectType:${objType.objectType} }`;
|
|
97
|
+
const objectSchema = await getObjSchemaS3WithHierarchy(_izContext, objType);
|
|
98
|
+
|
|
99
|
+
if (!objectSchema) {
|
|
100
|
+
errorsFound.push(`validateIdentifiers, not found schema of ${objTypeString}`);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
for (const schemaIdentifier of objectSchema.identifiers) {
|
|
104
|
+
let identifierNames = schemaIdentifier.fieldNames || [schemaIdentifier.fieldName];
|
|
105
|
+
for (const identifierName of identifierNames) {
|
|
106
|
+
if (!identifiersObject.hasOwnProperty(identifierName)) {
|
|
107
|
+
errorsFound.push(`validateIdentifiers, ${objTypeString} property:${identifierName} not exists`);
|
|
108
|
+
} else {
|
|
109
|
+
if (
|
|
110
|
+
typeof (identifiersObject[identifierName]) !== "string" &&
|
|
111
|
+
typeof (identifiersObject[identifierName]) !== "number"
|
|
112
|
+
) {
|
|
113
|
+
errorsFound.push(`validateIdentifiers, ${objTypeString} property:${identifierName} should be string or number`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
await validateIdentifiersExists(_izContext, objects[0].objType, objects[0].identifiers);
|
|
121
|
+
await validateIdentifiersExists(_izContext, objects[1].objType, objects[1].identifiers);
|
|
122
|
+
// finished validate object and identifiers
|
|
123
|
+
|
|
124
|
+
//(<afterValidateCreateRel>)
|
|
125
|
+
//(</afterValidateCreateRel>)
|
|
126
|
+
|
|
127
|
+
//(<beforeGetRelCreateRel>)
|
|
128
|
+
//(</beforeGetRelCreateRel>)
|
|
129
|
+
|
|
130
|
+
const relationshipSchema = await getRelationshipSchemaWithCache(_izContext, relType);
|
|
131
|
+
_izContext.logger.debug("relationshipSchema: ", relationshipSchema);
|
|
132
|
+
|
|
133
|
+
let targetStorageResources = [];
|
|
134
|
+
|
|
135
|
+
if (relationshipSchema) {
|
|
136
|
+
// find targetStorageResources and validate each storageResources
|
|
137
|
+
await Promise.all(
|
|
138
|
+
relationshipSchema.links.map(async ({ from, to, storageResourceTags }) => {
|
|
139
|
+
const { serviceTag: fromServiceTag, objectType: fromObjectType } = from.objType
|
|
140
|
+
const { serviceTag: toServiceTag, objectType: toObjectType } = to.objType
|
|
141
|
+
|
|
142
|
+
const { serviceTag: firstServiceTag, objectType: firstObjectType } = objects[0].objType;
|
|
143
|
+
const { serviceTag: secondServiceTag, objectType: secondObjectType } = objects[1].objType;
|
|
144
|
+
|
|
145
|
+
// find exists link
|
|
146
|
+
if (
|
|
147
|
+
(
|
|
148
|
+
(firstServiceTag === fromServiceTag && firstObjectType === fromObjectType) &&
|
|
149
|
+
(secondServiceTag === toServiceTag && secondObjectType === toObjectType)
|
|
150
|
+
) ||
|
|
151
|
+
(
|
|
152
|
+
(firstServiceTag === toServiceTag && firstObjectType === toObjectType) &&
|
|
153
|
+
(secondServiceTag === fromServiceTag && secondObjectType === fromObjectType)
|
|
154
|
+
)
|
|
155
|
+
) {
|
|
156
|
+
|
|
157
|
+
// check founded storageResource of link and collect used storageResources
|
|
158
|
+
await Promise.all(storageResourceTags.map(async storageResourceTag => {
|
|
159
|
+
const usedStorageResource = relationshipSchema.storageResources[storageResourceTag];
|
|
160
|
+
|
|
161
|
+
if (usedStorageResource.storageType === consts.STORAGE_TYPES.graph) {
|
|
162
|
+
const graphServiceTag = await getGraphServiceTagWithCache(_izContext, usedStorageResource.graphServerTag);
|
|
163
|
+
if (!graphServiceTag) {
|
|
164
|
+
errorsFound.push(`storageResourceTag:${storageResourceTag} invalid, not found graph serviceTag from graphServerTag:${usedStorageResource.graphServerTag}`)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
targetStorageResources.push({
|
|
168
|
+
...usedStorageResource,
|
|
169
|
+
graphServiceTag: graphServiceTag
|
|
170
|
+
});
|
|
171
|
+
} else {
|
|
172
|
+
targetStorageResources.push(usedStorageResource);
|
|
173
|
+
}
|
|
174
|
+
}));
|
|
175
|
+
}
|
|
176
|
+
})
|
|
177
|
+
);
|
|
178
|
+
//(<afterGetRelCreateRel>)
|
|
179
|
+
//(</afterGetRelCreateRel>)
|
|
180
|
+
_izContext.logger.debug("targetStorageResources: ", targetStorageResources);
|
|
181
|
+
|
|
182
|
+
if (!targetStorageResources.length) {
|
|
183
|
+
errorsFound.push(`Not found link from relationship schema`);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
// validate properties exists with schema
|
|
188
|
+
for (const propKey in relationshipProperties) {
|
|
189
|
+
if (!relationshipSchema.properties.hasOwnProperty(propKey)) {
|
|
190
|
+
errorsFound.push(`property:${propKey} not exists in relationshipSchema`);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// validate canCreate properties relationship
|
|
195
|
+
for (const [propName, propSetting] of Object.entries(relationshipSchema.properties)) {
|
|
196
|
+
if (propSetting.requiredOnCreate === true) {
|
|
197
|
+
if (!relationshipProperties.hasOwnProperty(propName)) {
|
|
198
|
+
errorsFound.push(`Missing requiredOnCreate property:${propKey}`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (!propSetting.optionalOnCreate && !propSetting.requiredOnCreate && relationshipProperties.hasOwnProperty(propName)) {
|
|
203
|
+
errorsFound.push(`property:${propName} cannot create`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
} else {
|
|
208
|
+
errorsFound.push(`relationshipSchema not exists`);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
// if found errors will stop processing
|
|
213
|
+
if (errorsFound.length) {
|
|
214
|
+
|
|
215
|
+
let createRelCompleteMsg = {
|
|
216
|
+
objects: objects,
|
|
217
|
+
relType: relType,
|
|
218
|
+
relationshipProperties: relationshipProperties,
|
|
219
|
+
//(<inCreateRelCompleteMsgCrateRel>)
|
|
220
|
+
//(</inCreateRelCompleteMsgCrateRel>)
|
|
221
|
+
status: 'error',
|
|
222
|
+
errorFounds: errorsFound
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
// if have callingFlow will send to message complete
|
|
226
|
+
if (callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]) {
|
|
227
|
+
_izContext.logger.debug("HAVE CallingFlow");
|
|
228
|
+
|
|
229
|
+
createRelCompleteMsg = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(callingFlowConfig, createRelCompleteMsg);
|
|
230
|
+
let messageAttributes = callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(callingFlowConfig, {});
|
|
231
|
+
|
|
232
|
+
let messageParams = {
|
|
233
|
+
Message: JSON.stringify(createRelCompleteMsg),
|
|
234
|
+
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
235
|
+
TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.outCreateRelComplete),
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
_izContext.logger.debug("messageParams OutCreateRelationshipComplete ::::::: ", messageParams);
|
|
239
|
+
await sns.publishAsync(_izContext, messageParams);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return createRelCompleteMsg;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
// before create awaitingStepId per graph storageResource
|
|
247
|
+
const linkTypeId = createLinkTypeId(_izContext, [objects[0].objType, objects[1].objType], relType);
|
|
248
|
+
|
|
249
|
+
let usedGraphServiceTag = []; // collect used graph serviceTag, use to check duplicate graph serviceTag across graph serverTag
|
|
250
|
+
let targetGraphStorageResources = []; // collect used graph storageResources, filtered duplicate graphServiceTag from graphServerTag out
|
|
251
|
+
let awaitingStepIds = [];
|
|
252
|
+
|
|
253
|
+
for (const targetStorageResource of targetStorageResources) {
|
|
254
|
+
if (targetStorageResource.storageType === consts.STORAGE_TYPES.graph &&
|
|
255
|
+
!usedGraphServiceTag.includes(targetStorageResource.graphServiceTag)
|
|
256
|
+
) {
|
|
257
|
+
usedGraphServiceTag.push(targetStorageResource.graphServiceTag);
|
|
258
|
+
targetGraphStorageResources.push(targetStorageResource);
|
|
259
|
+
|
|
260
|
+
// awaitingStepId per graphServiceTag
|
|
261
|
+
awaitingStepIds.push(
|
|
262
|
+
asyncFlowSharedLib.createAwaitingStepId(
|
|
263
|
+
hash({ linkTypeId, relationshipProperties, graphServiceTag: targetStorageResource.graphServiceTag }), // hash id
|
|
264
|
+
PREFIX.createRel // prefix, use constant further
|
|
265
|
+
)
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/*
|
|
271
|
+
if have storageResource.storageType === "dynamoDB" will create relationship here
|
|
272
|
+
*/
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
if (awaitingStepIds.length) {
|
|
276
|
+
// save awaiting
|
|
277
|
+
await asyncFlowSharedLib.createAwaitingMultipleSteps(
|
|
278
|
+
_izContext,
|
|
279
|
+
awaitingStepIds, // awaitingStepIds
|
|
280
|
+
asyncFlowSharedLib.createPendingStepId( // pendingStepId
|
|
281
|
+
hash({ linkTypeId, relationshipProperties, correlationId: _izContext.correlationIds.get("id") }), // hash id
|
|
282
|
+
PREFIX.createRel // prefix, use constant further
|
|
283
|
+
)
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
// prepare message body
|
|
287
|
+
let updateRelMessageBody = {
|
|
288
|
+
objects: objects,
|
|
289
|
+
relType: relType,
|
|
290
|
+
relationshipProperties
|
|
291
|
+
//(<inUpdateRelMessageBodyCreateRel>)
|
|
292
|
+
//(</inUpdateRelMessageBodyCreateRel>)
|
|
293
|
+
}
|
|
294
|
+
_izContext.logger.debug('createRelMessageBody: ', updateRelMessageBody);
|
|
295
|
+
|
|
296
|
+
await Promise.all(
|
|
297
|
+
targetGraphStorageResources.map(async (storageResource) => {
|
|
298
|
+
if (storageResource.storageType === consts.STORAGE_TYPES.graph) {
|
|
299
|
+
|
|
300
|
+
updateRelMessageBody = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
|
|
301
|
+
updateRelMessageBody,
|
|
302
|
+
callingFlowSharedLib.addParentCallingFlowConfig(
|
|
303
|
+
callingFlowConfig, // receive parent callingFlowConfig.
|
|
304
|
+
callingFlowSharedLib.createCallingFlowConfig( // callinfflow own service
|
|
305
|
+
await lambdaSharedLib.lambdaFunctionName(_izContext, TOPIC_NAME_GENERATE_CODE.createRelComplete),
|
|
306
|
+
{
|
|
307
|
+
graphServiceTag: storageResource.graphServiceTag
|
|
308
|
+
}
|
|
309
|
+
)
|
|
310
|
+
)
|
|
311
|
+
);
|
|
312
|
+
_izContext.logger.debug("messageObject before send message:", updateRelMessageBody)
|
|
313
|
+
|
|
314
|
+
let messageToInUpdateRelationship = {
|
|
315
|
+
Message: JSON.stringify(updateRelMessageBody),
|
|
316
|
+
TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GRAPH_HANDLER.inCreateRel, storageResource.graphServiceTag),
|
|
317
|
+
};
|
|
318
|
+
_izContext.logger.debug("RequestParams before send to sqs messageToInUpdateRelationship ::::::: ", messageToInUpdateRelationship);
|
|
319
|
+
await sns.publishAsync(_izContext, messageToInUpdateRelationship);
|
|
320
|
+
}
|
|
321
|
+
})
|
|
322
|
+
)
|
|
323
|
+
|
|
324
|
+
} else {
|
|
325
|
+
// if relationshipSchema stored in dynamoDB only will send message to outComplete
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return {
|
|
329
|
+
objects,
|
|
330
|
+
relType,
|
|
331
|
+
relationshipProperties,
|
|
332
|
+
errorFounds: errorsFound
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
} catch (err) {
|
|
337
|
+
_izContext.logger.error('error updateRelationship: ', err)
|
|
338
|
+
throw (err)
|
|
339
|
+
}
|
|
340
|
+
}
|
package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrApi/data.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
|
|
24
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase } = require("../../../../../../MainLibs/src/Utils")
|
|
25
|
+
const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH } = require("../../../../libs/Consts");
|
|
26
|
+
|
|
27
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* receive objectSchema
|
|
31
|
+
* create data for hdrInv template
|
|
32
|
+
*
|
|
33
|
+
* @return {{ templatePath, templateData, setting } }
|
|
34
|
+
*/
|
|
35
|
+
function data(_izContext, srcPath) {
|
|
36
|
+
const createSourceParams = createParamForCreateSource(srcPath)
|
|
37
|
+
return [createSourceParams];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
function createParamForCreateSource(srcPath) {
|
|
42
|
+
let functionName = "createRelationship";
|
|
43
|
+
return {
|
|
44
|
+
templatePath: templatePath,
|
|
45
|
+
templateData: {
|
|
46
|
+
functionName,
|
|
47
|
+
},
|
|
48
|
+
setting: {
|
|
49
|
+
savePath: path.join(srcPath, SOURCE_PATH.relationshipPerAction),
|
|
50
|
+
saveFileName: upperCase(functionName) + "_" + upperCase(HANDLER.hdrApi),
|
|
51
|
+
fileExtension: '.js',
|
|
52
|
+
isAppend: false
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
module.exports = data;
|
package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrApi/request.json
ADDED
|
File without changes
|
package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrApi/template.ejs
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
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 izara = require("@izara_project/izara-middleware");
|
|
20
|
+
const middleware = izara.middlewareHandler;
|
|
21
|
+
const callingFlowSharedLib = require('@izara_project/izara-shared/src/CallingFlowSharedLib')
|
|
22
|
+
const {
|
|
23
|
+
validateSchemaMiddleware
|
|
24
|
+
} = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
|
|
25
|
+
|
|
26
|
+
const <%- functionName %> = require('./<%- firstLetterUpperCase(functionName) %>_Main');
|
|
27
|
+
// validate event params in middleware before into function
|
|
28
|
+
let validatorSchema = {
|
|
29
|
+
type: "object",
|
|
30
|
+
required: ["objects", "relId", "relType", "relationshipProperties"],
|
|
31
|
+
properties: {
|
|
32
|
+
objects: {
|
|
33
|
+
type: "array",
|
|
34
|
+
minItems: 2,
|
|
35
|
+
maxItems: 2,
|
|
36
|
+
Items: {
|
|
37
|
+
type: "object",
|
|
38
|
+
required: ["objType", "identifiers"],
|
|
39
|
+
properties: {
|
|
40
|
+
objType: {
|
|
41
|
+
type: "object",
|
|
42
|
+
required: ["serviceTag", "objectType"],
|
|
43
|
+
properties: {
|
|
44
|
+
serviceTag: izara.validatorSchema.stringNotEmpty(),
|
|
45
|
+
objectType: izara.validatorSchema.stringNotEmpty()
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
identifiers: {
|
|
49
|
+
type: "object",
|
|
50
|
+
minproperties: 1
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
relType: {
|
|
56
|
+
type: "object",
|
|
57
|
+
required: ["relationshipTag", "serviceTag"],
|
|
58
|
+
properties: {
|
|
59
|
+
relationshipTag: izara.validatorSchema.stringNotEmpty(),
|
|
60
|
+
serviceTag: {
|
|
61
|
+
type: 'string',
|
|
62
|
+
pattern: "^[a-zA-Z0-9_-]+$",
|
|
63
|
+
enum: [process.env.iz_serviceTag]
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
relId: izara.validatorSchema.stringNotEmpty(),
|
|
68
|
+
relationshipProperties: {
|
|
69
|
+
type: "object",
|
|
70
|
+
minProperties: 1
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
//(<globalVarible>
|
|
77
|
+
//</globalVarible>)
|
|
78
|
+
|
|
79
|
+
// validate event params in middleware before into main function
|
|
80
|
+
validatorSchema = callingFlowSharedLib.addOptionalCallingFlowToValidatorSchema(validatorSchema);
|
|
81
|
+
middleware.setValidatorSchema(validatorSchema)
|
|
82
|
+
// if need to validate authorizer or additional params , add code to hook tag below
|
|
83
|
+
|
|
84
|
+
//(<afterValidateWith>)
|
|
85
|
+
//(</afterValidateWith>)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
89
|
+
event._izContext.logger.debug('Event:', event);
|
|
90
|
+
try {
|
|
91
|
+
// invoke LambdaFunction
|
|
92
|
+
let lambdaFunctionResponse = await <%- functionName %>.<%- functionName %>(
|
|
93
|
+
event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId/userId
|
|
94
|
+
{
|
|
95
|
+
objects: event.objects,
|
|
96
|
+
relType: event.relType,
|
|
97
|
+
relId: event.relId,
|
|
98
|
+
relationshipProperties: event.relationshipProperties
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
// return error to client
|
|
103
|
+
if (lambdaFunctionResponse instanceof Error) {
|
|
104
|
+
return (izara.response.failure(lambdaFunctionResponse));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// return success to client
|
|
108
|
+
return (izara.response.success(lambdaFunctionResponse));
|
|
109
|
+
|
|
110
|
+
} catch (err) {
|
|
111
|
+
event._izContext.logger.error('Error, <%- functionName %>HdrApi: ', err);
|
|
112
|
+
return (izara.response.failure(err));
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
<%_ function firstLetterUpperCase(text) {
|
|
116
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
117
|
+
} _%>
|
|
118
|
+
<%_ function firstLetterLowerCase(str) {
|
|
119
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
120
|
+
} _%>
|
package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrDsq/data.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
|
|
24
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase } = require("../../../../../../MainLibs/src/Utils")
|
|
25
|
+
const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH, FUNCTION_NAME } = require("../../../../libs/Consts");
|
|
26
|
+
|
|
27
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* create data for hdrInv template
|
|
31
|
+
*
|
|
32
|
+
* @return {{ templatePath, templateData, setting } }
|
|
33
|
+
*/
|
|
34
|
+
function data(_izContext, srcPath) {
|
|
35
|
+
const createSourceParams = createParamForCreateSource(srcPath)
|
|
36
|
+
return [createSourceParams];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
function createParamForCreateSource(srcPath) {
|
|
41
|
+
let functionName = FUNCTION_NAME.createRel
|
|
42
|
+
let queueName = functionName + upperCase(HANDLER.hdrDsq)
|
|
43
|
+
return {
|
|
44
|
+
templatePath: templatePath,
|
|
45
|
+
templateData: {
|
|
46
|
+
functionName,
|
|
47
|
+
queueName
|
|
48
|
+
},
|
|
49
|
+
setting: {
|
|
50
|
+
savePath: path.join(srcPath, SOURCE_PATH.relationshipPerAction),
|
|
51
|
+
saveFileName: upperCase(functionName) + "_" + upperCase(HANDLER.hdrDsq),
|
|
52
|
+
fileExtension: '.js',
|
|
53
|
+
isAppend: false
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
module.exports = data;
|
package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrDsq/request.json
ADDED
|
File without changes
|