import type { PostgresJsDatabase } from "drizzle-orm/postgres-js"; import { type NotificationReminderRule, type NotificationReminderRuleStage, type NotificationReminderStageCadenceInterval, type NotificationReminderStageChannel, type NotificationSettings } from "./schema.js"; export { computeAnchorDateEnvelope, fetchTargetsForRule, } from "./service-sequence-targets.js"; export type ReminderTargetSnapshot = { id: string; bookingId: string | null; dueDate: string | null; issuedAt: string | null; departureDate: string | null; bookingCreatedAt: string | null; status: string; isTerminal: boolean; }; export type SequenceHistoryEntry = { scheduledFor: Date; sentAt: Date | null; status: string; }; export type StageDecision = { fire: false; reason: string; stage?: NotificationReminderRuleStage; } | { fire: true; stage: NotificationReminderRuleStage; anchorDate: Date; sendCountAtFire: number; }; export declare const DEFAULT_NOTIFICATION_SETTINGS: NotificationSettings; export declare function getNotificationSettings(db: PostgresJsDatabase, scope?: string): Promise; export declare function listStagesForRule(db: PostgresJsDatabase, reminderRuleId: string): Promise; export declare function listChannelsForStage(db: PostgresJsDatabase, stageId: string): Promise; export declare function pickActiveStage(stages: NotificationReminderRuleStage[], attemptsSoFar: number): NotificationReminderRuleStage | null; export declare function inWindow(today: Date, anchorDate: Date, stage: NotificationReminderRuleStage): boolean; export declare function pickEscalatingInterval(intervals: NotificationReminderStageCadenceInterval[] | null | undefined, daysUntilDue: number | null): NotificationReminderStageCadenceInterval | null; export declare function cadenceElapsed(today: Date, lastSentAt: Date | null, stage: NotificationReminderRuleStage, daysUntilDue: number | null): boolean; export declare function resolveAnchor(anchor: NotificationReminderRuleStage["anchor"], target: ReminderTargetSnapshot, history: SequenceHistoryEntry[]): Date | null; export declare function evaluateStage(_rule: NotificationReminderRule, stages: NotificationReminderRuleStage[], target: ReminderTargetSnapshot, history: SequenceHistoryEntry[], today: Date): StageDecision; export declare function applyQuietHours(now: Date, stage: NotificationReminderRuleStage, settings: NotificationSettings, recipientTimezone?: string | null): { scheduledAt: Date; deferred: boolean; }; export declare function exceedsRecipientRateLimit(db: PostgresJsDatabase, recipient: string, channel: string, settings: NotificationSettings, now: Date): Promise; export declare function suppressedByGroup(db: PostgresJsDatabase, recipient: string | null, suppressionGroup: string | null, settings: NotificationSettings, now: Date): Promise; export declare function loadHistory(db: PostgresJsDatabase, reminderRuleId: string, targetId: string): Promise; export declare function listActiveRulesByPriority(db: PostgresJsDatabase): Promise; export type PreviewRow = { ruleId: string; ruleName: string; ruleSlug: string; targetType: string; targetId: string; bookingId: string | null; stageId: string; stageName: string | null; stageOrderIndex: number; anchor: string; anchorDate: string; scheduledAt: string; sendCountAtFire: number; reasoning: string; }; export declare function previewReminders(db: PostgresJsDatabase, options?: { now?: Date; ruleId?: string; targetId?: string; }): Promise;