@izara_project/izara-market-library-service-schemas 1.0.34 → 1.0.36

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 (135) hide show
  1. package/package.json +1 -1
  2. package/src/GenerateCodeLibs/src/Consts.js +2 -1
  3. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +7 -6
  4. package/src/MainLibs/src/Consts.js +47 -14
  5. package/src/MainLibs/src/GenerateCodeUtils.js +2 -0
  6. package/src/TemplateManager/src/attributeTree/relationshipSchema/data.js +1 -1
  7. package/src/TemplateManager/src/attributeTreeSchema/generateTemplateData.js +103 -0
  8. package/src/{reStructure/TemplateData/attributeTreeSchema/mainAttributeTreeSchema → TemplateManager/src/attributeTreeSchema/mainAttributeTree}/attributeLinkTemplate.ejs +3 -7
  9. package/src/TemplateManager/src/attributeTreeSchema/mainAttributeTree/data.js +134 -0
  10. package/src/TemplateManager/src/attributeTreeSchema/referenceRelationshipSchema/data.js +84 -0
  11. package/src/TemplateManager/src/attributeTreeSchema/referenceRelationshipSchema/tempReferenceRelationshipSchema.ejs +9 -0
  12. package/src/TemplateManager/src/attributeTreeSchema/relationshipSchema/data.js +172 -0
  13. package/src/TemplateManager/src/attributeTreeSchema/relationshipSchema/template.ejs +7 -0
  14. package/src/reStructure/GenerateCode.js +1 -0
  15. package/src/reStructure/SchemaConfig.js +1 -3
  16. package/src/reStructure/TemplateData/EndpointPerService/handler/api/template.ejs +2 -2
  17. package/src/reStructure/TemplateData/EndpointPerService/handler/inv/template.ejs +2 -2
  18. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/backupTemplate.ejs +701 -0
  19. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +34 -159
  20. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +2 -0
  21. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +3 -4
  22. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +2 -0
  23. package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +38 -12
  24. package/src/reStructure/TemplateData/externalService/lambdaRole/template.ejs +5 -2
  25. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +22 -14
  26. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/template.ejs +4 -1
  27. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/functionYaml/data.js +123 -0
  28. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/functionYaml/template.ejs +20 -0
  29. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/handler/data.js +57 -0
  30. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/handler/template.ejs +85 -0
  31. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/data.js +68 -0
  32. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/template.ejs +131 -0
  33. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/queue/data.js +77 -0
  34. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/queue/template.ejs +49 -0
  35. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/template.ejs +1 -1
  36. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/mainFunction/template.ejs +1 -1
  37. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +1 -1
  38. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/data.js +12 -4
  39. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/template.ejs +13 -8
  40. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/template.ejs +4 -4
  41. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/data.js +141 -0
  42. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/template.ejs +20 -0
  43. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/handler/data.js +55 -0
  44. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/handler/template.ejs +83 -0
  45. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/data.js +55 -0
  46. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/template.ejs +131 -0
  47. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/dynamoDB/register.js +82 -0
  48. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/data.js +64 -0
  49. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/template.ejs +45 -0
  50. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/statusFieldTemplate.ejs +19 -6
  51. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs +9 -15
  52. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/data.js +76 -0
  53. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/template.ejs +13 -0
  54. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/data.js +164 -0
  55. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/template.ejs +18 -0
  56. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/handler/data.js +64 -0
  57. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/handler/template.ejs +88 -0
  58. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/data.js +55 -0
  59. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/template.ejs +222 -0
  60. package/src/reStructure/TemplateData/flowSchema/dynamoDb/data.js +83 -44
  61. package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/data.js +26 -59
  62. package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/template.ejs +3 -3
  63. package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/data.js +8 -8
  64. package/src/reStructure/TemplateData/flowSchema/eventBridge/mainFunction/data.js +11 -9
  65. package/src/reStructure/TemplateData/flowSchema/eventBridge/mainFunction/template.ejs +3 -3
  66. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +5 -9
  67. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/template.ejs +1 -7
  68. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/data.js +2 -3
  69. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/template.ejs +2 -4
  70. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/data.js +37 -11
  71. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/template.ejs +4 -4
  72. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/data.js +8 -9
  73. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/template.ejs +13 -13
  74. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/data.js +4 -4
  75. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/template.ejs +44 -69
  76. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/data.js +7 -44
  77. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/template.ejs +3 -3
  78. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/data.js +3 -10
  79. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/template.ejs +40 -86
  80. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/data.js +11 -4
  81. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/template.ejs +11 -8
  82. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/data.js +17 -3
  83. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/template.ejs +2 -2
  84. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/data.js +8 -2
  85. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/template.ejs +49 -84
  86. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +55 -10
  87. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/template.ejs +1 -1
  88. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +2 -2
  89. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/template.ejs +1 -1
  90. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +27 -8
  91. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +50 -20
  92. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/data.js +20 -5
  93. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/template.ejs +1 -1
  94. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/handler/data.js +2 -2
  95. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/handler/template.ejs +5 -5
  96. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/mainFunction/data.js +5 -3
  97. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/mainFunction/template.ejs +7 -5
  98. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +6 -3
  99. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/template.ejs +0 -2
  100. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/data.js +2 -2
  101. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +3 -3
  102. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +9 -9
  103. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +17 -39
  104. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +14 -8
  105. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +4 -1
  106. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +90 -21
  107. package/src/reStructure/TemplateData/generateRole/createSharedResource.js +22 -1
  108. package/src/reStructure/TemplateData/generateRole/sharedResourceTemplate.ejs +3 -0
  109. package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +9 -8
  110. package/src/reStructure/TemplateData/perActionComplete/delete/mainFunction/template.ejs +5 -1
  111. package/src/reStructure/TemplateData/perActionComplete/get/mainFunction/template.ejs +2 -1
  112. package/src/reStructure/TemplateData/processLogical/mainFunction/template.ejs +1 -0
  113. package/src/reStructure/TemplateData/propertyValueSchema/generateTemplateData.js +66 -0
  114. package/src/reStructure/TemplateData/propertyValueSchema/objectPropertyValueSchema/data.js +131 -0
  115. package/src/reStructure/TemplateData/propertyValueSchema/objectPropertyValueSchema/templateObjectPropertyValueSchema.ejs +16 -0
  116. package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js +156 -0
  117. package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/tempRelationship.ejs +13 -0
  118. package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/templateRelationshipPropertyValueSchema.ejs +7 -0
  119. package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +2 -1
  120. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +2 -1
  121. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/mainFunction/template.ejs +2 -1
  122. package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/handler/sqs/template.ejs +5 -5
  123. package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/mainFunction/template.ejs +5 -4
  124. package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +2 -1
  125. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/handler/sqs/template.ejs +4 -4
  126. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/mainFunction/template.ejs +4 -3
  127. package/src/reStructure/TemplateData/relationshipPerAction/update/action/mainFunction/template.ejs +2 -1
  128. package/src/reStructure/TemplateData/relationshipPerAction/update/complete/mainFunction/template.ejs +2 -1
  129. package/src/reStructure/TemplateData/resourceYaml/dynamodb/template.ejs +1 -3
  130. package/src/reStructure/TemplateData/resourceYaml/filterGenerateResource/data.js +61 -0
  131. package/src/reStructure/TemplateData/resourceYaml/generateTemplateData.js +13 -4
  132. package/src/reStructure/libs/ValidateAddOnDataStructure.js +62 -0
  133. package/src/reStructure/TemplateData/attributeTreeSchema/generateTemplateData.js +0 -104
  134. package/src/reStructure/TemplateData/attributeTreeSchema/mainAttributeTreeSchema/data.js +0 -188
  135. /package/src/{reStructure/TemplateData/attributeTreeSchema/mainAttributeTreeSchema → TemplateManager/src/attributeTreeSchema/mainAttributeTree}/request.json +0 -0
@@ -35,6 +35,9 @@ const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryEr
35
35
  const { v4: uuidv4 } = require('uuid')
36
36
  const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
37
37
  const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
38
+ <% if (statusType === "statusField") { %>
39
+ const { createFieldNamesFromRequestParamsByObjectSchema } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs')
40
+ <% } %>
38
41
  /**
39
42
  *
40
43
  *
@@ -50,7 +53,7 @@ const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-librar
50
53
  * @returns {object} description of return value
51
54
  */
52
55
 
53
- module.exports.<%- externalTopicMain%> = async (
56
+ module.exports.<%- externalTopicMain %> = async (
54
57
  _izContext,
55
58
  requestParams,
56
59
  callingFlowConfig = {},
@@ -59,13 +62,13 @@ module.exports.<%- externalTopicMain%> = async (
59
62
  ) => {
60
63
 
61
64
  try {
62
- // send message to ImportBatchCreateHdrSqs
63
- let sendMessageToCreateEndpoint = {
64
- Message: JSON.stringify(requestParams),
65
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, '<%- topicName%>', '<%- serviceTag%>')
66
- }
67
- _izContext.logger.debug("sendMessageToCreateEndpoint", sendMessageToCreateEndpoint);
68
- await sns.publishAsync(_izContext, sendMessageToCreateEndpoint);
65
+ let sendMessageToCreateEndpoint = {
66
+ Message: JSON.stringify(requestParams),
67
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, '<%- topicName %>', '<%- serviceTag%>')
68
+ }
69
+ _izContext.logger.debug("sendMessageToCreateEndpoint", sendMessageToCreateEndpoint);
70
+ await sns.publishAsync(_izContext, sendMessageToCreateEndpoint);
71
+
69
72
 
70
73
  } catch (err) {
71
74
  _izContext.logger.error('error WebSocketInvoke: ', err)
@@ -32,7 +32,8 @@ const {
32
32
  FUNCTION_NAME,
33
33
  shortNameHandler,
34
34
  externalResourceYaml,
35
- SOURCE_GENERATE_IAM_ROLE
35
+ SOURCE_GENERATE_IAM_ROLE,
36
+ SQS_RESOURCE
36
37
  } = require('../../../../../../MainLibs/src/Consts');
37
38
  const { TOPIC_NAME_GENERATE_CODE } = require('../../../../../../GenerateCodeLibs/src/Consts');
38
39
 
@@ -55,13 +56,25 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
55
56
  let handlerType = upperCase(HANDLER.hdrSqs)
56
57
  let additionalResourcePermission = defaultIamRolePerAction();
57
58
  let flowSteps = Object.keys(flowSchema.flowSteps)
59
+ let flowStepsOut = flowSteps[1];
60
+ let splitFlowStepsOut = flowStepsOut.split("_");
61
+ let topicOut = `${splitFlowStepsOut[3]}_${splitFlowStepsOut[4]}`
62
+ let queueName = functionName + handlerType
58
63
  additionalResourcePermission.push(
59
64
  createIamRole(
60
65
  {
61
66
  [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
62
67
  },
63
68
  [
64
- resourceNames(RESOURCE_CLASSES.sns, flowSteps[1])
69
+ resourceNames(RESOURCE_CLASSES.sns, topicOut)
70
+ ]
71
+ ),
72
+ createIamRole(
73
+ {
74
+ [RESOURCE_CLASSES.sqs]: [SQS_RESOURCE.sendMessage, SQS_RESOURCE.receiveMessage, SQS_RESOURCE.deleteMessage, SQS_RESOURCE.getQueueAttributes]
75
+ },
76
+ [
77
+ resourceNames(RESOURCE_CLASSES.sqs, queueName)
65
78
  ]
66
79
  )
67
80
  )
@@ -75,7 +88,8 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
75
88
  handlerType,
76
89
  additionalResourcePermission,
77
90
  functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
78
- roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic
91
+ roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic,
92
+ queueName: queueName
79
93
  },
80
94
  setting: {
81
95
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
@@ -3,8 +3,8 @@
3
3
  handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
4
4
  name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
5
5
  events:
6
- - sqs:
7
- arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- functionName %>
6
+ - sqs:
7
+ arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>
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
@@ -23,6 +23,7 @@ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = req
23
23
  const templatePath = path.join(__dirname, "template.ejs");
24
24
  const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
25
25
 
26
+
26
27
  /**
27
28
  * receive objectSchema
28
29
  * create data for WebScoket handler template
@@ -38,11 +39,16 @@ function data(_izContext, flowSchema, srcPath) {
38
39
 
39
40
  function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
40
41
  let functionName = upperCase(FUNCTION_NAME.flowSchemaOwnTopicEndpointComplete)
41
- let topicArn = Object.keys(flowSchema.flowSteps)[1]
42
+ // let topicArn = Object.keys(flowSchema.flowSteps)[1]
43
+ let flowSteps = Object.keys(flowSchema.flowSteps)
44
+ let flowStepsOut = flowSteps[1];
45
+ let splitFlowStepsOut = flowStepsOut.split("_");
46
+ let topicOut = `${splitFlowStepsOut[3]}+_${splitFlowStepsOut[4]}`
42
47
  return {
43
48
  templatePath: templatePath,
44
49
  templateData: {
45
- topicArn
50
+ topicOut,
51
+
46
52
  },
47
53
  setting: {
48
54
  savePath: path.join(srcPath, SOURCE_PATH.flowSchemaOwnTopic, flowSchema.flowTag, "source/"),
@@ -1,85 +1,50 @@
1
- /*
2
- Copyright (C) 2020 Sven Mason <http: //izara.io>
3
-
4
- This program is free software: you can redistribute it and/or modify
5
- it under the terms of the GNU Affero General Public License as
6
- published by the Free Software Foundation, either version 3 of the
7
- License, or (at your option) any later version.
8
-
9
- This program is distributed in the hope that it will be useful,
10
- but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- GNU Affero General Public License for more details.
13
-
14
- You should have received a copy of the GNU Affero General Public License
15
- along with this program. If not, see
16
- <http: //www.gnu.org/licenses />.
17
- */
18
-
19
- 'use strict';
20
-
21
- const hash = require("object-hash");
22
- const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
23
-
1
+ /* Copyright (C) 2020 Sven Mason <http: //izara.io> This program is free
2
+ software: you can redistribute it and/or modify it under the terms of the GNU
3
+ Affero General Public License as published by the Free Software Foundation,
4
+ either version 3 of the License, or (at your option) any later version. This
5
+ program is distributed in the hope that it will be useful, but WITHOUT ANY
6
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
7
+ PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
8
+ You should have received a copy of the GNU Affero General Public License along
9
+ with this program. If not, see <http: //www.gnu.org/licenses />. */ 'use
10
+ strict'; const hash = require("object-hash"); const getObjectSchema =
11
+ require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
24
12
  const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
25
- const snsSharedLib = require('@izara_project/izara-core-library-sns');
26
- const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
27
- const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
28
- const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
29
-
30
- const externalRequest = require('@izara_project/izara-core-library-external-request');
31
- const sns = externalRequest.sns
32
- const { postToConnection } = require("../../../../libs/source/GenerateCodeLibs");
33
- const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
34
- const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
35
- const { v4: uuidv4 } = require('uuid')
36
- const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
37
- const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
38
- /**
39
- *
40
- *
41
- * description of function.
42
- * @param {Object} _izContext
43
- * @param {CorrelationIds} _izContext.correlationIds - property of _izContext
44
- * @param {Logger} _izContext.logger - property of _izContext
45
- * @param {Object} requestParams - request params
46
- * @param {Object} requestParams.identifiers - identifiers for get data
47
- * @param {Object} requestParams.additionalRequest - additionalRequest
48
- *
49
- *
50
- * @returns {object} description of return value
51
- */
52
-
53
- module.exports.FlowSchemaOwnTopicEndpointComplete = async (
54
- _izContext,
55
- requestParams,
56
- callingFlowConfig = {},
57
- //(<additionalParams>)
58
- //(</additionalParams>)
59
- ) => {
60
-
61
- try {
62
- _izContext.logger.debug("FlowSchemaOwnTopicEndpointComplete _izContext", _izContext)
63
- _izContext.logger.debug("FlowSchemaOwnTopicEndpointComplete requestParams", requestParams)
64
- _izContext.logger.debug("FlowSchemaOwnTopicEndpointComplete callingFlowConfig", callingFlowConfig)
65
-
66
- //(<endpointCompleteHookMainFunction>)
67
- //(</endpointCompleteHookMainFunction>)
68
-
69
- let messageObject = {
70
- //(<messageObjectHook>)
71
- //(</messageObjectHook>)
72
- }
73
-
74
- let sendMessageToOutFlowSchema = {
75
- Message: JSON.stringify(messageObject),
76
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, "<%- topicArn %>")
77
- };
78
- _izContext.logger.debug("before sendMessageToOutFlowSchema::", sendMessageToOutFlowSchema);
79
- await sns.publishAsync(_izContext, sendMessageToOutFlowSchema)
80
-
81
- } catch (err) {
82
- _izContext.logger.error('error FlowSchemaOwnTopicEndpointComplete: ', err)
83
- throw (err)
84
- }
85
- }
13
+ const snsSharedLib = require('@izara_project/izara-core-library-sns'); const
14
+ asyncFlowSharedLib =
15
+ require('@izara_project/izara-core-library-asynchronous-flow'); const
16
+ callingFlowSharedLib =
17
+ require('@izara_project/izara-core-library-calling-flow'); const lambdaSharedLib
18
+ = require('@izara_project/izara-core-library-lambda'); const externalRequest =
19
+ require('@izara_project/izara-core-library-external-request'); const sns =
20
+ externalRequest.sns const { postToConnection } =
21
+ require("../../../libs/source/GenerateCodeLibs"); const utils =
22
+ require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
23
+ const NoRetryError =
24
+ require('@izara_project/izara-core-library-core').NoRetryError const { v4:
25
+ uuidv4 } = require('uuid') const coreConsts =
26
+ require("@izara_project/izara-core-library-core/src/Consts"); const {
27
+ TOPIC_NAME_GENERATE_CODE } =
28
+ require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
29
+ /** * * * description of function. * @param {Object} _izContext * @param
30
+ {CorrelationIds} _izContext.correlationIds - property of _izContext * @param
31
+ {Logger} _izContext.logger - property of _izContext * @param {Object}
32
+ requestParams - request params * @param {Object} requestParams.identifiers -
33
+ identifiers for get data * @param {Object} requestParams.additionalRequest -
34
+ additionalRequest * * * @returns {object} description of return value */
35
+ module.exports.FlowSchemaOwnTopicEndpointComplete = async ( _izContext,
36
+ requestParams, callingFlowConfig = {}, //(<additionalParams
37
+ >) //(</additionalParams
38
+ >) ) => { try { _izContext.logger.debug("FlowSchemaOwnTopicEndpointComplete
39
+ _izContext", _izContext)
40
+ _izContext.logger.debug("FlowSchemaOwnTopicEndpointComplete requestParams",
41
+ requestParams) _izContext.logger.debug("FlowSchemaOwnTopicEndpointComplete
42
+ callingFlowConfig", callingFlowConfig) //(<endpointCompleteHookMainFunction
43
+ >) //(</endpointCompleteHookMainFunction
44
+ >) let messageObject = { //(<messageObjectHook>) //(</messageObjectHook>) } let
45
+ sendMessageToOutFlowSchema = { Message: JSON.stringify(messageObject), TopicArn:
46
+ await snsSharedLib.snsTopicArnByFlowSchema(_izContext, "<%- topicOut %>") };
47
+ _izContext.logger.debug("before sendMessageToOutFlowSchema::",
48
+ sendMessageToOutFlowSchema); await sns.publishAsync(_izContext,
49
+ sendMessageToOutFlowSchema) } catch (err) { _izContext.logger.error('error
50
+ FlowSchemaOwnTopicEndpointComplete: ', err) throw (err) } }
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
  'use strict';
19
19
  const path = require('path');
20
20
 
21
- const { FLOW_SCHEMA_HOOK_STATE, ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
21
+ const { FLOW_SCHEMA_HOOK_STATE, ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
22
22
  const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
23
23
  const {
24
24
  SOURCE_PATH,
@@ -32,12 +32,14 @@ const {
32
32
  FUNCTION_NAME,
33
33
  shortNameHandler,
34
34
  externalResourceYaml,
35
- SOURCE_GENERATE_IAM_ROLE
35
+ SOURCE_GENERATE_IAM_ROLE,
36
+ SQS_RESOURCE,
37
+ LAMBDA_RESOURCE
36
38
  } = require('../../../../../../MainLibs/src/Consts');
37
39
  const { TOPIC_NAME_GENERATE_CODE } = require('../../../../../../GenerateCodeLibs/src/Consts');
40
+ const getObjectSchema = require('@izara_project/izara-core-library-service-schemas').getObjectSchema;
38
41
 
39
42
  const templatePath = path.join(__dirname, "template.ejs");
40
- const hookTemplate = path.join(__dirname, "./hookTemplate.ejs");
41
43
  /**
42
44
  * receive objectSchema
43
45
  * create data for WebScoket handler template
@@ -46,29 +48,72 @@ const hookTemplate = path.join(__dirname, "./hookTemplate.ejs");
46
48
  * @return {{templatePath, templateData,setting}}
47
49
  */
48
50
 
49
- function data(_izContext, flowSchema, srcPath) {
50
- return [createSourceParams(_izContext, flowSchema, srcPath)]
51
+ async function data(_izContext, flowSchema, srcPath) {
52
+ return [await createSourceParams(_izContext, flowSchema, srcPath)]
51
53
  }
52
54
 
53
- function createSourceParams(_izContext, flowSchema, srcPath) {
54
- let functionName = upperCase(FUNCTION_NAME.flowSchemaOwnTopicEndpoint)
55
+ async function createSourceParams(_izContext, flowSchema, srcPath) {
56
+ let functionName = "Process" + upperCase(flowSchema.flowTag)
55
57
  let handlerType = upperCase(HANDLER.hdrSqs)
56
58
  let additionalResourcePermission = defaultIamRolePerAction();
57
59
  let route = flowSchema.flowTag;
60
+ let flowSteps = Object.keys(flowSchema.flowSteps)
61
+ let flowStepsIn = flowSteps[0];
62
+ let splitFlowStepsOut = flowStepsIn.split("_");
63
+ let queueName = splitFlowStepsOut[3] + handlerType
64
+ additionalResourcePermission.push(
65
+ createIamRole(
66
+ {
67
+ [RESOURCE_CLASSES.sqs]: Object.values(SQS_RESOURCE)
68
+ },
69
+ [
70
+ resourceNames(RESOURCE_CLASSES.sqs, queueName)
71
+ ]
72
+ ),
73
+ createIamRole(
74
+ {
75
+ [RESOURCE_CLASSES.lambda]: Object.values(LAMBDA_RESOURCE)
76
+ },
77
+ [
78
+ resourceNames(RESOURCE_CLASSES.lambda, 'CreateHdrInv')
79
+ ]
80
+ ),
81
+ )
58
82
 
59
- additionalResourcePermission.push()
83
+ if (flowSchema.statusType === "storedCache") {
84
+ let tableStroedCaches = [];
85
+ const objectSchemaPath = path.join(srcPath, "./schemas")
86
+ let objectSchema = await getObjectSchema.getLocalObjectSchemas(_izContext, [flowSchema.objType.objectType], objectSchemaPath).then(res => res.records[0])
87
+ for (const storageResource of Object.values(objectSchema.storageResources)) {
88
+ if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
89
+ if (!tableStroedCaches.includes(storageResource.tableName)) {
90
+ tableStroedCaches.push(storageResource.tableName)
91
+ }
92
+ }
93
+ }
60
94
 
95
+ additionalResourcePermission.push(
96
+ createIamRole(
97
+ {
98
+ [RESOURCE_CLASSES.dynamoDbTable]: Object.values(DYNAMO_RESOURCE)
99
+ },
100
+ tableStroedCaches.map(
101
+ tableName => resourceNames(RESOURCE_CLASSES.dynamoDbTable, tableName))
102
+ )
103
+ )
104
+ }
61
105
 
62
106
  return {
63
107
  templatePath: templatePath,
64
108
  templateData: {
65
- resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchemaOwnTopic, flowSchema.flowTag, "source/"),
109
+ resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, flowSchema.flowTag, "source/"),
66
110
  functionName,
67
111
  handlerType,
68
112
  additionalResourcePermission,
69
113
  route,
70
114
  functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
71
- roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic
115
+ roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic,
116
+ queueName
72
117
  },
73
118
  setting: {
74
119
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
@@ -4,7 +4,7 @@
4
4
  name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
5
5
  events:
6
6
  - sqs:
7
- arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- functionName %>
7
+ arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>
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
@@ -36,7 +36,7 @@ function data(_izContext, flowSchema, srcPath) {
36
36
  }
37
37
 
38
38
  function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
39
- let functionName = upperCase(FUNCTION_NAME.flowSchemaOwnTopicEndpoint)
39
+ let functionName = "Process" + upperCase(flowSchema.flowTag)
40
40
  let handlerType = upperCase(HANDLER.hdrSqs)
41
41
  let route = flowSchema.flowTag;
42
42
  let queueName = functionName
@@ -49,7 +49,7 @@ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
49
49
  queueName
50
50
  },
51
51
  setting: {
52
- savePath: path.join(srcPath, SOURCE_PATH.flowSchemaOwnTopic, flowSchema.flowTag, "source/"),
52
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, "source/"),
53
53
  saveFileName: `${functionName}_${handlerType}`,
54
54
  fileExtension: ".js",
55
55
  isAppend: false
@@ -25,7 +25,7 @@ const middleware = izara.middlewareHandler;
25
25
  const recordHandlerSharedLib = require("@izara_project/izara-core-library-record-handler")
26
26
  const Logger = require('@izara_project/izara-core-library-logger');
27
27
 
28
- const FlowSchemaOwnTopicEndpoint = require('./FlowSchemaOwnTopicEndpoint_Main')
28
+ const <%- functionName %> = require('./<%- functionName %>_Main')
29
29
 
30
30
  // validate event properties in body.Message of sqs event
31
31
  let perRecordsValidatorSchema = {}
@@ -18,10 +18,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
  'use strict';
19
19
  const path = require('path');
20
20
 
21
- const { SOURCE_PATH, FUNCTION_NAME } = require('../../../../../../MainLibs/src/Consts');
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");
24
- const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
24
+ const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
25
+ const { STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
26
+ const statusFieldTemplate = path.join(__dirname, "../../../createRecordByStatusType/statusFieldTemplate.ejs")
27
+ const storedCacheTemplate = path.join(__dirname, "../../../createRecordByStatusType/storedCacheTemplate.ejs")
25
28
 
26
29
  /**
27
30
  * receive objectSchema
@@ -32,17 +35,33 @@ const getObjectSchema = require('@izara_project/izara-core-library-service-schem
32
35
  */
33
36
 
34
37
 
35
- function data(_izContext, flowSchema, srcPath) {
36
- return [createParamsForCreateSource(_izContext, flowSchema, srcPath)]
38
+ async function data(_izContext, flowSchema, srcPath) {
39
+ return [await createParamsForCreateSource(_izContext, flowSchema, srcPath)]
37
40
  }
38
41
 
39
- function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
40
- let functionName = upperCase(FUNCTION_NAME.flowSchemaOwnTopicEndpoint)
42
+ async function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
43
+ let functionName = "Process" + upperCase(flowSchema.flowTag);
44
+ let tableName;
45
+ let objectSchema = await getObjectSchema.getLocalObjectSchemas(_izContext, [flowSchema.objType.objectType], path.join(srcPath, "./schemas")).then(res => res.records[0]);
46
+ for (const storageResource of Object.values(objectSchema.storageResources)) {
47
+ if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
48
+ tableName = storageResource.tableName
49
+ }
50
+ }
51
+ let flowSchemaComplete = upperCase(flowSchema.flowTag) + "Complete"
41
52
  return {
42
53
  templatePath: templatePath,
43
- templateData: {},
54
+ templateData: {
55
+ statusType: flowSchema.statusType,
56
+ statusFieldTemplate,
57
+ storedCacheTemplate,
58
+ flowTag: flowSchema.flowTag,
59
+ functionName,
60
+ tableName,
61
+ flowSchemaComplete
62
+ },
44
63
  setting: {
45
- savePath: path.join(srcPath, SOURCE_PATH.flowSchemaOwnTopic, flowSchema.flowTag, "source/"),
64
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, "source/"),
46
65
  saveFileName: `${functionName}_Main`,
47
66
  fileExtension: ".js",
48
67
  isAppend: false
@@ -23,18 +23,24 @@ const getObjectSchema = require('@izara_project/izara-core-library-service-schem
23
23
 
24
24
  const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
25
25
  const snsSharedLib = require('@izara_project/izara-core-library-sns');
26
+ const sqsSharedLib = require('@izara_project/izara-core-library-sqs');
26
27
  const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
27
28
  const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
28
29
  const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
29
30
 
30
31
  const externalRequest = require('@izara_project/izara-core-library-external-request');
31
32
  const sns = externalRequest.sns
33
+ const sqs = externalRequest.sqs
34
+ const lambda = externalRequest.lambda
32
35
  const { postToConnection } = require("../../../../libs/source/GenerateCodeLibs");
33
36
  const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
34
37
  const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
35
38
  const { v4: uuidv4 } = require('uuid')
36
39
  const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
37
40
  const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
41
+ const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
42
+ const { createFieldNamesFromRequestParamsByObjectSchema } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs.js')
43
+
38
44
  /**
39
45
  *
40
46
  *
@@ -50,7 +56,7 @@ const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-librar
50
56
  * @returns {object} description of return value
51
57
  */
52
58
 
53
- module.exports.FlowSchemaOwnTopicEndpoint = async (
59
+ module.exports.<%- functionName %> = async (
54
60
  _izContext,
55
61
  requestParams,
56
62
  callingFlowConfig = {},
@@ -59,38 +65,62 @@ module.exports.FlowSchemaOwnTopicEndpoint = async (
59
65
  ) => {
60
66
 
61
67
  try {
62
- _izContext.logger.debug("flowSchemaOwnTopicEndpoint _izContext", _izContext)
63
- _izContext.logger.debug("flowSchemaOwnTopicEndpoint requestParams", requestParams)
64
- _izContext.logger.debug("flowSchemaOwnTopicEndpoint callingFlowConfig", callingFlowConfig)
68
+ _izContext.logger.debug("<%- functionName %> _izContext", _izContext)
69
+ _izContext.logger.debug("<%- functionName %> requestParams", requestParams)
70
+ _izContext.logger.debug("<%- functionName %> callingFlowConfig", callingFlowConfig)
71
+
72
+ let correlationId = _izContext.correlationIds.get(consts.X_CORRELATION_ID)
73
+ let connectionId = _izContext.correlationIds.get(consts.CONNECTION_ID);
65
74
 
66
75
  //(<endpointHookMainFunction>)
67
76
  //(</endpointHookMainFunction>)
68
77
 
69
- let messageObject = {
70
- //(<messageObject>)
71
- //(</messageObject>)
72
- };
78
+ const flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
79
+ flowTag: requestParams.action,
80
+ serviceTag: process.env.iz_serviceTag
81
+ })
82
+
83
+ <% if (statusType === "statusField") { %>
84
+ <%- include(statusFieldTemplate) %>
85
+ <% } else if (statusType === "storedCache") { %>
86
+ <%- include(storedCacheTemplate, {tableName:tableName}) %>
87
+ let messageObject = requestParams
73
88
 
74
- messageObject = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
75
- sendMessageToTranslateIdIterFromAHdrDsq,
89
+ //(<beforeSendMessage>)
90
+ //(</beforeSendMessage>)
91
+ // create callingFlow
92
+ messageObject = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
93
+ messageObject,
76
94
  callingFlowSharedLib.addParentCallingFlowConfig(
77
- callingFlow,
95
+ callingFlowConfig,
78
96
  callingFlowSharedLib.createCallingFlowConfig(
79
- await lambdaSharedLib.lambdaFunctionName(_izContext, TOPIC_NAME_GENERATE_CODE.flowSchemaOwnTopicComplete), {}
97
+ await lambdaSharedLib.lambdaFunctionName(_izContext, "<%- flowSchemaComplete %>"), {}
80
98
  )
81
99
  )
82
100
  )
83
101
 
84
- let sendMessageToFlowSchemaOutEndpointComplete = {
85
- MessageBody: JSON.stringify(messageObject),
86
- QueueUrl: await sqsSharedLib.sqsQueueUrl(_izContext, "FlowSchemaOwnTopicEndpointHdrSqs")
87
- }
88
- _izContext.logger.debug("before sendMessageToFlowSchemaOutEndpointComplete::",sendMessageToFlowSchemaOutEndpointComplete),
89
- await sqs.sendMessage(_izContext, sendMessageToFlowSchemaOutEndpointComplete);
102
+ <% } else if (statusType === "none") { %>
103
+
104
+ let messageObject = requestParams
105
+
106
+ // create callingFlow
107
+ messageObject = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
108
+ messageObject,
109
+ callingFlowSharedLib.addParentCallingFlowConfig(
110
+ callingFlowConfig,
111
+ callingFlowSharedLib.createCallingFlowConfig(
112
+ await lambdaSharedLib.lambdaFunctionName(_izContext, TOPIC_NAME_GENERATE_CODE.flowSchemaOwnTopicComplete), {}
113
+ )
114
+ )
115
+ )
116
+ <% } %>
117
+
118
+ //(<endpointHook>)
119
+ //(</endpointHook>)
90
120
 
91
121
  return {
92
- //(<returnParams>)
93
- //(</returnParams>)
122
+ //(<endpointReturn>)
123
+ //(</endpointReturn>)
94
124
  }
95
125
  } catch (err) {
96
126
  _izContext.logger.error('error WebSocketInvoke: ', err)
@@ -32,7 +32,8 @@ const {
32
32
  FUNCTION_NAME,
33
33
  shortNameHandler,
34
34
  externalResourceYaml,
35
- SOURCE_GENERATE_IAM_ROLE
35
+ SOURCE_GENERATE_IAM_ROLE,
36
+ SQS_RESOURCE
36
37
  } = require('../../../../../../MainLibs/src/Consts');
37
38
  const { TOPIC_NAME_GENERATE_CODE } = require('../../../../../../GenerateCodeLibs/src/Consts');
38
39
 
@@ -51,11 +52,16 @@ function data(_izContext, flowSchema, srcPath) {
51
52
  }
52
53
 
53
54
  function createSourceParams(_izContext, flowSchema, srcPath) {
54
- let functionName = upperCase(FUNCTION_NAME.flowSchemaOwnTopicComplete)
55
+ let functionName = upperCase(flowSchema.flowTag) + "Complete"
55
56
  let handlerType = upperCase(HANDLER.hdrSqs)
56
57
  let additionalResourcePermission = defaultIamRolePerAction();
57
58
  let route = flowSchema.flowTag;
58
59
  let flowStep = Object.keys(flowSchema.flowSteps)
60
+ let flowStepsIn = flowStep[0];
61
+ let splitFlowStepsIn = flowStepsIn.split("_");
62
+ let topicIn = `${splitFlowStepsIn[3]}_${splitFlowStepsIn[4]}`
63
+ let queueName = functionName + handlerType
64
+
59
65
  additionalResourcePermission.push(
60
66
  createIamRole(
61
67
  {
@@ -64,7 +70,7 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
64
70
  ]
65
71
  },
66
72
  [
67
- resourceNames(RESOURCE_CLASSES.sns, flowStep[0])
73
+ resourceNames(RESOURCE_CLASSES.sns, topicIn)
68
74
  ]
69
75
  ),
70
76
  createIamRole(
@@ -90,6 +96,14 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
90
96
  [
91
97
  resourceNames(RESOURCE_CLASSES.webSocket)
92
98
  ]
99
+ ),
100
+ createIamRole(
101
+ {
102
+ [RESOURCE_CLASSES.sqs]: [SQS_RESOURCE.sendMessage, SQS_RESOURCE.receiveMessage, SQS_RESOURCE.deleteMessage, SQS_RESOURCE.getQueueAttributes]
103
+ },
104
+ [
105
+ resourceNames(RESOURCE_CLASSES.sqs, queueName)
106
+ ]
93
107
  )
94
108
  )
95
109
 
@@ -97,13 +111,14 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
97
111
  return {
98
112
  templatePath: templatePath,
99
113
  templateData: {
100
- resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchemaOwnTopic, flowSchema.flowTag, "source/"),
114
+ resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, flowSchema.flowTag, "source/"),
101
115
  functionName,
102
116
  handlerType,
103
117
  additionalResourcePermission,
104
118
  route,
105
119
  functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
106
- roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic
120
+ roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic,
121
+ queueName: queueName
107
122
  },
108
123
  setting: {
109
124
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),