import { ITelegramClient } from '../client.types.js';
export type BatchedQuery<T, U> = (client: ITelegramClient, item: T) => Promise<U | null>;
/**
 * Helper function for building batched queries.
 *
 * Concepts:
 *   - "input" - items being passed to the query function
 *   - "output" - items returned by the query function
 *   - "key" - unique identifier of the item, which should be deriveable from both input and output.
 *     used for matching input and output items and deduplicating them.
 */
export declare function batchedQuery<T, U>(params: {
    /**
     * Fetcher function, taking an array of input items and returning an array of output items.
     *
     * If some item is not found, it should be omitted from the result array,
     * this way the corresponding request will be resolved with `null`.
     */
    fetch: (client: ITelegramClient, items: T[]) => Promise<U[]>;
    /** Key derivation function for input items */
    inputKey: (item: T, client: ITelegramClient) => string | number;
    /** Key derivation function for output items */
    outputKey: (item: U, client: ITelegramClient) => string | number;
    /**
     * Maximum number of items to be passed to the `fetcher` function at once.
     *
     * It is recommended to pass ~half of the maximum allowed by the server,
     * since in some cases failing on a single item will cause the whole batch to fail.
     *
     * @default  Infinity
     */
    maxBatchSize?: number;
    /**
     * Maximum number of concurrently running queries.
     *
     * @default  1
     */
    maxConcurrent?: number;
    /**
     * In case of an error, we can try retrying the query for some items one-by-one,
     * to avoid failing the whole batch.
     *
     * @param items  Items contained in the batch that failed
     * @param err  Error that was thrown by the fetcher
     * @returns  `true` if the query should be retried for all items, `false` if it should be retried for none,
     *   or an array of items for which the query should be retried (waiters for other items will throw `err`).
     */
    retrySingleOnError?: (items: T[], err: unknown) => boolean | T[];
}): BatchedQuery<T, U>;
