import * as i0 from '@angular/core'; import { Injector, ModuleWithProviders } from '@angular/core'; import { Observable } from 'rxjs'; import { HttpHeaders, HttpParams, HttpResponse, HttpClient } from '@angular/common/http'; /** * Using for model classes that it's not Resource but can hold Resources as property, for example is Embeddable entity. * A distinctive feature of such resources is that they do not have the self link while {@link Resource} has. * It's related with that Embeddable entity can't have an id property. * * Usage example: * * // Regular resource * class Product extends Resource { * name: string; * } * * // EmbeddedResource that holds Product resource. * class CartItem extends EmbeddedResource { * product: Product; * } */ declare class EmbeddedResource extends BaseResource { } /** * Resource link object. */ interface Link { /** * Link name. */ [key: string]: LinkData; } interface LinkData { /** * Link url. */ href: string; /** * {@code true} if href has template, {@code false} otherwise. */ templated?: boolean; } /** * Interface that allows to identify that object is resource when it is has a links object. */ interface ResourceIdentifiable { /** * List of links related with the resource. */ _links: Link; } /** * Http options that used by Angular HttpClient. */ interface HttpClientOptions { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: 'body' | 'response'; params?: HttpParams; reportProgress?: boolean; responseType?: 'json'; withCredentials?: boolean; } /** * Extend {@link GetOption} with page param. */ interface PagedGetOption extends GetOption { pageParams?: PageParam; } /** * Contains options that can be applied to POST/PUT/PATCH/DELETE request. */ interface RequestOption { params?: RequestParam; headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: 'body' | 'response'; reportProgress?: boolean; withCredentials?: boolean; } /** * Contains additional options that can be applied to the GET request. */ interface GetOption extends RequestOption { /** * Sorting options. */ sort?: Sort; useCache?: boolean; } /** * Request params that will be applied to the result url as http request params. * * Should not contains params as: 'projection' and {@link PageParam} properties. * If want pass this params then use suitable properties from {@link GetOption} or {@link PagedGetOption}, * otherwise exception will be thrown. */ interface RequestParam { [paramName: string]: Resource | string | number | boolean | Array | Array; } /** * Page content params. */ interface PageParam { /** * Number of page. */ page?: number; /** * Page size. */ size?: number; } /** * Page params with sort option. */ interface SortedPageParam { /** * Page content params. */ pageParams?: PageParam; /** * Sorting options. */ sort?: Sort; } type SortOrder = 'DESC' | 'ASC'; interface Sort { /** * Name of the property to sort. */ [propertyToSort: string]: SortOrder; } /** * Page resource response from Spring application. */ interface PageData { page: { size: number; totalElements: number; totalPages: number; number: number; }; _links?: { first: { href: string; }; prev?: { href: string; }; self: { href: string; }; next?: { href: string; }; last: { href: string; }; }; } declare enum Include { /** * Allows to include null values to request body */ NULL_VALUES = "NULL_VALUES", /** * Not replace related resources with their self links, instead pass them as JSON objects. */ REL_RESOURCES_AS_OBJECTS = "REL_RESOURCES_AS_OBJECTS" } /** * Include options that allow configure should include or not some specific values * (e.q. null values). */ interface ValuesOption { include: Include | Include[]; } /** * Request body object. */ interface RequestBody { /** * Any object that will be passed as request body. */ body: T; /** * Use this param to influence on body values that you want include or not. */ valuesOption?: ValuesOption; } /** * Supported http methods for custom query. */ declare enum HttpMethod { GET = "GET", POST = "POST", PUT = "PUT", PATCH = "PATCH" } type NonResourcePropertyType = { [K in keyof T]: T[K] extends BaseResource ? never : K; }[keyof T]; /** * Type that allowed represent resource relations as resource projection excluding {@link Resource}, * {@link EmbeddedResource} props and methods from current type. */ type ProjectionRelType = Pick & NonResourcePropertyType>; /** * Additional cache modes. */ declare enum CacheMode { /** * Default mode. * When cache enable, then all HTTP GET methods will use cache. Except methods where explicitly passed {useCache : false}. */ ALWAYS = "ALWAYS", /** * This is opposite option for ALWAYS mode. * When cache enable, that mode will NOT use cache by default on all HTTP GET methods. * Except methods where explicitly passed {useCache : true}. */ ON_DEMAND = "ON_DEMAND" } /** * Abstract impl identifies resource interface. */ declare abstract class AbstractResource { /** * List of links related with the resource. */ protected _links: Link; /** * Get relation link by relation name. * * @param relationName used to get the specific resource relation link * @throws error if no link is found by passed relation name */ getRelationLink(relationName: string): LinkData; /** * Checks if relation link is present. * * @param relationName used to check for the specified relation name * @returns true if link is present, false otherwise */ hasRelation(relationName: string): boolean; } /** * Collection of resources without pagination. * * If you want to have a pagination {@see PagedResourceCollection}. */ declare class ResourceCollection extends AbstractResource { resources: Array; /** * Resource collection constructor. * If passed param then it used as a copy constructor. * * @param that (optional) another resource collection using to copy data from to current object */ constructor(that?: ResourceCollection); } /** * Collection of resources with pagination. */ declare class PagedResourceCollection extends ResourceCollection { private readonly selfLink; private readonly nextLink; private readonly prevLink; private readonly firstLink; private readonly lastLink; readonly totalElements: number; readonly totalPages: number; readonly pageNumber: number; readonly pageSize: number; /** * Create a new paged resource collection from resource collection with the page data. * * @param resourceCollection collection that will be paged * @param pageData contains data about characteristics of the page. */ constructor(resourceCollection: ResourceCollection, pageData?: PageData); hasFirst(): boolean; hasLast(): boolean; hasNext(): boolean; hasPrev(): boolean; first(options?: { useCache: true; }): Observable>; last(options?: { useCache: true; }): Observable>; next(options?: { useCache: true; }): Observable>; prev(options?: { useCache: true; }): Observable>; page(pageNumber: number, options?: { useCache: true; }): Observable>; size(size: number, options?: { useCache: true; }): Observable>; sortElements(sortParam: Sort, options?: { useCache: true; }): Observable>; /** * Perform query with custom page data. * That allows you change page size, current page or sort options. * * @param params contains data about new characteristics of the page. * @param options (optional) additional options that will be applied to the request * @throws error when required params are not valid or when passed inconsistent data */ customPage(params: SortedPageParam, options?: { useCache: true; }): Observable>; } /** * Common resource class. */ declare abstract class BaseResource extends AbstractResource { /** * Get single resource by the relation name. * * @param relationName used to get the specific relation link * @param options (optional) options that should be applied to the request * @throws error when required params are not valid or link not found by relation name */ getRelation(relationName: string, options?: GetOption): Observable; /** * Get collection of resources by the relation name. * * @param relationName used to get the specific relation link * @param options (optional) options that will be applied to the request * @throws error when required params are not valid or link not found by relation name */ getRelatedCollection>(relationName: string, options?: GetOption): Observable; /** * Get paged collection of resources by the relation name. * * @param relationName used to get the specific relation link * @param options (optional) additional options that should be applied to the request * if options didn't contains {@link PageParam} then will be used default page params. * @throws error when required params are not valid or link not found by relation name */ getRelatedPage>(relationName: string, options?: PagedGetOption): Observable; /** * Perform POST request to the relation with the body and url params. * * @param relationName used to get the specific relation link * @param requestBody that contains the body directly and optional body values option {@link ValuesOption} * @param options (optional) request options that will be applied to the request * @throws error when required params are not valid or link not found by relation name */ postRelation(relationName: string, requestBody: RequestBody, options?: RequestOption): Observable | any>; /** * Perform PATCH request to relation with body and url params. * * @param relationName used to get the specific relation link * @param requestBody contains the body directly and body values option {@link ValuesOption} * to clarify what specific values need to be included or not included in result request body * @param options (optional) request options that will be applied to the request * @throws error when required params are not valid or link not found by relation name */ patchRelation(relationName: string, requestBody: RequestBody, options?: RequestOption): Observable | any>; /** * Perform PUT request to relation with body and url params. * * @param relationName used to get the specific relation link * @param requestBody contains the body directly and body values option {@link ValuesOption} * to clarify what specific values need to be included or not included in result request body * @param options (optional) request options that will be applied to the request * @throws error when required params are not valid or link not found by relation name */ putRelation(relationName: string, requestBody: RequestBody, options?: RequestOption): Observable | any>; } /** * Resource class. * Should be extended by client model classes that represent entity objects. * * If you have an embedded entity then consider to use the {@link EmbeddedResource} class. */ declare class Resource extends BaseResource { /** * Resource should has self link. */ protected _links: { self: LinkData; [key: string]: LinkData; }; /** * Adding passed entities to the resource collection behind the relation name. * Used POST method with 'Content-Type': 'text/uri-list'. * * This method DOES NOT REPLACE existing resources in the collection instead it adds new ones. * To replace collection resource with passed entities use {@link bindRelation} method. * * @param relationName used to get the specific resource relation link to the resource collection * @param entities one or more entities that should be added to the resource collection * @throws error when required params are not valid or link not found by relation name */ addCollectionRelation(relationName: string, entities: Array): Observable>; /** * Bounding the passed entity or collection of entities to this resource by the relation name. * Used PUT method with 'Content-Type': 'text/uri-list'. * * This method also REPLACED existing resources in the collection by passed entities. * To add entities to collection resource use {@link addCollectionRelation} method. * * @param relationName with which will be associated passed entity to this resource * @param entities one or more entities that should be bind to this resource * @throws error when required params are not valid or link not found by relation name */ bindRelation(relationName: string, entities: T | Array): Observable>; /** * Unbinding single resource relation behind resource name. * Used DELETE method to relation resource link URL. * * This method DOES NOT WORK WITH COLLECTION RESOURCE relations. * To clear collection resource relation use {@link unbindCollectionRelation} method. * To delete one resource from resource collection use {@link deleteRelation} method. * * @param relationName resource relation name to unbind */ unbindRelation(relationName: string): Observable>; /** * Unbind all resources from collection by the relation name. * Used PUT method with 'Content-Type': 'text/uri-list' and EMPTY body to clear relations. * * To delete one resource from collection use {@link deleteRelation} method. * To delete single resource relations use {@link unbindRelation} or {@link deleteRelation} methods. * * @param relationName used to get relation link to unbind * @throws error when required params are not valid or link not found by relation name */ unbindCollectionRelation(relationName: string): Observable>; /** * Deleting resource relation. * For collection, means that only passed entity will be unbound from the collection. * For single resource, deleting relation the same as @{link unbindRelation} method. * * To delete all resource relations from collection use {@link unbindCollectionRelation} method. * * @param relationName used to get relation link to unbind * @param entity that should be unbind from this relation * @throws error when required params are not valid or link not found by relation name */ deleteRelation(relationName: string, entity: T): Observable>; getSelfLinkHref(): string; } /** * Describe all client configuration params. */ /** * Used to specify additional {@link Resource} options. */ interface ResourceOption { /** * Name of the route that configured in {@link HateoasConfiguration#http} as {@link MultipleResourceRoutes}. * Be default used route with name 'defaultRoute'. * * See more about this option in documentation. */ routeName?: string; } /** * Resource route config that defined where from retrieve resources. * If you use this config, then a default route created with name 'defaultRoute' will be assigned to all resources. */ interface ResourceRoute { /** * Root server url. * * For default Spring application it looks like: http://localhost:8080. */ rootUrl: string; /** * Proxy url on which to send requests. * If passed then it uses to change rootUrl to proxyUrl when get relation link. * * For default Spring application it looks like: http://localhost:8080/api/v1. */ proxyUrl?: string; } /** * Defines several resource routes. */ interface MultipleResourceRoutes { /** * Each resource route is declared as {@link ResourceRoute} object with root and proxy url if need it. * Specified route name is used in {@link ResourceOption#routeName} to retrieve resource by this route. * * If you want to declare only one route, you need to use default route name as 'defaultRoute' or use simple {@link ResourceRoute} config. */ [routeName: string]: ResourceRoute; } interface HateoasConfiguration { /** * Http options. * {@link ResourceRoute} declare common resource route that created with default name 'defaultRoute'. * {@link MultipleResourceRoutes} declare several resource routes, * to define default route in this case, use default route name 'defaultRoute'. */ http: ResourceRoute | MultipleResourceRoutes; /** * Logging option. */ logs?: { /** * Should print verbose logs to the console. */ verboseLogs?: boolean; }; /** * Cache options. */ cache?: { /** * When {@code true} then cache will be used, {@code false} otherwise. */ enabled: boolean; /** * Allows to adjust cache more granular using {@link CacheMode} modes. */ mode?: CacheMode; /** * Time in milliseconds after which cache need to be expired. */ lifeTime?: number; }; /** * Declared resource/embedded resource types that will be used to create resources from server response that contains resources. */ useTypes?: { resources: Array Resource>; embeddedResources?: Array EmbeddedResource>; }; /** * {@code true} when running in production environment, {@code false} otherwise. */ isProduction?: boolean; /** * Specifying format for some type values. */ typesFormat?: { /** * This date format will be used when parse {@link Resource} properties. * If the property will be match to some one of specified formats, then the property type will be as Date object. * Otherwise, raw type will be used as default. */ date?: { /** * Date pattern. * The {@link https://date-fns.org} lib is used to parse date with patterns, use patterns supported by this lib. * See more about supported formats here. */ patterns: Array; }; }; /** * Let to change default page params that is size = 20, page = 0. */ pagination?: { defaultPage: { size: number; page?: number; }; }; /** * Additional configuration to specify settings for HAL format. */ halFormat?: { json?: { /** * {@code true} when empty object {} should be converted to {@code null} value * {@code false} when empty object {} should be used as is */ convertEmptyObjectToNull: boolean; }; collections?: { /** * If {@code true}, then for empty collections, not required to specify _embedded property. * When {@code false} (be default), you need to specify empty _embedded property for empty collections. * * By default, Spring Data REST includes empty _embedded property for empty collections, * but when using Spring HATEOAS you need to do it manually. * * Recommending use Spring Data REST approach and return empty _embedded property for empty collection * for more predictable determine resource type algorithm. */ embeddedOptional: boolean; }; }; } /** * This service for configuration library. * * You should inject this service in your main AppModule and pass * configuration using {@link #configure()} method. */ declare class NgxHateoasClientConfigurationService { private injector; constructor(injector: Injector); private static isCommonRouteConfig; /** * Configure library with client params. * * @param config suitable client properties needed to properly library work */ configure(config: HateoasConfiguration): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** * Main resource operation class. * Extend this class to create resource service. */ declare class HateoasResourceOperation { private readonly resourceType; private hateoasResourceService; constructor(resourceType: new () => T); /** * {@link HateoasResourceService#getResource}. */ getResource(id: number | string, options?: GetOption): Observable; /** * {@link HateoasResourceService#getCollection}. */ getCollection(options?: GetOption): Observable>; /** * {@link HateoasResourceService#getPage}. */ getPage(options?: PagedGetOption): Observable>; /** * {@link HateoasResourceService#createResource}. */ createResource(requestBody: RequestBody, options?: RequestOption): Observable; /** * {@link HateoasResourceService#updateResource}. */ updateResource(entity: T, requestBody?: RequestBody, options?: RequestOption): Observable; /** * {@link HateoasResourceService#updateResourceById}. */ updateResourceById(id: number | string, requestBody: RequestBody, options?: RequestOption): Observable; /** * {@link HateoasResourceService#patchResource}. */ patchResource(entity: T, requestBody?: RequestBody, options?: RequestOption): Observable; /** * {@link HateoasResourceService#patchResourceById}. */ patchResourceById(id: number | string, requestBody: RequestBody, options?: RequestOption): Observable; /** * {@link HateoasResourceService#deleteResource}. */ deleteResource(entity: T, options?: RequestOption): Observable | any>; /** * {@link HateoasResourceService#deleteResourceById}. */ deleteResourceById(id: number | string, options?: RequestOption): Observable | any>; /** * {@see ResourceCollectionHttpService#search} */ searchCollection(query: string, options?: GetOption): Observable>; /** * {@see PagedResourceCollection#search} */ searchPage(query: string, options?: PagedGetOption): Observable>; /** * {@see ResourceHttpService#search} */ searchResource(query: string, options?: GetOption): Observable; /** * {@see ResourceHttpService#customQuery} */ customQuery(method: HttpMethod, query: string, requestBody?: RequestBody, options?: PagedGetOption): Observable; /** * {@see ResourceHttpService#customSearchQuery} */ customSearchQuery(method: HttpMethod, searchQuery: string, requestBody?: RequestBody, options?: PagedGetOption): Observable; } /** * Contains all needed information about a resource. * It generates a string cache key to hold in a cache map from information about a resource. */ declare class CacheKey { readonly url: string; private readonly options; /** * String cache key value. */ value: string; private constructor(); /** * Create cache key from resource url and request params. * * @param url resource url * @param params request params */ static of(url: string, params: { observe?: 'body' | 'response'; params?: HttpParams; }): CacheKey; } declare class ResourceCacheService { private cacheMap; /** * Get cached resource value. * * @param key cache key * @return cached value or {@code null} when cached value is not exist or expired */ getResource(key: CacheKey): ResourceIdentifiable; /** * Add resource value to the cache. * Before add new value, previous will be deleted if it was exist. * * @param key cache key * @param value cache value */ putResource(key: CacheKey, value: ResourceIdentifiable): void; /** * Delete cached resource value by passed key. * * @param key cache key */ evictResource(key: CacheKey): void; evictAll(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** * Base class with common logics to perform HTTP requests. */ declare class HttpExecutor { protected httpClient: HttpClient; protected cacheService: ResourceCacheService; constructor(httpClient: HttpClient, cacheService: ResourceCacheService); private static logRequest; private static logResponse; /** * Perform GET request. * * @param url to perform request * @param options (optional) options that applied to the request * @param useCache value {@code true} if need to use cache, {@code false} otherwise * @throws error when required params are not valid */ getHttp(url: string, options?: HttpClientOptions, useCache?: boolean): Observable; /** * Perform POST request. * * @param url to perform request * @param body to send with request * @param options (optional) options that applied to the request * @throws error when required params are not valid */ postHttp(url: string, body: any | null, options?: HttpClientOptions): Observable; /** * Perform PUT request. * * @param url to perform request * @param body to send with request * @param options (optional) options that applied to the request * @throws error when required params are not valid */ putHttp(url: string, body: any | null, options?: HttpClientOptions): Observable; /** * Perform PATCH request. * * @param url to perform request * @param body to send with request * @param options (optional) options that applied to the request * @throws error when required params are not valid */ patchHttp(url: string, body: any | null, options?: HttpClientOptions): Observable; /** * Perform DELETE request. * * @param url to perform request * @param options (optional) options that applied to the request * @throws error when required params are not valid */ deleteHttp(url: string, options?: HttpClientOptions): Observable; } /** * Service to perform HTTP requests to get {@link Resource} type. */ declare class ResourceHttpService extends HttpExecutor { constructor(httpClient: HttpClient, cacheService: ResourceCacheService); /** * Perform GET request to retrieve resource. * * @param url to perform request * @param options request options * @throws error when required params are not valid or returned resource type is not resource */ get(url: string, options?: GetOption): Observable; /** * Perform POST request. * * @param url to perform request * @param body request body * @param options request options * @throws error when required params are not valid */ post(url: string, body: any | null, options?: RequestOption): Observable; /** * Perform PUT request. * * @param url to perform request * @param body request body * @param options request options * @throws error when required params are not valid */ put(url: string, body: any | null, options?: RequestOption): Observable; /** * Perform PATCH request. * * @param url to perform request * @param body request body * @param options request options * @throws error when required params are not valid */ patch(url: string, body: any | null, options?: RequestOption): Observable; /** * Perform DELETE request. * * @param url to perform request * @param options request options * @throws error when required params are not valid */ delete(url: string, options?: RequestOption): Observable; /** * Perform get resource request with url built by the resource name. * * @param resourceName used to build root url to the resource * @param resourceOptions additional resource options {@link ResourceOption} * @param id resource id * @param options (optional) options that applied to the request * @throws error when required params are not valid */ getResource(resourceName: string, resourceOptions: ResourceOption, id: number | string, options?: GetOption): Observable; /** * Perform POST resource request with url built by the resource name. * * @param resourceName to be post * @param resourceOptions additional resource options {@link ResourceOption} * @param body resource to create * @param options (optional) options that applied to the request * @throws error when required params are not valid */ postResource(resourceName: string, resourceOptions: ResourceOption, body: BaseResource, options?: RequestOption): Observable; /** * Perform PATCH resource request with url built by the resource name and resource id. * * @param resourceName to be patched * @param resourceOptions additional resource options {@link ResourceOption} * @param id resource id * @param body contains data to patch resource properties * @param options (optional) options that applied to the request * @throws error when required params are not valid */ patchResource(resourceName: string, resourceOptions: ResourceOption, id: number | string, body: any, options?: RequestOption): Observable; /** * Perform PUT resource request with url built by the resource name and resource id. * * @param resourceName to be put * @param resourceOptions additional resource options {@link ResourceOption} * @param id resource id * @param body contains data to replace resource properties * @param options (optional) options that applied to the request * @throws error when required params are not valid */ putResource(resourceName: string, resourceOptions: ResourceOption, id: number | string, body: any, options?: RequestOption): Observable; /** * Perform DELETE resource request with url built by the resource name and resource id. * * @param resourceName to be deleted * @param resourceOptions additional resource options {@link ResourceOption} * @param id resource id * @param options (optional) additional options that will be applied to the request * @throws error when required params are not valid */ deleteResource(resourceName: string, resourceOptions: ResourceOption, id: number | string, options?: RequestOption): Observable; /** * Perform search single resource request with url built by the resource name. * * @param resourceName used to build root url to the resource * @param resourceOptions additional resource options {@link ResourceOption} * @param searchQuery name of the search method * @param options (optional) options that applied to the request * @throws error when required params are not valid */ search(resourceName: string, resourceOptions: ResourceOption, searchQuery: string, options?: GetOption): Observable; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** * Service to perform HTTP requests to get {@link PagedResourceCollection} type. */ declare class PagedResourceCollectionHttpService extends HttpExecutor { constructor(httpClient: HttpClient, cacheService: ResourceCacheService); /** * Perform GET request to retrieve paged collection of the resources. * * @param url to perform request * @param options request options * @throws error when required params are not valid or returned resource type is not paged collection of the resources */ get>(url: string, options?: PagedGetOption): Observable; /** * Perform get paged resource collection request with url built by the resource name. * * @param resourceName used to build root url to the resource * @param resourceOptions additional resource options {@link ResourceOption} * @param options (optional) options that applied to the request * @throws error when required params are not valid */ getResourcePage>(resourceName: string, resourceOptions: ResourceOption, options?: PagedGetOption): Observable; /** * Perform search paged resource collection request with url built by the resource name. * * @param resourceName used to build root url to the resource * @param resourceOptions additional resource options {@link ResourceOption} * @param searchQuery name of the search method * @param options (optional) options that applied to the request * @throws error when required params are not valid */ search>(resourceName: string, resourceOptions: ResourceOption, searchQuery: string, options?: PagedGetOption): Observable; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** * Service to perform HTTP requests to get {@link ResourceCollection} type. */ declare class ResourceCollectionHttpService extends HttpExecutor { constructor(httpClient: HttpClient, cacheService: ResourceCacheService); /** * Perform GET request to retrieve collection of the resources. * * @param url to perform request * @param options request options * @throws error when required params are not valid or returned resource type is not collection of the resources */ get>(url: string, options?: GetOption): Observable; /** * Perform get resource collection request with url built by the resource name. * * @param resourceName used to build root url to the resource * @param resourceOptions additional resource options {@link ResourceOption} * @param options (optional) options that applied to the request * @throws error when required params are not valid */ getResourceCollection>(resourceName: string, resourceOptions: ResourceOption, options?: GetOption): Observable; /** * Perform search resource collection request with url built by the resource name. * * @param resourceName used to build root url to the resource * @param resourceOptions additional resource options {@link ResourceOption} * @param searchQuery name of the search method * @param options (optional) options that applied to the request * @throws error when required params are not valid */ search>(resourceName: string, resourceOptions: ResourceOption, searchQuery: string, options?: GetOption): Observable; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** * Service to perform HTTP requests to get any type of the {@link Resource}, {@link PagedResourceCollection}, {@link ResourceCollection}. */ declare class CommonResourceHttpService extends HttpExecutor { constructor(httpClient: HttpClient, cacheService: ResourceCacheService); /** * Perform custom HTTP request. * * Return type depends on result data it can be {@link Resource}, {@link ResourceCollection}, * {@link PagedResourceCollection} or any data. * * @param resourceName used to build root url to the resource * @param resourceOptions additional resource options {@link ResourceOption} * @param method HTTP method that will be perform {@link HttpMethod} * @param query url path that applied to the result url at the end * @param body (optional) request body * @param options (optional) options that applied to the request * @throws error when required params are not valid */ customQuery(resourceName: string, resourceOptions: ResourceOption, method: HttpMethod, query: string, body?: any, options?: PagedGetOption): Observable; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** * Service to operate with {@link Resource}. * * Can be injected as standalone service to work with {@link Resource}. */ declare class HateoasResourceService { private commonHttpService; private resourceHttpService; private resourceCollectionHttpService; private pagedResourceCollectionHttpService; private cacheService; constructor(commonHttpService: CommonResourceHttpService, resourceHttpService: ResourceHttpService, resourceCollectionHttpService: ResourceCollectionHttpService, pagedResourceCollectionHttpService: PagedResourceCollectionHttpService, cacheService: ResourceCacheService); /** * Get resource by id. * * @param resourceType resource for which will perform request * @param id resource id * @param options (optional) options that should be applied to the request * @throws error when required params are not valid */ getResource(resourceType: new () => T, id: number | string, options?: GetOption): Observable; /** * Get collection of the resource by id. * * @param resourceType resource for which will perform request * @param options (optional) options that should be applied to the request * @throws error when required params are not valid */ getCollection(resourceType: new () => T, options?: GetOption): Observable>; /** * Get paged collection of the resource by id. * * @param resourceType resource for which will perform request * @param options (optional) options that should be applied to the request * @throws error when required params are not valid */ getPage(resourceType: new () => T, options?: PagedGetOption): Observable>; /** * Create resource. * * @param resourceType resource for which will perform request * @param requestBody that contains the body directly and optional body values option {@link ValuesOption} * @param options (optional) options that should be applied to the request {@link RequestOption} * @throws error when required params are not valid */ createResource(resourceType: new () => T, requestBody: RequestBody, options?: RequestOption): Observable; /** * Updating all resource properties at the time to passed body properties. If some properties are not passed then will be used null value. * If you need update some part resource properties, use {@link HateoasResourceService#patchResource} method. * * @param entity to update * @param requestBody that contains the body directly and optional body values option {@link ValuesOption} * @param options (optional) options that should be applied to the request {@link RequestOption} * @throws error when required params are not valid */ updateResource(entity: T, requestBody?: RequestBody, options?: RequestOption): Observable; /** * Update resource by id. * Updating all resource properties at the time to passed body properties. If some properties are not passed then will be used null value. * If you need update some part resource properties, use {@link HateoasResourceService#patchResource} method. * * @param resourceType resource for which will perform request * @param id resource id * @param requestBody that contains the body directly and optional body values option {@link ValuesOption} * @param options (optional) options that should be applied to the request {@link RequestOption} * @throws error when required params are not valid */ updateResourceById(resourceType: new () => T, id: number | string, requestBody: RequestBody, options?: RequestOption): Observable; /** * Patch resource. * Allows fine-grained update resource properties, it means that only passed properties in body will be changed, * other properties stay as is. * * @param entity to patch * @param requestBody (optional) contains the body that will be patched resource and optional body values option {@link ValuesOption} * if not passed then entity will be passed as body directly * @param options (optional) options that should be applied to the request {@link RequestOption} * @throws error when required params are not valid */ patchResource(entity: T, requestBody?: RequestBody, options?: RequestOption): Observable; /** * Patch resource by id. * Allows fine-grained update resource properties, it means that only passed properties in body will be changed, * other properties stay as is. * * @param resourceType resource for which will perform request * @param id resource id * @param requestBody that contains the body directly and optional body values option {@link ValuesOption} * @param options (optional) options that should be applied to the request {@link RequestOption} * @throws error when required params are not valid */ patchResourceById(resourceType: new () => T, id: number | string, requestBody: RequestBody, options?: RequestOption): Observable; /** * Delete resource. * * @param entity to delete * @param options (optional) options that should be applied to the request * @throws error when required params are not valid */ deleteResource(entity: T, options?: RequestOption): Observable | any>; /** * Delete resource by id. * * @param resourceType resource for which will perform request * @param id resource id * @param options (optional) options that should be applied to the request * @throws error when required params are not valid */ deleteResourceById(resourceType: new () => T, id: number | string, options?: RequestOption): Observable | any>; /** * {@see ResourceCollectionHttpService#search} */ searchCollection(resourceType: new () => T, searchQuery: string, options?: GetOption): Observable>; /** * {@see PagedResourceCollection#search} */ searchPage(resourceType: new () => T, searchQuery: string, options?: PagedGetOption): Observable>; /** * {@see ResourceHttpService#search} */ searchResource(resourceType: new () => T, searchQuery: string, options?: GetOption): Observable; /** * {@see CommonResourceHttpService#customQuery} */ customQuery(resourceType: new () => Resource, method: HttpMethod, query: string, requestBody?: RequestBody, options?: PagedGetOption): Observable; /** * Differences between {@link HateoasResourceService#customQuery} and this method * that this one puts 'search' path to the result url automatically. * * {@see CommonResourceHttpService#customQuery} */ customSearchQuery(resourceType: new () => Resource, method: HttpMethod, searchQuery: string, requestBody?: RequestBody, options?: PagedGetOption): Observable; /** * Evict all resources cache. */ evictResourcesCache(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** * Decorator used to classes that extend {@link Resource} class to register 'resourceName' and 'resourceType' * information about this resource. * * @param resourceName resource name which will be used to build a resource URL. * @param options additional resource options. See more {@link ResourceOption}. */ declare function HateoasResource(resourceName: string, options?: ResourceOption): any>(constructor: T) => T; /** * Decorator used to classes that extend {@link EmbeddedResource} class to register 'relationNames' and 'resourceType' * information about this resource. * * @param relationNames names of the properties that using to hold this embedded resource in resource objects. */ declare function HateoasEmbeddedResource(relationNames: Array): any>(constructor: T) => void; /** * Decorator used to create a projection representation of {@link Resource} heirs. * * @param resourceType type of resource that using for projection. * @param projectionName name of projection, will be used as projection request param. */ declare function HateoasProjection(resourceType: new () => Resource, projectionName: string): any>(constructor: T) => T; /** * Decorator used to mark projection class properties that are resources and specifying class type used to create this relation. * This decorator used with class marked as {@link HateoasProjection}. * * @param relationType resource relation type that will be used to create resource with this type when parsed server response. */ declare function ProjectionRel(relationType: new () => BaseResource): (target: object, propertyKey: string) => void; declare class NgxHateoasClientModule { static forRoot(): ModuleWithProviders; constructor(config: NgxHateoasClientConfigurationService); static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } export { CacheMode, EmbeddedResource, HateoasEmbeddedResource, HateoasProjection, HateoasResource, HateoasResourceOperation, HateoasResourceService, HttpMethod, Include, NgxHateoasClientConfigurationService, NgxHateoasClientModule, PagedResourceCollection, ProjectionRel, Resource, ResourceCollection }; export type { GetOption, PagedGetOption, ProjectionRelType, RequestOption, RequestParam, Sort, SortOrder };