@chronicle.app/email-core 0.4.0 → 0.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/README.md +1 -1
- package/dist/build.d.ts +2 -3
- package/dist/build.js +8 -8
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ What Chronicle's mail sources share: reading an mbox, parsing an email, identify
|
|
|
10
10
|
- for bulk mail (one with `List-Unsubscribe`, `List-Id`, or `Precedence: bulk`), without its footer: from the first unsubscribe or "you're receiving this" line in its second half;
|
|
11
11
|
- with tracking parameters (`utm_*`, `fbclid`, …) taken off links and the padding characters newsletters fill their inbox preview with removed, by `tidyText` from `@chronicle.app/etl`. In bulk mail, click-tracking redirects (URLs over 200 characters) lose their URL but keep their words; a person's mail keeps long links, like a meeting's join link.
|
|
12
12
|
- `identityOf(message)` is its Message-ID, or else its sender, date, and subject; null when it has neither, and a source skips it.
|
|
13
|
-
- `messageAction(message, options)` is the sending of it: a `MessageAction` by the sender
|
|
13
|
+
- `messageAction(message, options)` is the sending of it: a `MessageAction` by the sender whose `result` is the `Message`, keyed by it, with its recipients and the message it replies to, and a source's thread and labels when it has them. The sender is written in full as the action's `agent`, and as the message's `author` by key alone. A display name the mail gives an address, other than the address itself, is its `alternateName`: what that message called it, not its own name. With `account`, the message is `inAccount` it.
|
|
14
14
|
- `emailAccount(address)` is the account at an address, an Agent keyed by it in the `email` namespace: what a message is `inAccount`, whatever service holds it.
|
|
15
15
|
|
|
16
16
|
Identifiers the email protocol defines are keyed in its namespace (`source: 'email'`): a message by its Message-ID without the angle brackets around it (as JMAP and `mid:` URIs write it), so the same email read by any mail source is one node. A person is their lowercased address in the `email` namespace (`source: 'email'`), the identity other plugins already link an address to, so every mail source, a calendar, and those links meet on one node.
|
package/dist/build.d.ts
CHANGED
|
@@ -35,11 +35,10 @@ export interface MessageNodeOptions {
|
|
|
35
35
|
account?: Agent;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
* The sending of a message: a `MessageAction` by its sender, whose
|
|
38
|
+
* The sending of a message: a `MessageAction` by its sender, whose result is
|
|
39
39
|
* the `Message`, with its recipients, the message it replies to, and its
|
|
40
40
|
* thread and labels when the source has them. The sending happened once, so
|
|
41
|
-
* the action is keyed by the
|
|
42
|
-
* message is.
|
|
41
|
+
* the action is keyed by the message it made, wherever the message is read.
|
|
43
42
|
*/
|
|
44
43
|
export declare function messageAction(mail: MailMessage, options?: MessageNodeOptions): MessageAction;
|
|
45
44
|
/**
|
package/dist/build.js
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
const MESSAGE_KEY = ['@type', 'source', 'sourceId'];
|
|
7
7
|
/** Without a Message-ID: who sent it, when, and under what subject. */
|
|
8
8
|
const KEYLESS_MESSAGE_KEY = ['@type', 'source', 'action.timestamp', 'action.agent.handle', 'name'];
|
|
9
|
-
const KEYLESS_ACTION_KEY = ['@type', 'source', 'timestamp', 'agent.handle', '
|
|
9
|
+
const KEYLESS_ACTION_KEY = ['@type', 'source', 'timestamp', 'agent.handle', 'result.name'];
|
|
10
|
+
/** Sending makes the message, so the action is keyed by the message it made. */
|
|
11
|
+
const ACTION_KEY = ['@type', 'source', 'result.sourceId'];
|
|
10
12
|
/** Identifiers defined by the email protocol (RFC 5322) live in its namespace. */
|
|
11
13
|
const EMAIL = 'email';
|
|
12
14
|
/**
|
|
@@ -42,11 +44,10 @@ export function identityOf(mail) {
|
|
|
42
44
|
return [mail.from.address.toLowerCase(), mail.date, mail.subject].join(COMPOSITE_DELIMITER);
|
|
43
45
|
}
|
|
44
46
|
/**
|
|
45
|
-
* The sending of a message: a `MessageAction` by its sender, whose
|
|
47
|
+
* The sending of a message: a `MessageAction` by its sender, whose result is
|
|
46
48
|
* the `Message`, with its recipients, the message it replies to, and its
|
|
47
49
|
* thread and labels when the source has them. The sending happened once, so
|
|
48
|
-
* the action is keyed by the
|
|
49
|
-
* message is.
|
|
50
|
+
* the action is keyed by the message it made, wherever the message is read.
|
|
50
51
|
*/
|
|
51
52
|
export function messageAction(mail, options = {}) {
|
|
52
53
|
const me = new Set((options.me ?? []).map(address => address.toLowerCase()));
|
|
@@ -87,12 +88,11 @@ export function messageAction(mail, options = {}) {
|
|
|
87
88
|
};
|
|
88
89
|
return {
|
|
89
90
|
'@type': 'MessageAction',
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
: { '@key': KEYLESS_ACTION_KEY, source: EMAIL }),
|
|
91
|
+
'@key': messageId ? ACTION_KEY : KEYLESS_ACTION_KEY,
|
|
92
|
+
source: EMAIL,
|
|
93
93
|
timestamp: new Date(sentAt),
|
|
94
94
|
agent: sender,
|
|
95
|
-
|
|
95
|
+
result: message,
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
98
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chronicle.app/email-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"type": "module",
|
|
24
24
|
"description": "Email parsing, mbox reading, and message nodes shared by Chronicle mail sources",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@chronicle.app/etl": "0.
|
|
27
|
-
"@chronicle.app/schema": "0.
|
|
28
|
-
"@chronicle.app/tsconfig": "0.
|
|
26
|
+
"@chronicle.app/etl": "0.5.0",
|
|
27
|
+
"@chronicle.app/schema": "0.5.0",
|
|
28
|
+
"@chronicle.app/tsconfig": "0.5.0",
|
|
29
29
|
"@types/node": "^22.10.1",
|
|
30
30
|
"typescript": "^5.7.2"
|
|
31
31
|
},
|