@domain-first/project-structure 7.1.1 → 7.2.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 +4 -0
- package/dist/201.js +61 -6
- package/dist/287.js +255 -134
- package/dist/backend-module-move.d.ts +1 -0
- package/dist/implementations.d.ts +48 -0
- package/dist/index.cjs +313 -134
- package/dist/index.js +5 -2
- package/dist/lint.cjs +8 -5
- package/dist/use-cases/index.d.ts +1 -0
- package/dist/use-cases/scaffold-new-aggregate.d.ts +1 -1
- package/dist/use-cases/scaffold-new-implementation.d.ts +6 -0
- package/dist/use-cases/scaffold-new-implementation.spec.d.ts +1 -0
- package/dist/use-cases/wire-dependency.d.ts +5 -0
- package/dist/wiring.d.ts +21 -0
- package/package.json +1 -1
- package/skills/df-ps-scaffold/SKILL.md +3 -2
- package/skills/df-ps-scaffold/references/choosing-components.md +1 -0
- package/skills/df-ps-scaffold/references/units/implementation.md +20 -0
package/dist/wiring.d.ts
CHANGED
|
@@ -93,3 +93,24 @@ export declare const addWireDependencies: (source: string, className: string, wi
|
|
|
93
93
|
* the same order.
|
|
94
94
|
*/
|
|
95
95
|
export declare const wireDependencies: (consumer: WiredModule, implementation: WiredClass, dependencies: WiredModule[]) => void;
|
|
96
|
+
/**
|
|
97
|
+
* Environment → the wire it uses, as written in the module's
|
|
98
|
+
* `envBranchedWire({...})`.
|
|
99
|
+
*/
|
|
100
|
+
export declare const wireBranches: (source: string, wireName: string) => Map<string, string>;
|
|
101
|
+
/**
|
|
102
|
+
* Points the environments of the module's `envBranchedWire` at the wire,
|
|
103
|
+
* adding the environments it doesn't have yet.
|
|
104
|
+
*/
|
|
105
|
+
export declare const setWireBranches: (source: string, wireName: string, environments: string[], branchWire: string) => string;
|
|
106
|
+
/**
|
|
107
|
+
* Adds an implementation to a branched wire: its import and its own
|
|
108
|
+
* `wireClass` before the module's wire, which it serves in the given
|
|
109
|
+
* environments.
|
|
110
|
+
*/
|
|
111
|
+
export declare const addBranchedImplementation: (source: string, wireName: string, implementation: {
|
|
112
|
+
importLine: string;
|
|
113
|
+
className: string;
|
|
114
|
+
wireName: string;
|
|
115
|
+
environments: string[];
|
|
116
|
+
}) => string;
|
package/package.json
CHANGED
|
@@ -104,6 +104,7 @@ One file per unit in `references/units/`: when to choose it, how to generate it
|
|
|
104
104
|
| Use case | `use-case.md` | Application → New Use Case |
|
|
105
105
|
| Command, query | `command-query.md` | Application → New Command / New Query |
|
|
106
106
|
| Port + adapters | `port.md` | Application → New Port |
|
|
107
|
+
| One more implementation of a repository, command, query or port | `implementation.md` | Infrastructure → New Implementation |
|
|
107
108
|
| REST endpoint | `endpoint.md` | Presentation → New Handlers-REST Endpoint |
|
|
108
109
|
| Dependency of an existing module | `wire-dependency.md` | Wire dependency |
|
|
109
110
|
| Moving or renaming a module | `move-or-rename.md` | Move or rename |
|
|
@@ -141,11 +142,11 @@ Check every run: exit code 0, no `WARNING`/`ABORTED`, and exactly the planned fi
|
|
|
141
142
|
| -------------- | ---------------------------------------------------------------- | ------------------------------------------------- |
|
|
142
143
|
| Domain | New Aggregate, New Entity, New Value Object, Errors, New Service | New Entity, New Value Object, Errors, New Service |
|
|
143
144
|
| Application | New Query, New Command, New Use Case, New Port, New Service | New Port, New Service |
|
|
144
|
-
| Infrastructure | New Service
|
|
145
|
+
| Infrastructure | New Service, New Implementation | New Service, New Implementation |
|
|
145
146
|
| Presentation | New Handlers-REST Endpoint (needs handlers-rest), New Service | New Service |
|
|
146
147
|
|
|
147
148
|
With `@domain-first/wire`, the layer menu of a context and of the Shared Kernel also has `Wire dependency`: it adds dependencies to an existing wired module. Every layer menu has `Move or rename`.
|
|
148
149
|
|
|
149
150
|
The main menu also has `Scaffold new bounded context`. React modules come from a separate CLI, `df-react`: see `df-ps-react`.
|
|
150
151
|
|
|
151
|
-
Run order in a plan: new contexts → domain (aggregates before their entities and value objects) → application (ports, commands/queries, use cases) → endpoints → React (`df-ps-react`).
|
|
152
|
+
Run order in a plan: new contexts → domain (aggregates before their entities and value objects) → application (ports, commands/queries, use cases) → new implementations of existing contracts → endpoints → React (`df-ps-react`).
|
|
@@ -32,6 +32,7 @@ Split the request into pieces of logic (one responsibility each). For each piece
|
|
|
32
32
|
- A rule about a **set** of aggregates (uniqueness, "at most N per day") = a repository method that queries it, plus a check and a domain error in the use case. No separate component.
|
|
33
33
|
- Steps 9–10 beat 11–15. The other-context or external part becomes a query/command or a port. What remains may be a service that **receives it in its constructor**.
|
|
34
34
|
- Another context (step 9): input/output are this context's own models, duplicated in its terms, never the other context's. The implementation reaches the other context the simplest available way: a shared database → directly (the persistence label, e.g. `prisma`); otherwise the way chosen by `df-ps-plan-feature` (step 3, rule 4): if the project has several ways to reach a context (REST, message queue, RPC…), ask the user; with REST only, its REST endpoint (`http`). The test implementation returns fixed data. No imports from the other context.
|
|
35
|
+
- Another way to perform an **existing** repository, command, query or port (another storage, provider or environment) is a new implementation of it (Infrastructure → New Implementation, `units/implementation.md`), not a new contract.
|
|
35
36
|
- Don't create components "just in case": a command only when storage access deserves its own contract, an application service only when reused.
|
|
36
37
|
|
|
37
38
|
## Port or service?
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Implementation of an existing contract
|
|
2
|
+
|
|
3
|
+
When: a repository, command, query or port already exists and needs one more implementation, e.g. a third adapter of a port so that test, development and production each use their own. A new contract is its own generator (`aggregate.md`, `command-query.md`, `port.md`); never copy an implementation file by hand.
|
|
4
|
+
|
|
5
|
+
## Generate (context and Shared Kernel)
|
|
6
|
+
|
|
7
|
+
Prompts: `Contract:` (select, grouped: Repositories, Commands, Queries, Ports; each with its implementations: `file-storage (in-memory, s3)`) → `Implementation type:` (kebab-case, one the contract doesn't have) → {wire} `Environments:` (checkbox `test`, `development`, `production`, each shown with its current implementation: `development (now: s3)`; at least one) → {wire} `Dependencies for <Implementation>:` for the new implementation only (`../generators.md`).
|
|
8
|
+
|
|
9
|
+
`… pick:Infrastructure "pick:New Implementation" pick:file-storage text:local toggle:2`
|
|
10
|
+
|
|
11
|
+
`toggle:` numbers the environments top to bottom: 1 `test`, 2 `development`, 3 `production`.
|
|
12
|
+
|
|
13
|
+
- `<C>/infrastructure/<kind>/I/I-n….ts` as the contract's generator creates it (in-memory DB included)
|
|
14
|
+
- {wire} `~ <C>/wiring/<kind>/wire-n….ts`: import, `const wireIImplementation = wireClass(IN…, [])` before the module's wire, the chosen environments of `envBranchedWire` point at it
|
|
15
|
+
|
|
16
|
+
An implementation left without environments stays in the wire file; the CLI prints `<Class> is no longer used in any environment.` Specs don't change.
|
|
17
|
+
|
|
18
|
+
## Implement and test
|
|
19
|
+
|
|
20
|
+
As the implementations of the contract's unit file. The spec of the contract wires what `NODE_ENV=test` uses: only a new `test` implementation changes what it tests.
|