@izara_project/izara-core-generate-service-code 1.0.67 → 1.0.69

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 (128) hide show
  1. package/.prettierrc +11 -0
  2. package/package.json +16 -12
  3. package/scripts/format-ejs.js +104 -0
  4. package/src/compile/compileProject.js +40 -9
  5. package/src/compile/loadSchemas.js +120 -11
  6. package/src/emit/crud/emitCrudApplicationArtifacts.js +188 -41
  7. package/src/emit/crud/emitDynamicCrudFlowSchemas.js +34 -18
  8. package/src/emit/crud/generateCrudApplicationArtifacts.js +14 -6
  9. package/src/emit/crud/generateDynamicCrudFlowSchemas.js +4 -1
  10. package/src/emit/crud/templates/CreateEndpoint_Main.ejs +296 -105
  11. package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +222 -144
  12. package/src/emit/crud/templates/FlowEndpointBeforeLogical_Main.ejs +22 -6
  13. package/src/emit/crud/templates/FlowEndpointComplete_Main.ejs +134 -43
  14. package/src/emit/crud/templates/FlowEndpoint_HdrWbs.ejs +51 -31
  15. package/src/emit/crud/templates/FlowHandler_HdrApi.ejs +53 -45
  16. package/src/emit/crud/templates/FlowHandler_HdrInv.ejs +28 -26
  17. package/src/emit/crud/templates/FlowHandler_HdrSqs.ejs +15 -11
  18. package/src/emit/crud/templates/FlowMain_Wbs.ejs +53 -38
  19. package/src/emit/crud/templates/GetEndpoint_Main.ejs +6 -3
  20. package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +2 -2
  21. package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +402 -249
  22. package/src/emit/custom/customFlows.js +68 -28
  23. package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +520 -123
  24. package/src/emit/custom/generateCustomFlowApplicationArtifacts.js +28 -8
  25. package/src/emit/custom/templates/FlowEndpoint_Main.ejs +48 -36
  26. package/src/emit/custom/templates/FlowStep_Main.ejs +7 -9
  27. package/src/emit/custom/templates/s3/ConfirmReserved_HdrSqs.ejs +59 -54
  28. package/src/emit/custom/templates/s3/ConfirmReserved_Main.ejs +33 -23
  29. package/src/emit/custom/templates/s3/CreateObject_HdrWbs.ejs +30 -23
  30. package/src/emit/custom/templates/s3/CreateObject_Main.ejs +56 -39
  31. package/src/emit/custom/templates/s3/CreatePreSignUrl_HdrSqs.ejs +56 -51
  32. package/src/emit/custom/templates/s3/CreatePreSignUrl_Main.ejs +112 -75
  33. package/src/emit/custom/templates/s3/FlowHandler_HdrS3.ejs +14 -9
  34. package/src/emit/custom/templates/s3/ProcessS3File_Main.ejs +11 -8
  35. package/src/emit/custom/templates/s3/ReservedLimit_HdrSqs.ejs +65 -56
  36. package/src/emit/custom/templates/s3/ReservedLimit_Main.ejs +74 -52
  37. package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +58 -14
  38. package/src/emit/custom/templates/triggerCache/CheckTriggerCache_Main.ejs +12 -17
  39. package/src/emit/custom/templates/triggerCache/TriggerCacheComplete_Main.ejs +20 -13
  40. package/src/emit/custom/templates/triggerCache/TriggerCache_Main.ejs +4 -1
  41. package/src/emit/function/functionYamlArtifact.js +272 -79
  42. package/src/emit/function/templates/ApiFunction_Yaml.ejs +7 -0
  43. package/src/emit/function/templates/EventBridgeFunction_Yaml.ejs +6 -0
  44. package/src/emit/function/templates/InvFunction_Yaml.ejs +5 -0
  45. package/src/emit/function/templates/S3Function_Yaml.ejs +16 -0
  46. package/src/emit/function/templates/SqsFunction_Yaml.ejs +10 -0
  47. package/src/emit/function/templates/WbsFunction_Yaml.ejs +10 -0
  48. package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +40 -29
  49. package/src/emit/rbac/emitRbacApplicationArtifacts.js +171 -72
  50. package/src/emit/rbac/generateCreateTargetRoleHandler.js +6 -4
  51. package/src/emit/rbac/generateDynamicRbacFlowSchemas.js +8 -2
  52. package/src/emit/rbac/rbacFlowTag.js +3 -1
  53. package/src/emit/rbac/templates/CreateTargetRole_HdrSqs.ejs +41 -18
  54. package/src/emit/rbac/templates/CreateTargetRole_Main.ejs +23 -3
  55. package/src/emit/rbac/templates/ListRbac_HdrApi.ejs +27 -5
  56. package/src/emit/rbac/templates/ListRbac_HdrSqs.ejs +41 -8
  57. package/src/emit/rbac/templates/ListRbac_Main.ejs +26 -6
  58. package/src/emit/rbac/templates/RbacMutation_Main.ejs +23 -3
  59. package/src/emit/rbac/templates/UserRbacFlow_HdrSqs.ejs +46 -0
  60. package/src/emit/rbac/templates/UserRbacFlow_Main.ejs +152 -33
  61. package/src/emit/rbac/templates/UserRoleMutation_Main.ejs +24 -4
  62. package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +26 -11
  63. package/src/emit/relationship/emitRelationshipApplicationArtifacts.js +179 -37
  64. package/src/emit/relationship/generateDynamicRelationshipFlowSchemas.js +8 -2
  65. package/src/emit/relationship/generateRelationshipApplicationArtifacts.js +15 -6
  66. package/src/emit/relationship/templates/ChangeRelationshipComplete_Main.ejs +64 -37
  67. package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +258 -142
  68. package/src/emit/relationship/templates/CreateRelationshipComplete_Main.ejs +68 -43
  69. package/src/emit/relationship/templates/CreateRelationship_Main.ejs +315 -171
  70. package/src/emit/relationship/templates/DeleteRelationshipComplete_Main.ejs +67 -41
  71. package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +226 -115
  72. package/src/emit/relationship/templates/FlowHandler_HdrApi.ejs +41 -33
  73. package/src/emit/relationship/templates/FlowHandler_HdrDsq.ejs +15 -11
  74. package/src/emit/relationship/templates/FlowHandler_HdrInv.ejs +28 -26
  75. package/src/emit/relationship/templates/FlowHandler_HdrSqs.ejs +15 -11
  76. package/src/emit/relationship/templates/GetRelationshipComplete_Main.ejs +46 -26
  77. package/src/emit/relationship/templates/GetRelationship_Main.ejs +233 -126
  78. package/src/emit/relationship/templates/MoveRelationshipComplete_Main.ejs +72 -44
  79. package/src/emit/relationship/templates/MoveRelationship_Main.ejs +266 -150
  80. package/src/emit/relationship/templates/UpdateRelationshipComplete_Main.ejs +74 -45
  81. package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +285 -152
  82. package/src/emit/resource/emitResourceArtifacts.js +274 -105
  83. package/src/emit/resource/generateResourceArtifacts.js +15 -6
  84. package/src/emit/resource/templates/GeneratedLambdaRoleServiceConfig.ejs +139 -0
  85. package/src/emit/resource/templates/S3Bucket_Yaml.ejs +19 -0
  86. package/src/emit/resource/templates/S3Subscription_Yaml.ejs +7 -0
  87. package/src/emit/resource/templates/WebSocketSubscription_Yaml.ejs +7 -0
  88. package/src/emit/system/emitSystemWebSocketArtifacts.js +61 -165
  89. package/src/emit/system/templates/WebSocketComplete_HdrSqs.ejs +32 -0
  90. package/src/emit/system/templates/WebSocketComplete_Main.ejs +46 -0
  91. package/src/emit/system/templates/WebSocketComplete_Yaml.ejs +19 -0
  92. package/src/emit/system/templates/WebSocketConnect.ejs +25 -0
  93. package/src/emit/system/templates/WebSocketConnect_Yaml.ejs +11 -0
  94. package/src/generate.js +141 -34
  95. package/src/generateIntTest.js +76 -28
  96. package/src/generateResourceIntTest.js +35 -12
  97. package/src/generateResources/IntTest/generateResources/generateResources.js +5 -2
  98. package/src/generateResources/IntTest/generateResources/templateResources.ejs +18 -30
  99. package/src/generateResources/IntTest/generateTests/events/events.js +1 -1
  100. package/src/generateResources/IntTest/generateTests/events/templateEvents.ejs +13 -10
  101. package/src/generateResources/IntTest/generateTests/generateTemplate.js +2 -2
  102. package/src/generateResources/IntTest/generateTests/pathIntTest/pathIntTest.js +2 -1
  103. package/src/generateResources/IntTest/generateTests/pathIntTest/template.ejs +1 -3
  104. package/src/generateResources/IntTest/generateTests/tests/templateTests.ejs +1 -1
  105. package/src/generateResources/IntTest/generateTests/tests/tests.js +7 -3
  106. package/src/generateResources/IntTest/libs/{libs.js → IntTestGenerateLib.js} +34 -23
  107. package/src/generateResources/IntTest/upload/uploadIntTest.js +33 -19
  108. package/src/intTestGeneratorShared.js +15 -10
  109. package/src/output/commitArtifacts.js +99 -39
  110. package/src/output/mergeHooks.js +24 -10
  111. package/src/output/validateArtifacts.js +37 -27
  112. package/src/plan/buildGenerationPlan.js +24 -13
  113. package/test/core.test.js +116 -49
  114. package/test/createTargetRoleHandler.test.js +63 -14
  115. package/test/crudApplicationArtifacts.test.js +128 -23
  116. package/test/customFlowApplicationArtifacts.test.js +391 -84
  117. package/test/dynamicCrudFlowSchemas.test.js +74 -26
  118. package/test/dynamicRbacFlowSchemas.test.js +63 -20
  119. package/test/dynamicRelationshipFlowSchemas.test.js +65 -18
  120. package/test/functionYamlArtifact.test.js +67 -10
  121. package/test/intTestApi.test.js +9 -10
  122. package/test/publicApi.test.js +184 -44
  123. package/test/relationshipApplicationArtifacts.test.js +90 -19
  124. package/test/resourceArtifacts.test.js +183 -33
  125. package/docs/test.png +0 -0
  126. package/src/emit/rbac/templates/UserRbacFlow_HdrInv.ejs +0 -10
  127. package/src/emit/relationship/dynamicRelationshipFlowSchemaTemplate.js +0 -11
  128. /package/docs/{test.mmd → TriggeredCacheFlow.mmd} +0 -0
@@ -1,92 +1,212 @@
1
- import ejs from 'ejs';
1
+ import ejsLib from 'ejs';
2
2
  import { readFile } from 'node:fs/promises';
3
3
 
4
4
  import {
5
5
  renderApiFunctionYaml,
6
6
  renderEventBridgeFunctionYaml,
7
7
  renderInvFunctionYaml,
8
+ renderS3FunctionYaml,
8
9
  renderSqsFunctionYaml,
9
10
  renderWbsFunctionYaml
10
11
  } from '../function/functionYamlArtifact.js';
11
- import { customFlowRoleName, flowDsqSteps, flowExtTopicSteps, generatedOwnTopicFlows, supportedCustomFlows, upperFirst } from './customFlows.js';
12
+ import {
13
+ customFlowRoleName,
14
+ flowDsqSteps,
15
+ flowExtTopicSteps,
16
+ generatedOwnTopicFlows,
17
+ supportedCustomFlows,
18
+ upperFirst
19
+ } from './customFlows.js';
12
20
 
13
21
  const YAML_PATH = 'app/sls_yaml/generatedCode/source/flow-schema.yml';
14
22
  const TEMPLATE_URL = new URL('../crud/templates/', import.meta.url);
15
23
  const CUSTOM_TEMPLATE_URL = new URL('./templates/', import.meta.url);
16
24
  const DSQ_TEMPLATE_URL = new URL('../relationship/templates/', import.meta.url);
17
25
 
18
- export async function emitCustomFlowApplicationArtifacts(flows, { systemFunctions = [], objects = [] } = {}) {
26
+ export async function emitCustomFlowApplicationArtifacts(
27
+ flows,
28
+ { systemFunctions = [], objects = [] } = {}
29
+ ) {
19
30
  const customFlows = supportedCustomFlows(flows);
20
31
  const generatedRoots = generatedOwnTopicFlows(flows);
21
32
  const steps = flowExtTopicSteps(flows);
22
33
  const dsqSteps = flowDsqSteps(flows);
23
- if (customFlows.length === 0 && generatedRoots.length === 0 && steps.length === 0 && dsqSteps.length === 0 && systemFunctions.length === 0) return [];
24
-
25
- const emitted = await Promise.all(customFlows.map(flow => emitFlow(flow, objects)));
26
- const roots = await Promise.all(generatedRoots.map(flow => emitOwnTopicRoot(flow, objects)));
34
+ if (
35
+ customFlows.length === 0 &&
36
+ generatedRoots.length === 0 &&
37
+ steps.length === 0 &&
38
+ dsqSteps.length === 0 &&
39
+ systemFunctions.length === 0
40
+ )
41
+ return [];
42
+
43
+ const emitted = await Promise.all(
44
+ customFlows.map((flow) => emitFlow(flow, objects))
45
+ );
46
+ const roots = await Promise.all(
47
+ generatedRoots.map((flow) => emitOwnTopicRoot(flow, objects))
48
+ );
27
49
  const stepResults = await Promise.all(steps.map(emitExtTopicStep));
28
50
  const dsqStepResults = await Promise.all(dsqSteps.map(emitDsqStep));
29
51
  return [
30
- ...emitted.flatMap(result => result.artifacts),
31
- ...roots.flatMap(result => result.artifacts),
32
- ...stepResults.flatMap(result => result.artifacts),
33
- ...dsqStepResults.flatMap(result => result.artifacts),
34
- { path: YAML_PATH, content: [...systemFunctions, ...emitted.flatMap(result => result.functions), ...roots.flatMap(result => result.functions), ...stepResults.flatMap(result => result.functions), ...dsqStepResults.flatMap(result => result.functions)].join('\n') }
52
+ ...emitted.flatMap((result) => result.artifacts),
53
+ ...roots.flatMap((result) => result.artifacts),
54
+ ...stepResults.flatMap((result) => result.artifacts),
55
+ ...dsqStepResults.flatMap((result) => result.artifacts),
56
+ {
57
+ path: YAML_PATH,
58
+ content: [
59
+ ...systemFunctions,
60
+ ...emitted.flatMap((result) => result.functions),
61
+ ...roots.flatMap((result) => result.functions),
62
+ ...stepResults.flatMap((result) => result.functions),
63
+ ...dsqStepResults.flatMap((result) => result.functions)
64
+ ].join('\n')
65
+ }
35
66
  ];
36
67
  }
37
68
 
38
- export function customFlowApplicationManagedPaths(flows, { includeYaml = false } = {}) {
69
+ export function customFlowApplicationManagedPaths(
70
+ flows,
71
+ { includeYaml = false } = {}
72
+ ) {
39
73
  return [
40
- ...supportedCustomFlows(flows).flatMap(flow => flowPaths(flow)),
74
+ ...supportedCustomFlows(flows).flatMap((flow) => flowPaths(flow)),
41
75
  ...generatedOwnTopicFlows(flows).flatMap(ownTopicRootPaths),
42
76
  ...flowExtTopicSteps(flows).flatMap(({ flowTag, stepName }) => {
43
77
  const source = `app/src/generatedCode/FlowSchemas/${flowTag}/source`;
44
- return [`${source}/${flowTag}${stepName}_Main.js`, `${source}/${flowTag}${stepName}_HdrSqs.js`];
78
+ return [
79
+ `${source}/${flowTag}${stepName}_Main.js`,
80
+ `${source}/${flowTag}${stepName}_HdrSqs.js`
81
+ ];
45
82
  }),
46
83
  ...flowDsqSteps(flows).flatMap(({ flowTag, stepName, step }) => {
47
84
  const source = `app/src/generatedCode/FlowSchemas/${flowTag}/source`;
48
- const stepEvents = Array.isArray(step.event) ? step.event : [];
49
- return [
50
- ...(stepEvents.includes('extTopic') ? [] : [`${source}/${flowTag}${stepName}_Main.js`]),
51
- `${source}/${flowTag}${stepName}_HdrDsq.js`
52
- ];
85
+ let stepEvents = [];
86
+ if (Array.isArray(step.event)) {
87
+ stepEvents = step.event;
88
+ }
89
+ const files = [`${source}/${flowTag}${stepName}_HdrDsq.js`];
90
+ if (!stepEvents.includes('extTopic')) {
91
+ files.unshift(`${source}/${flowTag}${stepName}_Main.js`);
92
+ }
93
+ return files;
53
94
  }),
54
- ...(supportedCustomFlows(flows).length > 0 || generatedOwnTopicFlows(flows).length > 0 || flowExtTopicSteps(flows).length > 0 || flowDsqSteps(flows).length > 0 || includeYaml ? [YAML_PATH] : [])
95
+ ...(supportedCustomFlows(flows).length > 0 ||
96
+ generatedOwnTopicFlows(flows).length > 0 ||
97
+ flowExtTopicSteps(flows).length > 0 ||
98
+ flowDsqSteps(flows).length > 0 ||
99
+ includeYaml
100
+ ? [YAML_PATH]
101
+ : [])
55
102
  ];
56
103
  }
57
104
 
58
-
59
-
60
105
  async function emitFlow(flow, objects) {
61
106
  const tag = upperFirst(flow.flowTag);
62
107
  const process = tag;
63
108
  const source = `app/src/generatedCode/FlowSchemas/${tag}/source`;
64
109
  const handlerRoot = `src/generatedCode/FlowSchemas/${tag}/source`;
65
- const shared = { flowTag: flow.flowTag, flowStepName: '', mainFileName: `${process}_Main`, functionName: process, startConfig: startConfig(flow) };
110
+ const shared = {
111
+ flowTag: flow.flowTag,
112
+ flowStepName: '',
113
+ mainFileName: `${process}_Main`,
114
+ functionName: process,
115
+ startConfig: startConfig(flow)
116
+ };
66
117
  const artifacts = needsProcessMain(flow)
67
- ? [{ path: `${source}/${process}_Main.js`, content: await renderEndpointMain(flow, process, objects) }]
118
+ ? [
119
+ {
120
+ path: `${source}/${process}_Main.js`,
121
+ content: await renderEndpointMain(flow, process, objects)
122
+ }
123
+ ]
68
124
  : [];
69
125
  const functions = [];
70
126
 
71
127
  if (flow.event.includes('extTopic') && !flow.event.includes('ownTopic')) {
72
- artifacts.push({ path: `${source}/${process}_HdrSqs.js`, content: await render('FlowHandler_HdrSqs.ejs', { ...shared, queueName: `${process}HdrSqs` }) });
73
- functions.push(renderSqsFunctionYaml({ functionName: `${process}HdrSqs`, handlerPath: `${handlerRoot}/${process}_HdrSqs.main`, roleName: customFlowRoleName(flow.flowTag), queueName: `${process}HdrSqs`, flowTag: flow.flowTag, flowStepName: '' }));
128
+ artifacts.push({
129
+ path: `${source}/${process}_HdrSqs.js`,
130
+ content: await render('FlowHandler_HdrSqs.ejs', {
131
+ ...shared,
132
+ queueName: `${process}HdrSqs`
133
+ })
134
+ });
135
+ functions.push(
136
+ renderSqsFunctionYaml({
137
+ functionName: `${process}HdrSqs`,
138
+ handlerPath: `${handlerRoot}/${process}_HdrSqs.main`,
139
+ roleName: customFlowRoleName(flow.flowTag),
140
+ queueName: `${process}HdrSqs`,
141
+ flowTag: flow.flowTag,
142
+ flowStepName: ''
143
+ })
144
+ );
74
145
  }
75
146
  if (flow.event.includes('dsq')) {
76
- artifacts.push({ path: `${source}/${process}_HdrDsq.js`, content: await renderDsq('FlowHandler_HdrDsq.ejs', { ...shared, queueName: `${process}HdrDsq` }) });
77
- functions.push(renderSqsFunctionYaml({ functionName: `${process}HdrDsq`, handlerPath: `${handlerRoot}/${process}_HdrDsq.main`, roleName: customFlowRoleName(flow.flowTag), queueName: `${process}HdrDsq`, flowTag: flow.flowTag, flowStepName: '' }));
147
+ artifacts.push({
148
+ path: `${source}/${process}_HdrDsq.js`,
149
+ content: await renderDsq('FlowHandler_HdrDsq.ejs', {
150
+ ...shared,
151
+ queueName: `${process}HdrDsq`
152
+ })
153
+ });
154
+ functions.push(
155
+ renderSqsFunctionYaml({
156
+ functionName: `${process}HdrDsq`,
157
+ handlerPath: `${handlerRoot}/${process}_HdrDsq.main`,
158
+ roleName: customFlowRoleName(flow.flowTag),
159
+ queueName: `${process}HdrDsq`,
160
+ flowTag: flow.flowTag,
161
+ flowStepName: ''
162
+ })
163
+ );
78
164
  }
79
165
  if (flow.event.includes('lambdaSyncInv')) {
80
- artifacts.push({ path: `${source}/${process}_HdrInv.js`, content: await render('FlowHandler_HdrInv.ejs', shared) });
81
- functions.push(renderInvFunctionYaml({ functionName: `${process}HdrInv`, handlerPath: `${handlerRoot}/${process}_HdrInv.main`, roleName: customFlowRoleName(flow.flowTag), flowTag: flow.flowTag, flowStepName: '' }));
166
+ artifacts.push({
167
+ path: `${source}/${process}_HdrInv.js`,
168
+ content: await render('FlowHandler_HdrInv.ejs', shared)
169
+ });
170
+ functions.push(
171
+ renderInvFunctionYaml({
172
+ functionName: `${process}HdrInv`,
173
+ handlerPath: `${handlerRoot}/${process}_HdrInv.main`,
174
+ roleName: customFlowRoleName(flow.flowTag),
175
+ flowTag: flow.flowTag,
176
+ flowStepName: ''
177
+ })
178
+ );
82
179
  }
83
180
  if (flow.event.includes('lambdaSyncApi')) {
84
- artifacts.push({ path: `${source}/${process}_HdrApi.js`, content: await render('FlowHandler_HdrApi.ejs', shared) });
85
- functions.push(renderApiFunctionYaml({ functionName: `${process}HdrApi`, handlerPath: `${handlerRoot}/${process}_HdrApi.main`, roleName: customFlowRoleName(flow.flowTag), flowTag: flow.flowTag, flowStepName: '' }));
181
+ artifacts.push({
182
+ path: `${source}/${process}_HdrApi.js`,
183
+ content: await render('FlowHandler_HdrApi.ejs', shared)
184
+ });
185
+ functions.push(
186
+ renderApiFunctionYaml({
187
+ functionName: `${process}HdrApi`,
188
+ handlerPath: `${handlerRoot}/${process}_HdrApi.main`,
189
+ roleName: customFlowRoleName(flow.flowTag),
190
+ flowTag: flow.flowTag,
191
+ flowStepName: ''
192
+ })
193
+ );
86
194
  }
87
195
  if (flow.event.includes('eventBridge')) {
88
- artifacts.push({ path: `${source}/${process}_HdrInv.js`, content: await render('FlowHandler_HdrInv.ejs', shared) });
89
- functions.push(renderEventBridgeFunctionYaml({ functionName: `${process}HdrInv`, handlerPath: `${handlerRoot}/${process}_HdrInv.main`, roleName: customFlowRoleName(flow.flowTag), flowTag: flow.flowTag, flowStepName: '', schedules: flow.schedules ?? [] }));
196
+ artifacts.push({
197
+ path: `${source}/${process}_HdrInv.js`,
198
+ content: await render('FlowHandler_HdrInv.ejs', shared)
199
+ });
200
+ functions.push(
201
+ renderEventBridgeFunctionYaml({
202
+ functionName: `${process}HdrInv`,
203
+ handlerPath: `${handlerRoot}/${process}_HdrInv.main`,
204
+ roleName: customFlowRoleName(flow.flowTag),
205
+ flowTag: flow.flowTag,
206
+ flowStepName: '',
207
+ schedules: flow.schedules ?? []
208
+ })
209
+ );
90
210
  }
91
211
  if (flow.event.includes('ownTopic')) {
92
212
  const root = await emitOwnTopicRoot(flow, objects);
@@ -105,17 +225,48 @@ function flowPaths(flow) {
105
225
  const tag = upperFirst(flow.flowTag);
106
226
  const process = tag;
107
227
  const source = `app/src/generatedCode/FlowSchemas/${tag}/source`;
108
- const paths = needsProcessMain(flow) ? [`${source}/${process}_Main.js`] : [];
109
- if (flow.event.includes('extTopic') && !flow.event.includes('ownTopic')) paths.push(`${source}/${process}_HdrSqs.js`);
110
- if (flow.event.includes('dsq')) paths.push(`${source}/${process}_HdrDsq.js`);
111
- if (flow.event.includes('lambdaSyncInv') || flow.event.includes('eventBridge')) paths.push(`${source}/${process}_HdrInv.js`);
112
- if (flow.event.includes('lambdaSyncApi')) paths.push(`${source}/${process}_HdrApi.js`);
113
- if (flow.event.includes('ownTopic')) paths.push(...ownTopicRootPaths(flow));
228
+ const paths = [];
229
+ if (needsProcessMain(flow)) {
230
+ paths.push(`${source}/${process}_Main.js`);
231
+ }
232
+ if (flow.event.includes('extTopic') && !flow.event.includes('ownTopic')) {
233
+ paths.push(`${source}/${process}_HdrSqs.js`);
234
+ }
235
+ if (flow.event.includes('dsq')) {
236
+ paths.push(`${source}/${process}_HdrDsq.js`);
237
+ }
238
+ if (
239
+ flow.event.includes('lambdaSyncInv') ||
240
+ flow.event.includes('eventBridge')
241
+ ) {
242
+ paths.push(`${source}/${process}_HdrInv.js`);
243
+ }
244
+ if (flow.event.includes('lambdaSyncApi')) {
245
+ paths.push(`${source}/${process}_HdrApi.js`);
246
+ }
247
+ if (flow.event.includes('ownTopic')) {
248
+ paths.push(...ownTopicRootPaths(flow));
249
+ }
114
250
  if (flow.event.includes('s3')) {
115
- ['ConfirmAfterUpload', 'CreateObject', 'CreatePreSignUrl', 'ProcessAfterUpload', 'ReservedLimit'].forEach(action => {
116
- const handler = action === 'CreateObject' ? 'HdrWbs' : action === 'ProcessAfterUpload' ? 'HdrS3' : 'HdrSqs';
117
- paths.push(`${source}/${tag}${action}_Main.js`, `${source}/${tag}${action}_${handler}.js`);
118
- });
251
+ const s3Actions = [
252
+ 'ConfirmAfterUpload',
253
+ 'CreateObject',
254
+ 'CreatePreSignUrl',
255
+ 'ProcessAfterUpload',
256
+ 'ReservedLimit'
257
+ ];
258
+ for (const action of s3Actions) {
259
+ let handler = 'HdrSqs';
260
+ if (action === 'CreateObject') {
261
+ handler = 'HdrWbs';
262
+ } else if (action === 'ProcessAfterUpload') {
263
+ handler = 'HdrS3';
264
+ }
265
+ paths.push(
266
+ `${source}/${tag}${action}_Main.js`,
267
+ `${source}/${tag}${action}_${handler}.js`
268
+ );
269
+ }
119
270
  }
120
271
  return paths;
121
272
  }
@@ -123,42 +274,85 @@ function flowPaths(flow) {
123
274
  async function emitExtTopicStep({ flow, step, flowTag, stepName }) {
124
275
  const source = `app/src/generatedCode/FlowSchemas/${flowTag}/source`;
125
276
  const handlerRoot = `src/generatedCode/FlowSchemas/${flowTag}/source`;
126
- const functionName = `${flowTag}${stepName}`;
277
+ const functionName = stepName.startsWith(flowTag)
278
+ ? stepName
279
+ : `${flowTag}${stepName}`;
127
280
  const mainFileName = `${functionName}_Main`;
128
281
  const startConfig = stepConfig(flow, step);
129
282
 
130
- if (step.checkTriggerType === 'flowType') {
131
- const completeStep = flow.flowSteps?.find(s => s.checkTriggerType === 'complete');
132
- const completeStepName = completeStep ? completeStep.stepName : undefined;
133
- const queueName = `${functionName}HdrSqs`;
134
- return {
135
- artifacts: [
136
- { path: `${source}/${mainFileName}.js`, content: await renderCustom('triggerCache/CheckTriggerCache_Main.ejs', { functionName, flowTag }) },
137
- { path: `${source}/${functionName}_HdrSqs.js`, content: await renderCustom('triggerCache/CheckTriggerCache_HdrSqs.ejs', { functionName, queueName }) }
138
- ],
139
- functions: [renderSqsFunctionYaml({ functionName: queueName, handlerPath: `${handlerRoot}/${functionName}_HdrSqs.main`, roleName: customFlowRoleName(flow.flowTag), queueName, flowTag, flowStepName: step.stepName, targetCompleteStepName: completeStepName })]
140
- };
141
- } else if (step.checkTriggerType === 'complete') {
283
+ const hasTriggerFlowTypes =
284
+ Array.isArray(flow.triggerFlowTypes) && flow.triggerFlowTypes.length > 0;
285
+ const isCheckStep = stepName.toLowerCase().includes('checktrigger');
286
+
287
+ if (isCheckStep && hasTriggerFlowTypes) {
142
288
  const queueName = `${functionName}HdrSqs`;
143
289
  return {
144
290
  artifacts: [
145
- { path: `${source}/${mainFileName}.js`, content: await renderCustom('triggerCache/TriggerCacheComplete_Main.ejs', { functionName, flowTag }) },
146
- { path: `${source}/${functionName}_HdrSqs.js`, content: await render('FlowHandler_HdrSqs.ejs', { flowTag: flow.flowTag, flowStepName: step.stepName, functionName, mainFileName, startConfig, queueName, usePassBack: false }) }
291
+ {
292
+ path: `${source}/${mainFileName}.js`,
293
+ content: await renderCustom(
294
+ 'triggerCache/CheckTriggerCache_Main.ejs',
295
+ { functionName, flowTag }
296
+ )
297
+ },
298
+ {
299
+ path: `${source}/${functionName}_HdrSqs.js`,
300
+ content: await renderCustom(
301
+ 'triggerCache/CheckTriggerCache_HdrSqs.ejs',
302
+ { functionName, queueName, startConfig }
303
+ )
304
+ }
147
305
  ],
148
- functions: [renderSqsFunctionYaml({ functionName: queueName, handlerPath: `${handlerRoot}/${functionName}_HdrSqs.main`, roleName: customFlowRoleName(flow.flowTag), queueName, flowTag, flowStepName: step.stepName })]
306
+ functions: [
307
+ renderSqsFunctionYaml({
308
+ functionName: queueName,
309
+ handlerPath: `${handlerRoot}/${functionName}_HdrSqs.main`,
310
+ roleName: customFlowRoleName(flow.flowTag),
311
+ queueName,
312
+ flowTag,
313
+ flowStepName: step.stepName
314
+ })
315
+ ]
149
316
  };
150
317
  }
151
318
 
152
- const artifacts = [{ path: `${source}/${mainFileName}.js`, content: await renderStepMain(functionName) }];
319
+ const artifacts = [
320
+ {
321
+ path: `${source}/${mainFileName}.js`,
322
+ content: await renderStepMain(functionName)
323
+ }
324
+ ];
153
325
  const functions = [];
154
326
 
155
- const stepEvents = Array.isArray(step.event) ? step.event : [];
327
+ let stepEvents = [];
328
+ if (Array.isArray(step.event)) {
329
+ stepEvents = step.event;
330
+ }
156
331
  const hasSqs = stepEvents.includes('extTopic') || stepEvents.includes('sqs');
157
332
 
158
333
  if (hasSqs) {
159
334
  const queueName = `${functionName}HdrSqs`;
160
- artifacts.push({ path: `${source}/${functionName}_HdrSqs.js`, content: await render('FlowHandler_HdrSqs.ejs', { flowTag: flow.flowTag, flowStepName: step.stepName, functionName, mainFileName, startConfig, queueName }) });
161
- functions.push(renderSqsFunctionYaml({ functionName: queueName, handlerPath: `${handlerRoot}/${functionName}_HdrSqs.main`, roleName: customFlowRoleName(flow.flowTag), queueName, flowTag, flowStepName: step.stepName }));
335
+ artifacts.push({
336
+ path: `${source}/${functionName}_HdrSqs.js`,
337
+ content: await render('FlowHandler_HdrSqs.ejs', {
338
+ flowTag: flow.flowTag,
339
+ flowStepName: step.stepName,
340
+ functionName,
341
+ mainFileName,
342
+ startConfig,
343
+ queueName
344
+ })
345
+ });
346
+ functions.push(
347
+ renderSqsFunctionYaml({
348
+ functionName: queueName,
349
+ handlerPath: `${handlerRoot}/${functionName}_HdrSqs.main`,
350
+ roleName: customFlowRoleName(flow.flowTag),
351
+ queueName,
352
+ flowTag,
353
+ flowStepName: step.stepName
354
+ })
355
+ );
162
356
  }
163
357
 
164
358
  return { artifacts, functions };
@@ -171,16 +365,44 @@ async function emitDsqStep({ flow, step, flowTag, stepName }) {
171
365
  const mainFileName = `${functionName}_Main`;
172
366
  const startConfig = stepConfig(flow, step);
173
367
 
174
- const stepEvents = Array.isArray(step.event) ? step.event : [];
175
- const artifacts = stepEvents.includes('extTopic') ? [] : [{ path: `${source}/${mainFileName}.js`, content: await renderStepMain(functionName) }];
368
+ let stepEvents = [];
369
+ if (Array.isArray(step.event)) {
370
+ stepEvents = step.event;
371
+ }
372
+ const artifacts = [];
373
+ if (!stepEvents.includes('extTopic')) {
374
+ artifacts.push({
375
+ path: `${source}/${mainFileName}.js`,
376
+ content: await renderStepMain(functionName)
377
+ });
378
+ }
176
379
  const functions = [];
177
380
 
178
381
  const hasDsq = stepEvents.includes('dsq');
179
382
 
180
383
  if (hasDsq) {
181
384
  const queueName = `${functionName}HdrDsq`;
182
- artifacts.push({ path: `${source}/${functionName}_HdrDsq.js`, content: await renderDsq('FlowHandler_HdrDsq.ejs', { flowTag: flow.flowTag, flowStepName: step.stepName, functionName, mainFileName, startConfig, queueName }) });
183
- functions.push(renderSqsFunctionYaml({ functionName: queueName, handlerPath: `${handlerRoot}/${functionName}_HdrDsq.main`, roleName: customFlowRoleName(flow.flowTag), queueName, flowTag, flowStepName: step.stepName }));
385
+ artifacts.push({
386
+ path: `${source}/${functionName}_HdrDsq.js`,
387
+ content: await renderDsq('FlowHandler_HdrDsq.ejs', {
388
+ flowTag: flow.flowTag,
389
+ flowStepName: step.stepName,
390
+ functionName,
391
+ mainFileName,
392
+ startConfig,
393
+ queueName
394
+ })
395
+ });
396
+ functions.push(
397
+ renderSqsFunctionYaml({
398
+ functionName: queueName,
399
+ handlerPath: `${handlerRoot}/${functionName}_HdrDsq.main`,
400
+ roleName: customFlowRoleName(flow.flowTag),
401
+ queueName,
402
+ flowTag,
403
+ flowStepName: step.stepName
404
+ })
405
+ );
184
406
  }
185
407
 
186
408
  return { artifacts, functions };
@@ -192,17 +414,61 @@ async function emitOwnTopicRoot(flow, objects) {
192
414
  const handlerRoot = `src/generatedCode/FlowSchemas/${tag}/source`;
193
415
  const mainFileName = `${tag}_Main`;
194
416
  const wbsMainFileName = `${tag}_WbsMain`;
195
- const shared = { flowTag: flow.flowTag, flowStepName: '', upperCaseFlowTag: tag, startConfig: startConfig(flow) };
417
+ const shared = {
418
+ flowTag: flow.flowTag,
419
+ flowStepName: '',
420
+ upperCaseFlowTag: tag,
421
+ startConfig: startConfig(flow)
422
+ };
196
423
  return {
197
424
  artifacts: [
198
- { path: `${source}/${mainFileName}.js`, content: await renderEndpointMain(flow, mainFileName, objects) },
199
- { path: `${source}/${tag}_HdrSqs.js`, content: await render('FlowHandler_HdrSqs.ejs', { ...shared, functionName: mainFileName, mainFileName, queueName: `${tag}HdrSqs` }) },
200
- { path: `${source}/${wbsMainFileName}.js`, content: await render('FlowMain_Wbs.ejs', { ...shared, functionName: wbsMainFileName }) },
201
- { path: `${source}/${tag}_HdrWbs.js`, content: await render('FlowEndpoint_HdrWbs.ejs', { ...shared, functionName: tag, mainFileName: wbsMainFileName, route: tag }) }
425
+ {
426
+ path: `${source}/${mainFileName}.js`,
427
+ content: await renderEndpointMain(flow, mainFileName, objects)
428
+ },
429
+ {
430
+ path: `${source}/${tag}_HdrSqs.js`,
431
+ content: await render('FlowHandler_HdrSqs.ejs', {
432
+ ...shared,
433
+ functionName: mainFileName,
434
+ mainFileName,
435
+ queueName: `${tag}HdrSqs`
436
+ })
437
+ },
438
+ {
439
+ path: `${source}/${wbsMainFileName}.js`,
440
+ content: await render('FlowMain_Wbs.ejs', {
441
+ ...shared,
442
+ functionName: wbsMainFileName
443
+ })
444
+ },
445
+ {
446
+ path: `${source}/${tag}_HdrWbs.js`,
447
+ content: await render('FlowEndpoint_HdrWbs.ejs', {
448
+ ...shared,
449
+ functionName: tag,
450
+ mainFileName: wbsMainFileName,
451
+ route: tag
452
+ })
453
+ }
202
454
  ],
203
455
  functions: [
204
- renderWbsFunctionYaml({ functionName: `${tag}HdrWbs`, handlerPath: `${handlerRoot}/${tag}_HdrWbs.main`, roleName: customFlowRoleName(flow.flowTag), routeName: tag, flowTag: flow.flowTag, flowStepName: '' }),
205
- renderSqsFunctionYaml({ functionName: `${tag}HdrSqs`, handlerPath: `${handlerRoot}/${tag}_HdrSqs.main`, roleName: customFlowRoleName(flow.flowTag), queueName: `${tag}HdrSqs`, flowTag: flow.flowTag, flowStepName: '' })
456
+ renderWbsFunctionYaml({
457
+ functionName: `${tag}HdrWbs`,
458
+ handlerPath: `${handlerRoot}/${tag}_HdrWbs.main`,
459
+ roleName: customFlowRoleName(flow.flowTag),
460
+ routeName: tag,
461
+ flowTag: flow.flowTag,
462
+ flowStepName: ''
463
+ }),
464
+ renderSqsFunctionYaml({
465
+ functionName: `${tag}HdrSqs`,
466
+ handlerPath: `${handlerRoot}/${tag}_HdrSqs.main`,
467
+ roleName: customFlowRoleName(flow.flowTag),
468
+ queueName: `${tag}HdrSqs`,
469
+ flowTag: flow.flowTag,
470
+ flowStepName: ''
471
+ })
206
472
  ]
207
473
  };
208
474
  }
@@ -210,75 +476,187 @@ async function emitOwnTopicRoot(flow, objects) {
210
476
  function ownTopicRootPaths(flow) {
211
477
  const tag = upperFirst(flow.flowTag);
212
478
  const source = `app/src/generatedCode/FlowSchemas/${tag}/source`;
213
- return [`${source}/${tag}_Main.js`, `${source}/${tag}_HdrSqs.js`, `${source}/${tag}_WbsMain.js`, `${source}/${tag}_HdrWbs.js`];
479
+ return [
480
+ `${source}/${tag}_Main.js`,
481
+ `${source}/${tag}_HdrSqs.js`,
482
+ `${source}/${tag}_WbsMain.js`,
483
+ `${source}/${tag}_HdrWbs.js`
484
+ ];
214
485
  }
215
486
 
216
487
  function needsProcessMain(flow) {
217
- return !isS3Only(flow) && !flow.event.includes('ownTopic') && flow.event.some(event => event !== 'ownTopic' && event !== 's3');
488
+ return (
489
+ !isS3Only(flow) &&
490
+ !flow.event.includes('ownTopic') &&
491
+ flow.event.some((event) => event !== 'ownTopic' && event !== 's3')
492
+ );
218
493
  }
219
494
 
220
495
  async function emitS3Flow(flow, source, handlerRoot) {
221
496
  const tag = upperFirst(flow.flowTag);
222
497
  const roleName = customFlowRoleName(flow.flowTag);
223
498
  const parts = [
224
- { action: 'CreateObject', handler: 'HdrWbs', type: 'wbs', mainTemplate: 'CreateObject_Main.ejs', handlerTemplate: 'CreateObject_HdrWbs.ejs' },
225
- { action: 'ReservedLimit', handler: 'HdrSqs', type: 'sqs', mainTemplate: 'ReservedLimit_Main.ejs', handlerTemplate: 'ReservedLimit_HdrSqs.ejs' },
226
- { action: 'CreatePreSignUrl', handler: 'HdrSqs', type: 'sqs', mainTemplate: 'CreatePreSignUrl_Main.ejs', handlerTemplate: 'CreatePreSignUrl_HdrSqs.ejs' },
227
- { action: 'ProcessAfterUpload', handler: 'HdrS3', type: 'inv', mainTemplate: 'ProcessS3File_Main.ejs', handlerTemplate: 'FlowHandler_HdrS3.ejs' },
228
- { action: 'ConfirmAfterUpload', handler: 'HdrSqs', type: 'sqs', mainTemplate: 'ConfirmReserved_Main.ejs', handlerTemplate: 'ConfirmReserved_HdrSqs.ejs' }
499
+ {
500
+ action: 'CreateObject',
501
+ handler: 'HdrWbs',
502
+ type: 'wbs',
503
+ mainTemplate: 'CreateObject_Main.ejs',
504
+ handlerTemplate: 'CreateObject_HdrWbs.ejs'
505
+ },
506
+ {
507
+ action: 'ReservedLimit',
508
+ handler: 'HdrSqs',
509
+ type: 'sqs',
510
+ mainTemplate: 'ReservedLimit_Main.ejs',
511
+ handlerTemplate: 'ReservedLimit_HdrSqs.ejs'
512
+ },
513
+ {
514
+ action: 'CreatePreSignUrl',
515
+ handler: 'HdrSqs',
516
+ type: 'sqs',
517
+ mainTemplate: 'CreatePreSignUrl_Main.ejs',
518
+ handlerTemplate: 'CreatePreSignUrl_HdrSqs.ejs'
519
+ },
520
+ {
521
+ action: 'ProcessAfterUpload',
522
+ handler: 'HdrS3',
523
+ type: 's3',
524
+ mainTemplate: 'ProcessS3File_Main.ejs',
525
+ handlerTemplate: 'FlowHandler_HdrS3.ejs'
526
+ },
527
+ {
528
+ action: 'ConfirmAfterUpload',
529
+ handler: 'HdrSqs',
530
+ type: 'sqs',
531
+ mainTemplate: 'ConfirmReserved_Main.ejs',
532
+ handlerTemplate: 'ConfirmReserved_HdrSqs.ejs'
533
+ }
229
534
  ];
230
- const emitted = await Promise.all(parts.map(async ({ action, handler, type, mainTemplate, handlerTemplate }) => {
231
- const functionName = `${tag}${action}`;
232
- const mainFileName = `${functionName}_Main`;
233
- const handlerFileName = `${functionName}_${handler}`;
234
- const mainContent = await renderCustom(`s3/${mainTemplate}`, s3TemplateData({ action, flow, functionName }));
235
- const handlerContent = await renderCustom(`s3/${handlerTemplate}`, s3HandlerData({ action, flow, functionName, mainFileName, handler }));
236
- const descriptor = { functionName: `${functionName}${handler}`, handlerPath: `${handlerRoot}/${handlerFileName}.main`, roleName };
237
- const functionYaml = type === 'wbs'
238
- ? renderWbsFunctionYaml({ ...descriptor, routeName: tag, flowTag: flow.flowTag, flowStepName: '' })
239
- : type === 'sqs'
240
- ? renderSqsFunctionYaml({ ...descriptor, queueName: handlerFileName, flowTag: flow.flowTag, flowStepName: '' })
241
- : renderInvFunctionYaml({ ...descriptor, flowTag: flow.flowTag, flowStepName: '' });
242
- return {
243
- artifacts: [
244
- { path: `${source}/${mainFileName}.js`, content: mainContent },
245
- { path: `${source}/${handlerFileName}.js`, content: handlerContent }
246
- ],
247
- functionYaml
248
- };
249
- }));
250
- return { artifacts: emitted.flatMap(item => item.artifacts), functions: emitted.map(item => item.functionYaml) };
535
+ const emitted = await Promise.all(
536
+ parts.map(
537
+ async ({ action, handler, type, mainTemplate, handlerTemplate }) => {
538
+ const functionName = `${tag}${action}`;
539
+ const mainFileName = `${functionName}_Main`;
540
+ const handlerFileName = `${functionName}_${handler}`;
541
+ const mainContent = await renderCustom(
542
+ `s3/${mainTemplate}`,
543
+ _s3TemplateData({ action, flow, functionName })
544
+ );
545
+ const handlerContent = await renderCustom(
546
+ `s3/${handlerTemplate}`,
547
+ _s3HandlerData({ action, flow, functionName, mainFileName, handler })
548
+ );
549
+ const descriptor = {
550
+ functionName: `${functionName}${handler}`,
551
+ handlerPath: `${handlerRoot}/${handlerFileName}.main`,
552
+ roleName
553
+ };
554
+ let functionYaml;
555
+ if (type === 'wbs') {
556
+ functionYaml = renderWbsFunctionYaml({
557
+ ...descriptor,
558
+ routeName: tag,
559
+ flowTag: flow.flowTag,
560
+ flowStepName: ''
561
+ });
562
+ } else if (type === 'sqs') {
563
+ functionYaml = renderSqsFunctionYaml({
564
+ ...descriptor,
565
+ queueName: descriptor.functionName,
566
+ flowTag: flow.flowTag,
567
+ flowStepName: ''
568
+ });
569
+ } else if (type === 's3') {
570
+ let bucketName = '';
571
+ if (flow.bucketName) {
572
+ bucketName = flow.bucketName;
573
+ }
574
+ functionYaml = renderS3FunctionYaml({
575
+ ...descriptor,
576
+ bucketName,
577
+ flowTag: flow.flowTag,
578
+ flowStepName: ''
579
+ });
580
+ } else {
581
+ functionYaml = renderInvFunctionYaml({
582
+ ...descriptor,
583
+ flowTag: flow.flowTag,
584
+ flowStepName: ''
585
+ });
586
+ }
587
+ return {
588
+ artifacts: [
589
+ { path: `${source}/${mainFileName}.js`, content: mainContent },
590
+ { path: `${source}/${handlerFileName}.js`, content: handlerContent }
591
+ ],
592
+ functionYaml
593
+ };
594
+ }
595
+ )
596
+ );
597
+ return {
598
+ artifacts: emitted.flatMap((item) => item.artifacts),
599
+ functions: emitted.map((item) => item.functionYaml)
600
+ };
251
601
  }
252
602
 
253
- function s3TemplateData({ action, flow, functionName }) {
254
- return action === 'CreateObject'
255
- ? { flowTag: flow.flowTag, objectType: flow.objType?.objectType, functionName }
256
- : action === 'CreatePreSignUrl'
257
- ? { flowTag: flow.flowTag }
258
- : { flowTag: flow.flowTag, functionName };
603
+ function _s3TemplateData({ action, flow, functionName }) {
604
+ if (action === 'CreateObject') {
605
+ return {
606
+ flowTag: flow.flowTag,
607
+ objectType: flow.objType?.objectType,
608
+ functionName
609
+ };
610
+ }
611
+ if (action === 'CreatePreSignUrl') {
612
+ return { flowTag: flow.flowTag };
613
+ }
614
+ return { flowTag: flow.flowTag, functionName };
259
615
  }
260
616
 
261
- function s3HandlerData({ action, flow, functionName, mainFileName, handler }) {
262
- if (action === 'CreateObject') return { functionName, handlerType: handler, route: flow.flowTag };
263
- if (action === 'ProcessAfterUpload') return { flowTag: flow.flowTag, functionName, mainFileName, s3Bucket: flow.bucketName ?? '' };
617
+ function _s3HandlerData({ action, flow, functionName, mainFileName, handler }) {
618
+ if (action === 'CreateObject') {
619
+ return { functionName, handlerType: handler, route: flow.flowTag };
620
+ }
621
+ if (action === 'ProcessAfterUpload') {
622
+ let bucketName = '';
623
+ if (flow.bucketName) {
624
+ bucketName = flow.bucketName;
625
+ }
626
+ return {
627
+ flowTag: flow.flowTag,
628
+ functionName,
629
+ mainFileName,
630
+ s3Bucket: bucketName
631
+ };
632
+ }
264
633
  return { functionName, handlerType: handler };
265
634
  }
266
635
 
267
636
  function startConfig(flow) {
268
- const start = flow.flowSteps?.find(step => step.stepName?.toLowerCase() === 'start');
269
- return start ? stepConfig(flow, start) : null;
637
+ const start = flow.flowSteps?.[0];
638
+ if (start) {
639
+ return stepConfig(flow, start);
640
+ }
641
+ return null;
270
642
  }
271
643
 
272
644
  function stepConfig(flow, step) {
273
645
  return {
274
646
  ...step,
275
647
  properties: mapFields(step.properties, flow.stepProperties),
276
- messageAttributes: mapFields(step.messageAttributes, flow.stepMessageAttributes)
648
+ messageAttributes: mapFields(
649
+ step.messageAttributes,
650
+ flow.stepMessageAttributes
651
+ )
277
652
  };
278
653
  }
279
654
 
280
655
  function mapFields(names = [], definitions = {}) {
281
- return names.map(name => ({ propertyName: name, ...(definitions?.[name] ?? {}) }));
656
+ return names.map((name) => ({
657
+ propertyName: name,
658
+ ...(definitions?.[name] ?? {})
659
+ }));
282
660
  }
283
661
 
284
662
  function isS3Only(flow) {
@@ -297,11 +675,19 @@ async function renderEndpointMain(flow, functionName, objects) {
297
675
 
298
676
  function storedCacheTableName(flow, objects) {
299
677
  if (flow.statusType !== 'storedCache') return null;
300
- const candidates = objects.filter(object => object.objectType === flow.objType?.objectType);
678
+ const candidates = objects.filter(
679
+ (object) => object.objectType === flow.objType?.objectType
680
+ );
301
681
  const object = flow.objType?.serviceTag
302
- ? candidates.find(object => object.serviceTag === flow.objType.serviceTag) ?? candidates.find(object => object.serviceTag === undefined)
682
+ ? (candidates.find(
683
+ (object) => object.serviceTag === flow.objType.serviceTag
684
+ ) ?? candidates.find((object) => object.serviceTag === undefined))
303
685
  : candidates[0];
304
- return Object.values(object?.storageResources ?? {}).find(resource => resource?.storageType === 'dynamoDB')?.tableName ?? null;
686
+ return (
687
+ Object.values(object?.storageResources ?? {}).find(
688
+ (resource) => resource?.storageType === 'dynamoDB'
689
+ )?.tableName ?? null
690
+ );
305
691
  }
306
692
 
307
693
  async function renderStepMain(functionName) {
@@ -313,13 +699,24 @@ function renderMain(functionName) {
313
699
  }
314
700
 
315
701
  async function render(templateName, data) {
316
- return ejs.render(await readFile(new URL(templateName, TEMPLATE_URL), 'utf8'), data);
702
+ return ejsLib.render(
703
+ await readFile(new URL(templateName, TEMPLATE_URL), 'utf8'),
704
+ data
705
+ );
317
706
  }
318
707
 
319
708
  async function renderDsq(templateName, data) {
320
- return ejs.render(await readFile(new URL(templateName, DSQ_TEMPLATE_URL), 'utf8'), data);
709
+ return ejsLib.render(
710
+ await readFile(new URL(templateName, DSQ_TEMPLATE_URL), 'utf8'),
711
+ data
712
+ );
321
713
  }
322
714
 
323
715
  async function renderCustom(templateName, data) {
324
- return ejs.render(await readFile(new URL(templateName, CUSTOM_TEMPLATE_URL), 'utf8'), data).replace(/\n$/, '');
716
+ return ejsLib
717
+ .render(
718
+ await readFile(new URL(templateName, CUSTOM_TEMPLATE_URL), 'utf8'),
719
+ data
720
+ )
721
+ .replace(/\n$/, '');
325
722
  }