import { PiniaPlugin } from 'pinia'; /** Per-state persistence options (declared inside a store's `persist.fields`). */ export interface IPersistFieldOptions { /** * When true, the field is written through the httpOnly server endpoint * (`/api/cms-sdk/persist`) instead of directly on the client. During SSR the * plugin still writes it directly via `storage` (server-side setCookie). * Default false. */ httpOnly?: boolean; } /** Per-store persistence config (the `persist` option on a setup store). */ export interface IPersistConfig { /** Namespace prefix for this store's cookies. Each field → cookie `${key}.${field}`. */ key: string; /** Explicit field → options map. Mutually tolerant with `pick` (both may be used). */ fields?: Record; /** * Shorthand: list of field names to persist as non-httpOnly cookies. Equivalent * to `fields: { : {} }` for each. Compatible with the `pick` convention. */ pick?: string[]; } /** Key-value storage the persistence plugin reads from / writes to. */ export interface IPersistStorage { getItem(key: string): string | null; setItem(key: string, value: string, opts?: { httpOnly?: boolean; }): void; removeItem(key: string, opts?: { httpOnly?: boolean; }): void; } export interface ICreatePersistPluginOptions { storage: IPersistStorage; /** * Persist endpoint used for client-side httpOnly writes. If unset, httpOnly * client writes are skipped (e.g. standalone usage without a server). */ httpEndpoint?: string; /** True during SSR — the plugin writes cookies directly via `storage`. */ ssr?: boolean; /** Debounce window for writes on the client (ms). Default 150. */ debounceMs?: number; } /** * Internal, dependency-free Pinia persistence plugin. Cookie-based, per-state, * with an optional `httpOnly` flag per state. * * - `httpOnly: false` (default) → written directly on the client (document.cookie). * - `httpOnly: true` → on the client, POSTed to `httpEndpoint` so the server * sets the httpOnly cookie; during SSR, written directly via `storage`. * * Only the states declared in `persist.fields` are persisted (never the whole * store, never credentials). */ export declare function createPersistPlugin(options: ICreatePersistPluginOptions): PiniaPlugin; //# sourceMappingURL=persist.d.ts.map