Description
The SDK creates invoices with due dates but provides no mechanism to trigger reminder notifications at configurable intervals before the due date (e.g. 7 days, 1 day, 1 hour). Integrators implement ad-hoc setTimeout calls that break on process restarts. A due-date reminder scheduler should persist reminder schedules and fire callbacks reliably, including recovering missed reminders after a restart.
Technical Context
Add src/invoiceReminderScheduler.ts. Extends src/scheduler.ts. Persists scheduled reminders in src/snapshot.ts keyed by invoiceId. Reads InvoiceRecord.dueAt from src/types.ts. Adds ReminderSchedule and ReminderEvent to src/types.ts. Emits invoiceReminderDue via src/events.ts. On startup, loads persisted schedules and fires any that are past-due within a configurable grace period.
Acceptance Criteria
Description
The SDK creates invoices with due dates but provides no mechanism to trigger reminder notifications at configurable intervals before the due date (e.g. 7 days, 1 day, 1 hour). Integrators implement ad-hoc
setTimeoutcalls that break on process restarts. A due-date reminder scheduler should persist reminder schedules and fire callbacks reliably, including recovering missed reminders after a restart.Technical Context
Add
src/invoiceReminderScheduler.ts. Extendssrc/scheduler.ts. Persists scheduled reminders insrc/snapshot.tskeyed byinvoiceId. ReadsInvoiceRecord.dueAtfromsrc/types.ts. AddsReminderScheduleandReminderEventtosrc/types.ts. EmitsinvoiceReminderDueviasrc/events.ts. On startup, loads persisted schedules and fires any that are past-due within a configurable grace period.Acceptance Criteria
InvoiceReminderScheduler.schedule(invoiceId, offsets: number[])registers reminders at eachoffsetms before the invoice due datesrc/snapshot.tsso reminders survive process restartsgracePeriodMs(default 60 000 ms)invoiceReminderDuewith{ invoiceId, offsetMs, dueAt }for each triggered reminderInvoiceReminderScheduler.cancel(invoiceId)removes all pending reminders for an invoice from the store