@open-mercato/cli 0.4.6-develop-7889bc5a01 → 0.4.6-develop-02aac88968
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.
|
@@ -177,7 +177,7 @@ function processSubscribers(options) {
|
|
|
177
177
|
imports.push(`import ${importName}, * as ${metaName} from '${importPath}'`);
|
|
178
178
|
const sid = [modId, ...segs, name].filter(Boolean).join(":");
|
|
179
179
|
subscribers.push(
|
|
180
|
-
`{ id: (((${metaName}.metadata) as any)?.id || '${sid}'), event: ((${metaName}.metadata) as any)?.event, persistent: ((${metaName}.metadata) as any)?.persistent, handler: ${importName} }`
|
|
180
|
+
`{ id: (((${metaName}.metadata) as any)?.id || '${sid}'), event: ((${metaName}.metadata) as any)?.event, persistent: ((${metaName}.metadata) as any)?.persistent, sync: ((${metaName}.metadata) as any)?.sync, priority: ((${metaName}.metadata) as any)?.priority, handler: ${importName} }`
|
|
181
181
|
);
|
|
182
182
|
}
|
|
183
183
|
return subscribers;
|
|
@@ -301,6 +301,10 @@ async function generateModuleRegistry(options) {
|
|
|
301
301
|
const componentOverridesChecksumFile = path.join(outputDir, "component-overrides.generated.checksum");
|
|
302
302
|
const inboxActionsOutFile = path.join(outputDir, "inbox-actions.generated.ts");
|
|
303
303
|
const inboxActionsChecksumFile = path.join(outputDir, "inbox-actions.generated.checksum");
|
|
304
|
+
const guardsOutFile = path.join(outputDir, "guards.generated.ts");
|
|
305
|
+
const guardsChecksumFile = path.join(outputDir, "guards.generated.checksum");
|
|
306
|
+
const commandInterceptorsOutFile = path.join(outputDir, "command-interceptors.generated.ts");
|
|
307
|
+
const commandInterceptorsChecksumFile = path.join(outputDir, "command-interceptors.generated.checksum");
|
|
304
308
|
const enabled = resolver.loadEnabledModules();
|
|
305
309
|
const imports = [];
|
|
306
310
|
const moduleDecls = [];
|
|
@@ -336,6 +340,10 @@ async function generateModuleRegistry(options) {
|
|
|
336
340
|
const componentOverrideImports = [];
|
|
337
341
|
const inboxActionsConfigs = [];
|
|
338
342
|
const inboxActionsImports = [];
|
|
343
|
+
const guardConfigs = [];
|
|
344
|
+
const guardImports = [];
|
|
345
|
+
const commandInterceptorConfigs = [];
|
|
346
|
+
const commandInterceptorImports = [];
|
|
339
347
|
for (const entry of enabled) {
|
|
340
348
|
const modId = entry.id;
|
|
341
349
|
const roots = resolver.getModulePaths(entry);
|
|
@@ -574,6 +582,28 @@ async function generateModuleRegistry(options) {
|
|
|
574
582
|
);
|
|
575
583
|
}
|
|
576
584
|
}
|
|
585
|
+
processStandaloneConfig({
|
|
586
|
+
roots,
|
|
587
|
+
imps,
|
|
588
|
+
modId,
|
|
589
|
+
importIdRef,
|
|
590
|
+
relativePath: "data/guards.ts",
|
|
591
|
+
prefix: "GUARDS",
|
|
592
|
+
standaloneImports: guardImports,
|
|
593
|
+
standaloneConfigs: guardConfigs,
|
|
594
|
+
configExpr: (n, id) => `{ moduleId: '${id}', guards: ((${n} as any).guards ?? (${n} as any).default ?? []) }`
|
|
595
|
+
});
|
|
596
|
+
processStandaloneConfig({
|
|
597
|
+
roots,
|
|
598
|
+
imps,
|
|
599
|
+
modId,
|
|
600
|
+
importIdRef,
|
|
601
|
+
relativePath: "commands/interceptors.ts",
|
|
602
|
+
prefix: "CMD_INTERCEPTORS",
|
|
603
|
+
standaloneImports: commandInterceptorImports,
|
|
604
|
+
standaloneConfigs: commandInterceptorConfigs,
|
|
605
|
+
configExpr: (n, id) => `{ moduleId: '${id}', interceptors: ((${n} as any).interceptors ?? (${n} as any).default ?? []) }`
|
|
606
|
+
});
|
|
577
607
|
{
|
|
578
608
|
const setup = resolveConventionFile(roots, imps, "setup.ts", "SETUP", modId, importIdRef, imports);
|
|
579
609
|
if (setup) setupImportName = setup.importName;
|
|
@@ -1170,6 +1200,32 @@ ${componentOverrideEntriesLiteral ? ` ${componentOverrideEntriesLiteral}
|
|
|
1170
1200
|
result,
|
|
1171
1201
|
quiet
|
|
1172
1202
|
});
|
|
1203
|
+
const guardEntriesLiteral = guardConfigs.join(",\n ");
|
|
1204
|
+
const guardImportSection = guardImports.join("\n");
|
|
1205
|
+
const guardsOutput = `// AUTO-GENERATED by mercato generate registry
|
|
1206
|
+
import type { MutationGuard } from '@open-mercato/shared/lib/crud/mutation-guard-registry'
|
|
1207
|
+
${guardImportSection ? `
|
|
1208
|
+
${guardImportSection}
|
|
1209
|
+
` : "\n"}type GuardEntry = { moduleId: string; guards: MutationGuard[] }
|
|
1210
|
+
|
|
1211
|
+
export const guardEntries: GuardEntry[] = [
|
|
1212
|
+
${guardEntriesLiteral ? ` ${guardEntriesLiteral}
|
|
1213
|
+
` : ""}]
|
|
1214
|
+
`;
|
|
1215
|
+
writeGeneratedFile({ outFile: guardsOutFile, checksumFile: guardsChecksumFile, content: guardsOutput, structureChecksum, result, quiet });
|
|
1216
|
+
const commandInterceptorEntriesLiteral = commandInterceptorConfigs.join(",\n ");
|
|
1217
|
+
const commandInterceptorImportSection = commandInterceptorImports.join("\n");
|
|
1218
|
+
const commandInterceptorsOutput = `// AUTO-GENERATED by mercato generate registry
|
|
1219
|
+
import type { CommandInterceptor } from '@open-mercato/shared/lib/commands/command-interceptor'
|
|
1220
|
+
${commandInterceptorImportSection ? `
|
|
1221
|
+
${commandInterceptorImportSection}
|
|
1222
|
+
` : "\n"}type CommandInterceptorEntry = { moduleId: string; interceptors: CommandInterceptor[] }
|
|
1223
|
+
|
|
1224
|
+
export const commandInterceptorEntries: CommandInterceptorEntry[] = [
|
|
1225
|
+
${commandInterceptorEntriesLiteral ? ` ${commandInterceptorEntriesLiteral}
|
|
1226
|
+
` : ""}]
|
|
1227
|
+
`;
|
|
1228
|
+
writeGeneratedFile({ outFile: commandInterceptorsOutFile, checksumFile: commandInterceptorsChecksumFile, content: commandInterceptorsOutput, structureChecksum, result, quiet });
|
|
1173
1229
|
return result;
|
|
1174
1230
|
}
|
|
1175
1231
|
async function generateModuleRegistryCli(options) {
|
|
@@ -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 calculateStructureChecksum,\n toVar,\n moduleHasExport,\n type GeneratorResult,\n createGeneratorResult,\n writeGeneratedFile,\n} from '../utils'\nimport {\n scanModuleDir,\n resolveModuleFile,\n SCAN_CONFIGS,\n type ModuleRoots,\n type ModuleImports,\n} from './scanner'\n\ntype HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'\n\nexport interface ModuleRegistryOptions {\n resolver: PackageResolver\n quiet?: boolean\n}\n\ntype DashboardWidgetEntry = {\n moduleId: string\n key: string\n source: 'app' | 'package'\n importPath: string\n}\n\nfunction scanDashboardWidgetEntries(options: {\n modId: string\n roots: ModuleRoots\n appImportBase: string\n pkgImportBase: string\n}): DashboardWidgetEntry[] {\n const { modId, roots, appImportBase, pkgImportBase } = options\n const files = scanModuleDir(roots, SCAN_CONFIGS.dashboardWidgets)\n return files.map(({ relPath, fromApp }) => {\n const segs = relPath.split('/')\n const file = segs.pop()!\n const base = file.replace(/\\.(t|j)sx?$/, '')\n const importPath = `${fromApp ? appImportBase : pkgImportBase}/widgets/dashboard/${[...segs, base].join('/')}`\n const key = [modId, ...segs, base].filter(Boolean).join(':')\n const source = fromApp ? 'app' : 'package'\n return { moduleId: modId, key, source, importPath }\n })\n}\n\nfunction processPageFiles(options: {\n files: Array<{ relPath: string; fromApp: boolean }>\n type: 'frontend' | 'backend'\n modId: string\n appDir: string\n pkgDir: string\n appImportBase: string\n pkgImportBase: string\n imports: string[]\n importIdRef: { value: number }\n}): string[] {\n const { files, type, modId, appDir, pkgDir, appImportBase, pkgImportBase, imports, importIdRef } = options\n const prefix = type === 'frontend' ? 'C' : 'B'\n const modPrefix = type === 'frontend' ? 'CM' : 'BM'\n const metaPrefix = type === 'frontend' ? 'M' : 'BM'\n const routes: string[] = []\n\n // Next-style page.tsx files\n for (const { relPath, fromApp } of files.filter(({ relPath: f }) => f.endsWith('/page.tsx') || f === 'page.tsx')) {\n const segs = relPath.split('/')\n segs.pop()\n const importName = `${prefix}${importIdRef.value++}_${toVar(modId)}_${toVar(segs.join('_') || 'index')}`\n const pageModName = `${modPrefix}${importIdRef.value++}_${toVar(modId)}_${toVar(segs.join('_') || 'index')}`\n const sub = segs.length ? `${segs.join('/')}/page` : 'page'\n const importPath = `${fromApp ? appImportBase : pkgImportBase}/${type}/${sub}`\n const routePath = type === 'frontend'\n ? '/' + (segs.join('/') || '')\n : '/backend/' + (segs.join('/') || modId)\n const metaCandidates = [\n path.join(fromApp ? appDir : pkgDir, ...segs, 'page.meta.ts'),\n path.join(fromApp ? appDir : pkgDir, ...segs, 'meta.ts'),\n ]\n const metaPath = metaCandidates.find((p) => fs.existsSync(p))\n let metaExpr = 'undefined'\n if (metaPath) {\n const metaImportName = `${metaPrefix}${importIdRef.value++}_${toVar(modId)}_${toVar(segs.join('_') || 'index')}`\n const metaImportPath = `${fromApp ? appImportBase : pkgImportBase}/${type}/${[...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 const baseProps = `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`\n const extraProps = type === 'backend' ? `, pageContext: (${metaExpr})?.pageContext` : ''\n routes.push(`{ ${baseProps}${extraProps}, Component: ${importName} }`)\n }\n\n // Back-compat direct files (old-style pages like login.tsx instead of login/page.tsx)\n for (const { relPath, fromApp } of files.filter(({ relPath: f }) => !f.endsWith('/page.tsx') && f !== 'page.tsx')) {\n const segs = relPath.split('/')\n const file = segs.pop()!\n const name = file.replace(/\\.tsx$/, '')\n const routeSegs = [...segs, name].filter(Boolean)\n const importName = `${prefix}${importIdRef.value++}_${toVar(modId)}_${toVar(routeSegs.join('_') || 'index')}`\n const pageModName = `${modPrefix}${importIdRef.value++}_${toVar(modId)}_${toVar(routeSegs.join('_') || 'index')}`\n const importPath = `${fromApp ? appImportBase : pkgImportBase}/${type}/${[...segs, name].join('/')}`\n const routePath = type === 'frontend'\n ? '/' + (routeSegs.join('/') || '')\n : '/backend/' + [modId, ...segs, name].filter(Boolean).join('/')\n const metaCandidates = [\n path.join(fromApp ? appDir : pkgDir, ...segs, `${name}.meta.ts`),\n path.join(fromApp ? appDir : pkgDir, ...segs, 'meta.ts'),\n ]\n const metaPath = metaCandidates.find((p) => fs.existsSync(p))\n let metaExpr = 'undefined'\n if (metaPath) {\n const metaImportName = `${metaPrefix}${importIdRef.value++}_${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 : pkgImportBase}/${type}/${[...segs, metaImportSub].join('/')}`\n imports.push(`import * as ${metaImportName} from '${metaImportPath}'`)\n metaExpr = type === 'frontend' ? `(${metaImportName}.metadata as any)` : `${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 const baseProps = `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`\n const extraFe = type === 'frontend' ? `, visible: (${metaExpr})?.visible, enabled: (${metaExpr})?.enabled` : `, 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, pageContext: (${metaExpr})?.pageContext`\n routes.push(`{ ${baseProps}${extraFe}, Component: ${importName} }`)\n }\n\n return routes\n}\n\nasync function processApiRoutes(options: {\n roots: ModuleRoots\n modId: string\n appImportBase: string\n pkgImportBase: string\n imports: string[]\n importIdRef: { value: number }\n}): Promise<string[]> {\n const { roots, modId, appImportBase, pkgImportBase, imports, importIdRef } = options\n const apiApp = path.join(roots.appBase, 'api')\n const apiPkg = path.join(roots.pkgBase, 'api')\n if (!fs.existsSync(apiApp) && !fs.existsSync(apiPkg)) return []\n\n const apis: string[] = []\n\n // route.ts aggregations\n const routeFiles = scanModuleDir(roots, SCAN_CONFIGS.apiRoutes)\n for (const { relPath, fromApp } of routeFiles) {\n const segs = relPath.split('/')\n segs.pop()\n const reqSegs = [modId, ...segs]\n const importName = `R${importIdRef.value++}_${toVar(modId)}_${toVar(segs.join('_') || 'index')}`\n const appFile = path.join(apiApp, ...segs, 'route.ts')\n const apiSegPath = segs.join('/')\n const importPath = `${fromApp ? appImportBase : pkgImportBase}/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 (plain .ts, not route.ts, not tests, skip method dirs)\n const plainFiles = scanModuleDir(roots, SCAN_CONFIGS.apiPlainFiles)\n for (const { relPath, fromApp } of plainFiles) {\n const segs = relPath.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${importIdRef.value++}_${toVar(modId)}_${toVar(fullSegs.join('_') || 'index')}`\n const appFile = path.join(apiApp, ...fullSegs) + '.ts'\n const plainSegPath = fullSegs.join('/')\n const importPath = `${fromApp ? appImportBase : pkgImportBase}/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\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 methodRoots: ModuleRoots = { appBase: methodDir, pkgBase: methodDir }\n const methodConfig = {\n folder: '',\n include: (name: string) => name.endsWith('.ts') && !/\\.(test|spec)\\.ts$/.test(name),\n }\n const apiFiles = scanModuleDir(methodRoots, methodConfig)\n for (const { relPath } of apiFiles) {\n const segs = relPath.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${importIdRef.value++}_${toVar(modId)}_${toVar(method)}_${toVar(fullSegs.join('_'))}`\n const fromApp = methodDir === appMethodDir\n const importPath = `${fromApp ? appImportBase : pkgImportBase}/api/${method.toLowerCase()}/${fullSegs.join('/')}`\n const metaName = `RM${importIdRef.value++}_${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 return apis\n}\n\nfunction processSubscribers(options: {\n roots: ModuleRoots\n modId: string\n appImportBase: string\n pkgImportBase: string\n imports: string[]\n importIdRef: { value: number }\n}): string[] {\n const { roots, modId, appImportBase, pkgImportBase, imports, importIdRef } = options\n const files = scanModuleDir(roots, SCAN_CONFIGS.subscribers)\n const subscribers: string[] = []\n for (const { relPath, fromApp } of files) {\n const segs = relPath.split('/')\n const file = segs.pop()!\n const name = file.replace(/\\.ts$/, '')\n const importName = `Subscriber${importIdRef.value++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n const metaName = `SubscriberMeta${importIdRef.value++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n const importPath = `${fromApp ? appImportBase : pkgImportBase}/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 return subscribers\n}\n\nasync function processWorkers(options: {\n roots: ModuleRoots\n modId: string\n appImportBase: string\n pkgImportBase: string\n imports: string[]\n importIdRef: { value: number }\n}): Promise<string[]> {\n const { roots, modId, appImportBase, pkgImportBase, imports, importIdRef } = options\n const files = scanModuleDir(roots, SCAN_CONFIGS.workers)\n const workers: string[] = []\n for (const { relPath, fromApp } of files) {\n const segs = relPath.split('/')\n const file = segs.pop()!\n const name = file.replace(/\\.ts$/, '')\n const importPath = `${fromApp ? appImportBase : pkgImportBase}/workers/${[...segs, name].join('/')}`\n if (!(await moduleHasExport(importPath, 'metadata'))) continue\n const importName = `Worker${importIdRef.value++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n const metaName = `WorkerMeta${importIdRef.value++}_${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 return workers\n}\n\nfunction processTranslations(options: {\n roots: ModuleRoots\n modId: string\n appImportBase: string\n pkgImportBase: string\n imports: string[]\n}): string[] {\n const { roots, modId, appImportBase, pkgImportBase, imports } = options\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 const translations: string[] = []\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 '${pkgImportBase}/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 '${pkgImportBase}/i18n/${locale}.json'`)\n translations.push(`'${locale}': ${cName} as unknown as Record<string,string>`)\n }\n }\n return translations\n}\n\n/**\n * Resolves a convention file and pushes its import + config entry to standalone arrays.\n * Used for files that produce their own generated output (notifications, AI tools, events, analytics, enrichers, etc.).\n *\n * @returns The generated import name, or null if the file was not found.\n */\nfunction processStandaloneConfig(options: {\n roots: ModuleRoots\n imps: ModuleImports\n modId: string\n relativePath: string\n prefix: string\n importIdRef: { value: number }\n standaloneImports: string[]\n standaloneConfigs: string[]\n configExpr: (importName: string, modId: string) => string\n /** Also push the import to the shared imports array (used by modules.generated.ts) */\n sharedImports?: string[]\n}): string | null {\n const { roots, imps, modId, relativePath, prefix, importIdRef, standaloneImports, standaloneConfigs, configExpr, sharedImports } = options\n const resolved = resolveModuleFile(roots, imps, relativePath)\n if (!resolved) return null\n const importName = `${prefix}_${toVar(modId)}_${importIdRef.value++}`\n const importStmt = `import * as ${importName} from '${resolved.importPath}'`\n standaloneImports.push(importStmt)\n if (sharedImports) sharedImports.push(importStmt)\n standaloneConfigs.push(configExpr(importName, modId))\n return importName\n}\n\nfunction resolveConventionFile(\n roots: ModuleRoots,\n imps: ModuleImports,\n relativePath: string,\n prefix: string,\n modId: string,\n importIdRef: { value: number },\n imports: string[],\n importStyle: 'namespace' | 'default' = 'namespace'\n): { importName: string; importPath: string; fromApp: boolean } | null {\n const resolved = resolveModuleFile(roots, imps, relativePath)\n if (!resolved) return null\n const importName = `${prefix}_${toVar(modId)}_${importIdRef.value++}`\n if (importStyle === 'default') {\n imports.push(`import ${importName} from '${resolved.importPath}'`)\n } else {\n imports.push(`import * as ${importName} from '${resolved.importPath}'`)\n }\n return { importName, importPath: resolved.importPath, fromApp: resolved.fromApp }\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 const notificationsOutFile = path.join(outputDir, 'notifications.generated.ts')\n const notificationsChecksumFile = path.join(outputDir, 'notifications.generated.checksum')\n const notificationsClientOutFile = path.join(outputDir, 'notifications.client.generated.ts')\n const notificationsClientChecksumFile = path.join(outputDir, 'notifications.client.generated.checksum')\n const messageTypesOutFile = path.join(outputDir, 'message-types.generated.ts')\n const messageTypesChecksumFile = path.join(outputDir, 'message-types.generated.checksum')\n const messageObjectsOutFile = path.join(outputDir, 'message-objects.generated.ts')\n const messageObjectsChecksumFile = path.join(outputDir, 'message-objects.generated.checksum')\n const messagesClientOutFile = path.join(outputDir, 'messages.client.generated.ts')\n const messagesClientChecksumFile = path.join(outputDir, 'messages.client.generated.checksum')\n const aiToolsOutFile = path.join(outputDir, 'ai-tools.generated.ts')\n const aiToolsChecksumFile = path.join(outputDir, 'ai-tools.generated.checksum')\n const eventsOutFile = path.join(outputDir, 'events.generated.ts')\n const eventsChecksumFile = path.join(outputDir, 'events.generated.checksum')\n const analyticsOutFile = path.join(outputDir, 'analytics.generated.ts')\n const analyticsChecksumFile = path.join(outputDir, 'analytics.generated.checksum')\n const transFieldsOutFile = path.join(outputDir, 'translations-fields.generated.ts')\n const transFieldsChecksumFile = path.join(outputDir, 'translations-fields.generated.checksum')\n const enrichersOutFile = path.join(outputDir, 'enrichers.generated.ts')\n const enrichersChecksumFile = path.join(outputDir, 'enrichers.generated.checksum')\n const interceptorsOutFile = path.join(outputDir, 'interceptors.generated.ts')\n const interceptorsChecksumFile = path.join(outputDir, 'interceptors.generated.checksum')\n const componentOverridesOutFile = path.join(outputDir, 'component-overrides.generated.ts')\n const componentOverridesChecksumFile = path.join(outputDir, 'component-overrides.generated.checksum')\n const inboxActionsOutFile = path.join(outputDir, 'inbox-actions.generated.ts')\n const inboxActionsChecksumFile = path.join(outputDir, 'inbox-actions.generated.checksum')\n\n const enabled = resolver.loadEnabledModules()\n const imports: string[] = []\n const moduleDecls: string[] = []\n // Mutable ref so extracted helper functions can increment the shared counter\n const importIdRef = { value: 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 const notificationTypes: string[] = []\n const notificationImports: string[] = []\n const notificationClientTypes: string[] = []\n const notificationClientImports: string[] = []\n const messageTypeEntries: string[] = []\n const messageTypeImports: string[] = []\n const messageObjectTypeEntries: string[] = []\n const messageObjectTypeImports: string[] = []\n const aiToolsConfigs: string[] = []\n const aiToolsImports: string[] = []\n const eventsConfigs: string[] = []\n const eventsImports: string[] = []\n const analyticsConfigs: string[] = []\n const analyticsImports: string[] = []\n const transFieldsConfigs: string[] = []\n const transFieldsImports: string[] = []\n const enricherConfigs: string[] = []\n const enricherImports: string[] = []\n const interceptorConfigs: string[] = []\n const interceptorImports: string[] = []\n const componentOverrideConfigs: string[] = []\n const componentOverrideImports: string[] = []\n const inboxActionsConfigs: string[] = []\n const inboxActionsImports: string[] = []\n\n for (const entry of enabled) {\n const modId = entry.id\n const roots = resolver.getModulePaths(entry)\n const rawImps = resolver.getModuleImportBase(entry)\n trackedRoots.add(roots.appBase)\n trackedRoots.add(roots.pkgBase)\n\n const isAppModule = entry.from === '@app'\n const appImportBase = isAppModule ? `../../src/modules/${modId}` : rawImps.appBase\n const imps: ModuleImports = { appBase: appImportBase, pkgBase: rawImps.pkgBase }\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 eventsImportName: string | null = null\n let analyticsImportName: string | null = null\n let customFieldSetsExpr: string = '[]'\n const dashboardWidgets: string[] = []\n const injectionWidgets: string[] = []\n let injectionTableImportName: string | null = null\n let setupImportName: string | null = null\n\n // === Processing order MUST match original import ID sequence ===\n\n // 1. Module metadata: index.ts (overrideable)\n const appIndex = path.join(roots.appBase, 'index.ts')\n const pkgIndex = path.join(roots.pkgBase, 'index.ts')\n const indexTs = fs.existsSync(appIndex) ? appIndex : fs.existsSync(pkgIndex) ? pkgIndex : null\n if (indexTs) {\n infoImportName = `I${importIdRef.value++}_${toVar(modId)}`\n const importPath = indexTs.startsWith(roots.appBase) ? `${appImportBase}/index` : `${imps.pkgBase}/index`\n imports.push(`import * as ${infoImportName} from '${importPath}'`)\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 // 2. Pages: frontend\n {\n const feApp = path.join(roots.appBase, 'frontend')\n const fePkg = path.join(roots.pkgBase, 'frontend')\n const feFiles = scanModuleDir(roots, SCAN_CONFIGS.frontendPages)\n if (feFiles.length) {\n frontendRoutes.push(...processPageFiles({\n files: feFiles,\n type: 'frontend',\n modId,\n appDir: feApp,\n pkgDir: fePkg,\n appImportBase,\n pkgImportBase: imps.pkgBase,\n imports,\n importIdRef,\n }))\n }\n }\n\n // 3. Entity extensions: data/extensions.ts\n {\n const ext = resolveConventionFile(roots, imps, 'data/extensions.ts', 'X', modId, importIdRef, imports)\n if (ext) extensionsImportName = ext.importName\n }\n\n // 4. RBAC: acl.ts\n {\n const rootApp = path.join(roots.appBase, 'acl.ts')\n const rootPkg = path.join(roots.pkgBase, 'acl.ts')\n const hasRoot = fs.existsSync(rootApp) || fs.existsSync(rootPkg)\n if (hasRoot) {\n const importName = `ACL_${toVar(modId)}_${importIdRef.value++}`\n const useApp = fs.existsSync(rootApp) ? 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 // 5. Custom entities: ce.ts\n {\n const ce = resolveConventionFile(roots, imps, 'ce.ts', 'CE', modId, importIdRef, imports)\n if (ce) customEntitiesImportName = ce.importName\n }\n\n // 6. Search: search.ts\n {\n const resolved = resolveModuleFile(roots, imps, 'search.ts')\n if (resolved) {\n const importName = `SEARCH_${toVar(modId)}_${importIdRef.value++}`\n const importStmt = `import * as ${importName} from '${resolved.importPath}'`\n imports.push(importStmt)\n searchImports.push(importStmt)\n searchImportName = importName\n }\n }\n\n // 7. Notifications: notifications.ts\n processStandaloneConfig({\n roots, imps, modId, importIdRef,\n relativePath: 'notifications.ts',\n prefix: 'NOTIF',\n standaloneImports: notificationImports,\n standaloneConfigs: notificationTypes,\n configExpr: (n, id) => `{ moduleId: '${id}', types: ((${n}.default ?? ${n}.notificationTypes ?? (${n} as any).types ?? []) as NotificationTypeDefinition[]) }`,\n })\n\n // Notification client renderers: notifications.client.ts\n processStandaloneConfig({\n roots, imps, modId, importIdRef,\n relativePath: 'notifications.client.ts',\n prefix: 'NOTIF_CLIENT',\n standaloneImports: notificationClientImports,\n standaloneConfigs: notificationClientTypes,\n configExpr: (n, id) => `{ moduleId: '${id}', types: (${n}.default ?? []) }`,\n })\n // Message types: module root message-types.ts\n {\n const resolved = resolveModuleFile(roots, imps, 'message-types.ts')\n if (resolved) {\n const importName = `MSG_TYPES_${toVar(modId)}_${importIdRef.value++}`\n const importStmt = `import * as ${importName} from '${resolved.importPath}'`\n messageTypeImports.push(importStmt)\n messageTypeEntries.push(\n `{ moduleId: '${modId}', types: ((${importName}.default ?? (${importName} as any).messageTypes ?? (${importName} as any).types ?? []) as MessageTypeDefinition[]) }`\n )\n }\n }\n\n // Message object types: module root message-objects.ts\n {\n const resolved = resolveModuleFile(roots, imps, 'message-objects.ts')\n if (resolved) {\n const importName = `MSG_OBJECTS_${toVar(modId)}_${importIdRef.value++}`\n const importStmt = `import * as ${importName} from '${resolved.importPath}'`\n messageObjectTypeImports.push(importStmt)\n messageObjectTypeEntries.push(\n `{ moduleId: '${modId}', types: ((${importName}.default ?? (${importName} as any).messageObjectTypes ?? (${importName} as any).objectTypes ?? (${importName} as any).types ?? []) as MessageObjectTypeDefinition[]) }`\n )\n }\n }\n\n // AI Tools: module root ai-tools.ts\n {\n const resolved = resolveModuleFile(roots, imps, 'notifications.client.ts')\n if (resolved) {\n const importName = `NOTIF_CLIENT_${toVar(modId)}_${importIdRef.value++}`\n const importStmt = `import * as ${importName} from '${resolved.importPath}'`\n notificationClientImports.push(importStmt)\n notificationClientTypes.push(\n `{ moduleId: '${modId}', types: (${importName}.default ?? []) }`\n )\n }\n }\n\n // 8. AI Tools: ai-tools.ts\n processStandaloneConfig({\n roots, imps, modId, importIdRef,\n relativePath: 'ai-tools.ts',\n prefix: 'AI_TOOLS',\n standaloneImports: aiToolsImports,\n standaloneConfigs: aiToolsConfigs,\n configExpr: (n, id) => `{ moduleId: '${id}', tools: (${n}.aiTools ?? ${n}.default ?? []) }`,\n })\n\n // 9. Events: events.ts (also referenced in module declarations)\n eventsImportName = processStandaloneConfig({\n roots, imps, modId, importIdRef,\n relativePath: 'events.ts',\n prefix: 'EVENTS',\n standaloneImports: eventsImports,\n standaloneConfigs: eventsConfigs,\n sharedImports: imports,\n configExpr: (n, id) => `{ moduleId: '${id}', config: (${n}.default ?? ${n}.eventsConfig ?? null) as EventModuleConfigBase | null }`,\n })\n\n // 10. Analytics: analytics.ts (also referenced in module declarations)\n analyticsImportName = processStandaloneConfig({\n roots, imps, modId, importIdRef,\n relativePath: 'analytics.ts',\n prefix: 'ANALYTICS',\n standaloneImports: analyticsImports,\n standaloneConfigs: analyticsConfigs,\n sharedImports: imports,\n configExpr: (n, id) => `{ moduleId: '${id}', config: (${n}.default ?? ${n}.analyticsConfig ?? ${n}.config ?? null) }`,\n })\n\n // 10b. Enrichers: data/enrichers.ts\n processStandaloneConfig({\n roots, imps, modId, importIdRef,\n relativePath: 'data/enrichers.ts',\n prefix: 'ENRICHERS',\n standaloneImports: enricherImports,\n standaloneConfigs: enricherConfigs,\n configExpr: (n, id) => `{ moduleId: '${id}', enrichers: ((${n} as any).enrichers ?? (${n} as any).default ?? []) }`,\n })\n\n // 10c. API interceptors: api/interceptors.ts\n processStandaloneConfig({\n roots, imps, modId, importIdRef,\n relativePath: 'api/interceptors.ts',\n prefix: 'INTERCEPTORS',\n standaloneImports: interceptorImports,\n standaloneConfigs: interceptorConfigs,\n configExpr: (n, id) => `{ moduleId: '${id}', interceptors: ((${n} as any).interceptors ?? (${n} as any).default ?? []) }`,\n })\n\n // 10d. Component overrides: widgets/components.ts\n processStandaloneConfig({\n roots, imps, modId, importIdRef,\n relativePath: 'widgets/components.ts',\n prefix: 'COMPONENT_OVERRIDES',\n standaloneImports: componentOverrideImports,\n standaloneConfigs: componentOverrideConfigs,\n configExpr: (n, id) => `{ moduleId: '${id}', componentOverrides: ((${n} as any).componentOverrides ?? (${n} as any).default ?? []) }`,\n })\n\n // Translatable fields: translations.ts (also referenced in module declarations)\n let transFieldsImportName: string | null = null\n transFieldsImportName = processStandaloneConfig({\n roots, imps, modId, importIdRef,\n relativePath: 'translations.ts',\n prefix: 'TRANS_FIELDS',\n standaloneImports: transFieldsImports,\n standaloneConfigs: transFieldsConfigs,\n sharedImports: imports,\n configExpr: (n, id) => `{ moduleId: '${id}', fields: (${n}.default ?? ${n}.translatableFields ?? {}) as Record<string, string[]> }`,\n })\n\n // Inbox Actions: inbox-actions.ts\n {\n const resolved = resolveModuleFile(roots, imps, 'inbox-actions.ts')\n if (resolved) {\n const importName = `INBOX_ACTIONS_${toVar(modId)}_${importIdRef.value++}`\n const importStmt = `import * as ${importName} from '${resolved.importPath}'`\n inboxActionsImports.push(importStmt)\n inboxActionsConfigs.push(\n `{ moduleId: '${modId}', actions: (${importName}.default ?? ${importName}.inboxActions ?? []) }`\n )\n }\n }\n\n // 11. Setup: setup.ts\n {\n const setup = resolveConventionFile(roots, imps, 'setup.ts', 'SETUP', modId, importIdRef, imports)\n if (setup) setupImportName = setup.importName\n }\n\n // 12. Custom fields: data/fields.ts\n {\n const fields = resolveConventionFile(roots, imps, 'data/fields.ts', 'F', modId, importIdRef, imports)\n if (fields) fieldsImportName = fields.importName\n }\n\n // 13. Pages: backend\n {\n const beApp = path.join(roots.appBase, 'backend')\n const bePkg = path.join(roots.pkgBase, 'backend')\n const beFiles = scanModuleDir(roots, SCAN_CONFIGS.backendPages)\n if (beFiles.length) {\n backendRoutes.push(...processPageFiles({\n files: beFiles,\n type: 'backend',\n modId,\n appDir: beApp,\n pkgDir: bePkg,\n appImportBase,\n pkgImportBase: imps.pkgBase,\n imports,\n importIdRef,\n }))\n }\n }\n\n // 14. API routes\n apis.push(...await processApiRoutes({\n roots,\n modId,\n appImportBase,\n pkgImportBase: imps.pkgBase,\n imports,\n importIdRef,\n }))\n\n // 15. CLI\n {\n const cliApp = path.join(roots.appBase, 'cli.ts')\n const cliPkg = path.join(roots.pkgBase, 'cli.ts')\n const cliPath = fs.existsSync(cliApp) ? cliApp : fs.existsSync(cliPkg) ? cliPkg : null\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\n // 16. Translations\n translations.push(...processTranslations({\n roots,\n modId,\n appImportBase,\n pkgImportBase: imps.pkgBase,\n imports,\n }))\n\n // 17. Subscribers\n subscribers.push(...processSubscribers({\n roots,\n modId,\n appImportBase,\n pkgImportBase: imps.pkgBase,\n imports,\n importIdRef,\n }))\n\n // 18. Workers\n workers.push(...await processWorkers({\n roots,\n modId,\n appImportBase,\n pkgImportBase: imps.pkgBase,\n imports,\n importIdRef,\n }))\n\n // Build combined customFieldSets expression\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 // 19. Dashboard widgets\n {\n const entries = scanDashboardWidgetEntries({\n modId,\n roots,\n appImportBase,\n pkgImportBase: imps.pkgBase,\n })\n for (const entry of entries) {\n dashboardWidgets.push(\n `{ moduleId: '${entry.moduleId}', key: '${entry.key}', source: '${entry.source}', loader: () => import('${entry.importPath}').then((mod) => mod.default ?? mod) }`\n )\n const existing = allDashboardWidgets.get(entry.key)\n if (!existing || (existing.source !== 'app' && entry.source === 'app')) {\n allDashboardWidgets.set(entry.key, {\n moduleId: entry.moduleId,\n source: entry.source,\n importPath: entry.importPath,\n })\n }\n }\n }\n\n // 20. Injection widgets\n {\n const files = scanModuleDir(roots, SCAN_CONFIGS.injectionWidgets)\n const widgetApp = path.join(roots.appBase, 'widgets', 'injection')\n for (const { relPath, fromApp } of files) {\n const segs = relPath.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 // 21. Injection table\n {\n const resolved = resolveModuleFile(roots, imps, 'widgets/injection-table.ts')\n if (resolved) {\n const importName = `InjTable_${toVar(modId)}_${importIdRef.value++}`\n imports.push(`import * as ${importName} from '${resolved.importPath}'`)\n injectionTableImportName = importName\n allInjectionTables.push({ moduleId: modId, importPath: resolved.importPath, importName })\n }\n }\n\n if (searchImportName) {\n searchConfigs.push(`{ moduleId: '${modId}', config: (${searchImportName}.default ?? ${searchImportName}.searchConfig ?? ${searchImportName}.config ?? null) }`)\n }\n\n // Note: events, analytics, enrichers, notifications, AI tools, and translatable fields\n // configs are pushed inside processStandaloneConfig() above \u2014 no separate push needed here.\n\n if (transFieldsImportName) {\n transFieldsConfigs.push(`{ moduleId: '${modId}', fields: (${transFieldsImportName}.default ?? ${transFieldsImportName}.translatableFields ?? {}) as Record<string, string[]> }`)\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 ${setupImportName ? `setup: (${setupImportName}.default ?? ${setupImportName}.setup) || undefined,` : ''}\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 const eventsEntriesLiteral = eventsConfigs.join(',\\n ')\n const eventsImportSection = eventsImports.join('\\n')\n const eventsOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { EventModuleConfigBase, EventDefinition } from '@open-mercato/shared/modules/events'\n${eventsImportSection ? `\\n${eventsImportSection}\\n` : '\\n'}type EventConfigEntry = { moduleId: string; config: EventModuleConfigBase | null }\n\nconst entriesRaw: EventConfigEntry[] = [\n${eventsEntriesLiteral ? ` ${eventsEntriesLiteral}\\n` : ''}]\nconst entries = entriesRaw.filter((e): e is { moduleId: string; config: EventModuleConfigBase } => e.config != null)\n\nexport const eventModuleConfigEntries = entries\nexport const eventModuleConfigs: EventModuleConfigBase[] = entries.map((e) => e.config)\nexport const allEvents: EventDefinition[] = entries.flatMap((e) => e.config.events)\n\n// Runtime registry for validation\nconst allDeclaredEventIds = new Set(allEvents.map((e) => e.id))\nexport function isEventDeclared(eventId: string): boolean {\n return allDeclaredEventIds.has(eventId)\n}\n`\n\n const analyticsEntriesLiteral = analyticsConfigs.join(',\\n ')\n const analyticsImportSection = analyticsImports.join('\\n')\n const analyticsOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { AnalyticsModuleConfig } from '@open-mercato/shared/modules/analytics'\n${analyticsImportSection ? `\\n${analyticsImportSection}\\n` : '\\n'}type AnalyticsConfigEntry = { moduleId: string; config: AnalyticsModuleConfig | null }\n\nconst entriesRaw: AnalyticsConfigEntry[] = [\n${analyticsEntriesLiteral ? ` ${analyticsEntriesLiteral}\\n` : ''}]\nconst entries = entriesRaw.filter((entry): entry is { moduleId: string; config: AnalyticsModuleConfig } => entry.config != null)\n\nexport const analyticsModuleConfigEntries = entries\nexport const analyticsModuleConfigs: AnalyticsModuleConfig[] = entries.map((entry) => entry.config)\n`\n\n const transFieldsEntriesLiteral = transFieldsConfigs.join(',\\n ')\n const transFieldsImportSection = transFieldsImports.join('\\n')\n const transFieldsOutput = `// AUTO-GENERATED by mercato generate registry\nimport { registerTranslatableFields } from '@open-mercato/shared/lib/localization/translatable-fields'\n${transFieldsImportSection ? `\\n${transFieldsImportSection}\\n` : '\\n'}type TransFieldsEntry = { moduleId: string; fields: Record<string, string[]> }\n\nconst entries: TransFieldsEntry[] = [\n${transFieldsEntriesLiteral ? ` ${transFieldsEntriesLiteral}\\n` : ''}]\n\nconst allFields: Record<string, string[]> = {}\nfor (const entry of entries) {\n for (const [key, value] of Object.entries(entry.fields)) {\n allFields[key] = value\n }\n}\n\nexport const translatableFieldEntries = entries\nexport const allTranslatableFields = allFields\nexport const allTranslatableEntityTypes = Object.keys(allFields)\n\n// Auto-register on import (side-effect)\nregisterTranslatableFields(allFields)\n`\n\n const notificationEntriesLiteral = notificationTypes.join(',\\n ')\n const notificationImportSection = notificationImports.join('\\n')\n const notificationsOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { NotificationTypeDefinition } from '@open-mercato/shared/modules/notifications/types'\n${notificationImportSection ? `\\n${notificationImportSection}\\n` : '\\n'}type NotificationTypeEntry = { moduleId: string; types: NotificationTypeDefinition[] }\n\nconst entriesRaw: NotificationTypeEntry[] = [\n${notificationEntriesLiteral ? ` ${notificationEntriesLiteral}\\n` : ''}]\n\nconst allTypes = entriesRaw.flatMap((entry) => entry.types)\n\nexport const notificationTypeEntries = entriesRaw\nexport const notificationTypes = allTypes\n\nexport function getNotificationTypes(): NotificationTypeDefinition[] {\n return allTypes\n}\n\nexport function getNotificationType(type: string): NotificationTypeDefinition | undefined {\n return allTypes.find((t) => t.type === type)\n}\n`\n const notificationClientEntriesLiteral = notificationClientTypes.join(',\\n ')\n const notificationClientImportSection = notificationClientImports.join('\\n')\n const notificationsClientOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { ComponentType } from 'react'\nimport type { NotificationTypeDefinition, NotificationRendererProps } from '@open-mercato/shared/modules/notifications/types'\n${notificationClientImportSection ? `\\n${notificationClientImportSection}\\n` : '\\n'}type NotificationTypeEntry = { moduleId: string; types: NotificationTypeDefinition[] }\nexport type NotificationRenderers = Record<string, ComponentType<NotificationRendererProps>>\n\nconst entriesRaw: NotificationTypeEntry[] = [\n${notificationClientEntriesLiteral ? ` ${notificationClientEntriesLiteral}\\n` : ''}]\n\nconst allTypes = entriesRaw.flatMap((entry) => entry.types)\nconst renderers: NotificationRenderers = Object.fromEntries(\n allTypes\n .filter((typeDef) => Boolean(typeDef.Renderer))\n .map((typeDef) => [typeDef.type, typeDef.Renderer!]),\n)\n\nexport const notificationClientTypeEntries = entriesRaw\nexport const notificationClientTypes = allTypes\nexport const notificationRenderers = renderers\n\nexport function getNotificationRenderers(): NotificationRenderers {\n return renderers\n}\n`\n\n const messageTypeEntriesLiteral = messageTypeEntries.join(',\\n ')\n const messageTypeImportSection = messageTypeImports.join('\\n')\n const messageTypesOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { MessageTypeDefinition } from '@open-mercato/shared/modules/messages/types'\n${messageTypeImportSection ? `\\n${messageTypeImportSection}\\n` : '\\n'}type MessageTypeEntry = { moduleId: string; types: MessageTypeDefinition[] }\n\nconst entriesRaw: MessageTypeEntry[] = [\n${messageTypeEntriesLiteral ? ` ${messageTypeEntriesLiteral}\\n` : ''}]\n\nconst allTypes = entriesRaw.flatMap((entry) => entry.types)\n\nexport const messageTypeEntries = entriesRaw\nexport const messageTypes = allTypes\n\nexport function getMessageTypes(): MessageTypeDefinition[] {\n return allTypes\n}\n\nexport function getMessageType(type: string): MessageTypeDefinition | undefined {\n return allTypes.find((entry) => entry.type === type)\n}\n`\n\n const messageObjectEntriesLiteral = messageObjectTypeEntries.join(',\\n ')\n const messageObjectImportSection = messageObjectTypeImports.join('\\n')\n const messageObjectsOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { MessageObjectTypeDefinition } from '@open-mercato/shared/modules/messages/types'\n${messageObjectImportSection ? `\\n${messageObjectImportSection}\\n` : '\\n'}type MessageObjectTypeEntry = { moduleId: string; types: MessageObjectTypeDefinition[] }\n\nconst entriesRaw: MessageObjectTypeEntry[] = [\n${messageObjectEntriesLiteral ? ` ${messageObjectEntriesLiteral}\\n` : ''}]\n\nconst allTypes = entriesRaw.flatMap((entry) => entry.types)\n\nexport const messageObjectTypeEntries = entriesRaw\nexport const messageObjectTypes = allTypes\n\nexport function getMessageObjectTypes(): MessageObjectTypeDefinition[] {\n return allTypes\n}\n\nexport function getMessageObjectType(module: string, entityType: string): MessageObjectTypeDefinition | undefined {\n return allTypes.find((entry) => entry.module === module && entry.entityType === entityType)\n}\n`\n const messagesClientOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { ComponentType } from 'react'\nimport type {\n MessageTypeDefinition,\n MessageObjectTypeDefinition,\n MessageListItemProps,\n MessageContentProps,\n MessageActionsProps,\n ObjectDetailProps,\n ObjectPreviewProps,\n} from '@open-mercato/shared/modules/messages/types'\nimport { registerMessageObjectTypes } from '@open-mercato/core/modules/messages/lib/message-objects-registry'\nimport { configureMessageUiComponentRegistry } from '@open-mercato/core/modules/messages/components/utils/typeUiRegistry'\n${messageTypeImportSection ? `\\n${messageTypeImportSection}\\n` : '\\n'}${messageObjectImportSection ? `\\n${messageObjectImportSection}\\n` : ''}type MessageTypeEntry = { moduleId: string; types: MessageTypeDefinition[] }\ntype MessageObjectTypeEntry = { moduleId: string; types: MessageObjectTypeDefinition[] }\n\nexport type MessageListItemRenderers = Record<string, ComponentType<MessageListItemProps>>\nexport type MessageContentRenderers = Record<string, ComponentType<MessageContentProps>>\nexport type MessageActionsRenderers = Record<string, ComponentType<MessageActionsProps>>\nexport type MessageObjectDetailRenderers = Record<string, ComponentType<ObjectDetailProps>>\nexport type MessageObjectPreviewRenderers = Record<string, ComponentType<ObjectPreviewProps>>\n\nexport type MessageUiComponentRegistry = {\n listItemComponents: MessageListItemRenderers\n contentComponents: MessageContentRenderers\n actionsComponents: MessageActionsRenderers\n objectDetailComponents: MessageObjectDetailRenderers\n objectPreviewComponents: MessageObjectPreviewRenderers\n}\n\nconst messageTypeEntriesRaw: MessageTypeEntry[] = [\n${messageTypeEntriesLiteral ? ` ${messageTypeEntriesLiteral}\\n` : ''}]\nconst messageObjectTypeEntriesRaw: MessageObjectTypeEntry[] = [\n${messageObjectEntriesLiteral ? ` ${messageObjectEntriesLiteral}\\n` : ''}]\n\nconst allMessageTypes = messageTypeEntriesRaw.flatMap((entry) => entry.types)\nconst allMessageObjectTypes = messageObjectTypeEntriesRaw.flatMap((entry) => entry.types)\n\nconst listItemComponents: MessageListItemRenderers = Object.fromEntries(\n allMessageTypes\n .filter((typeDef) => Boolean(typeDef.ui?.listItemComponent) && Boolean(typeDef.ListItemComponent))\n .map((typeDef) => [typeDef.ui!.listItemComponent!, typeDef.ListItemComponent!]),\n)\n\nconst contentComponents: MessageContentRenderers = Object.fromEntries(\n allMessageTypes\n .filter((typeDef) => Boolean(typeDef.ui?.contentComponent) && Boolean(typeDef.ContentComponent))\n .map((typeDef) => [typeDef.ui!.contentComponent!, typeDef.ContentComponent!]),\n)\n\nconst actionsComponents: MessageActionsRenderers = Object.fromEntries(\n allMessageTypes\n .filter((typeDef) => Boolean(typeDef.ui?.actionsComponent) && Boolean(typeDef.ActionsComponent))\n .map((typeDef) => [typeDef.ui!.actionsComponent!, typeDef.ActionsComponent!]),\n)\n\nconst objectDetailComponents: MessageObjectDetailRenderers = Object.fromEntries(\n allMessageObjectTypes\n .filter((typeDef) => Boolean(typeDef.DetailComponent))\n .map((typeDef) => [\\`\\${typeDef.module}:\\${typeDef.entityType}\\`, typeDef.DetailComponent!]),\n)\n\nconst objectPreviewComponents: MessageObjectPreviewRenderers = Object.fromEntries(\n allMessageObjectTypes\n .filter((typeDef) => Boolean(typeDef.PreviewComponent))\n .map((typeDef) => [\\`\\${typeDef.module}:\\${typeDef.entityType}\\`, typeDef.PreviewComponent!]),\n)\n\nconst registry: MessageUiComponentRegistry = {\n listItemComponents,\n contentComponents,\n actionsComponents,\n objectDetailComponents,\n objectPreviewComponents,\n}\n\nexport const messageClientTypeEntries = messageTypeEntriesRaw\nexport const messageClientObjectTypeEntries = messageObjectTypeEntriesRaw\nexport const messageUiComponentRegistry = registry\n\nexport function getMessageUiComponentRegistry(): MessageUiComponentRegistry {\n return registry\n}\n\n// Side-effects: register all message object types and configure the UI component registry on import.\nfor (const entry of messageObjectTypeEntriesRaw) {\n registerMessageObjectTypes(entry.types)\n}\nconfigureMessageUiComponentRegistry(registry)\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([\n ...Array.from(trackedRoots),\n ])\n\n writeGeneratedFile({ outFile, checksumFile, content: output, structureChecksum, result, quiet })\n writeGeneratedFile({ outFile: widgetsOutFile, checksumFile: widgetsChecksumFile, content: widgetsOutput, structureChecksum, result, quiet })\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 writeGeneratedFile({ outFile: injectionWidgetsOutFile, checksumFile: injectionWidgetsChecksumFile, content: injectionWidgetsOutput, structureChecksum, result, quiet })\n writeGeneratedFile({ outFile: injectionTablesOutFile, checksumFile: injectionTablesChecksumFile, content: injectionTablesOutput, structureChecksum, result, quiet })\n writeGeneratedFile({ outFile: searchOutFile, checksumFile: searchChecksumFile, content: searchOutput, structureChecksum, result, quiet })\n\n // AI Tools generated file\n const aiToolsOutput = `// AUTO-GENERATED by mercato generate registry\n${aiToolsImports.length ? aiToolsImports.join('\\n') + '\\n' : ''}\ntype AiToolConfigEntry = { moduleId: string; tools: unknown[] }\n\nexport const aiToolConfigEntries: AiToolConfigEntry[] = [\n${aiToolsConfigs.length ? ' ' + aiToolsConfigs.join(',\\n ') + '\\n' : ''}].filter(e => Array.isArray(e.tools) && e.tools.length > 0)\n\nexport const allAiTools = aiToolConfigEntries.flatMap(e => e.tools)\n`\n writeGeneratedFile({ outFile: aiToolsOutFile, checksumFile: aiToolsChecksumFile, content: aiToolsOutput, structureChecksum, result, quiet })\n writeGeneratedFile({ outFile: notificationsOutFile, checksumFile: notificationsChecksumFile, content: notificationsOutput, structureChecksum, result, quiet })\n writeGeneratedFile({ outFile: notificationsClientOutFile, checksumFile: notificationsClientChecksumFile, content: notificationsClientOutput, structureChecksum, result, quiet })\n writeGeneratedFile({ outFile: messageTypesOutFile, checksumFile: messageTypesChecksumFile, content: messageTypesOutput, structureChecksum, result, quiet })\n writeGeneratedFile({ outFile: messageObjectsOutFile, checksumFile: messageObjectsChecksumFile, content: messageObjectsOutput, structureChecksum, result, quiet })\n writeGeneratedFile({ outFile: messagesClientOutFile, checksumFile: messagesClientChecksumFile, content: messagesClientOutput, structureChecksum, result, quiet })\n writeGeneratedFile({ outFile: eventsOutFile, checksumFile: eventsChecksumFile, content: eventsOutput, structureChecksum, result, quiet })\n writeGeneratedFile({ outFile: analyticsOutFile, checksumFile: analyticsChecksumFile, content: analyticsOutput, structureChecksum, result, quiet })\n writeGeneratedFile({ outFile: transFieldsOutFile, checksumFile: transFieldsChecksumFile, content: transFieldsOutput, structureChecksum, result, quiet })\n\n // Enrichers generated file\n const enricherEntriesLiteral = enricherConfigs.join(',\\n ')\n const enricherImportSection = enricherImports.join('\\n')\n const enrichersOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { ResponseEnricher } from '@open-mercato/shared/lib/crud/response-enricher'\n${enricherImportSection ? `\\n${enricherImportSection}\\n` : '\\n'}type EnricherEntry = { moduleId: string; enrichers: ResponseEnricher[] }\n\nexport const enricherEntries: EnricherEntry[] = [\n${enricherEntriesLiteral ? ` ${enricherEntriesLiteral}\\n` : ''}]\n`\n writeGeneratedFile({ outFile: enrichersOutFile, checksumFile: enrichersChecksumFile, content: enrichersOutput, structureChecksum, result, quiet })\n // Inbox Actions generated file\n const inboxActionsEntriesLiteral = inboxActionsConfigs.join(',\\n ')\n const inboxActionsImportSection = inboxActionsImports.join('\\n')\n const inboxActionsOutput = `// AUTO-GENERATED by mercato generate registry \u2014 do not edit\nimport type { InboxActionDefinition } from '@open-mercato/shared/modules/inbox-actions'\n${inboxActionsImportSection ? `\\n${inboxActionsImportSection}\\n` : '\\n'}\ntype InboxActionConfigEntry = { moduleId: string; actions: InboxActionDefinition[] }\n\nconst entriesRaw: InboxActionConfigEntry[] = [\n${inboxActionsEntriesLiteral ? ` ${inboxActionsEntriesLiteral}\\n` : ''}]\n\nconst entries = entriesRaw.filter((e): e is InboxActionConfigEntry => Array.isArray(e.actions) && e.actions.length > 0)\n\nexport const inboxActionConfigEntries = entries\nexport const inboxActions: InboxActionDefinition[] = entries.flatMap((e) => e.actions)\n\nconst actionTypeMap = new Map(inboxActions.map((a) => [a.type, a]))\nexport function getInboxAction(type: string): InboxActionDefinition | undefined {\n return actionTypeMap.get(type)\n}\nexport function getRegisteredActionTypes(): string[] {\n return Array.from(actionTypeMap.keys())\n}\n`\n writeGeneratedFile({ outFile: inboxActionsOutFile, checksumFile: inboxActionsChecksumFile, content: inboxActionsOutput, structureChecksum, result, quiet })\n\n const interceptorEntriesLiteral = interceptorConfigs.join(',\\n ')\n const interceptorImportSection = interceptorImports.join('\\n')\n const interceptorsOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { ApiInterceptor } from '@open-mercato/shared/lib/crud/api-interceptor'\n${interceptorImportSection ? `\\n${interceptorImportSection}\\n` : '\\n'}type InterceptorEntry = { moduleId: string; interceptors: ApiInterceptor[] }\n\nexport const interceptorEntries: InterceptorEntry[] = [\n${interceptorEntriesLiteral ? ` ${interceptorEntriesLiteral}\\n` : ''}]\n`\n writeGeneratedFile({ outFile: interceptorsOutFile, checksumFile: interceptorsChecksumFile, content: interceptorsOutput, structureChecksum, result, quiet })\n\n const componentOverrideEntriesLiteral = componentOverrideConfigs.join(',\\n ')\n const componentOverrideImportSection = componentOverrideImports.join('\\n')\n const componentOverridesOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { ComponentOverride } from '@open-mercato/shared/modules/widgets/component-registry'\n${componentOverrideImportSection ? `\\n${componentOverrideImportSection}\\n` : '\\n'}type ComponentOverrideEntry = { moduleId: string; componentOverrides: ComponentOverride[] }\n\nexport const componentOverrideEntries: ComponentOverrideEntry[] = [\n${componentOverrideEntriesLiteral ? ` ${componentOverrideEntriesLiteral}\\n` : ''}]\n`\n writeGeneratedFile({\n outFile: componentOverridesOutFile,\n checksumFile: componentOverridesChecksumFile,\n content: componentOverridesOutput,\n structureChecksum,\n result,\n quiet,\n })\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, dashboard widgets\n * Excludes: frontend routes, backend routes, API handlers, 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 // Mutable ref so extracted helper functions can increment the shared counter\n const importIdRef = { value: 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 rawImps = resolver.getModuleImportBase(entry)\n trackedRoots.add(roots.appBase)\n trackedRoots.add(roots.pkgBase)\n\n const isAppModule = entry.from === '@app'\n const appImportBase = isAppModule ? `../../src/modules/${modId}` : rawImps.appBase\n const imps: ModuleImports = { appBase: appImportBase, pkgBase: rawImps.pkgBase }\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 const dashboardWidgets: string[] = []\n let setupImportName: string | null = null\n let customFieldSetsExpr: string = '[]'\n\n // Module metadata: index.ts (overrideable)\n const appIndex = path.join(roots.appBase, 'index.ts')\n const pkgIndex = path.join(roots.pkgBase, 'index.ts')\n const indexTs = fs.existsSync(appIndex) ? appIndex : fs.existsSync(pkgIndex) ? pkgIndex : null\n if (indexTs) {\n infoImportName = `I${importIdRef.value++}_${toVar(modId)}`\n const importPath = indexTs.startsWith(roots.appBase) ? `${appImportBase}/index` : `${imps.pkgBase}/index`\n imports.push(`import * as ${infoImportName} from '${importPath}'`)\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 // Module setup configuration: setup.ts\n {\n const setup = resolveConventionFile(roots, imps, 'setup.ts', 'SETUP', modId, importIdRef, imports)\n if (setup) setupImportName = setup.importName\n }\n\n // Entity extensions: data/extensions.ts\n {\n const ext = resolveConventionFile(roots, imps, 'data/extensions.ts', 'X', modId, importIdRef, imports)\n if (ext) extensionsImportName = ext.importName\n }\n\n // RBAC: acl.ts\n {\n const rootApp = path.join(roots.appBase, 'acl.ts')\n const rootPkg = path.join(roots.pkgBase, 'acl.ts')\n const hasRoot = fs.existsSync(rootApp) || fs.existsSync(rootPkg)\n if (hasRoot) {\n const importName = `ACL_${toVar(modId)}_${importIdRef.value++}`\n const useApp = fs.existsSync(rootApp) ? 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: ce.ts\n {\n const ce = resolveConventionFile(roots, imps, 'ce.ts', 'CE', modId, importIdRef, imports)\n if (ce) customEntitiesImportName = ce.importName\n }\n\n // Vector search configuration: vector.ts\n {\n const vec = resolveConventionFile(roots, imps, 'vector.ts', 'VECTOR', modId, importIdRef, imports)\n if (vec) vectorImportName = vec.importName\n }\n\n // Custom fields: data/fields.ts\n {\n const fields = resolveConventionFile(roots, imps, 'data/fields.ts', 'F', modId, importIdRef, imports)\n if (fields) fieldsImportName = fields.importName\n }\n\n // CLI\n {\n const cliApp = path.join(roots.appBase, 'cli.ts')\n const cliPkg = path.join(roots.pkgBase, 'cli.ts')\n const cliPath = fs.existsSync(cliApp) ? cliApp : fs.existsSync(cliPkg) ? cliPkg : null\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\n // Translations\n translations.push(...processTranslations({\n roots,\n modId,\n appImportBase,\n pkgImportBase: imps.pkgBase,\n imports,\n }))\n\n // Subscribers\n subscribers.push(...processSubscribers({\n roots,\n modId,\n appImportBase,\n pkgImportBase: imps.pkgBase,\n imports,\n importIdRef,\n }))\n\n // Workers\n workers.push(...await processWorkers({\n roots,\n modId,\n appImportBase,\n pkgImportBase: imps.pkgBase,\n imports,\n importIdRef,\n }))\n\n // Build combined customFieldSets expression\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\n {\n const entries = scanDashboardWidgetEntries({\n modId,\n roots,\n appImportBase,\n pkgImportBase: imps.pkgBase,\n })\n for (const entry of entries) {\n dashboardWidgets.push(\n `{ moduleId: '${entry.moduleId}', key: '${entry.key}', source: '${entry.source}', loader: () => import('${entry.importPath}').then((mod) => mod.default ?? mod) }`\n )\n }\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 ${dashboardWidgets.length ? `dashboardWidgets: [${dashboardWidgets.join(', ')}],` : ''}\n ${vectorImportName ? `vector: (${vectorImportName}.default ?? ${vectorImportName}.vectorConfig ?? ${vectorImportName}.config ?? undefined),` : ''}\n ${setupImportName ? `setup: (${setupImportName}.default ?? ${setupImportName}.setup) || 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, injection 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 writeGeneratedFile({ outFile, checksumFile, content: output, structureChecksum, result, quiet })\n\n return result\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAEjB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAgBP,SAAS,2BAA2B,SAKT;AACzB,QAAM,EAAE,OAAO,OAAO,eAAe,cAAc,IAAI;AACvD,QAAM,QAAQ,cAAc,OAAO,aAAa,gBAAgB;AAChE,SAAO,MAAM,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;AAAA,MACxG;AAAA,EACJ;AAEA,QAAM,SAAS;AAAA;AAAA;AAAA,EAGf,QAAQ,KAAK,IAAI,CAAC;AAAA;AAAA;AAAA,IAGhB,YAAY,KAAK,OAAO,CAAC;AAAA;AAAA;AAAA;AAAA;AAO3B;AACE,UAAM,aAAa,IAAI,IAAI,QAAQ,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;AACnD,UAAM,WAAqB,CAAC;AAC5B,eAAW,CAAC,OAAO,IAAI,KAAK,iBAAiB,QAAQ,GAAG;AACtD,YAAM,UAAU,KAAK,OAAO,CAAC,MAAM,CAAC,WAAW,IAAI,CAAC,CAAC;AACrD,UAAI,QAAQ,QAAQ;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;AAC7E,qBAAmB,EAAE,SAAS,cAAc,SAAS,QAAQ,mBAAmB,QAAQ,MAAM,CAAC;AAE/F,SAAO;AACT;",
|
|
4
|
+
"sourcesContent": ["import fs from 'node:fs'\nimport path from 'node:path'\nimport type { PackageResolver } from '../resolver'\nimport {\n calculateStructureChecksum,\n toVar,\n moduleHasExport,\n type GeneratorResult,\n createGeneratorResult,\n writeGeneratedFile,\n} from '../utils'\nimport {\n scanModuleDir,\n resolveModuleFile,\n SCAN_CONFIGS,\n type ModuleRoots,\n type ModuleImports,\n} from './scanner'\n\ntype HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'\n\nexport interface ModuleRegistryOptions {\n resolver: PackageResolver\n quiet?: boolean\n}\n\ntype DashboardWidgetEntry = {\n moduleId: string\n key: string\n source: 'app' | 'package'\n importPath: string\n}\n\nfunction scanDashboardWidgetEntries(options: {\n modId: string\n roots: ModuleRoots\n appImportBase: string\n pkgImportBase: string\n}): DashboardWidgetEntry[] {\n const { modId, roots, appImportBase, pkgImportBase } = options\n const files = scanModuleDir(roots, SCAN_CONFIGS.dashboardWidgets)\n return files.map(({ relPath, fromApp }) => {\n const segs = relPath.split('/')\n const file = segs.pop()!\n const base = file.replace(/\\.(t|j)sx?$/, '')\n const importPath = `${fromApp ? appImportBase : pkgImportBase}/widgets/dashboard/${[...segs, base].join('/')}`\n const key = [modId, ...segs, base].filter(Boolean).join(':')\n const source = fromApp ? 'app' : 'package'\n return { moduleId: modId, key, source, importPath }\n })\n}\n\nfunction processPageFiles(options: {\n files: Array<{ relPath: string; fromApp: boolean }>\n type: 'frontend' | 'backend'\n modId: string\n appDir: string\n pkgDir: string\n appImportBase: string\n pkgImportBase: string\n imports: string[]\n importIdRef: { value: number }\n}): string[] {\n const { files, type, modId, appDir, pkgDir, appImportBase, pkgImportBase, imports, importIdRef } = options\n const prefix = type === 'frontend' ? 'C' : 'B'\n const modPrefix = type === 'frontend' ? 'CM' : 'BM'\n const metaPrefix = type === 'frontend' ? 'M' : 'BM'\n const routes: string[] = []\n\n // Next-style page.tsx files\n for (const { relPath, fromApp } of files.filter(({ relPath: f }) => f.endsWith('/page.tsx') || f === 'page.tsx')) {\n const segs = relPath.split('/')\n segs.pop()\n const importName = `${prefix}${importIdRef.value++}_${toVar(modId)}_${toVar(segs.join('_') || 'index')}`\n const pageModName = `${modPrefix}${importIdRef.value++}_${toVar(modId)}_${toVar(segs.join('_') || 'index')}`\n const sub = segs.length ? `${segs.join('/')}/page` : 'page'\n const importPath = `${fromApp ? appImportBase : pkgImportBase}/${type}/${sub}`\n const routePath = type === 'frontend'\n ? '/' + (segs.join('/') || '')\n : '/backend/' + (segs.join('/') || modId)\n const metaCandidates = [\n path.join(fromApp ? appDir : pkgDir, ...segs, 'page.meta.ts'),\n path.join(fromApp ? appDir : pkgDir, ...segs, 'meta.ts'),\n ]\n const metaPath = metaCandidates.find((p) => fs.existsSync(p))\n let metaExpr = 'undefined'\n if (metaPath) {\n const metaImportName = `${metaPrefix}${importIdRef.value++}_${toVar(modId)}_${toVar(segs.join('_') || 'index')}`\n const metaImportPath = `${fromApp ? appImportBase : pkgImportBase}/${type}/${[...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 const baseProps = `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`\n const extraProps = type === 'backend' ? `, pageContext: (${metaExpr})?.pageContext` : ''\n routes.push(`{ ${baseProps}${extraProps}, Component: ${importName} }`)\n }\n\n // Back-compat direct files (old-style pages like login.tsx instead of login/page.tsx)\n for (const { relPath, fromApp } of files.filter(({ relPath: f }) => !f.endsWith('/page.tsx') && f !== 'page.tsx')) {\n const segs = relPath.split('/')\n const file = segs.pop()!\n const name = file.replace(/\\.tsx$/, '')\n const routeSegs = [...segs, name].filter(Boolean)\n const importName = `${prefix}${importIdRef.value++}_${toVar(modId)}_${toVar(routeSegs.join('_') || 'index')}`\n const pageModName = `${modPrefix}${importIdRef.value++}_${toVar(modId)}_${toVar(routeSegs.join('_') || 'index')}`\n const importPath = `${fromApp ? appImportBase : pkgImportBase}/${type}/${[...segs, name].join('/')}`\n const routePath = type === 'frontend'\n ? '/' + (routeSegs.join('/') || '')\n : '/backend/' + [modId, ...segs, name].filter(Boolean).join('/')\n const metaCandidates = [\n path.join(fromApp ? appDir : pkgDir, ...segs, `${name}.meta.ts`),\n path.join(fromApp ? appDir : pkgDir, ...segs, 'meta.ts'),\n ]\n const metaPath = metaCandidates.find((p) => fs.existsSync(p))\n let metaExpr = 'undefined'\n if (metaPath) {\n const metaImportName = `${metaPrefix}${importIdRef.value++}_${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 : pkgImportBase}/${type}/${[...segs, metaImportSub].join('/')}`\n imports.push(`import * as ${metaImportName} from '${metaImportPath}'`)\n metaExpr = type === 'frontend' ? `(${metaImportName}.metadata as any)` : `${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 const baseProps = `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`\n const extraFe = type === 'frontend' ? `, visible: (${metaExpr})?.visible, enabled: (${metaExpr})?.enabled` : `, 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, pageContext: (${metaExpr})?.pageContext`\n routes.push(`{ ${baseProps}${extraFe}, Component: ${importName} }`)\n }\n\n return routes\n}\n\nasync function processApiRoutes(options: {\n roots: ModuleRoots\n modId: string\n appImportBase: string\n pkgImportBase: string\n imports: string[]\n importIdRef: { value: number }\n}): Promise<string[]> {\n const { roots, modId, appImportBase, pkgImportBase, imports, importIdRef } = options\n const apiApp = path.join(roots.appBase, 'api')\n const apiPkg = path.join(roots.pkgBase, 'api')\n if (!fs.existsSync(apiApp) && !fs.existsSync(apiPkg)) return []\n\n const apis: string[] = []\n\n // route.ts aggregations\n const routeFiles = scanModuleDir(roots, SCAN_CONFIGS.apiRoutes)\n for (const { relPath, fromApp } of routeFiles) {\n const segs = relPath.split('/')\n segs.pop()\n const reqSegs = [modId, ...segs]\n const importName = `R${importIdRef.value++}_${toVar(modId)}_${toVar(segs.join('_') || 'index')}`\n const appFile = path.join(apiApp, ...segs, 'route.ts')\n const apiSegPath = segs.join('/')\n const importPath = `${fromApp ? appImportBase : pkgImportBase}/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 (plain .ts, not route.ts, not tests, skip method dirs)\n const plainFiles = scanModuleDir(roots, SCAN_CONFIGS.apiPlainFiles)\n for (const { relPath, fromApp } of plainFiles) {\n const segs = relPath.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${importIdRef.value++}_${toVar(modId)}_${toVar(fullSegs.join('_') || 'index')}`\n const appFile = path.join(apiApp, ...fullSegs) + '.ts'\n const plainSegPath = fullSegs.join('/')\n const importPath = `${fromApp ? appImportBase : pkgImportBase}/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\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 methodRoots: ModuleRoots = { appBase: methodDir, pkgBase: methodDir }\n const methodConfig = {\n folder: '',\n include: (name: string) => name.endsWith('.ts') && !/\\.(test|spec)\\.ts$/.test(name),\n }\n const apiFiles = scanModuleDir(methodRoots, methodConfig)\n for (const { relPath } of apiFiles) {\n const segs = relPath.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${importIdRef.value++}_${toVar(modId)}_${toVar(method)}_${toVar(fullSegs.join('_'))}`\n const fromApp = methodDir === appMethodDir\n const importPath = `${fromApp ? appImportBase : pkgImportBase}/api/${method.toLowerCase()}/${fullSegs.join('/')}`\n const metaName = `RM${importIdRef.value++}_${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 return apis\n}\n\nfunction processSubscribers(options: {\n roots: ModuleRoots\n modId: string\n appImportBase: string\n pkgImportBase: string\n imports: string[]\n importIdRef: { value: number }\n}): string[] {\n const { roots, modId, appImportBase, pkgImportBase, imports, importIdRef } = options\n const files = scanModuleDir(roots, SCAN_CONFIGS.subscribers)\n const subscribers: string[] = []\n for (const { relPath, fromApp } of files) {\n const segs = relPath.split('/')\n const file = segs.pop()!\n const name = file.replace(/\\.ts$/, '')\n const importName = `Subscriber${importIdRef.value++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n const metaName = `SubscriberMeta${importIdRef.value++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n const importPath = `${fromApp ? appImportBase : pkgImportBase}/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, sync: ((${metaName}.metadata) as any)?.sync, priority: ((${metaName}.metadata) as any)?.priority, handler: ${importName} }`\n )\n }\n return subscribers\n}\n\nasync function processWorkers(options: {\n roots: ModuleRoots\n modId: string\n appImportBase: string\n pkgImportBase: string\n imports: string[]\n importIdRef: { value: number }\n}): Promise<string[]> {\n const { roots, modId, appImportBase, pkgImportBase, imports, importIdRef } = options\n const files = scanModuleDir(roots, SCAN_CONFIGS.workers)\n const workers: string[] = []\n for (const { relPath, fromApp } of files) {\n const segs = relPath.split('/')\n const file = segs.pop()!\n const name = file.replace(/\\.ts$/, '')\n const importPath = `${fromApp ? appImportBase : pkgImportBase}/workers/${[...segs, name].join('/')}`\n if (!(await moduleHasExport(importPath, 'metadata'))) continue\n const importName = `Worker${importIdRef.value++}_${toVar(modId)}_${toVar([...segs, name].join('_') || 'index')}`\n const metaName = `WorkerMeta${importIdRef.value++}_${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 return workers\n}\n\nfunction processTranslations(options: {\n roots: ModuleRoots\n modId: string\n appImportBase: string\n pkgImportBase: string\n imports: string[]\n}): string[] {\n const { roots, modId, appImportBase, pkgImportBase, imports } = options\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 const translations: string[] = []\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 '${pkgImportBase}/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 '${pkgImportBase}/i18n/${locale}.json'`)\n translations.push(`'${locale}': ${cName} as unknown as Record<string,string>`)\n }\n }\n return translations\n}\n\n/**\n * Resolves a convention file and pushes its import + config entry to standalone arrays.\n * Used for files that produce their own generated output (notifications, AI tools, events, analytics, enrichers, etc.).\n *\n * @returns The generated import name, or null if the file was not found.\n */\nfunction processStandaloneConfig(options: {\n roots: ModuleRoots\n imps: ModuleImports\n modId: string\n relativePath: string\n prefix: string\n importIdRef: { value: number }\n standaloneImports: string[]\n standaloneConfigs: string[]\n configExpr: (importName: string, modId: string) => string\n /** Also push the import to the shared imports array (used by modules.generated.ts) */\n sharedImports?: string[]\n}): string | null {\n const { roots, imps, modId, relativePath, prefix, importIdRef, standaloneImports, standaloneConfigs, configExpr, sharedImports } = options\n const resolved = resolveModuleFile(roots, imps, relativePath)\n if (!resolved) return null\n const importName = `${prefix}_${toVar(modId)}_${importIdRef.value++}`\n const importStmt = `import * as ${importName} from '${resolved.importPath}'`\n standaloneImports.push(importStmt)\n if (sharedImports) sharedImports.push(importStmt)\n standaloneConfigs.push(configExpr(importName, modId))\n return importName\n}\n\nfunction resolveConventionFile(\n roots: ModuleRoots,\n imps: ModuleImports,\n relativePath: string,\n prefix: string,\n modId: string,\n importIdRef: { value: number },\n imports: string[],\n importStyle: 'namespace' | 'default' = 'namespace'\n): { importName: string; importPath: string; fromApp: boolean } | null {\n const resolved = resolveModuleFile(roots, imps, relativePath)\n if (!resolved) return null\n const importName = `${prefix}_${toVar(modId)}_${importIdRef.value++}`\n if (importStyle === 'default') {\n imports.push(`import ${importName} from '${resolved.importPath}'`)\n } else {\n imports.push(`import * as ${importName} from '${resolved.importPath}'`)\n }\n return { importName, importPath: resolved.importPath, fromApp: resolved.fromApp }\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 const notificationsOutFile = path.join(outputDir, 'notifications.generated.ts')\n const notificationsChecksumFile = path.join(outputDir, 'notifications.generated.checksum')\n const notificationsClientOutFile = path.join(outputDir, 'notifications.client.generated.ts')\n const notificationsClientChecksumFile = path.join(outputDir, 'notifications.client.generated.checksum')\n const messageTypesOutFile = path.join(outputDir, 'message-types.generated.ts')\n const messageTypesChecksumFile = path.join(outputDir, 'message-types.generated.checksum')\n const messageObjectsOutFile = path.join(outputDir, 'message-objects.generated.ts')\n const messageObjectsChecksumFile = path.join(outputDir, 'message-objects.generated.checksum')\n const messagesClientOutFile = path.join(outputDir, 'messages.client.generated.ts')\n const messagesClientChecksumFile = path.join(outputDir, 'messages.client.generated.checksum')\n const aiToolsOutFile = path.join(outputDir, 'ai-tools.generated.ts')\n const aiToolsChecksumFile = path.join(outputDir, 'ai-tools.generated.checksum')\n const eventsOutFile = path.join(outputDir, 'events.generated.ts')\n const eventsChecksumFile = path.join(outputDir, 'events.generated.checksum')\n const analyticsOutFile = path.join(outputDir, 'analytics.generated.ts')\n const analyticsChecksumFile = path.join(outputDir, 'analytics.generated.checksum')\n const transFieldsOutFile = path.join(outputDir, 'translations-fields.generated.ts')\n const transFieldsChecksumFile = path.join(outputDir, 'translations-fields.generated.checksum')\n const enrichersOutFile = path.join(outputDir, 'enrichers.generated.ts')\n const enrichersChecksumFile = path.join(outputDir, 'enrichers.generated.checksum')\n const interceptorsOutFile = path.join(outputDir, 'interceptors.generated.ts')\n const interceptorsChecksumFile = path.join(outputDir, 'interceptors.generated.checksum')\n const componentOverridesOutFile = path.join(outputDir, 'component-overrides.generated.ts')\n const componentOverridesChecksumFile = path.join(outputDir, 'component-overrides.generated.checksum')\n const inboxActionsOutFile = path.join(outputDir, 'inbox-actions.generated.ts')\n const inboxActionsChecksumFile = path.join(outputDir, 'inbox-actions.generated.checksum')\n const guardsOutFile = path.join(outputDir, 'guards.generated.ts')\n const guardsChecksumFile = path.join(outputDir, 'guards.generated.checksum')\n const commandInterceptorsOutFile = path.join(outputDir, 'command-interceptors.generated.ts')\n const commandInterceptorsChecksumFile = path.join(outputDir, 'command-interceptors.generated.checksum')\n\n const enabled = resolver.loadEnabledModules()\n const imports: string[] = []\n const moduleDecls: string[] = []\n // Mutable ref so extracted helper functions can increment the shared counter\n const importIdRef = { value: 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 const notificationTypes: string[] = []\n const notificationImports: string[] = []\n const notificationClientTypes: string[] = []\n const notificationClientImports: string[] = []\n const messageTypeEntries: string[] = []\n const messageTypeImports: string[] = []\n const messageObjectTypeEntries: string[] = []\n const messageObjectTypeImports: string[] = []\n const aiToolsConfigs: string[] = []\n const aiToolsImports: string[] = []\n const eventsConfigs: string[] = []\n const eventsImports: string[] = []\n const analyticsConfigs: string[] = []\n const analyticsImports: string[] = []\n const transFieldsConfigs: string[] = []\n const transFieldsImports: string[] = []\n const enricherConfigs: string[] = []\n const enricherImports: string[] = []\n const interceptorConfigs: string[] = []\n const interceptorImports: string[] = []\n const componentOverrideConfigs: string[] = []\n const componentOverrideImports: string[] = []\n const inboxActionsConfigs: string[] = []\n const inboxActionsImports: string[] = []\n const guardConfigs: string[] = []\n const guardImports: string[] = []\n const commandInterceptorConfigs: string[] = []\n const commandInterceptorImports: string[] = []\n\n for (const entry of enabled) {\n const modId = entry.id\n const roots = resolver.getModulePaths(entry)\n const rawImps = resolver.getModuleImportBase(entry)\n trackedRoots.add(roots.appBase)\n trackedRoots.add(roots.pkgBase)\n\n const isAppModule = entry.from === '@app'\n const appImportBase = isAppModule ? `../../src/modules/${modId}` : rawImps.appBase\n const imps: ModuleImports = { appBase: appImportBase, pkgBase: rawImps.pkgBase }\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 eventsImportName: string | null = null\n let analyticsImportName: string | null = null\n let customFieldSetsExpr: string = '[]'\n const dashboardWidgets: string[] = []\n const injectionWidgets: string[] = []\n let injectionTableImportName: string | null = null\n let setupImportName: string | null = null\n\n // === Processing order MUST match original import ID sequence ===\n\n // 1. Module metadata: index.ts (overrideable)\n const appIndex = path.join(roots.appBase, 'index.ts')\n const pkgIndex = path.join(roots.pkgBase, 'index.ts')\n const indexTs = fs.existsSync(appIndex) ? appIndex : fs.existsSync(pkgIndex) ? pkgIndex : null\n if (indexTs) {\n infoImportName = `I${importIdRef.value++}_${toVar(modId)}`\n const importPath = indexTs.startsWith(roots.appBase) ? `${appImportBase}/index` : `${imps.pkgBase}/index`\n imports.push(`import * as ${infoImportName} from '${importPath}'`)\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 // 2. Pages: frontend\n {\n const feApp = path.join(roots.appBase, 'frontend')\n const fePkg = path.join(roots.pkgBase, 'frontend')\n const feFiles = scanModuleDir(roots, SCAN_CONFIGS.frontendPages)\n if (feFiles.length) {\n frontendRoutes.push(...processPageFiles({\n files: feFiles,\n type: 'frontend',\n modId,\n appDir: feApp,\n pkgDir: fePkg,\n appImportBase,\n pkgImportBase: imps.pkgBase,\n imports,\n importIdRef,\n }))\n }\n }\n\n // 3. Entity extensions: data/extensions.ts\n {\n const ext = resolveConventionFile(roots, imps, 'data/extensions.ts', 'X', modId, importIdRef, imports)\n if (ext) extensionsImportName = ext.importName\n }\n\n // 4. RBAC: acl.ts\n {\n const rootApp = path.join(roots.appBase, 'acl.ts')\n const rootPkg = path.join(roots.pkgBase, 'acl.ts')\n const hasRoot = fs.existsSync(rootApp) || fs.existsSync(rootPkg)\n if (hasRoot) {\n const importName = `ACL_${toVar(modId)}_${importIdRef.value++}`\n const useApp = fs.existsSync(rootApp) ? 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 // 5. Custom entities: ce.ts\n {\n const ce = resolveConventionFile(roots, imps, 'ce.ts', 'CE', modId, importIdRef, imports)\n if (ce) customEntitiesImportName = ce.importName\n }\n\n // 6. Search: search.ts\n {\n const resolved = resolveModuleFile(roots, imps, 'search.ts')\n if (resolved) {\n const importName = `SEARCH_${toVar(modId)}_${importIdRef.value++}`\n const importStmt = `import * as ${importName} from '${resolved.importPath}'`\n imports.push(importStmt)\n searchImports.push(importStmt)\n searchImportName = importName\n }\n }\n\n // 7. Notifications: notifications.ts\n processStandaloneConfig({\n roots, imps, modId, importIdRef,\n relativePath: 'notifications.ts',\n prefix: 'NOTIF',\n standaloneImports: notificationImports,\n standaloneConfigs: notificationTypes,\n configExpr: (n, id) => `{ moduleId: '${id}', types: ((${n}.default ?? ${n}.notificationTypes ?? (${n} as any).types ?? []) as NotificationTypeDefinition[]) }`,\n })\n\n // Notification client renderers: notifications.client.ts\n processStandaloneConfig({\n roots, imps, modId, importIdRef,\n relativePath: 'notifications.client.ts',\n prefix: 'NOTIF_CLIENT',\n standaloneImports: notificationClientImports,\n standaloneConfigs: notificationClientTypes,\n configExpr: (n, id) => `{ moduleId: '${id}', types: (${n}.default ?? []) }`,\n })\n // Message types: module root message-types.ts\n {\n const resolved = resolveModuleFile(roots, imps, 'message-types.ts')\n if (resolved) {\n const importName = `MSG_TYPES_${toVar(modId)}_${importIdRef.value++}`\n const importStmt = `import * as ${importName} from '${resolved.importPath}'`\n messageTypeImports.push(importStmt)\n messageTypeEntries.push(\n `{ moduleId: '${modId}', types: ((${importName}.default ?? (${importName} as any).messageTypes ?? (${importName} as any).types ?? []) as MessageTypeDefinition[]) }`\n )\n }\n }\n\n // Message object types: module root message-objects.ts\n {\n const resolved = resolveModuleFile(roots, imps, 'message-objects.ts')\n if (resolved) {\n const importName = `MSG_OBJECTS_${toVar(modId)}_${importIdRef.value++}`\n const importStmt = `import * as ${importName} from '${resolved.importPath}'`\n messageObjectTypeImports.push(importStmt)\n messageObjectTypeEntries.push(\n `{ moduleId: '${modId}', types: ((${importName}.default ?? (${importName} as any).messageObjectTypes ?? (${importName} as any).objectTypes ?? (${importName} as any).types ?? []) as MessageObjectTypeDefinition[]) }`\n )\n }\n }\n\n // AI Tools: module root ai-tools.ts\n {\n const resolved = resolveModuleFile(roots, imps, 'notifications.client.ts')\n if (resolved) {\n const importName = `NOTIF_CLIENT_${toVar(modId)}_${importIdRef.value++}`\n const importStmt = `import * as ${importName} from '${resolved.importPath}'`\n notificationClientImports.push(importStmt)\n notificationClientTypes.push(\n `{ moduleId: '${modId}', types: (${importName}.default ?? []) }`\n )\n }\n }\n\n // 8. AI Tools: ai-tools.ts\n processStandaloneConfig({\n roots, imps, modId, importIdRef,\n relativePath: 'ai-tools.ts',\n prefix: 'AI_TOOLS',\n standaloneImports: aiToolsImports,\n standaloneConfigs: aiToolsConfigs,\n configExpr: (n, id) => `{ moduleId: '${id}', tools: (${n}.aiTools ?? ${n}.default ?? []) }`,\n })\n\n // 9. Events: events.ts (also referenced in module declarations)\n eventsImportName = processStandaloneConfig({\n roots, imps, modId, importIdRef,\n relativePath: 'events.ts',\n prefix: 'EVENTS',\n standaloneImports: eventsImports,\n standaloneConfigs: eventsConfigs,\n sharedImports: imports,\n configExpr: (n, id) => `{ moduleId: '${id}', config: (${n}.default ?? ${n}.eventsConfig ?? null) as EventModuleConfigBase | null }`,\n })\n\n // 10. Analytics: analytics.ts (also referenced in module declarations)\n analyticsImportName = processStandaloneConfig({\n roots, imps, modId, importIdRef,\n relativePath: 'analytics.ts',\n prefix: 'ANALYTICS',\n standaloneImports: analyticsImports,\n standaloneConfigs: analyticsConfigs,\n sharedImports: imports,\n configExpr: (n, id) => `{ moduleId: '${id}', config: (${n}.default ?? ${n}.analyticsConfig ?? ${n}.config ?? null) }`,\n })\n\n // 10b. Enrichers: data/enrichers.ts\n processStandaloneConfig({\n roots, imps, modId, importIdRef,\n relativePath: 'data/enrichers.ts',\n prefix: 'ENRICHERS',\n standaloneImports: enricherImports,\n standaloneConfigs: enricherConfigs,\n configExpr: (n, id) => `{ moduleId: '${id}', enrichers: ((${n} as any).enrichers ?? (${n} as any).default ?? []) }`,\n })\n\n // 10c. API interceptors: api/interceptors.ts\n processStandaloneConfig({\n roots, imps, modId, importIdRef,\n relativePath: 'api/interceptors.ts',\n prefix: 'INTERCEPTORS',\n standaloneImports: interceptorImports,\n standaloneConfigs: interceptorConfigs,\n configExpr: (n, id) => `{ moduleId: '${id}', interceptors: ((${n} as any).interceptors ?? (${n} as any).default ?? []) }`,\n })\n\n // 10d. Component overrides: widgets/components.ts\n processStandaloneConfig({\n roots, imps, modId, importIdRef,\n relativePath: 'widgets/components.ts',\n prefix: 'COMPONENT_OVERRIDES',\n standaloneImports: componentOverrideImports,\n standaloneConfigs: componentOverrideConfigs,\n configExpr: (n, id) => `{ moduleId: '${id}', componentOverrides: ((${n} as any).componentOverrides ?? (${n} as any).default ?? []) }`,\n })\n\n // Translatable fields: translations.ts (also referenced in module declarations)\n let transFieldsImportName: string | null = null\n transFieldsImportName = processStandaloneConfig({\n roots, imps, modId, importIdRef,\n relativePath: 'translations.ts',\n prefix: 'TRANS_FIELDS',\n standaloneImports: transFieldsImports,\n standaloneConfigs: transFieldsConfigs,\n sharedImports: imports,\n configExpr: (n, id) => `{ moduleId: '${id}', fields: (${n}.default ?? ${n}.translatableFields ?? {}) as Record<string, string[]> }`,\n })\n\n // Inbox Actions: inbox-actions.ts\n {\n const resolved = resolveModuleFile(roots, imps, 'inbox-actions.ts')\n if (resolved) {\n const importName = `INBOX_ACTIONS_${toVar(modId)}_${importIdRef.value++}`\n const importStmt = `import * as ${importName} from '${resolved.importPath}'`\n inboxActionsImports.push(importStmt)\n inboxActionsConfigs.push(\n `{ moduleId: '${modId}', actions: (${importName}.default ?? ${importName}.inboxActions ?? []) }`\n )\n }\n }\n\n // 10e. Mutation guards: data/guards.ts\n processStandaloneConfig({\n roots, imps, modId, importIdRef,\n relativePath: 'data/guards.ts',\n prefix: 'GUARDS',\n standaloneImports: guardImports,\n standaloneConfigs: guardConfigs,\n configExpr: (n, id) => `{ moduleId: '${id}', guards: ((${n} as any).guards ?? (${n} as any).default ?? []) }`,\n })\n\n // 10f. Command interceptors: commands/interceptors.ts\n processStandaloneConfig({\n roots, imps, modId, importIdRef,\n relativePath: 'commands/interceptors.ts',\n prefix: 'CMD_INTERCEPTORS',\n standaloneImports: commandInterceptorImports,\n standaloneConfigs: commandInterceptorConfigs,\n configExpr: (n, id) => `{ moduleId: '${id}', interceptors: ((${n} as any).interceptors ?? (${n} as any).default ?? []) }`,\n })\n\n // 11. Setup: setup.ts\n {\n const setup = resolveConventionFile(roots, imps, 'setup.ts', 'SETUP', modId, importIdRef, imports)\n if (setup) setupImportName = setup.importName\n }\n\n // 12. Custom fields: data/fields.ts\n {\n const fields = resolveConventionFile(roots, imps, 'data/fields.ts', 'F', modId, importIdRef, imports)\n if (fields) fieldsImportName = fields.importName\n }\n\n // 13. Pages: backend\n {\n const beApp = path.join(roots.appBase, 'backend')\n const bePkg = path.join(roots.pkgBase, 'backend')\n const beFiles = scanModuleDir(roots, SCAN_CONFIGS.backendPages)\n if (beFiles.length) {\n backendRoutes.push(...processPageFiles({\n files: beFiles,\n type: 'backend',\n modId,\n appDir: beApp,\n pkgDir: bePkg,\n appImportBase,\n pkgImportBase: imps.pkgBase,\n imports,\n importIdRef,\n }))\n }\n }\n\n // 14. API routes\n apis.push(...await processApiRoutes({\n roots,\n modId,\n appImportBase,\n pkgImportBase: imps.pkgBase,\n imports,\n importIdRef,\n }))\n\n // 15. CLI\n {\n const cliApp = path.join(roots.appBase, 'cli.ts')\n const cliPkg = path.join(roots.pkgBase, 'cli.ts')\n const cliPath = fs.existsSync(cliApp) ? cliApp : fs.existsSync(cliPkg) ? cliPkg : null\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\n // 16. Translations\n translations.push(...processTranslations({\n roots,\n modId,\n appImportBase,\n pkgImportBase: imps.pkgBase,\n imports,\n }))\n\n // 17. Subscribers\n subscribers.push(...processSubscribers({\n roots,\n modId,\n appImportBase,\n pkgImportBase: imps.pkgBase,\n imports,\n importIdRef,\n }))\n\n // 18. Workers\n workers.push(...await processWorkers({\n roots,\n modId,\n appImportBase,\n pkgImportBase: imps.pkgBase,\n imports,\n importIdRef,\n }))\n\n // Build combined customFieldSets expression\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 // 19. Dashboard widgets\n {\n const entries = scanDashboardWidgetEntries({\n modId,\n roots,\n appImportBase,\n pkgImportBase: imps.pkgBase,\n })\n for (const entry of entries) {\n dashboardWidgets.push(\n `{ moduleId: '${entry.moduleId}', key: '${entry.key}', source: '${entry.source}', loader: () => import('${entry.importPath}').then((mod) => mod.default ?? mod) }`\n )\n const existing = allDashboardWidgets.get(entry.key)\n if (!existing || (existing.source !== 'app' && entry.source === 'app')) {\n allDashboardWidgets.set(entry.key, {\n moduleId: entry.moduleId,\n source: entry.source,\n importPath: entry.importPath,\n })\n }\n }\n }\n\n // 20. Injection widgets\n {\n const files = scanModuleDir(roots, SCAN_CONFIGS.injectionWidgets)\n const widgetApp = path.join(roots.appBase, 'widgets', 'injection')\n for (const { relPath, fromApp } of files) {\n const segs = relPath.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 // 21. Injection table\n {\n const resolved = resolveModuleFile(roots, imps, 'widgets/injection-table.ts')\n if (resolved) {\n const importName = `InjTable_${toVar(modId)}_${importIdRef.value++}`\n imports.push(`import * as ${importName} from '${resolved.importPath}'`)\n injectionTableImportName = importName\n allInjectionTables.push({ moduleId: modId, importPath: resolved.importPath, importName })\n }\n }\n\n if (searchImportName) {\n searchConfigs.push(`{ moduleId: '${modId}', config: (${searchImportName}.default ?? ${searchImportName}.searchConfig ?? ${searchImportName}.config ?? null) }`)\n }\n\n // Note: events, analytics, enrichers, notifications, AI tools, and translatable fields\n // configs are pushed inside processStandaloneConfig() above \u2014 no separate push needed here.\n\n if (transFieldsImportName) {\n transFieldsConfigs.push(`{ moduleId: '${modId}', fields: (${transFieldsImportName}.default ?? ${transFieldsImportName}.translatableFields ?? {}) as Record<string, string[]> }`)\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 ${setupImportName ? `setup: (${setupImportName}.default ?? ${setupImportName}.setup) || undefined,` : ''}\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 const eventsEntriesLiteral = eventsConfigs.join(',\\n ')\n const eventsImportSection = eventsImports.join('\\n')\n const eventsOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { EventModuleConfigBase, EventDefinition } from '@open-mercato/shared/modules/events'\n${eventsImportSection ? `\\n${eventsImportSection}\\n` : '\\n'}type EventConfigEntry = { moduleId: string; config: EventModuleConfigBase | null }\n\nconst entriesRaw: EventConfigEntry[] = [\n${eventsEntriesLiteral ? ` ${eventsEntriesLiteral}\\n` : ''}]\nconst entries = entriesRaw.filter((e): e is { moduleId: string; config: EventModuleConfigBase } => e.config != null)\n\nexport const eventModuleConfigEntries = entries\nexport const eventModuleConfigs: EventModuleConfigBase[] = entries.map((e) => e.config)\nexport const allEvents: EventDefinition[] = entries.flatMap((e) => e.config.events)\n\n// Runtime registry for validation\nconst allDeclaredEventIds = new Set(allEvents.map((e) => e.id))\nexport function isEventDeclared(eventId: string): boolean {\n return allDeclaredEventIds.has(eventId)\n}\n`\n\n const analyticsEntriesLiteral = analyticsConfigs.join(',\\n ')\n const analyticsImportSection = analyticsImports.join('\\n')\n const analyticsOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { AnalyticsModuleConfig } from '@open-mercato/shared/modules/analytics'\n${analyticsImportSection ? `\\n${analyticsImportSection}\\n` : '\\n'}type AnalyticsConfigEntry = { moduleId: string; config: AnalyticsModuleConfig | null }\n\nconst entriesRaw: AnalyticsConfigEntry[] = [\n${analyticsEntriesLiteral ? ` ${analyticsEntriesLiteral}\\n` : ''}]\nconst entries = entriesRaw.filter((entry): entry is { moduleId: string; config: AnalyticsModuleConfig } => entry.config != null)\n\nexport const analyticsModuleConfigEntries = entries\nexport const analyticsModuleConfigs: AnalyticsModuleConfig[] = entries.map((entry) => entry.config)\n`\n\n const transFieldsEntriesLiteral = transFieldsConfigs.join(',\\n ')\n const transFieldsImportSection = transFieldsImports.join('\\n')\n const transFieldsOutput = `// AUTO-GENERATED by mercato generate registry\nimport { registerTranslatableFields } from '@open-mercato/shared/lib/localization/translatable-fields'\n${transFieldsImportSection ? `\\n${transFieldsImportSection}\\n` : '\\n'}type TransFieldsEntry = { moduleId: string; fields: Record<string, string[]> }\n\nconst entries: TransFieldsEntry[] = [\n${transFieldsEntriesLiteral ? ` ${transFieldsEntriesLiteral}\\n` : ''}]\n\nconst allFields: Record<string, string[]> = {}\nfor (const entry of entries) {\n for (const [key, value] of Object.entries(entry.fields)) {\n allFields[key] = value\n }\n}\n\nexport const translatableFieldEntries = entries\nexport const allTranslatableFields = allFields\nexport const allTranslatableEntityTypes = Object.keys(allFields)\n\n// Auto-register on import (side-effect)\nregisterTranslatableFields(allFields)\n`\n\n const notificationEntriesLiteral = notificationTypes.join(',\\n ')\n const notificationImportSection = notificationImports.join('\\n')\n const notificationsOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { NotificationTypeDefinition } from '@open-mercato/shared/modules/notifications/types'\n${notificationImportSection ? `\\n${notificationImportSection}\\n` : '\\n'}type NotificationTypeEntry = { moduleId: string; types: NotificationTypeDefinition[] }\n\nconst entriesRaw: NotificationTypeEntry[] = [\n${notificationEntriesLiteral ? ` ${notificationEntriesLiteral}\\n` : ''}]\n\nconst allTypes = entriesRaw.flatMap((entry) => entry.types)\n\nexport const notificationTypeEntries = entriesRaw\nexport const notificationTypes = allTypes\n\nexport function getNotificationTypes(): NotificationTypeDefinition[] {\n return allTypes\n}\n\nexport function getNotificationType(type: string): NotificationTypeDefinition | undefined {\n return allTypes.find((t) => t.type === type)\n}\n`\n const notificationClientEntriesLiteral = notificationClientTypes.join(',\\n ')\n const notificationClientImportSection = notificationClientImports.join('\\n')\n const notificationsClientOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { ComponentType } from 'react'\nimport type { NotificationTypeDefinition, NotificationRendererProps } from '@open-mercato/shared/modules/notifications/types'\n${notificationClientImportSection ? `\\n${notificationClientImportSection}\\n` : '\\n'}type NotificationTypeEntry = { moduleId: string; types: NotificationTypeDefinition[] }\nexport type NotificationRenderers = Record<string, ComponentType<NotificationRendererProps>>\n\nconst entriesRaw: NotificationTypeEntry[] = [\n${notificationClientEntriesLiteral ? ` ${notificationClientEntriesLiteral}\\n` : ''}]\n\nconst allTypes = entriesRaw.flatMap((entry) => entry.types)\nconst renderers: NotificationRenderers = Object.fromEntries(\n allTypes\n .filter((typeDef) => Boolean(typeDef.Renderer))\n .map((typeDef) => [typeDef.type, typeDef.Renderer!]),\n)\n\nexport const notificationClientTypeEntries = entriesRaw\nexport const notificationClientTypes = allTypes\nexport const notificationRenderers = renderers\n\nexport function getNotificationRenderers(): NotificationRenderers {\n return renderers\n}\n`\n\n const messageTypeEntriesLiteral = messageTypeEntries.join(',\\n ')\n const messageTypeImportSection = messageTypeImports.join('\\n')\n const messageTypesOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { MessageTypeDefinition } from '@open-mercato/shared/modules/messages/types'\n${messageTypeImportSection ? `\\n${messageTypeImportSection}\\n` : '\\n'}type MessageTypeEntry = { moduleId: string; types: MessageTypeDefinition[] }\n\nconst entriesRaw: MessageTypeEntry[] = [\n${messageTypeEntriesLiteral ? ` ${messageTypeEntriesLiteral}\\n` : ''}]\n\nconst allTypes = entriesRaw.flatMap((entry) => entry.types)\n\nexport const messageTypeEntries = entriesRaw\nexport const messageTypes = allTypes\n\nexport function getMessageTypes(): MessageTypeDefinition[] {\n return allTypes\n}\n\nexport function getMessageType(type: string): MessageTypeDefinition | undefined {\n return allTypes.find((entry) => entry.type === type)\n}\n`\n\n const messageObjectEntriesLiteral = messageObjectTypeEntries.join(',\\n ')\n const messageObjectImportSection = messageObjectTypeImports.join('\\n')\n const messageObjectsOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { MessageObjectTypeDefinition } from '@open-mercato/shared/modules/messages/types'\n${messageObjectImportSection ? `\\n${messageObjectImportSection}\\n` : '\\n'}type MessageObjectTypeEntry = { moduleId: string; types: MessageObjectTypeDefinition[] }\n\nconst entriesRaw: MessageObjectTypeEntry[] = [\n${messageObjectEntriesLiteral ? ` ${messageObjectEntriesLiteral}\\n` : ''}]\n\nconst allTypes = entriesRaw.flatMap((entry) => entry.types)\n\nexport const messageObjectTypeEntries = entriesRaw\nexport const messageObjectTypes = allTypes\n\nexport function getMessageObjectTypes(): MessageObjectTypeDefinition[] {\n return allTypes\n}\n\nexport function getMessageObjectType(module: string, entityType: string): MessageObjectTypeDefinition | undefined {\n return allTypes.find((entry) => entry.module === module && entry.entityType === entityType)\n}\n`\n const messagesClientOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { ComponentType } from 'react'\nimport type {\n MessageTypeDefinition,\n MessageObjectTypeDefinition,\n MessageListItemProps,\n MessageContentProps,\n MessageActionsProps,\n ObjectDetailProps,\n ObjectPreviewProps,\n} from '@open-mercato/shared/modules/messages/types'\nimport { registerMessageObjectTypes } from '@open-mercato/core/modules/messages/lib/message-objects-registry'\nimport { configureMessageUiComponentRegistry } from '@open-mercato/core/modules/messages/components/utils/typeUiRegistry'\n${messageTypeImportSection ? `\\n${messageTypeImportSection}\\n` : '\\n'}${messageObjectImportSection ? `\\n${messageObjectImportSection}\\n` : ''}type MessageTypeEntry = { moduleId: string; types: MessageTypeDefinition[] }\ntype MessageObjectTypeEntry = { moduleId: string; types: MessageObjectTypeDefinition[] }\n\nexport type MessageListItemRenderers = Record<string, ComponentType<MessageListItemProps>>\nexport type MessageContentRenderers = Record<string, ComponentType<MessageContentProps>>\nexport type MessageActionsRenderers = Record<string, ComponentType<MessageActionsProps>>\nexport type MessageObjectDetailRenderers = Record<string, ComponentType<ObjectDetailProps>>\nexport type MessageObjectPreviewRenderers = Record<string, ComponentType<ObjectPreviewProps>>\n\nexport type MessageUiComponentRegistry = {\n listItemComponents: MessageListItemRenderers\n contentComponents: MessageContentRenderers\n actionsComponents: MessageActionsRenderers\n objectDetailComponents: MessageObjectDetailRenderers\n objectPreviewComponents: MessageObjectPreviewRenderers\n}\n\nconst messageTypeEntriesRaw: MessageTypeEntry[] = [\n${messageTypeEntriesLiteral ? ` ${messageTypeEntriesLiteral}\\n` : ''}]\nconst messageObjectTypeEntriesRaw: MessageObjectTypeEntry[] = [\n${messageObjectEntriesLiteral ? ` ${messageObjectEntriesLiteral}\\n` : ''}]\n\nconst allMessageTypes = messageTypeEntriesRaw.flatMap((entry) => entry.types)\nconst allMessageObjectTypes = messageObjectTypeEntriesRaw.flatMap((entry) => entry.types)\n\nconst listItemComponents: MessageListItemRenderers = Object.fromEntries(\n allMessageTypes\n .filter((typeDef) => Boolean(typeDef.ui?.listItemComponent) && Boolean(typeDef.ListItemComponent))\n .map((typeDef) => [typeDef.ui!.listItemComponent!, typeDef.ListItemComponent!]),\n)\n\nconst contentComponents: MessageContentRenderers = Object.fromEntries(\n allMessageTypes\n .filter((typeDef) => Boolean(typeDef.ui?.contentComponent) && Boolean(typeDef.ContentComponent))\n .map((typeDef) => [typeDef.ui!.contentComponent!, typeDef.ContentComponent!]),\n)\n\nconst actionsComponents: MessageActionsRenderers = Object.fromEntries(\n allMessageTypes\n .filter((typeDef) => Boolean(typeDef.ui?.actionsComponent) && Boolean(typeDef.ActionsComponent))\n .map((typeDef) => [typeDef.ui!.actionsComponent!, typeDef.ActionsComponent!]),\n)\n\nconst objectDetailComponents: MessageObjectDetailRenderers = Object.fromEntries(\n allMessageObjectTypes\n .filter((typeDef) => Boolean(typeDef.DetailComponent))\n .map((typeDef) => [\\`\\${typeDef.module}:\\${typeDef.entityType}\\`, typeDef.DetailComponent!]),\n)\n\nconst objectPreviewComponents: MessageObjectPreviewRenderers = Object.fromEntries(\n allMessageObjectTypes\n .filter((typeDef) => Boolean(typeDef.PreviewComponent))\n .map((typeDef) => [\\`\\${typeDef.module}:\\${typeDef.entityType}\\`, typeDef.PreviewComponent!]),\n)\n\nconst registry: MessageUiComponentRegistry = {\n listItemComponents,\n contentComponents,\n actionsComponents,\n objectDetailComponents,\n objectPreviewComponents,\n}\n\nexport const messageClientTypeEntries = messageTypeEntriesRaw\nexport const messageClientObjectTypeEntries = messageObjectTypeEntriesRaw\nexport const messageUiComponentRegistry = registry\n\nexport function getMessageUiComponentRegistry(): MessageUiComponentRegistry {\n return registry\n}\n\n// Side-effects: register all message object types and configure the UI component registry on import.\nfor (const entry of messageObjectTypeEntriesRaw) {\n registerMessageObjectTypes(entry.types)\n}\nconfigureMessageUiComponentRegistry(registry)\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([\n ...Array.from(trackedRoots),\n ])\n\n writeGeneratedFile({ outFile, checksumFile, content: output, structureChecksum, result, quiet })\n writeGeneratedFile({ outFile: widgetsOutFile, checksumFile: widgetsChecksumFile, content: widgetsOutput, structureChecksum, result, quiet })\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 writeGeneratedFile({ outFile: injectionWidgetsOutFile, checksumFile: injectionWidgetsChecksumFile, content: injectionWidgetsOutput, structureChecksum, result, quiet })\n writeGeneratedFile({ outFile: injectionTablesOutFile, checksumFile: injectionTablesChecksumFile, content: injectionTablesOutput, structureChecksum, result, quiet })\n writeGeneratedFile({ outFile: searchOutFile, checksumFile: searchChecksumFile, content: searchOutput, structureChecksum, result, quiet })\n\n // AI Tools generated file\n const aiToolsOutput = `// AUTO-GENERATED by mercato generate registry\n${aiToolsImports.length ? aiToolsImports.join('\\n') + '\\n' : ''}\ntype AiToolConfigEntry = { moduleId: string; tools: unknown[] }\n\nexport const aiToolConfigEntries: AiToolConfigEntry[] = [\n${aiToolsConfigs.length ? ' ' + aiToolsConfigs.join(',\\n ') + '\\n' : ''}].filter(e => Array.isArray(e.tools) && e.tools.length > 0)\n\nexport const allAiTools = aiToolConfigEntries.flatMap(e => e.tools)\n`\n writeGeneratedFile({ outFile: aiToolsOutFile, checksumFile: aiToolsChecksumFile, content: aiToolsOutput, structureChecksum, result, quiet })\n writeGeneratedFile({ outFile: notificationsOutFile, checksumFile: notificationsChecksumFile, content: notificationsOutput, structureChecksum, result, quiet })\n writeGeneratedFile({ outFile: notificationsClientOutFile, checksumFile: notificationsClientChecksumFile, content: notificationsClientOutput, structureChecksum, result, quiet })\n writeGeneratedFile({ outFile: messageTypesOutFile, checksumFile: messageTypesChecksumFile, content: messageTypesOutput, structureChecksum, result, quiet })\n writeGeneratedFile({ outFile: messageObjectsOutFile, checksumFile: messageObjectsChecksumFile, content: messageObjectsOutput, structureChecksum, result, quiet })\n writeGeneratedFile({ outFile: messagesClientOutFile, checksumFile: messagesClientChecksumFile, content: messagesClientOutput, structureChecksum, result, quiet })\n writeGeneratedFile({ outFile: eventsOutFile, checksumFile: eventsChecksumFile, content: eventsOutput, structureChecksum, result, quiet })\n writeGeneratedFile({ outFile: analyticsOutFile, checksumFile: analyticsChecksumFile, content: analyticsOutput, structureChecksum, result, quiet })\n writeGeneratedFile({ outFile: transFieldsOutFile, checksumFile: transFieldsChecksumFile, content: transFieldsOutput, structureChecksum, result, quiet })\n\n // Enrichers generated file\n const enricherEntriesLiteral = enricherConfigs.join(',\\n ')\n const enricherImportSection = enricherImports.join('\\n')\n const enrichersOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { ResponseEnricher } from '@open-mercato/shared/lib/crud/response-enricher'\n${enricherImportSection ? `\\n${enricherImportSection}\\n` : '\\n'}type EnricherEntry = { moduleId: string; enrichers: ResponseEnricher[] }\n\nexport const enricherEntries: EnricherEntry[] = [\n${enricherEntriesLiteral ? ` ${enricherEntriesLiteral}\\n` : ''}]\n`\n writeGeneratedFile({ outFile: enrichersOutFile, checksumFile: enrichersChecksumFile, content: enrichersOutput, structureChecksum, result, quiet })\n // Inbox Actions generated file\n const inboxActionsEntriesLiteral = inboxActionsConfigs.join(',\\n ')\n const inboxActionsImportSection = inboxActionsImports.join('\\n')\n const inboxActionsOutput = `// AUTO-GENERATED by mercato generate registry \u2014 do not edit\nimport type { InboxActionDefinition } from '@open-mercato/shared/modules/inbox-actions'\n${inboxActionsImportSection ? `\\n${inboxActionsImportSection}\\n` : '\\n'}\ntype InboxActionConfigEntry = { moduleId: string; actions: InboxActionDefinition[] }\n\nconst entriesRaw: InboxActionConfigEntry[] = [\n${inboxActionsEntriesLiteral ? ` ${inboxActionsEntriesLiteral}\\n` : ''}]\n\nconst entries = entriesRaw.filter((e): e is InboxActionConfigEntry => Array.isArray(e.actions) && e.actions.length > 0)\n\nexport const inboxActionConfigEntries = entries\nexport const inboxActions: InboxActionDefinition[] = entries.flatMap((e) => e.actions)\n\nconst actionTypeMap = new Map(inboxActions.map((a) => [a.type, a]))\nexport function getInboxAction(type: string): InboxActionDefinition | undefined {\n return actionTypeMap.get(type)\n}\nexport function getRegisteredActionTypes(): string[] {\n return Array.from(actionTypeMap.keys())\n}\n`\n writeGeneratedFile({ outFile: inboxActionsOutFile, checksumFile: inboxActionsChecksumFile, content: inboxActionsOutput, structureChecksum, result, quiet })\n\n const interceptorEntriesLiteral = interceptorConfigs.join(',\\n ')\n const interceptorImportSection = interceptorImports.join('\\n')\n const interceptorsOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { ApiInterceptor } from '@open-mercato/shared/lib/crud/api-interceptor'\n${interceptorImportSection ? `\\n${interceptorImportSection}\\n` : '\\n'}type InterceptorEntry = { moduleId: string; interceptors: ApiInterceptor[] }\n\nexport const interceptorEntries: InterceptorEntry[] = [\n${interceptorEntriesLiteral ? ` ${interceptorEntriesLiteral}\\n` : ''}]\n`\n writeGeneratedFile({ outFile: interceptorsOutFile, checksumFile: interceptorsChecksumFile, content: interceptorsOutput, structureChecksum, result, quiet })\n\n const componentOverrideEntriesLiteral = componentOverrideConfigs.join(',\\n ')\n const componentOverrideImportSection = componentOverrideImports.join('\\n')\n const componentOverridesOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { ComponentOverride } from '@open-mercato/shared/modules/widgets/component-registry'\n${componentOverrideImportSection ? `\\n${componentOverrideImportSection}\\n` : '\\n'}type ComponentOverrideEntry = { moduleId: string; componentOverrides: ComponentOverride[] }\n\nexport const componentOverrideEntries: ComponentOverrideEntry[] = [\n${componentOverrideEntriesLiteral ? ` ${componentOverrideEntriesLiteral}\\n` : ''}]\n`\n writeGeneratedFile({\n outFile: componentOverridesOutFile,\n checksumFile: componentOverridesChecksumFile,\n content: componentOverridesOutput,\n structureChecksum,\n result,\n quiet,\n })\n\n const guardEntriesLiteral = guardConfigs.join(',\\n ')\n const guardImportSection = guardImports.join('\\n')\n const guardsOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { MutationGuard } from '@open-mercato/shared/lib/crud/mutation-guard-registry'\n${guardImportSection ? `\\n${guardImportSection}\\n` : '\\n'}type GuardEntry = { moduleId: string; guards: MutationGuard[] }\n\nexport const guardEntries: GuardEntry[] = [\n${guardEntriesLiteral ? ` ${guardEntriesLiteral}\\n` : ''}]\n`\n writeGeneratedFile({ outFile: guardsOutFile, checksumFile: guardsChecksumFile, content: guardsOutput, structureChecksum, result, quiet })\n\n const commandInterceptorEntriesLiteral = commandInterceptorConfigs.join(',\\n ')\n const commandInterceptorImportSection = commandInterceptorImports.join('\\n')\n const commandInterceptorsOutput = `// AUTO-GENERATED by mercato generate registry\nimport type { CommandInterceptor } from '@open-mercato/shared/lib/commands/command-interceptor'\n${commandInterceptorImportSection ? `\\n${commandInterceptorImportSection}\\n` : '\\n'}type CommandInterceptorEntry = { moduleId: string; interceptors: CommandInterceptor[] }\n\nexport const commandInterceptorEntries: CommandInterceptorEntry[] = [\n${commandInterceptorEntriesLiteral ? ` ${commandInterceptorEntriesLiteral}\\n` : ''}]\n`\n writeGeneratedFile({ outFile: commandInterceptorsOutFile, checksumFile: commandInterceptorsChecksumFile, content: commandInterceptorsOutput, structureChecksum, result, quiet })\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, dashboard widgets\n * Excludes: frontend routes, backend routes, API handlers, 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 // Mutable ref so extracted helper functions can increment the shared counter\n const importIdRef = { value: 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 rawImps = resolver.getModuleImportBase(entry)\n trackedRoots.add(roots.appBase)\n trackedRoots.add(roots.pkgBase)\n\n const isAppModule = entry.from === '@app'\n const appImportBase = isAppModule ? `../../src/modules/${modId}` : rawImps.appBase\n const imps: ModuleImports = { appBase: appImportBase, pkgBase: rawImps.pkgBase }\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 const dashboardWidgets: string[] = []\n let setupImportName: string | null = null\n let customFieldSetsExpr: string = '[]'\n\n // Module metadata: index.ts (overrideable)\n const appIndex = path.join(roots.appBase, 'index.ts')\n const pkgIndex = path.join(roots.pkgBase, 'index.ts')\n const indexTs = fs.existsSync(appIndex) ? appIndex : fs.existsSync(pkgIndex) ? pkgIndex : null\n if (indexTs) {\n infoImportName = `I${importIdRef.value++}_${toVar(modId)}`\n const importPath = indexTs.startsWith(roots.appBase) ? `${appImportBase}/index` : `${imps.pkgBase}/index`\n imports.push(`import * as ${infoImportName} from '${importPath}'`)\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 // Module setup configuration: setup.ts\n {\n const setup = resolveConventionFile(roots, imps, 'setup.ts', 'SETUP', modId, importIdRef, imports)\n if (setup) setupImportName = setup.importName\n }\n\n // Entity extensions: data/extensions.ts\n {\n const ext = resolveConventionFile(roots, imps, 'data/extensions.ts', 'X', modId, importIdRef, imports)\n if (ext) extensionsImportName = ext.importName\n }\n\n // RBAC: acl.ts\n {\n const rootApp = path.join(roots.appBase, 'acl.ts')\n const rootPkg = path.join(roots.pkgBase, 'acl.ts')\n const hasRoot = fs.existsSync(rootApp) || fs.existsSync(rootPkg)\n if (hasRoot) {\n const importName = `ACL_${toVar(modId)}_${importIdRef.value++}`\n const useApp = fs.existsSync(rootApp) ? 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: ce.ts\n {\n const ce = resolveConventionFile(roots, imps, 'ce.ts', 'CE', modId, importIdRef, imports)\n if (ce) customEntitiesImportName = ce.importName\n }\n\n // Vector search configuration: vector.ts\n {\n const vec = resolveConventionFile(roots, imps, 'vector.ts', 'VECTOR', modId, importIdRef, imports)\n if (vec) vectorImportName = vec.importName\n }\n\n // Custom fields: data/fields.ts\n {\n const fields = resolveConventionFile(roots, imps, 'data/fields.ts', 'F', modId, importIdRef, imports)\n if (fields) fieldsImportName = fields.importName\n }\n\n // CLI\n {\n const cliApp = path.join(roots.appBase, 'cli.ts')\n const cliPkg = path.join(roots.pkgBase, 'cli.ts')\n const cliPath = fs.existsSync(cliApp) ? cliApp : fs.existsSync(cliPkg) ? cliPkg : null\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\n // Translations\n translations.push(...processTranslations({\n roots,\n modId,\n appImportBase,\n pkgImportBase: imps.pkgBase,\n imports,\n }))\n\n // Subscribers\n subscribers.push(...processSubscribers({\n roots,\n modId,\n appImportBase,\n pkgImportBase: imps.pkgBase,\n imports,\n importIdRef,\n }))\n\n // Workers\n workers.push(...await processWorkers({\n roots,\n modId,\n appImportBase,\n pkgImportBase: imps.pkgBase,\n imports,\n importIdRef,\n }))\n\n // Build combined customFieldSets expression\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\n {\n const entries = scanDashboardWidgetEntries({\n modId,\n roots,\n appImportBase,\n pkgImportBase: imps.pkgBase,\n })\n for (const entry of entries) {\n dashboardWidgets.push(\n `{ moduleId: '${entry.moduleId}', key: '${entry.key}', source: '${entry.source}', loader: () => import('${entry.importPath}').then((mod) => mod.default ?? mod) }`\n )\n }\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 ${dashboardWidgets.length ? `dashboardWidgets: [${dashboardWidgets.join(', ')}],` : ''}\n ${vectorImportName ? `vector: (${vectorImportName}.default ?? ${vectorImportName}.vectorConfig ?? ${vectorImportName}.config ?? undefined),` : ''}\n ${setupImportName ? `setup: (${setupImportName}.default ?? ${setupImportName}.setup) || 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, injection 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 writeGeneratedFile({ outFile, checksumFile, content: output, structureChecksum, result, quiet })\n\n return result\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAEjB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAgBP,SAAS,2BAA2B,SAKT;AACzB,QAAM,EAAE,OAAO,OAAO,eAAe,cAAc,IAAI;AACvD,Q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E/F,SAAO;AACT;",
|
|
6
6
|
"names": ["entry"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/cli",
|
|
3
|
-
"version": "0.4.6-develop-
|
|
3
|
+
"version": "0.4.6-develop-02aac88968",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@mikro-orm/core": "^6.6.2",
|
|
59
59
|
"@mikro-orm/migrations": "^6.6.2",
|
|
60
60
|
"@mikro-orm/postgresql": "^6.6.2",
|
|
61
|
-
"@open-mercato/shared": "0.4.6-develop-
|
|
61
|
+
"@open-mercato/shared": "0.4.6-develop-02aac88968",
|
|
62
62
|
"pg": "8.16.3",
|
|
63
63
|
"testcontainers": "^11.12.0",
|
|
64
64
|
"typescript": "^5.9.3"
|
|
@@ -245,7 +245,7 @@ function processSubscribers(options: {
|
|
|
245
245
|
imports.push(`import ${importName}, * as ${metaName} from '${importPath}'`)
|
|
246
246
|
const sid = [modId, ...segs, name].filter(Boolean).join(':')
|
|
247
247
|
subscribers.push(
|
|
248
|
-
`{ id: (((${metaName}.metadata) as any)?.id || '${sid}'), event: ((${metaName}.metadata) as any)?.event, persistent: ((${metaName}.metadata) as any)?.persistent, handler: ${importName} }`
|
|
248
|
+
`{ id: (((${metaName}.metadata) as any)?.id || '${sid}'), event: ((${metaName}.metadata) as any)?.event, persistent: ((${metaName}.metadata) as any)?.persistent, sync: ((${metaName}.metadata) as any)?.sync, priority: ((${metaName}.metadata) as any)?.priority, handler: ${importName} }`
|
|
249
249
|
)
|
|
250
250
|
}
|
|
251
251
|
return subscribers
|
|
@@ -413,6 +413,10 @@ export async function generateModuleRegistry(options: ModuleRegistryOptions): Pr
|
|
|
413
413
|
const componentOverridesChecksumFile = path.join(outputDir, 'component-overrides.generated.checksum')
|
|
414
414
|
const inboxActionsOutFile = path.join(outputDir, 'inbox-actions.generated.ts')
|
|
415
415
|
const inboxActionsChecksumFile = path.join(outputDir, 'inbox-actions.generated.checksum')
|
|
416
|
+
const guardsOutFile = path.join(outputDir, 'guards.generated.ts')
|
|
417
|
+
const guardsChecksumFile = path.join(outputDir, 'guards.generated.checksum')
|
|
418
|
+
const commandInterceptorsOutFile = path.join(outputDir, 'command-interceptors.generated.ts')
|
|
419
|
+
const commandInterceptorsChecksumFile = path.join(outputDir, 'command-interceptors.generated.checksum')
|
|
416
420
|
|
|
417
421
|
const enabled = resolver.loadEnabledModules()
|
|
418
422
|
const imports: string[] = []
|
|
@@ -450,6 +454,10 @@ export async function generateModuleRegistry(options: ModuleRegistryOptions): Pr
|
|
|
450
454
|
const componentOverrideImports: string[] = []
|
|
451
455
|
const inboxActionsConfigs: string[] = []
|
|
452
456
|
const inboxActionsImports: string[] = []
|
|
457
|
+
const guardConfigs: string[] = []
|
|
458
|
+
const guardImports: string[] = []
|
|
459
|
+
const commandInterceptorConfigs: string[] = []
|
|
460
|
+
const commandInterceptorImports: string[] = []
|
|
453
461
|
|
|
454
462
|
for (const entry of enabled) {
|
|
455
463
|
const modId = entry.id
|
|
@@ -705,6 +713,26 @@ export async function generateModuleRegistry(options: ModuleRegistryOptions): Pr
|
|
|
705
713
|
}
|
|
706
714
|
}
|
|
707
715
|
|
|
716
|
+
// 10e. Mutation guards: data/guards.ts
|
|
717
|
+
processStandaloneConfig({
|
|
718
|
+
roots, imps, modId, importIdRef,
|
|
719
|
+
relativePath: 'data/guards.ts',
|
|
720
|
+
prefix: 'GUARDS',
|
|
721
|
+
standaloneImports: guardImports,
|
|
722
|
+
standaloneConfigs: guardConfigs,
|
|
723
|
+
configExpr: (n, id) => `{ moduleId: '${id}', guards: ((${n} as any).guards ?? (${n} as any).default ?? []) }`,
|
|
724
|
+
})
|
|
725
|
+
|
|
726
|
+
// 10f. Command interceptors: commands/interceptors.ts
|
|
727
|
+
processStandaloneConfig({
|
|
728
|
+
roots, imps, modId, importIdRef,
|
|
729
|
+
relativePath: 'commands/interceptors.ts',
|
|
730
|
+
prefix: 'CMD_INTERCEPTORS',
|
|
731
|
+
standaloneImports: commandInterceptorImports,
|
|
732
|
+
standaloneConfigs: commandInterceptorConfigs,
|
|
733
|
+
configExpr: (n, id) => `{ moduleId: '${id}', interceptors: ((${n} as any).interceptors ?? (${n} as any).default ?? []) }`,
|
|
734
|
+
})
|
|
735
|
+
|
|
708
736
|
// 11. Setup: setup.ts
|
|
709
737
|
{
|
|
710
738
|
const setup = resolveConventionFile(roots, imps, 'setup.ts', 'SETUP', modId, importIdRef, imports)
|
|
@@ -1312,6 +1340,28 @@ ${componentOverrideEntriesLiteral ? ` ${componentOverrideEntriesLiteral}\n` : '
|
|
|
1312
1340
|
quiet,
|
|
1313
1341
|
})
|
|
1314
1342
|
|
|
1343
|
+
const guardEntriesLiteral = guardConfigs.join(',\n ')
|
|
1344
|
+
const guardImportSection = guardImports.join('\n')
|
|
1345
|
+
const guardsOutput = `// AUTO-GENERATED by mercato generate registry
|
|
1346
|
+
import type { MutationGuard } from '@open-mercato/shared/lib/crud/mutation-guard-registry'
|
|
1347
|
+
${guardImportSection ? `\n${guardImportSection}\n` : '\n'}type GuardEntry = { moduleId: string; guards: MutationGuard[] }
|
|
1348
|
+
|
|
1349
|
+
export const guardEntries: GuardEntry[] = [
|
|
1350
|
+
${guardEntriesLiteral ? ` ${guardEntriesLiteral}\n` : ''}]
|
|
1351
|
+
`
|
|
1352
|
+
writeGeneratedFile({ outFile: guardsOutFile, checksumFile: guardsChecksumFile, content: guardsOutput, structureChecksum, result, quiet })
|
|
1353
|
+
|
|
1354
|
+
const commandInterceptorEntriesLiteral = commandInterceptorConfigs.join(',\n ')
|
|
1355
|
+
const commandInterceptorImportSection = commandInterceptorImports.join('\n')
|
|
1356
|
+
const commandInterceptorsOutput = `// AUTO-GENERATED by mercato generate registry
|
|
1357
|
+
import type { CommandInterceptor } from '@open-mercato/shared/lib/commands/command-interceptor'
|
|
1358
|
+
${commandInterceptorImportSection ? `\n${commandInterceptorImportSection}\n` : '\n'}type CommandInterceptorEntry = { moduleId: string; interceptors: CommandInterceptor[] }
|
|
1359
|
+
|
|
1360
|
+
export const commandInterceptorEntries: CommandInterceptorEntry[] = [
|
|
1361
|
+
${commandInterceptorEntriesLiteral ? ` ${commandInterceptorEntriesLiteral}\n` : ''}]
|
|
1362
|
+
`
|
|
1363
|
+
writeGeneratedFile({ outFile: commandInterceptorsOutFile, checksumFile: commandInterceptorsChecksumFile, content: commandInterceptorsOutput, structureChecksum, result, quiet })
|
|
1364
|
+
|
|
1315
1365
|
return result
|
|
1316
1366
|
}
|
|
1317
1367
|
|