@domain-first/project-structure 4.2.0 → 4.2.2

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
@@ -164,30 +164,15 @@ Every endpoint uses the one endpoint generator of the project, `RestEndpointGene
164
164
  const adapter = undefined as unknown as Adapter<any[], any>
165
165
 
166
166
  export class RestEndpointGeneratorPresentationService {
167
- /**
168
- * Default errors of a client request, to spread into a generator's
169
- * own error mappings.
170
- */
171
- private get defaultClientRequestErrors(): ErrorMapping[] {
172
- return [
173
- httpStatus(400, {
174
- code: 'INVALID_REQUEST',
175
- description: 'Invalid request',
176
- message: (error) => error.message,
177
- match: [RequestParsingError, InputMappingError]
178
- })
179
- ]
180
- }
181
-
182
167
  get withoutGuards(): EndpointGenerator {
183
168
  return createEndpoint({
184
- errors: this.defaultClientRequestErrors
169
+ errors: [invalidRequest()]
185
170
  })(adapter) as EndpointGenerator
186
171
  }
187
172
  }
188
173
  ```
189
174
 
190
- Set the module-level `adapter` constant above the class to the adapter of your HTTP framework; the class uses it through closure. If you connected the Next adapter during initialization, the file imports `nextAdapter` from `@domain-first/handlers-next` instead, with nothing to set. Each generating method is a getter returning `EndpointGenerator`: add one per kind of endpoint (for example `withAuth`, with its `context` and error mappings). Reuse the default mappings there and add your own: `errors: [httpError(MyError, 404), ...this.defaultClientRequestErrors]`. A new endpoint calls `this.endpointGenerator(...)` and doesn't compile on purpose: choose the getter yourself in its `get handle()`, e.g. `this.endpointGenerator.withoutGuards(...)`.
175
+ Set the module-level `adapter` constant above the class to the adapter of your HTTP framework; the class uses it through closure. If you connected the Next adapter during initialization, the file imports `nextAdapter` from `@domain-first/handlers-next` instead, with nothing to set. Each generating method is a getter returning `EndpointGenerator`: add one per kind of endpoint (for example `withAuth`, with its `context` and error mappings). Keep `invalidRequest()` of `@domain-first/handlers-rest` there for invalid requests (`400`) and add your own mappings: `errors: [httpError(MyError, 404), invalidRequest()]`. A new endpoint calls `this.endpointGenerator(...)` and doesn't compile on purpose: choose the getter yourself in its `get handle()`, e.g. `this.endpointGenerator.withoutGuards(...)`.
191
176
 
192
177
  With wiring, the endpoint takes the generator and a handler you pick from the context's queries, commands and use cases, and all endpoints are collected as `restHandlers` in `src/presentation/rest/index.ts`. Connect them to your HTTP server.
193
178
 
package/dist/201.js CHANGED
@@ -31,7 +31,9 @@ const infrastructure = [
31
31
  'infrastructure-services'
32
32
  ];
33
33
  const defaultDependencies = {
34
- 'domain-services': domain,
34
+ 'domain-services': [
35
+ 'domain-services'
36
+ ],
35
37
  repositories: [
36
38
  'domain-services',
37
39
  'application-ports',
@@ -40,7 +42,8 @@ const defaultDependencies = {
40
42
  'application-ports': infrastructure,
41
43
  'application-services': [
42
44
  ...domain,
43
- 'application-ports'
45
+ 'application-ports',
46
+ ...commandsAndQueries
44
47
  ],
45
48
  'use-cases': [
46
49
  ...domain,
package/dist/index.cjs CHANGED
@@ -60,7 +60,9 @@ const infrastructure = [
60
60
  'infrastructure-services'
61
61
  ];
62
62
  const defaultDependencies = {
63
- 'domain-services': domain,
63
+ 'domain-services': [
64
+ 'domain-services'
65
+ ],
64
66
  repositories: [
65
67
  'domain-services',
66
68
  'application-ports',
@@ -69,7 +71,8 @@ const defaultDependencies = {
69
71
  'application-ports': infrastructure,
70
72
  'application-services': [
71
73
  ...domain,
72
- 'application-ports'
74
+ 'application-ports',
75
+ ...commandsAndQueries
73
76
  ],
74
77
  'use-cases': [
75
78
  ...domain,
@@ -2129,11 +2132,8 @@ const scaffoldRestEndpointGenerator = (sharedFolder, { withNextAdapter = false }
2129
2132
  return `
2130
2133
  import {
2131
2134
  ${withNextAdapter ? '' : ' type Adapter,\n'} type EndpointGenerator,
2132
- type ErrorMapping,
2133
2135
  createEndpoint,
2134
- httpStatus,
2135
- InputMappingError,
2136
- RequestParsingError
2136
+ invalidRequest
2137
2137
  } from '@domain-first/handlers-rest'
2138
2138
  ${withNextAdapter ? "import { nextAdapter } from '@domain-first/handlers-next'" : `
2139
2139
  /**
@@ -2142,24 +2142,9 @@ ${withNextAdapter ? "import { nextAdapter } from '@domain-first/handlers-next'"
2142
2142
  const adapter = undefined as unknown as Adapter<any[], any>`}
2143
2143
 
2144
2144
  export class ${className} {
2145
- /**
2146
- * Default errors of a client request, to spread into a generator's
2147
- * own error mappings.
2148
- */
2149
- private get defaultClientRequestErrors(): ErrorMapping[] {
2150
- return [
2151
- httpStatus(400, {
2152
- code: 'INVALID_REQUEST',
2153
- description: 'Invalid request',
2154
- message: (error) => error.message,
2155
- match: [RequestParsingError, InputMappingError]
2156
- })
2157
- ]
2158
- }
2159
-
2160
2145
  get withoutGuards(): EndpointGenerator {
2161
2146
  return createEndpoint({
2162
- errors: this.defaultClientRequestErrors
2147
+ errors: [invalidRequest()]
2163
2148
  })(${adapter}) as EndpointGenerator
2164
2149
  }
2165
2150
  }
package/dist/index.js CHANGED
@@ -1429,11 +1429,8 @@ const scaffoldRestEndpointGenerator = (sharedFolder, { withNextAdapter = false }
1429
1429
  return `
1430
1430
  import {
1431
1431
  ${withNextAdapter ? '' : ' type Adapter,\n'} type EndpointGenerator,
1432
- type ErrorMapping,
1433
1432
  createEndpoint,
1434
- httpStatus,
1435
- InputMappingError,
1436
- RequestParsingError
1433
+ invalidRequest
1437
1434
  } from '@domain-first/handlers-rest'
1438
1435
  ${withNextAdapter ? "import { nextAdapter } from '@domain-first/handlers-next'" : `
1439
1436
  /**
@@ -1442,24 +1439,9 @@ ${withNextAdapter ? "import { nextAdapter } from '@domain-first/handlers-next'"
1442
1439
  const adapter = undefined as unknown as Adapter<any[], any>`}
1443
1440
 
1444
1441
  export class ${className} {
1445
- /**
1446
- * Default errors of a client request, to spread into a generator's
1447
- * own error mappings.
1448
- */
1449
- private get defaultClientRequestErrors(): ErrorMapping[] {
1450
- return [
1451
- httpStatus(400, {
1452
- code: 'INVALID_REQUEST',
1453
- description: 'Invalid request',
1454
- message: (error) => error.message,
1455
- match: [RequestParsingError, InputMappingError]
1456
- })
1457
- ]
1458
- }
1459
-
1460
1442
  get withoutGuards(): EndpointGenerator {
1461
1443
  return createEndpoint({
1462
- errors: this.defaultClientRequestErrors
1444
+ errors: [invalidRequest()]
1463
1445
  })(${adapter}) as EndpointGenerator
1464
1446
  }
1465
1447
  }
package/dist/lint.cjs CHANGED
@@ -60,7 +60,9 @@ const infrastructure = [
60
60
  'infrastructure-services'
61
61
  ];
62
62
  const defaultDependencies = {
63
- 'domain-services': domain,
63
+ 'domain-services': [
64
+ 'domain-services'
65
+ ],
64
66
  repositories: [
65
67
  'domain-services',
66
68
  'application-ports',
@@ -69,7 +71,8 @@ const defaultDependencies = {
69
71
  'application-ports': infrastructure,
70
72
  'application-services': [
71
73
  ...domain,
72
- 'application-ports'
74
+ 'application-ports',
75
+ ...commandsAndQueries
73
76
  ],
74
77
  'use-cases': [
75
78
  ...domain,
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": "4.2.0",
4
+ "version": "4.2.2",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
@@ -67,7 +67,7 @@ export class Order extends domainType(
67
67
  ## Application
68
68
 
69
69
  - Use cases, commands, queries ({handlers}): the member is `handle = defineHandler({ inputSchema, outputSchema, handler })`. Replace the static `{}` schemas with real ones and write the logic in the `handler` callback; dependencies come through the constructor. Execution: the abstract contract holds the static schemas and `abstract handle`; each infrastructure implementation defines `handle` with the contract's schemas and writes only its `handler` callback. Orchestrator: a concrete class composing injected contracts. Call with `x.handle(input)` (returns a result) or `x.handle.unsafe(input)` (throws).
70
- - A query only reads: it never changes data (not even idempotently) and never uses a command; an orchestrator query may use a repository, but calls only its reading methods (never `save`/`delete`); see "Commonly confused" in `df-ps-scaffold/references/choosing-components.md`. Data a command returns goes in its output schema.
70
+ - A query only reads: it never changes data (not even idempotently) and never uses a command; an orchestrator query may use a repository, but calls only its reading methods (never `save`/`delete`); see "Commonly confused" in `df-ps-scaffold/references/choosing-components.md`. A command returns nothing or only the minimum needed to use its result later (e.g. the created ID), in its output schema; data to show after it comes from a query.
71
71
  - Ports: abstract members in the port, one implementation per adapter (`api` real, `mock`/`fake` deterministic). Use the shared `clock` port instead of `new Date()`.
72
72
  - Services: what each kind may contain and call is in `choosing-components.md` (steps 13–16, "Port or service?"). Domain services take and return domain types. Application services have no `handle`.
73
73
 
@@ -86,7 +86,7 @@ export const wirePlaceOrderUseCase = wireClass(PlaceOrderUseCase, [wireOrderRepo
86
86
 
87
87
  ## REST endpoints ({handlers-rest})
88
88
 
89
- 1. Generator: initialization creates `RestEndpointGeneratorPresentationService` in `<rootFolder>/shared/presentation/services/`; every endpoint uses it. Set the module-level `const adapter` above the class (`undefined` until set) to the HTTP framework's adapter; the class reads it through closure. If initialization connected the Next adapter, the file already imports `nextAdapter` from `@domain-first/handlers-next` and passes it instead; just make sure that package is installed. The default `400` mapping lives in the private `defaultClientRequestErrors` getter (`ErrorMapping[]`); extend it with `errors: [httpError(MyError, 404), ...this.defaultClientRequestErrors]`. Map domain errors to statuses in the generator's `errors` with `httpError(ErrorClass, status, { description, message, details: { schema, map } })` (one class) or `httpStatus(status, { code, match })` (many errors, one code); the first match wins, so put specific mappings first, importing them from the contexts' `domain/errors` (the only thing `shared/` may import from a context, besides domain models in the in-memory DB). A new kind of endpoint (auth, other context) is a new getter returning `createEndpoint({ context, errors })(adapter) as EndpointGenerator` (`nextAdapter` with the Next adapter), next to `withoutGuards`. Generate the exposed handler before the endpoint: with wire, the `Handler:` pick fills its type and the wire (`[wireRestEndpointGeneratorPresentationService, wireGetRecentOrdersUseCase]`).
89
+ 1. Generator: initialization creates `RestEndpointGeneratorPresentationService` in `<rootFolder>/shared/presentation/services/`; every endpoint uses it. Set the module-level `const adapter` above the class (`undefined` until set) to the HTTP framework's adapter; the class reads it through closure. If initialization connected the Next adapter, the file already imports `nextAdapter` from `@domain-first/handlers-next` and passes it instead; just make sure that package is installed. Invalid requests (`400`) are answered by `invalidRequest()` of `@domain-first/handlers-rest` in `errors`; don't map `RequestParsingError` / `InputMappingError` by hand, add your own mappings next to it: `errors: [httpError(MyError, 404), invalidRequest()]`. Map domain errors to statuses in the generator's `errors` with `httpError(ErrorClass, status, { description, message, details: { schema, map } })` (one class) or `httpStatus(status, { code, match })` (many errors, one code); the first match wins, so put specific mappings first, importing them from the contexts' `domain/errors` (the only thing `shared/` may import from a context, besides domain models in the in-memory DB). A new kind of endpoint (auth, other context) is a new getter returning `createEndpoint({ context, errors: [..., invalidRequest()] })(adapter) as EndpointGenerator` (`nextAdapter` with the Next adapter), next to `withoutGuards`. Generate the exposed handler before the endpoint: with wire, the `Handler:` pick fills its type and the wire (`[wireRestEndpointGeneratorPresentationService, wireRecentOrdersQuery]`).
90
90
  2. If `handler: never` is left (no handler existed at generation), re-run the endpoint generator as an approved overwrite to pick it (rule 3); don't replace it by hand.
91
91
  3. Complete `get handle()`: the generated `this.endpointGenerator(...)` doesn't compile on purpose. Pick the generating getter that fits the endpoint (`this.endpointGenerator.withoutGuards(...)`, or one with the needed guards), then `.input(...)`, `.mapInput(...)`, optional `.output(...)`, `.mapOutput(...)`.
92
92
  4. Register `restHandlers` from `<rootFolder>/presentation/rest/index.ts` in the server bootstrap (rule 2, exception 5).
@@ -35,7 +35,7 @@ Split the request into pieces of logic and choose each piece's component with `d
35
35
  - Otherwise, look for the ways the project already reaches a context besides its REST endpoints: message queue, RPC, events, generated API clients. Several options (REST counts) → ask the user which one in "Decisions for you", with a recommendation. Never pick silently.
36
36
  - Nothing besides REST → the providing context's REST endpoint (`http`).
37
37
 
38
- Unless it's the database, plan **both sides**: check that the providing context exposes what the call needs (endpoint, queue consumer…). If not, add it (and the use case behind it) to the plan.
38
+ Unless it's the database, plan **both sides**: check that the providing context exposes what the call needs (endpoint, queue consumer…). If not, add it (and the handler behind it: a query or command, or a use case only when one query or command isn't enough) to the plan.
39
39
  5. `shared/` holds technical, ownerless pieces and universal entities / value objects (`money`, `email`): the same meaning in every context, owned by none. Never a concept with one context's meaning or rules.
40
40
  6. Names: kebab-case, in the context's language. Contexts are business areas (`sales`, `reviews`), not features.
41
41
 
@@ -15,19 +15,20 @@ Split the request into pieces of logic (one responsibility each). For each piece
15
15
  | 5 | An entity or value object used **only inside one** aggregate (an entity inside it, or a value like `order-id` used only by `order`)? | **Entity / value object** (Domain → New Entity / New Value Object, pick that aggregate) |
16
16
  | 6 | An entity or value object used by **several** aggregates or by a domain service? | **Entity / value object** (Domain → New Entity / New Value Object, `No aggregate`). Universal ones (see "Where it goes") in Shared Layer |
17
17
  | 7 | A rule about one aggregate's own state, including the junction of entities / value objects that all belong to it? | **Method on the aggregate**. No new file |
18
- | 8 | One business action a user/system triggers? (Its I/O is separate pieces.) | **Use case** |
18
+ | 8 | One business action a user/system triggers that doesn't fit into a single query or command? (Its I/O is separate pieces.) | **Use case**. An action that is exactly one query or command gets none (see below) |
19
19
  | 9 | Data or behavior of **another context**? | **Execution query** (read) / **execution command** (write) in this context (see below) |
20
20
  | 10 | Leaves this context's code and storage: external system or time? | **Port** (+ adapters) |
21
21
  | 11 | One read/write on this context's own storage that isn't "load/save one aggregate" (read model, report, bulk update)? | **Execution command** (write) / **query** (read) |
22
22
  | 12 | A reusable read/write composed of other commands/queries? | **Orchestrator command** (execution commands and queries) / **query** (execution queries and repositories only, calling only their reading methods) |
23
- | 13 | A rule at the junction of several entities / value objects not all belonging to one aggregate (a discount from purchase history and the current discount), no I/O? | **Domain service**, always |
24
- | 14 | Application logic reused by 2+ use cases, with any external interaction delegated to injected ports? | **Application service** |
23
+ | 13 | A rule at the junction of several entities / value objects not all belonging to one aggregate (a discount from purchase history and the current discount), no I/O? | **Domain service**, always. It takes the aggregates and values it needs as arguments; loading them is the caller's job (use case, application service) |
24
+ | 14 | Application logic reused by 2+ use cases, with any external interaction or storage access delegated to injected ports, commands or queries? | **Application service** |
25
25
  | 15 | A technical helper used only by infrastructure code? | **Infrastructure service** |
26
26
  | 16 | A helper used only by presentation code? | **Presentation service** |
27
27
  | — | None of the above | A method or function in an existing file |
28
28
 
29
29
  - Entities and value objects are **rich**: rules about their own data, including how they are created, are their methods. They never know about their storage or loading: that's repositories and execution queries/commands.
30
30
  - Loading/saving one aggregate = a **repository method**, not a query or command.
31
+ - **No proxy use cases.** Every query and command (execution or orchestration) is a handler, so an endpoint uses it directly. A use case that only forwards the call to one query or command adds nothing: don't create it. A use case appears only when the action needs several queries, commands or ports, or logic around them.
31
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.
32
33
  - Steps 9–10 beat 11–16. The other-context or external part becomes an execution query/command or a port. What remains may be a service that **receives it in its constructor**.
33
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.
@@ -36,7 +37,7 @@ Split the request into pieces of logic (one responsibility each). For each piece
36
37
  ## Port or service?
37
38
 
38
39
  - A **port** describes a capability at the boundary: an external system or time. Its adapter performs the actual interaction. Own storage still follows the repository / execution command / query rules above. Another context is not a port: it's an execution query/command (step 9).
39
- - An **application service** contains reusable application logic and may call injected ports. It does not call external SDKs, HTTP clients, or another context directly. A domain service remains pure: no I/O, ports, or repositories.
40
+ - An **application service** contains reusable application logic and may call injected ports, commands and queries. It does not call external SDKs, HTTP clients, or another context directly. A domain service remains pure: no I/O, ports, or repositories, not even injected ones; it works with the data it is handed.
40
41
  - Wanting to mock a class or imagining multiple implementations is not enough to make it a port. Identify the boundary capability first. Ports get swappable adapters and a test implementation under `NODE_ENV=test`; test a service's logic with fake dependencies.
41
42
 
42
43
  Example: `order-confirmation` prepares a message and calls the injected `mailer` port. It stays an application service; the mailer adapter calls the email provider. Tests use a fake mailer and exercise the real service.
@@ -47,11 +48,12 @@ Example: `order-confirmation` prepares a message and calls the injected `mailer`
47
48
  | --- | --- |
48
49
  | Port / repository | Own aggregate's persistence → repository. External system → port. |
49
50
  | Port / execution command, query | Own storage or another context → command/query. External system → port. |
50
- | Query / command | A query only reads: it never changes any state, not even idempotently (no cache filling, no default settings created if missing), and never calls a command. Any state change → command. A command may return data (the created order, the new balance); an orchestrator command may also use execution queries. An orchestrator query may load aggregates through a repository, but never calls its writing methods (`save`, `delete`): the wiring can't forbid it, so it's on the developer. |
51
+ | Query / command | A query only reads: it never changes any state, not even idempotently (no cache filling, no default settings created if missing), and never calls a command. Any state change → command. A command returns nothing or only the minimum needed to use its result later (the created order's ID), never the changed data: read that with a query. An orchestrator command may also use execution queries. An orchestrator query may load aggregates through a repository, but never calls its writing methods (`save`, `delete`): the wiring can't forbid it, so it's on the developer. |
51
52
  | Domain service / entity, value object method | One entity / value object → its method. The junction of several → always a domain service, unless they all belong to one aggregate → a method on that aggregate. |
52
53
  | Domain / application service | Stated without requests, permissions, responses, scenarios → domain. Otherwise application. |
53
54
  | Use case / application service | Use case = one action with `handle`. Application service = helper used by use cases. |
54
- | Use case / orchestrator | Use case = action exposed outside. Orchestrator = reusable operation called by use cases. |
55
+ | Use case / orchestrator | Use case = one complete business action, never reused by other use cases. Orchestrator = reusable read/write composed of execution commands/queries. Both are handlers an endpoint can use directly. |
56
+ | Orchestrator / application service | Only composes commands/queries into one reusable storage operation → orchestrator. Also needs ports or application logic beyond that composition → application service (it may call commands and queries, orchestrators included). |
55
57
  | Application / infrastructure service | Used by use cases → application. Only by adapters/repositories → infrastructure. |
56
58
  | Logic infrastructure needs from an application service | Infrastructure never sees application services. Pure logic without ports → domain service. Logic over ports → infrastructure calls the ports directly. Technical (mapping, retries, external API formats) → infrastructure service. |
57
59
  | Clock | Always a port (`clock`, usually in Shared Layer). |
@@ -6,7 +6,7 @@ Every step list starts with `"pick:Bounded Context: <ctx>"` or `"pick:Shared Lay
6
6
 
7
7
  Any generator: if the run would replace existing files, the last prompt is the confirm `Overwrite them?` (the files are listed above it). Without it, nothing extra is asked. Added lines (barrels, errors, wiring indexes) never trigger it.
8
8
 
9
- {wire} Generators that create a wire (all below except endpoints, which ask their own two selects) then ask the checkbox `Dependencies:`, before `Overwrite them?`. It lists wired modules of `<C>` and of the Shared Layer (`(shared)` suffix), grouped under headers in this order: Repositories, Domain services, Ports, Application services, Queries, Commands, Use cases, Infrastructure services, Presentation services. Inside a group: by type name, `<C>` first. Headers are not counted: `toggle:<n,..>` numbers only modules, top to bottom. Answer `toggle:<n,..>` or `none`. It is skipped when nothing fits, so check `<C>/wiring/` and `<rootFolder>/shared/wiring/` before counting steps. What fits depends on the layer of the class the wire builds: domain → domain; application → domain, application; infrastructure (repository, execution command/query, and port implementations, infrastructure services) → domain, application ports (of `<C>` and the Shared Layer; no other application modules), infrastructure; presentation → application, presentation. On top of that, application services see only ports from application, use cases never see use cases, repository implementations never see repositories, execution command/query implementations never see commands or queries, orchestration commands see only execution commands and queries from application, and orchestration queries only execution queries (repositories from domain stay available; they call only reading methods). These are the defaults: `rules.dependencies` in the config changes them per kind (`use-cases`, `orchestration-queries`, …), so count items from what the project's rules allow. Endpoints are never listed. Each chosen module goes into the wire (`wireClass(X, [wireUserRepository])`) and the constructor (`private readonly userRepository: UserRepository`, with `import type`), in the same order. An env-branched wire (repository, execution command/query, port) wires each implementation in isolation: instead of `Dependencies:` 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. It may start with a `Suggested` group: infrastructure modules whose file name has the implementation label (its folder, e.g. `prisma`, `in-memory`) as whole words, such as `in-memory-db-infrastructure-service` for `in-memory`. They are listed there only, so numbering starts with them, and they are **checked**: `none` keeps them, `toggle:<n>` on one of them unchecks it.
9
+ {wire} Generators that create a wire (all below except endpoints, which ask their own two selects) then ask the checkbox `Dependencies:`, before `Overwrite them?`. It lists wired modules of `<C>` and of the Shared Layer (`(shared)` suffix), grouped under headers in this order: Repositories, Domain services, Ports, Application services, Queries, Commands, Use cases, Infrastructure services, Presentation services. Inside a group: by type name, `<C>` first. Headers are not counted: `toggle:<n,..>` numbers only modules, top to bottom. Answer `toggle:<n,..>` or `none`. It is skipped when nothing fits, so check `<C>/wiring/` and `<rootFolder>/shared/wiring/` before counting steps. What fits depends on the layer of the class the wire builds: domain → domain; application → domain, application; infrastructure (repository, execution command/query, and port implementations, infrastructure services) → domain, application ports (of `<C>` and the Shared Layer; no other application modules), infrastructure; presentation → application, presentation. On top of that, domain services see only domain services (no repositories), application services see only ports, commands and queries from application, use cases never see use cases, repository implementations never see repositories, execution command/query implementations never see commands or queries, orchestration commands see only execution commands and queries from application, and orchestration queries only execution queries (repositories from domain stay available; they call only reading methods). These are the defaults: `rules.dependencies` in the config changes them per kind (`use-cases`, `orchestration-queries`, …), so count items from what the project's rules allow. Endpoints are never listed. Each chosen module goes into the wire (`wireClass(X, [wireUserRepository])`) and the constructor (`private readonly userRepository: UserRepository`, with `import type`), in the same order. An env-branched wire (repository, execution command/query, port) wires each implementation in isolation: instead of `Dependencies:` 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. It may start with a `Suggested` group: infrastructure modules whose file name has the implementation label (its folder, e.g. `prisma`, `in-memory`) as whole words, such as `in-memory-db-infrastructure-service` for `in-memory`. They are listed there only, so numbering starts with them, and they are **checked**: `none` keeps them, `toggle:<n>` on one of them unchecks it.
10
10
 
11
11
  ## Bounded context
12
12
 
@@ -107,13 +107,13 @@ Edits the wire and the implementation classes in place; this never triggers `Ove
107
107
 
108
108
  Prompts: controller (select: existing | `New controller` → name) → method (`get` `post` `patch` `delete` `put`) → relative path (may be empty: `default`) → {wire} `Handler:` (select: queries, commands, and use cases of `<C>`, grouped; skipped if there are none).
109
109
 
110
- `… pick:Presentation "pick:New Handlers" "pick:New controller" text:orders pick:get text:recent pick:GetRecentOrders`
110
+ `… pick:Presentation "pick:New Handlers" "pick:New controller" text:orders pick:get text:recent pick:RecentOrdersQuery`
111
111
  `… pick:Presentation "pick:New Handlers" pick:orders pick:post default pick:PlaceOrder`
112
112
 
113
113
  For `sales`, `orders`, `get`, `recent`:
114
114
 
115
- - `<C>/presentation/rest/orders/recent/GET.ts`: `class OrdersRecentGetEndpoint(endpointGenerator, handler)`, route `['sales','orders','recent']`. `endpointGenerator: RestEndpointGeneratorPresentationService` (the Shared Layer generator from initialization) and `handler: GetRecentOrdersUseCase` (`never` without a pick), both `import type`. `get handle()` calls `this.endpointGenerator(...)`, which doesn't compile until a generating getter is picked (`this.endpointGenerator.withoutGuards(...)`); that's expected, not a generator bug. Projects without the generator file get `EndpointGenerator` from handlers-rest.
116
- - {wire} `<C>/wiring/presentation/rest/orders/wire-orders-recent-get-endpoint.ts` (`[wireRestEndpointGeneratorPresentationService, wireGetRecentOrdersUseCase]`; `[]` without the generator file) + a line in that folder's `index.ts`
115
+ - `<C>/presentation/rest/orders/recent/GET.ts`: `class OrdersRecentGetEndpoint(endpointGenerator, handler)`, route `['sales','orders','recent']`. `endpointGenerator: RestEndpointGeneratorPresentationService` (the Shared Layer generator from initialization) and `handler: RecentOrdersQuery` (`never` without a pick), both `import type`. `get handle()` calls `this.endpointGenerator(...)`, which doesn't compile until a generating getter is picked (`this.endpointGenerator.withoutGuards(...)`); that's expected, not a generator bug. Projects without the generator file get `EndpointGenerator` from handlers-rest.
116
+ - {wire} `<C>/wiring/presentation/rest/orders/wire-orders-recent-get-endpoint.ts` (`[wireRestEndpointGeneratorPresentationService, wireRecentOrdersQuery]`; `[]` without the generator file) + a line in that folder's `index.ts`
117
117
  - {wire}, new controller only: `<C>/wiring/presentation/rest/index.ts`, `<rootFolder>/presentation/rest/wires.ts` (lines appended), `<rootFolder>/presentation/rest/index.ts` (`restHandlers`, created once)
118
118
 
119
119
  The same controller, path, and method replace the existing endpoint (after `Overwrite them?`).