@izara_project/izara-core-generate-service-code 1.0.29 → 1.0.31

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 (25) hide show
  1. package/package.json +2 -2
  2. package/src/generateCode/generateFlowSchema/event/lambdaSyncApiComponent/handler/template.ejs +4 -4
  3. package/src/generateCode/generateFlowSchema/event/s3Component/upload/processFile/handler/handlerS3/template.ejs +4 -4
  4. package/src/generateCode/generateInitialSetup/GenerateCodeExternalService.js +0 -1
  5. package/src/generateCode/generateInitialSetup/externalServiceComponent/index.js +9 -3
  6. package/src/generateCode/generateInitialSetup/externalServiceComponent/tableNameConfig/data.js +90 -0
  7. package/src/generateCode/generateInitialSetup/externalServiceComponent/tableNameConfig/template.ejs +43 -0
  8. package/src/generateCode/generateSchema/GenerateCodeSchema.js +13 -4
  9. package/src/generateCode/generateSchema/actionEndpointCompleteComponent/update/mainFunction/template.ejs +4 -4
  10. package/src/generateCode/generateSchema/actionEndpointComponent/mainFunction/get/template.ejs +0 -9
  11. package/src/generateCode/generateSchema/actionEndpointComponent/yaml/data.js +3 -3
  12. package/src/generateCode/{generateTranslation/generateTranslation.js → generateSchema/generateTextTag/index.js} +10 -7
  13. package/src/generateCode/{generateTranslation/translations → generateSchema/generateTextTag/systemText}/data.js +46 -11
  14. package/src/generateCode/generateSchema/rbac/dynamoDb/data.js +74 -0
  15. package/src/generateCode/generateSchema/rbac/index.js +68 -0
  16. package/src/generateCode/generateSchema/rbac/lambda/handler/data.js +69 -0
  17. package/src/generateCode/generateSchema/rbac/lambda/handler/template.ejs +52 -0
  18. package/src/generateCode/generateSchema/rbac/lambda/mainFunction/data.js +82 -0
  19. package/src/generateCode/generateSchema/rbac/lambda/mainFunction/template.ejs +111 -0
  20. package/src/generateCode/generateSchema/rbac/lambda/yaml/data.js +106 -0
  21. package/src/generateCode/generateSchema/rbac/lambda/yaml/template.ejs +6 -0
  22. package/src/generateCode.js +5 -12
  23. package/src/libs/Consts.js +10 -4
  24. package/src/libs/Libs.js +7 -1
  25. /package/src/generateCode/{generateTranslation/translations → generateSchema/generateTextTag/systemText}/template.ejs +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-core-generate-service-code",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "description": "Code for locally generating per service files",
5
5
  "author": "Sven Mason <thebarbariansven@gmail.com>",
6
6
  "license": "AGPL-3.0-or-later",
@@ -27,7 +27,7 @@
27
27
  "@izara_project/izara-core-library-core": "^1.0.31",
28
28
  "@izara_project/izara-core-library-logger": "^1.0.8",
29
29
  "@izara_project/izara-core-library-s3": "^1.0.5",
30
- "@izara_project/izara-core-library-service-schemas": "^1.0.127",
30
+ "@izara_project/izara-core-library-service-schemas": "^1.0.133",
31
31
  "@izara_project/izara-shared-core": "^1.0.9",
32
32
  "ejs": "^5.0.1",
33
33
  "js-beautify": "^1.15.4",
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
 
18
18
  const RBAC_TARGET_ID = process.env.iz_rbacTargetIdUser // iz_rbacTargetIdUser | iz_rbacDeliveryMethodId
19
19
 
20
- import { middlewareHandler as middleware } from "@izara_project/izara-middleware";
20
+ import { middlewareHandler as middleware, response } from "@izara_project/izara-middleware";
21
21
  import Logger from '@izara_project/izara-core-library-logger';
22
22
  import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
23
23
 
@@ -71,14 +71,14 @@ export const main = middleware.wrap(async (event, context, callback) => {
71
71
 
72
72
  // return error to client
73
73
  if (lambdaFunctionResponse instanceof Error) {
74
- return (izara.response.failure(lambdaFunctionResponse));
74
+ return (response.failure(lambdaFunctionResponse));
75
75
  }
76
76
 
77
77
  // return success to client
78
- return (izara.response.success(lambdaFunctionResponse));
78
+ return (response.success(lambdaFunctionResponse));
79
79
 
80
80
  } catch (err) {
81
81
  event._izContext.logger.error('Error, LambdaFunctionHdrApi: ', err);
82
- return (izara.response.failure(err));
82
+ return (response.failure(err));
83
83
  }
84
84
  });
@@ -16,7 +16,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
 
18
18
 
19
- import { middlewareHandler as middleware } from "@izara_project/izara-middleware";
19
+ import { middlewareHandler as middleware, response } from "@izara_project/izara-middleware";
20
20
  import Logger from '@izara_project/izara-core-library-logger';
21
21
  import recordHandlerS3SharedLib from '@izara_project/izara-core-library-record-handler';
22
22
 
@@ -38,13 +38,13 @@ export const main = middleware.wrap(async (event, context) => {
38
38
  );
39
39
 
40
40
  if (processImageResponse instanceof Error) {
41
- return (izara.response.failure(processImageResponse));
41
+ return (response.failure(processImageResponse));
42
42
  };
43
43
 
44
- return (izara.response.success(processImageResponse));
44
+ return (response.success(processImageResponse));
45
45
 
46
46
  } catch (err) {
47
47
  event._izContext.logger.error('Error, processAfterUploadHdrS3: ', err);
48
- return (izara.response.failure(err));
48
+ return (response.failure(err));
49
49
  }
50
50
  });
@@ -33,7 +33,6 @@ async function generateTemplateExternalResourceDataFromCustomData(
33
33
  allObjSchemas,
34
34
  allRelationshipSchemas,
35
35
  allFlowSchemas,
36
- settings
37
36
  )
38
37
  ]);
39
38
 
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
 
18
18
  import createExternalLambdaRole from './lambdaRole/data.js';
19
19
  import createExternalSnsSubscriptions from './snsTopicSubscriptions/data.js';
20
-
20
+ import createTableNameConfig from './tableNameConfig/data.js';
21
21
  /**
22
22
  * Generates code with templates for different actions
23
23
  * @param {Object} _izContext - Context object
@@ -29,7 +29,7 @@ async function generateCodeWithTemplate(
29
29
  rootServicePath,
30
30
  allObjSchemas,
31
31
  allObjectRelationships,
32
- allLocalFlowSchemas
32
+ allLocalFlowSchemas,
33
33
  ) {
34
34
  try {
35
35
  const createSourceParams = [];
@@ -51,7 +51,13 @@ async function generateCodeWithTemplate(
51
51
  rootServicePath
52
52
  );
53
53
 
54
- createSourceParams.push(createFunctionIamRole, createSnsSubscription);
54
+ const createTableName = createTableNameConfig(_izContext,
55
+ allObjSchemas,
56
+ allObjectRelationships,
57
+ rootServicePath
58
+ )
59
+
60
+ createSourceParams.push(createFunctionIamRole, createSnsSubscription, createTableName);
55
61
 
56
62
  return createSourceParams;
57
63
  } catch (error) {
@@ -0,0 +1,90 @@
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
+ import path from 'path';
19
+ import { fileURLToPath } from 'url';
20
+ import consts from '#libs/Consts.js';
21
+ import libs from '#libs/Libs.js';
22
+ import utils from '#libs/Utils.js';
23
+
24
+ const __filename = fileURLToPath(import.meta.url);
25
+ const __dirname = path.dirname(__filename);
26
+
27
+ const {
28
+ STORAGE_TYPES,
29
+ SOURCE_PATH,
30
+ SAVE_FILE_NAME
31
+ } = consts;
32
+
33
+ const { createDynamoDbComponentByLinks } = libs;
34
+
35
+ const templatePath = path.join(__dirname, 'template.ejs');
36
+
37
+ /**
38
+ * Creates external SNS subscription configuration
39
+ * @param {Object} _izContext - Context object
40
+ * @param {Array} allObjSchemas - All object schemas
41
+ * @param {Array} allRelSchemas - All relationship schemas
42
+ * @param {Array} allLocalFlowSchemas - All local flow schemas
43
+ * @param {string} rootSchemasPath
44
+ * @returns {Promise<Object>} SNS subscription template config
45
+ */
46
+ function createTableNameConfig(
47
+ _izContext,
48
+ allObjSchemas,
49
+ allRelationshipSchemas,
50
+ appPath
51
+ ) {
52
+
53
+ const tableNames = [];
54
+
55
+ if (allObjSchemas.some(objSchema => objSchema.addOnDataStructure?.some(addOn => addOn.type === 'rbac'))) {
56
+ tableNames.push("Permission", "RolePermissions", "Roles", "UserRoles")
57
+ };
58
+
59
+ for (const objSchema of allObjSchemas) {
60
+ for (const storageResource of Object.values(objSchema.storageResources)) {
61
+ if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
62
+ tableNames.push(storageResource.tableName)
63
+ }
64
+ }
65
+ };
66
+
67
+ for (const relSchema of allRelationshipSchemas) {
68
+ const relData = Object.values(relSchema);
69
+ for (const storageResource of Object.values(relData[0].storageResources)) {
70
+ if (storageResource.storagetype === STORAGE_TYPES.dynamoDB) {
71
+ const { resourceNameFrom, resourceNameTo } = createDynamoDbComponentByLinks(relData.links, Object.keys(relSchema)[0])
72
+ tableNames.push(resourceNameFrom, resourceNameTo)
73
+ }
74
+ }
75
+ }
76
+
77
+ // console.log("tableNames", tableNames)
78
+ return {
79
+ templatePath,
80
+ templateData: { tableNames },
81
+ setting: {
82
+ savePath: path.join(appPath, SOURCE_PATH.externalService),
83
+ saveFileName: SAVE_FILE_NAME.tableName,
84
+ fileExtension: '.js',
85
+ isAppend: true
86
+ }
87
+ };
88
+ }
89
+
90
+ export default createTableNameConfig;
@@ -0,0 +1,43 @@
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
+ /*
19
+ Copyright (C) 2020 Sven Mason <http://izara.io>
20
+
21
+ This program is free software: you can redistribute it and/or modify
22
+ it under the terms of the GNU Affero General Public License as
23
+ published by the Free Software Foundation, either version 3 of the
24
+ License, or (at your option) any later version.
25
+
26
+ This program is distributed in the hope that it will be useful,
27
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
28
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29
+ GNU Affero General Public License for more details.
30
+
31
+ You should have received a copy of the GNU Affero General Public License
32
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
33
+ */
34
+
35
+ const generatedTableNameConfig = [
36
+ <% tableNames.forEach(tableName => { %>
37
+ {<%- tableName %>: {},},
38
+ <% }) %>
39
+ ]
40
+
41
+ export {
42
+ generatedTableNameConfig
43
+ }
@@ -5,6 +5,8 @@ import relationshipPerActionComponent from './relationshipPerActionComponent/ind
5
5
  import processLogicalComponent from './processLogicalComponent/index.js';
6
6
  import processLogicalPaginateComponent from './processLogicalPaginationComponent/index.js';
7
7
  import findDataComponent from './findDataComponent/index.js';
8
+ import systemTextTagComponent from './generateTextTag/index.js';
9
+ import rbacComponent from './rbac/index.js'
8
10
 
9
11
  /**
10
12
  * Generates code from templates based on object schemas
@@ -21,6 +23,7 @@ async function generateTemplateDataFromSchema(
21
23
  allObjSchemas,
22
24
  allRelationshipSchemas,
23
25
  allLocalFlowSchemas,
26
+ localNotificationSystem,
24
27
  settings
25
28
  ) {
26
29
  try {
@@ -50,7 +53,9 @@ async function generateTemplateDataFromSchema(
50
53
  relationshipParams,
51
54
  processLogicalParams,
52
55
  processLogicalPaginateParams,
53
- findDataParams
56
+ findDataParams,
57
+ systemTextParams,
58
+ rbacParams,
54
59
  ] = await Promise.all([
55
60
  endpointComponent(
56
61
  _izContext,
@@ -79,11 +84,13 @@ async function generateTemplateDataFromSchema(
79
84
  appPath,
80
85
  allObjSchemas.records
81
86
  ),
82
- findDataComponent(_izContext, appPath, allObjSchemas, settings)
87
+ findDataComponent(_izContext, appPath, allObjSchemas, settings),
88
+ systemTextTagComponent(_izContext, appPath, allObjSchemas, allRelationshipSchemas, allLocalFlowSchemas, localNotificationSystem),
89
+ rbacComponent(_izContext, appPath, allObjSchemas, settings)
83
90
  ]);
84
91
 
85
92
  console.info(
86
- `[Schema] components generated endpoint=${endpointParams.length} endpointComplete=${endpointCompleteParams.length} resourceYaml=${resourceYamlParams.length} relationship=${relationshipParams.length} processLogical=${processLogicalParams.length} processLogicalPaginate=${processLogicalPaginateParams.length} findData=${findDataParams.length}`
93
+ `[Schema] components generated endpoint=${endpointParams.length} \nendpointComplete=${endpointCompleteParams.length} \nresourceYaml=${resourceYamlParams.length} \nrelationship=${relationshipParams.length} \nprocessLogical=${processLogicalParams.length} \nprocessLogicalPaginate=${processLogicalPaginateParams.length} \nfindData=${findDataParams.length} \nsystemText=${systemTextParams.length} \nrbac=${rbacParams.length}`
87
94
  );
88
95
 
89
96
  const allCreateSourceParams = [
@@ -93,7 +100,9 @@ async function generateTemplateDataFromSchema(
93
100
  ...relationshipParams,
94
101
  ...processLogicalParams,
95
102
  ...processLogicalPaginateParams,
96
- ...findDataParams
103
+ ...findDataParams,
104
+ ...systemTextParams,
105
+ ...rbacParams
97
106
  ];
98
107
 
99
108
  const uniqueSortedTargetFiles = Array.from(
@@ -25,10 +25,10 @@ import {
25
25
  consts,
26
26
  } from '@izara_project/izara-core-library-service-schemas';
27
27
 
28
- const { TOPIC_NAME_GENERATE_CODE } = consts;
29
- const PREFIX = {
30
- updateNode: 'updateNode',
31
- };
28
+ const { TOPIC_NAME_GENERATE_CODE, PREFIX } = consts;
29
+ // const PREFIX = {
30
+ // updateNode: 'updateNode',
31
+ // };
32
32
 
33
33
  //(<optionalRequire>)
34
34
  //(</optionalRequire>)
@@ -84,15 +84,6 @@ export default async function getMain(
84
84
  const objectSchema = await getObjSchemaS3WithHierarchy(_izContext, objType);
85
85
  _izContext.logger.debug('objectSchema:', objectSchema);
86
86
 
87
- // ── Validate user context ─────────────────────────────────────────────────
88
- if (objectSchema.generatedBy === 'userGenerated') {
89
- const userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID);
90
- const targetId = _izContext.correlationIds.get(coreConsts.TARGET_ID);
91
- if (!userId) throw new Error('Not have userId');
92
- if (objectSchema.hasOwnProperty('belongTo') && !targetId)
93
- throw new Error('not have targetId');
94
- }
95
-
96
87
  // ── Build getDataDetails ──────────────────────────────────────────────────
97
88
  const getDataDetails = await createGetDataDetails(_izContext, objectSchema);
98
89
  _izContext.logger.debug('getDataDetails:', getDataDetails);
@@ -253,9 +253,9 @@ async function data(
253
253
  const resourceApis =
254
254
  handler === HANDLER.hdrApi
255
255
  ? allObjSchemas.map(objectSchema => ({
256
- event: lowerCase(objectSchema.objectType),
257
- method: HTTP_METHOD[action]
258
- }))
256
+ event: lowerCase(objectSchema.objectType),
257
+ method: HTTP_METHOD[action]
258
+ }))
259
259
  : [];
260
260
 
261
261
  // ── External topic SNS permissions (create only) ──────────────────────────
@@ -19,23 +19,26 @@ import { join } from 'path';
19
19
 
20
20
  import libs from '#libs/Utils.js';
21
21
 
22
- const { checkValidTableYaml } = libs;
23
- import createSourceTranslations from './translations/data.js';
22
+ import createSourceSystemText from './systemText/data.js';
24
23
 
25
- async function translationComponent(
24
+ async function systemTextComponent(
26
25
  _izContext,
27
26
  appPath,
28
27
  allObjSchemas,
29
- allFlowSchemas
28
+ allRelationshipSchemas,
29
+ allFlowSchemas,
30
+ notificationSchemas
30
31
  ) {
31
32
  try {
32
33
  const objSchemaPath = join(appPath, '/src/schemas');
33
34
 
34
35
  const createSources = [];
35
- const translationComponent = await createSourceTranslations(
36
+ const translationComponent = await createSourceSystemText(
36
37
  _izContext,
37
- allObjSchemas,
38
+ allObjSchemas.records,
39
+ allRelationshipSchemas,
38
40
  allFlowSchemas,
41
+ notificationSchemas,
39
42
  objSchemaPath
40
43
  );
41
44
 
@@ -52,4 +55,4 @@ async function translationComponent(
52
55
  }
53
56
  }
54
57
 
55
- export default translationComponent;
58
+ export default systemTextComponent;
@@ -40,47 +40,82 @@ import { utils as coreUtils } from '@izara_project/izara-core-library-service-sc
40
40
  *
41
41
  * @return {{ templatePath, templateData, setting } }
42
42
  */
43
- function createSourceTranslations(
43
+ function createSourceSystemText(
44
44
  _izContext,
45
45
  allObjectSchema,
46
+ allRelSchema,
46
47
  allFlowSchemas,
48
+ notificationSchemas,
47
49
  schemaPath
48
50
  ) {
49
51
  const createSourceArray = [];
50
52
  // console.log("params objSchema", JSON.stringify(allObjectSchema, null, 2));
51
- for (const objectSchema of allObjectSchema.records) {
52
- for (const fieldName of Object.keys(objectSchema.fieldNames)) {
53
+ for (const objectSchema of allObjectSchema) {
54
+ const fieldNames = [...Object.keys(objectSchema.fieldNames)];
55
+ if (objectSchema.hasOwnProperty("addOnDataStructure")) {
56
+ for (const addOn of objectSchema.addOnDataStructure) {
57
+ if (addOn.type === "versionedData") {
58
+ fieldNames.push(...Object.keys(addOn.fieldNames))
59
+ }
60
+ }
61
+ };
62
+
63
+ for (const fieldName of fieldNames) {
53
64
  const objType = {
54
65
  objectType: objectSchema.objectType,
55
66
  serviceTag: getLocalConfig('iz_serviceTag')
56
67
  };
57
- const translationTextObjSchemas = {
68
+ const systemTextObjectSchemas = {
58
69
  nameSpace: `${coreUtils.createObjTypeConcat(_izContext, objType)}_description`, // for each objectType
59
70
  systemTextTag: `${fieldName}_${coreUtils.createObjTypeConcat(_izContext, objType)}` // for each fieldName
60
71
  };
61
- createSourceArray.push(translationTextObjSchemas);
72
+ createSourceArray.push(systemTextObjectSchemas);
62
73
  }
63
74
  }
64
75
 
65
- for (const flowSchema of allFlowSchemas.records) {
76
+ for (const flowSchema of allFlowSchemas) {
66
77
  const flowType = {
67
78
  flowTag: flowSchema.flowTag,
68
79
  serviceTag: getLocalConfig('iz_serviceTag')
69
80
  };
70
- const translationTextFlowSchemas = {
81
+ const systemTextFlowSchemas = {
71
82
  nameSpace: `${coreUtils.createFlowTypeConcat(_izContext, flowType)}`, // for each flowType
72
83
  systemTextTag: `errors_${coreUtils.createFlowTypeConcat(_izContext, flowType)}`
73
84
  };
74
- createSourceArray.push(translationTextFlowSchemas);
85
+ createSourceArray.push(systemTextFlowSchemas);
75
86
  }
76
87
 
88
+ for (const relSchema of allRelSchema) {
89
+ const relTag = Object.keys(relSchema)[0]
90
+ const relType = {
91
+ serviceTag: getLocalConfig('iz_serviceTag'),
92
+ relationshipTag: relTag
93
+ };
94
+
95
+ for (const fieldName of Object.keys(relSchema[relTag].fieldNames)) {
96
+ const systemTextRelSchemas = {
97
+ nameSpace: `${coreUtils.createRelTypeConcat(_izContext, relType)}_description`,
98
+ systemTextTag: `${fieldName}_${coreUtils.createRelTypeConcat(_izContext, relType)}`
99
+ }
100
+ createSourceArray.push(systemTextRelSchemas);
101
+ }
102
+ }
103
+ console.log("notificationSchemas", notificationSchemas);
104
+ for (const notification of notificationSchemas) {
105
+ const notificationSystemText = {
106
+ nameSpace: `sysNotification_${notification.notificationGrouping}`,
107
+ systemTextTag: notification.notificationTag
108
+ }
109
+ createSourceArray.push(notificationSystemText)
110
+ }
111
+ // console.log("schemaPath", schemaPath)
77
112
  // console.log("createSourceArray", createSourceArray)
78
113
  return {
79
114
  templatePath: templatePath,
80
115
  templateData: { datas: createSourceArray },
81
116
  setting: {
82
- savePath: path.join(schemaPath, SOURCE_PATH.translationSchema),
83
- saveFileName: SAVE_FILE_NAME.translationSchema,
117
+ savePath: path.join(schemaPath, SOURCE_PATH.systemTextSchema),
118
+ saveFileName: SAVE_FILE_NAME.systemTextSchema,
84
119
  fileExtension: '.js',
85
120
  isAppend: true,
86
121
  generateHookFile: false
@@ -88,4 +123,4 @@ function createSourceTranslations(
88
123
  };
89
124
  }
90
125
 
91
- export default createSourceTranslations;
126
+ export default createSourceSystemText;
@@ -0,0 +1,74 @@
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
+ import path from 'path';
19
+ import { fileURLToPath } from 'url';
20
+ const __filename = fileURLToPath(import.meta.url);
21
+ const __dirname = path.dirname(__filename);
22
+
23
+ import consts from '#libs/Consts.js';
24
+ const { SOURCE_PATH, SAVE_FILE_NAME } = consts;
25
+ const templatePath = path.join(__dirname, '../../../resourceYamlComponent/dynamodb/template.ejs');
26
+
27
+ /**
28
+ * create param of crateSouce for FindData And processLogical
29
+ *
30
+ * @param {Object} _izContext
31
+ * @param {String} srcPath
32
+ * @returns {Object[]}
33
+ */
34
+ const createAwaitingMultipleStepDynamoDbData = (_izContext, srcPath) => {
35
+ let resultsForCreateSource = [];
36
+ const defaultDynamoDataLists = [];
37
+
38
+ defaultDynamoDataLists.push(
39
+ {
40
+ tableName: 'RolePermissions',
41
+ resourceName: 'RolePermissions',
42
+ attributes: [
43
+ {
44
+ keyType: 'partitionKey',
45
+ AttributeName: 'userId',
46
+ AttributeType: 'S'
47
+ },
48
+ {
49
+ keyType: 'sortKey',
50
+ AttributeName: 'flowTypeWithTargetIdConcat',
51
+ AttributeType: 'S'
52
+ }
53
+ ]
54
+ }
55
+ );
56
+
57
+ for (let defaultlDynamoData of defaultDynamoDataLists) {
58
+ resultsForCreateSource.push({
59
+ templatePath: templatePath,
60
+ templateData: defaultlDynamoData,
61
+ setting: {
62
+ initialData: 'Resources:\n',
63
+ savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
64
+ saveFileName: SAVE_FILE_NAME.dynamoDbYaml,
65
+ fileExtension: '.yml',
66
+ isAppend: true
67
+ }
68
+ });
69
+ };
70
+
71
+ return resultsForCreateSource;
72
+ };
73
+
74
+ export default createAwaitingMultipleStepDynamoDbData;
@@ -0,0 +1,68 @@
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
+ // Import required modules
19
+ import { join } from 'path';
20
+ import { getObjectSchema } from '@izara_project/izara-core-library-service-schemas';
21
+ const { getAllLocalObjectSchemasWithHierarchy } = getObjectSchema;
22
+
23
+ // auth for api
24
+ import authHandler from './lambda/handler/data.js'
25
+ import authMainFunction from './lambda/mainFunction/data.js'
26
+ // yaml
27
+ import authYaml from './lambda/yaml/data.js';
28
+ // dynamo
29
+ import dynamo from './dynamoDb/data.js';
30
+
31
+ /**
32
+ * Generates code with templates for different actions
33
+ * @param {Object} _izContext - Context object
34
+ * @param {string} appPath - Path to the schema
35
+ * @returns {Array} Array of generated code parameters
36
+ */
37
+ async function generateCodeWithTemplate(
38
+ _izContext,
39
+ appPath,
40
+ allObjSchemas,
41
+ ) {
42
+ try {
43
+ const createSourceParams = [];
44
+ if (allObjSchemas.records.some(objectSchema => objectSchema.addOnDataStructure?.some(addOn => addOn.type === 'rbac'))) {
45
+ const yamlInvComponent = await authYaml(_izContext, appPath);
46
+ const dynamoRbacPermission = dynamo(_izContext, appPath);
47
+ const handler = authHandler(_izContext, appPath);
48
+ const mainFunction = authMainFunction(_izContext, appPath);
49
+
50
+ createSourceParams.push(
51
+ ...yamlInvComponent,
52
+ ...dynamoRbacPermission,
53
+ handler,
54
+ mainFunction
55
+ );
56
+
57
+ }
58
+
59
+
60
+
61
+ return createSourceParams;
62
+ } catch (error) {
63
+ _izContext.logger.error('Error generating code with template:', error);
64
+ return [];
65
+ }
66
+ }
67
+
68
+ export default generateCodeWithTemplate;
@@ -0,0 +1,69 @@
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
+ // yaml data.js
19
+ import path from 'path';
20
+ import { fileURLToPath } from 'url';
21
+ import consts from '#libs/Consts.js';
22
+ import utils from '#libs/Utils.js';
23
+ import libs from '#libs/Libs.js';
24
+
25
+ const __filename = fileURLToPath(import.meta.url);
26
+ const __dirname = path.dirname(__filename);
27
+
28
+ const {
29
+ SOURCE_PATH,
30
+ HANDLER
31
+ } = consts;
32
+
33
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } =
34
+ utils;
35
+
36
+ const templatePathInv = path.join(__dirname, 'template.ejs');
37
+
38
+
39
+ /**
40
+ * Generates yaml source params for a given action and handler
41
+ * @param {Object} _izContext - Context object with logger
42
+ * @param {Array} allObjSchemas - All object schemas
43
+ * @param {string} appPath - Source path
44
+ * @param {string} action - Action name (create/update/get/delete)
45
+ * @param {string} handler - Handler type (hdrApi/hdrSqs/hdrDsq/hdrInv)
46
+ * @param {string|null} functionNameConfig - Override for yaml key (null = derive from action+handler)
47
+ * @param {string} handlerSuffix - Suffix for fnName across all fields (e.g. 'BeforeLogical')
48
+ * @returns {Promise<Array>} Array containing source param object
49
+ */
50
+ function data(
51
+ _izContext,
52
+ appPath,
53
+ ) {
54
+ const functionName = "Authorization";
55
+ const fileName = `${upperCase(functionName)}_${upperCase(HANDLER.hdrInv)}`;
56
+
57
+ return {
58
+ templatePath: templatePathInv,
59
+ templateData: { functionName },
60
+ setting: {
61
+ savePath: path.join(appPath, SOURCE_PATH.rbac),
62
+ saveFileName: fileName,
63
+ fileExtension: '.js',
64
+ isAppend: true
65
+ }
66
+ };
67
+ }
68
+
69
+ export default data;
@@ -0,0 +1,52 @@
1
+ /*
2
+ Copyright (C) 2020 Sven Mason <http://izara.io>
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Affero General Public License as
6
+ published by the Free Software Foundation, either version 3 of the
7
+ License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Affero General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Affero General Public License
15
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+
19
+
20
+ import { middlewareHandler as middleware } from "@izara_project/izara-middleware";
21
+ import Logger from '@izara_project/izara-core-library-logger';
22
+ import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
23
+
24
+ import <%- functionName %> from './<%- functionName %>_Main.js';
25
+
26
+ // validate event params in middleware before into function.
27
+ const validatorSchema = {
28
+ //(<validatorSchema>)
29
+ //(</validatorSchema>)
30
+ };
31
+ middleware.setValidatorSchema(validatorSchema)
32
+
33
+ export const main = middleware.wrap(async (event, context, callback) => {
34
+ event._izContext.logger.debug('Event:', event);
35
+ event._izContext.logger.debug('context:', context);
36
+
37
+ try {
38
+
39
+ // invoke LambdaFunction
40
+ return await <%- functionName %>(
41
+ event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId
42
+ event,
43
+ callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
44
+ //(<additionalParams>)
45
+ //(</additionalParams>)
46
+ );
47
+
48
+ } catch (err) {
49
+ event._izContext.logger.error('Error, LambdaFunctionHdrInv: ', err);
50
+ throw (err);
51
+ }
52
+ });
@@ -0,0 +1,82 @@
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
+ // yaml data.js
19
+ import path from 'path';
20
+ import { fileURLToPath } from 'url';
21
+ import fs from 'fs';
22
+ import yaml from 'yaml';
23
+ import { objectHash as hash } from '@izara_project/izara-shared-core';
24
+ import consts from '#libs/Consts.js';
25
+ import utils from '#libs/Utils.js';
26
+ import libs from '#libs/Libs.js';
27
+
28
+ const __filename = fileURLToPath(import.meta.url);
29
+ const __dirname = path.dirname(__filename);
30
+
31
+ const {
32
+ RESOURCE_CLASSES,
33
+ SOURCE_PATH,
34
+ SAVE_FILE_NAME,
35
+ LAMBDA_RESOURCE
36
+ } = consts;
37
+
38
+ const {
39
+ createIamRole,
40
+ defaultIamRolePerAction,
41
+ externalResourceYaml
42
+ } = libs;
43
+
44
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } =
45
+ utils;
46
+
47
+ const templatePath = path.join(__dirname, 'template.ejs');
48
+
49
+ /**
50
+ * Generates yaml source params for a given action and handler
51
+ * @param {Object} _izContext - Context object with logger
52
+ * @param {Array} allObjSchemas - All object schemas
53
+ * @param {string} appPath - Source path
54
+ * @param {string} action - Action name (create/update/get/delete)
55
+ * @param {string} handler - Handler type (hdrApi/hdrSqs/hdrDsq/hdrInv)
56
+ * @param {string|null} functionNameConfig - Override for yaml key (null = derive from action+handler)
57
+ * @param {string} handlerSuffix - Suffix for fnName across all fields (e.g. 'BeforeLogical')
58
+ * @returns {Promise<Array>} Array containing source param object
59
+ */
60
+ function data(
61
+ _izContext,
62
+ appPath,
63
+ ) {
64
+ const functionName = "Authorization";
65
+ const fileName = upperCase(functionName) + '_Main';
66
+
67
+ return {
68
+ templatePath,
69
+ templateData: {
70
+ functionName
71
+ },
72
+ setting: {
73
+ savePath: path.join(appPath, SOURCE_PATH.rbac),
74
+ saveFileName: fileName,
75
+ fileExtension: '.js',
76
+ isAppend: true
77
+ }
78
+ }
79
+
80
+ };
81
+
82
+ export default data;
@@ -0,0 +1,111 @@
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
16
+ <http: //www.gnu.org/licenses />.
17
+ */
18
+
19
+ import { consts } from '@izara_project/izara-core-library-core';
20
+ import dynamoDBSharedLibs from '@izara_project/izara-core-library-dynamodb';
21
+ import { utils } from '@izara_project/izara-core-library-service-schemas';
22
+ import snsSharedLib from '@izara_project/izara-core-library-sns';
23
+ import { sns } from '@izara_project/izara-core-library-external-request';
24
+ import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
25
+
26
+ //(<optionalRequire>)
27
+ //(</optionalRequire>)
28
+
29
+ /**
30
+ * Gets an object by processing storage resources (DynamoDB, Graph)
31
+ * @param {Object} _izContext - Context object with logger
32
+ * @param {Object} requestParams - { objectType, identifiers, additionalParams }
33
+ * @param {Object} callingFlowConfig - Calling flow configuration
34
+ * @returns {Promise<Object>} Collected get result
35
+ */
36
+ export default async function Authorization(
37
+ _izContext,
38
+ requestParams,
39
+ callingFlowConfig = {}
40
+ ) {
41
+ try {
42
+ _izContext.logger.debug('rbacValidator ::: ', {
43
+ requestParams,
44
+ callingFlowConfig
45
+ });
46
+
47
+ const identifier = requestParams?.identifier || null;
48
+ let flowTypeConcat = requestParams?.flowTypeConcat || null;
49
+
50
+ if (!identifier || !flowTypeConcat) {
51
+ throw new Error(
52
+ 'Missing required request parameters: identifier or flowTagConcat'
53
+ );
54
+ }
55
+ if (typeof flowTypeConcat === 'object') {
56
+ flowTypeConcat = utils.createFlowTypeConcat(flowTypeConcat)
57
+ }
58
+
59
+ if (typeof flowTypeConcat !== 'string') {
60
+ throw new Error('flowTypeConcat must be a string');
61
+ }
62
+
63
+ const userId = _izContext.correlationIds.get(consts.BASE_USER_ID);
64
+ _izContext.logger.debug('userId', userId);
65
+
66
+ if (!userId) {
67
+ throw new Error('User ID not found in correlation IDs');
68
+ };
69
+
70
+ const targetId = _izContext.correlationIds.get(consts.TARGET_ID);
71
+ _izContext.logger.debug('targetId', targetId);
72
+
73
+ if (!targetId) {
74
+ throw new Error('Target ID not found in correlation IDs');
75
+ };
76
+
77
+ const rolePermissionTableName = dynamoDBSharedLibs.tableName(_izContext, "RolePermission");
78
+
79
+ const resultRolePermissions = await dynamoDBSharedLibs.getItem(_izContext, rolePermissionTableName, {
80
+ userId: userId,
81
+ flowTypeWithTargetIdConcat: `${flowTypeConcat}_${targetId}`
82
+ });
83
+
84
+ if (!resultRolePermissions) {
85
+ throw new Error('User roles not found for the given user');
86
+ };
87
+
88
+ if (resultRolePermissions.permission === true) {
89
+ // will check app level permission
90
+ const messageObject = {
91
+ requestParams: {
92
+ identifier: identifier,
93
+ flowTypeConcat: flowTypeConcat,
94
+ },
95
+ callingFlow: callingFlowConfig || {}
96
+ };
97
+
98
+
99
+ const sendMessageToCheckRbacAppLevel = {
100
+ Message: JSON.stringify(messageObject),
101
+ TopicArn: snsSharedLib.snsTopicArnByFlowSchema(_izContext, "RbacValidator_In", "TestRbac")
102
+ };
103
+
104
+ await sns.publishAsync(_izContext, sendMessageToCheckRbacAppLevel)
105
+ };
106
+
107
+ } catch (err) {
108
+ _izContext.logger.error('error GetMain:', err);
109
+ throw err;
110
+ }
111
+ }
@@ -0,0 +1,106 @@
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
+ // yaml data.js
19
+ import path from 'path';
20
+ import { fileURLToPath } from 'url';
21
+ import consts from '#libs/Consts.js';
22
+ import utils from '#libs/Utils.js';
23
+ import libs from '#libs/Libs.js';
24
+
25
+ const __filename = fileURLToPath(import.meta.url);
26
+ const __dirname = path.dirname(__filename);
27
+
28
+ const {
29
+ RESOURCE_CLASSES,
30
+ SOURCE_PATH,
31
+ SAVE_FILE_NAME,
32
+ DYNAMO_RESOURCE,
33
+ SNS_RESOURCE
34
+ } = consts;
35
+
36
+ const {
37
+ createIamRole,
38
+ defaultIamRolePerAction,
39
+ externalResourceYaml,
40
+ resourceNames
41
+ } = libs;
42
+
43
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } =
44
+ utils;
45
+
46
+ const templatePath = path.join(__dirname, 'template.ejs');
47
+
48
+ /**
49
+ * Generates yaml source params for a given action and handler
50
+ * @param {Object} _izContext - Context object with logger
51
+ * @param {Array} allObjSchemas - All object schemas
52
+ * @param {string} appPath - Source path
53
+ * @param {string} action - Action name (create/update/get/delete)
54
+ * @param {string} handler - Handler type (hdrApi/hdrSqs/hdrDsq/hdrInv)
55
+ * @param {string|null} functionNameConfig - Override for yaml key (null = derive from action+handler)
56
+ * @param {string} handlerSuffix - Suffix for fnName across all fields (e.g. 'BeforeLogical')
57
+ * @returns {Promise<Array>} Array containing source param object
58
+ */
59
+ async function data(
60
+ _izContext,
61
+ appPath,
62
+ ) {
63
+ const allCreateSources = [];
64
+ const functionName = "Authorization";
65
+ const additionalResourcePermission = defaultIamRolePerAction();
66
+
67
+ additionalResourcePermission.push(
68
+ createIamRole({
69
+ [RESOURCE_CLASSES.sns]: SNS_RESOURCE.publish,
70
+ },
71
+ externalResourceYaml(RESOURCE_CLASSES.sns, "RbacValidator_In", "TestRbac")),
72
+ createIamRole({
73
+ [RESOURCE_CLASSES.dynamoDbTable]: [DYNAMO_RESOURCE.getItem, DYNAMO_RESOURCE.putItem]
74
+ },
75
+ [
76
+ resourceNames(RESOURCE_CLASSES.dynamoDbTable, "RolePermissions"),
77
+ ])
78
+ );
79
+
80
+ allCreateSources.push(
81
+ {
82
+ templatePath,
83
+ templateData: {
84
+ functionName: functionName,
85
+ handlerPath: path.join(
86
+ SOURCE_PATH.resourceLocationRbac,
87
+ `${functionName}.main`
88
+ ),
89
+ additionalResourcePermission,
90
+ roleName: "Authorization",
91
+ hookTagSetting: `${functionName}FunctionSetting`,
92
+ functionNameConfig: functionName
93
+ },
94
+ setting: {
95
+ savePath: path.join(appPath, SOURCE_PATH.appYaml),
96
+ saveFileName: SAVE_FILE_NAME.rbac,
97
+ fileExtension: '.yml',
98
+ isAppend: true
99
+ }
100
+ }
101
+ );
102
+
103
+ return allCreateSources;
104
+ };
105
+
106
+ export default data;
@@ -0,0 +1,6 @@
1
+ <%- functionNameConfig %>:
2
+ handler: <%- handlerPath %>
3
+ name: ${self:custom.iz_resourcePrefix}<%- functionName %>
4
+ role: <%- roleName %>Role
5
+ #<#<%- hookTagSetting %>#>
6
+ #<#/<%- hookTagSetting %>#>
@@ -37,7 +37,6 @@ import generateTemplateDataInitialSetup from './generateCode/generateInitialSetu
37
37
  import generateTemplateDataOther from './generateCode/generateOther/generateCodeOther.js';
38
38
 
39
39
  import generateTemplateDataRole from './generateCode/generateRole/generateCodeRole.js';
40
- import generateTemplateTranslations from './generateCode/generateTranslation/generateTranslation.js';
41
40
 
42
41
  const __filename = fileURLToPath(import.meta.url);
43
42
  const __dirname = dirname(__filename);
@@ -73,14 +72,15 @@ async function generateCodeWithTemplate(
73
72
  // ── 1. Fetch all schemas ─────────────────────────────────────────────────
74
73
  console.info('[INFO] [generateCode] STATUS=FETCHING | schemas...');
75
74
  const fetchStartTime = Date.now();
76
- const [allLocalFlowSchemas, allObjSchemas, allLocalRelationshipSchemas] =
75
+ const [allLocalFlowSchemas, allObjSchemas, allLocalRelationshipSchemas, allLocalNotificationSystem] =
77
76
  await Promise.all([
78
77
  getObjectSchema.getAllLocalFlowSchemas(_izContext, schemasPath),
79
78
  getObjectSchema.getAllLocalObjectSchemasWithHierarchy(
80
79
  _izContext,
81
80
  schemasPath
82
81
  ),
83
- getObjectSchema.getAllLocalRelationshipSchema(_izContext, schemasPath)
82
+ getObjectSchema.getAllLocalRelationshipSchema(_izContext, schemasPath),
83
+ getObjectSchema.getLocalNotificationSystemSchemas(_izContext, schemasPath)
84
84
  ]);
85
85
 
86
86
  const fetchDuration = Date.now() - fetchStartTime;
@@ -98,7 +98,6 @@ async function generateCodeWithTemplate(
98
98
  schemaResult,
99
99
  initialSetupResult,
100
100
  otherResult,
101
- translationResult
102
101
  ] = await Promise.all([
103
102
  generateTemplateDataFromFlowSchema(
104
103
  _izContext,
@@ -112,6 +111,7 @@ async function generateCodeWithTemplate(
112
111
  allObjSchemas,
113
112
  allLocalRelationshipSchemas,
114
113
  allLocalFlowSchemas.records,
114
+ allLocalNotificationSystem,
115
115
  settings
116
116
  ).catch(error => {
117
117
  console.error('[generateCode] schemaResult error:', error);
@@ -126,13 +126,7 @@ async function generateCodeWithTemplate(
126
126
  allLocalFlowSchemas.records,
127
127
  settings
128
128
  ),
129
- generateTemplateDataOther(_izContext, appPath),
130
- generateTemplateTranslations(
131
- _izContext,
132
- appPath,
133
- allObjSchemas,
134
- allLocalFlowSchemas
135
- )
129
+ generateTemplateDataOther(_izContext, appPath)
136
130
  ]);
137
131
 
138
132
  const genDuration = Date.now() - genStartTime;
@@ -146,7 +140,6 @@ async function generateCodeWithTemplate(
146
140
  ...schemaResult,
147
141
  ...initialSetupResult,
148
142
  ...otherResult,
149
- ...translationResult
150
143
  ];
151
144
 
152
145
  // ── 3. Generate role configs ─────────────────────────────────────────────
@@ -93,8 +93,12 @@ const SOURCE_PATH = {
93
93
  resourceLocationCreateRecordComplete:
94
94
  'src/generatedCode/CreateRecordComplete/',
95
95
 
96
- // translations
97
- translationSchema: 'translations/'
96
+ // systemText
97
+ systemTextSchema: 'SystemTextSchema/generatedCode/',
98
+
99
+ // rbac
100
+ rbac: '/src/generatedCode/Rbac/source/',
101
+ resourceLocationRbac: 'src/generatedCode/Rbac/source/'
98
102
  };
99
103
 
100
104
  const SQS_RESOURCE = {
@@ -146,16 +150,18 @@ const SAVE_FILE_NAME = {
146
150
  sharedResourceYaml: 'generate-shared-resource',
147
151
  authorizerYaml: 'authorizer',
148
152
  findData: 'find-data',
153
+ rbac: 'rbac',
149
154
 
150
155
  externalLambdaRole: 'generatedLambdaRoleServiceConfig',
151
156
  snsSubscription: 'generatedSnsServiceConfig',
152
- translateId: 'TranslateIdsRequest',
157
+ tableName: "generatedTableNameConfig",
158
+ // translateId: 'TranslateIdsRequest',
153
159
  S3Bucket: 'generated-s3-bucket',
154
160
  objectRelationship: 'ObjectRelationships',
155
161
  refObjectRelationship: 'RefObjectRelationships',
156
162
  objectSchema: 'ObjectFieldSchema',
157
163
  roleNameConfig: 'RoleNameConfig',
158
- translationSchema: 'TranslationsSchema'
164
+ systemTextSchema: 'SystemTextSchema'
159
165
  };
160
166
 
161
167
  const FUNCTION_NAME = {
package/src/libs/Libs.js CHANGED
@@ -50,7 +50,9 @@ function resourceNames(resourceClass, resourceName) {
50
50
  'arn:aws:lambda:${self:custom.iz_region}:${self:custom.iz_accountId}:function:${self:custom.iz_resourcePrefix}' +
51
51
  resourceName,
52
52
  [RESOURCE_CLASSES.webSocket]:
53
- 'arn:aws:execute-api:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_webSocketHostId}/${self:custom.iz_stage}/POST/@connections/{connectionId}'
53
+ 'arn:aws:execute-api:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_webSocketHostId}/${self:custom.iz_stage}/POST/@connections/{connectionId}',
54
+ [RESOURCE_CLASSES.s3]:
55
+ 'arn:aws:s3:::${self:custom.iz_serviceSchemaBucketName}/' + resourceName,
54
56
  }[resourceClass];
55
57
  }
56
58
 
@@ -62,6 +64,10 @@ function resourceNames(resourceClass, resourceName) {
62
64
  * @returns {{ effect, action, resource}}
63
65
  */
64
66
  function createIamRole(action, resource = [], effect = 'Allow') {
67
+ if (!Array.isArray(resource)) {
68
+ resource = [resource];
69
+ };
70
+
65
71
  if (Array.isArray(action)) {
66
72
  const actionObj = {};
67
73
  action.forEach(act => {