@domain-first/project-structure 8.9.2 → 8.10.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/dist/115.js +33 -2
- package/dist/201.js +114 -38
- package/dist/287.js +65 -72
- package/dist/38.js +15 -13
- package/dist/561.js +7 -7
- package/dist/bounded-contexts.d.ts +33 -0
- package/dist/bounded-contexts.spec.d.ts +1 -0
- package/dist/context-dependencies.d.ts +14 -3
- package/dist/graph.cjs +34 -6
- package/dist/graph.js +3 -5
- package/dist/index.cjs +217 -145
- package/dist/index.js +4 -6
- package/dist/integration.cjs +213 -138
- package/dist/integrations/openapi-extractor.d.ts +11 -3
- package/dist/lint.cjs +57 -17
- package/dist/react.cjs +213 -138
- package/dist/upgrade-rest-root.d.ts +5 -0
- package/dist/upgrade.cjs +106 -9
- package/dist/upgrade.js +25 -8
- package/dist/use-cases/move-backend-unit.d.ts +1 -1
- package/dist/use-cases/scaffold-new-bounded-context.d.ts +4 -0
- package/dist/use-cases/scaffold-new-handlers-rest-endpoint.d.ts +1 -1
- package/dist/wire-branches.d.ts +5 -0
- package/package.json +1 -1
- package/skills/df-ps-scaffold/references/agent-operations.md +2 -2
package/dist/index.cjs
CHANGED
|
@@ -26,31 +26,134 @@ var __webpack_require__ = {};
|
|
|
26
26
|
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
27
27
|
})();
|
|
28
28
|
var __webpack_exports__ = {};
|
|
29
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
30
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
29
31
|
const prompts_namespaceObject = require("@inquirer/prompts");
|
|
30
32
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
31
33
|
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
32
|
-
const external_node_path_namespaceObject = require("node:path");
|
|
33
|
-
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
34
34
|
const external_node_util_namespaceObject = require("node:util");
|
|
35
35
|
const external_zod_namespaceObject = require("zod");
|
|
36
36
|
var external_zod_default = /*#__PURE__*/ __webpack_require__.n(external_zod_namespaceObject);
|
|
37
|
+
class UnknownFormatNaming {
|
|
38
|
+
rawSource;
|
|
39
|
+
camelCase;
|
|
40
|
+
PascalCase;
|
|
41
|
+
constructor(rawSource){
|
|
42
|
+
this.rawSource = rawSource;
|
|
43
|
+
const source = rawSource.trim();
|
|
44
|
+
if (!source.includes('-')) {
|
|
45
|
+
this.camelCase = source.substring(0, 1).toLowerCase() + source.substring(1);
|
|
46
|
+
this.PascalCase = source.substring(0, 1).toUpperCase() + source.substring(1);
|
|
47
|
+
}
|
|
48
|
+
const words = source.split('-').filter((word)=>!!word);
|
|
49
|
+
this.camelCase = words.map((word, index)=>0 === index ? word.toLowerCase() : word[0].toUpperCase() + word.slice(1).toLowerCase()).join('');
|
|
50
|
+
this.PascalCase = words.map((word)=>word[0].toUpperCase() + word.slice(1).toLowerCase()).join('');
|
|
51
|
+
}
|
|
52
|
+
get fileName() {
|
|
53
|
+
return this.rawSource;
|
|
54
|
+
}
|
|
55
|
+
get variableName() {
|
|
56
|
+
return this.camelCase;
|
|
57
|
+
}
|
|
58
|
+
get ClassName() {
|
|
59
|
+
return this.PascalCase;
|
|
60
|
+
}
|
|
61
|
+
get withSpaces() {
|
|
62
|
+
return this.fileName.replaceAll('-', ' ');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const splitSegments = (rawSource)=>rawSource.split(/[\\/]/).map((segment)=>segment.trim()).filter((segment)=>!!segment);
|
|
66
|
+
class NestedName {
|
|
67
|
+
folders;
|
|
68
|
+
folderName;
|
|
69
|
+
fileName;
|
|
70
|
+
ClassName;
|
|
71
|
+
classNameSegments;
|
|
72
|
+
constructor(rawSource){
|
|
73
|
+
const segments = splitSegments(rawSource);
|
|
74
|
+
this.folders = segments.slice(0, -1);
|
|
75
|
+
this.folderName = new UnknownFormatNaming(segments.at(-1) ?? '').fileName;
|
|
76
|
+
this.fileName = segments.map((segment)=>new UnknownFormatNaming(segment).fileName).join('-');
|
|
77
|
+
this.classNameSegments = segments.map((segment)=>new UnknownFormatNaming(segment).ClassName);
|
|
78
|
+
this.ClassName = this.classNameSegments.join('');
|
|
79
|
+
}
|
|
80
|
+
static validate = (rawSource)=>{
|
|
81
|
+
const segments = splitSegments(rawSource);
|
|
82
|
+
if (!segments.length) return 'Name is required';
|
|
83
|
+
if (segments.some((segment)=>'.' === segment || '..' === segment)) return 'Use a path relative to the folder, without "." or ".."';
|
|
84
|
+
return true;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const boundedContextsFolderName = 'bounded-contexts';
|
|
88
|
+
const contextLayerFolders = [
|
|
89
|
+
'domain',
|
|
90
|
+
'application',
|
|
91
|
+
'infrastructure',
|
|
92
|
+
'presentation',
|
|
93
|
+
'wiring'
|
|
94
|
+
];
|
|
95
|
+
const subfolders = (folder)=>external_node_fs_default().existsSync(folder) ? external_node_fs_default().readdirSync(folder, {
|
|
96
|
+
withFileTypes: true
|
|
97
|
+
}).filter((entry)=>entry.isDirectory()).map((entry)=>entry.name) : [];
|
|
98
|
+
const isBoundedContextFolder = (folder)=>{
|
|
99
|
+
const names = subfolders(folder);
|
|
100
|
+
return !names.length || names.some((name)=>contextLayerFolders.includes(name));
|
|
101
|
+
};
|
|
102
|
+
const boundedContextNames = (contextsFolder)=>{
|
|
103
|
+
const walk = (folder, prefix)=>subfolders(folder).flatMap((name)=>{
|
|
104
|
+
const child = external_node_path_default().join(folder, name);
|
|
105
|
+
return isBoundedContextFolder(child) ? [
|
|
106
|
+
[
|
|
107
|
+
...prefix,
|
|
108
|
+
name
|
|
109
|
+
].join('/')
|
|
110
|
+
] : walk(child, [
|
|
111
|
+
...prefix,
|
|
112
|
+
name
|
|
113
|
+
]);
|
|
114
|
+
});
|
|
115
|
+
return walk(contextsFolder, []).sort();
|
|
116
|
+
};
|
|
117
|
+
const contextClassName = (name)=>new NestedName(name).ClassName;
|
|
118
|
+
const splitContextSegments = (segments)=>{
|
|
119
|
+
const layer = segments.findIndex((segment)=>contextLayerFolders.includes(segment));
|
|
120
|
+
const length = layer > 0 ? layer : 1;
|
|
121
|
+
return {
|
|
122
|
+
name: segments.slice(0, length).join('/'),
|
|
123
|
+
segments: segments.slice(length)
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
const validateBoundedContextName = (contextsFolder, name)=>{
|
|
127
|
+
const valid = NestedName.validate(name);
|
|
128
|
+
if (true !== valid) return valid;
|
|
129
|
+
const segments = name.split(/[\\/]/).map((segment)=>segment.trim()).filter((segment)=>!!segment);
|
|
130
|
+
const reserved = segments.find((segment)=>contextLayerFolders.includes(segment));
|
|
131
|
+
if (reserved) return `"${reserved}" is a layer folder of a bounded context and can't name one`;
|
|
132
|
+
for(let index = 1; index < segments.length; index++){
|
|
133
|
+
const parent = external_node_path_default().join(contextsFolder, ...segments.slice(0, index));
|
|
134
|
+
if (external_node_fs_default().existsSync(parent) && isBoundedContextFolder(parent)) return `${segments.slice(0, index).join('/')} is a bounded context: contexts can't be nested in one`;
|
|
135
|
+
}
|
|
136
|
+
const folder = external_node_path_default().join(contextsFolder, ...segments);
|
|
137
|
+
if (external_node_fs_default().existsSync(folder) && !isBoundedContextFolder(folder)) return `${segments.join('/')} groups bounded contexts: pick a name inside it`;
|
|
138
|
+
return true;
|
|
139
|
+
};
|
|
37
140
|
const crossContextImplementation = 'cross-context';
|
|
38
141
|
const hasNeighboringBoundedContext = (ownerPath)=>{
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
142
|
+
const location = boundedContextLocation(external_node_path_default().join(ownerPath, 'domain'));
|
|
143
|
+
if (!location) return false;
|
|
144
|
+
const contextsPath = external_node_path_default().join(location.root, boundedContextsFolderName);
|
|
145
|
+
return boundedContextNames(contextsPath).some((name)=>name !== location.name);
|
|
43
146
|
};
|
|
44
147
|
const boundedContextLocation = (file)=>{
|
|
45
148
|
const parts = external_node_path_default().resolve(file).split(external_node_path_default().sep);
|
|
46
|
-
const index = parts.lastIndexOf(
|
|
149
|
+
const index = parts.lastIndexOf(boundedContextsFolderName);
|
|
47
150
|
if (-1 === index || parts.length < index + 3) return;
|
|
48
151
|
return {
|
|
49
152
|
root: parts.slice(0, index).join(external_node_path_default().sep),
|
|
50
|
-
|
|
51
|
-
segments: parts.slice(index + 2)
|
|
153
|
+
...splitContextSegments(parts.slice(index + 1))
|
|
52
154
|
};
|
|
53
155
|
};
|
|
156
|
+
const boundedContextName = (folder)=>boundedContextLocation(external_node_path_default().join(folder, 'domain'))?.name;
|
|
54
157
|
const isCrossContextImplementation = (file)=>{
|
|
55
158
|
const location = boundedContextLocation(file);
|
|
56
159
|
const [layer, kind, label] = location?.segments ?? [];
|
|
@@ -844,34 +947,6 @@ const addDrizzle = async ()=>{
|
|
|
844
947
|
})
|
|
845
948
|
];
|
|
846
949
|
};
|
|
847
|
-
class UnknownFormatNaming {
|
|
848
|
-
rawSource;
|
|
849
|
-
camelCase;
|
|
850
|
-
PascalCase;
|
|
851
|
-
constructor(rawSource){
|
|
852
|
-
this.rawSource = rawSource;
|
|
853
|
-
const source = rawSource.trim();
|
|
854
|
-
if (!source.includes('-')) {
|
|
855
|
-
this.camelCase = source.substring(0, 1).toLowerCase() + source.substring(1);
|
|
856
|
-
this.PascalCase = source.substring(0, 1).toUpperCase() + source.substring(1);
|
|
857
|
-
}
|
|
858
|
-
const words = source.split('-').filter((word)=>!!word);
|
|
859
|
-
this.camelCase = words.map((word, index)=>0 === index ? word.toLowerCase() : word[0].toUpperCase() + word.slice(1).toLowerCase()).join('');
|
|
860
|
-
this.PascalCase = words.map((word)=>word[0].toUpperCase() + word.slice(1).toLowerCase()).join('');
|
|
861
|
-
}
|
|
862
|
-
get fileName() {
|
|
863
|
-
return this.rawSource;
|
|
864
|
-
}
|
|
865
|
-
get variableName() {
|
|
866
|
-
return this.camelCase;
|
|
867
|
-
}
|
|
868
|
-
get ClassName() {
|
|
869
|
-
return this.PascalCase;
|
|
870
|
-
}
|
|
871
|
-
get withSpaces() {
|
|
872
|
-
return this.fileName.replaceAll('-', ' ');
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
950
|
const wiring_layers = [
|
|
876
951
|
'domain',
|
|
877
952
|
'application',
|
|
@@ -1214,7 +1289,7 @@ const wireDependencies = (consumer, implementation, dependencies)=>{
|
|
|
1214
1289
|
const bindings = dependencies.map((dependency)=>{
|
|
1215
1290
|
const crossContext = crossContextImportAllowed(consumer.wireFile, dependency.wireFile);
|
|
1216
1291
|
const context = crossContext ? boundedContextLocation(dependency.wireFile) : void 0;
|
|
1217
|
-
const prefix = context ?
|
|
1292
|
+
const prefix = context ? contextClassName(context.name) : '';
|
|
1218
1293
|
const wireName = dependencyBinding(wireSource, consumer.wireFile, dependency.wireFile, dependency.wireName, context ? `wire${prefix}${dependency.typeName}` : dependency.wireName);
|
|
1219
1294
|
const typeName = dependencyBinding(classSource, implementation.file, dependency.typeFile, dependency.typeName, `${prefix}${dependency.typeName}`);
|
|
1220
1295
|
wireSource = addImport(wireSource, `import { ${importedAs(dependency.wireName, wireName)} } from '${relativeImport(consumer.wireFile, dependency.wireFile)}'`);
|
|
@@ -1511,28 +1586,6 @@ const missing_domain_first_packages_missingPackages = (packages)=>{
|
|
|
1511
1586
|
`npm i ${missing.join(' ')}`
|
|
1512
1587
|
] : [];
|
|
1513
1588
|
};
|
|
1514
|
-
const splitSegments = (rawSource)=>rawSource.split(/[\\/]/).map((segment)=>segment.trim()).filter((segment)=>!!segment);
|
|
1515
|
-
class NestedName {
|
|
1516
|
-
folders;
|
|
1517
|
-
folderName;
|
|
1518
|
-
fileName;
|
|
1519
|
-
ClassName;
|
|
1520
|
-
classNameSegments;
|
|
1521
|
-
constructor(rawSource){
|
|
1522
|
-
const segments = splitSegments(rawSource);
|
|
1523
|
-
this.folders = segments.slice(0, -1);
|
|
1524
|
-
this.folderName = new UnknownFormatNaming(segments.at(-1) ?? '').fileName;
|
|
1525
|
-
this.fileName = segments.map((segment)=>new UnknownFormatNaming(segment).fileName).join('-');
|
|
1526
|
-
this.classNameSegments = segments.map((segment)=>new UnknownFormatNaming(segment).ClassName);
|
|
1527
|
-
this.ClassName = this.classNameSegments.join('');
|
|
1528
|
-
}
|
|
1529
|
-
static validate = (rawSource)=>{
|
|
1530
|
-
const segments = splitSegments(rawSource);
|
|
1531
|
-
if (!segments.length) return 'Name is required';
|
|
1532
|
-
if (segments.some((segment)=>'.' === segment || '..' === segment)) return 'Use a path relative to the folder, without "." or ".."';
|
|
1533
|
-
return true;
|
|
1534
|
-
};
|
|
1535
|
-
}
|
|
1536
1589
|
const usesNext = ()=>config_file_ConfigFile.exists && config_file_ConfigFile.Instance.data.frontend?.react?.framework === 'next';
|
|
1537
1590
|
const nextAppFolder = (root)=>[
|
|
1538
1591
|
'app',
|
|
@@ -1619,29 +1672,36 @@ const scaffoldReactPage = async (presentationReactFolder)=>{
|
|
|
1619
1672
|
};
|
|
1620
1673
|
const openapiExtractorPath = "scripts/extract-open-api-data-from-endpoint.ts";
|
|
1621
1674
|
const rootFolderSegments = (rootFolder, indent = 20)=>rootFolder.split(/[\\/]/).map((segment)=>segment.trim()).filter((segment)=>!!segment && '.' !== segment).map((segment)=>`'${segment}',\n${' '.repeat(indent)}`).join('');
|
|
1622
|
-
const endpointFileLookup = (rootFolder)=>`
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
// A controller is the first folder of the path; other routes
|
|
1629
|
-
// belong to the context root in presentation/rest/(root).
|
|
1630
|
-
const restFolder = path.join(
|
|
1631
|
-
${rootFolderSegments(rootFolder, 16)}'bounded-contexts',
|
|
1632
|
-
currentBoundedContext,
|
|
1633
|
-
'presentation',
|
|
1634
|
-
'rest'
|
|
1675
|
+
const endpointFileLookup = (rootFolder)=>` // A context is the start of the route, nested ones included
|
|
1676
|
+
// (/sales/orders/...). A controller is the next folder; other
|
|
1677
|
+
// routes belong to the context root in presentation/rest/(root).
|
|
1678
|
+
const contextsFolder = path.join(
|
|
1679
|
+
${rootFolderSegments(rootFolder, 16)}'bounded-contexts'
|
|
1635
1680
|
);
|
|
1636
|
-
const
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1681
|
+
const endpointFile = Array.from(
|
|
1682
|
+
{ length: routeMetadata.path.length },
|
|
1683
|
+
(_, index) => index + 1
|
|
1684
|
+
)
|
|
1685
|
+
.flatMap((contextLength) => {
|
|
1686
|
+
const restFolder = path.join(
|
|
1687
|
+
contextsFolder,
|
|
1688
|
+
...routeMetadata.path.slice(0, contextLength),
|
|
1689
|
+
'presentation',
|
|
1690
|
+
'rest'
|
|
1691
|
+
);
|
|
1692
|
+
const endpointPath = [
|
|
1693
|
+
...routeMetadata.path
|
|
1694
|
+
.slice(contextLength)
|
|
1695
|
+
.map(pathParameterAsName),
|
|
1696
|
+
\`\${routeMetadata.method.toUpperCase()}.ts\`
|
|
1697
|
+
];
|
|
1698
|
+
return [
|
|
1699
|
+
path.join(restFolder, ...endpointPath),
|
|
1700
|
+
path.join(restFolder, '(root)', ...endpointPath)
|
|
1701
|
+
];
|
|
1702
|
+
})
|
|
1703
|
+
.map((file) => project.getSourceFile(file))
|
|
1704
|
+
.find((file) => !!file);
|
|
1645
1705
|
`;
|
|
1646
1706
|
const openapiExtractor = (rootFolder)=>`import path from 'node:path';
|
|
1647
1707
|
import {
|
|
@@ -2409,9 +2469,7 @@ const dependencyOptions = (boundedContextFolder)=>{
|
|
|
2409
2469
|
module: x,
|
|
2410
2470
|
label: `${x.typeName} (shared-kernel)`
|
|
2411
2471
|
})),
|
|
2412
|
-
...isShared ? [] : contextsFolder.
|
|
2413
|
-
name
|
|
2414
|
-
]).path).map((module)=>({
|
|
2472
|
+
...isShared ? [] : boundedContextNames(contextsFolder.path).filter((name)=>name !== boundedContextName(boundedContextFolder.path)).flatMap((name)=>findWiredModules(contextsFolder.subitem(name.split('/')).path).map((module)=>({
|
|
2415
2473
|
module,
|
|
2416
2474
|
label: `${module.typeName} (${name})`
|
|
2417
2475
|
})))
|
|
@@ -3025,7 +3083,7 @@ const integrationSpecFile = (unit, label)=>{
|
|
|
3025
3083
|
]).find((file)=>file.startsWith(`${layout.implementations}/${label}/`)) : void 0;
|
|
3026
3084
|
const projectRoot = projectRootOf(unit.ownerPath);
|
|
3027
3085
|
if (!source || !projectRoot) return;
|
|
3028
|
-
return external_node_path_default().join(projectRoot, integrationSpecsFolder, external_node_path_default().basename(unit.ownerPath), source.slice(15).replace(/\.ts$/, '.spec.ts'));
|
|
3086
|
+
return external_node_path_default().join(projectRoot, integrationSpecsFolder, ...(boundedContextName(unit.ownerPath) ?? external_node_path_default().basename(unit.ownerPath)).split('/'), source.slice(15).replace(/\.ts$/, '.spec.ts'));
|
|
3029
3087
|
};
|
|
3030
3088
|
const integrationSpecSubjects = (unit)=>'infrastructure-service' === unit.kind ? [
|
|
3031
3089
|
void 0
|
|
@@ -3036,21 +3094,21 @@ const integrationSpecsStop = (file)=>{
|
|
|
3036
3094
|
const folder = external_node_path_default().join(projectRoot, integrationSpecsFolder);
|
|
3037
3095
|
return file.startsWith(`${folder}${external_node_path_default().sep}`) ? folder : void 0;
|
|
3038
3096
|
};
|
|
3039
|
-
const
|
|
3097
|
+
const backend_module_move_subfolders = (folder)=>external_node_fs_default().existsSync(folder) ? external_node_fs_default().readdirSync(folder, {
|
|
3040
3098
|
withFileTypes: true
|
|
3041
3099
|
}).filter((entry)=>entry.isDirectory()).map((entry)=>entry.name).sort() : [];
|
|
3042
3100
|
const namesBySuffix = (folder, suffix)=>external_node_fs_default().existsSync(folder) ? external_node_fs_default().readdirSync(folder).filter((file)=>file.endsWith(suffix) && !file.endsWith('.spec.ts')).map((file)=>file.slice(0, -suffix.length)).sort() : [];
|
|
3043
3101
|
const labelsOf = (ownerPath, kind, name)=>{
|
|
3044
3102
|
const { implementations } = kindLayouts[kind];
|
|
3045
3103
|
if (!implementations) return [];
|
|
3046
|
-
return
|
|
3104
|
+
return backend_module_move_subfolders(external_node_path_default().join(ownerPath, implementations)).filter((label)=>kindLayouts[kind].files({
|
|
3047
3105
|
ownerPath,
|
|
3048
3106
|
name
|
|
3049
3107
|
}, [
|
|
3050
3108
|
label
|
|
3051
3109
|
]).some((file)=>file.startsWith(`${implementations}/`) && external_node_fs_default().existsSync(external_node_path_default().join(ownerPath, file))));
|
|
3052
3110
|
};
|
|
3053
|
-
const aggregatesOf = (ownerPath)=>
|
|
3111
|
+
const aggregatesOf = (ownerPath)=>backend_module_move_subfolders(external_node_path_default().join(ownerPath, 'domain/aggregates')).filter((name)=>external_node_fs_default().existsSync(external_node_path_default().join(ownerPath, 'domain/aggregates', name, `${name}.aggregate-root.ts`)));
|
|
3054
3112
|
const findBackendUnits = (ownerPath)=>{
|
|
3055
3113
|
const unit = (kind, name, aggregate)=>({
|
|
3056
3114
|
kind,
|
|
@@ -3114,11 +3172,14 @@ const validateBackendMove = (unit, target, sharedKernelPath)=>{
|
|
|
3114
3172
|
return true;
|
|
3115
3173
|
};
|
|
3116
3174
|
const ownerOf = (rootFolderPath, file)=>{
|
|
3117
|
-
const [area,
|
|
3118
|
-
if ('bounded-contexts' === area &&
|
|
3119
|
-
context
|
|
3120
|
-
|
|
3121
|
-
|
|
3175
|
+
const [area, ...segments] = external_node_path_default().relative(rootFolderPath, file).split(external_node_path_default().sep);
|
|
3176
|
+
if ('bounded-contexts' === area && segments.length) {
|
|
3177
|
+
const context = splitContextSegments(segments).name;
|
|
3178
|
+
return {
|
|
3179
|
+
context,
|
|
3180
|
+
path: external_node_path_default().join(rootFolderPath, area, ...context.split('/'))
|
|
3181
|
+
};
|
|
3182
|
+
}
|
|
3122
3183
|
if ('shared-kernel' === area) return {
|
|
3123
3184
|
context: void 0,
|
|
3124
3185
|
path: external_node_path_default().join(rootFolderPath, area)
|
|
@@ -3630,6 +3691,10 @@ const envBranchedWireArgument = (testWire, primaryWire)=>{
|
|
|
3630
3691
|
...primary.map((name)=>` ${name}: ${primaryWire}`)
|
|
3631
3692
|
].join(',\n')}\n}`;
|
|
3632
3693
|
};
|
|
3694
|
+
const envBranchedWireImport = (wireFolder)=>{
|
|
3695
|
+
const relativePath = external_node_path_default().relative(wireFolder, external_node_path_default().join(new project_root_ProjectRoot().path, config_file_ConfigFile.Instance.data.project.rootFolder, 'shared-kernel', 'wiring', 'env-branched-wire')).split(external_node_path_default().sep).join('/');
|
|
3696
|
+
return `import { envBranchedWire } from '${relativePath.startsWith('.') ? relativePath : `./${relativePath}`}'`;
|
|
3697
|
+
};
|
|
3633
3698
|
const integrationFolder = 'specs/integration';
|
|
3634
3699
|
const testcontainersScripts = {
|
|
3635
3700
|
'test:integration': `vitest run --config ${integrationFolder}/vitest.config.ts --reporter=dot --silent=passed-only`
|
|
@@ -3790,11 +3855,11 @@ const configureIntegrationTests = async (root)=>{
|
|
|
3790
3855
|
source.subitem([
|
|
3791
3856
|
'shared-kernel'
|
|
3792
3857
|
]),
|
|
3793
|
-
...source.subitem([
|
|
3858
|
+
...boundedContextNames(source.subitem([
|
|
3794
3859
|
'bounded-contexts'
|
|
3795
|
-
]).
|
|
3860
|
+
]).path).map((name)=>source.subitem([
|
|
3796
3861
|
'bounded-contexts',
|
|
3797
|
-
name
|
|
3862
|
+
...name.split('/')
|
|
3798
3863
|
]))
|
|
3799
3864
|
];
|
|
3800
3865
|
for (const owner of owners)for (const unit of findContracts(owner.path)){
|
|
@@ -3900,10 +3965,10 @@ export default defineConfig({
|
|
|
3900
3965
|
exclude: [
|
|
3901
3966
|
'**/*.spec.ts',
|
|
3902
3967
|
${folder('shared-kernel/infrastructure/**')},
|
|
3903
|
-
${folder('bounded-contexts
|
|
3904
|
-
${folder('bounded-contexts
|
|
3968
|
+
${folder('bounded-contexts/**/infrastructure/**')},
|
|
3969
|
+
${folder('bounded-contexts/**/presentation/rest/**')},
|
|
3905
3970
|
${folder('shared-kernel/wiring/**')},
|
|
3906
|
-
${folder('bounded-contexts
|
|
3971
|
+
${folder('bounded-contexts/**/wiring/**')}
|
|
3907
3972
|
],
|
|
3908
3973
|
reporter: [['text', { skipFull: true }], 'html']
|
|
3909
3974
|
}${server}
|
|
@@ -4170,7 +4235,7 @@ const common = {
|
|
|
4170
4235
|
dryRun: external_zod_default().boolean().optional()
|
|
4171
4236
|
};
|
|
4172
4237
|
const agent_requests_owner = {
|
|
4173
|
-
context:
|
|
4238
|
+
context: agent_requests_nestedName.describe('A bounded-context name (nested ones as paths, e.g. sales/orders), or shared-kernel.')
|
|
4174
4239
|
};
|
|
4175
4240
|
const agent_requests_wired = {
|
|
4176
4241
|
dependencies: agent_requests_dependencies.optional()
|
|
@@ -4192,7 +4257,7 @@ const agent_requests_operation = (value, shape)=>external_zod_default().strictOb
|
|
|
4192
4257
|
const scaffoldRequestSchema = external_zod_default().discriminatedUnion('operation', [
|
|
4193
4258
|
agent_requests_operation('bounded-context', {
|
|
4194
4259
|
...common,
|
|
4195
|
-
name:
|
|
4260
|
+
name: agent_requests_nestedName.describe('Folders split by "/", e.g. sales/orders.').refine((value)=>'shared-kernel' !== value, 'shared-kernel is reserved for the Shared Kernel.')
|
|
4196
4261
|
}),
|
|
4197
4262
|
agent_requests_operation('aggregate', {
|
|
4198
4263
|
...named,
|
|
@@ -4290,7 +4355,7 @@ const scaffoldRequestSchema = external_zod_default().discriminatedUnion('operati
|
|
|
4290
4355
|
...common,
|
|
4291
4356
|
...agent_requests_owner,
|
|
4292
4357
|
module: agent_requests_id.describe('Exact unit ID from --describe.'),
|
|
4293
|
-
targetContext:
|
|
4358
|
+
targetContext: agent_requests_nestedName.optional(),
|
|
4294
4359
|
name: agent_requests_name.optional(),
|
|
4295
4360
|
aggregate: agent_requests_name.optional()
|
|
4296
4361
|
})
|
|
@@ -4800,10 +4865,8 @@ const moveBackendUnitUseCase = async (ownerFolder)=>{
|
|
|
4800
4865
|
}),
|
|
4801
4866
|
pageSize: 20
|
|
4802
4867
|
});
|
|
4803
|
-
const placeName = (ownerPath)=>ownerPath === sharedKernelPath ? 'Shared Kernel' : `Bounded Context: ${
|
|
4804
|
-
const contexts =
|
|
4805
|
-
'bounded-contexts'
|
|
4806
|
-
]).content.subfolderNames.map((name)=>external_node_path_default().join(rootFolderPath, 'bounded-contexts', name));
|
|
4868
|
+
const placeName = (ownerPath)=>ownerPath === sharedKernelPath ? 'Shared Kernel' : `Bounded Context: ${boundedContextName(ownerPath)}`;
|
|
4869
|
+
const contexts = boundedContextNames(external_node_path_default().join(rootFolderPath, 'bounded-contexts')).map((name)=>external_node_path_default().join(rootFolderPath, 'bounded-contexts', ...name.split('/')));
|
|
4807
4870
|
const places = [
|
|
4808
4871
|
unit.ownerPath,
|
|
4809
4872
|
...contexts,
|
|
@@ -4813,7 +4876,7 @@ const moveBackendUnitUseCase = async (ownerFolder)=>{
|
|
|
4813
4876
|
].filter((place, index, all)=>all.indexOf(place) === index);
|
|
4814
4877
|
const ownerPath = await interaction_select({
|
|
4815
4878
|
key: 'targetContext',
|
|
4816
|
-
id: (owner)=>owner === sharedKernelPath ? 'shared-kernel' : external_node_path_default().basename(owner),
|
|
4879
|
+
id: (owner)=>owner === sharedKernelPath ? 'shared-kernel' : boundedContextName(owner) ?? external_node_path_default().basename(owner),
|
|
4817
4880
|
message: 'Move to:',
|
|
4818
4881
|
choices: places.map((value)=>({
|
|
4819
4882
|
name: value === unit.ownerPath ? `${placeName(value)} (stays)` : placeName(value),
|
|
@@ -5106,7 +5169,10 @@ describe('${aggregateNaming.withSpaces}', () => {
|
|
|
5106
5169
|
'repositories'
|
|
5107
5170
|
]).createFile(`wire-${aggregateNaming.fileName}-repository.ts`, `
|
|
5108
5171
|
import { wireClass } from '@domain-first/wire'
|
|
5109
|
-
|
|
5172
|
+
${envBranchedWireImport(boundedContextFolder.subitem([
|
|
5173
|
+
'wiring',
|
|
5174
|
+
'repositories'
|
|
5175
|
+
]).path)}
|
|
5110
5176
|
${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { ${ClassName}${aggregateNaming.ClassName}Repository } from '../../infrastructure/repositories/${fileName}/${fileName}-${aggregateNaming.fileName}-repository'`).join('\n')}
|
|
5111
5177
|
|
|
5112
5178
|
${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName })=>`const wire${ClassName}Implementation = wireClass(${ClassName}${aggregateNaming.ClassName}Repository, [])`).join('\n\n')}
|
|
@@ -5175,7 +5241,7 @@ export abstract class ${naming.ClassName} {
|
|
|
5175
5241
|
if (config_file_ConfigFile.backend.domainFirstPackages.includes('@domain-first/wire')) {
|
|
5176
5242
|
const wireFile = wiringFolder.createFile(`wire-${naming.fileName}.ts`, `
|
|
5177
5243
|
import { wireClass } from '@domain-first/wire'
|
|
5178
|
-
|
|
5244
|
+
${envBranchedWireImport(wiringFolder.path)}
|
|
5179
5245
|
${implementationTypes.map((x)=>({
|
|
5180
5246
|
naming: new UnknownFormatNaming(`${x}-${naming.fileName}`),
|
|
5181
5247
|
implementation: x
|
|
@@ -5249,19 +5315,19 @@ export const wire${naming.ClassName}ApplicationService = wireClass(
|
|
|
5249
5315
|
}
|
|
5250
5316
|
};
|
|
5251
5317
|
const scaffoldNewBoundedContextUseCase = async ()=>{
|
|
5318
|
+
const rootFolder = new file_system_Folder(new project_root_ProjectRoot().path).subitem([
|
|
5319
|
+
config_file_ConfigFile.Instance.data.project.rootFolder
|
|
5320
|
+
]);
|
|
5321
|
+
const contextsFolder = external_node_path_default().join(rootFolder.path, boundedContextsFolderName);
|
|
5252
5322
|
const name = await interaction_input({
|
|
5253
5323
|
key: 'name',
|
|
5254
|
-
message: 'Name:',
|
|
5255
|
-
validate: (
|
|
5324
|
+
message: 'Name (folders split by "/"):',
|
|
5325
|
+
validate: (value)=>validateBoundedContextName(contextsFolder, value)
|
|
5256
5326
|
});
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
'bounded-contexts',
|
|
5262
|
-
name
|
|
5263
|
-
]);
|
|
5264
|
-
folder.createIfNotExisted();
|
|
5327
|
+
rootFolder.subitem([
|
|
5328
|
+
boundedContextsFolderName,
|
|
5329
|
+
...name.split(/[\\/]/).map((segment)=>segment.trim()).filter((segment)=>!!segment)
|
|
5330
|
+
]).createIfNotExisted();
|
|
5265
5331
|
};
|
|
5266
5332
|
const scaffoldNewCommand = async (boundedContextFolder)=>{
|
|
5267
5333
|
const commandsFolder = boundedContextFolder.subitem([
|
|
@@ -5323,7 +5389,10 @@ export abstract class ${naming.ClassName}Command {
|
|
|
5323
5389
|
'commands'
|
|
5324
5390
|
]).createFile(`wire-${naming.fileName}-command.ts`, `
|
|
5325
5391
|
import { wireClass } from '@domain-first/wire'
|
|
5326
|
-
|
|
5392
|
+
${envBranchedWireImport(boundedContextFolder.subitem([
|
|
5393
|
+
'wiring',
|
|
5394
|
+
'commands'
|
|
5395
|
+
]).path)}
|
|
5327
5396
|
${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { ${ClassName}${naming.ClassName}Command } from '../../infrastructure/commands/${fileName}/${fileName}-${naming.fileName}-command'`).join('\n')}
|
|
5328
5397
|
|
|
5329
5398
|
${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName })=>`const wire${ClassName}Implementation = wireClass(${ClassName}${naming.ClassName}Command, [])`).join('\n\n')}
|
|
@@ -5475,7 +5544,8 @@ const scaffoldNewErrorUseCase = async (boundedContextFolder)=>{
|
|
|
5475
5544
|
'errors'
|
|
5476
5545
|
]);
|
|
5477
5546
|
const names = errorNames(boundedContextFolder);
|
|
5478
|
-
const
|
|
5547
|
+
const contextName = boundedContextName(boundedContextFolder.path) ?? boundedContextFolder.name;
|
|
5548
|
+
const contextNaming = new NestedName(contextName);
|
|
5479
5549
|
const currentErrorNamespaces = currentErrorFolder.content.fileNames.filter((x)=>'index' !== x);
|
|
5480
5550
|
const variants = [
|
|
5481
5551
|
'New error without namespace',
|
|
@@ -5494,7 +5564,7 @@ const scaffoldNewErrorUseCase = async (boundedContextFolder)=>{
|
|
|
5494
5564
|
});
|
|
5495
5565
|
const naming = new UnknownFormatNaming(errorName);
|
|
5496
5566
|
const indexFile = currentErrorFolder.file('index.ts');
|
|
5497
|
-
indexFile.addLineIfMissing(errorClass(names.error(naming.ClassName), rootNamespace(indexFile, `${contextNaming.ClassName}Errors`,
|
|
5567
|
+
indexFile.addLineIfMissing(errorClass(names.error(naming.ClassName), rootNamespace(indexFile, `${contextNaming.ClassName}Errors`, contextName), naming.fileName), '\n\n');
|
|
5498
5568
|
return;
|
|
5499
5569
|
}
|
|
5500
5570
|
if ('New namespace' === selectedVariant) {
|
|
@@ -5506,7 +5576,7 @@ const scaffoldNewErrorUseCase = async (boundedContextFolder)=>{
|
|
|
5506
5576
|
if (!currentErrorFolder.file(`${fileName}.ts`).exists) currentErrorFolder.createFile(`${fileName}.ts`, `
|
|
5507
5577
|
import { errorNamespace } from '@domain-first/errors'
|
|
5508
5578
|
|
|
5509
|
-
export const ${names.namespace(ClassName)} = errorNamespace('${
|
|
5579
|
+
export const ${names.namespace(ClassName)} = errorNamespace('${contextName}').subnamespace('${fileName}')
|
|
5510
5580
|
`.trim());
|
|
5511
5581
|
currentErrorFolder.file('index.ts').addLineIfMissing(`export * from './${fileName}'`, '\n\n');
|
|
5512
5582
|
return;
|
|
@@ -5523,15 +5593,17 @@ export const ${names.namespace(ClassName)} = errorNamespace('${boundedContextFol
|
|
|
5523
5593
|
};
|
|
5524
5594
|
const newController = 'New controller';
|
|
5525
5595
|
const rootControllerChoice = 'No controller (context root)';
|
|
5526
|
-
const
|
|
5527
|
-
|
|
5528
|
-
|
|
5596
|
+
const sourceFolder = ()=>new file_system_Folder(new project_root_ProjectRoot().path).subitem([
|
|
5597
|
+
config_file_ConfigFile.Instance.data.project.rootFolder
|
|
5598
|
+
]);
|
|
5599
|
+
const sharedRestFolder = ()=>sourceFolder().subitem([
|
|
5529
5600
|
'presentation',
|
|
5530
5601
|
'rest'
|
|
5531
5602
|
]);
|
|
5532
5603
|
const legacyRootEndpointsMessage = (context)=>`${context} keeps its context-root endpoints in the 8.5 layout (presentation/rest/<METHOD>.ts, _param_/). Run npx df-upgrade to move them to presentation/rest/(root)/ first.`;
|
|
5533
5604
|
const scaffoldNewHandlersRestEndpoint = async (boundedContextFolder)=>{
|
|
5534
|
-
const context = boundedContextFolder.name;
|
|
5605
|
+
const context = boundedContextName(boundedContextFolder.path) ?? boundedContextFolder.name;
|
|
5606
|
+
const contextSegments = context.split('/');
|
|
5535
5607
|
const restPresentationFolder = boundedContextFolder.subitem([
|
|
5536
5608
|
'presentation',
|
|
5537
5609
|
'rest'
|
|
@@ -5589,7 +5661,7 @@ const scaffoldNewHandlersRestEndpoint = async (boundedContextFolder)=>{
|
|
|
5589
5661
|
...routeSegments
|
|
5590
5662
|
];
|
|
5591
5663
|
const routePath = [
|
|
5592
|
-
|
|
5664
|
+
...contextSegments,
|
|
5593
5665
|
...controller ? [
|
|
5594
5666
|
controller
|
|
5595
5667
|
] : [],
|
|
@@ -5597,7 +5669,9 @@ const scaffoldNewHandlersRestEndpoint = async (boundedContextFolder)=>{
|
|
|
5597
5669
|
];
|
|
5598
5670
|
const endpointFolder = restPresentationFolder.subitem(folderSegments.map(pathParameterAsName));
|
|
5599
5671
|
const nameSegments = [
|
|
5600
|
-
controller
|
|
5672
|
+
...controller ? [
|
|
5673
|
+
controller
|
|
5674
|
+
] : contextSegments,
|
|
5601
5675
|
...routeSegments
|
|
5602
5676
|
];
|
|
5603
5677
|
const nameBase = `${[
|
|
@@ -5609,9 +5683,7 @@ const scaffoldNewHandlersRestEndpoint = async (boundedContextFolder)=>{
|
|
|
5609
5683
|
method,
|
|
5610
5684
|
'endpoint'
|
|
5611
5685
|
].map((segment)=>segment.startsWith(':') ? pathParameterAsName(segment) : new UnknownFormatNaming(segment).ClassName).join('');
|
|
5612
|
-
const endpointGenerator = findRestEndpointGenerator(
|
|
5613
|
-
'..',
|
|
5614
|
-
'..',
|
|
5686
|
+
const endpointGenerator = findRestEndpointGenerator(sourceFolder().subitem([
|
|
5615
5687
|
'shared-kernel'
|
|
5616
5688
|
]));
|
|
5617
5689
|
const handler = withWiring ? await promptEndpointHandler(boundedContextFolder) : void 0;
|
|
@@ -5664,9 +5736,9 @@ export const wire${endpointClassName} = wireClass(
|
|
|
5664
5736
|
'presentation',
|
|
5665
5737
|
'rest'
|
|
5666
5738
|
]).file('index.ts').addLineIfMissing(`export * from './${group}'`);
|
|
5667
|
-
sharedRestFolder(
|
|
5668
|
-
const restHandlersFile = sharedRestFolder(
|
|
5669
|
-
if (!restHandlersFile.exists) sharedRestFolder(
|
|
5739
|
+
sharedRestFolder().file('wires.ts').addLineIfMissing(`export * from '../../bounded-contexts/${context}/wiring/presentation/rest/${group}'`);
|
|
5740
|
+
const restHandlersFile = sharedRestFolder().file('index.ts');
|
|
5741
|
+
if (!restHandlersFile.exists) sharedRestFolder().createFile('index.ts', `
|
|
5670
5742
|
import * as wires from './wires'
|
|
5671
5743
|
|
|
5672
5744
|
const restWires = Object.values(wires)
|
|
@@ -5927,7 +5999,10 @@ export abstract class ${naming.ClassName}Query {
|
|
|
5927
5999
|
'queries'
|
|
5928
6000
|
]).createFile(`wire-${naming.fileName}-query.ts`, `
|
|
5929
6001
|
import { wireClass } from '@domain-first/wire'
|
|
5930
|
-
|
|
6002
|
+
${envBranchedWireImport(boundedContextFolder.subitem([
|
|
6003
|
+
'wiring',
|
|
6004
|
+
'queries'
|
|
6005
|
+
]).path)}
|
|
5931
6006
|
${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { ${ClassName}${naming.ClassName}Query } from '../../infrastructure/queries/${fileName}/${fileName}-${naming.fileName}-query'`).join('\n')}
|
|
5932
6007
|
|
|
5933
6008
|
${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName })=>`const wire${ClassName}Implementation = wireClass(${ClassName}${naming.ClassName}Query, [])`).join('\n\n')}
|
|
@@ -6218,13 +6293,13 @@ const ownerFolders = (root)=>{
|
|
|
6218
6293
|
'shared-kernel'
|
|
6219
6294
|
])
|
|
6220
6295
|
},
|
|
6221
|
-
...source.subitem([
|
|
6296
|
+
...boundedContextNames(source.subitem([
|
|
6222
6297
|
'bounded-contexts'
|
|
6223
|
-
]).
|
|
6298
|
+
]).path).map((name)=>({
|
|
6224
6299
|
name,
|
|
6225
6300
|
folder: source.subitem([
|
|
6226
6301
|
'bounded-contexts',
|
|
6227
|
-
name
|
|
6302
|
+
...name.split('/')
|
|
6228
6303
|
])
|
|
6229
6304
|
}))
|
|
6230
6305
|
];
|
|
@@ -6563,10 +6638,7 @@ const main = async ()=>{
|
|
|
6563
6638
|
process.exit(1);
|
|
6564
6639
|
}
|
|
6565
6640
|
const rootPath = new project_root_ProjectRoot().path;
|
|
6566
|
-
const currentBoundedContextOptions =
|
|
6567
|
-
config_file_ConfigFile.Instance.data.project.rootFolder,
|
|
6568
|
-
'bounded-contexts'
|
|
6569
|
-
]).content.subfolderNames.map((name)=>({
|
|
6641
|
+
const currentBoundedContextOptions = boundedContextNames(external_node_path_default().join(rootPath, config_file_ConfigFile.Instance.data.project.rootFolder, 'bounded-contexts')).map((name)=>({
|
|
6570
6642
|
name: `Bounded Context: ${name}`,
|
|
6571
6643
|
action: 'Scaffold in bounded context'
|
|
6572
6644
|
}));
|
|
@@ -6596,7 +6668,7 @@ const main = async ()=>{
|
|
|
6596
6668
|
const boundedContextFolder = new file_system_Folder(new project_root_ProjectRoot().path).subitem(specificContext ? [
|
|
6597
6669
|
config_file_ConfigFile.Instance.data.project.rootFolder,
|
|
6598
6670
|
'bounded-contexts',
|
|
6599
|
-
name.substring(17)
|
|
6671
|
+
...name.substring(17).split('/')
|
|
6600
6672
|
] : [
|
|
6601
6673
|
config_file_ConfigFile.Instance.data.project.rootFolder,
|
|
6602
6674
|
'shared-kernel'
|