import type { KV2 } from "./cached-kv.js"; import type { ManifestLog } from "./manifest-log.js"; import type { EntriesIterable, KVEntry, KVGetResult, KVLike, KVSetResult, KeysIterable, SetOptions } from "./types.js"; import { TypedKV } from "./typed-kv.js"; /** * Wrapper that adds copy-on-write (CoW) behavior to KV2. * * - Reads check manifest to route to local or upstream (avoids unnecessary blob lookups) * - Writes go to local only * - Deletes create tombstones to prevent upstream fallthrough * - keys() returns keys from the manifest (discovered + local) */ export declare class UpstreamKV implements KVLike { private local; private upstream; private manifest; constructor(local: KV2, upstream: KV2, manifest: ManifestLog); /** * Wrap an upstream entry to redirect update() calls through UpstreamKV.set(). * This ensures updates write to local storage, not upstream. * * Note: We don't use expectedVersion here because we're creating a new local * shadow of the upstream entry, not updating an existing local entry. */ private wrapUpstreamEntry; /** * Get a value. Uses manifest to route efficiently: * - Keys marked "local" → check local only * - Keys marked "upstream" → check upstream only (skip local blob lookup) * - Keys marked "tombstone" → return not found * - Unknown keys → check local, then upstream */ get(key: string): Promise>; /** * Set a value. Writes to local only. */ set(key: string, value: V | ReadableStream, ...[metadata, options]: undefined extends M ? [M?, SetOptions?] : [M, SetOptions?]): Promise; /** * Delete a key. Creates a tombstone to prevent upstream fallthrough. */ delete(key: string): Promise; /** * Iterate over keys. Returns merged keys from local, manifest, and upstream, * excluding tombstones. */ keys(prefix?: string): KeysIterable; /** * Fetch multiple keys concurrently with bounded concurrency. * Returns a Map of key -> entry for all existing keys. * Uses this.get() which handles local/upstream routing and tombstones. * * @param keys - Array of keys to fetch * @param concurrency - Number of concurrent get operations (default: 20) */ getMany(keys: string[], concurrency?: number): Promise>>; /** * Iterate over key-value entries with concurrent fetching. * Yields entries as soon as each fetch completes. * Returns merged entries from local and upstream, excluding tombstones. * * @param prefix - Optional prefix to filter keys * @param concurrency - Number of concurrent get operations (default: 20) */ entries(prefix?: string, concurrency?: number): EntriesIterable; /** * Discover all keys from upstream and add to manifest. * Use when you need complete keys() immediately. */ discoverAllKeys(): Promise; /** * Delete all local data and manifest (for environment cleanup). */ destroy(): Promise; /** * Get the underlying local KV (for advanced use cases). */ getLocalKV(): KV2; /** * Get a typed sub-store with CoW behavior. * Reads fall back to upstream, writes go to local. */ getStore(subPrefix: string, indexes?: Record>): TypedKV; } //# sourceMappingURL=upstream-kv.d.ts.map