@izara_project/izara-market-library-service-schemas 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/src/GenerateCodeLibs/src/Consts.js +40 -0
- package/src/TemplateManager/src/FunctionYaml/HdrApi/data.js +4 -4
- package/src/TemplateManager/src/FunctionYaml/HdrDsq/data.js +7 -5
- package/src/TemplateManager/src/FunctionYaml/HdrInv/data.js +3 -3
- package/src/TemplateManager/src/FunctionYaml/HdrSqs/data.js +11 -13
- package/src/TemplateManager/src/FunctionYaml/HdrSqs/template.ejs +1 -1
- package/src/TemplateManager/src/GenerateCode.js +117 -29
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/data.js +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/data.js +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/data.js +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/data.js +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/template.ejs +1 -1
- package/src/TemplateManager/src/ResourceYaml/dynamodb/awaitingMultipleStepData.js +98 -0
- package/src/TemplateManager/src/ResourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +7 -7
- package/src/TemplateManager/src/ResourceYaml/dynamodb/processLogicalAndFindData.js +4 -3
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical.js +4 -4
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/snsAndSqsPerActiondata.js +4 -4
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/sqsTemplate.ejs +1 -0
- package/src/TemplateManager/src/ResourceYaml/sns-out/data.js +89 -0
- package/src/TemplateManager/src/ResourceYaml/sns-out/request.json +3 -0
- package/src/TemplateManager/src/ResourceYaml/sns-out/template.ejs +10 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/data.js +151 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/request.json +3 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/template.ejs +33 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/handler/HdrSqs/data.js +76 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/handler/HdrSqs/request.json +0 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/handler/HdrSqs/template.ejs +127 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/data.js +55 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/request.json +1 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/template.ejs +140 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-in-sqs/data.js +75 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-in-sqs/request.json +3 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-in-sqs/template.ejs +45 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-out/data.js +70 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-out/request.json +3 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/data.js +127 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/request.json +0 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/template.ejs +33 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/data.js +148 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/request.json +0 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/data.js +125 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/request.json +0 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/data.js +148 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/request.json +0 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/mainFunction/data.js +80 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/mainFunction/request.json +1 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/mainFunction/template.ejs +324 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/data.js +72 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/request.json +7 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/template.ejs +120 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/data.js +73 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/request.json +7 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/template.ejs +167 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/data.js +73 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/request.json +5 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/template.ejs +126 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/data.js +73 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/request.json +7 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/template.ejs +146 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/request.json +31 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-in-sqs/data.js +91 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-in-sqs/request.json +3 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-out/data.js +70 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-out/request.json +3 -0
- package/src/TemplateManager/src/externalService/LambdaRole/data.js +56 -10
- package/src/TemplateManager/src/externalService/LambdaRole/template.ejs +6 -2
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/data.js +67 -2
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/request.json +12 -0
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/template.ejs +10 -14
- package/src/TemplateManager/src/libs/Consts.js +16 -25
- package/src/TemplateManager/src/MainResourcesYaml/CreateSourceData.js +0 -76
- package/src/TemplateManager/src/MainResourcesYaml/TemplateAndData/DynamoDbMain/Data/MainDynamoDbYamlData.js +0 -155
- package/src/TemplateManager/src/MainResourcesYaml/TemplateAndData/DynamoDbMain/Template/DynamoDb.ejs +0 -31
- package/src/TemplateManager/src/MainResourcesYaml/TemplateAndData/DynamoDbMain/Template/DynamoDb.exampleData.js +0 -12
|
@@ -0,0 +1,140 @@
|
|
|
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 hash = require("object-hash");
|
|
20
|
+
|
|
21
|
+
const izaraShared = require('@izara_project/izara-shared');
|
|
22
|
+
const callingFlowSharedLib = izaraShared.callingFlowSharedLib;
|
|
23
|
+
const configSharedLib = izaraShared.configSharedLib;
|
|
24
|
+
const snsSharedLib = izaraShared.snsSharedLib;
|
|
25
|
+
const asyncFlowSharedLib = izaraShared.asyncFlowSharedLib;
|
|
26
|
+
const dynamodbSharedLib = izaraShared.dynamodbSharedLib;
|
|
27
|
+
|
|
28
|
+
const sns = require("@izara_project/izara-core-library-external-request").sns;
|
|
29
|
+
const NoRetryError = require("@izara_project/izara-core-library-core/src/NoRetryError");
|
|
30
|
+
|
|
31
|
+
const { explodedObjectTypeId, explodedRelationshipTypeId, createLinkTypeId } = require('@izara_project/izara-core-library-service-schemas/src/Utils')
|
|
32
|
+
|
|
33
|
+
const {
|
|
34
|
+
PREFIX,
|
|
35
|
+
TOPIC_NAME_GRAPH_HANDLER,
|
|
36
|
+
TOPIC_NAME_GENERATE_CODE
|
|
37
|
+
} = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts');
|
|
38
|
+
|
|
39
|
+
module.exports.updateRelationshipComplete = async (
|
|
40
|
+
_izContext,
|
|
41
|
+
returnValue,
|
|
42
|
+
status,
|
|
43
|
+
errorsFound,
|
|
44
|
+
passBackProperties = {},
|
|
45
|
+
// callingFlowConfig = {}
|
|
46
|
+
) => {
|
|
47
|
+
try {
|
|
48
|
+
_izContext.logger.debug("Function:updateRelationshipComplete", {
|
|
49
|
+
returnValue: returnValue,
|
|
50
|
+
status: status,
|
|
51
|
+
errorsFound: errorsFound,
|
|
52
|
+
passBackProperties: passBackProperties,
|
|
53
|
+
// callingFlowConfig: callingFlowConfig
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
// start create awaitingStepId
|
|
58
|
+
const linkTypeId = createLinkTypeId(
|
|
59
|
+
_izContext,
|
|
60
|
+
[
|
|
61
|
+
returnValue.objects[0].objType,
|
|
62
|
+
returnValue.objects[1].objType,
|
|
63
|
+
],
|
|
64
|
+
returnValue.relType
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
let awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
|
|
68
|
+
hash({
|
|
69
|
+
linkTypeId,
|
|
70
|
+
relId: returnValue.relId,
|
|
71
|
+
relationshipProperties: returnValue.updatePropertiesParam,
|
|
72
|
+
graphServiceTag: passBackProperties.passBackProperties.graphServiceTag
|
|
73
|
+
}), // hash id
|
|
74
|
+
PREFIX.updateRel // prefix, use constant further
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
let updateRelPendingObjects = await dynamodbSharedLib.query(
|
|
79
|
+
_izContext,
|
|
80
|
+
await dynamodbSharedLib.tableName(_izContext, "AwaitingMultipleSteps"),
|
|
81
|
+
{
|
|
82
|
+
awaitingStepId: awaitingStepId
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
_izContext.logger.debug("record of updateRelPendingObjects ::", updateRelPendingObjects);
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
await Promise.all(
|
|
90
|
+
updateRelPendingObjects.Items.map(async ({ pendingStepId }) => {
|
|
91
|
+
if (await asyncFlowSharedLib.checkAllAwaitingStepsFinished(
|
|
92
|
+
_izContext,
|
|
93
|
+
pendingStepId, // task waiting
|
|
94
|
+
awaitingStepId
|
|
95
|
+
)) {
|
|
96
|
+
_izContext.logger.debug("finished all awaitingStep");
|
|
97
|
+
|
|
98
|
+
let updateCompleteMsg = {
|
|
99
|
+
relId: returnValue.relId,
|
|
100
|
+
relType: returnValue.relType,
|
|
101
|
+
status: status,
|
|
102
|
+
errorFounds: errorsFound
|
|
103
|
+
//(<inUpdateCompleteMsg>)
|
|
104
|
+
//(</inUpdateCompleteMsg>)
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
updateCompleteMsg = callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(passBackProperties, updateCompleteMsg);
|
|
108
|
+
_izContext.logger.debug("After addCallingFlowToSnsResponseMessageObject", updateCompleteMsg);
|
|
109
|
+
|
|
110
|
+
let messageAttributes = callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(passBackProperties, {});
|
|
111
|
+
_izContext.logger.debug("After addCallingFlowToSnsResponseMessageAttributes", updateCompleteMsg);
|
|
112
|
+
|
|
113
|
+
let sendMessageToOutUpdateRelatonshipComplete = {
|
|
114
|
+
Message: JSON.stringify(updateCompleteMsg),
|
|
115
|
+
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
116
|
+
TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GRAPH_HANDLER.outUpdateRelationshipComplete)
|
|
117
|
+
};
|
|
118
|
+
_izContext.logger.debug("Send message to OutUpdateRelationshipComplete :::>", sendMessageToOutUpdateRelatonshipComplete);
|
|
119
|
+
await sns.publishAsync(_izContext, sendMessageToOutUpdateRelatonshipComplete);
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
// remove awaitingMultipleStep after finished
|
|
123
|
+
await asyncFlowSharedLib.removeAwaitingMultipleStep(
|
|
124
|
+
_izContext,
|
|
125
|
+
awaitingStepId,
|
|
126
|
+
pendingStepId,
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
} // check pendingStepId finished
|
|
130
|
+
}) // end per pendingStep
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
return { returnValue: 'function:updateRelationshipComplete' };
|
|
135
|
+
|
|
136
|
+
} catch (err) {
|
|
137
|
+
_izContext.logger.error('error updateRelationshipComplete:', err)
|
|
138
|
+
throw (err)
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
|
|
22
|
+
|
|
23
|
+
// const {
|
|
24
|
+
// HANDLER,
|
|
25
|
+
// STORAGE_TYPES
|
|
26
|
+
// } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
const STORAGE_TYPES = {
|
|
30
|
+
dynamoDB: "dynamoDB",
|
|
31
|
+
graph: "graph"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const templatePath = path.join(__dirname, './template.ejs');
|
|
35
|
+
const { SOURCE_PATH } = require('../../../libs/Consts')
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* create data for dynamoDbYaml tempalte from objectSchema
|
|
40
|
+
* return array of dynamoDb data
|
|
41
|
+
* because one objectSchema can create multiple dynamoDb table
|
|
42
|
+
*
|
|
43
|
+
* @param {Object} _izContext
|
|
44
|
+
* @param {String} saveFilePath
|
|
45
|
+
* @returns {Object[]} - data of multiple dynamoDb template
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
function createDataForDefaultSnsInSqs(_izContext, srcPath) {
|
|
49
|
+
let resultsForCreateDefaultSnsInSqs = [];
|
|
50
|
+
const defaultSnsInSqsDataList = [
|
|
51
|
+
{
|
|
52
|
+
"queueName": "UpdateRelationshipComplete"
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
// console.log("defaultSnsInSqsDataList", defaultSnsInSqsDataList);
|
|
57
|
+
|
|
58
|
+
for (let defaultSnsInSqsData of defaultSnsInSqsDataList) {
|
|
59
|
+
resultsForCreateDefaultSnsInSqs.push({
|
|
60
|
+
templatePath,
|
|
61
|
+
templateData: defaultSnsInSqsData,
|
|
62
|
+
setting: {
|
|
63
|
+
initialData: "Resources:\n",
|
|
64
|
+
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
65
|
+
saveFileName: "generated-sns-in-sqs",
|
|
66
|
+
fileExtension: ".yml",
|
|
67
|
+
isAppend: true
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
// console.log("resultsForCreateDefaultSnsInSqs", resultsForCreateDefaultSnsInSqs);
|
|
72
|
+
return resultsForCreateDefaultSnsInSqs;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
module.exports = createDataForDefaultSnsInSqs;
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
<%_ function firstLetterUpperCase(text){
|
|
41
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
42
|
+
} _%>
|
|
43
|
+
<%_ function firstLetterLowerCase(str) {
|
|
44
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
45
|
+
} _%>
|
package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-out/data.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
|
|
22
|
+
|
|
23
|
+
// const {
|
|
24
|
+
// HANDLER,
|
|
25
|
+
// STORAGE_TYPES
|
|
26
|
+
// } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
const STORAGE_TYPES = {
|
|
30
|
+
dynamoDB: "dynamoDB",
|
|
31
|
+
graph: "graph"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase } = require("../../../../../MainLibs/src/Utils")
|
|
35
|
+
const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH } = require("../../../libs/Consts");
|
|
36
|
+
const templatePath = path.join(__dirname, '../../../ResourceYaml/sns-out/template.ejs')
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* create data for dynamoDbYaml tempalte from objectSchema
|
|
40
|
+
* return array of dynamoDb data
|
|
41
|
+
* because one objectSchema can create multiple dynamoDb table
|
|
42
|
+
*
|
|
43
|
+
* @param {Object} _izContext
|
|
44
|
+
* @param {String} saveFilePath
|
|
45
|
+
* @returns {Object[]} - data of multiple dynamoDb template
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
function createDefaultSnsOut(_izContext, srcPath) {
|
|
49
|
+
const createSourceParams = createParamsForCreateSource(_izContext, srcPath)
|
|
50
|
+
return [createSourceParams]
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function createParamsForCreateSource(_izContext, srcPath) {
|
|
54
|
+
let queueName = "updateRelationshipComplete"
|
|
55
|
+
return {
|
|
56
|
+
templatePath: templatePath,
|
|
57
|
+
templateData: {
|
|
58
|
+
queueName: queueName
|
|
59
|
+
},
|
|
60
|
+
setting: {
|
|
61
|
+
initialData: 'Resources:\n',
|
|
62
|
+
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
63
|
+
saveFileName: "generated-sns-out",
|
|
64
|
+
fileExtension: '.yml',
|
|
65
|
+
isAppend: true
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
module.exports = createDefaultSnsOut
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
const path = require('path');
|
|
20
|
+
const fs = require('fs');
|
|
21
|
+
|
|
22
|
+
const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
23
|
+
|
|
24
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils")
|
|
25
|
+
const { DEFAULT_HANDLER_PER_ACTION, createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SQS_RESOURCE, SOURCE_PATH } = require("../../../../libs/Consts");
|
|
26
|
+
|
|
27
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
28
|
+
|
|
29
|
+
function defaultIamRolePerAction() {
|
|
30
|
+
|
|
31
|
+
let defaultIamRole = [];
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
defaultIamRole.push(
|
|
35
|
+
createIamRole(
|
|
36
|
+
{
|
|
37
|
+
[RESOURCE_CLASSES.s3]: ["GetObject", "GetObjectVersion"],
|
|
38
|
+
},
|
|
39
|
+
[
|
|
40
|
+
resourceNames(RESOURCE_CLASSES.s3, "object-schema/perServiceSchemas/*"),
|
|
41
|
+
resourceNames(RESOURCE_CLASSES.s3, "object-schema/serviceConfig/ServiceNameConfig.json"),
|
|
42
|
+
resourceNames(RESOURCE_CLASSES.s3, "object-schema/serviceConfig/GraphServerTags.json"),
|
|
43
|
+
]
|
|
44
|
+
)
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
defaultIamRole.push(
|
|
48
|
+
createIamRole(
|
|
49
|
+
{ [RESOURCE_CLASSES.s3]: ["ListBucket"] },
|
|
50
|
+
[
|
|
51
|
+
resourceNames(RESOURCE_CLASSES.s3, "object-schema"),
|
|
52
|
+
]
|
|
53
|
+
)
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
return defaultIamRole
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* receive objectSchema
|
|
61
|
+
* create data for updateRelationshipSchema
|
|
62
|
+
*
|
|
63
|
+
* @param {Object} objectSchema
|
|
64
|
+
* @return {{ templatePath, templateData, setting } }
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
function data(_izContext, srcPath) {
|
|
68
|
+
let createSourceArray = [];
|
|
69
|
+
|
|
70
|
+
const createSourceParam = createParamForCreateSource(srcPath);
|
|
71
|
+
createSourceArray.push(createSourceParam);
|
|
72
|
+
// console.log("createSourceArrayInUpdaterelationShipSchemahdrSqs", createSourceArray)
|
|
73
|
+
return createSourceArray
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
function createParamForCreateSource(srcPath) {
|
|
78
|
+
|
|
79
|
+
let handlerType = "HdrApi"
|
|
80
|
+
let functionName = 'updateRelationship'
|
|
81
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
82
|
+
|
|
83
|
+
additionalResourcePermission.push(
|
|
84
|
+
createIamRole(
|
|
85
|
+
{ [RESOURCE_CLASSES.dynamoDbTable]: ["PutItem"] },
|
|
86
|
+
[
|
|
87
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "AwaitingMultipleSteps"),
|
|
88
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "AwaitingMultipleStepByPending")
|
|
89
|
+
]
|
|
90
|
+
))
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
templatePath: templatePath,
|
|
95
|
+
templateData: {
|
|
96
|
+
functionName,
|
|
97
|
+
handlerType,
|
|
98
|
+
additionalResourcePermission,
|
|
99
|
+
resourceLocation: SOURCE_PATH.resourceLocationUpdateRelationshipSchema
|
|
100
|
+
},
|
|
101
|
+
setting: {
|
|
102
|
+
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
103
|
+
saveFileName: 'updateRelationshipSchema',
|
|
104
|
+
fileExtension: '.yml',
|
|
105
|
+
isAppend: true
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
// [
|
|
114
|
+
// {
|
|
115
|
+
// templatePath: '/home/toughnut/BasProgram/empty-service-template/app/node_modules/@izara_project/izara-market-library-service-schemas/src/TemplateManager/src/MainResourcesYaml/TemplateAndData/DynamoDbMain/Template/DynamoDb.ejs',
|
|
116
|
+
// templateData: { tableName: 'ObjectTypeSingle', attributes: [Array] },
|
|
117
|
+
// setting: {
|
|
118
|
+
// savePath: '/generatedCode/source/',
|
|
119
|
+
// saveFileName: 'ObjectTypeGet',
|
|
120
|
+
// fileExtension: '.js',
|
|
121
|
+
// isAppend: false
|
|
122
|
+
// }
|
|
123
|
+
// }
|
|
124
|
+
// ]
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
module.exports = data;
|
|
File without changes
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<%_ const join = require('path').join; _%>
|
|
2
|
+
<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>:
|
|
3
|
+
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
|
+
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
|
+
events:
|
|
6
|
+
- http:
|
|
7
|
+
path: <%- objectType %>/<%- firstLetterUpperCase(action) %>
|
|
8
|
+
method: <%- event %>
|
|
9
|
+
cors: true
|
|
10
|
+
#<#Authorizer#>
|
|
11
|
+
#<#/Authorizer#>
|
|
12
|
+
iamRoleStatements:
|
|
13
|
+
<%_ additionalResourcePermission.forEach(resourcePermission => { _%>
|
|
14
|
+
- Effect: <%- resourcePermission.effect %>
|
|
15
|
+
Action:
|
|
16
|
+
<%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
|
|
17
|
+
<%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
|
|
18
|
+
- <%- resourcePerAction %>:<%- permission %>
|
|
19
|
+
<%_}) _%>
|
|
20
|
+
<%_ }) _%>
|
|
21
|
+
Resource:
|
|
22
|
+
<%_ resourcePermission.resource.forEach(resource => { _%>
|
|
23
|
+
- <%- resource %>
|
|
24
|
+
<%_ }) _%>
|
|
25
|
+
<%_}) _%>
|
|
26
|
+
#<#<%- functionName %><%- handlerType %>IamRole#>
|
|
27
|
+
#<#/<%- functionName %><%- handlerType %>IamRole#>
|
|
28
|
+
<%_ function firstLetterUpperCase(text){
|
|
29
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
30
|
+
} _%>
|
|
31
|
+
<%_ function firstLetterLowerCase(str) {
|
|
32
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
33
|
+
} _%>
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
const path = require('path');
|
|
20
|
+
const fs = require('fs');
|
|
21
|
+
|
|
22
|
+
const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
23
|
+
|
|
24
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils")
|
|
25
|
+
const { DEFAULT_HANDLER_PER_ACTION, createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SQS_RESOURCE, SOURCE_PATH } = require("../../../../libs/Consts");
|
|
26
|
+
|
|
27
|
+
const templatePath = path.join(__dirname, "../../../../FunctionYaml/HdrDsq/template.ejs")
|
|
28
|
+
|
|
29
|
+
function defaultIamRolePerAction() {
|
|
30
|
+
|
|
31
|
+
let defaultIamRole = [];
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
defaultIamRole.push(
|
|
35
|
+
createIamRole(
|
|
36
|
+
{
|
|
37
|
+
[RESOURCE_CLASSES.s3]: ["GetObject", "GetObjectVersion"],
|
|
38
|
+
},
|
|
39
|
+
[
|
|
40
|
+
resourceNames(RESOURCE_CLASSES.s3, "object-schema/perServiceSchemas/*"),
|
|
41
|
+
resourceNames(RESOURCE_CLASSES.s3, "object-schema/serviceConfig/ServiceNameConfig.json"),
|
|
42
|
+
resourceNames(RESOURCE_CLASSES.s3, "object-schema/serviceConfig/GraphServerTags.json"),
|
|
43
|
+
]
|
|
44
|
+
)
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
defaultIamRole.push(
|
|
48
|
+
createIamRole(
|
|
49
|
+
{ [RESOURCE_CLASSES.s3]: ["ListBucket"] },
|
|
50
|
+
[
|
|
51
|
+
resourceNames(RESOURCE_CLASSES.s3, "object-schema"),
|
|
52
|
+
]
|
|
53
|
+
)
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
return defaultIamRole
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* receive objectSchema
|
|
61
|
+
* create data for updateRelationshipSchema
|
|
62
|
+
*
|
|
63
|
+
* @param {Object} objectSchema
|
|
64
|
+
* @return {{ templatePath, templateData, setting } }
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
function data(_izContext, srcPath) {
|
|
68
|
+
let createSourceArray = [];
|
|
69
|
+
|
|
70
|
+
const createSourceParam = createParamForCreateSource(srcPath);
|
|
71
|
+
createSourceArray.push(createSourceParam);
|
|
72
|
+
// console.log("createSourceArrayInUpdaterelationShipSchemahdrSqs", createSourceArray)
|
|
73
|
+
return createSourceArray
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
function createParamForCreateSource(srcPath) {
|
|
78
|
+
|
|
79
|
+
let handlerType = "HdrDsq"
|
|
80
|
+
let functionName = 'updateRelationship'
|
|
81
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
82
|
+
|
|
83
|
+
additionalResourcePermission.push(
|
|
84
|
+
// createIamRole(
|
|
85
|
+
// { [RESOURCE_CLASSES.lambda]: ["InvokeFunction"] },
|
|
86
|
+
// [resourceNames(RESOURCE_CLASSES.lambda, "*GetNodeHdrInv")]),
|
|
87
|
+
createIamRole(
|
|
88
|
+
{
|
|
89
|
+
[RESOURCE_CLASSES.sqs]: [
|
|
90
|
+
SQS_RESOURCE.deleteMessage,
|
|
91
|
+
SQS_RESOURCE.getQueueAttributes,
|
|
92
|
+
SQS_RESOURCE.receiveMessage,
|
|
93
|
+
SQS_RESOURCE.sendMessage,
|
|
94
|
+
SQS_RESOURCE.deleteMessageBatch,
|
|
95
|
+
SQS_RESOURCE.getQueueUrl
|
|
96
|
+
]
|
|
97
|
+
},
|
|
98
|
+
[
|
|
99
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrDsq)),
|
|
100
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrDsq) + "DLQ")
|
|
101
|
+
]
|
|
102
|
+
)
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
additionalResourcePermission.push(
|
|
106
|
+
createIamRole(
|
|
107
|
+
{ [RESOURCE_CLASSES.dynamoDbTable]: ["PutItem"] },
|
|
108
|
+
[
|
|
109
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "AwaitingMultipleSteps"),
|
|
110
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "AwaitingMultipleStepByPending")
|
|
111
|
+
]
|
|
112
|
+
))
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
templatePath: templatePath,
|
|
116
|
+
templateData: {
|
|
117
|
+
functionName,
|
|
118
|
+
handlerType,
|
|
119
|
+
additionalResourcePermission,
|
|
120
|
+
resourceLocation: SOURCE_PATH.resourceLocationUpdateRelationshipSchema
|
|
121
|
+
},
|
|
122
|
+
setting: {
|
|
123
|
+
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
124
|
+
saveFileName: 'updateRelationshipSchema',
|
|
125
|
+
fileExtension: '.yml',
|
|
126
|
+
isAppend: true
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
// [
|
|
135
|
+
// {
|
|
136
|
+
// templatePath: '/home/toughnut/BasProgram/empty-service-template/app/node_modules/@izara_project/izara-market-library-service-schemas/src/TemplateManager/src/MainResourcesYaml/TemplateAndData/DynamoDbMain/Template/DynamoDb.ejs',
|
|
137
|
+
// templateData: { tableName: 'ObjectTypeSingle', attributes: [Array] },
|
|
138
|
+
// setting: {
|
|
139
|
+
// savePath: '/generatedCode/source/',
|
|
140
|
+
// saveFileName: 'ObjectTypeGet',
|
|
141
|
+
// fileExtension: '.js',
|
|
142
|
+
// isAppend: false
|
|
143
|
+
// }
|
|
144
|
+
// }
|
|
145
|
+
// ]
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
module.exports = data;
|
|
File without changes
|