@izara_project/izara-market-library-service-schemas 1.0.57 → 1.0.59
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/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +23 -9
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +17 -72
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +8 -32
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +2 -2
- package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +3 -21
- package/src/reStructure/TemplateData/externalService/lambdaRole/template.ejs +2 -0
- package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +2 -0
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/functionYaml/data.js +2 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/data.js +0 -14
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +13 -8
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/handler/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +12 -10
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/data.js +31 -7
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +10 -9
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrS3/template.ejs +0 -3
- package/src/reStructure/TemplateData/flowSchema/components/upload/relate/S3/data.js +4 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/relate/S3/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/template.ejs +2 -45
- package/src/reStructure/TemplateData/flowSchema/components/upload/relate/sns-out/data.js +75 -0
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/template.ejs +16 -16
- package/src/reStructure/TemplateData/flowSchema/components/websocket/dynamoDb/ttlDynamoTemplate.ejs +32 -0
- package/src/reStructure/TemplateData/flowSchema/components/websocket/dynamoDb/userUploadRecords.js +58 -0
- package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/handler/template.ejs +20 -2
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +24 -16
- package/src/reStructure/TemplateData/flowSchema/webSocketComplete/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/webSocketComplete/mainFunction/template.ejs +33 -21
- package/src/reStructure/TemplateData/perActionComplete/update/mainFunction/template.ejs +4 -1
- package/src/reStructure/TemplateData/processLogical/mainFunction/template.ejs +2 -2
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +1 -1
- package/src/reStructure/TemplateData/resourceYaml/filterGenerateResource/data.js +10 -15
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrDsq/data.js +0 -87
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrDsq/template.ejs +0 -30
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/handler/handlerDsq/data.js +0 -45
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/handler/handlerDsq/template.ejs +0 -151
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/request.json +0 -7
|
@@ -3,9 +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
|
-
- sqs:
|
|
7
|
-
arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- functionName %>
|
|
8
|
-
batchSize: 10
|
|
9
6
|
- s3:
|
|
10
7
|
bucket: <%- bucketName %>
|
|
11
8
|
event: s3:ObjectCreated:*
|
|
@@ -36,10 +36,13 @@ function data(_izContext, flowSchema, srcPath) {
|
|
|
36
36
|
|
|
37
37
|
function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
38
38
|
let bucketName = flowSchema.bucketName
|
|
39
|
+
let resourceName = bucketName.split("-").join("")
|
|
40
|
+
|
|
39
41
|
return {
|
|
40
42
|
templatePath: templatePath,
|
|
41
43
|
templateData: {
|
|
42
|
-
bucketName
|
|
44
|
+
bucketName,
|
|
45
|
+
resourceName
|
|
43
46
|
},
|
|
44
47
|
setting: {
|
|
45
48
|
initialData: 'Resources:\n',
|
|
@@ -22,10 +22,7 @@ const lambda = externalRequest.lambda;
|
|
|
22
22
|
const lambdaSharedLib = require('@izara_project/izara-core-library-lambda')
|
|
23
23
|
const { ApiGatewayManagementApiClient, PostToConnectionCommand } = require("@aws-sdk/client-apigatewaymanagementapi");
|
|
24
24
|
const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
25
|
-
|
|
26
|
-
const csv = require('csv-parser');
|
|
27
|
-
const streamifier = require('streamifier');
|
|
28
|
-
<% } %>
|
|
25
|
+
|
|
29
26
|
const { NoRetryError,inMemoryCacheLib } = require('@izara_project/izara-core-library-core');
|
|
30
27
|
|
|
31
28
|
const client = new ApiGatewayManagementApiClient({
|
|
@@ -74,43 +71,6 @@ const processStaticLimitWithCache = inMemoryCacheLib(
|
|
|
74
71
|
}
|
|
75
72
|
)
|
|
76
73
|
|
|
77
|
-
<% if (uploadS3) { %>
|
|
78
|
-
/**
|
|
79
|
-
*
|
|
80
|
-
* @param {Object} _izContext
|
|
81
|
-
* @param {Object} data - S3 data
|
|
82
|
-
* @returns
|
|
83
|
-
*/
|
|
84
|
-
async function isValidCsv(_izContext, data) {
|
|
85
|
-
_izContext.logger.debug("function checkValidCsv", { data })
|
|
86
|
-
let errorCheckCsv = [];
|
|
87
|
-
let validCsv = true;
|
|
88
|
-
let rowCount = 0;
|
|
89
|
-
let columnCount = null;
|
|
90
|
-
|
|
91
|
-
streamifier.createReadStream(data.Body).pipe(csv()).on('data', (row) => {
|
|
92
|
-
rowCount++;
|
|
93
|
-
if (columnCount === null) {
|
|
94
|
-
columnCount = Object.keys(row).length
|
|
95
|
-
} else if (Object.keys(row).length !== columnCount) {
|
|
96
|
-
validCsv = false
|
|
97
|
-
errorCheckCsv.push(`Row ${rowCount} has inconsistent columns: ${JSON.stringify(row)}`)
|
|
98
|
-
}
|
|
99
|
-
})
|
|
100
|
-
.on('end', () => {
|
|
101
|
-
if (rowCount === 0) {
|
|
102
|
-
errorCheckCsv.push("csv file not have data row")
|
|
103
|
-
} else {
|
|
104
|
-
_izContext.logger.debug("validCsv")
|
|
105
|
-
}
|
|
106
|
-
})
|
|
107
|
-
.on('error', (error) => {
|
|
108
|
-
errorCheckCsv.push(`error:: ${error}`)
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
return [validCsv, errorCheckCsv]
|
|
112
|
-
}
|
|
113
|
-
<% } %>
|
|
114
74
|
|
|
115
75
|
/**
|
|
116
76
|
*
|
|
@@ -135,8 +95,5 @@ module.exports = {
|
|
|
135
95
|
postToConnection,
|
|
136
96
|
processStaticLimit,
|
|
137
97
|
processStaticLimitWithCache,
|
|
138
|
-
getNestObject
|
|
139
|
-
<% if (uploadS3) { %>
|
|
140
|
-
isValidCsv,
|
|
141
|
-
<% } %>
|
|
98
|
+
getNestObject
|
|
142
99
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
|
|
23
|
+
// const {
|
|
24
|
+
// HANDLER,
|
|
25
|
+
// STORAGE_TYPES
|
|
26
|
+
// } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
const STORAGE_TYPES = {
|
|
30
|
+
dynamoDB: "dynamoDB",
|
|
31
|
+
graph: "graph"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const templatePath = path.join(__dirname, '../../../../../resourceYaml/sns-out/template.ejs')
|
|
35
|
+
const {
|
|
36
|
+
utils: { firstLetterUpperCase: upperCase },
|
|
37
|
+
consts: { SOURCE_PATH, SAVE_FILE_NAME }
|
|
38
|
+
} = require("../../../../../../../MainLibs")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* create data for template.ejs
|
|
43
|
+
* return array of defaultSnsOutData
|
|
44
|
+
* because must create for FindData and ProcessLogical
|
|
45
|
+
*
|
|
46
|
+
* @param {Object} _izContext
|
|
47
|
+
* @param {String} saveFilePath
|
|
48
|
+
* @returns {Object[]} - data of multiple defaultSnsOutData
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
function createDataForDefaultSnsOut(_izContext, flowSchema, srcPath) {
|
|
52
|
+
let resultsForCreateDefaultSnsOut = [];
|
|
53
|
+
const defaultSnsOutDataList = [
|
|
54
|
+
{
|
|
55
|
+
queueName: upperCase(flowSchema.flowTag)
|
|
56
|
+
},
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
for (let defaultSnsOutData of defaultSnsOutDataList) {
|
|
60
|
+
resultsForCreateDefaultSnsOut.push({
|
|
61
|
+
templatePath: templatePath,
|
|
62
|
+
templateData: defaultSnsOutData,
|
|
63
|
+
setting: {
|
|
64
|
+
initialData: "Resources:\n",
|
|
65
|
+
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
66
|
+
saveFileName: SAVE_FILE_NAME.snsOutYaml,
|
|
67
|
+
fileExtension: ".yml",
|
|
68
|
+
isAppend: true
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
return resultsForCreateDefaultSnsOut;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
module.exports = createDataForDefaultSnsOut;
|
package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/template.ejs
CHANGED
|
@@ -28,33 +28,33 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
28
28
|
const { eventType, connectionId } = event.requestContext
|
|
29
29
|
try {
|
|
30
30
|
|
|
31
|
-
let userId = event.queryStringParameters.userId
|
|
32
|
-
let submitByUserId = event.queryStringParameters.submitByUserId
|
|
33
|
-
let correlationIds = event._izContext.correlationIds.get(izara.consts.X_CORRELATION_ID)
|
|
34
|
-
|
|
35
31
|
if (event.requestContext) {
|
|
36
32
|
switch (eventType) {
|
|
37
33
|
case 'CONNECT':
|
|
38
34
|
console.log('Connect websocket')
|
|
35
|
+
|
|
36
|
+
let { userId, submittedByUserId } = event.queryStringParameters;
|
|
37
|
+
|
|
39
38
|
await dynamodbSharedLib.putItem(event._izContext,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
await dynamodbSharedLib.tableName(event._izContext, "UserUploadRecords"),
|
|
40
|
+
{
|
|
41
|
+
connectionId: connectionId,
|
|
42
|
+
userId: userId,
|
|
43
|
+
submittedByUserId: submittedByUserId,
|
|
44
|
+
expirationTime: Math.floor(Date.now() / 1000) + 7200 // ttl time milliSecond to second + 2 hour
|
|
45
|
+
}
|
|
46
|
+
)
|
|
47
47
|
//(<webSocketConnect>)
|
|
48
48
|
//(</webSocketConnect>)
|
|
49
49
|
break
|
|
50
50
|
case 'DISCONNECT':
|
|
51
51
|
console.log('Websocket are Disconnection')
|
|
52
52
|
await dynamodbSharedLib.deleteItem(event._izContext,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
await dynamodbSharedLib.tableName(event._izContext, "UserUploadRecords"),
|
|
54
|
+
{
|
|
55
|
+
connectionId: connectionId,
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
58
|
//(<webSocketDisconnect>)
|
|
59
59
|
//(</webSocketDisconnect>)
|
|
60
60
|
break
|
package/src/reStructure/TemplateData/flowSchema/components/websocket/dynamoDb/ttlDynamoTemplate.ejs
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<%- resourceName %>Table:
|
|
2
|
+
Type: "AWS::DynamoDB::Table"
|
|
3
|
+
Properties:
|
|
4
|
+
TableName: ${self:custom.iz_resourcePrefix}<%- tableName %>
|
|
5
|
+
BillingMode: PAY_PER_REQUEST
|
|
6
|
+
AttributeDefinitions:
|
|
7
|
+
<%_ attributes.forEach(attribute => { -%>
|
|
8
|
+
- AttributeName: <%- attribute['AttributeName'] %>
|
|
9
|
+
AttributeType: <%- attribute['AttributeType'] %>
|
|
10
|
+
<%_ }) _%>
|
|
11
|
+
KeySchema:
|
|
12
|
+
<%_ attributes.forEach(attribute => { -%>
|
|
13
|
+
<%_ if (attribute.keyType === 'partitionKey' || attribute.keyType === "identifier") { -%>
|
|
14
|
+
- AttributeName: <%- attribute["AttributeName"] %>
|
|
15
|
+
KeyType: HASH
|
|
16
|
+
<%_ } -%>
|
|
17
|
+
<%_ if(attribute.keyType === "sortKey") { -%>
|
|
18
|
+
- AttributeName: <%- attribute["AttributeName"] %>
|
|
19
|
+
KeyType: RANGE
|
|
20
|
+
<%_ } -%>
|
|
21
|
+
<%_ }) _%>
|
|
22
|
+
TimeToLiveSpecification:
|
|
23
|
+
AttributeName: expirationTime
|
|
24
|
+
Enabled: true
|
|
25
|
+
#<#<%- firstLetterUpperCase(tableName) %>DynamoDbSetting#>
|
|
26
|
+
#<#/<%- firstLetterUpperCase(tableName) %>DynamoDbSetting#>
|
|
27
|
+
<%_ function firstLetterUpperCase(text){
|
|
28
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
29
|
+
} _%>
|
|
30
|
+
<%_ function firstLetterLowerCase(str) {
|
|
31
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
32
|
+
} _%>
|
package/src/reStructure/TemplateData/flowSchema/components/websocket/dynamoDb/userUploadRecords.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
const { SOURCE_PATH, SAVE_FILE_NAME } = require('../../../../../../MainLibs/src/Consts');
|
|
21
|
+
|
|
22
|
+
const templatePath = path.join(__dirname, "./ttlDynamoTemplate.ejs")
|
|
23
|
+
|
|
24
|
+
function data(_izContext, srcPath) {
|
|
25
|
+
let resultForCreateSources = [];
|
|
26
|
+
const userUploadRecords = [
|
|
27
|
+
{
|
|
28
|
+
tableName: "UserUploadRecords",
|
|
29
|
+
resourceName: "UserUploadRecords",
|
|
30
|
+
attributes: [
|
|
31
|
+
{
|
|
32
|
+
keyType: "partitionKey",
|
|
33
|
+
AttributeName: "connectionId",
|
|
34
|
+
AttributeType: "S"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
for (let userUploadRecord of userUploadRecords) {
|
|
41
|
+
resultForCreateSources.push(
|
|
42
|
+
{
|
|
43
|
+
templatePath: templatePath,
|
|
44
|
+
templateData: userUploadRecord,
|
|
45
|
+
setting: {
|
|
46
|
+
initialData: 'Resources:\n',
|
|
47
|
+
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
48
|
+
saveFileName: SAVE_FILE_NAME.dynamoDbYaml,
|
|
49
|
+
fileExtension: ".yml",
|
|
50
|
+
isAppend: true
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
return resultForCreateSources;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
module.exports = data;
|
|
@@ -24,15 +24,29 @@ const izara = require("@izara_project/izara-middleware");
|
|
|
24
24
|
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
|
+
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
28
28
|
const <%- functionName %> = require('./<%- functionName %>_Main')
|
|
29
29
|
|
|
30
|
+
middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema(
|
|
31
|
+
{
|
|
32
|
+
type: "object",
|
|
33
|
+
required: ['body', 'messageAttributes'],
|
|
34
|
+
properties: {
|
|
35
|
+
body: {
|
|
36
|
+
type: 'object',
|
|
37
|
+
},
|
|
38
|
+
messageAttributes: {
|
|
39
|
+
type: 'object'
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
));
|
|
44
|
+
|
|
30
45
|
// validate event properties in body.Message of sqs event
|
|
31
46
|
let perRecordsValidatorSchema = {
|
|
32
47
|
//(<validatorSchema>)
|
|
33
48
|
//(</validatorSchema>)
|
|
34
49
|
}
|
|
35
|
-
middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
|
|
36
50
|
|
|
37
51
|
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
38
52
|
|
|
@@ -43,6 +57,9 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
43
57
|
// loop each record and send to mainFunction
|
|
44
58
|
await Promise.all(event.Records.map(async record => { // promise.all for map() function
|
|
45
59
|
|
|
60
|
+
record = recordHandlerSharedLib.reformatDsqMessage(record._izContext, record);
|
|
61
|
+
record._izContext.logger.debug('record LambdaFunctionHdrDsq after reform', record);
|
|
62
|
+
|
|
46
63
|
let passOnProperties = []
|
|
47
64
|
record._izContext.logger.debug('record ReceiveMsgOutHdrSqs', record);
|
|
48
65
|
|
|
@@ -58,6 +75,7 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
58
75
|
passOnProperties.push(record.body.Message)
|
|
59
76
|
//(<additionalParams>)
|
|
60
77
|
//(</additionalParams>)
|
|
78
|
+
passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
|
|
61
79
|
record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
|
|
62
80
|
|
|
63
81
|
// call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
|
|
@@ -29,21 +29,23 @@ const {
|
|
|
29
29
|
|
|
30
30
|
// Core components
|
|
31
31
|
const createWebSocketDynamoDb = require('./components/websocket/dynamoDb/WebSocketTaskData');
|
|
32
|
+
const createUserUploadRecordTable = require('./components/websocket/dynamoDb/userUploadRecords')
|
|
32
33
|
const createReservedDataMainTable = require('./components/websocket/dynamoDb/ReservedTableData');
|
|
33
34
|
const createBucketS3 = require('./components/upload/relate/S3/data');
|
|
34
35
|
const createWebSocketGenerateCodeLibs = require('./components/upload/relate/libs/data');
|
|
35
36
|
const createWebSocketConnectYaml = require('./components/websocket/connect/functionYaml/data')
|
|
36
37
|
const createWebSocketConnectHandler = require('./components/websocket/connect/handler/data')
|
|
38
|
+
const createSnsTopicForUploadS3 = require('./components/upload/relate/sns-out/data')
|
|
37
39
|
// CreateObject components
|
|
38
40
|
const createFunctionYamlCreateObjectWebSocket = require('./components/upload/createObject/functionYaml/data');
|
|
39
41
|
const createHandlerCreateObjectWebSocket = require('./components/upload/createObject/handler/data');
|
|
40
42
|
const createMainFunctionCreateObjectWebSocket = require('./components/upload/createObject/mainFunction/data');
|
|
41
43
|
|
|
42
44
|
// CreateObjectComplete components
|
|
43
|
-
const createWebSocketCreateObjectCompleteFunctionYaml = require('./components/upload/createObjectComplete/functionYaml/data');
|
|
44
|
-
const createWebSocketCreateObjectCompleteQueue = require('./components/upload/createObjectComplete/sns-sqs/data');
|
|
45
|
-
const createWebSocketCreateObjectCompleteHandler = require('./components/upload/createObjectComplete/handler/data');
|
|
46
|
-
const createWebSocketCreateObjectCompleteMainFunction = require('./components/upload/createObjectComplete/mainFunction/data');
|
|
45
|
+
// const createWebSocketCreateObjectCompleteFunctionYaml = require('./components/upload/createObjectComplete/functionYaml/data');
|
|
46
|
+
// const createWebSocketCreateObjectCompleteQueue = require('./components/upload/createObjectComplete/sns-sqs/data');
|
|
47
|
+
// const createWebSocketCreateObjectCompleteHandler = require('./components/upload/createObjectComplete/handler/data');
|
|
48
|
+
// const createWebSocketCreateObjectCompleteMainFunction = require('./components/upload/createObjectComplete/mainFunction/data');
|
|
47
49
|
|
|
48
50
|
// PreSign URL components
|
|
49
51
|
const createReservedLimitFunctionYaml = require('./components/upload/preSignUrl/reservedLimit/functionYaml/data');
|
|
@@ -72,9 +74,9 @@ const createConfirmAfterUploadS3Queue = require('./components/upload/confirmRese
|
|
|
72
74
|
// flowSchema ExternalTopic components //
|
|
73
75
|
const createExternalSqsFunctionYaml = require('./externalTopic/Process/functionYaml/data');
|
|
74
76
|
const createExternalSqsHandler = require('./externalTopic/Process/handler/data');
|
|
75
|
-
const createExternalSqsCompleteFunctionYaml = require("./externalTopic/Complete/functionYaml/data");
|
|
76
|
-
const createExternalSqsCompleteHandler = require("./externalTopic/Complete/handler/data");
|
|
77
|
-
const createExternalSqsCompleteMainFunction = require("./externalTopic/Complete/mainFunction/data");
|
|
77
|
+
// const createExternalSqsCompleteFunctionYaml = require("./externalTopic/Complete/functionYaml/data");
|
|
78
|
+
// const createExternalSqsCompleteHandler = require("./externalTopic/Complete/handler/data");
|
|
79
|
+
// const createExternalSqsCompleteMainFunction = require("./externalTopic/Complete/mainFunction/data");
|
|
78
80
|
const createExternalTopicSnsInSqs = require('./externalTopic/sns-in-sqs/data');
|
|
79
81
|
const createExternalTopicSnsOut = require('./externalTopic/sns-out/data')
|
|
80
82
|
|
|
@@ -101,9 +103,9 @@ const createFlowSchemaFlowStepHandler = require('./flowStep/handler/data');
|
|
|
101
103
|
const createFlowSchemaFlowStepMainFunction = require('./flowStep/mainFunction/data')
|
|
102
104
|
const createFlowSchemaFlowStepSnsIn = require('./flowStep/sns-in/data');
|
|
103
105
|
// flowSchema OwnTopicEndpointComplete component
|
|
104
|
-
const createFlowSchemaOwnTopicEndpointCompleteFuntionYaml = require('./flowSchemaOwnTopic/EndpointComplete/functionYaml/data');
|
|
105
|
-
const createFlowSchemaOwnTopicEndpointCompleteHandler = require('./flowSchemaOwnTopic/EndpointComplete/handler/data');
|
|
106
|
-
const createFlowSchemaOwnTopicEndpointCompleteMainFunction = require('./flowSchemaOwnTopic/EndpointComplete/mainFunction/data');
|
|
106
|
+
// const createFlowSchemaOwnTopicEndpointCompleteFuntionYaml = require('./flowSchemaOwnTopic/EndpointComplete/functionYaml/data');
|
|
107
|
+
// const createFlowSchemaOwnTopicEndpointCompleteHandler = require('./flowSchemaOwnTopic/EndpointComplete/handler/data');
|
|
108
|
+
// const createFlowSchemaOwnTopicEndpointCompleteMainFunction = require('./flowSchemaOwnTopic/EndpointComplete/mainFunction/data');
|
|
107
109
|
|
|
108
110
|
const createFlowSchemaOwnTopicQueue = require('./flowSchemaOwnTopic/sns-in/data');
|
|
109
111
|
const createFlowSchemaOwnTopicSnsOut = require('./flowSchemaOwnTopic/sns-out/data');
|
|
@@ -121,10 +123,10 @@ const createFlowSchemaLambdaSyncHandlerApi = require("./lambdaSync/Api/handler/d
|
|
|
121
123
|
|
|
122
124
|
const createAwaitingMultipleStepDynamoDbData = require('./dynamoDb/data');
|
|
123
125
|
// create record status Field Complete
|
|
124
|
-
const createCreateObjectCompleteFunctionYaml = require('./CreateRecordComplete/functionYaml/data');
|
|
125
|
-
const createCreateObjectCompleteHandler = require('./CreateRecordComplete/handler/data');
|
|
126
|
-
const createCreateObjectCompleteMainFunction = require('./CreateRecordComplete/mainFunction/data');
|
|
127
|
-
const createCreateObjectCompleteQueue = require('./CreateRecordComplete/queue/data');// flowSchema Register component //
|
|
126
|
+
// const createCreateObjectCompleteFunctionYaml = require('./CreateRecordComplete/functionYaml/data');
|
|
127
|
+
// const createCreateObjectCompleteHandler = require('./CreateRecordComplete/handler/data');
|
|
128
|
+
// const createCreateObjectCompleteMainFunction = require('./CreateRecordComplete/mainFunction/data');
|
|
129
|
+
// const createCreateObjectCompleteQueue = require('./CreateRecordComplete/queue/data');// flowSchema Register component //
|
|
128
130
|
|
|
129
131
|
const createFlowSchemaRegisterHandlerComplete = require('./register/complete/handler/data');
|
|
130
132
|
const createFlowSchemaRegisterMainCompleteFunc = require('./register/complete/mainFunction/data');
|
|
@@ -178,9 +180,10 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
178
180
|
for (const flowSchema of allLocalFlowSchemas.records) {
|
|
179
181
|
// console.log("flowSchema in Generate TemplateData", flowSchema);
|
|
180
182
|
const webSocketGenerateCodeLibs = createWebSocketGenerateCodeLibs(_izContext, flowSchema, saveFilePath)
|
|
183
|
+
createSourceParams.push(...webSocketGenerateCodeLibs)
|
|
181
184
|
if (!flowSchema.event.includes("s3")) {
|
|
182
185
|
const flowSchemaEndpointMainFunction = await createFlowSchemaEndpointMainFunction(_izContext, flowSchema, saveFilePath);
|
|
183
|
-
createSourceParams.push(...
|
|
186
|
+
createSourceParams.push(...flowSchemaEndpointMainFunction)
|
|
184
187
|
}
|
|
185
188
|
|
|
186
189
|
// event has [s3, extTopic, ownTopic, eventBridge, lambdaSync]
|
|
@@ -188,6 +191,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
188
191
|
if (event.includes("s3")) {
|
|
189
192
|
const reservedDataTable = createReservedDataMainTable(_izContext, saveFilePath);
|
|
190
193
|
const bucketS3 = createBucketS3(_izContext, flowSchema, saveFilePath)
|
|
194
|
+
const userUploadRecordTable = createUserUploadRecordTable(_izContext, saveFilePath)
|
|
191
195
|
|
|
192
196
|
const functionYamlCreateObjectWebSocket = createFunctionYamlCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
|
|
193
197
|
const handlerCreateObjectWebSocket = createHandlerCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
|
|
@@ -199,7 +203,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
199
203
|
|
|
200
204
|
// const webSocketCreateObjectStordCache = createWebSocketCreateObjectStoredCache(_izContext, saveFilePath);
|
|
201
205
|
|
|
202
|
-
const reservedLimitFunctionYaml = createReservedLimitFunctionYaml(_izContext, flowSchema, saveFilePath);
|
|
206
|
+
const reservedLimitFunctionYaml = await createReservedLimitFunctionYaml(_izContext, flowSchema, saveFilePath);
|
|
203
207
|
const reservedLimitHandlerFunction = createReservedLimitHandler(_izContext, flowSchema, saveFilePath);
|
|
204
208
|
const reservedLimitMainFunction = await createReservedLimitMainFunction(_izContext, flowSchema, saveFilePath);
|
|
205
209
|
const reservedLimitQueueName = createReservedLimitQueueName(_izContext, saveFilePath);
|
|
@@ -221,6 +225,8 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
221
225
|
const confirmReservedAfterUploadMainFunction = createConfirmAfterUploadS3MainFunction(_izContext, flowSchema, saveFilePath);
|
|
222
226
|
const confirmReservedAfterUploadQueue = createConfirmAfterUploadS3Queue(_izContext, saveFilePath);
|
|
223
227
|
|
|
228
|
+
const snsTopicOutFlowSchemaUploadS3 = createSnsTopicForUploadS3(_izContext, flowSchema, saveFilePath);
|
|
229
|
+
|
|
224
230
|
const webSocketFunctions = [
|
|
225
231
|
...functionYamlCreateObjectWebSocket,
|
|
226
232
|
...handlerCreateObjectWebSocket,
|
|
@@ -275,6 +281,8 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
275
281
|
...reservedLimitResources,
|
|
276
282
|
...processAfterUploadResources,
|
|
277
283
|
...confirmAfterUploadResources,
|
|
284
|
+
...snsTopicOutFlowSchemaUploadS3,
|
|
285
|
+
...userUploadRecordTable
|
|
278
286
|
);
|
|
279
287
|
|
|
280
288
|
} else if (event.includes("extTopic")) {
|
|
@@ -24,7 +24,7 @@ const izara = require("@izara_project/izara-middleware");
|
|
|
24
24
|
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
|
+
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
28
28
|
const <%- functionName %> = require('./<%- functionName %>_Main')
|
|
29
29
|
|
|
30
30
|
// validate event properties in body.Message of sqs event
|
|
@@ -37,6 +37,8 @@ const { v4: uuidv4 } = require('uuid')
|
|
|
37
37
|
const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
|
|
38
38
|
const consts = require("@izara_project/izara-middleware").consts
|
|
39
39
|
const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
|
|
40
|
+
const { createFlowTypeConcat } = require("@izara_project/izara-core-library-service-schemas").utils
|
|
41
|
+
|
|
40
42
|
//(<optionalRequire>)
|
|
41
43
|
//(</optionalRequire>)
|
|
42
44
|
/**
|
|
@@ -73,59 +75,69 @@ module.exports.<%- functionName %> = async (
|
|
|
73
75
|
throw new NoRetryError('not have TopicArn for get FlowSchemas')
|
|
74
76
|
}
|
|
75
77
|
|
|
76
|
-
let topicName = topicArn.
|
|
78
|
+
let topicName = topicArn.split(":")[5].split("_")
|
|
79
|
+
let flowTag = topicName[2]
|
|
77
80
|
|
|
78
81
|
let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
|
|
79
|
-
flowTag:
|
|
82
|
+
flowTag: flowTag,
|
|
80
83
|
serviceTag: topicName[0]
|
|
81
84
|
})
|
|
82
85
|
|
|
86
|
+
if (!flowSchema) {
|
|
87
|
+
if (requestParams.hasOwnProperty("flowTag")) {
|
|
88
|
+
flowTag = requestParams.flowTag;
|
|
89
|
+
flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
|
|
90
|
+
flowTag: flowTag,
|
|
91
|
+
serviceTag: process.env.iz_serviceTag
|
|
92
|
+
})
|
|
93
|
+
} else {
|
|
94
|
+
throw new NoRetryError("Could not find flowSchema from topicArn or requestParams.flowTag")
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
83
98
|
//(<createIdentifiersFlow>)
|
|
84
99
|
let identifiers
|
|
85
100
|
//(</createIdentifiersFlow>)
|
|
86
101
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
let wbsTasks;
|
|
102
|
+
let wbsTasks;
|
|
103
|
+
let taskKey;
|
|
92
104
|
if (flowSchema.statusType === "statusField" || flowSchema.statusType === "storedCache" || flowSchema.statusType === "triggerCache") {
|
|
105
|
+
taskKey = `${createFlowTypeConcat(_izContext,{flowTag: flowTag, serviceTag: topicName[0]})}${identifiers}`
|
|
93
106
|
wbsTasks = await dynamodbSharedLib.query(
|
|
94
107
|
_izContext,
|
|
95
108
|
await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
|
|
96
109
|
{
|
|
97
|
-
taskKey:
|
|
110
|
+
taskKey: taskKey
|
|
98
111
|
}
|
|
99
112
|
)
|
|
100
113
|
} else if (flowSchema.statusType === "none") {
|
|
114
|
+
taskKey = `${createFlowTypeConcat(_izContext,{flowTag: flowTag, serviceTag: topicName[0]})}${correlationId}`
|
|
101
115
|
wbsTasks = await dynamodbSharedLib.query(
|
|
102
116
|
_izContext,
|
|
103
117
|
await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
|
|
104
118
|
{
|
|
105
|
-
taskKey:
|
|
119
|
+
taskKey: taskKey
|
|
106
120
|
}
|
|
107
121
|
)
|
|
108
|
-
|
|
122
|
+
}
|
|
109
123
|
|
|
110
124
|
if (wbsTasks.Items.length) {
|
|
111
|
-
await Promise.all(wbsTasks.Items.map(async (
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
)
|
|
125
|
+
await Promise.all(wbsTasks.Items.map(async (wbsTask) => {
|
|
126
|
+
let postMessage = { message: requestParams }
|
|
127
|
+
|
|
128
|
+
//(<beforePostMessage>)
|
|
129
|
+
//(</beforePostMessage>)
|
|
130
|
+
|
|
131
|
+
await postToConnection(postMessage, wbsTask.connectionId)
|
|
118
132
|
|
|
119
133
|
await dynamodbSharedLib.deleteItem(_izContext,
|
|
120
134
|
await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
|
|
121
135
|
{
|
|
122
|
-
taskKey:
|
|
123
|
-
connectionId: connectionId
|
|
136
|
+
taskKey: wbsTask.taskKey,
|
|
137
|
+
connectionId: wbsTask.connectionId
|
|
124
138
|
}
|
|
125
139
|
)
|
|
126
140
|
}))
|
|
127
|
-
|
|
128
|
-
|
|
129
141
|
}
|
|
130
142
|
|
|
131
143
|
} catch (err) {
|
|
@@ -91,9 +91,12 @@ module.exports.updateNodeComplete = async (
|
|
|
91
91
|
fields: returnValue.queryResult.objInstanceFull.fields
|
|
92
92
|
},
|
|
93
93
|
status: status,
|
|
94
|
-
errorsFound: errorsFound
|
|
94
|
+
errorsFound: errorsFound,
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
+
//(<additionalProperties>)
|
|
98
|
+
//(</additionalProperties>)
|
|
99
|
+
|
|
97
100
|
updateCompleteMsg = callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(passBackProperties, updateCompleteMsg);
|
|
98
101
|
_izContext.logger.debug("after addCallingFlow to SnsResponseMessageObject", updateCompleteMsg);
|
|
99
102
|
|
|
@@ -315,7 +315,7 @@ module.exports.processLogical = async (
|
|
|
315
315
|
comparison: comparison,
|
|
316
316
|
callingFlow: callingFlow
|
|
317
317
|
}),
|
|
318
|
-
TopicArn: await snsSharedLib.
|
|
318
|
+
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, "InPaginateProcessLogical")
|
|
319
319
|
};
|
|
320
320
|
_izContext.logger.debug('Request params before send to topic InPaginateProcessLogical: ', sentMessageToPaginateProcessLogical);
|
|
321
321
|
|
|
@@ -374,7 +374,7 @@ module.exports.processLogical = async (
|
|
|
374
374
|
sortKeyFieldName: sortKeyFieldName,
|
|
375
375
|
callingFlow: callingFlow
|
|
376
376
|
}),
|
|
377
|
-
TopicArn: await snsSharedLib.
|
|
377
|
+
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, "InPaginateProcessLogical")
|
|
378
378
|
};
|
|
379
379
|
_izContext.logger.debug('Request params before send to topic InPaginateProcessLogical: ', sentMessageToPaginateProcessLogical);
|
|
380
380
|
|
package/src/reStructure/TemplateData/resourceYaml/dynamodb/mainResourcePerObjectSchemaData.js
CHANGED
|
@@ -70,7 +70,7 @@ function dataForMainDynamoDbYamlFromObjectSchema(_izContext, objectSchema, srcPa
|
|
|
70
70
|
let attributeType;
|
|
71
71
|
if (fieldNameType === 'string') {
|
|
72
72
|
attributeType = "S"
|
|
73
|
-
} else if (fieldNameType === 'number') {
|
|
73
|
+
} else if (fieldNameType === 'number' || fieldNameType === "timestamp") {
|
|
74
74
|
attributeType = "N"
|
|
75
75
|
}
|
|
76
76
|
Object.assign(
|