@izara_project/izara-core-generate-service-code 1.0.98 → 1.0.100
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/compileProject.js +16 -5
- package/src/compile/flowValidator.js +47 -8
- package/src/compile/loadSchemas.js +18 -7
- package/src/compile/schemaValidatorSetup.js +16 -0
- package/src/emit/application/coreFunction/emitCoreFunctionArtifacts.js +123 -109
- package/src/emit/application/coreFunction/templates/InitialSetupConfig.ejs +8 -4
- package/src/emit/application/coreFunction/templates/InitialSetupRunner.ejs +2 -2
- package/src/emit/application/crud/templates/CreateComplete_Main.ejs +2 -0
- package/src/emit/application/crud/templates/CreateEndpoint_Main.ejs +4 -4
- package/src/emit/application/crud/templates/CreateLogicalLib.ejs +74 -15
- package/src/emit/application/crud/templates/DeleteComplete_Main.ejs +2 -0
- package/src/emit/application/crud/templates/DeleteEndpoint_Main.ejs +4 -4
- package/src/emit/application/crud/templates/FlowEndpoint_HdrWbs.ejs +7 -5
- package/src/emit/application/crud/templates/UpdateComplete_Main.ejs +2 -0
- package/src/emit/application/crud/templates/UpdateEndpoint_Main.ejs +4 -4
- package/src/emit/application/custom/customFlowPaths.js +13 -16
- package/src/emit/application/custom/customFlowS3.js +277 -66
- package/src/emit/application/custom/customFlows.js +131 -0
- package/src/emit/application/custom/emitCustomFlowApplicationArtifacts.js +3 -1
- package/src/emit/application/custom/templates/FlowEndpoint_Main.ejs +2 -2
- package/src/emit/application/custom/templates/s3/ConfirmAfterUpload_HdrSqs.ejs +110 -0
- package/src/emit/application/custom/templates/s3/ConfirmAfterUpload_Main.ejs +89 -0
- package/src/emit/application/custom/templates/s3/ConfirmComplete_HdrSqs.ejs +110 -0
- package/src/emit/application/custom/templates/s3/ConfirmComplete_Main.ejs +89 -0
- package/src/emit/application/custom/templates/s3/CreateObject_HdrWbs.ejs +2 -1
- package/src/emit/application/custom/templates/s3/CreateObject_Main.ejs +4 -0
- package/src/emit/application/custom/templates/s3/CreatePreSignUrl_HdrSqs.ejs +42 -0
- package/src/emit/application/custom/templates/s3/CreatePreSignUrl_Main.ejs +23 -0
- package/src/emit/application/custom/templates/s3/ProcessS3File_Main.ejs +135 -27
- package/src/emit/application/custom/templates/s3/Start_Main.ejs +197 -0
- package/src/emit/application/rbac/emitDynamicRbacFlowSchemas.js +8 -1
- package/src/emit/application/rbac/emitRbacApplicationArtifacts.js +107 -25
- package/src/emit/application/rbac/templates/ReservedDynamicUsage_Main.ejs +29 -9
- package/src/emit/application/rbac/templates/ReservedUsageTtlExpired_HdrDss.ejs +176 -0
- package/src/emit/application/rbac/templates/UserRbacFlow_Main.ejs +4 -3
- package/src/emit/application/system/templates/Register_HdrWbs.ejs +2 -1
- package/src/emit/infrastructure/functions/functionYamlArtifact.js +31 -8
- package/src/emit/infrastructure/functions/templates/DssFunction_Yaml.ejs +21 -0
- package/src/emit/infrastructure/functions/templates/S3Function_Yaml.ejs +2 -3
- package/src/emit/infrastructure/resources/iamResourceArtifacts.js +67 -5
- package/src/emit/infrastructure/resources/resourceState.js +15 -5
- package/src/emit/infrastructure/resources/s3ResourceArtifacts.js +19 -3
- package/src/emit/infrastructure/resources/templates/GeneratedLambdaRoleServiceConfig.ejs +5 -3
- package/src/emit/infrastructure/resources/templates/S3Bucket_Yaml.ejs +1 -1
- package/src/emit/infrastructure/resources/templates/SystemDynamoDB_Yaml.ejs +2 -2
- package/src/emit/schemas/attributeTree/emitAttributeTreeSchemas.js +62 -1
- package/src/emit/schemas/error/emitErrorSchemas.js +120 -10
- package/src/emit/schemas/error/templates/errorConsts.ejs +12 -0
- package/src/generate.js +32 -34
- package/src/output/mergeHooks.js +105 -5
- package/src/plan/domainRegistry.js +0 -10
- package/task.md +40 -96
- package/test/integration/graphDrivenFlowSchema.test.js +58 -0
- package/test/integration/publicApi.test.js +33 -24
- package/test/unit/application/createTargetRoleHandler.test.js +101 -9
- package/test/unit/application/crudApplicationArtifacts.test.js +4 -0
- package/test/unit/application/customFlowApplicationArtifacts.test.js +6 -6
- package/test/unit/application/customFlowS3.test.js +730 -0
- package/test/unit/infrastructure/functionYamlArtifact.test.js +6 -4
- package/test/unit/infrastructure/resourceArtifacts.test.js +103 -0
- package/test/unit/output/mergeHooks.test.js +137 -0
- package/test/unit/schemas/attributeTreeSchemas.test.js +32 -3
- package/test/unit/schemas/attributeTreeSingleService.test.js +175 -0
- package/test/unit/schemas/dynamicRbacFlowSchemas.test.js +8 -6
- package/test/unit/schemas/dynamicRelationshipFlowSchemas.test.js +51 -0
- package/test/unit/schemas/errorSchemas.test.js +84 -5
- package/test/unit/templates/hookTagsValidation.test.js +83 -0
- package/src/emit/schemas/attributeTree/emitAttributeTreeTargetValueStandard.js +0 -132
- package/test/unit/schemas/attributeTreeDirectives.test.js +0 -177
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@izara_project/izara-core-generate-service-code",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.100",
|
|
4
4
|
"description": "Code for locally generating per service files",
|
|
5
5
|
"homepage": "https://bitbucket.org/izara-core-support-services/izara-core-support-services-generate-service-code#readme",
|
|
6
6
|
"repository": {
|
|
@@ -20,15 +20,25 @@ export function compileProject(request = {}) {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
let serviceTag = request.serviceTag;
|
|
23
|
-
|
|
23
|
+
let schemaBucketName = request.schemaBucketName;
|
|
24
|
+
if (existsSync(configPath)) {
|
|
24
25
|
try {
|
|
25
26
|
const configContent = readFileSync(configPath, 'utf8');
|
|
26
27
|
const parsedConfig = parseYaml(configContent);
|
|
27
28
|
if (parsedConfig && parsedConfig.main_config) {
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
if (!serviceTag) {
|
|
30
|
+
if (parsedConfig.main_config.iz_serviceTag) {
|
|
31
|
+
serviceTag = parsedConfig.main_config.iz_serviceTag;
|
|
32
|
+
} else if (parsedConfig.main_config.iz_serviceName) {
|
|
33
|
+
serviceTag = parsedConfig.main_config.iz_serviceName;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (
|
|
37
|
+
!schemaBucketName &&
|
|
38
|
+
parsedConfig.main_config.iz_serviceSchemaBucketName
|
|
39
|
+
) {
|
|
40
|
+
schemaBucketName =
|
|
41
|
+
parsedConfig.main_config.iz_serviceSchemaBucketName;
|
|
32
42
|
}
|
|
33
43
|
}
|
|
34
44
|
} catch (err) {
|
|
@@ -49,6 +59,7 @@ export function compileProject(request = {}) {
|
|
|
49
59
|
configPath,
|
|
50
60
|
schemaRoot: join(rootPath, 'app', 'src', 'schemas'),
|
|
51
61
|
serviceTag,
|
|
62
|
+
schemaBucketName,
|
|
52
63
|
schemaTemplateConfig
|
|
53
64
|
});
|
|
54
65
|
}
|
|
@@ -6,9 +6,20 @@ export const VALID_EVENT_ENUM = [
|
|
|
6
6
|
'ownTopic',
|
|
7
7
|
's3',
|
|
8
8
|
'dsq',
|
|
9
|
+
'dss',
|
|
9
10
|
'generateCode'
|
|
10
11
|
];
|
|
11
12
|
|
|
13
|
+
export const VALID_S3_STEP_NAMES = [
|
|
14
|
+
'CreateObject',
|
|
15
|
+
'ReservedLimit',
|
|
16
|
+
'CreatePreSignUrl',
|
|
17
|
+
'ProcessAfterUpload',
|
|
18
|
+
'ConfirmAfterUpload',
|
|
19
|
+
'ConfirmComplete'
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
|
|
12
23
|
export function validateFlowSchema(flowSchema) {
|
|
13
24
|
if (!flowSchema || typeof flowSchema !== 'object') {
|
|
14
25
|
throw new TypeError('flowSchema must be an object');
|
|
@@ -188,14 +199,19 @@ export function validateFlowSchema(flowSchema) {
|
|
|
188
199
|
}
|
|
189
200
|
}
|
|
190
201
|
|
|
202
|
+
const flowEvents = flowSchema.event;
|
|
203
|
+
const isS3Flow = Array.isArray(flowEvents) && flowEvents.includes('s3');
|
|
204
|
+
|
|
191
205
|
const steps = flowSchema.flowSteps;
|
|
192
206
|
if (!Array.isArray(steps) || steps.length === 0) {
|
|
207
|
+
if (isS3Flow) {
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
193
210
|
throw new Error(
|
|
194
211
|
'FlowSchema validation error: flowSteps must be a non-empty array'
|
|
195
212
|
);
|
|
196
213
|
}
|
|
197
214
|
|
|
198
|
-
const flowEvents = flowSchema.event;
|
|
199
215
|
const syncEvents = ['lambdaSyncInv', 'lambdaSyncApi'];
|
|
200
216
|
let hasSyncEvent = false;
|
|
201
217
|
for (const eventName of flowEvents) {
|
|
@@ -220,16 +236,28 @@ export function validateFlowSchema(flowSchema) {
|
|
|
220
236
|
}
|
|
221
237
|
|
|
222
238
|
const entryStep = steps[0];
|
|
223
|
-
if (
|
|
224
|
-
!entryStep ||
|
|
225
|
-
typeof entryStep !== 'object' ||
|
|
226
|
-
entryStep.stepName !== 'Start'
|
|
227
|
-
) {
|
|
239
|
+
if (!entryStep || typeof entryStep !== 'object') {
|
|
228
240
|
throw new Error(
|
|
229
|
-
|
|
241
|
+
'FlowSchema validation error: flowSteps[0] must be an object'
|
|
230
242
|
);
|
|
231
243
|
}
|
|
232
244
|
|
|
245
|
+
if (isS3Flow) {
|
|
246
|
+
const validS3EntrySteps = ['Start', 'CreateObject'];
|
|
247
|
+
if (!validS3EntrySteps.includes(entryStep.stepName)) {
|
|
248
|
+
throw new Error(
|
|
249
|
+
`FlowSchema validation error: Entry step flowSteps[0] for s3 flow ` +
|
|
250
|
+
`must have stepName 'CreateObject' or 'Start', got '${entryStep.stepName}'`
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
} else {
|
|
254
|
+
if (entryStep.stepName !== 'Start') {
|
|
255
|
+
throw new Error(
|
|
256
|
+
"FlowSchema validation error: Entry step flowSteps[0] must have stepName fixed to 'Start'"
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
233
261
|
if (
|
|
234
262
|
entryStep.previousSteps &&
|
|
235
263
|
Array.isArray(entryStep.previousSteps) &&
|
|
@@ -240,7 +268,7 @@ export function validateFlowSchema(flowSchema) {
|
|
|
240
268
|
);
|
|
241
269
|
}
|
|
242
270
|
|
|
243
|
-
if (entryStep.event) {
|
|
271
|
+
if (!isS3Flow && entryStep.event) {
|
|
244
272
|
throw new Error(
|
|
245
273
|
"FlowSchema validation error: Entry step flowSteps[0] must not define step-level 'event'"
|
|
246
274
|
);
|
|
@@ -266,6 +294,17 @@ export function validateFlowSchema(flowSchema) {
|
|
|
266
294
|
);
|
|
267
295
|
}
|
|
268
296
|
|
|
297
|
+
if (
|
|
298
|
+
isS3Flow &&
|
|
299
|
+
step.stepName !== 'Start' &&
|
|
300
|
+
!VALID_S3_STEP_NAMES.includes(step.stepName)
|
|
301
|
+
) {
|
|
302
|
+
throw new Error(
|
|
303
|
+
`FlowSchema validation error: flowSteps[${idx}].stepName '${step.stepName}' ` +
|
|
304
|
+
`is invalid for s3 flow. Must be one of ${JSON.stringify(VALID_S3_STEP_NAMES)}`
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
|
|
269
308
|
if (step.stepName.toLowerCase().includes('checktrigger')) {
|
|
270
309
|
if (
|
|
271
310
|
!Array.isArray(flowSchema.triggerFlowTypes) ||
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readdir, stat } from 'node:fs/promises';
|
|
2
|
-
import { join } from 'node:path';
|
|
2
|
+
import { join, relative, sep } from 'node:path';
|
|
3
3
|
import { pathToFileURL } from 'node:url';
|
|
4
4
|
import { utils } from '@izara_project/izara-core-library-service-schemas';
|
|
5
5
|
import { validateFlowSchema } from './flowValidator.js';
|
|
@@ -28,9 +28,6 @@ const consoleLogger = {
|
|
|
28
28
|
|
|
29
29
|
export { resolveExtendedObjectSchemas, resolveGraphServiceTags };
|
|
30
30
|
|
|
31
|
-
export async function loadGenerateDirectives(project, options = {}) {
|
|
32
|
-
return loadLocalSchemaDirectory(project, 'GenerateDirectives', options);
|
|
33
|
-
}
|
|
34
31
|
|
|
35
32
|
export async function loadLocalSchemaDirectory(
|
|
36
33
|
project,
|
|
@@ -62,6 +59,13 @@ export async function loadLocalSchemaDirectory(
|
|
|
62
59
|
return false;
|
|
63
60
|
}
|
|
64
61
|
}
|
|
62
|
+
if (directoryName === 'ErrorSchemas') {
|
|
63
|
+
const parentDir = entry.parentPath || entry.path || directoryPath;
|
|
64
|
+
const relDir = relative(directoryPath, parentDir);
|
|
65
|
+
if (relDir.split(sep).includes('generateCode')) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
65
69
|
return true;
|
|
66
70
|
});
|
|
67
71
|
validEntries.sort((a, b) => {
|
|
@@ -419,10 +423,13 @@ export async function loadLocalSchemaDirectory(
|
|
|
419
423
|
schema
|
|
420
424
|
);
|
|
421
425
|
}
|
|
426
|
+
const relTag = Object.keys(schema || {})[0];
|
|
427
|
+
const relGeneratedBy =
|
|
428
|
+
schema?.[relTag]?.generatedBy || schema?.generatedBy;
|
|
422
429
|
if (
|
|
423
430
|
!status &&
|
|
424
431
|
Array.isArray(errors) &&
|
|
425
|
-
VALID_GENERATED_BY_ENUM.includes(
|
|
432
|
+
VALID_GENERATED_BY_ENUM.includes(relGeneratedBy)
|
|
426
433
|
) {
|
|
427
434
|
errors = errors.filter(
|
|
428
435
|
(err) =>
|
|
@@ -432,7 +439,7 @@ export async function loadLocalSchemaDirectory(
|
|
|
432
439
|
) &&
|
|
433
440
|
!(
|
|
434
441
|
err.includes('should be one of enum') &&
|
|
435
|
-
err.includes(
|
|
442
|
+
err.includes(relGeneratedBy)
|
|
436
443
|
)
|
|
437
444
|
);
|
|
438
445
|
if (errors.length === 0) {
|
|
@@ -530,7 +537,11 @@ export async function loadLocalSchemaDirectory(
|
|
|
530
537
|
);
|
|
531
538
|
});
|
|
532
539
|
}
|
|
533
|
-
|
|
540
|
+
const remainingActionableErrors = errors.filter(
|
|
541
|
+
(err) => err && !err.trim().startsWith('FlowTag:')
|
|
542
|
+
);
|
|
543
|
+
if (remainingActionableErrors.length === 0) {
|
|
544
|
+
errors = [];
|
|
534
545
|
status = true;
|
|
535
546
|
}
|
|
536
547
|
}
|
|
@@ -9,6 +9,7 @@ export const VALID_EVENT_ENUM = [
|
|
|
9
9
|
'lambdaSyncInv',
|
|
10
10
|
'lambdaSyncApi',
|
|
11
11
|
'dsq',
|
|
12
|
+
'dss',
|
|
12
13
|
'generateCode'
|
|
13
14
|
];
|
|
14
15
|
export const VALID_CODE_HOOK_TAG_ENUM = ['before', 'after'];
|
|
@@ -110,6 +111,21 @@ export function setupBasicValidatorSchema(targetSchema = basicValidatorSchema) {
|
|
|
110
111
|
VALID_GENERATED_BY_ENUM;
|
|
111
112
|
}
|
|
112
113
|
|
|
114
|
+
if (targetSchema.relationshipBasicSchema?.patternProperties) {
|
|
115
|
+
for (const patternSchema of Object.values(
|
|
116
|
+
targetSchema.relationshipBasicSchema.patternProperties
|
|
117
|
+
)) {
|
|
118
|
+
if (patternSchema?.properties?.generatedBy) {
|
|
119
|
+
patternSchema.properties.generatedBy.enum = Array.from(
|
|
120
|
+
new Set([
|
|
121
|
+
...(patternSchema.properties.generatedBy.enum || []),
|
|
122
|
+
...VALID_GENERATED_BY_ENUM
|
|
123
|
+
])
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
113
129
|
const objectSchemasToPatch = [
|
|
114
130
|
targetSchema.basicObjectSchema,
|
|
115
131
|
targetSchema.basicExtendObjectSchema
|
|
@@ -5,8 +5,8 @@ import { customFlowNextSteps } from '../custom/customFlows.js';
|
|
|
5
5
|
import { createCrudActionPlans } from '../crud/crudActionPlan.js';
|
|
6
6
|
|
|
7
7
|
const TEMPLATE_URL = new URL('./templates/', import.meta.url);
|
|
8
|
-
const APP_ROOT = 'app/sls_yaml/generatedCode/source';
|
|
9
|
-
const SRC_ROOT = 'app/src/generatedCode/CoreFunctions';
|
|
8
|
+
// const APP_ROOT = 'app/sls_yaml/generatedCode/source';
|
|
9
|
+
// const SRC_ROOT = 'app/src/generatedCode/CoreFunctions';
|
|
10
10
|
const INITIAL_SETUP_ROOT = 'app/initial_setup/generatedCode/source';
|
|
11
11
|
const INITIAL_SETUP_DATA_ROOT = 'app/initial_setup/generatedCode/data';
|
|
12
12
|
|
|
@@ -159,21 +159,21 @@ export function coreFunctionManagedPaths(
|
|
|
159
159
|
]);
|
|
160
160
|
|
|
161
161
|
const paths = [
|
|
162
|
-
`${APP_ROOT}/core-function.yml`,
|
|
163
|
-
`${APP_ROOT}/core-resource.yml`,
|
|
164
|
-
`${SRC_ROOT}/UploadSchema_HdrInv.js`,
|
|
165
|
-
`${SRC_ROOT}/UploadSchema_Main.js`,
|
|
166
|
-
`${SRC_ROOT}/GenerateSeedDataDynamo_HdrInv.js`,
|
|
167
|
-
`${SRC_ROOT}/GenerateSeedDataDynamo_Main.js`,
|
|
168
|
-
`${SRC_ROOT}/RemoveSeedDataDynamo_HdrInv.js`,
|
|
169
|
-
`${SRC_ROOT}/RemoveSeedDataDynamo_Main.js`,
|
|
170
|
-
`${SRC_ROOT}/GenerateSeedDataGraphData_HdrInv.js`,
|
|
171
|
-
`${SRC_ROOT}/GenerateSeedDataGraphData_Main.js`,
|
|
172
|
-
`${SRC_ROOT}/GenerateSeedDataGraphSchema_HdrInv.js`,
|
|
173
|
-
`${SRC_ROOT}/GenerateSeedDataGraphSchema_Main.js`,
|
|
174
|
-
`${SRC_ROOT}/InitialSetup_HdrInv.js`,
|
|
175
|
-
`${SRC_ROOT}/InitialSetup_Main.js`,
|
|
176
|
-
`${SRC_ROOT}/InitialSetupConfig.js`,
|
|
162
|
+
// `${APP_ROOT}/core-function.yml`,
|
|
163
|
+
// `${APP_ROOT}/core-resource.yml`,
|
|
164
|
+
// `${SRC_ROOT}/UploadSchema_HdrInv.js`,
|
|
165
|
+
// `${SRC_ROOT}/UploadSchema_Main.js`,
|
|
166
|
+
// `${SRC_ROOT}/GenerateSeedDataDynamo_HdrInv.js`,
|
|
167
|
+
// `${SRC_ROOT}/GenerateSeedDataDynamo_Main.js`,
|
|
168
|
+
// `${SRC_ROOT}/RemoveSeedDataDynamo_HdrInv.js`,
|
|
169
|
+
// `${SRC_ROOT}/RemoveSeedDataDynamo_Main.js`,
|
|
170
|
+
// `${SRC_ROOT}/GenerateSeedDataGraphData_HdrInv.js`,
|
|
171
|
+
// `${SRC_ROOT}/GenerateSeedDataGraphData_Main.js`,
|
|
172
|
+
// `${SRC_ROOT}/GenerateSeedDataGraphSchema_HdrInv.js`,
|
|
173
|
+
// `${SRC_ROOT}/GenerateSeedDataGraphSchema_Main.js`,
|
|
174
|
+
// `${SRC_ROOT}/InitialSetup_HdrInv.js`,
|
|
175
|
+
// `${SRC_ROOT}/InitialSetup_Main.js`,
|
|
176
|
+
// `${SRC_ROOT}/InitialSetupConfig.js`,
|
|
177
177
|
`${INITIAL_SETUP_ROOT}/InitialSetupConfig.js`,
|
|
178
178
|
`${INITIAL_SETUP_ROOT}/runner.js`,
|
|
179
179
|
`${INITIAL_SETUP_ROOT}/commands/initialSetup.js`,
|
|
@@ -206,7 +206,21 @@ export async function emitCoreFunctionArtifacts({ project, objects = [], relatio
|
|
|
206
206
|
if (typeof flow.flowTag === 'string' && flow.flowTag) {
|
|
207
207
|
roleName = flow.flowTag[0].toUpperCase() + flow.flowTag.slice(1);
|
|
208
208
|
}
|
|
209
|
-
|
|
209
|
+
let quotaServiceTag = flow.quotaServiceTag;
|
|
210
|
+
if (!quotaServiceTag && flow.belongTo) {
|
|
211
|
+
if (Array.isArray(flow.belongTo)) {
|
|
212
|
+
quotaServiceTag = flow.belongTo[0]?.serviceTag;
|
|
213
|
+
} else if (flow.belongTo.serviceTag) {
|
|
214
|
+
quotaServiceTag = flow.belongTo.serviceTag;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (!quotaServiceTag && flow.objType?.serviceTag) {
|
|
218
|
+
quotaServiceTag = flow.objType.serviceTag;
|
|
219
|
+
}
|
|
220
|
+
if (!quotaServiceTag) {
|
|
221
|
+
quotaServiceTag = project?.serviceTag || 'Rbac';
|
|
222
|
+
}
|
|
223
|
+
return { roleName, quotaServiceTag };
|
|
210
224
|
});
|
|
211
225
|
|
|
212
226
|
const rbac =
|
|
@@ -239,20 +253,20 @@ export async function emitCoreFunctionArtifacts({ project, objects = [], relatio
|
|
|
239
253
|
};
|
|
240
254
|
|
|
241
255
|
const [
|
|
242
|
-
coreFunctionYaml,
|
|
243
|
-
coreResourceYaml,
|
|
244
|
-
uploadSchemaHdrInv,
|
|
245
|
-
uploadSchemaMain,
|
|
246
|
-
generateSeedDataDynamoHdrInv,
|
|
247
|
-
generateSeedDataDynamoMain,
|
|
248
|
-
removeSeedDataDynamoHdrInv,
|
|
249
|
-
removeSeedDataDynamoMain,
|
|
250
|
-
generateSeedDataGraphDataHdrInv,
|
|
251
|
-
generateSeedDataGraphDataMain,
|
|
252
|
-
generateSeedDataGraphSchemaHdrInv,
|
|
253
|
-
generateSeedDataGraphSchemaMain,
|
|
254
|
-
initialSetupHdrInv,
|
|
255
|
-
initialSetupMain,
|
|
256
|
+
// coreFunctionYaml,
|
|
257
|
+
// coreResourceYaml,
|
|
258
|
+
// uploadSchemaHdrInv,
|
|
259
|
+
// uploadSchemaMain,
|
|
260
|
+
// generateSeedDataDynamoHdrInv,
|
|
261
|
+
// generateSeedDataDynamoMain,
|
|
262
|
+
// removeSeedDataDynamoHdrInv,
|
|
263
|
+
// removeSeedDataDynamoMain,
|
|
264
|
+
// generateSeedDataGraphDataHdrInv,
|
|
265
|
+
// generateSeedDataGraphDataMain,
|
|
266
|
+
// generateSeedDataGraphSchemaHdrInv,
|
|
267
|
+
// generateSeedDataGraphSchemaMain,
|
|
268
|
+
// initialSetupHdrInv,
|
|
269
|
+
// initialSetupMain,
|
|
256
270
|
initialSetupConfig,
|
|
257
271
|
initialSetupRunner,
|
|
258
272
|
commandInitialSetup,
|
|
@@ -261,20 +275,20 @@ export async function emitCoreFunctionArtifacts({ project, objects = [], relatio
|
|
|
261
275
|
commandSeedGraph,
|
|
262
276
|
commandUploadSchema
|
|
263
277
|
] = await Promise.all([
|
|
264
|
-
render('CoreFunction_Yaml.ejs', state),
|
|
265
|
-
render('CoreResource_Yaml.ejs', state),
|
|
266
|
-
render('UploadSchema_HdrInv.ejs', state),
|
|
267
|
-
render('UploadSchema_Main.ejs', state),
|
|
268
|
-
render('GenerateSeedDataDynamo_HdrInv.ejs', state),
|
|
269
|
-
render('GenerateSeedDataDynamo_Main.ejs', state),
|
|
270
|
-
render('RemoveSeedDataDynamo_HdrInv.ejs', state),
|
|
271
|
-
render('RemoveSeedDataDynamo_Main.ejs', state),
|
|
272
|
-
render('GenerateSeedDataGraphData_HdrInv.ejs', state),
|
|
273
|
-
render('GenerateSeedDataGraphData_Main.ejs', state),
|
|
274
|
-
render('GenerateSeedDataGraphSchema_HdrInv.ejs', state),
|
|
275
|
-
render('GenerateSeedDataGraphSchema_Main.ejs', state),
|
|
276
|
-
render('InitialSetup_HdrInv.ejs', state),
|
|
277
|
-
render('InitialSetup_Main.ejs', state),
|
|
278
|
+
// render('CoreFunction_Yaml.ejs', state),
|
|
279
|
+
// render('CoreResource_Yaml.ejs', state),
|
|
280
|
+
// render('UploadSchema_HdrInv.ejs', state),
|
|
281
|
+
// render('UploadSchema_Main.ejs', state),
|
|
282
|
+
// render('GenerateSeedDataDynamo_HdrInv.ejs', state),
|
|
283
|
+
// render('GenerateSeedDataDynamo_Main.ejs', state),
|
|
284
|
+
// render('RemoveSeedDataDynamo_HdrInv.ejs', state),
|
|
285
|
+
// render('RemoveSeedDataDynamo_Main.ejs', state),
|
|
286
|
+
// render('GenerateSeedDataGraphData_HdrInv.ejs', state),
|
|
287
|
+
// render('GenerateSeedDataGraphData_Main.ejs', state),
|
|
288
|
+
// render('GenerateSeedDataGraphSchema_HdrInv.ejs', state),
|
|
289
|
+
// render('GenerateSeedDataGraphSchema_Main.ejs', state),
|
|
290
|
+
// render('InitialSetup_HdrInv.ejs', state),
|
|
291
|
+
// render('InitialSetup_Main.ejs', state),
|
|
278
292
|
render('InitialSetupConfig.ejs', state),
|
|
279
293
|
render('InitialSetupRunner.ejs', state),
|
|
280
294
|
render('InitialSetupRunner_initialSetup.ejs', state),
|
|
@@ -285,66 +299,66 @@ export async function emitCoreFunctionArtifacts({ project, objects = [], relatio
|
|
|
285
299
|
]);
|
|
286
300
|
|
|
287
301
|
const baseArtifacts = [
|
|
288
|
-
{
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
},
|
|
292
|
-
{
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
},
|
|
300
|
-
{
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
},
|
|
304
|
-
{
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
},
|
|
308
|
-
{
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
},
|
|
320
|
-
{
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
},
|
|
324
|
-
{
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
},
|
|
328
|
-
{
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
},
|
|
332
|
-
{
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
},
|
|
336
|
-
{
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
},
|
|
340
|
-
{
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
},
|
|
344
|
-
{
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
},
|
|
302
|
+
// {
|
|
303
|
+
// path: `${APP_ROOT}/core-function.yml`,
|
|
304
|
+
// content: normalizeYaml(coreFunctionYaml)
|
|
305
|
+
// },
|
|
306
|
+
// {
|
|
307
|
+
// path: `${APP_ROOT}/core-resource.yml`,
|
|
308
|
+
// content: normalizeYaml(coreResourceYaml)
|
|
309
|
+
// },
|
|
310
|
+
// {
|
|
311
|
+
// path: `${SRC_ROOT}/UploadSchema_HdrInv.js`,
|
|
312
|
+
// content: uploadSchemaHdrInv
|
|
313
|
+
// },
|
|
314
|
+
// {
|
|
315
|
+
// path: `${SRC_ROOT}/UploadSchema_Main.js`,
|
|
316
|
+
// content: uploadSchemaMain
|
|
317
|
+
// },
|
|
318
|
+
// {
|
|
319
|
+
// path: `${SRC_ROOT}/GenerateSeedDataDynamo_HdrInv.js`,
|
|
320
|
+
// content: generateSeedDataDynamoHdrInv
|
|
321
|
+
// },
|
|
322
|
+
// {
|
|
323
|
+
// path: `${SRC_ROOT}/GenerateSeedDataDynamo_Main.js`,
|
|
324
|
+
// content: generateSeedDataDynamoMain
|
|
325
|
+
// },
|
|
326
|
+
// {
|
|
327
|
+
// path: `${SRC_ROOT}/RemoveSeedDataDynamo_HdrInv.js`,
|
|
328
|
+
// content: removeSeedDataDynamoHdrInv
|
|
329
|
+
// },
|
|
330
|
+
// {
|
|
331
|
+
// path: `${SRC_ROOT}/RemoveSeedDataDynamo_Main.js`,
|
|
332
|
+
// content: removeSeedDataDynamoMain
|
|
333
|
+
// },
|
|
334
|
+
// {
|
|
335
|
+
// path: `${SRC_ROOT}/GenerateSeedDataGraphData_HdrInv.js`,
|
|
336
|
+
// content: generateSeedDataGraphDataHdrInv
|
|
337
|
+
// },
|
|
338
|
+
// {
|
|
339
|
+
// path: `${SRC_ROOT}/GenerateSeedDataGraphData_Main.js`,
|
|
340
|
+
// content: generateSeedDataGraphDataMain
|
|
341
|
+
// },
|
|
342
|
+
// {
|
|
343
|
+
// path: `${SRC_ROOT}/GenerateSeedDataGraphSchema_HdrInv.js`,
|
|
344
|
+
// content: generateSeedDataGraphSchemaHdrInv
|
|
345
|
+
// },
|
|
346
|
+
// {
|
|
347
|
+
// path: `${SRC_ROOT}/GenerateSeedDataGraphSchema_Main.js`,
|
|
348
|
+
// content: generateSeedDataGraphSchemaMain
|
|
349
|
+
// },
|
|
350
|
+
// {
|
|
351
|
+
// path: `${SRC_ROOT}/InitialSetup_HdrInv.js`,
|
|
352
|
+
// content: initialSetupHdrInv
|
|
353
|
+
// },
|
|
354
|
+
// {
|
|
355
|
+
// path: `${SRC_ROOT}/InitialSetup_Main.js`,
|
|
356
|
+
// content: initialSetupMain
|
|
357
|
+
// },
|
|
358
|
+
// {
|
|
359
|
+
// path: `${SRC_ROOT}/InitialSetupConfig.js`,
|
|
360
|
+
// content: initialSetupConfig
|
|
361
|
+
// },
|
|
348
362
|
{
|
|
349
363
|
path: `${INITIAL_SETUP_ROOT}/InitialSetupConfig.js`,
|
|
350
364
|
content: initialSetupConfig
|
|
@@ -418,9 +432,9 @@ export async function emitCoreFunctionArtifacts({ project, objects = [], relatio
|
|
|
418
432
|
return baseArtifacts;
|
|
419
433
|
}
|
|
420
434
|
|
|
421
|
-
function normalizeYaml(content) {
|
|
422
|
-
|
|
423
|
-
}
|
|
435
|
+
// function normalizeYaml(content) {
|
|
436
|
+
// return `${content.trimEnd()}\n`;
|
|
437
|
+
// }
|
|
424
438
|
|
|
425
439
|
async function render(templateName, data) {
|
|
426
440
|
return ejsLib.render(
|
|
@@ -277,7 +277,9 @@ function roleConfigs() {
|
|
|
277
277
|
`arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${lambdaSharedLib.lambdaFunctionName(_izContext, 'ConfirmUsageHdrInv', 'Rbac')}`,
|
|
278
278
|
`arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${lambdaSharedLib.lambdaFunctionName(_izContext, 'CancelUsageHdrInv', 'Rbac')}`<% if (rbac) { %>,
|
|
279
279
|
`arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${lambdaSharedLib.lambdaFunctionName(_izContext, 'ValidatorRbacHdrInv')}`<% } %><% (rbacValidatorServiceTags || []).forEach(function(tag) { %>,
|
|
280
|
-
`arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${lambdaSharedLib.lambdaFunctionName(_izContext, 'ValidatorRbacHdrInv', '<%= tag %>')}
|
|
280
|
+
`arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${lambdaSharedLib.lambdaFunctionName(_izContext, 'ValidatorRbacHdrInv', '<%= tag %>')}`,
|
|
281
|
+
`arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${lambdaSharedLib.lambdaFunctionName(_izContext, 'ConfirmUsageHdrInv', '<%= tag %>')}`,
|
|
282
|
+
`arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${lambdaSharedLib.lambdaFunctionName(_izContext, 'CancelUsageHdrInv', '<%= tag %>')}`<% }); %>
|
|
281
283
|
]
|
|
282
284
|
},
|
|
283
285
|
|
|
@@ -290,7 +292,9 @@ function roleConfigs() {
|
|
|
290
292
|
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'ConfirmUsage_In', 'Rbac')}`,
|
|
291
293
|
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'CancelUsage_In', 'Rbac')}`<% if (rbac) { %>,
|
|
292
294
|
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'ValidatorRbac_In')}`<% } %><% (rbacValidatorServiceTags || []).forEach(function(tag) { %>,
|
|
293
|
-
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'ValidatorRbac_In', '<%= tag %>')}
|
|
295
|
+
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'ValidatorRbac_In', '<%= tag %>')}`,
|
|
296
|
+
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'ConfirmUsage_In', '<%= tag %>')}`,
|
|
297
|
+
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'CancelUsage_In', '<%= tag %>')}`<% }); %>
|
|
294
298
|
]
|
|
295
299
|
},
|
|
296
300
|
<% } -%>
|
|
@@ -390,7 +394,7 @@ function roleConfigs() {
|
|
|
390
394
|
Effect: 'Allow',
|
|
391
395
|
Action: ['sns:Publish'],
|
|
392
396
|
Resource: [
|
|
393
|
-
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'ReservedDynamicUsage_In', '
|
|
397
|
+
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'ReservedDynamicUsage_In', '<%= flow.quotaServiceTag || 'Rbac' %>')}`
|
|
394
398
|
]
|
|
395
399
|
},
|
|
396
400
|
|
|
@@ -399,7 +403,7 @@ function roleConfigs() {
|
|
|
399
403
|
Effect: 'Allow',
|
|
400
404
|
Action: ['sns:Publish'],
|
|
401
405
|
Resource: [
|
|
402
|
-
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'ConfirmDynamicAfterUpload_In', '
|
|
406
|
+
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'ConfirmDynamicAfterUpload_In', '<%= flow.quotaServiceTag || 'Rbac' %>')}`
|
|
403
407
|
]
|
|
404
408
|
}
|
|
405
409
|
//(<create<%= flow.roleName %>Role>)
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import fs from 'fs';
|
|
17
|
-
import
|
|
17
|
+
import { readYamlFileSync } from 'read-yaml-file';
|
|
18
18
|
import { join } from 'path';
|
|
19
19
|
|
|
20
20
|
// 1. Parse serverless config and set environment variables
|
|
21
21
|
const configPath = join(process.cwd(), '..', 'config', 'serverless.config.yml');
|
|
22
22
|
if (fs.existsSync(configPath)) {
|
|
23
|
-
const serverlessConfig =
|
|
23
|
+
const serverlessConfig = readYamlFileSync(configPath);
|
|
24
24
|
const izConfig = serverlessConfig.main_config || {};
|
|
25
25
|
process.env.iz_stage = izConfig.iz_stage || process.env.iz_stage;
|
|
26
26
|
process.env.iz_region = izConfig.iz_region || process.env.iz_region;
|
|
@@ -145,6 +145,8 @@ export default async function CreateComplete(
|
|
|
145
145
|
}
|
|
146
146
|
const callingFlowConfig =
|
|
147
147
|
result?.additionalAttributes?.callingFlowConfig ||
|
|
148
|
+
requestParams?.passBackProperties?.parentPassBackProperties ||
|
|
149
|
+
passBackProperties?.passBackProperties?.parentPassBackProperties ||
|
|
148
150
|
passBackProperties;
|
|
149
151
|
const actionData = {
|
|
150
152
|
objType: returnValue.requestParams.objType,
|
|
@@ -142,9 +142,9 @@ export default async function <%- flowTag %>(
|
|
|
142
142
|
const { checkRbacPermission } =
|
|
143
143
|
await import('@izara_project/izara-authorization');
|
|
144
144
|
|
|
145
|
-
//(<rbacParameterGroups_<%- flowTag
|
|
145
|
+
//(<rbacParameterGroups_<%- flowTag %>>)
|
|
146
146
|
const parameterGroups = {};
|
|
147
|
-
//(</rbacParameterGroups_<%- flowTag
|
|
147
|
+
//(</rbacParameterGroups_<%- flowTag %>>)
|
|
148
148
|
|
|
149
149
|
const isBillable = objectSchema.addOnDataStructure?.some(
|
|
150
150
|
(item) => item.type === 'rbac' && item.billable === true
|
|
@@ -187,8 +187,8 @@ export default async function <%- flowTag %>(
|
|
|
187
187
|
);
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
//(<rbacPublish_<%- flowTag
|
|
191
|
-
//(</rbacPublish_<%- flowTag
|
|
190
|
+
//(<rbacPublish_<%- flowTag %>>)
|
|
191
|
+
//(</rbacPublish_<%- flowTag %>>)
|
|
192
192
|
}
|
|
193
193
|
<%_ } _%>
|
|
194
194
|
|