@izara_project/izara-market-library-service-schemas 1.0.35 → 1.0.37
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 +8 -7
- package/src/GenerateCodeLibs/src/Consts.js +2 -2
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +3 -2
- package/src/MainLibs/src/Consts.js +8 -8
- package/src/MainLibs/src/GenerateCodeUtils.js +3 -1
- package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/generateTemplateData.js +35 -20
- package/src/TemplateManager/src/attributeTreeSchema/referenceRelationshipSchema/data.js +84 -0
- package/src/TemplateManager/src/attributeTreeSchema/referenceRelationshipSchema/tempReferenceRelationshipSchema.ejs +9 -0
- package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/relationshipSchema/data.js +1 -1
- package/src/TemplateManager/src/flowSchema/DefaultWebSocketResource/webSocketConnect/handler/template.ejs +1 -1
- package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/InProcessFlowSchema/handler/template.ejs +1 -1
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/handler/template.ejs +1 -1
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/getsignUrlsAcc/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/reservedLimitComplete/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/flowSchema/UploadS3Case/relate/libs/template.ejs +1 -1
- package/src/reStructure/SchemaConfig.js +1 -4
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/backupTemplate.ejs +701 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +35 -163
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +3 -1
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +3 -4
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +3 -1
- package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +45 -19
- package/src/reStructure/TemplateData/externalService/lambdaRole/template.ejs +5 -2
- package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +24 -14
- package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/template.ejs +4 -1
- package/src/reStructure/TemplateData/findData/GetByStorage/getByGraph.ejs +4 -3
- package/src/reStructure/TemplateData/findData/handler/template.ejs +2 -1
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/data.js +4 -10
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/template.ejs +69 -34
- package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/data.js +3 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/template.ejs +3 -12
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/mainFunction/template.ejs +18 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +10 -7
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/sqs/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/mainFunction/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/data.js +12 -4
- package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/template.ejs +14 -9
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/data.js +16 -40
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/template.ejs +9 -9
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/handler/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/data.js +3 -3
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/template.ejs +78 -27
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/dynamoDB/register.js +82 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/template.ejs +34 -1
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs +9 -32
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/data.js +30 -20
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/template.ejs +6 -6
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/data.js +32 -32
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/template.ejs +5 -5
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/handler/template.ejs +8 -9
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/template.ejs +116 -26
- package/src/reStructure/TemplateData/flowSchema/dynamoDb/data.js +83 -44
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +4 -5
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/template.ejs +1 -7
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/data.js +6 -4
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/template.ejs +2 -4
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/data.js +31 -3
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/template.ejs +4 -4
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/data.js +7 -8
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/template.ejs +13 -13
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/data.js +4 -4
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/template.ejs +43 -39
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/data.js +5 -7
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/data.js +2 -9
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/template.ejs +46 -48
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/data.js +5 -4
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/template.ejs +3 -11
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/data.js +17 -3
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/data.js +6 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/template.ejs +49 -84
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +60 -10
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +7 -3
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +22 -7
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +27 -34
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/data.js +21 -5
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/template.ejs +1 -3
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/handler/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/handler/template.ejs +5 -5
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/mainFunction/data.js +5 -3
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/mainFunction/template.ejs +10 -6
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +6 -3
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/template.ejs +0 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +4 -4
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +8 -3
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +21 -14
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +23 -8
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +11 -6
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +50 -45
- package/src/reStructure/TemplateData/generateRole/createSharedResource.js +3 -2
- package/src/reStructure/TemplateData/generateRole/sharedResourceTemplate.ejs +2 -28
- package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/createObjectComplete_main.js +1 -1
- package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +10 -9
- package/src/reStructure/TemplateData/perActionComplete/delete/mainFunction/template.ejs +6 -2
- package/src/reStructure/TemplateData/perActionComplete/get/mainFunction/template.ejs +3 -2
- package/src/reStructure/TemplateData/perActionComplete/update/mainFunction/template.ejs +3 -2
- package/src/reStructure/TemplateData/perActionEndpoint/libs/template.ejs +1 -1
- package/src/reStructure/TemplateData/perActionEndpoint/mainFunction/create/template.ejs +1 -1
- package/src/reStructure/TemplateData/perActionEndpoint/mainFunction/delete/template.ejs +1 -1
- package/src/reStructure/TemplateData/perActionEndpoint/mainFunction/update/template.ejs +1 -1
- package/src/reStructure/TemplateData/processLogical/mainFunction/template.ejs +1 -0
- package/src/reStructure/TemplateData/{propertyNodeSchema → propertyValueSchema}/generateTemplateData.js +4 -4
- package/src/reStructure/TemplateData/propertyValueSchema/objectPropertyValueSchema/data.js +131 -0
- package/src/reStructure/TemplateData/{propertyNodeSchema/relationshipPropertyNodeSchema → propertyValueSchema/relationshipPropertyValueSchema}/data.js +32 -55
- package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/tempRelationship.ejs +13 -0
- package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/templateRelationshipPropertyValueSchema.ejs +7 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +3 -2
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +3 -2
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/mainFunction/template.ejs +3 -2
- package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/handler/sqs/template.ejs +5 -5
- package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/mainFunction/template.ejs +6 -5
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +3 -3
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/handler/sqs/template.ejs +4 -4
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/mainFunction/template.ejs +5 -4
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/mainFunction/template.ejs +3 -2
- package/src/reStructure/TemplateData/relationshipPerAction/update/complete/mainFunction/template.ejs +3 -2
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/template.ejs +1 -3
- package/src/reStructure/TemplateData/resourceYaml/filterGenerateResource/data.js +61 -0
- package/src/reStructure/TemplateData/resourceYaml/generateTemplateData.js +13 -4
- package/src/reStructure/TemplateData/propertyNodeSchema/objectPropertyNodeSchema/data.js +0 -151
- package/src/reStructure/TemplateData/propertyNodeSchema/relationshipPropertyNodeSchema/templateRelationshipPropertyNodeSchema.ejs +0 -7
- package/src/reStructure/TemplateData/testTemplate/data.js +0 -27
- package/src/reStructure/TemplateData/testTemplate/template.ejs +0 -0
- /package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/mainAttributeTree/attributeLinkTemplate.ejs +0 -0
- /package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/mainAttributeTree/data.js +0 -0
- /package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/mainAttributeTree/request.json +0 -0
- /package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/relationshipSchema/template.ejs +0 -0
- /package/src/reStructure/TemplateData/{propertyNodeSchema/objectPropertyNodeSchema/templateObjectPropertyNodeSchema.ejs → propertyValueSchema/objectPropertyValueSchema/templateObjectPropertyValueSchema.ejs} +0 -0
|
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
18
18
|
'use strict';
|
|
19
19
|
const path = require('path');
|
|
20
20
|
|
|
21
|
-
const { FLOW_SCHEMA_HOOK_STATE, ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
21
|
+
const { FLOW_SCHEMA_HOOK_STATE, ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
22
22
|
const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
|
|
23
23
|
const {
|
|
24
24
|
SOURCE_PATH,
|
|
@@ -32,12 +32,15 @@ const {
|
|
|
32
32
|
FUNCTION_NAME,
|
|
33
33
|
shortNameHandler,
|
|
34
34
|
externalResourceYaml,
|
|
35
|
-
SOURCE_GENERATE_IAM_ROLE
|
|
35
|
+
SOURCE_GENERATE_IAM_ROLE,
|
|
36
|
+
SQS_RESOURCE,
|
|
37
|
+
LAMBDA_RESOURCE
|
|
36
38
|
} = require('../../../../../../MainLibs/src/Consts');
|
|
37
39
|
const { TOPIC_NAME_GENERATE_CODE } = require('../../../../../../GenerateCodeLibs/src/Consts');
|
|
40
|
+
const { NoRetryError } = require('@izara_project/izara-core-library-core');
|
|
41
|
+
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas').getObjectSchema;
|
|
38
42
|
|
|
39
43
|
const templatePath = path.join(__dirname, "template.ejs");
|
|
40
|
-
const hookTemplate = path.join(__dirname, "./hookTemplate.ejs");
|
|
41
44
|
/**
|
|
42
45
|
* receive objectSchema
|
|
43
46
|
* create data for WebScoket handler template
|
|
@@ -46,29 +49,76 @@ const hookTemplate = path.join(__dirname, "./hookTemplate.ejs");
|
|
|
46
49
|
* @return {{templatePath, templateData,setting}}
|
|
47
50
|
*/
|
|
48
51
|
|
|
49
|
-
function data(_izContext, flowSchema, srcPath) {
|
|
50
|
-
return [createSourceParams(_izContext, flowSchema, srcPath)]
|
|
52
|
+
async function data(_izContext, flowSchema, srcPath) {
|
|
53
|
+
return [await createSourceParams(_izContext, flowSchema, srcPath)]
|
|
51
54
|
}
|
|
52
55
|
|
|
53
|
-
function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
54
|
-
let functionName = upperCase(
|
|
56
|
+
async function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
57
|
+
let functionName = "Process" + upperCase(flowSchema.flowTag)
|
|
55
58
|
let handlerType = upperCase(HANDLER.hdrSqs)
|
|
56
59
|
let additionalResourcePermission = defaultIamRolePerAction();
|
|
57
60
|
let route = flowSchema.flowTag;
|
|
61
|
+
let flowSteps = Object.keys(flowSchema.flowSteps)
|
|
62
|
+
let flowStepsIn = flowSteps[0];
|
|
63
|
+
let splitFlowStepsIn = flowStepsIn.split("_");
|
|
64
|
+
let queueName = splitFlowStepsIn[2] + handlerType;
|
|
65
|
+
additionalResourcePermission.push(
|
|
66
|
+
createIamRole(
|
|
67
|
+
{
|
|
68
|
+
[RESOURCE_CLASSES.sqs]: Object.values(SQS_RESOURCE)
|
|
69
|
+
},
|
|
70
|
+
[
|
|
71
|
+
resourceNames(RESOURCE_CLASSES.sqs, queueName),
|
|
72
|
+
resourceNames(RESOURCE_CLASSES.sqs, queueName + "DLQ")
|
|
73
|
+
]
|
|
74
|
+
),
|
|
75
|
+
createIamRole(
|
|
76
|
+
{
|
|
77
|
+
[RESOURCE_CLASSES.lambda]: Object.values(LAMBDA_RESOURCE)
|
|
78
|
+
},
|
|
79
|
+
[
|
|
80
|
+
resourceNames(RESOURCE_CLASSES.lambda, 'CreateHdrInv')
|
|
81
|
+
]
|
|
82
|
+
),
|
|
83
|
+
)
|
|
58
84
|
|
|
59
|
-
|
|
85
|
+
if (flowSchema.statusType === "storedCache") {
|
|
86
|
+
let tableStroedCaches = [];
|
|
87
|
+
const objectSchemaPath = path.join(srcPath, "./schemas")
|
|
88
|
+
let objectSchema = await getObjectSchema.getLocalObjectSchemas(_izContext, [flowSchema.objType.objectType], objectSchemaPath).then(res => res.records[0])
|
|
89
|
+
if (!objectSchema) {
|
|
90
|
+
throw new NoRetryError('ObjectSchema not found')
|
|
91
|
+
}
|
|
92
|
+
for (const storageResource of Object.values(objectSchema.storageResources)) {
|
|
93
|
+
if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
|
|
94
|
+
if (!tableStroedCaches.includes(storageResource.tableName)) {
|
|
95
|
+
tableStroedCaches.push(storageResource.tableName)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
60
99
|
|
|
100
|
+
additionalResourcePermission.push(
|
|
101
|
+
createIamRole(
|
|
102
|
+
{
|
|
103
|
+
[RESOURCE_CLASSES.dynamoDbTable]: Object.values(DYNAMO_RESOURCE)
|
|
104
|
+
},
|
|
105
|
+
tableStroedCaches.map(
|
|
106
|
+
tableName => resourceNames(RESOURCE_CLASSES.dynamoDbTable, tableName))
|
|
107
|
+
)
|
|
108
|
+
)
|
|
109
|
+
}
|
|
61
110
|
|
|
62
111
|
return {
|
|
63
112
|
templatePath: templatePath,
|
|
64
113
|
templateData: {
|
|
65
|
-
resourceLocation: path.join(SOURCE_PATH.
|
|
114
|
+
resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, flowSchema.flowTag, "source/"),
|
|
66
115
|
functionName,
|
|
67
116
|
handlerType,
|
|
68
117
|
additionalResourcePermission,
|
|
69
118
|
route,
|
|
70
119
|
functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
|
|
71
|
-
roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic
|
|
120
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic,
|
|
121
|
+
queueName
|
|
72
122
|
},
|
|
73
123
|
setting: {
|
|
74
124
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
5
|
events:
|
|
6
6
|
- sqs:
|
|
7
|
-
arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%-
|
|
7
|
+
arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>
|
|
8
8
|
batchSize: 10
|
|
9
9
|
filterPatterns: #**** need to update serverless framwork upper v.2.69.1
|
|
10
10
|
- body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%- functionName %>"]}}} # functionName of callingFlow
|
package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js
CHANGED
|
@@ -36,10 +36,14 @@ function data(_izContext, flowSchema, srcPath) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
39
|
-
let functionName = upperCase(
|
|
39
|
+
let functionName = "Process" + upperCase(flowSchema.flowTag)
|
|
40
40
|
let handlerType = upperCase(HANDLER.hdrSqs)
|
|
41
41
|
let route = flowSchema.flowTag;
|
|
42
|
-
let
|
|
42
|
+
let flowSteps = Object.keys(flowSchema.flowSteps)
|
|
43
|
+
let flowStepsIn = flowSteps[0];
|
|
44
|
+
let splitFlowStepsIn = flowStepsIn.split("_");
|
|
45
|
+
let queueName = splitFlowStepsIn[2] + handlerType
|
|
46
|
+
|
|
43
47
|
return {
|
|
44
48
|
templatePath: templatePath,
|
|
45
49
|
templateData: {
|
|
@@ -49,7 +53,7 @@ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
|
49
53
|
queueName
|
|
50
54
|
},
|
|
51
55
|
setting: {
|
|
52
|
-
savePath: path.join(srcPath, SOURCE_PATH.
|
|
56
|
+
savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, "source/"),
|
|
53
57
|
saveFileName: `${functionName}_${handlerType}`,
|
|
54
58
|
fileExtension: ".js",
|
|
55
59
|
isAppend: false
|
|
@@ -25,7 +25,7 @@ const middleware = izara.middlewareHandler;
|
|
|
25
25
|
const recordHandlerSharedLib = require("@izara_project/izara-core-library-record-handler")
|
|
26
26
|
const Logger = require('@izara_project/izara-core-library-logger');
|
|
27
27
|
|
|
28
|
-
const
|
|
28
|
+
const <%- functionName %> = require('./<%- functionName %>_Main')
|
|
29
29
|
|
|
30
30
|
// validate event properties in body.Message of sqs event
|
|
31
31
|
let perRecordsValidatorSchema = {}
|
|
@@ -18,10 +18,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
18
18
|
'use strict';
|
|
19
19
|
const path = require('path');
|
|
20
20
|
|
|
21
|
-
const { SOURCE_PATH, FUNCTION_NAME } = require('../../../../../../MainLibs/src/Consts');
|
|
21
|
+
const { SOURCE_PATH, FUNCTION_NAME, HANDLER } = require('../../../../../../MainLibs/src/Consts');
|
|
22
22
|
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils")
|
|
23
23
|
const templatePath = path.join(__dirname, "template.ejs");
|
|
24
|
-
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
|
|
24
|
+
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
|
|
25
|
+
const { STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
25
26
|
const statusFieldTemplate = path.join(__dirname, "../../../createRecordByStatusType/statusFieldTemplate.ejs")
|
|
26
27
|
const storedCacheTemplate = path.join(__dirname, "../../../createRecordByStatusType/storedCacheTemplate.ejs")
|
|
27
28
|
|
|
@@ -34,21 +35,35 @@ const storedCacheTemplate = path.join(__dirname, "../../../createRecordByStatusT
|
|
|
34
35
|
*/
|
|
35
36
|
|
|
36
37
|
|
|
37
|
-
function data(_izContext, flowSchema, srcPath) {
|
|
38
|
-
return [createParamsForCreateSource(_izContext, flowSchema, srcPath)]
|
|
38
|
+
async function data(_izContext, flowSchema, srcPath) {
|
|
39
|
+
return [await createParamsForCreateSource(_izContext, flowSchema, srcPath)]
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
42
|
-
let functionName = upperCase(
|
|
42
|
+
async function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
43
|
+
let functionName = "Process" + upperCase(flowSchema.flowTag);
|
|
44
|
+
let tableName = null;
|
|
45
|
+
if (flowSchema.statusType === "storedCache") {
|
|
46
|
+
let objectSchema = await getObjectSchema.getLocalObjectSchemas(_izContext, [flowSchema.objType.objectType], path.join(srcPath, "./schemas")).then(res => res.records[0]);
|
|
47
|
+
for (const storageResource of Object.values(objectSchema.storageResources)) {
|
|
48
|
+
if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
|
|
49
|
+
tableName = storageResource.tableName
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
let flowSchemaComplete = upperCase(flowSchema.flowTag) + "Complete"
|
|
43
54
|
return {
|
|
44
55
|
templatePath: templatePath,
|
|
45
56
|
templateData: {
|
|
46
57
|
statusType: flowSchema.statusType,
|
|
47
58
|
statusFieldTemplate,
|
|
48
59
|
storedCacheTemplate,
|
|
60
|
+
flowTag: flowSchema.flowTag,
|
|
61
|
+
functionName,
|
|
62
|
+
tableName,
|
|
63
|
+
flowSchemaComplete
|
|
49
64
|
},
|
|
50
65
|
setting: {
|
|
51
|
-
savePath: path.join(srcPath, SOURCE_PATH.
|
|
66
|
+
savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, "source/"),
|
|
52
67
|
saveFileName: `${functionName}_Main`,
|
|
53
68
|
fileExtension: ".js",
|
|
54
69
|
isAppend: false
|
|
@@ -18,7 +18,7 @@ along with this program. If not, see
|
|
|
18
18
|
|
|
19
19
|
'use strict';
|
|
20
20
|
|
|
21
|
-
const hash = require(
|
|
21
|
+
const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
22
22
|
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
|
|
23
23
|
|
|
24
24
|
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
|
|
@@ -27,16 +27,22 @@ const sqsSharedLib = require('@izara_project/izara-core-library-sqs');
|
|
|
27
27
|
const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
|
|
28
28
|
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
29
29
|
const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
|
|
30
|
+
const storedCacheSharedLib = require('@izara_project/izara-core-library-stored-cache')
|
|
30
31
|
|
|
31
32
|
const externalRequest = require('@izara_project/izara-core-library-external-request');
|
|
32
33
|
const sns = externalRequest.sns
|
|
33
34
|
const sqs = externalRequest.sqs
|
|
35
|
+
const lambda = externalRequest.lambda
|
|
34
36
|
const { postToConnection } = require("../../../../libs/source/GenerateCodeLibs");
|
|
35
37
|
const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
|
|
36
38
|
const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
|
|
37
39
|
const { v4: uuidv4 } = require('uuid')
|
|
38
40
|
const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
|
|
39
41
|
const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
|
|
42
|
+
const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
|
|
43
|
+
const { createFieldNamesFromRequestParamsByObjectSchema } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs.js')
|
|
44
|
+
//(<optionalRequire>)
|
|
45
|
+
//(</optionalRequire>)
|
|
40
46
|
/**
|
|
41
47
|
*
|
|
42
48
|
*
|
|
@@ -52,7 +58,7 @@ const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-librar
|
|
|
52
58
|
* @returns {object} description of return value
|
|
53
59
|
*/
|
|
54
60
|
|
|
55
|
-
module.exports
|
|
61
|
+
module.exports.<%- functionName %> = async (
|
|
56
62
|
_izContext,
|
|
57
63
|
requestParams,
|
|
58
64
|
callingFlowConfig = {},
|
|
@@ -61,20 +67,26 @@ module.exports.FlowSchemaOwnTopicEndpoint = async (
|
|
|
61
67
|
) => {
|
|
62
68
|
|
|
63
69
|
try {
|
|
64
|
-
_izContext.logger.debug("
|
|
65
|
-
_izContext.logger.debug("
|
|
66
|
-
_izContext.logger.debug("
|
|
70
|
+
_izContext.logger.debug("<%- functionName %> _izContext", _izContext)
|
|
71
|
+
_izContext.logger.debug("<%- functionName %> requestParams", requestParams)
|
|
72
|
+
_izContext.logger.debug("<%- functionName %> callingFlowConfig", callingFlowConfig)
|
|
73
|
+
|
|
74
|
+
let correlationId = _izContext.correlationIds.get(consts.X_CORRELATION_ID)
|
|
75
|
+
let connectionId = _izContext.correlationIds.get(consts.CONNECTION_ID);
|
|
67
76
|
|
|
68
77
|
//(<endpointHookMainFunction>)
|
|
69
78
|
//(</endpointHookMainFunction>)
|
|
70
79
|
|
|
80
|
+
const flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
|
|
81
|
+
flowTag: requestParams.action,
|
|
82
|
+
serviceTag: process.env.iz_serviceTag
|
|
83
|
+
})
|
|
84
|
+
|
|
71
85
|
<% if (statusType === "statusField") { %>
|
|
72
86
|
<%- include(statusFieldTemplate) %>
|
|
73
87
|
<% } else if (statusType === "storedCache") { %>
|
|
74
|
-
<%- include(storedCacheTemplate) %>
|
|
75
|
-
let messageObject =
|
|
76
|
-
requestParams:requestParams
|
|
77
|
-
}
|
|
88
|
+
<%- include(storedCacheTemplate, {tableName:tableName}) %>
|
|
89
|
+
let messageObject = requestParams
|
|
78
90
|
|
|
79
91
|
//(<beforeSendMessage>)
|
|
80
92
|
//(</beforeSendMessage>)
|
|
@@ -84,22 +96,15 @@ module.exports.FlowSchemaOwnTopicEndpoint = async (
|
|
|
84
96
|
callingFlowSharedLib.addParentCallingFlowConfig(
|
|
85
97
|
callingFlowConfig,
|
|
86
98
|
callingFlowSharedLib.createCallingFlowConfig(
|
|
87
|
-
await lambdaSharedLib.lambdaFunctionName(_izContext,
|
|
99
|
+
await lambdaSharedLib.lambdaFunctionName(_izContext, "<%- flowSchemaComplete %>"), {}
|
|
88
100
|
)
|
|
89
101
|
)
|
|
90
102
|
)
|
|
91
103
|
|
|
92
|
-
let sendMessageToEndpointComplete = {
|
|
93
|
-
Message:JSON.stringify(messageObject),
|
|
94
|
-
QueueUrl: await sqsSharedLib.sqsQueueUrl(_izContext, "FlowSchemaOwnTopicEndpointCompleteHdrSqs")
|
|
95
|
-
}
|
|
96
|
-
_izContext.logger.debug("sendMessageToEndpointComplete", sendMessageToEndpointComplete)
|
|
97
|
-
await sqs.sendMessage(_izContext, sendMessageToEndpointComplete)
|
|
98
|
-
|
|
99
104
|
<% } else if (statusType === "none") { %>
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
105
|
+
|
|
106
|
+
let messageObject = requestParams
|
|
107
|
+
|
|
103
108
|
// create callingFlow
|
|
104
109
|
messageObject = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
|
|
105
110
|
messageObject,
|
|
@@ -110,22 +115,10 @@ module.exports.FlowSchemaOwnTopicEndpoint = async (
|
|
|
110
115
|
)
|
|
111
116
|
)
|
|
112
117
|
)
|
|
113
|
-
|
|
114
|
-
let sendMessageToEndpointComplete = {
|
|
115
|
-
Message:JSON.stringify(messageObject),
|
|
116
|
-
QueueUrl: await sqsSharedLib.sqsQueueUrl(_izContext, "FlowSchemaOwnTopicEndpointCompleteHdrSqs")
|
|
117
|
-
}
|
|
118
|
-
_izContext.logger.debug("sendMessageToEndpointComplete", sendMessageToEndpointComplete)
|
|
119
|
-
await sqs.sendMessage(_izContext, sendMessageToEndpointComplete)
|
|
120
|
-
|
|
121
118
|
<% } %>
|
|
122
119
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
QueueUrl: await sqsSharedLib.sqsQueueUrl(_izContext, "FlowSchemaOwnTopicEndpointCompleteHdrSqs")
|
|
126
|
-
}
|
|
127
|
-
_izContext.logger.debug("sendMessageToEndpointComplete", sendMessageToEndpointComplete)
|
|
128
|
-
await sqs.sendMessage(_izContext, sendMessageToEndpointComplete)
|
|
120
|
+
//(<endpointHook>)
|
|
121
|
+
//(</endpointHook>)
|
|
129
122
|
|
|
130
123
|
return {
|
|
131
124
|
//(<endpointReturn>)
|
|
@@ -32,7 +32,8 @@ const {
|
|
|
32
32
|
FUNCTION_NAME,
|
|
33
33
|
shortNameHandler,
|
|
34
34
|
externalResourceYaml,
|
|
35
|
-
SOURCE_GENERATE_IAM_ROLE
|
|
35
|
+
SOURCE_GENERATE_IAM_ROLE,
|
|
36
|
+
SQS_RESOURCE
|
|
36
37
|
} = require('../../../../../../MainLibs/src/Consts');
|
|
37
38
|
const { TOPIC_NAME_GENERATE_CODE } = require('../../../../../../GenerateCodeLibs/src/Consts');
|
|
38
39
|
|
|
@@ -51,11 +52,16 @@ function data(_izContext, flowSchema, srcPath) {
|
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
54
|
-
let functionName = upperCase(
|
|
55
|
+
let functionName = upperCase(flowSchema.flowTag) + "Complete"
|
|
55
56
|
let handlerType = upperCase(HANDLER.hdrSqs)
|
|
56
57
|
let additionalResourcePermission = defaultIamRolePerAction();
|
|
57
58
|
let route = flowSchema.flowTag;
|
|
58
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
|
+
let queueName = functionName + handlerType
|
|
64
|
+
|
|
59
65
|
additionalResourcePermission.push(
|
|
60
66
|
createIamRole(
|
|
61
67
|
{
|
|
@@ -64,7 +70,7 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
64
70
|
]
|
|
65
71
|
},
|
|
66
72
|
[
|
|
67
|
-
resourceNames(RESOURCE_CLASSES.sns,
|
|
73
|
+
resourceNames(RESOURCE_CLASSES.sns, topicIn)
|
|
68
74
|
]
|
|
69
75
|
),
|
|
70
76
|
createIamRole(
|
|
@@ -90,6 +96,15 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
90
96
|
[
|
|
91
97
|
resourceNames(RESOURCE_CLASSES.webSocket)
|
|
92
98
|
]
|
|
99
|
+
),
|
|
100
|
+
createIamRole(
|
|
101
|
+
{
|
|
102
|
+
[RESOURCE_CLASSES.sqs]: [SQS_RESOURCE.sendMessage, SQS_RESOURCE.receiveMessage, SQS_RESOURCE.deleteMessage, SQS_RESOURCE.getQueueAttributes]
|
|
103
|
+
},
|
|
104
|
+
[
|
|
105
|
+
resourceNames(RESOURCE_CLASSES.sqs, queueName),
|
|
106
|
+
resourceNames(RESOURCE_CLASSES.sqs, queueName + "DLQ")
|
|
107
|
+
]
|
|
93
108
|
)
|
|
94
109
|
)
|
|
95
110
|
|
|
@@ -97,13 +112,14 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
97
112
|
return {
|
|
98
113
|
templatePath: templatePath,
|
|
99
114
|
templateData: {
|
|
100
|
-
resourceLocation: path.join(SOURCE_PATH.
|
|
115
|
+
resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, flowSchema.flowTag, "source/"),
|
|
101
116
|
functionName,
|
|
102
117
|
handlerType,
|
|
103
118
|
additionalResourcePermission,
|
|
104
119
|
route,
|
|
105
120
|
functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
|
|
106
|
-
roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic
|
|
121
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic,
|
|
122
|
+
queueName: queueName
|
|
107
123
|
},
|
|
108
124
|
setting: {
|
|
109
125
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -4,13 +4,11 @@
|
|
|
4
4
|
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
5
|
events:
|
|
6
6
|
- sqs:
|
|
7
|
-
arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%-
|
|
7
|
+
arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>
|
|
8
8
|
batchSize: 10
|
|
9
9
|
filterPatterns: #**** need to update serverless framwork upper v.2.69.1
|
|
10
10
|
- body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%- functionName %>"]}}} # functionName of callingFlow
|
|
11
11
|
- body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
|
|
12
|
-
- body: {"MessageAttributes":{"_izContext":{"Value":["x-correlation-connectionId"]}}} # functionName of callingFlow
|
|
13
|
-
- body: {"MessageAttributes":{"_izContext":{"Value":[{"exists":true}]}}}
|
|
14
12
|
role: <%- roleName %>Role
|
|
15
13
|
#<#<%- functionName %><%- handlerType %>IamRole#>
|
|
16
14
|
#<#/<%- functionName %><%- handlerType %>IamRole#>
|
|
@@ -36,7 +36,7 @@ function data(_izContext, flowSchema, srcPath) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
39
|
-
let functionName = upperCase(
|
|
39
|
+
let functionName = upperCase(flowSchema.flowTag) + "Complete"
|
|
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.flowSchema, flowSchema.flowTag, "source/"),
|
|
51
51
|
saveFileName: `${functionName}_${handlerType}`,
|
|
52
52
|
fileExtension: ".js",
|
|
53
53
|
isAppend: false
|
|
@@ -25,11 +25,11 @@ const middleware = izara.middlewareHandler;
|
|
|
25
25
|
const recordHandlerSharedLib = require("@izara_project/izara-core-library-record-handler")
|
|
26
26
|
const Logger = require('@izara_project/izara-core-library-logger');
|
|
27
27
|
|
|
28
|
-
const
|
|
28
|
+
const <%- functionName %> = require('./<%- functionName %>_Main')
|
|
29
29
|
|
|
30
30
|
// validate event properties in body.Message of sqs event
|
|
31
31
|
middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
|
|
32
|
-
|
|
32
|
+
let perRecordsValidatorSchema = {}
|
|
33
33
|
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
34
34
|
|
|
35
35
|
try {
|
|
@@ -45,7 +45,7 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
45
45
|
//validate message (and MessageAttributes)
|
|
46
46
|
await recordHandlerSharedLib.validateRecord(
|
|
47
47
|
record, // one record will send to mainFunction
|
|
48
|
-
"
|
|
48
|
+
"<%- queueName %>", // queue name that need to retry or send to dlq
|
|
49
49
|
perRecordsValidatorSchema, // schema for record.Message
|
|
50
50
|
// messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
|
|
51
51
|
);
|
|
@@ -57,8 +57,8 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
57
57
|
// call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
|
|
58
58
|
let recordPromise = recordHandlerSharedLib.recordHandler(
|
|
59
59
|
record, // one record will send to mainFunction
|
|
60
|
-
|
|
61
|
-
"
|
|
60
|
+
<%- functionName %>.<%- functionName %>, // mainFunction that need to invoke.
|
|
61
|
+
"<%- queueName %>", // queue name that need to retry or send to dlq
|
|
62
62
|
passOnProperties, // all parameters that mainFunction needed.
|
|
63
63
|
);
|
|
64
64
|
record._izContext.logger.debug('after recordPromise in handler');
|
|
@@ -37,12 +37,14 @@ function data(_izContext, flowSchema, srcPath) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
40
|
-
let functionName = upperCase(
|
|
40
|
+
let functionName = `${upperCase(flowSchema.flowTag)}Complete`
|
|
41
41
|
return {
|
|
42
42
|
templatePath: templatePath,
|
|
43
|
-
templateData: {
|
|
43
|
+
templateData: {
|
|
44
|
+
functionName
|
|
45
|
+
},
|
|
44
46
|
setting: {
|
|
45
|
-
savePath: path.join(srcPath, SOURCE_PATH.
|
|
47
|
+
savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, "source/"),
|
|
46
48
|
saveFileName: `${functionName}_Main`,
|
|
47
49
|
fileExtension: ".js",
|
|
48
50
|
isAppend: false
|
|
@@ -18,7 +18,7 @@ along with this program. If not, see
|
|
|
18
18
|
|
|
19
19
|
'use strict';
|
|
20
20
|
|
|
21
|
-
const hash = require(
|
|
21
|
+
const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
22
22
|
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
|
|
23
23
|
|
|
24
24
|
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
|
|
@@ -29,12 +29,16 @@ 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 { postToConnection } = require("
|
|
32
|
+
const { postToConnection } = require("../../../libs/source/GenerateCodeLibs");
|
|
33
|
+
|
|
33
34
|
const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
|
|
34
35
|
const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
|
|
35
36
|
const { v4: uuidv4 } = require('uuid')
|
|
36
37
|
const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
|
|
38
|
+
const consts = require("@izara_project/izara-middleware").consts
|
|
37
39
|
const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
|
|
40
|
+
//(<optionalRequire>)
|
|
41
|
+
//(</optionalRequire>)
|
|
38
42
|
/**
|
|
39
43
|
*
|
|
40
44
|
*
|
|
@@ -50,7 +54,7 @@ const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-librar
|
|
|
50
54
|
* @returns {object} description of return value
|
|
51
55
|
*/
|
|
52
56
|
|
|
53
|
-
module.exports
|
|
57
|
+
module.exports.<%- functionName %> = async (
|
|
54
58
|
_izContext,
|
|
55
59
|
requestParams,
|
|
56
60
|
callingFlowConfig = {},
|
|
@@ -59,9 +63,9 @@ module.exports.FlowSchemaOwnTopicComplete = async (
|
|
|
59
63
|
) => {
|
|
60
64
|
|
|
61
65
|
try {
|
|
62
|
-
_izContext.logger.debug("
|
|
63
|
-
_izContext.logger.debug("
|
|
64
|
-
_izContext.logger.debug("
|
|
66
|
+
_izContext.logger.debug("<%- functionName %> _izContext", _izContext)
|
|
67
|
+
_izContext.logger.debug("<%- functionName %> requestParams", requestParams)
|
|
68
|
+
_izContext.logger.debug("<%- functionName %> callingFlowConfig", callingFlowConfig)
|
|
65
69
|
|
|
66
70
|
let connectionId = _izContext.correlationIds.get(coreConsts.CONNECTION_ID);
|
|
67
71
|
let correlationId = _izContext.correlationIds.get(coreConsts.X_CORRELATION_ID);
|
|
@@ -51,11 +51,14 @@ function data(_izContext, flowSchema, srcPath) {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
54
|
-
let functionName = upperCase(
|
|
54
|
+
let functionName = upperCase(flowSchema.flowTag)
|
|
55
55
|
let handlerType = upperCase("hdrWbs")
|
|
56
56
|
let additionalResourcePermission = defaultIamRolePerAction();
|
|
57
57
|
let route = flowSchema.flowTag;
|
|
58
58
|
let flowStep = Object.keys(flowSchema.flowSteps)
|
|
59
|
+
let flowStepsOut = flowStep[0];
|
|
60
|
+
let splitFlowStepsIn = flowStepsOut.split("_");
|
|
61
|
+
let topicIn = `${splitFlowStepsIn[2]}_${splitFlowStepsIn[3]}`
|
|
59
62
|
additionalResourcePermission.push(
|
|
60
63
|
createIamRole(
|
|
61
64
|
{
|
|
@@ -64,7 +67,7 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
64
67
|
]
|
|
65
68
|
},
|
|
66
69
|
[
|
|
67
|
-
resourceNames(RESOURCE_CLASSES.sns,
|
|
70
|
+
resourceNames(RESOURCE_CLASSES.sns, topicIn)
|
|
68
71
|
]
|
|
69
72
|
),
|
|
70
73
|
createIamRole(
|
|
@@ -97,7 +100,7 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
97
100
|
return {
|
|
98
101
|
templatePath: templatePath,
|
|
99
102
|
templateData: {
|
|
100
|
-
resourceLocation: path.join(SOURCE_PATH.
|
|
103
|
+
resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, flowSchema.flowTag, "source/"),
|
|
101
104
|
functionName,
|
|
102
105
|
handlerType,
|
|
103
106
|
additionalResourcePermission,
|
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
4
|
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
5
|
events:
|
|
6
|
-
- websocket:
|
|
7
|
-
route: $default
|
|
8
6
|
- websocket:
|
|
9
7
|
route: <%- route %>
|
|
10
8
|
# authorizer: ${self:custom.iz_authorizerAppLevel}
|
|
@@ -36,7 +36,7 @@ function data(_izContext, flowSchema, srcPath) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
39
|
-
let functionName = upperCase(
|
|
39
|
+
let functionName = upperCase(flowSchema.flowTag)
|
|
40
40
|
let handlerType = "HdrWbs"
|
|
41
41
|
let route = flowSchema.flowTag;
|
|
42
42
|
return {
|
|
@@ -47,7 +47,7 @@ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
|
47
47
|
route
|
|
48
48
|
},
|
|
49
49
|
setting: {
|
|
50
|
-
savePath: path.join(srcPath, SOURCE_PATH.
|
|
50
|
+
savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, "source/"),
|
|
51
51
|
saveFileName: `${functionName}_${handlerType}`,
|
|
52
52
|
fileExtension: ".js",
|
|
53
53
|
isAppend: false
|
|
@@ -23,11 +23,11 @@ const middleware = izara.middlewareHandler;
|
|
|
23
23
|
// const api = new AWS.ApiGatewayManagementApi({ endpoint: process.env.iz_webSocketEndpoint });
|
|
24
24
|
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb')
|
|
25
25
|
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow')
|
|
26
|
-
const hash = require('
|
|
26
|
+
const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
27
27
|
// const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
|
|
28
28
|
const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
|
|
29
|
-
const { postToConnection } = require(
|
|
30
|
-
const
|
|
29
|
+
const { postToConnection } = require('../../../libs/source/GenerateCodeLibs')
|
|
30
|
+
const <%- functionName %> = require('./<%- functionName %>_Main');
|
|
31
31
|
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
32
32
|
|
|
33
33
|
event._izContext.logger.debug('Event:', event);
|
|
@@ -58,7 +58,7 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
58
58
|
)
|
|
59
59
|
|
|
60
60
|
let callingFlow = eventParams?.callingFlow ? eventParams.callingFlow : {};
|
|
61
|
-
await
|
|
61
|
+
await <%- functionName %>.<%- functionName %>(
|
|
62
62
|
event._izContext,
|
|
63
63
|
eventParams,
|
|
64
64
|
callingFlowSharedLib.addCallingFlowToPassOnProperties(callingFlow)
|