import type { PostgresJsDatabase } from "drizzle-orm/postgres-js"; import type { NotificationReminderRule, NotificationReminderRuleStage } from "./schema.js"; import type { ReminderTargetSnapshot } from "./service-sequence.js"; /** * Computes the date range a target's `due_date` (or `issue_date`) needs to * fall in for any of the rule's stages to be inside their eligibility window * today. * * From `inWindow`: today must satisfy * anchor + windowStartDays ≤ today ≤ anchor + windowEndDays * Solving for anchor: * today − windowEndDays ≤ anchor ≤ today − windowStartDays * * Across all stages with anchor=`due_date`, we union the [start, end] ranges * and use the resulting envelope as a SQL `BETWEEN` filter. Returns null when * no stage is anchored on the requested column (e.g. all stages anchor on * `departure_date`) — caller should skip the pushdown in that case. */ export declare function computeAnchorDateEnvelope(stages: NotificationReminderRuleStage[], today: Date, anchor: NotificationReminderRuleStage["anchor"]): { from: string; to: string; } | null; /** * Per-rule target fetch that pushes a date envelope into the WHERE when all * relevant stages share an anchor we can SQL-filter on (`due_date` for both * target types, `invoice_issued_at` for invoices). Other anchors fall through * to the unfiltered fetch — they're expected to be rare and the in-app * window check still rejects misses. */ export declare function fetchTargetsForRule(db: PostgresJsDatabase, rule: NotificationReminderRule, stages?: NotificationReminderRuleStage[], today?: Date): Promise;