@wirecat/cli-core 1.0.0 → 1.1.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 +89 -0
- package/THIRD_PARTY_NOTICES +43 -0
- package/dist/background/daily-archive-timer.d.ts +1 -1
- package/dist/cli/documents/words.d.ts +1 -1
- package/dist/cli/domain-lists-command.d.ts +16 -0
- package/dist/cli/domain-lists-command.js +88 -0
- package/dist/cli/index.d.ts +4 -3
- package/dist/cli/index.js +3 -2
- package/dist/cli/model-catalogue-command.d.ts +6 -0
- package/dist/cli/model-catalogue-command.js +1 -1
- package/dist/cli/oauth-session.d.ts +38 -4
- package/dist/cli/oauth-session.js +66 -22
- package/dist/cli/shared-command-exports.d.ts +2 -0
- package/dist/cli/shared-command-exports.js +3 -0
- package/dist/cli/token-session.d.ts +9 -0
- package/dist/cli/token-session.js +29 -2
- package/dist/domain/domain-lists.d.ts +86 -0
- package/dist/domain/domain-lists.js +110 -0
- package/dist/domain/free-mail-domains.generated.d.ts +1 -0
- package/dist/domain/free-mail-domains.generated.js +4 -0
- package/dist/domain/organization-sectors.d.ts +9 -3
- package/dist/domain/organization-sectors.generated.d.ts +1 -0
- package/dist/domain/organization-sectors.generated.js +1 -0
- package/dist/domain/organization-sectors.js +16 -3
- package/dist/domain/person-kinds.d.ts +6 -1
- package/dist/domain/person-kinds.js +5 -0
- package/dist/entities/domain-list.d.ts +27 -0
- package/dist/entities/domain-list.js +28 -0
- package/dist/entities/index.d.ts +20 -2
- package/dist/entities/index.js +3 -1
- package/dist/entities/knowledge-lists.d.ts +1 -1
- package/dist/errors/reasons.js +4 -2
- package/dist/mail/mail-types.d.ts +48 -0
- package/dist/mail/mail-types.js +218 -0
- package/dist/oauth/index.d.ts +1 -1
- package/dist/oauth/storage.d.ts +10 -2
- package/dist/oauth/storage.js +23 -9
- package/dist/services/domain-lists-download.d.ts +26 -0
- package/dist/services/domain-lists-download.js +155 -0
- package/dist/services/metadata.d.ts +1 -1
- package/dist/store/areas.d.ts +1 -1
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/people.d.ts +18 -9
- package/dist/store/people.js +8 -7
- package/dist/store/sqlite/accounts.js +3 -1
- package/dist/store/sqlite/domain-organizations.d.ts +7 -4
- package/dist/store/sqlite/domain-organizations.js +94 -36
- package/dist/store/sqlite/email-types.d.ts +79 -0
- package/dist/store/sqlite/email-types.js +261 -0
- package/dist/store/sqlite/emails.d.ts +11 -2
- package/dist/store/sqlite/emails.js +18 -7
- package/dist/store/sqlite/identities.d.ts +4 -1
- package/dist/store/sqlite/identities.js +11 -2
- package/dist/store/sqlite/identity-rekey.js +2 -0
- package/dist/store/sqlite/manifest.js +4 -0
- package/dist/store/sqlite/merged-persons.d.ts +3 -2
- package/dist/store/sqlite/merged-persons.js +5 -3
- package/dist/store/sqlite/migrations.generated.js +56 -0
- package/dist/store/sqlite/people-list.d.ts +1 -6
- package/dist/store/sqlite/people-list.js +38 -32
- package/dist/store/sqlite/person-links.js +13 -3
- package/dist/store/sqlite/person-match-scan.js +5 -2
- package/dist/store/sqlite/schema/sender-bots.d.ts +56 -0
- package/dist/store/sqlite/schema/sender-bots.js +9 -1
- package/dist/store/sqlite/schema.d.ts +49 -1
- package/dist/store/sqlite/schema.js +6 -1
- package/dist/store/sqlite/sender-bots.d.ts +80 -15
- package/dist/store/sqlite/sender-bots.js +378 -136
- package/dist/store/sqlite/sender-signals.d.ts +11 -4
- package/dist/store/sqlite/sender-signals.js +14 -10
- package/package.json +2 -2
|
@@ -7,7 +7,8 @@ import { SMALL_GROUP_MEMBERS } from "./person-ties.js";
|
|
|
7
7
|
export const REACHES = ["direct", "group", "broadcast"];
|
|
8
8
|
/** A list three people write to is a discussion; one sender, even under `+tag` addresses, is a newsletter. */
|
|
9
9
|
export const DISCUSSION_SENDERS = 3;
|
|
10
|
-
|
|
10
|
+
/** How one email reached the owner, and the signal that says so. */
|
|
11
|
+
export const reachOfOne = (mail) => {
|
|
11
12
|
if (mail.discussionList)
|
|
12
13
|
return { reach: "group", signal: "discussion-list" };
|
|
13
14
|
if (mail.oneClick)
|
|
@@ -52,22 +53,25 @@ export const senderSignalsOf = (mail, { addresses, ownerWrote, chatted }) => {
|
|
|
52
53
|
const reach = ownerWrote ? "direct" : (voted ?? (chatted ? "direct" : null));
|
|
53
54
|
return { signals: [...signals], reach };
|
|
54
55
|
};
|
|
55
|
-
const LIST_ID = "coalesce(json_extract(e.headers, '$.\"list-id\"'), json_extract(e.metadata, '$.listId'))";
|
|
56
|
-
/** `bob+news@x` and `bob@x` are one sender. */
|
|
56
|
+
export const LIST_ID = "coalesce(json_extract(e.headers, '$.\"list-id\"'), json_extract(e.metadata, '$.listId'))";
|
|
57
57
|
/** The senders of each of these List-Ids, through `emails_by_list_id`. */
|
|
58
58
|
export const LIST_SENDERS = `SELECT DISTINCT ${LIST_ID} AS list, e.from_address AS address FROM emails e ` +
|
|
59
59
|
`WHERE e.from_address IS NOT NULL AND ${LIST_ID} IN (SELECT value FROM json_each(?))`;
|
|
60
|
-
|
|
60
|
+
/** `bob+news@x` and `bob@x` are one sender. */
|
|
61
|
+
export const senderKey = (address) => address.toLowerCase().replace(/\+[^@]*@/, "@");
|
|
61
62
|
/**
|
|
62
|
-
* The mail each of these people sent the owner, as `senderSignalsOf` reads it. Asked for a page
|
|
63
|
-
* senders of their List-Ids tell a discussion list from a newsletter.
|
|
63
|
+
* The mail each of these people, or sender bots, sent the owner, as `senderSignalsOf` reads it. Asked for a page
|
|
64
|
+
* only: the senders of their List-Ids tell a discussion list from a newsletter.
|
|
64
65
|
*/
|
|
65
|
-
export const sentMailOf = (database, people) => {
|
|
66
|
+
export const sentMailOf = (database, people, holder = "person") => {
|
|
66
67
|
const found = new Map();
|
|
67
68
|
if (people.length === 0)
|
|
68
69
|
return found;
|
|
70
|
+
const held = holder === "person"
|
|
71
|
+
? { owner: "l.person_id", join: "identity_links l" }
|
|
72
|
+
: { owner: "l.bot_id", join: "sender_bot_identities l" };
|
|
69
73
|
const rows = database
|
|
70
|
-
.prepare(
|
|
74
|
+
.prepare(`SELECT ${held.owner} AS person, ` +
|
|
71
75
|
`${LIST_ID} AS list, json_extract(e.headers, '$."auto-submitted"') IS NOT NULL AS auto, ` +
|
|
72
76
|
"json_extract(e.headers, '$.\"null-return-path\"') IS 1 AS null_return, " +
|
|
73
77
|
"json_extract(e.headers, '$.\"list-unsubscribe-post\"') IS 1 AS one_click, " +
|
|
@@ -76,8 +80,8 @@ export const sentMailOf = (database, people) => {
|
|
|
76
80
|
"WHERE m.email_id = e.id AND b.kind = 'bulk') AS bulk, " +
|
|
77
81
|
"CASE WHEN json_extract(e.metadata, '$.rule') IS NOT NULL THEN NULL ELSE " +
|
|
78
82
|
"(SELECT count(*) FROM email_recipients r WHERE r.email_id = e.id AND r.role IN ('to', 'cc')) END AS recipients " +
|
|
79
|
-
|
|
80
|
-
|
|
83
|
+
`FROM emails e JOIN ${held.join} ON l.identity_id = e.from_identity_id ` +
|
|
84
|
+
`WHERE e.outgoing IS NOT 1 AND e.deleted_at IS NULL AND ${held.owner} IN (SELECT value FROM json_each(?))`)
|
|
81
85
|
.all(JSON.stringify(people));
|
|
82
86
|
const lists = [...new Set(rows.flatMap((row) => (typeof row.list === "string" ? [row.list] : [])))];
|
|
83
87
|
const senders = new Map();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.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",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"./update"
|
|
28
28
|
],
|
|
29
29
|
"store": {
|
|
30
|
-
"speaks":
|
|
30
|
+
"speaks": 76,
|
|
31
31
|
"minCompatible": 73
|
|
32
32
|
}
|
|
33
33
|
},
|