@izara_project/izara-market-library-service-schemas 1.0.5 → 1.0.7
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 +2 -2
- package/src/GenerateCodeLibs/index.js +2 -1
- package/src/GenerateCodeLibs/src/Consts.js +12 -3
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +232 -7
- package/src/GenerateCodeLibs/src/TranslateIdsLibs.js +89 -0
- package/src/MainLibs/src/Utils.js +10 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrApi/data.js +10 -2
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrDsq/data.js +5 -4
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrInv/data.js +11 -1
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrSqs/data.js +4 -3
- package/src/TemplateManager/src/CreateRelationship/createRelationship/mainFunction/template.ejs +24 -22
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrDsq/data.js +0 -1
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrSqs/data.js +1 -1
- package/src/TemplateManager/src/CreateRelationship/createRelationship/sns-in-sqs/data.js +0 -2
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/functionYaml/data.js +2 -2
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/handler/HdrSqs/data.js +0 -1
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-out/data.js +1 -1
- package/src/TemplateManager/src/FindData/FindDataYaml/data.js +188 -0
- package/src/TemplateManager/src/FindData/FindDataYaml/template.ejs +27 -0
- package/src/TemplateManager/src/FindData/GetByStorage/getByDynamo.ejs +53 -0
- package/src/TemplateManager/src/FindData/GetByStorage/getByGraph.ejs +99 -0
- package/src/TemplateManager/src/FindData/Handler/data.js +48 -0
- package/src/TemplateManager/src/FindData/Handler/template.ejs +140 -0
- package/src/TemplateManager/src/FindData/mainFunction/data.js +279 -0
- package/src/TemplateManager/src/FindData/mainFunction/template.ejs +158 -0
- package/src/TemplateManager/src/GenerateCode(Old).js +1 -1
- package/src/TemplateManager/src/GenerateCode.js +163 -42
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/functionYaml/data.js +98 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/functionYaml/template.ejs +33 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/handler/data.js +59 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/handler/template.ejs +129 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/createObjectComplete_main.js +172 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/data.js +53 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/template.ejs +172 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-in-sqs/data.js +58 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-in-sqs/template.ejs +47 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-out/data.js +62 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-out/template.ejs +10 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/functionYaml/data.js +98 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/functionYaml/template.ejs +33 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/handler/data.js +59 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/handler/template.ejs +129 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/mainFunction/data.js +53 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/mainFunction/template.ejs +126 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/sns-out/data.js +62 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/sqs-in-sns/data.js +58 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/sqs-in-sns/template.ejs +47 -0
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/data.js +22 -3
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/template.ejs +2 -2
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrDsq/data.js +24 -1
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrInv/data.js +53 -2
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrSqs/data.js +25 -3
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/data.js +5 -8
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/getTemplate.ejs +76 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/updateTemplate.ejs +67 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/data.js +47 -23
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/getTemplate.ejs +105 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/updateTemplate.ejs +109 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/createTemplate.ejs +75 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/data.js +69 -21
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/getTemplate.ejs +82 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/updateTemplate.ejs +75 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/data.js +46 -17
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/getTemplate.ejs +124 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/updateTemplate.ejs +133 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/CreateObject_main.js +760 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/data.js +67 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/request.json +0 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/template.ejs +575 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/data.js +0 -6
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/template.ejs +17 -12
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/data.js +61 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/request.json +0 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/template.ejs +267 -0
- package/src/TemplateManager/src/ProcessLogical/Handler/data.js +49 -0
- package/src/TemplateManager/src/ProcessLogical/Handler/template.ejs +129 -0
- package/src/TemplateManager/src/ProcessLogical/ProcessLogicalYaml/data.js +175 -0
- package/src/TemplateManager/src/ProcessLogical/ProcessLogicalYaml/template.ejs +25 -0
- package/src/TemplateManager/src/ProcessLogical/mainFunction/data.js +47 -0
- package/src/TemplateManager/src/ProcessLogical/mainFunction/template.ejs +429 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/DsqYaml/data.js +50 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/DsqYaml/template.ejs +32 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrDsq/data.js +167 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrDsq/template.ejs +25 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrSqs/data.js +169 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrSqs/template.ejs +25 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/Handler/HdrDsq/data.js +48 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/Handler/HdrDsq/template.ejs +163 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/Handler/HdrSqs/data.js +48 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/Handler/HdrSqs/template.ejs +146 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/mainFunction/data.js +48 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/mainFunction/template.ejs +212 -0
- package/src/TemplateManager/src/ResourceYaml/CreateSourceData.js +2 -2
- package/src/TemplateManager/src/ResourceYaml/dynamodb/processLogicalAndFindData.js +2 -2
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical.js +27 -12
- package/src/TemplateManager/src/ResourceYaml/sns-out/data.js +1 -1
- package/src/TemplateManager/src/ResourceYaml/sns-out/defaultSnsOutForFindDataAndProcessLogical.js +75 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/functionYaml/data.js +95 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/functionYaml/template.ejs +30 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/handler/dataHdrDsq.js +52 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/handler/template.ejs +194 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/mainFunction/data.js +48 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/mainFunction/template.ejs +330 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/sns-out/data.js +47 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/sqs-sns/data.js +58 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/sqs-sns/template.ejs +43 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/functionYaml/HdrDsq/data.js +116 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/functionYaml/HdrSqs/data.js +116 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/handler/HdrDsq/data.js +60 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/handler/HdrDsq/template.ejs +157 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/handler/HdrSqs/data.js +59 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/handler/HdrSqs/template.ejs +175 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/mainFunction/data.js +61 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/mainFunction/template.ejs +155 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/resourceYaml/dynamoDb/data.js +120 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/resourceYaml/sns-sqs/data.js +75 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/data.js +2 -2
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-out/data.js +1 -1
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/data.js +10 -3
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/data.js +6 -4
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/data.js +11 -1
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/data.js +7 -5
- package/src/TemplateManager/src/externalService/LambdaRole/data.js +150 -32
- package/src/TemplateManager/src/externalService/LambdaRole/template.ejs +16 -15
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/data.js +35 -6
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/template.ejs +3 -4
- package/src/TemplateManager/src/libs/Consts.js +122 -11
- package/src/TemplateManager/src/PerActionEndpoint/Handler/testRequest.json +0 -5
|
@@ -0,0 +1,95 @@
|
|
|
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 fs = require('fs');
|
|
21
|
+
|
|
22
|
+
const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
23
|
+
|
|
24
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils")
|
|
25
|
+
const { DEFAULT_HANDLER_PER_ACTION, createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SQS_RESOURCE, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, defaultIamRolePerAction } = require("../../../libs/Consts");
|
|
26
|
+
const templatePath = path.join(__dirname, "./template.ejs");
|
|
27
|
+
|
|
28
|
+
defaultIamRolePerAction()
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* receive objectSchema
|
|
32
|
+
* create data for hdrInv template
|
|
33
|
+
*
|
|
34
|
+
* @param {Object} objectSchema
|
|
35
|
+
* @return {{ templatePath, templateData, setting } }
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
function data(_izContext, srcPath) {
|
|
39
|
+
return [createParamForCreateSource(_izContext, srcPath)];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function createParamForCreateSource(_izContext, srcPath) {
|
|
43
|
+
const functionName = upperCase(FUNCTION_NAME.translateIdsProcess);
|
|
44
|
+
const handlerType = upperCase(HANDLER.hdrDsq);
|
|
45
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
46
|
+
|
|
47
|
+
additionalResourcePermission.push(
|
|
48
|
+
createIamRole(
|
|
49
|
+
{
|
|
50
|
+
[RESOURCE_CLASSES.sqs]:
|
|
51
|
+
[
|
|
52
|
+
SQS_RESOURCE.deleteMessage,
|
|
53
|
+
SQS_RESOURCE.getQueueAttributes,
|
|
54
|
+
SQS_RESOURCE.receiveMessage,
|
|
55
|
+
SQS_RESOURCE.sendMessage,
|
|
56
|
+
SQS_RESOURCE.getQueueUrl,
|
|
57
|
+
],
|
|
58
|
+
[RESOURCE_CLASSES.sns]: ["Publish"]
|
|
59
|
+
},
|
|
60
|
+
[
|
|
61
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + handlerType),
|
|
62
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + handlerType + "DLQ"),
|
|
63
|
+
resourceNames(RESOURCE_CLASSES.sns, "Out" + upperCase(FUNCTION_NAME.outTranslateIds)),
|
|
64
|
+
]
|
|
65
|
+
),
|
|
66
|
+
createIamRole(
|
|
67
|
+
{
|
|
68
|
+
[RESOURCE_CLASSES.dynamoDbTable]: ["GetItem", "UpdateItem", "Query", "PutItem"]
|
|
69
|
+
},
|
|
70
|
+
[
|
|
71
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "TranslateIdsCacheMain"),
|
|
72
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "TranslateIdsCacheFromIdMain"),
|
|
73
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "TranslateIdsCacheFromIdData"),
|
|
74
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "TranslateIdsCacheData"),
|
|
75
|
+
]
|
|
76
|
+
),
|
|
77
|
+
)
|
|
78
|
+
return {
|
|
79
|
+
templatePath: templatePath,
|
|
80
|
+
templateData: {
|
|
81
|
+
functionName,
|
|
82
|
+
handlerType,
|
|
83
|
+
additionalResourcePermission,
|
|
84
|
+
resourceLocation: SOURCE_PATH.resourceLocationTranslateId
|
|
85
|
+
},
|
|
86
|
+
setting: {
|
|
87
|
+
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
88
|
+
saveFileName: upperCase(SAVE_FILE_NAME.translateId),
|
|
89
|
+
fileExtension: ".yml",
|
|
90
|
+
isAppend: true
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
module.exports = data
|
package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/functionYaml/template.ejs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<%_ const join = require('path').join; _%>
|
|
2
|
+
<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>:
|
|
3
|
+
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
|
+
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
|
+
events:
|
|
6
|
+
- sqs:
|
|
7
|
+
arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
8
|
+
batchSize: 10
|
|
9
|
+
iamRoleStatements:
|
|
10
|
+
<%_ additionalResourcePermission.forEach(resourcePermission => { _%>
|
|
11
|
+
- Effect: <%- resourcePermission.effect %>
|
|
12
|
+
Action:
|
|
13
|
+
<%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
|
|
14
|
+
<%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
|
|
15
|
+
- <%- resourcePerAction %>:<%- permission %>
|
|
16
|
+
<%_}) _%>
|
|
17
|
+
<%_ }) _%>
|
|
18
|
+
Resource:
|
|
19
|
+
<%_ resourcePermission.resource.forEach(resource => { _%>
|
|
20
|
+
- "<%- resource %>"
|
|
21
|
+
<%_ }) _%>
|
|
22
|
+
<%_}) _%>
|
|
23
|
+
#<#<%- functionName %><%- handlerType %>IamRole#>
|
|
24
|
+
#<#/<%- functionName %><%- handlerType %>IamRole#>
|
|
25
|
+
<%_ function firstLetterUpperCase(text){
|
|
26
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
27
|
+
} _%>
|
|
28
|
+
<%_ function firstLetterLowerCase(str) {
|
|
29
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
30
|
+
} _%>
|
|
@@ -0,0 +1,52 @@
|
|
|
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 fs = require('fs');
|
|
21
|
+
|
|
22
|
+
const { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
23
|
+
|
|
24
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase } = require("../../../../../MainLibs/src/Utils")
|
|
25
|
+
const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME } = require("../../../libs/Consts");
|
|
26
|
+
const templatePath = path.join(__dirname, './template.ejs');
|
|
27
|
+
|
|
28
|
+
function data(_izContext, srcPath) {
|
|
29
|
+
return [createParamsForCreateSource(_izContext, srcPath)]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function createParamsForCreateSource(_izContext, srcPath) {
|
|
33
|
+
let functionName = (FUNCTION_NAME.translateIdsProcess);
|
|
34
|
+
let handlerType = upperCase(HANDLER.hdrDsq)
|
|
35
|
+
let queueName = upperCase(functionName) + handlerType;
|
|
36
|
+
return {
|
|
37
|
+
templatePath: templatePath,
|
|
38
|
+
templateData: {
|
|
39
|
+
functionName,
|
|
40
|
+
queueName,
|
|
41
|
+
handlerType
|
|
42
|
+
},
|
|
43
|
+
setting: {
|
|
44
|
+
savePath: path.join(srcPath, SOURCE_PATH.translateIdsRequestFile),
|
|
45
|
+
saveFileName: `${upperCase(functionName)}_${handlerType}`,
|
|
46
|
+
fileExtension: ".js",
|
|
47
|
+
isAppend: false
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
module.exports = data
|
|
@@ -0,0 +1,194 @@
|
|
|
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-shared/src/CallingFlowSharedLib');
|
|
22
|
+
const recordHandlerSharedLib = require('@izara_project/izara-shared').recordHandlerSharedLib;
|
|
23
|
+
const {
|
|
24
|
+
validateSchemaMiddleware
|
|
25
|
+
} = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
|
|
26
|
+
const Logger = require('@izara_project/izara-core-library-logger');
|
|
27
|
+
const processTranslateIds = require('./ProcessTranslateIds_Main')
|
|
28
|
+
const perRecordsValidatorSchema = {
|
|
29
|
+
type: "object",
|
|
30
|
+
required: [
|
|
31
|
+
"fromObjType",
|
|
32
|
+
// "fromTypeId",
|
|
33
|
+
"toObjType",
|
|
34
|
+
// "toTypeId",
|
|
35
|
+
"relType",
|
|
36
|
+
],
|
|
37
|
+
properties: {
|
|
38
|
+
fromObjType: {
|
|
39
|
+
type: "object",
|
|
40
|
+
required: ["objectType", "serviceTag"],
|
|
41
|
+
properties: {
|
|
42
|
+
objectType: izara.validatorSchema.stringNotEmpty(),
|
|
43
|
+
serviceTag: izara.validatorSchema.stringNotEmpty(),
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
fromTypeId: {
|
|
47
|
+
type: "string",
|
|
48
|
+
},
|
|
49
|
+
concatinateIdentifier: {
|
|
50
|
+
type: "string",
|
|
51
|
+
},
|
|
52
|
+
fromTable: {
|
|
53
|
+
type: "string",
|
|
54
|
+
},
|
|
55
|
+
fromPartitionKeyId: {
|
|
56
|
+
type: "string",
|
|
57
|
+
},
|
|
58
|
+
fromPartitionKeyFieldName: {
|
|
59
|
+
type: "string",
|
|
60
|
+
},
|
|
61
|
+
fromDataFieldName: {
|
|
62
|
+
type: "string",
|
|
63
|
+
},
|
|
64
|
+
toObjType: {
|
|
65
|
+
type: "object",
|
|
66
|
+
required: ["objectType", "serviceTag"],
|
|
67
|
+
properties: {
|
|
68
|
+
objectType: izara.validatorSchema.stringNotEmpty(),
|
|
69
|
+
serviceTag: izara.validatorSchema.stringNotEmpty(),
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
toTypeId: {
|
|
73
|
+
type: "string",
|
|
74
|
+
},
|
|
75
|
+
relType: {
|
|
76
|
+
type: "object",
|
|
77
|
+
required: ["relationshipTag", "serviceTag"],
|
|
78
|
+
properties: {
|
|
79
|
+
relationshipTag: izara.validatorSchema.stringNotEmpty(),
|
|
80
|
+
serviceTag: izara.validatorSchema.stringNotEmpty(),
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
startKey: {
|
|
84
|
+
type: "object",
|
|
85
|
+
properties: {
|
|
86
|
+
filterDataId: {
|
|
87
|
+
type: "string",
|
|
88
|
+
},
|
|
89
|
+
dataId: {
|
|
90
|
+
type: "string",
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
default: {},
|
|
94
|
+
},
|
|
95
|
+
invocationCount: {
|
|
96
|
+
type: "number",
|
|
97
|
+
default: 0,
|
|
98
|
+
},
|
|
99
|
+
translateIdsCacheMainStatus: {
|
|
100
|
+
type: "string"
|
|
101
|
+
},
|
|
102
|
+
translateIdsCacheId: {
|
|
103
|
+
type: "string"
|
|
104
|
+
},
|
|
105
|
+
translateIdsCacheMain: {
|
|
106
|
+
type: "object",
|
|
107
|
+
properties: {
|
|
108
|
+
cacheExpiryTime: {
|
|
109
|
+
type: "number"
|
|
110
|
+
},
|
|
111
|
+
cacheUniqueRequestId: izara.validatorSchema.stringNotEmpty(),
|
|
112
|
+
cacheStatus: izara.validatorSchema.stringNotEmpty(),
|
|
113
|
+
translateIdsCacheId: izara.validatorSchema.stringNotEmpty(),
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
uniqueRequestId: {
|
|
117
|
+
type: "string"
|
|
118
|
+
},
|
|
119
|
+
callingFlow: {
|
|
120
|
+
type: "string",
|
|
121
|
+
default: "",
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
//(<globalVarible>)
|
|
127
|
+
//(</globalVarible>)
|
|
128
|
+
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
129
|
+
|
|
130
|
+
try {
|
|
131
|
+
let recordPromises = []; // final return
|
|
132
|
+
|
|
133
|
+
// loop each record and send to mainFunction
|
|
134
|
+
await Promise.all(event.Records.map(async record => { // promise.all for map() function
|
|
135
|
+
|
|
136
|
+
// --- reforming record.body for Dsq request
|
|
137
|
+
record = recordHandlerSharedLib.reformatDsqMessage(record._izContext, record);
|
|
138
|
+
record._izContext.logger.debug('record LambdaFunctionHdrDsq after reform', record);
|
|
139
|
+
|
|
140
|
+
let passOnProperties = []
|
|
141
|
+
|
|
142
|
+
// --- validate message (and MessageAttributes)
|
|
143
|
+
await recordHandlerSharedLib.validateRecord(
|
|
144
|
+
record, // one record will send to mainFunction
|
|
145
|
+
"ProcessTranslateIdsHdrDsq", // queue name that need to retry or send to dlq
|
|
146
|
+
perRecordsValidatorSchema, // schema for record.Message
|
|
147
|
+
// messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
// add argument (to invoke lambda) to passOnProperties[]
|
|
151
|
+
passOnProperties.push(record.body.Message.fromObjType)
|
|
152
|
+
passOnProperties.push(record.body.Message.fromTypeId)
|
|
153
|
+
passOnProperties.push(record.body.Message.concatinateIdentifier)
|
|
154
|
+
passOnProperties.push(record.body.Message.fromTable)
|
|
155
|
+
passOnProperties.push(record.body.Message.fromPartitionKeyId)
|
|
156
|
+
passOnProperties.push(record.body.Message.fromPartitionKeyFieldName)
|
|
157
|
+
passOnProperties.push(record.body.Message.fromDataFieldName)
|
|
158
|
+
passOnProperties.push(record.body.Message.toObjType)
|
|
159
|
+
passOnProperties.push(record.body.Message.toTypeId)
|
|
160
|
+
passOnProperties.push(record.body.Message.relType)
|
|
161
|
+
passOnProperties.push(record.body.Message.translateIdsCacheId)
|
|
162
|
+
passOnProperties.push(record.body.Message.uniqueRequestId)
|
|
163
|
+
passOnProperties.push(record.body.Message.startKey)
|
|
164
|
+
// passOnProperties.push(record.body.Message.invocationCount)
|
|
165
|
+
passOnProperties.push(record.body.Message.callingFlow)
|
|
166
|
+
//(<afterSendParamIntoTranslateIdMainByHandlerDsq>)
|
|
167
|
+
//(</afterSendParamIntoTranslateIdMainByHandlerDsq>)
|
|
168
|
+
|
|
169
|
+
record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
|
|
170
|
+
|
|
171
|
+
// call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
|
|
172
|
+
let recordPromise = recordHandlerSharedLib.recordHandler(
|
|
173
|
+
record, // one record will send to mainFunction
|
|
174
|
+
processTranslateIds.processTranslateIds, // mainFunction that need to invoke.
|
|
175
|
+
"ProcessTranslateIdsHdrDsq", // queue name that need to retry or send to dlq
|
|
176
|
+
passOnProperties, // all parameters that mainFunction needed.
|
|
177
|
+
);
|
|
178
|
+
record._izContext.logger.debug('after recordPromise in handler');
|
|
179
|
+
recordPromises.push(recordPromise); // push promise to recordPromises
|
|
180
|
+
})) //end record
|
|
181
|
+
|
|
182
|
+
Logger.debug('before Promise.all(recordPromises) in handler');
|
|
183
|
+
try {
|
|
184
|
+
await Promise.all(recordPromises); // await all promises
|
|
185
|
+
return event.Records // return all for local test
|
|
186
|
+
} catch {
|
|
187
|
+
Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did no resolve)');
|
|
188
|
+
}
|
|
189
|
+
Logger.debug('after Promise.all(recordPromises) in handler');
|
|
190
|
+
} catch (err) {
|
|
191
|
+
Logger.error('Unhandled error, ProcessTranslateIdsRequestHdrDsq:', err);
|
|
192
|
+
throw (err)
|
|
193
|
+
}
|
|
194
|
+
})
|
|
@@ -0,0 +1,48 @@
|
|
|
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 fs = require('fs');
|
|
21
|
+
|
|
22
|
+
const { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
23
|
+
|
|
24
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils")
|
|
25
|
+
const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME } = require("../../../libs/Consts");
|
|
26
|
+
const templatePath = path.join(__dirname, './template.ejs');
|
|
27
|
+
|
|
28
|
+
function data(_izContext, srcPath) {
|
|
29
|
+
return [createSourceParams(_izContext, srcPath)]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function createSourceParams(_izContext, srcPath) {
|
|
33
|
+
let functionName = upperCase(FUNCTION_NAME.translateIdsProcess)
|
|
34
|
+
return {
|
|
35
|
+
templatePath: templatePath,
|
|
36
|
+
templateData: {
|
|
37
|
+
functionName,
|
|
38
|
+
},
|
|
39
|
+
setting: {
|
|
40
|
+
savePath: path.join(srcPath, SOURCE_PATH.translateIdsRequestFile),
|
|
41
|
+
saveFileName: `${upperCase(FUNCTION_NAME.translateIdsProcess)}_Main`,
|
|
42
|
+
fileExtension: ".js",
|
|
43
|
+
isAppend: false
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = data
|