@izara_project/izara-market-library-service-schemas 1.0.19 → 1.0.20
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 +1 -1
- package/src/SourceManager/src/Utils.js +33 -9
- package/src/TemplateManager/src/FindData/FindDataYaml/data.js +4 -1
- package/src/TemplateManager/src/FindData/FindDataYaml/template.ejs +1 -14
- package/src/TemplateManager/src/GenerateCode.js +22 -5
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/functionYaml/data.js +22 -2
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/functionYaml/template.ejs +1 -14
- package/src/TemplateManager/src/OutPerActionComplete/OutDeleteComplete/functionYaml/data.js +21 -2
- package/src/TemplateManager/src/OutPerActionComplete/OutDeleteComplete/functionYaml/template.ejs +1 -14
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/functionYaml/data.js +23 -3
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/functionYaml/template.ejs +1 -14
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/functionYaml/data.js +22 -2
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/functionYaml/template.ejs +1 -14
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/data.js +6 -6
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/template.ejs +1 -14
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrDsq/data.js +2 -1
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrDsq/template.ejs +1 -14
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrInv/data.js +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrInv/template.ejs +1 -14
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrSqs/data.js +3 -1
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrSqs/template.ejs +1 -14
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrWbs/data.js +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/template.ejs +23 -3
- package/src/TemplateManager/src/ProcessLogical/ProcessLogicalYaml/data.js +18 -2
- package/src/TemplateManager/src/ProcessLogical/ProcessLogicalYaml/template.ejs +1 -14
- package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrDsq/data.js +20 -3
- package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrDsq/template.ejs +1 -14
- package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrSqs/data.js +21 -3
- package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrSqs/template.ejs +1 -14
- package/src/TemplateManager/src/ProcessLogicalPagination/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrApi/data.js +16 -2
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrApi/template.ejs +1 -14
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrDsq/data.js +17 -2
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrDsq/template.ejs +1 -14
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrInv/data.js +16 -2
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrInv/template.ejs +1 -14
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrSqs/data.js +18 -3
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrSqs/template.ejs +1 -14
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationshipComplete/functionYaml/data.js +18 -3
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationshipComplete/functionYaml/template.ejs +1 -14
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrApi/data.js +15 -2
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrApi/template.ejs +1 -14
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrDsq/data.js +17 -2
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrDsq/template.ejs +1 -14
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrInv/data.js +16 -2
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrInv/template.ejs +1 -14
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrSqs/data.js +18 -3
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrSqs/template.ejs +1 -14
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationshipComplete/functionYaml/data.js +18 -3
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationshipComplete/functionYaml/template.ejs +1 -14
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/data.js +19 -4
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/template.ejs +1 -14
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/data.js +19 -2
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/template.ejs +1 -14
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/data.js +19 -2
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/template.ejs +1 -14
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/data.js +20 -2
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/template.ejs +1 -14
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/data.js +20 -2
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/template.ejs +1 -14
- package/src/TemplateManager/src/Role/createSharedResource.js +270 -0
- package/src/TemplateManager/src/Role/sharedResourceTemplate.ejs +58 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/functionYaml/HdrDsq/data.js +1 -1
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/functionYaml/HdrSqs/data.js +1 -1
- package/src/TemplateManager/src/externalService/LambdaRole/data.js +13 -13
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/functionYaml/data.js +16 -10
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/handler/data.js +8 -5
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/handler/template.ejs +22 -9
- package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/functionYaml/data.js +102 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/functionYaml/template.ejs +43 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/handler/data.js +94 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/handler/templateAsyncHandler.ejs +110 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/handler/templateSyncHandler.ejs +49 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/hookLogic/data.js +65 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/mainFunction/data.js +67 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/mainFunction/template.ejs +30 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/queue/data.js +125 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/queue/snsTemplate.ejs +59 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/queue/sqsTemplate.ejs +43 -0
- package/src/TemplateManager/src/libs/Consts.js +36 -10
- package/src/TemplateManager/src/reStructureExample/GenerateCodeTest.js +31 -0
- package/src/TemplateManager/src/reStructureExample/TemplateConfig.js +11 -0
- package/src/TemplateManager/src/reStructureExample/TemplateData/perAction/data.js +0 -0
- package/src/TemplateManager/src/reStructureExample/TemplateData/perAction/generateCodeShared.js +1 -0
- package/src/TemplateManager/src/reStructureExample/TemplateData/perAction/generatePerAction.js +5 -0
- package/src/TemplateManager/src/reStructureExample/TemplateData/perAction/template.ejs +0 -0
|
@@ -0,0 +1,125 @@
|
|
|
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
|
+
const { HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
22
|
+
const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
|
|
23
|
+
const { SOURCE_PATH, defaultIamRolePerAction, createIamRole, RESOURCE_CLASSES, SNS_RESOURCE, resourceNames, DYNAMO_RESOURCE, SAVE_FILE_NAME, FUNCTION_NAME, shortNameHandler, SQS_RESOURCE } = require("../../../../libs/Consts");
|
|
24
|
+
const snsTemplatePath = path.join(__dirname, "./snsTemplate.ejs");
|
|
25
|
+
const sqsTemplatePath = path.join(__dirname, "./sqsTemplate.ejs");
|
|
26
|
+
/**
|
|
27
|
+
* receive objectSchema
|
|
28
|
+
* create data for WebScoket handler template
|
|
29
|
+
*
|
|
30
|
+
* @param {Object} objectSchema
|
|
31
|
+
* @return {{templatePath, templateData,setting}}
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
35
|
+
let queueNames = [];
|
|
36
|
+
let resultForCreateQueueHook = []
|
|
37
|
+
const settings = {
|
|
38
|
+
saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
|
|
39
|
+
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
40
|
+
fileExtension: ".yml",
|
|
41
|
+
isAppend: true
|
|
42
|
+
}
|
|
43
|
+
if (flowSchema?.hook) {
|
|
44
|
+
for (const hookProperties of Object.values(flowSchema.hook)) {
|
|
45
|
+
for (const hookFunction of hookProperties.functionList) {
|
|
46
|
+
if (hookFunction.event.continueFlow === true) {
|
|
47
|
+
if (hookFunction.event.handlerType === HANDLER.hdrSqs) {
|
|
48
|
+
queueNames.push(
|
|
49
|
+
{
|
|
50
|
+
queueName: "In" + createResourceSqsAndSns(
|
|
51
|
+
hookFunction.event.handlerType,
|
|
52
|
+
upperCase(hookProperties.name)
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
} else if (hookFunction.event.handlerType === HANDLER.hdrDsq) {
|
|
57
|
+
queueNames.push(
|
|
58
|
+
{
|
|
59
|
+
queueName: createResourceSqsAndSns(
|
|
60
|
+
hookFunction.event.handlerType,
|
|
61
|
+
upperCase(hookFunction.name)
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
if (hookFunction.event.createNewTopic === true) {
|
|
67
|
+
if (hookFunction.event.handlerType === HANDLER.hdrSqs) {
|
|
68
|
+
queueNames.push(
|
|
69
|
+
{
|
|
70
|
+
queueName: createResourceSqsAndSns(
|
|
71
|
+
hookFunction.event.handlerType,
|
|
72
|
+
upperCase(hookFunction.event.topicName)
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
} else if (hookFunction.event.handlerType === HANDLER.hdrDsq) {
|
|
77
|
+
queueNames.push(
|
|
78
|
+
{
|
|
79
|
+
queueName: createResourceSqsAndSns(
|
|
80
|
+
hookFunction.event.handlerType,
|
|
81
|
+
upperCase(hookFunction.event.queueName)
|
|
82
|
+
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
for (const queueName of queueNames) {
|
|
95
|
+
if (queueName.queueName.includes(upperCase(HANDLER.hdrDsq))) {
|
|
96
|
+
resultForCreateQueueHook.push({
|
|
97
|
+
templatePath: sqsTemplatePath,
|
|
98
|
+
templateData: queueName.queueName,
|
|
99
|
+
setting: settings
|
|
100
|
+
})
|
|
101
|
+
} else {
|
|
102
|
+
resultForCreateQueueHook.push({
|
|
103
|
+
templatePath: snsTemplatePath,
|
|
104
|
+
templateData: queueName,
|
|
105
|
+
setting: settings
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
console.log("resultForCreateQueueHook: ", resultForCreateQueueHook);
|
|
110
|
+
return resultForCreateQueueHook;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function createResourceSqsAndSns(handlerType, resourceName) {
|
|
114
|
+
let queueName
|
|
115
|
+
if (handlerType === HANDLER.hdrDsq) {
|
|
116
|
+
queueName = upperCase(resourceName) + handlerType
|
|
117
|
+
} else if (handlerType === HANDLER.hdrSqs) {
|
|
118
|
+
if (resourceName.includes("In")) {
|
|
119
|
+
resourceName.slice(2)
|
|
120
|
+
}
|
|
121
|
+
queueName = resourceName
|
|
122
|
+
}
|
|
123
|
+
return queueName
|
|
124
|
+
}
|
|
125
|
+
module.exports = createSourceParams;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
##===== [Create topic in]
|
|
2
|
+
In<%- queueName %>:
|
|
3
|
+
Type: AWS::SNS::Topic
|
|
4
|
+
Properties:
|
|
5
|
+
DisplayName: "SNS Message in"
|
|
6
|
+
TopicName: ${self:custom.iz_resourcePrefix}In<%- queueName %>
|
|
7
|
+
##===== SNS Subscription
|
|
8
|
+
##===== [Topic In]
|
|
9
|
+
SubscriptionIn<%- queueName %>:
|
|
10
|
+
Type: AWS::SNS::Subscription
|
|
11
|
+
Properties:
|
|
12
|
+
TopicArn: !Ref In<%- queueName %>
|
|
13
|
+
Endpoint: "arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqs"
|
|
14
|
+
Protocol: "sqs"
|
|
15
|
+
##===== [Queue]
|
|
16
|
+
<%- queueName %>HdrSqs:
|
|
17
|
+
Type: "AWS::SQS::Queue"
|
|
18
|
+
Properties:
|
|
19
|
+
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqs
|
|
20
|
+
RedrivePolicy:
|
|
21
|
+
deadLetterTargetArn:
|
|
22
|
+
# !GetAtt
|
|
23
|
+
Fn::GetAtt:
|
|
24
|
+
- <%- queueName %>HdrSqsDLQ
|
|
25
|
+
- Arn
|
|
26
|
+
maxReceiveCount: 3
|
|
27
|
+
VisibilityTimeout: 120
|
|
28
|
+
##==== [QueueDLQ]
|
|
29
|
+
<%- queueName %>HdrSqsDLQ:
|
|
30
|
+
Type: AWS::SQS::Queue
|
|
31
|
+
Properties:
|
|
32
|
+
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqsDLQ
|
|
33
|
+
##==== [QueuePolicy]
|
|
34
|
+
<%- queueName %>HdrSqsPolicy:
|
|
35
|
+
Type: AWS::SQS::QueuePolicy
|
|
36
|
+
Properties:
|
|
37
|
+
PolicyDocument:
|
|
38
|
+
Version: "2012-10-17"
|
|
39
|
+
Statement:
|
|
40
|
+
- Sid: "allow-sns-messages"
|
|
41
|
+
Effect: Allow
|
|
42
|
+
Principal: "*"
|
|
43
|
+
Resource:
|
|
44
|
+
# !GetAtt
|
|
45
|
+
Fn::GetAtt:
|
|
46
|
+
- <%- queueName %>HdrSqs
|
|
47
|
+
- Arn
|
|
48
|
+
Action: "SQS:SendMessage"
|
|
49
|
+
Queues:
|
|
50
|
+
- Ref: <%- queueName %>HdrSqs
|
|
51
|
+
#<#<%- firstLetterUpperCase(queueName) %>QueueSetting#>
|
|
52
|
+
#<#/<%- firstLetterUpperCase(queueName) %>QueueSetting#>
|
|
53
|
+
|
|
54
|
+
<%_ function firstLetterUpperCase(text){
|
|
55
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
56
|
+
} _%>
|
|
57
|
+
<%_ function firstLetterLowerCase(str) {
|
|
58
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
59
|
+
} _%>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#------- queue ---------
|
|
2
|
+
<%- queueName %>:
|
|
3
|
+
Type: "AWS::SQS::Queue"
|
|
4
|
+
Properties:
|
|
5
|
+
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>
|
|
6
|
+
RedrivePolicy:
|
|
7
|
+
deadLetterTargetArn: #!GetAtt
|
|
8
|
+
Fn::GetAtt:
|
|
9
|
+
- <%- queueName %>DLQ
|
|
10
|
+
- Arn
|
|
11
|
+
maxReceiveCount: 3
|
|
12
|
+
VisibilityTimeout: 120
|
|
13
|
+
|
|
14
|
+
<%- queueName %>DLQ:
|
|
15
|
+
Type: AWS::SQS::Queue
|
|
16
|
+
Properties:
|
|
17
|
+
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>DLQ
|
|
18
|
+
|
|
19
|
+
<%- queueName %>Policy:
|
|
20
|
+
Type: AWS::SQS::QueuePolicy
|
|
21
|
+
Properties:
|
|
22
|
+
PolicyDocument:
|
|
23
|
+
Version: "2012-10-17"
|
|
24
|
+
Statement:
|
|
25
|
+
- Sid: "allow-sns-messages"
|
|
26
|
+
Effect: Allow
|
|
27
|
+
Principal: "*"
|
|
28
|
+
Resource: #!GetAtt
|
|
29
|
+
Fn::GetAtt:
|
|
30
|
+
- <%- queueName %>
|
|
31
|
+
- Arn
|
|
32
|
+
Action: "SQS:SendMessage"
|
|
33
|
+
Queues:
|
|
34
|
+
- Ref: <%- queueName %>
|
|
35
|
+
#<#<%- firstLetterUpperCase(queueName) %>QueueSetting#>
|
|
36
|
+
#<#/<%- firstLetterUpperCase(queueName) %>QueueSetting#>
|
|
37
|
+
|
|
38
|
+
<%_ function firstLetterUpperCase(text){
|
|
39
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
40
|
+
} _%>
|
|
41
|
+
<%_ function firstLetterLowerCase(str) {
|
|
42
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
43
|
+
} _%>
|
|
@@ -23,6 +23,8 @@ const {
|
|
|
23
23
|
STORAGE_TYPES
|
|
24
24
|
} = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
25
25
|
|
|
26
|
+
const { firstLetterUpperCase: upperCase } = require("../../../MainLibs/src/Utils")
|
|
27
|
+
|
|
26
28
|
const { getGraphServiceNameFromGraphServerTagWithCache, getGraphServiceTagWithCache } = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig');
|
|
27
29
|
|
|
28
30
|
const DEFAULT_HANDLER_PER_ACTION = {
|
|
@@ -37,7 +39,7 @@ const RESOURCE_CLASSES = {
|
|
|
37
39
|
s3: 's3',
|
|
38
40
|
dynamoDbTable: 'dynamodb',
|
|
39
41
|
dynamoDbAcrossService: 'dynamodb',
|
|
40
|
-
sns: "
|
|
42
|
+
sns: "sns",
|
|
41
43
|
lambda: "lambda",
|
|
42
44
|
webSocket: "webSocket"
|
|
43
45
|
};
|
|
@@ -72,7 +74,7 @@ function createIamRole(action, resource = [], effect = "Allow") {
|
|
|
72
74
|
action.forEach(act => {
|
|
73
75
|
if (act.includes(":")) {
|
|
74
76
|
const [serviceAction, resourceAction] = act.split(":")
|
|
75
|
-
actionObj[serviceAction] = [resourceAction]
|
|
77
|
+
actionObj[serviceAction] = [upperCase(resourceAction)]
|
|
76
78
|
}
|
|
77
79
|
});
|
|
78
80
|
action = actionObj
|
|
@@ -116,7 +118,10 @@ const SOURCE_PATH = {
|
|
|
116
118
|
webSocket: "../src/generatedCode/WebSocket/source/",
|
|
117
119
|
resourceLocationWebSocket: "src/generatedCode/WebSocket/source/",
|
|
118
120
|
generateCodeLib: "../src/generatedCode/libs/source/",
|
|
119
|
-
|
|
121
|
+
logicalFunctionHook: "../src/generatedCode/WebSocket/source/FlowSchemaHook/HookLogicFunction/source/",
|
|
122
|
+
resourceLocationLogicalFunctionHook: "src/generatedCode/WebSocket/source/FlowSchemaHook/HookLogicFunction/source",
|
|
123
|
+
generatedCodeHookFunction: "../src/generatedCode/WebSocket/source/FlowSchemaHook/HookFunctionGeneratedCode/source/",
|
|
124
|
+
resourceLocationGeneratedCodeHookFunction: "src/generatedCode/WebSocket/source/FlowSchemaHook/HookFunctionGeneratedCode/source/",
|
|
120
125
|
};
|
|
121
126
|
|
|
122
127
|
|
|
@@ -178,13 +183,26 @@ function externalResourceName(resourceClass, resourceName, serviceTag) {
|
|
|
178
183
|
return {
|
|
179
184
|
[RESOURCE_CLASSES.dynamoDbTable]: "arn:aws:dynamodb:${process.env.iz_region}:${process.env.iz_accountId}:table/${await dynamoSharedLib.tableName(_izContext, " + `"${resourceName}" ,"${serviceTag}")}`,
|
|
180
185
|
// [RESOURCE_CLASSES.dynamoDbAcrossService]: "arn:aws:dynamodb:${process.env.iz_region}:${process.env.iz_accountId}:table/*/" + `${resourceName}`,
|
|
181
|
-
[RESOURCE_CLASSES.dynamoDbAcrossService]: "arn:aws:dynamodb:${process.env.iz_region}:${process.env.iz_accountId}:table
|
|
186
|
+
[RESOURCE_CLASSES.dynamoDbAcrossService]: "arn:aws:dynamodb:${process.env.iz_region}:${process.env.iz_accountId}:table/" + `"${serviceTag}"` + `"${resourceName}"`,
|
|
182
187
|
[RESOURCE_CLASSES.lambda]: "arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${await lambdaSharedLib.lambdaFunctionName(_izContext, " + `"${resourceName}" ,"${serviceTag}")}`,
|
|
188
|
+
[RESOURCE_CLASSES.sns]: "arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${await snsSharedLib.snsTopicName(_izContext, " + `"${resourceName}", "${serviceTag}")}`
|
|
189
|
+
|
|
183
190
|
}[resourceClass]
|
|
184
191
|
};
|
|
185
192
|
|
|
186
|
-
function
|
|
187
|
-
|
|
193
|
+
function externalResourceYaml(resourceClass, resourceName, serviceTag) {
|
|
194
|
+
if (!serviceTag) {
|
|
195
|
+
serviceTag = "${self:custom.iz_resourcePrefix}"
|
|
196
|
+
} else {
|
|
197
|
+
serviceTag = serviceTag + "Test"
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
[RESOURCE_CLASSES.dynamoDbTable]: "arn:aws:dynamodb:${self:custom.iz_region}:${self:custom.iz_accountId}:table/" + `${serviceTag}` + `${resourceName}`,
|
|
201
|
+
[RESOURCE_CLASSES.lambda]: "arn:aws:lambda:${self:custom.iz_region}:${self:custom.iz_accountId}:function:" + `${serviceTag}` + `${resourceName}`,
|
|
202
|
+
[RESOURCE_CLASSES.sns]: "arn:aws:sns:${self:custom.iz_region}:${self:custom.iz_accountId}:" + `${serviceTag}` + `${resourceName}`,
|
|
203
|
+
[RESOURCE_CLASSES.sqs]: "arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:" + `${serviceTag}` + `${resourceName}`
|
|
204
|
+
|
|
205
|
+
}[resourceClass]
|
|
188
206
|
};
|
|
189
207
|
|
|
190
208
|
const SAVE_FILE_NAME = {
|
|
@@ -199,7 +217,8 @@ const SAVE_FILE_NAME = {
|
|
|
199
217
|
findData: "findData",
|
|
200
218
|
processLogicalYaml: "processLogical",
|
|
201
219
|
flowSchema: "flowSchema",
|
|
202
|
-
S3Bucket: "generated-s3-bucket"
|
|
220
|
+
S3Bucket: "generated-s3-bucket",
|
|
221
|
+
sharedResourceYaml: "generate-SharedResource",
|
|
203
222
|
};
|
|
204
223
|
|
|
205
224
|
const FUNCTION_NAME = {
|
|
@@ -275,7 +294,6 @@ function defaultIamRolePerAction() {
|
|
|
275
294
|
},
|
|
276
295
|
[
|
|
277
296
|
resourceNames(RESOURCE_CLASSES.s3, "object-schema/perServiceSchemas/*"),
|
|
278
|
-
resourceNames(RESOURCE_CLASSES.s3, "object-schema/serviceConfig/ServiceNameConfig.json"),
|
|
279
297
|
resourceNames(RESOURCE_CLASSES.s3, "object-schema/serviceConfig/GraphServerTags.json"),
|
|
280
298
|
]
|
|
281
299
|
)
|
|
@@ -340,6 +358,13 @@ function shortNameHandler(fullNameHandler) {
|
|
|
340
358
|
return fullNameHandler.slice(3)
|
|
341
359
|
};
|
|
342
360
|
|
|
361
|
+
const SOURCE_GENERATE_IAM_ROLE = {
|
|
362
|
+
ProcessFindDataRole: "ProcessFindData",
|
|
363
|
+
ObjectCompleteRole: "ObjectComplete",
|
|
364
|
+
RelationshipRole: "Relationship",
|
|
365
|
+
RelationshipCompleteRole: "RelationshipComplete",
|
|
366
|
+
};
|
|
367
|
+
|
|
343
368
|
|
|
344
369
|
module.exports = {
|
|
345
370
|
ACTIONS,
|
|
@@ -355,7 +380,7 @@ module.exports = {
|
|
|
355
380
|
LAMBDA_RESOURCE,
|
|
356
381
|
HANDLER,
|
|
357
382
|
externalResourceName,
|
|
358
|
-
|
|
383
|
+
externalResourceYaml,
|
|
359
384
|
SAVE_FILE_NAME,
|
|
360
385
|
FUNCTION_NAME,
|
|
361
386
|
getGraphServiceNameFromAllRelSchema,
|
|
@@ -365,5 +390,6 @@ module.exports = {
|
|
|
365
390
|
awaitingMultipleStepsRole,
|
|
366
391
|
shortNameHandler,
|
|
367
392
|
SHORT_FUNCTION_NAME,
|
|
368
|
-
S3_RESOURCE
|
|
393
|
+
S3_RESOURCE,
|
|
394
|
+
SOURCE_GENERATE_IAM_ROLE
|
|
369
395
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const templateConfig = require("./TemplateConfig");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const { createSource } = require("../../../SourceManager/src/CreateSource");
|
|
4
|
+
|
|
5
|
+
async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
6
|
+
let allCreateSource = []
|
|
7
|
+
|
|
8
|
+
for (const templateName in templateConfig) {
|
|
9
|
+
const { generateCode } = require(path.join(__dirname, templateConfig[templateName]))
|
|
10
|
+
let createSourceResult = await generateCode(generateCode)
|
|
11
|
+
allCreateSource.push(...createSourceResult);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
for (let folderPathToEmpty of Object.keys(GENERATECODE_SOURCE_PATH)) {
|
|
16
|
+
await deleteFileInDir(GENERATECODE_SOURCE_PATH[folderPathToEmpty]);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
for (let { templatePath, templateData, setting } of allCreateSource) {
|
|
21
|
+
// console.log("setting.saveFileName in GenerateCode", setting.saveFileName);
|
|
22
|
+
// console.log("templatePath in GenerateCode", templatePath);
|
|
23
|
+
|
|
24
|
+
await createSource(
|
|
25
|
+
readFileSync(templatePath, 'utf8'),
|
|
26
|
+
templateData,
|
|
27
|
+
setting,
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
|
File without changes
|
package/src/TemplateManager/src/reStructureExample/TemplateData/perAction/generateCodeShared.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// generated code (data,template)
|
|
File without changes
|