@izara_project/izara-core-generate-service-code 1.0.44 → 1.0.45
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 +3 -3
- package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/yaml/template.ejs +13 -1
- package/src/generateCode/generateInitialSetup/externalServiceComponent/lambdaRole/template.ejs +1 -0
- package/src/generateCode/generateSchema/relationshipPerActionComponent/changeRelationship/action/functionYaml/data.js +37 -18
- package/src/generateCode/generateSchema/relationshipPerActionComponent/changeRelationship/action/functionYaml/template.ejs +33 -9
- package/src/generateCode/generateSchema/relationshipPerActionComponent/create/action/functionYaml/data.js +26 -11
- package/src/generateCode/generateSchema/relationshipPerActionComponent/create/action/functionYaml/template.ejs +33 -9
- package/src/generateCode/generateSchema/relationshipPerActionComponent/delete/action/functionYaml/data.js +28 -11
- package/src/generateCode/generateSchema/relationshipPerActionComponent/delete/action/functionYaml/template.ejs +33 -9
- package/src/generateCode/generateSchema/relationshipPerActionComponent/get/action/functionYaml/data.js +26 -13
- package/src/generateCode/generateSchema/relationshipPerActionComponent/get/action/functionYaml/template.ejs +27 -9
- package/src/generateCode/generateSchema/relationshipPerActionComponent/index.js +3 -2
- package/src/generateCode/generateSchema/relationshipPerActionComponent/moveRelationship/action/functionYaml/data.js +27 -11
- package/src/generateCode/generateSchema/relationshipPerActionComponent/moveRelationship/action/functionYaml/template.ejs +33 -9
- package/src/generateCode/generateSchema/relationshipPerActionComponent/update/action/functionYaml/data.js +27 -6
- package/src/generateCode/generateSchema/relationshipPerActionComponent/update/action/functionYaml/template.ejs +33 -9
- package/src/libs/Libs.js +13 -12
- package/src/generateCode/generateSchema/relationshipPerActionComponent/changeRelationship/action/functionYaml/templateByHandler/apiTemplate.ejs +0 -20
- package/src/generateCode/generateSchema/relationshipPerActionComponent/changeRelationship/action/functionYaml/templateByHandler/dsqTemplate.ejs +0 -17
- package/src/generateCode/generateSchema/relationshipPerActionComponent/changeRelationship/action/functionYaml/templateByHandler/invTemplate.ejs +0 -13
- package/src/generateCode/generateSchema/relationshipPerActionComponent/changeRelationship/action/functionYaml/templateByHandler/sqsTemplate.ejs +0 -18
- package/src/generateCode/generateSchema/relationshipPerActionComponent/create/action/functionYaml/templateByHandler/apiTemplate.ejs +0 -21
- package/src/generateCode/generateSchema/relationshipPerActionComponent/create/action/functionYaml/templateByHandler/dsqTemplate.ejs +0 -17
- package/src/generateCode/generateSchema/relationshipPerActionComponent/create/action/functionYaml/templateByHandler/invTemplate.ejs +0 -13
- package/src/generateCode/generateSchema/relationshipPerActionComponent/create/action/functionYaml/templateByHandler/sqsTemplate.ejs +0 -17
- package/src/generateCode/generateSchema/relationshipPerActionComponent/delete/action/functionYaml/templateByHandler/apiTemplate.ejs +0 -21
- package/src/generateCode/generateSchema/relationshipPerActionComponent/delete/action/functionYaml/templateByHandler/dsqTemplate.ejs +0 -17
- package/src/generateCode/generateSchema/relationshipPerActionComponent/delete/action/functionYaml/templateByHandler/invTemplate.ejs +0 -13
- package/src/generateCode/generateSchema/relationshipPerActionComponent/delete/action/functionYaml/templateByHandler/sqsTemplate.ejs +0 -18
- package/src/generateCode/generateSchema/relationshipPerActionComponent/get/action/functionYaml/templateByHandler/apiTemplate.ejs +0 -21
- package/src/generateCode/generateSchema/relationshipPerActionComponent/get/action/functionYaml/templateByHandler/dsqTemplate.ejs +0 -17
- package/src/generateCode/generateSchema/relationshipPerActionComponent/get/action/functionYaml/templateByHandler/invTemplate.ejs +0 -13
- package/src/generateCode/generateSchema/relationshipPerActionComponent/get/action/functionYaml/templateByHandler/sqsTemplate.ejs +0 -18
- package/src/generateCode/generateSchema/relationshipPerActionComponent/moveRelationship/action/functionYaml/templateByHandler/apiTemplate.ejs +0 -20
- package/src/generateCode/generateSchema/relationshipPerActionComponent/moveRelationship/action/functionYaml/templateByHandler/dsqTemplate.ejs +0 -17
- package/src/generateCode/generateSchema/relationshipPerActionComponent/moveRelationship/action/functionYaml/templateByHandler/invTemplate.ejs +0 -13
- package/src/generateCode/generateSchema/relationshipPerActionComponent/moveRelationship/action/functionYaml/templateByHandler/sqsTemplate.ejs +0 -17
- package/src/generateCode/generateSchema/relationshipPerActionComponent/update/action/functionYaml/templateByHandler/apiTemplate.ejs +0 -20
- package/src/generateCode/generateSchema/relationshipPerActionComponent/update/action/functionYaml/templateByHandler/dsqTemplate.ejs +0 -18
- package/src/generateCode/generateSchema/relationshipPerActionComponent/update/action/functionYaml/templateByHandler/invTemplate.ejs +0 -13
- package/src/generateCode/generateSchema/relationshipPerActionComponent/update/action/functionYaml/templateByHandler/sqsTemplate.ejs +0 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@izara_project/izara-core-generate-service-code",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.45",
|
|
4
4
|
"description": "Code for locally generating per service files",
|
|
5
5
|
"author": "Sven Mason <thebarbariansven@gmail.com>",
|
|
6
6
|
"license": "AGPL-3.0-or-later",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@izara_project/izara-core-library-core": "^1.0.32",
|
|
28
28
|
"@izara_project/izara-core-library-logger": "^1.0.9",
|
|
29
|
-
"@izara_project/izara-core-library-s3": "^1.0.
|
|
30
|
-
"@izara_project/izara-core-library-service-schemas": "^1.0.
|
|
29
|
+
"@izara_project/izara-core-library-s3": "^1.0.9",
|
|
30
|
+
"@izara_project/izara-core-library-service-schemas": "^1.0.145",
|
|
31
31
|
"@izara_project/izara-shared-core": "^1.0.12",
|
|
32
32
|
"ejs": "^5.0.1",
|
|
33
33
|
"js-beautify": "^1.15.4",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<%- functionNameConfig %>:
|
|
2
|
-
handler: <%- handlerPath
|
|
2
|
+
handler: <%- handlerPath %>.main
|
|
3
3
|
name: ${self:custom.iz_resourcePrefix}<%- functionName %>
|
|
4
4
|
role: <%- roleName %>Role
|
|
5
5
|
#<#<%- hookTagSetting %>#>
|
|
@@ -9,6 +9,18 @@
|
|
|
9
9
|
- sqs:
|
|
10
10
|
arn: <%- event %>
|
|
11
11
|
batchSize: 10
|
|
12
|
+
<%_ if (eventFlow === 'extTopic') { _%>
|
|
13
|
+
filterPatterns: #**** need to update serverless framework upper v.2.69.1
|
|
14
|
+
- body: { 'MessageAttributes': {
|
|
15
|
+
'callingFlow': {
|
|
16
|
+
'Value': ['${self:custom.iz_resourcePrefix}<%- functionName %>']
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
} # functionName of callingFlow
|
|
20
|
+
- body: {
|
|
21
|
+
'MessageAttributes': { 'callingFlow': { 'Value': [{ 'exists': false }] } }
|
|
22
|
+
}
|
|
23
|
+
<%_ } _%>
|
|
12
24
|
<%_ } else if (handlerType === 'hdrApi' && resourceApis.length > 0) { _%>
|
|
13
25
|
events:
|
|
14
26
|
<%_ resourceApis.forEach(api => { _%>
|
package/src/generateCode/generateInitialSetup/externalServiceComponent/lambdaRole/template.ejs
CHANGED
|
@@ -19,6 +19,7 @@ import Logger from '@izara_project/izara-core-library-logger';
|
|
|
19
19
|
import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
|
|
20
20
|
import lambdaSharedLib from '@izara_project/izara-core-library-lambda';
|
|
21
21
|
import snsSharedLib from '@izara_project/izara-core-library-sns';
|
|
22
|
+
import initialSetupConfig from '../../config/Config.js';
|
|
22
23
|
const _izContext = { logger: Logger }
|
|
23
24
|
|
|
24
25
|
export function generatedLambdaRole() {
|
|
@@ -19,7 +19,6 @@ import path from 'path';
|
|
|
19
19
|
import { fileURLToPath } from 'url';
|
|
20
20
|
const __filename = fileURLToPath(import.meta.url);
|
|
21
21
|
const __dirname = path.dirname(__filename);
|
|
22
|
-
|
|
23
22
|
import consts from '#libs/Consts.js';
|
|
24
23
|
import utils from '#libs/Utils.js';
|
|
25
24
|
import libs from '#libs/Libs.js';
|
|
@@ -36,7 +35,10 @@ const {
|
|
|
36
35
|
HANDLER
|
|
37
36
|
} = consts;
|
|
38
37
|
|
|
39
|
-
const { firstLetterUpperCase: upperCase,
|
|
38
|
+
const { firstLetterUpperCase: upperCase,
|
|
39
|
+
firstLetterLowerCase: lowerCase,
|
|
40
|
+
getLocalConfig
|
|
41
|
+
} = utils;
|
|
40
42
|
|
|
41
43
|
const {
|
|
42
44
|
createIamRole,
|
|
@@ -48,11 +50,6 @@ const {
|
|
|
48
50
|
|
|
49
51
|
const templatePath = path.join(__dirname, 'template.ejs');
|
|
50
52
|
|
|
51
|
-
const apiTemplate = path.join(__dirname, 'templateByHandler/apiTemplate.ejs');
|
|
52
|
-
const dsqTemplate = path.join(__dirname, 'templateByHandler/dsqTemplate.ejs');
|
|
53
|
-
const invTemplate = path.join(__dirname, 'templateByHandler/invTemplate.ejs');
|
|
54
|
-
const sqsTemplate = path.join(__dirname, 'templateByHandler/sqsTemplate.ejs');
|
|
55
|
-
|
|
56
53
|
/**
|
|
57
54
|
* receive objectSchema
|
|
58
55
|
* create data for updateRelationshipSchema
|
|
@@ -61,19 +58,23 @@ const sqsTemplate = path.join(__dirname, 'templateByHandler/sqsTemplate.ejs');
|
|
|
61
58
|
* @return {{ templatePath, templateData, setting } }
|
|
62
59
|
*/
|
|
63
60
|
|
|
64
|
-
function data(_izContext, srcPath) {
|
|
61
|
+
function data(_izContext, allObjectRelationships, srcPath) {
|
|
65
62
|
let createSourceArray = [];
|
|
66
63
|
for (const handlerType of Object.values(HANDLER)) {
|
|
67
|
-
const createSourceParam = createParamForCreateSource(
|
|
64
|
+
const createSourceParam = createParamForCreateSource(
|
|
65
|
+
allObjectRelationships,
|
|
66
|
+
handlerType,
|
|
67
|
+
srcPath
|
|
68
|
+
);
|
|
68
69
|
createSourceArray.push(createSourceParam);
|
|
69
70
|
}
|
|
70
|
-
// console.log("createSourceArrayInUpdaterelationShipSchemahdrSqs",
|
|
71
|
+
// console.log("createSourceArrayInUpdaterelationShipSchemahdrSqs", createSourceArray)
|
|
71
72
|
return createSourceArray;
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
function createParamForCreateSource(handlerType, srcPath) {
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
function createParamForCreateSource(allObjectRelationships, handlerType, srcPath) {
|
|
76
|
+
const functionName = upperCase(FUNCTION_NAME.changeRel);
|
|
77
|
+
const additionalResourcePermission = defaultIamRolePerAction();
|
|
77
78
|
|
|
78
79
|
additionalResourcePermission.push(awaitingMultipleStepsRole());
|
|
79
80
|
|
|
@@ -134,6 +135,21 @@ function createParamForCreateSource(handlerType, srcPath) {
|
|
|
134
135
|
);
|
|
135
136
|
}
|
|
136
137
|
|
|
138
|
+
const event = resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(handlerType));
|
|
139
|
+
|
|
140
|
+
const serviceTag = getLocalConfig('iz_serviceTag');
|
|
141
|
+
|
|
142
|
+
const resourcesApi = [];
|
|
143
|
+
if (handlerType === HANDLER.hdrApi) {
|
|
144
|
+
allObjectRelationships.map(relationshipSchema => (
|
|
145
|
+
resourcesApi.push({
|
|
146
|
+
event: lowerCase(Object.keys(relationshipSchema)[0]),
|
|
147
|
+
method: 'post',
|
|
148
|
+
action: 'change'
|
|
149
|
+
}))
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
|
|
137
153
|
return {
|
|
138
154
|
templatePath: templatePath,
|
|
139
155
|
templateData: {
|
|
@@ -145,11 +161,14 @@ function createParamForCreateSource(handlerType, srcPath) {
|
|
|
145
161
|
upperCase(SHORT_FUNCTION_NAME(FUNCTION_NAME.changeRel)) +
|
|
146
162
|
upperCase(shortNameHandler(handlerType)),
|
|
147
163
|
roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
164
|
+
resourceApis: resourcesApi.map(api => ({
|
|
165
|
+
path: `/${serviceTag}/${api.event}/${api.action}`,
|
|
166
|
+
pathWithUser: `/${serviceTag}/${api.event}/${api.action}/{targetUserId}`,
|
|
167
|
+
method: api.method,
|
|
168
|
+
hookTagApp: `${upperCase(api.event)}AppLevelAuthorizer`,
|
|
169
|
+
hookTagUser: `${upperCase(api.event)}UserLevelAuthorizer`
|
|
170
|
+
})),
|
|
171
|
+
event
|
|
153
172
|
},
|
|
154
173
|
setting: {
|
|
155
174
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -1,9 +1,33 @@
|
|
|
1
|
-
<%
|
|
2
|
-
<%-
|
|
3
|
-
|
|
4
|
-
<%-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
<%_ const join = require('path').join; _%>
|
|
2
|
+
<%- firstLetterUpperCase(functionNameConfig) %>:
|
|
3
|
+
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
|
+
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
|
+
role: <%- roleName %>Role
|
|
6
|
+
#<#<%- functionName %><%- firstLetterUpperCase(handlerType) %>FunctionSetting#>
|
|
7
|
+
#<#/<%- functionName %><%- firstLetterUpperCase(handlerType) %>FunctionSetting#>
|
|
8
|
+
<%_ if (handlerType === 'hdrDsq' || handlerType === 'hdrSqs') { _%>
|
|
9
|
+
events:
|
|
10
|
+
- sqs:
|
|
11
|
+
arn: <%- event %>
|
|
12
|
+
batchSize: 10
|
|
13
|
+
<%_ } else if (handlerType === 'hdrApi' && resourceApis.length > 0) { _%>
|
|
14
|
+
events:
|
|
15
|
+
<%_ resourceApis.forEach(api => { _%>
|
|
16
|
+
- httpApi:
|
|
17
|
+
path: <%- api.path %>
|
|
18
|
+
method: <%- api.method %>
|
|
19
|
+
#<#<%- api.hookTagApp %>#>
|
|
20
|
+
# authorizer: authorizerServiceSchema
|
|
21
|
+
#<#/<%- api.hookTagApp %>#>
|
|
22
|
+
- httpApi:
|
|
23
|
+
path: <%- api.pathWithUser %>
|
|
24
|
+
method: <%- api.method %>
|
|
25
|
+
#<#<%- api.hookTagUser %>#>
|
|
26
|
+
# authorizer: authorizerIdentifiers
|
|
27
|
+
#<#/<%- api.hookTagUser %>#>a
|
|
28
|
+
<%_ }) _%>
|
|
29
|
+
<%_ } _%>
|
|
30
|
+
|
|
31
|
+
<%_ function firstLetterUpperCase(text) {
|
|
32
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
33
|
+
} _%>
|
|
@@ -37,7 +37,10 @@ const {
|
|
|
37
37
|
HANDLER
|
|
38
38
|
} = consts;
|
|
39
39
|
|
|
40
|
-
const { firstLetterUpperCase: upperCase,
|
|
40
|
+
const { firstLetterUpperCase: upperCase,
|
|
41
|
+
firstLetterLowerCase: lowerCase,
|
|
42
|
+
getLocalConfig
|
|
43
|
+
} = utils;
|
|
41
44
|
|
|
42
45
|
const {
|
|
43
46
|
createIamRole,
|
|
@@ -51,11 +54,6 @@ const {
|
|
|
51
54
|
|
|
52
55
|
const templatePath = path.join(__dirname, 'template.ejs');
|
|
53
56
|
|
|
54
|
-
const apiTemplate = path.join(__dirname, 'templateByHandler/apiTemplate.ejs');
|
|
55
|
-
const dsqTemplate = path.join(__dirname, 'templateByHandler/dsqTemplate.ejs');
|
|
56
|
-
const invTemplate = path.join(__dirname, 'templateByHandler/invTemplate.ejs');
|
|
57
|
-
const sqsTemplate = path.join(__dirname, 'templateByHandler/sqsTemplate.ejs');
|
|
58
|
-
|
|
59
57
|
/**
|
|
60
58
|
* receive objectSchema
|
|
61
59
|
* create data for updateRelationshipSchema
|
|
@@ -175,6 +173,20 @@ function createParamForCreateSource(
|
|
|
175
173
|
}
|
|
176
174
|
}
|
|
177
175
|
|
|
176
|
+
const serviceTag = getLocalConfig('iz_serviceTag');
|
|
177
|
+
|
|
178
|
+
const resourcesApi = [];
|
|
179
|
+
if (handlerType === HANDLER.hdrApi) {
|
|
180
|
+
allObjectRelationships.map(relationshipSchema => (
|
|
181
|
+
resourcesApi.push({
|
|
182
|
+
event: lowerCase(Object.keys(relationshipSchema)[0]),
|
|
183
|
+
method: 'post',
|
|
184
|
+
action: 'create'
|
|
185
|
+
}))
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
const event = resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(handlerType));
|
|
189
|
+
|
|
178
190
|
return {
|
|
179
191
|
templatePath: templatePath,
|
|
180
192
|
templateData: {
|
|
@@ -186,11 +198,14 @@ function createParamForCreateSource(
|
|
|
186
198
|
upperCase(SHORT_FUNCTION_NAME(FUNCTION_NAME.createRel)) +
|
|
187
199
|
upperCase(shortNameHandler(handlerType)),
|
|
188
200
|
roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole,
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
201
|
+
resourceApis: resourcesApi.map(api => ({
|
|
202
|
+
path: `/${serviceTag}/${api.event}/${api.action}`,
|
|
203
|
+
pathWithUser: `/${serviceTag}/${api.event}/${api.action}/{targetUserId}`,
|
|
204
|
+
method: api.method,
|
|
205
|
+
hookTagApp: `${upperCase(api.event)}AppLevelAuthorizer`,
|
|
206
|
+
hookTagUser: `${upperCase(api.event)}UserLevelAuthorizer`
|
|
207
|
+
})),
|
|
208
|
+
event
|
|
194
209
|
},
|
|
195
210
|
setting: {
|
|
196
211
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -1,9 +1,33 @@
|
|
|
1
|
-
<%
|
|
2
|
-
<%-
|
|
3
|
-
|
|
4
|
-
<%-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
<%_ const join = require('path').join; _%>
|
|
2
|
+
<%- firstLetterUpperCase(functionNameConfig) %>:
|
|
3
|
+
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
|
+
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
|
+
role: <%- roleName %>Role
|
|
6
|
+
#<#<%- functionName %><%- firstLetterUpperCase(handlerType) %>FunctionSetting#>
|
|
7
|
+
#<#/<%- functionName %><%- firstLetterUpperCase(handlerType) %>FunctionSetting#>
|
|
8
|
+
<%_ if (handlerType === 'hdrDsq' || handlerType === 'hdrSqs') { _%>
|
|
9
|
+
events:
|
|
10
|
+
- sqs:
|
|
11
|
+
arn: <%- event %>
|
|
12
|
+
batchSize: 10
|
|
13
|
+
<%_ } else if (handlerType === 'hdrApi' && resourceApis.length > 0) { _%>
|
|
14
|
+
events:
|
|
15
|
+
<%_ resourceApis.forEach(api => { _%>
|
|
16
|
+
- httpApi:
|
|
17
|
+
path: <%- api.path %>
|
|
18
|
+
method: <%- api.method %>
|
|
19
|
+
#<#<%- api.hookTagApp %>#>
|
|
20
|
+
# authorizer: authorizerServiceSchema
|
|
21
|
+
#<#/<%- api.hookTagApp %>#>
|
|
22
|
+
- httpApi:
|
|
23
|
+
path: <%- api.pathWithUser %>
|
|
24
|
+
method: <%- api.method %>
|
|
25
|
+
#<#<%- api.hookTagUser %>#>
|
|
26
|
+
# authorizer: authorizerIdentifiers
|
|
27
|
+
#<#/<%- api.hookTagUser %>#>
|
|
28
|
+
<%_ }) _%>
|
|
29
|
+
<%_ } _%>
|
|
30
|
+
|
|
31
|
+
<%_ function firstLetterUpperCase(text) {
|
|
32
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
33
|
+
} _%>
|
|
@@ -37,7 +37,10 @@ const {
|
|
|
37
37
|
HANDLER
|
|
38
38
|
} = consts;
|
|
39
39
|
|
|
40
|
-
const { firstLetterUpperCase: upperCase,
|
|
40
|
+
const { firstLetterUpperCase: upperCase,
|
|
41
|
+
firstLetterLowerCase: lowerCase,
|
|
42
|
+
getLocalConfig
|
|
43
|
+
} = utils;
|
|
41
44
|
|
|
42
45
|
const {
|
|
43
46
|
createIamRole,
|
|
@@ -51,11 +54,6 @@ const {
|
|
|
51
54
|
|
|
52
55
|
const templatePath = path.join(__dirname, 'template.ejs');
|
|
53
56
|
|
|
54
|
-
const apiTemplate = path.join(__dirname, 'templateByHandler/apiTemplate.ejs');
|
|
55
|
-
const dsqTemplate = path.join(__dirname, 'templateByHandler/dsqTemplate.ejs');
|
|
56
|
-
const invTemplate = path.join(__dirname, 'templateByHandler/invTemplate.ejs');
|
|
57
|
-
const sqsTemplate = path.join(__dirname, 'templateByHandler/sqsTemplate.ejs');
|
|
58
|
-
|
|
59
57
|
/**
|
|
60
58
|
* receive objectSchema
|
|
61
59
|
* create data for updateRelationshipSchema
|
|
@@ -175,6 +173,22 @@ function createParamForCreateSource(
|
|
|
175
173
|
}
|
|
176
174
|
}
|
|
177
175
|
|
|
176
|
+
const serviceTag = getLocalConfig('iz_serviceTag');
|
|
177
|
+
|
|
178
|
+
const resourcesApi = [];
|
|
179
|
+
if (handlerType === HANDLER.hdrApi) {
|
|
180
|
+
allObjectRelationships.map(relationshipSchema => (
|
|
181
|
+
resourcesApi.push({
|
|
182
|
+
event: lowerCase(Object.keys(relationshipSchema)[0]),
|
|
183
|
+
method: 'post',
|
|
184
|
+
action: 'delete'
|
|
185
|
+
}))
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const event = resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(handlerType));
|
|
190
|
+
|
|
191
|
+
|
|
178
192
|
return {
|
|
179
193
|
templatePath: templatePath,
|
|
180
194
|
templateData: {
|
|
@@ -186,11 +200,14 @@ function createParamForCreateSource(
|
|
|
186
200
|
upperCase(SHORT_FUNCTION_NAME(FUNCTION_NAME.deleteRel)) +
|
|
187
201
|
upperCase(shortNameHandler(handlerType)),
|
|
188
202
|
roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole,
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
203
|
+
resourceApis: resourcesApi.map(api => ({
|
|
204
|
+
path: `/${serviceTag}/${api.event}/${api.action}`,
|
|
205
|
+
pathWithUser: `/${serviceTag}/${api.event}/${api.action}/{targetUserId}`,
|
|
206
|
+
method: api.method,
|
|
207
|
+
hookTagApp: `${upperCase(api.event)}AppLevelAuthorizer`,
|
|
208
|
+
hookTagUser: `${upperCase(api.event)}UserLevelAuthorizer`
|
|
209
|
+
})),
|
|
210
|
+
event
|
|
194
211
|
},
|
|
195
212
|
setting: {
|
|
196
213
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -1,9 +1,33 @@
|
|
|
1
|
-
<%
|
|
2
|
-
<%-
|
|
3
|
-
|
|
4
|
-
<%-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
<%_ const join = require('path').join; _%>
|
|
2
|
+
<%- firstLetterUpperCase(functionNameConfig) %>:
|
|
3
|
+
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
|
+
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
|
+
role: <%- roleName %>Role
|
|
6
|
+
#<#<%- functionName %><%- firstLetterUpperCase(handlerType) %>FunctionSetting#>
|
|
7
|
+
#<#/<%- functionName %><%- firstLetterUpperCase(handlerType) %>FunctionSetting#>
|
|
8
|
+
<%_ if (handlerType === 'hdrDsq' || handlerType === 'hdrSqs') { _%>
|
|
9
|
+
events:
|
|
10
|
+
- sqs:
|
|
11
|
+
arn: <%- event %>
|
|
12
|
+
batchSize: 10
|
|
13
|
+
<%_ } else if (handlerType === 'hdrApi' && resourceApis.length > 0) { _%>
|
|
14
|
+
events:
|
|
15
|
+
<%_ resourceApis.forEach(api => { _%>
|
|
16
|
+
- httpApi:
|
|
17
|
+
path: <%- api.path %>
|
|
18
|
+
method: <%- api.method %>
|
|
19
|
+
#<#<%- api.hookTagApp %>#>
|
|
20
|
+
# authorizer: authorizerServiceSchema
|
|
21
|
+
#<#/<%- api.hookTagApp %>#>
|
|
22
|
+
- httpApi:
|
|
23
|
+
path: <%- api.pathWithUser %>
|
|
24
|
+
method: <%- api.method %>
|
|
25
|
+
#<#<%- api.hookTagUser %>#>
|
|
26
|
+
# authorizer: authorizerIdentifiers
|
|
27
|
+
#<#/<%- api.hookTagUser %>#>
|
|
28
|
+
<%_ }) _%>
|
|
29
|
+
<%_ } _%>
|
|
30
|
+
|
|
31
|
+
<%_ function firstLetterUpperCase(text) {
|
|
32
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
33
|
+
} _%>
|
|
@@ -37,7 +37,10 @@ const {
|
|
|
37
37
|
HANDLER
|
|
38
38
|
} = consts;
|
|
39
39
|
|
|
40
|
-
const { firstLetterUpperCase: upperCase,
|
|
40
|
+
const { firstLetterUpperCase: upperCase,
|
|
41
|
+
firstLetterLowerCase: lowerCase,
|
|
42
|
+
getLocalConfig
|
|
43
|
+
} = utils;
|
|
41
44
|
|
|
42
45
|
const {
|
|
43
46
|
createIamRole,
|
|
@@ -50,11 +53,6 @@ const {
|
|
|
50
53
|
} = libs;
|
|
51
54
|
const templatePath = path.join(__dirname, 'template.ejs');
|
|
52
55
|
|
|
53
|
-
const apiTemplate = path.join(__dirname, 'templateByHandler/apiTemplate.ejs');
|
|
54
|
-
const dsqTemplate = path.join(__dirname, 'templateByHandler/dsqTemplate.ejs');
|
|
55
|
-
const invTemplate = path.join(__dirname, 'templateByHandler/invTemplate.ejs');
|
|
56
|
-
const sqsTemplate = path.join(__dirname, 'templateByHandler/sqsTemplate.ejs');
|
|
57
|
-
|
|
58
56
|
/**
|
|
59
57
|
* receive objectSchema
|
|
60
58
|
* create data for updateRelationshipSchema
|
|
@@ -82,8 +80,9 @@ function createParamForCreateSource(
|
|
|
82
80
|
handlerType,
|
|
83
81
|
srcPath
|
|
84
82
|
) {
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
const ownServiceTag = getLocalConfig('iz_serviceTag');
|
|
84
|
+
const functionName = upperCase(FUNCTION_NAME.getRel);
|
|
85
|
+
const additionalResourcePermission = defaultIamRolePerAction();
|
|
87
86
|
|
|
88
87
|
additionalResourcePermission.push(awaitingMultipleStepsRole());
|
|
89
88
|
|
|
@@ -174,6 +173,19 @@ function createParamForCreateSource(
|
|
|
174
173
|
}
|
|
175
174
|
}
|
|
176
175
|
|
|
176
|
+
const resourcesApi = [];
|
|
177
|
+
if (handlerType === HANDLER.hdrApi) {
|
|
178
|
+
allObjectRelationships.map(relationshipSchema => (
|
|
179
|
+
resourcesApi.push({
|
|
180
|
+
event: lowerCase(Object.keys(relationshipSchema)[0]),
|
|
181
|
+
method: 'post',
|
|
182
|
+
action: 'get'
|
|
183
|
+
}))
|
|
184
|
+
)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const event = resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(handlerType));
|
|
188
|
+
|
|
177
189
|
return {
|
|
178
190
|
templatePath: templatePath,
|
|
179
191
|
templateData: {
|
|
@@ -185,11 +197,12 @@ function createParamForCreateSource(
|
|
|
185
197
|
upperCase(SHORT_FUNCTION_NAME(FUNCTION_NAME.getRel)) +
|
|
186
198
|
upperCase(shortNameHandler(handlerType)),
|
|
187
199
|
roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole,
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
200
|
+
resourceApis: resourcesApi.map(api => ({
|
|
201
|
+
path: `/${ownServiceTag}/${api.event}/${api.action}`,
|
|
202
|
+
method: api.method,
|
|
203
|
+
hookTagApp: `${upperCase(api.event)}AppLevelAuthorizer`,
|
|
204
|
+
})),
|
|
205
|
+
event
|
|
193
206
|
},
|
|
194
207
|
setting: {
|
|
195
208
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -1,9 +1,27 @@
|
|
|
1
|
-
<%
|
|
2
|
-
<%-
|
|
3
|
-
|
|
4
|
-
<%-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
<%_ const join = require('path').join; _%>
|
|
2
|
+
<%- firstLetterUpperCase(functionNameConfig) %>:
|
|
3
|
+
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
|
+
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
|
+
role: <%- roleName %>Role
|
|
6
|
+
#<#<%- functionName %><%- firstLetterUpperCase(handlerType) %>FunctionSetting#>
|
|
7
|
+
#<#/<%- functionName %><%- firstLetterUpperCase(handlerType) %>FunctionSetting#>
|
|
8
|
+
<%_ if (handlerType === 'hdrDsq' || handlerType === 'hdrSqs') { _%>
|
|
9
|
+
events:
|
|
10
|
+
- sqs:
|
|
11
|
+
arn: <%- event %>
|
|
12
|
+
batchSize: 10
|
|
13
|
+
<%_ } else if (handlerType === 'hdrApi' && resourceApis.length > 0) { _%>
|
|
14
|
+
events:
|
|
15
|
+
<%_ resourceApis.forEach(api => { _%>
|
|
16
|
+
- httpApi:
|
|
17
|
+
path: <%- api.path %>
|
|
18
|
+
method: <%- api.method %>
|
|
19
|
+
#<#<%- api.hookTagApp %>#>
|
|
20
|
+
# authorizer: authorizerServiceSchema
|
|
21
|
+
#<#/<%- api.hookTagApp %>#>
|
|
22
|
+
<%_ }) _%>
|
|
23
|
+
<%_ } _%>
|
|
24
|
+
|
|
25
|
+
<%_ function firstLetterUpperCase(text) {
|
|
26
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
27
|
+
} _%>
|
|
@@ -112,7 +112,6 @@ const baseComponents = [
|
|
|
112
112
|
changeRelActionMainFunction,
|
|
113
113
|
changeRelActionHandler,
|
|
114
114
|
changeRelActionSnsInSqs,
|
|
115
|
-
changeRelActionFunctionYaml,
|
|
116
115
|
changeRelCompleteMainFunction,
|
|
117
116
|
changeRelCompleteFunctionYaml,
|
|
118
117
|
changeRelCompleteHandler,
|
|
@@ -134,7 +133,9 @@ const schemaComponents = [
|
|
|
134
133
|
createActionFunctionYaml,
|
|
135
134
|
deleteActionFunctionYaml,
|
|
136
135
|
getActionFunctionYaml,
|
|
137
|
-
moveRelActionFunctionYaml
|
|
136
|
+
moveRelActionFunctionYaml,
|
|
137
|
+
changeRelActionFunctionYaml,
|
|
138
|
+
|
|
138
139
|
];
|
|
139
140
|
|
|
140
141
|
async function relationshipPerActionComponent(
|
|
@@ -35,7 +35,10 @@ const {
|
|
|
35
35
|
HANDLER
|
|
36
36
|
} = consts;
|
|
37
37
|
|
|
38
|
-
const { firstLetterUpperCase: upperCase,
|
|
38
|
+
const { firstLetterUpperCase: upperCase,
|
|
39
|
+
firstLetterLowerCase: lowerCase,
|
|
40
|
+
getLocalConfig
|
|
41
|
+
} = utils;
|
|
39
42
|
|
|
40
43
|
const {
|
|
41
44
|
createIamRole,
|
|
@@ -46,11 +49,6 @@ const {
|
|
|
46
49
|
} = libs;
|
|
47
50
|
const templatePath = path.join(__dirname, 'template.ejs');
|
|
48
51
|
|
|
49
|
-
const apiTemplate = path.join(__dirname, 'templateByHandler/apiTemplate.ejs');
|
|
50
|
-
const dsqTemplate = path.join(__dirname, 'templateByHandler/dsqTemplate.ejs');
|
|
51
|
-
const invTemplate = path.join(__dirname, 'templateByHandler/invTemplate.ejs');
|
|
52
|
-
const sqsTemplate = path.join(__dirname, 'templateByHandler/sqsTemplate.ejs');
|
|
53
|
-
|
|
54
52
|
/**
|
|
55
53
|
* receive objectSchema
|
|
56
54
|
* create data for updateRelationshipSchema
|
|
@@ -140,6 +138,21 @@ function createParamForCreateSource(
|
|
|
140
138
|
);
|
|
141
139
|
}
|
|
142
140
|
|
|
141
|
+
const serviceTag = getLocalConfig('iz_serviceTag');
|
|
142
|
+
|
|
143
|
+
const resourcesApi = [];
|
|
144
|
+
if (handlerType === HANDLER.hdrApi) {
|
|
145
|
+
allObjectRelationships.map(relationshipSchema => (
|
|
146
|
+
resourcesApi.push({
|
|
147
|
+
event: lowerCase(Object.keys(relationshipSchema)[0]),
|
|
148
|
+
method: 'post',
|
|
149
|
+
action: 'move'
|
|
150
|
+
}))
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const event = resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(handlerType));
|
|
155
|
+
|
|
143
156
|
return {
|
|
144
157
|
templatePath: templatePath,
|
|
145
158
|
templateData: {
|
|
@@ -151,11 +164,14 @@ function createParamForCreateSource(
|
|
|
151
164
|
upperCase(SHORT_FUNCTION_NAME(FUNCTION_NAME.moveRel)) +
|
|
152
165
|
upperCase(shortNameHandler(handlerType)),
|
|
153
166
|
roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
167
|
+
resourceApis: resourcesApi.map(api => ({
|
|
168
|
+
path: `/${serviceTag}/${api.event}/${api.action}`,
|
|
169
|
+
pathWithUser: `/${serviceTag}/${api.event}/${api.action}/{targetUserId}`,
|
|
170
|
+
method: api.method,
|
|
171
|
+
hookTagApp: `${upperCase(api.event)}AppLevelAuthorizer`,
|
|
172
|
+
hookTagUser: `${upperCase(api.event)}UserLevelAuthorizer`
|
|
173
|
+
})),
|
|
174
|
+
event
|
|
159
175
|
},
|
|
160
176
|
setting: {
|
|
161
177
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|