@wirecat/mail-cli 0.5.0 → 0.7.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/CHANGELOG.md +149 -0
- package/README.md +48 -13
- package/dist/bin/mail.js +2 -2
- package/dist/bundle/{all-profiles-GR5JXYEQ.js → all-profiles-SI67TKZM.js} +9 -9
- package/dist/bundle/{anthropic-REBXE65F.js → anthropic-DALMLC3Y.js} +6 -6
- package/dist/bundle/{app-server-QJ7ICQXZ.js → app-server-XOH327Z2.js} +46 -46
- package/dist/bundle/{bun-WAX4QHW5.js → bun-ORL67CJ6.js} +2 -2
- package/dist/bundle/{bun-sqlite-5S7TQ4SG.js → bun-sqlite-DGXFNFHI.js} +5 -5
- package/dist/bundle/{chunk-ZD3WUGR2.js → chunk-23IEVVL2.js} +4 -4
- package/dist/bundle/{chunk-B5WSIWY5.js → chunk-2M4K7HYR.js} +17 -17
- package/dist/bundle/{chunk-IWDOGGMY.js → chunk-35KD2CI2.js} +501 -301
- package/dist/bundle/{chunk-7A7BHABA.js → chunk-3GZK5GTU.js} +1 -1
- package/dist/bundle/{chunk-JJBQPA7D.js → chunk-3TYEJRMZ.js} +4 -4
- package/dist/bundle/{chunk-M6BDHZON.js → chunk-45KA5667.js} +26 -13
- package/dist/bundle/{chunk-LOA4X6JW.js → chunk-4NYWHINR.js} +6 -6
- package/dist/bundle/{dist-KJOAJ6NF.js → chunk-4ULY3GDL.js} +16 -116
- package/dist/bundle/{chunk-2FXVBCA3.js → chunk-5BSEGMNE.js} +4 -4
- package/dist/bundle/{chunk-HCMUGUAG.js → chunk-5JEYIHS6.js} +3 -3
- package/dist/bundle/{chunk-QXOSGGKS.js → chunk-6LK7KTWB.js} +1 -1
- package/dist/bundle/{chunk-ESNNQA7D.js → chunk-6RMMAUUW.js} +28 -28
- package/dist/bundle/{chunk-VXAZZGXE.js → chunk-6XNPXAJU.js} +33 -27
- package/dist/bundle/{chunk-5INWLYBD.js → chunk-73OJJGZE.js} +14 -3
- package/dist/bundle/{chunk-4XJ4AM3K.js → chunk-7K6KJWTO.js} +12 -12
- package/dist/bundle/{chunk-KIDF77MA.js → chunk-AP7V256W.js} +1 -1
- package/dist/bundle/{chunk-4BMNP2FT.js → chunk-BEMLGWY4.js} +1 -1
- package/dist/bundle/{chunk-BFJV4FWJ.js → chunk-BGUMGCUY.js} +2 -2
- package/dist/bundle/{chunk-5BVIWP3S.js → chunk-BM445GYF.js} +2 -2
- package/dist/bundle/{chunk-F3NYA4KN.js → chunk-CAKBG5FC.js} +6 -6
- package/dist/bundle/{chunk-EB3R2PV3.js → chunk-DKQWTQVY.js} +23 -23
- package/dist/bundle/{chunk-6TY3DGCC.js → chunk-DXGMPMFP.js} +4 -4
- package/dist/bundle/{chunk-LFRHIXCF.js → chunk-E3DRM6YP.js} +3 -3
- package/dist/bundle/{chunk-FSUNGHRI.js → chunk-EYT33MM3.js} +47 -46
- package/dist/bundle/{chunk-DXDQOZ2P.js → chunk-FPOGVDLS.js} +2 -2
- package/dist/bundle/{chunk-S677WGOQ.js → chunk-FTFNWGIR.js} +8 -8
- package/dist/bundle/{chunk-TI6VBZKJ.js → chunk-FUB3X25H.js} +4 -4
- package/dist/bundle/{chunk-7JCRQX56.js → chunk-GJUUTUK4.js} +8 -8
- package/dist/bundle/{chunk-BLS5YG77.js → chunk-HFJNEXU7.js} +2 -2
- package/dist/bundle/{chunk-YKPBC3NL.js → chunk-HV3EIYX4.js} +1 -1
- package/dist/bundle/{chunk-EL554DV2.js → chunk-IYZHM3ZN.js} +3 -3
- package/dist/bundle/{chunk-6EO7GVYJ.js → chunk-JFMUI4H6.js} +1 -1
- package/dist/bundle/{chunk-2YQNBIDQ.js → chunk-LZ5J3UXD.js} +4 -4
- package/dist/bundle/{chunk-WNCCYHRV.js → chunk-M2JCUVCJ.js} +116 -95
- package/dist/bundle/{chunk-7F3NDIYL.js → chunk-MCJ7LKYR.js} +6 -6
- package/dist/bundle/{chunk-VDAIJM5L.js → chunk-MHQKHWCJ.js} +88 -34
- package/dist/bundle/{chunk-SQ7KOBRA.js → chunk-MMXMVGA6.js} +10 -8
- package/dist/bundle/{chunk-AFCGOZR7.js → chunk-NNIXREJH.js} +7 -7
- package/dist/bundle/{chunk-LQ37ALDJ.js → chunk-NXJLC2WK.js} +8 -8
- package/dist/bundle/{chunk-6GE3EADU.js → chunk-OHTR4WFO.js} +2 -2
- package/dist/bundle/{chunk-PJCTWPJB.js → chunk-PDL4UREY.js} +8 -8
- package/dist/bundle/{chunk-J3QXTBD2.js → chunk-Q2C3VMSU.js} +20 -18
- package/dist/bundle/{chunk-SWJAG5IE.js → chunk-Q44AYEOB.js} +2 -2
- package/dist/bundle/{chunk-P7P5MNAU.js → chunk-QZBT6BOU.js} +1 -1
- package/dist/bundle/{chunk-IBYTYIYO.js → chunk-R5MML3FC.js} +61 -54
- package/dist/bundle/{chunk-CEAANMJ2.js → chunk-RQVWZBW3.js} +3 -3
- package/dist/bundle/{chunk-5CXAH4Y6.js → chunk-S4YUR4S3.js} +656 -572
- package/dist/bundle/{chunk-QX7RCLRS.js → chunk-SQLCCKEL.js} +1 -1
- package/dist/bundle/chunk-U6UJ3HRS.js +58 -0
- package/dist/bundle/{chunk-YRGBZZUW.js → chunk-V4TDG4KF.js} +14 -14
- package/dist/bundle/{chunk-5FK6RD4M.js → chunk-VBOMKZ4E.js} +73 -57
- package/dist/bundle/{chunk-MQUJEQTU.js → chunk-VKPWP3AK.js} +2 -2
- package/dist/bundle/{chunk-7XNPSIWD.js → chunk-VNJMO5F6.js} +2 -2
- package/dist/bundle/{chunk-MMDCL42A.js → chunk-VSHJWTX5.js} +12 -6
- package/dist/bundle/{chunk-2MRECWJZ.js → chunk-XQJWMBDY.js} +6 -6
- package/dist/bundle/{chunk-2U4IANVV.js → chunk-ZKCNMW7G.js} +2 -2
- package/dist/bundle/{chunk-LNS27BTB.js → chunk-ZKZABB4K.js} +3 -3
- package/dist/bundle/{chunk-WNI5BZFB.js → chunk-ZNGQ3NZ4.js} +9 -9
- package/dist/bundle/command-contract-CB5BII3S.js +34 -0
- package/dist/bundle/{decode-D7BDVIVB.js → decode-KOBURZIQ.js} +5 -5
- package/dist/bundle/{dispatch-EUKKT3PD.js → dispatch-GDAH4JHS.js} +8 -8
- package/dist/bundle/dist-T7HMT675.js +134 -0
- package/dist/bundle/{echarts-IVRX7XHP.js → echarts-LEWTQO6H.js} +2 -2
- package/dist/bundle/{embed-X527RBTG.js → embed-PUFE4BSQ.js} +6 -6
- package/dist/bundle/{embedder-F4PSJS6S.js → embedder-3G4BQQ6X.js} +9 -9
- package/dist/bundle/{failure-OAIC5VAP.js → failure-6COJAO7T.js} +2 -2
- package/dist/bundle/{first-run-M5CIX6NA.js → first-run-FLXOC53U.js} +11 -11
- package/dist/bundle/first-screen-VUZEDSQW.js +32 -0
- package/dist/bundle/{instructions-UX36BT5F.js → instructions-HGSXDCBT.js} +1 -1
- package/dist/bundle/mail.js +12 -11
- package/dist/bundle/{mcp-L7SRVDRN.js → mcp-GAPDLFWA.js} +2 -2
- package/dist/bundle/{node-OXT7WE2T.js → node-5Z7PS4F5.js} +2 -2
- package/dist/bundle/{node-sqlite-X2PSEHA4.js → node-sqlite-OAW7APIX.js} +5 -5
- package/dist/bundle/{oauth-MYK4BSYN.js → oauth-ZFZWPAJN.js} +7 -7
- package/dist/bundle/{open-GONIP2DH.js → open-ZQMBZVH4.js} +4 -4
- package/dist/bundle/{openai-YJFNUOQT.js → openai-XT2RIXAK.js} +14 -14
- package/dist/bundle/{process-7IEUUSRK.js → process-VVEQIHPE.js} +1 -1
- package/dist/bundle/{program-Q73TTG3E.js → program-RD3BBDNY.js} +21470 -7075
- package/dist/bundle/{prompt-SKQ72KN7.js → prompt-PU7GE4Z4.js} +5 -5
- package/dist/bundle/{recognize-GC7CU2DB.js → recognize-AG4A3KUK.js} +4 -4
- package/dist/bundle/{remote-UEXFZP2I.js → remote-D6TQ6T7F.js} +7 -7
- package/dist/bundle/{rerank-2U2NDEZP.js → rerank-GO24HJPF.js} +7 -7
- package/dist/bundle/{serve-OOGKFEWL.js → serve-WCHJAH6G.js} +9 -9
- package/dist/bundle/server-5KJJ3D6P.js +63 -0
- package/dist/bundle/{server-FZ3LFQTF.js → server-CAVNBG3P.js} +38 -38
- package/dist/bundle/{sqlite-runtime-GIQSW6LJ.js → sqlite-runtime-ANXC4AW2.js} +5 -5
- package/dist/bundle/{state-EMFXPQVZ.js → state-EGJ66A62.js} +6 -6
- package/dist/bundle/{store-BDU4UPNK.js → store-OON7FCMQ.js} +15 -15
- package/dist/bundle/{store-LDI62AUG.js → store-SBFA444C.js} +13 -13
- package/dist/bundle/store-maintenance-command-UEOJLYMJ.js +52 -0
- package/dist/commands/attachments.d.ts +3 -0
- package/dist/commands/attachments.d.ts.map +1 -0
- package/dist/commands/attachments.js +97 -0
- package/dist/commands/attachments.js.map +1 -0
- package/dist/commands/context.d.ts +21 -6
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js +58 -7
- package/dist/commands/context.js.map +1 -1
- package/dist/commands/drafts-send.d.ts +7 -0
- package/dist/commands/drafts-send.d.ts.map +1 -0
- package/dist/commands/drafts-send.js +58 -0
- package/dist/commands/drafts-send.js.map +1 -0
- package/dist/commands/drafts.d.ts +3 -0
- package/dist/commands/drafts.d.ts.map +1 -0
- package/dist/commands/drafts.js +243 -0
- package/dist/commands/drafts.js.map +1 -0
- package/dist/commands/export.d.ts +3 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +278 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/folders.d.ts.map +1 -1
- package/dist/commands/folders.js +120 -2
- package/dist/commands/folders.js.map +1 -1
- package/dist/commands/messages.d.ts +25 -0
- package/dist/commands/messages.d.ts.map +1 -0
- package/dist/commands/messages.js +506 -0
- package/dist/commands/messages.js.map +1 -0
- package/dist/commands/read.d.ts +4 -1
- package/dist/commands/read.d.ts.map +1 -1
- package/dist/commands/read.js +14 -3
- package/dist/commands/read.js.map +1 -1
- package/dist/commands/rules.d.ts +3 -0
- package/dist/commands/rules.d.ts.map +1 -0
- package/dist/commands/rules.js +292 -0
- package/dist/commands/rules.js.map +1 -0
- package/dist/commands/send.d.ts +39 -0
- package/dist/commands/send.d.ts.map +1 -0
- package/dist/commands/send.js +309 -0
- package/dist/commands/send.js.map +1 -0
- package/dist/commands/server-search.d.ts +8 -0
- package/dist/commands/server-search.d.ts.map +1 -0
- package/dist/commands/server-search.js +38 -0
- package/dist/commands/server-search.js.map +1 -0
- package/dist/commands/session-start.d.ts.map +1 -1
- package/dist/commands/session-start.js +107 -10
- package/dist/commands/session-start.js.map +1 -1
- package/dist/commands/session.d.ts.map +1 -1
- package/dist/commands/session.js +72 -9
- package/dist/commands/session.js.map +1 -1
- package/dist/commands/stats.d.ts +3 -0
- package/dist/commands/stats.d.ts.map +1 -0
- package/dist/commands/stats.js +89 -0
- package/dist/commands/stats.js.map +1 -0
- package/dist/commands/status.js +2 -2
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/sync.d.ts +6 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +28 -20
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/tags.d.ts +3 -0
- package/dist/commands/tags.d.ts.map +1 -0
- package/dist/commands/tags.js +144 -0
- package/dist/commands/tags.js.map +1 -0
- package/dist/config.d.ts +15 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +52 -1
- package/dist/config.js.map +1 -1
- package/dist/export/format.d.ts +19 -0
- package/dist/export/format.d.ts.map +1 -0
- package/dist/export/format.js +40 -0
- package/dist/export/format.js.map +1 -0
- package/dist/export/journal.d.ts +32 -0
- package/dist/export/journal.d.ts.map +1 -0
- package/dist/export/journal.js +84 -0
- package/dist/export/journal.js.map +1 -0
- package/dist/export/write.d.ts +14 -0
- package/dist/export/write.d.ts.map +1 -0
- package/dist/export/write.js +42 -0
- package/dist/export/write.js.map +1 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +3 -0
- package/dist/identity.js.map +1 -1
- package/dist/mail/backend.d.ts +104 -2
- package/dist/mail/backend.d.ts.map +1 -1
- package/dist/mail/backend.js +4 -1
- package/dist/mail/backend.js.map +1 -1
- package/dist/mail/changes.d.ts +91 -0
- package/dist/mail/changes.d.ts.map +1 -0
- package/dist/mail/changes.js +198 -0
- package/dist/mail/changes.js.map +1 -0
- package/dist/mail/cleanup.d.ts +41 -0
- package/dist/mail/cleanup.d.ts.map +1 -0
- package/dist/mail/cleanup.js +119 -0
- package/dist/mail/cleanup.js.map +1 -0
- package/dist/mail/compose.d.ts +73 -0
- package/dist/mail/compose.d.ts.map +1 -0
- package/dist/mail/compose.js +110 -0
- package/dist/mail/compose.js.map +1 -0
- package/dist/mail/doctor.d.ts +67 -0
- package/dist/mail/doctor.d.ts.map +1 -0
- package/dist/mail/doctor.js +115 -0
- package/dist/mail/doctor.js.map +1 -0
- package/dist/mail/drafts.d.ts +54 -0
- package/dist/mail/drafts.d.ts.map +1 -0
- package/dist/mail/drafts.js +104 -0
- package/dist/mail/drafts.js.map +1 -0
- package/dist/mail/imap/connection.d.ts +13 -3
- package/dist/mail/imap/connection.d.ts.map +1 -1
- package/dist/mail/imap/connection.js +87 -18
- package/dist/mail/imap/connection.js.map +1 -1
- package/dist/mail/imap/index.d.ts +3 -3
- package/dist/mail/imap/index.d.ts.map +1 -1
- package/dist/mail/imap/index.js +14 -4
- package/dist/mail/imap/index.js.map +1 -1
- package/dist/mail/imap/messages.d.ts +5 -6
- package/dist/mail/imap/messages.d.ts.map +1 -1
- package/dist/mail/imap/messages.js +14 -28
- package/dist/mail/imap/messages.js.map +1 -1
- package/dist/mail/imap/read.d.ts.map +1 -1
- package/dist/mail/imap/read.js +27 -13
- package/dist/mail/imap/read.js.map +1 -1
- package/dist/mail/imap/search.d.ts +14 -0
- package/dist/mail/imap/search.d.ts.map +1 -0
- package/dist/mail/imap/search.js +55 -0
- package/dist/mail/imap/search.js.map +1 -0
- package/dist/mail/imap/write.d.ts +5 -0
- package/dist/mail/imap/write.d.ts.map +1 -0
- package/dist/mail/imap/write.js +93 -0
- package/dist/mail/imap/write.js.map +1 -0
- package/dist/mail/organise.d.ts +116 -0
- package/dist/mail/organise.d.ts.map +1 -0
- package/dist/mail/organise.js +531 -0
- package/dist/mail/organise.js.map +1 -0
- package/dist/mail/rethread.d.ts +1 -2
- package/dist/mail/rethread.d.ts.map +1 -1
- package/dist/mail/rethread.js +8 -3
- package/dist/mail/rethread.js.map +1 -1
- package/dist/mail/rules/apply.d.ts +40 -0
- package/dist/mail/rules/apply.d.ts.map +1 -0
- package/dist/mail/rules/apply.js +114 -0
- package/dist/mail/rules/apply.js.map +1 -0
- package/dist/mail/rules/file.d.ts +9 -0
- package/dist/mail/rules/file.d.ts.map +1 -0
- package/dist/mail/rules/file.js +51 -0
- package/dist/mail/rules/file.js.map +1 -0
- package/dist/mail/rules/filters.d.ts +11 -0
- package/dist/mail/rules/filters.d.ts.map +1 -0
- package/dist/mail/rules/filters.js +150 -0
- package/dist/mail/rules/filters.js.map +1 -0
- package/dist/mail/rules/folders.d.ts +11 -0
- package/dist/mail/rules/folders.d.ts.map +1 -0
- package/dist/mail/rules/folders.js +17 -0
- package/dist/mail/rules/folders.js.map +1 -0
- package/dist/mail/rules/query.d.ts +15 -0
- package/dist/mail/rules/query.d.ts.map +1 -0
- package/dist/mail/rules/query.js +103 -0
- package/dist/mail/rules/query.js.map +1 -0
- package/dist/mail/rules/store.d.ts +9 -0
- package/dist/mail/rules/store.d.ts.map +1 -0
- package/dist/mail/rules/store.js +17 -0
- package/dist/mail/rules/store.js.map +1 -0
- package/dist/mail/save.d.ts +9 -0
- package/dist/mail/save.d.ts.map +1 -0
- package/dist/mail/save.js +50 -0
- package/dist/mail/save.js.map +1 -0
- package/dist/mail/send.d.ts +67 -0
- package/dist/mail/send.d.ts.map +1 -0
- package/dist/mail/send.js +173 -0
- package/dist/mail/send.js.map +1 -0
- package/dist/mail/smtp.d.ts +4 -0
- package/dist/mail/smtp.d.ts.map +1 -0
- package/dist/mail/smtp.js +133 -0
- package/dist/mail/smtp.js.map +1 -0
- package/dist/oauth.d.ts +74 -0
- package/dist/oauth.d.ts.map +1 -0
- package/dist/oauth.js +230 -0
- package/dist/oauth.js.map +1 -0
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +26 -4
- package/dist/program.js.map +1 -1
- package/dist/providers.d.ts +96 -9
- package/dist/providers.d.ts.map +1 -1
- package/dist/providers.js +69 -16
- package/dist/providers.js.map +1 -1
- package/dist/reasons.d.ts +9 -0
- package/dist/reasons.d.ts.map +1 -0
- package/dist/reasons.js +27 -0
- package/dist/reasons.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -5
- package/skills/mail-cli/SKILL.md +30 -3
- package/dist/bundle/chunk-YD5WV757.js +0 -27
- package/dist/bundle/command-contract-GPUED3GT.js +0 -34
- package/dist/bundle/first-screen-M7MT776O.js +0 -32
- package/dist/bundle/server-4JMHDHZ7.js +0 -63
- package/dist/bundle/store-maintenance-command-OFRPORN2.js +0 -52
- /package/dist/bundle/{chunk-NPGVOZVK.js → chunk-WJWLHLQ7.js} +0 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
const SEARCH_IDS = 100;
|
|
3
|
+
const range = (uids) => uids.join(",");
|
|
4
|
+
const movedOf = (answer) => answer === false
|
|
5
|
+
? { uids: new Map() }
|
|
6
|
+
: {
|
|
7
|
+
uids: new Map(answer.uidMap ?? []),
|
|
8
|
+
...(answer.uidValidity === undefined ? {} : { validity: String(answer.uidValidity) }),
|
|
9
|
+
};
|
|
10
|
+
/** Every change the mail commands make, over imapflow. Each is one command per folder, never repeated. */
|
|
11
|
+
export const imapWrites = (pool) => {
|
|
12
|
+
const changed = async (done, what) => {
|
|
13
|
+
if (!(await done))
|
|
14
|
+
throw new CliError("provider_unavailable", `the server refused to ${what}`);
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
locate: (folder, { emailIds = [], messageIds = [] }) => pool.inFolder(folder, async (open, validity) => {
|
|
18
|
+
const uids = new Map();
|
|
19
|
+
const found = async (queries, keyOf) => {
|
|
20
|
+
for (let at = 0; at < queries.length; at += SEARCH_IDS) {
|
|
21
|
+
const part = queries.slice(at, at + SEARCH_IDS);
|
|
22
|
+
const hits = (await open.search(part.length === 1 ? part[0] : { or: part }, { uid: true })) || [];
|
|
23
|
+
if (hits.length === 0)
|
|
24
|
+
continue;
|
|
25
|
+
for (const message of await open.fetchAll(hits, { uid: true, emailId: true, envelope: true }, { uid: true })) {
|
|
26
|
+
const key = keyOf(message);
|
|
27
|
+
if (key !== undefined)
|
|
28
|
+
uids.set(key, message.uid);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const wantedEmails = new Set(emailIds);
|
|
33
|
+
await found(emailIds.map((emailId) => ({ emailId })), (message) => message.emailId && wantedEmails.has(String(message.emailId)) ? String(message.emailId) : undefined);
|
|
34
|
+
const wantedMessages = new Set(messageIds);
|
|
35
|
+
await found(messageIds.map((messageId) => ({ header: { "message-id": messageId } })), (message) => {
|
|
36
|
+
const id = message.envelope?.messageId;
|
|
37
|
+
return id && wantedMessages.has(id) ? id : undefined;
|
|
38
|
+
});
|
|
39
|
+
return { validity, uids };
|
|
40
|
+
}),
|
|
41
|
+
state: (folder, validity, uids) => pool.inFolder(folder, async (open) => {
|
|
42
|
+
const states = new Map();
|
|
43
|
+
if (uids.length === 0)
|
|
44
|
+
return states;
|
|
45
|
+
const fetched = await open.fetchAll(range(uids), { uid: true, flags: true, labels: true, envelope: true }, { uid: true });
|
|
46
|
+
for (const message of fetched)
|
|
47
|
+
states.set(message.uid, {
|
|
48
|
+
flags: [...(message.flags ?? [])].sort(),
|
|
49
|
+
...(message.labels ? { labels: [...message.labels].sort() } : {}),
|
|
50
|
+
...(message.envelope?.messageId ? { messageId: message.envelope.messageId } : {}),
|
|
51
|
+
});
|
|
52
|
+
return states;
|
|
53
|
+
}, validity),
|
|
54
|
+
flag: (folder, validity, uids, { add = [], remove = [] }) => pool.writeIn(folder, async (open) => {
|
|
55
|
+
if (add.length)
|
|
56
|
+
await changed(open.messageFlagsAdd(range(uids), add, { uid: true }), "add the flags");
|
|
57
|
+
if (remove.length)
|
|
58
|
+
await changed(open.messageFlagsRemove(range(uids), remove, { uid: true }), "remove the flags");
|
|
59
|
+
}, validity),
|
|
60
|
+
label: (folder, validity, uids, { add = [], remove = [] }) => pool.writeIn(folder, async (open) => {
|
|
61
|
+
if (add.length)
|
|
62
|
+
await changed(open.messageFlagsAdd(range(uids), add, { uid: true, useLabels: true }), "add the labels");
|
|
63
|
+
if (remove.length)
|
|
64
|
+
await changed(open.messageFlagsRemove(range(uids), remove, { uid: true, useLabels: true }), "remove the labels");
|
|
65
|
+
}, validity),
|
|
66
|
+
move: (folder, validity, uids, to) => pool.writeIn(folder, async (open) => movedOf(await open.messageMove(range(uids), to, { uid: true })), validity),
|
|
67
|
+
copy: (folder, validity, uids, to) => pool.writeIn(folder, async (open) => movedOf(await open.messageCopy(range(uids), to, { uid: true })), validity),
|
|
68
|
+
expunge: (folder, validity, uids) => pool.writeIn(folder, async (open) => {
|
|
69
|
+
if (!open.capabilities.has("UIDPLUS"))
|
|
70
|
+
throw new CliError("provider_unavailable", "the server cannot expunge single messages (no UIDPLUS), so a copy cannot be taken back alone", { reason: "mail.no-uidplus" });
|
|
71
|
+
await changed(open.messageDelete(range(uids), { uid: true }), "remove the copies");
|
|
72
|
+
}, validity),
|
|
73
|
+
append: (folder, raw, flags) => pool.writeOnServer(async (open) => {
|
|
74
|
+
const stored = await open.append(folder, Buffer.from(raw), [...flags]);
|
|
75
|
+
if (stored === false)
|
|
76
|
+
throw new CliError("provider_unavailable", `the server refused to store the message in ${folder}`);
|
|
77
|
+
return {
|
|
78
|
+
...(stored.uid === undefined ? {} : { uid: stored.uid }),
|
|
79
|
+
...(stored.uidValidity === undefined ? {} : { validity: String(stored.uidValidity) }),
|
|
80
|
+
};
|
|
81
|
+
}),
|
|
82
|
+
createFolder: (path) => pool.writeOnServer(async (open) => {
|
|
83
|
+
await open.mailboxCreate(path);
|
|
84
|
+
}),
|
|
85
|
+
renameFolder: (path, to) => pool.writeOnServer(async (open) => {
|
|
86
|
+
await open.mailboxRename(path, to);
|
|
87
|
+
}),
|
|
88
|
+
deleteFolder: (path) => pool.writeOnServer(async (open) => {
|
|
89
|
+
await open.mailboxDelete(path);
|
|
90
|
+
}),
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=write.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write.js","sourceRoot":"","sources":["../../../src/mail/imap/write.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAK5C,MAAM,UAAU,GAAG,GAAG,CAAA;AAEtB,MAAM,KAAK,GAAG,CAAC,IAAuB,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAEzD,MAAM,OAAO,GAAG,CAAC,MAAoD,EAAS,EAAE,CAC9E,MAAM,KAAK,KAAK;IACd,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE;IACrB,CAAC,CAAC;QACE,IAAI,EAAE,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC;QAClC,GAAG,CAAC,MAAM,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;KACtF,CAAA;AAEP,0GAA0G;AAC1G,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAiB,EAAc,EAAE;IAC1D,MAAM,OAAO,GAAG,KAAK,EAAE,IAAsB,EAAE,IAAY,EAAE,EAAE;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G,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC;gBACxD,GAAG,CAAC,MAAM,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;aACtF,CAAA;QACH,CAAC,CAAC;QAEJ,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CACrB,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YAChC,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;QAChC,CAAC,CAAC;QAEJ,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CACzB,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YAChC,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;QACpC,CAAC,CAAC;QAEJ,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CACrB,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YAChC,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;QAChC,CAAC,CAAC;KACL,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { AppIdentity } from "@wirecat/cli-core/cli";
|
|
2
|
+
import { type SendGuard } from "@wirecat/cli-core/sends";
|
|
3
|
+
import type { AccountKey, MessageStore } from "@wirecat/cli-core/store";
|
|
4
|
+
import type { Organise } from "../providers.js";
|
|
5
|
+
import type { FolderInfo, MailWrites, ServerState } from "./backend.js";
|
|
6
|
+
import { type ChangedItem, type ChangeLog, type ChangeRun, type StepLine } from "./changes.js";
|
|
7
|
+
/** One mailbox as the write commands see it: its stored mail, its server and where its provider differs. */
|
|
8
|
+
export interface Mailbox {
|
|
9
|
+
app: AppIdentity;
|
|
10
|
+
store: MessageStore;
|
|
11
|
+
key: AccountKey;
|
|
12
|
+
accountId: number;
|
|
13
|
+
writes: MailWrites;
|
|
14
|
+
folders: () => Promise<FolderInfo[]>;
|
|
15
|
+
organise: Organise;
|
|
16
|
+
now: () => number;
|
|
17
|
+
}
|
|
18
|
+
export declare const FILTER_LIMIT = 500;
|
|
19
|
+
export declare const MAX_LIMIT = 5000;
|
|
20
|
+
/** More messages than this at once is a bulk change: previewed first and checked as `messages.bulk` too. */
|
|
21
|
+
export declare const BULK = 20;
|
|
22
|
+
/** A flag as the owner types it, `read` or `$Junk`, in IMAP's spelling; `\Deleted` is refused, it is how mail is expunged. */
|
|
23
|
+
export declare const flagOf: (given: string) => string;
|
|
24
|
+
/** Stored mail by reference or by the shared query, at most `limit`; `more` says the query matched more. */
|
|
25
|
+
export declare const selectIds: (mailbox: Mailbox, { refs, filter, limit }: {
|
|
26
|
+
refs?: string[];
|
|
27
|
+
filter?: string;
|
|
28
|
+
limit?: number;
|
|
29
|
+
}) => Promise<{
|
|
30
|
+
ids: string[];
|
|
31
|
+
more: boolean;
|
|
32
|
+
}>;
|
|
33
|
+
interface Located {
|
|
34
|
+
folder: string;
|
|
35
|
+
validity: string;
|
|
36
|
+
items: ChangedItem[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Where each email is on the server now, folder by folder. `everywhere` keeps every place an email is in (a flag is
|
|
40
|
+
* set on each copy); otherwise only its first, so one email is moved once. Trash counts only when `trash` is given.
|
|
41
|
+
*/
|
|
42
|
+
export declare const locate: (mailbox: Mailbox, ids: readonly string[], { everywhere, trash }?: {
|
|
43
|
+
everywhere?: boolean;
|
|
44
|
+
trash?: string;
|
|
45
|
+
}) => Promise<{
|
|
46
|
+
located: Located[];
|
|
47
|
+
missing: string[];
|
|
48
|
+
deleted: string[];
|
|
49
|
+
inTrash: string[];
|
|
50
|
+
}>;
|
|
51
|
+
/** The folder a name or a role names: its path, a role (`archive`, `trash`), then a name in any case. */
|
|
52
|
+
export declare const folderNamed: (folders: readonly FolderInfo[], given: string) => FolderInfo | undefined;
|
|
53
|
+
export declare const trashOf: (mailbox: Mailbox) => Promise<string>;
|
|
54
|
+
/** On Gmail a folder is a label: what a move or copy to `given` adds and takes away, or a real folder to move to. */
|
|
55
|
+
type Target = {
|
|
56
|
+
kind: "folder";
|
|
57
|
+
path: string;
|
|
58
|
+
} | {
|
|
59
|
+
kind: "labels";
|
|
60
|
+
add: string[];
|
|
61
|
+
remove: string[];
|
|
62
|
+
name: string;
|
|
63
|
+
};
|
|
64
|
+
export declare const targetOf: (mailbox: Mailbox, given: string, copy: boolean) => Promise<Target>;
|
|
65
|
+
/** Runs one step against the server under the guard, recording it before it goes and once it is done. */
|
|
66
|
+
export declare class Changer {
|
|
67
|
+
readonly mailbox: Mailbox;
|
|
68
|
+
readonly guard: SendGuard;
|
|
69
|
+
readonly log: ChangeLog;
|
|
70
|
+
readonly key: string;
|
|
71
|
+
readonly action: "message-flag" | "message-move" | "message-copy" | "message-delete" | "message-restore";
|
|
72
|
+
constructor(mailbox: Mailbox, guard: SendGuard, log: ChangeLog, key: string, action: "message-flag" | "message-move" | "message-copy" | "message-delete" | "message-restore");
|
|
73
|
+
step<T>(line: Omit<StepLine, "type" | "step">, act: () => Promise<T>, moved?: (done: T) => {
|
|
74
|
+
uids: Map<string, number>;
|
|
75
|
+
validity?: string;
|
|
76
|
+
}): Promise<T>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Adds and removes flags, or with `replace` makes `add` each message's whole set. On Gmail the flags of All Mail are
|
|
80
|
+
* the message's own. The store takes read and flagged once the server said yes.
|
|
81
|
+
*/
|
|
82
|
+
export declare const changeFlags: (changer: Changer, located: Located[], change: {
|
|
83
|
+
add: string[];
|
|
84
|
+
remove: string[];
|
|
85
|
+
replace?: boolean;
|
|
86
|
+
}) => Promise<string[]>;
|
|
87
|
+
export declare const moveMessages: (changer: Changer, located: Located[], target: Target, op: "move" | "copy") => Promise<string[]>;
|
|
88
|
+
/**
|
|
89
|
+
* Moves the messages to Trash, which the provider empties in its own time; until then `messages restore` brings them
|
|
90
|
+
* back. On Gmail each message's labels are kept in the record first. The store marks them deleted, as a sync would.
|
|
91
|
+
*/
|
|
92
|
+
export declare const trashMessages: (changer: Changer, located: Located[], trash: string, keep?: (id: string, state: ServerState) => string | undefined) => Promise<{
|
|
93
|
+
changed: string[];
|
|
94
|
+
kept: Record<string, number>;
|
|
95
|
+
}>;
|
|
96
|
+
export interface RestorePlan {
|
|
97
|
+
run: string;
|
|
98
|
+
command: string;
|
|
99
|
+
started_at: string;
|
|
100
|
+
restorable_until: string | null;
|
|
101
|
+
expired: boolean;
|
|
102
|
+
/** Messages the run changed. */
|
|
103
|
+
logged: number;
|
|
104
|
+
/** Messages a restore puts back: still where the run left them. */
|
|
105
|
+
restorable: number;
|
|
106
|
+
/** Changed by the run, and no longer where it left them: restored already, moved by hand, or gone for good. */
|
|
107
|
+
missing: number;
|
|
108
|
+
restored: number;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Undoes a run, last step first, for the messages still where it left them. Without `apply` it only counts. Trash
|
|
112
|
+
* brings mail back to where it was (on Gmail: to the Inbox if it was there, else All Mail, labels put back).
|
|
113
|
+
*/
|
|
114
|
+
export declare const restoreRun: (changer: Changer, { run, steps, restored: before }: ChangeRun, path: string, apply: boolean) => Promise<RestorePlan>;
|
|
115
|
+
export {};
|
|
116
|
+
//# sourceMappingURL=organise.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organise.d.ts","sourceRoot":"","sources":["../../src/mail/organise.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,OAAO,EAAmD,KAAK,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACzG,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACvE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAA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