@domain-first/project-structure 2.9.0 → 2.10.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/README.md CHANGED
@@ -84,7 +84,7 @@ A bounded context groups a business area and its implementation. Within it, each
84
84
  | `presentation/` | REST endpoints and presentation services. |
85
85
  | `wiring/` | Factories that construct components and select implementations, when `@domain-first/wire` is enabled. |
86
86
 
87
- The **Shared Layer** menu provides cross-context errors, application ports, and application, infrastructure, and presentation services under `<rootFolder>/shared`.
87
+ The **Shared Layer** menu provides cross-context errors, entities and value objects, application ports, and application, infrastructure, and presentation services under `<rootFolder>/shared`.
88
88
 
89
89
  A project using handler and wiring integrations can grow into this structure:
90
90
 
@@ -131,6 +131,7 @@ Choose a bounded context, then a layer:
131
131
  | Layer / menu option | Generated output |
132
132
  | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
133
133
  | Domain → New Aggregate | Aggregate root and barrel export; optional repository contract, primary and test implementations, tests, and repository wiring. |
134
+ | Domain → New Entity / New Value Object | Entity or value object class with tests, in the `entities/` or `value-objects/` folder of a chosen aggregate (exported from its barrel) or of the context's `domain/`. Also in the Shared Layer, under `shared/domain/`. |
134
135
  | Domain → Errors | Errors in the context namespace, nested namespaces, and exports. Uses `@domain-first/errors`. |
135
136
  | Domain → New Service | Domain service class, with optional tests and wiring. |
136
137
  | Application → New Use Case | Use case class; handler schemas and `handle` when enabled; optional tests and wiring. |
@@ -184,7 +185,7 @@ Enable `useReact` and choose **Scaffold React module** from the main menu. Modul
184
185
  | ------------------------------ | ---------------------------------------------------------------------------------------------------------- |
185
186
  | New page | `pages/<name>-page.tsx` with a typed props object and a component. |
186
187
  | New widget → monolithic | `widgets/<name>/<name>-widget.tsx` with props and rendering in one file, re-exported from `index.ts`. |
187
- | New widget → with separated ui | `<name>-widget.tsx`, `types.ts`, `ui/<name>-widget-ui.tsx`, `hooks/use-<name>-ui-model.ts`, and `index.ts`. |
188
+ | New widget → with separated ui | `<name>-widget.tsx`, `types.ts`, `ui/<name>-widget-ui.tsx`, `hooks/use-<name>-ui-model.ts`, and `index.ts`; with `storybookFramework`, also `ui/<name>-widget-ui.stories.tsx`. |
188
189
  | New widget → headless | `<name>-widget.tsx`, types, a UI-model hook, and `index.ts`; the rendering component is supplied through the `UI` prop. |
189
190
  | New UI-kit component | `ui-kit/<name>/<name>.tsx` with a typed props object and a component, re-exported from `index.ts`; with `storybookFramework`, also `<name>.stories.tsx`. |
190
191
  | New shared hook | `hooks/use-<name>.ts` with an app-wide hook, such as `use-debounce`; a leading `use-` in the name is not repeated. |
@@ -216,7 +217,7 @@ The project configuration is stored in `domain-first.project-structure.config.js
216
217
  | `domainFirstPackages` | Explicit list of integrations used by templates. An empty array selects basic class templates where supported. |
217
218
  | `defaultPersistenceLayerImplementation` | Suggested implementation label for execution commands and queries. |
218
219
  | `useReact` | Shows or hides the React module menu. |
219
- | `storybookFramework` | Storybook framework package imported by generated stories (`Meta`, `StoryObj`), e.g. `@storybook/react-vite`. Omit this field to skip stories for UI-kit components. Asked during setup only when React is enabled. |
220
+ | `storybookFramework` | Storybook framework package imported by generated stories (`Meta`, `StoryObj`), e.g. `@storybook/react-vite`. Omit this field to skip stories for UI-kit components and widget UI. Asked during setup only when React is enabled. |
220
221
  | `testingLibrary` | Module imported by generated tests. Omit this field to disable test generation. Templates expect helpers such as `describe`, `test`, `expect`, and `beforeEach`. |
221
222
 
222
223
  ### Package integrations
@@ -18,5 +18,9 @@ export declare class File extends FileSystemItem {
18
18
  get data(): string;
19
19
  set data(content: string);
20
20
  addLine: (newLine: string, separator?: string) => void;
21
+ /**
22
+ * Re-running a generator for the same name must not duplicate the line.
23
+ */
24
+ addLineIfMissing: (newLine: string, separator?: string) => void;
21
25
  }
22
26
  export {};
package/dist/index.cjs CHANGED
@@ -99,6 +99,10 @@ class File extends FileSystemItem {
99
99
  newLine.trim()
100
100
  ].filter((x)=>!!x).join(separator), 'utf8');
101
101
  };
102
+ addLineIfMissing = (newLine, separator = '\n')=>{
103
+ const alreadyAdded = this.exists && this.data.split('\n').some((line)=>line.trim() === newLine.trim());
104
+ if (!alreadyAdded) this.addLine(newLine, separator);
105
+ };
102
106
  }
103
107
  class ProjectRoot {
104
108
  path;
@@ -719,6 +723,60 @@ test('can be ${withWiring ? 'wired' : 'created via constructor'}', () => {
719
723
  })
720
724
  `.trim());
721
725
  };
726
+ const noAggregate = 'No aggregate';
727
+ const scaffoldNewDomainObject = async (boundedContextFolder, kind)=>{
728
+ const name = await (0, prompts_namespaceObject.input)({
729
+ message: 'Name: '
730
+ });
731
+ const naming = new UnknownFormatNaming(name);
732
+ const aggregatesFolder = boundedContextFolder.subitem([
733
+ 'domain',
734
+ 'aggregates'
735
+ ]);
736
+ const aggregateNames = aggregatesFolder.content.subfolderNames;
737
+ const aggregate = aggregateNames.length ? await (0, prompts_namespaceObject.select)({
738
+ message: 'Aggregate:',
739
+ choices: [
740
+ ...aggregateNames,
741
+ noAggregate
742
+ ]
743
+ }) : noAggregate;
744
+ const kindFolderName = 'entity' === kind ? 'entities' : 'value-objects';
745
+ const folder = aggregate === noAggregate ? boundedContextFolder.subitem([
746
+ 'domain',
747
+ kindFolderName
748
+ ]) : aggregatesFolder.subitem([
749
+ aggregate,
750
+ kindFolderName
751
+ ]);
752
+ const fileName = `${naming.fileName}.${kind}`;
753
+ folder.createFile(`${fileName}.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/types') ? `
754
+ import { domainType } from '@domain-first/types'
755
+
756
+ export class ${naming.ClassName} extends domainType() {
757
+
758
+ }`.trim() : `export class ${naming.ClassName} {}`);
759
+ if (aggregate !== noAggregate) aggregatesFolder.subitem([
760
+ aggregate
761
+ ]).file('index.ts').addLineIfMissing(`export * from './${kindFolderName}/${fileName}'`);
762
+ const { testingLibrary } = ConfigFile.Instance.data;
763
+ if (testingLibrary) folder.createFile(`${fileName}.spec.ts`, `
764
+ import { describe, test, expect, beforeEach } from '${testingLibrary}'
765
+ import { ${naming.ClassName} } from './${fileName}'
766
+
767
+ let ${naming.variableName}: ${naming.ClassName}
768
+
769
+ beforeEach(() => {
770
+ ${naming.variableName} = new ${naming.ClassName}()
771
+ })
772
+
773
+ describe('${naming.withSpaces}', () => {
774
+ test('can be instantiated via constructor', () => {
775
+ expect(${naming.variableName}).toBeDefined()
776
+ })
777
+ })
778
+ `.trim());
779
+ };
722
780
  const scaffoldNewDomainService = async (boundedContextFolder)=>{
723
781
  const portName = await (0, prompts_namespaceObject.input)({
724
782
  message: 'Name:'
@@ -785,7 +843,7 @@ const scaffoldNewErrorUseCase = async (boundedContextFolder)=>{
785
843
  message: 'Error name:'
786
844
  });
787
845
  const naming = new UnknownFormatNaming(errorName);
788
- currentErrorFolder.file('index.ts').addLine(`export const ${naming.ClassName}${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Error = ${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Errors.define('${naming.fileName}')`, '\n\n');
846
+ currentErrorFolder.file('index.ts').addLineIfMissing(`export const ${naming.ClassName}${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Error = ${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Errors.define('${naming.fileName}')`, '\n\n');
789
847
  return;
790
848
  }
791
849
  if ('New namespace' === selectedVariant) {
@@ -793,12 +851,12 @@ const scaffoldNewErrorUseCase = async (boundedContextFolder)=>{
793
851
  message: 'Namespace name:'
794
852
  });
795
853
  const { ClassName, fileName } = new UnknownFormatNaming(namespaceName);
796
- currentErrorFolder.createFile(`${fileName}.ts`, `
854
+ if (!currentErrorFolder.file(`${fileName}.ts`).exists) currentErrorFolder.createFile(`${fileName}.ts`, `
797
855
  import { errorNamespace } from '@domain-first/errors'
798
856
 
799
857
  export const ${ClassName}${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Errors = errorNamespace('${boundedContextFolder.name}').subnamespace('${fileName}')
800
- `);
801
- currentErrorFolder.file('index.ts').addLine(`export * from './${fileName}'`, '\n\n');
858
+ `.trim());
859
+ currentErrorFolder.file('index.ts').addLineIfMissing(`export * from './${fileName}'`, '\n\n');
802
860
  return;
803
861
  }
804
862
  const namespace = selectedVariant.substring(23);
@@ -807,7 +865,7 @@ export const ${ClassName}${new UnknownFormatNaming(boundedContextFolder.name).Cl
807
865
  message: 'Error name:'
808
866
  });
809
867
  const { ClassName, fileName } = new UnknownFormatNaming(errorName);
810
- currentErrorFolder.file(`${namespace}.ts`).addLine(`export const ${ClassName}${namespaceNaming.ClassName}${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Error = ${namespaceNaming.ClassName}${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Errors.define('${fileName}')`, '\n\n');
868
+ currentErrorFolder.file(`${namespace}.ts`).addLineIfMissing(`export const ${ClassName}${namespaceNaming.ClassName}${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Error = ${namespaceNaming.ClassName}${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Errors.define('${fileName}')`, '\n\n');
811
869
  };
812
870
  const scaffoldNewHandlersRestEndpoint = async (boundedContextFolder)=>{
813
871
  const restPresentationFolder = boundedContextFolder.subitem([
@@ -1354,12 +1412,13 @@ export const ${ClassName}Widget: FC<${ClassName}WidgetProps> = (props) => {
1354
1412
  `.trim());
1355
1413
  break;
1356
1414
  case 'with separated ui':
1357
- folder.createFile('types.ts', `
1415
+ {
1416
+ folder.createFile('types.ts', `
1358
1417
  export type ${ClassName}WidgetProps = { }
1359
1418
 
1360
1419
  export type ${ClassName}WidgetUIProps = { }
1361
1420
  `.trim());
1362
- folder.createFile(`${widgetFileName}.tsx`, `
1421
+ folder.createFile(`${widgetFileName}.tsx`, `
1363
1422
  import { type FC } from 'react'
1364
1423
  import type { ${ClassName}WidgetProps } from './types'
1365
1424
  import { ${ClassName}WidgetUI } from './ui/${uiFileName}'
@@ -1372,9 +1431,9 @@ export const ${ClassName}Widget: FC<${ClassName}WidgetProps> = (props) => {
1372
1431
 
1373
1432
  export type { ${ClassName}WidgetProps }
1374
1433
  `.trim());
1375
- folder.subitem([
1376
- 'ui'
1377
- ]).createFile(`${uiFileName}.tsx`, `
1434
+ folder.subitem([
1435
+ 'ui'
1436
+ ]).createFile(`${uiFileName}.tsx`, `
1378
1437
  import { FC } from 'react'
1379
1438
  import type { ${ClassName}WidgetUIProps } from '../types'
1380
1439
 
@@ -1382,16 +1441,37 @@ export const ${ClassName}WidgetUI: FC<${ClassName}WidgetUIProps> = (props) => {
1382
1441
  return <></>
1383
1442
  }
1384
1443
  `.trim());
1385
- folder.subitem([
1386
- 'hooks'
1387
- ]).createFile(`${uiModelFileName}.ts`, `
1444
+ const { storybookFramework } = ConfigFile.Instance.data;
1445
+ if (storybookFramework) folder.subitem([
1446
+ 'ui'
1447
+ ]).createFile(`${uiFileName}.stories.tsx`, `
1448
+ import type { Meta, StoryObj } from '${storybookFramework}'
1449
+ import { ${ClassName}WidgetUI } from './${uiFileName}'
1450
+
1451
+ const meta = {
1452
+ title: 'Widgets/${ClassName}',
1453
+ component: ${ClassName}WidgetUI
1454
+ } satisfies Meta<typeof ${ClassName}WidgetUI>
1455
+
1456
+ export default meta
1457
+
1458
+ type Story = StoryObj<typeof meta>
1459
+
1460
+ export const Default: Story = {
1461
+ args: {}
1462
+ }
1463
+ `.trim());
1464
+ folder.subitem([
1465
+ 'hooks'
1466
+ ]).createFile(`${uiModelFileName}.ts`, `
1388
1467
  import type { ${ClassName}WidgetProps, ${ClassName}WidgetUIProps } from '../types'
1389
1468
 
1390
1469
  export const use${ClassName}UIModel = (widgetProps: ${ClassName}WidgetProps): ${ClassName}WidgetUIProps => {
1391
1470
  return {}
1392
1471
  }
1393
1472
  `.trim());
1394
- break;
1473
+ break;
1474
+ }
1395
1475
  case 'headless':
1396
1476
  folder.createFile('types.ts', `
1397
1477
  import { type FC } from 'react'
@@ -1515,15 +1595,23 @@ const main = async ()=>{
1515
1595
  message: 'Domain layer operation:',
1516
1596
  choices: specificContext ? [
1517
1597
  'New Aggregate',
1598
+ 'New Entity',
1599
+ 'New Value Object',
1518
1600
  'Errors',
1519
1601
  'New Service'
1520
1602
  ] : [
1603
+ 'New Entity',
1604
+ 'New Value Object',
1521
1605
  'Errors'
1522
1606
  ]
1523
1607
  });
1524
1608
  switch(operation){
1525
1609
  case 'New Aggregate':
1526
1610
  return void await scaffoldNewAggregateUseCase(boundedContextFolder);
1611
+ case 'New Entity':
1612
+ return void await scaffoldNewDomainObject(boundedContextFolder, 'entity');
1613
+ case 'New Value Object':
1614
+ return void await scaffoldNewDomainObject(boundedContextFolder, 'value-object');
1527
1615
  case 'Errors':
1528
1616
  return void await scaffoldNewErrorUseCase(boundedContextFolder);
1529
1617
  case 'New Service':
package/dist/index.js CHANGED
@@ -69,6 +69,10 @@ class File extends FileSystemItem {
69
69
  newLine.trim()
70
70
  ].filter((x)=>!!x).join(separator), 'utf8');
71
71
  };
72
+ addLineIfMissing = (newLine, separator = '\n')=>{
73
+ const alreadyAdded = this.exists && this.data.split('\n').some((line)=>line.trim() === newLine.trim());
74
+ if (!alreadyAdded) this.addLine(newLine, separator);
75
+ };
72
76
  }
73
77
  class ProjectRoot {
74
78
  path;
@@ -689,6 +693,60 @@ test('can be ${withWiring ? 'wired' : 'created via constructor'}', () => {
689
693
  })
690
694
  `.trim());
691
695
  };
696
+ const noAggregate = 'No aggregate';
697
+ const scaffoldNewDomainObject = async (boundedContextFolder, kind)=>{
698
+ const name = await input({
699
+ message: 'Name: '
700
+ });
701
+ const naming = new UnknownFormatNaming(name);
702
+ const aggregatesFolder = boundedContextFolder.subitem([
703
+ 'domain',
704
+ 'aggregates'
705
+ ]);
706
+ const aggregateNames = aggregatesFolder.content.subfolderNames;
707
+ const aggregate = aggregateNames.length ? await prompts_select({
708
+ message: 'Aggregate:',
709
+ choices: [
710
+ ...aggregateNames,
711
+ noAggregate
712
+ ]
713
+ }) : noAggregate;
714
+ const kindFolderName = 'entity' === kind ? 'entities' : 'value-objects';
715
+ const folder = aggregate === noAggregate ? boundedContextFolder.subitem([
716
+ 'domain',
717
+ kindFolderName
718
+ ]) : aggregatesFolder.subitem([
719
+ aggregate,
720
+ kindFolderName
721
+ ]);
722
+ const fileName = `${naming.fileName}.${kind}`;
723
+ folder.createFile(`${fileName}.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/types') ? `
724
+ import { domainType } from '@domain-first/types'
725
+
726
+ export class ${naming.ClassName} extends domainType() {
727
+
728
+ }`.trim() : `export class ${naming.ClassName} {}`);
729
+ if (aggregate !== noAggregate) aggregatesFolder.subitem([
730
+ aggregate
731
+ ]).file('index.ts').addLineIfMissing(`export * from './${kindFolderName}/${fileName}'`);
732
+ const { testingLibrary } = ConfigFile.Instance.data;
733
+ if (testingLibrary) folder.createFile(`${fileName}.spec.ts`, `
734
+ import { describe, test, expect, beforeEach } from '${testingLibrary}'
735
+ import { ${naming.ClassName} } from './${fileName}'
736
+
737
+ let ${naming.variableName}: ${naming.ClassName}
738
+
739
+ beforeEach(() => {
740
+ ${naming.variableName} = new ${naming.ClassName}()
741
+ })
742
+
743
+ describe('${naming.withSpaces}', () => {
744
+ test('can be instantiated via constructor', () => {
745
+ expect(${naming.variableName}).toBeDefined()
746
+ })
747
+ })
748
+ `.trim());
749
+ };
692
750
  const scaffoldNewDomainService = async (boundedContextFolder)=>{
693
751
  const portName = await input({
694
752
  message: 'Name:'
@@ -755,7 +813,7 @@ const scaffoldNewErrorUseCase = async (boundedContextFolder)=>{
755
813
  message: 'Error name:'
756
814
  });
757
815
  const naming = new UnknownFormatNaming(errorName);
758
- currentErrorFolder.file('index.ts').addLine(`export const ${naming.ClassName}${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Error = ${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Errors.define('${naming.fileName}')`, '\n\n');
816
+ currentErrorFolder.file('index.ts').addLineIfMissing(`export const ${naming.ClassName}${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Error = ${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Errors.define('${naming.fileName}')`, '\n\n');
759
817
  return;
760
818
  }
761
819
  if ('New namespace' === selectedVariant) {
@@ -763,12 +821,12 @@ const scaffoldNewErrorUseCase = async (boundedContextFolder)=>{
763
821
  message: 'Namespace name:'
764
822
  });
765
823
  const { ClassName, fileName } = new UnknownFormatNaming(namespaceName);
766
- currentErrorFolder.createFile(`${fileName}.ts`, `
824
+ if (!currentErrorFolder.file(`${fileName}.ts`).exists) currentErrorFolder.createFile(`${fileName}.ts`, `
767
825
  import { errorNamespace } from '@domain-first/errors'
768
826
 
769
827
  export const ${ClassName}${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Errors = errorNamespace('${boundedContextFolder.name}').subnamespace('${fileName}')
770
- `);
771
- currentErrorFolder.file('index.ts').addLine(`export * from './${fileName}'`, '\n\n');
828
+ `.trim());
829
+ currentErrorFolder.file('index.ts').addLineIfMissing(`export * from './${fileName}'`, '\n\n');
772
830
  return;
773
831
  }
774
832
  const namespace = selectedVariant.substring(23);
@@ -777,7 +835,7 @@ export const ${ClassName}${new UnknownFormatNaming(boundedContextFolder.name).Cl
777
835
  message: 'Error name:'
778
836
  });
779
837
  const { ClassName, fileName } = new UnknownFormatNaming(errorName);
780
- currentErrorFolder.file(`${namespace}.ts`).addLine(`export const ${ClassName}${namespaceNaming.ClassName}${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Error = ${namespaceNaming.ClassName}${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Errors.define('${fileName}')`, '\n\n');
838
+ currentErrorFolder.file(`${namespace}.ts`).addLineIfMissing(`export const ${ClassName}${namespaceNaming.ClassName}${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Error = ${namespaceNaming.ClassName}${new UnknownFormatNaming(boundedContextFolder.name).ClassName}Errors.define('${fileName}')`, '\n\n');
781
839
  };
782
840
  const scaffoldNewHandlersRestEndpoint = async (boundedContextFolder)=>{
783
841
  const restPresentationFolder = boundedContextFolder.subitem([
@@ -1324,12 +1382,13 @@ export const ${ClassName}Widget: FC<${ClassName}WidgetProps> = (props) => {
1324
1382
  `.trim());
1325
1383
  break;
1326
1384
  case 'with separated ui':
1327
- folder.createFile('types.ts', `
1385
+ {
1386
+ folder.createFile('types.ts', `
1328
1387
  export type ${ClassName}WidgetProps = { }
1329
1388
 
1330
1389
  export type ${ClassName}WidgetUIProps = { }
1331
1390
  `.trim());
1332
- folder.createFile(`${widgetFileName}.tsx`, `
1391
+ folder.createFile(`${widgetFileName}.tsx`, `
1333
1392
  import { type FC } from 'react'
1334
1393
  import type { ${ClassName}WidgetProps } from './types'
1335
1394
  import { ${ClassName}WidgetUI } from './ui/${uiFileName}'
@@ -1342,9 +1401,9 @@ export const ${ClassName}Widget: FC<${ClassName}WidgetProps> = (props) => {
1342
1401
 
1343
1402
  export type { ${ClassName}WidgetProps }
1344
1403
  `.trim());
1345
- folder.subitem([
1346
- 'ui'
1347
- ]).createFile(`${uiFileName}.tsx`, `
1404
+ folder.subitem([
1405
+ 'ui'
1406
+ ]).createFile(`${uiFileName}.tsx`, `
1348
1407
  import { FC } from 'react'
1349
1408
  import type { ${ClassName}WidgetUIProps } from '../types'
1350
1409
 
@@ -1352,16 +1411,37 @@ export const ${ClassName}WidgetUI: FC<${ClassName}WidgetUIProps> = (props) => {
1352
1411
  return <></>
1353
1412
  }
1354
1413
  `.trim());
1355
- folder.subitem([
1356
- 'hooks'
1357
- ]).createFile(`${uiModelFileName}.ts`, `
1414
+ const { storybookFramework } = ConfigFile.Instance.data;
1415
+ if (storybookFramework) folder.subitem([
1416
+ 'ui'
1417
+ ]).createFile(`${uiFileName}.stories.tsx`, `
1418
+ import type { Meta, StoryObj } from '${storybookFramework}'
1419
+ import { ${ClassName}WidgetUI } from './${uiFileName}'
1420
+
1421
+ const meta = {
1422
+ title: 'Widgets/${ClassName}',
1423
+ component: ${ClassName}WidgetUI
1424
+ } satisfies Meta<typeof ${ClassName}WidgetUI>
1425
+
1426
+ export default meta
1427
+
1428
+ type Story = StoryObj<typeof meta>
1429
+
1430
+ export const Default: Story = {
1431
+ args: {}
1432
+ }
1433
+ `.trim());
1434
+ folder.subitem([
1435
+ 'hooks'
1436
+ ]).createFile(`${uiModelFileName}.ts`, `
1358
1437
  import type { ${ClassName}WidgetProps, ${ClassName}WidgetUIProps } from '../types'
1359
1438
 
1360
1439
  export const use${ClassName}UIModel = (widgetProps: ${ClassName}WidgetProps): ${ClassName}WidgetUIProps => {
1361
1440
  return {}
1362
1441
  }
1363
1442
  `.trim());
1364
- break;
1443
+ break;
1444
+ }
1365
1445
  case 'headless':
1366
1446
  folder.createFile('types.ts', `
1367
1447
  import { type FC } from 'react'
@@ -1485,15 +1565,23 @@ const main = async ()=>{
1485
1565
  message: 'Domain layer operation:',
1486
1566
  choices: specificContext ? [
1487
1567
  'New Aggregate',
1568
+ 'New Entity',
1569
+ 'New Value Object',
1488
1570
  'Errors',
1489
1571
  'New Service'
1490
1572
  ] : [
1573
+ 'New Entity',
1574
+ 'New Value Object',
1491
1575
  'Errors'
1492
1576
  ]
1493
1577
  });
1494
1578
  switch(operation){
1495
1579
  case 'New Aggregate':
1496
1580
  return void await scaffoldNewAggregateUseCase(boundedContextFolder);
1581
+ case 'New Entity':
1582
+ return void await scaffoldNewDomainObject(boundedContextFolder, 'entity');
1583
+ case 'New Value Object':
1584
+ return void await scaffoldNewDomainObject(boundedContextFolder, 'value-object');
1497
1585
  case 'Errors':
1498
1586
  return void await scaffoldNewErrorUseCase(boundedContextFolder);
1499
1587
  case 'New Service':
@@ -4,6 +4,7 @@ export * from './scaffold-new-application-port';
4
4
  export * from './scaffold-new-application-service';
5
5
  export * from './scaffold-new-bounded-context';
6
6
  export * from './scaffold-new-command';
7
+ export * from './scaffold-new-domain-object';
7
8
  export * from './scaffold-new-domain-service';
8
9
  export * from './scaffold-new-error';
9
10
  export * from './scaffold-new-handlers-rest-endpoint';
@@ -0,0 +1,2 @@
1
+ import type { Folder } from '../file-system';
2
+ export declare const scaffoldNewDomainObject: (boundedContextFolder: Folder, kind: "entity" | "value-object") => Promise<void>;
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": "2.9.0",
4
+ "version": "2.10.0",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",