@wirecat/cli-core 1.0.0-rc.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 +186 -0
- package/THIRD_PARTY_NOTICES +47 -0
- package/dist/cli/account-rename.js +1 -1
- package/dist/cli/bot/api-input.d.ts +5 -0
- package/dist/cli/bot/api-input.js +6 -1
- package/dist/cli/bot/api.js +7 -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/service-api.js +3 -1
- 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/crm/manifest/map.d.ts +5 -2
- package/dist/crm/manifest/map.js +14 -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 +16 -0
- package/dist/domain/organization-sectors.generated.d.ts +12 -0
- package/dist/domain/organization-sectors.generated.js +15 -0
- package/dist/domain/organization-sectors.js +22 -0
- package/dist/domain/person-kinds.d.ts +5 -0
- 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 -1
- package/dist/entities/index.js +3 -1
- package/dist/entities/knowledge-lists.d.ts +1 -0
- package/dist/entities/knowledge-lists.js +2 -0
- package/dist/errors/reasons.js +14 -3
- package/dist/mail/mail-types.d.ts +48 -0
- package/dist/mail/mail-types.js +218 -0
- package/dist/mail/score.d.ts +2 -0
- package/dist/mail/score.js +9 -2
- 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/search-all-rank.d.ts +44 -0
- package/dist/services/search-all-rank.js +112 -0
- package/dist/services/search-all-tracker.d.ts +58 -0
- package/dist/services/search-all-tracker.js +155 -0
- package/dist/services/search-all.d.ts +1 -8
- package/dist/services/search-all.js +18 -199
- package/dist/services/tracker-meaning.js +1 -1
- package/dist/store/areas.d.ts +1 -0
- package/dist/store/index.d.ts +2 -1
- package/dist/store/index.js +1 -1
- package/dist/store/people.d.ts +30 -0
- package/dist/store/people.js +16 -1
- package/dist/store/sqlite/accounts.js +3 -1
- package/dist/store/sqlite/domain-organizations.d.ts +36 -0
- package/dist/store/sqlite/domain-organizations.js +288 -0
- 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/knowledge.d.ts +2 -9
- package/dist/store/sqlite/manifest.js +6 -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 +77 -0
- package/dist/store/sqlite/organizations.d.ts +12 -1
- package/dist/store/sqlite/organizations.js +9 -1
- package/dist/store/sqlite/people-list.js +69 -11
- package/dist/store/sqlite/person-links.js +13 -3
- package/dist/store/sqlite/person-match-scan.js +14 -1
- package/dist/store/sqlite/schema/sender-bots.d.ts +344 -0
- package/dist/store/sqlite/schema/sender-bots.js +30 -0
- package/dist/store/sqlite/schema.d.ts +49 -0
- package/dist/store/sqlite/schema.js +7 -0
- package/dist/store/sqlite/sender-bots.d.ts +108 -0
- package/dist/store/sqlite/sender-bots.js +431 -0
- package/dist/store/sqlite/sender-signals.d.ts +13 -3
- package/dist/store/sqlite/sender-signals.js +17 -13
- package/dist/store/sqlite/tracker.d.ts +11 -9
- package/dist/store/sqlite/tracker.js +27 -12
- package/dist/store/sqlite/work-tasks.js +2 -0
- package/dist/tracker/cli/index.d.ts +1 -1
- package/dist/tracker/cli/index.js +83 -24
- package/dist/tracker/sync.js +43 -20
- package/dist/tracker/writes.d.ts +28 -0
- package/dist/tracker/writes.js +141 -19
- package/package.json +3 -3
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { getDomainWithoutSuffix } from "tldts";
|
|
2
|
+
import { isReadable } from "../../domain/display-names.js";
|
|
3
|
+
import { installedPack, isPackFreeMailDomain, lookupDomains } from "../../domain/domain-lists.js";
|
|
4
|
+
import { SECTORS_BUILT } from "../../domain/organization-sectors.generated.js";
|
|
5
|
+
import { isFreeMailDomain, SECTORS, sectorOfDomain } from "../../domain/organization-sectors.js";
|
|
6
|
+
import { isCompanyName } from "../../domain/person-kinds.js";
|
|
7
|
+
import { FREE_MAIL, isDisposableDomain, registrableOf } from "../../mail/score.js";
|
|
8
|
+
import { fold } from "../normalize.js";
|
|
9
|
+
import { actorOfOrigin } from "./actors.js";
|
|
10
|
+
import { linkKind } from "./link-kinds.js";
|
|
11
|
+
/**
|
|
12
|
+
* Newsletter hosts and mail services that send for many customers. Their domain names none of the senders, so it never
|
|
13
|
+
* makes an organization; the bounce and signing domains are here for mail whose `From` carries them.
|
|
14
|
+
*/
|
|
15
|
+
export const SENDING_PLATFORMS = new Set([
|
|
16
|
+
"substack.com",
|
|
17
|
+
"beehiiv.com",
|
|
18
|
+
"ghost.io",
|
|
19
|
+
"buttondown.email",
|
|
20
|
+
"buttondown.com",
|
|
21
|
+
"mailchimpapp.net",
|
|
22
|
+
"mcsv.net",
|
|
23
|
+
"mcdlv.net",
|
|
24
|
+
"rsgsv.net",
|
|
25
|
+
"list-manage.com",
|
|
26
|
+
"mandrillapp.com",
|
|
27
|
+
"sendgrid.net",
|
|
28
|
+
"amazonses.com",
|
|
29
|
+
"mailgun.org",
|
|
30
|
+
"mailgun.net",
|
|
31
|
+
"postmarkapp.com",
|
|
32
|
+
"mtasv.net",
|
|
33
|
+
"sparkpostmail.com",
|
|
34
|
+
"convertkit-mail.com",
|
|
35
|
+
"mlsend.com",
|
|
36
|
+
"sendinblue.com",
|
|
37
|
+
"brevosend.com",
|
|
38
|
+
]);
|
|
39
|
+
/** How a rule's hold on an address is marked in `organization_identities.method`. */
|
|
40
|
+
export const BY_DOMAIN = "domain";
|
|
41
|
+
/** A rejected `proposed_actions` row of this kind keeps a rule from making an organization for its domain again. */
|
|
42
|
+
export const REFUSED_DOMAIN = "organization-domain";
|
|
43
|
+
/** The registrable domain whose organization an address joins; none for free, throwaway and platform mail. */
|
|
44
|
+
export const companyDomainOf = (address) => {
|
|
45
|
+
if (!address.includes("@"))
|
|
46
|
+
return undefined;
|
|
47
|
+
const domain = registrableOf(address);
|
|
48
|
+
return domain.includes(".") &&
|
|
49
|
+
!FREE_MAIL.has(domain) &&
|
|
50
|
+
!isFreeMailDomain(domain) &&
|
|
51
|
+
!isPackFreeMailDomain(domain) &&
|
|
52
|
+
!SENDING_PLATFORMS.has(domain) &&
|
|
53
|
+
!isDisposableDomain(domain)
|
|
54
|
+
? domain
|
|
55
|
+
: undefined;
|
|
56
|
+
};
|
|
57
|
+
const nameFor = (shown, domain) => {
|
|
58
|
+
const label = getDomainWithoutSuffix(domain);
|
|
59
|
+
return shown !== null &&
|
|
60
|
+
isReadable(shown) &&
|
|
61
|
+
(isCompanyName(shown) || (label !== null && fold(shown).trim() === fold(label)))
|
|
62
|
+
? shown.trim()
|
|
63
|
+
: domain;
|
|
64
|
+
};
|
|
65
|
+
const keyOf = (one) => `${one.bot ? "bot" : "person"}:${one.id}`;
|
|
66
|
+
const mailOf = (database, sorted) => {
|
|
67
|
+
const found = new Map();
|
|
68
|
+
const held = [
|
|
69
|
+
{ prefix: "person", sql: "SELECT l.person_id AS holder, l.identity_id FROM identity_links l" },
|
|
70
|
+
{ prefix: "bot", sql: "SELECT l.bot_id AS holder, l.identity_id FROM sender_bot_identities l" },
|
|
71
|
+
];
|
|
72
|
+
for (const { prefix, sql } of held) {
|
|
73
|
+
const ids = sorted.filter((one) => (prefix === "bot") === (one.bot === true)).map(({ id }) => id);
|
|
74
|
+
if (ids.length === 0)
|
|
75
|
+
continue;
|
|
76
|
+
for (const row of database
|
|
77
|
+
.prepare(`SELECT h.holder, i.id, lower(i.external_id) AS address FROM (${sql}) h JOIN identities i ON i.id = h.identity_id ` +
|
|
78
|
+
"WHERE i.provider = 'email' AND h.holder IN (SELECT value FROM json_each(?)) ORDER BY i.id")
|
|
79
|
+
.all(JSON.stringify(ids))) {
|
|
80
|
+
const domain = companyDomainOf(String(row.address));
|
|
81
|
+
if (domain === undefined)
|
|
82
|
+
continue;
|
|
83
|
+
const key = `${prefix}:${Number(row.holder)}`;
|
|
84
|
+
found.set(key, [...(found.get(key) ?? []), { identity: Number(row.id), domain }]);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return found;
|
|
88
|
+
};
|
|
89
|
+
/** Every organization by the company domains of the addresses it holds, and which identities are held at all. */
|
|
90
|
+
const holdersOf = (database) => {
|
|
91
|
+
const byDomain = new Map();
|
|
92
|
+
const held = new Map();
|
|
93
|
+
for (const row of database
|
|
94
|
+
.prepare("SELECT oi.identity_id, oi.organization_id, lower(i.external_id) AS address FROM organization_identities oi " +
|
|
95
|
+
"JOIN organizations o ON o.id = oi.organization_id JOIN identities i ON i.id = oi.identity_id " +
|
|
96
|
+
"WHERE o.deleted_at IS NULL AND i.provider = 'email' ORDER BY oi.id")
|
|
97
|
+
.all()) {
|
|
98
|
+
const organization = Number(row.organization_id);
|
|
99
|
+
if (!held.has(Number(row.identity_id)))
|
|
100
|
+
held.set(Number(row.identity_id), organization);
|
|
101
|
+
const domain = companyDomainOf(String(row.address));
|
|
102
|
+
if (domain !== undefined)
|
|
103
|
+
byDomain.set(domain, (byDomain.get(domain) ?? new Set()).add(organization));
|
|
104
|
+
}
|
|
105
|
+
return { byDomain, held };
|
|
106
|
+
};
|
|
107
|
+
const refusedDomains = (database) => new Set(database
|
|
108
|
+
.prepare("SELECT json_extract(payload, '$.domain') AS domain FROM proposed_actions WHERE kind = ? AND status = 'rejected'")
|
|
109
|
+
.all(REFUSED_DOMAIN)
|
|
110
|
+
.map((row) => String(row.domain)));
|
|
111
|
+
/** Person → organization pairs the owner removed: a rule never links them again. */
|
|
112
|
+
const removedMemberships = (database) => new Set(database
|
|
113
|
+
.prepare("SELECT target_id, json_extract(payload, '$.to') AS target FROM proposed_actions WHERE kind = 'relationship' " +
|
|
114
|
+
"AND status = 'rejected' AND target_type = 'person' AND json_extract(payload, '$.kind') = 'member-of' " +
|
|
115
|
+
"AND json_extract(payload, '$.to') LIKE 'organization:%'")
|
|
116
|
+
.all()
|
|
117
|
+
.map((row) => `${row.target_id}>${row.target}`));
|
|
118
|
+
/** Humans the kind pass did not see who write from one of `domains`: a new organization takes them as members too. */
|
|
119
|
+
const othersAt = (database, domains, seen) => {
|
|
120
|
+
const found = new Map();
|
|
121
|
+
for (const row of database
|
|
122
|
+
.prepare("SELECT l.person_id AS person, i.id, lower(i.external_id) AS address FROM identity_links l " +
|
|
123
|
+
"JOIN identities i ON i.id = l.identity_id JOIN persons p ON p.id = l.person_id " +
|
|
124
|
+
"WHERE i.provider = 'email' AND p.owner = 0 AND p.kind IS NOT NULL AND p.kind NOT IN ('test', 'merged') " +
|
|
125
|
+
"AND NOT EXISTS (SELECT 1 FROM organization_identities oi WHERE oi.identity_id = i.id) ORDER BY i.id")
|
|
126
|
+
.all()) {
|
|
127
|
+
const person = Number(row.person);
|
|
128
|
+
if (seen.has(person))
|
|
129
|
+
continue;
|
|
130
|
+
const domain = companyDomainOf(String(row.address));
|
|
131
|
+
if (domain === undefined || !domains.has(domain))
|
|
132
|
+
continue;
|
|
133
|
+
found.set(person, [...(found.get(person) ?? []), { identity: Number(row.id), domain }]);
|
|
134
|
+
}
|
|
135
|
+
return found;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Plan step 5: a sender bot or a shared mailbox at a company domain joins that domain's organization, made when none holds
|
|
139
|
+
* it; a human there becomes a `member-of` it, never merged. Free mail, throwaway mail and sending platforms make none.
|
|
140
|
+
* An organization holding a domain of the built-in Wikidata list or of the domain-list pack gets its `metadata.sector`.
|
|
141
|
+
* The owner's word holds: a membership the owner removed and a domain whose organization the owner erased are not made
|
|
142
|
+
* again. The caller holds the write lock.
|
|
143
|
+
*/
|
|
144
|
+
export const groupByDomain = (database, people, at) => {
|
|
145
|
+
refreshSectors(database, at);
|
|
146
|
+
const mail = mailOf(database, people);
|
|
147
|
+
if (mail.size === 0)
|
|
148
|
+
return;
|
|
149
|
+
const { byDomain, held } = holdersOf(database);
|
|
150
|
+
const refused = refusedDomains(database);
|
|
151
|
+
const created = new Set();
|
|
152
|
+
const create = database.prepare("INSERT INTO organizations (kind, name, scope, created_at, updated_at) VALUES ('company', ?, 'personal', ?, ?) " +
|
|
153
|
+
"RETURNING id");
|
|
154
|
+
const hold = database.prepare("INSERT INTO organization_identities (identity_id, organization_id, method, author, created_at, updated_at) " +
|
|
155
|
+
`VALUES (?, ?, '${BY_DOMAIN}', 'rules', ?, ?) ON CONFLICT (identity_id, organization_id) DO NOTHING`);
|
|
156
|
+
const sends = database.prepare("UPDATE sender_bots SET organization_id = ?, updated_at = ? WHERE id = ? AND organization_id IS NULL");
|
|
157
|
+
const holder = (domain) => {
|
|
158
|
+
const found = byDomain.get(domain);
|
|
159
|
+
return found?.size === 1 ? [...found][0] : undefined;
|
|
160
|
+
};
|
|
161
|
+
for (const person of people) {
|
|
162
|
+
if (!person.holds)
|
|
163
|
+
continue;
|
|
164
|
+
for (const { identity, domain } of mail.get(keyOf(person)) ?? []) {
|
|
165
|
+
let organization = held.get(identity);
|
|
166
|
+
if (organization === undefined) {
|
|
167
|
+
if ((byDomain.get(domain)?.size ?? 0) > 1)
|
|
168
|
+
continue;
|
|
169
|
+
organization = holder(domain);
|
|
170
|
+
if (organization === undefined) {
|
|
171
|
+
if (refused.has(domain))
|
|
172
|
+
continue;
|
|
173
|
+
organization = Number(create.get(nameFor(person.displayName, domain), at, at)?.id);
|
|
174
|
+
byDomain.set(domain, new Set([organization]));
|
|
175
|
+
created.add(domain);
|
|
176
|
+
}
|
|
177
|
+
hold.run(identity, organization, at, at);
|
|
178
|
+
held.set(identity, organization);
|
|
179
|
+
}
|
|
180
|
+
if (person.bot)
|
|
181
|
+
sends.run(organization, at, person.id);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
const removed = removedMemberships(database);
|
|
185
|
+
const member = database.prepare("INSERT INTO links (from_type, from_id, to_type, to_id, kind, source, confirmed, author, evidence, metadata, " +
|
|
186
|
+
`created_at, updated_at) SELECT 'person', ?, 'organization', ?, ${linkKind("member-of")}, 'owner', 1, 'rule', ?, ` +
|
|
187
|
+
`'{"derived":"mail-domain"}', ?, ? ` +
|
|
188
|
+
"WHERE NOT EXISTS (SELECT 1 FROM links WHERE from_type = 'person' AND from_id = ? AND to_type = 'organization' " +
|
|
189
|
+
`AND to_id = ? AND kind = ${linkKind("member-of")})`);
|
|
190
|
+
const join = (person, addresses) => {
|
|
191
|
+
for (const domain of new Set(addresses.map((one) => one.domain))) {
|
|
192
|
+
const organization = holder(domain);
|
|
193
|
+
if (organization === undefined || removed.has(`${person}>organization:${organization}`))
|
|
194
|
+
continue;
|
|
195
|
+
member.run(person, organization, `writes from ${domain}`, at, at, person, organization);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
const humans = people.filter((one) => !one.bot);
|
|
199
|
+
const seen = new Set(humans.map(({ id }) => id));
|
|
200
|
+
for (const person of humans)
|
|
201
|
+
if (!person.holds)
|
|
202
|
+
join(person.id, mail.get(keyOf(person)) ?? []);
|
|
203
|
+
if (created.size > 0)
|
|
204
|
+
for (const [person, addresses] of othersAt(database, created, seen))
|
|
205
|
+
join(person, addresses);
|
|
206
|
+
if (created.size > 0)
|
|
207
|
+
setSectors(database, byDomain, at, new Set([...created].flatMap((domain) => [...(byDomain.get(domain) ?? [])])));
|
|
208
|
+
};
|
|
209
|
+
/** Which lists the sectors in the store come from: this build's table and the pack in place. */
|
|
210
|
+
export const SECTORS_FROM = "organizations.sectors_from";
|
|
211
|
+
const listsVersion = () => {
|
|
212
|
+
const pack = installedPack();
|
|
213
|
+
return [SECTORS_BUILT, pack?.version ?? "none", ...Object.keys(pack?.files ?? {}).sort()].join(" ");
|
|
214
|
+
};
|
|
215
|
+
/** A newer table or pack can give a sector, change it or take it away: every organization is worked out again once. */
|
|
216
|
+
const refreshSectors = (database, at) => {
|
|
217
|
+
const version = listsVersion();
|
|
218
|
+
if (database.prepare("SELECT value FROM store_settings WHERE key = ?").get(SECTORS_FROM)?.value === version)
|
|
219
|
+
return;
|
|
220
|
+
setSectors(database, holdersOf(database).byDomain, at);
|
|
221
|
+
database
|
|
222
|
+
.prepare("INSERT OR REPLACE INTO store_settings (key, value, at) VALUES (?, ?, ?)")
|
|
223
|
+
.run(SECTORS_FROM, version, at);
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Each organization holding a company domain takes that domain's sector, the first in `SECTORS` order if several; the
|
|
227
|
+
* built-in table wins over the pack, which only fills its gaps. A rule's sector goes when no list gives one any more.
|
|
228
|
+
* `metadata.sector_by` is `rules` (or absent, as #3350 wrote it) for a rule's sector; any other value is the owner's,
|
|
229
|
+
* which no rule changes.
|
|
230
|
+
*/
|
|
231
|
+
const setSectors = (database, byDomain, at, only) => {
|
|
232
|
+
const scope = [...byDomain].filter(([, organizations]) => only === undefined || [...organizations].some((one) => only.has(one)));
|
|
233
|
+
if (scope.length === 0)
|
|
234
|
+
return;
|
|
235
|
+
const pack = lookupDomains(new Set(scope.map(([domain]) => domain))).sectors;
|
|
236
|
+
const rank = (sector, fromPack) => SECTORS.indexOf(sector) + (fromPack ? SECTORS.length : 0);
|
|
237
|
+
const found = new Map();
|
|
238
|
+
for (const [domain, organizations] of scope) {
|
|
239
|
+
const core = sectorOfDomain(domain);
|
|
240
|
+
const ranks = [
|
|
241
|
+
...(core === undefined ? [] : [rank(core, false)]),
|
|
242
|
+
...(pack.get(domain) ?? []).map((one) => rank(one, true)),
|
|
243
|
+
];
|
|
244
|
+
const best = ranks.reduce((low, one) => (low === undefined || one < low ? one : low), undefined);
|
|
245
|
+
for (const organization of organizations) {
|
|
246
|
+
if (only !== undefined && !only.has(organization))
|
|
247
|
+
continue;
|
|
248
|
+
const before = found.get(organization);
|
|
249
|
+
found.set(organization, before === undefined ? best : best === undefined ? before : Math.min(before, best));
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
const byRules = "coalesce(json_extract(metadata, '$.sector_by'), 'rules') = 'rules'";
|
|
253
|
+
const set = database.prepare("UPDATE organizations SET metadata = json_set(coalesce(metadata, '{}'), '$.sector', ?, '$.sector_by', 'rules'), " +
|
|
254
|
+
`updated_at = ? WHERE id = ? AND deleted_at IS NULL AND ${byRules} AND json_extract(metadata, '$.sector') IS NOT ?`);
|
|
255
|
+
const clear = database.prepare("UPDATE organizations SET metadata = json_remove(metadata, '$.sector', '$.sector_by'), updated_at = ? " +
|
|
256
|
+
`WHERE id = ? AND deleted_at IS NULL AND ${byRules} AND json_extract(metadata, '$.sector') IS NOT NULL`);
|
|
257
|
+
for (const [organization, ranked] of found) {
|
|
258
|
+
const sector = ranked === undefined ? undefined : SECTORS[ranked % SECTORS.length];
|
|
259
|
+
if (sector === undefined)
|
|
260
|
+
clear.run(at, organization);
|
|
261
|
+
else
|
|
262
|
+
set.run(sector, at, organization, sector);
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
/** The owner erased an organization: no rule makes one for the company domains it held again. */
|
|
266
|
+
export const refuseDomainsOf = (database, organization, at) => {
|
|
267
|
+
const domains = new Set(database
|
|
268
|
+
.prepare("SELECT lower(i.external_id) AS address FROM organization_identities oi JOIN identities i ON i.id = oi.identity_id " +
|
|
269
|
+
"WHERE oi.organization_id = ? AND i.provider = 'email'")
|
|
270
|
+
.all(organization)
|
|
271
|
+
.flatMap((row) => companyDomainOf(String(row.address)) ?? []));
|
|
272
|
+
if (domains.size === 0)
|
|
273
|
+
return;
|
|
274
|
+
const rule = actorOfOrigin(database, "rule");
|
|
275
|
+
const owner = database.prepare("SELECT id FROM persons WHERE owner = 1 ORDER BY id LIMIT 1").get();
|
|
276
|
+
const refuse = database.prepare("INSERT INTO proposed_actions (kind, payload, reason, status, proposed_by_type, proposed_by_id, decided_by_type, " +
|
|
277
|
+
"decided_by_id, decided_at, created_at, updated_at) VALUES (?, ?, ?, 'rejected', ?, ?, ?, ?, ?, ?, ?)");
|
|
278
|
+
const already = refusedDomains(database);
|
|
279
|
+
for (const domain of [...domains].filter((one) => !already.has(one)))
|
|
280
|
+
refuse.run(REFUSED_DOMAIN, JSON.stringify({ domain }), `the owner erased organization:${organization}`, rule.type, rule.id, owner === undefined ? null : "person", owner === undefined ? null : Number(owner.id), owner === undefined ? null : at, at, at);
|
|
281
|
+
};
|
|
282
|
+
/** The owner moved these identities to a person: the holds a rule gave them go, so they read as a person's again. */
|
|
283
|
+
export const releaseDomainHolds = (database, identities) => {
|
|
284
|
+
database
|
|
285
|
+
.prepare(`DELETE FROM organization_identities WHERE method = '${BY_DOMAIN}' AND author = 'rules' ` +
|
|
286
|
+
"AND identity_id IN (SELECT value FROM json_each(?))")
|
|
287
|
+
.run(JSON.stringify(identities));
|
|
288
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { type MailType, type MailTypeOf } from "../../mail/mail-types.js";
|
|
2
|
+
import { type CacheDatabase } from "../driver.js";
|
|
3
|
+
import { type Reach } from "./sender-signals.js";
|
|
4
|
+
/** The type, reach and signal of each of these emails, worked out from the store; nothing is written. */
|
|
5
|
+
/**
|
|
6
|
+
* `senders` carries each List-Id's sender count from batch to batch: a newsletter's every issue would read all its
|
|
7
|
+
* issues again.
|
|
8
|
+
*/
|
|
9
|
+
export declare const typesOf: (database: CacheDatabase, ids: readonly number[], senders?: Map<string, number>) => Map<number, MailTypeOf>;
|
|
10
|
+
/** Whether every email's stored type is current. */
|
|
11
|
+
export declare const typesCurrent: (database: CacheDatabase) => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Works out and keeps the type of every email whose stored one the triggers cleared, or every email after the rules
|
|
14
|
+
* changed, a batch per write so another process never waits long for the lock. A query-only open keeps nothing.
|
|
15
|
+
* Answers whether every stored type is current.
|
|
16
|
+
*/
|
|
17
|
+
export declare const storeMailTypes: (database: CacheDatabase) => boolean;
|
|
18
|
+
/** Each email's stored type, or for one the store has not typed yet, the type worked out for this read. */
|
|
19
|
+
export declare const withTypes: <T extends {
|
|
20
|
+
id: number;
|
|
21
|
+
mailType: MailType | null;
|
|
22
|
+
}>(database: CacheDatabase, emails: T[]) => T[];
|
|
23
|
+
/** Which emails a filter by type and reach keeps. @experimental */
|
|
24
|
+
export interface TypeFilter {
|
|
25
|
+
types?: readonly MailType[];
|
|
26
|
+
reaches?: readonly Reach[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The SQL of a filter by type and reach over `e`. Types are worked out and kept first; a query-only open that finds
|
|
30
|
+
* some not worked out works those out in memory, so a filtered list is never short.
|
|
31
|
+
*/
|
|
32
|
+
export declare const typeWhere: (database: CacheDatabase, filter: TypeFilter) => {
|
|
33
|
+
sql: string[];
|
|
34
|
+
params: string[];
|
|
35
|
+
};
|
|
36
|
+
/** One sender's mail, counted by type and reach: a shop's receipts and its sales side by side. @experimental */
|
|
37
|
+
export interface SenderMailTypes {
|
|
38
|
+
/** `person:<id>`, `sender-bot:<id>`, or `null` when the store links the address to neither. */
|
|
39
|
+
ref: string | null;
|
|
40
|
+
/** The addresses it sent from, lower case. */
|
|
41
|
+
addresses: string[];
|
|
42
|
+
/** The display name on its newest email. */
|
|
43
|
+
name: string | null;
|
|
44
|
+
/** Its live emails the filter's account and time take in. */
|
|
45
|
+
emails: number;
|
|
46
|
+
types: Partial<Record<MailType, number>>;
|
|
47
|
+
reaches: Partial<Record<Reach, number>>;
|
|
48
|
+
/** Its newest email, ms. */
|
|
49
|
+
lastAt: number | null;
|
|
50
|
+
}
|
|
51
|
+
/** Which senders `mailSenders` lists: those with at least one email of these types and reaches. @experimental */
|
|
52
|
+
export interface SenderTypesFilter extends TypeFilter {
|
|
53
|
+
accountId?: number;
|
|
54
|
+
since?: number;
|
|
55
|
+
until?: number;
|
|
56
|
+
limit?: number;
|
|
57
|
+
offset?: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Every sender of incoming mail with its mail counted by type and reach, most mail first. A sender is listed when
|
|
61
|
+
* any of its emails passes `types` and `reaches`, and its counts cover all its mail: Subscriptions shows a shop by
|
|
62
|
+
* its sales and still says it also sends receipts.
|
|
63
|
+
*/
|
|
64
|
+
export declare const mailSenders: (database: CacheDatabase, filter: SenderTypesFilter) => {
|
|
65
|
+
items: SenderMailTypes[];
|
|
66
|
+
total: number;
|
|
67
|
+
};
|
|
68
|
+
/** @experimental */
|
|
69
|
+
export interface MailTypeStore {
|
|
70
|
+
/**
|
|
71
|
+
* Senders of incoming mail with their mail counted by type and reach, most mail first; a sender is listed when any of
|
|
72
|
+
* its emails passes `types` and `reaches`.
|
|
73
|
+
*/
|
|
74
|
+
mailSenders(filter?: SenderTypesFilter): Promise<{
|
|
75
|
+
items: SenderMailTypes[];
|
|
76
|
+
total: number;
|
|
77
|
+
}>;
|
|
78
|
+
}
|
|
79
|
+
export declare const mailTypeStore: (database: CacheDatabase) => MailTypeStore;
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { SENDER_BOT_PREFIX } from "../../domain/person-kinds.js";
|
|
2
|
+
import { MAIL_TYPES, mailTypeOf, schemaTypesOf } from "../../mail/mail-types.js";
|
|
3
|
+
import { isQueryOnly } from "../driver.js";
|
|
4
|
+
import { LIST_ID, LIST_SENDERS, REACHES, senderKey } from "./sender-signals.js";
|
|
5
|
+
import { read, writeBatch } from "./transaction.js";
|
|
6
|
+
/** Bump when what decides a mail type changes in code: every stored one is worked out again on the next read. */
|
|
7
|
+
const TYPE_RULES = "1";
|
|
8
|
+
const RULES_KEY = "mail.type_rules";
|
|
9
|
+
/**
|
|
10
|
+
* Working out 5,000 types takes about 40 ms; the commit's sync to disk costs more, so fewer and larger batches finish
|
|
11
|
+
* sooner and still hold the lock well inside another writer's 5 s wait.
|
|
12
|
+
*/
|
|
13
|
+
const BATCH = 5_000;
|
|
14
|
+
const INPUTS = "SELECT e.id, e.from_address, e.subject, e.headers, e.body_html, " +
|
|
15
|
+
`${LIST_ID} AS list, ` +
|
|
16
|
+
"CASE WHEN json_extract(e.metadata, '$.rule') IS NOT NULL THEN NULL ELSE " +
|
|
17
|
+
"(SELECT count(*) FROM email_recipients r WHERE r.email_id = e.id AND r.role IN ('to', 'cc')) END AS recipients, " +
|
|
18
|
+
"(SELECT json_group_array(lower(a.mime)) FROM attachments a " +
|
|
19
|
+
"WHERE a.attachable_type = 'email' AND a.attachable_id = e.id AND a.mime IS NOT NULL) AS parts, " +
|
|
20
|
+
"e.outgoing IS 1 OR EXISTS (SELECT 1 FROM email_recipients r JOIN emails o ON o.id = r.email_id " +
|
|
21
|
+
"WHERE r.identity_id = e.from_identity_id AND o.outgoing = 1) AS owner_wrote, " +
|
|
22
|
+
"EXISTS (SELECT 1 FROM sender_bot_identities b WHERE b.identity_id = e.from_identity_id) AS bot, " +
|
|
23
|
+
"(SELECT json_extract(g.metadata, '$.sector') FROM organization_identities oi " +
|
|
24
|
+
"JOIN organizations g ON g.id = oi.organization_id " +
|
|
25
|
+
"WHERE oi.identity_id = e.from_identity_id AND g.deleted_at IS NULL ORDER BY g.id LIMIT 1) AS sector " +
|
|
26
|
+
"FROM emails e WHERE e.id IN (SELECT value FROM json_each(?))";
|
|
27
|
+
const parsed = (value) => {
|
|
28
|
+
if (typeof value !== "string")
|
|
29
|
+
return {};
|
|
30
|
+
try {
|
|
31
|
+
const found = JSON.parse(value);
|
|
32
|
+
return found !== null && typeof found === "object" && !Array.isArray(found)
|
|
33
|
+
? found
|
|
34
|
+
: {};
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
/** The type, reach and signal of each of these emails, worked out from the store; nothing is written. */
|
|
41
|
+
/**
|
|
42
|
+
* `senders` carries each List-Id's sender count from batch to batch: a newsletter's every issue would read all its
|
|
43
|
+
* issues again.
|
|
44
|
+
*/
|
|
45
|
+
export const typesOf = (database, ids, senders = new Map()) => {
|
|
46
|
+
const found = new Map();
|
|
47
|
+
if (ids.length === 0)
|
|
48
|
+
return found;
|
|
49
|
+
const rows = database.prepare(INPUTS).all(JSON.stringify(ids));
|
|
50
|
+
const lists = [
|
|
51
|
+
...new Set(rows.flatMap((row) => (typeof row.list === "string" && !senders.has(row.list) ? [row.list] : []))),
|
|
52
|
+
];
|
|
53
|
+
if (lists.length > 0) {
|
|
54
|
+
const held = new Map(lists.map((list) => [list, new Set()]));
|
|
55
|
+
for (const row of database.prepare(LIST_SENDERS).all(JSON.stringify(lists)))
|
|
56
|
+
held.get(String(row.list))?.add(senderKey(String(row.address)));
|
|
57
|
+
for (const [list, addresses] of held)
|
|
58
|
+
senders.set(list, addresses.size);
|
|
59
|
+
}
|
|
60
|
+
for (const row of rows) {
|
|
61
|
+
const headers = parsed(row.headers);
|
|
62
|
+
found.set(Number(row.id), mailTypeOf({
|
|
63
|
+
from: typeof row.from_address === "string" ? row.from_address.toLowerCase() : null,
|
|
64
|
+
subject: typeof row.subject === "string" ? row.subject : null,
|
|
65
|
+
headers: typeof row.list === "string" ? { ...headers, "list-id": row.list } : headers,
|
|
66
|
+
recipients: row.recipients == null ? null : Number(row.recipients),
|
|
67
|
+
parts: JSON.parse(String(row.parts ?? "[]")),
|
|
68
|
+
schemaTypes: schemaTypesOf(typeof row.body_html === "string" ? row.body_html : null),
|
|
69
|
+
listSenders: typeof row.list === "string" ? (senders.get(row.list) ?? 0) : 0,
|
|
70
|
+
ownerWrote: Number(row.owner_wrote) === 1,
|
|
71
|
+
bot: Number(row.bot) === 1,
|
|
72
|
+
sector: typeof row.sector === "string" ? row.sector : null,
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
return found;
|
|
76
|
+
};
|
|
77
|
+
const rulesOf = (database) => {
|
|
78
|
+
const row = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(RULES_KEY);
|
|
79
|
+
return row === undefined ? undefined : String(row.value);
|
|
80
|
+
};
|
|
81
|
+
const anyLeft = (database) => database.prepare("SELECT 1 FROM emails WHERE mail_type IS NULL LIMIT 1").get() !== undefined;
|
|
82
|
+
/** Whether every email's stored type is current. */
|
|
83
|
+
export const typesCurrent = (database) => rulesOf(database) === TYPE_RULES && !anyLeft(database);
|
|
84
|
+
/**
|
|
85
|
+
* Works out and keeps the type of every email whose stored one the triggers cleared, or every email after the rules
|
|
86
|
+
* changed, a batch per write so another process never waits long for the lock. A query-only open keeps nothing.
|
|
87
|
+
* Answers whether every stored type is current.
|
|
88
|
+
*/
|
|
89
|
+
export const storeMailTypes = (database) => {
|
|
90
|
+
if (isQueryOnly(database))
|
|
91
|
+
return typesCurrent(database);
|
|
92
|
+
if (rulesOf(database) !== TYPE_RULES)
|
|
93
|
+
writeBatch(database, () => {
|
|
94
|
+
if (rulesOf(database) === TYPE_RULES)
|
|
95
|
+
return;
|
|
96
|
+
database
|
|
97
|
+
.prepare("UPDATE emails SET mail_type = NULL, reach = NULL, type_signal = NULL WHERE mail_type IS NOT NULL")
|
|
98
|
+
.run();
|
|
99
|
+
database
|
|
100
|
+
.prepare("INSERT INTO store_settings (key, value, at) VALUES (?, ?, ?) " +
|
|
101
|
+
"ON CONFLICT (key) DO UPDATE SET value = excluded.value, at = excluded.at")
|
|
102
|
+
.run(RULES_KEY, TYPE_RULES, Date.now());
|
|
103
|
+
});
|
|
104
|
+
const keep = database.prepare("UPDATE emails SET mail_type = ?, reach = ?, type_signal = ? WHERE id = ?");
|
|
105
|
+
const senders = new Map();
|
|
106
|
+
for (;;) {
|
|
107
|
+
const more = writeBatch(database, () => {
|
|
108
|
+
const ids = database
|
|
109
|
+
.prepare("SELECT id FROM emails WHERE mail_type IS NULL LIMIT ?")
|
|
110
|
+
.all(BATCH)
|
|
111
|
+
.map((row) => Number(row.id));
|
|
112
|
+
for (const [id, { type, reach, signal }] of typesOf(database, ids, senders))
|
|
113
|
+
keep.run(type, reach, signal, id);
|
|
114
|
+
return ids.length === BATCH;
|
|
115
|
+
});
|
|
116
|
+
if (!more)
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
/** Each email's stored type, or for one the store has not typed yet, the type worked out for this read. */
|
|
121
|
+
export const withTypes = (database, emails) => {
|
|
122
|
+
const missing = emails.filter((email) => email.mailType === null).map((email) => email.id);
|
|
123
|
+
if (missing.length === 0)
|
|
124
|
+
return emails;
|
|
125
|
+
const found = read(database, () => typesOf(database, missing));
|
|
126
|
+
return emails.map((email) => {
|
|
127
|
+
const typed = found.get(email.id);
|
|
128
|
+
return typed === undefined
|
|
129
|
+
? email
|
|
130
|
+
: { ...email, mailType: typed.type, reach: typed.reach, typeSignal: typed.signal };
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
const passes = (filter, type, reach) => (filter.types === undefined || filter.types.includes(type)) &&
|
|
134
|
+
(filter.reaches === undefined || filter.reaches.includes(reach));
|
|
135
|
+
/**
|
|
136
|
+
* The SQL of a filter by type and reach over `e`. Types are worked out and kept first; a query-only open that finds
|
|
137
|
+
* some not worked out works those out in memory, so a filtered list is never short.
|
|
138
|
+
*/
|
|
139
|
+
export const typeWhere = (database, filter) => {
|
|
140
|
+
if (filter.types === undefined && filter.reaches === undefined)
|
|
141
|
+
return { sql: [], params: [] };
|
|
142
|
+
const stored = [
|
|
143
|
+
...(filter.types === undefined ? [] : ["e.mail_type IN (SELECT value FROM json_each(?))"]),
|
|
144
|
+
...(filter.reaches === undefined ? [] : ["e.reach IN (SELECT value FROM json_each(?))"]),
|
|
145
|
+
].join(" AND ");
|
|
146
|
+
const params = [
|
|
147
|
+
...(filter.types === undefined ? [] : [JSON.stringify(filter.types)]),
|
|
148
|
+
...(filter.reaches === undefined ? [] : [JSON.stringify(filter.reaches)]),
|
|
149
|
+
];
|
|
150
|
+
if (storeMailTypes(database))
|
|
151
|
+
return { sql: [stored], params };
|
|
152
|
+
const pending = read(database, () => {
|
|
153
|
+
const ids = database
|
|
154
|
+
.prepare("SELECT id FROM emails WHERE mail_type IS NULL")
|
|
155
|
+
.all()
|
|
156
|
+
.map((row) => Number(row.id));
|
|
157
|
+
const kept = [];
|
|
158
|
+
const senders = new Map();
|
|
159
|
+
for (let at = 0; at < ids.length; at += BATCH)
|
|
160
|
+
for (const [id, typed] of typesOf(database, ids.slice(at, at + BATCH), senders))
|
|
161
|
+
if (passes(filter, typed.type, typed.reach))
|
|
162
|
+
kept.push(id);
|
|
163
|
+
return kept;
|
|
164
|
+
});
|
|
165
|
+
return {
|
|
166
|
+
sql: [`((${stored}) OR e.id IN (SELECT value FROM json_each(?)))`],
|
|
167
|
+
params: [...params, JSON.stringify(pending)],
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
const SENDER_ROWS = "SELECT e.id, lower(e.from_address) AS address, e.from_name AS name, e.mail_type, e.reach, " +
|
|
171
|
+
"coalesce(e.received_at, e.sent_at) AS at, b.bot_id, l.person_id " +
|
|
172
|
+
"FROM emails e LEFT JOIN sender_bot_identities b ON b.identity_id = e.from_identity_id " +
|
|
173
|
+
"LEFT JOIN identity_links l ON l.identity_id = e.from_identity_id AND b.bot_id IS NULL " +
|
|
174
|
+
"WHERE e.deleted_at IS NULL AND e.outgoing IS NOT 1 AND e.from_address IS NOT NULL";
|
|
175
|
+
/**
|
|
176
|
+
* Every sender of incoming mail with its mail counted by type and reach, most mail first. A sender is listed when
|
|
177
|
+
* any of its emails passes `types` and `reaches`, and its counts cover all its mail: Subscriptions shows a shop by
|
|
178
|
+
* its sales and still says it also sends receipts.
|
|
179
|
+
*/
|
|
180
|
+
export const mailSenders = (database, filter) => {
|
|
181
|
+
const complete = storeMailTypes(database);
|
|
182
|
+
const where = [];
|
|
183
|
+
const params = [];
|
|
184
|
+
const add = (sql, value) => {
|
|
185
|
+
if (value === undefined)
|
|
186
|
+
return;
|
|
187
|
+
where.push(sql);
|
|
188
|
+
params.push(value);
|
|
189
|
+
};
|
|
190
|
+
add("e.account_id = ?", filter.accountId);
|
|
191
|
+
add("coalesce(e.received_at, e.sent_at) >= ?", filter.since);
|
|
192
|
+
add("coalesce(e.received_at, e.sent_at) < ?", filter.until);
|
|
193
|
+
const rows = read(database, () => {
|
|
194
|
+
const all = database.prepare([SENDER_ROWS, ...where].join(" AND ")).all(...params);
|
|
195
|
+
if (complete)
|
|
196
|
+
return all;
|
|
197
|
+
const missing = all.filter((row) => row.mail_type == null).map((row) => Number(row.id));
|
|
198
|
+
const found = new Map();
|
|
199
|
+
const senders = new Map();
|
|
200
|
+
for (let at = 0; at < missing.length; at += BATCH)
|
|
201
|
+
for (const [id, typed] of typesOf(database, missing.slice(at, at + BATCH), senders))
|
|
202
|
+
found.set(id, typed);
|
|
203
|
+
return all.map((row) => {
|
|
204
|
+
const typed = found.get(Number(row.id));
|
|
205
|
+
return typed === undefined ? row : { ...row, mail_type: typed.type, reach: typed.reach };
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
const tallies = new Map();
|
|
209
|
+
for (const row of rows) {
|
|
210
|
+
const address = String(row.address);
|
|
211
|
+
const ref = row.bot_id != null
|
|
212
|
+
? `${SENDER_BOT_PREFIX}${row.bot_id}`
|
|
213
|
+
: row.person_id != null
|
|
214
|
+
? `person:${row.person_id}`
|
|
215
|
+
: null;
|
|
216
|
+
const key = ref ?? `address:${address}`;
|
|
217
|
+
const at = row.at == null ? null : Number(row.at);
|
|
218
|
+
const tally = tallies.get(key) ?? {
|
|
219
|
+
ref,
|
|
220
|
+
addresses: [],
|
|
221
|
+
name: null,
|
|
222
|
+
emails: 0,
|
|
223
|
+
types: {},
|
|
224
|
+
reaches: {},
|
|
225
|
+
lastAt: null,
|
|
226
|
+
matched: false,
|
|
227
|
+
};
|
|
228
|
+
const type = String(row.mail_type);
|
|
229
|
+
const reach = String(row.reach);
|
|
230
|
+
if (!tally.addresses.includes(address))
|
|
231
|
+
tally.addresses.push(address);
|
|
232
|
+
if (at !== null && (tally.lastAt === null || at >= tally.lastAt)) {
|
|
233
|
+
tally.lastAt = at;
|
|
234
|
+
tally.name = typeof row.name === "string" ? row.name : tally.name;
|
|
235
|
+
}
|
|
236
|
+
tally.emails += 1;
|
|
237
|
+
tally.types[type] = (tally.types[type] ?? 0) + 1;
|
|
238
|
+
tally.reaches[reach] = (tally.reaches[reach] ?? 0) + 1;
|
|
239
|
+
if (passes(filter, type, reach))
|
|
240
|
+
tally.matched = true;
|
|
241
|
+
tallies.set(key, tally);
|
|
242
|
+
}
|
|
243
|
+
const listed = [...tallies.values()]
|
|
244
|
+
.filter((tally) => tally.matched)
|
|
245
|
+
.sort((a, b) => b.emails - a.emails || (b.lastAt ?? 0) - (a.lastAt ?? 0))
|
|
246
|
+
.map(({ matched: _, ...tally }) => ({
|
|
247
|
+
...tally,
|
|
248
|
+
addresses: tally.addresses.sort(),
|
|
249
|
+
types: ordered(tally.types, MAIL_TYPES),
|
|
250
|
+
reaches: ordered(tally.reaches, REACHES),
|
|
251
|
+
}));
|
|
252
|
+
const offset = filter.offset ?? 0;
|
|
253
|
+
return {
|
|
254
|
+
items: listed.slice(offset, filter.limit === undefined ? undefined : offset + filter.limit),
|
|
255
|
+
total: listed.length,
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
const ordered = (counts, order) => Object.fromEntries(order.flatMap((key) => (counts[key] === undefined ? [] : [[key, counts[key]]])));
|
|
259
|
+
export const mailTypeStore = (database) => ({
|
|
260
|
+
mailSenders: async (filter = {}) => mailSenders(database, filter),
|
|
261
|
+
});
|