@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.
Files changed (36) hide show
  1. package/package.json +7 -10
  2. package/src/compile/flowValidator.js +6 -0
  3. package/src/compile/loadSchemas.js +195 -69
  4. package/src/emit/coreFunction/templates/UploadSchema_Main.ejs +2 -2
  5. package/src/emit/crud/generateCrudApplicationArtifacts.js +15 -17
  6. package/src/emit/crud/generateDynamicCrudFlowSchemas.js +16 -21
  7. package/src/emit/crud/loadLocalSchemaArrays.js +4 -8
  8. package/src/emit/custom/customFlowPaths.js +149 -0
  9. package/src/emit/custom/customFlowS3.js +156 -0
  10. package/src/emit/custom/customFlowSteps.js +385 -0
  11. package/src/emit/custom/customFlowTemplates.js +28 -0
  12. package/src/emit/custom/customFlows.js +48 -19
  13. package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +57 -692
  14. package/src/emit/custom/generateCustomFlowApplicationArtifacts.js +27 -25
  15. package/src/emit/error/emitErrorSchemas.js +73 -0
  16. package/src/emit/error/templates/errorSchema.ejs +8 -0
  17. package/src/emit/rbac/generateCreateTargetRoleHandler.js +11 -13
  18. package/src/emit/rbac/generateDynamicRbacFlowSchemas.js +14 -18
  19. package/src/emit/relationship/generateDynamicRelationshipFlowSchemas.js +16 -19
  20. package/src/emit/relationship/generateRelationshipApplicationArtifacts.js +19 -19
  21. package/src/emit/resource/dynamoResourceArtifacts.js +18 -0
  22. package/src/emit/resource/emitResourceArtifacts.js +13 -1247
  23. package/src/emit/resource/generateResourceArtifacts.js +20 -20
  24. package/src/emit/resource/iamResourceArtifacts.js +612 -0
  25. package/src/emit/resource/resourceState.js +564 -0
  26. package/src/emit/resource/resourceTemplate.js +30 -0
  27. package/src/emit/resource/s3ResourceArtifacts.js +14 -0
  28. package/src/emit/resource/sqsResourceArtifacts.js +113 -0
  29. package/src/emit/shared/runSubsystemGeneration.js +55 -0
  30. package/src/emit/system/emitSystemWebSocketArtifacts.js +2 -1
  31. package/src/generate.js +37 -4
  32. package/test/crudApplicationArtifacts.test.js +72 -0
  33. package/test/customFlowApplicationArtifacts.test.js +98 -0
  34. package/test/errorSchemas.test.js +154 -0
  35. package/test/publicApi.test.js +1 -1
  36. package/test/resourceArtifacts.test.js +99 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-core-generate-service-code",
3
- "version": "1.0.91",
3
+ "version": "1.0.93",
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": {
@@ -13,28 +13,25 @@
13
13
  "exports": "./index.js",
14
14
  "main": "index.js",
15
15
  "scripts": {
16
- "test": "node --test",
17
- "format:ejs": "node scripts/format-ejs.js"
18
- },
19
- "jest": {
20
- "testEnvironment": "node"
16
+ "format:ejs": "node scripts/format-ejs.js",
17
+ "test": "node --test"
21
18
  },
22
19
  "dependencies": {
23
20
  "@izara_project/izara-attribute-tree": "^1.0.15",
24
- "@izara_project/izara-core-library-core": "^1.0.35",
21
+ "@izara_project/izara-core-library-core": "^1.0.37",
22
+ "@izara_project/izara-core-library-s3": "^1.0.12",
25
23
  "@izara_project/izara-property-nodes": "^1.0.16",
26
24
  "@izara_project/izara-shared-core": "^1.0.13",
27
25
  "ejs": "^6.0.1",
28
26
  "js-beautify": "^2.0.3",
29
27
  "ws": "^8.21.3",
30
- "yaml": "^2.9.0"
28
+ "yaml": "^2.9.1"
31
29
  },
32
30
  "devDependencies": {
33
31
  "@izara_project/izara-core-library-logger": "^1.0.11",
34
32
  "@izara_project/izara-core-library-service-schemas": "1.0.166",
35
33
  "@izara_project/izara-shared-service-schemas": "^1.0.74",
36
- "jest": "^30.4.2",
37
- "prettier": "^3.9.6",
34
+ "prettier": "^3.9.8",
38
35
  "prettier-plugin-ejs": "^1.0.3"
39
36
  },
40
37
  "peerDependencies": {
@@ -44,6 +44,12 @@ export function validateFlowSchema(flowSchema) {
44
44
  break;
45
45
  }
46
46
  }
47
+ if (
48
+ flowEvents.includes('generateCode') &&
49
+ flowSchema?.generatedCodeConfig?.invocationType === 'lambdaSyncInv'
50
+ ) {
51
+ hasSyncEvent = true;
52
+ }
47
53
 
48
54
  if (hasSyncEvent && steps.length > 1) {
49
55
  let flowTag = 'unknown';
@@ -16,20 +16,31 @@ const consoleLogger = {
16
16
  error: console.error
17
17
  };
18
18
 
19
- const VALID_INITIATE_BY_ENUM = [
20
- 'user',
21
- 'systemWithUser',
22
- 'systemNoUser'
19
+ const VALID_INITIATE_BY_ENUM = ['user', 'systemWithUser', 'systemNoUser'];
20
+ const VALID_EVENT_ENUM = [
21
+ 'ownTopic',
22
+ 'extTopic',
23
+ 's3',
24
+ 'eventBridge',
25
+ 'lambdaSyncInv',
26
+ 'lambdaSyncApi',
27
+ 'dsq',
28
+ 'generateCode'
23
29
  ];
24
-
25
30
  const VALID_CODE_HOOK_TAG_ENUM = ['before', 'after'];
26
31
  const VALID_GENERATE_CODE_TAG_ENUM = ['create', 'update', 'delete'];
32
+ const VALID_INVOCATION_TYPE_ENUM = ['ownTopic', 'lambdaSyncInv'];
27
33
 
28
34
  if (basicValidatorSchema?.basicFlowSchema?.properties?.initiateBy) {
29
35
  basicValidatorSchema.basicFlowSchema.properties.initiateBy.enum =
30
36
  VALID_INITIATE_BY_ENUM;
31
37
  }
32
38
 
39
+ if (basicValidatorSchema?.basicFlowSchema?.properties?.event?.items) {
40
+ basicValidatorSchema.basicFlowSchema.properties.event.items.enum =
41
+ VALID_EVENT_ENUM;
42
+ }
43
+
33
44
  if (
34
45
  basicValidatorSchema?.basicFlowSchema?.properties?.generatedCodeConfig
35
46
  ?.properties?.codeHookTag
@@ -38,48 +49,58 @@ if (
38
49
  VALID_CODE_HOOK_TAG_ENUM;
39
50
  }
40
51
 
52
+ if (
53
+ basicValidatorSchema?.basicFlowSchema?.properties?.generatedCodeConfig
54
+ ?.properties?.invocationType
55
+ ) {
56
+ basicValidatorSchema.basicFlowSchema.properties.generatedCodeConfig.properties.invocationType.enum =
57
+ VALID_INVOCATION_TYPE_ENUM;
58
+ }
59
+
41
60
  if (
42
61
  basicValidatorSchema?.basicFlowSchema?.properties?.generatedCodeConfig
43
62
  ?.properties?.generateCodeTag
44
63
  ) {
45
- basicValidatorSchema.basicFlowSchema.properties.generatedCodeConfig.properties.generateCodeTag = {
46
- anyOf: [
47
- {
48
- type: 'array',
49
- items: {
64
+ basicValidatorSchema.basicFlowSchema.properties.generatedCodeConfig.properties.generateCodeTag =
65
+ {
66
+ anyOf: [
67
+ {
68
+ type: 'array',
69
+ items: {
70
+ type: 'string',
71
+ enum: VALID_GENERATE_CODE_TAG_ENUM
72
+ }
73
+ },
74
+ {
50
75
  type: 'string',
51
76
  enum: VALID_GENERATE_CODE_TAG_ENUM
52
77
  }
53
- },
54
- {
55
- type: 'string',
56
- enum: VALID_GENERATE_CODE_TAG_ENUM
57
- }
58
- ]
59
- };
78
+ ]
79
+ };
60
80
  }
61
81
 
62
82
  if (
63
83
  basicValidatorSchema?.basicFlowSchema?.properties?.generatedCodeConfig
64
84
  ?.properties
65
85
  ) {
66
- basicValidatorSchema.basicFlowSchema.properties.generatedCodeConfig.properties.objType = {
67
- anyOf: [
68
- { type: 'string' },
69
- {
70
- type: 'array',
71
- items: { type: 'string' }
72
- },
73
- {
74
- type: 'object',
75
- properties: {
76
- objectType: { type: 'string' },
77
- serviceTag: { type: 'string' }
86
+ basicValidatorSchema.basicFlowSchema.properties.generatedCodeConfig.properties.objType =
87
+ {
88
+ anyOf: [
89
+ { type: 'string' },
90
+ {
91
+ type: 'array',
92
+ items: { type: 'string' }
78
93
  },
79
- required: ['objectType']
80
- }
81
- ]
82
- };
94
+ {
95
+ type: 'object',
96
+ properties: {
97
+ objectType: { type: 'string' },
98
+ serviceTag: { type: 'string' }
99
+ },
100
+ required: ['objectType']
101
+ }
102
+ ]
103
+ };
83
104
  }
84
105
 
85
106
  const VALID_GENERATED_BY_ENUM = [
@@ -165,9 +186,60 @@ export async function loadLocalSchemaDirectory(
165
186
  );
166
187
  if (loadedSchemas.length === 0) continue;
167
188
 
189
+ if (directoryName === 'ErrorSchemas') {
190
+ for (const schema of loadedSchemas) {
191
+ if (!schema._sourceFile) {
192
+ schema._sourceFile = entry.name;
193
+ }
194
+ if (!schema.errorTag || typeof schema.errorTag !== 'string') {
195
+ throw new Error(
196
+ `Invalid ErrorSchema in ${entry.name}: errorTag is required and must be a non-empty string`
197
+ );
198
+ }
199
+ if (!schema.errorAction || typeof schema.errorAction !== 'string') {
200
+ throw new Error(
201
+ `Invalid ErrorSchema in ${entry.name}: errorAction is required and must be a non-empty string`
202
+ );
203
+ }
204
+ }
205
+ }
206
+
168
207
  if (directoryName === 'FlowSchemas') {
169
208
  for (const schema of loadedSchemas) {
170
- if (Object.prototype.hasOwnProperty.call(schema?.generatedCodeConfig ?? {}, 'codeHookTag')) {
209
+ if (
210
+ Array.isArray(schema?.event) &&
211
+ schema.event.includes('generateCode') &&
212
+ !schema.generatedCodeConfig
213
+ ) {
214
+ throw new Error(
215
+ `Unsupported FlowHook configuration in ${entry.name}: ` +
216
+ `flow with event 'generateCode' requires generatedCodeConfig`
217
+ );
218
+ }
219
+ if (
220
+ Object.prototype.hasOwnProperty.call(
221
+ schema?.generatedCodeConfig ?? {},
222
+ 'invocationType'
223
+ )
224
+ ) {
225
+ const invType = schema.generatedCodeConfig.invocationType;
226
+ if (
227
+ typeof invType !== 'string' ||
228
+ !VALID_INVOCATION_TYPE_ENUM.includes(invType)
229
+ ) {
230
+ throw new Error(
231
+ `Unsupported FlowHook configuration in ${entry.name}: ` +
232
+ `generatedCodeConfig.invocationType '${invType}' is invalid. ` +
233
+ `Must be 'ownTopic' or 'lambdaSyncInv'`
234
+ );
235
+ }
236
+ }
237
+ if (
238
+ Object.prototype.hasOwnProperty.call(
239
+ schema?.generatedCodeConfig ?? {},
240
+ 'codeHookTag'
241
+ )
242
+ ) {
171
243
  const hookTag = schema.generatedCodeConfig.codeHookTag;
172
244
  if (hookTag === 'beforeLogical') {
173
245
  throw new Error(
@@ -191,7 +263,7 @@ export async function loadLocalSchemaDirectory(
191
263
  if (codeTag.length === 0) {
192
264
  throw new Error(
193
265
  `Unsupported FlowHook configuration in ${entry.name}: ` +
194
- `generatedCodeConfig.generateCodeTag array must not be empty`
266
+ `generatedCodeConfig.generateCodeTag array must not be empty`
195
267
  );
196
268
  }
197
269
  for (const tag of codeTag) {
@@ -201,8 +273,8 @@ export async function loadLocalSchemaDirectory(
201
273
  ) {
202
274
  throw new Error(
203
275
  `Unsupported FlowHook configuration in ${entry.name}: ` +
204
- `generatedCodeConfig.generateCodeTag contains invalid ` +
205
- `tag '${tag}'. Must be 'create', 'update', or 'delete'`
276
+ `generatedCodeConfig.generateCodeTag contains invalid ` +
277
+ `tag '${tag}'. Must be 'create', 'update', or 'delete'`
206
278
  );
207
279
  }
208
280
  }
@@ -210,14 +282,14 @@ export async function loadLocalSchemaDirectory(
210
282
  if (!VALID_GENERATE_CODE_TAG_ENUM.includes(codeTag.toLowerCase())) {
211
283
  throw new Error(
212
284
  `Unsupported FlowHook configuration in ${entry.name}: ` +
213
- `generatedCodeConfig.generateCodeTag '${codeTag}' ` +
214
- `is invalid. Must be 'create', 'update', or 'delete'`
285
+ `generatedCodeConfig.generateCodeTag '${codeTag}' ` +
286
+ `is invalid. Must be 'create', 'update', or 'delete'`
215
287
  );
216
288
  }
217
289
  } else {
218
290
  throw new Error(
219
291
  `Unsupported FlowHook configuration in ${entry.name}: ` +
220
- `generatedCodeConfig.generateCodeTag must be an array or string`
292
+ `generatedCodeConfig.generateCodeTag must be an array or string`
221
293
  );
222
294
  }
223
295
  }
@@ -232,7 +304,7 @@ export async function loadLocalSchemaDirectory(
232
304
  if (hookObjType.length === 0) {
233
305
  throw new Error(
234
306
  `Unsupported FlowHook configuration in ${entry.name}: ` +
235
- `generatedCodeConfig.objType array must not be empty`
307
+ `generatedCodeConfig.objType array must not be empty`
236
308
  );
237
309
  }
238
310
  for (const item of hookObjType) {
@@ -240,7 +312,7 @@ export async function loadLocalSchemaDirectory(
240
312
  if (!strVal || typeof strVal !== 'string') {
241
313
  throw new Error(
242
314
  `Unsupported FlowHook configuration in ${entry.name}: ` +
243
- `generatedCodeConfig.objType array items must be non-empty strings or objects with objectType`
315
+ `generatedCodeConfig.objType array items must be non-empty strings or objects with objectType`
244
316
  );
245
317
  }
246
318
  }
@@ -251,7 +323,7 @@ export async function loadLocalSchemaDirectory(
251
323
  ) {
252
324
  throw new Error(
253
325
  `Unsupported FlowHook configuration in ${entry.name}: ` +
254
- `generatedCodeConfig.objType object must have string property objectType`
326
+ `generatedCodeConfig.objType object must have string property objectType`
255
327
  );
256
328
  }
257
329
  } else if (
@@ -260,7 +332,7 @@ export async function loadLocalSchemaDirectory(
260
332
  ) {
261
333
  throw new Error(
262
334
  `Unsupported FlowHook configuration in ${entry.name}: ` +
263
- `generatedCodeConfig.objType must be a non-empty string, array, or object`
335
+ `generatedCodeConfig.objType must be a non-empty string, array, or object`
264
336
  );
265
337
  }
266
338
  }
@@ -276,20 +348,20 @@ export async function loadLocalSchemaDirectory(
276
348
  let errors = [];
277
349
 
278
350
  if (directoryName === 'ObjectSchemas') {
279
- [status, errors] = utils.validateObjectSchema(
280
- { logger },
281
- schema
282
- );
351
+ [status, errors] = utils.validateObjectSchema({ logger }, schema);
283
352
  if (!status && Array.isArray(errors)) {
284
- errors = errors.filter(
285
- (err) => !err.includes('billalble')
286
- );
353
+ errors = errors.filter((err) => !err.includes('billalble'));
287
354
  if (VALID_GENERATED_BY_ENUM.includes(schema?.generatedBy)) {
288
355
  errors = errors.filter(
289
356
  (err) =>
290
357
  !err.includes('generatedBy') &&
291
- !err.includes('must be equal to one of the allowed values (enum)') &&
292
- !(err.includes('should be one of enum') && err.includes(schema?.generatedBy))
358
+ !err.includes(
359
+ 'must be equal to one of the allowed values (enum)'
360
+ ) &&
361
+ !(
362
+ err.includes('should be one of enum') &&
363
+ err.includes(schema?.generatedBy)
364
+ )
293
365
  );
294
366
  }
295
367
  if (errors.length === 0) {
@@ -308,29 +380,73 @@ export async function loadLocalSchemaDirectory(
308
380
  schema
309
381
  );
310
382
  }
311
- if (!status && Array.isArray(errors) && VALID_GENERATED_BY_ENUM.includes(schema?.generatedBy)) {
383
+ if (
384
+ !status &&
385
+ Array.isArray(errors) &&
386
+ VALID_GENERATED_BY_ENUM.includes(schema?.generatedBy)
387
+ ) {
312
388
  errors = errors.filter(
313
389
  (err) =>
314
390
  !err.includes('generatedBy') &&
315
- !err.includes('must be equal to one of the allowed values (enum)') &&
316
- !(err.includes('should be one of enum') && err.includes(schema?.generatedBy))
391
+ !err.includes(
392
+ 'must be equal to one of the allowed values (enum)'
393
+ ) &&
394
+ !(
395
+ err.includes('should be one of enum') &&
396
+ err.includes(schema?.generatedBy)
397
+ )
317
398
  );
318
399
  if (errors.length === 0) {
319
400
  status = true;
320
401
  }
321
402
  }
322
403
  } else if (directoryName === 'FlowSchemas') {
323
- [status, errors] = utils.validateBasicFlowSchema(
324
- { logger },
325
- schema
326
- );
404
+ [status, errors] = utils.validateBasicFlowSchema({ logger }, schema);
327
405
  if (!status && Array.isArray(errors)) {
328
406
  if (VALID_INITIATE_BY_ENUM.includes(schema?.initiateBy)) {
329
407
  errors = errors.filter(
330
408
  (err) =>
331
409
  !err.includes('initiateBy') &&
332
- !err.includes('must be equal to one of the allowed values (enum)') &&
333
- !(err.includes('should be one of enum') && err.includes(schema?.initiateBy))
410
+ !err.includes(
411
+ 'must be equal to one of the allowed values (enum)'
412
+ ) &&
413
+ !(
414
+ err.includes('should be one of enum') &&
415
+ err.includes(schema?.initiateBy)
416
+ )
417
+ );
418
+ }
419
+ if (
420
+ Array.isArray(schema?.event) &&
421
+ schema.event.every((e) => VALID_EVENT_ENUM.includes(e))
422
+ ) {
423
+ errors = errors.filter(
424
+ (err) =>
425
+ !err.includes('event') &&
426
+ !err.includes(
427
+ 'must be equal to one of the allowed values (enum)'
428
+ ) &&
429
+ !(
430
+ err.includes('should be one of enum') &&
431
+ schema.event.some((e) => err.includes(e))
432
+ )
433
+ );
434
+ }
435
+ if (
436
+ VALID_INVOCATION_TYPE_ENUM.includes(
437
+ schema?.generatedCodeConfig?.invocationType
438
+ )
439
+ ) {
440
+ errors = errors.filter(
441
+ (err) =>
442
+ !err.includes('invocationType') &&
443
+ !err.includes(
444
+ 'must be equal to one of the allowed values (enum)'
445
+ ) &&
446
+ !(
447
+ err.includes('should be one of enum') &&
448
+ err.includes(schema?.generatedCodeConfig?.invocationType)
449
+ )
334
450
  );
335
451
  }
336
452
  if (
@@ -341,7 +457,9 @@ export async function loadLocalSchemaDirectory(
341
457
  errors = errors.filter(
342
458
  (err) =>
343
459
  !err.includes('codeHookTag') &&
344
- !err.includes('must be equal to one of the allowed values (enum)') &&
460
+ !err.includes(
461
+ 'must be equal to one of the allowed values (enum)'
462
+ ) &&
345
463
  !(
346
464
  err.includes('should be one of enum') &&
347
465
  err.includes(schema?.generatedCodeConfig?.codeHookTag)
@@ -398,6 +516,14 @@ export async function loadLocalSchemaDirectory(
398
516
  return schemas;
399
517
  }
400
518
 
519
+ export async function loadLocalSchemaArrays(project, options = {}) {
520
+ const [objects, flows] = await Promise.all([
521
+ loadLocalSchemaDirectory(project, 'ObjectSchemas', options),
522
+ loadLocalSchemaDirectory(project, 'FlowSchemas', options)
523
+ ]);
524
+ return { objects, flows };
525
+ }
526
+
401
527
  /**
402
528
  * Resolves extendObjType for ObjectSchemas by fetching the parent schema
403
529
  * from S3 and merging its storageResources into the child schema.
@@ -426,7 +552,7 @@ export async function resolveExtendedObjectSchemas(
426
552
  try {
427
553
  console.log(
428
554
  `[DEBUG] [resolveExtendedObjectSchemas] Merging extendObjType ` +
429
- `for objectType=${currentSchema.objectType}`,
555
+ `for objectType=${currentSchema.objectType}`,
430
556
  { extendObjType: currentSchema.extendObjType }
431
557
  );
432
558
  const initialResources = currentSchema.storageResources || {};
@@ -468,7 +594,7 @@ export async function resolveExtendedObjectSchemas(
468
594
  } catch (error) {
469
595
  console.log(
470
596
  `[ERROR] [resolveExtendedObjectSchemas] Failed to merge ` +
471
- `extendObjType for objectType=${currentSchema.objectType}`,
597
+ `extendObjType for objectType=${currentSchema.objectType}`,
472
598
  { error }
473
599
  );
474
600
  throw error;
@@ -488,7 +614,7 @@ export async function resolveExtendedObjectSchemas(
488
614
  try {
489
615
  console.log(
490
616
  `[DEBUG] [resolveExtendedObjectSchemas] Fetching belongTo ` +
491
- `schema for objectType=${currentSchema.objectType}`,
617
+ `schema for objectType=${currentSchema.objectType}`,
492
618
  { belongTo: belongToTarget }
493
619
  );
494
620
  const belongToObjType = {
@@ -504,13 +630,13 @@ export async function resolveExtendedObjectSchemas(
504
630
  currentSchema.belongToSchema = belongToSchema;
505
631
  console.log(
506
632
  `[DEBUG] [resolveExtendedObjectSchemas] Successfully fetched ` +
507
- `belongTo schema for objectType=${currentSchema.objectType}`,
633
+ `belongTo schema for objectType=${currentSchema.objectType}`,
508
634
  { belongToObjectType: belongToSchema?.objectType }
509
635
  );
510
636
  } catch (error) {
511
637
  console.log(
512
638
  `[WARN] [resolveExtendedObjectSchemas] Failed to fetch ` +
513
- `belongTo schema for objectType=${currentSchema.objectType}`,
639
+ `belongTo schema for objectType=${currentSchema.objectType}`,
514
640
  { error }
515
641
  );
516
642
  }
@@ -572,7 +698,7 @@ export async function resolveGraphServiceTags(
572
698
  } catch (error) {
573
699
  console.log(
574
700
  `[DEBUG] [resolveGraphServiceTags] Could not fetch ` +
575
- `GraphServerTags.json from bucket=${bucketName}`,
701
+ `GraphServerTags.json from bucket=${bucketName}`,
576
702
  error
577
703
  );
578
704
  }
@@ -15,7 +15,7 @@ You should have received a copy of the GNU Affero General Public License
15
15
  along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
 
18
- import { uploadObjSchema } from '@izara_project/izara-core-library-service-schemas';
18
+ import initialSetupSharedLib from '@izara_project/izara-core-library-initial-setup';
19
19
 
20
20
  const SERVICE_TAG = {
21
21
  TRANSLATIONS: 'Translations',
@@ -39,7 +39,7 @@ const uploadSchema = async (_izContext) => {
39
39
  try {
40
40
  _izContext.logger.debug('uploadSchema _izContext: ', _izContext);
41
41
 
42
- await uploadObjSchema.uploadObjectSchemaByUseCase(_izContext, {
42
+ await initialSetupSharedLib.uploadObjectSchema(_izContext, {
43
43
  ignoreExternalServices: ignoreExternalServices
44
44
  });
45
45
  return 'upload successfully';
@@ -1,25 +1,23 @@
1
- import { buildGenerationPlan } from '../../plan/buildGenerationPlan.js';
2
- import { commitArtifacts } from '../../output/commitArtifacts.js';
3
- import { compileProject } from '../../compile/compileProject.js';
4
- import { loadLocalSchemaArrays } from './loadLocalSchemaArrays.js';
1
+ import { loadLocalSchemaArrays } from '../../compile/loadSchemas.js';
2
+ import { runSubsystemGeneration } from '../shared/runSubsystemGeneration.js';
5
3
  import {
6
4
  crudApplicationManagedPaths,
7
5
  emitCrudApplicationArtifacts
8
6
  } from './emitCrudApplicationArtifacts.js';
9
7
 
10
8
  export async function generateCrudApplicationArtifacts(rootPath, options = {}) {
11
- const project = compileProject({ ...options, rootPath });
12
- const schemas = await loadLocalSchemaArrays(project, options);
13
- const artifacts = await emitCrudApplicationArtifacts({
14
- ...schemas,
15
- serviceTag: project.serviceTag,
16
- logger: options.logger
9
+ return await runSubsystemGeneration({
10
+ rootPath,
11
+ options,
12
+ loadInputs: (project, opt) => loadLocalSchemaArrays(project, opt),
13
+ emitArtifacts: ({ objects, flows, project, options: opt }) =>
14
+ emitCrudApplicationArtifacts({
15
+ objects,
16
+ flows,
17
+ serviceTag: project.serviceTag,
18
+ logger: opt.logger
19
+ }),
20
+ managedScope: 'crud-application',
21
+ resolveManagedPaths: () => crudApplicationManagedPaths()
17
22
  });
18
- const files = await commitArtifacts(
19
- buildGenerationPlan(project, artifacts, {
20
- managedPaths: crudApplicationManagedPaths(),
21
- managedScope: 'crud-application'
22
- })
23
- );
24
- return { project, files };
25
23
  }
@@ -1,28 +1,23 @@
1
- import { buildGenerationPlan } from '../../plan/buildGenerationPlan.js';
2
- import { commitArtifacts } from '../../output/commitArtifacts.js';
3
- import { compileProject } from '../../compile/compileProject.js';
1
+ import { loadLocalSchemaArrays } from '../../compile/loadSchemas.js';
2
+ import { runSubsystemGeneration } from '../shared/runSubsystemGeneration.js';
4
3
  import {
5
4
  dynamicCrudFlowSchemaPaths,
6
5
  emitDynamicCrudFlowSchemas
7
6
  } from './emitDynamicCrudFlowSchemas.js';
8
- import { loadLocalSchemaArrays } from './loadLocalSchemaArrays.js';
9
7
 
10
8
  export async function generateDynamicCrudFlowSchemas(rootPath, options = {}) {
11
- const project = compileProject({ ...options, rootPath });
12
- const schemaInputs = await loadLocalSchemaArrays(project, options);
13
- const plan = buildGenerationPlan(
14
- project,
15
- emitDynamicCrudFlowSchemas({
16
- ...schemaInputs,
17
- serviceTag: project.serviceTag,
18
- logger: options.logger
19
- }),
20
- {
21
- managedPaths: dynamicCrudFlowSchemaPaths,
22
- managedScope: 'crud-flow-schemas'
23
- }
24
- );
25
- const files = await commitArtifacts(plan);
26
-
27
- return { project, files };
9
+ return await runSubsystemGeneration({
10
+ rootPath,
11
+ options,
12
+ loadInputs: (project, opt) => loadLocalSchemaArrays(project, opt),
13
+ emitArtifacts: ({ objects, flows, project, options: opt }) =>
14
+ emitDynamicCrudFlowSchemas({
15
+ objects,
16
+ flows,
17
+ serviceTag: project.serviceTag,
18
+ logger: opt.logger
19
+ }),
20
+ managedScope: 'crud-flow-schemas',
21
+ resolveManagedPaths: dynamicCrudFlowSchemaPaths
22
+ });
28
23
  }
@@ -1,8 +1,4 @@
1
- import { loadLocalSchemaDirectory } from '../../compile/loadSchemas.js';
2
-
3
- export async function loadLocalSchemaArrays(project, options = {}) {
4
- return {
5
- objects: await loadLocalSchemaDirectory(project, 'ObjectSchemas', options),
6
- flows: await loadLocalSchemaDirectory(project, 'FlowSchemas', options)
7
- };
8
- }
1
+ /**
2
+ * @deprecated Use `loadLocalSchemaArrays` from `../../compile/loadSchemas.js` instead.
3
+ */
4
+ export { loadLocalSchemaArrays } from '../../compile/loadSchemas.js';