@izara_project/izara-core-generate-service-code 1.0.74 → 1.0.76
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/compile/loadSchemas.js +36 -30
- package/src/emit/coreFunction/emitCoreFunctionArtifacts.js +2 -4
- package/src/emit/coreFunction/templates/InitialSetupConfig.ejs +12 -2
- package/src/emit/coreFunction/templates/InitialSetupRunner.ejs +5 -3
- package/src/emit/coreFunction/templates/InitialSetupRunner_uploadSchema.ejs +13 -6
- package/src/emit/coreFunction/templates/InitialSetup_HdrInv.ejs +1 -1
- package/src/emit/crud/emitCrudApplicationArtifacts.js +2 -2
- package/src/emit/crud/emitDynamicCrudFlowSchemas.js +43 -2
- package/src/emit/crud/templates/CreateComplete_HdrSqs.ejs +99 -0
- package/src/emit/crud/templates/CreateComplete_Main.ejs +188 -0
- package/src/emit/crud/templates/DeleteComplete_HdrSqs.ejs +99 -0
- package/src/emit/crud/templates/DeleteComplete_Main.ejs +188 -0
- package/src/emit/crud/templates/FlowEndpointComplete_Main.ejs +1 -1
- package/src/emit/crud/templates/UpdateComplete_HdrSqs.ejs +99 -0
- package/src/emit/crud/templates/UpdateComplete_Main.ejs +188 -0
- package/src/emit/custom/customFlows.js +15 -1
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +2 -0
- package/src/emit/custom/templates/FlowEndpoint_Main.ejs +1 -1
- package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +20 -5
- package/src/emit/rbac/emitRbacApplicationArtifacts.js +58 -43
- package/src/emit/rbac/templates/CreateTargetRole_HdrSqs.ejs +68 -20
- package/src/emit/rbac/templates/ListRbac_HdrSqs.ejs +69 -20
- package/src/emit/rbac/templates/UserRbacFlow_HdrSqs.ejs +69 -20
- package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +21 -1
- package/src/emit/relationship/emitRelationshipApplicationArtifacts.js +1 -1
- package/src/emit/relationship/templates/ChangeRelationshipComplete_HdrSqs.ejs +99 -0
- package/src/emit/relationship/templates/ChangeRelationshipComplete_Main.ejs +91 -87
- package/src/emit/relationship/templates/CreateRelationshipComplete_HdrSqs.ejs +99 -0
- package/src/emit/relationship/templates/CreateRelationshipComplete_Main.ejs +90 -86
- package/src/emit/relationship/templates/DeleteRelationshipComplete_HdrSqs.ejs +99 -0
- package/src/emit/relationship/templates/DeleteRelationshipComplete_Main.ejs +85 -81
- package/src/emit/relationship/templates/GetRelationshipComplete_HdrSqs.ejs +99 -0
- package/src/emit/relationship/templates/GetRelationshipComplete_Main.ejs +2 -0
- package/src/emit/relationship/templates/GetRelationship_Main.ejs +2 -20
- package/src/emit/relationship/templates/MoveRelationshipComplete_HdrSqs.ejs +99 -0
- package/src/emit/relationship/templates/MoveRelationshipComplete_Main.ejs +93 -89
- package/src/emit/relationship/templates/UpdateRelationshipComplete_HdrSqs.ejs +99 -0
- package/src/emit/relationship/templates/UpdateRelationshipComplete_Main.ejs +85 -81
- package/src/emit/resource/emitResourceArtifacts.js +36 -2
- package/src/emit/shared/templates/FindData_Main.ejs +1 -1
- package/src/emit/system/emitSystemWebSocketArtifacts.js +54 -2
- package/src/emit/system/templates/RegisterComplete_HdrSqs.ejs +64 -0
- package/src/emit/system/templates/RegisterComplete_Main.ejs +154 -0
- package/src/emit/system/templates/RegisterComplete_Yaml.ejs +17 -0
- package/src/emit/system/templates/RegisterWbs_Yaml.ejs +7 -0
- package/src/emit/system/templates/Register_HdrWbs.ejs +56 -0
- package/src/emit/system/templates/Register_Main.ejs +148 -0
- package/src/output/mergeHooks.js +4 -3
- package/test/customFlowApplicationArtifacts.test.js +16 -5
- package/test/publicApi.test.js +21 -0
- package/test/relationshipApplicationArtifacts.test.js +1 -1
- package/test/resourceArtifacts.test.js +20 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { middlewareHandler as middleware } from '@izara_project/izara-middleware';
|
|
2
|
+
import { recordHandlerSharedLib } from '@izara_project/izara-core-library-record-handler';
|
|
3
|
+
import Logger from '@izara_project/izara-core-library-logger';
|
|
4
|
+
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
5
|
+
import UpdateRelationshipComplete from './UpdateRelationshipComplete_Main.js';
|
|
6
|
+
|
|
7
|
+
//(<optionalRequire>)
|
|
8
|
+
//(</optionalRequire>)
|
|
9
|
+
|
|
10
|
+
// validate event properties in body.Message of sqs event
|
|
11
|
+
let perRecordsValidatorSchema = {
|
|
12
|
+
type: 'object',
|
|
13
|
+
properties: {
|
|
14
|
+
returnValue: {
|
|
15
|
+
type: 'object'
|
|
16
|
+
},
|
|
17
|
+
parentFlowId: {
|
|
18
|
+
type: 'string'
|
|
19
|
+
},
|
|
20
|
+
status: {
|
|
21
|
+
type: 'string'
|
|
22
|
+
},
|
|
23
|
+
errorsFound: {
|
|
24
|
+
type: 'array'
|
|
25
|
+
},
|
|
26
|
+
graphServiceTag: {
|
|
27
|
+
type: 'string'
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
required: [
|
|
31
|
+
'returnValue',
|
|
32
|
+
'parentFlowId',
|
|
33
|
+
'status',
|
|
34
|
+
'errorsFound',
|
|
35
|
+
'graphServiceTag'
|
|
36
|
+
]
|
|
37
|
+
//(<validatorSchema>)
|
|
38
|
+
//(</validatorSchema>)
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
let messageAttributeValidatorSchema = null;
|
|
42
|
+
middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
|
|
43
|
+
|
|
44
|
+
export const main = middleware.wrap(async (event, context) => {
|
|
45
|
+
try {
|
|
46
|
+
let recordPromises = [];
|
|
47
|
+
|
|
48
|
+
// loop each record and send to mainFunction
|
|
49
|
+
await Promise.all(
|
|
50
|
+
event.Records.map(async (record) => {
|
|
51
|
+
let passOnProperties = [];
|
|
52
|
+
record._izContext.logger.debug('record ReceiveMsgOutHdrSqs', record);
|
|
53
|
+
|
|
54
|
+
//validate message (and MessageAttributes)
|
|
55
|
+
await recordHandlerSharedLib.validateRecord(
|
|
56
|
+
record, // one record will send to mainFunction
|
|
57
|
+
'UpdateRelationshipCompleteHdrSqs', // queue name that need to retry or send to dlq
|
|
58
|
+
perRecordsValidatorSchema, // schema for record.Message
|
|
59
|
+
messageAttributeValidatorSchema
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
// add argument (to invoke lambda) to passOnProperties[]
|
|
63
|
+
passOnProperties.push(record.body.Message);
|
|
64
|
+
passOnProperties.push(
|
|
65
|
+
callingFlowSharedLib.addPassBackPropertiesToPassOnProperties(
|
|
66
|
+
record.body.Message
|
|
67
|
+
)
|
|
68
|
+
);
|
|
69
|
+
//(<additionalParams>)
|
|
70
|
+
//(</additionalParams>)
|
|
71
|
+
record._izContext.logger.debug(
|
|
72
|
+
'passOnProperties in handler',
|
|
73
|
+
passOnProperties
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
// call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
|
|
77
|
+
let recordPromise = recordHandlerSharedLib.recordHandler(
|
|
78
|
+
record, // one record will send to mainFunction
|
|
79
|
+
UpdateRelationshipComplete, // mainFunction that need to invoke.
|
|
80
|
+
'UpdateRelationshipCompleteHdrSqs', // queue name that need to retry or send to dlq
|
|
81
|
+
passOnProperties // all parameters that mainFunction needed.
|
|
82
|
+
);
|
|
83
|
+
record._izContext.logger.debug('after recordPromise in handler');
|
|
84
|
+
recordPromises.push(recordPromise); // push promise to recordPromises
|
|
85
|
+
})
|
|
86
|
+
);
|
|
87
|
+
try {
|
|
88
|
+
await Promise.all(recordPromises);
|
|
89
|
+
return event.Records;
|
|
90
|
+
} catch {
|
|
91
|
+
Logger.debug(
|
|
92
|
+
'Promise.all(recordPromises) in handler threw error (at least one record did no resolve)'
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
} catch (error) {
|
|
96
|
+
Logger.error('Unhandled Error, UpdateRelationshipComplete_HdrSqs: ', error);
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
@@ -19,7 +19,7 @@ import { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
|
19
19
|
|
|
20
20
|
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
21
21
|
import snsSharedLib from '@izara_project/izara-core-library-sns';
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-flow';
|
|
24
24
|
|
|
25
25
|
import { sns } from '@izara_project/izara-core-library-external-request';
|
|
@@ -43,6 +43,7 @@ export default async function updateRelationshipComplete(
|
|
|
43
43
|
try {
|
|
44
44
|
const {
|
|
45
45
|
returnValue,
|
|
46
|
+
parentFlowId,
|
|
46
47
|
status,
|
|
47
48
|
errorsFound,
|
|
48
49
|
graphServiceTag
|
|
@@ -50,6 +51,7 @@ export default async function updateRelationshipComplete(
|
|
|
50
51
|
|
|
51
52
|
_izContext.logger.debug('Function:updateRelationshipComplete', {
|
|
52
53
|
returnValue: returnValue,
|
|
54
|
+
parentFlowId: parentFlowId,
|
|
53
55
|
status: status,
|
|
54
56
|
errorsFound: errorsFound,
|
|
55
57
|
graphServiceTag: graphServiceTag,
|
|
@@ -57,94 +59,96 @@ export default async function updateRelationshipComplete(
|
|
|
57
59
|
// callingFlowConfig: callingFlowConfig
|
|
58
60
|
});
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
returnValue
|
|
62
|
+
const awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
|
|
63
|
+
parentFlowId || returnValue?.parentFlowId, // hash id
|
|
62
64
|
PREFIX.updateRel // prefix, use constant further
|
|
63
65
|
);
|
|
64
66
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
const pending =
|
|
68
|
+
await asyncFlowSharedLib.findPendingStepAwaitingMultipleSteps(
|
|
69
|
+
_izContext,
|
|
70
|
+
awaitingStepId
|
|
71
|
+
);
|
|
72
|
+
_izContext.logger.debug('[UpdateRelationshipComplete] awaiting step', {
|
|
73
|
+
awaitingStepId,
|
|
74
|
+
pending
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
if (!pending) {
|
|
78
|
+
_izContext.logger.warn(
|
|
79
|
+
`No pending step found for awaitingStepId: ${awaitingStepId}`
|
|
80
|
+
);
|
|
81
|
+
return { returnValue, status, errorsFound };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const result =
|
|
85
|
+
await asyncFlowSharedLib.checkAllAwaitingStepsFinishedWithReturnParams(
|
|
86
|
+
_izContext,
|
|
87
|
+
pending.pendingStepId,
|
|
88
|
+
awaitingStepId,
|
|
89
|
+
errorsFound
|
|
90
|
+
);
|
|
91
|
+
_izContext.logger.debug(
|
|
92
|
+
'[UpdateRelationshipComplete] all awaiting steps result',
|
|
68
93
|
{
|
|
69
|
-
|
|
94
|
+
isComplete: result.isComplete,
|
|
95
|
+
awaitingStepId,
|
|
96
|
+
pendingStepId: pending.pendingStepId
|
|
70
97
|
}
|
|
71
98
|
);
|
|
72
|
-
_izContext.logger.debug(
|
|
73
|
-
'record of updateRelPendingObjects ::',
|
|
74
|
-
updateRelPendingObjects
|
|
75
|
-
);
|
|
76
99
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
errorsFound: errorsFound
|
|
94
|
-
//(<inUpdateCompleteMsg>)
|
|
95
|
-
//(</inUpdateCompleteMsg>)
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
updateCompleteMsg =
|
|
99
|
-
callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(
|
|
100
|
-
passBackProperties,
|
|
101
|
-
updateCompleteMsg
|
|
102
|
-
);
|
|
103
|
-
_izContext.logger.debug(
|
|
104
|
-
'After addCallingFlowToSnsResponseMessageObject',
|
|
105
|
-
updateCompleteMsg
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
let messageAttributes =
|
|
109
|
-
callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(
|
|
110
|
-
passBackProperties,
|
|
111
|
-
{}
|
|
112
|
-
);
|
|
113
|
-
_izContext.logger.debug(
|
|
114
|
-
'After addCallingFlowToSnsResponseMessageAttributes',
|
|
115
|
-
updateCompleteMsg
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
let sendMessageToOutUpdateRelationshipComplete = {
|
|
119
|
-
Message: JSON.stringify(updateCompleteMsg),
|
|
120
|
-
MessageAttributes: sns.createStringMessageAttributes(
|
|
121
|
-
_izContext,
|
|
122
|
-
messageAttributes
|
|
123
|
-
),
|
|
124
|
-
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
125
|
-
_izContext,
|
|
126
|
-
TOPIC_NAME_GENERATE_CODE.outUpdateRelComplete
|
|
127
|
-
)
|
|
128
|
-
};
|
|
129
|
-
_izContext.logger.debug(
|
|
130
|
-
'Send message to OutUpdateRelationshipComplete :::>',
|
|
131
|
-
sendMessageToOutUpdateRelationshipComplete
|
|
132
|
-
);
|
|
133
|
-
await sns.publishAsync(
|
|
134
|
-
_izContext,
|
|
135
|
-
sendMessageToOutUpdateRelationshipComplete
|
|
136
|
-
);
|
|
137
|
-
} // check pendingStepId finished
|
|
138
|
-
|
|
139
|
-
// remove awaitingMultipleStep after finished
|
|
140
|
-
await asyncFlowSharedLib.removeAwaitingMultipleStep(
|
|
141
|
-
_izContext,
|
|
142
|
-
awaitingStepId,
|
|
143
|
-
pendingStepId,
|
|
144
|
-
errorsFound
|
|
100
|
+
if (result.isComplete) {
|
|
101
|
+
_izContext.logger.debug('finished all awaitingStep');
|
|
102
|
+
|
|
103
|
+
let updateCompleteMsg = {
|
|
104
|
+
relId: returnValue.requestParams.relId,
|
|
105
|
+
relType: returnValue.requestParams.relType,
|
|
106
|
+
status: status,
|
|
107
|
+
errorsFound: errorsFound
|
|
108
|
+
//(<inUpdateCompleteMsg>)
|
|
109
|
+
//(</inUpdateCompleteMsg>)
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
updateCompleteMsg =
|
|
113
|
+
callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(
|
|
114
|
+
passBackProperties,
|
|
115
|
+
updateCompleteMsg
|
|
145
116
|
);
|
|
146
|
-
|
|
147
|
-
|
|
117
|
+
_izContext.logger.debug(
|
|
118
|
+
'After addCallingFlowToSnsResponseMessageObject',
|
|
119
|
+
updateCompleteMsg
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
let messageAttributes =
|
|
123
|
+
callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(
|
|
124
|
+
passBackProperties,
|
|
125
|
+
{}
|
|
126
|
+
);
|
|
127
|
+
_izContext.logger.debug(
|
|
128
|
+
'After addCallingFlowToSnsResponseMessageAttributes',
|
|
129
|
+
updateCompleteMsg
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
let sendMessageToOutUpdateRelationshipComplete = {
|
|
133
|
+
Message: JSON.stringify(updateCompleteMsg),
|
|
134
|
+
MessageAttributes: sns.createStringMessageAttributes(
|
|
135
|
+
_izContext,
|
|
136
|
+
messageAttributes
|
|
137
|
+
),
|
|
138
|
+
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
139
|
+
_izContext,
|
|
140
|
+
TOPIC_NAME_GENERATE_CODE.outUpdateRelComplete
|
|
141
|
+
)
|
|
142
|
+
};
|
|
143
|
+
_izContext.logger.debug(
|
|
144
|
+
'Send message to OutUpdateRelationshipComplete :::>',
|
|
145
|
+
sendMessageToOutUpdateRelationshipComplete
|
|
146
|
+
);
|
|
147
|
+
await sns.publishAsync(
|
|
148
|
+
_izContext,
|
|
149
|
+
sendMessageToOutUpdateRelationshipComplete
|
|
150
|
+
);
|
|
151
|
+
} // check isComplete finished
|
|
148
152
|
|
|
149
153
|
return {
|
|
150
154
|
returnValue,
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
customFlowRoleName,
|
|
6
6
|
flowDsqSteps,
|
|
7
7
|
flowExtTopicSteps,
|
|
8
|
+
generatedDsqFlows,
|
|
8
9
|
generatedOwnTopicFlows,
|
|
9
10
|
supportedCustomFlows
|
|
10
11
|
} from '../custom/customFlows.js';
|
|
@@ -74,6 +75,12 @@ const SQS_CONSUMER_ACTIONS = [
|
|
|
74
75
|
'sqs:GetQueueAttributes',
|
|
75
76
|
'sqs:ReceiveMessage'
|
|
76
77
|
];
|
|
78
|
+
const SQS_DLQ_ACTIONS = [
|
|
79
|
+
'sqs:DeleteMessage',
|
|
80
|
+
'sqs:GetQueueAttributes',
|
|
81
|
+
'sqs:ReceiveMessage',
|
|
82
|
+
'sqs:SendMessage'
|
|
83
|
+
];
|
|
77
84
|
|
|
78
85
|
export async function emitResourceArtifacts({
|
|
79
86
|
objects,
|
|
@@ -141,6 +148,7 @@ export const resourceArtifactPaths = [
|
|
|
141
148
|
|
|
142
149
|
function createResourceState({ objects, relationships, flows }) {
|
|
143
150
|
const crud = objects.some(isCrudObject);
|
|
151
|
+
const selfRbac = objects.some(hasSelfRbacAddOn);
|
|
144
152
|
const rbac = objects.some(hasRbacAddOn);
|
|
145
153
|
const ownTopics = new Set([
|
|
146
154
|
'ProcessLogical',
|
|
@@ -188,11 +196,13 @@ function createResourceState({ objects, relationships, flows }) {
|
|
|
188
196
|
}
|
|
189
197
|
dsqQueues.add('GetRelationshipHdrDsq');
|
|
190
198
|
}
|
|
191
|
-
if (
|
|
199
|
+
if (selfRbac) {
|
|
192
200
|
for (const action of RBAC_ACTIONS) {
|
|
193
201
|
ownTopics.add(action);
|
|
194
202
|
sqsQueues.add(`Process${action}HdrSqs`);
|
|
195
203
|
}
|
|
204
|
+
}
|
|
205
|
+
if (rbac) {
|
|
196
206
|
for (const object of objects.filter(hasRbacAddOn)) {
|
|
197
207
|
const flowTag = upperFirst(object.objectType) + 'RbacFlow';
|
|
198
208
|
ownTopics.add(flowTag);
|
|
@@ -219,6 +229,9 @@ function createResourceState({ objects, relationships, flows }) {
|
|
|
219
229
|
...generatedOwnTopicFlows(flows).map((flow) =>
|
|
220
230
|
customFlowRoleName(flow.flowTag)
|
|
221
231
|
),
|
|
232
|
+
...generatedDsqFlows(flows).map((flow) =>
|
|
233
|
+
customFlowRoleName(flow.flowTag)
|
|
234
|
+
),
|
|
222
235
|
...flowExtTopicSteps(flows).map(({ flow }) =>
|
|
223
236
|
customFlowRoleName(flow.flowTag)
|
|
224
237
|
),
|
|
@@ -497,6 +510,11 @@ function roleStatements(state, roleName) {
|
|
|
497
510
|
SQS_CONSUMER_ACTIONS,
|
|
498
511
|
queueArns(roleQueueNames(state, roleName))
|
|
499
512
|
);
|
|
513
|
+
addStatement(
|
|
514
|
+
statements,
|
|
515
|
+
SQS_DLQ_ACTIONS,
|
|
516
|
+
queueArns(roleDlqQueueNames(state, roleName))
|
|
517
|
+
);
|
|
500
518
|
addStatement(
|
|
501
519
|
statements,
|
|
502
520
|
['sns:Publish'],
|
|
@@ -649,6 +667,14 @@ function roleQueueNames(state, roleName) {
|
|
|
649
667
|
return queueList;
|
|
650
668
|
}
|
|
651
669
|
|
|
670
|
+
function roleDlqQueueNames(state, roleName) {
|
|
671
|
+
const queues = roleQueueNames(state, roleName);
|
|
672
|
+
if (!Array.isArray(queues) || queues.length === 0) {
|
|
673
|
+
return [];
|
|
674
|
+
}
|
|
675
|
+
return queues.map((q) => (q.endsWith('DLQ') ? q : `${q}DLQ`));
|
|
676
|
+
}
|
|
677
|
+
|
|
652
678
|
function roleTopicNames(state, roleName) {
|
|
653
679
|
if (roleName === 'ProcFindDataRole') return [];
|
|
654
680
|
if (roleName === 'FlowObjectsRole')
|
|
@@ -793,13 +819,21 @@ function isCrudObject(object) {
|
|
|
793
819
|
object?.generatedBy === 'systemGenerated'
|
|
794
820
|
);
|
|
795
821
|
}
|
|
796
|
-
function
|
|
822
|
+
function hasSelfRbacAddOn(object) {
|
|
797
823
|
return (
|
|
798
824
|
Array.isArray(object?.addOnDataStructure) &&
|
|
799
825
|
object.addOnDataStructure.some((addOn) => addOn?.type === 'rbac')
|
|
800
826
|
);
|
|
801
827
|
}
|
|
802
828
|
|
|
829
|
+
function hasRbacAddOn(object) {
|
|
830
|
+
const selfHasRbac = hasSelfRbacAddOn(object);
|
|
831
|
+
const belongToHasRbac =
|
|
832
|
+
Array.isArray(object?.belongToSchema?.addOnDataStructure) &&
|
|
833
|
+
object.belongToSchema.addOnDataStructure.some((addOn) => addOn?.type === 'rbac');
|
|
834
|
+
return selfHasRbac || belongToHasRbac;
|
|
835
|
+
}
|
|
836
|
+
|
|
803
837
|
/**
|
|
804
838
|
* Returns the per-object RBAC flow queues (e.g. UserRbacFlowHdrSqs)
|
|
805
839
|
* created for objects with an 'rbac' add-on. These are consumed by the
|
|
@@ -3,6 +3,8 @@ import ejsLib from 'ejs';
|
|
|
3
3
|
|
|
4
4
|
const TEMPLATE_URL = new URL('./templates/', import.meta.url);
|
|
5
5
|
const SOURCE = 'app/src/generatedCode/SystemFlowSchemas/WebSocketMain/source';
|
|
6
|
+
const REGISTER_SOURCE =
|
|
7
|
+
'app/src/generatedCode/SystemFlowSchemas/Register/source';
|
|
6
8
|
|
|
7
9
|
async function _renderSystemTemplate(templateName, data = {}) {
|
|
8
10
|
const templatePath = new URL(templateName, TEMPLATE_URL);
|
|
@@ -27,12 +29,32 @@ export async function emitSystemWebSocketArtifacts(
|
|
|
27
29
|
const webSocketCompleteHdrSqsContent = await _renderSystemTemplate(
|
|
28
30
|
'WebSocketComplete_HdrSqs.ejs'
|
|
29
31
|
);
|
|
32
|
+
const registerMainContent = await _renderSystemTemplate('Register_Main.ejs');
|
|
33
|
+
const registerHdrWbsContent = await _renderSystemTemplate(
|
|
34
|
+
'Register_HdrWbs.ejs'
|
|
35
|
+
);
|
|
36
|
+
const registerCompleteMainContent = await _renderSystemTemplate(
|
|
37
|
+
'RegisterComplete_Main.ejs'
|
|
38
|
+
);
|
|
39
|
+
const registerCompleteHdrSqsContent = await _renderSystemTemplate(
|
|
40
|
+
'RegisterComplete_HdrSqs.ejs',
|
|
41
|
+
{ queueName: 'RegisterComplete' }
|
|
42
|
+
);
|
|
43
|
+
const registerCompleteHdrDsqContent = await _renderSystemTemplate(
|
|
44
|
+
'RegisterComplete_HdrSqs.ejs',
|
|
45
|
+
{ queueName: 'RegisterCompleteDLQ' }
|
|
46
|
+
);
|
|
47
|
+
|
|
30
48
|
const webSocketConnectYaml = await _renderSystemTemplate(
|
|
31
49
|
'WebSocketConnect_Yaml.ejs'
|
|
32
50
|
);
|
|
33
51
|
const webSocketCompleteYaml = await _renderSystemTemplate(
|
|
34
52
|
'WebSocketComplete_Yaml.ejs'
|
|
35
53
|
);
|
|
54
|
+
const registerWbsYaml = await _renderSystemTemplate('RegisterWbs_Yaml.ejs');
|
|
55
|
+
const registerCompleteYaml = await _renderSystemTemplate(
|
|
56
|
+
'RegisterComplete_Yaml.ejs'
|
|
57
|
+
);
|
|
36
58
|
|
|
37
59
|
return {
|
|
38
60
|
artifacts: [
|
|
@@ -47,9 +69,34 @@ export async function emitSystemWebSocketArtifacts(
|
|
|
47
69
|
{
|
|
48
70
|
path: `${SOURCE}/WebSocketComplete_HdrSqs.js`,
|
|
49
71
|
content: webSocketCompleteHdrSqsContent
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
path: `${REGISTER_SOURCE}/Register_Main.js`,
|
|
75
|
+
content: registerMainContent
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
path: `${REGISTER_SOURCE}/Register_HdrWbs.js`,
|
|
79
|
+
content: registerHdrWbsContent
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
path: `${REGISTER_SOURCE}/RegisterComplete_Main.js`,
|
|
83
|
+
content: registerCompleteMainContent
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
path: `${REGISTER_SOURCE}/RegisterComplete_HdrSqs.js`,
|
|
87
|
+
content: registerCompleteHdrSqsContent
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
path: `${REGISTER_SOURCE}/RegisterComplete_HdrDsq.js`,
|
|
91
|
+
content: registerCompleteHdrDsqContent
|
|
50
92
|
}
|
|
51
93
|
],
|
|
52
|
-
functions: [
|
|
94
|
+
functions: [
|
|
95
|
+
webSocketConnectYaml,
|
|
96
|
+
webSocketCompleteYaml,
|
|
97
|
+
registerWbsYaml,
|
|
98
|
+
registerCompleteYaml
|
|
99
|
+
]
|
|
53
100
|
};
|
|
54
101
|
}
|
|
55
102
|
|
|
@@ -57,7 +104,12 @@ export function systemWebSocketManagedPaths() {
|
|
|
57
104
|
return [
|
|
58
105
|
`${SOURCE}/WebSocketConnect.js`,
|
|
59
106
|
`${SOURCE}/WebSocketComplete_Main.js`,
|
|
60
|
-
`${SOURCE}/WebSocketComplete_HdrSqs.js
|
|
107
|
+
`${SOURCE}/WebSocketComplete_HdrSqs.js`,
|
|
108
|
+
`${REGISTER_SOURCE}/Register_Main.js`,
|
|
109
|
+
`${REGISTER_SOURCE}/Register_HdrWbs.js`,
|
|
110
|
+
`${REGISTER_SOURCE}/RegisterComplete_Main.js`,
|
|
111
|
+
`${REGISTER_SOURCE}/RegisterComplete_HdrSqs.js`,
|
|
112
|
+
`${REGISTER_SOURCE}/RegisterComplete_HdrDsq.js`
|
|
61
113
|
];
|
|
62
114
|
}
|
|
63
115
|
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { middlewareHandler } from '@izara_project/izara-middleware';
|
|
2
|
+
import Logger from '@izara_project/izara-core-library-logger';
|
|
3
|
+
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
4
|
+
import { recordHandlerSharedLib } from '@izara_project/izara-core-library-record-handler';
|
|
5
|
+
import registerCompleteMain from './RegisterComplete_Main.js';
|
|
6
|
+
|
|
7
|
+
middlewareHandler.setValidatorSchema(
|
|
8
|
+
recordHandlerSharedLib.baseValidatorSchema()
|
|
9
|
+
);
|
|
10
|
+
let perRecordsValidatorSchema = {};
|
|
11
|
+
|
|
12
|
+
export const main = middlewareHandler.wrap(async (event, context) => {
|
|
13
|
+
try {
|
|
14
|
+
let recordPromises = [];
|
|
15
|
+
|
|
16
|
+
await Promise.all(
|
|
17
|
+
event.Records.map(async (record) => {
|
|
18
|
+
let passOnProperties = [];
|
|
19
|
+
record._izContext.logger.debug('record ReceiveMsgOutHdrSqs', record);
|
|
20
|
+
|
|
21
|
+
await recordHandlerSharedLib.validateRecord(
|
|
22
|
+
record,
|
|
23
|
+
'<%= queueName %>',
|
|
24
|
+
perRecordsValidatorSchema
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
passOnProperties.push(record.body.TopicArn);
|
|
28
|
+
passOnProperties.push(record.body.Message);
|
|
29
|
+
passOnProperties.push(
|
|
30
|
+
callingFlowSharedLib.addCallingFlowToPassOnProperties(
|
|
31
|
+
record.body.Message
|
|
32
|
+
)
|
|
33
|
+
);
|
|
34
|
+
record._izContext.logger.debug(
|
|
35
|
+
'passOnProperties in handler',
|
|
36
|
+
passOnProperties
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
let recordPromise = recordHandlerSharedLib.recordHandler(
|
|
40
|
+
record,
|
|
41
|
+
registerCompleteMain,
|
|
42
|
+
'<%= queueName %>',
|
|
43
|
+
passOnProperties
|
|
44
|
+
);
|
|
45
|
+
record._izContext.logger.debug('after recordPromise in handler');
|
|
46
|
+
recordPromises.push(recordPromise);
|
|
47
|
+
})
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
Logger.debug('before Promise.all(recordPromises) in handler');
|
|
51
|
+
try {
|
|
52
|
+
await Promise.all(recordPromises);
|
|
53
|
+
return event.Records;
|
|
54
|
+
} catch {
|
|
55
|
+
Logger.debug(
|
|
56
|
+
'Promise.all(recordPromises) in handler threw error (at least one record did not resolve)'
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
Logger.debug('after Promise.all(recordPromises) in handler');
|
|
60
|
+
} catch (err) {
|
|
61
|
+
Logger.error('Unhandled Error, RegisterComplete: ', err);
|
|
62
|
+
throw err;
|
|
63
|
+
}
|
|
64
|
+
});
|