@izara_project/izara-market-library-service-schemas 1.0.40 → 1.0.42
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/MainLibs/src/Consts.js +1 -1
- package/src/reStructure/GenerateSchema.js +6 -6
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +20 -12
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +23 -8
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +28 -21
- package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +0 -32
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +5 -2
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/dynamoDb/data.js +0 -20
- package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/data.js +7 -16
- package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/template.ejs +0 -1
- package/src/reStructure/TemplateData/flowSchema/externalTopic/Complete/functionYaml/data.js +112 -0
- package/src/reStructure/TemplateData/flowSchema/externalTopic/Complete/handler/data.js +93 -0
- package/src/reStructure/TemplateData/flowSchema/externalTopic/Complete/mainFunction/data.js +61 -0
- package/src/reStructure/TemplateData/flowSchema/externalTopic/Complete/mainFunction/template.ejs +96 -0
- package/src/reStructure/TemplateData/flowSchema/externalTopic/{functionYaml → Process/functionYaml}/data.js +20 -4
- package/src/reStructure/TemplateData/flowSchema/externalTopic/{handler → Process/handler}/data.js +3 -3
- package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/handler/template.ejs +87 -0
- package/src/reStructure/TemplateData/flowSchema/externalTopic/{mainFunction → Process/mainFunction}/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/externalTopic/{mainFunction → Process/mainFunction}/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +14 -4
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/sqsTemplate.ejs +52 -0
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/data.js +10 -9
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/handler/data.js +8 -4
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/data.js +12 -11
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/template.ejs +93 -49
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/template.ejs +2 -0
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +3 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +9 -21
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/sqsTemplate.ejs +0 -10
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → flowStep}/functionYaml/data.js +37 -24
- package/src/reStructure/TemplateData/flowSchema/flowStep/functionYaml/template.ejs +20 -0
- package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → flowStep}/handler/data.js +24 -20
- package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → flowStep}/mainFunction/data.js +27 -22
- package/src/reStructure/TemplateData/flowSchema/flowStep/sns-in/data.js +90 -0
- package/src/reStructure/TemplateData/flowSchema/flowStep/sns-in/template.ejs +45 -0
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +45 -29
- package/src/reStructure/TemplateData/flowSchema/register/complete/functionYaml/data.js +3 -1
- package/src/reStructure/TemplateData/flowSchema/register/complete/handler/data.js +0 -1
- package/src/reStructure/TemplateData/flowSchema/register/complete/mainFunction/template.ejs +33 -29
- package/src/reStructure/TemplateData/flowSchema/register/dynamoDB/register.js +0 -17
- package/src/reStructure/TemplateData/flowSchema/register/sns-in/data.js +0 -1
- package/src/reStructure/TemplateData/flowSchema/register/subscriptionOutAll/data.js +1 -3
- package/src/reStructure/TemplateData/flowSchema/register/subscriptionOutAll/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/register/wbs/functionYaml/data.js +0 -29
- package/src/reStructure/TemplateData/flowSchema/register/wbs/handler/data.js +0 -1
- package/src/reStructure/TemplateData/flowSchema/register/wbs/handler/template.ejs +3 -5
- package/src/reStructure/TemplateData/flowSchema/register/wbs/mainFunction/template.ejs +35 -32
- package/src/reStructure/TemplateData/flowSchema/templateBystatusType/triggerCacheTemplate.ejs +7 -1
- package/src/reStructure/TemplateData/flowSchema/webSocketComplete/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/webSocketComplete/sqs/data.js +97 -0
- package/src/reStructure/TemplateData/flowSchema/webSocketComplete/sqs/template.ejs +52 -0
- package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +1 -0
- package/src/reStructure/TemplateData/propertyValueSchema/generateTemplateData.js +18 -18
- package/src/reStructure/TemplateData/propertyValueSchema/objectPropertyValueSchema/data.js +82 -79
- package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js +33 -37
- /package/src/reStructure/TemplateData/flowSchema/externalTopic/{functionYaml → Complete/functionYaml}/template.ejs +0 -0
- /package/src/reStructure/TemplateData/flowSchema/externalTopic/{handler → Complete/handler}/template.ejs +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → externalTopic/Process}/functionYaml/template.ejs +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → flowStep}/handler/template.ejs +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → flowStep}/mainFunction/template.ejs +0 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
|
|
20
|
+
const path = require("path")
|
|
21
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils.js");
|
|
22
|
+
|
|
23
|
+
const templatePath = path.join(__dirname, './template.ejs');
|
|
24
|
+
|
|
25
|
+
const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, HANDLER } = require('../../../../../MainLibs/src/Consts.js');
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* create data for dynamoDbYaml tempalte from objectSchema
|
|
29
|
+
* return array of dynamoDb data
|
|
30
|
+
* because one objectSchema can create multiple dynamoDb table
|
|
31
|
+
*
|
|
32
|
+
* @param {Object} _izContext
|
|
33
|
+
* @param {String} saveFilePath
|
|
34
|
+
* @returns {Object[]} - data of multiple dynamoDb template
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
function createDataForDefaultSnsInSqs(_izContext, flowSchema, srcPath) {
|
|
38
|
+
let resultsForCreateDefaultSnsInSqs = [];
|
|
39
|
+
// console.log("create topic by flowSteps", flowSteps)
|
|
40
|
+
const setting = {
|
|
41
|
+
initialData: "Resources:\n",
|
|
42
|
+
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
43
|
+
saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
|
|
44
|
+
fileExtension: ".yml",
|
|
45
|
+
isAppend: true
|
|
46
|
+
}
|
|
47
|
+
const generatedSnsTopicInForFlowSchema = [];
|
|
48
|
+
if (flowSchema.hasOwnProperty("flowSteps")) {
|
|
49
|
+
let flowSteps = Object.keys(flowSchema.flowSteps);
|
|
50
|
+
if (flowSteps.length && flowSteps.length > 0) {
|
|
51
|
+
if (flowSchema.outputTopic) {
|
|
52
|
+
if (flowSteps.includes("In") && flowSteps.includes("Out")) {
|
|
53
|
+
if (flowSteps.length > 2) {
|
|
54
|
+
for (let i = 2; i < flowSteps.length; i++) {
|
|
55
|
+
generatedSnsTopicInForFlowSchema.push(
|
|
56
|
+
{
|
|
57
|
+
queueName: upperCase(flowSteps[i])
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
if (flowSteps.includes("In")) {
|
|
65
|
+
if (flowSteps.length > 1) {
|
|
66
|
+
for (let i = 2; i < flowSteps.length; i++) {
|
|
67
|
+
generatedSnsTopicInForFlowSchema.push(
|
|
68
|
+
{
|
|
69
|
+
queueName: upperCase(flowSteps[i])
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
for (let defaultSnsInSqsData of generatedSnsTopicInForFlowSchema) {
|
|
80
|
+
resultsForCreateDefaultSnsInSqs.push({
|
|
81
|
+
templatePath: templatePath,
|
|
82
|
+
templateData: defaultSnsInSqsData,
|
|
83
|
+
setting: setting
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return resultsForCreateDefaultSnsInSqs;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
module.exports = createDataForDefaultSnsInSqs;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
##===== [Queue]
|
|
2
|
+
<%- queueName %>HdrSqs:
|
|
3
|
+
Type: "AWS::SQS::Queue"
|
|
4
|
+
Properties:
|
|
5
|
+
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqs
|
|
6
|
+
RedrivePolicy:
|
|
7
|
+
deadLetterTargetArn:
|
|
8
|
+
# !GetAtt
|
|
9
|
+
Fn::GetAtt:
|
|
10
|
+
- <%- queueName %>HdrSqsDLQ
|
|
11
|
+
- Arn
|
|
12
|
+
maxReceiveCount: 3
|
|
13
|
+
VisibilityTimeout: 120
|
|
14
|
+
##==== [QueueDLQ]
|
|
15
|
+
<%- queueName %>HdrSqsDLQ:
|
|
16
|
+
Type: AWS::SQS::Queue
|
|
17
|
+
Properties:
|
|
18
|
+
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqsDLQ
|
|
19
|
+
##==== [QueuePolicy]
|
|
20
|
+
<%- queueName %>HdrSqsPolicy:
|
|
21
|
+
Type: AWS::SQS::QueuePolicy
|
|
22
|
+
Properties:
|
|
23
|
+
PolicyDocument:
|
|
24
|
+
Version: "2012-10-17"
|
|
25
|
+
Statement:
|
|
26
|
+
- Sid: "allow-sns-messages"
|
|
27
|
+
Effect: Allow
|
|
28
|
+
Principal: "*"
|
|
29
|
+
Resource:
|
|
30
|
+
# !GetAtt
|
|
31
|
+
Fn::GetAtt:
|
|
32
|
+
- <%- queueName %>HdrSqs
|
|
33
|
+
- Arn
|
|
34
|
+
Action: "SQS:SendMessage"
|
|
35
|
+
Queues:
|
|
36
|
+
- Ref: <%- queueName %>HdrSqs
|
|
37
|
+
#<#<%- firstLetterUpperCase(queueName) %>QueueSetting#>
|
|
38
|
+
#<#/<%- firstLetterUpperCase(queueName) %>QueueSetting#>
|
|
39
|
+
|
|
40
|
+
<%_ function firstLetterUpperCase(text){
|
|
41
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
42
|
+
} _%>
|
|
43
|
+
<%_ function firstLetterLowerCase(str) {
|
|
44
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
45
|
+
} _%>
|
|
@@ -71,9 +71,12 @@ 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 createExternalSqsFunctionYaml = require('./externalTopic/functionYaml/data');
|
|
75
|
-
const createExternalSqsHandler = require('./externalTopic/handler/data');
|
|
76
|
-
const createExternalSqsMainFunction = require('./externalTopic/mainFunction/data');
|
|
74
|
+
const createExternalSqsFunctionYaml = require('./externalTopic/Process/functionYaml/data');
|
|
75
|
+
const createExternalSqsHandler = require('./externalTopic/Process/handler/data');
|
|
76
|
+
const createExternalSqsMainFunction = require('./externalTopic/Process/mainFunction/data');
|
|
77
|
+
const createExternalSqsCompleteFunctionYaml = require("./externalTopic/Complete/functionYaml/data");
|
|
78
|
+
const createExternalSqsCompleteHandler = require("./externalTopic/Complete/handler/data");
|
|
79
|
+
const createExternalSqsCompleteMainFunction = require("./externalTopic/Complete/mainFunction/data");
|
|
77
80
|
const createExternalTopicSnsInSqs = require('./externalTopic/sns-in-sqs/data');
|
|
78
81
|
const createExternalTopicSnsOut = require('./externalTopic/sns-out/data')
|
|
79
82
|
|
|
@@ -83,19 +86,21 @@ const createFlowSchemaOwnTopicHandler = require('./flowSchemaOwnTopic/FlowSchema
|
|
|
83
86
|
const createFlowSchemaOwnTopicMainFunction = require('./flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data');
|
|
84
87
|
|
|
85
88
|
// flowSchema OwnTopicComplete component
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
const
|
|
89
|
-
|
|
89
|
+
const createWebSocketCompleteMainFunctionYaml = require("./webSocketComplete/functionYaml/data");
|
|
90
|
+
const createWebSocketCompleteMainHandler = require("./webSocketComplete/handler/data");
|
|
91
|
+
const createWebSocketCompleteMainMainFunction = require("./webSocketComplete/mainFunction/data");
|
|
92
|
+
const createWebSocketCompleteMainSqs = require('./webSocketComplete/sqs/data');
|
|
90
93
|
// flowSchema OwnTopicEndpoint component
|
|
94
|
+
|
|
91
95
|
const createFlowSchemaOwnTopicEndpointFuntionYaml = require('./flowSchemaOwnTopic/EndpointComponent/functionYaml/data');
|
|
92
96
|
const createFlowSchemaOwnTopicEndpointHandler = require('./flowSchemaOwnTopic/EndpointComponent/handler/data');
|
|
93
97
|
const createFlowSchemaOwnTopicEndpointMainFunction = require('./flowSchemaOwnTopic/EndpointComponent/mainFunction/data');
|
|
94
98
|
|
|
95
99
|
// flowSchema OnwTopic flowStep component
|
|
96
|
-
const
|
|
97
|
-
const
|
|
98
|
-
const
|
|
100
|
+
const createFlowSchemaFlowStepFunctionYaml = require('./flowStep/functionYaml/data');
|
|
101
|
+
const createFlowSchemaFlowStepHandler = require('./flowStep/handler/data');
|
|
102
|
+
const createFlowSchemaFlowStepMainFunction = require('./flowStep/mainFunction/data')
|
|
103
|
+
const createFlowSchemaFlowStepSnsIn = require('./flowStep/sns-in/data');
|
|
99
104
|
// flowSchema OwnTopicEndpointComplete component
|
|
100
105
|
const createFlowSchemaOwnTopicEndpointCompleteFuntionYaml = require('./flowSchemaOwnTopic/EndpointComplete/functionYaml/data');
|
|
101
106
|
const createFlowSchemaOwnTopicEndpointCompleteHandler = require('./flowSchemaOwnTopic/EndpointComplete/handler/data');
|
|
@@ -132,10 +137,10 @@ const createFlowSchemaRegisterDynamoDb = require('./register/dynamoDB/register')
|
|
|
132
137
|
* @returns {Array} Array of generated code parameters
|
|
133
138
|
*/
|
|
134
139
|
async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
135
|
-
console.log("objSchemaPath in flowSchema generateTemplateAndData", objSchemaPath);
|
|
140
|
+
// console.log("objSchemaPath in flowSchema generateTemplateAndData", objSchemaPath);
|
|
136
141
|
try {
|
|
137
142
|
const saveFilePath = join(objSchemaPath, '../');
|
|
138
|
-
console.log("saveFilePath in flowSchema generateTemplateAndData", saveFilePath)
|
|
143
|
+
// console.log("saveFilePath in flowSchema generateTemplateAndData", saveFilePath)
|
|
139
144
|
let createSourceParams = [];
|
|
140
145
|
const allLocalFlowSchemas = await getAllLocalFlowSchemas(_izContext, objSchemaPath);
|
|
141
146
|
const allLocalObjectSchemas = await getAllLocalObjectSchemasWithHierarchy(_izContext, objSchemaPath);
|
|
@@ -146,24 +151,26 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
146
151
|
const webSocketConnectHandler = createWebSocketConnectHandler(_izContext, saveFilePath);
|
|
147
152
|
|
|
148
153
|
// flowSchema OwnTopic Complete component
|
|
149
|
-
const
|
|
150
|
-
const
|
|
151
|
-
const
|
|
152
|
-
const
|
|
154
|
+
const webSocketCompleteFunctionYaml = createWebSocketCompleteMainFunctionYaml(_izContext, allLocalFlowSchemas, saveFilePath);
|
|
155
|
+
const webSocketCompleteHandler = createWebSocketCompleteMainHandler(_izContext, saveFilePath);
|
|
156
|
+
const webSocketCompleteMainFunction = createWebSocketCompleteMainMainFunction(_izContext, saveFilePath);
|
|
157
|
+
const webSocketCompleteSqs = createWebSocketCompleteMainSqs(_izContext, allLocalFlowSchemas, saveFilePath)
|
|
158
|
+
const webSocketCompleteComponent = [...webSocketCompleteFunctionYaml, ...webSocketCompleteHandler, ...webSocketCompleteMainFunction, ...webSocketCompleteSqs]
|
|
153
159
|
|
|
154
160
|
const webSocketResource = [...webSocketTaskTable, ...webSocketConnectYaml, ...webSocketConnectHandler]
|
|
155
161
|
if (allLocalFlowSchemas.records.length) {
|
|
156
162
|
createSourceParams.push(
|
|
157
163
|
...webSocketResource,
|
|
158
|
-
...
|
|
164
|
+
...webSocketCompleteComponent
|
|
159
165
|
)
|
|
160
166
|
}
|
|
161
167
|
|
|
168
|
+
|
|
162
169
|
// get flowsteps out form all local object schemas
|
|
163
170
|
|
|
164
171
|
|
|
165
172
|
for (const flowSchema of allLocalFlowSchemas.records) {
|
|
166
|
-
console.log("flowSchema in Generate TemplateData", flowSchema);
|
|
173
|
+
// console.log("flowSchema in Generate TemplateData", flowSchema);
|
|
167
174
|
const webSocketGenerateCodeLibs = createWebSocketGenerateCodeLibs(_izContext, flowSchema, saveFilePath)
|
|
168
175
|
createSourceParams.push(...webSocketGenerateCodeLibs)
|
|
169
176
|
|
|
@@ -267,13 +274,18 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
267
274
|
const externalSqsMainFunction = await createExternalSqsMainFunction(_izContext, flowSchema, saveFilePath);
|
|
268
275
|
const externalTopicSnsInSqs = createExternalTopicSnsInSqs(_izContext, flowSchema, saveFilePath);
|
|
269
276
|
const externalTopicSnsOut = createExternalTopicSnsOut(_izContext, flowSchema, saveFilePath);
|
|
277
|
+
|
|
278
|
+
const externalTopicCompleteFunctionYml = createExternalSqsCompleteFunctionYaml(_izContext, flowSchema, saveFilePath);
|
|
279
|
+
const externalTopicCompleteHandler = createExternalSqsCompleteHandler(_izContext, flowSchema, saveFilePath);
|
|
280
|
+
const externalTopicCompleteMainFunction = createExternalSqsCompleteMainFunction(_izContext, flowSchema, saveFilePath);
|
|
270
281
|
// Group related resources for better organization
|
|
271
282
|
const externalTopic = [
|
|
272
283
|
...externalSqsFunctionYaml,
|
|
273
284
|
...externalSqsHandler,
|
|
274
285
|
...externalSqsMainFunction,
|
|
275
286
|
...externalTopicSnsInSqs,
|
|
276
|
-
...externalTopicSnsOut
|
|
287
|
+
...externalTopicSnsOut,
|
|
288
|
+
...externalTopicCompleteFunctionYml, ...externalTopicCompleteHandler, ...externalTopicCompleteMainFunction
|
|
277
289
|
];
|
|
278
290
|
|
|
279
291
|
createSourceParams.push(...externalTopic)
|
|
@@ -293,22 +305,17 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
293
305
|
const flowSchemaOwnTopicEndpointComponent = [...flowSchemaOwnTopicEndpointFuntionYaml, ...flowSchemaOwnTopicEndpointHandler, ...flowSchemaOwnTopicEndpointMainFunction]
|
|
294
306
|
|
|
295
307
|
// flowSchemaOwnTopic EndpointComplete
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
308
|
+
const flowSchemaOwnTopicEndpointCompleteFuntionYaml = createFlowSchemaOwnTopicEndpointCompleteFuntionYaml(_izContext, flowSchema, saveFilePath);
|
|
309
|
+
const flowSchemaOwnTopicEndpointCompleteHandler = createFlowSchemaOwnTopicEndpointCompleteHandler(_izContext, flowSchema, saveFilePath);
|
|
310
|
+
const flowSchemaOwnTopicEndpointCompleteMainFunction = createFlowSchemaOwnTopicEndpointCompleteMainFunction(_izContext, flowSchema, saveFilePath);
|
|
311
|
+
const flowSchemaOwnTopicEndpointCompleteComponent = [...flowSchemaOwnTopicEndpointCompleteFuntionYaml, ...flowSchemaOwnTopicEndpointCompleteHandler, ...flowSchemaOwnTopicEndpointCompleteMainFunction];
|
|
300
312
|
|
|
301
313
|
const flowSchemaOwnTopicQueue = createFlowSchemaOwnTopicQueue(_izContext, flowSchema, saveFilePath);
|
|
302
314
|
const flowSchemaOwnTopicSnsOut = createFlowSchemaOwnTopicSnsOut(_izContext, flowSchema, saveFilePath);
|
|
303
315
|
|
|
304
|
-
const flowSchemaOwnTopicFlowStepYml = createFlowScheamOwnTopicFlowStepFunctionYml(_izContext, flowSchema, saveFilePath);
|
|
305
|
-
const flowSchemaOwnTopicFlowStepHandler = createFlowSchemaOwnTopicFlowStepHandler(_izContext, flowSchema, saveFilePath);
|
|
306
|
-
const flowSchemaOwnTopicFlowStepMainFunction = createFlowScheamOwnTopicFlowStepMainFunction(_izContext, flowSchema, saveFilePath)
|
|
307
|
-
const flowSchemaOwnTopicFlowStep = [...flowSchemaOwnTopicFlowStepYml, ...flowSchemaOwnTopicFlowStepHandler, ...flowSchemaOwnTopicFlowStepMainFunction]
|
|
308
316
|
// Group the resources
|
|
309
317
|
const ownTopicResources = [
|
|
310
|
-
...flowSchemaOwnTopicComponent, ...flowSchemaOwnTopicEndpointComponent, ...flowSchemaOwnTopicQueue, ...flowSchemaOwnTopicSnsOut, ...
|
|
311
|
-
// ...flowSchemaOwnTopicEndpointCompleteComponent
|
|
318
|
+
...flowSchemaOwnTopicComponent, ...flowSchemaOwnTopicEndpointComponent, ...flowSchemaOwnTopicQueue, ...flowSchemaOwnTopicSnsOut, ...flowSchemaOwnTopicEndpointCompleteComponent
|
|
312
319
|
];
|
|
313
320
|
|
|
314
321
|
|
|
@@ -328,6 +335,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
328
335
|
...flowSchemaEventBridgeFunctionYaml
|
|
329
336
|
];
|
|
330
337
|
|
|
338
|
+
// console.log("event eventBridge generated", JSON.stringify(eventBridgeResources, null, 2))
|
|
331
339
|
console.log("event eventBridge generated")
|
|
332
340
|
createSourceParams.push(...eventBridgeResources);
|
|
333
341
|
}
|
|
@@ -357,7 +365,14 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
357
365
|
// createSourceParams.push(...recordCompleteResources);
|
|
358
366
|
// }
|
|
359
367
|
}
|
|
368
|
+
const flowSchemaFlowStepYml = createFlowSchemaFlowStepFunctionYaml(_izContext, flowSchema, saveFilePath);
|
|
369
|
+
const flowSchemaFlowStepHandler = createFlowSchemaFlowStepHandler(_izContext, flowSchema, saveFilePath);
|
|
370
|
+
const flowSchemaFlowStepMainFunction = createFlowSchemaFlowStepMainFunction(_izContext, flowSchema, saveFilePath);
|
|
371
|
+
const flowSchemaFlowStepSnsIn = createFlowSchemaFlowStepSnsIn(_izContext, flowSchema, saveFilePath);
|
|
372
|
+
const flowSchemaOwnTopicFlowStep = [...flowSchemaFlowStepYml, ...flowSchemaFlowStepHandler, ...flowSchemaFlowStepMainFunction, ...flowSchemaFlowStepSnsIn]
|
|
373
|
+
createSourceParams.push(...flowSchemaOwnTopicFlowStep)
|
|
360
374
|
}
|
|
375
|
+
|
|
361
376
|
if (allLocalFlowSchemas.records.length) {
|
|
362
377
|
console.log("flowSchema Register");
|
|
363
378
|
const flowSchemaRegisterHandlerComplete = createFlowSchemaRegisterHandlerComplete(_izContext, saveFilePath);
|
|
@@ -385,6 +400,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
385
400
|
createSourceParams.push(...flowSchemaRegisters);
|
|
386
401
|
}
|
|
387
402
|
|
|
403
|
+
// console.log("createSourceParams flowSchema", createSourceParams)
|
|
388
404
|
return createSourceParams;
|
|
389
405
|
} catch (error) {
|
|
390
406
|
_izContext.logger.error('Error generating code with template flowSchema:', error);
|
|
@@ -52,6 +52,7 @@ function data(_izContext, srcPath) {
|
|
|
52
52
|
const functionName = upperCase(FUNCTION_NAME.flowSchemaRegister);
|
|
53
53
|
let functionNameConfig = upperCase(functionName) + upperCase(shortNameHandler(handlerType));
|
|
54
54
|
let additionalResourcePermission = defaultIamRolePerAction();
|
|
55
|
+
|
|
55
56
|
additionalResourcePermission.push(
|
|
56
57
|
createIamRole(
|
|
57
58
|
{
|
|
@@ -76,7 +77,8 @@ function data(_izContext, srcPath) {
|
|
|
76
77
|
]
|
|
77
78
|
},
|
|
78
79
|
[
|
|
79
|
-
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "WebSocketTask")
|
|
80
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "WebSocketTask"),
|
|
81
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "RegisterRecords ")
|
|
80
82
|
]
|
|
81
83
|
),
|
|
82
84
|
createIamRole(
|
|
@@ -42,7 +42,6 @@ function data(_izContext, srcPath) {
|
|
|
42
42
|
functionName: functionName,
|
|
43
43
|
handler: HANDLER.hdrSqs,
|
|
44
44
|
firstLetterUpperCase: upperCase,
|
|
45
|
-
roleName: SOURCE_GENERATE_IAM_ROLE.RegisterRole
|
|
46
45
|
},
|
|
47
46
|
setting: {
|
|
48
47
|
savePath: path.join(srcPath, SOURCE_PATH.flowSchemaRegister, 'source/'),
|
|
@@ -29,7 +29,7 @@ const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
|
|
|
29
29
|
|
|
30
30
|
const externalRequest = require('@izara_project/izara-core-library-external-request');
|
|
31
31
|
const sns = externalRequest.sns
|
|
32
|
-
const
|
|
32
|
+
const generatedCodeLibs = require("../../../libs/source/GenerateCodeLibs");
|
|
33
33
|
|
|
34
34
|
const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
|
|
35
35
|
const { NoRetryError } = require('@izara_project/izara-core-library-core')
|
|
@@ -61,6 +61,8 @@ module.exports.registerCompleteMain = async (
|
|
|
61
61
|
_izContext.logger.debug("WebSocketInvoke requestParams", requestParams)
|
|
62
62
|
_izContext.logger.debug("WebSocketInvoke callingFlowConfig", callingFlowConfig)
|
|
63
63
|
|
|
64
|
+
let connectionId = _izContext.correlationIds.get(consts.CONNECTION_ID);
|
|
65
|
+
|
|
64
66
|
// getflowSchema by using send topic name
|
|
65
67
|
// ! didn't got topicName from requestParams complete endpoint must send flowTag with identifiersTask
|
|
66
68
|
|
|
@@ -92,48 +94,48 @@ module.exports.registerCompleteMain = async (
|
|
|
92
94
|
const result = await externalRequest.lambda.invokeSync(_izContext,
|
|
93
95
|
await lambdaSharedLib.lambdaFunctionName(_izContext, "GetHdrInv"),
|
|
94
96
|
{
|
|
95
|
-
identifiers: await identifiersObject.
|
|
97
|
+
identifiers: await identifiersObject.identifiersFromIdentifiersConcat(_izContext, objType, requestParams.identifiersTask),
|
|
96
98
|
objectType: objType.objectType
|
|
97
99
|
}
|
|
98
100
|
)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
await generatedCodeLibs.postToConnection({ message: "not have record" }, connecttionId)
|
|
101
|
+
if (!result) {
|
|
102
|
+
await generatedCodeLibs.postToConnection({ message: "not have record" }, connectionId)
|
|
103
|
+
} else {
|
|
104
|
+
for (const [fieldName, fieldNameSetting] of Object.entries(objectSchema.fieldNames)) {
|
|
105
|
+
if (fieldNameSetting.hasOwnProperty("statusField") && fieldNameSetting.statusField === true) {
|
|
106
|
+
if (result.fields[fieldName] !== "complete" && result.fields[fieldName] !== "error") {
|
|
107
|
+
// if status is not complete or error will save data into table
|
|
108
|
+
await dynamodbSharedLib.putItem(_izContext,
|
|
109
|
+
await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
|
|
110
|
+
{
|
|
111
|
+
identifiersTask: requestParams.identifiersTask,
|
|
112
|
+
connectionId: connectionId
|
|
113
|
+
}
|
|
114
|
+
)
|
|
114
115
|
} else {
|
|
115
|
-
await generatedCodeLibs.postToConnection({ message: result },
|
|
116
|
+
await generatedCodeLibs.postToConnection({ message: result }, connectionId)
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
|
-
|
|
122
122
|
// check statusType
|
|
123
123
|
switch (flowSchema.statusType) {
|
|
124
124
|
case "statusField":
|
|
125
|
-
await getResult(flowSchema.objType
|
|
125
|
+
await getResult(flowSchema.objType);
|
|
126
126
|
break;
|
|
127
127
|
case "storedCache":
|
|
128
|
-
await getResult(flowSchema.objType
|
|
128
|
+
await getResult(flowSchema.objType);
|
|
129
129
|
break;
|
|
130
130
|
|
|
131
131
|
case "none":
|
|
132
132
|
|
|
133
133
|
let identifier = {};
|
|
134
|
-
if (requestParams.hasOwnProperty("identifiersField") && Array.isArray(requestParams.
|
|
135
|
-
for (const fieldNames of requestParams.
|
|
136
|
-
Object.assign(identifier, {
|
|
134
|
+
if (requestParams.hasOwnProperty("identifiersField") && Array.isArray(requestParams.identifiersField)) {
|
|
135
|
+
for (const fieldNames of requestParams.identifiersField) {
|
|
136
|
+
Object.assign(identifier, {
|
|
137
|
+
[fieldNames]: requestParams[fieldNames]
|
|
138
|
+
})
|
|
137
139
|
}
|
|
138
140
|
identifier = identifier;
|
|
139
141
|
} else {
|
|
@@ -142,27 +144,29 @@ module.exports.registerCompleteMain = async (
|
|
|
142
144
|
|
|
143
145
|
// get task before putItem
|
|
144
146
|
let tasks = await dynamodbSharedLib.query(_izContext,
|
|
145
|
-
await dynamodbSharedLib.tableName(_izContext, "
|
|
147
|
+
await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
|
|
146
148
|
{
|
|
147
149
|
identifiersTask: hash(identifier)
|
|
148
150
|
}
|
|
149
151
|
)
|
|
150
|
-
|
|
152
|
+
|
|
153
|
+
if (tasks.Items && tasks.Items.length > 0) {
|
|
151
154
|
await Promise.all(tasks.Items.map(async (task) => {
|
|
152
|
-
await generatedCodeLibs.postToConnection({ message: task }, task.
|
|
155
|
+
await generatedCodeLibs.postToConnection({ message: task }, task.connectionId)
|
|
153
156
|
}))
|
|
157
|
+
await generatedCodeLibs.postToConnection({ message: tasks.Items[0] }, connectionId)
|
|
154
158
|
} else {
|
|
155
159
|
await dynamodbSharedLib.putItem(_izContext,
|
|
156
160
|
await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
|
|
157
161
|
{
|
|
158
162
|
identifiersTask: hash(identifier),
|
|
159
|
-
|
|
163
|
+
connectionId: connectionId
|
|
160
164
|
}
|
|
161
165
|
)
|
|
162
166
|
}
|
|
163
167
|
break
|
|
164
168
|
default:
|
|
165
|
-
throw new NoRetryError(`statusType not found ${
|
|
169
|
+
throw new NoRetryError(`statusType not found ${flowSchema.statusType}`)
|
|
166
170
|
}
|
|
167
171
|
|
|
168
172
|
} catch (err) {
|
|
@@ -32,29 +32,12 @@ const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, defaultIamRolePerAction, DYN
|
|
|
32
32
|
const createRegisterTable = (_izContext, srcPath) => {
|
|
33
33
|
let additionalResourcePermission = defaultIamRolePerAction();
|
|
34
34
|
const tableName = "RegisterRecords";
|
|
35
|
-
additionalResourcePermission.push(
|
|
36
|
-
createIamRole(
|
|
37
|
-
{
|
|
38
|
-
[RESOURCE_CLASSES.dynamoDbTable]: [
|
|
39
|
-
DYNAMO_RESOURCE.putItem,
|
|
40
|
-
DYNAMO_RESOURCE.getItem,
|
|
41
|
-
DYNAMO_RESOURCE.query,
|
|
42
|
-
DYNAMO_RESOURCE.deleteItem,
|
|
43
|
-
DYNAMO_RESOURCE.updateItem
|
|
44
|
-
]
|
|
45
|
-
},
|
|
46
|
-
[
|
|
47
|
-
resourceNames(RESOURCE_CLASSES.dynamoDbTable, tableName)
|
|
48
|
-
]
|
|
49
|
-
),
|
|
50
|
-
);
|
|
51
35
|
|
|
52
36
|
return [{
|
|
53
37
|
templatePath: templatePath,
|
|
54
38
|
templateData: {
|
|
55
39
|
tableName: tableName,
|
|
56
40
|
resourceName: tableName,
|
|
57
|
-
roleName: SOURCE_GENERATE_IAM_ROLE.RegisterRole,
|
|
58
41
|
additionalResourcePermission,
|
|
59
42
|
attributes: [
|
|
60
43
|
{
|
|
@@ -50,7 +50,6 @@ function createDataForSnsIn(_izContext, srcPath) {
|
|
|
50
50
|
templateData: {
|
|
51
51
|
queueName: upperCase(FUNCTION_NAME.flowSchemaRegister),
|
|
52
52
|
firstLetterUpperCase: upperCase,
|
|
53
|
-
roleName: SOURCE_GENERATE_IAM_ROLE.RegisterRole,
|
|
54
53
|
},
|
|
55
54
|
setting: {
|
|
56
55
|
initialData: "Resources:\n",
|
|
@@ -56,9 +56,7 @@ function createDataForSubscriptionOutAll(_izContext, allLocalFlowSchemas, srcPat
|
|
|
56
56
|
}
|
|
57
57
|
let queueName;
|
|
58
58
|
if (flowSchema.outputTopic) {
|
|
59
|
-
|
|
60
|
-
// queueName = flowStepOut[3] + flowStepOut[2]
|
|
61
|
-
queueName = flowStepOut[0] + flowSchema.flowTag + "Complete";
|
|
59
|
+
queueName = upperCase(flowSchema.flowTag);
|
|
62
60
|
}
|
|
63
61
|
|
|
64
62
|
if (queueName) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
##===== [Topic In]
|
|
2
|
-
|
|
2
|
+
SubscriptionOut<%- queueName %>:
|
|
3
3
|
Type: AWS::SNS::Subscription
|
|
4
4
|
Properties:
|
|
5
|
-
TopicArn: !Ref <%- queueName %>
|
|
5
|
+
TopicArn: !Ref Out<%- queueName %>
|
|
6
6
|
Endpoint: "arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- endpoint %>"
|
|
7
7
|
Protocol: "sqs"
|
|
8
8
|
<%_ function firstLetterUpperCase(text){
|
|
@@ -91,35 +91,6 @@ async function data(_izContext, allLocalFlowSchemas, srcPath) {
|
|
|
91
91
|
)
|
|
92
92
|
)
|
|
93
93
|
|
|
94
|
-
let tableStoredCacheList = new Set();
|
|
95
|
-
await Promise.all(allLocalFlowSchemas.records.map(async (flowSchema) => {
|
|
96
|
-
if (flowSchema.statusType === "storedCache") {
|
|
97
|
-
let objectSchema = await getLocalObjectSchemas(_izContext, [flowSchema.objType.objectType], path.join(srcPath, "./schemas")).then(res => res.records[0]);
|
|
98
|
-
for (const storageResource of Object.values(objectSchema.storageResources)) {
|
|
99
|
-
if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
|
|
100
|
-
tableStoredCacheList.add(storageResource.tableName);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}))
|
|
105
|
-
if (tableStoredCacheList.size > 0) {
|
|
106
|
-
let tableNames = [...tableStoredCacheList]
|
|
107
|
-
additionalResourcePermission.push(
|
|
108
|
-
createIamRole(
|
|
109
|
-
{
|
|
110
|
-
[RESOURCE_CLASSES.dynamoDbTable]: [
|
|
111
|
-
DYNAMO_RESOURCE.getItem,
|
|
112
|
-
// DYNAMO_RESOURCE.putItem,
|
|
113
|
-
// DYNAMO_RESOURCE.query,
|
|
114
|
-
// DYNAMO_RESOURCE.deleteItem,
|
|
115
|
-
// DYNAMO_RESOURCE.updateItem
|
|
116
|
-
]
|
|
117
|
-
},
|
|
118
|
-
tableNames.map(tableName => resourceNames(RESOURCE_CLASSES.dynamoDbTable, tableName))
|
|
119
|
-
)
|
|
120
|
-
)
|
|
121
|
-
}
|
|
122
|
-
|
|
123
94
|
return [{
|
|
124
95
|
templatePath: templatePath,
|
|
125
96
|
templateData: {
|
|
@@ -26,6 +26,7 @@ const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
|
26
26
|
// const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
|
|
27
27
|
const { postToConnection } = require("../../../libs/source/GenerateCodeLibs");
|
|
28
28
|
const { <%- functionName%>Main } = require("./<%- firstLetterUpperCase(functionName) %>_Main");
|
|
29
|
+
const izara = require("@izara_project/izara-middleware");
|
|
29
30
|
|
|
30
31
|
module.exports.main = middlewareHandler.wrap(async (event, context, callback) => {
|
|
31
32
|
|
|
@@ -64,10 +65,6 @@ module.exports.main = middlewareHandler.wrap(async (event, context, callback) =>
|
|
|
64
65
|
//(<additionalParams>)
|
|
65
66
|
//(</additionalParams>)
|
|
66
67
|
)
|
|
67
|
-
await postToConnection(
|
|
68
|
-
{ message: result },
|
|
69
|
-
connectionId
|
|
70
|
-
)
|
|
71
68
|
break
|
|
72
69
|
}
|
|
73
70
|
} else {
|
|
@@ -75,11 +72,12 @@ module.exports.main = middlewareHandler.wrap(async (event, context, callback) =>
|
|
|
75
72
|
// await postMessage({ message: event.message }, connId);
|
|
76
73
|
await postToConnection({ message: event.message }, connId);
|
|
77
74
|
}
|
|
75
|
+
return izara.response.webSocketSuccess()
|
|
78
76
|
} catch (err) {
|
|
79
77
|
const connId = event.requestContext.connectionId
|
|
80
78
|
event._izContext.logger.error('Error, WebSocket: ', err);
|
|
81
|
-
// await sendErrorMessage({ message: err.message }, connId);
|
|
82
79
|
await postToConnection({ message: err.message }, connId);
|
|
80
|
+
return (izara.response.failure(err));
|
|
83
81
|
}
|
|
84
82
|
});
|
|
85
83
|
<%_ const join = require('path').join _%>
|