import { type Database } from "lmdb"; import { type Kind } from "../../../cesr/mod.js"; import { RawRecord, type RawRecordClass, type RecordInputOf, type RecordShapeOf } from "../core/records.js"; import { BinKey, BinVal, LMDBer } from "./core/lmdber.js"; type KeyPart = string | Uint8Array; type Keys = KeyPart | Iterable; /** Serialization kinds supported by `Komer` record payloads. */ export type KomerKind = Extract; /** Plain stored-object projection returned by `getDict()`. */ export type KomerDictValue> = RecordShapeOf; /** Shared constructor options for `KomerBase` variants. */ export interface KomerBaseOptions> { subkey: string; sep?: string; kind?: KomerKind; dupsort?: boolean; recordClass: RawRecordClass; } /** Constructor options for non-duplicate `Komer` variants. */ export interface KomerOptions> extends Omit, "dupsort"> { } /** * Shared keyspace/object-mapper substrate for `Komer` variants. * * Responsibilities: * - open one named LMDB subdb and manage its key separator policy * - convert tuple-like keyspace paths to/from stored LMDB keys * - select JSON/CBOR/MGPK serializer functions for one record payload shape * - hydrate stored payloads through one record class and serialize them back * - expose KERIpy-style branch iteration and trim helpers used by subclasses * * KERIpy correspondence: * - mirrors `keri.db.koming.KomerBase` * * Current `keri-ts` differences: * - callers may still write either a record instance or constructor-input * shape, but the public model is the record class rather than arbitrary * hydrator/normalizer hooks */ export declare class KomerBase> { static readonly Sep = "."; readonly db: LMDBer; readonly sdb: Database; readonly sep: string; readonly kind: KomerKind; readonly recordClass: RawRecordClass; protected readonly _ser: (val: RecordInputOf) => Uint8Array; protected readonly _des: (val: Uint8Array | null) => TRecord | null; constructor(db: LMDBer, { subkey, sep, kind, dupsort, recordClass, }: KomerBaseOptions); /** * Converts a key path to one LMDB key, optionally forcing a trailing * separator for top-branch scans. */ _tokey(keys: Keys, topive?: boolean): Uint8Array; /** Converts one LMDB key back into its separator-delimited key path. */ _tokeys(key: Uint8Array): string[]; /** Materialize one caller-supplied value into the canonical record class. */ protected coerceRecord(val: RecordInputOf): TRecord; /** Project one normalized record into its persisted object representation. */ protected toStoredValue(val: RecordInputOf): RecordShapeOf; /** Rebuild one caller-facing record from a decoded stored object. */ protected fromStoredValue(val: unknown): TRecord; /** Returns the serializer function for the requested storage encoding kind. */ _serializer(kind: KomerKind): (val: RecordInputOf) => Uint8Array; /** Returns the deserializer function for the requested storage encoding kind. */ _deserializer(kind: KomerKind): (val: Uint8Array | null) => TRecord | null; /** Encode one logical record as UTF-8 JSON bytes. */ protected serializeJSON(val: RecordInputOf): Uint8Array; /** Encode one logical record as MGPK/MessagePack bytes. */ protected serializeMGPK(val: RecordInputOf): Uint8Array; /** Encode one logical record as KERI-compatible CBOR bytes. */ protected serializeCBOR(val: RecordInputOf): Uint8Array; /** Decode one JSON byte payload into the logical record type. */ protected deserializeJSON(val: Uint8Array | null): TRecord | null; /** Decode one MGPK/MessagePack payload into the logical record type. */ protected deserializeMGPK(val: Uint8Array | null): TRecord | null; /** Decode one KERI-compatible CBOR payload into the logical record type. */ protected deserializeCBOR(val: Uint8Array | null): TRecord | null; /** * Removes every entry whose key starts with the provided branch prefix. * * This mirrors KERIpy `trim`, including the `topive` flag for forcing a * branch separator when the caller passes a partial key path. */ trim(keys?: Keys, { topive }?: { topive?: boolean; }): boolean; /** Convenience alias matching the KERIpy API surface. */ remTop(keys?: Keys, { topive }?: { topive?: boolean; }): boolean; /** * Iterates decoded records for one top-branch keyspace prefix. * * Subclasses that add hidden ordinal suffixes or other key/value transforms * should override this method and strip those hidden storage details. */ getTopItemIter(keys?: Keys, { topive }?: { topive?: boolean; }): Generator<[string[], TRecord]>; /** * Returns full stored items for debugging or testing. * * This is currently identical to `getTopItemIter()` because the single-value * `Komer` path has no hidden suffixes or value proems yet. */ getFullItemIter(keys?: Keys, { topive }?: { topive?: boolean; }): Generator<[string[], TRecord]>; } /** * Single-record keyspace/object mapper for one value per effective key. * * Responsibilities: * - expose the KERIpy `Komer` CRUD/count API for non-duplicate subdbs * - keep the active `Baser` and `Keeper` JSON-backed records on the KERIpy * object-mapper path rather than raw LMDB access * * KERIpy correspondence: * - mirrors `keri.db.koming.Komer` * * Current `keri-ts` differences: * - JSON remains the live-store default even though CBOR and MGPK are available * - callers may write constructor-input shapes directly, but reads always * return hydrated record instances */ export declare class Komer> extends KomerBase { constructor(db: LMDBer, { subkey, sep, kind, ...options }: KomerOptions); /** Insert one record value at its effective key if absent. */ put(keys: Keys, val: RecordInputOf): boolean; /** Upsert one record value at its effective key. */ pin(keys: Keys, val: RecordInputOf): boolean; /** Read one record value by its effective key. */ get(keys: Keys): TRecord | null; /** * Return the plain stored-object shape for one record. * * This mirrors KERIpy `getDict` for persisted record shapes even when reads * normally hydrate into richer record instances. */ getDict(keys: Keys): KomerDictValue | null; /** Remove one record value by its effective key. */ rem(keys: Keys): boolean; /** Count all stored records in this `Komer` subdb. */ cnt(): number; /** Alias matching the normalized KERIpy counting surface. */ cntAll(): number; } /** * Insertion-ordered set mapper for record payloads (`IoSetKomer`). * * KERIpy correspondence: * - mirrors `keri.db.koming.IoSetKomer` */ export declare class IoSetKomer> extends KomerBase { constructor(db: LMDBer, { subkey, sep, kind, ...options }: KomerOptions); /** * Insert an insertion-ordered set of records for one effective key if absent. * * Each logical member becomes its own physical key through the `IoSet*` * storage model; duplicate values are deduplicated by the underlying LMDB * helper family. */ put(keys: Keys, vals?: RecordInputOf | Iterable> | null): boolean; /** Upsert an insertion-ordered set of records for one effective key. */ pin(keys: Keys, vals?: RecordInputOf | Iterable> | null): boolean; /** Append one record member to the insertion-ordered set for an effective key. */ add(keys: Keys, val: RecordInputOf): boolean; /** Read all logical members for one effective key in insertion order. */ get(keys: Keys, { ion }?: { ion?: number; }): TRecord[]; /** Read the last logical member for one effective key. */ getLast(keys: Keys): TRecord | null; /** Iterate logical members for one effective key in insertion order. */ getIter(keys: Keys): Generator; /** Remove one member, or all members when `val` is `null`, for an effective key. */ rem(keys: Keys, val?: RecordInputOf | null): boolean; /** Count stored members for one effective key or the whole subdb. */ cnt(keys?: Keys, { ion }?: { ion?: number; }): number; /** Iterate branch members while hiding the synthetic insertion-order suffix. */ getTopItemIter(keys?: Keys, { topive }?: { topive?: boolean; }): Generator<[string[], TRecord]>; } /** * Native duplicate-key object mapper (`DupKomer`). * * KERIpy correspondence: * - mirrors `keri.db.koming.DupKomer` * * Ordering rule: * - duplicates are kept in LMDB duplicate-sort order, not insertion order * - values must remain under LMDB's dupsort value-size limits */ export declare class DupKomer> extends KomerBase { constructor(db: LMDBer, { subkey, sep, kind, ...options }: KomerOptions); /** Insert duplicate members at one effective key without overwriting existing values. */ put(keys: Keys, vals?: RecordInputOf | Iterable> | null): boolean; /** Add one duplicate member if that exact stored value is absent. */ add(keys: Keys, val: RecordInputOf): boolean; /** Replace the full duplicate set for one effective key. */ pin(keys: Keys, vals?: RecordInputOf | Iterable> | null): boolean; /** Read all duplicate members for one effective key. */ get(keys: Keys): TRecord[]; /** Read the lexicographically last duplicate member for one effective key. */ getLast(keys: Keys): TRecord | null; /** Iterate duplicate members at one effective key in LMDB duplicate order. */ getIter(keys: Keys): Generator; /** Count duplicate members at one effective key or across the whole subdb. */ cnt(keys?: Keys): number; /** Remove one duplicate member, or the entire duplicate set when `val` is `null`. */ rem(keys: Keys, val?: RecordInputOf | null): boolean; } export {}; //# sourceMappingURL=koming.d.ts.map