@izara_project/izara-core-generate-service-code 1.0.35 → 1.0.36
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/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/recievePlugIn/yaml/data.js +3 -3
- package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/recievePlugIn/yaml/template.ejs +1 -1
- package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/queueNtopic/data.js +3 -3
- package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/queueNtopic/snsTemplate.ejs +58 -0
- package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/queueNtopic/sqsTemplate.ejs +43 -0
- package/src/generateCode/generateFlowStepWithPlugIn/index.js +6 -6
- package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/queueNtopic/template.ejs +0 -0
package/package.json
CHANGED
package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/recievePlugIn/yaml/data.js
CHANGED
|
@@ -39,13 +39,13 @@ async function data(_izContext, data, appPath) {
|
|
|
39
39
|
|
|
40
40
|
const functionName = 'recievePlugInHook' + upperCase(data.recieveType)
|
|
41
41
|
let handlerType;
|
|
42
|
-
const
|
|
42
|
+
const additionalResourcePermission = defaultIamRolePerAction();
|
|
43
43
|
|
|
44
44
|
if (data.recieveType === 'sync') {
|
|
45
45
|
handlerType = HANDLER.hdrApi;
|
|
46
46
|
} else if (data.recieveType === 'async') {
|
|
47
47
|
handlerType = 'hdrWbs';
|
|
48
|
-
|
|
48
|
+
additionalResourcePermission.push(
|
|
49
49
|
createIamRole(
|
|
50
50
|
{
|
|
51
51
|
'execute-api': ['ManageConnections']
|
|
@@ -64,7 +64,7 @@ async function data(_izContext, data, appPath) {
|
|
|
64
64
|
serviceTag,
|
|
65
65
|
functionName: upperCase(functionName),
|
|
66
66
|
functionNameConfig,
|
|
67
|
-
|
|
67
|
+
additionalResourcePermission,
|
|
68
68
|
roleName,
|
|
69
69
|
event: 'post',
|
|
70
70
|
resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, `${data.flowTag}`, `${data.flowStepName}`, 'source/'),
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
events:
|
|
8
8
|
<% if (handlerType === 'HdrApi') { %>
|
|
9
9
|
- httpApi:
|
|
10
|
-
path: /<%- serviceTag %>/<%- lowerCase(functionName)
|
|
10
|
+
path: /<%- serviceTag %>/<%- lowerCase(functionName) %>
|
|
11
11
|
method: <%- event %>
|
|
12
12
|
- httpApi:
|
|
13
13
|
path: /<%- serviceTag %>/<%- lowerCase(functionName) %>/{targetUserId}
|
|
@@ -26,9 +26,9 @@ import utils from '#libs/Utils.js';
|
|
|
26
26
|
const { firstLetterUpperCase: upperCase } = utils;
|
|
27
27
|
const { SOURCE_PATH, SAVE_FILE_NAME, HANDLER } = consts;
|
|
28
28
|
const templatePathByHandler = {
|
|
29
|
-
[HANDLER.hdrDsq]: path.join(__dirname, '
|
|
30
|
-
[HANDLER.hdrSqs]: path.join(__dirname, '
|
|
31
|
-
queueNoTopic: path.join(__dirname, '
|
|
29
|
+
[HANDLER.hdrDsq]: path.join(__dirname, './sqsTemplate.ejs'),
|
|
30
|
+
[HANDLER.hdrSqs]: path.join(__dirname, './snsTemplate.ejs'),
|
|
31
|
+
queueNoTopic: path.join(__dirname, './sqsTemplate.ejs')
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
async function data(_izContext, data, appPath) {
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
##===== [Create topic in]
|
|
2
|
+
In<%- queueName %>:
|
|
3
|
+
Type: AWS::SNS::Topic
|
|
4
|
+
Properties:
|
|
5
|
+
DisplayName: "SNS Message in"
|
|
6
|
+
TopicName: ${self:custom.iz_serviceTag}_${self:custom.iz_stage}_<%- queueName %>_In
|
|
7
|
+
##===== SNS Subscription [Topic In] =====##
|
|
8
|
+
SubscriptionIn<%- queueName %>:
|
|
9
|
+
Type: AWS::SNS::Subscription
|
|
10
|
+
Properties:
|
|
11
|
+
TopicArn: !Ref In<%- queueName %>
|
|
12
|
+
Endpoint: "arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqs"
|
|
13
|
+
Protocol: "sqs"
|
|
14
|
+
##===== [Queue]
|
|
15
|
+
<%- queueName %>HdrSqs:
|
|
16
|
+
Type: "AWS::SQS::Queue"
|
|
17
|
+
Properties:
|
|
18
|
+
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqs
|
|
19
|
+
RedrivePolicy:
|
|
20
|
+
deadLetterTargetArn:
|
|
21
|
+
# !GetAtt
|
|
22
|
+
Fn::GetAtt:
|
|
23
|
+
- <%- queueName %>HdrSqsDLQ
|
|
24
|
+
- Arn
|
|
25
|
+
maxReceiveCount: 3
|
|
26
|
+
VisibilityTimeout: 120
|
|
27
|
+
##==== [QueueDLQ]
|
|
28
|
+
<%- queueName %>HdrSqsDLQ:
|
|
29
|
+
Type: AWS::SQS::Queue
|
|
30
|
+
Properties:
|
|
31
|
+
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqsDLQ
|
|
32
|
+
##==== [QueuePolicy]
|
|
33
|
+
<%- queueName %>HdrSqsPolicy:
|
|
34
|
+
Type: AWS::SQS::QueuePolicy
|
|
35
|
+
Properties:
|
|
36
|
+
PolicyDocument:
|
|
37
|
+
Version: "2012-10-17"
|
|
38
|
+
Statement:
|
|
39
|
+
- Sid: "allow-sns-messages"
|
|
40
|
+
Effect: Allow
|
|
41
|
+
Principal: "*"
|
|
42
|
+
Resource:
|
|
43
|
+
# !GetAtt
|
|
44
|
+
Fn::GetAtt:
|
|
45
|
+
- <%- queueName %>HdrSqs
|
|
46
|
+
- Arn
|
|
47
|
+
Action: "SQS:SendMessage"
|
|
48
|
+
Queues:
|
|
49
|
+
- Ref: <%- queueName %>HdrSqs
|
|
50
|
+
#<#<%- firstLetterUpperCase(queueName) %>QueueSetting#>
|
|
51
|
+
#<#/<%- firstLetterUpperCase(queueName) %>QueueSetting#>
|
|
52
|
+
|
|
53
|
+
<%_ function firstLetterUpperCase(text){
|
|
54
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
55
|
+
} _%>
|
|
56
|
+
<%_ function firstLetterLowerCase(str) {
|
|
57
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
58
|
+
} _%>
|
|
@@ -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
|
+
} _%>
|
|
@@ -81,10 +81,10 @@ async function generatePlunIg(
|
|
|
81
81
|
const roleName = upperCase(flowTag);
|
|
82
82
|
const resourceApis = [];
|
|
83
83
|
let handler;
|
|
84
|
-
const
|
|
84
|
+
const additionalResourcePermission = defaultIamRolePerAction();
|
|
85
85
|
|
|
86
86
|
const data = {
|
|
87
|
-
|
|
87
|
+
additionalResourcePermission: additionalResourcePermission,
|
|
88
88
|
flowStepName: flowStepName,
|
|
89
89
|
flowTag: flowTag,
|
|
90
90
|
resourceApis: resourceApis,
|
|
@@ -96,7 +96,7 @@ async function generatePlunIg(
|
|
|
96
96
|
if (flowStepConfig.event.includes("ownTopic")) {
|
|
97
97
|
data['eventFlow'] = 'ownTopic'
|
|
98
98
|
handler = HANDLER.hdrSqs;
|
|
99
|
-
|
|
99
|
+
additionalResourcePermission.push(
|
|
100
100
|
createSnsResource(
|
|
101
101
|
[
|
|
102
102
|
upperCase(flowSchema.flowTag) + upperCase(flowStepName) + "_In"
|
|
@@ -112,7 +112,7 @@ async function generatePlunIg(
|
|
|
112
112
|
} else if (flowStepConfig.event.includes("extTopic")) {
|
|
113
113
|
data['eventFlow'] = 'extTopic'
|
|
114
114
|
handler = HANDLER.hdrSqs;
|
|
115
|
-
|
|
115
|
+
additionalResourcePermission.push(
|
|
116
116
|
createSqsResource(
|
|
117
117
|
[
|
|
118
118
|
upperCase(flowSchema.flowTag) + upperCase(flowStepName) + upperCase(handler),
|
|
@@ -133,7 +133,7 @@ async function generatePlunIg(
|
|
|
133
133
|
})
|
|
134
134
|
} else if (flowStepConfig.event.includes("queue")) {
|
|
135
135
|
handler = HANDLER.hdrDsq;
|
|
136
|
-
|
|
136
|
+
additionalResourcePermission.push(
|
|
137
137
|
createSqsResource(
|
|
138
138
|
[
|
|
139
139
|
upperCase(flowSchema.flowTag) + upperCase(flowStepName) + upperCase(handler),
|
|
@@ -154,7 +154,7 @@ async function generatePlunIg(
|
|
|
154
154
|
),
|
|
155
155
|
functionNameConfig: upperCase(flowSchema.flowTag) + upperCase(flowStepName) + upperCase(handler),
|
|
156
156
|
event: resourceNames(RESOURCE_CLASSES.sqs, upperCase(flowSchema.flowTag) + upperCase(flowStepName) + upperCase(handler)),
|
|
157
|
-
queueName: upperCase(flowSchema.flowTag) + upperCase(flowStepName)
|
|
157
|
+
queueName: upperCase(flowSchema.flowTag) + upperCase(flowStepName),
|
|
158
158
|
})
|
|
159
159
|
|
|
160
160
|
const yamlFlowStepRes = await yamlFlowStep(_izContext, data, appPath);
|
|
File without changes
|