@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,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
|
+
|
|
20
|
+
const path = require('path');
|
|
21
|
+
const { SOURCE_PATH, FUNCTION_NAME, HANDLER } = require("../../../libs/Consts");
|
|
22
|
+
const { firstLetterUpperCase: upperCase } = require('../../../../../MainLibs/src/Utils');
|
|
23
|
+
const templatePath = path.join(__dirname, "./template.ejs");
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* receive srcPath
|
|
28
|
+
* not create data for ProcessLogical Main template
|
|
29
|
+
*
|
|
30
|
+
* @param {Object} srcPath
|
|
31
|
+
* @return {{ templatePath, templateData, setting } }
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
function data(_izContext, srcPath) {
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
templatePath: templatePath,
|
|
38
|
+
templateData: {},
|
|
39
|
+
setting: {
|
|
40
|
+
savePath: path.join(srcPath, SOURCE_PATH.processLogical),
|
|
41
|
+
saveFileName: `${upperCase(FUNCTION_NAME.paginateProcessLogical)}_${upperCase(HANDLER.hdrSqs)}`,
|
|
42
|
+
fileExtension: '.js',
|
|
43
|
+
isAppend: false
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = data;
|
|
@@ -0,0 +1,146 @@
|
|
|
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 AWS = require('aws-sdk');
|
|
21
|
+
// const sqs = new AWS.SQS({ apiVersion: '2012-11-05' });
|
|
22
|
+
|
|
23
|
+
const izara = require("@izara_project/izara-middleware");
|
|
24
|
+
const middleware = izara.middlewareHandler;
|
|
25
|
+
const recordHandlerSharedLib = require("@izara_project/izara-shared").recordHandlerSharedLib;
|
|
26
|
+
const Logger = require('@izara_project/izara-core-library-logger');
|
|
27
|
+
|
|
28
|
+
const paginateProcessLogical = require('./PaginateProcessLogical_Main');
|
|
29
|
+
|
|
30
|
+
// validate event properties in body.Message of sqs event
|
|
31
|
+
middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
|
|
32
|
+
|
|
33
|
+
// set schema for record.body.Message
|
|
34
|
+
const perRecordsValidatorSchema = {
|
|
35
|
+
type: "object",
|
|
36
|
+
required: [
|
|
37
|
+
'logicalResultId',
|
|
38
|
+
'tableName',
|
|
39
|
+
'partitionKeyFieldName',
|
|
40
|
+
'sortKeyFieldName'
|
|
41
|
+
],
|
|
42
|
+
properties: {
|
|
43
|
+
logicalResultId: {
|
|
44
|
+
type: "string"
|
|
45
|
+
},
|
|
46
|
+
tableName: {
|
|
47
|
+
type: "string"
|
|
48
|
+
},
|
|
49
|
+
partitionKeyFieldName: {
|
|
50
|
+
type: "string"
|
|
51
|
+
},
|
|
52
|
+
sortKeyFieldName: {
|
|
53
|
+
type: "string"
|
|
54
|
+
},
|
|
55
|
+
comparison: {
|
|
56
|
+
type: "string",
|
|
57
|
+
default: ""
|
|
58
|
+
},
|
|
59
|
+
startKey: {
|
|
60
|
+
type: "object",
|
|
61
|
+
default: {}
|
|
62
|
+
},
|
|
63
|
+
overwriteUniqueRequestId: {
|
|
64
|
+
type: "string",
|
|
65
|
+
default: ""
|
|
66
|
+
},
|
|
67
|
+
callingFlow: {
|
|
68
|
+
type: 'string',
|
|
69
|
+
default: ""
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// set schema for record.body.MessageAttributes
|
|
75
|
+
// const messageAttributeValidatorSchema = {
|
|
76
|
+
// type: "object",
|
|
77
|
+
// required: ['msgAtrrParam1', 'msgAtrrParam2'],
|
|
78
|
+
// properties: {
|
|
79
|
+
// msgAtrrParam1: {
|
|
80
|
+
// type: "string"
|
|
81
|
+
// },
|
|
82
|
+
// msgAtrrParam2: {
|
|
83
|
+
// type: "object"
|
|
84
|
+
// }
|
|
85
|
+
// }
|
|
86
|
+
// };
|
|
87
|
+
|
|
88
|
+
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
89
|
+
|
|
90
|
+
try {
|
|
91
|
+
|
|
92
|
+
let recordPromises = [];
|
|
93
|
+
|
|
94
|
+
// loop each record and send to mainFunction
|
|
95
|
+
await Promise.all(event.Records.map(async record => { // promise.all for map() function
|
|
96
|
+
|
|
97
|
+
let passOnProperties = []
|
|
98
|
+
record._izContext.logger.debug('record ReceiveMsgOutHdrSqs', record);
|
|
99
|
+
|
|
100
|
+
// validate message (and MessageAttributes)
|
|
101
|
+
await recordHandlerSharedLib.validateRecord(
|
|
102
|
+
record, // one record will send to mainFunction
|
|
103
|
+
"PaginateProcessLogicalHdrSqs", // queue name that need to retry or send to dlq
|
|
104
|
+
perRecordsValidatorSchema, // schema for record.Message
|
|
105
|
+
// messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
// add argument (to invoke lambda) to passOnProperties[]
|
|
109
|
+
passOnProperties.push(record.body.Message.logicalResultId)
|
|
110
|
+
passOnProperties.push(record.body.Message.tableName)
|
|
111
|
+
passOnProperties.push(record.body.Message.partitionKeyFieldName)
|
|
112
|
+
passOnProperties.push(record.body.Message.sortKeyFieldName)
|
|
113
|
+
passOnProperties.push(record.body.Message.comparison)
|
|
114
|
+
passOnProperties.push(record.body.Message.startKey)
|
|
115
|
+
passOnProperties.push(record.body.Message.overwriteUniqueRequestId)
|
|
116
|
+
passOnProperties.push(record.body.Message.callingFlow)
|
|
117
|
+
record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
|
|
118
|
+
|
|
119
|
+
// call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
|
|
120
|
+
let recordPromise = recordHandlerSharedLib.recordHandler(
|
|
121
|
+
record, // one record will send to mainFunction
|
|
122
|
+
paginateProcessLogical.paginateProcessLogical, // mainFunction that need to invoke.
|
|
123
|
+
"PaginateProcessLogicalHdrSqs", // queue name that need to retry or send to dlq
|
|
124
|
+
passOnProperties, // all parameters that mainFunction needed.
|
|
125
|
+
);
|
|
126
|
+
record._izContext.logger.debug('after recordPromise in handler');
|
|
127
|
+
recordPromises.push(recordPromise); // push promise to recordPromises
|
|
128
|
+
}))
|
|
129
|
+
|
|
130
|
+
Logger.debug('before Promise.all(recordPromises) in handler');
|
|
131
|
+
try {
|
|
132
|
+
// --- main await all promises
|
|
133
|
+
await Promise.all(recordPromises); // await all promises
|
|
134
|
+
|
|
135
|
+
return event.Records // return all for local testing
|
|
136
|
+
|
|
137
|
+
} catch {
|
|
138
|
+
Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did no resolve)');
|
|
139
|
+
}
|
|
140
|
+
Logger.debug('after Promise.all(recordPromises) in handler');
|
|
141
|
+
|
|
142
|
+
} catch (err) {
|
|
143
|
+
Logger.error('Unhandled Error, PaginateProcessLogicalHdrSqs: ', err);
|
|
144
|
+
throw (err);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
@@ -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
|
+
|
|
20
|
+
const path = require('path');
|
|
21
|
+
const { SOURCE_PATH, FUNCTION_NAME, HANDLER } = require("../../libs/Consts");
|
|
22
|
+
const { firstLetterUpperCase: upperCase } = require('../../../../MainLibs/src/Utils');
|
|
23
|
+
const templatePath = path.join(__dirname, "./template.ejs");
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* receive srcPath
|
|
28
|
+
* not create data for ProcessLogical Main template
|
|
29
|
+
*
|
|
30
|
+
* @param {Object} srcPath
|
|
31
|
+
* @return {{ templatePath, templateData, setting } }
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
function data(_izContext, srcPath) {
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
templatePath: templatePath,
|
|
38
|
+
templateData: {},
|
|
39
|
+
setting: {
|
|
40
|
+
savePath: path.join(srcPath, SOURCE_PATH.processLogical),
|
|
41
|
+
saveFileName: `${upperCase(FUNCTION_NAME.paginateProcessLogical)}_Main`,
|
|
42
|
+
fileExtension: '.js',
|
|
43
|
+
isAppend: false
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = data;
|
|
@@ -0,0 +1,212 @@
|
|
|
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 logicalResultsSharedLib = izaraShared.logicalResultsSharedLib;
|
|
23
|
+
const asyncFlowSharedLib = izaraShared.asyncFlowSharedLib;
|
|
24
|
+
const sqsSharedLib = izaraShared.sqsSharedLib;
|
|
25
|
+
|
|
26
|
+
const sqs = require('@izara_project/izara-core-library-external-request').sqs;
|
|
27
|
+
|
|
28
|
+
const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError;
|
|
29
|
+
|
|
30
|
+
// set query limit
|
|
31
|
+
const limit = 2;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* performs the logical operation/filter/search in the element, saves into LogicalResultsData table
|
|
35
|
+
* @param {Object} _izContext
|
|
36
|
+
* @param {string} logicalResultId
|
|
37
|
+
* @param {string} tableName
|
|
38
|
+
* @param {string} partitionKeyFieldName
|
|
39
|
+
* @param {string} sortKeyFieldName
|
|
40
|
+
* @param {string} comparison
|
|
41
|
+
* @param {Object} startKey
|
|
42
|
+
* @param {string} overwriteUniqueRequestId
|
|
43
|
+
* @param {string} callingFlow
|
|
44
|
+
*
|
|
45
|
+
* @returns {string} description of return value
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
module.exports.paginateProcessLogical = async (
|
|
49
|
+
_izContext,
|
|
50
|
+
logicalResultId,
|
|
51
|
+
tableName,
|
|
52
|
+
partitionKeyFieldName,
|
|
53
|
+
sortKeyFieldName,
|
|
54
|
+
comparison, // optional
|
|
55
|
+
startKey, // optional
|
|
56
|
+
overwriteUniqueRequestId, // optional
|
|
57
|
+
callingFlow // optional
|
|
58
|
+
) => {
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
|
|
62
|
+
_izContext.logger.debug('----- PaginateProcessLogical event params -----', {
|
|
63
|
+
logicalResultId: logicalResultId,
|
|
64
|
+
tableName: tableName,
|
|
65
|
+
partitionKeyFieldName: partitionKeyFieldName,
|
|
66
|
+
sortKeyFieldName: sortKeyFieldName,
|
|
67
|
+
comparison: comparison,
|
|
68
|
+
startKey: startKey,
|
|
69
|
+
overwriteUniqueRequestId: overwriteUniqueRequestId,
|
|
70
|
+
callingFlow: callingFlow
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Check/Create logicalResultsMain
|
|
74
|
+
let [checkUniqueRequestProcessingStatus, logicalResultsMain] = await asyncFlowSharedLib.checkUniqueRequestProcessing(
|
|
75
|
+
_izContext,
|
|
76
|
+
"LogicalResultsMain",
|
|
77
|
+
{
|
|
78
|
+
logicalResultId: logicalResultId
|
|
79
|
+
},
|
|
80
|
+
"paginateProcessLogical",
|
|
81
|
+
overwriteUniqueRequestId
|
|
82
|
+
);
|
|
83
|
+
_izContext.logger.debug("After check uniqueRequestProcessingStatus:", {
|
|
84
|
+
checkUniqueRequestProcessingStatus: checkUniqueRequestProcessingStatus,
|
|
85
|
+
logicalResultsMain: logicalResultsMain
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
if (checkUniqueRequestProcessingStatus == "stop") {
|
|
89
|
+
return;
|
|
90
|
+
} else if (checkUniqueRequestProcessingStatus == "recordNotFound") {
|
|
91
|
+
// should always have unless another request already completed it, in which case nothing to do
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let errorsFound = [];
|
|
96
|
+
let standardErrorParams = [
|
|
97
|
+
_izContext,
|
|
98
|
+
logicalResultId,
|
|
99
|
+
logicalResultsMain.logicalElement,
|
|
100
|
+
logicalResultsMain.objType,
|
|
101
|
+
"error"
|
|
102
|
+
];
|
|
103
|
+
|
|
104
|
+
const partitionKeyValue = logicalResultsMain.logicalElement.partitionKey;
|
|
105
|
+
let queryElements = {
|
|
106
|
+
limit: limit
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
//if received startKey validate it, if not received will return null
|
|
110
|
+
startKey = asyncFlowSharedLib.validateStartKeyParam(
|
|
111
|
+
_izContext,
|
|
112
|
+
startKey,
|
|
113
|
+
partitionKeyFieldName,
|
|
114
|
+
sortKeyFieldName
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
if (startKey === false) {
|
|
118
|
+
throw new NoRetryError("split processing received invalid startKey");
|
|
119
|
+
}
|
|
120
|
+
_izContext.logger.debug("startKey :", startKey);
|
|
121
|
+
|
|
122
|
+
if (startKey) {
|
|
123
|
+
queryElements["exclusiveStartKey"] = {
|
|
124
|
+
[partitionKeyFieldName]: startKey[partitionKeyFieldName],
|
|
125
|
+
[sortKeyFieldName]: startKey[sortKeyFieldName]
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
if (comparison) {
|
|
131
|
+
const sortKeyValue = logicalResultsMain.logicalElement.sortKey;
|
|
132
|
+
|
|
133
|
+
queryElements["sortKeyCondition"] = {
|
|
134
|
+
comparison: comparison,
|
|
135
|
+
name: sortKeyFieldName,
|
|
136
|
+
value: sortKeyValue
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
let queryDatas = await dynamodbSharedLib.query(
|
|
141
|
+
_izContext,
|
|
142
|
+
await dynamodbSharedLib.tableName(_izContext, tableName),
|
|
143
|
+
{
|
|
144
|
+
[partitionKeyFieldName]: partitionKeyValue
|
|
145
|
+
},
|
|
146
|
+
queryElements
|
|
147
|
+
)
|
|
148
|
+
_izContext.logger.debug("queryDatas result: ", queryDatas)
|
|
149
|
+
|
|
150
|
+
if (!startKey && queryDatas.Items.length == 0) {
|
|
151
|
+
_izContext.logger.debug(`can't find data in table ${tableName} by query`)
|
|
152
|
+
errorsFound.push(`can't find data in table ${tableName} by query`)
|
|
153
|
+
standardErrorParams.push(errorsFound)
|
|
154
|
+
await logicalResultsSharedLib.completeLogicalResultsMain(...standardErrorParams);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
for (const objInstanceBase of queryDatas.Items) {
|
|
159
|
+
|
|
160
|
+
await logicalResultsSharedLib.saveLogicalData(
|
|
161
|
+
_izContext,
|
|
162
|
+
logicalResultId,
|
|
163
|
+
logicalResultsMain.objType,
|
|
164
|
+
objInstanceBase
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (queryDatas.hasOwnProperty("LastEvaluatedKey")) {
|
|
169
|
+
|
|
170
|
+
if (!overwriteUniqueRequestId) {
|
|
171
|
+
overwriteUniqueRequestId = _izContext.uniqueRequestId
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
let continuePaginationMsg = {
|
|
175
|
+
MessageBody: JSON.stringify({
|
|
176
|
+
logicalResultId: logicalResultId,
|
|
177
|
+
tableName: tableName,
|
|
178
|
+
partitionKeyFieldName: partitionKeyFieldName,
|
|
179
|
+
sortKeyFieldName: sortKeyFieldName,
|
|
180
|
+
comparison: comparison,
|
|
181
|
+
overwriteUniqueRequestId: overwriteUniqueRequestId,
|
|
182
|
+
startKey: queryDatas.LastEvaluatedKey,
|
|
183
|
+
callingFlow: callingFlow
|
|
184
|
+
}),
|
|
185
|
+
QueueUrl: await sqsSharedLib.sqsQueueUrl(_izContext, "PaginateProcessLogicalHdrDsq"),
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
_izContext.logger.debug("continuePaginationMessage: ", continuePaginationMsg);
|
|
189
|
+
await sqs.sendMessage(_izContext, continuePaginationMsg).promise();
|
|
190
|
+
|
|
191
|
+
return "Continue PaginateProcessLogical"
|
|
192
|
+
|
|
193
|
+
} else {
|
|
194
|
+
|
|
195
|
+
await logicalResultsSharedLib.completeLogicalResultsMain(
|
|
196
|
+
_izContext,
|
|
197
|
+
logicalResultId,
|
|
198
|
+
logicalResultsMain.logicalElement,
|
|
199
|
+
logicalResultsMain.objType,
|
|
200
|
+
"complete",
|
|
201
|
+
[],
|
|
202
|
+
callingFlow
|
|
203
|
+
)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return "Function PaginateProcessLogical is Finished"
|
|
207
|
+
|
|
208
|
+
} catch (err) {
|
|
209
|
+
_izContext.logger.error('error PaginateProcessLogicalMain: ', err);
|
|
210
|
+
throw (err)
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -40,7 +40,7 @@ module.exports.createSourceDataObjectSchema = (_izContext, objectSchema, saveFil
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
const dynamoDbMainYamlDataList = dynamoDbMainYaml.dynamoDbMainYamlFromObjectSchema.templateDataFunction(_izContext, objectSchema);
|
|
43
|
-
console.log("dynamoDbMainYamlDataList: ", dynamoDbMainYamlDataList);
|
|
43
|
+
// console.log("dynamoDbMainYamlDataList: ", dynamoDbMainYamlDataList);
|
|
44
44
|
|
|
45
45
|
for (let dynamoDbMainYamlData of dynamoDbMainYamlDataList) {
|
|
46
46
|
// create iam role of handler here
|
|
@@ -57,7 +57,7 @@ module.exports.createSourceDataObjectSchema = (_izContext, objectSchema, saveFil
|
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
console.log("resultsForCreateSource: ", resultsForCreateSource);
|
|
60
|
+
// console.log("resultsForCreateSource: ", resultsForCreateSource);
|
|
61
61
|
|
|
62
62
|
return resultsForCreateSource;
|
|
63
63
|
}
|
|
@@ -45,7 +45,7 @@ const createDefaultSourceDataDynamoDB = (_izContext, srcPath) => {
|
|
|
45
45
|
|
|
46
46
|
const defaultDynamoDataList = [
|
|
47
47
|
{
|
|
48
|
-
"tableName": "
|
|
48
|
+
"tableName": "FindDataMain",
|
|
49
49
|
"attributes": [
|
|
50
50
|
{
|
|
51
51
|
"keyType": "partitionKey",
|
|
@@ -74,7 +74,7 @@ const createDefaultSourceDataDynamoDB = (_izContext, srcPath) => {
|
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
76
|
"keyType": "sortKey",
|
|
77
|
-
"AttributeName": "
|
|
77
|
+
"AttributeName": "identifiersId",
|
|
78
78
|
"AttributeType": "S"
|
|
79
79
|
}
|
|
80
80
|
]
|
|
@@ -31,7 +31,8 @@ const STORAGE_TYPES = {
|
|
|
31
31
|
graph: "graph"
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
const
|
|
34
|
+
const snsTemplatePath = path.join(__dirname, './snsTemplate.ejs');
|
|
35
|
+
const sqsTemplatePath = path.join(__dirname, './sqsTemplate.ejs');
|
|
35
36
|
const { SOURCE_PATH, SAVE_FILE_NAME } = require('../../libs/Consts')
|
|
36
37
|
|
|
37
38
|
|
|
@@ -46,30 +47,44 @@ const { SOURCE_PATH, SAVE_FILE_NAME } = require('../../libs/Consts')
|
|
|
46
47
|
*/
|
|
47
48
|
|
|
48
49
|
function createDataForDefaultSnsInSqs(_izContext, srcPath) {
|
|
50
|
+
const setting = {
|
|
51
|
+
initialData: "Resources:\n",
|
|
52
|
+
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
53
|
+
saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
|
|
54
|
+
fileExtension: ".yml",
|
|
55
|
+
isAppend: true
|
|
56
|
+
}
|
|
49
57
|
let resultsForCreateDefaultSnsInSqs = [];
|
|
50
58
|
const defaultSnsInSqsDataList = [
|
|
51
59
|
{
|
|
52
|
-
|
|
60
|
+
queueName: "FindData"
|
|
53
61
|
},
|
|
54
62
|
{
|
|
55
|
-
|
|
63
|
+
queueName: "ProcessLogical"
|
|
56
64
|
},
|
|
57
65
|
{
|
|
58
|
-
|
|
66
|
+
queueName: "PaginateProcessLogical"
|
|
59
67
|
}
|
|
60
68
|
]
|
|
61
69
|
|
|
62
70
|
for (let defaultSnsInSqsData of defaultSnsInSqsDataList) {
|
|
63
71
|
resultsForCreateDefaultSnsInSqs.push({
|
|
64
|
-
templatePath,
|
|
72
|
+
templatePath: snsTemplatePath,
|
|
65
73
|
templateData: defaultSnsInSqsData,
|
|
66
|
-
setting:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
74
|
+
setting: setting
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
let defaultDsqQueueDataList = [
|
|
79
|
+
{
|
|
80
|
+
queueName: "PaginateProcessLogicalHdrDsq"
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
for (let defaultDsqQueueData of defaultDsqQueueDataList) {
|
|
84
|
+
resultsForCreateDefaultSnsInSqs.push({
|
|
85
|
+
templatePath: sqsTemplatePath,
|
|
86
|
+
templateData: defaultDsqQueueData,
|
|
87
|
+
setting: setting
|
|
73
88
|
})
|
|
74
89
|
}
|
|
75
90
|
return resultsForCreateDefaultSnsInSqs;
|
|
@@ -51,7 +51,7 @@ function createDataForCreateSourceSnsOut(_izContext, objectSchema, srcPath) {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
console.log("createSourceArrayInCreateSourceSnsOut", createSourceArray)
|
|
54
|
+
// console.log("createSourceArrayInCreateSourceSnsOut", createSourceArray)
|
|
55
55
|
return createSourceArray;
|
|
56
56
|
}
|
|
57
57
|
|
package/src/TemplateManager/src/ResourceYaml/sns-out/defaultSnsOutForFindDataAndProcessLogical.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
|
|
23
|
+
// const {
|
|
24
|
+
// HANDLER,
|
|
25
|
+
// STORAGE_TYPES
|
|
26
|
+
// } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
const STORAGE_TYPES = {
|
|
30
|
+
dynamoDB: "dynamoDB",
|
|
31
|
+
graph: "graph"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const templatePath = path.join(__dirname, "./template.ejs");
|
|
35
|
+
const { SOURCE_PATH, SAVE_FILE_NAME } = require('../../libs/Consts')
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* create data for template.ejs
|
|
40
|
+
* return array of defaultSnsOutData
|
|
41
|
+
* because must create for FindData and ProcessLogical
|
|
42
|
+
*
|
|
43
|
+
* @param {Object} _izContext
|
|
44
|
+
* @param {String} saveFilePath
|
|
45
|
+
* @returns {Object[]} - data of multiple defaultSnsOutData
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
function createDataForDefaultSnsOut(_izContext, srcPath) {
|
|
49
|
+
let resultsForCreateDefaultSnsOut = [];
|
|
50
|
+
const defaultSnsOutDataList = [
|
|
51
|
+
{
|
|
52
|
+
"queueName": "FindDataComplete"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"queueName": "ProcessLogicalComplete"
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
for (let defaultSnsOutData of defaultSnsOutDataList) {
|
|
60
|
+
resultsForCreateDefaultSnsOut.push({
|
|
61
|
+
templatePath: templatePath,
|
|
62
|
+
templateData: defaultSnsOutData,
|
|
63
|
+
setting: {
|
|
64
|
+
initialData: "Resources:\n",
|
|
65
|
+
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
66
|
+
saveFileName: SAVE_FILE_NAME.snsOutYaml,
|
|
67
|
+
fileExtension: ".yml",
|
|
68
|
+
isAppend: true
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
return resultsForCreateDefaultSnsOut;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
module.exports = createDataForDefaultSnsOut;
|