declare module "hyperdrive" { import { EventEmitter } from "node:stream"; import type Hypercore from "hypercore"; import type Hyperbee from "hyperbee"; import type CoreStore from "corestore"; interface DriveOpts { key?: Buffer | Uint8Array; } interface Entry { seq: number; key: string; value: { executable: boolean; linkname: null | string; blob: { blockOffset: number; blockLength: number; byteOffset: number; byteLength: number; }; metadata: Metadata | null; }; } type Metadata = { [key: string]: any }; interface WriteOptions { executable?: boolean; metadata: Metadata; } interface ReadOptions { wait?: boolean; timeout?: number; start?: number; end?: number; length?: number; } interface ListOptions { recursive?: boolean; ignore?: string | string[]; wait?: boolean; } type EntryOptions = ReadOptions & { follow?: boolean; }; interface Diff { left: Entry; right: Entry; } interface Download { done(): Promise; destroy(): void; } interface HypedriveEvents { close: []; } type UncloseableDrive = Hyperdrive & { close(): never; }; interface MirrorDriveOptions { prefix?: string; dryRun?: boolean; prune?: boolean; includeEquals?: boolean; filter: (key: string) => boolean; batch?: boolean; ignore?: string | string[]; } interface MirrorEvent { op: "add"; key: string; bytesRemoved: number; bytesAdded: number; } type MirrorDrive = AsyncIterable & { readonly count: number; done: Promise; }; export default class Hyperdrive extends EventEmitter { readonly url: string; readonly id: string; readonly writable: boolean; readonly readable: boolean; readonly key: Key; readonly discoveryKey: Key; readonly version: number; readonly supportsMetadata: true; readonly core: Hypercore; readonly corestore: CoreStore; readonly db: Hyperbee; constructor( store: CoreStore, key: Buffer | Uint8Array | null, opts?: DriveOpts ); ready(): Promise; close(): Promise; put( path: string, buffer: Uint8Array, options?: WriteOptions ): Promise; get(path: string, options?: ReadOptions): Promise; entry(path: string, options?: EntryOptions): Promise; exists(path: string): Promise; del(path: string): Promise; compare(entryA: Entry, entryB: Entry): number; clear(path: string, options?: { diff?: boolean }): Promise; clearAll(options?: { diff?: boolean }): Promise; truncate( version: number, options?: { blobs?: number } ): Promise; purge(): Promise; symlink(path: string, linkname: string): Promise; batch(): Hyperdrive & { flush(): Promise }; list(folder: string, options?: ListOptions): AsyncIterable; readdir( folder: string, options?: { wait?: boolean } ): AsyncIterable; has(path: string): Promise; entries: Hyperbee["createReadStream"]; mirror(out: Hyperdrive, options?: MirrorDriveOptions): MirrorDrive; watch(folder?: string): AsyncIterable<[UncloseableDrive, UncloseableDrive]>; ready(): Promise; destroy(): void; createReadStream(path: string, options?: ReadOptions): any; createWriteStream(path: string, options?: WriteOptions): any; download(folder: string, options?: ListOptions): Download; checkout(version: number): Hyperdrive; diff(version: number, folder: string, options?: any): AsyncIterable; downloadDiff(version: number, folder: string, options?: any): Download; downloadRange(dbRanges: any, blobRanges: any): Download; findingPeers(): () => void; update(options?: { wait: boolean }): Promise; } }