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

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 (86) hide show
  1. package/package.json +1 -1
  2. package/src/SourceManager/src/Utils.js +33 -9
  3. package/src/TemplateManager/src/FindData/FindDataYaml/data.js +4 -1
  4. package/src/TemplateManager/src/FindData/FindDataYaml/template.ejs +1 -14
  5. package/src/TemplateManager/src/GenerateCode.js +22 -5
  6. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/functionYaml/data.js +22 -2
  7. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/functionYaml/template.ejs +1 -14
  8. package/src/TemplateManager/src/OutPerActionComplete/OutDeleteComplete/functionYaml/data.js +21 -2
  9. package/src/TemplateManager/src/OutPerActionComplete/OutDeleteComplete/functionYaml/template.ejs +1 -14
  10. package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/functionYaml/data.js +23 -3
  11. package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/functionYaml/template.ejs +1 -14
  12. package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/functionYaml/data.js +22 -2
  13. package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/functionYaml/template.ejs +1 -14
  14. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/data.js +6 -6
  15. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/template.ejs +1 -14
  16. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrDsq/data.js +2 -1
  17. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrDsq/template.ejs +1 -14
  18. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrInv/data.js +1 -1
  19. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrInv/template.ejs +1 -14
  20. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrSqs/data.js +3 -1
  21. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrSqs/template.ejs +1 -14
  22. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrWbs/data.js +1 -1
  23. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/template.ejs +23 -3
  24. package/src/TemplateManager/src/ProcessLogical/ProcessLogicalYaml/data.js +18 -2
  25. package/src/TemplateManager/src/ProcessLogical/ProcessLogicalYaml/template.ejs +1 -14
  26. package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrDsq/data.js +20 -3
  27. package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrDsq/template.ejs +1 -14
  28. package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrSqs/data.js +21 -3
  29. package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrSqs/template.ejs +1 -14
  30. package/src/TemplateManager/src/ProcessLogicalPagination/mainFunction/template.ejs +1 -1
  31. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrApi/data.js +16 -2
  32. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrApi/template.ejs +1 -14
  33. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrDsq/data.js +17 -2
  34. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrDsq/template.ejs +1 -14
  35. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrInv/data.js +16 -2
  36. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrInv/template.ejs +1 -14
  37. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrSqs/data.js +18 -3
  38. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrSqs/template.ejs +1 -14
  39. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationshipComplete/functionYaml/data.js +18 -3
  40. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationshipComplete/functionYaml/template.ejs +1 -14
  41. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrApi/data.js +15 -2
  42. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrApi/template.ejs +1 -14
  43. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrDsq/data.js +17 -2
  44. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrDsq/template.ejs +1 -14
  45. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrInv/data.js +16 -2
  46. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrInv/template.ejs +1 -14
  47. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrSqs/data.js +18 -3
  48. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrSqs/template.ejs +1 -14
  49. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationshipComplete/functionYaml/data.js +18 -3
  50. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationshipComplete/functionYaml/template.ejs +1 -14
  51. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/data.js +19 -4
  52. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/template.ejs +1 -14
  53. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/data.js +19 -2
  54. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/template.ejs +1 -14
  55. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/data.js +19 -2
  56. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/template.ejs +1 -14
  57. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/data.js +20 -2
  58. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/template.ejs +1 -14
  59. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/data.js +20 -2
  60. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/template.ejs +1 -14
  61. package/src/TemplateManager/src/Role/createSharedResource.js +270 -0
  62. package/src/TemplateManager/src/Role/sharedResourceTemplate.ejs +58 -0
  63. package/src/TemplateManager/src/TranslateIdReq/TranslateIds/functionYaml/HdrDsq/data.js +1 -1
  64. package/src/TemplateManager/src/TranslateIdReq/TranslateIds/functionYaml/HdrSqs/data.js +1 -1
  65. package/src/TemplateManager/src/externalService/LambdaRole/data.js +13 -13
  66. package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/functionYaml/data.js +16 -10
  67. package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/handler/data.js +8 -5
  68. package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/handler/template.ejs +22 -9
  69. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/functionYaml/data.js +102 -0
  70. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/functionYaml/template.ejs +43 -0
  71. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/handler/data.js +94 -0
  72. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/handler/templateAsyncHandler.ejs +110 -0
  73. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/handler/templateSyncHandler.ejs +49 -0
  74. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/hookLogic/data.js +65 -0
  75. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/mainFunction/data.js +67 -0
  76. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/mainFunction/template.ejs +30 -0
  77. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/queue/data.js +125 -0
  78. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/queue/snsTemplate.ejs +59 -0
  79. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/queue/sqsTemplate.ejs +43 -0
  80. package/src/TemplateManager/src/libs/Consts.js +36 -10
  81. package/src/TemplateManager/src/reStructureExample/GenerateCodeTest.js +31 -0
  82. package/src/TemplateManager/src/reStructureExample/TemplateConfig.js +11 -0
  83. package/src/TemplateManager/src/reStructureExample/TemplateData/perAction/data.js +0 -0
  84. package/src/TemplateManager/src/reStructureExample/TemplateData/perAction/generateCodeShared.js +1 -0
  85. package/src/TemplateManager/src/reStructureExample/TemplateData/perAction/generatePerAction.js +5 -0
  86. package/src/TemplateManager/src/reStructureExample/TemplateData/perAction/template.ejs +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-market-library-service-schemas",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
4
4
  "description": "Schemas for Izara Market project",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -19,6 +19,8 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
19
19
 
20
20
 
21
21
  const fs = require('fs');
22
+ const path = require('path');
23
+ const { firstLetterUpperCase: upperCase } = require('../../MainLibs/src/Utils');
22
24
  // const { unlink, readdir } = require('node:fs/promises');
23
25
 
24
26
 
@@ -48,19 +50,41 @@ function deleteFile(filePath) {
48
50
  }
49
51
 
50
52
 
51
- async function createHookFunction(_izContext, sourcePath, destinationPath) {
52
- const logicalHookFile = path.join("./src/schemas/flowSchema", sourcePath)
53
- if (fs.existsSync(logicalHookFile)) {
54
- try {
55
- fse.copySync(logicalHookFile, destinationPath, { overwrite: true })
56
- } catch (err) {
57
- _izContext.logger.error(err)
53
+ async function createHookFunction(_izContext, sourcePath, setting = { fileExtension, isAppend, saveFileName, destinationPath }) {
54
+ _izContext.logger.debug("createHookFunction", { sourcePath, setting });
55
+
56
+ let absSourcePath = path.resolve("src/schemas/flowSchema", sourcePath);
57
+ let absDestinationPath = path.resolve(setting.destinationPath, upperCase(setting.saveFileName) + (setting?.fileExtension || ".js"));
58
+
59
+ _izContext.logger.debug("Source:", absSourcePath);
60
+ _izContext.logger.debug("Destination:", absDestinationPath);
61
+
62
+ if (!fs.existsSync(absSourcePath)) {
63
+ _izContext.logger.debug("Source file does not exist:");
64
+ return;
65
+ }
66
+
67
+ const destDir = path.dirname(absDestinationPath);
68
+ if (!fs.existsSync(destDir)) {
69
+ _izContext.logger.debug("Destination directory missing. Creating...");
70
+ fs.mkdirSync(destDir, { recursive: true });
71
+ }
72
+
73
+ try {
74
+ await fs.promises.copyFile(absSourcePath, absDestinationPath);
75
+ _izContext.logger.debug("File copied successfully!");
76
+
77
+ if (fs.existsSync(absDestinationPath)) {
78
+ _izContext.logger.debug("File exists after copying:", absDestinationPath);
79
+ } else {
80
+ _izContext.logger.debug("File still missing after copying: ", absDestinationPath);
58
81
  }
59
- } else {
60
- throw new NoRetryError(`error no sourceFile:${logicalHookFile}`)
82
+ } catch (err) {
83
+ _izContext.logger.debug("Error copying file:", err);
61
84
  }
62
85
  }
63
86
 
87
+
64
88
  module.exports = {
65
89
  deleteFileInDir,
66
90
  deleteFile,
@@ -28,6 +28,8 @@ const { createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_
28
28
  const serviceSchemas = require('@izara_project/izara-core-library-service-schemas');
29
29
  const serviceConfig = serviceSchemas.serviceConfig;
30
30
 
31
+ const { SOURCE_GENERATE_IAM_ROLE } = require("../../libs/Consts")
32
+
31
33
  function defaultIamRolePerAction() {
32
34
 
33
35
  let defaultIamRole = [];
@@ -166,7 +168,8 @@ async function data(_izContext, objectSchemas, srcPath) {
166
168
  resourceLocation: SOURCE_PATH.resourceLocationFindData,
167
169
  handlerType: HANDLER.hdrSqs,
168
170
  additionalResourcePermission,
169
- functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(HANDLER.hdrSqs))
171
+ functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(HANDLER.hdrSqs)),
172
+ roleName: SOURCE_GENERATE_IAM_ROLE.ProcessFindDataRole
170
173
  },
171
174
  setting: {
172
175
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
@@ -6,20 +6,7 @@
6
6
  - sqs:
7
7
  arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- functionName %><%- firstLetterUpperCase(handlerType) %>
8
8
  batchSize: 10
9
- iamRoleStatements:
10
- <%_ additionalResourcePermission.forEach(resourcePermission => { _%>
11
- - Effect: <%- resourcePermission.effect %>
12
- Action:
13
- <%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
14
- <%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
15
- - <%- resourcePerAction %>:<%- permission %>
16
- <%_ }) _%>
17
- <%_ }) _%>
18
- Resource:
19
- <%_ resourcePermission.resource.forEach(resource => { _%>
20
- - "<%- resource %>"
21
- <%_ }) _%>
22
- <%_}) _%>
9
+ role: <%- roleName %>Role
23
10
  #<#<%- functionName %><%- handlerType %>IamRole#>
24
11
  #<#/<%- functionName %><%- handlerType %>IamRole#>
25
12
  <%_ function firstLetterUpperCase(text){
@@ -34,7 +34,7 @@ const {
34
34
  const { SOURCE_PATH } = require('./libs/Consts')
35
35
 
36
36
  const { createSource } = require("../../SourceManager/src/CreateSource");
37
- const { deleteFileInDir } = require("../../SourceManager/src/Utils");
37
+ const { deleteFileInDir, createHookFunction } = require("../../SourceManager/src/Utils");
38
38
  // create Get handler per ObjectType
39
39
  const perActionGetHdrInvData = require("./PerActionEndpoint/Handler/HdrInv/data");
40
40
  const perActionGetHdrApiData = require("./PerActionEndpoint/Handler/HdrApi/data");
@@ -216,9 +216,17 @@ const createConfirmAfterUploadS3Handler = require('./flowSchema/UploadS3Case/con
216
216
  const createConfirmAfterUploadS3MainFunction = require('./flowSchema/UploadS3Case/confirmReservedAfterUpload/mainFunction/data');
217
217
  const createConfirmAfterUploadS3Queue = require('./flowSchema/UploadS3Case/confirmReservedAfterUpload/queue/data');
218
218
 
219
- const createHookFunctionMainFunction = require('./flowSchema/UploadS3Case/hookCode/mainFunction/data');
219
+ // const createHookFunctionFunctionYaml = require('./flowSchema/UploadS3Case/hookCode(old)/functionYaml/data');
220
+ // const createHookFunctionMainFunction = require('./flowSchema/UploadS3Case/hookCode(old)/mainFunction/data');
221
+ // const createHookFunctionHandler = require('./flowSchema/UploadS3Case/hookCode(old)/handler/data');
222
+ // const createHookFunctionQueue = require('./flowSchema/UploadS3Case/hookCode(old)/queue/data');
223
+
224
+ // const createHookFunction = require('./flowSchema/UploadS3Case/hookCode(old)/hookLogic/data');
220
225
  //get functionNameConfig
221
226
  const functionNameConfigYamldata = require('./externalService/FunctionNameConfig/data');
227
+ // create shared resource
228
+ const { createSharedResource } = require('./Role/createSharedResource');
229
+
222
230
 
223
231
  //lib of generateCode
224
232
  const { checkValidTableYaml,
@@ -357,10 +365,14 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
357
365
  createSourceParams.push(...webSocketEndpointResource)
358
366
  }
359
367
 
360
- const hookFunctionMainFunction = createHookFunctionMainFunction(_izContext, flowSchema, saveFilePath);
361
- const createHookResource = [...hookFunctionMainFunction];
368
+ // const hookFunctionFunctionYaml = createHookFunctionFunctionYaml(_izContext, flowSchema, saveFilePath);
369
+ // const hookFunctionMainFunction = createHookFunctionMainFunction(_izContext, flowSchema, saveFilePath);
370
+ // const hookFunctionHandler = createHookFunctionHandler(_izContext, flowSchema, saveFilePath);
371
+ // const hookFunctionQueue = createHookFunctionQueue(_izContext, flowSchema, saveFilePath);
372
+
373
+ // const createHookResource = [...hookFunctionFunctionYaml, ...hookFunctionMainFunction, ...hookFunctionHandler, ...hookFunctionQueue];
362
374
 
363
- createSourceParams.push(...createHookResource)
375
+ // createSourceParams.push(...createHookResource)
364
376
 
365
377
  }
366
378
 
@@ -623,11 +635,16 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
623
635
  const createFunctionNameConfig = functionNameConfigYamldata(_izContext, createSourceParams, saveFilePath);
624
636
  createSourceParams = createSourceParams.concat(...createFunctionNameConfig);
625
637
 
638
+ const createSharedResourceIamRole = createSharedResource(_izContext, createSourceParams, saveFilePath);
639
+ createSourceParams.push(createSharedResourceIamRole)
626
640
  // delete file .yml before start to prevent confilct of data
627
641
  for (let folderPathToEmpty of Object.keys(GENERATECODE_SOURCE_PATH)) {
628
642
  await deleteFileInDir(GENERATECODE_SOURCE_PATH[folderPathToEmpty]);
629
643
  }
630
644
 
645
+ // for (const flowSchema of allLocalFlowSchemas.records) {
646
+ // await createHookFunction(_izContext, flowSchema, saveFilePath);
647
+ // }
631
648
  // console.log(""createSourceParams": ", createSourceParams)
632
649
  // start create source
633
650
  for (let { templatePath, templateData, setting } of createSourceParams) {
@@ -22,7 +22,26 @@ const fs = require('fs');
22
22
  const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
23
23
  const { getGraphServiceNameFromGraphServerTagWithCache, getServiceNameWithCache } = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig')
24
24
  const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils")
25
- const { DEFAULT_HANDLER_PER_ACTION, createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SOURCE_PATH, externalResourceName, getGraphServiceNameFromAllRelSchema, FUNCTION_NAME, SAVE_FILE_NAME, getGraphServiceNameFromObjectSchema, defaultIamRolePerAction, SQS_RESOURCE, SNS_RESOURCE, DYNAMO_RESOURCE, awaitingMultipleStepsRole, SHORT_FUNCTION_NAME } = require("../../../libs/Consts");
25
+ const {
26
+ DEFAULT_HANDLER_PER_ACTION,
27
+ createIamRole,
28
+ resourceNames,
29
+ RESOURCE_CLASSES,
30
+ DEFAULT_LAMBDA_ROLE_PER_ACTION,
31
+ SOURCE_PATH,
32
+ externalResourceName,
33
+ getGraphServiceNameFromAllRelSchema,
34
+ FUNCTION_NAME,
35
+ SAVE_FILE_NAME,
36
+ getGraphServiceNameFromObjectSchema,
37
+ defaultIamRolePerAction,
38
+ SQS_RESOURCE,
39
+ SNS_RESOURCE,
40
+ DYNAMO_RESOURCE,
41
+ awaitingMultipleStepsRole,
42
+ SHORT_FUNCTION_NAME,
43
+ SOURCE_GENERATE_IAM_ROLE
44
+ } = require("../../../libs/Consts");
26
45
 
27
46
  const templatePath = path.join(__dirname, './template.ejs');
28
47
 
@@ -71,7 +90,8 @@ function createFunctionYamlOutUpdateComplete(_izContext, srcPath) {
71
90
  handlerType,
72
91
  additionalResourcePermission,
73
92
  resourceLocation: SOURCE_PATH.resourceLocationOutPerActionComplete,
74
- functionNameConfig
93
+ functionNameConfig,
94
+ roleName: SOURCE_GENERATE_IAM_ROLE.ObjectCompleteRole
75
95
  },
76
96
  setting: {
77
97
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
@@ -9,20 +9,7 @@
9
9
  filterPatterns: #**** need to update serverless framwork upper v.2.69.1
10
10
  - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%-firstLetterUpperCase(functionName) %>"]}}} # functionName of callingFlow
11
11
  - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
12
- iamRoleStatements:
13
- <%_ additionalResourcePermission.forEach(resourcePermission => { _%>
14
- - Effect: <%- resourcePermission.effect %>
15
- Action:
16
- <%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
17
- <%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
18
- - <%- resourcePerAction %>:<%- permission %>
19
- <%_}) _%>
20
- <%_ }) _%>
21
- Resource:
22
- <%_ resourcePermission.resource.forEach(resource => { _%>
23
- - <%- resource %>
24
- <%_ }) _%>
25
- <%_}) _%>
12
+ role: <%- roleName %>Role
26
13
  #<#<%- functionName %><%- handlerType %>IamRole#>
27
14
  #<#/<%- functionName %><%- handlerType %>IamRole#>
28
15
  <%_ function firstLetterUpperCase(text){
@@ -22,7 +22,25 @@ const fs = require('fs');
22
22
  const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
23
23
  const { getGraphServiceNameFromGraphServerTagWithCache, getServiceNameWithCache } = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig')
24
24
  const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils")
25
- const { DEFAULT_HANDLER_PER_ACTION, createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SOURCE_PATH, externalResourceName, getGraphServiceNameFromAllRelSchema, FUNCTION_NAME, SAVE_FILE_NAME, getGraphServiceNameFromObjectSchema, defaultIamRolePerAction, SQS_RESOURCE, SNS_RESOURCE, DYNAMO_RESOURCE, SHORT_FUNCTION_NAME } = require("../../../libs/Consts");
25
+ const {
26
+ DEFAULT_HANDLER_PER_ACTION,
27
+ createIamRole,
28
+ resourceNames,
29
+ RESOURCE_CLASSES,
30
+ DEFAULT_LAMBDA_ROLE_PER_ACTION,
31
+ SOURCE_PATH,
32
+ externalResourceName,
33
+ getGraphServiceNameFromAllRelSchema,
34
+ FUNCTION_NAME,
35
+ SAVE_FILE_NAME,
36
+ getGraphServiceNameFromObjectSchema,
37
+ defaultIamRolePerAction,
38
+ SQS_RESOURCE,
39
+ SNS_RESOURCE,
40
+ DYNAMO_RESOURCE,
41
+ SHORT_FUNCTION_NAME,
42
+ SOURCE_GENERATE_IAM_ROLE
43
+ } = require("../../../libs/Consts");
26
44
 
27
45
  const templatePath = path.join(__dirname, './template.ejs');
28
46
 
@@ -68,7 +86,8 @@ function createFunctionYamlOutUpdateComplete(_izContext, srcPath) {
68
86
  handlerType,
69
87
  additionalResourcePermission,
70
88
  resourceLocation: SOURCE_PATH.resourceLocationOutPerActionComplete,
71
- functionNameConfig
89
+ functionNameConfig,
90
+ roleName: SOURCE_GENERATE_IAM_ROLE.ObjectCompleteRole,
72
91
  },
73
92
  setting: {
74
93
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
@@ -9,20 +9,7 @@
9
9
  filterPatterns: #**** need to update serverless framwork upper v.2.69.1
10
10
  - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%-firstLetterUpperCase(functionName) %>"]}}} # functionName of callingFlow
11
11
  - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
12
- iamRoleStatements:
13
- <%_ additionalResourcePermission.forEach(resourcePermission => { _%>
14
- - Effect: <%- resourcePermission.effect %>
15
- Action:
16
- <%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
17
- <%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
18
- - <%- resourcePerAction %>:<%- permission %>
19
- <%_}) _%>
20
- <%_ }) _%>
21
- Resource:
22
- <%_ resourcePermission.resource.forEach(resource => { _%>
23
- - <%- resource %>
24
- <%_ }) _%>
25
- <%_}) _%>
12
+ role: <%- roleName %>Role
26
13
  #<#<%- functionName %><%- handlerType %>IamRole#>
27
14
  #<#/<%- functionName %><%- handlerType %>IamRole#>
28
15
  <%_ function firstLetterUpperCase(text){
@@ -22,7 +22,26 @@ const fs = require('fs');
22
22
  const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
23
23
  const { getGraphServiceNameFromGraphServerTagWithCache, getServiceNameWithCache } = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig')
24
24
  const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils")
25
- const { DEFAULT_HANDLER_PER_ACTION, createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SOURCE_PATH, externalResourceName, getGraphServiceNameFromAllRelSchema, FUNCTION_NAME, SAVE_FILE_NAME, getGraphServiceNameFromObjectSchema, defaultIamRolePerAction, SQS_RESOURCE, SNS_RESOURCE, DYNAMO_RESOURCE, awaitingMultipleStepsRole, SHORT_FUNCTION_NAME } = require("../../../libs/Consts");
25
+ const {
26
+ DEFAULT_HANDLER_PER_ACTION,
27
+ createIamRole,
28
+ resourceNames,
29
+ RESOURCE_CLASSES,
30
+ DEFAULT_LAMBDA_ROLE_PER_ACTION,
31
+ SOURCE_PATH,
32
+ externalResourceName,
33
+ getGraphServiceNameFromAllRelSchema,
34
+ FUNCTION_NAME,
35
+ SAVE_FILE_NAME,
36
+ getGraphServiceNameFromObjectSchema,
37
+ defaultIamRolePerAction,
38
+ SQS_RESOURCE,
39
+ SNS_RESOURCE,
40
+ DYNAMO_RESOURCE,
41
+ awaitingMultipleStepsRole,
42
+ SHORT_FUNCTION_NAME,
43
+ SOURCE_GENERATE_IAM_ROLE
44
+ } = require("../../../libs/Consts");
26
45
 
27
46
  const templatePath = path.join(__dirname, './template.ejs');
28
47
 
@@ -49,7 +68,7 @@ function createFunctionYamlOutUpdateComplete(_izContext, srcPath) {
49
68
  ],
50
69
  [RESOURCE_CLASSES.sns]: [
51
70
  SNS_RESOURCE.publish,
52
- SNS_RESOURCE.subscription
71
+ SNS_RESOURCE.subscribe
53
72
  ]
54
73
  },
55
74
  [
@@ -71,7 +90,8 @@ function createFunctionYamlOutUpdateComplete(_izContext, srcPath) {
71
90
  handlerType,
72
91
  additionalResourcePermission,
73
92
  resourceLocation: SOURCE_PATH.resourceLocationOutPerActionComplete,
74
- functionNameConfig
93
+ functionNameConfig,
94
+ roleName: SOURCE_GENERATE_IAM_ROLE.roleName,
75
95
  },
76
96
  setting: {
77
97
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
@@ -9,20 +9,7 @@
9
9
  filterPatterns: #**** need to update serverless framwork upper v.2.69.1
10
10
  - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%-firstLetterUpperCase(functionName) %>"]}}} # functionName of callingFlow
11
11
  - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
12
- iamRoleStatements:
13
- <%_ additionalResourcePermission.forEach(resourcePermission => { _%>
14
- - Effect: <%- resourcePermission.effect %>
15
- Action:
16
- <%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
17
- <%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
18
- - <%- resourcePerAction %>:<%- permission %>
19
- <%_}) _%>
20
- <%_ }) _%>
21
- Resource:
22
- <%_ resourcePermission.resource.forEach(resource => { _%>
23
- - <%- resource %>
24
- <%_ }) _%>
25
- <%_}) _%>
12
+ role: <%- roleName %>Role
26
13
  #<#<%- functionName %><%- handlerType %>IamRole#>
27
14
  #<#/<%- functionName %><%- handlerType %>IamRole#>
28
15
  <%_ function firstLetterUpperCase(text){
@@ -22,7 +22,26 @@ const fs = require('fs');
22
22
  const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
23
23
  const { getGraphServiceNameFromGraphServerTagWithCache, getServiceNameWithCache } = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig')
24
24
  const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils")
25
- const { DEFAULT_HANDLER_PER_ACTION, createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SOURCE_PATH, externalResourceName, getGraphServiceNameFromAllRelSchema, FUNCTION_NAME, SAVE_FILE_NAME, getGraphServiceNameFromObjectSchema, defaultIamRolePerAction, SQS_RESOURCE, SNS_RESOURCE, DYNAMO_RESOURCE, awaitingMultipleStepsRole, SHORT_FUNCTION_NAME } = require("../../../libs/Consts");
25
+ const {
26
+ DEFAULT_HANDLER_PER_ACTION,
27
+ createIamRole,
28
+ resourceNames,
29
+ RESOURCE_CLASSES,
30
+ DEFAULT_LAMBDA_ROLE_PER_ACTION,
31
+ SOURCE_PATH,
32
+ externalResourceName,
33
+ getGraphServiceNameFromAllRelSchema,
34
+ FUNCTION_NAME,
35
+ SAVE_FILE_NAME,
36
+ getGraphServiceNameFromObjectSchema,
37
+ defaultIamRolePerAction,
38
+ SQS_RESOURCE,
39
+ SNS_RESOURCE,
40
+ DYNAMO_RESOURCE,
41
+ awaitingMultipleStepsRole,
42
+ SHORT_FUNCTION_NAME,
43
+ SOURCE_GENERATE_IAM_ROLE
44
+ } = require("../../../libs/Consts");
26
45
 
27
46
  const templatePath = path.join(__dirname, './template.ejs');
28
47
 
@@ -71,7 +90,8 @@ function createFunctionYamlOutUpdateComplete(_izContext, srcPath) {
71
90
  handlerType,
72
91
  additionalResourcePermission,
73
92
  resourceLocation: SOURCE_PATH.resourceLocationOutPerActionComplete,
74
- functionNameConfig
93
+ functionNameConfig,
94
+ roleName: SOURCE_GENERATE_IAM_ROLE.ObjectCompleteRole,
75
95
  },
76
96
  setting: {
77
97
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
@@ -9,20 +9,7 @@
9
9
  filterPatterns: #**** need to update serverless framwork upper v.2.69.1
10
10
  - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%-firstLetterUpperCase(functionName) %>"]}}} # functionName of callingFlow
11
11
  - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
12
- iamRoleStatements:
13
- <%_ additionalResourcePermission.forEach(resourcePermission => { _%>
14
- - Effect: <%- resourcePermission.effect %>
15
- Action:
16
- <%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
17
- <%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
18
- - <%- resourcePerAction %>:<%- permission %>
19
- <%_}) _%>
20
- <%_ }) _%>
21
- Resource:
22
- <%_ resourcePermission.resource.forEach(resource => { _%>
23
- - <%- resource %>
24
- <%_ }) _%>
25
- <%_}) _%>
12
+ role: <%- roleName %>Role
26
13
  #<#<%- functionName %><%- handlerType %>IamRole#>
27
14
  #<#/<%- functionName %><%- handlerType %>IamRole#>
28
15
  <%_ function firstLetterUpperCase(text){
@@ -161,14 +161,14 @@ function createParamForCreateSource(objectSchema, action, srcPath) {
161
161
  event: event,
162
162
  objectType: objectType,
163
163
  action: action,
164
- functionNameConfig
164
+ functionNameConfig,
165
165
  },
166
- setting: {
167
- savePath: path.join(srcPath, SOURCE_PATH.appYaml),
168
- saveFileName: SAVE_FILE_NAME.functionPerActionYaml,
166
+ setting: {
167
+ savePath: path.join(srcPath, SOURCE_PATH.appYaml),
168
+ saveFileName: SAVE_FILE_NAME.functionPerActionYaml,
169
169
  fileExtension: '.yml',
170
- isAppend: true
171
- }
170
+ isAppend: true
171
+ }
172
172
  }
173
173
  }
174
174
 
@@ -9,20 +9,7 @@
9
9
  cors: true
10
10
  #<#<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>Authorizer#>
11
11
  #<#/<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>Authorizer#>
12
- iamRoleStatements:
13
- <%_ additionalResourcePermission.forEach(resourcePermission => { _%>
14
- - Effect: <%- resourcePermission.effect %>
15
- Action:
16
- <%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
17
- <%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
18
- - <%- resourcePerAction %>:<%- permission %>
19
- <%_}) _%>
20
- <%_ }) _%>
21
- Resource:
22
- <%_ resourcePermission.resource.forEach(resource => { _%>
23
- - <%- resource %>
24
- <%_ }) _%>
25
- <%_}) _%>
12
+ role: <%- objectType %>Role
26
13
  #<#<%- functionName %><%- handlerType %>IamRole#>
27
14
  #<#/<%- functionName %><%- handlerType %>IamRole#>
28
15
  <%_ function firstLetterUpperCase(text){
@@ -168,7 +168,8 @@ function createParamForCreateSource(objectSchema, action, srcPath) {
168
168
  resourceLocation: SOURCE_PATH.resourceLocationPerAction,
169
169
  handlerType: HANDLER.hdrDsq,
170
170
  additionalResourcePermission,
171
- functionNameConfig
171
+ functionNameConfig,
172
+ roleName: `${objectType}`,
172
173
  },
173
174
  setting: {
174
175
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
@@ -6,20 +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
- iamRoleStatements:
10
- <%_ additionalResourcePermission.forEach(resourcePermission => { _%>
11
- - Effect: <%- resourcePermission.effect %>
12
- Action:
13
- <%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
14
- <%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
15
- - <%- resourcePerAction %>:<%- permission %>
16
- <%_}) _%>
17
- <%_ }) _%>
18
- Resource:
19
- <%_ resourcePermission.resource.forEach(resource => { _%>
20
- - "<%- resource %>"
21
- <%_ }) _%>
22
- <%_}) _%>
9
+ role: <%- roleName %>Role
23
10
  #<#<%- functionName %><%- handlerType %>IamRole#>
24
11
  #<#/<%- functionName %><%- handlerType %>IamRole#>
25
12
  <%_ function firstLetterUpperCase(text){
@@ -152,7 +152,7 @@ function createParamForCreateSource(objectSchema, action, srcPath) {
152
152
  additionalResourcePermission,
153
153
  objectType,
154
154
  // functionNameConfig: upperCase(objectType) + upperCase(action) + upperCase(shortNameHandler(HANDLER.hdrInv))
155
- functionNameConfig: upperCase(functionNameObjectType) + upperCase(action) + upperCase(shortNameHandler(HANDLER.hdrInv))
155
+ functionNameConfig: upperCase(functionNameObjectType) + upperCase(action) + upperCase(shortNameHandler(HANDLER.hdrInv)),
156
156
  },
157
157
  setting: {
158
158
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
@@ -2,20 +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
- iamRoleStatements:
6
- <%_ additionalResourcePermission.forEach(resourcePermission => { _%>
7
- - Effect: <%- resourcePermission.effect %>
8
- Action:
9
- <%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
10
- <%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
11
- - <%- resourcePerAction %>:<%- permission %>
12
- <%_}) _%>
13
- <%_ }) _%>
14
- Resource:
15
- <%_ resourcePermission.resource.forEach(resource => { _%>
16
- - <%- resource %>
17
- <%_ }) _%>
18
- <%_}) _%>
5
+ role: <%- objectType %>Role
19
6
  #<#<%- functionName %><%- handlerType %>IamRole#>
20
7
  #<#/<%- functionName %><%- handlerType %>IamRole#>
21
8
  <%_ function firstLetterUpperCase(text){
@@ -171,7 +171,9 @@ function createParamForCreateSource(objectSchema, action, srcPath) {
171
171
  resourceLocation: SOURCE_PATH.resourceLocationPerAction,
172
172
  handlerType: HANDLER.hdrSqs,
173
173
  additionalResourcePermission,
174
- functionNameConfig
174
+ functionNameConfig,
175
+ objectType,
176
+ roleName: `${objectType}`,
175
177
  },
176
178
  setting: {
177
179
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
@@ -6,20 +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
- iamRoleStatements:
10
- <%_ additionalResourcePermission.forEach(resourcePermission => { _%>
11
- - Effect: <%- resourcePermission.effect %>
12
- Action:
13
- <%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
14
- <%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
15
- - <%- resourcePerAction %>:<%- permission %>
16
- <%_ }) _%>
17
- <%_ }) _%>
18
- Resource:
19
- <%_ resourcePermission.resource.forEach(resource => { _%>
20
- - "<%- resource %>"
21
- <%_ }) _%>
22
- <%_}) _%>
9
+ role: <%- roleName %>Role
23
10
  #<#<%- functionName %><%- handlerType %>IamRole#>
24
11
  #<#/<%- functionName %><%- handlerType %>IamRole#>
25
12
  <%_ function firstLetterUpperCase(text){
@@ -157,7 +157,7 @@ function createParamForCreateSource(objectSchema, action, srcPath) {
157
157
  handlerType: HANDLER.hdrWbs,
158
158
  additionalResourcePermission,
159
159
  functionNameConfig,
160
- objectType
160
+ objectType,
161
161
  },
162
162
  setting: {
163
163
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
@@ -322,10 +322,26 @@ module.exports.<%- functionName %>Main = async (
322
322
  }
323
323
  }
324
324
  };
325
+ } else if (objectSchemas.fieldNames[identifier.fieldName].hasOwnProperty("hashOnCreate")) {
326
+ if (objectSchemas.fieldNames[identifier.fieldName].hashOnCreate.length &&
327
+ objectSchemas.fieldNames[identifier.fieldName].hashOnCreate.length > 0) {
328
+ for (const fieldName of objectSchemas.fieldNames[identifier.fieldName].hashOnCreate) {
329
+ Object.assign(
330
+ requestParams.fieldNames, {
331
+ [identifier.fieldName]: hash({
332
+ [fieldName]: requestParams.fieldNames[fieldName]
333
+ })
334
+ }
335
+ )
336
+ }
337
+ } else {
338
+ errorsFound.push("[invalid] no data to hash for create")
339
+ }
325
340
  } else {
326
- if ((objectSchemas.fieldNames[identifier.fieldName].requiredOnCreate == false) &&
327
- (objectSchemas.fieldNames[identifier.fieldName].optionalOnCreate == false) &&
328
- (objectSchemas.fieldNames[identifier.fieldName].canUpdate == false)) {
341
+ if ((objectSchemas.fieldNames[identifier.fieldName].requiredOnCreate === false) &&
342
+ (objectSchemas.fieldNames[identifier.fieldName].optionalOnCreate === false) &&
343
+ (objectSchemas.fieldNames[identifier.fieldName].canUpdate === false) &&
344
+ objectSchemas.fieldNames[identifier.fieldName].hashOnCreate === false) {
329
345
  errorsFound.push("[invalid]case single identifier invalid objectSchemass");
330
346
  };
331
347
  };
@@ -344,6 +360,10 @@ module.exports.<%- functionName %>Main = async (
344
360
  listOfRequiredOnCreate.push(keyFieldNames)
345
361
  };
346
362
 
363
+ if (valueFieldNames.hasOwnProperty("hashOnCreate") && valueFieldNames.hashOnCreate.length) {
364
+ listOfRequiredOnCreate.push(keyFieldNames)
365
+ }
366
+
347
367
  if (valueFieldNames.hasOwnProperty("optionalOnCreate") && valueFieldNames.optionalOnCreate === true) {
348
368
  if ((valueFieldNames.requiredOnCreate === false) && valueFieldNames.optionalOnCreate === true) {
349
369
  listOfOptionalOnCreate.push(keyFieldNames)