@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-market-library-service-schemas",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "description": "Schemas for Izara Market project",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -48,19 +48,21 @@ const TOPIC_NAME_GENERATE_CODE = {
48
48
  createRelComplete: "CreateRelationshipComplete",
49
49
  deleteRelComplete: "DeleteRelationshipComplete",
50
50
  getRelComplete: "GetRelationshipComplete",
51
- outUpdateRelComplete: "OutUpdateRelationshipComplete",
52
- outCreateRelComplete: "OutCreateRelationshipComplete",
53
- outDeleteRelComplete: "OutDeleteRelationshipComplete",
54
- outGetRelComplete: "OutGetRelationshipComplete",
51
+ outUpdateRelComplete: "UpdateRelationshipComplete_Out",
52
+ outCreateRelComplete: "CreateRelationshipComplete_Out",
53
+ outDeleteRelComplete: "DeleteRelationshipComplete_Out",
54
+ outGetRelComplete: "GetRelationshipComplete_Out",
55
55
  updateNodeComplete: "UpdateNodeComplete",
56
- outUpdateNodeComplete: "OutUpdateNodeComplete",
56
+ outUpdateNodeComplete: "UpdateNodeComplete_Out",
57
57
  createNodeComplete: "CreateObjectComplete",
58
- outCreateNodeComplete: "OutCreateObjectComplete",
58
+ outCreateNodeComplete: "CreateObjectComplete_Out",
59
59
  deleteNodeComplete: "DeleteNodeComplete",
60
- outDeleteNodeComplete: "OutDeleteNodeComplete",
60
+ outDeleteNodeComplete: "DeleteNodeComplete_Out",
61
61
  getNodeComplete: "GetNodeComplete",
62
- outGetNodeComplete: "OutGetNodeComplete",
63
- reservedLimitComplete: "ReservedLimitComplete"
62
+ outGetNodeComplete: "GetNodeComplete_Out",
63
+ reservedLimitComplete: "ReservedLimitComplete",
64
+ createPresignUrl: "CreatePresignUrl",
65
+ flowSchemaOwnTopicComplete: "FlowSchemaOwnTopicComplete"
64
66
  }
65
67
 
66
68
  const GRAPH_HANDLER_SERVICE_NAME = {
@@ -19,21 +19,14 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
19
19
 
20
20
  const lodash = require('lodash');
21
21
  const hash = require("object-hash")
22
-
23
22
  const snsSharedLib = require('@izara_project/izara-core-library-sns');
24
23
  const sqsSharedLib = require('@izara_project/izara-core-library-sqs');
25
24
  const inMemoryCacheLib = require('@izara_project/izara-core-library-core').inMemoryCacheLib;
26
25
  const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
27
-
28
26
  const sns = require('@izara_project/izara-core-library-external-request/src/resources/Sns');
29
27
  const sqs = require('@izara_project/izara-core-library-external-request/src/resources/Sqs');
30
-
31
28
  const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
32
- const { validateObject } = require('@izara_project/izara-core-library-core/src/Validator');
33
-
34
-
35
29
  const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
36
- // const serviceSchemas = require('./ServiceSchemas');
37
30
  const validatorSchema = require('@izara_project/izara-core-library-service-schemas/src/ValidatorSchema');
38
31
  const serviceConfig = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig');
39
32
  const utils = require('@izara_project/izara-core-library-service-schemas/src/Utils');
@@ -47,8 +40,8 @@ const Logger = require("@izara_project/izara-core-library-logger");
47
40
 
48
41
  const nodeLabelRegexPattern = "^[a-zA-Z0-9_-]+(?:\:[a-zA-Z0-9_-]+)?$"
49
42
  const { validateObjType } = require('@izara_project/izara-shared-service-schemas').validateObjType;
50
-
51
-
43
+ // const { validateObject } = require('@izara_project/izara-core-library-core').validator
44
+ const { validateObject } = require("@izara_project/izara-core-library-core").validator
52
45
 
53
46
  const schemaFunctionPerAction = {
54
47
  [consts.ACTIONS.create]: validatorSchema.generateValidatorSchemaForCreate,
@@ -77,23 +70,23 @@ const explodeDataPerAction = {
77
70
  */
78
71
  function validateSchemaMiddleware(
79
72
  middleware,
80
- objectType,
73
+ // objectType,
81
74
  action,
82
- setting = {}
75
+ // setting = {}
83
76
  ) {
84
77
 
85
78
  if (!schemaFunctionPerAction[action] || !explodeDataPerAction[action]) {
86
79
  throw new NoRetryError(`Not found function for generateValidatorSchema or explodeDataPerAction of action:${action}`);
87
80
  }
88
- Logger.debug("setting in generateCodeLibs", setting)
81
+ // Logger.debug("setting in generateCodeLibs", setting)
89
82
  middleware.setServiceSchema(
90
83
  schemaFunctionPerAction[action],
91
84
  explodeDataPerAction[action],
92
- {
93
- objectType: objectType,
94
- specificFieldNames: setting?.specificFieldNames ? setting.specificFieldNames : [],
95
- action: action
96
- },
85
+ // {
86
+ // objectType: objectType,
87
+ // specificFieldNames: setting?.specificFieldNames ? setting.specificFieldNames : [],
88
+ // action: action
89
+ // },
97
90
  );
98
91
  }
99
92
 
@@ -112,14 +105,15 @@ async function validateSchemaPerRecord(
112
105
  record,
113
106
  lambdaFunctionName,
114
107
  objType,
115
- action, // action
108
+ action,
116
109
  setting
117
110
  ) {
118
111
  try {
119
- record._izContext.logger.debug("validateSchemaPerRecord: ", record,
112
+ record._izContext.logger.debug("validateSchemaPerRecord: ",
113
+ record,
120
114
  lambdaFunctionName,
121
115
  objType,
122
- action, // action
116
+ action,
123
117
  setting
124
118
  )
125
119
 
@@ -129,6 +123,10 @@ async function validateSchemaPerRecord(
129
123
 
130
124
  const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(record._izContext, objType);
131
125
 
126
+ if (!objectSchema) {
127
+ throw new Error("not have objectSchema in service");
128
+ }
129
+
132
130
  const generateValidatorFunction = schemaFunctionPerAction[action];
133
131
  const explodeDataFunction = explodeDataPerAction[action]
134
132
 
@@ -147,7 +145,7 @@ async function validateSchemaPerRecord(
147
145
  record._izContext.logger.debug('explodedDataRequestParams in validateSchemaPerRecord : ', JSON.stringify(explodedDataRequestParams));
148
146
 
149
147
 
150
- let validateStatus = validateObject(record._izContext, generatedSchema, explodedDataRequestParams);
148
+ let validateStatus = validateObject(generatedSchema, explodedDataRequestParams);
151
149
  record._izContext.logger.debug('validateStatus : ', validateStatus);
152
150
 
153
151
  // if not pass validate will sent messsage to dlq and throw NoRetryError
@@ -187,6 +185,40 @@ async function validationForWebSocket(
187
185
 
188
186
 
189
187
  }
188
+
189
+ /**
190
+ *
191
+ * @param {middleware} middleware
192
+ * @param {string} objectType - name of ObjectType
193
+ * @param {string} action - action type of Lambda create | update | get | delete
194
+ */
195
+ function validatorSchemaMiddlewareByAction(
196
+ middleware,
197
+ // objectType,
198
+ action,
199
+ setting = {}
200
+ ) {
201
+
202
+ // if (!schemaFunctionPerAction[action] || !explodeDataPerAction[action]) {
203
+ // throw new NoRetryError(`Not found function for generateValidatorSchema or explodeDataPerAction of action:${action}`);
204
+ // }
205
+ console.log("before send to middleware", {
206
+ middleware,
207
+ // objectType,
208
+ action,
209
+ setting
210
+ })
211
+ Logger.debug("setting in generateCodeLibs", setting)
212
+ middleware.setServiceSchema(
213
+ // schemaFunctionPerAction[action],
214
+ // explodeDataPerAction[action],
215
+ {
216
+ // objectType: objectType,
217
+ specificFieldNames: setting?.specificFieldNames ? setting.specificFieldNames : [],
218
+ action: action
219
+ },
220
+ );
221
+ }
190
222
  // /**
191
223
  // * use to validate record for Lambda handler hdrSqs/hdrDsq
192
224
  // * Note!: cannot throw error when use this function outside recordHandler
@@ -1032,6 +1064,7 @@ module.exports = {
1032
1064
 
1033
1065
  validateSchemaMiddleware,
1034
1066
  validateSchemaPerRecord,
1067
+ validatorSchemaMiddlewareByAction,
1035
1068
 
1036
1069
  createGetDataDetails,
1037
1070
  collectGetData,
@@ -55,7 +55,7 @@ function resourceNames(resourceClass, resourceName) {
55
55
  [RESOURCE_CLASSES.sqs]: "arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}" + resourceName,
56
56
  [RESOURCE_CLASSES.s3]: "arn:aws:s3:::" + resourceName,
57
57
  [RESOURCE_CLASSES.dynamoDbTable]: "arn:aws:dynamodb:${self:custom.iz_region}:${self:custom.iz_accountId}:table/${self:custom.iz_resourcePrefix}" + resourceName,
58
- [RESOURCE_CLASSES.sns]: "arn:aws:sns:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}" + resourceName,
58
+ [RESOURCE_CLASSES.sns]: "arn:aws:sns:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_serviceTag}_${self:custom.iz_stage}_" + resourceName,
59
59
  [RESOURCE_CLASSES.lambda]: "arn:aws:lambda:${self:custom.iz_region}:${self:custom.iz_accountId}:function:${self:custom.iz_resourcePrefix}" + resourceName,
60
60
  [RESOURCE_CLASSES.webSocket]: "arn:aws:execute-api:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_webSocketHostId}/Test/POST/@connections/{connectionId}"
61
61
  }[resourceClass];
@@ -111,18 +111,23 @@ const SOURCE_PATH = {
111
111
  translateIdsRequestFile: '../src/generatedCode/TranslateId/source/',
112
112
  processLogical: "../src/generatedCode/ProcessLogical/source/",
113
113
  resourceLocationPerAction: 'src/generatedCode/ObjectTypePerActionEndpoint/source/',
114
- resourceLocationFindData: 'src/generatedCode/FindData/source',
114
+ resourceLocationFindData: 'src/generatedCode/FindData/source/',
115
+ resourceLocationFindData: 'src/generatedCode/FindData/source/',
115
116
  resourceLocationRelationshipPerAction: 'src/generatedCode/RelationshipPerAction/source/',
116
117
  resourceLocationTranslateId: 'src/generatedCode/TranslateId/source/',
117
118
  resourceLocationProcessLogical: "src/generatedCode/ProcessLogical/source/",
118
- webSocket: "../src/generatedCode/FlowSchema/source/",
119
- resourceLocationWebSocket: "src/generatedCode/FlowSchema/source/",
119
+ webSocket: "../src/generatedCode/FlowSchema/UploadS3/",
120
+ resourceLocationWebSocket: "src/generatedCode/FlowSchema/UploadS3/",
121
+ flowSchemaOwnTopic: "../src/generatedCode/FlowSchema/FlowSchemaOwnTopic/",
122
+ resourceLocationFlowSchemaOwnTopic: "src/generatedCode/flowSchemaOwnTopic/UploadS3/",
120
123
  generateCodeLib: "../src/generatedCode/libs/source/",
121
124
  logicalFunctionHook: "../src/generatedCode/WebSocket/source/FlowSchemaHook/HookLogicFunction/source/",
122
125
  resourceLocationLogicalFunctionHook: "src/generatedCode/WebSocket/source/FlowSchemaHook/HookLogicFunction/source",
123
126
  generatedCodeHookFunction: "../src/generatedCode/WebSocket/source/FlowSchemaHook/HookFunctionGeneratedCode/source/",
124
127
  resourceLocationGeneratedCodeHookFunction: "src/generatedCode/WebSocket/source/FlowSchemaHook/HookFunctionGeneratedCode/source/",
125
- generatedAttributeTree: "../src/schemas/generatedCode/source/"
128
+ generatedAttributeTree: "../src/schemas/generatedCode/source/",
129
+ endpointPerService: "../src/generatedCode/ActionEndpoint/source/",
130
+ resourceLocationHandlerEndpointPerService: "src/generatedCode/ActionEndpoint/source/"
126
131
  };
127
132
 
128
133
  const DEFAULT_LAMBDA_ROLE_PER_ACTION = {
@@ -221,7 +226,7 @@ const SAVE_FILE_NAME = {
221
226
  sharedResourceYaml: "generate-SharedResource",
222
227
  attributeTreeObjectRelationship: "ObjectRelationships",
223
228
  attributeTreeRefObjectRelationship: "RefObjectRelationships",
224
- attributeTreeObjectSchema: "ObjectFieldSchema"
229
+ attributeTreeObjectSchema: "ObjectFieldSchema",
225
230
  };
226
231
 
227
232
  const FUNCTION_NAME = {
@@ -246,7 +251,11 @@ const FUNCTION_NAME = {
246
251
  createObjectS3Complete: "webSocketTaskComplete",
247
252
  processAfterUploadS3: "processAfterUploadS3",
248
253
  getRel: "getRelationship",
249
- getRelComplete: "getRelationshipComplete"
254
+ getRelComplete: "getRelationshipComplete",
255
+ reservedLimit: "reservedLimit",
256
+ createPresignUrl: "createPresignUrl",
257
+ flowSchemaOwnTopic: "flowSchemaOwnTopic",
258
+ flowSchemaOwnTopicComplete: "flowSchemaOwnTopicComplete"
250
259
  };
251
260
 
252
261
  const SHORT_FUNCTION_NAME = {
@@ -318,15 +327,6 @@ function defaultIamRolePerAction() {
318
327
  return defaultIamRole
319
328
  };
320
329
 
321
- function getComplexFilterServiceTag(allObjectSchemas) {
322
- const complexFilterServiceTagSet = new Set();
323
- for (let objectSchema of allObjectSchemas) {
324
- complexFilterServiceTagSet.add(objectSchema.complexFilterServiceTag)
325
- }
326
- let complexFilterServiceTags = [...complexFilterServiceTagSet];
327
- return complexFilterServiceTags
328
- };
329
-
330
330
  async function getGraphServiceNameFromObjectSchema(_izContext, allObjSchemas) {
331
331
  const graphServiceName = new Set();
332
332
  for (const objectSchema of allObjSchemas) {
@@ -338,7 +338,6 @@ async function getGraphServiceNameFromObjectSchema(_izContext, allObjSchemas) {
338
338
  }
339
339
  }
340
340
  let graphServiceNames = [...graphServiceName]
341
- // console.log("graphServiceName", graphServiceNames)
342
341
  return graphServiceNames
343
342
  };
344
343
 
@@ -371,7 +370,10 @@ const SOURCE_GENERATE_IAM_ROLE = {
371
370
  NodeCompleteRole: "NodeCom",
372
371
  RelationshipRole: "Relationship",
373
372
  RelationshipCompleteRole: "RelationshipCom",
374
- FlowSchemaUploadS3Role: "FlowSchemaUploadS3"
373
+ FlowSchemaUploadS3Role: "FlowSchemaUploadS3",
374
+ FlowSchemaOwnTopic: "FlowSchemaOwnTopic",
375
+ FlowSchemaOwnTopic: "FlowSchemaOwnTopic",
376
+ perActionEndpoint: "PerActionEndpoint"
375
377
  };
376
378
 
377
379
  const ADD_ON_DATA_STRUCTURE_TYPE = {
@@ -475,6 +477,7 @@ function checkDynamoTypeRelationship(relationship) {
475
477
  }
476
478
  return [storageType, relaitonshipTag, links];
477
479
  }
480
+
478
481
  function createDynamoDbComponentByLinks(link, relationshipTag) {
479
482
  let tableNameFrom = `${link.from.objType.serviceTag}_${link.from.objType.objectType}__${relationshipTag}__${link.to.objType.serviceTag}_${link.to.objType.objectType}`
480
483
  let tableNameTo = `${link.to.objType.serviceTag}_${link.to.objType.objectType}__${relationshipTag}__${link.from.objType.serviceTag}_${link.from.objType.objectType}`
@@ -494,6 +497,26 @@ function createDynamoDbComponentByLinks(link, relationshipTag) {
494
497
  }
495
498
  }
496
499
 
500
+ async function getStorageResourceFromObjectSchemas(_izContext, allObjSchemas) {
501
+ if (Array.isArray(allObjSchemas)) {
502
+ allObjSchemas = [allObjSchemas]
503
+ }
504
+ let resourceGraphServiceTag = new Set();
505
+ let resourceDynamoTableName = new Set();
506
+ for (const objectSchema of allObjSchemas.records) {
507
+ for (const storageResource of Object.values(objectSchema.storageResources)) {
508
+ if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
509
+ resourceDynamoTableName.add(storageResource.tableName);
510
+ } else if (storageResource.storageType === STORAGE_TYPES.graph) {
511
+ let graphServiceTag = await getGraphServiceTagWithCache(_izContext, storageResource.graphServerTag);
512
+ resourceGraphServiceTag.add(graphServiceTag);
513
+ }
514
+ }
515
+ }
516
+
517
+ return { resourceGraphServiceTag: [...resourceGraphServiceTag], resourceDynamoTableName: [...resourceDynamoTableName] }
518
+ }
519
+
497
520
  module.exports = {
498
521
  ACTIONS,
499
522
  DEFAULT_HANDLER_PER_ACTION,
@@ -513,7 +536,6 @@ module.exports = {
513
536
  FUNCTION_NAME,
514
537
  getGraphServiceNameFromAllRelSchema,
515
538
  defaultIamRolePerAction,
516
- getComplexFilterServiceTag,
517
539
  getGraphServiceNameFromObjectSchema,
518
540
  awaitingMultipleStepsRole,
519
541
  shortNameHandler,
@@ -526,5 +548,6 @@ module.exports = {
526
548
  ATTRIBUTE_TAG,
527
549
  PREFIX_RELATIONSHIP,
528
550
  checkDynamoTypeRelationship,
529
- createDynamoDbComponentByLinks
551
+ createDynamoDbComponentByLinks,
552
+ getStorageResourceFromObjectSchemas
530
553
  }
@@ -28,7 +28,7 @@ const templateConfig = require("./TemplateConfig");
28
28
  const { deleteFileInDir, createHookFunction } = require("../SourceManager/src/Utils");
29
29
  const { createSource } = require("../SourceManager/src/CreateSource");
30
30
 
31
- const { SOURCE_PATH } = require('../TemplateManager/src/libs/Consts');
31
+ const { SOURCE_PATH } = require('../MainLibs/src/Consts');
32
32
 
33
33
  //* get functionNameConfig
34
34
  const functionNameConfigYamlData = require('./TemplateData/externalService/functionNameConfig/data');
@@ -53,6 +53,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
53
53
  relationshipPerAction: join(saveFilePath, SOURCE_PATH.relationshipPerAction),
54
54
  webSocketEndpoint: join(saveFilePath, SOURCE_PATH.webSocket),
55
55
  generateCodeLib: join(saveFilePath, SOURCE_PATH.generateCodeLib),
56
+ generatedMainFunctionPerService: join(saveFilePath, SOURCE_PATH.endpointPerService),
56
57
  };
57
58
 
58
59
  //------ Start Create Source ------
@@ -21,7 +21,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
21
21
  module.exports = {
22
22
  TemplateAndData: {
23
23
  // ** PerActionEndpoint **
24
- perActionEndpoint: './TemplateData/perActionEndpoint/generateTemplateData.js',
24
+ // perActionEndpoint: './TemplateData/perActionEndpoint/generateTemplateData.js',
25
+
25
26
  // ** perActionComplete **
26
27
  perActionComplete: './TemplateData/perActionComplete/generateTemplateData.js',
27
28
  // ** Resource YAML **
@@ -44,6 +45,9 @@ module.exports = {
44
45
 
45
46
  // ** flowSchema **
46
47
  flowSchema: './TemplateData/flowSchema/generateTemplateData.js',
48
+
49
+ // ** endpoint per service **
50
+ endpointPerServiceConfig: './TemplateData/EndpointPerService/generateTemplateData.js'
47
51
  },
48
52
  Plugin: {
49
53
 
@@ -0,0 +1,108 @@
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 { join } = require('path');
21
+ const {
22
+ getAllLocalObjectSchemasWithHierarchy
23
+ } = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
24
+ const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
25
+ // Import handlers and generators
26
+ const modules = {
27
+ handlers: {
28
+ inv: require("./handler/inv/data"),
29
+ api: require("./handler/api/data"),
30
+ sqs: require("./handler/sqs/data"),
31
+ dsq: require("./handler/dsq/data")
32
+ },
33
+ mainFunctions: {
34
+ create: require("./mainFunction/create/data"),
35
+ update: require("./mainFunction/update/data"),
36
+ get: require('./mainFunction/get/data'),
37
+ delete: require('./mainFunction/delete/data')
38
+ },
39
+ // yamlGenerators: {
40
+ // inv: require('./yaml/inv/data'),
41
+ // api: require('./yaml/api/data'),
42
+ // sqs: require('./yaml/sqs/data'),
43
+ // dsq: require('./yaml/dsq/data')
44
+ // },
45
+ yamlGenerators: {
46
+ yaml: require('./yaml/data')
47
+ }
48
+ };
49
+
50
+ // Import code libs generator
51
+ // const createGenerateCodeLibs = require('./libs/data');
52
+
53
+ /**
54
+ * Generates code from templates based on object schemas
55
+ * @param {Object} _izContext - Context object
56
+ * @param {string} objSchemaPath - Path to object schema
57
+ * @returns {Promise<Array>} - Array of parameter objects for code generation
58
+ */
59
+ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
60
+ try {
61
+ const saveFilePath = join(objSchemaPath, `../`);
62
+ const allObjSchemas = await getAllLocalObjectSchemasWithHierarchy(_izContext, objSchemaPath);
63
+
64
+ const createSourceParams = [];
65
+
66
+ for (const objectSchema of allObjSchemas.records) {
67
+ try {
68
+ // Generate handlers
69
+ const handlerParams = Object.entries(modules.handlers)
70
+ .flatMap(([type, handlerFn]) => handlerFn(_izContext, saveFilePath));
71
+
72
+ // Generate main functions
73
+ const functionParams = (await Promise.all(
74
+ Object.entries(modules.mainFunctions).map(([action, functionFn]) =>
75
+ functionFn(_izContext, saveFilePath)
76
+ )
77
+ )).flat();
78
+
79
+
80
+
81
+ // Generate code libs
82
+ // const libsParam = createGenerateCodeLibs(_izContext, saveFilePath);
83
+
84
+ createSourceParams.push(...handlerParams, ...functionParams);
85
+ } catch (error) {
86
+ _izContext.logger.error(`Error processing schema ${objectSchema.name || 'unknown'}: ${error}`);
87
+ throw new NoRetryError(error)
88
+ }
89
+ }
90
+ try {
91
+ // Generate function YAML files
92
+ const yamlParams = (await Promise.all(
93
+ Object.entries(modules.yamlGenerators)
94
+ .map(([type, yamlFn]) => yamlFn(_izContext, allObjSchemas, saveFilePath))
95
+ )).flat();
96
+ createSourceParams.push(...yamlParams);
97
+
98
+ } catch (error) {
99
+ _izContext.logger.error(`Error processing schema yaml ${error}`);
100
+ }
101
+ return createSourceParams;
102
+ } catch (error) {
103
+ _izContext.logger.error('Error generating code with template endpointPerService:', error);
104
+ return [];
105
+ }
106
+ }
107
+
108
+ module.exports = generateCodeWithTemplate;
@@ -0,0 +1,76 @@
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, SOURCE_GENERATE_IAM_ROLE } = require("../../../../../MainLibs/src/Consts.js");
33
+
34
+ const templatePath = path.join(__dirname, "./template.ejs")
35
+
36
+ /**
37
+ * receive objectSchema
38
+ * create data for hdrApi template
39
+ *
40
+ * @param {Object} objectSchema
41
+ * @return {{ templatePath, templateData, setting } }
42
+ */
43
+ function data(_izContext, srcPath) {
44
+ let createSourceArray = [];
45
+ for (const action of Object.values(ACTIONS)) {
46
+ const defaultHandlers = DEFAULT_HANDLER_PER_ACTION[action]
47
+ for (const defaultHandler of defaultHandlers) {
48
+ if (defaultHandler === HANDLER.hdrApi) {
49
+ const createSourceParam = createParamForCreateSource(action, defaultHandler, srcPath)
50
+ createSourceParam && createSourceArray.push(createSourceParam)
51
+ }
52
+ }
53
+ }
54
+ // console.log("createSourceArray::", JSON.stringify(createSourceArray, null, 2))
55
+ return createSourceArray;
56
+ }
57
+
58
+
59
+ function createParamForCreateSource(action, handler, srcPath) {
60
+ return {
61
+ templatePath: templatePath,
62
+ templateData: {
63
+ roleName: SOURCE_GENERATE_IAM_ROLE.perActionEndpoint,
64
+ action: action,
65
+ handler
66
+ },
67
+ setting: {
68
+ savePath: path.join(srcPath, SOURCE_PATH.endpointPerService),
69
+ saveFileName: `${upperCase(action)}_${upperCase(handler)}`,
70
+ fileExtension: '.js',
71
+ isAppend: false
72
+ }
73
+ }
74
+ }
75
+
76
+ 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
+ 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 {
23
+ validatorSchemaMiddlewareByAction
24
+ } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
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
+ validatorSchemaMiddlewareByAction(
33
+ middleware,
34
+ "<%- action %>"
35
+ //(<validateSchemaSetting>
36
+ //</validateSchemaSetting>)
37
+ )
38
+ // if need to validate authorizer or additional params , add code to hook tag below
39
+
40
+ //(<afterValidateWith>)
41
+ //(</afterValidateWith>)
42
+
43
+
44
+ module.exports.main = middleware.wrap(async (event, context, callback) => {
45
+ event._izContext.logger.debug('Event:', event);
46
+ try {
47
+ // invoke LambdaFunction
48
+ let lambdaFunctionResponse = await <%- action %>Main(
49
+ event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId/userId
50
+ event,
51
+ callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
52
+
53
+ );
54
+
55
+ // return error to client
56
+ if (lambdaFunctionResponse instanceof Error) {
57
+ return (izara.response.failure(lambdaFunctionResponse));
58
+ }
59
+
60
+ // return success to client
61
+ return (izara.response.success(lambdaFunctionResponse));
62
+
63
+ } catch (err) {
64
+ event._izContext.logger.error('Error, <%- firstLetterUpperCase(action) %>_<%- firstLetterUpperCase(handler) %>: ', err);
65
+ return (izara.response.failure(err));
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
+ } _%>