feat: add dashboard persistence store

This commit is contained in:
vince 2026-06-18 18:09:17 +02:00
parent 5eeec0dcb5
commit 5e42ee8869
18 changed files with 1181 additions and 19 deletions

View file

@ -1,3 +1,9 @@
import { dimensionLabDashboardFixture } from "$lib/model/fixtures/dimensionlab";
import {
createDashboardStore,
type DashboardStore,
} from "$lib/server/db/dashboard-store";
export type PlaceholderStatus = "ready" | "building";
export interface PlaceholderDashboard {
@ -5,6 +11,8 @@ export interface PlaceholderDashboard {
subtitle: string;
status: PlaceholderStatus;
message: string;
schemaVersion?: string;
currentRevisionId?: string;
}
export function loadPlaceholderDashboard(): PlaceholderDashboard {
@ -16,3 +24,29 @@ export function loadPlaceholderDashboard(): PlaceholderDashboard {
"SvelteKit is running. Later issues will replace this placeholder with the validated dashboard model.",
};
}
export function loadDashboardRuntime(store?: DashboardStore): PlaceholderDashboard {
const dashboardStore = store || createDashboardStore();
try {
const seeded = dashboardStore.seedDashboardIfEmpty(dimensionLabDashboardFixture, {
actor: "dimensionlab-seed",
message: "load initial dashboard seed",
});
const active = dashboardStore.getActiveDashboard();
const document = active?.document || seeded.document;
const currentRevisionId = active?.currentRevisionId || seeded.id;
return {
title: document.metadata.title,
subtitle: document.metadata.subtitle || "",
status: "building",
message:
"Active dashboard document loaded from SQLite. Later issues will replace this placeholder with model-driven rendering.",
schemaVersion: document.schemaVersion,
currentRevisionId,
};
} finally {
if (!store) dashboardStore.close();
}
}