@open-mercato/cli 0.4.5-develop-5191db4ef3 → 0.4.5-develop-9f9549ebc8
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.
|
@@ -268,6 +268,12 @@ async function generateModuleRegistry(options) {
|
|
|
268
268
|
const notificationsChecksumFile = path.join(outputDir, "notifications.generated.checksum");
|
|
269
269
|
const notificationsClientOutFile = path.join(outputDir, "notifications.client.generated.ts");
|
|
270
270
|
const notificationsClientChecksumFile = path.join(outputDir, "notifications.client.generated.checksum");
|
|
271
|
+
const messageTypesOutFile = path.join(outputDir, "message-types.generated.ts");
|
|
272
|
+
const messageTypesChecksumFile = path.join(outputDir, "message-types.generated.checksum");
|
|
273
|
+
const messageObjectsOutFile = path.join(outputDir, "message-objects.generated.ts");
|
|
274
|
+
const messageObjectsChecksumFile = path.join(outputDir, "message-objects.generated.checksum");
|
|
275
|
+
const messagesClientOutFile = path.join(outputDir, "messages.client.generated.ts");
|
|
276
|
+
const messagesClientChecksumFile = path.join(outputDir, "messages.client.generated.checksum");
|
|
271
277
|
const aiToolsOutFile = path.join(outputDir, "ai-tools.generated.ts");
|
|
272
278
|
const aiToolsChecksumFile = path.join(outputDir, "ai-tools.generated.checksum");
|
|
273
279
|
const eventsOutFile = path.join(outputDir, "events.generated.ts");
|
|
@@ -291,6 +297,10 @@ async function generateModuleRegistry(options) {
|
|
|
291
297
|
const notificationImports = [];
|
|
292
298
|
const notificationClientTypes = [];
|
|
293
299
|
const notificationClientImports = [];
|
|
300
|
+
const messageTypeEntries = [];
|
|
301
|
+
const messageTypeImports = [];
|
|
302
|
+
const messageObjectTypeEntries = [];
|
|
303
|
+
const messageObjectTypeImports = [];
|
|
294
304
|
const aiToolsConfigs = [];
|
|
295
305
|
const aiToolsImports = [];
|
|
296
306
|
const eventsConfigs = [];
|
|
@@ -401,6 +411,28 @@ async function generateModuleRegistry(options) {
|
|
|
401
411
|
);
|
|
402
412
|
}
|
|
403
413
|
}
|
|
414
|
+
{
|
|
415
|
+
const resolved = resolveModuleFile(roots, imps, "message-types.ts");
|
|
416
|
+
if (resolved) {
|
|
417
|
+
const importName = `MSG_TYPES_${toVar(modId)}_${importIdRef.value++}`;
|
|
418
|
+
const importStmt = `import * as ${importName} from '${resolved.importPath}'`;
|
|
419
|
+
messageTypeImports.push(importStmt);
|
|
420
|
+
messageTypeEntries.push(
|
|
421
|
+
`{ moduleId: '${modId}', types: ((${importName}.default ?? (${importName} as any).messageTypes ?? (${importName} as any).types ?? []) as MessageTypeDefinition[]) }`
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
{
|
|
426
|
+
const resolved = resolveModuleFile(roots, imps, "message-objects.ts");
|
|
427
|
+
if (resolved) {
|
|
428
|
+
const importName = `MSG_OBJECTS_${toVar(modId)}_${importIdRef.value++}`;
|
|
429
|
+
const importStmt = `import * as ${importName} from '${resolved.importPath}'`;
|
|
430
|
+
messageObjectTypeImports.push(importStmt);
|
|
431
|
+
messageObjectTypeEntries.push(
|
|
432
|
+
`{ moduleId: '${modId}', types: ((${importName}.default ?? (${importName} as any).messageObjectTypes ?? (${importName} as any).objectTypes ?? (${importName} as any).types ?? []) as MessageObjectTypeDefinition[]) }`
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
404
436
|
{
|
|
405
437
|
const resolved = resolveModuleFile(roots, imps, "notifications.client.ts");
|
|
406
438
|
if (resolved) {
|
|
@@ -766,6 +798,144 @@ export const notificationRenderers = renderers
|
|
|
766
798
|
export function getNotificationRenderers(): NotificationRenderers {
|
|
767
799
|
return renderers
|
|
768
800
|
}
|
|
801
|
+
`;
|
|
802
|
+
const messageTypeEntriesLiteral = messageTypeEntries.join(",\n ");
|
|
803
|
+
const messageTypeImportSection = messageTypeImports.join("\n");
|
|
804
|
+
const messageTypesOutput = `// AUTO-GENERATED by mercato generate registry
|
|
805
|
+
import type { MessageTypeDefinition } from '@open-mercato/shared/modules/messages/types'
|
|
806
|
+
${messageTypeImportSection ? `
|
|
807
|
+
${messageTypeImportSection}
|
|
808
|
+
` : "\n"}type MessageTypeEntry = { moduleId: string; types: MessageTypeDefinition[] }
|
|
809
|
+
|
|
810
|
+
const entriesRaw: MessageTypeEntry[] = [
|
|
811
|
+
${messageTypeEntriesLiteral ? ` ${messageTypeEntriesLiteral}
|
|
812
|
+
` : ""}]
|
|
813
|
+
|
|
814
|
+
const allTypes = entriesRaw.flatMap((entry) => entry.types)
|
|
815
|
+
|
|
816
|
+
export const messageTypeEntries = entriesRaw
|
|
817
|
+
export const messageTypes = allTypes
|
|
818
|
+
|
|
819
|
+
export function getMessageTypes(): MessageTypeDefinition[] {
|
|
820
|
+
return allTypes
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
export function getMessageType(type: string): MessageTypeDefinition | undefined {
|
|
824
|
+
return allTypes.find((entry) => entry.type === type)
|
|
825
|
+
}
|
|
826
|
+
`;
|
|
827
|
+
const messageObjectEntriesLiteral = messageObjectTypeEntries.join(",\n ");
|
|
828
|
+
const messageObjectImportSection = messageObjectTypeImports.join("\n");
|
|
829
|
+
const messageObjectsOutput = `// AUTO-GENERATED by mercato generate registry
|
|
830
|
+
import type { MessageObjectTypeDefinition } from '@open-mercato/shared/modules/messages/types'
|
|
831
|
+
${messageObjectImportSection ? `
|
|
832
|
+
${messageObjectImportSection}
|
|
833
|
+
` : "\n"}type MessageObjectTypeEntry = { moduleId: string; types: MessageObjectTypeDefinition[] }
|
|
834
|
+
|
|
835
|
+
const entriesRaw: MessageObjectTypeEntry[] = [
|
|
836
|
+
${messageObjectEntriesLiteral ? ` ${messageObjectEntriesLiteral}
|
|
837
|
+
` : ""}]
|
|
838
|
+
|
|
839
|
+
const allTypes = entriesRaw.flatMap((entry) => entry.types)
|
|
840
|
+
|
|
841
|
+
export const messageObjectTypeEntries = entriesRaw
|
|
842
|
+
export const messageObjectTypes = allTypes
|
|
843
|
+
|
|
844
|
+
export function getMessageObjectTypes(): MessageObjectTypeDefinition[] {
|
|
845
|
+
return allTypes
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
export function getMessageObjectType(module: string, entityType: string): MessageObjectTypeDefinition | undefined {
|
|
849
|
+
return allTypes.find((entry) => entry.module === module && entry.entityType === entityType)
|
|
850
|
+
}
|
|
851
|
+
`;
|
|
852
|
+
const messagesClientOutput = `// AUTO-GENERATED by mercato generate registry
|
|
853
|
+
import type { ComponentType } from 'react'
|
|
854
|
+
import type {
|
|
855
|
+
MessageTypeDefinition,
|
|
856
|
+
MessageObjectTypeDefinition,
|
|
857
|
+
MessageListItemProps,
|
|
858
|
+
MessageContentProps,
|
|
859
|
+
MessageActionsProps,
|
|
860
|
+
ObjectDetailProps,
|
|
861
|
+
ObjectPreviewProps,
|
|
862
|
+
} from '@open-mercato/shared/modules/messages/types'
|
|
863
|
+
${messageTypeImportSection ? `
|
|
864
|
+
${messageTypeImportSection}
|
|
865
|
+
` : "\n"}${messageObjectImportSection ? `
|
|
866
|
+
${messageObjectImportSection}
|
|
867
|
+
` : ""}type MessageTypeEntry = { moduleId: string; types: MessageTypeDefinition[] }
|
|
868
|
+
type MessageObjectTypeEntry = { moduleId: string; types: MessageObjectTypeDefinition[] }
|
|
869
|
+
|
|
870
|
+
export type MessageListItemRenderers = Record<string, ComponentType<MessageListItemProps>>
|
|
871
|
+
export type MessageContentRenderers = Record<string, ComponentType<MessageContentProps>>
|
|
872
|
+
export type MessageActionsRenderers = Record<string, ComponentType<MessageActionsProps>>
|
|
873
|
+
export type MessageObjectDetailRenderers = Record<string, ComponentType<ObjectDetailProps>>
|
|
874
|
+
export type MessageObjectPreviewRenderers = Record<string, ComponentType<ObjectPreviewProps>>
|
|
875
|
+
|
|
876
|
+
export type MessageUiComponentRegistry = {
|
|
877
|
+
listItemComponents: MessageListItemRenderers
|
|
878
|
+
contentComponents: MessageContentRenderers
|
|
879
|
+
actionsComponents: MessageActionsRenderers
|
|
880
|
+
objectDetailComponents: MessageObjectDetailRenderers
|
|
881
|
+
objectPreviewComponents: MessageObjectPreviewRenderers
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
const messageTypeEntriesRaw: MessageTypeEntry[] = [
|
|
885
|
+
${messageTypeEntriesLiteral ? ` ${messageTypeEntriesLiteral}
|
|
886
|
+
` : ""}]
|
|
887
|
+
const messageObjectTypeEntriesRaw: MessageObjectTypeEntry[] = [
|
|
888
|
+
${messageObjectEntriesLiteral ? ` ${messageObjectEntriesLiteral}
|
|
889
|
+
` : ""}]
|
|
890
|
+
|
|
891
|
+
const allMessageTypes = messageTypeEntriesRaw.flatMap((entry) => entry.types)
|
|
892
|
+
const allMessageObjectTypes = messageObjectTypeEntriesRaw.flatMap((entry) => entry.types)
|
|
893
|
+
|
|
894
|
+
const listItemComponents: MessageListItemRenderers = Object.fromEntries(
|
|
895
|
+
allMessageTypes
|
|
896
|
+
.filter((typeDef) => Boolean(typeDef.ui?.listItemComponent) && Boolean(typeDef.ListItemComponent))
|
|
897
|
+
.map((typeDef) => [typeDef.ui!.listItemComponent!, typeDef.ListItemComponent!]),
|
|
898
|
+
)
|
|
899
|
+
|
|
900
|
+
const contentComponents: MessageContentRenderers = Object.fromEntries(
|
|
901
|
+
allMessageTypes
|
|
902
|
+
.filter((typeDef) => Boolean(typeDef.ui?.contentComponent) && Boolean(typeDef.ContentComponent))
|
|
903
|
+
.map((typeDef) => [typeDef.ui!.contentComponent!, typeDef.ContentComponent!]),
|
|
904
|
+
)
|
|
905
|
+
|
|
906
|
+
const actionsComponents: MessageActionsRenderers = Object.fromEntries(
|
|
907
|
+
allMessageTypes
|
|
908
|
+
.filter((typeDef) => Boolean(typeDef.ui?.actionsComponent) && Boolean(typeDef.ActionsComponent))
|
|
909
|
+
.map((typeDef) => [typeDef.ui!.actionsComponent!, typeDef.ActionsComponent!]),
|
|
910
|
+
)
|
|
911
|
+
|
|
912
|
+
const objectDetailComponents: MessageObjectDetailRenderers = Object.fromEntries(
|
|
913
|
+
allMessageObjectTypes
|
|
914
|
+
.filter((typeDef) => Boolean(typeDef.DetailComponent))
|
|
915
|
+
.map((typeDef) => [\`\${typeDef.module}:\${typeDef.entityType}\`, typeDef.DetailComponent!]),
|
|
916
|
+
)
|
|
917
|
+
|
|
918
|
+
const objectPreviewComponents: MessageObjectPreviewRenderers = Object.fromEntries(
|
|
919
|
+
allMessageObjectTypes
|
|
920
|
+
.filter((typeDef) => Boolean(typeDef.PreviewComponent))
|
|
921
|
+
.map((typeDef) => [\`\${typeDef.module}:\${typeDef.entityType}\`, typeDef.PreviewComponent!]),
|
|
922
|
+
)
|
|
923
|
+
|
|
924
|
+
const registry: MessageUiComponentRegistry = {
|
|
925
|
+
listItemComponents,
|
|
926
|
+
contentComponents,
|
|
927
|
+
actionsComponents,
|
|
928
|
+
objectDetailComponents,
|
|
929
|
+
objectPreviewComponents,
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
export const messageClientTypeEntries = messageTypeEntriesRaw
|
|
933
|
+
export const messageClientObjectTypeEntries = messageObjectTypeEntriesRaw
|
|
934
|
+
export const messageUiComponentRegistry = registry
|
|
935
|
+
|
|
936
|
+
export function getMessageUiComponentRegistry(): MessageUiComponentRegistry {
|
|
937
|
+
return registry
|
|
938
|
+
}
|
|
769
939
|
`;
|
|
770
940
|
{
|
|
771
941
|
const enabledIds = new Set(enabled.map((e) => e.id));
|
|
@@ -831,6 +1001,9 @@ export const allAiTools = aiToolConfigEntries.flatMap(e => e.tools)
|
|
|
831
1001
|
writeGeneratedFile({ outFile: aiToolsOutFile, checksumFile: aiToolsChecksumFile, content: aiToolsOutput, structureChecksum, result, quiet });
|
|
832
1002
|
writeGeneratedFile({ outFile: notificationsOutFile, checksumFile: notificationsChecksumFile, content: notificationsOutput, structureChecksum, result, quiet });
|
|
833
1003
|
writeGeneratedFile({ outFile: notificationsClientOutFile, checksumFile: notificationsClientChecksumFile, content: notificationsClientOutput, structureChecksum, result, quiet });
|
|
1004
|
+
writeGeneratedFile({ outFile: messageTypesOutFile, checksumFile: messageTypesChecksumFile, content: messageTypesOutput, structureChecksum, result, quiet });
|
|
1005
|
+
writeGeneratedFile({ outFile: messageObjectsOutFile, checksumFile: messageObjectsChecksumFile, content: messageObjectsOutput, structureChecksum, result, quiet });
|
|
1006
|
+
writeGeneratedFile({ outFile: messagesClientOutFile, checksumFile: messagesClientChecksumFile, content: messagesClientOutput, structureChecksum, result, quiet });
|
|
834
1007
|
writeGeneratedFile({ outFile: eventsOutFile, checksumFile: eventsChecksumFile, content: eventsOutput, structureChecksum, result, quiet });
|
|
835
1008
|
writeGeneratedFile({ outFile: analyticsOutFile, checksumFile: analyticsChecksumFile, content: analyticsOutput, structureChecksum, result, quiet });
|
|
836
1009
|
writeGeneratedFile({ outFile: transFieldsOutFile, checksumFile: transFieldsChecksumFile, content: transFieldsOutput, structureChecksum, result, quiet });
|
|
@@ -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\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 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\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 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\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 {\n const resolved = resolveModuleFile(roots, imps, 'notifications.ts')\n if (resolved) {\n const importName = `NOTIF_${toVar(modId)}_${importIdRef.value++}`\n const importStmt = `import * as ${importName} from '${resolved.importPath}'`\n notificationImports.push(importStmt)\n notificationTypes.push(\n `{ moduleId: '${modId}', types: (${importName}.default ?? ${importName}.notificationTypes ?? []) }`\n )\n }\n }\n\n // Notification client renderers: module root notifications.client.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 {\n const resolved = resolveModuleFile(roots, imps, 'ai-tools.ts')\n if (resolved) {\n const importName = `AI_TOOLS_${toVar(modId)}_${importIdRef.value++}`\n const importStmt = `import * as ${importName} from '${resolved.importPath}'`\n aiToolsImports.push(importStmt)\n aiToolsConfigs.push(\n `{ moduleId: '${modId}', tools: (${importName}.aiTools ?? ${importName}.default ?? []) }`\n )\n }\n }\n\n // 9. Events: events.ts\n {\n const resolved = resolveModuleFile(roots, imps, 'events.ts')\n if (resolved) {\n const importName = `EVENTS_${toVar(modId)}_${importIdRef.value++}`\n const importStmt = `import * as ${importName} from '${resolved.importPath}'`\n imports.push(importStmt)\n eventsImports.push(importStmt)\n eventsImportName = importName\n }\n }\n\n // 10. Analytics: analytics.ts\n {\n const resolved = resolveModuleFile(roots, imps, 'analytics.ts')\n if (resolved) {\n const importName = `ANALYTICS_${toVar(modId)}_${importIdRef.value++}`\n const importStmt = `import * as ${importName} from '${resolved.importPath}'`\n imports.push(importStmt)\n analyticsImports.push(importStmt)\n analyticsImportName = importName\n }\n }\n\n // Translatable fields: module root translations.ts\n let transFieldsImportName: string | null = null\n {\n const resolved = resolveModuleFile(roots, imps, 'translations.ts')\n if (resolved) {\n const importName = `TRANS_FIELDS_${toVar(modId)}_${importIdRef.value++}`\n const importStmt = `import * as ${importName} from '${resolved.importPath}'`\n imports.push(importStmt)\n transFieldsImports.push(importStmt)\n transFieldsImportName = importName\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 if (eventsImportName) {\n eventsConfigs.push(`{ moduleId: '${modId}', config: (${eventsImportName}.default ?? ${eventsImportName}.eventsConfig ?? null) as EventModuleConfigBase | null }`)\n }\n\n if (analyticsImportName) {\n analyticsConfigs.push(`{ moduleId: '${modId}', config: (${analyticsImportName}.default ?? ${analyticsImportName}.analyticsConfig ?? ${analyticsImportName}.config ?? null) }`)\n }\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 // 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: 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 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,EAC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": ["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\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\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\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 {\n const resolved = resolveModuleFile(roots, imps, 'notifications.ts')\n if (resolved) {\n const importName = `NOTIF_${toVar(modId)}_${importIdRef.value++}`\n const importStmt = `import * as ${importName} from '${resolved.importPath}'`\n notificationImports.push(importStmt)\n notificationTypes.push(\n `{ moduleId: '${modId}', types: (${importName}.default ?? ${importName}.notificationTypes ?? []) }`\n )\n }\n }\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 {\n const resolved = resolveModuleFile(roots, imps, 'ai-tools.ts')\n if (resolved) {\n const importName = `AI_TOOLS_${toVar(modId)}_${importIdRef.value++}`\n const importStmt = `import * as ${importName} from '${resolved.importPath}'`\n aiToolsImports.push(importStmt)\n aiToolsConfigs.push(\n `{ moduleId: '${modId}', tools: (${importName}.aiTools ?? ${importName}.default ?? []) }`\n )\n }\n }\n\n // 9. Events: events.ts\n {\n const resolved = resolveModuleFile(roots, imps, 'events.ts')\n if (resolved) {\n const importName = `EVENTS_${toVar(modId)}_${importIdRef.value++}`\n const importStmt = `import * as ${importName} from '${resolved.importPath}'`\n imports.push(importStmt)\n eventsImports.push(importStmt)\n eventsImportName = importName\n }\n }\n\n // 10. Analytics: analytics.ts\n {\n const resolved = resolveModuleFile(roots, imps, 'analytics.ts')\n if (resolved) {\n const importName = `ANALYTICS_${toVar(modId)}_${importIdRef.value++}`\n const importStmt = `import * as ${importName} from '${resolved.importPath}'`\n imports.push(importStmt)\n analyticsImports.push(importStmt)\n analyticsImportName = importName\n }\n }\n\n // Translatable fields: module root translations.ts\n let transFieldsImportName: string | null = null\n {\n const resolved = resolveModuleFile(roots, imps, 'translations.ts')\n if (resolved) {\n const importName = `TRANS_FIELDS_${toVar(modId)}_${importIdRef.value++}`\n const importStmt = `import * as ${importName} from '${resolved.importPath}'`\n imports.push(importStmt)\n transFieldsImports.push(importStmt)\n transFieldsImportName = importName\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 if (eventsImportName) {\n eventsConfigs.push(`{ moduleId: '${modId}', config: (${eventsImportName}.default ?? ${eventsImportName}.eventsConfig ?? null) as EventModuleConfigBase | null }`)\n }\n\n if (analyticsImportName) {\n analyticsConfigs.push(`{ moduleId: '${modId}', config: (${analyticsImportName}.default ?? ${analyticsImportName}.analyticsConfig ?? ${analyticsImportName}.config ?? null) }`)\n }\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'\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\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 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"],
|
|
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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;",
|
|
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.5-develop-
|
|
3
|
+
"version": "0.4.5-develop-9f9549ebc8",
|
|
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.5-develop-
|
|
61
|
+
"@open-mercato/shared": "0.4.5-develop-9f9549ebc8",
|
|
62
62
|
"pg": "8.16.3",
|
|
63
63
|
"testcontainers": "^11.12.0",
|
|
64
64
|
"typescript": "^5.9.3"
|
|
@@ -361,6 +361,12 @@ export async function generateModuleRegistry(options: ModuleRegistryOptions): Pr
|
|
|
361
361
|
const notificationsChecksumFile = path.join(outputDir, 'notifications.generated.checksum')
|
|
362
362
|
const notificationsClientOutFile = path.join(outputDir, 'notifications.client.generated.ts')
|
|
363
363
|
const notificationsClientChecksumFile = path.join(outputDir, 'notifications.client.generated.checksum')
|
|
364
|
+
const messageTypesOutFile = path.join(outputDir, 'message-types.generated.ts')
|
|
365
|
+
const messageTypesChecksumFile = path.join(outputDir, 'message-types.generated.checksum')
|
|
366
|
+
const messageObjectsOutFile = path.join(outputDir, 'message-objects.generated.ts')
|
|
367
|
+
const messageObjectsChecksumFile = path.join(outputDir, 'message-objects.generated.checksum')
|
|
368
|
+
const messagesClientOutFile = path.join(outputDir, 'messages.client.generated.ts')
|
|
369
|
+
const messagesClientChecksumFile = path.join(outputDir, 'messages.client.generated.checksum')
|
|
364
370
|
const aiToolsOutFile = path.join(outputDir, 'ai-tools.generated.ts')
|
|
365
371
|
const aiToolsChecksumFile = path.join(outputDir, 'ai-tools.generated.checksum')
|
|
366
372
|
const eventsOutFile = path.join(outputDir, 'events.generated.ts')
|
|
@@ -386,6 +392,10 @@ export async function generateModuleRegistry(options: ModuleRegistryOptions): Pr
|
|
|
386
392
|
const notificationImports: string[] = []
|
|
387
393
|
const notificationClientTypes: string[] = []
|
|
388
394
|
const notificationClientImports: string[] = []
|
|
395
|
+
const messageTypeEntries: string[] = []
|
|
396
|
+
const messageTypeImports: string[] = []
|
|
397
|
+
const messageObjectTypeEntries: string[] = []
|
|
398
|
+
const messageObjectTypeImports: string[] = []
|
|
389
399
|
const aiToolsConfigs: string[] = []
|
|
390
400
|
const aiToolsImports: string[] = []
|
|
391
401
|
const eventsConfigs: string[] = []
|
|
@@ -517,7 +527,33 @@ export async function generateModuleRegistry(options: ModuleRegistryOptions): Pr
|
|
|
517
527
|
}
|
|
518
528
|
}
|
|
519
529
|
|
|
520
|
-
//
|
|
530
|
+
// Message types: module root message-types.ts
|
|
531
|
+
{
|
|
532
|
+
const resolved = resolveModuleFile(roots, imps, 'message-types.ts')
|
|
533
|
+
if (resolved) {
|
|
534
|
+
const importName = `MSG_TYPES_${toVar(modId)}_${importIdRef.value++}`
|
|
535
|
+
const importStmt = `import * as ${importName} from '${resolved.importPath}'`
|
|
536
|
+
messageTypeImports.push(importStmt)
|
|
537
|
+
messageTypeEntries.push(
|
|
538
|
+
`{ moduleId: '${modId}', types: ((${importName}.default ?? (${importName} as any).messageTypes ?? (${importName} as any).types ?? []) as MessageTypeDefinition[]) }`
|
|
539
|
+
)
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
// Message object types: module root message-objects.ts
|
|
544
|
+
{
|
|
545
|
+
const resolved = resolveModuleFile(roots, imps, 'message-objects.ts')
|
|
546
|
+
if (resolved) {
|
|
547
|
+
const importName = `MSG_OBJECTS_${toVar(modId)}_${importIdRef.value++}`
|
|
548
|
+
const importStmt = `import * as ${importName} from '${resolved.importPath}'`
|
|
549
|
+
messageObjectTypeImports.push(importStmt)
|
|
550
|
+
messageObjectTypeEntries.push(
|
|
551
|
+
`{ moduleId: '${modId}', types: ((${importName}.default ?? (${importName} as any).messageObjectTypes ?? (${importName} as any).objectTypes ?? (${importName} as any).types ?? []) as MessageObjectTypeDefinition[]) }`
|
|
552
|
+
)
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
// AI Tools: module root ai-tools.ts
|
|
521
557
|
{
|
|
522
558
|
const resolved = resolveModuleFile(roots, imps, 'notifications.client.ts')
|
|
523
559
|
if (resolved) {
|
|
@@ -907,6 +943,134 @@ export const notificationRenderers = renderers
|
|
|
907
943
|
export function getNotificationRenderers(): NotificationRenderers {
|
|
908
944
|
return renderers
|
|
909
945
|
}
|
|
946
|
+
`
|
|
947
|
+
|
|
948
|
+
const messageTypeEntriesLiteral = messageTypeEntries.join(',\n ')
|
|
949
|
+
const messageTypeImportSection = messageTypeImports.join('\n')
|
|
950
|
+
const messageTypesOutput = `// AUTO-GENERATED by mercato generate registry
|
|
951
|
+
import type { MessageTypeDefinition } from '@open-mercato/shared/modules/messages/types'
|
|
952
|
+
${messageTypeImportSection ? `\n${messageTypeImportSection}\n` : '\n'}type MessageTypeEntry = { moduleId: string; types: MessageTypeDefinition[] }
|
|
953
|
+
|
|
954
|
+
const entriesRaw: MessageTypeEntry[] = [
|
|
955
|
+
${messageTypeEntriesLiteral ? ` ${messageTypeEntriesLiteral}\n` : ''}]
|
|
956
|
+
|
|
957
|
+
const allTypes = entriesRaw.flatMap((entry) => entry.types)
|
|
958
|
+
|
|
959
|
+
export const messageTypeEntries = entriesRaw
|
|
960
|
+
export const messageTypes = allTypes
|
|
961
|
+
|
|
962
|
+
export function getMessageTypes(): MessageTypeDefinition[] {
|
|
963
|
+
return allTypes
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
export function getMessageType(type: string): MessageTypeDefinition | undefined {
|
|
967
|
+
return allTypes.find((entry) => entry.type === type)
|
|
968
|
+
}
|
|
969
|
+
`
|
|
970
|
+
|
|
971
|
+
const messageObjectEntriesLiteral = messageObjectTypeEntries.join(',\n ')
|
|
972
|
+
const messageObjectImportSection = messageObjectTypeImports.join('\n')
|
|
973
|
+
const messageObjectsOutput = `// AUTO-GENERATED by mercato generate registry
|
|
974
|
+
import type { MessageObjectTypeDefinition } from '@open-mercato/shared/modules/messages/types'
|
|
975
|
+
${messageObjectImportSection ? `\n${messageObjectImportSection}\n` : '\n'}type MessageObjectTypeEntry = { moduleId: string; types: MessageObjectTypeDefinition[] }
|
|
976
|
+
|
|
977
|
+
const entriesRaw: MessageObjectTypeEntry[] = [
|
|
978
|
+
${messageObjectEntriesLiteral ? ` ${messageObjectEntriesLiteral}\n` : ''}]
|
|
979
|
+
|
|
980
|
+
const allTypes = entriesRaw.flatMap((entry) => entry.types)
|
|
981
|
+
|
|
982
|
+
export const messageObjectTypeEntries = entriesRaw
|
|
983
|
+
export const messageObjectTypes = allTypes
|
|
984
|
+
|
|
985
|
+
export function getMessageObjectTypes(): MessageObjectTypeDefinition[] {
|
|
986
|
+
return allTypes
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
export function getMessageObjectType(module: string, entityType: string): MessageObjectTypeDefinition | undefined {
|
|
990
|
+
return allTypes.find((entry) => entry.module === module && entry.entityType === entityType)
|
|
991
|
+
}
|
|
992
|
+
`
|
|
993
|
+
const messagesClientOutput = `// AUTO-GENERATED by mercato generate registry
|
|
994
|
+
import type { ComponentType } from 'react'
|
|
995
|
+
import type {
|
|
996
|
+
MessageTypeDefinition,
|
|
997
|
+
MessageObjectTypeDefinition,
|
|
998
|
+
MessageListItemProps,
|
|
999
|
+
MessageContentProps,
|
|
1000
|
+
MessageActionsProps,
|
|
1001
|
+
ObjectDetailProps,
|
|
1002
|
+
ObjectPreviewProps,
|
|
1003
|
+
} from '@open-mercato/shared/modules/messages/types'
|
|
1004
|
+
${messageTypeImportSection ? `\n${messageTypeImportSection}\n` : '\n'}${messageObjectImportSection ? `\n${messageObjectImportSection}\n` : ''}type MessageTypeEntry = { moduleId: string; types: MessageTypeDefinition[] }
|
|
1005
|
+
type MessageObjectTypeEntry = { moduleId: string; types: MessageObjectTypeDefinition[] }
|
|
1006
|
+
|
|
1007
|
+
export type MessageListItemRenderers = Record<string, ComponentType<MessageListItemProps>>
|
|
1008
|
+
export type MessageContentRenderers = Record<string, ComponentType<MessageContentProps>>
|
|
1009
|
+
export type MessageActionsRenderers = Record<string, ComponentType<MessageActionsProps>>
|
|
1010
|
+
export type MessageObjectDetailRenderers = Record<string, ComponentType<ObjectDetailProps>>
|
|
1011
|
+
export type MessageObjectPreviewRenderers = Record<string, ComponentType<ObjectPreviewProps>>
|
|
1012
|
+
|
|
1013
|
+
export type MessageUiComponentRegistry = {
|
|
1014
|
+
listItemComponents: MessageListItemRenderers
|
|
1015
|
+
contentComponents: MessageContentRenderers
|
|
1016
|
+
actionsComponents: MessageActionsRenderers
|
|
1017
|
+
objectDetailComponents: MessageObjectDetailRenderers
|
|
1018
|
+
objectPreviewComponents: MessageObjectPreviewRenderers
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
const messageTypeEntriesRaw: MessageTypeEntry[] = [
|
|
1022
|
+
${messageTypeEntriesLiteral ? ` ${messageTypeEntriesLiteral}\n` : ''}]
|
|
1023
|
+
const messageObjectTypeEntriesRaw: MessageObjectTypeEntry[] = [
|
|
1024
|
+
${messageObjectEntriesLiteral ? ` ${messageObjectEntriesLiteral}\n` : ''}]
|
|
1025
|
+
|
|
1026
|
+
const allMessageTypes = messageTypeEntriesRaw.flatMap((entry) => entry.types)
|
|
1027
|
+
const allMessageObjectTypes = messageObjectTypeEntriesRaw.flatMap((entry) => entry.types)
|
|
1028
|
+
|
|
1029
|
+
const listItemComponents: MessageListItemRenderers = Object.fromEntries(
|
|
1030
|
+
allMessageTypes
|
|
1031
|
+
.filter((typeDef) => Boolean(typeDef.ui?.listItemComponent) && Boolean(typeDef.ListItemComponent))
|
|
1032
|
+
.map((typeDef) => [typeDef.ui!.listItemComponent!, typeDef.ListItemComponent!]),
|
|
1033
|
+
)
|
|
1034
|
+
|
|
1035
|
+
const contentComponents: MessageContentRenderers = Object.fromEntries(
|
|
1036
|
+
allMessageTypes
|
|
1037
|
+
.filter((typeDef) => Boolean(typeDef.ui?.contentComponent) && Boolean(typeDef.ContentComponent))
|
|
1038
|
+
.map((typeDef) => [typeDef.ui!.contentComponent!, typeDef.ContentComponent!]),
|
|
1039
|
+
)
|
|
1040
|
+
|
|
1041
|
+
const actionsComponents: MessageActionsRenderers = Object.fromEntries(
|
|
1042
|
+
allMessageTypes
|
|
1043
|
+
.filter((typeDef) => Boolean(typeDef.ui?.actionsComponent) && Boolean(typeDef.ActionsComponent))
|
|
1044
|
+
.map((typeDef) => [typeDef.ui!.actionsComponent!, typeDef.ActionsComponent!]),
|
|
1045
|
+
)
|
|
1046
|
+
|
|
1047
|
+
const objectDetailComponents: MessageObjectDetailRenderers = Object.fromEntries(
|
|
1048
|
+
allMessageObjectTypes
|
|
1049
|
+
.filter((typeDef) => Boolean(typeDef.DetailComponent))
|
|
1050
|
+
.map((typeDef) => [\`\${typeDef.module}:\${typeDef.entityType}\`, typeDef.DetailComponent!]),
|
|
1051
|
+
)
|
|
1052
|
+
|
|
1053
|
+
const objectPreviewComponents: MessageObjectPreviewRenderers = Object.fromEntries(
|
|
1054
|
+
allMessageObjectTypes
|
|
1055
|
+
.filter((typeDef) => Boolean(typeDef.PreviewComponent))
|
|
1056
|
+
.map((typeDef) => [\`\${typeDef.module}:\${typeDef.entityType}\`, typeDef.PreviewComponent!]),
|
|
1057
|
+
)
|
|
1058
|
+
|
|
1059
|
+
const registry: MessageUiComponentRegistry = {
|
|
1060
|
+
listItemComponents,
|
|
1061
|
+
contentComponents,
|
|
1062
|
+
actionsComponents,
|
|
1063
|
+
objectDetailComponents,
|
|
1064
|
+
objectPreviewComponents,
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
export const messageClientTypeEntries = messageTypeEntriesRaw
|
|
1068
|
+
export const messageClientObjectTypeEntries = messageObjectTypeEntriesRaw
|
|
1069
|
+
export const messageUiComponentRegistry = registry
|
|
1070
|
+
|
|
1071
|
+
export function getMessageUiComponentRegistry(): MessageUiComponentRegistry {
|
|
1072
|
+
return registry
|
|
1073
|
+
}
|
|
910
1074
|
`
|
|
911
1075
|
|
|
912
1076
|
// Validate module dependencies declared via ModuleInfo.requires
|
|
@@ -983,10 +1147,12 @@ export const allAiTools = aiToolConfigEntries.flatMap(e => e.tools)
|
|
|
983
1147
|
writeGeneratedFile({ outFile: aiToolsOutFile, checksumFile: aiToolsChecksumFile, content: aiToolsOutput, structureChecksum, result, quiet })
|
|
984
1148
|
writeGeneratedFile({ outFile: notificationsOutFile, checksumFile: notificationsChecksumFile, content: notificationsOutput, structureChecksum, result, quiet })
|
|
985
1149
|
writeGeneratedFile({ outFile: notificationsClientOutFile, checksumFile: notificationsClientChecksumFile, content: notificationsClientOutput, structureChecksum, result, quiet })
|
|
1150
|
+
writeGeneratedFile({ outFile: messageTypesOutFile, checksumFile: messageTypesChecksumFile, content: messageTypesOutput, structureChecksum, result, quiet })
|
|
1151
|
+
writeGeneratedFile({ outFile: messageObjectsOutFile, checksumFile: messageObjectsChecksumFile, content: messageObjectsOutput, structureChecksum, result, quiet })
|
|
1152
|
+
writeGeneratedFile({ outFile: messagesClientOutFile, checksumFile: messagesClientChecksumFile, content: messagesClientOutput, structureChecksum, result, quiet })
|
|
986
1153
|
writeGeneratedFile({ outFile: eventsOutFile, checksumFile: eventsChecksumFile, content: eventsOutput, structureChecksum, result, quiet })
|
|
987
1154
|
writeGeneratedFile({ outFile: analyticsOutFile, checksumFile: analyticsChecksumFile, content: analyticsOutput, structureChecksum, result, quiet })
|
|
988
1155
|
writeGeneratedFile({ outFile: transFieldsOutFile, checksumFile: transFieldsChecksumFile, content: transFieldsOutput, structureChecksum, result, quiet })
|
|
989
|
-
|
|
990
1156
|
return result
|
|
991
1157
|
}
|
|
992
1158
|
|