@domain-first/project-structure 2.10.4 → 2.12.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 +15 -2
- package/dist/file-system.d.ts +5 -0
- package/dist/index.cjs +550 -39
- package/dist/index.js +551 -40
- package/dist/nested-name.d.ts +19 -0
- package/dist/nested-name.spec.d.ts +1 -0
- package/dist/use-cases/index.d.ts +1 -0
- package/dist/use-cases/wire-dependency.d.ts +17 -0
- package/dist/wiring.d.ts +90 -0
- package/dist/wiring.spec.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -161,7 +161,18 @@ With `@domain-first/wire`, generators create `wireClass` factories. Repositories
|
|
|
161
161
|
| `development` | The primary implementation. Also used when `NODE_ENV` is unset. |
|
|
162
162
|
| `production` | The primary implementation. |
|
|
163
163
|
|
|
164
|
-
Implementation names such as `prisma`, `api`, `in-memory`, and `mock` determine names and locations for generated classes. Add the database queries, API calls, or in-memory behavior yourself.
|
|
164
|
+
Implementation names such as `prisma`, `api`, `in-memory`, and `mock` determine names and locations for generated classes. Add the database queries, API calls, or in-memory behavior yourself. As the last step, generators that create a wiring factory offer to pick its dependencies from wired modules of the same bounded context and the Shared Layer. Each selected module is added to the factory's dependency list and to the constructor, for example `private readonly userRepository: UserRepository`. Environment-branched factories (repositories, execution commands and queries, ports) wire each implementation in isolation: you pick dependencies separately for each one, for example for `PrismaUserRepository` and then for `InMemoryUserRepository`. Each list starts with a **Suggested** group when infrastructure modules match the implementation name: `prisma-infrastructure-service` for a `prisma` implementation, or `in-memory-db-infrastructure-service` for an `in-memory` one. To add dependencies to an existing module later, select **Wire dependency** in the bounded context or Shared Layer menu. Environment-branched modules are listed there once per implementation, such as `UserRepository (prisma)` and `UserRepository (in-memory)`, and only the chosen one is changed.
|
|
165
|
+
|
|
166
|
+
The list depends on the layer of the class being built:
|
|
167
|
+
|
|
168
|
+
| Layer | Can depend on |
|
|
169
|
+
| -------------- | -------------------------------------------- |
|
|
170
|
+
| Domain | Domain |
|
|
171
|
+
| Application | Domain, application |
|
|
172
|
+
| Infrastructure | Domain, infrastructure |
|
|
173
|
+
| Presentation | Application, presentation |
|
|
174
|
+
|
|
175
|
+
Some kinds of modules have narrower rules. From the application layer, application services can use only ports. Use cases can't use other use cases, and repository implementations can't use other repositories. Execution commands and queries can't use other commands or queries. From the application layer, orchestration commands and queries can use only execution commands and queries. Repository, execution command, execution query, and port implementations belong to infrastructure: they implement application modules but can't take them as dependencies. REST endpoints are not offered as dependencies. Their dependencies are chosen when they are generated (see REST endpoints) and are not available in **Wire dependency**.
|
|
165
176
|
|
|
166
177
|
When `testingLibrary` is configured, supported generators always add `.spec.ts` files. These start with construction or wiring checks; extend them with tests for your business behavior. Repository, command, query, and port test templates reference wiring factories, so use the wiring integration or adapt those tests to your own construction setup.
|
|
167
178
|
|
|
@@ -173,7 +184,7 @@ Select an existing controller or create one, choose `get`, `post`, `patch`, `del
|
|
|
173
184
|
src/bounded-contexts/sales/presentation/rest/orders/recent/GET.ts
|
|
174
185
|
```
|
|
175
186
|
|
|
176
|
-
The route metadata uses `/sales/orders/recent`.
|
|
187
|
+
The route metadata uses `/sales/orders/recent`. With `@domain-first/wire`, the generator then asks for the endpoint generator, picked from presentation services of the bounded context and the Shared Layer (services with `endpoint` in the name are suggested first), and for the handler, picked from queries, commands, and use cases of the bounded context. The endpoint's constructor gets the chosen types, and its wiring factory gets their factories. In `get handle()`, call the generating method of the chosen service yourself, for example `this.endpointGenerator.generate(...)` for `readonly generate = createEndpoint(...)(adapter)`. Without wiring, or when there is nothing to pick, the endpoint keeps the `EndpointGenerator` type and a `never` handler placeholder for you to replace.
|
|
177
188
|
|
|
178
189
|
With wiring enabled, the generator also adds endpoint factories and exports collected as `restHandlers` in `<rootFolder>/presentation/rest/index.ts`. Connect these handlers to your HTTP server.
|
|
179
190
|
|
|
@@ -190,6 +201,8 @@ Enable `useReact` and choose **Scaffold React module** from the main menu. Modul
|
|
|
190
201
|
| 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`. |
|
|
191
202
|
| 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. |
|
|
192
203
|
|
|
204
|
+
Page and widget names can include folders split by `/`. For example, a page named `admin/panel/users` is created at `pages/admin/panel/users-page.tsx` as `AdminPanelUsersPage`, and a widget with the same name at `widgets/admin/panel/users/` as `AdminPanelUsersWidget` with the story title `Widgets/Admin/Panel/Users`. File names use only the last segment; code names use the whole path.
|
|
205
|
+
|
|
193
206
|
## Configuration
|
|
194
207
|
|
|
195
208
|
The project configuration is stored in `domain-first.project-structure.config.json`. Commit it to share generation settings with your team. For example:
|
package/dist/file-system.d.ts
CHANGED
|
@@ -23,6 +23,11 @@ export declare class File extends FileSystemItem {
|
|
|
23
23
|
get exists(): boolean;
|
|
24
24
|
get data(): string;
|
|
25
25
|
set data(content: string);
|
|
26
|
+
/**
|
|
27
|
+
* Changes the content without marking a full rewrite, so editing an
|
|
28
|
+
* existing file doesn't ask to overwrite it.
|
|
29
|
+
*/
|
|
30
|
+
update: (content: string) => void;
|
|
26
31
|
addLine: (newLine: string, separator?: string) => void;
|
|
27
32
|
/**
|
|
28
33
|
* Re-running a generator for the same name must not duplicate the line.
|