import { Observable } from 'rxjs'; import { ResultSet, DataQuery, DataSource } from './data-source'; import { DataMapper } from '@softeq/data-mappers'; import { RestSettings } from './rest-settings.service'; import { AbstractRestService, HttpRequestConfig } from './abstract-rest.service'; /** * Definition of HTTP request operation which returns paginable result set. */ export declare type HttpSlicedDataRequestConfig = HttpRequestConfig; /** * Definition of HTTP request operation having given query which returns pageable result set. */ export interface HttpSlicedDataQueryRequestConfig extends HttpSlicedDataRequestConfig { query: DataQuery; } /** * Basic class for all REST services. * It provides basic support of operations over HTTP protocol and integration with mappers. */ export declare abstract class AbstractPaginationRestService extends AbstractRestService { constructor(settings: RestSettings); /** * Performs HTTP paginable request operation based on given config and using provided mappers (from config). * Paginable request differs from typical request in the following way * * * paginable request always has query. * Query tells how to sort data and what slice of data should be retrieved from backend. * Slice is defined by interval (from ... to) * * paginable request adds additional query parameter (sortBy) which defines how to sort data * * paginable request adds range header (Range) which defines slice of data that should be retrieved * * paginable request always returns instance of {@link ResultSet} */ protected createSlicedDataRequest(config: HttpSlicedDataQueryRequestConfig): Observable>; /** * Creates {@link DataSource} based on GET requests. * Each request use provided mapper to deserialize its response. * * @param path relative url for endpoint * @param responseMapper mapper for response entity */ protected createSlicedDataSourceGet(path: string, responseMapper: DataMapper): DataSource; /** * Creates {@link DataSource} based on GET requests. * * This method allows to pass additional parameters common for each request. * Body is serialized using provided request mapper (optional). * * Each request use provided mapper to deserialize its response. * * @param path relative url for endpoint * @param body body is merged into url using querystring library. * @param requestMapper serializes body. Optional, if mapper is not provided body is used as is. * @param responseMapper mapper for response entity */ protected createSlicedDataSourceGet(path: string, body: Req, requestMapper: DataMapper | undefined, responseMapper: DataMapper): DataSource; /** * Creates {@link DataSource} based on POST requests. * * This method allows to pass additional parameters common for each request. * Body is serialized using provided request mapper. * * Each request use provided mapper to deserialize its response. * * @param path relative url for endpoint * @param body entity to be serialized and send * @param requestMapper mapper for request entity * @param responseMapper mapper for response entity */ protected createSlicedDataSourcePost(path: string, body: S, requestMapper: DataMapper, responseMapper: DataMapper): DataSource; /** * Creates {@link DataSource} based on PUT requests. * * This method allows to pass additional parameters common for each request. * Body is serialized using provided request mapper. * * Each request use provided mapper to deserialize its response. * * @param path relative url for endpoint * @param body entity to be serialized and send * @param requestMapper mapper for request entity * @param responseMapper mapper for response entity */ protected createSlicedDataSourcePut(path: string, body: S, requestMapper: DataMapper, responseMapper: DataMapper): DataSource; /** * Creates {@link DataSource} based on the provided config. * One instance of {@link DataSource} can be used to request data * for different queries ({@link DataQuery}). * Each performed query use configuration provided in the config parameter. * See {@link #createSlicedDataRequest} for details. */ protected createSlicedDataSource(config: HttpSlicedDataRequestConfig): DataSource; }