@izara_project/izara-market-library-service-schemas 1.0.4 → 1.0.6

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 (177) hide show
  1. package/package.json +2 -2
  2. package/src/GenerateCodeLibs/index.js +2 -1
  3. package/src/GenerateCodeLibs/src/Consts.js +20 -5
  4. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +298 -12
  5. package/src/GenerateCodeLibs/src/TranslateIdsLibs.js +89 -0
  6. package/src/MainLibs/src/Utils.js +10 -0
  7. package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrApi/data.js +119 -0
  8. package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrDsq/data.js +133 -0
  9. package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrInv/data.js +120 -0
  10. package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrSqs/data.js +133 -0
  11. package/src/TemplateManager/src/CreateRelationship/createRelationship/mainFunction/data.js +59 -0
  12. package/src/TemplateManager/src/CreateRelationship/createRelationship/mainFunction/template.ejs +340 -0
  13. package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrApi/data.js +58 -0
  14. package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrApi/request.json +0 -0
  15. package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrApi/template.ejs +120 -0
  16. package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrDsq/data.js +59 -0
  17. package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrDsq/request.json +0 -0
  18. package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrDsq/template.ejs +167 -0
  19. package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrInv/data.js +60 -0
  20. package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrInv/request.json +0 -0
  21. package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrInv/template.ejs +107 -0
  22. package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrSqs/data.js +60 -0
  23. package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrSqs/request.json +0 -0
  24. package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrSqs/template.ejs +146 -0
  25. package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/request.json +30 -0
  26. package/src/TemplateManager/src/CreateRelationship/createRelationship/sns-in-sqs/data.js +78 -0
  27. package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/functionYaml/data.js +133 -0
  28. package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/functionYaml/request.json +0 -0
  29. package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/functionYaml/template.ejs +33 -0
  30. package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/handler/HdrSqs/data.js +61 -0
  31. package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/handler/HdrSqs/request.json +0 -0
  32. package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/handler/HdrSqs/template.ejs +125 -0
  33. package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/mainFunction/data.js +56 -0
  34. package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/mainFunction/request.json +0 -0
  35. package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/mainFunction/template.ejs +137 -0
  36. package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-in-sqs/data.js +72 -0
  37. package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-in-sqs/request.json +0 -0
  38. package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-in-sqs/template.ejs +47 -0
  39. package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-out/data.js +72 -0
  40. package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-out/request.json +0 -0
  41. package/src/TemplateManager/src/FindData/FindDataYaml/data.js +188 -0
  42. package/src/TemplateManager/src/FindData/FindDataYaml/template.ejs +27 -0
  43. package/src/TemplateManager/src/FindData/GetByStorage/getByDynamo.ejs +53 -0
  44. package/src/TemplateManager/src/FindData/GetByStorage/getByGraph.ejs +99 -0
  45. package/src/TemplateManager/src/FindData/Handler/data.js +48 -0
  46. package/src/TemplateManager/src/FindData/Handler/template.ejs +140 -0
  47. package/src/TemplateManager/src/FindData/mainFunction/data.js +279 -0
  48. package/src/TemplateManager/src/FindData/mainFunction/template.ejs +155 -0
  49. package/src/TemplateManager/src/GenerateCode(Old).js +1 -1
  50. package/src/TemplateManager/src/GenerateCode.js +205 -45
  51. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/functionYaml/data.js +98 -0
  52. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/functionYaml/template.ejs +33 -0
  53. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/handler/data.js +0 -0
  54. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/handler/template.ejs +0 -0
  55. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/createObjectComplete_main.js +172 -0
  56. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/data.js +0 -0
  57. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/template.ejs +0 -0
  58. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-in-sqs/data.js +0 -0
  59. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-in-sqs/template.ejs +0 -0
  60. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-out/data.js +0 -0
  61. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-out/template.ejs +0 -0
  62. package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/functionYaml/data.js +98 -0
  63. package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/functionYaml/template.ejs +33 -0
  64. package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/handler/data.js +59 -0
  65. package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/handler/template.ejs +129 -0
  66. package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/mainFunction/data.js +53 -0
  67. package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/mainFunction/template.ejs +126 -0
  68. package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/sns-out/data.js +62 -0
  69. package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/sqs-in-sns/data.js +58 -0
  70. package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/sqs-in-sns/template.ejs +47 -0
  71. package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrApi/data.js +24 -20
  72. package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrApi/template.ejs +2 -2
  73. package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrDsq/data.js +27 -20
  74. package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrInv/data.js +54 -22
  75. package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrSqs/data.js +28 -23
  76. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrSqs/template.ejs +30 -0
  77. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/data.js +6 -22
  78. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/getTemplate.ejs +76 -0
  79. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/updateTemplate.ejs +67 -0
  80. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/data.js +47 -37
  81. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/getTemplate.ejs +105 -0
  82. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/updateTemplate.ejs +109 -0
  83. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/createTemplate.ejs +75 -0
  84. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/data.js +68 -33
  85. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/getTemplate.ejs +82 -0
  86. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/updateTemplate.ejs +75 -0
  87. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/data.js +46 -30
  88. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/getTemplate.ejs +124 -0
  89. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/updateTemplate.ejs +133 -0
  90. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/CreateObject_main.js +760 -0
  91. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/data.js +67 -0
  92. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/request.json +0 -0
  93. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/template.ejs +581 -0
  94. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/data.js +0 -21
  95. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/template.ejs +34 -31
  96. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/testParam.json +5 -0
  97. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/data.js +61 -0
  98. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/request.json +0 -0
  99. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/template.ejs +267 -0
  100. package/src/TemplateManager/src/ProcessLogical/Handler/data.js +49 -0
  101. package/src/TemplateManager/src/ProcessLogical/Handler/template.ejs +129 -0
  102. package/src/TemplateManager/src/ProcessLogical/ProcessLogicalYaml/data.js +175 -0
  103. package/src/TemplateManager/src/ProcessLogical/ProcessLogicalYaml/template.ejs +25 -0
  104. package/src/TemplateManager/src/ProcessLogical/mainFunction/data.js +47 -0
  105. package/src/TemplateManager/src/ProcessLogical/mainFunction/template.ejs +421 -0
  106. package/src/TemplateManager/src/ProcessLogicalPagination/DsqYaml/data.js +50 -0
  107. package/src/TemplateManager/src/ProcessLogicalPagination/DsqYaml/template.ejs +32 -0
  108. package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrDsq/data.js +167 -0
  109. package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrDsq/template.ejs +25 -0
  110. package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrSqs/data.js +169 -0
  111. package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrSqs/template.ejs +25 -0
  112. package/src/TemplateManager/src/ProcessLogicalPagination/Handler/HdrDsq/data.js +48 -0
  113. package/src/TemplateManager/src/ProcessLogicalPagination/Handler/HdrDsq/template.ejs +163 -0
  114. package/src/TemplateManager/src/ProcessLogicalPagination/Handler/HdrSqs/data.js +48 -0
  115. package/src/TemplateManager/src/ProcessLogicalPagination/Handler/HdrSqs/template.ejs +146 -0
  116. package/src/TemplateManager/src/ProcessLogicalPagination/mainFunction/data.js +48 -0
  117. package/src/TemplateManager/src/ProcessLogicalPagination/mainFunction/template.ejs +212 -0
  118. package/src/TemplateManager/src/ResourceYaml/CreateSourceData.js +2 -2
  119. package/src/TemplateManager/src/ResourceYaml/dynamodb/awaitingMultipleStepData.js +5 -8
  120. package/src/TemplateManager/src/ResourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +4 -26
  121. package/src/TemplateManager/src/ResourceYaml/dynamodb/processLogicalAndFindData.js +6 -10
  122. package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical.js +28 -16
  123. package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/snsAndSqsPerActiondata.js +5 -5
  124. package/src/TemplateManager/src/ResourceYaml/sns-out/data.js +3 -3
  125. package/src/TemplateManager/src/ResourceYaml/sns-out/defaultSnsOutForFindDataAndProcessLogical.js +75 -0
  126. package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/functionYaml/data.js +95 -0
  127. package/src/TemplateManager/src/{FunctionYaml/HdrSqs → TranslateIdReq/ProcessingTranslateIds/functionYaml}/template.ejs +1 -1
  128. package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/handler/dataHdrDsq.js +52 -0
  129. package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/handler/template.ejs +194 -0
  130. package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/mainFunction/data.js +48 -0
  131. package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/mainFunction/template.ejs +330 -0
  132. package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/sns-out/data.js +47 -0
  133. package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/sqs-sns/data.js +58 -0
  134. package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/sqs-sns/template.ejs +43 -0
  135. package/src/TemplateManager/src/TranslateIdReq/TranslateIds/functionYaml/HdrDsq/data.js +116 -0
  136. package/src/TemplateManager/src/TranslateIdReq/TranslateIds/functionYaml/HdrSqs/data.js +116 -0
  137. package/src/TemplateManager/src/TranslateIdReq/TranslateIds/handler/HdrDsq/data.js +60 -0
  138. package/src/TemplateManager/src/TranslateIdReq/TranslateIds/handler/HdrDsq/template.ejs +157 -0
  139. package/src/TemplateManager/src/TranslateIdReq/TranslateIds/handler/HdrSqs/data.js +59 -0
  140. package/src/TemplateManager/src/TranslateIdReq/TranslateIds/handler/HdrSqs/template.ejs +175 -0
  141. package/src/TemplateManager/src/TranslateIdReq/TranslateIds/mainFunction/data.js +61 -0
  142. package/src/TemplateManager/src/TranslateIdReq/TranslateIds/mainFunction/template.ejs +155 -0
  143. package/src/TemplateManager/src/TranslateIdReq/TranslateIds/resourceYaml/dynamoDb/data.js +120 -0
  144. package/src/TemplateManager/src/TranslateIdReq/TranslateIds/resourceYaml/sns-sqs/data.js +75 -0
  145. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/data.js +8 -24
  146. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/handler/HdrSqs/data.js +7 -21
  147. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/data.js +4 -3
  148. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/template.ejs +1 -1
  149. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-in-sqs/data.js +10 -13
  150. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-in-sqs/template.ejs +1 -0
  151. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-out/data.js +6 -5
  152. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/data.js +13 -21
  153. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/data.js +11 -29
  154. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/data.js +16 -21
  155. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/data.js +12 -27
  156. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/mainFunction/data.js +3 -18
  157. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/mainFunction/template.ejs +18 -11
  158. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/data.js +5 -18
  159. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/data.js +5 -19
  160. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/data.js +7 -18
  161. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/data.js +6 -20
  162. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/request.json +3 -4
  163. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-in-sqs/data.js +5 -6
  164. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-out/data.js +4 -4
  165. package/src/TemplateManager/src/externalService/LambdaRole/data.js +181 -59
  166. package/src/TemplateManager/src/externalService/LambdaRole/template.ejs +17 -15
  167. package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/data.js +56 -44
  168. package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/template.ejs +3 -4
  169. package/src/TemplateManager/src/libs/Consts.js +162 -13
  170. package/src/TemplateManager/src/PerActionEndpoint/Handler/testRequest.json +0 -5
  171. /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrApi/request.json +0 -0
  172. /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrDsq/request.json +0 -0
  173. /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrDsq/template.ejs +0 -0
  174. /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrInv/example req.js +0 -0
  175. /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrInv/request.json +0 -0
  176. /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrInv/template.ejs +0 -0
  177. /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrSqs/request.json +0 -0
@@ -0,0 +1,167 @@
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 izara = require("@izara_project/izara-middleware");
21
+ const middleware = izara.middlewareHandler;
22
+
23
+ const callingFlowSharedLib = require('@izara_project/izara-shared/src/CallingFlowSharedLib');
24
+
25
+ // const CorrelationIds = require('@izara_project/izara-core-library-correlation-ids')
26
+ // const IntegrationTestDetail = require('@izara_project/izara-core-library-integration-tests')
27
+ const Logger = require('@izara_project/izara-core-library-logger');
28
+ const recordHandlerSharedLib = require('@izara_project/izara-shared').recordHandlerSharedLib
29
+
30
+
31
+ const <%- functionName %> = require('./<%- firstLetterUpperCase(functionName) %>_Main');
32
+ // validate event properties in body.Message of sqs event
33
+ middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema(
34
+ {
35
+ type: "object",
36
+ required: ['body', 'messageAttributes'],
37
+ properties: {
38
+ body: {
39
+ type: 'object',
40
+ },
41
+ messageAttributes: {
42
+ type: 'object'
43
+ }
44
+ }
45
+ }
46
+ ));
47
+
48
+ // validate event params in middlewware before into function.
49
+ let validatorSchema = {
50
+ type: "object",
51
+ required: ["objects", "relType"],
52
+ properties: {
53
+ objects: {
54
+ type: "array",
55
+ minItems: 2,
56
+ maxItems: 2,
57
+ items: {
58
+ type: 'object',
59
+ required: ["objType", "identifiers"],
60
+ properties: {
61
+ objType: {
62
+ type: "object",
63
+ required: ["serviceTag", "objectType"],
64
+ properties: {
65
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
66
+ objectType: izara.validatorSchema.stringNotEmpty()
67
+ }
68
+ },
69
+ identifiers: {
70
+ type: "object",
71
+ minProperties: 1
72
+ }
73
+ }
74
+ }
75
+ },
76
+ relType: {
77
+ type: "object",
78
+ required: ["relationshipTag", "serviceTag"],
79
+ properties: {
80
+ relationshipTag: izara.validatorSchema.stringNotEmpty(),
81
+ serviceTag: {
82
+ type: 'string',
83
+ pattern: "^[a-zA-Z0-9_-]+$",
84
+ enum: [process.env.iz_serviceTag]
85
+ },
86
+ }
87
+ },
88
+ relationshipProperties: {
89
+ type: 'object',
90
+ default: {}
91
+ },
92
+ }
93
+ };
94
+
95
+
96
+ //(<globalVarible>
97
+ //</globalVarible>)
98
+
99
+ // validate event params in middleware before into main function
100
+ validatorSchema = callingFlowSharedLib.addOptionalCallingFlowToValidatorSchema(validatorSchema);
101
+ // if need to validate authorizer or additional params , add code to hook tag below
102
+
103
+ //(<afterValidateWith>)
104
+ //(</afterValidateWith>)
105
+
106
+
107
+ module.exports.main = middleware.wrap(async (event, context, callback) => {
108
+ Logger.debug('event:', event);
109
+ Logger.debug('context:', context);
110
+ try {
111
+
112
+ let recordPromises = []; // final return
113
+
114
+ // loop each record and send to mainFunction
115
+ await Promise.all(event.Records.map(async record => { // promise.all for map() function
116
+
117
+ // --- reforming record.body for Dsq request
118
+ record = recordHandlerSharedLib.reformatDsqMessage(record._izContext, record);
119
+ record._izContext.logger.debug('record LambdaFunctionHdrDsq after reform', record);
120
+
121
+ let passOnProperties = []
122
+
123
+ // --- validate message (and MessageAttributes)
124
+ await recordHandlerSharedLib.validateRecord(
125
+ record, // one record will send to mainFunction
126
+ "<%- queueName %>", // queue name that need to retry or send to dlq
127
+ validatorSchema, // schema for record.Message
128
+ // messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
129
+ );
130
+
131
+ // add argument (to invoke lambda) to passOnProperties[]
132
+ passOnProperties.push(record.body.Message)
133
+ passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
134
+ //(<afterPutParamIntoMainFunction>)
135
+ //(</afterPutParamIntoMainFunction>)
136
+ record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
137
+
138
+ // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
139
+ let recordPromise = recordHandlerSharedLib.recordHandler(
140
+ record, // one record will send to mainFunction
141
+ <%- functionName %>.<%- functionName %>, // mainFunction that need to invoke.
142
+ "<%- queueName %>", // queue name that need to retry or send to dlq
143
+ passOnProperties, // all parameters that mainFunction needed.
144
+ );
145
+ record._izContext.logger.debug('after recordPromise in handler');
146
+ recordPromises.push(recordPromise); // push promise to recordPromises
147
+ })) //end record
148
+
149
+ Logger.debug('before Promise.all(recordPromises) in handler');
150
+ try {
151
+ await Promise.all(recordPromises); // await all promises
152
+ return event.Records // return all for local test
153
+ } catch {
154
+ Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did no resolve)');
155
+ }
156
+ Logger.debug('after Promise.all(recordPromises) in handler');
157
+ } catch (err) {
158
+ Logger.error('Unhandled Error, updateRelationshipHdrDsq:', err);
159
+ throw (err);
160
+ }
161
+ });
162
+ <%_ function firstLetterUpperCase(text) {
163
+ return text.charAt(0).toUpperCase() + text.slice(1)
164
+ } _%>
165
+ <%_ function firstLetterLowerCase(str) {
166
+ return str.charAt(0).toLowerCase() + str.slice(1)
167
+ } _%>
@@ -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
+ const fs = require('fs');
21
+
22
+ const { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
23
+
24
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase } = require("../../../../../../MainLibs/src/Utils")
25
+ const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH, FUNCTION_NAME } = require("../../../../libs/Consts");
26
+
27
+ const templatePath = path.join(__dirname, "./template.ejs")
28
+
29
+ /**
30
+ * receive objectSchema
31
+ * create data for hdrInv template
32
+ *
33
+ * @return {{ templatePath, templateData, setting } }
34
+ */
35
+ function data(_izContext, srcPath) {
36
+ const createSourceParams = createParamForCreateSource(srcPath)
37
+ return [createSourceParams];
38
+ }
39
+
40
+
41
+ function createParamForCreateSource(srcPath) {
42
+ let functionName = FUNCTION_NAME.createRel;
43
+ let handler = HANDLER.hdrInv
44
+ return {
45
+ templatePath: templatePath,
46
+ templateData: {
47
+ functionName,
48
+ handler
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,107 @@
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 izara = require("@izara_project/izara-middleware");
21
+ const middleware = izara.middlewareHandler;
22
+
23
+ const callingFlowSharedLib = require('@izara_project/izara-shared/src/CallingFlowSharedLib');
24
+
25
+ // const CorrelationIds = require('@izara_project/izara-core-library-correlation-ids')
26
+ // const Logger = require('@izara_project/izara-core-library-logger');
27
+ // const IntegrationTestDetail = require('@izara_project/izara-core-library-integration-tests')
28
+
29
+ const <%- functionName %> = require('./<%- firstLetterUpperCase(functionName) %>_Main');
30
+
31
+ // validate event params in middlewware before into function.
32
+ let validatorSchema = {
33
+ type: "object",
34
+ required: ["objects", "relType"],
35
+ properties: {
36
+ objects: {
37
+ type: "array",
38
+ minItems: 2,
39
+ maxItems: 2,
40
+ items: {
41
+ type: 'object',
42
+ required: ["objType", "identifiers"],
43
+ properties: {
44
+ objType: {
45
+ type: "object",
46
+ required: ["serviceTag", "objectType"],
47
+ properties: {
48
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
49
+ objectType: izara.validatorSchema.stringNotEmpty()
50
+ }
51
+ },
52
+ identifiers: {
53
+ type: "object",
54
+ minProperties: 1
55
+ }
56
+ }
57
+ }
58
+ },
59
+ relType: {
60
+ type: "object",
61
+ required: ["relationshipTag", "serviceTag"],
62
+ properties: {
63
+ relationshipTag: izara.validatorSchema.stringNotEmpty(),
64
+ serviceTag: {
65
+ type: 'string',
66
+ pattern: "^[a-zA-Z0-9_-]+$",
67
+ enum: [process.env.iz_serviceTag]
68
+ },
69
+ }
70
+ },
71
+ relationshipProperties: {
72
+ type: 'object',
73
+ default: {}
74
+ },
75
+ }
76
+ };
77
+
78
+ validatorSchema = callingFlowSharedLib.addOptionalCallingFlowToValidatorSchema(validatorSchema); // is Ok callinfFlow
79
+ middleware.setValidatorSchema(validatorSchema)
80
+
81
+ module.exports.main = middleware.wrap(async (event, context, callback) => {
82
+ event._izContext.logger.debug('Event:', event);
83
+ event._izContext.logger.debug('context:', context);
84
+
85
+ try {
86
+ // invoke LambdaFunction
87
+ return await createRelationship.createRelationship(
88
+ event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId
89
+ {
90
+ objects: event.objects,
91
+ relType: event.relType,
92
+ relationshipProperties: event.relationshipProperties,
93
+ },
94
+ callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
95
+ );
96
+
97
+ } catch (err) {
98
+ event._izContext.logger.error('Error, <%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handler) %> : ', err);
99
+ throw (err);
100
+ }
101
+ });
102
+ <%_ function firstLetterUpperCase(text) {
103
+ return text.charAt(0).toUpperCase() + text.slice(1)
104
+ } _%>
105
+ <%_ function firstLetterLowerCase(str) {
106
+ return str.charAt(0).toLowerCase() + str.slice(1)
107
+ } _%>
@@ -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
+ const fs = require('fs');
21
+
22
+ const { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
23
+
24
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase } = require("../../../../../../MainLibs/src/Utils")
25
+ const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH, FUNCTION_NAME } = require("../../../../libs/Consts");
26
+
27
+ const templatePath = path.join(__dirname, "./template.ejs")
28
+
29
+ /**
30
+ * receive objectSchema
31
+ * create data for sqs template
32
+ *
33
+ * @return {{ templatePath, templateData, setting } }
34
+ */
35
+ function data(_izContext, srcPath) {
36
+ const createSourceParams = createParamForCreateSource(srcPath)
37
+ return [createSourceParams];
38
+ }
39
+
40
+
41
+ function createParamForCreateSource(srcPath) {
42
+ let functionName = FUNCTION_NAME.createRel;
43
+ let queueName = functionName + upperCase(HANDLER.hdrSqs)
44
+ return {
45
+ templatePath: templatePath,
46
+ templateData: {
47
+ functionName,
48
+ queueName
49
+ },
50
+ setting: {
51
+ savePath: path.join(srcPath, SOURCE_PATH.relationshipPerAction),
52
+ saveFileName: upperCase(functionName) + "_" + upperCase(HANDLER.hdrSqs),
53
+ fileExtension: '.js',
54
+ isAppend: false
55
+ }
56
+ }
57
+ }
58
+
59
+
60
+ module.exports = data;
@@ -0,0 +1,146 @@
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 izara = require("@izara_project/izara-middleware");
20
+ const middleware = izara.middlewareHandler;
21
+ const callingFlowSharedLib = require('@izara_project/izara-shared/src/CallingFlowSharedLib')
22
+ const {
23
+ validateSchemaMiddleware
24
+ } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
25
+ const Logger = require('@izara_project/izara-core-library-logger');
26
+ const recordHandlerSharedLib = require('@izara_project/izara-shared').recordHandlerSharedLib
27
+
28
+ const <%- functionName %> = require('./<%- firstLetterUpperCase(functionName) %>_Main');
29
+
30
+ middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
31
+
32
+ // validate event params in middleware before into function
33
+ let validatorSchema = {
34
+ type: "object",
35
+ required: ["objects", "relType"],
36
+ properties: {
37
+ objects: {
38
+ type: "array",
39
+ minItems: 2,
40
+ maxItems: 2,
41
+ items: {
42
+ type: 'object',
43
+ required: ["objType", "identifiers"],
44
+ properties: {
45
+ objType: {
46
+ type: "object",
47
+ required: ["serviceTag", "objectType"],
48
+ properties: {
49
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
50
+ objectType: izara.validatorSchema.stringNotEmpty()
51
+ }
52
+ },
53
+ identifiers: {
54
+ type: "object",
55
+ minProperties: 1
56
+ }
57
+ }
58
+ }
59
+ },
60
+ relType: {
61
+ type: "object",
62
+ required: ["relationshipTag", "serviceTag"],
63
+ properties: {
64
+ relationshipTag: izara.validatorSchema.stringNotEmpty(),
65
+ serviceTag: {
66
+ type: 'string',
67
+ pattern: "^[a-zA-Z0-9_-]+$",
68
+ enum: [process.env.iz_serviceTag]
69
+ },
70
+ }
71
+ },
72
+ relationshipProperties: {
73
+ type: 'object',
74
+ default: {}
75
+ },
76
+ }
77
+ };
78
+
79
+
80
+ //(<globalVarible>
81
+ //</globalVarible>)
82
+
83
+ // validate event params in middleware before into main function
84
+ validatorSchema = callingFlowSharedLib.addOptionalCallingFlowToValidatorSchema(validatorSchema);
85
+ // if need to validate authorizer or additional params , add code to hook tag below
86
+
87
+ //(<afterValidateWith>)
88
+ //(</afterValidateWith>)
89
+
90
+ module.exports.main = middleware.wrap(async (event, context, callback) => {
91
+
92
+ try {
93
+
94
+ let recordPromises = []; // final return
95
+
96
+ // loop each record and send to mainFunction
97
+ await Promise.all(event.Records.map(async record => { // promise.all for map() function
98
+
99
+ let passOnProperties = []
100
+
101
+ // --- validate message (and MessageAttributes)
102
+ await recordHandlerSharedLib.validateRecord(
103
+ record, // one record will send to mainFunction
104
+ "<%-firstLetterUpperCase(queueName) %>", // queue name that need to retry or send to dlq
105
+ validatorSchema, // schema for record.Message
106
+ // messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
107
+ );
108
+
109
+ // add argument (to invoke lambda) to passOnProperties[]
110
+ passOnProperties.push(record.body.Message)
111
+ passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
112
+ //(<afterPutParamIntoMainFunction>)
113
+ //(</afterPutParamIntoMainFunction>)
114
+
115
+ record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
116
+
117
+ // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
118
+ let recordPromise = recordHandlerSharedLib.recordHandler(
119
+ record, // one record will send to mainFunction
120
+ <%- functionName %>.<%- functionName %>, // mainFunction that need to invoke.
121
+ "<%-firstLetterUpperCase(queueName) %>", // queue name that need to retry or send to dlq
122
+ passOnProperties, // all parameters that mainFunction needed.
123
+ );
124
+ record._izContext.logger.debug('after recordPromise in handler');
125
+ recordPromises.push(recordPromise); // push promise to recordPromises
126
+ })) //end record
127
+
128
+ Logger.debug('before Promise.all(recordPromises) in handler');
129
+ try {
130
+ await Promise.all(recordPromises); // await all promises
131
+ return event.Records // return all for local test
132
+ } catch {
133
+ Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did no resolve)');
134
+ }
135
+ Logger.debug('after Promise.all(recordPromises) in handler');
136
+ } catch (err) {
137
+ Logger.error('Unhandled Error, updateRelationshipHdrDsq:', err);
138
+ throw (err);
139
+ }
140
+ });
141
+ <%_ function firstLetterUpperCase(text) {
142
+ return text.charAt(0).toUpperCase() + text.slice(1)
143
+ } _%>
144
+ <%_ function firstLetterLowerCase(str) {
145
+ return str.charAt(0).toLowerCase() + str.slice(1)
146
+ } _%>
@@ -0,0 +1,30 @@
1
+ {
2
+ "objects": [
3
+ {
4
+ "objType": {
5
+ "objectType": "Sunny",
6
+ "serviceTag": "GenerateCodeTemplateBas"
7
+ },
8
+ "identifiers": {
9
+ "personId": "Node1"
10
+ }
11
+ },
12
+ {
13
+ "objType": {
14
+ "objectType": "Weather",
15
+ "serviceTag": "GenerateCodeTemplateBas"
16
+ },
17
+ "identifiers": {
18
+ "personId": "Node2"
19
+ }
20
+ }
21
+ ],
22
+ "relType": {
23
+ "relationshipTag": "RelTag",
24
+ "serviceTag": "GenerateCodeTemplateBas"
25
+ },
26
+ "relationshipProperties": {
27
+ "name": "bas007"
28
+ },
29
+ "callingFlow": "bas"
30
+ }
@@ -0,0 +1,78 @@
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
+
23
+ const {
24
+ HANDLER,
25
+ } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
26
+
27
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils")
28
+ const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME } = require("../../../libs/Consts");
29
+ const snsTemplatePath = path.join(__dirname, "../../../ResourceYaml/sns-in-sqs/snsTemplate.ejs")
30
+ const sqsTemplatePath = path.join(__dirname, "../../../ResourceYaml/sns-in-sqs/sqsTemplate.ejs")
31
+
32
+ /**
33
+ * create data for dynamoDbYaml tempalte from objectSchema
34
+ *
35
+ * @param {Object} _izContext
36
+ * @param {String} saveFilePath
37
+ * @returns {Object[]} - data of multiple dynamoDb template
38
+ */
39
+
40
+ function createRelationshipSnsInSqs(_izContext, srcPath) {
41
+ let resultForCreateRelationshipSnsAndSqs = [];
42
+ const setting = {
43
+ initialData: "Resources:\n",
44
+ savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
45
+ saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
46
+ fileExtension: ".yml",
47
+ isAppend: true
48
+ }
49
+ const createRelationshipQueueNames = [
50
+ {
51
+ queueName: upperCase(FUNCTION_NAME.createRel)
52
+ },
53
+ {
54
+ queueName: upperCase(FUNCTION_NAME.createRel) + upperCase(HANDLER.hdrDsq)
55
+ }
56
+ ]
57
+ for (let createRelationshipQueueName of createRelationshipQueueNames) {
58
+ if (createRelationshipQueueName.queueName.includes("HdrDsq")) {
59
+ resultForCreateRelationshipSnsAndSqs.push({
60
+ templatePath: sqsTemplatePath,
61
+ templateData: createRelationshipQueueName,
62
+ setting: setting
63
+ }
64
+ )
65
+ } else {
66
+ resultForCreateRelationshipSnsAndSqs.push(
67
+ {
68
+ templatePath: snsTemplatePath,
69
+ templateData: createRelationshipQueueName,
70
+ setting: setting
71
+ }
72
+ )
73
+ }
74
+ }
75
+ return resultForCreateRelationshipSnsAndSqs
76
+ }
77
+
78
+ module.exports = createRelationshipSnsInSqs