/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ import { type EastType } from "@elaraai/east"; import type { RemoteCollection } from "@elaraai/e3-api-client"; import { type ResultWindows } from "./results-table.js"; /** How many rows a page of a result holds: as many as a run returns. */ export declare const RESULT_PAGE_ROWS = 1000; /** * A result read a page at a time: a split call's output, opened by its hash. * * @property hash - The collection's hash: what the result is * @property type - Its type: an Array or a Set of the rows * @property total - How many rows it holds * @property page - Reads its rows `[offset, offset + limit)`, a value of its type */ export interface PagedResult { /** The collection's hash: what the result is. */ readonly hash: string; /** Its type, as the run's result is typed: an Array or a Set of the rows. */ readonly type: EastType; /** How many rows it holds. */ readonly total: number; /** * Reads its rows `[offset, offset + limit)`, fewer at its end. * * @param offset - The first row * @param limit - The most rows * @returns The rows, a value of its type */ page(offset: number, limit: number): Promise; } /** * A result from its collection, opened (e3-api-client's `collectionOpen`): an * Array's or a Set's rows, which the results show a row each. * * @param collection - The collection, opened by its hash * @returns The result, read a page at a time; `undefined` for a Dict, whose * entries the results show no rows of */ export declare function pagedResultOf(collection: RemoteCollection): PagedResult | undefined; /** A result's pages, as the results read them ({@link usePagedResult}). */ export interface PagedResultPages { /** The pages that landed, by index — page `p` holds rows from `p × RESULT_PAGE_ROWS` — each a value of the result's type. */ readonly pages: ReadonlyMap; /** Why a page could not be read, once one could not. */ readonly failure: string | undefined; /** * Reads the pages `[first, last]` that have not landed and are not being * read; each lands in {@link PagedResultPages.pages}. It sets nothing as * it is asked, so a renderer may ask in its render. */ need(first: number, last: number): void; /** * Lets go of the pages far from `[first, last]`, past those the results * hold: what a Tree scrolled far away asks. */ keep(first: number, last: number): void; } /** * Reads a result a page at a time: each page once, as the Table or the Tree * asks for it, through the page cache the dataset preview reads by * (`usePageReads`). A failure is said once, and the pages read stay; the page * that failed is read again when it is asked for again. * * @param paged - The result * @returns Its pages, and how to ask for more * * @remarks * Its pages are the result's, by its hash: a run whose result is another * reads its pages afresh, and a page read for the one before lands nothing. */ export declare function usePagedResult(paged: PagedResult): PagedResultPages; /** * A result's rows a window at a time, from the pages that landed: what the * Table's paged row source serves (`pagedResultTable`). A window whose pages * have not landed asks for them, and reads `undefined` until they do. * * @param paged - The result * @param read - Its pages ({@link usePagedResult}) * @returns Its windows */ export declare function resultWindows(paged: PagedResult, read: PagedResultPages): ResultWindows; //# sourceMappingURL=paged-result.d.ts.map