@izara_project/izara-market-library-service-schemas 1.0.29 → 1.0.30
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/Consts.js +10 -9
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +54 -21
- package/src/MainLibs/src/Consts.js +33 -17
- package/src/reStructure/GenerateCode.js +2 -1
- package/src/reStructure/TemplateConfig.js +5 -1
- package/src/reStructure/TemplateData/EndpointPerService/generateTemplateData.js +108 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/api/data.js +76 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/api/request.json +7 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/api/template.ejs +73 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/dsq/data.js +81 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/dsq/request.json +7 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/dsq/template.ejs +125 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/inv/data.js +70 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/inv/request.json +7 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/inv/template.ejs +73 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/sqs/data.js +79 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/sqs/request.json +7 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/sqs/template.ejs +126 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/data.js +53 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +624 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/data.js +52 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +177 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/data.js +56 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +234 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/data.js +56 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +330 -0
- package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +175 -0
- package/src/reStructure/TemplateData/EndpointPerService/yaml/template.ejs +26 -0
- package/src/reStructure/TemplateData/externalService/generateTemplateData.js +1 -1
- package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +91 -249
- package/src/reStructure/TemplateData/externalService/lambdaRole/template.ejs +1 -1
- package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +10 -8
- package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/template.ejs +1 -1
- package/src/reStructure/TemplateData/findData/findDataYaml/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/functionYaml/data.js +4 -3
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/functionYaml/data.js +3 -29
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/data.js +3 -21
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/template.ejs +3 -31
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/functionYaml/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/sns-sqs/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/sns-sqs/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{getSignUrls → createPresignUrl}/functionYaml/data.js +41 -10
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{getSignUrls → createPresignUrl}/functionYaml/template.ejs +3 -0
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{getSignUrls → createPresignUrl}/handler/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/{hook/handler/templateAsyncHandler.ejs → preSignUrl/createPresignUrl/handler/template.ejs} +26 -11
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{getSignUrls → createPresignUrl}/mainFunction/data.js +10 -7
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +253 -0
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{reservedLimit → createPresignUrl}/queue/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/data.js +10 -38
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/template.ejs +0 -3
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/handler/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/handler/template.ejs +40 -45
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/data.js +7 -10
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +100 -190
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{getSignUrls → reservedLimit}/sqs/data.js +4 -4
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{getSignUrls → reservedLimit}/sqs/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrS3/data.js +8 -6
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/queue/s3Template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/relate/S3/data.js +5 -2
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +41 -38
- package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/queue/snsTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/generateRole/createSharedResource.js +11 -1
- package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +35 -44
- package/src/reStructure/TemplateData/perActionComplete/create/sns-out/template.ejs +1 -1
- package/src/reStructure/TemplateData/perActionComplete/create/yaml/data.js +4 -5
- package/src/reStructure/TemplateData/perActionComplete/delete/yaml/data.js +5 -4
- package/src/reStructure/TemplateData/perActionComplete/generateTemplateData.js +15 -2
- package/src/reStructure/TemplateData/perActionComplete/get/yaml/data.js +7 -4
- package/src/reStructure/TemplateData/perActionComplete/update/sns-out/data.js +1 -1
- package/src/reStructure/TemplateData/perActionComplete/update/yaml/data.js +5 -4
- package/src/reStructure/TemplateData/processLogical/yaml/data.js +3 -3
- package/src/reStructure/TemplateData/processLogicalPagination/yaml/dsq/data.js +1 -1
- package/src/reStructure/TemplateData/processLogicalPagination/yaml/sqs/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/api/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/dsq/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/inv/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/sqs/data.js +3 -3
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/sns-in-sqs/snsTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/functionYaml/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/sns-in-sqs/template.ejs +0 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/sns-out/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/api/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/dsq/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/inv/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/sqs/data.js +3 -3
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/sns-in-sqs/snsTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/functionYaml/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/sns-out/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/api/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/inv/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/sqs/data.js +4 -4
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/sns-in-sqs/snsTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/sns-out/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/api/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/dsq/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/inv/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/sqs/data.js +4 -4
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/sns-in-sqs/snsTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/complete/functionYaml/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/update/complete/sns-out/template.ejs +1 -1
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/defaultDynamoDbTable.js +1 -1
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/generateDynamoPerLink.js +1 -1
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +1 -1
- package/src/reStructure/TemplateData/resourceYaml/generateTemplateData.js +6 -12
- package/src/reStructure/TemplateData/resourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical.js +1 -1
- package/src/reStructure/TemplateData/resourceYaml/sns-in-sqs/snsAndSqsPerActionData.js +22 -49
- package/src/reStructure/TemplateData/resourceYaml/sns-in-sqs/snsTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/resourceYaml/sns-out/data.js +8 -24
- package/src/reStructure/TemplateData/resourceYaml/sns-out/template.ejs +1 -1
- package/src/reStructure/TemplateData/testTemplate/template.ejs +0 -5
- package/src/reStructure/TemplateData/flowSchema/components/upload/hook/handler/data.js +0 -93
- package/src/reStructure/TemplateData/flowSchema/components/upload/hook/handler/templateSyncHandler.ejs +0 -49
- package/src/reStructure/TemplateData/flowSchema/components/upload/hook/hookLogic/data.js +0 -43
- package/src/reStructure/TemplateData/flowSchema/components/upload/hook/mainFunction/data.js +0 -65
- package/src/reStructure/TemplateData/flowSchema/components/upload/hook/mainFunction/template.ejs +0 -7
- package/src/reStructure/TemplateData/flowSchema/components/upload/hook/queue/data.js +0 -72
- package/src/reStructure/TemplateData/flowSchema/components/upload/hook/queue/snsTemplate.ejs +0 -59
- package/src/reStructure/TemplateData/flowSchema/components/upload/hook/queue/sqsTemplate.ejs +0 -43
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/getSignUrls/handler/template.ejs +0 -120
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/getSignUrls/mainFunction/template.ejs +0 -163
- package/src/reStructure/TemplateData/relationshipPerAction.zip +0 -0
- /package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{reservedLimit → createPresignUrl}/queue/template.ejs +0 -0
|
@@ -1,65 +0,0 @@
|
|
|
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 { createHookFunction } = require('../../../../../../GenerateCodeLibs/src/GenerateCodeLibs')
|
|
21
|
-
const { FLOW_SCHEMA_HOOK_STATE } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
22
|
-
const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
|
|
23
|
-
const { SOURCE_PATH, defaultIamRolePerAction, createIamRole, RESOURCE_CLASSES, SNS_RESOURCE, resourceNames, DYNAMO_RESOURCE, SAVE_FILE_NAME, FUNCTION_NAME, shortNameHandler } = require("../../../../libs/Consts");
|
|
24
|
-
const templatePath = path.join(__dirname, "template.ejs")
|
|
25
|
-
/**
|
|
26
|
-
* receive objectSchema
|
|
27
|
-
* create data for WebScoket handler template
|
|
28
|
-
*
|
|
29
|
-
* @param {Object} objectSchema
|
|
30
|
-
* @return {{templatePath, templateData,setting}}
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
function data(_izContext, flowSchema, srcPath) {
|
|
34
|
-
return [createSourceParams(_izContext, flowSchema, srcPath)]
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
38
|
-
let hook;
|
|
39
|
-
let hookFunctionName;
|
|
40
|
-
if (flowSchema?.hook) {
|
|
41
|
-
for (const [hookName, hookProperties] of Object.entries(flowSchema.hook)) {
|
|
42
|
-
for (const hookFunction of hookProperties.functionList) {
|
|
43
|
-
if (hookName === FLOW_SCHEMA_HOOK_STATE.beforeCreate) {
|
|
44
|
-
if (hookFunction.event?.initialEvent && hookFunction.event.initialEvent === true) {
|
|
45
|
-
hook = true
|
|
46
|
-
hookFunctionName = hookFunction.name
|
|
47
|
-
createHookFunction(_izContext, hookFunction.logicFunction, path.join(srcPath, SOURCE_PATH.webSocketHook))
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
templatePath: templatePath,
|
|
55
|
-
templateData: {},
|
|
56
|
-
setting: {
|
|
57
|
-
savePath: path.join(srcPath, SOURCE_PATH.webSocketHook),
|
|
58
|
-
saveFileName: `${upperCase(hookFunctionName)}_Main`,
|
|
59
|
-
fileExtension: ".js",
|
|
60
|
-
isAppend: false
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
module.exports = data;
|
package/src/reStructure/TemplateData/flowSchema/components/upload/hook/mainFunction/template.ejs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
const <%- hookFunctionName %> = require("../../FlowSchemaHook/source/<%- hookFunctionName %>");
|
|
2
|
-
const createObjectMain = require("../../../CreateObjectS3_Main")
|
|
3
|
-
|
|
4
|
-
module.exports.main = async (event, callingFlow) => {
|
|
5
|
-
const result = await <%- hookFunctionName %>(event);
|
|
6
|
-
await createObjectMain(...result, callingFlow);
|
|
7
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
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 { HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
21
|
-
const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
|
|
22
|
-
const { SOURCE_PATH, defaultIamRolePerAction, createIamRole, RESOURCE_CLASSES, SNS_RESOURCE, resourceNames, DYNAMO_RESOURCE, SAVE_FILE_NAME, FUNCTION_NAME, shortNameHandler, SQS_RESOURCE } = require("../../../../libs/Consts");
|
|
23
|
-
const snsTemplatePath = path.join(__dirname, "./snsTemplate.ejs");
|
|
24
|
-
const sqsTemplatePath = path.join(__dirname, "./sqsTemplate.ejs");
|
|
25
|
-
/**
|
|
26
|
-
* receive objectSchema
|
|
27
|
-
* create data for WebScoket handler template
|
|
28
|
-
*
|
|
29
|
-
* @param {Object} objectSchema
|
|
30
|
-
* @return {{templatePath, templateData,setting}}
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
34
|
-
let queueNames = [];
|
|
35
|
-
let resultForCreateQueueHook = []
|
|
36
|
-
const settings = {
|
|
37
|
-
saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
|
|
38
|
-
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
39
|
-
fileExtension: ".yml",
|
|
40
|
-
isAppend: true
|
|
41
|
-
}
|
|
42
|
-
if (flowSchema?.hook) {
|
|
43
|
-
for (const hookProperties of Object.values(flowSchema.hook)) {
|
|
44
|
-
for (const hookFunction of hookProperties.functionList) {
|
|
45
|
-
if (hookFunction.event.handlerType === HANDLER.hdrSqs) {
|
|
46
|
-
queueNames.push({ queueName: hookFunction.event.topicName });
|
|
47
|
-
} else if (hookFunction.event.handlerType === HANDLER.hdrDsq) {
|
|
48
|
-
queueNames.push({ queueName: hookFunction.event.queueName });
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
for (const queueName of queueNames) {
|
|
55
|
-
if (queueName.queueName.includes(upperCase(HANDLER.hdrDsq))) {
|
|
56
|
-
resultForCreateQueueHook.push({
|
|
57
|
-
templatePath: snsTemplatePath,
|
|
58
|
-
templateData: queueName.queueName,
|
|
59
|
-
setting: settings
|
|
60
|
-
})
|
|
61
|
-
} else {
|
|
62
|
-
resultForCreateQueueHook.push({
|
|
63
|
-
templatePath: sqsTemplatePath,
|
|
64
|
-
templateData: queueName,
|
|
65
|
-
setting: settings
|
|
66
|
-
})
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return resultForCreateQueueHook;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
module.exports = createSourceParams;
|
package/src/reStructure/TemplateData/flowSchema/components/upload/hook/queue/snsTemplate.ejs
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
##===== [Create topic in]
|
|
2
|
-
In<%- queueName %>:
|
|
3
|
-
Type: AWS::SNS::Topic
|
|
4
|
-
Properties:
|
|
5
|
-
DisplayName: "SNS Message in"
|
|
6
|
-
TopicName: ${self:custom.iz_resourcePrefix}In<%- queueName %>
|
|
7
|
-
##===== SNS Subscription
|
|
8
|
-
##===== [Topic In]
|
|
9
|
-
SubscriptionIn<%- queueName %>:
|
|
10
|
-
Type: AWS::SNS::Subscription
|
|
11
|
-
Properties:
|
|
12
|
-
TopicArn: !Ref In<%- queueName %>
|
|
13
|
-
Endpoint: "arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqs"
|
|
14
|
-
Protocol: "sqs"
|
|
15
|
-
##===== [Queue]
|
|
16
|
-
<%- queueName %>HdrSqs:
|
|
17
|
-
Type: "AWS::SQS::Queue"
|
|
18
|
-
Properties:
|
|
19
|
-
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqs
|
|
20
|
-
RedrivePolicy:
|
|
21
|
-
deadLetterTargetArn:
|
|
22
|
-
# !GetAtt
|
|
23
|
-
Fn::GetAtt:
|
|
24
|
-
- <%- queueName %>HdrSqsDLQ
|
|
25
|
-
- Arn
|
|
26
|
-
maxReceiveCount: 3
|
|
27
|
-
VisibilityTimeout: 120
|
|
28
|
-
##==== [QueueDLQ]
|
|
29
|
-
<%- queueName %>HdrSqsDLQ:
|
|
30
|
-
Type: AWS::SQS::Queue
|
|
31
|
-
Properties:
|
|
32
|
-
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqsDLQ
|
|
33
|
-
##==== [QueuePolicy]
|
|
34
|
-
<%- queueName %>HdrSqsPolicy:
|
|
35
|
-
Type: AWS::SQS::QueuePolicy
|
|
36
|
-
Properties:
|
|
37
|
-
PolicyDocument:
|
|
38
|
-
Version: "2012-10-17"
|
|
39
|
-
Statement:
|
|
40
|
-
- Sid: "allow-sns-messages"
|
|
41
|
-
Effect: Allow
|
|
42
|
-
Principal: "*"
|
|
43
|
-
Resource:
|
|
44
|
-
# !GetAtt
|
|
45
|
-
Fn::GetAtt:
|
|
46
|
-
- <%- queueName %>HdrSqs
|
|
47
|
-
- Arn
|
|
48
|
-
Action: "SQS:SendMessage"
|
|
49
|
-
Queues:
|
|
50
|
-
- Ref: <%- queueName %>HdrSqs
|
|
51
|
-
#<#<%- firstLetterUpperCase(queueName) %>QueueSetting#>
|
|
52
|
-
#<#/<%- firstLetterUpperCase(queueName) %>QueueSetting#>
|
|
53
|
-
|
|
54
|
-
<%_ function firstLetterUpperCase(text){
|
|
55
|
-
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
56
|
-
} _%>
|
|
57
|
-
<%_ function firstLetterLowerCase(str) {
|
|
58
|
-
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
59
|
-
} _%>
|
package/src/reStructure/TemplateData/flowSchema/components/upload/hook/queue/sqsTemplate.ejs
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
#------- queue ---------
|
|
2
|
-
<%- queueName %>:
|
|
3
|
-
Type: "AWS::SQS::Queue"
|
|
4
|
-
Properties:
|
|
5
|
-
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>
|
|
6
|
-
RedrivePolicy:
|
|
7
|
-
deadLetterTargetArn: #!GetAtt
|
|
8
|
-
Fn::GetAtt:
|
|
9
|
-
- <%- queueName %>DLQ
|
|
10
|
-
- Arn
|
|
11
|
-
maxReceiveCount: 3
|
|
12
|
-
VisibilityTimeout: 120
|
|
13
|
-
|
|
14
|
-
<%- queueName %>DLQ:
|
|
15
|
-
Type: AWS::SQS::Queue
|
|
16
|
-
Properties:
|
|
17
|
-
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>DLQ
|
|
18
|
-
|
|
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: #!GetAtt
|
|
29
|
-
Fn::GetAtt:
|
|
30
|
-
- <%- queueName %>
|
|
31
|
-
- Arn
|
|
32
|
-
Action: "SQS:SendMessage"
|
|
33
|
-
Queues:
|
|
34
|
-
- Ref: <%- queueName %>
|
|
35
|
-
#<#<%- firstLetterUpperCase(queueName) %>QueueSetting#>
|
|
36
|
-
#<#/<%- firstLetterUpperCase(queueName) %>QueueSetting#>
|
|
37
|
-
|
|
38
|
-
<%_ function firstLetterUpperCase(text){
|
|
39
|
-
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
40
|
-
} _%>
|
|
41
|
-
<%_ function firstLetterLowerCase(str) {
|
|
42
|
-
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
43
|
-
} _%>
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (C) 2021 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 izara = require("@izara_project/izara-middleware");
|
|
21
|
-
const middleware = izara.middlewareHandler;
|
|
22
|
-
const izaraShared = require('@izara_project/izara-shared');
|
|
23
|
-
const recordHandlerSharedLib = require('@izara_project/izara-core-library-record-handler');
|
|
24
|
-
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
25
|
-
const Logger = require('@izara_project/izara-core-library-logger');
|
|
26
|
-
|
|
27
|
-
const getPresignUrl = require('./GetPresignUrl_Main');
|
|
28
|
-
|
|
29
|
-
middleware.setServiceSchema(recordHandlerSharedLib.baseValidatorSchema());
|
|
30
|
-
|
|
31
|
-
let perRecordsValidatorSchema = {
|
|
32
|
-
type: "object",
|
|
33
|
-
required: ["objType", "objInstanceFull"],
|
|
34
|
-
properties: {
|
|
35
|
-
objType: {
|
|
36
|
-
type: "object",
|
|
37
|
-
required: ["objectType", "serviceTag"],
|
|
38
|
-
properties: {
|
|
39
|
-
objectType: {
|
|
40
|
-
type: "string",
|
|
41
|
-
pattern: "^[a-zA-Z0-9_-]+$"
|
|
42
|
-
},
|
|
43
|
-
serviceTag: {
|
|
44
|
-
type: "string",
|
|
45
|
-
pattern: "^[a-zA-Z0-9_-]+$"
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
objInstaceFull: {
|
|
50
|
-
type: "object",
|
|
51
|
-
properties: {
|
|
52
|
-
identifiers: {
|
|
53
|
-
type: "object",
|
|
54
|
-
minProperties: 1
|
|
55
|
-
},
|
|
56
|
-
fields: {
|
|
57
|
-
type: "object"
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
perRecordsValidatorSchema = callingFlowSharedLib.addOptionalPassBackPropertiesToValidatorSchema(perRecordsValidatorSchema);
|
|
65
|
-
|
|
66
|
-
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
67
|
-
|
|
68
|
-
try {
|
|
69
|
-
|
|
70
|
-
let recordPromises = [];
|
|
71
|
-
|
|
72
|
-
// loop each record and send to mainFunction
|
|
73
|
-
await Promise.all(event.Records.map(async record => { // promise.all for map() function
|
|
74
|
-
|
|
75
|
-
let passOnProperties = []
|
|
76
|
-
record._izContext.logger.debug('record ReceiveMsgOutHdrSqs', record);
|
|
77
|
-
|
|
78
|
-
//validate message (and MessageAttributes)
|
|
79
|
-
await recordHandlerSharedLib.validateRecord(
|
|
80
|
-
record, // one record will send to mainFunction
|
|
81
|
-
"GetPresignUrlHdrSqs", // queue name that need to retry or send to dlq
|
|
82
|
-
perRecordsValidatorSchema, // schema for record.Message
|
|
83
|
-
// messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
// add argument (to invoke lambda) to passOnProperties[]
|
|
87
|
-
passOnProperties.push(record.body.Message.objType)
|
|
88
|
-
passOnProperties.push(record.body.Message.objInstanceFull)
|
|
89
|
-
passOnProperties.push(callingFlowSharedLib.addPassBackPropertiesToPassOnProperties(record.body.Message)) // is Ok PassBackProperties
|
|
90
|
-
// passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message)) // is Ok callinfFlow
|
|
91
|
-
record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
|
|
92
|
-
|
|
93
|
-
// call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
|
|
94
|
-
let recordPromise = recordHandlerSharedLib.recordHandler(
|
|
95
|
-
record, // one record will send to mainFunction
|
|
96
|
-
getPresignUrl.getSignedUrlAccountLimit, // mainFunction that need to invoke.
|
|
97
|
-
"GetPresignUrlHdrSqs", // queue name that need to retry or send to dlq
|
|
98
|
-
passOnProperties, // all parameters that mainFunction needed.
|
|
99
|
-
);
|
|
100
|
-
record._izContext.logger.debug('after recordPromise in handler');
|
|
101
|
-
recordPromises.push(recordPromise); // push promise to recordPromises
|
|
102
|
-
}))
|
|
103
|
-
|
|
104
|
-
Logger.debug('before Promise.all(recordPromises) in handler');
|
|
105
|
-
try {
|
|
106
|
-
// --- main await all promises
|
|
107
|
-
await Promise.all(recordPromises); // await all promises
|
|
108
|
-
|
|
109
|
-
return event.Records // return all for local testing
|
|
110
|
-
|
|
111
|
-
} catch {
|
|
112
|
-
Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did no resolve)');
|
|
113
|
-
}
|
|
114
|
-
Logger.debug('after Promise.all(recordPromises) in handler');
|
|
115
|
-
|
|
116
|
-
} catch (err) {
|
|
117
|
-
Logger.error('Unhandled Error, updateNodeCompleteHdrSqs: ', err);
|
|
118
|
-
throw (err);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (C) 2021 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 callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
21
|
-
const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
|
|
22
|
-
const snsSharedLib = require('@izara_project/izara-core-library-sns');
|
|
23
|
-
|
|
24
|
-
const externalRequest = require('@izara_project/izara-core-library-external-request')
|
|
25
|
-
const sns = externalRequest.sns;
|
|
26
|
-
const lambda = externalRequest.lambda
|
|
27
|
-
const consts = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
|
|
28
|
-
const coreConsts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
|
|
29
|
-
const hash = require('object-hash');
|
|
30
|
-
const importDataLibs = require('../../libs/source/ImportDataLib')
|
|
31
|
-
/**
|
|
32
|
-
* description of function.
|
|
33
|
-
* @param {Object} _izContext
|
|
34
|
-
* @param {CorrelationIds} _izContext.correlationIds - property of _izContext
|
|
35
|
-
* @param {Logger} _izContext.logger - property of _izContext
|
|
36
|
-
* @param {string} userId - from client
|
|
37
|
-
* @param {string} imageImportConfigId - from client
|
|
38
|
-
* @param {string} fileName - name of image
|
|
39
|
-
* @param {string} imageType - type of image
|
|
40
|
-
* @param {numeric} imageSize - size of image
|
|
41
|
-
*
|
|
42
|
-
* @returns {object} return imageImportId
|
|
43
|
-
*/
|
|
44
|
-
module.exports.getSignedUrlAccountLimit = async (
|
|
45
|
-
_izContext,
|
|
46
|
-
objType,
|
|
47
|
-
objInstaceFull,
|
|
48
|
-
callingFlowConfig = {}
|
|
49
|
-
) => {
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
|
|
53
|
-
_izContext.logger.debug('----- getSignedUrlAccountLimit event params ----- ', {
|
|
54
|
-
objType,
|
|
55
|
-
objInstaceFull,
|
|
56
|
-
callingFlowConfig
|
|
57
|
-
});
|
|
58
|
-
const {
|
|
59
|
-
userId,
|
|
60
|
-
submittedByUserId,
|
|
61
|
-
importConfigId,
|
|
62
|
-
importBatchStatus,
|
|
63
|
-
importType,
|
|
64
|
-
fileName,
|
|
65
|
-
fileSize,
|
|
66
|
-
startTime
|
|
67
|
-
} = objInstaceFull.fields
|
|
68
|
-
const {
|
|
69
|
-
importBatchId
|
|
70
|
-
} = objInstaceFull.identifiers
|
|
71
|
-
|
|
72
|
-
let connectionId = _izContext.correlationIds.get(coreConsts.CONNECTION_ID)
|
|
73
|
-
//* hard code
|
|
74
|
-
// _izContext['userId'] = 'this-is-uuid-for-user-superUserA'
|
|
75
|
-
|
|
76
|
-
// get static
|
|
77
|
-
let payloadBeforeInvokeStaticLimit = {
|
|
78
|
-
userId: userId,
|
|
79
|
-
limitTag: consts.LIMIT_TAG.uploadData,
|
|
80
|
-
value: fileSize,
|
|
81
|
-
rbacType: consts.RBAC_TYPE.appLevel,
|
|
82
|
-
targetUserId: submittedByUserId,
|
|
83
|
-
callingFlow: "BasDev",
|
|
84
|
-
callingFlowProperties: {}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
let res = await importDataLibs.getDataFromInvokeFunctionWithCache(_izContext,
|
|
88
|
-
await lambdaSharedLib.lambdaFunctionName(_izContext, "StaticLimitProcessHdrInv", consts.EXTERNAL_SERVICE_NAME.accountLimits),
|
|
89
|
-
payloadBeforeInvokeStaticLimit
|
|
90
|
-
)
|
|
91
|
-
// let res = await lambda.invokeSync(_izContext,
|
|
92
|
-
// await lambdaSharedLib.lambdaFunctionName(_izContext, "StaticLimitProcessHdrInv", consts.EXTERNAL_SERVICE_NAME.accountLimits),
|
|
93
|
-
// payloadBeforeInvokeStaticLimit
|
|
94
|
-
// )
|
|
95
|
-
|
|
96
|
-
_izContext.logger.debug("res::", res);
|
|
97
|
-
|
|
98
|
-
if (res.passStatus === false) {
|
|
99
|
-
importDataLibs.postToConnection({ message: "static limit over" }, connectionId)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
// reservedDynamic
|
|
104
|
-
|
|
105
|
-
let sendMsgReservedDynamic = {
|
|
106
|
-
userId: userId,
|
|
107
|
-
limitTag: consts.LIMIT_TAG.uploadData,
|
|
108
|
-
value: fileSize,
|
|
109
|
-
rbacType: consts.RBAC_TYPE.appLevel,
|
|
110
|
-
usedTimestamp: startTime,
|
|
111
|
-
targetUserId: submittedByUserId
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const reservedDataId = `${consts.ACCOUNTLIMIT_TAG.reservedDynamic}_${userId}_${consts.LIMIT_TAG.uploadData}`
|
|
115
|
-
|
|
116
|
-
let callingFlowProperties = {
|
|
117
|
-
identifier: {
|
|
118
|
-
servicePendingId: importBatchId,
|
|
119
|
-
reservedDataId: reservedDataId
|
|
120
|
-
},
|
|
121
|
-
importConfigId: importConfigId,
|
|
122
|
-
objType: objType
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
_izContext.logger.debug("callingFlowProperties", callingFlowProperties);
|
|
126
|
-
|
|
127
|
-
if (callingFlowConfig) {
|
|
128
|
-
sendMsgReservedDynamic = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
|
|
129
|
-
sendMsgReservedDynamic,
|
|
130
|
-
callingFlowSharedLib.addParentCallingFlowConfig(
|
|
131
|
-
callingFlowConfig,
|
|
132
|
-
callingFlowSharedLib.createCallingFlowConfig(
|
|
133
|
-
await lambdaSharedLib.lambdaFunctionName(_izContext, "ReservedLimitCompleteHdrSqs"),
|
|
134
|
-
callingFlowProperties
|
|
135
|
-
)
|
|
136
|
-
)
|
|
137
|
-
)
|
|
138
|
-
} else {
|
|
139
|
-
sendMsgReservedDynamic = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
|
|
140
|
-
sendMsgReservedDynamic,
|
|
141
|
-
callingFlowSharedLib.createCallingFlowConfig(
|
|
142
|
-
await lambdaSharedLib.lambdaFunctionName(_izContext, "ReservedLimitCompleteHdrSqs"),
|
|
143
|
-
callingFlowProperties
|
|
144
|
-
)
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
let sendMessageToReservedDynamic = {
|
|
149
|
-
Message: JSON.stringify(sendMsgReservedDynamic),
|
|
150
|
-
TopicArn: await snsSharedLib.snsTopicArn(_izContext, "InReservedDynamicUsage", consts.EXTERNAL_SERVICE_NAME.accountLimits)
|
|
151
|
-
};
|
|
152
|
-
_izContext.logger.debug("sendMessageToReservedDynamic", sendMessageToReservedDynamic);
|
|
153
|
-
await sns.publishAsync(_izContext, sendMessageToReservedDynamic);
|
|
154
|
-
|
|
155
|
-
return {
|
|
156
|
-
objType,
|
|
157
|
-
objInstaceFull,
|
|
158
|
-
}
|
|
159
|
-
} catch (err) {
|
|
160
|
-
_izContext.logger.error('error GetSignedUrlAccountLimit: ', err);
|
|
161
|
-
throw (err)
|
|
162
|
-
}
|
|
163
|
-
}
|
|
Binary file
|