@izara_project/izara-core-generate-service-code 1.0.83 → 1.0.85
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 +4 -4
- package/src/compile/flowValidator.js +13 -2
- package/src/compile/loadSchemas.js +116 -7
- package/src/emit/attributeTree/emitAttributeTreeSchemas.js +388 -0
- package/src/emit/coreFunction/emitCoreFunctionArtifacts.js +34 -1
- package/src/emit/coreFunction/templates/InitialSetupConfig.ejs +29 -7
- package/src/emit/crud/crudActionPlan.js +41 -6
- package/src/emit/crud/emitCrudApplicationArtifacts.js +56 -8
- package/src/emit/crud/emitDynamicCrudFlowSchemas.js +153 -27
- package/src/emit/crud/generateCrudApplicationArtifacts.js +3 -2
- package/src/emit/crud/generateDynamicCrudFlowSchemas.js +3 -2
- package/src/emit/crud/loadLocalSchemaArrays.js +3 -3
- package/src/emit/crud/templates/CreateComplete_Main.ejs +1 -1
- package/src/emit/crud/templates/CreateConfirmComplete_Main.ejs +54 -0
- package/src/emit/crud/templates/CreateEndpoint_Main.ejs +252 -154
- package/src/emit/crud/templates/CreateLogicalLib.ejs +1163 -236
- package/src/emit/crud/templates/CreateNodeCallback_Main.ejs +221 -0
- package/src/emit/crud/templates/DeleteComplete_Main.ejs +1 -1
- package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +33 -8
- package/src/emit/crud/templates/DeleteLogicalLib.ejs +6 -3
- package/src/emit/crud/templates/FlowEndpointRbacCallback_Main.ejs +20 -120
- package/src/emit/crud/templates/FlowEndpoint_HdrWbs.ejs +79 -10
- package/src/emit/crud/templates/FlowMain_Wbs.ejs +31 -35
- package/src/emit/crud/templates/GetEndpoint_Main.ejs +13 -0
- package/src/emit/crud/templates/UpdateComplete_Main.ejs +1 -1
- package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +52 -3
- package/src/emit/crud/templates/UpdateLogicalLib.ejs +4 -3
- package/src/emit/custom/customFlows.js +47 -0
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +168 -49
- package/src/emit/custom/generateCustomFlowApplicationArtifacts.js +1 -1
- package/src/emit/custom/templates/FlowEndpointRbacCallback_Main.ejs +194 -0
- package/src/emit/custom/templates/FlowEndpoint_Main.ejs +14 -22
- package/src/emit/custom/templates/FlowStep_Main.ejs +1 -1
- package/src/emit/function/templates/WbsFunction_Yaml.ejs +0 -2
- package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +33 -8
- package/src/emit/rbac/emitRbacApplicationArtifacts.js +204 -7
- package/src/emit/rbac/templates/CancelUsage_Main.ejs +163 -0
- package/src/emit/rbac/templates/ConfirmUsage_Main.ejs +187 -0
- package/src/emit/rbac/templates/CreateTargetRole_Main.ejs +68 -6
- package/src/emit/rbac/templates/ListRbac_Main.ejs +9 -3
- package/src/emit/rbac/templates/RbacMutation_Main.ejs +1 -1
- package/src/emit/rbac/templates/ReservedDynamicUsage_Main.ejs +166 -0
- package/src/emit/rbac/templates/UserRbacFlow_Main.ejs +84 -23
- package/src/emit/rbac/templates/UserRoleMutation_Main.ejs +11 -8
- package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +1 -1
- package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +4 -4
- package/src/emit/resource/emitResourceArtifacts.js +351 -108
- package/src/emit/resource/templates/GeneratedLambdaRoleServiceConfig.ejs +3 -1
- package/src/emit/resource/templates/SystemDynamoDB_Yaml.ejs +55 -2
- package/src/emit/shared/templates/FlowHandler_HdrSqs.ejs +1 -1
- package/src/emit/system/emitSystemWebSocketArtifacts.js +6 -5
- package/src/emit/system/templates/WebSocketConnect.ejs +71 -12
- package/src/emit/system/templates/WebSocketConnect_Yaml.ejs +6 -0
- package/src/emit/systemText/emitSystemTextSchemas.js +1 -1
- package/src/generate.js +41 -10
- package/test/attributeTreeSchemas.test.js +219 -0
- package/test/createTargetRoleHandler.test.js +59 -4
- package/test/crudApplicationArtifacts.test.js +20 -3
- package/test/customFlowApplicationArtifacts.test.js +5 -5
- package/test/dynamicCrudFlowSchemas.test.js +107 -6
- package/test/dynamicRbacFlowSchemas.test.js +15 -2
- package/test/publicApi.test.js +6 -6
- package/test/resourceArtifacts.test.js +89 -27
|
@@ -33,34 +33,27 @@ const { postToConnection } = webSocket;
|
|
|
33
33
|
//(</optionalRequire>)
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* description of function.
|
|
36
|
+
* WebSocket handler entry for <%- upperCaseFlowTag %> Flow
|
|
39
37
|
* @param {Object} _izContext
|
|
40
|
-
* @param {CorrelationIds} _izContext.correlationIds -
|
|
41
|
-
* @param {Logger} _izContext.logger -
|
|
42
|
-
* @param {Object} requestParams -
|
|
43
|
-
* @param {Object}
|
|
44
|
-
* @
|
|
45
|
-
*
|
|
46
|
-
* @returns {object} description of return value
|
|
38
|
+
* @param {CorrelationIds} _izContext.correlationIds - Context correlation IDs
|
|
39
|
+
* @param {Logger} _izContext.logger - Context logger
|
|
40
|
+
* @param {Object} requestParams - Request parameters
|
|
41
|
+
* @param {Object} callingFlowConfig - Calling flow configuration
|
|
42
|
+
* @returns {Promise<void>}
|
|
47
43
|
*/
|
|
48
44
|
export default async function <%- typeof functionName !== 'undefined' ? functionName : upperCaseFlowTag %>(
|
|
49
45
|
_izContext,
|
|
50
46
|
requestParams,
|
|
51
|
-
|
|
52
|
-
//(</additionalParams>)
|
|
53
|
-
callingFlowConfig = {}
|
|
47
|
+
callingFlowConfig
|
|
54
48
|
) {
|
|
55
49
|
try {
|
|
56
|
-
_izContext.logger.debug('<%- typeof functionName !== 'undefined' ? functionName : upperCaseFlowTag %> _izContext', _izContext);
|
|
57
|
-
_izContext.logger.debug('<%- typeof functionName !== 'undefined' ? functionName : upperCaseFlowTag %> requestParams', requestParams);
|
|
58
50
|
_izContext.logger.debug(
|
|
59
|
-
|
|
51
|
+
`[${process.env.iz_serviceTag}:<%- typeof functionName !== 'undefined' ? functionName : upperCaseFlowTag %>Wbs] started`,
|
|
52
|
+
requestParams,
|
|
60
53
|
callingFlowConfig
|
|
61
54
|
);
|
|
62
55
|
|
|
63
|
-
|
|
56
|
+
const flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(
|
|
64
57
|
_izContext,
|
|
65
58
|
{
|
|
66
59
|
flowTag: '<%- flowTag %>',
|
|
@@ -70,6 +63,23 @@ export default async function <%- typeof functionName !== 'undefined' ? function
|
|
|
70
63
|
|
|
71
64
|
_izContext.logger.debug('flowSchema', flowSchema);
|
|
72
65
|
|
|
66
|
+
const connectionId = _izContext.correlationIds?.get(coreConsts.CONNECTION_ID);
|
|
67
|
+
|
|
68
|
+
if (!flowSchema) {
|
|
69
|
+
if (connectionId) {
|
|
70
|
+
await postToConnection(
|
|
71
|
+
_izContext,
|
|
72
|
+
{
|
|
73
|
+
message: {
|
|
74
|
+
error: `flowTag not found ${requestParams.action}`
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
connectionId
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
throw new NoRetryError(`flowTag not found ${requestParams.action}`);
|
|
81
|
+
}
|
|
82
|
+
|
|
73
83
|
if (
|
|
74
84
|
flowSchema.initiateBy === 'user' ||
|
|
75
85
|
flowSchema.initiateBy === 'systemWithUser'
|
|
@@ -77,24 +87,9 @@ export default async function <%- typeof functionName !== 'undefined' ? function
|
|
|
77
87
|
_izContext.correlationIds.set(coreConsts.USER_AGENT, 'webSocket');
|
|
78
88
|
}
|
|
79
89
|
|
|
80
|
-
let connectionId = _izContext.correlationIds.get(coreConsts.CONNECTION_ID);
|
|
81
|
-
|
|
82
|
-
if (!flowSchema) {
|
|
83
|
-
await postToConnection(
|
|
84
|
-
_izContext,
|
|
85
|
-
{
|
|
86
|
-
message: {
|
|
87
|
-
error: `flowTag not found ${requestParams.action}`
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
connectionId
|
|
91
|
-
);
|
|
92
|
-
throw new NoRetryError(`flowTag not found ${requestParams.action}`);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
90
|
let messageObject = requestParams;
|
|
96
91
|
|
|
97
|
-
//
|
|
92
|
+
// Attach calling flow configuration pointing to WebSocketCompleteHdrSqs
|
|
98
93
|
messageObject =
|
|
99
94
|
callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
|
|
100
95
|
messageObject,
|
|
@@ -110,17 +105,18 @@ export default async function <%- typeof functionName !== 'undefined' ? function
|
|
|
110
105
|
)
|
|
111
106
|
);
|
|
112
107
|
|
|
113
|
-
|
|
108
|
+
const sendMessageToEndpoint = {
|
|
114
109
|
Message: JSON.stringify(messageObject),
|
|
115
110
|
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
116
111
|
_izContext,
|
|
117
112
|
'<%- upperCaseFlowTag %>_In'
|
|
118
113
|
)
|
|
119
114
|
};
|
|
115
|
+
|
|
120
116
|
_izContext.logger.debug('sendMessageToEndpoint', sendMessageToEndpoint);
|
|
121
117
|
await sns.publishAsync(_izContext, sendMessageToEndpoint);
|
|
122
118
|
} catch (err) {
|
|
123
|
-
_izContext.logger.error('
|
|
119
|
+
_izContext.logger.error(`[${process.env.iz_serviceTag}:<%- typeof functionName !== 'undefined' ? functionName : upperCaseFlowTag %>Wbs] error:`, err);
|
|
124
120
|
throw err;
|
|
125
121
|
}
|
|
126
122
|
}
|
|
@@ -68,6 +68,19 @@ export default async function <%- flowTag %>(
|
|
|
68
68
|
callingFlowConfig
|
|
69
69
|
});
|
|
70
70
|
|
|
71
|
+
// ── Resolve submittedByUserId / targetIdentifiers ─────────────────────────
|
|
72
|
+
const submittedByUserId =
|
|
73
|
+
requestParams.submittedByUserId ||
|
|
74
|
+
_izContext.correlationIds?.get(coreConsts.SUBMITTED_BY_USER_ID);
|
|
75
|
+
if (submittedByUserId) {
|
|
76
|
+
requestParams.submittedByUserId = submittedByUserId;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const targetIdentifiers = requestParams.targetIdentifiers;
|
|
80
|
+
if (targetIdentifiers) {
|
|
81
|
+
requestParams.targetIdentifiers = targetIdentifiers;
|
|
82
|
+
}
|
|
83
|
+
|
|
71
84
|
// ── Settings ──────────────────────────────────────────────────────────────
|
|
72
85
|
const settings = requestParams.additionalParams?.settings ?? {};
|
|
73
86
|
const returnSystemFieldsName = settings.returnSystemFieldsName === true;
|
|
@@ -52,7 +52,7 @@ export default async function UpdateComplete(
|
|
|
52
52
|
//(</additionalParams>)
|
|
53
53
|
) {
|
|
54
54
|
try {
|
|
55
|
-
_izContext.logger.debug(
|
|
55
|
+
_izContext.logger.debug(`[${process.env.iz_serviceTag}:UpdateComplete] started`, {
|
|
56
56
|
requestParams
|
|
57
57
|
});
|
|
58
58
|
const {
|
|
@@ -78,9 +78,58 @@ export default async function <%- flowTag %>(
|
|
|
78
78
|
callingFlowConfig
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
+
const errorsFound = [];
|
|
82
|
+
const objType = createObjType(requestParams.objectType);
|
|
83
|
+
|
|
84
|
+
// ── Load schema ───────────────────────────────────────────────────────────
|
|
85
|
+
const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(
|
|
86
|
+
_izContext,
|
|
87
|
+
objType
|
|
88
|
+
);
|
|
89
|
+
_izContext.logger.debug(`[${process.env.iz_serviceTag}:<%- flowTag %>] objectSchema:`, objectSchema);
|
|
90
|
+
|
|
91
|
+
// ── Resolve submittedByUserId / targetIdentifiers ─────────────────────────
|
|
92
|
+
let submittedByUserId, targetIdentifiers;
|
|
93
|
+
if (
|
|
94
|
+
objectSchema.generatedBy === 'user' ||
|
|
95
|
+
objectSchema.generatedBy === 'systemWithUser'
|
|
96
|
+
) {
|
|
97
|
+
submittedByUserId =
|
|
98
|
+
requestParams.submittedByUserId ||
|
|
99
|
+
_izContext.correlationIds?.get(coreConsts.SUBMITTED_BY_USER_ID);
|
|
100
|
+
|
|
101
|
+
targetIdentifiers = requestParams.targetIdentifiers;
|
|
102
|
+
|
|
103
|
+
if (!targetIdentifiers && objectSchema.belongTo?.objectType === 'user' && submittedByUserId) {
|
|
104
|
+
targetIdentifiers = { submittedByUserId };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (!submittedByUserId) errorsFound.push('Not have submittedByUserId');
|
|
108
|
+
if (objectSchema.hasOwnProperty('belongTo') && !targetIdentifiers)
|
|
109
|
+
errorsFound.push('not have targetIdentifiers');
|
|
110
|
+
|
|
111
|
+
requestParams.submittedByUserId = submittedByUserId;
|
|
112
|
+
if (targetIdentifiers) {
|
|
113
|
+
if (!targetIdentifiers.submittedByUserId && submittedByUserId) {
|
|
114
|
+
targetIdentifiers.submittedByUserId = submittedByUserId;
|
|
115
|
+
}
|
|
116
|
+
requestParams.targetIdentifiers = targetIdentifiers;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
_izContext.logger.debug(`[${process.env.iz_serviceTag}:<%- flowTag %>] Identity & Target Context Resolved:`, {
|
|
120
|
+
submittedByUserId: requestParams.submittedByUserId,
|
|
121
|
+
targetIdentifiers: requestParams.targetIdentifiers,
|
|
122
|
+
belongTo: objectSchema.belongTo,
|
|
123
|
+
generatedBy: objectSchema.generatedBy
|
|
124
|
+
});
|
|
125
|
+
} else if (objectSchema.generatedBy === 'searchResultGenerated') {
|
|
126
|
+
throw new NoRetryError(
|
|
127
|
+
'error searchResultGenerated should not happen here'
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
81
131
|
// ── Build identifiers used by asynchronous processing ────────────────────
|
|
82
132
|
const identifiers = requestParams.objInstanceFull.identifiers;
|
|
83
|
-
const errorsFound = [];
|
|
84
133
|
|
|
85
134
|
//(<validateBeforeUpdate>)
|
|
86
135
|
//(</validateBeforeUpdate>)
|
|
@@ -142,7 +191,7 @@ export default async function <%- flowTag %>(
|
|
|
142
191
|
);
|
|
143
192
|
|
|
144
193
|
_izContext.logger.debug(
|
|
145
|
-
|
|
194
|
+
`[${process.env.iz_serviceTag}:<%- flowTag %>] checkRbacPermission result:`,
|
|
146
195
|
resultPermissionCheck
|
|
147
196
|
);
|
|
148
197
|
|
|
@@ -308,7 +357,7 @@ export default async function <%- flowTag %>(
|
|
|
308
357
|
errorsFound
|
|
309
358
|
);
|
|
310
359
|
} catch (err) {
|
|
311
|
-
_izContext.logger.error(
|
|
360
|
+
_izContext.logger.error(`[${process.env.iz_serviceTag}:<%- flowTag %>] error:`, err);
|
|
312
361
|
throw err;
|
|
313
362
|
}
|
|
314
363
|
}
|
|
@@ -72,7 +72,7 @@ export async function <%- flowTag %>LogicalLib(
|
|
|
72
72
|
phaseResults = {}
|
|
73
73
|
) {
|
|
74
74
|
try {
|
|
75
|
-
_izContext.logger.debug(
|
|
75
|
+
_izContext.logger.debug(`[${process.env.iz_serviceTag}:<%- flowTag %>LogicalLib] started`, {
|
|
76
76
|
requestParams,
|
|
77
77
|
callingFlowConfig,
|
|
78
78
|
phaseResults
|
|
@@ -96,7 +96,7 @@ export async function <%- flowTag %>LogicalLib(
|
|
|
96
96
|
_izContext,
|
|
97
97
|
objType
|
|
98
98
|
);
|
|
99
|
-
_izContext.logger.debug(
|
|
99
|
+
_izContext.logger.debug(`[${process.env.iz_serviceTag}:<%- flowTag %>LogicalLib] objectSchema:`, objectSchema);
|
|
100
100
|
|
|
101
101
|
const objectSchemas =
|
|
102
102
|
await uploadUseCase.generateObjectSchemaForCombineFieldNames(
|
|
@@ -110,7 +110,7 @@ export async function <%- flowTag %>LogicalLib(
|
|
|
110
110
|
_izContext,
|
|
111
111
|
objectSchemas
|
|
112
112
|
);
|
|
113
|
-
_izContext.logger.debug(
|
|
113
|
+
_izContext.logger.debug(`[${process.env.iz_serviceTag}:<%- flowTag %>LogicalLib] updateDataDetails:`, updateDataDetails);
|
|
114
114
|
|
|
115
115
|
const originTimestamp = Date.now();
|
|
116
116
|
|
|
@@ -468,6 +468,7 @@ export async function <%- flowTag %>LogicalLib(
|
|
|
468
468
|
errorsFound
|
|
469
469
|
};
|
|
470
470
|
} catch (err) {
|
|
471
|
+
_izContext.logger.error(`[${process.env.iz_serviceTag}:<%- flowTag %>LogicalLib] error:`, err);
|
|
471
472
|
_izContext.logger.error('[<%- flowTag %>LogicalLib] error:', err);
|
|
472
473
|
throw err;
|
|
473
474
|
}
|
|
@@ -49,6 +49,7 @@ export function flowExtTopicSteps(flows) {
|
|
|
49
49
|
typeof step?.stepName !== 'string' ||
|
|
50
50
|
step.stepName === '' ||
|
|
51
51
|
step.stepName.toLowerCase() === 'start' ||
|
|
52
|
+
step.stepName.toLowerCase() === 'rbaccallback' ||
|
|
52
53
|
!Array.isArray(step.event) ||
|
|
53
54
|
!step.event.includes('extTopic')
|
|
54
55
|
) {
|
|
@@ -242,3 +243,49 @@ export function customFlowNextSteps(flows) {
|
|
|
242
243
|
}
|
|
243
244
|
return results;
|
|
244
245
|
}
|
|
246
|
+
|
|
247
|
+
export function flowHasRbac(flow, objects = []) {
|
|
248
|
+
if (!flow || !flow.objType || typeof flow.objType !== "object") return false;
|
|
249
|
+
const candidates = objects.filter(
|
|
250
|
+
(o) => o.objectType === flow.objType.objectType
|
|
251
|
+
);
|
|
252
|
+
const object = flow.objType.serviceTag
|
|
253
|
+
? (candidates.find((o) => o.serviceTag === flow.objType.serviceTag) ??
|
|
254
|
+
candidates.find((o) => o.serviceTag === undefined) ??
|
|
255
|
+
candidates[0])
|
|
256
|
+
: candidates[0];
|
|
257
|
+
if (!object) return false;
|
|
258
|
+
return hasRbacObject(object, objects);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function hasRbacObject(object, objects = []) {
|
|
262
|
+
return (
|
|
263
|
+
hasSelfRbac(object) ||
|
|
264
|
+
(Array.isArray(object?.belongToSchema?.addOnDataStructure) &&
|
|
265
|
+
object.belongToSchema.addOnDataStructure.some(
|
|
266
|
+
(addOn) => addOn?.type === "rbac"
|
|
267
|
+
)) ||
|
|
268
|
+
normalizeBelongTo(object).some((target) => {
|
|
269
|
+
if (target?.serviceTag === "UserAccount") return true;
|
|
270
|
+
const matched = objects.find(
|
|
271
|
+
(candidate) =>
|
|
272
|
+
candidate?.serviceTag === target?.serviceTag &&
|
|
273
|
+
candidate?.objectType === target?.objectType
|
|
274
|
+
);
|
|
275
|
+
return hasSelfRbac(matched);
|
|
276
|
+
})
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function hasSelfRbac(object) {
|
|
281
|
+
return (
|
|
282
|
+
Array.isArray(object?.addOnDataStructure) &&
|
|
283
|
+
object.addOnDataStructure.some((addOn) => addOn?.type === "rbac")
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function normalizeBelongTo(object) {
|
|
288
|
+
const belongTo = object?.belongTo;
|
|
289
|
+
if (!belongTo) return [];
|
|
290
|
+
return Array.isArray(belongTo) ? belongTo : [belongTo];
|
|
291
|
+
}
|
|
@@ -16,7 +16,8 @@ import {
|
|
|
16
16
|
generatedDsqFlows,
|
|
17
17
|
generatedOwnTopicFlows,
|
|
18
18
|
supportedCustomFlows,
|
|
19
|
-
upperFirst
|
|
19
|
+
upperFirst,
|
|
20
|
+
flowHasRbac
|
|
20
21
|
} from './customFlows.js';
|
|
21
22
|
|
|
22
23
|
const YAML_PATH = 'app/sls_yaml/generatedCode/source/flow-schema.yml';
|
|
@@ -67,10 +68,10 @@ export async function emitCustomFlowApplicationArtifacts(
|
|
|
67
68
|
];
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
export function customFlowApplicationManagedPaths(flows) {
|
|
71
|
+
export function customFlowApplicationManagedPaths(flows, { objects = [] } = {}) {
|
|
71
72
|
return [
|
|
72
|
-
...supportedCustomFlows(flows).flatMap((flow) => flowPaths(flow)),
|
|
73
|
-
...generatedOwnTopicFlows(flows).flatMap(ownTopicRootPaths),
|
|
73
|
+
...supportedCustomFlows(flows).flatMap((flow) => flowPaths(flow, objects)),
|
|
74
|
+
...generatedOwnTopicFlows(flows).flatMap((flow) => ownTopicRootPaths(flow, objects)),
|
|
74
75
|
...flowExtTopicSteps(flows).flatMap(({ flowTag, stepName }) => {
|
|
75
76
|
const source = `app/src/generatedCode/FlowSchemas/${flowTag}/source`;
|
|
76
77
|
return [
|
|
@@ -122,6 +123,45 @@ async function emitFlow(flow, objects) {
|
|
|
122
123
|
: [];
|
|
123
124
|
const functions = [];
|
|
124
125
|
|
|
126
|
+
const isRbac = flowHasRbac(flow, objects);
|
|
127
|
+
if (isRbac && !flow.event.includes('ownTopic')) {
|
|
128
|
+
const rbacStep = (flow.flowSteps || []).find(
|
|
129
|
+
(s) => typeof s?.stepName === 'string' && s.stepName.toLowerCase() === 'rbaccallback'
|
|
130
|
+
);
|
|
131
|
+
const rbacConfig = rbacStep ? stepConfig(flow, rbacStep) : null;
|
|
132
|
+
artifacts.push(
|
|
133
|
+
{
|
|
134
|
+
path: `${source}/${tag}RbacCallback_Main.js`,
|
|
135
|
+
content: await renderCustom('FlowEndpointRbacCallback_Main.ejs', {
|
|
136
|
+
flowTag: flow.flowTag,
|
|
137
|
+
upperCaseFlowTag: tag,
|
|
138
|
+
functionName: `${tag}RbacCallbackMain`
|
|
139
|
+
})
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
path: `${source}/${tag}RbacCallback_HdrSqs.js`,
|
|
143
|
+
content: await renderShared('FlowHandler_HdrSqs.ejs', {
|
|
144
|
+
flowTag: flow.flowTag,
|
|
145
|
+
flowStepName: 'RbacCallback',
|
|
146
|
+
mainFileName: `${tag}RbacCallback_Main`,
|
|
147
|
+
functionName: `${tag}RbacCallbackMain`,
|
|
148
|
+
queueName: `${tag}RbacCallbackHdrSqs`,
|
|
149
|
+
startConfig: rbacConfig
|
|
150
|
+
})
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
functions.push(
|
|
154
|
+
renderSqsFunctionYaml({
|
|
155
|
+
functionName: `${tag}RbacCallbackHdrSqs`,
|
|
156
|
+
handlerPath: `${handlerRoot}/${tag}RbacCallback_HdrSqs.main`,
|
|
157
|
+
roleName: customFlowRoleName(flow.flowTag),
|
|
158
|
+
queueName: `${tag}RbacCallbackHdrSqs`,
|
|
159
|
+
flowTag: flow.flowTag,
|
|
160
|
+
flowStepName: 'RbacCallback'
|
|
161
|
+
})
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
125
165
|
if (flow.event.includes('extTopic') && !flow.event.includes('ownTopic')) {
|
|
126
166
|
artifacts.push({
|
|
127
167
|
path: `${source}/${process}_HdrSqs.js`,
|
|
@@ -219,7 +259,7 @@ async function emitFlow(flow, objects) {
|
|
|
219
259
|
return { artifacts, functions };
|
|
220
260
|
}
|
|
221
261
|
|
|
222
|
-
function flowPaths(flow) {
|
|
262
|
+
function flowPaths(flow, objects = []) {
|
|
223
263
|
const tag = upperFirst(flow.flowTag);
|
|
224
264
|
const process = tag;
|
|
225
265
|
const source = `app/src/generatedCode/FlowSchemas/${tag}/source`;
|
|
@@ -227,6 +267,12 @@ function flowPaths(flow) {
|
|
|
227
267
|
if (needsProcessMain(flow)) {
|
|
228
268
|
paths.push(`${source}/${process}_Main.js`);
|
|
229
269
|
}
|
|
270
|
+
if (flowHasRbac(flow, objects)) {
|
|
271
|
+
paths.push(
|
|
272
|
+
`${source}/${tag}RbacCallback_Main.js`,
|
|
273
|
+
`${source}/${tag}RbacCallback_HdrSqs.js`
|
|
274
|
+
);
|
|
275
|
+
}
|
|
230
276
|
if (flow.event.includes('extTopic') && !flow.event.includes('ownTopic')) {
|
|
231
277
|
paths.push(`${source}/${process}_HdrSqs.js`);
|
|
232
278
|
}
|
|
@@ -418,68 +464,118 @@ async function emitOwnTopicRoot(flow, objects) {
|
|
|
418
464
|
upperCaseFlowTag: tag,
|
|
419
465
|
startConfig: _startConfig(flow)
|
|
420
466
|
};
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
467
|
+
const isRbac = flowHasRbac(flow, objects);
|
|
468
|
+
const ownArtifacts = [
|
|
469
|
+
{
|
|
470
|
+
path: `${source}/${mainFileName}.js`,
|
|
471
|
+
content: await renderEndpointMain(flow, mainFileName, objects)
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
path: `${source}/${tag}_HdrSqs.js`,
|
|
475
|
+
content: await renderShared('FlowHandler_HdrSqs.ejs', {
|
|
476
|
+
...shared,
|
|
477
|
+
functionName: mainFileName,
|
|
478
|
+
mainFileName,
|
|
479
|
+
queueName: `${tag}HdrSqs`
|
|
480
|
+
})
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
path: `${source}/${wbsMainFileName}.js`,
|
|
484
|
+
content: await renderCrudTemplate('FlowMain_Wbs.ejs', {
|
|
485
|
+
...shared,
|
|
486
|
+
functionName: wbsMainFileName
|
|
487
|
+
})
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
path: `${source}/${tag}_HdrWbs.js`,
|
|
491
|
+
content: await renderCrudTemplate('FlowEndpoint_HdrWbs.ejs', {
|
|
492
|
+
...shared,
|
|
493
|
+
functionName: tag,
|
|
494
|
+
mainFileName: wbsMainFileName,
|
|
495
|
+
route: tag
|
|
496
|
+
})
|
|
497
|
+
}
|
|
498
|
+
];
|
|
499
|
+
|
|
500
|
+
const ownFunctions = [
|
|
501
|
+
renderWbsFunctionYaml({
|
|
502
|
+
functionName: `${tag}HdrWbs`,
|
|
503
|
+
handlerPath: `${handlerRoot}/${tag}_HdrWbs.main`,
|
|
504
|
+
roleName: customFlowRoleName(flow.flowTag),
|
|
505
|
+
routeName: tag,
|
|
506
|
+
flowTag: flow.flowTag,
|
|
507
|
+
flowStepName: ''
|
|
508
|
+
}),
|
|
509
|
+
renderSqsFunctionYaml({
|
|
510
|
+
functionName: `${tag}HdrSqs`,
|
|
511
|
+
handlerPath: `${handlerRoot}/${tag}_HdrSqs.main`,
|
|
512
|
+
roleName: customFlowRoleName(flow.flowTag),
|
|
513
|
+
queueName: `${tag}HdrSqs`,
|
|
514
|
+
flowTag: flow.flowTag,
|
|
515
|
+
flowStepName: ''
|
|
516
|
+
})
|
|
517
|
+
];
|
|
518
|
+
|
|
519
|
+
if (isRbac) {
|
|
520
|
+
const rbacStep = (flow.flowSteps || []).find(
|
|
521
|
+
(s) => typeof s?.stepName === 'string' && s.stepName.toLowerCase() === 'rbaccallback'
|
|
522
|
+
);
|
|
523
|
+
const rbacConfig = rbacStep ? stepConfig(flow, rbacStep) : null;
|
|
524
|
+
ownArtifacts.push(
|
|
436
525
|
{
|
|
437
|
-
path: `${source}/${
|
|
438
|
-
content: await
|
|
439
|
-
|
|
440
|
-
|
|
526
|
+
path: `${source}/${tag}RbacCallback_Main.js`,
|
|
527
|
+
content: await renderCustom('FlowEndpointRbacCallback_Main.ejs', {
|
|
528
|
+
flowTag: flow.flowTag,
|
|
529
|
+
upperCaseFlowTag: tag,
|
|
530
|
+
functionName: `${tag}RbacCallbackMain`
|
|
441
531
|
})
|
|
442
532
|
},
|
|
443
533
|
{
|
|
444
|
-
path: `${source}/${tag}
|
|
445
|
-
content: await
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
mainFileName:
|
|
449
|
-
|
|
534
|
+
path: `${source}/${tag}RbacCallback_HdrSqs.js`,
|
|
535
|
+
content: await renderShared('FlowHandler_HdrSqs.ejs', {
|
|
536
|
+
flowTag: flow.flowTag,
|
|
537
|
+
flowStepName: 'RbacCallback',
|
|
538
|
+
mainFileName: `${tag}RbacCallback_Main`,
|
|
539
|
+
functionName: `${tag}RbacCallbackMain`,
|
|
540
|
+
queueName: `${tag}RbacCallbackHdrSqs`,
|
|
541
|
+
startConfig: rbacConfig
|
|
450
542
|
})
|
|
451
543
|
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
renderWbsFunctionYaml({
|
|
455
|
-
functionName: `${tag}HdrWbs`,
|
|
456
|
-
handlerPath: `${handlerRoot}/${tag}_HdrWbs.main`,
|
|
457
|
-
roleName: customFlowRoleName(flow.flowTag),
|
|
458
|
-
routeName: tag,
|
|
459
|
-
flowTag: flow.flowTag,
|
|
460
|
-
flowStepName: ''
|
|
461
|
-
}),
|
|
544
|
+
);
|
|
545
|
+
ownFunctions.push(
|
|
462
546
|
renderSqsFunctionYaml({
|
|
463
|
-
functionName: `${tag}
|
|
464
|
-
handlerPath: `${handlerRoot}/${tag}
|
|
547
|
+
functionName: `${tag}RbacCallbackHdrSqs`,
|
|
548
|
+
handlerPath: `${handlerRoot}/${tag}RbacCallback_HdrSqs.main`,
|
|
465
549
|
roleName: customFlowRoleName(flow.flowTag),
|
|
466
|
-
queueName: `${tag}
|
|
550
|
+
queueName: `${tag}RbacCallbackHdrSqs`,
|
|
467
551
|
flowTag: flow.flowTag,
|
|
468
|
-
flowStepName: ''
|
|
552
|
+
flowStepName: 'RbacCallback'
|
|
469
553
|
})
|
|
470
|
-
|
|
554
|
+
);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
return {
|
|
558
|
+
artifacts: ownArtifacts,
|
|
559
|
+
functions: ownFunctions
|
|
471
560
|
};
|
|
472
561
|
}
|
|
473
562
|
|
|
474
|
-
function ownTopicRootPaths(flow) {
|
|
563
|
+
function ownTopicRootPaths(flow, objects = []) {
|
|
475
564
|
const tag = upperFirst(flow.flowTag);
|
|
476
565
|
const source = `app/src/generatedCode/FlowSchemas/${tag}/source`;
|
|
477
|
-
|
|
566
|
+
const paths = [
|
|
478
567
|
`${source}/${tag}_Main.js`,
|
|
479
568
|
`${source}/${tag}_HdrSqs.js`,
|
|
480
569
|
`${source}/${tag}_WbsMain.js`,
|
|
481
570
|
`${source}/${tag}_HdrWbs.js`
|
|
482
571
|
];
|
|
572
|
+
if (flowHasRbac(flow, objects)) {
|
|
573
|
+
paths.push(
|
|
574
|
+
`${source}/${tag}RbacCallback_Main.js`,
|
|
575
|
+
`${source}/${tag}RbacCallback_HdrSqs.js`
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
return paths;
|
|
483
579
|
}
|
|
484
580
|
|
|
485
581
|
function needsProcessMain(flow) {
|
|
@@ -694,12 +790,35 @@ function isS3Only(flow) {
|
|
|
694
790
|
return flow.event.length === 1 && flow.event[0] === 's3';
|
|
695
791
|
}
|
|
696
792
|
|
|
697
|
-
async function renderEndpointMain(flow, functionName, objects) {
|
|
793
|
+
async function renderEndpointMain(flow, functionName, objects = []) {
|
|
794
|
+
const isRbac = flowHasRbac(flow, objects);
|
|
795
|
+
const matchedObject = objects.find(
|
|
796
|
+
(o) => o.objectType === flow.objType?.objectType
|
|
797
|
+
);
|
|
798
|
+
let rbacServiceTag = null;
|
|
799
|
+
if (matchedObject) {
|
|
800
|
+
const belongTo = matchedObject.belongTo;
|
|
801
|
+
if (belongTo) {
|
|
802
|
+
rbacServiceTag = Array.isArray(belongTo)
|
|
803
|
+
? belongTo[0]?.serviceTag
|
|
804
|
+
: belongTo?.serviceTag;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
if (!rbacServiceTag) {
|
|
808
|
+
rbacServiceTag = flow.objType?.serviceTag || flow.serviceTag || 'Rbac';
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
const enrichedFlow = {
|
|
812
|
+
...flow,
|
|
813
|
+
isRbac
|
|
814
|
+
};
|
|
815
|
+
|
|
698
816
|
return renderCustom('FlowEndpoint_Main.ejs', {
|
|
699
|
-
flow,
|
|
817
|
+
flow: enrichedFlow,
|
|
700
818
|
flowTag: flow.flowTag,
|
|
701
819
|
upperCaseFlowTag: upperFirst(flow.flowTag),
|
|
702
820
|
functionName,
|
|
821
|
+
rbacServiceTag,
|
|
703
822
|
tableName: storedCacheTableName(flow, objects),
|
|
704
823
|
startConfig: _startConfig(flow)
|
|
705
824
|
});
|
|
@@ -32,7 +32,7 @@ export async function generateCustomFlowApplicationArtifacts(
|
|
|
32
32
|
managedPaths: [
|
|
33
33
|
...systemWebSocketManagedPaths(),
|
|
34
34
|
...customFlowApplicationManagedPaths(flows, {
|
|
35
|
-
includeYaml: hasSystemWebSocket(flows)
|
|
35
|
+
includeYaml: hasSystemWebSocket(flows), objects
|
|
36
36
|
})
|
|
37
37
|
],
|
|
38
38
|
managedScope: 'custom-flow-application'
|