@izara_project/izara-market-library-service-schemas 1.0.5 → 1.0.7
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 +12 -3
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +232 -7
- 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 +10 -2
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrDsq/data.js +5 -4
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrInv/data.js +11 -1
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrSqs/data.js +4 -3
- package/src/TemplateManager/src/CreateRelationship/createRelationship/mainFunction/template.ejs +24 -22
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrDsq/data.js +0 -1
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrSqs/data.js +1 -1
- package/src/TemplateManager/src/CreateRelationship/createRelationship/sns-in-sqs/data.js +0 -2
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/functionYaml/data.js +2 -2
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/handler/HdrSqs/data.js +0 -1
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-out/data.js +1 -1
- 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 +158 -0
- package/src/TemplateManager/src/GenerateCode(Old).js +1 -1
- package/src/TemplateManager/src/GenerateCode.js +163 -42
- 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 +59 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/handler/template.ejs +129 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/createObjectComplete_main.js +172 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/data.js +53 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/template.ejs +172 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-in-sqs/data.js +58 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-in-sqs/template.ejs +47 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-out/data.js +62 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-out/template.ejs +10 -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/PerActionEndpoint/FunctionYaml/HdrApi/data.js +22 -3
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/template.ejs +2 -2
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrDsq/data.js +24 -1
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrInv/data.js +53 -2
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrSqs/data.js +25 -3
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/data.js +5 -8
- 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 -23
- 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 +69 -21
- 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 -17
- 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 +575 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/data.js +0 -6
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/template.ejs +17 -12
- 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 +429 -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/processLogicalAndFindData.js +2 -2
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical.js +27 -12
- package/src/TemplateManager/src/ResourceYaml/sns-out/data.js +1 -1
- 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/TranslateIdReq/ProcessingTranslateIds/functionYaml/template.ejs +30 -0
- 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 +2 -2
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-out/data.js +1 -1
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/data.js +10 -3
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/data.js +6 -4
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/data.js +11 -1
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/data.js +7 -5
- package/src/TemplateManager/src/externalService/LambdaRole/data.js +150 -32
- package/src/TemplateManager/src/externalService/LambdaRole/template.ejs +16 -15
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/data.js +35 -6
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/template.ejs +3 -4
- package/src/TemplateManager/src/libs/Consts.js +122 -11
- package/src/TemplateManager/src/PerActionEndpoint/Handler/testRequest.json +0 -5
|
@@ -0,0 +1,172 @@
|
|
|
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
|
+
'use strict';
|
|
18
|
+
const asyncFlowSharedLib = require('@izara_project/izara-shared/src/AsyncFlowSharedLib');
|
|
19
|
+
const dynamodbSharedLib = require('@izara_project/izara-shared/src/DynamodbSharedLib');
|
|
20
|
+
const snsSharedLib = require('@izara_project/izara-shared/src/SnsSharedLib');
|
|
21
|
+
const sns = require('@izara_project/izara-core-library-external-request/src/resources/Sns');
|
|
22
|
+
const callingFlowSharedLib = require('@izara_project/izara-shared/src/CallingFlowSharedLib');
|
|
23
|
+
const _ = require('lodash');
|
|
24
|
+
const hash = require("object-hash")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
const PREFIX = {
|
|
28
|
+
CREATE_OBJECT_ASYNC: "createObjectAsync",
|
|
29
|
+
CREATE_OBJECT_ASYNC_COMPLETE: "createObjectAsyncComplete"
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @param {*} _izContext
|
|
35
|
+
* @param {*} returnValue
|
|
36
|
+
* @param {*} status
|
|
37
|
+
* @param {*} errorsFounds
|
|
38
|
+
* @param {*} graphServiceTag
|
|
39
|
+
* @param {*} passBackProperties
|
|
40
|
+
* @param {*} callingFlowConfig
|
|
41
|
+
returnValue = {
|
|
42
|
+
queryResult: returnCreateNode,
|
|
43
|
+
objType,
|
|
44
|
+
objInstance,
|
|
45
|
+
relationships,
|
|
46
|
+
settings
|
|
47
|
+
}
|
|
48
|
+
*/
|
|
49
|
+
module.exports.createObjectComplete = async (
|
|
50
|
+
_izContext,
|
|
51
|
+
returnValue,
|
|
52
|
+
status,
|
|
53
|
+
errorsFound,
|
|
54
|
+
graphServiceTag,
|
|
55
|
+
passBackProperties,
|
|
56
|
+
callingFlowConfig
|
|
57
|
+
) => {
|
|
58
|
+
try {
|
|
59
|
+
_izContext.logger.debug("function createObjectComplete:", {
|
|
60
|
+
returnValue,
|
|
61
|
+
status,
|
|
62
|
+
errorsFound,
|
|
63
|
+
graphServiceTag,
|
|
64
|
+
passBackProperties,
|
|
65
|
+
callingFlowConfig
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
let errorFounds = [];
|
|
69
|
+
|
|
70
|
+
if (_.isEmpty(returnValue)) {
|
|
71
|
+
_izContext.logger.debug("message callingFlowProperties is empty");
|
|
72
|
+
throw new NoRetryError("message not an object")
|
|
73
|
+
};
|
|
74
|
+
// validate.
|
|
75
|
+
if (!returnValue.hasOwnProperty("queryResult")) {
|
|
76
|
+
errorFounds.push("message is not have property queryResult, should be not happen");
|
|
77
|
+
};
|
|
78
|
+
if (!returnValue.hasOwnProperty("objType")) {
|
|
79
|
+
errorFounds.push("message is not have property objType, should be not happen");
|
|
80
|
+
};
|
|
81
|
+
if (!returnValue.hasOwnProperty("objInstance")) {
|
|
82
|
+
errorFounds.push("message is not have property objInstance, should be not objInstance");
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
if (status == "error" && errorsFound.length > 0) {
|
|
86
|
+
errorFounds.push(errorsFound);
|
|
87
|
+
} else if (status == "error" && errorsFound.length == 0) {
|
|
88
|
+
errorFounds.push("[invalid]statur is error not have errorfound form graphService");
|
|
89
|
+
|
|
90
|
+
};
|
|
91
|
+
if (status === "complete" && errorsFound.length > 0) {
|
|
92
|
+
errorFounds.push("[Invalid] status is commplete should be not have errorsFound");
|
|
93
|
+
};
|
|
94
|
+
if (graphServiceTag == "") {
|
|
95
|
+
errorFounds.push("[Invalid] graphServiceTag is not empty string");
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
if (errorsFound.length > 0) {
|
|
99
|
+
_izContext.logger.debug("Have error form grapService:", errorsFound);
|
|
100
|
+
errorFounds = errorFounds.concat(errorsFound);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// check and remove awaitngStep finish.
|
|
104
|
+
let awaitingStepId = asyncFlowSharedLib.createAwaitingStepId((hash(
|
|
105
|
+
{
|
|
106
|
+
objType: returnValue.objType,
|
|
107
|
+
graphServerTag: graphServiceTag,
|
|
108
|
+
identifiers: returnValue.objInstance.identifiers
|
|
109
|
+
}
|
|
110
|
+
)),
|
|
111
|
+
PREFIX.CREATE_OBJECT_ASYNC
|
|
112
|
+
)
|
|
113
|
+
_izContext.logger.debug("awaitingStepId:", awaitingStepId);
|
|
114
|
+
|
|
115
|
+
let recordAwaitingSteps = await dynamodbSharedLib.query(
|
|
116
|
+
_izContext,
|
|
117
|
+
await dynamodbSharedLib.tableName(_izContext, "AwaitingMultipleSteps"),
|
|
118
|
+
{
|
|
119
|
+
awaitingStepId: awaitingStepId
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
_izContext.logger.debug("record awaitingSteps::", recordAwaitingSteps);
|
|
123
|
+
|
|
124
|
+
nextAwaitingAteps:
|
|
125
|
+
for (let listRecordAwaitingStep of recordAwaitingSteps.Items) {
|
|
126
|
+
|
|
127
|
+
_izContext.logger.debug("iterate RecordAwaitingStep:", listRecordAwaitingStep);
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
if (!await asyncFlowSharedLib.checkAllAwaitingStepsFinished(
|
|
131
|
+
_izContext,
|
|
132
|
+
listRecordAwaitingStep.pendingStepId,
|
|
133
|
+
awaitingStepId
|
|
134
|
+
)) {
|
|
135
|
+
_izContext.logger.debug("!Waiting record form other graph::")
|
|
136
|
+
// **** add step of remove awaitingMultiplestep!! ??
|
|
137
|
+
continue nextAwaitingAteps
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
await asyncFlowSharedLib.removeAwaitingMultipleStep(
|
|
141
|
+
_izContext,
|
|
142
|
+
awaitingStepId,
|
|
143
|
+
listRecordAwaitingStep.pendingStepId,
|
|
144
|
+
);
|
|
145
|
+
_izContext.logger.debug("Remove awaitingStep finish")
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
// seagame: problem about lambdaComplete is will missing errorsFound from request if have 2 request
|
|
149
|
+
// one send with errorsFound and one send without errorsFound
|
|
150
|
+
// this scenario can complete with or without errorsFound
|
|
151
|
+
let messageObject = {
|
|
152
|
+
objType: returnValue.objType,
|
|
153
|
+
identifierId: returnValue.objInstance.identifiers,
|
|
154
|
+
errorFounds: errorFounds
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
messageObject = callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(passBackProperties, messageObject)
|
|
158
|
+
let messageAttributes = callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(passBackProperties, {})
|
|
159
|
+
|
|
160
|
+
let sendMessageOutCreateObjectComplete = {
|
|
161
|
+
Message: JSON.stringify(messageObject),
|
|
162
|
+
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
163
|
+
TopicArn: await snsSharedLib.snsTopicArn(_izContext, "OutCreateObjectComplete")
|
|
164
|
+
};
|
|
165
|
+
_izContext.logger.debug("Send message to OutCreateObjectComplete :::>", sendMessageOutCreateObjectComplete)
|
|
166
|
+
await sns.publishAsync(_izContext, sendMessageOutCreateObjectComplete);
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
} catch (err) {
|
|
170
|
+
throw (err)
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
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, SAVE_FILE_NAME } = 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
|
+
|
|
36
|
+
function data(_izContext, srcPath) {
|
|
37
|
+
return [createMainFunctionCreateComplete(_izContext, srcPath)]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function createMainFunctionCreateComplete(_izContext, srcPath) {
|
|
41
|
+
return {
|
|
42
|
+
templatePath: templatePath,
|
|
43
|
+
templateData: {},
|
|
44
|
+
setting: {
|
|
45
|
+
savePath: path.join(srcPath, SOURCE_PATH.lambdaPerAction),
|
|
46
|
+
saveFileName: `${upperCase(FUNCTION_NAME.createObjectComplete)}_Main`,
|
|
47
|
+
fileExtension: ".js",
|
|
48
|
+
isAppend: false
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
module.exports = data
|
package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/template.ejs
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
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
|
+
'use strict';
|
|
18
|
+
const asyncFlowSharedLib = require('@izara_project/izara-shared/src/AsyncFlowSharedLib');
|
|
19
|
+
const dynamodbSharedLib = require('@izara_project/izara-shared/src/DynamodbSharedLib');
|
|
20
|
+
const snsSharedLib = require('@izara_project/izara-shared/src/SnsSharedLib');
|
|
21
|
+
const sns = require('@izara_project/izara-core-library-external-request/src/resources/Sns');
|
|
22
|
+
const callingFlowSharedLib = require('@izara_project/izara-shared/src/CallingFlowSharedLib');
|
|
23
|
+
const _ = require('lodash');
|
|
24
|
+
const hash = require("object-hash")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
const PREFIX = {
|
|
28
|
+
CREATE_OBJECT_ASYNC: "createObjectAsync",
|
|
29
|
+
CREATE_OBJECT_ASYNC_COMPLETE: "createObjectAsyncComplete"
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @param {*} _izContext
|
|
35
|
+
* @param {*} returnValue
|
|
36
|
+
* @param {*} status
|
|
37
|
+
* @param {*} errorsFounds
|
|
38
|
+
* @param {*} graphServiceTag
|
|
39
|
+
* @param {*} passBackProperties
|
|
40
|
+
* @param {*} callingFlowConfig
|
|
41
|
+
returnValue = {
|
|
42
|
+
queryResult: returnCreateNode,
|
|
43
|
+
objType,
|
|
44
|
+
objInstance,
|
|
45
|
+
relationships,
|
|
46
|
+
settings
|
|
47
|
+
}
|
|
48
|
+
*/
|
|
49
|
+
module.exports.createObjectComplete = async (
|
|
50
|
+
_izContext,
|
|
51
|
+
returnValue,
|
|
52
|
+
status,
|
|
53
|
+
errorsFound,
|
|
54
|
+
graphServiceTag,
|
|
55
|
+
passBackProperties,
|
|
56
|
+
callingFlowConfig
|
|
57
|
+
) => {
|
|
58
|
+
try {
|
|
59
|
+
_izContext.logger.debug("function createObjectComplete:", {
|
|
60
|
+
returnValue,
|
|
61
|
+
status,
|
|
62
|
+
errorsFound,
|
|
63
|
+
graphServiceTag,
|
|
64
|
+
passBackProperties,
|
|
65
|
+
callingFlowConfig
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
let errorFounds = [];
|
|
69
|
+
|
|
70
|
+
if (_.isEmpty(returnValue)) {
|
|
71
|
+
_izContext.logger.debug("message callingFlowProperties is empty");
|
|
72
|
+
throw new NoRetryError("message not an object")
|
|
73
|
+
};
|
|
74
|
+
// validate.
|
|
75
|
+
if (!returnValue.hasOwnProperty("queryResult")) {
|
|
76
|
+
errorFounds.push("message is not have property queryResult, should be not happen");
|
|
77
|
+
};
|
|
78
|
+
if (!returnValue.hasOwnProperty("objType")) {
|
|
79
|
+
errorFounds.push("message is not have property objType, should be not happen");
|
|
80
|
+
};
|
|
81
|
+
if (!returnValue.hasOwnProperty("objInstance")) {
|
|
82
|
+
errorFounds.push("message is not have property objInstance, should be not objInstance");
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
if (status == "error" && errorsFound.length > 0) {
|
|
86
|
+
errorFounds.push(errorsFound);
|
|
87
|
+
} else if (status == "error" && errorsFound.length == 0) {
|
|
88
|
+
errorFounds.push("[invalid]statur is error not have errorfound form graphService");
|
|
89
|
+
|
|
90
|
+
};
|
|
91
|
+
if (status === "complete" && errorsFound.length > 0) {
|
|
92
|
+
errorFounds.push("[Invalid] status is commplete should be not have errorsFound");
|
|
93
|
+
};
|
|
94
|
+
if (graphServiceTag == "") {
|
|
95
|
+
errorFounds.push("[Invalid] graphServiceTag is not empty string");
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
if (errorsFound.length > 0) {
|
|
99
|
+
_izContext.logger.debug("Have error form grapService:", errorsFound);
|
|
100
|
+
errorFounds = errorFounds.concat(errorsFound);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// check and remove awaitngStep finish.
|
|
104
|
+
let awaitingStepId = asyncFlowSharedLib.createAwaitingStepId((hash(
|
|
105
|
+
{
|
|
106
|
+
objType: returnValue.objType,
|
|
107
|
+
graphServerTag: graphServiceTag,
|
|
108
|
+
identifiers: returnValue.objInstance.identifiers
|
|
109
|
+
}
|
|
110
|
+
)),
|
|
111
|
+
PREFIX.CREATE_OBJECT_ASYNC
|
|
112
|
+
)
|
|
113
|
+
_izContext.logger.debug("awaitingStepId:", awaitingStepId);
|
|
114
|
+
|
|
115
|
+
let recordAwaitingSteps = await dynamodbSharedLib.query(
|
|
116
|
+
_izContext,
|
|
117
|
+
await dynamodbSharedLib.tableName(_izContext, "AwaitingMultipleSteps"),
|
|
118
|
+
{
|
|
119
|
+
awaitingStepId: awaitingStepId
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
_izContext.logger.debug("record awaitingSteps::", recordAwaitingSteps);
|
|
123
|
+
|
|
124
|
+
nextAwaitingAteps:
|
|
125
|
+
for (let listRecordAwaitingStep of recordAwaitingSteps.Items) {
|
|
126
|
+
|
|
127
|
+
_izContext.logger.debug("iterate RecordAwaitingStep:", listRecordAwaitingStep);
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
if (!await asyncFlowSharedLib.checkAllAwaitingStepsFinished(
|
|
131
|
+
_izContext,
|
|
132
|
+
listRecordAwaitingStep.pendingStepId,
|
|
133
|
+
awaitingStepId
|
|
134
|
+
)) {
|
|
135
|
+
_izContext.logger.debug("!Waiting record form other graph::")
|
|
136
|
+
// **** add step of remove awaitingMultiplestep!! ??
|
|
137
|
+
continue nextAwaitingAteps
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
await asyncFlowSharedLib.removeAwaitingMultipleStep(
|
|
141
|
+
_izContext,
|
|
142
|
+
awaitingStepId,
|
|
143
|
+
listRecordAwaitingStep.pendingStepId,
|
|
144
|
+
);
|
|
145
|
+
_izContext.logger.debug("Remove awaitingStep finish")
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
// seagame: problem about lambdaComplete is will missing errorsFound from request if have 2 request
|
|
149
|
+
// one send with errorsFound and one send without errorsFound
|
|
150
|
+
// this scenario can complete with or without errorsFound
|
|
151
|
+
let messageObject = {
|
|
152
|
+
objType: returnValue.objType,
|
|
153
|
+
identifierId: returnValue.objInstance.identifiers,
|
|
154
|
+
errorFounds: errorFounds
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
messageObject = callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(passBackProperties, messageObject)
|
|
158
|
+
let messageAttributes = callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(passBackProperties, {})
|
|
159
|
+
|
|
160
|
+
let sendMessageOutCreateObjectComplete = {
|
|
161
|
+
Message: JSON.stringify(messageObject),
|
|
162
|
+
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
163
|
+
TopicArn: await snsSharedLib.snsTopicArn(_izContext, "OutCreateObjectComplete")
|
|
164
|
+
};
|
|
165
|
+
_izContext.logger.debug("Send message to OutCreateObjectComplete :::>", sendMessageOutCreateObjectComplete)
|
|
166
|
+
await sns.publishAsync(_izContext, sendMessageOutCreateObjectComplete);
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
} catch (err) {
|
|
170
|
+
throw (err)
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -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
|
+
|
|
20
|
+
const path = require("path")
|
|
21
|
+
const templatePath = path.join(__dirname, './template.ejs');
|
|
22
|
+
const { SOURCE_PATH, FUNCTION_NAME, SAVE_FILE_NAME } = require('../../../libs/Consts');
|
|
23
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils")
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* create data for dynamoDbYaml tempalte from objectSchema
|
|
27
|
+
* return array of dynamoDb data
|
|
28
|
+
* because one objectSchema can create multiple dynamoDb table
|
|
29
|
+
*
|
|
30
|
+
* @param {Object} _izContext
|
|
31
|
+
* @param {String} saveFilePath
|
|
32
|
+
* @returns {Object[]} - data of multiple dynamoDb template
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
function data(_izContext, srcPath) {
|
|
36
|
+
let createUpdateNodeCompleteQueues = [];
|
|
37
|
+
const createCreateUpdatenodeCompleteQueueNames = [
|
|
38
|
+
{
|
|
39
|
+
queueName: upperCase(FUNCTION_NAME.createObjectComplete)
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
for (let createUpdateNodeCompleteQueueName of createCreateUpdatenodeCompleteQueueNames) {
|
|
43
|
+
createUpdateNodeCompleteQueues.push({
|
|
44
|
+
templatePath: templatePath,
|
|
45
|
+
templateData: createUpdateNodeCompleteQueueName,
|
|
46
|
+
setting: {
|
|
47
|
+
initialData: "Resource\n",
|
|
48
|
+
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
49
|
+
saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
|
|
50
|
+
fileExtension: ".yml",
|
|
51
|
+
isAppend: true
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
return createUpdateNodeCompleteQueues
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
module.exports = data
|
package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-in-sqs/template.ejs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
##===== [Queue]
|
|
2
|
+
<%- queueName %>:
|
|
3
|
+
Type: "AWS::SQS::Queue"
|
|
4
|
+
Properties:
|
|
5
|
+
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>
|
|
6
|
+
RedrivePolicy:
|
|
7
|
+
deadLetterTargetArn:
|
|
8
|
+
# !GetAtt
|
|
9
|
+
Fn::GetAtt:
|
|
10
|
+
- <%- queueName %>DLQ
|
|
11
|
+
- Arn
|
|
12
|
+
maxReceiveCount: 3
|
|
13
|
+
VisibilityTimeout: 120
|
|
14
|
+
##==== [QueueDLQ]
|
|
15
|
+
<%- queueName %>DLQ:
|
|
16
|
+
Type: AWS::SQS::Queue
|
|
17
|
+
Properties:
|
|
18
|
+
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>DLQ
|
|
19
|
+
##==== [QueuePolicy]
|
|
20
|
+
<%- queueName %>Policy:
|
|
21
|
+
Type: AWS::SQS::QueuePolicy
|
|
22
|
+
Properties:
|
|
23
|
+
PolicyDocument:
|
|
24
|
+
Version: "2012-10-17"
|
|
25
|
+
Statement:
|
|
26
|
+
- Sid: "allow-sns-messages"
|
|
27
|
+
Effect: Allow
|
|
28
|
+
Principal: "*"
|
|
29
|
+
Resource:
|
|
30
|
+
# !GetAtt
|
|
31
|
+
Fn::GetAtt:
|
|
32
|
+
- <%- queueName %>
|
|
33
|
+
- Arn
|
|
34
|
+
Action: "SQS:SendMessage"
|
|
35
|
+
Queues:
|
|
36
|
+
- Ref: <%- queueName %>
|
|
37
|
+
#<#<%- firstLetterUpperCase(queueName) %>QueueSetting#>
|
|
38
|
+
#<#/<%- firstLetterUpperCase(queueName) %>QueueSetting#>
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
<%_ function firstLetterUpperCase(text){
|
|
42
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
43
|
+
} _%>
|
|
44
|
+
<%_ function firstLetterLowerCase(str) {
|
|
45
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
46
|
+
} _%>
|
|
47
|
+
|
|
@@ -0,0 +1,62 @@
|
|
|
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, SAVE_FILE_NAME, FUNCTION_NAME } = require("../../../libs/Consts");
|
|
26
|
+
|
|
27
|
+
const templatePath = path.join(__dirname, "../../../ResourceYaml/sns-out/template.ejs")
|
|
28
|
+
// /ResourceYaml/sns-out/template.ejs
|
|
29
|
+
// /OutPerActionComplete/OutUpdateComplete/sns-out/data.js
|
|
30
|
+
/**
|
|
31
|
+
* create data for dynamoDbYaml tempalte from objectSchema
|
|
32
|
+
* return array of dynamoDb data
|
|
33
|
+
* because one objectSchema can create multiple dynamoDb table
|
|
34
|
+
*
|
|
35
|
+
* @param {Object} _izContext
|
|
36
|
+
* @param {String} saveFilePath
|
|
37
|
+
* @returns {Object[]} - data of multiple dynamoDb template
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
function data(_izContext, srcPath) {
|
|
41
|
+
const createSourceParams = createParamsForCreateSource(_izContext, srcPath)
|
|
42
|
+
return [createSourceParams]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function createParamsForCreateSource(_izContext, srcPath) {
|
|
46
|
+
let queueName = FUNCTION_NAME.createObjectComplete
|
|
47
|
+
return {
|
|
48
|
+
templatePath: templatePath,
|
|
49
|
+
templateData: {
|
|
50
|
+
queueName: upperCase(queueName)
|
|
51
|
+
},
|
|
52
|
+
setting: {
|
|
53
|
+
initialData: 'Resources:\n',
|
|
54
|
+
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
55
|
+
saveFileName: SAVE_FILE_NAME.snsOutYaml,
|
|
56
|
+
fileExtension: '.yml',
|
|
57
|
+
isAppend: true
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
module.exports = data
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
##--------- [Create Topic Out]
|
|
2
|
+
Out<%- firstLetterUpperCase(queueName) %>:
|
|
3
|
+
Type: AWS::SNS::Topic
|
|
4
|
+
Properties:
|
|
5
|
+
DisplayName: "SNS Message out"
|
|
6
|
+
TopicName: ${self:custom.iz_resourcePrefix}Out<%- firstLetterUpperCase(queueName) %>
|
|
7
|
+
|
|
8
|
+
<%_ function firstLetterUpperCase(text) {
|
|
9
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
10
|
+
} _%>
|
|
@@ -0,0 +1,98 @@
|
|
|
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
|
+
const { getGraphServiceNameFromGraphServerTagWithCache, getServiceNameWithCache } = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig')
|
|
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, SOURCE_PATH, externalResourceName, getGraphServiceNameFromAllRelSchema, FUNCTION_NAME, SAVE_FILE_NAME, getGraphServiceNameFromObjectSchema, defaultIamRolePerAction, SQS_RESOURCE, SNS_RESOURCE, DYNAMO_RESOURCE } = require("../../../libs/Consts");
|
|
26
|
+
|
|
27
|
+
const templatePath = path.join(__dirname, './template.ejs');
|
|
28
|
+
|
|
29
|
+
function data(_izContext, srcPath) {
|
|
30
|
+
return [createFunctionYamlOutUpdateComplete(_izContext, srcPath)]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function createFunctionYamlOutUpdateComplete(_izContext, srcPath) {
|
|
34
|
+
let functionName = upperCase(FUNCTION_NAME.updateNodeComplete)
|
|
35
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
36
|
+
let awaitingTables = ["AwaitingMultipleSteps", "AwaitingMultipleStepByPending"]
|
|
37
|
+
let handlerType = upperCase(HANDLER.hdrSqs)
|
|
38
|
+
|
|
39
|
+
additionalResourcePermission.push(
|
|
40
|
+
createIamRole(
|
|
41
|
+
{
|
|
42
|
+
[RESOURCE_CLASSES.sqs]: [
|
|
43
|
+
SQS_RESOURCE.deleteMessage,
|
|
44
|
+
SQS_RESOURCE.deleteMessageBatch,
|
|
45
|
+
SQS_RESOURCE.getQueueAttributes,
|
|
46
|
+
SQS_RESOURCE.getQueueUrl,
|
|
47
|
+
SQS_RESOURCE.receiveMessage,
|
|
48
|
+
SQS_RESOURCE.sendMessage
|
|
49
|
+
],
|
|
50
|
+
[RESOURCE_CLASSES.sns]: [
|
|
51
|
+
SNS_RESOURCE.publish,
|
|
52
|
+
SNS_RESOURCE.subscription
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
[
|
|
56
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName)),
|
|
57
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + "DLQ"),
|
|
58
|
+
resourceNames(RESOURCE_CLASSES.sns, "In" + upperCase(functionName)),
|
|
59
|
+
resourceNames(RESOURCE_CLASSES.sns, "Out" + upperCase(functionName)),
|
|
60
|
+
]
|
|
61
|
+
)
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
additionalResourcePermission.push(
|
|
65
|
+
createIamRole(
|
|
66
|
+
{
|
|
67
|
+
[RESOURCE_CLASSES.dynamoDbTable]: [
|
|
68
|
+
DYNAMO_RESOURCE.updateItem,
|
|
69
|
+
DYNAMO_RESOURCE.query,
|
|
70
|
+
DYNAMO_RESOURCE.deleteItem
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
awaitingTables.map(tableName =>
|
|
74
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, tableName)
|
|
75
|
+
)
|
|
76
|
+
)
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
templatePath: templatePath,
|
|
82
|
+
templateData: {
|
|
83
|
+
functionName,
|
|
84
|
+
handlerType,
|
|
85
|
+
additionalResourcePermission,
|
|
86
|
+
resourceLocation: SOURCE_PATH.resourceLocationPerAction
|
|
87
|
+
},
|
|
88
|
+
setting: {
|
|
89
|
+
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
90
|
+
saveFileName: SAVE_FILE_NAME.functionPerActionYaml,
|
|
91
|
+
fileExtension: '.yml',
|
|
92
|
+
isAppend: true
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
module.exports = data
|