@izara_project/izara-core-generate-service-code 1.0.94 → 1.0.95
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/src/emit/coreFunction/emitCoreFunctionArtifacts.js +1 -26
- package/src/emit/coreFunction/templates/InitialSetupConfig.ejs +0 -30
- package/src/emit/custom/customFlowPaths.js +3 -16
- package/src/emit/custom/customFlowSteps.js +0 -41
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +1 -47
- package/src/emit/custom/templates/FlowEndpoint_Main.ejs +2 -2
- package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +7 -7
- package/src/emit/relationship/templates/CreateRelationship_Main.ejs +5 -5
- package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +3 -3
- package/src/emit/relationship/templates/GetRelationship_Main.ejs +1 -1
- package/src/emit/relationship/templates/MoveRelationship_Main.ejs +5 -5
- package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +5 -5
- package/src/emit/resource/iamResourceArtifacts.js +1 -5
- package/src/emit/resource/resourceState.js +3 -9
- package/test/customFlowApplicationArtifacts.test.js +126 -0
- package/test/relationshipApplicationArtifacts.test.js +29 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@izara_project/izara-core-generate-service-code",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.95",
|
|
4
4
|
"description": "Code for locally generating per service files",
|
|
5
5
|
"homepage": "https://bitbucket.org/izara-core-support-services/izara-core-support-services-generate-service-code#readme",
|
|
6
6
|
"repository": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ejsLib from 'ejs';
|
|
2
2
|
import { readFile } from 'node:fs/promises';
|
|
3
3
|
|
|
4
|
-
import { customFlowNextSteps
|
|
4
|
+
import { customFlowNextSteps } from '../custom/customFlows.js';
|
|
5
5
|
import { createCrudActionPlans } from '../crud/crudActionPlan.js';
|
|
6
6
|
|
|
7
7
|
const TEMPLATE_URL = new URL('./templates/', import.meta.url);
|
|
@@ -217,29 +217,6 @@ export async function emitCoreFunctionArtifacts({ project, objects = [], relatio
|
|
|
217
217
|
(objects || []).filter(o => o.belongTo?.serviceTag && o.belongTo.serviceTag !== 'Rbac').map(o => o.belongTo.serviceTag)
|
|
218
218
|
)).sort();
|
|
219
219
|
|
|
220
|
-
const customRbacFlows = (flows || []).filter((f) => flowHasRbac(f, objects));
|
|
221
|
-
const customRbacFlowTags = customRbacFlows.map((f) => f.flowTag);
|
|
222
|
-
const customRbacFlowsWithTags = customRbacFlows.map((f) => {
|
|
223
|
-
const roleName = upperFirst(f.flowTag);
|
|
224
|
-
const matched = objects.find((o) => o.objectType === f.objType?.objectType);
|
|
225
|
-
const targetServiceTags = [];
|
|
226
|
-
const belongTo = matched?.belongTo;
|
|
227
|
-
if (belongTo) {
|
|
228
|
-
if (Array.isArray(belongTo)) {
|
|
229
|
-
for (const b of belongTo) {
|
|
230
|
-
if (b?.serviceTag) targetServiceTags.push(b.serviceTag);
|
|
231
|
-
}
|
|
232
|
-
} else if (belongTo.serviceTag) {
|
|
233
|
-
targetServiceTags.push(belongTo.serviceTag);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
return {
|
|
237
|
-
roleName,
|
|
238
|
-
flowTag: f.flowTag,
|
|
239
|
-
targetServiceTags: Array.from(new Set(targetServiceTags))
|
|
240
|
-
};
|
|
241
|
-
});
|
|
242
|
-
|
|
243
220
|
const crudPlans = createCrudActionPlans(objects);
|
|
244
221
|
const hasQuotaReservation = crudPlans?.Create?.hasQuotaReservation ?? false;
|
|
245
222
|
|
|
@@ -250,8 +227,6 @@ export async function emitCoreFunctionArtifacts({ project, objects = [], relatio
|
|
|
250
227
|
relationships,
|
|
251
228
|
flows,
|
|
252
229
|
customFlowNextSteps: customFlowNextSteps(flows),
|
|
253
|
-
customRbacFlowTags,
|
|
254
|
-
customRbacFlowsWithTags,
|
|
255
230
|
objectGraphServiceTags,
|
|
256
231
|
relationshipGraphServiceTags,
|
|
257
232
|
crud,
|
|
@@ -178,23 +178,6 @@ const tableConfigs = {
|
|
|
178
178
|
}
|
|
179
179
|
});
|
|
180
180
|
});
|
|
181
|
-
|
|
182
|
-
const currentServiceTag = (typeof serviceTag !== 'undefined' && serviceTag) ? serviceTag : ((typeof project !== 'undefined' && project?.serviceTag) ? project.serviceTag : '');
|
|
183
|
-
const rbacSubs = [];
|
|
184
|
-
|
|
185
|
-
if (typeof customRbacFlowTags !== 'undefined' && customRbacFlowTags && customRbacFlowTags.length > 0) {
|
|
186
|
-
const allRbacTags = Array.from(new Set([
|
|
187
|
-
'Rbac',
|
|
188
|
-
currentServiceTag,
|
|
189
|
-
...(typeof rbacValidatorServiceTags !== 'undefined' ? rbacValidatorServiceTags : [])
|
|
190
|
-
])).filter(Boolean);
|
|
191
|
-
customRbacFlowTags.forEach(function(flowTag) {
|
|
192
|
-
const tagUpper = flowTag[0].toUpperCase() + flowTag.slice(1);
|
|
193
|
-
allRbacTags.forEach(function(tag) {
|
|
194
|
-
rbacSubs.push({ serviceTag: tag, topicName: 'ValidatorRbac_Out', sqsEndpoint: `${tagUpper}RbacCallbackHdrSqs` });
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
181
|
-%>
|
|
199
182
|
const snsTopicSubscriptions = [
|
|
200
183
|
<% if (relSubs.length > 0) { -%>
|
|
@@ -247,19 +230,6 @@ const snsTopicSubscriptions = [
|
|
|
247
230
|
sqsEndpoint: '<%= sub.sqsEndpoint %>'
|
|
248
231
|
},
|
|
249
232
|
<% }); -%>
|
|
250
|
-
<% } -%>
|
|
251
|
-
<% if (rbacSubs.length > 0) { -%>
|
|
252
|
-
|
|
253
|
-
// ------------------------------------------------------------
|
|
254
|
-
// RBAC Validator Subscriptions
|
|
255
|
-
// ------------------------------------------------------------
|
|
256
|
-
<% rbacSubs.forEach(function(sub, idx) { -%>
|
|
257
|
-
{
|
|
258
|
-
serviceTag: '<%= sub.serviceTag %>',
|
|
259
|
-
topicName: '<%= sub.topicName %>',
|
|
260
|
-
sqsEndpoint: '<%= sub.sqsEndpoint %>'
|
|
261
|
-
},
|
|
262
|
-
<% }); -%>
|
|
263
233
|
<% } -%>
|
|
264
234
|
|
|
265
235
|
//(<additionalSubscription>)
|
|
@@ -4,8 +4,7 @@ import {
|
|
|
4
4
|
generatedDsqFlows,
|
|
5
5
|
generatedOwnTopicFlows,
|
|
6
6
|
supportedCustomFlows,
|
|
7
|
-
upperFirst
|
|
8
|
-
flowHasRbac
|
|
7
|
+
upperFirst
|
|
9
8
|
} from './customFlows.js';
|
|
10
9
|
|
|
11
10
|
export const YAML_PATH = 'app/sls_yaml/generatedCode/source/flow-schema.yml';
|
|
@@ -35,12 +34,6 @@ export function ownTopicRootPaths(flow, objects = []) {
|
|
|
35
34
|
`${source}/${tag}_WbsMain.js`,
|
|
36
35
|
`${source}/${tag}_HdrWbs.js`
|
|
37
36
|
];
|
|
38
|
-
if (flowHasRbac(flow, objects)) {
|
|
39
|
-
paths.push(
|
|
40
|
-
`${source}/${tag}RbacCallback_Main.js`,
|
|
41
|
-
`${source}/${tag}RbacCallback_HdrSqs.js`
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
37
|
return paths;
|
|
45
38
|
}
|
|
46
39
|
|
|
@@ -52,12 +45,6 @@ export function flowPaths(flow, objects = []) {
|
|
|
52
45
|
if (needsProcessMain(flow)) {
|
|
53
46
|
paths.push(`${source}/${process}_Main.js`);
|
|
54
47
|
}
|
|
55
|
-
if (flowHasRbac(flow, objects)) {
|
|
56
|
-
paths.push(
|
|
57
|
-
`${source}/${tag}RbacCallback_Main.js`,
|
|
58
|
-
`${source}/${tag}RbacCallback_HdrSqs.js`
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
48
|
if (flow.event.includes('extTopic') && !flow.event.includes('ownTopic')) {
|
|
62
49
|
paths.push(`${source}/${process}_HdrSqs.js`);
|
|
63
50
|
}
|
|
@@ -116,7 +103,7 @@ export function customFlowApplicationManagedPaths(
|
|
|
116
103
|
const extSteps = flowExtTopicSteps(flows);
|
|
117
104
|
const dsqSteps = flowDsqSteps(flows);
|
|
118
105
|
|
|
119
|
-
return [
|
|
106
|
+
return Array.from(new Set([
|
|
120
107
|
...customFlowList.flatMap((flow) => flowPaths(flow, objects)),
|
|
121
108
|
...generatedRoots.flatMap((flow) => ownTopicRootPaths(flow, objects)),
|
|
122
109
|
...extSteps.flatMap(({ flowTag, stepName }) => {
|
|
@@ -145,5 +132,5 @@ export function customFlowApplicationManagedPaths(
|
|
|
145
132
|
dsqSteps.length > 0
|
|
146
133
|
? [YAML_PATH]
|
|
147
134
|
: [])
|
|
148
|
-
];
|
|
135
|
+
]));
|
|
149
136
|
}
|
|
@@ -157,7 +157,6 @@ export async function emitOwnTopicRoot(flow, objects) {
|
|
|
157
157
|
upperCaseFlowTag: tag,
|
|
158
158
|
startConfig: _startConfig(flow)
|
|
159
159
|
};
|
|
160
|
-
const isRbac = flowHasRbac(flow, objects);
|
|
161
160
|
const ownArtifacts = [
|
|
162
161
|
{
|
|
163
162
|
path: `${source}/${mainFileName}.js`,
|
|
@@ -209,46 +208,6 @@ export async function emitOwnTopicRoot(flow, objects) {
|
|
|
209
208
|
})
|
|
210
209
|
];
|
|
211
210
|
|
|
212
|
-
if (isRbac) {
|
|
213
|
-
const rbacStep = (flow.flowSteps || []).find(
|
|
214
|
-
(s) =>
|
|
215
|
-
typeof s?.stepName === 'string' &&
|
|
216
|
-
s.stepName.toLowerCase() === 'rbaccallback'
|
|
217
|
-
);
|
|
218
|
-
const rbacConfig = rbacStep ? stepConfig(flow, rbacStep) : null;
|
|
219
|
-
ownArtifacts.push(
|
|
220
|
-
{
|
|
221
|
-
path: `${source}/${tag}RbacCallback_Main.js`,
|
|
222
|
-
content: await renderCustom('FlowEndpointRbacCallback_Main.ejs', {
|
|
223
|
-
flowTag: flow.flowTag,
|
|
224
|
-
upperCaseFlowTag: tag,
|
|
225
|
-
functionName: `${tag}RbacCallbackMain`
|
|
226
|
-
})
|
|
227
|
-
},
|
|
228
|
-
{
|
|
229
|
-
path: `${source}/${tag}RbacCallback_HdrSqs.js`,
|
|
230
|
-
content: await renderShared('FlowHandler_HdrSqs.ejs', {
|
|
231
|
-
flowTag: flow.flowTag,
|
|
232
|
-
flowStepName: 'RbacCallback',
|
|
233
|
-
mainFileName: `${tag}RbacCallback_Main`,
|
|
234
|
-
functionName: `${tag}RbacCallbackMain`,
|
|
235
|
-
queueName: `${tag}RbacCallbackHdrSqs`,
|
|
236
|
-
startConfig: rbacConfig
|
|
237
|
-
})
|
|
238
|
-
}
|
|
239
|
-
);
|
|
240
|
-
ownFunctions.push(
|
|
241
|
-
renderSqsFunctionYaml({
|
|
242
|
-
functionName: `${tag}RbacCallbackHdrSqs`,
|
|
243
|
-
handlerPath: `${handlerRoot}/${tag}RbacCallback_HdrSqs.main`,
|
|
244
|
-
roleName: customFlowRoleName(flow.flowTag),
|
|
245
|
-
queueName: `${tag}RbacCallbackHdrSqs`,
|
|
246
|
-
flowTag: flow.flowTag,
|
|
247
|
-
flowStepName: 'RbacCallback'
|
|
248
|
-
})
|
|
249
|
-
);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
211
|
return {
|
|
253
212
|
artifacts: ownArtifacts,
|
|
254
213
|
functions: ownFunctions
|
|
@@ -5,8 +5,7 @@ import {
|
|
|
5
5
|
generatedDsqFlows,
|
|
6
6
|
generatedOwnTopicFlows,
|
|
7
7
|
supportedCustomFlows,
|
|
8
|
-
upperFirst
|
|
9
|
-
flowHasRbac
|
|
8
|
+
upperFirst
|
|
10
9
|
} from './customFlows.js';
|
|
11
10
|
import {
|
|
12
11
|
customFlowApplicationManagedPaths,
|
|
@@ -19,11 +18,9 @@ import {
|
|
|
19
18
|
emitDsqStep,
|
|
20
19
|
emitOwnTopicRoot,
|
|
21
20
|
renderEndpointMain,
|
|
22
|
-
stepConfig,
|
|
23
21
|
_startConfig
|
|
24
22
|
} from './customFlowSteps.js';
|
|
25
23
|
import {
|
|
26
|
-
renderCustom,
|
|
27
24
|
renderShared,
|
|
28
25
|
renderDsq
|
|
29
26
|
} from './customFlowTemplates.js';
|
|
@@ -101,49 +98,6 @@ async function emitFlow(flow, objects) {
|
|
|
101
98
|
}
|
|
102
99
|
const functions = [];
|
|
103
100
|
|
|
104
|
-
const isRbac = flowHasRbac(flow, objects);
|
|
105
|
-
if (isRbac && !flow.event.includes('ownTopic')) {
|
|
106
|
-
const rbacStep = (flow.flowSteps || []).find(
|
|
107
|
-
(s) =>
|
|
108
|
-
typeof s?.stepName === 'string' &&
|
|
109
|
-
s.stepName.toLowerCase() === 'rbaccallback'
|
|
110
|
-
);
|
|
111
|
-
let rbacConfig = null;
|
|
112
|
-
if (rbacStep) {
|
|
113
|
-
rbacConfig = stepConfig(flow, rbacStep);
|
|
114
|
-
}
|
|
115
|
-
artifacts.push(
|
|
116
|
-
{
|
|
117
|
-
path: `${source}/${tag}RbacCallback_Main.js`,
|
|
118
|
-
content: await renderCustom('FlowEndpointRbacCallback_Main.ejs', {
|
|
119
|
-
flowTag: flow.flowTag,
|
|
120
|
-
upperCaseFlowTag: tag,
|
|
121
|
-
functionName: `${tag}RbacCallbackMain`
|
|
122
|
-
})
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
path: `${source}/${tag}RbacCallback_HdrSqs.js`,
|
|
126
|
-
content: await renderShared('FlowHandler_HdrSqs.ejs', {
|
|
127
|
-
flowTag: flow.flowTag,
|
|
128
|
-
flowStepName: 'RbacCallback',
|
|
129
|
-
mainFileName: `${tag}RbacCallback_Main`,
|
|
130
|
-
functionName: `${tag}RbacCallbackMain`,
|
|
131
|
-
queueName: `${tag}RbacCallbackHdrSqs`,
|
|
132
|
-
startConfig: rbacConfig
|
|
133
|
-
})
|
|
134
|
-
}
|
|
135
|
-
);
|
|
136
|
-
functions.push(
|
|
137
|
-
renderSqsFunctionYaml({
|
|
138
|
-
functionName: `${tag}RbacCallbackHdrSqs`,
|
|
139
|
-
handlerPath: `${handlerRoot}/${tag}RbacCallback_HdrSqs.main`,
|
|
140
|
-
roleName: customFlowRoleName(flow.flowTag),
|
|
141
|
-
queueName: `${tag}RbacCallbackHdrSqs`,
|
|
142
|
-
flowTag: flow.flowTag,
|
|
143
|
-
flowStepName: 'RbacCallback'
|
|
144
|
-
})
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
101
|
|
|
148
102
|
if (flow.event.includes('extTopic') && !flow.event.includes('ownTopic')) {
|
|
149
103
|
artifacts.push({
|
|
@@ -182,7 +182,7 @@ export default async function <%- typeof functionName !== 'undefined' ? function
|
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
<% } -%>
|
|
185
|
-
<% if (typeof flow !== 'undefined' && flow.isRbac && !flow.generatedCodeConfig) { -%>
|
|
185
|
+
<% if (typeof flow !== 'undefined' && flow.isRbac && !flow.generatedCodeConfig && flow.initiateBy !== 'systemNoUser') { -%>
|
|
186
186
|
|
|
187
187
|
const { checkRbacPermission } =
|
|
188
188
|
await import('@izara_project/izara-authorization');
|
|
@@ -200,7 +200,7 @@ export default async function <%- typeof functionName !== 'undefined' ? function
|
|
|
200
200
|
serviceTag: '<%- (typeof rbacServiceTag !== "undefined" && rbacServiceTag) ? rbacServiceTag : ((flow.objType?.belongTo ? (Array.isArray(flow.objType.belongTo) ? flow.objType.belongTo[0]?.serviceTag : flow.objType.belongTo?.serviceTag) : null) || flow.serviceTag || (flow.objType ? flow.objType.serviceTag : "")) %>'
|
|
201
201
|
},
|
|
202
202
|
requestParams: typeof requestParams !== 'undefined' ? requestParams : {},
|
|
203
|
-
|
|
203
|
+
sync: true
|
|
204
204
|
}
|
|
205
205
|
);
|
|
206
206
|
|
|
@@ -84,15 +84,15 @@ export default async function <%- functionName %>(
|
|
|
84
84
|
firstObject,
|
|
85
85
|
secondObject,
|
|
86
86
|
oldRelTypeAndDirection,
|
|
87
|
-
newRelType
|
|
88
|
-
//(<
|
|
89
|
-
//(</
|
|
87
|
+
newRelType,
|
|
88
|
+
//(<requestParamChangeRel>)
|
|
89
|
+
//(</requestParamChangeRel>)
|
|
90
90
|
} = requestParams;
|
|
91
91
|
|
|
92
92
|
let foundErrors = [];
|
|
93
93
|
const parentFlowId = identifierUuid();
|
|
94
94
|
//(<beforeValidateChangeRel>)
|
|
95
|
-
//(</beforeValidateChangeRel>)
|
|
95
|
+
//(</beforeValidateChangeRel>)
|
|
96
96
|
// validate object and identifiers
|
|
97
97
|
async function validateIdentifiersExists(
|
|
98
98
|
_izContext,
|
|
@@ -443,7 +443,7 @@ export default async function <%- functionName %>(
|
|
|
443
443
|
newRelType,
|
|
444
444
|
originTimestamp,
|
|
445
445
|
changedByUserId,
|
|
446
|
-
parentFlowId
|
|
446
|
+
parentFlowId,
|
|
447
447
|
//(<messageBodyChangeRel>)
|
|
448
448
|
//(</messageBodyChangeRel>)
|
|
449
449
|
|
|
@@ -461,15 +461,15 @@ export default async function <%- functionName %>(
|
|
|
461
461
|
callingFlowConfig, // receive parent callingFlowConfig.
|
|
462
462
|
callingFlowSharedLib.createCallingFlowConfig(
|
|
463
463
|
// calling flow own service
|
|
464
|
-
//(<callingFlowProperties>)
|
|
465
464
|
await lambdaSharedLib.lambdaFunctionName(
|
|
466
465
|
_izContext,
|
|
467
466
|
TOPIC_NAME_GENERATE_CODE.changeRelationshipComplete
|
|
468
467
|
),
|
|
469
|
-
//(
|
|
468
|
+
//(<callingFlowProperties>)
|
|
470
469
|
{
|
|
471
470
|
graphServiceTag: storageResource.graphServiceTag
|
|
472
471
|
}
|
|
472
|
+
//(</callingFlowProperties>)
|
|
473
473
|
)
|
|
474
474
|
)
|
|
475
475
|
);
|
|
@@ -83,7 +83,7 @@ export default async function createRelationship(
|
|
|
83
83
|
relationshipDirection,
|
|
84
84
|
relationshipProperties,
|
|
85
85
|
deepPathConditional,
|
|
86
|
-
settings = {}
|
|
86
|
+
settings = {},
|
|
87
87
|
//(<requestParamCreateRel>)
|
|
88
88
|
//(</requestParamCreateRel>)
|
|
89
89
|
} = requestParams;
|
|
@@ -93,7 +93,7 @@ export default async function createRelationship(
|
|
|
93
93
|
let foundErrors = [];
|
|
94
94
|
const parentFlowId = identifierUuid();
|
|
95
95
|
//(<beforeValidateCreateRel>)
|
|
96
|
-
//(</beforeValidateCreateRel>)
|
|
96
|
+
//(</beforeValidateCreateRel>)
|
|
97
97
|
// validate object and identifiers
|
|
98
98
|
async function validateIdentifiersExists(
|
|
99
99
|
_izContext,
|
|
@@ -465,7 +465,7 @@ export default async function createRelationship(
|
|
|
465
465
|
relationshipProperties,
|
|
466
466
|
deepPathConditional: deepPathConditional || [],
|
|
467
467
|
parentFlowId,
|
|
468
|
-
settings: { createOnConditionalFail: createOnConditionalFail }
|
|
468
|
+
settings: { createOnConditionalFail: createOnConditionalFail },
|
|
469
469
|
//(<inCreateRelMessageBodyCreateRel>)
|
|
470
470
|
//(</inCreateRelMessageBodyCreateRel>)
|
|
471
471
|
|
|
@@ -483,15 +483,15 @@ export default async function createRelationship(
|
|
|
483
483
|
callingFlowConfig, // receive parent callingFlowConfig.
|
|
484
484
|
callingFlowSharedLib.createCallingFlowConfig(
|
|
485
485
|
// calling flow own service
|
|
486
|
-
//(<callingFlowProperties>)
|
|
487
486
|
await lambdaSharedLib.lambdaFunctionName(
|
|
488
487
|
_izContext,
|
|
489
488
|
TOPIC_NAME_GENERATE_CODE.createRelComplete
|
|
490
489
|
),
|
|
491
|
-
//(
|
|
490
|
+
//(<callingFlowProperties>)
|
|
492
491
|
{
|
|
493
492
|
graphServiceTag: storageResource.graphServiceTag
|
|
494
493
|
}
|
|
494
|
+
//(</callingFlowProperties>)
|
|
495
495
|
)
|
|
496
496
|
)
|
|
497
497
|
);
|
|
@@ -81,7 +81,7 @@ export default async function deleteRelationship(
|
|
|
81
81
|
secondObject,
|
|
82
82
|
relType,
|
|
83
83
|
relId,
|
|
84
|
-
relationshipDirection
|
|
84
|
+
relationshipDirection,
|
|
85
85
|
//(<requestParamDeleteRel>)
|
|
86
86
|
//(</requestParamDeleteRel>)
|
|
87
87
|
} = requestParams;
|
|
@@ -346,7 +346,7 @@ export default async function deleteRelationship(
|
|
|
346
346
|
relType: relType,
|
|
347
347
|
relId: relId,
|
|
348
348
|
relationshipDirection: relationshipDirection,
|
|
349
|
-
parentFlowId: parentFlowId
|
|
349
|
+
parentFlowId: parentFlowId,
|
|
350
350
|
//(<inDeleteRelMessageBody>)
|
|
351
351
|
//(</inDeleteRelMessageBody>)
|
|
352
352
|
};
|
|
@@ -362,11 +362,11 @@ export default async function deleteRelationship(
|
|
|
362
362
|
callingFlowConfig, // receive parent callingFlowConfig.
|
|
363
363
|
callingFlowSharedLib.createCallingFlowConfig(
|
|
364
364
|
// calling flow own service
|
|
365
|
-
//(<callingFlowProperties>)
|
|
366
365
|
await lambdaSharedLib.lambdaFunctionName(
|
|
367
366
|
_izContext,
|
|
368
367
|
TOPIC_NAME_GENERATE_CODE.deleteRelComplete
|
|
369
368
|
),
|
|
369
|
+
//(<callingFlowProperties>)
|
|
370
370
|
{}
|
|
371
371
|
//(</callingFlowProperties>)
|
|
372
372
|
)
|
|
@@ -87,7 +87,7 @@ export default async function moveRelationship(
|
|
|
87
87
|
relType,
|
|
88
88
|
relationshipDirection,
|
|
89
89
|
relationshipProperties,
|
|
90
|
-
moveObject
|
|
90
|
+
moveObject,
|
|
91
91
|
//(<requestParamMoveRel>)
|
|
92
92
|
//(</requestParamMoveRel>)
|
|
93
93
|
} = requestParams;
|
|
@@ -96,7 +96,7 @@ export default async function moveRelationship(
|
|
|
96
96
|
let foundErrors = [];
|
|
97
97
|
|
|
98
98
|
//(<beforeValidateMoveRel>)
|
|
99
|
-
//(</beforeValidateMoveRel>)
|
|
99
|
+
//(</beforeValidateMoveRel>)
|
|
100
100
|
// validate object and identifiers
|
|
101
101
|
async function validateIdentifiersExists(
|
|
102
102
|
_izContext,
|
|
@@ -428,7 +428,7 @@ export default async function moveRelationship(
|
|
|
428
428
|
relationshipDirection,
|
|
429
429
|
relationshipProperties,
|
|
430
430
|
moveObject,
|
|
431
|
-
parentFlowId: parentFlowId
|
|
431
|
+
parentFlowId: parentFlowId,
|
|
432
432
|
//(<messageBodyMoveRel>)
|
|
433
433
|
//(</messageBodyMoveRel>)
|
|
434
434
|
|
|
@@ -446,15 +446,15 @@ export default async function moveRelationship(
|
|
|
446
446
|
callingFlowConfig, // receive parent callingFlowConfig.
|
|
447
447
|
callingFlowSharedLib.createCallingFlowConfig(
|
|
448
448
|
// calling flow own service
|
|
449
|
-
//(<callingFlowProperties>)
|
|
450
449
|
await lambdaSharedLib.lambdaFunctionName(
|
|
451
450
|
_izContext,
|
|
452
451
|
TOPIC_NAME_GENERATE_CODE.moveRelationshipComplete
|
|
453
452
|
),
|
|
454
|
-
//(
|
|
453
|
+
//(<callingFlowProperties>)
|
|
455
454
|
{
|
|
456
455
|
graphServiceTag: storageResource.graphServiceTag
|
|
457
456
|
}
|
|
457
|
+
//(</callingFlowProperties>)
|
|
458
458
|
)
|
|
459
459
|
)
|
|
460
460
|
);
|
|
@@ -83,7 +83,7 @@ export default async function updateRelationship(
|
|
|
83
83
|
relType,
|
|
84
84
|
relId,
|
|
85
85
|
relationshipProperties,
|
|
86
|
-
relationshipDirection
|
|
86
|
+
relationshipDirection,
|
|
87
87
|
//(<requestParamUpdateRel>)
|
|
88
88
|
//(</requestParamUpdateRel>)
|
|
89
89
|
} = requestParams;
|
|
@@ -292,7 +292,7 @@ export default async function updateRelationship(
|
|
|
292
292
|
relationshipDirection,
|
|
293
293
|
status: 'error',
|
|
294
294
|
foundErrors: foundErrors,
|
|
295
|
-
parentFlowId: parentFlowId
|
|
295
|
+
parentFlowId: parentFlowId,
|
|
296
296
|
//(<inUpdateCompleteMsgUpdateRel>)
|
|
297
297
|
//(</inUpdateCompleteMsgUpdateRel>)
|
|
298
298
|
};
|
|
@@ -422,7 +422,7 @@ export default async function updateRelationship(
|
|
|
422
422
|
relType: relType,
|
|
423
423
|
relationshipProperties,
|
|
424
424
|
relationshipDirection,
|
|
425
|
-
parentFlowId
|
|
425
|
+
parentFlowId,
|
|
426
426
|
//(<inUpdateRelMessageBodyUpdateRel>)
|
|
427
427
|
//(</inUpdateRelMessageBodyUpdateRel>)
|
|
428
428
|
};
|
|
@@ -438,15 +438,15 @@ export default async function updateRelationship(
|
|
|
438
438
|
callingFlowConfig, // receive parent callingFlowConfig.
|
|
439
439
|
callingFlowSharedLib.createCallingFlowConfig(
|
|
440
440
|
// callingFlow own service
|
|
441
|
-
//(<callingFlowProperties>)
|
|
442
441
|
await lambdaSharedLib.lambdaFunctionName(
|
|
443
442
|
_izContext,
|
|
444
443
|
TOPIC_NAME_GENERATE_CODE.updateRelComplete
|
|
445
444
|
),
|
|
446
|
-
//(
|
|
445
|
+
//(<callingFlowProperties>)
|
|
447
446
|
{
|
|
448
447
|
graphServiceTag: storageResource.graphServiceTag
|
|
449
448
|
}
|
|
449
|
+
//(</callingFlowProperties>)
|
|
450
450
|
)
|
|
451
451
|
)
|
|
452
452
|
);
|
|
@@ -3,8 +3,7 @@ import { CRUD_ACTIONS } from '../crud/crudActionPlan.js';
|
|
|
3
3
|
import {
|
|
4
4
|
customFlowRoleName,
|
|
5
5
|
flowDsqSteps,
|
|
6
|
-
flowExtTopicSteps
|
|
7
|
-
flowHasRbac
|
|
6
|
+
flowExtTopicSteps
|
|
8
7
|
} from '../custom/customFlows.js';
|
|
9
8
|
import {
|
|
10
9
|
RELATIONSHIP_ACTIONS,
|
|
@@ -338,9 +337,6 @@ export function roleQueueNames(state, roleName) {
|
|
|
338
337
|
if (includesEvent(flow, 'dsq')) {
|
|
339
338
|
queueList.push(`${tag}HdrDsq`);
|
|
340
339
|
}
|
|
341
|
-
if (flowHasRbac(flow, state.objects)) {
|
|
342
|
-
queueList.push(`${tag}RbacCallbackHdrSqs`);
|
|
343
|
-
}
|
|
344
340
|
queueList.push(
|
|
345
341
|
...flowExtTopicSteps([flow]).map(
|
|
346
342
|
({ flowTag, stepName }) => `${flowTag}${stepName}HdrSqs`
|
|
@@ -4,8 +4,7 @@ import {
|
|
|
4
4
|
flowExtTopicSteps,
|
|
5
5
|
generatedDsqFlows,
|
|
6
6
|
generatedOwnTopicFlows,
|
|
7
|
-
supportedCustomFlows
|
|
8
|
-
flowHasRbac
|
|
7
|
+
supportedCustomFlows
|
|
9
8
|
} from '../custom/customFlows.js';
|
|
10
9
|
import { hasSystemWebSocket } from '../system/emitSystemWebSocketArtifacts.js';
|
|
11
10
|
import { rbacFlowTag } from '../rbac/rbacFlowTag.js';
|
|
@@ -146,7 +145,7 @@ export function createResourceState({ objects, relationships, flows }) {
|
|
|
146
145
|
const customSqsQueues = [
|
|
147
146
|
...flows
|
|
148
147
|
.filter((flow) => includesEvent(flow, 'extTopic'))
|
|
149
|
-
.map((flow) =>
|
|
148
|
+
.map((flow) => `${upperFirst(flow.flowTag)}HdrSqs`),
|
|
150
149
|
...flows
|
|
151
150
|
.filter(
|
|
152
151
|
(flow) =>
|
|
@@ -159,12 +158,7 @@ export function createResourceState({ objects, relationships, flows }) {
|
|
|
159
158
|
for (const { flowTag, stepName } of flowExtTopicSteps(flows)) {
|
|
160
159
|
customSqsQueues.push(`${flowTag}${stepName}HdrSqs`);
|
|
161
160
|
}
|
|
162
|
-
|
|
163
|
-
if (flowHasRbac(flow, objects)) {
|
|
164
|
-
const tag = upperFirst(flow.flowTag);
|
|
165
|
-
customSqsQueues.push(`${tag}RbacCallbackHdrSqs`);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
161
|
+
|
|
168
162
|
for (const flow of flows.filter((flow) => includesEvent(flow, 's3'))) {
|
|
169
163
|
const tag = upperFirst(flow.flowTag);
|
|
170
164
|
customSqsQueues.push(`${tag}CreatePreSignUrlHdrSqs`);
|
|
@@ -88,6 +88,15 @@ test('emits handlers, function YAML, and IAM roles for supported custom flow eve
|
|
|
88
88
|
assert.match(iam, /ApiRole:/);
|
|
89
89
|
assert.match(iam, /OwnRole:/);
|
|
90
90
|
assert.match(iam, /UploadRole:/);
|
|
91
|
+
const customSqsYaml = await readFile(
|
|
92
|
+
join(
|
|
93
|
+
rootPath,
|
|
94
|
+
'resource/sls_yaml/generatedCode/source/generated-sns-sqs-custom-flows.yml'
|
|
95
|
+
),
|
|
96
|
+
'utf8'
|
|
97
|
+
);
|
|
98
|
+
assert.match(customSqsYaml, /ExtHdrSqs:/);
|
|
99
|
+
assert.doesNotMatch(customSqsYaml, /ProcessExtHdrSqs/);
|
|
91
100
|
assert.match(
|
|
92
101
|
await readFile(
|
|
93
102
|
join(
|
|
@@ -1412,4 +1421,121 @@ test('emits early return cacheMain on cache hit in FlowEndpoint_Main for storedC
|
|
|
1412
1421
|
await parseAsEsm(mainPath);
|
|
1413
1422
|
});
|
|
1414
1423
|
|
|
1424
|
+
test('does not emit RbacCallback artifacts or duplicate artifact paths for custom flow with RBAC', async () => {
|
|
1425
|
+
const { generate } = await import('../src/generate.js');
|
|
1426
|
+
const rootPath = await createProject();
|
|
1427
|
+
await writeFile(
|
|
1428
|
+
join(rootPath, 'app/src/schemas/ObjectSchemas/ComAcc.js'),
|
|
1429
|
+
`export default {
|
|
1430
|
+
objectType: 'comAcc',
|
|
1431
|
+
belongTo: {
|
|
1432
|
+
objectType: 'user',
|
|
1433
|
+
serviceTag: 'UserAccount'
|
|
1434
|
+
}
|
|
1435
|
+
};\n`
|
|
1436
|
+
);
|
|
1437
|
+
await writeFile(
|
|
1438
|
+
join(
|
|
1439
|
+
rootPath,
|
|
1440
|
+
'app/src/schemas/FlowSchemas/CreateBusinessToComAcc.js'
|
|
1441
|
+
),
|
|
1442
|
+
`export default {
|
|
1443
|
+
flowTag: 'createBusinessToComAcc',
|
|
1444
|
+
event: ['lambdaSyncInv', 'ownTopic'],
|
|
1445
|
+
objType: {
|
|
1446
|
+
objectType: 'comAcc',
|
|
1447
|
+
serviceTag: 'ComAcc'
|
|
1448
|
+
},
|
|
1449
|
+
flowSteps: [{ stepName: 'Start' }]
|
|
1450
|
+
};\n`
|
|
1451
|
+
);
|
|
1452
|
+
|
|
1453
|
+
const result = await generate(rootPath, {
|
|
1454
|
+
serviceTag: 'BusinessService'
|
|
1455
|
+
});
|
|
1456
|
+
assert.ok(result);
|
|
1457
|
+
|
|
1458
|
+
const sourceDir = join(
|
|
1459
|
+
rootPath,
|
|
1460
|
+
'app/src/generatedCode/FlowSchemas/CreateBusinessToComAcc/source'
|
|
1461
|
+
);
|
|
1462
|
+
const mainPath = join(sourceDir, 'CreateBusinessToComAcc_Main.js');
|
|
1463
|
+
const mainContent = await readFile(mainPath, 'utf8');
|
|
1464
|
+
assert.match(mainContent, /checkRbacPermission/);
|
|
1465
|
+
assert.doesNotMatch(mainContent, /CreateBusinessToComAccRbacCallback/);
|
|
1466
|
+
|
|
1467
|
+
await assert.rejects(
|
|
1468
|
+
() =>
|
|
1469
|
+
readFile(
|
|
1470
|
+
join(sourceDir, 'CreateBusinessToComAccRbacCallback_Main.js'),
|
|
1471
|
+
'utf8'
|
|
1472
|
+
),
|
|
1473
|
+
{ code: 'ENOENT' }
|
|
1474
|
+
);
|
|
1475
|
+
await assert.rejects(
|
|
1476
|
+
() =>
|
|
1477
|
+
readFile(
|
|
1478
|
+
join(sourceDir, 'CreateBusinessToComAccRbacCallback_HdrSqs.js'),
|
|
1479
|
+
'utf8'
|
|
1480
|
+
),
|
|
1481
|
+
{ code: 'ENOENT' }
|
|
1482
|
+
);
|
|
1483
|
+
|
|
1484
|
+
const initialSetupConfigContent = await readFile(
|
|
1485
|
+
join(
|
|
1486
|
+
rootPath,
|
|
1487
|
+
'app/src/generatedCode/CoreFunctions/InitialSetupConfig.js'
|
|
1488
|
+
),
|
|
1489
|
+
'utf8'
|
|
1490
|
+
);
|
|
1491
|
+
assert.doesNotMatch(
|
|
1492
|
+
initialSetupConfigContent,
|
|
1493
|
+
/CreateBusinessToComAccRbacCallbackHdrSqs/
|
|
1494
|
+
);
|
|
1495
|
+
});
|
|
1496
|
+
|
|
1497
|
+
test('skips checkRbacPermission in FlowEndpoint_Main when initiateBy is systemNoUser', async () => {
|
|
1498
|
+
const { generate } = await import('../src/generate.js');
|
|
1499
|
+
const rootPath = await createProject();
|
|
1500
|
+
await writeFile(
|
|
1501
|
+
join(rootPath, 'app/src/schemas/ObjectSchemas/ComAcc.js'),
|
|
1502
|
+
`export default {
|
|
1503
|
+
objectType: 'comAcc',
|
|
1504
|
+
belongTo: {
|
|
1505
|
+
objectType: 'user',
|
|
1506
|
+
serviceTag: 'UserAccount'
|
|
1507
|
+
}
|
|
1508
|
+
};\n`
|
|
1509
|
+
);
|
|
1510
|
+
await writeFile(
|
|
1511
|
+
join(
|
|
1512
|
+
rootPath,
|
|
1513
|
+
'app/src/schemas/FlowSchemas/SystemCronFlow.js'
|
|
1514
|
+
),
|
|
1515
|
+
`export default {
|
|
1516
|
+
flowTag: 'systemCronFlow',
|
|
1517
|
+
event: ['ownTopic'],
|
|
1518
|
+
initiateBy: 'systemNoUser',
|
|
1519
|
+
objType: {
|
|
1520
|
+
objectType: 'comAcc',
|
|
1521
|
+
serviceTag: 'ComAcc'
|
|
1522
|
+
},
|
|
1523
|
+
flowSteps: [{ stepName: 'Start' }]
|
|
1524
|
+
};\n`
|
|
1525
|
+
);
|
|
1526
|
+
|
|
1527
|
+
const result = await generate(rootPath, {
|
|
1528
|
+
serviceTag: 'BusinessService'
|
|
1529
|
+
});
|
|
1530
|
+
assert.ok(result);
|
|
1531
|
+
|
|
1532
|
+
const mainPath = join(
|
|
1533
|
+
rootPath,
|
|
1534
|
+
'app/src/generatedCode/FlowSchemas/SystemCronFlow/source/SystemCronFlow_Main.js'
|
|
1535
|
+
);
|
|
1536
|
+
const mainContent = await readFile(mainPath, 'utf8');
|
|
1537
|
+
assert.doesNotMatch(mainContent, /checkRbacPermission/);
|
|
1538
|
+
await parseAsEsm(mainPath);
|
|
1539
|
+
});
|
|
1540
|
+
|
|
1415
1541
|
|
|
@@ -125,6 +125,35 @@ test('emits relationship action and complete handlers with data-first function Y
|
|
|
125
125
|
assert.match(yaml, /CreateRelationshipCompleteHdrSqs:/);
|
|
126
126
|
});
|
|
127
127
|
|
|
128
|
+
test('emits valid hook tags without trailing periods and with correct callingFlowProperties placement in relationship Main files', async () => {
|
|
129
|
+
const rootPath = await createProject(true);
|
|
130
|
+
await generateRelationshipApplicationArtifacts(rootPath, {
|
|
131
|
+
serviceTag: 'orders'
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const actions = ['Create', 'Update', 'Delete', 'Move', 'Change'];
|
|
135
|
+
for (const action of actions) {
|
|
136
|
+
const mainContent = await readFile(
|
|
137
|
+
join(
|
|
138
|
+
rootPath,
|
|
139
|
+
`app/src/generatedCode/FlowRelationships/${action}Relationship/source/${action}Relationship_Main.js`
|
|
140
|
+
),
|
|
141
|
+
'utf8'
|
|
142
|
+
);
|
|
143
|
+
assert.doesNotMatch(mainContent, /\/\/\(<\/[^>]+>\)\./);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const changeMain = await readFile(
|
|
147
|
+
join(
|
|
148
|
+
rootPath,
|
|
149
|
+
'app/src/generatedCode/FlowRelationships/ChangeRelationship/source/ChangeRelationship_Main.js'
|
|
150
|
+
),
|
|
151
|
+
'utf8'
|
|
152
|
+
);
|
|
153
|
+
assert.match(changeMain, /\/\/\(<requestParamChangeRel>\)/);
|
|
154
|
+
assert.doesNotMatch(changeMain, /\/\/\(<requestParamCreateRel>\)/);
|
|
155
|
+
});
|
|
156
|
+
|
|
128
157
|
test('removes managed relationship artifacts after relationships are removed', async () => {
|
|
129
158
|
const rootPath = await createProject(true);
|
|
130
159
|
await generateRelationshipApplicationArtifacts(rootPath, {
|