@izara_project/izara-market-library-service-schemas 1.0.28 → 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 +36 -18
- 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 +16 -14
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/dsq/data.js +16 -14
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/inv/data.js +16 -15
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/sqs/data.js +18 -16
- 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 +16 -14
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/dsq/data.js +16 -15
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/inv/data.js +17 -14
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/sqs/data.js +18 -16
- 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 +16 -14
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/data.js +17 -14
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/inv/data.js +16 -14
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/sqs/data.js +20 -17
- 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 +16 -14
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/dsq/data.js +16 -14
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/inv/data.js +16 -14
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/sqs/data.js +19 -18
- 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 +40 -38
- 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/flowSchema/components/upload/preSignUrl/{reservedLimit → createPresignUrl}/queue/template.ejs +0 -0
|
@@ -0,0 +1,81 @@
|
|
|
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 { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
23
|
+
const { SOURCE_GENERATE_IAM_ROLE } = require('../../../../../MainLibs/src/Consts.js');
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase, checkOverWriteGenerateMainFunction } = require("../#utils");
|
|
27
|
+
// const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH } = require("../#const");
|
|
28
|
+
const {
|
|
29
|
+
firstLetterLowerCase: lowerCase,
|
|
30
|
+
firstLetterUpperCase: upperCase,
|
|
31
|
+
firstLetterUpperCase,
|
|
32
|
+
checkOverWriteGenerateMainFunction
|
|
33
|
+
} = require("../../../../../MainLibs/index.js").utils;
|
|
34
|
+
const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH } = require("../../../../../MainLibs/src/Consts.js");
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* receive objectSchema
|
|
41
|
+
* create data for hdrInv template
|
|
42
|
+
*
|
|
43
|
+
* @param {Object} objectSchema
|
|
44
|
+
* @return {{ templatePath, templateData, setting } }
|
|
45
|
+
*/
|
|
46
|
+
function data(_izContext, srcPath) {
|
|
47
|
+
let createSourceArray = [];
|
|
48
|
+
for (const action of Object.values(ACTIONS)) {
|
|
49
|
+
const defaultHandlers = DEFAULT_HANDLER_PER_ACTION[action]
|
|
50
|
+
for (const defaultHandler of defaultHandlers) {
|
|
51
|
+
if (defaultHandler === HANDLER.hdrDsq) {
|
|
52
|
+
const createSourceParam = createParamForCreateSource(action, defaultHandler, srcPath)
|
|
53
|
+
createSourceParam && createSourceArray.push(createSourceParam)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return createSourceArray;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
function createParamForCreateSource(action, handler, srcPath) {
|
|
62
|
+
let queueName = firstLetterUpperCase(action) + upperCase(handler);
|
|
63
|
+
return {
|
|
64
|
+
templatePath: templatePath,
|
|
65
|
+
templateData: {
|
|
66
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.perActionEndpoint,
|
|
67
|
+
queueName,
|
|
68
|
+
action,
|
|
69
|
+
handler
|
|
70
|
+
},
|
|
71
|
+
setting: {
|
|
72
|
+
savePath: path.join(srcPath, SOURCE_PATH.endpointPerService),
|
|
73
|
+
saveFileName: `${upperCase(action)}_${upperCase(handler)}`,
|
|
74
|
+
fileExtension: '.js',
|
|
75
|
+
isAppend: false
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
module.exports = data;
|
|
@@ -0,0 +1,125 @@
|
|
|
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 izara = require("@izara_project/izara-middleware");
|
|
20
|
+
const middleware = izara.middlewareHandler;
|
|
21
|
+
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
22
|
+
const Logger = require('@izara_project/izara-core-library-logger');
|
|
23
|
+
const {validateSchemaPerRecord} = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs')
|
|
24
|
+
const recordHandlerSharedLib = require('@izara_project/izara-core-library-record-handler');
|
|
25
|
+
|
|
26
|
+
const { <%- action %>Main } =require('./<%- firstLetterUpperCase(action) %>_Main.js')
|
|
27
|
+
|
|
28
|
+
//(<globalVarible>
|
|
29
|
+
//</globalVarible>)
|
|
30
|
+
|
|
31
|
+
//validate event params in middleware before into main function
|
|
32
|
+
middleware.setValidatorSchema(
|
|
33
|
+
recordHandlerSharedLib.baseValidatorSchema(),
|
|
34
|
+
//(<middlewareSettings>)
|
|
35
|
+
//(</middlewareSettings>)
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
/*
|
|
39
|
+
const perRecordsValidatorSchema = {
|
|
40
|
+
type: "object",
|
|
41
|
+
required: [],
|
|
42
|
+
properties: {},
|
|
43
|
+
}
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
//(<globalValidatorSchema>)
|
|
47
|
+
//(</globalValidatorSchema>)
|
|
48
|
+
|
|
49
|
+
// if need to validate authorizer or additional params , add code to hook tag below
|
|
50
|
+
|
|
51
|
+
module.exports.main = middleware.wrap(async (event,context, callback) => {
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
|
|
55
|
+
let recordPromises = [];
|
|
56
|
+
|
|
57
|
+
await Promise.all(event.Records.map(async record => {
|
|
58
|
+
record._izContext.logger.debug('record RecieveMsgOutHdrSqs', record);
|
|
59
|
+
|
|
60
|
+
let passOnProperties = [];
|
|
61
|
+
|
|
62
|
+
const OBJTYPE = {
|
|
63
|
+
objectType: record.body.Message.objectType,
|
|
64
|
+
serviceTag: process.env.iz_serviceTag
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
await validateSchemaPerRecord(
|
|
69
|
+
record,
|
|
70
|
+
"<%- firstLetterUpperCase(action) %><%- firstLetterUpperCase(handler) %>",
|
|
71
|
+
OBJTYPE,
|
|
72
|
+
"<%- action %>"
|
|
73
|
+
//(<validateSchemaSetting>)
|
|
74
|
+
//(</validateSchemaSetting>)
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
//for validate additional params
|
|
78
|
+
/*
|
|
79
|
+
await recordHandlerSharedLib.validateRecord(
|
|
80
|
+
record,
|
|
81
|
+
"<%- firstLetterUpperCase(action) %><%- firstLetterUpperCase(handler) %>",
|
|
82
|
+
perRecordsValidatorSchema
|
|
83
|
+
);
|
|
84
|
+
*/
|
|
85
|
+
//(<afterGenerateValidatorSchema>)
|
|
86
|
+
//(</afterGenerateValidatorSchema>)
|
|
87
|
+
|
|
88
|
+
//(<additionalParams>)
|
|
89
|
+
//(</additionalParams>)
|
|
90
|
+
|
|
91
|
+
passOnProperties.push(record.body.Message);
|
|
92
|
+
passOnProperties.push(OBJTYPE);
|
|
93
|
+
passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
|
|
94
|
+
record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
|
|
95
|
+
|
|
96
|
+
let recordPromise = recordHandlerSharedLib.recordHandler(
|
|
97
|
+
record,
|
|
98
|
+
<%- action %>Main, // mainFunction
|
|
99
|
+
'<%- firstLetterUpperCase(queueName) %>', // queueName
|
|
100
|
+
passOnProperties
|
|
101
|
+
);
|
|
102
|
+
record._izContext.logger.debug('after record Promise in handler');
|
|
103
|
+
recordPromises.push(recordPromise);
|
|
104
|
+
}))
|
|
105
|
+
|
|
106
|
+
Logger.debug('before Promise.all(recordPromise) in handler');
|
|
107
|
+
try {
|
|
108
|
+
await Promise.all(recordPromises);
|
|
109
|
+
|
|
110
|
+
return event.Records
|
|
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.debug('unhandled error <%- firstLetterUpperCase(action) %><%- firstLetterUpperCase(handler) %>')
|
|
118
|
+
throw err
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
<%_ function firstLetterUpperCase(text){
|
|
124
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
125
|
+
} _%>
|
|
@@ -0,0 +1,70 @@
|
|
|
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 { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
23
|
+
|
|
24
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/index.js").utils;
|
|
25
|
+
const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH, FUNCTION_NAME, SOURCE_GENERATE_IAM_ROLE } = require("../../../../../MainLibs/src/Consts.js");
|
|
26
|
+
|
|
27
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
28
|
+
/**
|
|
29
|
+
* receive objectSchema
|
|
30
|
+
* create data for hdrInv template
|
|
31
|
+
*
|
|
32
|
+
* @param {Object} objectSchema
|
|
33
|
+
* @return {{ templatePath, templateData, setting } }
|
|
34
|
+
*/
|
|
35
|
+
function data(_izContext, srcPath) {
|
|
36
|
+
let createSourceArray = [];
|
|
37
|
+
|
|
38
|
+
for (const action of Object.values(ACTIONS)) {
|
|
39
|
+
const defaultHandlers = DEFAULT_HANDLER_PER_ACTION[action]
|
|
40
|
+
for (const defaultHandler of defaultHandlers) {
|
|
41
|
+
if (defaultHandler === HANDLER.hdrInv) {
|
|
42
|
+
const createSourceParam = createParamForCreateSource(action, defaultHandler, srcPath)
|
|
43
|
+
createSourceParam && createSourceArray.push(createSourceParam)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// console.log("createSourceArrayInHdrInv", createSourceArray)
|
|
48
|
+
return createSourceArray;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
function createParamForCreateSource(action, handler, srcPath) {
|
|
53
|
+
return {
|
|
54
|
+
templatePath: templatePath,
|
|
55
|
+
templateData: {
|
|
56
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.perActionEndpoint,
|
|
57
|
+
action: action,
|
|
58
|
+
handler
|
|
59
|
+
},
|
|
60
|
+
setting: {
|
|
61
|
+
savePath: path.join(srcPath, SOURCE_PATH.endpointPerService),
|
|
62
|
+
saveFileName: `${upperCase(action)}_${upperCase(handler)}`,
|
|
63
|
+
fileExtension: '.js',
|
|
64
|
+
isAppend: false
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
module.exports = data;
|
|
@@ -0,0 +1,73 @@
|
|
|
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 middleware = require("@izara_project/izara-middleware/src/MiddlewareCore/MiddlewareHandler");
|
|
21
|
+
|
|
22
|
+
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
23
|
+
const {
|
|
24
|
+
validatorSchemaMiddlewareByAction
|
|
25
|
+
} = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
|
|
26
|
+
|
|
27
|
+
const { <%- action %>Main } =require('./<%- firstLetterUpperCase(action) %>_Main.js')
|
|
28
|
+
|
|
29
|
+
//(<globalVariable>
|
|
30
|
+
//</globalVariable>)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
//validate event params in middleware before into main function
|
|
34
|
+
validatorSchemaMiddlewareByAction(
|
|
35
|
+
middleware,
|
|
36
|
+
"<%- action %>"
|
|
37
|
+
//(<validateSchemaSetting>
|
|
38
|
+
//</validateSchemaSetting>)
|
|
39
|
+
)
|
|
40
|
+
// if need to validate authorizer or additional params, add code to hook tag below
|
|
41
|
+
|
|
42
|
+
//(<afterValidateWithGenereatedSchema>)
|
|
43
|
+
//(</afterValidateWithGenereatedSchema>)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
47
|
+
event._izContext.logger.debug('Event:', event);
|
|
48
|
+
event._izContext.logger.debug('context:', context);
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
|
|
52
|
+
//(<beforeInvoke>)
|
|
53
|
+
//(</beforeInvoke>)
|
|
54
|
+
|
|
55
|
+
// invoke LambdaFunction
|
|
56
|
+
return await <%- action %>Main(
|
|
57
|
+
event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId
|
|
58
|
+
event,
|
|
59
|
+
callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
} catch (err) {
|
|
63
|
+
event._izContext.logger.error('Error, <%- firstLetterUpperCase(action) %>_<%- firstLetterUpperCase(handler) %>: ', err);
|
|
64
|
+
throw (err);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
<%_ function firstLetterUpperCase(text){
|
|
69
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
70
|
+
} _%>
|
|
71
|
+
<%_ function firstLetterLowerCase(str) {
|
|
72
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
73
|
+
} _%>
|
|
@@ -0,0 +1,79 @@
|
|
|
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 { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
23
|
+
|
|
24
|
+
// const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase, checkOverWriteGenerateMainFunction } = require("../#utils");
|
|
25
|
+
// const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH } = require("../#const");
|
|
26
|
+
const {
|
|
27
|
+
firstLetterLowerCase: lowerCase,
|
|
28
|
+
firstLetterUpperCase: upperCase,
|
|
29
|
+
firstLetterUpperCase,
|
|
30
|
+
checkOverWriteGenerateMainFunction
|
|
31
|
+
} = require("../../../../../MainLibs/index.js").utils;
|
|
32
|
+
const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH } = require("../../../../../MainLibs/src/Consts.js");
|
|
33
|
+
|
|
34
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* receive objectSchema
|
|
38
|
+
* create data for hdrInv template
|
|
39
|
+
*
|
|
40
|
+
* @param {Object} objectSchema
|
|
41
|
+
* @return {{ templatePath, templateData, setting } }
|
|
42
|
+
*/
|
|
43
|
+
function data(_izContext, srcPath) {
|
|
44
|
+
let createSourceArray = [];
|
|
45
|
+
|
|
46
|
+
for (const action of Object.values(ACTIONS)) {
|
|
47
|
+
const defaultHandlers = DEFAULT_HANDLER_PER_ACTION[action]
|
|
48
|
+
for (const defaultHandler of defaultHandlers) {
|
|
49
|
+
if (defaultHandler === HANDLER.hdrSqs) {
|
|
50
|
+
const createSourceParam = createParamForCreateSource(action, defaultHandler, srcPath)
|
|
51
|
+
createSourceParam && createSourceArray.push(createSourceParam)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// console.log("createSourceArray in sqsData :", createSourceArray)
|
|
57
|
+
return createSourceArray;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
function createParamForCreateSource(action, handler, srcPath) {
|
|
62
|
+
let queueName = upperCase(action) + upperCase(handler);
|
|
63
|
+
return {
|
|
64
|
+
templatePath: templatePath,
|
|
65
|
+
templateData: {
|
|
66
|
+
queueName,
|
|
67
|
+
action,
|
|
68
|
+
handler
|
|
69
|
+
},
|
|
70
|
+
setting: {
|
|
71
|
+
savePath: path.join(srcPath, SOURCE_PATH.endpointPerService),
|
|
72
|
+
saveFileName: `${upperCase(action)}_${upperCase(handler)}`,
|
|
73
|
+
fileExtension: '.js',
|
|
74
|
+
isAppend: false
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
module.exports = data;
|
|
@@ -0,0 +1,126 @@
|
|
|
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 izara = require("@izara_project/izara-middleware");
|
|
20
|
+
const middleware = izara.middlewareHandler;
|
|
21
|
+
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
22
|
+
const Logger = require('@izara_project/izara-core-library-logger');
|
|
23
|
+
const {validateSchemaPerRecord} = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs')
|
|
24
|
+
const recordHandlerSharedLib = require('@izara_project/izara-core-library-record-handler');
|
|
25
|
+
|
|
26
|
+
const { <%- action %>Main } =require('./<%- firstLetterUpperCase(action) %>_Main.js')
|
|
27
|
+
|
|
28
|
+
//(<globalVarible>
|
|
29
|
+
//</globalVarible>)
|
|
30
|
+
|
|
31
|
+
//validate event params in middleware before into main function
|
|
32
|
+
middleware.setValidatorSchema(
|
|
33
|
+
recordHandlerSharedLib.baseValidatorSchema(),
|
|
34
|
+
//(<middlewareSettings>)
|
|
35
|
+
//(</middlewareSettings>)
|
|
36
|
+
)
|
|
37
|
+
/*
|
|
38
|
+
const perRecordsValidatorSchema = {
|
|
39
|
+
type: "object",
|
|
40
|
+
required: [],
|
|
41
|
+
properties: {},
|
|
42
|
+
}
|
|
43
|
+
*/
|
|
44
|
+
//(<globalValidatorSchema>)
|
|
45
|
+
//(</globalValidatorSchema>)
|
|
46
|
+
|
|
47
|
+
// if need to validate authorizer or additional params , add code to hook tag below
|
|
48
|
+
|
|
49
|
+
module.exports.main = middleware.wrap(async (event,context, callback) => {
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
|
|
53
|
+
let recordPromises = [];
|
|
54
|
+
|
|
55
|
+
await Promise.all(event.Records.map(async record => {
|
|
56
|
+
record._izContext.logger.debug('record RecieveMsgOutHdrSqs', record);
|
|
57
|
+
|
|
58
|
+
let passOnProperties = [];
|
|
59
|
+
|
|
60
|
+
const OBJTYPE = {
|
|
61
|
+
objectType: record.body.Message.objectType,
|
|
62
|
+
serviceTag: process.env.iz_serviceTag
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
await validateSchemaPerRecord(
|
|
66
|
+
record,
|
|
67
|
+
"<%- firstLetterUpperCase(action) %><%- firstLetterUpperCase(handler) %>",
|
|
68
|
+
OBJTYPE,
|
|
69
|
+
"<%- action %>"
|
|
70
|
+
//(<validateSchemaSetting>)
|
|
71
|
+
//(</validateSchemaSetting>)
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
//for validate additional params
|
|
75
|
+
/*
|
|
76
|
+
await recordHandlerSharedLib.validateRecord(
|
|
77
|
+
record,
|
|
78
|
+
"<%- firstLetterUpperCase(action) %><%- firstLetterUpperCase(handler) %>",
|
|
79
|
+
perRecordsValidatorSchema
|
|
80
|
+
);
|
|
81
|
+
*/
|
|
82
|
+
//(<afterGenerateValidatorSchema>)
|
|
83
|
+
//(</afterGenerateValidatorSchema>)
|
|
84
|
+
|
|
85
|
+
//(<additionalParams>)
|
|
86
|
+
//(</additionalParams>)
|
|
87
|
+
|
|
88
|
+
passOnProperties.push(record.body.Message);
|
|
89
|
+
passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
|
|
90
|
+
record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
|
|
91
|
+
|
|
92
|
+
let recordPromise = recordHandlerSharedLib.recordHandler(
|
|
93
|
+
record,
|
|
94
|
+
<%- action %>Main, // mainFunction
|
|
95
|
+
'<%- firstLetterUpperCase(queueName) %>', // queueName
|
|
96
|
+
passOnProperties
|
|
97
|
+
);
|
|
98
|
+
record._izContext.logger.debug('after record Promise in handler');
|
|
99
|
+
recordPromises.push(recordPromise);
|
|
100
|
+
}))
|
|
101
|
+
|
|
102
|
+
Logger.debug('before Promise.all(recordPromise) in handler');
|
|
103
|
+
try {
|
|
104
|
+
await Promise.all(recordPromises);
|
|
105
|
+
|
|
106
|
+
return event.Records
|
|
107
|
+
} catch {
|
|
108
|
+
Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did no resolve)');
|
|
109
|
+
}
|
|
110
|
+
Logger.debug('after Promise.all(recordPromises) in handler');
|
|
111
|
+
|
|
112
|
+
} catch (err) {
|
|
113
|
+
Logger.debug('unhandled error <%- firstLetterUpperCase(action) %><%- firstLetterUpperCase(handler) %>')
|
|
114
|
+
throw err
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
<%_ function firstLetterUpperCase(text){
|
|
122
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
123
|
+
} _%>
|
|
124
|
+
<%_ function firstLetterLowerCase(str) {
|
|
125
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
126
|
+
} _%>
|
|
@@ -0,0 +1,53 @@
|
|
|
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 { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
23
|
+
|
|
24
|
+
const {
|
|
25
|
+
firstLetterLowerCase: lowerCase,
|
|
26
|
+
firstLetterUpperCase: upperCase,
|
|
27
|
+
} = require("../../../../../MainLibs/index.js").utils;
|
|
28
|
+
const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH } = require("../../../../../MainLibs/src/Consts.js");
|
|
29
|
+
|
|
30
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
31
|
+
|
|
32
|
+
function data(_izContext, srcPath) {
|
|
33
|
+
return [createSource(_izContext, srcPath)]
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function createSource(_izContext, srcPath) {
|
|
37
|
+
let functionName = upperCase(ACTIONS.create)
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
templatePath: templatePath,
|
|
41
|
+
templateData: {
|
|
42
|
+
functionName,
|
|
43
|
+
},
|
|
44
|
+
setting: {
|
|
45
|
+
savePath: path.join(srcPath, SOURCE_PATH.endpointPerService),
|
|
46
|
+
saveFileName: `${upperCase(functionName)}_Main`,
|
|
47
|
+
fileExtension: ".js",
|
|
48
|
+
isAppend: false
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
module.exports = data
|