@izara_project/izara-market-library-service-schemas 1.0.19 → 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.
Files changed (90) hide show
  1. package/package.json +2 -2
  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 +2 -15
  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 +269 -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/FunctionNameConfig/data.js +98 -22
  66. package/src/TemplateManager/src/externalService/FunctionNameConfig/templateIntTesting.ejs +5 -5
  67. package/src/TemplateManager/src/externalService/FunctionNameConfig/templateYaml.ejs +2 -2
  68. package/src/TemplateManager/src/externalService/LambdaRole/data.js +32 -22
  69. package/src/TemplateManager/src/externalService/LambdaRole/template.ejs +1 -1
  70. package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/functionYaml/data.js +16 -10
  71. package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/handler/data.js +8 -5
  72. package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/handler/template.ejs +22 -9
  73. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/functionYaml/data.js +102 -0
  74. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/functionYaml/template.ejs +43 -0
  75. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/handler/data.js +94 -0
  76. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/handler/templateAsyncHandler.ejs +110 -0
  77. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/handler/templateSyncHandler.ejs +49 -0
  78. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/hookLogic/data.js +65 -0
  79. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/mainFunction/data.js +67 -0
  80. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/mainFunction/template.ejs +30 -0
  81. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/queue/data.js +125 -0
  82. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/queue/snsTemplate.ejs +59 -0
  83. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode(old)/queue/sqsTemplate.ejs +43 -0
  84. package/src/TemplateManager/src/libs/Consts.js +38 -12
  85. package/src/TemplateManager/src/reStructureExample/GenerateCodeTest.js +31 -0
  86. package/src/TemplateManager/src/reStructureExample/TemplateConfig.js +11 -0
  87. package/src/TemplateManager/src/reStructureExample/TemplateData/perAction/data.js +0 -0
  88. package/src/TemplateManager/src/reStructureExample/TemplateData/perAction/generateCodeShared.js +1 -0
  89. package/src/TemplateManager/src/reStructureExample/TemplateData/perAction/generatePerAction.js +5 -0
  90. package/src/TemplateManager/src/reStructureExample/TemplateData/perAction/template.ejs +0 -0
@@ -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, externalResourceSns, 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
@@ -159,7 +159,7 @@ async function externalLambdaIamRoleDataPerAction(_izContext, objectSchema, acti
159
159
  [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
160
160
  },
161
161
  graphServiceNames.map(graphServiceName =>
162
- externalResourceSns("InUpdateNode", graphServiceName)
162
+ externalResourceName(RESOURCE_CLASSES.sns, "InUpdateNode", graphServiceName)
163
163
  )
164
164
  )
165
165
  )
@@ -171,7 +171,7 @@ async function externalLambdaIamRoleDataPerAction(_izContext, objectSchema, acti
171
171
  [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
172
172
  },
173
173
  graphServiceNames.map(graphServiceName =>
174
- externalResourceSns("InCreateNodeV2", graphServiceName)
174
+ externalResourceName(RESOURCE_CLASSES.sns, "InCreateNodeV2", graphServiceName)
175
175
  )
176
176
  )
177
177
  )
@@ -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(
@@ -215,14 +216,15 @@ async function externalLambdaIamRoleDataUpdateRelationshipSchema(_izContext, all
215
216
  [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
216
217
  },
217
218
  graphServiceNamesFromAllRelSchemas.map(graphServiceName =>
218
- externalResourceSns("InUpdateRelationship", graphServiceName)
219
+ externalResourceName(RESOURCE_CLASSES.sns, "InUpdateRelationship", graphServiceName)
219
220
  )
220
221
  )
221
222
  )
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(
@@ -240,13 +243,14 @@ async function externalLambdaIamRoleDataCreateRelationshipSchema(_izContext, all
240
243
  [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
241
244
  },
242
245
  graphServiceNamesFromAllRelSchemas.map(graphServiceName =>
243
- externalResourceSns("InCreateRelationshipV2", graphServiceName)
246
+ externalResourceName(RESOURCE_CLASSES.sns, "InCreateRelationshipV2", graphServiceName)
244
247
  )
245
248
  )
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(
@@ -262,20 +267,21 @@ async function externalLambdaIamRoleDataDeleteRelationshipSchema(_izContext, all
262
267
  [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
263
268
  },
264
269
  graphServiceNamesFromAllRelSchemas.map(graphServiceName =>
265
- externalResourceSns("InDeleteRelationshipV2", graphServiceName)
270
+ externalResourceName(RESOURCE_CLASSES.sns, "InDeleteRelationshipV2", graphServiceName)
266
271
  )
267
272
  )
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
 
@@ -325,7 +335,7 @@ function externalLambdaIamRoleDataGetPresignUrl(_izContext) {
325
335
  [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
326
336
  },
327
337
  [
328
- externalResourceSns("InReservedDynamicUsage", EXTERNAL_SERVICE_NAME.accountLimits)
338
+ externalResourceName(RESOURCE_CLASSES.sns, "InReservedDynamicUsage", EXTERNAL_SERVICE_NAME.accountLimits)
329
339
  ]
330
340
  ),
331
341
  createIamRole(
@@ -354,7 +364,7 @@ function externalLambdaIamRoleDataReservedLimitComplete(_izContext) {
354
364
  [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
355
365
  },
356
366
  [
357
- externalResourceSns("InCancelUsage", EXTERNAL_SERVICE_NAME.accountLimits)
367
+ externalResourceName(RESOURCE_CLASSES.sns, "InCancelUsage", EXTERNAL_SERVICE_NAME.accountLimits)
358
368
  ]
359
369
  )
360
370
  )
@@ -374,8 +384,8 @@ function externalLambdaIamRoleDataConfirmReservedAfterUpload(_izContext) {
374
384
  [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
375
385
  },
376
386
  [
377
- externalResourceSns("OutReservedDynamicUsageComplet", EXTERNAL_SERVICE_NAME.accountLimits),
378
- externalResourceSns("InConfirmUsage", EXTERNAL_SERVICE_NAME.accountLimits)
387
+ externalResourceName(RESOURCE_CLASSES.sns, "OutReservedDynamicUsageComplet", EXTERNAL_SERVICE_NAME.accountLimits),
388
+ externalResourceName(RESOURCE_CLASSES.sns, "InConfirmUsage", EXTERNAL_SERVICE_NAME.accountLimits)
379
389
  ]
380
390
  ),
381
391
  )
@@ -395,9 +405,9 @@ function externalLambdaIamRoleDataProcessAfterUpload(_izContext) {
395
405
  [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
396
406
  },
397
407
  [
398
- externalResourceSns("InCancelUsage", EXTERNAL_SERVICE_NAME.accountLimits),
399
- externalResourceSns("InConfirmUsage", EXTERNAL_SERVICE_NAME.accountLimits),
400
- externalResourceSns("InReservedDynamicUsage", EXTERNAL_SERVICE_NAME.accountLimits),
408
+ externalResourceName(RESOURCE_CLASSES.sns, "InCancelUsage", EXTERNAL_SERVICE_NAME.accountLimits),
409
+ externalResourceName(RESOURCE_CLASSES.sns, "InConfirmUsage", EXTERNAL_SERVICE_NAME.accountLimits),
410
+ externalResourceName(RESOURCE_CLASSES.sns, "InReservedDynamicUsage", EXTERNAL_SERVICE_NAME.accountLimits),
401
411
  ]
402
412
  )
403
413
  )
@@ -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
  {
@@ -21,7 +21,7 @@ const fs = require('fs');
21
21
 
22
22
  const { FLOW_SCHEMA_HOOK_STATE } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
23
23
  const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
24
- const { SOURCE_PATH, defaultIamRolePerAction, createIamRole, RESOURCE_CLASSES, SNS_RESOURCE, resourceNames, DYNAMO_RESOURCE, SAVE_FILE_NAME, FUNCTION_NAME, shortNameHandler } = require("../../../../libs/Consts");
24
+ const { SOURCE_PATH, defaultIamRolePerAction, createIamRole, RESOURCE_CLASSES, SNS_RESOURCE, resourceNames, DYNAMO_RESOURCE, SAVE_FILE_NAME, FUNCTION_NAME, shortNameHandler, externalResourceYaml } = require("../../../../libs/Consts");
25
25
  const templatePath = path.join(__dirname, "template.ejs")
26
26
  const hookTemplate = path.join(__dirname, "./hookTemplate.ejs")
27
27
  /**
@@ -50,7 +50,7 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
50
50
  ]
51
51
  },
52
52
  [
53
- resourceNames(RESOURCE_CLASSES.sns, "*")
53
+ resourceNames(RESOURCE_CLASSES.sns, "InImportBatchMainCreate")
54
54
  ]
55
55
  ),
56
56
  createIamRole(
@@ -81,25 +81,31 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
81
81
 
82
82
  if (flowSchema?.hook) {
83
83
  for (const [hookName, hookProperties] of Object.entries(flowSchema.hook)) {
84
- for (const hookFunction of hookProperties.functionList) {
85
- if (hookName === FLOW_SCHEMA_HOOK_STATE.beforeCreate) {
86
- if (hookFunction?.permission) {
87
- for (const permission of hookFunction.permission) {
88
- if (hookFunction.event?.initialEvent && hookFunction.initialEvent === true)
84
+ if (hookName === FLOW_SCHEMA_HOOK_STATE.beforeCreate) {
85
+ for (const hookFunction of hookProperties.functionList) {
86
+ if ((hookFunction.event.hasOwnProperty("initialEvent") && (hookFunction.event.initialEvent === true))) {
87
+ if (hookFunction?.permission) {
88
+ for (const permission of hookFunction.permission) {
89
89
  additionalResourcePermission.push(
90
90
  createIamRole(
91
91
  permission.action,
92
- permission.resource,
93
- permission.effect
92
+ permission.resource.map(resource =>
93
+ externalResourceYaml(
94
+ resource.resource,
95
+ resource.resourceName,
96
+ resource.serviceTag),
97
+ permission.effect
98
+ )
94
99
  )
95
100
  )
101
+ }
96
102
  }
97
103
  }
98
104
  }
99
105
  }
100
106
  }
101
107
  }
102
- // console.log("additionalResourcePermission in createObjectS3", additionalResourcePermission)
108
+ // console.log("additionalResourcePermission in createObjectS3", JSON.stringify(additionalResourcePermission))
103
109
  return {
104
110
  templatePath: templatePath,
105
111
  templateData: {
@@ -39,8 +39,9 @@ function data(_izContext, flowSchema, srcPath) {
39
39
  function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
40
40
  let functionName = upperCase(FUNCTION_NAME.createObjectS3)
41
41
  let handlerType = "HdrWbs"
42
- let hook;
42
+ let hook = false;
43
43
  let hookFunctionName;
44
+ let isAsync = false;
44
45
  if (flowSchema?.hook) {
45
46
  for (const [hookName, hookProperties] of Object.entries(flowSchema.hook)) {
46
47
  for (const hookFunction of hookProperties.functionList) {
@@ -48,18 +49,20 @@ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
48
49
  if (hookFunction.event?.initialEvent && hookFunction.event.initialEvent === true) {
49
50
  hook = true
50
51
  hookFunctionName = hookFunction.name
52
+ if (hookFunction.event?.isAsync && hookFunction.event.isAsync === true) {
53
+ isAsync = true
54
+ }
51
55
  }
52
56
  }
53
57
  }
54
58
  }
55
59
  }
56
-
57
60
  return {
58
61
  templatePath: templatePath,
59
62
  templateData: {
60
- hook: hook ? hook : false,
61
- hookFunctionName: hookFunctionName ? hookFunctionName : null,
62
- // hookSourcePath: hook ? SOURCE_PATH.webSocketHook : {}
63
+ hook: hook,
64
+ hookFunctionName: hookFunctionName,
65
+ isAsync
63
66
  },
64
67
  setting: {
65
68
  savePath: path.join(srcPath, SOURCE_PATH.webSocket),
@@ -29,7 +29,7 @@ const hash = require('object-hash')
29
29
  const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
30
30
  const { postToConnection } = require("../../libs/source/ImportDataLib");
31
31
  <% if (hook) { _%>
32
- const <%- hookFunctionName %> = required("<% hookFunctionName _%>_Main ")
32
+ const <%- upperCase(hookFunctionName) %> = require("./FlowSchemaHook/HookLogicFunction/source/<%- upperCase(hookFunctionName) %>")
33
33
  <% } else { _%>
34
34
  const createObject = require('./CreateObjectS3_Main');
35
35
  <% } _%>
@@ -69,13 +69,23 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
69
69
 
70
70
  let callingFlow = eventParams?.callingFlow ? eventParams.callingFlow : {};
71
71
  <% if (hook) { _%>
72
- await <%- hookFunctionName %>.<%- hookFunctionName %>(
73
- event._izContext,
74
- eventParams,
75
- callingFlowSharedLib.addCallingFlowToPassOnProperties(callingFlow)
76
- //(<additionalParams>)
77
- //(</additionalParams>)
78
- )
72
+ <% if (isAsync) { %>
73
+ await <%- upperCase(hookFunctionName) %>(
74
+ event._izContext,
75
+ eventParams,
76
+ callingFlowSharedLib.addCallingFlowToPassOnProperties(callingFlow)
77
+ //(<additionalParams>)
78
+ //(</additionalParams>)
79
+ )
80
+ <% } else { %>
81
+ <%- upperCase(hookFunctionName) %>(
82
+ event._izContext,
83
+ eventParams,
84
+ callingFlowSharedLib.addCallingFlowToPassOnProperties(callingFlow)
85
+ //(<additionalParams>)
86
+ //(</additionalParams>)
87
+ )
88
+ <% } _%>
79
89
  <% } else { _%>
80
90
  await createObject.createObject(
81
91
  event._izContext,
@@ -104,4 +114,7 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
104
114
  return (izara.response.failure(err));
105
115
  }
106
116
  });
107
- <%_ const join = require('path').join _%>
117
+ <%_ const join = require('path').join _%>
118
+ <%_ function upperCase (text) {
119
+ return text.charAt(0).toUpperCase() + text.slice(1)
120
+ } _%>
@@ -0,0 +1,102 @@
1
+ /*
2
+ Copyright (C) 2020 Sven Mason <http://izara.io>
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Affero General Public License as
6
+ published by the Free Software Foundation, either version 3 of the
7
+ License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Affero General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Affero General Public License
15
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ 'use strict';
19
+ const path = require('path');
20
+ const fs = require('fs');
21
+ const { HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
22
+ const { FLOW_SCHEMA_HOOK_STATE } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
23
+ const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
24
+ const { SOURCE_PATH, defaultIamRolePerAction, createIamRole, RESOURCE_CLASSES, SNS_RESOURCE, resourceNames, DYNAMO_RESOURCE, SAVE_FILE_NAME, FUNCTION_NAME, shortNameHandler, SQS_RESOURCE } = require("../../../../libs/Consts");
25
+ const templatePath = path.join(__dirname, "template.ejs")
26
+ /**
27
+ * receive objectSchema
28
+ * create data for WebScoket handler template
29
+ *
30
+ * @param {Object} objectSchema
31
+ * @return {{templatePath, templateData,setting}}
32
+ */
33
+
34
+ function data(_izContext, flowSchema, srcPath) {
35
+ return [createSourceParams(_izContext, flowSchema, srcPath)]
36
+ }
37
+
38
+ function createSourceParams(_izContext, flowSchema, srcPath) {
39
+ let hook;
40
+ let hookFunctionName
41
+ let handlerType;
42
+ let queueName;
43
+ let filterPattern;
44
+ let additionalResourcePermission = defaultIamRolePerAction();
45
+ if (flowSchema?.hook) {
46
+ for (const [hookName, hookProperties] of Object.entries(flowSchema.hook)) {
47
+ for (const hookFunction of hookProperties.functionList) {
48
+ if (hookName === FLOW_SCHEMA_HOOK_STATE.beforeCreate) {
49
+ if (hookFunction.event.continueFlow === true && hookFunction.event.initialEvent === false) {
50
+ hook = true
51
+ hookFunctionName = upperCase(hookFunction.name)
52
+ handlerType = upperCase(hookFunction.event.handlerType);
53
+ filterPattern = hookFunction.event.filterPattern;
54
+ additionalResourcePermission.push(
55
+ createIamRole(
56
+ {
57
+ [RESOURCE_CLASSES.sns]: [
58
+ SNS_RESOURCE.publish
59
+ ]
60
+ },
61
+ [
62
+ resourceNames(RESOURCE_CLASSES.sns, "InImportBatchMainCreate")
63
+ ]
64
+ )
65
+ )
66
+ if (upperCase(handlerType) === upperCase(HANDLER.hdrDsq)) {
67
+ queueName = hookFunction.event.queueName;
68
+ } else if (upperCase(handlerType) === upperCase(HANDLER.hdrSqs)) {
69
+ if (hookFunction.event.topicName.includes("In")) {
70
+ queueName = upperCase(hookFunction.event.topicName.slice(2));
71
+ } else {
72
+ queueName = hookFunction.event.topicName;
73
+ }
74
+ }
75
+ }
76
+ }
77
+ }
78
+ }
79
+ }
80
+ return {
81
+ templatePath: templatePath,
82
+ templateData: {
83
+ hookFunctionName,
84
+ handlerType,
85
+ queueName,
86
+ additionalResourcePermission,
87
+ functionName: upperCase(hookFunctionName),
88
+ functionNameConfig: upperCase(hookFunctionName) + upperCase(shortNameHandler(handlerType)),
89
+ resourceLocation: SOURCE_PATH.resourceLocationGeneratedCodeHookFunction,
90
+ filterPattern
91
+ },
92
+ setting: {
93
+ savePath: path.join(srcPath, SOURCE_PATH.appYaml),
94
+ saveFileName: upperCase(SAVE_FILE_NAME.flowSchema),
95
+ fileExtension: ".yml",
96
+ isAppend: true
97
+ }
98
+ }
99
+
100
+ }
101
+
102
+ module.exports = data;
@@ -0,0 +1,43 @@
1
+ <%_ const join = require('path').join; _%>
2
+ <%_ const { HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts'); _%>
3
+ <%- firstLetterUpperCase(functionNameConfig) %>:
4
+ handler: <%- join(resourceLocation, `${functionName}_${firstLetterUpperCase(handlerType)}.main`)%>
5
+ name: ${self:custom.iz_resourcePrefix}<%- functionName %><%- firstLetterUpperCase(handlerType) %>
6
+ <%_ if (handlerType === firstLetterUpperCase(HANDLER.hdrDsq) || handlerType === firstLetterUpperCase(HANDLER.hdrSqs)) { _%>
7
+ events:
8
+ - sqs:
9
+ arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %><%- firstLetterUpperCase(handlerType) %>
10
+ batchSize: 10
11
+ <%_ if (filterPattern) { _%>
12
+ filterPatterns: #**** need to update serverless framwork upper v.2.69.1
13
+ - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%- filterPattern %>"]}}} # functionName of callingFlow
14
+ - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
15
+ <%_ } _%>
16
+ <%_ } else if (handlerType === firstLetterUpperCase(HANDLER.hdrApi)) { _%>
17
+ events:
18
+ - http:
19
+ path: <%- objectType %>/<%- firstLetterUpperCase(action) %>
20
+ method: <%- event %>
21
+ cors: true
22
+ #<#<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>Authorizer#>
23
+ #<#/<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>Authorizer#>
24
+ <%_ } _%>
25
+ iamRoleStatements:
26
+ <%_ additionalResourcePermission.forEach(resourcePermission => { _%>
27
+ - Effect: <%- resourcePermission.effect %>
28
+ Action:
29
+ <%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
30
+ <%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
31
+ - <%- resourcePerAction %>:<%- permission %>
32
+ <%_ }) _%>
33
+ <%_ }) _%>
34
+ Resource:
35
+ <%_ resourcePermission.resource.forEach(resource => { _%>
36
+ - "<%- resource %>"
37
+ <%_ }) _%>
38
+ <%_}) _%>
39
+ #<#<%- functionName %><%- handlerType %>IamRole#>
40
+ #<#/<%- functionName %><%- handlerType %>IamRole#>
41
+ <%_ function firstLetterUpperCase(text){
42
+ return text.charAt(0).toUpperCase() + text.slice(1)
43
+ } _%>
@@ -0,0 +1,94 @@
1
+ /*
2
+ Copyright (C) 2020 Sven Mason <http://izara.io>
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Affero General Public License as
6
+ published by the Free Software Foundation, either version 3 of the
7
+ License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Affero General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Affero General Public License
15
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ 'use strict';
19
+ const path = require('path');
20
+ const fs = require('fs');
21
+ const { HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
22
+ const { createHookFunction } = require('../../../../../../SourceManager/src/Utils')
23
+ const { FLOW_SCHEMA_HOOK_STATE } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
24
+ const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
25
+ const { SOURCE_PATH, defaultIamRolePerAction, createIamRole, RESOURCE_CLASSES, SNS_RESOURCE, resourceNames, DYNAMO_RESOURCE, SAVE_FILE_NAME, FUNCTION_NAME, shortNameHandler, SQS_RESOURCE } = require("../../../../libs/Consts");
26
+ const asyncTemplatePath = path.join(__dirname, "templateAsyncHandler.ejs")
27
+ const syncTemplatePath = path.join(__dirname, "templateSyncHandler.ejs")
28
+ /**
29
+ * receive objectSchema
30
+ * create data for WebScoket handler template
31
+ *
32
+ * @param {Object} objectSchema
33
+ * @return {{templatePath, templateData,setting}}
34
+ */
35
+
36
+ function data(_izContext, flowSchema, srcPath) {
37
+ return [createSourceParams(_izContext, flowSchema, srcPath)]
38
+ }
39
+
40
+ function createSourceParams(_izContext, flowSchema, srcPath) {
41
+ let hook;
42
+ let hookFunctionName
43
+ let handlerType;
44
+ let queueName;
45
+ if (flowSchema?.hook) {
46
+ for (const [hookName, hookProperties] of Object.entries(flowSchema.hook)) {
47
+ for (const hookFunction of hookProperties.functionList) {
48
+ if (hookName === FLOW_SCHEMA_HOOK_STATE.beforeCreate) {
49
+ if (hookFunction.event.continueFlow === true && hookFunction.event.initialEvent === false) {
50
+ hook = true
51
+ hookFunctionName = upperCase(hookFunction.name)
52
+ handlerType = upperCase(hookFunction.event.handlerType);
53
+ if (upperCase(handlerType) === upperCase(HANDLER.hdrDsq)) {
54
+ queueName = hookFunction.event.queueName;
55
+ } else if (upperCase(handlerType) === upperCase(HANDLER.hdrSqs)) {
56
+ queueName = hookFunction.event.topicName;
57
+ }
58
+ }
59
+ }
60
+ }
61
+ }
62
+ }
63
+
64
+ if (upperCase(handlerType) === upperCase(HANDLER.hdrSqs) || upperCase(handlerType) === upperCase(HANDLER.hdrDsq)) {
65
+ return {
66
+ templatePath: asyncTemplatePath,
67
+ templateData: {
68
+ hookFunctionName,
69
+ queueName
70
+ },
71
+ setting: {
72
+ savePath: path.join(srcPath, SOURCE_PATH.generatedCodeHookFunction),
73
+ saveFileName: `${upperCase(hookFunctionName)}_${upperCase(handlerType)}`,
74
+ fileExtension: ".js",
75
+ isAppend: false
76
+ }
77
+ }
78
+ } else if (upperCase(handlerType) === upperCase(HANDLER.hdrApi) || upperCase(handlerType) === upperCase(HANDLER.hdrInv)) {
79
+ return {
80
+ templatePath: syncTemplatePath,
81
+ templateData: {
82
+ hookFunctionName,
83
+ },
84
+ setting: {
85
+ savePath: path.join(srcPath, SOURCE_PATH.generatedCodeHookFunction),
86
+ saveFileName: `${upperCase(hookFunctionName)}_${upperCase(handlerType)}`,
87
+ fileExtension: ".js",
88
+ isAppend: false
89
+ }
90
+ }
91
+ }
92
+ }
93
+
94
+ module.exports = data;