@izara_project/izara-market-library-service-schemas 1.0.37 → 1.0.38
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 +15 -23
- 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 +46 -37
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +14 -19
- 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 +23 -25
- 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/templateBystatusType/storedCacheTemplate.ejs +38 -0
- package/src/reStructure/TemplateData/flowSchema/templateBystatusType/triggerCacheTemplate.ejs +39 -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/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
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → templateBystatusType}/statusFieldTemplate.ejs +0 -0
|
@@ -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,43 @@ 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
|
+
let topicOut = `${upperCase(flowSchema.flowTag)}`;
|
|
78
|
+
defaultDsqQueueDataList.push({
|
|
79
|
+
queueName: `WebSocketComplete` + upperCase(HANDLER.hdrSqs),
|
|
80
|
+
subscribeTo: topicOut
|
|
81
|
+
}
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (flowSteps.includes("In") && flowSteps.includes("Out")) {
|
|
88
|
+
if (flowSteps.length > 2) {
|
|
89
|
+
for (let i = 2; i < flowSteps.length; i++) {
|
|
90
|
+
generatedSnsTopicInForFlowSchema.push(
|
|
91
|
+
{
|
|
92
|
+
queueName: upperCase(flowSteps[i])
|
|
93
|
+
}
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
82
98
|
|
|
83
99
|
for (let defaultSnsInSqsData of generatedSnsTopicInForFlowSchema) {
|
|
84
100
|
resultsForCreateDefaultSnsInSqs.push({
|
|
@@ -88,23 +104,16 @@ function createDataForDefaultSnsInSqs(_izContext, flowSchema, srcPath) {
|
|
|
88
104
|
})
|
|
89
105
|
}
|
|
90
106
|
|
|
91
|
-
|
|
92
|
-
{
|
|
93
|
-
|
|
94
|
-
|
|
107
|
+
if (defaultDsqQueueDataList.length) {
|
|
108
|
+
for (let defaultDsqQueueData of defaultDsqQueueDataList) {
|
|
109
|
+
resultsForCreateDefaultSnsInSqs.push({
|
|
110
|
+
templatePath: subscriptionSqsTemplatePath,
|
|
111
|
+
templateData: defaultDsqQueueData,
|
|
112
|
+
setting: setting
|
|
113
|
+
})
|
|
95
114
|
}
|
|
96
|
-
]
|
|
97
|
-
for (let defaultDsqQueueData of defaultDsqQueueDataList) {
|
|
98
|
-
resultsForCreateDefaultSnsInSqs.push({
|
|
99
|
-
templatePath: sqsTemplatePath,
|
|
100
|
-
templateData: defaultDsqQueueData,
|
|
101
|
-
setting: setting
|
|
102
|
-
})
|
|
103
115
|
}
|
|
104
|
-
|
|
105
|
-
// resultsForCreateDefaultSnsInSqs: JSON.stringify(resultsForCreateDefaultSnsInSqs, null, 2
|
|
106
|
-
// )
|
|
107
|
-
// })
|
|
116
|
+
|
|
108
117
|
return resultsForCreateDefaultSnsInSqs;
|
|
109
118
|
}
|
|
110
119
|
|
|
@@ -47,33 +47,28 @@ 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 = []
|
|
51
|
+
let topicOut = `${upperCase(flowSchema.flowTag)}`
|
|
52
52
|
if (flowSchema.outputTopic) {
|
|
53
|
-
let flowStepsOut = flowSteps[1];
|
|
54
|
-
let splitFlowStepsOut = flowStepsOut.split("_");
|
|
55
|
-
let topicOut = splitFlowStepsOut[2]
|
|
56
53
|
generatedSnsTopicOutForFlowSchema.push(
|
|
57
54
|
{
|
|
58
55
|
queueName: upperCase(topicOut)
|
|
59
56
|
}
|
|
60
57
|
)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
for (let defaultSnsOutData of generatedSnsTopicOutForFlowSchema) {
|
|
65
|
-
resultsForCreateDefaultSnsInSqs.push({
|
|
66
|
-
templatePath: templatePath,
|
|
67
|
-
templateData: defaultSnsOutData,
|
|
68
|
-
setting: {
|
|
69
|
-
initialData: "Resources:\n",
|
|
70
|
-
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
71
|
-
saveFileName: SAVE_FILE_NAME.snsOutYaml,
|
|
72
|
-
fileExtension: ".yml",
|
|
73
|
-
isAppend: true
|
|
74
|
-
}
|
|
75
58
|
|
|
76
|
-
|
|
59
|
+
for (let defaultSnsOutData of generatedSnsTopicOutForFlowSchema) {
|
|
60
|
+
resultsForCreateDefaultSnsInSqs.push({
|
|
61
|
+
templatePath: templatePath,
|
|
62
|
+
templateData: defaultSnsOutData,
|
|
63
|
+
setting: {
|
|
64
|
+
initialData: "Resources:\n",
|
|
65
|
+
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
66
|
+
saveFileName: SAVE_FILE_NAME.snsOutYaml,
|
|
67
|
+
fileExtension: ".yml",
|
|
68
|
+
isAppend: true
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
}
|
|
77
72
|
}
|
|
78
73
|
|
|
79
74
|
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');
|
|
@@ -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 {
|
|
@@ -0,0 +1,172 @@
|
|
|
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('@izara_project/izara-shared-core').objectHash;
|
|
22
|
+
const { getObjectSchema } = require('@izara_project/izara-core-library-service-schemas');
|
|
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
|
+
const { postToConnection } = require("../../../libs/source/GenerateCodeLibs");
|
|
33
|
+
|
|
34
|
+
const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
|
|
35
|
+
const { NoRetryError } = require('@izara_project/izara-core-library-core')
|
|
36
|
+
const { v4: uuidv4 } = require('uuid')
|
|
37
|
+
const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
|
|
38
|
+
// const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
|
|
39
|
+
const { generateCodeLibs: { consts: TOPIC_NAME_GENERATE_CODE } } = require('@izara_project/izara-market-library-service-schemas')
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* description of function.
|
|
43
|
+
* @param {Object} _izContext
|
|
44
|
+
* @param {CorrelationIds} _izContext.correlationIds - property of _izContext
|
|
45
|
+
* @param {Logger} _izContext.logger - property of _izContext
|
|
46
|
+
* @param {Object} requestParams - request params
|
|
47
|
+
* @param {Object} requestParams.identifiers - identifiers for get data
|
|
48
|
+
* @param {Object} requestParams.additionalRequest - additionalRequest
|
|
49
|
+
*
|
|
50
|
+
* @returns {object} description of return value
|
|
51
|
+
*/
|
|
52
|
+
module.exports.registerCompleteMain = async (
|
|
53
|
+
_izContext,
|
|
54
|
+
requestParams,
|
|
55
|
+
callingFlowConfig = {},
|
|
56
|
+
//(<additionalParams>)
|
|
57
|
+
//(</additionalParams>)
|
|
58
|
+
) => {
|
|
59
|
+
try {
|
|
60
|
+
_izContext.logger.debug("WebSocketInvoke _izContext", _izContext)
|
|
61
|
+
_izContext.logger.debug("WebSocketInvoke requestParams", requestParams)
|
|
62
|
+
_izContext.logger.debug("WebSocketInvoke callingFlowConfig", callingFlowConfig)
|
|
63
|
+
|
|
64
|
+
// getflowSchema by using send topic name
|
|
65
|
+
// ! didn't got topicName from requestParams complete endpoint must send flowTag with identifiersTask
|
|
66
|
+
|
|
67
|
+
if (!requestParams.flowTag) {
|
|
68
|
+
throw new NoRetryError("not have flowTag in request")
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
|
|
72
|
+
flowTag: requestParams.flowTag,
|
|
73
|
+
serviceTag: process.env.iz_serviceTag
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
if (!flowSchema) {
|
|
77
|
+
throw new NoRetryError("not have flowSchema in S3")
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
let correlationId = _izContext.correlationIds.get(consts.X_CORRELATION_ID);
|
|
81
|
+
|
|
82
|
+
const getResult = async (objectType) => {
|
|
83
|
+
const objectSchema = await getObjectSchema.getObjSchemaS3WithCache(
|
|
84
|
+
_izContext,
|
|
85
|
+
{
|
|
86
|
+
objectType: objectType,
|
|
87
|
+
serviceTag: process.env.iz_serviceTag,
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
_izContext.logger.debug("==> objectSchema", objectSchema)
|
|
91
|
+
|
|
92
|
+
const result = await externalRequest.lambda.invokeSync(_izContext,
|
|
93
|
+
await lambdaSharedLib.lambdaFunctionName(_izContext, "GetHdrInv"),
|
|
94
|
+
{
|
|
95
|
+
identifiers: identifiersLibs.identifiersFromIdentifiersConcat(_izContext, objectType, requestParams.identifiersTask),
|
|
96
|
+
objectType: objectType
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
for (const [fieldName, fieldNameSetting] of Object.entries(objectSchema.fieldNames)) {
|
|
101
|
+
if (fieldNameSetting.hasOwnProperty("statusField") && fieldNameSetting.statusField === true) {
|
|
102
|
+
if (fieldName[result] !== "complete" || fieldName[result] !== "error") {
|
|
103
|
+
// if status is not complete or error will save data into table
|
|
104
|
+
await dynamodbSharedLib.putItem(_izContext,
|
|
105
|
+
await dynamodbSharedLib.tableName(_izContext, "RegisterRecord"),
|
|
106
|
+
{
|
|
107
|
+
identifiersTask: requestParams.identifiersTask,
|
|
108
|
+
connecttionId: connecttionId
|
|
109
|
+
}
|
|
110
|
+
)
|
|
111
|
+
} else {
|
|
112
|
+
if (!result) {
|
|
113
|
+
await generatedCodeLibs.postToConnection({ message: "not have record" }, connecttionId)
|
|
114
|
+
} else {
|
|
115
|
+
await generatedCodeLibs.postToConnection({ message: result }, connecttionId)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// check statusType
|
|
123
|
+
switch (flowSchema.statusType) {
|
|
124
|
+
case "statusField":
|
|
125
|
+
await getResult(flowSchema.objType.objectType);
|
|
126
|
+
break;
|
|
127
|
+
case "storedCache":
|
|
128
|
+
await getResult(flowSchema.objType.objectType);
|
|
129
|
+
break;
|
|
130
|
+
|
|
131
|
+
case "none":
|
|
132
|
+
|
|
133
|
+
let identifier = {};
|
|
134
|
+
if (requestParams.hasOwnProperty("identifiersField") && Array.isArray(requestParams.identifierisField)) {
|
|
135
|
+
for (const fieldNames of requestParams.identifierisField) {
|
|
136
|
+
Object.assign(identifier, { [fieldNames]: requestParams[fieldNames] })
|
|
137
|
+
}
|
|
138
|
+
identifier = identifier;
|
|
139
|
+
} else {
|
|
140
|
+
identifier = requestParams
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// get task before putItem
|
|
144
|
+
let tasks = await dynamodbSharedLib.query(_izContext,
|
|
145
|
+
await dynamodbSharedLib.tableName(_izContext, "ResgisterRecords"),
|
|
146
|
+
{
|
|
147
|
+
identifiersTask: hash(identifier)
|
|
148
|
+
}
|
|
149
|
+
)
|
|
150
|
+
if (tasks && tasks.length > 0) {
|
|
151
|
+
await Promise.all(tasks.Items.map(async (task) => {
|
|
152
|
+
await generatedCodeLibs.postToConnection({ message: task }, task.connecttionId)
|
|
153
|
+
}))
|
|
154
|
+
} else {
|
|
155
|
+
await dynamodbSharedLib.putItem(_izContext,
|
|
156
|
+
await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
|
|
157
|
+
{
|
|
158
|
+
identifiersTask: hash(identifier),
|
|
159
|
+
connecttionId: connecttionId
|
|
160
|
+
}
|
|
161
|
+
)
|
|
162
|
+
}
|
|
163
|
+
break
|
|
164
|
+
default:
|
|
165
|
+
throw new NoRetryError(`statusType not found ${getFlowSchema.statusType}`)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
} catch (err) {
|
|
169
|
+
_izContext.logger.error('error WebSocketInvoke: ', err)
|
|
170
|
+
throw (err)
|
|
171
|
+
}
|
|
172
|
+
}
|