@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,175 @@
|
|
|
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 templatePath = path.join(__dirname, "./template.ejs")
|
|
23
|
+
|
|
24
|
+
const serviceSchemas = require('@izara_project/izara-core-library-service-schemas');
|
|
25
|
+
const serviceConfig = serviceSchemas.serviceConfig;
|
|
26
|
+
|
|
27
|
+
const { HANDLER, STORAGE_TYPES, ACTIONS } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
28
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../MainLibs/src/Utils")
|
|
29
|
+
const { createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SQS_RESOURCE, SOURCE_PATH, SAVE_FILE_NAME } = require("../../libs/Consts");
|
|
30
|
+
|
|
31
|
+
function defaultIamRolePerAction() {
|
|
32
|
+
|
|
33
|
+
let defaultIamRole = [];
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
defaultIamRole.push(
|
|
37
|
+
createIamRole(
|
|
38
|
+
{
|
|
39
|
+
[RESOURCE_CLASSES.s3]: ["GetObject", "GetObjectVersion"],
|
|
40
|
+
},
|
|
41
|
+
[
|
|
42
|
+
resourceNames(RESOURCE_CLASSES.s3, "object-schema/perServiceSchemas/*"),
|
|
43
|
+
resourceNames(RESOURCE_CLASSES.s3, "object-schema/serviceConfig/ServiceNameConfig.json"),
|
|
44
|
+
resourceNames(RESOURCE_CLASSES.s3, "object-schema/serviceConfig/GraphServerTags.json"),
|
|
45
|
+
]
|
|
46
|
+
)
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
defaultIamRole.push(
|
|
50
|
+
createIamRole(
|
|
51
|
+
{ [RESOURCE_CLASSES.s3]: ["ListBucket"] },
|
|
52
|
+
[
|
|
53
|
+
resourceNames(RESOURCE_CLASSES.s3, "object-schema"),
|
|
54
|
+
]
|
|
55
|
+
)
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
defaultIamRole.push(
|
|
59
|
+
createIamRole(
|
|
60
|
+
{
|
|
61
|
+
[RESOURCE_CLASSES.sns]: ["Publish"]
|
|
62
|
+
},
|
|
63
|
+
[
|
|
64
|
+
resourceNames(RESOURCE_CLASSES.sns, "InProcessLogical"),
|
|
65
|
+
resourceNames(RESOURCE_CLASSES.sns, "InPaginateProcessLogical"),
|
|
66
|
+
resourceNames(RESOURCE_CLASSES.sns, "OutProcessLogicalComplete")
|
|
67
|
+
]
|
|
68
|
+
)
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
defaultIamRole.push(
|
|
72
|
+
createIamRole(
|
|
73
|
+
{
|
|
74
|
+
[RESOURCE_CLASSES.dynamoDbTable]: [
|
|
75
|
+
DEFAULT_LAMBDA_ROLE_PER_ACTION[ACTIONS.get].dynamoDbPermission,
|
|
76
|
+
DEFAULT_LAMBDA_ROLE_PER_ACTION[ACTIONS.update].dynamoDbPermission,
|
|
77
|
+
"Query"
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
[
|
|
81
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "LogicalResultsMain")
|
|
82
|
+
]
|
|
83
|
+
)
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
defaultIamRole.push(
|
|
87
|
+
createIamRole(
|
|
88
|
+
{
|
|
89
|
+
[RESOURCE_CLASSES.dynamoDbTable]: [
|
|
90
|
+
DEFAULT_LAMBDA_ROLE_PER_ACTION[ACTIONS.get].dynamoDbPermission,
|
|
91
|
+
DEFAULT_LAMBDA_ROLE_PER_ACTION[ACTIONS.delete].dynamoDbPermission,
|
|
92
|
+
DEFAULT_LAMBDA_ROLE_PER_ACTION[ACTIONS.create].dynamoDbPermission,
|
|
93
|
+
"Query"
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
[
|
|
97
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "LogicalResultsData")
|
|
98
|
+
]
|
|
99
|
+
)
|
|
100
|
+
)
|
|
101
|
+
// console.log("defaultIamRole Api", defaultIamRole)
|
|
102
|
+
return defaultIamRole
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* receive objectSchema
|
|
107
|
+
* create data for FindData Main template
|
|
108
|
+
*
|
|
109
|
+
* @param {Object} objectSchemas
|
|
110
|
+
* @return {{ templatePath, templateData, setting } }
|
|
111
|
+
*/
|
|
112
|
+
async function data(_izContext, objectSchemas, srcPath) {
|
|
113
|
+
|
|
114
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
115
|
+
let functionName = "ProcessLogical";
|
|
116
|
+
let tableForQuery = [];
|
|
117
|
+
|
|
118
|
+
for (let objectSchema of objectSchemas.records) {
|
|
119
|
+
console.log("objectSchema", objectSchemas)
|
|
120
|
+
|
|
121
|
+
for (let storageResource of Object.values(objectSchema.storageResources)) {
|
|
122
|
+
if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
|
|
123
|
+
// add IamRole for dynamodb depend on tableName in storageResources of objectSchema
|
|
124
|
+
tableForQuery.push(resourceNames(RESOURCE_CLASSES.dynamoDbTable, storageResource.tableName));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (tableForQuery.length) {
|
|
130
|
+
additionalResourcePermission.push(
|
|
131
|
+
createIamRole(
|
|
132
|
+
{ [RESOURCE_CLASSES.dynamoDbTable]: "Query" },
|
|
133
|
+
tableForQuery
|
|
134
|
+
)
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
additionalResourcePermission.push(
|
|
139
|
+
createIamRole({
|
|
140
|
+
[RESOURCE_CLASSES.sqs]:
|
|
141
|
+
[
|
|
142
|
+
SQS_RESOURCE.deleteMessage,
|
|
143
|
+
SQS_RESOURCE.getQueueAttributes,
|
|
144
|
+
SQS_RESOURCE.receiveMessage,
|
|
145
|
+
SQS_RESOURCE.sendMessage,
|
|
146
|
+
SQS_RESOURCE.deleteMessageBatch,
|
|
147
|
+
SQS_RESOURCE.getQueueUrl
|
|
148
|
+
]
|
|
149
|
+
}, [
|
|
150
|
+
resourceNames(RESOURCE_CLASSES.sqs, functionName + upperCase(HANDLER.hdrSqs)),
|
|
151
|
+
resourceNames(RESOURCE_CLASSES.sqs, functionName + upperCase(HANDLER.hdrSqs) + "DLQ")
|
|
152
|
+
]
|
|
153
|
+
)
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
console.log("additionalResourcePermission", additionalResourcePermission)
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
templatePath: templatePath,
|
|
160
|
+
templateData: {
|
|
161
|
+
functionName: functionName,
|
|
162
|
+
resourceLocation: SOURCE_PATH.resourceLocationProcessLogical,
|
|
163
|
+
handlerType: HANDLER.hdrSqs,
|
|
164
|
+
additionalResourcePermission
|
|
165
|
+
},
|
|
166
|
+
setting: {
|
|
167
|
+
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
168
|
+
saveFileName: upperCase(SAVE_FILE_NAME.processLogicalYaml),
|
|
169
|
+
fileExtension: '.yml',
|
|
170
|
+
isAppend: true
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
module.exports = data;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<%_ const join = require('path').join; _%>
|
|
2
|
+
<%- functionName %><%- firstLetterUpperCase(handlerType) %>:
|
|
3
|
+
handler: <%- join(resourceLocation, `${functionName}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
|
+
name: ${self:custom.iz_resourcePrefix}<%- functionName %><%- firstLetterUpperCase(handlerType) %>
|
|
5
|
+
events:
|
|
6
|
+
- sqs:
|
|
7
|
+
arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- 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){ return text.charAt(0).toUpperCase() + text.slice(1) } _%>
|
|
@@ -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
|
+
|
|
20
|
+
const path = require('path');
|
|
21
|
+
const { SOURCE_PATH } = require("../../libs/Consts");
|
|
22
|
+
const templatePath = path.join(__dirname, "./template.ejs");
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* receive srcPath
|
|
27
|
+
* not create data for ProcessLogical Main template
|
|
28
|
+
*
|
|
29
|
+
* @param {Object} srcPath
|
|
30
|
+
* @return {{ templatePath, templateData, setting } }
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
function data(_izContext, srcPath) {
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
templatePath: templatePath,
|
|
37
|
+
templateData: {},
|
|
38
|
+
setting: {
|
|
39
|
+
savePath: path.join(srcPath, SOURCE_PATH.processLogical),
|
|
40
|
+
saveFileName: `ProcessLogical_Main`,
|
|
41
|
+
fileExtension: '.js',
|
|
42
|
+
isAppend: false
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = data;
|
|
@@ -0,0 +1,429 @@
|
|
|
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 dynamodbSharedLib = izaraShared.dynamodbSharedLib;
|
|
22
|
+
const graphSharedLib = izaraShared.graphSharedLib;
|
|
23
|
+
const searchResultSharedLib = izaraShared.searchResultSharedLib;
|
|
24
|
+
const logicalResultsSharedLib = izaraShared.logicalResultsSharedLib;
|
|
25
|
+
const snsSharedLib = izaraShared.snsSharedLib;
|
|
26
|
+
|
|
27
|
+
const serviceSchemas = require('@izara_project/izara-core-library-service-schemas');
|
|
28
|
+
const getObjectSchemas = serviceSchemas.getObjectSchema;
|
|
29
|
+
const serviceConfig = serviceSchemas.serviceConfig;
|
|
30
|
+
const { STORAGE_TYPES } = serviceSchemas.consts;
|
|
31
|
+
const { getUsedFieldNamesOfIdentifiers } = serviceSchemas.utils;
|
|
32
|
+
|
|
33
|
+
const sns = require('@izara_project/izara-core-library-external-request').sns;
|
|
34
|
+
|
|
35
|
+
//(<additionalModule>)
|
|
36
|
+
//(</additionalModule>)
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* performs the logical operation/filter/search in the element, saves into LogicalResultsData table
|
|
40
|
+
* @param {Object} _izContext
|
|
41
|
+
* @param {Object} objType - contain objectType and serviceTag
|
|
42
|
+
* @param {Object} element - logical element
|
|
43
|
+
* @param {Object} element.type - "logical"
|
|
44
|
+
* @param {string} element.logicalType - contain "identifier" | "partitionKey"
|
|
45
|
+
* @param {string} [element.partitionKey] - value of fieldNames that is partitionKey. send if logicalType is "partitionKey"
|
|
46
|
+
* @param {string} [element.sortKey] - value of fieldNames that is sortKey. send if logicalType is "partitionKey"
|
|
47
|
+
* @param {string} [element.comparison] - use for query in queryElements.sortKeyCondition. send if logicalType is "partitionKey"
|
|
48
|
+
* @param {Object} [element.identifiers] - object that have identifier. send if logicalType is "identifier"
|
|
49
|
+
*
|
|
50
|
+
* @returns {string} description of return value
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
module.exports.processLogical = async (
|
|
54
|
+
_izContext,
|
|
55
|
+
objType,
|
|
56
|
+
element,
|
|
57
|
+
callingFlow
|
|
58
|
+
) => {
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
|
|
62
|
+
_izContext.logger.debug('----- ProcessLogical event params -----', {
|
|
63
|
+
objType: objType,
|
|
64
|
+
element: element,
|
|
65
|
+
callingFlow: callingFlow
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
let removeAttributes = ["paginateProcessLogicalUniqueRequestId"];
|
|
69
|
+
|
|
70
|
+
//(<removeAttributes>)
|
|
71
|
+
//(</removeAttributes>)
|
|
72
|
+
|
|
73
|
+
// Check/Create logicalResultsMain
|
|
74
|
+
let [logicalResultsMainStatus, logicalResultId, logicalResultMain] = await logicalResultsSharedLib.checkLogicalMainStatus(
|
|
75
|
+
_izContext,
|
|
76
|
+
element, // for create logicalResultId
|
|
77
|
+
objType,
|
|
78
|
+
callingFlow,
|
|
79
|
+
removeAttributes
|
|
80
|
+
);
|
|
81
|
+
_izContext.logger.debug("After check logicalMainStatus: ", {
|
|
82
|
+
logicalResultsMainStatus: logicalResultsMainStatus,
|
|
83
|
+
logicalResultId: logicalResultId,
|
|
84
|
+
logicalResultMain: logicalResultMain
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
if (logicalResultsMainStatus !== "process") {
|
|
88
|
+
_izContext.logger.debug(`logicalResultsMainStatus status isn't process :${logicalResultsMainStatus}`);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
let errorsFound = [];
|
|
93
|
+
|
|
94
|
+
let standardErrorParams = [
|
|
95
|
+
_izContext,
|
|
96
|
+
logicalResultId,
|
|
97
|
+
logicalResultMain.logicalElement,
|
|
98
|
+
logicalResultMain.objType,
|
|
99
|
+
"error"
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
if (element.logicalType === "identifier") {
|
|
103
|
+
_izContext.logger.debug("logicalType: ", element.logicalType)
|
|
104
|
+
|
|
105
|
+
if (!element.hasOwnProperty("identifiers")) {
|
|
106
|
+
errorsFound.push("element don't have identifier")
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (typeof element.identifiers !== "object") {
|
|
110
|
+
errorsFound.push("type of element isn't object")
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const objectSchemas = await getObjectSchemas.getObjSchemaS3WithHierarchy(_izContext, objType);
|
|
114
|
+
_izContext.logger.debug("objectSchemas: ", objectSchemas)
|
|
115
|
+
|
|
116
|
+
let identifiersFieldName = null;
|
|
117
|
+
let graphServerTag = null;
|
|
118
|
+
let fieldNameFindStorageTags = null;
|
|
119
|
+
|
|
120
|
+
const storageResources = objectSchemas.storageResources;
|
|
121
|
+
const fieldNames = objectSchemas.fieldNames;
|
|
122
|
+
|
|
123
|
+
for (const schemasIdentifier of objectSchemas.identifiers) {
|
|
124
|
+
|
|
125
|
+
if (schemasIdentifier.type === "identifier") {
|
|
126
|
+
|
|
127
|
+
identifiersFieldName = schemasIdentifier.fieldName ?
|
|
128
|
+
schemasIdentifier.fieldName :
|
|
129
|
+
schemasIdentifier.name
|
|
130
|
+
|
|
131
|
+
if (identifiersFieldName == schemasIdentifier.name) {
|
|
132
|
+
fieldNameFindStorageTags = schemasIdentifier.fieldNames[0];
|
|
133
|
+
} else {
|
|
134
|
+
fieldNameFindStorageTags = identifiersFieldName;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
let storageResourceTags = fieldNames[fieldNameFindStorageTags].storageResourceTags; // array
|
|
138
|
+
_izContext.logger.debug(`storageResourceTags of fieldNameForFindGraph ${fieldNameFindStorageTags}: `, storageResourceTags)
|
|
139
|
+
|
|
140
|
+
for (const storageResourceTag of storageResourceTags) {
|
|
141
|
+
_izContext.logger.debug("check storageResourceTag: ", storageResourceTag)
|
|
142
|
+
|
|
143
|
+
if (Object.keys(storageResources).includes(storageResourceTag) &&
|
|
144
|
+
storageResources[storageResourceTag].storageType === STORAGE_TYPES.graph) {
|
|
145
|
+
graphServerTag = storageResources[storageResourceTag].graphServerTag;
|
|
146
|
+
_izContext.logger.debug("found graphServerTag: ", graphServerTag)
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (!graphServerTag) {
|
|
154
|
+
errorsFound.push("can't get graphServerTag")
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const identifiersNames = getUsedFieldNamesOfIdentifiers(_izContext, objectSchemas.identifiers);
|
|
158
|
+
_izContext.logger.debug("identifiersNames: ", identifiersNames);
|
|
159
|
+
|
|
160
|
+
for (const identifierName of identifiersNames) {
|
|
161
|
+
if (!element.identifiers.hasOwnProperty(identifierName)) {
|
|
162
|
+
errorsFound.push(`Missing property: ${identifierName} in element`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (errorsFound.length > 0) {
|
|
167
|
+
_izContext.logger.debug("Have errorsFound: ", errorsFound)
|
|
168
|
+
standardErrorParams.push(errorsFound)
|
|
169
|
+
await logicalResultsSharedLib.completeLogicalResultsMain(...standardErrorParams);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const graphHandlerServiceTag = await serviceConfig.getGraphServiceTagWithCache(
|
|
174
|
+
_izContext,
|
|
175
|
+
graphServerTag
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
if (!graphHandlerServiceTag) {
|
|
179
|
+
_izContext.logger.debug("can't get graphServerTag")
|
|
180
|
+
errorsFound.push("can't get graphServerTag")
|
|
181
|
+
standardErrorParams.push(errorsFound)
|
|
182
|
+
await logicalResultsSharedLib.completeLogicalResultsMain(...standardErrorParams);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
let getNodeByIdentifiers = await graphSharedLib.getNodeV2(
|
|
187
|
+
_izContext,
|
|
188
|
+
graphHandlerServiceTag,
|
|
189
|
+
objType,
|
|
190
|
+
{
|
|
191
|
+
identifiers: element.identifiers
|
|
192
|
+
},
|
|
193
|
+
);
|
|
194
|
+
_izContext.logger.debug("getNodeByIdentifiers: ", getNodeByIdentifiers)
|
|
195
|
+
|
|
196
|
+
if (!getNodeByIdentifiers) {
|
|
197
|
+
errorsFound.push(`can not get node by identifiers`);
|
|
198
|
+
standardErrorParams.push(errorsFound)
|
|
199
|
+
await logicalResultsSharedLib.completeLogicalResultsMain(...standardErrorParams);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
await logicalResultsSharedLib.saveLogicalData(
|
|
204
|
+
_izContext,
|
|
205
|
+
logicalResultId,
|
|
206
|
+
objType,
|
|
207
|
+
element.identifiers
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
await logicalResultsSharedLib.completeLogicalResultsMain(
|
|
211
|
+
_izContext,
|
|
212
|
+
logicalResultId,
|
|
213
|
+
element,
|
|
214
|
+
objType,
|
|
215
|
+
"complete",
|
|
216
|
+
[],
|
|
217
|
+
callingFlow
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
} else if (element.logicalType === "partitionKey") {
|
|
221
|
+
_izContext.logger.debug("logicalType: ", element.logicalType)
|
|
222
|
+
|
|
223
|
+
if (!element.hasOwnProperty("partitionKey")) {
|
|
224
|
+
errorsFound.push("element don't have partitionKey")
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (element.comparison && !searchResultSharedLib.consts.POSSIBLE_COMPARISON_SORTID.includes(element.comparison)) {
|
|
228
|
+
errorsFound.push("comparison isn't possible comparison")
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const objectSchemas = await getObjectSchemas.getObjSchemaS3WithHierarchy(_izContext, objType);
|
|
232
|
+
_izContext.logger.debug("objectSchemas: ", objectSchemas)
|
|
233
|
+
|
|
234
|
+
let identifiersFieldName = null;
|
|
235
|
+
let tableName = null;
|
|
236
|
+
let fieldNameFindStorageTags = null; // AKA partitionKeyFieldName
|
|
237
|
+
let sortKeyFieldName = null;
|
|
238
|
+
let haveSortKey = false;
|
|
239
|
+
|
|
240
|
+
const storageResources = objectSchemas.storageResources;
|
|
241
|
+
const fieldNames = objectSchemas.fieldNames;
|
|
242
|
+
|
|
243
|
+
for (const schemasIdentifier of objectSchemas.identifiers) {
|
|
244
|
+
|
|
245
|
+
if (schemasIdentifier.type === "partitionKey") {
|
|
246
|
+
|
|
247
|
+
identifiersFieldName = schemasIdentifier.fieldName ?
|
|
248
|
+
schemasIdentifier.fieldName :
|
|
249
|
+
schemasIdentifier.name
|
|
250
|
+
|
|
251
|
+
if (identifiersFieldName == schemasIdentifier.name) {
|
|
252
|
+
fieldNameFindStorageTags = schemasIdentifier.fieldNames[0];
|
|
253
|
+
} else {
|
|
254
|
+
fieldNameFindStorageTags = identifiersFieldName;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
let storageResourceTags = fieldNames[fieldNameFindStorageTags].storageResourceTags; // array
|
|
258
|
+
_izContext.logger.debug(`storageResourceTags of fieldNameForFindGraph ${fieldNameFindStorageTags}: `, storageResourceTags)
|
|
259
|
+
|
|
260
|
+
for (const storageResourceTag of storageResourceTags) {
|
|
261
|
+
_izContext.logger.debug("check storageResourceTag: ", storageResourceTag)
|
|
262
|
+
|
|
263
|
+
if (Object.keys(storageResources).includes(storageResourceTag) &&
|
|
264
|
+
storageResources[storageResourceTag].storageType === STORAGE_TYPES.dynamoDB
|
|
265
|
+
) {
|
|
266
|
+
tableName = storageResources[storageResourceTag].tableName;
|
|
267
|
+
_izContext.logger.debug("found tableName: ", tableName)
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (schemasIdentifier.type === "sortKey") {
|
|
274
|
+
haveSortKey = true;
|
|
275
|
+
|
|
276
|
+
sortKeyFieldName = schemasIdentifier.fieldName ?
|
|
277
|
+
schemasIdentifier.fieldName :
|
|
278
|
+
schemasIdentifier.name
|
|
279
|
+
_izContext.logger.debug("have sortKeyFieldName: ", sortKeyFieldName)
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (!tableName) {
|
|
284
|
+
errorsFound.push("can't get tableName")
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
if (errorsFound.length > 0) {
|
|
288
|
+
_izContext.logger.debug("Have errorsFound: ", errorsFound)
|
|
289
|
+
standardErrorParams.push(errorsFound)
|
|
290
|
+
await logicalResultsSharedLib.completeLogicalResultsMain(...standardErrorParams);
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (element.hasOwnProperty("sortKey")) {
|
|
295
|
+
|
|
296
|
+
if (!sortKeyFieldName) {
|
|
297
|
+
_izContext.logger.debug("element have sortKey but can't find sortKey in object schemas")
|
|
298
|
+
errorsFound.push("element have sortKey but can't find sortKey in object schemas")
|
|
299
|
+
standardErrorParams.push(errorsFound)
|
|
300
|
+
await logicalResultsSharedLib.completeLogicalResultsMain(...standardErrorParams);
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
let comparison = "equals";
|
|
305
|
+
|
|
306
|
+
if (element.comparison && element.comparison !== "equals") {
|
|
307
|
+
comparison = element.comparison;
|
|
308
|
+
|
|
309
|
+
let sentMessageToPaginateProcessLogical = {
|
|
310
|
+
Message: JSON.stringify({
|
|
311
|
+
logicalResultId: logicalResultId,
|
|
312
|
+
tableName: tableName,
|
|
313
|
+
partitionKeyFieldName: fieldNameFindStorageTags,
|
|
314
|
+
sortKeyFieldName: sortKeyFieldName,
|
|
315
|
+
comparison: comparison,
|
|
316
|
+
callingFlow: callingFlow
|
|
317
|
+
}),
|
|
318
|
+
TopicArn: await snsSharedLib.snsTopicArn(_izContext, "InPaginateProcessLogical")
|
|
319
|
+
};
|
|
320
|
+
_izContext.logger.debug('Request params before send to topic InPaginateProcessLogical: ', sentMessageToPaginateProcessLogical);
|
|
321
|
+
|
|
322
|
+
let resSNS = await sns.publishAsync(_izContext, sentMessageToPaginateProcessLogical);
|
|
323
|
+
_izContext.logger.debug('resSNS send to topic ProcessSortResult finish!', resSNS);
|
|
324
|
+
|
|
325
|
+
return "Send message to InPaginateProcessLogical";
|
|
326
|
+
|
|
327
|
+
} else {
|
|
328
|
+
|
|
329
|
+
let queryDatas = await dynamodbSharedLib.query(
|
|
330
|
+
_izContext,
|
|
331
|
+
await dynamodbSharedLib.tableName(_izContext, tableName),
|
|
332
|
+
{
|
|
333
|
+
[fieldNameFindStorageTags]: element.partitionKey
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
sortKeyCondition: {
|
|
337
|
+
comparison: comparison,
|
|
338
|
+
name: sortKeyFieldName,
|
|
339
|
+
value: element.sortKey
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
)
|
|
343
|
+
_izContext.logger.debug("queryDatas result: ", queryDatas)
|
|
344
|
+
|
|
345
|
+
if (queryDatas.Items.length == 0) {
|
|
346
|
+
_izContext.logger.debug(`can't find data in table ${tableName} by query`)
|
|
347
|
+
errorsFound.push(`can't find data in table ${tableName} by query`)
|
|
348
|
+
standardErrorParams.push(errorsFound)
|
|
349
|
+
await logicalResultsSharedLib.completeLogicalResultsMain(...standardErrorParams);
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
for (const objInstanceBase of queryDatas.Items) {
|
|
354
|
+
|
|
355
|
+
await logicalResultsSharedLib.saveLogicalData(
|
|
356
|
+
_izContext,
|
|
357
|
+
logicalResultId,
|
|
358
|
+
logicalResultMain.objType,
|
|
359
|
+
objInstanceBase
|
|
360
|
+
)
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
} else { // element don't have sortKey
|
|
365
|
+
|
|
366
|
+
if (haveSortKey) {
|
|
367
|
+
_izContext.logger.debug("identifiers have sortKey: query dynamo")
|
|
368
|
+
|
|
369
|
+
let sentMessageToPaginateProcessLogical = {
|
|
370
|
+
Message: JSON.stringify({
|
|
371
|
+
logicalResultId: logicalResultId,
|
|
372
|
+
tableName: tableName,
|
|
373
|
+
partitionKeyFieldName: fieldNameFindStorageTags,
|
|
374
|
+
sortKeyFieldName: sortKeyFieldName,
|
|
375
|
+
callingFlow: callingFlow
|
|
376
|
+
}),
|
|
377
|
+
TopicArn: await snsSharedLib.snsTopicArn(_izContext, "InPaginateProcessLogical")
|
|
378
|
+
};
|
|
379
|
+
_izContext.logger.debug('Request params before send to topic InPaginateProcessLogical: ', sentMessageToPaginateProcessLogical);
|
|
380
|
+
|
|
381
|
+
let resSNS = await sns.publishAsync(_izContext, sentMessageToPaginateProcessLogical);
|
|
382
|
+
_izContext.logger.debug('resSNS send to topic ProcessSortResult finish!', resSNS);
|
|
383
|
+
|
|
384
|
+
return "Send message to InPaginateProcessLogical";
|
|
385
|
+
|
|
386
|
+
} else {
|
|
387
|
+
_izContext.logger.debug("identifiers don't have sortKey: save dataId")
|
|
388
|
+
|
|
389
|
+
await logicalResultsSharedLib.saveLogicalData(
|
|
390
|
+
_izContext,
|
|
391
|
+
logicalResultId,
|
|
392
|
+
objType,
|
|
393
|
+
{
|
|
394
|
+
[fieldNameFindStorageTags]: element.partitionKey
|
|
395
|
+
}
|
|
396
|
+
)
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// complete processLogical and send message Out
|
|
401
|
+
await logicalResultsSharedLib.completeLogicalResultsMain(
|
|
402
|
+
_izContext,
|
|
403
|
+
logicalResultId,
|
|
404
|
+
element,
|
|
405
|
+
objType,
|
|
406
|
+
"complete",
|
|
407
|
+
[],
|
|
408
|
+
callingFlow
|
|
409
|
+
)
|
|
410
|
+
|
|
411
|
+
}
|
|
412
|
+
//(<additionalProcessLogical>)
|
|
413
|
+
//(</additionalProcessLogical>)
|
|
414
|
+
|
|
415
|
+
else {
|
|
416
|
+
_izContext.logger.debug("unrecognised logicalType");
|
|
417
|
+
errorsFound.push("unrecognised logicalType")
|
|
418
|
+
standardErrorParams.push(errorsFound)
|
|
419
|
+
await logicalResultsSharedLib.completeLogicalResultsMain(...standardErrorParams);
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
return "Function ProcessLogical is Finished"
|
|
424
|
+
|
|
425
|
+
} catch (err) {
|
|
426
|
+
_izContext.logger.error('error ProcessLogicalMain: ', err);
|
|
427
|
+
throw (err)
|
|
428
|
+
}
|
|
429
|
+
}
|