import { FileContent, CID } from '../ipfs'; import { Maybe } from '../common/types'; export declare type FileSystemOptions = { version?: SemVer; keyName?: string; rootDid?: string; }; export interface File { content: FileContent; put(): Promise; } export interface HeaderFile extends File { getHeader(): HeaderV1; putWithPins(): Promise; } export declare type AddLinkOpts = { shouldOverwrite?: boolean; }; export declare type BasicLink = { name: string; cid: CID; size?: number; }; export declare type Link = BasicLink & { mtime?: number; isFile: boolean; }; export declare type Links = { [name: string]: Link; }; export declare type BasicLinks = { [name: string]: BasicLink; }; export declare type Metadata = { name?: string; isFile: boolean; mtime?: number; size: number; }; export declare type HeaderV1 = { name: string; isFile: boolean; mtime: number; size: number; version: SemVer; key: Maybe; fileIndex: NodeMap; pins: PinMap; }; export declare type PinMap = { [name: string]: PinMap | CID; }; export declare type NodeInfo = HeaderV1 & { cid: CID; }; export declare type NodeMap = { [name: string]: NodeInfo; }; export declare type UnstructuredHeader = { [name: string]: unknown; }; export declare type NonEmptyPath = [string, ...string[]]; export declare type SyncHook = (cid: CID) => unknown; export declare type SemVer = { major: number; minor: number; patch: number; }; export declare type PutResult = { cid: CID; pins: PinMap; }; export interface TreeStatic { empty(parentKey: Maybe): Promise; fromCID(cid: CID, parentKey: Maybe): Promise; fromHeader(header: HeaderV1, parentKey: Maybe): HeaderTree; } export interface FileStatic { create(content: FileContent, parentKey: Maybe): Promise; fromCID(cid: CID, parentKey: Maybe): Promise; } export interface StaticMethods { tree: TreeStatic; file: FileStatic; } export interface Tree { version: SemVer; ls(path: string): Promise; mkdir(path: string): Promise; cat(path: string): Promise; add(path: string, content: FileContent): Promise; rm(path: string): Promise; get(path: string): Promise; pathExists(path: string): Promise; addChild(path: string, toAdd: Tree | FileContent): Promise; addRecurse(path: NonEmptyPath, child: Tree | FileContent): Promise; put(): Promise; updateDirectChild(child: Tree | File, name: string): Promise; removeDirectChild(name: string): Promise; getDirectChild(name: string): Promise; getOrCreateDirectChild(name: string): Promise; emptyChildTree(): Promise; childTreeFromCID(cid: CID): Promise; createChildFile(content: FileContent): Promise; childFileFromCID(cid: CID): Promise; getLinks(): Links; } export interface HeaderTree extends Tree { getHeader(): HeaderV1; updateHeader(name: string, childInfo: Maybe): Promise; childTreeFromHeader(heaer: HeaderV1): HeaderTree; putWithPins(): Promise; }