import type { OptionalPaginationParams, PaginatedResponse, PaginationMeta } from './apiSchemas.ts'; /** * @deprecated use `createPaginatedResponse` instead * * Constructs a PaginationMeta object encapsulating the total count and the cursor for fetching the next page. * * The resultant cursor can be either a simple string or an encoded string based on the 'cursorKeys' parameter. * - If 'cursorKeys' is undefined, the cursor will default to the 'id' property of the last element in 'data'. * - If 'cursorKeys' contains a single key, the cursor will correspond to the value of that key from the last element * in 'data'. * - If 'cursorKeys' features multiple keys, the cursor will be an encoded string incorporating the values of these * keys from the last element in 'data'. * * @param currentPageData - A generic array of objects, each object expected to extend { id: string }. * @param cursorKeys - An optional array of keys that determine the formation of the cursor. By default, this uses * the 'id' property. * @param pageLimit - An optional number that can be used to specify the expected count of items in the current page. * - If it is provided and currentPageData length is less than or equal to pageLimit, it means that there are no more items to fetch. * In that case, hasMore flag will be set to false. Otherwise, hasMore flag will be set to true. * If currentPageData length is greater than pageLimit, count will be set to pageLimit. * - If the parameter is not provided, hasMore flag will be undefined. * * @returns PaginationMeta - An object detailing two crucial properties required for effective pagination: total item * count, the cursor and has more flag. */ export declare function getMetaForNextPage(currentPageData: T[], cursorKeys?: undefined, pageLimit?: number): PaginationMeta; export declare function getMetaForNextPage, K extends keyof T>(currentPageData: T[], cursorKeys: K[], pageLimit?: number): PaginationMeta; /** * Constructs a PaginatedResponse object with the current page respecting page limit and building meta to retrieve next page. * * @param page - Current page of objects which will be included in `data`. It will be sliced to pageLimit if provided * @param pageLimit - An optional number that can be used to specify the expected count of items in the current page. * - If it is provided and page length is less than or equal to pageLimit, it means that there are no more items to fetch. * In that case, hasMore flag will be set to false. Otherwise, hasMore flag will be set to true. * If currentPageData length is greater than pageLimit, it will be sliced and count will be set to pageLimit. * - If the parameter is not provided, hasMore flag will be undefined. * @param cursorKeys - An optional array of keys that determine the formation of the cursor. By default, this uses * the 'id' property. * - If 'cursorKeys' is undefined, the cursor will default to the 'id' property of the last element in 'data'. * - If 'cursorKeys' contains a single key, the cursor will correspond to the value of that key from the last element * in 'data'. * - If 'cursorKeys' features multiple keys, the cursor will be an encoded string incorporating the values of these * keys from the last element in 'data'. * * @returns PageResponse * * Note: `hasMore` flag will be undefined if `pageLimit` is not provided, please read the param doc for more details. */ export declare function createPaginatedResponse(page: T[], pageLimit: number | undefined, cursorKeys?: undefined): PaginatedResponse; export declare function createPaginatedResponse, K extends keyof T>(page: T[], pageLimit: number | undefined, cursorKeys: K[]): PaginatedResponse; /** * @deprecated use {@link getPaginatedEntriesByHasMore} * * This function will collect all paginated entries based on returned 'cursor'. * For function to behave correctly the last result should have 'cursor === undefined'. * * @param pagination * @param apiCall * * @example * <caption>Example usage of method</caption> * await getPaginatedEntries({ limit: 1 }, (params) => { * return market.getApples(params) * } */ export declare function getPaginatedEntries>(pagination: OptionalPaginationParams, apiCall: (params: OptionalPaginationParams) => Promise>): Promise; /** * This function will collect all paginated entries based on returned 'cursor' and 'hasMore' fields. * * For better experience should be used in combine with {@link createPaginatedResponse} function. * * @param pagination * @param apiCall * * @example * Example of usage with limit * await getPaginatedEntries({ limit: 1 }, (params) => { * return market.getApples(params) * } * * Example of usage with limit and start cursor * await getPaginatedEntries({ limit: 1, after: 'red' }, (params) => { * return market.getApples(params) * } */ export declare function getPaginatedEntriesByHasMore>(pagination: OptionalPaginationParams, apiCall: (params: OptionalPaginationParams) => Promise>): Promise;