@izara_project/izara-core-generate-service-code 1.0.91 → 1.0.92

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.
Files changed (30) hide show
  1. package/package.json +7 -10
  2. package/src/compile/flowValidator.js +6 -0
  3. package/src/compile/loadSchemas.js +177 -69
  4. package/src/emit/crud/generateCrudApplicationArtifacts.js +15 -17
  5. package/src/emit/crud/generateDynamicCrudFlowSchemas.js +16 -21
  6. package/src/emit/crud/loadLocalSchemaArrays.js +4 -8
  7. package/src/emit/custom/customFlowPaths.js +149 -0
  8. package/src/emit/custom/customFlowS3.js +156 -0
  9. package/src/emit/custom/customFlowSteps.js +385 -0
  10. package/src/emit/custom/customFlowTemplates.js +28 -0
  11. package/src/emit/custom/customFlows.js +48 -19
  12. package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +57 -692
  13. package/src/emit/custom/generateCustomFlowApplicationArtifacts.js +27 -25
  14. package/src/emit/rbac/generateCreateTargetRoleHandler.js +11 -13
  15. package/src/emit/rbac/generateDynamicRbacFlowSchemas.js +14 -18
  16. package/src/emit/relationship/generateDynamicRelationshipFlowSchemas.js +16 -19
  17. package/src/emit/relationship/generateRelationshipApplicationArtifacts.js +19 -19
  18. package/src/emit/resource/dynamoResourceArtifacts.js +18 -0
  19. package/src/emit/resource/emitResourceArtifacts.js +13 -1247
  20. package/src/emit/resource/generateResourceArtifacts.js +20 -20
  21. package/src/emit/resource/iamResourceArtifacts.js +612 -0
  22. package/src/emit/resource/resourceState.js +564 -0
  23. package/src/emit/resource/resourceTemplate.js +30 -0
  24. package/src/emit/resource/s3ResourceArtifacts.js +14 -0
  25. package/src/emit/resource/sqsResourceArtifacts.js +113 -0
  26. package/src/emit/shared/runSubsystemGeneration.js +55 -0
  27. package/src/emit/system/emitSystemWebSocketArtifacts.js +2 -1
  28. package/test/crudApplicationArtifacts.test.js +72 -0
  29. package/test/customFlowApplicationArtifacts.test.js +98 -0
  30. 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
- typeof flow?.flowTag === 'string' &&
18
- flow.flowTag !== '' &&
19
- (!flow.generatedCodeConfig ||
20
- (flow.generatedCodeConfig.codeHookTag &&
21
- !flow.event.includes('ownTopic'))) &&
22
- Array.isArray(flow.event) &&
23
- flow.event.some((event) => SUPPORTED_EVENTS.has(event))
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
- typeof flow?.flowTag === 'string' &&
122
- flow.flowTag !== '' &&
123
- flow.generatedCodeConfig &&
124
- Array.isArray(flow.event) &&
125
- flow.event.includes('ownTopic')
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) {