export declare const compareKeys: (a: string, b: string) => number; export interface PaginateOptions { prefix?: string; cursor?: string; limit?: number; } export interface PaginatedKeys { keys: string[]; cursor?: string; } /** * Page a sorted key list. Filters by `prefix`, starts after `cursor`, and * returns up to `limit` keys (default 1000) plus a `cursor` when more remain. * `sortedKeys` must already be sorted with {@link compareKeys}. */ export declare const paginateKeys: (sortedKeys: readonly string[], options?: PaginateOptions) => PaginatedKeys; export interface PaginateHierarchyOptions { prefix?: string; delimiter: string; cursor?: string; limit?: number; } export interface PaginatedHierarchy { /** Direct keys with no delimiter after the prefix. */ items: string[]; /** Collapsed groups, each ending in the delimiter. */ prefixes: string[]; cursor?: string; } /** * Synthesize S3-style common-prefix ("folder") listing from a sorted flat key * list, for adapters with no native delimiter support (fs, memory, FTP, SFTP, * Google Drive, Cloudinary). Mirrors {@link paginateKeys}' cursor scheme so * callers see identical pagination across every key-list adapter. * * Walks in key order spending one shared `limit` budget per **entry**: a * direct key (no delimiter at/after `prefix.length`) is an item; otherwise the * key collapses into `prefix + segment + delimiter` and every contiguous key * under that group is consumed atomically — a collapsed prefix counts as one * entry against the budget (matching S3's CommonPrefix accounting) but is never * split across a page. * * The cursor is always the **last real key consumed**, never a collapsed * prefix string: a prefix `P` sorts *before* its own group's keys (`P + rest > * P`), so resuming at `first key > P` would re-list the group. The last real * key sorts after the whole group and before the next entry, so the existing * strictly-greater resume lands correctly. * * `sortedKeys` must already be sorted with {@link compareKeys}. */ export declare const paginateHierarchy: (sortedKeys: readonly string[], options: PaginateHierarchyOptions) => PaginatedHierarchy; export interface PageKeyListOptions { prefix?: string; cursor?: string; limit?: number; delimiter?: string; } export interface PagedKeyList { keys: string[]; prefixes?: string[]; cursor?: string; } /** * Page a sorted key list, picking flat ({@link paginateKeys}) or hierarchical * ({@link paginateHierarchy}) pagination based on whether `delimiter` is set. * The single entry point every key-list adapter (fs, memory, FTP, SFTP, and * the test fake) calls so the flat/folder branch lives in one place. */ export declare const pageKeyList: (sortedKeys: readonly string[], options?: PageKeyListOptions) => PagedKeyList; //# sourceMappingURL=walk-paginate.d.ts.map