import { HttpClient, HttpHeaders, HttpContext, HttpParams, HttpRequest, HttpHandler, HttpEvent } from '@angular/common/http'; import { Subject, Observable } from 'rxjs'; import * as i0 from '@angular/core'; interface CacheOptions { /** * collect - collecting response body as table, maxSize parameter controls max size of table * reload - force to reload cache (send request) */ type?: 'collect' | 'reload'; /** * Work with type='collect' */ maxSize?: number; data?: any; name?: string; external?: Ext; withCacheItem?: boolean; /** list of keys to clear */ clear?: string[]; /** list of keys to retrigger */ retrigger?: string[]; convert?: (data: Res) => any; reloadOn?: (data: CacheItem) => boolean; } declare class CacheModel { options?: CacheOptions | undefined; constructor(options?: CacheOptions | undefined); } interface CacheItem { body: Res; reqBody?: any; triggeredAt: Date; method: 'get' | 'post' | 'put' | 'patch' | 'delete' | string; responseAt?: Date; cache?: CacheOptions; fullPath: string; external?: Ext; reloading?: true; } declare class CacheService { protected cache: Map>; /** * triggered when cache name value is changed or removed, not triggered when all cache was cleared */ changed: Subject<{ name: string; item?: CacheItem; }>; /** * triggered when one name of cache was cleared (emit string as name of removed one) or all was cleared (emit undefined) */ cleared: Subject; set(name: string, item: CacheItem): void; get(name: string): CacheItem | undefined; has(name: string): boolean; /** * when no name clear all, single one when name is known */ clear(name?: string): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } interface HttpClientOptions { body?: any; headers?: HttpHeaders | { [header: string]: string | string[]; }; context?: HttpContext; observe?: 'body'; params?: HttpParams | { [param: string]: string | number | boolean | ReadonlyArray; }; responseType?: 'json'; reportProgress?: boolean; withCredentials?: boolean; cache?: CacheOptions; } declare class HttpCacheService { http: HttpClient; constructor(http: HttpClient); request(method: string, url: string, options?: { body?: any; headers?: HttpHeaders | { [header: string]: string | string[]; }; context?: HttpContext; observe?: 'body'; params?: HttpParams | { [param: string]: string | number | boolean | ReadonlyArray; }; responseType?: 'json'; reportProgress?: boolean; withCredentials?: boolean; cache?: CacheOptions; }): Observable; get(url: string, options?: HttpClientOptions): Observable; patch(url: string, body: any, options?: HttpClientOptions): Observable; post(url: string, body: any, options?: HttpClientOptions): Observable; put(url: string, body: any, options?: HttpClientOptions): Observable; delete(url: string, options?: HttpClientOptions): Observable; retrigger(cacheItem: CacheItem | undefined): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } declare class CacheInterceptorService { private readonly cache; private readonly http; constructor(cache: CacheService, http: HttpCacheService); intercept(request: HttpRequest, next: HttpHandler): Observable>; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } export { CacheInterceptorService, CacheModel, CacheService, HttpCacheService }; export type { CacheItem, CacheOptions, HttpClientOptions };