@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/README.md CHANGED
@@ -239,6 +239,8 @@ With `@domain-first/handlers-rest`, choose **Presentation → New Handlers-REST
239
239
  src/bounded-contexts/sales/presentation/rest/orders/recent/GET.ts // GET /sales/orders/recent
240
240
  ```
241
241
 
242
+ For the context itself, pick the context-root controller **(root) — /social-networks**. It lives in `presentation/rest/(root)/`, a folder that is not part of the route: an empty path and `get` give `GET /social-networks` in `src/bounded-contexts/social-networks/presentation/rest/(root)/GET.ts` (`SocialNetworksGetEndpoint`), path `:id` gives `GET /social-networks/:id`, and path `from-scratch` with `post` gives `POST /social-networks/from-scratch`. A route belongs to one controller, so `(root)/from-scratch` and a controller `from-scratch` exclude each other. Projects with context-root endpoints of 8.5 move them with `npx df-upgrade`.
243
+
242
244
  Every endpoint uses the one endpoint generator of the project, `RestEndpointGeneratorPresentationService` in `src/shared-kernel/presentation/services/`. Initialization scaffolds it as a regular Shared Kernel presentation service (class, spec and wire):
243
245
 
244
246
  ```ts
package/dist/287.js CHANGED
@@ -3,9 +3,9 @@ import { AsyncLocalStorage } from "node:async_hooks";
3
3
  import { Separator, checkbox as prompts_checkbox, confirm as prompts_confirm, input, search, select as prompts_select } from "@inquirer/prompts";
4
4
  import { styleText } from "node:util";
5
5
  import node_fs from "node:fs";
6
- import { addImport, availableDependencies, compilerOption, findWiredModules, UnknownFormatNaming, readWiredModule, stripJsonComments, addClassMember, hasNeighboringBoundedContext, addBranchedImplementation, addWireDependencies, boundedContextLocation, addConstructorParameters, relativeImport, wireBranches, wireDependencies, implementationType as wiring_implementationType, crossContextImportAllowed, crossContextImplementation, isSuggestedFor } from "./201.js";
7
- import { implementationLabelSchema, withoutOverwrites, domainFirstPackages as config_file_domainFirstPackages, scaffoldBackendRules, branchNameSchema, discardPendingChanges, ConfigFile, filesToOverwrite, Folder, writePendingChanges, File, ProjectRoot } from "./870.js";
8
- import { missingPackages, hasDependency, missingDomainFirstPackages } from "./711.js";
6
+ import { addImport, availableDependencies, findWiredModules, UnknownFormatNaming, readWiredModule, addClassMember, hasNeighboringBoundedContext, addBranchedImplementation, addWireDependencies, boundedContextLocation, addConstructorParameters, relativeImport, wireBranches, wireDependencies, implementationType as wiring_implementationType, crossContextImportAllowed, crossContextImplementation, isSuggestedFor } from "./947.js";
7
+ import { implementationLabelSchema, withoutOverwrites, domainFirstPackages as config_file_domainFirstPackages, scaffoldBackendRules, branchNameSchema, discardPendingChanges, ConfigFile, filesToOverwrite, Folder, writePendingChanges, File, ProjectRoot, compilerOption } from "./780.js";
8
+ import { missingDomainFirstPackages, walk, projectImports, escapeRegExp, pathParameterAsName, hasLegacyRootEndpoints, stageModuleMove, toPosix, rootStaticSegments, openapiExtractorPath, restControllers, hasDependency, openapiExtractor, missingPackages, codeExtension, isPathParameterName } from "./526.js";
9
9
  const moduleId = (module)=>`${boundedContextLocation(module.typeFile)?.name ?? 'shared-kernel'}:${module.typeName}`;
10
10
  const unitId = (unit)=>`${unit.kind}:${unit.aggregate ? `${unit.aggregate}/` : ''}${unit.name}`;
11
11
  const inMemoryImplementationType = 'in-memory';
@@ -480,164 +480,6 @@ const scaffoldReactPage = async (presentationReactFolder)=>{
480
480
  ]).createFile(`${fileName}-page.tsx`, reactPageContent(ClassName));
481
481
  if (usesNext()) scaffoldNextRoute(nestedName, pageFile);
482
482
  };
483
- const openapiExtractorPath = "scripts/extract-open-api-data-from-endpoint.ts";
484
- const rootFolderSegments = (rootFolder)=>rootFolder.split(/[\\/]/).map((segment)=>segment.trim()).filter((segment)=>!!segment && '.' !== segment).map((segment)=>`'${segment}',\n `).join('');
485
- const openapiExtractor = (rootFolder)=>`import path from 'node:path';
486
- import {
487
- type DocNode,
488
- DocPlainText,
489
- TSDocConfiguration,
490
- TSDocParser,
491
- TSDocTagDefinition,
492
- TSDocTagSyntaxKind
493
- } from '@microsoft/tsdoc';
494
- import { Node, Project, type SourceFile, SyntaxKind } from 'ts-morph';
495
-
496
- type BlockTag = \`@\${string}\`;
497
-
498
- type OpenApiDataTags = {
499
- /** Omit to take the summary from the comment text before the first tag. */
500
- summary?: BlockTag;
501
- description?: BlockTag;
502
- };
503
-
504
- type OpenApiData = Partial<{
505
- summary: string;
506
- description: string;
507
- operationId: string;
508
- }>;
509
-
510
- const project = new Project({
511
- tsConfigFilePath: 'tsconfig.json'
512
- });
513
-
514
- const getText = (node: DocNode): string =>
515
- node
516
- .getChildNodes()
517
- .map((child) => {
518
- if (child instanceof DocPlainText) {
519
- return child.text;
520
- }
521
-
522
- return getText(child);
523
- })
524
- .join('');
525
-
526
- const getRawCommentText = (comment: string): string =>
527
- comment
528
- .replace(/^\\/\\*\\*/, '')
529
- .replace(/\\*\\/$/, '')
530
- .split(/\\r?\\n/)
531
- .map((line) => line.replace(/^\\s*\\*\\s?/, ''))
532
- .join('\\n');
533
-
534
- // TSDoc treats an unknown tag as summary content, so every block tag of the
535
- // comment has to be registered for the summary section to end before it.
536
- const parseSummary = (comment: string): string | undefined => {
537
- const configuration = new TSDocConfiguration();
538
- const tagNames = getRawCommentText(comment).matchAll(/(?:^|\\n)\\s*(@\\w+)/g);
539
-
540
- for (const [, tagName] of tagNames) {
541
- if (!configuration.tryGetTagDefinition(tagName)) {
542
- configuration.addTagDefinition(
543
- new TSDocTagDefinition({
544
- tagName,
545
- syntaxKind: TSDocTagSyntaxKind.BlockTag
546
- })
547
- );
548
- }
549
- }
550
-
551
- const { docComment } = new TSDocParser(configuration).parseString(comment);
552
-
553
- return getText(docComment.summarySection).trim() || undefined;
554
- };
555
-
556
- // Parsed by hand rather than through TSDoc, which drops the line breaks.
557
- const getTagText = (comment: string, tag: BlockTag): string | undefined => {
558
- const tagMatch = getRawCommentText(comment).match(
559
- new RegExp(
560
- \`(?:^|\\\\n)\\\\s*\${tag}(?:[ \\\\t]*\\\\n|[ \\\\t]+)([\\\\s\\\\S]*?)(?=\\\\n\\\\s*@\\\\w+|\\\\s*$)\`
561
- )
562
- );
563
-
564
- return tagMatch?.[1].trim() || undefined;
565
- };
566
-
567
- // Endpoints pass their logic as the generator's first argument
568
- // (\`this.endpointGenerator(this.handler.handle, ...)\`), while other injected
569
- // queries only serve as helpers, e.g. guest checks.
570
- const findHandlerClass = (endpointFile: SourceFile) =>
571
- endpointFile
572
- .getDescendantsOfKind(SyntaxKind.CallExpression)
573
- .map((call) => call.getArguments()[0])
574
- .filter(Node.isPropertyAccessExpression)
575
- .find((argument) => argument.getName() === 'handle')
576
- ?.getExpression()
577
- .getType()
578
- .getSymbol()
579
- ?.getDeclarations()
580
- .find(Node.isClassDeclaration);
581
-
582
- // Path parameters (\`:id\`) can't be part of file and folder names
583
- // everywhere (Windows), so endpoints name them \`_id_\` there.
584
- const pathParameterAsName = (segment: string) =>
585
- segment.startsWith(':') ? \`_\${segment.slice(1)}_\` : segment;
586
-
587
- export const createOpenApiDataFromEndpointLogicExtractor = ({
588
- summary: summaryTag,
589
- description: descriptionTag = '@description'
590
- }: OpenApiDataTags = {}) => {
591
- return (routeMetadata: {
592
- method: string;
593
- path: readonly string[];
594
- }): OpenApiData | undefined => {
595
- try {
596
- const [currentBoundedContext, controller, ...relativePath] =
597
- routeMetadata.path;
598
-
599
- if (!currentBoundedContext || !controller) {
600
- return undefined;
601
- }
602
-
603
- const endpointFile = project.getSourceFile(
604
- path.join(
605
- ${rootFolderSegments(rootFolder)}'bounded-contexts',
606
- currentBoundedContext,
607
- 'presentation',
608
- 'rest',
609
- controller,
610
- ...relativePath.map(pathParameterAsName),
611
- \`\${routeMetadata.method.toUpperCase()}.ts\`
612
- )
613
- );
614
-
615
- if (!endpointFile) {
616
- return undefined;
617
- }
618
-
619
- const declaration = findHandlerClass(endpointFile);
620
- const operationId = declaration?.getName();
621
- const comment = declaration?.getJsDocs().at(-1)?.getText();
622
-
623
- if (!comment) {
624
- return { operationId };
625
- }
626
-
627
- return {
628
- summary: summaryTag
629
- ? getTagText(comment, summaryTag)
630
- : parseSummary(comment),
631
- description: getTagText(comment, descriptionTag),
632
- operationId
633
- };
634
- } catch (e: unknown) {
635
- console.error(e);
636
- return undefined;
637
- }
638
- };
639
- };
640
- `;
641
483
  const addPackageScripts = async (file, additions)=>{
642
484
  const original = file.data;
643
485
  const manifest = JSON.parse(original);
@@ -2182,147 +2024,6 @@ const integrationDescriptions = ()=>integrations.map((integration)=>({
2182
2024
  group: integration.group,
2183
2025
  available: ('backend' !== integration.group || Boolean(ConfigFile.Instance.data.backend)) && (integration.available?.() ?? true)
2184
2026
  }));
2185
- const ignoredFolders = new Set([
2186
- 'node_modules',
2187
- '.git',
2188
- '.next',
2189
- 'dist',
2190
- 'build',
2191
- 'out',
2192
- 'coverage',
2193
- 'storybook-static'
2194
- ]);
2195
- const codeExtension = /\.(?:tsx?|mts|cts|jsx?|mjs|cjs|mdx)$/;
2196
- const escapeRegExp = (value)=>value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
2197
- const walk = (folder)=>{
2198
- if (!node_fs.existsSync(folder)) return [];
2199
- return node_fs.readdirSync(folder, {
2200
- withFileTypes: true
2201
- }).flatMap((entry)=>{
2202
- const entryPath = node_path.join(folder, entry.name);
2203
- if (entry.isDirectory()) return ignoredFolders.has(entry.name) ? [] : walk(entryPath);
2204
- return entry.isFile() ? [
2205
- entryPath
2206
- ] : [];
2207
- });
2208
- };
2209
- const toPosix = (value)=>value.split(node_path.sep).join('/');
2210
- const readAliases = (projectRoot)=>{
2211
- const tsconfig = node_path.join(projectRoot, 'tsconfig.json');
2212
- if (!node_fs.existsSync(tsconfig)) return [];
2213
- try {
2214
- const { compilerOptions = {} } = JSON.parse(stripJsonComments(node_fs.readFileSync(tsconfig, 'utf8')));
2215
- const base = node_path.resolve(projectRoot, compilerOptions.baseUrl ?? '.');
2216
- return Object.entries(compilerOptions.paths ?? {}).filter(([pattern, targets])=>pattern.endsWith('*') && targets[0]?.endsWith('*')).map(([pattern, [target]])=>({
2217
- prefix: pattern.slice(0, -1),
2218
- target: node_path.resolve(base, target.slice(0, -1))
2219
- }));
2220
- } catch {
2221
- return [];
2222
- }
2223
- };
2224
- const specifierPattern = /(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+|\brequire\s*\(\s*|\bmock\s*\(\s*)(['"])([^'"\n]+)\2/g;
2225
- const reExportPattern = /\bexport\s+(?:type\s+)?(?:\*(?:\s+as\s+[\w$]+)?|\{[^}]*\})\s*from\s*(['"])([^'"\n]+)\1/g;
2226
- const importPaths = (file)=>{
2227
- const withoutExtension = file.replace(codeExtension, '');
2228
- return 'index' === node_path.basename(withoutExtension) ? [
2229
- withoutExtension,
2230
- node_path.dirname(withoutExtension)
2231
- ] : [
2232
- withoutExtension
2233
- ];
2234
- };
2235
- const projectImports = (projectRoot)=>{
2236
- const aliases = readAliases(projectRoot);
2237
- const resolve = (specifier, fromFile)=>{
2238
- if (specifier.startsWith('.')) return {
2239
- resolved: node_path.resolve(node_path.dirname(fromFile), specifier),
2240
- alias: void 0
2241
- };
2242
- const alias = aliases.find(({ prefix })=>specifier.startsWith(prefix));
2243
- return alias ? {
2244
- resolved: node_path.resolve(alias.target, specifier.slice(alias.prefix.length)),
2245
- alias
2246
- } : void 0;
2247
- };
2248
- const specifierFor = (fromFile, toPath, alias)=>{
2249
- const aliased = alias && toPosix(node_path.relative(alias.target, toPath));
2250
- if (aliased && !aliased.startsWith('..')) return `${alias.prefix}${aliased}`;
2251
- const relative = toPosix(node_path.relative(node_path.dirname(fromFile), toPath));
2252
- return relative.startsWith('.') ? relative : `./${relative}`;
2253
- };
2254
- const codeFiles = new Map(walk(projectRoot).filter((file)=>codeExtension.test(file)).map((file)=>[
2255
- file,
2256
- node_fs.readFileSync(file, 'utf8')
2257
- ]));
2258
- const importsOf = (file)=>[
2259
- ...(codeFiles.get(file) ?? '').matchAll(specifierPattern)
2260
- ].map(([, , , specifier])=>resolve(specifier, file)?.resolved).filter((resolved)=>!!resolved);
2261
- return {
2262
- resolve,
2263
- specifierFor,
2264
- codeFiles,
2265
- importsOf
2266
- };
2267
- };
2268
- const stageModuleMove = ({ projectRoot, stopAt, moves, movedPath, rename, everyFile = (content)=>content, stopAtFor })=>{
2269
- const stopFor = (file)=>stopAtFor?.(file) ?? stopAt;
2270
- const { resolve, specifierFor, codeFiles } = projectImports(projectRoot);
2271
- const barrels = new Set();
2272
- const isBarrel = (resolved)=>barrels.has(resolved.replace(codeExtension, ''));
2273
- for(let found = true; found;){
2274
- found = false;
2275
- for (const [file, content] of codeFiles){
2276
- if (moves.has(file) || isBarrel(file)) continue;
2277
- const reExportsModule = [
2278
- ...content.matchAll(reExportPattern)
2279
- ].some(([, , specifier])=>{
2280
- const resolution = resolve(specifier, file);
2281
- return !!resolution && (!!movedPath(resolution.resolved) || isBarrel(resolution.resolved));
2282
- });
2283
- if (reExportsModule) {
2284
- for (const importPath of importPaths(file))barrels.add(importPath);
2285
- found = true;
2286
- }
2287
- }
2288
- }
2289
- const rewrite = (content, oldFile, newFile)=>{
2290
- let referencesModule = false;
2291
- const rewritten = content.replace(specifierPattern, (match, keyword, quote, specifier)=>{
2292
- const resolution = resolve(specifier, oldFile);
2293
- if (!resolution) return match;
2294
- const moved = movedPath(resolution.resolved);
2295
- if (moved || isBarrel(resolution.resolved)) referencesModule = true;
2296
- if (!moved && oldFile === newFile) return match;
2297
- const next = specifierFor(newFile, moved ?? resolution.resolved, resolution.alias);
2298
- return `${keyword}${quote}${next}${quote}`;
2299
- });
2300
- const changed = everyFile(rewritten);
2301
- if (!referencesModule && !moves.has(oldFile)) return changed;
2302
- return rename(changed, {
2303
- moved: moves.has(oldFile)
2304
- });
2305
- };
2306
- for (const [file, newFile] of moves)if (!codeFiles.has(file) && newFile !== file) new File(file).moveTo(newFile, stopFor(file));
2307
- const updated = [];
2308
- for (const [file, content] of codeFiles){
2309
- const newFile = moves.get(file);
2310
- const next = rewrite(content, file, newFile ?? file);
2311
- if (newFile && newFile !== file) {
2312
- new File(newFile).data = next;
2313
- new File(file).delete(stopFor(file));
2314
- } else if (next !== content) {
2315
- new File(file).update(next);
2316
- if (!newFile) updated.push(file);
2317
- }
2318
- }
2319
- return {
2320
- moves: [
2321
- ...moves
2322
- ].filter(([from, to])=>from !== to),
2323
- updated
2324
- };
2325
- };
2326
2027
  const serviceLayout = (layer)=>({
2327
2028
  title: `${layer[0].toUpperCase()}${layer.slice(1)} services`,
2328
2029
  core: (ClassName)=>`${ClassName}${layer[0].toUpperCase()}${layer.slice(1)}Service`,
@@ -4268,47 +3969,49 @@ export const ${names.namespace(ClassName)} = errorNamespace('${boundedContextFol
4268
3969
  const namespaceFile = currentErrorFolder.file(`${namespace}.ts`);
4269
3970
  namespaceFile.addLineIfMissing(errorClass(names.error(`${namespaceNaming.ClassName}${ClassName}`), exportedNamespace(namespaceFile, names.namespace(namespaceNaming.ClassName)), fileName), '\n\n');
4270
3971
  };
3972
+ const newController = 'New controller';
3973
+ const rootControllerChoice = 'No controller (context root)';
3974
+ const sharedRestFolder = (boundedContextFolder)=>boundedContextFolder.subitem([
3975
+ '..',
3976
+ '..',
3977
+ 'presentation',
3978
+ 'rest'
3979
+ ]);
3980
+ 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.`;
4271
3981
  const scaffoldNewHandlersRestEndpoint = async (boundedContextFolder)=>{
3982
+ const context = boundedContextFolder.name;
4272
3983
  const restPresentationFolder = boundedContextFolder.subitem([
4273
3984
  'presentation',
4274
3985
  'rest'
4275
3986
  ]);
4276
- const controllers = restPresentationFolder.content.subfolderNames;
4277
- let controller = await interaction_select({
3987
+ const controllers = restControllers(boundedContextFolder.path);
3988
+ const rootSegments = rootStaticSegments(boundedContextFolder.path);
3989
+ let controllerChoice = await interaction_select({
4278
3990
  key: 'controllerSelection',
4279
3991
  message: 'Controller: ',
4280
3992
  choices: [
3993
+ {
3994
+ value: rootControllerChoice,
3995
+ name: `(root) — /${context}`
3996
+ },
4281
3997
  ...controllers,
4282
- 'New controller'
3998
+ newController
4283
3999
  ]
4284
4000
  });
4285
- if ('New controller' === controller) {
4286
- controller = await interaction_input({
4287
- key: 'controllerName',
4288
- message: 'Name: '
4289
- });
4290
- if (ConfigFile.backend.domainFirstPackages.includes('@domain-first/wire')) {
4291
- boundedContextFolder.subitem([
4292
- 'wiring',
4293
- 'presentation',
4294
- 'rest'
4295
- ]).file('index.ts').addLine(`export * from './${controller}'`);
4296
- const sharedRestFolder = boundedContextFolder.subitem([
4297
- '..',
4298
- '..',
4299
- 'presentation',
4300
- 'rest'
4301
- ]);
4302
- sharedRestFolder.file('wires.ts').addLine(`export * from '../../bounded-contexts/${boundedContextFolder.name}/wiring/presentation/rest/${controller}'`);
4303
- if (!sharedRestFolder.file('index.ts').exists) sharedRestFolder.createFile('index.ts', `
4304
- import * as wires from './wires'
4305
-
4306
- const restWires = Object.values(wires)
4307
-
4308
- export const restHandlers = restWires.map(x => x().handle)
4309
- `.trim());
4001
+ if (controllerChoice === rootControllerChoice && hasLegacyRootEndpoints(boundedContextFolder.path)) throw new RequestError('UPGRADE_REQUIRED', legacyRootEndpointsMessage(context));
4002
+ if (controllerChoice === newController) controllerChoice = await interaction_input({
4003
+ key: 'controllerName',
4004
+ message: 'Name: ',
4005
+ validate: (value)=>{
4006
+ if (!value.trim()) return 'Name is required; pick "(root)" for an endpoint at the context root';
4007
+ if (isPathParameterName(value) || value.includes('/') || /[()]/.test(value)) return 'A controller is one static path segment';
4008
+ if (value === context) return `"${value}" is the context itself: pick "(root)" for /${context}`;
4009
+ if (rootSegments.includes(value)) return `/${context}/${value} belongs to the context root ((root)/${value}): add the endpoint there`;
4010
+ return true;
4310
4011
  }
4311
- }
4012
+ });
4013
+ const controller = controllerChoice === rootControllerChoice ? void 0 : controllerChoice;
4014
+ const withWiring = ConfigFile.backend.domainFirstPackages.includes('@domain-first/wire');
4312
4015
  const method = await interaction_select({
4313
4016
  key: 'method',
4314
4017
  message: 'Method:',
@@ -4322,21 +4025,38 @@ export const restHandlers = restWires.map(x => x().handle)
4322
4025
  });
4323
4026
  const routeSegments = (await interaction_input({
4324
4027
  key: 'path',
4325
- message: 'Relative path (split by "/"):'
4028
+ message: 'Relative path (split by "/"):',
4029
+ validate: (value)=>{
4030
+ const [first] = value.split('/').filter((x)=>!!x);
4031
+ return controller || !first || first.startsWith(':') || !controllers.includes(first) ? true : `/${context}/${first} belongs to controller "${first}": add the endpoint there`;
4032
+ }
4326
4033
  })).split('/').filter((x)=>!!x);
4327
- const pathParameterAsName = (segment)=>segment.startsWith(':') ? `_${segment.slice(1)}_` : segment;
4328
- const controllerFolder = restPresentationFolder.subitem([
4329
- controller
4330
- ]);
4331
- const endpointFolder = controllerFolder.subitem(routeSegments.map(pathParameterAsName));
4332
- const nameBase = `${controller}-${routeSegments.length ? `${routeSegments.map(pathParameterAsName).join('-')}-` : ''}${method}-endpoint`;
4034
+ const group = controller ?? "(root)";
4035
+ const folderSegments = [
4036
+ group,
4037
+ ...routeSegments
4038
+ ];
4039
+ const routePath = [
4040
+ context,
4041
+ ...controller ? [
4042
+ controller
4043
+ ] : [],
4044
+ ...routeSegments
4045
+ ];
4046
+ const endpointFolder = restPresentationFolder.subitem(folderSegments.map(pathParameterAsName));
4047
+ const nameSegments = [
4048
+ controller ?? context,
4049
+ ...routeSegments
4050
+ ];
4051
+ const nameBase = `${[
4052
+ ...nameSegments.map(pathParameterAsName),
4053
+ method
4054
+ ].join('-')}-endpoint`;
4333
4055
  const endpointClassName = [
4334
- controller,
4335
- ...routeSegments,
4056
+ ...nameSegments,
4336
4057
  method,
4337
4058
  'endpoint'
4338
4059
  ].map((segment)=>segment.startsWith(':') ? pathParameterAsName(segment) : new UnknownFormatNaming(segment).ClassName).join('');
4339
- const withWiring = ConfigFile.backend.domainFirstPackages.includes('@domain-first/wire');
4340
4060
  const endpointGenerator = findRestEndpointGenerator(boundedContextFolder.subitem([
4341
4061
  '..',
4342
4062
  '..',
@@ -4356,8 +4076,8 @@ export class ${endpointClassName} {
4356
4076
 
4357
4077
  get handle() {
4358
4078
  return this.endpointGenerator(this.handler.handle, {
4359
- route: { method: '${method}', path: ['${boundedContextFolder.name}', '${controller}'${routeSegments.length ? `, ${routeSegments.map((x)=>`'${x}'`).join(', ')}` : ''}] },
4360
- tags: ['${boundedContextFolder.name}: ${controller}'],
4079
+ route: { method: '${method}', path: [${routePath.map((x)=>`'${x}'`).join(', ')}] },
4080
+ tags: ['${context}${controller ? `: ${controller}` : ''}'],
4361
4081
  })
4362
4082
  }
4363
4083
  }
@@ -4367,7 +4087,7 @@ export class ${endpointClassName} {
4367
4087
  'wiring',
4368
4088
  'presentation',
4369
4089
  'rest',
4370
- controller
4090
+ group
4371
4091
  ]);
4372
4092
  const wireNameBase = `wire-${nameBase}`;
4373
4093
  const wireNaming = new UnknownFormatNaming(wireNameBase);
@@ -4387,6 +4107,20 @@ export const wire${endpointClassName} = wireClass(
4387
4107
  )
4388
4108
  `.trim());
4389
4109
  wiringFolder.file('index.ts').addLineIfMissing(`export * from './${wireNaming.fileName}'`);
4110
+ boundedContextFolder.subitem([
4111
+ 'wiring',
4112
+ 'presentation',
4113
+ 'rest'
4114
+ ]).file('index.ts').addLineIfMissing(`export * from './${group}'`);
4115
+ sharedRestFolder(boundedContextFolder).file('wires.ts').addLineIfMissing(`export * from '../../bounded-contexts/${context}/wiring/presentation/rest/${group}'`);
4116
+ const restHandlersFile = sharedRestFolder(boundedContextFolder).file('index.ts');
4117
+ if (!restHandlersFile.exists) sharedRestFolder(boundedContextFolder).createFile('index.ts', `
4118
+ import * as wires from './wires'
4119
+
4120
+ const restWires = Object.values(wires)
4121
+
4122
+ export const restHandlers = restWires.map(x => x().handle)
4123
+ `.trim());
4390
4124
  }
4391
4125
  };
4392
4126
  const scaffold_new_implementation_kindTitles = {
@@ -4882,4 +4616,4 @@ export const use${ClassName}UIModel = (widgetProps: Omit<${ClassName}WidgetProps
4882
4616
  break;
4883
4617
  }
4884
4618
  };
4885
- export { RequestError, addIntegration, assertAnswersConsumed, configurationSections, deleteBackendUnitUseCase, deleteReactModuleUseCase, findBackendUnits, findContracts, findReactModules, findRestEndpointGenerator, initializeUseCase, integrationDescriptions, integrationIds, moduleId, moveBackendUnitUseCase, moveReactModuleUseCase, printNextSteps, reactKindTitles, runWithAnswers, savePendingChanges, savedImplementations, scaffoldNewAggregateUseCase, scaffoldNewApplicationPort, scaffoldNewApplicationService, scaffoldNewBoundedContextUseCase, scaffoldNewCommand, scaffoldNewDomainObject, scaffoldNewDomainService, scaffoldNewErrorUseCase, scaffoldNewHandlersRestEndpoint, scaffoldNewImplementation, scaffoldNewInfrastructureService, scaffoldNewPresentationService, scaffoldNewQuery, scaffoldNewUseCase, scaffoldReactPage, scaffoldReactSharedHook, scaffoldReactUIKitComponent, scaffoldReactWidget, systemImplementationChoices, unitId, wireDependency };
4619
+ export { RequestError, addIntegration, assertAnswersConsumed, configurationSections, deleteBackendUnitUseCase, deleteReactModuleUseCase, findBackendUnits, findContracts, findReactModules, findRestEndpointGenerator, initializeUseCase, integrationDescriptions, integrationIds, moduleId, moveBackendUnitUseCase, moveReactModuleUseCase, printNextSteps, reactKindTitles, rootControllerChoice, runWithAnswers, savePendingChanges, savedImplementations, scaffoldNewAggregateUseCase, scaffoldNewApplicationPort, scaffoldNewApplicationService, scaffoldNewBoundedContextUseCase, scaffoldNewCommand, scaffoldNewDomainObject, scaffoldNewDomainService, scaffoldNewErrorUseCase, scaffoldNewHandlersRestEndpoint, scaffoldNewImplementation, scaffoldNewInfrastructureService, scaffoldNewPresentationService, scaffoldNewQuery, scaffoldNewUseCase, scaffoldReactPage, scaffoldReactSharedHook, scaffoldReactUIKitComponent, scaffoldReactWidget, systemImplementationChoices, unitId, wireDependency };
package/dist/38.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import node_fs from "node:fs";
2
2
  import node_path from "node:path";
3
- import { canDependOn, namedImportFiles, isCrossContextImplementation, findWiredModules, moduleKindOf, readWiredModule, crossContextImportAllowed, compilerOption, wiredDependencyNames } from "./201.js";
4
- import { defaultDependencyRules, fileModuleKind } from "./870.js";
3
+ import { namedImportFiles, canDependOn, isCrossContextImplementation, findWiredModules, moduleKindOf, readWiredModule, crossContextImportAllowed, wiredDependencyNames } from "./947.js";
4
+ import { defaultDependencyRules, fileModuleKind, compilerOption } from "./780.js";
5
5
  const readAliases = (projectRoot)=>{
6
6
  const tsconfig = node_path.join(projectRoot, 'tsconfig.json');
7
7
  const paths = compilerOption(tsconfig, 'paths');