@izara_project/izara-core-generate-service-code 1.0.68 → 1.0.70
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/package.json +1 -1
- package/scripts/format-ejs.js +36 -32
- package/src/compile/compileProject.js +26 -10
- package/src/compile/loadSchemas.js +122 -59
- package/src/emit/coreFunction/emitCoreFunctionArtifacts.js +163 -0
- package/src/emit/coreFunction/templates/CoreFunction_Yaml.ejs +38 -0
- package/src/emit/coreFunction/templates/CoreResource_Yaml.ejs +235 -0
- package/src/emit/coreFunction/templates/GenerateSeedDataDynamo_HdrInv.ejs +16 -0
- package/src/emit/coreFunction/templates/GenerateSeedDataDynamo_Main.ejs +38 -0
- package/src/emit/coreFunction/templates/GenerateSeedDataGraphData_HdrInv.ejs +16 -0
- package/src/emit/coreFunction/templates/GenerateSeedDataGraphData_Main.ejs +32 -0
- package/src/emit/coreFunction/templates/GenerateSeedDataGraphSchema_HdrInv.ejs +16 -0
- package/src/emit/coreFunction/templates/GenerateSeedDataGraphSchema_Main.ejs +71 -0
- package/src/emit/coreFunction/templates/GeneratedGraphNodeSchemas.ejs +47 -0
- package/src/emit/coreFunction/templates/GeneratedGraphRelSchemas.ejs +27 -0
- package/src/emit/coreFunction/templates/GeneratedTableConfigs.ejs +34 -0
- package/src/emit/coreFunction/templates/InitialSetupConfig.ejs +108 -0
- package/src/emit/coreFunction/templates/InitialSetup_HdrInv.ejs +12 -0
- package/src/emit/coreFunction/templates/InitialSetup_Main.ejs +51 -0
- package/src/emit/coreFunction/templates/RemoveSeedDataDynamo_HdrInv.ejs +16 -0
- package/src/emit/coreFunction/templates/RemoveSeedDataDynamo_Main.ejs +31 -0
- package/src/emit/coreFunction/templates/UploadSchema_HdrInv.ejs +37 -0
- package/src/emit/coreFunction/templates/UploadSchema_Main.ejs +52 -0
- package/src/emit/crud/emitCrudApplicationArtifacts.js +194 -41
- package/src/emit/crud/emitDynamicCrudFlowSchemas.js +34 -17
- package/src/emit/crud/generateCrudApplicationArtifacts.js +14 -6
- package/src/emit/crud/generateDynamicCrudFlowSchemas.js +4 -1
- package/src/emit/crud/templates/CreateEndpoint_Main.ejs +1 -1
- package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +1 -1
- package/src/emit/crud/templates/GetEndpoint_Main.ejs +2 -2
- package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +1 -1
- package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +1 -1
- package/src/emit/custom/customFlows.js +23 -13
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +535 -114
- package/src/emit/custom/generateCustomFlowApplicationArtifacts.js +28 -8
- package/src/emit/custom/templates/FlowEndpoint_Main.ejs +2 -2
- package/src/emit/custom/templates/FlowStep_Main.ejs +1 -1
- package/src/emit/custom/templates/s3/CreateObject_Main.ejs +1 -1
- package/src/emit/custom/templates/s3/FlowHandler_HdrS3.ejs +2 -2
- package/src/emit/custom/templates/s3/ReservedLimit_HdrSqs.ejs +1 -1
- package/src/emit/custom/templates/s3/ReservedLimit_Main.ejs +1 -1
- package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +4 -4
- package/src/emit/function/functionYamlArtifact.js +273 -97
- 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 +28 -30
- package/src/emit/rbac/emitRbacApplicationArtifacts.js +6 -6
- 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/UserRbacFlow_Main.ejs +1 -1
- package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +26 -10
- package/src/emit/relationship/emitRelationshipApplicationArtifacts.js +189 -37
- package/src/emit/relationship/generateDynamicRelationshipFlowSchemas.js +8 -2
- package/src/emit/relationship/generateRelationshipApplicationArtifacts.js +15 -6
- package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +1 -1
- package/src/emit/relationship/templates/CreateRelationship_Main.ejs +1 -1
- package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +1 -1
- package/src/emit/relationship/templates/GetRelationship_Main.ejs +1 -1
- package/src/emit/relationship/templates/MoveRelationship_Main.ejs +1 -1
- package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +1 -1
- package/src/emit/resource/emitResourceArtifacts.js +249 -123
- package/src/emit/resource/generateResourceArtifacts.js +15 -6
- package/src/emit/resource/templates/DynamoDBTable_Yaml.ejs +18 -18
- package/src/emit/resource/templates/FlowOut_Yaml.ejs +5 -5
- package/src/emit/resource/templates/GeneratedLambdaRoleServiceConfig.ejs +10 -9
- package/src/emit/resource/templates/ResourceBeforeLogicalYaml.ejs +44 -44
- package/src/emit/resource/templates/ResourceSqsYaml.ejs +36 -36
- package/src/emit/resource/templates/ResourceYaml.ejs +48 -48
- package/src/emit/resource/templates/S3Subscription_Yaml.ejs +7 -0
- package/src/emit/resource/templates/SharedResource_Yaml.ejs +11 -11
- package/src/emit/resource/templates/SystemDynamoDB_Yaml.ejs +122 -105
- package/src/emit/resource/templates/WebSocketSubscription_Yaml.ejs +7 -0
- package/src/emit/shared/templates/FindData_HdrSqs.ejs +120 -0
- package/src/emit/shared/templates/FindData_Main.ejs +345 -0
- package/src/emit/{crud → shared}/templates/FlowHandler_HdrApi.ejs +1 -1
- package/src/emit/{relationship → shared}/templates/FlowHandler_HdrDsq.ejs +4 -4
- package/src/emit/{crud → shared}/templates/FlowHandler_HdrInv.ejs +1 -1
- package/src/emit/{crud → shared}/templates/FlowHandler_HdrSqs.ejs +4 -4
- package/src/emit/shared/templates/PaginateProcessLogical_HdrDsq.ejs +162 -0
- package/src/emit/shared/templates/PaginateProcessLogical_HdrSqs.ejs +140 -0
- package/src/emit/shared/templates/PaginateProcessLogical_Main.ejs +268 -0
- package/src/emit/{relationship/templates/FlowHandler_HdrSqs.ejs → shared/templates/ProcessLogical_HdrSqs.ejs} +40 -55
- package/src/emit/shared/templates/ProcessLogical_Main.ejs +448 -0
- package/src/emit/system/emitSystemFindDataArtifacts.js +266 -0
- package/src/emit/system/emitSystemWebSocketArtifacts.js +61 -165
- package/src/emit/system/templates/WebSocketComplete_HdrSqs.ejs +48 -0
- package/src/emit/system/templates/WebSocketComplete_Main.ejs +91 -0
- package/src/emit/system/templates/WebSocketComplete_Yaml.ejs +19 -0
- package/src/emit/system/templates/WebSocketConnect.ejs +45 -0
- package/src/emit/system/templates/WebSocketConnect_Yaml.ejs +11 -0
- package/src/generate.js +166 -36
- 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 +34 -21
- package/src/output/validateArtifacts.js +37 -27
- package/src/plan/buildGenerationPlan.js +24 -13
- package/test/core.test.js +117 -58
- package/test/createTargetRoleHandler.test.js +1 -1
- package/test/crudApplicationArtifacts.test.js +132 -31
- package/test/customFlowApplicationArtifacts.test.js +353 -71
- package/test/dynamicCrudFlowSchemas.test.js +74 -26
- package/test/dynamicRbacFlowSchemas.test.js +61 -14
- 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 +178 -36
- package/test/relationshipApplicationArtifacts.test.js +90 -19
- package/test/resourceArtifacts.test.js +173 -33
- package/src/emit/relationship/dynamicRelationshipFlowSchemaTemplate.js +0 -11
- package/src/emit/relationship/templates/FlowHandler_HdrApi.ejs +0 -59
- package/src/emit/relationship/templates/FlowHandler_HdrInv.ejs +0 -47
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ejsLib from 'ejs';
|
|
2
2
|
import { readFile } from 'node:fs/promises';
|
|
3
3
|
|
|
4
4
|
import {
|
|
@@ -9,85 +9,204 @@ import {
|
|
|
9
9
|
renderSqsFunctionYaml,
|
|
10
10
|
renderWbsFunctionYaml
|
|
11
11
|
} from '../function/functionYamlArtifact.js';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
customFlowRoleName,
|
|
14
|
+
flowDsqSteps,
|
|
15
|
+
flowExtTopicSteps,
|
|
16
|
+
generatedOwnTopicFlows,
|
|
17
|
+
supportedCustomFlows,
|
|
18
|
+
upperFirst
|
|
19
|
+
} from './customFlows.js';
|
|
13
20
|
|
|
14
21
|
const YAML_PATH = 'app/sls_yaml/generatedCode/source/flow-schema.yml';
|
|
15
22
|
const TEMPLATE_URL = new URL('../crud/templates/', import.meta.url);
|
|
23
|
+
const SHARED_TEMPLATE_URL = new URL('../shared/templates/', import.meta.url);
|
|
16
24
|
const CUSTOM_TEMPLATE_URL = new URL('./templates/', import.meta.url);
|
|
17
|
-
const DSQ_TEMPLATE_URL = new URL('../relationship/templates/', import.meta.url);
|
|
18
25
|
|
|
19
|
-
export async function emitCustomFlowApplicationArtifacts(
|
|
26
|
+
export async function emitCustomFlowApplicationArtifacts(
|
|
27
|
+
flows,
|
|
28
|
+
{ systemFunctions = [], objects = [] } = {}
|
|
29
|
+
) {
|
|
20
30
|
const customFlows = supportedCustomFlows(flows);
|
|
21
31
|
const generatedRoots = generatedOwnTopicFlows(flows);
|
|
22
32
|
const steps = flowExtTopicSteps(flows);
|
|
23
33
|
const dsqSteps = flowDsqSteps(flows);
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
+
);
|
|
28
49
|
const stepResults = await Promise.all(steps.map(emitExtTopicStep));
|
|
29
50
|
const dsqStepResults = await Promise.all(dsqSteps.map(emitDsqStep));
|
|
30
51
|
return [
|
|
31
|
-
...emitted.flatMap(result => result.artifacts),
|
|
32
|
-
...roots.flatMap(result => result.artifacts),
|
|
33
|
-
...stepResults.flatMap(result => result.artifacts),
|
|
34
|
-
...dsqStepResults.flatMap(result => result.artifacts),
|
|
35
|
-
{
|
|
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
|
+
}
|
|
36
66
|
];
|
|
37
67
|
}
|
|
38
68
|
|
|
39
|
-
export function customFlowApplicationManagedPaths(
|
|
69
|
+
export function customFlowApplicationManagedPaths(
|
|
70
|
+
flows,
|
|
71
|
+
{ includeYaml = false } = {}
|
|
72
|
+
) {
|
|
40
73
|
return [
|
|
41
|
-
...supportedCustomFlows(flows).flatMap(flow => flowPaths(flow)),
|
|
74
|
+
...supportedCustomFlows(flows).flatMap((flow) => flowPaths(flow)),
|
|
42
75
|
...generatedOwnTopicFlows(flows).flatMap(ownTopicRootPaths),
|
|
43
76
|
...flowExtTopicSteps(flows).flatMap(({ flowTag, stepName }) => {
|
|
44
77
|
const source = `app/src/generatedCode/FlowSchemas/${flowTag}/source`;
|
|
45
|
-
return [
|
|
78
|
+
return [
|
|
79
|
+
`${source}/${flowTag}${stepName}_Main.js`,
|
|
80
|
+
`${source}/${flowTag}${stepName}_HdrSqs.js`
|
|
81
|
+
];
|
|
46
82
|
}),
|
|
47
83
|
...flowDsqSteps(flows).flatMap(({ flowTag, stepName, step }) => {
|
|
48
84
|
const source = `app/src/generatedCode/FlowSchemas/${flowTag}/source`;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
];
|
|
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;
|
|
54
94
|
}),
|
|
55
|
-
...(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
|
+
: [])
|
|
56
102
|
];
|
|
57
103
|
}
|
|
58
104
|
|
|
59
|
-
|
|
60
|
-
|
|
61
105
|
async function emitFlow(flow, objects) {
|
|
62
106
|
const tag = upperFirst(flow.flowTag);
|
|
63
107
|
const process = tag;
|
|
64
108
|
const source = `app/src/generatedCode/FlowSchemas/${tag}/source`;
|
|
65
109
|
const handlerRoot = `src/generatedCode/FlowSchemas/${tag}/source`;
|
|
66
|
-
const shared = {
|
|
110
|
+
const shared = {
|
|
111
|
+
flowTag: flow.flowTag,
|
|
112
|
+
flowStepName: '',
|
|
113
|
+
mainFileName: `${process}_Main`,
|
|
114
|
+
functionName: process,
|
|
115
|
+
startConfig: startConfig(flow)
|
|
116
|
+
};
|
|
67
117
|
const artifacts = needsProcessMain(flow)
|
|
68
|
-
? [
|
|
118
|
+
? [
|
|
119
|
+
{
|
|
120
|
+
path: `${source}/${process}_Main.js`,
|
|
121
|
+
content: await renderEndpointMain(flow, process, objects)
|
|
122
|
+
}
|
|
123
|
+
]
|
|
69
124
|
: [];
|
|
70
125
|
const functions = [];
|
|
71
126
|
|
|
72
127
|
if (flow.event.includes('extTopic') && !flow.event.includes('ownTopic')) {
|
|
73
|
-
artifacts.push({
|
|
74
|
-
|
|
128
|
+
artifacts.push({
|
|
129
|
+
path: `${source}/${process}_HdrSqs.js`,
|
|
130
|
+
content: await renderShared('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
|
+
);
|
|
75
145
|
}
|
|
76
146
|
if (flow.event.includes('dsq')) {
|
|
77
|
-
artifacts.push({
|
|
78
|
-
|
|
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
|
+
);
|
|
79
164
|
}
|
|
80
165
|
if (flow.event.includes('lambdaSyncInv')) {
|
|
81
|
-
artifacts.push({
|
|
82
|
-
|
|
166
|
+
artifacts.push({
|
|
167
|
+
path: `${source}/${process}_HdrInv.js`,
|
|
168
|
+
content: await renderShared('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
|
+
);
|
|
83
179
|
}
|
|
84
180
|
if (flow.event.includes('lambdaSyncApi')) {
|
|
85
|
-
artifacts.push({
|
|
86
|
-
|
|
181
|
+
artifacts.push({
|
|
182
|
+
path: `${source}/${process}_HdrApi.js`,
|
|
183
|
+
content: await renderShared('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
|
+
);
|
|
87
194
|
}
|
|
88
195
|
if (flow.event.includes('eventBridge')) {
|
|
89
|
-
artifacts.push({
|
|
90
|
-
|
|
196
|
+
artifacts.push({
|
|
197
|
+
path: `${source}/${process}_HdrInv.js`,
|
|
198
|
+
content: await renderShared('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
|
+
);
|
|
91
210
|
}
|
|
92
211
|
if (flow.event.includes('ownTopic')) {
|
|
93
212
|
const root = await emitOwnTopicRoot(flow, objects);
|
|
@@ -106,17 +225,48 @@ function flowPaths(flow) {
|
|
|
106
225
|
const tag = upperFirst(flow.flowTag);
|
|
107
226
|
const process = tag;
|
|
108
227
|
const source = `app/src/generatedCode/FlowSchemas/${tag}/source`;
|
|
109
|
-
const paths =
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (flow.event.includes('
|
|
114
|
-
|
|
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
|
+
}
|
|
115
250
|
if (flow.event.includes('s3')) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
+
}
|
|
120
270
|
}
|
|
121
271
|
return paths;
|
|
122
272
|
}
|
|
@@ -124,34 +274,85 @@ function flowPaths(flow) {
|
|
|
124
274
|
async function emitExtTopicStep({ flow, step, flowTag, stepName }) {
|
|
125
275
|
const source = `app/src/generatedCode/FlowSchemas/${flowTag}/source`;
|
|
126
276
|
const handlerRoot = `src/generatedCode/FlowSchemas/${flowTag}/source`;
|
|
127
|
-
const functionName = stepName.startsWith(flowTag)
|
|
277
|
+
const functionName = stepName.startsWith(flowTag)
|
|
278
|
+
? stepName
|
|
279
|
+
: `${flowTag}${stepName}`;
|
|
128
280
|
const mainFileName = `${functionName}_Main`;
|
|
129
281
|
const startConfig = stepConfig(flow, step);
|
|
130
282
|
|
|
131
|
-
const hasTriggerFlowTypes =
|
|
283
|
+
const hasTriggerFlowTypes =
|
|
284
|
+
Array.isArray(flow.triggerFlowTypes) && flow.triggerFlowTypes.length > 0;
|
|
132
285
|
const isCheckStep = stepName.toLowerCase().includes('checktrigger');
|
|
133
286
|
|
|
134
287
|
if (isCheckStep && hasTriggerFlowTypes) {
|
|
135
288
|
const queueName = `${functionName}HdrSqs`;
|
|
136
289
|
return {
|
|
137
290
|
artifacts: [
|
|
138
|
-
{
|
|
139
|
-
|
|
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
|
+
}
|
|
140
305
|
],
|
|
141
|
-
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
|
+
]
|
|
142
316
|
};
|
|
143
317
|
}
|
|
144
318
|
|
|
145
|
-
const artifacts = [
|
|
319
|
+
const artifacts = [
|
|
320
|
+
{
|
|
321
|
+
path: `${source}/${mainFileName}.js`,
|
|
322
|
+
content: await renderStepMain(functionName)
|
|
323
|
+
}
|
|
324
|
+
];
|
|
146
325
|
const functions = [];
|
|
147
326
|
|
|
148
|
-
|
|
327
|
+
let stepEvents = [];
|
|
328
|
+
if (Array.isArray(step.event)) {
|
|
329
|
+
stepEvents = step.event;
|
|
330
|
+
}
|
|
149
331
|
const hasSqs = stepEvents.includes('extTopic') || stepEvents.includes('sqs');
|
|
150
332
|
|
|
151
333
|
if (hasSqs) {
|
|
152
334
|
const queueName = `${functionName}HdrSqs`;
|
|
153
|
-
artifacts.push({
|
|
154
|
-
|
|
335
|
+
artifacts.push({
|
|
336
|
+
path: `${source}/${functionName}_HdrSqs.js`,
|
|
337
|
+
content: await renderShared('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
|
+
);
|
|
155
356
|
}
|
|
156
357
|
|
|
157
358
|
return { artifacts, functions };
|
|
@@ -164,16 +365,44 @@ async function emitDsqStep({ flow, step, flowTag, stepName }) {
|
|
|
164
365
|
const mainFileName = `${functionName}_Main`;
|
|
165
366
|
const startConfig = stepConfig(flow, step);
|
|
166
367
|
|
|
167
|
-
|
|
168
|
-
|
|
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
|
+
}
|
|
169
379
|
const functions = [];
|
|
170
380
|
|
|
171
381
|
const hasDsq = stepEvents.includes('dsq');
|
|
172
382
|
|
|
173
383
|
if (hasDsq) {
|
|
174
384
|
const queueName = `${functionName}HdrDsq`;
|
|
175
|
-
artifacts.push({
|
|
176
|
-
|
|
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
|
+
);
|
|
177
406
|
}
|
|
178
407
|
|
|
179
408
|
return { artifacts, functions };
|
|
@@ -185,17 +414,61 @@ async function emitOwnTopicRoot(flow, objects) {
|
|
|
185
414
|
const handlerRoot = `src/generatedCode/FlowSchemas/${tag}/source`;
|
|
186
415
|
const mainFileName = `${tag}_Main`;
|
|
187
416
|
const wbsMainFileName = `${tag}_WbsMain`;
|
|
188
|
-
const shared = {
|
|
417
|
+
const shared = {
|
|
418
|
+
flowTag: flow.flowTag,
|
|
419
|
+
flowStepName: '',
|
|
420
|
+
upperCaseFlowTag: tag,
|
|
421
|
+
startConfig: startConfig(flow)
|
|
422
|
+
};
|
|
189
423
|
return {
|
|
190
424
|
artifacts: [
|
|
191
|
-
{
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
425
|
+
{
|
|
426
|
+
path: `${source}/${mainFileName}.js`,
|
|
427
|
+
content: await renderEndpointMain(flow, mainFileName, objects)
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
path: `${source}/${tag}_HdrSqs.js`,
|
|
431
|
+
content: await renderShared('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 renderCrudTemplate('FlowMain_Wbs.ejs', {
|
|
441
|
+
...shared,
|
|
442
|
+
functionName: wbsMainFileName
|
|
443
|
+
})
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
path: `${source}/${tag}_HdrWbs.js`,
|
|
447
|
+
content: await renderCrudTemplate('FlowEndpoint_HdrWbs.ejs', {
|
|
448
|
+
...shared,
|
|
449
|
+
functionName: tag,
|
|
450
|
+
mainFileName: wbsMainFileName,
|
|
451
|
+
route: tag
|
|
452
|
+
})
|
|
453
|
+
}
|
|
195
454
|
],
|
|
196
455
|
functions: [
|
|
197
|
-
renderWbsFunctionYaml({
|
|
198
|
-
|
|
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
|
+
})
|
|
199
472
|
]
|
|
200
473
|
};
|
|
201
474
|
}
|
|
@@ -203,77 +476,192 @@ async function emitOwnTopicRoot(flow, objects) {
|
|
|
203
476
|
function ownTopicRootPaths(flow) {
|
|
204
477
|
const tag = upperFirst(flow.flowTag);
|
|
205
478
|
const source = `app/src/generatedCode/FlowSchemas/${tag}/source`;
|
|
206
|
-
return [
|
|
479
|
+
return [
|
|
480
|
+
`${source}/${tag}_Main.js`,
|
|
481
|
+
`${source}/${tag}_HdrSqs.js`,
|
|
482
|
+
`${source}/${tag}_WbsMain.js`,
|
|
483
|
+
`${source}/${tag}_HdrWbs.js`
|
|
484
|
+
];
|
|
207
485
|
}
|
|
208
486
|
|
|
209
487
|
function needsProcessMain(flow) {
|
|
210
|
-
return
|
|
488
|
+
return (
|
|
489
|
+
!isS3Only(flow) &&
|
|
490
|
+
!flow.event.includes('ownTopic') &&
|
|
491
|
+
flow.event.some((event) => event !== 'ownTopic' && event !== 's3')
|
|
492
|
+
);
|
|
211
493
|
}
|
|
212
494
|
|
|
213
495
|
async function emitS3Flow(flow, source, handlerRoot) {
|
|
214
496
|
const tag = upperFirst(flow.flowTag);
|
|
215
497
|
const roleName = customFlowRoleName(flow.flowTag);
|
|
216
498
|
const parts = [
|
|
217
|
-
{
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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
|
+
}
|
|
222
534
|
];
|
|
223
|
-
const emitted = await Promise.all(
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
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
|
+
let filterPatternFunctionName = descriptor.functionName;
|
|
564
|
+
if (action === 'CreatePreSignUrl') {
|
|
565
|
+
filterPatternFunctionName = 'CreatePresignUrlHdrSqs';
|
|
566
|
+
}
|
|
567
|
+
functionYaml = renderSqsFunctionYaml({
|
|
568
|
+
...descriptor,
|
|
569
|
+
queueName: descriptor.functionName,
|
|
570
|
+
flowTag: flow.flowTag,
|
|
571
|
+
flowStepName: '',
|
|
572
|
+
filterPatternFunctionName
|
|
573
|
+
});
|
|
574
|
+
} else if (type === 's3') {
|
|
575
|
+
let bucketName = '';
|
|
576
|
+
if (flow.bucketName) {
|
|
577
|
+
bucketName = flow.bucketName;
|
|
578
|
+
}
|
|
579
|
+
functionYaml = renderS3FunctionYaml({
|
|
580
|
+
...descriptor,
|
|
581
|
+
bucketName,
|
|
582
|
+
flowTag: flow.flowTag,
|
|
583
|
+
flowStepName: ''
|
|
584
|
+
});
|
|
585
|
+
} else {
|
|
586
|
+
functionYaml = renderInvFunctionYaml({
|
|
587
|
+
...descriptor,
|
|
588
|
+
flowTag: flow.flowTag,
|
|
589
|
+
flowStepName: ''
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
return {
|
|
593
|
+
artifacts: [
|
|
594
|
+
{ path: `${source}/${mainFileName}.js`, content: mainContent },
|
|
595
|
+
{ path: `${source}/${handlerFileName}.js`, content: handlerContent }
|
|
596
|
+
],
|
|
597
|
+
functionYaml
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
)
|
|
601
|
+
);
|
|
602
|
+
return {
|
|
603
|
+
artifacts: emitted.flatMap((item) => item.artifacts),
|
|
604
|
+
functions: emitted.map((item) => item.functionYaml)
|
|
605
|
+
};
|
|
246
606
|
}
|
|
247
607
|
|
|
248
|
-
function
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
608
|
+
function _s3TemplateData({ action, flow, functionName }) {
|
|
609
|
+
if (action === 'CreateObject') {
|
|
610
|
+
return {
|
|
611
|
+
flowTag: flow.flowTag,
|
|
612
|
+
objectType: flow.objType?.objectType,
|
|
613
|
+
functionName
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
if (action === 'CreatePreSignUrl') {
|
|
617
|
+
return { flowTag: flow.flowTag };
|
|
618
|
+
}
|
|
619
|
+
return { flowTag: flow.flowTag, functionName };
|
|
254
620
|
}
|
|
255
621
|
|
|
256
|
-
function
|
|
257
|
-
if (action === 'CreateObject')
|
|
258
|
-
|
|
622
|
+
function _s3HandlerData({ action, flow, functionName, mainFileName, handler }) {
|
|
623
|
+
if (action === 'CreateObject') {
|
|
624
|
+
return { functionName, handlerType: handler, route: flow.flowTag };
|
|
625
|
+
}
|
|
626
|
+
if (action === 'ProcessAfterUpload') {
|
|
627
|
+
let bucketName = '';
|
|
628
|
+
if (flow.bucketName) {
|
|
629
|
+
bucketName = flow.bucketName;
|
|
630
|
+
}
|
|
631
|
+
return {
|
|
632
|
+
flowTag: flow.flowTag,
|
|
633
|
+
functionName,
|
|
634
|
+
mainFileName,
|
|
635
|
+
s3Bucket: bucketName
|
|
636
|
+
};
|
|
637
|
+
}
|
|
259
638
|
return { functionName, handlerType: handler };
|
|
260
639
|
}
|
|
261
640
|
|
|
262
641
|
function startConfig(flow) {
|
|
263
642
|
const start = flow.flowSteps?.[0];
|
|
264
|
-
|
|
643
|
+
if (start) {
|
|
644
|
+
return stepConfig(flow, start);
|
|
645
|
+
}
|
|
646
|
+
return null;
|
|
265
647
|
}
|
|
266
648
|
|
|
267
649
|
function stepConfig(flow, step) {
|
|
268
650
|
return {
|
|
269
651
|
...step,
|
|
270
652
|
properties: mapFields(step.properties, flow.stepProperties),
|
|
271
|
-
messageAttributes: mapFields(
|
|
653
|
+
messageAttributes: mapFields(
|
|
654
|
+
step.messageAttributes,
|
|
655
|
+
flow.stepMessageAttributes
|
|
656
|
+
)
|
|
272
657
|
};
|
|
273
658
|
}
|
|
274
659
|
|
|
275
660
|
function mapFields(names = [], definitions = {}) {
|
|
276
|
-
return names.map(name => ({
|
|
661
|
+
return names.map((name) => ({
|
|
662
|
+
propertyName: name,
|
|
663
|
+
...(definitions?.[name] ?? {})
|
|
664
|
+
}));
|
|
277
665
|
}
|
|
278
666
|
|
|
279
667
|
function isS3Only(flow) {
|
|
@@ -292,11 +680,19 @@ async function renderEndpointMain(flow, functionName, objects) {
|
|
|
292
680
|
|
|
293
681
|
function storedCacheTableName(flow, objects) {
|
|
294
682
|
if (flow.statusType !== 'storedCache') return null;
|
|
295
|
-
const candidates = objects.filter(
|
|
683
|
+
const candidates = objects.filter(
|
|
684
|
+
(object) => object.objectType === flow.objType?.objectType
|
|
685
|
+
);
|
|
296
686
|
const object = flow.objType?.serviceTag
|
|
297
|
-
?
|
|
687
|
+
? (candidates.find(
|
|
688
|
+
(object) => object.serviceTag === flow.objType.serviceTag
|
|
689
|
+
) ?? candidates.find((object) => object.serviceTag === undefined))
|
|
298
690
|
: candidates[0];
|
|
299
|
-
return
|
|
691
|
+
return (
|
|
692
|
+
Object.values(object?.storageResources ?? {}).find(
|
|
693
|
+
(resource) => resource?.storageType === 'dynamoDB'
|
|
694
|
+
)?.tableName ?? null
|
|
695
|
+
);
|
|
300
696
|
}
|
|
301
697
|
|
|
302
698
|
async function renderStepMain(functionName) {
|
|
@@ -308,13 +704,38 @@ function renderMain(functionName) {
|
|
|
308
704
|
}
|
|
309
705
|
|
|
310
706
|
async function render(templateName, data) {
|
|
311
|
-
return
|
|
707
|
+
return ejsLib.render(
|
|
708
|
+
await readFile(new URL(templateName, TEMPLATE_URL), 'utf8'),
|
|
709
|
+
data
|
|
710
|
+
);
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
async function renderShared(templateName, data) {
|
|
714
|
+
return ejsLib.render(
|
|
715
|
+
await readFile(new URL(templateName, SHARED_TEMPLATE_URL), 'utf8'),
|
|
716
|
+
data
|
|
717
|
+
);
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
async function renderCrudTemplate(templateName, data) {
|
|
721
|
+
return ejsLib.render(
|
|
722
|
+
await readFile(new URL(templateName, TEMPLATE_URL), 'utf8'),
|
|
723
|
+
data
|
|
724
|
+
);
|
|
312
725
|
}
|
|
313
726
|
|
|
314
727
|
async function renderDsq(templateName, data) {
|
|
315
|
-
return
|
|
728
|
+
return ejsLib.render(
|
|
729
|
+
await readFile(new URL(templateName, SHARED_TEMPLATE_URL), 'utf8'),
|
|
730
|
+
data
|
|
731
|
+
);
|
|
316
732
|
}
|
|
317
733
|
|
|
318
734
|
async function renderCustom(templateName, data) {
|
|
319
|
-
return
|
|
735
|
+
return ejsLib
|
|
736
|
+
.render(
|
|
737
|
+
await readFile(new URL(templateName, CUSTOM_TEMPLATE_URL), 'utf8'),
|
|
738
|
+
data
|
|
739
|
+
)
|
|
740
|
+
.replace(/\n$/, '');
|
|
320
741
|
}
|