@izara_project/izara-core-generate-service-code 1.0.99 → 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 +3 -1
- package/src/compile/loadSchemas.js +18 -4
- package/src/compile/schemaValidatorSetup.js +16 -0
- package/src/emit/application/coreFunction/emitCoreFunctionArtifacts.js +108 -108
- 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/CreateLogicalLib.ejs +14 -7
- package/src/emit/application/crud/templates/DeleteComplete_Main.ejs +2 -0
- 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/custom/customFlowPaths.js +13 -16
- package/src/emit/application/custom/customFlowS3.js +274 -63
- package/src/emit/application/custom/customFlows.js +131 -0
- package/src/emit/application/custom/emitCustomFlowApplicationArtifacts.js +3 -1
- 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 +5 -1
- package/src/emit/application/rbac/emitRbacApplicationArtifacts.js +67 -60
- package/src/emit/application/rbac/templates/ReservedDynamicUsage_Main.ejs +27 -9
- 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 +3 -8
- package/src/emit/infrastructure/functions/templates/S3Function_Yaml.ejs +2 -3
- package/src/emit/infrastructure/resources/iamResourceArtifacts.js +22 -0
- package/src/emit/infrastructure/resources/resourceState.js +15 -5
- package/src/emit/infrastructure/resources/s3ResourceArtifacts.js +19 -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/error/emitErrorSchemas.js +120 -10
- package/src/emit/schemas/error/templates/errorConsts.ejs +12 -0
- package/src/generate.js +32 -30
- package/test/integration/publicApi.test.js +33 -24
- package/test/unit/application/createTargetRoleHandler.test.js +33 -10
- 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 +51 -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
|
@@ -1,19 +1,43 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
1
2
|
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
2
4
|
import ejsLib from 'ejs';
|
|
3
5
|
|
|
4
6
|
const TEMPLATE_URL = new URL('./templates/', import.meta.url);
|
|
5
7
|
export const ERROR_SCHEMA_PATH =
|
|
6
|
-
'app/src/schemas/ErrorSchemas/generateCode/
|
|
8
|
+
'app/src/schemas/ErrorSchemas/generateCode/errorConsts.js';
|
|
9
|
+
export const ERROR_CONSTS_PATH = ERROR_SCHEMA_PATH;
|
|
10
|
+
|
|
11
|
+
export const SHARED_ERROR_PACKAGE_PATH = 'libs/errorLib/package.json';
|
|
12
|
+
export const SHARED_ERROR_INDEX_PATH = 'libs/errorLib/index.js';
|
|
13
|
+
export const SHARED_ERROR_CONSTS_PATH = 'libs/errorLib/src/errorConsts.js';
|
|
7
14
|
|
|
8
15
|
export function errorSchemaManagedPaths(errors = []) {
|
|
9
16
|
if (!errors || errors.length === 0) {
|
|
10
17
|
return [];
|
|
11
18
|
}
|
|
12
|
-
|
|
19
|
+
const paths = [ERROR_SCHEMA_PATH];
|
|
20
|
+
const safeErrors = Array.isArray(errors) ? errors : [];
|
|
21
|
+
let hasShared = false;
|
|
22
|
+
for (const item of safeErrors) {
|
|
23
|
+
if (item && item.sharedLibrary === true) {
|
|
24
|
+
hasShared = true;
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (hasShared) {
|
|
29
|
+
paths.push(
|
|
30
|
+
SHARED_ERROR_PACKAGE_PATH,
|
|
31
|
+
SHARED_ERROR_INDEX_PATH,
|
|
32
|
+
SHARED_ERROR_CONSTS_PATH
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
return paths;
|
|
13
36
|
}
|
|
14
37
|
|
|
15
38
|
/**
|
|
16
|
-
* Emits
|
|
39
|
+
* Emits errorConsts.js artifact and shared library artifacts based on
|
|
40
|
+
* loaded ErrorSchemas
|
|
17
41
|
*
|
|
18
42
|
* @param {Object} params
|
|
19
43
|
* @param {Object} params.project
|
|
@@ -31,21 +55,28 @@ export async function emitErrorSchemas({
|
|
|
31
55
|
return [];
|
|
32
56
|
}
|
|
33
57
|
|
|
34
|
-
const defaultGraphServiceTag =
|
|
35
|
-
objectGraphServiceTags[0] || 'GraphHandler';
|
|
36
58
|
const defaultServiceTag = project?.serviceTag || '';
|
|
37
59
|
|
|
38
60
|
const errorTypes = {};
|
|
61
|
+
const sharedErrorTypes = {};
|
|
62
|
+
|
|
39
63
|
for (const item of safeErrors) {
|
|
40
64
|
if (!item || typeof item !== 'object' || !item.errorTag) {
|
|
41
65
|
continue;
|
|
42
66
|
}
|
|
43
67
|
const errorTag = item.errorTag;
|
|
44
|
-
|
|
45
|
-
|
|
68
|
+
let serviceTag = item.serviceTag;
|
|
69
|
+
if (!serviceTag) {
|
|
70
|
+
serviceTag = defaultServiceTag;
|
|
71
|
+
}
|
|
72
|
+
const errorEntry = {
|
|
46
73
|
errorTag,
|
|
47
74
|
serviceTag
|
|
48
75
|
};
|
|
76
|
+
errorTypes[errorTag] = errorEntry;
|
|
77
|
+
if (item.sharedLibrary === true) {
|
|
78
|
+
sharedErrorTypes[errorTag] = errorEntry;
|
|
79
|
+
}
|
|
49
80
|
}
|
|
50
81
|
|
|
51
82
|
const sortedKeys = Object.keys(errorTypes).sort();
|
|
@@ -58,16 +89,95 @@ export async function emitErrorSchemas({
|
|
|
58
89
|
sortedErrorTypes[key] = errorTypes[key];
|
|
59
90
|
}
|
|
60
91
|
|
|
61
|
-
const templatePath = new URL('
|
|
92
|
+
const templatePath = new URL('errorConsts.ejs', TEMPLATE_URL);
|
|
62
93
|
const template = await readFile(templatePath, 'utf8');
|
|
63
94
|
const content = ejsLib.render(template, {
|
|
64
|
-
errorTypes: sortedErrorTypes
|
|
95
|
+
errorTypes: sortedErrorTypes,
|
|
96
|
+
headerComment: null
|
|
65
97
|
});
|
|
66
98
|
|
|
67
|
-
|
|
99
|
+
const artifacts = [
|
|
68
100
|
{
|
|
69
101
|
path: ERROR_SCHEMA_PATH,
|
|
70
102
|
content
|
|
71
103
|
}
|
|
72
104
|
];
|
|
105
|
+
|
|
106
|
+
const sortedSharedKeys = Object.keys(sharedErrorTypes).sort();
|
|
107
|
+
if (sortedSharedKeys.length > 0) {
|
|
108
|
+
const sortedSharedErrorTypes = {};
|
|
109
|
+
for (const key of sortedSharedKeys) {
|
|
110
|
+
sortedSharedErrorTypes[key] = sharedErrorTypes[key];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const sharedContent = ejsLib.render(template, {
|
|
114
|
+
errorTypes: sortedSharedErrorTypes,
|
|
115
|
+
headerComment: '// only generate error that sharedLibrary: true'
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
let serviceName = 'service';
|
|
119
|
+
if (project?.serviceTag) {
|
|
120
|
+
serviceName = project.serviceTag.toLowerCase();
|
|
121
|
+
}
|
|
122
|
+
const packageName = `@izara_project/izara-${serviceName}-library-errorlib`;
|
|
123
|
+
|
|
124
|
+
let packageJson = {
|
|
125
|
+
name: packageName,
|
|
126
|
+
version: '1.0.0',
|
|
127
|
+
description: '',
|
|
128
|
+
type: 'module',
|
|
129
|
+
main: 'index.js',
|
|
130
|
+
scripts: {},
|
|
131
|
+
keywords: [],
|
|
132
|
+
author: '',
|
|
133
|
+
license: 'ISC',
|
|
134
|
+
devDependencies: {},
|
|
135
|
+
dependencies: {}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
let targetDir = project?.outputPath;
|
|
139
|
+
if (!targetDir) {
|
|
140
|
+
targetDir = project?.rootPath;
|
|
141
|
+
}
|
|
142
|
+
if (targetDir) {
|
|
143
|
+
const existingPkgPath = join(targetDir, SHARED_ERROR_PACKAGE_PATH);
|
|
144
|
+
if (existsSync(existingPkgPath)) {
|
|
145
|
+
try {
|
|
146
|
+
const raw = readFileSync(existingPkgPath, 'utf8');
|
|
147
|
+
const parsed = JSON.parse(raw);
|
|
148
|
+
if (parsed && typeof parsed === 'object') {
|
|
149
|
+
packageJson = {
|
|
150
|
+
...parsed,
|
|
151
|
+
name: packageName,
|
|
152
|
+
type: 'module',
|
|
153
|
+
main: 'index.js'
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
} catch {
|
|
157
|
+
// If parsing fails (e.g. comments in JSON), use default packageJson
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const packageJsonContent = `${JSON.stringify(packageJson, null, 2)}\n`;
|
|
163
|
+
const indexContent =
|
|
164
|
+
"import * as errorLib from './src/errorConsts.js';\n\nexport { errorLib };\n";
|
|
165
|
+
|
|
166
|
+
artifacts.push(
|
|
167
|
+
{
|
|
168
|
+
path: SHARED_ERROR_PACKAGE_PATH,
|
|
169
|
+
content: packageJsonContent
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
path: SHARED_ERROR_INDEX_PATH,
|
|
173
|
+
content: indexContent
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
path: SHARED_ERROR_CONSTS_PATH,
|
|
177
|
+
content: sharedContent
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return artifacts;
|
|
73
183
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<% if (locals.headerComment) { -%>
|
|
2
|
+
<%- headerComment %>
|
|
3
|
+
<% } -%>
|
|
4
|
+
export const ERROR_TYPES = {
|
|
5
|
+
<% const keys = Object.keys(errorTypes); -%>
|
|
6
|
+
<% keys.forEach((key, index) => { -%>
|
|
7
|
+
<%- key %>: {
|
|
8
|
+
errorTag: '<%- errorTypes[key].errorTag %>',
|
|
9
|
+
serviceTag: '<%- errorTypes[key].serviceTag %>'
|
|
10
|
+
}<%- index < keys.length - 1 ? ',' : '' %>
|
|
11
|
+
<% }); -%>
|
|
12
|
+
};
|
package/src/generate.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { mkdir } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
|
|
1
4
|
import { buildGenerationPlan } from './plan/buildGenerationPlan.js';
|
|
2
5
|
import { resolveEmissionGroups } from './plan/domainRegistry.js';
|
|
3
6
|
import { commitArtifacts } from './output/commitArtifacts.js';
|
|
@@ -13,32 +16,32 @@ export async function generate(rootPath, options = {}) {
|
|
|
13
16
|
console.log(`[INFO] [Generate] STATUS=STARTED | rootPath=${rootPath}`);
|
|
14
17
|
try {
|
|
15
18
|
const project = compileProject({ ...options, rootPath });
|
|
19
|
+
await mkdir(join(project.schemaRoot, 'ErrorSchemas'), {
|
|
20
|
+
recursive: true
|
|
21
|
+
});
|
|
16
22
|
const schemaLoadOptions = {
|
|
17
23
|
skipValidation: options.skipValidation
|
|
18
24
|
};
|
|
19
|
-
const [
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
'NotificationSchemas',
|
|
36
|
-
schemaLoadOptions
|
|
37
|
-
),
|
|
38
|
-
loadLocalSchemaDirectory(project, 'ErrorSchemas', schemaLoadOptions)
|
|
39
|
-
]);
|
|
25
|
+
const [rawObjects, relationships, flows, notifications, errors] =
|
|
26
|
+
await Promise.all([
|
|
27
|
+
loadLocalSchemaDirectory(project, 'ObjectSchemas', schemaLoadOptions),
|
|
28
|
+
loadLocalSchemaDirectory(
|
|
29
|
+
project,
|
|
30
|
+
'RelationshipSchemas',
|
|
31
|
+
schemaLoadOptions
|
|
32
|
+
),
|
|
33
|
+
loadLocalSchemaDirectory(project, 'FlowSchemas', schemaLoadOptions),
|
|
34
|
+
loadLocalSchemaDirectory(
|
|
35
|
+
project,
|
|
36
|
+
'NotificationSchemas',
|
|
37
|
+
schemaLoadOptions
|
|
38
|
+
),
|
|
39
|
+
loadLocalSchemaDirectory(project, 'ErrorSchemas', schemaLoadOptions)
|
|
40
|
+
]);
|
|
40
41
|
const schemaBucketName =
|
|
41
|
-
options.schemaBucketName ||
|
|
42
|
+
options.schemaBucketName ||
|
|
43
|
+
project.schemaBucketName ||
|
|
44
|
+
process.env.iz_serviceSchemaBucketName;
|
|
42
45
|
const objects = await resolveExtendedObjectSchemas(
|
|
43
46
|
rawObjects,
|
|
44
47
|
schemaBucketName
|
|
@@ -58,17 +61,17 @@ export async function generate(rootPath, options = {}) {
|
|
|
58
61
|
}
|
|
59
62
|
console.log(
|
|
60
63
|
`[INFO] [Generate] STATUS=SCHEMAS_LOADED | ` +
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
`objects=${objects.length}${objectSummary} ` +
|
|
65
|
+
`relationships=${relationships.length} flows=${flows.length} ` +
|
|
66
|
+
`notifications=${notifications.length} ` +
|
|
67
|
+
`errors=${errors.length}`
|
|
65
68
|
);
|
|
66
69
|
if (options.verbose || process.env.GENERATE_VERBOSE) {
|
|
67
70
|
for (const objectSchema of objects) {
|
|
68
71
|
const objectType = objectSchema.objectType || 'unknown';
|
|
69
72
|
console.log(
|
|
70
73
|
`[DEBUG] [Generate] OBJECT_SCHEMA | objectType=${objectType}\n` +
|
|
71
|
-
|
|
74
|
+
JSON.stringify(objectSchema, null, 2)
|
|
72
75
|
);
|
|
73
76
|
}
|
|
74
77
|
}
|
|
@@ -107,17 +110,16 @@ export async function generate(rootPath, options = {}) {
|
|
|
107
110
|
const durationMs = Date.now() - startedAt;
|
|
108
111
|
console.log(
|
|
109
112
|
`[INFO] [Generate] STATUS=FINISHED | ` +
|
|
110
|
-
|
|
113
|
+
`files=${files.length} durationMs=${durationMs}`
|
|
111
114
|
);
|
|
112
115
|
|
|
113
116
|
return { project, durationMs, files };
|
|
114
117
|
} catch (error) {
|
|
115
118
|
console.log(
|
|
116
119
|
`[ERROR] [Generate] STATUS=FAILED | ` +
|
|
117
|
-
|
|
120
|
+
`durationMs=${Date.now() - startedAt}`,
|
|
118
121
|
error
|
|
119
122
|
);
|
|
120
123
|
throw error;
|
|
121
124
|
}
|
|
122
125
|
}
|
|
123
|
-
|
|
@@ -23,7 +23,7 @@ test('generate commits schemas, application artifacts, and resources in one publ
|
|
|
23
23
|
const rootPath = await createCrudProject();
|
|
24
24
|
const result = await generate(rootPath);
|
|
25
25
|
|
|
26
|
-
assert.strictEqual(result.files.length,
|
|
26
|
+
assert.strictEqual(result.files.length, 59);
|
|
27
27
|
assert.equal(result.project.rootPath, rootPath);
|
|
28
28
|
assert.match(
|
|
29
29
|
await readFile(
|
|
@@ -366,7 +366,7 @@ test('generate removes stale CRUD schemas and application artifacts', async () =
|
|
|
366
366
|
|
|
367
367
|
const result = await generate(rootPath);
|
|
368
368
|
|
|
369
|
-
assert.equal(result.files.length,
|
|
369
|
+
assert.equal(result.files.length, 23);
|
|
370
370
|
await assert.rejects(
|
|
371
371
|
readFile(
|
|
372
372
|
join(
|
|
@@ -448,36 +448,45 @@ async function createTriggerCacheProject() {
|
|
|
448
448
|
}
|
|
449
449
|
|
|
450
450
|
test(
|
|
451
|
-
'emits ignoreExternalServices hooks in
|
|
452
|
-
'commands/uploadSchema.js',
|
|
451
|
+
'emits ignoreExternalServices hooks in commands/uploadSchema.js',
|
|
453
452
|
async () => {
|
|
454
453
|
const rootPath = await createCrudProject();
|
|
455
454
|
await generate(rootPath);
|
|
456
455
|
|
|
457
|
-
const uploadSchemaMain = await readFile(
|
|
456
|
+
// const uploadSchemaMain = await readFile(
|
|
457
|
+
// join(
|
|
458
|
+
// rootPath,
|
|
459
|
+
// 'app/src/generatedCode/CoreFunctions/UploadSchema_Main.js'
|
|
460
|
+
// ),
|
|
461
|
+
// 'utf8'
|
|
462
|
+
// );
|
|
463
|
+
// assert.match(uploadSchemaMain, /\/\/\(<ignoreExternalServices>\)/);
|
|
464
|
+
// assert.match(uploadSchemaMain, /\/\/\(<\/ignoreExternalServices>\)/);
|
|
465
|
+
|
|
466
|
+
// const coreResource = await readFile(
|
|
467
|
+
// join(
|
|
468
|
+
// rootPath,
|
|
469
|
+
// 'app/sls_yaml/generatedCode/source/core-resource.yml'
|
|
470
|
+
// ),
|
|
471
|
+
// 'utf8'
|
|
472
|
+
// );
|
|
473
|
+
// assert.match(
|
|
474
|
+
// coreResource,
|
|
475
|
+
// /UserAccount\$\{self:custom\.iz_stage\}AddLinkCreateByRelHdrInv/
|
|
476
|
+
// );
|
|
477
|
+
// assert.match(
|
|
478
|
+
// coreResource,
|
|
479
|
+
// /UserAccount\$\{self:custom\.iz_stage\}AddLinkBelongToHdrInv/
|
|
480
|
+
// );
|
|
481
|
+
|
|
482
|
+
const uploadSchemaCommand = await readFile(
|
|
458
483
|
join(
|
|
459
484
|
rootPath,
|
|
460
|
-
'app/
|
|
485
|
+
'app/initial_setup/generatedCode/source/commands/uploadSchema.js'
|
|
461
486
|
),
|
|
462
487
|
'utf8'
|
|
463
488
|
);
|
|
464
|
-
assert.match(
|
|
465
|
-
assert.match(
|
|
466
|
-
|
|
467
|
-
const coreResource = await readFile(
|
|
468
|
-
join(
|
|
469
|
-
rootPath,
|
|
470
|
-
'app/sls_yaml/generatedCode/source/core-resource.yml'
|
|
471
|
-
),
|
|
472
|
-
'utf8'
|
|
473
|
-
);
|
|
474
|
-
assert.match(
|
|
475
|
-
coreResource,
|
|
476
|
-
/UserAccount\$\{self:custom\.iz_stage\}AddLinkCreateByRelHdrInv/
|
|
477
|
-
);
|
|
478
|
-
assert.match(
|
|
479
|
-
coreResource,
|
|
480
|
-
/UserAccount\$\{self:custom\.iz_stage\}AddLinkBelongToHdrInv/
|
|
481
|
-
);
|
|
489
|
+
assert.match(uploadSchemaCommand, /\/\/\(<ignoreExternalServices>\)/);
|
|
490
|
+
assert.match(uploadSchemaCommand, /\/\/\(<\/ignoreExternalServices>\)/);
|
|
482
491
|
}
|
|
483
492
|
);
|
|
@@ -14,10 +14,7 @@ const OWN_TOPIC_FLOWS = [
|
|
|
14
14
|
'DeleteRolePermissions',
|
|
15
15
|
'DeleteTargetRole',
|
|
16
16
|
'CreateUserRole',
|
|
17
|
-
'DeleteUserFromRole'
|
|
18
|
-
'ReservedDynamicUsage',
|
|
19
|
-
'ConfirmUsage',
|
|
20
|
-
'CancelUsage'
|
|
17
|
+
'DeleteUserFromRole'
|
|
21
18
|
];
|
|
22
19
|
|
|
23
20
|
const LIMIT_FLOWS = [
|
|
@@ -36,7 +33,7 @@ test('generates RBAC own-topic WebSocket entries alongside their SQS handlers',
|
|
|
36
33
|
const rootPath = await createProject(true);
|
|
37
34
|
const result = await generateCreateTargetRoleHandler(rootPath);
|
|
38
35
|
|
|
39
|
-
assert.equal(result.files.length,
|
|
36
|
+
assert.equal(result.files.length, 60);
|
|
40
37
|
assert.match(
|
|
41
38
|
await readFile(join(rootPath, result.files[0].path), 'utf8'),
|
|
42
39
|
/CreateTargetRole/
|
|
@@ -167,6 +164,15 @@ test('generates RBAC own-topic WebSocket entries alongside their SQS handlers',
|
|
|
167
164
|
)
|
|
168
165
|
);
|
|
169
166
|
|
|
167
|
+
await assert.rejects(
|
|
168
|
+
readFile(
|
|
169
|
+
join(
|
|
170
|
+
rootPath,
|
|
171
|
+
'app/src/generatedCode/FlowLimit/ReservedDynamicUsage/source/ReservedDynamicUsage_HdrSqs.js'
|
|
172
|
+
)
|
|
173
|
+
)
|
|
174
|
+
);
|
|
175
|
+
|
|
170
176
|
assert.match(
|
|
171
177
|
await readFile(
|
|
172
178
|
join(
|
|
@@ -196,20 +202,37 @@ test('generates RBAC own-topic WebSocket entries alongside their SQS handlers',
|
|
|
196
202
|
'utf8'
|
|
197
203
|
);
|
|
198
204
|
for (const flowTag of OWN_TOPIC_FLOWS) {
|
|
199
|
-
const isLimit = LIMIT_FLOWS.includes(flowTag);
|
|
200
|
-
const folder = isLimit ? 'FlowLimit' : 'FlowRbac';
|
|
201
|
-
const yaml = isLimit ? limitYaml : rbacYaml;
|
|
202
205
|
assert.match(
|
|
203
206
|
await readFile(
|
|
204
207
|
join(
|
|
205
208
|
rootPath,
|
|
206
|
-
`app/src/generatedCode/${
|
|
209
|
+
`app/src/generatedCode/FlowRbac/${flowTag}/source/${flowTag}_HdrWbs.js`
|
|
207
210
|
),
|
|
208
211
|
'utf8'
|
|
209
212
|
),
|
|
210
213
|
new RegExp(`import ${flowTag}`)
|
|
211
214
|
);
|
|
212
|
-
assert.match(
|
|
215
|
+
assert.match(rbacYaml, new RegExp(`${flowTag}HdrWbs:\\n[\\s\\S]*websocket:`));
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
for (const flowTag of LIMIT_FLOWS) {
|
|
219
|
+
await assert.rejects(
|
|
220
|
+
readFile(
|
|
221
|
+
join(
|
|
222
|
+
rootPath,
|
|
223
|
+
`app/src/generatedCode/FlowLimit/${flowTag}/source/${flowTag}_HdrWbs.js`
|
|
224
|
+
)
|
|
225
|
+
)
|
|
226
|
+
);
|
|
227
|
+
await assert.rejects(
|
|
228
|
+
readFile(
|
|
229
|
+
join(
|
|
230
|
+
rootPath,
|
|
231
|
+
`app/src/generatedCode/FlowLimit/${flowTag}/source/${flowTag}_WbsMain.js`
|
|
232
|
+
)
|
|
233
|
+
)
|
|
234
|
+
);
|
|
235
|
+
assert.doesNotMatch(limitYaml, new RegExp(`${flowTag}HdrWbs:`));
|
|
213
236
|
}
|
|
214
237
|
|
|
215
238
|
const ttlExpiredFile = await readFile(
|
|
@@ -924,7 +924,7 @@ test('renders nextSteps IAM permissions in InitialSetupConfig', async () => {
|
|
|
924
924
|
const initialSetupConfigContent = await readFile(
|
|
925
925
|
join(
|
|
926
926
|
rootPath,
|
|
927
|
-
'app/
|
|
927
|
+
'app/initial_setup/generatedCode/source/InitialSetupConfig.js'
|
|
928
928
|
),
|
|
929
929
|
'utf8'
|
|
930
930
|
);
|
|
@@ -997,7 +997,7 @@ test('registers SQS queue, SNS subscription, and SNS out topic for custom flowSc
|
|
|
997
997
|
const initialSetupConfigContent = await readFile(
|
|
998
998
|
join(
|
|
999
999
|
rootPath,
|
|
1000
|
-
'app/
|
|
1000
|
+
'app/initial_setup/generatedCode/source/InitialSetupConfig.js'
|
|
1001
1001
|
),
|
|
1002
1002
|
'utf8'
|
|
1003
1003
|
);
|
|
@@ -1030,7 +1030,7 @@ test('uses synchronous RBAC without obsolete callback SQS subscriptions in Initi
|
|
|
1030
1030
|
const initialSetupConfigContent = await readFile(
|
|
1031
1031
|
join(
|
|
1032
1032
|
rootPath,
|
|
1033
|
-
'app/
|
|
1033
|
+
'app/initial_setup/generatedCode/source/InitialSetupConfig.js'
|
|
1034
1034
|
),
|
|
1035
1035
|
'utf8'
|
|
1036
1036
|
);
|
|
@@ -1096,7 +1096,7 @@ test('deduplicates duplicate nextSteps topics across flowSteps in InitialSetupCo
|
|
|
1096
1096
|
const initialSetupConfigContent = await readFile(
|
|
1097
1097
|
join(
|
|
1098
1098
|
rootPath,
|
|
1099
|
-
'app/
|
|
1099
|
+
'app/initial_setup/generatedCode/source/InitialSetupConfig.js'
|
|
1100
1100
|
),
|
|
1101
1101
|
'utf8'
|
|
1102
1102
|
);
|
|
@@ -1275,7 +1275,7 @@ test('renders previousSteps extTopic subscriptions in InitialSetupConfig', async
|
|
|
1275
1275
|
const initialSetupConfigContent = await readFile(
|
|
1276
1276
|
join(
|
|
1277
1277
|
rootPath,
|
|
1278
|
-
'app/
|
|
1278
|
+
'app/initial_setup/generatedCode/source/InitialSetupConfig.js'
|
|
1279
1279
|
),
|
|
1280
1280
|
'utf8'
|
|
1281
1281
|
);
|
|
@@ -1537,7 +1537,7 @@ test('does not emit RbacCallback artifacts or duplicate artifact paths for custo
|
|
|
1537
1537
|
const initialSetupConfigContent = await readFile(
|
|
1538
1538
|
join(
|
|
1539
1539
|
rootPath,
|
|
1540
|
-
'app/
|
|
1540
|
+
'app/initial_setup/generatedCode/source/InitialSetupConfig.js'
|
|
1541
1541
|
),
|
|
1542
1542
|
'utf8'
|
|
1543
1543
|
);
|