@izara_project/izara-market-library-service-schemas 1.0.2 → 1.0.4
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 +5 -5
- package/src/GenerateCodeLibs/src/Consts.js +40 -0
- package/src/SourceManager/src/CreateSource.js +0 -1
- package/src/SourceManager/src/Utils.js +15 -1
- package/src/TemplateManager/src/FunctionYaml/HdrApi/data.js +170 -0
- package/src/TemplateManager/src/FunctionYaml/HdrApi/request.json +14 -0
- package/src/TemplateManager/src/FunctionYaml/HdrApi/template.ejs +33 -0
- package/src/TemplateManager/src/FunctionYaml/HdrDsq/data.js +180 -0
- package/src/TemplateManager/src/FunctionYaml/HdrDsq/request.json +19 -0
- package/src/TemplateManager/src/FunctionYaml/HdrDsq/template.ejs +30 -0
- package/src/TemplateManager/src/FunctionYaml/HdrInv/data.js +169 -0
- package/src/TemplateManager/src/{PerActionEndpoint/TemplateAndData/ResourceYaml/Lambda/Template/HdrInv.exampleData.js → FunctionYaml/HdrInv/example req.js } +3 -3
- package/src/TemplateManager/src/FunctionYaml/HdrInv/request.json +14 -0
- package/src/TemplateManager/src/{PerActionEndpoint/TemplateAndData/ResourceYaml/Lambda/Template/HdrInv.ejs → FunctionYaml/HdrInv/template.ejs} +5 -5
- package/src/TemplateManager/src/FunctionYaml/HdrSqs/data.js +182 -0
- package/src/TemplateManager/src/FunctionYaml/HdrSqs/request.json +19 -0
- package/src/TemplateManager/src/FunctionYaml/HdrSqs/template.ejs +30 -0
- package/src/TemplateManager/src/GenerateCode(Old).js +135 -0
- package/src/TemplateManager/src/GenerateCode.js +175 -15
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/data.js +100 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/request.json +7 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/template.ejs +76 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/data.js +109 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/request.json +7 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/template.ejs +105 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/data.js +102 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/request.json +7 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/template.ejs +82 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/data.js +102 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/request.json +7 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/template.ejs +124 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/testRequest.json +5 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/data.js +88 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/request.json +5 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/template.ejs +219 -0
- package/src/TemplateManager/src/ResourceYaml/dynamodb/awaitingMultipleStepData.js +98 -0
- package/src/TemplateManager/src/{MainResourcesYaml/TemplateAndData/DynamoDbMain/Data/MainDynamoDbYamlData.js → ResourceYaml/dynamodb/mainResourcePerObjectSchemaData.js} +66 -46
- package/src/TemplateManager/src/ResourceYaml/dynamodb/processLogicalAndFindData.js +103 -0
- package/src/TemplateManager/src/ResourceYaml/dynamodb/request.json +7 -0
- package/src/TemplateManager/src/ResourceYaml/dynamodb/template.ejs +31 -0
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical.js +81 -0
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/request.json +4 -0
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/snsAndSqsPerActiondata.js +108 -0
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/snsTemplate.ejs +59 -0
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/sqsTemplate.ejs +43 -0
- package/src/TemplateManager/src/ResourceYaml/sns-out/data.js +89 -0
- package/src/TemplateManager/src/ResourceYaml/sns-out/request.json +3 -0
- package/src/TemplateManager/src/ResourceYaml/sns-out/template.ejs +10 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/data.js +151 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/request.json +3 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/template.ejs +33 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/handler/HdrSqs/data.js +76 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/handler/HdrSqs/template.ejs +127 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/data.js +55 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/request.json +1 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/template.ejs +140 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-in-sqs/data.js +75 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-in-sqs/request.json +3 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-in-sqs/template.ejs +45 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-out/data.js +70 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-out/request.json +3 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/data.js +127 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/template.ejs +33 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/data.js +148 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/data.js +125 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/data.js +148 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/mainFunction/data.js +80 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/mainFunction/request.json +1 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/mainFunction/template.ejs +324 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/data.js +72 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/request.json +7 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/template.ejs +120 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/data.js +73 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/request.json +7 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/template.ejs +167 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/data.js +73 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/request.json +5 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/template.ejs +126 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/data.js +73 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/request.json +7 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/template.ejs +146 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/request.json +31 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-in-sqs/data.js +91 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-in-sqs/request.json +3 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-out/data.js +70 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-out/request.json +3 -0
- package/src/TemplateManager/src/externalService/LambdaRole/data.js +193 -0
- package/src/TemplateManager/src/externalService/LambdaRole/request.json +18 -0
- package/src/TemplateManager/src/externalService/LambdaRole/template.ejs +56 -0
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/data.js +96 -0
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/request.json +12 -0
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/template.ejs +10 -0
- package/src/TemplateManager/src/libs/Consts.js +32 -3
- package/src/TemplateManager/src/MainResourcesYaml/TemplateAndData/DynamoDbMain/Template/DynamoDb.ejs +0 -31
- package/src/TemplateManager/src/MainResourcesYaml/TemplateAndData/DynamoDbMain/Template/DynamoDb.exampleData.js +0 -12
- package/src/TemplateManager/src/PerActionEndpoint/CreateSourceData.js +0 -131
- package/src/TemplateManager/src/PerActionEndpoint/TemplateAndData/MainFunction/MainFunctionTemplate/Create.js +0 -18
- package/src/TemplateManager/src/PerActionEndpoint/TemplateAndData/MainFunction/MainFunctionTemplate/Delete.js +0 -18
- package/src/TemplateManager/src/PerActionEndpoint/TemplateAndData/MainFunction/MainFunctionTemplate/Get.js +0 -18
- package/src/TemplateManager/src/PerActionEndpoint/TemplateAndData/MainFunction/MainFunctionTemplate/Update.js +0 -18
- package/src/TemplateManager/src/PerActionEndpoint/TemplateAndData/ResourceYaml/Lambda/Data/LambdaYamlData.js +0 -166
- package/src/TemplateManager/src/PerActionEndpoint/TemplateAndData/ResourceYaml/Lambda/Template/HdrSqs.ejs +0 -0
- /package/src/TemplateManager/src/{MainResourcesYaml → ResourceYaml}/CreateSourceData.js +0 -0
- /package/src/TemplateManager/src/{PerActionEndpoint/DataPerActionEndpoint.js → UpdateRelationshipSchema/updateRalationshipComplete/handler/HdrSqs/request.json} +0 -0
- /package/src/TemplateManager/src/{PerActionEndpoint/TemplateAndData/Handler/Handler.js → UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/request.json} +0 -0
- /package/src/TemplateManager/src/{PerActionEndpoint/TemplateAndData/MainFunction/MainFunctionTemplateData.js → UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/request.json} +0 -0
- /package/src/TemplateManager/src/{PerActionEndpoint/TemplateAndData/ResourceYaml/Lambda/Template/HdrApi.ejs → UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/request.json} +0 -0
- /package/src/TemplateManager/src/{PerActionEndpoint/TemplateAndData/ResourceYaml/Lambda/Template/HdrDsq.ejs → UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/request.json} +0 -0
|
@@ -1,131 +0,0 @@
|
|
|
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 schemaConsts = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
23
|
-
|
|
24
|
-
const consts = require('../libs/Consts')
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const lambdaYaml = require("./TemplateAndData/ResourceYaml/Lambda/Data/LambdaYamlData")
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* receive objectSchema
|
|
32
|
-
*
|
|
33
|
-
* return array of object for function createSource
|
|
34
|
-
* eg:
|
|
35
|
-
* [
|
|
36
|
-
* { // main function
|
|
37
|
-
* templatePath:"path of template",
|
|
38
|
-
* data: "data of template",
|
|
39
|
-
* setting: "setting of createSourceFunction"
|
|
40
|
-
* },
|
|
41
|
-
* // ... data of hdr, resource ...etc.
|
|
42
|
-
* ]
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* @param {Object} _izContext
|
|
47
|
-
* @param {Object} objectSchema
|
|
48
|
-
*/
|
|
49
|
-
module.exports.createSourceDataObjectSchema = (_izContext, objectSchema, saveFilePath) => {
|
|
50
|
-
|
|
51
|
-
let resultsForCreateSource = [];
|
|
52
|
-
/*
|
|
53
|
-
receive objectSchema
|
|
54
|
-
|
|
55
|
-
check setting of overwrite main function
|
|
56
|
-
if not exists will create new main function
|
|
57
|
-
|
|
58
|
-
check overWriteHandlers
|
|
59
|
-
create handler depend on overWriteHandlers setting or default setting
|
|
60
|
-
- create lambda Yaml depend on handler
|
|
61
|
-
- add dynamodb iam role to lambda iam role
|
|
62
|
-
*/
|
|
63
|
-
|
|
64
|
-
// create main function per action
|
|
65
|
-
for (let action of Object.values(consts.ACTIONS)) {
|
|
66
|
-
console.log("action: ", action);
|
|
67
|
-
|
|
68
|
-
let overWriteMainFunction = (objectSchema.overwriteGeneratedMainFunction && Array.isArray(objectSchema.overwriteGeneratedMainFunction))
|
|
69
|
-
? objectSchema.overwriteGeneratedMainFunction : [];
|
|
70
|
-
|
|
71
|
-
// avoid generate main function
|
|
72
|
-
if (overWriteMainFunction.includes(action)) {
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// -> start generate main function Per action here
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
// create handler and iam role of handler per action
|
|
81
|
-
for (let [action, handlerList] of Object.entries(consts.DEFAULT_HANDLER_PER_ACTION)) {
|
|
82
|
-
|
|
83
|
-
let useHandler = (objectSchema.overWriteHandlers && objectSchema.overWriteHandlers[action])
|
|
84
|
-
? objectSchema.overWriteHandlers[action]
|
|
85
|
-
: handlerList;
|
|
86
|
-
|
|
87
|
-
console.log("useHandler: ", useHandler);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
// start to create handler
|
|
91
|
-
// if overWriteHandlers[action] is empty array will not create handler
|
|
92
|
-
for (let hdr of useHandler) {
|
|
93
|
-
// -> create handler here
|
|
94
|
-
|
|
95
|
-
// -> create iam role of handler here
|
|
96
|
-
resultsForCreateSource.push({
|
|
97
|
-
templatePath: lambdaYaml[hdr].templatePath,
|
|
98
|
-
templateData: lambdaYaml[hdr].templateDataFunction(_izContext, objectSchema, action),
|
|
99
|
-
setting: {
|
|
100
|
-
savePath: path.join(saveFilePath, consts.SOURCE_PATH.appYaml),
|
|
101
|
-
saveFileName: 'generate-function',
|
|
102
|
-
fileExtension: '.yml',
|
|
103
|
-
isAppend: true
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
// -> create sns sqs here
|
|
108
|
-
// -> ideas for below
|
|
109
|
-
// resultsForCreateSource.push({
|
|
110
|
-
// templatePath: "xx",
|
|
111
|
-
// templateData: "xx",
|
|
112
|
-
// setting: {
|
|
113
|
-
// savePath: path.join(saveFilePath, config.SOURCE_PATH.appYaml),
|
|
114
|
-
// saveFileName: 'sns-in-sqs',
|
|
115
|
-
// fileExtension: '.yml',
|
|
116
|
-
// isAppend: true
|
|
117
|
-
// }
|
|
118
|
-
// });
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
// create resource for handler
|
|
126
|
-
|
|
127
|
-
// create resource for all handler, eg: dynamo
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return resultsForCreateSource;
|
|
131
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
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';
|
|
@@ -1,18 +0,0 @@
|
|
|
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';
|
|
@@ -1,18 +0,0 @@
|
|
|
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';
|
|
@@ -1,18 +0,0 @@
|
|
|
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';
|
|
@@ -1,166 +0,0 @@
|
|
|
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 {
|
|
23
|
-
// HANDLER
|
|
24
|
-
// } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
25
|
-
|
|
26
|
-
const {
|
|
27
|
-
createIamRole,
|
|
28
|
-
resourceNames,
|
|
29
|
-
RESOURCE_CLASSES,
|
|
30
|
-
DEFAULT_HANDLER_PER_ACTION
|
|
31
|
-
} = require("../../../../../libs/Consts");
|
|
32
|
-
|
|
33
|
-
const {
|
|
34
|
-
firstLetterLowerCase,
|
|
35
|
-
firstLetterUpperCase
|
|
36
|
-
} = require("../../../../../../../MainLibs/src/Utils");
|
|
37
|
-
|
|
38
|
-
const defaultGeneratedLambdaLocation = "src/generatedCode/lambdaPerObjectType/source/"
|
|
39
|
-
|
|
40
|
-
const HANDLER = { // mock
|
|
41
|
-
hdrApi: "hdrApi",
|
|
42
|
-
hdrInv: "hdrInv",
|
|
43
|
-
hdrDsq: "hdrDsq",
|
|
44
|
-
hdrSqs: "hdrSqs"
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const STORAGE_TYPES = {
|
|
48
|
-
dynamoDB: "dynamoDB",
|
|
49
|
-
graph: "graph"
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function defaultIamRolePerAction() {
|
|
53
|
-
|
|
54
|
-
let defaultIamRole = [];
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
defaultIamRole.push(
|
|
58
|
-
createIamRole(
|
|
59
|
-
{ [RESOURCE_CLASSES.s3]: ["GetObject", "GetObjectVersion"] },
|
|
60
|
-
[
|
|
61
|
-
resourceNames(RESOURCE_CLASSES.s3, "object-schema/perServiceSchemas/*"),
|
|
62
|
-
resourceNames(RESOURCE_CLASSES.s3, "object-schema/serviceConfig/ServiceNameConfig.json"),
|
|
63
|
-
resourceNames(RESOURCE_CLASSES.s3, "object-schema/serviceConfig/GraphServerTags.json"),
|
|
64
|
-
]
|
|
65
|
-
)
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
defaultIamRole.push(
|
|
69
|
-
createIamRole(
|
|
70
|
-
{ [RESOURCE_CLASSES.s3]: ["ListBucket"] },
|
|
71
|
-
[
|
|
72
|
-
resourceNames(RESOURCE_CLASSES.s3, "object-schema"),
|
|
73
|
-
]
|
|
74
|
-
)
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
return defaultIamRole
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// ---------- Per Lambda Handler IamRole Data ----------
|
|
81
|
-
|
|
82
|
-
function lambdaIamRoleForHdrInv(_izContext, objectSchema, action) {
|
|
83
|
-
console.log("lambdaIamRoleForHdrInv");
|
|
84
|
-
console.log("action: ", action);
|
|
85
|
-
|
|
86
|
-
// add lambda role
|
|
87
|
-
|
|
88
|
-
let additionalResourcePermission = defaultIamRolePerAction();
|
|
89
|
-
|
|
90
|
-
let hasGraphStorage = false;
|
|
91
|
-
for (let storageResource of Object.values(objectSchema.storageResources)) {
|
|
92
|
-
if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
|
|
93
|
-
// add IamRole for dynamodb depend on tableName in storageResources of objectSchema
|
|
94
|
-
additionalResourcePermission.push(
|
|
95
|
-
createIamRole(
|
|
96
|
-
{ [RESOURCE_CLASSES.dynamoDbTable]: [DEFAULT_HANDLER_PER_ACTION[action].dynamoDbPermission] },
|
|
97
|
-
[resourceNames(RESOURCE_CLASSES.dynamoDbTable, storageResource.tableName)]
|
|
98
|
-
)
|
|
99
|
-
);
|
|
100
|
-
} else if (storageResource.storageType === STORAGE_TYPES.graph) {
|
|
101
|
-
// find graph serviceName from graphServerTag or *GetNodeHdrInv ?
|
|
102
|
-
|
|
103
|
-
if (hasGraphStorage) {
|
|
104
|
-
continue;
|
|
105
|
-
} else {
|
|
106
|
-
hasGraphStorage = true;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
additionalResourcePermission.push(
|
|
110
|
-
createIamRole(
|
|
111
|
-
{ [RESOURCE_CLASSES.lambda]: ["InvokeFunction"] },
|
|
112
|
-
[resourceNames(RESOURCE_CLASSES.lambda, "*GetNodeHdrInv")]
|
|
113
|
-
)
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// finished add lambda role
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return {
|
|
122
|
-
resourceName: `${objectSchema.objectType}${firstLetterUpperCase(action)}`,
|
|
123
|
-
handlerType: HANDLER.hdrInv,
|
|
124
|
-
resourceLocation: `${path.join(defaultGeneratedLambdaLocation, objectSchema.objectType)}`,
|
|
125
|
-
additionalResourcePermission
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function lambdaIamRoleForHdrApi(_izContext, objectSchema, action) {
|
|
130
|
-
console.log("lambdaIamRoleForHdrApi");
|
|
131
|
-
console.log("action: ", action);
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
function lambdaIamRoleForHdrSqs(_izContext, objectSchema, action) {
|
|
137
|
-
console.log("lambdaIamRoleForHdrSqs");
|
|
138
|
-
console.log("action: ", action);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
function lambdaIamRoleForHdrDsq(_izContext, objectSchema, action) {
|
|
143
|
-
console.log("lambdaIamRoleForHdrDsq");
|
|
144
|
-
console.log("action: ", action);
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// ---------- End Per Lambda Handler IamRole Data ----------
|
|
149
|
-
module.exports = {
|
|
150
|
-
[HANDLER.hdrInv]: {
|
|
151
|
-
templatePath: path.join(__dirname, "../Template/HdrInv.ejs"),
|
|
152
|
-
templateDataFunction: lambdaIamRoleForHdrInv
|
|
153
|
-
},
|
|
154
|
-
[HANDLER.hdrApi]: {
|
|
155
|
-
templatePath: path.join(__dirname, "../Template/HdrApi.ejs"),
|
|
156
|
-
templateDataFunction: lambdaIamRoleForHdrApi
|
|
157
|
-
},
|
|
158
|
-
[HANDLER.hdrSqs]: {
|
|
159
|
-
templatePath: path.join(__dirname, "../Template/HdrSqs.ejs"),
|
|
160
|
-
templateDataFunction: lambdaIamRoleForHdrSqs
|
|
161
|
-
},
|
|
162
|
-
[HANDLER.hdrDsq]: {
|
|
163
|
-
templatePath: path.join(__dirname, "../Template/HdrDsq.ejs"),
|
|
164
|
-
templateDataFunction: lambdaIamRoleForHdrDsq
|
|
165
|
-
}
|
|
166
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|