@bobfrankston/mailx-store 0.1.20 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/db.d.ts +1 -0
- package/db.js +23 -4
- package/package.json +1 -1
package/db.d.ts
CHANGED
|
@@ -83,6 +83,7 @@ export declare class MailxDB {
|
|
|
83
83
|
recurringEventId?: string;
|
|
84
84
|
htmlLink?: string;
|
|
85
85
|
isHoliday?: boolean;
|
|
86
|
+
reminderMinutes?: number[];
|
|
86
87
|
}): string;
|
|
87
88
|
getCalendarEvents(accountId: string, fromMs: number, toMs: number): any[];
|
|
88
89
|
/** Lookup by uuid only — used by patch/delete paths that don't have an
|
package/db.js
CHANGED
|
@@ -411,6 +411,15 @@ export class MailxDB {
|
|
|
411
411
|
// calendar_events table; the flag distinguishes them so the UI can
|
|
412
412
|
// style them differently and the alarm scheduler can skip them.
|
|
413
413
|
this.addColumnIfMissing("calendar_events", "is_holiday", "INTEGER NOT NULL DEFAULT 0");
|
|
414
|
+
// Per-event reminder offsets (Bob 2026-05-12: "use the reminder
|
|
415
|
+
// times in the event (there can be multiple)"). Google's API
|
|
416
|
+
// returns `reminders.overrides` as an array of {method, minutes}
|
|
417
|
+
// — we store the minute offsets as JSON so alarms.ts can fire ONE
|
|
418
|
+
// popup per offset (10-min, 30-min, 1-day, …) instead of the
|
|
419
|
+
// hard-coded 10-min default. `useDefault: true` events get the
|
|
420
|
+
// calendar's defaultReminders pre-resolved server-side and pulled
|
|
421
|
+
// through here too.
|
|
422
|
+
this.addColumnIfMissing("calendar_events", "reminder_minutes_json", "TEXT DEFAULT '[]'");
|
|
414
423
|
// Backfill UUIDs for any pre-existing rows that were inserted before
|
|
415
424
|
// this column landed. One UPDATE + an id roundtrip per row — cheap
|
|
416
425
|
// at our row counts, runs once per DB upgrade.
|
|
@@ -733,12 +742,13 @@ export class MailxDB {
|
|
|
733
742
|
// ── Calendar events (two-way cache) ──
|
|
734
743
|
upsertCalendarEvent(ev) {
|
|
735
744
|
const uuid = ev.uuid || randomUUID().replace(/-/g, "");
|
|
745
|
+
const remindersJson = JSON.stringify(Array.isArray(ev.reminderMinutes) ? ev.reminderMinutes : []);
|
|
736
746
|
this.db.prepare(`
|
|
737
747
|
INSERT INTO calendar_events
|
|
738
748
|
(uuid, account_id, provider_id, calendar_id, title, start_ms, end_ms,
|
|
739
749
|
all_day, location, notes, etag, last_synced, dirty, deleted, updated_at,
|
|
740
|
-
recurring_event_id, html_link, is_holiday)
|
|
741
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?, ?, ?, ?)
|
|
750
|
+
recurring_event_id, html_link, is_holiday, reminder_minutes_json)
|
|
751
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?, ?, ?, ?, ?)
|
|
742
752
|
ON CONFLICT(uuid) DO UPDATE SET
|
|
743
753
|
account_id=excluded.account_id, provider_id=excluded.provider_id,
|
|
744
754
|
calendar_id=excluded.calendar_id, title=excluded.title,
|
|
@@ -749,8 +759,9 @@ export class MailxDB {
|
|
|
749
759
|
updated_at=excluded.updated_at,
|
|
750
760
|
recurring_event_id=excluded.recurring_event_id,
|
|
751
761
|
html_link=excluded.html_link,
|
|
752
|
-
is_holiday=excluded.is_holiday
|
|
753
|
-
|
|
762
|
+
is_holiday=excluded.is_holiday,
|
|
763
|
+
reminder_minutes_json=excluded.reminder_minutes_json
|
|
764
|
+
`).run(uuid, ev.accountId, ev.providerId || null, ev.calendarId || "primary", ev.title, ev.startMs, ev.endMs, ev.allDay ? 1 : 0, ev.location || "", ev.notes || "", ev.etag || null, ev.dirty ? 0 : Date.now(), ev.dirty ? 1 : 0, Date.now(), ev.recurringEventId || null, ev.htmlLink || null, ev.isHoliday ? 1 : 0, remindersJson);
|
|
754
765
|
return uuid;
|
|
755
766
|
}
|
|
756
767
|
getCalendarEvents(accountId, fromMs, toMs) {
|
|
@@ -778,7 +789,15 @@ export class MailxDB {
|
|
|
778
789
|
return rows.map(this.calendarRowToObject);
|
|
779
790
|
}
|
|
780
791
|
calendarRowToObject(r) {
|
|
792
|
+
let reminderMinutes = [];
|
|
793
|
+
try {
|
|
794
|
+
const parsed = JSON.parse(r.reminder_minutes_json || "[]");
|
|
795
|
+
if (Array.isArray(parsed))
|
|
796
|
+
reminderMinutes = parsed.filter((n) => Number.isFinite(n)).map((n) => Number(n));
|
|
797
|
+
}
|
|
798
|
+
catch { /* invalid JSON → empty */ }
|
|
781
799
|
return {
|
|
800
|
+
reminderMinutes,
|
|
782
801
|
uuid: r.uuid, accountId: r.account_id, providerId: r.provider_id,
|
|
783
802
|
calendarId: r.calendar_id, title: r.title, startMs: r.start_ms,
|
|
784
803
|
endMs: r.end_ms, allDay: !!r.all_day, location: r.location, notes: r.notes,
|