import { M as Middleware } from "./types.d-CRs03TYV.js"; import { P as Provider } from "./provider.d-Dh32nRm9.js"; import { b as ChatPayload, E as EmailChannelPayload, I as InAppPayload, P as PushPayload, S as SmsPayload, W as WebhookPayload, C as ChannelType, c as Receipt } from "./types.d-C7l7qdMG.js"; /** * Maps each channel to its payload type. */ interface ChannelPayloadMap { chat: ChatPayload; email: EmailChannelPayload; inapp: InAppPayload; push: PushPayload; sms: SmsPayload; webhook: WebhookPayload; } /** * A multi-channel message: a payload per channel to deliver on. */ type NotificationMessage = { [K in ChannelType]?: ChannelPayloadMap[K]; }; /** * Providers registered per channel. */ type NotificationProviders = { [K in ChannelType]?: Provider; }; interface SendManyOptions { /** Maximum number of messages delivered concurrently (default 10). */ concurrency?: number; } /** * The high-level multi-channel notification facade. Holds a provider per channel, * a shared middleware chain and dispatches messages across channels. */ declare class Notification { #private; constructor(providers: NotificationProviders); /** * Registers a middleware. First registered runs outermost. * @param middleware The middleware to add. * @returns This instance for chaining. */ use(middleware: Middleware): this; /** * Sets a logger used by the facade. * @param logger The console-like logger. * @returns This instance for chaining. */ setLogger(logger: Console): this; /** * Returns the provider registered for a channel, if any. * @param channel The channel whose registered provider should be looked up. * @returns The provider or undefined. */ getProvider(channel: ChannelType): Provider | undefined; /** * Sends a payload on a single channel. * @param channel The target channel. * @param payload The channel-specific payload to deliver. * @returns A receipt describing the outcome. */ sendToChannel(channel: K, payload: ChannelPayloadMap[K]): Promise; /** * Sends a multi-channel message, delivering each present channel in parallel. * @param message The multi-channel message. * @returns One receipt per attempted channel. */ send(message: NotificationMessage): Promise; /** * Sends many messages with bounded concurrency, yielding the receipts for each. * @param messages The messages to send. * @param options Concurrency options. * @yields The receipts for each message, in completion order. */ sendMany(messages: Iterable, options?: SendManyOptions): AsyncGenerator; /** * Initializes every registered provider. */ initialize(): Promise; /** * Shuts down every registered provider that supports it. */ shutdown(): Promise; } /** * Creates a {@link Notification} facade from a map of channel providers. * @param providers Providers keyed by channel. * @returns A configured notification facade. */ declare const createNotification: (providers: NotificationProviders) => Notification; /** * One-shot send through a single provider — the quickest path for a single-channel * send without wiring a {@link Notification} facade. For multiple channels, * middleware, routing or reuse, use {@link createNotification}. * @param channel The channel to deliver on. * @param provider The provider to deliver through. * @param payload The channel-specific payload. * @returns The send {@link Receipt}. * @example * ```ts * import { send } from "@visulima/notification"; * import { twilioProvider } from "@visulima/notification/providers/twilio"; * * await send("sms", twilioProvider({ accountSid, authToken, from }), { to: "+15555550100", text: "Hi" }); * ``` */ declare const send: (channel: ChannelT, provider: Provider, payload: ChannelPayloadMap[ChannelT]) => Promise; export { ChannelPayloadMap as C, Notification as N, SendManyOptions as S, NotificationMessage as a, NotificationProviders as b, createNotification as c, send as s };