@izara_project/izara-market-library-service-schemas 1.0.36 → 1.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -7
- package/src/GenerateCodeLibs/src/Consts.js +2 -2
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +36 -6
- package/src/MainLibs/src/Consts.js +5 -2
- package/src/MainLibs/src/GenerateCodeUtils.js +3 -1
- package/src/MainLibs/src/Utils.js +12 -0
- 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/GenerateCode.js +2 -2
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/backupTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +37 -12
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +25 -2
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +26 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +23 -1
- package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +37 -7
- package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +7 -7
- package/src/reStructure/TemplateData/externalService/lambdaRole/template.ejs +1 -1
- package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +4 -2
- 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 +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +3 -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 +6 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/mainFunction/template.ejs +18 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/sns-sqs/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +9 -6
- 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 +3 -3
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/sqs/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/mainFunction/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/externalTopic/functionYaml/data.js +127 -0
- package/src/reStructure/TemplateData/flowSchema/externalTopic/handler/data.js +121 -0
- package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/FlowSchemaCompleteComponent → externalTopic}/handler/template.ejs +4 -3
- package/src/reStructure/TemplateData/flowSchema/externalTopic/mainFunction/data.js +74 -0
- package/src/reStructure/TemplateData/flowSchema/externalTopic/mainFunction/template.ejs +131 -0
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +61 -34
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +9 -8
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +3 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +19 -8
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +19 -25
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +2 -4
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +2 -5
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +4 -3
- package/src/reStructure/TemplateData/flowSchema/{externalTopic/sqs → flowSchemaOwnTopic/flowStep}/functionYaml/data.js +43 -38
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/functionYaml/template.ejs +20 -0
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/handler/data.js +80 -0
- package/src/reStructure/TemplateData/flowSchema/{externalTopic/sqs → flowSchemaOwnTopic/flowStep}/handler/template.ejs +16 -61
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/mainFunction/data.js +92 -0
- package/src/reStructure/TemplateData/flowSchema/{externalTopic/websocket → flowSchemaOwnTopic/flowStep}/mainFunction/template.ejs +12 -14
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +48 -30
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +21 -24
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/functionYaml/data.js +7 -22
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/webSocketComplete/functionYaml/template.ejs +20 -0
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/handler/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/webSocketComplete/handler/template.ejs +84 -0
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/mainFunction/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/mainFunction/template.ejs +27 -11
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +25 -30
- package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/functionYaml/data.js +0 -27
- package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/mainFunction/data.js +3 -3
- package/src/reStructure/TemplateData/flowSchema/register/complete/mainFunction/template.ejs +172 -0
- package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/dynamoDB/register.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/subscriptionOutAll/data.js +29 -19
- package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/functionYaml/data.js +28 -50
- package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/register/wbs/mainFunction/template.ejs +165 -0
- package/src/reStructure/TemplateData/flowSchema/templateBystatusType/storedCacheTemplate.ejs +38 -0
- package/src/reStructure/TemplateData/flowSchema/templateBystatusType/triggerCacheTemplate.ejs +39 -0
- package/src/reStructure/TemplateData/generateRole/sharedResourceTemplate.ejs +0 -29
- package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/createObjectComplete_main.js +1 -1
- package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/perActionComplete/delete/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/perActionComplete/get/mainFunction/template.ejs +4 -1
- package/src/reStructure/TemplateData/perActionComplete/update/mainFunction/template.ejs +6 -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/propertyValueSchema/relationshipPropertyValueSchema/data.js +2 -7
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/api/data.js +22 -3
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/dsq/data.js +14 -9
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/inv/data.js +26 -6
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/sqs/data.js +11 -7
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/functionYaml/data.js +17 -7
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/api/data.js +23 -4
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/dsq/data.js +14 -9
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/inv/data.js +26 -6
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/sqs/data.js +10 -7
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/functionYaml/data.js +11 -7
- package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/api/data.js +23 -4
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/data.js +14 -9
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/inv/data.js +26 -7
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/sqs/data.js +10 -7
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +1 -2
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/data.js +12 -7
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/api/data.js +22 -3
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/dsq/data.js +14 -6
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/inv/data.js +20 -3
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/sqs/data.js +9 -3
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/complete/functionYaml/data.js +12 -6
- package/src/reStructure/TemplateData/relationshipPerAction/update/complete/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +6 -2
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/template.ejs +0 -131
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs +0 -11
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/template.ejs +0 -222
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/data.js +0 -74
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/template.ejs +0 -8
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/template.ejs +0 -17
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/data.js +0 -64
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/data.js +0 -61
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/template.ejs +0 -45
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/data.js +0 -110
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/template.ejs +0 -18
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/data.js +0 -57
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/template.ejs +0 -40
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/data.js +0 -67
- package/src/reStructure/TemplateData/testTemplate/data.js +0 -27
- package/src/reStructure/TemplateData/testTemplate/template.ejs +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/FlowSchemaCompleteComponent → externalTopic}/functionYaml/template.ejs +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/functionYaml/template.ejs +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/handler/data.js +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/sns-in/data.js +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/sns-in/template.ejs +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/subscriptionOutAll/template.ejs +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/functionYaml/template.ejs +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/handler/data.js +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/mainFunction/data.js +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → templateBystatusType}/statusFieldTemplate.ejs +0 -0
|
@@ -47,7 +47,7 @@ module.exports.generatedLambdaRole = async () => {
|
|
|
47
47
|
]
|
|
48
48
|
<%_ }) _%>
|
|
49
49
|
<%_ }) _%>
|
|
50
|
-
}
|
|
50
|
+
},
|
|
51
51
|
<%_ }) _%>
|
|
52
52
|
//(<create<%- data.objectType%>Role>)
|
|
53
53
|
//(</create<%- data.objectType%>Role>)
|
|
@@ -79,8 +79,10 @@ const createExternalSnsSubscriptions = async (_izContext, allObjSchemas, allRelS
|
|
|
79
79
|
const snsServiceConfigForExtTopic = await snsSubscriptionFlowSchemaExternalTopic(_izContext, localFlowSchema);
|
|
80
80
|
snsServiceConfigForExtTopic && snsServiceConfigArray.push(snsServiceConfigForExtTopic);
|
|
81
81
|
}
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
if (!localFlowSchema.statusType === "none") {
|
|
83
|
+
const snsServiceConfigForCreateRecordByStatusType = await createFlowSchemaRegisterSnsTopicSubscriptions(_izContext, localFlowSchema);
|
|
84
|
+
snsServiceConfigForCreateRecordByStatusType && snsServiceConfigArray.push(snsServiceConfigForCreateRecordByStatusType);
|
|
85
|
+
}
|
|
84
86
|
}
|
|
85
87
|
}
|
|
86
88
|
}
|
|
@@ -11,13 +11,14 @@ let getDataByGraph = await graphSharedLib.getNodeV2(
|
|
|
11
11
|
graphHandlerServiceTag,
|
|
12
12
|
objType,
|
|
13
13
|
{
|
|
14
|
-
|
|
15
|
-
...fieldName
|
|
14
|
+
identifiers:identifiers
|
|
16
15
|
},
|
|
17
|
-
|
|
16
|
+
<%- JSON.stringify(versionedDataLabel) %>
|
|
18
17
|
);
|
|
18
|
+
|
|
19
19
|
_izContext.logger.debug("getDataByGraph: ", getDataByGraph)
|
|
20
20
|
|
|
21
|
+
|
|
21
22
|
if (!getDataByGraph) {
|
|
22
23
|
errorsFound.push(`can't get data of ${objType.objectType} in graph`)
|
|
23
24
|
standardErrorParams.push(errorsFound)
|
|
@@ -40,16 +40,10 @@ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
|
40
40
|
let functionName = upperCase(FUNCTION_NAME.createRecordComplete)
|
|
41
41
|
let flowSteps = Object.keys(flowSchema.flowSteps)
|
|
42
42
|
let splitFlowSteps = flowSteps[0].split("_")
|
|
43
|
-
|
|
44
|
-
let
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
topicArn = flowSteps[0]
|
|
48
|
-
} else if (event.includes(FLOW_SCHEMA_EVENT_TYPE.extTopic)) {
|
|
49
|
-
topicArn = splitFlowSteps[3] + "_" + splitFlowSteps[4]
|
|
50
|
-
serviceTag = splitFlowSteps[0]
|
|
51
|
-
}
|
|
52
|
-
}
|
|
43
|
+
|
|
44
|
+
let topicArn = splitFlowSteps[2] + "_" + splitFlowSteps[3]
|
|
45
|
+
let serviceTag = splitFlowSteps[0]
|
|
46
|
+
// serviceTag_stage_TopicName_In/Out
|
|
53
47
|
return {
|
|
54
48
|
templatePath: templatePath,
|
|
55
49
|
templateData: {
|
package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/template.ejs
CHANGED
|
@@ -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');
|
|
23
23
|
|
|
24
24
|
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
|
|
@@ -21,7 +21,9 @@ const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb')
|
|
|
21
21
|
const snsSharedLib = require('@izara_project/izara-core-library-sns')
|
|
22
22
|
const sns = require('@izara_project/izara-core-library-external-request').sns
|
|
23
23
|
const consts = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
|
|
24
|
-
const { getNestObject } = require('
|
|
24
|
+
const { getNestObject } = require('../../../../libs/source/GenerateCodeLibs');
|
|
25
|
+
//(<optionalRequired>)
|
|
26
|
+
//(</optionalRequired>)
|
|
25
27
|
/**
|
|
26
28
|
* description of function.
|
|
27
29
|
* @param {Object} _izContext
|
package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/data.js
CHANGED
|
@@ -38,12 +38,13 @@ function data(_izContext, flowSchema, srcPath) {
|
|
|
38
38
|
function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
39
39
|
let functionName = upperCase(FUNCTION_NAME.createObjectS3)
|
|
40
40
|
let handlerType = "HdrWbs"
|
|
41
|
-
|
|
41
|
+
let route = flowSchema.flowTag
|
|
42
42
|
return {
|
|
43
43
|
templatePath: templatePath,
|
|
44
44
|
templateData: {
|
|
45
45
|
functionName,
|
|
46
|
-
handlerType
|
|
46
|
+
handlerType,
|
|
47
|
+
route
|
|
47
48
|
},
|
|
48
49
|
setting: {
|
|
49
50
|
savePath: path.join(srcPath, SOURCE_PATH.webSocket, flowSchema.flowTag, "source/"),
|
package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/template.ejs
CHANGED
|
@@ -23,10 +23,10 @@ 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('
|
|
29
|
+
const { postToConnection } = require('../../../../libs/source/GenerateCodeLibs');
|
|
30
30
|
const createObject = require('./CreateObjectS3_Main');
|
|
31
31
|
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
32
32
|
|
|
@@ -40,16 +40,7 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
40
40
|
let correlationId = event._izContext.correlationIds.get(consts.X_CORRELATION_ID)
|
|
41
41
|
|
|
42
42
|
switch (route) {
|
|
43
|
-
case
|
|
44
|
-
console.log("webSocket Connect");
|
|
45
|
-
break
|
|
46
|
-
case "$disconnect":
|
|
47
|
-
console.log("webSocket Disconnect");
|
|
48
|
-
break
|
|
49
|
-
case '$default':
|
|
50
|
-
console.log('Received unknown route:', route);
|
|
51
|
-
break
|
|
52
|
-
case 'uploadS3':
|
|
43
|
+
case '<%- route %>':
|
|
53
44
|
console.log("event in route webSocket", event);
|
|
54
45
|
let eventParams = JSON.parse(event.body)
|
|
55
46
|
|
|
@@ -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');
|
|
@@ -35,6 +35,8 @@ const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryEr
|
|
|
35
35
|
const { v4: uuidv4 } = require('uuid')
|
|
36
36
|
const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
|
|
37
37
|
const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
|
|
38
|
+
//(<optionalRequired>)
|
|
39
|
+
//(</optionalRequired>)
|
|
38
40
|
/**
|
|
39
41
|
*
|
|
40
42
|
*
|
|
@@ -91,6 +93,8 @@ module.exports.createObject = async (
|
|
|
91
93
|
|
|
92
94
|
_izContext.correlationIds.get(coreConsts.X_CORRELATION_ID)
|
|
93
95
|
|
|
96
|
+
//(<beforeCreateHook>)
|
|
97
|
+
//(</beforeCreateHook>)
|
|
94
98
|
// create message Object to create Endpoint
|
|
95
99
|
let messageObject = {
|
|
96
100
|
fieldNames: {
|
|
@@ -120,7 +124,7 @@ module.exports.createObject = async (
|
|
|
120
124
|
// send message to ImportBatchCreateHdrSqs
|
|
121
125
|
let sendMessageToCreateEndpoint = {
|
|
122
126
|
Message: JSON.stringify(messageObject),
|
|
123
|
-
TopicArn: await snsSharedLib.
|
|
127
|
+
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, "Create_In")
|
|
124
128
|
}
|
|
125
129
|
_izContext.logger.debug("sendMessageToCreateEndpoint", sendMessageToCreateEndpoint);
|
|
126
130
|
await sns.publishAsync(_izContext, sendMessageToCreateEndpoint);
|
|
@@ -21,10 +21,26 @@ const snsSharedLib = require('@izara_project/izara-core-library-sns');
|
|
|
21
21
|
const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
|
|
22
22
|
let coreConsts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
|
|
23
23
|
|
|
24
|
-
const { postToConnection } = require('
|
|
24
|
+
const { postToConnection } = require('../../../../libs/source/GenerateCodeLibs')
|
|
25
25
|
module.exports.webSocketTaskComplete = async (
|
|
26
26
|
_izContext,
|
|
27
|
-
objType,
|
|
27
|
+
objType,{
|
|
28
|
+
flowTag: "TranslateIds2",
|
|
29
|
+
handleObj: "one", // "one" | "multi",
|
|
30
|
+
statusType: "statusField", // "statusField" | "storedCache" | "none",
|
|
31
|
+
event: ["s3"], // "ownTopic" | "extTopic" | "s3" | "eventBridge"
|
|
32
|
+
outputTopic: true,
|
|
33
|
+
objType: {
|
|
34
|
+
objectType: "TranslateIds",
|
|
35
|
+
serviceTag: "TranslateIds"
|
|
36
|
+
},
|
|
37
|
+
// storedCacheTable: {
|
|
38
|
+
// tableName: "",
|
|
39
|
+
// partitionKey: "",
|
|
40
|
+
// sortKey: ""
|
|
41
|
+
// },
|
|
42
|
+
// flowSteps: {}
|
|
43
|
+
},
|
|
28
44
|
updateItem
|
|
29
45
|
) => {
|
|
30
46
|
try {
|
|
@@ -55,7 +55,7 @@ function createDataForDefaultSnsInSqs(_izContext, srcPath) {
|
|
|
55
55
|
defaultSnsInSqsDataList.push(
|
|
56
56
|
{
|
|
57
57
|
queueName: upperCase(FUNCTION_NAME.createObjectS3Complete) + upperCase(HANDLER.hdrSqs),
|
|
58
|
-
subScription: upperCase(FUNCTION_NAME.updateNodeComplete)
|
|
58
|
+
subScription: "Out" + upperCase(FUNCTION_NAME.updateNodeComplete)
|
|
59
59
|
}
|
|
60
60
|
)
|
|
61
61
|
|
|
@@ -33,7 +33,7 @@ const { createPresignedPost } = require('@aws-sdk/s3-presigned-post');
|
|
|
33
33
|
const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
|
|
34
34
|
|
|
35
35
|
const { postToConnection,getNestObject } = require('../../../../libs/source/GenerateCodeLibs')
|
|
36
|
-
const hash = require('
|
|
36
|
+
const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
37
37
|
const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils');
|
|
38
38
|
const coreConsts = require('@izara_project/izara-core-library-core/src/Consts');
|
|
39
39
|
const { EXTERNAL_SERVICE_NAME } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts');
|
|
@@ -77,11 +77,12 @@ module.exports.createPresignUrl = async (
|
|
|
77
77
|
|
|
78
78
|
// getImportBatchMain from table
|
|
79
79
|
let importBatchMain = await lambda.invokeSync(_izContext,
|
|
80
|
-
await lambdaSharedLib.lambdaFunctionName(_izContext, "
|
|
80
|
+
await lambdaSharedLib.lambdaFunctionName(_izContext, "GetHdrInv"),
|
|
81
81
|
{
|
|
82
82
|
identifiers: {
|
|
83
83
|
importBatchId: servicePendingId
|
|
84
|
-
}
|
|
84
|
+
},
|
|
85
|
+
objectType: objType.objectType
|
|
85
86
|
}
|
|
86
87
|
)
|
|
87
88
|
_izContext.logger.debug("importBatchMain", importBatchMain);
|
|
@@ -134,12 +135,13 @@ module.exports.createPresignUrl = async (
|
|
|
134
135
|
importBatchStatus: "error",
|
|
135
136
|
errorsFound: errorsFound
|
|
136
137
|
}
|
|
137
|
-
}
|
|
138
|
+
},
|
|
139
|
+
objType: objType.objectType
|
|
138
140
|
}
|
|
139
141
|
|
|
140
142
|
let sendMessageToUpdateImportBatch = {
|
|
141
143
|
Message: JSON.stringify(updateImportBatchMainMsg),
|
|
142
|
-
TopicArn: await snsSharedLib.snsTopicArn(_izContext, `
|
|
144
|
+
TopicArn: await snsSharedLib.snsTopicArn(_izContext, `Update_In`)
|
|
143
145
|
}
|
|
144
146
|
_izContext.logger.debug("sendMessageToUpdateImportBatch", sendMessageToUpdateImportBatch);
|
|
145
147
|
|
|
@@ -212,7 +214,8 @@ module.exports.createPresignUrl = async (
|
|
|
212
214
|
importBatchStatus: "waitingToUpload",
|
|
213
215
|
expiryTimestamp: (startTime + (createPresignUrlParam.expires * 1000))
|
|
214
216
|
}
|
|
215
|
-
}
|
|
217
|
+
},
|
|
218
|
+
objectType: objType,objectType
|
|
216
219
|
}
|
|
217
220
|
|
|
218
221
|
updateImportBatchMainMsg = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
|
|
@@ -26,8 +26,8 @@ const sns = externalRequest.sns;
|
|
|
26
26
|
const lambda = externalRequest.lambda
|
|
27
27
|
const consts = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
|
|
28
28
|
const coreConsts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
|
|
29
|
-
const hash = require('
|
|
30
|
-
const importDataLibs = require('
|
|
29
|
+
const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
30
|
+
const importDataLibs = require('../../../../libs/source/GenerateCodeLibs');
|
|
31
31
|
/**
|
|
32
32
|
* description of function.
|
|
33
33
|
* @param {Object} _izContext
|
|
@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
19
19
|
|
|
20
20
|
const path = require("path")
|
|
21
21
|
|
|
22
|
-
const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME } = require('../../../../../../../../MainLibs/src/Consts');
|
|
22
|
+
const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, HANDLER } = require('../../../../../../../../MainLibs/src/Consts');
|
|
23
23
|
const { TOPIC_NAME_GENERATE_CODE } = require("../../../../../../../../GenerateCodeLibs/src/Consts");
|
|
24
24
|
const { firstLetterUpperCase: upperCase } = require("../../../../../../../../MainLibs/src/Utils");
|
|
25
25
|
const templatePath = path.join(__dirname, './template.ejs');
|
|
@@ -48,8 +48,8 @@ function data(_izContext, srcPath) {
|
|
|
48
48
|
|
|
49
49
|
WebSocketSqsQueueNames.push(
|
|
50
50
|
{
|
|
51
|
-
queueName: upperCase(FUNCTION_NAME.reservedLimit),
|
|
52
|
-
|
|
51
|
+
queueName: upperCase(FUNCTION_NAME.reservedLimit) + upperCase(HANDLER.hdrSqs),
|
|
52
|
+
queueNameSubscription: upperCase(FUNCTION_NAME.createObjectComplete)
|
|
53
53
|
}
|
|
54
54
|
)
|
|
55
55
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Type: AWS::SNS::Subscription
|
|
4
4
|
Properties:
|
|
5
5
|
TopicArn: !Ref Out<%- queueNameSubscription %>
|
|
6
|
-
Endpoint: "arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%-
|
|
6
|
+
Endpoint: "arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>"
|
|
7
7
|
Protocol: "sqs"
|
|
8
8
|
##===== [Queue]
|
|
9
9
|
<%- queueName %>:
|
|
@@ -31,9 +31,9 @@ const utils = require('@izara_project/izara-market-library-service-schemas/src/M
|
|
|
31
31
|
const { S3Client, GetObjectCommand, DeleteObjectCommand, PutObjectCommand, CopyObjectCommand } = require('@aws-sdk/client-s3');
|
|
32
32
|
const s3 = new S3Client({ region: 'us-east-2' });
|
|
33
33
|
|
|
34
|
-
const hash = require('
|
|
34
|
+
const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
35
35
|
const Readable = require('stream');
|
|
36
|
-
const { isValidCsv, getNestObject } = require('
|
|
36
|
+
const { isValidCsv, getNestObject } = require('../../../../libs/source/GenerateCodeLibs');
|
|
37
37
|
const consts = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
|
|
38
38
|
const coreConsts = require('@izara_project/izara-core-library-core/src/Consts');
|
|
39
39
|
|
|
@@ -21,7 +21,7 @@ const externalRequest = require('@izara_project/izara-core-library-external-requ
|
|
|
21
21
|
const lambda = externalRequest.lambda;
|
|
22
22
|
|
|
23
23
|
const { ApiGatewayManagementApiClient, PostToConnectionCommand } = require("@aws-sdk/client-apigatewaymanagementapi");
|
|
24
|
-
const hash = require(
|
|
24
|
+
const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
25
25
|
<% if (uploadS3) { %>
|
|
26
26
|
const csv = require('csv-parser');
|
|
27
27
|
const streamifier = require('streamifier');
|
|
@@ -29,7 +29,7 @@ const hash = require("object-hash")
|
|
|
29
29
|
const { NoRetryError,inMemoryCacheLib } = require('@izara_project/izara-core-library-core');
|
|
30
30
|
|
|
31
31
|
const client = new ApiGatewayManagementApiClient({
|
|
32
|
-
endpoint:
|
|
32
|
+
endpoint: `https://${process.env.iz_webSocketEndpoint}`
|
|
33
33
|
})
|
|
34
34
|
|
|
35
35
|
async function postToConnection(message, connectionId) {
|
package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js
CHANGED
|
@@ -69,7 +69,7 @@ function createWebSocketConnectYaml(_izContext, srcPath) {
|
|
|
69
69
|
templatePath: templatePath,
|
|
70
70
|
templateData: {
|
|
71
71
|
functionName,
|
|
72
|
-
resourceLocation:
|
|
72
|
+
resourceLocation: SOURCE_PATH.resourceLocationWebSocketMain,
|
|
73
73
|
additionalResourcePermission,
|
|
74
74
|
roleName: "WebsocketConnect"
|
|
75
75
|
|
package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/data.js
CHANGED
|
@@ -45,7 +45,7 @@ function createWebSocketConnectYaml(_izContext, srcPath) {
|
|
|
45
45
|
functionName,
|
|
46
46
|
},
|
|
47
47
|
setting: {
|
|
48
|
-
savePath: path.join(srcPath,
|
|
48
|
+
savePath: path.join(srcPath, SOURCE_PATH.WebSocketMain),
|
|
49
49
|
saveFileName: functionName,
|
|
50
50
|
fileExtension: ".js",
|
|
51
51
|
isAppend: false
|
package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/template.ejs
CHANGED
|
@@ -21,7 +21,7 @@ const izaraShared = require('@izara_project/izara-shared');
|
|
|
21
21
|
const dynamodbSharedLib = izaraShared.dynamodbSharedLib;
|
|
22
22
|
const izara = require("@izara_project/izara-middleware");
|
|
23
23
|
const middleware = izara.middlewareHandler;
|
|
24
|
-
const hash = require('
|
|
24
|
+
const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
25
25
|
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
26
26
|
|
|
27
27
|
event._izContext.logger.debug('Event:', event);
|
|
@@ -0,0 +1,127 @@
|
|
|
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 templatePath = path.join(__dirname, "template.ejs");
|
|
43
|
+
/**
|
|
44
|
+
* receive objectSchema
|
|
45
|
+
* create data for WebScoket handler template
|
|
46
|
+
*
|
|
47
|
+
* @param {Object} objectSchema
|
|
48
|
+
* @return {{templatePath, templateData,setting}}
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
async function data(_izContext, flowSchema, srcPath) {
|
|
52
|
+
return [await createSourceParams(_izContext, flowSchema, srcPath)]
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
56
|
+
let functionName = "Process" + upperCase(flowSchema.flowTag)
|
|
57
|
+
let handlerType = upperCase(HANDLER.hdrSqs)
|
|
58
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
59
|
+
let route = upperCase(flowSchema.flowTag);
|
|
60
|
+
let queueName = "Process" + upperCase(flowSchema.flowTag) + handlerType;
|
|
61
|
+
additionalResourcePermission.push(
|
|
62
|
+
createIamRole(
|
|
63
|
+
{
|
|
64
|
+
[RESOURCE_CLASSES.sqs]: Object.values(SQS_RESOURCE)
|
|
65
|
+
},
|
|
66
|
+
[
|
|
67
|
+
resourceNames(RESOURCE_CLASSES.sqs, queueName),
|
|
68
|
+
resourceNames(RESOURCE_CLASSES.sqs, queueName + "DLQ")
|
|
69
|
+
]
|
|
70
|
+
),
|
|
71
|
+
createIamRole(
|
|
72
|
+
{
|
|
73
|
+
[RESOURCE_CLASSES.lambda]: Object.values(LAMBDA_RESOURCE)
|
|
74
|
+
},
|
|
75
|
+
[
|
|
76
|
+
resourceNames(RESOURCE_CLASSES.lambda, 'CreateHdrInv')
|
|
77
|
+
]
|
|
78
|
+
),
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
if (flowSchema.statusType === "storedCache") {
|
|
82
|
+
let tableStroedCaches = [];
|
|
83
|
+
let objectSchema = await getObjectSchema.getLocalObjectSchemas(_izContext, [flowSchema.objType.objectType], path.join(srcPath, "./schemas")).then(res => res.records[0])
|
|
84
|
+
if (!objectSchema) {
|
|
85
|
+
throw new NoRetryError('ObjectSchema not found')
|
|
86
|
+
}
|
|
87
|
+
for (const storageResource of Object.values(objectSchema.storageResources)) {
|
|
88
|
+
if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
|
|
89
|
+
if (!tableStroedCaches.includes(storageResource.tableName)) {
|
|
90
|
+
tableStroedCaches.push(storageResource.tableName)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
additionalResourcePermission.push(
|
|
96
|
+
createIamRole(
|
|
97
|
+
{
|
|
98
|
+
[RESOURCE_CLASSES.dynamoDbTable]: Object.values(DYNAMO_RESOURCE)
|
|
99
|
+
},
|
|
100
|
+
tableStroedCaches.map(
|
|
101
|
+
tableName => resourceNames(RESOURCE_CLASSES.dynamoDbTable, tableName))
|
|
102
|
+
)
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
templatePath: templatePath,
|
|
108
|
+
templateData: {
|
|
109
|
+
resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, flowSchema.flowTag, "source/"),
|
|
110
|
+
functionName,
|
|
111
|
+
handlerType,
|
|
112
|
+
additionalResourcePermission,
|
|
113
|
+
route,
|
|
114
|
+
functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
|
|
115
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic,
|
|
116
|
+
queueName
|
|
117
|
+
},
|
|
118
|
+
setting: {
|
|
119
|
+
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
120
|
+
saveFileName: upperCase(SAVE_FILE_NAME.flowSchema),
|
|
121
|
+
fileExtension: ".yml",
|
|
122
|
+
isAppend: true
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
module.exports = data;
|
|
@@ -0,0 +1,121 @@
|
|
|
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 templatePath = path.join(__dirname, "template.ejs");
|
|
43
|
+
/**
|
|
44
|
+
* receive objectSchema
|
|
45
|
+
* create data for WebScoket handler template
|
|
46
|
+
*
|
|
47
|
+
* @param {Object} objectSchema
|
|
48
|
+
* @return {{templatePath, templateData,setting}}
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
async function data(_izContext, flowSchema, srcPath) {
|
|
52
|
+
return [await createSourceParams(_izContext, flowSchema, srcPath)]
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
56
|
+
let functionName = "Process" + upperCase(flowSchema.flowTag)
|
|
57
|
+
let handlerType = upperCase(HANDLER.hdrSqs)
|
|
58
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
59
|
+
let queueName = "Process" + upperCase(flowSchema.flowTag) + handlerType;
|
|
60
|
+
additionalResourcePermission.push(
|
|
61
|
+
createIamRole(
|
|
62
|
+
{
|
|
63
|
+
[RESOURCE_CLASSES.sqs]: Object.values(SQS_RESOURCE)
|
|
64
|
+
},
|
|
65
|
+
[
|
|
66
|
+
resourceNames(RESOURCE_CLASSES.sqs, queueName),
|
|
67
|
+
resourceNames(RESOURCE_CLASSES.sqs, queueName + "DLQ")
|
|
68
|
+
]
|
|
69
|
+
),
|
|
70
|
+
createIamRole(
|
|
71
|
+
{
|
|
72
|
+
[RESOURCE_CLASSES.lambda]: Object.values(LAMBDA_RESOURCE)
|
|
73
|
+
},
|
|
74
|
+
[
|
|
75
|
+
resourceNames(RESOURCE_CLASSES.lambda, 'CreateHdrInv')
|
|
76
|
+
]
|
|
77
|
+
),
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
if (flowSchema.statusType === "storedCache") {
|
|
81
|
+
let tableStroedCaches = [];
|
|
82
|
+
let objectSchema = await getObjectSchema.getLocalObjectSchemas(_izContext, [flowSchema.objType.objectType], path.join(srcPath, "./schemas")).then(res => res.records[0])
|
|
83
|
+
if (!objectSchema) {
|
|
84
|
+
throw new NoRetryError('ObjectSchema not found')
|
|
85
|
+
}
|
|
86
|
+
for (const storageResource of Object.values(objectSchema.storageResources)) {
|
|
87
|
+
if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
|
|
88
|
+
if (!tableStroedCaches.includes(storageResource.tableName)) {
|
|
89
|
+
tableStroedCaches.push(storageResource.tableName)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
additionalResourcePermission.push(
|
|
95
|
+
createIamRole(
|
|
96
|
+
{
|
|
97
|
+
[RESOURCE_CLASSES.dynamoDbTable]: Object.values(DYNAMO_RESOURCE)
|
|
98
|
+
},
|
|
99
|
+
tableStroedCaches.map(
|
|
100
|
+
tableName => resourceNames(RESOURCE_CLASSES.dynamoDbTable, tableName))
|
|
101
|
+
)
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
templatePath: templatePath,
|
|
107
|
+
templateData: {
|
|
108
|
+
functionName,
|
|
109
|
+
handlerType,
|
|
110
|
+
queueName
|
|
111
|
+
},
|
|
112
|
+
setting: {
|
|
113
|
+
savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, "source/"),
|
|
114
|
+
saveFileName: `${functionName}_${handlerType}`,
|
|
115
|
+
fileExtension: ".js",
|
|
116
|
+
isAppend: false
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
module.exports = data;
|
|
@@ -28,8 +28,9 @@ const Logger = require('@izara_project/izara-core-library-logger');
|
|
|
28
28
|
const <%- functionName %> = require('./<%- functionName %>_Main')
|
|
29
29
|
|
|
30
30
|
// validate event properties in body.Message of sqs event
|
|
31
|
-
middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
|
|
32
31
|
let perRecordsValidatorSchema = {}
|
|
32
|
+
middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
|
|
33
|
+
|
|
33
34
|
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
34
35
|
|
|
35
36
|
try {
|
|
@@ -45,7 +46,7 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
45
46
|
//validate message (and MessageAttributes)
|
|
46
47
|
await recordHandlerSharedLib.validateRecord(
|
|
47
48
|
record, // one record will send to mainFunction
|
|
48
|
-
"<%-
|
|
49
|
+
"<%- queueName %>", // queue name that need to retry or send to dlq
|
|
49
50
|
perRecordsValidatorSchema, // schema for record.Message
|
|
50
51
|
// messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
|
|
51
52
|
);
|
|
@@ -58,7 +59,7 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
58
59
|
let recordPromise = recordHandlerSharedLib.recordHandler(
|
|
59
60
|
record, // one record will send to mainFunction
|
|
60
61
|
<%- functionName %>.<%- functionName %>, // mainFunction that need to invoke.
|
|
61
|
-
"<%-
|
|
62
|
+
"<%- queueName %>", // queue name that need to retry or send to dlq
|
|
62
63
|
passOnProperties, // all parameters that mainFunction needed.
|
|
63
64
|
);
|
|
64
65
|
record._izContext.logger.debug('after recordPromise in handler');
|