@izara_project/izara-core-generate-service-code 1.0.91 → 1.0.93
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 +7 -10
- package/src/compile/flowValidator.js +6 -0
- package/src/compile/loadSchemas.js +195 -69
- package/src/emit/coreFunction/templates/UploadSchema_Main.ejs +2 -2
- package/src/emit/crud/generateCrudApplicationArtifacts.js +15 -17
- package/src/emit/crud/generateDynamicCrudFlowSchemas.js +16 -21
- package/src/emit/crud/loadLocalSchemaArrays.js +4 -8
- package/src/emit/custom/customFlowPaths.js +149 -0
- package/src/emit/custom/customFlowS3.js +156 -0
- package/src/emit/custom/customFlowSteps.js +385 -0
- package/src/emit/custom/customFlowTemplates.js +28 -0
- package/src/emit/custom/customFlows.js +48 -19
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +57 -692
- package/src/emit/custom/generateCustomFlowApplicationArtifacts.js +27 -25
- package/src/emit/error/emitErrorSchemas.js +73 -0
- package/src/emit/error/templates/errorSchema.ejs +8 -0
- package/src/emit/rbac/generateCreateTargetRoleHandler.js +11 -13
- package/src/emit/rbac/generateDynamicRbacFlowSchemas.js +14 -18
- package/src/emit/relationship/generateDynamicRelationshipFlowSchemas.js +16 -19
- package/src/emit/relationship/generateRelationshipApplicationArtifacts.js +19 -19
- package/src/emit/resource/dynamoResourceArtifacts.js +18 -0
- package/src/emit/resource/emitResourceArtifacts.js +13 -1247
- package/src/emit/resource/generateResourceArtifacts.js +20 -20
- package/src/emit/resource/iamResourceArtifacts.js +612 -0
- package/src/emit/resource/resourceState.js +564 -0
- package/src/emit/resource/resourceTemplate.js +30 -0
- package/src/emit/resource/s3ResourceArtifacts.js +14 -0
- package/src/emit/resource/sqsResourceArtifacts.js +113 -0
- package/src/emit/shared/runSubsystemGeneration.js +55 -0
- package/src/emit/system/emitSystemWebSocketArtifacts.js +2 -1
- package/src/generate.js +37 -4
- package/test/crudApplicationArtifacts.test.js +72 -0
- package/test/customFlowApplicationArtifacts.test.js +98 -0
- package/test/errorSchemas.test.js +154 -0
- package/test/publicApi.test.js +1 -1
- package/test/resourceArtifacts.test.js +99 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import ejsLib from 'ejs';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
|
|
4
|
+
const SHARED_TEMPLATE_URL = new URL('../shared/templates/', import.meta.url);
|
|
5
|
+
const CRUD_TEMPLATE_URL = new URL('../crud/templates/', import.meta.url);
|
|
6
|
+
const CUSTOM_TEMPLATE_URL = new URL('./templates/', import.meta.url);
|
|
7
|
+
|
|
8
|
+
export async function renderShared(templateName, data) {
|
|
9
|
+
const templatePath = new URL(templateName, SHARED_TEMPLATE_URL);
|
|
10
|
+
const templateContent = await readFile(templatePath, 'utf8');
|
|
11
|
+
return ejsLib.render(templateContent, data);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function renderCrudTemplate(templateName, data) {
|
|
15
|
+
const templatePath = new URL(templateName, CRUD_TEMPLATE_URL);
|
|
16
|
+
const templateContent = await readFile(templatePath, 'utf8');
|
|
17
|
+
return ejsLib.render(templateContent, data);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export async function renderDsq(templateName, data) {
|
|
21
|
+
return renderShared(templateName, data);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function renderCustom(templateName, data) {
|
|
25
|
+
const templatePath = new URL(templateName, CUSTOM_TEMPLATE_URL);
|
|
26
|
+
const templateContent = await readFile(templatePath, 'utf8');
|
|
27
|
+
return ejsLib.render(templateContent, data).replace(/\n$/, '');
|
|
28
|
+
}
|
|
@@ -5,23 +5,51 @@ const SUPPORTED_EVENTS = new Set([
|
|
|
5
5
|
'lambdaSyncApi',
|
|
6
6
|
'ownTopic',
|
|
7
7
|
's3',
|
|
8
|
-
'dsq'
|
|
8
|
+
'dsq',
|
|
9
|
+
'generateCode'
|
|
9
10
|
]);
|
|
10
11
|
|
|
11
12
|
export function supportedCustomFlows(flows) {
|
|
12
13
|
if (!Array.isArray(flows)) {
|
|
13
14
|
throw new TypeError('flows must be an array');
|
|
14
15
|
}
|
|
15
|
-
return flows.filter(
|
|
16
|
-
(flow)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
return flows.filter((flow) => {
|
|
17
|
+
if (typeof flow?.flowTag !== 'string' || flow.flowTag === '') {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
if (!Array.isArray(flow.event)) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
const hasSupportedEvent = flow.event.some((e) => SUPPORTED_EVENTS.has(e));
|
|
24
|
+
if (!hasSupportedEvent) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
if (flow.generatedCodeConfig) {
|
|
28
|
+
if (flowHasOwnTopic(flow)) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
if (!flow.generatedCodeConfig.codeHookTag) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return true;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function flowHasOwnTopic(flow) {
|
|
40
|
+
if (!Array.isArray(flow?.event)) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
if (flow.event.includes('ownTopic')) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
if (
|
|
47
|
+
flow.event.includes('generateCode') &&
|
|
48
|
+
flow?.generatedCodeConfig?.invocationType === 'ownTopic'
|
|
49
|
+
) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
25
53
|
}
|
|
26
54
|
|
|
27
55
|
export function customFlowRoleName(flowTag) {
|
|
@@ -116,14 +144,15 @@ export function generatedOwnTopicFlows(flows) {
|
|
|
116
144
|
if (!Array.isArray(flows)) {
|
|
117
145
|
throw new TypeError('flows must be an array');
|
|
118
146
|
}
|
|
119
|
-
return flows.filter(
|
|
120
|
-
(flow)
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
147
|
+
return flows.filter((flow) => {
|
|
148
|
+
if (typeof flow?.flowTag !== 'string' || flow.flowTag === '') {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
if (!flow.generatedCodeConfig) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
return flowHasOwnTopic(flow);
|
|
155
|
+
});
|
|
127
156
|
}
|
|
128
157
|
|
|
129
158
|
export function generatedDsqFlows(flows) {
|