/** * Module-level request dedup, short-TTL in-memory cache, and * localStorage persistence for the widget data layer. * * Why this exists: SDK consumers naturally compose overlapping widgets * on a single page (HealthScore + CompanyValuation both call /analysis; * CompanyCard + FinancialsTable both call /financials). Without dedup * each widget fires its own fetch on mount, silently doubling the * customer's API quota usage. The cache layer collapses concurrent * calls to the same key into one network round-trip and reuses the * resolved value for a short window so a re-mount does not re-fetch. * * The localStorage layer (issue #260) extends that with cross-reload * persistence so a tab revisit or a full reload does not re-fire every * endpoint. Critically the layer lives at the API client, NOT inside * - the partner-demo SPA mounts widgets bare without a * provider, and the previous SWRConfig-based cache (PR #252) silently * never installed in that path. The module-level approach works for * both bare-mount and provider-wrapped consumers. * * Boundary: any future non-React consumer (vanilla-JS embed, Web * Component) gets the same dedup and persistence for free. There is no * telemetry attached - the cache is purely local. * * Cache key: callers pass an array of stable scalars (method name, * params, and the apiKey or a per-instance scope id). The key MUST * include the apiKey (or a scope id keyed off it) so two providers * mounted in the same tab with different keys never share a result - * see CLAUDE.md A07 (public-surface isolation). * * Errors do not poison the cache. A failed promise is dropped before * the rejection settles, so a subsequent caller fires a fresh request. * Errors also do NOT write to localStorage. */ /** * Run ``fetcher`` under the dedup cache. * * - In-memory: if a matching in-flight promise exists, every caller * awaits the same one (single network round-trip). * - localStorage: on a cold in-memory miss, check the persisted * envelope. If it is still within ``ttlMs``, return it without * hitting ``fetcher``. This is the path that survives a full * reload. * - On success, the resolved value is held in memory for ``ttlMs`` * and persisted to localStorage. * - On failure, the in-memory entry is dropped immediately; nothing * is written to localStorage, so the next caller retries instead * of getting the cached rejection. */ export declare function dedupedRequest(keyParts: ReadonlyArray, fetcher: () => Promise, ttlMs?: number): Promise; /** * Test-only escape hatch. Production code MUST NOT call this - it is * exported solely so the vitest suite can isolate cases that depend on * an empty cache. Mangling the export name (leading underscore) signals * the contract to any code review. */ export declare function __resetRequestCacheForTests(): void; /** * Test-only - clear every persisted envelope under the regna prefix. * Production code MUST NOT call this. Tests use it to isolate the * localStorage path between cases. */ export declare function __resetLocalStorageCacheForTests(): void; //# sourceMappingURL=request-cache.d.ts.map