@domain-first/project-structure 8.11.0 → 8.13.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.
@@ -1041,4 +1041,456 @@ const compilerOption = (configFile, name, seen = new Set())=>{
1041
1041
  if (void 0 !== value) return value;
1042
1042
  }
1043
1043
  };
1044
- export { ConfigFile, File, Folder, NestedName, ProjectRoot, UnknownFormatNaming, addBranchedImplementation, addClassMember, addConstructorParameters, addImport, addWireDependencies, availableDependencies, boundedContextLocation, boundedContextName, boundedContextNames, boundedContextPath, boundedContextsFolderName, branchNameSchema, canDependOn, compilerOption, configFileName, configSchema, configuredDependencyRules, crossContextImplementation, crossContextImportAllowed, defaultDependencyRules, discardPendingChanges, domainFirstPackages, fileModuleKind, filesToOverwrite, findWiredModules, hasNeighboringBoundedContext, implementationKinds, implementationLabelSchema, implementationType, isCrossContextImplementation, isOutdatedConfig, isSuggestedFor, moduleKindOf, namedImportFiles, outdatedConfigMessage, pendingChanges, readWiredModule, relativeImport, rulesSchema, scaffoldBackendRules, splitContextSegments, stripJsonComments, validateBoundedContextName, wireBranches, wireDependencies, wiredDependencyNames, wiring_layers, withoutOverwrites, writePendingChanges };
1044
+ const ignoredFolders = new Set([
1045
+ 'node_modules',
1046
+ '.git',
1047
+ '.next',
1048
+ '.svelte-kit',
1049
+ 'dist',
1050
+ 'build',
1051
+ 'out',
1052
+ 'coverage',
1053
+ 'storybook-static'
1054
+ ]);
1055
+ const codeExtension = /\.(?:tsx?|mts|cts|jsx?|mjs|cjs|mdx|svelte)$/;
1056
+ const escapeRegExp = (value)=>value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
1057
+ const module_move_walk = (folder)=>{
1058
+ if (!node_fs.existsSync(folder)) return [];
1059
+ return node_fs.readdirSync(folder, {
1060
+ withFileTypes: true
1061
+ }).flatMap((entry)=>{
1062
+ const entryPath = node_path.join(folder, entry.name);
1063
+ if (entry.isDirectory()) return ignoredFolders.has(entry.name) ? [] : module_move_walk(entryPath);
1064
+ return entry.isFile() ? [
1065
+ entryPath
1066
+ ] : [];
1067
+ });
1068
+ };
1069
+ const toPosix = (value)=>value.split(node_path.sep).join('/');
1070
+ const readAliases = (projectRoot)=>{
1071
+ const tsconfig = node_path.join(projectRoot, 'tsconfig.json');
1072
+ if (!node_fs.existsSync(tsconfig)) return [];
1073
+ try {
1074
+ const { compilerOptions = {} } = JSON.parse(stripJsonComments(node_fs.readFileSync(tsconfig, 'utf8')));
1075
+ const base = node_path.resolve(projectRoot, compilerOptions.baseUrl ?? '.');
1076
+ return Object.entries(compilerOptions.paths ?? {}).filter(([pattern, targets])=>pattern.endsWith('*') && targets[0]?.endsWith('*')).map(([pattern, [target]])=>({
1077
+ prefix: pattern.slice(0, -1),
1078
+ target: node_path.resolve(base, target.slice(0, -1))
1079
+ }));
1080
+ } catch {
1081
+ return [];
1082
+ }
1083
+ };
1084
+ const specifierPattern = /(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+|\brequire\s*\(\s*|\bmock\s*\(\s*)(['"])([^'"\n]+)\2/g;
1085
+ const reExportPattern = /\bexport\s+(?:type\s+)?(?:\*(?:\s+as\s+[\w$]+)?|\{[^}]*\})\s*from\s*(['"])([^'"\n]+)\1/g;
1086
+ const importPaths = (file)=>{
1087
+ const withoutExtension = file.replace(codeExtension, '');
1088
+ return 'index' === node_path.basename(withoutExtension) ? [
1089
+ withoutExtension,
1090
+ node_path.dirname(withoutExtension)
1091
+ ] : [
1092
+ withoutExtension
1093
+ ];
1094
+ };
1095
+ const projectImports = (projectRoot)=>{
1096
+ const aliases = readAliases(projectRoot);
1097
+ const resolve = (specifier, fromFile)=>{
1098
+ if (specifier.startsWith('.')) return {
1099
+ resolved: node_path.resolve(node_path.dirname(fromFile), specifier),
1100
+ alias: void 0
1101
+ };
1102
+ const alias = aliases.find(({ prefix })=>specifier.startsWith(prefix));
1103
+ return alias ? {
1104
+ resolved: node_path.resolve(alias.target, specifier.slice(alias.prefix.length)),
1105
+ alias
1106
+ } : void 0;
1107
+ };
1108
+ const specifierFor = (fromFile, toPath, alias)=>{
1109
+ const aliased = alias && toPosix(node_path.relative(alias.target, toPath));
1110
+ if (aliased && !aliased.startsWith('..')) return `${alias.prefix}${aliased}`;
1111
+ const relative = toPosix(node_path.relative(node_path.dirname(fromFile), toPath));
1112
+ return relative.startsWith('.') ? relative : `./${relative}`;
1113
+ };
1114
+ const codeFiles = new Map(module_move_walk(projectRoot).filter((file)=>codeExtension.test(file)).map((file)=>[
1115
+ file,
1116
+ node_fs.readFileSync(file, 'utf8')
1117
+ ]));
1118
+ const importsOf = (file)=>[
1119
+ ...(codeFiles.get(file) ?? '').matchAll(specifierPattern)
1120
+ ].map(([, , , specifier])=>resolve(specifier, file)?.resolved).filter((resolved)=>!!resolved);
1121
+ return {
1122
+ resolve,
1123
+ specifierFor,
1124
+ codeFiles,
1125
+ importsOf
1126
+ };
1127
+ };
1128
+ const stageModuleMove = ({ projectRoot, stopAt, moves, movedPath, rename, everyFile = (content)=>content, stopAtFor })=>{
1129
+ const stopFor = (file)=>stopAtFor?.(file) ?? stopAt;
1130
+ const { resolve, specifierFor, codeFiles } = projectImports(projectRoot);
1131
+ const barrels = new Set();
1132
+ const isBarrel = (resolved)=>barrels.has(resolved.replace(codeExtension, ''));
1133
+ for(let found = true; found;){
1134
+ found = false;
1135
+ for (const [file, content] of codeFiles){
1136
+ if (moves.has(file) || isBarrel(file)) continue;
1137
+ const reExportsModule = [
1138
+ ...content.matchAll(reExportPattern)
1139
+ ].some(([, , specifier])=>{
1140
+ const resolution = resolve(specifier, file);
1141
+ return !!resolution && (!!movedPath(resolution.resolved) || isBarrel(resolution.resolved));
1142
+ });
1143
+ if (reExportsModule) {
1144
+ for (const importPath of importPaths(file))barrels.add(importPath);
1145
+ found = true;
1146
+ }
1147
+ }
1148
+ }
1149
+ const rewrite = (content, oldFile, newFile)=>{
1150
+ let referencesModule = false;
1151
+ const rewritten = content.replace(specifierPattern, (match, keyword, quote, specifier)=>{
1152
+ const resolution = resolve(specifier, oldFile);
1153
+ if (!resolution) return match;
1154
+ const moved = movedPath(resolution.resolved);
1155
+ if (moved || isBarrel(resolution.resolved)) referencesModule = true;
1156
+ if (!moved && oldFile === newFile) return match;
1157
+ const next = specifierFor(newFile, moved ?? resolution.resolved, resolution.alias);
1158
+ return `${keyword}${quote}${next}${quote}`;
1159
+ });
1160
+ const changed = everyFile(rewritten);
1161
+ if (!referencesModule && !moves.has(oldFile)) return changed;
1162
+ return rename(changed, {
1163
+ moved: moves.has(oldFile)
1164
+ });
1165
+ };
1166
+ for (const [file, newFile] of moves)if (!codeFiles.has(file) && newFile !== file) new File(file).moveTo(newFile, stopFor(file));
1167
+ const updated = [];
1168
+ for (const [file, content] of codeFiles){
1169
+ const newFile = moves.get(file);
1170
+ const next = rewrite(content, file, newFile ?? file);
1171
+ if (newFile && newFile !== file) {
1172
+ new File(newFile).data = next;
1173
+ new File(file).delete(stopFor(file));
1174
+ } else if (next !== content) {
1175
+ new File(file).update(next);
1176
+ if (!newFile) updated.push(file);
1177
+ }
1178
+ }
1179
+ return {
1180
+ moves: [
1181
+ ...moves
1182
+ ].filter(([from, to])=>from !== to),
1183
+ updated
1184
+ };
1185
+ };
1186
+ const frontendExtensions = {
1187
+ react: {
1188
+ component: '.tsx',
1189
+ hook: '.ts'
1190
+ },
1191
+ svelte: {
1192
+ component: '.svelte',
1193
+ hook: '.svelte.ts'
1194
+ }
1195
+ };
1196
+ const frontendLogicNaming = {
1197
+ react: {
1198
+ prefix: 'use',
1199
+ shared: [
1200
+ 'hooks'
1201
+ ]
1202
+ },
1203
+ svelte: {
1204
+ prefix: 'create',
1205
+ shared: [
1206
+ 'shared',
1207
+ 'model'
1208
+ ]
1209
+ }
1210
+ };
1211
+ const kindLayouts = (framework)=>{
1212
+ const { component, hook } = frontendExtensions[framework];
1213
+ const { prefix, shared } = frontendLogicNaming[framework];
1214
+ return {
1215
+ page: {
1216
+ folder: 'pages',
1217
+ nested: true,
1218
+ inFolder: false,
1219
+ ownFile: (fileBase)=>new RegExp(`^${escapeRegExp(fileBase)}-page(?:\\.|$)`),
1220
+ target: (reactFolder, { folders, fileName })=>node_path.join(reactFolder, 'pages', ...folders, `${fileName}-page${component}`),
1221
+ classPrefix: `(${prefix})?`,
1222
+ classSuffix: 'Page'
1223
+ },
1224
+ widget: {
1225
+ folder: 'widgets',
1226
+ nested: true,
1227
+ inFolder: true,
1228
+ target: (reactFolder, { folders, folderName })=>node_path.join(reactFolder, 'widgets', ...folders, folderName),
1229
+ classPrefix: `(${prefix})?`,
1230
+ classSuffix: 'Widget|UIModel',
1231
+ storyTitle: (segments)=>[
1232
+ 'Widgets',
1233
+ ...segments
1234
+ ].join('/')
1235
+ },
1236
+ 'ui-kit': {
1237
+ folder: 'ui-kit',
1238
+ nested: false,
1239
+ inFolder: true,
1240
+ target: (reactFolder, { fileName })=>node_path.join(reactFolder, 'ui-kit', fileName),
1241
+ classPrefix: '()',
1242
+ classSuffix: 'Props(?![\\w$])|(?![\\w$])',
1243
+ storyTitle: (segments)=>`UI-kit/${segments.join('')}`
1244
+ },
1245
+ hook: {
1246
+ folder: shared.join('/'),
1247
+ nested: false,
1248
+ inFolder: false,
1249
+ ownFile: (fileBase)=>new RegExp(`^${prefix}-${escapeRegExp(fileBase)}(?:\\.|$)`),
1250
+ target: (reactFolder, { fileName })=>node_path.join(reactFolder, ...shared, `${prefix}-${fileName}${hook}`),
1251
+ classPrefix: `(${prefix})`,
1252
+ classSuffix: '(?![\\w$])'
1253
+ }
1254
+ };
1255
+ };
1256
+ const reactKindLayouts = kindLayouts('react');
1257
+ const svelteKindLayouts = kindLayouts('svelte');
1258
+ const frontendKindLayouts = (framework)=>'svelte' === framework ? svelteKindLayouts : reactKindLayouts;
1259
+ const reactKindTitles = {
1260
+ page: [
1261
+ 'Page',
1262
+ 'pages'
1263
+ ],
1264
+ widget: [
1265
+ 'Widget',
1266
+ 'widgets'
1267
+ ],
1268
+ 'ui-kit': [
1269
+ 'UI-kit component',
1270
+ 'UI-kit components'
1271
+ ],
1272
+ hook: [
1273
+ 'Shared hook',
1274
+ 'shared hooks'
1275
+ ]
1276
+ };
1277
+ const svelteKindTitles = {
1278
+ ...reactKindTitles,
1279
+ hook: [
1280
+ 'Shared model',
1281
+ 'shared models'
1282
+ ]
1283
+ };
1284
+ const frontendKindTitles = (framework)=>'svelte' === framework ? svelteKindTitles : reactKindTitles;
1285
+ const reactModuleName = (kind, rawName, framework = 'react')=>'hook' === kind ? rawName.trim().replace(new RegExp(`^${frontendLogicNaming[framework].prefix}-`), '') : rawName;
1286
+ const nestedName = (folders, fileBase)=>{
1287
+ const prefix = `${folders.join('-')}-`;
1288
+ const last = folders.length && fileBase.startsWith(prefix) ? fileBase.slice(prefix.length) : fileBase;
1289
+ return [
1290
+ ...folders,
1291
+ last
1292
+ ].join('/');
1293
+ };
1294
+ const declaredClassName = (filePaths, suffix, name)=>{
1295
+ for (const filePath of filePaths){
1296
+ if (!node_fs.existsSync(filePath)) continue;
1297
+ const declared = node_fs.readFileSync(filePath, 'utf8').match(new RegExp(`(?:export\\s+(?:const|function)|\\bdefault\\s+as)\\s+(\\w+)${suffix}\\b`))?.[1];
1298
+ if (declared) return declared;
1299
+ }
1300
+ return new NestedName(name).ClassName;
1301
+ };
1302
+ const findUiKit = (reactFolder, framework)=>{
1303
+ const { component } = frontendExtensions[framework];
1304
+ const root = node_path.join(reactFolder, 'ui-kit');
1305
+ if (!node_fs.existsSync(root)) return [];
1306
+ return node_fs.readdirSync(root, {
1307
+ withFileTypes: true
1308
+ }).filter((entry)=>entry.isDirectory() && node_fs.existsSync(node_path.join(root, entry.name, `${entry.name}${component}`))).map(({ name })=>({
1309
+ kind: 'ui-kit',
1310
+ name,
1311
+ path: node_path.join(root, name),
1312
+ fileBase: name,
1313
+ ClassName: declaredClassName([
1314
+ node_path.join(root, name, `${name}${component}`),
1315
+ node_path.join(root, name, 'index.ts')
1316
+ ], '', name)
1317
+ }));
1318
+ };
1319
+ const hookFile = {
1320
+ react: /\.tsx?$/,
1321
+ svelte: /\.svelte\.[jt]s$/
1322
+ };
1323
+ const findHooks = (reactFolder, framework)=>{
1324
+ const { prefix, shared } = frontendLogicNaming[framework];
1325
+ const root = node_path.join(reactFolder, ...shared);
1326
+ if (!node_fs.existsSync(root)) return [];
1327
+ const extension = hookFile[framework];
1328
+ const ownPrefix = new RegExp(`^${prefix}-`);
1329
+ return node_fs.readdirSync(root).filter((file)=>ownPrefix.test(file) && extension.test(file) && !/\.(spec|test)\./.test(file)).map((file)=>{
1330
+ const name = file.replace(ownPrefix, '').replace(extension, '');
1331
+ const content = node_fs.readFileSync(node_path.join(root, file), 'utf8');
1332
+ return {
1333
+ kind: 'hook',
1334
+ name,
1335
+ path: node_path.join(root, file),
1336
+ fileBase: name,
1337
+ ClassName: content.match(new RegExp(`export\\s+(?:const|function)\\s+${prefix}(\\w+)\\b`))?.[1] ?? new NestedName(name).ClassName
1338
+ };
1339
+ });
1340
+ };
1341
+ const findReactModules = (reactFolder, kind, framework = 'react')=>{
1342
+ const { component } = frontendExtensions[framework];
1343
+ const modules = 'ui-kit' === kind ? findUiKit(reactFolder, framework) : 'hook' === kind ? findHooks(reactFolder, framework) : 'page' === kind ? module_move_walk(node_path.join(reactFolder, 'pages')).filter((file)=>file.endsWith(`-page${component}`)).map((file)=>{
1344
+ const folders = node_path.relative(node_path.join(reactFolder, 'pages'), node_path.dirname(file)).split(node_path.sep).filter((segment)=>!!segment);
1345
+ const fileBase = node_path.basename(file, `-page${component}`);
1346
+ const name = nestedName(folders, fileBase);
1347
+ return {
1348
+ kind,
1349
+ name,
1350
+ path: file,
1351
+ fileBase,
1352
+ ClassName: declaredClassName([
1353
+ file
1354
+ ], 'Page', name)
1355
+ };
1356
+ }) : module_move_walk(node_path.join(reactFolder, 'widgets')).filter((file)=>file.endsWith(`-widget${component}`)).map((file)=>{
1357
+ const folder = node_path.dirname(file);
1358
+ const name = toPosix(node_path.relative(node_path.join(reactFolder, 'widgets'), folder));
1359
+ return {
1360
+ kind,
1361
+ name,
1362
+ path: folder,
1363
+ fileBase: node_path.basename(file, `-widget${component}`),
1364
+ ClassName: declaredClassName([
1365
+ file,
1366
+ node_path.join(folder, 'index.ts')
1367
+ ], 'Widget', name)
1368
+ };
1369
+ });
1370
+ return modules.sort((a, b)=>a.name.localeCompare(b.name));
1371
+ };
1372
+ const react_module_move_targetPath = (reactFolder, module, rawName, framework)=>frontendKindLayouts(framework)[module.kind].target(reactFolder, new NestedName(reactModuleName(module.kind, rawName, framework)));
1373
+ const validateMove = (reactFolder, module, rawName, framework = 'react')=>{
1374
+ const nameError = NestedName.validate(rawName);
1375
+ if (true !== nameError) return nameError;
1376
+ if (!frontendKindLayouts(framework)[module.kind].nested && /[\\/]/.test(rawName)) return `UI-kit components and ${frontendKindTitles(framework).hook[1]} have no folders: enter a name without "/"`;
1377
+ const target = react_module_move_targetPath(reactFolder, module, rawName, framework);
1378
+ if (target !== module.path && node_fs.existsSync(target)) return `${node_path.relative(reactFolder, target)} already exists`;
1379
+ if (target.startsWith(`${module.path}${node_path.sep}`)) return 'A widget cannot be moved into itself';
1380
+ return true;
1381
+ };
1382
+ const routeFolder = (appFolder, rawName)=>{
1383
+ const { folders, folderName } = new NestedName(rawName);
1384
+ return node_path.join(appFolder, ...folders, folderName);
1385
+ };
1386
+ const routeFiles = (folder)=>node_fs.existsSync(folder) ? node_fs.readdirSync(folder, {
1387
+ withFileTypes: true
1388
+ }).filter((entry)=>entry.isFile()).map((entry)=>node_path.join(folder, entry.name)) : [];
1389
+ const moveReactModule = (projectRoot, reactFolder, module, rawName, route, framework = 'react')=>{
1390
+ const layout = frontendKindLayouts(framework)[module.kind];
1391
+ const newName = new NestedName(reactModuleName(module.kind, rawName, framework));
1392
+ const { prefix } = frontendLogicNaming[framework];
1393
+ const target = react_module_move_targetPath(reactFolder, module, rawName, framework);
1394
+ const newClassName = newName.ClassName;
1395
+ const renameFile = (name)=>name.replace(new RegExp(`^(${prefix}-)?${escapeRegExp(module.fileBase)}(?=[-.]|$)`), (_, own = '')=>`${own}${newName.fileName}`);
1396
+ const oldFolder = layout.inFolder ? module.path : node_path.dirname(module.path);
1397
+ const newFolder = layout.inFolder ? target : node_path.dirname(target);
1398
+ const ownsPath = (candidate)=>layout.inFolder ? candidate === oldFolder || candidate.startsWith(`${oldFolder}${node_path.sep}`) : node_path.dirname(candidate) === oldFolder && layout.ownFile(module.fileBase).test(node_path.basename(candidate));
1399
+ const routeFileSet = new Set(route ? routeFiles(route.from) : []);
1400
+ const routeTarget = (candidate)=>{
1401
+ if (!route) return;
1402
+ const file = [
1403
+ ...routeFileSet
1404
+ ].find((x)=>x === candidate || x.replace(codeExtension, '') === candidate);
1405
+ if (!file) return;
1406
+ const moved = node_path.join(route.to, node_path.relative(route.from, file));
1407
+ return file === candidate ? moved : moved.replace(codeExtension, '');
1408
+ };
1409
+ const movedPath = (candidate)=>{
1410
+ const routed = routeTarget(candidate);
1411
+ if (routed) return routed;
1412
+ if (!ownsPath(candidate)) return;
1413
+ const segments = node_path.relative(oldFolder, candidate).split(node_path.sep);
1414
+ const last = segments.length - 1;
1415
+ segments[last] = renameFile(segments[last]);
1416
+ return node_path.join(newFolder, ...segments);
1417
+ };
1418
+ const moduleFiles = reactModuleFiles(module, framework);
1419
+ const moves = new Map([
1420
+ ...moduleFiles,
1421
+ ...routeFileSet
1422
+ ].map((file)=>[
1423
+ file,
1424
+ movedPath(file) ?? file
1425
+ ]));
1426
+ const classPattern = new RegExp(`(?<![\\w$])${layout.classPrefix}${escapeRegExp(module.ClassName)}(?=${layout.classSuffix})`, 'g');
1427
+ const oldTitle = layout.storyTitle?.('ui-kit' === module.kind ? [
1428
+ module.ClassName
1429
+ ] : module.name.split('/').map((segment)=>new NestedName(segment).ClassName));
1430
+ const titlePattern = oldTitle && new RegExp(`(['"\`])${escapeRegExp(oldTitle)}\\1`, 'g');
1431
+ const newTitle = layout.storyTitle?.('ui-kit' === module.kind ? [
1432
+ newClassName
1433
+ ] : newName.classNameSegments);
1434
+ return stageModuleMove({
1435
+ projectRoot,
1436
+ stopAt: reactFolder,
1437
+ stopAtFor: (file)=>route && routeFileSet.has(file) ? route.appFolder : void 0,
1438
+ moves,
1439
+ movedPath,
1440
+ rename: (content, { moved })=>{
1441
+ const renamed = content.replace(classPattern, (_, use)=>`${use ?? ''}${newClassName}`);
1442
+ return moved && titlePattern ? renamed.replace(titlePattern, (_, quote)=>`${quote}${newTitle}${quote}`) : renamed;
1443
+ }
1444
+ });
1445
+ };
1446
+ const routePageFile = {
1447
+ react: 'page.tsx',
1448
+ svelte: '+page.svelte'
1449
+ };
1450
+ const pageRouteFolder = (appFolder, page, framework = 'react')=>{
1451
+ const folder = routeFolder(appFolder, page.name);
1452
+ const routePage = node_path.join(folder, routePageFile[framework]);
1453
+ return node_fs.existsSync(routePage) && new RegExp(`(?<![\\w$])${page.ClassName}Page(?![\\w$])`).test(node_fs.readFileSync(routePage, 'utf8')) ? folder : void 0;
1454
+ };
1455
+ const reactModuleFiles = (module, framework)=>{
1456
+ const layout = frontendKindLayouts(framework)[module.kind];
1457
+ if (layout.inFolder) return module_move_walk(module.path);
1458
+ const folder = node_path.dirname(module.path);
1459
+ const own = layout.ownFile(module.fileBase);
1460
+ return node_fs.readdirSync(folder, {
1461
+ withFileTypes: true
1462
+ }).filter((entry)=>entry.isFile() && own.test(entry.name)).map((entry)=>node_path.join(folder, entry.name));
1463
+ };
1464
+ const importSpecifier = /(?:\bfrom\s*|\bimport\s*\(\s*|\brequire\s*\(\s*|\bimport\s+)(['"])([^'"\n]+)\1/g;
1465
+ const deleteReactModule = (projectRoot, reactFolder, module, route, framework = 'react')=>{
1466
+ const moduleFiles = reactModuleFiles(module, framework);
1467
+ const routeFileList = route ? routeFiles(route.folder) : [];
1468
+ const own = new Set([
1469
+ ...moduleFiles,
1470
+ ...routeFileList
1471
+ ]);
1472
+ const stems = new Set(moduleFiles.map((file)=>file.replace(codeExtension, '')));
1473
+ const isModule = (resolved)=>stems.has(resolved) || moduleFiles.includes(resolved) || frontendKindLayouts(framework)[module.kind].inFolder && (resolved === module.path || resolved.startsWith(`${module.path}${node_path.sep}`));
1474
+ const { codeFiles, resolve } = projectImports(projectRoot);
1475
+ const relative = (file)=>toPosix(node_path.relative(projectRoot, file));
1476
+ const usedBy = [];
1477
+ for (const [file, content] of codeFiles)if (!own.has(file)) for (const [, , specifier] of content.matchAll(importSpecifier)){
1478
+ const target = resolve(specifier, file)?.resolved;
1479
+ if (target && isModule(target)) usedBy.push([
1480
+ relative(file),
1481
+ relative(target)
1482
+ ]);
1483
+ }
1484
+ if (usedBy.length) return {
1485
+ usedBy
1486
+ };
1487
+ for (const file of moduleFiles)new File(file).delete(reactFolder);
1488
+ for (const file of routeFileList)new File(file).delete(route.appFolder);
1489
+ return {
1490
+ deleted: [
1491
+ ...moduleFiles,
1492
+ ...routeFileList
1493
+ ]
1494
+ };
1495
+ };
1496
+ export { ConfigFile, File, Folder, NestedName, ProjectRoot, UnknownFormatNaming, addBranchedImplementation, addClassMember, addConstructorParameters, addImport, addWireDependencies, availableDependencies, boundedContextLocation, boundedContextName, boundedContextNames, boundedContextPath, boundedContextsFolderName, branchNameSchema, canDependOn, codeExtension, compilerOption, configFileName, configSchema, configuredDependencyRules, crossContextImplementation, crossContextImportAllowed, defaultDependencyRules, deleteReactModule, discardPendingChanges, domainFirstPackages, escapeRegExp, fileModuleKind, filesToOverwrite, findReactModules, findWiredModules, frontendKindLayouts, frontendKindTitles, frontendLogicNaming, hasNeighboringBoundedContext, implementationKinds, implementationLabelSchema, implementationType, isCrossContextImplementation, isOutdatedConfig, isSuggestedFor, moduleKindOf, module_move_walk, moveReactModule, namedImportFiles, outdatedConfigMessage, pageRouteFolder, pendingChanges, projectImports, readWiredModule, relativeImport, routeFolder, routePageFile, rulesSchema, scaffoldBackendRules, splitContextSegments, stageModuleMove, toPosix, validateBoundedContextName, validateMove, wireBranches, wireDependencies, wiredDependencyNames, wiring_layers, withoutOverwrites, writePendingChanges };
@@ -236,7 +236,7 @@ export declare const describeAgentCommand: (command: AgentCommand) => {
236
236
  overwrite: z.ZodOptional<z.ZodBoolean>;
237
237
  dryRun: z.ZodOptional<z.ZodBoolean>;
238
238
  }, z.core.$strict>, z.ZodObject<{
239
- operation: z.ZodLiteral<"shared-hook">;
239
+ operation: z.ZodLiteral<"shared-hook" | "shared-model">;
240
240
  name: z.ZodString;
241
241
  overwrite: z.ZodOptional<z.ZodBoolean>;
242
242
  dryRun: z.ZodOptional<z.ZodBoolean>;
@@ -265,7 +265,7 @@ export declare const describeAgentCommand: (command: AgentCommand) => {
265
265
  overwrite: z.ZodOptional<z.ZodBoolean>;
266
266
  dryRun: z.ZodOptional<z.ZodBoolean>;
267
267
  }, z.core.$strict>, z.ZodObject<{
268
- operation: z.ZodLiteral<"move-shared-hook">;
268
+ operation: z.ZodLiteral<"move-shared-hook" | "move-shared-model">;
269
269
  module: z.ZodString;
270
270
  name: z.ZodString;
271
271
  overwrite: z.ZodOptional<z.ZodBoolean>;
@@ -276,7 +276,7 @@ export declare const describeAgentCommand: (command: AgentCommand) => {
276
276
  overwrite: z.ZodOptional<z.ZodBoolean>;
277
277
  dryRun: z.ZodOptional<z.ZodBoolean>;
278
278
  }, z.core.$strict>, z.ZodObject<{
279
- operation: z.ZodLiteral<"delete-shared-hook">;
279
+ operation: z.ZodLiteral<"delete-shared-hook" | "delete-shared-model">;
280
280
  module: z.ZodString;
281
281
  overwrite: z.ZodOptional<z.ZodBoolean>;
282
282
  dryRun: z.ZodOptional<z.ZodBoolean>;
@@ -430,12 +430,12 @@ export declare const describeAgentCommand: (command: AgentCommand) => {
430
430
  available: boolean;
431
431
  }[];
432
432
  reactModules: {
433
- kind: "page" | "widget" | "ui-kit" | "hook";
433
+ kind: string;
434
434
  name: string;
435
435
  file: string;
436
436
  }[];
437
437
  svelteModules: {
438
- kind: "page" | "widget" | "ui-kit" | "hook";
438
+ kind: string;
439
439
  name: string;
440
440
  file: string;
441
441
  }[];
@@ -215,7 +215,7 @@ export declare const reactRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
215
215
  overwrite: z.ZodOptional<z.ZodBoolean>;
216
216
  dryRun: z.ZodOptional<z.ZodBoolean>;
217
217
  }, z.core.$strict>, z.ZodObject<{
218
- operation: z.ZodLiteral<"shared-hook">;
218
+ operation: z.ZodLiteral<"shared-hook" | "shared-model">;
219
219
  name: z.ZodString;
220
220
  overwrite: z.ZodOptional<z.ZodBoolean>;
221
221
  dryRun: z.ZodOptional<z.ZodBoolean>;
@@ -244,7 +244,7 @@ export declare const reactRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
244
244
  overwrite: z.ZodOptional<z.ZodBoolean>;
245
245
  dryRun: z.ZodOptional<z.ZodBoolean>;
246
246
  }, z.core.$strict>, z.ZodObject<{
247
- operation: z.ZodLiteral<"move-shared-hook">;
247
+ operation: z.ZodLiteral<"move-shared-hook" | "move-shared-model">;
248
248
  module: z.ZodString;
249
249
  name: z.ZodString;
250
250
  overwrite: z.ZodOptional<z.ZodBoolean>;
@@ -255,7 +255,7 @@ export declare const reactRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
255
255
  overwrite: z.ZodOptional<z.ZodBoolean>;
256
256
  dryRun: z.ZodOptional<z.ZodBoolean>;
257
257
  }, z.core.$strict>, z.ZodObject<{
258
- operation: z.ZodLiteral<"delete-shared-hook">;
258
+ operation: z.ZodLiteral<"delete-shared-hook" | "delete-shared-model">;
259
259
  module: z.ZodString;
260
260
  overwrite: z.ZodOptional<z.ZodBoolean>;
261
261
  dryRun: z.ZodOptional<z.ZodBoolean>;
@@ -287,7 +287,7 @@ export declare const svelteRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
287
287
  overwrite: z.ZodOptional<z.ZodBoolean>;
288
288
  dryRun: z.ZodOptional<z.ZodBoolean>;
289
289
  }, z.core.$strict>, z.ZodObject<{
290
- operation: z.ZodLiteral<"shared-hook">;
290
+ operation: z.ZodLiteral<"shared-hook" | "shared-model">;
291
291
  name: z.ZodString;
292
292
  overwrite: z.ZodOptional<z.ZodBoolean>;
293
293
  dryRun: z.ZodOptional<z.ZodBoolean>;
@@ -316,7 +316,7 @@ export declare const svelteRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
316
316
  overwrite: z.ZodOptional<z.ZodBoolean>;
317
317
  dryRun: z.ZodOptional<z.ZodBoolean>;
318
318
  }, z.core.$strict>, z.ZodObject<{
319
- operation: z.ZodLiteral<"move-shared-hook">;
319
+ operation: z.ZodLiteral<"move-shared-hook" | "move-shared-model">;
320
320
  module: z.ZodString;
321
321
  name: z.ZodString;
322
322
  overwrite: z.ZodOptional<z.ZodBoolean>;
@@ -327,7 +327,7 @@ export declare const svelteRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
327
327
  overwrite: z.ZodOptional<z.ZodBoolean>;
328
328
  dryRun: z.ZodOptional<z.ZodBoolean>;
329
329
  }, z.core.$strict>, z.ZodObject<{
330
- operation: z.ZodLiteral<"delete-shared-hook">;
330
+ operation: z.ZodLiteral<"delete-shared-hook" | "delete-shared-model">;
331
331
  module: z.ZodString;
332
332
  overwrite: z.ZodOptional<z.ZodBoolean>;
333
333
  dryRun: z.ZodOptional<z.ZodBoolean>;
@@ -591,7 +591,7 @@ export declare const requestSchemaFor: (command: AgentCommand) => z.ZodDiscrimin
591
591
  overwrite: z.ZodOptional<z.ZodBoolean>;
592
592
  dryRun: z.ZodOptional<z.ZodBoolean>;
593
593
  }, z.core.$strict>, z.ZodObject<{
594
- operation: z.ZodLiteral<"shared-hook">;
594
+ operation: z.ZodLiteral<"shared-hook" | "shared-model">;
595
595
  name: z.ZodString;
596
596
  overwrite: z.ZodOptional<z.ZodBoolean>;
597
597
  dryRun: z.ZodOptional<z.ZodBoolean>;
@@ -620,7 +620,7 @@ export declare const requestSchemaFor: (command: AgentCommand) => z.ZodDiscrimin
620
620
  overwrite: z.ZodOptional<z.ZodBoolean>;
621
621
  dryRun: z.ZodOptional<z.ZodBoolean>;
622
622
  }, z.core.$strict>, z.ZodObject<{
623
- operation: z.ZodLiteral<"move-shared-hook">;
623
+ operation: z.ZodLiteral<"move-shared-hook" | "move-shared-model">;
624
624
  module: z.ZodString;
625
625
  name: z.ZodString;
626
626
  overwrite: z.ZodOptional<z.ZodBoolean>;
@@ -631,7 +631,7 @@ export declare const requestSchemaFor: (command: AgentCommand) => z.ZodDiscrimin
631
631
  overwrite: z.ZodOptional<z.ZodBoolean>;
632
632
  dryRun: z.ZodOptional<z.ZodBoolean>;
633
633
  }, z.core.$strict>, z.ZodObject<{
634
- operation: z.ZodLiteral<"delete-shared-hook">;
634
+ operation: z.ZodLiteral<"delete-shared-hook" | "delete-shared-model">;
635
635
  module: z.ZodString;
636
636
  overwrite: z.ZodOptional<z.ZodBoolean>;
637
637
  dryRun: z.ZodOptional<z.ZodBoolean>;
@@ -1,9 +1,14 @@
1
1
  import type { Folder } from './file-system';
2
2
  import type { FrontendFramework } from './react-module-move';
3
+ /**
4
+ * The operation name of reusable logic: React shared hooks, Svelte shared
5
+ * models (`createN` in `shared/model`).
6
+ */
7
+ export declare const sharedLogicOperation: Record<FrontendFramework, string>;
3
8
  /**
4
9
  * Operations on frontend modules by their agent operation name; menus and
5
10
  * `--request` run the same ones.
6
11
  */
7
12
  export declare const frontendOperations: (folder: Folder, framework: FrontendFramework) => Record<string, () => Promise<unknown>>;
8
13
  /** Menu items of df-react and df-svelte → agent operations. */
9
- export declare const frontendMenu: [string, string][];
14
+ export declare const frontendMenu: (framework: FrontendFramework) => [string, string][];