@wirecat/cli-core 0.533.0 → 0.534.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 +8 -0
- package/dist/mail/index.d.ts +1 -1
- package/dist/mail/index.js +1 -1
- package/dist/mail/parse.d.ts +9 -1
- package/dist/mail/parse.js +9 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,14 @@ shape of this file.
|
|
|
7
7
|
|
|
8
8
|
## Unreleased
|
|
9
9
|
|
|
10
|
+
## 0.534.0 — 01.11.2026
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **`parseMail` also returns `messageId`, `references`, `replyTo` and `date`**, and takes a third argument, the most
|
|
15
|
+
attachments to keep (`MAX_ATTACHMENTS`, 50, by default), so a command that lists one message's files can ask for all
|
|
16
|
+
of them.
|
|
17
|
+
|
|
10
18
|
## 0.533.0 — 01.11.2026
|
|
11
19
|
|
|
12
20
|
### Added
|
package/dist/mail/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { dropMissing, type Gone, tooManyGone } from "./gone.js";
|
|
|
6
6
|
export { type AuthVerdicts, HEADER_FIELDS, headersOf, type MailHeaders, mailHeadersOf } from "./headers.js";
|
|
7
7
|
export { type MailIdsInput, mailIds } from "./ids.js";
|
|
8
8
|
export { decodedLabelName, decodeMailboxName, labelName, systemLabel } from "./labels.js";
|
|
9
|
-
export { type Address, htmlToText, looksLikeHtml, MAX_BODY_CHARS, type ParsedMail, parseMail, } from "./parse.js";
|
|
9
|
+
export { type Address, htmlToText, looksLikeHtml, MAX_ATTACHMENTS, MAX_BODY_CHARS, type ParsedMail, parseMail, } from "./parse.js";
|
|
10
10
|
export { PRESET_NAMES, PRESETS, type PresetName, presetMatches } from "./presets.js";
|
|
11
11
|
export { domainsToAge, groupKey, type Probe, type ProbeGroup, probeMail, SUGGEST_RULE } from "./probe.js";
|
|
12
12
|
export { type MailFolderProgress, mailProgress } from "./progress.js";
|
package/dist/mail/index.js
CHANGED
|
@@ -6,7 +6,7 @@ export { dropMissing, tooManyGone } from "./gone.js";
|
|
|
6
6
|
export { HEADER_FIELDS, headersOf, mailHeadersOf } from "./headers.js";
|
|
7
7
|
export { mailIds } from "./ids.js";
|
|
8
8
|
export { decodedLabelName, decodeMailboxName, labelName, systemLabel } from "./labels.js";
|
|
9
|
-
export { htmlToText, looksLikeHtml, MAX_BODY_CHARS, parseMail, } from "./parse.js";
|
|
9
|
+
export { htmlToText, looksLikeHtml, MAX_ATTACHMENTS, MAX_BODY_CHARS, parseMail, } from "./parse.js";
|
|
10
10
|
export { PRESET_NAMES, PRESETS, presetMatches } from "./presets.js";
|
|
11
11
|
export { domainsToAge, groupKey, probeMail, SUGGEST_RULE } from "./probe.js";
|
|
12
12
|
export { mailProgress } from "./progress.js";
|
package/dist/mail/parse.d.ts
CHANGED
|
@@ -8,6 +8,12 @@ export interface ParsedMail {
|
|
|
8
8
|
to: Address[];
|
|
9
9
|
cc: Address[];
|
|
10
10
|
bcc: Address[];
|
|
11
|
+
replyTo: Address[];
|
|
12
|
+
date: string | null;
|
|
13
|
+
/** Message-ID as the first `<id>` the header holds, brackets kept; the header as written when it holds none. */
|
|
14
|
+
messageId: string | null;
|
|
15
|
+
/** Every `<id>` of References, in the header's order, brackets kept. */
|
|
16
|
+
references: string[];
|
|
11
17
|
attachments: {
|
|
12
18
|
id: number;
|
|
13
19
|
name: string;
|
|
@@ -17,8 +23,10 @@ export interface ParsedMail {
|
|
|
17
23
|
text: string;
|
|
18
24
|
}
|
|
19
25
|
export declare const MAX_BODY_CHARS = 1000000;
|
|
26
|
+
/** What sync stores; a command that shows the files of one message passes its own limit. */
|
|
27
|
+
export declare const MAX_ATTACHMENTS = 50;
|
|
20
28
|
export declare const htmlToText: (html: string) => string;
|
|
21
29
|
/** Some senders put their HTML in the text/plain part; its first tag gives it away. */
|
|
22
30
|
export declare const looksLikeHtml: (text: string) => boolean;
|
|
23
31
|
/** A raw RFC 5322 message, as IMAP's `BODY[]` holds it. */
|
|
24
|
-
export declare const parseMail: (raw: Uint8Array, maxBodyChars?: number) => Promise<ParsedMail>;
|
|
32
|
+
export declare const parseMail: (raw: Uint8Array, maxBodyChars?: number, maxAttachments?: number) => Promise<ParsedMail>;
|
package/dist/mail/parse.js
CHANGED
|
@@ -2,6 +2,9 @@ import { CliError } from "@wirecat/cli-base";
|
|
|
2
2
|
import PostalMime, {} from "postal-mime";
|
|
3
3
|
// The store cuts a body into pieces itself; this only guards against a pathological one, like a pasted log.
|
|
4
4
|
export const MAX_BODY_CHARS = 1_000_000;
|
|
5
|
+
/** What sync stores; a command that shows the files of one message passes its own limit. */
|
|
6
|
+
export const MAX_ATTACHMENTS = 50;
|
|
7
|
+
const BRACKETED_ID = /<[^<>\s]+>/g;
|
|
5
8
|
const addresses = (list) => list
|
|
6
9
|
.flatMap((entry) => entry.group ?? [entry])
|
|
7
10
|
.flatMap(({ address, name }) => (address ? [{ email: address.toLowerCase(), name: name || null }] : []));
|
|
@@ -52,7 +55,7 @@ const bytesOf = (content) => typeof content === "string"
|
|
|
52
55
|
? content
|
|
53
56
|
: new Uint8Array(content);
|
|
54
57
|
/** A raw RFC 5322 message, as IMAP's `BODY[]` holds it. */
|
|
55
|
-
export const parseMail = async (raw, maxBodyChars = MAX_BODY_CHARS) => {
|
|
58
|
+
export const parseMail = async (raw, maxBodyChars = MAX_BODY_CHARS, maxAttachments = MAX_ATTACHMENTS) => {
|
|
56
59
|
let email;
|
|
57
60
|
try {
|
|
58
61
|
email = await PostalMime.parse(raw);
|
|
@@ -68,7 +71,11 @@ export const parseMail = async (raw, maxBodyChars = MAX_BODY_CHARS) => {
|
|
|
68
71
|
to: addresses(email.to ?? []),
|
|
69
72
|
cc: addresses(email.cc ?? []),
|
|
70
73
|
bcc: addresses(email.bcc ?? []),
|
|
71
|
-
|
|
74
|
+
replyTo: addresses(email.replyTo ?? []),
|
|
75
|
+
date: email.date ?? null,
|
|
76
|
+
messageId: email.messageId?.match(BRACKETED_ID)?.[0] ?? email.messageId ?? null,
|
|
77
|
+
references: email.references?.match(BRACKETED_ID) ?? [],
|
|
78
|
+
attachments: email.attachments.slice(0, maxAttachments).map((part, id) => ({
|
|
72
79
|
id,
|
|
73
80
|
name: (part.filename ?? `attachment-${id}`).slice(0, 200),
|
|
74
81
|
mime: part.mimeType || null,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.534.0",
|
|
4
4
|
"description": "The messenger-neutral half of a messaging CLI: domain model, message locators, rendering, name resolution, the SQLite seam, the command skeleton and shared read commands, the send guard, run records and the message store",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Viacheslav Ptsarev",
|