@netgrif/components-core
Version:
Netgrif Application engine frontend core Angular library
46 lines (45 loc) • 2.13 kB
TypeScript
import { ResourceProvider } from '../resource-provider.service';
import { ConfigurationService } from '../../configuration/configuration.service';
import { Page } from '../interface/page';
/**
* The class that contains behavior common to all resource services.
*
* Mostly endpoint URL resolution and utility functions for response parsing.
*/
export declare abstract class AbstractResourceService {
protected _resourceProvider: ResourceProvider;
protected configurationService: ConfigurationService;
private _SERVER_URL;
private readonly resourceName;
/**
* @param resourceName the identifier of the desired endpoint from configuration, found in
* {@link SetAuthAndResourcesAddress}.[resources]{@link Resources}.
* @param _resourceProvider `ResourceProvider` instance
* @param configurationService `ConfigurationService` instance
*/
protected constructor(resourceName: string, _resourceProvider: ResourceProvider, configurationService: ConfigurationService);
protected get SERVER_URL(): string;
/**
* Get URL form nae.json - resources
* @param name - ID property
*/
protected getResourceAddress(name: string): string;
/**
* Parses a response `response` into a {@link Page} instance
* @param response - response object
* @param propertiesParams - plural form of the resource name, that is used to extract the data. Eg. "cases".
*/
protected getResourcePage<T>(response: any, propertiesParams: string): Page<T>;
/**
* Extracts data from the response `response` into an object with better usability.
* @param response - response object
* @param propertiesParams - plural form of the resource name, that is used to extract the data. Eg. "cases".
*/
protected changeType<T>(response: any, propertiesParams: string): T;
/**
* Converts a Spring-style paginated response into the application's Page<T> format.
* @param response The raw response from backend (Spring `PageImpl` structure).
* @returns Converted Page<T> object.
*/
protected mapToPage<T>(response: any): Page<T>;
}