import CID from 'cids'; import { BlockService } from './blockservice'; /** * AddOptions represents the set of default parameters to use when adding an IPLD Node via the DAG service. */ export interface AddOptions { /** * hashAlg is the hashing algorithm that is used to calculate the CID. The default comes from the given codec. */ hashAlg?: string; /** * onlyHash controls whether or not the serialized form of the IPLD Node will be passed to the underlying block store. */ onlyHash?: boolean; /** * cidVersion specifies which version of CID to use. This option is currently ignored (and defaults to v1). */ cidVersion?: number; } /** * DAGOptions represents the set of parameters to use when initializing a DAG service. */ export interface DAGOptions extends AddOptions { /** * The underlying block service for adding, deleting, and retrieving blocks. It is required. */ blockService: BlockService; } /** * ResolveResult represents an IPLD Node that was traversed during path resolving. */ export interface ResolveResult { /** * remainderPath is the part of the path that wasn’t resolved yet. */ remainderPath?: string; /** * value is what the resolved path points to. If further traversing is possible, then `value` is a CID object * linking to another IPLD node. If it was possible to fully resolve the path, `value` is the value the path points * to. So if you need the CID of the IPLD node you’re currently at, just take the `value` of the previously returned * IPLD node. */ value: CID | any; } /** * DAGService is a content-addressable store for adding, removing, and getting Merkle directed acyclic graphs (DAGs). * A DAG service provides an API for creating and resolving IPLD nodes, making it possible for apps and services to * integrate with the IPFS IPLD Merkle-forest. * * It satisfies the default IPLD interface: https://github.com/ipld/js-ipld. */ export declare class DAGService { /** * A set of default parameters to use when adding an IPLD Node via the DAG service. */ defaultOptions: AddOptions; /** * The underlying block service for adding, deleting, and retrieving blocks. */ blockService: BlockService; /** * DAGService creates a new directed acyclic graph (DAG) service. * * @param {DAGOptions} options The set of parameters to use when initializing a DAG service. Must include a `blockService` entry. */ constructor(options: DAGOptions); /** * resolve retrieves IPLD nodes along the path that is rooted at a given IPLD node. * * @param {CID} cid The content identifier at which to start resolving. * @param {string} path The path that should be resolved. */ resolve(cid: CID, path: string): AsyncIterableIterator; /** * tree returns all the paths that can be resolved into. * * @param {CID} cid The ID to get the paths from * @param {string} offsetPath the path to start to retrieve the other paths from. * @param {object} options Currently only whether to get the paths recursively or not. If `recursive` is * `false`, it will only resolve the paths of the given CID. */ tree(cid: CID, offsetPath?: string, options?: { recursive: boolean; }): AsyncIterableIterator; /** * get returns an IPLD node by its content identifier. * * @param {CID} cid The content identifier for the IPLD node that should be retrieved. */ get(cid: CID): Promise; /** * getMany returns multiple IPLD nodes from an iterable of content identifiers. * * @param {Iterable} cids The content identifiers for the IPLD nodes that should be retrieved. */ getMany(cids: Iterable): AsyncIterableIterator; /** * put encodes and adds an IPLD node using the specified codec. * * @param {any} node The deserialized IPLD node that should be added. Can be any value, object, Buffer, JSON, etc. * @param {string | number} codec A string representing the multicodec with which the IPLD node should be encoded. * Can also be a numeric multicodec code for compatibility with js-ipld. * @param {AddOptions} options The specific parameters to use when encoding the input node. */ put(node: any, codec?: string | number, options?: AddOptions): Promise; /** * putMany encodes and adds multiple IPLD nodes using the specified codec. * * @param {Iterable} nodes The deserialized IPLD nodes that should be added. * @param {string | number} codec A string representing the multicodec with which the IPLD node should be encoded. * Can also be a numeric multicodec code for compatibility with js-ipld. * @param {AddOptions} options The specific parameters to use when encoding the input node. */ putMany(nodes: Iterable, codec?: string | number, options?: AddOptions): AsyncIterableIterator; /** * remove deletes an IPLD node from the local store. * * @param {CID} cid The content identifier for the IPLD node to be removed. */ remove(cid: CID): Promise; /** * removeMany deletes multiple IPLD nodes from the local store. * * Throws an error if any of the Blocks can’t be removed. This operation is *not* atomic, some nodes might have * already been removed. * * @param {Iterable} cids The content identifiers for the IPLD nodes to be removed. */ removeMany(cids: Iterable): AsyncIterableIterator; }