@izara_project/izara-core-generate-service-code 1.0.53 → 1.0.54

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 (141) hide show
  1. package/package.json +1 -2
  2. package/src/codeGenerators/app/initial_setup/InitialSetupGenerator.js +1 -1
  3. package/src/codeGenerators/app/sls_yaml/FindDataYamlGenerator.js +23 -0
  4. package/src/codeGenerators/app/sls_yaml/FunctionYamlGenerator.js +1 -1
  5. package/src/codeGenerators/app/sls_yaml/ProcessLogicalYamlGenerator.js +11 -25
  6. package/src/codeGenerators/app/sls_yaml/RoleNameConfigGenerator.js +1 -1
  7. package/src/codeGenerators/app/sls_yaml/SharedResourceYamlGenerator.js +3 -3
  8. package/src/codeGenerators/app/sls_yaml/renderYamlTemplate.js +13 -0
  9. package/src/codeGenerators/app/sls_yaml/templates/SharedResource_Yaml.ejs +6 -2
  10. package/src/codeGenerators/app/src/generatedCode/FindData/FindDataGenerator.js +10 -44
  11. package/src/codeGenerators/app/src/generatedCode/Flow/FlowEndpoints/EndpointsGenerator.js +119 -0
  12. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/RbacFlowGenerator.js +91 -52
  13. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRelationshipEndpoints/RelationshipFlowGenerator.js +20 -16
  14. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/StatusFieldGenerator.js +1 -1
  15. package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3Components/ConfirmAfterUploadS3Generator.js +2 -4
  16. package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3Components/CreateObjectGenerator.js +2 -4
  17. package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3Components/CreatePreSignUrlGenerator.js +2 -4
  18. package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3Components/ProcessAfterUploadS3Generator.js +5 -5
  19. package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3Components/ReservedLimitGenerator.js +2 -4
  20. package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowEntryPointBase.js +6 -6
  21. package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowMainFunctionBase.js +3 -3
  22. package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowStepBase.js +11 -11
  23. package/src/codeGenerators/app/src/generatedCode/ProcessLogical/ProcessLogicalGenerator.js +18 -15
  24. package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/{PaginateProcessLogical_HdrDsq.js → PaginateProcessLogical_HdrDsq.ejs} +1 -1
  25. package/src/codeGenerators/app/src/generatedCode/SystemFlowSchemas/RegisterGenerator.js +133 -149
  26. package/src/codeGenerators/app/src/generatedCode/libs/ConstsGenerator.js +16 -8
  27. package/src/codeGenerators/app/src/generatedCode/libs/GenerateCodeLibsGenerator.js +17 -9
  28. package/src/codeGenerators/resource/sls_yaml/FlowOutGenerator.js +11 -2
  29. package/src/codeGenerators/resource/sls_yaml/FlowResourceYamlGenerator.js +31 -4
  30. package/src/core/renderTemplateFile.js +22 -0
  31. package/src/generateCode.js +143 -110
  32. package/src/generateIntTest.js +45 -69
  33. package/src/generateResourceIntTest.js +22 -47
  34. package/src/intTestGeneratorShared.js +36 -0
  35. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/flowSchemaMainFunction/data.js +0 -119
  36. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/flowSchemaMainFunction/template.ejs +0 -89
  37. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/flowSchemaMainFunction/templateByStatusType/statusFieldTemplate.ejs +0 -30
  38. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/flowSchemaMainFunction/templateByStatusType/storedCacheTemplate.ejs +0 -26
  39. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/flowSchemaMainFunction/templateByStatusType/triggerCacheTemplate.ejs +0 -44
  40. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/index.js +0 -80
  41. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/functionYaml/data.js +0 -129
  42. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/functionYaml/template.ejs +0 -17
  43. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/handler/data.js +0 -63
  44. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/mainFunction/data.js +0 -54
  45. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/mainFunction/template.ejs +0 -129
  46. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/queue/data.js +0 -63
  47. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/queue/template.ejs +0 -45
  48. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObject/functionYaml/data.js +0 -117
  49. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObject/functionYaml/template.ejs +0 -20
  50. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObject/handler/data.js +0 -64
  51. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObject/mainFunction/data.js +0 -64
  52. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObject/mainFunction/template.ejs +0 -131
  53. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/functionYaml/data.js +0 -122
  54. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/functionYaml/template.ejs +0 -17
  55. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/handler/data.js +0 -66
  56. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/handler/template.ejs +0 -99
  57. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/mainFunction/data.js +0 -64
  58. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/mainFunction/template.ejs +0 -82
  59. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/sns-sqs/data.js +0 -70
  60. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/sns-sqs/template.ejs +0 -49
  61. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/functionYaml/data.js +0 -139
  62. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/functionYaml/template.ejs +0 -18
  63. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/handler/data.js +0 -63
  64. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/mainFunction/data.js +0 -63
  65. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/mainFunction/template.ejs +0 -262
  66. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/queue/data.js +0 -63
  67. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/queue/template.ejs +0 -45
  68. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/functionYaml/data.js +0 -146
  69. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/functionYaml/template.ejs +0 -14
  70. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/handler/data.js +0 -64
  71. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/mainFunction/data.js +0 -59
  72. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +0 -173
  73. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/sqs/data.js +0 -67
  74. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/sqs/template.ejs +0 -53
  75. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/functionYml/HdrS3/data.js +0 -140
  76. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/functionYml/HdrS3/template.ejs +0 -25
  77. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/handler/handlerS3/data.js +0 -49
  78. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/handler/handlerS3/template.ejs +0 -50
  79. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/mainFunction/ProcessCsvtemplate.ejs +0 -182
  80. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/mainFunction/data.js +0 -49
  81. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/mainFunction/template.ejs +0 -66
  82. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/queue/data.js +0 -77
  83. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/queue/dsqTemplatePath.ejs +0 -32
  84. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/queue/s3Template.ejs +0 -59
  85. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/relate/S3/data.js +0 -61
  86. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/relate/S3/template.ejs +0 -13
  87. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/relate/sns-out/data.js +0 -70
  88. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/websocket/dynamoDb/ReservedTableData.js +0 -69
  89. package/src/codeGenerators/app/src/generatedCode/Flow/SystemFlowDescriptorBuilder.js +0 -151
  90. /package/src/codeGenerators/app/{src/generatedCode/FindData → sls_yaml}/templates/FindData_Yaml.ejs +0 -0
  91. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared/endpoint → FlowEndpoints/templates}/FlowEndpointBeforeLogical_Main.ejs +0 -0
  92. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/endpoint/FlowEndpoint_HdrWbs.ejs +0 -0
  93. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/endpoint/FlowEndpoint_Main.ejs +0 -0
  94. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/endpoint/FlowEntryPoint_Main.ejs +0 -0
  95. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/endpoint/FlowMain_Wbs.ejs +0 -0
  96. /package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/{s3Legacy/upload/confirmReserved/handler/template.ejs → s3/ConfirmReserved_HdrSqs.ejs} +0 -0
  97. /package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/{s3Legacy/upload/createObject/handler/template.ejs → s3/CreateObject_HdrWbs.ejs} +0 -0
  98. /package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/{s3Legacy/upload/preSignUrl/createPreSignUrl/handler/template.ejs → s3/CreatePreSignUrl_HdrSqs.ejs} +0 -0
  99. /package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/{s3Legacy/upload/preSignUrl/reservedLimit/handler/template.ejs → s3/ReservedLimit_HdrSqs.ejs} +0 -0
  100. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/FlowEndpointComplete_Main.ejs +0 -0
  101. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/FlowStep_Main.ejs +0 -0
  102. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/FlowStep_ByConfig_Awaiting_Main.ejs +0 -0
  103. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/FlowStep_ByConfig_Paginated_Main.ejs +0 -0
  104. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/FlowStep_PlugIn_Main.ejs +0 -0
  105. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/FlowStep_RecievePlugIn_Main.ejs +0 -0
  106. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/templateAwaitingStep.ejs +0 -0
  107. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/templateSendPlugin.ejs +0 -0
  108. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/BaseSqsHandler.js +0 -0
  109. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/eventBridge.js +0 -0
  110. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/extTopic.js +0 -0
  111. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/lambdaSyncApi.js +0 -0
  112. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/lambdaSyncInv.js +0 -0
  113. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/ownTopic.js +0 -0
  114. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/registry.js +0 -0
  115. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3.js +0 -0
  116. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/handlers/FlowHandler_HdrApi.ejs +0 -0
  117. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/handlers/FlowHandler_HdrInv.ejs +0 -0
  118. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/handlers/FlowHandler_HdrSqs.ejs +0 -0
  119. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/eventTypes.js +0 -0
  120. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowClassifier.js +0 -0
  121. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowNaming.js +0 -0
  122. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowSelection.js +0 -0
  123. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowStepNormalizer.js +0 -0
  124. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowValidator.js +0 -0
  125. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/registry.js +0 -0
  126. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/triggerCacheBase.js +0 -0
  127. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/CheckTriggerCache_HdrSqs.ejs +0 -0
  128. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/CheckTriggerCache_Main.ejs +0 -0
  129. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/ProcessTriggerCache_HdrSqs.ejs +0 -0
  130. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/ProcessTriggerCache_Main.ejs +0 -0
  131. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/TriggerCacheComplete_HdrDsq.ejs +0 -0
  132. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/TriggerCacheComplete_HdrSqs.ejs +0 -0
  133. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/TriggerCacheComplete_Main.ejs +0 -0
  134. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/TriggerCacheQueue_Yaml.ejs +0 -0
  135. /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/yaml/SharedFunctionSqs_Yaml.ejs +0 -0
  136. /package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/{PaginateProcessLogical_HdrSqs.js → PaginateProcessLogical_HdrSqs.ejs} +0 -0
  137. /package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/{PaginateProcessLogical_Main.js → PaginateProcessLogical_Main.ejs} +0 -0
  138. /package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/{ProcessLogical_HdrSqs.js → ProcessLogical_HdrSqs.ejs} +0 -0
  139. /package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/{ProcessLogical_Main.js → ProcessLogical_Main.ejs} +0 -0
  140. /package/src/codeGenerators/app/src/generatedCode/libs/templates/{Consts.js → Consts.ejs} +0 -0
  141. /package/src/codeGenerators/app/src/generatedCode/libs/templates/{GenerateCodeLibs.js → GenerateCodeLibs.ejs} +0 -0
@@ -1,49 +0,0 @@
1
- Subscription<%- queueName-%>:
2
- Type: AWS::SNS::Subscription
3
- Properties:
4
- TopicArn: !Ref <%- subScription %>
5
- Endpoint: "arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>"
6
- Protocol: "sqs"
7
- #------- queue ---------
8
- <%- queueName %>:
9
- Type: "AWS::SQS::Queue"
10
- Properties:
11
- QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>
12
- RedrivePolicy:
13
- deadLetterTargetArn: #!GetAtt
14
- Fn::GetAtt:
15
- - <%- queueName %>DLQ
16
- - Arn
17
- maxReceiveCount: 3
18
- VisibilityTimeout: 120
19
-
20
- <%- queueName %>DLQ:
21
- Type: AWS::SQS::Queue
22
- Properties:
23
- QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>DLQ
24
-
25
- <%- queueName %>Policy:
26
- Type: AWS::SQS::QueuePolicy
27
- Properties:
28
- PolicyDocument:
29
- Version: "2012-10-17"
30
- Statement:
31
- - Sid: "allow-sns-messages"
32
- Effect: Allow
33
- Principal: "*"
34
- Resource: #!GetAtt
35
- Fn::GetAtt:
36
- - <%- queueName %>
37
- - Arn
38
- Action: "SQS:SendMessage"
39
- Queues:
40
- - Ref: <%- queueName %>
41
- #<#<%- firstLetterUpperCase(queueName) %>QueueSetting#>
42
- #<#/<%- firstLetterUpperCase(queueName) %>QueueSetting#>
43
-
44
- <%_ function firstLetterUpperCase(text){
45
- return text.charAt(0).toUpperCase() + text.slice(1)
46
- } _%>
47
- <%_ function firstLetterLowerCase(str) {
48
- return str.charAt(0).toLowerCase() + str.slice(1)
49
- } _%>
@@ -1,139 +0,0 @@
1
- /*
2
- Copyright (C) 2021 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
- import path from 'path';
19
- import { fileURLToPath } from 'url';
20
- const __filename = fileURLToPath(import.meta.url);
21
- const __dirname = path.dirname(__filename);
22
-
23
- import consts from '#libs/Consts.js';
24
- import utils from '#libs/Utils.js';
25
- import libs from '#libs/Libs.js';
26
-
27
- const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } =
28
- utils;
29
- const {
30
- HANDLER,
31
- RESOURCE_CLASSES,
32
- SQS_RESOURCE,
33
- SNS_RESOURCE,
34
- SOURCE_PATH,
35
- SAVE_FILE_NAME,
36
- DYNAMO_RESOURCE,
37
- LAMBDA_RESOURCE,
38
- SOURCE_GENERATE_IAM_ROLE,
39
- FUNCTION_NAME,
40
- ACTIONS
41
- } = consts;
42
-
43
- const {
44
- resourceNames,
45
- shortNameHandler,
46
- defaultIamRolePerAction,
47
- createIamRole
48
- } = libs;
49
-
50
- const templatePath = path.join(__dirname, 'template.ejs');
51
-
52
- /**
53
- * receive objectSchema
54
- *
55
- * @param {Object} flowSchema
56
- * @return {{ templatePath, templateData, setting } }
57
- */
58
-
59
- function createSourceParams(_izContext, flowSchema, appPath) {
60
- let functionName = upperCase(FUNCTION_NAME.createPreSignUrl);
61
- let handlerType = upperCase(HANDLER.hdrSqs);
62
- let additionalResourcePermission = defaultIamRolePerAction();
63
-
64
- additionalResourcePermission.push(
65
- createIamRole(
66
- {
67
- [RESOURCE_CLASSES.sqs]: [
68
- SQS_RESOURCE.receiveMessage,
69
- SQS_RESOURCE.sendMessage,
70
- SQS_RESOURCE.deleteMessage,
71
- SQS_RESOURCE.getQueueAttributes
72
- ]
73
- },
74
- [
75
- resourceNames(RESOURCE_CLASSES.sqs, functionName + handlerType),
76
- resourceNames(RESOURCE_CLASSES.sqs, functionName + 'DLQ')
77
- ]
78
- ),
79
- createIamRole(
80
- {
81
- [RESOURCE_CLASSES.dynamoDbTable]: [
82
- DYNAMO_RESOURCE.query,
83
- DYNAMO_RESOURCE.deleteItem,
84
- DYNAMO_RESOURCE.updateItem,
85
- DYNAMO_RESOURCE.putItem
86
- ]
87
- },
88
- [
89
- resourceNames(RESOURCE_CLASSES.dynamoDbTable, 'WebSocketTask'),
90
- resourceNames(RESOURCE_CLASSES.dynamoDbTable, 'ReservedDataMain')
91
- ]
92
- ),
93
- createIamRole(
94
- {
95
- 'execute-api': 'ManageConnections'
96
- },
97
- [resourceNames(RESOURCE_CLASSES.webSocket)]
98
- ),
99
- createIamRole(
100
- {
101
- [RESOURCE_CLASSES.lambda]: [LAMBDA_RESOURCE.invokeFunction],
102
- [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
103
- },
104
- [
105
- resourceNames(
106
- RESOURCE_CLASSES.lambda,
107
- upperCase(ACTIONS.get) + upperCase(HANDLER.hdrInv)
108
- ),
109
- resourceNames(RESOURCE_CLASSES.sns, upperCase(ACTIONS.update) + '_In')
110
- ]
111
- )
112
- );
113
-
114
- return {
115
- templatePath: templatePath,
116
- templateData: {
117
- functionName,
118
- handlerType,
119
- functionNameConfig: functionName + upperCase(handlerType),
120
- resourceLocation: path.join(
121
- SOURCE_PATH.resourceLocationWebSocket,
122
- flowSchema.flowTag,
123
- 'source/'
124
- ),
125
- additionalResourcePermission,
126
- functionNameConfig:
127
- functionName + upperCase(shortNameHandler(handlerType)),
128
- roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaUploadS3Role
129
- },
130
- setting: {
131
- saveFileName: SAVE_FILE_NAME.flowSchemaYaml,
132
- savePath: path.join(appPath, SOURCE_PATH.appYaml),
133
- fileExtension: '.yml',
134
- isAppend: true
135
- }
136
- };
137
- }
138
-
139
- export default createSourceParams;
@@ -1,18 +0,0 @@
1
- <%_ const join = require('path').join; _%>
2
- <%- firstLetterUpperCase(functionNameConfig) %>:
3
- handler: <%- join(resourceLocation, `${functionName}_${firstLetterUpperCase(handlerType)}.main`)%>
4
- name: ${self:custom.iz_resourcePrefix}<%- functionName %><%- firstLetterUpperCase(handlerType) %>
5
- role: <%- roleName %>Role
6
- #<#<%- functionName %><%- handlerType %>FunctionSetting#>
7
- #<#/<%- functionName %><%- handlerType %>FunctionSetting#>
8
- events:
9
- - sqs:
10
- arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- functionName %><%- firstLetterUpperCase(handlerType) %>
11
- batchSize: 10
12
- filterPatterns: #**** need to update serverless framework upper v.2.69.1
13
- - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>"]}}} # functionName of callingFlow
14
- - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
15
-
16
- <%_ function firstLetterUpperCase(text){
17
- return text.charAt(0).toUpperCase() + text.slice(1)
18
- } _%>
@@ -1,63 +0,0 @@
1
- /*
2
- Copyright (C) 2021 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
- import path from 'path';
19
- import { fileURLToPath } from 'url';
20
- const __filename = fileURLToPath(import.meta.url);
21
- const __dirname = path.dirname(__filename);
22
-
23
- import consts from '#libs/Consts.js';
24
- import utils from '#libs/Utils.js';
25
-
26
- const { HANDLER, SOURCE_PATH, FUNCTION_NAME } = consts;
27
-
28
- const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } =
29
- utils;
30
- const templatePath = path.join(__dirname, 'template.ejs');
31
-
32
- /**
33
- * receive objectSchema
34
- *
35
- * @param {Object} flowSchema
36
- * @return {{ templatePath, templateData, setting } }
37
- */
38
-
39
- function createSourceParams(_izContext, flowSchema, appPath) {
40
- let functionName = upperCase(FUNCTION_NAME.createPreSignUrl);
41
- let handlerType = upperCase(HANDLER.hdrSqs);
42
-
43
- return {
44
- templatePath: templatePath,
45
- templateData: {
46
- functionName,
47
- handlerType
48
- },
49
- setting: {
50
- saveFileName: `${functionName}_${handlerType}`,
51
- savePath: path.join(
52
- appPath,
53
- SOURCE_PATH.webSocket,
54
- flowSchema.flowTag,
55
- 'source/'
56
- ),
57
- fileExtension: '.js',
58
- isAppend: true
59
- }
60
- };
61
- }
62
-
63
- export default createSourceParams;
@@ -1,63 +0,0 @@
1
- /*
2
- Copyright (C) 2021 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
- import path from 'path';
19
- import { fileURLToPath } from 'url';
20
- const __filename = fileURLToPath(import.meta.url);
21
- const __dirname = path.dirname(__filename);
22
-
23
- import consts from '#libs/Consts.js';
24
- import utils from '#libs/Utils.js';
25
-
26
- const { SOURCE_PATH, FUNCTION_NAME } = consts;
27
- const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } =
28
- utils;
29
-
30
- const templatePath = path.join(__dirname, 'template.ejs');
31
-
32
- /**
33
- * receive objectSchema
34
- *
35
- * @param {Object} flowSchema
36
- * @return {{ templatePath, templateData, setting } }
37
- */
38
-
39
- function createSourceParams(_izContext, flowSchema, appPath) {
40
- let functionName = upperCase(FUNCTION_NAME.createPreSignUrl);
41
- let bucketName = flowSchema.bucketName;
42
- let flowTag = flowSchema.flowTag;
43
- return {
44
- templatePath: templatePath,
45
- templateData: {
46
- bucketName,
47
- flowTag
48
- },
49
- setting: {
50
- saveFileName: `${functionName}_Main`,
51
- savePath: path.join(
52
- appPath,
53
- SOURCE_PATH.webSocket,
54
- flowSchema.flowTag,
55
- 'source/'
56
- ),
57
- fileExtension: '.js',
58
- isAppend: false
59
- }
60
- };
61
- }
62
-
63
- export default createSourceParams;
@@ -1,262 +0,0 @@
1
- /*
2
- Copyright (C) 2021 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
-
19
-
20
- import snsSharedLib from '@izara_project/izara-core-library-sns';
21
- import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
22
- import lambdaSharedLib from '@izara_project/izara-core-library-lambda';
23
- import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
24
-
25
- import { lambda, sns } from '@izara_project/izara-core-library-external-request'
26
-
27
- import { S3Client } from '@aws-sdk/client-s3';
28
- import { createPresignedPost } from '@aws-sdk/s3-presigned-post';
29
- const client = new S3Client({ region: 'us-east-2' });
30
- import { consts } from '@izara_project/izara-middleware';
31
-
32
- import { postToConnection, getNestObject } from '../../../../libs/source/GenerateCodeLibs.js'
33
- import { consts as coreConsts } from '@izara_project/izara-core-library-core';
34
- import { consts as generateCodeConsts } from '@izara_project/izara-core-generate-service-code';
35
- const { EXTERNAL_SERVICE_NAME } = generateCodeConsts;
36
- import { utils } from "@izara_project/izara-core-library-service-schemas"
37
- const { createFlowTypeConcat } = utils
38
- //(<optionalRequired>)
39
- //(</optionalRequired>)
40
-
41
- /**
42
- * description of function.
43
- * @param {Object} _izContext
44
- * @param {CorrelationIds} _izContext.correlationIds - property of _izContext
45
- * @param {Logger} _izContext.logger - property of _izContext
46
- * @param {Logger} _izContext.logger - property of _izContext
47
- * @param {Object} returnMessage - limitValue or limitFound
48
- * @param {Array} errorsFound - array
49
- * @param {boolean} passStatus - true || false
50
- * @param {Object} passBackProperties - identifier
51
- *
52
- * @returns {object} returnResponse
53
- */
54
-
55
- export default async function <%= functionName %> (
56
- _izContext,
57
- returnMessage,
58
- errorsFound,
59
- passStatus,
60
- //(<additionalProperties>)
61
- //(</additionalProperties>)
62
- passBackProperties = {}
63
- ) {
64
-
65
- try {
66
-
67
- _izContext.logger.debug('----- createPreSignUrl event params -----', {
68
- returnMessage: returnMessage,
69
- errorsFound: errorsFound,
70
- passStatus: passStatus,
71
- passBackProperties: passBackProperties
72
- });
73
-
74
- const servicePendingId = passBackProperties.passBackProperties.identifier.servicePendingId; // importBatchId
75
- const reservedDataId = passBackProperties.passBackProperties.identifier.reservedDataId;
76
- const objType = passBackProperties.passBackProperties.objType
77
-
78
- const correlationId = _izContext.correlationIds.get(consts.X_CORRELATION_ID)
79
- const connectionId = _izContext.correlationIds.get(consts.CONNECTION_ID)
80
-
81
- let getResult = await lambda.invokeSync(_izContext,
82
- await lambdaSharedLib.lambdaFunctionName(_izContext, "GetHdrInv"),
83
- {
84
- objectType: objType.objectType,
85
- //(<identifiersForGetData>)
86
- //(</identifiersForGetData>)
87
- }
88
- )
89
- _izContext.logger.debug("getResult", getResult);
90
-
91
- //(<afterGetResult>)
92
- //(</afterGetResult>)
93
-
94
- let uniqueIdentify = getNestObject(
95
- _izContext,
96
- returnMessage,
97
- ['limitFound', 'runningTotal', 'uniqueIdentify', 'usedTimestampId']
98
- );
99
- _izContext.logger.debug("uniqueIdentify", uniqueIdentify);
100
-
101
- await dynamodbSharedLib.putItem(_izContext,
102
- await dynamodbSharedLib.tableName(_izContext, "ReservedDataMain"),
103
- //(<createReservedDataMain>)
104
- {}
105
- //(</createReservedDataMain>)
106
- );
107
-
108
- if (passStatus === false) { // if passStatus false post message to client
109
- // use correlationId to get connectionId and use connectionId to post message to client
110
-
111
- _izContext.logger.debug("reserved has reach limit");
112
-
113
- errorsFound.push("reserved has reach limit")
114
- // update status
115
- let updateStatusField = {
116
- objInstanceFull: {
117
- identifiers: {
118
- //(<identifiersForUpdateStatus>)
119
- //(</identifiersForUpdateStatus>)
120
- },
121
- fields: {
122
- //(<fields>)
123
- //(</fields>)
124
- }
125
- },
126
- objectType: objType.objectType
127
- }
128
-
129
- let sendMessageToUpdateEndpoint = {
130
- Message: JSON.stringify(updateStatusField),
131
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, `Update_In`)
132
- }
133
- _izContext.logger.debug("sendMessageToUpdateEndpoint", sendMessageToUpdateEndpoint);
134
-
135
- // cancel reserved
136
-
137
- let cancelReservedMsg = {
138
- userId: _izContext.correlationIds.get(coreConsts.BASE_USER_ID),
139
- limitTag: returnMessage.limitTag,
140
- uniqueIdentify: uniqueIdentify
141
- };
142
-
143
- let sendMessageToCancelReserved = {
144
- Message: JSON.stringify(cancelReservedMsg),
145
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, 'CancelUsage_In', EXTERNAL_SERVICE_NAME.accountLimits)
146
- };
147
-
148
- _izContext.logger.debug("sendMessageToCancelReserved", sendMessageToCancelReserved);
149
- await sns.publishAsync(_izContext, sendMessageToCancelReserved);
150
-
151
- await postToConnection({ message: "reserved has reach limit" }, connectionId)
152
-
153
- //(<createIdentifiersForDeleteTask>)
154
- let identifiers
155
- //(</createIdentifiersForDeleteTask>)
156
- // after post message delete websocket task
157
- await dynamodbSharedLib.deleteItem(_izContext,
158
- await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
159
- {
160
- taskKey: `${createFlowTypeConcat(_izContext, { flowTag: "<%- flowTag %>", serviceTag: process.env.iz_serviceTag })}${identifiers}`,
161
- connectionId: connectionId
162
- }
163
- )
164
-
165
- //(<afterCancelReservedLimit>)
166
- //(</afterCancelReservedLimit>)
167
-
168
- return "reserved not pass"
169
- }
170
-
171
- //(<createKeyForUploadFile>)
172
- const Key = `${fileName}.${importType}`
173
- //(</createKeyForUploadFile>)
174
-
175
- const maximumSize = getResult.fields.fileSize * 1048576 // convert to byte unit for restrict
176
- _izContext.logger.debug("maximumSize", maximumSize);
177
-
178
- // create PresignUrl
179
- let createPreSignUrlParam = {
180
- Bucket: process.env.iz_csvBucketName,
181
- Key: Key,
182
- Conditions: [
183
- //(<conditionCreateUrlLink>)
184
- ["content-length-range", 0, maximumSize],
185
- ["starts-with", "$Content-Type", "file/csv"],
186
- ["eq", "$x-amz-meta-importBatchId", importBatchId]
187
- //(</conditionCreateUrlLink>)
188
- ],
189
- Fields: {},
190
- Expires: 86400
191
- };
192
- _izContext.logger.debug('createPreSignUrlParam', createPreSignUrlParam);
193
-
194
- const uploadUrl = await createPresignedPost(client, createPreSignUrlParam);
195
-
196
- //(<modifyUploadLinkField>)
197
- uploadUrl.fields['x-amz-meta-importBatchId'] = importBatchId;
198
- uploadUrl.fields['Content-Type'] = `file/${importType}`;
199
- //(</modifyUploadLinkField>)
200
-
201
- _izContext.logger.debug('uploadUrlLimitSize: ', uploadUrl) // return as object type = {url, fields}
202
-
203
- // update to waiting to upload
204
- //(<checkStatusField>)
205
- if (status === "processing") {
206
- //(</checkStatusField>)
207
- let messageObject = {
208
- objInstanceFull: {
209
- identifiers: {
210
- //(<identifiersForUpdateTable>)
211
- //(</identifiersForUpdateTable>)
212
- },
213
- fields: {
214
- importBatchStatus: "waitingToUpload",
215
- expiryTimestamp: (getResult.fields.startTime + (createPreSignUrlParam.Expires * 1000))
216
- }
217
- },
218
- objectType: objType.objectType
219
- }
220
-
221
- messageObject = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
222
- messageObject,
223
- callingFlowSharedLib.addParentCallingFlowConfig(
224
- returnMessage, // resive parent callingFlowConfig.
225
- callingFlowSharedLib.createCallingFlowConfig( // calling flow own service
226
- await lambdaSharedLib.lambdaFunctionName(_izContext, `WebSocketComplete`), {}
227
- )
228
- )
229
- );
230
-
231
- _izContext.logger.debug("after add callingFlow", messageObject)
232
-
233
- let sendMessageToUpdateEndpoint = {
234
- Message: JSON.stringify(messageObject),
235
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, "Update_In")
236
- }
237
- _izContext.logger.debug("sendMessageToUpdateEndpoint", sendMessageToUpdateEndpoint);
238
- await sns.publishAsync(_izContext, sendMessageToUpdateEndpoint);
239
-
240
- //(<createIdentifierFlow>)
241
- let identifiers
242
- //(</createIdentifierFlow>)
243
- await dynamodbSharedLib.updateItem(_izContext,
244
- await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
245
- {
246
- taskKey: `${createFlowTypeConcat(_izContext, { flowTag: "<%- flowTag %>", serviceTag: process.env.iz_serviceTag })}${identifiers}`,
247
- connectionId: connectionId
248
- },
249
- {
250
- uploadUrl: uploadUrl
251
- }
252
- )
253
- }
254
-
255
- //(<mainFunctionHookCode>)
256
- //(</mainFunctionHookCode>)
257
-
258
- } catch (err) {
259
- _izContext.logger.error('error createPreSignUrl: ', err)
260
- throw (err)
261
- }
262
- }
@@ -1,63 +0,0 @@
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
- import path from 'path';
19
- import { fileURLToPath } from 'url';
20
- const __filename = fileURLToPath(import.meta.url);
21
- const __dirname = path.dirname(__filename);
22
-
23
- import consts from '#libs/Consts.js';
24
-
25
- const { SOURCE_PATH, SAVE_FILE_NAME, TOPIC_NAME_GENERATE_CODE } = consts;
26
-
27
- const templatePath = path.join(__dirname, 'template.ejs');
28
-
29
- /**
30
- * create data for dynamoDbYaml tempalte from objectSchema
31
- * return array of dynamoDb data
32
- * because one objectSchema can create multiple dynamoDb table
33
- *
34
- * @param {Object} _izContext
35
- * @param {Object} objectSchema
36
- * @returns {Object[]} - data of multiple dynamoDb template
37
- */
38
-
39
- function data(_izContext, appPath) {
40
- let resultForCreateSqs = [];
41
- const WebSocketSqsQueueNames = [];
42
- const setting = {
43
- initialData: 'Resources:\n',
44
- savePath: path.join(appPath, SOURCE_PATH.resourceYaml),
45
- saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
46
- fileExtension: '.yml',
47
- isAppend: true
48
- };
49
-
50
- WebSocketSqsQueueNames.push({
51
- queueName: TOPIC_NAME_GENERATE_CODE.createPreSignUrl
52
- });
53
-
54
- for (let WebSocketSqsQueueName of WebSocketSqsQueueNames) {
55
- resultForCreateSqs.push({
56
- templatePath: templatePath,
57
- templateData: WebSocketSqsQueueName,
58
- setting: setting
59
- });
60
- }
61
- return resultForCreateSqs;
62
- }
63
- export default data;