@izara_project/izara-market-library-service-schemas 1.0.26 → 1.0.27
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/index.js +2 -1
- package/package.json +3 -2
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +1 -1
- package/src/MainLibs/src/Consts.js +1 -0
- package/src/TemplateManager/src/libs/Consts.js +0 -1
- package/src/reStructure/GenerateCode.js +27 -4
- package/src/reStructure/GenerateSchema.js +141 -0
- package/src/reStructure/SchemaConfig.js +28 -0
- package/src/reStructure/TemplateConfig.js +20 -0
- package/src/reStructure/TemplateData/attributeTreeSchema/generateTemplateData.js +52 -0
- package/src/reStructure/TemplateData/attributeTreeSchema/mainAttributeTreeSchema/attributeLink.ejs +21 -0
- package/src/reStructure/TemplateData/attributeTreeSchema/mainAttributeTreeSchema/data.js +128 -0
- package/src/reStructure/TemplateData/attributeTreeSchema/mainAttributeTreeSchema/request.json +11 -0
- package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/functionYaml/data.js +3 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/functionYaml/template.ejs +1 -14
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/functionYaml/data.js +4 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/functionYaml/template.ejs +1 -14
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/functionYaml/data.js +3 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/functionYaml/template.ejs +1 -14
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/getSignUrls/functionYaml/data.js +3 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/getSignUrls/functionYaml/template.ejs +1 -14
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/data.js +3 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/template.ejs +1 -14
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrS3/data.js +4 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrS3/template.ejs +1 -14
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +4 -2
- package/src/reStructure/TemplateData/flowSchema/components/websocket/dynamoDb/ReservedTableData.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/websocket/dynamoDb/WebSocketTaskData.js +1 -1
- package/src/reStructure/TemplateData/generateRole/createSharedResource.js +10 -0
- package/src/reStructure/TemplateData/perActionComplete/update/sns-in-sqs/data.js +1 -1
- package/src/reStructure/libs/GenerateCodeLibs.js +38 -0
package/index.js
CHANGED
|
@@ -23,5 +23,6 @@ module.exports = {
|
|
|
23
23
|
generateCodeLibs: require('./src/GenerateCodeLibs'),
|
|
24
24
|
|
|
25
25
|
generateSchemaWithTemplate: require('./src/TemplateManager/src/GenerateSchema').generateSchemaWithTemplate,
|
|
26
|
-
generateCodeWithTemplate: require('./src/reStructure/GenerateCode').generateCodeWithTemplate
|
|
26
|
+
generateCodeWithTemplate: require('./src/reStructure/GenerateCode').generateCodeWithTemplate,
|
|
27
|
+
generateSchema: require('./src/reStructure/GenerateSchema')
|
|
27
28
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@izara_project/izara-market-library-service-schemas",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.27",
|
|
4
4
|
"description": "Schemas for Izara Market project",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,8 +22,9 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@izara_project/izara-core-library-core": "^1.0.16",
|
|
24
24
|
"@izara_project/izara-core-library-external-request": "^1.0.17",
|
|
25
|
-
"@izara_project/izara-core-library-service-schemas": "^1.0.
|
|
25
|
+
"@izara_project/izara-core-library-service-schemas": "^1.0.47",
|
|
26
26
|
"@izara_project/izara-shared": "^1.0.125",
|
|
27
|
+
"@izara_project/izara-shared-service-schemas": "^1.0.4",
|
|
27
28
|
"ejs": "^3.1.10",
|
|
28
29
|
"js-beautify": "^1.15.4",
|
|
29
30
|
"lodash": "^4.17.21",
|
|
@@ -46,7 +46,7 @@ const {
|
|
|
46
46
|
const Logger = require("@izara_project/izara-core-library-logger");
|
|
47
47
|
|
|
48
48
|
const nodeLabelRegexPattern = "^[a-zA-Z0-9_-]+(?:\:[a-zA-Z0-9_-]+)?$"
|
|
49
|
-
const { validateObjType } = require('@izara_project/izara-
|
|
49
|
+
const { validateObjType } = require('@izara_project/izara-shared-service-schemas').validateObjType;
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
|
|
@@ -367,6 +367,7 @@ const SOURCE_GENERATE_IAM_ROLE = {
|
|
|
367
367
|
NodeCompleteRole: "NodeCom",
|
|
368
368
|
RelationshipRole: "Relationship",
|
|
369
369
|
RelationshipCompleteRole: "RelationshipCom",
|
|
370
|
+
FlowSchemaUploadS3Role: "FlowSchemaUploadS3"
|
|
370
371
|
};
|
|
371
372
|
|
|
372
373
|
const ADD_ON_DATA_STRUCTURE_TYPE = {
|
|
@@ -23,7 +23,6 @@ const {
|
|
|
23
23
|
STORAGE_TYPES
|
|
24
24
|
} = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
25
25
|
|
|
26
|
-
const { firstLetterUpperCase: upperCase } = require("../../../MainLibs/src/Utils")
|
|
27
26
|
|
|
28
27
|
const { getGraphServiceNameFromGraphServerTagWithCache, getGraphServiceTagWithCache } = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig');
|
|
29
28
|
|
|
@@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
20
20
|
const { join, resolve } = require("path");
|
|
21
21
|
const { readFileSync } = require("fs");
|
|
22
22
|
|
|
23
|
+
const { validatePathWithRootServicePath } = require("./libs/GenerateCodeLibs")
|
|
24
|
+
|
|
23
25
|
const templateConfig = require("./TemplateConfig");
|
|
24
26
|
|
|
25
27
|
// SourceManager
|
|
@@ -39,6 +41,9 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
39
41
|
// point to app/src
|
|
40
42
|
let saveFilePath = join(objSchemaPath, `../`);
|
|
41
43
|
|
|
44
|
+
// point to root folder of service
|
|
45
|
+
let localServicePath = join(saveFilePath, "../../");
|
|
46
|
+
|
|
42
47
|
// // define path for store yml file
|
|
43
48
|
const GENERATE_CODE_SOURCE_PATH = {
|
|
44
49
|
appYaml: join(saveFilePath, SOURCE_PATH.appYaml),
|
|
@@ -50,7 +55,6 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
50
55
|
generateCodeLib: join(saveFilePath, SOURCE_PATH.generateCodeLib),
|
|
51
56
|
};
|
|
52
57
|
|
|
53
|
-
|
|
54
58
|
//------ Start Create Source ------
|
|
55
59
|
|
|
56
60
|
// collect all result of template data for execute createSource
|
|
@@ -105,14 +109,22 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
105
109
|
}
|
|
106
110
|
}
|
|
107
111
|
|
|
112
|
+
// validate path before empty folder
|
|
113
|
+
for (let folderPathToEmpty of Object.values(GENERATE_CODE_SOURCE_PATH)) {
|
|
114
|
+
validatePathWithRootServicePath(localServicePath, folderPathToEmpty)
|
|
115
|
+
}
|
|
108
116
|
|
|
109
|
-
for (let folderPathToEmpty of Object.
|
|
110
|
-
await deleteFileInDir(
|
|
117
|
+
for (let folderPathToEmpty of Object.values(GENERATE_CODE_SOURCE_PATH)) {
|
|
118
|
+
await deleteFileInDir(folderPathToEmpty);
|
|
111
119
|
}
|
|
112
120
|
|
|
113
121
|
|
|
114
122
|
// generate all source
|
|
115
123
|
for (let item of allCreateSource) {
|
|
124
|
+
if (item.setting.initialData) {
|
|
125
|
+
console.log("setting::", item.setting)
|
|
126
|
+
console.log("templatePath::", item.templatePath)
|
|
127
|
+
}
|
|
116
128
|
// throw error if item is invalid
|
|
117
129
|
if (!item || !item.templatePath || !item.templateData || !item.setting) {
|
|
118
130
|
console.log('Throwing invalid source item:', item);
|
|
@@ -139,4 +151,15 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
139
151
|
|
|
140
152
|
module.exports = {
|
|
141
153
|
generateCodeWithTemplate
|
|
142
|
-
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
/*
|
|
158
|
+
GenerateCode will iterate through templateConfig and generate each template dependOn each templateAndData\
|
|
159
|
+
|
|
160
|
+
GenerateSchema now use for generate attribute tree only
|
|
161
|
+
generateSchema can be modify use used depend on use case eg: some objectType have attribute tree inside addOn
|
|
162
|
+
when generateSchema in own service need to generate ref objectRelationship only
|
|
163
|
+
and attribute tree service can generate schema
|
|
164
|
+
|
|
165
|
+
*/
|
|
@@ -0,0 +1,141 @@
|
|
|
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 { join, resolve } = require("path");
|
|
21
|
+
const { readFileSync } = require("fs");
|
|
22
|
+
|
|
23
|
+
const schemaConfig = require("./SchemaConfig");
|
|
24
|
+
|
|
25
|
+
// SourceManager
|
|
26
|
+
const { deleteFileInDir, createHookFunction } = require("../SourceManager/src/Utils");
|
|
27
|
+
const { createSource } = require("../SourceManager/src/CreateSource");
|
|
28
|
+
|
|
29
|
+
const { SOURCE_PATH } = require('../TemplateManager/src/libs/Consts');
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
async function generateSchema(_izContext, objSchemaPath, generateSchemaSettings) {
|
|
34
|
+
try {
|
|
35
|
+
console.log('objSchemaPath', objSchemaPath);
|
|
36
|
+
// --------- Prepare path -------------
|
|
37
|
+
// point to app/src
|
|
38
|
+
let saveFilePath = join(objSchemaPath, `../`);
|
|
39
|
+
console.log("saveFilePath: ", saveFilePath);
|
|
40
|
+
|
|
41
|
+
// point to root folder of service
|
|
42
|
+
let localServicePath = join(saveFilePath, "../../");
|
|
43
|
+
console.log("localServicePath: ", localServicePath);
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
//------ Start Create Source ------
|
|
47
|
+
|
|
48
|
+
// collect all result of template data for execute createSource
|
|
49
|
+
let allCreateSource = [];
|
|
50
|
+
// collect all path that need to empty before createSource
|
|
51
|
+
let allEmptyPath = [];
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
// Validate that all generateNames in generateSettings are present in the schemaConfig
|
|
55
|
+
const generateNameSet = new Set(Object.keys(schemaConfig.TemplateAndData));
|
|
56
|
+
|
|
57
|
+
// Find any missing generateNames that are not in the schemaConfig
|
|
58
|
+
let missingGenerateName = generateSchemaSettings.
|
|
59
|
+
filter(({ generateName }) => !generateNameSet.has(generateName));
|
|
60
|
+
|
|
61
|
+
// If there are missing generateNames, throw an error with the list of missing names
|
|
62
|
+
if (missingGenerateName.length) {
|
|
63
|
+
throw Error(`Invalid generateName:[ ${missingGenerateName.map(({ generateName }) => generateName).join(", ")} ]`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
// start create generateSchema depend on
|
|
68
|
+
for (const { generateName, settingData } of generateSchemaSettings) {
|
|
69
|
+
let generateSchemaData = require(join(__dirname, schemaConfig.TemplateAndData[generateName]));
|
|
70
|
+
let createSourceResult = await generateSchemaData(_izContext, objSchemaPath, settingData);
|
|
71
|
+
|
|
72
|
+
// Filter out empty or invalid objects before adding to allCreateSource
|
|
73
|
+
if (Array.isArray(createSourceResult)) {
|
|
74
|
+
const validResults = createSourceResult.filter(item =>
|
|
75
|
+
item && item.templatePath && item.templateData && item.setting
|
|
76
|
+
);
|
|
77
|
+
allCreateSource.push(...validResults);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// check each allCreateSource valid
|
|
82
|
+
for (let item of allCreateSource) {
|
|
83
|
+
// throw Error('Skipping invalid source item:', item);
|
|
84
|
+
if (!item || !item.templatePath || !item.templateData || !item.setting) {
|
|
85
|
+
console.log('throw Error Skipping invalid source item:', item);
|
|
86
|
+
throw Error('Skipping invalid source item:', item);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const { templatePath, templateData, setting, emptyPath: returnEmptyPath } = item;
|
|
90
|
+
setting.checkCreateSourcePass = true;
|
|
91
|
+
|
|
92
|
+
let [status, errors] = await createSource(
|
|
93
|
+
readFileSync(templatePath, 'utf8'),
|
|
94
|
+
templateData,
|
|
95
|
+
setting,
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
if (status === false) {
|
|
99
|
+
throw Error(errors);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
allEmptyPath.push(returnEmptyPath);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// validate path before empty folder
|
|
106
|
+
for (let emptyPath of allEmptyPath) {
|
|
107
|
+
validatePathWithRootServicePath(localServicePath, emptyPath)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
for (let emptyPath of allEmptyPath) {
|
|
111
|
+
await deleteFileInDir(emptyPath);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
// generate all source
|
|
116
|
+
for (let item of allCreateSource) {
|
|
117
|
+
// throw error if item is invalid
|
|
118
|
+
if (!item || !item.templatePath || !item.templateData || !item.setting) {
|
|
119
|
+
console.log('Throwing invalid source item:', item);
|
|
120
|
+
throw Error('Throwing invalid source item:', item);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const { templatePath, templateData, setting } = item;
|
|
124
|
+
setting.checkCreateSourcePass = false;
|
|
125
|
+
|
|
126
|
+
await createSource(
|
|
127
|
+
readFileSync(templatePath, 'utf8'),
|
|
128
|
+
templateData,
|
|
129
|
+
setting,
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
console.log('Generated all source files successfully');
|
|
134
|
+
return 'return values';
|
|
135
|
+
} catch (error) {
|
|
136
|
+
console.error('Error generating code:', error);
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
module.exports = generateSchema
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
module.exports = {
|
|
21
|
+
TemplateAndData: {
|
|
22
|
+
// ** mock schema config **
|
|
23
|
+
mainAttributeTree: './TemplateData/mainAttributeTree/generateTemplateData.js',
|
|
24
|
+
},
|
|
25
|
+
Plugin: {
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,3 +1,23 @@
|
|
|
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
|
+
|
|
1
21
|
module.exports = {
|
|
2
22
|
TemplateAndData: {
|
|
3
23
|
// ** PerActionEndpoint **
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
|
|
20
|
+
// Import required modules
|
|
21
|
+
const { join } = require('path');
|
|
22
|
+
|
|
23
|
+
const modules = {
|
|
24
|
+
mainAttributeTreeSchema: {}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Generates code with templates for different actions
|
|
28
|
+
* @param {Object} _izContext - Context object
|
|
29
|
+
* @param {string} objSchemaPath - Path to the schema
|
|
30
|
+
* @returns {Array} Array of generated code parameters
|
|
31
|
+
*/
|
|
32
|
+
async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
33
|
+
try {
|
|
34
|
+
const saveFilePath = join(objSchemaPath, '../');
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
// will receive objSchemaPath and prepare params for each data function
|
|
38
|
+
// then data function will return params for createSource
|
|
39
|
+
|
|
40
|
+
// (template, data, { savePath, hookPath, saveFileName, fileExtension, initialData, isAppend = false, checkCreateSourcePass = false })
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
|
|
45
|
+
};
|
|
46
|
+
} catch (error) {
|
|
47
|
+
_izContext.logger.error('Error generating code with template perActionComplete:', error);
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
module.exports = generateCodeWithTemplate;
|
package/src/reStructure/TemplateData/attributeTreeSchema/mainAttributeTreeSchema/attributeLink.ejs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const izara = require("@izara_project/izara-middleware");
|
|
2
|
+
let { pattern } = izara.validatorSchema.stringNotEmpty(); // should not be empty string
|
|
3
|
+
|
|
4
|
+
module.exports = [
|
|
5
|
+
{
|
|
6
|
+
objectType: "<%- objectType %>",
|
|
7
|
+
overWriteHandlers: { // optional, if not set will create default handlers, if empty will not create handler and main function
|
|
8
|
+
//(<overWriteHandlers<%- objectType %>>)
|
|
9
|
+
//(</overWriteHandlers<%- objectType %>>)
|
|
10
|
+
},
|
|
11
|
+
overwriteGeneratedMainFunction: [
|
|
12
|
+
//(<overwriteGeneratedMainFunction<%- objectType %>>)
|
|
13
|
+
//(</overwriteGeneratedMainFunction<%- objectType %>>)
|
|
14
|
+
],
|
|
15
|
+
canDelete: true,
|
|
16
|
+
storageResources: <%- storageResources %>,
|
|
17
|
+
fieldNames: <%- fieldNames %>,
|
|
18
|
+
compositeKeyDeliminator: "<%- compositeKeyDeliminator %>",
|
|
19
|
+
identifiers: <%- identifiers %>
|
|
20
|
+
}
|
|
21
|
+
]
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
const path = require('path');
|
|
20
|
+
const fs = require('fs');
|
|
21
|
+
|
|
22
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../MainLibs/src/Utils");
|
|
23
|
+
const { SOURCE_PATH, ADD_ON_DATA_STRUCTURE_TYPE, ATTRIBUTE_TAG, fieldNameSetting, FIELD_NAME_TPYE, SAVE_FILE_NAME } = require('../../libs/Consts');
|
|
24
|
+
const templatePath = path.join(__dirname, "./template.ejs");
|
|
25
|
+
|
|
26
|
+
function data(_izContext, objectSchema, srcPath) {
|
|
27
|
+
const createSources = [];
|
|
28
|
+
let attributeTreeObjSchemas = [];
|
|
29
|
+
if (objectSchema.hasOwnProperty("addOnDataStructure")) {
|
|
30
|
+
for (const versionedData of objectSchema.addOnDataStructure) {
|
|
31
|
+
if (versionedData.type === ADD_ON_DATA_STRUCTURE_TYPE.attributeTree) {
|
|
32
|
+
const objectType = objectSchema.objectType; // main objectType
|
|
33
|
+
const storageResources = objectSchema.storageResources // storageResource from main objectType
|
|
34
|
+
const storageResourceTag = Object.keys(storageResources) // storage ResourceTag from main objectType
|
|
35
|
+
const compositeKeyDeliminator = objectSchema.compositeKeyDeliminator
|
|
36
|
+
attributeTreeObjSchemas.push(
|
|
37
|
+
{
|
|
38
|
+
objectType: objectType + ATTRIBUTE_TAG.attributeTagLabel,
|
|
39
|
+
fieldNames: {
|
|
40
|
+
labelId: fieldNameSetting(FIELD_NAME_TPYE.identifiers)
|
|
41
|
+
},
|
|
42
|
+
identifiers: [
|
|
43
|
+
{
|
|
44
|
+
type: "identifier",
|
|
45
|
+
fieldName: "labelId"
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
objectType: objectType + ATTRIBUTE_TAG.attributeTagLink,
|
|
51
|
+
fieldNames: {
|
|
52
|
+
[objectType + ATTRIBUTE_TAG.attributeTagLink + "Id"]: fieldNameSetting(FIELD_NAME_TPYE.identifiers),
|
|
53
|
+
[objectType + "Id"]: fieldNameSetting(FIELD_NAME_TPYE.requiredOnCreateFieldName),
|
|
54
|
+
topLevelParentIdentifierProperties: fieldNameSetting(FIELD_NAME_TPYE.requiredOnCreateFieldName),
|
|
55
|
+
parentNodeIdentifierLabel: fieldNameSetting(FIELD_NAME_TPYE.requiredOnCreateFieldName),
|
|
56
|
+
parentNodeIdentifierProperties: fieldNameSetting(FIELD_NAME_TPYE.requiredOnCreateFieldName),
|
|
57
|
+
},
|
|
58
|
+
identifiers: [
|
|
59
|
+
{
|
|
60
|
+
type: "identifier",
|
|
61
|
+
fieldName: `${objectType + ATTRIBUTE_TAG.attributeTagLink}Id`
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
objectType: objectType + ATTRIBUTE_TAG.attributeTagProperty,
|
|
67
|
+
fieldNames: {
|
|
68
|
+
propertyId: fieldNameSetting(FIELD_NAME_TPYE.identifiers),
|
|
69
|
+
propertyLabelId: fieldNameSetting(FIELD_NAME_TPYE.optionalOnCreate)
|
|
70
|
+
},
|
|
71
|
+
identifiers: [
|
|
72
|
+
{
|
|
73
|
+
type: "identifier",
|
|
74
|
+
fieldName: "propertyId"
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
objectType: objectType + ATTRIBUTE_TAG.attributeTagPropertyLabel,
|
|
80
|
+
fieldNames: {
|
|
81
|
+
propertyLabelId: fieldNameSetting(FIELD_NAME_TPYE.identifiers)
|
|
82
|
+
},
|
|
83
|
+
identifiers: [
|
|
84
|
+
{
|
|
85
|
+
type: "identifier",
|
|
86
|
+
fieldName: "propertyLabelId"
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
for (let attributeTreeObjSchema of attributeTreeObjSchemas) {
|
|
92
|
+
Object.assign(attributeTreeObjSchema, {
|
|
93
|
+
storageResources: storageResources, // add storageResources
|
|
94
|
+
compositeKeyDeliminator: compositeKeyDeliminator
|
|
95
|
+
})
|
|
96
|
+
for (let attributeTreeFieldName of Object.values(attributeTreeObjSchema.fieldNames)) {
|
|
97
|
+
Object.assign(attributeTreeFieldName, { storageResourceTags: storageResourceTag }) // add storageResourceTags for each fieldName
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
// console.log("attributeTreeObjSchemas", attributeTreeObjSchemas)
|
|
104
|
+
for (const attributeTreeObjSchema of attributeTreeObjSchemas) {
|
|
105
|
+
createSources.push({
|
|
106
|
+
templatePath: templatePath,
|
|
107
|
+
templateData: {
|
|
108
|
+
fieldNames: JSON.stringify(attributeTreeObjSchema.fieldNames),
|
|
109
|
+
identifiers: JSON.stringify(attributeTreeObjSchema.identifiers),
|
|
110
|
+
objectType: attributeTreeObjSchema.objectType,
|
|
111
|
+
storageResources: JSON.stringify(attributeTreeObjSchema.storageResources),
|
|
112
|
+
compositeKeyDeliminator: attributeTreeObjSchema.compositeKeyDeliminator
|
|
113
|
+
},
|
|
114
|
+
setting: {
|
|
115
|
+
savePath: path.join(srcPath, SOURCE_PATH.generatedAttributeTree, attributeTreeObjSchema.objectType + "/"),
|
|
116
|
+
hookPath: path.join(srcPath, "schemaHook", attributeTreeObjSchema.objectType, "/"),
|
|
117
|
+
saveFileName: SAVE_FILE_NAME.attributeTreeObjectSchema,
|
|
118
|
+
fileExtension: ".js",
|
|
119
|
+
isAppend: false
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
console.log("createSources", createSources)
|
|
125
|
+
return createSources;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
module.exports = data
|
|
@@ -76,7 +76,7 @@ const createExternalSnsSubscriptions = async (_izContext, allObjSchemas, allRelS
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
console.log("snsServiceConfigArray::", snsServiceConfigArray)
|
|
79
|
+
// console.log("snsServiceConfigArray::", snsServiceConfigArray)
|
|
80
80
|
|
|
81
81
|
return {
|
|
82
82
|
templatePath: templatePath,
|
|
@@ -37,7 +37,8 @@ const {
|
|
|
37
37
|
externalResourceSns,
|
|
38
38
|
externalResourceName,
|
|
39
39
|
DYNAMO_RESOURCE,
|
|
40
|
-
LAMBDA_RESOURCE
|
|
40
|
+
LAMBDA_RESOURCE,
|
|
41
|
+
SOURCE_GENERATE_IAM_ROLE
|
|
41
42
|
} = require('../../../../../../../MainLibs/src/Consts');
|
|
42
43
|
|
|
43
44
|
/**
|
|
@@ -105,6 +106,7 @@ function createSourceParams(_izContext, srcPath) {
|
|
|
105
106
|
resourceLocation: SOURCE_PATH.resourceLocationWebSocket,
|
|
106
107
|
additionalResourcePermission,
|
|
107
108
|
functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
|
|
109
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaUploadS3Role
|
|
108
110
|
},
|
|
109
111
|
setting: {
|
|
110
112
|
saveFileName: upperCase(SAVE_FILE_NAME.flowSchema),
|
|
@@ -9,20 +9,7 @@
|
|
|
9
9
|
filterPatterns: #**** need to update serverless framwork upper v.2.69.1
|
|
10
10
|
- body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>"]}}} # functionName of callingFlow
|
|
11
11
|
- body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
|
|
12
|
-
|
|
13
|
-
<%_ additionalResourcePermission.forEach(resourcePermission => { _%>
|
|
14
|
-
- Effect: <%- resourcePermission.effect %>
|
|
15
|
-
Action:
|
|
16
|
-
<%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
|
|
17
|
-
<%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
|
|
18
|
-
- <%- resourcePerAction %>:<%- permission %>
|
|
19
|
-
<%_ }) _%>
|
|
20
|
-
<%_ }) _%>
|
|
21
|
-
Resource:
|
|
22
|
-
<%_ resourcePermission.resource.forEach(resource => { _%>
|
|
23
|
-
- "<%- resource %>"
|
|
24
|
-
<%_ }) _%>
|
|
25
|
-
<%_}) _%>
|
|
12
|
+
role: <%- roleName %>Role
|
|
26
13
|
#<#<%- functionName %><%- handlerType %>IamRole#>
|
|
27
14
|
#<#/<%- functionName %><%- handlerType %>IamRole#>
|
|
28
15
|
<%_ function firstLetterUpperCase(text){
|
package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/functionYaml/data.js
CHANGED
|
@@ -31,7 +31,8 @@ const {
|
|
|
31
31
|
SAVE_FILE_NAME,
|
|
32
32
|
FUNCTION_NAME,
|
|
33
33
|
shortNameHandler,
|
|
34
|
-
externalResourceYaml
|
|
34
|
+
externalResourceYaml,
|
|
35
|
+
SOURCE_GENERATE_IAM_ROLE
|
|
35
36
|
} = require('../../../../../../../MainLibs/src/Consts');
|
|
36
37
|
|
|
37
38
|
const templatePath = path.join(__dirname, "template.ejs");
|
|
@@ -126,7 +127,8 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
126
127
|
handlerType,
|
|
127
128
|
additionalResourcePermission,
|
|
128
129
|
route,
|
|
129
|
-
functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType))
|
|
130
|
+
functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
|
|
131
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaUploadS3Role
|
|
130
132
|
},
|
|
131
133
|
setting: {
|
|
132
134
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -13,20 +13,7 @@
|
|
|
13
13
|
route: <%- route %>
|
|
14
14
|
# authorizer: ${self:custom.iz_authorizerAppLevel}
|
|
15
15
|
# identifierResource: 'route.request.header.Auth'
|
|
16
|
-
|
|
17
|
-
<%_ additionalResourcePermission.forEach(resourcePermission => { _%>
|
|
18
|
-
- Effect: <%- resourcePermission.effect %>
|
|
19
|
-
Action:
|
|
20
|
-
<%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
|
|
21
|
-
<%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
|
|
22
|
-
- <%- resourcePerAction %>:<%- permission %>
|
|
23
|
-
<%_}) _%>
|
|
24
|
-
<%_ }) _%>
|
|
25
|
-
Resource:
|
|
26
|
-
<%_ resourcePermission.resource.forEach(resource => { _%>
|
|
27
|
-
- <%- resource %>
|
|
28
|
-
<%_ }) _%>
|
|
29
|
-
<%_}) _%>
|
|
16
|
+
role: <%- roleName %>Role
|
|
30
17
|
#<#<%- functionName %><%- handlerType %>IamRole#>
|
|
31
18
|
#<#/<%- functionName %><%- handlerType %>IamRole#>
|
|
32
19
|
<%_ function firstLetterUpperCase(text){
|
|
@@ -35,7 +35,8 @@ const {
|
|
|
35
35
|
shortNameHandler,
|
|
36
36
|
defaultIamRolePerAction,
|
|
37
37
|
DYNAMO_RESOURCE,
|
|
38
|
-
SHORT_FUNCTION_NAME
|
|
38
|
+
SHORT_FUNCTION_NAME,
|
|
39
|
+
SOURCE_GENERATE_IAM_ROLE
|
|
39
40
|
} = require('../../../../../../../MainLibs/src/Consts');
|
|
40
41
|
|
|
41
42
|
|
|
@@ -102,6 +103,7 @@ function createSourceParams(_izContext, srcPath) {
|
|
|
102
103
|
handlerType: handlerType,
|
|
103
104
|
additionalResourcePermission: additionalResourcePermission,
|
|
104
105
|
functionNameConfig: upperCase(SHORT_FUNCTION_NAME.createObjectS3Complete) + upperCase(shortNameHandler(handlerType)),
|
|
106
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaUploadS3Role
|
|
105
107
|
},
|
|
106
108
|
setting: {
|
|
107
109
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -9,20 +9,7 @@
|
|
|
9
9
|
filterPatterns: #**** need to update serverless framwork upper v.2.69.1
|
|
10
10
|
- body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%- functionName %>"]}}} # functionName of callingFlow
|
|
11
11
|
- body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
|
|
12
|
-
|
|
13
|
-
<%_ additionalResourcePermission.forEach(resourcePermission => { _%>
|
|
14
|
-
- Effect: <%- resourcePermission.effect %>
|
|
15
|
-
Action:
|
|
16
|
-
<%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
|
|
17
|
-
<%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
|
|
18
|
-
- <%- resourcePerAction %>:<%- permission %>
|
|
19
|
-
<%_ }) _%>
|
|
20
|
-
<%_ }) _%>
|
|
21
|
-
Resource:
|
|
22
|
-
<%_ resourcePermission.resource.forEach(resource => { _%>
|
|
23
|
-
- "<%- resource %>"
|
|
24
|
-
<%_ }) _%>
|
|
25
|
-
<%_}) _%>
|
|
12
|
+
role: <%- roleName %>Role
|
|
26
13
|
#<#<%- functionName %><%- handlerType %>IamRole#>
|
|
27
14
|
#<#/<%- functionName %><%- handlerType %>IamRole#>
|
|
28
15
|
<%_ function firstLetterUpperCase(text){
|
|
@@ -35,7 +35,8 @@ const {
|
|
|
35
35
|
SAVE_FILE_NAME,
|
|
36
36
|
awaitingMultipleStepsRole,
|
|
37
37
|
externalResourceSns,
|
|
38
|
-
externalResourceName
|
|
38
|
+
externalResourceName,
|
|
39
|
+
SOURCE_GENERATE_IAM_ROLE
|
|
39
40
|
} = require('../../../../../../../../MainLibs/src/Consts');
|
|
40
41
|
|
|
41
42
|
const {
|
|
@@ -89,6 +90,7 @@ function createSourceParams(_izContext, srcPath) {
|
|
|
89
90
|
resourceLocation: SOURCE_PATH.resourceLocationWebSocket,
|
|
90
91
|
additionalResourcePermission,
|
|
91
92
|
functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
|
|
93
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaUploadS3Role
|
|
92
94
|
},
|
|
93
95
|
setting: {
|
|
94
96
|
saveFileName: upperCase(SAVE_FILE_NAME.flowSchema),
|
|
@@ -6,20 +6,7 @@
|
|
|
6
6
|
- sqs:
|
|
7
7
|
arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- functionName %><%- firstLetterUpperCase(handlerType) %>
|
|
8
8
|
batchSize: 10
|
|
9
|
-
|
|
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
|
-
<%_}) _%>
|
|
9
|
+
role: <%- roleName %>Role
|
|
23
10
|
#<#<%- functionName %><%- handlerType %>IamRole#>
|
|
24
11
|
#<#/<%- functionName %><%- handlerType %>IamRole#>
|
|
25
12
|
<%_ function firstLetterUpperCase(text){
|
|
@@ -37,7 +37,8 @@ const {
|
|
|
37
37
|
externalResourceSns,
|
|
38
38
|
externalResourceName,
|
|
39
39
|
DYNAMO_RESOURCE,
|
|
40
|
-
LAMBDA_RESOURCE
|
|
40
|
+
LAMBDA_RESOURCE,
|
|
41
|
+
SOURCE_GENERATE_IAM_ROLE
|
|
41
42
|
} = require('../../../../../../../../MainLibs/src/Consts');
|
|
42
43
|
|
|
43
44
|
const {
|
|
@@ -118,6 +119,7 @@ function createSourceParams(_izContext, srcPath) {
|
|
|
118
119
|
resourceLocation: SOURCE_PATH.resourceLocationWebSocket,
|
|
119
120
|
additionalResourcePermission,
|
|
120
121
|
functionNameConfig: upperCase("ReservedLimitComp") + upperCase(shortNameHandler(handlerType)),
|
|
122
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaUploadS3Role
|
|
121
123
|
},
|
|
122
124
|
setting: {
|
|
123
125
|
saveFileName: upperCase(SAVE_FILE_NAME.flowSchema),
|
|
@@ -9,20 +9,7 @@
|
|
|
9
9
|
filterPatterns: #**** need to update serverless framwork upper v.2.69.1
|
|
10
10
|
- body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>"]}}} # functionName of callingFlow
|
|
11
11
|
- body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
|
|
12
|
-
|
|
13
|
-
<%_ additionalResourcePermission.forEach(resourcePermission => { _%>
|
|
14
|
-
- Effect: <%- resourcePermission.effect %>
|
|
15
|
-
Action:
|
|
16
|
-
<%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
|
|
17
|
-
<%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
|
|
18
|
-
- <%- resourcePerAction %>:<%- permission %>
|
|
19
|
-
<%_ }) _%>
|
|
20
|
-
<%_ }) _%>
|
|
21
|
-
Resource:
|
|
22
|
-
<%_ resourcePermission.resource.forEach(resource => { _%>
|
|
23
|
-
- "<%- resource %>"
|
|
24
|
-
<%_ }) _%>
|
|
25
|
-
<%_}) _%>
|
|
12
|
+
role: <%- roleName %>Role
|
|
26
13
|
#<#<%- functionName %><%- handlerType %>IamRole#>
|
|
27
14
|
#<#/<%- functionName %><%- handlerType %>IamRole#>
|
|
28
15
|
<%_ function firstLetterUpperCase(text){
|
|
@@ -33,7 +33,8 @@ const {
|
|
|
33
33
|
SNS_RESOURCE,
|
|
34
34
|
shortNameHandler,
|
|
35
35
|
FUNCTION_NAME,
|
|
36
|
-
LAMBDA_RESOURCE
|
|
36
|
+
LAMBDA_RESOURCE,
|
|
37
|
+
SOURCE_GENERATE_IAM_ROLE
|
|
37
38
|
} = require('../../../../../../../../MainLibs/src/Consts');
|
|
38
39
|
|
|
39
40
|
const templatePath = path.join(__dirname, "./template.ejs")
|
|
@@ -113,7 +114,8 @@ function createSourceParam(_izContext, flowSchema, srcPath) {
|
|
|
113
114
|
additionalResourcePermission,
|
|
114
115
|
resourceLocation: SOURCE_PATH.resourceLocationWebSocket,
|
|
115
116
|
bucketName,
|
|
116
|
-
functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType))
|
|
117
|
+
functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
|
|
118
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaUploadS3Role
|
|
117
119
|
},
|
|
118
120
|
setting: {
|
|
119
121
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -14,20 +14,7 @@
|
|
|
14
14
|
# - prefix: uploads/
|
|
15
15
|
# - suffix: .csv
|
|
16
16
|
forceDeploy: true
|
|
17
|
-
|
|
18
|
-
<%_ additionalResourcePermission.forEach(resourcePermission => { _%>
|
|
19
|
-
- Effect: <%- resourcePermission.effect %>
|
|
20
|
-
Action:
|
|
21
|
-
<%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
|
|
22
|
-
<%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
|
|
23
|
-
- <%- resourcePerAction %>:<%- permission %>
|
|
24
|
-
<%_}) _%>
|
|
25
|
-
<%_ }) _%>
|
|
26
|
-
Resource:
|
|
27
|
-
<%_ resourcePermission.resource.forEach(resource => { _%>
|
|
28
|
-
- <%- resource %>
|
|
29
|
-
<%_ }) _%>
|
|
30
|
-
<%_}) _%>
|
|
17
|
+
role: <%- roleName %>Role
|
|
31
18
|
#<#<%- functionName %><%- handlerType %>IamRole#>
|
|
32
19
|
#<#/<%- functionName %><%- handlerType %>IamRole#>
|
|
33
20
|
<%_ function firstLetterUpperCase(text){
|
package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js
CHANGED
|
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
18
18
|
'use strict';
|
|
19
19
|
const path = require('path');
|
|
20
20
|
|
|
21
|
-
const { SOURCE_PATH, SAVE_FILE_NAME, defaultIamRolePerAction, createIamRole, RESOURCE_CLASSES, DYNAMO_RESOURCE, resourceNames } = require("../../../../libs/Consts");
|
|
21
|
+
const { SOURCE_PATH, SAVE_FILE_NAME, defaultIamRolePerAction, createIamRole, RESOURCE_CLASSES, DYNAMO_RESOURCE, resourceNames, SOURCE_GENERATE_IAM_ROLE } = require("../../../../libs/Consts");
|
|
22
22
|
const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils');
|
|
23
23
|
|
|
24
24
|
const templatePath = path.join(__dirname, "./template.ejs")
|
|
@@ -60,7 +60,9 @@ function createWebSocketConnectYaml(_izContext, srcPath) {
|
|
|
60
60
|
templateData: {
|
|
61
61
|
functionName,
|
|
62
62
|
resourceLocation: SOURCE_PATH.resourceLocationWebSocket,
|
|
63
|
-
additionalResourcePermission
|
|
63
|
+
additionalResourcePermission,
|
|
64
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaUploadS3Role
|
|
65
|
+
|
|
64
66
|
},
|
|
65
67
|
setting: {
|
|
66
68
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
package/src/reStructure/TemplateData/flowSchema/components/websocket/dynamoDb/ReservedTableData.js
CHANGED
|
@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
19
19
|
const path = require('path');
|
|
20
20
|
const { SOURCE_PATH, SAVE_FILE_NAME } = require('../../../../../../MainLibs/src/Consts');
|
|
21
21
|
|
|
22
|
-
const templatePath = path.join(__dirname, "
|
|
22
|
+
const templatePath = path.join(__dirname, "../../../../resourceYaml/dynamodb/template.ejs")
|
|
23
23
|
|
|
24
24
|
function data(_izContext, srcPath) {
|
|
25
25
|
let resultForCreateSources = [];
|
package/src/reStructure/TemplateData/flowSchema/components/websocket/dynamoDb/WebSocketTaskData.js
CHANGED
|
@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
19
19
|
const path = require('path');
|
|
20
20
|
const { SOURCE_PATH, SAVE_FILE_NAME } = require('../../../../../../MainLibs/src/Consts');
|
|
21
21
|
|
|
22
|
-
const templatePath = path.join(__dirname, "
|
|
22
|
+
const templatePath = path.join(__dirname, "../../../../resourceYaml/dynamodb/template.ejs")
|
|
23
23
|
|
|
24
24
|
function data(_izContext, srcPath) {
|
|
25
25
|
let resultForCreateSources = [];
|
|
@@ -102,6 +102,10 @@ const createSharedResource = (_izContext, createSourceParams, srcPath) => {
|
|
|
102
102
|
handlerType: [],
|
|
103
103
|
resources: []
|
|
104
104
|
},
|
|
105
|
+
[SOURCE_GENERATE_IAM_ROLE.FlowSchemaUploadS3Role]: {
|
|
106
|
+
handlerType: [],
|
|
107
|
+
resources: {}
|
|
108
|
+
},
|
|
105
109
|
Other: []
|
|
106
110
|
};
|
|
107
111
|
const objectTypeList = [];
|
|
@@ -177,6 +181,12 @@ const createSharedResource = (_izContext, createSourceParams, srcPath) => {
|
|
|
177
181
|
templateData.additionalResourcePermission,
|
|
178
182
|
groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.ProcessFindDataRole].resources
|
|
179
183
|
);
|
|
184
|
+
} else if (templateData.roleName.includes(SOURCE_GENERATE_IAM_ROLE.FlowSchemaUploadS3Role)) {
|
|
185
|
+
groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.FlowSchemaUploadS3Role].handlerType.push(templateData);
|
|
186
|
+
processResourcePermissions(
|
|
187
|
+
templateData.additionalResourcePermission,
|
|
188
|
+
groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.FlowSchemaUploadS3Role].resources
|
|
189
|
+
)
|
|
180
190
|
}
|
|
181
191
|
else {
|
|
182
192
|
// Handle other items
|
|
@@ -52,7 +52,7 @@ function data(_izContext, srcPath) {
|
|
|
52
52
|
templatePath: templatePath,
|
|
53
53
|
templateData: createUpdateNodeCompleteQueueName,
|
|
54
54
|
setting: {
|
|
55
|
-
initialData: "
|
|
55
|
+
initialData: "Resources:\n",
|
|
56
56
|
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
57
57
|
saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
|
|
58
58
|
fileExtension: ".yml",
|
|
@@ -0,0 +1,38 @@
|
|
|
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 { join } = require("path");
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
function validatePathWithRootServicePath(rootServicePath, checkPath) {
|
|
24
|
+
if (typeof (checkPath) !== "string"
|
|
25
|
+
|| (typeof (checkPath) === "string" && (
|
|
26
|
+
!checkPath.startsWith(join(rootServicePath, "app"))
|
|
27
|
+
&& !checkPath.startsWith(join(rootServicePath, "resource"))
|
|
28
|
+
&& !checkPath.startsWith(join(rootServicePath, "layer")))
|
|
29
|
+
)
|
|
30
|
+
) {
|
|
31
|
+
throw Error(`invalid path:${checkPath} not contain inside service`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
module.exports = {
|
|
37
|
+
validatePathWithRootServicePath
|
|
38
|
+
}
|