@izara_project/izara-market-library-service-schemas 1.0.29 → 1.0.31

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 (170) hide show
  1. package/package.json +1 -1
  2. package/src/GenerateCodeLibs/src/Consts.js +11 -9
  3. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +54 -21
  4. package/src/MainLibs/src/Consts.js +43 -20
  5. package/src/reStructure/GenerateCode.js +2 -1
  6. package/src/reStructure/TemplateConfig.js +5 -1
  7. package/src/reStructure/TemplateData/EndpointPerService/generateTemplateData.js +108 -0
  8. package/src/reStructure/TemplateData/EndpointPerService/handler/api/data.js +76 -0
  9. package/src/reStructure/TemplateData/EndpointPerService/handler/api/request.json +7 -0
  10. package/src/reStructure/TemplateData/EndpointPerService/handler/api/template.ejs +73 -0
  11. package/src/reStructure/TemplateData/EndpointPerService/handler/dsq/data.js +81 -0
  12. package/src/reStructure/TemplateData/EndpointPerService/handler/dsq/request.json +7 -0
  13. package/src/reStructure/TemplateData/EndpointPerService/handler/dsq/template.ejs +125 -0
  14. package/src/reStructure/TemplateData/EndpointPerService/handler/inv/data.js +70 -0
  15. package/src/reStructure/TemplateData/EndpointPerService/handler/inv/request.json +7 -0
  16. package/src/reStructure/TemplateData/EndpointPerService/handler/inv/template.ejs +73 -0
  17. package/src/reStructure/TemplateData/EndpointPerService/handler/sqs/data.js +79 -0
  18. package/src/reStructure/TemplateData/EndpointPerService/handler/sqs/request.json +7 -0
  19. package/src/reStructure/TemplateData/EndpointPerService/handler/sqs/template.ejs +126 -0
  20. package/src/reStructure/TemplateData/{flowSchema/components/schema/inProcess/handler → EndpointPerService/mainFunction/create}/data.js +20 -13
  21. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +624 -0
  22. package/src/reStructure/TemplateData/{flowSchema/components/schema/inProcess/mainFunction → EndpointPerService/mainFunction/delete}/data.js +18 -11
  23. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +176 -0
  24. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/data.js +56 -0
  25. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +234 -0
  26. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/data.js +56 -0
  27. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +330 -0
  28. package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +177 -0
  29. package/src/reStructure/TemplateData/EndpointPerService/yaml/template.ejs +26 -0
  30. package/src/reStructure/TemplateData/externalService/generateTemplateData.js +1 -1
  31. package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +91 -249
  32. package/src/reStructure/TemplateData/externalService/lambdaRole/template.ejs +1 -1
  33. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +10 -8
  34. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/template.ejs +1 -1
  35. package/src/reStructure/TemplateData/findData/findDataYaml/data.js +2 -2
  36. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/functionYaml/data.js +8 -7
  37. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/handler/data.js +4 -4
  38. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/data.js +2 -2
  39. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/functionYaml/data.js +5 -31
  40. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/data.js +4 -22
  41. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/template.ejs +3 -31
  42. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/data.js +1 -1
  43. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/functionYaml/data.js +6 -6
  44. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/handler/data.js +4 -4
  45. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/mainFunction/data.js +4 -4
  46. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/sns-sqs/data.js +1 -1
  47. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/sns-sqs/template.ejs +1 -1
  48. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{getSignUrls → createPresignUrl}/functionYaml/data.js +45 -14
  49. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{getSignUrls → createPresignUrl}/functionYaml/template.ejs +3 -0
  50. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{getSignUrls → createPresignUrl}/handler/data.js +6 -6
  51. package/src/reStructure/TemplateData/flowSchema/{legacy/hookCode-old/handler/templateAsyncHandler.ejs → components/upload/preSignUrl/createPresignUrl/handler/template.ejs} +26 -11
  52. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{getSignUrls → createPresignUrl}/mainFunction/data.js +11 -8
  53. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +253 -0
  54. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{reservedLimit → createPresignUrl}/queue/data.js +1 -1
  55. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/data.js +14 -42
  56. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/template.ejs +0 -3
  57. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/handler/data.js +6 -6
  58. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/handler/template.ejs +40 -45
  59. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/data.js +5 -8
  60. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +100 -190
  61. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{getSignUrls → reservedLimit}/sqs/data.js +4 -4
  62. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{getSignUrls → reservedLimit}/sqs/template.ejs +2 -2
  63. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrS3/data.js +9 -7
  64. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/handler/handlerS3/data.js +4 -4
  65. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/mainFunction/data.js +4 -4
  66. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/queue/s3Template.ejs +1 -1
  67. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/S3/data.js +5 -2
  68. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +3 -3
  69. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/template.ejs +2 -0
  70. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/data.js +3 -2
  71. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/template.ejs +4 -16
  72. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchema/functionYaml/data.js +115 -0
  73. package/src/reStructure/TemplateData/flowSchema/{components/schema/inProcess → flowSchemaOwnTopic/flowSchema}/functionYaml/template.ejs +1 -20
  74. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchema/handler/data.js +70 -0
  75. package/src/reStructure/TemplateData/flowSchema/{components/schema/inProcess → flowSchemaOwnTopic/flowSchema}/handler/template.ejs +14 -32
  76. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchema/mainFunction/data.js +64 -0
  77. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchema/mainFunction/template.ejs +104 -0
  78. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchemaComplete/functionYaml/data.js +115 -0
  79. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchemaComplete/functionYaml/template.ejs +20 -0
  80. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchemaComplete/handler/data.js +71 -0
  81. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchemaComplete/handler/template.ejs +85 -0
  82. package/src/reStructure/TemplateData/flowSchema/{components/upload/hook/hookLogic → flowSchemaOwnTopic/flowSchemaComplete/mainFunction}/data.js +30 -10
  83. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchemaComplete/mainFunction/template.ejs +105 -0
  84. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +78 -55
  85. package/src/reStructure/TemplateData/generateRole/createSharedResource.js +21 -1
  86. package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +35 -44
  87. package/src/reStructure/TemplateData/perActionComplete/create/sns-out/template.ejs +1 -1
  88. package/src/reStructure/TemplateData/perActionComplete/create/yaml/data.js +4 -5
  89. package/src/reStructure/TemplateData/perActionComplete/delete/yaml/data.js +5 -4
  90. package/src/reStructure/TemplateData/perActionComplete/generateTemplateData.js +15 -2
  91. package/src/reStructure/TemplateData/perActionComplete/get/yaml/data.js +7 -4
  92. package/src/reStructure/TemplateData/perActionComplete/update/sns-out/data.js +1 -1
  93. package/src/reStructure/TemplateData/perActionComplete/update/yaml/data.js +5 -4
  94. package/src/reStructure/TemplateData/processLogical/yaml/data.js +3 -3
  95. package/src/reStructure/TemplateData/processLogicalPagination/yaml/dsq/data.js +1 -1
  96. package/src/reStructure/TemplateData/processLogicalPagination/yaml/sqs/data.js +2 -2
  97. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/api/data.js +1 -1
  98. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/dsq/data.js +1 -1
  99. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/inv/data.js +1 -1
  100. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/sqs/data.js +3 -3
  101. package/src/reStructure/TemplateData/relationshipPerAction/create/action/sns-in-sqs/snsTemplate.ejs +1 -1
  102. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/functionYaml/data.js +2 -2
  103. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/data.js +1 -1
  104. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/sns-in-sqs/template.ejs +0 -1
  105. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/sns-out/template.ejs +1 -1
  106. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/api/data.js +1 -1
  107. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/dsq/data.js +1 -1
  108. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/inv/data.js +1 -1
  109. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/sqs/data.js +3 -3
  110. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/sns-in-sqs/snsTemplate.ejs +1 -1
  111. package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/functionYaml/data.js +2 -2
  112. package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/sns-out/template.ejs +1 -1
  113. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/api/data.js +1 -1
  114. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/data.js +1 -1
  115. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/inv/data.js +1 -1
  116. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/sqs/data.js +4 -4
  117. package/src/reStructure/TemplateData/relationshipPerAction/get/action/sns-in-sqs/snsTemplate.ejs +1 -1
  118. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/data.js +2 -2
  119. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/sns-out/template.ejs +1 -1
  120. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/api/data.js +1 -1
  121. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/dsq/data.js +1 -1
  122. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/inv/data.js +1 -1
  123. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/sqs/data.js +4 -4
  124. package/src/reStructure/TemplateData/relationshipPerAction/update/action/sns-in-sqs/snsTemplate.ejs +1 -1
  125. package/src/reStructure/TemplateData/relationshipPerAction/update/complete/functionYaml/data.js +2 -2
  126. package/src/reStructure/TemplateData/relationshipPerAction/update/complete/sns-out/template.ejs +1 -1
  127. package/src/reStructure/TemplateData/resourceYaml/dynamodb/defaultDynamoDbTable.js +1 -1
  128. package/src/reStructure/TemplateData/resourceYaml/dynamodb/generateDynamoPerLink.js +1 -1
  129. package/src/reStructure/TemplateData/resourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +1 -1
  130. package/src/reStructure/TemplateData/resourceYaml/generateTemplateData.js +6 -12
  131. package/src/reStructure/TemplateData/resourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical.js +1 -1
  132. package/src/reStructure/TemplateData/resourceYaml/sns-in-sqs/snsAndSqsPerActionData.js +22 -49
  133. package/src/reStructure/TemplateData/resourceYaml/sns-in-sqs/snsTemplate.ejs +1 -1
  134. package/src/reStructure/TemplateData/resourceYaml/sns-out/data.js +8 -24
  135. package/src/reStructure/TemplateData/resourceYaml/sns-out/template.ejs +1 -1
  136. package/src/reStructure/TemplateData/testTemplate/template.ejs +0 -5
  137. package/src/reStructure/TemplateData/flowSchema/components/schema/inProcess/functionYaml/data.js +0 -76
  138. package/src/reStructure/TemplateData/flowSchema/components/schema/inProcess/sns-sqs/data.js +0 -35
  139. package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/functionYaml/data.js +0 -34
  140. package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/functionYaml/template.ejs +0 -0
  141. package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/handler/data.js +0 -34
  142. package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/handler/template.ejs +0 -0
  143. package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/mainFunction/data.js +0 -34
  144. package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/mainFunction/template.ejs +0 -0
  145. package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/sns-sqs/data.js +0 -34
  146. package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/sns-sqs/template.ejs +0 -0
  147. package/src/reStructure/TemplateData/flowSchema/components/upload/hook/handler/data.js +0 -93
  148. package/src/reStructure/TemplateData/flowSchema/components/upload/hook/handler/templateAsyncHandler.ejs +0 -110
  149. package/src/reStructure/TemplateData/flowSchema/components/upload/hook/handler/templateSyncHandler.ejs +0 -49
  150. package/src/reStructure/TemplateData/flowSchema/components/upload/hook/mainFunction/data.js +0 -65
  151. package/src/reStructure/TemplateData/flowSchema/components/upload/hook/mainFunction/template.ejs +0 -7
  152. package/src/reStructure/TemplateData/flowSchema/components/upload/hook/queue/data.js +0 -72
  153. package/src/reStructure/TemplateData/flowSchema/components/upload/hook/queue/snsTemplate.ejs +0 -59
  154. package/src/reStructure/TemplateData/flowSchema/components/upload/hook/queue/sqsTemplate.ejs +0 -43
  155. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/getSignUrls/handler/template.ejs +0 -120
  156. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/getSignUrls/mainFunction/template.ejs +0 -163
  157. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/functionYaml/data.js +0 -101
  158. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/functionYaml/template.ejs +0 -43
  159. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/handler/data.js +0 -93
  160. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/handler/templateSyncHandler.ejs +0 -49
  161. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/hookLogic/data.js +0 -64
  162. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/mainFunction/data.js +0 -66
  163. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/mainFunction/template.ejs +0 -30
  164. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/queue/data.js +0 -124
  165. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/queue/snsTemplate.ejs +0 -59
  166. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/queue/sqsTemplate.ejs +0 -43
  167. package/src/reStructure/TemplateData/relationshipPerAction.zip +0 -0
  168. /package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{reservedLimit → createPresignUrl}/queue/template.ejs +0 -0
  169. /package/src/reStructure/TemplateData/flowSchema/{components/schema/inProcess/mainFunction/template.ejs → flowSchemaOwnTopic/sns-in/data.js} +0 -0
  170. /package/src/reStructure/TemplateData/flowSchema/{components/schema/inProcess/sns-sqs/template.ejs → flowSchemaOwnTopic/sns-out/data.js} +0 -0
@@ -0,0 +1,81 @@
1
+ /*
2
+ Copyright (C) 2020 Sven Mason <http://izara.io>
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Affero General Public License as
6
+ published by the Free Software Foundation, either version 3 of the
7
+ License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Affero General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Affero General Public License
15
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ 'use strict';
19
+
20
+ const path = require('path');
21
+
22
+ const { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
23
+ const { SOURCE_GENERATE_IAM_ROLE } = require('../../../../../MainLibs/src/Consts.js');
24
+
25
+
26
+ // const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase, checkOverWriteGenerateMainFunction } = require("../#utils");
27
+ // const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH } = require("../#const");
28
+ const {
29
+ firstLetterLowerCase: lowerCase,
30
+ firstLetterUpperCase: upperCase,
31
+ firstLetterUpperCase,
32
+ checkOverWriteGenerateMainFunction
33
+ } = require("../../../../../MainLibs/index.js").utils;
34
+ const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH } = require("../../../../../MainLibs/src/Consts.js");
35
+
36
+
37
+ const templatePath = path.join(__dirname, "./template.ejs")
38
+
39
+ /**
40
+ * receive objectSchema
41
+ * create data for hdrInv template
42
+ *
43
+ * @param {Object} objectSchema
44
+ * @return {{ templatePath, templateData, setting } }
45
+ */
46
+ function data(_izContext, srcPath) {
47
+ let createSourceArray = [];
48
+ for (const action of Object.values(ACTIONS)) {
49
+ const defaultHandlers = DEFAULT_HANDLER_PER_ACTION[action]
50
+ for (const defaultHandler of defaultHandlers) {
51
+ if (defaultHandler === HANDLER.hdrDsq) {
52
+ const createSourceParam = createParamForCreateSource(action, defaultHandler, srcPath)
53
+ createSourceParam && createSourceArray.push(createSourceParam)
54
+ }
55
+ }
56
+ }
57
+ return createSourceArray;
58
+ }
59
+
60
+
61
+ function createParamForCreateSource(action, handler, srcPath) {
62
+ let queueName = firstLetterUpperCase(action) + upperCase(handler);
63
+ return {
64
+ templatePath: templatePath,
65
+ templateData: {
66
+ roleName: SOURCE_GENERATE_IAM_ROLE.perActionEndpoint,
67
+ queueName,
68
+ action,
69
+ handler
70
+ },
71
+ setting: {
72
+ savePath: path.join(srcPath, SOURCE_PATH.endpointPerService),
73
+ saveFileName: `${upperCase(action)}_${upperCase(handler)}`,
74
+ fileExtension: '.js',
75
+ isAppend: false
76
+ }
77
+ }
78
+ }
79
+
80
+
81
+ module.exports = data;
@@ -0,0 +1,7 @@
1
+ {
2
+ "objectType": "objectType",
3
+ "action": "get",
4
+ "mainFunction": "xxx",
5
+ "mainFunctionFile": "directoryOfMainFunction",
6
+ "isCreateMainByDev": "boolean"
7
+ }
@@ -0,0 +1,125 @@
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-core-library-calling-flow');
22
+ const Logger = require('@izara_project/izara-core-library-logger');
23
+ const {validateSchemaPerRecord} = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs')
24
+ const recordHandlerSharedLib = require('@izara_project/izara-core-library-record-handler');
25
+
26
+ const { <%- action %>Main } =require('./<%- firstLetterUpperCase(action) %>_Main.js')
27
+
28
+ //(<globalVarible>
29
+ //</globalVarible>)
30
+
31
+ //validate event params in middleware before into main function
32
+ middleware.setValidatorSchema(
33
+ recordHandlerSharedLib.baseValidatorSchema(),
34
+ //(<middlewareSettings>)
35
+ //(</middlewareSettings>)
36
+ )
37
+
38
+ /*
39
+ const perRecordsValidatorSchema = {
40
+ type: "object",
41
+ required: [],
42
+ properties: {},
43
+ }
44
+ */
45
+
46
+ //(<globalValidatorSchema>)
47
+ //(</globalValidatorSchema>)
48
+
49
+ // if need to validate authorizer or additional params , add code to hook tag below
50
+
51
+ module.exports.main = middleware.wrap(async (event,context, callback) => {
52
+
53
+ try {
54
+
55
+ let recordPromises = [];
56
+
57
+ await Promise.all(event.Records.map(async record => {
58
+ record._izContext.logger.debug('record RecieveMsgOutHdrSqs', record);
59
+
60
+ let passOnProperties = [];
61
+
62
+ const OBJTYPE = {
63
+ objectType: record.body.Message.objectType,
64
+ serviceTag: process.env.iz_serviceTag
65
+ }
66
+
67
+
68
+ await validateSchemaPerRecord(
69
+ record,
70
+ "<%- firstLetterUpperCase(action) %><%- firstLetterUpperCase(handler) %>",
71
+ OBJTYPE,
72
+ "<%- action %>"
73
+ //(<validateSchemaSetting>)
74
+ //(</validateSchemaSetting>)
75
+ )
76
+
77
+ //for validate additional params
78
+ /*
79
+ await recordHandlerSharedLib.validateRecord(
80
+ record,
81
+ "<%- firstLetterUpperCase(action) %><%- firstLetterUpperCase(handler) %>",
82
+ perRecordsValidatorSchema
83
+ );
84
+ */
85
+ //(<afterGenerateValidatorSchema>)
86
+ //(</afterGenerateValidatorSchema>)
87
+
88
+ //(<additionalParams>)
89
+ //(</additionalParams>)
90
+
91
+ passOnProperties.push(record.body.Message);
92
+ passOnProperties.push(OBJTYPE);
93
+ passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
94
+ record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
95
+
96
+ let recordPromise = recordHandlerSharedLib.recordHandler(
97
+ record,
98
+ <%- action %>Main, // mainFunction
99
+ '<%- firstLetterUpperCase(queueName) %>', // queueName
100
+ passOnProperties
101
+ );
102
+ record._izContext.logger.debug('after record Promise in handler');
103
+ recordPromises.push(recordPromise);
104
+ }))
105
+
106
+ Logger.debug('before Promise.all(recordPromise) in handler');
107
+ try {
108
+ await Promise.all(recordPromises);
109
+
110
+ return event.Records
111
+ } catch {
112
+ Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did no resolve)');
113
+ }
114
+ Logger.debug('after Promise.all(recordPromises) in handler');
115
+
116
+ } catch (err) {
117
+ Logger.debug('unhandled error <%- firstLetterUpperCase(action) %><%- firstLetterUpperCase(handler) %>')
118
+ throw err
119
+ }
120
+ }
121
+ )
122
+
123
+ <%_ function firstLetterUpperCase(text){
124
+ return text.charAt(0).toUpperCase() + text.slice(1)
125
+ } _%>
@@ -0,0 +1,70 @@
1
+ /*
2
+ Copyright (C) 2020 Sven Mason <http://izara.io>
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Affero General Public License as
6
+ published by the Free Software Foundation, either version 3 of the
7
+ License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Affero General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Affero General Public License
15
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ 'use strict';
19
+
20
+ const path = require('path');
21
+
22
+ const { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
23
+
24
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/index.js").utils;
25
+ const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH, FUNCTION_NAME, SOURCE_GENERATE_IAM_ROLE } = require("../../../../../MainLibs/src/Consts.js");
26
+
27
+ const templatePath = path.join(__dirname, "./template.ejs")
28
+ /**
29
+ * receive objectSchema
30
+ * create data for hdrInv template
31
+ *
32
+ * @param {Object} objectSchema
33
+ * @return {{ templatePath, templateData, setting } }
34
+ */
35
+ function data(_izContext, srcPath) {
36
+ let createSourceArray = [];
37
+
38
+ for (const action of Object.values(ACTIONS)) {
39
+ const defaultHandlers = DEFAULT_HANDLER_PER_ACTION[action]
40
+ for (const defaultHandler of defaultHandlers) {
41
+ if (defaultHandler === HANDLER.hdrInv) {
42
+ const createSourceParam = createParamForCreateSource(action, defaultHandler, srcPath)
43
+ createSourceParam && createSourceArray.push(createSourceParam)
44
+ }
45
+ }
46
+ }
47
+ // console.log("createSourceArrayInHdrInv", createSourceArray)
48
+ return createSourceArray;
49
+ }
50
+
51
+
52
+ function createParamForCreateSource(action, handler, srcPath) {
53
+ return {
54
+ templatePath: templatePath,
55
+ templateData: {
56
+ roleName: SOURCE_GENERATE_IAM_ROLE.perActionEndpoint,
57
+ action: action,
58
+ handler
59
+ },
60
+ setting: {
61
+ savePath: path.join(srcPath, SOURCE_PATH.endpointPerService),
62
+ saveFileName: `${upperCase(action)}_${upperCase(handler)}`,
63
+ fileExtension: '.js',
64
+ isAppend: false
65
+ }
66
+ }
67
+ }
68
+
69
+
70
+ module.exports = data;
@@ -0,0 +1,7 @@
1
+ {
2
+ "objectType": "objectType",
3
+ "action": "get",
4
+ "mainFunction": "xxx",
5
+ "mainFunctionFile": "directoryOfMainFunction",
6
+ "isCreateMainByDev": "boolean"
7
+ }
@@ -0,0 +1,73 @@
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 middleware = require("@izara_project/izara-middleware/src/MiddlewareCore/MiddlewareHandler");
21
+
22
+ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
23
+ const {
24
+ validatorSchemaMiddlewareByAction
25
+ } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
26
+
27
+ const { <%- action %>Main } =require('./<%- firstLetterUpperCase(action) %>_Main.js')
28
+
29
+ //(<globalVariable>
30
+ //</globalVariable>)
31
+
32
+
33
+ //validate event params in middleware before into main function
34
+ validatorSchemaMiddlewareByAction(
35
+ middleware,
36
+ "<%- action %>"
37
+ //(<validateSchemaSetting>
38
+ //</validateSchemaSetting>)
39
+ )
40
+ // if need to validate authorizer or additional params, add code to hook tag below
41
+
42
+ //(<afterValidateWithGenereatedSchema>)
43
+ //(</afterValidateWithGenereatedSchema>)
44
+
45
+
46
+ module.exports.main = middleware.wrap(async (event, context, callback) => {
47
+ event._izContext.logger.debug('Event:', event);
48
+ event._izContext.logger.debug('context:', context);
49
+
50
+ try {
51
+
52
+ //(<beforeInvoke>)
53
+ //(</beforeInvoke>)
54
+
55
+ // invoke LambdaFunction
56
+ return await <%- action %>Main(
57
+ event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId
58
+ event,
59
+ callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
60
+ );
61
+
62
+ } catch (err) {
63
+ event._izContext.logger.error('Error, <%- firstLetterUpperCase(action) %>_<%- firstLetterUpperCase(handler) %>: ', err);
64
+ throw (err);
65
+ }
66
+ });
67
+
68
+ <%_ function firstLetterUpperCase(text){
69
+ return text.charAt(0).toUpperCase() + text.slice(1)
70
+ } _%>
71
+ <%_ function firstLetterLowerCase(str) {
72
+ return str.charAt(0).toLowerCase() + str.slice(1)
73
+ } _%>
@@ -0,0 +1,79 @@
1
+ /*
2
+ Copyright (C) 2020 Sven Mason <http://izara.io>
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Affero General Public License as
6
+ published by the Free Software Foundation, either version 3 of the
7
+ License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Affero General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Affero General Public License
15
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ 'use strict';
19
+
20
+ const path = require('path');
21
+
22
+ const { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
23
+
24
+ // const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase, checkOverWriteGenerateMainFunction } = require("../#utils");
25
+ // const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH } = require("../#const");
26
+ const {
27
+ firstLetterLowerCase: lowerCase,
28
+ firstLetterUpperCase: upperCase,
29
+ firstLetterUpperCase,
30
+ checkOverWriteGenerateMainFunction
31
+ } = require("../../../../../MainLibs/index.js").utils;
32
+ const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH } = require("../../../../../MainLibs/src/Consts.js");
33
+
34
+ const templatePath = path.join(__dirname, "./template.ejs")
35
+
36
+ /**
37
+ * receive objectSchema
38
+ * create data for hdrInv template
39
+ *
40
+ * @param {Object} objectSchema
41
+ * @return {{ templatePath, templateData, setting } }
42
+ */
43
+ function data(_izContext, srcPath) {
44
+ let createSourceArray = [];
45
+
46
+ for (const action of Object.values(ACTIONS)) {
47
+ const defaultHandlers = DEFAULT_HANDLER_PER_ACTION[action]
48
+ for (const defaultHandler of defaultHandlers) {
49
+ if (defaultHandler === HANDLER.hdrSqs) {
50
+ const createSourceParam = createParamForCreateSource(action, defaultHandler, srcPath)
51
+ createSourceParam && createSourceArray.push(createSourceParam)
52
+ }
53
+ }
54
+ }
55
+
56
+ // console.log("createSourceArray in sqsData :", createSourceArray)
57
+ return createSourceArray;
58
+ }
59
+
60
+
61
+ function createParamForCreateSource(action, handler, srcPath) {
62
+ let queueName = upperCase(action) + upperCase(handler);
63
+ return {
64
+ templatePath: templatePath,
65
+ templateData: {
66
+ queueName,
67
+ action,
68
+ handler
69
+ },
70
+ setting: {
71
+ savePath: path.join(srcPath, SOURCE_PATH.endpointPerService),
72
+ saveFileName: `${upperCase(action)}_${upperCase(handler)}`,
73
+ fileExtension: '.js',
74
+ isAppend: false
75
+ }
76
+ }
77
+ }
78
+
79
+ module.exports = data;
@@ -0,0 +1,7 @@
1
+ {
2
+ "objectType": "objectType",
3
+ "action": "get",
4
+ "mainFunction": "xxx",
5
+ "mainFunctionFile": "directoryOfMainFunction",
6
+ "isCreateMainByDev": "boolean"
7
+ }
@@ -0,0 +1,126 @@
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-core-library-calling-flow');
22
+ const Logger = require('@izara_project/izara-core-library-logger');
23
+ const {validateSchemaPerRecord} = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs')
24
+ const recordHandlerSharedLib = require('@izara_project/izara-core-library-record-handler');
25
+
26
+ const { <%- action %>Main } =require('./<%- firstLetterUpperCase(action) %>_Main.js')
27
+
28
+ //(<globalVarible>
29
+ //</globalVarible>)
30
+
31
+ //validate event params in middleware before into main function
32
+ middleware.setValidatorSchema(
33
+ recordHandlerSharedLib.baseValidatorSchema(),
34
+ //(<middlewareSettings>)
35
+ //(</middlewareSettings>)
36
+ )
37
+ /*
38
+ const perRecordsValidatorSchema = {
39
+ type: "object",
40
+ required: [],
41
+ properties: {},
42
+ }
43
+ */
44
+ //(<globalValidatorSchema>)
45
+ //(</globalValidatorSchema>)
46
+
47
+ // if need to validate authorizer or additional params , add code to hook tag below
48
+
49
+ module.exports.main = middleware.wrap(async (event,context, callback) => {
50
+
51
+ try {
52
+
53
+ let recordPromises = [];
54
+
55
+ await Promise.all(event.Records.map(async record => {
56
+ record._izContext.logger.debug('record RecieveMsgOutHdrSqs', record);
57
+
58
+ let passOnProperties = [];
59
+
60
+ const OBJTYPE = {
61
+ objectType: record.body.Message.objectType,
62
+ serviceTag: process.env.iz_serviceTag
63
+ }
64
+
65
+ await validateSchemaPerRecord(
66
+ record,
67
+ "<%- firstLetterUpperCase(action) %><%- firstLetterUpperCase(handler) %>",
68
+ OBJTYPE,
69
+ "<%- action %>"
70
+ //(<validateSchemaSetting>)
71
+ //(</validateSchemaSetting>)
72
+ )
73
+
74
+ //for validate additional params
75
+ /*
76
+ await recordHandlerSharedLib.validateRecord(
77
+ record,
78
+ "<%- firstLetterUpperCase(action) %><%- firstLetterUpperCase(handler) %>",
79
+ perRecordsValidatorSchema
80
+ );
81
+ */
82
+ //(<afterGenerateValidatorSchema>)
83
+ //(</afterGenerateValidatorSchema>)
84
+
85
+ //(<additionalParams>)
86
+ //(</additionalParams>)
87
+
88
+ passOnProperties.push(record.body.Message);
89
+ passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
90
+ record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
91
+
92
+ let recordPromise = recordHandlerSharedLib.recordHandler(
93
+ record,
94
+ <%- action %>Main, // mainFunction
95
+ '<%- firstLetterUpperCase(queueName) %>', // queueName
96
+ passOnProperties
97
+ );
98
+ record._izContext.logger.debug('after record Promise in handler');
99
+ recordPromises.push(recordPromise);
100
+ }))
101
+
102
+ Logger.debug('before Promise.all(recordPromise) in handler');
103
+ try {
104
+ await Promise.all(recordPromises);
105
+
106
+ return event.Records
107
+ } catch {
108
+ Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did no resolve)');
109
+ }
110
+ Logger.debug('after Promise.all(recordPromises) in handler');
111
+
112
+ } catch (err) {
113
+ Logger.debug('unhandled error <%- firstLetterUpperCase(action) %><%- firstLetterUpperCase(handler) %>')
114
+ throw err
115
+ }
116
+ }
117
+ )
118
+
119
+
120
+
121
+ <%_ function firstLetterUpperCase(text){
122
+ return text.charAt(0).toUpperCase() + text.slice(1)
123
+ } _%>
124
+ <%_ function firstLetterLowerCase(str) {
125
+ return str.charAt(0).toLowerCase() + str.slice(1)
126
+ } _%>
@@ -16,31 +16,38 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
 
18
18
  'use strict';
19
+
19
20
  const path = require('path');
20
21
 
21
- const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils");
22
- const { SOURCE_PATH } = require('../../../../libs/Consts');
23
- const templatePath = path.join(__dirname, './template.ejs')
22
+ const { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
23
+
24
+ const {
25
+ firstLetterLowerCase: lowerCase,
26
+ firstLetterUpperCase: upperCase,
27
+ } = require("../../../../../MainLibs/index.js").utils;
28
+ const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH } = require("../../../../../MainLibs/src/Consts.js");
29
+
30
+ const templatePath = path.join(__dirname, "./template.ejs")
24
31
 
25
32
  function data(_izContext, srcPath) {
26
- return [createSourceParams(_izContext, srcPath)]
33
+ return [createSource(_izContext, srcPath)]
27
34
  }
28
35
 
29
- function createSourceParams(_izContext, srcPath) {
30
- let functionName = "InProcessWebSocket";
31
- let handlerType = "HdrWbs";
36
+ function createSource(_izContext, srcPath) {
37
+ let functionName = upperCase(ACTIONS.create)
32
38
 
33
39
  return {
34
40
  templatePath: templatePath,
35
- templateData: {},
41
+ templateData: {
42
+ functionName,
43
+ },
36
44
  setting: {
37
- savePath: path.join(srcPath, SOURCE_PATH.webSocket),
38
- saveFileName: upperCase(functionName) + upperCase(handlerType),
45
+ savePath: path.join(srcPath, SOURCE_PATH.endpointPerService),
46
+ saveFileName: `${upperCase(functionName)}_Main`,
39
47
  fileExtension: ".js",
40
- isAppend: true
48
+ isAppend: false
41
49
  }
42
50
  }
43
51
  }
44
52
 
45
-
46
- module.exports = data;
53
+ module.exports = data