import { createAction } from '@reduxjs/toolkit'; /* * Tier 2 offline support contract. RTK Query can seed its cache from a * persisted snapshot via `extractRehydrationInfo` (see `api/index.ts`). We use * a single action whose payload is the previously-saved api slice state; the * api reducer pulls `queries`/`mutations` out of it on startup so last-seen * library data renders read-only while the backend is unreachable. * * The type string lives here (not in the store) so `api/index.ts` can match it * without importing from the store layer (which would create a cycle). */ export const REHYDRATE_API = 'api/rehydrate'; export interface RehydrateApiPayload { queries: Record; mutations: Record; // RTKQ's invalidation slice reads `provided.tags`/`provided.keys` during // rehydration (it does `Object.entries(provided.tags ?? {})`), so `provided` // must be an object — a bare `{ queries, mutations }` makes it crash on // `provided.tags` of undefined. Always present; empty objects are valid. provided: { tags: Record; keys: Record }; } export const rehydrateApi = createAction(REHYDRATE_API);