import { Helia } from '@helia/interface'; import { CID } from 'multiformats'; import { NormalizedDagLink, NormalizedDagNode } from '../types.js'; interface ResolvedIpldPathInfo { targetNode: NormalizedDagNode; canonicalPath: string; localPath: string; nodes: NormalizedDagNode[]; pathBoundaries: object[]; } export interface IpldInterface { get(): Promise; resolve(): Promise; } /** * Walk an IPLD path to find all the nodes and path boundaries it traverses. * * Normalizes nodes into a common structure: * * ```js * { cid: String, type: 'dag-cbor' | 'dag-pb' | 'git-raw' | ..., data: *, links: [{cid, name}] } * ``` * * Path boundaries capture the source and target cid where a path traverses a link: * * ```js * { linkPath: 'a/b', source: `zdpHash1` target: `zdpHash2`' } * ``` * * Usage: * ```js * const res = resolveIpldPath(getHelia, 'zdpuHash' '/favourites/0/a/css') * const {targetNode, canonicalPath, localPath, nodes, pathBoundaries} = res * ``` * Where: * - `targetNode` is the normalised node that the path lands in. * - `canonicalPath` is the shortest cid + path that can be used to locate the targetNode * - `localPath` is the tail part of the path that is local to the targetNode. May be '' * - `nodes` is the array of nodes that the path traverses. * - `pathBoundaries` is the array of links that the path traverses. */ export declare function resolveIpldPath(helia: Helia, sourceCid: CID | string, path: string, nodes?: NormalizedDagNode[], pathBoundaries?: NormalizedDagLink[]): Promise; export interface IpldGetNodeAndRemainderResult { /** * The decoded value of the node at the given path */ value: any; /** * The path that was not resolved */ remainderPath: string; } export declare function ipldGetNodeAndRemainder(helia: Helia, sourceCid: CID | string, path?: string): Promise; /** * Find the link object that matches linkPath * * @param {import('./normalise-dag-node').NormalizedDagNode} node - a `normalisedDagNode` * @param {string} linkPath - an IPLD path string * @returns {import('./normalise-dag-node').NormalizedDagLink} the link object for `linkPath` */ export declare function findLink(node: NormalizedDagNode, linkPath: string | null): NormalizedDagLink | null; export declare function findLinkPath(fullPath: string, remainderPath: string): string | null; export declare function trimSlashes(str: string): string; export {};