@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,116 @@
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, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
23
+
24
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils")
25
+ const { DEFAULT_HANDLER_PER_ACTION, createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SQS_RESOURCE, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, externalResourceName } = require("../../../../libs/Consts");
26
+
27
+ const templatePath = path.join(__dirname, '../../../../PerActionEndpoint/FunctionYaml/HdrDsq/template.ejs');
28
+
29
+ function defaultIamRolePerAction() {
30
+ let defaultIamRole = [];
31
+
32
+ defaultIamRole.push(
33
+ createIamRole(
34
+ {
35
+ [RESOURCE_CLASSES.s3]: ["GetObject", "GetObjectVersion"],
36
+ },
37
+ [
38
+ resourceNames(RESOURCE_CLASSES.s3, "object-schema/perServiceSchemas/*"),
39
+ resourceNames(RESOURCE_CLASSES.s3, "object-schema/serviceConfig/ServiceNameConfig.json"),
40
+ resourceNames(RESOURCE_CLASSES.s3, "object-schema/serviceConfig/GraphServerTags.json")
41
+ ]
42
+ ),
43
+ createIamRole(
44
+ {
45
+ [RESOURCE_CLASSES.s3]: ["ListBucket"]
46
+ },
47
+ [
48
+ resourceNames(RESOURCE_CLASSES.s3, "object-schema")
49
+ ]
50
+ )
51
+ )
52
+ return defaultIamRole
53
+ }
54
+
55
+ /**
56
+ * create data for function yaml for translateIds HdrSqs
57
+ */
58
+
59
+ function data(_izContext, srcPath) {
60
+ return [createTranslateIdFunctionYmlHdrSqs(srcPath)]
61
+ }
62
+
63
+ function createTranslateIdFunctionYmlHdrSqs(srcPath) {
64
+ const functionName = FUNCTION_NAME.translateId;
65
+ const handlerType = HANDLER.hdrSqs;
66
+ let additionalResourcePermission = defaultIamRolePerAction();
67
+ additionalResourcePermission.push(
68
+ createIamRole(
69
+ {
70
+ [RESOURCE_CLASSES.sqs]: [
71
+ SQS_RESOURCE.deleteMessage,
72
+ SQS_RESOURCE.getQueueAttributes,
73
+ SQS_RESOURCE.receiveMessage,
74
+ SQS_RESOURCE.sendMessage,
75
+ SQS_RESOURCE.getQueueUrl
76
+ ],
77
+ [RESOURCE_CLASSES.sns]:
78
+ [
79
+ "Publish", "Subscribe"
80
+ ]
81
+ },
82
+ [
83
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(handlerType)),
84
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(handlerType) + "DLQ"),
85
+ resourceNames(RESOURCE_CLASSES.sns, "In" + upperCase(functionName)),
86
+ resourceNames(RESOURCE_CLASSES.sns, "Out" + upperCase(functionName)),
87
+ ]
88
+ ),
89
+ createIamRole(
90
+ {
91
+ [RESOURCE_CLASSES.dynamoDbTable]: ["GetItem", "UpdateItem"]
92
+ },
93
+ [
94
+ resourceNames(RESOURCE_CLASSES.dynamoDbTable, "TranslateIdsCacheMain")
95
+ ]
96
+ )
97
+ )
98
+
99
+ return {
100
+ templatePath: templatePath,
101
+ templateData: {
102
+ functionName,
103
+ handlerType,
104
+ resourceLocation: SOURCE_PATH.resourceLocationTranslateId,
105
+ additionalResourcePermission
106
+ },
107
+ setting: {
108
+ savePath: path.join(srcPath, SOURCE_PATH.appYaml),
109
+ saveFileName: SAVE_FILE_NAME.translateId,
110
+ fileExtension: '.yml',
111
+ isAppend: true
112
+ }
113
+ }
114
+ };
115
+
116
+ module.exports = data;
@@ -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, SAVE_FILE_NAME, FUNCTION_NAME } = require("../../../../libs/Consts");
26
+
27
+
28
+ const templatePath = path.join(__dirname, "./template.ejs")
29
+
30
+ /**
31
+ * create data for TranslateId Handler Dsq
32
+ * @return {{templatePath, templateData, setting}}
33
+ */
34
+
35
+ function createTranslateIdHandlerDsq(_izContext, srcPath) {
36
+ let createSourceParams = createSourceParamsTranslateIdHandlerDsq(srcPath)
37
+ return [createSourceParams]
38
+ }
39
+
40
+ function createSourceParamsTranslateIdHandlerDsq(srcPath) {
41
+ const handlerType = HANDLER.hdrDsq
42
+ const functionName = FUNCTION_NAME.translateId
43
+ const queueName = upperCase(functionName) + upperCase(handlerType)
44
+ return {
45
+ templatePath: templatePath,
46
+ templateData: {
47
+ queueName,
48
+ functionName,
49
+ handlerType
50
+ },
51
+ setting: {
52
+ savePath: path.join(srcPath, SOURCE_PATH.translateIdsRequestFile),
53
+ saveFileName: `${SAVE_FILE_NAME.translateId}_${upperCase(handlerType)}`,
54
+ fileExtension: '.js',
55
+ isAppend: false
56
+ }
57
+ }
58
+ };
59
+
60
+ module.exports = createTranslateIdHandlerDsq;
@@ -0,0 +1,157 @@
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 recordHandlerSharedLib = require('@izara_project/izara-shared').recordHandlerSharedLib;
23
+ const {
24
+ validateSchemaMiddleware
25
+ } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
26
+ const Logger = require('@izara_project/izara-core-library-logger');
27
+ const translateIdsRequest = require('./TranslateIdsRequest_Main')
28
+ const perRecordsValidatorSchema = {
29
+ type: "object",
30
+ required: [
31
+ "fromObjType",
32
+ // "fromTypeId",
33
+ "toObjType",
34
+ // "toTypeId",
35
+ "relType",
36
+ ],
37
+ properties: {
38
+ fromObjType: {
39
+ type: "object",
40
+ required: ["objectType", "serviceTag"],
41
+ properties: {
42
+ objectType: izara.validatorSchema.stringNotEmpty(),
43
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
44
+ },
45
+ },
46
+ fromTypeId: {
47
+ type: "string",
48
+ },
49
+ concatinateIdentifier: {
50
+ type: "string",
51
+ },
52
+ fromTable: {
53
+ type: "string",
54
+ },
55
+ fromPartitionKeyId: {
56
+ type: "string",
57
+ },
58
+ fromPartitionKeyFieldName: {
59
+ type: "string",
60
+ },
61
+ fromDataFieldName: {
62
+ type: "string",
63
+ },
64
+ toObjType: {
65
+ type: "object",
66
+ required: ["objectType", "serviceTag"],
67
+ properties: {
68
+ objectType: izara.validatorSchema.stringNotEmpty(),
69
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
70
+ },
71
+ },
72
+ toTypeId: {
73
+ type: "string",
74
+ },
75
+ relType: {
76
+ type: "object",
77
+ required: ["relationshipTag", "serviceTag"],
78
+ properties: {
79
+ relationshipTag: izara.validatorSchema.stringNotEmpty(),
80
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
81
+ }
82
+ },
83
+ invocationCount: {
84
+ type: "number",
85
+ default: 0,
86
+ },
87
+ callingFlow: {
88
+ type: "string",
89
+ default: "",
90
+ },
91
+ },
92
+ };
93
+ //(<globalVarible>)
94
+ //(</globalVarible>)
95
+ module.exports.main = middleware.wrap(async (event, context, callback) => {
96
+
97
+ try {
98
+ let recordPromises = []; // final return
99
+
100
+ // loop each record and send to mainFunction
101
+ await Promise.all(event.Records.map(async record => { // promise.all for map() function
102
+
103
+ // --- reforming record.body for Dsq request
104
+ record = recordHandlerSharedLib.reformatDsqMessage(record._izContext, record);
105
+ record._izContext.logger.debug('record LambdaFunctionHdrDsq after reform', record);
106
+
107
+ let passOnProperties = []
108
+
109
+ // --- validate message (and MessageAttributes)
110
+ await recordHandlerSharedLib.validateRecord(
111
+ record, // one record will send to mainFunction
112
+ "TranslateIdsRequestHdrDsq", // queue name that need to retry or send to dlq
113
+ perRecordsValidatorSchema, // schema for record.Message
114
+ // messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
115
+ );
116
+
117
+ // add argument (to invoke lambda) to passOnProperties[]
118
+ passOnProperties.push(record.body.Message.fromObjType)
119
+ passOnProperties.push(record.body.Message.fromTypeId)
120
+ passOnProperties.push(record.body.Message.concatinateIdentifier)
121
+ passOnProperties.push(record.body.Message.fromTable)
122
+ passOnProperties.push(record.body.Message.fromPartitionKeyId)
123
+ passOnProperties.push(record.body.Message.fromPartitionKeyFieldName)
124
+ passOnProperties.push(record.body.Message.fromDataFieldName)
125
+ passOnProperties.push(record.body.Message.toObjType)
126
+ passOnProperties.push(record.body.Message.toTypeId)
127
+ passOnProperties.push(record.body.Message.relType)
128
+ passOnProperties.push(record.body.Message.callingFlow)
129
+ //(<afterSendParamIntoTranslateIdMainByHandlerDsq>)
130
+ //(</afterSendParamIntoTranslateIdMainByHandlerDsq>)
131
+
132
+ record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
133
+
134
+ // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
135
+ let recordPromise = recordHandlerSharedLib.recordHandler(
136
+ record, // one record will send to mainFunction
137
+ translateIdsRequest.translateIdsRequest, // mainFunction that need to invoke.
138
+ "TranslateIdsRequestHdrDsq", // queue name that need to retry or send to dlq
139
+ passOnProperties, // all parameters that mainFunction needed.
140
+ );
141
+ record._izContext.logger.debug('after recordPromise in handler');
142
+ recordPromises.push(recordPromise); // push promise to recordPromises
143
+ })) //end record
144
+
145
+ Logger.debug('before Promise.all(recordPromises) in handler');
146
+ try {
147
+ await Promise.all(recordPromises); // await all promises
148
+ return event.Records // return all for local test
149
+ } catch {
150
+ Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did no resolve)');
151
+ }
152
+ Logger.debug('after Promise.all(recordPromises) in handler');
153
+ } catch (err) {
154
+ Logger.error('Unhandled error, TranslateIdsRequestHdrDsq:', err);
155
+ throw (err)
156
+ }
157
+ })
@@ -0,0 +1,59 @@
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, SAVE_FILE_NAME, FUNCTION_NAME } = require("../../../../libs/Consts");
26
+ const templatePath = path.join(__dirname, './template.ejs');
27
+
28
+ /**
29
+ * create data for sqs template
30
+ *
31
+ * @return {{templatePath,templateData,setting}}
32
+ */
33
+
34
+ function data(_izContext, srcPath) {
35
+ const createSourceParams = createTranslateIdsHandlerSqs(srcPath);
36
+ return [createSourceParams]
37
+ }
38
+
39
+ function createTranslateIdsHandlerSqs(srcPath) {
40
+ const functionName = FUNCTION_NAME.translateId;
41
+ const handler = HANDLER.hdrSqs;
42
+ const queueName = upperCase(functionName) + upperCase(handler)
43
+ return {
44
+ templatePath: templatePath,
45
+ templateData: {
46
+ functionName,
47
+ handler,
48
+ queueName
49
+ },
50
+ setting: {
51
+ savePath: path.join(srcPath, SOURCE_PATH.translateIdsRequestFile),
52
+ saveFileName: `${SAVE_FILE_NAME.translateId}_${upperCase(handler)}`,
53
+ fileExtension: '.js',
54
+ isAppend: false
55
+ }
56
+ }
57
+ };
58
+
59
+ module.exports = data;
@@ -0,0 +1,175 @@
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 send into main function
33
+ let validatorSchema = {
34
+ type: "object",
35
+ required: [
36
+ "fromObjType",
37
+ // "fromTypeId",
38
+ "toObjType",
39
+ // "toTypeId",
40
+ "relType",
41
+ ],
42
+ properties: {
43
+ fromObjType: {
44
+ type: "object",
45
+ required: ["objectType", "serviceTag"],
46
+ properties: {
47
+ objectType: izara.validatorSchema.stringNotEmpty(),
48
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
49
+ },
50
+ },
51
+ fromTypeId: {
52
+ type: "string",
53
+ },
54
+ concatinateIdentifier: {
55
+ type: "string",
56
+ },
57
+ fromTable: {
58
+ type: "string",
59
+ },
60
+ fromPartitionKeyId: {
61
+ type: "string",
62
+ },
63
+ fromPartitionKeyFieldName: {
64
+ type: "string",
65
+ },
66
+ fromDataFieldName: {
67
+ type: "string",
68
+ },
69
+ toObjType: {
70
+ type: "object",
71
+ required: ["objectType", "serviceTag"],
72
+ properties: {
73
+ objectType: izara.validatorSchema.stringNotEmpty(),
74
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
75
+ },
76
+ },
77
+ toTypeId: {
78
+ type: "string",
79
+ },
80
+ relType: {
81
+ type: "object",
82
+ required: ["relationshipTag", "serviceTag"],
83
+ properties: {
84
+ relationshipTag: izara.validatorSchema.stringNotEmpty(),
85
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
86
+ }
87
+ },
88
+ invocationCount: {
89
+ type: "number",
90
+ default: 0,
91
+ },
92
+ callingFlow: {
93
+ type: "string",
94
+ default: "",
95
+ },
96
+ },
97
+ };
98
+
99
+ //(<globalVarible>)
100
+ //(</globalVarible>)
101
+
102
+ //validate event params in middleware
103
+ validatorSchema = callingFlowSharedLib.addOptionalCallingFlowToValidatorSchema(validatorSchema);
104
+
105
+ //(<afterValidate>)
106
+ //(</afterValidate>)
107
+
108
+ module.exports.main = middleware.wrap(async (event, context, callback) => {
109
+ try {
110
+ let recordPromises = []; // final return
111
+
112
+ // loop each record and send to mainFunction
113
+ await Promise.all(event.Records.map(async record => { // promise.all for map() function
114
+
115
+ let passOnProperties = []
116
+
117
+ // --- validate message (and MessageAttributes)
118
+ await recordHandlerSharedLib.validateRecord(
119
+ record, // one record will send to mainFunction
120
+ "<%-firstLetterUpperCase(queueName) %>", // queue name that need to retry or send to dlq
121
+ validatorSchema, // schema for record.Message
122
+ // messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
123
+ );
124
+
125
+ // add argument (to invoke lambda) to passOnProperties[]
126
+ passOnProperties.push(record.body.Message.fromObjType)
127
+ passOnProperties.push(record.body.Message.fromTypeId)
128
+ passOnProperties.push(record.body.Message.concatinateIdentifier)
129
+ passOnProperties.push(record.body.Message.fromTable)
130
+ passOnProperties.push(record.body.Message.fromPartitionKeyId)
131
+ passOnProperties.push(record.body.Message.fromPartitionKeyFieldName)
132
+ passOnProperties.push(record.body.Message.fromDataFieldName)
133
+ passOnProperties.push(record.body.Message.toObjType)
134
+ passOnProperties.push(record.body.Message.toTypeId)
135
+ passOnProperties.push(record.body.Message.relType)
136
+ passOnProperties.push(record.body.Message.callingFlow)
137
+ //(<afterPutParamIntoMainFunction>)
138
+ //(</afterPutParamIntoMainFunction>)
139
+
140
+ record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
141
+
142
+ // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
143
+ let recordPromise = recordHandlerSharedLib.recordHandler(
144
+ record, // one record will send to mainFunction
145
+ <%- functionName %>.<%- functionName %>, // mainFunction that need to invoke.
146
+ "<%-firstLetterUpperCase(queueName) %>", // queue name that need to retry or send to dlq
147
+ passOnProperties, // all parameters that mainFunction needed.
148
+ );
149
+ record._izContext.logger.debug('after recordPromise in handler');
150
+ recordPromises.push(recordPromise); // push promise to recordPromises
151
+ })) //end record
152
+
153
+ Logger.debug('before Promise.all(recordPromises) in handler');
154
+ try {
155
+ await Promise.all(recordPromises); // await all promises
156
+ return event.Records // return all for local test
157
+ } catch {
158
+ Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did no resolve)');
159
+ }
160
+ Logger.debug('after Promise.all(recordPromises) in handler');
161
+ } catch (err) {
162
+ Logger.error('Unhandled Error, <%- firstLetterUpperCase(functionName) %>:', err);
163
+ throw (err);
164
+ }
165
+ })
166
+
167
+
168
+
169
+
170
+ <%_ function firstLetterUpperCase(text) {
171
+ return text.charAt(0).toUpperCase() + text.slice(1)
172
+ } _%>
173
+ <%_ function firstLetterLowerCase(str) {
174
+ return str.charAt(0).toLowerCase() + str.slice(1)
175
+ } _%>
@@ -0,0 +1,61 @@
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
+ const { createGetDataDetails } = require('../../../../../GenerateCodeLibs/src/GenerateCodeLibs')
24
+
25
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase } = require("../../../../../MainLibs/src/Utils")
26
+ const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME } = require("../../../libs/Consts");
27
+
28
+
29
+ const templatePath = path.join(__dirname, "./template.ejs")
30
+
31
+
32
+ /**
33
+ * receive objectSchema
34
+ * create data for TranslateedMain
35
+ *
36
+ * @param {object} objectSchema
37
+ * @return {{templatePath, templateData, setting}}
38
+ */
39
+
40
+ async function createTranslateIdRequestMainFunction(_izContext, objectSchema, srcPath) {
41
+ return [await createSourceParams(_izContext, objectSchema, srcPath)];
42
+ }
43
+
44
+ async function createSourceParams(_izContext, objectSchema, srcPath) {
45
+ let functionName = FUNCTION_NAME.translateId
46
+ let getDataDetail = await createGetDataDetails(_izContext, objectSchema);
47
+ return {
48
+ templatePath: templatePath,
49
+ templateData: {
50
+ getDataDetail: JSON.stringify(getDataDetail),
51
+ functionName
52
+ },
53
+ setting: {
54
+ savePath: path.join(srcPath, SOURCE_PATH.translateIdsRequestFile),
55
+ saveFileName: `${SAVE_FILE_NAME.translateId}_Main`,
56
+ fileExtension: '.js',
57
+ isAppend: false
58
+ }
59
+ }
60
+ }
61
+ module.exports = createTranslateIdRequestMainFunction