@izara_project/izara-market-library-service-schemas 1.0.65 → 1.0.67

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 (146) hide show
  1. package/package.json +3 -3
  2. package/src/GenerateCodeLibs/src/Consts.js +7 -2
  3. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +11 -1
  4. package/src/MainLibs/src/Consts.js +64 -25
  5. package/src/MainLibs/src/GenerateCodeUtils.js +6 -6
  6. package/src/reStructure/GenerateCode.js +2 -1
  7. package/src/reStructure/TemplateData/EndpointPerService/generateTemplateData.js +1 -1
  8. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +20 -4
  9. package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +49 -5
  10. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +3 -0
  11. package/src/reStructure/TemplateData/findData/findDataYaml/data.js +2 -2
  12. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/functionYaml/data.js +1 -1
  13. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/data.js +3 -1
  14. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +14 -0
  15. package/src/reStructure/TemplateData/flowSchema/dynamoDb/data.js +2 -2
  16. package/src/reStructure/TemplateData/flowSchema/flowStep/functionYaml/data.js +3 -3
  17. package/src/reStructure/TemplateData/flowSchema/flowStep/handler/data.js +1 -1
  18. package/src/reStructure/TemplateData/flowSchema/flowStep/sns-in/data.js +4 -2
  19. package/src/reStructure/TemplateData/flowSchema/flowStep/sns-in/template.ejs +9 -9
  20. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +24 -24
  21. package/src/reStructure/TemplateData/generateRole/data.js +38 -24
  22. package/src/reStructure/TemplateData/generateRole/template.ejs +5 -7
  23. package/src/reStructure/TemplateData/perActionComplete/create/yaml/data.js +1 -1
  24. package/src/reStructure/TemplateData/perActionComplete/delete/yaml/data.js +1 -1
  25. package/src/reStructure/TemplateData/perActionComplete/get/yaml/data.js +1 -1
  26. package/src/reStructure/TemplateData/perActionComplete/update/yaml/data.js +1 -1
  27. package/src/reStructure/TemplateData/processLogical/yaml/data.js +4 -4
  28. package/src/reStructure/TemplateData/processLogicalPagination/yaml/dsq/data.js +2 -2
  29. package/src/reStructure/TemplateData/processLogicalPagination/yaml/sqs/data.js +2 -2
  30. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/api/data.js +1 -1
  31. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/data.js +136 -0
  32. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/dsq/data.js +1 -1
  33. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/inv/data.js +1 -1
  34. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/sqs/data.js +1 -1
  35. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/template.ejs +9 -0
  36. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
  37. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
  38. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
  39. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
  40. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/data.js +73 -0
  41. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/template.ejs +9 -0
  42. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/templateByHandler/apiTemplate.ejs +155 -0
  43. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/templateByHandler/dsqTemplate.ejs +202 -0
  44. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/templateByHandler/invTemplate.ejs +144 -0
  45. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/templateByHandler/sqsTemplate.ejs +181 -0
  46. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/mainFunction/template.ejs +11 -11
  47. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/functionYaml/data.js +1 -1
  48. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/api/data.js +1 -1
  49. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/data.js +159 -0
  50. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/dsq/data.js +2 -2
  51. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/inv/data.js +2 -2
  52. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/sqs/data.js +2 -2
  53. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/template.ejs +9 -0
  54. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
  55. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
  56. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
  57. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
  58. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/data.js +73 -0
  59. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/template.ejs +9 -0
  60. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/templateByHandler/apiTemplate.ejs +155 -0
  61. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/templateByHandler/dsqTemplate.ejs +202 -0
  62. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/templateByHandler/invTemplate.ejs +144 -0
  63. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/templateByHandler/sqsTemplate.ejs +181 -0
  64. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/functionYaml/data.js +1 -1
  65. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/api/data.js +1 -1
  66. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/data.js +158 -0
  67. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/dsq/data.js +2 -2
  68. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/inv/data.js +2 -2
  69. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/sqs/data.js +1 -1
  70. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/template.ejs +9 -0
  71. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
  72. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
  73. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
  74. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
  75. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/data.js +73 -0
  76. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/template.ejs +9 -0
  77. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/templateByHandler/apiTemplate.ejs +155 -0
  78. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/templateByHandler/dsqTemplate.ejs +202 -0
  79. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/templateByHandler/invTemplate.ejs +144 -0
  80. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/templateByHandler/sqsTemplate.ejs +181 -0
  81. package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/functionYaml/data.js +1 -1
  82. package/src/reStructure/TemplateData/relationshipPerAction/generateTemplateData.js +131 -88
  83. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/api/data.js +2 -2
  84. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/data.js +158 -0
  85. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/data.js +2 -2
  86. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/inv/data.js +2 -2
  87. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/sqs/data.js +1 -1
  88. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/template.ejs +9 -0
  89. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
  90. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
  91. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
  92. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
  93. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/data.js +73 -0
  94. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/template.ejs +9 -0
  95. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/templateByHandler/apiTemplate.ejs +155 -0
  96. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/templateByHandler/dsqTemplate.ejs +202 -0
  97. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/templateByHandler/invTemplate.ejs +144 -0
  98. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/templateByHandler/sqsTemplate.ejs +181 -0
  99. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/data.js +1 -1
  100. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/data.js +160 -0
  101. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/template.ejs +9 -0
  102. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
  103. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
  104. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
  105. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
  106. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/data.js +73 -0
  107. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/template.ejs +9 -0
  108. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/templateByHandler/apiTemplate.ejs +172 -0
  109. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/templateByHandler/dsqTemplate.ejs +218 -0
  110. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/templateByHandler/invTemplate.ejs +161 -0
  111. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/templateByHandler/sqsTemplate.ejs +197 -0
  112. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/mainFunction/data.js +59 -0
  113. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/mainFunction/template.ejs +386 -0
  114. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/sns-in-sqs/data.js +77 -0
  115. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/sns-in-sqs/snsTemplate.ejs +59 -0
  116. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/sns-in-sqs/sqsTemplate.ejs +43 -0
  117. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/functionYaml/data.js +121 -0
  118. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/functionYaml/template.ejs +20 -0
  119. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/handler/sqs/data.js +60 -0
  120. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/handler/sqs/template.ejs +129 -0
  121. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/mainFunction/data.js +56 -0
  122. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/mainFunction/template.ejs +159 -0
  123. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/sns-in-sqs/data.js +71 -0
  124. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/sns-in-sqs/template.ejs +46 -0
  125. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/sns-out/data.js +71 -0
  126. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/sns-out/template.ejs +10 -0
  127. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/api/data.js +2 -2
  128. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/data.js +164 -0
  129. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/dsq/data.js +2 -2
  130. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/inv/data.js +2 -2
  131. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/sqs/data.js +1 -1
  132. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/template.ejs +9 -0
  133. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
  134. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
  135. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
  136. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
  137. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/data.js +73 -0
  138. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/template.ejs +9 -0
  139. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/templateByHandler/apiTemplate.ejs +155 -0
  140. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/templateByHandler/dsqTemplate.ejs +202 -0
  141. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/templateByHandler/invTemplate.ejs +144 -0
  142. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/templateByHandler/sqsTemplate.ejs +181 -0
  143. package/src/reStructure/TemplateData/relationshipPerAction/update/complete/functionYaml/data.js +1 -1
  144. package/src/reStructure/TemplateData/resourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +8 -7
  145. package/src/reStructure/TemplateData/resourceYaml/filterGenerateResource/data.js +36 -30
  146. package/src/reStructure/TemplateData/resourceYaml/generateTemplateData.js +3 -3
@@ -0,0 +1,77 @@
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
+
22
+ const {
23
+ HANDLER,
24
+ } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
25
+
26
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils.js");
27
+ const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME } = require("../../../../../../MainLibs/src/Consts.js");
28
+ const snsTemplatePath = path.join(__dirname, "./snsTemplate.ejs")
29
+ const sqsTemplatePath = path.join(__dirname, "./sqsTemplate.ejs")
30
+
31
+ /**
32
+ * create data for dynamoDbYaml tempalte from objectSchema
33
+ *
34
+ * @param {Object} _izContext
35
+ * @param {String} saveFilePath
36
+ * @returns {Object[]} - data of multiple dynamoDb template
37
+ */
38
+
39
+ function createRelationshipSnsInSqs(_izContext, srcPath) {
40
+ let resultForCreateRelationshipSnsAndSqs = [];
41
+ const setting = {
42
+ initialData: "Resources:\n",
43
+ savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
44
+ saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
45
+ fileExtension: ".yml",
46
+ isAppend: true
47
+ }
48
+ const createRelationshipQueueNames = [
49
+ {
50
+ queueName: upperCase(FUNCTION_NAME.moveRel)
51
+ },
52
+ {
53
+ queueName: upperCase(FUNCTION_NAME.moveRel) + upperCase(HANDLER.hdrDsq)
54
+ }
55
+ ]
56
+ for (let createRelationshipQueueName of createRelationshipQueueNames) {
57
+ if (createRelationshipQueueName.queueName.includes("HdrDsq")) {
58
+ resultForCreateRelationshipSnsAndSqs.push({
59
+ templatePath: sqsTemplatePath,
60
+ templateData: createRelationshipQueueName,
61
+ setting: setting
62
+ }
63
+ )
64
+ } else {
65
+ resultForCreateRelationshipSnsAndSqs.push(
66
+ {
67
+ templatePath: snsTemplatePath,
68
+ templateData: createRelationshipQueueName,
69
+ setting: setting
70
+ }
71
+ )
72
+ }
73
+ }
74
+ return resultForCreateRelationshipSnsAndSqs
75
+ }
76
+
77
+ module.exports = createRelationshipSnsInSqs
@@ -0,0 +1,59 @@
1
+ ##===== [Create topic in]
2
+ In<%- queueName %>:
3
+ Type: AWS::SNS::Topic
4
+ Properties:
5
+ DisplayName: "SNS Message in"
6
+ TopicName: ${self:custom.iz_serviceTag}_${self:custom.iz_stage}_<%- queueName %>_In
7
+ ##===== SNS Subscription
8
+ ##===== [Topic In]
9
+ SubscriptionIn<%- queueName %>:
10
+ Type: AWS::SNS::Subscription
11
+ Properties:
12
+ TopicArn: !Ref In<%- queueName %>
13
+ Endpoint: "arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqs"
14
+ Protocol: "sqs"
15
+ ##===== [Queue]
16
+ <%- queueName %>HdrSqs:
17
+ Type: "AWS::SQS::Queue"
18
+ Properties:
19
+ QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqs
20
+ RedrivePolicy:
21
+ deadLetterTargetArn:
22
+ # !GetAtt
23
+ Fn::GetAtt:
24
+ - <%- queueName %>HdrSqsDLQ
25
+ - Arn
26
+ maxReceiveCount: 3
27
+ VisibilityTimeout: 120
28
+ ##==== [QueueDLQ]
29
+ <%- queueName %>HdrSqsDLQ:
30
+ Type: AWS::SQS::Queue
31
+ Properties:
32
+ QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqsDLQ
33
+ ##==== [QueuePolicy]
34
+ <%- queueName %>HdrSqsPolicy:
35
+ Type: AWS::SQS::QueuePolicy
36
+ Properties:
37
+ PolicyDocument:
38
+ Version: "2012-10-17"
39
+ Statement:
40
+ - Sid: "allow-sns-messages"
41
+ Effect: Allow
42
+ Principal: "*"
43
+ Resource:
44
+ # !GetAtt
45
+ Fn::GetAtt:
46
+ - <%- queueName %>HdrSqs
47
+ - Arn
48
+ Action: "SQS:SendMessage"
49
+ Queues:
50
+ - Ref: <%- queueName %>HdrSqs
51
+ #<#<%- firstLetterUpperCase(queueName) %>QueueSetting#>
52
+ #<#/<%- firstLetterUpperCase(queueName) %>QueueSetting#>
53
+
54
+ <%_ function firstLetterUpperCase(text){
55
+ return text.charAt(0).toUpperCase() + text.slice(1)
56
+ } _%>
57
+ <%_ function firstLetterLowerCase(str) {
58
+ return str.charAt(0).toLowerCase() + str.slice(1)
59
+ } _%>
@@ -0,0 +1,43 @@
1
+ #------- queue ---------
2
+ <%- queueName %>:
3
+ Type: "AWS::SQS::Queue"
4
+ Properties:
5
+ QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>
6
+ RedrivePolicy:
7
+ deadLetterTargetArn: #!GetAtt
8
+ Fn::GetAtt:
9
+ - <%- queueName %>DLQ
10
+ - Arn
11
+ maxReceiveCount: 3
12
+ VisibilityTimeout: 120
13
+
14
+ <%- queueName %>DLQ:
15
+ Type: AWS::SQS::Queue
16
+ Properties:
17
+ QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>DLQ
18
+
19
+ <%- queueName %>Policy:
20
+ Type: AWS::SQS::QueuePolicy
21
+ Properties:
22
+ PolicyDocument:
23
+ Version: "2012-10-17"
24
+ Statement:
25
+ - Sid: "allow-sns-messages"
26
+ Effect: Allow
27
+ Principal: "*"
28
+ Resource: #!GetAtt
29
+ Fn::GetAtt:
30
+ - <%- queueName %>
31
+ - Arn
32
+ Action: "SQS:SendMessage"
33
+ Queues:
34
+ - Ref: <%- queueName %>
35
+ #<#<%- firstLetterUpperCase(queueName) %>QueueSetting#>
36
+ #<#/<%- firstLetterUpperCase(queueName) %>QueueSetting#>
37
+
38
+ <%_ function firstLetterUpperCase(text){
39
+ return text.charAt(0).toUpperCase() + text.slice(1)
40
+ } _%>
41
+ <%_ function firstLetterLowerCase(str) {
42
+ return str.charAt(0).toLowerCase() + str.slice(1)
43
+ } _%>
@@ -0,0 +1,121 @@
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
+
21
+ const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
22
+
23
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/index.js").utils;
24
+ const {
25
+ createIamRole,
26
+ resourceNames,
27
+ RESOURCE_CLASSES,
28
+ SQS_RESOURCE,
29
+ SOURCE_PATH,
30
+ SAVE_FILE_NAME,
31
+ FUNCTION_NAME,
32
+ defaultIamRolePerAction,
33
+ awaitingMultipleStepsRole,
34
+ SNS_RESOURCE,
35
+ shortNameHandler,
36
+ SHORT_FUNCTION_NAME,
37
+ SOURCE_GENERATE_IAM_ROLE
38
+ } = require("../../../../../../MainLibs/src/Consts.js");
39
+
40
+ const templatePath = path.join(__dirname, "./template.ejs")
41
+
42
+ /**
43
+ * receive objectSchema
44
+ * create data for updateRelationshipSchema
45
+ *
46
+ * @param {Object} objectSchema
47
+ * @return {{ templatePath, templateData, setting } }
48
+ */
49
+
50
+ function data(_izContext, srcPath) {
51
+ let createSourceArray = [];
52
+ const createSourceParam = createParamForCreateSource(srcPath);
53
+ createSourceArray.push(createSourceParam);
54
+ return createSourceArray
55
+ }
56
+
57
+
58
+ function createParamForCreateSource(srcPath) {
59
+ let handlerType = upperCase(HANDLER.hdrSqs);
60
+ let functionName = FUNCTION_NAME.moveRelComplete
61
+ let additionalResourcePermission = defaultIamRolePerAction();
62
+
63
+ additionalResourcePermission.push(
64
+ createIamRole(
65
+ {
66
+ [RESOURCE_CLASSES.sqs]: [
67
+ SQS_RESOURCE.deleteMessage,
68
+ SQS_RESOURCE.getQueueAttributes,
69
+ SQS_RESOURCE.receiveMessage,
70
+ SQS_RESOURCE.sendMessage,
71
+ SQS_RESOURCE.deleteMessageBatch,
72
+ SQS_RESOURCE.getQueueUrl,
73
+ ],
74
+
75
+ },
76
+ [
77
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName)),
78
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + "DLQ"),
79
+
80
+ ],
81
+ ),
82
+ createIamRole(
83
+ {
84
+ [RESOURCE_CLASSES.sns]:
85
+ [
86
+ SNS_RESOURCE.publish, SNS_RESOURCE.subscribe
87
+ ]
88
+ },
89
+ [
90
+ resourceNames(RESOURCE_CLASSES.sns, upperCase(functionName) + "_In"),
91
+ resourceNames(RESOURCE_CLASSES.sns, upperCase(functionName) + "_Out")
92
+ ]
93
+ )
94
+ )
95
+
96
+
97
+
98
+ additionalResourcePermission.push(awaitingMultipleStepsRole())
99
+
100
+ return {
101
+ templatePath: templatePath,
102
+ templateData: {
103
+ functionName,
104
+ handlerType,
105
+ additionalResourcePermission,
106
+ resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
107
+ functionNameConfig: upperCase(SHORT_FUNCTION_NAME(FUNCTION_NAME.moveRelComplete)),
108
+ roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipCompleteRole
109
+ },
110
+ setting: {
111
+ savePath: path.join(srcPath, SOURCE_PATH.appYaml),
112
+ saveFileName: SAVE_FILE_NAME.functionRelationshipYaml,
113
+ fileExtension: '.yml',
114
+ isAppend: true
115
+ }
116
+
117
+ }
118
+ }
119
+
120
+
121
+ module.exports = data;
@@ -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) %>
5
+ events:
6
+ - sqs:
7
+ arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %>
8
+ batchSize: 10
9
+ filterPatterns: #**** need to update serverless framework upper v.2.69.1
10
+ - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%-firstLetterUpperCase(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
+ } _%>
@@ -0,0 +1,60 @@
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
+
21
+ const { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
22
+
23
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../../MainLibs/src/Utils.js");
24
+ const { SOURCE_PATH, FUNCTION_NAME } = require("../../../../../../../MainLibs/src/Consts.js");
25
+
26
+ const templatePath = path.join(__dirname, "./template.ejs")
27
+
28
+ /**
29
+ * receive objectSchema
30
+ * create data for hdrInv template
31
+ *
32
+ * @return {{ templatePath, templateData, setting } }
33
+ */
34
+ function data(_izContext, srcPath) {
35
+ const createSourceParams = createParamForCreateSource(srcPath)
36
+ return [createSourceParams];
37
+ }
38
+
39
+
40
+ function createParamForCreateSource(srcPath) {
41
+ const functionName = FUNCTION_NAME.moveRelComplete;
42
+ const handler = HANDLER.hdrSqs
43
+
44
+ return {
45
+ templatePath: templatePath,
46
+ templateData: {
47
+ functionName: upperCase(functionName),
48
+ queueName: upperCase(functionName)
49
+ },
50
+ setting: {
51
+ savePath: path.join(srcPath, SOURCE_PATH.relationshipPerAction),
52
+ saveFileName: `${upperCase(functionName)}_${upperCase(handler)}`,
53
+ fileExtension: '.js',
54
+ isAppend: false
55
+ }
56
+ }
57
+ }
58
+
59
+
60
+ module.exports = data;
@@ -0,0 +1,129 @@
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 AWS = require('aws-sdk');
21
+ // const sqs = new AWS.SQS({ apiVersion: '2012-11-05' });
22
+
23
+ const izara = require("@izara_project/izara-middleware");
24
+ const middleware = izara.middlewareHandler;
25
+ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
26
+ const recordHandlerSharedLib = require('@izara_project/izara-core-library-record-handler');
27
+
28
+ const <%- functionName %> = require('./<%- functionName %>_Main');
29
+ const Logger = require('@izara_project/izara-core-library-logger');
30
+ // validate event properties in body.Message of sqs event
31
+ middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
32
+ // set schema for record.body.Message
33
+ let perRecordsValidatorSchema = {
34
+ type: "object",
35
+ required: [
36
+ 'returnValue',
37
+ 'status',
38
+ 'errorsFound',
39
+ 'graphServiceTag'
40
+ ],
41
+ properties: {
42
+ returnValue: {
43
+ type: 'object',
44
+ },
45
+ status: {
46
+ type: 'string',
47
+ },
48
+ errorsFound: {
49
+ type: 'array',
50
+ default: []
51
+ },
52
+ graphServiceTag: {
53
+ type: 'string'
54
+ }
55
+ }
56
+ };
57
+
58
+ // set schema for record.body.MessageAttributes
59
+ // const messageAttributeValidatorSchema = {
60
+ // type: "object",
61
+ // required: ['msgAtrrParam1', 'msgAtrrParam2'],
62
+ // properties: {
63
+ // msgAtrrParam1: {
64
+ // type: "string"
65
+ // },
66
+ // msgAtrrParam2: {
67
+ // type: "object"
68
+ // }
69
+ // }
70
+ // };
71
+
72
+ perRecordsValidatorSchema = callingFlowSharedLib.addOptionalPassBackPropertiesToValidatorSchema(perRecordsValidatorSchema); // is Ok passBackProperties
73
+ module.exports.main = middleware.wrap(async (event, context, callback) => {
74
+
75
+ try {
76
+
77
+ let recordPromises = [];
78
+
79
+ // loop each record and send to mainFunction
80
+ await Promise.all(event.Records.map(async record => { // promise.all for map() function
81
+
82
+ let passOnProperties = []
83
+ record._izContext.logger.debug('record ReceiveMsgOutHdrSqs', record);
84
+
85
+ //validate message (and MessageAttributes)
86
+ await recordHandlerSharedLib.validateRecord(
87
+ record, // one record will send to mainFunction
88
+ "<%- functionName %>", // queue name that need to retry or send to dlq
89
+ perRecordsValidatorSchema, // schema for record.Message
90
+ // messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
91
+ );
92
+
93
+ // add argument (to invoke lambda) to passOnProperties[]
94
+ passOnProperties.push(record.body.Message.returnValue)
95
+ passOnProperties.push(record.body.Message.status)
96
+ passOnProperties.push(record.body.Message.errorsFound)
97
+ passOnProperties.push(record.body.Message.graphServiceTag)
98
+ passOnProperties.push(callingFlowSharedLib.addPassBackPropertiesToPassOnProperties(record.body.Message)) // is Ok PassBackProperties
99
+ // passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message)) // is Ok callingFlow
100
+ record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
101
+
102
+ // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
103
+ let recordPromise = recordHandlerSharedLib.recordHandler(
104
+ record, // one record will send to mainFunction
105
+ <%- functionName %>.<%- functionName %>, // mainFunction that need to invoke.
106
+ "<%- queueName %>", // queue name that need to retry or send to dlq
107
+ passOnProperties, // all parameters that mainFunction needed.
108
+ );
109
+ record._izContext.logger.debug('after recordPromise in handler');
110
+ recordPromises.push(recordPromise); // push promise to recordPromises
111
+ }))
112
+
113
+ Logger.debug('before Promise.all(recordPromises) in handler');
114
+ try {
115
+ // --- main await all promises
116
+ await Promise.all(recordPromises); // await all promises
117
+
118
+ return event.Records // return all for local testing
119
+
120
+ } catch {
121
+ Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did no resolve)');
122
+ }
123
+ Logger.debug('after Promise.all(recordPromises) in handler');
124
+
125
+ } catch (err) {
126
+ Logger.error('Unhandled Error, CreateRelationshipCompleteHdrSqs: ', err);
127
+ throw (err);
128
+ }
129
+ });
@@ -0,0 +1,56 @@
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
+
21
+ const { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
22
+
23
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase } = require("../../../../../../MainLibs/index.js").utils;
24
+ const { SOURCE_PATH, FUNCTION_NAME } = require("../../../../../../MainLibs/src/Consts.js");
25
+
26
+ const templatePath = path.join(__dirname, "./template.ejs")
27
+
28
+ /**
29
+ * receive objectSchema
30
+ * create data for hdrInv template
31
+ *
32
+ * @return {{ templatePath, templateData, setting } }
33
+ */
34
+ function data(_izContext, srcPath) {
35
+ const createSourceParams = createParamForCreateSource(srcPath)
36
+ return [createSourceParams];
37
+ }
38
+
39
+
40
+ function createParamForCreateSource(srcPath) {
41
+ const functionName = upperCase(FUNCTION_NAME.moveRelComplete);
42
+ return {
43
+ templatePath: templatePath,
44
+ templateData: {
45
+ functionName
46
+ },
47
+ setting: {
48
+ savePath: path.join(srcPath, SOURCE_PATH.relationshipPerAction),
49
+ saveFileName: `${upperCase(functionName)}_Main`,
50
+ fileExtension: '.js',
51
+ isAppend: false
52
+ }
53
+ }
54
+ }
55
+
56
+ module.exports = data;