@izara_project/izara-core-generate-service-code 1.0.70 → 1.0.72
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 +3 -3
- package/src/compile/loadSchemas.js +69 -1
- package/src/emit/coreFunction/emitCoreFunctionArtifacts.js +171 -44
- package/src/emit/coreFunction/templates/GenerateSeedDataDynamo_HdrInv.ejs +4 -1
- package/src/emit/coreFunction/templates/GenerateSeedDataGraphData_HdrInv.ejs +4 -1
- package/src/emit/coreFunction/templates/GenerateSeedDataGraphSchema_HdrInv.ejs +4 -1
- package/src/emit/coreFunction/templates/GenerateSeedDataGraphSchema_Main.ejs +10 -2
- package/src/emit/coreFunction/templates/GeneratedGraphNodeSchemas.ejs +17 -17
- package/src/emit/coreFunction/templates/GeneratedGraphRelSchemas.ejs +6 -6
- package/src/emit/coreFunction/templates/GeneratedTableConfigs.ejs +12 -12
- package/src/emit/coreFunction/templates/InitialSetupConfig.ejs +195 -58
- package/src/emit/coreFunction/templates/InitialSetupRunner.ejs +175 -0
- package/src/emit/coreFunction/templates/InitialSetupRunner_initialSetup.ejs +9 -0
- package/src/emit/coreFunction/templates/InitialSetupRunner_seedDynamo.ejs +22 -0
- package/src/emit/coreFunction/templates/InitialSetupRunner_seedGraph.ejs +8 -0
- package/src/emit/coreFunction/templates/InitialSetupRunner_seedRemove.ejs +5 -0
- package/src/emit/coreFunction/templates/InitialSetupRunner_uploadSchema.ejs +33 -0
- package/src/emit/coreFunction/templates/InitialSetup_Main.ejs +9 -11
- package/src/emit/coreFunction/templates/UploadSchema_HdrInv.ejs +1 -3
- package/src/emit/coreFunction/templates/UploadSchema_Main.ejs +1 -1
- package/src/emit/crud/templates/CreateEndpoint_Main.ejs +1 -1
- package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +1 -1
- package/src/emit/crud/templates/FlowMain_Wbs.ejs +1 -2
- package/src/emit/crud/templates/GetEndpoint_Main.ejs +1 -1
- package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +1 -1
- package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +1 -1
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +4 -1
- package/src/emit/custom/templates/FlowEndpoint_Main.ejs +2 -2
- package/src/emit/custom/templates/FlowStep_Main.ejs +1 -1
- package/src/emit/custom/templates/s3/CreateObject_Main.ejs +1 -1
- package/src/emit/custom/templates/s3/ReservedLimit_Main.ejs +1 -1
- package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +2 -2
- package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +1 -1
- package/src/emit/relationship/templates/CreateRelationship_Main.ejs +1 -1
- package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +1 -1
- package/src/emit/relationship/templates/GetRelationship_Main.ejs +53 -32
- package/src/emit/relationship/templates/MoveRelationship_Main.ejs +1 -1
- package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +1 -1
- package/src/emit/resource/emitResourceArtifacts.js +65 -21
- package/src/emit/resource/templates/DynamoDBTable_Yaml.ejs +18 -18
- package/src/emit/resource/templates/FlowOut_Yaml.ejs +5 -5
- package/src/emit/resource/templates/GeneratedLambdaRoleServiceConfig.ejs +9 -10
- package/src/emit/resource/templates/ResourceBeforeLogicalYaml.ejs +44 -44
- package/src/emit/resource/templates/ResourceSqsYaml.ejs +36 -36
- package/src/emit/resource/templates/ResourceYaml.ejs +48 -48
- package/src/emit/resource/templates/S3Bucket_Yaml.ejs +0 -1
- package/src/emit/resource/templates/S3Subscription_Yaml.ejs +6 -6
- package/src/emit/resource/templates/SharedResource_Yaml.ejs +4 -4
- package/src/emit/resource/templates/SystemDynamoDB_Yaml.ejs +115 -115
- package/src/emit/resource/templates/WebSocketSubscription_Yaml.ejs +6 -6
- package/src/emit/shared/templates/FindData_HdrSqs.ejs +1 -1
- package/src/emit/shared/templates/FlowHandler_HdrApi.ejs +3 -1
- package/src/emit/shared/templates/FlowHandler_HdrDsq.ejs +5 -2
- package/src/emit/shared/templates/FlowHandler_HdrInv.ejs +3 -1
- package/src/emit/shared/templates/FlowHandler_HdrSqs.ejs +5 -2
- package/src/emit/shared/templates/PaginateProcessLogical_HdrDsq.ejs +1 -1
- package/src/emit/shared/templates/PaginateProcessLogical_HdrSqs.ejs +1 -1
- package/src/emit/shared/templates/PaginateProcessLogical_Main.ejs +2 -2
- package/src/emit/shared/templates/ProcessLogical_HdrSqs.ejs +1 -1
- package/src/generate.js +26 -5
- package/src/output/mergeHooks.js +13 -13
- package/src/output/validateArtifacts.js +10 -1
- package/test/publicApi.test.js +2 -2
- package/test/resourceArtifacts.test.js +8 -18
- package/docs/TriggeredCache Flow.drawio +0 -193
- package/docs/TriggeredCacheFlow.mmd +0 -47
|
@@ -43,7 +43,7 @@ import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
|
|
|
43
43
|
export default async function <%- mainFileName %>(
|
|
44
44
|
_izContext,
|
|
45
45
|
requestParams,
|
|
46
|
-
callingFlowConfig = {}
|
|
46
|
+
callingFlowConfig = {}
|
|
47
47
|
//(<additionalParams>)
|
|
48
48
|
//(</additionalParams>)
|
|
49
49
|
) {
|
|
@@ -690,7 +690,10 @@ function storedCacheTableName(flow, objects) {
|
|
|
690
690
|
: candidates[0];
|
|
691
691
|
return (
|
|
692
692
|
Object.values(object?.storageResources ?? {}).find(
|
|
693
|
-
(resource) =>
|
|
693
|
+
(resource) =>
|
|
694
|
+
resource?.storageType === 'dynamo' ||
|
|
695
|
+
resource?.storageType === 'dynamoDB' ||
|
|
696
|
+
!resource?.storageType
|
|
694
697
|
)?.tableName ?? null
|
|
695
698
|
);
|
|
696
699
|
}
|
|
@@ -58,7 +58,7 @@ const { createFlowTypeConcat } = utils;
|
|
|
58
58
|
export default async function <%- typeof functionName !== 'undefined' ? functionName : upperCaseFlowTag %>(
|
|
59
59
|
_izContext,
|
|
60
60
|
requestParams,
|
|
61
|
-
callingFlowConfig = {}
|
|
61
|
+
callingFlowConfig = {}
|
|
62
62
|
//(<additionalParams>)
|
|
63
63
|
//(</additionalParams>)
|
|
64
64
|
) {
|
|
@@ -88,7 +88,7 @@ export default async function <%- typeof functionName !== 'undefined' ? function
|
|
|
88
88
|
createFlowTypeConcat(_izContext, {
|
|
89
89
|
flowTag: '<%= flowTag %>',
|
|
90
90
|
serviceTag: process.env.iz_serviceTag
|
|
91
|
-
})
|
|
91
|
+
})
|
|
92
92
|
//(<storedCacheConfig>)
|
|
93
93
|
//(</storedCacheConfig>)
|
|
94
94
|
);
|
|
@@ -37,7 +37,7 @@ import { identifierUuid } from '@izara_project/izara-shared-core';
|
|
|
37
37
|
export default async function <%= functionName %>(
|
|
38
38
|
_izContext,
|
|
39
39
|
requestParams,
|
|
40
|
-
callingFlowConfig = {}
|
|
40
|
+
callingFlowConfig = {}
|
|
41
41
|
//(<additionalParams>)
|
|
42
42
|
//(</additionalParams>)
|
|
43
43
|
) {
|
|
@@ -56,7 +56,7 @@ export default async function reservedLimit(
|
|
|
56
56
|
objInstanceFull,
|
|
57
57
|
//(<additionalProperties>)
|
|
58
58
|
//(</additionalProperties>)
|
|
59
|
-
callingFlowConfig = {}
|
|
59
|
+
callingFlowConfig = {}
|
|
60
60
|
) {
|
|
61
61
|
try {
|
|
62
62
|
_izContext.logger.debug('----- reservedLimit event params ----- ', {
|
|
@@ -11,7 +11,7 @@ let perRecordsValidatorSchema = {
|
|
|
11
11
|
properties: {
|
|
12
12
|
<% startConfig.properties.forEach((prop, index) => { %> <%- prop.propertyName %>: {
|
|
13
13
|
type: '<%- prop.type || 'string' %>'
|
|
14
|
-
}
|
|
14
|
+
}
|
|
15
15
|
<% }) %>
|
|
16
16
|
},
|
|
17
17
|
required: [<%- startConfig.properties.filter(p => p.required === true).map(p => `'${p.propertyName}'`).join(', ') %>]
|
|
@@ -29,7 +29,7 @@ let messageAttributeValidatorSchema = {
|
|
|
29
29
|
Value: { type: '<%- prop.type || 'string' %>' }
|
|
30
30
|
},
|
|
31
31
|
required: ['Type', 'Value']
|
|
32
|
-
}
|
|
32
|
+
}
|
|
33
33
|
<% }) %>
|
|
34
34
|
},
|
|
35
35
|
required: [<%- startConfig.messageAttributes.filter(p => p.required === true).map(p => `'${p.propertyName}'`).join(', ') %>]
|
|
@@ -64,7 +64,7 @@ import { consts as coreConsts } from '@izara_project/izara-core-library-core';
|
|
|
64
64
|
export default async function <%- functionName %>(
|
|
65
65
|
_izContext,
|
|
66
66
|
requestParams,
|
|
67
|
-
callingFlowConfig = {}
|
|
67
|
+
callingFlowConfig = {}
|
|
68
68
|
//(<additionalParams>)
|
|
69
69
|
//(</additionalParams>)
|
|
70
70
|
) {
|
|
@@ -61,7 +61,7 @@ const { PREFIX, TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = consts;
|
|
|
61
61
|
export default async function createRelationship(
|
|
62
62
|
_izContext,
|
|
63
63
|
requestParams,
|
|
64
|
-
callingFlowConfig = {}
|
|
64
|
+
callingFlowConfig = {}
|
|
65
65
|
//(<additionalParams>)
|
|
66
66
|
//(</additionalParams>)
|
|
67
67
|
) {
|
|
@@ -61,7 +61,7 @@ const { PREFIX, TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = consts;
|
|
|
61
61
|
export default async function deleteRelationship(
|
|
62
62
|
_izContext,
|
|
63
63
|
requestParams,
|
|
64
|
-
callingFlowConfig = {}
|
|
64
|
+
callingFlowConfig = {}
|
|
65
65
|
//(<additionalParams>)
|
|
66
66
|
//(</additionalParams>)
|
|
67
67
|
) {
|
|
@@ -16,18 +16,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
19
|
-
|
|
20
19
|
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
21
20
|
import lambdaSharedLib from '@izara_project/izara-core-library-lambda';
|
|
22
21
|
import snsSharedLib from '@izara_project/izara-core-library-sns';
|
|
23
22
|
import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-flow';
|
|
24
23
|
import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
|
|
25
|
-
|
|
26
24
|
import {
|
|
27
25
|
sns,
|
|
28
26
|
lambda
|
|
29
27
|
} from '@izara_project/izara-core-library-external-request';
|
|
30
|
-
|
|
31
28
|
import {
|
|
32
29
|
getObjectSchema,
|
|
33
30
|
utils,
|
|
@@ -36,19 +33,15 @@ import {
|
|
|
36
33
|
relSchemaLib,
|
|
37
34
|
identifiersObject
|
|
38
35
|
} from '@izara_project/izara-core-library-service-schemas';
|
|
39
|
-
|
|
36
|
+
import { consts as coreConsts } from '@izara_project/izara-core-library-core';
|
|
40
37
|
|
|
38
|
+
const { findLinksByObjTypes } = relSchemaLib;
|
|
41
39
|
const { getRelationshipSchemaWithCache, getObjSchemaS3WithHierarchy } =
|
|
42
40
|
getObjectSchema;
|
|
43
|
-
|
|
44
41
|
const { createLinkTypeId } = utils;
|
|
45
|
-
|
|
46
42
|
const { getGraphServiceTagWithCache } = serviceConfig;
|
|
47
|
-
|
|
48
43
|
const { PREFIX, TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = consts;
|
|
49
44
|
|
|
50
|
-
import { consts as coreConsts } from '@izara_project/izara-core-library-core';
|
|
51
|
-
|
|
52
45
|
//(<optionalRequire>)
|
|
53
46
|
//(</optionalRequire>)
|
|
54
47
|
|
|
@@ -66,7 +59,7 @@ import { consts as coreConsts } from '@izara_project/izara-core-library-core';
|
|
|
66
59
|
export default async function getRelationship(
|
|
67
60
|
_izContext,
|
|
68
61
|
requestParams,
|
|
69
|
-
callingFlowConfig = {}
|
|
62
|
+
callingFlowConfig = {}
|
|
70
63
|
//(<additionalParams>)
|
|
71
64
|
//(</additionalParams>)
|
|
72
65
|
) {
|
|
@@ -94,14 +87,16 @@ export default async function getRelationship(
|
|
|
94
87
|
let errorsFound = [];
|
|
95
88
|
|
|
96
89
|
//(<beforeValidateGetRel>)
|
|
97
|
-
//(</beforeValidateGetRel>)
|
|
90
|
+
//(</beforeValidateGetRel>)
|
|
98
91
|
// validate object and identifiers
|
|
99
92
|
async function validateIdentifiersExists(
|
|
100
93
|
_izContext,
|
|
101
94
|
objType,
|
|
102
95
|
identifiersObject
|
|
103
96
|
) {
|
|
104
|
-
const objTypeString =
|
|
97
|
+
const objTypeString =
|
|
98
|
+
`objType:{ serviceTag:${objType.serviceTag}, ` +
|
|
99
|
+
`objectType:${objType.objectType} }`;
|
|
105
100
|
const objectSchema = await getObjSchemaS3WithHierarchy(
|
|
106
101
|
_izContext,
|
|
107
102
|
objType
|
|
@@ -120,7 +115,8 @@ export default async function getRelationship(
|
|
|
120
115
|
for (const identifierName of identifierNames) {
|
|
121
116
|
if (!identifiersObject.hasOwnProperty(identifierName)) {
|
|
122
117
|
errorsFound.push(
|
|
123
|
-
`validateIdentifiers, ${objTypeString}
|
|
118
|
+
`validateIdentifiers, ${objTypeString} ` +
|
|
119
|
+
`property:${identifierName} not exists`
|
|
124
120
|
);
|
|
125
121
|
} else {
|
|
126
122
|
if (
|
|
@@ -128,7 +124,8 @@ export default async function getRelationship(
|
|
|
128
124
|
typeof identifiersObject[identifierName] !== 'number'
|
|
129
125
|
) {
|
|
130
126
|
errorsFound.push(
|
|
131
|
-
`validateIdentifiers, ${objTypeString}
|
|
127
|
+
`validateIdentifiers, ${objTypeString} ` +
|
|
128
|
+
`property:${identifierName} should be string or number`
|
|
132
129
|
);
|
|
133
130
|
}
|
|
134
131
|
}
|
|
@@ -136,16 +133,21 @@ export default async function getRelationship(
|
|
|
136
133
|
}
|
|
137
134
|
}
|
|
138
135
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
136
|
+
if (firstObject && Object.values(firstObject).length > 0) {
|
|
137
|
+
await validateIdentifiersExists(
|
|
138
|
+
_izContext,
|
|
139
|
+
firstObject.objType,
|
|
140
|
+
firstObject.identifiers
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (secondObject && Object.values(secondObject).length > 0) {
|
|
145
|
+
await validateIdentifiersExists(
|
|
146
|
+
_izContext,
|
|
147
|
+
secondObject.objType,
|
|
148
|
+
secondObject.identifiers
|
|
149
|
+
);
|
|
150
|
+
}
|
|
149
151
|
// finished validate object and identifiers
|
|
150
152
|
|
|
151
153
|
//(<afterValidateGetRel>)
|
|
@@ -167,8 +169,14 @@ export default async function getRelationship(
|
|
|
167
169
|
);
|
|
168
170
|
_izContext.logger.debug('links', links);
|
|
169
171
|
if (!links.length) {
|
|
172
|
+
const firstTypeStr = JSON.stringify({
|
|
173
|
+
firstObject: firstObject.objType
|
|
174
|
+
});
|
|
175
|
+
const secondTypeStr = JSON.stringify({
|
|
176
|
+
secondObject: secondObject.objType
|
|
177
|
+
});
|
|
170
178
|
errorsFound.push(
|
|
171
|
-
`not found link between ${
|
|
179
|
+
`not found link between ${firstTypeStr} ${secondTypeStr}`
|
|
172
180
|
);
|
|
173
181
|
}
|
|
174
182
|
|
|
@@ -192,7 +200,7 @@ export default async function getRelationship(
|
|
|
192
200
|
);
|
|
193
201
|
}
|
|
194
202
|
|
|
195
|
-
if (firstObjectHie || firstObject
|
|
203
|
+
if (firstObjectHie || (firstObject && secondObjectHie) || secondObject) {
|
|
196
204
|
// find targetStorageResources and validate each storageResources
|
|
197
205
|
await Promise.all(
|
|
198
206
|
relationshipSchema.links.map(
|
|
@@ -238,7 +246,9 @@ export default async function getRelationship(
|
|
|
238
246
|
);
|
|
239
247
|
if (!graphServiceTag) {
|
|
240
248
|
errorsFound.push(
|
|
241
|
-
`storageResourceTag: ${storageResourceTag}
|
|
249
|
+
`storageResourceTag: ${storageResourceTag} ` +
|
|
250
|
+
`invalid, not found graph serviceTag from ` +
|
|
251
|
+
`graphServerTag: ${usedStorageResource.graphServerTag}`
|
|
242
252
|
);
|
|
243
253
|
}
|
|
244
254
|
|
|
@@ -322,8 +332,10 @@ export default async function getRelationship(
|
|
|
322
332
|
return getRelCompleteMsg;
|
|
323
333
|
}
|
|
324
334
|
|
|
325
|
-
|
|
326
|
-
let
|
|
335
|
+
// collect used graph serviceTag, use to check duplicate graph serviceTag across graph serverTag
|
|
336
|
+
let usedGraphServiceTag = [];
|
|
337
|
+
// collect used graph storageResources, filtered duplicate graphServiceTag from graphServerTag out
|
|
338
|
+
let targetGraphStorageResources = [];
|
|
327
339
|
|
|
328
340
|
for (const targetStorageResource of targetStorageResources) {
|
|
329
341
|
if (
|
|
@@ -351,7 +363,12 @@ export default async function getRelationship(
|
|
|
351
363
|
storageResource.storageType === consts.STORAGE_TYPES.dynamoDB
|
|
352
364
|
) {
|
|
353
365
|
// if have storageResource.storageType === "dynamoDB" will create relationship here
|
|
354
|
-
let tableNameFrom =
|
|
366
|
+
let tableNameFrom =
|
|
367
|
+
`${firstObject.objType.serviceTag}_` +
|
|
368
|
+
`${firstObject.objType.objectType}__` +
|
|
369
|
+
`${relType.relationshipTag}__` +
|
|
370
|
+
`${secondObject.objType.serviceTag}_` +
|
|
371
|
+
`${secondObject.objType.objectType}`;
|
|
355
372
|
|
|
356
373
|
let identifiersConcatFirstObject =
|
|
357
374
|
await identifiersObject.identifiersConcatFromIdentifiers(
|
|
@@ -365,8 +382,12 @@ export default async function getRelationship(
|
|
|
365
382
|
secondObject.objType,
|
|
366
383
|
secondObject.identifiers
|
|
367
384
|
);
|
|
368
|
-
const firstObjectIdentifiersConcat =
|
|
369
|
-
|
|
385
|
+
const firstObjectIdentifiersConcat =
|
|
386
|
+
`${firstObject.objType.serviceTag}_` +
|
|
387
|
+
`${firstObject.objType.objectType}__identifiersConcat`;
|
|
388
|
+
const secondObjectIdentifiersConcat =
|
|
389
|
+
`${secondObject.objType.serviceTag}_` +
|
|
390
|
+
`${secondObject.objType.objectType}__identifiersConcat`;
|
|
370
391
|
// putItem first Object DynamoDb
|
|
371
392
|
let getResultFromDynamo = await dynamodbSharedLib.getItem(
|
|
372
393
|
_izContext,
|
|
@@ -69,7 +69,7 @@ import { consts as coreConsts } from '@izara_project/izara-core-library-core';
|
|
|
69
69
|
export default async function moveRelationship(
|
|
70
70
|
_izContext,
|
|
71
71
|
requestParams,
|
|
72
|
-
callingFlowConfig = {}
|
|
72
|
+
callingFlowConfig = {}
|
|
73
73
|
//(<additionalParams>)
|
|
74
74
|
//(</additionalParams>)
|
|
75
75
|
) {
|
|
@@ -62,7 +62,7 @@ const { PREFIX, TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = consts;
|
|
|
62
62
|
export default async function updateRelationship(
|
|
63
63
|
_izContext,
|
|
64
64
|
requestParams,
|
|
65
|
-
callingFlowConfig = {}
|
|
65
|
+
callingFlowConfig = {}
|
|
66
66
|
//(<additionalParams>)
|
|
67
67
|
//(</additionalParams>)
|
|
68
68
|
) {
|
|
@@ -112,10 +112,6 @@ export async function emitResourceArtifacts({
|
|
|
112
112
|
{
|
|
113
113
|
path: `${APP_ROOT}/role-name-config.yml`,
|
|
114
114
|
content: normalizeYaml(iam.roleNameConfigContent)
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
path: `${INITIAL_SETUP_ROOT}/generatedLambdaRoleServiceConfig.js`,
|
|
118
|
-
content: lambdaRoleConfig
|
|
119
115
|
}
|
|
120
116
|
];
|
|
121
117
|
if (state.s3Buckets.length > 0) {
|
|
@@ -140,20 +136,22 @@ export const resourceArtifactPaths = [
|
|
|
140
136
|
`${RESOURCE_ROOT}/generated-s3.yml`,
|
|
141
137
|
`${APP_ROOT}/generate-shared-resource.yml`,
|
|
142
138
|
`${APP_ROOT}/role-name-config.yml`,
|
|
143
|
-
`${INITIAL_SETUP_ROOT}/generatedLambdaRoleServiceConfig.js`,
|
|
144
139
|
`${APP_ROOT}/cors.yml`
|
|
145
140
|
];
|
|
146
141
|
|
|
147
142
|
function createResourceState({ objects, relationships, flows }) {
|
|
148
143
|
const crud = objects.some(isCrudObject);
|
|
149
144
|
const rbac = objects.some(hasRbacAddOn);
|
|
150
|
-
const ownTopics = new Set(
|
|
151
|
-
|
|
145
|
+
const ownTopics = new Set([
|
|
146
|
+
'ProcessLogical',
|
|
147
|
+
'FindData',
|
|
148
|
+
...flows
|
|
152
149
|
.filter((flow) => includesEvent(flow, 'ownTopic'))
|
|
153
150
|
.map((flow) => upperFirst(flow.flowTag))
|
|
154
|
-
);
|
|
151
|
+
]);
|
|
155
152
|
const sqsQueues = new Set([
|
|
156
|
-
|
|
153
|
+
'PaginateProcessLogicalHdrDsq',
|
|
154
|
+
'PaginateProcessLogicalHdrSqs',
|
|
157
155
|
...flows
|
|
158
156
|
.filter((flow) => includesEvent(flow, 'extTopic'))
|
|
159
157
|
.map((flow) => `Process${upperFirst(flow.flowTag)}HdrSqs`)
|
|
@@ -339,18 +337,35 @@ function createResourceState({ objects, relationships, flows }) {
|
|
|
339
337
|
.map((object) => [
|
|
340
338
|
object.objectType,
|
|
341
339
|
Object.values(object.storageResources ?? {}).find(
|
|
342
|
-
(resource) =>
|
|
340
|
+
(resource) =>
|
|
341
|
+
resource?.storageType === 'dynamo' ||
|
|
342
|
+
resource?.storageType === 'dynamoDB' ||
|
|
343
|
+
!resource?.storageType
|
|
343
344
|
)?.tableName
|
|
344
345
|
])
|
|
345
346
|
.filter(([, tableName]) => tableName)
|
|
346
347
|
),
|
|
347
348
|
s3Buckets,
|
|
348
|
-
flows
|
|
349
|
+
flows,
|
|
350
|
+
objects
|
|
349
351
|
};
|
|
350
352
|
}
|
|
351
353
|
|
|
354
|
+
function indentYaml(content, spaces = 2) {
|
|
355
|
+
const prefix = ' '.repeat(spaces);
|
|
356
|
+
return content
|
|
357
|
+
.split('\n')
|
|
358
|
+
.map((line) => {
|
|
359
|
+
if (line.trim()) {
|
|
360
|
+
return `${prefix}${line}`;
|
|
361
|
+
}
|
|
362
|
+
return '';
|
|
363
|
+
})
|
|
364
|
+
.join('\n');
|
|
365
|
+
}
|
|
366
|
+
|
|
352
367
|
async function renderS3(state) {
|
|
353
|
-
if (state.s3Buckets.length === 0) return 'Resources
|
|
368
|
+
if (state.s3Buckets.length === 0) return 'Resources:\n';
|
|
354
369
|
const template = await readFile(
|
|
355
370
|
new URL('S3Bucket_Yaml.ejs', TEMPLATE_URL),
|
|
356
371
|
'utf8'
|
|
@@ -358,7 +373,7 @@ async function renderS3(state) {
|
|
|
358
373
|
const chunks = await Promise.all(
|
|
359
374
|
state.s3Buckets.map((bucketName) => ejsLib.render(template, { bucketName }))
|
|
360
375
|
);
|
|
361
|
-
return `Resources:\n${chunks.join('\n')}`;
|
|
376
|
+
return `Resources:\n${indentYaml(chunks.join('\n'), 2)}`;
|
|
362
377
|
}
|
|
363
378
|
|
|
364
379
|
async function renderInSqs(state) {
|
|
@@ -408,11 +423,17 @@ async function renderInSqs(state) {
|
|
|
408
423
|
if (s3Subscriptions.length > 0) {
|
|
409
424
|
parts.push(s3Subscriptions.join('\n'));
|
|
410
425
|
}
|
|
411
|
-
|
|
426
|
+
const body = parts.join('\n');
|
|
427
|
+
return `Resources:\n${indentYaml(body, 2)}`;
|
|
412
428
|
}
|
|
413
429
|
|
|
414
430
|
async function renderOut(state) {
|
|
415
|
-
|
|
431
|
+
const body = (
|
|
432
|
+
await Promise.all(
|
|
433
|
+
state.outTopics.map((topicName) => render('FlowOut_Yaml.ejs', { topicName }))
|
|
434
|
+
)
|
|
435
|
+
).join('\n');
|
|
436
|
+
return `Resources:\n${indentYaml(body, 2)}`;
|
|
416
437
|
}
|
|
417
438
|
|
|
418
439
|
async function renderDynamo(state) {
|
|
@@ -420,7 +441,8 @@ async function renderDynamo(state) {
|
|
|
420
441
|
render('SystemDynamoDB_Yaml.ejs', { hasS3: state.s3FlowTags.length > 0 }),
|
|
421
442
|
...state.tables.map((table) => render('DynamoDBTable_Yaml.ejs', table))
|
|
422
443
|
]);
|
|
423
|
-
|
|
444
|
+
const indentedTables = tables.map((t) => indentYaml(t, 2)).join('\n');
|
|
445
|
+
return indentedTables ? `${system}\n${indentedTables}` : `${system}`;
|
|
424
446
|
}
|
|
425
447
|
|
|
426
448
|
async function renderIam(state) {
|
|
@@ -583,10 +605,13 @@ function roleQueueNames(state, roleName) {
|
|
|
583
605
|
];
|
|
584
606
|
}
|
|
585
607
|
if (roleName === 'FlowRbacRole') {
|
|
586
|
-
return
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
608
|
+
return [
|
|
609
|
+
...RBAC_ACTIONS.flatMap((action) => [
|
|
610
|
+
`${action}HdrSqs`,
|
|
611
|
+
`Process${action}HdrSqs`
|
|
612
|
+
]),
|
|
613
|
+
...rbacFlowQueueNames(state)
|
|
614
|
+
];
|
|
590
615
|
}
|
|
591
616
|
const flow = state.flows.find(
|
|
592
617
|
(candidate) => customFlowRoleName(candidate?.flowTag ?? '') === roleName
|
|
@@ -738,7 +763,9 @@ function collectTables(schemas) {
|
|
|
738
763
|
);
|
|
739
764
|
for (const resource of Object.values(schema.storageResources)) {
|
|
740
765
|
if (
|
|
741
|
-
resource?.storageType === '
|
|
766
|
+
(resource?.storageType === 'dynamo' ||
|
|
767
|
+
resource?.storageType === 'dynamoDB' ||
|
|
768
|
+
!resource?.storageType) &&
|
|
742
769
|
resource.tableName &&
|
|
743
770
|
!tables.has(resource.tableName)
|
|
744
771
|
)
|
|
@@ -771,6 +798,23 @@ function hasRbacAddOn(object) {
|
|
|
771
798
|
object.addOnDataStructure.some((addOn) => addOn?.type === 'rbac')
|
|
772
799
|
);
|
|
773
800
|
}
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* Returns the per-object RBAC flow queues (e.g. UserRbacFlowHdrSqs)
|
|
804
|
+
* created for objects with an 'rbac' add-on. These are consumed by the
|
|
805
|
+
* UserRbacFlow SQS functions emitted in emitRbacApplicationArtifacts.
|
|
806
|
+
*/
|
|
807
|
+
function rbacFlowQueueNames(state) {
|
|
808
|
+
return (state.objects ?? [])
|
|
809
|
+
.filter(hasRbacAddOn)
|
|
810
|
+
.map((object) => {
|
|
811
|
+
const objectType = object?.objectType;
|
|
812
|
+
if (typeof objectType !== 'string' || objectType.trim() === '') return null;
|
|
813
|
+
const flowTag = `${objectType[0].toUpperCase()}${objectType.slice(1)}RbacFlow`;
|
|
814
|
+
return `${flowTag}HdrSqs`;
|
|
815
|
+
})
|
|
816
|
+
.filter(Boolean);
|
|
817
|
+
}
|
|
774
818
|
function includesEvent(flow, event) {
|
|
775
819
|
return Array.isArray(flow?.event) && flow.event.includes(event);
|
|
776
820
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
##===== [DynamoDB Table: <%- tableName %>]
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
<% if (sk) { %>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
<% } %>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
<% if (sk) { %>
|
|
18
|
-
|
|
19
|
-
|
|
2
|
+
<%- tableName %>Table:
|
|
3
|
+
Type: AWS::DynamoDB::Table
|
|
4
|
+
Properties:
|
|
5
|
+
TableName: ${self:custom.iz_resourcePrefix}<%- tableName %>
|
|
6
|
+
BillingMode: PAY_PER_REQUEST
|
|
7
|
+
AttributeDefinitions:
|
|
8
|
+
- AttributeName: '<%- pk %>'
|
|
9
|
+
AttributeType: 'S'
|
|
10
|
+
<% if (sk) { %>
|
|
11
|
+
- AttributeName: '<%- sk %>'
|
|
12
|
+
AttributeType: 'S'
|
|
13
|
+
<% } %>
|
|
14
|
+
KeySchema:
|
|
15
|
+
- AttributeName: '<%- pk %>'
|
|
16
|
+
KeyType: 'HASH'
|
|
17
|
+
<% if (sk) { %>
|
|
18
|
+
- AttributeName: '<%- sk %>'
|
|
19
|
+
KeyType: 'RANGE'
|
|
20
20
|
<% } %>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
##===== [Topic Out]
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
Out<%- topicName %>:
|
|
3
|
+
Type: AWS::SNS::Topic
|
|
4
|
+
Properties:
|
|
5
|
+
DisplayName: 'SNS Message out'
|
|
6
|
+
TopicName: ${self:custom.iz_serviceTag}_${self:custom.iz_stage}_<%- topicName %>_Out
|
|
@@ -25,7 +25,7 @@ const _izContext = { logger: Logger };
|
|
|
25
25
|
|
|
26
26
|
export function generatedLambdaRole() {
|
|
27
27
|
const externalLambdaRole = [
|
|
28
|
-
<% if (crud) { -%>
|
|
28
|
+
<% if (crud) { -%>
|
|
29
29
|
{
|
|
30
30
|
roleName: 'FlowObjects',
|
|
31
31
|
statement: [
|
|
@@ -34,7 +34,7 @@ export function generatedLambdaRole() {
|
|
|
34
34
|
Effect: 'Allow',
|
|
35
35
|
Action: ['lambda:InvokeFunction'],
|
|
36
36
|
Resource: [
|
|
37
|
-
`arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${lambdaSharedLib.lambdaFunctionName(_izContext, 'GetNodeHdrInv'
|
|
37
|
+
`arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${lambdaSharedLib.lambdaFunctionName(_izContext, 'GetNodeHdrInv', 'GraphHandler')}`
|
|
38
38
|
]
|
|
39
39
|
},
|
|
40
40
|
|
|
@@ -59,7 +59,7 @@ export function generatedLambdaRole() {
|
|
|
59
59
|
//(</createFlowObjectsRole>)
|
|
60
60
|
]
|
|
61
61
|
},
|
|
62
|
-
<% } -%>
|
|
62
|
+
<% } -%>
|
|
63
63
|
|
|
64
64
|
{
|
|
65
65
|
roleName: 'ProcFindData',
|
|
@@ -69,13 +69,13 @@ export function generatedLambdaRole() {
|
|
|
69
69
|
Effect: 'Allow',
|
|
70
70
|
Action: ['lambda:InvokeFunction'],
|
|
71
71
|
Resource: [
|
|
72
|
-
`arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${lambdaSharedLib.lambdaFunctionName(_izContext, 'GetNodeHdrInv'
|
|
72
|
+
`arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${lambdaSharedLib.lambdaFunctionName(_izContext, 'GetNodeHdrInv', 'GraphHandler')}`
|
|
73
73
|
]
|
|
74
74
|
}
|
|
75
75
|
//(<createProcFindDataRole>)
|
|
76
76
|
//(</createProcFindDataRole>)
|
|
77
77
|
]
|
|
78
|
-
}<% if (relationships) { %>,
|
|
78
|
+
} <% if (relationships) { %>,
|
|
79
79
|
|
|
80
80
|
{
|
|
81
81
|
roleName: 'FlowRelationship',
|
|
@@ -85,7 +85,7 @@ export function generatedLambdaRole() {
|
|
|
85
85
|
Effect: 'Allow',
|
|
86
86
|
Action: ['lambda:InvokeFunction'],
|
|
87
87
|
Resource: [
|
|
88
|
-
`arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${lambdaSharedLib.lambdaFunctionName(_izContext, 'GetRelationshipHdrInv'
|
|
88
|
+
`arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${lambdaSharedLib.lambdaFunctionName(_izContext, 'GetRelationshipHdrInv', 'GraphHandler')}`
|
|
89
89
|
]
|
|
90
90
|
},
|
|
91
91
|
|
|
@@ -104,10 +104,9 @@ export function generatedLambdaRole() {
|
|
|
104
104
|
//(<createFlowRelationshipRole>)
|
|
105
105
|
//(</createFlowRelationshipRole>)
|
|
106
106
|
]
|
|
107
|
-
}<% }
|
|
108
|
-
<% s3Flows.forEach(function(flow) { -%>,
|
|
107
|
+
} <% } -%>,
|
|
109
108
|
|
|
110
|
-
{
|
|
109
|
+
<% s3Flows.forEach(function(flow) { -%> {
|
|
111
110
|
roleName: '<%= flow.roleName %>',
|
|
112
111
|
statement: [
|
|
113
112
|
{
|
|
@@ -130,7 +129,7 @@ export function generatedLambdaRole() {
|
|
|
130
129
|
//(<create<%= flow.roleName %>Role>)
|
|
131
130
|
//(</create<%= flow.roleName %>Role>)
|
|
132
131
|
]
|
|
133
|
-
}<% }); %>
|
|
132
|
+
} <% }); %>
|
|
134
133
|
//(<additionalRole>)
|
|
135
134
|
//(</additionalRole>)
|
|
136
135
|
];
|