@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,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ejsLib from 'ejs';
|
|
2
2
|
import { readFile } from 'node:fs/promises';
|
|
3
3
|
|
|
4
4
|
import {
|
|
@@ -12,30 +12,42 @@ const ACTIONS = ['Create', 'Update', 'Delete', 'Get'];
|
|
|
12
12
|
const YAML_PATH = 'app/sls_yaml/generatedCode/source/flow-objects.yml';
|
|
13
13
|
const TEMPLATE_URL = new URL('./templates/', import.meta.url);
|
|
14
14
|
|
|
15
|
-
export async function emitCrudApplicationArtifacts({
|
|
15
|
+
export async function emitCrudApplicationArtifacts({
|
|
16
|
+
objects,
|
|
17
|
+
flows = [],
|
|
18
|
+
serviceTag
|
|
19
|
+
}) {
|
|
16
20
|
if (!Array.isArray(objects) || !Array.isArray(flows)) {
|
|
17
21
|
throw new TypeError('objects and flows must be arrays');
|
|
18
22
|
}
|
|
19
23
|
if (!objects.some(isCrudObject)) return [];
|
|
20
24
|
|
|
21
|
-
const handlers = await Promise.all(
|
|
25
|
+
const handlers = await Promise.all(
|
|
26
|
+
ACTIONS.map((action) => emitAction(action, objects, flows, serviceTag))
|
|
27
|
+
);
|
|
22
28
|
return [
|
|
23
|
-
...handlers.flatMap(handler => handler.artifacts),
|
|
29
|
+
...handlers.flatMap((handler) => handler.artifacts),
|
|
24
30
|
{
|
|
25
31
|
path: YAML_PATH,
|
|
26
|
-
content: handlers
|
|
32
|
+
content: handlers
|
|
33
|
+
.flatMap((handler) => handler.functions)
|
|
34
|
+
.map(renderFunction)
|
|
35
|
+
.join('\n')
|
|
27
36
|
}
|
|
28
37
|
];
|
|
29
38
|
}
|
|
30
39
|
|
|
31
40
|
export function crudApplicationManagedPaths() {
|
|
32
41
|
return [
|
|
33
|
-
...ACTIONS.flatMap(action => {
|
|
42
|
+
...ACTIONS.flatMap((action) => {
|
|
34
43
|
const source = `app/src/generatedCode/FlowObjects/${action}/source`;
|
|
35
44
|
const paths = [`${source}/${action}_Main.js`];
|
|
36
45
|
if (action === 'Get') {
|
|
37
46
|
paths.push(`${source}/Get_HdrInv.js`, `${source}/Get_HdrApi.js`);
|
|
38
|
-
paths.push(
|
|
47
|
+
paths.push(
|
|
48
|
+
`${source}/GetRange_Main.js`,
|
|
49
|
+
`${source}/GetRange_HdrApi.js`
|
|
50
|
+
);
|
|
39
51
|
} else {
|
|
40
52
|
paths.push(
|
|
41
53
|
`${source}/${action}_HdrSqs.js`,
|
|
@@ -44,7 +56,10 @@ export function crudApplicationManagedPaths() {
|
|
|
44
56
|
`${source}/${action}BeforeLogical_Main.js`,
|
|
45
57
|
`${source}/${action}BeforeLogical_HdrSqs.js`
|
|
46
58
|
);
|
|
47
|
-
paths.push(
|
|
59
|
+
paths.push(
|
|
60
|
+
`${source}/${action}Complete_Main.js`,
|
|
61
|
+
`${source}/${action}Complete_HdrSqs.js`
|
|
62
|
+
);
|
|
48
63
|
}
|
|
49
64
|
return paths;
|
|
50
65
|
}),
|
|
@@ -56,8 +71,12 @@ async function emitAction(action, objects, flows, serviceTag) {
|
|
|
56
71
|
const source = `app/src/generatedCode/FlowObjects/${action}/source`;
|
|
57
72
|
const handlerRoot = `src/generatedCode/FlowObjects/${action}/source`;
|
|
58
73
|
const generateCode = flows
|
|
59
|
-
.filter(
|
|
60
|
-
|
|
74
|
+
.filter(
|
|
75
|
+
(flow) =>
|
|
76
|
+
flow?.generatedCodeConfig?.generatedCodeTag?.toLowerCase() ===
|
|
77
|
+
action.toLowerCase()
|
|
78
|
+
)
|
|
79
|
+
.map((flow) => ({ ...flow.generatedCodeConfig, flowTag: flow.flowTag }));
|
|
61
80
|
const mainFileName = `${action}_Main`;
|
|
62
81
|
const shared = {
|
|
63
82
|
flowTag: action,
|
|
@@ -68,22 +87,66 @@ async function emitAction(action, objects, flows, serviceTag) {
|
|
|
68
87
|
flowStepName: '',
|
|
69
88
|
startConfig: null
|
|
70
89
|
};
|
|
71
|
-
const artifacts = [
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
90
|
+
const artifacts = [
|
|
91
|
+
{
|
|
92
|
+
path: `${source}/${mainFileName}.js`,
|
|
93
|
+
content: await render(`${action}Endpoint_Main.ejs`, shared)
|
|
94
|
+
}
|
|
95
|
+
];
|
|
75
96
|
|
|
97
|
+
let targetServiceTag = '${self:custom.iz_serviceName}';
|
|
98
|
+
if (serviceTag) {
|
|
99
|
+
targetServiceTag = serviceTag;
|
|
100
|
+
}
|
|
76
101
|
if (action === 'Get') {
|
|
77
102
|
artifacts.push(
|
|
78
|
-
{
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
103
|
+
{
|
|
104
|
+
path: `${source}/Get_HdrInv.js`,
|
|
105
|
+
content: await render('FlowHandler_HdrInv.ejs', {
|
|
106
|
+
...shared,
|
|
107
|
+
mainFileName,
|
|
108
|
+
functionName: 'Get',
|
|
109
|
+
queueName: 'GetHdrInv'
|
|
110
|
+
})
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
path: `${source}/Get_HdrApi.js`,
|
|
114
|
+
content: await render('FlowHandler_HdrApi.ejs', {
|
|
115
|
+
...shared,
|
|
116
|
+
mainFileName,
|
|
117
|
+
functionName: 'Get',
|
|
118
|
+
queueName: 'GetHdrApi'
|
|
119
|
+
})
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
path: `${source}/GetRange_Main.js`,
|
|
123
|
+
content: await render('GetRangeEndpoint_Main.ejs', {
|
|
124
|
+
...shared,
|
|
125
|
+
mainFileName: 'GetRange_Main',
|
|
126
|
+
functionName: 'GetRange'
|
|
127
|
+
})
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
path: `${source}/GetRange_HdrApi.js`,
|
|
131
|
+
content: await render('FlowHandler_HdrApi.ejs', {
|
|
132
|
+
...shared,
|
|
133
|
+
mainFileName: 'GetRange_Main',
|
|
134
|
+
functionName: 'GetRange',
|
|
135
|
+
queueName: 'GetRangeHdrApi'
|
|
136
|
+
})
|
|
137
|
+
}
|
|
82
138
|
);
|
|
83
139
|
return {
|
|
84
140
|
artifacts,
|
|
85
141
|
functions: [
|
|
86
|
-
{
|
|
142
|
+
{
|
|
143
|
+
type: 'inv',
|
|
144
|
+
functionName: 'GetHdrInv',
|
|
145
|
+
handlerPath: `${handlerRoot}/Get_HdrInv.main`,
|
|
146
|
+
roleName: 'FlowObjectsRole',
|
|
147
|
+
flowTag: action,
|
|
148
|
+
flowStepName: ''
|
|
149
|
+
},
|
|
87
150
|
{
|
|
88
151
|
type: 'api',
|
|
89
152
|
functionName: 'GetHdrApi',
|
|
@@ -91,8 +154,8 @@ async function emitAction(action, objects, flows, serviceTag) {
|
|
|
91
154
|
roleName: 'FlowObjectsRole',
|
|
92
155
|
flowTag: action,
|
|
93
156
|
flowStepName: '',
|
|
94
|
-
routes: objects.filter(isCrudObject).map(object => ({
|
|
95
|
-
path: `/${
|
|
157
|
+
routes: objects.filter(isCrudObject).map((object) => ({
|
|
158
|
+
path: `/${targetServiceTag}/${object.objectType}/get`,
|
|
96
159
|
upperName: upperFirst(object.objectType)
|
|
97
160
|
}))
|
|
98
161
|
},
|
|
@@ -103,45 +166,129 @@ async function emitAction(action, objects, flows, serviceTag) {
|
|
|
103
166
|
roleName: 'FlowObjectsRole',
|
|
104
167
|
flowTag: 'GetRange',
|
|
105
168
|
flowStepName: '',
|
|
106
|
-
routes: objects
|
|
107
|
-
.filter(
|
|
108
|
-
.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
169
|
+
routes: objects
|
|
170
|
+
.filter(isCrudObject)
|
|
171
|
+
.filter(
|
|
172
|
+
(object) =>
|
|
173
|
+
object.identifiers &&
|
|
174
|
+
object.identifiers.some((i) => i.type === 'sortKey')
|
|
175
|
+
)
|
|
176
|
+
.map((object) => ({
|
|
177
|
+
path: `/${targetServiceTag}/${object.objectType}/getRange`,
|
|
178
|
+
upperName: upperFirst(object.objectType)
|
|
179
|
+
}))
|
|
112
180
|
}
|
|
113
181
|
]
|
|
114
182
|
};
|
|
115
183
|
}
|
|
116
184
|
|
|
117
185
|
artifacts.push(
|
|
118
|
-
{
|
|
119
|
-
|
|
120
|
-
|
|
186
|
+
{
|
|
187
|
+
path: `${source}/${action}_HdrSqs.js`,
|
|
188
|
+
content: await render('FlowHandler_HdrSqs.ejs', {
|
|
189
|
+
...shared,
|
|
190
|
+
mainFileName,
|
|
191
|
+
functionName: action,
|
|
192
|
+
queueName: `${action}HdrSqs`
|
|
193
|
+
})
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
path: `${source}/${action}_WbsMain.js`,
|
|
197
|
+
content: await render('FlowMain_Wbs.ejs', {
|
|
198
|
+
...shared,
|
|
199
|
+
functionName: action
|
|
200
|
+
})
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
path: `${source}/${action}_HdrWbs.js`,
|
|
204
|
+
content: await render('FlowEndpoint_HdrWbs.ejs', {
|
|
205
|
+
...shared,
|
|
206
|
+
mainFileName: `${action}_WbsMain`,
|
|
207
|
+
functionName: action,
|
|
208
|
+
route: action
|
|
209
|
+
})
|
|
210
|
+
}
|
|
121
211
|
);
|
|
122
212
|
const functions = [
|
|
123
|
-
{
|
|
124
|
-
|
|
213
|
+
{
|
|
214
|
+
type: 'wbs',
|
|
215
|
+
functionName: `${action}HdrWbs`,
|
|
216
|
+
handlerPath: `${handlerRoot}/${action}_HdrWbs.main`,
|
|
217
|
+
roleName: 'FlowObjectsRole',
|
|
218
|
+
routeName: action,
|
|
219
|
+
flowTag: action,
|
|
220
|
+
flowStepName: ''
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
type: 'sqs',
|
|
224
|
+
functionName: `${action}HdrSqs`,
|
|
225
|
+
handlerPath: `${handlerRoot}/${action}_HdrSqs.main`,
|
|
226
|
+
roleName: 'FlowObjectsRole',
|
|
227
|
+
queueName: `${action}HdrSqs`,
|
|
228
|
+
flowTag: action,
|
|
229
|
+
flowStepName: ''
|
|
230
|
+
}
|
|
125
231
|
];
|
|
126
232
|
const complete = `${action}Complete`;
|
|
127
233
|
artifacts.push(
|
|
128
|
-
{
|
|
129
|
-
|
|
234
|
+
{
|
|
235
|
+
path: `${source}/${complete}_Main.js`,
|
|
236
|
+
content: await render('FlowEndpointComplete_Main.ejs', { action })
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
path: `${source}/${complete}_HdrSqs.js`,
|
|
240
|
+
content: await render('FlowHandler_HdrSqs.ejs', {
|
|
241
|
+
...shared,
|
|
242
|
+
mainFileName: `${complete}_Main`,
|
|
243
|
+
functionName: complete,
|
|
244
|
+
queueName: `${action}CompleteHdrSqs`
|
|
245
|
+
})
|
|
246
|
+
}
|
|
130
247
|
);
|
|
131
|
-
functions.push({
|
|
132
|
-
|
|
248
|
+
functions.push({
|
|
249
|
+
type: 'sqs',
|
|
250
|
+
functionName: `${action}CompleteHdrSqs`,
|
|
251
|
+
handlerPath: `${handlerRoot}/${complete}_HdrSqs.main`,
|
|
252
|
+
roleName: 'FlowObjectsRole',
|
|
253
|
+
queueName: `${action}CompleteHdrSqs`,
|
|
254
|
+
flowTag: action,
|
|
255
|
+
flowStepName: 'Complete'
|
|
256
|
+
});
|
|
257
|
+
if (generateCode.some((config) => config.codeHookTag === 'beforeLogical')) {
|
|
133
258
|
const beforeMain = `${action}BeforeLogical_Main`;
|
|
134
259
|
artifacts.push(
|
|
135
|
-
{
|
|
136
|
-
|
|
260
|
+
{
|
|
261
|
+
path: `${source}/${beforeMain}.js`,
|
|
262
|
+
content: await render('FlowEndpointBeforeLogical_Main.ejs', shared)
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
path: `${source}/${action}BeforeLogical_HdrSqs.js`,
|
|
266
|
+
content: await render('FlowHandler_HdrSqs.ejs', {
|
|
267
|
+
...shared,
|
|
268
|
+
mainFileName: beforeMain,
|
|
269
|
+
functionName: `${action}BeforeLogicalMain`,
|
|
270
|
+
queueName: `${action}BeforeLogicalHdrSqs`
|
|
271
|
+
})
|
|
272
|
+
}
|
|
137
273
|
);
|
|
138
|
-
functions.push({
|
|
274
|
+
functions.push({
|
|
275
|
+
type: 'sqs',
|
|
276
|
+
functionName: `${action}BeforeLogicalHdrSqs`,
|
|
277
|
+
handlerPath: `${handlerRoot}/${action}BeforeLogical_HdrSqs.main`,
|
|
278
|
+
roleName: 'FlowObjectsRole',
|
|
279
|
+
queueName: `${action}BeforeLogicalHdrSqs`,
|
|
280
|
+
flowTag: action,
|
|
281
|
+
flowStepName: 'BeforeLogical'
|
|
282
|
+
});
|
|
139
283
|
}
|
|
140
284
|
return { artifacts, functions };
|
|
141
285
|
}
|
|
142
286
|
|
|
143
287
|
function isCrudObject(object) {
|
|
144
|
-
return
|
|
288
|
+
return (
|
|
289
|
+
object?.generatedBy === 'userGenerated' ||
|
|
290
|
+
object?.generatedBy === 'systemGenerated'
|
|
291
|
+
);
|
|
145
292
|
}
|
|
146
293
|
|
|
147
294
|
function upperFirst(value) {
|
|
@@ -150,7 +297,7 @@ function upperFirst(value) {
|
|
|
150
297
|
|
|
151
298
|
async function render(templateName, data) {
|
|
152
299
|
const template = await readFile(new URL(templateName, TEMPLATE_URL), 'utf8');
|
|
153
|
-
return
|
|
300
|
+
return ejsLib.render(template, data);
|
|
154
301
|
}
|
|
155
302
|
|
|
156
303
|
function renderFunction(descriptor) {
|
|
@@ -4,19 +4,26 @@ const ACTIONS = ['Create', 'Update', 'Delete', 'Get'];
|
|
|
4
4
|
const MESSAGE_ATTRIBUTES = ['userId', 'correlationId'];
|
|
5
5
|
|
|
6
6
|
export const dynamicCrudFlowSchemaPaths = ACTIONS.map(
|
|
7
|
-
action =>
|
|
7
|
+
(action) =>
|
|
8
|
+
`app/src/schemas/FlowSchemas/generateCode/FlowObjects/${action}.js`
|
|
8
9
|
);
|
|
9
10
|
|
|
10
11
|
export function emitDynamicCrudFlowSchemas({ objects, flows = [] }) {
|
|
11
12
|
if (!Array.isArray(objects) || !Array.isArray(flows)) {
|
|
12
13
|
throw new TypeError('objects and flows must be arrays');
|
|
13
14
|
}
|
|
14
|
-
if (
|
|
15
|
+
if (
|
|
16
|
+
!objects.some(
|
|
17
|
+
(object) =>
|
|
18
|
+
object?.generatedBy === 'userGenerated' ||
|
|
19
|
+
object?.generatedBy === 'systemGenerated'
|
|
20
|
+
)
|
|
21
|
+
) {
|
|
15
22
|
return [];
|
|
16
23
|
}
|
|
17
24
|
|
|
18
25
|
return ACTIONS.map((action, index) => {
|
|
19
|
-
const flow =
|
|
26
|
+
const flow = _createDynamicFlow(action, _hasBeforeLogicalStep(flows, action));
|
|
20
27
|
return {
|
|
21
28
|
path: dynamicCrudFlowSchemaPaths[index],
|
|
22
29
|
content: renderDynamicCrudFlowSchema(action, flow)
|
|
@@ -24,19 +31,21 @@ export function emitDynamicCrudFlowSchemas({ objects, flows = [] }) {
|
|
|
24
31
|
});
|
|
25
32
|
}
|
|
26
33
|
|
|
27
|
-
function
|
|
34
|
+
function _createDynamicFlow(action, hasBeforeLogicalStep) {
|
|
28
35
|
const outputTopic = action !== 'Get';
|
|
29
36
|
const flowSteps = [
|
|
30
37
|
{
|
|
31
38
|
stepName: 'start',
|
|
32
39
|
properties: [],
|
|
33
40
|
messageAttributes: MESSAGE_ATTRIBUTES,
|
|
34
|
-
...(outputTopic
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
...(outputTopic
|
|
42
|
+
? {
|
|
43
|
+
returnValues: {
|
|
44
|
+
properties: [],
|
|
45
|
+
messageAttributes: MESSAGE_ATTRIBUTES
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
: {})
|
|
40
49
|
}
|
|
41
50
|
];
|
|
42
51
|
|
|
@@ -48,6 +57,7 @@ function createDynamicFlow(action, hasBeforeLogicalStep) {
|
|
|
48
57
|
messageAttributes: MESSAGE_ATTRIBUTES
|
|
49
58
|
});
|
|
50
59
|
}
|
|
60
|
+
|
|
51
61
|
if (action !== 'Get') {
|
|
52
62
|
flowSteps.push({
|
|
53
63
|
stepName: 'Complete',
|
|
@@ -57,13 +67,17 @@ function createDynamicFlow(action, hasBeforeLogicalStep) {
|
|
|
57
67
|
});
|
|
58
68
|
}
|
|
59
69
|
|
|
70
|
+
let eventTypes = ['lambdaSyncInv', 'lambdaSyncApi'];
|
|
71
|
+
if (outputTopic) {
|
|
72
|
+
eventTypes = ['ownTopic'];
|
|
73
|
+
}
|
|
74
|
+
|
|
60
75
|
return {
|
|
61
76
|
flowTag: action,
|
|
62
|
-
isDynamicObjectType: true,
|
|
63
77
|
initiateBy: 'system',
|
|
64
78
|
handleObj: 'one',
|
|
65
79
|
statusType: 'none',
|
|
66
|
-
event:
|
|
80
|
+
event: eventTypes,
|
|
67
81
|
outputTopic,
|
|
68
82
|
stepMessageAttributes: {
|
|
69
83
|
userId: { propertyName: 'x-correlation-base-user-id', type: 'string' },
|
|
@@ -73,12 +87,14 @@ function createDynamicFlow(action, hasBeforeLogicalStep) {
|
|
|
73
87
|
};
|
|
74
88
|
}
|
|
75
89
|
|
|
76
|
-
function
|
|
77
|
-
return flows.some(flow => {
|
|
90
|
+
function _hasBeforeLogicalStep(flows, action) {
|
|
91
|
+
return flows.some((flow) => {
|
|
78
92
|
const config = flow?.generatedCodeConfig;
|
|
79
|
-
return
|
|
80
|
-
|
|
81
|
-
&&
|
|
82
|
-
|
|
93
|
+
return (
|
|
94
|
+
config?.generatedCodeTag === action.toLowerCase() &&
|
|
95
|
+
config.codeHookTag === 'beforeLogical' &&
|
|
96
|
+
Array.isArray(flow.event) &&
|
|
97
|
+
flow.event.includes(config.invocationType)
|
|
98
|
+
);
|
|
83
99
|
});
|
|
84
100
|
}
|
|
@@ -2,15 +2,23 @@ import { buildGenerationPlan } from '../../plan/buildGenerationPlan.js';
|
|
|
2
2
|
import { commitArtifacts } from '../../output/commitArtifacts.js';
|
|
3
3
|
import { compileProject } from '../../compile/compileProject.js';
|
|
4
4
|
import { loadLocalSchemaArrays } from './loadLocalSchemaArrays.js';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
crudApplicationManagedPaths,
|
|
7
|
+
emitCrudApplicationArtifacts
|
|
8
|
+
} from './emitCrudApplicationArtifacts.js';
|
|
6
9
|
|
|
7
10
|
export async function generateCrudApplicationArtifacts(rootPath, options = {}) {
|
|
8
11
|
const project = compileProject({ ...options, rootPath });
|
|
9
12
|
const schemas = await loadLocalSchemaArrays(project);
|
|
10
|
-
const artifacts = await emitCrudApplicationArtifacts({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const artifacts = await emitCrudApplicationArtifacts({
|
|
14
|
+
...schemas,
|
|
15
|
+
serviceTag: project.serviceTag
|
|
16
|
+
});
|
|
17
|
+
const files = await commitArtifacts(
|
|
18
|
+
buildGenerationPlan(project, artifacts, {
|
|
19
|
+
managedPaths: crudApplicationManagedPaths(),
|
|
20
|
+
managedScope: 'crud-application'
|
|
21
|
+
})
|
|
22
|
+
);
|
|
15
23
|
return { project, files };
|
|
16
24
|
}
|
|
@@ -13,7 +13,10 @@ export async function generateDynamicCrudFlowSchemas(rootPath, options = {}) {
|
|
|
13
13
|
const plan = buildGenerationPlan(
|
|
14
14
|
project,
|
|
15
15
|
emitDynamicCrudFlowSchemas(schemaInputs),
|
|
16
|
-
{
|
|
16
|
+
{
|
|
17
|
+
managedPaths: dynamicCrudFlowSchemaPaths,
|
|
18
|
+
managedScope: 'crud-flow-schemas'
|
|
19
|
+
}
|
|
17
20
|
);
|
|
18
21
|
const files = await commitArtifacts(plan);
|
|
19
22
|
|