Add module loader & registry (task 04)
Implements the extensibility foundation: ModuleManifest/DashboardWidget/EntityTypeRegistration types in _core/module.ts, a plain-Map registry singleton with registerModule/getRegistry/getEntityType/getWidget, and stub manifests for calendar/lists/notes. Root layout imports src/modules/index.ts for side-effect registration; AppNav reads the registry to render nav links. /debug/registry dumps the full registry JSON in dev using zod v4 + z.toJSONSchema(). Adding a fourth module requires one folder + one line in index.ts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
37977568ed
commit
e237fe8449
@@ -0,0 +1,51 @@
|
||||
import { notFound } from "next/navigation";
|
||||
import { z } from "zod";
|
||||
import { getRegistry } from "@/modules/_core/registry";
|
||||
import "@/modules";
|
||||
|
||||
export default function RegistryDebugPage() {
|
||||
if (process.env.NODE_ENV !== "development") {
|
||||
notFound();
|
||||
}
|
||||
|
||||
const { modules } = getRegistry();
|
||||
|
||||
const output = {
|
||||
modules: modules.map((m) => ({
|
||||
id: m.id,
|
||||
name: m.name,
|
||||
nav: m.nav ?? null,
|
||||
entities: m.entities.map((e) => ({
|
||||
type: e.type,
|
||||
label: e.label,
|
||||
hasShare: !!e.share,
|
||||
hasReminder: !!e.reminder,
|
||||
hasSearch: !!e.search,
|
||||
})),
|
||||
dashboardWidgets: (m.dashboardWidgets ?? []).map((w) => ({
|
||||
id: w.id,
|
||||
title: w.title,
|
||||
description: w.description,
|
||||
category: w.category ?? null,
|
||||
defaultSize: w.defaultSize,
|
||||
defaultPriority: w.defaultPriority,
|
||||
configSchema: z.toJSONSchema(w.configSchema),
|
||||
defaultConfig: w.defaultConfig,
|
||||
})),
|
||||
quickAdds: (m.quickAdds ?? []).map((q) => ({
|
||||
id: q.id,
|
||||
label: q.label,
|
||||
icon: q.icon ?? null,
|
||||
})),
|
||||
})),
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="p-8">
|
||||
<h1 className="text-2xl font-bold mb-4">Module Registry (dev only)</h1>
|
||||
<pre className="text-xs bg-muted rounded p-4 overflow-auto">
|
||||
{JSON.stringify(output, null, 2)}
|
||||
</pre>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user