@izara_project/izara-market-library-service-schemas 1.0.30 → 1.0.31
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/GenerateCodeLibs/src/Consts.js +2 -1
- package/src/MainLibs/src/Consts.js +11 -4
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +3 -3
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +1 -2
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +2 -2
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +2 -2
- package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +10 -8
- package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/functionYaml/data.js +4 -4
- package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/handler/data.js +4 -4
- package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/functionYaml/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/functionYaml/data.js +4 -4
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/handler/data.js +4 -4
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/mainFunction/data.js +4 -4
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/functionYaml/data.js +4 -4
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/handler/data.js +4 -4
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/data.js +4 -4
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/handler/data.js +4 -4
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/data.js +4 -4
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrS3/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/handler/handlerS3/data.js +4 -4
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/mainFunction/data.js +4 -4
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +3 -3
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/template.ejs +2 -0
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/data.js +3 -2
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/template.ejs +4 -16
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchema/functionYaml/data.js +115 -0
- package/src/reStructure/TemplateData/flowSchema/{components/schema/inProcess → flowSchemaOwnTopic/flowSchema}/functionYaml/template.ejs +1 -20
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchema/handler/data.js +70 -0
- package/src/reStructure/TemplateData/flowSchema/{components/schema/inProcess → flowSchemaOwnTopic/flowSchema}/handler/template.ejs +14 -32
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchema/mainFunction/data.js +64 -0
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchema/mainFunction/template.ejs +104 -0
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchemaComplete/functionYaml/data.js +115 -0
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchemaComplete/functionYaml/template.ejs +20 -0
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchemaComplete/handler/data.js +71 -0
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchemaComplete/handler/template.ejs +85 -0
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchemaComplete/mainFunction/data.js +63 -0
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchemaComplete/mainFunction/template.ejs +105 -0
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +55 -35
- package/src/reStructure/TemplateData/generateRole/createSharedResource.js +10 -0
- package/src/reStructure/TemplateData/flowSchema/components/schema/inProcess/functionYaml/data.js +0 -76
- package/src/reStructure/TemplateData/flowSchema/components/schema/inProcess/handler/data.js +0 -46
- package/src/reStructure/TemplateData/flowSchema/components/schema/inProcess/mainFunction/data.js +0 -45
- package/src/reStructure/TemplateData/flowSchema/components/schema/inProcess/sns-sqs/data.js +0 -35
- package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/functionYaml/data.js +0 -34
- package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/functionYaml/template.ejs +0 -0
- package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/handler/data.js +0 -34
- package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/handler/template.ejs +0 -0
- package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/mainFunction/data.js +0 -34
- package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/mainFunction/template.ejs +0 -0
- package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/sns-sqs/data.js +0 -34
- package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/sns-sqs/template.ejs +0 -0
- package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/functionYaml/data.js +0 -101
- package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/functionYaml/template.ejs +0 -43
- package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/handler/data.js +0 -93
- package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/handler/templateAsyncHandler.ejs +0 -110
- package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/handler/templateSyncHandler.ejs +0 -49
- package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/hookLogic/data.js +0 -64
- package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/mainFunction/data.js +0 -66
- package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/mainFunction/template.ejs +0 -30
- package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/queue/data.js +0 -124
- package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/queue/snsTemplate.ejs +0 -59
- package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/queue/sqsTemplate.ejs +0 -43
- /package/src/reStructure/TemplateData/flowSchema/{components/schema/inProcess/mainFunction/template.ejs → flowSchemaOwnTopic/sns-in/data.js} +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{components/schema/inProcess/sns-sqs/template.ejs → flowSchemaOwnTopic/sns-out/data.js} +0 -0
package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchema/functionYaml/data.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
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
|
+
|
|
21
|
+
const { ACTIONS } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
22
|
+
const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
|
|
23
|
+
const {
|
|
24
|
+
SOURCE_PATH,
|
|
25
|
+
defaultIamRolePerAction,
|
|
26
|
+
createIamRole,
|
|
27
|
+
RESOURCE_CLASSES,
|
|
28
|
+
SNS_RESOURCE,
|
|
29
|
+
resourceNames,
|
|
30
|
+
DYNAMO_RESOURCE,
|
|
31
|
+
SAVE_FILE_NAME,
|
|
32
|
+
FUNCTION_NAME,
|
|
33
|
+
shortNameHandler,
|
|
34
|
+
externalResourceYaml,
|
|
35
|
+
SOURCE_GENERATE_IAM_ROLE
|
|
36
|
+
} = require('../../../../../../MainLibs/src/Consts');
|
|
37
|
+
|
|
38
|
+
const templatePath = path.join(__dirname, "./template.ejs");
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* receive objectSchema
|
|
42
|
+
* create data for WebScoket handler template
|
|
43
|
+
*
|
|
44
|
+
* @param {Object} objectSchema
|
|
45
|
+
* @return {{templatePath, templateData,setting}}
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
function data(_izContext, flowSchema, srcPath) {
|
|
49
|
+
return [createSourceParams(_izContext, flowSchema, srcPath)]
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
53
|
+
|
|
54
|
+
let functionName = upperCase(FUNCTION_NAME.flowSchemaOwnTopic)
|
|
55
|
+
let handlerType = upperCase("hdrWbs")
|
|
56
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
57
|
+
let route = flowSchema.flowTag
|
|
58
|
+
|
|
59
|
+
additionalResourcePermission.push(
|
|
60
|
+
createIamRole(
|
|
61
|
+
{
|
|
62
|
+
[RESOURCE_CLASSES.dynamoDbTable]: Object.values(DYNAMO_RESOURCE)
|
|
63
|
+
},
|
|
64
|
+
[
|
|
65
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "WebSocketTask")
|
|
66
|
+
]
|
|
67
|
+
),
|
|
68
|
+
createIamRole(
|
|
69
|
+
{
|
|
70
|
+
"execute-api": [
|
|
71
|
+
"ManageConnections"
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
[
|
|
75
|
+
resourceNames(RESOURCE_CLASSES.webSocket)
|
|
76
|
+
]
|
|
77
|
+
)
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
for (const flowStep of Object.keys(flowSchema.flowSteps)) {
|
|
81
|
+
if (flowStep.includes("In")) {
|
|
82
|
+
additionalResourcePermission.push(
|
|
83
|
+
createIamRole(
|
|
84
|
+
{
|
|
85
|
+
[RESOURCE_CLASSES.sns]: SNS_RESOURCE.publish
|
|
86
|
+
},
|
|
87
|
+
[
|
|
88
|
+
resourceNames(RESOURCE_CLASSES.sns, flowStep)
|
|
89
|
+
]
|
|
90
|
+
)
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
templatePath: templatePath,
|
|
97
|
+
templateData: {
|
|
98
|
+
resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchemaOwnTopic, flowSchema.flowTag),
|
|
99
|
+
functionName,
|
|
100
|
+
handlerType,
|
|
101
|
+
additionalResourcePermission,
|
|
102
|
+
route,
|
|
103
|
+
functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
|
|
104
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic
|
|
105
|
+
},
|
|
106
|
+
setting: {
|
|
107
|
+
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
108
|
+
saveFileName: upperCase(SAVE_FILE_NAME.flowSchema),
|
|
109
|
+
fileExtension: ".yml",
|
|
110
|
+
isAppend: true
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
module.exports = data;
|
|
@@ -3,30 +3,11 @@
|
|
|
3
3
|
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
4
|
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
5
|
events:
|
|
6
|
-
- websocket:
|
|
7
|
-
route: $connect
|
|
8
|
-
- websocket:
|
|
9
|
-
route: $disconnect
|
|
10
|
-
- websocket:
|
|
11
|
-
route: $default
|
|
12
6
|
- websocket:
|
|
13
7
|
route: <%- route %>
|
|
14
8
|
# authorizer: ${self:custom.iz_authorizerAppLevel}
|
|
15
9
|
# identifierResource: 'route.request.header.Auth'
|
|
16
|
-
|
|
17
|
-
<%_ additionalResourcePermission.forEach(resourcePermission => { _%>
|
|
18
|
-
- Effect: <%- resourcePermission.effect %>
|
|
19
|
-
Action:
|
|
20
|
-
<%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
|
|
21
|
-
<%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
|
|
22
|
-
- <%- resourcePerAction %>:<%- permission %>
|
|
23
|
-
<%_}) _%>
|
|
24
|
-
<%_ }) _%>
|
|
25
|
-
Resource:
|
|
26
|
-
<%_ resourcePermission.resource.forEach(resource => { _%>
|
|
27
|
-
- <%- resource %>
|
|
28
|
-
<%_ }) _%>
|
|
29
|
-
<%_}) _%>
|
|
10
|
+
role: <%- roleName %>Role
|
|
30
11
|
#<#<%- functionName %><%- handlerType %>IamRole#>
|
|
31
12
|
#<#/<%- functionName %><%- handlerType %>IamRole#>
|
|
32
13
|
<%_ function firstLetterUpperCase(text){
|
|
@@ -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
|
+
const path = require('path');
|
|
20
|
+
const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
|
|
21
|
+
const {
|
|
22
|
+
SOURCE_PATH,
|
|
23
|
+
defaultIamRolePerAction,
|
|
24
|
+
createIamRole,
|
|
25
|
+
RESOURCE_CLASSES,
|
|
26
|
+
SNS_RESOURCE,
|
|
27
|
+
resourceNames,
|
|
28
|
+
DYNAMO_RESOURCE,
|
|
29
|
+
SAVE_FILE_NAME,
|
|
30
|
+
FUNCTION_NAME,
|
|
31
|
+
shortNameHandler,
|
|
32
|
+
externalResourceYaml,
|
|
33
|
+
SOURCE_GENERATE_IAM_ROLE
|
|
34
|
+
} = require('../../../../../../MainLibs/src/Consts');
|
|
35
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* receive objectSchema
|
|
39
|
+
* create data for WebScoket handler template
|
|
40
|
+
*
|
|
41
|
+
* @param {Object} objectSchema
|
|
42
|
+
* @return {{templatePath, templateData,setting}}
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
function data(_izContext, flowSchema, srcPath) {
|
|
47
|
+
return [createParamsForCreateSource(_izContext, flowSchema, srcPath)]
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
51
|
+
let functionName = upperCase(FUNCTION_NAME.flowSchemaOwnTopic)
|
|
52
|
+
let handlerType = "HdrWbs";
|
|
53
|
+
let route = flowSchema.flowTag
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
templatePath: templatePath,
|
|
57
|
+
templateData: {
|
|
58
|
+
functionName,
|
|
59
|
+
handlerType,
|
|
60
|
+
route
|
|
61
|
+
},
|
|
62
|
+
setting: {
|
|
63
|
+
savePath: path.join(srcPath, SOURCE_PATH.flowSchemaOwnTopic, flowSchema.flowTag, "source/"),
|
|
64
|
+
saveFileName: `${functionName}_${handlerType}`,
|
|
65
|
+
fileExtension: ".js",
|
|
66
|
+
isAppend: false
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
module.exports = data
|
|
@@ -21,15 +21,13 @@ const izara = require("@izara_project/izara-middleware");
|
|
|
21
21
|
const middleware = izara.middlewareHandler;
|
|
22
22
|
// const AWS = require('aws-sdk');
|
|
23
23
|
// const api = new AWS.ApiGatewayManagementApi({ endpoint: process.env.iz_webSocketEndpoint });
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const callingFlowSharedLib = izaraShared.callingFlowSharedLib;
|
|
24
|
+
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb')
|
|
25
|
+
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow')
|
|
27
26
|
const hash = require('object-hash')
|
|
28
27
|
// const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
|
|
29
28
|
const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
|
|
30
29
|
const { postToConnection } = require("../../libs/source/ImportDataLib");
|
|
31
|
-
const
|
|
32
|
-
|
|
30
|
+
const { flowSchemaOwnTopic } = require('./<%- `${functionName}_Main` %>');
|
|
33
31
|
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
34
32
|
|
|
35
33
|
event._izContext.logger.debug('Event:', event);
|
|
@@ -39,37 +37,16 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
39
37
|
if (event.requestContext) {
|
|
40
38
|
const route = event.requestContext.routeKey;
|
|
41
39
|
const connectionId = event.requestContext.connectionId;
|
|
40
|
+
let correlationId = event._izContext.correlationIds.get(consts.X_CORRELATION_ID)
|
|
42
41
|
|
|
43
42
|
switch (route) {
|
|
44
|
-
case "$connect":
|
|
45
|
-
console.log("webSocket Connect");
|
|
46
|
-
break
|
|
47
|
-
case "$disconnect":
|
|
48
|
-
console.log("webSocket Disconnect");
|
|
49
|
-
break
|
|
50
43
|
case '$default':
|
|
51
44
|
console.log('Received unknown route:', route);
|
|
52
45
|
break
|
|
53
|
-
case '
|
|
46
|
+
case '<%- route %>':
|
|
54
47
|
console.log("event in route webSocket", event);
|
|
55
|
-
|
|
56
48
|
let eventParams = JSON.parse(event.body)
|
|
57
49
|
|
|
58
|
-
let callingFlow = eventParams?.callingFlow ? eventParams.callingFlow : {};
|
|
59
|
-
|
|
60
|
-
await createObject.createObject(
|
|
61
|
-
event._izContext,
|
|
62
|
-
eventParams,
|
|
63
|
-
//(<additionalParams>)
|
|
64
|
-
event,
|
|
65
|
-
//(</additionalParams>)
|
|
66
|
-
callingFlowSharedLib.addCallingFlowToPassOnProperties(callingFlow)
|
|
67
|
-
)
|
|
68
|
-
|
|
69
|
-
let correlationId = event._izContext.correlationIds.get(consts.X_CORRELATION_ID)
|
|
70
|
-
event._izContext.logger.debug("correlationId", correlationId)
|
|
71
|
-
|
|
72
|
-
// if (returnValueFlowSchema) {
|
|
73
50
|
await dynamodbSharedLib.putItem(
|
|
74
51
|
event._izContext,
|
|
75
52
|
await dynamodbSharedLib.tableName(event._izContext, "WebSocketTask"),
|
|
@@ -78,11 +55,16 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
78
55
|
connectionId: connectionId,
|
|
79
56
|
}
|
|
80
57
|
)
|
|
81
|
-
// }
|
|
82
58
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
59
|
+
let callingFlow = eventParams?.callingFlow ? eventParams.callingFlow : {};
|
|
60
|
+
await flowSchemaOwnTopic(
|
|
61
|
+
event._izContext,
|
|
62
|
+
eventParams,
|
|
63
|
+
callingFlowSharedLib.addCallingFlowToPassOnProperties(callingFlow)
|
|
64
|
+
//(<additionalParams>)
|
|
65
|
+
//(</additionalParams>)
|
|
66
|
+
)
|
|
67
|
+
|
|
86
68
|
break
|
|
87
69
|
}
|
|
88
70
|
} else {
|
package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchema/mainFunction/data.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
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 { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
|
|
21
|
+
const {
|
|
22
|
+
SOURCE_PATH,
|
|
23
|
+
defaultIamRolePerAction,
|
|
24
|
+
createIamRole,
|
|
25
|
+
RESOURCE_CLASSES,
|
|
26
|
+
SNS_RESOURCE,
|
|
27
|
+
resourceNames,
|
|
28
|
+
DYNAMO_RESOURCE,
|
|
29
|
+
SAVE_FILE_NAME,
|
|
30
|
+
FUNCTION_NAME,
|
|
31
|
+
shortNameHandler,
|
|
32
|
+
externalResourceYaml,
|
|
33
|
+
SOURCE_GENERATE_IAM_ROLE
|
|
34
|
+
} = require('../../../../../../MainLibs/src/Consts');
|
|
35
|
+
const templatePath = path.join(__dirname, "template.ejs");
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* receive objectSchema
|
|
39
|
+
* create data for WebScoket handler template
|
|
40
|
+
*
|
|
41
|
+
* @param {Object} objectSchema
|
|
42
|
+
* @return {{templatePath, templateData,setting}}
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
function data(_izContext, flowSchema, srcPath) {
|
|
47
|
+
return [createParamsForCreateSource(_izContext, flowSchema, srcPath)]
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
51
|
+
let functionName = upperCase(FUNCTION_NAME.flowSchemaOwnTopic)
|
|
52
|
+
let topicArn = Object.keys(flowSchema.flowSteps)[0];
|
|
53
|
+
return {
|
|
54
|
+
templatePath: templatePath,
|
|
55
|
+
templateData: {},
|
|
56
|
+
setting: {
|
|
57
|
+
savePath: path.join(srcPath, SOURCE_PATH.flowSchemaOwnTopic, flowSchema.flowTag, "source/"),
|
|
58
|
+
saveFileName: `${functionName}_Main`,
|
|
59
|
+
fileExtension: ".js",
|
|
60
|
+
isAppend: false
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
module.exports = data
|
|
@@ -0,0 +1,104 @@
|
|
|
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
|
|
16
|
+
<http: //www.gnu.org/licenses />.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
const hash = require("object-hash");
|
|
22
|
+
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
|
|
23
|
+
|
|
24
|
+
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
|
|
25
|
+
const snsSharedLib = require('@izara_project/izara-core-library-sns');
|
|
26
|
+
const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
|
|
27
|
+
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
28
|
+
const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
|
|
29
|
+
|
|
30
|
+
const externalRequest = require('@izara_project/izara-core-library-external-request');
|
|
31
|
+
const sns = externalRequest.sns
|
|
32
|
+
|
|
33
|
+
const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
|
|
34
|
+
const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
|
|
35
|
+
const { v4: uuidv4 } = require('uuid')
|
|
36
|
+
const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
|
|
37
|
+
const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
*
|
|
41
|
+
* description of function.
|
|
42
|
+
* @param {Object} _izContext
|
|
43
|
+
* @param {CorrelationIds} _izContext.correlationIds - property of _izContext
|
|
44
|
+
* @param {Logger} _izContext.logger - property of _izContext
|
|
45
|
+
* @param {Object} requestParams - request params
|
|
46
|
+
* @param {Object} requestParams.identifiers - identifiers for get data
|
|
47
|
+
* @param {Object} requestParams.additionalRequest - additionalRequest
|
|
48
|
+
*
|
|
49
|
+
*
|
|
50
|
+
* @returns {object} description of return value
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
module.exports.flowSchemaOwnTopic = async (
|
|
54
|
+
_izContext,
|
|
55
|
+
requestParams,
|
|
56
|
+
callingFlowConfig = {},
|
|
57
|
+
//(<additionalParams>)
|
|
58
|
+
//(</additionalParams>)
|
|
59
|
+
) => {
|
|
60
|
+
|
|
61
|
+
try {
|
|
62
|
+
_izContext.logger.debug("WebSocketInvoke _izContext", _izContext)
|
|
63
|
+
_izContext.logger.debug("WebSocketInvoke requestParams", requestParams)
|
|
64
|
+
_izContext.logger.debug("WebSocketInvoke callingFlowConfig", callingFlowConfig)
|
|
65
|
+
|
|
66
|
+
let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
|
|
67
|
+
flowTag: requestParams.flowTag,
|
|
68
|
+
serviceTag: process.env.iz_serviceTag
|
|
69
|
+
// serviceTag: "GenerateCodeTamplateBas002"
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
_izContext.logger.debug("flowSchema", flowSchema)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
if (!flowSchema) {
|
|
76
|
+
throw new NoRetryError(`flowTag not found ${requestParams.flowTag}`)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let messageObject = {
|
|
80
|
+
requestParams:requestParams
|
|
81
|
+
}
|
|
82
|
+
// create callingFlow
|
|
83
|
+
messageObject = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
|
|
84
|
+
messageObject,
|
|
85
|
+
callingFlowSharedLib.addParentCallingFlowConfig(
|
|
86
|
+
callingFlowConfig,
|
|
87
|
+
callingFlowSharedLib.createCallingFlowConfig(
|
|
88
|
+
await lambdaSharedLib.lambdaFunctionName(_izContext, TOPIC_NAME_GENERATE_CODE.flowSchemaOwnTopicComplete), {}
|
|
89
|
+
)
|
|
90
|
+
)
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
let sendMessageToCreateEndpoint = {
|
|
94
|
+
Message: JSON.stringify(messageObject),
|
|
95
|
+
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, )
|
|
96
|
+
}
|
|
97
|
+
_izContext.logger.debug("sendMessageToCreateEndpoint", sendMessageToCreateEndpoint);
|
|
98
|
+
await sns.publishAsync(_izContext, sendMessageToCreateEndpoint);
|
|
99
|
+
|
|
100
|
+
} catch (err) {
|
|
101
|
+
_izContext.logger.error('error WebSocketInvoke: ', err)
|
|
102
|
+
throw (err)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
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
|
+
|
|
21
|
+
const { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
22
|
+
const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
|
|
23
|
+
const {
|
|
24
|
+
SOURCE_PATH,
|
|
25
|
+
defaultIamRolePerAction,
|
|
26
|
+
createIamRole,
|
|
27
|
+
RESOURCE_CLASSES,
|
|
28
|
+
SNS_RESOURCE,
|
|
29
|
+
resourceNames,
|
|
30
|
+
DYNAMO_RESOURCE,
|
|
31
|
+
SAVE_FILE_NAME,
|
|
32
|
+
FUNCTION_NAME,
|
|
33
|
+
shortNameHandler,
|
|
34
|
+
externalResourceYaml,
|
|
35
|
+
SOURCE_GENERATE_IAM_ROLE
|
|
36
|
+
} = require('../../../../../../MainLibs/src/Consts');
|
|
37
|
+
|
|
38
|
+
const templatePath = path.join(__dirname, "./template.ejs");
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* receive objectSchema
|
|
42
|
+
* create data for WebScoket handler template
|
|
43
|
+
*
|
|
44
|
+
* @param {Object} objectSchema
|
|
45
|
+
* @return {{templatePath, templateData,setting}}
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
function data(_izContext, flowSchema, srcPath) {
|
|
49
|
+
return [createSourceParams(_izContext, flowSchema, srcPath)]
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
53
|
+
|
|
54
|
+
let functionName = upperCase(FUNCTION_NAME.flowSchemaOwnTopicComplete)
|
|
55
|
+
let handlerType = upperCase(HANDLER.hdrSqs)
|
|
56
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
57
|
+
let route = flowSchema.flowTag
|
|
58
|
+
|
|
59
|
+
additionalResourcePermission.push(
|
|
60
|
+
createIamRole(
|
|
61
|
+
{
|
|
62
|
+
[RESOURCE_CLASSES.dynamoDbTable]: Object.values(DYNAMO_RESOURCE)
|
|
63
|
+
},
|
|
64
|
+
[
|
|
65
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "WebSocketTask")
|
|
66
|
+
]
|
|
67
|
+
),
|
|
68
|
+
createIamRole(
|
|
69
|
+
{
|
|
70
|
+
"execute-api": [
|
|
71
|
+
"ManageConnections"
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
[
|
|
75
|
+
resourceNames(RESOURCE_CLASSES.webSocket)
|
|
76
|
+
]
|
|
77
|
+
)
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
for (const flowStep of Object.keys(flowSchema.flowSteps)) {
|
|
81
|
+
if (flowStep.includes("In")) {
|
|
82
|
+
additionalResourcePermission.push(
|
|
83
|
+
createIamRole(
|
|
84
|
+
{
|
|
85
|
+
[RESOURCE_CLASSES.sns]: SNS_RESOURCE.publish
|
|
86
|
+
},
|
|
87
|
+
[
|
|
88
|
+
resourceNames(RESOURCE_CLASSES.sns, flowStep)
|
|
89
|
+
]
|
|
90
|
+
)
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
templatePath: templatePath,
|
|
97
|
+
templateData: {
|
|
98
|
+
resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchemaOwnTopic, flowSchema.flowTag),
|
|
99
|
+
functionName,
|
|
100
|
+
handlerType,
|
|
101
|
+
additionalResourcePermission,
|
|
102
|
+
route,
|
|
103
|
+
functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
|
|
104
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic
|
|
105
|
+
},
|
|
106
|
+
setting: {
|
|
107
|
+
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
108
|
+
saveFileName: upperCase(SAVE_FILE_NAME.flowSchema),
|
|
109
|
+
fileExtension: ".yml",
|
|
110
|
+
isAppend: true
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
module.exports = data;
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
events:
|
|
6
|
+
- sqs:
|
|
7
|
+
arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %>
|
|
8
|
+
batchSize: 10
|
|
9
|
+
filterPatterns: #**** need to update serverless framwork upper v.2.69.1
|
|
10
|
+
- body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%-firstLetterUpperCase(functionName) %>"]}}} # functionName of callingFlow
|
|
11
|
+
- body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
|
|
12
|
+
role: <%- roleName %>Role
|
|
13
|
+
#<#<%- functionName %><%- handlerType %>IamRole#>
|
|
14
|
+
#<#/<%- functionName %><%- handlerType %>IamRole#>
|
|
15
|
+
<%_ function firstLetterUpperCase(text){
|
|
16
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
17
|
+
} _%>
|
|
18
|
+
<%_ function firstLetterLowerCase(str) {
|
|
19
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
20
|
+
} _%>
|
|
@@ -0,0 +1,71 @@
|
|
|
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 { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
|
|
21
|
+
const {
|
|
22
|
+
SOURCE_PATH,
|
|
23
|
+
defaultIamRolePerAction,
|
|
24
|
+
createIamRole,
|
|
25
|
+
RESOURCE_CLASSES,
|
|
26
|
+
SNS_RESOURCE,
|
|
27
|
+
resourceNames,
|
|
28
|
+
DYNAMO_RESOURCE,
|
|
29
|
+
SAVE_FILE_NAME,
|
|
30
|
+
FUNCTION_NAME,
|
|
31
|
+
shortNameHandler,
|
|
32
|
+
externalResourceYaml,
|
|
33
|
+
SOURCE_GENERATE_IAM_ROLE,
|
|
34
|
+
HANDLER
|
|
35
|
+
} = require('../../../../../../MainLibs/src/Consts');
|
|
36
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* receive objectSchema
|
|
40
|
+
* create data for WebScoket handler template
|
|
41
|
+
*
|
|
42
|
+
* @param {Object} objectSchema
|
|
43
|
+
* @return {{templatePath, templateData,setting}}
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
function data(_izContext, flowSchema, srcPath) {
|
|
48
|
+
return [createParamsForCreateSource(_izContext, flowSchema, srcPath)]
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
52
|
+
let functionName = upperCase(FUNCTION_NAME.flowSchemaOwnTopicComplete)
|
|
53
|
+
let handlerType = upperCase(HANDLER.hdrSqs);
|
|
54
|
+
let route = flowSchema.flowTag
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
templatePath: templatePath,
|
|
58
|
+
templateData: {
|
|
59
|
+
functionName,
|
|
60
|
+
handlerType,
|
|
61
|
+
route
|
|
62
|
+
},
|
|
63
|
+
setting: {
|
|
64
|
+
savePath: path.join(srcPath, SOURCE_PATH.flowSchemaOwnTopic, flowSchema.flowTag, "source/"),
|
|
65
|
+
saveFileName: `${functionName}_${handlerType}`,
|
|
66
|
+
fileExtension: ".js",
|
|
67
|
+
isAppend: false
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
module.exports = data
|