import { IndexEntry } from '@struktoai/mirage-core/cache/index/config'; import type { IndexCacheStore } from '@struktoai/mirage-core/cache/index/store'; import type { HfHubAccessor, RowTables } from '../../accessor/hf_hub.ts'; import { HfHubError } from './client.ts'; import type { TreeEntry } from './tree_entry.ts'; /** Turn one tree row into a TreeEntry. */ export declare function parseEntry(item: Record): TreeEntry; /** * The next page's URL, read out of the Link header. * * The Hub pages the tree with an opaque cursor rather than a page number, so * the only way to ask for page two is to follow the URL it handed back. */ export declare function nextCursor(headers: Record): string; /** Query for one tree page. */ export declare function pageParams(expand: boolean): Record; /** The tree endpoint for the mount's revision and key prefix. */ export declare function treeUrl(accessor: HfHubAccessor): string; /** Fold one page of tree rows into the mount's listing. */ export declare function collect(rows: unknown, prefix: string, into: Map): void; /** Follow the cursor from one page to the last, folding as it goes. */ /** * The refusal for a listing the page ceiling cut short. * * Thrown rather than returned because this listing is not a cache in front * of the Hub, it is seeded as the mount's whole index: a partial one reads * as a complete one, so every file past the ceiling becomes a confident * false absence and `hf download` silently omits it. An error the caller * can see is the lesser failure. */ export declare function truncated(repoId: string): HfHubError; export declare function walkPages(accessor: HfHubAccessor, url: string, params: Record | undefined, into: Map, limit?: number): Promise; /** * Every path under the mount's subtree, in one paged walk. * * `recursive=true` returns the whole subtree. Size, oid and the LFS and Xet * hashes all ride the bare row, so the only thing `expand=true` adds is the * commit that last touched each path -- a Hub file's only mtime -- and it * costs a twentyfold drop in page size (1000 rows to 50, with any explicit * limit above 100 refused). * * Which one is used is the mount's call, and its default is neither: ask for * one expanded page, and if the whole repository fit in it, that page is the * answer and the mtimes came free. Only a repository too big for one page * falls back to the bare walk, and pays one wasted request for the attempt. */ export declare function fetchTree(accessor: HfHubAccessor): Promise>; /** * Bucket a Hub tree by parent directory. * * Keyed by mount-absolute path, the way every other backend keys its index, * so the shared cache machinery can spell an eviction without knowing which * backend it is talking to. The tree itself stays mount-relative; `prefix` is * what lifts it. This is the one shape both storage paths are built from, so * the seeded index and the derived tables cannot disagree. */ export declare function indexDirs(tree: Map, prefix: string): Map; /** The entry and children tables a no-index mount reads, from the buckets. */ export declare function indexRows(tree: Map, prefix: string): RowTables; /** * Write the accessor's tree into `index` under `prefix`. * * One `setDir` per directory, the way the shared store spells a whole * listing; the year-long expiry is what makes the index the listing rather * than a cache in front of one. */ export declare function seedIndex(accessor: HfHubAccessor, index: IndexCacheStore, prefix: string): Promise; /** * Refetch the tree and re-seed the index from it. * * The mount fetches the whole tree once and seeds the index with it, so the * index *is* the listing rather than a cache in front of one. That makes a * cleared or expired index indistinguishable from an empty repository, which * is why dropping the index has to mean "refetch". */ export declare function refillIndex(accessor: HfHubAccessor, index: IndexCacheStore, prefix: string): Promise; /** * Refetch when the index holds no listing at all. * * Every reader treats a missing listing as a real absence, which is right * against a *live* index and wrong against one that was never filled or has * been dropped. The root listing is what tells the two apart, in one lookup * and no request: the tree is written whole, so while the index is live the * mount root always has a row. */ export declare function ensureLiveIndex(accessor: HfHubAccessor, index: IndexCacheStore, prefix: string): Promise; /** * Fetch the tree if this mount has not got one yet. * * Hydration is tracked by `treeLoaded`, never by whether the tree holds * anything: an empty repository hydrates to an empty map, and reading that as * "not hydrated" refetches it on every call forever. */ export declare function ensureTree(accessor: HfHubAccessor, index?: IndexCacheStore, prefix?: string): Promise; /** * The index tables built straight from the accessor's tree. * * What a mount with no index wired reads instead. Every reader has an index * inside a workspace, but a backend constructed on its own has NULL_INDEX, * whose every lookup is a miss -- so without this, readdir answered ENOENT for * a repository it could list perfectly well. Built by the same `indexRows` the * seeded path uses, so the two cannot disagree. */ export declare function localRows(accessor: HfHubAccessor, prefix: string): Promise; //# sourceMappingURL=tree.d.ts.map