@domain-first/project-structure 8.7.1 → 8.9.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.
Files changed (39) hide show
  1. package/README.md +4 -2
  2. package/dist/287.js +2446 -2005
  3. package/dist/561.js +19 -3
  4. package/dist/780.js +9 -2
  5. package/dist/947.js +4 -0
  6. package/dist/agent-cli.d.ts +37 -5
  7. package/dist/agent-requests.d.ts +24 -0
  8. package/dist/backend-module-move.d.ts +16 -0
  9. package/dist/config-file.d.ts +38 -18
  10. package/dist/graph.cjs +13 -2
  11. package/dist/implementation-options-schema.d.ts +19 -9
  12. package/dist/in-memory-db.d.ts +4 -0
  13. package/dist/index.cjs +3465 -2997
  14. package/dist/init.cjs +94 -77
  15. package/dist/integration-tests.d.ts +39 -0
  16. package/dist/integration-tests.spec.d.ts +1 -0
  17. package/dist/integration.cjs +3489 -3021
  18. package/dist/integrations/drizzle.d.ts +8 -0
  19. package/dist/integrations/drizzle.spec.d.ts +1 -0
  20. package/dist/integrations/index.d.ts +1 -0
  21. package/dist/integrations/testcontainers.d.ts +1 -1
  22. package/dist/lint.cjs +13 -2
  23. package/dist/react.cjs +3465 -2997
  24. package/dist/upgrade-steps.d.ts +19 -4
  25. package/dist/upgrade.cjs +9 -2
  26. package/dist/use-cases/add-integration.d.ts +3 -3
  27. package/dist/use-cases/prompt-implementation-type.d.ts +2 -0
  28. package/package.json +1 -1
  29. package/skills/df-ps-implement/SKILL.md +2 -1
  30. package/skills/df-ps-project-scripts/SKILL.md +22 -5
  31. package/skills/df-ps-scaffold/SKILL.md +1 -0
  32. package/skills/df-ps-scaffold/references/agent-mode.md +1 -1
  33. package/skills/df-ps-scaffold/references/agent-operations.md +3 -2
  34. package/skills/df-ps-scaffold/references/generators.md +27 -2
  35. package/skills/df-ps-scaffold/references/units/aggregate.md +2 -1
  36. package/skills/df-ps-scaffold/references/units/command-query.md +2 -1
  37. package/skills/df-ps-scaffold/references/units/implementation.md +1 -1
  38. package/skills/df-ps-scaffold/references/units/port.md +1 -0
  39. package/skills/df-ps-scaffold/references/units/services.md +3 -2
@@ -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?: Partial<Record<"queries" | "commands" | "repositories" | "ports", {
61
- primary: string[];
62
- test: string[];
63
- }>> | undefined;
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 implementationOptionsSchema = external_zod_default().partialRecord(external_zod_default()["enum"](implementationKinds), external_zod_default().object({
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(){
@@ -1,15 +1,15 @@
1
1
  /**
2
2
  * Integrations are shown by group, but selected ones run in this order, each one seeing the changes of
3
3
  * the previous ones: Storybook configures `frontend.react` for the Swagger UI page
4
- * of OpenAPI, integration tests read the Prisma config and the Vitest
4
+ * of OpenAPI, integration tests read the Prisma and Drizzle configs and the Vitest
5
5
  * config, Orval reads the OpenAPI document path.
6
6
  */
7
- export declare const integrationIds: readonly ["storybook", "rest-endpoint-generator", "in-memory-db", "prisma", "vitest", "playwright", "testcontainers", "openapi", "orval"];
7
+ export declare const integrationIds: readonly ["storybook", "rest-endpoint-generator", "in-memory-db", "prisma", "drizzle", "vitest", "playwright", "testcontainers", "openapi", "orval"];
8
8
  export declare const addIntegration: ({ save }?: {
9
9
  save?: boolean;
10
10
  }) => Promise<string[]>;
11
11
  export declare const integrationDescriptions: () => {
12
- id: "prisma" | "openapi" | "orval" | "rest-endpoint-generator" | "storybook" | "vitest" | "testcontainers" | "in-memory-db" | "playwright";
12
+ id: "prisma" | "drizzle" | "openapi" | "orval" | "rest-endpoint-generator" | "storybook" | "vitest" | "testcontainers" | "in-memory-db" | "playwright";
13
13
  name: string;
14
14
  group: "backend" | "frontend";
15
15
  available: boolean;
@@ -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
@@ -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": "8.7.1",
4
+ "version": "8.9.0",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
@@ -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
- - Missing spec: create it from "Spec templates" in `df-ps-scaffold/references/generators.md` (exception 1). Don't re-run the generator: it would overwrite the implementation. Never delete generated specs.
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.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: df-ps-project-scripts
3
- description: Rules for running this project's own scripts (package.json) and handling the files they produce — Prisma contract (`contract.prisma`, `prisma:emit`), database migrations (`prisma:migration:plan`, `prisma:migration:apply`), and other codegen. Use when a change needs new or changed database data (models, fields), when planning or creating a migration, when regenerating contract types, or when the user asks to run any project script that writes files.
3
+ description: Rules for running this project's own scripts (package.json) and handling the files they produce — Prisma contract (`contract.prisma`, `prisma:emit`), Drizzle schema (`schema.ts`), database migrations (`prisma:migration:plan`, `prisma:migration:apply`, `drizzle:generate`, `drizzle:migrate`), and other codegen. Use when a change needs new or changed database data (models, fields), when planning or creating a migration, when regenerating contract types, or when the user asks to run any project script that writes files.
4
4
  ---
5
5
 
6
6
  # Project scripts
@@ -9,9 +9,9 @@ The project's scripts live in `package.json`. Run them through `npm run <script>
9
9
 
10
10
  ## Rules
11
11
 
12
- 1. **No approval needed.** Files written by the project's own scripts (`prisma:emit`, `prisma:migration:plan`, …) aren't "new files" under `df-ps-scaffold` rule 1: run these scripts yourself when the work needs them. Still list them under "Tool runs" in a work plan so the user sees them coming, and report every run.
13
- 2. **The database is changed only by a human.** Never run `prisma:migration:apply` or anything else that touches the database (`prisma db …`). When a migration is ready, give the user the command (`! npm run prisma:migration:apply`) and wait.
14
- 3. **Script output is never edited.** Generated migrations, `contract.json`, `contract.d.ts`, and any other output are used as-is: no edits, no deletions, no hand-written copies. Output is wrong → change the source (`contract.prisma`) and run the script again; if that can't fix it (a wrong migration already exists), stop and tell the user.
12
+ 1. **No approval needed.** Files written by the project's own scripts (`prisma:emit`, `prisma:migration:plan`, `drizzle:generate`, …) aren't "new files" under `df-ps-scaffold` rule 1: run these scripts yourself when the work needs them. Still list them under "Tool runs" in a work plan so the user sees them coming, and report every run.
13
+ 2. **The database is changed only by a human.** Never run `prisma:migration:apply`, `drizzle:migrate` or anything else that touches the database (`prisma db …`, `drizzle-kit push`). When a migration is ready, give the user the command (`! npm run prisma:migration:apply`, `! npm run drizzle:migrate`) and wait.
14
+ 3. **Script output is never edited.** Generated migrations, `contract.json`, `contract.d.ts`, and any other output are used as-is: no edits, no deletions, no hand-written copies. Output is wrong → change the source (`contract.prisma`, `schema.ts`) and run the script again; if that can't fix it (a wrong migration already exists), stop and tell the user.
15
15
 
16
16
  ## Prisma
17
17
 
@@ -27,7 +27,7 @@ Config: `shared-kernel/infrastructure/prisma/prisma.config.ts`. Source: `shared-
27
27
 
28
28
  Only when domain and application logic are implemented, and implementing an infrastructure module (repository, command/query) needs data the database doesn't have yet. Not earlier "just in case", and never as the first step of a feature: the domain decides what's stored, not the schema.
29
29
 
30
- Order: domain → application → `contract.prisma` + migration → user applies it → infrastructure → endpoints → other codegen → React.
30
+ Order: domain → application → `contract.prisma` / `schema.ts` + migration → user applies it → infrastructure → endpoints → other codegen → React.
31
31
 
32
32
  ### Making a migration
33
33
 
@@ -38,3 +38,20 @@ Order: domain → application → `contract.prisma` + migration → user applies
38
38
  5. Check the output: the planned files only, nothing else changed. Report each migration and ask the user to apply them before implementing the infrastructure that depends on them.
39
39
 
40
40
  Types only (no storage change, e.g. after pulling someone's contract change): `npm run prisma:emit`.
41
+
42
+ ## Drizzle
43
+
44
+ Config: `shared-kernel/infrastructure/drizzle/drizzle.config.ts`. Source: `shared-kernel/infrastructure/drizzle/schema.ts` (edit by hand, tables with `drizzle-orm/pg-core`). Output: `migrations/` next to it (SQL files and `meta/`, from `drizzle:generate`). The database is created in `shared-kernel/infrastructure/services/drizzle-infrastructure-service.ts`; implementations import tables from `schema.ts`.
45
+
46
+ | Script | Does | Who runs it |
47
+ | ------------------ | ------------------------------------------------------------ | ----------------- |
48
+ | `drizzle:generate` | Writes a SQL migration from the change in `schema.ts`. Offline. | You |
49
+ | `drizzle:migrate` | Applies migrations to the database. | **The user only** |
50
+
51
+ When to migrate: as for Prisma above.
52
+
53
+ 1. Edit `schema.ts` for **one** logical change.
54
+ 2. Generate it with a name by meaning: `npm run drizzle:generate -- --name add-user`.
55
+ 3. Several changes → repeat 1–2 once per change.
56
+ 4. When `drizzle:generate` asks whether a column or table is created or renamed, it waits for an answer you can't give: stop it, and ask the user to run `! npm run drizzle:generate -- --name <name>` and answer it.
57
+ 5. Check the output: the new SQL file and `meta/` only. Report each migration and ask the user to apply them before implementing the infrastructure that depends on them.
@@ -89,6 +89,7 @@ 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
+ - **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).
92
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.
@@ -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
 
@@ -139,9 +139,10 @@ Use `operation: "add"` and a nonempty `integrations` array. Select only IDs mark
139
139
  | `rest-endpoint-generator` | Backend must have `@domain-first/handlers-rest`. `nextAdapter` applies only when `frontend.react.framework` is `next`; omitted means no Next adapter in JSON mode. Existing support files are preserved with a manual connection note as needed. |
140
140
  | `in-memory-db` | Backend required. Enables the DB flag and restores missing support files while keeping edited files. No extra fields. |
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
+ | `drizzle` | Backend required. `withService` defaults to true; false skips the infrastructure service and its wire. Registers `drizzle` implementation choices. A `drizzle.config.*` in the project root is rejected as an existing setup. |
142
143
  | `vitest` | Backend required. `replaceTestingLibrary` is required if a different testing library is configured; true changes it to Vitest, false skips this setup. |
143
144
  | `playwright` | No extra integration-specific fields. Adds its config, example and scripts. |
144
- | `testcontainers` | Backend required. No extra fields. Reads staged Prisma/Vitest setup when selected together. Database scripts are generated, not executed. |
145
+ | `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/Drizzle/Vitest setup when selected together. Database scripts are generated, not executed. |
145
146
  | `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
147
  | `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
148
 
@@ -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 spec templates. Prompts and output of each generator are in `units/<unit>.md`.
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
 
@@ -35,7 +35,7 @@ Each chosen module goes into the wire (`wireClass(X, [wireUserRepository])`) and
35
35
 
36
36
  An env-branched wire (repository, command/query, port) wires each implementation in isolation: 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.
37
37
 
38
- It may start with a `Suggested` group, which holds only the system service of the implementation: `prisma-infrastructure-service` for `prisma`, `in-memory-db-infrastructure-service` for `in-memory`. It is listed there only and is **checked**: omitting the implementation's group in JSON keeps it, `[]` selects none. Any other service is an ordinary unchecked item in `Infrastructure services`, whatever its name, so select it explicitly.
38
+ It may start with a `Suggested` group, which holds only the system service of the implementation: `prisma-infrastructure-service` for `prisma`, `drizzle-infrastructure-service` for `drizzle`, `in-memory-db-infrastructure-service` for `in-memory`. It is listed there only and is **checked**: omitting the implementation's group in JSON keeps it, `[]` selects none. Any other service is an ordinary unchecked item in `Infrastructure services`, whatever its name, so select it explicitly.
39
39
 
40
40
  ## Remembered and system implementation types
41
41
 
@@ -96,3 +96,28 @@ Only modules without infrastructure have specs. Repositories, commands, queries,
96
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` |
97
97
 
98
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.
@@ -10,6 +10,7 @@ Prompts: name → `With Repository` → primary implementation select → `Add a
10
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 spec of the root with the aggregate rules. The repository has no unit spec: it is infrastructure, tested through integration tests and the use cases that inject its test implementation.
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.
@@ -12,6 +12,7 @@ Prompts: name → primary implementation select → `Add a test implementation`
12
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
- No unit spec: a command or query is infrastructure, tested through integration tests and the use cases that inject its test implementation.
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.
@@ -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. 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.
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.
@@ -9,6 +9,7 @@ Prompts: name → primary adapter select → `With test implementation` → test
9
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
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 domain, application or presentation service's logic with fake dependencies in its generated spec. Infrastructure services have no unit spec: integration tests cover them.
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.