@domain-first/project-structure 1.2.0 → 2.0.0
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/dist/index.cjs +158 -169
- package/dist/index.js +158 -169
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -282,41 +282,26 @@ export class ${naming.ClassName}${aggregateNaming.ClassName}Repository implement
|
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
`.trim());
|
|
285
|
-
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
286
|
-
const wiringFolder = boundedContextFolder.subitem([
|
|
287
|
-
'wiring',
|
|
288
|
-
'infrastructure',
|
|
289
|
-
'repositories',
|
|
290
|
-
naming.fileName
|
|
291
|
-
]);
|
|
292
|
-
wiringFolder.createFile(`wire-${naming.fileName}-${aggregateNaming.fileName}-repository.ts`, `
|
|
293
|
-
import { wireClass } from '@domain-first/wire'
|
|
294
|
-
import { ${naming.ClassName}${aggregateNaming.ClassName}Repository } from '../../../../infrastructure/repositories/${naming.fileName}/${naming.fileName}-${aggregateNaming.fileName}-repository'
|
|
295
|
-
|
|
296
|
-
export const wire${naming.ClassName}${aggregateNaming.ClassName}Repository = wireClass(
|
|
297
|
-
${naming.ClassName}${aggregateNaming.ClassName}Repository,
|
|
298
|
-
[]
|
|
299
|
-
)
|
|
300
|
-
`.trim());
|
|
301
|
-
}
|
|
302
285
|
}
|
|
303
286
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
304
287
|
const implementationNaming = new UnknownFormatNaming(infrastructureImplementationType);
|
|
305
288
|
const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
|
|
306
289
|
boundedContextFolder.subitem([
|
|
307
290
|
'wiring',
|
|
308
|
-
'domain',
|
|
309
291
|
'repositories'
|
|
310
292
|
]).createFile(`wire-${aggregateNaming.fileName}-repository.ts`, `
|
|
311
|
-
import {
|
|
312
|
-
|
|
293
|
+
import { wireClass } from '@domain-first/wire'
|
|
294
|
+
import { envBranchedWire } from '../../../../shared/wiring/env-branched-wire'
|
|
295
|
+
${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { ${ClassName}${aggregateNaming.ClassName}Repository } from '../../infrastructure/repositories/${fileName}/${fileName}-${aggregateNaming.fileName}-repository'`).join('\n')}
|
|
296
|
+
|
|
297
|
+
${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName })=>`const wire${ClassName}Implementation = wireClass(${ClassName}${aggregateNaming.ClassName}Repository, [])`).join('\n\n')}
|
|
313
298
|
|
|
314
299
|
export const wire${aggregateNaming.ClassName}Repository = envBranchedWire({
|
|
315
|
-
test: wire${addTestImplementation ? testImplementationNaming.ClassName : implementationNaming.ClassName}
|
|
316
|
-
development: wire${implementationNaming.ClassName}
|
|
317
|
-
production: wire${implementationNaming.ClassName}
|
|
300
|
+
test: wire${addTestImplementation ? testImplementationNaming.ClassName : implementationNaming.ClassName}Implementation,
|
|
301
|
+
development: wire${implementationNaming.ClassName}Implementation,
|
|
302
|
+
production: wire${implementationNaming.ClassName}Implementation
|
|
318
303
|
})
|
|
319
|
-
`.trim());
|
|
304
|
+
`.trim());
|
|
320
305
|
}
|
|
321
306
|
}
|
|
322
307
|
};
|
|
@@ -327,14 +312,8 @@ const scaffoldNewApplicationPort = async (boundedContextFolder)=>{
|
|
|
327
312
|
const naming = new UnknownFormatNaming(name);
|
|
328
313
|
const wiringFolder = boundedContextFolder.subitem([
|
|
329
314
|
'wiring',
|
|
330
|
-
'application',
|
|
331
315
|
'ports'
|
|
332
316
|
]);
|
|
333
|
-
const infraFolder = boundedContextFolder.subitem([
|
|
334
|
-
'wiring',
|
|
335
|
-
'infrastructure',
|
|
336
|
-
'application-ports'
|
|
337
|
-
]);
|
|
338
317
|
const applicationPortsFolder = boundedContextFolder.subitem([
|
|
339
318
|
'application',
|
|
340
319
|
'ports'
|
|
@@ -374,29 +353,24 @@ export class ${currentNaming.ClassName} extends ${naming.ClassName} {
|
|
|
374
353
|
|
|
375
354
|
}
|
|
376
355
|
`);
|
|
377
|
-
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) infraFolder.subitem([
|
|
378
|
-
implementation
|
|
379
|
-
]).createFile(`wire-${currentNaming.fileName}.ts`, `
|
|
380
|
-
import { wireClass } from '@domain-first/wire'
|
|
381
|
-
import { ${currentNaming.ClassName} } from '../../../../infrastructure/application-adapters/${implementation}/${currentNaming.fileName}'
|
|
382
|
-
|
|
383
|
-
export const wire${currentNaming.ClassName} = wireClass(
|
|
384
|
-
${currentNaming.ClassName},
|
|
385
|
-
[]
|
|
386
|
-
)
|
|
387
|
-
`.trim());
|
|
388
356
|
}
|
|
389
357
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) wiringFolder.createFile(`wire-${naming.fileName}.ts`, `
|
|
390
|
-
import {
|
|
358
|
+
import { wireClass } from '@domain-first/wire'
|
|
359
|
+
import { envBranchedWire } from '../../../${'shared' === boundedContextFolder.name ? '' : '../'}shared/wiring/env-branched-wire'
|
|
360
|
+
${implementationTypes.map((x)=>({
|
|
361
|
+
naming: new UnknownFormatNaming(`${x}-${naming.fileName}`),
|
|
362
|
+
implementation: x
|
|
363
|
+
})).map(({ naming: { ClassName, fileName }, implementation })=>`import { ${ClassName} } from '../../infrastructure/application-adapters/${implementation}/${fileName}'`).join('\n')}
|
|
364
|
+
|
|
391
365
|
${implementationTypes.map((x)=>({
|
|
392
366
|
naming: new UnknownFormatNaming(`${x}-${naming.fileName}`),
|
|
393
367
|
implementation: x
|
|
394
|
-
})).map(({ naming: { ClassName
|
|
368
|
+
})).map(({ naming: { ClassName }, implementation })=>`const wire${new UnknownFormatNaming(implementation).ClassName}Implementation = wireClass(${ClassName}, [])`).join('\n\n')}
|
|
395
369
|
|
|
396
370
|
export const wire${naming.ClassName} = envBranchedWire({
|
|
397
|
-
test: wire${new UnknownFormatNaming(`${implementationTypes.at(-1)}
|
|
398
|
-
development: wire${new UnknownFormatNaming(`${implementationTypes.at(0)}
|
|
399
|
-
production: wire${new UnknownFormatNaming(`${implementationTypes.at(0)}
|
|
371
|
+
test: wire${new UnknownFormatNaming(`${implementationTypes.at(-1)}-implementation`).ClassName},
|
|
372
|
+
development: wire${new UnknownFormatNaming(`${implementationTypes.at(0)}-implementation`).ClassName},
|
|
373
|
+
production: wire${new UnknownFormatNaming(`${implementationTypes.at(0)}-implementation`).ClassName}
|
|
400
374
|
})
|
|
401
375
|
|
|
402
376
|
`.trim());
|
|
@@ -436,9 +410,14 @@ const scaffoldNewCommand = async (boundedContextFolder)=>{
|
|
|
436
410
|
message: 'Name: '
|
|
437
411
|
});
|
|
438
412
|
const naming = new UnknownFormatNaming(commandName);
|
|
439
|
-
const
|
|
440
|
-
|
|
413
|
+
const commandType = await (0, prompts_namespaceObject.select)({
|
|
414
|
+
choices: [
|
|
415
|
+
'Execution (with infrastructure implementation)',
|
|
416
|
+
'Orchestrator (no infrastructure implementation)'
|
|
417
|
+
],
|
|
418
|
+
message: 'Command type'
|
|
441
419
|
});
|
|
420
|
+
const isOrchestrator = 'Orchestrator (no infrastructure implementation)' === commandType;
|
|
442
421
|
if (!isOrchestrator) {
|
|
443
422
|
const implementationType = await (0, prompts_namespaceObject.input)({
|
|
444
423
|
message: 'Command infrastructure implementation type:',
|
|
@@ -462,81 +441,73 @@ const scaffoldNewCommand = async (boundedContextFolder)=>{
|
|
|
462
441
|
infrastructureFolder.subitem([
|
|
463
442
|
formatNaming.fileName
|
|
464
443
|
]).createFile(`${formatNaming.fileName}-${naming.fileName}-command.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
export class ${formatNaming.ClassName}${naming.ClassName}Command implements ${naming.ClassName}Command {
|
|
469
|
-
constructor() {}
|
|
444
|
+
import { defineHandler } from '@domain-first/handlers'
|
|
445
|
+
import { ${naming.ClassName}Command } from '../../../application/commands/execution/${naming.fileName}-command'
|
|
470
446
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
handler: async (input) => {
|
|
475
|
-
return {}
|
|
476
|
-
}
|
|
477
|
-
})
|
|
447
|
+
export class ${formatNaming.ClassName}${naming.ClassName}Command extends ${naming.ClassName}Command {
|
|
448
|
+
constructor() {
|
|
449
|
+
super()
|
|
478
450
|
}
|
|
479
|
-
`.trim() : `
|
|
480
|
-
import { ${naming.ClassName}Command } from '../../../domain/commands/${naming.fileName}-command'
|
|
481
451
|
|
|
482
|
-
|
|
452
|
+
handle = defineHandler({
|
|
453
|
+
inputSchema: ${naming.ClassName}Command.inputSchema,
|
|
454
|
+
outputSchema: ${naming.ClassName}Command.outputSchema,
|
|
455
|
+
handler: async (input) => {
|
|
456
|
+
return {}
|
|
457
|
+
}
|
|
458
|
+
})
|
|
459
|
+
}
|
|
460
|
+
`.trim() : `
|
|
461
|
+
import { ${naming.ClassName}Command } from '../../../domain/commands/${naming.fileName}-command'
|
|
483
462
|
|
|
463
|
+
export class ${formatNaming.ClassName}${naming.ClassName}Command extends ${naming.ClassName}Command {
|
|
464
|
+
constructor() {
|
|
465
|
+
super()
|
|
484
466
|
}
|
|
467
|
+
}
|
|
485
468
|
`.trim());
|
|
486
|
-
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
487
|
-
const wiringFolder = boundedContextFolder.subitem([
|
|
488
|
-
'wiring',
|
|
489
|
-
'infrastructure',
|
|
490
|
-
'commands',
|
|
491
|
-
formatNaming.fileName
|
|
492
|
-
]);
|
|
493
|
-
wiringFolder.createFile(`wire-${formatNaming.fileName}-${naming.fileName}-command.ts`, `
|
|
494
|
-
import { wireClass } from '@domain-first/wire'
|
|
495
|
-
import { ${formatNaming.ClassName}${naming.ClassName}Command } from '../../../../infrastructure/commands/${formatNaming.fileName}/${formatNaming.fileName}-${naming.fileName}-command'
|
|
496
|
-
|
|
497
|
-
export const wire${formatNaming.ClassName}${naming.ClassName}Command = wireClass(
|
|
498
|
-
${formatNaming.ClassName}${naming.ClassName}Command,
|
|
499
|
-
[]
|
|
500
|
-
)
|
|
501
|
-
|
|
502
|
-
`.trim());
|
|
503
|
-
}
|
|
504
469
|
}
|
|
505
|
-
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) commandsFolder.
|
|
506
|
-
|
|
470
|
+
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) commandsFolder.subitem([
|
|
471
|
+
'execution'
|
|
472
|
+
]).createFile(`${naming.fileName}-command.ts`, `
|
|
473
|
+
import type { Handler } from '@domain-first/handlers'
|
|
507
474
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
475
|
+
export abstract class ${naming.ClassName}Command {
|
|
476
|
+
static inputSchema = {}
|
|
477
|
+
static outputSchema = {}
|
|
511
478
|
|
|
512
|
-
|
|
513
|
-
|
|
479
|
+
abstract handle: Handler<typeof ${naming.ClassName}Command.inputSchema, typeof ${naming.ClassName}Command.outputSchema>
|
|
480
|
+
}
|
|
514
481
|
`.trim());
|
|
515
482
|
else commandsFolder.createFile(`${naming.fileName}-command.ts`, `
|
|
516
|
-
|
|
483
|
+
export abstract class ${naming.ClassName}Command {
|
|
517
484
|
|
|
518
|
-
|
|
485
|
+
}`.trim());
|
|
519
486
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
520
487
|
const implementationNaming = new UnknownFormatNaming(implementationType);
|
|
521
488
|
const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
|
|
522
489
|
boundedContextFolder.subitem([
|
|
523
490
|
'wiring',
|
|
524
|
-
'application',
|
|
525
491
|
'commands'
|
|
526
492
|
]).createFile(`wire-${naming.fileName}-command.ts`, `
|
|
527
|
-
|
|
528
|
-
|
|
493
|
+
import { wireClass } from '@domain-first/wire'
|
|
494
|
+
import { envBranchedWire } from '../../../../shared/wiring/env-branched-wire'
|
|
495
|
+
${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { ${ClassName}${naming.ClassName}Command } from '../../infrastructure/commands/${fileName}/${fileName}-${naming.fileName}-command'`).join('\n')}
|
|
529
496
|
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
}
|
|
497
|
+
${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName })=>`const wire${ClassName}Implementation = wireClass(${ClassName}${naming.ClassName}Command, [])`).join('\n\n')}
|
|
498
|
+
|
|
499
|
+
export const wire${naming.ClassName}Command = envBranchedWire({
|
|
500
|
+
test: wire${addTestImplementation ? testImplementationNaming.ClassName : implementationNaming.ClassName}Implementation,
|
|
501
|
+
development: wire${implementationNaming.ClassName}Implementation,
|
|
502
|
+
production: wire${implementationNaming.ClassName}Implementation
|
|
503
|
+
})
|
|
535
504
|
`.trim());
|
|
536
505
|
}
|
|
537
506
|
return;
|
|
538
507
|
}
|
|
539
|
-
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) commandsFolder.
|
|
508
|
+
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) commandsFolder.subitem([
|
|
509
|
+
'orchestration'
|
|
510
|
+
]).createFile(`${naming.fileName}-command.ts`, `
|
|
540
511
|
import { defineHandler } from '@domain-first/handlers'
|
|
541
512
|
|
|
542
513
|
export class ${naming.ClassName}Command {
|
|
@@ -552,7 +523,9 @@ export class ${naming.ClassName}Command {
|
|
|
552
523
|
})
|
|
553
524
|
}
|
|
554
525
|
`.trim());
|
|
555
|
-
else commandsFolder.
|
|
526
|
+
else commandsFolder.subitem([
|
|
527
|
+
'orchestration'
|
|
528
|
+
]).createFile(`${naming.fileName}-command.ts`, `
|
|
556
529
|
export class ${naming.ClassName}Command {
|
|
557
530
|
|
|
558
531
|
}`.trim());
|
|
@@ -562,7 +535,7 @@ export class ${naming.ClassName}Command {
|
|
|
562
535
|
'commands'
|
|
563
536
|
]).createFile(`wire-${naming.fileName}-command.ts`, `
|
|
564
537
|
import { wireClass } from '@domain-first/wire'
|
|
565
|
-
import { ${naming.ClassName}Command } from '../../../application/commands/${naming.fileName}-command'
|
|
538
|
+
import { ${naming.ClassName}Command } from '../../../application/commands/orchestration/${naming.fileName}-command'
|
|
566
539
|
|
|
567
540
|
export const wire${naming.ClassName}Command = wireClass(${naming.ClassName}Command, [])
|
|
568
541
|
`.trim());
|
|
@@ -614,7 +587,7 @@ const scaffoldNewErrorUseCase = async (boundedContextFolder)=>{
|
|
|
614
587
|
message: 'Error name:'
|
|
615
588
|
});
|
|
616
589
|
const naming = new UnknownFormatNaming(errorName);
|
|
617
|
-
currentErrorFolder.file('index.ts').addLine(`export const ${naming.ClassName}Error = ${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Errors.define('${naming.fileName}')`, '\n\n');
|
|
590
|
+
currentErrorFolder.file('index.ts').addLine(`export const ${naming.ClassName}${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Error = ${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Errors.define('${naming.fileName}')`, '\n\n');
|
|
618
591
|
return;
|
|
619
592
|
}
|
|
620
593
|
if ('New namespace' === selectedVariant) {
|
|
@@ -625,17 +598,18 @@ const scaffoldNewErrorUseCase = async (boundedContextFolder)=>{
|
|
|
625
598
|
currentErrorFolder.createFile(`${fileName}.ts`, `
|
|
626
599
|
import { errorNamespace } from '@domain-first/errors'
|
|
627
600
|
|
|
628
|
-
const ${ClassName}Errors = errorNamespace('${boundedContextFolder.name}').subnamespace('${fileName}')
|
|
601
|
+
export const ${ClassName}${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Errors = errorNamespace('${boundedContextFolder.name}').subnamespace('${fileName}')
|
|
629
602
|
`);
|
|
630
|
-
currentErrorFolder.file('index.ts').addLine(`export * from './${fileName}'
|
|
603
|
+
currentErrorFolder.file('index.ts').addLine(`export * from './${fileName}'`, '\n\n');
|
|
631
604
|
return;
|
|
632
605
|
}
|
|
633
606
|
const namespace = selectedVariant.substring(23);
|
|
607
|
+
const namespaceNaming = new UnknownFormatNaming(namespace);
|
|
634
608
|
const errorName = await (0, prompts_namespaceObject.input)({
|
|
635
609
|
message: 'Error name:'
|
|
636
610
|
});
|
|
637
611
|
const { ClassName, fileName } = new UnknownFormatNaming(errorName);
|
|
638
|
-
currentErrorFolder.file(`${namespace}.ts`).addLine(`export const ${ClassName}Error = ${new UnknownFormatNaming(
|
|
612
|
+
currentErrorFolder.file(`${namespace}.ts`).addLine(`export const ${ClassName}${namespaceNaming.ClassName}${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Error = ${namespaceNaming.ClassName}${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Errors.define('${fileName}')`, '\n\n');
|
|
639
613
|
};
|
|
640
614
|
const scaffoldNewHandlersRestEndpoint = async (boundedContextFolder)=>{
|
|
641
615
|
const restPresentationFolder = boundedContextFolder.subitem([
|
|
@@ -654,11 +628,27 @@ const scaffoldNewHandlersRestEndpoint = async (boundedContextFolder)=>{
|
|
|
654
628
|
controller = await (0, prompts_namespaceObject.input)({
|
|
655
629
|
message: 'Name: '
|
|
656
630
|
});
|
|
657
|
-
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire'))
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
631
|
+
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
632
|
+
boundedContextFolder.subitem([
|
|
633
|
+
'wiring',
|
|
634
|
+
'presentation',
|
|
635
|
+
'rest'
|
|
636
|
+
]).file('index.ts').addLine(`export * from './${controller}'`);
|
|
637
|
+
const sharedRestFolder = boundedContextFolder.subitem([
|
|
638
|
+
'..',
|
|
639
|
+
'..',
|
|
640
|
+
'presentation',
|
|
641
|
+
'rest'
|
|
642
|
+
]);
|
|
643
|
+
sharedRestFolder.file('wires.ts').addLine(`export * from '../../bounded-contexts/${boundedContextFolder.name}/wiring/presentation/rest/${controller}'`);
|
|
644
|
+
if (!sharedRestFolder.file('index.ts').exists) sharedRestFolder.createFile('index.ts', `
|
|
645
|
+
import * as wires from './wires'
|
|
646
|
+
|
|
647
|
+
const restWires = Object.values(wires)
|
|
648
|
+
|
|
649
|
+
export const restHandlers = restWires.map(x => x().handle)
|
|
650
|
+
`.trim());
|
|
651
|
+
}
|
|
662
652
|
}
|
|
663
653
|
const method = await (0, prompts_namespaceObject.select)({
|
|
664
654
|
message: 'Method:',
|
|
@@ -676,9 +666,10 @@ const scaffoldNewHandlersRestEndpoint = async (boundedContextFolder)=>{
|
|
|
676
666
|
const controllerFolder = restPresentationFolder.subitem([
|
|
677
667
|
controller
|
|
678
668
|
]);
|
|
669
|
+
const endpointFolder = controllerFolder.subitem(path);
|
|
679
670
|
const nameBase = `${controller}-${path.length ? `${path.join('-')}-` : ''}${method}-endpoint`;
|
|
680
671
|
const endpointNaming = new UnknownFormatNaming(nameBase);
|
|
681
|
-
|
|
672
|
+
endpointFolder.createFile(`${method.toUpperCase()}.ts`, `
|
|
682
673
|
import { EndpointGenerator } from '@domain-first/handlers-rest'
|
|
683
674
|
|
|
684
675
|
export class ${endpointNaming.ClassName} {
|
|
@@ -694,7 +685,6 @@ export class ${endpointNaming.ClassName} {
|
|
|
694
685
|
tags: ['${boundedContextFolder.name}: ${controller}'],
|
|
695
686
|
})
|
|
696
687
|
}
|
|
697
|
-
|
|
698
688
|
}
|
|
699
689
|
`.trim());
|
|
700
690
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
@@ -708,7 +698,7 @@ export class ${endpointNaming.ClassName} {
|
|
|
708
698
|
const wireNaming = new UnknownFormatNaming(wireNameBase);
|
|
709
699
|
wiringFolder.createFile(`${wireNaming.fileName}.ts`, `
|
|
710
700
|
import { wireClass } from '@domain-first/wire'
|
|
711
|
-
import { ${endpointNaming.ClassName} } from '../../../../presentation/rest/${controller}/${
|
|
701
|
+
import { ${endpointNaming.ClassName} } from '../../../../presentation/rest/${controller}/${path.length ? `${path.join('/')}/` : ''}${method.toUpperCase()}'
|
|
712
702
|
|
|
713
703
|
export const wire${endpointNaming.ClassName} = wireClass(
|
|
714
704
|
${endpointNaming.ClassName},
|
|
@@ -731,9 +721,14 @@ const scaffoldNewQuery = async (boundedContextFolder)=>{
|
|
|
731
721
|
message: 'Name: '
|
|
732
722
|
});
|
|
733
723
|
const naming = new UnknownFormatNaming(queryName);
|
|
734
|
-
const
|
|
735
|
-
|
|
724
|
+
const queryType = await (0, prompts_namespaceObject.select)({
|
|
725
|
+
choices: [
|
|
726
|
+
'Execution (with infrastructure implementation)',
|
|
727
|
+
'Orchestrator (no infrastructure implementation)'
|
|
728
|
+
],
|
|
729
|
+
message: 'Query type'
|
|
736
730
|
});
|
|
731
|
+
const isOrchestrator = 'Orchestrator (no infrastructure implementation)' === queryType;
|
|
737
732
|
if (!isOrchestrator) {
|
|
738
733
|
const implementationType = await (0, prompts_namespaceObject.input)({
|
|
739
734
|
message: 'Query infrastructure implementation type:',
|
|
@@ -757,80 +752,73 @@ const scaffoldNewQuery = async (boundedContextFolder)=>{
|
|
|
757
752
|
infrastructureFolder.subitem([
|
|
758
753
|
formatNaming.fileName
|
|
759
754
|
]).createFile(`${formatNaming.fileName}-${naming.fileName}-query.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
export class ${formatNaming.ClassName}${naming.ClassName}Query implements ${naming.ClassName}Query {
|
|
764
|
-
constructor() {}
|
|
755
|
+
import { defineHandler } from '@domain-first/handlers'
|
|
756
|
+
import { ${naming.ClassName}Query } from '../../../application/queries/execution/${naming.fileName}-query'
|
|
765
757
|
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
handler: async (input) => {
|
|
770
|
-
return {}
|
|
771
|
-
}
|
|
772
|
-
})
|
|
758
|
+
export class ${formatNaming.ClassName}${naming.ClassName}Query extends ${naming.ClassName}Query {
|
|
759
|
+
constructor() {
|
|
760
|
+
super()
|
|
773
761
|
}
|
|
774
|
-
`.trim() : `
|
|
775
|
-
import { ${naming.ClassName}Query } from '../../../domain/queries/${naming.fileName}-query'
|
|
776
762
|
|
|
777
|
-
|
|
763
|
+
handle = defineHandler({
|
|
764
|
+
inputSchema: ${naming.ClassName}Query.inputSchema,
|
|
765
|
+
outputSchema: ${naming.ClassName}Query.outputSchema,
|
|
766
|
+
handler: async (input) => {
|
|
767
|
+
return {}
|
|
768
|
+
}
|
|
769
|
+
})
|
|
770
|
+
}
|
|
771
|
+
`.trim() : `
|
|
772
|
+
import { ${naming.ClassName}Query } from '../../../domain/queries/${naming.fileName}-query'
|
|
778
773
|
|
|
774
|
+
export class ${formatNaming.ClassName}${naming.ClassName}Query extends ${naming.ClassName}Query {
|
|
775
|
+
constructor() {
|
|
776
|
+
super()
|
|
779
777
|
}
|
|
778
|
+
}
|
|
780
779
|
`.trim());
|
|
781
|
-
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
782
|
-
const wiringFolder = boundedContextFolder.subitem([
|
|
783
|
-
'wiring',
|
|
784
|
-
'infrastructure',
|
|
785
|
-
'queries',
|
|
786
|
-
formatNaming.fileName
|
|
787
|
-
]);
|
|
788
|
-
wiringFolder.createFile(`wire-${formatNaming.fileName}-${naming.fileName}-query.ts`, `
|
|
789
|
-
import { wireClass } from '@domain-first/wire'
|
|
790
|
-
import { ${formatNaming.ClassName}${naming.ClassName}Query } from '../../../../infrastructure/queries/${formatNaming.fileName}/${formatNaming.fileName}-${naming.fileName}-query'
|
|
791
|
-
|
|
792
|
-
export const wire${formatNaming.ClassName}${naming.ClassName}Query = wireClass(
|
|
793
|
-
${formatNaming.ClassName}${naming.ClassName}Query,
|
|
794
|
-
[]
|
|
795
|
-
)
|
|
796
|
-
`.trim());
|
|
797
|
-
}
|
|
798
780
|
}
|
|
799
|
-
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) queriesFolder.
|
|
800
|
-
|
|
781
|
+
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) queriesFolder.subitem([
|
|
782
|
+
'execution'
|
|
783
|
+
]).createFile(`${naming.fileName}-query.ts`, `
|
|
784
|
+
import type { Handler } from '@domain-first/handlers'
|
|
801
785
|
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
786
|
+
export abstract class ${naming.ClassName}Query {
|
|
787
|
+
static inputSchema = {}
|
|
788
|
+
static outputSchema = {}
|
|
805
789
|
|
|
806
|
-
|
|
807
|
-
|
|
790
|
+
abstract handle: Handler<typeof ${naming.ClassName}Query.inputSchema, typeof ${naming.ClassName}Query.outputSchema>
|
|
791
|
+
}
|
|
808
792
|
`.trim());
|
|
809
793
|
else queriesFolder.createFile(`${naming.fileName}-query.ts`, `
|
|
810
|
-
|
|
794
|
+
export abstract class ${naming.ClassName}Query {
|
|
811
795
|
|
|
812
|
-
|
|
796
|
+
}`.trim());
|
|
813
797
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
814
798
|
const implementationNaming = new UnknownFormatNaming(implementationType);
|
|
815
799
|
const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
|
|
816
800
|
boundedContextFolder.subitem([
|
|
817
801
|
'wiring',
|
|
818
|
-
'application',
|
|
819
802
|
'queries'
|
|
820
803
|
]).createFile(`wire-${naming.fileName}-query.ts`, `
|
|
821
|
-
|
|
822
|
-
|
|
804
|
+
import { wireClass } from '@domain-first/wire'
|
|
805
|
+
import { envBranchedWire } from '../../../../shared/wiring/env-branched-wire'
|
|
806
|
+
${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { ${ClassName}${naming.ClassName}Query } from '../../infrastructure/queries/${fileName}/${fileName}-${naming.fileName}-query'`).join('\n')}
|
|
823
807
|
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
}
|
|
808
|
+
${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName })=>`const wire${ClassName}Implementation = wireClass(${ClassName}${naming.ClassName}Query, [])`).join('\n\n')}
|
|
809
|
+
|
|
810
|
+
export const wire${naming.ClassName}Query = envBranchedWire({
|
|
811
|
+
test: wire${addTestImplementation ? testImplementationNaming.ClassName : implementationNaming.ClassName}Implementation,
|
|
812
|
+
development: wire${implementationNaming.ClassName}Implementation,
|
|
813
|
+
production: wire${implementationNaming.ClassName}Implementation
|
|
814
|
+
})
|
|
829
815
|
`.trim());
|
|
830
816
|
}
|
|
831
817
|
return;
|
|
832
818
|
}
|
|
833
|
-
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) queriesFolder.
|
|
819
|
+
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) queriesFolder.subitem([
|
|
820
|
+
'orchestration'
|
|
821
|
+
]).createFile(`${naming.fileName}-query.ts`, `
|
|
834
822
|
import { defineHandler } from '@domain-first/handlers'
|
|
835
823
|
|
|
836
824
|
export class ${naming.ClassName}Query {
|
|
@@ -846,7 +834,9 @@ export class ${naming.ClassName}Query {
|
|
|
846
834
|
})
|
|
847
835
|
}
|
|
848
836
|
`.trim());
|
|
849
|
-
else queriesFolder.
|
|
837
|
+
else queriesFolder.subitem([
|
|
838
|
+
'orchestration'
|
|
839
|
+
]).createFile(`${naming.fileName}-query.ts`, `
|
|
850
840
|
export class ${naming.ClassName}Query {
|
|
851
841
|
|
|
852
842
|
}`.trim());
|
|
@@ -856,7 +846,7 @@ export class ${naming.ClassName}Query {
|
|
|
856
846
|
'queries'
|
|
857
847
|
]).createFile(`wire-${naming.fileName}-query.ts`, `
|
|
858
848
|
import { wireClass } from '@domain-first/wire'
|
|
859
|
-
import { ${naming.ClassName}Query } from '../../../application/queries/${naming.fileName}-query'
|
|
849
|
+
import { ${naming.ClassName}Query } from '../../../application/queries/orchestration/${naming.fileName}-query'
|
|
860
850
|
|
|
861
851
|
export const wire${naming.ClassName}Query = wireClass(${naming.ClassName}Query, [])
|
|
862
852
|
`.trim());
|
|
@@ -894,11 +884,10 @@ export class ${naming.ClassName}UseCase {
|
|
|
894
884
|
`.trim());
|
|
895
885
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) boundedContextFolder.subitem([
|
|
896
886
|
'wiring',
|
|
897
|
-
'application',
|
|
898
887
|
'use-cases'
|
|
899
888
|
]).createFile(`wire-${naming.fileName}-use-case.ts`, `
|
|
900
889
|
import { wireClass } from '@domain-first/wire'
|
|
901
|
-
import { ${naming.ClassName}UseCase } from '
|
|
890
|
+
import { ${naming.ClassName}UseCase } from '../../application/use-cases/${naming.fileName}-use-case'
|
|
902
891
|
|
|
903
892
|
export const wire${naming.ClassName}UseCase = wireClass(
|
|
904
893
|
${naming.ClassName}UseCase,
|
package/dist/index.js
CHANGED
|
@@ -252,41 +252,26 @@ export class ${naming.ClassName}${aggregateNaming.ClassName}Repository implement
|
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
`.trim());
|
|
255
|
-
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
256
|
-
const wiringFolder = boundedContextFolder.subitem([
|
|
257
|
-
'wiring',
|
|
258
|
-
'infrastructure',
|
|
259
|
-
'repositories',
|
|
260
|
-
naming.fileName
|
|
261
|
-
]);
|
|
262
|
-
wiringFolder.createFile(`wire-${naming.fileName}-${aggregateNaming.fileName}-repository.ts`, `
|
|
263
|
-
import { wireClass } from '@domain-first/wire'
|
|
264
|
-
import { ${naming.ClassName}${aggregateNaming.ClassName}Repository } from '../../../../infrastructure/repositories/${naming.fileName}/${naming.fileName}-${aggregateNaming.fileName}-repository'
|
|
265
|
-
|
|
266
|
-
export const wire${naming.ClassName}${aggregateNaming.ClassName}Repository = wireClass(
|
|
267
|
-
${naming.ClassName}${aggregateNaming.ClassName}Repository,
|
|
268
|
-
[]
|
|
269
|
-
)
|
|
270
|
-
`.trim());
|
|
271
|
-
}
|
|
272
255
|
}
|
|
273
256
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
274
257
|
const implementationNaming = new UnknownFormatNaming(infrastructureImplementationType);
|
|
275
258
|
const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
|
|
276
259
|
boundedContextFolder.subitem([
|
|
277
260
|
'wiring',
|
|
278
|
-
'domain',
|
|
279
261
|
'repositories'
|
|
280
262
|
]).createFile(`wire-${aggregateNaming.fileName}-repository.ts`, `
|
|
281
|
-
import {
|
|
282
|
-
|
|
263
|
+
import { wireClass } from '@domain-first/wire'
|
|
264
|
+
import { envBranchedWire } from '../../../../shared/wiring/env-branched-wire'
|
|
265
|
+
${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { ${ClassName}${aggregateNaming.ClassName}Repository } from '../../infrastructure/repositories/${fileName}/${fileName}-${aggregateNaming.fileName}-repository'`).join('\n')}
|
|
266
|
+
|
|
267
|
+
${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName })=>`const wire${ClassName}Implementation = wireClass(${ClassName}${aggregateNaming.ClassName}Repository, [])`).join('\n\n')}
|
|
283
268
|
|
|
284
269
|
export const wire${aggregateNaming.ClassName}Repository = envBranchedWire({
|
|
285
|
-
test: wire${addTestImplementation ? testImplementationNaming.ClassName : implementationNaming.ClassName}
|
|
286
|
-
development: wire${implementationNaming.ClassName}
|
|
287
|
-
production: wire${implementationNaming.ClassName}
|
|
270
|
+
test: wire${addTestImplementation ? testImplementationNaming.ClassName : implementationNaming.ClassName}Implementation,
|
|
271
|
+
development: wire${implementationNaming.ClassName}Implementation,
|
|
272
|
+
production: wire${implementationNaming.ClassName}Implementation
|
|
288
273
|
})
|
|
289
|
-
`.trim());
|
|
274
|
+
`.trim());
|
|
290
275
|
}
|
|
291
276
|
}
|
|
292
277
|
};
|
|
@@ -297,14 +282,8 @@ const scaffoldNewApplicationPort = async (boundedContextFolder)=>{
|
|
|
297
282
|
const naming = new UnknownFormatNaming(name);
|
|
298
283
|
const wiringFolder = boundedContextFolder.subitem([
|
|
299
284
|
'wiring',
|
|
300
|
-
'application',
|
|
301
285
|
'ports'
|
|
302
286
|
]);
|
|
303
|
-
const infraFolder = boundedContextFolder.subitem([
|
|
304
|
-
'wiring',
|
|
305
|
-
'infrastructure',
|
|
306
|
-
'application-ports'
|
|
307
|
-
]);
|
|
308
287
|
const applicationPortsFolder = boundedContextFolder.subitem([
|
|
309
288
|
'application',
|
|
310
289
|
'ports'
|
|
@@ -344,29 +323,24 @@ export class ${currentNaming.ClassName} extends ${naming.ClassName} {
|
|
|
344
323
|
|
|
345
324
|
}
|
|
346
325
|
`);
|
|
347
|
-
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) infraFolder.subitem([
|
|
348
|
-
implementation
|
|
349
|
-
]).createFile(`wire-${currentNaming.fileName}.ts`, `
|
|
350
|
-
import { wireClass } from '@domain-first/wire'
|
|
351
|
-
import { ${currentNaming.ClassName} } from '../../../../infrastructure/application-adapters/${implementation}/${currentNaming.fileName}'
|
|
352
|
-
|
|
353
|
-
export const wire${currentNaming.ClassName} = wireClass(
|
|
354
|
-
${currentNaming.ClassName},
|
|
355
|
-
[]
|
|
356
|
-
)
|
|
357
|
-
`.trim());
|
|
358
326
|
}
|
|
359
327
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) wiringFolder.createFile(`wire-${naming.fileName}.ts`, `
|
|
360
|
-
import {
|
|
328
|
+
import { wireClass } from '@domain-first/wire'
|
|
329
|
+
import { envBranchedWire } from '../../../${'shared' === boundedContextFolder.name ? '' : '../'}shared/wiring/env-branched-wire'
|
|
330
|
+
${implementationTypes.map((x)=>({
|
|
331
|
+
naming: new UnknownFormatNaming(`${x}-${naming.fileName}`),
|
|
332
|
+
implementation: x
|
|
333
|
+
})).map(({ naming: { ClassName, fileName }, implementation })=>`import { ${ClassName} } from '../../infrastructure/application-adapters/${implementation}/${fileName}'`).join('\n')}
|
|
334
|
+
|
|
361
335
|
${implementationTypes.map((x)=>({
|
|
362
336
|
naming: new UnknownFormatNaming(`${x}-${naming.fileName}`),
|
|
363
337
|
implementation: x
|
|
364
|
-
})).map(({ naming: { ClassName
|
|
338
|
+
})).map(({ naming: { ClassName }, implementation })=>`const wire${new UnknownFormatNaming(implementation).ClassName}Implementation = wireClass(${ClassName}, [])`).join('\n\n')}
|
|
365
339
|
|
|
366
340
|
export const wire${naming.ClassName} = envBranchedWire({
|
|
367
|
-
test: wire${new UnknownFormatNaming(`${implementationTypes.at(-1)}
|
|
368
|
-
development: wire${new UnknownFormatNaming(`${implementationTypes.at(0)}
|
|
369
|
-
production: wire${new UnknownFormatNaming(`${implementationTypes.at(0)}
|
|
341
|
+
test: wire${new UnknownFormatNaming(`${implementationTypes.at(-1)}-implementation`).ClassName},
|
|
342
|
+
development: wire${new UnknownFormatNaming(`${implementationTypes.at(0)}-implementation`).ClassName},
|
|
343
|
+
production: wire${new UnknownFormatNaming(`${implementationTypes.at(0)}-implementation`).ClassName}
|
|
370
344
|
})
|
|
371
345
|
|
|
372
346
|
`.trim());
|
|
@@ -406,9 +380,14 @@ const scaffoldNewCommand = async (boundedContextFolder)=>{
|
|
|
406
380
|
message: 'Name: '
|
|
407
381
|
});
|
|
408
382
|
const naming = new UnknownFormatNaming(commandName);
|
|
409
|
-
const
|
|
410
|
-
|
|
383
|
+
const commandType = await prompts_select({
|
|
384
|
+
choices: [
|
|
385
|
+
'Execution (with infrastructure implementation)',
|
|
386
|
+
'Orchestrator (no infrastructure implementation)'
|
|
387
|
+
],
|
|
388
|
+
message: 'Command type'
|
|
411
389
|
});
|
|
390
|
+
const isOrchestrator = 'Orchestrator (no infrastructure implementation)' === commandType;
|
|
412
391
|
if (!isOrchestrator) {
|
|
413
392
|
const implementationType = await input({
|
|
414
393
|
message: 'Command infrastructure implementation type:',
|
|
@@ -432,81 +411,73 @@ const scaffoldNewCommand = async (boundedContextFolder)=>{
|
|
|
432
411
|
infrastructureFolder.subitem([
|
|
433
412
|
formatNaming.fileName
|
|
434
413
|
]).createFile(`${formatNaming.fileName}-${naming.fileName}-command.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
export class ${formatNaming.ClassName}${naming.ClassName}Command implements ${naming.ClassName}Command {
|
|
439
|
-
constructor() {}
|
|
414
|
+
import { defineHandler } from '@domain-first/handlers'
|
|
415
|
+
import { ${naming.ClassName}Command } from '../../../application/commands/execution/${naming.fileName}-command'
|
|
440
416
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
handler: async (input) => {
|
|
445
|
-
return {}
|
|
446
|
-
}
|
|
447
|
-
})
|
|
417
|
+
export class ${formatNaming.ClassName}${naming.ClassName}Command extends ${naming.ClassName}Command {
|
|
418
|
+
constructor() {
|
|
419
|
+
super()
|
|
448
420
|
}
|
|
449
|
-
`.trim() : `
|
|
450
|
-
import { ${naming.ClassName}Command } from '../../../domain/commands/${naming.fileName}-command'
|
|
451
421
|
|
|
452
|
-
|
|
422
|
+
handle = defineHandler({
|
|
423
|
+
inputSchema: ${naming.ClassName}Command.inputSchema,
|
|
424
|
+
outputSchema: ${naming.ClassName}Command.outputSchema,
|
|
425
|
+
handler: async (input) => {
|
|
426
|
+
return {}
|
|
427
|
+
}
|
|
428
|
+
})
|
|
429
|
+
}
|
|
430
|
+
`.trim() : `
|
|
431
|
+
import { ${naming.ClassName}Command } from '../../../domain/commands/${naming.fileName}-command'
|
|
453
432
|
|
|
433
|
+
export class ${formatNaming.ClassName}${naming.ClassName}Command extends ${naming.ClassName}Command {
|
|
434
|
+
constructor() {
|
|
435
|
+
super()
|
|
454
436
|
}
|
|
437
|
+
}
|
|
455
438
|
`.trim());
|
|
456
|
-
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
457
|
-
const wiringFolder = boundedContextFolder.subitem([
|
|
458
|
-
'wiring',
|
|
459
|
-
'infrastructure',
|
|
460
|
-
'commands',
|
|
461
|
-
formatNaming.fileName
|
|
462
|
-
]);
|
|
463
|
-
wiringFolder.createFile(`wire-${formatNaming.fileName}-${naming.fileName}-command.ts`, `
|
|
464
|
-
import { wireClass } from '@domain-first/wire'
|
|
465
|
-
import { ${formatNaming.ClassName}${naming.ClassName}Command } from '../../../../infrastructure/commands/${formatNaming.fileName}/${formatNaming.fileName}-${naming.fileName}-command'
|
|
466
|
-
|
|
467
|
-
export const wire${formatNaming.ClassName}${naming.ClassName}Command = wireClass(
|
|
468
|
-
${formatNaming.ClassName}${naming.ClassName}Command,
|
|
469
|
-
[]
|
|
470
|
-
)
|
|
471
|
-
|
|
472
|
-
`.trim());
|
|
473
|
-
}
|
|
474
439
|
}
|
|
475
|
-
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) commandsFolder.
|
|
476
|
-
|
|
440
|
+
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) commandsFolder.subitem([
|
|
441
|
+
'execution'
|
|
442
|
+
]).createFile(`${naming.fileName}-command.ts`, `
|
|
443
|
+
import type { Handler } from '@domain-first/handlers'
|
|
477
444
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
445
|
+
export abstract class ${naming.ClassName}Command {
|
|
446
|
+
static inputSchema = {}
|
|
447
|
+
static outputSchema = {}
|
|
481
448
|
|
|
482
|
-
|
|
483
|
-
|
|
449
|
+
abstract handle: Handler<typeof ${naming.ClassName}Command.inputSchema, typeof ${naming.ClassName}Command.outputSchema>
|
|
450
|
+
}
|
|
484
451
|
`.trim());
|
|
485
452
|
else commandsFolder.createFile(`${naming.fileName}-command.ts`, `
|
|
486
|
-
|
|
453
|
+
export abstract class ${naming.ClassName}Command {
|
|
487
454
|
|
|
488
|
-
|
|
455
|
+
}`.trim());
|
|
489
456
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
490
457
|
const implementationNaming = new UnknownFormatNaming(implementationType);
|
|
491
458
|
const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
|
|
492
459
|
boundedContextFolder.subitem([
|
|
493
460
|
'wiring',
|
|
494
|
-
'application',
|
|
495
461
|
'commands'
|
|
496
462
|
]).createFile(`wire-${naming.fileName}-command.ts`, `
|
|
497
|
-
|
|
498
|
-
|
|
463
|
+
import { wireClass } from '@domain-first/wire'
|
|
464
|
+
import { envBranchedWire } from '../../../../shared/wiring/env-branched-wire'
|
|
465
|
+
${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { ${ClassName}${naming.ClassName}Command } from '../../infrastructure/commands/${fileName}/${fileName}-${naming.fileName}-command'`).join('\n')}
|
|
499
466
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
}
|
|
467
|
+
${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName })=>`const wire${ClassName}Implementation = wireClass(${ClassName}${naming.ClassName}Command, [])`).join('\n\n')}
|
|
468
|
+
|
|
469
|
+
export const wire${naming.ClassName}Command = envBranchedWire({
|
|
470
|
+
test: wire${addTestImplementation ? testImplementationNaming.ClassName : implementationNaming.ClassName}Implementation,
|
|
471
|
+
development: wire${implementationNaming.ClassName}Implementation,
|
|
472
|
+
production: wire${implementationNaming.ClassName}Implementation
|
|
473
|
+
})
|
|
505
474
|
`.trim());
|
|
506
475
|
}
|
|
507
476
|
return;
|
|
508
477
|
}
|
|
509
|
-
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) commandsFolder.
|
|
478
|
+
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) commandsFolder.subitem([
|
|
479
|
+
'orchestration'
|
|
480
|
+
]).createFile(`${naming.fileName}-command.ts`, `
|
|
510
481
|
import { defineHandler } from '@domain-first/handlers'
|
|
511
482
|
|
|
512
483
|
export class ${naming.ClassName}Command {
|
|
@@ -522,7 +493,9 @@ export class ${naming.ClassName}Command {
|
|
|
522
493
|
})
|
|
523
494
|
}
|
|
524
495
|
`.trim());
|
|
525
|
-
else commandsFolder.
|
|
496
|
+
else commandsFolder.subitem([
|
|
497
|
+
'orchestration'
|
|
498
|
+
]).createFile(`${naming.fileName}-command.ts`, `
|
|
526
499
|
export class ${naming.ClassName}Command {
|
|
527
500
|
|
|
528
501
|
}`.trim());
|
|
@@ -532,7 +505,7 @@ export class ${naming.ClassName}Command {
|
|
|
532
505
|
'commands'
|
|
533
506
|
]).createFile(`wire-${naming.fileName}-command.ts`, `
|
|
534
507
|
import { wireClass } from '@domain-first/wire'
|
|
535
|
-
import { ${naming.ClassName}Command } from '../../../application/commands/${naming.fileName}-command'
|
|
508
|
+
import { ${naming.ClassName}Command } from '../../../application/commands/orchestration/${naming.fileName}-command'
|
|
536
509
|
|
|
537
510
|
export const wire${naming.ClassName}Command = wireClass(${naming.ClassName}Command, [])
|
|
538
511
|
`.trim());
|
|
@@ -584,7 +557,7 @@ const scaffoldNewErrorUseCase = async (boundedContextFolder)=>{
|
|
|
584
557
|
message: 'Error name:'
|
|
585
558
|
});
|
|
586
559
|
const naming = new UnknownFormatNaming(errorName);
|
|
587
|
-
currentErrorFolder.file('index.ts').addLine(`export const ${naming.ClassName}Error = ${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Errors.define('${naming.fileName}')`, '\n\n');
|
|
560
|
+
currentErrorFolder.file('index.ts').addLine(`export const ${naming.ClassName}${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Error = ${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Errors.define('${naming.fileName}')`, '\n\n');
|
|
588
561
|
return;
|
|
589
562
|
}
|
|
590
563
|
if ('New namespace' === selectedVariant) {
|
|
@@ -595,17 +568,18 @@ const scaffoldNewErrorUseCase = async (boundedContextFolder)=>{
|
|
|
595
568
|
currentErrorFolder.createFile(`${fileName}.ts`, `
|
|
596
569
|
import { errorNamespace } from '@domain-first/errors'
|
|
597
570
|
|
|
598
|
-
const ${ClassName}Errors = errorNamespace('${boundedContextFolder.name}').subnamespace('${fileName}')
|
|
571
|
+
export const ${ClassName}${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Errors = errorNamespace('${boundedContextFolder.name}').subnamespace('${fileName}')
|
|
599
572
|
`);
|
|
600
|
-
currentErrorFolder.file('index.ts').addLine(`export * from './${fileName}'
|
|
573
|
+
currentErrorFolder.file('index.ts').addLine(`export * from './${fileName}'`, '\n\n');
|
|
601
574
|
return;
|
|
602
575
|
}
|
|
603
576
|
const namespace = selectedVariant.substring(23);
|
|
577
|
+
const namespaceNaming = new UnknownFormatNaming(namespace);
|
|
604
578
|
const errorName = await input({
|
|
605
579
|
message: 'Error name:'
|
|
606
580
|
});
|
|
607
581
|
const { ClassName, fileName } = new UnknownFormatNaming(errorName);
|
|
608
|
-
currentErrorFolder.file(`${namespace}.ts`).addLine(`export const ${ClassName}Error = ${new UnknownFormatNaming(
|
|
582
|
+
currentErrorFolder.file(`${namespace}.ts`).addLine(`export const ${ClassName}${namespaceNaming.ClassName}${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Error = ${namespaceNaming.ClassName}${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Errors.define('${fileName}')`, '\n\n');
|
|
609
583
|
};
|
|
610
584
|
const scaffoldNewHandlersRestEndpoint = async (boundedContextFolder)=>{
|
|
611
585
|
const restPresentationFolder = boundedContextFolder.subitem([
|
|
@@ -624,11 +598,27 @@ const scaffoldNewHandlersRestEndpoint = async (boundedContextFolder)=>{
|
|
|
624
598
|
controller = await input({
|
|
625
599
|
message: 'Name: '
|
|
626
600
|
});
|
|
627
|
-
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire'))
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
601
|
+
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
602
|
+
boundedContextFolder.subitem([
|
|
603
|
+
'wiring',
|
|
604
|
+
'presentation',
|
|
605
|
+
'rest'
|
|
606
|
+
]).file('index.ts').addLine(`export * from './${controller}'`);
|
|
607
|
+
const sharedRestFolder = boundedContextFolder.subitem([
|
|
608
|
+
'..',
|
|
609
|
+
'..',
|
|
610
|
+
'presentation',
|
|
611
|
+
'rest'
|
|
612
|
+
]);
|
|
613
|
+
sharedRestFolder.file('wires.ts').addLine(`export * from '../../bounded-contexts/${boundedContextFolder.name}/wiring/presentation/rest/${controller}'`);
|
|
614
|
+
if (!sharedRestFolder.file('index.ts').exists) sharedRestFolder.createFile('index.ts', `
|
|
615
|
+
import * as wires from './wires'
|
|
616
|
+
|
|
617
|
+
const restWires = Object.values(wires)
|
|
618
|
+
|
|
619
|
+
export const restHandlers = restWires.map(x => x().handle)
|
|
620
|
+
`.trim());
|
|
621
|
+
}
|
|
632
622
|
}
|
|
633
623
|
const method = await prompts_select({
|
|
634
624
|
message: 'Method:',
|
|
@@ -646,9 +636,10 @@ const scaffoldNewHandlersRestEndpoint = async (boundedContextFolder)=>{
|
|
|
646
636
|
const controllerFolder = restPresentationFolder.subitem([
|
|
647
637
|
controller
|
|
648
638
|
]);
|
|
639
|
+
const endpointFolder = controllerFolder.subitem(path);
|
|
649
640
|
const nameBase = `${controller}-${path.length ? `${path.join('-')}-` : ''}${method}-endpoint`;
|
|
650
641
|
const endpointNaming = new UnknownFormatNaming(nameBase);
|
|
651
|
-
|
|
642
|
+
endpointFolder.createFile(`${method.toUpperCase()}.ts`, `
|
|
652
643
|
import { EndpointGenerator } from '@domain-first/handlers-rest'
|
|
653
644
|
|
|
654
645
|
export class ${endpointNaming.ClassName} {
|
|
@@ -664,7 +655,6 @@ export class ${endpointNaming.ClassName} {
|
|
|
664
655
|
tags: ['${boundedContextFolder.name}: ${controller}'],
|
|
665
656
|
})
|
|
666
657
|
}
|
|
667
|
-
|
|
668
658
|
}
|
|
669
659
|
`.trim());
|
|
670
660
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
@@ -678,7 +668,7 @@ export class ${endpointNaming.ClassName} {
|
|
|
678
668
|
const wireNaming = new UnknownFormatNaming(wireNameBase);
|
|
679
669
|
wiringFolder.createFile(`${wireNaming.fileName}.ts`, `
|
|
680
670
|
import { wireClass } from '@domain-first/wire'
|
|
681
|
-
import { ${endpointNaming.ClassName} } from '../../../../presentation/rest/${controller}/${
|
|
671
|
+
import { ${endpointNaming.ClassName} } from '../../../../presentation/rest/${controller}/${path.length ? `${path.join('/')}/` : ''}${method.toUpperCase()}'
|
|
682
672
|
|
|
683
673
|
export const wire${endpointNaming.ClassName} = wireClass(
|
|
684
674
|
${endpointNaming.ClassName},
|
|
@@ -701,9 +691,14 @@ const scaffoldNewQuery = async (boundedContextFolder)=>{
|
|
|
701
691
|
message: 'Name: '
|
|
702
692
|
});
|
|
703
693
|
const naming = new UnknownFormatNaming(queryName);
|
|
704
|
-
const
|
|
705
|
-
|
|
694
|
+
const queryType = await prompts_select({
|
|
695
|
+
choices: [
|
|
696
|
+
'Execution (with infrastructure implementation)',
|
|
697
|
+
'Orchestrator (no infrastructure implementation)'
|
|
698
|
+
],
|
|
699
|
+
message: 'Query type'
|
|
706
700
|
});
|
|
701
|
+
const isOrchestrator = 'Orchestrator (no infrastructure implementation)' === queryType;
|
|
707
702
|
if (!isOrchestrator) {
|
|
708
703
|
const implementationType = await input({
|
|
709
704
|
message: 'Query infrastructure implementation type:',
|
|
@@ -727,80 +722,73 @@ const scaffoldNewQuery = async (boundedContextFolder)=>{
|
|
|
727
722
|
infrastructureFolder.subitem([
|
|
728
723
|
formatNaming.fileName
|
|
729
724
|
]).createFile(`${formatNaming.fileName}-${naming.fileName}-query.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
export class ${formatNaming.ClassName}${naming.ClassName}Query implements ${naming.ClassName}Query {
|
|
734
|
-
constructor() {}
|
|
725
|
+
import { defineHandler } from '@domain-first/handlers'
|
|
726
|
+
import { ${naming.ClassName}Query } from '../../../application/queries/execution/${naming.fileName}-query'
|
|
735
727
|
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
handler: async (input) => {
|
|
740
|
-
return {}
|
|
741
|
-
}
|
|
742
|
-
})
|
|
728
|
+
export class ${formatNaming.ClassName}${naming.ClassName}Query extends ${naming.ClassName}Query {
|
|
729
|
+
constructor() {
|
|
730
|
+
super()
|
|
743
731
|
}
|
|
744
|
-
`.trim() : `
|
|
745
|
-
import { ${naming.ClassName}Query } from '../../../domain/queries/${naming.fileName}-query'
|
|
746
732
|
|
|
747
|
-
|
|
733
|
+
handle = defineHandler({
|
|
734
|
+
inputSchema: ${naming.ClassName}Query.inputSchema,
|
|
735
|
+
outputSchema: ${naming.ClassName}Query.outputSchema,
|
|
736
|
+
handler: async (input) => {
|
|
737
|
+
return {}
|
|
738
|
+
}
|
|
739
|
+
})
|
|
740
|
+
}
|
|
741
|
+
`.trim() : `
|
|
742
|
+
import { ${naming.ClassName}Query } from '../../../domain/queries/${naming.fileName}-query'
|
|
748
743
|
|
|
744
|
+
export class ${formatNaming.ClassName}${naming.ClassName}Query extends ${naming.ClassName}Query {
|
|
745
|
+
constructor() {
|
|
746
|
+
super()
|
|
749
747
|
}
|
|
748
|
+
}
|
|
750
749
|
`.trim());
|
|
751
|
-
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
752
|
-
const wiringFolder = boundedContextFolder.subitem([
|
|
753
|
-
'wiring',
|
|
754
|
-
'infrastructure',
|
|
755
|
-
'queries',
|
|
756
|
-
formatNaming.fileName
|
|
757
|
-
]);
|
|
758
|
-
wiringFolder.createFile(`wire-${formatNaming.fileName}-${naming.fileName}-query.ts`, `
|
|
759
|
-
import { wireClass } from '@domain-first/wire'
|
|
760
|
-
import { ${formatNaming.ClassName}${naming.ClassName}Query } from '../../../../infrastructure/queries/${formatNaming.fileName}/${formatNaming.fileName}-${naming.fileName}-query'
|
|
761
|
-
|
|
762
|
-
export const wire${formatNaming.ClassName}${naming.ClassName}Query = wireClass(
|
|
763
|
-
${formatNaming.ClassName}${naming.ClassName}Query,
|
|
764
|
-
[]
|
|
765
|
-
)
|
|
766
|
-
`.trim());
|
|
767
|
-
}
|
|
768
750
|
}
|
|
769
|
-
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) queriesFolder.
|
|
770
|
-
|
|
751
|
+
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) queriesFolder.subitem([
|
|
752
|
+
'execution'
|
|
753
|
+
]).createFile(`${naming.fileName}-query.ts`, `
|
|
754
|
+
import type { Handler } from '@domain-first/handlers'
|
|
771
755
|
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
756
|
+
export abstract class ${naming.ClassName}Query {
|
|
757
|
+
static inputSchema = {}
|
|
758
|
+
static outputSchema = {}
|
|
775
759
|
|
|
776
|
-
|
|
777
|
-
|
|
760
|
+
abstract handle: Handler<typeof ${naming.ClassName}Query.inputSchema, typeof ${naming.ClassName}Query.outputSchema>
|
|
761
|
+
}
|
|
778
762
|
`.trim());
|
|
779
763
|
else queriesFolder.createFile(`${naming.fileName}-query.ts`, `
|
|
780
|
-
|
|
764
|
+
export abstract class ${naming.ClassName}Query {
|
|
781
765
|
|
|
782
|
-
|
|
766
|
+
}`.trim());
|
|
783
767
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
784
768
|
const implementationNaming = new UnknownFormatNaming(implementationType);
|
|
785
769
|
const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
|
|
786
770
|
boundedContextFolder.subitem([
|
|
787
771
|
'wiring',
|
|
788
|
-
'application',
|
|
789
772
|
'queries'
|
|
790
773
|
]).createFile(`wire-${naming.fileName}-query.ts`, `
|
|
791
|
-
|
|
792
|
-
|
|
774
|
+
import { wireClass } from '@domain-first/wire'
|
|
775
|
+
import { envBranchedWire } from '../../../../shared/wiring/env-branched-wire'
|
|
776
|
+
${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { ${ClassName}${naming.ClassName}Query } from '../../infrastructure/queries/${fileName}/${fileName}-${naming.fileName}-query'`).join('\n')}
|
|
793
777
|
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
}
|
|
778
|
+
${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName })=>`const wire${ClassName}Implementation = wireClass(${ClassName}${naming.ClassName}Query, [])`).join('\n\n')}
|
|
779
|
+
|
|
780
|
+
export const wire${naming.ClassName}Query = envBranchedWire({
|
|
781
|
+
test: wire${addTestImplementation ? testImplementationNaming.ClassName : implementationNaming.ClassName}Implementation,
|
|
782
|
+
development: wire${implementationNaming.ClassName}Implementation,
|
|
783
|
+
production: wire${implementationNaming.ClassName}Implementation
|
|
784
|
+
})
|
|
799
785
|
`.trim());
|
|
800
786
|
}
|
|
801
787
|
return;
|
|
802
788
|
}
|
|
803
|
-
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) queriesFolder.
|
|
789
|
+
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) queriesFolder.subitem([
|
|
790
|
+
'orchestration'
|
|
791
|
+
]).createFile(`${naming.fileName}-query.ts`, `
|
|
804
792
|
import { defineHandler } from '@domain-first/handlers'
|
|
805
793
|
|
|
806
794
|
export class ${naming.ClassName}Query {
|
|
@@ -816,7 +804,9 @@ export class ${naming.ClassName}Query {
|
|
|
816
804
|
})
|
|
817
805
|
}
|
|
818
806
|
`.trim());
|
|
819
|
-
else queriesFolder.
|
|
807
|
+
else queriesFolder.subitem([
|
|
808
|
+
'orchestration'
|
|
809
|
+
]).createFile(`${naming.fileName}-query.ts`, `
|
|
820
810
|
export class ${naming.ClassName}Query {
|
|
821
811
|
|
|
822
812
|
}`.trim());
|
|
@@ -826,7 +816,7 @@ export class ${naming.ClassName}Query {
|
|
|
826
816
|
'queries'
|
|
827
817
|
]).createFile(`wire-${naming.fileName}-query.ts`, `
|
|
828
818
|
import { wireClass } from '@domain-first/wire'
|
|
829
|
-
import { ${naming.ClassName}Query } from '../../../application/queries/${naming.fileName}-query'
|
|
819
|
+
import { ${naming.ClassName}Query } from '../../../application/queries/orchestration/${naming.fileName}-query'
|
|
830
820
|
|
|
831
821
|
export const wire${naming.ClassName}Query = wireClass(${naming.ClassName}Query, [])
|
|
832
822
|
`.trim());
|
|
@@ -864,11 +854,10 @@ export class ${naming.ClassName}UseCase {
|
|
|
864
854
|
`.trim());
|
|
865
855
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) boundedContextFolder.subitem([
|
|
866
856
|
'wiring',
|
|
867
|
-
'application',
|
|
868
857
|
'use-cases'
|
|
869
858
|
]).createFile(`wire-${naming.fileName}-use-case.ts`, `
|
|
870
859
|
import { wireClass } from '@domain-first/wire'
|
|
871
|
-
import { ${naming.ClassName}UseCase } from '
|
|
860
|
+
import { ${naming.ClassName}UseCase } from '../../application/use-cases/${naming.fileName}-use-case'
|
|
872
861
|
|
|
873
862
|
export const wire${naming.ClassName}UseCase = wireClass(
|
|
874
863
|
${naming.ClassName}UseCase,
|