@izara_project/izara-core-generate-service-code 1.0.86 → 1.0.88
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 +45 -10
- package/src/emit/coreFunction/emitCoreFunctionArtifacts.js +1 -1
- package/src/emit/coreFunction/templates/InitialSetupConfig.ejs +22 -15
- package/src/emit/crud/crudActionPlan.js +47 -6
- package/src/emit/crud/emitCrudApplicationArtifacts.js +63 -3
- package/src/emit/crud/emitDynamicCrudFlowSchemas.js +6 -4
- package/src/emit/crud/templates/CreateAfterHookCallback_Main.ejs +121 -0
- package/src/emit/crud/templates/CreateBeforeHookCallback_Main.ejs +108 -0
- package/src/emit/crud/templates/CreateEndpoint_Main.ejs +138 -335
- package/src/emit/crud/templates/CreateLogicalLib.ejs +205 -42
- package/src/emit/crud/templates/CreateNodeCallback_Main.ejs +80 -0
- package/src/emit/crud/templates/DeleteBeforeHookCallback_Main.ejs +99 -0
- package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +153 -182
- package/src/emit/crud/templates/DeleteLogicalLib.ejs +132 -26
- package/src/emit/crud/templates/UpdateBeforeHookCallback_Main.ejs +112 -0
- package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +166 -188
- package/src/emit/crud/templates/UpdateLogicalLib.ejs +2 -2
- package/src/emit/custom/customFlows.js +3 -1
- package/src/emit/function/functionYamlArtifact.js +4 -2
- package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +0 -3
- package/src/emit/rbac/emitRbacApplicationArtifacts.js +1 -116
- package/src/emit/rbac/templates/CancelUsage_Main.ejs +14 -10
- package/src/emit/rbac/templates/ConfirmUsage_Main.ejs +14 -10
- package/src/emit/rbac/templates/CreateTargetRole_Main.ejs +22 -12
- package/src/emit/rbac/templates/GetMyPermissions_Main.ejs +14 -10
- package/src/emit/rbac/templates/ReservedDynamicUsage_Main.ejs +76 -34
- package/src/emit/rbac/templates/UserRbacFlow_Main.ejs +12 -9
- package/src/emit/resource/emitResourceArtifacts.js +141 -62
- package/src/emit/resource/templates/SystemDynamoDB_Yaml.ejs +14 -18
- package/src/emit/system/templates/WebSocketComplete_Yaml.ejs +4 -2
- package/test/createTargetRoleHandler.test.js +1 -15
- package/test/crudApplicationArtifacts.test.js +540 -3
- package/test/customFlowApplicationArtifacts.test.js +3 -5
- package/test/dynamicCrudFlowSchemas.test.js +5 -17
- package/test/dynamicRbacFlowSchemas.test.js +0 -3
- package/test/functionYamlArtifact.test.js +4 -2
- package/test/resourceArtifacts.test.js +203 -14
|
@@ -12,10 +12,7 @@ import {
|
|
|
12
12
|
} from '../custom/customFlows.js';
|
|
13
13
|
import { hasSystemWebSocket } from '../system/emitSystemWebSocketArtifacts.js';
|
|
14
14
|
import { rbacFlowTag } from '../rbac/rbacFlowTag.js';
|
|
15
|
-
import {
|
|
16
|
-
CRUD_ACTIONS,
|
|
17
|
-
createCrudActionPlans
|
|
18
|
-
} from '../crud/crudActionPlan.js';
|
|
15
|
+
import { CRUD_ACTIONS, createCrudActionPlans } from '../crud/crudActionPlan.js';
|
|
19
16
|
|
|
20
17
|
const TEMPLATE_URL = new URL('./templates/', import.meta.url);
|
|
21
18
|
const RESOURCE_ROOT = 'resource/sls_yaml/generatedCode/source';
|
|
@@ -43,9 +40,6 @@ const RBAC_ACTIONS = [
|
|
|
43
40
|
'DeleteUserFromRole',
|
|
44
41
|
'GetMyPermissions',
|
|
45
42
|
'ValidatorRbac',
|
|
46
|
-
'CreateRoleLimit',
|
|
47
|
-
'ListRoleLimits',
|
|
48
|
-
'DeleteRoleLimit',
|
|
49
43
|
'ReservedDynamicUsage',
|
|
50
44
|
'ConfirmUsage',
|
|
51
45
|
'CancelUsage'
|
|
@@ -62,12 +56,12 @@ const SYSTEM_TABLES = [
|
|
|
62
56
|
'AwaitingStep'
|
|
63
57
|
];
|
|
64
58
|
const RBAC_TABLES = [
|
|
59
|
+
'Roles',
|
|
65
60
|
'TargetRoles',
|
|
66
61
|
'RolePermissions',
|
|
67
62
|
'RoleUsers',
|
|
68
63
|
'UserRoles',
|
|
69
64
|
'RbacPermissionCaches',
|
|
70
|
-
'RoleLimit',
|
|
71
65
|
'RunningTotalUsage',
|
|
72
66
|
'RunningTotalReservedUsage',
|
|
73
67
|
'WebSocketTask'
|
|
@@ -211,7 +205,7 @@ function createResourceState({ objects, relationships, flows }) {
|
|
|
211
205
|
const crud = objects.some(isCrudObject);
|
|
212
206
|
const selfRbac = objects.some(hasSelfRbacAddOn);
|
|
213
207
|
const rbac = objects.some(hasSelfRbacAddOn);
|
|
214
|
-
const crudActionPlans = createCrudActionPlans(objects);
|
|
208
|
+
const crudActionPlans = createCrudActionPlans(objects, flows);
|
|
215
209
|
|
|
216
210
|
const crudOwnTopics = crud ? [...CRUD_ACTIONS] : [];
|
|
217
211
|
const crudSqsQueues = [];
|
|
@@ -221,21 +215,26 @@ function createResourceState({ objects, relationships, flows }) {
|
|
|
221
215
|
if (plan.hasCreateNodeCallback) {
|
|
222
216
|
crudSqsQueues.push(`${action}NodeCallbackHdrSqs`);
|
|
223
217
|
}
|
|
218
|
+
if (plan.hasBeforeHookCallback) {
|
|
219
|
+
crudSqsQueues.push(`${action}BeforeHookCallbackHdrSqs`);
|
|
220
|
+
}
|
|
221
|
+
if (plan.hasAfterHookCallback) {
|
|
222
|
+
crudSqsQueues.push(`${action}AfterHookCallbackHdrSqs`);
|
|
223
|
+
}
|
|
224
224
|
if (plan.hasComplete) {
|
|
225
225
|
crudSqsQueues.push(`${action}CompleteHdrSqs`);
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
const relationshipOwnTopics =
|
|
231
|
-
? [...RELATIONSHIP_ACTIONS]
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
const relationshipDsqQueues =
|
|
237
|
-
? ['GetRelationshipHdrDsq']
|
|
238
|
-
: [];
|
|
230
|
+
const relationshipOwnTopics =
|
|
231
|
+
relationships.length > 0 ? [...RELATIONSHIP_ACTIONS] : [];
|
|
232
|
+
const relationshipSqsQueues =
|
|
233
|
+
relationships.length > 0
|
|
234
|
+
? RELATIONSHIP_ACTIONS.map((action) => `${action}CompleteHdrSqs`)
|
|
235
|
+
: [];
|
|
236
|
+
const relationshipDsqQueues =
|
|
237
|
+
relationships.length > 0 ? ['GetRelationshipHdrDsq'] : [];
|
|
239
238
|
|
|
240
239
|
const rbacOwnTopics = [];
|
|
241
240
|
const rbacSqsQueues = [];
|
|
@@ -311,9 +310,7 @@ function createResourceState({ objects, relationships, flows }) {
|
|
|
311
310
|
const systemOwnTopics = ['ProcessLogical', 'FindData'];
|
|
312
311
|
const systemSqsQueues = [
|
|
313
312
|
'PaginateProcessLogicalHdrSqs',
|
|
314
|
-
...(websocket
|
|
315
|
-
? ['WebSocketCompleteHdrSqs', 'RegisterCompleteHdrSqs']
|
|
316
|
-
: [])
|
|
313
|
+
...(websocket ? ['WebSocketCompleteHdrSqs', 'RegisterCompleteHdrSqs'] : [])
|
|
317
314
|
];
|
|
318
315
|
const systemDsqQueues = ['PaginateProcessLogicalHdrDsq'];
|
|
319
316
|
|
|
@@ -351,9 +348,7 @@ function createResourceState({ objects, relationships, flows }) {
|
|
|
351
348
|
...flowExtTopicSteps(flows).map(({ flow }) =>
|
|
352
349
|
customFlowRoleName(flow.flowTag)
|
|
353
350
|
),
|
|
354
|
-
...flowDsqSteps(flows).map(({ flow }) =>
|
|
355
|
-
customFlowRoleName(flow.flowTag)
|
|
356
|
-
)
|
|
351
|
+
...flowDsqSteps(flows).map(({ flow }) => customFlowRoleName(flow.flowTag))
|
|
357
352
|
])
|
|
358
353
|
];
|
|
359
354
|
const webSocketRoles = new Set();
|
|
@@ -403,9 +398,9 @@ function createResourceState({ objects, relationships, flows }) {
|
|
|
403
398
|
const outputTopicStr =
|
|
404
399
|
typeof flow.outputTopic === 'string' ? flow.outputTopic : null;
|
|
405
400
|
const topicName = outputTopicStr
|
|
406
|
-
?
|
|
401
|
+
? outputTopicStr.startsWith('Out')
|
|
407
402
|
? outputTopicStr
|
|
408
|
-
: `Out${upperFirst(outputTopicStr)}`
|
|
403
|
+
: `Out${upperFirst(outputTopicStr)}`
|
|
409
404
|
: flow.s3Subscription?.topicName || 'OutCreate';
|
|
410
405
|
const queueName =
|
|
411
406
|
flow.s3Subscription?.queueName || `${tag}ReservedLimitHdrSqs`;
|
|
@@ -417,12 +412,12 @@ function createResourceState({ objects, relationships, flows }) {
|
|
|
417
412
|
const systemTables = [...SYSTEM_TABLES];
|
|
418
413
|
if (rbac) {
|
|
419
414
|
systemTables.push(
|
|
415
|
+
'Roles',
|
|
420
416
|
'TargetRoles',
|
|
421
417
|
'RolePermissions',
|
|
422
418
|
'RoleUsers',
|
|
423
419
|
'UserRoles',
|
|
424
420
|
'RbacPermissionCaches',
|
|
425
|
-
'RoleLimit',
|
|
426
421
|
'RunningTotalUsage',
|
|
427
422
|
'RunningTotalReservedUsage'
|
|
428
423
|
);
|
|
@@ -558,9 +553,7 @@ async function renderResourceGroup({
|
|
|
558
553
|
if (!hasResources) return '';
|
|
559
554
|
|
|
560
555
|
const chunks = await Promise.all([
|
|
561
|
-
...ownTopics.map((queueName) =>
|
|
562
|
-
render('ResourceYaml.ejs', { queueName })
|
|
563
|
-
),
|
|
556
|
+
...ownTopics.map((queueName) => render('ResourceYaml.ejs', { queueName })),
|
|
564
557
|
...sqsQueues.map((queueName) =>
|
|
565
558
|
render('ResourceSqsYaml.ejs', { queueName })
|
|
566
559
|
),
|
|
@@ -574,13 +567,12 @@ async function renderResourceGroup({
|
|
|
574
567
|
)
|
|
575
568
|
);
|
|
576
569
|
const s3Subs = await Promise.all(
|
|
577
|
-
s3Subscriptions.map(
|
|
578
|
-
(
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
})
|
|
570
|
+
s3Subscriptions.map(({ subscriptionName, topicName, queueName }) =>
|
|
571
|
+
render('S3Subscription_Yaml.ejs', {
|
|
572
|
+
subscriptionName,
|
|
573
|
+
topicName,
|
|
574
|
+
queueName
|
|
575
|
+
})
|
|
584
576
|
)
|
|
585
577
|
);
|
|
586
578
|
const parts = [chunks.join('\n')];
|
|
@@ -634,7 +626,9 @@ async function renderSystemInSqs(state) {
|
|
|
634
626
|
async function renderOut(state) {
|
|
635
627
|
const body = (
|
|
636
628
|
await Promise.all(
|
|
637
|
-
state.outTopics.map((topicName) =>
|
|
629
|
+
state.outTopics.map((topicName) =>
|
|
630
|
+
render('FlowOut_Yaml.ejs', { topicName })
|
|
631
|
+
)
|
|
638
632
|
)
|
|
639
633
|
).join('\n');
|
|
640
634
|
return `Resources:\n${indentYaml(body, 2)}`;
|
|
@@ -703,15 +697,11 @@ function roleStatements(state, roleName) {
|
|
|
703
697
|
if (roleNeedsSchemaRead(state, roleName)) {
|
|
704
698
|
statements.push({
|
|
705
699
|
action: ['s3:GetObject'],
|
|
706
|
-
resource: [
|
|
707
|
-
'arn:aws:s3:::${self:custom.iz_serviceSchemaBucketName}/*'
|
|
708
|
-
]
|
|
700
|
+
resource: ['arn:aws:s3:::${self:custom.iz_serviceSchemaBucketName}/*']
|
|
709
701
|
});
|
|
710
702
|
statements.push({
|
|
711
703
|
action: ['s3:ListBucket'],
|
|
712
|
-
resource: [
|
|
713
|
-
'arn:aws:s3:::${self:custom.iz_serviceSchemaBucketName}'
|
|
714
|
-
]
|
|
704
|
+
resource: ['arn:aws:s3:::${self:custom.iz_serviceSchemaBucketName}']
|
|
715
705
|
});
|
|
716
706
|
}
|
|
717
707
|
addStatement(statements, dynamoActionsForRole(roleName), [
|
|
@@ -736,6 +726,14 @@ function roleStatements(state, roleName) {
|
|
|
736
726
|
...roleExternalTopicArns(state, roleName)
|
|
737
727
|
]
|
|
738
728
|
);
|
|
729
|
+
addStatement(
|
|
730
|
+
statements,
|
|
731
|
+
['lambda:InvokeFunction'],
|
|
732
|
+
[
|
|
733
|
+
...roleExternalLambdaArns(state, roleName),
|
|
734
|
+
...roleHookLambdaArns(state, roleName)
|
|
735
|
+
]
|
|
736
|
+
);
|
|
739
737
|
if (state.webSocketRoles.has(roleName)) {
|
|
740
738
|
statements.push({
|
|
741
739
|
action: ['execute-api:ManageConnections'],
|
|
@@ -771,11 +769,11 @@ function roleTableNames(state, roleName) {
|
|
|
771
769
|
'WebSocketTask',
|
|
772
770
|
...(state.rbac
|
|
773
771
|
? [
|
|
772
|
+
'Roles',
|
|
774
773
|
'TargetRoles',
|
|
775
774
|
'RolePermissions',
|
|
776
775
|
'RoleUsers',
|
|
777
776
|
'UserRoles',
|
|
778
|
-
'RoleLimit',
|
|
779
777
|
'RunningTotalUsage',
|
|
780
778
|
'RunningTotalReservedUsage'
|
|
781
779
|
]
|
|
@@ -805,7 +803,8 @@ function roleTableNames(state, roleName) {
|
|
|
805
803
|
const tables = [];
|
|
806
804
|
if (includesEvent(flow, 'ownTopic') || includesEvent(flow, 's3'))
|
|
807
805
|
tables.push('WebSocketTask');
|
|
808
|
-
if (includesEvent(flow, 's3'))
|
|
806
|
+
if (includesEvent(flow, 's3'))
|
|
807
|
+
tables.push('UserUploadRecords', 'ReservedDataMain');
|
|
809
808
|
if (flow.statusType === 'storedCache') {
|
|
810
809
|
const object = state.objectTablesByType.get(flow.objType?.objectType);
|
|
811
810
|
if (object) tables.push(object);
|
|
@@ -815,7 +814,12 @@ function roleTableNames(state, roleName) {
|
|
|
815
814
|
|
|
816
815
|
function dynamoActionsForRole(roleName) {
|
|
817
816
|
if (roleName === 'ProcFindDataRole')
|
|
818
|
-
return [
|
|
817
|
+
return [
|
|
818
|
+
'dynamodb:GetItem',
|
|
819
|
+
'dynamodb:PutItem',
|
|
820
|
+
'dynamodb:Query',
|
|
821
|
+
'dynamodb:UpdateItem'
|
|
822
|
+
];
|
|
819
823
|
if (roleName === 'WebSocketMainRole')
|
|
820
824
|
return ['dynamodb:DeleteItem', 'dynamodb:PutItem', 'dynamodb:Query'];
|
|
821
825
|
if (roleName === 'FlowRbacRole' || roleName === 'FlowObjectsRole')
|
|
@@ -845,12 +849,10 @@ function roleQueueNames(state, roleName) {
|
|
|
845
849
|
if (!plan.outputTopic) return [];
|
|
846
850
|
return [
|
|
847
851
|
`${action}HdrSqs`,
|
|
848
|
-
...(plan.hasCreateNodeCallback
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
...(plan.hasRbacCallback
|
|
852
|
-
? [`${action}RbacCallbackHdrSqs`]
|
|
853
|
-
: []),
|
|
852
|
+
...(plan.hasCreateNodeCallback ? [`${action}NodeCallbackHdrSqs`] : []),
|
|
853
|
+
...(plan.hasBeforeHookCallback ? [`${action}BeforeHookCallbackHdrSqs`] : []),
|
|
854
|
+
...(plan.hasAfterHookCallback ? [`${action}AfterHookCallbackHdrSqs`] : []),
|
|
855
|
+
...(plan.hasRbacCallback ? [`${action}RbacCallbackHdrSqs`] : []),
|
|
854
856
|
...(plan.hasComplete ? [`${action}CompleteHdrSqs`] : [])
|
|
855
857
|
];
|
|
856
858
|
});
|
|
@@ -921,9 +923,13 @@ function roleDlqQueueNames(state, roleName) {
|
|
|
921
923
|
|
|
922
924
|
function roleTopicNames(state, roleName) {
|
|
923
925
|
if (roleName === 'ProcFindDataRole')
|
|
924
|
-
return state.outTopics
|
|
926
|
+
return state.outTopics
|
|
927
|
+
.filter((topic) => topic === 'FindData')
|
|
928
|
+
.map((t) => `${t}_Out`);
|
|
925
929
|
if (roleName === 'FlowObjectsRole') {
|
|
926
|
-
const actions = state.outTopics.filter((topic) =>
|
|
930
|
+
const actions = state.outTopics.filter((topic) =>
|
|
931
|
+
CRUD_ACTIONS.includes(topic)
|
|
932
|
+
);
|
|
927
933
|
const topics = [];
|
|
928
934
|
for (const action of actions) {
|
|
929
935
|
if (action === 'Get') {
|
|
@@ -935,10 +941,29 @@ function roleTopicNames(state, roleName) {
|
|
|
935
941
|
if (state.rbac) {
|
|
936
942
|
topics.push('ValidatorRbac_In');
|
|
937
943
|
}
|
|
944
|
+
for (const action of ['Create', 'Update', 'Delete']) {
|
|
945
|
+
const plan = state.crudActionPlans?.[action];
|
|
946
|
+
if (plan?.hasBeforeHookAsync) {
|
|
947
|
+
for (const hook of plan.beforeHooks) {
|
|
948
|
+
if (hook?.generatedCodeConfig?.invocationType === 'ownTopic') {
|
|
949
|
+
topics.push(`${upperFirst(hook.flowTag)}_In`);
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
if (plan?.hasAfterHookAsync) {
|
|
954
|
+
for (const hook of plan.afterHooks) {
|
|
955
|
+
if (hook?.generatedCodeConfig?.invocationType === 'ownTopic') {
|
|
956
|
+
topics.push(`${upperFirst(hook.flowTag)}_In`);
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
}
|
|
938
961
|
return topics;
|
|
939
962
|
}
|
|
940
963
|
if (roleName === 'FlowRelationshipRole') {
|
|
941
|
-
const actions = state.outTopics.filter((topic) =>
|
|
964
|
+
const actions = state.outTopics.filter((topic) =>
|
|
965
|
+
RELATIONSHIP_ACTIONS.includes(topic)
|
|
966
|
+
);
|
|
942
967
|
const topics = [];
|
|
943
968
|
for (const action of actions) {
|
|
944
969
|
if (action === 'GetRelationship') {
|
|
@@ -953,7 +978,9 @@ function roleTopicNames(state, roleName) {
|
|
|
953
978
|
return topics;
|
|
954
979
|
}
|
|
955
980
|
if (roleName === 'FlowRbacRole') {
|
|
956
|
-
const actions = state.outTopics.filter((topic) =>
|
|
981
|
+
const actions = state.outTopics.filter((topic) =>
|
|
982
|
+
RBAC_ACTIONS.includes(topic)
|
|
983
|
+
);
|
|
957
984
|
const topics = [];
|
|
958
985
|
for (const action of actions) {
|
|
959
986
|
if (action.startsWith('List')) {
|
|
@@ -1064,6 +1091,61 @@ function roleExternalTopicArns(state, roleName) {
|
|
|
1064
1091
|
return [];
|
|
1065
1092
|
}
|
|
1066
1093
|
|
|
1094
|
+
function roleExternalLambdaArns(state, roleName) {
|
|
1095
|
+
if (!state.rbac) {
|
|
1096
|
+
return [];
|
|
1097
|
+
}
|
|
1098
|
+
const extraTags = getRbacValidatorServiceTags(state).filter(
|
|
1099
|
+
(tag) => tag && tag !== 'Rbac'
|
|
1100
|
+
);
|
|
1101
|
+
const extraLambdas = extraTags.map(
|
|
1102
|
+
(tag) =>
|
|
1103
|
+
`arn:aws:lambda:\${self:custom.iz_region}:\${self:custom.iz_accountId}:function:${tag}\${self:custom.iz_stage}ValidatorRbacHdrInv`
|
|
1104
|
+
);
|
|
1105
|
+
if (
|
|
1106
|
+
roleName === 'FlowObjectsRole' ||
|
|
1107
|
+
roleName === 'FlowRbacRole' ||
|
|
1108
|
+
roleName === 'FlowRelationshipRole'
|
|
1109
|
+
) {
|
|
1110
|
+
return [
|
|
1111
|
+
`arn:aws:lambda:\${self:custom.iz_region}:\${self:custom.iz_accountId}:function:Rbac\${self:custom.iz_stage}ValidatorRbacHdrInv`,
|
|
1112
|
+
...extraLambdas
|
|
1113
|
+
];
|
|
1114
|
+
}
|
|
1115
|
+
return [];
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
function roleHookLambdaArns(state, roleName) {
|
|
1119
|
+
if (roleName !== 'FlowObjectsRole') {
|
|
1120
|
+
return [];
|
|
1121
|
+
}
|
|
1122
|
+
const hookLambdas = [];
|
|
1123
|
+
for (const action of ['Create', 'Update', 'Delete']) {
|
|
1124
|
+
const plan = state.crudActionPlans?.[action];
|
|
1125
|
+
if (plan?.hasBeforeHookSync) {
|
|
1126
|
+
for (const hook of plan.beforeHooks) {
|
|
1127
|
+
if (hook?.generatedCodeConfig?.invocationType === 'lambdaSyncInv') {
|
|
1128
|
+
const hookTag = upperFirst(hook.flowTag);
|
|
1129
|
+
hookLambdas.push(
|
|
1130
|
+
`arn:aws:lambda:\${self:custom.iz_region}:\${self:custom.iz_accountId}:function:\${self:custom.iz_resourcePrefix}${hookTag}*`
|
|
1131
|
+
);
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
if (plan?.hasAfterHookSync) {
|
|
1136
|
+
for (const hook of plan.afterHooks) {
|
|
1137
|
+
if (hook?.generatedCodeConfig?.invocationType === 'lambdaSyncInv') {
|
|
1138
|
+
const hookTag = upperFirst(hook.flowTag);
|
|
1139
|
+
hookLambdas.push(
|
|
1140
|
+
`arn:aws:lambda:\${self:custom.iz_region}:\${self:custom.iz_accountId}:function:\${self:custom.iz_resourcePrefix}${hookTag}*`
|
|
1141
|
+
);
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
return [...new Set(hookLambdas)];
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1067
1149
|
function queueArns(queueNames) {
|
|
1068
1150
|
return [...new Set(queueNames)]
|
|
1069
1151
|
.sort()
|
|
@@ -1095,8 +1177,7 @@ function collectTables(schemas) {
|
|
|
1095
1177
|
: [];
|
|
1096
1178
|
const pkIdentifier = identifiers.find(
|
|
1097
1179
|
(identifier) =>
|
|
1098
|
-
identifier.type === 'partitionKey' ||
|
|
1099
|
-
identifier.type === 'identifier'
|
|
1180
|
+
identifier.type === 'partitionKey' || identifier.type === 'identifier'
|
|
1100
1181
|
);
|
|
1101
1182
|
const skIdentifier = identifiers.find(
|
|
1102
1183
|
(identifier) => identifier.type === 'sortKey'
|
|
@@ -1211,9 +1292,7 @@ function hasRbacAddOn(object) {
|
|
|
1211
1292
|
*/
|
|
1212
1293
|
function rbacFlowQueueNames(state) {
|
|
1213
1294
|
const flowTags = [
|
|
1214
|
-
...new Set(
|
|
1215
|
-
(state.objects ?? []).filter(hasRbacAddOn).map(rbacFlowTag)
|
|
1216
|
-
)
|
|
1295
|
+
...new Set((state.objects ?? []).filter(hasRbacAddOn).map(rbacFlowTag))
|
|
1217
1296
|
];
|
|
1218
1297
|
return flowTags.map((flowTag) => `${flowTag}HdrSqs`);
|
|
1219
1298
|
}
|
|
@@ -138,6 +138,18 @@ Resources:
|
|
|
138
138
|
KeyType: RANGE
|
|
139
139
|
|
|
140
140
|
<% if (hasRbac) { %>
|
|
141
|
+
RolesTable:
|
|
142
|
+
Type: 'AWS::DynamoDB::Table'
|
|
143
|
+
Properties:
|
|
144
|
+
TableName: ${self:custom.iz_resourcePrefix}Roles
|
|
145
|
+
BillingMode: PAY_PER_REQUEST
|
|
146
|
+
AttributeDefinitions:
|
|
147
|
+
- AttributeName: roleIdKey
|
|
148
|
+
AttributeType: S
|
|
149
|
+
KeySchema:
|
|
150
|
+
- AttributeName: roleIdKey
|
|
151
|
+
KeyType: HASH
|
|
152
|
+
|
|
141
153
|
TargetRolesTable:
|
|
142
154
|
Type: 'AWS::DynamoDB::Table'
|
|
143
155
|
Properties:
|
|
@@ -221,22 +233,6 @@ Resources:
|
|
|
221
233
|
AttributeName: ttlTimestamp
|
|
222
234
|
Enabled: true
|
|
223
235
|
|
|
224
|
-
RoleLimitTable:
|
|
225
|
-
Type: 'AWS::DynamoDB::Table'
|
|
226
|
-
Properties:
|
|
227
|
-
TableName: ${self:custom.iz_resourcePrefix}RoleLimit
|
|
228
|
-
BillingMode: PAY_PER_REQUEST
|
|
229
|
-
AttributeDefinitions:
|
|
230
|
-
- AttributeName: roleLimitId
|
|
231
|
-
AttributeType: S
|
|
232
|
-
- AttributeName: limitType
|
|
233
|
-
AttributeType: S
|
|
234
|
-
KeySchema:
|
|
235
|
-
- AttributeName: roleLimitId
|
|
236
|
-
KeyType: HASH
|
|
237
|
-
- AttributeName: limitType
|
|
238
|
-
KeyType: RANGE
|
|
239
|
-
|
|
240
236
|
RunningTotalUsageTable:
|
|
241
237
|
Type: 'AWS::DynamoDB::Table'
|
|
242
238
|
Properties:
|
|
@@ -245,12 +241,12 @@ Resources:
|
|
|
245
241
|
AttributeDefinitions:
|
|
246
242
|
- AttributeName: identifiersConcat
|
|
247
243
|
AttributeType: S
|
|
248
|
-
- AttributeName:
|
|
244
|
+
- AttributeName: flowTypeConcat
|
|
249
245
|
AttributeType: S
|
|
250
246
|
KeySchema:
|
|
251
247
|
- AttributeName: identifiersConcat
|
|
252
248
|
KeyType: HASH
|
|
253
|
-
- AttributeName:
|
|
249
|
+
- AttributeName: flowTypeConcat
|
|
254
250
|
KeyType: RANGE
|
|
255
251
|
|
|
256
252
|
RunningTotalReservedUsageTable:
|
|
@@ -15,16 +15,12 @@ const OWN_TOPIC_FLOWS = [
|
|
|
15
15
|
'DeleteTargetRole',
|
|
16
16
|
'CreateUserRole',
|
|
17
17
|
'DeleteUserFromRole',
|
|
18
|
-
'CreateRoleLimit',
|
|
19
|
-
'DeleteRoleLimit',
|
|
20
18
|
'ReservedDynamicUsage',
|
|
21
19
|
'ConfirmUsage',
|
|
22
20
|
'CancelUsage'
|
|
23
21
|
];
|
|
24
22
|
|
|
25
23
|
const LIMIT_FLOWS = [
|
|
26
|
-
'CreateRoleLimit',
|
|
27
|
-
'DeleteRoleLimit',
|
|
28
24
|
'ReservedDynamicUsage',
|
|
29
25
|
'ConfirmUsage',
|
|
30
26
|
'CancelUsage'
|
|
@@ -40,7 +36,7 @@ test('generates RBAC own-topic WebSocket entries alongside their SQS handlers',
|
|
|
40
36
|
const rootPath = await createProject(true);
|
|
41
37
|
const result = await generateCreateTargetRoleHandler(rootPath);
|
|
42
38
|
|
|
43
|
-
assert.equal(result.files.length,
|
|
39
|
+
assert.equal(result.files.length, 59);
|
|
44
40
|
assert.match(
|
|
45
41
|
await readFile(join(rootPath, result.files[0].path), 'utf8'),
|
|
46
42
|
/CreateTargetRole/
|
|
@@ -130,16 +126,6 @@ test('generates RBAC own-topic WebSocket entries alongside their SQS handlers',
|
|
|
130
126
|
),
|
|
131
127
|
/Math\.min\(maxIncrease, minDecrease\)/
|
|
132
128
|
);
|
|
133
|
-
assert.match(
|
|
134
|
-
await readFile(
|
|
135
|
-
join(
|
|
136
|
-
rootPath,
|
|
137
|
-
'app/src/generatedCode/FlowLimit/CreateRoleLimit/source/CreateRoleLimit_Main.js'
|
|
138
|
-
),
|
|
139
|
-
'utf8'
|
|
140
|
-
),
|
|
141
|
-
/actionType/
|
|
142
|
-
);
|
|
143
129
|
const rbacYaml = await readFile(
|
|
144
130
|
join(rootPath, 'app/sls_yaml/generatedCode/source/flow-rbac.yml'),
|
|
145
131
|
'utf8'
|