@izara_project/izara-market-library-service-schemas 1.0.41 → 1.0.42

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 (88) hide show
  1. package/package.json +1 -1
  2. package/src/MainLibs/src/Consts.js +1 -1
  3. package/src/reStructure/GenerateSchema.js +6 -6
  4. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +20 -12
  5. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +23 -8
  6. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +28 -21
  7. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +0 -32
  8. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/functionYaml/data.js +1 -1
  9. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/functionYaml/template.ejs +1 -0
  10. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/functionYaml/template.ejs +1 -0
  11. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +1 -1
  12. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/functionYaml/template.ejs +1 -0
  13. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/functionYaml/template.ejs +1 -0
  14. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +5 -2
  15. package/src/reStructure/TemplateData/flowSchema/dynamoDb/data.js +0 -20
  16. package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/data.js +7 -16
  17. package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/data.js +2 -2
  18. package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/template.ejs +0 -1
  19. package/src/reStructure/TemplateData/flowSchema/externalTopic/Complete/functionYaml/data.js +112 -0
  20. package/src/reStructure/TemplateData/flowSchema/externalTopic/{functionYaml → Complete/functionYaml}/template.ejs +1 -0
  21. package/src/reStructure/TemplateData/flowSchema/externalTopic/Complete/handler/data.js +93 -0
  22. package/src/reStructure/TemplateData/flowSchema/externalTopic/Complete/mainFunction/data.js +61 -0
  23. package/src/reStructure/TemplateData/flowSchema/externalTopic/Complete/mainFunction/template.ejs +96 -0
  24. package/src/reStructure/TemplateData/flowSchema/externalTopic/{functionYaml → Process/functionYaml}/data.js +20 -4
  25. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → externalTopic/Process}/functionYaml/template.ejs +1 -0
  26. package/src/reStructure/TemplateData/flowSchema/externalTopic/{handler → Process/handler}/data.js +3 -3
  27. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/handler/template.ejs +87 -0
  28. package/src/reStructure/TemplateData/flowSchema/externalTopic/{mainFunction → Process/mainFunction}/data.js +2 -2
  29. package/src/reStructure/TemplateData/flowSchema/externalTopic/{mainFunction → Process/mainFunction}/template.ejs +2 -2
  30. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +14 -4
  31. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/sqsTemplate.ejs +52 -0
  32. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/data.js +1 -1
  33. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/data.js +4 -4
  34. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/template.ejs +1 -0
  35. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/handler/data.js +1 -2
  36. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/handler/template.ejs +1 -1
  37. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/data.js +5 -5
  38. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/template.ejs +5 -2
  39. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +1 -1
  40. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/template.ejs +1 -0
  41. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +1 -1
  42. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/template.ejs +2 -0
  43. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +3 -2
  44. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +2 -2
  45. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +1 -1
  46. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +1 -1
  47. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +2 -2
  48. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +9 -21
  49. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/sqsTemplate.ejs +0 -10
  50. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +1 -1
  51. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → flowStep}/functionYaml/data.js +36 -23
  52. package/src/reStructure/TemplateData/flowSchema/flowStep/functionYaml/template.ejs +20 -0
  53. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → flowStep}/handler/data.js +22 -18
  54. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → flowStep}/mainFunction/data.js +22 -18
  55. package/src/reStructure/TemplateData/flowSchema/flowStep/sns-in/data.js +90 -0
  56. package/src/reStructure/TemplateData/flowSchema/flowStep/sns-in/template.ejs +45 -0
  57. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +41 -25
  58. package/src/reStructure/TemplateData/flowSchema/register/complete/functionYaml/data.js +1 -0
  59. package/src/reStructure/TemplateData/flowSchema/register/complete/functionYaml/template.ejs +1 -0
  60. package/src/reStructure/TemplateData/flowSchema/register/complete/handler/data.js +0 -1
  61. package/src/reStructure/TemplateData/flowSchema/register/complete/mainFunction/template.ejs +16 -17
  62. package/src/reStructure/TemplateData/flowSchema/register/dynamoDB/register.js +0 -17
  63. package/src/reStructure/TemplateData/flowSchema/register/sns-in/data.js +0 -1
  64. package/src/reStructure/TemplateData/flowSchema/register/subscriptionOutAll/data.js +1 -3
  65. package/src/reStructure/TemplateData/flowSchema/register/subscriptionOutAll/template.ejs +2 -2
  66. package/src/reStructure/TemplateData/flowSchema/register/wbs/functionYaml/data.js +0 -29
  67. package/src/reStructure/TemplateData/flowSchema/register/wbs/handler/data.js +0 -1
  68. package/src/reStructure/TemplateData/flowSchema/register/wbs/handler/template.ejs +0 -5
  69. package/src/reStructure/TemplateData/flowSchema/register/wbs/mainFunction/template.ejs +16 -15
  70. package/src/reStructure/TemplateData/flowSchema/templateBystatusType/triggerCacheTemplate.ejs +7 -1
  71. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/functionYaml/data.js +1 -1
  72. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/functionYaml/template.ejs +2 -1
  73. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/sqs/data.js +97 -0
  74. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/sqs/template.ejs +52 -0
  75. package/src/reStructure/TemplateData/perActionComplete/create/yaml/template.ejs +1 -0
  76. package/src/reStructure/TemplateData/perActionComplete/delete/yaml/template.ejs +1 -0
  77. package/src/reStructure/TemplateData/perActionComplete/get/yaml/template.ejs +1 -0
  78. package/src/reStructure/TemplateData/perActionComplete/update/yaml/template.ejs +1 -0
  79. package/src/reStructure/TemplateData/propertyValueSchema/generateTemplateData.js +18 -18
  80. package/src/reStructure/TemplateData/propertyValueSchema/objectPropertyValueSchema/data.js +82 -79
  81. package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js +33 -37
  82. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/functionYaml/template.ejs +1 -0
  83. package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/functionYaml/template.ejs +1 -0
  84. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/template.ejs +1 -0
  85. package/src/reStructure/TemplateData/relationshipPerAction/update/complete/functionYaml/template.ejs +1 -0
  86. /package/src/reStructure/TemplateData/flowSchema/externalTopic/{handler → Complete/handler}/template.ejs +0 -0
  87. /package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → flowStep}/handler/template.ejs +0 -0
  88. /package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → flowStep}/mainFunction/template.ejs +0 -0
@@ -74,11 +74,14 @@ module.exports.<%- functionName %> = async (
74
74
  _izContext.correlationIds.get(consts.X_CORRELATION_ID)
75
75
  _izContext.correlationIds.get(consts.CONNECTION_ID);
76
76
 
77
+ //(<endpointHook>)
78
+ //(</endpointHook>)
77
79
  const flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
78
- flowTag: requestParams.action,
80
+ flowTag: "<%- flowTag %>",
79
81
  serviceTag: process.env.iz_serviceTag
80
82
  })
81
-
83
+ //(<beforeReturn>)
84
+ //(</beforeReturn>)
82
85
 
83
86
  return {
84
87
  //(<endpointReturn>)
@@ -58,7 +58,7 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
58
58
  let handlerType = upperCase(HANDLER.hdrSqs)
59
59
  let additionalResourcePermission = defaultIamRolePerAction();
60
60
  let route = upperCase(flowSchema.flowTag);
61
- let queueName = "Process" + upperCase(flowSchema.flowTag) + handlerType;
61
+ let queueName = upperCase(flowSchema.flowTag) + handlerType;
62
62
  additionalResourcePermission.push(
63
63
  createIamRole(
64
64
  {
@@ -8,6 +8,7 @@
8
8
  batchSize: 10
9
9
  filterPatterns: #**** need to update serverless framwork upper v.2.69.1
10
10
  - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%- functionName %>"]}}} # functionName of callingFlow
11
+ - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
11
12
  role: <%- roleName %>Role
12
13
  #<#<%- functionName %><%- handlerType %>IamRole#>
13
14
  #<#/<%- functionName %><%- handlerType %>IamRole#>
@@ -39,7 +39,7 @@ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
39
39
  let functionName = "Process" + upperCase(flowSchema.flowTag)
40
40
  let handlerType = upperCase(HANDLER.hdrSqs)
41
41
  let route = upperCase(flowSchema.flowTag);
42
- let queueName = `Process${upperCase(flowSchema.flowTag)}${upperCase(handlerType)}`
42
+ let queueName = `${upperCase(flowSchema.flowTag)}${upperCase(handlerType)}`
43
43
 
44
44
  return {
45
45
  templatePath: templatePath,
@@ -53,6 +53,8 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
53
53
 
54
54
  // add argument (to invoke lambda) to passOnProperties[]
55
55
  passOnProperties.push(record.body.Message)
56
+ //(<additionalParams>)
57
+ //(</additionalParams>)
56
58
  record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
57
59
 
58
60
  // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
 
18
18
  'use strict';
19
19
  const path = require('path');
20
-
20
+ const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
21
21
  const { SOURCE_PATH, FUNCTION_NAME, HANDLER } = require('../../../../../../MainLibs/src/Consts');
22
22
  const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils")
23
23
  const templatePath = path.join(__dirname, "template.ejs");
@@ -45,6 +45,7 @@ async function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
45
45
  let tableName = null;
46
46
  if (flowSchema.statusType === "storedCache" || flowSchema.statusType === "triggerCache") {
47
47
  let objectSchema = await getObjectSchema.getLocalObjectSchemas(_izContext, [flowSchema.objType.objectType], path.join(srcPath, "./schemas")).then(res => res.records[0]);
48
+ if (!objectSchema) throw new NoRetryError('no objectSchema in local service')
48
49
  for (const storageResource of Object.values(objectSchema.storageResources)) {
49
50
  if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
50
51
  tableName = storageResource.tableName
@@ -56,7 +57,7 @@ async function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
56
57
  if (flowSchema.statusType === "triggerCache" && flowSchema.hasOwnProperty("triggerType")) {
57
58
  triggerType = flowSchema.triggerType;
58
59
  }
59
- let flowSchemaComplete = upperCase(flowSchema.flowTag) + "Complete"
60
+ let flowSchemaComplete = upperCase(flowSchema.flowTag)
60
61
 
61
62
  return {
62
63
  templatePath: templatePath,
@@ -61,9 +61,9 @@ const { createFieldNamesFromRequestParamsByObjectSchema } = require('@izara_proj
61
61
  module.exports.<%- functionName %> = async (
62
62
  _izContext,
63
63
  requestParams,
64
- callingFlowConfig = {},
65
64
  //(<additionalParams>)
66
65
  //(</additionalParams>)
66
+ callingFlowConfig = {},
67
67
  ) => {
68
68
 
69
69
  try {
@@ -75,7 +75,7 @@ module.exports.<%- functionName %> = async (
75
75
  _izContext.correlationIds.get(consts.CONNECTION_ID);
76
76
 
77
77
  const flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
78
- flowTag: requestParams.action,
78
+ flowTag: "<%- flowTag %>",
79
79
  serviceTag: process.env.iz_serviceTag
80
80
  })
81
81
 
@@ -55,7 +55,7 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
55
55
  let handlerType = upperCase("hdrWbs")
56
56
  let additionalResourcePermission = defaultIamRolePerAction();
57
57
  let route = flowSchema.flowTag;
58
- let topicIn = `Process${upperCase(flowSchema.flowTag)}_In`
58
+ let topicIn = `${upperCase(flowSchema.flowTag)}_In`
59
59
 
60
60
  additionalResourcePermission.push(
61
61
  createIamRole(
@@ -50,7 +50,7 @@ function data(_izContext, flowSchema, srcPath) {
50
50
 
51
51
  function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
52
52
  let functionName = upperCase(flowSchema.flowTag)
53
- let topicArn = `Process${upperCase(flowSchema.flowTag)}_In`
53
+ let topicArn = `${upperCase(flowSchema.flowTag)}_In`
54
54
 
55
55
  return {
56
56
  templatePath: templatePath,
@@ -66,7 +66,7 @@ module.exports.<%- functionName %> = async (
66
66
  _izContext.logger.debug("<%- functionName %> callingFlowConfig", callingFlowConfig)
67
67
 
68
68
  let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
69
- flowTag: requestParams.action,
69
+ flowTag: "<%- flowTag %>",
70
70
  serviceTag: process.env.iz_serviceTag
71
71
  })
72
72
 
@@ -91,7 +91,7 @@ module.exports.<%- functionName %> = async (
91
91
  callingFlowSharedLib.addParentCallingFlowConfig(
92
92
  callingFlowConfig,
93
93
  callingFlowSharedLib.createCallingFlowConfig(
94
- await lambdaSharedLib.lambdaFunctionName(_izContext, "WebSocketCompleteHdrSqs"), {}
94
+ await lambdaSharedLib.lambdaFunctionName(_izContext, "WebSocketComplete"), {}
95
95
  )
96
96
  )
97
97
  )
@@ -22,14 +22,14 @@ const path = require("path")
22
22
 
23
23
  // const {
24
24
  // HANDLER,
25
- // STORAGE_TYPES
25
+ // STORAGE_TYPES
26
26
  // } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
27
27
 
28
28
  const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils.js");
29
- const STORAGE_TYPES = {
30
- dynamoDB: "dynamoDB",
31
- graph: "graph"
32
- }
29
+ // const STORAGE_TYPES = {
30
+ // dynamoDB: "dynamoDB",
31
+ // graph: "graph"
32
+ // }
33
33
 
34
34
  const snsTemplatePath = path.join(__dirname, '../../../resourceYaml/sns-in-sqs/snsTemplate.ejs');
35
35
  const subscriptionSqsTemplatePath = path.join(__dirname, './sqsTemplate.ejs');
@@ -64,7 +64,7 @@ function createDataForDefaultSnsInSqs(_izContext, flowSchema, srcPath) {
64
64
  if (flowSteps.includes("In")) {
65
65
  generatedSnsTopicInForFlowSchema.push(
66
66
  {
67
- queueName: "Process" + upperCase(topicIn)
67
+ queueName: upperCase(topicIn)
68
68
  }
69
69
  )
70
70
  }
@@ -75,28 +75,16 @@ function createDataForDefaultSnsInSqs(_izContext, flowSchema, srcPath) {
75
75
  if (flowSchema.outputTopic) {
76
76
  if (flowSteps.includes("Out")) {
77
77
  if (flowSchema.outputTopic) {
78
- let topicOut = `${upperCase(flowSchema.flowTag)}Complete`;
79
- defaultDsqQueueDataList.push({
80
- queueName: `WebSocketComplete` + upperCase(HANDLER.hdrSqs),
81
- subscribeTo: topicOut
82
- }
83
- )
84
- }
85
- }
86
- }
87
-
88
- if (flowSteps.includes("In") && flowSteps.includes("Out")) {
89
- if (flowSteps.length > 2) {
90
- for (let i = 2; i < flowSteps.length; i++) {
91
- generatedSnsTopicInForFlowSchema.push(
78
+ defaultDsqQueueDataList.push(
92
79
  {
93
- queueName: upperCase(flowSteps[i])
80
+ queueName: upperCase(topicIn) + "CompleteHdrSqs"
94
81
  }
95
82
  )
96
83
  }
97
84
  }
98
85
  }
99
86
 
87
+
100
88
  for (let defaultSnsInSqsData of generatedSnsTopicInForFlowSchema) {
101
89
  resultsForCreateDefaultSnsInSqs.push({
102
90
  templatePath: snsTemplatePath,
@@ -1,13 +1,3 @@
1
- <% if (subscribeTo) { %>
2
- ##===== SNS Subscription
3
- ##===== [Topic In]
4
- SubscriptionToOut<%- subscribeTo %>:
5
- Type: AWS::SNS::Subscription
6
- Properties:
7
- TopicArn: !Ref Out<%- subscribeTo %>
8
- Endpoint: "arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>"
9
- Protocol: "sqs"
10
- <% } %>
11
1
  #------- queue ---------
12
2
  <%- queueName %>:
13
3
  Type: "AWS::SQS::Queue"
@@ -55,7 +55,7 @@ function createDataForSnsOut(_izContext, flowSchema, srcPath) {
55
55
  if (flowSchema.outputTopic) {
56
56
  generatedSnsTopicOutForFlowSchema.push(
57
57
  {
58
- queueName: upperCase(topicOut) + "Complete"
58
+ queueName: upperCase(topicOut)
59
59
  }
60
60
  )
61
61
  }
@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
  const path = require('path');
20
20
 
21
21
  const { FLOW_SCHEMA_HOOK_STATE, ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
22
- const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
22
+ const { firstLetterUpperCase: upperCase } = require('../../../../../MainLibs/src/Utils')
23
23
  const {
24
24
  SOURCE_PATH,
25
25
  defaultIamRolePerAction,
@@ -32,9 +32,10 @@ const {
32
32
  FUNCTION_NAME,
33
33
  shortNameHandler,
34
34
  externalResourceYaml,
35
- SOURCE_GENERATE_IAM_ROLE
36
- } = require('../../../../../../MainLibs/src/Consts');
37
- const { TOPIC_NAME_GENERATE_CODE } = require('../../../../../../GenerateCodeLibs/src/Consts');
35
+ SOURCE_GENERATE_IAM_ROLE,
36
+ SQS_RESOURCE
37
+ } = require('../../../../../MainLibs/src/Consts');
38
+ const { TOPIC_NAME_GENERATE_CODE } = require('../../../../../GenerateCodeLibs/src/Consts');
38
39
 
39
40
  const templatePath = path.join(__dirname, "template.ejs");
40
41
  const hookTemplate = path.join(__dirname, "./hookTemplate.ejs");
@@ -48,22 +49,26 @@ const hookTemplate = path.join(__dirname, "./hookTemplate.ejs");
48
49
 
49
50
  function data(_izContext, flowSchema, srcPath) {
50
51
  let resultCreateSource = [];
51
- let flowSteps = Object.keys(flowSchema.flowSteps)
52
- let events = flowSchema.event
53
- for (const event of events) {
54
- if (event === "ownTopic") {
55
- if (flowSteps.includes("In") && flowSteps.includes("Out")) {
56
- if (flowSteps.length > 2) {
57
- for (let i = 2; i < flowSteps.length; i++) {
58
- let createSource = createSourceParams(_izContext, flowSchema.flowTag, flowSteps[i], srcPath)
59
- createSource && resultCreateSource.push(createSource);
60
- }
61
- }
62
- } else if (flowSteps.includes("In") && !flowSchema.outputTopic) {
63
- if (flowSteps.length > 1) {
64
- for (let i = 1; i < flowSteps.length; i++) {
65
- let createSource = createSourceParams(_izContext, flowSchema.flowTag, flowSteps[i], srcPath)
66
- createSource && resultCreateSource.push(createSource);
52
+ if (flowSchema.hasOwnProperty("flowSteps")) {
53
+ let flowSteps = Object.keys(flowSchema.flowSteps)
54
+ if (flowSteps.length && flowSteps.length > 0) {
55
+ let events = flowSchema.event
56
+ for (const event of events) {
57
+ if (event === "ownTopic") {
58
+ if (flowSteps.includes("In") && flowSteps.includes("Out")) {
59
+ if (flowSteps.length > 2) {
60
+ for (let i = 2; i < flowSteps.length; i++) {
61
+ let createSource = createSourceParams(_izContext, flowSteps[i], srcPath)
62
+ createSource && resultCreateSource.push(createSource);
63
+ }
64
+ }
65
+ } else if (flowSteps.includes("In") && !flowSchema.outputTopic) {
66
+ if (flowSteps.length > 1) {
67
+ for (let i = 1; i < flowSteps.length; i++) {
68
+ let createSource = createSourceParams(_izContext, flowSteps[i], srcPath)
69
+ createSource && resultCreateSource.push(createSource);
70
+ }
71
+ }
67
72
  }
68
73
  }
69
74
  }
@@ -72,8 +77,8 @@ function data(_izContext, flowSchema, srcPath) {
72
77
  return resultCreateSource
73
78
  }
74
79
 
75
- function createSourceParams(_izContext, flowTag, flowStep, srcPath) {
76
- let functionName = upperCase(flowTag);
80
+ function createSourceParams(_izContext, flowStep, srcPath) {
81
+ let functionName = upperCase(flowStep);
77
82
  let handlerType = upperCase(HANDLER.hdrSqs);
78
83
  let topicIn = upperCase(flowStep);
79
84
  let additionalResourcePermission = defaultIamRolePerAction();
@@ -87,10 +92,18 @@ function createSourceParams(_izContext, flowTag, flowStep, srcPath) {
87
92
  [
88
93
  resourceNames(RESOURCE_CLASSES.sns, topicIn + "_In")
89
94
  ]
95
+ ),
96
+ createIamRole(
97
+ {
98
+ [RESOURCE_CLASSES.sqs]: [SQS_RESOURCE.sendMessage, SQS_RESOURCE.receiveMessage, SQS_RESOURCE.deleteMessage, SQS_RESOURCE.getQueueAttributes, SQS_RESOURCE.deleteMessageBatch, SQS_RESOURCE.getQueueUrl]
99
+ },
100
+ [
101
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(flowStep) + upperCase(handlerType)),
102
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(flowStep) + upperCase(handlerType) + "DLQ")
103
+ ]
90
104
  )
91
105
  )
92
106
 
93
-
94
107
  return {
95
108
  templatePath: templatePath,
96
109
  templateData: {
@@ -0,0 +1,20 @@
1
+ <%_ const join = require('path').join; _%>
2
+ <%- firstLetterUpperCase(functionNameConfig) %>:
3
+ handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
4
+ name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
5
+ events:
6
+ - sqs:
7
+ arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>
8
+ batchSize: 10
9
+ filterPatterns: #**** need to update serverless framwork upper v.2.69.1
10
+ - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%- functionName %>"]}}} # functionName of callingFlow
11
+ - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
12
+ role: <%- roleName %>Role
13
+ #<#<%- functionName %><%- handlerType %>IamRole#>
14
+ #<#/<%- functionName %><%- handlerType %>IamRole#>
15
+ <%_ function firstLetterUpperCase(text){
16
+ return text.charAt(0).toUpperCase() + text.slice(1)
17
+ } _%>
18
+ <%_ function firstLetterLowerCase(str) {
19
+ return str.charAt(0).toLowerCase() + str.slice(1)
20
+ } _%>
@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
  'use strict';
19
19
  const path = require('path');
20
20
  const { FLOW_SCHEMA_HOOK_STATE, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
21
- const { SOURCE_PATH, FUNCTION_NAME } = require('../../../../../../MainLibs/src/Consts');
22
- const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils")
21
+ const { SOURCE_PATH, FUNCTION_NAME } = require('../../../../../MainLibs/src/Consts');
22
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils")
23
23
  const templatePath = path.join(__dirname, "template.ejs")
24
24
 
25
25
  /**
@@ -33,22 +33,26 @@ const templatePath = path.join(__dirname, "template.ejs")
33
33
 
34
34
  function data(_izContext, flowSchema, srcPath) {
35
35
  let resultCreateParam = [];
36
- let flowSteps = Object.keys(flowSchema.flowSteps);
37
- let events = flowSchema.event;
38
- for (const event of events) {
39
- if (event === "ownTopic") {
40
- if (flowSteps.includes("In") && flowSteps.includes("Out")) {
41
- if (flowSteps.length > 2) {
42
- for (let i = 2; i < flowSteps.length; i++) {
43
- let createSource = createParamsForCreateSource(_izContext, upperCase(flowSchema.flowTag), upperCase(flowSteps[i]), srcPath);
44
- createSource && resultCreateParam.push(createSource)
45
- }
46
- }
47
- } else if (flowSteps.includes("In") && !flowSchema.outputTopic) {
48
- if (flowSteps.length > 1) {
49
- for (let i = 1; i < flowSteps.length; i++) {
50
- let createSource = createParamsForCreateSource(_izContext, upperCase(flowSchema.flowTag), upperCase(flowSteps[i]), srcPath);
51
- createSource && resultCreateParam.push(createSource)
36
+ if (flowSchema.hasOwnProperty("flowSteps")) {
37
+ let flowSteps = Object.keys(flowSchema.flowSteps);
38
+ if (flowSteps.length && flowSteps.length > 0) {
39
+ let events = flowSchema.event;
40
+ for (const event of events) {
41
+ if (event === "ownTopic") {
42
+ if (flowSteps.includes("In") && flowSteps.includes("Out")) {
43
+ if (flowSteps.length > 2) {
44
+ for (let i = 2; i < flowSteps.length; i++) {
45
+ let createSource = createParamsForCreateSource(_izContext, upperCase(flowSchema.flowTag), upperCase(flowSteps[i]), srcPath);
46
+ createSource && resultCreateParam.push(createSource)
47
+ }
48
+ }
49
+ } else if (flowSteps.includes("In") && !flowSchema.outputTopic) {
50
+ if (flowSteps.length > 1) {
51
+ for (let i = 1; i < flowSteps.length; i++) {
52
+ let createSource = createParamsForCreateSource(_izContext, upperCase(flowSchema.flowTag), upperCase(flowSteps[i]), srcPath);
53
+ createSource && resultCreateParam.push(createSource)
54
+ }
55
+ }
52
56
  }
53
57
  }
54
58
  }
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
 
18
18
  'use strict';
19
19
  const path = require('path');
20
- const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
20
+ const { firstLetterUpperCase: upperCase } = require('../../../../../MainLibs/src/Utils')
21
21
  const {
22
22
  SOURCE_PATH,
23
23
  defaultIamRolePerAction,
@@ -32,7 +32,7 @@ const {
32
32
  externalResourceYaml,
33
33
  SOURCE_GENERATE_IAM_ROLE,
34
34
  HANDLER
35
- } = require('../../../../../../MainLibs/src/Consts');
35
+ } = require('../../../../../MainLibs/src/Consts');
36
36
  const templatePath = path.join(__dirname, "template.ejs");
37
37
 
38
38
 
@@ -47,22 +47,26 @@ const templatePath = path.join(__dirname, "template.ejs");
47
47
 
48
48
  function data(_izContext, flowSchema, srcPath) {
49
49
  let resultCreateSource = [];
50
- let flowSteps = Object.keys(flowSchema.flowSteps)
51
- let events = flowSchema.event
52
- for (const event of events) {
53
- if (event === "ownTopic") {
54
- if (flowSteps.includes("In") && flowSteps.includes("Out")) {
55
- if (flowSteps.length > 2) {
56
- for (let i = 2; i < flowSteps.length; i++) {
57
- let createSource = createParamsForCreateSource(_izContext, flowSchema.flowTag, flowSteps[i], srcPath)
58
- createSource && resultCreateSource.push(createSource);
59
- }
60
- }
61
- } else if (flowSteps.includes("In") && !flowSchema.outputTopic) {
62
- if (flowSteps.length > 1) {
63
- for (let i = 1; i < flowSteps.length; i++) {
64
- let createSource = createParamsForCreateSource(_izContext, flowSchema.flowTag, flowSteps[i], srcPath)
65
- createSource && resultCreateSource.push(createSource);
50
+ if (flowSchema.hasOwnProperty("flowSteps")) {
51
+ let flowSteps = Object.keys(flowSchema.flowSteps)
52
+ if (flowSteps.length && flowSteps.length > 0) {
53
+ let events = flowSchema.event
54
+ for (const event of events) {
55
+ if (event === "ownTopic") {
56
+ if (flowSteps.includes("In") && flowSteps.includes("Out")) {
57
+ if (flowSteps.length > 2) {
58
+ for (let i = 2; i < flowSteps.length; i++) {
59
+ let createSource = createParamsForCreateSource(_izContext, flowSchema.flowTag, flowSteps[i], srcPath)
60
+ createSource && resultCreateSource.push(createSource);
61
+ }
62
+ }
63
+ } else if (flowSteps.includes("In") && !flowSchema.outputTopic) {
64
+ if (flowSteps.length > 1) {
65
+ for (let i = 1; i < flowSteps.length; i++) {
66
+ let createSource = createParamsForCreateSource(_izContext, flowSchema.flowTag, flowSteps[i], srcPath)
67
+ createSource && resultCreateSource.push(createSource);
68
+ }
69
+ }
66
70
  }
67
71
  }
68
72
  }
@@ -0,0 +1,90 @@
1
+ /*
2
+ Copyright (C) 2020 Sven Mason <http://izara.io>
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Affero General Public License as
6
+ published by the Free Software Foundation, either version 3 of the
7
+ License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Affero General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Affero General Public License
15
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ 'use strict';
19
+
20
+ const path = require("path")
21
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils.js");
22
+
23
+ const templatePath = path.join(__dirname, './template.ejs');
24
+
25
+ const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, HANDLER } = require('../../../../../MainLibs/src/Consts.js');
26
+
27
+ /**
28
+ * create data for dynamoDbYaml tempalte from objectSchema
29
+ * return array of dynamoDb data
30
+ * because one objectSchema can create multiple dynamoDb table
31
+ *
32
+ * @param {Object} _izContext
33
+ * @param {String} saveFilePath
34
+ * @returns {Object[]} - data of multiple dynamoDb template
35
+ */
36
+
37
+ function createDataForDefaultSnsInSqs(_izContext, flowSchema, srcPath) {
38
+ let resultsForCreateDefaultSnsInSqs = [];
39
+ // console.log("create topic by flowSteps", flowSteps)
40
+ const setting = {
41
+ initialData: "Resources:\n",
42
+ savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
43
+ saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
44
+ fileExtension: ".yml",
45
+ isAppend: true
46
+ }
47
+ const generatedSnsTopicInForFlowSchema = [];
48
+ if (flowSchema.hasOwnProperty("flowSteps")) {
49
+ let flowSteps = Object.keys(flowSchema.flowSteps);
50
+ if (flowSteps.length && flowSteps.length > 0) {
51
+ if (flowSchema.outputTopic) {
52
+ if (flowSteps.includes("In") && flowSteps.includes("Out")) {
53
+ if (flowSteps.length > 2) {
54
+ for (let i = 2; i < flowSteps.length; i++) {
55
+ generatedSnsTopicInForFlowSchema.push(
56
+ {
57
+ queueName: upperCase(flowSteps[i])
58
+ }
59
+ )
60
+ }
61
+ }
62
+ }
63
+ } else {
64
+ if (flowSteps.includes("In")) {
65
+ if (flowSteps.length > 1) {
66
+ for (let i = 2; i < flowSteps.length; i++) {
67
+ generatedSnsTopicInForFlowSchema.push(
68
+ {
69
+ queueName: upperCase(flowSteps[i])
70
+ }
71
+ )
72
+ }
73
+ }
74
+ }
75
+ }
76
+ }
77
+ }
78
+
79
+ for (let defaultSnsInSqsData of generatedSnsTopicInForFlowSchema) {
80
+ resultsForCreateDefaultSnsInSqs.push({
81
+ templatePath: templatePath,
82
+ templateData: defaultSnsInSqsData,
83
+ setting: setting
84
+ })
85
+ }
86
+
87
+ return resultsForCreateDefaultSnsInSqs;
88
+ }
89
+
90
+ module.exports = createDataForDefaultSnsInSqs;
@@ -0,0 +1,45 @@
1
+ ##===== [Queue]
2
+ <%- queueName %>HdrSqs:
3
+ Type: "AWS::SQS::Queue"
4
+ Properties:
5
+ QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqs
6
+ RedrivePolicy:
7
+ deadLetterTargetArn:
8
+ # !GetAtt
9
+ Fn::GetAtt:
10
+ - <%- queueName %>HdrSqsDLQ
11
+ - Arn
12
+ maxReceiveCount: 3
13
+ VisibilityTimeout: 120
14
+ ##==== [QueueDLQ]
15
+ <%- queueName %>HdrSqsDLQ:
16
+ Type: AWS::SQS::Queue
17
+ Properties:
18
+ QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqsDLQ
19
+ ##==== [QueuePolicy]
20
+ <%- queueName %>HdrSqsPolicy:
21
+ Type: AWS::SQS::QueuePolicy
22
+ Properties:
23
+ PolicyDocument:
24
+ Version: "2012-10-17"
25
+ Statement:
26
+ - Sid: "allow-sns-messages"
27
+ Effect: Allow
28
+ Principal: "*"
29
+ Resource:
30
+ # !GetAtt
31
+ Fn::GetAtt:
32
+ - <%- queueName %>HdrSqs
33
+ - Arn
34
+ Action: "SQS:SendMessage"
35
+ Queues:
36
+ - Ref: <%- queueName %>HdrSqs
37
+ #<#<%- firstLetterUpperCase(queueName) %>QueueSetting#>
38
+ #<#/<%- firstLetterUpperCase(queueName) %>QueueSetting#>
39
+
40
+ <%_ function firstLetterUpperCase(text){
41
+ return text.charAt(0).toUpperCase() + text.slice(1)
42
+ } _%>
43
+ <%_ function firstLetterLowerCase(str) {
44
+ return str.charAt(0).toLowerCase() + str.slice(1)
45
+ } _%>