apple-mail-mcp 2.11.2 → 2.12.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/build/index.js +50 -10
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -83838,6 +83838,10 @@ function imapMailStats(deps = {}) {
|
|
|
83838
83838
|
function errText(e) {
|
|
83839
83839
|
return e instanceof Error ? e.message : String(e);
|
|
83840
83840
|
}
|
|
83841
|
+
function assertMutated(result, what) {
|
|
83842
|
+
if (!result) throw new Error(`${what}: server rejected the command (IMAP NO/BAD)`);
|
|
83843
|
+
return result;
|
|
83844
|
+
}
|
|
83841
83845
|
var poolConnect = defaultConnect;
|
|
83842
83846
|
var pools = /* @__PURE__ */ new Map();
|
|
83843
83847
|
function poolKey(cfg) {
|
|
@@ -84176,7 +84180,10 @@ async function imapMoveMessageById(id, destMailbox, deps = {}) {
|
|
|
84176
84180
|
const destPath = dest.kind === "found" ? dest.path : resolveMailboxPath(destMailbox, "list");
|
|
84177
84181
|
const lock = await client.getMailboxLock(ref.path);
|
|
84178
84182
|
try {
|
|
84179
|
-
|
|
84183
|
+
assertMutated(
|
|
84184
|
+
await client.messageMove([ref.uid], destPath, { uid: true }),
|
|
84185
|
+
`IMAP move of UID ${ref.uid} to "${destPath}"`
|
|
84186
|
+
);
|
|
84180
84187
|
return { success: true, info: `Moved UID ${ref.uid} to "${destPath}" via IMAP.` };
|
|
84181
84188
|
} catch (e) {
|
|
84182
84189
|
return {
|
|
@@ -84188,9 +84195,12 @@ async function imapMoveMessageById(id, destMailbox, deps = {}) {
|
|
|
84188
84195
|
}
|
|
84189
84196
|
});
|
|
84190
84197
|
}
|
|
84198
|
+
var FALLBACK_TRASH_PATH = "Trash";
|
|
84191
84199
|
async function resolveTrashPath(client) {
|
|
84200
|
+
let listed = false;
|
|
84192
84201
|
try {
|
|
84193
84202
|
const boxes = await client.list();
|
|
84203
|
+
listed = true;
|
|
84194
84204
|
const special = boxes.find((b) => b.specialUse === "\\Trash");
|
|
84195
84205
|
if (special) return special.path;
|
|
84196
84206
|
const named = boxes.find(
|
|
@@ -84199,15 +84209,27 @@ async function resolveTrashPath(client) {
|
|
|
84199
84209
|
if (named) return named.path;
|
|
84200
84210
|
} catch {
|
|
84201
84211
|
}
|
|
84202
|
-
return resolveMailboxPath("trash", "list");
|
|
84212
|
+
if (!listed) return resolveMailboxPath("trash", "list");
|
|
84213
|
+
try {
|
|
84214
|
+
const created = await client.mailboxCreate(FALLBACK_TRASH_PATH);
|
|
84215
|
+
return created?.path || FALLBACK_TRASH_PATH;
|
|
84216
|
+
} catch {
|
|
84217
|
+
return FALLBACK_TRASH_PATH;
|
|
84218
|
+
}
|
|
84203
84219
|
}
|
|
84204
84220
|
async function trashUids(client, uids, srcPath) {
|
|
84205
84221
|
const dest = await resolveTrashPath(client);
|
|
84206
84222
|
if (srcPath.trim().toLowerCase() === dest.trim().toLowerCase()) {
|
|
84207
|
-
|
|
84223
|
+
assertMutated(
|
|
84224
|
+
await client.messageDelete(uids, { uid: true }),
|
|
84225
|
+
`IMAP expunge of ${uids.length} message(s) from "${srcPath}"`
|
|
84226
|
+
);
|
|
84208
84227
|
return { dest, expunged: true };
|
|
84209
84228
|
}
|
|
84210
|
-
|
|
84229
|
+
assertMutated(
|
|
84230
|
+
await client.messageMove(uids, dest, { uid: true }),
|
|
84231
|
+
`IMAP move of ${uids.length} message(s) from "${srcPath}" to "${dest}"`
|
|
84232
|
+
);
|
|
84211
84233
|
return { dest, expunged: false };
|
|
84212
84234
|
}
|
|
84213
84235
|
async function imapDeleteMessageById(id, deps = {}) {
|
|
@@ -84347,22 +84369,37 @@ async function imapBatch(ids, deps, op) {
|
|
|
84347
84369
|
return { success, failed, errors };
|
|
84348
84370
|
}
|
|
84349
84371
|
var imapBatchMarkRead = (ids, deps = {}) => imapBatch(ids, deps, async (c, uids) => {
|
|
84350
|
-
|
|
84372
|
+
assertMutated(
|
|
84373
|
+
await c.messageFlagsAdd(uids, ["\\Seen"], { uid: true }),
|
|
84374
|
+
`IMAP mark-read of ${uids.length} message(s)`
|
|
84375
|
+
);
|
|
84351
84376
|
});
|
|
84352
84377
|
var imapBatchMarkUnread = (ids, deps = {}) => imapBatch(ids, deps, async (c, uids) => {
|
|
84353
|
-
|
|
84378
|
+
assertMutated(
|
|
84379
|
+
await c.messageFlagsRemove(uids, ["\\Seen"], { uid: true }),
|
|
84380
|
+
`IMAP mark-unread of ${uids.length} message(s)`
|
|
84381
|
+
);
|
|
84354
84382
|
});
|
|
84355
84383
|
var imapBatchFlag = (ids, colorIndex, deps = {}) => imapBatch(ids, deps, async (c, uids) => {
|
|
84356
84384
|
if (colorIndex === void 0) {
|
|
84357
|
-
|
|
84385
|
+
assertMutated(
|
|
84386
|
+
await c.messageFlagsAdd(uids, ["\\Flagged"], { uid: true }),
|
|
84387
|
+
`IMAP flag of ${uids.length} message(s)`
|
|
84388
|
+
);
|
|
84358
84389
|
return;
|
|
84359
84390
|
}
|
|
84360
84391
|
const { set, clear } = mailFlagBitsFor(colorIndex);
|
|
84361
|
-
|
|
84392
|
+
assertMutated(
|
|
84393
|
+
await c.messageFlagsAdd(uids, ["\\Flagged", ...set], { uid: true }),
|
|
84394
|
+
`IMAP flag of ${uids.length} message(s)`
|
|
84395
|
+
);
|
|
84362
84396
|
if (clear.length) await c.messageFlagsRemove(uids, clear, { uid: true });
|
|
84363
84397
|
});
|
|
84364
84398
|
var imapBatchUnflag = (ids, deps = {}) => imapBatch(ids, deps, async (c, uids) => {
|
|
84365
|
-
|
|
84399
|
+
assertMutated(
|
|
84400
|
+
await c.messageFlagsRemove(uids, ["\\Flagged", ...MAIL_FLAG_BITS], { uid: true }),
|
|
84401
|
+
`IMAP unflag of ${uids.length} message(s)`
|
|
84402
|
+
);
|
|
84366
84403
|
});
|
|
84367
84404
|
var imapBatchDelete = (ids, deps = {}) => imapBatch(ids, deps, async (c, uids, path) => {
|
|
84368
84405
|
await trashUids(c, uids, path);
|
|
@@ -84370,7 +84407,10 @@ var imapBatchDelete = (ids, deps = {}) => imapBatch(ids, deps, async (c, uids, p
|
|
|
84370
84407
|
function imapBatchMove(ids, destMailbox, deps = {}) {
|
|
84371
84408
|
return imapBatch(ids, deps, async (c, uids) => {
|
|
84372
84409
|
const dest = await findMailboxPathOrThrow(c, destMailbox) ?? resolveMailboxPath(destMailbox, "list");
|
|
84373
|
-
|
|
84410
|
+
assertMutated(
|
|
84411
|
+
await c.messageMove(uids, dest, { uid: true }),
|
|
84412
|
+
`IMAP move of ${uids.length} message(s) to "${dest}"`
|
|
84413
|
+
);
|
|
84374
84414
|
});
|
|
84375
84415
|
}
|
|
84376
84416
|
function senderName(from) {
|
package/package.json
CHANGED