@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,48 @@
1
+ /*
2
+ Copyright (C) 2020 Sven Mason <http://izara.io>
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Affero General Public License as
6
+ published by the Free Software Foundation, either version 3 of the
7
+ License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Affero General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Affero General Public License
15
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ 'use strict';
19
+
20
+ const path = require('path');
21
+ const { SOURCE_PATH, FUNCTION_NAME, HANDLER } = require("../../../libs/Consts");
22
+ const { firstLetterUpperCase: upperCase } = require('../../../../../MainLibs/src/Utils');
23
+ const templatePath = path.join(__dirname, "./template.ejs");
24
+
25
+
26
+ /**
27
+ * receive srcPath
28
+ * not create data for ProcessLogical Main template
29
+ *
30
+ * @param {Object} srcPath
31
+ * @return {{ templatePath, templateData, setting } }
32
+ */
33
+
34
+ function data(_izContext, srcPath) {
35
+
36
+ return {
37
+ templatePath: templatePath,
38
+ templateData: {},
39
+ setting: {
40
+ savePath: path.join(srcPath, SOURCE_PATH.processLogical),
41
+ saveFileName: `${upperCase(FUNCTION_NAME.paginateProcessLogical)}_${upperCase(HANDLER.hdrSqs)}`,
42
+ fileExtension: '.js',
43
+ isAppend: false
44
+ }
45
+ }
46
+ }
47
+
48
+ 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
+
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 recordHandlerSharedLib = require("@izara_project/izara-shared").recordHandlerSharedLib;
26
+ const Logger = require('@izara_project/izara-core-library-logger');
27
+
28
+ const paginateProcessLogical = require('./PaginateProcessLogical_Main');
29
+
30
+ // validate event properties in body.Message of sqs event
31
+ middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
32
+
33
+ // set schema for record.body.Message
34
+ const perRecordsValidatorSchema = {
35
+ type: "object",
36
+ required: [
37
+ 'logicalResultId',
38
+ 'tableName',
39
+ 'partitionKeyFieldName',
40
+ 'sortKeyFieldName'
41
+ ],
42
+ properties: {
43
+ logicalResultId: {
44
+ type: "string"
45
+ },
46
+ tableName: {
47
+ type: "string"
48
+ },
49
+ partitionKeyFieldName: {
50
+ type: "string"
51
+ },
52
+ sortKeyFieldName: {
53
+ type: "string"
54
+ },
55
+ comparison: {
56
+ type: "string",
57
+ default: ""
58
+ },
59
+ startKey: {
60
+ type: "object",
61
+ default: {}
62
+ },
63
+ overwriteUniqueRequestId: {
64
+ type: "string",
65
+ default: ""
66
+ },
67
+ callingFlow: {
68
+ type: 'string',
69
+ default: ""
70
+ }
71
+ }
72
+ };
73
+
74
+ // set schema for record.body.MessageAttributes
75
+ // const messageAttributeValidatorSchema = {
76
+ // type: "object",
77
+ // required: ['msgAtrrParam1', 'msgAtrrParam2'],
78
+ // properties: {
79
+ // msgAtrrParam1: {
80
+ // type: "string"
81
+ // },
82
+ // msgAtrrParam2: {
83
+ // type: "object"
84
+ // }
85
+ // }
86
+ // };
87
+
88
+ module.exports.main = middleware.wrap(async (event, context, callback) => {
89
+
90
+ try {
91
+
92
+ let recordPromises = [];
93
+
94
+ // loop each record and send to mainFunction
95
+ await Promise.all(event.Records.map(async record => { // promise.all for map() function
96
+
97
+ let passOnProperties = []
98
+ record._izContext.logger.debug('record ReceiveMsgOutHdrSqs', record);
99
+
100
+ // validate message (and MessageAttributes)
101
+ await recordHandlerSharedLib.validateRecord(
102
+ record, // one record will send to mainFunction
103
+ "PaginateProcessLogicalHdrSqs", // queue name that need to retry or send to dlq
104
+ perRecordsValidatorSchema, // schema for record.Message
105
+ // messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
106
+ );
107
+
108
+ // add argument (to invoke lambda) to passOnProperties[]
109
+ passOnProperties.push(record.body.Message.logicalResultId)
110
+ passOnProperties.push(record.body.Message.tableName)
111
+ passOnProperties.push(record.body.Message.partitionKeyFieldName)
112
+ passOnProperties.push(record.body.Message.sortKeyFieldName)
113
+ passOnProperties.push(record.body.Message.comparison)
114
+ passOnProperties.push(record.body.Message.startKey)
115
+ passOnProperties.push(record.body.Message.overwriteUniqueRequestId)
116
+ passOnProperties.push(record.body.Message.callingFlow)
117
+ record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
118
+
119
+ // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
120
+ let recordPromise = recordHandlerSharedLib.recordHandler(
121
+ record, // one record will send to mainFunction
122
+ paginateProcessLogical.paginateProcessLogical, // mainFunction that need to invoke.
123
+ "PaginateProcessLogicalHdrSqs", // queue name that need to retry or send to dlq
124
+ passOnProperties, // all parameters that mainFunction needed.
125
+ );
126
+ record._izContext.logger.debug('after recordPromise in handler');
127
+ recordPromises.push(recordPromise); // push promise to recordPromises
128
+ }))
129
+
130
+ Logger.debug('before Promise.all(recordPromises) in handler');
131
+ try {
132
+ // --- main await all promises
133
+ await Promise.all(recordPromises); // await all promises
134
+
135
+ return event.Records // return all for local testing
136
+
137
+ } catch {
138
+ Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did no resolve)');
139
+ }
140
+ Logger.debug('after Promise.all(recordPromises) in handler');
141
+
142
+ } catch (err) {
143
+ Logger.error('Unhandled Error, PaginateProcessLogicalHdrSqs: ', err);
144
+ throw (err);
145
+ }
146
+ });
@@ -0,0 +1,48 @@
1
+ /*
2
+ Copyright (C) 2020 Sven Mason <http://izara.io>
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Affero General Public License as
6
+ published by the Free Software Foundation, either version 3 of the
7
+ License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Affero General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Affero General Public License
15
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ 'use strict';
19
+
20
+ const path = require('path');
21
+ const { SOURCE_PATH, FUNCTION_NAME, HANDLER } = require("../../libs/Consts");
22
+ const { firstLetterUpperCase: upperCase } = require('../../../../MainLibs/src/Utils');
23
+ const templatePath = path.join(__dirname, "./template.ejs");
24
+
25
+
26
+ /**
27
+ * receive srcPath
28
+ * not create data for ProcessLogical Main template
29
+ *
30
+ * @param {Object} srcPath
31
+ * @return {{ templatePath, templateData, setting } }
32
+ */
33
+
34
+ function data(_izContext, srcPath) {
35
+
36
+ return {
37
+ templatePath: templatePath,
38
+ templateData: {},
39
+ setting: {
40
+ savePath: path.join(srcPath, SOURCE_PATH.processLogical),
41
+ saveFileName: `${upperCase(FUNCTION_NAME.paginateProcessLogical)}_Main`,
42
+ fileExtension: '.js',
43
+ isAppend: false
44
+ }
45
+ }
46
+ }
47
+
48
+ module.exports = data;
@@ -0,0 +1,212 @@
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 izaraShared = require('@izara_project/izara-shared');
21
+ const dynamodbSharedLib = izaraShared.dynamodbSharedLib;
22
+ const logicalResultsSharedLib = izaraShared.logicalResultsSharedLib;
23
+ const asyncFlowSharedLib = izaraShared.asyncFlowSharedLib;
24
+ const sqsSharedLib = izaraShared.sqsSharedLib;
25
+
26
+ const sqs = require('@izara_project/izara-core-library-external-request').sqs;
27
+
28
+ const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError;
29
+
30
+ // set query limit
31
+ const limit = 2;
32
+
33
+ /**
34
+ * performs the logical operation/filter/search in the element, saves into LogicalResultsData table
35
+ * @param {Object} _izContext
36
+ * @param {string} logicalResultId
37
+ * @param {string} tableName
38
+ * @param {string} partitionKeyFieldName
39
+ * @param {string} sortKeyFieldName
40
+ * @param {string} comparison
41
+ * @param {Object} startKey
42
+ * @param {string} overwriteUniqueRequestId
43
+ * @param {string} callingFlow
44
+ *
45
+ * @returns {string} description of return value
46
+ */
47
+
48
+ module.exports.paginateProcessLogical = async (
49
+ _izContext,
50
+ logicalResultId,
51
+ tableName,
52
+ partitionKeyFieldName,
53
+ sortKeyFieldName,
54
+ comparison, // optional
55
+ startKey, // optional
56
+ overwriteUniqueRequestId, // optional
57
+ callingFlow // optional
58
+ ) => {
59
+
60
+ try {
61
+
62
+ _izContext.logger.debug('----- PaginateProcessLogical event params -----', {
63
+ logicalResultId: logicalResultId,
64
+ tableName: tableName,
65
+ partitionKeyFieldName: partitionKeyFieldName,
66
+ sortKeyFieldName: sortKeyFieldName,
67
+ comparison: comparison,
68
+ startKey: startKey,
69
+ overwriteUniqueRequestId: overwriteUniqueRequestId,
70
+ callingFlow: callingFlow
71
+ });
72
+
73
+ // Check/Create logicalResultsMain
74
+ let [checkUniqueRequestProcessingStatus, logicalResultsMain] = await asyncFlowSharedLib.checkUniqueRequestProcessing(
75
+ _izContext,
76
+ "LogicalResultsMain",
77
+ {
78
+ logicalResultId: logicalResultId
79
+ },
80
+ "paginateProcessLogical",
81
+ overwriteUniqueRequestId
82
+ );
83
+ _izContext.logger.debug("After check uniqueRequestProcessingStatus:", {
84
+ checkUniqueRequestProcessingStatus: checkUniqueRequestProcessingStatus,
85
+ logicalResultsMain: logicalResultsMain
86
+ });
87
+
88
+ if (checkUniqueRequestProcessingStatus == "stop") {
89
+ return;
90
+ } else if (checkUniqueRequestProcessingStatus == "recordNotFound") {
91
+ // should always have unless another request already completed it, in which case nothing to do
92
+ return;
93
+ }
94
+
95
+ let errorsFound = [];
96
+ let standardErrorParams = [
97
+ _izContext,
98
+ logicalResultId,
99
+ logicalResultsMain.logicalElement,
100
+ logicalResultsMain.objType,
101
+ "error"
102
+ ];
103
+
104
+ const partitionKeyValue = logicalResultsMain.logicalElement.partitionKey;
105
+ let queryElements = {
106
+ limit: limit
107
+ };
108
+
109
+ //if received startKey validate it, if not received will return null
110
+ startKey = asyncFlowSharedLib.validateStartKeyParam(
111
+ _izContext,
112
+ startKey,
113
+ partitionKeyFieldName,
114
+ sortKeyFieldName
115
+ );
116
+
117
+ if (startKey === false) {
118
+ throw new NoRetryError("split processing received invalid startKey");
119
+ }
120
+ _izContext.logger.debug("startKey :", startKey);
121
+
122
+ if (startKey) {
123
+ queryElements["exclusiveStartKey"] = {
124
+ [partitionKeyFieldName]: startKey[partitionKeyFieldName],
125
+ [sortKeyFieldName]: startKey[sortKeyFieldName]
126
+ }
127
+ };
128
+
129
+
130
+ if (comparison) {
131
+ const sortKeyValue = logicalResultsMain.logicalElement.sortKey;
132
+
133
+ queryElements["sortKeyCondition"] = {
134
+ comparison: comparison,
135
+ name: sortKeyFieldName,
136
+ value: sortKeyValue
137
+ };
138
+ }
139
+
140
+ let queryDatas = await dynamodbSharedLib.query(
141
+ _izContext,
142
+ await dynamodbSharedLib.tableName(_izContext, tableName),
143
+ {
144
+ [partitionKeyFieldName]: partitionKeyValue
145
+ },
146
+ queryElements
147
+ )
148
+ _izContext.logger.debug("queryDatas result: ", queryDatas)
149
+
150
+ if (!startKey && queryDatas.Items.length == 0) {
151
+ _izContext.logger.debug(`can't find data in table ${tableName} by query`)
152
+ errorsFound.push(`can't find data in table ${tableName} by query`)
153
+ standardErrorParams.push(errorsFound)
154
+ await logicalResultsSharedLib.completeLogicalResultsMain(...standardErrorParams);
155
+ return;
156
+ }
157
+
158
+ for (const objInstanceBase of queryDatas.Items) {
159
+
160
+ await logicalResultsSharedLib.saveLogicalData(
161
+ _izContext,
162
+ logicalResultId,
163
+ logicalResultsMain.objType,
164
+ objInstanceBase
165
+ )
166
+ }
167
+
168
+ if (queryDatas.hasOwnProperty("LastEvaluatedKey")) {
169
+
170
+ if (!overwriteUniqueRequestId) {
171
+ overwriteUniqueRequestId = _izContext.uniqueRequestId
172
+ };
173
+
174
+ let continuePaginationMsg = {
175
+ MessageBody: JSON.stringify({
176
+ logicalResultId: logicalResultId,
177
+ tableName: tableName,
178
+ partitionKeyFieldName: partitionKeyFieldName,
179
+ sortKeyFieldName: sortKeyFieldName,
180
+ comparison: comparison,
181
+ overwriteUniqueRequestId: overwriteUniqueRequestId,
182
+ startKey: queryDatas.LastEvaluatedKey,
183
+ callingFlow: callingFlow
184
+ }),
185
+ QueueUrl: await sqsSharedLib.sqsQueueUrl(_izContext, "PaginateProcessLogicalHdrDsq"),
186
+ };
187
+
188
+ _izContext.logger.debug("continuePaginationMessage: ", continuePaginationMsg);
189
+ await sqs.sendMessage(_izContext, continuePaginationMsg).promise();
190
+
191
+ return "Continue PaginateProcessLogical"
192
+
193
+ } else {
194
+
195
+ await logicalResultsSharedLib.completeLogicalResultsMain(
196
+ _izContext,
197
+ logicalResultId,
198
+ logicalResultsMain.logicalElement,
199
+ logicalResultsMain.objType,
200
+ "complete",
201
+ [],
202
+ callingFlow
203
+ )
204
+ }
205
+
206
+ return "Function PaginateProcessLogical is Finished"
207
+
208
+ } catch (err) {
209
+ _izContext.logger.error('error PaginateProcessLogicalMain: ', err);
210
+ throw (err)
211
+ }
212
+ }
@@ -40,7 +40,7 @@ module.exports.createSourceDataObjectSchema = (_izContext, objectSchema, saveFil
40
40
 
41
41
 
42
42
  const dynamoDbMainYamlDataList = dynamoDbMainYaml.dynamoDbMainYamlFromObjectSchema.templateDataFunction(_izContext, objectSchema);
43
- console.log("dynamoDbMainYamlDataList: ", dynamoDbMainYamlDataList);
43
+ // console.log("dynamoDbMainYamlDataList: ", dynamoDbMainYamlDataList);
44
44
 
45
45
  for (let dynamoDbMainYamlData of dynamoDbMainYamlDataList) {
46
46
  // create iam role of handler here
@@ -57,7 +57,7 @@ module.exports.createSourceDataObjectSchema = (_izContext, objectSchema, saveFil
57
57
  });
58
58
  }
59
59
 
60
- console.log("resultsForCreateSource: ", resultsForCreateSource);
60
+ // console.log("resultsForCreateSource: ", resultsForCreateSource);
61
61
 
62
62
  return resultsForCreateSource;
63
63
  }
@@ -30,7 +30,7 @@ const STORAGE_TYPES = {
30
30
  graph: "graph"
31
31
  }
32
32
  const templatePath = path.join(__dirname, './template.ejs')
33
- const { SOURCE_PATH } = require('../../libs/Consts');
33
+ const { SOURCE_PATH, SAVE_FILE_NAME } = require('../../libs/Consts');
34
34
 
35
35
  /**
36
36
  * create param of crateSouce for FindData And processLogical
@@ -39,7 +39,7 @@ const { SOURCE_PATH } = require('../../libs/Consts');
39
39
  * @param {String} srcPath
40
40
  * @returns {Object[]}
41
41
  */
42
- module.exports.createAwaitingMultipleStepDynamoDbData = (_izContext, srcPath) => {
42
+ const createAwaitingMultipleStepDynamoDbData = (_izContext, srcPath) => {
43
43
 
44
44
  let resultsForCreateSource = [];
45
45
 
@@ -76,8 +76,6 @@ module.exports.createAwaitingMultipleStepDynamoDbData = (_izContext, srcPath) =>
76
76
  }
77
77
  ];
78
78
 
79
- // console.log("defaultlDynamoDataList: ", (awaitingStepDynamoDbDataList));
80
-
81
79
  for (let defaultlDynamoData of awaitingStepDynamoDbDataList) {
82
80
  resultsForCreateSource.push({
83
81
  templatePath: templatePath,
@@ -85,14 +83,13 @@ module.exports.createAwaitingMultipleStepDynamoDbData = (_izContext, srcPath) =>
85
83
  setting: {
86
84
  initialData: 'Resources:\n',
87
85
  savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
88
- saveFileName: 'generated-dynamoDB-table',
86
+ saveFileName: SAVE_FILE_NAME.dynamoDbYaml,
89
87
  fileExtension: '.yml',
90
88
  isAppend: true
91
89
  }
92
90
  });
93
91
  }
94
-
95
- // console.log("resultForCreateDefaultDynamoDb: ", (resultsForCreateSource));
96
-
97
92
  return resultsForCreateSource;
98
93
  }
94
+
95
+ module.exports = createAwaitingMultipleStepDynamoDbData
@@ -31,7 +31,7 @@ const STORAGE_TYPES = {
31
31
  graph: "graph"
32
32
  }
33
33
 
34
- const { SOURCE_PATH } = require('../../libs/Consts')
34
+ const { SOURCE_PATH, SAVE_FILE_NAME } = require('../../libs/Consts')
35
35
  const templatePath = path.join(__dirname, './template.ejs')
36
36
 
37
37
  // ---------- End Per Lambda Handler IamRole Data ----------
@@ -85,7 +85,6 @@ function dataForMainDynamoDbYamlFromObjectSchema(_izContext, objectSchema, srcPa
85
85
  }
86
86
  }
87
87
 
88
- // console.log("identifierDetail :", identifierDetail)
89
88
  if (!identifierDetail.hasOwnProperty("partitionKey")) {
90
89
  return []
91
90
  }
@@ -123,51 +122,30 @@ function dataForMainDynamoDbYamlFromObjectSchema(_izContext, objectSchema, srcPa
123
122
  return dynamoDbYamlTempleteData
124
123
  }
125
124
 
126
-
127
- // data for MainDynamo from RelSchema
128
- // function dataForMainDynamoDbYamlFromRelSchema(_izContext, relSchema) {
129
- // let relTag = Object.keys(relSchema)[0];
130
- // let relData = relSchema[relTag];
131
-
132
- // for (let parents of relData.parents) {
133
- // let parentObjectType = parent.objType.objectType;
134
-
135
-
136
- // }
137
-
138
- // return
139
- // }
140
-
141
-
142
- module.exports.createSourceDataDynamoDB = (_izContext, objectSchema, srcPath) => {
125
+ const createSourceDataDynamoDB = (_izContext, objectSchema, srcPath) => {
143
126
 
144
127
  let resultsForCreateSource = [];
145
128
 
146
129
 
147
130
  const dynamoDbMainYamlDataList = dataForMainDynamoDbYamlFromObjectSchema(_izContext, objectSchema, srcPath)
148
- // console.log("dynamoDbMainYamlDataList: ", dynamoDbMainYamlDataList);
149
131
 
150
132
  for (let dynamoDbMainYamlData of dynamoDbMainYamlDataList) {
151
- // create iam role of handler here
152
133
  resultsForCreateSource.push({
153
134
  templatePath: templatePath,
154
135
  templateData: dynamoDbMainYamlData,
155
136
  setting: {
156
137
  initialData: 'Resources:\n',
157
138
  savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
158
- saveFileName: 'generated-dynamoDB-table',
139
+ saveFileName: SAVE_FILE_NAME.dynamoDbYaml,
159
140
  fileExtension: '.yml',
160
141
  isAppend: true
161
142
  }
162
143
  });
163
144
  }
164
145
 
165
- // console.log("resultsForCreateSource: ", resultsForCreateSource);
166
146
 
167
147
  return resultsForCreateSource;
168
148
  }
169
149
 
170
- // module.exports.createSourceDataRelSchema = (_izContext, relSchema, saveFilePath) => {
171
150
 
172
- // return []
173
- // }
151
+ module.exports = createSourceDataDynamoDB
@@ -30,7 +30,7 @@ const STORAGE_TYPES = {
30
30
  graph: "graph"
31
31
  }
32
32
  const templatePath = path.join(__dirname, './template.ejs')
33
- const { SOURCE_PATH } = require('../../libs/Consts');
33
+ const { SOURCE_PATH, SAVE_FILE_NAME } = require('../../libs/Consts');
34
34
 
35
35
  /**
36
36
  * create param of crateSouce for FindData And processLogical
@@ -39,13 +39,13 @@ const { SOURCE_PATH } = require('../../libs/Consts');
39
39
  * @param {String} srcPath
40
40
  * @returns {Object[]}
41
41
  */
42
- module.exports.createDefaultSourceDataDynamoDB = (_izContext, srcPath) => {
42
+ const createDefaultSourceDataDynamoDB = (_izContext, srcPath) => {
43
43
 
44
44
  let resultsForCreateSource = [];
45
45
 
46
46
  const defaultDynamoDataList = [
47
47
  {
48
- "tableName": "FindData",
48
+ "tableName": "FindDataMain",
49
49
  "attributes": [
50
50
  {
51
51
  "keyType": "partitionKey",
@@ -74,15 +74,13 @@ module.exports.createDefaultSourceDataDynamoDB = (_izContext, srcPath) => {
74
74
  },
75
75
  {
76
76
  "keyType": "sortKey",
77
- "AttributeName": "dataId",
77
+ "AttributeName": "identifiersId",
78
78
  "AttributeType": "S"
79
79
  }
80
80
  ]
81
81
  }
82
82
  ];
83
83
 
84
- // console.log("defaultlDynamoDataList: ", (defaultDynamoDataList));
85
-
86
84
  for (let defaultlDynamoData of defaultDynamoDataList) {
87
85
  resultsForCreateSource.push({
88
86
  templatePath: templatePath,
@@ -90,14 +88,12 @@ module.exports.createDefaultSourceDataDynamoDB = (_izContext, srcPath) => {
90
88
  setting: {
91
89
  initialData: 'Resources:\n',
92
90
  savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
93
- saveFileName: 'generated-dynamoDB-table',
91
+ saveFileName: SAVE_FILE_NAME.dynamoDbYaml,
94
92
  fileExtension: '.yml',
95
93
  isAppend: true
96
94
  }
97
95
  });
98
96
  }
99
-
100
- // console.log("resultForCreateDefaultDynamoDb: ", (resultsForCreateSource));
101
-
102
97
  return resultsForCreateSource;
103
98
  }
99
+ module.exports = createDefaultSourceDataDynamoDB