@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,5 +1,4 @@
1
- /*
2
- Copyright (C) 2020 Sven Mason <http://izara.io>
1
+ /* Copyright (C) 2020 Sven Mason <http://izara.io>
3
2
 
4
3
  This program is free software: you can redistribute it and/or modify
5
4
  it under the terms of the GNU Affero General Public License as
@@ -8,33 +7,33 @@ License, or (at your option) any later version.
8
7
 
9
8
  This program is distributed in the hope that it will be useful,
10
9
  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
11
  GNU Affero General Public License for more details.
13
12
 
14
13
  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/>.
14
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
15
  */
17
16
 
18
- import { readFileSync, writeFileSync, mkdirSync, existsSync, rmSync } from 'fs';
17
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
19
18
  import { join } from 'path';
20
- import yaml from 'yaml';
21
19
  import ejs from 'ejs';
22
20
 
23
21
  import generateResourceTemplate from './generateResources/IntTest/generateResources/generateResources.js';
22
+ import { getServiceTag, runTemplateItems } from './intTestGeneratorShared.js';
24
23
 
25
- // Minimal writeSource for resource generation (no hook support, no beautify — resources are .json)
26
24
  function writeSource({ templatePath, templateData, setting }, { checkCreateSourcePass = false } = {}) {
27
25
  if (!templatePath || !templateData || !setting) {
28
26
  throw new Error('Invalid IntTest resource item: missing templatePath/templateData/setting');
29
27
  }
28
+
30
29
  const { savePath, saveFileName, fileExtension } = setting;
31
30
 
32
31
  if (checkCreateSourcePass) {
33
32
  try {
34
33
  ejs.compile(readFileSync(templatePath, 'utf8'))(templateData);
35
34
  return [true, {}];
36
- } catch (err) {
37
- return [false, err];
35
+ } catch (error) {
36
+ return [false, error];
38
37
  }
39
38
  }
40
39
 
@@ -43,59 +42,35 @@ function writeSource({ templatePath, templateData, setting }, { checkCreateSourc
43
42
 
44
43
  const dataToSave = ejs.compile(readFileSync(templatePath, 'utf8'))(templateData);
45
44
  writeFileSync(filePath, dataToSave, 'utf8');
45
+ return [true, {}];
46
46
  }
47
47
 
48
- function getServiceTag(rootPath) {
49
- const configPath = join(rootPath, 'config', 'serverless.config.yml');
50
- const config = yaml.parse(readFileSync(configPath, 'utf8'));
51
- return config?.main_config?.iz_serviceTag;
52
- }
53
-
54
- /**
55
- * Generate integration test shared resources (tableNames + function components) for the service.
56
- * Result-Driven refactor: flat pipeline, no createSource/libs dependencies.
57
- *
58
- * @param {string} rootPath - Service root path containing /config and /app
59
- * @param {Object} [options]
60
- * @param {string} [options.outputPath] - Where to write (default: rootPath)
61
- * @param {Object} [options._izContext] - Logger context (default: silent logger)
62
- * @returns {Promise<{ serviceTag: string, count: number, durationMs: number }>}
63
- */
64
48
  export async function generateResourceIntTest(rootPath, options = {}) {
65
49
  const {
66
50
  outputPath = rootPath,
67
- _izContext = { logger: { debug: () => {}, info: console.info, warn: console.warn, error: console.error } }
51
+ _izContext = {
52
+ logger: {
53
+ debug: () => {},
54
+ info: console.info,
55
+ warn: console.warn,
56
+ error: console.error
57
+ }
58
+ }
68
59
  } = options;
69
60
 
70
61
  const startTime = Date.now();
71
62
  const serviceTag = getServiceTag(rootPath);
72
63
  if (!serviceTag) {
73
- throw new Error('Missing iz_serviceTag in serverless.config.yml — required for IntTest resource generation');
64
+ throw new Error('Missing iz_serviceTag in serverless.config.yml — required IntTest resource generation');
74
65
  }
75
66
 
76
67
  const savePath = join(outputPath, 'src', 'generateIntegrationTest');
77
-
78
- // Get IntTest resource data from sub-orchestrator
79
68
  const items = await generateResourceTemplate(_izContext, savePath, { serviceTag });
80
69
 
81
- // Validate phase
82
- for (const item of items) {
83
- if (!item || !item.templatePath || !item.templateData || !item.setting) {
84
- throw new Error('Invalid IntTest resource item: missing templatePath/templateData/setting');
85
- }
86
- const [status, errors] = writeSource(item, { checkCreateSourcePass: true });
87
- if (!status) {
88
- throw new Error(`IntTest resource template validation failed: ${errors?.message || errors}`);
89
- }
90
- }
91
-
92
- // Write phase
93
- for (const item of items) {
94
- if (item.setting?.savePath && existsSync(item.setting.savePath)) {
95
- rmSync(item.setting.savePath, { recursive: true, force: true });
96
- }
97
- writeSource(item, { checkCreateSourcePass: false });
98
- }
70
+ await runTemplateItems(items, {
71
+ writeSource,
72
+ errorPrefix: 'IntTest resource'
73
+ });
99
74
 
100
75
  const durationMs = Date.now() - startTime;
101
76
  return { serviceTag, count: items.length, durationMs };
@@ -0,0 +1,36 @@
1
+ import { existsSync, readFileSync, rmSync } from 'fs';
2
+ import { join } from 'path';
3
+ import yaml from 'yaml';
4
+
5
+ function getServiceTag(rootPath) {
6
+ const configPath = join(rootPath, 'config', 'serverless.config.yml');
7
+ const config = yaml.parse(readFileSync(configPath, 'utf8'));
8
+ return config?.main_config?.iz_serviceTag;
9
+ }
10
+
11
+ async function runTemplateItems(items, { writeSource, errorPrefix }) {
12
+ const clearedPaths = new Set();
13
+
14
+ for (const item of items) {
15
+ if (!item || !item.templatePath || !item.templateData || !item.setting) {
16
+ throw new Error(`Invalid ${errorPrefix} item: missing templatePath/templateData/setting`);
17
+ }
18
+
19
+ const [status, error] = await writeSource(item, { checkCreateSourcePass: true });
20
+ if (!status) {
21
+ throw new Error(`${errorPrefix} template validation failed: ${error?.message || error}`);
22
+ }
23
+ }
24
+
25
+ for (const item of items) {
26
+ const savePath = item.setting?.savePath;
27
+ if (savePath && existsSync(savePath) && !clearedPaths.has(savePath)) {
28
+ rmSync(savePath, { recursive: true, force: true });
29
+ clearedPaths.add(savePath);
30
+ }
31
+
32
+ await writeSource(item, { checkCreateSourcePass: false });
33
+ }
34
+ }
35
+
36
+ export { getServiceTag, runTemplateItems };
@@ -1,119 +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 { NoRetryError } from '@izara_project/izara-core-library-core';
24
- import {
25
- getObjectSchema,
26
- utils as coreUtils
27
- } from '@izara_project/izara-core-library-service-schemas';
28
- const { createFlowTypeConcat } = coreUtils;
29
-
30
- import consts from '#libs/Consts.js';
31
- import utils from '#libs/Utils.js';
32
- const { SOURCE_PATH, STORAGE_TYPES } = consts;
33
- const { firstLetterUpperCase: upperCase, getLocalConfig, savePath } = utils;
34
-
35
- const templatePath = path.join(__dirname, 'template.ejs');
36
- const statusFieldTemplate = path.join(
37
- __dirname,
38
- './templateByStatusType/statusFieldTemplate.ejs'
39
- );
40
- const storedCacheTemplate = path.join(
41
- __dirname,
42
- './templateByStatusType/storedCacheTemplate.ejs'
43
- );
44
- const triggerCacheTemplate = path.join(
45
- __dirname,
46
- './templateByStatusType/triggerCacheTemplate.ejs'
47
- );
48
-
49
- /**
50
- * receive objectSchema
51
- * create data for WebScoket handler template
52
- *
53
- * @param {Object} objectSchema
54
- * @return {{templatePath, templateData,setting}}
55
- */
56
- async function createParamsForCreateSource(_izContext, flowSchema, appPath) {
57
- let functionName = 'Process' + upperCase(flowSchema.flowTag);
58
- let tableName = null;
59
- if (
60
- flowSchema.statusType === 'storedCache' ||
61
- flowSchema.statusType === 'triggerCache'
62
- ) {
63
- let objectSchema = await getObjectSchema
64
- .getLocalObjectSchemas(
65
- _izContext,
66
- [flowSchema.objType.objectType],
67
- path.join(appPath, 'src/schemas')
68
- )
69
- .then(res => res.records[0]);
70
- if (!objectSchema)
71
- throw new NoRetryError('no objectSchema in local service');
72
- for (const storageResource of Object.values(
73
- objectSchema.storageResources
74
- )) {
75
- if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
76
- tableName = storageResource.tableName;
77
- }
78
- }
79
- }
80
-
81
- let triggerType;
82
- if (
83
- flowSchema.statusType === 'triggerCache' &&
84
- flowSchema.hasOwnProperty('triggerType')
85
- ) {
86
- triggerType = flowSchema.triggerType;
87
- }
88
- let flowSchemaComplete = upperCase(flowSchema.flowTag);
89
-
90
- return {
91
- templatePath: templatePath,
92
- templateData: {
93
- statusType: flowSchema.statusType,
94
- statusFieldTemplate,
95
- storedCacheTemplate,
96
- triggerCacheTemplate,
97
- flowTag: flowSchema.flowTag,
98
- functionName,
99
- tableName,
100
- flowSchemaComplete,
101
- triggerType,
102
- queueName: `${createFlowTypeConcat(_izContext, { serviceTag: (await import('yaml')).default.parse((await import('fs')).default.readFileSync(path.resolve(appPath, '../config/serverless.config.yml'), 'utf8'))?.main_config?.iz_serviceTag, flowTag: upperCase(flowSchema.flowTag) })}_Main`
103
- },
104
- setting: {
105
- savePath:
106
- // path.join(
107
- // appPath,
108
- // SOURCE_PATH.flowSchema,
109
- // upperCase(flowSchema.flowTag),
110
- // 'source/'
111
- // ),
112
- savePath.resourceYamlFlowSchemaFlowTag(appPath, flowSchema.flowTag),
113
- saveFileName: `${functionName}_Main`,
114
- fileExtension: '.js',
115
- isAppend: false
116
- }
117
- };
118
- }
119
- export default createParamsForCreateSource;
@@ -1,89 +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
16
- <http: //www.gnu.org/licenses />.
17
- */
18
-
19
- import { getObjectSchema } from '@izara_project/izara-core-library-service-schemas';
20
- import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
21
- import snsSharedLib from '@izara_project/izara-core-library-sns';
22
- import sqsSharedLib from '@izara_project/izara-core-library-sqs';
23
- import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-flow';
24
- import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
25
- import lambdaSharedLib from '@izara_project/izara-core-library-lambda';
26
- import { lambda,sns,sqs } from '@izara_project/izara-core-library-external-request';
27
- import { NoRetryError } from '@izara_project/izara-core-library-core';
28
- import { utils } from '@izara_project/izara-core-library-service-schemas';
29
- const { createFlowTypeConcat } = utils;
30
- <% if (statusType === "triggerCache") { -%>
31
- import { triggeredCacheSharedLibV2 } from '@izara_project/izara-core-library-trigger-cache';
32
- <% } else if (statusType === "statusField") { -%>
33
- import statusFieldSharedLib from '@izara_project/izara-core-library-status-field';
34
- <% } else if (statusType === "storedCache") { -%>
35
- import storedCacheSharedLib from '@izara_project/izara-core-library-stored-cache';
36
- <% } -%>
37
-
38
- //(<optionalRequire>)
39
- //(</optionalRequire>)
40
- /**
41
- *
42
- *
43
- * description of function.
44
- * @param {Object} _izContext
45
- * @param {CorrelationIds} _izContext.correlationIds - property of _izContext
46
- * @param {Logger} _izContext.logger - property of _izContext
47
- * @param {Object} requestParams - request params
48
- * @param {Object} requestParams.identifiers - identifiers for get data
49
- * @param {Object} requestParams.additionalRequest - additionalRequest
50
- *
51
- *
52
- * @returns {object} description of return value
53
- */
54
-
55
- export default async function <%- functionName %> (
56
- _izContext,
57
- requestParams,
58
- callingFlowConfig = {},
59
- //(<additionalParams>)
60
- //(</additionalParams>)
61
- ) {
62
-
63
- try {
64
- _izContext.logger.debug("<%- functionName %> _izContext", _izContext)
65
- _izContext.logger.debug("<%- functionName %> requestParams", requestParams)
66
- _izContext.logger.debug("<%- functionName %> callingFlowConfig", callingFlowConfig)
67
-
68
- <% if (statusType === "statusField") { %>
69
- <% include(statusFieldTemplate, { tableName:tableName, flowTag: flowTag }) %>
70
- <% } else if (statusType === "storedCache") { %>
71
- <% include(storedCacheTemplate, { tableName:tableName, flowSchemaComplete:flowSchemaComplete, flowTag }) %>
72
- <% } else if (statusType === "triggerCache") { %>
73
- <% include(triggerCacheTemplate, {
74
- tableName: tableName,
75
- flowSchemaComplete: flowSchemaComplete,
76
- triggerType: triggerType,
77
- flowTag,
78
- queueName
79
- }) %>
80
- <% } %>
81
-
82
- //(<endpointHook>)
83
- //(</endpointHook>)
84
-
85
- } catch (err) {
86
- _izContext.logger.error('error WebSocketInvoke: ', err)
87
- throw (err)
88
- }
89
- }
@@ -1,30 +0,0 @@
1
- //(<beforeCheckedStatusField>)
2
- //(</beforeCheckedStatusField>)
3
-
4
- let [status, flowStatusFieldRecord] = await statusFieldSharedLib.checkStatusField(
5
- _izContext,
6
- {
7
- flowTag: "<%- flowTag %>",
8
- serviceTag: process.env.iz_serviceTag
9
- },
10
- {
11
- //(<identifiers>)
12
- //(</identifiers>)
13
- },
14
- //(<errorsFounds>)
15
- //(<errorsFounds>)
16
- //(<overwriteUniqueRequestId>)
17
- //(</overwriteUniqueRequestId>)
18
- )
19
-
20
- //(<afterCheckStatusField>)
21
- //(</afterCheckStatusField>)
22
-
23
- if (status !== "process") {
24
- if (status === "error" || status === "complete") {
25
- //(<afterValidateStatusField>)
26
- //(</afterValidateStatusField>)
27
- }
28
- //(<checkStatusFieldHook>)
29
- //(</checkStatusFieldHook>)
30
- }
@@ -1,26 +0,0 @@
1
- let [ cacheMainStatus, cacheMain, cacheExist ] = await storedCacheSharedLib.checkStoredCacheStatus(
2
- _izContext,
3
- "<%- tableName %>",
4
- {
5
- //(<keyValueStoredCacheTable>)
6
- //(</keyValueStoredCacheTable>)
7
- },
8
- //(<additionalAttributesWhenCreateStoredCache>)
9
- //(</additionalAttributesWhenCreateStoredCache>),
10
- createFlowTypeConcat(_izContext,{flowTag: "<%- flowTag %>", serviceTag: process.env.iz_serviceTag}),
11
- //(<storedCacheConfig>)
12
- //(</storedCacheConfig>)
13
- )
14
-
15
- //(<afterCheckStoredCache>)
16
- //(</afterCheckStoredCache>)
17
-
18
- if (cacheMainStatus !== "process") {
19
- if (cacheMainStatus === "error" || cacheMainStatus === "complete") {
20
- //(<afterValidateStoredCacheStatus>)
21
- //(</afterValidateStoredCacheStatus>)
22
- }
23
-
24
- //(<checkStoredCacheHook>)
25
- //(</checkStoredCacheHook>)
26
- }
@@ -1,44 +0,0 @@
1
- let [triggerCacheStatus, triggerCache] = await triggeredCacheSharedLibV2.checkTriggeredCacheV2(
2
- _izContext,
3
- {
4
- serviceTag: process.env.iz_serviceTag,
5
- flowTag: "<%- flowTag %>"
6
- },
7
- {
8
- //(<identifiersTriggerCacheTable>)
9
- //(</identifiersTriggerCacheTable>)
10
- },
11
- //(<additionalCheckTriggerCacheSetting>)
12
- "", // overWriteUniqueRequestId
13
- {}, //flowParams
14
- false, // createIfNotHave
15
- {} // triggerFlowIdentifiers
16
- //(</additionalCheckTriggerCacheSetting>)
17
- )
18
-
19
- //(<afterCheckTriggerCache>)
20
- //(</afterCheckTriggerCache>)
21
-
22
- if (triggerCacheStatus !== "process") {
23
- if (triggerCacheStatus === "error" || triggerCacheStatus === "complete") {
24
- //(<afterValidateTriggerCacheStatus>)
25
- //(</afterValidateTriggerCacheStatus>)
26
- }
27
- //(<checkTriggerCacheHook>)
28
- //(</checkTriggerCacheHook>)
29
-
30
- // send message to ProcessTriggerCache
31
- }
32
-
33
- //(<processTriggerCacheHook>)
34
- //(</processTriggerCacheHook>)
35
- let sendMessageToProcessTriggerCache = {
36
- MessageBody: JSON.stringify(
37
- //(<messageBody>)
38
- //(</messageBody>)
39
- ),
40
- QueueUrl: await sqsSharedLib.sqsQueueUrl(_izContext, "<%- queueName %>")
41
- }
42
-
43
- await sqs.sendMessage(_izContext, sendMessageToProcessTriggerCache)
44
- _izContext.logger.debug("after send message to <%- queueName %>", sendMessageToProcessTriggerCache)
@@ -1,80 +0,0 @@
1
- // Create S3 Component
2
- import createFunctionYamlCreateObjectWebSocket from './upload/createObject/functionYaml/data.js';
3
- import createHandlerCreateObjectWebSocket from './upload/createObject/handler/data.js';
4
- import createMainFunctionCreateObjectWebSocket from './upload/createObject/mainFunction/data.js';
5
-
6
- // Create PreSigned URL Component
7
- // reservedLimit
8
- import createReservedLimitFunctionYaml from './upload/preSignUrl/reservedLimit/functionYaml/data.js';
9
- import createReservedLimitHandler from './upload/preSignUrl/reservedLimit/handler/data.js';
10
- import createReservedLimitMainFunction from './upload/preSignUrl/reservedLimit/mainFunction/data.js';
11
- import createReservedLimitQueueName from './upload/preSignUrl/reservedLimit/sqs/data.js';
12
- // createPreSignUrl
13
- import createPreSignUrlFunctionYaml from './upload/preSignUrl/createPreSignUrl/functionYaml/data.js';
14
- import createPreSignUrlHandler from './upload/preSignUrl/createPreSignUrl/handler/data.js';
15
- import createPreSignUrlMainFunction from './upload/preSignUrl/createPreSignUrl/mainFunction/data.js';
16
- import createPreSignUrlQueueName from './upload/preSignUrl/createPreSignUrl/queue/data.js';
17
- // Process After Upload S3
18
- import createProcessAfterUploadS3FunctionYmlS3 from './upload/processFile/functionYml/HdrS3/data.js';
19
- import createProcessAfterUploadS3HandlerS3 from './upload/processFile/handler/handlerS3/data.js';
20
- import createProcessAfterUploadS3MainFunction from './upload/processFile/mainFunction/data.js';
21
- // confirm After Upload S3
22
- import createConfirmAfterUploadS3FunctionYaml from './upload/confirmReserved/functionYaml/data.js';
23
- import createConfirmAfterUploadS3Handler from './upload/confirmReserved/handler/data.js';
24
- import createConfirmAfterUploadS3MainFunction from './upload/confirmReserved/mainFunction/data.js';
25
- import createConfirmAfterUploadS3Queue from './upload/confirmReserved/queue/data.js';
26
- // Relate Resources
27
- import createBucketS3 from './upload/relate/S3/data.js';
28
- // Other Resources
29
- import createReservedDataMainTable from './websocket/dynamoDb/ReservedTableData.js';
30
- import createSnsTopicForUploadS3 from './upload/relate/sns-out/data.js';
31
-
32
- //
33
- import createFlowSchemaEndpointMainFunction from './flowSchemaMainFunction/data.js';
34
-
35
- async function createS3Component(_izContext, flowSchema, appPath) {
36
- const component = [
37
- // * Create Object WebSocket
38
- createFunctionYamlCreateObjectWebSocket(_izContext, flowSchema, appPath),
39
- createHandlerCreateObjectWebSocket(_izContext, flowSchema, appPath),
40
- createMainFunctionCreateObjectWebSocket(_izContext, flowSchema, appPath),
41
-
42
- // * PreSigned URL WebSocket
43
- // reservedLimit
44
- await createReservedLimitFunctionYaml(_izContext, flowSchema, appPath),
45
- createReservedLimitHandler(_izContext, flowSchema, appPath),
46
- createReservedLimitMainFunction(_izContext, flowSchema, appPath),
47
- ...createReservedLimitQueueName(_izContext, appPath),
48
-
49
- // createPreSignUrl
50
- createPreSignUrlFunctionYaml(_izContext, flowSchema, appPath),
51
- createPreSignUrlHandler(_izContext, flowSchema, appPath),
52
- createPreSignUrlMainFunction(_izContext, flowSchema, appPath),
53
- ...createPreSignUrlQueueName(_izContext, appPath),
54
-
55
- // * Process After Upload S3
56
- createProcessAfterUploadS3FunctionYmlS3(_izContext, flowSchema, appPath),
57
- createProcessAfterUploadS3HandlerS3(_izContext, flowSchema, appPath),
58
- createProcessAfterUploadS3MainFunction(_izContext, flowSchema, appPath),
59
-
60
- // * confirm After Upload S3
61
- createConfirmAfterUploadS3FunctionYaml(_izContext, flowSchema, appPath),
62
- createConfirmAfterUploadS3Handler(_izContext, flowSchema, appPath),
63
- createConfirmAfterUploadS3MainFunction(_izContext, flowSchema, appPath),
64
- ...createConfirmAfterUploadS3Queue(_izContext, appPath),
65
-
66
- // * Relate Resources
67
- createBucketS3(_izContext, flowSchema, appPath),
68
-
69
- // * Other Resources
70
- ...createReservedDataMainTable(_izContext, appPath),
71
- ...createSnsTopicForUploadS3(_izContext, flowSchema, appPath),
72
-
73
- //
74
- await createFlowSchemaEndpointMainFunction(_izContext, flowSchema, appPath)
75
- ];
76
-
77
- return component.flat();
78
- }
79
-
80
- export default createS3Component;
@@ -1,129 +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
- ACTIONS
40
- } = consts;
41
-
42
- const {
43
- defaultIamRolePerAction,
44
- createIamRole,
45
- resourceNames,
46
- shortNameHandler
47
- } = libs;
48
-
49
- const templatePath = path.join(__dirname, 'template.ejs');
50
-
51
- /**
52
- * receive objectSchema
53
- *
54
- * @param {Object} flowSchema
55
- * @return {{ templatePath, templateData, setting } }
56
- */
57
-
58
- function createSourceParams(_izContext, flowSchema, appPath) {
59
- let functionName = 'ConfirmNewReserved';
60
- let handlerType = upperCase(HANDLER.hdrSqs);
61
- let additionalResourcePermission = defaultIamRolePerAction();
62
-
63
- additionalResourcePermission.push(
64
- createIamRole(
65
- {
66
- [RESOURCE_CLASSES.sqs]: [
67
- SQS_RESOURCE.receiveMessage,
68
- SQS_RESOURCE.sendMessage,
69
- SQS_RESOURCE.deleteMessage,
70
- SQS_RESOURCE.getQueueAttributes
71
- ]
72
- },
73
- [
74
- resourceNames(RESOURCE_CLASSES.sqs, functionName + handlerType),
75
- resourceNames(RESOURCE_CLASSES.sqs, functionName + 'DLQ')
76
- ]
77
- ),
78
- createIamRole(
79
- {
80
- [RESOURCE_CLASSES.dynamoDbTable]: [
81
- DYNAMO_RESOURCE.query,
82
- DYNAMO_RESOURCE.deleteItem,
83
- DYNAMO_RESOURCE.updateItem,
84
- DYNAMO_RESOURCE.putItem
85
- ]
86
- },
87
- [resourceNames(RESOURCE_CLASSES.dynamoDbTable, 'ReservedDataMain')]
88
- ),
89
- createIamRole(
90
- {
91
- [RESOURCE_CLASSES.lambda]: [LAMBDA_RESOURCE.invokeFunction],
92
- [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
93
- },
94
- [
95
- resourceNames(
96
- RESOURCE_CLASSES.lambda,
97
- upperCase(ACTIONS.get) + upperCase(HANDLER.hdrInv)
98
- ),
99
- resourceNames(RESOURCE_CLASSES.sns, upperCase(ACTIONS.update) + '_In')
100
- ]
101
- )
102
- );
103
-
104
- return {
105
- templatePath: templatePath,
106
- templateData: {
107
- functionName,
108
- handlerType,
109
- functionNameConfig: functionName + upperCase(handlerType),
110
- resourceLocation: path.join(
111
- SOURCE_PATH.resourceLocationWebSocket,
112
- flowSchema.flowTag,
113
- 'source/'
114
- ),
115
- additionalResourcePermission,
116
- functionNameConfig:
117
- upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
118
- roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaUploadS3Role
119
- },
120
- setting: {
121
- saveFileName: SAVE_FILE_NAME.flowSchemaYaml,
122
- savePath: path.join(appPath, SOURCE_PATH.appYaml),
123
- fileExtension: '.yml',
124
- isAppend: true
125
- }
126
- };
127
- }
128
-
129
- export default createSourceParams;