/** Messaging channel for normalized delivery events. */ export type DeliveryChannel = "email" | "sms" | "whatsapp" | "push"; /** * Cross-channel delivery / lifecycle event for ingest pipelines. * Email webhooks still return {@link EmailEvent}; map with {@link toDeliveryEvent}. */ export interface DeliveryEvent { /** Channel this event belongs to. */ channel: DeliveryChannel; /** Provider identifier (e.g. `"twilio-sms"`, `"whatsapp-cloud"`). */ provider: string; /** Normalized lifecycle type. */ type: "queued" | "sent" | "delivered" | "failed" | "read" | "bounced" | "complained" | "opened" | "clicked" | "deferred" | "unknown"; /** Provider message identifier when available. */ messageId?: string; /** Recipient address or phone when available. */ recipient?: string; /** Event timestamp when available. */ timestamp?: Date; /** Original provider payload for debugging or custom handling. */ raw: unknown; } /** Normalized email lifecycle event from any provider webhook. */ export interface EmailEvent { /** Provider identifier (e.g. `"resend"`, `"sendgrid"`). */ provider: string; /** Normalized event type. */ type: "delivered" | "bounced" | "complained" | "opened" | "clicked" | "deferred" | "unknown"; /** Provider message identifier when available. */ messageId?: string; /** Recipient email address when available. */ recipient?: string; /** Event timestamp when available. */ timestamp?: Date; /** Original provider payload for debugging or custom handling. */ raw: unknown; } /** Map an {@link EmailEvent} into the shared {@link DeliveryEvent} shape. */ export declare function toDeliveryEvent(event: EmailEvent): DeliveryEvent; /** Build a {@link DeliveryEvent} respecting exact optional property types. */ export declare function deliveryEvent(input: { channel: DeliveryChannel; provider: string; type: DeliveryEvent["type"]; raw: unknown; messageId?: string | undefined; recipient?: string | undefined; timestamp?: Date | undefined; }): DeliveryEvent; /** Map a provider-specific event string to a normalized event type. */ export type EventTypeMapper = (event: string) => EmailEvent["type"] | DeliveryEvent["type"]; /** Default mapper — returns `"unknown"` for unrecognized events. */ export declare function mapEventType(event: string, mapping: Record): T | "unknown"; /** Parse an ISO or Unix timestamp into a Date, or undefined when invalid. */ export declare function parseTimestamp(value: unknown): Date | undefined; /** Ensure payload is an array (for providers that batch events). */ export declare function asArray(payload: unknown): unknown[]; /** Build an {@link EmailEvent} respecting exact optional property types. */ export declare function emailEvent(input: { provider: string; type: EmailEvent["type"]; raw: unknown; messageId?: string | undefined; recipient?: string | undefined; timestamp?: Date | undefined; }): EmailEvent;