import type { createPinboard } from "./server.js"; /** In-memory marked-rows index for tests and embedded runs. */ export class MemoryDurabilityStore implements createPinboard.DurabilityStore { readonly rows = new Map< string, { env: string; hostname: string; ns: string; id: string } >(); private key(env: string, ns: string, id: string): string { return `${env}\n${ns}\n${id}`; } add(env: string, hostname: string, ns: string, id: string): void { this.rows.set(this.key(env, ns, id), { env, hostname, ns, id }); } remove(env: string, ns: string, id: string): void { this.rows.delete(this.key(env, ns, id)); } async listMarked( cursor: string | null, limit: number, ): Promise<{ entries: { env: string; hostname: string; ns: string; id: string }[]; cursor: string | null; }> { const all = [...this.rows.keys()].sort(); const from = cursor === null ? 0 : all.filter((key) => key <= cursor).length; const page = all.slice(from, from + limit); return { entries: page.map((key) => this.rows.get(key)!), cursor: from + limit >= all.length ? null : page[page.length - 1]!, }; } }