@open-mercato/cli 0.4.2-canary-0d5782b643 → 0.4.2-canary-eb5f87d5f9
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.
|
@@ -326,12 +326,14 @@ async function generateModuleRegistry(options) {
|
|
|
326
326
|
if (e.isDirectory()) {
|
|
327
327
|
if (e.name === "__tests__" || e.name === "__mocks__") continue;
|
|
328
328
|
walk(path.join(dir, e.name), [...rel, e.name]);
|
|
329
|
-
} else if (e.isFile() && e.name === "route.ts"
|
|
329
|
+
} else if (e.isFile() && (e.name === "route.ts" || e.name === "route.js")) {
|
|
330
|
+
routeFiles.push([...rel, e.name].join("/"));
|
|
331
|
+
}
|
|
330
332
|
}
|
|
331
333
|
};
|
|
332
334
|
if (fs.existsSync(apiPkg)) walk(apiPkg);
|
|
333
335
|
if (fs.existsSync(apiApp)) walk(apiApp);
|
|
334
|
-
const routeList = Array.from(new Set(routeFiles));
|
|
336
|
+
const routeList = Array.from(new Set(routeFiles.map((f) => f.replace(/\.(ts|js)$/, ""))));
|
|
335
337
|
const isDynamicRoute = (p) => p.split("/").some((seg) => /\[|\[\[\.\.\./.test(seg));
|
|
336
338
|
routeList.sort((a, b) => {
|
|
337
339
|
const ad = isDynamicRoute(a) ? 1 : 0;
|
|
@@ -344,12 +346,15 @@ async function generateModuleRegistry(options) {
|
|
|
344
346
|
segs.pop();
|
|
345
347
|
const reqSegs = [modId, ...segs];
|
|
346
348
|
const importName = `R${importId++}_${toVar(modId)}_${toVar(segs.join("_") || "index")}`;
|
|
347
|
-
const
|
|
348
|
-
const
|
|
349
|
+
const appFileTs = path.join(apiApp, ...segs, "route.ts");
|
|
350
|
+
const appFileJs = path.join(apiApp, ...segs, "route.js");
|
|
351
|
+
const fromApp = fs.existsSync(appFileTs) || fs.existsSync(appFileJs);
|
|
349
352
|
const apiSegPath = segs.join("/");
|
|
350
353
|
const importPath = `${fromApp ? appImportBase : imps.pkgBase}/api${apiSegPath ? `/${apiSegPath}` : ""}/route`;
|
|
351
354
|
const routePath = "/" + reqSegs.filter(Boolean).join("/");
|
|
352
|
-
const
|
|
355
|
+
const pkgFileTs = path.join(apiPkg, ...segs, "route.ts");
|
|
356
|
+
const pkgFileJs = path.join(apiPkg, ...segs, "route.js");
|
|
357
|
+
const sourceFile = fromApp ? fs.existsSync(appFileTs) ? appFileTs : appFileJs : fs.existsSync(pkgFileTs) ? pkgFileTs : pkgFileJs;
|
|
353
358
|
const hasOpenApi = await moduleHasExport(sourceFile, "openApi");
|
|
354
359
|
const docsPart = hasOpenApi ? `, docs: ${importName}.openApi` : "";
|
|
355
360
|
imports.push(`import * as ${importName} from '${importPath}'`);
|
|
@@ -363,28 +368,30 @@ async function generateModuleRegistry(options) {
|
|
|
363
368
|
if (methodNames.has(e.name.toLowerCase())) continue;
|
|
364
369
|
if (e.name === "__tests__" || e.name === "__mocks__") continue;
|
|
365
370
|
walkPlain(path.join(dir, e.name), [...rel, e.name]);
|
|
366
|
-
} else if (e.isFile() && e.name.endsWith(".ts")
|
|
367
|
-
if (/\.(test|spec)\.ts$/.test(e.name)) continue;
|
|
371
|
+
} else if (e.isFile() && (e.name.endsWith(".ts") || e.name.endsWith(".js")) && !e.name.startsWith("route.")) {
|
|
372
|
+
if (/\.(test|spec)\.(ts|js)$/.test(e.name)) continue;
|
|
373
|
+
if (e.name.endsWith(".d.ts")) continue;
|
|
368
374
|
plainFiles.push([...rel, e.name].join("/"));
|
|
369
375
|
}
|
|
370
376
|
}
|
|
371
377
|
};
|
|
372
378
|
if (fs.existsSync(apiPkg)) walkPlain(apiPkg);
|
|
373
379
|
if (fs.existsSync(apiApp)) walkPlain(apiApp);
|
|
374
|
-
const plainList = Array.from(new Set(plainFiles));
|
|
380
|
+
const plainList = Array.from(new Set(plainFiles.map((f) => f.replace(/\.(ts|js)$/, ""))));
|
|
375
381
|
for (const rel of plainList) {
|
|
376
382
|
const segs = rel.split("/");
|
|
377
|
-
const
|
|
378
|
-
const pathWithoutExt = file.replace(/\.ts$/, "");
|
|
383
|
+
const pathWithoutExt = segs.pop();
|
|
379
384
|
const fullSegs = [...segs, pathWithoutExt];
|
|
380
385
|
const routePath = "/" + [modId, ...fullSegs].filter(Boolean).join("/");
|
|
381
386
|
const importName = `R${importId++}_${toVar(modId)}_${toVar(fullSegs.join("_") || "index")}`;
|
|
382
|
-
const
|
|
383
|
-
const
|
|
387
|
+
const appFileTs = path.join(apiApp, ...fullSegs) + ".ts";
|
|
388
|
+
const appFileJs = path.join(apiApp, ...fullSegs) + ".js";
|
|
389
|
+
const fromApp = fs.existsSync(appFileTs) || fs.existsSync(appFileJs);
|
|
384
390
|
const plainSegPath = fullSegs.join("/");
|
|
385
391
|
const importPath = `${fromApp ? appImportBase : imps.pkgBase}/api${plainSegPath ? `/${plainSegPath}` : ""}`;
|
|
386
|
-
const
|
|
387
|
-
const
|
|
392
|
+
const pkgFileTs = path.join(apiPkg, ...fullSegs) + ".ts";
|
|
393
|
+
const pkgFileJs = path.join(apiPkg, ...fullSegs) + ".js";
|
|
394
|
+
const sourceFile = fromApp ? fs.existsSync(appFileTs) ? appFileTs : appFileJs : fs.existsSync(pkgFileTs) ? pkgFileTs : pkgFileJs;
|
|
388
395
|
const hasOpenApi = await moduleHasExport(sourceFile, "openApi");
|
|
389
396
|
const docsPart = hasOpenApi ? `, docs: ${importName}.openApi` : "";
|
|
390
397
|
imports.push(`import * as ${importName} from '${importPath}'`);
|
|
@@ -402,25 +409,27 @@ async function generateModuleRegistry(options) {
|
|
|
402
409
|
if (e.isDirectory()) {
|
|
403
410
|
if (e.name === "__tests__" || e.name === "__mocks__") continue;
|
|
404
411
|
walk2(path.join(dir, e.name), [...rel, e.name]);
|
|
405
|
-
} else if (e.isFile() && e.name.endsWith(".ts")) {
|
|
406
|
-
if (/\.(test|spec)\.ts$/.test(e.name)) continue;
|
|
412
|
+
} else if (e.isFile() && (e.name.endsWith(".ts") || e.name.endsWith(".js"))) {
|
|
413
|
+
if (/\.(test|spec)\.(ts|js)$/.test(e.name)) continue;
|
|
414
|
+
if (e.name.endsWith(".d.ts")) continue;
|
|
407
415
|
apiFiles.push([...rel, e.name].join("/"));
|
|
408
416
|
}
|
|
409
417
|
}
|
|
410
418
|
};
|
|
411
419
|
walk2(methodDir);
|
|
412
|
-
const methodList = Array.from(new Set(apiFiles));
|
|
420
|
+
const methodList = Array.from(new Set(apiFiles.map((f) => f.replace(/\.(ts|js)$/, ""))));
|
|
413
421
|
for (const rel of methodList) {
|
|
414
422
|
const segs = rel.split("/");
|
|
415
|
-
const
|
|
416
|
-
const pathWithoutExt = file.replace(/\.ts$/, "");
|
|
423
|
+
const pathWithoutExt = segs.pop();
|
|
417
424
|
const fullSegs = [...segs, pathWithoutExt];
|
|
418
425
|
const routePath = "/" + [modId, ...fullSegs].filter(Boolean).join("/");
|
|
419
426
|
const importName = `H${importId++}_${toVar(modId)}_${toVar(method)}_${toVar(fullSegs.join("_"))}`;
|
|
420
427
|
const fromApp = methodDir === appMethodDir;
|
|
421
428
|
const importPath = `${fromApp ? appImportBase : imps.pkgBase}/api/${method.toLowerCase()}/${fullSegs.join("/")}`;
|
|
422
429
|
const metaName = `RM${importId++}_${toVar(modId)}_${toVar(method)}_${toVar(fullSegs.join("_"))}`;
|
|
423
|
-
const
|
|
430
|
+
const sourceFileTs = path.join(methodDir, ...segs, `${pathWithoutExt}.ts`);
|
|
431
|
+
const sourceFileJs = path.join(methodDir, ...segs, `${pathWithoutExt}.js`);
|
|
432
|
+
const sourceFile = fs.existsSync(sourceFileTs) ? sourceFileTs : sourceFileJs;
|
|
424
433
|
const hasOpenApi = await moduleHasExport(sourceFile, "openApi");
|
|
425
434
|
const docsPart = hasOpenApi ? `, docs: ${metaName}.openApi` : "";
|
|
426
435
|
imports.push(`import ${importName}, * as ${metaName} from '${importPath}'`);
|
|
@@ -478,8 +487,9 @@ async function generateModuleRegistry(options) {
|
|
|
478
487
|
if (e.isDirectory()) {
|
|
479
488
|
if (e.name === "__tests__" || e.name === "__mocks__") continue;
|
|
480
489
|
walk(path.join(dir, e.name), [...rel, e.name]);
|
|
481
|
-
} else if (e.isFile() && e.name.endsWith(".ts")) {
|
|
482
|
-
if (/\.(test|spec)\.ts$/.test(e.name)) continue;
|
|
490
|
+
} else if (e.isFile() && (e.name.endsWith(".ts") || e.name.endsWith(".js"))) {
|
|
491
|
+
if (/\.(test|spec)\.(ts|js)$/.test(e.name)) continue;
|
|
492
|
+
if (e.name.endsWith(".d.ts")) continue;
|
|
483
493
|
found.push([...rel, e.name].join("/"));
|
|
484
494
|
}
|
|
485
495
|
}
|
|
@@ -490,11 +500,12 @@ async function generateModuleRegistry(options) {
|
|
|
490
500
|
for (const rel of files) {
|
|
491
501
|
const segs = rel.split("/");
|
|
492
502
|
const file = segs.pop();
|
|
493
|
-
const name = file.replace(/\.ts$/, "");
|
|
503
|
+
const name = file.replace(/\.(ts|js)$/, "");
|
|
494
504
|
const importName = `Subscriber${importId++}_${toVar(modId)}_${toVar([...segs, name].join("_") || "index")}`;
|
|
495
505
|
const metaName = `SubscriberMeta${importId++}_${toVar(modId)}_${toVar([...segs, name].join("_") || "index")}`;
|
|
496
|
-
const
|
|
497
|
-
const
|
|
506
|
+
const appFileTs = path.join(subApp, ...segs, `${name}.ts`);
|
|
507
|
+
const appFileJs = path.join(subApp, ...segs, `${name}.js`);
|
|
508
|
+
const fromApp = fs.existsSync(appFileTs) || fs.existsSync(appFileJs);
|
|
498
509
|
const importPath = `${fromApp ? appImportBase : imps.pkgBase}/subscribers/${[...segs, name].join("/")}`;
|
|
499
510
|
imports.push(`import ${importName}, * as ${metaName} from '${importPath}'`);
|
|
500
511
|
const sid = [modId, ...segs, name].filter(Boolean).join(":");
|
|
@@ -513,8 +524,9 @@ async function generateModuleRegistry(options) {
|
|
|
513
524
|
if (e.isDirectory()) {
|
|
514
525
|
if (e.name === "__tests__" || e.name === "__mocks__") continue;
|
|
515
526
|
walk(path.join(dir, e.name), [...rel, e.name]);
|
|
516
|
-
} else if (e.isFile() && e.name.endsWith(".ts")) {
|
|
517
|
-
if (/\.(test|spec)\.ts$/.test(e.name)) continue;
|
|
527
|
+
} else if (e.isFile() && (e.name.endsWith(".ts") || e.name.endsWith(".js"))) {
|
|
528
|
+
if (/\.(test|spec)\.(ts|js)$/.test(e.name)) continue;
|
|
529
|
+
if (e.name.endsWith(".d.ts")) continue;
|
|
518
530
|
found.push([...rel, e.name].join("/"));
|
|
519
531
|
}
|
|
520
532
|
}
|
|
@@ -525,9 +537,10 @@ async function generateModuleRegistry(options) {
|
|
|
525
537
|
for (const rel of files) {
|
|
526
538
|
const segs = rel.split("/");
|
|
527
539
|
const file = segs.pop();
|
|
528
|
-
const name = file.replace(/\.ts$/, "");
|
|
529
|
-
const
|
|
530
|
-
const
|
|
540
|
+
const name = file.replace(/\.(ts|js)$/, "");
|
|
541
|
+
const appFileTs = path.join(wrkApp, ...segs, `${name}.ts`);
|
|
542
|
+
const appFileJs = path.join(wrkApp, ...segs, `${name}.js`);
|
|
543
|
+
const fromApp = fs.existsSync(appFileTs) || fs.existsSync(appFileJs);
|
|
531
544
|
const importPath = `${fromApp ? appImportBase : imps.pkgBase}/workers/${[...segs, name].join("/")}`;
|
|
532
545
|
if (!await moduleHasExport(importPath, "metadata")) continue;
|
|
533
546
|
const importName = `Worker${importId++}_${toVar(modId)}_${toVar([...segs, name].join("_") || "index")}`;
|
|
@@ -952,8 +965,9 @@ async function generateModuleRegistryCli(options) {
|
|
|
952
965
|
if (e.isDirectory()) {
|
|
953
966
|
if (e.name === "__tests__" || e.name === "__mocks__") continue;
|
|
954
967
|
walk(path.join(dir, e.name), [...rel, e.name]);
|
|
955
|
-
} else if (e.isFile() && e.name.endsWith(".ts")) {
|
|
956
|
-
if (/\.(test|spec)\.ts$/.test(e.name)) continue;
|
|
968
|
+
} else if (e.isFile() && (e.name.endsWith(".ts") || e.name.endsWith(".js"))) {
|
|
969
|
+
if (/\.(test|spec)\.(ts|js)$/.test(e.name)) continue;
|
|
970
|
+
if (e.name.endsWith(".d.ts")) continue;
|
|
957
971
|
found.push([...rel, e.name].join("/"));
|
|
958
972
|
}
|
|
959
973
|
}
|
|
@@ -964,11 +978,12 @@ async function generateModuleRegistryCli(options) {
|
|
|
964
978
|
for (const rel of files) {
|
|
965
979
|
const segs = rel.split("/");
|
|
966
980
|
const file = segs.pop();
|
|
967
|
-
const name = file.replace(/\.ts$/, "");
|
|
981
|
+
const name = file.replace(/\.(ts|js)$/, "");
|
|
968
982
|
const importName = `Subscriber${importId++}_${toVar(modId)}_${toVar([...segs, name].join("_") || "index")}`;
|
|
969
983
|
const metaName = `SubscriberMeta${importId++}_${toVar(modId)}_${toVar([...segs, name].join("_") || "index")}`;
|
|
970
|
-
const
|
|
971
|
-
const
|
|
984
|
+
const appFileTs = path.join(subApp, ...segs, `${name}.ts`);
|
|
985
|
+
const appFileJs = path.join(subApp, ...segs, `${name}.js`);
|
|
986
|
+
const fromApp = fs.existsSync(appFileTs) || fs.existsSync(appFileJs);
|
|
972
987
|
const importPath = `${fromApp ? appImportBase : imps.pkgBase}/subscribers/${[...segs, name].join("/")}`;
|
|
973
988
|
imports.push(`import ${importName}, * as ${metaName} from '${importPath}'`);
|
|
974
989
|
const sid = [modId, ...segs, name].filter(Boolean).join(":");
|
|
@@ -987,8 +1002,9 @@ async function generateModuleRegistryCli(options) {
|
|
|
987
1002
|
if (e.isDirectory()) {
|
|
988
1003
|
if (e.name === "__tests__" || e.name === "__mocks__") continue;
|
|
989
1004
|
walk(path.join(dir, e.name), [...rel, e.name]);
|
|
990
|
-
} else if (e.isFile() && e.name.endsWith(".ts")) {
|
|
991
|
-
if (/\.(test|spec)\.ts$/.test(e.name)) continue;
|
|
1005
|
+
} else if (e.isFile() && (e.name.endsWith(".ts") || e.name.endsWith(".js"))) {
|
|
1006
|
+
if (/\.(test|spec)\.(ts|js)$/.test(e.name)) continue;
|
|
1007
|
+
if (e.name.endsWith(".d.ts")) continue;
|
|
992
1008
|
found.push([...rel, e.name].join("/"));
|
|
993
1009
|
}
|
|
994
1010
|
}
|
|
@@ -999,9 +1015,10 @@ async function generateModuleRegistryCli(options) {
|
|
|
999
1015
|
for (const rel of files) {
|
|
1000
1016
|
const segs = rel.split("/");
|
|
1001
1017
|
const file = segs.pop();
|
|
1002
|
-
const name = file.replace(/\.ts$/, "");
|
|
1003
|
-
const
|
|
1004
|
-
const
|
|
1018
|
+
const name = file.replace(/\.(ts|js)$/, "");
|
|
1019
|
+
const appFileTs = path.join(wrkApp, ...segs, `${name}.ts`);
|
|
1020
|
+
const appFileJs = path.join(wrkApp, ...segs, `${name}.js`);
|
|
1021
|
+
const fromApp = fs.existsSync(appFileTs) || fs.existsSync(appFileJs);
|
|
1005
1022
|
const importPath = `${fromApp ? appImportBase : imps.pkgBase}/workers/${[...segs, name].join("/")}`;
|
|
1006
1023
|
if (!await moduleHasExport(importPath, "metadata")) continue;
|
|
1007
1024
|
const importName = `Worker${importId++}_${toVar(modId)}_${toVar([...segs, name].join("_") || "index")}`;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/generators/module-registry.ts"],
|
|
4
|
-
"sourcesContent": ["import fs from 'node:fs'\nimport path from 'node:path'\nimport type { PackageResolver } from '../resolver'\nimport {\n calculateChecksum,\n calculateStructureChecksum,\n readChecksumRecord,\n writeChecksumRecord,\n toVar,\n moduleHasExport,\n logGenerationResult,\n type GeneratorResult,\n createGeneratorResult,\n} from '../utils'\n\ntype HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'\n\n/**\n * Find a module file, checking for both .ts (src) and .js (dist) extensions.\n * Supports both simple names (e.g., 'cli') and nested paths (e.g., 'data/extensions').\n * Returns the path if found, null otherwise.\n */\nfunction findModuleFile(basePath: string, ...segments: string[]): string | null {\n const name = segments.pop()!\n const dir = segments.length ? path.join(basePath, ...segments) : basePath\n const tsPath = path.join(dir, `${name}.ts`)\n if (fs.existsSync(tsPath)) return tsPath\n const jsPath = path.join(dir, `${name}.js`)\n if (fs.existsSync(jsPath)) return jsPath\n return null\n}\n\nexport interface ModuleRegistryOptions {\n resolver: PackageResolver\n quiet?: boolean\n}\n\nexport async function generateModuleRegistry(options: ModuleRegistryOptions): Promise<GeneratorResult> {\n const { resolver, quiet = false } = options\n const result = createGeneratorResult()\n\n const outputDir = resolver.getOutputDir()\n const outFile = path.join(outputDir, 'modules.generated.ts')\n const checksumFile = path.join(outputDir, 'modules.generated.checksum')\n const widgetsOutFile = path.join(outputDir, 'dashboard-widgets.generated.ts')\n const widgetsChecksumFile = path.join(outputDir, 'dashboard-widgets.generated.checksum')\n const injectionWidgetsOutFile = path.join(outputDir, 'injection-widgets.generated.ts')\n const injectionWidgetsChecksumFile = path.join(outputDir, 'injection-widgets.generated.checksum')\n const injectionTablesOutFile = path.join(outputDir, 'injection-tables.generated.ts')\n const injectionTablesChecksumFile = path.join(outputDir, 'injection-tables.generated.checksum')\n const searchOutFile = path.join(outputDir, 'search.generated.ts')\n const searchChecksumFile = path.join(outputDir, 'search.generated.checksum')\n\n const enabled = resolver.loadEnabledModules()\n const imports: string[] = []\n const moduleDecls: string[] = []\n let importId = 0\n const trackedRoots = new Set<string>()\n const requiresByModule = new Map<string, string[]>()\n const allDashboardWidgets = new Map<string, { moduleId: string; source: 'app' | 'package'; importPath: string }>()\n const allInjectionWidgets = new Map<string, { moduleId: string; source: 'app' | 'package'; importPath: string }>()\n const allInjectionTables: Array<{ moduleId: string; importPath: string; importName: string }> = []\n const searchConfigs: string[] = []\n const searchImports: string[] = []\n\n for (const entry of enabled) {\n const modId = entry.id\n const roots = resolver.getModulePaths(entry)\n const imps = resolver.getModuleImportBase(entry)\n trackedRoots.add(roots.appBase)\n trackedRoots.add(roots.pkgBase)\n\n // For @app modules, use relative paths since @/ alias doesn't work in Node.js runtime\n // From .mercato/generated/, go up two levels (../..) to reach the app root, then into src/modules/\n const isAppModule = entry.from === '@app'\n const appImportBase = isAppModule ? `../../src/modules/${modId}` : imps.appBase\n\n const frontendRoutes: string[] = []\n const backendRoutes: string[] = []\n const apis: string[] = []\n let cliImportName: string | null = null\n const translations: string[] = []\n const subscribers: string[] = []\n const workers: string[] = []\n let infoImportName: string | null = null\n let extensionsImportName: string | null = null\n let fieldsImportName: string | null = null\n let featuresImportName: string | null = null\n let customEntitiesImportName: string | null = null\n let searchImportName: string | null = null\n let customFieldSetsExpr: string = '[]'\n const dashboardWidgets: string[] = []\n const injectionWidgets: string[] = []\n let injectionTableImportName: string | null = null\n\n // Module metadata: index.ts (overrideable)\n const appIndex = findModuleFile(roots.appBase, 'index')\n const pkgIndex = findModuleFile(roots.pkgBase, 'index')\n const indexTs = appIndex ?? pkgIndex\n if (indexTs) {\n infoImportName = `I${importId++}_${toVar(modId)}`\n const importPath = indexTs.startsWith(roots.appBase) ? `${appImportBase}/index` : `${imps.pkgBase}/index`\n imports.push(`import * as ${infoImportName} from '${importPath}'`)\n // Try to eagerly read ModuleInfo.requires for dependency validation\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const mod = require(indexTs)\n const reqs: string[] | undefined =\n mod?.metadata && Array.isArray(mod.metadata.requires) ? mod.metadata.requires : undefined\n if (reqs && reqs.length) requiresByModule.set(modId, reqs)\n } catch {}\n }\n\n // Pages: frontend\n const feApp = path.join(roots.appBase, 'frontend')\n const fePkg = path.join(roots.pkgBase, 'frontend')\n if (fs.existsSync(feApp) || fs.existsSync(fePkg)) {\n const found: string[] = []\n const walk = (dir: string, rel: string[] = []) => {\n for (const e of fs.readdirSync(dir, { withFileTypes: true })) {\n if (e.isDirectory()) {\n if (e.name === '__tests__' || e.name === '__mocks__') continue\n walk(path.join(dir, e.name), [...rel, e.name])\n } else if (e.isFile() && e.name.endsWith('.tsx')) found.push([...rel, e.name].join('/'))\n }\n }\n if (fs.existsSync(fePkg)) walk(fePkg)\n if (fs.existsSync(feApp)) walk(feApp)\n let files = Array.from(new Set(found))\n // Ensure static routes win over dynamic ones (e.g., 'create' before '[id]')\n const isDynamic = (p: string) => /\\/(\\[|\\[\\[\\.\\.\\.)/.test(p) || /^\\[/.test(p)\n files.sort((a, b) => {\n const ad = isDynamic(a) ? 1 : 0\n const bd = isDynamic(b) ? 1 : 0\n if (ad !== bd) return ad - bd // static first\n // Longer, more specific paths later to not shadow peers\n return a.localeCompare(b)\n })\n // Next-style page.tsx\n for (const rel of files.filter((f) => f.endsWith('/page.tsx') || f === 'page.tsx')) {\n const segs = rel.split('/')\n segs.pop()\n const importName = `C${importId++}_${toVar(modId)}_${toVar(segs.join('_') || 'index')}`\n const pageModName = `CM${importId++}_${toVar(modId)}_${toVar(segs.join('_') || 'index')}`\n const appFile = path.join(feApp, ...segs, 'page.tsx')\n const fromApp = fs.existsSync(appFile)\n const sub = segs.length ? `${segs.join('/')}/page` : 'page'\n const importPath = `${fromApp ? appImportBase : imps.pkgBase}/frontend/${sub}`\n const routePath = '/' + (segs.join('/') || '')\n const metaCandidates = [\n path.join(fromApp ? feApp : fePkg, ...segs, 'page.meta.ts'),\n path.join(fromApp ? feApp : fePkg, ...segs, 'meta.ts'),\n ]\n const metaPath = metaCandidates.find((p) => fs.existsSync(p))\n let metaExpr = 'undefined'\n if (metaPath) {\n const metaImportName = `M${importId++}_${toVar(modId)}_${toVar(segs.join('_') || 'index')}`\n const metaImportPath = `${fromApp ? appImportBase : imps.pkgBase}/frontend/${[...segs, path.basename(metaPath).replace(/\\.ts$/, '')].join('/')}`\n imports.push(`import * as ${metaImportName} from '${metaImportPath}'`)\n metaExpr = `(${metaImportName}.metadata as any)`\n imports.push(`import ${importName} from '${importPath}'`)\n } else {\n metaExpr = `(${pageModName} as any).metadata`\n imports.push(`import ${importName}, * as ${pageModName} from '${importPath}'`)\n }\n frontendRoutes.push(\n `{ pattern: '${routePath || '/'}', requireAuth: (${metaExpr})?.requireAuth, requireRoles: (${metaExpr})?.requireRoles, requireFeatures: (${metaExpr})?.requireFeatures, title: (${metaExpr})?.pageTitle ?? (${metaExpr})?.title, titleKey: (${metaExpr})?.pageTitleKey ?? (${metaExpr})?.titleKey, group: (${metaExpr})?.pageGroup ?? (${metaExpr})?.group, groupKey: (${metaExpr})?.pageGroupKey ?? (${metaExpr})?.groupKey, icon: (${metaExpr})?.icon, order: (${metaExpr})?.pageOrder ?? (${metaExpr})?.order, priority: (${metaExpr})?.pagePriority ?? (${metaExpr})?.priority, navHidden: (${metaExpr})?.navHidden, visible: (${metaExpr})?.visible, enabled: (${metaExpr})?.enabled, breadcrumb: (${metaExpr})?.breadcrumb, Component: ${importName} }`\n )\n }\n // Back-compat direct files\n for (const rel of files.filter((f) => !f.endsWith('/page.tsx') && f !== 'page.tsx')) {\n const segs = rel.split('/')\n const file = segs.pop()!\n const name = file.replace(/\\.tsx$/, '')\n const routeSegs = [...segs, name].filter(Boolean)\n const importName = `C${importId++}_${toVar(modId)}_${toVar(routeSegs.join('_') || 'index')}`\n const pageModName = `CM${importId++}_${toVar(modId)}_${toVar(routeSegs.join('_') || 'index')}`\n const appFile = path.join(feApp, ...segs, `${name}.tsx`)\n const fromApp = fs.existsSync(appFile)\n const importPath = `${fromApp ? appImportBase : imps.pkgBase}/frontend/${[...segs, name].join('/')}`\n const routePath = '/' + (routeSegs.join('/') || '')\n const metaCandidates = [\n path.join(fromApp ? feApp : fePkg, ...segs, name + '.meta.ts'),\n path.join(fromApp ? feApp : fePkg, ...segs, 'meta.ts'),\n ]\n const metaPath = metaCandidates.find((p) => fs.existsSync(p))\n let metaExpr = 'undefined'\n if (metaPath) {\n const metaImportName = `M${importId++}_${toVar(modId)}_${toVar(routeSegs.join('_') || 'index')}`\n const metaBase = path.basename(metaPath)\n const metaImportSub = metaBase === 'meta.ts' ? 'meta' : name + '.meta'\n const metaImportPath = `${fromApp ? appImportBase : imps.pkgBase}/frontend/${[...segs, metaImportSub].join('/')}`\n imports.push(`import * as ${metaImportName} from '${metaImportPath}'`)\n metaExpr = `(${metaImportName}.metadata as any)`\n imports.push(`import ${importName} from '${importPath}'`)\n } else {\n metaExpr = `(${pageModName} as any).metadata`\n imports.push(`import ${importName}, * as ${pageModName} from '${importPath}'`)\n }\n frontendRoutes.push(\n `{ pattern: '${routePath || '/'}', requireAuth: (${metaExpr})?.requireAuth, requireRoles: (${metaExpr})?.requireRoles, requireFeatures: (${metaExpr})?.requireFeatures, title: (${metaExpr})?.pageTitle ?? (${metaExpr})?.title, titleKey: (${metaExpr})?.pageTitleKey ?? (${metaExpr})?.titleKey, group: (${metaExpr})?.pageGroup ?? (${metaExpr})?.group, groupKey: (${metaExpr})?.pageGroupKey ?? (${metaExpr})?.groupKey, visible: (${metaExpr})?.visible, enabled: (${metaExpr})?.enabled, Component: ${importName} }`\n )\n }\n }\n\n // Entity extensions: src/modules/<module>/data/extensions.ts\n {\n const appFile = findModuleFile(roots.appBase, 'data', 'extensions')\n const pkgFile = findModuleFile(roots.pkgBase, 'data', 'extensions')\n const hasApp = !!appFile\n const hasPkg = !!pkgFile\n if (hasApp || hasPkg) {\n const importName = `X_${toVar(modId)}_${importId++}`\n const importPath = hasApp ? `${appImportBase}/data/extensions` : `${imps.pkgBase}/data/extensions`\n imports.push(`import * as ${importName} from '${importPath}'`)\n extensionsImportName = importName\n }\n }\n\n // RBAC feature declarations: module root acl.ts\n {\n const rootApp = findModuleFile(roots.appBase, 'acl')\n const rootPkg = findModuleFile(roots.pkgBase, 'acl')\n const hasRoot = rootApp || rootPkg\n if (hasRoot) {\n const importName = `ACL_${toVar(modId)}_${importId++}`\n const useApp = rootApp ?? rootPkg!\n const importPath = useApp.startsWith(roots.appBase) ? `${appImportBase}/acl` : `${imps.pkgBase}/acl`\n imports.push(`import * as ${importName} from '${importPath}'`)\n featuresImportName = importName\n }\n }\n\n // Custom entities declarations: module root ce.ts\n {\n const appFile = findModuleFile(roots.appBase, 'ce')\n const pkgFile = findModuleFile(roots.pkgBase, 'ce')\n const hasApp = !!appFile\n const hasPkg = !!pkgFile\n if (hasApp || hasPkg) {\n const importName = `CE_${toVar(modId)}_${importId++}`\n const importPath = hasApp ? `${appImportBase}/ce` : `${imps.pkgBase}/ce`\n imports.push(`import * as ${importName} from '${importPath}'`)\n customEntitiesImportName = importName\n }\n }\n\n // Search module configuration: module root search.ts\n {\n const appFile = findModuleFile(roots.appBase, 'search')\n const pkgFile = findModuleFile(roots.pkgBase, 'search')\n const hasApp = !!appFile\n const hasPkg = !!pkgFile\n if (hasApp || hasPkg) {\n const importName = `SEARCH_${toVar(modId)}_${importId++}`\n const importPath = hasApp ? `${appImportBase}/search` : `${imps.pkgBase}/search`\n const importStmt = `import * as ${importName} from '${importPath}'`\n imports.push(importStmt)\n searchImports.push(importStmt)\n searchImportName = importName\n }\n }\n\n // Custom field declarations: src/modules/<module>/data/fields.ts\n {\n const appFile = findModuleFile(roots.appBase, 'data', 'fields')\n const pkgFile = findModuleFile(roots.pkgBase, 'data', 'fields')\n const hasApp = !!appFile\n const hasPkg = !!pkgFile\n if (hasApp || hasPkg) {\n const importName = `F_${toVar(modId)}_${importId++}`\n const importPath = hasApp ? `${appImportBase}/data/fields` : `${imps.pkgBase}/data/fields`\n imports.push(`import * as ${importName} from '${importPath}'`)\n fieldsImportName = importName\n }\n }\n\n // Pages: backend\n const beApp = path.join(roots.appBase, 'backend')\n const bePkg = path.join(roots.pkgBase, 'backend')\n if (fs.existsSync(beApp) || fs.existsSync(bePkg)) {\n const found: string[] = []\n const walk = (dir: string, rel: string[] = []) => {\n for (const e of fs.readdirSync(dir, { withFileTypes: true })) {\n if (e.isDirectory()) {\n if (e.name === '__tests__' || e.name === '__mocks__') continue\n walk(path.join(dir, e.name), [...rel, e.name])\n } else if (e.isFile() && e.name.endsWith('.tsx')) found.push([...rel, e.name].join('/'))\n }\n }\n if (fs.existsSync(bePkg)) walk(bePkg)\n if (fs.existsSync(beApp)) walk(beApp)\n let files = Array.from(new Set(found))\n const isDynamic = (p: string) => /\\/(\\[|\\[\\[\\.\\.\\.)/.test(p) || /^\\[/.test(p)\n files.sort((a, b) => {\n const ad = isDynamic(a) ? 1 : 0\n const bd = isDynamic(b) ? 1 : 0\n if (ad !== bd) return ad - bd\n return a.localeCompare(b)\n })\n // Next-style\n for (const rel of files.filter((f) => f.endsWith('/page.tsx') || f === 'page.tsx')) {\n const segs = rel.split('/')\n segs.pop()\n const importName = `B${importId++}_${toVar(modId)}_${toVar(segs.join('_') || 'index')}`\n const pageModName = `BM${importId++}_${toVar(modId)}_${toVar(segs.join('_') || 'index')}`\n const appFile = path.join(beApp, ...segs, 'page.tsx')\n const fromApp = fs.existsSync(appFile)\n const sub = segs.length ? `${segs.join('/')}/page` : 'page'\n const importPath = `${fromApp ? appImportBase : imps.pkgBase}/backend/${sub}`\n const basePath = segs.join('/') || modId\n const routePath = '/backend/' + basePath\n const metaCandidates = [\n path.join(fromApp ? beApp : bePkg, ...segs, 'page.meta.ts'),\n path.join(fromApp ? beApp : bePkg, ...segs, 'meta.ts'),\n ]\n const metaPath = metaCandidates.find((p) => fs.existsSync(p))\n let metaExpr = 'undefined'\n if (metaPath) {\n const metaImportName = `BM${importId++}_${toVar(modId)}_${toVar(segs.join('_') || 'index')}`\n const metaImportPath = `${fromApp ? appImportBase : imps.pkgBase}/backend/${[...segs, path.basename(metaPath).replace(/\\.ts$/, '')].join('/')}`\n imports.push(`import * as ${metaImportName} from '${metaImportPath}'`)\n metaExpr = `(${metaImportName}.metadata as any)`\n imports.push(`import ${importName} from '${importPath}'`)\n } else {\n metaExpr = `(${pageModName} as any).metadata`\n imports.push(`import ${importName}, * as ${pageModName} from '${importPath}'`)\n }\n backendRoutes.push(\n `{ pattern: '${routePath}', requireAuth: (${metaExpr})?.requireAuth, requireRoles: (${metaExpr})?.requireRoles, requireFeatures: (${metaExpr})?.requireFeatures, title: (${metaExpr})?.pageTitle ?? (${metaExpr})?.title, titleKey: (${metaExpr})?.pageTitleKey ?? (${metaExpr})?.titleKey, group: (${metaExpr})?.pageGroup ?? (${metaExpr})?.group, groupKey: (${metaExpr})?.pageGroupKey ?? (${metaExpr})?.groupKey, icon: (${metaExpr})?.icon, order: (${metaExpr})?.pageOrder ?? (${metaExpr})?.order, priority: (${metaExpr})?.pagePriority ?? (${metaExpr})?.priority, navHidden: (${metaExpr})?.navHidden, visible: (${metaExpr})?.visible, enabled: (${metaExpr})?.enabled, breadcrumb: (${metaExpr})?.breadcrumb, Component: ${importName} }`\n )\n }\n // Direct files\n for (const rel of files.filter((f) => !f.endsWith('/page.tsx') && f !== 'page.tsx')) {\n const segs = rel.split('/')\n const file = segs.pop()!\n const name = file.replace(/\\.tsx$/, '')\n const importName = `B${importId++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n const pageModName = `BM${importId++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n const appFile = path.join(beApp, ...segs, `${name}.tsx`)\n const fromApp = fs.existsSync(appFile)\n const importPath = `${fromApp ? appImportBase : imps.pkgBase}/backend/${[...segs, name].join('/')}`\n const routePath = '/backend/' + [modId, ...segs, name].filter(Boolean).join('/')\n const metaCandidates = [\n path.join(fromApp ? beApp : bePkg, ...segs, name + '.meta.ts'),\n path.join(fromApp ? beApp : bePkg, ...segs, 'meta.ts'),\n ]\n const metaPath = metaCandidates.find((p) => fs.existsSync(p))\n let metaExpr = 'undefined'\n if (metaPath) {\n const metaImportName = `BM${importId++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n const metaBase = path.basename(metaPath)\n const metaImportSub = metaBase === 'meta.ts' ? 'meta' : name + '.meta'\n const metaImportPath = `${fromApp ? appImportBase : imps.pkgBase}/backend/${[...segs, metaImportSub].join('/')}`\n imports.push(`import * as ${metaImportName} from '${metaImportPath}'`)\n metaExpr = `${metaImportName}.metadata`\n imports.push(`import ${importName} from '${importPath}'`)\n } else {\n metaExpr = `(${pageModName} as any).metadata`\n imports.push(`import ${importName}, * as ${pageModName} from '${importPath}'`)\n }\n backendRoutes.push(\n `{ pattern: '${routePath}', requireAuth: (${metaExpr})?.requireAuth, requireRoles: (${metaExpr})?.requireRoles, requireFeatures: (${metaExpr})?.requireFeatures, title: (${metaExpr})?.pageTitle ?? (${metaExpr})?.title, titleKey: (${metaExpr})?.pageTitleKey ?? (${metaExpr})?.titleKey, group: (${metaExpr})?.pageGroup ?? (${metaExpr})?.group, groupKey: (${metaExpr})?.pageGroupKey ?? (${metaExpr})?.groupKey, icon: (${metaExpr})?.icon, order: (${metaExpr})?.pageOrder ?? (${metaExpr})?.order, priority: (${metaExpr})?.pagePriority ?? (${metaExpr})?.priority, navHidden: (${metaExpr})?.navHidden, visible: (${metaExpr})?.visible, enabled: (${metaExpr})?.enabled, breadcrumb: (${metaExpr})?.breadcrumb, Component: ${importName} }`\n )\n }\n }\n\n // APIs\n const apiApp = path.join(roots.appBase, 'api')\n const apiPkg = path.join(roots.pkgBase, 'api')\n if (fs.existsSync(apiApp) || fs.existsSync(apiPkg)) {\n // route.ts aggregations\n const routeFiles: string[] = []\n const walk = (dir: string, rel: string[] = []) => {\n for (const e of fs.readdirSync(dir, { withFileTypes: true })) {\n if (e.isDirectory()) {\n if (e.name === '__tests__' || e.name === '__mocks__') continue\n walk(path.join(dir, e.name), [...rel, e.name])\n } else if (e.isFile() && e.name === 'route.ts') routeFiles.push([...rel, e.name].join('/'))\n }\n }\n if (fs.existsSync(apiPkg)) walk(apiPkg)\n if (fs.existsSync(apiApp)) walk(apiApp)\n const routeList = Array.from(new Set(routeFiles))\n const isDynamicRoute = (p: string) => p.split('/').some((seg) => /\\[|\\[\\[\\.\\.\\./.test(seg))\n routeList.sort((a, b) => {\n const ad = isDynamicRoute(a) ? 1 : 0\n const bd = isDynamicRoute(b) ? 1 : 0\n if (ad !== bd) return ad - bd\n return a.localeCompare(b)\n })\n for (const rel of routeList) {\n const segs = rel.split('/')\n segs.pop()\n const reqSegs = [modId, ...segs]\n const importName = `R${importId++}_${toVar(modId)}_${toVar(segs.join('_') || 'index')}`\n const appFile = path.join(apiApp, ...segs, 'route.ts')\n const fromApp = fs.existsSync(appFile)\n const apiSegPath = segs.join('/')\n const importPath = `${fromApp ? appImportBase : imps.pkgBase}/api${apiSegPath ? `/${apiSegPath}` : ''}/route`\n const routePath = '/' + reqSegs.filter(Boolean).join('/')\n const sourceFile = fromApp ? appFile : path.join(apiPkg, ...segs, 'route.ts')\n const hasOpenApi = await moduleHasExport(sourceFile, 'openApi')\n const docsPart = hasOpenApi ? `, docs: ${importName}.openApi` : ''\n imports.push(`import * as ${importName} from '${importPath}'`)\n apis.push(`{ path: '${routePath}', metadata: (${importName} as any).metadata, handlers: ${importName} as any${docsPart} }`)\n }\n\n // Single files\n const plainFiles: string[] = []\n const methodNames = new Set(['get', 'post', 'put', 'patch', 'delete'])\n const walkPlain = (dir: string, rel: string[] = []) => {\n for (const e of fs.readdirSync(dir, { withFileTypes: true })) {\n if (e.isDirectory()) {\n if (methodNames.has(e.name.toLowerCase())) continue\n if (e.name === '__tests__' || e.name === '__mocks__') continue\n walkPlain(path.join(dir, e.name), [...rel, e.name])\n } else if (e.isFile() && e.name.endsWith('.ts') && e.name !== 'route.ts') {\n if (/\\.(test|spec)\\.ts$/.test(e.name)) continue\n plainFiles.push([...rel, e.name].join('/'))\n }\n }\n }\n if (fs.existsSync(apiPkg)) walkPlain(apiPkg)\n if (fs.existsSync(apiApp)) walkPlain(apiApp)\n const plainList = Array.from(new Set(plainFiles))\n for (const rel of plainList) {\n const segs = rel.split('/')\n const file = segs.pop()!\n const pathWithoutExt = file.replace(/\\.ts$/, '')\n const fullSegs = [...segs, pathWithoutExt]\n const routePath = '/' + [modId, ...fullSegs].filter(Boolean).join('/')\n const importName = `R${importId++}_${toVar(modId)}_${toVar(fullSegs.join('_') || 'index')}`\n const appFile = path.join(apiApp, ...fullSegs) + '.ts'\n const fromApp = fs.existsSync(appFile)\n const plainSegPath = fullSegs.join('/')\n const importPath = `${fromApp ? appImportBase : imps.pkgBase}/api${plainSegPath ? `/${plainSegPath}` : ''}`\n const pkgFile = path.join(apiPkg, ...fullSegs) + '.ts'\n const sourceFile = fromApp ? appFile : pkgFile\n const hasOpenApi = await moduleHasExport(sourceFile, 'openApi')\n const docsPart = hasOpenApi ? `, docs: ${importName}.openApi` : ''\n imports.push(`import * as ${importName} from '${importPath}'`)\n apis.push(`{ path: '${routePath}', metadata: (${importName} as any).metadata, handlers: ${importName} as any${docsPart} }`)\n }\n // Legacy per-method\n const methods: HttpMethod[] = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE']\n for (const method of methods) {\n const coreMethodDir = path.join(apiPkg, method.toLowerCase())\n const appMethodDir = path.join(apiApp, method.toLowerCase())\n const methodDir = fs.existsSync(appMethodDir) ? appMethodDir : coreMethodDir\n if (!fs.existsSync(methodDir)) continue\n const apiFiles: string[] = []\n const walk2 = (dir: string, rel: string[] = []) => {\n for (const e of fs.readdirSync(dir, { withFileTypes: true })) {\n if (e.isDirectory()) {\n if (e.name === '__tests__' || e.name === '__mocks__') continue\n walk2(path.join(dir, e.name), [...rel, e.name])\n } else if (e.isFile() && e.name.endsWith('.ts')) {\n if (/\\.(test|spec)\\.ts$/.test(e.name)) continue\n apiFiles.push([...rel, e.name].join('/'))\n }\n }\n }\n walk2(methodDir)\n const methodList = Array.from(new Set(apiFiles))\n for (const rel of methodList) {\n const segs = rel.split('/')\n const file = segs.pop()!\n const pathWithoutExt = file.replace(/\\.ts$/, '')\n const fullSegs = [...segs, pathWithoutExt]\n const routePath = '/' + [modId, ...fullSegs].filter(Boolean).join('/')\n const importName = `H${importId++}_${toVar(modId)}_${toVar(method)}_${toVar(fullSegs.join('_'))}`\n const fromApp = methodDir === appMethodDir\n const importPath = `${fromApp ? appImportBase : imps.pkgBase}/api/${method.toLowerCase()}/${fullSegs.join('/')}`\n const metaName = `RM${importId++}_${toVar(modId)}_${toVar(method)}_${toVar(fullSegs.join('_'))}`\n const sourceFile = path.join(methodDir, ...segs, file)\n const hasOpenApi = await moduleHasExport(sourceFile, 'openApi')\n const docsPart = hasOpenApi ? `, docs: ${metaName}.openApi` : ''\n imports.push(`import ${importName}, * as ${metaName} from '${importPath}'`)\n apis.push(`{ method: '${method}', path: '${routePath}', handler: ${importName}, metadata: ${metaName}.metadata${docsPart} }`)\n }\n }\n }\n\n // CLI\n const cliApp = findModuleFile(roots.appBase, 'cli')\n const cliPkg = findModuleFile(roots.pkgBase, 'cli')\n const cliPath = cliApp ?? cliPkg\n if (cliPath) {\n const importName = `CLI_${toVar(modId)}`\n const importPath = cliPath.startsWith(roots.appBase) ? `${appImportBase}/cli` : `${imps.pkgBase}/cli`\n imports.push(`import ${importName} from '${importPath}'`)\n cliImportName = importName\n }\n\n // Translations: merge core + app with app overriding\n const i18nApp = path.join(roots.appBase, 'i18n')\n const i18nCore = path.join(roots.pkgBase, 'i18n')\n const locales = new Set<string>()\n if (fs.existsSync(i18nCore))\n for (const e of fs.readdirSync(i18nCore, { withFileTypes: true }))\n if (e.isFile() && e.name.endsWith('.json')) locales.add(e.name.replace(/\\.json$/, ''))\n if (fs.existsSync(i18nApp))\n for (const e of fs.readdirSync(i18nApp, { withFileTypes: true }))\n if (e.isFile() && e.name.endsWith('.json')) locales.add(e.name.replace(/\\.json$/, ''))\n for (const locale of locales) {\n const coreHas = fs.existsSync(path.join(i18nCore, `${locale}.json`))\n const appHas = fs.existsSync(path.join(i18nApp, `${locale}.json`))\n if (coreHas && appHas) {\n const cName = `T_${toVar(modId)}_${toVar(locale)}_C`\n const aName = `T_${toVar(modId)}_${toVar(locale)}_A`\n imports.push(`import ${cName} from '${imps.pkgBase}/i18n/${locale}.json'`)\n imports.push(`import ${aName} from '${appImportBase}/i18n/${locale}.json'`)\n translations.push(\n `'${locale}': { ...( ${cName} as unknown as Record<string,string> ), ...( ${aName} as unknown as Record<string,string> ) }`\n )\n } else if (appHas) {\n const aName = `T_${toVar(modId)}_${toVar(locale)}_A`\n imports.push(`import ${aName} from '${appImportBase}/i18n/${locale}.json'`)\n translations.push(`'${locale}': ${aName} as unknown as Record<string,string>`)\n } else if (coreHas) {\n const cName = `T_${toVar(modId)}_${toVar(locale)}_C`\n imports.push(`import ${cName} from '${imps.pkgBase}/i18n/${locale}.json'`)\n translations.push(`'${locale}': ${cName} as unknown as Record<string,string>`)\n }\n }\n\n // Subscribers: src/modules/<module>/subscribers/*.ts\n const subApp = path.join(roots.appBase, 'subscribers')\n const subPkg = path.join(roots.pkgBase, 'subscribers')\n if (fs.existsSync(subApp) || fs.existsSync(subPkg)) {\n const found: string[] = []\n const walk = (dir: string, rel: string[] = []) => {\n for (const e of fs.readdirSync(dir, { withFileTypes: true })) {\n if (e.isDirectory()) {\n if (e.name === '__tests__' || e.name === '__mocks__') continue\n walk(path.join(dir, e.name), [...rel, e.name])\n } else if (e.isFile() && e.name.endsWith('.ts')) {\n if (/\\.(test|spec)\\.ts$/.test(e.name)) continue\n found.push([...rel, e.name].join('/'))\n }\n }\n }\n if (fs.existsSync(subPkg)) walk(subPkg)\n if (fs.existsSync(subApp)) walk(subApp)\n const files = Array.from(new Set(found))\n for (const rel of files) {\n const segs = rel.split('/')\n const file = segs.pop()!\n const name = file.replace(/\\.ts$/, '')\n const importName = `Subscriber${importId++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n const metaName = `SubscriberMeta${importId++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n const appFile = path.join(subApp, ...segs, `${name}.ts`)\n const fromApp = fs.existsSync(appFile)\n const importPath = `${fromApp ? appImportBase : imps.pkgBase}/subscribers/${[...segs, name].join('/')}`\n imports.push(`import ${importName}, * as ${metaName} from '${importPath}'`)\n const sid = [modId, ...segs, name].filter(Boolean).join(':')\n subscribers.push(\n `{ id: (((${metaName}.metadata) as any)?.id || '${sid}'), event: ((${metaName}.metadata) as any)?.event, persistent: ((${metaName}.metadata) as any)?.persistent, handler: ${importName} }`\n )\n }\n }\n\n // Workers: src/modules/<module>/workers/*.ts\n // Only includes files that export `metadata` with a `queue` property\n {\n const wrkApp = path.join(roots.appBase, 'workers')\n const wrkPkg = path.join(roots.pkgBase, 'workers')\n if (fs.existsSync(wrkApp) || fs.existsSync(wrkPkg)) {\n const found: string[] = []\n const walk = (dir: string, rel: string[] = []) => {\n for (const e of fs.readdirSync(dir, { withFileTypes: true })) {\n if (e.isDirectory()) {\n if (e.name === '__tests__' || e.name === '__mocks__') continue\n walk(path.join(dir, e.name), [...rel, e.name])\n } else if (e.isFile() && e.name.endsWith('.ts')) {\n if (/\\.(test|spec)\\.ts$/.test(e.name)) continue\n found.push([...rel, e.name].join('/'))\n }\n }\n }\n if (fs.existsSync(wrkPkg)) walk(wrkPkg)\n if (fs.existsSync(wrkApp)) walk(wrkApp)\n const files = Array.from(new Set(found))\n for (const rel of files) {\n const segs = rel.split('/')\n const file = segs.pop()!\n const name = file.replace(/\\.ts$/, '')\n const appFile = path.join(wrkApp, ...segs, `${name}.ts`)\n const fromApp = fs.existsSync(appFile)\n // Use package import path for checking exports (file path fails due to relative imports)\n const importPath = `${fromApp ? appImportBase : imps.pkgBase}/workers/${[...segs, name].join('/')}`\n // Only include files that export metadata with a queue property\n if (!(await moduleHasExport(importPath, 'metadata'))) continue\n const importName = `Worker${importId++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n const metaName = `WorkerMeta${importId++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n imports.push(`import ${importName}, * as ${metaName} from '${importPath}'`)\n const wid = [modId, 'workers', ...segs, name].filter(Boolean).join(':')\n workers.push(\n `{ id: (${metaName}.metadata as { id?: string })?.id || '${wid}', queue: (${metaName}.metadata as { queue: string }).queue, concurrency: (${metaName}.metadata as { concurrency?: number })?.concurrency ?? 1, handler: ${importName} as (job: unknown, ctx: unknown) => Promise<void> }`\n )\n }\n }\n }\n\n // Build combined customFieldSets expression from data/fields.ts and ce.ts (entities[].fields)\n {\n const parts: string[] = []\n if (fieldsImportName)\n parts.push(`(( ${fieldsImportName}.default ?? ${fieldsImportName}.fieldSets) as any) || []`)\n if (customEntitiesImportName)\n parts.push(\n `((( ${customEntitiesImportName}.default ?? ${customEntitiesImportName}.entities) as any) || []).filter((e: any) => Array.isArray(e.fields) && e.fields.length).map((e: any) => ({ entity: e.id, fields: e.fields, source: '${modId}' }))`\n )\n customFieldSetsExpr = parts.length ? `[...${parts.join(', ...')}]` : '[]'\n }\n\n // Dashboard widgets: src/modules/<module>/widgets/dashboard/**/widget.ts(x)\n {\n const widgetApp = path.join(roots.appBase, 'widgets', 'dashboard')\n const widgetPkg = path.join(roots.pkgBase, 'widgets', 'dashboard')\n if (fs.existsSync(widgetApp) || fs.existsSync(widgetPkg)) {\n const found: string[] = []\n const walk = (dir: string, rel: string[] = []) => {\n for (const e of fs.readdirSync(dir, { withFileTypes: true })) {\n if (e.isDirectory()) {\n if (e.name === '__tests__' || e.name === '__mocks__') continue\n walk(path.join(dir, e.name), [...rel, e.name])\n } else if (e.isFile() && /^widget\\.(t|j)sx?$/.test(e.name)) {\n found.push([...rel, e.name].join('/'))\n }\n }\n }\n if (fs.existsSync(widgetPkg)) walk(widgetPkg)\n if (fs.existsSync(widgetApp)) walk(widgetApp)\n const files = Array.from(new Set(found)).sort()\n for (const rel of files) {\n const appFile = path.join(widgetApp, ...rel.split('/'))\n const fromApp = fs.existsSync(appFile)\n const segs = rel.split('/')\n const file = segs.pop()!\n const base = file.replace(/\\.(t|j)sx?$/, '')\n const importPath = `${fromApp ? appImportBase : imps.pkgBase}/widgets/dashboard/${[...segs, base].join('/')}`\n const key = [modId, ...segs, base].filter(Boolean).join(':')\n const source = fromApp ? 'app' : 'package'\n dashboardWidgets.push(\n `{ moduleId: '${modId}', key: '${key}', source: '${source}', loader: () => import('${importPath}').then((mod) => mod.default ?? mod) }`\n )\n const existing = allDashboardWidgets.get(key)\n if (!existing || (existing.source !== 'app' && source === 'app')) {\n allDashboardWidgets.set(key, { moduleId: modId, source, importPath })\n }\n }\n }\n }\n\n // Injection widgets: src/modules/<module>/widgets/injection/**/widget.ts(x)\n {\n const widgetApp = path.join(roots.appBase, 'widgets', 'injection')\n const widgetPkg = path.join(roots.pkgBase, 'widgets', 'injection')\n if (fs.existsSync(widgetApp) || fs.existsSync(widgetPkg)) {\n const found: string[] = []\n const walk = (dir: string, rel: string[] = []) => {\n for (const e of fs.readdirSync(dir, { withFileTypes: true })) {\n if (e.isDirectory()) {\n if (e.name === '__tests__' || e.name === '__mocks__') continue\n walk(path.join(dir, e.name), [...rel, e.name])\n } else if (e.isFile() && /^widget\\.(t|j)sx?$/.test(e.name)) {\n found.push([...rel, e.name].join('/'))\n }\n }\n }\n if (fs.existsSync(widgetPkg)) walk(widgetPkg)\n if (fs.existsSync(widgetApp)) walk(widgetApp)\n const files = Array.from(new Set(found)).sort()\n for (const rel of files) {\n const appFile = path.join(widgetApp, ...rel.split('/'))\n const fromApp = fs.existsSync(appFile)\n const segs = rel.split('/')\n const file = segs.pop()!\n const base = file.replace(/\\.(t|j)sx?$/, '')\n const importPath = `${fromApp ? appImportBase : imps.pkgBase}/widgets/injection/${[...segs, base].join('/')}`\n const key = [modId, ...segs, base].filter(Boolean).join(':')\n const source = fromApp ? 'app' : 'package'\n injectionWidgets.push(\n `{ moduleId: '${modId}', key: '${key}', source: '${source}', loader: () => import('${importPath}').then((mod) => mod.default ?? mod) }`\n )\n const existing = allInjectionWidgets.get(key)\n if (!existing || (existing.source !== 'app' && source === 'app')) {\n allInjectionWidgets.set(key, { moduleId: modId, source, importPath })\n }\n }\n }\n }\n\n // Injection table: src/modules/<module>/widgets/injection-table.ts\n {\n const appFile = path.join(roots.appBase, 'widgets', 'injection-table.ts')\n const pkgFile = path.join(roots.pkgBase, 'widgets', 'injection-table.ts')\n const hasApp = fs.existsSync(appFile)\n const hasPkg = fs.existsSync(pkgFile)\n if (hasApp || hasPkg) {\n const importName = `InjTable_${toVar(modId)}_${importId++}`\n const importPath = hasApp ? `${appImportBase}/widgets/injection-table` : `${imps.pkgBase}/widgets/injection-table`\n imports.push(`import * as ${importName} from '${importPath}'`)\n injectionTableImportName = importName\n allInjectionTables.push({ moduleId: modId, importPath, importName })\n }\n }\n\n if (searchImportName) {\n searchConfigs.push(`{ moduleId: '${modId}', config: (${searchImportName}.default ?? ${searchImportName}.searchConfig ?? ${searchImportName}.config ?? null) }`)\n }\n\n moduleDecls.push(`{\n id: '${modId}',\n ${infoImportName ? `info: ${infoImportName}.metadata,` : ''}\n ${frontendRoutes.length ? `frontendRoutes: [${frontendRoutes.join(', ')}],` : ''}\n ${backendRoutes.length ? `backendRoutes: [${backendRoutes.join(', ')}],` : ''}\n ${apis.length ? `apis: [${apis.join(', ')}],` : ''}\n ${cliImportName ? `cli: ${cliImportName},` : ''}\n ${translations.length ? `translations: { ${translations.join(', ')} },` : ''}\n ${subscribers.length ? `subscribers: [${subscribers.join(', ')}],` : ''}\n ${workers.length ? `workers: [${workers.join(', ')}],` : ''}\n ${extensionsImportName ? `entityExtensions: ((${extensionsImportName}.default ?? ${extensionsImportName}.extensions) as import('@open-mercato/shared/modules/entities').EntityExtension[]) || [],` : ''}\n customFieldSets: ${customFieldSetsExpr},\n ${featuresImportName ? `features: ((${featuresImportName}.default ?? ${featuresImportName}.features) as any) || [],` : ''}\n ${customEntitiesImportName ? `customEntities: ((${customEntitiesImportName}.default ?? ${customEntitiesImportName}.entities) as any) || [],` : ''}\n ${dashboardWidgets.length ? `dashboardWidgets: [${dashboardWidgets.join(', ')}],` : ''}\n }`)\n }\n\n const output = `// AUTO-GENERATED by mercato generate registry\nimport type { Module } from '@open-mercato/shared/modules/registry'\n${imports.join('\\n')}\n\nexport const modules: Module[] = [\n ${moduleDecls.join(',\\n ')}\n]\nexport const modulesInfo = modules.map(m => ({ id: m.id, ...(m.info || {}) }))\nexport default modules\n`\n const widgetEntriesList = Array.from(allDashboardWidgets.entries()).sort(([a], [b]) => a.localeCompare(b))\n const widgetDecls = widgetEntriesList.map(\n ([key, data]) =>\n ` { moduleId: '${data.moduleId}', key: '${key}', source: '${data.source}', loader: () => import('${data.importPath}').then((mod) => mod.default ?? mod) }`\n )\n const widgetsOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { ModuleDashboardWidgetEntry } from '@open-mercato/shared/modules/registry'\n\nexport const dashboardWidgetEntries: ModuleDashboardWidgetEntry[] = [\n${widgetDecls.join(',\\n')}\n]\n`\n const searchEntriesLiteral = searchConfigs.join(',\\n ')\n const searchImportSection = searchImports.join('\\n')\n const searchOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { SearchModuleConfig } from '@open-mercato/shared/modules/search'\n${searchImportSection ? `\\n${searchImportSection}\\n` : '\\n'}type SearchConfigEntry = { moduleId: string; config: SearchModuleConfig | null }\n\nconst entriesRaw: SearchConfigEntry[] = [\n${searchEntriesLiteral ? ` ${searchEntriesLiteral}\\n` : ''}]\nconst entries = entriesRaw.filter((entry): entry is { moduleId: string; config: SearchModuleConfig } => entry.config != null)\n\nexport const searchModuleConfigEntries = entries\nexport const searchModuleConfigs: SearchModuleConfig[] = entries.map((entry) => entry.config)\n`\n\n // Validate module dependencies declared via ModuleInfo.requires\n {\n const enabledIds = new Set(enabled.map((e) => e.id))\n const problems: string[] = []\n for (const [modId, reqs] of requiresByModule.entries()) {\n const missing = reqs.filter((r) => !enabledIds.has(r))\n if (missing.length) {\n problems.push(`- Module \"${modId}\" requires: ${missing.join(', ')}`)\n }\n }\n if (problems.length) {\n console.error('\\nModule dependency check failed:')\n for (const p of problems) console.error(p)\n console.error('\\nFix: Enable required module(s) in src/modules.ts. Example:')\n console.error(\n ' export const enabledModules = [ { id: \\'' +\n Array.from(new Set(requiresByModule.values()).values()).join(\"' }, { id: '\") +\n \"' } ]\"\n )\n process.exit(1)\n }\n }\n\n const structureChecksum = calculateStructureChecksum(Array.from(trackedRoots))\n\n const modulesChecksum = { content: calculateChecksum(output), structure: structureChecksum }\n const existingModulesChecksum = readChecksumRecord(checksumFile)\n const shouldWriteModules =\n !existingModulesChecksum ||\n existingModulesChecksum.content !== modulesChecksum.content ||\n existingModulesChecksum.structure !== modulesChecksum.structure\n if (shouldWriteModules) {\n fs.mkdirSync(path.dirname(outFile), { recursive: true })\n fs.writeFileSync(outFile, output)\n writeChecksumRecord(checksumFile, modulesChecksum)\n result.filesWritten.push(outFile)\n } else {\n result.filesUnchanged.push(outFile)\n }\n if (!quiet) logGenerationResult(path.relative(process.cwd(), outFile), shouldWriteModules)\n\n const widgetsChecksum = { content: calculateChecksum(widgetsOutput), structure: structureChecksum }\n const existingWidgetsChecksum = readChecksumRecord(widgetsChecksumFile)\n const shouldWriteWidgets =\n !existingWidgetsChecksum ||\n existingWidgetsChecksum.content !== widgetsChecksum.content ||\n existingWidgetsChecksum.structure !== widgetsChecksum.structure\n if (shouldWriteWidgets) {\n fs.writeFileSync(widgetsOutFile, widgetsOutput)\n writeChecksumRecord(widgetsChecksumFile, widgetsChecksum)\n result.filesWritten.push(widgetsOutFile)\n } else {\n result.filesUnchanged.push(widgetsOutFile)\n }\n if (!quiet) logGenerationResult(path.relative(process.cwd(), widgetsOutFile), shouldWriteWidgets)\n\n const injectionWidgetEntriesList = Array.from(allInjectionWidgets.entries()).sort(([a], [b]) => a.localeCompare(b))\n const injectionWidgetDecls = injectionWidgetEntriesList.map(\n ([key, data]) =>\n ` { moduleId: '${data.moduleId}', key: '${key}', source: '${data.source}', loader: () => import('${data.importPath}').then((mod) => mod.default ?? mod) }`\n )\n const injectionWidgetsOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { ModuleInjectionWidgetEntry } from '@open-mercato/shared/modules/registry'\n\nexport const injectionWidgetEntries: ModuleInjectionWidgetEntry[] = [\n${injectionWidgetDecls.join(',\\n')}\n]\n`\n const injectionTableImports = allInjectionTables.map(\n (entry) => `import * as ${entry.importName} from '${entry.importPath}'`\n )\n const injectionTableDecls = allInjectionTables.map(\n (entry) =>\n ` { moduleId: '${entry.moduleId}', table: ((${entry.importName}.default ?? ${entry.importName}.injectionTable) as any) || {} }`\n )\n const injectionTablesOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { ModuleInjectionTable } from '@open-mercato/shared/modules/widgets/injection'\n${injectionTableImports.join('\\n')}\n\nexport const injectionTables: Array<{ moduleId: string; table: ModuleInjectionTable }> = [\n${injectionTableDecls.join(',\\n')}\n]\n`\n const injectionWidgetsChecksum = { content: calculateChecksum(injectionWidgetsOutput), structure: structureChecksum }\n const existingInjectionWidgetsChecksum = readChecksumRecord(injectionWidgetsChecksumFile)\n const shouldWriteInjectionWidgets =\n !existingInjectionWidgetsChecksum ||\n existingInjectionWidgetsChecksum.content !== injectionWidgetsChecksum.content ||\n existingInjectionWidgetsChecksum.structure !== injectionWidgetsChecksum.structure\n if (shouldWriteInjectionWidgets) {\n fs.writeFileSync(injectionWidgetsOutFile, injectionWidgetsOutput)\n writeChecksumRecord(injectionWidgetsChecksumFile, injectionWidgetsChecksum)\n result.filesWritten.push(injectionWidgetsOutFile)\n } else {\n result.filesUnchanged.push(injectionWidgetsOutFile)\n }\n if (!quiet) logGenerationResult(path.relative(process.cwd(), injectionWidgetsOutFile), shouldWriteInjectionWidgets)\n\n const injectionTablesChecksum = { content: calculateChecksum(injectionTablesOutput), structure: structureChecksum }\n const existingInjectionTablesChecksum = readChecksumRecord(injectionTablesChecksumFile)\n const shouldWriteInjectionTables =\n !existingInjectionTablesChecksum ||\n existingInjectionTablesChecksum.content !== injectionTablesChecksum.content ||\n existingInjectionTablesChecksum.structure !== injectionTablesChecksum.structure\n if (shouldWriteInjectionTables) {\n fs.writeFileSync(injectionTablesOutFile, injectionTablesOutput)\n writeChecksumRecord(injectionTablesChecksumFile, injectionTablesChecksum)\n result.filesWritten.push(injectionTablesOutFile)\n } else {\n result.filesUnchanged.push(injectionTablesOutFile)\n }\n if (!quiet) logGenerationResult(path.relative(process.cwd(), injectionTablesOutFile), shouldWriteInjectionTables)\n\n const searchChecksum = { content: calculateChecksum(searchOutput), structure: structureChecksum }\n const existingSearchChecksum = readChecksumRecord(searchChecksumFile)\n const shouldWriteSearch =\n !existingSearchChecksum ||\n existingSearchChecksum.content !== searchChecksum.content ||\n existingSearchChecksum.structure !== searchChecksum.structure\n if (shouldWriteSearch) {\n fs.writeFileSync(searchOutFile, searchOutput)\n writeChecksumRecord(searchChecksumFile, searchChecksum)\n result.filesWritten.push(searchOutFile)\n } else {\n result.filesUnchanged.push(searchOutFile)\n }\n if (!quiet) logGenerationResult(path.relative(process.cwd(), searchOutFile), shouldWriteSearch)\n\n return result\n}\n\n/**\n * Generate a CLI-specific module registry that excludes Next.js dependent code.\n * This produces modules.cli.generated.ts which can be loaded without Next.js runtime.\n *\n * Includes: module metadata, CLI commands, translations, subscribers, workers, entity extensions,\n * features/ACL, custom entities, vector config, custom fields\n * Excludes: frontend routes, backend routes, API handlers, dashboard/injection widgets\n */\nexport async function generateModuleRegistryCli(options: ModuleRegistryOptions): Promise<GeneratorResult> {\n const { resolver, quiet = false } = options\n const result = createGeneratorResult()\n\n const outputDir = resolver.getOutputDir()\n const outFile = path.join(outputDir, 'modules.cli.generated.ts')\n const checksumFile = path.join(outputDir, 'modules.cli.generated.checksum')\n\n const enabled = resolver.loadEnabledModules()\n const imports: string[] = []\n const moduleDecls: string[] = []\n let importId = 0\n const trackedRoots = new Set<string>()\n const requiresByModule = new Map<string, string[]>()\n\n for (const entry of enabled) {\n const modId = entry.id\n const roots = resolver.getModulePaths(entry)\n const imps = resolver.getModuleImportBase(entry)\n trackedRoots.add(roots.appBase)\n trackedRoots.add(roots.pkgBase)\n\n // For @app modules, use relative paths since @/ alias doesn't work in Node.js runtime\n // From .mercato/generated/, go up two levels (../..) to reach the app root, then into src/modules/\n const isAppModule = entry.from === '@app'\n const appImportBase = isAppModule ? `../../src/modules/${modId}` : imps.appBase\n\n let cliImportName: string | null = null\n const translations: string[] = []\n const subscribers: string[] = []\n const workers: string[] = []\n let infoImportName: string | null = null\n let extensionsImportName: string | null = null\n let fieldsImportName: string | null = null\n let featuresImportName: string | null = null\n let customEntitiesImportName: string | null = null\n let vectorImportName: string | null = null\n let customFieldSetsExpr: string = '[]'\n\n // Module metadata: index.ts (overrideable)\n const appIndex = findModuleFile(roots.appBase, 'index')\n const pkgIndex = findModuleFile(roots.pkgBase, 'index')\n const indexTs = appIndex ?? pkgIndex\n if (indexTs) {\n infoImportName = `I${importId++}_${toVar(modId)}`\n const importPath = indexTs.startsWith(roots.appBase) ? `${appImportBase}/index` : `${imps.pkgBase}/index`\n imports.push(`import * as ${infoImportName} from '${importPath}'`)\n // Try to eagerly read ModuleInfo.requires for dependency validation\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const mod = require(indexTs)\n const reqs: string[] | undefined =\n mod?.metadata && Array.isArray(mod.metadata.requires) ? mod.metadata.requires : undefined\n if (reqs && reqs.length) requiresByModule.set(modId, reqs)\n } catch {}\n }\n\n // Entity extensions: src/modules/<module>/data/extensions.ts\n {\n const appFile = findModuleFile(roots.appBase, 'data', 'extensions')\n const pkgFile = findModuleFile(roots.pkgBase, 'data', 'extensions')\n const hasApp = !!appFile\n const hasPkg = !!pkgFile\n if (hasApp || hasPkg) {\n const importName = `X_${toVar(modId)}_${importId++}`\n const importPath = hasApp ? `${appImportBase}/data/extensions` : `${imps.pkgBase}/data/extensions`\n imports.push(`import * as ${importName} from '${importPath}'`)\n extensionsImportName = importName\n }\n }\n\n // RBAC feature declarations: module root acl.ts\n {\n const rootApp = findModuleFile(roots.appBase, 'acl')\n const rootPkg = findModuleFile(roots.pkgBase, 'acl')\n const hasRoot = rootApp || rootPkg\n if (hasRoot) {\n const importName = `ACL_${toVar(modId)}_${importId++}`\n const useApp = rootApp ?? rootPkg!\n const importPath = useApp.startsWith(roots.appBase) ? `${appImportBase}/acl` : `${imps.pkgBase}/acl`\n imports.push(`import * as ${importName} from '${importPath}'`)\n featuresImportName = importName\n }\n }\n\n // Custom entities declarations: module root ce.ts\n {\n const appFile = findModuleFile(roots.appBase, 'ce')\n const pkgFile = findModuleFile(roots.pkgBase, 'ce')\n const hasApp = !!appFile\n const hasPkg = !!pkgFile\n if (hasApp || hasPkg) {\n const importName = `CE_${toVar(modId)}_${importId++}`\n const importPath = hasApp ? `${appImportBase}/ce` : `${imps.pkgBase}/ce`\n imports.push(`import * as ${importName} from '${importPath}'`)\n customEntitiesImportName = importName\n }\n }\n\n // Vector search configuration: module root vector.ts\n {\n const appFile = findModuleFile(roots.appBase, 'vector')\n const pkgFile = findModuleFile(roots.pkgBase, 'vector')\n const hasApp = !!appFile\n const hasPkg = !!pkgFile\n if (hasApp || hasPkg) {\n const importName = `VECTOR_${toVar(modId)}_${importId++}`\n const importPath = hasApp ? `${appImportBase}/vector` : `${imps.pkgBase}/vector`\n imports.push(`import * as ${importName} from '${importPath}'`)\n vectorImportName = importName\n }\n }\n\n // Custom field declarations: src/modules/<module>/data/fields.ts\n {\n const appFile = findModuleFile(roots.appBase, 'data', 'fields')\n const pkgFile = findModuleFile(roots.pkgBase, 'data', 'fields')\n const hasApp = !!appFile\n const hasPkg = !!pkgFile\n if (hasApp || hasPkg) {\n const importName = `F_${toVar(modId)}_${importId++}`\n const importPath = hasApp ? `${appImportBase}/data/fields` : `${imps.pkgBase}/data/fields`\n imports.push(`import * as ${importName} from '${importPath}'`)\n fieldsImportName = importName\n }\n }\n\n // CLI\n const cliApp = findModuleFile(roots.appBase, 'cli')\n const cliPkg = findModuleFile(roots.pkgBase, 'cli')\n const cliPath = cliApp ?? cliPkg\n if (cliPath) {\n const importName = `CLI_${toVar(modId)}`\n const importPath = cliPath.startsWith(roots.appBase) ? `${appImportBase}/cli` : `${imps.pkgBase}/cli`\n imports.push(`import ${importName} from '${importPath}'`)\n cliImportName = importName\n }\n\n // Translations: merge core + app with app overriding\n const i18nApp = path.join(roots.appBase, 'i18n')\n const i18nCore = path.join(roots.pkgBase, 'i18n')\n const locales = new Set<string>()\n if (fs.existsSync(i18nCore))\n for (const e of fs.readdirSync(i18nCore, { withFileTypes: true }))\n if (e.isFile() && e.name.endsWith('.json')) locales.add(e.name.replace(/\\.json$/, ''))\n if (fs.existsSync(i18nApp))\n for (const e of fs.readdirSync(i18nApp, { withFileTypes: true }))\n if (e.isFile() && e.name.endsWith('.json')) locales.add(e.name.replace(/\\.json$/, ''))\n for (const locale of locales) {\n const coreHas = fs.existsSync(path.join(i18nCore, `${locale}.json`))\n const appHas = fs.existsSync(path.join(i18nApp, `${locale}.json`))\n if (coreHas && appHas) {\n const cName = `T_${toVar(modId)}_${toVar(locale)}_C`\n const aName = `T_${toVar(modId)}_${toVar(locale)}_A`\n imports.push(`import ${cName} from '${imps.pkgBase}/i18n/${locale}.json'`)\n imports.push(`import ${aName} from '${appImportBase}/i18n/${locale}.json'`)\n translations.push(\n `'${locale}': { ...( ${cName} as unknown as Record<string,string> ), ...( ${aName} as unknown as Record<string,string> ) }`\n )\n } else if (appHas) {\n const aName = `T_${toVar(modId)}_${toVar(locale)}_A`\n imports.push(`import ${aName} from '${appImportBase}/i18n/${locale}.json'`)\n translations.push(`'${locale}': ${aName} as unknown as Record<string,string>`)\n } else if (coreHas) {\n const cName = `T_${toVar(modId)}_${toVar(locale)}_C`\n imports.push(`import ${cName} from '${imps.pkgBase}/i18n/${locale}.json'`)\n translations.push(`'${locale}': ${cName} as unknown as Record<string,string>`)\n }\n }\n\n // Subscribers: src/modules/<module>/subscribers/*.ts\n const subApp = path.join(roots.appBase, 'subscribers')\n const subPkg = path.join(roots.pkgBase, 'subscribers')\n if (fs.existsSync(subApp) || fs.existsSync(subPkg)) {\n const found: string[] = []\n const walk = (dir: string, rel: string[] = []) => {\n for (const e of fs.readdirSync(dir, { withFileTypes: true })) {\n if (e.isDirectory()) {\n if (e.name === '__tests__' || e.name === '__mocks__') continue\n walk(path.join(dir, e.name), [...rel, e.name])\n } else if (e.isFile() && e.name.endsWith('.ts')) {\n if (/\\.(test|spec)\\.ts$/.test(e.name)) continue\n found.push([...rel, e.name].join('/'))\n }\n }\n }\n if (fs.existsSync(subPkg)) walk(subPkg)\n if (fs.existsSync(subApp)) walk(subApp)\n const files = Array.from(new Set(found))\n for (const rel of files) {\n const segs = rel.split('/')\n const file = segs.pop()!\n const name = file.replace(/\\.ts$/, '')\n const importName = `Subscriber${importId++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n const metaName = `SubscriberMeta${importId++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n const appFile = path.join(subApp, ...segs, `${name}.ts`)\n const fromApp = fs.existsSync(appFile)\n const importPath = `${fromApp ? appImportBase : imps.pkgBase}/subscribers/${[...segs, name].join('/')}`\n imports.push(`import ${importName}, * as ${metaName} from '${importPath}'`)\n const sid = [modId, ...segs, name].filter(Boolean).join(':')\n subscribers.push(\n `{ id: (((${metaName}.metadata) as any)?.id || '${sid}'), event: ((${metaName}.metadata) as any)?.event, persistent: ((${metaName}.metadata) as any)?.persistent, handler: ${importName} }`\n )\n }\n }\n\n // Workers: src/modules/<module>/workers/*.ts\n // Only includes files that export `metadata` with a `queue` property\n {\n const wrkApp = path.join(roots.appBase, 'workers')\n const wrkPkg = path.join(roots.pkgBase, 'workers')\n if (fs.existsSync(wrkApp) || fs.existsSync(wrkPkg)) {\n const found: string[] = []\n const walk = (dir: string, rel: string[] = []) => {\n for (const e of fs.readdirSync(dir, { withFileTypes: true })) {\n if (e.isDirectory()) {\n if (e.name === '__tests__' || e.name === '__mocks__') continue\n walk(path.join(dir, e.name), [...rel, e.name])\n } else if (e.isFile() && e.name.endsWith('.ts')) {\n if (/\\.(test|spec)\\.ts$/.test(e.name)) continue\n found.push([...rel, e.name].join('/'))\n }\n }\n }\n if (fs.existsSync(wrkPkg)) walk(wrkPkg)\n if (fs.existsSync(wrkApp)) walk(wrkApp)\n const files = Array.from(new Set(found))\n for (const rel of files) {\n const segs = rel.split('/')\n const file = segs.pop()!\n const name = file.replace(/\\.ts$/, '')\n const appFile = path.join(wrkApp, ...segs, `${name}.ts`)\n const fromApp = fs.existsSync(appFile)\n // Use package import path for checking exports (file path fails due to relative imports)\n const importPath = `${fromApp ? appImportBase : imps.pkgBase}/workers/${[...segs, name].join('/')}`\n // Only include files that export metadata with a queue property\n if (!(await moduleHasExport(importPath, 'metadata'))) continue\n const importName = `Worker${importId++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n const metaName = `WorkerMeta${importId++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n imports.push(`import ${importName}, * as ${metaName} from '${importPath}'`)\n const wid = [modId, 'workers', ...segs, name].filter(Boolean).join(':')\n workers.push(\n `{ id: (${metaName}.metadata as { id?: string })?.id || '${wid}', queue: (${metaName}.metadata as { queue: string }).queue, concurrency: (${metaName}.metadata as { concurrency?: number })?.concurrency ?? 1, handler: ${importName} as (job: unknown, ctx: unknown) => Promise<void> }`\n )\n }\n }\n }\n\n // Build combined customFieldSets expression from data/fields.ts and ce.ts (entities[].fields)\n {\n const parts: string[] = []\n if (fieldsImportName)\n parts.push(`(( ${fieldsImportName}.default ?? ${fieldsImportName}.fieldSets) as any) || []`)\n if (customEntitiesImportName)\n parts.push(\n `((( ${customEntitiesImportName}.default ?? ${customEntitiesImportName}.entities) as any) || []).filter((e: any) => Array.isArray(e.fields) && e.fields.length).map((e: any) => ({ entity: e.id, fields: e.fields, source: '${modId}' }))`\n )\n customFieldSetsExpr = parts.length ? `[...${parts.join(', ...')}]` : '[]'\n }\n\n moduleDecls.push(`{\n id: '${modId}',\n ${infoImportName ? `info: ${infoImportName}.metadata,` : ''}\n ${cliImportName ? `cli: ${cliImportName},` : ''}\n ${translations.length ? `translations: { ${translations.join(', ')} },` : ''}\n ${subscribers.length ? `subscribers: [${subscribers.join(', ')}],` : ''}\n ${workers.length ? `workers: [${workers.join(', ')}],` : ''}\n ${extensionsImportName ? `entityExtensions: ((${extensionsImportName}.default ?? ${extensionsImportName}.extensions) as any) || [],` : ''}\n customFieldSets: ${customFieldSetsExpr},\n ${featuresImportName ? `features: ((${featuresImportName}.default ?? ${featuresImportName}.features) as any) || [],` : ''}\n ${customEntitiesImportName ? `customEntities: ((${customEntitiesImportName}.default ?? ${customEntitiesImportName}.entities) as any) || [],` : ''}\n ${vectorImportName ? `vector: (${vectorImportName}.default ?? ${vectorImportName}.vectorConfig ?? ${vectorImportName}.config ?? undefined),` : ''}\n }`)\n }\n\n const output = `// AUTO-GENERATED by mercato generate registry (CLI version)\n// This file excludes Next.js dependent code (routes, APIs, widgets)\nimport type { Module } from '@open-mercato/shared/modules/registry'\n${imports.join('\\n')}\n\nexport const modules: Module[] = [\n ${moduleDecls.join(',\\n ')}\n]\nexport const modulesInfo = modules.map(m => ({ id: m.id, ...(m.info || {}) }))\nexport default modules\n`\n\n // Validate module dependencies declared via ModuleInfo.requires\n {\n const enabledIds = new Set(enabled.map((e) => e.id))\n const problems: string[] = []\n for (const [modId, reqs] of requiresByModule.entries()) {\n const missing = reqs.filter((r) => !enabledIds.has(r))\n if (missing.length) {\n problems.push(`- Module \"${modId}\" requires: ${missing.join(', ')}`)\n }\n }\n if (problems.length) {\n console.error('\\nModule dependency check failed:')\n for (const p of problems) console.error(p)\n console.error('\\nFix: Enable required module(s) in src/modules.ts. Example:')\n console.error(\n ' export const enabledModules = [ { id: \\'' +\n Array.from(new Set(requiresByModule.values()).values()).join(\"' }, { id: '\") +\n \"' } ]\"\n )\n process.exit(1)\n }\n }\n\n const structureChecksum = calculateStructureChecksum(Array.from(trackedRoots))\n\n const checksum = { content: calculateChecksum(output), structure: structureChecksum }\n const existingChecksum = readChecksumRecord(checksumFile)\n const shouldWrite =\n !existingChecksum ||\n existingChecksum.content !== checksum.content ||\n existingChecksum.structure !== checksum.structure\n if (shouldWrite) {\n fs.mkdirSync(path.dirname(outFile), { recursive: true })\n fs.writeFileSync(outFile, output)\n writeChecksumRecord(checksumFile, checksum)\n result.filesWritten.push(outFile)\n } else {\n result.filesUnchanged.push(outFile)\n }\n if (!quiet) logGenerationResult(path.relative(process.cwd(), outFile), shouldWrite)\n\n return result\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAEjB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AASP,SAAS,eAAe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AAQ;AAClB,iBAAS,KAAK,aAAa,KAAK,eAAe,QAAQ,KAAK,IAAI,CAAC,EAAE;AAAA,MACrE;AAAA,IACF;AACA,QAAI,SAAS,QAAQ;AACnB,cAAQ,MAAM,mCAAmC;AACjD,iBAAW,KAAK,SAAU,SAAQ,MAAM,CAAC;AACzC,cAAQ,MAAM,8DAA8D;AAC5E,cAAQ;AAAA,QACN,8CACE,MAAM,KAAK,IAAI,IAAI,iBAAiB,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,KAAK,cAAc,IAC3E;AAAA,MACJ;AACA,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AAEA,QAAM,oBAAoB,2BAA2B,MAAM,KAAK,YAAY,CAAC;AAE7E,QAAM,WAAW,EAAE,SAAS,kBAAkB,MAAM,GAAG,WAAW,kBAAkB;AACpF,QAAM,mBAAmB,mBAAmB,YAAY;AACxD,QAAM,cACJ,CAAC,oBACD,iBAAiB,YAAY,SAAS,WACtC,iBAAiB,cAAc,SAAS;AAC1C,MAAI,aAAa;AACf,OAAG,UAAU,KAAK,QAAQ,OAAO,GAAG,EAAE,WAAW,KAAK,CAAC;AACvD,OAAG,cAAc,SAAS,MAAM;AAChC,wBAAoB,cAAc,QAAQ;AAC1C,WAAO,aAAa,KAAK,OAAO;AAAA,EAClC,OAAO;AACL,WAAO,eAAe,KAAK,OAAO;AAAA,EACpC;AACA,MAAI,CAAC,MAAO,qBAAoB,KAAK,SAAS,QAAQ,IAAI,GAAG,OAAO,GAAG,WAAW;AAElF,SAAO;AACT;",
|
|
4
|
+
"sourcesContent": ["import fs from 'node:fs'\nimport path from 'node:path'\nimport type { PackageResolver } from '../resolver'\nimport {\n calculateChecksum,\n calculateStructureChecksum,\n readChecksumRecord,\n writeChecksumRecord,\n toVar,\n moduleHasExport,\n logGenerationResult,\n type GeneratorResult,\n createGeneratorResult,\n} from '../utils'\n\ntype HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'\n\n/**\n * Find a module file, checking for both .ts (src) and .js (dist) extensions.\n * Supports both simple names (e.g., 'cli') and nested paths (e.g., 'data/extensions').\n * Returns the path if found, null otherwise.\n */\nfunction findModuleFile(basePath: string, ...segments: string[]): string | null {\n const name = segments.pop()!\n const dir = segments.length ? path.join(basePath, ...segments) : basePath\n const tsPath = path.join(dir, `${name}.ts`)\n if (fs.existsSync(tsPath)) return tsPath\n const jsPath = path.join(dir, `${name}.js`)\n if (fs.existsSync(jsPath)) return jsPath\n return null\n}\n\nexport interface ModuleRegistryOptions {\n resolver: PackageResolver\n quiet?: boolean\n}\n\nexport async function generateModuleRegistry(options: ModuleRegistryOptions): Promise<GeneratorResult> {\n const { resolver, quiet = false } = options\n const result = createGeneratorResult()\n\n const outputDir = resolver.getOutputDir()\n const outFile = path.join(outputDir, 'modules.generated.ts')\n const checksumFile = path.join(outputDir, 'modules.generated.checksum')\n const widgetsOutFile = path.join(outputDir, 'dashboard-widgets.generated.ts')\n const widgetsChecksumFile = path.join(outputDir, 'dashboard-widgets.generated.checksum')\n const injectionWidgetsOutFile = path.join(outputDir, 'injection-widgets.generated.ts')\n const injectionWidgetsChecksumFile = path.join(outputDir, 'injection-widgets.generated.checksum')\n const injectionTablesOutFile = path.join(outputDir, 'injection-tables.generated.ts')\n const injectionTablesChecksumFile = path.join(outputDir, 'injection-tables.generated.checksum')\n const searchOutFile = path.join(outputDir, 'search.generated.ts')\n const searchChecksumFile = path.join(outputDir, 'search.generated.checksum')\n\n const enabled = resolver.loadEnabledModules()\n const imports: string[] = []\n const moduleDecls: string[] = []\n let importId = 0\n const trackedRoots = new Set<string>()\n const requiresByModule = new Map<string, string[]>()\n const allDashboardWidgets = new Map<string, { moduleId: string; source: 'app' | 'package'; importPath: string }>()\n const allInjectionWidgets = new Map<string, { moduleId: string; source: 'app' | 'package'; importPath: string }>()\n const allInjectionTables: Array<{ moduleId: string; importPath: string; importName: string }> = []\n const searchConfigs: string[] = []\n const searchImports: string[] = []\n\n for (const entry of enabled) {\n const modId = entry.id\n const roots = resolver.getModulePaths(entry)\n const imps = resolver.getModuleImportBase(entry)\n trackedRoots.add(roots.appBase)\n trackedRoots.add(roots.pkgBase)\n\n // For @app modules, use relative paths since @/ alias doesn't work in Node.js runtime\n // From .mercato/generated/, go up two levels (../..) to reach the app root, then into src/modules/\n const isAppModule = entry.from === '@app'\n const appImportBase = isAppModule ? `../../src/modules/${modId}` : imps.appBase\n\n const frontendRoutes: string[] = []\n const backendRoutes: string[] = []\n const apis: string[] = []\n let cliImportName: string | null = null\n const translations: string[] = []\n const subscribers: string[] = []\n const workers: string[] = []\n let infoImportName: string | null = null\n let extensionsImportName: string | null = null\n let fieldsImportName: string | null = null\n let featuresImportName: string | null = null\n let customEntitiesImportName: string | null = null\n let searchImportName: string | null = null\n let customFieldSetsExpr: string = '[]'\n const dashboardWidgets: string[] = []\n const injectionWidgets: string[] = []\n let injectionTableImportName: string | null = null\n\n // Module metadata: index.ts (overrideable)\n const appIndex = findModuleFile(roots.appBase, 'index')\n const pkgIndex = findModuleFile(roots.pkgBase, 'index')\n const indexTs = appIndex ?? pkgIndex\n if (indexTs) {\n infoImportName = `I${importId++}_${toVar(modId)}`\n const importPath = indexTs.startsWith(roots.appBase) ? `${appImportBase}/index` : `${imps.pkgBase}/index`\n imports.push(`import * as ${infoImportName} from '${importPath}'`)\n // Try to eagerly read ModuleInfo.requires for dependency validation\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const mod = require(indexTs)\n const reqs: string[] | undefined =\n mod?.metadata && Array.isArray(mod.metadata.requires) ? mod.metadata.requires : undefined\n if (reqs && reqs.length) requiresByModule.set(modId, reqs)\n } catch {}\n }\n\n // Pages: frontend\n const feApp = path.join(roots.appBase, 'frontend')\n const fePkg = path.join(roots.pkgBase, 'frontend')\n if (fs.existsSync(feApp) || fs.existsSync(fePkg)) {\n const found: string[] = []\n const walk = (dir: string, rel: string[] = []) => {\n for (const e of fs.readdirSync(dir, { withFileTypes: true })) {\n if (e.isDirectory()) {\n if (e.name === '__tests__' || e.name === '__mocks__') continue\n walk(path.join(dir, e.name), [...rel, e.name])\n } else if (e.isFile() && e.name.endsWith('.tsx')) found.push([...rel, e.name].join('/'))\n }\n }\n if (fs.existsSync(fePkg)) walk(fePkg)\n if (fs.existsSync(feApp)) walk(feApp)\n let files = Array.from(new Set(found))\n // Ensure static routes win over dynamic ones (e.g., 'create' before '[id]')\n const isDynamic = (p: string) => /\\/(\\[|\\[\\[\\.\\.\\.)/.test(p) || /^\\[/.test(p)\n files.sort((a, b) => {\n const ad = isDynamic(a) ? 1 : 0\n const bd = isDynamic(b) ? 1 : 0\n if (ad !== bd) return ad - bd // static first\n // Longer, more specific paths later to not shadow peers\n return a.localeCompare(b)\n })\n // Next-style page.tsx\n for (const rel of files.filter((f) => f.endsWith('/page.tsx') || f === 'page.tsx')) {\n const segs = rel.split('/')\n segs.pop()\n const importName = `C${importId++}_${toVar(modId)}_${toVar(segs.join('_') || 'index')}`\n const pageModName = `CM${importId++}_${toVar(modId)}_${toVar(segs.join('_') || 'index')}`\n const appFile = path.join(feApp, ...segs, 'page.tsx')\n const fromApp = fs.existsSync(appFile)\n const sub = segs.length ? `${segs.join('/')}/page` : 'page'\n const importPath = `${fromApp ? appImportBase : imps.pkgBase}/frontend/${sub}`\n const routePath = '/' + (segs.join('/') || '')\n const metaCandidates = [\n path.join(fromApp ? feApp : fePkg, ...segs, 'page.meta.ts'),\n path.join(fromApp ? feApp : fePkg, ...segs, 'meta.ts'),\n ]\n const metaPath = metaCandidates.find((p) => fs.existsSync(p))\n let metaExpr = 'undefined'\n if (metaPath) {\n const metaImportName = `M${importId++}_${toVar(modId)}_${toVar(segs.join('_') || 'index')}`\n const metaImportPath = `${fromApp ? appImportBase : imps.pkgBase}/frontend/${[...segs, path.basename(metaPath).replace(/\\.ts$/, '')].join('/')}`\n imports.push(`import * as ${metaImportName} from '${metaImportPath}'`)\n metaExpr = `(${metaImportName}.metadata as any)`\n imports.push(`import ${importName} from '${importPath}'`)\n } else {\n metaExpr = `(${pageModName} as any).metadata`\n imports.push(`import ${importName}, * as ${pageModName} from '${importPath}'`)\n }\n frontendRoutes.push(\n `{ pattern: '${routePath || '/'}', requireAuth: (${metaExpr})?.requireAuth, requireRoles: (${metaExpr})?.requireRoles, requireFeatures: (${metaExpr})?.requireFeatures, title: (${metaExpr})?.pageTitle ?? (${metaExpr})?.title, titleKey: (${metaExpr})?.pageTitleKey ?? (${metaExpr})?.titleKey, group: (${metaExpr})?.pageGroup ?? (${metaExpr})?.group, groupKey: (${metaExpr})?.pageGroupKey ?? (${metaExpr})?.groupKey, icon: (${metaExpr})?.icon, order: (${metaExpr})?.pageOrder ?? (${metaExpr})?.order, priority: (${metaExpr})?.pagePriority ?? (${metaExpr})?.priority, navHidden: (${metaExpr})?.navHidden, visible: (${metaExpr})?.visible, enabled: (${metaExpr})?.enabled, breadcrumb: (${metaExpr})?.breadcrumb, Component: ${importName} }`\n )\n }\n // Back-compat direct files\n for (const rel of files.filter((f) => !f.endsWith('/page.tsx') && f !== 'page.tsx')) {\n const segs = rel.split('/')\n const file = segs.pop()!\n const name = file.replace(/\\.tsx$/, '')\n const routeSegs = [...segs, name].filter(Boolean)\n const importName = `C${importId++}_${toVar(modId)}_${toVar(routeSegs.join('_') || 'index')}`\n const pageModName = `CM${importId++}_${toVar(modId)}_${toVar(routeSegs.join('_') || 'index')}`\n const appFile = path.join(feApp, ...segs, `${name}.tsx`)\n const fromApp = fs.existsSync(appFile)\n const importPath = `${fromApp ? appImportBase : imps.pkgBase}/frontend/${[...segs, name].join('/')}`\n const routePath = '/' + (routeSegs.join('/') || '')\n const metaCandidates = [\n path.join(fromApp ? feApp : fePkg, ...segs, name + '.meta.ts'),\n path.join(fromApp ? feApp : fePkg, ...segs, 'meta.ts'),\n ]\n const metaPath = metaCandidates.find((p) => fs.existsSync(p))\n let metaExpr = 'undefined'\n if (metaPath) {\n const metaImportName = `M${importId++}_${toVar(modId)}_${toVar(routeSegs.join('_') || 'index')}`\n const metaBase = path.basename(metaPath)\n const metaImportSub = metaBase === 'meta.ts' ? 'meta' : name + '.meta'\n const metaImportPath = `${fromApp ? appImportBase : imps.pkgBase}/frontend/${[...segs, metaImportSub].join('/')}`\n imports.push(`import * as ${metaImportName} from '${metaImportPath}'`)\n metaExpr = `(${metaImportName}.metadata as any)`\n imports.push(`import ${importName} from '${importPath}'`)\n } else {\n metaExpr = `(${pageModName} as any).metadata`\n imports.push(`import ${importName}, * as ${pageModName} from '${importPath}'`)\n }\n frontendRoutes.push(\n `{ pattern: '${routePath || '/'}', requireAuth: (${metaExpr})?.requireAuth, requireRoles: (${metaExpr})?.requireRoles, requireFeatures: (${metaExpr})?.requireFeatures, title: (${metaExpr})?.pageTitle ?? (${metaExpr})?.title, titleKey: (${metaExpr})?.pageTitleKey ?? (${metaExpr})?.titleKey, group: (${metaExpr})?.pageGroup ?? (${metaExpr})?.group, groupKey: (${metaExpr})?.pageGroupKey ?? (${metaExpr})?.groupKey, visible: (${metaExpr})?.visible, enabled: (${metaExpr})?.enabled, Component: ${importName} }`\n )\n }\n }\n\n // Entity extensions: src/modules/<module>/data/extensions.ts\n {\n const appFile = findModuleFile(roots.appBase, 'data', 'extensions')\n const pkgFile = findModuleFile(roots.pkgBase, 'data', 'extensions')\n const hasApp = !!appFile\n const hasPkg = !!pkgFile\n if (hasApp || hasPkg) {\n const importName = `X_${toVar(modId)}_${importId++}`\n const importPath = hasApp ? `${appImportBase}/data/extensions` : `${imps.pkgBase}/data/extensions`\n imports.push(`import * as ${importName} from '${importPath}'`)\n extensionsImportName = importName\n }\n }\n\n // RBAC feature declarations: module root acl.ts\n {\n const rootApp = findModuleFile(roots.appBase, 'acl')\n const rootPkg = findModuleFile(roots.pkgBase, 'acl')\n const hasRoot = rootApp || rootPkg\n if (hasRoot) {\n const importName = `ACL_${toVar(modId)}_${importId++}`\n const useApp = rootApp ?? rootPkg!\n const importPath = useApp.startsWith(roots.appBase) ? `${appImportBase}/acl` : `${imps.pkgBase}/acl`\n imports.push(`import * as ${importName} from '${importPath}'`)\n featuresImportName = importName\n }\n }\n\n // Custom entities declarations: module root ce.ts\n {\n const appFile = findModuleFile(roots.appBase, 'ce')\n const pkgFile = findModuleFile(roots.pkgBase, 'ce')\n const hasApp = !!appFile\n const hasPkg = !!pkgFile\n if (hasApp || hasPkg) {\n const importName = `CE_${toVar(modId)}_${importId++}`\n const importPath = hasApp ? `${appImportBase}/ce` : `${imps.pkgBase}/ce`\n imports.push(`import * as ${importName} from '${importPath}'`)\n customEntitiesImportName = importName\n }\n }\n\n // Search module configuration: module root search.ts\n {\n const appFile = findModuleFile(roots.appBase, 'search')\n const pkgFile = findModuleFile(roots.pkgBase, 'search')\n const hasApp = !!appFile\n const hasPkg = !!pkgFile\n if (hasApp || hasPkg) {\n const importName = `SEARCH_${toVar(modId)}_${importId++}`\n const importPath = hasApp ? `${appImportBase}/search` : `${imps.pkgBase}/search`\n const importStmt = `import * as ${importName} from '${importPath}'`\n imports.push(importStmt)\n searchImports.push(importStmt)\n searchImportName = importName\n }\n }\n\n // Custom field declarations: src/modules/<module>/data/fields.ts\n {\n const appFile = findModuleFile(roots.appBase, 'data', 'fields')\n const pkgFile = findModuleFile(roots.pkgBase, 'data', 'fields')\n const hasApp = !!appFile\n const hasPkg = !!pkgFile\n if (hasApp || hasPkg) {\n const importName = `F_${toVar(modId)}_${importId++}`\n const importPath = hasApp ? `${appImportBase}/data/fields` : `${imps.pkgBase}/data/fields`\n imports.push(`import * as ${importName} from '${importPath}'`)\n fieldsImportName = importName\n }\n }\n\n // Pages: backend\n const beApp = path.join(roots.appBase, 'backend')\n const bePkg = path.join(roots.pkgBase, 'backend')\n if (fs.existsSync(beApp) || fs.existsSync(bePkg)) {\n const found: string[] = []\n const walk = (dir: string, rel: string[] = []) => {\n for (const e of fs.readdirSync(dir, { withFileTypes: true })) {\n if (e.isDirectory()) {\n if (e.name === '__tests__' || e.name === '__mocks__') continue\n walk(path.join(dir, e.name), [...rel, e.name])\n } else if (e.isFile() && e.name.endsWith('.tsx')) found.push([...rel, e.name].join('/'))\n }\n }\n if (fs.existsSync(bePkg)) walk(bePkg)\n if (fs.existsSync(beApp)) walk(beApp)\n let files = Array.from(new Set(found))\n const isDynamic = (p: string) => /\\/(\\[|\\[\\[\\.\\.\\.)/.test(p) || /^\\[/.test(p)\n files.sort((a, b) => {\n const ad = isDynamic(a) ? 1 : 0\n const bd = isDynamic(b) ? 1 : 0\n if (ad !== bd) return ad - bd\n return a.localeCompare(b)\n })\n // Next-style\n for (const rel of files.filter((f) => f.endsWith('/page.tsx') || f === 'page.tsx')) {\n const segs = rel.split('/')\n segs.pop()\n const importName = `B${importId++}_${toVar(modId)}_${toVar(segs.join('_') || 'index')}`\n const pageModName = `BM${importId++}_${toVar(modId)}_${toVar(segs.join('_') || 'index')}`\n const appFile = path.join(beApp, ...segs, 'page.tsx')\n const fromApp = fs.existsSync(appFile)\n const sub = segs.length ? `${segs.join('/')}/page` : 'page'\n const importPath = `${fromApp ? appImportBase : imps.pkgBase}/backend/${sub}`\n const basePath = segs.join('/') || modId\n const routePath = '/backend/' + basePath\n const metaCandidates = [\n path.join(fromApp ? beApp : bePkg, ...segs, 'page.meta.ts'),\n path.join(fromApp ? beApp : bePkg, ...segs, 'meta.ts'),\n ]\n const metaPath = metaCandidates.find((p) => fs.existsSync(p))\n let metaExpr = 'undefined'\n if (metaPath) {\n const metaImportName = `BM${importId++}_${toVar(modId)}_${toVar(segs.join('_') || 'index')}`\n const metaImportPath = `${fromApp ? appImportBase : imps.pkgBase}/backend/${[...segs, path.basename(metaPath).replace(/\\.ts$/, '')].join('/')}`\n imports.push(`import * as ${metaImportName} from '${metaImportPath}'`)\n metaExpr = `(${metaImportName}.metadata as any)`\n imports.push(`import ${importName} from '${importPath}'`)\n } else {\n metaExpr = `(${pageModName} as any).metadata`\n imports.push(`import ${importName}, * as ${pageModName} from '${importPath}'`)\n }\n backendRoutes.push(\n `{ pattern: '${routePath}', requireAuth: (${metaExpr})?.requireAuth, requireRoles: (${metaExpr})?.requireRoles, requireFeatures: (${metaExpr})?.requireFeatures, title: (${metaExpr})?.pageTitle ?? (${metaExpr})?.title, titleKey: (${metaExpr})?.pageTitleKey ?? (${metaExpr})?.titleKey, group: (${metaExpr})?.pageGroup ?? (${metaExpr})?.group, groupKey: (${metaExpr})?.pageGroupKey ?? (${metaExpr})?.groupKey, icon: (${metaExpr})?.icon, order: (${metaExpr})?.pageOrder ?? (${metaExpr})?.order, priority: (${metaExpr})?.pagePriority ?? (${metaExpr})?.priority, navHidden: (${metaExpr})?.navHidden, visible: (${metaExpr})?.visible, enabled: (${metaExpr})?.enabled, breadcrumb: (${metaExpr})?.breadcrumb, Component: ${importName} }`\n )\n }\n // Direct files\n for (const rel of files.filter((f) => !f.endsWith('/page.tsx') && f !== 'page.tsx')) {\n const segs = rel.split('/')\n const file = segs.pop()!\n const name = file.replace(/\\.tsx$/, '')\n const importName = `B${importId++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n const pageModName = `BM${importId++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n const appFile = path.join(beApp, ...segs, `${name}.tsx`)\n const fromApp = fs.existsSync(appFile)\n const importPath = `${fromApp ? appImportBase : imps.pkgBase}/backend/${[...segs, name].join('/')}`\n const routePath = '/backend/' + [modId, ...segs, name].filter(Boolean).join('/')\n const metaCandidates = [\n path.join(fromApp ? beApp : bePkg, ...segs, name + '.meta.ts'),\n path.join(fromApp ? beApp : bePkg, ...segs, 'meta.ts'),\n ]\n const metaPath = metaCandidates.find((p) => fs.existsSync(p))\n let metaExpr = 'undefined'\n if (metaPath) {\n const metaImportName = `BM${importId++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n const metaBase = path.basename(metaPath)\n const metaImportSub = metaBase === 'meta.ts' ? 'meta' : name + '.meta'\n const metaImportPath = `${fromApp ? appImportBase : imps.pkgBase}/backend/${[...segs, metaImportSub].join('/')}`\n imports.push(`import * as ${metaImportName} from '${metaImportPath}'`)\n metaExpr = `${metaImportName}.metadata`\n imports.push(`import ${importName} from '${importPath}'`)\n } else {\n metaExpr = `(${pageModName} as any).metadata`\n imports.push(`import ${importName}, * as ${pageModName} from '${importPath}'`)\n }\n backendRoutes.push(\n `{ pattern: '${routePath}', requireAuth: (${metaExpr})?.requireAuth, requireRoles: (${metaExpr})?.requireRoles, requireFeatures: (${metaExpr})?.requireFeatures, title: (${metaExpr})?.pageTitle ?? (${metaExpr})?.title, titleKey: (${metaExpr})?.pageTitleKey ?? (${metaExpr})?.titleKey, group: (${metaExpr})?.pageGroup ?? (${metaExpr})?.group, groupKey: (${metaExpr})?.pageGroupKey ?? (${metaExpr})?.groupKey, icon: (${metaExpr})?.icon, order: (${metaExpr})?.pageOrder ?? (${metaExpr})?.order, priority: (${metaExpr})?.pagePriority ?? (${metaExpr})?.priority, navHidden: (${metaExpr})?.navHidden, visible: (${metaExpr})?.visible, enabled: (${metaExpr})?.enabled, breadcrumb: (${metaExpr})?.breadcrumb, Component: ${importName} }`\n )\n }\n }\n\n // APIs\n const apiApp = path.join(roots.appBase, 'api')\n const apiPkg = path.join(roots.pkgBase, 'api')\n if (fs.existsSync(apiApp) || fs.existsSync(apiPkg)) {\n // route.ts or route.js aggregations\n const routeFiles: string[] = []\n const walk = (dir: string, rel: string[] = []) => {\n for (const e of fs.readdirSync(dir, { withFileTypes: true })) {\n if (e.isDirectory()) {\n if (e.name === '__tests__' || e.name === '__mocks__') continue\n walk(path.join(dir, e.name), [...rel, e.name])\n } else if (e.isFile() && (e.name === 'route.ts' || e.name === 'route.js')) {\n routeFiles.push([...rel, e.name].join('/'))\n }\n }\n }\n if (fs.existsSync(apiPkg)) walk(apiPkg)\n if (fs.existsSync(apiApp)) walk(apiApp)\n const routeList = Array.from(new Set(routeFiles.map(f => f.replace(/\\.(ts|js)$/, ''))))\n const isDynamicRoute = (p: string) => p.split('/').some((seg) => /\\[|\\[\\[\\.\\.\\./.test(seg))\n routeList.sort((a, b) => {\n const ad = isDynamicRoute(a) ? 1 : 0\n const bd = isDynamicRoute(b) ? 1 : 0\n if (ad !== bd) return ad - bd\n return a.localeCompare(b)\n })\n for (const rel of routeList) {\n const segs = rel.split('/')\n segs.pop() // remove 'route'\n const reqSegs = [modId, ...segs]\n const importName = `R${importId++}_${toVar(modId)}_${toVar(segs.join('_') || 'index')}`\n const appFileTs = path.join(apiApp, ...segs, 'route.ts')\n const appFileJs = path.join(apiApp, ...segs, 'route.js')\n const fromApp = fs.existsSync(appFileTs) || fs.existsSync(appFileJs)\n const apiSegPath = segs.join('/')\n const importPath = `${fromApp ? appImportBase : imps.pkgBase}/api${apiSegPath ? `/${apiSegPath}` : ''}/route`\n const routePath = '/' + reqSegs.filter(Boolean).join('/')\n const pkgFileTs = path.join(apiPkg, ...segs, 'route.ts')\n const pkgFileJs = path.join(apiPkg, ...segs, 'route.js')\n const sourceFile = fromApp\n ? (fs.existsSync(appFileTs) ? appFileTs : appFileJs)\n : (fs.existsSync(pkgFileTs) ? pkgFileTs : pkgFileJs)\n const hasOpenApi = await moduleHasExport(sourceFile, 'openApi')\n const docsPart = hasOpenApi ? `, docs: ${importName}.openApi` : ''\n imports.push(`import * as ${importName} from '${importPath}'`)\n apis.push(`{ path: '${routePath}', metadata: (${importName} as any).metadata, handlers: ${importName} as any${docsPart} }`)\n }\n\n // Single files (non-route API files)\n const plainFiles: string[] = []\n const methodNames = new Set(['get', 'post', 'put', 'patch', 'delete'])\n const walkPlain = (dir: string, rel: string[] = []) => {\n for (const e of fs.readdirSync(dir, { withFileTypes: true })) {\n if (e.isDirectory()) {\n if (methodNames.has(e.name.toLowerCase())) continue\n if (e.name === '__tests__' || e.name === '__mocks__') continue\n walkPlain(path.join(dir, e.name), [...rel, e.name])\n } else if (e.isFile() && (e.name.endsWith('.ts') || e.name.endsWith('.js')) && !e.name.startsWith('route.')) {\n if (/\\.(test|spec)\\.(ts|js)$/.test(e.name)) continue\n if (e.name.endsWith('.d.ts')) continue\n plainFiles.push([...rel, e.name].join('/'))\n }\n }\n }\n if (fs.existsSync(apiPkg)) walkPlain(apiPkg)\n if (fs.existsSync(apiApp)) walkPlain(apiApp)\n const plainList = Array.from(new Set(plainFiles.map(f => f.replace(/\\.(ts|js)$/, ''))))\n for (const rel of plainList) {\n const segs = rel.split('/')\n const pathWithoutExt = segs.pop()!\n const fullSegs = [...segs, pathWithoutExt]\n const routePath = '/' + [modId, ...fullSegs].filter(Boolean).join('/')\n const importName = `R${importId++}_${toVar(modId)}_${toVar(fullSegs.join('_') || 'index')}`\n const appFileTs = path.join(apiApp, ...fullSegs) + '.ts'\n const appFileJs = path.join(apiApp, ...fullSegs) + '.js'\n const fromApp = fs.existsSync(appFileTs) || fs.existsSync(appFileJs)\n const plainSegPath = fullSegs.join('/')\n const importPath = `${fromApp ? appImportBase : imps.pkgBase}/api${plainSegPath ? `/${plainSegPath}` : ''}`\n const pkgFileTs = path.join(apiPkg, ...fullSegs) + '.ts'\n const pkgFileJs = path.join(apiPkg, ...fullSegs) + '.js'\n const sourceFile = fromApp\n ? (fs.existsSync(appFileTs) ? appFileTs : appFileJs)\n : (fs.existsSync(pkgFileTs) ? pkgFileTs : pkgFileJs)\n const hasOpenApi = await moduleHasExport(sourceFile, 'openApi')\n const docsPart = hasOpenApi ? `, docs: ${importName}.openApi` : ''\n imports.push(`import * as ${importName} from '${importPath}'`)\n apis.push(`{ path: '${routePath}', metadata: (${importName} as any).metadata, handlers: ${importName} as any${docsPart} }`)\n }\n // Legacy per-method\n const methods: HttpMethod[] = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE']\n for (const method of methods) {\n const coreMethodDir = path.join(apiPkg, method.toLowerCase())\n const appMethodDir = path.join(apiApp, method.toLowerCase())\n const methodDir = fs.existsSync(appMethodDir) ? appMethodDir : coreMethodDir\n if (!fs.existsSync(methodDir)) continue\n const apiFiles: string[] = []\n const walk2 = (dir: string, rel: string[] = []) => {\n for (const e of fs.readdirSync(dir, { withFileTypes: true })) {\n if (e.isDirectory()) {\n if (e.name === '__tests__' || e.name === '__mocks__') continue\n walk2(path.join(dir, e.name), [...rel, e.name])\n } else if (e.isFile() && (e.name.endsWith('.ts') || e.name.endsWith('.js'))) {\n if (/\\.(test|spec)\\.(ts|js)$/.test(e.name)) continue\n if (e.name.endsWith('.d.ts')) continue\n apiFiles.push([...rel, e.name].join('/'))\n }\n }\n }\n walk2(methodDir)\n const methodList = Array.from(new Set(apiFiles.map(f => f.replace(/\\.(ts|js)$/, ''))))\n for (const rel of methodList) {\n const segs = rel.split('/')\n const pathWithoutExt = segs.pop()!\n const fullSegs = [...segs, pathWithoutExt]\n const routePath = '/' + [modId, ...fullSegs].filter(Boolean).join('/')\n const importName = `H${importId++}_${toVar(modId)}_${toVar(method)}_${toVar(fullSegs.join('_'))}`\n const fromApp = methodDir === appMethodDir\n const importPath = `${fromApp ? appImportBase : imps.pkgBase}/api/${method.toLowerCase()}/${fullSegs.join('/')}`\n const metaName = `RM${importId++}_${toVar(modId)}_${toVar(method)}_${toVar(fullSegs.join('_'))}`\n const sourceFileTs = path.join(methodDir, ...segs, `${pathWithoutExt}.ts`)\n const sourceFileJs = path.join(methodDir, ...segs, `${pathWithoutExt}.js`)\n const sourceFile = fs.existsSync(sourceFileTs) ? sourceFileTs : sourceFileJs\n const hasOpenApi = await moduleHasExport(sourceFile, 'openApi')\n const docsPart = hasOpenApi ? `, docs: ${metaName}.openApi` : ''\n imports.push(`import ${importName}, * as ${metaName} from '${importPath}'`)\n apis.push(`{ method: '${method}', path: '${routePath}', handler: ${importName}, metadata: ${metaName}.metadata${docsPart} }`)\n }\n }\n }\n\n // CLI\n const cliApp = findModuleFile(roots.appBase, 'cli')\n const cliPkg = findModuleFile(roots.pkgBase, 'cli')\n const cliPath = cliApp ?? cliPkg\n if (cliPath) {\n const importName = `CLI_${toVar(modId)}`\n const importPath = cliPath.startsWith(roots.appBase) ? `${appImportBase}/cli` : `${imps.pkgBase}/cli`\n imports.push(`import ${importName} from '${importPath}'`)\n cliImportName = importName\n }\n\n // Translations: merge core + app with app overriding\n const i18nApp = path.join(roots.appBase, 'i18n')\n const i18nCore = path.join(roots.pkgBase, 'i18n')\n const locales = new Set<string>()\n if (fs.existsSync(i18nCore))\n for (const e of fs.readdirSync(i18nCore, { withFileTypes: true }))\n if (e.isFile() && e.name.endsWith('.json')) locales.add(e.name.replace(/\\.json$/, ''))\n if (fs.existsSync(i18nApp))\n for (const e of fs.readdirSync(i18nApp, { withFileTypes: true }))\n if (e.isFile() && e.name.endsWith('.json')) locales.add(e.name.replace(/\\.json$/, ''))\n for (const locale of locales) {\n const coreHas = fs.existsSync(path.join(i18nCore, `${locale}.json`))\n const appHas = fs.existsSync(path.join(i18nApp, `${locale}.json`))\n if (coreHas && appHas) {\n const cName = `T_${toVar(modId)}_${toVar(locale)}_C`\n const aName = `T_${toVar(modId)}_${toVar(locale)}_A`\n imports.push(`import ${cName} from '${imps.pkgBase}/i18n/${locale}.json'`)\n imports.push(`import ${aName} from '${appImportBase}/i18n/${locale}.json'`)\n translations.push(\n `'${locale}': { ...( ${cName} as unknown as Record<string,string> ), ...( ${aName} as unknown as Record<string,string> ) }`\n )\n } else if (appHas) {\n const aName = `T_${toVar(modId)}_${toVar(locale)}_A`\n imports.push(`import ${aName} from '${appImportBase}/i18n/${locale}.json'`)\n translations.push(`'${locale}': ${aName} as unknown as Record<string,string>`)\n } else if (coreHas) {\n const cName = `T_${toVar(modId)}_${toVar(locale)}_C`\n imports.push(`import ${cName} from '${imps.pkgBase}/i18n/${locale}.json'`)\n translations.push(`'${locale}': ${cName} as unknown as Record<string,string>`)\n }\n }\n\n // Subscribers: src/modules/<module>/subscribers/*.ts or *.js\n const subApp = path.join(roots.appBase, 'subscribers')\n const subPkg = path.join(roots.pkgBase, 'subscribers')\n if (fs.existsSync(subApp) || fs.existsSync(subPkg)) {\n const found: string[] = []\n const walk = (dir: string, rel: string[] = []) => {\n for (const e of fs.readdirSync(dir, { withFileTypes: true })) {\n if (e.isDirectory()) {\n if (e.name === '__tests__' || e.name === '__mocks__') continue\n walk(path.join(dir, e.name), [...rel, e.name])\n } else if (e.isFile() && (e.name.endsWith('.ts') || e.name.endsWith('.js'))) {\n if (/\\.(test|spec)\\.(ts|js)$/.test(e.name)) continue\n if (e.name.endsWith('.d.ts')) continue\n found.push([...rel, e.name].join('/'))\n }\n }\n }\n if (fs.existsSync(subPkg)) walk(subPkg)\n if (fs.existsSync(subApp)) walk(subApp)\n const files = Array.from(new Set(found))\n for (const rel of files) {\n const segs = rel.split('/')\n const file = segs.pop()!\n const name = file.replace(/\\.(ts|js)$/, '')\n const importName = `Subscriber${importId++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n const metaName = `SubscriberMeta${importId++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n const appFileTs = path.join(subApp, ...segs, `${name}.ts`)\n const appFileJs = path.join(subApp, ...segs, `${name}.js`)\n const fromApp = fs.existsSync(appFileTs) || fs.existsSync(appFileJs)\n const importPath = `${fromApp ? appImportBase : imps.pkgBase}/subscribers/${[...segs, name].join('/')}`\n imports.push(`import ${importName}, * as ${metaName} from '${importPath}'`)\n const sid = [modId, ...segs, name].filter(Boolean).join(':')\n subscribers.push(\n `{ id: (((${metaName}.metadata) as any)?.id || '${sid}'), event: ((${metaName}.metadata) as any)?.event, persistent: ((${metaName}.metadata) as any)?.persistent, handler: ${importName} }`\n )\n }\n }\n\n // Workers: src/modules/<module>/workers/*.ts or *.js\n // Only includes files that export `metadata` with a `queue` property\n {\n const wrkApp = path.join(roots.appBase, 'workers')\n const wrkPkg = path.join(roots.pkgBase, 'workers')\n if (fs.existsSync(wrkApp) || fs.existsSync(wrkPkg)) {\n const found: string[] = []\n const walk = (dir: string, rel: string[] = []) => {\n for (const e of fs.readdirSync(dir, { withFileTypes: true })) {\n if (e.isDirectory()) {\n if (e.name === '__tests__' || e.name === '__mocks__') continue\n walk(path.join(dir, e.name), [...rel, e.name])\n } else if (e.isFile() && (e.name.endsWith('.ts') || e.name.endsWith('.js'))) {\n if (/\\.(test|spec)\\.(ts|js)$/.test(e.name)) continue\n if (e.name.endsWith('.d.ts')) continue\n found.push([...rel, e.name].join('/'))\n }\n }\n }\n if (fs.existsSync(wrkPkg)) walk(wrkPkg)\n if (fs.existsSync(wrkApp)) walk(wrkApp)\n const files = Array.from(new Set(found))\n for (const rel of files) {\n const segs = rel.split('/')\n const file = segs.pop()!\n const name = file.replace(/\\.(ts|js)$/, '')\n const appFileTs = path.join(wrkApp, ...segs, `${name}.ts`)\n const appFileJs = path.join(wrkApp, ...segs, `${name}.js`)\n const fromApp = fs.existsSync(appFileTs) || fs.existsSync(appFileJs)\n // Use package import path for checking exports (file path fails due to relative imports)\n const importPath = `${fromApp ? appImportBase : imps.pkgBase}/workers/${[...segs, name].join('/')}`\n // Only include files that export metadata with a queue property\n if (!(await moduleHasExport(importPath, 'metadata'))) continue\n const importName = `Worker${importId++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n const metaName = `WorkerMeta${importId++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n imports.push(`import ${importName}, * as ${metaName} from '${importPath}'`)\n const wid = [modId, 'workers', ...segs, name].filter(Boolean).join(':')\n workers.push(\n `{ id: (${metaName}.metadata as { id?: string })?.id || '${wid}', queue: (${metaName}.metadata as { queue: string }).queue, concurrency: (${metaName}.metadata as { concurrency?: number })?.concurrency ?? 1, handler: ${importName} as (job: unknown, ctx: unknown) => Promise<void> }`\n )\n }\n }\n }\n\n // Build combined customFieldSets expression from data/fields.ts and ce.ts (entities[].fields)\n {\n const parts: string[] = []\n if (fieldsImportName)\n parts.push(`(( ${fieldsImportName}.default ?? ${fieldsImportName}.fieldSets) as any) || []`)\n if (customEntitiesImportName)\n parts.push(\n `((( ${customEntitiesImportName}.default ?? ${customEntitiesImportName}.entities) as any) || []).filter((e: any) => Array.isArray(e.fields) && e.fields.length).map((e: any) => ({ entity: e.id, fields: e.fields, source: '${modId}' }))`\n )\n customFieldSetsExpr = parts.length ? `[...${parts.join(', ...')}]` : '[]'\n }\n\n // Dashboard widgets: src/modules/<module>/widgets/dashboard/**/widget.ts(x)\n {\n const widgetApp = path.join(roots.appBase, 'widgets', 'dashboard')\n const widgetPkg = path.join(roots.pkgBase, 'widgets', 'dashboard')\n if (fs.existsSync(widgetApp) || fs.existsSync(widgetPkg)) {\n const found: string[] = []\n const walk = (dir: string, rel: string[] = []) => {\n for (const e of fs.readdirSync(dir, { withFileTypes: true })) {\n if (e.isDirectory()) {\n if (e.name === '__tests__' || e.name === '__mocks__') continue\n walk(path.join(dir, e.name), [...rel, e.name])\n } else if (e.isFile() && /^widget\\.(t|j)sx?$/.test(e.name)) {\n found.push([...rel, e.name].join('/'))\n }\n }\n }\n if (fs.existsSync(widgetPkg)) walk(widgetPkg)\n if (fs.existsSync(widgetApp)) walk(widgetApp)\n const files = Array.from(new Set(found)).sort()\n for (const rel of files) {\n const appFile = path.join(widgetApp, ...rel.split('/'))\n const fromApp = fs.existsSync(appFile)\n const segs = rel.split('/')\n const file = segs.pop()!\n const base = file.replace(/\\.(t|j)sx?$/, '')\n const importPath = `${fromApp ? appImportBase : imps.pkgBase}/widgets/dashboard/${[...segs, base].join('/')}`\n const key = [modId, ...segs, base].filter(Boolean).join(':')\n const source = fromApp ? 'app' : 'package'\n dashboardWidgets.push(\n `{ moduleId: '${modId}', key: '${key}', source: '${source}', loader: () => import('${importPath}').then((mod) => mod.default ?? mod) }`\n )\n const existing = allDashboardWidgets.get(key)\n if (!existing || (existing.source !== 'app' && source === 'app')) {\n allDashboardWidgets.set(key, { moduleId: modId, source, importPath })\n }\n }\n }\n }\n\n // Injection widgets: src/modules/<module>/widgets/injection/**/widget.ts(x)\n {\n const widgetApp = path.join(roots.appBase, 'widgets', 'injection')\n const widgetPkg = path.join(roots.pkgBase, 'widgets', 'injection')\n if (fs.existsSync(widgetApp) || fs.existsSync(widgetPkg)) {\n const found: string[] = []\n const walk = (dir: string, rel: string[] = []) => {\n for (const e of fs.readdirSync(dir, { withFileTypes: true })) {\n if (e.isDirectory()) {\n if (e.name === '__tests__' || e.name === '__mocks__') continue\n walk(path.join(dir, e.name), [...rel, e.name])\n } else if (e.isFile() && /^widget\\.(t|j)sx?$/.test(e.name)) {\n found.push([...rel, e.name].join('/'))\n }\n }\n }\n if (fs.existsSync(widgetPkg)) walk(widgetPkg)\n if (fs.existsSync(widgetApp)) walk(widgetApp)\n const files = Array.from(new Set(found)).sort()\n for (const rel of files) {\n const appFile = path.join(widgetApp, ...rel.split('/'))\n const fromApp = fs.existsSync(appFile)\n const segs = rel.split('/')\n const file = segs.pop()!\n const base = file.replace(/\\.(t|j)sx?$/, '')\n const importPath = `${fromApp ? appImportBase : imps.pkgBase}/widgets/injection/${[...segs, base].join('/')}`\n const key = [modId, ...segs, base].filter(Boolean).join(':')\n const source = fromApp ? 'app' : 'package'\n injectionWidgets.push(\n `{ moduleId: '${modId}', key: '${key}', source: '${source}', loader: () => import('${importPath}').then((mod) => mod.default ?? mod) }`\n )\n const existing = allInjectionWidgets.get(key)\n if (!existing || (existing.source !== 'app' && source === 'app')) {\n allInjectionWidgets.set(key, { moduleId: modId, source, importPath })\n }\n }\n }\n }\n\n // Injection table: src/modules/<module>/widgets/injection-table.ts\n {\n const appFile = path.join(roots.appBase, 'widgets', 'injection-table.ts')\n const pkgFile = path.join(roots.pkgBase, 'widgets', 'injection-table.ts')\n const hasApp = fs.existsSync(appFile)\n const hasPkg = fs.existsSync(pkgFile)\n if (hasApp || hasPkg) {\n const importName = `InjTable_${toVar(modId)}_${importId++}`\n const importPath = hasApp ? `${appImportBase}/widgets/injection-table` : `${imps.pkgBase}/widgets/injection-table`\n imports.push(`import * as ${importName} from '${importPath}'`)\n injectionTableImportName = importName\n allInjectionTables.push({ moduleId: modId, importPath, importName })\n }\n }\n\n if (searchImportName) {\n searchConfigs.push(`{ moduleId: '${modId}', config: (${searchImportName}.default ?? ${searchImportName}.searchConfig ?? ${searchImportName}.config ?? null) }`)\n }\n\n moduleDecls.push(`{\n id: '${modId}',\n ${infoImportName ? `info: ${infoImportName}.metadata,` : ''}\n ${frontendRoutes.length ? `frontendRoutes: [${frontendRoutes.join(', ')}],` : ''}\n ${backendRoutes.length ? `backendRoutes: [${backendRoutes.join(', ')}],` : ''}\n ${apis.length ? `apis: [${apis.join(', ')}],` : ''}\n ${cliImportName ? `cli: ${cliImportName},` : ''}\n ${translations.length ? `translations: { ${translations.join(', ')} },` : ''}\n ${subscribers.length ? `subscribers: [${subscribers.join(', ')}],` : ''}\n ${workers.length ? `workers: [${workers.join(', ')}],` : ''}\n ${extensionsImportName ? `entityExtensions: ((${extensionsImportName}.default ?? ${extensionsImportName}.extensions) as import('@open-mercato/shared/modules/entities').EntityExtension[]) || [],` : ''}\n customFieldSets: ${customFieldSetsExpr},\n ${featuresImportName ? `features: ((${featuresImportName}.default ?? ${featuresImportName}.features) as any) || [],` : ''}\n ${customEntitiesImportName ? `customEntities: ((${customEntitiesImportName}.default ?? ${customEntitiesImportName}.entities) as any) || [],` : ''}\n ${dashboardWidgets.length ? `dashboardWidgets: [${dashboardWidgets.join(', ')}],` : ''}\n }`)\n }\n\n const output = `// AUTO-GENERATED by mercato generate registry\nimport type { Module } from '@open-mercato/shared/modules/registry'\n${imports.join('\\n')}\n\nexport const modules: Module[] = [\n ${moduleDecls.join(',\\n ')}\n]\nexport const modulesInfo = modules.map(m => ({ id: m.id, ...(m.info || {}) }))\nexport default modules\n`\n const widgetEntriesList = Array.from(allDashboardWidgets.entries()).sort(([a], [b]) => a.localeCompare(b))\n const widgetDecls = widgetEntriesList.map(\n ([key, data]) =>\n ` { moduleId: '${data.moduleId}', key: '${key}', source: '${data.source}', loader: () => import('${data.importPath}').then((mod) => mod.default ?? mod) }`\n )\n const widgetsOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { ModuleDashboardWidgetEntry } from '@open-mercato/shared/modules/registry'\n\nexport const dashboardWidgetEntries: ModuleDashboardWidgetEntry[] = [\n${widgetDecls.join(',\\n')}\n]\n`\n const searchEntriesLiteral = searchConfigs.join(',\\n ')\n const searchImportSection = searchImports.join('\\n')\n const searchOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { SearchModuleConfig } from '@open-mercato/shared/modules/search'\n${searchImportSection ? `\\n${searchImportSection}\\n` : '\\n'}type SearchConfigEntry = { moduleId: string; config: SearchModuleConfig | null }\n\nconst entriesRaw: SearchConfigEntry[] = [\n${searchEntriesLiteral ? ` ${searchEntriesLiteral}\\n` : ''}]\nconst entries = entriesRaw.filter((entry): entry is { moduleId: string; config: SearchModuleConfig } => entry.config != null)\n\nexport const searchModuleConfigEntries = entries\nexport const searchModuleConfigs: SearchModuleConfig[] = entries.map((entry) => entry.config)\n`\n\n // Validate module dependencies declared via ModuleInfo.requires\n {\n const enabledIds = new Set(enabled.map((e) => e.id))\n const problems: string[] = []\n for (const [modId, reqs] of requiresByModule.entries()) {\n const missing = reqs.filter((r) => !enabledIds.has(r))\n if (missing.length) {\n problems.push(`- Module \"${modId}\" requires: ${missing.join(', ')}`)\n }\n }\n if (problems.length) {\n console.error('\\nModule dependency check failed:')\n for (const p of problems) console.error(p)\n console.error('\\nFix: Enable required module(s) in src/modules.ts. Example:')\n console.error(\n ' export const enabledModules = [ { id: \\'' +\n Array.from(new Set(requiresByModule.values()).values()).join(\"' }, { id: '\") +\n \"' } ]\"\n )\n process.exit(1)\n }\n }\n\n const structureChecksum = calculateStructureChecksum(Array.from(trackedRoots))\n\n const modulesChecksum = { content: calculateChecksum(output), structure: structureChecksum }\n const existingModulesChecksum = readChecksumRecord(checksumFile)\n const shouldWriteModules =\n !existingModulesChecksum ||\n existingModulesChecksum.content !== modulesChecksum.content ||\n existingModulesChecksum.structure !== modulesChecksum.structure\n if (shouldWriteModules) {\n fs.mkdirSync(path.dirname(outFile), { recursive: true })\n fs.writeFileSync(outFile, output)\n writeChecksumRecord(checksumFile, modulesChecksum)\n result.filesWritten.push(outFile)\n } else {\n result.filesUnchanged.push(outFile)\n }\n if (!quiet) logGenerationResult(path.relative(process.cwd(), outFile), shouldWriteModules)\n\n const widgetsChecksum = { content: calculateChecksum(widgetsOutput), structure: structureChecksum }\n const existingWidgetsChecksum = readChecksumRecord(widgetsChecksumFile)\n const shouldWriteWidgets =\n !existingWidgetsChecksum ||\n existingWidgetsChecksum.content !== widgetsChecksum.content ||\n existingWidgetsChecksum.structure !== widgetsChecksum.structure\n if (shouldWriteWidgets) {\n fs.writeFileSync(widgetsOutFile, widgetsOutput)\n writeChecksumRecord(widgetsChecksumFile, widgetsChecksum)\n result.filesWritten.push(widgetsOutFile)\n } else {\n result.filesUnchanged.push(widgetsOutFile)\n }\n if (!quiet) logGenerationResult(path.relative(process.cwd(), widgetsOutFile), shouldWriteWidgets)\n\n const injectionWidgetEntriesList = Array.from(allInjectionWidgets.entries()).sort(([a], [b]) => a.localeCompare(b))\n const injectionWidgetDecls = injectionWidgetEntriesList.map(\n ([key, data]) =>\n ` { moduleId: '${data.moduleId}', key: '${key}', source: '${data.source}', loader: () => import('${data.importPath}').then((mod) => mod.default ?? mod) }`\n )\n const injectionWidgetsOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { ModuleInjectionWidgetEntry } from '@open-mercato/shared/modules/registry'\n\nexport const injectionWidgetEntries: ModuleInjectionWidgetEntry[] = [\n${injectionWidgetDecls.join(',\\n')}\n]\n`\n const injectionTableImports = allInjectionTables.map(\n (entry) => `import * as ${entry.importName} from '${entry.importPath}'`\n )\n const injectionTableDecls = allInjectionTables.map(\n (entry) =>\n ` { moduleId: '${entry.moduleId}', table: ((${entry.importName}.default ?? ${entry.importName}.injectionTable) as any) || {} }`\n )\n const injectionTablesOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { ModuleInjectionTable } from '@open-mercato/shared/modules/widgets/injection'\n${injectionTableImports.join('\\n')}\n\nexport const injectionTables: Array<{ moduleId: string; table: ModuleInjectionTable }> = [\n${injectionTableDecls.join(',\\n')}\n]\n`\n const injectionWidgetsChecksum = { content: calculateChecksum(injectionWidgetsOutput), structure: structureChecksum }\n const existingInjectionWidgetsChecksum = readChecksumRecord(injectionWidgetsChecksumFile)\n const shouldWriteInjectionWidgets =\n !existingInjectionWidgetsChecksum ||\n existingInjectionWidgetsChecksum.content !== injectionWidgetsChecksum.content ||\n existingInjectionWidgetsChecksum.structure !== injectionWidgetsChecksum.structure\n if (shouldWriteInjectionWidgets) {\n fs.writeFileSync(injectionWidgetsOutFile, injectionWidgetsOutput)\n writeChecksumRecord(injectionWidgetsChecksumFile, injectionWidgetsChecksum)\n result.filesWritten.push(injectionWidgetsOutFile)\n } else {\n result.filesUnchanged.push(injectionWidgetsOutFile)\n }\n if (!quiet) logGenerationResult(path.relative(process.cwd(), injectionWidgetsOutFile), shouldWriteInjectionWidgets)\n\n const injectionTablesChecksum = { content: calculateChecksum(injectionTablesOutput), structure: structureChecksum }\n const existingInjectionTablesChecksum = readChecksumRecord(injectionTablesChecksumFile)\n const shouldWriteInjectionTables =\n !existingInjectionTablesChecksum ||\n existingInjectionTablesChecksum.content !== injectionTablesChecksum.content ||\n existingInjectionTablesChecksum.structure !== injectionTablesChecksum.structure\n if (shouldWriteInjectionTables) {\n fs.writeFileSync(injectionTablesOutFile, injectionTablesOutput)\n writeChecksumRecord(injectionTablesChecksumFile, injectionTablesChecksum)\n result.filesWritten.push(injectionTablesOutFile)\n } else {\n result.filesUnchanged.push(injectionTablesOutFile)\n }\n if (!quiet) logGenerationResult(path.relative(process.cwd(), injectionTablesOutFile), shouldWriteInjectionTables)\n\n const searchChecksum = { content: calculateChecksum(searchOutput), structure: structureChecksum }\n const existingSearchChecksum = readChecksumRecord(searchChecksumFile)\n const shouldWriteSearch =\n !existingSearchChecksum ||\n existingSearchChecksum.content !== searchChecksum.content ||\n existingSearchChecksum.structure !== searchChecksum.structure\n if (shouldWriteSearch) {\n fs.writeFileSync(searchOutFile, searchOutput)\n writeChecksumRecord(searchChecksumFile, searchChecksum)\n result.filesWritten.push(searchOutFile)\n } else {\n result.filesUnchanged.push(searchOutFile)\n }\n if (!quiet) logGenerationResult(path.relative(process.cwd(), searchOutFile), shouldWriteSearch)\n\n return result\n}\n\n/**\n * Generate a CLI-specific module registry that excludes Next.js dependent code.\n * This produces modules.cli.generated.ts which can be loaded without Next.js runtime.\n *\n * Includes: module metadata, CLI commands, translations, subscribers, workers, entity extensions,\n * features/ACL, custom entities, vector config, custom fields\n * Excludes: frontend routes, backend routes, API handlers, dashboard/injection widgets\n */\nexport async function generateModuleRegistryCli(options: ModuleRegistryOptions): Promise<GeneratorResult> {\n const { resolver, quiet = false } = options\n const result = createGeneratorResult()\n\n const outputDir = resolver.getOutputDir()\n const outFile = path.join(outputDir, 'modules.cli.generated.ts')\n const checksumFile = path.join(outputDir, 'modules.cli.generated.checksum')\n\n const enabled = resolver.loadEnabledModules()\n const imports: string[] = []\n const moduleDecls: string[] = []\n let importId = 0\n const trackedRoots = new Set<string>()\n const requiresByModule = new Map<string, string[]>()\n\n for (const entry of enabled) {\n const modId = entry.id\n const roots = resolver.getModulePaths(entry)\n const imps = resolver.getModuleImportBase(entry)\n trackedRoots.add(roots.appBase)\n trackedRoots.add(roots.pkgBase)\n\n // For @app modules, use relative paths since @/ alias doesn't work in Node.js runtime\n // From .mercato/generated/, go up two levels (../..) to reach the app root, then into src/modules/\n const isAppModule = entry.from === '@app'\n const appImportBase = isAppModule ? `../../src/modules/${modId}` : imps.appBase\n\n let cliImportName: string | null = null\n const translations: string[] = []\n const subscribers: string[] = []\n const workers: string[] = []\n let infoImportName: string | null = null\n let extensionsImportName: string | null = null\n let fieldsImportName: string | null = null\n let featuresImportName: string | null = null\n let customEntitiesImportName: string | null = null\n let vectorImportName: string | null = null\n let customFieldSetsExpr: string = '[]'\n\n // Module metadata: index.ts (overrideable)\n const appIndex = findModuleFile(roots.appBase, 'index')\n const pkgIndex = findModuleFile(roots.pkgBase, 'index')\n const indexTs = appIndex ?? pkgIndex\n if (indexTs) {\n infoImportName = `I${importId++}_${toVar(modId)}`\n const importPath = indexTs.startsWith(roots.appBase) ? `${appImportBase}/index` : `${imps.pkgBase}/index`\n imports.push(`import * as ${infoImportName} from '${importPath}'`)\n // Try to eagerly read ModuleInfo.requires for dependency validation\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const mod = require(indexTs)\n const reqs: string[] | undefined =\n mod?.metadata && Array.isArray(mod.metadata.requires) ? mod.metadata.requires : undefined\n if (reqs && reqs.length) requiresByModule.set(modId, reqs)\n } catch {}\n }\n\n // Entity extensions: src/modules/<module>/data/extensions.ts\n {\n const appFile = findModuleFile(roots.appBase, 'data', 'extensions')\n const pkgFile = findModuleFile(roots.pkgBase, 'data', 'extensions')\n const hasApp = !!appFile\n const hasPkg = !!pkgFile\n if (hasApp || hasPkg) {\n const importName = `X_${toVar(modId)}_${importId++}`\n const importPath = hasApp ? `${appImportBase}/data/extensions` : `${imps.pkgBase}/data/extensions`\n imports.push(`import * as ${importName} from '${importPath}'`)\n extensionsImportName = importName\n }\n }\n\n // RBAC feature declarations: module root acl.ts\n {\n const rootApp = findModuleFile(roots.appBase, 'acl')\n const rootPkg = findModuleFile(roots.pkgBase, 'acl')\n const hasRoot = rootApp || rootPkg\n if (hasRoot) {\n const importName = `ACL_${toVar(modId)}_${importId++}`\n const useApp = rootApp ?? rootPkg!\n const importPath = useApp.startsWith(roots.appBase) ? `${appImportBase}/acl` : `${imps.pkgBase}/acl`\n imports.push(`import * as ${importName} from '${importPath}'`)\n featuresImportName = importName\n }\n }\n\n // Custom entities declarations: module root ce.ts\n {\n const appFile = findModuleFile(roots.appBase, 'ce')\n const pkgFile = findModuleFile(roots.pkgBase, 'ce')\n const hasApp = !!appFile\n const hasPkg = !!pkgFile\n if (hasApp || hasPkg) {\n const importName = `CE_${toVar(modId)}_${importId++}`\n const importPath = hasApp ? `${appImportBase}/ce` : `${imps.pkgBase}/ce`\n imports.push(`import * as ${importName} from '${importPath}'`)\n customEntitiesImportName = importName\n }\n }\n\n // Vector search configuration: module root vector.ts\n {\n const appFile = findModuleFile(roots.appBase, 'vector')\n const pkgFile = findModuleFile(roots.pkgBase, 'vector')\n const hasApp = !!appFile\n const hasPkg = !!pkgFile\n if (hasApp || hasPkg) {\n const importName = `VECTOR_${toVar(modId)}_${importId++}`\n const importPath = hasApp ? `${appImportBase}/vector` : `${imps.pkgBase}/vector`\n imports.push(`import * as ${importName} from '${importPath}'`)\n vectorImportName = importName\n }\n }\n\n // Custom field declarations: src/modules/<module>/data/fields.ts\n {\n const appFile = findModuleFile(roots.appBase, 'data', 'fields')\n const pkgFile = findModuleFile(roots.pkgBase, 'data', 'fields')\n const hasApp = !!appFile\n const hasPkg = !!pkgFile\n if (hasApp || hasPkg) {\n const importName = `F_${toVar(modId)}_${importId++}`\n const importPath = hasApp ? `${appImportBase}/data/fields` : `${imps.pkgBase}/data/fields`\n imports.push(`import * as ${importName} from '${importPath}'`)\n fieldsImportName = importName\n }\n }\n\n // CLI\n const cliApp = findModuleFile(roots.appBase, 'cli')\n const cliPkg = findModuleFile(roots.pkgBase, 'cli')\n const cliPath = cliApp ?? cliPkg\n if (cliPath) {\n const importName = `CLI_${toVar(modId)}`\n const importPath = cliPath.startsWith(roots.appBase) ? `${appImportBase}/cli` : `${imps.pkgBase}/cli`\n imports.push(`import ${importName} from '${importPath}'`)\n cliImportName = importName\n }\n\n // Translations: merge core + app with app overriding\n const i18nApp = path.join(roots.appBase, 'i18n')\n const i18nCore = path.join(roots.pkgBase, 'i18n')\n const locales = new Set<string>()\n if (fs.existsSync(i18nCore))\n for (const e of fs.readdirSync(i18nCore, { withFileTypes: true }))\n if (e.isFile() && e.name.endsWith('.json')) locales.add(e.name.replace(/\\.json$/, ''))\n if (fs.existsSync(i18nApp))\n for (const e of fs.readdirSync(i18nApp, { withFileTypes: true }))\n if (e.isFile() && e.name.endsWith('.json')) locales.add(e.name.replace(/\\.json$/, ''))\n for (const locale of locales) {\n const coreHas = fs.existsSync(path.join(i18nCore, `${locale}.json`))\n const appHas = fs.existsSync(path.join(i18nApp, `${locale}.json`))\n if (coreHas && appHas) {\n const cName = `T_${toVar(modId)}_${toVar(locale)}_C`\n const aName = `T_${toVar(modId)}_${toVar(locale)}_A`\n imports.push(`import ${cName} from '${imps.pkgBase}/i18n/${locale}.json'`)\n imports.push(`import ${aName} from '${appImportBase}/i18n/${locale}.json'`)\n translations.push(\n `'${locale}': { ...( ${cName} as unknown as Record<string,string> ), ...( ${aName} as unknown as Record<string,string> ) }`\n )\n } else if (appHas) {\n const aName = `T_${toVar(modId)}_${toVar(locale)}_A`\n imports.push(`import ${aName} from '${appImportBase}/i18n/${locale}.json'`)\n translations.push(`'${locale}': ${aName} as unknown as Record<string,string>`)\n } else if (coreHas) {\n const cName = `T_${toVar(modId)}_${toVar(locale)}_C`\n imports.push(`import ${cName} from '${imps.pkgBase}/i18n/${locale}.json'`)\n translations.push(`'${locale}': ${cName} as unknown as Record<string,string>`)\n }\n }\n\n // Subscribers: src/modules/<module>/subscribers/*.ts or *.js\n const subApp = path.join(roots.appBase, 'subscribers')\n const subPkg = path.join(roots.pkgBase, 'subscribers')\n if (fs.existsSync(subApp) || fs.existsSync(subPkg)) {\n const found: string[] = []\n const walk = (dir: string, rel: string[] = []) => {\n for (const e of fs.readdirSync(dir, { withFileTypes: true })) {\n if (e.isDirectory()) {\n if (e.name === '__tests__' || e.name === '__mocks__') continue\n walk(path.join(dir, e.name), [...rel, e.name])\n } else if (e.isFile() && (e.name.endsWith('.ts') || e.name.endsWith('.js'))) {\n if (/\\.(test|spec)\\.(ts|js)$/.test(e.name)) continue\n if (e.name.endsWith('.d.ts')) continue\n found.push([...rel, e.name].join('/'))\n }\n }\n }\n if (fs.existsSync(subPkg)) walk(subPkg)\n if (fs.existsSync(subApp)) walk(subApp)\n const files = Array.from(new Set(found))\n for (const rel of files) {\n const segs = rel.split('/')\n const file = segs.pop()!\n const name = file.replace(/\\.(ts|js)$/, '')\n const importName = `Subscriber${importId++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n const metaName = `SubscriberMeta${importId++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n const appFileTs = path.join(subApp, ...segs, `${name}.ts`)\n const appFileJs = path.join(subApp, ...segs, `${name}.js`)\n const fromApp = fs.existsSync(appFileTs) || fs.existsSync(appFileJs)\n const importPath = `${fromApp ? appImportBase : imps.pkgBase}/subscribers/${[...segs, name].join('/')}`\n imports.push(`import ${importName}, * as ${metaName} from '${importPath}'`)\n const sid = [modId, ...segs, name].filter(Boolean).join(':')\n subscribers.push(\n `{ id: (((${metaName}.metadata) as any)?.id || '${sid}'), event: ((${metaName}.metadata) as any)?.event, persistent: ((${metaName}.metadata) as any)?.persistent, handler: ${importName} }`\n )\n }\n }\n\n // Workers: src/modules/<module>/workers/*.ts or *.js\n // Only includes files that export `metadata` with a `queue` property\n {\n const wrkApp = path.join(roots.appBase, 'workers')\n const wrkPkg = path.join(roots.pkgBase, 'workers')\n if (fs.existsSync(wrkApp) || fs.existsSync(wrkPkg)) {\n const found: string[] = []\n const walk = (dir: string, rel: string[] = []) => {\n for (const e of fs.readdirSync(dir, { withFileTypes: true })) {\n if (e.isDirectory()) {\n if (e.name === '__tests__' || e.name === '__mocks__') continue\n walk(path.join(dir, e.name), [...rel, e.name])\n } else if (e.isFile() && (e.name.endsWith('.ts') || e.name.endsWith('.js'))) {\n if (/\\.(test|spec)\\.(ts|js)$/.test(e.name)) continue\n if (e.name.endsWith('.d.ts')) continue\n found.push([...rel, e.name].join('/'))\n }\n }\n }\n if (fs.existsSync(wrkPkg)) walk(wrkPkg)\n if (fs.existsSync(wrkApp)) walk(wrkApp)\n const files = Array.from(new Set(found))\n for (const rel of files) {\n const segs = rel.split('/')\n const file = segs.pop()!\n const name = file.replace(/\\.(ts|js)$/, '')\n const appFileTs = path.join(wrkApp, ...segs, `${name}.ts`)\n const appFileJs = path.join(wrkApp, ...segs, `${name}.js`)\n const fromApp = fs.existsSync(appFileTs) || fs.existsSync(appFileJs)\n // Use package import path for checking exports (file path fails due to relative imports)\n const importPath = `${fromApp ? appImportBase : imps.pkgBase}/workers/${[...segs, name].join('/')}`\n // Only include files that export metadata with a queue property\n if (!(await moduleHasExport(importPath, 'metadata'))) continue\n const importName = `Worker${importId++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n const metaName = `WorkerMeta${importId++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n imports.push(`import ${importName}, * as ${metaName} from '${importPath}'`)\n const wid = [modId, 'workers', ...segs, name].filter(Boolean).join(':')\n workers.push(\n `{ id: (${metaName}.metadata as { id?: string })?.id || '${wid}', queue: (${metaName}.metadata as { queue: string }).queue, concurrency: (${metaName}.metadata as { concurrency?: number })?.concurrency ?? 1, handler: ${importName} as (job: unknown, ctx: unknown) => Promise<void> }`\n )\n }\n }\n }\n\n // Build combined customFieldSets expression from data/fields.ts and ce.ts (entities[].fields)\n {\n const parts: string[] = []\n if (fieldsImportName)\n parts.push(`(( ${fieldsImportName}.default ?? ${fieldsImportName}.fieldSets) as any) || []`)\n if (customEntitiesImportName)\n parts.push(\n `((( ${customEntitiesImportName}.default ?? ${customEntitiesImportName}.entities) as any) || []).filter((e: any) => Array.isArray(e.fields) && e.fields.length).map((e: any) => ({ entity: e.id, fields: e.fields, source: '${modId}' }))`\n )\n customFieldSetsExpr = parts.length ? `[...${parts.join(', ...')}]` : '[]'\n }\n\n moduleDecls.push(`{\n id: '${modId}',\n ${infoImportName ? `info: ${infoImportName}.metadata,` : ''}\n ${cliImportName ? `cli: ${cliImportName},` : ''}\n ${translations.length ? `translations: { ${translations.join(', ')} },` : ''}\n ${subscribers.length ? `subscribers: [${subscribers.join(', ')}],` : ''}\n ${workers.length ? `workers: [${workers.join(', ')}],` : ''}\n ${extensionsImportName ? `entityExtensions: ((${extensionsImportName}.default ?? ${extensionsImportName}.extensions) as any) || [],` : ''}\n customFieldSets: ${customFieldSetsExpr},\n ${featuresImportName ? `features: ((${featuresImportName}.default ?? ${featuresImportName}.features) as any) || [],` : ''}\n ${customEntitiesImportName ? `customEntities: ((${customEntitiesImportName}.default ?? ${customEntitiesImportName}.entities) as any) || [],` : ''}\n ${vectorImportName ? `vector: (${vectorImportName}.default ?? ${vectorImportName}.vectorConfig ?? ${vectorImportName}.config ?? undefined),` : ''}\n }`)\n }\n\n const output = `// AUTO-GENERATED by mercato generate registry (CLI version)\n// This file excludes Next.js dependent code (routes, APIs, widgets)\nimport type { Module } from '@open-mercato/shared/modules/registry'\n${imports.join('\\n')}\n\nexport const modules: Module[] = [\n ${moduleDecls.join(',\\n ')}\n]\nexport const modulesInfo = modules.map(m => ({ id: m.id, ...(m.info || {}) }))\nexport default modules\n`\n\n // Validate module dependencies declared via ModuleInfo.requires\n {\n const enabledIds = new Set(enabled.map((e) => e.id))\n const problems: string[] = []\n for (const [modId, reqs] of requiresByModule.entries()) {\n const missing = reqs.filter((r) => !enabledIds.has(r))\n if (missing.length) {\n problems.push(`- Module \"${modId}\" requires: ${missing.join(', ')}`)\n }\n }\n if (problems.length) {\n console.error('\\nModule dependency check failed:')\n for (const p of problems) console.error(p)\n console.error('\\nFix: Enable required module(s) in src/modules.ts. Example:')\n console.error(\n ' export const enabledModules = [ { id: \\'' +\n Array.from(new Set(requiresByModule.values()).values()).join(\"' }, { id: '\") +\n \"' } ]\"\n )\n process.exit(1)\n }\n }\n\n const structureChecksum = calculateStructureChecksum(Array.from(trackedRoots))\n\n const checksum = { content: calculateChecksum(output), structure: structureChecksum }\n const existingChecksum = readChecksumRecord(checksumFile)\n const shouldWrite =\n !existingChecksum ||\n existingChecksum.content !== checksum.content ||\n existingChecksum.structure !== checksum.structure\n if (shouldWrite) {\n fs.mkdirSync(path.dirname(outFile), { recursive: true })\n fs.writeFileSync(outFile, output)\n writeChecksumRecord(checksumFile, checksum)\n result.filesWritten.push(outFile)\n } else {\n result.filesUnchanged.push(outFile)\n }\n if (!quiet) logGenerationResult(path.relative(process.cwd(), outFile), shouldWrite)\n\n return result\n}\n"],
|
|
5
|
+
"mappings": "AA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AAO,eAAe,KAAK,OAAO;AAAA,EACpC;AACA,MAAI,CAAC,MAAO,qBAAoB,KAAK,SAAS,QAAQ,IAAI,GAAG,OAAO,GAAG,WAAW;AAElF,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/cli",
|
|
3
|
-
"version": "0.4.2-canary-
|
|
3
|
+
"version": "0.4.2-canary-eb5f87d5f9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@mikro-orm/core": "^6.6.2",
|
|
56
56
|
"@mikro-orm/migrations": "^6.6.2",
|
|
57
57
|
"@mikro-orm/postgresql": "^6.6.2",
|
|
58
|
-
"@open-mercato/shared": "0.4.2-canary-
|
|
58
|
+
"@open-mercato/shared": "0.4.2-canary-eb5f87d5f9",
|
|
59
59
|
"pg": "^8.16.3",
|
|
60
60
|
"typescript": "^5.9.3"
|
|
61
61
|
},
|
|
@@ -369,19 +369,21 @@ export async function generateModuleRegistry(options: ModuleRegistryOptions): Pr
|
|
|
369
369
|
const apiApp = path.join(roots.appBase, 'api')
|
|
370
370
|
const apiPkg = path.join(roots.pkgBase, 'api')
|
|
371
371
|
if (fs.existsSync(apiApp) || fs.existsSync(apiPkg)) {
|
|
372
|
-
// route.ts aggregations
|
|
372
|
+
// route.ts or route.js aggregations
|
|
373
373
|
const routeFiles: string[] = []
|
|
374
374
|
const walk = (dir: string, rel: string[] = []) => {
|
|
375
375
|
for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
376
376
|
if (e.isDirectory()) {
|
|
377
377
|
if (e.name === '__tests__' || e.name === '__mocks__') continue
|
|
378
378
|
walk(path.join(dir, e.name), [...rel, e.name])
|
|
379
|
-
} else if (e.isFile() && e.name === 'route.ts'
|
|
379
|
+
} else if (e.isFile() && (e.name === 'route.ts' || e.name === 'route.js')) {
|
|
380
|
+
routeFiles.push([...rel, e.name].join('/'))
|
|
381
|
+
}
|
|
380
382
|
}
|
|
381
383
|
}
|
|
382
384
|
if (fs.existsSync(apiPkg)) walk(apiPkg)
|
|
383
385
|
if (fs.existsSync(apiApp)) walk(apiApp)
|
|
384
|
-
const routeList = Array.from(new Set(routeFiles))
|
|
386
|
+
const routeList = Array.from(new Set(routeFiles.map(f => f.replace(/\.(ts|js)$/, ''))))
|
|
385
387
|
const isDynamicRoute = (p: string) => p.split('/').some((seg) => /\[|\[\[\.\.\./.test(seg))
|
|
386
388
|
routeList.sort((a, b) => {
|
|
387
389
|
const ad = isDynamicRoute(a) ? 1 : 0
|
|
@@ -391,22 +393,27 @@ export async function generateModuleRegistry(options: ModuleRegistryOptions): Pr
|
|
|
391
393
|
})
|
|
392
394
|
for (const rel of routeList) {
|
|
393
395
|
const segs = rel.split('/')
|
|
394
|
-
segs.pop()
|
|
396
|
+
segs.pop() // remove 'route'
|
|
395
397
|
const reqSegs = [modId, ...segs]
|
|
396
398
|
const importName = `R${importId++}_${toVar(modId)}_${toVar(segs.join('_') || 'index')}`
|
|
397
|
-
const
|
|
398
|
-
const
|
|
399
|
+
const appFileTs = path.join(apiApp, ...segs, 'route.ts')
|
|
400
|
+
const appFileJs = path.join(apiApp, ...segs, 'route.js')
|
|
401
|
+
const fromApp = fs.existsSync(appFileTs) || fs.existsSync(appFileJs)
|
|
399
402
|
const apiSegPath = segs.join('/')
|
|
400
403
|
const importPath = `${fromApp ? appImportBase : imps.pkgBase}/api${apiSegPath ? `/${apiSegPath}` : ''}/route`
|
|
401
404
|
const routePath = '/' + reqSegs.filter(Boolean).join('/')
|
|
402
|
-
const
|
|
405
|
+
const pkgFileTs = path.join(apiPkg, ...segs, 'route.ts')
|
|
406
|
+
const pkgFileJs = path.join(apiPkg, ...segs, 'route.js')
|
|
407
|
+
const sourceFile = fromApp
|
|
408
|
+
? (fs.existsSync(appFileTs) ? appFileTs : appFileJs)
|
|
409
|
+
: (fs.existsSync(pkgFileTs) ? pkgFileTs : pkgFileJs)
|
|
403
410
|
const hasOpenApi = await moduleHasExport(sourceFile, 'openApi')
|
|
404
411
|
const docsPart = hasOpenApi ? `, docs: ${importName}.openApi` : ''
|
|
405
412
|
imports.push(`import * as ${importName} from '${importPath}'`)
|
|
406
413
|
apis.push(`{ path: '${routePath}', metadata: (${importName} as any).metadata, handlers: ${importName} as any${docsPart} }`)
|
|
407
414
|
}
|
|
408
415
|
|
|
409
|
-
// Single files
|
|
416
|
+
// Single files (non-route API files)
|
|
410
417
|
const plainFiles: string[] = []
|
|
411
418
|
const methodNames = new Set(['get', 'post', 'put', 'patch', 'delete'])
|
|
412
419
|
const walkPlain = (dir: string, rel: string[] = []) => {
|
|
@@ -415,28 +422,32 @@ export async function generateModuleRegistry(options: ModuleRegistryOptions): Pr
|
|
|
415
422
|
if (methodNames.has(e.name.toLowerCase())) continue
|
|
416
423
|
if (e.name === '__tests__' || e.name === '__mocks__') continue
|
|
417
424
|
walkPlain(path.join(dir, e.name), [...rel, e.name])
|
|
418
|
-
} else if (e.isFile() && e.name.endsWith('.ts')
|
|
419
|
-
if (/\.(test|spec)\.ts$/.test(e.name)) continue
|
|
425
|
+
} else if (e.isFile() && (e.name.endsWith('.ts') || e.name.endsWith('.js')) && !e.name.startsWith('route.')) {
|
|
426
|
+
if (/\.(test|spec)\.(ts|js)$/.test(e.name)) continue
|
|
427
|
+
if (e.name.endsWith('.d.ts')) continue
|
|
420
428
|
plainFiles.push([...rel, e.name].join('/'))
|
|
421
429
|
}
|
|
422
430
|
}
|
|
423
431
|
}
|
|
424
432
|
if (fs.existsSync(apiPkg)) walkPlain(apiPkg)
|
|
425
433
|
if (fs.existsSync(apiApp)) walkPlain(apiApp)
|
|
426
|
-
const plainList = Array.from(new Set(plainFiles))
|
|
434
|
+
const plainList = Array.from(new Set(plainFiles.map(f => f.replace(/\.(ts|js)$/, ''))))
|
|
427
435
|
for (const rel of plainList) {
|
|
428
436
|
const segs = rel.split('/')
|
|
429
|
-
const
|
|
430
|
-
const pathWithoutExt = file.replace(/\.ts$/, '')
|
|
437
|
+
const pathWithoutExt = segs.pop()!
|
|
431
438
|
const fullSegs = [...segs, pathWithoutExt]
|
|
432
439
|
const routePath = '/' + [modId, ...fullSegs].filter(Boolean).join('/')
|
|
433
440
|
const importName = `R${importId++}_${toVar(modId)}_${toVar(fullSegs.join('_') || 'index')}`
|
|
434
|
-
const
|
|
435
|
-
const
|
|
441
|
+
const appFileTs = path.join(apiApp, ...fullSegs) + '.ts'
|
|
442
|
+
const appFileJs = path.join(apiApp, ...fullSegs) + '.js'
|
|
443
|
+
const fromApp = fs.existsSync(appFileTs) || fs.existsSync(appFileJs)
|
|
436
444
|
const plainSegPath = fullSegs.join('/')
|
|
437
445
|
const importPath = `${fromApp ? appImportBase : imps.pkgBase}/api${plainSegPath ? `/${plainSegPath}` : ''}`
|
|
438
|
-
const
|
|
439
|
-
const
|
|
446
|
+
const pkgFileTs = path.join(apiPkg, ...fullSegs) + '.ts'
|
|
447
|
+
const pkgFileJs = path.join(apiPkg, ...fullSegs) + '.js'
|
|
448
|
+
const sourceFile = fromApp
|
|
449
|
+
? (fs.existsSync(appFileTs) ? appFileTs : appFileJs)
|
|
450
|
+
: (fs.existsSync(pkgFileTs) ? pkgFileTs : pkgFileJs)
|
|
440
451
|
const hasOpenApi = await moduleHasExport(sourceFile, 'openApi')
|
|
441
452
|
const docsPart = hasOpenApi ? `, docs: ${importName}.openApi` : ''
|
|
442
453
|
imports.push(`import * as ${importName} from '${importPath}'`)
|
|
@@ -455,25 +466,27 @@ export async function generateModuleRegistry(options: ModuleRegistryOptions): Pr
|
|
|
455
466
|
if (e.isDirectory()) {
|
|
456
467
|
if (e.name === '__tests__' || e.name === '__mocks__') continue
|
|
457
468
|
walk2(path.join(dir, e.name), [...rel, e.name])
|
|
458
|
-
} else if (e.isFile() && e.name.endsWith('.ts')) {
|
|
459
|
-
if (/\.(test|spec)\.ts$/.test(e.name)) continue
|
|
469
|
+
} else if (e.isFile() && (e.name.endsWith('.ts') || e.name.endsWith('.js'))) {
|
|
470
|
+
if (/\.(test|spec)\.(ts|js)$/.test(e.name)) continue
|
|
471
|
+
if (e.name.endsWith('.d.ts')) continue
|
|
460
472
|
apiFiles.push([...rel, e.name].join('/'))
|
|
461
473
|
}
|
|
462
474
|
}
|
|
463
475
|
}
|
|
464
476
|
walk2(methodDir)
|
|
465
|
-
const methodList = Array.from(new Set(apiFiles))
|
|
477
|
+
const methodList = Array.from(new Set(apiFiles.map(f => f.replace(/\.(ts|js)$/, ''))))
|
|
466
478
|
for (const rel of methodList) {
|
|
467
479
|
const segs = rel.split('/')
|
|
468
|
-
const
|
|
469
|
-
const pathWithoutExt = file.replace(/\.ts$/, '')
|
|
480
|
+
const pathWithoutExt = segs.pop()!
|
|
470
481
|
const fullSegs = [...segs, pathWithoutExt]
|
|
471
482
|
const routePath = '/' + [modId, ...fullSegs].filter(Boolean).join('/')
|
|
472
483
|
const importName = `H${importId++}_${toVar(modId)}_${toVar(method)}_${toVar(fullSegs.join('_'))}`
|
|
473
484
|
const fromApp = methodDir === appMethodDir
|
|
474
485
|
const importPath = `${fromApp ? appImportBase : imps.pkgBase}/api/${method.toLowerCase()}/${fullSegs.join('/')}`
|
|
475
486
|
const metaName = `RM${importId++}_${toVar(modId)}_${toVar(method)}_${toVar(fullSegs.join('_'))}`
|
|
476
|
-
const
|
|
487
|
+
const sourceFileTs = path.join(methodDir, ...segs, `${pathWithoutExt}.ts`)
|
|
488
|
+
const sourceFileJs = path.join(methodDir, ...segs, `${pathWithoutExt}.js`)
|
|
489
|
+
const sourceFile = fs.existsSync(sourceFileTs) ? sourceFileTs : sourceFileJs
|
|
477
490
|
const hasOpenApi = await moduleHasExport(sourceFile, 'openApi')
|
|
478
491
|
const docsPart = hasOpenApi ? `, docs: ${metaName}.openApi` : ''
|
|
479
492
|
imports.push(`import ${importName}, * as ${metaName} from '${importPath}'`)
|
|
@@ -525,7 +538,7 @@ export async function generateModuleRegistry(options: ModuleRegistryOptions): Pr
|
|
|
525
538
|
}
|
|
526
539
|
}
|
|
527
540
|
|
|
528
|
-
// Subscribers: src/modules/<module>/subscribers/*.ts
|
|
541
|
+
// Subscribers: src/modules/<module>/subscribers/*.ts or *.js
|
|
529
542
|
const subApp = path.join(roots.appBase, 'subscribers')
|
|
530
543
|
const subPkg = path.join(roots.pkgBase, 'subscribers')
|
|
531
544
|
if (fs.existsSync(subApp) || fs.existsSync(subPkg)) {
|
|
@@ -535,8 +548,9 @@ export async function generateModuleRegistry(options: ModuleRegistryOptions): Pr
|
|
|
535
548
|
if (e.isDirectory()) {
|
|
536
549
|
if (e.name === '__tests__' || e.name === '__mocks__') continue
|
|
537
550
|
walk(path.join(dir, e.name), [...rel, e.name])
|
|
538
|
-
} else if (e.isFile() && e.name.endsWith('.ts')) {
|
|
539
|
-
if (/\.(test|spec)\.ts$/.test(e.name)) continue
|
|
551
|
+
} else if (e.isFile() && (e.name.endsWith('.ts') || e.name.endsWith('.js'))) {
|
|
552
|
+
if (/\.(test|spec)\.(ts|js)$/.test(e.name)) continue
|
|
553
|
+
if (e.name.endsWith('.d.ts')) continue
|
|
540
554
|
found.push([...rel, e.name].join('/'))
|
|
541
555
|
}
|
|
542
556
|
}
|
|
@@ -547,11 +561,12 @@ export async function generateModuleRegistry(options: ModuleRegistryOptions): Pr
|
|
|
547
561
|
for (const rel of files) {
|
|
548
562
|
const segs = rel.split('/')
|
|
549
563
|
const file = segs.pop()!
|
|
550
|
-
const name = file.replace(/\.ts$/, '')
|
|
564
|
+
const name = file.replace(/\.(ts|js)$/, '')
|
|
551
565
|
const importName = `Subscriber${importId++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`
|
|
552
566
|
const metaName = `SubscriberMeta${importId++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`
|
|
553
|
-
const
|
|
554
|
-
const
|
|
567
|
+
const appFileTs = path.join(subApp, ...segs, `${name}.ts`)
|
|
568
|
+
const appFileJs = path.join(subApp, ...segs, `${name}.js`)
|
|
569
|
+
const fromApp = fs.existsSync(appFileTs) || fs.existsSync(appFileJs)
|
|
555
570
|
const importPath = `${fromApp ? appImportBase : imps.pkgBase}/subscribers/${[...segs, name].join('/')}`
|
|
556
571
|
imports.push(`import ${importName}, * as ${metaName} from '${importPath}'`)
|
|
557
572
|
const sid = [modId, ...segs, name].filter(Boolean).join(':')
|
|
@@ -561,7 +576,7 @@ export async function generateModuleRegistry(options: ModuleRegistryOptions): Pr
|
|
|
561
576
|
}
|
|
562
577
|
}
|
|
563
578
|
|
|
564
|
-
// Workers: src/modules/<module>/workers/*.ts
|
|
579
|
+
// Workers: src/modules/<module>/workers/*.ts or *.js
|
|
565
580
|
// Only includes files that export `metadata` with a `queue` property
|
|
566
581
|
{
|
|
567
582
|
const wrkApp = path.join(roots.appBase, 'workers')
|
|
@@ -573,8 +588,9 @@ export async function generateModuleRegistry(options: ModuleRegistryOptions): Pr
|
|
|
573
588
|
if (e.isDirectory()) {
|
|
574
589
|
if (e.name === '__tests__' || e.name === '__mocks__') continue
|
|
575
590
|
walk(path.join(dir, e.name), [...rel, e.name])
|
|
576
|
-
} else if (e.isFile() && e.name.endsWith('.ts')) {
|
|
577
|
-
if (/\.(test|spec)\.ts$/.test(e.name)) continue
|
|
591
|
+
} else if (e.isFile() && (e.name.endsWith('.ts') || e.name.endsWith('.js'))) {
|
|
592
|
+
if (/\.(test|spec)\.(ts|js)$/.test(e.name)) continue
|
|
593
|
+
if (e.name.endsWith('.d.ts')) continue
|
|
578
594
|
found.push([...rel, e.name].join('/'))
|
|
579
595
|
}
|
|
580
596
|
}
|
|
@@ -585,9 +601,10 @@ export async function generateModuleRegistry(options: ModuleRegistryOptions): Pr
|
|
|
585
601
|
for (const rel of files) {
|
|
586
602
|
const segs = rel.split('/')
|
|
587
603
|
const file = segs.pop()!
|
|
588
|
-
const name = file.replace(/\.ts$/, '')
|
|
589
|
-
const
|
|
590
|
-
const
|
|
604
|
+
const name = file.replace(/\.(ts|js)$/, '')
|
|
605
|
+
const appFileTs = path.join(wrkApp, ...segs, `${name}.ts`)
|
|
606
|
+
const appFileJs = path.join(wrkApp, ...segs, `${name}.js`)
|
|
607
|
+
const fromApp = fs.existsSync(appFileTs) || fs.existsSync(appFileJs)
|
|
591
608
|
// Use package import path for checking exports (file path fails due to relative imports)
|
|
592
609
|
const importPath = `${fromApp ? appImportBase : imps.pkgBase}/workers/${[...segs, name].join('/')}`
|
|
593
610
|
// Only include files that export metadata with a queue property
|
|
@@ -1075,7 +1092,7 @@ export async function generateModuleRegistryCli(options: ModuleRegistryOptions):
|
|
|
1075
1092
|
}
|
|
1076
1093
|
}
|
|
1077
1094
|
|
|
1078
|
-
// Subscribers: src/modules/<module>/subscribers/*.ts
|
|
1095
|
+
// Subscribers: src/modules/<module>/subscribers/*.ts or *.js
|
|
1079
1096
|
const subApp = path.join(roots.appBase, 'subscribers')
|
|
1080
1097
|
const subPkg = path.join(roots.pkgBase, 'subscribers')
|
|
1081
1098
|
if (fs.existsSync(subApp) || fs.existsSync(subPkg)) {
|
|
@@ -1085,8 +1102,9 @@ export async function generateModuleRegistryCli(options: ModuleRegistryOptions):
|
|
|
1085
1102
|
if (e.isDirectory()) {
|
|
1086
1103
|
if (e.name === '__tests__' || e.name === '__mocks__') continue
|
|
1087
1104
|
walk(path.join(dir, e.name), [...rel, e.name])
|
|
1088
|
-
} else if (e.isFile() && e.name.endsWith('.ts')) {
|
|
1089
|
-
if (/\.(test|spec)\.ts$/.test(e.name)) continue
|
|
1105
|
+
} else if (e.isFile() && (e.name.endsWith('.ts') || e.name.endsWith('.js'))) {
|
|
1106
|
+
if (/\.(test|spec)\.(ts|js)$/.test(e.name)) continue
|
|
1107
|
+
if (e.name.endsWith('.d.ts')) continue
|
|
1090
1108
|
found.push([...rel, e.name].join('/'))
|
|
1091
1109
|
}
|
|
1092
1110
|
}
|
|
@@ -1097,11 +1115,12 @@ export async function generateModuleRegistryCli(options: ModuleRegistryOptions):
|
|
|
1097
1115
|
for (const rel of files) {
|
|
1098
1116
|
const segs = rel.split('/')
|
|
1099
1117
|
const file = segs.pop()!
|
|
1100
|
-
const name = file.replace(/\.ts$/, '')
|
|
1118
|
+
const name = file.replace(/\.(ts|js)$/, '')
|
|
1101
1119
|
const importName = `Subscriber${importId++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`
|
|
1102
1120
|
const metaName = `SubscriberMeta${importId++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`
|
|
1103
|
-
const
|
|
1104
|
-
const
|
|
1121
|
+
const appFileTs = path.join(subApp, ...segs, `${name}.ts`)
|
|
1122
|
+
const appFileJs = path.join(subApp, ...segs, `${name}.js`)
|
|
1123
|
+
const fromApp = fs.existsSync(appFileTs) || fs.existsSync(appFileJs)
|
|
1105
1124
|
const importPath = `${fromApp ? appImportBase : imps.pkgBase}/subscribers/${[...segs, name].join('/')}`
|
|
1106
1125
|
imports.push(`import ${importName}, * as ${metaName} from '${importPath}'`)
|
|
1107
1126
|
const sid = [modId, ...segs, name].filter(Boolean).join(':')
|
|
@@ -1111,7 +1130,7 @@ export async function generateModuleRegistryCli(options: ModuleRegistryOptions):
|
|
|
1111
1130
|
}
|
|
1112
1131
|
}
|
|
1113
1132
|
|
|
1114
|
-
// Workers: src/modules/<module>/workers/*.ts
|
|
1133
|
+
// Workers: src/modules/<module>/workers/*.ts or *.js
|
|
1115
1134
|
// Only includes files that export `metadata` with a `queue` property
|
|
1116
1135
|
{
|
|
1117
1136
|
const wrkApp = path.join(roots.appBase, 'workers')
|
|
@@ -1123,8 +1142,9 @@ export async function generateModuleRegistryCli(options: ModuleRegistryOptions):
|
|
|
1123
1142
|
if (e.isDirectory()) {
|
|
1124
1143
|
if (e.name === '__tests__' || e.name === '__mocks__') continue
|
|
1125
1144
|
walk(path.join(dir, e.name), [...rel, e.name])
|
|
1126
|
-
} else if (e.isFile() && e.name.endsWith('.ts')) {
|
|
1127
|
-
if (/\.(test|spec)\.ts$/.test(e.name)) continue
|
|
1145
|
+
} else if (e.isFile() && (e.name.endsWith('.ts') || e.name.endsWith('.js'))) {
|
|
1146
|
+
if (/\.(test|spec)\.(ts|js)$/.test(e.name)) continue
|
|
1147
|
+
if (e.name.endsWith('.d.ts')) continue
|
|
1128
1148
|
found.push([...rel, e.name].join('/'))
|
|
1129
1149
|
}
|
|
1130
1150
|
}
|
|
@@ -1135,9 +1155,10 @@ export async function generateModuleRegistryCli(options: ModuleRegistryOptions):
|
|
|
1135
1155
|
for (const rel of files) {
|
|
1136
1156
|
const segs = rel.split('/')
|
|
1137
1157
|
const file = segs.pop()!
|
|
1138
|
-
const name = file.replace(/\.ts$/, '')
|
|
1139
|
-
const
|
|
1140
|
-
const
|
|
1158
|
+
const name = file.replace(/\.(ts|js)$/, '')
|
|
1159
|
+
const appFileTs = path.join(wrkApp, ...segs, `${name}.ts`)
|
|
1160
|
+
const appFileJs = path.join(wrkApp, ...segs, `${name}.js`)
|
|
1161
|
+
const fromApp = fs.existsSync(appFileTs) || fs.existsSync(appFileJs)
|
|
1141
1162
|
// Use package import path for checking exports (file path fails due to relative imports)
|
|
1142
1163
|
const importPath = `${fromApp ? appImportBase : imps.pkgBase}/workers/${[...segs, name].join('/')}`
|
|
1143
1164
|
// Only include files that export metadata with a queue property
|