experimenting with config history

This commit is contained in:
dswbx
2025-09-20 14:44:09 +02:00
parent 7d89fe4894
commit 2fdaf594f4
4 changed files with 175 additions and 1 deletions
@@ -32,6 +32,7 @@ import { getVersion } from "core/env";
import type { Module } from "modules/Module";
import { getSystemMcp } from "modules/mcp/system-mcp";
import type { DbModuleManager } from "modules/db/DbModuleManager";
import type { Repository } from "data/entities";
export type ConfigUpdate<Key extends ModuleKey = ModuleKey> = {
success: true;
@@ -129,6 +130,25 @@ export class SystemController extends Controller {
},
);
hono.get("/history", async (c) => {
// @ts-expect-error "repo" is private
const repo = manager.repo() as Repository;
const { data } = await repo.findMany({
where: { type: "diff", version: manager.version() },
sort: { by: "id", dir: "desc" },
});
return c.json(data);
});
hono.get("/history/:id", async (c) => {
// @ts-expect-error "repo" is private
const repo = manager.repo() as Repository;
const { data } = await repo.findId(c.req.param("id"), {
where: { type: "diff", version: manager.version() },
});
return c.json(data);
});
async function handleConfigUpdateResponse(
c: Context<any>,
cb: () => Promise<ConfigUpdate>,