ng-http-caching 19.0.1 → 20.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/ng-http-caching.mjs +37 -34
- package/fesm2022/ng-http-caching.mjs.map +1 -1
- package/index.d.ts +320 -5
- package/package.json +1 -1
- package/lib/ng-http-caching-interceptor.service.d.ts +0 -13
- package/lib/ng-http-caching-provider.d.ts +0 -3
- package/lib/ng-http-caching.module.d.ts +0 -9
- package/lib/ng-http-caching.service.d.ts +0 -227
- package/lib/storage/ng-http-caching-browser-storage.d.ts +0 -27
- package/lib/storage/ng-http-caching-local-storage.d.ts +0 -5
- package/lib/storage/ng-http-caching-memory-storage.d.ts +0 -4
- package/lib/storage/ng-http-caching-session-storage.d.ts +0 -5
- package/lib/storage/ng-http-caching-storage.interface.d.ts +0 -31
- package/public-api.d.ts +0 -9
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { HttpContextToken, HttpContext,
|
|
1
|
+
import { HttpContextToken, HttpContext, HttpEventType, HTTP_INTERCEPTORS, HttpHeaders, HttpParams, HttpRequest, HttpResponse } from '@angular/common/http';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
3
|
import { InjectionToken, VERSION, isDevMode, inject, Injectable, NgModule, makeEnvironmentProviders } from '@angular/core';
|
|
4
4
|
import { scheduled, of, asyncScheduler } from 'rxjs';
|
|
5
|
-
import { tap,
|
|
5
|
+
import { tap, shareReplay } from 'rxjs/operators';
|
|
6
6
|
|
|
7
7
|
class NgHttpCachingMemoryStorage extends Map {
|
|
8
8
|
}
|
|
@@ -338,7 +338,7 @@ class NgHttpCachingService {
|
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
340
|
// request is allowed if method is in allowedMethod
|
|
341
|
-
return this.config.allowedMethod.
|
|
341
|
+
return this.config.allowedMethod.includes(req.method);
|
|
342
342
|
}
|
|
343
343
|
/**
|
|
344
344
|
* Return the cache key.
|
|
@@ -416,10 +416,10 @@ class NgHttpCachingService {
|
|
|
416
416
|
Object.keys(object).forEach(key => this.deepFreeze(object[key]));
|
|
417
417
|
return object;
|
|
418
418
|
}
|
|
419
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
420
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
419
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.2", ngImport: i0, type: NgHttpCachingService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
420
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.2", ngImport: i0, type: NgHttpCachingService }); }
|
|
421
421
|
}
|
|
422
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
422
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.2", ngImport: i0, type: NgHttpCachingService, decorators: [{
|
|
423
423
|
type: Injectable
|
|
424
424
|
}], ctorParameters: () => [] });
|
|
425
425
|
|
|
@@ -450,12 +450,11 @@ class NgHttpCachingInterceptorService {
|
|
|
450
450
|
// then let the request proceed and cache the response
|
|
451
451
|
// console.log('sendRequest', req);
|
|
452
452
|
const shared = this.sendRequest(req, next).pipe(tap(event => {
|
|
453
|
-
if (event
|
|
454
|
-
this.cacheService.addToCache(req, event
|
|
453
|
+
if (event.type === HttpEventType.Response) {
|
|
454
|
+
this.cacheService.addToCache(req, event);
|
|
455
|
+
// delete pending request
|
|
456
|
+
this.cacheService.deleteFromQueue(req);
|
|
455
457
|
}
|
|
456
|
-
}), finalize(() => {
|
|
457
|
-
// delete pending request
|
|
458
|
-
this.cacheService.deleteFromQueue(req);
|
|
459
458
|
}), shareReplay());
|
|
460
459
|
// add pending request to queue for cache parallel request
|
|
461
460
|
this.cacheService.addToQueue(req, shared);
|
|
@@ -465,19 +464,24 @@ class NgHttpCachingInterceptorService {
|
|
|
465
464
|
* Send http request (next handler)
|
|
466
465
|
*/
|
|
467
466
|
sendRequest(req, next) {
|
|
468
|
-
let cloned = req.clone();
|
|
469
467
|
// trim custom headers before send request
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
468
|
+
let headers = req.headers;
|
|
469
|
+
let needClone = false;
|
|
470
|
+
for (const header of NgHttpCachingHeadersList) {
|
|
471
|
+
if (headers.has(header)) {
|
|
472
|
+
needClone = true;
|
|
473
|
+
headers = headers.delete(header);
|
|
473
474
|
}
|
|
474
|
-
}
|
|
475
|
-
|
|
475
|
+
}
|
|
476
|
+
if (needClone) {
|
|
477
|
+
req = req.clone({ headers });
|
|
478
|
+
}
|
|
479
|
+
return next.handle(req);
|
|
476
480
|
}
|
|
477
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
478
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
481
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.2", ngImport: i0, type: NgHttpCachingInterceptorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
482
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.2", ngImport: i0, type: NgHttpCachingInterceptorService }); }
|
|
479
483
|
}
|
|
480
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
484
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.2", ngImport: i0, type: NgHttpCachingInterceptorService, decorators: [{
|
|
481
485
|
type: Injectable
|
|
482
486
|
}] });
|
|
483
487
|
|
|
@@ -493,9 +497,9 @@ class NgHttpCachingModule {
|
|
|
493
497
|
],
|
|
494
498
|
};
|
|
495
499
|
}
|
|
496
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
497
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
498
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
500
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.2", ngImport: i0, type: NgHttpCachingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
501
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.0.2", ngImport: i0, type: NgHttpCachingModule }); }
|
|
502
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.0.2", ngImport: i0, type: NgHttpCachingModule, providers: [
|
|
499
503
|
NgHttpCachingService,
|
|
500
504
|
NgHttpCachingInterceptorService,
|
|
501
505
|
{
|
|
@@ -505,7 +509,7 @@ class NgHttpCachingModule {
|
|
|
505
509
|
},
|
|
506
510
|
] }); }
|
|
507
511
|
}
|
|
508
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
512
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.2", ngImport: i0, type: NgHttpCachingModule, decorators: [{
|
|
509
513
|
type: NgModule,
|
|
510
514
|
args: [{
|
|
511
515
|
providers: [
|
|
@@ -521,14 +525,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImpor
|
|
|
521
525
|
}] });
|
|
522
526
|
|
|
523
527
|
function provideNgHttpCaching(ngHttpCachingConfig) {
|
|
524
|
-
const providers = [
|
|
525
|
-
if (ngHttpCachingConfig) {
|
|
526
|
-
providers.push(makeEnvironmentProviders([{
|
|
527
|
-
provide: NG_HTTP_CACHING_CONFIG,
|
|
528
|
-
useValue: ngHttpCachingConfig,
|
|
529
|
-
}]));
|
|
530
|
-
}
|
|
531
|
-
providers.push(makeEnvironmentProviders([
|
|
528
|
+
const providers = [
|
|
532
529
|
NgHttpCachingService,
|
|
533
530
|
{
|
|
534
531
|
provide: HTTP_INTERCEPTORS,
|
|
@@ -536,8 +533,14 @@ function provideNgHttpCaching(ngHttpCachingConfig) {
|
|
|
536
533
|
multi: true,
|
|
537
534
|
},
|
|
538
535
|
NgHttpCachingInterceptorService
|
|
539
|
-
]
|
|
540
|
-
|
|
536
|
+
];
|
|
537
|
+
if (ngHttpCachingConfig) {
|
|
538
|
+
providers.push({
|
|
539
|
+
provide: NG_HTTP_CACHING_CONFIG,
|
|
540
|
+
useValue: ngHttpCachingConfig,
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
return makeEnvironmentProviders(providers);
|
|
541
544
|
}
|
|
542
545
|
|
|
543
546
|
const KEY_PREFIX = 'NgHttpCaching::';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-http-caching.mjs","sources":["../../../projects/ng-http-caching/src/lib/storage/ng-http-caching-memory-storage.ts","../../../projects/ng-http-caching/src/lib/ng-http-caching.service.ts","../../../projects/ng-http-caching/src/lib/ng-http-caching-interceptor.service.ts","../../../projects/ng-http-caching/src/lib/ng-http-caching.module.ts","../../../projects/ng-http-caching/src/lib/ng-http-caching-provider.ts","../../../projects/ng-http-caching/src/lib/storage/ng-http-caching-browser-storage.ts","../../../projects/ng-http-caching/src/lib/storage/ng-http-caching-local-storage.ts","../../../projects/ng-http-caching/src/lib/storage/ng-http-caching-session-storage.ts","../../../projects/ng-http-caching/src/public-api.ts","../../../projects/ng-http-caching/src/ng-http-caching.ts"],"sourcesContent":["import { NgHttpCachingStorageInterface } from './ng-http-caching-storage.interface';\r\nimport { NgHttpCachingEntry } from '../ng-http-caching.service';\r\n\r\nexport class NgHttpCachingMemoryStorage extends Map<string, NgHttpCachingEntry<any, any>> implements NgHttpCachingStorageInterface { }\r\n","import { Injectable, InjectionToken, VERSION, isDevMode, inject } from '@angular/core';\r\nimport { HttpRequest, HttpResponse, HttpEvent, HttpContextToken, HttpContext, HttpHeaders } from '@angular/common/http';\r\nimport { Observable } from 'rxjs/internal/Observable';\r\nimport { NgHttpCachingStorageInterface } from './storage/ng-http-caching-storage.interface';\r\nimport { NgHttpCachingMemoryStorage } from './storage/ng-http-caching-memory-storage';\r\n\r\nexport type NgHttpCachingContext = Pick<NgHttpCachingConfig, 'getKey' | 'isCacheable' | 'isExpired' | 'isValid'>;\r\n\r\nexport const NG_HTTP_CACHING_CONTEXT = new HttpContextToken<NgHttpCachingContext>(() => ({}));\r\n\r\nexport const withNgHttpCachingContext = (value: NgHttpCachingContext, context: HttpContext = new HttpContext()) => context.set(NG_HTTP_CACHING_CONTEXT, value)\r\n\r\nexport const checkCacheHeaders = (headers: HttpHeaders): boolean => {\r\n // check Cache-Control\r\n const cacheControlHeader = headers.get('cache-control');\r\n if (cacheControlHeader) {\r\n const cacheControl = cacheControlHeader.toLowerCase();\r\n if (cacheControl.includes('no-store')) {\r\n return false;\r\n } else if (cacheControl.includes('no-cache')) {\r\n return false;\r\n } else {\r\n return true;\r\n }\r\n }\r\n\r\n // check Expires header Expires if response is without Cache-Control\r\n const expiresHeader = headers.get('expires');\r\n if (expiresHeader) {\r\n const expires = Date.parse(expiresHeader);\r\n if (!isNaN(expires)) {\r\n return expires > Date.now();\r\n }\r\n }\r\n\r\n return true;\r\n}\r\n\r\nexport interface NgHttpCachingEntry<K = any, T = any> {\r\n /**\r\n * URL\r\n */\r\n url: string;\r\n /**\r\n * HttpResponse\r\n */\r\n response: HttpResponse<T>;\r\n /**\r\n * HttpRequest\r\n */\r\n request: HttpRequest<K>;\r\n /**\r\n * Timestamp of add to cache time\r\n */\r\n addedTime: number;\r\n /**\r\n * Cache version\r\n */\r\n version: string;\r\n}\r\n\r\nexport const NG_HTTP_CACHING_CONFIG = new InjectionToken<NgHttpCachingContext>(\r\n 'ng-http-caching.config'\r\n);\r\n\r\nexport enum NgHttpCachingStrategy {\r\n /**\r\n * All request are cacheable if HTTP method is into `allowedMethod`\r\n */\r\n ALLOW_ALL = 'ALLOW_ALL',\r\n /**\r\n * Only the request with `X-NG-HTTP-CACHING-ALLOW-CACHE` header are cacheable if HTTP method is into `allowedMethod`\r\n */\r\n DISALLOW_ALL = 'DISALLOW_ALL'\r\n}\r\n\r\nexport enum NgHttpCachingHeaders {\r\n /**\r\n * Request is cacheable if HTTP method is into `allowedMethod`\r\n */\r\n ALLOW_CACHE = 'X-NG-HTTP-CACHING-ALLOW-CACHE',\r\n /**\r\n * Request isn't cacheable\r\n */\r\n DISALLOW_CACHE = 'X-NG-HTTP-CACHING-DISALLOW-CACHE',\r\n /**\r\n * Specific cache lifetime for the request\r\n */\r\n LIFETIME = 'X-NG-HTTP-CACHING-LIFETIME',\r\n /**\r\n * You can tag multiple request by adding this header with the same tag and \r\n * using `NgHttpCachingService.clearCacheByTag(tag: string)` for delete all the tagged request\r\n */\r\n TAG = 'X-NG-HTTP-CACHING-TAG'\r\n}\r\n\r\nexport const NgHttpCachingHeadersList = Object.values(NgHttpCachingHeaders);\r\n\r\nexport const NG_HTTP_CACHING_SECOND_IN_MS = 1000;\r\nexport const NG_HTTP_CACHING_MINUTE_IN_MS = NG_HTTP_CACHING_SECOND_IN_MS * 60;\r\nexport const NG_HTTP_CACHING_HOUR_IN_MS = NG_HTTP_CACHING_MINUTE_IN_MS * 60;\r\nexport const NG_HTTP_CACHING_DAY_IN_MS = NG_HTTP_CACHING_HOUR_IN_MS * 24;\r\nexport const NG_HTTP_CACHING_WEEK_IN_MS = NG_HTTP_CACHING_DAY_IN_MS * 7;\r\nexport const NG_HTTP_CACHING_MONTH_IN_MS = NG_HTTP_CACHING_DAY_IN_MS * 30;\r\nexport const NG_HTTP_CACHING_YEAR_IN_MS = NG_HTTP_CACHING_DAY_IN_MS * 365;\r\n\r\nexport interface NgHttpCachingConfig {\r\n /**\r\n * Set the cache store. You can implement your custom store by implement the `NgHttpCachingStorageInterface` interface, eg.:\r\n */\r\n store?: NgHttpCachingStorageInterface;\r\n /**\r\n * Number of millisecond that a response is stored in the cache. \r\n * You can set specific \"lifetime\" for each request by add the header `X-NG-HTTP-CACHING-LIFETIME` (see example below).\r\n */\r\n lifetime?: number;\r\n /**\r\n * Array of allowed HTTP methods to cache. \r\n * You can allow multiple methods, eg.: `['GET', 'POST', 'PUT', 'DELETE', 'HEAD']` or \r\n * allow all methods by: `['ALL']`. If `allowedMethod` is an empty array (`[]`), no response are cached.\r\n * *Warning!* `NgHttpCaching` use the full url (url with query parameters) as unique key for the cached response,\r\n * this is correct for the `GET` request but is _potentially_ wrong for other type of request (eg. `POST`, `PUT`). \r\n * You can set a different \"key\" by customizing the `getKey` config method (see `getKey` section).\r\n */\r\n allowedMethod?: string[];\r\n /**\r\n * Set the cache strategy, possible strategies are:\r\n * - `NgHttpCachingStrategy.ALLOW_ALL`: All request are cacheable if HTTP method is into `allowedMethod`;\r\n * - `NgHttpCachingStrategy.DISALLOW_ALL`: Only the request with `X-NG-HTTP-CACHING-ALLOW-CACHE` header are cacheable if HTTP method is into `allowedMethod`;\r\n */\r\n cacheStrategy?: NgHttpCachingStrategy;\r\n /**\r\n * Cache version. When you have a breaking change, change the version, and it'll delete the current cache automatically.\r\n * The default value is Angular major version (eg. 13), in this way, the cache is invalidated on every Angular upgrade.\r\n */\r\n version?: string;\r\n /**\r\n * If true response headers cache-control and expires are respected.\r\n */\r\n checkResponseHeaders?: boolean;\r\n /**\r\n * If this function return `true` the request is expired and a new request is send to backend, if return `false` isn't expired. \r\n * If the result is `undefined`, the normal behaviour is provided.\r\n */\r\n isExpired?: <K, T>(entry: NgHttpCachingEntry<K, T>) => boolean | undefined | void;\r\n /**\r\n * If this function return `true` the request is cacheable, if return `false` isn't cacheable. \r\n * If the result is `undefined`, the normal behaviour is provided.\r\n */\r\n isCacheable?: <K>(req: HttpRequest<K>) => boolean | undefined | void;\r\n /**\r\n * This function return the unique key (`string`) for store the response into the cache. \r\n * If the result is `undefined`, the normal behaviour is provided.\r\n */\r\n getKey?: <K>(req: HttpRequest<K>) => string | undefined | void;\r\n /**\r\n * If this function return `true` the cache entry is valid and can be stored, if return `false` isn't valid. \r\n * If the result is `undefined`, the normal behaviour is provided.\r\n */\r\n isValid?: <K, T>(entry: NgHttpCachingEntry<K, T>) => boolean | undefined | void;\r\n}\r\n\r\nexport interface NgHttpCachingDefaultConfig extends NgHttpCachingConfig {\r\n store: NgHttpCachingStorageInterface;\r\n lifetime: number;\r\n allowedMethod: string[];\r\n cacheStrategy: NgHttpCachingStrategy;\r\n version: string;\r\n checkResponseHeaders: boolean;\r\n}\r\n\r\nexport const NgHttpCachingConfigDefault: Readonly<NgHttpCachingDefaultConfig> = {\r\n store: new NgHttpCachingMemoryStorage(),\r\n lifetime: NG_HTTP_CACHING_HOUR_IN_MS,\r\n version: VERSION.major,\r\n allowedMethod: ['GET', 'HEAD'],\r\n cacheStrategy: NgHttpCachingStrategy.ALLOW_ALL,\r\n checkResponseHeaders: false\r\n};\r\n\r\n@Injectable()\r\nexport class NgHttpCachingService {\r\n\r\n private readonly queue = new Map<string, Observable<HttpEvent<any>>>();\r\n\r\n private readonly config: NgHttpCachingDefaultConfig;\r\n\r\n private gcLock = false;\r\n\r\n private devMode: boolean = isDevMode();\r\n\r\n constructor() {\r\n const config: Readonly<NgHttpCachingConfig | null> = inject(NG_HTTP_CACHING_CONFIG, { optional: true });\r\n if (config) {\r\n this.config = { ...NgHttpCachingConfigDefault, ...config };\r\n } else {\r\n this.config = { ...NgHttpCachingConfigDefault };\r\n }\r\n // start cache clean\r\n this.runGc();\r\n }\r\n\r\n /**\r\n * Return the config\r\n */\r\n getConfig(): Readonly<NgHttpCachingConfig> {\r\n return this.config;\r\n }\r\n\r\n /**\r\n * Return the queue map\r\n */\r\n getQueue(): Readonly<Map<string, Observable<HttpEvent<any>>>> {\r\n return this.queue;\r\n }\r\n\r\n /**\r\n * Return the cache store\r\n */\r\n getStore(): Readonly<NgHttpCachingStorageInterface> {\r\n return this.config.store;\r\n }\r\n\r\n /**\r\n * Return response from cache\r\n */\r\n getFromCache<K, T>(req: HttpRequest<K>): Readonly<HttpResponse<T>> | undefined {\r\n const key: string = this.getKey(req);\r\n const cached: NgHttpCachingEntry<K, T> | undefined = this.config.store.get<K, T>(key);\r\n\r\n if (!cached) {\r\n return undefined;\r\n }\r\n\r\n if (this.isExpired(cached)) {\r\n this.clearCacheByKey(key);\r\n return undefined;\r\n }\r\n\r\n return this.deepFreeze(cached.response);\r\n }\r\n\r\n /**\r\n * Add response to cache\r\n */\r\n addToCache<K, T>(req: HttpRequest<K>, res: HttpResponse<T>): boolean {\r\n const entry: NgHttpCachingEntry<K, T> = {\r\n url: req.urlWithParams,\r\n response: res,\r\n request: req,\r\n addedTime: Date.now(),\r\n version: this.config.version,\r\n };\r\n if (this.isValid(entry)) {\r\n const key: string = this.getKey(req);\r\n this.config.store.set(key, entry);\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Delete response from cache\r\n */\r\n deleteFromCache<K>(req: HttpRequest<K>): boolean {\r\n const key: string = this.getKey(req);\r\n return this.clearCacheByKey(key);\r\n }\r\n\r\n /**\r\n * Clear the cache\r\n */\r\n clearCache(): void {\r\n this.config.store.clear();\r\n }\r\n\r\n /**\r\n * Clear the cache by key\r\n */\r\n clearCacheByKey(key: string): boolean {\r\n return this.config.store.delete(key);\r\n }\r\n\r\n /**\r\n * Clear the cache by keys\r\n */\r\n clearCacheByKeys(keys: Array<string>): number {\r\n let counter = 0;\r\n if (keys) {\r\n for (const key of keys) {\r\n if (this.clearCacheByKey(key)) {\r\n counter++;\r\n }\r\n }\r\n }\r\n return counter;\r\n }\r\n\r\n /**\r\n * Clear the cache by regex\r\n */\r\n clearCacheByRegex<K, T>(regex: RegExp): number {\r\n const keys: Array<string> = [];\r\n this.config.store.forEach<K, T>((_: NgHttpCachingEntry<K, T>, key: string) => {\r\n if (regex.test(key)) {\r\n keys.push(key);\r\n }\r\n });\r\n return this.clearCacheByKeys(keys);\r\n }\r\n\r\n /**\r\n * Clear the cache by TAG\r\n */\r\n clearCacheByTag<K, T>(tag: string): number {\r\n const keys: Array<string> = [];\r\n this.config.store.forEach<K, T>((entry: NgHttpCachingEntry<K, T>, key: string) => {\r\n const tagHeader = entry.request.headers.get(NgHttpCachingHeaders.TAG);\r\n if (tagHeader && tagHeader.split(',').includes(tag)) {\r\n keys.push(key);\r\n }\r\n });\r\n return this.clearCacheByKeys(keys);\r\n }\r\n\r\n /**\r\n * Run garbage collector (delete expired cache entry)\r\n */\r\n runGc<K, T>(): boolean {\r\n if (this.gcLock) {\r\n return false;\r\n }\r\n this.gcLock = true;\r\n const keys: Array<string> = [];\r\n this.config.store.forEach<K, T>((entry: NgHttpCachingEntry<K, T>, key: string) => {\r\n if (this.isExpired(entry)) {\r\n keys.push(key);\r\n }\r\n });\r\n this.clearCacheByKeys(keys);\r\n this.gcLock = false;\r\n return true;\r\n }\r\n\r\n /**\r\n * Return true if cache entry is expired\r\n */\r\n isExpired<K, T>(entry: NgHttpCachingEntry<K, T>): boolean {\r\n // if user provide custom method, use it\r\n const context = entry.request.context.get(NG_HTTP_CACHING_CONTEXT);\r\n if (typeof context?.isExpired === 'function') {\r\n const result = context.isExpired(entry);\r\n // if result is undefined, normal behaviour is provided\r\n if (result !== undefined) {\r\n return result;\r\n }\r\n }\r\n // if user provide custom method, use it\r\n if (typeof this.config.isExpired === 'function') {\r\n const result = this.config.isExpired(entry);\r\n // if result is undefined, normal behaviour is provided\r\n if (result !== undefined) {\r\n return result;\r\n }\r\n }\r\n // if version change, always expire\r\n if (this.config.version !== entry.version) {\r\n return true;\r\n }\r\n // config/default lifetime\r\n let lifetime: number = this.config.lifetime;\r\n // request has own lifetime\r\n const headerLifetime = entry.request.headers.get(NgHttpCachingHeaders.LIFETIME);\r\n if (headerLifetime) {\r\n lifetime = +headerLifetime;\r\n }\r\n // never expire if 0\r\n if (lifetime === 0) {\r\n return false;\r\n }\r\n // wrong lifetime\r\n if (lifetime < 0 || isNaN(lifetime)) {\r\n throw new Error('lifetime must be greater than or equal 0');\r\n }\r\n return entry.addedTime + lifetime < Date.now();\r\n }\r\n\r\n /**\r\n * Return true if cache entry is valid for store in the cache\r\n * Default behaviour is whether the status code falls in the 2xx range and response headers cache-control and expires allow cache.\r\n */\r\n isValid<K, T>(entry: NgHttpCachingEntry<K, T>): boolean {\r\n const context = entry.request.context.get(NG_HTTP_CACHING_CONTEXT);\r\n // if user provide custom method, use it\r\n if (typeof context.isValid === 'function') {\r\n const result = context.isValid(entry);\r\n // if result is undefined, normal behaviour is provided\r\n if (result !== undefined) {\r\n return result;\r\n }\r\n }\r\n // if user provide custom method, use it\r\n if (typeof this.config.isValid === 'function') {\r\n const result = this.config.isValid(entry);\r\n // if result is undefined, normal behaviour is provided\r\n if (result !== undefined) {\r\n return result;\r\n }\r\n }\r\n // different version\r\n if (this.config.version !== entry.version) {\r\n return false;\r\n }\r\n\r\n let fromHeader = true;\r\n if (this.config.checkResponseHeaders) {\r\n // check if response headers allow cache\r\n fromHeader = checkCacheHeaders(entry.response.headers);\r\n }\r\n return entry.response.ok && fromHeader;\r\n }\r\n\r\n /**\r\n * Return true if the request is cacheable\r\n */\r\n isCacheable<K>(req: HttpRequest<K>): boolean {\r\n const context = req.context.get(NG_HTTP_CACHING_CONTEXT);\r\n // if user provide custom method, use it\r\n if (typeof context?.isCacheable === 'function') {\r\n const result = context.isCacheable(req);\r\n // if result is undefined, normal behaviour is provided\r\n if (result !== undefined) {\r\n return result;\r\n }\r\n }\r\n // if user provide custom method, use it\r\n if (typeof this.config.isCacheable === 'function') {\r\n const result = this.config.isCacheable(req);\r\n // if result is undefined, normal behaviour is provided\r\n if (result !== undefined) {\r\n return result;\r\n }\r\n }\r\n // request has disallow cache header\r\n if (req.headers.has(NgHttpCachingHeaders.DISALLOW_CACHE)) {\r\n return false;\r\n }\r\n // strategy is disallow all...\r\n if (this.config.cacheStrategy === NgHttpCachingStrategy.DISALLOW_ALL) {\r\n // request isn't allowed if come without allow header\r\n if (!req.headers.has(NgHttpCachingHeaders.ALLOW_CACHE)) {\r\n return false;\r\n }\r\n }\r\n // if allowed method is only ALL, allow all http methods\r\n if (this.config.allowedMethod.length === 1) {\r\n if (this.config.allowedMethod[0] === 'ALL') {\r\n return true;\r\n }\r\n }\r\n // request is allowed if method is in allowedMethod\r\n return this.config.allowedMethod.indexOf(req.method) !== -1;\r\n }\r\n\r\n /**\r\n * Return the cache key.\r\n * Default key is http method plus url with query parameters, eg.:\r\n * `GET@https://github.com/nigrosimone/ng-http-caching`\r\n */\r\n getKey<K>(req: HttpRequest<K>): string {\r\n // if user provide custom method, use it\r\n const context = req.context.get(NG_HTTP_CACHING_CONTEXT);\r\n if (typeof context.getKey === 'function') {\r\n const result = context.getKey(req);\r\n // if result is undefined, normal behaviour is provided\r\n if (result !== undefined) {\r\n return result;\r\n }\r\n }\r\n // if user provide custom method, use it\r\n if (typeof this.config.getKey === 'function') {\r\n const result = this.config.getKey(req);\r\n // if result is undefined, normal behaviour is provided\r\n if (result !== undefined) {\r\n return result;\r\n }\r\n }\r\n // default key is req.method plus url with query parameters\r\n return req.method + '@' + req.urlWithParams;\r\n }\r\n\r\n /**\r\n * Return observable from cache\r\n */\r\n getFromQueue<K, T>(req: HttpRequest<K>): Observable<HttpEvent<T>> | undefined {\r\n const key: string = this.getKey(req);\r\n const cached: Observable<HttpEvent<T>> | undefined = this.queue.get(key);\r\n\r\n if (!cached) {\r\n return undefined;\r\n }\r\n\r\n return cached;\r\n }\r\n\r\n /**\r\n * Add observable to cache\r\n */\r\n addToQueue<K, T>(req: HttpRequest<K>, obs: Observable<HttpEvent<T>>): void {\r\n const key: string = this.getKey(req);\r\n this.queue.set(key, obs);\r\n }\r\n\r\n /**\r\n * Delete observable from cache\r\n */\r\n deleteFromQueue<K>(req: HttpRequest<K>): boolean {\r\n const key: string = this.getKey(req);\r\n return this.queue.delete(key);\r\n }\r\n\r\n /**\r\n * Recursively Object.freeze simple Javascript structures consisting of plain objects, arrays, and primitives.\r\n * Make the data immutable.\r\n * @returns immutable object\r\n */\r\n private deepFreeze<S>(object: S): Readonly<S> {\r\n // No freezing in production (for better performance).\r\n if (!this.devMode || !object || typeof object !== 'object') {\r\n return object as Readonly<S>;\r\n }\r\n\r\n // When already frozen, we assume its children are frozen (for better performance).\r\n // This should be true if you always use `deepFreeze` to freeze objects.\r\n //\r\n // Note that Object.isFrozen will also return `true` for primitives (numbers,\r\n // strings, booleans, undefined, null), so there is no need to check for\r\n // those explicitly.\r\n if (Object.isFrozen(object)) {\r\n return object as Readonly<S>;\r\n }\r\n\r\n // At this point we know that we're dealing with either an array or plain object, so\r\n // just freeze it and recurse on its values.\r\n Object.freeze(object);\r\n Object.keys(object).forEach(key => this.deepFreeze((object as any)[key]));\r\n\r\n return object as Readonly<S>;\r\n }\r\n}\r\n","import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponse } from '@angular/common/http';\r\nimport { inject, Injectable } from '@angular/core';\r\nimport { asyncScheduler, Observable, of, scheduled } from 'rxjs';\r\nimport { tap, finalize, shareReplay } from 'rxjs/operators';\r\nimport { NgHttpCachingService, NgHttpCachingHeadersList } from './ng-http-caching.service';\r\n\r\n@Injectable()\r\nexport class NgHttpCachingInterceptorService implements HttpInterceptor {\r\n\r\n private readonly cacheService: NgHttpCachingService = inject(NgHttpCachingService);\r\n\r\n intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {\r\n // run garbage collector\r\n this.cacheService.runGc();\r\n\r\n // Don't cache if it's not cacheable\r\n if (!this.cacheService.isCacheable(req)) {\r\n return this.sendRequest(req, next);\r\n }\r\n\r\n // Checked if there is pending response for this request\r\n const cachedObservable: Observable<HttpEvent<any>> | undefined = this.cacheService.getFromQueue(req);\r\n if (cachedObservable) {\r\n // console.log('cachedObservable',cachedObservable);\r\n return cachedObservable;\r\n }\r\n\r\n // Checked if there is cached response for this request\r\n const cachedResponse: HttpResponse<any> | undefined = this.cacheService.getFromCache(req);\r\n if (cachedResponse) {\r\n // console.log('cachedResponse');\r\n return scheduled(of(cachedResponse.clone()), asyncScheduler);\r\n }\r\n\r\n // If the request of going through for first time\r\n // then let the request proceed and cache the response\r\n // console.log('sendRequest', req);\r\n const shared = this.sendRequest(req, next).pipe(\r\n tap(event => {\r\n if (event instanceof HttpResponse) {\r\n this.cacheService.addToCache(req, event.clone());\r\n }\r\n }),\r\n finalize(() => {\r\n // delete pending request\r\n this.cacheService.deleteFromQueue(req);\r\n }),\r\n shareReplay()\r\n );\r\n\r\n // add pending request to queue for cache parallel request\r\n this.cacheService.addToQueue(req, shared);\r\n\r\n return shared;\r\n }\r\n\r\n /**\r\n * Send http request (next handler)\r\n */\r\n sendRequest(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {\r\n let cloned: HttpRequest<any> = req.clone();\r\n // trim custom headers before send request\r\n NgHttpCachingHeadersList.forEach(ngHttpCachingHeaders => {\r\n if (cloned.headers.has(ngHttpCachingHeaders)) {\r\n cloned = cloned.clone({ headers: cloned.headers.delete(ngHttpCachingHeaders) });\r\n }\r\n });\r\n return next.handle(cloned);\r\n }\r\n}\r\n","import { NgModule, ModuleWithProviders } from '@angular/core';\r\nimport { HTTP_INTERCEPTORS } from '@angular/common/http';\r\nimport {\r\n NG_HTTP_CACHING_CONFIG,\r\n NgHttpCachingConfig,\r\n NgHttpCachingService,\r\n} from './ng-http-caching.service';\r\nimport { NgHttpCachingInterceptorService } from './ng-http-caching-interceptor.service';\r\n\r\n@NgModule({\r\n providers: [\r\n NgHttpCachingService,\r\n NgHttpCachingInterceptorService,\r\n {\r\n provide: HTTP_INTERCEPTORS,\r\n useClass: NgHttpCachingInterceptorService,\r\n multi: true,\r\n },\r\n ]\r\n})\r\nexport class NgHttpCachingModule {\r\n static forRoot(\r\n ngHttpCachingConfig?: NgHttpCachingConfig\r\n ): ModuleWithProviders<NgHttpCachingModule> {\r\n return {\r\n ngModule: NgHttpCachingModule,\r\n providers: [\r\n {\r\n provide: NG_HTTP_CACHING_CONFIG,\r\n useValue: ngHttpCachingConfig,\r\n },\r\n ],\r\n };\r\n }\r\n}\r\n","import { EnvironmentProviders, makeEnvironmentProviders } from \"@angular/core\";\r\nimport { HTTP_INTERCEPTORS } from \"@angular/common/http\";\r\nimport { NgHttpCachingInterceptorService } from \"./ng-http-caching-interceptor.service\";\r\nimport { NG_HTTP_CACHING_CONFIG, NgHttpCachingConfig, NgHttpCachingService } from \"./ng-http-caching.service\";\r\n\r\nexport function provideNgHttpCaching(ngHttpCachingConfig?: NgHttpCachingConfig) {\r\n const providers: EnvironmentProviders[] = [];\r\n if (ngHttpCachingConfig) {\r\n providers.push(makeEnvironmentProviders([{\r\n provide: NG_HTTP_CACHING_CONFIG,\r\n useValue: ngHttpCachingConfig,\r\n }]));\r\n }\r\n providers.push(makeEnvironmentProviders([\r\n NgHttpCachingService,\r\n {\r\n provide: HTTP_INTERCEPTORS,\r\n useClass: NgHttpCachingInterceptorService,\r\n multi: true,\r\n },\r\n NgHttpCachingInterceptorService\r\n ]));\r\n return providers;\r\n}\r\n","import { NgHttpCachingStorageInterface } from './ng-http-caching-storage.interface';\r\nimport { NgHttpCachingEntry } from '../ng-http-caching.service';\r\nimport { HttpHeaders, HttpParams, HttpRequest, HttpResponse } from '@angular/common/http';\r\n\r\nconst KEY_PREFIX = 'NgHttpCaching::';\r\n\r\nexport interface NgHttpCachingStorageEntry {\r\n url: string;\r\n response: string;\r\n request: string;\r\n addedTime: number;\r\n version: string;\r\n}\r\n\r\nexport const serializeRequest = (req: HttpRequest<any>): string => {\r\n const request = req.clone(); // Make a clone, useful for doing destructive things\r\n return JSON.stringify({\r\n headers: Object.fromEntries( // Just a helper to make this into an object, not really required but makes the output nicer\r\n request.headers.keys().map( // Get all of the headers\r\n (key: string) => [key, request.headers.getAll(key)] // Get all of the corresponding values for the headers\r\n )\r\n ),\r\n method: request.method, // The Request Method, e.g. GET, POST, DELETE\r\n url: request.url, // The URL\r\n params: Object.fromEntries( // Just a helper to make this into an object, not really required but makes the output nicer\r\n request.headers.keys().map( // Get all of the headers\r\n (key: string) => [key, request.headers.getAll(key)] // Get all of the corresponding values for the headers\r\n )\r\n ), // The request parameters\r\n withCredentials: request.withCredentials, // Whether credentials are being sent\r\n responseType: request.responseType, // The response type\r\n body: request.serializeBody() // Serialize the body, all well and good since we are working on a clone\r\n });\r\n}\r\n\r\nexport const serializeResponse = (res: HttpResponse<any>): string => {\r\n const response = res.clone();\r\n return JSON.stringify({\r\n headers: Object.fromEntries( // Just a helper to make this into an object, not really required but makes the output nicer\r\n response.headers.keys().map( // Get all of the headers\r\n (key: string) => [key, response.headers.getAll(key)] // Get all of the corresponding values for the headers\r\n )\r\n ),\r\n status: response.status,\r\n statusText: response.statusText,\r\n url: response.url,\r\n body: response.body // Serialize the body, all well and good since we are working on a clone\r\n });\r\n}\r\n\r\nexport const deserializeRequest = <T = any>(req: string): HttpRequest<T> => {\r\n const request = JSON.parse(req);\r\n const headers = new HttpHeaders(request.headers);\r\n const params = new HttpParams(); // Probably some way to make this a one-liner, but alas, there are no good docs\r\n for (const parameter in request.params) {\r\n request.params[parameter].forEach((paramValue: string) => params.append(parameter, paramValue));\r\n }\r\n return new HttpRequest(request.method, request.url, request.body, {\r\n headers,\r\n params,\r\n responseType: request.responseType,\r\n withCredentials: request.withCredentials\r\n });\r\n}\r\n\r\nexport const deserializeResponse = <T = any>(res: string): HttpResponse<T> => {\r\n const response = JSON.parse(res);\r\n return new HttpResponse<T>({\r\n url: response.url,\r\n headers: new HttpHeaders(response.headers),\r\n body: response.body,\r\n status: response.status,\r\n statusText: response.statusText,\r\n });\r\n}\r\n\r\nexport class NgHttpCachingBrowserStorage implements NgHttpCachingStorageInterface {\r\n\r\n constructor(private storage: Storage) { }\r\n\r\n get size(): number {\r\n let count = 0;\r\n for (let i = 0, e = this.storage.length; i < e; i++) {\r\n const key = this.storage.key(i);\r\n if (key && key.startsWith(KEY_PREFIX)) {\r\n count++;\r\n }\r\n }\r\n return count;\r\n }\r\n\r\n clear(): void {\r\n for (let i = this.storage.length; i >= 0; i--) {\r\n const key = this.storage.key(i);\r\n if (key && key.startsWith(KEY_PREFIX)) {\r\n this.storage.removeItem(key);\r\n }\r\n }\r\n }\r\n\r\n delete(key: string): boolean {\r\n if (!key) {\r\n return false;\r\n }\r\n if (!key.startsWith(KEY_PREFIX)) {\r\n key = KEY_PREFIX + key;\r\n }\r\n this.storage.removeItem(key);\r\n return true;\r\n }\r\n\r\n forEach(callbackfn: (value: NgHttpCachingEntry, key: string) => void): void {\r\n // iterate this.storage\r\n for (let i = 0, e = this.storage.length; i < e; i++) {\r\n const keyWithPrefix = this.storage.key(i);\r\n if (keyWithPrefix && keyWithPrefix.startsWith(KEY_PREFIX)) {\r\n const value = this.get(keyWithPrefix);\r\n if (value) {\r\n const keyWithoutPrefix = keyWithPrefix.substring(KEY_PREFIX.length);\r\n callbackfn(value, keyWithoutPrefix);\r\n }\r\n }\r\n }\r\n }\r\n\r\n get(key: string): Readonly<NgHttpCachingEntry> | undefined {\r\n if (!key) {\r\n return undefined;\r\n }\r\n if (!key.startsWith(KEY_PREFIX)) {\r\n key = KEY_PREFIX + key;\r\n }\r\n const item = this.storage.getItem(key);\r\n if (item) {\r\n const parsedItem: NgHttpCachingStorageEntry = JSON.parse(item);\r\n return this.deserialize(parsedItem);\r\n }\r\n return undefined;\r\n }\r\n\r\n has(key: string): boolean {\r\n if (!key) {\r\n return false;\r\n }\r\n if (!key.startsWith(KEY_PREFIX)) {\r\n key = KEY_PREFIX + key;\r\n }\r\n return !!this.storage.getItem(key);\r\n }\r\n\r\n set(key: string, value: NgHttpCachingEntry): void {\r\n if (!key) {\r\n return;\r\n }\r\n if (!key.startsWith(KEY_PREFIX)) {\r\n key = KEY_PREFIX + key;\r\n }\r\n const unParsedItem: NgHttpCachingStorageEntry = this.serialize(value);\r\n this.storage.setItem(key, JSON.stringify(unParsedItem));\r\n }\r\n\r\n protected serialize(value: NgHttpCachingEntry): NgHttpCachingStorageEntry {\r\n return {\r\n url: value.url,\r\n response: serializeResponse(value.response),\r\n request: serializeRequest(value.request),\r\n addedTime: value.addedTime,\r\n version: value.version\r\n };\r\n }\r\n\r\n protected deserialize(value: NgHttpCachingStorageEntry): NgHttpCachingEntry {\r\n return {\r\n url: value.url,\r\n response: deserializeResponse(value.response),\r\n request: deserializeRequest(value.request),\r\n addedTime: value.addedTime,\r\n version: value.version\r\n };\r\n }\r\n}\r\n\r\n","import { NgHttpCachingBrowserStorage } from './ng-http-caching-browser-storage';\r\n\r\nexport class NgHttpCachingLocalStorage extends NgHttpCachingBrowserStorage {\r\n\r\n constructor() {\r\n super(localStorage);\r\n }\r\n}\r\n\r\nexport const withNgHttpCachingLocalStorage = () => new NgHttpCachingLocalStorage();","import { NgHttpCachingBrowserStorage } from './ng-http-caching-browser-storage';\r\n\r\nexport class NgHttpCachingSessionStorage extends NgHttpCachingBrowserStorage {\r\n\r\n constructor() {\r\n super(sessionStorage);\r\n }\r\n}\r\n\r\nexport const withNgHttpCachingSessionStorage = () => new NgHttpCachingSessionStorage();","/*\r\n * Public API Surface of ng-http-caching\r\n */\r\nexport * from './lib/ng-http-caching-interceptor.service';\r\nexport * from './lib/ng-http-caching.service';\r\nexport * from './lib/ng-http-caching.module';\r\nexport * from './lib/ng-http-caching-provider';\r\nexport * from './lib/storage/ng-http-caching-storage.interface';\r\nexport * from './lib/storage/ng-http-caching-memory-storage';\r\nexport * from './lib/storage/ng-http-caching-local-storage';\r\nexport * from './lib/storage/ng-http-caching-session-storage';\r\nexport * from './lib/storage/ng-http-caching-browser-storage';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;AAGM,MAAO,0BAA2B,SAAQ,GAAyC,CAAA;AAA6C;;ACK/H,MAAM,uBAAuB,GAAG,IAAI,gBAAgB,CAAuB,OAAO,EAAE,CAAC;MAE/E,wBAAwB,GAAG,CAAC,KAA2B,EAAE,OAAuB,GAAA,IAAI,WAAW,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,KAAK;A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ClB;;AAER;;AClLK,MAAO,yBAA0B,SAAQ,2BAA2B,CAAA;AAEtE,IAAA,WAAA,GAAA;QACI,KAAK,CAAC,YAAY,CAAC;;AAE1B;AAEY,MAAA,6BAA6B,GAAG,MAAM,IAAI,yBAAyB;;ACP1E,MAAO,2BAA4B,SAAQ,2BAA2B,CAAA;AAExE,IAAA,WAAA,GAAA;QACI,KAAK,CAAC,cAAc,CAAC;;AAE5B;AAEY,MAAA,+BAA+B,GAAG,MAAM,IAAI,2BAA2B;;ACTpF;;AAEG;;ACFH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ng-http-caching.mjs","sources":["../../../projects/ng-http-caching/src/lib/storage/ng-http-caching-memory-storage.ts","../../../projects/ng-http-caching/src/lib/ng-http-caching.service.ts","../../../projects/ng-http-caching/src/lib/ng-http-caching-interceptor.service.ts","../../../projects/ng-http-caching/src/lib/ng-http-caching.module.ts","../../../projects/ng-http-caching/src/lib/ng-http-caching-provider.ts","../../../projects/ng-http-caching/src/lib/storage/ng-http-caching-browser-storage.ts","../../../projects/ng-http-caching/src/lib/storage/ng-http-caching-local-storage.ts","../../../projects/ng-http-caching/src/lib/storage/ng-http-caching-session-storage.ts","../../../projects/ng-http-caching/src/public-api.ts","../../../projects/ng-http-caching/src/ng-http-caching.ts"],"sourcesContent":["import { NgHttpCachingStorageInterface } from './ng-http-caching-storage.interface';\r\nimport { NgHttpCachingEntry } from '../ng-http-caching.service';\r\n\r\nexport class NgHttpCachingMemoryStorage extends Map<string, NgHttpCachingEntry<any, any>> implements NgHttpCachingStorageInterface { }\r\n","import { Injectable, InjectionToken, VERSION, isDevMode, inject } from '@angular/core';\nimport { HttpRequest, HttpResponse, HttpEvent, HttpContextToken, HttpContext, HttpHeaders } from '@angular/common/http';\nimport { Observable } from 'rxjs/internal/Observable';\nimport { NgHttpCachingStorageInterface } from './storage/ng-http-caching-storage.interface';\nimport { NgHttpCachingMemoryStorage } from './storage/ng-http-caching-memory-storage';\n\nexport type NgHttpCachingContext = Pick<NgHttpCachingConfig, 'getKey' | 'isCacheable' | 'isExpired' | 'isValid'>;\n\nexport const NG_HTTP_CACHING_CONTEXT = new HttpContextToken<NgHttpCachingContext>(() => ({}));\n\nexport const withNgHttpCachingContext = (value: NgHttpCachingContext, context: HttpContext = new HttpContext()) => context.set(NG_HTTP_CACHING_CONTEXT, value)\n\nexport const checkCacheHeaders = (headers: HttpHeaders): boolean => {\n // check Cache-Control\n const cacheControlHeader = headers.get('cache-control');\n if (cacheControlHeader) {\n const cacheControl = cacheControlHeader.toLowerCase();\n if (cacheControl.includes('no-store')) {\n return false;\n } else if (cacheControl.includes('no-cache')) {\n return false;\n } else {\n return true;\n }\n }\n\n // check Expires header Expires if response is without Cache-Control\n const expiresHeader = headers.get('expires');\n if (expiresHeader) {\n const expires = Date.parse(expiresHeader);\n if (!isNaN(expires)) {\n return expires > Date.now();\n }\n }\n\n return true;\n}\n\nexport interface NgHttpCachingEntry<K = any, T = any> {\n /**\n * URL\n */\n url: string;\n /**\n * HttpResponse\n */\n response: HttpResponse<T>;\n /**\n * HttpRequest\n */\n request: HttpRequest<K>;\n /**\n * Timestamp of add to cache time\n */\n addedTime: number;\n /**\n * Cache version\n */\n version: string;\n}\n\nexport const NG_HTTP_CACHING_CONFIG = new InjectionToken<NgHttpCachingContext>(\n 'ng-http-caching.config'\n);\n\nexport enum NgHttpCachingStrategy {\n /**\n * All request are cacheable if HTTP method is into `allowedMethod`\n */\n ALLOW_ALL = 'ALLOW_ALL',\n /**\n * Only the request with `X-NG-HTTP-CACHING-ALLOW-CACHE` header are cacheable if HTTP method is into `allowedMethod`\n */\n DISALLOW_ALL = 'DISALLOW_ALL'\n}\n\nexport enum NgHttpCachingHeaders {\n /**\n * Request is cacheable if HTTP method is into `allowedMethod`\n */\n ALLOW_CACHE = 'X-NG-HTTP-CACHING-ALLOW-CACHE',\n /**\n * Request isn't cacheable\n */\n DISALLOW_CACHE = 'X-NG-HTTP-CACHING-DISALLOW-CACHE',\n /**\n * Specific cache lifetime for the request\n */\n LIFETIME = 'X-NG-HTTP-CACHING-LIFETIME',\n /**\n * You can tag multiple request by adding this header with the same tag and \n * using `NgHttpCachingService.clearCacheByTag(tag: string)` for delete all the tagged request\n */\n TAG = 'X-NG-HTTP-CACHING-TAG'\n}\n\nexport const NgHttpCachingHeadersList = Object.values(NgHttpCachingHeaders);\n\nexport const NG_HTTP_CACHING_SECOND_IN_MS = 1000;\nexport const NG_HTTP_CACHING_MINUTE_IN_MS = NG_HTTP_CACHING_SECOND_IN_MS * 60;\nexport const NG_HTTP_CACHING_HOUR_IN_MS = NG_HTTP_CACHING_MINUTE_IN_MS * 60;\nexport const NG_HTTP_CACHING_DAY_IN_MS = NG_HTTP_CACHING_HOUR_IN_MS * 24;\nexport const NG_HTTP_CACHING_WEEK_IN_MS = NG_HTTP_CACHING_DAY_IN_MS * 7;\nexport const NG_HTTP_CACHING_MONTH_IN_MS = NG_HTTP_CACHING_DAY_IN_MS * 30;\nexport const NG_HTTP_CACHING_YEAR_IN_MS = NG_HTTP_CACHING_DAY_IN_MS * 365;\n\nexport interface NgHttpCachingConfig {\n /**\n * Set the cache store. You can implement your custom store by implement the `NgHttpCachingStorageInterface` interface, eg.:\n */\n store?: NgHttpCachingStorageInterface;\n /**\n * Number of millisecond that a response is stored in the cache. \n * You can set specific \"lifetime\" for each request by add the header `X-NG-HTTP-CACHING-LIFETIME` (see example below).\n */\n lifetime?: number;\n /**\n * Array of allowed HTTP methods to cache. \n * You can allow multiple methods, eg.: `['GET', 'POST', 'PUT', 'DELETE', 'HEAD']` or \n * allow all methods by: `['ALL']`. If `allowedMethod` is an empty array (`[]`), no response are cached.\n * *Warning!* `NgHttpCaching` use the full url (url with query parameters) as unique key for the cached response,\n * this is correct for the `GET` request but is _potentially_ wrong for other type of request (eg. `POST`, `PUT`). \n * You can set a different \"key\" by customizing the `getKey` config method (see `getKey` section).\n */\n allowedMethod?: string[];\n /**\n * Set the cache strategy, possible strategies are:\n * - `NgHttpCachingStrategy.ALLOW_ALL`: All request are cacheable if HTTP method is into `allowedMethod`;\n * - `NgHttpCachingStrategy.DISALLOW_ALL`: Only the request with `X-NG-HTTP-CACHING-ALLOW-CACHE` header are cacheable if HTTP method is into `allowedMethod`;\n */\n cacheStrategy?: NgHttpCachingStrategy;\n /**\n * Cache version. When you have a breaking change, change the version, and it'll delete the current cache automatically.\n * The default value is Angular major version (eg. 13), in this way, the cache is invalidated on every Angular upgrade.\n */\n version?: string;\n /**\n * If true response headers cache-control and expires are respected.\n */\n checkResponseHeaders?: boolean;\n /**\n * If this function return `true` the request is expired and a new request is send to backend, if return `false` isn't expired. \n * If the result is `undefined`, the normal behaviour is provided.\n */\n isExpired?: <K, T>(entry: NgHttpCachingEntry<K, T>) => boolean | undefined | void;\n /**\n * If this function return `true` the request is cacheable, if return `false` isn't cacheable. \n * If the result is `undefined`, the normal behaviour is provided.\n */\n isCacheable?: <K>(req: HttpRequest<K>) => boolean | undefined | void;\n /**\n * This function return the unique key (`string`) for store the response into the cache. \n * If the result is `undefined`, the normal behaviour is provided.\n */\n getKey?: <K>(req: HttpRequest<K>) => string | undefined | void;\n /**\n * If this function return `true` the cache entry is valid and can be stored, if return `false` isn't valid. \n * If the result is `undefined`, the normal behaviour is provided.\n */\n isValid?: <K, T>(entry: NgHttpCachingEntry<K, T>) => boolean | undefined | void;\n}\n\nexport interface NgHttpCachingDefaultConfig extends NgHttpCachingConfig {\n store: NgHttpCachingStorageInterface;\n lifetime: number;\n allowedMethod: string[];\n cacheStrategy: NgHttpCachingStrategy;\n version: string;\n checkResponseHeaders: boolean;\n}\n\nexport const NgHttpCachingConfigDefault: Readonly<NgHttpCachingDefaultConfig> = {\n store: new NgHttpCachingMemoryStorage(),\n lifetime: NG_HTTP_CACHING_HOUR_IN_MS,\n version: VERSION.major,\n allowedMethod: ['GET', 'HEAD'],\n cacheStrategy: NgHttpCachingStrategy.ALLOW_ALL,\n checkResponseHeaders: false\n};\n\n@Injectable()\nexport class NgHttpCachingService {\n\n private readonly queue = new Map<string, Observable<HttpEvent<any>>>();\n\n private readonly config: NgHttpCachingDefaultConfig;\n\n private gcLock = false;\n\n private devMode: boolean = isDevMode();\n\n constructor() {\n const config: Readonly<NgHttpCachingConfig | null> = inject(NG_HTTP_CACHING_CONFIG, { optional: true });\n if (config) {\n this.config = { ...NgHttpCachingConfigDefault, ...config };\n } else {\n this.config = { ...NgHttpCachingConfigDefault };\n }\n // start cache clean\n this.runGc();\n }\n\n /**\n * Return the config\n */\n getConfig(): Readonly<NgHttpCachingConfig> {\n return this.config;\n }\n\n /**\n * Return the queue map\n */\n getQueue(): Readonly<Map<string, Observable<HttpEvent<any>>>> {\n return this.queue;\n }\n\n /**\n * Return the cache store\n */\n getStore(): Readonly<NgHttpCachingStorageInterface> {\n return this.config.store;\n }\n\n /**\n * Return response from cache\n */\n getFromCache<K, T>(req: HttpRequest<K>): Readonly<HttpResponse<T>> | undefined {\n const key: string = this.getKey(req);\n const cached: NgHttpCachingEntry<K, T> | undefined = this.config.store.get<K, T>(key);\n\n if (!cached) {\n return undefined;\n }\n\n if (this.isExpired(cached)) {\n this.clearCacheByKey(key);\n return undefined;\n }\n\n return this.deepFreeze(cached.response);\n }\n\n /**\n * Add response to cache\n */\n addToCache<K, T>(req: HttpRequest<K>, res: HttpResponse<T>): boolean {\n const entry: NgHttpCachingEntry<K, T> = {\n url: req.urlWithParams,\n response: res,\n request: req,\n addedTime: Date.now(),\n version: this.config.version,\n };\n if (this.isValid(entry)) {\n const key: string = this.getKey(req);\n this.config.store.set(key, entry);\n return true;\n }\n return false;\n }\n\n /**\n * Delete response from cache\n */\n deleteFromCache<K>(req: HttpRequest<K>): boolean {\n const key: string = this.getKey(req);\n return this.clearCacheByKey(key);\n }\n\n /**\n * Clear the cache\n */\n clearCache(): void {\n this.config.store.clear();\n }\n\n /**\n * Clear the cache by key\n */\n clearCacheByKey(key: string): boolean {\n return this.config.store.delete(key);\n }\n\n /**\n * Clear the cache by keys\n */\n clearCacheByKeys(keys: Array<string>): number {\n let counter = 0;\n if (keys) {\n for (const key of keys) {\n if (this.clearCacheByKey(key)) {\n counter++;\n }\n }\n }\n return counter;\n }\n\n /**\n * Clear the cache by regex\n */\n clearCacheByRegex<K, T>(regex: RegExp): number {\n const keys: Array<string> = [];\n this.config.store.forEach<K, T>((_: NgHttpCachingEntry<K, T>, key: string) => {\n if (regex.test(key)) {\n keys.push(key);\n }\n });\n return this.clearCacheByKeys(keys);\n }\n\n /**\n * Clear the cache by TAG\n */\n clearCacheByTag<K, T>(tag: string): number {\n const keys: Array<string> = [];\n this.config.store.forEach<K, T>((entry: NgHttpCachingEntry<K, T>, key: string) => {\n const tagHeader = entry.request.headers.get(NgHttpCachingHeaders.TAG);\n if (tagHeader && tagHeader.split(',').includes(tag)) {\n keys.push(key);\n }\n });\n return this.clearCacheByKeys(keys);\n }\n\n /**\n * Run garbage collector (delete expired cache entry)\n */\n runGc<K, T>(): boolean {\n if (this.gcLock) {\n return false;\n }\n this.gcLock = true;\n const keys: Array<string> = [];\n this.config.store.forEach<K, T>((entry: NgHttpCachingEntry<K, T>, key: string) => {\n if (this.isExpired(entry)) {\n keys.push(key);\n }\n });\n this.clearCacheByKeys(keys);\n this.gcLock = false;\n return true;\n }\n\n /**\n * Return true if cache entry is expired\n */\n isExpired<K, T>(entry: NgHttpCachingEntry<K, T>): boolean {\n // if user provide custom method, use it\n const context = entry.request.context.get(NG_HTTP_CACHING_CONTEXT);\n if (typeof context?.isExpired === 'function') {\n const result = context.isExpired(entry);\n // if result is undefined, normal behaviour is provided\n if (result !== undefined) {\n return result;\n }\n }\n // if user provide custom method, use it\n if (typeof this.config.isExpired === 'function') {\n const result = this.config.isExpired(entry);\n // if result is undefined, normal behaviour is provided\n if (result !== undefined) {\n return result;\n }\n }\n // if version change, always expire\n if (this.config.version !== entry.version) {\n return true;\n }\n // config/default lifetime\n let lifetime: number = this.config.lifetime;\n // request has own lifetime\n const headerLifetime = entry.request.headers.get(NgHttpCachingHeaders.LIFETIME);\n if (headerLifetime) {\n lifetime = +headerLifetime;\n }\n // never expire if 0\n if (lifetime === 0) {\n return false;\n }\n // wrong lifetime\n if (lifetime < 0 || isNaN(lifetime)) {\n throw new Error('lifetime must be greater than or equal 0');\n }\n return entry.addedTime + lifetime < Date.now();\n }\n\n /**\n * Return true if cache entry is valid for store in the cache\n * Default behaviour is whether the status code falls in the 2xx range and response headers cache-control and expires allow cache.\n */\n isValid<K, T>(entry: NgHttpCachingEntry<K, T>): boolean {\n const context = entry.request.context.get(NG_HTTP_CACHING_CONTEXT);\n // if user provide custom method, use it\n if (typeof context.isValid === 'function') {\n const result = context.isValid(entry);\n // if result is undefined, normal behaviour is provided\n if (result !== undefined) {\n return result;\n }\n }\n // if user provide custom method, use it\n if (typeof this.config.isValid === 'function') {\n const result = this.config.isValid(entry);\n // if result is undefined, normal behaviour is provided\n if (result !== undefined) {\n return result;\n }\n }\n // different version\n if (this.config.version !== entry.version) {\n return false;\n }\n\n let fromHeader = true;\n if (this.config.checkResponseHeaders) {\n // check if response headers allow cache\n fromHeader = checkCacheHeaders(entry.response.headers);\n }\n return entry.response.ok && fromHeader;\n }\n\n /**\n * Return true if the request is cacheable\n */\n isCacheable<K>(req: HttpRequest<K>): boolean {\n const context = req.context.get(NG_HTTP_CACHING_CONTEXT);\n // if user provide custom method, use it\n if (typeof context?.isCacheable === 'function') {\n const result = context.isCacheable(req);\n // if result is undefined, normal behaviour is provided\n if (result !== undefined) {\n return result;\n }\n }\n // if user provide custom method, use it\n if (typeof this.config.isCacheable === 'function') {\n const result = this.config.isCacheable(req);\n // if result is undefined, normal behaviour is provided\n if (result !== undefined) {\n return result;\n }\n }\n // request has disallow cache header\n if (req.headers.has(NgHttpCachingHeaders.DISALLOW_CACHE)) {\n return false;\n }\n // strategy is disallow all...\n if (this.config.cacheStrategy === NgHttpCachingStrategy.DISALLOW_ALL) {\n // request isn't allowed if come without allow header\n if (!req.headers.has(NgHttpCachingHeaders.ALLOW_CACHE)) {\n return false;\n }\n }\n // if allowed method is only ALL, allow all http methods\n if (this.config.allowedMethod.length === 1) {\n if (this.config.allowedMethod[0] === 'ALL') {\n return true;\n }\n }\n // request is allowed if method is in allowedMethod\n return this.config.allowedMethod.includes(req.method);\n }\n\n /**\n * Return the cache key.\n * Default key is http method plus url with query parameters, eg.:\n * `GET@https://github.com/nigrosimone/ng-http-caching`\n */\n getKey<K>(req: HttpRequest<K>): string {\n // if user provide custom method, use it\n const context = req.context.get(NG_HTTP_CACHING_CONTEXT);\n if (typeof context.getKey === 'function') {\n const result = context.getKey(req);\n // if result is undefined, normal behaviour is provided\n if (result !== undefined) {\n return result;\n }\n }\n // if user provide custom method, use it\n if (typeof this.config.getKey === 'function') {\n const result = this.config.getKey(req);\n // if result is undefined, normal behaviour is provided\n if (result !== undefined) {\n return result;\n }\n }\n // default key is req.method plus url with query parameters\n return req.method + '@' + req.urlWithParams;\n }\n\n /**\n * Return observable from cache\n */\n getFromQueue<K, T>(req: HttpRequest<K>): Observable<HttpEvent<T>> | undefined {\n const key: string = this.getKey(req);\n const cached: Observable<HttpEvent<T>> | undefined = this.queue.get(key);\n\n if (!cached) {\n return undefined;\n }\n\n return cached;\n }\n\n /**\n * Add observable to cache\n */\n addToQueue<K, T>(req: HttpRequest<K>, obs: Observable<HttpEvent<T>>): void {\n const key: string = this.getKey(req);\n this.queue.set(key, obs);\n }\n\n /**\n * Delete observable from cache\n */\n deleteFromQueue<K>(req: HttpRequest<K>): boolean {\n const key: string = this.getKey(req);\n return this.queue.delete(key);\n }\n\n /**\n * Recursively Object.freeze simple Javascript structures consisting of plain objects, arrays, and primitives.\n * Make the data immutable.\n * @returns immutable object\n */\n private deepFreeze<S>(object: S): Readonly<S> {\n // No freezing in production (for better performance).\n if (!this.devMode || !object || typeof object !== 'object') {\n return object as Readonly<S>;\n }\n\n // When already frozen, we assume its children are frozen (for better performance).\n // This should be true if you always use `deepFreeze` to freeze objects.\n //\n // Note that Object.isFrozen will also return `true` for primitives (numbers,\n // strings, booleans, undefined, null), so there is no need to check for\n // those explicitly.\n if (Object.isFrozen(object)) {\n return object as Readonly<S>;\n }\n\n // At this point we know that we're dealing with either an array or plain object, so\n // just freeze it and recurse on its values.\n Object.freeze(object);\n Object.keys(object).forEach(key => this.deepFreeze((object as any)[key]));\n\n return object as Readonly<S>;\n }\n}\n","import { HttpEvent, HttpEventType, HttpHandler, HttpHeaders, HttpInterceptor, HttpRequest, HttpResponse } from '@angular/common/http';\r\nimport { inject, Injectable } from '@angular/core';\r\nimport { asyncScheduler, Observable, of, scheduled } from 'rxjs';\r\nimport { tap, shareReplay } from 'rxjs/operators';\r\nimport { NgHttpCachingService, NgHttpCachingHeadersList } from './ng-http-caching.service';\r\n\r\n@Injectable()\r\nexport class NgHttpCachingInterceptorService implements HttpInterceptor {\r\n\r\n private readonly cacheService: NgHttpCachingService = inject(NgHttpCachingService);\r\n\r\n intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {\r\n // run garbage collector\r\n this.cacheService.runGc();\r\n\r\n // Don't cache if it's not cacheable\r\n if (!this.cacheService.isCacheable(req)) {\r\n return this.sendRequest(req, next);\r\n }\r\n\r\n // Checked if there is pending response for this request\r\n const cachedObservable: Observable<HttpEvent<any>> | undefined = this.cacheService.getFromQueue(req);\r\n if (cachedObservable) {\r\n // console.log('cachedObservable',cachedObservable);\r\n return cachedObservable;\r\n }\r\n\r\n // Checked if there is cached response for this request\r\n const cachedResponse: HttpResponse<any> | undefined = this.cacheService.getFromCache(req);\r\n if (cachedResponse) {\r\n // console.log('cachedResponse');\r\n return scheduled(of(cachedResponse.clone()), asyncScheduler);\r\n }\r\n\r\n // If the request of going through for first time\r\n // then let the request proceed and cache the response\r\n // console.log('sendRequest', req);\r\n const shared = this.sendRequest(req, next).pipe(\r\n tap(event => {\r\n if (event.type === HttpEventType.Response) {\r\n this.cacheService.addToCache(req, event);\r\n // delete pending request\r\n this.cacheService.deleteFromQueue(req);\r\n }\r\n }),\r\n shareReplay()\r\n );\r\n\r\n // add pending request to queue for cache parallel request\r\n this.cacheService.addToQueue(req, shared);\r\n\r\n return shared;\r\n }\r\n\r\n /**\r\n * Send http request (next handler)\r\n */\r\n sendRequest(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {\r\n // trim custom headers before send request\r\n let headers: HttpHeaders = req.headers;\r\n let needClone = false;\r\n for (const header of NgHttpCachingHeadersList) {\r\n if (headers.has(header)) {\r\n needClone = true;\r\n headers = headers.delete(header);\r\n }\r\n }\r\n if (needClone) {\r\n req = req.clone({ headers });\r\n }\r\n return next.handle(req);\r\n }\r\n}\r\n","import { NgModule, ModuleWithProviders } from '@angular/core';\r\nimport { HTTP_INTERCEPTORS } from '@angular/common/http';\r\nimport {\r\n NG_HTTP_CACHING_CONFIG,\r\n NgHttpCachingConfig,\r\n NgHttpCachingService,\r\n} from './ng-http-caching.service';\r\nimport { NgHttpCachingInterceptorService } from './ng-http-caching-interceptor.service';\r\n\r\n@NgModule({\r\n providers: [\r\n NgHttpCachingService,\r\n NgHttpCachingInterceptorService,\r\n {\r\n provide: HTTP_INTERCEPTORS,\r\n useClass: NgHttpCachingInterceptorService,\r\n multi: true,\r\n },\r\n ]\r\n})\r\nexport class NgHttpCachingModule {\r\n static forRoot(\r\n ngHttpCachingConfig?: NgHttpCachingConfig\r\n ): ModuleWithProviders<NgHttpCachingModule> {\r\n return {\r\n ngModule: NgHttpCachingModule,\r\n providers: [\r\n {\r\n provide: NG_HTTP_CACHING_CONFIG,\r\n useValue: ngHttpCachingConfig,\r\n },\r\n ],\r\n };\r\n }\r\n}\r\n","import { makeEnvironmentProviders, Provider } from \"@angular/core\";\r\nimport { HTTP_INTERCEPTORS } from \"@angular/common/http\";\r\nimport { NgHttpCachingInterceptorService } from \"./ng-http-caching-interceptor.service\";\r\nimport { NG_HTTP_CACHING_CONFIG, NgHttpCachingConfig, NgHttpCachingService } from \"./ng-http-caching.service\";\r\n\r\nexport function provideNgHttpCaching(ngHttpCachingConfig?: NgHttpCachingConfig) {\r\n const providers: Provider[] = [\r\n NgHttpCachingService,\r\n {\r\n provide: HTTP_INTERCEPTORS,\r\n useClass: NgHttpCachingInterceptorService,\r\n multi: true,\r\n },\r\n NgHttpCachingInterceptorService\r\n ];\r\n if (ngHttpCachingConfig) {\r\n providers.push({\r\n provide: NG_HTTP_CACHING_CONFIG,\r\n useValue: ngHttpCachingConfig,\r\n });\r\n }\r\n return makeEnvironmentProviders(providers);\r\n}\r\n","import { NgHttpCachingStorageInterface } from './ng-http-caching-storage.interface';\r\nimport { NgHttpCachingEntry } from '../ng-http-caching.service';\r\nimport { HttpHeaders, HttpParams, HttpRequest, HttpResponse } from '@angular/common/http';\r\n\r\nconst KEY_PREFIX = 'NgHttpCaching::';\r\n\r\nexport interface NgHttpCachingStorageEntry {\r\n url: string;\r\n response: string;\r\n request: string;\r\n addedTime: number;\r\n version: string;\r\n}\r\n\r\nexport const serializeRequest = (req: HttpRequest<any>): string => {\r\n const request = req.clone(); // Make a clone, useful for doing destructive things\r\n return JSON.stringify({\r\n headers: Object.fromEntries( // Just a helper to make this into an object, not really required but makes the output nicer\r\n request.headers.keys().map( // Get all of the headers\r\n (key: string) => [key, request.headers.getAll(key)] // Get all of the corresponding values for the headers\r\n )\r\n ),\r\n method: request.method, // The Request Method, e.g. GET, POST, DELETE\r\n url: request.url, // The URL\r\n params: Object.fromEntries( // Just a helper to make this into an object, not really required but makes the output nicer\r\n request.headers.keys().map( // Get all of the headers\r\n (key: string) => [key, request.headers.getAll(key)] // Get all of the corresponding values for the headers\r\n )\r\n ), // The request parameters\r\n withCredentials: request.withCredentials, // Whether credentials are being sent\r\n responseType: request.responseType, // The response type\r\n body: request.serializeBody() // Serialize the body, all well and good since we are working on a clone\r\n });\r\n}\r\n\r\nexport const serializeResponse = (res: HttpResponse<any>): string => {\r\n const response = res.clone();\r\n return JSON.stringify({\r\n headers: Object.fromEntries( // Just a helper to make this into an object, not really required but makes the output nicer\r\n response.headers.keys().map( // Get all of the headers\r\n (key: string) => [key, response.headers.getAll(key)] // Get all of the corresponding values for the headers\r\n )\r\n ),\r\n status: response.status,\r\n statusText: response.statusText,\r\n url: response.url,\r\n body: response.body // Serialize the body, all well and good since we are working on a clone\r\n });\r\n}\r\n\r\nexport const deserializeRequest = <T = any>(req: string): HttpRequest<T> => {\r\n const request = JSON.parse(req);\r\n const headers = new HttpHeaders(request.headers);\r\n const params = new HttpParams(); // Probably some way to make this a one-liner, but alas, there are no good docs\r\n for (const parameter in request.params) {\r\n request.params[parameter].forEach((paramValue: string) => params.append(parameter, paramValue));\r\n }\r\n return new HttpRequest(request.method, request.url, request.body, {\r\n headers,\r\n params,\r\n responseType: request.responseType,\r\n withCredentials: request.withCredentials\r\n });\r\n}\r\n\r\nexport const deserializeResponse = <T = any>(res: string): HttpResponse<T> => {\r\n const response = JSON.parse(res);\r\n return new HttpResponse<T>({\r\n url: response.url,\r\n headers: new HttpHeaders(response.headers),\r\n body: response.body,\r\n status: response.status,\r\n statusText: response.statusText,\r\n });\r\n}\r\n\r\nexport class NgHttpCachingBrowserStorage implements NgHttpCachingStorageInterface {\r\n\r\n constructor(private storage: Storage) { }\r\n\r\n get size(): number {\r\n let count = 0;\r\n for (let i = 0, e = this.storage.length; i < e; i++) {\r\n const key = this.storage.key(i);\r\n if (key && key.startsWith(KEY_PREFIX)) {\r\n count++;\r\n }\r\n }\r\n return count;\r\n }\r\n\r\n clear(): void {\r\n for (let i = this.storage.length; i >= 0; i--) {\r\n const key = this.storage.key(i);\r\n if (key && key.startsWith(KEY_PREFIX)) {\r\n this.storage.removeItem(key);\r\n }\r\n }\r\n }\r\n\r\n delete(key: string): boolean {\r\n if (!key) {\r\n return false;\r\n }\r\n if (!key.startsWith(KEY_PREFIX)) {\r\n key = KEY_PREFIX + key;\r\n }\r\n this.storage.removeItem(key);\r\n return true;\r\n }\r\n\r\n forEach(callbackfn: (value: NgHttpCachingEntry, key: string) => void): void {\r\n // iterate this.storage\r\n for (let i = 0, e = this.storage.length; i < e; i++) {\r\n const keyWithPrefix = this.storage.key(i);\r\n if (keyWithPrefix && keyWithPrefix.startsWith(KEY_PREFIX)) {\r\n const value = this.get(keyWithPrefix);\r\n if (value) {\r\n const keyWithoutPrefix = keyWithPrefix.substring(KEY_PREFIX.length);\r\n callbackfn(value, keyWithoutPrefix);\r\n }\r\n }\r\n }\r\n }\r\n\r\n get(key: string): Readonly<NgHttpCachingEntry> | undefined {\r\n if (!key) {\r\n return undefined;\r\n }\r\n if (!key.startsWith(KEY_PREFIX)) {\r\n key = KEY_PREFIX + key;\r\n }\r\n const item = this.storage.getItem(key);\r\n if (item) {\r\n const parsedItem: NgHttpCachingStorageEntry = JSON.parse(item);\r\n return this.deserialize(parsedItem);\r\n }\r\n return undefined;\r\n }\r\n\r\n has(key: string): boolean {\r\n if (!key) {\r\n return false;\r\n }\r\n if (!key.startsWith(KEY_PREFIX)) {\r\n key = KEY_PREFIX + key;\r\n }\r\n return !!this.storage.getItem(key);\r\n }\r\n\r\n set(key: string, value: NgHttpCachingEntry): void {\r\n if (!key) {\r\n return;\r\n }\r\n if (!key.startsWith(KEY_PREFIX)) {\r\n key = KEY_PREFIX + key;\r\n }\r\n const unParsedItem: NgHttpCachingStorageEntry = this.serialize(value);\r\n this.storage.setItem(key, JSON.stringify(unParsedItem));\r\n }\r\n\r\n protected serialize(value: NgHttpCachingEntry): NgHttpCachingStorageEntry {\r\n return {\r\n url: value.url,\r\n response: serializeResponse(value.response),\r\n request: serializeRequest(value.request),\r\n addedTime: value.addedTime,\r\n version: value.version\r\n };\r\n }\r\n\r\n protected deserialize(value: NgHttpCachingStorageEntry): NgHttpCachingEntry {\r\n return {\r\n url: value.url,\r\n response: deserializeResponse(value.response),\r\n request: deserializeRequest(value.request),\r\n addedTime: value.addedTime,\r\n version: value.version\r\n };\r\n }\r\n}\r\n\r\n","import { NgHttpCachingBrowserStorage } from './ng-http-caching-browser-storage';\r\n\r\nexport class NgHttpCachingLocalStorage extends NgHttpCachingBrowserStorage {\r\n\r\n constructor() {\r\n super(localStorage);\r\n }\r\n}\r\n\r\nexport const withNgHttpCachingLocalStorage = () => new NgHttpCachingLocalStorage();","import { NgHttpCachingBrowserStorage } from './ng-http-caching-browser-storage';\r\n\r\nexport class NgHttpCachingSessionStorage extends NgHttpCachingBrowserStorage {\r\n\r\n constructor() {\r\n super(sessionStorage);\r\n }\r\n}\r\n\r\nexport const withNgHttpCachingSessionStorage = () => new NgHttpCachingSessionStorage();","/*\r\n * Public API Surface of ng-http-caching\r\n */\r\nexport * from './lib/ng-http-caching-interceptor.service';\r\nexport * from './lib/ng-http-caching.service';\r\nexport * from './lib/ng-http-caching.module';\r\nexport * from './lib/ng-http-caching-provider';\r\nexport * from './lib/storage/ng-http-caching-storage.interface';\r\nexport * from './lib/storage/ng-http-caching-memory-storage';\r\nexport * from './lib/storage/ng-http-caching-local-storage';\r\nexport * from './lib/storage/ng-http-caching-session-storage';\r\nexport * from './lib/storage/ng-http-caching-browser-storage';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;AAGM,MAAO,0BAA2B,SAAQ,GAAyC,CAAA;AAA6C;;ACK/H,MAAM,uBAAuB,GAAG,IAAI,gBAAgB,CAAuB,OAAO,EAAE,CAAC;MAE/E,wBAAwB,GAAG,CAAC,KAA2B,EAAE,OAAuB,GAAA,IAAI,WAAW,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,KAAK;AAEhJ,MAAA,iBAAiB,GAAG,CAAC,OAAoB,KAAa;;IAEjE,MAAM,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;IACvD,IAAI,kBAAkB,EAAE;AACtB,QAAA,MAAM,YAAY,GAAG,kBAAkB,CAAC,WAAW,EAAE;AACrD,QAAA,IAAI,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;AACrC,YAAA,OAAO,KAAK;;AACP,aAAA,IAAI,YAAY,CAAC,QA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|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent, HttpResponse, HttpContextToken, HttpContext, HttpHeaders } from '@angular/common/http';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import * as i0 from '@angular/core';
|
|
4
|
+
import { InjectionToken, ModuleWithProviders } from '@angular/core';
|
|
5
|
+
import { Observable as Observable$1 } from 'rxjs/internal/Observable';
|
|
6
|
+
|
|
7
|
+
declare class NgHttpCachingInterceptorService implements HttpInterceptor {
|
|
8
|
+
private readonly cacheService;
|
|
9
|
+
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>;
|
|
10
|
+
/**
|
|
11
|
+
* Send http request (next handler)
|
|
12
|
+
*/
|
|
13
|
+
sendRequest(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>;
|
|
14
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NgHttpCachingInterceptorService, never>;
|
|
15
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<NgHttpCachingInterceptorService>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface NgHttpCachingStorageInterface {
|
|
19
|
+
/**
|
|
20
|
+
* The number of cached entries.
|
|
21
|
+
*/
|
|
22
|
+
readonly size: number;
|
|
23
|
+
/**
|
|
24
|
+
* Clear the cache.
|
|
25
|
+
*/
|
|
26
|
+
clear(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Delete the cache entry for the provided key.
|
|
29
|
+
*/
|
|
30
|
+
delete(key: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The forEach() method executes a provided function once for each cache entry.
|
|
33
|
+
*/
|
|
34
|
+
forEach<K = any, T = any>(callbackfn: (value: NgHttpCachingEntry<K, T>, key: string) => void): void;
|
|
35
|
+
/**
|
|
36
|
+
* Return the cache entry for the provided key.
|
|
37
|
+
*/
|
|
38
|
+
get<K = any, T = any>(key: string): Readonly<NgHttpCachingEntry<K, T>> | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Return true if the cache entry exists the provided key.
|
|
41
|
+
*/
|
|
42
|
+
has(key: string): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Set the cache entry for the provided key.
|
|
45
|
+
*/
|
|
46
|
+
set<K = any, T = any>(key: string, value: NgHttpCachingEntry<K, T>): void;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
type NgHttpCachingContext = Pick<NgHttpCachingConfig, 'getKey' | 'isCacheable' | 'isExpired' | 'isValid'>;
|
|
50
|
+
declare const NG_HTTP_CACHING_CONTEXT: HttpContextToken<NgHttpCachingContext>;
|
|
51
|
+
declare const withNgHttpCachingContext: (value: NgHttpCachingContext, context?: HttpContext) => HttpContext;
|
|
52
|
+
declare const checkCacheHeaders: (headers: HttpHeaders) => boolean;
|
|
53
|
+
interface NgHttpCachingEntry<K = any, T = any> {
|
|
54
|
+
/**
|
|
55
|
+
* URL
|
|
56
|
+
*/
|
|
57
|
+
url: string;
|
|
58
|
+
/**
|
|
59
|
+
* HttpResponse
|
|
60
|
+
*/
|
|
61
|
+
response: HttpResponse<T>;
|
|
62
|
+
/**
|
|
63
|
+
* HttpRequest
|
|
64
|
+
*/
|
|
65
|
+
request: HttpRequest<K>;
|
|
66
|
+
/**
|
|
67
|
+
* Timestamp of add to cache time
|
|
68
|
+
*/
|
|
69
|
+
addedTime: number;
|
|
70
|
+
/**
|
|
71
|
+
* Cache version
|
|
72
|
+
*/
|
|
73
|
+
version: string;
|
|
74
|
+
}
|
|
75
|
+
declare const NG_HTTP_CACHING_CONFIG: InjectionToken<NgHttpCachingContext>;
|
|
76
|
+
declare enum NgHttpCachingStrategy {
|
|
77
|
+
/**
|
|
78
|
+
* All request are cacheable if HTTP method is into `allowedMethod`
|
|
79
|
+
*/
|
|
80
|
+
ALLOW_ALL = "ALLOW_ALL",
|
|
81
|
+
/**
|
|
82
|
+
* Only the request with `X-NG-HTTP-CACHING-ALLOW-CACHE` header are cacheable if HTTP method is into `allowedMethod`
|
|
83
|
+
*/
|
|
84
|
+
DISALLOW_ALL = "DISALLOW_ALL"
|
|
85
|
+
}
|
|
86
|
+
declare enum NgHttpCachingHeaders {
|
|
87
|
+
/**
|
|
88
|
+
* Request is cacheable if HTTP method is into `allowedMethod`
|
|
89
|
+
*/
|
|
90
|
+
ALLOW_CACHE = "X-NG-HTTP-CACHING-ALLOW-CACHE",
|
|
91
|
+
/**
|
|
92
|
+
* Request isn't cacheable
|
|
93
|
+
*/
|
|
94
|
+
DISALLOW_CACHE = "X-NG-HTTP-CACHING-DISALLOW-CACHE",
|
|
95
|
+
/**
|
|
96
|
+
* Specific cache lifetime for the request
|
|
97
|
+
*/
|
|
98
|
+
LIFETIME = "X-NG-HTTP-CACHING-LIFETIME",
|
|
99
|
+
/**
|
|
100
|
+
* You can tag multiple request by adding this header with the same tag and
|
|
101
|
+
* using `NgHttpCachingService.clearCacheByTag(tag: string)` for delete all the tagged request
|
|
102
|
+
*/
|
|
103
|
+
TAG = "X-NG-HTTP-CACHING-TAG"
|
|
104
|
+
}
|
|
105
|
+
declare const NgHttpCachingHeadersList: NgHttpCachingHeaders[];
|
|
106
|
+
declare const NG_HTTP_CACHING_SECOND_IN_MS = 1000;
|
|
107
|
+
declare const NG_HTTP_CACHING_MINUTE_IN_MS: number;
|
|
108
|
+
declare const NG_HTTP_CACHING_HOUR_IN_MS: number;
|
|
109
|
+
declare const NG_HTTP_CACHING_DAY_IN_MS: number;
|
|
110
|
+
declare const NG_HTTP_CACHING_WEEK_IN_MS: number;
|
|
111
|
+
declare const NG_HTTP_CACHING_MONTH_IN_MS: number;
|
|
112
|
+
declare const NG_HTTP_CACHING_YEAR_IN_MS: number;
|
|
113
|
+
interface NgHttpCachingConfig {
|
|
114
|
+
/**
|
|
115
|
+
* Set the cache store. You can implement your custom store by implement the `NgHttpCachingStorageInterface` interface, eg.:
|
|
116
|
+
*/
|
|
117
|
+
store?: NgHttpCachingStorageInterface;
|
|
118
|
+
/**
|
|
119
|
+
* Number of millisecond that a response is stored in the cache.
|
|
120
|
+
* You can set specific "lifetime" for each request by add the header `X-NG-HTTP-CACHING-LIFETIME` (see example below).
|
|
121
|
+
*/
|
|
122
|
+
lifetime?: number;
|
|
123
|
+
/**
|
|
124
|
+
* Array of allowed HTTP methods to cache.
|
|
125
|
+
* You can allow multiple methods, eg.: `['GET', 'POST', 'PUT', 'DELETE', 'HEAD']` or
|
|
126
|
+
* allow all methods by: `['ALL']`. If `allowedMethod` is an empty array (`[]`), no response are cached.
|
|
127
|
+
* *Warning!* `NgHttpCaching` use the full url (url with query parameters) as unique key for the cached response,
|
|
128
|
+
* this is correct for the `GET` request but is _potentially_ wrong for other type of request (eg. `POST`, `PUT`).
|
|
129
|
+
* You can set a different "key" by customizing the `getKey` config method (see `getKey` section).
|
|
130
|
+
*/
|
|
131
|
+
allowedMethod?: string[];
|
|
132
|
+
/**
|
|
133
|
+
* Set the cache strategy, possible strategies are:
|
|
134
|
+
* - `NgHttpCachingStrategy.ALLOW_ALL`: All request are cacheable if HTTP method is into `allowedMethod`;
|
|
135
|
+
* - `NgHttpCachingStrategy.DISALLOW_ALL`: Only the request with `X-NG-HTTP-CACHING-ALLOW-CACHE` header are cacheable if HTTP method is into `allowedMethod`;
|
|
136
|
+
*/
|
|
137
|
+
cacheStrategy?: NgHttpCachingStrategy;
|
|
138
|
+
/**
|
|
139
|
+
* Cache version. When you have a breaking change, change the version, and it'll delete the current cache automatically.
|
|
140
|
+
* The default value is Angular major version (eg. 13), in this way, the cache is invalidated on every Angular upgrade.
|
|
141
|
+
*/
|
|
142
|
+
version?: string;
|
|
143
|
+
/**
|
|
144
|
+
* If true response headers cache-control and expires are respected.
|
|
145
|
+
*/
|
|
146
|
+
checkResponseHeaders?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* If this function return `true` the request is expired and a new request is send to backend, if return `false` isn't expired.
|
|
149
|
+
* If the result is `undefined`, the normal behaviour is provided.
|
|
150
|
+
*/
|
|
151
|
+
isExpired?: <K, T>(entry: NgHttpCachingEntry<K, T>) => boolean | undefined | void;
|
|
152
|
+
/**
|
|
153
|
+
* If this function return `true` the request is cacheable, if return `false` isn't cacheable.
|
|
154
|
+
* If the result is `undefined`, the normal behaviour is provided.
|
|
155
|
+
*/
|
|
156
|
+
isCacheable?: <K>(req: HttpRequest<K>) => boolean | undefined | void;
|
|
157
|
+
/**
|
|
158
|
+
* This function return the unique key (`string`) for store the response into the cache.
|
|
159
|
+
* If the result is `undefined`, the normal behaviour is provided.
|
|
160
|
+
*/
|
|
161
|
+
getKey?: <K>(req: HttpRequest<K>) => string | undefined | void;
|
|
162
|
+
/**
|
|
163
|
+
* If this function return `true` the cache entry is valid and can be stored, if return `false` isn't valid.
|
|
164
|
+
* If the result is `undefined`, the normal behaviour is provided.
|
|
165
|
+
*/
|
|
166
|
+
isValid?: <K, T>(entry: NgHttpCachingEntry<K, T>) => boolean | undefined | void;
|
|
167
|
+
}
|
|
168
|
+
interface NgHttpCachingDefaultConfig extends NgHttpCachingConfig {
|
|
169
|
+
store: NgHttpCachingStorageInterface;
|
|
170
|
+
lifetime: number;
|
|
171
|
+
allowedMethod: string[];
|
|
172
|
+
cacheStrategy: NgHttpCachingStrategy;
|
|
173
|
+
version: string;
|
|
174
|
+
checkResponseHeaders: boolean;
|
|
175
|
+
}
|
|
176
|
+
declare const NgHttpCachingConfigDefault: Readonly<NgHttpCachingDefaultConfig>;
|
|
177
|
+
declare class NgHttpCachingService {
|
|
178
|
+
private readonly queue;
|
|
179
|
+
private readonly config;
|
|
180
|
+
private gcLock;
|
|
181
|
+
private devMode;
|
|
182
|
+
constructor();
|
|
183
|
+
/**
|
|
184
|
+
* Return the config
|
|
185
|
+
*/
|
|
186
|
+
getConfig(): Readonly<NgHttpCachingConfig>;
|
|
187
|
+
/**
|
|
188
|
+
* Return the queue map
|
|
189
|
+
*/
|
|
190
|
+
getQueue(): Readonly<Map<string, Observable$1<HttpEvent<any>>>>;
|
|
191
|
+
/**
|
|
192
|
+
* Return the cache store
|
|
193
|
+
*/
|
|
194
|
+
getStore(): Readonly<NgHttpCachingStorageInterface>;
|
|
195
|
+
/**
|
|
196
|
+
* Return response from cache
|
|
197
|
+
*/
|
|
198
|
+
getFromCache<K, T>(req: HttpRequest<K>): Readonly<HttpResponse<T>> | undefined;
|
|
199
|
+
/**
|
|
200
|
+
* Add response to cache
|
|
201
|
+
*/
|
|
202
|
+
addToCache<K, T>(req: HttpRequest<K>, res: HttpResponse<T>): boolean;
|
|
203
|
+
/**
|
|
204
|
+
* Delete response from cache
|
|
205
|
+
*/
|
|
206
|
+
deleteFromCache<K>(req: HttpRequest<K>): boolean;
|
|
207
|
+
/**
|
|
208
|
+
* Clear the cache
|
|
209
|
+
*/
|
|
210
|
+
clearCache(): void;
|
|
211
|
+
/**
|
|
212
|
+
* Clear the cache by key
|
|
213
|
+
*/
|
|
214
|
+
clearCacheByKey(key: string): boolean;
|
|
215
|
+
/**
|
|
216
|
+
* Clear the cache by keys
|
|
217
|
+
*/
|
|
218
|
+
clearCacheByKeys(keys: Array<string>): number;
|
|
219
|
+
/**
|
|
220
|
+
* Clear the cache by regex
|
|
221
|
+
*/
|
|
222
|
+
clearCacheByRegex<K, T>(regex: RegExp): number;
|
|
223
|
+
/**
|
|
224
|
+
* Clear the cache by TAG
|
|
225
|
+
*/
|
|
226
|
+
clearCacheByTag<K, T>(tag: string): number;
|
|
227
|
+
/**
|
|
228
|
+
* Run garbage collector (delete expired cache entry)
|
|
229
|
+
*/
|
|
230
|
+
runGc<K, T>(): boolean;
|
|
231
|
+
/**
|
|
232
|
+
* Return true if cache entry is expired
|
|
233
|
+
*/
|
|
234
|
+
isExpired<K, T>(entry: NgHttpCachingEntry<K, T>): boolean;
|
|
235
|
+
/**
|
|
236
|
+
* Return true if cache entry is valid for store in the cache
|
|
237
|
+
* Default behaviour is whether the status code falls in the 2xx range and response headers cache-control and expires allow cache.
|
|
238
|
+
*/
|
|
239
|
+
isValid<K, T>(entry: NgHttpCachingEntry<K, T>): boolean;
|
|
240
|
+
/**
|
|
241
|
+
* Return true if the request is cacheable
|
|
242
|
+
*/
|
|
243
|
+
isCacheable<K>(req: HttpRequest<K>): boolean;
|
|
244
|
+
/**
|
|
245
|
+
* Return the cache key.
|
|
246
|
+
* Default key is http method plus url with query parameters, eg.:
|
|
247
|
+
* `GET@https://github.com/nigrosimone/ng-http-caching`
|
|
248
|
+
*/
|
|
249
|
+
getKey<K>(req: HttpRequest<K>): string;
|
|
250
|
+
/**
|
|
251
|
+
* Return observable from cache
|
|
252
|
+
*/
|
|
253
|
+
getFromQueue<K, T>(req: HttpRequest<K>): Observable$1<HttpEvent<T>> | undefined;
|
|
254
|
+
/**
|
|
255
|
+
* Add observable to cache
|
|
256
|
+
*/
|
|
257
|
+
addToQueue<K, T>(req: HttpRequest<K>, obs: Observable$1<HttpEvent<T>>): void;
|
|
258
|
+
/**
|
|
259
|
+
* Delete observable from cache
|
|
260
|
+
*/
|
|
261
|
+
deleteFromQueue<K>(req: HttpRequest<K>): boolean;
|
|
262
|
+
/**
|
|
263
|
+
* Recursively Object.freeze simple Javascript structures consisting of plain objects, arrays, and primitives.
|
|
264
|
+
* Make the data immutable.
|
|
265
|
+
* @returns immutable object
|
|
266
|
+
*/
|
|
267
|
+
private deepFreeze;
|
|
268
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NgHttpCachingService, never>;
|
|
269
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<NgHttpCachingService>;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
declare class NgHttpCachingModule {
|
|
273
|
+
static forRoot(ngHttpCachingConfig?: NgHttpCachingConfig): ModuleWithProviders<NgHttpCachingModule>;
|
|
274
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NgHttpCachingModule, never>;
|
|
275
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<NgHttpCachingModule, never, never, never>;
|
|
276
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<NgHttpCachingModule>;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
declare function provideNgHttpCaching(ngHttpCachingConfig?: NgHttpCachingConfig): i0.EnvironmentProviders;
|
|
280
|
+
|
|
281
|
+
declare class NgHttpCachingMemoryStorage extends Map<string, NgHttpCachingEntry<any, any>> implements NgHttpCachingStorageInterface {
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
interface NgHttpCachingStorageEntry {
|
|
285
|
+
url: string;
|
|
286
|
+
response: string;
|
|
287
|
+
request: string;
|
|
288
|
+
addedTime: number;
|
|
289
|
+
version: string;
|
|
290
|
+
}
|
|
291
|
+
declare const serializeRequest: (req: HttpRequest<any>) => string;
|
|
292
|
+
declare const serializeResponse: (res: HttpResponse<any>) => string;
|
|
293
|
+
declare const deserializeRequest: <T = any>(req: string) => HttpRequest<T>;
|
|
294
|
+
declare const deserializeResponse: <T = any>(res: string) => HttpResponse<T>;
|
|
295
|
+
declare class NgHttpCachingBrowserStorage implements NgHttpCachingStorageInterface {
|
|
296
|
+
private storage;
|
|
297
|
+
constructor(storage: Storage);
|
|
298
|
+
get size(): number;
|
|
299
|
+
clear(): void;
|
|
300
|
+
delete(key: string): boolean;
|
|
301
|
+
forEach(callbackfn: (value: NgHttpCachingEntry, key: string) => void): void;
|
|
302
|
+
get(key: string): Readonly<NgHttpCachingEntry> | undefined;
|
|
303
|
+
has(key: string): boolean;
|
|
304
|
+
set(key: string, value: NgHttpCachingEntry): void;
|
|
305
|
+
protected serialize(value: NgHttpCachingEntry): NgHttpCachingStorageEntry;
|
|
306
|
+
protected deserialize(value: NgHttpCachingStorageEntry): NgHttpCachingEntry;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
declare class NgHttpCachingLocalStorage extends NgHttpCachingBrowserStorage {
|
|
310
|
+
constructor();
|
|
311
|
+
}
|
|
312
|
+
declare const withNgHttpCachingLocalStorage: () => NgHttpCachingLocalStorage;
|
|
313
|
+
|
|
314
|
+
declare class NgHttpCachingSessionStorage extends NgHttpCachingBrowserStorage {
|
|
315
|
+
constructor();
|
|
316
|
+
}
|
|
317
|
+
declare const withNgHttpCachingSessionStorage: () => NgHttpCachingSessionStorage;
|
|
318
|
+
|
|
319
|
+
export { NG_HTTP_CACHING_CONFIG, NG_HTTP_CACHING_CONTEXT, NG_HTTP_CACHING_DAY_IN_MS, NG_HTTP_CACHING_HOUR_IN_MS, NG_HTTP_CACHING_MINUTE_IN_MS, NG_HTTP_CACHING_MONTH_IN_MS, NG_HTTP_CACHING_SECOND_IN_MS, NG_HTTP_CACHING_WEEK_IN_MS, NG_HTTP_CACHING_YEAR_IN_MS, NgHttpCachingBrowserStorage, NgHttpCachingConfigDefault, NgHttpCachingHeaders, NgHttpCachingHeadersList, NgHttpCachingInterceptorService, NgHttpCachingLocalStorage, NgHttpCachingMemoryStorage, NgHttpCachingModule, NgHttpCachingService, NgHttpCachingSessionStorage, NgHttpCachingStrategy, checkCacheHeaders, deserializeRequest, deserializeResponse, provideNgHttpCaching, serializeRequest, serializeResponse, withNgHttpCachingContext, withNgHttpCachingLocalStorage, withNgHttpCachingSessionStorage };
|
|
320
|
+
export type { NgHttpCachingConfig, NgHttpCachingContext, NgHttpCachingDefaultConfig, NgHttpCachingEntry, NgHttpCachingStorageEntry, NgHttpCachingStorageInterface };
|
package/package.json
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import * as i0 from "@angular/core";
|
|
4
|
-
export declare class NgHttpCachingInterceptorService implements HttpInterceptor {
|
|
5
|
-
private readonly cacheService;
|
|
6
|
-
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>;
|
|
7
|
-
/**
|
|
8
|
-
* Send http request (next handler)
|
|
9
|
-
*/
|
|
10
|
-
sendRequest(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>;
|
|
11
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<NgHttpCachingInterceptorService, never>;
|
|
12
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<NgHttpCachingInterceptorService>;
|
|
13
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ModuleWithProviders } from '@angular/core';
|
|
2
|
-
import { NgHttpCachingConfig } from './ng-http-caching.service';
|
|
3
|
-
import * as i0 from "@angular/core";
|
|
4
|
-
export declare class NgHttpCachingModule {
|
|
5
|
-
static forRoot(ngHttpCachingConfig?: NgHttpCachingConfig): ModuleWithProviders<NgHttpCachingModule>;
|
|
6
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<NgHttpCachingModule, never>;
|
|
7
|
-
static ɵmod: i0.ɵɵNgModuleDeclaration<NgHttpCachingModule, never, never, never>;
|
|
8
|
-
static ɵinj: i0.ɵɵInjectorDeclaration<NgHttpCachingModule>;
|
|
9
|
-
}
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import { InjectionToken } from '@angular/core';
|
|
2
|
-
import { HttpRequest, HttpResponse, HttpEvent, HttpContextToken, HttpContext, HttpHeaders } from '@angular/common/http';
|
|
3
|
-
import { Observable } from 'rxjs/internal/Observable';
|
|
4
|
-
import { NgHttpCachingStorageInterface } from './storage/ng-http-caching-storage.interface';
|
|
5
|
-
import * as i0 from "@angular/core";
|
|
6
|
-
export type NgHttpCachingContext = Pick<NgHttpCachingConfig, 'getKey' | 'isCacheable' | 'isExpired' | 'isValid'>;
|
|
7
|
-
export declare const NG_HTTP_CACHING_CONTEXT: HttpContextToken<NgHttpCachingContext>;
|
|
8
|
-
export declare const withNgHttpCachingContext: (value: NgHttpCachingContext, context?: HttpContext) => HttpContext;
|
|
9
|
-
export declare const checkCacheHeaders: (headers: HttpHeaders) => boolean;
|
|
10
|
-
export interface NgHttpCachingEntry<K = any, T = any> {
|
|
11
|
-
/**
|
|
12
|
-
* URL
|
|
13
|
-
*/
|
|
14
|
-
url: string;
|
|
15
|
-
/**
|
|
16
|
-
* HttpResponse
|
|
17
|
-
*/
|
|
18
|
-
response: HttpResponse<T>;
|
|
19
|
-
/**
|
|
20
|
-
* HttpRequest
|
|
21
|
-
*/
|
|
22
|
-
request: HttpRequest<K>;
|
|
23
|
-
/**
|
|
24
|
-
* Timestamp of add to cache time
|
|
25
|
-
*/
|
|
26
|
-
addedTime: number;
|
|
27
|
-
/**
|
|
28
|
-
* Cache version
|
|
29
|
-
*/
|
|
30
|
-
version: string;
|
|
31
|
-
}
|
|
32
|
-
export declare const NG_HTTP_CACHING_CONFIG: InjectionToken<NgHttpCachingContext>;
|
|
33
|
-
export declare enum NgHttpCachingStrategy {
|
|
34
|
-
/**
|
|
35
|
-
* All request are cacheable if HTTP method is into `allowedMethod`
|
|
36
|
-
*/
|
|
37
|
-
ALLOW_ALL = "ALLOW_ALL",
|
|
38
|
-
/**
|
|
39
|
-
* Only the request with `X-NG-HTTP-CACHING-ALLOW-CACHE` header are cacheable if HTTP method is into `allowedMethod`
|
|
40
|
-
*/
|
|
41
|
-
DISALLOW_ALL = "DISALLOW_ALL"
|
|
42
|
-
}
|
|
43
|
-
export declare enum NgHttpCachingHeaders {
|
|
44
|
-
/**
|
|
45
|
-
* Request is cacheable if HTTP method is into `allowedMethod`
|
|
46
|
-
*/
|
|
47
|
-
ALLOW_CACHE = "X-NG-HTTP-CACHING-ALLOW-CACHE",
|
|
48
|
-
/**
|
|
49
|
-
* Request isn't cacheable
|
|
50
|
-
*/
|
|
51
|
-
DISALLOW_CACHE = "X-NG-HTTP-CACHING-DISALLOW-CACHE",
|
|
52
|
-
/**
|
|
53
|
-
* Specific cache lifetime for the request
|
|
54
|
-
*/
|
|
55
|
-
LIFETIME = "X-NG-HTTP-CACHING-LIFETIME",
|
|
56
|
-
/**
|
|
57
|
-
* You can tag multiple request by adding this header with the same tag and
|
|
58
|
-
* using `NgHttpCachingService.clearCacheByTag(tag: string)` for delete all the tagged request
|
|
59
|
-
*/
|
|
60
|
-
TAG = "X-NG-HTTP-CACHING-TAG"
|
|
61
|
-
}
|
|
62
|
-
export declare const NgHttpCachingHeadersList: NgHttpCachingHeaders[];
|
|
63
|
-
export declare const NG_HTTP_CACHING_SECOND_IN_MS = 1000;
|
|
64
|
-
export declare const NG_HTTP_CACHING_MINUTE_IN_MS: number;
|
|
65
|
-
export declare const NG_HTTP_CACHING_HOUR_IN_MS: number;
|
|
66
|
-
export declare const NG_HTTP_CACHING_DAY_IN_MS: number;
|
|
67
|
-
export declare const NG_HTTP_CACHING_WEEK_IN_MS: number;
|
|
68
|
-
export declare const NG_HTTP_CACHING_MONTH_IN_MS: number;
|
|
69
|
-
export declare const NG_HTTP_CACHING_YEAR_IN_MS: number;
|
|
70
|
-
export interface NgHttpCachingConfig {
|
|
71
|
-
/**
|
|
72
|
-
* Set the cache store. You can implement your custom store by implement the `NgHttpCachingStorageInterface` interface, eg.:
|
|
73
|
-
*/
|
|
74
|
-
store?: NgHttpCachingStorageInterface;
|
|
75
|
-
/**
|
|
76
|
-
* Number of millisecond that a response is stored in the cache.
|
|
77
|
-
* You can set specific "lifetime" for each request by add the header `X-NG-HTTP-CACHING-LIFETIME` (see example below).
|
|
78
|
-
*/
|
|
79
|
-
lifetime?: number;
|
|
80
|
-
/**
|
|
81
|
-
* Array of allowed HTTP methods to cache.
|
|
82
|
-
* You can allow multiple methods, eg.: `['GET', 'POST', 'PUT', 'DELETE', 'HEAD']` or
|
|
83
|
-
* allow all methods by: `['ALL']`. If `allowedMethod` is an empty array (`[]`), no response are cached.
|
|
84
|
-
* *Warning!* `NgHttpCaching` use the full url (url with query parameters) as unique key for the cached response,
|
|
85
|
-
* this is correct for the `GET` request but is _potentially_ wrong for other type of request (eg. `POST`, `PUT`).
|
|
86
|
-
* You can set a different "key" by customizing the `getKey` config method (see `getKey` section).
|
|
87
|
-
*/
|
|
88
|
-
allowedMethod?: string[];
|
|
89
|
-
/**
|
|
90
|
-
* Set the cache strategy, possible strategies are:
|
|
91
|
-
* - `NgHttpCachingStrategy.ALLOW_ALL`: All request are cacheable if HTTP method is into `allowedMethod`;
|
|
92
|
-
* - `NgHttpCachingStrategy.DISALLOW_ALL`: Only the request with `X-NG-HTTP-CACHING-ALLOW-CACHE` header are cacheable if HTTP method is into `allowedMethod`;
|
|
93
|
-
*/
|
|
94
|
-
cacheStrategy?: NgHttpCachingStrategy;
|
|
95
|
-
/**
|
|
96
|
-
* Cache version. When you have a breaking change, change the version, and it'll delete the current cache automatically.
|
|
97
|
-
* The default value is Angular major version (eg. 13), in this way, the cache is invalidated on every Angular upgrade.
|
|
98
|
-
*/
|
|
99
|
-
version?: string;
|
|
100
|
-
/**
|
|
101
|
-
* If true response headers cache-control and expires are respected.
|
|
102
|
-
*/
|
|
103
|
-
checkResponseHeaders?: boolean;
|
|
104
|
-
/**
|
|
105
|
-
* If this function return `true` the request is expired and a new request is send to backend, if return `false` isn't expired.
|
|
106
|
-
* If the result is `undefined`, the normal behaviour is provided.
|
|
107
|
-
*/
|
|
108
|
-
isExpired?: <K, T>(entry: NgHttpCachingEntry<K, T>) => boolean | undefined | void;
|
|
109
|
-
/**
|
|
110
|
-
* If this function return `true` the request is cacheable, if return `false` isn't cacheable.
|
|
111
|
-
* If the result is `undefined`, the normal behaviour is provided.
|
|
112
|
-
*/
|
|
113
|
-
isCacheable?: <K>(req: HttpRequest<K>) => boolean | undefined | void;
|
|
114
|
-
/**
|
|
115
|
-
* This function return the unique key (`string`) for store the response into the cache.
|
|
116
|
-
* If the result is `undefined`, the normal behaviour is provided.
|
|
117
|
-
*/
|
|
118
|
-
getKey?: <K>(req: HttpRequest<K>) => string | undefined | void;
|
|
119
|
-
/**
|
|
120
|
-
* If this function return `true` the cache entry is valid and can be stored, if return `false` isn't valid.
|
|
121
|
-
* If the result is `undefined`, the normal behaviour is provided.
|
|
122
|
-
*/
|
|
123
|
-
isValid?: <K, T>(entry: NgHttpCachingEntry<K, T>) => boolean | undefined | void;
|
|
124
|
-
}
|
|
125
|
-
export interface NgHttpCachingDefaultConfig extends NgHttpCachingConfig {
|
|
126
|
-
store: NgHttpCachingStorageInterface;
|
|
127
|
-
lifetime: number;
|
|
128
|
-
allowedMethod: string[];
|
|
129
|
-
cacheStrategy: NgHttpCachingStrategy;
|
|
130
|
-
version: string;
|
|
131
|
-
checkResponseHeaders: boolean;
|
|
132
|
-
}
|
|
133
|
-
export declare const NgHttpCachingConfigDefault: Readonly<NgHttpCachingDefaultConfig>;
|
|
134
|
-
export declare class NgHttpCachingService {
|
|
135
|
-
private readonly queue;
|
|
136
|
-
private readonly config;
|
|
137
|
-
private gcLock;
|
|
138
|
-
private devMode;
|
|
139
|
-
constructor();
|
|
140
|
-
/**
|
|
141
|
-
* Return the config
|
|
142
|
-
*/
|
|
143
|
-
getConfig(): Readonly<NgHttpCachingConfig>;
|
|
144
|
-
/**
|
|
145
|
-
* Return the queue map
|
|
146
|
-
*/
|
|
147
|
-
getQueue(): Readonly<Map<string, Observable<HttpEvent<any>>>>;
|
|
148
|
-
/**
|
|
149
|
-
* Return the cache store
|
|
150
|
-
*/
|
|
151
|
-
getStore(): Readonly<NgHttpCachingStorageInterface>;
|
|
152
|
-
/**
|
|
153
|
-
* Return response from cache
|
|
154
|
-
*/
|
|
155
|
-
getFromCache<K, T>(req: HttpRequest<K>): Readonly<HttpResponse<T>> | undefined;
|
|
156
|
-
/**
|
|
157
|
-
* Add response to cache
|
|
158
|
-
*/
|
|
159
|
-
addToCache<K, T>(req: HttpRequest<K>, res: HttpResponse<T>): boolean;
|
|
160
|
-
/**
|
|
161
|
-
* Delete response from cache
|
|
162
|
-
*/
|
|
163
|
-
deleteFromCache<K>(req: HttpRequest<K>): boolean;
|
|
164
|
-
/**
|
|
165
|
-
* Clear the cache
|
|
166
|
-
*/
|
|
167
|
-
clearCache(): void;
|
|
168
|
-
/**
|
|
169
|
-
* Clear the cache by key
|
|
170
|
-
*/
|
|
171
|
-
clearCacheByKey(key: string): boolean;
|
|
172
|
-
/**
|
|
173
|
-
* Clear the cache by keys
|
|
174
|
-
*/
|
|
175
|
-
clearCacheByKeys(keys: Array<string>): number;
|
|
176
|
-
/**
|
|
177
|
-
* Clear the cache by regex
|
|
178
|
-
*/
|
|
179
|
-
clearCacheByRegex<K, T>(regex: RegExp): number;
|
|
180
|
-
/**
|
|
181
|
-
* Clear the cache by TAG
|
|
182
|
-
*/
|
|
183
|
-
clearCacheByTag<K, T>(tag: string): number;
|
|
184
|
-
/**
|
|
185
|
-
* Run garbage collector (delete expired cache entry)
|
|
186
|
-
*/
|
|
187
|
-
runGc<K, T>(): boolean;
|
|
188
|
-
/**
|
|
189
|
-
* Return true if cache entry is expired
|
|
190
|
-
*/
|
|
191
|
-
isExpired<K, T>(entry: NgHttpCachingEntry<K, T>): boolean;
|
|
192
|
-
/**
|
|
193
|
-
* Return true if cache entry is valid for store in the cache
|
|
194
|
-
* Default behaviour is whether the status code falls in the 2xx range and response headers cache-control and expires allow cache.
|
|
195
|
-
*/
|
|
196
|
-
isValid<K, T>(entry: NgHttpCachingEntry<K, T>): boolean;
|
|
197
|
-
/**
|
|
198
|
-
* Return true if the request is cacheable
|
|
199
|
-
*/
|
|
200
|
-
isCacheable<K>(req: HttpRequest<K>): boolean;
|
|
201
|
-
/**
|
|
202
|
-
* Return the cache key.
|
|
203
|
-
* Default key is http method plus url with query parameters, eg.:
|
|
204
|
-
* `GET@https://github.com/nigrosimone/ng-http-caching`
|
|
205
|
-
*/
|
|
206
|
-
getKey<K>(req: HttpRequest<K>): string;
|
|
207
|
-
/**
|
|
208
|
-
* Return observable from cache
|
|
209
|
-
*/
|
|
210
|
-
getFromQueue<K, T>(req: HttpRequest<K>): Observable<HttpEvent<T>> | undefined;
|
|
211
|
-
/**
|
|
212
|
-
* Add observable to cache
|
|
213
|
-
*/
|
|
214
|
-
addToQueue<K, T>(req: HttpRequest<K>, obs: Observable<HttpEvent<T>>): void;
|
|
215
|
-
/**
|
|
216
|
-
* Delete observable from cache
|
|
217
|
-
*/
|
|
218
|
-
deleteFromQueue<K>(req: HttpRequest<K>): boolean;
|
|
219
|
-
/**
|
|
220
|
-
* Recursively Object.freeze simple Javascript structures consisting of plain objects, arrays, and primitives.
|
|
221
|
-
* Make the data immutable.
|
|
222
|
-
* @returns immutable object
|
|
223
|
-
*/
|
|
224
|
-
private deepFreeze;
|
|
225
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<NgHttpCachingService, never>;
|
|
226
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<NgHttpCachingService>;
|
|
227
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { NgHttpCachingStorageInterface } from './ng-http-caching-storage.interface';
|
|
2
|
-
import { NgHttpCachingEntry } from '../ng-http-caching.service';
|
|
3
|
-
import { HttpRequest, HttpResponse } from '@angular/common/http';
|
|
4
|
-
export interface NgHttpCachingStorageEntry {
|
|
5
|
-
url: string;
|
|
6
|
-
response: string;
|
|
7
|
-
request: string;
|
|
8
|
-
addedTime: number;
|
|
9
|
-
version: string;
|
|
10
|
-
}
|
|
11
|
-
export declare const serializeRequest: (req: HttpRequest<any>) => string;
|
|
12
|
-
export declare const serializeResponse: (res: HttpResponse<any>) => string;
|
|
13
|
-
export declare const deserializeRequest: <T = any>(req: string) => HttpRequest<T>;
|
|
14
|
-
export declare const deserializeResponse: <T = any>(res: string) => HttpResponse<T>;
|
|
15
|
-
export declare class NgHttpCachingBrowserStorage implements NgHttpCachingStorageInterface {
|
|
16
|
-
private storage;
|
|
17
|
-
constructor(storage: Storage);
|
|
18
|
-
get size(): number;
|
|
19
|
-
clear(): void;
|
|
20
|
-
delete(key: string): boolean;
|
|
21
|
-
forEach(callbackfn: (value: NgHttpCachingEntry, key: string) => void): void;
|
|
22
|
-
get(key: string): Readonly<NgHttpCachingEntry> | undefined;
|
|
23
|
-
has(key: string): boolean;
|
|
24
|
-
set(key: string, value: NgHttpCachingEntry): void;
|
|
25
|
-
protected serialize(value: NgHttpCachingEntry): NgHttpCachingStorageEntry;
|
|
26
|
-
protected deserialize(value: NgHttpCachingStorageEntry): NgHttpCachingEntry;
|
|
27
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { NgHttpCachingBrowserStorage } from './ng-http-caching-browser-storage';
|
|
2
|
-
export declare class NgHttpCachingLocalStorage extends NgHttpCachingBrowserStorage {
|
|
3
|
-
constructor();
|
|
4
|
-
}
|
|
5
|
-
export declare const withNgHttpCachingLocalStorage: () => NgHttpCachingLocalStorage;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { NgHttpCachingStorageInterface } from './ng-http-caching-storage.interface';
|
|
2
|
-
import { NgHttpCachingEntry } from '../ng-http-caching.service';
|
|
3
|
-
export declare class NgHttpCachingMemoryStorage extends Map<string, NgHttpCachingEntry<any, any>> implements NgHttpCachingStorageInterface {
|
|
4
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { NgHttpCachingBrowserStorage } from './ng-http-caching-browser-storage';
|
|
2
|
-
export declare class NgHttpCachingSessionStorage extends NgHttpCachingBrowserStorage {
|
|
3
|
-
constructor();
|
|
4
|
-
}
|
|
5
|
-
export declare const withNgHttpCachingSessionStorage: () => NgHttpCachingSessionStorage;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { NgHttpCachingEntry } from '../ng-http-caching.service';
|
|
2
|
-
export interface NgHttpCachingStorageInterface {
|
|
3
|
-
/**
|
|
4
|
-
* The number of cached entries.
|
|
5
|
-
*/
|
|
6
|
-
readonly size: number;
|
|
7
|
-
/**
|
|
8
|
-
* Clear the cache.
|
|
9
|
-
*/
|
|
10
|
-
clear(): void;
|
|
11
|
-
/**
|
|
12
|
-
* Delete the cache entry for the provided key.
|
|
13
|
-
*/
|
|
14
|
-
delete(key: string): boolean;
|
|
15
|
-
/**
|
|
16
|
-
* The forEach() method executes a provided function once for each cache entry.
|
|
17
|
-
*/
|
|
18
|
-
forEach<K = any, T = any>(callbackfn: (value: NgHttpCachingEntry<K, T>, key: string) => void): void;
|
|
19
|
-
/**
|
|
20
|
-
* Return the cache entry for the provided key.
|
|
21
|
-
*/
|
|
22
|
-
get<K = any, T = any>(key: string): Readonly<NgHttpCachingEntry<K, T>> | undefined;
|
|
23
|
-
/**
|
|
24
|
-
* Return true if the cache entry exists the provided key.
|
|
25
|
-
*/
|
|
26
|
-
has(key: string): boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Set the cache entry for the provided key.
|
|
29
|
-
*/
|
|
30
|
-
set<K = any, T = any>(key: string, value: NgHttpCachingEntry<K, T>): void;
|
|
31
|
-
}
|
package/public-api.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from './lib/ng-http-caching-interceptor.service';
|
|
2
|
-
export * from './lib/ng-http-caching.service';
|
|
3
|
-
export * from './lib/ng-http-caching.module';
|
|
4
|
-
export * from './lib/ng-http-caching-provider';
|
|
5
|
-
export * from './lib/storage/ng-http-caching-storage.interface';
|
|
6
|
-
export * from './lib/storage/ng-http-caching-memory-storage';
|
|
7
|
-
export * from './lib/storage/ng-http-caching-local-storage';
|
|
8
|
-
export * from './lib/storage/ng-http-caching-session-storage';
|
|
9
|
-
export * from './lib/storage/ng-http-caching-browser-storage';
|