@izara_project/izara-market-library-service-schemas 1.0.37 → 1.0.39
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/GenerateCodeLibs.js +35 -5
- package/src/MainLibs/src/Consts.js +5 -2
- package/src/MainLibs/src/GenerateCodeUtils.js +2 -0
- package/src/MainLibs/src/Utils.js +12 -0
- package/src/reStructure/GenerateCode.js +2 -2
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +36 -11
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +24 -1
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +26 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +22 -0
- package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +37 -7
- package/src/reStructure/TemplateData/findData/handler/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +2 -0
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +5 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/sns-sqs/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/sqs/data.js +3 -3
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/sqs/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/externalTopic/functionYaml/data.js +127 -0
- package/src/reStructure/TemplateData/flowSchema/externalTopic/handler/data.js +121 -0
- package/src/reStructure/TemplateData/flowSchema/externalTopic/{sqs/handler → handler}/template.ejs +16 -61
- package/src/reStructure/TemplateData/flowSchema/externalTopic/mainFunction/data.js +74 -0
- package/src/reStructure/TemplateData/flowSchema/externalTopic/mainFunction/template.ejs +131 -0
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +61 -34
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +3 -7
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +2 -5
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +13 -4
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +16 -37
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +2 -4
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +2 -5
- package/src/reStructure/TemplateData/flowSchema/{externalTopic/sqs → flowSchemaOwnTopic/flowStep}/functionYaml/data.js +43 -38
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/functionYaml/template.ejs +20 -0
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/handler/data.js +80 -0
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/handler/template.ejs +85 -0
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/mainFunction/data.js +92 -0
- package/src/reStructure/TemplateData/flowSchema/{externalTopic/websocket → flowSchemaOwnTopic/flowStep}/mainFunction/template.ejs +11 -13
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +47 -37
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +23 -26
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/functionYaml/data.js +5 -21
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/webSocketComplete/functionYaml/template.ejs +20 -0
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/handler/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/mainFunction/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/mainFunction/template.ejs +24 -10
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +32 -34
- package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/register/complete/mainFunction/template.ejs +172 -0
- package/src/reStructure/TemplateData/flowSchema/register/wbs/mainFunction/template.ejs +165 -0
- package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → templateBystatusType}/statusFieldTemplate.ejs +0 -5
- package/src/reStructure/TemplateData/flowSchema/templateBystatusType/storedCacheTemplate.ejs +24 -0
- package/src/reStructure/TemplateData/flowSchema/templateBystatusType/triggerCacheTemplate.ejs +20 -0
- package/src/reStructure/TemplateData/perActionComplete/get/mainFunction/template.ejs +3 -0
- package/src/reStructure/TemplateData/perActionComplete/update/mainFunction/template.ejs +3 -0
- package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js +2 -7
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/api/data.js +22 -3
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/dsq/data.js +14 -9
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/inv/data.js +26 -6
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/sqs/data.js +11 -7
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/functionYaml/data.js +17 -7
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/api/data.js +23 -4
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/dsq/data.js +14 -9
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/inv/data.js +26 -6
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/sqs/data.js +10 -7
- package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/functionYaml/data.js +11 -7
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/api/data.js +23 -4
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/data.js +14 -9
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/inv/data.js +26 -7
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/sqs/data.js +10 -7
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/data.js +12 -7
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/api/data.js +22 -3
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/dsq/data.js +14 -6
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/inv/data.js +20 -3
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/sqs/data.js +9 -3
- package/src/reStructure/TemplateData/relationshipPerAction/update/complete/functionYaml/data.js +12 -6
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +6 -2
- package/src/reStructure/TemplateData/resourceYaml/filterGenerateResource/data.js +20 -11
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/template.ejs +0 -184
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs +0 -11
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/template.ejs +0 -210
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/data.js +0 -77
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/template.ejs +0 -8
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/template.ejs +0 -17
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/data.js +0 -64
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/data.js +0 -61
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/template.ejs +0 -74
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/data.js +0 -110
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/template.ejs +0 -18
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/data.js +0 -57
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/template.ejs +0 -85
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/data.js +0 -67
- /package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/FlowSchemaCompleteComponent → externalTopic}/functionYaml/template.ejs +0 -0
- /package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/handler/template.ejs +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/functionYaml/data.js +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/functionYaml/template.ejs +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/handler/data.js +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/mainFunction/data.js +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/dynamoDB/register.js +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/sns-in/data.js +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/sns-in/template.ejs +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/subscriptionOutAll/data.js +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/subscriptionOutAll/template.ejs +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/functionYaml/data.js +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/functionYaml/template.ejs +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/handler/data.js +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/handler/template.ejs +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/mainFunction/data.js +0 -0
|
@@ -19,25 +19,24 @@ along with this program. If not, see
|
|
|
19
19
|
'use strict';
|
|
20
20
|
|
|
21
21
|
const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
22
|
-
const
|
|
22
|
+
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
|
|
23
23
|
|
|
24
24
|
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
|
|
25
25
|
const snsSharedLib = require('@izara_project/izara-core-library-sns');
|
|
26
26
|
const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
|
|
27
27
|
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
28
28
|
const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
|
|
29
|
-
|
|
29
|
+
const storedCacheSharedLib = require('@izara_project/izara-core-library-stored-cache')
|
|
30
30
|
const externalRequest = require('@izara_project/izara-core-library-external-request');
|
|
31
31
|
const sns = externalRequest.sns
|
|
32
32
|
|
|
33
33
|
const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
|
|
34
34
|
const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
|
|
35
|
-
const { v4: uuidv4 } = require('uuid')
|
|
36
35
|
const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
|
|
37
36
|
const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
const { postToConnection } = require('../../../libs/source/GenerateCodeLibs')
|
|
38
|
+
//(<optionalRequire>)
|
|
39
|
+
//(</optionalRequire>)
|
|
41
40
|
/**
|
|
42
41
|
*
|
|
43
42
|
*
|
|
@@ -53,7 +52,7 @@ const { createFieldNamesFromRequestParamsByObjectSchema } = require('@izara_proj
|
|
|
53
52
|
* @returns {object} description of return value
|
|
54
53
|
*/
|
|
55
54
|
|
|
56
|
-
module.exports.<%-
|
|
55
|
+
module.exports.<%- functionName %> = async (
|
|
57
56
|
_izContext,
|
|
58
57
|
requestParams,
|
|
59
58
|
callingFlowConfig = {},
|
|
@@ -62,13 +61,12 @@ module.exports.<%- externalTopicMain %> = async (
|
|
|
62
61
|
) => {
|
|
63
62
|
|
|
64
63
|
try {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
_izContext.logger.debug("sendMessageToCreateEndpoint", sendMessageToCreateEndpoint);
|
|
70
|
-
await sns.publishAsync(_izContext, sendMessageToCreateEndpoint);
|
|
64
|
+
_izContext.logger.debug("<%- functionName %> _izContext", _izContext)
|
|
65
|
+
_izContext.logger.debug("<%- functionName %> requestParams", requestParams)
|
|
66
|
+
_izContext.logger.debug("<%- functionName %> callingFlowConfig", callingFlowConfig)
|
|
71
67
|
|
|
68
|
+
//(<hookCode>)
|
|
69
|
+
//(</hookCode>)
|
|
72
70
|
|
|
73
71
|
} catch (err) {
|
|
74
72
|
_izContext.logger.error('error WebSocketInvoke: ', err)
|
|
@@ -32,7 +32,8 @@ const STORAGE_TYPES = {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const snsTemplatePath = path.join(__dirname, '../../../resourceYaml/sns-in-sqs/snsTemplate.ejs');
|
|
35
|
-
const
|
|
35
|
+
const subscriptionSqsTemplatePath = path.join(__dirname, './sqsTemplate.ejs');
|
|
36
|
+
|
|
36
37
|
const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, HANDLER } = require('../../../../../MainLibs/src/Consts.js');
|
|
37
38
|
|
|
38
39
|
/**
|
|
@@ -47,7 +48,8 @@ const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, HANDLER } = require('../../.
|
|
|
47
48
|
|
|
48
49
|
function createDataForDefaultSnsInSqs(_izContext, flowSchema, srcPath) {
|
|
49
50
|
let resultsForCreateDefaultSnsInSqs = [];
|
|
50
|
-
|
|
51
|
+
let flowSteps = Object.keys(flowSchema.flowSteps);
|
|
52
|
+
// console.log("create topic by flowSteps", flowSteps)
|
|
51
53
|
const setting = {
|
|
52
54
|
initialData: "Resources:\n",
|
|
53
55
|
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
@@ -56,29 +58,44 @@ function createDataForDefaultSnsInSqs(_izContext, flowSchema, srcPath) {
|
|
|
56
58
|
isAppend: true
|
|
57
59
|
}
|
|
58
60
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
let flowStepOut = flowSteps[1];
|
|
69
|
-
splitFlowStepsOut = flowStepOut.split("_")
|
|
70
|
-
topicOut = splitFlowStepsOut[2]
|
|
71
|
-
} else {
|
|
72
|
-
splitFlowStepsOut = null
|
|
73
|
-
topicOut = null
|
|
61
|
+
let topicIn = `${upperCase(flowSchema.flowTag)}`;
|
|
62
|
+
|
|
63
|
+
const generatedSnsTopicInForFlowSchema = [];
|
|
64
|
+
if (flowSteps.includes("In")) {
|
|
65
|
+
generatedSnsTopicInForFlowSchema.push(
|
|
66
|
+
{
|
|
67
|
+
queueName: "Process" + upperCase(topicIn)
|
|
68
|
+
}
|
|
69
|
+
)
|
|
74
70
|
}
|
|
75
71
|
|
|
76
|
-
const generatedSnsTopicInForFlowSchema = [
|
|
77
|
-
{
|
|
78
|
-
queueName: upperCase(topicIn),
|
|
79
|
-
},
|
|
80
|
-
];
|
|
81
72
|
|
|
73
|
+
let defaultDsqQueueDataList = [];
|
|
74
|
+
|
|
75
|
+
if (flowSchema.outputTopic) {
|
|
76
|
+
if (flowSteps.includes("Out")) {
|
|
77
|
+
if (flowSchema.outputTopic) {
|
|
78
|
+
let topicOut = `${upperCase(flowSchema.flowTag)}`;
|
|
79
|
+
defaultDsqQueueDataList.push({
|
|
80
|
+
queueName: `WebSocketComplete` + upperCase(HANDLER.hdrSqs),
|
|
81
|
+
subscribeTo: topicOut
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (flowSteps.includes("In") && flowSteps.includes("Out")) {
|
|
89
|
+
if (flowSteps.length > 2) {
|
|
90
|
+
for (let i = 2; i < flowSteps.length; i++) {
|
|
91
|
+
generatedSnsTopicInForFlowSchema.push(
|
|
92
|
+
{
|
|
93
|
+
queueName: upperCase(flowSteps[i])
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
82
99
|
|
|
83
100
|
for (let defaultSnsInSqsData of generatedSnsTopicInForFlowSchema) {
|
|
84
101
|
resultsForCreateDefaultSnsInSqs.push({
|
|
@@ -88,23 +105,16 @@ function createDataForDefaultSnsInSqs(_izContext, flowSchema, srcPath) {
|
|
|
88
105
|
})
|
|
89
106
|
}
|
|
90
107
|
|
|
91
|
-
|
|
92
|
-
{
|
|
93
|
-
|
|
94
|
-
|
|
108
|
+
if (defaultDsqQueueDataList.length) {
|
|
109
|
+
for (let defaultDsqQueueData of defaultDsqQueueDataList) {
|
|
110
|
+
resultsForCreateDefaultSnsInSqs.push({
|
|
111
|
+
templatePath: subscriptionSqsTemplatePath,
|
|
112
|
+
templateData: defaultDsqQueueData,
|
|
113
|
+
setting: setting
|
|
114
|
+
})
|
|
95
115
|
}
|
|
96
|
-
]
|
|
97
|
-
for (let defaultDsqQueueData of defaultDsqQueueDataList) {
|
|
98
|
-
resultsForCreateDefaultSnsInSqs.push({
|
|
99
|
-
templatePath: sqsTemplatePath,
|
|
100
|
-
templateData: defaultDsqQueueData,
|
|
101
|
-
setting: setting
|
|
102
|
-
})
|
|
103
116
|
}
|
|
104
|
-
|
|
105
|
-
// resultsForCreateDefaultSnsInSqs: JSON.stringify(resultsForCreateDefaultSnsInSqs, null, 2
|
|
106
|
-
// )
|
|
107
|
-
// })
|
|
117
|
+
|
|
108
118
|
return resultsForCreateDefaultSnsInSqs;
|
|
109
119
|
}
|
|
110
120
|
|
|
@@ -47,33 +47,30 @@ const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, HANDLER } = require('../../.
|
|
|
47
47
|
function createDataForSnsOut(_izContext, flowSchema, srcPath) {
|
|
48
48
|
let resultsForCreateDefaultSnsInSqs = [];
|
|
49
49
|
|
|
50
|
-
let flowSteps = Object.keys(flowSchema.flowSteps)
|
|
51
50
|
let generatedSnsTopicOutForFlowSchema = []
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
})
|
|
51
|
+
let flowSteps = Object.keys(flowSchema.flowSteps);
|
|
52
|
+
let topicOut = `${upperCase(flowSchema.flowTag)}`
|
|
53
|
+
if (flowSteps.includes("Out")) {
|
|
54
|
+
if (flowSchema.outputTopic) {
|
|
55
|
+
generatedSnsTopicOutForFlowSchema.push(
|
|
56
|
+
{
|
|
57
|
+
queueName: upperCase(topicOut)
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
for (let defaultSnsOutData of generatedSnsTopicOutForFlowSchema) {
|
|
62
|
+
resultsForCreateDefaultSnsInSqs.push({
|
|
63
|
+
templatePath: templatePath,
|
|
64
|
+
templateData: defaultSnsOutData,
|
|
65
|
+
setting: {
|
|
66
|
+
initialData: "Resources:\n",
|
|
67
|
+
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
68
|
+
saveFileName: SAVE_FILE_NAME.snsOutYaml,
|
|
69
|
+
fileExtension: ".yml",
|
|
70
|
+
isAppend: true
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
}
|
|
77
74
|
}
|
|
78
75
|
|
|
79
76
|
return resultsForCreateDefaultSnsInSqs;
|
|
@@ -47,32 +47,17 @@ const hookTemplate = path.join(__dirname, "./hookTemplate.ejs");
|
|
|
47
47
|
* @return {{templatePath, templateData,setting}}
|
|
48
48
|
*/
|
|
49
49
|
|
|
50
|
-
function data(_izContext,
|
|
51
|
-
return [createSourceParams(_izContext,
|
|
50
|
+
function data(_izContext, srcPath) {
|
|
51
|
+
return [createSourceParams(_izContext, srcPath)]
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
function createSourceParams(_izContext,
|
|
55
|
-
let functionName =
|
|
54
|
+
function createSourceParams(_izContext, srcPath) {
|
|
55
|
+
let functionName = "WebSocketComplete"
|
|
56
56
|
let handlerType = upperCase(HANDLER.hdrSqs)
|
|
57
57
|
let additionalResourcePermission = defaultIamRolePerAction();
|
|
58
|
-
let route = flowSchema.flowTag;
|
|
59
|
-
let flowStep = Object.keys(flowSchema.flowSteps)
|
|
60
|
-
let flowStepsIn = flowStep[0];
|
|
61
|
-
let splitFlowStepsIn = flowStepsIn.split("_");
|
|
62
|
-
let topicIn = `${splitFlowStepsIn[2]}_${splitFlowStepsIn[3]}`
|
|
63
58
|
let queueName = functionName + handlerType
|
|
64
59
|
|
|
65
60
|
additionalResourcePermission.push(
|
|
66
|
-
createIamRole(
|
|
67
|
-
{
|
|
68
|
-
[RESOURCE_CLASSES.sns]: [
|
|
69
|
-
SNS_RESOURCE.publish
|
|
70
|
-
]
|
|
71
|
-
},
|
|
72
|
-
[
|
|
73
|
-
resourceNames(RESOURCE_CLASSES.sns, topicIn)
|
|
74
|
-
]
|
|
75
|
-
),
|
|
76
61
|
createIamRole(
|
|
77
62
|
{
|
|
78
63
|
[RESOURCE_CLASSES.dynamoDbTable]: [
|
|
@@ -112,11 +97,10 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
112
97
|
return {
|
|
113
98
|
templatePath: templatePath,
|
|
114
99
|
templateData: {
|
|
115
|
-
resourceLocation: path.join(SOURCE_PATH.
|
|
100
|
+
resourceLocation: path.join(SOURCE_PATH.resourceLocationWebSocketMain),
|
|
116
101
|
functionName,
|
|
117
102
|
handlerType,
|
|
118
103
|
additionalResourcePermission,
|
|
119
|
-
route,
|
|
120
104
|
functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
|
|
121
105
|
roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic,
|
|
122
106
|
queueName: queueName
|
|
@@ -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}<%- queueName %>
|
|
8
|
+
batchSize: 10
|
|
9
|
+
filterPatterns: #**** need to update serverless framwork upper v.2.69.1
|
|
10
|
+
- body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%- 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
|
+
} _%>
|
|
@@ -36,7 +36,7 @@ function data(_izContext, flowSchema, srcPath) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
39
|
-
let functionName =
|
|
39
|
+
let functionName = "WebSocketComplete"
|
|
40
40
|
let handlerType = upperCase(HANDLER.hdrSqs)
|
|
41
41
|
let queueName = upperCase(functionName) + upperCase(handlerType);
|
|
42
42
|
return {
|
|
@@ -47,7 +47,7 @@ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
|
47
47
|
queueName
|
|
48
48
|
},
|
|
49
49
|
setting: {
|
|
50
|
-
savePath: path.join(srcPath, SOURCE_PATH.
|
|
50
|
+
savePath: path.join(srcPath, SOURCE_PATH.WebSocketMain),
|
|
51
51
|
saveFileName: `${functionName}_${handlerType}`,
|
|
52
52
|
fileExtension: ".js",
|
|
53
53
|
isAppend: false
|
|
@@ -37,14 +37,14 @@ function data(_izContext, flowSchema, srcPath) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
40
|
-
let functionName =
|
|
40
|
+
let functionName = "WebSocketComplete"
|
|
41
41
|
return {
|
|
42
42
|
templatePath: templatePath,
|
|
43
43
|
templateData: {
|
|
44
44
|
functionName
|
|
45
45
|
},
|
|
46
46
|
setting: {
|
|
47
|
-
savePath: path.join(srcPath, SOURCE_PATH.
|
|
47
|
+
savePath: path.join(srcPath, SOURCE_PATH.WebSocketMain),
|
|
48
48
|
saveFileName: `${functionName}_Main`,
|
|
49
49
|
fileExtension: ".js",
|
|
50
50
|
isAppend: false
|
|
@@ -67,24 +67,38 @@ module.exports.<%- functionName %> = async (
|
|
|
67
67
|
_izContext.logger.debug("<%- functionName %> requestParams", requestParams)
|
|
68
68
|
_izContext.logger.debug("<%- functionName %> callingFlowConfig", callingFlowConfig)
|
|
69
69
|
|
|
70
|
-
let
|
|
71
|
-
let correlationId = _izContext.correlationIds.get(coreConsts.X_CORRELATION_ID);
|
|
70
|
+
let correlationId = _izContext.correlationIds.get(consts.X_CORRELATION_ID);
|
|
72
71
|
|
|
73
|
-
await postToConnection(
|
|
74
|
-
{
|
|
75
|
-
message: requestParams
|
|
76
|
-
},
|
|
77
|
-
connectionId
|
|
78
|
-
)
|
|
79
72
|
|
|
80
|
-
await dynamodbSharedLib.
|
|
73
|
+
let wbsTasks = await dynamodbSharedLib.query(
|
|
74
|
+
_izContext,
|
|
81
75
|
await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
|
|
82
76
|
{
|
|
83
77
|
taskKey: correlationId,
|
|
84
|
-
connectionId: connectionId
|
|
85
78
|
}
|
|
86
79
|
)
|
|
87
80
|
|
|
81
|
+
if (wbsTasks.Items.length) {
|
|
82
|
+
await Promise.all(wbsTasks.Items.map(async ({ connectionId }) => {
|
|
83
|
+
await postToConnection(
|
|
84
|
+
{
|
|
85
|
+
message: requestParams
|
|
86
|
+
},
|
|
87
|
+
connectionId
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
await dynamodbSharedLib.deleteItem(_izContext,
|
|
91
|
+
await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
|
|
92
|
+
{
|
|
93
|
+
taskKey: correlationId,
|
|
94
|
+
connectionId: connectionId
|
|
95
|
+
}
|
|
96
|
+
)
|
|
97
|
+
}))
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
|
|
88
102
|
} catch (err) {
|
|
89
103
|
_izContext.logger.error('error WebSocketInvoke: ', err)
|
|
90
104
|
throw (err)
|
|
@@ -71,14 +71,10 @@ const createConfirmAfterUploadS3MainFunction = require('./components/upload/conf
|
|
|
71
71
|
const createConfirmAfterUploadS3Queue = require('./components/upload/confirmReserved/queue/data');
|
|
72
72
|
|
|
73
73
|
// flowSchema ExternalTopic components //
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
const
|
|
77
|
-
const createExternalSqsFunctionYaml = require('./externalTopic/sqs/functionYaml/data');
|
|
78
|
-
const createExternalSqsHandler = require('./externalTopic/sqs/handler/data');
|
|
79
|
-
const createExternalSqsMainFunction = require('./externalTopic/sqs/mainFunction/data');
|
|
74
|
+
const createExternalSqsFunctionYaml = require('./externalTopic/functionYaml/data');
|
|
75
|
+
const createExternalSqsHandler = require('./externalTopic/handler/data');
|
|
76
|
+
const createExternalSqsMainFunction = require('./externalTopic/mainFunction/data');
|
|
80
77
|
const createExternalTopicSnsInSqs = require('./externalTopic/sns-in-sqs/data');
|
|
81
|
-
const createExternalTopicSnsOut = require('./externalTopic/sns-out/data');
|
|
82
78
|
|
|
83
79
|
// flowSchema OwnTopic component
|
|
84
80
|
const createFlowSchemaOwnTopicFunctionYaml = require('./flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data');
|
|
@@ -86,15 +82,19 @@ const createFlowSchemaOwnTopicHandler = require('./flowSchemaOwnTopic/FlowSchema
|
|
|
86
82
|
const createFlowSchemaOwnTopicMainFunction = require('./flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data');
|
|
87
83
|
|
|
88
84
|
// flowSchema OwnTopicComplete component
|
|
89
|
-
const createFlowSchemaOwnTopicCompleteFunctionYaml = require("./flowSchemaOwnTopic/
|
|
90
|
-
const createFlowSchemaOwnTopicCompleteHandler = require("./flowSchemaOwnTopic/
|
|
91
|
-
const createFlowSchemaOwnTopicCompleteMainFunction = require("./flowSchemaOwnTopic/
|
|
85
|
+
const createFlowSchemaOwnTopicCompleteFunctionYaml = require("./flowSchemaOwnTopic/webSocketComplete/functionYaml/data");
|
|
86
|
+
const createFlowSchemaOwnTopicCompleteHandler = require("./flowSchemaOwnTopic/webSocketComplete/handler/data");
|
|
87
|
+
const createFlowSchemaOwnTopicCompleteMainFunction = require("./flowSchemaOwnTopic/webSocketComplete/mainFunction/data");
|
|
92
88
|
|
|
93
89
|
// flowSchema OwnTopicEndpoint component
|
|
94
90
|
const createFlowSchemaOwnTopicEndpointFuntionYaml = require('./flowSchemaOwnTopic/EndpointComponent/functionYaml/data');
|
|
95
91
|
const createFlowSchemaOwnTopicEndpointHandler = require('./flowSchemaOwnTopic/EndpointComponent/handler/data');
|
|
96
92
|
const createFlowSchemaOwnTopicEndpointMainFunction = require('./flowSchemaOwnTopic/EndpointComponent/mainFunction/data');
|
|
97
93
|
|
|
94
|
+
// flowSchema OnwTopic flowStep component
|
|
95
|
+
const createFlowScheamOwnTopicFlowStepFunctionYml = require('./flowSchemaOwnTopic/flowStep/functionYaml/data');
|
|
96
|
+
const createFlowSchemaOwnTopicFlowStepHandler = require('./flowSchemaOwnTopic/flowStep/handler/data');
|
|
97
|
+
const createFlowScheamOwnTopicFlowStepMainFunction = require('./flowSchemaOwnTopic/flowStep/mainFunction/data')
|
|
98
98
|
// flowSchema OwnTopicEndpointComplete component
|
|
99
99
|
const createFlowSchemaOwnTopicEndpointCompleteFuntionYaml = require('./flowSchemaOwnTopic/EndpointComplete/functionYaml/data');
|
|
100
100
|
const createFlowSchemaOwnTopicEndpointCompleteHandler = require('./flowSchemaOwnTopic/EndpointComplete/handler/data');
|
|
@@ -114,15 +114,15 @@ const createCreateObjectCompleteHandler = require('./CreateRecordComplete/handle
|
|
|
114
114
|
const createCreateObjectCompleteMainFunction = require('./CreateRecordComplete/mainFunction/data');
|
|
115
115
|
const createCreateObjectCompleteQueue = require('./CreateRecordComplete/queue/data');// flowSchema Register component //
|
|
116
116
|
|
|
117
|
-
const createFlowSchemaRegisterHandlerComplete = require('./
|
|
118
|
-
const createFlowSchemaRegisterMainCompleteFunc = require('./
|
|
119
|
-
const createFlowSchemaRegisterHandlerWbsFunc = require('./
|
|
120
|
-
const createFlowSchemaRegisterMainWbsFunc = require('./
|
|
121
|
-
const createFlowSchemaRegisterMainCompleteFuncYaml = require('./
|
|
122
|
-
const createFlowSchemaRegisterMainWbsFuncYaml = require('./
|
|
123
|
-
const createFlowSchemaRegisterSubscribeOutAll = require('./
|
|
124
|
-
const createFlowSchemaRegisterSnsInSqs = require('./
|
|
125
|
-
const createFlowSchemaRegisterDynamoDb = require('./
|
|
117
|
+
const createFlowSchemaRegisterHandlerComplete = require('./register/complete/handler/data');
|
|
118
|
+
const createFlowSchemaRegisterMainCompleteFunc = require('./register/complete/mainFunction/data');
|
|
119
|
+
const createFlowSchemaRegisterHandlerWbsFunc = require('./register/wbs/handler/data');
|
|
120
|
+
const createFlowSchemaRegisterMainWbsFunc = require('./register/wbs/mainFunction/data');
|
|
121
|
+
const createFlowSchemaRegisterMainCompleteFuncYaml = require('./register/complete/functionYaml/data');
|
|
122
|
+
const createFlowSchemaRegisterMainWbsFuncYaml = require('./register/wbs/functionYaml/data');
|
|
123
|
+
const createFlowSchemaRegisterSubscribeOutAll = require('./register/subscriptionOutAll/data');
|
|
124
|
+
const createFlowSchemaRegisterSnsInSqs = require('./register/sns-in/data');
|
|
125
|
+
const createFlowSchemaRegisterDynamoDb = require('./register/dynamoDB/register');
|
|
126
126
|
|
|
127
127
|
/**
|
|
128
128
|
* Generates code with templates for different actions
|
|
@@ -254,25 +254,17 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
254
254
|
|
|
255
255
|
} else if (event.includes("extTopic")) {
|
|
256
256
|
// ** External Topic ** //
|
|
257
|
+
const externalSqsFunctionYaml = await createExternalSqsFunctionYaml(_izContext, flowSchema, saveFilePath);
|
|
258
|
+
const externalSqsHandler = await createExternalSqsHandler(_izContext, flowSchema, saveFilePath);
|
|
259
|
+
const externalSqsMainFunction = await createExternalSqsMainFunction(_izContext, flowSchema, saveFilePath);
|
|
257
260
|
const externalTopicSnsInSqs = createExternalTopicSnsInSqs(_izContext, flowSchema, saveFilePath);
|
|
258
|
-
const externalTopicSnsOut = createExternalTopicSnsOut(_izContext, flowSchema, saveFilePath);
|
|
259
|
-
const externalWebsocketFunctionYaml = createExternalWebsocketFunctionYaml(_izContext, flowSchema, saveFilePath);
|
|
260
|
-
const externalWebsocketHandler = createExternalWebsocketHandler(_izContext, flowSchema, saveFilePath);
|
|
261
|
-
const externalWebsocketMainFunction = createExternalWebsocketMainFunction(_izContext, flowSchema, saveFilePath);
|
|
262
|
-
const externalSqsFunctionYaml = createExternalSqsFunctionYaml(_izContext, flowSchema, saveFilePath);
|
|
263
|
-
const externalSqsHandler = createExternalSqsHandler(_izContext, flowSchema, saveFilePath);
|
|
264
|
-
const externalSqsMainFunction = createExternalSqsMainFunction(_izContext, flowSchema, saveFilePath);
|
|
265
261
|
|
|
266
262
|
// Group related resources for better organization
|
|
267
263
|
const externalTopic = [
|
|
268
|
-
...externalWebsocketFunctionYaml,
|
|
269
|
-
...externalWebsocketHandler,
|
|
270
|
-
...externalWebsocketMainFunction,
|
|
271
264
|
...externalSqsFunctionYaml,
|
|
272
265
|
...externalSqsHandler,
|
|
273
266
|
...externalSqsMainFunction,
|
|
274
|
-
...externalTopicSnsInSqs
|
|
275
|
-
...externalTopicSnsOut
|
|
267
|
+
...externalTopicSnsInSqs
|
|
276
268
|
];
|
|
277
269
|
|
|
278
270
|
createSourceParams.push(...externalTopic)
|
|
@@ -285,7 +277,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
285
277
|
const flowSchemaOwnTopicMainFunction = await createFlowSchemaOwnTopicMainFunction(_izContext, flowSchema, saveFilePath);
|
|
286
278
|
const flowSchemaOwnTopicComponent = [...flowSchemaOwnTopicFunctionYaml, ...flowSchemaOwnTopicHandler, ...flowSchemaOwnTopicMainFunction]
|
|
287
279
|
// flowSchema OwnTopic Complete component
|
|
288
|
-
const flowSchemaOwnTopicCompleteFunctionYaml = createFlowSchemaOwnTopicCompleteFunctionYaml(_izContext,
|
|
280
|
+
const flowSchemaOwnTopicCompleteFunctionYaml = createFlowSchemaOwnTopicCompleteFunctionYaml(_izContext, saveFilePath);
|
|
289
281
|
const flowSchemaOwnTopicCompleteHandler = createFlowSchemaOwnTopicCompleteHandler(_izContext, flowSchema, saveFilePath);
|
|
290
282
|
const flowSchemaOwnTopicCompleteMainFunction = createFlowSchemaOwnTopicCompleteMainFunction(_izContext, flowSchema, saveFilePath);
|
|
291
283
|
const flowSchemaOwnTopicCompleteComponent = [...flowSchemaOwnTopicCompleteFunctionYaml, ...flowSchemaOwnTopicCompleteHandler, ...flowSchemaOwnTopicCompleteMainFunction]
|
|
@@ -303,16 +295,22 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
303
295
|
|
|
304
296
|
const flowSchemaOwnTopicQueue = createFlowSchemaOwnTopicQueue(_izContext, flowSchema, saveFilePath);
|
|
305
297
|
const flowSchemaOwnTopicSnsOut = createFlowSchemaOwnTopicSnsOut(_izContext, flowSchema, saveFilePath);
|
|
298
|
+
|
|
299
|
+
const flowSchemaOwnTopicFlowStepYml = createFlowScheamOwnTopicFlowStepFunctionYml(_izContext, flowSchema, saveFilePath);
|
|
300
|
+
const flowSchemaOwnTopicFlowStepHandler = createFlowSchemaOwnTopicFlowStepHandler(_izContext, flowSchema, saveFilePath);
|
|
301
|
+
const flowSchemaOwnTopicFlowStepMainFunction = createFlowScheamOwnTopicFlowStepMainFunction(_izContext, flowSchema, saveFilePath)
|
|
302
|
+
const flowSchemaOwnTopicFlowStep = [...flowSchemaOwnTopicFlowStepYml, ...flowSchemaOwnTopicFlowStepHandler, ...flowSchemaOwnTopicFlowStepMainFunction]
|
|
306
303
|
// Group the resources
|
|
307
304
|
const ownTopicResources = [
|
|
308
|
-
...flowSchemaOwnTopicComponent, ...flowSchemaOwnTopicCompleteComponent, ...flowSchemaOwnTopicEndpointComponent, ...flowSchemaOwnTopicQueue, ...flowSchemaOwnTopicSnsOut,
|
|
305
|
+
...flowSchemaOwnTopicComponent, ...flowSchemaOwnTopicCompleteComponent, ...flowSchemaOwnTopicEndpointComponent, ...flowSchemaOwnTopicQueue, ...flowSchemaOwnTopicSnsOut, ...flowSchemaOwnTopicFlowStep
|
|
309
306
|
// ...flowSchemaOwnTopicEndpointCompleteComponent
|
|
310
307
|
];
|
|
311
308
|
|
|
309
|
+
|
|
310
|
+
|
|
312
311
|
console.log("event ownTopic generated")
|
|
313
312
|
createSourceParams.push(...ownTopicResources);
|
|
314
313
|
|
|
315
|
-
|
|
316
314
|
} else if (event.includes("eventBridge")) {
|
|
317
315
|
const flowSchemaEventBridgeHandler = createFlowSchemaEventBridgeHandler(_izContext, flowSchema, saveFilePath);
|
|
318
316
|
const flowSchemaEventBridgeMainFunction = createFlowSchemaEventBridgeMainFunction(_izContext, flowSchema, saveFilePath);
|
|
@@ -28,7 +28,7 @@ const { <%- functionName %>Main } =require('./<%- firstLetterUpperCase(functionN
|
|
|
28
28
|
|
|
29
29
|
// validate event properties in body.Message of sqs event
|
|
30
30
|
middlewareHandler.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
|
|
31
|
-
|
|
31
|
+
let perRecordsValidatorSchema = {}
|
|
32
32
|
module.exports.main = middlewareHandler.wrap(async (event, context, callback) => {
|
|
33
33
|
|
|
34
34
|
try {
|