export namespace KV { type Value = string | ReadableStream | ArrayBuffer; type WriteOptions = { expiration?: number; expirationTtl?: number }; type ListOptions = { prefix?: string; limit?: number; cursor?: string }; type GetOptions = 'text' | 'json' | 'arrayBuffer' | 'stream'; interface KeyList { keys: Array<{ name: string; expiration?: number }>; list_complete: boolean; cursor: string; } interface Namespace { get(key: string, type: 'json'): Promise; get(key: string, type: 'stream'): Promise; get(key: string, type: 'arrayBuffer'): Promise; get(key: string, type: 'text'): Promise; get(key: string, type: GetOptions): Promise; get(key: string): Promise; // "text" put(key: string, value: Value, options?: WriteOptions): Promise; list(options?: ListOptions): Promise; delete(key: string): Promise; } } export declare class Database = { [P in keyof Models]: string}> { constructor(binding: KV.Namespace); get(type: K, uid: Identifiers[K], format?: KV.GetOptions): Promise; put(type: K, uid: Identifiers[K], value: Models[K], toJSON?: boolean): Promise; del(type: K, uid: Identifiers[K]): Promise; } export function read(binding: KV.Namespace, key: string, format?: KV.GetOptions): Promise; export function write(binding: KV.Namespace, key: string, value: T, toJSON?: boolean): Promise; export function remove(binding: KV.Namespace, key: string): Promise; export function until( toMake: () => X, toSearch: (val: X) => Promise ): Promise;