@domain-first/project-structure 3.2.1 → 3.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/dist/index.cjs CHANGED
@@ -1230,6 +1230,7 @@ const visibleLayers = {
1230
1230
  ],
1231
1231
  infrastructure: [
1232
1232
  'domain',
1233
+ 'application',
1233
1234
  'infrastructure'
1234
1235
  ],
1235
1236
  presentation: [
@@ -1351,6 +1352,9 @@ const findWiredModules = (contextPath)=>{
1351
1352
  const isCommandOrQuery = (module)=>'commands' === module.kind || 'queries' === module.kind;
1352
1353
  const isExecution = (module)=>isCommandOrQuery(module) && 'execution' === external_node_path_default().basename(external_node_path_default().dirname(module.typeFile));
1353
1354
  const commandOrQueryRule = (candidate, consumer)=>isExecution(consumer) ? !isCommandOrQuery(candidate) : 'application' !== candidate.layer || isExecution(candidate);
1355
+ const layerRules = {
1356
+ infrastructure: (candidate)=>'application' !== candidate.layer || 'application-ports' === candidate.kind
1357
+ };
1354
1358
  const kindRules = {
1355
1359
  'application-services': (candidate)=>'application' !== candidate.layer || 'application-ports' === candidate.kind,
1356
1360
  'use-cases': (candidate)=>'use-cases' !== candidate.kind,
@@ -1360,7 +1364,7 @@ const kindRules = {
1360
1364
  };
1361
1365
  const wiring_implementationType = (consumer, implementation)=>consumer.branched ? external_node_path_default().basename(external_node_path_default().dirname(implementation.file)) : void 0;
1362
1366
  const isSuggestedFor = (candidate, implementation)=>'infrastructure' === candidate.layer && `-${external_node_path_default().basename(candidate.typeFile, '.ts')}-`.includes(`-${implementation}-`);
1363
- const canDependOn = (consumer, candidate)=>visibleLayers[consumer.implementationsLayer].includes(candidate.layer) && (kindRules[consumer.kind]?.(candidate, consumer) ?? true);
1367
+ const canDependOn = (consumer, candidate)=>visibleLayers[consumer.implementationsLayer].includes(candidate.layer) && (layerRules[consumer.implementationsLayer]?.(candidate) ?? true) && (kindRules[consumer.kind]?.(candidate, consumer) ?? true);
1364
1368
  const availableDependencies = (consumer, implementation, candidates)=>{
1365
1369
  const wired = wiredDependencyNames(new File(consumer.wireFile).data, implementation.className);
1366
1370
  return candidates.filter((candidate)=>candidate.wireFile !== consumer.wireFile && canDependOn(consumer, candidate) && !wired.includes(candidate.wireName));
package/dist/index.js CHANGED
@@ -1200,6 +1200,7 @@ const visibleLayers = {
1200
1200
  ],
1201
1201
  infrastructure: [
1202
1202
  'domain',
1203
+ 'application',
1203
1204
  'infrastructure'
1204
1205
  ],
1205
1206
  presentation: [
@@ -1321,6 +1322,9 @@ const findWiredModules = (contextPath)=>{
1321
1322
  const isCommandOrQuery = (module)=>'commands' === module.kind || 'queries' === module.kind;
1322
1323
  const isExecution = (module)=>isCommandOrQuery(module) && 'execution' === node_path.basename(node_path.dirname(module.typeFile));
1323
1324
  const commandOrQueryRule = (candidate, consumer)=>isExecution(consumer) ? !isCommandOrQuery(candidate) : 'application' !== candidate.layer || isExecution(candidate);
1325
+ const layerRules = {
1326
+ infrastructure: (candidate)=>'application' !== candidate.layer || 'application-ports' === candidate.kind
1327
+ };
1324
1328
  const kindRules = {
1325
1329
  'application-services': (candidate)=>'application' !== candidate.layer || 'application-ports' === candidate.kind,
1326
1330
  'use-cases': (candidate)=>'use-cases' !== candidate.kind,
@@ -1330,7 +1334,7 @@ const kindRules = {
1330
1334
  };
1331
1335
  const wiring_implementationType = (consumer, implementation)=>consumer.branched ? node_path.basename(node_path.dirname(implementation.file)) : void 0;
1332
1336
  const isSuggestedFor = (candidate, implementation)=>'infrastructure' === candidate.layer && `-${node_path.basename(candidate.typeFile, '.ts')}-`.includes(`-${implementation}-`);
1333
- const canDependOn = (consumer, candidate)=>visibleLayers[consumer.implementationsLayer].includes(candidate.layer) && (kindRules[consumer.kind]?.(candidate, consumer) ?? true);
1337
+ const canDependOn = (consumer, candidate)=>visibleLayers[consumer.implementationsLayer].includes(candidate.layer) && (layerRules[consumer.implementationsLayer]?.(candidate) ?? true) && (kindRules[consumer.kind]?.(candidate, consumer) ?? true);
1334
1338
  const availableDependencies = (consumer, implementation, candidates)=>{
1335
1339
  const wired = wiredDependencyNames(new File(consumer.wireFile).data, implementation.className);
1336
1340
  return candidates.filter((candidate)=>candidate.wireFile !== consumer.wireFile && canDependOn(consumer, candidate) && !wired.includes(candidate.wireName));
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": "3.2.1",
4
+ "version": "3.2.2",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
@@ -11,7 +11,7 @@ Generated files contain placeholders: empty classes, `{}` schemas, `[]` dependen
11
11
 
12
12
  - New files need an approved work plan (`df-ps-scaffold`, rule 1) and come only via df-ps or its listed exceptions (rule 2). Edits to existing files don't need approval; report them.
13
13
  - Keep generated names and paths: barrels, wiring, specs, and `presentation/rest/wires.ts` import them.
14
- - Layers: domain imports nothing from other layers. Application uses domain and its own abstractions. Infrastructure implements repositories, contracts, and ports. Presentation calls application handlers. Only `wiring/` knows concrete classes.
14
+ - Layers: domain imports nothing from other layers. Application uses domain and its own abstractions. Infrastructure implements repositories, contracts, and ports, and may use application ports (of its context and the Shared Layer), never other application modules. Infrastructure needing logic from an application service means the logic is misplaced: pure logic without ports → a domain service; logic over ports → call those ports directly; technical logic (mapping, retries, formatting for an external API) → an infrastructure service. Presentation calls application handlers. Only `wiring/` knows concrete classes.
15
15
  - Constructors take abstractions (`OrderRepository`, abstract `PlaceOrderCommand`, port `PaymentGateway`), never `PrismaOrderRepository`.
16
16
  - Implementation order: domain → application → schema tool runs (migrations, only if infrastructure needs data the database lacks) → infrastructure (repositories, execution commands/queries, adapters) → endpoints → other tool runs (OpenAPI, API client) → React. Widgets need the regenerated client. How to run tools and handle their output: the project's scripts skill (`project-scripts`), if there is one.
17
17
  - Run the project's tsc/lint/tests after each component.
@@ -53,6 +53,7 @@ Example: `order-confirmation` prepares a message and calls the injected `mailer`
53
53
  | Use case / application service | Use case = one action with `handle`. Application service = helper used by use cases. |
54
54
  | Use case / orchestrator | Use case = action exposed outside. Orchestrator = reusable operation called by use cases. |
55
55
  | Application / infrastructure service | Used by use cases → application. Only by adapters/repositories → infrastructure. |
56
+ | 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. |
56
57
  | Clock | Always a port (`clock`, usually in Shared Layer). |
57
58
 
58
59
  ## React page, widget, UI-kit component or shared hook
@@ -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) → domain, infrastructure (it implements application modules, never depends on them); 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, and orchestration commands/queries see only execution commands and queries from application. 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, 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, and orchestration commands/queries see only execution commands and queries from application. 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