@domain-first/project-structure 4.2.2 → 5.0.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 CHANGED
@@ -101,11 +101,11 @@ export class PlaceOrderUseCase {
101
101
  }
102
102
  ```
103
103
 
104
- Commands and queries come in two modes. **Execution** creates an abstract contract in `application/` and implementations in `infrastructure/`, like a repository. **Orchestrator** creates one application class that coordinates execution commands and queries (an orchestrator query, execution queries and repositories only, reading methods only). A query only reads and never changes data; any change is a command.
104
+ A command or query creates an abstract contract in `application/` and implementations in `infrastructure/`, like a repository. A query only reads and never changes data; any change is a command.
105
105
 
106
106
  ### How to switch implementations
107
107
 
108
- With `@domain-first/wire`, repositories, execution commands and queries, and ports get one factory per implementation, selected by `NODE_ENV`:
108
+ With `@domain-first/wire`, repositories, commands, queries and ports get one factory per implementation, selected by `NODE_ENV`:
109
109
 
110
110
  ```ts
111
111
  export const wireOrderRepository = envBranchedWire({
@@ -202,7 +202,7 @@ It reports what breaks the Domain-First rules: imports between bounded contexts,
202
202
 
203
203
  The rules are a default. Teams that work differently change them in the config: what each kind of module may depend on (`rules.dependencies`) and which checks run (`rules.lint`). `df-ps` offers dependencies by the same rules. Without `rules`, the defaults apply and every check runs; kinds and checks you don't mention keep their defaults.
204
204
 
205
- - Kinds in `rules.dependencies` (as keys and in lists): `repositories`, `domain-services`, `application-ports`, `application-services`, `use-cases`, `execution-commands`, `execution-queries`, `orchestration-commands`, `orchestration-queries`, `infrastructure-services`, `presentation-services`.
205
+ - Kinds in `rules.dependencies` (as keys and in lists): `repositories`, `domain-services`, `application-ports`, `application-services`, `use-cases`, `commands`, `queries`, `infrastructure-services`, `presentation-services`.
206
206
  - A kind's value: a list that replaces its defaults, or `{ "add": [...], "remove": [...] }`.
207
207
  - Checks in `rules.lint`: `context-isolation`, `shared-layer`, `layers`, `dependencies`, `react`, `clock`.
208
208
 
package/dist/201.js CHANGED
@@ -8,10 +8,8 @@ const moduleKinds = [
8
8
  'application-ports',
9
9
  'application-services',
10
10
  'use-cases',
11
- 'execution-commands',
12
- 'execution-queries',
13
- 'orchestration-commands',
14
- 'orchestration-queries',
11
+ 'commands',
12
+ 'queries',
15
13
  'infrastructure-services',
16
14
  'presentation-services'
17
15
  ];
@@ -20,10 +18,8 @@ const domain = [
20
18
  'domain-services'
21
19
  ];
22
20
  const commandsAndQueries = [
23
- 'execution-commands',
24
- 'execution-queries',
25
- 'orchestration-commands',
26
- 'orchestration-queries'
21
+ 'commands',
22
+ 'queries'
27
23
  ];
28
24
  const infrastructure = [
29
25
  ...domain,
@@ -51,16 +47,11 @@ const defaultDependencies = {
51
47
  'application-services',
52
48
  ...commandsAndQueries
53
49
  ],
54
- 'execution-commands': infrastructure,
55
- 'execution-queries': infrastructure,
56
- 'orchestration-commands': [
57
- ...domain,
58
- 'execution-commands',
59
- 'execution-queries'
50
+ commands: [
51
+ 'infrastructure-services'
60
52
  ],
61
- 'orchestration-queries': [
62
- ...domain,
63
- 'execution-queries'
53
+ queries: [
54
+ 'infrastructure-services'
64
55
  ],
65
56
  'infrastructure-services': infrastructure,
66
57
  'presentation-services': [
@@ -100,30 +91,26 @@ const resolveDependencyRules = (config = {})=>{
100
91
  };
101
92
  const defaultDependencyRules = resolveDependencyRules();
102
93
  const isModuleKind = (value)=>moduleKinds.includes(value);
103
- const wiredModuleKind = (wiringKind, typeFile)=>{
104
- const kind = 'commands' === wiringKind || 'queries' === wiringKind ? `${'execution' === node_path.basename(node_path.dirname(typeFile)) ? 'execution' : 'orchestration'}-${wiringKind}` : wiringKind;
105
- return isModuleKind(kind) ? kind : void 0;
106
- };
94
+ const wiredModuleKind = (wiringKind)=>isModuleKind(wiringKind) ? wiringKind : void 0;
107
95
  const fileModuleKind = (segments)=>{
108
- const [layer, folder, mode] = segments;
96
+ const [layer, folder] = segments;
109
97
  const file = segments.at(-1) ?? '';
110
98
  if (/^index(\.tsx?)?$/.test(file)) return;
111
99
  if ('domain' === layer) {
112
100
  if ('services' === folder) return 'domain-services';
113
101
  return 'aggregates' === folder && /-repository(\.tsx?)?$/.test(file) ? 'repositories' : void 0;
114
102
  }
115
- if ('application' === layer) {
116
- if ('commands' === folder || 'queries' === folder) return 'execution' === mode || 'orchestration' === mode ? `${mode}-${folder}` : void 0;
117
- return ({
118
- ports: 'application-ports',
119
- services: 'application-services',
120
- 'use-cases': 'use-cases'
121
- })[folder];
122
- }
103
+ if ('application' === layer) return ({
104
+ commands: 'commands',
105
+ queries: 'queries',
106
+ ports: 'application-ports',
107
+ services: 'application-services',
108
+ 'use-cases': 'use-cases'
109
+ })[folder];
123
110
  if ('infrastructure' === layer) return ({
124
111
  repositories: 'repositories',
125
- commands: 'execution-commands',
126
- queries: 'execution-queries',
112
+ commands: 'commands',
113
+ queries: 'queries',
127
114
  'application-adapters': 'application-ports',
128
115
  services: 'infrastructure-services'
129
116
  })[folder];
@@ -424,13 +411,11 @@ const branchedTypeFiles = {
424
411
  commands: (fileBase)=>[
425
412
  'application',
426
413
  'commands',
427
- 'execution',
428
414
  `${fileBase}.ts`
429
415
  ],
430
416
  queries: (fileBase)=>[
431
417
  'application',
432
418
  'queries',
433
- 'execution',
434
419
  `${fileBase}.ts`
435
420
  ],
436
421
  'application-ports': (fileBase)=>[
@@ -525,7 +510,7 @@ const findWiredModules = (contextPath)=>{
525
510
  walk(node_path.join(contextPath, 'wiring'));
526
511
  return result.sort((a, b)=>a.typeName.localeCompare(b.typeName));
527
512
  };
528
- const moduleKindOf = (module)=>wiredModuleKind(module.kind, module.typeFile);
513
+ const moduleKindOf = (module)=>wiredModuleKind(module.kind);
529
514
  const layerRule = (consumer, candidate)=>visibleLayers[consumer.implementationsLayer].includes(candidate.layer) && ('infrastructure' !== consumer.implementationsLayer || 'application' !== candidate.layer || 'application-ports' === candidate.kind);
530
515
  const implementationType = (consumer, implementation)=>consumer.branched ? node_path.basename(node_path.dirname(implementation.file)) : void 0;
531
516
  const isSuggestedFor = (candidate, implementation)=>'infrastructure' === candidate.layer && `-${node_path.basename(candidate.typeFile, '.ts')}-`.includes(`-${implementation}-`);
@@ -25,10 +25,8 @@ declare const configSchema: z.ZodObject<{
25
25
  "application-ports": "application-ports";
26
26
  "application-services": "application-services";
27
27
  "use-cases": "use-cases";
28
- "execution-commands": "execution-commands";
29
- "execution-queries": "execution-queries";
30
- "orchestration-commands": "orchestration-commands";
31
- "orchestration-queries": "orchestration-queries";
28
+ commands: "commands";
29
+ queries: "queries";
32
30
  "infrastructure-services": "infrastructure-services";
33
31
  "presentation-services": "presentation-services";
34
32
  }> & z.core.$partial, z.ZodUnion<readonly [z.ZodArray<z.ZodEnum<{
@@ -37,10 +35,8 @@ declare const configSchema: z.ZodObject<{
37
35
  "application-ports": "application-ports";
38
36
  "application-services": "application-services";
39
37
  "use-cases": "use-cases";
40
- "execution-commands": "execution-commands";
41
- "execution-queries": "execution-queries";
42
- "orchestration-commands": "orchestration-commands";
43
- "orchestration-queries": "orchestration-queries";
38
+ commands: "commands";
39
+ queries: "queries";
44
40
  "infrastructure-services": "infrastructure-services";
45
41
  "presentation-services": "presentation-services";
46
42
  }>>, z.ZodObject<{
@@ -50,10 +46,8 @@ declare const configSchema: z.ZodObject<{
50
46
  "application-ports": "application-ports";
51
47
  "application-services": "application-services";
52
48
  "use-cases": "use-cases";
53
- "execution-commands": "execution-commands";
54
- "execution-queries": "execution-queries";
55
- "orchestration-commands": "orchestration-commands";
56
- "orchestration-queries": "orchestration-queries";
49
+ commands: "commands";
50
+ queries: "queries";
57
51
  "infrastructure-services": "infrastructure-services";
58
52
  "presentation-services": "presentation-services";
59
53
  }>>>;
@@ -63,10 +57,8 @@ declare const configSchema: z.ZodObject<{
63
57
  "application-ports": "application-ports";
64
58
  "application-services": "application-services";
65
59
  "use-cases": "use-cases";
66
- "execution-commands": "execution-commands";
67
- "execution-queries": "execution-queries";
68
- "orchestration-commands": "orchestration-commands";
69
- "orchestration-queries": "orchestration-queries";
60
+ commands: "commands";
61
+ queries: "queries";
70
62
  "infrastructure-services": "infrastructure-services";
71
63
  "presentation-services": "presentation-services";
72
64
  }>>>;
@@ -1,14 +1,14 @@
1
1
  import z from 'zod';
2
2
  /**
3
3
  * Kinds of modules the dependency rules are written in: the folders
4
- * under `wiring/`, with commands and queries split by mode.
4
+ * under `wiring/`.
5
5
  */
6
- export declare const moduleKinds: readonly ["repositories", "domain-services", "application-ports", "application-services", "use-cases", "execution-commands", "execution-queries", "orchestration-commands", "orchestration-queries", "infrastructure-services", "presentation-services"];
6
+ export declare const moduleKinds: readonly ["repositories", "domain-services", "application-ports", "application-services", "use-cases", "commands", "queries", "infrastructure-services", "presentation-services"];
7
7
  export type ModuleKind = (typeof moduleKinds)[number];
8
8
  export type DependencyRules = Record<ModuleKind, ReadonlySet<ModuleKind>>;
9
9
  /**
10
- * What each kind of module may depend on. Repositories, execution
11
- * commands and queries, and ports are their implementations here.
10
+ * What each kind of module may depend on. Repositories, commands,
11
+ * queries and ports are their implementations here.
12
12
  */
13
13
  export declare const defaultDependencies: Record<ModuleKind, ModuleKind[]>;
14
14
  /**
@@ -20,10 +20,8 @@ export declare const dependencyRulesSchema: z.ZodRecord<z.ZodEnum<{
20
20
  "application-ports": "application-ports";
21
21
  "application-services": "application-services";
22
22
  "use-cases": "use-cases";
23
- "execution-commands": "execution-commands";
24
- "execution-queries": "execution-queries";
25
- "orchestration-commands": "orchestration-commands";
26
- "orchestration-queries": "orchestration-queries";
23
+ commands: "commands";
24
+ queries: "queries";
27
25
  "infrastructure-services": "infrastructure-services";
28
26
  "presentation-services": "presentation-services";
29
27
  }> & z.core.$partial, z.ZodUnion<readonly [z.ZodArray<z.ZodEnum<{
@@ -32,10 +30,8 @@ export declare const dependencyRulesSchema: z.ZodRecord<z.ZodEnum<{
32
30
  "application-ports": "application-ports";
33
31
  "application-services": "application-services";
34
32
  "use-cases": "use-cases";
35
- "execution-commands": "execution-commands";
36
- "execution-queries": "execution-queries";
37
- "orchestration-commands": "orchestration-commands";
38
- "orchestration-queries": "orchestration-queries";
33
+ commands: "commands";
34
+ queries: "queries";
39
35
  "infrastructure-services": "infrastructure-services";
40
36
  "presentation-services": "presentation-services";
41
37
  }>>, z.ZodObject<{
@@ -45,10 +41,8 @@ export declare const dependencyRulesSchema: z.ZodRecord<z.ZodEnum<{
45
41
  "application-ports": "application-ports";
46
42
  "application-services": "application-services";
47
43
  "use-cases": "use-cases";
48
- "execution-commands": "execution-commands";
49
- "execution-queries": "execution-queries";
50
- "orchestration-commands": "orchestration-commands";
51
- "orchestration-queries": "orchestration-queries";
44
+ commands: "commands";
45
+ queries: "queries";
52
46
  "infrastructure-services": "infrastructure-services";
53
47
  "presentation-services": "presentation-services";
54
48
  }>>>;
@@ -58,10 +52,8 @@ export declare const dependencyRulesSchema: z.ZodRecord<z.ZodEnum<{
58
52
  "application-ports": "application-ports";
59
53
  "application-services": "application-services";
60
54
  "use-cases": "use-cases";
61
- "execution-commands": "execution-commands";
62
- "execution-queries": "execution-queries";
63
- "orchestration-commands": "orchestration-commands";
64
- "orchestration-queries": "orchestration-queries";
55
+ commands: "commands";
56
+ queries: "queries";
65
57
  "infrastructure-services": "infrastructure-services";
66
58
  "presentation-services": "presentation-services";
67
59
  }>>>;
@@ -70,10 +62,9 @@ export type DependencyRulesConfig = z.infer<typeof dependencyRulesSchema>;
70
62
  export declare const resolveDependencyRules: (config?: DependencyRulesConfig) => DependencyRules;
71
63
  export declare const defaultDependencyRules: DependencyRules;
72
64
  /**
73
- * The kind of a wired module: its folder under `wiring/`; commands and
74
- * queries by the folder of their type, `execution/` or `orchestration/`.
65
+ * The kind of a wired module: its folder under `wiring/`.
75
66
  */
76
- export declare const wiredModuleKind: (wiringKind: string, typeFile: string) => "repositories" | "domain-services" | "application-ports" | "application-services" | "use-cases" | "execution-commands" | "execution-queries" | "orchestration-commands" | "orchestration-queries" | "infrastructure-services" | "presentation-services" | undefined;
67
+ export declare const wiredModuleKind: (wiringKind: string) => "repositories" | "domain-services" | "application-ports" | "application-services" | "use-cases" | "commands" | "queries" | "infrastructure-services" | "presentation-services" | undefined;
77
68
  /**
78
69
  * The kind of a module file, from its path inside a context or the
79
70
  * Shared Layer (`application/use-cases/…`), or undefined for other files