@domain-first/project-structure 4.2.1 → 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 +3 -3
- package/dist/201.js +23 -36
- package/dist/config-file.d.ts +8 -16
- package/dist/dependency-rules.d.ts +14 -23
- package/dist/index.cjs +98 -260
- package/dist/index.js +85 -235
- package/dist/lint.cjs +25 -38
- package/dist/lint.js +2 -2
- package/dist/wiring.d.ts +1 -1
- package/package.json +1 -1
- package/skills/df-ps-implement/SKILL.md +8 -8
- package/skills/df-ps-plan-feature/SKILL.md +4 -4
- package/skills/df-ps-project-scripts/SKILL.md +1 -1
- package/skills/df-ps-scaffold/SKILL.md +2 -2
- package/skills/df-ps-scaffold/references/choosing-components.md +20 -21
- package/skills/df-ps-scaffold/references/generators.md +9 -14
package/README.md
CHANGED
|
@@ -101,11 +101,11 @@ export class PlaceOrderUseCase {
|
|
|
101
101
|
}
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
-
|
|
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,
|
|
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`, `
|
|
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
|
-
'
|
|
12
|
-
'
|
|
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
|
-
'
|
|
24
|
-
'
|
|
25
|
-
'orchestration-commands',
|
|
26
|
-
'orchestration-queries'
|
|
21
|
+
'commands',
|
|
22
|
+
'queries'
|
|
27
23
|
];
|
|
28
24
|
const infrastructure = [
|
|
29
25
|
...domain,
|
|
@@ -31,7 +27,9 @@ const infrastructure = [
|
|
|
31
27
|
'infrastructure-services'
|
|
32
28
|
];
|
|
33
29
|
const defaultDependencies = {
|
|
34
|
-
'domain-services':
|
|
30
|
+
'domain-services': [
|
|
31
|
+
'domain-services'
|
|
32
|
+
],
|
|
35
33
|
repositories: [
|
|
36
34
|
'domain-services',
|
|
37
35
|
'application-ports',
|
|
@@ -49,16 +47,11 @@ const defaultDependencies = {
|
|
|
49
47
|
'application-services',
|
|
50
48
|
...commandsAndQueries
|
|
51
49
|
],
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
'orchestration-commands': [
|
|
55
|
-
...domain,
|
|
56
|
-
'execution-commands',
|
|
57
|
-
'execution-queries'
|
|
50
|
+
commands: [
|
|
51
|
+
'infrastructure-services'
|
|
58
52
|
],
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
'execution-queries'
|
|
53
|
+
queries: [
|
|
54
|
+
'infrastructure-services'
|
|
62
55
|
],
|
|
63
56
|
'infrastructure-services': infrastructure,
|
|
64
57
|
'presentation-services': [
|
|
@@ -98,30 +91,26 @@ const resolveDependencyRules = (config = {})=>{
|
|
|
98
91
|
};
|
|
99
92
|
const defaultDependencyRules = resolveDependencyRules();
|
|
100
93
|
const isModuleKind = (value)=>moduleKinds.includes(value);
|
|
101
|
-
const wiredModuleKind = (wiringKind
|
|
102
|
-
const kind = 'commands' === wiringKind || 'queries' === wiringKind ? `${'execution' === node_path.basename(node_path.dirname(typeFile)) ? 'execution' : 'orchestration'}-${wiringKind}` : wiringKind;
|
|
103
|
-
return isModuleKind(kind) ? kind : void 0;
|
|
104
|
-
};
|
|
94
|
+
const wiredModuleKind = (wiringKind)=>isModuleKind(wiringKind) ? wiringKind : void 0;
|
|
105
95
|
const fileModuleKind = (segments)=>{
|
|
106
|
-
const [layer, folder
|
|
96
|
+
const [layer, folder] = segments;
|
|
107
97
|
const file = segments.at(-1) ?? '';
|
|
108
98
|
if (/^index(\.tsx?)?$/.test(file)) return;
|
|
109
99
|
if ('domain' === layer) {
|
|
110
100
|
if ('services' === folder) return 'domain-services';
|
|
111
101
|
return 'aggregates' === folder && /-repository(\.tsx?)?$/.test(file) ? 'repositories' : void 0;
|
|
112
102
|
}
|
|
113
|
-
if ('application' === layer) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
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];
|
|
121
110
|
if ('infrastructure' === layer) return ({
|
|
122
111
|
repositories: 'repositories',
|
|
123
|
-
commands: '
|
|
124
|
-
queries: '
|
|
112
|
+
commands: 'commands',
|
|
113
|
+
queries: 'queries',
|
|
125
114
|
'application-adapters': 'application-ports',
|
|
126
115
|
services: 'infrastructure-services'
|
|
127
116
|
})[folder];
|
|
@@ -422,13 +411,11 @@ const branchedTypeFiles = {
|
|
|
422
411
|
commands: (fileBase)=>[
|
|
423
412
|
'application',
|
|
424
413
|
'commands',
|
|
425
|
-
'execution',
|
|
426
414
|
`${fileBase}.ts`
|
|
427
415
|
],
|
|
428
416
|
queries: (fileBase)=>[
|
|
429
417
|
'application',
|
|
430
418
|
'queries',
|
|
431
|
-
'execution',
|
|
432
419
|
`${fileBase}.ts`
|
|
433
420
|
],
|
|
434
421
|
'application-ports': (fileBase)=>[
|
|
@@ -523,7 +510,7 @@ const findWiredModules = (contextPath)=>{
|
|
|
523
510
|
walk(node_path.join(contextPath, 'wiring'));
|
|
524
511
|
return result.sort((a, b)=>a.typeName.localeCompare(b.typeName));
|
|
525
512
|
};
|
|
526
|
-
const moduleKindOf = (module)=>wiredModuleKind(module.kind
|
|
513
|
+
const moduleKindOf = (module)=>wiredModuleKind(module.kind);
|
|
527
514
|
const layerRule = (consumer, candidate)=>visibleLayers[consumer.implementationsLayer].includes(candidate.layer) && ('infrastructure' !== consumer.implementationsLayer || 'application' !== candidate.layer || 'application-ports' === candidate.kind);
|
|
528
515
|
const implementationType = (consumer, implementation)=>consumer.branched ? node_path.basename(node_path.dirname(implementation.file)) : void 0;
|
|
529
516
|
const isSuggestedFor = (candidate, implementation)=>'infrastructure' === candidate.layer && `-${node_path.basename(candidate.typeFile, '.ts')}-`.includes(`-${implementation}-`);
|
package/dist/config-file.d.ts
CHANGED
|
@@ -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
|
-
|
|
29
|
-
|
|
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
|
-
|
|
41
|
-
|
|
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
|
-
|
|
54
|
-
|
|
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
|
-
|
|
67
|
-
|
|
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
|
|
4
|
+
* under `wiring/`.
|
|
5
5
|
*/
|
|
6
|
-
export declare const moduleKinds: readonly ["repositories", "domain-services", "application-ports", "application-services", "use-cases", "
|
|
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,
|
|
11
|
-
*
|
|
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
|
-
|
|
24
|
-
|
|
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
|
-
|
|
36
|
-
|
|
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
|
-
|
|
49
|
-
|
|
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
|
-
|
|
62
|
-
|
|
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
|
|
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
|
|
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
|