// Copyright © 2022-2026 Partium, Inc. DBA Partium import { Observable } from 'rxjs'; import { APIObject } from '../models/api-object'; import { BACKEND_SERVICE, HttpsService } from './http/https.service.interface'; import { PaginatedList } from '../models/paginated-list'; /** * Non-injectable Service that fetches data from a paginated API-endpoint. * The service is generic and can be used for different types of data. * * Usage: * 1) initialize via constructor for endpoint that it should be used for * 2) call loadInitialPage to receive first page from server * 3) call loadMore to load the next page from server * 4) to access currently loaded paginated list call getLoadedPaginatedList (returns last successfully loaded list from server) */ export interface PaginatedRequestService { /** * Will trigger loading the first page of objects from the configured endpoint. * * @param concatResult if true, the lists returned by loadMore() will always * contain the full concatenated list of results. If false, it will only * contain the current page. * @returns observable that emits with an object of type PaginatedList, which * contains the items of the current page, the current page-index, the * total pages, ... */ loadInitialPage(concatResult?: boolean): Observable>; /** * @deprecated use loadInitialPage instead * * Will trigger loading the first page of objects from the configured endpoint. * * @param concatResult if true, the lists returned by loadMore() will always * contain the full concatenated list of results. If false, it will only * contain the current page. * @returns observable that emits with an object of type PaginatedList, which * contains the items of the current page, the current page-index, the * total pages, ... */ getPaginatedList(concatResult?: boolean): Observable>; /** * @returns the currently loaded paginated list, which was last successfully loaded from the server */ getLoadedPaginatedList(): PaginatedList; /** * @returns true if the initial page was loaded successfully, false otherwise */ isInitialPageLoaded(): boolean; /** * @returns true if there is currently a page loading from the server, false otherwise */ isPageLoading(): boolean; /** * @returns true if there are more results available to load, false otherwise */ hasMoreResultsAvailable(): boolean; /** * Fetch the next page of objects from configured endpoint. * @returns observable that emits with an object of type PaginatedList, which * contains the items of the current page (or the whole concatenated * list), the current page-index, the total pages, ... */ loadMore(): Observable>; /** * Load a specific page with the given page-index from the backend. * If loadMore is called after this function is called, the next page after * this one will be loaded. * * @param pageIdx the page to load (1-indexed) * @returns Observable that emits the PaginatedList loaded from backend */ loadPage(pageIdx: number): Observable>; } export declare class PaginatedRequestServiceImpl implements PaginatedRequestService { private httpsService; private url; private urlParams; private backendService; private pageSize; private paginatedList; private concatResult; private initialPageLoaded; private pageLoading; private cursorPaginationEnabled; private createObject; constructor(createObject: (resObj: any) => T, httpsService: HttpsService, url: string, backendService?: BACKEND_SERVICE, urlParams?: Array, pageSize?: number, cursorPaginationEnabled?: boolean); loadInitialPage(concatResult?: boolean): Observable>; getPaginatedList(concatResult?: boolean): Observable>; getLoadedPaginatedList(): PaginatedList; isInitialPageLoaded(): boolean; isPageLoading(): boolean; hasMoreResultsAvailable(): boolean; loadMore(): Observable>; loadPage(pageIdx: number): Observable>; /** * Fetch page of paginated list from server * * @param pageIdx which page to fetch * @returns Observable that resolves with the PaginatedList object of the requested page */ private fetchPaginatedListFromServer; private concatenateItems; private removeUrlParam; }