@domain-first/project-structure 1.0.2 → 1.1.1

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 (3) hide show
  1. package/dist/index.cjs +214 -142
  2. package/dist/index.js +216 -144
  3. package/package.json +2 -2
package/dist/index.cjs CHANGED
@@ -431,100 +431,136 @@ const scaffoldNewCommand = async (boundedContextFolder)=>{
431
431
  message: 'Name: '
432
432
  });
433
433
  const naming = new UnknownFormatNaming(commandName);
434
- const implementationType = await (0, prompts_namespaceObject.input)({
435
- message: 'Command infrastructure implementation type:',
436
- default: ConfigFile.Instance.data.defaultPersistenceLayerImplementation
437
- });
438
- let addTestImplementation = false;
439
- let testImplementationType = '';
440
- addTestImplementation = await (0, prompts_namespaceObject.confirm)({
441
- message: 'Add a test implementation for Command'
434
+ const isOrchestrator = await (0, prompts_namespaceObject.confirm)({
435
+ message: 'Is an orchestrator command (no infrastructure implementations)?'
442
436
  });
443
- if (addTestImplementation) testImplementationType = await (0, prompts_namespaceObject.input)({
444
- message: 'Test Command infrastructure implementation type:',
445
- default: 'in-memory'
446
- });
447
- const implementationTypes = [
448
- implementationType,
449
- testImplementationType
450
- ].filter((x)=>!!x);
451
- for (const implementation of implementationTypes){
452
- const formatNaming = new UnknownFormatNaming(implementation);
453
- infrastructureFolder.subitem([
454
- formatNaming.fileName
455
- ]).createFile(`${formatNaming.fileName}-${naming.fileName}-command.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
456
- import { defineHandler } from '@domain-first/handlers'
457
- import { ${naming.ClassName}Command } from '../../../application/commands/${naming.fileName}-command'
437
+ if (!isOrchestrator) {
438
+ const implementationType = await (0, prompts_namespaceObject.input)({
439
+ message: 'Command infrastructure implementation type:',
440
+ default: ConfigFile.Instance.data.defaultPersistenceLayerImplementation
441
+ });
442
+ let addTestImplementation = false;
443
+ let testImplementationType = '';
444
+ addTestImplementation = await (0, prompts_namespaceObject.confirm)({
445
+ message: 'Add a test implementation for Command'
446
+ });
447
+ if (addTestImplementation) testImplementationType = await (0, prompts_namespaceObject.input)({
448
+ message: 'Test Command infrastructure implementation type:',
449
+ default: 'in-memory'
450
+ });
451
+ const implementationTypes = [
452
+ implementationType,
453
+ testImplementationType
454
+ ].filter((x)=>!!x);
455
+ for (const implementation of implementationTypes){
456
+ const formatNaming = new UnknownFormatNaming(implementation);
457
+ infrastructureFolder.subitem([
458
+ formatNaming.fileName
459
+ ]).createFile(`${formatNaming.fileName}-${naming.fileName}-command.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
460
+ import { defineHandler } from '@domain-first/handlers'
461
+ import { ${naming.ClassName}Command } from '../../../application/commands/${naming.fileName}-command'
458
462
 
459
- export class ${formatNaming.ClassName}${naming.ClassName}Command implements ${naming.ClassName}Command {
460
- constructor() {}
463
+ export class ${formatNaming.ClassName}${naming.ClassName}Command implements ${naming.ClassName}Command {
464
+ constructor() {}
461
465
 
462
- handle = defineHandler({
463
- inputSchema: ${naming.ClassName}Command.inputSchema,
464
- outputSchema: ${naming.ClassName}Command.outputSchema,
465
- handler: async (input) => {
466
- return {}
466
+ handle = defineHandler({
467
+ inputSchema: ${naming.ClassName}Command.inputSchema,
468
+ outputSchema: ${naming.ClassName}Command.outputSchema,
469
+ handler: async (input) => {
470
+ return {}
471
+ }
472
+ })
473
+ }
474
+ `.trim() : `
475
+ import { ${naming.ClassName}Command } from '../../../domain/commands/${naming.fileName}-command'
476
+
477
+ export class ${formatNaming.ClassName}${naming.ClassName}Command implements ${naming.ClassName}Command {
478
+
479
+ }
480
+ `.trim());
481
+ if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
482
+ const wiringFolder = boundedContextFolder.subitem([
483
+ 'wiring',
484
+ 'infrastructure',
485
+ 'commands',
486
+ formatNaming.fileName
487
+ ]);
488
+ wiringFolder.createFile(`wire-${formatNaming.fileName}-${naming.fileName}-command.ts`, `
489
+ import { wireClass } from '@domain-first/wire'
490
+ import { ${formatNaming.ClassName}${naming.ClassName}Command } from '../../../../infrastructure/commands/${formatNaming.fileName}/${formatNaming.fileName}-${naming.fileName}-command'
491
+
492
+ export const wire${formatNaming.ClassName}${naming.ClassName}Command = wireClass(
493
+ ${formatNaming.ClassName}${naming.ClassName}Command,
494
+ []
495
+ )
496
+
497
+ `.trim());
498
+ }
467
499
  }
468
- })
469
- }
470
- `.trim() : `
471
- import { ${naming.ClassName}Command } from '../../../domain/commands/${naming.fileName}-command'
500
+ if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) commandsFolder.createFile(`${naming.fileName}-command.ts`, `
501
+ import type { Handler } from '@domain-first/handlers'
472
502
 
473
- export class ${formatNaming.ClassName}${naming.ClassName}Command implements ${naming.ClassName}Command {
503
+ export abstract class ${naming.ClassName}Command {
504
+ static inputSchema = {}
505
+ static outputSchema = {}
474
506
 
475
- }
476
- `.trim());
507
+ abstract handle: Handler<typeof ${naming.ClassName}Command.inputSchema, typeof ${naming.ClassName}Command.outputSchema>
508
+ }
509
+ `.trim());
510
+ else commandsFolder.createFile(`${naming.fileName}-command.ts`, `
511
+ export abstract class ${naming.ClassName}Command {
512
+
513
+ }`.trim());
477
514
  if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
478
- const wiringFolder = boundedContextFolder.subitem([
515
+ const implementationNaming = new UnknownFormatNaming(implementationType);
516
+ const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
517
+ boundedContextFolder.subitem([
479
518
  'wiring',
480
- 'infrastructure',
481
- 'commands',
482
- formatNaming.fileName
483
- ]);
484
- wiringFolder.createFile(`wire-${formatNaming.fileName}-${naming.fileName}-command.ts`, `
485
- import { wireClass } from '@domain-first/wire'
486
- import { ${formatNaming.ClassName}${naming.ClassName}Command } from '../../../../infrastructure/commands/${formatNaming.fileName}/${formatNaming.fileName}-${naming.fileName}-command'
519
+ 'application',
520
+ 'commands'
521
+ ]).createFile(`wire-${naming.fileName}-command.ts`, `
522
+ import { envBranchedWire } from '../../../../../shared/wiring/env-branched-wire'
523
+ ${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { wire${ClassName}${naming.ClassName}Command } from '../../infrastructure/commands/${fileName}/wire-${fileName}-${naming.fileName}-command'`).join('\n')}
487
524
 
488
- export const wire${formatNaming.ClassName}${naming.ClassName}Command = wireClass(
489
- ${formatNaming.ClassName}${naming.ClassName}Command,
490
- []
491
- )
492
-
493
- `.trim());
525
+ export const wire${naming.ClassName}Command = envBranchedWire({
526
+ test: wire${addTestImplementation ? testImplementationNaming.ClassName : implementationNaming.ClassName}${naming.ClassName}Command,
527
+ development: wire${implementationNaming.ClassName}${naming.ClassName}Command,
528
+ production: wire${implementationNaming.ClassName}${naming.ClassName}Command
529
+ })
530
+ `.trim());
494
531
  }
532
+ return;
495
533
  }
496
534
  if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) commandsFolder.createFile(`${naming.fileName}-command.ts`, `
497
- import type { Handler } from '@domain-first/handlers'
535
+ import { defineHandler, type Handler } from '@domain-first/handlers'
498
536
 
499
- export abstract class ${naming.ClassName}Command {
537
+ export class ${naming.ClassName}Command {
500
538
  static inputSchema = {}
501
539
  static outputSchema = {}
502
540
 
503
- abstract handle: Handler<typeof ${naming.ClassName}Command.inputSchema, typeof ${naming.ClassName}Command.outputSchema>
541
+ handle = defineHandler({
542
+ inputSchema: ${naming.ClassName}Command.inputSchema,
543
+ outputSchema: ${naming.ClassName}Command.outputSchema,
544
+ handler: async (payload) => {
545
+ return {}
546
+ }
547
+ })
504
548
  }
505
549
  `.trim());
506
550
  else commandsFolder.createFile(`${naming.fileName}-command.ts`, `
507
- export abstract class ${naming.ClassName}Command {
551
+ export class ${naming.ClassName}Command {
508
552
 
509
553
  }`.trim());
510
- if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
511
- const implementationNaming = new UnknownFormatNaming(implementationType);
512
- const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
513
- boundedContextFolder.subitem([
514
- 'wiring',
515
- 'application',
516
- 'commands'
517
- ]).createFile(`wire-${naming.fileName}-command.ts`, `
518
- import { envBranchedWire } from '../../../../../shared/wiring/env-branched-wire'
519
- ${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { wire${ClassName}${naming.ClassName}Command } from '../../infrastructure/commands/${fileName}/wire-${fileName}-${naming.fileName}-command'`).join('\n')}
554
+ if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) boundedContextFolder.subitem([
555
+ 'wiring',
556
+ 'application',
557
+ 'commands'
558
+ ]).createFile(`wire-${naming.fileName}-command.ts`, `
559
+ import { wireClass } from '@domain-first/wire'
560
+ import { ${naming.ClassName}Command } from '../../../application/commands/${naming.fileName}-command'
520
561
 
521
- export const wire${naming.ClassName}Command = envBranchedWire({
522
- test: wire${addTestImplementation ? testImplementationNaming.ClassName : implementationNaming.ClassName}${naming.ClassName}Command,
523
- development: wire${implementationNaming.ClassName}${naming.ClassName}Command,
524
- production: wire${implementationNaming.ClassName}${naming.ClassName}Command
525
- })
562
+ export const wire${naming.ClassName}Command = wireClass(${naming.ClassName}Command, [])
526
563
  `.trim());
527
- }
528
564
  };
529
565
  const scaffoldNewDomainService = async (boundedContextFolder)=>{
530
566
  const portName = await (0, prompts_namespaceObject.input)({
@@ -649,7 +685,7 @@ export class ${endpointNaming.ClassName} {
649
685
 
650
686
  get handle() {
651
687
  return this.endpointGenerator(this.logic, {
652
- route: { method: '${method}', path: ['${boundedContextFolder.name}-${controller}'${path.length ? `, ${path.map((x)=>`'${x}'`).join(', ')}` : ''}] },
688
+ route: { method: '${method}', path: ['${boundedContextFolder.name}/${controller}'${path.length ? `, ${path.map((x)=>`'${x}'`).join(', ')}` : ''}] },
653
689
  tags: ['${boundedContextFolder.name}: ${controller}'],
654
690
  })
655
691
  }
@@ -690,99 +726,135 @@ const scaffoldNewQuery = async (boundedContextFolder)=>{
690
726
  message: 'Name: '
691
727
  });
692
728
  const naming = new UnknownFormatNaming(queryName);
693
- const implementationType = await (0, prompts_namespaceObject.input)({
694
- message: 'Query infrastructure implementation type:',
695
- default: ConfigFile.Instance.data.defaultPersistenceLayerImplementation
696
- });
697
- let addTestImplementation = false;
698
- let testImplementationType = '';
699
- addTestImplementation = await (0, prompts_namespaceObject.confirm)({
700
- message: 'Add a test implementation for Query'
729
+ const isOrchestrator = await (0, prompts_namespaceObject.confirm)({
730
+ message: 'Is an orchestrator query (no infrastructure implementations)?'
701
731
  });
702
- if (addTestImplementation) testImplementationType = await (0, prompts_namespaceObject.input)({
703
- message: 'Test Query infrastructure implementation type:',
704
- default: 'in-memory'
705
- });
706
- const implementationTypes = [
707
- implementationType,
708
- testImplementationType
709
- ].filter((x)=>!!x);
710
- for (const implementation of implementationTypes){
711
- const formatNaming = new UnknownFormatNaming(implementation);
712
- infrastructureFolder.subitem([
713
- formatNaming.fileName
714
- ]).createFile(`${formatNaming.fileName}-${naming.fileName}-query.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
715
- import { defineHandler } from '@domain-first/handlers'
716
- import { ${naming.ClassName}Query } from '../../../application/queries/${naming.fileName}-query'
732
+ if (!isOrchestrator) {
733
+ const implementationType = await (0, prompts_namespaceObject.input)({
734
+ message: 'Query infrastructure implementation type:',
735
+ default: ConfigFile.Instance.data.defaultPersistenceLayerImplementation
736
+ });
737
+ let addTestImplementation = false;
738
+ let testImplementationType = '';
739
+ addTestImplementation = await (0, prompts_namespaceObject.confirm)({
740
+ message: 'Add a test implementation for Query'
741
+ });
742
+ if (addTestImplementation) testImplementationType = await (0, prompts_namespaceObject.input)({
743
+ message: 'Test Query infrastructure implementation type:',
744
+ default: 'in-memory'
745
+ });
746
+ const implementationTypes = [
747
+ implementationType,
748
+ testImplementationType
749
+ ].filter((x)=>!!x);
750
+ for (const implementation of implementationTypes){
751
+ const formatNaming = new UnknownFormatNaming(implementation);
752
+ infrastructureFolder.subitem([
753
+ formatNaming.fileName
754
+ ]).createFile(`${formatNaming.fileName}-${naming.fileName}-query.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
755
+ import { defineHandler } from '@domain-first/handlers'
756
+ import { ${naming.ClassName}Query } from '../../../application/queries/${naming.fileName}-query'
717
757
 
718
- export class ${formatNaming.ClassName}${naming.ClassName}Query implements ${naming.ClassName}Query {
719
- constructor() {}
758
+ export class ${formatNaming.ClassName}${naming.ClassName}Query implements ${naming.ClassName}Query {
759
+ constructor() {}
720
760
 
721
- handle = defineHandler({
722
- inputSchema: ${naming.ClassName}Query.inputSchema,
723
- outputSchema: ${naming.ClassName}Query.outputSchema,
724
- handler: async (input) => {
725
- return {}
761
+ handle = defineHandler({
762
+ inputSchema: ${naming.ClassName}Query.inputSchema,
763
+ outputSchema: ${naming.ClassName}Query.outputSchema,
764
+ handler: async (input) => {
765
+ return {}
766
+ }
767
+ })
768
+ }
769
+ `.trim() : `
770
+ import { ${naming.ClassName}Query } from '../../../domain/queries/${naming.fileName}-query'
771
+
772
+ export class ${formatNaming.ClassName}${naming.ClassName}Query implements ${naming.ClassName}Query {
773
+
774
+ }
775
+ `.trim());
776
+ if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
777
+ const wiringFolder = boundedContextFolder.subitem([
778
+ 'wiring',
779
+ 'infrastructure',
780
+ 'queries',
781
+ formatNaming.fileName
782
+ ]);
783
+ wiringFolder.createFile(`wire-${formatNaming.fileName}-${naming.fileName}-query.ts`, `
784
+ import { wireClass } from '@domain-first/wire'
785
+ import { ${formatNaming.ClassName}${naming.ClassName}Query } from '../../../../infrastructure/queries/${formatNaming.fileName}/${formatNaming.fileName}-${naming.fileName}-query'
786
+
787
+ export const wire${formatNaming.ClassName}${naming.ClassName}Query = wireClass(
788
+ ${formatNaming.ClassName}${naming.ClassName}Query,
789
+ []
790
+ )
791
+ `.trim());
792
+ }
726
793
  }
727
- })
728
- }
729
- `.trim() : `
730
- import { ${naming.ClassName}Query } from '../../../domain/queries/${naming.fileName}-query'
794
+ if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) queriesFolder.createFile(`${naming.fileName}-query.ts`, `
795
+ import type { Handler } from '@domain-first/handlers'
731
796
 
732
- export class ${formatNaming.ClassName}${naming.ClassName}Query implements ${naming.ClassName}Query {
797
+ export abstract class ${naming.ClassName}Query {
798
+ static inputSchema = {}
799
+ static outputSchema = {}
733
800
 
734
- }
735
- `.trim());
801
+ abstract handle: Handler<typeof ${naming.ClassName}Query.inputSchema, typeof ${naming.ClassName}Query.outputSchema>
802
+ }
803
+ `.trim());
804
+ else queriesFolder.createFile(`${naming.fileName}-query.ts`, `
805
+ export abstract class ${naming.ClassName}Query {
806
+
807
+ }`.trim());
736
808
  if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
737
- const wiringFolder = boundedContextFolder.subitem([
809
+ const implementationNaming = new UnknownFormatNaming(implementationType);
810
+ const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
811
+ boundedContextFolder.subitem([
738
812
  'wiring',
739
- 'infrastructure',
740
- 'queries',
741
- formatNaming.fileName
742
- ]);
743
- wiringFolder.createFile(`wire-${formatNaming.fileName}-${naming.fileName}-query.ts`, `
744
- import { wireClass } from '@domain-first/wire'
745
- import { ${formatNaming.ClassName}${naming.ClassName}Query } from '../../../../infrastructure/queries/${formatNaming.fileName}/${formatNaming.fileName}-${naming.fileName}-query'
813
+ 'application',
814
+ 'queries'
815
+ ]).createFile(`wire-${naming.fileName}-query.ts`, `
816
+ import { envBranchedWire } from '../../../../../shared/wiring/env-branched-wire'
817
+ ${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { wire${ClassName}${naming.ClassName}Query } from '../../infrastructure/queries/${fileName}/wire-${fileName}-${naming.fileName}-query'`).join('\n')}
746
818
 
747
- export const wire${formatNaming.ClassName}${naming.ClassName}Query = wireClass(
748
- ${formatNaming.ClassName}${naming.ClassName}Query,
749
- []
750
- )
751
- `.trim());
819
+ export const wire${naming.ClassName}Query = envBranchedWire({
820
+ test: wire${addTestImplementation ? testImplementationNaming.ClassName : implementationNaming.ClassName}${naming.ClassName}Query,
821
+ development: wire${implementationNaming.ClassName}${naming.ClassName}Query,
822
+ production: wire${implementationNaming.ClassName}${naming.ClassName}Query
823
+ })
824
+ `.trim());
752
825
  }
826
+ return;
753
827
  }
754
828
  if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) queriesFolder.createFile(`${naming.fileName}-query.ts`, `
755
- import type { Handler } from '@domain-first/handlers'
829
+ import { defineHandler, type Handler } from '@domain-first/handlers'
756
830
 
757
- export abstract class ${naming.ClassName}Query {
831
+ export class ${naming.ClassName}Query {
758
832
  static inputSchema = {}
759
833
  static outputSchema = {}
760
834
 
761
- abstract handle: Handler<typeof ${naming.ClassName}Query.inputSchema, typeof ${naming.ClassName}Query.outputSchema>
835
+ handle = defineHandler({
836
+ inputSchema: ${naming.ClassName}Query.inputSchema,
837
+ outputSchema: ${naming.ClassName}Query.outputSchema,
838
+ handler: async (payload) => {
839
+ return {}
840
+ }
841
+ })
762
842
  }
763
843
  `.trim());
764
844
  else queriesFolder.createFile(`${naming.fileName}-query.ts`, `
765
- export abstract class ${naming.ClassName}Query {
845
+ export class ${naming.ClassName}Query {
766
846
 
767
847
  }`.trim());
768
- if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
769
- const implementationNaming = new UnknownFormatNaming(implementationType);
770
- const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
771
- boundedContextFolder.subitem([
772
- 'wiring',
773
- 'application',
774
- 'queries'
775
- ]).createFile(`wire-${naming.fileName}-query.ts`, `
776
- import { envBranchedWire } from '../../../../../shared/wiring/env-branched-wire'
777
- ${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { wire${ClassName}${naming.ClassName}Query } from '../../infrastructure/queries/${fileName}/wire-${fileName}-${naming.fileName}-query'`).join('\n')}
848
+ if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) boundedContextFolder.subitem([
849
+ 'wiring',
850
+ 'application',
851
+ 'queries'
852
+ ]).createFile(`wire-${naming.fileName}-query.ts`, `
853
+ import { wireClass } from '@domain-first/wire'
854
+ import { ${naming.ClassName}Query } from '../../../application/queries/${naming.fileName}-query'
778
855
 
779
- export const wire${naming.ClassName}Query = envBranchedWire({
780
- test: wire${addTestImplementation ? testImplementationNaming.ClassName : implementationNaming.ClassName}${naming.ClassName}Query,
781
- development: wire${implementationNaming.ClassName}${naming.ClassName}Query,
782
- production: wire${implementationNaming.ClassName}${naming.ClassName}Query
783
- })
856
+ export const wire${naming.ClassName}Query = wireClass(${naming.ClassName}Query, [])
784
857
  `.trim());
785
- }
786
858
  };
787
859
  const scaffoldNewUseCase = async (boundedContextFolder)=>{
788
860
  const useCasesFolder = boundedContextFolder.subitem([
package/dist/index.js CHANGED
@@ -401,100 +401,136 @@ const scaffoldNewCommand = async (boundedContextFolder)=>{
401
401
  message: 'Name: '
402
402
  });
403
403
  const naming = new UnknownFormatNaming(commandName);
404
- const implementationType = await input({
405
- message: 'Command infrastructure implementation type:',
406
- default: ConfigFile.Instance.data.defaultPersistenceLayerImplementation
407
- });
408
- let addTestImplementation = false;
409
- let testImplementationType = '';
410
- addTestImplementation = await prompts_confirm({
411
- message: 'Add a test implementation for Command'
412
- });
413
- if (addTestImplementation) testImplementationType = await input({
414
- message: 'Test Command infrastructure implementation type:',
415
- default: 'in-memory'
404
+ const isOrchestrator = await prompts_confirm({
405
+ message: 'Is an orchestrator command (no infrastructure implementations)?'
416
406
  });
417
- const implementationTypes = [
418
- implementationType,
419
- testImplementationType
420
- ].filter((x)=>!!x);
421
- for (const implementation of implementationTypes){
422
- const formatNaming = new UnknownFormatNaming(implementation);
423
- infrastructureFolder.subitem([
424
- formatNaming.fileName
425
- ]).createFile(`${formatNaming.fileName}-${naming.fileName}-command.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
426
- import { defineHandler } from '@domain-first/handlers'
427
- import { ${naming.ClassName}Command } from '../../../application/commands/${naming.fileName}-command'
407
+ if (!isOrchestrator) {
408
+ const implementationType = await input({
409
+ message: 'Command infrastructure implementation type:',
410
+ default: ConfigFile.Instance.data.defaultPersistenceLayerImplementation
411
+ });
412
+ let addTestImplementation = false;
413
+ let testImplementationType = '';
414
+ addTestImplementation = await prompts_confirm({
415
+ message: 'Add a test implementation for Command'
416
+ });
417
+ if (addTestImplementation) testImplementationType = await input({
418
+ message: 'Test Command infrastructure implementation type:',
419
+ default: 'in-memory'
420
+ });
421
+ const implementationTypes = [
422
+ implementationType,
423
+ testImplementationType
424
+ ].filter((x)=>!!x);
425
+ for (const implementation of implementationTypes){
426
+ const formatNaming = new UnknownFormatNaming(implementation);
427
+ infrastructureFolder.subitem([
428
+ formatNaming.fileName
429
+ ]).createFile(`${formatNaming.fileName}-${naming.fileName}-command.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
430
+ import { defineHandler } from '@domain-first/handlers'
431
+ import { ${naming.ClassName}Command } from '../../../application/commands/${naming.fileName}-command'
432
+
433
+ export class ${formatNaming.ClassName}${naming.ClassName}Command implements ${naming.ClassName}Command {
434
+ constructor() {}
435
+
436
+ handle = defineHandler({
437
+ inputSchema: ${naming.ClassName}Command.inputSchema,
438
+ outputSchema: ${naming.ClassName}Command.outputSchema,
439
+ handler: async (input) => {
440
+ return {}
441
+ }
442
+ })
443
+ }
444
+ `.trim() : `
445
+ import { ${naming.ClassName}Command } from '../../../domain/commands/${naming.fileName}-command'
428
446
 
429
- export class ${formatNaming.ClassName}${naming.ClassName}Command implements ${naming.ClassName}Command {
430
- constructor() {}
447
+ export class ${formatNaming.ClassName}${naming.ClassName}Command implements ${naming.ClassName}Command {
431
448
 
432
- handle = defineHandler({
433
- inputSchema: ${naming.ClassName}Command.inputSchema,
434
- outputSchema: ${naming.ClassName}Command.outputSchema,
435
- handler: async (input) => {
436
- return {}
449
+ }
450
+ `.trim());
451
+ if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
452
+ const wiringFolder = boundedContextFolder.subitem([
453
+ 'wiring',
454
+ 'infrastructure',
455
+ 'commands',
456
+ formatNaming.fileName
457
+ ]);
458
+ wiringFolder.createFile(`wire-${formatNaming.fileName}-${naming.fileName}-command.ts`, `
459
+ import { wireClass } from '@domain-first/wire'
460
+ import { ${formatNaming.ClassName}${naming.ClassName}Command } from '../../../../infrastructure/commands/${formatNaming.fileName}/${formatNaming.fileName}-${naming.fileName}-command'
461
+
462
+ export const wire${formatNaming.ClassName}${naming.ClassName}Command = wireClass(
463
+ ${formatNaming.ClassName}${naming.ClassName}Command,
464
+ []
465
+ )
466
+
467
+ `.trim());
468
+ }
437
469
  }
438
- })
439
- }
440
- `.trim() : `
441
- import { ${naming.ClassName}Command } from '../../../domain/commands/${naming.fileName}-command'
470
+ if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) commandsFolder.createFile(`${naming.fileName}-command.ts`, `
471
+ import type { Handler } from '@domain-first/handlers'
442
472
 
443
- export class ${formatNaming.ClassName}${naming.ClassName}Command implements ${naming.ClassName}Command {
473
+ export abstract class ${naming.ClassName}Command {
474
+ static inputSchema = {}
475
+ static outputSchema = {}
444
476
 
445
- }
446
- `.trim());
477
+ abstract handle: Handler<typeof ${naming.ClassName}Command.inputSchema, typeof ${naming.ClassName}Command.outputSchema>
478
+ }
479
+ `.trim());
480
+ else commandsFolder.createFile(`${naming.fileName}-command.ts`, `
481
+ export abstract class ${naming.ClassName}Command {
482
+
483
+ }`.trim());
447
484
  if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
448
- const wiringFolder = boundedContextFolder.subitem([
485
+ const implementationNaming = new UnknownFormatNaming(implementationType);
486
+ const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
487
+ boundedContextFolder.subitem([
449
488
  'wiring',
450
- 'infrastructure',
451
- 'commands',
452
- formatNaming.fileName
453
- ]);
454
- wiringFolder.createFile(`wire-${formatNaming.fileName}-${naming.fileName}-command.ts`, `
455
- import { wireClass } from '@domain-first/wire'
456
- import { ${formatNaming.ClassName}${naming.ClassName}Command } from '../../../../infrastructure/commands/${formatNaming.fileName}/${formatNaming.fileName}-${naming.fileName}-command'
457
-
458
- export const wire${formatNaming.ClassName}${naming.ClassName}Command = wireClass(
459
- ${formatNaming.ClassName}${naming.ClassName}Command,
460
- []
461
- )
462
-
463
- `.trim());
489
+ 'application',
490
+ 'commands'
491
+ ]).createFile(`wire-${naming.fileName}-command.ts`, `
492
+ import { envBranchedWire } from '../../../../../shared/wiring/env-branched-wire'
493
+ ${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { wire${ClassName}${naming.ClassName}Command } from '../../infrastructure/commands/${fileName}/wire-${fileName}-${naming.fileName}-command'`).join('\n')}
494
+
495
+ export const wire${naming.ClassName}Command = envBranchedWire({
496
+ test: wire${addTestImplementation ? testImplementationNaming.ClassName : implementationNaming.ClassName}${naming.ClassName}Command,
497
+ development: wire${implementationNaming.ClassName}${naming.ClassName}Command,
498
+ production: wire${implementationNaming.ClassName}${naming.ClassName}Command
499
+ })
500
+ `.trim());
464
501
  }
502
+ return;
465
503
  }
466
504
  if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) commandsFolder.createFile(`${naming.fileName}-command.ts`, `
467
- import type { Handler } from '@domain-first/handlers'
505
+ import { defineHandler, type Handler } from '@domain-first/handlers'
468
506
 
469
- export abstract class ${naming.ClassName}Command {
507
+ export class ${naming.ClassName}Command {
470
508
  static inputSchema = {}
471
509
  static outputSchema = {}
472
510
 
473
- abstract handle: Handler<typeof ${naming.ClassName}Command.inputSchema, typeof ${naming.ClassName}Command.outputSchema>
511
+ handle = defineHandler({
512
+ inputSchema: ${naming.ClassName}Command.inputSchema,
513
+ outputSchema: ${naming.ClassName}Command.outputSchema,
514
+ handler: async (payload) => {
515
+ return {}
516
+ }
517
+ })
474
518
  }
475
519
  `.trim());
476
520
  else commandsFolder.createFile(`${naming.fileName}-command.ts`, `
477
- export abstract class ${naming.ClassName}Command {
521
+ export class ${naming.ClassName}Command {
478
522
 
479
523
  }`.trim());
480
- if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
481
- const implementationNaming = new UnknownFormatNaming(implementationType);
482
- const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
483
- boundedContextFolder.subitem([
484
- 'wiring',
485
- 'application',
486
- 'commands'
487
- ]).createFile(`wire-${naming.fileName}-command.ts`, `
488
- import { envBranchedWire } from '../../../../../shared/wiring/env-branched-wire'
489
- ${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { wire${ClassName}${naming.ClassName}Command } from '../../infrastructure/commands/${fileName}/wire-${fileName}-${naming.fileName}-command'`).join('\n')}
524
+ if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) boundedContextFolder.subitem([
525
+ 'wiring',
526
+ 'application',
527
+ 'commands'
528
+ ]).createFile(`wire-${naming.fileName}-command.ts`, `
529
+ import { wireClass } from '@domain-first/wire'
530
+ import { ${naming.ClassName}Command } from '../../../application/commands/${naming.fileName}-command'
490
531
 
491
- export const wire${naming.ClassName}Command = envBranchedWire({
492
- test: wire${addTestImplementation ? testImplementationNaming.ClassName : implementationNaming.ClassName}${naming.ClassName}Command,
493
- development: wire${implementationNaming.ClassName}${naming.ClassName}Command,
494
- production: wire${implementationNaming.ClassName}${naming.ClassName}Command
495
- })
532
+ export const wire${naming.ClassName}Command = wireClass(${naming.ClassName}Command, [])
496
533
  `.trim());
497
- }
498
534
  };
499
535
  const scaffoldNewDomainService = async (boundedContextFolder)=>{
500
536
  const portName = await input({
@@ -619,7 +655,7 @@ export class ${endpointNaming.ClassName} {
619
655
 
620
656
  get handle() {
621
657
  return this.endpointGenerator(this.logic, {
622
- route: { method: '${method}', path: ['${boundedContextFolder.name}-${controller}'${path.length ? `, ${path.map((x)=>`'${x}'`).join(', ')}` : ''}] },
658
+ route: { method: '${method}', path: ['${boundedContextFolder.name}/${controller}'${path.length ? `, ${path.map((x)=>`'${x}'`).join(', ')}` : ''}] },
623
659
  tags: ['${boundedContextFolder.name}: ${controller}'],
624
660
  })
625
661
  }
@@ -660,99 +696,135 @@ const scaffoldNewQuery = async (boundedContextFolder)=>{
660
696
  message: 'Name: '
661
697
  });
662
698
  const naming = new UnknownFormatNaming(queryName);
663
- const implementationType = await input({
664
- message: 'Query infrastructure implementation type:',
665
- default: ConfigFile.Instance.data.defaultPersistenceLayerImplementation
666
- });
667
- let addTestImplementation = false;
668
- let testImplementationType = '';
669
- addTestImplementation = await prompts_confirm({
670
- message: 'Add a test implementation for Query'
671
- });
672
- if (addTestImplementation) testImplementationType = await input({
673
- message: 'Test Query infrastructure implementation type:',
674
- default: 'in-memory'
699
+ const isOrchestrator = await prompts_confirm({
700
+ message: 'Is an orchestrator query (no infrastructure implementations)?'
675
701
  });
676
- const implementationTypes = [
677
- implementationType,
678
- testImplementationType
679
- ].filter((x)=>!!x);
680
- for (const implementation of implementationTypes){
681
- const formatNaming = new UnknownFormatNaming(implementation);
682
- infrastructureFolder.subitem([
683
- formatNaming.fileName
684
- ]).createFile(`${formatNaming.fileName}-${naming.fileName}-query.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
685
- import { defineHandler } from '@domain-first/handlers'
686
- import { ${naming.ClassName}Query } from '../../../application/queries/${naming.fileName}-query'
702
+ if (!isOrchestrator) {
703
+ const implementationType = await input({
704
+ message: 'Query infrastructure implementation type:',
705
+ default: ConfigFile.Instance.data.defaultPersistenceLayerImplementation
706
+ });
707
+ let addTestImplementation = false;
708
+ let testImplementationType = '';
709
+ addTestImplementation = await prompts_confirm({
710
+ message: 'Add a test implementation for Query'
711
+ });
712
+ if (addTestImplementation) testImplementationType = await input({
713
+ message: 'Test Query infrastructure implementation type:',
714
+ default: 'in-memory'
715
+ });
716
+ const implementationTypes = [
717
+ implementationType,
718
+ testImplementationType
719
+ ].filter((x)=>!!x);
720
+ for (const implementation of implementationTypes){
721
+ const formatNaming = new UnknownFormatNaming(implementation);
722
+ infrastructureFolder.subitem([
723
+ formatNaming.fileName
724
+ ]).createFile(`${formatNaming.fileName}-${naming.fileName}-query.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
725
+ import { defineHandler } from '@domain-first/handlers'
726
+ import { ${naming.ClassName}Query } from '../../../application/queries/${naming.fileName}-query'
727
+
728
+ export class ${formatNaming.ClassName}${naming.ClassName}Query implements ${naming.ClassName}Query {
729
+ constructor() {}
730
+
731
+ handle = defineHandler({
732
+ inputSchema: ${naming.ClassName}Query.inputSchema,
733
+ outputSchema: ${naming.ClassName}Query.outputSchema,
734
+ handler: async (input) => {
735
+ return {}
736
+ }
737
+ })
738
+ }
739
+ `.trim() : `
740
+ import { ${naming.ClassName}Query } from '../../../domain/queries/${naming.fileName}-query'
687
741
 
688
- export class ${formatNaming.ClassName}${naming.ClassName}Query implements ${naming.ClassName}Query {
689
- constructor() {}
742
+ export class ${formatNaming.ClassName}${naming.ClassName}Query implements ${naming.ClassName}Query {
690
743
 
691
- handle = defineHandler({
692
- inputSchema: ${naming.ClassName}Query.inputSchema,
693
- outputSchema: ${naming.ClassName}Query.outputSchema,
694
- handler: async (input) => {
695
- return {}
744
+ }
745
+ `.trim());
746
+ if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
747
+ const wiringFolder = boundedContextFolder.subitem([
748
+ 'wiring',
749
+ 'infrastructure',
750
+ 'queries',
751
+ formatNaming.fileName
752
+ ]);
753
+ wiringFolder.createFile(`wire-${formatNaming.fileName}-${naming.fileName}-query.ts`, `
754
+ import { wireClass } from '@domain-first/wire'
755
+ import { ${formatNaming.ClassName}${naming.ClassName}Query } from '../../../../infrastructure/queries/${formatNaming.fileName}/${formatNaming.fileName}-${naming.fileName}-query'
756
+
757
+ export const wire${formatNaming.ClassName}${naming.ClassName}Query = wireClass(
758
+ ${formatNaming.ClassName}${naming.ClassName}Query,
759
+ []
760
+ )
761
+ `.trim());
762
+ }
696
763
  }
697
- })
698
- }
699
- `.trim() : `
700
- import { ${naming.ClassName}Query } from '../../../domain/queries/${naming.fileName}-query'
764
+ if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) queriesFolder.createFile(`${naming.fileName}-query.ts`, `
765
+ import type { Handler } from '@domain-first/handlers'
701
766
 
702
- export class ${formatNaming.ClassName}${naming.ClassName}Query implements ${naming.ClassName}Query {
767
+ export abstract class ${naming.ClassName}Query {
768
+ static inputSchema = {}
769
+ static outputSchema = {}
703
770
 
704
- }
705
- `.trim());
771
+ abstract handle: Handler<typeof ${naming.ClassName}Query.inputSchema, typeof ${naming.ClassName}Query.outputSchema>
772
+ }
773
+ `.trim());
774
+ else queriesFolder.createFile(`${naming.fileName}-query.ts`, `
775
+ export abstract class ${naming.ClassName}Query {
776
+
777
+ }`.trim());
706
778
  if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
707
- const wiringFolder = boundedContextFolder.subitem([
779
+ const implementationNaming = new UnknownFormatNaming(implementationType);
780
+ const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
781
+ boundedContextFolder.subitem([
708
782
  'wiring',
709
- 'infrastructure',
710
- 'queries',
711
- formatNaming.fileName
712
- ]);
713
- wiringFolder.createFile(`wire-${formatNaming.fileName}-${naming.fileName}-query.ts`, `
714
- import { wireClass } from '@domain-first/wire'
715
- import { ${formatNaming.ClassName}${naming.ClassName}Query } from '../../../../infrastructure/queries/${formatNaming.fileName}/${formatNaming.fileName}-${naming.fileName}-query'
716
-
717
- export const wire${formatNaming.ClassName}${naming.ClassName}Query = wireClass(
718
- ${formatNaming.ClassName}${naming.ClassName}Query,
719
- []
720
- )
721
- `.trim());
783
+ 'application',
784
+ 'queries'
785
+ ]).createFile(`wire-${naming.fileName}-query.ts`, `
786
+ import { envBranchedWire } from '../../../../../shared/wiring/env-branched-wire'
787
+ ${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { wire${ClassName}${naming.ClassName}Query } from '../../infrastructure/queries/${fileName}/wire-${fileName}-${naming.fileName}-query'`).join('\n')}
788
+
789
+ export const wire${naming.ClassName}Query = envBranchedWire({
790
+ test: wire${addTestImplementation ? testImplementationNaming.ClassName : implementationNaming.ClassName}${naming.ClassName}Query,
791
+ development: wire${implementationNaming.ClassName}${naming.ClassName}Query,
792
+ production: wire${implementationNaming.ClassName}${naming.ClassName}Query
793
+ })
794
+ `.trim());
722
795
  }
796
+ return;
723
797
  }
724
798
  if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) queriesFolder.createFile(`${naming.fileName}-query.ts`, `
725
- import type { Handler } from '@domain-first/handlers'
799
+ import { defineHandler, type Handler } from '@domain-first/handlers'
726
800
 
727
- export abstract class ${naming.ClassName}Query {
801
+ export class ${naming.ClassName}Query {
728
802
  static inputSchema = {}
729
803
  static outputSchema = {}
730
804
 
731
- abstract handle: Handler<typeof ${naming.ClassName}Query.inputSchema, typeof ${naming.ClassName}Query.outputSchema>
805
+ handle = defineHandler({
806
+ inputSchema: ${naming.ClassName}Query.inputSchema,
807
+ outputSchema: ${naming.ClassName}Query.outputSchema,
808
+ handler: async (payload) => {
809
+ return {}
810
+ }
811
+ })
732
812
  }
733
813
  `.trim());
734
814
  else queriesFolder.createFile(`${naming.fileName}-query.ts`, `
735
- export abstract class ${naming.ClassName}Query {
815
+ export class ${naming.ClassName}Query {
736
816
 
737
817
  }`.trim());
738
- if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
739
- const implementationNaming = new UnknownFormatNaming(implementationType);
740
- const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
741
- boundedContextFolder.subitem([
742
- 'wiring',
743
- 'application',
744
- 'queries'
745
- ]).createFile(`wire-${naming.fileName}-query.ts`, `
746
- import { envBranchedWire } from '../../../../../shared/wiring/env-branched-wire'
747
- ${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { wire${ClassName}${naming.ClassName}Query } from '../../infrastructure/queries/${fileName}/wire-${fileName}-${naming.fileName}-query'`).join('\n')}
818
+ if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) boundedContextFolder.subitem([
819
+ 'wiring',
820
+ 'application',
821
+ 'queries'
822
+ ]).createFile(`wire-${naming.fileName}-query.ts`, `
823
+ import { wireClass } from '@domain-first/wire'
824
+ import { ${naming.ClassName}Query } from '../../../application/queries/${naming.fileName}-query'
748
825
 
749
- export const wire${naming.ClassName}Query = envBranchedWire({
750
- test: wire${addTestImplementation ? testImplementationNaming.ClassName : implementationNaming.ClassName}${naming.ClassName}Query,
751
- development: wire${implementationNaming.ClassName}${naming.ClassName}Query,
752
- production: wire${implementationNaming.ClassName}${naming.ClassName}Query
753
- })
826
+ export const wire${naming.ClassName}Query = wireClass(${naming.ClassName}Query, [])
754
827
  `.trim());
755
- }
756
828
  };
757
829
  const scaffoldNewUseCase = async (boundedContextFolder)=>{
758
830
  const useCasesFolder = boundedContextFolder.subitem([
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@domain-first/project-structure",
3
3
  "description": "Build and manage your Domain-First project structure with CLI",
4
- "version": "1.0.2",
4
+ "version": "1.1.1",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
@@ -42,7 +42,7 @@
42
42
  "test:watch": "rstest --watch"
43
43
  },
44
44
  "devDependencies": {
45
- "@biomejs/biome": "2.4.15",
45
+ "@biomejs/biome": "2.4.2",
46
46
  "@domain-first/errors": "^4.0.4",
47
47
  "@domain-first/handlers": "^4.0.4",
48
48
  "@domain-first/handlers-rest": "^5.1.0",