@domain-first/project-structure 4.2.1 → 5.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 CHANGED
@@ -37,10 +37,8 @@ const moduleKinds = [
37
37
  'application-ports',
38
38
  'application-services',
39
39
  'use-cases',
40
- 'execution-commands',
41
- 'execution-queries',
42
- 'orchestration-commands',
43
- 'orchestration-queries',
40
+ 'commands',
41
+ 'queries',
44
42
  'infrastructure-services',
45
43
  'presentation-services'
46
44
  ];
@@ -49,10 +47,8 @@ const domain = [
49
47
  'domain-services'
50
48
  ];
51
49
  const commandsAndQueries = [
52
- 'execution-commands',
53
- 'execution-queries',
54
- 'orchestration-commands',
55
- 'orchestration-queries'
50
+ 'commands',
51
+ 'queries'
56
52
  ];
57
53
  const infrastructure = [
58
54
  ...domain,
@@ -60,7 +56,9 @@ const infrastructure = [
60
56
  'infrastructure-services'
61
57
  ];
62
58
  const defaultDependencies = {
63
- 'domain-services': domain,
59
+ 'domain-services': [
60
+ 'domain-services'
61
+ ],
64
62
  repositories: [
65
63
  'domain-services',
66
64
  'application-ports',
@@ -78,16 +76,11 @@ const defaultDependencies = {
78
76
  'application-services',
79
77
  ...commandsAndQueries
80
78
  ],
81
- 'execution-commands': infrastructure,
82
- 'execution-queries': infrastructure,
83
- 'orchestration-commands': [
84
- ...domain,
85
- 'execution-commands',
86
- 'execution-queries'
79
+ commands: [
80
+ 'infrastructure-services'
87
81
  ],
88
- 'orchestration-queries': [
89
- ...domain,
90
- 'execution-queries'
82
+ queries: [
83
+ 'infrastructure-services'
91
84
  ],
92
85
  'infrastructure-services': infrastructure,
93
86
  'presentation-services': [
@@ -127,10 +120,7 @@ const resolveDependencyRules = (config = {})=>{
127
120
  };
128
121
  const defaultDependencyRules = resolveDependencyRules();
129
122
  const isModuleKind = (value)=>moduleKinds.includes(value);
130
- const wiredModuleKind = (wiringKind, typeFile)=>{
131
- const kind = 'commands' === wiringKind || 'queries' === wiringKind ? `${'execution' === external_node_path_default().basename(external_node_path_default().dirname(typeFile)) ? 'execution' : 'orchestration'}-${wiringKind}` : wiringKind;
132
- return isModuleKind(kind) ? kind : void 0;
133
- };
123
+ const wiredModuleKind = (wiringKind)=>isModuleKind(wiringKind) ? wiringKind : void 0;
134
124
  const external_node_fs_namespaceObject = require("node:fs");
135
125
  var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
136
126
  const pendingFiles = new Map();
@@ -1474,13 +1464,11 @@ const branchedTypeFiles = {
1474
1464
  commands: (fileBase)=>[
1475
1465
  'application',
1476
1466
  'commands',
1477
- 'execution',
1478
1467
  `${fileBase}.ts`
1479
1468
  ],
1480
1469
  queries: (fileBase)=>[
1481
1470
  'application',
1482
1471
  'queries',
1483
- 'execution',
1484
1472
  `${fileBase}.ts`
1485
1473
  ],
1486
1474
  'application-ports': (fileBase)=>[
@@ -1575,7 +1563,7 @@ const findWiredModules = (contextPath)=>{
1575
1563
  walk(external_node_path_default().join(contextPath, 'wiring'));
1576
1564
  return result.sort((a, b)=>a.typeName.localeCompare(b.typeName));
1577
1565
  };
1578
- const moduleKindOf = (module)=>wiredModuleKind(module.kind, module.typeFile);
1566
+ const moduleKindOf = (module)=>wiredModuleKind(module.kind);
1579
1567
  const layerRule = (consumer, candidate)=>visibleLayers[consumer.implementationsLayer].includes(candidate.layer) && ('infrastructure' !== consumer.implementationsLayer || 'application' !== candidate.layer || 'application-ports' === candidate.kind);
1580
1568
  const wiring_implementationType = (consumer, implementation)=>consumer.branched ? external_node_path_default().basename(external_node_path_default().dirname(implementation.file)) : void 0;
1581
1569
  const isSuggestedFor = (candidate, implementation)=>'infrastructure' === candidate.layer && `-${external_node_path_default().basename(candidate.typeFile, '.ts')}-`.includes(`-${implementation}-`);
@@ -2825,40 +2813,31 @@ const scaffoldNewCommand = async (boundedContextFolder)=>{
2825
2813
  });
2826
2814
  const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
2827
2815
  const naming = new UnknownFormatNaming(commandName);
2828
- const commandType = await (0, prompts_namespaceObject.select)({
2829
- choices: [
2830
- 'Execution (with infrastructure implementation)',
2831
- 'Orchestrator (no infrastructure implementation)'
2832
- ],
2833
- message: 'Command type'
2834
- });
2835
- const isOrchestrator = 'Orchestrator (no infrastructure implementation)' === commandType;
2836
2816
  const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
2837
- if (!isOrchestrator) {
2838
- const implementationType = await (0, prompts_namespaceObject.input)({
2839
- message: 'Command infrastructure implementation type:',
2840
- default: ConfigFile.Instance.data.defaultPersistenceLayerImplementation
2841
- });
2842
- let addTestImplementation = false;
2843
- let testImplementationType = '';
2844
- addTestImplementation = await (0, prompts_namespaceObject.confirm)({
2845
- message: 'Add a test implementation for Command'
2846
- });
2847
- if (addTestImplementation) testImplementationType = await (0, prompts_namespaceObject.input)({
2848
- message: 'Test Command infrastructure implementation type:',
2849
- default: 'in-memory'
2850
- });
2851
- const implementationTypes = [
2852
- implementationType,
2853
- testImplementationType
2854
- ].filter((x)=>!!x);
2855
- for (const implementation of implementationTypes){
2856
- const formatNaming = new UnknownFormatNaming(implementation);
2857
- const implementationFile = infrastructureFolder.subitem([
2858
- formatNaming.fileName
2859
- ]).createFile(`${formatNaming.fileName}-${naming.fileName}-command.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
2817
+ const implementationType = await (0, prompts_namespaceObject.input)({
2818
+ message: 'Command infrastructure implementation type:',
2819
+ default: ConfigFile.Instance.data.defaultPersistenceLayerImplementation
2820
+ });
2821
+ let addTestImplementation = false;
2822
+ let testImplementationType = '';
2823
+ addTestImplementation = await (0, prompts_namespaceObject.confirm)({
2824
+ message: 'Add a test implementation for Command'
2825
+ });
2826
+ if (addTestImplementation) testImplementationType = await (0, prompts_namespaceObject.input)({
2827
+ message: 'Test Command infrastructure implementation type:',
2828
+ default: 'in-memory'
2829
+ });
2830
+ const implementationTypes = [
2831
+ implementationType,
2832
+ testImplementationType
2833
+ ].filter((x)=>!!x);
2834
+ for (const implementation of implementationTypes){
2835
+ const formatNaming = new UnknownFormatNaming(implementation);
2836
+ const implementationFile = infrastructureFolder.subitem([
2837
+ formatNaming.fileName
2838
+ ]).createFile(`${formatNaming.fileName}-${naming.fileName}-command.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
2860
2839
  import { defineHandler } from '@domain-first/handlers'
2861
- import { ${naming.ClassName}Command } from '../../../application/commands/execution/${naming.fileName}-command'
2840
+ import { ${naming.ClassName}Command } from '../../../application/commands/${naming.fileName}-command'
2862
2841
 
2863
2842
  export class ${formatNaming.ClassName}${naming.ClassName}Command extends ${naming.ClassName}Command {
2864
2843
  constructor() {
@@ -2874,7 +2853,7 @@ export class ${formatNaming.ClassName}${naming.ClassName}Command extends ${namin
2874
2853
  })
2875
2854
  }
2876
2855
  `.trim() : `
2877
- import { ${naming.ClassName}Command } from '../../../application/commands/execution/${naming.fileName}-command'
2856
+ import { ${naming.ClassName}Command } from '../../../application/commands/${naming.fileName}-command'
2878
2857
 
2879
2858
  export class ${formatNaming.ClassName}${naming.ClassName}Command extends ${naming.ClassName}Command {
2880
2859
  constructor() {
@@ -2882,11 +2861,9 @@ export class ${formatNaming.ClassName}${naming.ClassName}Command extends ${namin
2882
2861
  }
2883
2862
  }
2884
2863
  `.trim());
2885
- if (!withWiring && usesInMemoryDb(implementation)) injectInMemoryDb(implementationFile, `${formatNaming.ClassName}${naming.ClassName}Command`);
2886
- }
2887
- if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) commandsFolder.subitem([
2888
- 'execution'
2889
- ]).createFile(`${naming.fileName}-command.ts`, `
2864
+ if (!withWiring && usesInMemoryDb(implementation)) injectInMemoryDb(implementationFile, `${formatNaming.ClassName}${naming.ClassName}Command`);
2865
+ }
2866
+ if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) commandsFolder.createFile(`${naming.fileName}-command.ts`, `
2890
2867
  import type { Handler } from '@domain-first/handlers'
2891
2868
 
2892
2869
  export abstract class ${naming.ClassName}Command {
@@ -2896,20 +2873,16 @@ export abstract class ${naming.ClassName}Command {
2896
2873
  abstract handle: Handler<typeof ${naming.ClassName}Command.inputSchema, typeof ${naming.ClassName}Command.outputSchema>
2897
2874
  }
2898
2875
  `.trim());
2899
- else commandsFolder.subitem([
2900
- 'execution'
2901
- ]).createFile(`${naming.fileName}-command.ts`, `
2876
+ else commandsFolder.createFile(`${naming.fileName}-command.ts`, `
2902
2877
  export abstract class ${naming.ClassName}Command {
2903
2878
 
2904
2879
  }`.trim());
2905
- if (scaffoldUnitTests) {
2906
- const implementationNaming = new UnknownFormatNaming(implementationType);
2907
- const specFile = commandsFolder.subitem([
2908
- 'execution'
2909
- ]).createFile(`${naming.fileName}-command.spec.ts`, `
2880
+ if (scaffoldUnitTests) {
2881
+ const implementationNaming = new UnknownFormatNaming(implementationType);
2882
+ const specFile = commandsFolder.createFile(`${naming.fileName}-command.spec.ts`, `
2910
2883
  import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
2911
2884
  ${withWiring ? `import { type ${naming.ClassName}Command } from './${naming.fileName}-command'
2912
- import { wire${naming.ClassName}Command } from '../../../wiring/commands/wire-${naming.fileName}-command'` : `import { ${implementationNaming.ClassName}${naming.ClassName}Command } from '../../../infrastructure/commands/${implementationNaming.fileName}/${implementationNaming.fileName}-${naming.fileName}-command'
2885
+ import { wire${naming.ClassName}Command } from '../../wiring/commands/wire-${naming.fileName}-command'` : `import { ${implementationNaming.ClassName}${naming.ClassName}Command } from '../../infrastructure/commands/${implementationNaming.fileName}/${implementationNaming.fileName}-${naming.fileName}-command'
2913
2886
 
2914
2887
  type ${naming.ClassName}Command = ${implementationNaming.ClassName}${naming.ClassName}Command`}
2915
2888
 
@@ -2925,15 +2898,15 @@ describe('${naming.withSpaces} command', () => {
2925
2898
  })
2926
2899
  })
2927
2900
  `.trim());
2928
- if (!withWiring && usesInMemoryDb(implementationType)) passInMemoryDb(specFile, `${implementationNaming.ClassName}${naming.ClassName}Command`);
2929
- }
2930
- if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
2931
- const implementationNaming = new UnknownFormatNaming(implementationType);
2932
- const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
2933
- const wireFile = boundedContextFolder.subitem([
2934
- 'wiring',
2935
- 'commands'
2936
- ]).createFile(`wire-${naming.fileName}-command.ts`, `
2901
+ if (!withWiring && usesInMemoryDb(implementationType)) passInMemoryDb(specFile, `${implementationNaming.ClassName}${naming.ClassName}Command`);
2902
+ }
2903
+ if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
2904
+ const implementationNaming = new UnknownFormatNaming(implementationType);
2905
+ const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
2906
+ const wireFile = boundedContextFolder.subitem([
2907
+ 'wiring',
2908
+ 'commands'
2909
+ ]).createFile(`wire-${naming.fileName}-command.ts`, `
2937
2910
  import { wireClass } from '@domain-first/wire'
2938
2911
  import { envBranchedWire } from '../../../../shared/wiring/env-branched-wire'
2939
2912
  ${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { ${ClassName}${naming.ClassName}Command } from '../../infrastructure/commands/${fileName}/${fileName}-${naming.fileName}-command'`).join('\n')}
@@ -2946,68 +2919,8 @@ export const wire${naming.ClassName}Command = envBranchedWire({
2946
2919
  production: wire${implementationNaming.ClassName}Implementation
2947
2920
  })
2948
2921
  `.trim());
2949
- await wireNewModuleDependencies(boundedContextFolder, wireFile);
2950
- }
2951
- return;
2922
+ await wireNewModuleDependencies(boundedContextFolder, wireFile);
2952
2923
  }
2953
- if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) commandsFolder.subitem([
2954
- 'orchestration'
2955
- ]).createFile(`${naming.fileName}-command.ts`, `
2956
- import { defineHandler } from '@domain-first/handlers'
2957
-
2958
- export class ${naming.ClassName}Command {
2959
- constructor() {}
2960
-
2961
- static inputSchema = {}
2962
- static outputSchema = {}
2963
-
2964
- handle = defineHandler({
2965
- inputSchema: ${naming.ClassName}Command.inputSchema,
2966
- outputSchema: ${naming.ClassName}Command.outputSchema,
2967
- handler: async (payload) => {
2968
- return {}
2969
- }
2970
- })
2971
- }
2972
- `.trim());
2973
- else commandsFolder.subitem([
2974
- 'orchestration'
2975
- ]).createFile(`${naming.fileName}-command.ts`, `
2976
- export class ${naming.ClassName}Command {
2977
- constructor() {}
2978
- }`.trim());
2979
- if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) boundedContextFolder.subitem([
2980
- 'wiring',
2981
- 'commands'
2982
- ]).createFile(`wire-${naming.fileName}-command.ts`, `
2983
- import { wireClass } from '@domain-first/wire'
2984
- import { ${naming.ClassName}Command } from '../../application/commands/orchestration/${naming.fileName}-command'
2985
-
2986
- export const wire${naming.ClassName}Command = wireClass(${naming.ClassName}Command, [])
2987
- `.trim());
2988
- if (scaffoldUnitTests) commandsFolder.subitem([
2989
- 'orchestration'
2990
- ]).createFile(`${naming.fileName}-command.spec.ts`, `
2991
- import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
2992
- ${withWiring ? `import { type ${naming.ClassName}Command } from './${naming.fileName}-command'
2993
- import { wire${naming.ClassName}Command } from '../../../wiring/commands/wire-${naming.fileName}-command'` : `import { ${naming.ClassName}Command } from './${naming.fileName}-command'`}
2994
-
2995
- let ${naming.variableName}Command: ${naming.ClassName}Command
2996
-
2997
- beforeEach(() => {
2998
- ${naming.variableName}Command = ${withWiring ? `wire${naming.ClassName}Command()` : `new ${naming.ClassName}Command()`}
2999
- })
3000
-
3001
- describe('${naming.withSpaces} command', () => {
3002
- test('can be ${withWiring ? 'wired' : 'created via constructor'}', () => {
3003
- expect(${naming.variableName}Command).toBeDefined()
3004
- })
3005
- })
3006
- `.trim());
3007
- if (withWiring) await wireNewModuleDependencies(boundedContextFolder, boundedContextFolder.subitem([
3008
- 'wiring',
3009
- 'commands'
3010
- ]).file(`wire-${naming.fileName}-command.ts`));
3011
2924
  };
3012
2925
  const noAggregate = 'No aggregate';
3013
2926
  const scaffoldNewDomainObject = async (boundedContextFolder, kind)=>{
@@ -3352,42 +3265,33 @@ const scaffoldNewQuery = async (boundedContextFolder)=>{
3352
3265
  const queryName = await (0, prompts_namespaceObject.input)({
3353
3266
  message: 'Name: '
3354
3267
  });
3355
- const naming = new UnknownFormatNaming(queryName);
3356
3268
  const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
3357
- const queryType = await (0, prompts_namespaceObject.select)({
3358
- choices: [
3359
- 'Execution (with infrastructure implementation)',
3360
- 'Orchestrator (no infrastructure implementation)'
3361
- ],
3362
- message: 'Query type'
3363
- });
3364
- const isOrchestrator = 'Orchestrator (no infrastructure implementation)' === queryType;
3269
+ const naming = new UnknownFormatNaming(queryName);
3365
3270
  const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
3366
- if (!isOrchestrator) {
3367
- const implementationType = await (0, prompts_namespaceObject.input)({
3368
- message: 'Query infrastructure implementation type:',
3369
- default: ConfigFile.Instance.data.defaultPersistenceLayerImplementation
3370
- });
3371
- let addTestImplementation = false;
3372
- let testImplementationType = '';
3373
- addTestImplementation = await (0, prompts_namespaceObject.confirm)({
3374
- message: 'Add a test implementation for Query'
3375
- });
3376
- if (addTestImplementation) testImplementationType = await (0, prompts_namespaceObject.input)({
3377
- message: 'Test Query infrastructure implementation type:',
3378
- default: 'in-memory'
3379
- });
3380
- const implementationTypes = [
3381
- implementationType,
3382
- testImplementationType
3383
- ].filter((x)=>!!x);
3384
- for (const implementation of implementationTypes){
3385
- const formatNaming = new UnknownFormatNaming(implementation);
3386
- const implementationFile = infrastructureFolder.subitem([
3387
- formatNaming.fileName
3388
- ]).createFile(`${formatNaming.fileName}-${naming.fileName}-query.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
3271
+ const implementationType = await (0, prompts_namespaceObject.input)({
3272
+ message: 'Query infrastructure implementation type:',
3273
+ default: ConfigFile.Instance.data.defaultPersistenceLayerImplementation
3274
+ });
3275
+ let addTestImplementation = false;
3276
+ let testImplementationType = '';
3277
+ addTestImplementation = await (0, prompts_namespaceObject.confirm)({
3278
+ message: 'Add a test implementation for Query'
3279
+ });
3280
+ if (addTestImplementation) testImplementationType = await (0, prompts_namespaceObject.input)({
3281
+ message: 'Test Query infrastructure implementation type:',
3282
+ default: 'in-memory'
3283
+ });
3284
+ const implementationTypes = [
3285
+ implementationType,
3286
+ testImplementationType
3287
+ ].filter((x)=>!!x);
3288
+ for (const implementation of implementationTypes){
3289
+ const formatNaming = new UnknownFormatNaming(implementation);
3290
+ const implementationFile = infrastructureFolder.subitem([
3291
+ formatNaming.fileName
3292
+ ]).createFile(`${formatNaming.fileName}-${naming.fileName}-query.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
3389
3293
  import { defineHandler } from '@domain-first/handlers'
3390
- import { ${naming.ClassName}Query } from '../../../application/queries/execution/${naming.fileName}-query'
3294
+ import { ${naming.ClassName}Query } from '../../../application/queries/${naming.fileName}-query'
3391
3295
 
3392
3296
  export class ${formatNaming.ClassName}${naming.ClassName}Query extends ${naming.ClassName}Query {
3393
3297
  constructor() {
@@ -3403,7 +3307,7 @@ export class ${formatNaming.ClassName}${naming.ClassName}Query extends ${naming.
3403
3307
  })
3404
3308
  }
3405
3309
  `.trim() : `
3406
- import { ${naming.ClassName}Query } from '../../../application/queries/execution/${naming.fileName}-query'
3310
+ import { ${naming.ClassName}Query } from '../../../application/queries/${naming.fileName}-query'
3407
3311
 
3408
3312
  export class ${formatNaming.ClassName}${naming.ClassName}Query extends ${naming.ClassName}Query {
3409
3313
  constructor() {
@@ -3411,11 +3315,9 @@ export class ${formatNaming.ClassName}${naming.ClassName}Query extends ${naming.
3411
3315
  }
3412
3316
  }
3413
3317
  `.trim());
3414
- if (!withWiring && usesInMemoryDb(implementation)) injectInMemoryDb(implementationFile, `${formatNaming.ClassName}${naming.ClassName}Query`);
3415
- }
3416
- if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) queriesFolder.subitem([
3417
- 'execution'
3418
- ]).createFile(`${naming.fileName}-query.ts`, `
3318
+ if (!withWiring && usesInMemoryDb(implementation)) injectInMemoryDb(implementationFile, `${formatNaming.ClassName}${naming.ClassName}Query`);
3319
+ }
3320
+ if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) queriesFolder.createFile(`${naming.fileName}-query.ts`, `
3419
3321
  import type { Handler } from '@domain-first/handlers'
3420
3322
 
3421
3323
  export abstract class ${naming.ClassName}Query {
@@ -3425,20 +3327,16 @@ export abstract class ${naming.ClassName}Query {
3425
3327
  abstract handle: Handler<typeof ${naming.ClassName}Query.inputSchema, typeof ${naming.ClassName}Query.outputSchema>
3426
3328
  }
3427
3329
  `.trim());
3428
- else queriesFolder.subitem([
3429
- 'execution'
3430
- ]).createFile(`${naming.fileName}-query.ts`, `
3330
+ else queriesFolder.createFile(`${naming.fileName}-query.ts`, `
3431
3331
  export abstract class ${naming.ClassName}Query {
3432
3332
 
3433
3333
  }`.trim());
3434
- if (scaffoldUnitTests) {
3435
- const implementationNaming = new UnknownFormatNaming(implementationType);
3436
- const specFile = queriesFolder.subitem([
3437
- 'execution'
3438
- ]).createFile(`${naming.fileName}-query.spec.ts`, `
3334
+ if (scaffoldUnitTests) {
3335
+ const implementationNaming = new UnknownFormatNaming(implementationType);
3336
+ const specFile = queriesFolder.createFile(`${naming.fileName}-query.spec.ts`, `
3439
3337
  import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
3440
3338
  ${withWiring ? `import { type ${naming.ClassName}Query } from './${naming.fileName}-query'
3441
- import { wire${naming.ClassName}Query } from '../../../wiring/queries/wire-${naming.fileName}-query'` : `import { ${implementationNaming.ClassName}${naming.ClassName}Query } from '../../../infrastructure/queries/${implementationNaming.fileName}/${implementationNaming.fileName}-${naming.fileName}-query'
3339
+ import { wire${naming.ClassName}Query } from '../../wiring/queries/wire-${naming.fileName}-query'` : `import { ${implementationNaming.ClassName}${naming.ClassName}Query } from '../../infrastructure/queries/${implementationNaming.fileName}/${implementationNaming.fileName}-${naming.fileName}-query'
3442
3340
 
3443
3341
  type ${naming.ClassName}Query = ${implementationNaming.ClassName}${naming.ClassName}Query`}
3444
3342
 
@@ -3454,15 +3352,15 @@ describe('${naming.withSpaces} query', () => {
3454
3352
  })
3455
3353
  })
3456
3354
  `.trim());
3457
- if (!withWiring && usesInMemoryDb(implementationType)) passInMemoryDb(specFile, `${implementationNaming.ClassName}${naming.ClassName}Query`);
3458
- }
3459
- if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
3460
- const implementationNaming = new UnknownFormatNaming(implementationType);
3461
- const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
3462
- const wireFile = boundedContextFolder.subitem([
3463
- 'wiring',
3464
- 'queries'
3465
- ]).createFile(`wire-${naming.fileName}-query.ts`, `
3355
+ if (!withWiring && usesInMemoryDb(implementationType)) passInMemoryDb(specFile, `${implementationNaming.ClassName}${naming.ClassName}Query`);
3356
+ }
3357
+ if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
3358
+ const implementationNaming = new UnknownFormatNaming(implementationType);
3359
+ const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
3360
+ const wireFile = boundedContextFolder.subitem([
3361
+ 'wiring',
3362
+ 'queries'
3363
+ ]).createFile(`wire-${naming.fileName}-query.ts`, `
3466
3364
  import { wireClass } from '@domain-first/wire'
3467
3365
  import { envBranchedWire } from '../../../../shared/wiring/env-branched-wire'
3468
3366
  ${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { ${ClassName}${naming.ClassName}Query } from '../../infrastructure/queries/${fileName}/${fileName}-${naming.fileName}-query'`).join('\n')}
@@ -3475,68 +3373,8 @@ export const wire${naming.ClassName}Query = envBranchedWire({
3475
3373
  production: wire${implementationNaming.ClassName}Implementation
3476
3374
  })
3477
3375
  `.trim());
3478
- await wireNewModuleDependencies(boundedContextFolder, wireFile);
3479
- }
3480
- return;
3376
+ await wireNewModuleDependencies(boundedContextFolder, wireFile);
3481
3377
  }
3482
- if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) queriesFolder.subitem([
3483
- 'orchestration'
3484
- ]).createFile(`${naming.fileName}-query.ts`, `
3485
- import { defineHandler } from '@domain-first/handlers'
3486
-
3487
- export class ${naming.ClassName}Query {
3488
- constructor() {}
3489
-
3490
- static inputSchema = {}
3491
- static outputSchema = {}
3492
-
3493
- handle = defineHandler({
3494
- inputSchema: ${naming.ClassName}Query.inputSchema,
3495
- outputSchema: ${naming.ClassName}Query.outputSchema,
3496
- handler: async (payload) => {
3497
- return {}
3498
- }
3499
- })
3500
- }
3501
- `.trim());
3502
- else queriesFolder.subitem([
3503
- 'orchestration'
3504
- ]).createFile(`${naming.fileName}-query.ts`, `
3505
- export class ${naming.ClassName}Query {
3506
- constructor() {}
3507
- }`.trim());
3508
- if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) boundedContextFolder.subitem([
3509
- 'wiring',
3510
- 'queries'
3511
- ]).createFile(`wire-${naming.fileName}-query.ts`, `
3512
- import { wireClass } from '@domain-first/wire'
3513
- import { ${naming.ClassName}Query } from '../../application/queries/orchestration/${naming.fileName}-query'
3514
-
3515
- export const wire${naming.ClassName}Query = wireClass(${naming.ClassName}Query, [])
3516
- `.trim());
3517
- if (scaffoldUnitTests) queriesFolder.subitem([
3518
- 'orchestration'
3519
- ]).createFile(`${naming.fileName}-query.spec.ts`, `
3520
- import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
3521
- ${withWiring ? `import { type ${naming.ClassName}Query } from './${naming.fileName}-query'
3522
- import { wire${naming.ClassName}Query } from '../../../wiring/queries/wire-${naming.fileName}-query'` : `import { ${naming.ClassName}Query } from './${naming.fileName}-query'`}
3523
-
3524
- let ${naming.variableName}Query: ${naming.ClassName}Query
3525
-
3526
- beforeEach(() => {
3527
- ${naming.variableName}Query = ${withWiring ? `wire${naming.ClassName}Query()` : `new ${naming.ClassName}Query()`}
3528
- })
3529
-
3530
- describe('${naming.withSpaces} query', () => {
3531
- test('can be ${withWiring ? 'wired' : 'created via constructor'}', () => {
3532
- expect(${naming.variableName}Query).toBeDefined()
3533
- })
3534
- })
3535
- `.trim());
3536
- if (withWiring) await wireNewModuleDependencies(boundedContextFolder, boundedContextFolder.subitem([
3537
- 'wiring',
3538
- 'queries'
3539
- ]).file(`wire-${naming.fileName}-query.ts`));
3540
3378
  };
3541
3379
  const scaffoldNewUseCase = async (boundedContextFolder)=>{
3542
3380
  const useCasesFolder = boundedContextFolder.subitem([