import type { NotificationRecord } from '../../server/adapters/types.js'; import { type CsrfClientOptions } from '../csrf.js'; export interface NotificationStoreConfig { apiPath?: string; /** * CSRF cookie/header names. Only needed when the server overrides the * defaults via `config.csrf`. Omit to use the package defaults. */ csrf?: CsrfClientOptions; /** * Custom fetch implementation for all API calls. Defaults to the global * `fetch`. Useful for mock backends in demos/tests or custom retry layers — * the same injection point every component exposes. */ fetcher?: typeof globalThis.fetch; } /** * Wire-contract failure of the most recent store operation. Localize like the * components do: `errorMessageFromCode(lastError.code, t, lastError.error)`. * `code: 'network_error'` is client-synthesized (the request never reached * the server). */ export interface NotificationStoreError { error?: string; code?: string; } /** * Runes store backing ``/``: loads, * marks read and deletes the session user's notifications. Its four routes — * `GET {apiPath}`, `POST {apiPath}/[id]/read`, `POST {apiPath}/read-all`, * `DELETE {apiPath}/[id]` — are served by `createNotificationsHandlers` * from `@urbicon-ui/auth/server` (mount its `list`/`read`/`readAll`/`item` * groups under `apiPath`, default `/api/notifications`). * * Every operation returns `false` and records `lastError` when it fails — * an unauthenticated `load` no longer masquerades as an empty inbox, and a * failed mark/delete no longer no-ops silently. A successful * operation clears `lastError`. */ export declare function createNotificationStore(config?: NotificationStoreConfig): { readonly notifications: NotificationRecord[]; readonly loading: boolean; readonly unreadCount: number; readonly lastError: NotificationStoreError | null; load: (options?: { limit?: number; unreadOnly?: boolean; }) => Promise; markAsRead: (id: string) => Promise; markAllAsRead: () => Promise; add: (notification: NotificationRecord) => void; delete: (id: string) => Promise; };