@domain-first/project-structure 8.7.0 → 8.8.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 +2 -0
- package/dist/287.js +1275 -1127
- package/dist/561.js +19 -3
- package/dist/780.js +9 -2
- package/dist/agent-cli.d.ts +35 -4
- package/dist/agent-requests.d.ts +22 -0
- package/dist/backend-module-move.d.ts +16 -0
- package/dist/config-file.d.ts +38 -18
- package/dist/graph.cjs +9 -2
- package/dist/implementation-options-schema.d.ts +19 -9
- package/dist/in-memory-db.d.ts +5 -6
- package/dist/index.cjs +1635 -1464
- package/dist/init.cjs +53 -59
- package/dist/integration-tests.d.ts +39 -0
- package/dist/integration-tests.spec.d.ts +1 -0
- package/dist/integration.cjs +1635 -1464
- package/dist/lint.cjs +9 -2
- package/dist/react.cjs +1635 -1464
- package/dist/upgrade-steps.d.ts +19 -4
- package/dist/upgrade.cjs +9 -2
- package/dist/use-cases/prompt-implementation-type.d.ts +2 -0
- package/package.json +1 -1
- package/skills/df-ps-implement/SKILL.md +2 -1
- package/skills/df-ps-scaffold/SKILL.md +2 -1
- package/skills/df-ps-scaffold/references/agent-mode.md +1 -1
- package/skills/df-ps-scaffold/references/agent-operations.md +2 -2
- package/skills/df-ps-scaffold/references/generators.md +31 -7
- package/skills/df-ps-scaffold/references/units/aggregate.md +3 -2
- package/skills/df-ps-scaffold/references/units/command-query.md +3 -2
- package/skills/df-ps-scaffold/references/units/helper.md +1 -1
- package/skills/df-ps-scaffold/references/units/implementation.md +1 -1
- package/skills/df-ps-scaffold/references/units/port.md +2 -1
- package/skills/df-ps-scaffold/references/units/services.md +4 -3
package/dist/upgrade-steps.d.ts
CHANGED
|
@@ -57,10 +57,25 @@ export declare const planUpgrade: (config: unknown, acceptOptional?: (step: Plan
|
|
|
57
57
|
} | undefined;
|
|
58
58
|
withInMemoryDb?: boolean | undefined;
|
|
59
59
|
testingLibrary?: string | undefined;
|
|
60
|
-
implementations?:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
implementations?: {
|
|
61
|
+
queries?: {
|
|
62
|
+
primary: string[];
|
|
63
|
+
test: string[];
|
|
64
|
+
} | undefined;
|
|
65
|
+
commands?: {
|
|
66
|
+
primary: string[];
|
|
67
|
+
test: string[];
|
|
68
|
+
} | undefined;
|
|
69
|
+
repositories?: {
|
|
70
|
+
primary: string[];
|
|
71
|
+
test: string[];
|
|
72
|
+
} | undefined;
|
|
73
|
+
ports?: {
|
|
74
|
+
primary: string[];
|
|
75
|
+
test: string[];
|
|
76
|
+
} | undefined;
|
|
77
|
+
integrationTests?: string[] | undefined;
|
|
78
|
+
} | undefined;
|
|
64
79
|
rules?: {
|
|
65
80
|
dependencies?: Partial<Record<"queries" | "commands" | "use-cases" | "application-ports" | "repositories" | "domain-services" | "application-services" | "infrastructure-services" | "presentation-services", ("queries" | "commands" | "use-cases" | "application-ports" | "repositories" | "domain-services" | "application-services" | "infrastructure-services" | "presentation-services")[] | {
|
|
66
81
|
add?: ("queries" | "commands" | "use-cases" | "application-ports" | "repositories" | "domain-services" | "application-services" | "infrastructure-services" | "presentation-services")[] | undefined;
|
package/dist/upgrade.cjs
CHANGED
|
@@ -226,10 +226,17 @@ const implementationKinds = [
|
|
|
226
226
|
'ports'
|
|
227
227
|
];
|
|
228
228
|
const implementationLabelSchema = external_zod_default().string().regex(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/);
|
|
229
|
-
const
|
|
229
|
+
const implementationGroupSchema = external_zod_default().object({
|
|
230
230
|
primary: external_zod_default().array(implementationLabelSchema).default([]),
|
|
231
231
|
test: external_zod_default().array(implementationLabelSchema).default([])
|
|
232
|
-
}).strict()
|
|
232
|
+
}).strict();
|
|
233
|
+
const implementationOptionsSchema = external_zod_default().object({
|
|
234
|
+
...Object.fromEntries(implementationKinds.map((kind)=>[
|
|
235
|
+
kind,
|
|
236
|
+
implementationGroupSchema.optional()
|
|
237
|
+
])),
|
|
238
|
+
integrationTests: external_zod_default().array(implementationLabelSchema).optional()
|
|
239
|
+
}).strict();
|
|
233
240
|
class ProjectRoot {
|
|
234
241
|
path;
|
|
235
242
|
constructor(){
|
|
@@ -10,6 +10,8 @@ export declare const implementationTypeEntryChoices: readonly [{
|
|
|
10
10
|
export type ImplementationTypeSelection = {
|
|
11
11
|
label: string;
|
|
12
12
|
saveForFutureUse: boolean;
|
|
13
|
+
/** Typed in rather than picked: not a saved or system type. */
|
|
14
|
+
entered: boolean;
|
|
13
15
|
};
|
|
14
16
|
/** Saved choices, active system implementations, and explicit manual entry. */
|
|
15
17
|
export declare const promptImplementationType: (message: string, kind: ImplementationKind, { existing, purpose, crossContext, remember }?: {
|
package/package.json
CHANGED
|
@@ -99,4 +99,5 @@ Pages, widgets, UI-kit components, shared hooks and stories, and how they reach
|
|
|
99
99
|
## Tests
|
|
100
100
|
|
|
101
101
|
- Generated specs only check construction. Extend them in the same file with behavior tests; what to test per unit: its unit file.
|
|
102
|
-
-
|
|
102
|
+
- Integration specs in `specs/integration/` check that the factory builds the implementation. Replace `test.todo('works against the infrastructure')` with tests against the container (`DATABASE_URL`); run them with `npm run test:integration` (Docker).
|
|
103
|
+
- Missing spec: create it from "Spec templates" or "Integration specs" in `df-ps-scaffold/references/generators.md` (exception 1). Don't re-run the generator: it would overwrite the implementation. Never delete generated specs.
|
|
@@ -89,7 +89,8 @@ One file per unit in `references/units/`: when to choose it, how to generate it
|
|
|
89
89
|
- **Contexts**: subfolders of `<rootFolder>/bounded-contexts/`.
|
|
90
90
|
- **Names**: lowercase kebab-case, no generator suffix (`place-order`, not `place-order-use-case`). No empty segments (`a--b`).
|
|
91
91
|
- **Collisions**: JSON requests require `overwrite: true` to replace changed existing files. Inspect `overwriteRequired` with `dryRun: true` and include those overwrites in the plan. The interactive equivalent asks `Overwrite them?`.
|
|
92
|
-
- **
|
|
92
|
+
- **Integration specs**: with the Testcontainers integration and wire, primary implementations of the types in `backend.implementations.integrationTests`, and infrastructure services when asked, get a spec in `specs/integration/` (`references/generators.md`). For a new type, set `integrationTests: false` when the container can't exercise it (an external API).
|
|
93
|
+
- **Tests**: with `backend.testingLibrary` set, df-scaffold generates specs for modules without infrastructure (domain model, non-infrastructure services, use cases); repositories, commands/queries, ports, infrastructure services and helpers get none. Add a test implementation (`in-memory`/`mock`) to repositories, commands/queries and ports, so `NODE_ENV=test` specs of the use cases that inject them don't touch real infrastructure. Without `backend.testingLibrary`, tell the user once and suggest adding it with `! npx df-integration` (Vitest); don't edit the config yourself.
|
|
93
94
|
- **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`).
|
|
94
95
|
- **Requests**: take the unit semantics and output files from its reference, then use `--describe` and `references/agent-mode.md` to build a JSON request.
|
|
95
96
|
|
|
@@ -36,7 +36,7 @@ npx df-integration --request '{"operation":"add","integrations":["storybook"]}'
|
|
|
36
36
|
|
|
37
37
|
- `dryRun: true` returns the proposed changes without writing anything. Discovery and dry runs are read-only and can be used while preparing a plan.
|
|
38
38
|
- `overwrite: true` explicitly permits replacing changed existing generated files. Use it only for overwrites covered by the approved plan. Never add it merely to bypass an `OVERWRITE_REQUIRED` error; inspect the listed paths first. Identical generated file contents need no overwrite flag.
|
|
39
|
-
- `implementation` / `testImplementation`: `{ "type": "prisma", "save": false }`. `save` defaults to false; true remembers an ordinary type in the appropriate backend implementation choices. A missing `testImplementation` means no separate test implementation.
|
|
39
|
+
- `implementation` / `testImplementation`: `{ "type": "prisma", "save": false }`. `save` defaults to false; true remembers an ordinary type in the appropriate backend implementation choices. A newly entered primary type takes `integrationTests` with the Testcontainers integration (default true; see agent-operations.md). A missing `testImplementation` means no separate test implementation.
|
|
40
40
|
- `dependencies`: implementation/class name → array of qualified module IDs. Omitted entries keep the generator's checked suggestions; `[]` explicitly selects none when that selection applies. When wiring is off or no candidates exist, omit the group; see the [dependency conditions](agent-operations.md#dependency-keys-and-system-implementations). Every supplied dependency group must apply to the operation. Different primary/test implementations have independent lists.
|
|
41
41
|
- Aggregate repositories require `withRepository: true` and an `implementation`. Without it, aggregate creation makes no repository.
|
|
42
42
|
- New implementations use a `contract` ID and, with a branched wire, an explicit `environments` array. Moves use a `module` unit ID and optional `targetContext`, `aggregate` and `name`. `wire-dependency` uses a wiring target ID in `module` plus its `dependencies` entry.
|
|
@@ -31,7 +31,7 @@ All operations support `dryRun` and `overwrite`. Except `bounded-context`, they
|
|
|
31
31
|
| `move` | `module` | `module` is a unit ID. Optional `name`, `targetContext`, `aggregate`; omitted name/context keep the existing ones. A same-owner entity/value-object keeps its aggregate by default. The target aggregate must exist; the target context must be a discovered, allowed destination for that unit kind. Illegal cross-context imports reject the move. |
|
|
32
32
|
| `delete` | `module` | `module` is a unit ID. Deletes every file of the unit and its generated references (aggregate barrel re-export, in-memory DB section). Refused with `DELETE_NOT_ALLOWED` and `details.usedBy` while other files import it; nothing changes. |
|
|
33
33
|
|
|
34
|
-
`implementation` and `testImplementation` contain `type` and optional `save` (default false). Explicit types can be new ordinary names; they need not already be saved. Saving is independent for primary and test roles. The test type must differ from the primary type. Adding a new implementation remembers a saved type according to the selected environments: `test` or primary for other environments. Branches are `backend.envBranches.names` from the config (`test`, `development`, `production` when absent), with `backend.envBranches.test` as the test one; additional names must be offered by the existing branched wire. Custom branches without `test` take no test implementations: omit `testImplementation`. Without usable branching, omit `environments` and follow the returned wiring note.
|
|
34
|
+
`implementation` and `testImplementation` contain `type` and optional `save` (default false). With the Testcontainers integration and wire, a newly entered primary `implementation` also takes `integrationTests` (default true): whether implementations of the type get integration specs; it is refused on test implementations, listed types and without the integration. `infrastructure-service` takes `integrationSpec` (default false) under the same conditions. Explicit types can be new ordinary names; they need not already be saved. Saving is independent for primary and test roles. The test type must differ from the primary type. Adding a new implementation remembers a saved type according to the selected environments: `test` or primary for other environments. Branches are `backend.envBranches.names` from the config (`test`, `development`, `production` when absent), with `backend.envBranches.test` as the test one; additional names must be offered by the existing branched wire. Custom branches without `test` take no test implementations: omit `testImplementation`. Without usable branching, omit `environments` and follow the returned wiring note.
|
|
35
35
|
|
|
36
36
|
## Dependency keys and system implementations
|
|
37
37
|
|
|
@@ -141,7 +141,7 @@ Use `operation: "add"` and a nonempty `integrations` array. Select only IDs mark
|
|
|
141
141
|
| `prisma` | Backend required. `withService` defaults to true; false skips the infrastructure service and its wire. Registers `prisma` implementation choices. Existing incompatible Prisma setups are rejected rather than upgraded. |
|
|
142
142
|
| `vitest` | Backend required. `replaceTestingLibrary` is required if a different testing library is configured; true changes it to Vitest, false skips this setup. |
|
|
143
143
|
| `playwright` | No extra integration-specific fields. Adds its config, example and scripts. |
|
|
144
|
-
| `testcontainers` | Backend required.
|
|
144
|
+
| `testcontainers` | Backend required. With wire: optional `integrationTestTypes`, the saved primary types whose implementations get integration specs (omitted: the configured list stays); missing specs of existing primary implementations are added. Reads staged Prisma/Vitest setup when selected together. Database scripts are generated, not executed. |
|
|
145
145
|
| `openapi` | Backend with `handlers-rest`. `routePrefix` defaults to `/api`; `openapiPath` is computed from the project unless supplied. `withExtractor` defaults to true. `swaggerPage` applies only with React configured and defaults to true there; otherwise omit it. |
|
|
146
146
|
| `orval` | Requires configured `handlers-rest`. `openapiPath` is read from the staged/existing OpenAPI generator when omitted. With React configured, `targets` can be a nonempty list of `hooks`/`client` and defaults to `hooks`. Without React, omit `targets`: the typed client is generated automatically. |
|
|
147
147
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Use the JSON interface described in [agent-mode.md](agent-mode.md), with the complete operation map in [agent-operations.md](agent-operations.md). Prompts below are what a generator asks interactively; JSON requests carry the same answers as fields. Generated files and implementation rules are the same.
|
|
4
4
|
|
|
5
|
-
What every generator shares: notation, the `Dependencies:` step, env-branched wiring and
|
|
5
|
+
What every generator shares: notation, the `Dependencies:` step, env-branched wiring, spec templates and integration specs. Prompts and output of each generator are in `units/<unit>.md`.
|
|
6
6
|
|
|
7
7
|
Config paths: `project.rootFolder`, `backend.domainFirstPackages`, `backend.testingLibrary`, `backend.withInMemoryDb`, and `frontend.react.storybookFramework`. Initialization/reconfiguration is performed by the user, not the agent.
|
|
8
8
|
|
|
@@ -85,15 +85,39 @@ describe('<label>', () => {
|
|
|
85
85
|
})
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
-
Without wire: import `<Class>` from `<noWire>`, use `new <Class>()` and the test name `<noWireTest>`.
|
|
88
|
+
Without wire: import `<Class>` from `<noWire>`, use `new <Class>()` and the test name `<noWireTest>`.
|
|
89
|
+
|
|
90
|
+
Only modules without infrastructure have specs. Repositories, commands, queries, ports, infrastructure services and helpers get none: don't create one for them.
|
|
89
91
|
|
|
90
92
|
| Component | Spec next to | `<Type>` / `<var>` | `<wirePath>` | `<label>` | `<Class>` from `<noWire>`, `<noWireTest>` |
|
|
91
93
|
| -------------------- | ---------------------------- | ----------------------------- | ------------------------------------------------ | -------------------- | -------------------------------------------------------------------------------------------------------- |
|
|
92
94
|
| 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` |
|
|
93
|
-
|
|
|
94
|
-
| Service | `n-L-service.ts` | `NLService` / `vLService` | `../../wiring/L-services/wire-n-L-service` | `n words` | `NLService` `./n-L-service`, `can be created` |
|
|
95
|
+
| Service (not infrastructure) | `n-L-service.ts` | `NLService` / `vLService` | `../../wiring/L-services/wire-n-L-service` | `n words` | `NLService` `./n-L-service`, `can be created` |
|
|
95
96
|
| 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` |
|
|
96
|
-
| Command | `n-command.ts` | `NCommand` / `vCommand` | `../../wiring/commands/wire-n-command` | `n words command` | `INCommand` `../../infrastructure/commands/I/I-n-command`, `can be created via constructor` |
|
|
97
|
-
| Port | `n.ts` | `N` / `v` | `../../wiring/application-ports/wire-n` | `n words` | `IN` `../../infrastructure/application-adapters/I/I-n`, `can be created via constructor` |
|
|
98
97
|
|
|
99
|
-
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.
|
|
98
|
+
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.
|
|
99
|
+
|
|
100
|
+
## Integration specs {integration}
|
|
101
|
+
|
|
102
|
+
{integration} = the Testcontainers integration (`specs/integration/vitest.config.ts`) and {wire}. Then an integration spec goes to `specs/integration/<context>/<path without infrastructure/>.spec.ts`, e.g. `specs/integration/sales/queries/prisma/prisma-orders-query.spec.ts`, for:
|
|
103
|
+
|
|
104
|
+
- each primary implementation of a repository, command, query or port whose type is in `backend.implementations.integrationTests`. A newly entered primary type asks `Generate integration tests for <type> implementations?` (JSON `implementation.integrationTests`, default true; with `save: true`, a yes lists the type). Test implementations, `in-memory` and `cross-context` get none;
|
|
105
|
+
- an infrastructure service, when `Generate an integration spec?` is answered yes (JSON `integrationSpec`, default false). Helpers never get one.
|
|
106
|
+
|
|
107
|
+
The spec imports the implementation's factory from the contract's wire, which the CLI exports (`export const wireIImplementation = …`), and names it with `as`; a service's spec imports `wireNInfrastructureService`:
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
import { describe, test, expect } from 'vitest'
|
|
111
|
+
import { INContract } from '<implementation file>'
|
|
112
|
+
import { wireIImplementation as wireINContract } from '<contract wire file>'
|
|
113
|
+
|
|
114
|
+
describe('n words <kind> (I)', () => {
|
|
115
|
+
test('can be wired', () => {
|
|
116
|
+
expect(wireINContract()).toBeInstanceOf(INContract)
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
test.todo('works against the infrastructure')
|
|
120
|
+
})
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Specs follow their module on move, rename and delete. Recreate a missing one only from this template (rule 2, exception 1), exporting the factory in the wire.
|
|
@@ -7,9 +7,10 @@ When: a thing with identity, lifecycle, and rules about its own state, owned by
|
|
|
7
7
|
Prompts: name → `With Repository` → primary implementation select → `Add a test implementation` → test implementation select if yes → {wire} dependencies per implementation. Each select contains saved repository types for that role, available system types and both manual-entry actions (`../generators.md`). `System: in-memory (uses the shared in-memory database)` appears only with the shared DB enabled and scaffolded. There are no ordinary presets; default to the first available saved/system choice, otherwise manual entry.
|
|
8
8
|
|
|
9
9
|
- Custom types entered with the save action are staged in the shared config under `backend.implementations.repositories.primary` or `backend.implementations.repositories.test` and offered on later runs, including in other contexts. Both manual-entry actions from `../generators.md` are available; the run-only action generates the repository without remembering its type.
|
|
10
|
-
- `<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
|
|
10
|
+
- `<C>/domain/aggregates/n/`: `n.aggregate-root.ts` (`class N extends domainType()` {types}), `index.ts`, spec; with repository: `n-repository.ts` (`abstract class NRepository`), no spec
|
|
11
11
|
- `<C>/infrastructure/repositories/I/I-n-repository.ts` per implementation (`class INRepository implements NRepository`)
|
|
12
12
|
- {wire} `<C>/wiring/repositories/wire-n-repository.ts` (env-branched)
|
|
13
|
+
- {integration} `specs/integration/<context>/repositories/I/I-n-repository.spec.ts` for the primary implementation, by type (`../generators.md`, "Integration specs")
|
|
13
14
|
- With `backend.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-kernel/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.
|
|
14
15
|
|
|
15
16
|
Its entities and value objects come after it: [entity-value-object](entity-value-object.md), picking this aggregate.
|
|
@@ -43,4 +44,4 @@ export class Order extends domainType(
|
|
|
43
44
|
|
|
44
45
|
## Test
|
|
45
46
|
|
|
46
|
-
Extend the generated
|
|
47
|
+
Extend the generated spec of the root with the aggregate rules. The repository has no unit spec: it is infrastructure, tested through its integration spec (extend `test.todo` against the container) and the use cases that inject its test implementation.
|
|
@@ -9,9 +9,10 @@ When (`../choosing-components.md`, step 11): one atomic read/write on this conte
|
|
|
9
9
|
|
|
10
10
|
Prompts: name → primary implementation select → `Add a test implementation` → test implementation select if yes → {wire} dependencies per implementation. Menus contain saved types from `commands` or `queries` for the selected role, active system types and both manual-entry actions (`../generators.md`). Only `System: in-memory (uses the shared in-memory database)` can be automatic here, when its integration is ready. `api` and `mock` must be saved or entered manually. The first saved/system choice is the default, otherwise manual entry without a suggested name. Saving stages the new ordinary label for that category/role; run-only input leaves the catalog unchanged.
|
|
11
11
|
|
|
12
|
-
- `<C>/application/commands/n-command.ts`: abstract `NCommand` ({handlers} schemas + abstract `handle: Handler<…>`), spec
|
|
12
|
+
- `<C>/application/commands/n-command.ts`: abstract `NCommand` ({handlers} schemas + abstract `handle: Handler<…>`), no spec
|
|
13
13
|
- `<C>/infrastructure/commands/I/I-n-command.ts` per implementation (`extends NCommand`, implements `handle`)
|
|
14
14
|
- {wire} `<C>/wiring/commands/wire-n-command.ts` (env-branched)
|
|
15
|
+
- {integration} `specs/integration/<context>/commands/I/I-n-command.spec.ts` for the primary implementation, by type (`../generators.md`, "Integration specs")
|
|
15
16
|
- With `backend.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.
|
|
16
17
|
|
|
17
18
|
Queries: the same with `query` / `queries`.
|
|
@@ -27,4 +28,4 @@ Queries: the same with `query` / `queries`.
|
|
|
27
28
|
|
|
28
29
|
## Test
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
No unit spec: a command or query is infrastructure, tested through its integration spec (extend `test.todo` against the container) and the use cases that inject its test implementation.
|
|
@@ -8,7 +8,7 @@ Prompts: `Name (folders split by "/"):` → `Implementation:` (a type the projec
|
|
|
8
8
|
|
|
9
9
|
JSON: `{ "operation": "helper", "context": "sales", "name": "mappers/social-network-type", "implementationType": "prisma" }`.
|
|
10
10
|
|
|
11
|
-
- `<C>/infrastructure/helpers/I/<folders>/I-n.ts` (`export const iN = () => {}`), spec
|
|
11
|
+
- `<C>/infrastructure/helpers/I/<folders>/I-n.ts` (`export const iN = () => {}`), no spec
|
|
12
12
|
|
|
13
13
|
A name that already starts with the type (`prisma-errors`) doesn't get the prefix twice. A helper of a type that isn't saved yet can't be generated: add an implementation of that type first, saving the type.
|
|
14
14
|
|
|
@@ -13,4 +13,4 @@ An implementation left without environments stays in the wire file; the CLI prin
|
|
|
13
13
|
|
|
14
14
|
## Implement and test
|
|
15
15
|
|
|
16
|
-
As the implementations of the contract's unit file.
|
|
16
|
+
As the implementations of the contract's unit file. A primary implementation (any environment but `test`) gets an integration spec by type, as in `../generators.md`, "Integration specs". Contracts have no unit spec; specs of the use cases that inject the contract wire what `NODE_ENV=test` uses: only a new `test` implementation changes what they test.
|
|
@@ -6,9 +6,10 @@ When: a capability across this context's boundary: another bounded context, an e
|
|
|
6
6
|
|
|
7
7
|
Prompts: name → primary adapter select → `With test implementation` → test adapter select if yes → {wire} dependencies per adapter. Both selects show saved port types for their role, active system types and both manual-entry actions (`../generators.md`). The only automatic system choice is `System: cross-context (calls handlers in another bounded context)`, conditional on a neighboring context and unavailable in the Shared Kernel. No `api`, `mock` or `in-memory` presets are inserted for ports. The first saved/system choice is the default; manual input is empty without saved choices. Existing labels are disabled. Saved ordinary port types are isolated from other categories. Save-entry updates `ports` history; run-only entry generates the adapter without updating the catalog.
|
|
8
8
|
|
|
9
|
-
- `<C>/application/ports/n.ts` (abstract `N`; name it after the capability), spec
|
|
9
|
+
- `<C>/application/ports/n.ts` (abstract `N`; name it after the capability), no spec
|
|
10
10
|
- `<C>/infrastructure/application-adapters/I/I-n.ts` per implementation (`class IN extends N`)
|
|
11
11
|
- {wire} `<C>/wiring/application-ports/wire-n.ts` (env-branched)
|
|
12
|
+
- {integration} `specs/integration/<context>/application-adapters/I/I-n.spec.ts` for the primary adapter, by type (`../generators.md`, "Integration specs"); answer `integrationTests: false` for a type the database container can't exercise (an external API)
|
|
12
13
|
|
|
13
14
|
## Implement
|
|
14
15
|
|
|
@@ -9,10 +9,11 @@ When (`../choosing-components.md`, steps 12–15, "Port or service?"):
|
|
|
9
9
|
|
|
10
10
|
## Generate (context and Shared Kernel)
|
|
11
11
|
|
|
12
|
-
Prompts: name → {wire} `Dependencies:` (`../generators.md`). `L` = `domain` | `application` | `infrastructure` | `presentation`.
|
|
12
|
+
Prompts: name → infrastructure with {integration}: `Generate an integration spec?` (JSON `integrationSpec`, default false) → {wire} `Dependencies:` (`../generators.md`). `L` = `domain` | `application` | `infrastructure` | `presentation`.
|
|
13
13
|
|
|
14
|
-
- `<C>/L/services/n-L-service.ts` (`class NLService`, e.g. `CheckoutApplicationService`), spec
|
|
14
|
+
- `<C>/L/services/n-L-service.ts` (`class NLService`, e.g. `CheckoutApplicationService`), spec except for `infrastructure`
|
|
15
15
|
- {wire} `<C>/wiring/L-services/wire-n-L-service.ts` (`wireClass(X, [])`)
|
|
16
|
+
- {integration} if asked: `specs/integration/<context>/services/n-infrastructure-service.spec.ts`
|
|
16
17
|
|
|
17
18
|
## Implement
|
|
18
19
|
|
|
@@ -23,4 +24,4 @@ Prompts: name → {wire} `Dependencies:` (`../generators.md`). `L` = `domain` |
|
|
|
23
24
|
|
|
24
25
|
## Test
|
|
25
26
|
|
|
26
|
-
Test a service's logic with fake dependencies in its generated spec.
|
|
27
|
+
Test a domain, application or presentation service's logic with fake dependencies in its generated spec. Infrastructure services have no unit spec: ask for an integration spec when the service talks to the database container, otherwise the specs of the implementations using it cover it.
|