@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.
- package/.prettierrc +11 -0
- package/package.json +16 -12
- package/scripts/format-ejs.js +104 -0
- package/src/compile/compileProject.js +40 -9
- package/src/compile/loadSchemas.js +120 -11
- package/src/emit/crud/emitCrudApplicationArtifacts.js +188 -41
- package/src/emit/crud/emitDynamicCrudFlowSchemas.js +34 -18
- package/src/emit/crud/generateCrudApplicationArtifacts.js +14 -6
- package/src/emit/crud/generateDynamicCrudFlowSchemas.js +4 -1
- package/src/emit/crud/templates/CreateEndpoint_Main.ejs +296 -105
- package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +222 -144
- package/src/emit/crud/templates/FlowEndpointBeforeLogical_Main.ejs +22 -6
- package/src/emit/crud/templates/FlowEndpointComplete_Main.ejs +134 -43
- package/src/emit/crud/templates/FlowEndpoint_HdrWbs.ejs +51 -31
- package/src/emit/crud/templates/FlowHandler_HdrApi.ejs +53 -45
- package/src/emit/crud/templates/FlowHandler_HdrInv.ejs +28 -26
- package/src/emit/crud/templates/FlowHandler_HdrSqs.ejs +15 -11
- package/src/emit/crud/templates/FlowMain_Wbs.ejs +53 -38
- package/src/emit/crud/templates/GetEndpoint_Main.ejs +6 -3
- package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +2 -2
- package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +402 -249
- package/src/emit/custom/customFlows.js +68 -28
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +520 -123
- package/src/emit/custom/generateCustomFlowApplicationArtifacts.js +28 -8
- package/src/emit/custom/templates/FlowEndpoint_Main.ejs +48 -36
- package/src/emit/custom/templates/FlowStep_Main.ejs +7 -9
- package/src/emit/custom/templates/s3/ConfirmReserved_HdrSqs.ejs +59 -54
- package/src/emit/custom/templates/s3/ConfirmReserved_Main.ejs +33 -23
- package/src/emit/custom/templates/s3/CreateObject_HdrWbs.ejs +30 -23
- package/src/emit/custom/templates/s3/CreateObject_Main.ejs +56 -39
- package/src/emit/custom/templates/s3/CreatePreSignUrl_HdrSqs.ejs +56 -51
- package/src/emit/custom/templates/s3/CreatePreSignUrl_Main.ejs +112 -75
- package/src/emit/custom/templates/s3/FlowHandler_HdrS3.ejs +14 -9
- package/src/emit/custom/templates/s3/ProcessS3File_Main.ejs +11 -8
- package/src/emit/custom/templates/s3/ReservedLimit_HdrSqs.ejs +65 -56
- package/src/emit/custom/templates/s3/ReservedLimit_Main.ejs +74 -52
- package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +58 -14
- package/src/emit/custom/templates/triggerCache/CheckTriggerCache_Main.ejs +12 -17
- package/src/emit/custom/templates/triggerCache/TriggerCacheComplete_Main.ejs +20 -13
- package/src/emit/custom/templates/triggerCache/TriggerCache_Main.ejs +4 -1
- package/src/emit/function/functionYamlArtifact.js +272 -79
- package/src/emit/function/templates/ApiFunction_Yaml.ejs +7 -0
- package/src/emit/function/templates/EventBridgeFunction_Yaml.ejs +6 -0
- package/src/emit/function/templates/InvFunction_Yaml.ejs +5 -0
- package/src/emit/function/templates/S3Function_Yaml.ejs +16 -0
- package/src/emit/function/templates/SqsFunction_Yaml.ejs +10 -0
- package/src/emit/function/templates/WbsFunction_Yaml.ejs +10 -0
- package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +40 -29
- package/src/emit/rbac/emitRbacApplicationArtifacts.js +171 -72
- package/src/emit/rbac/generateCreateTargetRoleHandler.js +6 -4
- package/src/emit/rbac/generateDynamicRbacFlowSchemas.js +8 -2
- package/src/emit/rbac/rbacFlowTag.js +3 -1
- package/src/emit/rbac/templates/CreateTargetRole_HdrSqs.ejs +41 -18
- package/src/emit/rbac/templates/CreateTargetRole_Main.ejs +23 -3
- package/src/emit/rbac/templates/ListRbac_HdrApi.ejs +27 -5
- package/src/emit/rbac/templates/ListRbac_HdrSqs.ejs +41 -8
- package/src/emit/rbac/templates/ListRbac_Main.ejs +26 -6
- package/src/emit/rbac/templates/RbacMutation_Main.ejs +23 -3
- package/src/emit/rbac/templates/UserRbacFlow_HdrSqs.ejs +46 -0
- package/src/emit/rbac/templates/UserRbacFlow_Main.ejs +152 -33
- package/src/emit/rbac/templates/UserRoleMutation_Main.ejs +24 -4
- package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +26 -11
- package/src/emit/relationship/emitRelationshipApplicationArtifacts.js +179 -37
- package/src/emit/relationship/generateDynamicRelationshipFlowSchemas.js +8 -2
- package/src/emit/relationship/generateRelationshipApplicationArtifacts.js +15 -6
- package/src/emit/relationship/templates/ChangeRelationshipComplete_Main.ejs +64 -37
- package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +258 -142
- package/src/emit/relationship/templates/CreateRelationshipComplete_Main.ejs +68 -43
- package/src/emit/relationship/templates/CreateRelationship_Main.ejs +315 -171
- package/src/emit/relationship/templates/DeleteRelationshipComplete_Main.ejs +67 -41
- package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +226 -115
- package/src/emit/relationship/templates/FlowHandler_HdrApi.ejs +41 -33
- package/src/emit/relationship/templates/FlowHandler_HdrDsq.ejs +15 -11
- package/src/emit/relationship/templates/FlowHandler_HdrInv.ejs +28 -26
- package/src/emit/relationship/templates/FlowHandler_HdrSqs.ejs +15 -11
- package/src/emit/relationship/templates/GetRelationshipComplete_Main.ejs +46 -26
- package/src/emit/relationship/templates/GetRelationship_Main.ejs +233 -126
- package/src/emit/relationship/templates/MoveRelationshipComplete_Main.ejs +72 -44
- package/src/emit/relationship/templates/MoveRelationship_Main.ejs +266 -150
- package/src/emit/relationship/templates/UpdateRelationshipComplete_Main.ejs +74 -45
- package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +285 -152
- package/src/emit/resource/emitResourceArtifacts.js +274 -105
- package/src/emit/resource/generateResourceArtifacts.js +15 -6
- package/src/emit/resource/templates/GeneratedLambdaRoleServiceConfig.ejs +139 -0
- package/src/emit/resource/templates/S3Bucket_Yaml.ejs +19 -0
- package/src/emit/resource/templates/S3Subscription_Yaml.ejs +7 -0
- package/src/emit/resource/templates/WebSocketSubscription_Yaml.ejs +7 -0
- package/src/emit/system/emitSystemWebSocketArtifacts.js +61 -165
- package/src/emit/system/templates/WebSocketComplete_HdrSqs.ejs +32 -0
- package/src/emit/system/templates/WebSocketComplete_Main.ejs +46 -0
- package/src/emit/system/templates/WebSocketComplete_Yaml.ejs +19 -0
- package/src/emit/system/templates/WebSocketConnect.ejs +25 -0
- package/src/emit/system/templates/WebSocketConnect_Yaml.ejs +11 -0
- package/src/generate.js +141 -34
- package/src/generateIntTest.js +76 -28
- package/src/generateResourceIntTest.js +35 -12
- package/src/generateResources/IntTest/generateResources/generateResources.js +5 -2
- package/src/generateResources/IntTest/generateResources/templateResources.ejs +18 -30
- package/src/generateResources/IntTest/generateTests/events/events.js +1 -1
- package/src/generateResources/IntTest/generateTests/events/templateEvents.ejs +13 -10
- package/src/generateResources/IntTest/generateTests/generateTemplate.js +2 -2
- package/src/generateResources/IntTest/generateTests/pathIntTest/pathIntTest.js +2 -1
- package/src/generateResources/IntTest/generateTests/pathIntTest/template.ejs +1 -3
- package/src/generateResources/IntTest/generateTests/tests/templateTests.ejs +1 -1
- package/src/generateResources/IntTest/generateTests/tests/tests.js +7 -3
- package/src/generateResources/IntTest/libs/{libs.js → IntTestGenerateLib.js} +34 -23
- package/src/generateResources/IntTest/upload/uploadIntTest.js +33 -19
- package/src/intTestGeneratorShared.js +15 -10
- package/src/output/commitArtifacts.js +99 -39
- package/src/output/mergeHooks.js +24 -10
- package/src/output/validateArtifacts.js +37 -27
- package/src/plan/buildGenerationPlan.js +24 -13
- package/test/core.test.js +116 -49
- package/test/createTargetRoleHandler.test.js +63 -14
- package/test/crudApplicationArtifacts.test.js +128 -23
- package/test/customFlowApplicationArtifacts.test.js +391 -84
- package/test/dynamicCrudFlowSchemas.test.js +74 -26
- package/test/dynamicRbacFlowSchemas.test.js +63 -20
- package/test/dynamicRelationshipFlowSchemas.test.js +65 -18
- package/test/functionYamlArtifact.test.js +67 -10
- package/test/intTestApi.test.js +9 -10
- package/test/publicApi.test.js +184 -44
- package/test/relationshipApplicationArtifacts.test.js +90 -19
- package/test/resourceArtifacts.test.js +183 -33
- package/docs/test.png +0 -0
- package/src/emit/rbac/templates/UserRbacFlow_HdrInv.ejs +0 -10
- package/src/emit/relationship/dynamicRelationshipFlowSchemaTemplate.js +0 -11
- /package/docs/{test.mmd → TriggeredCacheFlow.mmd} +0 -0
|
@@ -1,92 +1,212 @@
|
|
|
1
|
-
import
|
|
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 {
|
|
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(
|
|
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 (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
{
|
|
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(
|
|
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 [
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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 ||
|
|
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 = {
|
|
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
|
-
? [
|
|
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({
|
|
73
|
-
|
|
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({
|
|
77
|
-
|
|
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({
|
|
81
|
-
|
|
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({
|
|
85
|
-
|
|
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({
|
|
89
|
-
|
|
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 =
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (flow.event.includes('
|
|
113
|
-
|
|
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
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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 =
|
|
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
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
{
|
|
146
|
-
|
|
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: [
|
|
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 = [
|
|
319
|
+
const artifacts = [
|
|
320
|
+
{
|
|
321
|
+
path: `${source}/${mainFileName}.js`,
|
|
322
|
+
content: await renderStepMain(functionName)
|
|
323
|
+
}
|
|
324
|
+
];
|
|
153
325
|
const functions = [];
|
|
154
326
|
|
|
155
|
-
|
|
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({
|
|
161
|
-
|
|
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
|
-
|
|
175
|
-
|
|
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({
|
|
183
|
-
|
|
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 = {
|
|
417
|
+
const shared = {
|
|
418
|
+
flowTag: flow.flowTag,
|
|
419
|
+
flowStepName: '',
|
|
420
|
+
upperCaseFlowTag: tag,
|
|
421
|
+
startConfig: startConfig(flow)
|
|
422
|
+
};
|
|
196
423
|
return {
|
|
197
424
|
artifacts: [
|
|
198
|
-
{
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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({
|
|
205
|
-
|
|
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 [
|
|
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
|
|
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
|
-
{
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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
|
|
262
|
-
if (action === 'CreateObject')
|
|
263
|
-
|
|
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?.
|
|
269
|
-
|
|
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(
|
|
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 => ({
|
|
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(
|
|
678
|
+
const candidates = objects.filter(
|
|
679
|
+
(object) => object.objectType === flow.objType?.objectType
|
|
680
|
+
);
|
|
301
681
|
const object = flow.objType?.serviceTag
|
|
302
|
-
?
|
|
682
|
+
? (candidates.find(
|
|
683
|
+
(object) => object.serviceTag === flow.objType.serviceTag
|
|
684
|
+
) ?? candidates.find((object) => object.serviceTag === undefined))
|
|
303
685
|
: candidates[0];
|
|
304
|
-
return
|
|
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
|
|
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
|
|
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
|
|
716
|
+
return ejsLib
|
|
717
|
+
.render(
|
|
718
|
+
await readFile(new URL(templateName, CUSTOM_TEMPLATE_URL), 'utf8'),
|
|
719
|
+
data
|
|
720
|
+
)
|
|
721
|
+
.replace(/\n$/, '');
|
|
325
722
|
}
|