/** * Pagination utilities for consistent pagination across all API categories */ import type { PaginationRequest, PaginationResponse, CursorPaginationRequest, CursorPaginationResponse } from "../types/common/base.js"; /** * Основные типы пагинации */ export type PaginationType = "offset" | "cursor"; /** * Конфигурация пагинации */ export interface PaginationConfig { /** Тип пагинации */ type: PaginationType; /** Лимит по умолчанию */ defaultLimit: number; /** Максимальный лимит */ maxLimit: number; } /** * Конфигурации пагинации для различных категорий API */ export declare const PAGINATION_CONFIGS: Record; /** * Хелпер для создания offset-пагинации запроса */ export declare function createOffsetPaginationRequest(options: { limit?: number; last_id?: number; category: string; }): PaginationRequest; /** * Хелпер для создания cursor-пагинации запроса */ export declare function createCursorPaginationRequest(options: { limit?: number; cursor?: string; category: string; }): CursorPaginationRequest; /** * Проверка, есть ли следующая страница для offset пагинации */ export declare function hasNextPageOffset(response: PaginationResponse, requestedLimit: number, itemsCount: number): boolean; /** * Проверка, есть ли следующая страница для cursor пагинации */ export declare function hasNextPageCursor(response: CursorPaginationResponse): boolean; /** * Получить следующий последний ID для offset пагинации */ export declare function getNextLastId(items: T[]): number | undefined; /** * Универсальный итератор для автоматической пагинации (offset) */ export declare function paginateOffset(fetcher: (request: TRequest) => Promise, baseRequest: Omit, category: string, itemsExtractor: (response: TResponse) => TItem[] | undefined): AsyncIterableIterator; /** * Универсальный итератор для автоматической пагинации (cursor) */ export declare function paginateCursor(fetcher: (request: TRequest) => Promise, baseRequest: Omit, category: string, itemsExtractor: (response: TResponse) => TItem[] | undefined): AsyncIterableIterator; /** * Собрать все результаты из пагинированного API (offset) */ export declare function collectAllOffset(fetcher: (request: TRequest) => Promise, baseRequest: Omit, category: string, itemsExtractor: (response: TResponse) => TItem[] | undefined, maxItems?: number): Promise; /** * Собрать все результаты из пагинированного API (cursor) */ export declare function collectAllCursor(fetcher: (request: TRequest) => Promise, baseRequest: Omit, category: string, itemsExtractor: (response: TResponse) => TItem[] | undefined, maxItems?: number): Promise; //# sourceMappingURL=pagination.d.ts.map