import { AtomicCheck, AtomicOperation, Kv, KvCommitError, KvCommitResult, KvConsistencyLevel, KvEntry, KvEntryMaybe, KvKey, KvListIterator, KvListOptions, KvListSelector, KvMutation } from "./kv_types.js"; import { _KvU64 } from "./kv_u64.js"; export type EncodeV8 = (value: unknown) => Uint8Array; export type DecodeV8 = (bytes: Uint8Array) => unknown; export type KvValueEncoding = "VE_UNSPECIFIED" | "VE_V8" | "VE_LE64" | "VE_BYTES"; export type KvValue = { data: Uint8Array; encoding: KvValueEncoding; }; export declare function unpackKvu(bytes: Uint8Array): _KvU64; export declare function packKvu(value: _KvU64): Uint8Array; export declare function readValue(bytes: Uint8Array, encoding: KvValueEncoding, decodeV8: DecodeV8): unknown; export declare function packKvValue(value: unknown, encodeV8: EncodeV8): KvValue; export type Cursor = { lastYieldedKeyBytes: Uint8Array; }; export declare function packCursor({ lastYieldedKeyBytes }: Cursor): string; export declare function unpackCursor(str: string): Cursor; export declare function checkListSelector(selector: KvListSelector): KvListSelector; export declare function checkListOptions(options: KvListOptions): KvListOptions; export declare const packVersionstamp: (version: number) => string; export declare const unpackVersionstamp: (versionstamp: string) => number; export declare const isValidVersionstamp: (versionstamp: string) => boolean; export declare const replacer: (_this: unknown, v: unknown) => unknown; export declare class CursorHolder { private cursor; get(): string; set(cursor: string): void; } export declare class GenericKvListIterator implements KvListIterator { private readonly generator; private readonly _cursor; constructor(generator: AsyncGenerator>, cursor: () => string); get cursor(): string; next(): Promise, undefined>>; [Symbol.asyncIterator](): AsyncIterableIterator>; return?(value?: any): Promise, any>>; throw?(e?: any): Promise, any>>; } export type Enqueue = { value: unknown; opts?: { delay?: number; keysIfUndelivered?: KvKey[]; }; }; type CommitFn = (checks: AtomicCheck[], mutations: KvMutation[], enqueues: Enqueue[]) => Promise; export declare class GenericAtomicOperation implements AtomicOperation { private readonly commitFn; private readonly checks; private readonly mutations; private readonly enqueues; constructor(commit: CommitFn); check(...checks: AtomicCheck[]): this; mutate(...mutations: KvMutation[]): this; sum(key: KvKey, n: bigint): this; min(key: KvKey, n: bigint): this; max(key: KvKey, n: bigint): this; set(key: KvKey, value: unknown, { expireIn }?: { expireIn?: number; }): this; delete(key: KvKey): this; enqueue(value: unknown, opts?: { delay?: number; keysIfUndelivered?: KvKey[]; }): this; commit(): Promise; } export declare abstract class BaseKv implements Kv { protected readonly debug: boolean; private closed; protected constructor({ debug }: { debug: boolean; }); get(key: KvKey, { consistency }?: { consistency?: KvConsistencyLevel; }): Promise>; getMany(keys: readonly KvKey[], { consistency }?: { consistency?: KvConsistencyLevel; }): Promise; set(key: KvKey, value: unknown, { expireIn }?: { expireIn?: number; }): Promise; delete(key: KvKey): Promise; enqueue(value: unknown, opts?: { delay?: number; keysIfUndelivered?: KvKey[]; }): Promise; list(selector: KvListSelector, options?: KvListOptions): KvListIterator; listenQueue(handler: (value: unknown) => void | Promise): Promise; atomic(additionalWork?: () => void): AtomicOperation; watch(keys: readonly KvKey[], options?: { raw?: boolean; }): ReadableStream; close(): void; [Symbol.dispose](): void; protected abstract get_(key: KvKey, consistency: KvConsistencyLevel | undefined): Promise>; protected abstract getMany_(keys: readonly KvKey[], consistency: KvConsistencyLevel | undefined): Promise[]>; protected abstract listStream(outCursor: CursorHolder, selector: KvListSelector, opts: KvListOptions): AsyncGenerator>; protected abstract listenQueue_(handler: (value: unknown) => void | Promise): Promise; protected abstract commit(checks: AtomicCheck[], mutations: KvMutation[], enqueues: Enqueue[], additionalWork?: () => void): Promise; protected abstract watch_(keys: readonly KvKey[], raw: boolean | undefined): ReadableStream[]>; protected abstract close_(): void; private checkOpen; } export declare class Expirer { private readonly debug; private readonly expireFn; private minExpires; private expirerTimeout; constructor(debug: boolean, expireFn: () => number | undefined); init(minExpires: number | undefined): void; rescheduleExpirer(expires: number): void; finalize(): void; private runExpirer; } export type QueueHandler = (value: unknown) => void | Promise; export declare class QueueWorker { private readonly workerFn; private workerTimeout; private queueHandler?; private queueHandlerPromise?; constructor(workerFn: (queueHandler?: QueueHandler) => void); listen(handler: QueueHandler): Promise; rescheduleWorker(delay?: number): void; finalize(): void; } export {};