@domain-first/project-structure 4.1.0 → 4.2.1
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 +21 -19
- package/dist/{533.js → 201.js} +149 -18
- package/dist/config-file.d.ts +71 -0
- package/dist/dependency-rules.d.ts +82 -0
- package/dist/dependency-rules.spec.d.ts +1 -0
- package/dist/index.cjs +125 -37
- package/dist/index.js +3 -21
- package/dist/lint.cjs +183 -41
- package/dist/lint.js +39 -28
- package/dist/project-lint.d.ts +14 -1
- package/dist/wiring.d.ts +10 -5
- package/package.json +1 -1
- package/skills/df-ps-implement/SKILL.md +4 -4
- package/skills/df-ps-scaffold/SKILL.md +2 -2
- package/skills/df-ps-scaffold/references/choosing-components.md +4 -3
- package/skills/df-ps-scaffold/references/generators.md +1 -1
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ Spend less time setting up files. Spend more time building your domain.
|
|
|
13
13
|
|
|
14
14
|
In most TypeScript codebases you choose between convenience and architecture. Clear boundaries and roles around the domain mean more files, more contracts and more wiring, so under deadline pressure the logic ends up wherever it is quickest to write it. The boundaries blur one shortcut at a time.
|
|
15
15
|
|
|
16
|
-
Domain First Project Structure removes that choice: **the cleanest path is also the shortest one**. An interactive CLI asks which bounded context, layer and role a new piece of code has, and generates it in its place, with contracts, implementations, test skeletons and wiring that respect the boundaries. Dependencies are offered only where the
|
|
16
|
+
Domain First Project Structure removes that choice: **the cleanest path is also the shortest one**. An interactive CLI asks which bounded context, layer and role a new piece of code has, and generates it in its place, with contracts, implementations, test skeletons and wiring that respect the boundaries. Dependencies are offered only where the dependency rules allow them. Doing it right takes a few prompts; doing it wrong takes extra effort. It knows the `@domain-first` packages: types, errors, handlers, wire and handlers-rest. The generated files belong to your project; you write the business rules.
|
|
17
17
|
|
|
18
18
|
```
|
|
19
19
|
npm i -D @domain-first/project-structure
|
|
@@ -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:
|
|
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).
|
|
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
|
|
|
@@ -213,7 +198,24 @@ Choose **Add integration** to configure Storybook, Prisma 8, Vitest, Playwright,
|
|
|
213
198
|
npx df-lint
|
|
214
199
|
```
|
|
215
200
|
|
|
216
|
-
It reports what breaks the Domain-First rules: imports between bounded contexts, imports against the layers,
|
|
201
|
+
It reports what breaks the Domain-First rules: imports between bounded contexts, imports against the layers, modules using kinds the dependency rules don't allow (in imports and in wiring), React modules importing what they shouldn't, and reading the time without the clock port. It exits with 1 when something is found, so you can run it in CI.
|
|
202
|
+
|
|
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
|
+
|
|
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`.
|
|
206
|
+
- A kind's value: a list that replaces its defaults, or `{ "add": [...], "remove": [...] }`.
|
|
207
|
+
- Checks in `rules.lint`: `context-isolation`, `shared-layer`, `layers`, `dependencies`, `react`, `clock`.
|
|
208
|
+
|
|
209
|
+
Defaults and details: [Dependency rules](API.md#dependency-rules), [`df-lint`](API.md#df-lint).
|
|
210
|
+
|
|
211
|
+
```json
|
|
212
|
+
{
|
|
213
|
+
"rules": {
|
|
214
|
+
"dependencies": { "use-cases": { "add": ["use-cases"] } },
|
|
215
|
+
"lint": { "clock": false }
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
```
|
|
217
219
|
|
|
218
220
|
### How to teach your coding agent
|
|
219
221
|
|
package/dist/{533.js → 201.js}
RENAMED
|
@@ -2,6 +2,131 @@ import node_path from "node:path";
|
|
|
2
2
|
import zod from "zod";
|
|
3
3
|
import node_fs from "node:fs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
|
+
const moduleKinds = [
|
|
6
|
+
'repositories',
|
|
7
|
+
'domain-services',
|
|
8
|
+
'application-ports',
|
|
9
|
+
'application-services',
|
|
10
|
+
'use-cases',
|
|
11
|
+
'execution-commands',
|
|
12
|
+
'execution-queries',
|
|
13
|
+
'orchestration-commands',
|
|
14
|
+
'orchestration-queries',
|
|
15
|
+
'infrastructure-services',
|
|
16
|
+
'presentation-services'
|
|
17
|
+
];
|
|
18
|
+
const domain = [
|
|
19
|
+
'repositories',
|
|
20
|
+
'domain-services'
|
|
21
|
+
];
|
|
22
|
+
const commandsAndQueries = [
|
|
23
|
+
'execution-commands',
|
|
24
|
+
'execution-queries',
|
|
25
|
+
'orchestration-commands',
|
|
26
|
+
'orchestration-queries'
|
|
27
|
+
];
|
|
28
|
+
const infrastructure = [
|
|
29
|
+
...domain,
|
|
30
|
+
'application-ports',
|
|
31
|
+
'infrastructure-services'
|
|
32
|
+
];
|
|
33
|
+
const defaultDependencies = {
|
|
34
|
+
'domain-services': domain,
|
|
35
|
+
repositories: [
|
|
36
|
+
'domain-services',
|
|
37
|
+
'application-ports',
|
|
38
|
+
'infrastructure-services'
|
|
39
|
+
],
|
|
40
|
+
'application-ports': infrastructure,
|
|
41
|
+
'application-services': [
|
|
42
|
+
...domain,
|
|
43
|
+
'application-ports',
|
|
44
|
+
...commandsAndQueries
|
|
45
|
+
],
|
|
46
|
+
'use-cases': [
|
|
47
|
+
...domain,
|
|
48
|
+
'application-ports',
|
|
49
|
+
'application-services',
|
|
50
|
+
...commandsAndQueries
|
|
51
|
+
],
|
|
52
|
+
'execution-commands': infrastructure,
|
|
53
|
+
'execution-queries': infrastructure,
|
|
54
|
+
'orchestration-commands': [
|
|
55
|
+
...domain,
|
|
56
|
+
'execution-commands',
|
|
57
|
+
'execution-queries'
|
|
58
|
+
],
|
|
59
|
+
'orchestration-queries': [
|
|
60
|
+
...domain,
|
|
61
|
+
'execution-queries'
|
|
62
|
+
],
|
|
63
|
+
'infrastructure-services': infrastructure,
|
|
64
|
+
'presentation-services': [
|
|
65
|
+
'application-ports',
|
|
66
|
+
'application-services',
|
|
67
|
+
'use-cases',
|
|
68
|
+
...commandsAndQueries,
|
|
69
|
+
'presentation-services'
|
|
70
|
+
]
|
|
71
|
+
};
|
|
72
|
+
const kindSchema = zod["enum"](moduleKinds);
|
|
73
|
+
const dependencyRulesSchema = zod.partialRecord(kindSchema, zod.union([
|
|
74
|
+
zod.array(kindSchema),
|
|
75
|
+
zod.object({
|
|
76
|
+
add: zod.array(kindSchema).optional(),
|
|
77
|
+
remove: zod.array(kindSchema).optional()
|
|
78
|
+
})
|
|
79
|
+
]));
|
|
80
|
+
const resolveDependencyRules = (config = {})=>{
|
|
81
|
+
const entries = moduleKinds.map((kind)=>{
|
|
82
|
+
const override = config[kind];
|
|
83
|
+
if (Array.isArray(override)) return [
|
|
84
|
+
kind,
|
|
85
|
+
new Set(override)
|
|
86
|
+
];
|
|
87
|
+
const kinds = new Set([
|
|
88
|
+
...defaultDependencies[kind],
|
|
89
|
+
...override?.add ?? []
|
|
90
|
+
]);
|
|
91
|
+
for (const removed of override?.remove ?? [])kinds.delete(removed);
|
|
92
|
+
return [
|
|
93
|
+
kind,
|
|
94
|
+
kinds
|
|
95
|
+
];
|
|
96
|
+
});
|
|
97
|
+
return Object.fromEntries(entries);
|
|
98
|
+
};
|
|
99
|
+
const defaultDependencyRules = resolveDependencyRules();
|
|
100
|
+
const isModuleKind = (value)=>moduleKinds.includes(value);
|
|
101
|
+
const wiredModuleKind = (wiringKind, typeFile)=>{
|
|
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
|
+
};
|
|
105
|
+
const fileModuleKind = (segments)=>{
|
|
106
|
+
const [layer, folder, mode] = segments;
|
|
107
|
+
const file = segments.at(-1) ?? '';
|
|
108
|
+
if (/^index(\.tsx?)?$/.test(file)) return;
|
|
109
|
+
if ('domain' === layer) {
|
|
110
|
+
if ('services' === folder) return 'domain-services';
|
|
111
|
+
return 'aggregates' === folder && /-repository(\.tsx?)?$/.test(file) ? 'repositories' : void 0;
|
|
112
|
+
}
|
|
113
|
+
if ('application' === layer) {
|
|
114
|
+
if ('commands' === folder || 'queries' === folder) return 'execution' === mode || 'orchestration' === mode ? `${mode}-${folder}` : void 0;
|
|
115
|
+
return ({
|
|
116
|
+
ports: 'application-ports',
|
|
117
|
+
services: 'application-services',
|
|
118
|
+
'use-cases': 'use-cases'
|
|
119
|
+
})[folder];
|
|
120
|
+
}
|
|
121
|
+
if ('infrastructure' === layer) return ({
|
|
122
|
+
repositories: 'repositories',
|
|
123
|
+
commands: 'execution-commands',
|
|
124
|
+
queries: 'execution-queries',
|
|
125
|
+
'application-adapters': 'application-ports',
|
|
126
|
+
services: 'infrastructure-services'
|
|
127
|
+
})[folder];
|
|
128
|
+
return 'presentation' === layer && 'services' === folder ? 'presentation-services' : void 0;
|
|
129
|
+
};
|
|
5
130
|
const pendingFiles = new Map();
|
|
6
131
|
const pendingFolders = new Set();
|
|
7
132
|
const pendingMoves = new Map();
|
|
@@ -151,6 +276,14 @@ class ProjectRoot {
|
|
|
151
276
|
throw new Error('No package.json was found');
|
|
152
277
|
}
|
|
153
278
|
}
|
|
279
|
+
const lintChecks = [
|
|
280
|
+
'context-isolation',
|
|
281
|
+
'shared-layer',
|
|
282
|
+
'layers',
|
|
283
|
+
'dependencies',
|
|
284
|
+
'react',
|
|
285
|
+
'clock'
|
|
286
|
+
];
|
|
154
287
|
const configFileName = 'domain-first.project-structure.config.json';
|
|
155
288
|
const configSchema = zod.object({
|
|
156
289
|
rootFolder: zod.string(),
|
|
@@ -165,7 +298,11 @@ const configSchema = zod.object({
|
|
|
165
298
|
withInMemoryDb: zod.boolean().optional(),
|
|
166
299
|
useReact: zod.boolean(),
|
|
167
300
|
storybookFramework: zod.string().optional(),
|
|
168
|
-
testingLibrary: zod.string().optional()
|
|
301
|
+
testingLibrary: zod.string().optional(),
|
|
302
|
+
rules: zod.object({
|
|
303
|
+
dependencies: dependencyRulesSchema.optional(),
|
|
304
|
+
lint: zod.partialRecord(zod["enum"](lintChecks), zod.boolean()).optional()
|
|
305
|
+
}).optional()
|
|
169
306
|
});
|
|
170
307
|
class ConfigFile {
|
|
171
308
|
data;
|
|
@@ -189,6 +326,7 @@ class ConfigFile {
|
|
|
189
326
|
new File(ConfigFile.path).data = JSON.stringify(config, null, '\t');
|
|
190
327
|
};
|
|
191
328
|
}
|
|
329
|
+
const configuredDependencyRules = ()=>resolveDependencyRules(ConfigFile.exists ? ConfigFile.Instance.data.rules?.dependencies : void 0);
|
|
192
330
|
const stripJsonComments = (source)=>source.replace(/("(?:\\.|[^"\\])*")|\/\/[^\n]*|\/\*[\s\S]*?\*\//g, (_, text)=>text ? text : '').replace(/,(\s*[}\]])/g, '$1');
|
|
193
331
|
const resolveExtends = (fromFile, target)=>{
|
|
194
332
|
if (target.startsWith('.') || node_path.isAbsolute(target)) {
|
|
@@ -385,25 +523,18 @@ const findWiredModules = (contextPath)=>{
|
|
|
385
523
|
walk(node_path.join(contextPath, 'wiring'));
|
|
386
524
|
return result.sort((a, b)=>a.typeName.localeCompare(b.typeName));
|
|
387
525
|
};
|
|
388
|
-
const
|
|
389
|
-
const
|
|
390
|
-
const commandOrQueryRule = (candidate, consumer)=>isExecution(consumer) ? !isCommandOrQuery(candidate) : 'application' !== candidate.layer || isExecution(candidate) && ('commands' === consumer.kind || 'queries' === candidate.kind);
|
|
391
|
-
const layerRules = {
|
|
392
|
-
infrastructure: (candidate)=>'application' !== candidate.layer || 'application-ports' === candidate.kind
|
|
393
|
-
};
|
|
394
|
-
const kindRules = {
|
|
395
|
-
'application-services': (candidate)=>'application' !== candidate.layer || 'application-ports' === candidate.kind,
|
|
396
|
-
'use-cases': (candidate)=>'use-cases' !== candidate.kind,
|
|
397
|
-
repositories: (candidate)=>'repositories' !== candidate.kind,
|
|
398
|
-
commands: commandOrQueryRule,
|
|
399
|
-
queries: commandOrQueryRule
|
|
400
|
-
};
|
|
526
|
+
const moduleKindOf = (module)=>wiredModuleKind(module.kind, module.typeFile);
|
|
527
|
+
const layerRule = (consumer, candidate)=>visibleLayers[consumer.implementationsLayer].includes(candidate.layer) && ('infrastructure' !== consumer.implementationsLayer || 'application' !== candidate.layer || 'application-ports' === candidate.kind);
|
|
401
528
|
const implementationType = (consumer, implementation)=>consumer.branched ? node_path.basename(node_path.dirname(implementation.file)) : void 0;
|
|
402
529
|
const isSuggestedFor = (candidate, implementation)=>'infrastructure' === candidate.layer && `-${node_path.basename(candidate.typeFile, '.ts')}-`.includes(`-${implementation}-`);
|
|
403
|
-
const canDependOn = (consumer, candidate
|
|
404
|
-
const
|
|
530
|
+
const canDependOn = (consumer, candidate, rules = defaultDependencyRules)=>{
|
|
531
|
+
const consumerKind = moduleKindOf(consumer);
|
|
532
|
+
const candidateKind = moduleKindOf(candidate);
|
|
533
|
+
return consumerKind && candidateKind ? rules[consumerKind].has(candidateKind) : layerRule(consumer, candidate);
|
|
534
|
+
};
|
|
535
|
+
const availableDependencies = (consumer, implementation, candidates, rules = configuredDependencyRules())=>{
|
|
405
536
|
const wired = wiredDependencyNames(new File(consumer.wireFile).data, implementation.className);
|
|
406
|
-
return candidates.filter((candidate)=>candidate.wireFile !== consumer.wireFile && canDependOn(consumer, candidate) && !wired.includes(candidate.wireName));
|
|
537
|
+
return candidates.filter((candidate)=>candidate.wireFile !== consumer.wireFile && canDependOn(consumer, candidate, rules) && !wired.includes(candidate.wireName));
|
|
407
538
|
};
|
|
408
539
|
const relativeImport = (fromFile, toFile)=>{
|
|
409
540
|
const relativePath = node_path.relative(node_path.dirname(fromFile), toFile).replace(/\.ts$/, '').split(node_path.sep).join('/');
|
|
@@ -566,4 +697,4 @@ const wireDependencies = (consumer, implementation, dependencies)=>{
|
|
|
566
697
|
for (const dependency of dependencies)classSource = addImport(classSource, `import type { ${dependency.typeName} } from '${relativeImport(implementation.file, dependency.typeFile)}'`);
|
|
567
698
|
classFile.update(addConstructorParameters(classSource, implementation.className, dependencies.map((x)=>`private readonly ${parameterName(x.typeName)}: ${x.typeName}`)));
|
|
568
699
|
};
|
|
569
|
-
export { ConfigFile, File, Folder, ProjectRoot, UnknownFormatNaming, addClassMember, addConstructorParameters, addImport, addWireDependencies, availableDependencies, canDependOn, compilerOption, discardPendingChanges, filesToOverwrite, findWiredModules, implementationType, isSuggestedFor, readWiredModule, relativeImport, stripJsonComments, wireDependencies, wiredDependencyNames, writePendingChanges };
|
|
700
|
+
export { ConfigFile, File, Folder, ProjectRoot, UnknownFormatNaming, addClassMember, addConstructorParameters, addImport, addWireDependencies, availableDependencies, canDependOn, compilerOption, configuredDependencyRules, defaultDependencyRules, discardPendingChanges, fileModuleKind, filesToOverwrite, findWiredModules, implementationType, isSuggestedFor, moduleKindOf, readWiredModule, relativeImport, stripJsonComments, wireDependencies, wiredDependencyNames, writePendingChanges };
|
package/dist/config-file.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* `df-lint` checks that `rules.lint` can turn off.
|
|
4
|
+
*/
|
|
5
|
+
export declare const lintChecks: readonly ["context-isolation", "shared-layer", "layers", "dependencies", "react", "clock"];
|
|
6
|
+
export type LintCheck = (typeof lintChecks)[number];
|
|
2
7
|
declare const configSchema: z.ZodObject<{
|
|
3
8
|
rootFolder: z.ZodString;
|
|
4
9
|
domainFirstPackages: z.ZodArray<z.ZodEnum<{
|
|
@@ -13,6 +18,68 @@ declare const configSchema: z.ZodObject<{
|
|
|
13
18
|
useReact: z.ZodBoolean;
|
|
14
19
|
storybookFramework: z.ZodOptional<z.ZodString>;
|
|
15
20
|
testingLibrary: z.ZodOptional<z.ZodString>;
|
|
21
|
+
rules: z.ZodOptional<z.ZodObject<{
|
|
22
|
+
dependencies: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
|
|
23
|
+
repositories: "repositories";
|
|
24
|
+
"domain-services": "domain-services";
|
|
25
|
+
"application-ports": "application-ports";
|
|
26
|
+
"application-services": "application-services";
|
|
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";
|
|
32
|
+
"infrastructure-services": "infrastructure-services";
|
|
33
|
+
"presentation-services": "presentation-services";
|
|
34
|
+
}> & z.core.$partial, z.ZodUnion<readonly [z.ZodArray<z.ZodEnum<{
|
|
35
|
+
repositories: "repositories";
|
|
36
|
+
"domain-services": "domain-services";
|
|
37
|
+
"application-ports": "application-ports";
|
|
38
|
+
"application-services": "application-services";
|
|
39
|
+
"use-cases": "use-cases";
|
|
40
|
+
"execution-commands": "execution-commands";
|
|
41
|
+
"execution-queries": "execution-queries";
|
|
42
|
+
"orchestration-commands": "orchestration-commands";
|
|
43
|
+
"orchestration-queries": "orchestration-queries";
|
|
44
|
+
"infrastructure-services": "infrastructure-services";
|
|
45
|
+
"presentation-services": "presentation-services";
|
|
46
|
+
}>>, z.ZodObject<{
|
|
47
|
+
add: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
48
|
+
repositories: "repositories";
|
|
49
|
+
"domain-services": "domain-services";
|
|
50
|
+
"application-ports": "application-ports";
|
|
51
|
+
"application-services": "application-services";
|
|
52
|
+
"use-cases": "use-cases";
|
|
53
|
+
"execution-commands": "execution-commands";
|
|
54
|
+
"execution-queries": "execution-queries";
|
|
55
|
+
"orchestration-commands": "orchestration-commands";
|
|
56
|
+
"orchestration-queries": "orchestration-queries";
|
|
57
|
+
"infrastructure-services": "infrastructure-services";
|
|
58
|
+
"presentation-services": "presentation-services";
|
|
59
|
+
}>>>;
|
|
60
|
+
remove: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
61
|
+
repositories: "repositories";
|
|
62
|
+
"domain-services": "domain-services";
|
|
63
|
+
"application-ports": "application-ports";
|
|
64
|
+
"application-services": "application-services";
|
|
65
|
+
"use-cases": "use-cases";
|
|
66
|
+
"execution-commands": "execution-commands";
|
|
67
|
+
"execution-queries": "execution-queries";
|
|
68
|
+
"orchestration-commands": "orchestration-commands";
|
|
69
|
+
"orchestration-queries": "orchestration-queries";
|
|
70
|
+
"infrastructure-services": "infrastructure-services";
|
|
71
|
+
"presentation-services": "presentation-services";
|
|
72
|
+
}>>>;
|
|
73
|
+
}, z.core.$strip>]>>>;
|
|
74
|
+
lint: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
|
|
75
|
+
"context-isolation": "context-isolation";
|
|
76
|
+
"shared-layer": "shared-layer";
|
|
77
|
+
layers: "layers";
|
|
78
|
+
dependencies: "dependencies";
|
|
79
|
+
react: "react";
|
|
80
|
+
clock: "clock";
|
|
81
|
+
}> & z.core.$partial, z.ZodBoolean>>;
|
|
82
|
+
}, z.core.$strip>>;
|
|
16
83
|
}, z.core.$strip>;
|
|
17
84
|
export declare class ConfigFile {
|
|
18
85
|
readonly data: z.infer<typeof configSchema>;
|
|
@@ -22,4 +89,8 @@ export declare class ConfigFile {
|
|
|
22
89
|
static get exists(): boolean;
|
|
23
90
|
static write: (config: z.infer<typeof configSchema>) => void;
|
|
24
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* The dependency rules: the defaults with the config's `rules.dependencies`.
|
|
94
|
+
*/
|
|
95
|
+
export declare const configuredDependencyRules: () => import("./dependency-rules").DependencyRules;
|
|
25
96
|
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Kinds of modules the dependency rules are written in: the folders
|
|
4
|
+
* under `wiring/`, with commands and queries split by mode.
|
|
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"];
|
|
7
|
+
export type ModuleKind = (typeof moduleKinds)[number];
|
|
8
|
+
export type DependencyRules = Record<ModuleKind, ReadonlySet<ModuleKind>>;
|
|
9
|
+
/**
|
|
10
|
+
* What each kind of module may depend on. Repositories, execution
|
|
11
|
+
* commands and queries, and ports are their implementations here.
|
|
12
|
+
*/
|
|
13
|
+
export declare const defaultDependencies: Record<ModuleKind, ModuleKind[]>;
|
|
14
|
+
/**
|
|
15
|
+
* A list replaces the default one; `add` and `remove` change it.
|
|
16
|
+
*/
|
|
17
|
+
export declare const dependencyRulesSchema: z.ZodRecord<z.ZodEnum<{
|
|
18
|
+
repositories: "repositories";
|
|
19
|
+
"domain-services": "domain-services";
|
|
20
|
+
"application-ports": "application-ports";
|
|
21
|
+
"application-services": "application-services";
|
|
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";
|
|
27
|
+
"infrastructure-services": "infrastructure-services";
|
|
28
|
+
"presentation-services": "presentation-services";
|
|
29
|
+
}> & z.core.$partial, z.ZodUnion<readonly [z.ZodArray<z.ZodEnum<{
|
|
30
|
+
repositories: "repositories";
|
|
31
|
+
"domain-services": "domain-services";
|
|
32
|
+
"application-ports": "application-ports";
|
|
33
|
+
"application-services": "application-services";
|
|
34
|
+
"use-cases": "use-cases";
|
|
35
|
+
"execution-commands": "execution-commands";
|
|
36
|
+
"execution-queries": "execution-queries";
|
|
37
|
+
"orchestration-commands": "orchestration-commands";
|
|
38
|
+
"orchestration-queries": "orchestration-queries";
|
|
39
|
+
"infrastructure-services": "infrastructure-services";
|
|
40
|
+
"presentation-services": "presentation-services";
|
|
41
|
+
}>>, z.ZodObject<{
|
|
42
|
+
add: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
43
|
+
repositories: "repositories";
|
|
44
|
+
"domain-services": "domain-services";
|
|
45
|
+
"application-ports": "application-ports";
|
|
46
|
+
"application-services": "application-services";
|
|
47
|
+
"use-cases": "use-cases";
|
|
48
|
+
"execution-commands": "execution-commands";
|
|
49
|
+
"execution-queries": "execution-queries";
|
|
50
|
+
"orchestration-commands": "orchestration-commands";
|
|
51
|
+
"orchestration-queries": "orchestration-queries";
|
|
52
|
+
"infrastructure-services": "infrastructure-services";
|
|
53
|
+
"presentation-services": "presentation-services";
|
|
54
|
+
}>>>;
|
|
55
|
+
remove: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
56
|
+
repositories: "repositories";
|
|
57
|
+
"domain-services": "domain-services";
|
|
58
|
+
"application-ports": "application-ports";
|
|
59
|
+
"application-services": "application-services";
|
|
60
|
+
"use-cases": "use-cases";
|
|
61
|
+
"execution-commands": "execution-commands";
|
|
62
|
+
"execution-queries": "execution-queries";
|
|
63
|
+
"orchestration-commands": "orchestration-commands";
|
|
64
|
+
"orchestration-queries": "orchestration-queries";
|
|
65
|
+
"infrastructure-services": "infrastructure-services";
|
|
66
|
+
"presentation-services": "presentation-services";
|
|
67
|
+
}>>>;
|
|
68
|
+
}, z.core.$strip>]>>;
|
|
69
|
+
export type DependencyRulesConfig = z.infer<typeof dependencyRulesSchema>;
|
|
70
|
+
export declare const resolveDependencyRules: (config?: DependencyRulesConfig) => DependencyRules;
|
|
71
|
+
export declare const defaultDependencyRules: DependencyRules;
|
|
72
|
+
/**
|
|
73
|
+
* The kind of a wired module: its folder under `wiring/`; commands and
|
|
74
|
+
* queries by the folder of their type, `execution/` or `orchestration/`.
|
|
75
|
+
*/
|
|
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;
|
|
77
|
+
/**
|
|
78
|
+
* The kind of a module file, from its path inside a context or the
|
|
79
|
+
* Shared Layer (`application/use-cases/…`), or undefined for other files
|
|
80
|
+
* such as entities, value objects and errors.
|
|
81
|
+
*/
|
|
82
|
+
export declare const fileModuleKind: (segments: string[]) => ModuleKind | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|