feat(cms): improve catalog, editorial recovery and operations
CI / check (push) Successful in 52s
CI / deploy (push) Successful in 2m10s
CI / publish-container (push) Failing after 1m18s

This commit is contained in:
Simo committed 2026-09-09 19:36:15 +02:00
1 parent 2fead134e6
commit c389c3893d
122 files changed
+8137 -703

No files matched your search

+48 -1
View File
@@ -1,4 +1,4 @@
import { mkdtemp, rm } from "node:fs/promises";
import { mkdtemp, readdir, rm, writeFile } from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { expect, it } from "vitest";
@@ -54,3 +54,50 @@ it("resolves a group and reopens it when a later occurrence arrives", async () =
await rm(dir, { recursive: true, force: true });
}
});
it("persists assignments across instances and clears them without modifying resolution", async () => {
const dir = await mkdtemp(path.join(os.tmpdir(), "cms-errors-"));
try {
const store = new ErrorStore(dir);
const record = createErrorRecord("server", "assign", "failed");
await store.append(record);
await store.resolve(record.fingerprint);
await store.assign(record.fingerprint, 42);
const persisted = (await new ErrorStore(dir).read()).records[0];
expect(persisted.assignment?.userId).toBe(42);
expect(persisted.resolved).toBe(true);
await new ErrorStore(dir).assign(record.fingerprint, null);
expect((await store.read()).records[0].assignment).toBeNull();
await expect(store.assign("../escape", 42)).rejects.toThrow(
"Invalid fingerprint",
);
await expect(store.assign(record.fingerprint, -1)).rejects.toThrow(
"Invalid assignee",
);
await expect(store.assign("0000000000000000", 42)).rejects.toThrow(
"no longer available",
);
} finally {
await rm(dir, { recursive: true, force: true });
}
});
it("ignores expired assignment metadata and prunes it with error retention", async () => {
const dir = await mkdtemp(path.join(os.tmpdir(), "cms-errors-"));
try {
const record = createErrorRecord("server", "retention", "failed");
const expired = `2000-01-01.${record.fingerprint}.assignment`;
await writeFile(
path.join(dir, expired),
JSON.stringify({ userId: 99, at: "2000-01-01T00:00:00Z" }),
);
const store = new ErrorStore(dir);
await store.append(record);
expect((await store.read()).records[0].assignment).toBeNull();
expect(await readdir(dir)).not.toContain(expired);
const current = `${record.at.slice(0, 10)}.${record.fingerprint}.assignment`;
await writeFile(path.join(dir, current), "x".repeat(513));
expect((await store.read()).records[0].assignment).toBeNull();
} finally {
await rm(dir, { recursive: true, force: true });
}
});