@izara_project/izara-market-library-service-schemas 1.0.35 → 1.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +2 -1
- package/src/MainLibs/src/Consts.js +8 -8
- package/src/MainLibs/src/GenerateCodeUtils.js +2 -0
- 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/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 +34 -162
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +2 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +3 -4
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +2 -0
- package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +38 -12
- package/src/reStructure/TemplateData/externalService/lambdaRole/template.ejs +5 -2
- package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +22 -14
- package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/template.ejs +4 -1
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/template.ejs +68 -33
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/data.js +12 -4
- package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/template.ejs +13 -8
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/data.js +16 -13
- 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/template.ejs +7 -9
- 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 +10 -33
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/data.js +5 -5
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/template.ejs +6 -6
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/data.js +26 -4
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/template.ejs +5 -5
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/handler/template.ejs +7 -8
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/template.ejs +118 -16
- 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 +2 -3
- 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 +44 -69
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/data.js +4 -6
- 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 +40 -87
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/data.js +5 -4
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/template.ejs +2 -10
- 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 +55 -10
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +20 -7
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +24 -33
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/data.js +20 -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 +7 -5
- 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 +3 -3
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +8 -3
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +17 -11
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +14 -8
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +4 -1
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +50 -42
- package/src/reStructure/TemplateData/generateRole/createSharedResource.js +3 -2
- package/src/reStructure/TemplateData/generateRole/sharedResourceTemplate.ejs +3 -0
- package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +9 -8
- package/src/reStructure/TemplateData/perActionComplete/delete/mainFunction/template.ejs +5 -1
- package/src/reStructure/TemplateData/perActionComplete/get/mainFunction/template.ejs +2 -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 +2 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +2 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/mainFunction/template.ejs +2 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/handler/sqs/template.ejs +5 -5
- package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/mainFunction/template.ejs +5 -4
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +2 -1
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/handler/sqs/template.ejs +4 -4
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/mainFunction/template.ejs +4 -3
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/mainFunction/template.ejs +2 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/complete/mainFunction/template.ejs +2 -1
- 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 → 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
|
@@ -21,14 +21,15 @@ 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 { inMemoryCacheLib } = require('@izara_project/izara-shared');
|
|
25
24
|
const hash = require("object-hash")
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
const
|
|
25
|
+
<% if (uploadS3) { %>
|
|
26
|
+
const csv = require('csv-parser');
|
|
27
|
+
const streamifier = require('streamifier');
|
|
28
|
+
<% } %>
|
|
29
|
+
const { NoRetryError,inMemoryCacheLib } = require('@izara_project/izara-core-library-core');
|
|
29
30
|
|
|
30
31
|
const client = new ApiGatewayManagementApiClient({
|
|
31
|
-
endpoint:
|
|
32
|
+
endpoint: `${process.env.iz_webSocketEndpoint}`
|
|
32
33
|
})
|
|
33
34
|
|
|
34
35
|
async function postToConnection(message, connectionId) {
|
|
@@ -60,7 +61,7 @@ async function getDataFromInvokeFunction(_izContext, functionName, payload) {
|
|
|
60
61
|
return await lambda.invokeSync(_izContext, functionName, payload)
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
const getDataFromInvokeFunctionWithCache = inMemoryCacheLib
|
|
64
|
+
const getDataFromInvokeFunctionWithCache = inMemoryCacheLib(
|
|
64
65
|
getDataFromInvokeFunction,
|
|
65
66
|
{
|
|
66
67
|
max: 100,
|
|
@@ -73,6 +74,7 @@ const getDataFromInvokeFunctionWithCache = inMemoryCacheLib.inMemoryCacheLib(
|
|
|
73
74
|
}
|
|
74
75
|
)
|
|
75
76
|
|
|
77
|
+
<% if (uploadS3) { %>
|
|
76
78
|
/**
|
|
77
79
|
*
|
|
78
80
|
* @param {Object} _izContext
|
|
@@ -108,6 +110,7 @@ async function isValidCsv(_izContext, data) {
|
|
|
108
110
|
|
|
109
111
|
return [validCsv, errorCheckCsv]
|
|
110
112
|
}
|
|
113
|
+
<% } %>
|
|
111
114
|
|
|
112
115
|
/**
|
|
113
116
|
*
|
|
@@ -132,6 +135,8 @@ module.exports = {
|
|
|
132
135
|
postToConnection,
|
|
133
136
|
getDataFromInvokeFunction,
|
|
134
137
|
getDataFromInvokeFunctionWithCache,
|
|
135
|
-
|
|
136
|
-
|
|
138
|
+
getNestObject,
|
|
139
|
+
<% if (uploadS3) { %>
|
|
140
|
+
isValidCsv,
|
|
141
|
+
<% } %>
|
|
137
142
|
}
|
|
@@ -34,7 +34,8 @@ const {
|
|
|
34
34
|
FUNCTION_NAME,
|
|
35
35
|
shortNameHandler,
|
|
36
36
|
externalResourceYaml,
|
|
37
|
-
SOURCE_GENERATE_IAM_ROLE
|
|
37
|
+
SOURCE_GENERATE_IAM_ROLE,
|
|
38
|
+
SQS_RESOURCE
|
|
38
39
|
} = require("../../../../../../MainLibs/src/Consts");
|
|
39
40
|
|
|
40
41
|
const templatePath = path.join(__dirname, "template.ejs");
|
|
@@ -48,20 +49,22 @@ const hookTemplate = path.join(__dirname, "./hookTemplate.ejs");
|
|
|
48
49
|
*/
|
|
49
50
|
function data(_izContext, srcPath) {
|
|
50
51
|
const handlerType = upperCase("hdrSqs");
|
|
51
|
-
const functionName = FUNCTION_NAME.flowSchemaRegister;
|
|
52
|
+
const functionName = upperCase(FUNCTION_NAME.flowSchemaRegister);
|
|
52
53
|
let functionNameConfig = upperCase(functionName) + upperCase(shortNameHandler(handlerType));
|
|
53
54
|
let additionalResourcePermission = defaultIamRolePerAction();
|
|
54
55
|
additionalResourcePermission.push(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
createIamRole(
|
|
57
|
+
{
|
|
58
|
+
[RESOURCE_CLASSES.sqs]: [
|
|
59
|
+
SQS_RESOURCE.getQueueAttributes,
|
|
60
|
+
SQS_RESOURCE.receiveMessage,
|
|
61
|
+
SQS_RESOURCE.deleteMessage,
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
[
|
|
65
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName))
|
|
66
|
+
]
|
|
67
|
+
),
|
|
65
68
|
createIamRole(
|
|
66
69
|
{
|
|
67
70
|
[RESOURCE_CLASSES.dynamoDbTable]: [
|
|
@@ -119,7 +122,7 @@ function data(_izContext, srcPath) {
|
|
|
119
122
|
return [{
|
|
120
123
|
templatePath: templatePath,
|
|
121
124
|
templateData: {
|
|
122
|
-
resourceLocation: SOURCE_PATH.resourceLocationFlowSchemaRegister,
|
|
125
|
+
resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchemaRegister, "source/"),
|
|
123
126
|
additionalResourcePermission,
|
|
124
127
|
functionName,
|
|
125
128
|
handlerType,
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
<%_ const join = require('path').join; _%>
|
|
2
2
|
<%- firstLetterUpperCase(functionNameConfig) %>:
|
|
3
|
-
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}
|
|
4
|
-
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName)
|
|
3
|
+
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}Complete_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
|
+
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %>Complete<%- firstLetterUpperCase(handlerType) %>
|
|
5
5
|
events:
|
|
6
6
|
- sqs:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %>
|
|
8
|
+
batchSize: 10
|
|
9
|
+
filterPatterns: #**** need to update serverless framwork upper v.2.69.1
|
|
10
|
+
- body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%- functionName %>"]}}} # functionName of callingFlow
|
|
11
|
+
- body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
|
|
12
12
|
role: <%- roleName %>Role
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
#<#<%- functionName %><%- handlerType %>IamRole#>
|
|
14
|
+
#<#/<%- functionName %><%- handlerType %>IamRole#>
|
|
15
15
|
<%_ function firstLetterUpperCase(text){
|
|
16
16
|
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
17
17
|
} _%>
|
package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/handler/data.js
CHANGED
|
@@ -32,7 +32,7 @@ const templatePath = path.join(__dirname, "template.ejs")
|
|
|
32
32
|
* @return {{templatePath, templateData,setting}}
|
|
33
33
|
*/
|
|
34
34
|
function data(_izContext, srcPath) {
|
|
35
|
-
let queueName = FUNCTION_NAME.flowSchemaRegister
|
|
35
|
+
let queueName = FUNCTION_NAME.flowSchemaRegister;
|
|
36
36
|
let functionName = FUNCTION_NAME.flowSchemaRegister + 'Complete'
|
|
37
37
|
let handlerType = upperCase(HANDLER.hdrSqs);
|
|
38
38
|
return [{
|
|
@@ -29,16 +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
34
|
const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
|
|
35
|
-
const NoRetryError = require('@izara_project/izara-core-library-core')
|
|
35
|
+
const { NoRetryError } = require('@izara_project/izara-core-library-core')
|
|
36
36
|
const { v4: uuidv4 } = require('uuid')
|
|
37
37
|
const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
|
|
38
|
-
const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
|
|
38
|
+
// const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
|
|
39
|
+
const { generateCodeLibs: { consts: TOPIC_NAME_GENERATE_CODE } } = require('@izara_project/izara-market-library-service-schemas')
|
|
40
|
+
|
|
39
41
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
42
|
* description of function.
|
|
43
43
|
* @param {Object} _izContext
|
|
44
44
|
* @param {CorrelationIds} _izContext.correlationIds - property of _izContext
|
|
@@ -47,10 +47,8 @@ const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-librar
|
|
|
47
47
|
* @param {Object} requestParams.identifiers - identifiers for get data
|
|
48
48
|
* @param {Object} requestParams.additionalRequest - additionalRequest
|
|
49
49
|
*
|
|
50
|
-
*
|
|
51
50
|
* @returns {object} description of return value
|
|
52
51
|
*/
|
|
53
|
-
|
|
54
52
|
module.exports.<%- functionMain%> = async (
|
|
55
53
|
_izContext,
|
|
56
54
|
requestParams,
|
|
@@ -63,8 +61,8 @@ module.exports.<%- functionMain%> = async (
|
|
|
63
61
|
_izContext.logger.debug("WebSocketInvoke requestParams", requestParams)
|
|
64
62
|
_izContext.logger.debug("WebSocketInvoke callingFlowConfig", callingFlowConfig)
|
|
65
63
|
|
|
66
|
-
const connectionId =
|
|
67
|
-
let correlationId =
|
|
64
|
+
const connectionId = requestContext.connectionId;
|
|
65
|
+
let correlationId = _izContext.correlationIds.get(consts.X_CORRELATION_ID);
|
|
68
66
|
|
|
69
67
|
const getRegisterRecords = await dynamodbSharedLib.getItem(
|
|
70
68
|
_izContext,
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
|
|
20
|
+
const path = require("path")
|
|
21
|
+
|
|
22
|
+
const templatePath = path.join(__dirname, '../../../resourceYaml/dynamodb/template.ejs')
|
|
23
|
+
const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, defaultIamRolePerAction, DYNAMO_RESOURCE, RESOURCE_CLASSES, resourceNames, createIamRole, SOURCE_GENERATE_IAM_ROLE } = require('../../../../../MainLibs/src/Consts.js')
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* create param of crateSouce for FindData And processLogical
|
|
27
|
+
*
|
|
28
|
+
* @param {Object} _izContext
|
|
29
|
+
* @param {String} srcPath
|
|
30
|
+
* @returns {Object[]}
|
|
31
|
+
*/
|
|
32
|
+
const createRegisterTable = (_izContext, srcPath) => {
|
|
33
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
34
|
+
const tableName = "FlowTagRegisterRecords";
|
|
35
|
+
additionalResourcePermission.push(
|
|
36
|
+
createIamRole(
|
|
37
|
+
{
|
|
38
|
+
[RESOURCE_CLASSES.dynamoDbTable]: [
|
|
39
|
+
DYNAMO_RESOURCE.putItem,
|
|
40
|
+
DYNAMO_RESOURCE.getItem,
|
|
41
|
+
DYNAMO_RESOURCE.query,
|
|
42
|
+
DYNAMO_RESOURCE.deleteItem,
|
|
43
|
+
DYNAMO_RESOURCE.updateItem
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
[
|
|
47
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, tableName)
|
|
48
|
+
]
|
|
49
|
+
),
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
return [{
|
|
53
|
+
templatePath: templatePath,
|
|
54
|
+
templateData: {
|
|
55
|
+
tableName: tableName,
|
|
56
|
+
resourceName: tableName,
|
|
57
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.RegisterRole,
|
|
58
|
+
additionalResourcePermission,
|
|
59
|
+
attributes: [
|
|
60
|
+
{
|
|
61
|
+
keyType: "partitionKey",
|
|
62
|
+
AttributeName: "identifierTask",
|
|
63
|
+
AttributeType: "S"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
keyType: "sortKey",
|
|
67
|
+
AttributeName: "connectionId",
|
|
68
|
+
AttributeType: "S"
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
setting: {
|
|
73
|
+
initialData: 'Resources:\n',
|
|
74
|
+
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
75
|
+
saveFileName: SAVE_FILE_NAME.dynamoDbYaml,
|
|
76
|
+
fileExtension: '.yml',
|
|
77
|
+
isAppend: true
|
|
78
|
+
}
|
|
79
|
+
}];
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
module.exports = createRegisterTable;
|
|
@@ -48,7 +48,7 @@ function createDataForSnsIn(_izContext, srcPath) {
|
|
|
48
48
|
return [{
|
|
49
49
|
templatePath: templatePath,
|
|
50
50
|
templateData: {
|
|
51
|
-
queueName: FUNCTION_NAME.flowSchemaRegister
|
|
51
|
+
queueName: upperCase(FUNCTION_NAME.flowSchemaRegister),
|
|
52
52
|
firstLetterUpperCase: upperCase,
|
|
53
53
|
roleName: SOURCE_GENERATE_IAM_ROLE.RegisterRole,
|
|
54
54
|
},
|
package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/template.ejs
CHANGED
|
@@ -9,4 +9,37 @@
|
|
|
9
9
|
- <%- queueName %>DLQ
|
|
10
10
|
- Arn
|
|
11
11
|
maxReceiveCount: 3
|
|
12
|
-
VisibilityTimeout: 120
|
|
12
|
+
VisibilityTimeout: 120
|
|
13
|
+
##==== [QueueDLQ]
|
|
14
|
+
<%- queueName %>DLQ:
|
|
15
|
+
Type: AWS::SQS::Queue
|
|
16
|
+
Properties:
|
|
17
|
+
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>DLQ
|
|
18
|
+
##==== [QueuePolicy]
|
|
19
|
+
<%- queueName %>Policy:
|
|
20
|
+
Type: AWS::SQS::QueuePolicy
|
|
21
|
+
Properties:
|
|
22
|
+
PolicyDocument:
|
|
23
|
+
Version: "2012-10-17"
|
|
24
|
+
Statement:
|
|
25
|
+
- Sid: "allow-sns-messages"
|
|
26
|
+
Effect: Allow
|
|
27
|
+
Principal: "*"
|
|
28
|
+
Resource:
|
|
29
|
+
# !GetAtt
|
|
30
|
+
Fn::GetAtt:
|
|
31
|
+
- <%- queueName %>
|
|
32
|
+
- Arn
|
|
33
|
+
Action: "SQS:SendMessage"
|
|
34
|
+
Queues:
|
|
35
|
+
- Ref: <%- queueName %>
|
|
36
|
+
#<#<%- firstLetterUpperCase(queueName) %>QueueSetting#>
|
|
37
|
+
#<#/<%- firstLetterUpperCase(queueName) %>QueueSetting#>
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
<%_ function firstLetterUpperCase(text){
|
|
41
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
42
|
+
} _%>
|
|
43
|
+
<%_ function firstLetterLowerCase(str) {
|
|
44
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
45
|
+
} _%>
|
package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs
CHANGED
|
@@ -1,34 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
function createExpiryTime (_izContext, expiryInterval) {
|
|
3
|
-
const currentTime = new Date();
|
|
4
|
-
const expiryTime = new Date(currentTime);
|
|
5
|
-
expiryTime.setTime(expiryTime.getTime() + expiryInterval);
|
|
6
|
-
return expiryTime.getTime();
|
|
7
|
-
};
|
|
1
|
+
let expiryTime = storedCacheSharedLib.createExpiryTime(_izContext, 31536000);
|
|
8
2
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
cacheUniqueRequestId: _izContext.uniqueRequestId
|
|
19
|
-
}
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
await dynamodbSharedLib.updateItem(_izContext,
|
|
23
|
-
await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
|
|
24
|
-
{
|
|
25
|
-
taskKey: correlationId,
|
|
26
|
-
connectionId: connectionId,
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
identifiersTask: hash({
|
|
30
|
-
//(<updateStoredCacheId>)
|
|
31
|
-
//(</updateStoredCacheId>)
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
)
|
|
3
|
+
let createCacheId = hash({
|
|
4
|
+
//(<optionalParams>)
|
|
5
|
+
//(</optionalParams>)
|
|
6
|
+
})
|
|
7
|
+
let [ cacheMainStauts, cacheId, cacheMain ] = await storedCacheSharedLib.checkStoredCacheStatus(
|
|
8
|
+
_izContext,
|
|
9
|
+
"<%- tableName %>",
|
|
10
|
+
createCacheId
|
|
11
|
+
)
|
package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/data.js
CHANGED
|
@@ -45,18 +45,18 @@ const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, HANDLER } = require('../../.
|
|
|
45
45
|
*/
|
|
46
46
|
|
|
47
47
|
function createDataForSubscriptionOutAll(_izContext, allLocalFlowSchemas, srcPath) {
|
|
48
|
-
console.log("allLocalFlowSchemas", allLocalFlowSchemas.records)
|
|
48
|
+
// console.log("allLocalFlowSchemas", allLocalFlowSchemas.records)
|
|
49
49
|
const result = []
|
|
50
50
|
for (const flowSchema of allLocalFlowSchemas.records) {
|
|
51
51
|
let event = flowSchema.event;
|
|
52
52
|
if (!event.includes("eventBridge")) {
|
|
53
|
-
const flowStepOut = Object.keys(flowSchema.flowSteps)[1]
|
|
54
|
-
console.log("flowStepOut", flowStepOut)
|
|
53
|
+
const flowStepOut = Object.keys(flowSchema.flowSteps)[1].split("_")
|
|
54
|
+
// console.log("flowStepOut", flowStepOut)
|
|
55
55
|
result.push({
|
|
56
56
|
templatePath: templatePath,
|
|
57
57
|
templateData: {
|
|
58
|
-
queueName: flowStepOut,
|
|
59
|
-
endpoint: "
|
|
58
|
+
queueName: flowStepOut[4] + flowStepOut[3],
|
|
59
|
+
endpoint: "Register",
|
|
60
60
|
firstLetterUpperCase: upperCase,
|
|
61
61
|
},
|
|
62
62
|
setting: {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
##===== [Topic In]
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
Subscription<%- queueName %>:
|
|
3
|
+
Type: AWS::SNS::Subscription
|
|
4
|
+
Properties:
|
|
5
|
+
TopicArn: !Ref <%- queueName %>
|
|
6
|
+
Endpoint: "arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- endpoint %>"
|
|
7
|
+
Protocol: "sqs"
|
|
8
8
|
<%_ function firstLetterUpperCase(text){
|
|
9
9
|
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
10
10
|
} _%>
|
package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/data.js
CHANGED
|
@@ -47,12 +47,11 @@ const hookTemplate = path.join(__dirname, "./hookTemplate.ejs");
|
|
|
47
47
|
* @param {Object} objectSchema
|
|
48
48
|
* @return {{templatePath, templateData,setting}}
|
|
49
49
|
*/
|
|
50
|
-
function data(_izContext, srcPath) {
|
|
50
|
+
function data(_izContext, allLocalFlowSchemas, srcPath) {
|
|
51
51
|
const handlerType = upperCase("hdrWbs");
|
|
52
52
|
const functionName = FUNCTION_NAME.flowSchemaRegister;
|
|
53
53
|
let functionNameConfig = upperCase(functionName) + upperCase(shortNameHandler(handlerType));
|
|
54
54
|
let additionalResourcePermission = defaultIamRolePerAction();
|
|
55
|
-
let route = "webSocket";
|
|
56
55
|
|
|
57
56
|
additionalResourcePermission.push(
|
|
58
57
|
createIamRole(
|
|
@@ -91,6 +90,30 @@ function data(_izContext, srcPath) {
|
|
|
91
90
|
)
|
|
92
91
|
)
|
|
93
92
|
|
|
93
|
+
let tableStoredCacheList = [];
|
|
94
|
+
for (const flowSchema of allLocalFlowSchemas.records) {
|
|
95
|
+
if (flowSchema.statusType === "storedCache") {
|
|
96
|
+
tableStoredCacheList.push(flowSchema.flowTag + "Main");
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
additionalResourcePermission.push(
|
|
101
|
+
createIamRole(
|
|
102
|
+
{
|
|
103
|
+
[RESOURCE_CLASSES.dynamoDbTable]: [
|
|
104
|
+
DYNAMO_RESOURCE.getItem,
|
|
105
|
+
// DYNAMO_RESOURCE.putItem,
|
|
106
|
+
// DYNAMO_RESOURCE.query,
|
|
107
|
+
// DYNAMO_RESOURCE.deleteItem,
|
|
108
|
+
// DYNAMO_RESOURCE.updateItem
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
[
|
|
112
|
+
...tableStoredCacheList.map(tableName => resourceNames(RESOURCE_CLASSES.dynamoDbTable, tableName))
|
|
113
|
+
]
|
|
114
|
+
)
|
|
115
|
+
)
|
|
116
|
+
|
|
94
117
|
// if (flowSchema?.hook) {
|
|
95
118
|
// for (const [hookName, hookProperties] of Object.entries(flowSchema.hook)) {
|
|
96
119
|
// if (hookName === FLOW_SCHEMA_HOOK_STATE.beforeCreate) {
|
|
@@ -122,9 +145,8 @@ function data(_izContext, srcPath) {
|
|
|
122
145
|
return [{
|
|
123
146
|
templatePath: templatePath,
|
|
124
147
|
templateData: {
|
|
125
|
-
resourceLocation: SOURCE_PATH.resourceLocationFlowSchemaRegister,
|
|
148
|
+
resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchemaRegister, "source/"),
|
|
126
149
|
additionalResourcePermission,
|
|
127
|
-
route,
|
|
128
150
|
functionName,
|
|
129
151
|
handlerType,
|
|
130
152
|
roleName: SOURCE_GENERATE_IAM_ROLE.RegisterRole,
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
5
|
events:
|
|
6
6
|
- websocket:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
route: <%- functionName %>
|
|
8
|
+
# authorizer: ${self:custom.iz_authorizerAppLevel}
|
|
9
|
+
# identifierResource: 'route.request.header.Auth'
|
|
10
10
|
role: <%- roleName %>Role
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
#<#<%- functionName %><%- handlerType %>IamRole#>
|
|
12
|
+
#<#/<%- functionName %><%- handlerType %>IamRole#>
|
|
13
13
|
<%_ function firstLetterUpperCase(text){
|
|
14
14
|
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
15
15
|
} _%>
|
package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/handler/template.ejs
CHANGED
|
@@ -21,11 +21,10 @@ const { middlewareHandler, consts } = require("@izara_project/izara-middleware")
|
|
|
21
21
|
// const AWS = require('aws-sdk');
|
|
22
22
|
// const api = new AWS.ApiGatewayManagementApi({ endpoint: process.env.iz_webSocketEndpoint });
|
|
23
23
|
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
|
|
24
|
-
const callingFlowSharedLib = require('@izara_project/izara-core-calling-flow');
|
|
24
|
+
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
25
25
|
const hash = require('object-hash');
|
|
26
26
|
// const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
|
|
27
|
-
const
|
|
28
|
-
const { postToConnection } = require("../../libs/source/ImportDataLib");
|
|
27
|
+
const { postToConnection } = require("../../../libs/source/GenerateCodeLibs");
|
|
29
28
|
const { <%- functionName%>Main } = require("./<%- firstLetterUpperCase(functionName) %>_Main");
|
|
30
29
|
|
|
31
30
|
module.exports.main = middlewareHandler.wrap(async (event, context, callback) => {
|
|
@@ -58,13 +57,17 @@ module.exports.main = middlewareHandler.wrap(async (event, context, callback) =>
|
|
|
58
57
|
|
|
59
58
|
let callingFlow = eventParams?.callingFlow ? eventParams.callingFlow : {};
|
|
60
59
|
|
|
61
|
-
await
|
|
60
|
+
const result = await registerMain(
|
|
62
61
|
event._izContext,
|
|
63
62
|
eventParams,
|
|
64
63
|
callingFlowSharedLib.addCallingFlowToPassOnProperties(callingFlow)
|
|
65
64
|
//(<additionalParams>)
|
|
66
65
|
//(</additionalParams>)
|
|
67
66
|
)
|
|
67
|
+
await postToConnection(
|
|
68
|
+
{ message: result },
|
|
69
|
+
connectionId
|
|
70
|
+
)
|
|
68
71
|
break
|
|
69
72
|
}
|
|
70
73
|
} else {
|
|
@@ -72,15 +75,11 @@ module.exports.main = middlewareHandler.wrap(async (event, context, callback) =>
|
|
|
72
75
|
// await postMessage({ message: event.message }, connId);
|
|
73
76
|
await postToConnection({ message: event.message }, connId);
|
|
74
77
|
}
|
|
75
|
-
|
|
76
|
-
return (izara.response.webSocketSuccess());
|
|
77
|
-
|
|
78
78
|
} catch (err) {
|
|
79
79
|
const connId = event.requestContext.connectionId
|
|
80
80
|
event._izContext.logger.error('Error, WebSocket: ', err);
|
|
81
81
|
// await sendErrorMessage({ message: err.message }, connId);
|
|
82
82
|
await postToConnection({ message: err.message }, connId);
|
|
83
|
-
return (izara.response.failure(err));
|
|
84
83
|
}
|
|
85
84
|
});
|
|
86
85
|
<%_ const join = require('path').join _%>
|