@izara_project/izara-market-library-service-schemas 1.0.21 → 1.0.23
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 +8 -7
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +97 -1
- package/src/SourceManager/src/CreateSource.js +11 -1
- package/src/TemplateManager/src/FindData/mainFunction/data.js +28 -27
- package/src/TemplateManager/src/GenerateCode.js +6 -5
- package/src/TemplateManager/src/GenerateSchema.js +103 -0
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/data.js +9 -6
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/template.ejs +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrDsq/data.js +5 -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/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 +17 -14
- package/src/TemplateManager/src/attributeTree/objectSchema/data.js +128 -0
- package/src/TemplateManager/src/attributeTree/objectSchema/template.ejs +21 -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 +206 -0
- package/src/TemplateManager/src/attributeTree/relationshipSchema/template.ejs +7 -0
- package/src/TemplateManager/src/externalService/FunctionNameConfig/data.js +11 -6
- package/src/TemplateManager/src/externalService/LambdaRole/data.js +2 -2
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/data.js +1 -1
- package/src/TemplateManager/src/libs/Consts.js +92 -2
- package/src/TemplateManager/src/reStructureExample/TemplateConfig.js +7 -3
- package/src/TemplateManager/src/reStructureExample/TemplateData/perAction/generatePerAction.js +9 -2
|
@@ -44,13 +44,16 @@ async function data(_izContext, objectSchema, srcPath) {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
async function createParamForCreateSource(_izContext, objectSchema, action, srcPath) {
|
|
47
|
+
// let objectType = objectSchema.objectType;
|
|
47
48
|
let objectType = objectSchema.objectType;
|
|
49
|
+
let groupBy = objectSchema?.shortNameObjectType ? objectSchema.shortNameObjectType : objectSchema.objectType;
|
|
48
50
|
let functionName = objectType + upperCase(action);
|
|
49
51
|
return {
|
|
50
52
|
templatePath: templatePath,
|
|
51
53
|
templateData: {
|
|
52
54
|
functionName: functionName,
|
|
53
55
|
objectType: objectType,
|
|
56
|
+
roleName: groupBy,
|
|
54
57
|
action: action
|
|
55
58
|
},
|
|
56
59
|
setting: {
|
|
@@ -38,7 +38,9 @@ async function data(_izContext, objectSchema, srcPath) {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
async function createMainFunctionUpdateEndpoint(_izContext, objectSchema, action, srcPath) {
|
|
41
|
-
let objectType = objectSchema.objectType
|
|
41
|
+
// let objectType = objectSchema.objectType
|
|
42
|
+
let objectType = objectSchema?.shortNameObjectType ? objectSchema.shortNameObjectType : objectSchema.objectType
|
|
43
|
+
|
|
42
44
|
let actionHandler = action;
|
|
43
45
|
let functionName = (objectType) + upperCase(actionHandler);
|
|
44
46
|
return {
|
|
@@ -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);
|
|
@@ -202,10 +209,9 @@ module.exports.createSharedResource = (_izContext, createSourceParams, srcPath)
|
|
|
202
209
|
// Process and prepare data for role definitions and extract any resources
|
|
203
210
|
// that might be related to object types but weren't categorized properly
|
|
204
211
|
const roles = [];
|
|
205
|
-
const otherResources = []
|
|
206
212
|
Object.entries(groupedByObjectType).forEach(([objectType, data]) => {
|
|
207
213
|
if (objectType === 'Other' || !data.resources) return;
|
|
208
|
-
//
|
|
214
|
+
// create policy statements from resources
|
|
209
215
|
const rolePolicyStatement = [];
|
|
210
216
|
Object.entries(data.resources).forEach(([effect, permissionList]) => {
|
|
211
217
|
if (!Array.isArray(permissionList)) {
|
|
@@ -250,14 +256,11 @@ module.exports.createSharedResource = (_izContext, createSourceParams, srcPath)
|
|
|
250
256
|
});
|
|
251
257
|
}
|
|
252
258
|
});
|
|
253
|
-
const reformattedData = {
|
|
254
|
-
roles,
|
|
255
|
-
};
|
|
256
259
|
const sharedResourceTemplatePath = path.join(__dirname, './sharedResourceTemplate.ejs')
|
|
257
260
|
|
|
258
261
|
return {
|
|
259
262
|
templatePath: sharedResourceTemplatePath,
|
|
260
|
-
templateData:
|
|
263
|
+
templateData: { roles },
|
|
261
264
|
setting: {
|
|
262
265
|
initialData: 'Resources:\n',
|
|
263
266
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -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
|
|
@@ -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,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,206 @@
|
|
|
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 { createBasicRelationshipsProperties } = require("../../../../GenerateCodeLibs/src/GenerateCodeLibs")
|
|
25
|
+
const templatePath = path.join(__dirname, "./template.ejs");
|
|
26
|
+
|
|
27
|
+
function data(_izContext, objectSchema, srcPath) {
|
|
28
|
+
if (objectSchema.hasOwnProperty("addOnDataStructure")) {
|
|
29
|
+
for (const versionedData of objectSchema.addOnDataStructure) {
|
|
30
|
+
if (versionedData.type === ADD_ON_DATA_STRUCTURE_TYPE.attributeTree) {
|
|
31
|
+
let generateRelationships = createSourceParams(_izContext, objectSchema, srcPath)
|
|
32
|
+
console.log("generateRelationship", generateRelationships)
|
|
33
|
+
return {
|
|
34
|
+
templatePath: templatePath,
|
|
35
|
+
templateData: { datas: generateRelationships },
|
|
36
|
+
setting: {
|
|
37
|
+
savePath: path.join(srcPath, SOURCE_PATH.generatedAttributeTree),
|
|
38
|
+
saveFileName: SAVE_FILE_NAME.attributeTreeObjectRelationship,
|
|
39
|
+
fileExtension: ".js",
|
|
40
|
+
isAppend: false
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
function createSourceParams(_izContext, objectSchema, srcPath) {
|
|
50
|
+
const attributeRelationships = [];
|
|
51
|
+
const objectType = objectSchema.objectType; // main objectType
|
|
52
|
+
const storageResources = objectSchema.storageResources // storageResource from main objectType
|
|
53
|
+
const configPath = path.join(srcPath, '../../config/serverless.config.yml');
|
|
54
|
+
const serverlessConfig = fs.readFileSync(configPath, 'utf8');
|
|
55
|
+
const config = yaml.parse(serverlessConfig);
|
|
56
|
+
const serviceTag = config.main_config.iz_serviceTag;
|
|
57
|
+
|
|
58
|
+
const fieldNamesBasicRelationship = {
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
attributeRelationships.push(
|
|
62
|
+
{
|
|
63
|
+
relationshipTag: PREFIX_RELATIONSHIP.is + upperCase(objectType), // isProductAttribute
|
|
64
|
+
relationshipProperties: createBasicRelationshipsProperties(
|
|
65
|
+
{
|
|
66
|
+
serviceTag: serviceTag,
|
|
67
|
+
objectType: objectType + ATTRIBUTE_TAG.attributeTagLink,
|
|
68
|
+
linkType: "many",
|
|
69
|
+
requiredOnCreate: false
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
serviceTag: serviceTag,
|
|
73
|
+
objectType: objectType,
|
|
74
|
+
linkType: "one",
|
|
75
|
+
requiredOnCreate: false
|
|
76
|
+
},
|
|
77
|
+
storageResources,
|
|
78
|
+
"from"
|
|
79
|
+
)
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
relationshipTag: PREFIX_RELATIONSHIP.is + upperCase(objectType) + ATTRIBUTE_TAG.attributeTagLabel, // isProductAttributeLabel
|
|
83
|
+
relationshipProperties: createBasicRelationshipsProperties(
|
|
84
|
+
{
|
|
85
|
+
serviceTag: serviceTag,
|
|
86
|
+
objectType: objectType,
|
|
87
|
+
linkType: "many",
|
|
88
|
+
requiredOnCreate: true
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
serviceTag: serviceTag,
|
|
92
|
+
objectType: objectType + ATTRIBUTE_TAG.attributeTagLabel,
|
|
93
|
+
linkType: "one",
|
|
94
|
+
requiredOnCreate: false
|
|
95
|
+
},
|
|
96
|
+
storageResources,
|
|
97
|
+
"from"
|
|
98
|
+
)
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
relationshipTag: PREFIX_RELATIONSHIP.is + upperCase(objectType) + ATTRIBUTE_TAG.attributeTagPropertyLabel, // isProductAttributePropertyLabel
|
|
102
|
+
relationshipProperties: createBasicRelationshipsProperties(
|
|
103
|
+
{
|
|
104
|
+
serviceTag: serviceTag,
|
|
105
|
+
objectType: objectType + ATTRIBUTE_TAG.attributeTagProperty,
|
|
106
|
+
linkType: "one",
|
|
107
|
+
requiredOnCreate: true
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
serviceTag: serviceTag,
|
|
111
|
+
objectType: objectType + ATTRIBUTE_TAG.attributeTagPropertyLabel,
|
|
112
|
+
linkType: "one",
|
|
113
|
+
requiredOnCreate: false
|
|
114
|
+
},
|
|
115
|
+
storageResources,
|
|
116
|
+
"from"
|
|
117
|
+
)
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
relationshipTag: PREFIX_RELATIONSHIP.disabled + upperCase(objectType) + ATTRIBUTE_TAG.attributeTagLink, // disabledProductAttributeLink
|
|
121
|
+
relationshipProperties: createBasicRelationshipsProperties(
|
|
122
|
+
{
|
|
123
|
+
serviceTag: "ProductManager",
|
|
124
|
+
objectType: "product",
|
|
125
|
+
linkType: "one",
|
|
126
|
+
requiredOnCreate: false
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
serviceTag: serviceTag,
|
|
130
|
+
objectType: objectType + ATTRIBUTE_TAG.attributeTagLink,
|
|
131
|
+
linkType: "many",
|
|
132
|
+
requiredOnCreate: false
|
|
133
|
+
},
|
|
134
|
+
storageResources,
|
|
135
|
+
"from",
|
|
136
|
+
true
|
|
137
|
+
)
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
relationshipTag: PREFIX_RELATIONSHIP.disabled + upperCase(objectType) + ATTRIBUTE_TAG.attributeTagProperty, // disabledProductAttributeProperty
|
|
141
|
+
relationshipProperties: createBasicRelationshipsProperties(
|
|
142
|
+
{
|
|
143
|
+
serviceTag: serviceTag,
|
|
144
|
+
objectType: objectType,
|
|
145
|
+
linkType: "one",
|
|
146
|
+
requiredOnCreate: false
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
serviceTag: serviceTag,
|
|
150
|
+
objectType: objectType + ATTRIBUTE_TAG.attributeTagProperty,
|
|
151
|
+
linkType: "many",
|
|
152
|
+
requiredOnCreate: true
|
|
153
|
+
},
|
|
154
|
+
storageResources,
|
|
155
|
+
"from",
|
|
156
|
+
)
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
relationshipTag: PREFIX_RELATIONSHIP.disabled + upperCase(objectType) + ATTRIBUTE_TAG.attributeTagProperty, // hasProductAttributeLink
|
|
160
|
+
relationshipProperties: createBasicRelationshipsProperties(
|
|
161
|
+
{
|
|
162
|
+
serviceTag: "ProductManager",
|
|
163
|
+
objectType: "product",
|
|
164
|
+
linkType: "one",
|
|
165
|
+
requiredOnCreate: false
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
serviceTag: serviceTag,
|
|
169
|
+
objectType: objectType + ATTRIBUTE_TAG.attributeTagLink,
|
|
170
|
+
linkType: "many",
|
|
171
|
+
requiredOnCreate: false
|
|
172
|
+
},
|
|
173
|
+
storageResources,
|
|
174
|
+
"from",
|
|
175
|
+
true
|
|
176
|
+
)
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
relationshipTag: PREFIX_RELATIONSHIP.disabled + upperCase(objectType) + ATTRIBUTE_TAG.attributeTagProperty, // hasProductAttributeProperty
|
|
180
|
+
relationshipProperties: createBasicRelationshipsProperties(
|
|
181
|
+
{
|
|
182
|
+
serviceTag: serviceTag,
|
|
183
|
+
objectType: objectType,
|
|
184
|
+
linkType: "one",
|
|
185
|
+
requiredOnCreate: false
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
serviceTag: serviceTag,
|
|
189
|
+
objectType: objectType + ATTRIBUTE_TAG.attributeTagProperty,
|
|
190
|
+
linkType: "many",
|
|
191
|
+
requiredOnCreate: true
|
|
192
|
+
},
|
|
193
|
+
storageResources,
|
|
194
|
+
"from",
|
|
195
|
+
true
|
|
196
|
+
)
|
|
197
|
+
}
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
// console.log("attributeRelationships:::", JSON.stringify(attributeRelationships))
|
|
201
|
+
return attributeRelationships
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
module.exports = data
|
|
@@ -27,7 +27,6 @@ const { SOURCE_GENERATE_IAM_ROLE } = require("../../libs/Consts");
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
function data(_izContext, createSourceParams, srcPath) {
|
|
30
|
-
|
|
31
30
|
// ! old code
|
|
32
31
|
// function createFunctionNameConfigFileYaml(functionNameConfigs, srcPath) {
|
|
33
32
|
// let createFunctionNameConfigYaml = []
|
|
@@ -60,12 +59,18 @@ function data(_izContext, createSourceParams, srcPath) {
|
|
|
60
59
|
roleNameConcatConfigs.add(`${upperCase(value)}`);
|
|
61
60
|
});
|
|
62
61
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
+
}
|
|
67
71
|
}
|
|
68
|
-
}
|
|
72
|
+
});
|
|
73
|
+
|
|
69
74
|
|
|
70
75
|
// Generate YAML and JS configurations
|
|
71
76
|
const roleConfigYaml = createRoleNameConfigFileYaml(roleNameConfigs, srcPath);
|
|
@@ -28,11 +28,11 @@ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = req
|
|
|
28
28
|
const { DEFAULT_HANDLER_PER_ACTION, createIamRole, RESOURCE_CLASSES, SOURCE_PATH, externalResourceName, getGraphServiceNameFromAllRelSchema, SAVE_FILE_NAME, LAMBDA_RESOURCE, SNS_RESOURCE, getGraphServiceNameFromObjectSchema, shortNameHandler, SHORT_FUNCTION_NAME, defaultIamRolePerAction, resourceNames, SOURCE_GENERATE_IAM_ROLE } = require("../../libs/Consts");
|
|
29
29
|
// const templatePath = path.join(__dirname, "./template.ejs");
|
|
30
30
|
const templatePath = path.join(__dirname, "./template.ejs");
|
|
31
|
-
const {
|
|
31
|
+
const { getAllLocalRelationshipSchema } = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
|
|
32
32
|
const { EXTERNAL_SERVICE_NAME } = require("../../../../GenerateCodeLibs/src/Consts")
|
|
33
33
|
|
|
34
34
|
const createExternalLambdaRole = async (_izContext, allObjSchemas, allRelSchemas, allLocalFlowSchemas, srcPath) => {
|
|
35
|
-
const allRelationshipSchemas =
|
|
35
|
+
const allRelationshipSchemas = getAllLocalRelationshipSchema(_izContext, srcPath)
|
|
36
36
|
// console.log("allRelationshipSchemas", allRelationshipSchemas);
|
|
37
37
|
const externalLambdaIamRoleArray = [];
|
|
38
38
|
for (const objectSchema of allObjSchemas) {
|
|
@@ -59,7 +59,7 @@ const createExternalSnsSubscriptions = async (_izContext, allObjSchemas, allRelS
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
console.log("snsServiceConfigArray::", snsServiceConfigArray)
|
|
63
63
|
|
|
64
64
|
return {
|
|
65
65
|
templatePath: templatePath,
|