import { TwitterRateLimit, TwitterResponse } from '../types'; import TwitterApiSubClient from '../client.subclient'; export interface ITwitterPaginatorArgs { realData: TApiResult; rateLimit: TwitterRateLimit; instance: TwitterApiSubClient; queryParams: Partial; sharedParams?: TParams; } /** TwitterPaginator: able to get consume data from initial request, then fetch next data sequentially. */ export declare abstract class TwitterPaginator { protected _realData: TApiResult; protected _rateLimit: TwitterRateLimit; protected _instance: TwitterApiSubClient; protected _queryParams: Partial; protected _maxResultsWhenFetchLast: number; /** information unrelated to response data/query params that will be shared between paginator instances */ protected _sharedParams: TParams; protected abstract _endpoint: string; constructor({ realData, rateLimit, instance, queryParams, sharedParams }: ITwitterPaginatorArgs); protected get _isRateLimitOk(): boolean; protected makeRequest(queryParams: Partial): Promise>; protected makeNewInstanceFromResult(result: TwitterResponse, queryParams: Partial): this; protected getEndpoint(): string; protected injectQueryParams(maxResults?: number): { max_results?: number | undefined; } & Partial; protected abstract refreshInstanceFromResult(result: TwitterResponse, isNextPage: boolean): any; protected abstract getNextQueryParams(maxResults?: number): Partial; protected abstract getPageLengthFromRequest(result: TwitterResponse): number; protected abstract isFetchLastOver(result: TwitterResponse): boolean; protected abstract canFetchNextPage(result: TApiResult): boolean; protected abstract getItemArray(): TItem[]; /** * Next page. */ next(maxResults?: number): Promise; /** * Next page, but store it in current instance. */ fetchNext(maxResults?: number): Promise; /** * Fetch up to {count} items after current page, * as long as rate limit is not hit and Twitter has some results */ fetchLast(count?: number): Promise; get rateLimit(): { day?: import("../types").SingleTwitterRateLimit | undefined; userDay?: import("../types").SingleTwitterRateLimit | undefined; limit: number; reset: number; remaining: number; }; /** Get raw data returned by Twitter API. */ get data(): TApiResult; get done(): boolean; /** * Iterate over currently fetched items. */ [Symbol.iterator](): Generator; /** * Iterate over items "indefinitely" (until rate limit is hit / they're no more items available) * This will **mutate the current instance** and fill data, metas, etc. inside this instance. * * If you need to handle concurrent requests, or you need to rely on immutability, please use `.fetchAndIterate()` instead. */ [Symbol.asyncIterator](): AsyncGenerator; /** * Iterate over items "indefinitely" without modifying the current instance (until rate limit is hit / they're no more items available) * * This will **NOT** mutate the current instance, meaning that current instance will not inherit from `includes` and `meta` (v2 API only). * Use `Symbol.asyncIterator` (`for-await of`) to directly access items with current instance mutation. */ fetchAndIterate(): AsyncGenerator<[TItem, this], void, undefined>; } /** PreviousableTwitterPaginator: a TwitterPaginator able to get consume data from both side, next and previous. */ export declare abstract class PreviousableTwitterPaginator extends TwitterPaginator { protected abstract getPreviousQueryParams(maxResults?: number): Partial; /** * Previous page (new tweets) */ previous(maxResults?: number): Promise; /** * Previous page, but in current instance. */ fetchPrevious(maxResults?: number): Promise; } export default TwitterPaginator;