@domain-first/project-structure 3.2.0 → 3.2.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.
@@ -1,5 +1,6 @@
1
1
  import { File, Folder } from './file-system';
2
2
  import { UnknownFormatNaming } from './unknown-format-naming';
3
+ import { type WiredModule } from './wiring';
3
4
  /**
4
5
  * The shared in-memory DB with its spec and wire, as the config says.
5
6
  */
@@ -23,6 +24,15 @@ export declare const inMemoryDbTypeImport: (fromFile: string) => string;
23
24
  * in-memory DB as `data`.
24
25
  */
25
26
  export declare const inMemoryDbSectionMembers: (field: string, derived: boolean) => string;
27
+ /**
28
+ * Puts one section of the in-memory DB in place of the implementation's
29
+ * empty constructor.
30
+ */
31
+ export declare const keepInMemoryDbSection: (classFile: File, field: string) => void;
32
+ /**
33
+ * Whether the wired module is the in-memory DB.
34
+ */
35
+ export declare const isInMemoryDb: (module: WiredModule) => boolean;
26
36
  /**
27
37
  * Injects the whole in-memory DB into the implementation's constructor.
28
38
  */
package/dist/index.cjs CHANGED
@@ -1713,6 +1713,10 @@ const inMemoryDbSectionMembers = (field, derived)=>`
1713
1713
  ${derived ? 'super()\n ' : ''}this.data = ${in_memory_db_parameterName}.${field}
1714
1714
  }
1715
1715
  `.trim();
1716
+ const keepInMemoryDbSection = (classFile, field)=>{
1717
+ classFile.update(addImport(classFile.data, inMemoryDbTypeImport(classFile.path)).replace('constructor() {}', inMemoryDbSectionMembers(field, false)));
1718
+ };
1719
+ const isInMemoryDb = (module)=>module.wireName === in_memory_db_wireName;
1716
1720
  const injectInMemoryDb = (classFile, implementationName)=>{
1717
1721
  classFile.update(addConstructorParameters(addImport(classFile.data, inMemoryDbTypeImport(classFile.path)), implementationName, [
1718
1722
  `private readonly ${in_memory_db_parameterName}: ${in_memory_db_className}`
@@ -1742,7 +1746,8 @@ const groupedChoices = (items, suggested = [])=>{
1742
1746
  new prompts_namespaceObject.Separator('── Suggested'),
1743
1747
  ...suggested.map((x)=>({
1744
1748
  name: x.label,
1745
- value: x
1749
+ value: x,
1750
+ checked: true
1746
1751
  }))
1747
1752
  ] : [];
1748
1753
  const kinds = [
@@ -1783,7 +1788,7 @@ const contextAndSharedModules = (boundedContextFolder)=>{
1783
1788
  }))
1784
1789
  ];
1785
1790
  };
1786
- const promptDependencies = async (boundedContextFolder, consumer, implementations = consumer.implementations)=>{
1791
+ const promptDependencies = async (boundedContextFolder, consumer, implementations = consumer.implementations, customWiring)=>{
1787
1792
  const options = contextAndSharedModules(boundedContextFolder);
1788
1793
  let asked = false;
1789
1794
  for (const implementation of implementations){
@@ -1799,13 +1804,14 @@ const promptDependencies = async (boundedContextFolder, consumer, implementation
1799
1804
  pageSize: groupedPageSize,
1800
1805
  loop: false
1801
1806
  });
1802
- if (dependencies.length) wireDependencies(consumer, implementation, dependencies.map((x)=>x.module));
1807
+ const defaultWired = dependencies.map((x)=>x.module).filter((x)=>!customWiring?.(implementation, x));
1808
+ if (defaultWired.length) wireDependencies(consumer, implementation, defaultWired);
1803
1809
  }
1804
1810
  return asked;
1805
1811
  };
1806
- const wireNewModuleDependencies = async (boundedContextFolder, wireFile)=>{
1812
+ const wireNewModuleDependencies = async (boundedContextFolder, wireFile, customWiring)=>{
1807
1813
  const consumer = readWiredModule(wireFile.path, boundedContextFolder.path);
1808
- if (consumer) await promptDependencies(boundedContextFolder, consumer);
1814
+ if (consumer) await promptDependencies(boundedContextFolder, consumer, consumer.implementations, customWiring);
1809
1815
  };
1810
1816
  const wireDependency = async (boundedContextFolder)=>{
1811
1817
  const modules = findWiredModules(boundedContextFolder.path);
@@ -2323,7 +2329,8 @@ const scaffoldNewAggregateUseCase = async (boundedContextFolder)=>{
2323
2329
  'aggregates',
2324
2330
  aggregateName
2325
2331
  ]);
2326
- aggregatesFolder.createFile(`${aggregateNaming.fileName}.aggregate-root.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/types') ? `
2332
+ const withTypes = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/types');
2333
+ aggregatesFolder.createFile(`${aggregateNaming.fileName}.aggregate-root.ts`, withTypes ? `
2327
2334
  import { domainType } from '@domain-first/types'
2328
2335
 
2329
2336
  export class ${aggregateNaming.ClassName} extends domainType() {
@@ -2337,11 +2344,11 @@ import { ${aggregateNaming.ClassName} } from './${aggregateNaming.fileName}.aggr
2337
2344
  let ${aggregateNaming.variableName}: ${aggregateNaming.ClassName}
2338
2345
 
2339
2346
  beforeEach(() => {
2340
- ${aggregateNaming.variableName} = new ${aggregateNaming.ClassName}()
2347
+ ${aggregateNaming.variableName} = ${withTypes ? `${aggregateNaming.ClassName}.of({})` : `new ${aggregateNaming.ClassName}()`}
2341
2348
  })
2342
2349
 
2343
2350
  describe('${aggregateNaming.withSpaces}', () => {
2344
- test('can be instantiated via constructor', () => {
2351
+ test('can be instantiated via ${withTypes ? 'of' : 'constructor'}', () => {
2345
2352
  expect(${aggregateNaming.variableName}).toBeDefined()
2346
2353
  })
2347
2354
  })
@@ -2376,7 +2383,7 @@ describe('${aggregateNaming.withSpaces}', () => {
2376
2383
  naming.fileName
2377
2384
  ]);
2378
2385
  const repositoryFileName = `${naming.fileName}-${aggregateName}-repository.ts`;
2379
- if (usesInMemoryDb(implementation)) {
2386
+ if (usesInMemoryDb(implementation) && !ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
2380
2387
  const section = addInMemoryDbSection(aggregateNaming, aggregatesFolder.path);
2381
2388
  repositoryFolder.createFile(repositoryFileName, `
2382
2389
  ${inMemoryDbTypeImport(repositoryFolder.subitem([
@@ -2441,8 +2448,12 @@ export const wire${aggregateNaming.ClassName}Repository = envBranchedWire({
2441
2448
  production: wire${implementationNaming.ClassName}Implementation
2442
2449
  })
2443
2450
  `.trim());
2444
- for (const implementation of implementationTypes.filter(usesInMemoryDb))wireInMemoryDb(wireFile, `${new UnknownFormatNaming(implementation).ClassName}${aggregateNaming.ClassName}Repository`);
2445
- await wireNewModuleDependencies(boundedContextFolder, wireFile);
2451
+ await wireNewModuleDependencies(boundedContextFolder, wireFile, (implementation, dependency)=>{
2452
+ if (!isInMemoryDb(dependency)) return false;
2453
+ keepInMemoryDbSection(new File(implementation.file), addInMemoryDbSection(aggregateNaming, aggregatesFolder.path));
2454
+ wireInMemoryDb(wireFile, implementation.className);
2455
+ return true;
2456
+ });
2446
2457
  }
2447
2458
  }
2448
2459
  };
@@ -2686,7 +2697,7 @@ export class ${formatNaming.ClassName}${naming.ClassName}Command extends ${namin
2686
2697
  }
2687
2698
  }
2688
2699
  `.trim());
2689
- if (usesInMemoryDb(implementation)) injectInMemoryDb(implementationFile, `${formatNaming.ClassName}${naming.ClassName}Command`);
2700
+ if (!withWiring && usesInMemoryDb(implementation)) injectInMemoryDb(implementationFile, `${formatNaming.ClassName}${naming.ClassName}Command`);
2690
2701
  }
2691
2702
  if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) commandsFolder.subitem([
2692
2703
  'execution'
@@ -2750,7 +2761,6 @@ export const wire${naming.ClassName}Command = envBranchedWire({
2750
2761
  production: wire${implementationNaming.ClassName}Implementation
2751
2762
  })
2752
2763
  `.trim());
2753
- for (const implementation of implementationTypes.filter(usesInMemoryDb))wireInMemoryDb(wireFile, `${new UnknownFormatNaming(implementation).ClassName}${naming.ClassName}Command`);
2754
2764
  await wireNewModuleDependencies(boundedContextFolder, wireFile);
2755
2765
  }
2756
2766
  return;
@@ -2841,7 +2851,8 @@ const scaffoldNewDomainObject = async (boundedContextFolder, kind)=>{
2841
2851
  kindFolderName
2842
2852
  ]);
2843
2853
  const fileName = `${naming.fileName}.${kind}`;
2844
- folder.createFile(`${fileName}.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/types') ? `
2854
+ const withTypes = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/types');
2855
+ folder.createFile(`${fileName}.ts`, withTypes ? `
2845
2856
  import { domainType } from '@domain-first/types'
2846
2857
 
2847
2858
  export class ${naming.ClassName} extends domainType() {
@@ -2858,11 +2869,11 @@ import { ${naming.ClassName} } from './${fileName}'
2858
2869
  let ${naming.variableName}: ${naming.ClassName}
2859
2870
 
2860
2871
  beforeEach(() => {
2861
- ${naming.variableName} = new ${naming.ClassName}()
2872
+ ${naming.variableName} = ${withTypes ? `${naming.ClassName}.of({})` : `new ${naming.ClassName}()`}
2862
2873
  })
2863
2874
 
2864
2875
  describe('${naming.withSpaces}', () => {
2865
- test('can be instantiated via constructor', () => {
2876
+ test('can be instantiated via ${withTypes ? 'of' : 'constructor'}', () => {
2866
2877
  expect(${naming.variableName}).toBeDefined()
2867
2878
  })
2868
2879
  })
@@ -3199,7 +3210,7 @@ export class ${formatNaming.ClassName}${naming.ClassName}Query extends ${naming.
3199
3210
  }
3200
3211
  }
3201
3212
  `.trim());
3202
- if (usesInMemoryDb(implementation)) injectInMemoryDb(implementationFile, `${formatNaming.ClassName}${naming.ClassName}Query`);
3213
+ if (!withWiring && usesInMemoryDb(implementation)) injectInMemoryDb(implementationFile, `${formatNaming.ClassName}${naming.ClassName}Query`);
3203
3214
  }
3204
3215
  if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) queriesFolder.subitem([
3205
3216
  'execution'
@@ -3263,7 +3274,6 @@ export const wire${naming.ClassName}Query = envBranchedWire({
3263
3274
  production: wire${implementationNaming.ClassName}Implementation
3264
3275
  })
3265
3276
  `.trim());
3266
- for (const implementation of implementationTypes.filter(usesInMemoryDb))wireInMemoryDb(wireFile, `${new UnknownFormatNaming(implementation).ClassName}${naming.ClassName}Query`);
3267
3277
  await wireNewModuleDependencies(boundedContextFolder, wireFile);
3268
3278
  }
3269
3279
  return;
package/dist/index.js CHANGED
@@ -1683,6 +1683,10 @@ const inMemoryDbSectionMembers = (field, derived)=>`
1683
1683
  ${derived ? 'super()\n ' : ''}this.data = ${in_memory_db_parameterName}.${field}
1684
1684
  }
1685
1685
  `.trim();
1686
+ const keepInMemoryDbSection = (classFile, field)=>{
1687
+ classFile.update(addImport(classFile.data, inMemoryDbTypeImport(classFile.path)).replace('constructor() {}', inMemoryDbSectionMembers(field, false)));
1688
+ };
1689
+ const isInMemoryDb = (module)=>module.wireName === in_memory_db_wireName;
1686
1690
  const injectInMemoryDb = (classFile, implementationName)=>{
1687
1691
  classFile.update(addConstructorParameters(addImport(classFile.data, inMemoryDbTypeImport(classFile.path)), implementationName, [
1688
1692
  `private readonly ${in_memory_db_parameterName}: ${in_memory_db_className}`
@@ -1712,7 +1716,8 @@ const groupedChoices = (items, suggested = [])=>{
1712
1716
  new Separator('── Suggested'),
1713
1717
  ...suggested.map((x)=>({
1714
1718
  name: x.label,
1715
- value: x
1719
+ value: x,
1720
+ checked: true
1716
1721
  }))
1717
1722
  ] : [];
1718
1723
  const kinds = [
@@ -1753,7 +1758,7 @@ const contextAndSharedModules = (boundedContextFolder)=>{
1753
1758
  }))
1754
1759
  ];
1755
1760
  };
1756
- const promptDependencies = async (boundedContextFolder, consumer, implementations = consumer.implementations)=>{
1761
+ const promptDependencies = async (boundedContextFolder, consumer, implementations = consumer.implementations, customWiring)=>{
1757
1762
  const options = contextAndSharedModules(boundedContextFolder);
1758
1763
  let asked = false;
1759
1764
  for (const implementation of implementations){
@@ -1769,13 +1774,14 @@ const promptDependencies = async (boundedContextFolder, consumer, implementation
1769
1774
  pageSize: groupedPageSize,
1770
1775
  loop: false
1771
1776
  });
1772
- if (dependencies.length) wireDependencies(consumer, implementation, dependencies.map((x)=>x.module));
1777
+ const defaultWired = dependencies.map((x)=>x.module).filter((x)=>!customWiring?.(implementation, x));
1778
+ if (defaultWired.length) wireDependencies(consumer, implementation, defaultWired);
1773
1779
  }
1774
1780
  return asked;
1775
1781
  };
1776
- const wireNewModuleDependencies = async (boundedContextFolder, wireFile)=>{
1782
+ const wireNewModuleDependencies = async (boundedContextFolder, wireFile, customWiring)=>{
1777
1783
  const consumer = readWiredModule(wireFile.path, boundedContextFolder.path);
1778
- if (consumer) await promptDependencies(boundedContextFolder, consumer);
1784
+ if (consumer) await promptDependencies(boundedContextFolder, consumer, consumer.implementations, customWiring);
1779
1785
  };
1780
1786
  const wireDependency = async (boundedContextFolder)=>{
1781
1787
  const modules = findWiredModules(boundedContextFolder.path);
@@ -2293,7 +2299,8 @@ const scaffoldNewAggregateUseCase = async (boundedContextFolder)=>{
2293
2299
  'aggregates',
2294
2300
  aggregateName
2295
2301
  ]);
2296
- aggregatesFolder.createFile(`${aggregateNaming.fileName}.aggregate-root.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/types') ? `
2302
+ const withTypes = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/types');
2303
+ aggregatesFolder.createFile(`${aggregateNaming.fileName}.aggregate-root.ts`, withTypes ? `
2297
2304
  import { domainType } from '@domain-first/types'
2298
2305
 
2299
2306
  export class ${aggregateNaming.ClassName} extends domainType() {
@@ -2307,11 +2314,11 @@ import { ${aggregateNaming.ClassName} } from './${aggregateNaming.fileName}.aggr
2307
2314
  let ${aggregateNaming.variableName}: ${aggregateNaming.ClassName}
2308
2315
 
2309
2316
  beforeEach(() => {
2310
- ${aggregateNaming.variableName} = new ${aggregateNaming.ClassName}()
2317
+ ${aggregateNaming.variableName} = ${withTypes ? `${aggregateNaming.ClassName}.of({})` : `new ${aggregateNaming.ClassName}()`}
2311
2318
  })
2312
2319
 
2313
2320
  describe('${aggregateNaming.withSpaces}', () => {
2314
- test('can be instantiated via constructor', () => {
2321
+ test('can be instantiated via ${withTypes ? 'of' : 'constructor'}', () => {
2315
2322
  expect(${aggregateNaming.variableName}).toBeDefined()
2316
2323
  })
2317
2324
  })
@@ -2346,7 +2353,7 @@ describe('${aggregateNaming.withSpaces}', () => {
2346
2353
  naming.fileName
2347
2354
  ]);
2348
2355
  const repositoryFileName = `${naming.fileName}-${aggregateName}-repository.ts`;
2349
- if (usesInMemoryDb(implementation)) {
2356
+ if (usesInMemoryDb(implementation) && !ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
2350
2357
  const section = addInMemoryDbSection(aggregateNaming, aggregatesFolder.path);
2351
2358
  repositoryFolder.createFile(repositoryFileName, `
2352
2359
  ${inMemoryDbTypeImport(repositoryFolder.subitem([
@@ -2411,8 +2418,12 @@ export const wire${aggregateNaming.ClassName}Repository = envBranchedWire({
2411
2418
  production: wire${implementationNaming.ClassName}Implementation
2412
2419
  })
2413
2420
  `.trim());
2414
- for (const implementation of implementationTypes.filter(usesInMemoryDb))wireInMemoryDb(wireFile, `${new UnknownFormatNaming(implementation).ClassName}${aggregateNaming.ClassName}Repository`);
2415
- await wireNewModuleDependencies(boundedContextFolder, wireFile);
2421
+ await wireNewModuleDependencies(boundedContextFolder, wireFile, (implementation, dependency)=>{
2422
+ if (!isInMemoryDb(dependency)) return false;
2423
+ keepInMemoryDbSection(new File(implementation.file), addInMemoryDbSection(aggregateNaming, aggregatesFolder.path));
2424
+ wireInMemoryDb(wireFile, implementation.className);
2425
+ return true;
2426
+ });
2416
2427
  }
2417
2428
  }
2418
2429
  };
@@ -2656,7 +2667,7 @@ export class ${formatNaming.ClassName}${naming.ClassName}Command extends ${namin
2656
2667
  }
2657
2668
  }
2658
2669
  `.trim());
2659
- if (usesInMemoryDb(implementation)) injectInMemoryDb(implementationFile, `${formatNaming.ClassName}${naming.ClassName}Command`);
2670
+ if (!withWiring && usesInMemoryDb(implementation)) injectInMemoryDb(implementationFile, `${formatNaming.ClassName}${naming.ClassName}Command`);
2660
2671
  }
2661
2672
  if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) commandsFolder.subitem([
2662
2673
  'execution'
@@ -2720,7 +2731,6 @@ export const wire${naming.ClassName}Command = envBranchedWire({
2720
2731
  production: wire${implementationNaming.ClassName}Implementation
2721
2732
  })
2722
2733
  `.trim());
2723
- for (const implementation of implementationTypes.filter(usesInMemoryDb))wireInMemoryDb(wireFile, `${new UnknownFormatNaming(implementation).ClassName}${naming.ClassName}Command`);
2724
2734
  await wireNewModuleDependencies(boundedContextFolder, wireFile);
2725
2735
  }
2726
2736
  return;
@@ -2811,7 +2821,8 @@ const scaffoldNewDomainObject = async (boundedContextFolder, kind)=>{
2811
2821
  kindFolderName
2812
2822
  ]);
2813
2823
  const fileName = `${naming.fileName}.${kind}`;
2814
- folder.createFile(`${fileName}.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/types') ? `
2824
+ const withTypes = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/types');
2825
+ folder.createFile(`${fileName}.ts`, withTypes ? `
2815
2826
  import { domainType } from '@domain-first/types'
2816
2827
 
2817
2828
  export class ${naming.ClassName} extends domainType() {
@@ -2828,11 +2839,11 @@ import { ${naming.ClassName} } from './${fileName}'
2828
2839
  let ${naming.variableName}: ${naming.ClassName}
2829
2840
 
2830
2841
  beforeEach(() => {
2831
- ${naming.variableName} = new ${naming.ClassName}()
2842
+ ${naming.variableName} = ${withTypes ? `${naming.ClassName}.of({})` : `new ${naming.ClassName}()`}
2832
2843
  })
2833
2844
 
2834
2845
  describe('${naming.withSpaces}', () => {
2835
- test('can be instantiated via constructor', () => {
2846
+ test('can be instantiated via ${withTypes ? 'of' : 'constructor'}', () => {
2836
2847
  expect(${naming.variableName}).toBeDefined()
2837
2848
  })
2838
2849
  })
@@ -3169,7 +3180,7 @@ export class ${formatNaming.ClassName}${naming.ClassName}Query extends ${naming.
3169
3180
  }
3170
3181
  }
3171
3182
  `.trim());
3172
- if (usesInMemoryDb(implementation)) injectInMemoryDb(implementationFile, `${formatNaming.ClassName}${naming.ClassName}Query`);
3183
+ if (!withWiring && usesInMemoryDb(implementation)) injectInMemoryDb(implementationFile, `${formatNaming.ClassName}${naming.ClassName}Query`);
3173
3184
  }
3174
3185
  if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) queriesFolder.subitem([
3175
3186
  'execution'
@@ -3233,7 +3244,6 @@ export const wire${naming.ClassName}Query = envBranchedWire({
3233
3244
  production: wire${implementationNaming.ClassName}Implementation
3234
3245
  })
3235
3246
  `.trim());
3236
- for (const implementation of implementationTypes.filter(usesInMemoryDb))wireInMemoryDb(wireFile, `${new UnknownFormatNaming(implementation).ClassName}${naming.ClassName}Query`);
3237
3247
  await wireNewModuleDependencies(boundedContextFolder, wireFile);
3238
3248
  }
3239
3249
  return;
@@ -1,2 +1,2 @@
1
- import type { Folder } from '../file-system';
1
+ import { type Folder } from '../file-system';
2
2
  export declare const scaffoldNewAggregateUseCase: (boundedContextFolder: Folder) => Promise<void>;
@@ -1,9 +1,14 @@
1
1
  import { type File, Folder } from '../file-system';
2
- import { type WiredModule } from '../wiring';
2
+ import { type WiredClass, type WiredModule } from '../wiring';
3
+ /**
4
+ * Wires a chosen dependency in its own way. Returns false to leave it to
5
+ * the default wiring.
6
+ */
7
+ export type CustomWiring = (implementation: WiredClass, dependency: WiredModule) => boolean;
3
8
  /**
4
9
  * The last step of generators that create a wire.
5
10
  */
6
- export declare const wireNewModuleDependencies: (boundedContextFolder: Folder, wireFile: File) => Promise<void>;
11
+ export declare const wireNewModuleDependencies: (boundedContextFolder: Folder, wireFile: File, customWiring?: CustomWiring) => Promise<void>;
7
12
  export declare const wireDependency: (boundedContextFolder: Folder) => Promise<void>;
8
13
  /**
9
14
  * The endpoint's handler, from the context's queries, commands, and use
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": "3.2.0",
4
+ "version": "3.2.1",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
@@ -112,7 +112,7 @@ node scripts/drive.mjs "pick:Bounded Context: sales" pick:Domain "pick:New Aggre
112
112
  | `pick:<label>` | select | Types a **prefix of the choice text** + Enter. Aborts before submitting if the highlighted choice doesn't match. |
113
113
  | `text:<v>` / `default` | input | Types a value / accepts the default. |
114
114
  | `yes` / `no` | confirm | |
115
- | `toggle:1,3` / `none` | checkbox | Init, `Dependencies:`, `Dependencies for <Implementation>:`. |
115
+ | `toggle:1,3` / `none` | checkbox | Init, `Dependencies:`, `Dependencies for <Implementation>:`. `Suggested` items come checked: toggling unchecks. |
116
116
 
117
117
  Check every run: exit code 0, no `WARNING`/`ABORTED`, and exactly the planned files. "Still waiting for input" means too few steps; nothing was written. If the raw output ends at `Overwrite them?`, the run would replace files the plan didn't flag: show the user the listed files and ask, never just add `yes`. If prompts get out of sync, retry with `--delay 1200`.
118
118
 
@@ -6,7 +6,7 @@ Every step list starts with `"pick:Bounded Context: <ctx>"` or `"pick:Shared Lay
6
6
 
7
7
  Any generator: if the run would replace existing files, the last prompt is the confirm `Overwrite them?` (the files are listed above it). Without it, nothing extra is asked. Added lines (barrels, errors, wiring indexes) never trigger it.
8
8
 
9
- {wire} Generators that create a wire (all below except endpoints, which ask their own two selects) then ask the checkbox `Dependencies:`, before `Overwrite them?`. It lists wired modules of `<C>` and of the Shared Layer (`(shared)` suffix), grouped under headers in this order: Repositories, Domain services, Ports, Application services, Queries, Commands, Use cases, Infrastructure services, Presentation services. Inside a group: by type name, `<C>` first. Headers are not counted: `toggle:<n,..>` numbers only modules, top to bottom. Answer `toggle:<n,..>` or `none`. It is skipped when nothing fits, so check `<C>/wiring/` and `<rootFolder>/shared/wiring/` before counting steps. What fits depends on the layer of the class the wire builds: domain → domain; application → domain, application; infrastructure (repository, execution command/query, and port implementations) → domain, infrastructure (it implements application modules, never depends on them); presentation → application, presentation. On top of that, application services see only ports from application, use cases never see use cases, repository implementations never see repositories, execution command/query implementations never see commands or queries, and orchestration commands/queries see only execution commands and queries from application. Endpoints are never listed. Each chosen module goes into the wire (`wireClass(X, [wireUserRepository])`) and the constructor (`private readonly userRepository: UserRepository`, with `import type`), in the same order. An env-branched wire (repository, execution command/query, port) wires each implementation in isolation: instead of `Dependencies:` it asks `Dependencies for <Implementation>:` once per implementation, in the order of the wire (main, then test). Each list leaves out only what that implementation already has, and a list with nothing to choose is skipped. It may start with a `Suggested` group: infrastructure modules whose file name has the implementation label (its folder, e.g. `prisma`, `in-memory`) as whole words, such as `in-memory-db-infrastructure-service` for `in-memory`. They are listed there only, so numbering starts with them.
9
+ {wire} Generators that create a wire (all below except endpoints, which ask their own two selects) then ask the checkbox `Dependencies:`, before `Overwrite them?`. It lists wired modules of `<C>` and of the Shared Layer (`(shared)` suffix), grouped under headers in this order: Repositories, Domain services, Ports, Application services, Queries, Commands, Use cases, Infrastructure services, Presentation services. Inside a group: by type name, `<C>` first. Headers are not counted: `toggle:<n,..>` numbers only modules, top to bottom. Answer `toggle:<n,..>` or `none`. It is skipped when nothing fits, so check `<C>/wiring/` and `<rootFolder>/shared/wiring/` before counting steps. What fits depends on the layer of the class the wire builds: domain → domain; application → domain, application; infrastructure (repository, execution command/query, and port implementations) → domain, infrastructure (it implements application modules, never depends on them); presentation → application, presentation. On top of that, application services see only ports from application, use cases never see use cases, repository implementations never see repositories, execution command/query implementations never see commands or queries, and orchestration commands/queries see only execution commands and queries from application. Endpoints are never listed. Each chosen module goes into the wire (`wireClass(X, [wireUserRepository])`) and the constructor (`private readonly userRepository: UserRepository`, with `import type`), in the same order. An env-branched wire (repository, execution command/query, port) wires each implementation in isolation: instead of `Dependencies:` it asks `Dependencies for <Implementation>:` once per implementation, in the order of the wire (main, then test). Each list leaves out only what that implementation already has, and a list with nothing to choose is skipped. It may start with a `Suggested` group: infrastructure modules whose file name has the implementation label (its folder, e.g. `prisma`, `in-memory`) as whole words, such as `in-memory-db-infrastructure-service` for `in-memory`. They are listed there only, so numbering starts with them, and they are **checked**: `none` keeps them, `toggle:<n>` on one of them unchecks it.
10
10
 
11
11
  ## Bounded context
12
12
 
@@ -21,7 +21,7 @@ Prompts: name → `With Repository` → if yes: implementation (default = config
21
21
  - `<C>/domain/aggregates/n/`: `n.aggregate-root.ts` (`class N extends domainType()` {types}), `index.ts`, spec; with repository: `n-repository.ts` (`abstract class NRepository`), spec
22
22
  - `<C>/infrastructure/repositories/I/I-n-repository.ts` per implementation (`class INRepository implements NRepository`)
23
23
  - {wire} `<C>/wiring/repositories/wire-n-repository.ts` (env-branched)
24
- - With `withInMemoryDb` in the config, the `in-memory` implementation is not empty: `private readonly data: InMemoryDbInfrastructureService['ns']`, set in the constructor from its `inMemoryDbInfrastructureService` parameter; `ns = this.section<N>('NS');` is added to `<rootFolder>/shared/infrastructure/services/in-memory-db-infrastructure-service.ts` if missing (`N` needs an `id`), and {wire} its `wireClass` already has `wireInMemoryDbInfrastructureService`, so `Dependencies for InMemoryNRepository:` doesn't list it.
24
+ - With `withInMemoryDb` in the config, the `in-memory` implementation can keep its section of the DB: `private readonly data: InMemoryDbInfrastructureService['ns']`, set in the constructor from its `inMemoryDbInfrastructureService` parameter; `ns = this.section<N>('NS');` is added to `<rootFolder>/shared/infrastructure/services/in-memory-db-infrastructure-service.ts` if missing (`N` needs an `id`). Without {wire} this always happens. {wire} `Dependencies for InMemoryNRepository:` lists the DB under `Suggested`, checked: kept, it gets the section and `wireInMemoryDbInfrastructureService` in its `wireClass`; unchecked, the implementation stays empty (`constructor() {}`) and no section is added.
25
25
 
26
26
  ## Domain → New Entity / New Value Object (context and Shared Layer)
27
27
 
@@ -78,7 +78,7 @@ Execution:
78
78
  - `<C>/application/commands/execution/n-command.ts`: abstract `NCommand` ({handlers} schemas + abstract `handle: Handler<…>`), spec
79
79
  - `<C>/infrastructure/commands/I/I-n-command.ts` per implementation (`extends NCommand`, implements `handle`)
80
80
  - {wire} `<C>/wiring/commands/wire-n-command.ts` (env-branched)
81
- - With `withInMemoryDb` in the config, the `in-memory` implementation gets the whole DB: `constructor(private readonly inMemoryDbInfrastructureService: InMemoryDbInfrastructureService)`, {wire} already in its `wireClass`. No section is added.
81
+ - With `withInMemoryDb` in the config, the `in-memory` implementation can get the whole DB: `constructor(private readonly inMemoryDbInfrastructureService: InMemoryDbInfrastructureService)`. No section is added. Without {wire} this always happens; {wire} it is the checked `Suggested` choice of `Dependencies for InMemoryN<Suffix>:`, and unchecking it leaves the implementation empty.
82
82
 
83
83
  Orchestrator: `<C>/application/commands/orchestration/n-command.ts` (concrete class), spec, {wire} `wire-n-command.ts`.
84
84
 
@@ -225,7 +225,7 @@ Without wire: import `<Class>` from `<noWire>`, use `new <Class>()` and the test
225
225
 
226
226
  | Component | Spec next to | `<Type>` / `<var>` | `<wirePath>` | `<label>` | `<Class>` from `<noWire>`, `<noWireTest>` |
227
227
  | -------------------- | ---------------------------- | ----------------------------- | ------------------------------------------------ | -------------------- | -------------------------------------------------------------------------------------------------------- |
228
- | Aggregate root | `n.aggregate-root.ts` | `N` / `v` | none: always `new N()` | `n words` | `N` `./n.aggregate-root`, `can be instantiated via constructor` |
228
+ | Aggregate root | `n.aggregate-root.ts` | `N` / `v` | none: `N.of({})` {types} (`can be instantiated via of`), `new N()` otherwise | `n words` | `N` `./n.aggregate-root`, `can be instantiated via constructor` |
229
229
  | Repository* | `n-repository.ts` | `NRepository` / `vRepository` | `../../../wiring/repositories/wire-n-repository` | `n words repository` | `INRepository` `../../../infrastructure/repositories/I/I-n-repository`, `can be created via constructor` |
230
230
  | Service | `n-L-service.ts` | `NLService` / `vLService` | `../../wiring/L-services/wire-n-L-service` | `n words` | `NLService` `./n-L-service`, `can be created` |
231
231
  | Use case | `n-use-case.ts` | `NUseCase` / `vUseCase` | `../../wiring/use-cases/wire-n-use-case` | `n words use case` | `NUseCase` `./n-use-case`, `can be created` |
@@ -233,4 +233,4 @@ Without wire: import `<Class>` from `<noWire>`, use `new <Class>()` and the test
233
233
  | Orchestrator command | `orchestration/n-command.ts` | `NCommand` / `vCommand` | `../../../wiring/commands/wire-n-command` | `n words command` | `NCommand` `./n-command`, `can be created via constructor` |
234
234
  | Port | `n.ts` | `N` / `v` | `../../wiring/application-ports/wire-n` | `n words` | `IN` `../../infrastructure/application-adapters/I/I-n`, `can be created via constructor` |
235
235
 
236
- `n words` = the name with spaces instead of hyphens. Queries are the same as commands. \*The repository spec imports the wire first, then `import type { NRepository } from './n-repository'`.
236
+ Entities and value objects (`n.entity.ts`, `n.value-object.ts`) follow the aggregate root row. `n words` = the name with spaces instead of hyphens. Queries are the same as commands. \*The repository spec imports the wire first, then `import type { NRepository } from './n-repository'`.
@@ -13,7 +13,7 @@
13
13
  * yes | no confirm prompt
14
14
  * toggle:<n,..> checkbox prompt: toggle 1-based items (headers not counted),
15
15
  * moving with the arrow keys, then press Enter
16
- * none checkbox prompt: submit with nothing selected
16
+ * none checkbox prompt: submit as is (pre-checked items stay checked)
17
17
  */
18
18
  import { spawn } from 'node:child_process';
19
19
  import fs from 'node:fs';