@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.
Files changed (33) hide show
  1. package/package.json +8 -7
  2. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +97 -1
  3. package/src/SourceManager/src/CreateSource.js +11 -1
  4. package/src/TemplateManager/src/FindData/mainFunction/data.js +28 -27
  5. package/src/TemplateManager/src/GenerateCode.js +6 -5
  6. package/src/TemplateManager/src/GenerateSchema.js +103 -0
  7. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/data.js +9 -6
  8. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/template.ejs +1 -1
  9. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrDsq/data.js +5 -1
  10. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrInv/data.js +5 -1
  11. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrInv/template.ejs +1 -1
  12. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrSqs/data.js +3 -1
  13. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/data.js +4 -0
  14. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/data.js +3 -0
  15. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/data.js +3 -0
  16. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/data.js +3 -0
  17. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/data.js +3 -0
  18. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Delete/data.js +3 -0
  19. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/data.js +3 -0
  20. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/data.js +3 -1
  21. package/src/TemplateManager/src/Role/createSharedResource.js +17 -14
  22. package/src/TemplateManager/src/attributeTree/objectSchema/data.js +128 -0
  23. package/src/TemplateManager/src/attributeTree/objectSchema/template.ejs +21 -0
  24. package/src/TemplateManager/src/attributeTree/refRelationshipSchema/data.js +36 -0
  25. package/src/TemplateManager/src/attributeTree/refRelationshipSchema/template.ejs +0 -0
  26. package/src/TemplateManager/src/attributeTree/relationshipSchema/data.js +206 -0
  27. package/src/TemplateManager/src/attributeTree/relationshipSchema/template.ejs +7 -0
  28. package/src/TemplateManager/src/externalService/FunctionNameConfig/data.js +11 -6
  29. package/src/TemplateManager/src/externalService/LambdaRole/data.js +2 -2
  30. package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/data.js +1 -1
  31. package/src/TemplateManager/src/libs/Consts.js +92 -2
  32. package/src/TemplateManager/src/reStructureExample/TemplateConfig.js +7 -3
  33. package/src/TemplateManager/src/reStructureExample/TemplateData/perAction/generatePerAction.js +9 -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.23",
4
4
  "description": "Schemas for Izara Market project",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -14,19 +14,20 @@
14
14
  "license": "AGPL-3.0-or-later",
15
15
  "homepage": "https://bitbucket.org/izara-market-libraries/izara-market-library-service-schemas/src/master/README.md",
16
16
  "devDependencies": {
17
- "jest": "^23.6.0"
17
+ "jest": "^29.7.0"
18
18
  },
19
19
  "jest": {
20
20
  "testEnvironment": "node"
21
21
  },
22
22
  "dependencies": {
23
- "@izara_project/izara-core-library-core": "^1.0.14",
23
+ "@izara_project/izara-core-library-core": "^1.0.16",
24
24
  "@izara_project/izara-core-library-external-request": "^1.0.17",
25
- "@izara_project/izara-core-library-service-schemas": "^1.0.41",
26
- "@izara_project/izara-shared": "^1.0.116",
25
+ "@izara_project/izara-core-library-service-schemas": "^1.0.43",
26
+ "@izara_project/izara-shared": "^1.0.125",
27
27
  "ejs": "^3.1.10",
28
- "js-beautify": "^1.15.1",
28
+ "js-beautify": "^1.15.4",
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,99 @@ function createFieldForUpdateDynamoDb(_izContext, objectSchema, dynamoDataDetail
931
933
  return fieldsForUpdateDynamo
932
934
  }
933
935
 
936
+
937
+ /**
938
+ *
939
+ * @param {Object} from
940
+ * @param {String} from.objectType
941
+ * @param {String} from.serviceTag
942
+ * @param {String} from.linkType
943
+ * @param {String} from.requiredOnCreate
944
+ * @param {Object} to
945
+ * @param {String} to.objectType
946
+ * @param {String} to.serviceTag
947
+ * @param {String} to.linkType
948
+ * @param {String} to.requiredOnCreate
949
+ * @param {Object} storageResources
950
+ * @param {Boolean} topLevelParent
951
+ */
952
+ function createBasicRelationshipsProperties(from, to, storageResources, baseDirection, topLevelParent = false) {
953
+ validateObjType({ objectType: from.objectType, serviceTag: from.serviceTag });
954
+ validateObjType({ objectType: to.objectType, serviceTag: to.serviceTag });
955
+
956
+ let otherDirection;
957
+ if (baseDirection === "to") {
958
+ otherDirection = "from"
959
+ } else if (baseDirection === "from") {
960
+ otherDirection = "to"
961
+ }
962
+
963
+ let relationshipProperties = {
964
+ fieldNames: {
965
+ originTimeStamp: {
966
+ type: 'number',
967
+ requiredOnCreate: true,
968
+ canUpdate: false,
969
+ validation: {
970
+ minimum: 1111111111111,
971
+ maximum: 9999999999999
972
+ }
973
+ }
974
+ },
975
+ storageResources: storageResources,
976
+ links: [
977
+ {
978
+ storageResourceTags: Object.keys(storageResources),
979
+ from: {
980
+ objType: {
981
+ objectType: from.objectType,
982
+ serviceTag: from.serviceTag
983
+ },
984
+ linkType: from.linkType,
985
+ direction: baseDirection,
986
+ requiredOnCreate: from.requiredOnCreate
987
+ },
988
+ to: {
989
+ objType: {
990
+ objectType: to.objectType,
991
+ serviceTag: to.serviceTag
992
+ },
993
+ linkType: to.linkType,
994
+ direction: otherDirection,
995
+ requiredOnCreate: to.requiredOnCreate
996
+ }
997
+ }
998
+ ],
999
+ }
1000
+
1001
+ if (topLevelParent === true) {
1002
+ relationshipProperties.links.push(
1003
+ {
1004
+ storageResourceTags: Object.keys(storageResources),
1005
+ from: {
1006
+ objType: {
1007
+ serviceTag: to.serviceTag,
1008
+ objectType: to.objectType
1009
+ },
1010
+ linkType: "one",
1011
+ direction: "from",
1012
+ requiredOnCreate: false
1013
+ },
1014
+ to: {
1015
+ objType: {
1016
+ serviceTag: to.serviceTag,
1017
+ objectType: to.objectType
1018
+ },
1019
+ linkType: "many",
1020
+ direction: "to",
1021
+ requiredOnCreate: false
1022
+ }
1023
+ }
1024
+ )
1025
+ }
1026
+ return relationshipProperties
1027
+ }
1028
+
934
1029
  module.exports = {
935
1030
  sendMsgOutComplete,
936
1031
  messageToDlq,
@@ -948,7 +1043,8 @@ module.exports = {
948
1043
  createDataDetailsLib,
949
1044
  createDeleteDataDetail,
950
1045
 
951
- createFieldForUpdateDynamoDb
1046
+ createFieldForUpdateDynamoDb,
1047
+ createBasicRelationshipsProperties
952
1048
  }
953
1049
 
954
1050
 
@@ -86,10 +86,20 @@ function generateDataFromTemplate(template, data,) {
86
86
  * @param {string} setting.initialData // initialData can use when isAppend = true
87
87
  * @returns
88
88
  */
89
- async function createSource(template, data, { savePath, hookPath, saveFileName, fileExtension, initialData, isAppend = false }) {
89
+ async function createSource(template, data, { savePath, hookPath, saveFileName, fileExtension, initialData, isAppend = false, checkCreateSourcePass = false }) {
90
90
 
91
91
  try {
92
92
 
93
+ if (checkCreateSourcePass) {
94
+ try {
95
+ generateDataFromTemplate(template, data);
96
+ return [true, {}];
97
+ } catch (errors) {
98
+ return [false, errors];
99
+ }
100
+ }
101
+
102
+
93
103
  let dataToSave = generateDataFromTemplate(template, data);
94
104
 
95
105
  let anyDoubleTagClass
@@ -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');
@@ -43,10 +43,11 @@ const NoRetryError = require("@izara_project/izara-core-library-core/src/NoRetry
43
43
 
44
44
  async function data(_izContext, srcPath) {
45
45
 
46
+ let schemaPath = path.join(srcPath, "schemas")
46
47
  let datas = [];
47
48
 
48
49
  // 1. get objectTypes for check objType param
49
- let getObjectTypes = await getObjectSchemas.getAllLocalObjectSchemas(_izContext, srcPath);
50
+ let getObjectTypes = await getObjectSchemas.getAllLocalObjectSchemas(_izContext, schemaPath);
50
51
  // console.log(("getObjectTypes: ", getObjectTypes.fieldLookup)
51
52
 
52
53
  for (const objectType of Object.keys(getObjectTypes.fieldLookup)) {
@@ -56,7 +57,7 @@ async function data(_izContext, srcPath) {
56
57
  let objectSchemaRecord = await getObjectSchemas.getLocalObjectSchemasWithHierarchy(
57
58
  _izContext,
58
59
  objectType,
59
- srcPath
60
+ schemaPath
60
61
  );
61
62
  // console.log("objectSchemaRecord: ", objectSchemaRecord)
62
63
 
@@ -154,42 +155,42 @@ async function data(_izContext, srcPath) {
154
155
  // fieldName in versionedData
155
156
  if (objectSchema.hasOwnProperty("addOnDataStructure")) { // array
156
157
  // console.log(("objectSchemas have addOnDataStructure: ", objectSchema.addOnDataStructure)
157
-
158
158
  for (const versionedData of objectSchema.addOnDataStructure) { // object // loop versionedData
159
159
  // console.log("versionedData: ", versionedData)
160
+ if (versionedData === ADD_ON_DATA_STRUCTURE_TYPE.versionedData) {
160
161
 
161
- let versionedStorageDetail = {};
162
- let versioendStorageResourceTag = versionedData.storageResourceTag;
163
- let versionedFieldNames = versionedData.fieldNames; // array
162
+ let versionedStorageDetail = {};
163
+ let versioendStorageResourceTag = versionedData.storageResourceTag;
164
+ let versionedFieldNames = versionedData.fieldNames; // array
164
165
 
165
- Object.entries(storageResources).map(([storageTag, storageDetail]) => {
166
+ Object.entries(storageResources).map(([storageTag, storageDetail]) => {
166
167
 
167
- if (versioendStorageResourceTag === storageTag) {
168
- if (storageDetail.storageType === STORAGE_TYPES.graph) {
169
- versionedStorageDetail = {
170
- [storageDetail.storageType]: {
171
- graphServerTag: storageDetail.graphServerTag,
172
- versionedDataLabel: versionedData.versionedDataLabel
168
+ if (versioendStorageResourceTag === storageTag) {
169
+ if (storageDetail.storageType === STORAGE_TYPES.graph) {
170
+ versionedStorageDetail = {
171
+ [storageDetail.storageType]: {
172
+ graphServerTag: storageDetail.graphServerTag,
173
+ versionedDataLabel: versionedData.versionedDataLabel
174
+ }
173
175
  }
176
+ } else {
177
+ throw new NoRetryError(`storageType of versionedData isn't graph`)
174
178
  }
175
- } else {
176
- throw new NoRetryError(`storageType of versionedData isn't graph`)
177
179
  }
178
- }
179
- })
180
- // console.log(("versionedStorageDetail: ", versionedStorageDetail)
181
-
182
- for (const versionedFieldName of versionedFieldNames) { // object // loop versionedFieldNames
180
+ })
181
+ // console.log(("versionedStorageDetail: ", versionedStorageDetail)
183
182
 
184
- if (versionedFieldName.type === "string" || versionedFieldName.type === "number") {
185
- fieldNameDatas.push({ [versionedFieldName.fieldName]: versionedStorageDetail })
186
- }
183
+ for (const versionedFieldName of versionedFieldNames) { // object // loop versionedFieldNames
187
184
 
188
- } // end loop versionedFieldNames
185
+ if (versionedFieldName.type === "string" || versionedFieldName.type === "number") {
186
+ fieldNameDatas.push({ [versionedFieldName.fieldName]: versionedStorageDetail })
187
+ }
189
188
 
190
- } // end loop versionedData
191
- //fieldNameDatas.push(collectVersionedFieldNames)
189
+ } // end loop versionedFieldNames
192
190
 
191
+ } // end loop versionedData
192
+ //fieldNameDatas.push(collectVersionedFieldNames)
193
+ }
193
194
  }
194
195
  // console.log(("fieldNameDatas: ", fieldNameDatas)
195
196
 
@@ -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,9 +646,9 @@ 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
+ // console.log("templateData in generateCode", templateData)
651
652
  // console.log("setting.saveFileName in GenerateCode", setting.saveFileName);
652
653
  // console.log("templatePath in GenerateCode", templatePath);
653
654
 
@@ -0,0 +1,103 @@
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, ADD_ON_DATA_STRUCTURE_TYPE } = 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
+ const createAttributeTreeObjRelationship = require('./attributeTree/relationshipSchema/data');
30
+
31
+ /**
32
+ *
33
+ * get template and send to
34
+ *
35
+ * @param {object} objSchemaPath
36
+ * @returns
37
+ *
38
+ * add another param
39
+ * {string[]} objectTypes
40
+ * {string[]} templates
41
+ * {string} saveFilePath
42
+ */
43
+
44
+ async function generateSchemaWithTemplate(_izContext, objSchemaPath) {
45
+ try {
46
+
47
+ let saveFilePath = join(objSchemaPath, `../`);
48
+
49
+ // define path for store yml file
50
+ const GENERATECODE_SOURCE_PATH = {
51
+ generateAttributeTree: join(saveFilePath, SOURCE_PATH.generatedAttributeTree)
52
+ };
53
+
54
+ let createSourceParams = [];
55
+
56
+ const allObjectSchemas = await getAllLocalObjectSchemasWithHierarchy(_izContext, objSchemaPath);
57
+
58
+ for (const objectSchema of allObjectSchemas.records) {
59
+
60
+ const attributeTreeObjSchema = createAttributeTreeObjSchemas(_izContext, objectSchema, saveFilePath);
61
+
62
+ const attributeTreeGenerator = [...attributeTreeObjSchema]
63
+ if (objectSchema.hasOwnProperty("addOnDataStructure")) {
64
+ for (const versionedData of objectSchema.addOnDataStructure) {
65
+ if (versionedData.type === ADD_ON_DATA_STRUCTURE_TYPE.attributeTree) {
66
+ const attributeTreeObjRelationship = createAttributeTreeObjRelationship(_izContext, objectSchema, saveFilePath);
67
+ createSourceParams = createSourceParams.concat(attributeTreeObjRelationship)
68
+ }
69
+ }
70
+ }
71
+
72
+ createSourceParams.push(...attributeTreeGenerator)
73
+
74
+ }
75
+
76
+
77
+ console.log("createSourceParams in generateSchema", createSourceParams)
78
+
79
+ for (let folderPathToEmpty of Object.keys(GENERATECODE_SOURCE_PATH)) {
80
+ await deleteFileInDir(GENERATECODE_SOURCE_PATH[folderPathToEmpty]);
81
+ }
82
+
83
+ // console.log("createSourceParams", createSourceParams)
84
+ for (let { templatePath, templateData, setting } of createSourceParams) {
85
+ // console.log("templateData in generateSchema", templateData);
86
+ // console.log("setting.savePath in GenerateSchema", setting.savePath)
87
+ await createSource(
88
+ readFileSync(templatePath, 'utf8'),
89
+ templateData,
90
+ setting,
91
+ );
92
+ }
93
+
94
+ return "Generate Schema Complete"
95
+
96
+
97
+ } catch (err) {
98
+ console.log('error templateManager: ', err);
99
+ throw (err);
100
+ }
101
+ }
102
+
103
+ 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: {