declare module 'ipfs-repo' { import { Datastore, Key, Query, Result } from 'interface-datastore' import CID from 'cids' import OldBlock from 'ipld-block' import NewBLock from '@ipld/block' type Block = OldBlock | NewBLock export interface Options { lock?: 'fs' | 'memory', storageBackends?: { root?: Datastore, blocks?: Datastore, keys?: Datastore, datastore?: Datastore }, storageBackendOptions?: { root?: { extension?: string }, blocks?: { sharding?: boolean, extension?: string }, keys?: {} } } class Config { constructor(store: Datastore) get (key: string): Promise set (key: string, value: object): Promise exists(): Promise } class Spec { constructor(store: Datastore) get (): Promise set (spec: number): Promise exists(): Promise } class ApiAddr { constructor(store: Datastore) get(): Promise set(value: object): Promise delete(): Promise } class Version { constructor(store: Datastore) exists(): Promise get(): Promise set(version: number): Promise check(expected: number): Promise } interface Lockfile { close(): Promise } interface Lock { lock(dir: string): Promise locked(dir: string): boolean } interface Stats { repoPath: string storageMax: number version: string numObjects: number repoSize: number } interface BlockstoreOptions { valueEncoding?: string compression?: boolean sharding?: boolean extension?: string } export class Blockstore { constructor(store: Datastore, options: BlockstoreOptions) query(query: Query): AsyncIterable get(cid: CID): Promise put(block: Block): Promise putMany(blocks: AsyncIterable|Iterable): Promise has(cid: CID): Promise delete(cid: CID): Promise } class IpfsRepo { constructor (repoPath: string, options?: Options) root: Datastore version: Version config: Config spec: Spec apiAddr: ApiAddr _locker: Lock options: Options closed: boolean path: string lockfile?: Lockfile datastore?: Datastore blocks?: Blockstore keys?: Datastore init(config: Config): Promise open(): Promise close(): Promise exists(): Promise stat(options: {human: boolean}): Promise getSize(queryFunc: Query): number } // eslint-disable-next-line import/no-default-export export default IpfsRepo export namespace utils { export namespace blockstore { export function cidToKey(cid: CID): Key export function keytoCid(key: Key): CID } } export const repoVersion: number export namespace errors { export const LockExistsError: Error export const NotFoundError: Error export const ERR_REPO_NOT_INITIALIZED: string export const ERR_REPO_ALREADY_OPEN: string export const ERR_REPO_ALREADY_CLOSED: string } }