import * as i0 from '@angular/core'; import { InjectionToken } from '@angular/core'; import { SdPersistenceSerializer, SdPersistenceIdentityCanonicalizer } from '@sdcorejs/angular/services/persistence'; import { Observable } from 'rxjs'; interface SdCacheOption { type?: 'memory' | 'session' | 'local'; hours?: number; ttlMs?: number; default?: T; args?: Readonly>; namespace?: string; version?: string | number; serializer?: SdPersistenceSerializer; identityCanonicalizer?: SdPersistenceIdentityCanonicalizer; } interface SdCache { get: () => T | undefined; snapshot: () => SdCacheSnapshot; set: (data: T) => void; has: () => boolean; remove: () => void; /** Releases only this facade while preserving its backing cache entry. */ release: () => void; destroy: () => void; observer: Observable; load: (callback: () => Promise) => Promise; } type SdCacheSnapshot = { present: false; } | { present: true; value: T; }; interface SdCacheWithDefault extends Omit, 'get' | 'observer'> { get: () => T; observer: Observable; } interface SdCacheStoredValue { data: T; createdOn: Date; } type SdCacheSetCallback = (key: string, value: SdCacheStoredValue, option?: SdCacheOption) => Promise | void; type SdCacheGetCallback = (key: string, option?: SdCacheOption) => Promise | undefined>; type SdCacheRemoveCallback = (key: string, option?: SdCacheOption) => Promise | void; interface ISdCacheConfiguration { convertKey?: (key: string) => string; namespace?: string; version?: string | number; serializer?: SdPersistenceSerializer; identityCanonicalizer?: SdPersistenceIdentityCanonicalizer; set?: SdCacheSetCallback; get?: SdCacheGetCallback; remove?: SdCacheRemoveCallback; } declare const SD_CACHE_CONFIG: InjectionToken; interface SdLegacyCacheCallbacks { matches: (key: string, option?: SdCacheOption) => boolean; isValue: (value: unknown) => value is T; set?: (key: string, value: SdCacheStoredValue, option?: SdCacheOption) => Promise | void; get?: (key: string, option?: SdCacheOption) => Promise | undefined>; remove?: (key: string, option?: SdCacheOption) => Promise | void; } /** @deprecated Prefer globally safe unknown callbacks on `ISdCacheConfiguration`. */ declare function adaptLegacySdCacheCallbacks(callbacks: SdLegacyCacheCallbacks): ISdCacheConfiguration; declare class SdCacheService { #private; constructor(); create(key: string | object, option: SdCacheOption & { default: T; }): SdCacheWithDefault; create(key: string | object, option?: SdCacheOption): SdCache; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } export { SD_CACHE_CONFIG, SdCacheService, adaptLegacySdCacheCallbacks }; export type { ISdCacheConfiguration, SdCache, SdCacheGetCallback, SdCacheOption, SdCacheRemoveCallback, SdCacheSetCallback, SdCacheSnapshot, SdCacheStoredValue, SdCacheWithDefault, SdLegacyCacheCallbacks };