import { P as Provider } from "../../packem_shared/provider.d-Dh32nRm9.js"; import { I as InAppPayload } from "../../packem_shared/types.d-C7l7qdMG.js"; import { S as Storage } from "../../packem_shared/unstorage.DqlWKU2I.d-CogP3Etw.js"; /** * A persisted in-app notification. */ interface StoredNotification { actions?: { label: string; url?: string; }[]; body: string; createdAt: number; data?: Record; id: string; read: boolean; subscriberId: string; title?: string; } interface ListOptions { /** Max items to return. */ limit?: number; /** Only return unread items. */ unreadOnly?: boolean; } /** * Backing store for the in-app channel. The default {@link MemoryInAppStore} is * in-process; back it with a persistent store for production feeds. */ interface InAppStore { add: (notification: Omit & { id?: string; }) => Promise; list: (subscriberId: string, options?: ListOptions) => Promise; markAllRead: (subscriberId: string) => Promise; markRead: (id: string) => Promise; remove: (id: string) => Promise; unreadCount: (subscriberId: string) => Promise; } /** * In-memory {@link InAppStore}. */ declare class MemoryInAppStore implements InAppStore { #private; add(notification: Omit & { id?: string; }): Promise; list(subscriberId: string, options?: ListOptions): Promise; markRead(id: string): Promise; markAllRead(subscriberId: string): Promise; unreadCount(subscriberId: string): Promise; remove(id: string): Promise; } interface InAppProviderConfig { /** Provider id reported on results (default `"inapp"`). */ id?: string; /** Backing store (default a new {@link MemoryInAppStore}). */ store?: InAppStore; } /** * In-app channel provider. Persists notifications to an {@link InAppStore} for a feed/inbox * UI to query. Expose the store via `getInstance()` to read/markRead. * @param config Provider `id` and the backing {@link InAppStore} (defaults to in-memory). * @returns A provider that writes notifications into the configured store. */ declare const inAppProvider$1: (config?: InAppProviderConfig) => Provider; /** * An {@link InAppStore} backed by an [unstorage](https://unstorage.unjs.io) driver, giving durable, * multi-backend persistence (Redis, filesystem, Cloudflare KV, ...). `unstorage` is an optional peer * dependency — pass a configured `Storage` instance. * * Each notification is stored under `prefix:item:id`, and a per-subscriber index list is kept under * `prefix:index:subscriberId` so `list`/`unreadCount`/`markAllRead` avoid scanning every key. * * The per-subscriber index is eventually-consistent: the item and index keys are written * non-atomically, so a concurrent reader may briefly observe one without the other. * * Edge-safe: works on Cloudflare KV (and other edge runtimes) via the matching unstorage driver. */ declare class UnstorageInAppStore implements InAppStore { #private; constructor(storage: Storage, prefix?: string); add(notification: Omit & { id?: string; }): Promise; list(subscriberId: string, options?: ListOptions): Promise; markRead(id: string): Promise; markAllRead(subscriberId: string): Promise; unreadCount(subscriberId: string): Promise; remove(id: string): Promise; } /** * Convenience factory for {@link UnstorageInAppStore}. * @param storage A configured unstorage `Storage` instance (optional peer). * @param prefix Key prefix under which notifications are stored. * @returns A new {@link UnstorageInAppStore}. */ declare const createUnstorageInAppStore: (storage: Storage, prefix?: string) => UnstorageInAppStore; /** @deprecated Renamed to `createInAppProvider`; removed in the next major. */ declare const inAppProvider: typeof inAppProvider$1; export { type InAppProviderConfig, type InAppStore, type ListOptions, MemoryInAppStore, type StoredNotification, UnstorageInAppStore, inAppProvider$1 as createInAppProvider, createUnstorageInAppStore, inAppProvider };