@izara_project/izara-market-library-service-schemas 1.0.20 → 1.0.22
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 +4 -3
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +54 -1
- package/src/TemplateManager/src/FindData/mainFunction/data.js +25 -25
- package/src/TemplateManager/src/GenerateCode.js +5 -5
- package/src/TemplateManager/src/GenerateSchema.js +88 -0
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/data.js +9 -6
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/template.ejs +2 -2
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrDsq/data.js +5 -1
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrDsq/template.ejs +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrInv/data.js +5 -1
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrInv/template.ejs +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrSqs/data.js +3 -1
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrSqs/template.ejs +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/data.js +4 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/data.js +3 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/data.js +3 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/data.js +3 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/data.js +3 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Delete/data.js +3 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/data.js +3 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/data.js +3 -1
- package/src/TemplateManager/src/Role/createSharedResource.js +19 -17
- package/src/TemplateManager/src/attributeTree/objectSchema/data.js +125 -0
- package/src/TemplateManager/src/attributeTree/objectSchema/template.ejs +20 -0
- package/src/TemplateManager/src/attributeTree/refRelationshipSchema/data.js +36 -0
- package/src/TemplateManager/src/attributeTree/refRelationshipSchema/template.ejs +0 -0
- package/src/TemplateManager/src/attributeTree/relationshipSchema/data.js +92 -0
- package/src/TemplateManager/src/attributeTree/relationshipSchema/template.ejs +40 -0
- package/src/TemplateManager/src/externalService/FunctionNameConfig/data.js +104 -23
- package/src/TemplateManager/src/externalService/FunctionNameConfig/templateIntTesting.ejs +5 -5
- package/src/TemplateManager/src/externalService/FunctionNameConfig/templateYaml.ejs +2 -2
- package/src/TemplateManager/src/externalService/LambdaRole/data.js +22 -12
- package/src/TemplateManager/src/externalService/LambdaRole/template.ejs +1 -1
- package/src/TemplateManager/src/libs/Consts.js +97 -7
|
@@ -11,7 +11,9 @@ GNU Affero General Public License for more details.
|
|
|
11
11
|
You should have received a copy of the GNU Affero General Public License
|
|
12
12
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
13
13
|
*/
|
|
14
|
+
|
|
14
15
|
'use strict';
|
|
16
|
+
|
|
15
17
|
const { SOURCE_GENERATE_IAM_ROLE, SOURCE_PATH, SAVE_FILE_NAME } = require('../libs/Consts');
|
|
16
18
|
const { firstLetterUpperCase: upperCase } = require("../../../MainLibs/src/Utils")
|
|
17
19
|
const path = require('path');
|
|
@@ -51,6 +53,7 @@ const processResourcePermissions = (resourcePermissions, targetResources) => {
|
|
|
51
53
|
}
|
|
52
54
|
});
|
|
53
55
|
};
|
|
56
|
+
|
|
54
57
|
/**
|
|
55
58
|
* Check if an item should be skipped based on templateData content
|
|
56
59
|
* @param {Object} templateData - Template data to check
|
|
@@ -61,6 +64,7 @@ const shouldSkipItem = (templateData) => {
|
|
|
61
64
|
Object.keys(templateData).length === 0 ||
|
|
62
65
|
!templateData.additionalResourcePermission;
|
|
63
66
|
};
|
|
67
|
+
|
|
64
68
|
/**
|
|
65
69
|
* Initialize object type structure if it doesn't exist
|
|
66
70
|
* @param {Object} groupedByObjectType - The grouped object
|
|
@@ -107,28 +111,31 @@ module.exports.createSharedResource = (_izContext, createSourceParams, srcPath)
|
|
|
107
111
|
data.map((item) => {
|
|
108
112
|
const templateData = item.templateData;
|
|
109
113
|
if (shouldSkipItem(templateData)) return;
|
|
114
|
+
|
|
115
|
+
// ? Handle items with objectType and roleName
|
|
110
116
|
if (templateData.objectType) {
|
|
117
|
+
const objectType = templateData.roleName ? templateData.roleName : templateData.objectType;
|
|
111
118
|
// Handle items with objectType
|
|
112
|
-
initializeObjectType(groupedByObjectType,
|
|
119
|
+
initializeObjectType(groupedByObjectType, objectType, objectTypeList);
|
|
113
120
|
// Add function name if it doesn't exist
|
|
114
121
|
if (templateData.functionName &&
|
|
115
|
-
!groupedByObjectType[
|
|
116
|
-
groupedByObjectType[
|
|
122
|
+
!groupedByObjectType[objectType].functionNames?.includes(templateData.functionName)) {
|
|
123
|
+
groupedByObjectType[objectType].functionNames.push(templateData.functionName);
|
|
117
124
|
}
|
|
118
125
|
// Add action if it doesn't exist
|
|
119
126
|
if (templateData.action !== null &&
|
|
120
|
-
!groupedByObjectType[
|
|
121
|
-
groupedByObjectType[
|
|
127
|
+
!groupedByObjectType[objectType].actions?.includes(templateData.action)) {
|
|
128
|
+
groupedByObjectType[objectType].actions.push(templateData.action);
|
|
122
129
|
}
|
|
123
130
|
// Process additionalResourcePermission
|
|
124
131
|
processResourcePermissions(
|
|
125
132
|
templateData.additionalResourcePermission,
|
|
126
|
-
groupedByObjectType[
|
|
133
|
+
groupedByObjectType[objectType].resources
|
|
127
134
|
);
|
|
128
135
|
}
|
|
129
136
|
else if (templateData.functionName &&
|
|
130
|
-
(templateData.functionName.includes(
|
|
131
|
-
templateData.functionName.includes(
|
|
137
|
+
(templateData.functionName.includes([SOURCE_GENERATE_IAM_ROLE.ObjectCompleteRole]) ||
|
|
138
|
+
templateData.functionName.includes([SOURCE_GENERATE_IAM_ROLE.NodeCompleteRole]))) {
|
|
132
139
|
// Handle ObjectComplete items
|
|
133
140
|
groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.ObjectCompleteRole].functionNames.push(templateData.functionName);
|
|
134
141
|
groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.ObjectCompleteRole].handlerType.push(templateData.handlerType);
|
|
@@ -165,10 +172,10 @@ module.exports.createSharedResource = (_izContext, createSourceParams, srcPath)
|
|
|
165
172
|
templateData.functionName.includes('FindData') ||
|
|
166
173
|
templateData.functionName.includes('ProcessLogical'))) {
|
|
167
174
|
// Handle ProcessFindData items
|
|
168
|
-
groupedByObjectType.
|
|
175
|
+
groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.ProcessFindDataRole].handlerType.push(templateData.handlerType);
|
|
169
176
|
processResourcePermissions(
|
|
170
177
|
templateData.additionalResourcePermission,
|
|
171
|
-
groupedByObjectType.
|
|
178
|
+
groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.ProcessFindDataRole].resources
|
|
172
179
|
);
|
|
173
180
|
}
|
|
174
181
|
else {
|
|
@@ -199,14 +206,12 @@ module.exports.createSharedResource = (_izContext, createSourceParams, srcPath)
|
|
|
199
206
|
});
|
|
200
207
|
// Prepare results
|
|
201
208
|
|
|
202
|
-
|
|
203
209
|
// Process and prepare data for role definitions and extract any resources
|
|
204
210
|
// that might be related to object types but weren't categorized properly
|
|
205
211
|
const roles = [];
|
|
206
|
-
const otherResources = []
|
|
207
212
|
Object.entries(groupedByObjectType).forEach(([objectType, data]) => {
|
|
208
213
|
if (objectType === 'Other' || !data.resources) return;
|
|
209
|
-
//
|
|
214
|
+
// create policy statements from resources
|
|
210
215
|
const rolePolicyStatement = [];
|
|
211
216
|
Object.entries(data.resources).forEach(([effect, permissionList]) => {
|
|
212
217
|
if (!Array.isArray(permissionList)) {
|
|
@@ -251,14 +256,11 @@ module.exports.createSharedResource = (_izContext, createSourceParams, srcPath)
|
|
|
251
256
|
});
|
|
252
257
|
}
|
|
253
258
|
});
|
|
254
|
-
const reformattedData = {
|
|
255
|
-
roles,
|
|
256
|
-
};
|
|
257
259
|
const sharedResourceTemplatePath = path.join(__dirname, './sharedResourceTemplate.ejs')
|
|
258
260
|
|
|
259
261
|
return {
|
|
260
262
|
templatePath: sharedResourceTemplatePath,
|
|
261
|
-
templateData:
|
|
263
|
+
templateData: { roles },
|
|
262
264
|
setting: {
|
|
263
265
|
initialData: 'Resources:\n',
|
|
264
266
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -0,0 +1,125 @@
|
|
|
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
|
+
// console.log("attributeTreeObjSchemas", attributeTreeObjSchemas)
|
|
103
|
+
for (const attributeTreeObjSchema of attributeTreeObjSchemas) {
|
|
104
|
+
createSources.push({
|
|
105
|
+
templatePath: templatePath,
|
|
106
|
+
templateData: {
|
|
107
|
+
fieldNames: JSON.stringify(attributeTreeObjSchema.fieldNames),
|
|
108
|
+
identifiers: JSON.stringify(attributeTreeObjSchema.identifiers),
|
|
109
|
+
objectType: attributeTreeObjSchema.objectType,
|
|
110
|
+
storageResources: JSON.stringify(attributeTreeObjSchema.storageResources),
|
|
111
|
+
compositeKeyDeliminator: attributeTreeObjSchema.compositeKeyDeliminator
|
|
112
|
+
},
|
|
113
|
+
setting: {
|
|
114
|
+
savePath: path.join(srcPath, SOURCE_PATH.generatedAttributeTree, attributeTreeObjSchema.objectType + "/"),
|
|
115
|
+
saveFileName: SAVE_FILE_NAME.attributeTreeObjectSchema,
|
|
116
|
+
fileExtension: ".js",
|
|
117
|
+
isAppend: false
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
console.log("createSources", createSources)
|
|
122
|
+
return createSources;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
module.exports = data
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
create: [], // default: ['hdrApi', 'hdrSqs']
|
|
9
|
+
update: [], // default: ['hdrApi', 'hdrSqs']
|
|
10
|
+
get: [], // default: ['hdrApi', 'hdrInv']
|
|
11
|
+
delete: [], // default: ['hdrApi', 'hdrSqs']
|
|
12
|
+
},
|
|
13
|
+
overwriteGeneratedMainFunction: ["create","update","get","delete"],
|
|
14
|
+
canDelete: true,
|
|
15
|
+
storageResources: <%- storageResources %>,
|
|
16
|
+
fieldNames: <%- fieldNames %>,
|
|
17
|
+
compositeKeyDeliminator: "<%- compositeKeyDeliminator %>",
|
|
18
|
+
identifiers: <%- identifiers %>
|
|
19
|
+
}
|
|
20
|
+
]
|
|
@@ -0,0 +1,36 @@
|
|
|
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 } = require('../../libs/Consts');
|
|
24
|
+
const templateYamlPath = path.join(__dirname, "./templateYaml.ejs");
|
|
25
|
+
|
|
26
|
+
function data(_izContext, objectSchema, srcPath) {
|
|
27
|
+
let attributeTrees = [];
|
|
28
|
+
let objectType = objectSchema.objectType;
|
|
29
|
+
if (objectSchema.hasOwnProperty("addOnDataStructure")) {
|
|
30
|
+
if (objectSchema.addOnDataStructure === ADD_ON_DATA_STRUCTURE_TYPE.attributeTree) {
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
module.exports = data
|
|
File without changes
|
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
const yaml = require("yaml")
|
|
22
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../MainLibs/src/Utils");
|
|
23
|
+
const { SOURCE_PATH, ADD_ON_DATA_STRUCTURE_TYPE, SAVE_FILE_NAME, PREFIX_RELATIONSHIP, ATTRIBUTE_TAG } = require('../../libs/Consts');
|
|
24
|
+
const { createLinksObjectRelationshipAttributeTree } = require("../../../../GenerateCodeLibs/src/GenerateCodeLibs")
|
|
25
|
+
const templatePath = path.join(__dirname, "./template.ejs");
|
|
26
|
+
|
|
27
|
+
function data(_izContext, objectSchema, srcPath) {
|
|
28
|
+
const createSources = [];
|
|
29
|
+
let attributeTreeObjRelationshipSchemas = [];
|
|
30
|
+
if (objectSchema.hasOwnProperty("addOnDataStructure")) {
|
|
31
|
+
for (const versionedData of objectSchema.addOnDataStructure)
|
|
32
|
+
if (versionedData.type === ADD_ON_DATA_STRUCTURE_TYPE.attributeTree) {
|
|
33
|
+
const objectType = objectSchema.objectType; // main objectType
|
|
34
|
+
const storageResources = objectSchema.storageResources // storageResource from main objectType
|
|
35
|
+
const storageResourceTags = Object.keys(storageResources)
|
|
36
|
+
const configPath = path.join(__dirname, '../../../config/serverless.config.yml');
|
|
37
|
+
const serverlessConfig = fs.readFileSync(configPath, 'utf8');
|
|
38
|
+
const config = yaml.parse(serverlessConfig);
|
|
39
|
+
|
|
40
|
+
attributeTreeObjRelationshipSchemas.push(
|
|
41
|
+
{
|
|
42
|
+
relationshipTag: PREFIX_RELATIONSHIP.is + upperCase(objectType),
|
|
43
|
+
links: [
|
|
44
|
+
createLinksObjectRelationshipAttributeTree(
|
|
45
|
+
{
|
|
46
|
+
serviceTag: config.main_config.iz_serviceTag,
|
|
47
|
+
objectType: objectType
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
serviceTag: config.main_config.iz_serviceTag,
|
|
51
|
+
objectType: objectType + ATTRIBUTE_TAG.attributeTagLink
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
for (const attributeTreeObjRelationshipSchema of attributeTreeObjRelationshipSchemas) {
|
|
61
|
+
Object.assign(attributeTreeObjRelationshipSchema, { storageResources: storageResources })
|
|
62
|
+
attributeTreeObjRelationshipSchema.links.push({ storageResourceTags })
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
// console.log("attributeTreeObjSchemas", attributeTreeObjSchemas)
|
|
67
|
+
for (const attributeTreeObjRelationshipSchema of attributeTreeObjRelationshipSchemas) {
|
|
68
|
+
createSources.push({
|
|
69
|
+
templatePath: templatePath,
|
|
70
|
+
templateData: {
|
|
71
|
+
baseObjectType: attributeTreeObjRelationshipSchema.baseObjectType,
|
|
72
|
+
toObjectType: attributeTreeObjRelationshipSchema.toObjectType,
|
|
73
|
+
storageResources: JSON.stringify(attributeTreeObjRelationshipSchema.storageResources),
|
|
74
|
+
sotrageResourceTag: storageResourceTags,
|
|
75
|
+
relationshipTag: attributeTreeObjRelationshipSchema.relationshipTag,
|
|
76
|
+
serviceTag: attributeTreeObjRelationshipSchema.links[0]
|
|
77
|
+
},
|
|
78
|
+
setting: {
|
|
79
|
+
savePath: path.join(srcPath, SOURCE_PATH.generatedAttributeTree),
|
|
80
|
+
saveFileName: SAVE_FILE_NAME.attributeTreeObjectRelationship,
|
|
81
|
+
fileExtension: ".js",
|
|
82
|
+
isAppend: false
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
console.log("createSources", createSources)
|
|
89
|
+
return createSources;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
module.exports = data
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module.exports = [
|
|
2
|
+
{
|
|
3
|
+
"<%- relationshipTag %>": { // relationshipTag - name of relationship type stored in graph
|
|
4
|
+
fieldNames: {
|
|
5
|
+
"originTimestamp": {
|
|
6
|
+
"type": "number",
|
|
7
|
+
"requiredOnCreate": true,
|
|
8
|
+
"canUpdate": true,
|
|
9
|
+
"validation": {
|
|
10
|
+
|
|
11
|
+
},
|
|
12
|
+
"optionalOnCreate": false
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
storageResources: <%- storageResources %>,
|
|
16
|
+
links: [
|
|
17
|
+
{
|
|
18
|
+
storageResourceTags: <%- storageResourceTags %>,
|
|
19
|
+
from: {
|
|
20
|
+
objType: {
|
|
21
|
+
serviceTag: "GCTpBas",
|
|
22
|
+
objectType: "<%- baseObjectType %>"
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
linkType: "one", // one | many
|
|
26
|
+
},
|
|
27
|
+
to: {
|
|
28
|
+
objType: {
|
|
29
|
+
serviceTag: "GCTpBas",
|
|
30
|
+
objectType: "<%- toObjectType %>"
|
|
31
|
+
},
|
|
32
|
+
requiredOnCreate: true,
|
|
33
|
+
linkType: "many", // one | many
|
|
34
|
+
handler: true // if set true, serviceTag of objTyp will handle link logic eg. translateIds
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
]
|
|
@@ -23,61 +23,142 @@ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = req
|
|
|
23
23
|
const { SOURCE_PATH } = require('../../libs/Consts');
|
|
24
24
|
const templateYamlPath = path.join(__dirname, "./templateYaml.ejs");
|
|
25
25
|
const templatePathIntTestPath = path.join(__dirname, "./templateIntTesting.ejs");
|
|
26
|
+
const { SOURCE_GENERATE_IAM_ROLE } = require("../../libs/Consts");
|
|
26
27
|
|
|
27
28
|
|
|
28
29
|
function data(_izContext, createSourceParams, srcPath) {
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
let
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
// ! old code
|
|
31
|
+
// function createFunctionNameConfigFileYaml(functionNameConfigs, srcPath) {
|
|
32
|
+
// let createFunctionNameConfigYaml = []
|
|
33
|
+
// createFunctionNameConfigYaml.push(
|
|
34
|
+
// {
|
|
35
|
+
// templatePath: templateYamlPath,
|
|
36
|
+
// templateData: {
|
|
37
|
+
// functionNameConfigs: functionNameConfigs
|
|
38
|
+
// },
|
|
39
|
+
// setting: {
|
|
40
|
+
// savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
41
|
+
// saveFileName: "FunctionNameConfig",
|
|
42
|
+
// fileExtension: ".yml",
|
|
43
|
+
// isAppend: true
|
|
44
|
+
// }
|
|
45
|
+
// }
|
|
46
|
+
// )
|
|
47
|
+
// return createFunctionNameConfigYaml
|
|
48
|
+
// }
|
|
49
|
+
|
|
50
|
+
// Extract role names from object types in createSourceParams
|
|
51
|
+
const roleNameConfigs = new Set();
|
|
52
|
+
const roleNameConcatConfigs = new Set();
|
|
53
|
+
|
|
54
|
+
// Add default IAM roles from configuration
|
|
55
|
+
Object.entries(SOURCE_GENERATE_IAM_ROLE)
|
|
56
|
+
.filter(([_, enabled]) => enabled)
|
|
57
|
+
.forEach(([_, value]) => {
|
|
58
|
+
roleNameConfigs.add(`${upperCase(value)}Role`);
|
|
59
|
+
roleNameConcatConfigs.add(`${upperCase(value)}`);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Extract role names from templateData in createSourceParams
|
|
63
|
+
createSourceParams.forEach(({ templateData }) => {
|
|
64
|
+
if (templateData) {
|
|
65
|
+
const sourceName = templateData.roleName || templateData.objectType;
|
|
66
|
+
if (sourceName) {
|
|
67
|
+
const upperCasedName = upperCase(sourceName);
|
|
68
|
+
roleNameConfigs.add(`${upperCasedName}Role`);
|
|
69
|
+
roleNameConcatConfigs.add(upperCasedName);
|
|
70
|
+
}
|
|
35
71
|
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
let createFunctionNameConfigJs = createFunctionNameConfigFileJs(functionNameConfigs, srcPath);
|
|
39
|
-
createFunctionNameConfig.push(...createFunctionNameConfigYaml, ...createFunctionNameConfigJs)
|
|
40
|
-
return createFunctionNameConfig
|
|
72
|
+
});
|
|
73
|
+
|
|
41
74
|
|
|
75
|
+
// Generate YAML and JS configurations
|
|
76
|
+
const roleConfigYaml = createRoleNameConfigFileYaml(roleNameConfigs, srcPath);
|
|
77
|
+
const roleConfigJs = createRoleNameConfigFileJs(roleNameConcatConfigs, srcPath);
|
|
78
|
+
|
|
79
|
+
// Combine and return all configurations
|
|
80
|
+
return [...roleConfigYaml, ...roleConfigJs];
|
|
42
81
|
}
|
|
43
82
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
83
|
+
|
|
84
|
+
// ! old code
|
|
85
|
+
// function createFunctionNameConfigFileYaml(functionNameConfigs, srcPath) {
|
|
86
|
+
// let createFunctionNameConfigYaml = []
|
|
87
|
+
// createFunctionNameConfigYaml.push(
|
|
88
|
+
// {
|
|
89
|
+
// templatePath: templateYamlPath,
|
|
90
|
+
// templateData: {
|
|
91
|
+
// functionNameConfigs: functionNameConfigs
|
|
92
|
+
// },
|
|
93
|
+
// setting: {
|
|
94
|
+
// savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
95
|
+
// saveFileName: "FunctionNameConfig",
|
|
96
|
+
// fileExtension: ".yml",
|
|
97
|
+
// isAppend: true
|
|
98
|
+
// }
|
|
99
|
+
// }
|
|
100
|
+
// )
|
|
101
|
+
// return createFunctionNameConfigYaml
|
|
102
|
+
// }
|
|
103
|
+
|
|
104
|
+
// ! old code
|
|
105
|
+
// function createFunctionNameConfigFileJs(functionNameConfigs, srcPath) {
|
|
106
|
+
// let createFunctionNameConfigJs = []
|
|
107
|
+
// createFunctionNameConfigJs.push(
|
|
108
|
+
// {
|
|
109
|
+
// templatePath: templatePathIntTestPath,
|
|
110
|
+
// templateData: {
|
|
111
|
+
// functionNameConfigs: functionNameConfigs
|
|
112
|
+
// },
|
|
113
|
+
// setting: {
|
|
114
|
+
// savePath: path.join(srcPath, SOURCE_PATH.externalService),
|
|
115
|
+
// saveFileName: "FunctionNameConfig",
|
|
116
|
+
// fileExtension: ".js",
|
|
117
|
+
// isAppend: true
|
|
118
|
+
// }
|
|
119
|
+
// }
|
|
120
|
+
// )
|
|
121
|
+
|
|
122
|
+
// return createFunctionNameConfigJs
|
|
123
|
+
// }
|
|
124
|
+
|
|
125
|
+
function createRoleNameConfigFileYaml(roleNameConfigs, srcPath) {
|
|
126
|
+
let createRoleNameConfigYaml = []
|
|
127
|
+
createRoleNameConfigYaml.push(
|
|
47
128
|
{
|
|
48
129
|
templatePath: templateYamlPath,
|
|
49
130
|
templateData: {
|
|
50
|
-
|
|
131
|
+
roleNameConfigs: roleNameConfigs
|
|
51
132
|
},
|
|
52
133
|
setting: {
|
|
53
134
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
54
|
-
saveFileName: "
|
|
135
|
+
saveFileName: "RoleNameConfig",
|
|
55
136
|
fileExtension: ".yml",
|
|
56
137
|
isAppend: true
|
|
57
138
|
}
|
|
58
139
|
}
|
|
59
140
|
)
|
|
60
|
-
return
|
|
141
|
+
return createRoleNameConfigYaml
|
|
61
142
|
}
|
|
62
143
|
|
|
63
|
-
function
|
|
64
|
-
let
|
|
65
|
-
|
|
144
|
+
function createRoleNameConfigFileJs(roleNameConfigs, srcPath) {
|
|
145
|
+
let createRoleNameConfigJs = []
|
|
146
|
+
createRoleNameConfigJs.push(
|
|
66
147
|
{
|
|
67
148
|
templatePath: templatePathIntTestPath,
|
|
68
149
|
templateData: {
|
|
69
|
-
|
|
150
|
+
roleNameConfigs: roleNameConfigs
|
|
70
151
|
},
|
|
71
152
|
setting: {
|
|
72
153
|
savePath: path.join(srcPath, SOURCE_PATH.externalService),
|
|
73
|
-
saveFileName: "
|
|
154
|
+
saveFileName: "RoleNameConfig",
|
|
74
155
|
fileExtension: ".js",
|
|
75
156
|
isAppend: true
|
|
76
157
|
}
|
|
77
158
|
}
|
|
78
159
|
)
|
|
79
160
|
|
|
80
|
-
return
|
|
161
|
+
return createRoleNameConfigJs
|
|
81
162
|
}
|
|
82
163
|
|
|
83
164
|
module.exports = data;
|
|
@@ -17,13 +17,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
17
17
|
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
20
|
-
module.exports.
|
|
21
|
-
let
|
|
22
|
-
|
|
23
|
-
"<%- firstLetterUpperCase(
|
|
20
|
+
module.exports.generatedIntTestRoleNameConfig = () => {
|
|
21
|
+
let roleNameConfigIntTest = [
|
|
22
|
+
<% roleNameConfigs.forEach(roleNameConfig => { _%>
|
|
23
|
+
"<%- firstLetterUpperCase(roleNameConfig) %>",
|
|
24
24
|
<% }) _%>
|
|
25
25
|
]
|
|
26
|
-
return
|
|
26
|
+
return roleNameConfigIntTest
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
<%_function firstLetterUpperCase(text) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# for createIamRole
|
|
2
2
|
|
|
3
|
-
<%
|
|
4
|
-
-
|
|
3
|
+
<% roleNameConfigs.forEach(roleNameConfig => { _%>
|
|
4
|
+
- arn:aws:iam::${self:custom.iz_accountId}:role/${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(roleNameConfig) %>
|
|
5
5
|
<% }) _%>
|
|
6
6
|
|
|
7
7
|
|