@domain-first/project-structure 1.0.1 → 1.1.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 +220 -146
- package/dist/index.js +222 -148
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -323,8 +323,7 @@ const scaffoldNewApplicationPort = async (boundedContextFolder)=>{
|
|
|
323
323
|
const wiringFolder = boundedContextFolder.subitem([
|
|
324
324
|
'wiring',
|
|
325
325
|
'application',
|
|
326
|
-
'ports'
|
|
327
|
-
naming.fileName
|
|
326
|
+
'ports'
|
|
328
327
|
]);
|
|
329
328
|
const infraFolder = boundedContextFolder.subitem([
|
|
330
329
|
'wiring',
|
|
@@ -383,11 +382,11 @@ export const wire${currentNaming.ClassName} = wireClass(
|
|
|
383
382
|
`.trim());
|
|
384
383
|
}
|
|
385
384
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) wiringFolder.createFile(`wire-${naming.fileName}.ts`, `
|
|
386
|
-
import { envBranchedWire } from '
|
|
385
|
+
import { envBranchedWire } from '../../../../${'shared' === boundedContextFolder.name ? '' : '../'}shared/wiring/env-branched-wire'
|
|
387
386
|
${implementationTypes.map((x)=>({
|
|
388
387
|
naming: new UnknownFormatNaming(`${x}-${naming.fileName}`),
|
|
389
388
|
implementation: x
|
|
390
|
-
})).map(({ naming: { ClassName, fileName }, implementation })=>`import { wire${ClassName} } from '
|
|
389
|
+
})).map(({ naming: { ClassName, fileName }, implementation })=>`import { wire${ClassName} } from '../../infrastructure/application-ports/${implementation}/wire-${fileName}'`).join('\n')}
|
|
391
390
|
|
|
392
391
|
export const wire${naming.ClassName} = envBranchedWire({
|
|
393
392
|
test: wire${new UnknownFormatNaming(`${implementationTypes.at(-1)}-${naming.fileName}`).ClassName},
|
|
@@ -432,100 +431,136 @@ const scaffoldNewCommand = async (boundedContextFolder)=>{
|
|
|
432
431
|
message: 'Name: '
|
|
433
432
|
});
|
|
434
433
|
const naming = new UnknownFormatNaming(commandName);
|
|
435
|
-
const
|
|
436
|
-
message: '
|
|
437
|
-
default: ConfigFile.Instance.data.defaultPersistenceLayerImplementation
|
|
438
|
-
});
|
|
439
|
-
let addTestImplementation = false;
|
|
440
|
-
let testImplementationType = '';
|
|
441
|
-
addTestImplementation = await (0, prompts_namespaceObject.confirm)({
|
|
442
|
-
message: 'Add a test implementation for Command'
|
|
443
|
-
});
|
|
444
|
-
if (addTestImplementation) testImplementationType = await (0, prompts_namespaceObject.input)({
|
|
445
|
-
message: 'Test Command infrastructure implementation type:',
|
|
446
|
-
default: 'in-memory'
|
|
434
|
+
const isOrchestrator = await (0, prompts_namespaceObject.confirm)({
|
|
435
|
+
message: 'Is an orchestrator command (no infrastructure implementations)?'
|
|
447
436
|
});
|
|
448
|
-
|
|
449
|
-
implementationType,
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
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'
|
|
459
462
|
|
|
460
|
-
export class ${formatNaming.ClassName}${naming.ClassName}Command implements ${naming.ClassName}Command {
|
|
461
|
-
|
|
463
|
+
export class ${formatNaming.ClassName}${naming.ClassName}Command implements ${naming.ClassName}Command {
|
|
464
|
+
constructor() {}
|
|
462
465
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
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
|
+
}
|
|
468
499
|
}
|
|
469
|
-
|
|
470
|
-
}
|
|
471
|
-
`.trim() : `
|
|
472
|
-
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'
|
|
473
502
|
|
|
474
|
-
export class ${
|
|
503
|
+
export abstract class ${naming.ClassName}Command {
|
|
504
|
+
static inputSchema = {}
|
|
505
|
+
static outputSchema = {}
|
|
475
506
|
|
|
476
|
-
}
|
|
477
|
-
|
|
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());
|
|
478
514
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
479
|
-
const
|
|
515
|
+
const implementationNaming = new UnknownFormatNaming(implementationType);
|
|
516
|
+
const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
|
|
517
|
+
boundedContextFolder.subitem([
|
|
480
518
|
'wiring',
|
|
481
|
-
'
|
|
482
|
-
'commands'
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
import { wireClass } from '@domain-first/wire'
|
|
487
|
-
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')}
|
|
488
524
|
|
|
489
|
-
export const wire${
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
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());
|
|
495
531
|
}
|
|
532
|
+
return;
|
|
496
533
|
}
|
|
497
534
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) commandsFolder.createFile(`${naming.fileName}-command.ts`, `
|
|
498
|
-
import type
|
|
535
|
+
import { defineHandler, type Handler } from '@domain-first/handlers'
|
|
499
536
|
|
|
500
|
-
export
|
|
537
|
+
export class ${naming.ClassName}Command {
|
|
501
538
|
static inputSchema = {}
|
|
502
539
|
static outputSchema = {}
|
|
503
540
|
|
|
504
|
-
|
|
541
|
+
handle = defineHandler({
|
|
542
|
+
inputSchema: ${naming.ClassName}Command.inputSchema,
|
|
543
|
+
outputSchema: ${naming.ClassName}Command.outputSchema,
|
|
544
|
+
handler: async (payload) => {
|
|
545
|
+
return {}
|
|
546
|
+
}
|
|
547
|
+
})
|
|
505
548
|
}
|
|
506
549
|
`.trim());
|
|
507
550
|
else commandsFolder.createFile(`${naming.fileName}-command.ts`, `
|
|
508
|
-
export
|
|
551
|
+
export class ${naming.ClassName}Command {
|
|
509
552
|
|
|
510
553
|
}`.trim());
|
|
511
|
-
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire'))
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
]).createFile(`wire-${naming.fileName}-command.ts`, `
|
|
519
|
-
import { envBranchedWire } from '../../../../../shared/wiring/env-branched-wire'
|
|
520
|
-
${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'
|
|
521
561
|
|
|
522
|
-
export const wire${naming.ClassName}Command =
|
|
523
|
-
test: wire${addTestImplementation ? testImplementationNaming.ClassName : implementationNaming.ClassName}${naming.ClassName}Command,
|
|
524
|
-
development: wire${implementationNaming.ClassName}${naming.ClassName}Command,
|
|
525
|
-
production: wire${implementationNaming.ClassName}${naming.ClassName}Command
|
|
526
|
-
})
|
|
562
|
+
export const wire${naming.ClassName}Command = wireClass(${naming.ClassName}Command, [])
|
|
527
563
|
`.trim());
|
|
528
|
-
}
|
|
529
564
|
};
|
|
530
565
|
const scaffoldNewDomainService = async (boundedContextFolder)=>{
|
|
531
566
|
const portName = await (0, prompts_namespaceObject.input)({
|
|
@@ -691,99 +726,135 @@ const scaffoldNewQuery = async (boundedContextFolder)=>{
|
|
|
691
726
|
message: 'Name: '
|
|
692
727
|
});
|
|
693
728
|
const naming = new UnknownFormatNaming(queryName);
|
|
694
|
-
const
|
|
695
|
-
message: '
|
|
696
|
-
default: ConfigFile.Instance.data.defaultPersistenceLayerImplementation
|
|
697
|
-
});
|
|
698
|
-
let addTestImplementation = false;
|
|
699
|
-
let testImplementationType = '';
|
|
700
|
-
addTestImplementation = await (0, prompts_namespaceObject.confirm)({
|
|
701
|
-
message: 'Add a test implementation for Query'
|
|
729
|
+
const isOrchestrator = await (0, prompts_namespaceObject.confirm)({
|
|
730
|
+
message: 'Is an orchestrator query (no infrastructure implementations)?'
|
|
702
731
|
});
|
|
703
|
-
if (
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
testImplementationType
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
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'
|
|
718
757
|
|
|
719
|
-
export class ${formatNaming.ClassName}${naming.ClassName}Query implements ${naming.ClassName}Query {
|
|
720
|
-
|
|
758
|
+
export class ${formatNaming.ClassName}${naming.ClassName}Query implements ${naming.ClassName}Query {
|
|
759
|
+
constructor() {}
|
|
721
760
|
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
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
|
+
}
|
|
727
793
|
}
|
|
728
|
-
|
|
729
|
-
}
|
|
730
|
-
`.trim() : `
|
|
731
|
-
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'
|
|
732
796
|
|
|
733
|
-
export class ${
|
|
797
|
+
export abstract class ${naming.ClassName}Query {
|
|
798
|
+
static inputSchema = {}
|
|
799
|
+
static outputSchema = {}
|
|
734
800
|
|
|
735
|
-
}
|
|
736
|
-
|
|
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());
|
|
737
808
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
738
|
-
const
|
|
809
|
+
const implementationNaming = new UnknownFormatNaming(implementationType);
|
|
810
|
+
const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
|
|
811
|
+
boundedContextFolder.subitem([
|
|
739
812
|
'wiring',
|
|
740
|
-
'
|
|
741
|
-
'queries'
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
import { wireClass } from '@domain-first/wire'
|
|
746
|
-
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')}
|
|
747
818
|
|
|
748
|
-
export const wire${
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
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());
|
|
753
825
|
}
|
|
826
|
+
return;
|
|
754
827
|
}
|
|
755
828
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) queriesFolder.createFile(`${naming.fileName}-query.ts`, `
|
|
756
|
-
import type
|
|
829
|
+
import { defineHandler, type Handler } from '@domain-first/handlers'
|
|
757
830
|
|
|
758
|
-
export
|
|
831
|
+
export class ${naming.ClassName}Query {
|
|
759
832
|
static inputSchema = {}
|
|
760
833
|
static outputSchema = {}
|
|
761
834
|
|
|
762
|
-
|
|
835
|
+
handle = defineHandler({
|
|
836
|
+
inputSchema: ${naming.ClassName}Query.inputSchema,
|
|
837
|
+
outputSchema: ${naming.ClassName}Query.outputSchema,
|
|
838
|
+
handler: async (payload) => {
|
|
839
|
+
return {}
|
|
840
|
+
}
|
|
841
|
+
})
|
|
763
842
|
}
|
|
764
843
|
`.trim());
|
|
765
844
|
else queriesFolder.createFile(`${naming.fileName}-query.ts`, `
|
|
766
|
-
export
|
|
845
|
+
export class ${naming.ClassName}Query {
|
|
767
846
|
|
|
768
847
|
}`.trim());
|
|
769
|
-
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire'))
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
]).createFile(`wire-${naming.fileName}-query.ts`, `
|
|
777
|
-
import { envBranchedWire } from '../../../../../shared/wiring/env-branched-wire'
|
|
778
|
-
${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'
|
|
779
855
|
|
|
780
|
-
export const wire${naming.ClassName}Query =
|
|
781
|
-
test: wire${addTestImplementation ? testImplementationNaming.ClassName : implementationNaming.ClassName}${naming.ClassName}Query,
|
|
782
|
-
development: wire${implementationNaming.ClassName}${naming.ClassName}Query,
|
|
783
|
-
production: wire${implementationNaming.ClassName}${naming.ClassName}Query
|
|
784
|
-
})
|
|
856
|
+
export const wire${naming.ClassName}Query = wireClass(${naming.ClassName}Query, [])
|
|
785
857
|
`.trim());
|
|
786
|
-
}
|
|
787
858
|
};
|
|
788
859
|
const scaffoldNewUseCase = async (boundedContextFolder)=>{
|
|
789
860
|
const useCasesFolder = boundedContextFolder.subitem([
|
|
@@ -874,10 +945,13 @@ const main = async ()=>{
|
|
|
874
945
|
]);
|
|
875
946
|
const layer = await (0, prompts_namespaceObject.select)({
|
|
876
947
|
message: 'Layer:',
|
|
877
|
-
choices: [
|
|
948
|
+
choices: specificContext ? [
|
|
878
949
|
'Domain',
|
|
879
950
|
'Application',
|
|
880
951
|
'Presentation'
|
|
952
|
+
] : [
|
|
953
|
+
'Domain',
|
|
954
|
+
'Application'
|
|
881
955
|
]
|
|
882
956
|
});
|
|
883
957
|
if ('Domain' === layer) {
|
package/dist/index.js
CHANGED
|
@@ -293,8 +293,7 @@ const scaffoldNewApplicationPort = async (boundedContextFolder)=>{
|
|
|
293
293
|
const wiringFolder = boundedContextFolder.subitem([
|
|
294
294
|
'wiring',
|
|
295
295
|
'application',
|
|
296
|
-
'ports'
|
|
297
|
-
naming.fileName
|
|
296
|
+
'ports'
|
|
298
297
|
]);
|
|
299
298
|
const infraFolder = boundedContextFolder.subitem([
|
|
300
299
|
'wiring',
|
|
@@ -353,11 +352,11 @@ export const wire${currentNaming.ClassName} = wireClass(
|
|
|
353
352
|
`.trim());
|
|
354
353
|
}
|
|
355
354
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) wiringFolder.createFile(`wire-${naming.fileName}.ts`, `
|
|
356
|
-
import { envBranchedWire } from '
|
|
355
|
+
import { envBranchedWire } from '../../../../${'shared' === boundedContextFolder.name ? '' : '../'}shared/wiring/env-branched-wire'
|
|
357
356
|
${implementationTypes.map((x)=>({
|
|
358
357
|
naming: new UnknownFormatNaming(`${x}-${naming.fileName}`),
|
|
359
358
|
implementation: x
|
|
360
|
-
})).map(({ naming: { ClassName, fileName }, implementation })=>`import { wire${ClassName} } from '
|
|
359
|
+
})).map(({ naming: { ClassName, fileName }, implementation })=>`import { wire${ClassName} } from '../../infrastructure/application-ports/${implementation}/wire-${fileName}'`).join('\n')}
|
|
361
360
|
|
|
362
361
|
export const wire${naming.ClassName} = envBranchedWire({
|
|
363
362
|
test: wire${new UnknownFormatNaming(`${implementationTypes.at(-1)}-${naming.fileName}`).ClassName},
|
|
@@ -402,100 +401,136 @@ const scaffoldNewCommand = async (boundedContextFolder)=>{
|
|
|
402
401
|
message: 'Name: '
|
|
403
402
|
});
|
|
404
403
|
const naming = new UnknownFormatNaming(commandName);
|
|
405
|
-
const
|
|
406
|
-
message: '
|
|
407
|
-
default: ConfigFile.Instance.data.defaultPersistenceLayerImplementation
|
|
408
|
-
});
|
|
409
|
-
let addTestImplementation = false;
|
|
410
|
-
let testImplementationType = '';
|
|
411
|
-
addTestImplementation = await prompts_confirm({
|
|
412
|
-
message: 'Add a test implementation for Command'
|
|
413
|
-
});
|
|
414
|
-
if (addTestImplementation) testImplementationType = await input({
|
|
415
|
-
message: 'Test Command infrastructure implementation type:',
|
|
416
|
-
default: 'in-memory'
|
|
404
|
+
const isOrchestrator = await prompts_confirm({
|
|
405
|
+
message: 'Is an orchestrator command (no infrastructure implementations)?'
|
|
417
406
|
});
|
|
418
|
-
|
|
419
|
-
implementationType
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
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'
|
|
429
446
|
|
|
430
|
-
export class ${formatNaming.ClassName}${naming.ClassName}Command implements ${naming.ClassName}Command {
|
|
431
|
-
constructor() {}
|
|
447
|
+
export class ${formatNaming.ClassName}${naming.ClassName}Command implements ${naming.ClassName}Command {
|
|
432
448
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
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
|
+
}
|
|
438
469
|
}
|
|
439
|
-
|
|
440
|
-
}
|
|
441
|
-
`.trim() : `
|
|
442
|
-
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'
|
|
443
472
|
|
|
444
|
-
export class ${
|
|
473
|
+
export abstract class ${naming.ClassName}Command {
|
|
474
|
+
static inputSchema = {}
|
|
475
|
+
static outputSchema = {}
|
|
445
476
|
|
|
446
|
-
}
|
|
447
|
-
|
|
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());
|
|
448
484
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
449
|
-
const
|
|
485
|
+
const implementationNaming = new UnknownFormatNaming(implementationType);
|
|
486
|
+
const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
|
|
487
|
+
boundedContextFolder.subitem([
|
|
450
488
|
'wiring',
|
|
451
|
-
'
|
|
452
|
-
'commands'
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
)
|
|
463
|
-
|
|
464
|
-
`.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());
|
|
465
501
|
}
|
|
502
|
+
return;
|
|
466
503
|
}
|
|
467
504
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) commandsFolder.createFile(`${naming.fileName}-command.ts`, `
|
|
468
|
-
import type
|
|
505
|
+
import { defineHandler, type Handler } from '@domain-first/handlers'
|
|
469
506
|
|
|
470
|
-
export
|
|
507
|
+
export class ${naming.ClassName}Command {
|
|
471
508
|
static inputSchema = {}
|
|
472
509
|
static outputSchema = {}
|
|
473
510
|
|
|
474
|
-
|
|
511
|
+
handle = defineHandler({
|
|
512
|
+
inputSchema: ${naming.ClassName}Command.inputSchema,
|
|
513
|
+
outputSchema: ${naming.ClassName}Command.outputSchema,
|
|
514
|
+
handler: async (payload) => {
|
|
515
|
+
return {}
|
|
516
|
+
}
|
|
517
|
+
})
|
|
475
518
|
}
|
|
476
519
|
`.trim());
|
|
477
520
|
else commandsFolder.createFile(`${naming.fileName}-command.ts`, `
|
|
478
|
-
export
|
|
521
|
+
export class ${naming.ClassName}Command {
|
|
479
522
|
|
|
480
523
|
}`.trim());
|
|
481
|
-
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire'))
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
]).createFile(`wire-${naming.fileName}-command.ts`, `
|
|
489
|
-
import { envBranchedWire } from '../../../../../shared/wiring/env-branched-wire'
|
|
490
|
-
${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'
|
|
491
531
|
|
|
492
|
-
export const wire${naming.ClassName}Command =
|
|
493
|
-
test: wire${addTestImplementation ? testImplementationNaming.ClassName : implementationNaming.ClassName}${naming.ClassName}Command,
|
|
494
|
-
development: wire${implementationNaming.ClassName}${naming.ClassName}Command,
|
|
495
|
-
production: wire${implementationNaming.ClassName}${naming.ClassName}Command
|
|
496
|
-
})
|
|
532
|
+
export const wire${naming.ClassName}Command = wireClass(${naming.ClassName}Command, [])
|
|
497
533
|
`.trim());
|
|
498
|
-
}
|
|
499
534
|
};
|
|
500
535
|
const scaffoldNewDomainService = async (boundedContextFolder)=>{
|
|
501
536
|
const portName = await input({
|
|
@@ -661,99 +696,135 @@ const scaffoldNewQuery = async (boundedContextFolder)=>{
|
|
|
661
696
|
message: 'Name: '
|
|
662
697
|
});
|
|
663
698
|
const naming = new UnknownFormatNaming(queryName);
|
|
664
|
-
const
|
|
665
|
-
message: '
|
|
666
|
-
default: ConfigFile.Instance.data.defaultPersistenceLayerImplementation
|
|
667
|
-
});
|
|
668
|
-
let addTestImplementation = false;
|
|
669
|
-
let testImplementationType = '';
|
|
670
|
-
addTestImplementation = await prompts_confirm({
|
|
671
|
-
message: 'Add a test implementation for Query'
|
|
672
|
-
});
|
|
673
|
-
if (addTestImplementation) testImplementationType = await input({
|
|
674
|
-
message: 'Test Query infrastructure implementation type:',
|
|
675
|
-
default: 'in-memory'
|
|
699
|
+
const isOrchestrator = await prompts_confirm({
|
|
700
|
+
message: 'Is an orchestrator query (no infrastructure implementations)?'
|
|
676
701
|
});
|
|
677
|
-
|
|
678
|
-
implementationType
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
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'
|
|
688
741
|
|
|
689
|
-
export class ${formatNaming.ClassName}${naming.ClassName}Query implements ${naming.ClassName}Query {
|
|
690
|
-
constructor() {}
|
|
742
|
+
export class ${formatNaming.ClassName}${naming.ClassName}Query implements ${naming.ClassName}Query {
|
|
691
743
|
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
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
|
+
}
|
|
697
763
|
}
|
|
698
|
-
|
|
699
|
-
}
|
|
700
|
-
`.trim() : `
|
|
701
|
-
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'
|
|
702
766
|
|
|
703
|
-
export class ${
|
|
767
|
+
export abstract class ${naming.ClassName}Query {
|
|
768
|
+
static inputSchema = {}
|
|
769
|
+
static outputSchema = {}
|
|
704
770
|
|
|
705
|
-
}
|
|
706
|
-
|
|
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());
|
|
707
778
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
708
|
-
const
|
|
779
|
+
const implementationNaming = new UnknownFormatNaming(implementationType);
|
|
780
|
+
const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
|
|
781
|
+
boundedContextFolder.subitem([
|
|
709
782
|
'wiring',
|
|
710
|
-
'
|
|
711
|
-
'queries'
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
)
|
|
722
|
-
`.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());
|
|
723
795
|
}
|
|
796
|
+
return;
|
|
724
797
|
}
|
|
725
798
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) queriesFolder.createFile(`${naming.fileName}-query.ts`, `
|
|
726
|
-
import type
|
|
799
|
+
import { defineHandler, type Handler } from '@domain-first/handlers'
|
|
727
800
|
|
|
728
|
-
export
|
|
801
|
+
export class ${naming.ClassName}Query {
|
|
729
802
|
static inputSchema = {}
|
|
730
803
|
static outputSchema = {}
|
|
731
804
|
|
|
732
|
-
|
|
805
|
+
handle = defineHandler({
|
|
806
|
+
inputSchema: ${naming.ClassName}Query.inputSchema,
|
|
807
|
+
outputSchema: ${naming.ClassName}Query.outputSchema,
|
|
808
|
+
handler: async (payload) => {
|
|
809
|
+
return {}
|
|
810
|
+
}
|
|
811
|
+
})
|
|
733
812
|
}
|
|
734
813
|
`.trim());
|
|
735
814
|
else queriesFolder.createFile(`${naming.fileName}-query.ts`, `
|
|
736
|
-
export
|
|
815
|
+
export class ${naming.ClassName}Query {
|
|
737
816
|
|
|
738
817
|
}`.trim());
|
|
739
|
-
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire'))
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
]).createFile(`wire-${naming.fileName}-query.ts`, `
|
|
747
|
-
import { envBranchedWire } from '../../../../../shared/wiring/env-branched-wire'
|
|
748
|
-
${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'
|
|
749
825
|
|
|
750
|
-
export const wire${naming.ClassName}Query =
|
|
751
|
-
test: wire${addTestImplementation ? testImplementationNaming.ClassName : implementationNaming.ClassName}${naming.ClassName}Query,
|
|
752
|
-
development: wire${implementationNaming.ClassName}${naming.ClassName}Query,
|
|
753
|
-
production: wire${implementationNaming.ClassName}${naming.ClassName}Query
|
|
754
|
-
})
|
|
826
|
+
export const wire${naming.ClassName}Query = wireClass(${naming.ClassName}Query, [])
|
|
755
827
|
`.trim());
|
|
756
|
-
}
|
|
757
828
|
};
|
|
758
829
|
const scaffoldNewUseCase = async (boundedContextFolder)=>{
|
|
759
830
|
const useCasesFolder = boundedContextFolder.subitem([
|
|
@@ -844,10 +915,13 @@ const main = async ()=>{
|
|
|
844
915
|
]);
|
|
845
916
|
const layer = await prompts_select({
|
|
846
917
|
message: 'Layer:',
|
|
847
|
-
choices: [
|
|
918
|
+
choices: specificContext ? [
|
|
848
919
|
'Domain',
|
|
849
920
|
'Application',
|
|
850
921
|
'Presentation'
|
|
922
|
+
] : [
|
|
923
|
+
'Domain',
|
|
924
|
+
'Application'
|
|
851
925
|
]
|
|
852
926
|
});
|
|
853
927
|
if ('Domain' === layer) {
|
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
|
|
4
|
+
"version": "1.1.0",
|
|
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.
|
|
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",
|