import { TypedKV } from "./typed-kv.js"; import type { EntriesIterable, KVEntry, KVGetResult, KVLike, KVSetResult, KeysIterable, SetOptions } from "./types.js"; export interface IndexDef { /** Extract index key(s) from value. Return string for single-value, string[] for multi-value. */ key: (value: V, primaryKey: string) => string | string[]; /** Unique constraint. Default: false */ unique?: boolean; } /** * A KV store wrapper that automatically maintains secondary indexes. * * Wraps any KVLike parent and adds index management on top of a prefixed data store. * Index entries are stored as siblings under `__idx/` to avoid polluting `keys()` scans. * * Orphan detection: stale index entries are detected and cleaned up on read. */ export declare class IndexedKV { private parent; private store; private indexes; private prefix; private indexStores; constructor(parent: KVLike, prefix: string, indexes: Record>); get(key: string): Promise>; set(key: string, value: V, ...[metadata, options]: undefined extends M ? [M?, SetOptions?] : [M, SetOptions?]): Promise; delete(key: string): Promise; keys(prefix?: string): KeysIterable; entries(prefix?: string): EntriesIterable; getMany(keys: string[], concurrency?: number): Promise>>; /** * Point lookup on a unique index. Validates and cleans orphans. */ getByIndex(indexName: string, indexKey: string): Promise>; /** * Prefix scan on a non-unique index. Returns primary keys. */ keysByIndex(indexName: string, indexKey: string): KeysIterable; /** * Prefix scan returning full entries. Validates each result. */ entriesByIndex(indexName: string, indexKey: string): EntriesIterable; getStore(): TypedKV; } //# sourceMappingURL=indexed-kv.d.ts.map