@izara_project/izara-market-library-service-schemas 1.0.49 → 1.0.50
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/index.js +3 -1
- package/package.json +3 -3
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +28 -29
- package/src/GenerateCodeLibs/src/TranslateIdsLibs.js +9 -6
- package/src/MainLibs/src/Consts.js +29 -23
- package/src/MainLibs/src/Utils.js +4 -4
- package/src/reStructure/GenerateCode.js +3 -3
- package/src/reStructure/TemplateData/EndpointPerService/handler/api/template.ejs +1 -1
- package/src/reStructure/TemplateData/EndpointPerService/handler/dsq/template.ejs +2 -2
- package/src/reStructure/TemplateData/EndpointPerService/handler/inv/template.ejs +1 -1
- package/src/reStructure/TemplateData/EndpointPerService/handler/sqs/template.ejs +3 -3
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +24 -8
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +8 -3
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +7 -2
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +7 -2
- package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +0 -1
- package/src/reStructure/TemplateData/findData/GetByStorage/getByDynamo.ejs +5 -4
- package/src/reStructure/TemplateData/findData/GetByStorage/getByGraph.ejs +12 -32
- package/src/reStructure/TemplateData/findData/findDataYaml/data.js +32 -62
- package/src/reStructure/TemplateData/findData/generateTemplateData.js +2 -2
- package/src/reStructure/TemplateData/findData/handler/template.ejs +1 -2
- package/src/reStructure/TemplateData/findData/mainFunction/data.js +19 -12
- package/src/reStructure/TemplateData/findData/mainFunction/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/externalTopic/Complete/mainFunction/template.ejs +0 -15
- package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/mainFunction/data.js +4 -3
- package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/mainFunction/template.ejs +9 -42
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/template.ejs +0 -10
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +2 -14
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +2 -1
- package/src/reStructure/TemplateData/flowSchema/flowStep/functionYaml/data.js +14 -17
- package/src/reStructure/TemplateData/flowSchema/flowStep/handler/data.js +15 -18
- package/src/reStructure/TemplateData/flowSchema/flowStep/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowStep/mainFunction/data.js +16 -19
- package/src/reStructure/TemplateData/flowSchema/flowStep/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowStep/sns-in/data.js +21 -19
- package/src/reStructure/TemplateData/flowSchema/flowStep/sns-in/template.ejs +20 -6
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +33 -12
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/functionYaml/data.js +128 -0
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/functionYaml/templateApi.ejs +20 -0
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/functionYaml/templateInv.ejs +13 -0
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/handler/data.js +85 -0
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/handler/templateApi.ejs +80 -0
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/handler/templateInv.ejs +47 -0
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/mainFunction/data.js +74 -0
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/mainFunction/template.ejs +96 -0
- package/src/reStructure/TemplateData/flowSchema/register/complete/handler/template.ejs +1 -0
- package/src/reStructure/TemplateData/flowSchema/register/complete/mainFunction/template.ejs +6 -7
- package/src/reStructure/TemplateData/flowSchema/templateBystatusType/storedCacheTemplate.ejs +4 -5
- package/src/reStructure/TemplateData/flowSchema/templateBystatusType/triggerCacheTemplate.ejs +2 -7
- package/src/reStructure/TemplateData/generateRole/data.js +0 -20
- package/src/reStructure/TemplateData/generateRole/template.ejs +4 -2
- package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +18 -7
- package/src/reStructure/TemplateData/perActionComplete/get/mainFunction/template.ejs +10 -10
- package/src/reStructure/TemplateData/perActionComplete/update/mainFunction/template.ejs +10 -10
- package/src/reStructure/TemplateData/processLogical/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/propertyValueSchema/objectPropertyValueSchema/data.js +2 -2
- package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js +5 -5
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +3 -3
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/mainFunction/template.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/mainFunction/template.ejs +2 -2
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +2 -2
|
@@ -52,22 +52,19 @@ function data(_izContext, flowSchema, srcPath) {
|
|
|
52
52
|
if (flowSchema.hasOwnProperty("flowSteps")) {
|
|
53
53
|
let flowSteps = Object.keys(flowSchema.flowSteps)
|
|
54
54
|
if (flowSteps.length && flowSteps.length > 0) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
let createSource = createSourceParams(_izContext, flowSteps[i], srcPath)
|
|
62
|
-
createSource && resultCreateSource.push(createSource);
|
|
63
|
-
}
|
|
55
|
+
if (flowSchema.event.includes("ownTopic") || flowSchema.event.includes("extTopic")) {
|
|
56
|
+
if (flowSteps.includes("In") && flowSteps.includes("Out")) {
|
|
57
|
+
if (flowSteps.length > 2) {
|
|
58
|
+
for (let i = 2; i < flowSteps.length; i++) {
|
|
59
|
+
let createSource = createSourceParams(_izContext, flowSchema.flowTag, flowSteps[i], srcPath)
|
|
60
|
+
createSource && resultCreateSource.push(createSource);
|
|
64
61
|
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
62
|
+
}
|
|
63
|
+
} else if (flowSteps.includes("In") && !flowSchema.outputTopic) {
|
|
64
|
+
if (flowSteps.length > 1) {
|
|
65
|
+
for (let i = 1; i < flowSteps.length; i++) {
|
|
66
|
+
let createSource = createSourceParams(_izContext, flowSchema.flowTag, flowSteps[i], srcPath)
|
|
67
|
+
createSource && resultCreateSource.push(createSource);
|
|
71
68
|
}
|
|
72
69
|
}
|
|
73
70
|
}
|
|
@@ -77,7 +74,7 @@ function data(_izContext, flowSchema, srcPath) {
|
|
|
77
74
|
return resultCreateSource
|
|
78
75
|
}
|
|
79
76
|
|
|
80
|
-
function createSourceParams(_izContext, flowStep, srcPath) {
|
|
77
|
+
function createSourceParams(_izContext, flowTag, flowStep, srcPath) {
|
|
81
78
|
let functionName = upperCase(flowStep);
|
|
82
79
|
let handlerType = upperCase(HANDLER.hdrSqs);
|
|
83
80
|
let topicIn = upperCase(flowStep);
|
|
@@ -107,7 +104,7 @@ function createSourceParams(_izContext, flowStep, srcPath) {
|
|
|
107
104
|
return {
|
|
108
105
|
templatePath: templatePath,
|
|
109
106
|
templateData: {
|
|
110
|
-
resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, upperCase(
|
|
107
|
+
resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, upperCase(flowTag), "source/"),
|
|
111
108
|
functionName,
|
|
112
109
|
handlerType,
|
|
113
110
|
additionalResourcePermission,
|
|
@@ -20,7 +20,7 @@ const path = require('path');
|
|
|
20
20
|
const { FLOW_SCHEMA_HOOK_STATE, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
21
21
|
const { SOURCE_PATH, FUNCTION_NAME } = require('../../../../../MainLibs/src/Consts');
|
|
22
22
|
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils")
|
|
23
|
-
const templatePath = path.join(__dirname, "template.ejs")
|
|
23
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* receive objectSchema
|
|
@@ -35,23 +35,20 @@ function data(_izContext, flowSchema, srcPath) {
|
|
|
35
35
|
let resultCreateParam = [];
|
|
36
36
|
if (flowSchema.hasOwnProperty("flowSteps")) {
|
|
37
37
|
let flowSteps = Object.keys(flowSchema.flowSteps);
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
let createSource = createParamsForCreateSource(_izContext, upperCase(flowSchema.flowTag), upperCase(flowSteps[i]), srcPath);
|
|
46
|
-
createSource && resultCreateParam.push(createSource)
|
|
47
|
-
}
|
|
38
|
+
if (flowSchema.event.includes("ownTopic") || flowSchema.event.includes("extTopic")) {
|
|
39
|
+
if (flowSteps.length && flowSteps.length > 0) {
|
|
40
|
+
if (flowSteps.includes("In") && flowSteps.includes("Out")) {
|
|
41
|
+
if (flowSteps.length > 2) {
|
|
42
|
+
for (let i = 2; i < flowSteps.length; i++) {
|
|
43
|
+
let createSource = createParamsForCreateSource(_izContext, upperCase(flowSchema.flowTag), upperCase(flowSteps[i]), srcPath);
|
|
44
|
+
createSource && resultCreateParam.push(createSource)
|
|
48
45
|
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
}
|
|
47
|
+
} else if (flowSteps.includes("In") && !flowSchema.outputTopic) {
|
|
48
|
+
if (flowSteps.length > 1) {
|
|
49
|
+
for (let i = 1; i < flowSteps.length; i++) {
|
|
50
|
+
let createSource = createParamsForCreateSource(_izContext, upperCase(flowSchema.flowTag), upperCase(flowSteps[i]), srcPath);
|
|
51
|
+
createSource && resultCreateParam.push(createSource)
|
|
55
52
|
}
|
|
56
53
|
}
|
|
57
54
|
}
|
|
@@ -74,7 +71,7 @@ function createParamsForCreateSource(_izContext, flowTag, flowStep, srcPath) {
|
|
|
74
71
|
queueName
|
|
75
72
|
},
|
|
76
73
|
setting: {
|
|
77
|
-
savePath: path.join(srcPath, SOURCE_PATH.flowSchema, upperCase(
|
|
74
|
+
savePath: path.join(srcPath, SOURCE_PATH.flowSchema, upperCase(flowTag), "source/"),
|
|
78
75
|
saveFileName: `${upperCase(flowStep)}_${handlerType}`,
|
|
79
76
|
fileExtension: ".js",
|
|
80
77
|
isAppend: false
|
|
@@ -79,7 +79,7 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
79
79
|
Logger.debug('after Promise.all(recordPromises) in handler');
|
|
80
80
|
|
|
81
81
|
} catch (err) {
|
|
82
|
-
Logger.error('Unhandled Error,
|
|
82
|
+
Logger.error('Unhandled Error, <%- functionName %>: ', err);
|
|
83
83
|
throw (err);
|
|
84
84
|
}
|
|
85
85
|
});
|
|
@@ -33,7 +33,7 @@ const {
|
|
|
33
33
|
SOURCE_GENERATE_IAM_ROLE,
|
|
34
34
|
HANDLER
|
|
35
35
|
} = require('../../../../../MainLibs/src/Consts');
|
|
36
|
-
const templatePath = path.join(__dirname, "template.ejs");
|
|
36
|
+
const templatePath = path.join(__dirname, "./template.ejs");
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
/**
|
|
@@ -50,22 +50,19 @@ function data(_izContext, flowSchema, srcPath) {
|
|
|
50
50
|
if (flowSchema.hasOwnProperty("flowSteps")) {
|
|
51
51
|
let flowSteps = Object.keys(flowSchema.flowSteps)
|
|
52
52
|
if (flowSteps.length && flowSteps.length > 0) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
let createSource = createParamsForCreateSource(_izContext, flowSchema.flowTag, flowSteps[i], srcPath)
|
|
60
|
-
createSource && resultCreateSource.push(createSource);
|
|
61
|
-
}
|
|
53
|
+
if (flowSchema.event.includes("ownTopic") || flowSchema.event.includes("extTopic")) {
|
|
54
|
+
if (flowSteps.includes("In") && flowSteps.includes("Out")) {
|
|
55
|
+
if (flowSteps.length > 2) {
|
|
56
|
+
for (let i = 2; i < flowSteps.length; i++) {
|
|
57
|
+
let createSource = createParamsForCreateSource(_izContext, flowSchema.flowTag, flowSteps[i], srcPath)
|
|
58
|
+
createSource && resultCreateSource.push(createSource);
|
|
62
59
|
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
}
|
|
61
|
+
} else if (flowSteps.includes("In") && !flowSchema.outputTopic) {
|
|
62
|
+
if (flowSteps.length > 1) {
|
|
63
|
+
for (let i = 1; i < flowSteps.length; i++) {
|
|
64
|
+
let createSource = createParamsForCreateSource(_izContext, flowSchema.flowTag, flowSteps[i], srcPath)
|
|
65
|
+
createSource && resultCreateSource.push(createSource);
|
|
69
66
|
}
|
|
70
67
|
}
|
|
71
68
|
}
|
|
@@ -78,7 +75,7 @@ function data(_izContext, flowSchema, srcPath) {
|
|
|
78
75
|
function createParamsForCreateSource(_izContext, flowTag, flowStep, srcPath) {
|
|
79
76
|
let functionName = upperCase(flowTag)
|
|
80
77
|
let topicArn = `${upperCase(flowStep)}_In`
|
|
81
|
-
|
|
78
|
+
|
|
82
79
|
return {
|
|
83
80
|
templatePath: templatePath,
|
|
84
81
|
templateData: {
|
|
@@ -86,8 +83,8 @@ function createParamsForCreateSource(_izContext, flowTag, flowStep, srcPath) {
|
|
|
86
83
|
functionName
|
|
87
84
|
},
|
|
88
85
|
setting: {
|
|
89
|
-
savePath: path.join(srcPath, SOURCE_PATH.flowSchema, upperCase(
|
|
90
|
-
saveFileName: `${upperCase(flowStep)}
|
|
86
|
+
savePath: path.join(srcPath, SOURCE_PATH.flowSchema, upperCase(flowTag), "source/"),
|
|
87
|
+
saveFileName: `${upperCase(flowStep)}_Main`,
|
|
91
88
|
fileExtension: ".js",
|
|
92
89
|
isAppend: false
|
|
93
90
|
}
|
|
@@ -48,27 +48,29 @@ function createDataForDefaultSnsInSqs(_izContext, flowSchema, srcPath) {
|
|
|
48
48
|
if (flowSchema.hasOwnProperty("flowSteps")) {
|
|
49
49
|
let flowSteps = Object.keys(flowSchema.flowSteps);
|
|
50
50
|
if (flowSteps.length && flowSteps.length > 0) {
|
|
51
|
-
if (flowSchema.
|
|
52
|
-
if (
|
|
53
|
-
if (flowSteps.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
51
|
+
if (flowSchema.event.includes("ownTopic") || flowSchema.event.includes("extTopic")) {
|
|
52
|
+
if (flowSchema.outputTopic) {
|
|
53
|
+
if (flowSteps.includes("In") && flowSteps.includes("Out")) {
|
|
54
|
+
if (flowSteps.length > 2) {
|
|
55
|
+
for (let i = 2; i < flowSteps.length; i++) {
|
|
56
|
+
generatedSnsTopicInForFlowSchema.add(
|
|
57
|
+
{
|
|
58
|
+
queueName: upperCase(flowSteps[i])
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
}
|
|
60
62
|
}
|
|
61
63
|
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
} else {
|
|
65
|
+
if (flowSteps.includes("In")) {
|
|
66
|
+
if (flowSteps.length > 1) {
|
|
67
|
+
for (let i = 2; i < flowSteps.length; i++) {
|
|
68
|
+
generatedSnsTopicInForFlowSchema.add(
|
|
69
|
+
{
|
|
70
|
+
queueName: upperCase(flowSteps[i])
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
}
|
|
72
74
|
}
|
|
73
75
|
}
|
|
74
76
|
}
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
##===== [Create topic in]
|
|
2
|
+
In<%- queueName %>:
|
|
3
|
+
Type: AWS::SNS::Topic
|
|
4
|
+
Properties:
|
|
5
|
+
DisplayName: "SNS Message in"
|
|
6
|
+
TopicName: ${self:custom.iz_serviceTag}_${self:custom.iz_stage}_<%- queueName %>
|
|
7
|
+
##===== SNS Subscription
|
|
8
|
+
##===== [Topic In]
|
|
9
|
+
SubscriptionIn<%- queueName %>:
|
|
10
|
+
Type: AWS::SNS::Subscription
|
|
11
|
+
Properties:
|
|
12
|
+
TopicArn: !Ref In<%- queueName %>
|
|
13
|
+
Endpoint: "arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqs"
|
|
14
|
+
Protocol: "sqs"
|
|
1
15
|
##===== [Queue]
|
|
2
16
|
<%- queueName %>HdrSqs:
|
|
3
17
|
Type: "AWS::SQS::Queue"
|
|
@@ -37,9 +51,9 @@
|
|
|
37
51
|
#<#<%- firstLetterUpperCase(queueName) %>QueueSetting#>
|
|
38
52
|
#<#/<%- firstLetterUpperCase(queueName) %>QueueSetting#>
|
|
39
53
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
54
|
+
<%_ function firstLetterUpperCase(text){
|
|
55
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
56
|
+
} _%>
|
|
57
|
+
<%_ function firstLetterLowerCase(str) {
|
|
58
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
59
|
+
} _%>
|
|
@@ -92,7 +92,7 @@ const createWebSocketCompleteMainMainFunction = require("./webSocketComplete/mai
|
|
|
92
92
|
const createWebSocketCompleteMainSqs = require('./webSocketComplete/sqs/data');
|
|
93
93
|
// flowSchema OwnTopicEndpoint component
|
|
94
94
|
|
|
95
|
-
const
|
|
95
|
+
const createFlowSchemaOwnTopicEndpointFunctionYaml = require('./flowSchemaOwnTopic/EndpointComponent/functionYaml/data');
|
|
96
96
|
const createFlowSchemaOwnTopicEndpointHandler = require('./flowSchemaOwnTopic/EndpointComponent/handler/data');
|
|
97
97
|
const createFlowSchemaOwnTopicEndpointMainFunction = require('./flowSchemaOwnTopic/EndpointComponent/mainFunction/data');
|
|
98
98
|
|
|
@@ -113,6 +113,11 @@ const createFlowSchemaEventBridgeFunctionYaml = require('./eventBridge/functionY
|
|
|
113
113
|
const createFlowSchemaEventBridgeHandler = require('./eventBridge/handler/inv/data');
|
|
114
114
|
const createFlowSchemaEventBridgeMainFunction = require('./eventBridge/mainFunction/data');
|
|
115
115
|
|
|
116
|
+
// flowSchema lambdaSync components
|
|
117
|
+
const createFlowSchemaLambdaSyncFunctionYaml = require('./lambdaSync/functionYaml/data');
|
|
118
|
+
const createFlowSchemaLambdaSyncHandler = require('./lambdaSync/handler/data');
|
|
119
|
+
const createFlowSchemaLambdaSyncMainFunction = require('./lambdaSync/mainFunction/data');
|
|
120
|
+
|
|
116
121
|
const createAwaitingMultipleStepDynamoDbData = require('./dynamoDb/data');
|
|
117
122
|
// create record status Field Complete
|
|
118
123
|
const createCreateObjectCompleteFuntionYaml = require('./CreateRecordComplete/functionYaml/data');
|
|
@@ -174,6 +179,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
174
179
|
const webSocketGenerateCodeLibs = createWebSocketGenerateCodeLibs(_izContext, flowSchema, saveFilePath)
|
|
175
180
|
createSourceParams.push(...webSocketGenerateCodeLibs)
|
|
176
181
|
|
|
182
|
+
// event has [s3, extTopic, ownTopic, eventBridge, lambdaSync]
|
|
177
183
|
for (const event of flowSchema.event) {
|
|
178
184
|
if (event.includes("s3")) {
|
|
179
185
|
const reservedDataTable = createReservedDataMainTable(_izContext, saveFilePath);
|
|
@@ -275,9 +281,9 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
275
281
|
const externalTopicSnsInSqs = createExternalTopicSnsInSqs(_izContext, flowSchema, saveFilePath);
|
|
276
282
|
const externalTopicSnsOut = createExternalTopicSnsOut(_izContext, flowSchema, saveFilePath);
|
|
277
283
|
|
|
278
|
-
const externalTopicCompleteFunctionYml = createExternalSqsCompleteFunctionYaml(_izContext, flowSchema, saveFilePath);
|
|
279
|
-
const externalTopicCompleteHandler = createExternalSqsCompleteHandler(_izContext, flowSchema, saveFilePath);
|
|
280
|
-
const externalTopicCompleteMainFunction = createExternalSqsCompleteMainFunction(_izContext, flowSchema, saveFilePath);
|
|
284
|
+
// const externalTopicCompleteFunctionYml = createExternalSqsCompleteFunctionYaml(_izContext, flowSchema, saveFilePath);
|
|
285
|
+
// const externalTopicCompleteHandler = createExternalSqsCompleteHandler(_izContext, flowSchema, saveFilePath);
|
|
286
|
+
// const externalTopicCompleteMainFunction = createExternalSqsCompleteMainFunction(_izContext, flowSchema, saveFilePath);
|
|
281
287
|
// Group related resources for better organization
|
|
282
288
|
const externalTopic = [
|
|
283
289
|
...externalSqsFunctionYaml,
|
|
@@ -285,7 +291,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
285
291
|
...externalSqsMainFunction,
|
|
286
292
|
...externalTopicSnsInSqs,
|
|
287
293
|
...externalTopicSnsOut,
|
|
288
|
-
...externalTopicCompleteFunctionYml, ...externalTopicCompleteHandler, ...externalTopicCompleteMainFunction
|
|
294
|
+
// ...externalTopicCompleteFunctionYml, ...externalTopicCompleteHandler, ...externalTopicCompleteMainFunction
|
|
289
295
|
];
|
|
290
296
|
|
|
291
297
|
createSourceParams.push(...externalTopic)
|
|
@@ -299,23 +305,23 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
299
305
|
const flowSchemaOwnTopicComponent = [...flowSchemaOwnTopicFunctionYaml, ...flowSchemaOwnTopicHandler, ...flowSchemaOwnTopicMainFunction]
|
|
300
306
|
|
|
301
307
|
// flowSchemaOwnTopic Endpoint
|
|
302
|
-
const
|
|
308
|
+
const flowSchemaOwnTopicEndpointFunctionYaml = await createFlowSchemaOwnTopicEndpointFunctionYaml(_izContext, flowSchema, saveFilePath);
|
|
303
309
|
const flowSchemaOwnTopicEndpointHandler = createFlowSchemaOwnTopicEndpointHandler(_izContext, flowSchema, saveFilePath);
|
|
304
310
|
const flowSchemaOwnTopicEndpointMainFunction = await createFlowSchemaOwnTopicEndpointMainFunction(_izContext, flowSchema, saveFilePath);
|
|
305
|
-
const flowSchemaOwnTopicEndpointComponent = [...
|
|
311
|
+
const flowSchemaOwnTopicEndpointComponent = [...flowSchemaOwnTopicEndpointFunctionYaml, ...flowSchemaOwnTopicEndpointHandler, ...flowSchemaOwnTopicEndpointMainFunction]
|
|
306
312
|
|
|
307
313
|
// flowSchemaOwnTopic EndpointComplete
|
|
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];
|
|
314
|
+
// const flowSchemaOwnTopicEndpointCompleteFuntionYaml = createFlowSchemaOwnTopicEndpointCompleteFuntionYaml(_izContext, flowSchema, saveFilePath);
|
|
315
|
+
// const flowSchemaOwnTopicEndpointCompleteHandler = createFlowSchemaOwnTopicEndpointCompleteHandler(_izContext, flowSchema, saveFilePath);
|
|
316
|
+
// const flowSchemaOwnTopicEndpointCompleteMainFunction = createFlowSchemaOwnTopicEndpointCompleteMainFunction(_izContext, flowSchema, saveFilePath);
|
|
317
|
+
// const flowSchemaOwnTopicEndpointCompleteComponent = [...flowSchemaOwnTopicEndpointCompleteFuntionYaml, ...flowSchemaOwnTopicEndpointCompleteHandler, ...flowSchemaOwnTopicEndpointCompleteMainFunction];
|
|
312
318
|
|
|
313
319
|
const flowSchemaOwnTopicQueue = createFlowSchemaOwnTopicQueue(_izContext, flowSchema, saveFilePath);
|
|
314
320
|
const flowSchemaOwnTopicSnsOut = createFlowSchemaOwnTopicSnsOut(_izContext, flowSchema, saveFilePath);
|
|
315
321
|
|
|
316
322
|
// Group the resources
|
|
317
323
|
const ownTopicResources = [
|
|
318
|
-
...flowSchemaOwnTopicComponent, ...flowSchemaOwnTopicEndpointComponent, ...flowSchemaOwnTopicQueue, ...flowSchemaOwnTopicSnsOut,
|
|
324
|
+
...flowSchemaOwnTopicComponent, ...flowSchemaOwnTopicEndpointComponent, ...flowSchemaOwnTopicQueue, ...flowSchemaOwnTopicSnsOut, /*...flowSchemaOwnTopicEndpointCompleteComponent */
|
|
319
325
|
];
|
|
320
326
|
|
|
321
327
|
|
|
@@ -338,9 +344,24 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
338
344
|
// console.log("event eventBridge generated", JSON.stringify(eventBridgeResources, null, 2))
|
|
339
345
|
console.log("event eventBridge generated")
|
|
340
346
|
createSourceParams.push(...eventBridgeResources);
|
|
347
|
+
} else if (event.includes("lambdaSync")) {
|
|
348
|
+
const flowSchemaLambdaSyncFunctionYaml = await createFlowSchemaLambdaSyncFunctionYaml(_izContext, flowSchema, saveFilePath);
|
|
349
|
+
const flowSchemaLambdaSyncHandler = createFlowSchemaLambdaSyncHandler(_izContext, flowSchema, saveFilePath);
|
|
350
|
+
const flowSchemaLambdaSyncMainFunction = await createFlowSchemaLambdaSyncMainFunction(_izContext, flowSchema, saveFilePath);
|
|
351
|
+
|
|
352
|
+
// Group the resources
|
|
353
|
+
const lambdaSyncResources = [
|
|
354
|
+
...flowSchemaLambdaSyncFunctionYaml,
|
|
355
|
+
...flowSchemaLambdaSyncHandler,
|
|
356
|
+
...flowSchemaLambdaSyncMainFunction
|
|
357
|
+
];
|
|
358
|
+
|
|
359
|
+
console.log("event lambdaSync generated")
|
|
360
|
+
createSourceParams.push(...lambdaSyncResources);
|
|
341
361
|
}
|
|
342
362
|
}
|
|
343
363
|
|
|
364
|
+
// statusType enum [storedCache, statusField]
|
|
344
365
|
if (flowSchema.statusType === "storedCache") {
|
|
345
366
|
const flowSchemaDynamoDb = createAwaitingMultipleStepDynamoDbData(_izContext, flowSchema, allLocalObjectSchemas, saveFilePath)
|
|
346
367
|
console.log("generated code storedCache flowSchema")
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
const path = require('path');
|
|
20
|
+
|
|
21
|
+
const { FLOW_SCHEMA_HOOK_STATE, ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
22
|
+
const { firstLetterUpperCase: upperCase } = require('../../../../../MainLibs/src/Utils')
|
|
23
|
+
const {
|
|
24
|
+
SOURCE_PATH,
|
|
25
|
+
defaultIamRolePerAction,
|
|
26
|
+
createIamRole,
|
|
27
|
+
RESOURCE_CLASSES,
|
|
28
|
+
SNS_RESOURCE,
|
|
29
|
+
resourceNames,
|
|
30
|
+
DYNAMO_RESOURCE,
|
|
31
|
+
SAVE_FILE_NAME,
|
|
32
|
+
FUNCTION_NAME,
|
|
33
|
+
shortNameHandler,
|
|
34
|
+
externalResourceYaml,
|
|
35
|
+
SOURCE_GENERATE_IAM_ROLE,
|
|
36
|
+
SQS_RESOURCE,
|
|
37
|
+
LAMBDA_RESOURCE
|
|
38
|
+
} = require('../../../../../MainLibs/src/Consts');
|
|
39
|
+
const { NoRetryError } = require('@izara_project/izara-core-library-core');
|
|
40
|
+
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas').getObjectSchema;
|
|
41
|
+
|
|
42
|
+
const templatePathInv = path.join(__dirname, "templateInv.ejs");
|
|
43
|
+
const templatePathApi = path.join(__dirname, "templateApi.ejs");
|
|
44
|
+
/**
|
|
45
|
+
* receive objectSchema
|
|
46
|
+
* create data for WebScoket handler template
|
|
47
|
+
*
|
|
48
|
+
* @param {Object} objectSchema
|
|
49
|
+
* @return {{templatePath, templateData,setting}}
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
async function data(_izContext, flowSchema, srcPath) {
|
|
53
|
+
let returnCreateSource = [];
|
|
54
|
+
returnCreateSource.push(await createSourceParamsInvoke(_izContext, flowSchema, srcPath))
|
|
55
|
+
if (flowSchema.externalEndpoint) {
|
|
56
|
+
returnCreateSource.push(await createSourceParamsApi(_izContext, flowSchema, srcPath))
|
|
57
|
+
}
|
|
58
|
+
return returnCreateSource
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function createSourceParamsInvoke(_izContext, flowSchema, srcPath) {
|
|
62
|
+
let functionName = upperCase(flowSchema.flowTag)
|
|
63
|
+
let handlerType = upperCase(HANDLER.hdrInv)
|
|
64
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
65
|
+
let tableName = null;
|
|
66
|
+
if (flowSchema.statusType === "storedCache") {
|
|
67
|
+
let objectSchema = await getObjectSchema.getLocalObjectSchemas(_izContext, [flowSchema.objType.objectType], path.join(srcPath, "./schemas")).then(res => res.records[0]);
|
|
68
|
+
for (const storageResource of Object.values(objectSchema.storageResources)) {
|
|
69
|
+
if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
|
|
70
|
+
tableName = storageResource.tableName
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
templatePath: templatePathInv,
|
|
77
|
+
templateData: {
|
|
78
|
+
resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, upperCase(flowSchema.flowTag), "source/"),
|
|
79
|
+
functionName,
|
|
80
|
+
handlerType,
|
|
81
|
+
additionalResourcePermission,
|
|
82
|
+
functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
|
|
83
|
+
roleName: upperCase(flowSchema.flowTag)
|
|
84
|
+
},
|
|
85
|
+
setting: {
|
|
86
|
+
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
87
|
+
saveFileName: upperCase(SAVE_FILE_NAME.flowSchema),
|
|
88
|
+
fileExtension: ".yml",
|
|
89
|
+
isAppend: true
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function createSourceParamsApi(_izContext, flowSchema, srcPath) {
|
|
95
|
+
let functionName = upperCase(flowSchema.flowTag)
|
|
96
|
+
let handlerType = upperCase(HANDLER.hdrApi)
|
|
97
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
98
|
+
let tableName = null;
|
|
99
|
+
if (flowSchema.statusType === "storedCache") {
|
|
100
|
+
let objectSchema = await getObjectSchema.getLocalObjectSchemas(_izContext, [flowSchema.objType.objectType], path.join(srcPath, "./schemas")).then(res => res.records[0]);
|
|
101
|
+
for (const storageResource of Object.values(objectSchema.storageResources)) {
|
|
102
|
+
if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
|
|
103
|
+
tableName = storageResource.tableName
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
templatePath: templatePathApi,
|
|
110
|
+
templateData: {
|
|
111
|
+
resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, upperCase(flowSchema.flowTag), "source/"),
|
|
112
|
+
functionName,
|
|
113
|
+
handlerType,
|
|
114
|
+
additionalResourcePermission,
|
|
115
|
+
functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
|
|
116
|
+
roleName: upperCase(flowSchema.flowTag),
|
|
117
|
+
event: "post"
|
|
118
|
+
},
|
|
119
|
+
setting: {
|
|
120
|
+
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
121
|
+
saveFileName: upperCase(SAVE_FILE_NAME.flowSchema),
|
|
122
|
+
fileExtension: ".yml",
|
|
123
|
+
isAppend: true
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
module.exports = data;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<%_ const join = require('path').join _%>
|
|
2
|
+
<%- firstLetterUpperCase(functionNameConfig) %>:
|
|
3
|
+
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`) %>
|
|
4
|
+
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
|
+
events:
|
|
6
|
+
- http:
|
|
7
|
+
path: <%- firstLetterUpperCase(functionName) %>
|
|
8
|
+
method: <%- event %>
|
|
9
|
+
cors: true
|
|
10
|
+
#<#<%- firstLetterUpperCase(functionName) _%><%- firstLetterUpperCase(handlerType) %>Authorizer#>
|
|
11
|
+
#<#/<%- firstLetterUpperCase(functionName) _%><%- firstLetterUpperCase(handlerType) %>Authorizer#>
|
|
12
|
+
role: <%- firstLetterUpperCase(roleName) _%>Role
|
|
13
|
+
#<#<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>IamRole#>
|
|
14
|
+
#<#/<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>IamRole#>
|
|
15
|
+
<%_ function firstLetterUpperCase(text){
|
|
16
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
17
|
+
} _%>
|
|
18
|
+
<%_ function firstLetterLowerCase(str) {
|
|
19
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
20
|
+
} _%>
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
role: <%- roleName %>Role
|
|
6
|
+
#<#<%- functionName %><%- handlerType %>IamRole#>
|
|
7
|
+
#<#/<%- functionName %><%- handlerType %>IamRole#>
|
|
8
|
+
<%_ function firstLetterUpperCase(text){
|
|
9
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
10
|
+
} _%>
|
|
11
|
+
<%_ function firstLetterLowerCase(str) {
|
|
12
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
13
|
+
} _%>
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
const path = require('path');
|
|
20
|
+
|
|
21
|
+
const { FLOW_SCHEMA_HOOK_STATE, ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
22
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils")
|
|
23
|
+
const { SOURCE_PATH } = require('../../../../../MainLibs/src/Consts');
|
|
24
|
+
|
|
25
|
+
const templatePathInvoke = path.join(__dirname, "./templateInv.ejs");
|
|
26
|
+
const templatePathApi = path.join(__dirname, "./templateApi.ejs");
|
|
27
|
+
/**
|
|
28
|
+
* receive objectSchema
|
|
29
|
+
* create data for WebScoket handler template
|
|
30
|
+
*
|
|
31
|
+
* @param {Object} objectSchema
|
|
32
|
+
* @return {{templatePath, templateData,setting}}
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
function data(_izContext, flowSchema, srcPath) {
|
|
36
|
+
let returnCreateSource = [];
|
|
37
|
+
returnCreateSource.push(createSourceParamsInvoke(_izContext, flowSchema, srcPath))
|
|
38
|
+
if (flowSchema.externalEndpoint) {
|
|
39
|
+
returnCreateSource.push(createSourceParamsApi(_izContext, flowSchema, srcPath))
|
|
40
|
+
}
|
|
41
|
+
return returnCreateSource
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function createSourceParamsInvoke(_izContext, flowSchema, srcPath) {
|
|
45
|
+
let functionName = upperCase(flowSchema.flowTag)
|
|
46
|
+
let handlerType = upperCase(HANDLER.hdrInv)
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
templatePath: templatePathInvoke,
|
|
50
|
+
templateData: {
|
|
51
|
+
functionName,
|
|
52
|
+
handlerType,
|
|
53
|
+
},
|
|
54
|
+
setting: {
|
|
55
|
+
savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, "source/"),
|
|
56
|
+
saveFileName: `${functionName}_${handlerType}`,
|
|
57
|
+
fileExtension: ".js",
|
|
58
|
+
isAppend: false
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
function createSourceParamsApi(_izContext, flowSchema, srcPath) {
|
|
65
|
+
let functionName = upperCase(flowSchema.flowTag)
|
|
66
|
+
let handlerType = upperCase(HANDLER.hdrApi)
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
templatePath: templatePathApi,
|
|
70
|
+
templateData: {
|
|
71
|
+
functionName,
|
|
72
|
+
handlerType,
|
|
73
|
+
// propertyNames,
|
|
74
|
+
// properties
|
|
75
|
+
},
|
|
76
|
+
setting: {
|
|
77
|
+
savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, "source/"),
|
|
78
|
+
saveFileName: `${functionName}_${handlerType}`,
|
|
79
|
+
fileExtension: ".js",
|
|
80
|
+
isAppend: false
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
module.exports = data;
|