@domain-first/project-structure 8.5.0 → 8.6.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/526.js ADDED
@@ -0,0 +1,376 @@
1
+ import node_path from "node:path";
2
+ import node_fs from "node:fs";
3
+ import { ProjectRoot, File, stripJsonComments, ConfigFile } from "./780.js";
4
+ const hasDependency = (name)=>{
5
+ const manifestFile = new File(node_path.join(new ProjectRoot().path, 'package.json'));
6
+ if (!manifestFile.exists) return false;
7
+ const manifest = JSON.parse(manifestFile.data);
8
+ return [
9
+ manifest.dependencies,
10
+ manifest.devDependencies,
11
+ manifest.optionalDependencies
12
+ ].some((dependencies)=>dependencies && Object.hasOwn(dependencies, name));
13
+ };
14
+ const missingPackages = (packages)=>{
15
+ const missing = [
16
+ ...new Set(packages)
17
+ ].filter((name)=>!hasDependency(name));
18
+ return missing.length ? [
19
+ `npm i ${missing.join(' ')}`
20
+ ] : [];
21
+ };
22
+ const missingDomainFirstPackages = ()=>missingPackages(ConfigFile.backend.domainFirstPackages);
23
+ const openapiExtractorPath = "scripts/extract-open-api-data-from-endpoint.ts";
24
+ const rootFolderSegments = (rootFolder, indent = 20)=>rootFolder.split(/[\\/]/).map((segment)=>segment.trim()).filter((segment)=>!!segment && '.' !== segment).map((segment)=>`'${segment}',\n${' '.repeat(indent)}`).join('');
25
+ const legacyEndpointFileLookup = (rootFolder)=>` // The controller, if any, is the first folder of the path:
26
+ // context-root endpoints live right in presentation/rest.
27
+ const [currentBoundedContext, ...relativePath] = routeMetadata.path;
28
+
29
+ if (!currentBoundedContext) {
30
+ return undefined;
31
+ }
32
+
33
+ const endpointFile = project.getSourceFile(
34
+ path.join(
35
+ ${rootFolderSegments(rootFolder)}'bounded-contexts',
36
+ currentBoundedContext,
37
+ 'presentation',
38
+ 'rest',
39
+ ...relativePath.map(pathParameterAsName),
40
+ \`\${routeMetadata.method.toUpperCase()}.ts\`
41
+ )
42
+ );
43
+ `;
44
+ const endpointFileLookup = (rootFolder)=>` const [currentBoundedContext, ...relativePath] = routeMetadata.path;
45
+
46
+ if (!currentBoundedContext) {
47
+ return undefined;
48
+ }
49
+
50
+ // A controller is the first folder of the path; other routes
51
+ // belong to the context root in presentation/rest/(root).
52
+ const restFolder = path.join(
53
+ ${rootFolderSegments(rootFolder, 16)}'bounded-contexts',
54
+ currentBoundedContext,
55
+ 'presentation',
56
+ 'rest'
57
+ );
58
+ const endpointPath = [
59
+ ...relativePath.map(pathParameterAsName),
60
+ \`\${routeMetadata.method.toUpperCase()}.ts\`
61
+ ];
62
+ const endpointFile =
63
+ project.getSourceFile(path.join(restFolder, ...endpointPath)) ??
64
+ project.getSourceFile(
65
+ path.join(restFolder, '(root)', ...endpointPath)
66
+ );
67
+ `;
68
+ const openapiExtractor = (rootFolder)=>`import path from 'node:path';
69
+ import {
70
+ type DocNode,
71
+ DocPlainText,
72
+ TSDocConfiguration,
73
+ TSDocParser,
74
+ TSDocTagDefinition,
75
+ TSDocTagSyntaxKind
76
+ } from '@microsoft/tsdoc';
77
+ import { Node, Project, type SourceFile, SyntaxKind } from 'ts-morph';
78
+
79
+ type BlockTag = \`@\${string}\`;
80
+
81
+ type OpenApiDataTags = {
82
+ /** Omit to take the summary from the comment text before the first tag. */
83
+ summary?: BlockTag;
84
+ description?: BlockTag;
85
+ };
86
+
87
+ type OpenApiData = Partial<{
88
+ summary: string;
89
+ description: string;
90
+ operationId: string;
91
+ }>;
92
+
93
+ const project = new Project({
94
+ tsConfigFilePath: 'tsconfig.json'
95
+ });
96
+
97
+ const getText = (node: DocNode): string =>
98
+ node
99
+ .getChildNodes()
100
+ .map((child) => {
101
+ if (child instanceof DocPlainText) {
102
+ return child.text;
103
+ }
104
+
105
+ return getText(child);
106
+ })
107
+ .join('');
108
+
109
+ const getRawCommentText = (comment: string): string =>
110
+ comment
111
+ .replace(/^\\/\\*\\*/, '')
112
+ .replace(/\\*\\/$/, '')
113
+ .split(/\\r?\\n/)
114
+ .map((line) => line.replace(/^\\s*\\*\\s?/, ''))
115
+ .join('\\n');
116
+
117
+ // TSDoc treats an unknown tag as summary content, so every block tag of the
118
+ // comment has to be registered for the summary section to end before it.
119
+ const parseSummary = (comment: string): string | undefined => {
120
+ const configuration = new TSDocConfiguration();
121
+ const tagNames = getRawCommentText(comment).matchAll(/(?:^|\\n)\\s*(@\\w+)/g);
122
+
123
+ for (const [, tagName] of tagNames) {
124
+ if (!configuration.tryGetTagDefinition(tagName)) {
125
+ configuration.addTagDefinition(
126
+ new TSDocTagDefinition({
127
+ tagName,
128
+ syntaxKind: TSDocTagSyntaxKind.BlockTag
129
+ })
130
+ );
131
+ }
132
+ }
133
+
134
+ const { docComment } = new TSDocParser(configuration).parseString(comment);
135
+
136
+ return getText(docComment.summarySection).trim() || undefined;
137
+ };
138
+
139
+ // Parsed by hand rather than through TSDoc, which drops the line breaks.
140
+ const getTagText = (comment: string, tag: BlockTag): string | undefined => {
141
+ const tagMatch = getRawCommentText(comment).match(
142
+ new RegExp(
143
+ \`(?:^|\\\\n)\\\\s*\${tag}(?:[ \\\\t]*\\\\n|[ \\\\t]+)([\\\\s\\\\S]*?)(?=\\\\n\\\\s*@\\\\w+|\\\\s*$)\`
144
+ )
145
+ );
146
+
147
+ return tagMatch?.[1].trim() || undefined;
148
+ };
149
+
150
+ // Endpoints pass their logic as the generator's first argument
151
+ // (\`this.endpointGenerator(this.handler.handle, ...)\`), while other injected
152
+ // queries only serve as helpers, e.g. guest checks.
153
+ const findHandlerClass = (endpointFile: SourceFile) =>
154
+ endpointFile
155
+ .getDescendantsOfKind(SyntaxKind.CallExpression)
156
+ .map((call) => call.getArguments()[0])
157
+ .filter(Node.isPropertyAccessExpression)
158
+ .find((argument) => argument.getName() === 'handle')
159
+ ?.getExpression()
160
+ .getType()
161
+ .getSymbol()
162
+ ?.getDeclarations()
163
+ .find(Node.isClassDeclaration);
164
+
165
+ // Path parameters (\`:id\`) can't be part of file and folder names
166
+ // everywhere (Windows), so endpoints name them \`_id_\` there.
167
+ const pathParameterAsName = (segment: string) =>
168
+ segment.startsWith(':') ? \`_\${segment.slice(1)}_\` : segment;
169
+
170
+ export const createOpenApiDataFromEndpointLogicExtractor = ({
171
+ summary: summaryTag,
172
+ description: descriptionTag = '@description'
173
+ }: OpenApiDataTags = {}) => {
174
+ return (routeMetadata: {
175
+ method: string;
176
+ path: readonly string[];
177
+ }): OpenApiData | undefined => {
178
+ try {
179
+ ${endpointFileLookup(rootFolder)}
180
+ if (!endpointFile) {
181
+ return undefined;
182
+ }
183
+
184
+ const declaration = findHandlerClass(endpointFile);
185
+ const operationId = declaration?.getName();
186
+ const comment = declaration?.getJsDocs().at(-1)?.getText();
187
+
188
+ if (!comment) {
189
+ return { operationId };
190
+ }
191
+
192
+ return {
193
+ summary: summaryTag
194
+ ? getTagText(comment, summaryTag)
195
+ : parseSummary(comment),
196
+ description: getTagText(comment, descriptionTag),
197
+ operationId
198
+ };
199
+ } catch (e: unknown) {
200
+ console.error(e);
201
+ return undefined;
202
+ }
203
+ };
204
+ };
205
+ `;
206
+ const ignoredFolders = new Set([
207
+ 'node_modules',
208
+ '.git',
209
+ '.next',
210
+ 'dist',
211
+ 'build',
212
+ 'out',
213
+ 'coverage',
214
+ 'storybook-static'
215
+ ]);
216
+ const codeExtension = /\.(?:tsx?|mts|cts|jsx?|mjs|cjs|mdx)$/;
217
+ const escapeRegExp = (value)=>value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
218
+ const walk = (folder)=>{
219
+ if (!node_fs.existsSync(folder)) return [];
220
+ return node_fs.readdirSync(folder, {
221
+ withFileTypes: true
222
+ }).flatMap((entry)=>{
223
+ const entryPath = node_path.join(folder, entry.name);
224
+ if (entry.isDirectory()) return ignoredFolders.has(entry.name) ? [] : walk(entryPath);
225
+ return entry.isFile() ? [
226
+ entryPath
227
+ ] : [];
228
+ });
229
+ };
230
+ const toPosix = (value)=>value.split(node_path.sep).join('/');
231
+ const readAliases = (projectRoot)=>{
232
+ const tsconfig = node_path.join(projectRoot, 'tsconfig.json');
233
+ if (!node_fs.existsSync(tsconfig)) return [];
234
+ try {
235
+ const { compilerOptions = {} } = JSON.parse(stripJsonComments(node_fs.readFileSync(tsconfig, 'utf8')));
236
+ const base = node_path.resolve(projectRoot, compilerOptions.baseUrl ?? '.');
237
+ return Object.entries(compilerOptions.paths ?? {}).filter(([pattern, targets])=>pattern.endsWith('*') && targets[0]?.endsWith('*')).map(([pattern, [target]])=>({
238
+ prefix: pattern.slice(0, -1),
239
+ target: node_path.resolve(base, target.slice(0, -1))
240
+ }));
241
+ } catch {
242
+ return [];
243
+ }
244
+ };
245
+ const specifierPattern = /(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+|\brequire\s*\(\s*|\bmock\s*\(\s*)(['"])([^'"\n]+)\2/g;
246
+ const reExportPattern = /\bexport\s+(?:type\s+)?(?:\*(?:\s+as\s+[\w$]+)?|\{[^}]*\})\s*from\s*(['"])([^'"\n]+)\1/g;
247
+ const importPaths = (file)=>{
248
+ const withoutExtension = file.replace(codeExtension, '');
249
+ return 'index' === node_path.basename(withoutExtension) ? [
250
+ withoutExtension,
251
+ node_path.dirname(withoutExtension)
252
+ ] : [
253
+ withoutExtension
254
+ ];
255
+ };
256
+ const projectImports = (projectRoot)=>{
257
+ const aliases = readAliases(projectRoot);
258
+ const resolve = (specifier, fromFile)=>{
259
+ if (specifier.startsWith('.')) return {
260
+ resolved: node_path.resolve(node_path.dirname(fromFile), specifier),
261
+ alias: void 0
262
+ };
263
+ const alias = aliases.find(({ prefix })=>specifier.startsWith(prefix));
264
+ return alias ? {
265
+ resolved: node_path.resolve(alias.target, specifier.slice(alias.prefix.length)),
266
+ alias
267
+ } : void 0;
268
+ };
269
+ const specifierFor = (fromFile, toPath, alias)=>{
270
+ const aliased = alias && toPosix(node_path.relative(alias.target, toPath));
271
+ if (aliased && !aliased.startsWith('..')) return `${alias.prefix}${aliased}`;
272
+ const relative = toPosix(node_path.relative(node_path.dirname(fromFile), toPath));
273
+ return relative.startsWith('.') ? relative : `./${relative}`;
274
+ };
275
+ const codeFiles = new Map(walk(projectRoot).filter((file)=>codeExtension.test(file)).map((file)=>[
276
+ file,
277
+ node_fs.readFileSync(file, 'utf8')
278
+ ]));
279
+ const importsOf = (file)=>[
280
+ ...(codeFiles.get(file) ?? '').matchAll(specifierPattern)
281
+ ].map(([, , , specifier])=>resolve(specifier, file)?.resolved).filter((resolved)=>!!resolved);
282
+ return {
283
+ resolve,
284
+ specifierFor,
285
+ codeFiles,
286
+ importsOf
287
+ };
288
+ };
289
+ const stageModuleMove = ({ projectRoot, stopAt, moves, movedPath, rename, everyFile = (content)=>content, stopAtFor })=>{
290
+ const stopFor = (file)=>stopAtFor?.(file) ?? stopAt;
291
+ const { resolve, specifierFor, codeFiles } = projectImports(projectRoot);
292
+ const barrels = new Set();
293
+ const isBarrel = (resolved)=>barrels.has(resolved.replace(codeExtension, ''));
294
+ for(let found = true; found;){
295
+ found = false;
296
+ for (const [file, content] of codeFiles){
297
+ if (moves.has(file) || isBarrel(file)) continue;
298
+ const reExportsModule = [
299
+ ...content.matchAll(reExportPattern)
300
+ ].some(([, , specifier])=>{
301
+ const resolution = resolve(specifier, file);
302
+ return !!resolution && (!!movedPath(resolution.resolved) || isBarrel(resolution.resolved));
303
+ });
304
+ if (reExportsModule) {
305
+ for (const importPath of importPaths(file))barrels.add(importPath);
306
+ found = true;
307
+ }
308
+ }
309
+ }
310
+ const rewrite = (content, oldFile, newFile)=>{
311
+ let referencesModule = false;
312
+ const rewritten = content.replace(specifierPattern, (match, keyword, quote, specifier)=>{
313
+ const resolution = resolve(specifier, oldFile);
314
+ if (!resolution) return match;
315
+ const moved = movedPath(resolution.resolved);
316
+ if (moved || isBarrel(resolution.resolved)) referencesModule = true;
317
+ if (!moved && oldFile === newFile) return match;
318
+ const next = specifierFor(newFile, moved ?? resolution.resolved, resolution.alias);
319
+ return `${keyword}${quote}${next}${quote}`;
320
+ });
321
+ const changed = everyFile(rewritten);
322
+ if (!referencesModule && !moves.has(oldFile)) return changed;
323
+ return rename(changed, {
324
+ moved: moves.has(oldFile)
325
+ });
326
+ };
327
+ for (const [file, newFile] of moves)if (!codeFiles.has(file) && newFile !== file) new File(file).moveTo(newFile, stopFor(file));
328
+ const updated = [];
329
+ for (const [file, content] of codeFiles){
330
+ const newFile = moves.get(file);
331
+ const next = rewrite(content, file, newFile ?? file);
332
+ if (newFile && newFile !== file) {
333
+ new File(newFile).data = next;
334
+ new File(file).delete(stopFor(file));
335
+ } else if (next !== content) {
336
+ new File(file).update(next);
337
+ if (!newFile) updated.push(file);
338
+ }
339
+ }
340
+ return {
341
+ moves: [
342
+ ...moves
343
+ ].filter(([from, to])=>from !== to),
344
+ updated
345
+ };
346
+ };
347
+ const rootControllerFolder = '(root)';
348
+ const pathParameterAsName = (segment)=>segment.startsWith(':') ? `_${segment.slice(1)}_` : segment;
349
+ const isPathParameterName = (name)=>name.startsWith(':') || /^_.+_$/.test(name);
350
+ const endpointFileNames = new Set([
351
+ 'get',
352
+ 'post',
353
+ 'put',
354
+ 'patch',
355
+ 'delete'
356
+ ].map((method)=>`${method.toUpperCase()}.ts`));
357
+ const entries = (folder)=>node_fs.existsSync(folder) ? node_fs.readdirSync(folder, {
358
+ withFileTypes: true
359
+ }) : [];
360
+ const subfolders = (folder)=>entries(folder).filter((entry)=>entry.isDirectory()).map((entry)=>entry.name);
361
+ const restFolders = (boundedContextFolder)=>({
362
+ presentation: node_path.join(boundedContextFolder, 'presentation', 'rest'),
363
+ wiring: node_path.join(boundedContextFolder, 'wiring', 'presentation', 'rest')
364
+ });
365
+ const restControllers = (boundedContextFolder)=>subfolders(restFolders(boundedContextFolder).presentation).filter((name)=>name !== rootControllerFolder && !isPathParameterName(name));
366
+ const rootStaticSegments = (boundedContextFolder)=>subfolders(node_path.join(restFolders(boundedContextFolder).presentation, rootControllerFolder)).filter((name)=>!isPathParameterName(name));
367
+ const legacyRootEndpoints = (boundedContextFolder)=>{
368
+ const { presentation, wiring } = restFolders(boundedContextFolder);
369
+ return {
370
+ endpointFiles: entries(presentation).filter((entry)=>entry.isFile() && endpointFileNames.has(entry.name)).map((entry)=>node_path.join(presentation, entry.name)),
371
+ parameterFolders: subfolders(presentation).filter(isPathParameterName).map((name)=>node_path.join(presentation, name)),
372
+ wireFiles: entries(wiring).filter((entry)=>entry.isFile() && 'index.ts' !== entry.name && /\.ts$/.test(entry.name)).map((entry)=>node_path.join(wiring, entry.name))
373
+ };
374
+ };
375
+ const hasLegacyRootEndpoints = (boundedContextFolder)=>Object.values(legacyRootEndpoints(boundedContextFolder)).some((paths)=>paths.length > 0);
376
+ export { codeExtension, endpointFileLookup, escapeRegExp, hasDependency, hasLegacyRootEndpoints, isPathParameterName, legacyEndpointFileLookup, legacyRootEndpoints, missingDomainFirstPackages, missingPackages, openapiExtractor, openapiExtractorPath, pathParameterAsName, projectImports, restControllers, restFolders, rootStaticSegments, stageModuleMove, toPosix, walk };
package/dist/561.js CHANGED
@@ -2,9 +2,10 @@ 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, discardPendingChanges, filesToOverwrite, ConfigFile, Folder, implementationKinds, ProjectRoot, pendingChanges } from "./870.js";
6
- import { scaffoldNewHandlersRestEndpoint, addIntegration, findContracts, scaffoldNewAggregateUseCase, scaffoldNewInfrastructureService, scaffoldNewQuery, runWithAnswers, scaffoldNewCommand, moveBackendUnitUseCase, findReactModules, scaffoldReactUIKitComponent, scaffoldReactSharedHook, moveReactModuleUseCase, reactKindTitles, deleteBackendUnitUseCase, integrationIds, scaffoldNewImplementation, scaffoldNewApplicationService, savedImplementations, RequestError, deleteReactModuleUseCase, moduleId, assertAnswersConsumed, scaffoldNewDomainService, findRestEndpointGenerator, scaffoldNewErrorUseCase, scaffoldReactWidget, savePendingChanges, unitId, systemImplementationChoices, scaffoldReactPage, scaffoldNewPresentationService, findBackendUnits, scaffoldNewUseCase, integrationDescriptions, wireDependency, scaffoldNewDomainObject, scaffoldNewBoundedContextUseCase, scaffoldNewApplicationPort } from "./287.js";
7
- import { findWiredModules, availableDependencies, hasNeighboringBoundedContext } from "./201.js";
5
+ import { implementationLabelSchema, discardPendingChanges, filesToOverwrite, ConfigFile, Folder, implementationKinds, ProjectRoot, pendingChanges } from "./780.js";
6
+ import { scaffoldNewHandlersRestEndpoint, addIntegration, findContracts, scaffoldNewAggregateUseCase, scaffoldNewInfrastructureService, scaffoldNewQuery, runWithAnswers, scaffoldNewCommand, moveBackendUnitUseCase, findReactModules, scaffoldReactUIKitComponent, scaffoldReactSharedHook, moveReactModuleUseCase, reactKindTitles, deleteBackendUnitUseCase, integrationIds, scaffoldNewApplicationService, scaffoldNewImplementation, savedImplementations, RequestError, deleteReactModuleUseCase, rootControllerChoice, moduleId, assertAnswersConsumed, scaffoldNewDomainService, findRestEndpointGenerator, scaffoldNewErrorUseCase, scaffoldReactWidget, savePendingChanges, unitId, systemImplementationChoices, scaffoldReactPage, scaffoldNewPresentationService, findBackendUnits, scaffoldNewUseCase, integrationDescriptions, wireDependency, scaffoldNewDomainObject, scaffoldNewBoundedContextUseCase, scaffoldNewApplicationPort } from "./287.js";
7
+ import { findWiredModules, availableDependencies, hasNeighboringBoundedContext } from "./947.js";
8
+ import { restControllers } from "./526.js";
8
9
  const agent_requests_name = implementationLabelSchema;
9
10
  const nestedName = zod.string().regex(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*(?:\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*)*$/);
10
11
  const id = zod.string().min(1);
@@ -105,7 +106,7 @@ const scaffoldRequestSchema = zod.discriminatedUnion('operation', [
105
106
  agent_requests_operation('endpoint', {
106
107
  ...common,
107
108
  ...agent_requests_owner,
108
- controller: agent_requests_name,
109
+ controller: agent_requests_name.optional().describe('Omit for the context-root controller (root): `/<context>/<path>`.'),
109
110
  method: zod["enum"]([
110
111
  'get',
111
112
  'post',
@@ -369,12 +370,12 @@ const answersFor = (command, request, owner)=>{
369
370
  if ('error' === request.operation || 'error-namespace' === request.operation) defaults.errorAction = 'error-namespace' === request.operation ? 'New namespace' : request.namespace ? `New error in namespace ${request.namespace}` : 'New error without namespace';
370
371
  if ('endpoint' === request.operation) {
371
372
  delete answers.controller;
372
- const existing = owner.subitem([
373
- 'presentation',
374
- 'rest'
375
- ]).content.subfolderNames.includes(request.controller);
376
- answers.controllerSelection = existing ? request.controller : 'New controller';
377
- if (!existing) answers.controllerName = request.controller;
373
+ if (void 0 === request.controller) answers.controllerSelection = rootControllerChoice;
374
+ else {
375
+ const existing = restControllers(owner.path).includes(request.controller);
376
+ answers.controllerSelection = existing ? request.controller : 'New controller';
377
+ if (!existing) answers.controllerName = request.controller;
378
+ }
378
379
  }
379
380
  if ('move' === request.operation) defaults.targetContext = request.context;
380
381
  }
@@ -1,6 +1,7 @@
1
1
  import zod from "zod";
2
2
  import node_path from "node:path";
3
3
  import node_fs from "node:fs";
4
+ import { createRequire } from "node:module";
4
5
  const implementationKinds = [
5
6
  'repositories',
6
7
  'commands',
@@ -436,4 +437,37 @@ class ConfigFile {
436
437
  }
437
438
  }
438
439
  const configuredDependencyRules = ()=>resolveDependencyRules(ConfigFile.exists ? ConfigFile.Instance.data.backend?.rules?.dependencies : void 0);
439
- export { ConfigFile, File, Folder, ProjectRoot, branchNameSchema, configFileName, configSchema, configuredDependencyRules, defaultDependencyRules, discardPendingChanges, domainFirstPackages, fileModuleKind, filesToOverwrite, implementationKinds, implementationLabelSchema, isOutdatedConfig, outdatedConfigMessage, pendingChanges, rulesSchema, scaffoldBackendRules, wiredModuleKind, withoutOverwrites, writePendingChanges };
440
+ const stripJsonComments = (source)=>source.replace(/("(?:\\.|[^"\\])*")|\/\/[^\n]*|\/\*[\s\S]*?\*\//g, (_, text)=>text ? text : '').replace(/,(\s*[}\]])/g, '$1');
441
+ const resolveExtends = (fromFile, target)=>{
442
+ if (target.startsWith('.') || node_path.isAbsolute(target)) {
443
+ const resolved = node_path.resolve(node_path.dirname(fromFile), target);
444
+ return resolved.endsWith('.json') ? resolved : `${resolved}.json`;
445
+ }
446
+ const require = createRequire(fromFile);
447
+ for (const candidate of [
448
+ target,
449
+ `${target}/tsconfig.json`
450
+ ])try {
451
+ return require.resolve(candidate);
452
+ } catch {}
453
+ };
454
+ const compilerOption = (configFile, name, seen = new Set())=>{
455
+ if (seen.has(configFile) || !node_fs.existsSync(configFile)) return null;
456
+ seen.add(configFile);
457
+ let config;
458
+ try {
459
+ config = JSON.parse(stripJsonComments(node_fs.readFileSync(configFile, 'utf8')));
460
+ } catch {
461
+ return null;
462
+ }
463
+ if (config.compilerOptions && name in config.compilerOptions) return config.compilerOptions[name];
464
+ const parents = [
465
+ config.extends ?? []
466
+ ].flat().reverse();
467
+ for (const parent of parents){
468
+ const parentFile = resolveExtends(configFile, parent);
469
+ const value = parentFile ? compilerOption(parentFile, name, seen) : null;
470
+ if (void 0 !== value) return value;
471
+ }
472
+ };
473
+ export { ConfigFile, File, Folder, ProjectRoot, branchNameSchema, compilerOption, configFileName, configSchema, configuredDependencyRules, defaultDependencyRules, discardPendingChanges, domainFirstPackages, fileModuleKind, filesToOverwrite, implementationKinds, implementationLabelSchema, isOutdatedConfig, outdatedConfigMessage, pendingChanges, rulesSchema, scaffoldBackendRules, stripJsonComments, wiredModuleKind, withoutOverwrites, writePendingChanges };
@@ -1,7 +1,6 @@
1
1
  import node_fs from "node:fs";
2
2
  import node_path from "node:path";
3
- import { createRequire } from "node:module";
4
- import { defaultDependencyRules, configuredDependencyRules, wiredModuleKind, File } from "./870.js";
3
+ import { defaultDependencyRules, configuredDependencyRules, wiredModuleKind, File } from "./780.js";
5
4
  const crossContextImplementation = 'cross-context';
6
5
  const hasNeighboringBoundedContext = (ownerPath)=>{
7
6
  const contextsPath = node_path.dirname(ownerPath);
@@ -466,37 +465,4 @@ const addBranchedImplementation = (source, wireName, implementation)=>{
466
465
  const withWireClass = `${withImport.slice(0, declarationIndex)}const ${implementation.wireName} = wireClass(${implementation.className}, [])\n\n${withImport.slice(declarationIndex)}`;
467
466
  return setWireBranches(withWireClass, wireName, implementation.environments, implementation.wireName);
468
467
  };
469
- const stripJsonComments = (source)=>source.replace(/("(?:\\.|[^"\\])*")|\/\/[^\n]*|\/\*[\s\S]*?\*\//g, (_, text)=>text ? text : '').replace(/,(\s*[}\]])/g, '$1');
470
- const resolveExtends = (fromFile, target)=>{
471
- if (target.startsWith('.') || node_path.isAbsolute(target)) {
472
- const resolved = node_path.resolve(node_path.dirname(fromFile), target);
473
- return resolved.endsWith('.json') ? resolved : `${resolved}.json`;
474
- }
475
- const require = createRequire(fromFile);
476
- for (const candidate of [
477
- target,
478
- `${target}/tsconfig.json`
479
- ])try {
480
- return require.resolve(candidate);
481
- } catch {}
482
- };
483
- const compilerOption = (configFile, name, seen = new Set())=>{
484
- if (seen.has(configFile) || !node_fs.existsSync(configFile)) return null;
485
- seen.add(configFile);
486
- let config;
487
- try {
488
- config = JSON.parse(stripJsonComments(node_fs.readFileSync(configFile, 'utf8')));
489
- } catch {
490
- return null;
491
- }
492
- if (config.compilerOptions && name in config.compilerOptions) return config.compilerOptions[name];
493
- const parents = [
494
- config.extends ?? []
495
- ].flat().reverse();
496
- for (const parent of parents){
497
- const parentFile = resolveExtends(configFile, parent);
498
- const value = parentFile ? compilerOption(parentFile, name, seen) : null;
499
- if (void 0 !== value) return value;
500
- }
501
- };
502
- export { UnknownFormatNaming, addBranchedImplementation, addClassMember, addConstructorParameters, addImport, addWireDependencies, availableDependencies, boundedContextLocation, canDependOn, compilerOption, crossContextImplementation, crossContextImportAllowed, findWiredModules, hasNeighboringBoundedContext, implementationType, isCrossContextImplementation, isSuggestedFor, moduleKindOf, namedImportFiles, readWiredModule, relativeImport, stripJsonComments, wireBranches, wireDependencies, wiredDependencyNames, wiring_layers };
468
+ export { UnknownFormatNaming, addBranchedImplementation, addClassMember, addConstructorParameters, addImport, addWireDependencies, availableDependencies, boundedContextLocation, canDependOn, crossContextImplementation, crossContextImportAllowed, findWiredModules, hasNeighboringBoundedContext, implementationType, isCrossContextImplementation, isSuggestedFor, moduleKindOf, namedImportFiles, readWiredModule, relativeImport, wireBranches, wireDependencies, wiredDependencyNames, wiring_layers };
@@ -163,7 +163,7 @@ export declare const describeAgentCommand: (command: AgentCommand) => {
163
163
  dryRun: z.ZodOptional<z.ZodBoolean>;
164
164
  }, z.core.$strict>, z.ZodObject<{
165
165
  operation: z.ZodLiteral<"endpoint">;
166
- controller: z.ZodString;
166
+ controller: z.ZodOptional<z.ZodString>;
167
167
  method: z.ZodEnum<{
168
168
  get: "get";
169
169
  post: "post";
@@ -141,7 +141,7 @@ export declare const scaffoldRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject
141
141
  dryRun: z.ZodOptional<z.ZodBoolean>;
142
142
  }, z.core.$strict>, z.ZodObject<{
143
143
  operation: z.ZodLiteral<"endpoint">;
144
- controller: z.ZodString;
144
+ controller: z.ZodOptional<z.ZodString>;
145
145
  method: z.ZodEnum<{
146
146
  get: "get";
147
147
  post: "post";
@@ -426,7 +426,7 @@ export declare const requestSchemaFor: (command: AgentCommand) => z.ZodDiscrimin
426
426
  dryRun: z.ZodOptional<z.ZodBoolean>;
427
427
  }, z.core.$strict>, z.ZodObject<{
428
428
  operation: z.ZodLiteral<"endpoint">;
429
- controller: z.ZodString;
429
+ controller: z.ZodOptional<z.ZodString>;
430
430
  method: z.ZodEnum<{
431
431
  get: "get";
432
432
  post: "post";
package/dist/graph.js CHANGED
@@ -4,9 +4,9 @@ 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 { File, ProjectRoot, outdatedConfigMessage, ConfigFile } from "./870.js";
7
+ import { File, ProjectRoot, outdatedConfigMessage, ConfigFile } from "./780.js";
8
8
  import { readAliases, resolveSpecifier } from "./38.js";
9
- import { namedImportFiles, wiring_layers, findWiredModules, wiredDependencyNames } from "./201.js";
9
+ import { namedImportFiles, wiring_layers, findWiredModules, wiredDependencyNames } from "./947.js";
10
10
  const sharedKernel = 'shared-kernel';
11
11
  const contextsOf = (contextsFolder)=>node_fs.existsSync(contextsFolder) ? node_fs.readdirSync(contextsFolder, {
12
12
  withFileTypes: true