import { CID, Block, ToJSON, Await, AbortOptions } from './basic' import { DataStore, Key } from './datastore' import { ValueStore, StoreReader, Resource, StoreLookup, StoreImporter, StoreExporter, StoreEraser, StoreSelector, KeyValueStore } from './store' export interface Repo extends Resource { readonly path: string closed: boolean /** * Initializes necessary structures inside the repo */ init(config:Partial):Await /** * Tells whether this repo exists or not. */ exists():Await /** * Tells whether the repo has been initialized. */ isInitialized():Await /** * Gets the repo status. */ stat(options?:AbortOptions):Await root: KeyValueStore blocks: BlockStore datastore: DataStore pins: PinStore config: ConfigStore keys: KeyStore version: ValueStore apiAddr: ValueStore } export interface RepoStatus { numObjects: number repoPath: string repoSize: number version: number storageMax: number } interface BlockStore extends StoreImporter, StoreReader, StoreLookup, StoreExporter, StoreEraser, StoreSelector { put(block: Block): Await } export interface ConfigStore extends StoreReader { /** * Set a config `value`, where `value` can be anything that is serializable * to JSON. */ set(key: string, value: ToJSON, options?:AbortOptions): Await /** * Set the whole `config` which can be a any value that is serializable to * JSON. * * @param config */ replace(config: Config, options?: AbortOptions): Await /** * Get the entire config value. */ getAll(options?:AbortOptions): Await /** * Whether the config sub-repo exists. */ exists(): Await } export interface PinStore extends KeyValueStore, Object { } export interface KeyStore extends KeyValueStore, Object { }