import { type MonitoringLogger } from './logging'; export declare const MAX_CACHE_SIZE = 500; interface OnErrorArgs { error: unknown; invalidate: () => void; } type PromiseFunction = () => Promise; interface CachedPromiseOptions { cacheKey?: string; defaultValue?: T; invalidate?: boolean; onError?: (args: OnErrorArgs) => Promise; } export declare function setLogger(override: MonitoringLogger): void; /** * This utility function will safely handle concurrent requests for the same resource by caching the promise. * Caches the result of a promise based on the name of the promise function or cacheKey. If a cached promise exists for the given key, * it returns the cached promise. Otherwise, it executes the promise function and caches the result. * It also provides options for handling errors, including returning a defaultValue value or invoking a custom error handler. * If neither defaultValue nor onError is provided, errors will propagate as usual. * * @template T - The type of the resolved promise value * @param promise - Function that returns the promise to be cached * @param options - Options object for error behaviors * @param options.cacheKey - Optional cache key to use as key instead of the function name * @param options.defaultValue - Optional default value to return if the promise rejects * @param options.invalidate - Optionally invalidates the cache for the given function name or cacheKey * @param options.onError - Optional error handler that receives the error and an invalidate function * @returns A promise that resolves to the cached or newly computed value */ export declare function getCachedPromise(promise: PromiseFunction, options?: CachedPromiseOptions): Promise; export declare function invalidateCache(): void; export {};