@domain-first/project-structure 8.9.2 → 8.10.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/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-plan-feature/SKILL.md +1 -1
- package/skills/df-ps-scaffold/SKILL.md +2 -2
- package/skills/df-ps-scaffold/references/agent-operations.md +2 -2
package/dist/lint.cjs
CHANGED
|
@@ -348,15 +348,53 @@ class ConfigFile {
|
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
350
|
const config_file_configuredDependencyRules = ()=>resolveDependencyRules(ConfigFile.exists ? ConfigFile.Instance.data.backend?.rules?.dependencies : void 0);
|
|
351
|
+
const bounded_contexts_boundedContextsFolderName = 'bounded-contexts';
|
|
352
|
+
const contextLayerFolders = [
|
|
353
|
+
'domain',
|
|
354
|
+
'application',
|
|
355
|
+
'infrastructure',
|
|
356
|
+
'presentation',
|
|
357
|
+
'wiring'
|
|
358
|
+
];
|
|
359
|
+
const subfolders = (folder)=>external_node_fs_default().existsSync(folder) ? external_node_fs_default().readdirSync(folder, {
|
|
360
|
+
withFileTypes: true
|
|
361
|
+
}).filter((entry)=>entry.isDirectory()).map((entry)=>entry.name) : [];
|
|
362
|
+
const isBoundedContextFolder = (folder)=>{
|
|
363
|
+
const names = subfolders(folder);
|
|
364
|
+
return !names.length || names.some((name)=>contextLayerFolders.includes(name));
|
|
365
|
+
};
|
|
366
|
+
const bounded_contexts_boundedContextNames = (contextsFolder)=>{
|
|
367
|
+
const walk = (folder, prefix)=>subfolders(folder).flatMap((name)=>{
|
|
368
|
+
const child = external_node_path_default().join(folder, name);
|
|
369
|
+
return isBoundedContextFolder(child) ? [
|
|
370
|
+
[
|
|
371
|
+
...prefix,
|
|
372
|
+
name
|
|
373
|
+
].join('/')
|
|
374
|
+
] : walk(child, [
|
|
375
|
+
...prefix,
|
|
376
|
+
name
|
|
377
|
+
]);
|
|
378
|
+
});
|
|
379
|
+
return walk(contextsFolder, []).sort();
|
|
380
|
+
};
|
|
381
|
+
const boundedContextPath = (contextsFolder, name)=>external_node_path_default().join(contextsFolder, ...name.split('/'));
|
|
382
|
+
const splitContextSegments = (segments)=>{
|
|
383
|
+
const layer = segments.findIndex((segment)=>contextLayerFolders.includes(segment));
|
|
384
|
+
const length = layer > 0 ? layer : 1;
|
|
385
|
+
return {
|
|
386
|
+
name: segments.slice(0, length).join('/'),
|
|
387
|
+
segments: segments.slice(length)
|
|
388
|
+
};
|
|
389
|
+
};
|
|
351
390
|
const crossContextImplementation = 'cross-context';
|
|
352
391
|
const context_dependencies_boundedContextLocation = (file)=>{
|
|
353
392
|
const parts = external_node_path_default().resolve(file).split(external_node_path_default().sep);
|
|
354
|
-
const index = parts.lastIndexOf(
|
|
393
|
+
const index = parts.lastIndexOf(bounded_contexts_boundedContextsFolderName);
|
|
355
394
|
if (-1 === index || parts.length < index + 3) return;
|
|
356
395
|
return {
|
|
357
396
|
root: parts.slice(0, index).join(external_node_path_default().sep),
|
|
358
|
-
|
|
359
|
-
segments: parts.slice(index + 2)
|
|
397
|
+
...splitContextSegments(parts.slice(index + 1))
|
|
360
398
|
};
|
|
361
399
|
};
|
|
362
400
|
const isCrossContextImplementation = (file)=>{
|
|
@@ -419,7 +457,7 @@ const compilerOption = (configFile, name, seen = new Set())=>{
|
|
|
419
457
|
if (void 0 !== value) return value;
|
|
420
458
|
}
|
|
421
459
|
};
|
|
422
|
-
class
|
|
460
|
+
class UnknownFormatNaming {
|
|
423
461
|
rawSource;
|
|
424
462
|
camelCase;
|
|
425
463
|
PascalCase;
|
|
@@ -532,7 +570,7 @@ const readWiredModule = (wireFile, contextPath)=>{
|
|
|
532
570
|
const wiringRelativePath = external_node_path_default().relative(external_node_path_default().join(contextPath, 'wiring'), wireFile);
|
|
533
571
|
if (isEndpointWire(wiringRelativePath)) return;
|
|
534
572
|
const source = new file_system_File(wireFile).data;
|
|
535
|
-
const wireName = `wire${new
|
|
573
|
+
const wireName = `wire${new UnknownFormatNaming(external_node_path_default().basename(wireFile, '.ts').replace(/^wire-/, '')).ClassName}`;
|
|
536
574
|
const exportMatch = new RegExp(`export\\s+const\\s+${wireName}\\s*=\\s*`).exec(source);
|
|
537
575
|
if (!exportMatch) return;
|
|
538
576
|
const branched = source.slice(exportMatch.index + exportMatch[0].length).startsWith('envBranchedWire(');
|
|
@@ -794,12 +832,16 @@ const importViolations = (projectRoot, rootFolder, rules)=>{
|
|
|
794
832
|
const inMemoryDbFile = external_node_path_default().join(sharedFolder, 'infrastructure', 'services', 'in-memory-db-infrastructure-service.ts');
|
|
795
833
|
const aliases = readAliases(projectRoot);
|
|
796
834
|
const violations = [];
|
|
835
|
+
const contextOf = (file)=>{
|
|
836
|
+
const segments = inside(contextsFolder, file);
|
|
837
|
+
return segments && splitContextSegments(segments).name;
|
|
838
|
+
};
|
|
797
839
|
const locate = (file)=>{
|
|
798
840
|
const inContext = inside(contextsFolder, file);
|
|
799
841
|
if (inContext && inContext.length > 1) {
|
|
800
|
-
const
|
|
842
|
+
const { name, segments } = splitContextSegments(inContext);
|
|
801
843
|
return {
|
|
802
|
-
owner,
|
|
844
|
+
owner: name,
|
|
803
845
|
segments
|
|
804
846
|
};
|
|
805
847
|
}
|
|
@@ -838,8 +880,8 @@ const importViolations = (projectRoot, rootFolder, rules)=>{
|
|
|
838
880
|
line: 1,
|
|
839
881
|
text: external_node_path_default().basename(file)
|
|
840
882
|
});
|
|
841
|
-
const ownContext =
|
|
842
|
-
const directWiring = ownContext && from?.segments[0] === 'wiring' && readWiredModule(file,
|
|
883
|
+
const ownContext = contextOf(file);
|
|
884
|
+
const directWiring = ownContext && from?.segments[0] === 'wiring' && readWiredModule(file, boundedContextPath(contextsFolder, ownContext))?.implementations.some((implementation)=>isCrossContextImplementation(implementation.file));
|
|
843
885
|
const report = (check, rule, imported)=>violations.push({
|
|
844
886
|
check,
|
|
845
887
|
rule,
|
|
@@ -851,7 +893,7 @@ const importViolations = (projectRoot, rootFolder, rules)=>{
|
|
|
851
893
|
const target = imported.target;
|
|
852
894
|
if (!target) continue;
|
|
853
895
|
const to = locate(target);
|
|
854
|
-
const targetContext =
|
|
896
|
+
const targetContext = contextOf(target);
|
|
855
897
|
const crossContextAllowed = true === context_dependencies_crossContextImportAllowed(file, target) && (from?.segments[0] !== 'wiring' || directWiring);
|
|
856
898
|
if (ownContext) {
|
|
857
899
|
if (targetContext && targetContext !== ownContext && !crossContextAllowed) report('context-isolation', `[${ownContext}] imports another context:`, imported);
|
|
@@ -900,12 +942,10 @@ const wiringViolations = (projectRoot, rootFolder, rules)=>{
|
|
|
900
942
|
name: 'shared-kernel',
|
|
901
943
|
modules: sharedModules
|
|
902
944
|
},
|
|
903
|
-
...
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
modules: findWiredModules(external_node_path_default().join(contextsFolder, entry.name))
|
|
908
|
-
})) : []
|
|
945
|
+
...bounded_contexts_boundedContextNames(contextsFolder).map((name)=>({
|
|
946
|
+
name,
|
|
947
|
+
modules: findWiredModules(boundedContextPath(contextsFolder, name))
|
|
948
|
+
}))
|
|
909
949
|
];
|
|
910
950
|
const violations = [];
|
|
911
951
|
const allModules = new Map(owners.flatMap(({ modules })=>modules).map((module)=>[
|
|
@@ -966,7 +1006,7 @@ const directReadViolations = (projectRoot, rootFolder)=>{
|
|
|
966
1006
|
const root = external_node_path_default().resolve(projectRoot, rootFolder);
|
|
967
1007
|
const folders = [
|
|
968
1008
|
external_node_path_default().join(root, 'shared-kernel'),
|
|
969
|
-
...
|
|
1009
|
+
...bounded_contexts_boundedContextNames(external_node_path_default().join(root, 'bounded-contexts')).map((name)=>boundedContextPath(external_node_path_default().join(root, 'bounded-contexts'), name))
|
|
970
1010
|
].flatMap((folder)=>[
|
|
971
1011
|
external_node_path_default().join(folder, 'domain'),
|
|
972
1012
|
external_node_path_default().join(folder, 'application')
|