import { KV2 } from "./cached-kv.js"; import { UpstreamKV } from "./upstream-kv.js"; import type { BlobStore, CacheLike, Tracer } from "./types.js"; export interface UpstreamConfig { /** * Environment to fall back to. * @default same as current VERCEL_ENV */ env?: string; /** * Branch to fall back to. * @default 'main' */ branch?: string; } export interface CreateKVOptions { /** * User-defined prefix within the env/branch namespace. * Example: "users/" -> cached-kv/production/main/users/{key}.value */ prefix?: string; /** * Override the environment. Defaults to VERCEL_ENV. * Useful for local development or testing. */ env?: string; /** * Override the branch. Defaults to VERCEL_GIT_COMMIT_REF. * Useful for local development or testing. */ branch?: string; /** * Upstream environment for CoW fallback reads. * * - undefined (default): falls back to same env + 'main' branch * - { env, branch }: custom upstream * - null: disable fallback (isolated environment) * * @default { env: VERCEL_ENV, branch: 'main' } */ upstream?: UpstreamConfig | null; /** * Blob access token (defaults to BLOB_READ_WRITE_TOKEN). */ token?: string; /** * Blob store implementation (defaults to VercelBlobStore). */ blobStore?: BlobStore; /** * Cache implementation for testing (defaults to Vercel Runtime Cache). */ cache?: CacheLike; /** * Cache TTL in seconds (default: 3600). */ cacheTtl?: number; /** * Byte threshold for large value separation (default: 1MB). */ largeValueThreshold?: number; /** * Tracer for performance monitoring (defaults to no-op). */ tracer?: Tracer; } /** * Create a KV store with automatic environment detection and CoW fallback. * * - On production/main: returns KV2 directly (zero overhead) * - On preview branches: returns UpstreamKV with fallback to upstream * * @example * ```ts * // Auto-detect environment * const kv = createKV(); * * // Preview -> production fallback * const kv = createKV({ upstream: { env: 'production' } }); * * // Isolated (no fallback) * const kv = createKV({ upstream: null }); * ``` */ export declare function createKV(options?: CreateKVOptions): KV2 | UpstreamKV; //# sourceMappingURL=create-kv.d.ts.map