/** * Dedicated mailbox databaser. * * This is the provider-side durable inbox store used by mailbox relays: * - ordered topic indices live in `.tpcs` * - raw payload bytes live in `.msgs` * * KERIpy correspondence: * - ports the `Mailboxer` concept and storage surface from * `keri.app.storing` * * Current `keri-ts` difference: * - runtime polling, query streaming, and HTTP serving live elsewhere, but * they all treat this module as the single source of mailbox payload truth */ import { type Operation } from "effection"; import { Diger } from "../../../cesr/mod.js"; import { LMDBer, type LMDBerOptions } from "./core/lmdber.js"; import { CesrOnSuber, Suber } from "./subing.js"; /** Accepted topic key shapes for the mailbox ordering store. */ type MailboxKeys = string | Uint8Array | Iterable; /** * Options for opening the dedicated mailbox environment. * * `compat` selects the KERIpy-compatible alternate path layout when opening * external stores. */ export interface MailboxerOptions extends LMDBerOptions { compat?: boolean; } /** Raw-byte value family used for stored mailbox message bodies. */ declare class BytesSuber extends Suber { protected _ser(val: Uint8Array): Uint8Array; protected _des(val: Uint8Array | null): Uint8Array | null; } /** * Dedicated mailbox storage environment. * * Responsibilities: * - index topic ordering in `.tpcs` * - deduplicate stored mailbox payloads by digest in `.msgs` * - provide the KERIpy mailbox retrieval surface used by forwarding and * mailbox-stream HTTP handling * * Storage model: * - `.tpcs` stores `(topic, on) -> digest` * - `.msgs` stores `digest -> raw message bytes` */ export declare class Mailboxer extends LMDBer { tpcs: CesrOnSuber; msgs: BytesSuber; /** Default primary path for Tufa-owned mailbox environments. */ static readonly TailDirPath = "keri/mbx"; /** Default alternate path for Tufa-owned mailbox environments. */ static readonly AltTailDirPath = ".tufa/mbx"; /** Alternate path used when opening KERIpy-compatible mailbox stores. */ static readonly CompatAltTailDirPath = ".keri/mbx"; static readonly TempPrefix = "keri_mbx_"; static readonly MaxNamedDBs = 8; constructor(options?: MailboxerOptions); /** * Reopen the mailbox environment and bind the KERIpy-shaped named subdbs. */ reopen(options?: Partial): Operation; /** * Remove one topic ordinal index without deleting the deduplicated message. * * This mirrors KERIpy's separation between topic ordering and raw message * storage. Removing the ordinal mapping does not garbage-collect `.msgs`. */ delTopic(key: MailboxKeys, on?: number): boolean; /** * Append one message digest to the next ordinal slot for a topic. * * The ordinal returned here becomes the mailbox event id later exposed to * `mbx` query streams. */ appendToTopic(topic: MailboxKeys, val: Diger): number; /** * Materialize mailbox payloads for one topic from ordinal `fn` onward. * * This helper is intentionally payload-focused: callers that also need the * mailbox indices should use `cloneTopicIter()`. */ getTopicMsgs(topic: MailboxKeys, fn?: number): Uint8Array[]; /** * Store one raw mailbox payload and append its digest to the topic index. * * The message is deduplicated by digest in `.msgs`, but the topic index still * records each ordered appearance in `.tpcs`. */ storeMsg(topic: MailboxKeys, msg: Uint8Array | string): boolean; /** * Iterate `(on, topic, msg)` triples from ordinal `fn` onward. * * This is the storage primitive used by mailbox SSE streaming so the caller * can preserve both payload bytes and the ordered mailbox event id. */ cloneTopicIter(topic: MailboxKeys, fn?: number): Generator<[number, string, Uint8Array]>; } /** * Open a mailbox environment and return the ready-to-use databaser. * * Compatibility rule: * - explicit mailbox opens stay strict * - missing additive sidecars are tolerated only by higher-level habery open * flows that are inspecting compat stores readonly */ export declare function createMailboxer(options?: MailboxerOptions): Operation; export {}; //# sourceMappingURL=mailboxing.d.ts.map