import { CacheMetadata, Context } from './common'; export type GetFreshValueStartEvent = { name: 'getFreshValueStart'; }; export type GetFreshValueHookPendingEvent = { name: 'getFreshValueHookPending'; }; export type GetFreshValueSuccessEvent = { name: 'getFreshValueSuccess'; value: Value; }; export type GetFreshValueErrorEvent = { name: 'getFreshValueError'; error: unknown; }; export type GetFreshValueCacheFallbackEvent = { name: 'getFreshValueCacheFallback'; value: unknown; }; /** @deprecated this event will be removed in favour of `CheckFreshValueErrorObjEvent` */ export type CheckFreshValueErrorEvent = { name: 'checkFreshValueError'; reason: string; }; export type CheckFreshValueErrorObjEvent = { name: 'checkFreshValueErrorObj'; reason: unknown; }; export type WriteFreshValueSuccessEvent = { name: 'writeFreshValueSuccess'; metadata: CacheMetadata; /** * Value might not actually be written to cache in case getting fresh * value took longer then ttl */ written: boolean; migrated: boolean; }; export type WriteFreshValueErrorEvent = { name: 'writeFreshValueError'; error: unknown; }; export type GetCachedValueStartEvent = { name: 'getCachedValueStart'; }; export type GetCachedValueReadEvent = { name: 'getCachedValueRead'; entry: unknown; }; export type GetCachedValueEmptyEvent = { name: 'getCachedValueEmpty'; }; export type GetCachedValueOutdatedEvent = { name: 'getCachedValueOutdated'; value: unknown; metadata: CacheMetadata; }; export type GetCachedValueSuccessEvent = { name: 'getCachedValueSuccess'; value: Value; migrated: boolean; }; /** @deprecated this event will be removed in favour of `CheckCachedValueErrorObjEvent` */ export type CheckCachedValueErrorEvent = { name: 'checkCachedValueError'; reason: string; }; export type CheckCachedValueErrorObjEvent = { name: 'checkCachedValueErrorObj'; reason: unknown; }; export type GetCachedValueErrorEvent = { name: 'getCachedValueError'; error: unknown; }; export type RefreshValueStartEvent = { name: 'refreshValueStart'; }; export type RefreshValueSuccessEvent = { name: 'refreshValueSuccess'; value: Value; }; export type RefreshValueErrorEvent = { name: 'refreshValueError'; error: unknown; }; export type DoneEvent = { name: 'done'; value: Value; }; export type CacheEvent = GetFreshValueStartEvent | GetFreshValueHookPendingEvent | GetFreshValueSuccessEvent | GetFreshValueErrorEvent | GetFreshValueCacheFallbackEvent | CheckFreshValueErrorEvent | CheckFreshValueErrorObjEvent | WriteFreshValueSuccessEvent | WriteFreshValueErrorEvent | GetCachedValueStartEvent | GetCachedValueReadEvent | GetCachedValueEmptyEvent | GetCachedValueOutdatedEvent | GetCachedValueSuccessEvent | CheckCachedValueErrorEvent | CheckCachedValueErrorObjEvent | GetCachedValueErrorEvent | RefreshValueStartEvent | RefreshValueSuccessEvent | RefreshValueErrorEvent | DoneEvent; export type Reporter = (event: CacheEvent) => void; export type CreateReporter = (context: Omit, 'report'>) => Reporter; export type NoInfer = [T][T extends any ? 0 : never]; interface ReporterOpts { formatDuration?: (ms: number) => string; logger?: Pick; performance?: Pick; } export declare function verboseReporter({ formatDuration, logger, performance, }?: ReporterOpts): CreateReporter; export declare function mergeReporters(...reporters: (CreateReporter | null | undefined)[]): CreateReporter; export {};