@izara_project/izara-market-library-service-schemas 1.0.20 → 1.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-market-library-service-schemas",
3
- "version": "1.0.20",
3
+ "version": "1.0.21",
4
4
  "description": "Schemas for Izara Market project",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -22,7 +22,7 @@
22
22
  "dependencies": {
23
23
  "@izara_project/izara-core-library-core": "^1.0.14",
24
24
  "@izara_project/izara-core-library-external-request": "^1.0.17",
25
- "@izara_project/izara-core-library-service-schemas": "^1.0.37",
25
+ "@izara_project/izara-core-library-service-schemas": "^1.0.41",
26
26
  "@izara_project/izara-shared": "^1.0.116",
27
27
  "ejs": "^3.1.10",
28
28
  "js-beautify": "^1.15.1",
@@ -4,12 +4,12 @@
4
4
  name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
5
5
  events:
6
6
  - http:
7
- path: <%- objectType %>/<%- firstLetterUpperCase(action) %>
7
+ path: <%- firstLetterUpperCase(objectType) %>/<%- firstLetterUpperCase(action) %>
8
8
  method: <%- event %>
9
9
  cors: true
10
10
  #<#<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>Authorizer#>
11
11
  #<#/<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>Authorizer#>
12
- role: <%- objectType %>Role
12
+ role: <%- firstLetterUpperCase(objectType) %>Role
13
13
  #<#<%- functionName %><%- handlerType %>IamRole#>
14
14
  #<#/<%- functionName %><%- handlerType %>IamRole#>
15
15
  <%_ function firstLetterUpperCase(text){
@@ -6,7 +6,7 @@
6
6
  - sqs:
7
7
  arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
8
8
  batchSize: 10
9
- role: <%- roleName %>Role
9
+ role: <%- firstLetterUpperCase(roleName) %>Role
10
10
  #<#<%- functionName %><%- handlerType %>IamRole#>
11
11
  #<#/<%- functionName %><%- handlerType %>IamRole#>
12
12
  <%_ function firstLetterUpperCase(text){
@@ -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: <%- objectType %>Role
5
+ role: <%- firstLetterUpperCase(objectType) %>Role
6
6
  #<#<%- functionName %><%- handlerType %>IamRole#>
7
7
  #<#/<%- functionName %><%- handlerType %>IamRole#>
8
8
  <%_ function firstLetterUpperCase(text){
@@ -6,7 +6,7 @@
6
6
  - sqs:
7
7
  arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
8
8
  batchSize: 10
9
- role: <%- roleName %>Role
9
+ role: <%- firstLetterUpperCase(roleName) %>Role
10
10
  #<#<%- functionName %><%- handlerType %>IamRole#>
11
11
  #<#/<%- functionName %><%- handlerType %>IamRole#>
12
12
  <%_ function firstLetterUpperCase(text){
@@ -165,10 +165,10 @@ module.exports.createSharedResource = (_izContext, createSourceParams, srcPath)
165
165
  templateData.functionName.includes('FindData') ||
166
166
  templateData.functionName.includes('ProcessLogical'))) {
167
167
  // Handle ProcessFindData items
168
- groupedByObjectType.ProcessFindData.handlerType.push(templateData.handlerType);
168
+ groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.ProcessFindDataRole].handlerType.push(templateData.handlerType);
169
169
  processResourcePermissions(
170
170
  templateData.additionalResourcePermission,
171
- groupedByObjectType.ProcessFindData.resources
171
+ groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.ProcessFindDataRole].resources
172
172
  );
173
173
  }
174
174
  else {
@@ -199,7 +199,6 @@ module.exports.createSharedResource = (_izContext, createSourceParams, srcPath)
199
199
  });
200
200
  // Prepare results
201
201
 
202
-
203
202
  // Process and prepare data for role definitions and extract any resources
204
203
  // that might be related to object types but weren't categorized properly
205
204
  const roles = [];
@@ -23,61 +23,137 @@ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = req
23
23
  const { SOURCE_PATH } = require('../../libs/Consts');
24
24
  const templateYamlPath = path.join(__dirname, "./templateYaml.ejs");
25
25
  const templatePathIntTestPath = path.join(__dirname, "./templateIntTesting.ejs");
26
+ const { SOURCE_GENERATE_IAM_ROLE } = require("../../libs/Consts");
26
27
 
27
28
 
28
29
  function data(_izContext, createSourceParams, srcPath) {
29
- // console.log("createSourceParams in Data", createSourceParams);
30
- const functionNameConfigs = new Set();
31
- let createFunctionNameConfig = []
32
- for (let { templatePath, templateData, setting } of createSourceParams) {
33
- if (templateData?.functionNameConfig !== undefined) {
34
- functionNameConfigs.add(templateData.functionNameConfig)
30
+
31
+ // ! old code
32
+ // function createFunctionNameConfigFileYaml(functionNameConfigs, srcPath) {
33
+ // let createFunctionNameConfigYaml = []
34
+ // createFunctionNameConfigYaml.push(
35
+ // {
36
+ // templatePath: templateYamlPath,
37
+ // templateData: {
38
+ // functionNameConfigs: functionNameConfigs
39
+ // },
40
+ // setting: {
41
+ // savePath: path.join(srcPath, SOURCE_PATH.appYaml),
42
+ // saveFileName: "FunctionNameConfig",
43
+ // fileExtension: ".yml",
44
+ // isAppend: true
45
+ // }
46
+ // }
47
+ // )
48
+ // return createFunctionNameConfigYaml
49
+ // }
50
+
51
+ // Extract role names from object types in createSourceParams
52
+ const roleNameConfigs = new Set();
53
+ const roleNameConcatConfigs = new Set();
54
+
55
+ // Add default IAM roles from configuration
56
+ Object.entries(SOURCE_GENERATE_IAM_ROLE)
57
+ .filter(([_, enabled]) => enabled)
58
+ .forEach(([_, value]) => {
59
+ roleNameConfigs.add(`${upperCase(value)}Role`);
60
+ roleNameConcatConfigs.add(`${upperCase(value)}`);
61
+ });
62
+
63
+ for (const { templateData } of createSourceParams) {
64
+ if (templateData?.objectType) {
65
+ roleNameConfigs.add(`${upperCase(templateData.objectType)}Role`);
66
+ roleNameConcatConfigs.add(`${upperCase(templateData.objectType)}`);
35
67
  }
36
68
  }
37
- let createFunctionNameConfigYaml = createFunctionNameConfigFileYaml(functionNameConfigs, srcPath);
38
- let createFunctionNameConfigJs = createFunctionNameConfigFileJs(functionNameConfigs, srcPath);
39
- createFunctionNameConfig.push(...createFunctionNameConfigYaml, ...createFunctionNameConfigJs)
40
- return createFunctionNameConfig
41
69
 
70
+ // Generate YAML and JS configurations
71
+ const roleConfigYaml = createRoleNameConfigFileYaml(roleNameConfigs, srcPath);
72
+ const roleConfigJs = createRoleNameConfigFileJs(roleNameConcatConfigs, srcPath);
73
+
74
+ // Combine and return all configurations
75
+ return [...roleConfigYaml, ...roleConfigJs];
42
76
  }
43
77
 
44
- function createFunctionNameConfigFileYaml(functionNameConfigs, srcPath) {
45
- let createFunctionNameConfigYaml = []
46
- createFunctionNameConfigYaml.push(
78
+
79
+ // ! old code
80
+ // function createFunctionNameConfigFileYaml(functionNameConfigs, srcPath) {
81
+ // let createFunctionNameConfigYaml = []
82
+ // createFunctionNameConfigYaml.push(
83
+ // {
84
+ // templatePath: templateYamlPath,
85
+ // templateData: {
86
+ // functionNameConfigs: functionNameConfigs
87
+ // },
88
+ // setting: {
89
+ // savePath: path.join(srcPath, SOURCE_PATH.appYaml),
90
+ // saveFileName: "FunctionNameConfig",
91
+ // fileExtension: ".yml",
92
+ // isAppend: true
93
+ // }
94
+ // }
95
+ // )
96
+ // return createFunctionNameConfigYaml
97
+ // }
98
+
99
+ // ! old code
100
+ // function createFunctionNameConfigFileJs(functionNameConfigs, srcPath) {
101
+ // let createFunctionNameConfigJs = []
102
+ // createFunctionNameConfigJs.push(
103
+ // {
104
+ // templatePath: templatePathIntTestPath,
105
+ // templateData: {
106
+ // functionNameConfigs: functionNameConfigs
107
+ // },
108
+ // setting: {
109
+ // savePath: path.join(srcPath, SOURCE_PATH.externalService),
110
+ // saveFileName: "FunctionNameConfig",
111
+ // fileExtension: ".js",
112
+ // isAppend: true
113
+ // }
114
+ // }
115
+ // )
116
+
117
+ // return createFunctionNameConfigJs
118
+ // }
119
+
120
+ function createRoleNameConfigFileYaml(roleNameConfigs, srcPath) {
121
+ let createRoleNameConfigYaml = []
122
+ createRoleNameConfigYaml.push(
47
123
  {
48
124
  templatePath: templateYamlPath,
49
125
  templateData: {
50
- functionNameConfigs: functionNameConfigs
126
+ roleNameConfigs: roleNameConfigs
51
127
  },
52
128
  setting: {
53
129
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
54
- saveFileName: "FunctionNameConfig",
130
+ saveFileName: "RoleNameConfig",
55
131
  fileExtension: ".yml",
56
132
  isAppend: true
57
133
  }
58
134
  }
59
135
  )
60
- return createFunctionNameConfigYaml
136
+ return createRoleNameConfigYaml
61
137
  }
62
138
 
63
- function createFunctionNameConfigFileJs(functionNameConfigs, srcPath) {
64
- let createFunctionNameConfigJs = []
65
- createFunctionNameConfigJs.push(
139
+ function createRoleNameConfigFileJs(roleNameConfigs, srcPath) {
140
+ let createRoleNameConfigJs = []
141
+ createRoleNameConfigJs.push(
66
142
  {
67
143
  templatePath: templatePathIntTestPath,
68
144
  templateData: {
69
- functionNameConfigs: functionNameConfigs
145
+ roleNameConfigs: roleNameConfigs
70
146
  },
71
147
  setting: {
72
148
  savePath: path.join(srcPath, SOURCE_PATH.externalService),
73
- saveFileName: "FunctionNameConfig",
149
+ saveFileName: "RoleNameConfig",
74
150
  fileExtension: ".js",
75
151
  isAppend: true
76
152
  }
77
153
  }
78
154
  )
79
155
 
80
- return createFunctionNameConfigJs
156
+ return createRoleNameConfigJs
81
157
  }
82
158
 
83
159
  module.exports = data;
@@ -17,13 +17,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
 
18
18
  'use strict';
19
19
 
20
- module.exports.generatedIntTestFunctionNameConfig = () => {
21
- let functionNameConfigIntTest = [
22
- <% functionNameConfigs.forEach(functionNameConfig => { _%>
23
- "<%- firstLetterUpperCase(functionNameConfig) %>",
20
+ module.exports.generatedIntTestRoleNameConfig = () => {
21
+ let roleNameConfigIntTest = [
22
+ <% roleNameConfigs.forEach(roleNameConfig => { _%>
23
+ "<%- firstLetterUpperCase(roleNameConfig) %>",
24
24
  <% }) _%>
25
25
  ]
26
- return functionNameConfigIntTest
26
+ return roleNameConfigIntTest
27
27
  }
28
28
 
29
29
  <%_function firstLetterUpperCase(text) {
@@ -1,7 +1,7 @@
1
1
  # for createIamRole
2
2
 
3
- <% functionNameConfigs.forEach(functionNameConfig => { _%>
4
- - ${self:custom.iz_prefixIamRole}<%- firstLetterUpperCase(functionNameConfig) %>${self:custom.iz_suffixIamRole}
3
+ <% roleNameConfigs.forEach(roleNameConfig => { _%>
4
+ - arn:aws:iam::${self:custom.iz_accountId}:role/${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(roleNameConfig) %>
5
5
  <% }) _%>
6
6
 
7
7
 
@@ -25,11 +25,12 @@ const { getGraphServiceNameFromGraphServerTagWithCache,
25
25
  } = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig')
26
26
 
27
27
  const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../MainLibs/src/Utils")
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 } = require("../../libs/Consts");
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
31
  const { getAllLocalRelationshipSchemas } = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
32
32
  const { EXTERNAL_SERVICE_NAME } = require("../../../../GenerateCodeLibs/src/Consts")
33
+
33
34
  const createExternalLambdaRole = async (_izContext, allObjSchemas, allRelSchemas, allLocalFlowSchemas, srcPath) => {
34
35
  const allRelationshipSchemas = getAllLocalRelationshipSchemas(_izContext, srcPath)
35
36
  // console.log("allRelationshipSchemas", allRelationshipSchemas);
@@ -78,7 +79,6 @@ const createExternalLambdaRole = async (_izContext, allObjSchemas, allRelSchemas
78
79
  const externalLambdaIamRoleFindData = externalLambdaIamRoleDataFindData(_izContext);
79
80
  externalLambdaIamRoleFindData && externalLambdaIamRoleArray.push(externalLambdaIamRoleFindData)
80
81
 
81
-
82
82
  // updateRelationshipComplete external lambda role
83
83
 
84
84
  // ... another external lambda role data
@@ -195,6 +195,7 @@ async function externalLambdaIamRoleDataPerAction(_izContext, objectSchema, acti
195
195
 
196
196
 
197
197
  return {
198
+ objectType: upperCase(objectType),
198
199
  functionName: functionName,
199
200
  action: action,
200
201
  additionalResourcePermission
@@ -207,7 +208,7 @@ async function externalLambdaIamRoleDataUpdateRelationshipSchema(_izContext, all
207
208
  const functionName = upperCase(SHORT_FUNCTION_NAME.updateRel) + upperCase(shortNameHandler(handler));
208
209
  const additionalResourcePermission = [];
209
210
  const graphServiceNamesFromAllRelSchemas = await getGraphServiceNameFromAllRelSchema(_izContext, allRelSchemas);
210
-
211
+ const objectType = SOURCE_GENERATE_IAM_ROLE.RelationshipRole
211
212
 
212
213
  additionalResourcePermission.push(
213
214
  createIamRole(
@@ -222,7 +223,8 @@ async function externalLambdaIamRoleDataUpdateRelationshipSchema(_izContext, all
222
223
 
223
224
  return {
224
225
  functionName,
225
- additionalResourcePermission
226
+ additionalResourcePermission,
227
+ objectType
226
228
  }
227
229
  }
228
230
 
@@ -233,6 +235,7 @@ async function externalLambdaIamRoleDataCreateRelationshipSchema(_izContext, all
233
235
  const functionName = upperCase(SHORT_FUNCTION_NAME.createRel) + upperCase(shortNameHandler(handler));
234
236
  const additionalResourcePermission = [];
235
237
  const graphServiceNamesFromAllRelSchemas = await getGraphServiceNameFromAllRelSchema(_izContext, allRelSchemas);
238
+ const objectType = SOURCE_GENERATE_IAM_ROLE.RelationshipRole
236
239
 
237
240
  additionalResourcePermission.push(
238
241
  createIamRole(
@@ -246,7 +249,8 @@ async function externalLambdaIamRoleDataCreateRelationshipSchema(_izContext, all
246
249
  )
247
250
  return {
248
251
  functionName,
249
- additionalResourcePermission
252
+ additionalResourcePermission,
253
+ objectType
250
254
  }
251
255
  }
252
256
 
@@ -255,6 +259,7 @@ async function externalLambdaIamRoleDataDeleteRelationshipSchema(_izContext, all
255
259
  const functionName = upperCase(SHORT_FUNCTION_NAME.deleteRel) + upperCase(shortNameHandler(handler))
256
260
  const additionalResourcePermission = [];
257
261
  const graphServiceNamesFromAllRelSchemas = await getGraphServiceNameFromAllRelSchema(_izContext, allRelSchemas);
262
+ const objectType = SOURCE_GENERATE_IAM_ROLE.RelationshipRole
258
263
 
259
264
  additionalResourcePermission.push(
260
265
  createIamRole(
@@ -268,14 +273,15 @@ async function externalLambdaIamRoleDataDeleteRelationshipSchema(_izContext, all
268
273
  )
269
274
  return {
270
275
  functionName,
271
- additionalResourcePermission
276
+ additionalResourcePermission,
277
+ objectType
272
278
  }
273
279
  }
274
280
 
275
281
  function externalLambdaIamRoleDataFindData(_izContext) {
276
282
  let functionName = upperCase(SHORT_FUNCTION_NAME.findData) + upperCase(shortNameHandler(HANDLER.hdrSqs));
277
283
  let additionalResourcePermission = [];
278
-
284
+ let objectType = SOURCE_GENERATE_IAM_ROLE.ProcessFindDataRole
279
285
  additionalResourcePermission.push(
280
286
  createIamRole(
281
287
  {
@@ -286,10 +292,11 @@ function externalLambdaIamRoleDataFindData(_izContext) {
286
292
  ]
287
293
  )
288
294
  )
289
- console.log("findData template data:", { functionName, additionalResourcePermission })
295
+ // console.log("findData template data:", { functionName, additionalResourcePermission })
290
296
  return {
291
297
  functionName,
292
- additionalResourcePermission
298
+ additionalResourcePermission,
299
+ objectType
293
300
  }
294
301
  }
295
302
 
@@ -298,6 +305,8 @@ async function externalLambdaIamRoleDataProcessLogical(_izContext, allObjectSche
298
305
  let functionName = upperCase(SHORT_FUNCTION_NAME.processLogical) + upperCase(shortNameHandler(HANDLER.hdrSqs));
299
306
  let additionalResourcePermission = [];
300
307
  let graphServiceNames = await getGraphServiceNameFromObjectSchema(_izContext, allObjectSchemas)
308
+ let objectType = SOURCE_GENERATE_IAM_ROLE.ProcessFindDataRole
309
+
301
310
  // console.log("graphServiceNameFromProcessLogical::", graphServiceNames)
302
311
  additionalResourcePermission.push(
303
312
  createIamRole(
@@ -311,7 +320,8 @@ async function externalLambdaIamRoleDataProcessLogical(_izContext, allObjectSche
311
320
  )
312
321
  return {
313
322
  functionName,
314
- additionalResourcePermission
323
+ additionalResourcePermission,
324
+ objectType
315
325
  }
316
326
  }
317
327
 
@@ -29,7 +29,7 @@ const _izContext = {logger : Logger}
29
29
  module.exports.generatedLambdaRole = async () => {
30
30
  let externalLambdaRole = [ <%_ datas.forEach((data,dataIndex) => { %>
31
31
  {
32
- functionName: "<%- data.functionName %>",
32
+ roleName: "<%- data.objectType %>",
33
33
  statement: [
34
34
  <%_ data.additionalResourcePermission.forEach((resourcePermission, resourceIdx) => { _%>
35
35
  {
@@ -115,8 +115,8 @@ const SOURCE_PATH = {
115
115
  resourceLocationRelationshipPerAction: 'src/generatedCode/RelationshipPerAction/source/',
116
116
  resourceLocationTranslateId: 'src/generatedCode/TranslateId/source/',
117
117
  resourceLocationProcessLogical: "src/generatedCode/ProcessLogical/source/",
118
- webSocket: "../src/generatedCode/WebSocket/source/",
119
- resourceLocationWebSocket: "src/generatedCode/WebSocket/source/",
118
+ webSocket: "../src/generatedCode/FlowSchema/source/",
119
+ resourceLocationWebSocket: "src/generatedCode/FlowSchema/source/",
120
120
  generateCodeLib: "../src/generatedCode/libs/source/",
121
121
  logicalFunctionHook: "../src/generatedCode/WebSocket/source/FlowSchemaHook/HookLogicFunction/source/",
122
122
  resourceLocationLogicalFunctionHook: "src/generatedCode/WebSocket/source/FlowSchemaHook/HookLogicFunction/source",
@@ -359,10 +359,10 @@ function shortNameHandler(fullNameHandler) {
359
359
  };
360
360
 
361
361
  const SOURCE_GENERATE_IAM_ROLE = {
362
- ProcessFindDataRole: "ProcessFindData",
363
- ObjectCompleteRole: "ObjectComplete",
362
+ ProcessFindDataRole: "ProcFindData",
363
+ ObjectCompleteRole: "ObjectCom",
364
364
  RelationshipRole: "Relationship",
365
- RelationshipCompleteRole: "RelationshipComplete",
365
+ RelationshipCompleteRole: "RelationshipCom",
366
366
  };
367
367
 
368
368