@izara_project/izara-market-library-service-schemas 1.0.21 → 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.
Files changed (29) hide show
  1. package/package.json +3 -2
  2. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +54 -1
  3. package/src/TemplateManager/src/FindData/mainFunction/data.js +25 -25
  4. package/src/TemplateManager/src/GenerateCode.js +5 -5
  5. package/src/TemplateManager/src/GenerateSchema.js +88 -0
  6. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/data.js +9 -6
  7. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/template.ejs +1 -1
  8. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrDsq/data.js +5 -1
  9. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrInv/data.js +5 -1
  10. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrInv/template.ejs +1 -1
  11. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrSqs/data.js +3 -1
  12. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/data.js +4 -0
  13. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/data.js +3 -0
  14. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/data.js +3 -0
  15. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/data.js +3 -0
  16. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/data.js +3 -0
  17. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Delete/data.js +3 -0
  18. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/data.js +3 -0
  19. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/data.js +3 -1
  20. package/src/TemplateManager/src/Role/createSharedResource.js +17 -14
  21. package/src/TemplateManager/src/attributeTree/objectSchema/data.js +125 -0
  22. package/src/TemplateManager/src/attributeTree/objectSchema/template.ejs +20 -0
  23. package/src/TemplateManager/src/attributeTree/refRelationshipSchema/data.js +36 -0
  24. package/src/TemplateManager/src/attributeTree/refRelationshipSchema/template.ejs +0 -0
  25. package/src/TemplateManager/src/attributeTree/relationshipSchema/data.js +92 -0
  26. package/src/TemplateManager/src/attributeTree/relationshipSchema/template.ejs +40 -0
  27. package/src/TemplateManager/src/externalService/FunctionNameConfig/data.js +11 -6
  28. package/src/TemplateManager/src/externalService/LambdaRole/data.js +2 -2
  29. package/src/TemplateManager/src/libs/Consts.js +92 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-market-library-service-schemas",
3
- "version": "1.0.21",
3
+ "version": "1.0.22",
4
4
  "description": "Schemas for Izara Market project",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -27,6 +27,7 @@
27
27
  "ejs": "^3.1.10",
28
28
  "js-beautify": "^1.15.1",
29
29
  "lodash": "^4.17.21",
30
- "object-hash": "^3.0.0"
30
+ "object-hash": "^3.0.0",
31
+ "yaml": "^2.7.0"
31
32
  }
32
33
  }
@@ -46,6 +46,8 @@ 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-core-library-service-schemas').validateObjType;
50
+
49
51
 
50
52
 
51
53
  const schemaFunctionPerAction = {
@@ -931,6 +933,56 @@ function createFieldForUpdateDynamoDb(_izContext, objectSchema, dynamoDataDetail
931
933
  return fieldsForUpdateDynamo
932
934
  }
933
935
 
936
+
937
+ /**
938
+ *
939
+ * @param {Object} fromObjType
940
+ * @param {String} fromObjType.objectType
941
+ * @param {String} fromObjType.serviceTag
942
+ * @param {Object} toObjType
943
+ * @param {String} toObjType.objectType
944
+ * @param {String} toObjType.serviceTag
945
+ * @param {Object} storageResources
946
+ */
947
+ function createLinksObjectRelationshipAttributeTree(fromObjType, toObjType, storageResources, direction) {
948
+ validateObjType(fromObjType);
949
+ validateObjType(toObjType);
950
+
951
+ if (direction === from) {
952
+
953
+ }
954
+ return {
955
+ fieldNames: {
956
+ originTimeStamp: {
957
+ type: 'number',
958
+ requiredOnCreate: true,
959
+ canUpdate: false,
960
+ validation: {
961
+ minimum: 1111111111111,
962
+ maximum: 9999999999999
963
+ }
964
+ }
965
+ },
966
+ storageResources: storageResources,
967
+ links: [
968
+ {
969
+ storageResourceTag: Object.keys(storageResources),
970
+ from: {
971
+ objType: fromObjType,
972
+ linkType: "one",
973
+ direction: direction
974
+ },
975
+ to: {
976
+ objType: toObjType,
977
+ linkType: "many"
978
+ }
979
+ }
980
+ ]
981
+
982
+
983
+ }
984
+ }
985
+
934
986
  module.exports = {
935
987
  sendMsgOutComplete,
936
988
  messageToDlq,
@@ -948,7 +1000,8 @@ module.exports = {
948
1000
  createDataDetailsLib,
949
1001
  createDeleteDataDetail,
950
1002
 
951
- createFieldForUpdateDynamoDb
1003
+ createFieldForUpdateDynamoDb,
1004
+ createLinksObjectRelationshipAttributeTree
952
1005
  }
953
1006
 
954
1007
 
@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  const path = require('path');
21
21
 
22
- const { SOURCE_PATH, FUNCTION_NAME } = require("../../libs/Consts");
22
+ const { SOURCE_PATH, FUNCTION_NAME, ADD_ON_DATA_STRUCTURE_TYPE } = require("../../libs/Consts");
23
23
  const { firstLetterUpperCase: upperCase } = require("../../../../MainLibs/src/Utils")
24
24
 
25
25
  const serviceSchemas = require('@izara_project/izara-core-library-service-schemas');
@@ -154,42 +154,42 @@ async function data(_izContext, srcPath) {
154
154
  // fieldName in versionedData
155
155
  if (objectSchema.hasOwnProperty("addOnDataStructure")) { // array
156
156
  // console.log(("objectSchemas have addOnDataStructure: ", objectSchema.addOnDataStructure)
157
-
158
157
  for (const versionedData of objectSchema.addOnDataStructure) { // object // loop versionedData
159
158
  // console.log("versionedData: ", versionedData)
159
+ if (versionedData === ADD_ON_DATA_STRUCTURE_TYPE.versionedData) {
160
160
 
161
- let versionedStorageDetail = {};
162
- let versioendStorageResourceTag = versionedData.storageResourceTag;
163
- let versionedFieldNames = versionedData.fieldNames; // array
161
+ let versionedStorageDetail = {};
162
+ let versioendStorageResourceTag = versionedData.storageResourceTag;
163
+ let versionedFieldNames = versionedData.fieldNames; // array
164
164
 
165
- Object.entries(storageResources).map(([storageTag, storageDetail]) => {
165
+ Object.entries(storageResources).map(([storageTag, storageDetail]) => {
166
166
 
167
- if (versioendStorageResourceTag === storageTag) {
168
- if (storageDetail.storageType === STORAGE_TYPES.graph) {
169
- versionedStorageDetail = {
170
- [storageDetail.storageType]: {
171
- graphServerTag: storageDetail.graphServerTag,
172
- versionedDataLabel: versionedData.versionedDataLabel
167
+ if (versioendStorageResourceTag === storageTag) {
168
+ if (storageDetail.storageType === STORAGE_TYPES.graph) {
169
+ versionedStorageDetail = {
170
+ [storageDetail.storageType]: {
171
+ graphServerTag: storageDetail.graphServerTag,
172
+ versionedDataLabel: versionedData.versionedDataLabel
173
+ }
173
174
  }
175
+ } else {
176
+ throw new NoRetryError(`storageType of versionedData isn't graph`)
174
177
  }
175
- } else {
176
- throw new NoRetryError(`storageType of versionedData isn't graph`)
177
178
  }
178
- }
179
- })
180
- // console.log(("versionedStorageDetail: ", versionedStorageDetail)
181
-
182
- for (const versionedFieldName of versionedFieldNames) { // object // loop versionedFieldNames
179
+ })
180
+ // console.log(("versionedStorageDetail: ", versionedStorageDetail)
183
181
 
184
- if (versionedFieldName.type === "string" || versionedFieldName.type === "number") {
185
- fieldNameDatas.push({ [versionedFieldName.fieldName]: versionedStorageDetail })
186
- }
182
+ for (const versionedFieldName of versionedFieldNames) { // object // loop versionedFieldNames
187
183
 
188
- } // end loop versionedFieldNames
184
+ if (versionedFieldName.type === "string" || versionedFieldName.type === "number") {
185
+ fieldNameDatas.push({ [versionedFieldName.fieldName]: versionedStorageDetail })
186
+ }
189
187
 
190
- } // end loop versionedData
191
- //fieldNameDatas.push(collectVersionedFieldNames)
188
+ } // end loop versionedFieldNames
192
189
 
190
+ } // end loop versionedData
191
+ //fieldNameDatas.push(collectVersionedFieldNames)
192
+ }
193
193
  }
194
194
  // console.log(("fieldNameDatas: ", fieldNameDatas)
195
195
 
@@ -23,7 +23,8 @@ const { readFileSync } = require('fs');
23
23
 
24
24
  const {
25
25
  getAllLocalObjectSchemasWithHierarchy,
26
- getAllLocalRelationshipSchemas,
26
+ // getAllLocalRelationshipSchemas,
27
+ getAllLocalRelationshipSchema,
27
28
  getAllLocalFlowSchemas
28
29
  } = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
29
30
 
@@ -227,7 +228,6 @@ const functionNameConfigYamldata = require('./externalService/FunctionNameConfig
227
228
  // create shared resource
228
229
  const { createSharedResource } = require('./Role/createSharedResource');
229
230
 
230
-
231
231
  //lib of generateCode
232
232
  const { checkValidTableYaml,
233
233
  } = require('./libs/GenerateCodeUtils');
@@ -261,7 +261,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
261
261
  externalService: join(saveFilePath, SOURCE_PATH.externalService),
262
262
  relationshipPerAction: join(saveFilePath, SOURCE_PATH.relationshipPerAction),
263
263
  webSocketEndpoint: join(saveFilePath, SOURCE_PATH.webSocket),
264
- generateCodeLib: join(saveFilePath, SOURCE_PATH.generateCodeLib)
264
+ generateCodeLib: join(saveFilePath, SOURCE_PATH.generateCodeLib),
265
265
  };
266
266
 
267
267
  let createSourceParams = [];
@@ -277,7 +277,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
277
277
  const processLogicalPaginateFunctionYamlHdrDsq = await createProcessLogicalPaginateFunctionYamlHdrDsq(_izContext, allObjSchemas, saveFilePath);
278
278
  const processLogicalPaginateFunctionYamlHdrSqs = await createProcessLogicalPaginateFunctionYamlHdrSqs(_izContext, allObjSchemas, saveFilePath);
279
279
 
280
- const allObjectRelationships = await getAllLocalRelationshipSchemas(_izContext, objSchemaPath);
280
+ const allObjectRelationships = await getAllLocalRelationshipSchema(_izContext, objSchemaPath);
281
281
  // _izContext.logger.debug("allObjectRelationships::", allObjectRelationships);
282
282
 
283
283
  const allLocalFlowSchemas = await getAllLocalFlowSchemas(_izContext, objSchemaPath);
@@ -631,6 +631,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
631
631
  )
632
632
  }
633
633
  // console.log("createSourceParams templatePath in GenerateCode", createSourceParams.templatePath)
634
+ // console.log("template Data createSourceParams:", createSourceParams.templateData)
634
635
 
635
636
  const createFunctionNameConfig = functionNameConfigYamldata(_izContext, createSourceParams, saveFilePath);
636
637
  createSourceParams = createSourceParams.concat(...createFunctionNameConfig);
@@ -645,7 +646,6 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
645
646
  // for (const flowSchema of allLocalFlowSchemas.records) {
646
647
  // await createHookFunction(_izContext, flowSchema, saveFilePath);
647
648
  // }
648
- // console.log(""createSourceParams": ", createSourceParams)
649
649
  // start create source
650
650
  for (let { templatePath, templateData, setting } of createSourceParams) {
651
651
  // console.log("setting.saveFileName in GenerateCode", setting.saveFileName);
@@ -0,0 +1,88 @@
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 join = require('path').join;
20
+ const { readFileSync } = require('fs');
21
+ const { SOURCE_PATH } = require('./libs/Consts')
22
+ const { createSource } = require("../../SourceManager/src/CreateSource");
23
+ const { deleteFileInDir } = require('../../SourceManager/src/Utils')
24
+ const {
25
+ getAllLocalObjectSchemasWithHierarchy,
26
+ } = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
27
+
28
+ const createAttributeTreeObjSchemas = require('./attributeTree/objectSchema/data');
29
+
30
+ /**
31
+ *
32
+ * get template and send to
33
+ *
34
+ * @param {object} objSchemaPath
35
+ * @returns
36
+ *
37
+ * add another param
38
+ * {string[]} objectTypes
39
+ * {string[]} templates
40
+ * {string} saveFilePath
41
+ */
42
+
43
+ async function generateSchemaWithTemplate(_izContext, objSchemaPath) {
44
+ try {
45
+
46
+ let saveFilePath = join(objSchemaPath, `../`);
47
+
48
+ // define path for store yml file
49
+ const GENERATECODE_SOURCE_PATH = {
50
+ generateAttributeTree: join(saveFilePath, SOURCE_PATH.generatedAttributeTree)
51
+ };
52
+
53
+ let createSourceParams = [];
54
+
55
+ const allObjectSchemas = await getAllLocalObjectSchemasWithHierarchy(_izContext, objSchemaPath);
56
+
57
+ for (const objectSchema of allObjectSchemas.records) {
58
+ const attributeTreeObjSchema = createAttributeTreeObjSchemas(_izContext, objectSchema, saveFilePath);
59
+ const attributeTreeGenerator = [...attributeTreeObjSchema]
60
+ createSourceParams.push(...attributeTreeGenerator)
61
+ };
62
+
63
+ for (let folderPathToEmpty of Object.keys(GENERATECODE_SOURCE_PATH)) {
64
+ await deleteFileInDir(GENERATECODE_SOURCE_PATH[folderPathToEmpty]);
65
+ }
66
+
67
+
68
+ for (let { templatePath, templateData, setting } of createSourceParams) {
69
+ // console.log("setting.saveFileName in GenerateSchema", setting.saveFileName);
70
+ // console.log("templatePath in GenerateSchema", templatePath);
71
+ // console.log("setting.savePath in GenerateSchema", setting.savePath)
72
+ await createSource(
73
+ readFileSync(templatePath, 'utf8'),
74
+ templateData,
75
+ setting,
76
+ );
77
+ }
78
+
79
+ return "Generate Schema Complete"
80
+
81
+
82
+ } catch (err) {
83
+ console.log('error templateManager: ', err);
84
+ throw (err);
85
+ }
86
+ }
87
+
88
+ module.exports = { generateSchemaWithTemplate };
@@ -57,7 +57,9 @@ function data(_izContext, objectSchema, srcPath) {
57
57
  }
58
58
 
59
59
  function createParamForCreateSource(objectSchema, action, srcPath) {
60
- let objectType = objectSchema.objectType
60
+ // let objectType = objectSchema.objectType
61
+ let objectType = objectSchema.objectType;
62
+ let groupBy = objectSchema?.shortNameObjectType ? objectSchema.shortNameObjectType : objectSchema.objectType;
61
63
  let functionName = upperCase(objectType) + upperCase(action);
62
64
  let additionalResourcePermission = defaultIamRolePerAction();
63
65
  let tableForGetItem = [];
@@ -160,15 +162,16 @@ function createParamForCreateSource(objectSchema, action, srcPath) {
160
162
  additionalResourcePermission,
161
163
  event: event,
162
164
  objectType: objectType,
165
+ roleName: groupBy,
163
166
  action: action,
164
167
  functionNameConfig,
165
168
  },
166
- setting: {
167
- savePath: path.join(srcPath, SOURCE_PATH.appYaml),
168
- saveFileName: SAVE_FILE_NAME.functionPerActionYaml,
169
+ setting: {
170
+ savePath: path.join(srcPath, SOURCE_PATH.appYaml),
171
+ saveFileName: SAVE_FILE_NAME.functionPerActionYaml,
169
172
  fileExtension: '.yml',
170
- isAppend: true
171
- }
173
+ isAppend: true
174
+ }
172
175
  }
173
176
  }
174
177
 
@@ -9,7 +9,7 @@
9
9
  cors: true
10
10
  #<#<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>Authorizer#>
11
11
  #<#/<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>Authorizer#>
12
- role: <%- firstLetterUpperCase(objectType) %>Role
12
+ role: <%- firstLetterUpperCase(roleName) %>Role
13
13
  #<#<%- functionName %><%- handlerType %>IamRole#>
14
14
  #<#/<%- functionName %><%- handlerType %>IamRole#>
15
15
  <%_ function firstLetterUpperCase(text){
@@ -59,7 +59,10 @@ function data(_izContext, objectSchema, srcPath) {
59
59
 
60
60
 
61
61
  function createParamForCreateSource(objectSchema, action, srcPath) {
62
+ // let objectType = objectSchema.objectType;
63
+
62
64
  let objectType = objectSchema.objectType;
65
+ let groupBy = objectSchema?.shortNameObjectType ? objectSchema.shortNameObjectType : objectSchema.objectType;
63
66
  let functionName = upperCase(objectType) + upperCase(action);
64
67
  let functionNameObjectType = objectSchema?.shortNameObjectType ? objectSchema.shortNameObjectType : objectSchema.objectType;
65
68
  let functionNameConfig = upperCase(functionNameObjectType) + upperCase(action) + upperCase(shortNameHandler(HANDLER.hdrDsq))
@@ -169,7 +172,8 @@ function createParamForCreateSource(objectSchema, action, srcPath) {
169
172
  handlerType: HANDLER.hdrDsq,
170
173
  additionalResourcePermission,
171
174
  functionNameConfig,
172
- roleName: `${objectType}`,
175
+ roleName: objectType,
176
+ roleName: groupBy,
173
177
  },
174
178
  setting: {
175
179
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
@@ -61,7 +61,9 @@ function data(_izContext, objectSchema, srcPath) {
61
61
 
62
62
  function createParamForCreateSource(objectSchema, action, srcPath) {
63
63
  let functionNameObjectType = objectSchema?.shortNameObjectType ? objectSchema.shortNameObjectType : objectSchema.objectType;
64
+ // let objectType = objectSchema.objectType;
64
65
  let objectType = objectSchema.objectType;
66
+ let groupBy = objectSchema?.shortNameObjectType ? objectSchema.shortNameObjectType : objectSchema.objectType;
65
67
  let actionHandler = action;
66
68
  let functionName = upperCase(objectType) + upperCase(actionHandler);
67
69
  let additionalResourcePermission = defaultIamRolePerAction();
@@ -150,7 +152,9 @@ function createParamForCreateSource(objectSchema, action, srcPath) {
150
152
  resourceLocation: SOURCE_PATH.resourceLocationPerAction,
151
153
  handlerType: HANDLER.hdrInv,
152
154
  additionalResourcePermission,
153
- objectType,
155
+ objectType: objectType,
156
+ roleName: groupBy,
157
+
154
158
  // functionNameConfig: upperCase(objectType) + upperCase(action) + upperCase(shortNameHandler(HANDLER.hdrInv))
155
159
  functionNameConfig: upperCase(functionNameObjectType) + upperCase(action) + upperCase(shortNameHandler(HANDLER.hdrInv)),
156
160
  },
@@ -2,7 +2,7 @@
2
2
  <%- firstLetterUpperCase(functionNameConfig) %>:
3
3
  handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
4
4
  name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
5
- role: <%- firstLetterUpperCase(objectType) %>Role
5
+ role: <%- firstLetterUpperCase(roleName) %>Role
6
6
  #<#<%- functionName %><%- handlerType %>IamRole#>
7
7
  #<#/<%- functionName %><%- handlerType %>IamRole#>
8
8
  <%_ function firstLetterUpperCase(text){
@@ -59,7 +59,9 @@ function data(_izContext, objectSchema, srcPath) {
59
59
 
60
60
 
61
61
  function createParamForCreateSource(objectSchema, action, srcPath) {
62
+ // let objectType = objectSchema.objectType;
62
63
  let objectType = objectSchema.objectType;
64
+ let groupBy = objectSchema?.shortNameObjectType ? objectSchema.shortNameObjectType : objectSchema.objectType;
63
65
  let actionHandler = action;
64
66
  let functionName = upperCase(objectType) + upperCase(actionHandler);
65
67
  let additionalResourcePermission = defaultIamRolePerAction();
@@ -173,7 +175,7 @@ function createParamForCreateSource(objectSchema, action, srcPath) {
173
175
  additionalResourcePermission,
174
176
  functionNameConfig,
175
177
  objectType,
176
- roleName: `${objectType}`,
178
+ roleName: groupBy,
177
179
  },
178
180
  setting: {
179
181
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
@@ -60,13 +60,17 @@ function data(_izContext, objectSchema, srcPath) {
60
60
 
61
61
 
62
62
  function createParamForCreateSource(objectSchema, action, handler, srcPath) {
63
+ // let objectType = objectSchema.objectType;
63
64
  let objectType = objectSchema.objectType;
65
+ let groupBy = objectSchema?.shortNameObjectType ? objectSchema.shortNameObjectType : objectSchema.objectType;
66
+
64
67
  let functionName = objectType + firstLetterUpperCase(action);
65
68
  return {
66
69
  templatePath: templatePath,
67
70
  templateData: {
68
71
  functionName: functionName,
69
72
  objectType: objectType,
73
+ roleName: groupBy,
70
74
  action: action,
71
75
  isCreateMainFunction: checkOverWriteGenerateMainFunction(objectSchema, action),
72
76
  },
@@ -59,7 +59,9 @@ function data(_izContext, objectSchema, srcPath) {
59
59
 
60
60
 
61
61
  function createParamForCreateSourceHandlerGet(objectSchema, action, handler, srcPath) {
62
+ // let objectType = objectSchema.objectType;
62
63
  let objectType = objectSchema.objectType;
64
+ let groupBy = objectSchema?.shortNameObjectType ? objectSchema.shortNameObjectType : objectSchema.objectType;
63
65
  let functionName = objectType + upperCase(action);
64
66
  let queueName = objectType + firstLetterUpperCase(action) + upperCase(handler);
65
67
  return {
@@ -67,6 +69,7 @@ function createParamForCreateSourceHandlerGet(objectSchema, action, handler, src
67
69
  templateData: {
68
70
  functionName: functionName,
69
71
  objectType: objectType,
72
+ roleName: groupBy,
70
73
  queueName,
71
74
  action,
72
75
  isCreateMainFunction: checkOverWriteGenerateMainFunction(objectSchema, action),
@@ -61,13 +61,16 @@ function data(_izContext, objectSchema, srcPath) {
61
61
 
62
62
 
63
63
  function createParamForCreateHandlerGet(objectSchema, action, handler, srcPath) {
64
+ // let objectType = objectSchema.objectType;
64
65
  let objectType = objectSchema.objectType;
66
+ let groupBy = objectSchema?.shortNameObjectType ? objectSchema.shortNameObjectType : objectSchema.objectType;
65
67
  let functionName = objectType + upperCase(action);
66
68
  return {
67
69
  templatePath: templatePath,
68
70
  templateData: {
69
71
  functionName: functionName,
70
72
  objectType: objectType,
73
+ roleName: groupBy,
71
74
  action: action,
72
75
  isCreateMainFunction: checkOverWriteGenerateMainFunction(objectSchema, action),
73
76
  },
@@ -59,7 +59,9 @@ function data(_izContext, objectSchema, srcPath) {
59
59
 
60
60
 
61
61
  function createParamForCreateSourceGetHandler(objectSchema, action, handler, srcPath) {
62
+ // let objectType = objectSchema.objectType;
62
63
  let objectType = objectSchema.objectType;
64
+ let groupBy = objectSchema?.shortNameObjectType ? objectSchema.shortNameObjectType : objectSchema.objectType;
63
65
  let functionName = objectType + firstLetterUpperCase(action);
64
66
  let queueName = functionName + upperCase(handler);
65
67
  return {
@@ -67,6 +69,7 @@ function createParamForCreateSourceGetHandler(objectSchema, action, handler, src
67
69
  templateData: {
68
70
  functionName: functionName,
69
71
  objectType: objectType,
72
+ roleName: groupBy,
70
73
  queueName,
71
74
  action,
72
75
  isCreateMainFunction: checkOverWriteGenerateMainFunction(objectSchema, action),
@@ -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
  actionHandler: action,
55
58
  },
56
59
  setting: {
@@ -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: {
@@ -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, templateData.objectType, objectTypeList);
119
+ initializeObjectType(groupedByObjectType, objectType, objectTypeList);
113
120
  // Add function name if it doesn't exist
114
121
  if (templateData.functionName &&
115
- !groupedByObjectType[templateData.objectType].functionNames?.includes(templateData.functionName)) {
116
- groupedByObjectType[templateData.objectType].functionNames.push(templateData.functionName);
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[templateData.objectType].actions.includes(templateData.action)) {
121
- groupedByObjectType[templateData.objectType].actions.push(templateData.action);
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[templateData.objectType].resources
133
+ groupedByObjectType[objectType].resources
127
134
  );
128
135
  }
129
136
  else if (templateData.functionName &&
130
- (templateData.functionName.includes('ObjectComplete') ||
131
- templateData.functionName.includes('NodeComplete'))) {
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
- // สร้าง policy statements จาก resources
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: reformattedData,
263
+ templateData: { roles },
261
264
  setting: {
262
265
  initialData: 'Resources:\n',
263
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
@@ -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
+ ]
@@ -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
- for (const { templateData } of createSourceParams) {
64
- if (templateData?.objectType) {
65
- roleNameConfigs.add(`${upperCase(templateData.objectType)}Role`);
66
- roleNameConcatConfigs.add(`${upperCase(templateData.objectType)}`);
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 { getAllLocalRelationshipSchemas } = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
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 = getAllLocalRelationshipSchemas(_izContext, srcPath)
35
+ const allRelationshipSchemas = getAllLocalRelationshipSchema(_izContext, srcPath)
36
36
  // console.log("allRelationshipSchemas", allRelationshipSchemas);
37
37
  const externalLambdaIamRoleArray = [];
38
38
  for (const objectSchema of allObjSchemas) {
@@ -122,9 +122,9 @@ const SOURCE_PATH = {
122
122
  resourceLocationLogicalFunctionHook: "src/generatedCode/WebSocket/source/FlowSchemaHook/HookLogicFunction/source",
123
123
  generatedCodeHookFunction: "../src/generatedCode/WebSocket/source/FlowSchemaHook/HookFunctionGeneratedCode/source/",
124
124
  resourceLocationGeneratedCodeHookFunction: "src/generatedCode/WebSocket/source/FlowSchemaHook/HookFunctionGeneratedCode/source/",
125
+ generatedAttributeTree: "../src/schemas/generatedCode/source/"
125
126
  };
126
127
 
127
-
128
128
  const DEFAULT_LAMBDA_ROLE_PER_ACTION = {
129
129
  [ACTIONS.create]: {
130
130
  dynamoDbPermission: 'PutItem',
@@ -219,6 +219,9 @@ const SAVE_FILE_NAME = {
219
219
  flowSchema: "flowSchema",
220
220
  S3Bucket: "generated-s3-bucket",
221
221
  sharedResourceYaml: "generate-SharedResource",
222
+ attributeTreeObjectRelationship: "ObjectRelationships",
223
+ attributeTreeRefObjectRelationship: "RefObjectRelationships",
224
+ attributeTreeObjectSchema: "ObjectFieldSchema"
222
225
  };
223
226
 
224
227
  const FUNCTION_NAME = {
@@ -361,10 +364,92 @@ function shortNameHandler(fullNameHandler) {
361
364
  const SOURCE_GENERATE_IAM_ROLE = {
362
365
  ProcessFindDataRole: "ProcFindData",
363
366
  ObjectCompleteRole: "ObjectCom",
367
+ NodeCompleteRole: "NodeCom",
364
368
  RelationshipRole: "Relationship",
365
369
  RelationshipCompleteRole: "RelationshipCom",
366
370
  };
367
371
 
372
+ const ADD_ON_DATA_STRUCTURE_TYPE = {
373
+ versionedData: "versionedData",
374
+ attributeTree: "attributeTree"
375
+ };
376
+
377
+ const ATTRIBUTE_TAG = {
378
+ attributeTagLabel: "Label",
379
+ attributeTagLink: "Link",
380
+ attributeTagProperty: "Property",
381
+ attributeTagPropertyLabel: "PropertyLabel",
382
+ };
383
+
384
+ const FIELD_NAME_TPYE = {
385
+ identifiers: "identifiers",
386
+ nonIdentifiers: "nonIdentifiers",
387
+ requiredOnCreateFieldName: "requiredOnCreateFieldName",
388
+ randomOnCreateFieldName: "randomOnCreateFieldName",
389
+ optionalOnCreate: "optionalOnCreate"
390
+ };
391
+
392
+ function fieldNameSetting(fieldNameType) {
393
+ const stringValidation = "^[a-zA-Z0-9-_]+$"
394
+ return {
395
+ [FIELD_NAME_TPYE.identifiers]: {
396
+ type: "string",
397
+ requiredOnCreate: true,
398
+ optionalOnCreate: false,
399
+ canUpdate: false,
400
+ randomOnCreate: false,
401
+ validation: {
402
+ pattern: stringValidation
403
+ }
404
+ },
405
+ [FIELD_NAME_TPYE.nonIdentifiers]: {
406
+ type: "string",
407
+ requiredOnCreate: false,
408
+ optionalOnCreate: false,
409
+ canUpdate: true,
410
+ randomOnCreate: false,
411
+ validation: {
412
+ pattern: stringValidation
413
+ }
414
+ },
415
+ [FIELD_NAME_TPYE.requiredOnCreateFieldName]: {
416
+ type: "string",
417
+ requiredOnCreate: true,
418
+ optionalOnCreate: false,
419
+ canUpdate: false,
420
+ randomOnCreate: false,
421
+ validation: {
422
+ pattern: stringValidation
423
+ }
424
+ },
425
+ [FIELD_NAME_TPYE.randomOnCreateFieldName]: {
426
+ type: "string",
427
+ requiredOnCreate: true,
428
+ optionalOnCreate: false,
429
+ canUpdate: false,
430
+ randomOnCreate: false,
431
+ validation: {
432
+ pattern: stringValidation
433
+ }
434
+ },
435
+ [FIELD_NAME_TPYE.optionalOnCreate]: {
436
+ type: "string",
437
+ requiredOnCreate: false,
438
+ optionalOnCreate: true,
439
+ canUpdate: false,
440
+ randomOnCreate: false,
441
+ validation: {
442
+ pattern: stringValidation
443
+ }
444
+ }
445
+ }[fieldNameType]
446
+ };
447
+
448
+ const PREFIX_RELATIONSHIP = {
449
+ has: "has",
450
+ is: "is",
451
+ disabled: "disabled"
452
+ }
368
453
 
369
454
  module.exports = {
370
455
  ACTIONS,
@@ -391,5 +476,10 @@ module.exports = {
391
476
  shortNameHandler,
392
477
  SHORT_FUNCTION_NAME,
393
478
  S3_RESOURCE,
394
- SOURCE_GENERATE_IAM_ROLE
479
+ SOURCE_GENERATE_IAM_ROLE,
480
+ fieldNameSetting,
481
+ FIELD_NAME_TPYE,
482
+ ADD_ON_DATA_STRUCTURE_TYPE,
483
+ ATTRIBUTE_TAG,
484
+ PREFIX_RELATIONSHIP
395
485
  }