import bigInt from "big-integer"; import { Api } from "../tl"; import type { TelegramBaseClient } from "../client/telegramBaseClient"; export interface FilePoolOptions { /** * Number of parallel MTProto sessions per DC. Each session is a separate * TCP connection sharing the per-DC auth key. Telegram drops connections * if too many open at once on the same auth key, so we open them one at * a time with {@link sessionStartupDelayMs} between each. */ sessions: number; /** * Maximum concurrent `upload.GetFile` requests across all sessions of a * single DC. The download loop never schedules more than this many parts * in flight per DC. */ inflightPerDc: number; /** * Default part size (in bytes). Must be a multiple of 4096 and ≤ 1 MB. */ partSize: number; /** * When all sessions of a DC have been idle for this long, the underlying * connections are dropped. Set to `0` to never auto-disconnect. */ idleTimeoutMs: number; /** * Per-part retry budget for transient errors (FLOOD_WAIT, TIMEOUT, * server-side hiccups). Hard errors propagate immediately. */ requestRetries: number; /** Opt-in to CDN redirects. Disabled by default — most users don't need it. */ cdnSupported: boolean; /** * Minimum gap between TCP connects to the same DC. Telegram's anti-abuse * drops bursts of fresh connections that share an auth key, so we space * them out. Set to 0 to disable the gap. */ sessionStartupDelayMs: number; } export declare const DEFAULT_FILE_POOL_OPTIONS: FilePoolOptions; export declare class CdnRedirectError extends Error { readonly redirect: Api.upload.FileCdnRedirect; constructor(redirect: Api.upload.FileCdnRedirect); } export declare class FilePoolClosedError extends Error { constructor(); } export declare class FilePoolAbortError extends Error { constructor(); } export declare class FilePool { readonly opts: FilePoolOptions; readonly client: TelegramBaseClient; private readonly _dcs; private _closed; constructor(client: TelegramBaseClient, opts?: Partial); private _dc; getFile(dcId: number, location: Api.TypeInputFileLocation, offset: bigInt.BigInteger, limit: number, signal?: AbortSignal): Promise; private _invokeOnSlot; purge(dcId?: number): Promise; close(opts?: { waitMs: number; }): Promise; }