@haex-space/vault-sdk 3.5.0 → 3.6.0

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.
@@ -34,6 +34,10 @@ var SHELL_EVENTS = {
34
34
  /** Shell session has exited */
35
35
  EXIT: "shell:exit"
36
36
  };
37
+ var MAIL_EVENTS = {
38
+ /** A watched mailbox's UID high-water mark advanced — new mail arrived. */
39
+ NEW_MESSAGES: "mail:new-messages"
40
+ };
37
41
 
38
42
  // src/types.ts
39
43
  var DEFAULT_TIMEOUT = 3e4;
@@ -306,7 +310,11 @@ var MAIL_COMMANDS = {
306
310
  /** SMTP send. Returns the assigned Message-ID. */
307
311
  sendMessage: "extension_mail_send_message",
308
312
  /** Build RFC822 bytes without sending (for Drafts via APPEND) */
309
- buildRfc822: "extension_mail_build_rfc822"
313
+ buildRfc822: "extension_mail_build_rfc822",
314
+ /** Start (or replace) a background poll watch for an account/mailbox */
315
+ startWatch: "extension_mail_start_watch",
316
+ /** Stop a background poll watch */
317
+ stopWatch: "extension_mail_stop_watch"
310
318
  };
311
319
 
312
320
  // src/commands/notifications.ts
@@ -1429,6 +1437,41 @@ var MailAPI = class {
1429
1437
  message
1430
1438
  });
1431
1439
  }
1440
+ /**
1441
+ * Start (or replace) a background poll watch for `accountId`/`mailboxName`.
1442
+ * The host resolves credentials itself from `accountId` — no `ImapConfig`
1443
+ * is passed in. Requires `mail` permission with action `poll` on the
1444
+ * account's IMAP host (prompted on first call, same as `fetch`/`send`).
1445
+ *
1446
+ * `intervalSeconds` is clamped host-side to [30, 3600]. Listen for
1447
+ * results via `onNewMessages`.
1448
+ */
1449
+ async startWatchingAsync(accountId, mailboxName, intervalSeconds) {
1450
+ return this.client.request(MAIL_COMMANDS.startWatch, {
1451
+ accountId,
1452
+ mailboxName,
1453
+ intervalSeconds
1454
+ });
1455
+ }
1456
+ /** Stop a background poll watch previously started with `startWatchingAsync`. */
1457
+ async stopWatchingAsync(accountId, mailboxName) {
1458
+ return this.client.request(MAIL_COMMANDS.stopWatch, {
1459
+ accountId,
1460
+ mailboxName
1461
+ });
1462
+ }
1463
+ /**
1464
+ * Register a callback for new-mail notifications from any active watch.
1465
+ * `event.data` is a `MailNewMessagesEvent` — check `accountId`/`mailboxName`
1466
+ * before refreshing if watching more than one account.
1467
+ */
1468
+ onNewMessages(callback) {
1469
+ this.client.on(MAIL_EVENTS.NEW_MESSAGES, callback);
1470
+ }
1471
+ /** Remove a new-mail callback registered with `onNewMessages`. */
1472
+ offNewMessages(callback) {
1473
+ this.client.off(MAIL_EVENTS.NEW_MESSAGES, callback);
1474
+ }
1432
1475
  };
1433
1476
 
1434
1477
  // src/api/notifications.ts
@@ -1722,6 +1765,7 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
1722
1765
  EXTERNAL_EVENTS.REQUEST,
1723
1766
  EXTERNAL_EVENTS.ACTION_REQUEST,
1724
1767
  NOTIFICATION_EVENTS.CLICK,
1768
+ MAIL_EVENTS.NEW_MESSAGES,
1725
1769
  ...Object.values(LOCALSEND_EVENTS)
1726
1770
  ]) {
1727
1771
  await forwardEvent(listen, log, onEvent, listenOptions, eventName);