@haex-space/vault-sdk 5.4.1 → 5.5.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.
package/dist/react.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { S as StorageAPI } from './client-HdPYJ_9t.mjs';
1
+ import { S as StorageAPI } from './client-BFDgj2tC.mjs';
2
2
  import { HaexVaultSdk } from './index.mjs';
3
3
  import * as drizzle_orm_sqlite_proxy from 'drizzle-orm/sqlite-proxy';
4
4
  import { HaexHubConfig, ExtensionInfo, ApplicationContext } from './index.mjs';
package/dist/react.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { S as StorageAPI } from './client-CgngeKPm.js';
1
+ import { S as StorageAPI } from './client-CtUpYUH7.js';
2
2
  import { HaexVaultSdk } from './index.js';
3
3
  import * as drizzle_orm_sqlite_proxy from 'drizzle-orm/sqlite-proxy';
4
4
  import { HaexHubConfig, ExtensionInfo, ApplicationContext } from './index.js';
package/dist/react.js CHANGED
@@ -854,6 +854,10 @@ var MAIL_COMMANDS = {
854
854
  search: "extension_mail_search",
855
855
  /** CREATE a mailbox (reports whether it was already there) */
856
856
  createMailbox: "extension_mail_create_mailbox",
857
+ /** DELETE a mailbox (never INBOX) */
858
+ deleteMailbox: "extension_mail_delete_mailbox",
859
+ /** RENAME a mailbox (never INBOX) */
860
+ renameMailbox: "extension_mail_rename_mailbox",
857
861
  /** Delete messages for good: `\Deleted` plus UID EXPUNGE of exactly those UIDs */
858
862
  deleteMessages: "extension_mail_delete_messages",
859
863
  /** Set or unset IMAP flags on a UID set */
@@ -2378,6 +2382,25 @@ var MailAPI = class {
2378
2382
  );
2379
2383
  return created;
2380
2384
  }
2385
+ /**
2386
+ * Delete a mailbox. `mailbox` is the IMAP-encoded name (modified UTF-7), like in every other
2387
+ * call. `INBOX` can be neither deleted nor renamed; the host refuses it. Whether the mailbox's
2388
+ * messages and child mailboxes go with it, and whether a missing mailbox is an error, is up to
2389
+ * the server. Needs the same `fetch` permission as the other IMAP calls.
2390
+ */
2391
+ async deleteMailboxAsync(imap, mailbox) {
2392
+ return this.client.request(MAIL_COMMANDS.deleteMailbox, { imap, mailbox });
2393
+ }
2394
+ /**
2395
+ * Rename a mailbox from `from` to `to`, both IMAP-encoded names (modified UTF-7). `to` may
2396
+ * contain the server's hierarchy delimiter to move the mailbox in the tree; `*` and `%` are not
2397
+ * allowed. `INBOX` can be neither deleted nor renamed; the host refuses it. Whether child
2398
+ * mailboxes follow and whether an existing `to` is an error is up to the server. Needs the same
2399
+ * `fetch` permission as the other IMAP calls.
2400
+ */
2401
+ async renameMailboxAsync(imap, from, to) {
2402
+ return this.client.request(MAIL_COMMANDS.renameMailbox, { imap, from, to });
2403
+ }
2381
2404
  /**
2382
2405
  * Delete messages for good: flags exactly these UIDs `\Deleted` and expunges exactly them, so
2383
2406
  * other messages marked `\Deleted` stay. Refused with an error on a server without UIDPLUS,
@@ -2663,6 +2686,7 @@ function validateInput(schema, value) {
2663
2686
  var PROTOCOL_VERSION = "2025-11-25";
2664
2687
  var METHOD_NOT_FOUND = -32601;
2665
2688
  var INVALID_PARAMS = -32602;
2689
+ var INTERNAL_ERROR = -32603;
2666
2690
  function textResult(text, isError) {
2667
2691
  return { content: [{ type: "text", text }], isError };
2668
2692
  }
@@ -2748,11 +2772,30 @@ var ToolsServer = class {
2748
2772
  }
2749
2773
  if (!controller.signal.aborted) this.reply(id, result);
2750
2774
  }
2775
+ /**
2776
+ * Answers `id`. An answer that cannot be sent gets an error instead, so the host never waits for
2777
+ * an answer that will not come.
2778
+ */
2751
2779
  reply(id, result) {
2752
- this.options.send({ jsonrpc: "2.0", id, result });
2780
+ try {
2781
+ this.send({ jsonrpc: "2.0", id, result });
2782
+ } catch (error) {
2783
+ const reason = error instanceof Error ? error.message : String(error);
2784
+ console.warn(`[vault-sdk] tools: answer ${String(id)} could not be sent: ${reason}`);
2785
+ this.error(id, INTERNAL_ERROR, `the answer could not be sent: ${reason}`);
2786
+ }
2753
2787
  }
2754
2788
  error(id, code, message) {
2755
- this.options.send({ jsonrpc: "2.0", id, error: { code, message } });
2789
+ this.send({ jsonrpc: "2.0", id, error: { code, message } });
2790
+ }
2791
+ /**
2792
+ * Sends a JSON copy. The manifest of a Nuxt extension comes from its runtime config, a Vue
2793
+ * reactive proxy, and `postMessage` cannot clone a proxy: the input schemas of `tools/list`
2794
+ * would throw a `DataCloneError` and the host would never get the list. JSON-RPC is JSON, so the
2795
+ * copy loses nothing.
2796
+ */
2797
+ send(message) {
2798
+ this.options.send(JSON.parse(JSON.stringify(message)));
2756
2799
  }
2757
2800
  };
2758
2801