@domain-first/project-structure 2.11.0 → 2.12.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 +13 -2
- package/dist/file-system.d.ts +5 -0
- package/dist/index.cjs +516 -33
- package/dist/index.js +517 -34
- package/dist/use-cases/index.d.ts +1 -0
- package/dist/use-cases/wire-dependency.d.ts +17 -0
- package/dist/wiring.d.ts +90 -0
- package/dist/wiring.spec.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type File, Folder } from '../file-system';
|
|
2
|
+
import { type WiredModule } from '../wiring';
|
|
3
|
+
/**
|
|
4
|
+
* The last step of generators that create a wire.
|
|
5
|
+
*/
|
|
6
|
+
export declare const wireNewModuleDependencies: (boundedContextFolder: Folder, wireFile: File) => Promise<void>;
|
|
7
|
+
export declare const wireDependency: (boundedContextFolder: Folder) => Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* The endpoint's constructor parameters: an endpoint generator from the
|
|
10
|
+
* presentation services of the context and the Shared Layer, and a
|
|
11
|
+
* handler from the context's queries, commands, and use cases. Either is
|
|
12
|
+
* undefined when there is nothing to choose from.
|
|
13
|
+
*/
|
|
14
|
+
export declare const promptEndpointDependencies: (boundedContextFolder: Folder) => Promise<{
|
|
15
|
+
endpointGenerator: WiredModule | undefined;
|
|
16
|
+
handler: WiredModule | undefined;
|
|
17
|
+
}>;
|
package/dist/wiring.d.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export declare const layers: readonly ["domain", "application", "infrastructure", "presentation"];
|
|
2
|
+
export type Layer = (typeof layers)[number];
|
|
3
|
+
/**
|
|
4
|
+
* Layers whose modules a module of the given layer may depend on.
|
|
5
|
+
*/
|
|
6
|
+
export declare const visibleLayers: Record<Layer, Layer[]>;
|
|
7
|
+
/**
|
|
8
|
+
* A class built by a wire: the module itself, or one of the
|
|
9
|
+
* implementations of a branched wire.
|
|
10
|
+
*/
|
|
11
|
+
export type WiredClass = {
|
|
12
|
+
className: string;
|
|
13
|
+
file: string;
|
|
14
|
+
};
|
|
15
|
+
export type WiredModule = {
|
|
16
|
+
/**
|
|
17
|
+
* `wireUserRepository`.
|
|
18
|
+
*/
|
|
19
|
+
wireName: string;
|
|
20
|
+
/**
|
|
21
|
+
* `UserRepository`: what consumers declare in their constructors.
|
|
22
|
+
*/
|
|
23
|
+
typeName: string;
|
|
24
|
+
wireFile: string;
|
|
25
|
+
typeFile: string;
|
|
26
|
+
/**
|
|
27
|
+
* Layer of the type, as seen by consumers.
|
|
28
|
+
*/
|
|
29
|
+
layer: Layer;
|
|
30
|
+
implementations: WiredClass[];
|
|
31
|
+
/**
|
|
32
|
+
* An env-branched wire: each implementation is wired on its own.
|
|
33
|
+
*/
|
|
34
|
+
branched: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Layer of the implementations, which limits their dependencies.
|
|
37
|
+
*/
|
|
38
|
+
implementationsLayer: Layer;
|
|
39
|
+
/**
|
|
40
|
+
* The folder under `wiring/`: `use-cases`, `application-ports`, ….
|
|
41
|
+
*/
|
|
42
|
+
kind: string;
|
|
43
|
+
};
|
|
44
|
+
export declare const readWiredModule: (wireFile: string, contextPath: string) => WiredModule | undefined;
|
|
45
|
+
export declare const findWiredModules: (contextPath: string) => WiredModule[];
|
|
46
|
+
/**
|
|
47
|
+
* The implementation label of a branched wire's class, taken from its
|
|
48
|
+
* folder: `infrastructure/repositories/prisma/…` → `prisma`.
|
|
49
|
+
*/
|
|
50
|
+
export declare const implementationType: (consumer: WiredModule, implementation: WiredClass) => string | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* An infrastructure module whose file name has the implementation label
|
|
53
|
+
* as whole words: `in-memory-db-infrastructure-service` for `in-memory`.
|
|
54
|
+
*/
|
|
55
|
+
export declare const isSuggestedFor: (candidate: WiredModule, implementation: string) => boolean;
|
|
56
|
+
/**
|
|
57
|
+
* A likely endpoint generator: a service with `endpoint` in its name.
|
|
58
|
+
*/
|
|
59
|
+
export declare const isSuggestedEndpointGenerator: (candidate: WiredModule) => boolean;
|
|
60
|
+
export declare const canDependOn: (consumer: WiredModule, candidate: WiredModule) => boolean;
|
|
61
|
+
/**
|
|
62
|
+
* What an implementation of the consumer can depend on: modules of the
|
|
63
|
+
* visible layers, except the consumer and what this implementation
|
|
64
|
+
* already depends on.
|
|
65
|
+
*/
|
|
66
|
+
export declare const availableDependencies: (consumer: WiredModule, implementation: WiredClass, candidates: WiredModule[]) => WiredModule[];
|
|
67
|
+
/**
|
|
68
|
+
* Import path without extension, always starting with `./` or `../`.
|
|
69
|
+
*/
|
|
70
|
+
export declare const relativeImport: (fromFile: string, toFile: string) => string;
|
|
71
|
+
/**
|
|
72
|
+
* Adds the line after the last top import (multi-line ones included);
|
|
73
|
+
* does nothing if it is there.
|
|
74
|
+
*/
|
|
75
|
+
export declare const addImport: (source: string, importLine: string) => string;
|
|
76
|
+
/**
|
|
77
|
+
* Appends parameters to the class constructor, adding one if missing.
|
|
78
|
+
*/
|
|
79
|
+
export declare const addConstructorParameters: (source: string, className: string, parameters: string[]) => string;
|
|
80
|
+
export declare const wiredDependencyNames: (source: string, className: string) => string[];
|
|
81
|
+
/**
|
|
82
|
+
* Appends wires to the dependency list of `wireClass(className, [...])`,
|
|
83
|
+
* keeping the existing items as they are.
|
|
84
|
+
*/
|
|
85
|
+
export declare const addWireDependencies: (source: string, className: string, wireNames: string[]) => string;
|
|
86
|
+
/**
|
|
87
|
+
* Adds the dependencies to the implementation's wire and constructor, in
|
|
88
|
+
* the same order.
|
|
89
|
+
*/
|
|
90
|
+
export declare const wireDependencies: (consumer: WiredModule, implementation: WiredClass, dependencies: WiredModule[]) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|