import { ChannelGate } from "../routing/index.js"; import { C as ChannelType } from "../packem_shared/types.d-C7l7qdMG.js"; import "../packem_shared/notification.d-D0ado_cy.js"; import "../packem_shared/types.d-CRs03TYV.js"; import "../packem_shared/provider.d-Dh32nRm9.js"; /** * A subscriber's channel preferences. A channel set to `false` is opted out; channels * absent default to allowed. */ interface SubscriberPreferences { channels: Partial>; } interface IsAllowedOptions { /** Critical notifications bypass opt-outs (e.g. security alerts). */ critical?: boolean; } /** * Stores per-subscriber channel preferences and answers allow/deny questions. */ interface PreferenceStore { get: (subscriberId: string) => Promise | SubscriberPreferences; isAllowed: (subscriberId: string, channel: ChannelType, options?: IsAllowedOptions) => Promise | boolean; set: (subscriberId: string, preferences: SubscriberPreferences) => Promise | void; } /** * In-memory {@link PreferenceStore}. */ declare class MemoryPreferenceStore implements PreferenceStore { #private; get(subscriberId: string): SubscriberPreferences; set(subscriberId: string, preferences: SubscriberPreferences): void; isAllowed(subscriberId: string, channel: ChannelType, options?: IsAllowedOptions): boolean; } /** * Builds a {@link ChannelGate} for `route(...)` from a preference store. The subscriber id * is resolved from each payload (default: the payload's `to` field, stringified). * @param store The preference store. * @param options Resolution options. * @param options.critical When true the produced gate treats every send as critical, bypassing opt-outs. * @param options.subscriberId Resolver mapping a payload to its subscriber id (defaults to the `to` field). * @returns A gate suitable for `route(notification, message, { gate })`. */ declare const preferencesGate: (store: PreferenceStore, options?: { critical?: boolean; subscriberId?: (payload: { to?: unknown; }) => string | undefined; }) => ChannelGate; export { IsAllowedOptions, MemoryPreferenceStore, PreferenceStore, SubscriberPreferences, preferencesGate };