Add CultCache inspector app
This commit is contained in:
parent
d7aa3349f3
commit
b460612680
20 changed files with 5965 additions and 10 deletions
|
|
@ -10,6 +10,7 @@ import { decode, encode } from "@msgpack/msgpack";
|
|||
import { z } from "zod";
|
||||
|
||||
import { CultCache } from "../src/cult-cache";
|
||||
import { inspectCultCacheBytes } from "../src/cult-cache-inspector";
|
||||
import { defineDocumentRegistry, defineDocumentType } from "../src/document";
|
||||
import { SingleFileMessagePackBackingStore } from "../src/single-file-messagepack-backing-store";
|
||||
import type { CacheBackingStore, CultCacheEnvelope, CultCacheSchema } from "../src/types";
|
||||
|
|
@ -543,6 +544,27 @@ test("CultCache interop reader accepts missing compatible trailing slots and rej
|
|||
);
|
||||
});
|
||||
|
||||
test("CultCache inspector decodes v1 store catalog and record payloads from bytes", async () => {
|
||||
const tempDir = await mkdtemp(join(tmpdir(), "cultcache-inspector-"));
|
||||
const file = join(tempDir, "cache.cc");
|
||||
const written = await writeTsInteropStore(file, "inspector");
|
||||
|
||||
const inspection = inspectCultCacheBytes(file, await readFile(file));
|
||||
assert.equal(inspection.format, "cultcache.store.v1");
|
||||
assert.equal(inspection.catalog.length, 1);
|
||||
assert.equal(inspection.catalog[0]?.schemaName, "cultcache.interop-note");
|
||||
assert.equal(inspection.records.length, 1);
|
||||
assert.equal(inspection.records[0]?.key, written.documentId);
|
||||
assert.deepEqual(inspection.records[0]?.payloadPreview, [
|
||||
"cultcache.interop_note.v1",
|
||||
written.documentId,
|
||||
written.authorRuntimeId,
|
||||
written.title,
|
||||
written.body,
|
||||
written.tags,
|
||||
]);
|
||||
});
|
||||
|
||||
interface InteropNote {
|
||||
schemaVersion: "cultcache.interop_note.v1";
|
||||
documentId: string;
|
||||
|
|
|
|||
Loading…
Reference in a new issue