UNPKG

@push.rocks/smartrequest

Version:

A module for modern HTTP/HTTPS requests with support for form data, file uploads, JSON, binary data, streams, and more.

59 lines (58 loc) 1.7 kB
import type { ICoreResponse } from '../../core_base/types.js'; /** * Pagination strategy options */ export declare enum PaginationStrategy { OFFSET = "offset",// Uses page & limit parameters CURSOR = "cursor",// Uses a cursor/token for next page LINK_HEADER = "link",// Uses Link headers CUSTOM = "custom" } /** * Configuration for offset-based pagination */ export interface OffsetPaginationConfig { strategy: PaginationStrategy.OFFSET; pageParam?: string; limitParam?: string; startPage?: number; pageSize?: number; totalPath?: string; } /** * Configuration for cursor-based pagination */ export interface CursorPaginationConfig { strategy: PaginationStrategy.CURSOR; cursorParam?: string; cursorPath?: string; hasMorePath?: string; } /** * Configuration for Link header-based pagination */ export interface LinkPaginationConfig { strategy: PaginationStrategy.LINK_HEADER; } /** * Configuration for custom pagination */ export interface CustomPaginationConfig { strategy: PaginationStrategy.CUSTOM; hasNextPage: (response: ICoreResponse<any>) => boolean; getNextPageParams: (response: ICoreResponse<any>, currentParams: Record<string, string>) => Record<string, string>; } /** * Union type of all pagination configurations */ export type TPaginationConfig = OffsetPaginationConfig | CursorPaginationConfig | LinkPaginationConfig | CustomPaginationConfig; /** * Interface for a paginated response */ export interface TPaginatedResponse<T> { items: T[]; hasNextPage: boolean; getNextPage: () => Promise<TPaginatedResponse<T>>; getAllPages: () => Promise<T[]>; response: ICoreResponse<any>; }