@izara_project/izara-market-library-service-schemas 1.0.4 → 1.0.6
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 +20 -5
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +298 -12
- 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 +119 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrDsq/data.js +133 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrInv/data.js +120 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrSqs/data.js +133 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/mainFunction/data.js +59 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/mainFunction/template.ejs +340 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrApi/data.js +58 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrApi/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrApi/template.ejs +120 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrDsq/data.js +59 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrDsq/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrDsq/template.ejs +167 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrInv/data.js +60 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrInv/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrInv/template.ejs +107 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrSqs/data.js +60 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrSqs/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrSqs/template.ejs +146 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/request.json +30 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/sns-in-sqs/data.js +78 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/functionYaml/data.js +133 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/functionYaml/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/functionYaml/template.ejs +33 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/handler/HdrSqs/data.js +61 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/handler/HdrSqs/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/handler/HdrSqs/template.ejs +125 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/mainFunction/data.js +56 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/mainFunction/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/mainFunction/template.ejs +137 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-in-sqs/data.js +72 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-in-sqs/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-in-sqs/template.ejs +47 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-out/data.js +72 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-out/request.json +0 -0
- 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 +155 -0
- package/src/TemplateManager/src/GenerateCode(Old).js +1 -1
- package/src/TemplateManager/src/GenerateCode.js +205 -45
- 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 +0 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/handler/template.ejs +0 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/createObjectComplete_main.js +172 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/data.js +0 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/template.ejs +0 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-in-sqs/data.js +0 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-in-sqs/template.ejs +0 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-out/data.js +0 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-out/template.ejs +0 -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/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrApi/data.js +24 -20
- package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrApi/template.ejs +2 -2
- package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrDsq/data.js +27 -20
- package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrInv/data.js +54 -22
- package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrSqs/data.js +28 -23
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrSqs/template.ejs +30 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/data.js +6 -22
- 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 -37
- 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 +68 -33
- 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 -30
- 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 +581 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/data.js +0 -21
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/template.ejs +34 -31
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/testParam.json +5 -0
- 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 +421 -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/awaitingMultipleStepData.js +5 -8
- package/src/TemplateManager/src/ResourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +4 -26
- package/src/TemplateManager/src/ResourceYaml/dynamodb/processLogicalAndFindData.js +6 -10
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical.js +28 -16
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/snsAndSqsPerActiondata.js +5 -5
- package/src/TemplateManager/src/ResourceYaml/sns-out/data.js +3 -3
- 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/{FunctionYaml/HdrSqs → TranslateIdReq/ProcessingTranslateIds/functionYaml}/template.ejs +1 -1
- 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 +8 -24
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/handler/HdrSqs/data.js +7 -21
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/data.js +4 -3
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-in-sqs/data.js +10 -13
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-in-sqs/template.ejs +1 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-out/data.js +6 -5
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/data.js +13 -21
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/data.js +11 -29
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/data.js +16 -21
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/data.js +12 -27
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/mainFunction/data.js +3 -18
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/mainFunction/template.ejs +18 -11
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/data.js +5 -18
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/data.js +5 -19
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/data.js +7 -18
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/data.js +6 -20
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/request.json +3 -4
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-in-sqs/data.js +5 -6
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-out/data.js +4 -4
- package/src/TemplateManager/src/externalService/LambdaRole/data.js +181 -59
- package/src/TemplateManager/src/externalService/LambdaRole/template.ejs +17 -15
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/data.js +56 -44
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/template.ejs +3 -4
- package/src/TemplateManager/src/libs/Consts.js +162 -13
- package/src/TemplateManager/src/PerActionEndpoint/Handler/testRequest.json +0 -5
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrApi/request.json +0 -0
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrDsq/request.json +0 -0
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrDsq/template.ejs +0 -0
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrInv/example req.js +0 -0
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrInv/request.json +0 -0
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrInv/template.ejs +0 -0
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrSqs/request.json +0 -0
package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/mainFunction/template.ejs
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
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 izaraShared = require("@izara_project/izara-shared");
|
|
21
|
+
const configSharedLib = izaraShared.configSharedLib;
|
|
22
|
+
const dynamodbSharedLib = izaraShared.dynamodbSharedLib;
|
|
23
|
+
const lambdaSharedLib = izaraShared.lambdaSharedLib;
|
|
24
|
+
const graphSharedLib = izaraShared.graphSharedLib;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
const translateIdsSharedLib = require('@izara_project/izara-translateids/src/TranslateIdsLib');
|
|
29
|
+
const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
|
|
30
|
+
const lambda = require('@izara_project/izara-core-library-external-request/src/resources/Lambda');
|
|
31
|
+
const TranslateIdsLibs = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/TranslateIdsLibs')
|
|
32
|
+
const serviceSchemas = require("@izara_project/izara-core-library-service-schemas");
|
|
33
|
+
const identifiersObject = require('@izara_project/izara-core-library-service-schemas/src/IdentifiersObject');
|
|
34
|
+
const getObjectSchema = require("@izara_project/izara-core-library-service-schemas/src/GetObjectSchema")
|
|
35
|
+
const { firstLetterUpperCase: upperCase } = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* translate ids from one object to another related object
|
|
39
|
+
* @param {Object} _izContext
|
|
40
|
+
* @param {object} fromObjType - the type of object we are translating ids from
|
|
41
|
+
* @param {string} concatinateIdentifier
|
|
42
|
+
* @param {string} fromTypeId - the type of object we are translating ids from
|
|
43
|
+
* @param {string} fromTable - table name
|
|
44
|
+
* @param {string} fromPartitionKeyId - partition key value
|
|
45
|
+
* @param {string} fromPartitionKeyFieldName - partition key field/attribute name
|
|
46
|
+
* @param {string} fromDataFieldName - data field/attribute name
|
|
47
|
+
* @param {object} toObjType - the type of object we are translating ids to
|
|
48
|
+
* @param {string} toTypeId - the type of object we are translating ids to
|
|
49
|
+
* @param {Object} [additionalData={}] - additional data to send back in completed message
|
|
50
|
+
* @param {Object} [startKey={}] - first invoke will be empty
|
|
51
|
+
* @param {Nummic} invocationCount
|
|
52
|
+
* @param {string[]} passOnStatus
|
|
53
|
+
* @param {string[]} passOnErrorsFound
|
|
54
|
+
* @param {string} callingFlow
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
module.exports.processTranslateIds = async (
|
|
58
|
+
_izContext,
|
|
59
|
+
fromObjType,
|
|
60
|
+
fromTypeId,
|
|
61
|
+
concatinateIdentifier,
|
|
62
|
+
fromTable,
|
|
63
|
+
fromPartitionKeyId,
|
|
64
|
+
fromPartitionKeyFieldName,
|
|
65
|
+
fromDataFieldName,
|
|
66
|
+
toObjType,
|
|
67
|
+
toTypeId,
|
|
68
|
+
relType,
|
|
69
|
+
translateIdsCacheId,
|
|
70
|
+
uniqueRequestId,
|
|
71
|
+
startKey = {},
|
|
72
|
+
invocationCount,
|
|
73
|
+
passOnStatus,
|
|
74
|
+
passOnErrorsFound,
|
|
75
|
+
callingFlow = "",
|
|
76
|
+
) => {
|
|
77
|
+
// translateIds request to change from propertyIds to mediaLinkIds.
|
|
78
|
+
// MediaLinkProperty: filter dataId is propertyIds
|
|
79
|
+
// MediaLinkPropertyTranslation: filter dataId is propertyIds
|
|
80
|
+
// translate 2 time , propertyIds from MediaLinkProperty and propertyIds from MediaLinkPropertyTranslation
|
|
81
|
+
try {
|
|
82
|
+
_izContext.logger.debug("=== Function:TranslateIdsRequest ===", {
|
|
83
|
+
fromObjType: fromObjType,
|
|
84
|
+
fromTypeId: fromTypeId,
|
|
85
|
+
concatinateIdentifier: concatinateIdentifier,
|
|
86
|
+
fromTable: fromTable,
|
|
87
|
+
fromPartitionKeyId: fromPartitionKeyId,
|
|
88
|
+
fromPartitionKeyFieldName: fromPartitionKeyFieldName,
|
|
89
|
+
fromDataFieldName: fromDataFieldName,
|
|
90
|
+
toObjType: toObjType,
|
|
91
|
+
toTypeId: toTypeId,
|
|
92
|
+
relType: relType,
|
|
93
|
+
translateIdsCacheId: translateIdsCacheId,
|
|
94
|
+
uniqueRequestId: uniqueRequestId,
|
|
95
|
+
startKey,
|
|
96
|
+
invocationCount,
|
|
97
|
+
passOnStatus,
|
|
98
|
+
passOnErrorsFound,
|
|
99
|
+
callingFlow: callingFlow
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
let errorsFound = [];
|
|
103
|
+
// Query resultDatas from table
|
|
104
|
+
/*
|
|
105
|
+
receive fromType , toType , relType check relationshipSchema return boolean
|
|
106
|
+
just validate to check for error or use for do something further
|
|
107
|
+
if false throw error if true continue translateIds+
|
|
108
|
+
*/
|
|
109
|
+
// let validateObjTypeStatus = await validateFromTypeToToTypeWithRelType(_izContext, fromObjType, toObjType, relType)
|
|
110
|
+
let validateObjTypes = await TranslateIdsLibs.validateObjtypesAndRelType(_izContext, [fromObjType, toObjType], relType)
|
|
111
|
+
if (validateObjTypes == null) {
|
|
112
|
+
errorsFound = errorsFound.concat(`can't find ${fromObjType} and ${toObjType} in relationshipTag:${JSON.stringify(relType)}`)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/*
|
|
116
|
+
check fromIdentifiers if have use it
|
|
117
|
+
if not query data from table by using TranslateIdsGetResultIds
|
|
118
|
+
*/
|
|
119
|
+
let resultDatas;
|
|
120
|
+
let lastEvaluatedKeyResultDatas;
|
|
121
|
+
|
|
122
|
+
if (concatinateIdentifier == null || concatinateIdentifier == undefined) {
|
|
123
|
+
|
|
124
|
+
let getFromObjectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, fromObjType);
|
|
125
|
+
_izContext.logger.debug("getFromObjectSchema", getFromObjectSchema);
|
|
126
|
+
// create Full tableName
|
|
127
|
+
let tableName = await dynamodbSharedLib.tableName(_izContext, fromTable, upperCase(getFromObjectSchema.complexFilterServiceTag));
|
|
128
|
+
_izContext.logger.debug("tableName", tableName);
|
|
129
|
+
resultDatas = await translateIdsSharedLib.translateIdsGetResultIds(
|
|
130
|
+
_izContext,
|
|
131
|
+
tableName,
|
|
132
|
+
fromPartitionKeyId,
|
|
133
|
+
fromPartitionKeyFieldName,
|
|
134
|
+
startKey
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
// lastEvaluatedKeyResultDatas.LastEvaluatedKey
|
|
138
|
+
/*
|
|
139
|
+
if not have resultDatas it mean you cant query identifier from table and you didn't send identifier it will return error
|
|
140
|
+
*/
|
|
141
|
+
_izContext.logger.debug("resultDatas query fromtable =>", resultDatas);
|
|
142
|
+
if (!resultDatas && concatinateIdentifier === null) {
|
|
143
|
+
errorsFound.push(`Can not get resultDatas form Table${fromTable} and not have concatinateIdentifier to TranslateIds`)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/*
|
|
148
|
+
use from concatinateIdentifier to send in processOneRecord
|
|
149
|
+
concatinateIdentifier type string
|
|
150
|
+
check if in cache and if no save to TranslateIdsCacheFromIdDataTable, then move on to next resultData{fromDataId}
|
|
151
|
+
*/
|
|
152
|
+
|
|
153
|
+
async function processOneRecord(
|
|
154
|
+
_izContext,
|
|
155
|
+
translateIdsCacheId,
|
|
156
|
+
fromObjType,
|
|
157
|
+
toObjType,
|
|
158
|
+
relType,
|
|
159
|
+
concatinateIdentifier
|
|
160
|
+
) {
|
|
161
|
+
_izContext.logger.debug("==== Function processOneRecord =====:", {
|
|
162
|
+
translateIdsCacheId: translateIdsCacheId,
|
|
163
|
+
fromObjType: fromObjType,
|
|
164
|
+
toObjType: toObjType,
|
|
165
|
+
relType: relType,
|
|
166
|
+
concatinateIdentifier: concatinateIdentifier
|
|
167
|
+
});
|
|
168
|
+
//if true return becase has cache per FromdataId ,eles false found toDataId;
|
|
169
|
+
/*
|
|
170
|
+
check cache from each dataId
|
|
171
|
+
*/
|
|
172
|
+
let [cacheExist, errorsFoundPerconcatinateIdentifier, translateIdsCacheFromId] = await translateIdsSharedLib.translateIdsCheckCacheFromId(
|
|
173
|
+
_izContext,
|
|
174
|
+
fromObjType,
|
|
175
|
+
concatinateIdentifier,
|
|
176
|
+
toObjType,
|
|
177
|
+
relType,
|
|
178
|
+
translateIdsCacheId,
|
|
179
|
+
uniqueRequestId
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
_izContext.logger.debug('After check translateIdsCheckCacheFromId', {
|
|
184
|
+
cacheExist: cacheExist,
|
|
185
|
+
errorsFoundPerconcatinateIdentifier: errorsFoundPerconcatinateIdentifier,
|
|
186
|
+
translateIdsCacheFromId: translateIdsCacheFromId
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
if (cacheExist) {
|
|
190
|
+
if (errorsFoundPerconcatinateIdentifier.length > 0) {
|
|
191
|
+
errorsFound = errorsFound.concat(errorsFoundPerconcatinateIdentifier)
|
|
192
|
+
}
|
|
193
|
+
return;
|
|
194
|
+
};
|
|
195
|
+
// toDataIds from string to Object using function
|
|
196
|
+
let toDataIds = []
|
|
197
|
+
// transfrom Identifier string to Identifier object to use getNodeAndRelationship
|
|
198
|
+
let identifierObject = await identifiersObject.identifiersObjectFromCompositeIdentifier(
|
|
199
|
+
_izContext,
|
|
200
|
+
fromObjType,
|
|
201
|
+
concatinateIdentifier
|
|
202
|
+
)
|
|
203
|
+
_izContext.logger.debug("identifierObject", identifierObject)
|
|
204
|
+
|
|
205
|
+
let dataIdFromGetNodeAndRelationship = await graphSharedLib.getNodeAndRelationshipsV2(
|
|
206
|
+
_izContext,
|
|
207
|
+
"GraphHandler",
|
|
208
|
+
fromObjType,
|
|
209
|
+
identifierObject,
|
|
210
|
+
relType
|
|
211
|
+
)
|
|
212
|
+
_izContext.logger.debug("dataIdFromGetNodeAndRelationship: ", dataIdFromGetNodeAndRelationship);
|
|
213
|
+
|
|
214
|
+
await Promise.all(
|
|
215
|
+
dataIdFromGetNodeAndRelationship[0].relNodes.map(async (getNodeAndRelResult) => {
|
|
216
|
+
let dataIdFromIdentifiersObject = await identifiersObject.compositeIdentifierFromIdentifiersObject(
|
|
217
|
+
_izContext,
|
|
218
|
+
toObjType,
|
|
219
|
+
getNodeAndRelResult.properties
|
|
220
|
+
)
|
|
221
|
+
_izContext.logger.debug("dataIdFromIdentifiersObject", dataIdFromIdentifiersObject)
|
|
222
|
+
toDataIds.push(dataIdFromIdentifiersObject);
|
|
223
|
+
})
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
_izContext.logger.debug("---------toDataIds---------", toDataIds)
|
|
227
|
+
//-------------------complete TranslateIdsCacheFromIdMain Per fromdataId------------
|
|
228
|
+
let status = 'complete';
|
|
229
|
+
|
|
230
|
+
if (passOnStatus) {
|
|
231
|
+
status = passOnStatus;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (errorsFoundPerconcatinateIdentifier.length > 0) {
|
|
235
|
+
status = 'error';
|
|
236
|
+
passOnErrorsFound = passOnErrorsFound.concat(errorsFoundPerconcatinateIdentifier);
|
|
237
|
+
|
|
238
|
+
} else {
|
|
239
|
+
_izContext.logger.debug('saveTranslateIdsCacheBothDataTables')
|
|
240
|
+
// invoke translateIdsChache lib that saves all toDataIds into both cache Data tables
|
|
241
|
+
await translateIdsSharedLib.saveTranslateIdsCacheBothDataTables(
|
|
242
|
+
_izContext,
|
|
243
|
+
toDataIds,
|
|
244
|
+
translateIdsCacheFromId,
|
|
245
|
+
translateIdsCacheId
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
//complete TranslateIdsCacheFromIdDataMain
|
|
250
|
+
await translateIdsSharedLib.completeTranslateIdsCacheFromIdMain(
|
|
251
|
+
_izContext,
|
|
252
|
+
translateIdsCacheFromId,
|
|
253
|
+
status,
|
|
254
|
+
errorsFoundPerconcatinateIdentifier
|
|
255
|
+
);
|
|
256
|
+
} // end processOneRecord
|
|
257
|
+
|
|
258
|
+
let resultPromises = [];
|
|
259
|
+
/*
|
|
260
|
+
check concatinateIdentifier
|
|
261
|
+
if not use data from resultDatas that query from dynamo
|
|
262
|
+
*/
|
|
263
|
+
if (concatinateIdentifier == null || concatinateIdentifier == undefined) {
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
for (let resultData of resultDatas.Items) {
|
|
267
|
+
|
|
268
|
+
_izContext.logger.debug("+++++iterate resultDatas++++++", resultData);
|
|
269
|
+
resultPromises.push(
|
|
270
|
+
processOneRecord(
|
|
271
|
+
_izContext,
|
|
272
|
+
translateIdsCacheId, //fromPartitionKeyId, toType
|
|
273
|
+
fromObjType,
|
|
274
|
+
toObjType,
|
|
275
|
+
relType,
|
|
276
|
+
resultData[fromDataFieldName], //value of DataId
|
|
277
|
+
)
|
|
278
|
+
);
|
|
279
|
+
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
} else {
|
|
284
|
+
|
|
285
|
+
resultPromises.push(
|
|
286
|
+
processOneRecord(
|
|
287
|
+
_izContext,
|
|
288
|
+
translateIdsCacheId, //fromPartitionKeyId, toType
|
|
289
|
+
fromObjType,
|
|
290
|
+
toObjType,
|
|
291
|
+
relType,
|
|
292
|
+
concatinateIdentifier, //value of DataId
|
|
293
|
+
)
|
|
294
|
+
);
|
|
295
|
+
|
|
296
|
+
}
|
|
297
|
+
await Promise.all(resultPromises);
|
|
298
|
+
|
|
299
|
+
_izContext.logger.debug('============start translateIdsContinueProcessing============')
|
|
300
|
+
//complete TranslateIdsCacheFromIdMain {cache per filterMain}
|
|
301
|
+
let translateStatus = 'complete'
|
|
302
|
+
if (errorsFound.length > 0) {
|
|
303
|
+
translateStatus = 'error'
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
await translateIdsSharedLib.translateIdsContinueProcessing( //translateIdsCheckCache the rest next frsit resultDatas fininsh
|
|
308
|
+
_izContext,
|
|
309
|
+
fromObjType,
|
|
310
|
+
concatinateIdentifier,
|
|
311
|
+
fromTable,
|
|
312
|
+
fromPartitionKeyId,
|
|
313
|
+
fromPartitionKeyFieldName,
|
|
314
|
+
fromDataFieldName,
|
|
315
|
+
toObjType,
|
|
316
|
+
relType,
|
|
317
|
+
translateIdsCacheId,
|
|
318
|
+
lastEvaluatedKeyResultDatas,
|
|
319
|
+
invocationCount,
|
|
320
|
+
translateStatus,
|
|
321
|
+
'ProcessTranslateIdsHdrDsq', // send from calling -- for pagination // e.g,TranslateIdsRequestHdrDsq
|
|
322
|
+
errorsFound,
|
|
323
|
+
callingFlow
|
|
324
|
+
);
|
|
325
|
+
|
|
326
|
+
} catch (err) {
|
|
327
|
+
_izContext.logger.error('error TranslateIdsRequest: ', err)
|
|
328
|
+
throw (err)
|
|
329
|
+
}
|
|
330
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
|
|
21
|
+
|
|
22
|
+
const { HANDLER, ACTIONS } = require("@izara_project/izara-core-library-service-schemas/src/Consts")
|
|
23
|
+
const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME } = require('../../../libs/Consts')
|
|
24
|
+
const { firstLetterUpperCase: uppercase, fristLetterLowerCase: lowerCase } = require('../../../../../MainLibs/src/Utils')
|
|
25
|
+
const templatePath = path.join(__dirname, '../../../ResourceYaml/sns-out/template.ejs');
|
|
26
|
+
|
|
27
|
+
function data(_izContext, srcPath) {
|
|
28
|
+
return [createResourceData(_izContext, srcPath)]
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function createResourceData(_izContext, srcPath) {
|
|
32
|
+
let queueName = uppercase(FUNCTION_NAME.outTranslateIds)
|
|
33
|
+
return {
|
|
34
|
+
templatePath: templatePath,
|
|
35
|
+
templateData: {
|
|
36
|
+
queueName
|
|
37
|
+
},
|
|
38
|
+
setting: {
|
|
39
|
+
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
40
|
+
saveFileName: SAVE_FILE_NAME.snsOutYaml,
|
|
41
|
+
fileExtension: ".yml",
|
|
42
|
+
isAppend: true
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = data
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
|
|
20
|
+
const path = require("path");
|
|
21
|
+
const { HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
22
|
+
const templatePath = path.join(__dirname, './template.ejs');
|
|
23
|
+
const { SOURCE_PATH, FUNCTION_NAME, SAVE_FILE_NAME } = require('../../../libs/Consts');
|
|
24
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils")
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* create data for dynamoDbYaml tempalte from objectSchema
|
|
28
|
+
* return array of dynamoDb data
|
|
29
|
+
* because one objectSchema can create multiple dynamoDb table
|
|
30
|
+
*
|
|
31
|
+
* @param {Object} _izContext
|
|
32
|
+
* @param {String} saveFilePath
|
|
33
|
+
* @returns {Object[]} - data of multiple dynamoDb template
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
function data(_izContext, srcPath) {
|
|
37
|
+
let createTranslateIdsCompleteQueueArray = [];
|
|
38
|
+
const createTranslateIdsCompleteQueues = [
|
|
39
|
+
{
|
|
40
|
+
queueName: upperCase(FUNCTION_NAME.translateIdsProcess) + upperCase(HANDLER.hdrDsq)
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
for (let createTranslateIdsCompleteQueue of createTranslateIdsCompleteQueues) {
|
|
44
|
+
createTranslateIdsCompleteQueueArray.push({
|
|
45
|
+
templatePath: templatePath,
|
|
46
|
+
templateData: createTranslateIdsCompleteQueue,
|
|
47
|
+
setting: {
|
|
48
|
+
initialData: "Resources:\n",
|
|
49
|
+
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
50
|
+
saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
|
|
51
|
+
fileExtension: ".yml",
|
|
52
|
+
isAppend: true
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
return createTranslateIdsCompleteQueueArray
|
|
57
|
+
}
|
|
58
|
+
module.exports = data
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
} _%>
|
|
@@ -0,0 +1,116 @@
|
|
|
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, externalResourceName } = require("../../../../libs/Consts");
|
|
26
|
+
|
|
27
|
+
const templatePath = path.join(__dirname, '../../../../PerActionEndpoint/FunctionYaml/HdrDsq/template.ejs');
|
|
28
|
+
|
|
29
|
+
function defaultIamRolePerAction() {
|
|
30
|
+
let defaultIamRole = [];
|
|
31
|
+
|
|
32
|
+
defaultIamRole.push(
|
|
33
|
+
createIamRole(
|
|
34
|
+
{
|
|
35
|
+
[RESOURCE_CLASSES.s3]: ["GetObject", "GetObjectVersion"],
|
|
36
|
+
},
|
|
37
|
+
[
|
|
38
|
+
resourceNames(RESOURCE_CLASSES.s3, "object-schema/perServiceSchemas/*"),
|
|
39
|
+
resourceNames(RESOURCE_CLASSES.s3, "object-schema/serviceConfig/ServiceNameConfig.json"),
|
|
40
|
+
resourceNames(RESOURCE_CLASSES.s3, "object-schema/serviceConfig/GraphServerTags.json")
|
|
41
|
+
]
|
|
42
|
+
),
|
|
43
|
+
createIamRole(
|
|
44
|
+
{
|
|
45
|
+
[RESOURCE_CLASSES.s3]: ["ListBucket"]
|
|
46
|
+
},
|
|
47
|
+
[
|
|
48
|
+
resourceNames(RESOURCE_CLASSES.s3, "object-schema")
|
|
49
|
+
]
|
|
50
|
+
)
|
|
51
|
+
)
|
|
52
|
+
return defaultIamRole
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* create data for function yaml for translateIds HdrDsq
|
|
57
|
+
*/
|
|
58
|
+
function data(_izContext, srcPath) {
|
|
59
|
+
const createSoureParams = createTranslateIdFunctionYamlHdrDsq(srcPath)
|
|
60
|
+
return [createSoureParams]
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
function createTranslateIdFunctionYamlHdrDsq(srcPath) {
|
|
64
|
+
const functionName = FUNCTION_NAME.translateId
|
|
65
|
+
const handlerType = HANDLER.hdrDsq;
|
|
66
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
67
|
+
additionalResourcePermission.push(
|
|
68
|
+
createIamRole(
|
|
69
|
+
{
|
|
70
|
+
[RESOURCE_CLASSES.sqs]: [
|
|
71
|
+
SQS_RESOURCE.deleteMessage,
|
|
72
|
+
SQS_RESOURCE.getQueueAttributes,
|
|
73
|
+
SQS_RESOURCE.receiveMessage,
|
|
74
|
+
SQS_RESOURCE.sendMessage,
|
|
75
|
+
SQS_RESOURCE.getQueueUrl
|
|
76
|
+
],
|
|
77
|
+
[RESOURCE_CLASSES.sns]:
|
|
78
|
+
[
|
|
79
|
+
"Publish", "Subscribe"
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
[
|
|
83
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(handlerType)),
|
|
84
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(handlerType) + "DLQ"),
|
|
85
|
+
resourceNames(RESOURCE_CLASSES.sns, "In" + upperCase(functionName)),
|
|
86
|
+
resourceNames(RESOURCE_CLASSES.sns, "Out" + upperCase(functionName)),
|
|
87
|
+
]
|
|
88
|
+
),
|
|
89
|
+
createIamRole(
|
|
90
|
+
{
|
|
91
|
+
[RESOURCE_CLASSES.dynamoDbTable]: ["GetItem", "UpdateItem"]
|
|
92
|
+
},
|
|
93
|
+
[
|
|
94
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "TranslateIdsCacheMain")
|
|
95
|
+
]
|
|
96
|
+
)
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
templatePath: templatePath,
|
|
101
|
+
templateData: {
|
|
102
|
+
functionName,
|
|
103
|
+
handlerType,
|
|
104
|
+
additionalResourcePermission,
|
|
105
|
+
resourceLocation: SOURCE_PATH.resourceLocationTranslateId
|
|
106
|
+
},
|
|
107
|
+
setting: {
|
|
108
|
+
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
109
|
+
saveFileName: upperCase(SAVE_FILE_NAME.translateId),
|
|
110
|
+
fileExtension: ".yml",
|
|
111
|
+
isAppend: true
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
module.exports = data;
|