@izara_project/izara-market-library-service-schemas 1.0.29 → 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 +11 -9
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +54 -21
- package/src/MainLibs/src/Consts.js +43 -20
- package/src/reStructure/GenerateCode.js +2 -1
- package/src/reStructure/TemplateConfig.js +5 -1
- package/src/reStructure/TemplateData/EndpointPerService/generateTemplateData.js +108 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/api/data.js +76 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/api/request.json +7 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/api/template.ejs +73 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/dsq/data.js +81 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/dsq/request.json +7 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/dsq/template.ejs +125 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/inv/data.js +70 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/inv/request.json +7 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/inv/template.ejs +73 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/sqs/data.js +79 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/sqs/request.json +7 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/sqs/template.ejs +126 -0
- package/src/reStructure/TemplateData/{flowSchema/components/schema/inProcess/handler → EndpointPerService/mainFunction/create}/data.js +20 -13
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +624 -0
- package/src/reStructure/TemplateData/{flowSchema/components/schema/inProcess/mainFunction → EndpointPerService/mainFunction/delete}/data.js +18 -11
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +176 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/data.js +56 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +234 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/data.js +56 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +330 -0
- package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +177 -0
- package/src/reStructure/TemplateData/EndpointPerService/yaml/template.ejs +26 -0
- package/src/reStructure/TemplateData/externalService/generateTemplateData.js +1 -1
- package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +91 -249
- package/src/reStructure/TemplateData/externalService/lambdaRole/template.ejs +1 -1
- package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +10 -8
- package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/template.ejs +1 -1
- package/src/reStructure/TemplateData/findData/findDataYaml/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/functionYaml/data.js +8 -7
- 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 +5 -31
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/data.js +4 -22
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/template.ejs +3 -31
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/functionYaml/data.js +6 -6
- 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/createObjectComplete/sns-sqs/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/sns-sqs/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{getSignUrls → createPresignUrl}/functionYaml/data.js +45 -14
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{getSignUrls → createPresignUrl}/functionYaml/template.ejs +3 -0
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{getSignUrls → createPresignUrl}/handler/data.js +6 -6
- package/src/reStructure/TemplateData/flowSchema/{legacy/hookCode-old/handler/templateAsyncHandler.ejs → components/upload/preSignUrl/createPresignUrl/handler/template.ejs} +26 -11
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{getSignUrls → createPresignUrl}/mainFunction/data.js +11 -8
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +253 -0
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{reservedLimit → createPresignUrl}/queue/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/data.js +14 -42
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/template.ejs +0 -3
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/handler/data.js +6 -6
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/handler/template.ejs +40 -45
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/data.js +5 -8
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +100 -190
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{getSignUrls → reservedLimit}/sqs/data.js +4 -4
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{getSignUrls → reservedLimit}/sqs/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrS3/data.js +9 -7
- 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/upload/processFile/queue/s3Template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/relate/S3/data.js +5 -2
- 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/{components/upload/hook/hookLogic → flowSchemaOwnTopic/flowSchemaComplete/mainFunction}/data.js +30 -10
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchemaComplete/mainFunction/template.ejs +105 -0
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +78 -55
- package/src/reStructure/TemplateData/generateRole/createSharedResource.js +21 -1
- package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +35 -44
- package/src/reStructure/TemplateData/perActionComplete/create/sns-out/template.ejs +1 -1
- package/src/reStructure/TemplateData/perActionComplete/create/yaml/data.js +4 -5
- package/src/reStructure/TemplateData/perActionComplete/delete/yaml/data.js +5 -4
- package/src/reStructure/TemplateData/perActionComplete/generateTemplateData.js +15 -2
- package/src/reStructure/TemplateData/perActionComplete/get/yaml/data.js +7 -4
- package/src/reStructure/TemplateData/perActionComplete/update/sns-out/data.js +1 -1
- package/src/reStructure/TemplateData/perActionComplete/update/yaml/data.js +5 -4
- package/src/reStructure/TemplateData/processLogical/yaml/data.js +3 -3
- package/src/reStructure/TemplateData/processLogicalPagination/yaml/dsq/data.js +1 -1
- package/src/reStructure/TemplateData/processLogicalPagination/yaml/sqs/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/api/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/dsq/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/inv/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/sqs/data.js +3 -3
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/sns-in-sqs/snsTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/functionYaml/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/sns-in-sqs/template.ejs +0 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/sns-out/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/api/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/dsq/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/inv/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/sqs/data.js +3 -3
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/sns-in-sqs/snsTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/functionYaml/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/sns-out/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/api/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/inv/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/sqs/data.js +4 -4
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/sns-in-sqs/snsTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/sns-out/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/api/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/dsq/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/inv/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/sqs/data.js +4 -4
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/sns-in-sqs/snsTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/complete/functionYaml/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/update/complete/sns-out/template.ejs +1 -1
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/defaultDynamoDbTable.js +1 -1
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/generateDynamoPerLink.js +1 -1
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +1 -1
- package/src/reStructure/TemplateData/resourceYaml/generateTemplateData.js +6 -12
- package/src/reStructure/TemplateData/resourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical.js +1 -1
- package/src/reStructure/TemplateData/resourceYaml/sns-in-sqs/snsAndSqsPerActionData.js +22 -49
- package/src/reStructure/TemplateData/resourceYaml/sns-in-sqs/snsTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/resourceYaml/sns-out/data.js +8 -24
- package/src/reStructure/TemplateData/resourceYaml/sns-out/template.ejs +1 -1
- package/src/reStructure/TemplateData/testTemplate/template.ejs +0 -5
- package/src/reStructure/TemplateData/flowSchema/components/schema/inProcess/functionYaml/data.js +0 -76
- 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/components/upload/hook/handler/data.js +0 -93
- package/src/reStructure/TemplateData/flowSchema/components/upload/hook/handler/templateAsyncHandler.ejs +0 -110
- package/src/reStructure/TemplateData/flowSchema/components/upload/hook/handler/templateSyncHandler.ejs +0 -49
- package/src/reStructure/TemplateData/flowSchema/components/upload/hook/mainFunction/data.js +0 -65
- package/src/reStructure/TemplateData/flowSchema/components/upload/hook/mainFunction/template.ejs +0 -7
- package/src/reStructure/TemplateData/flowSchema/components/upload/hook/queue/data.js +0 -72
- package/src/reStructure/TemplateData/flowSchema/components/upload/hook/queue/snsTemplate.ejs +0 -59
- package/src/reStructure/TemplateData/flowSchema/components/upload/hook/queue/sqsTemplate.ejs +0 -43
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/getSignUrls/handler/template.ejs +0 -120
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/getSignUrls/mainFunction/template.ejs +0 -163
- 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/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/relationshipPerAction.zip +0 -0
- /package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{reservedLimit → createPresignUrl}/queue/template.ejs +0 -0
- /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
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2021 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
|
|
20
|
+
const izara = require("@izara_project/izara-middleware");
|
|
21
|
+
const middleware = izara.middlewareHandler;
|
|
22
|
+
// const AWS = require('aws-sdk');
|
|
23
|
+
// const api = new AWS.ApiGatewayManagementApi({ endpoint: process.env.iz_webSocketEndpoint });
|
|
24
|
+
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb')
|
|
25
|
+
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow')
|
|
26
|
+
const hash = require('object-hash')
|
|
27
|
+
// const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
|
|
28
|
+
const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
|
|
29
|
+
const { postToConnection } = require("../../libs/source/ImportDataLib");
|
|
30
|
+
const { flowSchemaOwnTopic } = require('./<%- `${functionName}_Main` %>');
|
|
31
|
+
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
32
|
+
|
|
33
|
+
event._izContext.logger.debug('Event:', event);
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
|
|
37
|
+
if (event.requestContext) {
|
|
38
|
+
const route = event.requestContext.routeKey;
|
|
39
|
+
const connectionId = event.requestContext.connectionId;
|
|
40
|
+
let correlationId = event._izContext.correlationIds.get(consts.X_CORRELATION_ID)
|
|
41
|
+
|
|
42
|
+
switch (route) {
|
|
43
|
+
case '$default':
|
|
44
|
+
console.log('Received unknown route:', route);
|
|
45
|
+
break
|
|
46
|
+
case '<%- route %>':
|
|
47
|
+
console.log("event in route webSocket", event);
|
|
48
|
+
let eventParams = JSON.parse(event.body)
|
|
49
|
+
|
|
50
|
+
await dynamodbSharedLib.putItem(
|
|
51
|
+
event._izContext,
|
|
52
|
+
await dynamodbSharedLib.tableName(event._izContext, "WebSocketTask"),
|
|
53
|
+
{
|
|
54
|
+
taskKey: correlationId,
|
|
55
|
+
connectionId: connectionId,
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
|
|
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
|
+
|
|
68
|
+
break
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
const connId = event.connId;
|
|
72
|
+
// await postMessage({ message: event.message }, connId);
|
|
73
|
+
await postToConnection({ message: event.message }, connId);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return (izara.response.webSocketSuccess());
|
|
77
|
+
|
|
78
|
+
} catch (err) {
|
|
79
|
+
const connId = event.requestContext.connectionId
|
|
80
|
+
event._izContext.logger.error('Error, WebSocket: ', err);
|
|
81
|
+
// await sendErrorMessage({ message: err.message }, connId);
|
|
82
|
+
await postToConnection({ message: err.message }, connId);
|
|
83
|
+
return (izara.response.failure(err));
|
|
84
|
+
}
|
|
85
|
+
});
|
|
@@ -17,13 +17,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
17
17
|
|
|
18
18
|
'use strict';
|
|
19
19
|
const path = require('path');
|
|
20
|
-
const { HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
21
|
-
const { createHookFunction } = require('../../../../../../SourceManager/src/Utils')
|
|
22
|
-
const { FLOW_SCHEMA_HOOK_STATE } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
23
20
|
const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
|
|
24
|
-
const {
|
|
25
|
-
|
|
26
|
-
|
|
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
|
+
|
|
27
37
|
/**
|
|
28
38
|
* receive objectSchema
|
|
29
39
|
* create data for WebScoket handler template
|
|
@@ -32,12 +42,22 @@ const syncTemplatePath = path.join(__dirname, "templateSyncHandler.ejs")
|
|
|
32
42
|
* @return {{templatePath, templateData,setting}}
|
|
33
43
|
*/
|
|
34
44
|
|
|
45
|
+
|
|
35
46
|
function data(_izContext, flowSchema, srcPath) {
|
|
36
|
-
return [
|
|
47
|
+
return [createParamsForCreateSource(_izContext, flowSchema, srcPath)]
|
|
37
48
|
}
|
|
38
49
|
|
|
39
|
-
function
|
|
40
|
-
|
|
50
|
+
function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
51
|
+
let functionName = upperCase(FUNCTION_NAME.flowSchemaOwnTopicComplete)
|
|
52
|
+
return {
|
|
53
|
+
templatePath: templatePath,
|
|
54
|
+
templateData: {},
|
|
55
|
+
setting: {
|
|
56
|
+
savePath: path.join(srcPath, SOURCE_PATH.flowSchemaOwnTopic, flowSchema.flowTag, "source/"),
|
|
57
|
+
saveFileName: `${functionName}_Main`,
|
|
58
|
+
fileExtension: ".js",
|
|
59
|
+
isAppend: false
|
|
60
|
+
}
|
|
61
|
+
}
|
|
41
62
|
}
|
|
42
|
-
|
|
43
63
|
module.exports = data
|
|
@@ -0,0 +1,105 @@
|
|
|
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.createNodeComplete), {}
|
|
89
|
+
)
|
|
90
|
+
)
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
// send message to ImportBatchCreateHdrSqs
|
|
94
|
+
let sendMessageToCreateEndpoint = {
|
|
95
|
+
Message: JSON.stringify(messageObject),
|
|
96
|
+
TopicArn: await snsSharedLib.snsTopicArn(_izContext, `flowSchema.flowSteps`)
|
|
97
|
+
}
|
|
98
|
+
_izContext.logger.debug("sendMessageToCreateEndpoint", sendMessageToCreateEndpoint);
|
|
99
|
+
await sns.publishAsync(_izContext, sendMessageToCreateEndpoint);
|
|
100
|
+
|
|
101
|
+
} catch (err) {
|
|
102
|
+
_izContext.logger.error('error WebSocketInvoke: ', err)
|
|
103
|
+
throw (err)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -32,7 +32,8 @@ const createWebSocketDynamoDb = require('./components/websocket/dynamoDb/WebSock
|
|
|
32
32
|
const createReservedDataMainTable = require('./components/websocket/dynamoDb/ReservedTableData');
|
|
33
33
|
const createBucketS3 = require('./components/upload/relate/S3/data');
|
|
34
34
|
const createWebSocketGenerateCodeLibs = require('./components/upload/relate/libs/data');
|
|
35
|
-
|
|
35
|
+
const createWebSocketConnectYaml = require('./components/websocket/connect/functionYaml/data')
|
|
36
|
+
const createWebSocketConnectHandler = require('./components/websocket/connect/handler/data')
|
|
36
37
|
// CreateObject components
|
|
37
38
|
const createFunctionYamlCreateObjectWebSocket = require('./components/upload/createObject/functionYaml/data');
|
|
38
39
|
const createHandlerCreateObjectWebSocket = require('./components/upload/createObject/handler/data');
|
|
@@ -45,16 +46,16 @@ const createWebSocketCreateObjectCompleteHandler = require('./components/upload/
|
|
|
45
46
|
const createWebSocketCreateObjectCompleteMainFunction = require('./components/upload/createObjectComplete/mainFunction/data');
|
|
46
47
|
|
|
47
48
|
// PreSign URL components
|
|
48
|
-
const createGetPreSignUrlFunctionYaml = require('./components/upload/preSignUrl/getSignUrls/functionYaml/data');
|
|
49
|
-
const createGetPreSignUrlHandler = require('./components/upload/preSignUrl/getSignUrls/handler/data');
|
|
50
|
-
const createGetPreSignUrlMainFunction = require('./components/upload/preSignUrl/getSignUrls/mainFunction/data');
|
|
51
|
-
const createGetPreSignUrlQueueName = require('./components/upload/preSignUrl/getSignUrls/sqs/data');
|
|
52
|
-
|
|
53
|
-
// Reserved limit components
|
|
54
49
|
const createReservedLimitFunctionYaml = require('./components/upload/preSignUrl/reservedLimit/functionYaml/data');
|
|
55
|
-
const
|
|
50
|
+
const createReservedLimitlHandler = require('./components/upload/preSignUrl/reservedLimit/handler/data');
|
|
56
51
|
const createReservedLimitMainFunction = require('./components/upload/preSignUrl/reservedLimit/mainFunction/data');
|
|
57
|
-
const createReservedLimitQueueName = require('./components/upload/preSignUrl/reservedLimit/
|
|
52
|
+
const createReservedLimitQueueName = require('./components/upload/preSignUrl/reservedLimit/sqs/data');
|
|
53
|
+
|
|
54
|
+
// Reserved limit components
|
|
55
|
+
const createPresignUrlFunctionYaml = require('./components/upload/preSignUrl/createPresignUrl/functionYaml/data');
|
|
56
|
+
const createPresignUrlHandler = require('./components/upload/preSignUrl/createPresignUrl/handler/data');
|
|
57
|
+
const createPresignUrlMainFunction = require('./components/upload/preSignUrl/createPresignUrl/mainFunction/data');
|
|
58
|
+
const createPresignUrlQueueName = require('./components/upload/preSignUrl/createPresignUrl/queue/data');
|
|
58
59
|
|
|
59
60
|
// Process uploaded file components
|
|
60
61
|
const createProcessAfterUploadS3FunctionYmlS3 = require('./components/upload/processFile/functionYml/HdrS3/data');
|
|
@@ -68,6 +69,16 @@ const createConfirmAfterUploadS3Handler = require('./components/upload/confirmRe
|
|
|
68
69
|
const createConfirmAfterUploadS3MainFunction = require('./components/upload/confirmReserved/mainFunction/data');
|
|
69
70
|
const createConfirmAfterUploadS3Queue = require('./components/upload/confirmReserved/queue/data');
|
|
70
71
|
|
|
72
|
+
// flowSchema OwnTopic component
|
|
73
|
+
const createFlowSchemaOwnTopicFunctionYaml = require('./flowSchemaOwnTopic/flowSchema/functionYaml/data');
|
|
74
|
+
const createFlowSchemaOwnTopicHandler = require('./flowSchemaOwnTopic/flowSchema/handler/data');
|
|
75
|
+
const createFlowSchemaOwnTopicMainFunction = require('./flowSchemaOwnTopic/flowSchema/mainFunction/data');
|
|
76
|
+
|
|
77
|
+
// flowSchema OwnTopicComplete component
|
|
78
|
+
const createFlowSchemaOwnTopicCompleteFunctionYaml = require("./flowSchemaOwnTopic/flowSchemaComplete/functionYaml/data")
|
|
79
|
+
const createFlowSchemaOwnTopicCompleteHandler = require("./flowSchemaOwnTopic/flowSchemaComplete/handler/data")
|
|
80
|
+
const createFlowSchemaOwnTopicCompleteMainFunction = require("./flowSchemaOwnTopic/flowSchemaComplete/mainFunction/data")
|
|
81
|
+
|
|
71
82
|
/**
|
|
72
83
|
* Generates code with templates for different actions
|
|
73
84
|
* @param {Object} _izContext - Context object
|
|
@@ -82,12 +93,10 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
82
93
|
|
|
83
94
|
// default webSocket setting
|
|
84
95
|
const webSocketTaskTable = createWebSocketDynamoDb(_izContext, saveFilePath);
|
|
85
|
-
|
|
86
|
-
|
|
96
|
+
const webSocketConnectYaml = createWebSocketConnectYaml(_izContext, saveFilePath);
|
|
97
|
+
const webSocketConnectHandler = createWebSocketConnectHandler(_izContext, saveFilePath);
|
|
87
98
|
|
|
88
|
-
const webSocketResource = [...webSocketTaskTable
|
|
89
|
-
// ...webSocketConnectYaml, ...webSocketConnectHandler,
|
|
90
|
-
]
|
|
99
|
+
const webSocketResource = [...webSocketTaskTable, ...webSocketConnectYaml, ...webSocketConnectHandler]
|
|
91
100
|
if (allLocalFlowSchemas.records.length) {
|
|
92
101
|
createSourceParams.push(
|
|
93
102
|
...webSocketResource
|
|
@@ -95,42 +104,41 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
95
104
|
}
|
|
96
105
|
|
|
97
106
|
for (const flowSchema of allLocalFlowSchemas.records) {
|
|
98
|
-
|
|
107
|
+
|
|
99
108
|
const reservedDataTable = createReservedDataMainTable(_izContext, saveFilePath);
|
|
100
109
|
const bucketS3 = createBucketS3(_izContext, flowSchema, saveFilePath)
|
|
101
110
|
|
|
102
|
-
|
|
103
111
|
const functionYamlCreateObjectWebSocket = createFunctionYamlCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
|
|
104
112
|
const handlerCreateObjectWebSocket = createHandlerCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
|
|
105
113
|
const mainFunctionCreateObjectWebSocket = await createMainFunctionCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
|
|
106
|
-
const webSocketCreateObjectCompleteFunctionYaml = createWebSocketCreateObjectCompleteFunctionYaml(_izContext, saveFilePath);
|
|
114
|
+
const webSocketCreateObjectCompleteFunctionYaml = createWebSocketCreateObjectCompleteFunctionYaml(_izContext, flowSchema, saveFilePath);
|
|
107
115
|
const webSocketCreateObjectCompleteQueue = createWebSocketCreateObjectCompleteQueue(_izContext, saveFilePath);
|
|
108
|
-
const webSocketCreateObjectCompleteMainFunction = createWebSocketCreateObjectCompleteMainFunction(_izContext, saveFilePath)
|
|
109
|
-
const webSocketCreateObjectCompleteHandler = createWebSocketCreateObjectCompleteHandler(_izContext, saveFilePath);
|
|
116
|
+
const webSocketCreateObjectCompleteMainFunction = createWebSocketCreateObjectCompleteMainFunction(_izContext, flowSchema, saveFilePath)
|
|
117
|
+
const webSocketCreateObjectCompleteHandler = createWebSocketCreateObjectCompleteHandler(_izContext, flowSchema, saveFilePath);
|
|
110
118
|
|
|
111
119
|
// const webSocketCreateObjectStordCache = createWebSocketCreateObjectStoredCache(_izContext, saveFilePath);
|
|
112
120
|
const webSocketGenerateCodeLibs = createWebSocketGenerateCodeLibs(_izContext, saveFilePath)
|
|
113
121
|
|
|
114
|
-
const getPreSignUrlFunctionYaml =
|
|
115
|
-
const getPreSignUrlHandler =
|
|
116
|
-
const getPreSignUrlMainFunction =
|
|
117
|
-
const getPreSignUrlQueue =
|
|
122
|
+
const getPreSignUrlFunctionYaml = createReservedLimitFunctionYaml(_izContext, flowSchema, saveFilePath);
|
|
123
|
+
const getPreSignUrlHandler = createReservedLimitlHandler(_izContext, flowSchema, saveFilePath);
|
|
124
|
+
const getPreSignUrlMainFunction = createReservedLimitMainFunction(_izContext, flowSchema, saveFilePath);
|
|
125
|
+
const getPreSignUrlQueue = createReservedLimitQueueName(_izContext, saveFilePath);
|
|
118
126
|
|
|
119
|
-
const reservedLimitCompleteFunctionYaml =
|
|
120
|
-
const reservedLimitCompleteMainFunction =
|
|
121
|
-
const reservedLimitCompleteHandler =
|
|
122
|
-
const reservedLimitCompleteQueue =
|
|
127
|
+
const reservedLimitCompleteFunctionYaml = createPresignUrlFunctionYaml(_izContext, flowSchema, saveFilePath);
|
|
128
|
+
const reservedLimitCompleteMainFunction = createPresignUrlMainFunction(_izContext, flowSchema, saveFilePath);
|
|
129
|
+
const reservedLimitCompleteHandler = createPresignUrlHandler(_izContext, flowSchema, saveFilePath);
|
|
130
|
+
const reservedLimitCompleteQueue = createPresignUrlQueueName(_izContext, saveFilePath);
|
|
123
131
|
|
|
124
132
|
const processAfterUploadFunctionYmlS3 = createProcessAfterUploadS3FunctionYmlS3(_izContext, flowSchema, saveFilePath);
|
|
125
133
|
// const processAfterUploadFunctionYamlHdrDsq = createProcessAfterUploadS3FunctionYmlDsq(_izContext, saveFilePath);
|
|
126
134
|
const processAfterUploadSqs = createProcessAfterUploadS3Queue(_izContext, saveFilePath);
|
|
127
|
-
const processAfterUploadHandlerS3 = createProcessAfterUploadS3HandlerS3(_izContext, saveFilePath);
|
|
135
|
+
const processAfterUploadHandlerS3 = createProcessAfterUploadS3HandlerS3(_izContext, flowSchema, saveFilePath);
|
|
128
136
|
// const processAfterUploadHandlerDsq = createProcessAfterUploadS3HandlerDsq(_izContext, saveFilePath);
|
|
129
|
-
const processAfterUploadMainFunction = createProcessAfterUploadS3MainFunction(_izContext, saveFilePath);
|
|
137
|
+
const processAfterUploadMainFunction = createProcessAfterUploadS3MainFunction(_izContext, flowSchema, saveFilePath);
|
|
130
138
|
|
|
131
|
-
const confirmReservedAfterUploadFunctionYaml = createConfirmAfterUploadS3FunctionYaml(_izContext, saveFilePath);
|
|
132
|
-
const confirmReservedAfterUploadHandler = createConfirmAfterUploadS3Handler(_izContext, saveFilePath);
|
|
133
|
-
const confirmReservedAfterUploadMainFunction = createConfirmAfterUploadS3MainFunction(_izContext, saveFilePath);
|
|
139
|
+
const confirmReservedAfterUploadFunctionYaml = createConfirmAfterUploadS3FunctionYaml(_izContext, flowSchema, saveFilePath);
|
|
140
|
+
const confirmReservedAfterUploadHandler = createConfirmAfterUploadS3Handler(_izContext, flowSchema, saveFilePath);
|
|
141
|
+
const confirmReservedAfterUploadMainFunction = createConfirmAfterUploadS3MainFunction(_izContext, flowSchema, saveFilePath);
|
|
134
142
|
const confirmReservedAfterUploadQueue = createConfirmAfterUploadS3Queue(_izContext, saveFilePath);
|
|
135
143
|
|
|
136
144
|
// Group related resources for better organization
|
|
@@ -175,34 +183,49 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
175
183
|
...confirmReservedAfterUploadQueue
|
|
176
184
|
];
|
|
177
185
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
];
|
|
185
|
-
|
|
186
|
-
// Add all resources to the parameters array
|
|
187
|
-
createSourceParams.push(
|
|
188
|
-
...webSocketUploadS3Resources,
|
|
189
|
-
...getPreSignUrlResources,
|
|
190
|
-
...reservedLimitResources,
|
|
191
|
-
...bucketS3,
|
|
192
|
-
...processAfterUploadResources,
|
|
193
|
-
...confirmAfterUploadResources
|
|
194
|
-
);
|
|
195
|
-
}
|
|
186
|
+
// Group all resources related to S3 upload functionality
|
|
187
|
+
const webSocketUploadS3Resources = [
|
|
188
|
+
...webSocketFunctions,
|
|
189
|
+
...webSocketGenerateCodeLibs,
|
|
190
|
+
...reservedDataTable
|
|
191
|
+
];
|
|
196
192
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
193
|
+
const flowSchemaOwnTopicFunctionYaml = createFlowSchemaOwnTopicFunctionYaml(_izContext, flowSchema, saveFilePath);
|
|
194
|
+
const flowSchemaOwnTopicHandler = createFlowSchemaOwnTopicHandler(_izContext, flowSchema, saveFilePath);
|
|
195
|
+
const flowSchemaOwnTopicMainFunction = createFlowSchemaOwnTopicMainFunction(_izContext, flowSchema, saveFilePath);
|
|
196
|
+
|
|
197
|
+
const flowSchemaOwnTopicComponent = [...flowSchemaOwnTopicFunctionYaml, ...flowSchemaOwnTopicHandler, ...flowSchemaOwnTopicMainFunction];
|
|
198
|
+
|
|
199
|
+
const flowSchemaOwnTopicCompleteFunctionYaml = createFlowSchemaOwnTopicCompleteFunctionYaml(_izContext, flowSchema, saveFilePath);
|
|
200
|
+
const flowSchemaOwnTopicCompleteHandler = createFlowSchemaOwnTopicCompleteHandler(_izContext, flowSchema, saveFilePath);
|
|
201
|
+
const flowSchemaOwnTopicCompleteMainFunction = createFlowSchemaOwnTopicCompleteMainFunction(_izContext, flowSchema, saveFilePath);
|
|
202
|
+
|
|
203
|
+
const flowSchemaOwnTopicCompleteComponent = [...flowSchemaOwnTopicCompleteFunctionYaml, ...flowSchemaOwnTopicCompleteHandler, ...flowSchemaOwnTopicCompleteMainFunction]
|
|
204
|
+
for (const event of flowSchema.event) {
|
|
205
|
+
if (event.includes("s3")) {
|
|
206
|
+
// Add all resources to the parameters array
|
|
207
|
+
createSourceParams.push(
|
|
208
|
+
...webSocketUploadS3Resources,
|
|
209
|
+
...getPreSignUrlResources,
|
|
210
|
+
...reservedLimitResources,
|
|
211
|
+
...bucketS3,
|
|
212
|
+
...processAfterUploadResources,
|
|
213
|
+
...confirmAfterUploadResources
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (event.includes("ownTopic")) {
|
|
218
|
+
createSourceParams.push(
|
|
219
|
+
...flowSchemaOwnTopicComponent,
|
|
220
|
+
...flowSchemaOwnTopicCompleteComponent
|
|
221
|
+
)
|
|
222
|
+
}
|
|
200
223
|
}
|
|
201
224
|
}
|
|
202
|
-
|
|
225
|
+
console.log("createSourceParams in flowSchemas", createSourceParams)
|
|
203
226
|
return createSourceParams;
|
|
204
227
|
} catch (error) {
|
|
205
|
-
_izContext.logger.error('Error generating code with template
|
|
228
|
+
_izContext.logger.error('Error generating code with template flowSchema:', error);
|
|
206
229
|
return [];
|
|
207
230
|
}
|
|
208
231
|
}
|
|
@@ -14,7 +14,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
14
14
|
|
|
15
15
|
'use strict';
|
|
16
16
|
|
|
17
|
-
const { SOURCE_GENERATE_IAM_ROLE, SOURCE_PATH, SAVE_FILE_NAME } = require('../../../MainLibs/
|
|
17
|
+
const { SOURCE_GENERATE_IAM_ROLE, SOURCE_PATH, SAVE_FILE_NAME } = require('../../../MainLibs/src/Consts');
|
|
18
18
|
const { firstLetterUpperCase: upperCase } = require("../../../MainLibs/index").utils;
|
|
19
19
|
const path = require('path');
|
|
20
20
|
|
|
@@ -106,6 +106,14 @@ const createSharedResource = (_izContext, createSourceParams, srcPath) => {
|
|
|
106
106
|
handlerType: [],
|
|
107
107
|
resources: {}
|
|
108
108
|
},
|
|
109
|
+
[SOURCE_GENERATE_IAM_ROLE.perActionEndpoint]: {
|
|
110
|
+
handlerType: [],
|
|
111
|
+
resources: {}
|
|
112
|
+
},
|
|
113
|
+
[SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic]: {
|
|
114
|
+
handlerType: [],
|
|
115
|
+
resources: {}
|
|
116
|
+
},
|
|
109
117
|
Other: []
|
|
110
118
|
};
|
|
111
119
|
const objectTypeList = [];
|
|
@@ -187,6 +195,18 @@ const createSharedResource = (_izContext, createSourceParams, srcPath) => {
|
|
|
187
195
|
templateData.additionalResourcePermission,
|
|
188
196
|
groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.FlowSchemaUploadS3Role].resources
|
|
189
197
|
)
|
|
198
|
+
} else if (templateData.roleName.includes(SOURCE_GENERATE_IAM_ROLE.perActionEndpoint)) {
|
|
199
|
+
groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.perActionEndpoint].handlerType.push(templateData);
|
|
200
|
+
processResourcePermissions(
|
|
201
|
+
templateData.additionalResourcePermission,
|
|
202
|
+
groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.perActionEndpoint].resources
|
|
203
|
+
)
|
|
204
|
+
} else if (templateData.roleName.includes(SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic)) {
|
|
205
|
+
groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic].handlerType.push(templateData);
|
|
206
|
+
processResourcePermissions(
|
|
207
|
+
templateData.additionalResourcePermission,
|
|
208
|
+
groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic].resources
|
|
209
|
+
)
|
|
190
210
|
}
|
|
191
211
|
else {
|
|
192
212
|
// Handle other items
|
|
@@ -113,50 +113,41 @@ module.exports.createObjectComplete = async (
|
|
|
113
113
|
);
|
|
114
114
|
_izContext.logger.debug("record awaitingSteps::", recordAwaitingSteps);
|
|
115
115
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
let sendMessageOutCreateObjectComplete = {
|
|
153
|
-
Message: JSON.stringify(messageObject),
|
|
154
|
-
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
155
|
-
TopicArn: await snsSharedLib.snsTopicArn(_izContext, "OutCreateObjectComplete")
|
|
156
|
-
};
|
|
157
|
-
_izContext.logger.debug("Send message to OutCreateObjectComplete :::>", sendMessageOutCreateObjectComplete)
|
|
158
|
-
await sns.publishAsync(_izContext, sendMessageOutCreateObjectComplete);
|
|
159
|
-
|
|
116
|
+
await Promise.all(
|
|
117
|
+
recordAwaitingSteps.Items.map(async ({ pendingStepId }) => {
|
|
118
|
+
if (await asyncFlowSharedLib.checkAllAwaitingStepsFinished(
|
|
119
|
+
_izContext,
|
|
120
|
+
pendingStepId,
|
|
121
|
+
awaitingStepId
|
|
122
|
+
)) {
|
|
123
|
+
_izContext.logger.debug("finish all awaitingStep");
|
|
124
|
+
|
|
125
|
+
let messageObject = {
|
|
126
|
+
objType: {
|
|
127
|
+
objectType: returnValue.objType.objectType,
|
|
128
|
+
serviceTag: returnValue.objType.serviceTag
|
|
129
|
+
},
|
|
130
|
+
objInstanceFull: {
|
|
131
|
+
identifiers: returnValue.objInstanceFull.identifiers,
|
|
132
|
+
fields: returnValue.objInstanceFull.fields
|
|
133
|
+
},
|
|
134
|
+
status: status,
|
|
135
|
+
errorsFound: errorsFound
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
messageObject = callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(passBackProperties, messageObject)
|
|
139
|
+
let messageAttributes = callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(passBackProperties, {})
|
|
140
|
+
|
|
141
|
+
let sendMessageOutCreateObjectComplete = {
|
|
142
|
+
Message: JSON.stringify(messageObject),
|
|
143
|
+
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
144
|
+
TopicArn: await snsSharedLib.snsTopicArn(_izContext, "OutCreateObjectComplete")
|
|
145
|
+
};
|
|
146
|
+
_izContext.logger.debug("Send message to OutCreateObjectComplete :::>", sendMessageOutCreateObjectComplete)
|
|
147
|
+
await sns.publishAsync(_izContext, sendMessageOutCreateObjectComplete);
|
|
148
|
+
}
|
|
149
|
+
})
|
|
150
|
+
)
|
|
160
151
|
return {
|
|
161
152
|
returnValue: returnValue,
|
|
162
153
|
status: status,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Type: AWS::SNS::Topic
|
|
4
4
|
Properties:
|
|
5
5
|
DisplayName: "SNS Message out"
|
|
6
|
-
TopicName: ${self:custom.
|
|
6
|
+
TopicName: ${self:custom.iz_serviceTag}_${self:custom.iz_stage}_<%- firstLetterUpperCase(queueName) %>_Out
|
|
7
7
|
|
|
8
8
|
<%_ function firstLetterUpperCase(text) {
|
|
9
9
|
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
@@ -45,7 +45,7 @@ const { getGraphServiceNameFromGraphServerTagWithCache, getServiceNameWithCache
|
|
|
45
45
|
const {
|
|
46
46
|
firstLetterLowerCase: lowerCase,
|
|
47
47
|
firstLetterUpperCase: upperCase
|
|
48
|
-
} = require("../../../../../MainLibs/
|
|
48
|
+
} = require("../../../../../MainLibs/src/Utils.js");
|
|
49
49
|
const {
|
|
50
50
|
DEFAULT_HANDLER_PER_ACTION,
|
|
51
51
|
createIamRole,
|
|
@@ -65,7 +65,7 @@ const {
|
|
|
65
65
|
awaitingMultipleStepsRole,
|
|
66
66
|
SHORT_FUNCTION_NAME,
|
|
67
67
|
SOURCE_GENERATE_IAM_ROLE
|
|
68
|
-
} = require("../../../../../MainLibs/
|
|
68
|
+
} = require("../../../../../MainLibs/src/Consts.js");
|
|
69
69
|
|
|
70
70
|
const templatePath = path.join(__dirname, './template.ejs');
|
|
71
71
|
|
|
@@ -98,8 +98,8 @@ function createFunctionYamlOutUpdateComplete(_izContext, srcPath) {
|
|
|
98
98
|
[
|
|
99
99
|
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName)),
|
|
100
100
|
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + "DLQ"),
|
|
101
|
-
resourceNames(RESOURCE_CLASSES.sns,
|
|
102
|
-
resourceNames(RESOURCE_CLASSES.sns,
|
|
101
|
+
resourceNames(RESOURCE_CLASSES.sns, upperCase(functionName) + "_In"),
|
|
102
|
+
resourceNames(RESOURCE_CLASSES.sns, upperCase(functionName) + "_Out")
|
|
103
103
|
]
|
|
104
104
|
)
|
|
105
105
|
)
|
|
@@ -123,7 +123,6 @@ function createFunctionYamlOutUpdateComplete(_izContext, srcPath) {
|
|
|
123
123
|
fileExtension: '.yml',
|
|
124
124
|
isAppend: true
|
|
125
125
|
}
|
|
126
|
-
|
|
127
126
|
}
|
|
128
127
|
}
|
|
129
128
|
|