import type { FetchedMessage } from '../../../../core/email/client.ts'; declare const SORT_KINDS: readonly ["date", "from", "to", "subject"]; type SortKind = (typeof SORT_KINDS)[number]; export declare class QueryError extends Error { } export interface Sorter { kind: SortKind; descending: boolean; } export interface Query { criteria: string; sorters: Sorter[]; } /** Parses a himalaya search query into IMAP criteria plus sorters. */ export declare function parseQuery(source: string): Query; /** * Orders fetched headers by the query's sorters, applied right to left so * the first sorter ends up the primary key. With no sorters the order is * date descending, matching `envelope list`. */ export declare function sortHeaders(headers: FetchedMessage[], sorters: readonly Sorter[]): FetchedMessage[]; /** Takes one page of results, counting from 1. */ /** * How many of the newest matching UIDs to fetch headers for. * * Sorting happens client-side, so a page cannot be served without * holding the candidate headers. Under the default order (date * descending) the newest `page * pageSize` messages are the only ones * that can appear, so ask for exactly those. An explicit `order by` is * unrelated to arrival order, so the whole account window has to be * considered, capped by `maxMessages` either way: that is the account * knob for how far back mirage looks, and without it one `envelope list` * would fetch every message in the mailbox. */ export declare function uidBudget(page: number, pageSize: number, sorters: readonly Sorter[], maxMessages: number): number; export declare function pageSlice(items: readonly T[], page: number, pageSize: number): T[]; export {}; //# sourceMappingURL=query.d.ts.map