import { IncrementalCache } from '@opennextjs/aws/types/overrides';

/**
 * Cimplify incremental-cache override for Workers for Platforms storefronts.
 *
 * Replaces opennext's stale-while-revalidate model with an evict-on-invalidate
 * model that fits Cimplify's event-driven domain:
 *
 *   - `get`: standard R2 fetch. Returns the cached value or null.
 *   - `set`: writes to R2 AND emits a tag→cache_key index update to the shared
 *     `CIMPLIFY_PATH_INDEX` Durable Object (hosted in cimplify-tag-cache).
 *   - `delete`: standard R2 delete (called by opennext on explicit invalidate;
 *     also called by us from the Rust EvictionDispatcher path on tag events).
 *
 * The Rust EvictionDispatcher reads the index on bus events, deletes the
 * matching R2 entries directly, and prunes the index — there is no SWR
 * "background refresh" path. opennext's queue and `isStale` checks become
 * no-ops; cached entries are by definition fresh (existed at write time and
 * haven't been evicted), and absence means the next request synchronously
 * re-renders.
 *
 * Why this exists: WfP user workers cannot have `WORKER_SELF_REFERENCE`,
 * which is the binding every built-in opennext queue requires. Rather than
 * recreate SWR via self-fetch tricks, we drop SWR for our domain — Cimplify
 * always knows when data changes (every catalog mutation flows through the
 * bus), so timer-based refresh adds no value.
 */

declare const evictIncrementalCache: IncrementalCache;

export { evictIncrementalCache };
