@domain-first/project-structure 8.9.1 → 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 +86 -81
- 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 +238 -154
- package/dist/index.js +4 -6
- package/dist/integration.cjs +234 -147
- package/dist/integrations/openapi-extractor.d.ts +11 -3
- package/dist/integrations/openapi.d.ts +4 -2
- package/dist/lint.cjs +57 -17
- package/dist/react.cjs +234 -147
- 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/use-cases/scaffold-react-page.d.ts +7 -0
- 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/38.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import node_fs from "node:fs";
|
|
2
2
|
import node_path from "node:path";
|
|
3
|
-
import { defaultDependencyRules, fileModuleKind, namedImportFiles, canDependOn, isCrossContextImplementation, findWiredModules, moduleKindOf, readWiredModule, crossContextImportAllowed, compilerOption,
|
|
3
|
+
import { defaultDependencyRules, fileModuleKind, namedImportFiles, canDependOn, isCrossContextImplementation, findWiredModules, wiredDependencyNames, boundedContextPath, moduleKindOf, splitContextSegments, readWiredModule, crossContextImportAllowed, compilerOption, boundedContextNames } from "./201.js";
|
|
4
4
|
const readAliases = (projectRoot)=>{
|
|
5
5
|
const tsconfig = node_path.join(projectRoot, 'tsconfig.json');
|
|
6
6
|
const paths = compilerOption(tsconfig, 'paths');
|
|
@@ -104,12 +104,16 @@ const importViolations = (projectRoot, rootFolder, rules)=>{
|
|
|
104
104
|
const inMemoryDbFile = node_path.join(sharedFolder, 'infrastructure', 'services', 'in-memory-db-infrastructure-service.ts');
|
|
105
105
|
const aliases = readAliases(projectRoot);
|
|
106
106
|
const violations = [];
|
|
107
|
+
const contextOf = (file)=>{
|
|
108
|
+
const segments = inside(contextsFolder, file);
|
|
109
|
+
return segments && splitContextSegments(segments).name;
|
|
110
|
+
};
|
|
107
111
|
const locate = (file)=>{
|
|
108
112
|
const inContext = inside(contextsFolder, file);
|
|
109
113
|
if (inContext && inContext.length > 1) {
|
|
110
|
-
const
|
|
114
|
+
const { name, segments } = splitContextSegments(inContext);
|
|
111
115
|
return {
|
|
112
|
-
owner,
|
|
116
|
+
owner: name,
|
|
113
117
|
segments
|
|
114
118
|
};
|
|
115
119
|
}
|
|
@@ -148,8 +152,8 @@ const importViolations = (projectRoot, rootFolder, rules)=>{
|
|
|
148
152
|
line: 1,
|
|
149
153
|
text: node_path.basename(file)
|
|
150
154
|
});
|
|
151
|
-
const ownContext =
|
|
152
|
-
const directWiring = ownContext && from?.segments[0] === 'wiring' && readWiredModule(file,
|
|
155
|
+
const ownContext = contextOf(file);
|
|
156
|
+
const directWiring = ownContext && from?.segments[0] === 'wiring' && readWiredModule(file, boundedContextPath(contextsFolder, ownContext))?.implementations.some((implementation)=>isCrossContextImplementation(implementation.file));
|
|
153
157
|
const report = (check, rule, imported)=>violations.push({
|
|
154
158
|
check,
|
|
155
159
|
rule,
|
|
@@ -161,7 +165,7 @@ const importViolations = (projectRoot, rootFolder, rules)=>{
|
|
|
161
165
|
const target = imported.target;
|
|
162
166
|
if (!target) continue;
|
|
163
167
|
const to = locate(target);
|
|
164
|
-
const targetContext =
|
|
168
|
+
const targetContext = contextOf(target);
|
|
165
169
|
const crossContextAllowed = true === crossContextImportAllowed(file, target) && (from?.segments[0] !== 'wiring' || directWiring);
|
|
166
170
|
if (ownContext) {
|
|
167
171
|
if (targetContext && targetContext !== ownContext && !crossContextAllowed) report('context-isolation', `[${ownContext}] imports another context:`, imported);
|
|
@@ -210,12 +214,10 @@ const wiringViolations = (projectRoot, rootFolder, rules)=>{
|
|
|
210
214
|
name: 'shared-kernel',
|
|
211
215
|
modules: sharedModules
|
|
212
216
|
},
|
|
213
|
-
...
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
modules: findWiredModules(node_path.join(contextsFolder, entry.name))
|
|
218
|
-
})) : []
|
|
217
|
+
...boundedContextNames(contextsFolder).map((name)=>({
|
|
218
|
+
name,
|
|
219
|
+
modules: findWiredModules(boundedContextPath(contextsFolder, name))
|
|
220
|
+
}))
|
|
219
221
|
];
|
|
220
222
|
const violations = [];
|
|
221
223
|
const allModules = new Map(owners.flatMap(({ modules })=>modules).map((module)=>[
|
|
@@ -276,7 +278,7 @@ const directReadViolations = (projectRoot, rootFolder)=>{
|
|
|
276
278
|
const root = node_path.resolve(projectRoot, rootFolder);
|
|
277
279
|
const folders = [
|
|
278
280
|
node_path.join(root, 'shared-kernel'),
|
|
279
|
-
...
|
|
281
|
+
...boundedContextNames(node_path.join(root, 'bounded-contexts')).map((name)=>boundedContextPath(node_path.join(root, 'bounded-contexts'), name))
|
|
280
282
|
].flatMap((folder)=>[
|
|
281
283
|
node_path.join(folder, 'domain'),
|
|
282
284
|
node_path.join(folder, 'application')
|
package/dist/561.js
CHANGED
|
@@ -2,7 +2,7 @@ import node_fs from "node:fs";
|
|
|
2
2
|
import node_path from "node:path";
|
|
3
3
|
import { parseArgs } from "node:util";
|
|
4
4
|
import zod from "zod";
|
|
5
|
-
import { implementationLabelSchema, availableDependencies, discardPendingChanges, findWiredModules, filesToOverwrite, ConfigFile, Folder, implementationKinds, ProjectRoot, pendingChanges, hasNeighboringBoundedContext } from "./201.js";
|
|
5
|
+
import { implementationLabelSchema, availableDependencies, discardPendingChanges, findWiredModules, filesToOverwrite, ConfigFile, Folder, implementationKinds, ProjectRoot, pendingChanges, hasNeighboringBoundedContext, boundedContextNames } from "./201.js";
|
|
6
6
|
import { scaffoldNewHandlersRestEndpoint, addIntegration, findContracts, helperImplementationTypes, scaffoldNewAggregateUseCase, scaffoldNewInfrastructureService, runWithAnswers, scaffoldNewCommand, scaffoldNewQuery, findReactModules, moveBackendUnitUseCase, scaffoldReactUIKitComponent, scaffoldReactSharedHook, moveReactModuleUseCase, reactKindTitles, deleteBackendUnitUseCase, integrationIds, scaffoldNewApplicationService, scaffoldNewImplementation, savedImplementations, RequestError, deleteReactModuleUseCase, rootControllerChoice, moduleId, assertAnswersConsumed, scaffoldNewDomainService, findRestEndpointGenerator, scaffoldNewErrorUseCase, scaffoldReactWidget, savePendingChanges, unitId, systemImplementationChoices, scaffoldReactPage, scaffoldNewPresentationService, scaffoldNewInfrastructureHelper, integrationSpecsAvailable, integrationSpecFile, findBackendUnits, scaffoldNewUseCase, integrationDescriptions, wireDependency, scaffoldNewDomainObject, scaffoldNewBoundedContextUseCase, scaffoldNewApplicationPort } from "./287.js";
|
|
7
7
|
import { restControllers } from "./115.js";
|
|
8
8
|
const agent_requests_name = implementationLabelSchema;
|
|
@@ -19,7 +19,7 @@ const common = {
|
|
|
19
19
|
dryRun: zod.boolean().optional()
|
|
20
20
|
};
|
|
21
21
|
const agent_requests_owner = {
|
|
22
|
-
context:
|
|
22
|
+
context: nestedName.describe('A bounded-context name (nested ones as paths, e.g. sales/orders), or shared-kernel.')
|
|
23
23
|
};
|
|
24
24
|
const wired = {
|
|
25
25
|
dependencies: dependencies.optional()
|
|
@@ -41,7 +41,7 @@ const agent_requests_operation = (value, shape)=>zod.strictObject({
|
|
|
41
41
|
const scaffoldRequestSchema = zod.discriminatedUnion('operation', [
|
|
42
42
|
agent_requests_operation('bounded-context', {
|
|
43
43
|
...common,
|
|
44
|
-
name:
|
|
44
|
+
name: nestedName.describe('Folders split by "/", e.g. sales/orders.').refine((value)=>'shared-kernel' !== value, 'shared-kernel is reserved for the Shared Kernel.')
|
|
45
45
|
}),
|
|
46
46
|
agent_requests_operation('aggregate', {
|
|
47
47
|
...named,
|
|
@@ -139,7 +139,7 @@ const scaffoldRequestSchema = zod.discriminatedUnion('operation', [
|
|
|
139
139
|
...common,
|
|
140
140
|
...agent_requests_owner,
|
|
141
141
|
module: id.describe('Exact unit ID from --describe.'),
|
|
142
|
-
targetContext:
|
|
142
|
+
targetContext: nestedName.optional(),
|
|
143
143
|
name: agent_requests_name.optional(),
|
|
144
144
|
aggregate: agent_requests_name.optional()
|
|
145
145
|
})
|
|
@@ -252,13 +252,13 @@ const ownerFolders = (root)=>{
|
|
|
252
252
|
'shared-kernel'
|
|
253
253
|
])
|
|
254
254
|
},
|
|
255
|
-
...source.subitem([
|
|
255
|
+
...boundedContextNames(source.subitem([
|
|
256
256
|
'bounded-contexts'
|
|
257
|
-
]).
|
|
257
|
+
]).path).map((name)=>({
|
|
258
258
|
name,
|
|
259
259
|
folder: source.subitem([
|
|
260
260
|
'bounded-contexts',
|
|
261
|
-
name
|
|
261
|
+
...name.split('/')
|
|
262
262
|
])
|
|
263
263
|
}))
|
|
264
264
|
];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const boundedContextsFolderName = "bounded-contexts";
|
|
2
|
+
/**
|
|
3
|
+
* Folders right in a bounded context. A context name can't use them as a
|
|
4
|
+
* segment: they tell a context from a folder grouping contexts.
|
|
5
|
+
*/
|
|
6
|
+
export declare const contextLayerFolders: string[];
|
|
7
|
+
/**
|
|
8
|
+
* A bounded context has a layer folder or no folders yet; any other
|
|
9
|
+
* folder groups contexts, like the folders of React pages and widgets.
|
|
10
|
+
*/
|
|
11
|
+
export declare const isBoundedContextFolder: (folder: string) => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Names of the bounded contexts in `<rootFolder>/bounded-contexts`,
|
|
14
|
+
* nested ones as paths (`sales/orders`), sorted.
|
|
15
|
+
*/
|
|
16
|
+
export declare const boundedContextNames: (contextsFolder: string) => string[];
|
|
17
|
+
export declare const boundedContextPath: (contextsFolder: string, name: string) => string;
|
|
18
|
+
/** `sales/orders` → `SalesOrders`, for names shared across contexts. */
|
|
19
|
+
export declare const contextClassName: (name: string) => string;
|
|
20
|
+
/**
|
|
21
|
+
* The context of the path segments below `bounded-contexts`: up to the
|
|
22
|
+
* first layer folder. Without one, the first segment, as before nesting.
|
|
23
|
+
*/
|
|
24
|
+
export declare const splitContextSegments: (segments: string[]) => {
|
|
25
|
+
name: string;
|
|
26
|
+
segments: string[];
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Where a context of the given name could be created: names are checked
|
|
30
|
+
* like page names, segments can't be layer folders, and a context can't
|
|
31
|
+
* hold or be part of another context.
|
|
32
|
+
*/
|
|
33
|
+
export declare const validateBoundedContextName: (contextsFolder: string, name: string) => string | true;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
export declare const crossContextImplementation = "cross-context";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Whether another bounded context exists anywhere under `bounded-contexts`,
|
|
4
|
+
* nested ones included.
|
|
5
|
+
*/
|
|
3
6
|
export declare const hasNeighboringBoundedContext: (ownerPath: string) => boolean;
|
|
4
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* A file inside a bounded context, including its project source root.
|
|
9
|
+
* A nested context is named by its path, e.g. `sales/orders`.
|
|
10
|
+
*/
|
|
5
11
|
export declare const boundedContextLocation: (file: string) => {
|
|
6
|
-
root: string;
|
|
7
12
|
name: string;
|
|
8
13
|
segments: string[];
|
|
14
|
+
root: string;
|
|
9
15
|
} | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* The name of the context in the folder (`sales/orders` when nested), or
|
|
18
|
+
* undefined for the Shared Kernel.
|
|
19
|
+
*/
|
|
20
|
+
export declare const boundedContextName: (folder: string) => string | undefined;
|
|
10
21
|
/** The reserved implementation type, determined by its infrastructure folder. */
|
|
11
22
|
export declare const isCrossContextImplementation: (file: string) => boolean;
|
|
12
23
|
/**
|
package/dist/graph.cjs
CHANGED
|
@@ -324,6 +324,36 @@ class ConfigFile {
|
|
|
324
324
|
new file_system_File(ConfigFile.path).update(`${JSON.stringify(config, null, 4)}\n`);
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
|
+
const contextLayerFolders = [
|
|
328
|
+
'domain',
|
|
329
|
+
'application',
|
|
330
|
+
'infrastructure',
|
|
331
|
+
'presentation',
|
|
332
|
+
'wiring'
|
|
333
|
+
];
|
|
334
|
+
const subfolders = (folder)=>external_node_fs_default().existsSync(folder) ? external_node_fs_default().readdirSync(folder, {
|
|
335
|
+
withFileTypes: true
|
|
336
|
+
}).filter((entry)=>entry.isDirectory()).map((entry)=>entry.name) : [];
|
|
337
|
+
const isBoundedContextFolder = (folder)=>{
|
|
338
|
+
const names = subfolders(folder);
|
|
339
|
+
return !names.length || names.some((name)=>contextLayerFolders.includes(name));
|
|
340
|
+
};
|
|
341
|
+
const bounded_contexts_boundedContextNames = (contextsFolder)=>{
|
|
342
|
+
const walk = (folder, prefix)=>subfolders(folder).flatMap((name)=>{
|
|
343
|
+
const child = external_node_path_default().join(folder, name);
|
|
344
|
+
return isBoundedContextFolder(child) ? [
|
|
345
|
+
[
|
|
346
|
+
...prefix,
|
|
347
|
+
name
|
|
348
|
+
].join('/')
|
|
349
|
+
] : walk(child, [
|
|
350
|
+
...prefix,
|
|
351
|
+
name
|
|
352
|
+
]);
|
|
353
|
+
});
|
|
354
|
+
return walk(contextsFolder, []).sort();
|
|
355
|
+
};
|
|
356
|
+
const bounded_contexts_boundedContextPath = (contextsFolder, name)=>external_node_path_default().join(contextsFolder, ...name.split('/'));
|
|
327
357
|
const external_node_module_namespaceObject = require("node:module");
|
|
328
358
|
const stripJsonComments = (source)=>source.replace(/("(?:\\.|[^"\\])*")|\/\/[^\n]*|\/\*[\s\S]*?\*\//g, (_, text)=>text ? text : '').replace(/,(\s*[}\]])/g, '$1');
|
|
329
359
|
const resolveExtends = (fromFile, target)=>{
|
|
@@ -358,7 +388,7 @@ const compilerOption = (configFile, name, seen = new Set())=>{
|
|
|
358
388
|
if (void 0 !== value) return value;
|
|
359
389
|
}
|
|
360
390
|
};
|
|
361
|
-
class
|
|
391
|
+
class UnknownFormatNaming {
|
|
362
392
|
rawSource;
|
|
363
393
|
camelCase;
|
|
364
394
|
PascalCase;
|
|
@@ -453,7 +483,7 @@ const wiring_readWiredModule = (wireFile, contextPath)=>{
|
|
|
453
483
|
const wiringRelativePath = external_node_path_default().relative(external_node_path_default().join(contextPath, 'wiring'), wireFile);
|
|
454
484
|
if (isEndpointWire(wiringRelativePath)) return;
|
|
455
485
|
const source = new file_system_File(wireFile).data;
|
|
456
|
-
const wireName = `wire${new
|
|
486
|
+
const wireName = `wire${new UnknownFormatNaming(external_node_path_default().basename(wireFile, '.ts').replace(/^wire-/, '')).ClassName}`;
|
|
457
487
|
const exportMatch = new RegExp(`export\\s+const\\s+${wireName}\\s*=\\s*`).exec(source);
|
|
458
488
|
if (!exportMatch) return;
|
|
459
489
|
const branched = source.slice(exportMatch.index + exportMatch[0].length).startsWith('envBranchedWire(');
|
|
@@ -623,9 +653,7 @@ const resolveSpecifier = (specifier, fromFile, aliases)=>{
|
|
|
623
653
|
for (const { prefix, wildcard, target } of aliases)if (wildcard ? specifier.startsWith(prefix) : specifier === prefix) return external_node_path_default().join(target, wildcard ? specifier.slice(prefix.length) : '');
|
|
624
654
|
};
|
|
625
655
|
const sharedKernel = 'shared-kernel';
|
|
626
|
-
const contextsOf =
|
|
627
|
-
withFileTypes: true
|
|
628
|
-
}).filter((entry)=>entry.isDirectory()).map((entry)=>entry.name).sort() : [];
|
|
656
|
+
const contextsOf = bounded_contexts_boundedContextNames;
|
|
629
657
|
const projectGraph = (projectRoot, rootFolder)=>{
|
|
630
658
|
const root = external_node_path_default().resolve(projectRoot, rootFolder);
|
|
631
659
|
const contextsFolder = external_node_path_default().join(root, 'bounded-contexts');
|
|
@@ -633,7 +661,7 @@ const projectGraph = (projectRoot, rootFolder)=>{
|
|
|
633
661
|
sharedKernel,
|
|
634
662
|
...contextsOf(contextsFolder)
|
|
635
663
|
];
|
|
636
|
-
const ownerPath = (owner)=>owner === sharedKernel ? external_node_path_default().join(root, sharedKernel) :
|
|
664
|
+
const ownerPath = (owner)=>owner === sharedKernel ? external_node_path_default().join(root, sharedKernel) : bounded_contexts_boundedContextPath(contextsFolder, owner);
|
|
637
665
|
const byWireFile = new Map();
|
|
638
666
|
const wired = [];
|
|
639
667
|
for (const owner of owners)for (const module of wiring_findWiredModules(ownerPath(owner))){
|
package/dist/graph.js
CHANGED
|
@@ -4,12 +4,10 @@ import node_fs from "node:fs";
|
|
|
4
4
|
import node_os from "node:os";
|
|
5
5
|
import node_path from "node:path";
|
|
6
6
|
import { parseArgs } from "node:util";
|
|
7
|
-
import { namedImportFiles, wiring_layers, findWiredModules,
|
|
7
|
+
import { namedImportFiles, wiring_layers, findWiredModules, ConfigFile, boundedContextPath, outdatedConfigMessage, File, ProjectRoot, wiredDependencyNames, boundedContextNames } from "./201.js";
|
|
8
8
|
import { readAliases, resolveSpecifier } from "./38.js";
|
|
9
9
|
const sharedKernel = 'shared-kernel';
|
|
10
|
-
const contextsOf =
|
|
11
|
-
withFileTypes: true
|
|
12
|
-
}).filter((entry)=>entry.isDirectory()).map((entry)=>entry.name).sort() : [];
|
|
10
|
+
const contextsOf = boundedContextNames;
|
|
13
11
|
const projectGraph = (projectRoot, rootFolder)=>{
|
|
14
12
|
const root = node_path.resolve(projectRoot, rootFolder);
|
|
15
13
|
const contextsFolder = node_path.join(root, 'bounded-contexts');
|
|
@@ -17,7 +15,7 @@ const projectGraph = (projectRoot, rootFolder)=>{
|
|
|
17
15
|
sharedKernel,
|
|
18
16
|
...contextsOf(contextsFolder)
|
|
19
17
|
];
|
|
20
|
-
const ownerPath = (owner)=>owner === sharedKernel ? node_path.join(root, sharedKernel) :
|
|
18
|
+
const ownerPath = (owner)=>owner === sharedKernel ? node_path.join(root, sharedKernel) : boundedContextPath(contextsFolder, owner);
|
|
21
19
|
const byWireFile = new Map();
|
|
22
20
|
const wired = [];
|
|
23
21
|
for (const owner of owners)for (const module of findWiredModules(ownerPath(owner))){
|