@happyvertical/smrt-messages 0.62.12 → 0.62.13

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.
Files changed (47) hide show
  1. package/AGENTS.md +6 -0
  2. package/agents/mail-search.md +40 -0
  3. package/dist/chunks/{AttachmentCollection-gv5YpGPo.js → AttachmentCollection-Dzz2iKjx.js} +4 -4
  4. package/dist/chunks/{AttachmentCollection-gv5YpGPo.js.map → AttachmentCollection-Dzz2iKjx.js.map} +1 -1
  5. package/dist/chunks/{Email---ifczUW.js → Email-DDMgkm_l.js} +11 -6
  6. package/dist/chunks/Email-DDMgkm_l.js.map +1 -0
  7. package/dist/chunks/EmailAccountCollection-CgZE9YAM.js +1992 -0
  8. package/dist/chunks/EmailAccountCollection-CgZE9YAM.js.map +1 -0
  9. package/dist/chunks/{EmailCollection-CHINTmyA.js → EmailCollection-lo8WePl-.js} +18 -3
  10. package/dist/chunks/EmailCollection-lo8WePl-.js.map +1 -0
  11. package/dist/chunks/{EmailFolder-C_H8u6bS.js → EmailFolder-Bu7y8-VX.js} +6 -6
  12. package/dist/chunks/{EmailFolder-C_H8u6bS.js.map → EmailFolder-Bu7y8-VX.js.map} +1 -1
  13. package/dist/chunks/{EmailFolderCollection-B83qLC-c.js → EmailFolderCollection-BpzzKBhM.js} +2 -2
  14. package/dist/chunks/{EmailFolderCollection-B83qLC-c.js.map → EmailFolderCollection-BpzzKBhM.js.map} +1 -1
  15. package/dist/chunks/{Message-Ccqg6BLO.js → Message-BwW51pgG.js} +6 -6
  16. package/dist/chunks/{Message-Ccqg6BLO.js.map → Message-BwW51pgG.js.map} +1 -1
  17. package/dist/chunks/{MessageCollection-BnHCLi1Q.js → MessageCollection-JjZybSMu.js} +2 -2
  18. package/dist/chunks/{MessageCollection-BnHCLi1Q.js.map → MessageCollection-JjZybSMu.js.map} +1 -1
  19. package/dist/chunks/{MessagingEndpointCollection-CHzGhkeL.js → MessagingEndpointCollection-FmbtiFJy.js} +2 -2
  20. package/dist/chunks/{MessagingEndpointCollection-CHzGhkeL.js.map → MessagingEndpointCollection-FmbtiFJy.js.map} +1 -1
  21. package/dist/collections/CorrespondentCollection.d.ts +6 -0
  22. package/dist/collections/CorrespondentCollection.d.ts.map +1 -0
  23. package/dist/collections/EmailCollection.d.ts +14 -0
  24. package/dist/collections/EmailCollection.d.ts.map +1 -1
  25. package/dist/connect.js +1 -1
  26. package/dist/index.d.ts +4 -0
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +843 -12
  29. package/dist/index.js.map +1 -1
  30. package/dist/manifest.json +557 -2
  31. package/dist/models/Correspondent.d.ts +63 -0
  32. package/dist/models/Correspondent.d.ts.map +1 -0
  33. package/dist/models/Email.d.ts.map +1 -1
  34. package/dist/services/CorrespondentService.d.ts +113 -0
  35. package/dist/services/CorrespondentService.d.ts.map +1 -0
  36. package/dist/services/MailSearchService.d.ts +127 -0
  37. package/dist/services/MailSearchService.d.ts.map +1 -0
  38. package/dist/smrt-knowledge.json +184 -9
  39. package/dist/smrt-knowledge.okf.md +9 -3
  40. package/dist/svelte/components/RecipientInput.svelte +54 -0
  41. package/dist/svelte/components/RecipientInput.svelte.d.ts +6 -0
  42. package/dist/svelte/components/RecipientInput.svelte.d.ts.map +1 -1
  43. package/package.json +11 -11
  44. package/dist/chunks/Email---ifczUW.js.map +0 -1
  45. package/dist/chunks/EmailAccountCollection-DkvT4tdP.js +0 -1992
  46. package/dist/chunks/EmailAccountCollection-DkvT4tdP.js.map +0 -1
  47. package/dist/chunks/EmailCollection-CHINTmyA.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,15 +1,15 @@
1
- import { A as MESSAGING_PERMISSION_DEFINITIONS, C as mailScopePermission, D as MANAGE_MESSAGE_CREDENTIALS_PERMISSION, E as withoutListBounds, F as seedMessagesRolePermissions, M as assertMessagingPermission, N as ensureMessagingPermissionsRegistered, O as MANAGE_MESSAGE_ROUTES_PERMISSION, P as messagingPrincipalFromPermissions, S as learnMailAccessOptions, T as runWithMailSystemAccess, _ as deniedMailAccountIds, b as inMailSystemAccess, c as MAIL_ACCOUNT_RESOURCE_TYPE, d as MailAccessService, f as assertHydratedMailAccess, g as decideMailAccess, h as configureMailAccess, i as AccountCollection, j as SEND_MESSAGES_PERMISSION, k as MESSAGES_ROLE_PERMISSION_MATRIX, l as MAIL_SCOPES, m as canAccessMailAccount, o as MailWriteBackUnsupportedError, p as assertMailAccess, r as EmailAccount, s as Account, t as EmailAccountCollection, u as MailAccessError, v as getEffectiveMailAccessConfigs, w as resetMailAccess, x as isMailScope, y as getMailAccessConfig } from "./chunks/EmailAccountCollection-DkvT4tdP.js";
1
+ import { A as MESSAGING_PERMISSION_DEFINITIONS, C as mailScopePermission, D as MANAGE_MESSAGE_CREDENTIALS_PERMISSION, E as withoutListBounds, F as seedMessagesRolePermissions, M as assertMessagingPermission, N as ensureMessagingPermissionsRegistered, O as MANAGE_MESSAGE_ROUTES_PERMISSION, P as messagingPrincipalFromPermissions, S as learnMailAccessOptions, T as runWithMailSystemAccess, _ as deniedMailAccountIds, b as inMailSystemAccess, c as MAIL_ACCOUNT_RESOURCE_TYPE, d as MailAccessService, f as assertHydratedMailAccess, g as decideMailAccess, h as configureMailAccess, i as AccountCollection, j as SEND_MESSAGES_PERMISSION, k as MESSAGES_ROLE_PERMISSION_MATRIX, l as MAIL_SCOPES, m as canAccessMailAccount, o as MailWriteBackUnsupportedError, p as assertMailAccess, r as EmailAccount, s as Account, t as EmailAccountCollection, u as MailAccessError, v as getEffectiveMailAccessConfigs, w as resetMailAccess, x as isMailScope, y as getMailAccessConfig } from "./chunks/EmailAccountCollection-CgZE9YAM.js";
2
2
  import { buildSqliteRebuildStatements, isDeepStrictEqual, normalizeIdentityEmail, queryGlobal, queryWithGlobals, readNotificationProfile, withSystemContext, withTenant } from "./host.js";
3
- import { r as Attachment, t as AttachmentCollection } from "./chunks/AttachmentCollection-gv5YpGPo.js";
4
- import { t as EmailFolder } from "./chunks/EmailFolder-C_H8u6bS.js";
3
+ import { r as Attachment, t as AttachmentCollection } from "./chunks/AttachmentCollection-Dzz2iKjx.js";
4
+ import { t as EmailFolder } from "./chunks/EmailFolder-Bu7y8-VX.js";
5
5
  import { d as withProtectedNotificationHandoff, f as PROFILE_NOTIFICATION_POLICY_PREFIX, l as protectedNotificationMetadata, m as profileNotificationPolicy, p as assertNotificationRecipientIdentity, t as ProtectedNotificationHandoffError } from "./chunks/protected-notification-handoff-mvaEZVp7.js";
6
- import { t as Message } from "./chunks/Message-Ccqg6BLO.js";
6
+ import { t as Message } from "./chunks/Message-BwW51pgG.js";
7
7
  import { a as registerMessagingProvider, n as getMessagingProvider, o as ZulipSender, r as listMessagingProviders, s as TelegramSender, t as ensureBuiltinMessagingProvidersRegistered } from "./chunks/providers-Bz_F_ywF.js";
8
- import { t as MessageCollection } from "./chunks/MessageCollection-BnHCLi1Q.js";
9
- import { r as MessagingEndpoint, t as MessagingEndpointCollection } from "./chunks/MessagingEndpointCollection-CHzGhkeL.js";
10
- import { t as Email } from "./chunks/Email---ifczUW.js";
11
- import { t as EmailCollection } from "./chunks/EmailCollection-CHINTmyA.js";
12
- import { t as EmailFolderCollection } from "./chunks/EmailFolderCollection-B83qLC-c.js";
8
+ import { t as MessageCollection } from "./chunks/MessageCollection-JjZybSMu.js";
9
+ import { r as MessagingEndpoint, t as MessagingEndpointCollection } from "./chunks/MessagingEndpointCollection-FmbtiFJy.js";
10
+ import { t as Email } from "./chunks/Email-DDMgkm_l.js";
11
+ import { t as EmailCollection } from "./chunks/EmailCollection-lo8WePl-.js";
12
+ import { t as EmailFolderCollection } from "./chunks/EmailFolderCollection-BpzzKBhM.js";
13
13
  import { t as EmailSender } from "./chunks/EmailSender-B-Rtq9du.js";
14
14
  import { t as SlackSender } from "./chunks/SlackSender-CetlSe6D.js";
15
15
  import { t as TweetSender } from "./chunks/TweetSender-Dw-TDxIB.js";
@@ -98,7 +98,7 @@ function createMailAccessInterceptor() {
98
98
  const row = instance;
99
99
  row.accountId = null;
100
100
  if (!row.messageId || !row.options) return;
101
- const { MessageCollection } = await import("./chunks/MessageCollection-BnHCLi1Q.js").then((n) => n.n);
101
+ const { MessageCollection } = await import("./chunks/MessageCollection-JjZybSMu.js").then((n) => n.n);
102
102
  row.accountId = (await runWithMailSystemAccess(async () => (await MessageCollection.create(row.options)).get({ id: row.messageId })))?.accountId || null;
103
103
  },
104
104
  async afterList(className, results, context) {
@@ -199,6 +199,107 @@ async function enqueueDueMailSyncs(accounts, options = {}) {
199
199
  return queued;
200
200
  }
201
201
  //#endregion
202
+ //#region src/models/Correspondent.ts
203
+ var __defProp$12 = Object.defineProperty;
204
+ var __getOwnPropDesc$12 = Object.getOwnPropertyDescriptor;
205
+ var __defNormalProp$12 = (obj, key, value) => key in obj ? __defProp$12(obj, key, {
206
+ enumerable: true,
207
+ configurable: true,
208
+ writable: true,
209
+ value
210
+ }) : obj[key] = value;
211
+ var __decorateClass$12 = (decorators, target, key, kind) => {
212
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$12(target, key) : target;
213
+ for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
214
+ if (kind && result) __defProp$12(target, key, result);
215
+ return result;
216
+ };
217
+ var __publicField$12 = (obj, key, value) => __defNormalProp$12(obj, typeof key !== "symbol" ? key + "" : key, value);
218
+ var Correspondent = class extends SmrtObject {
219
+ tenantId = "";
220
+ ownerUserId = "";
221
+ address = "";
222
+ /** The most recent name mail used for this address; may be empty. */
223
+ displayName = "";
224
+ /** Messages the owner can read that mention this address. */
225
+ messageCount = 0;
226
+ /** Of those, messages sent by this address. */
227
+ sentCount = 0;
228
+ /** Of those, messages sent to or copied to this address. */
229
+ receivedCount = 0;
230
+ firstContactAt = null;
231
+ lastContactAt = null;
232
+ /** JSON array of mail account ids the address was seen in. */
233
+ accountIds = "[]";
234
+ /**
235
+ * JSON object keyed by mail account id with that account's own sent and
236
+ * received counts, first/last contact, and latest name. The service builds
237
+ * every view from the accounts the viewer can read only; the top-level
238
+ * counts above are totals kept for storage and are never shown on their own.
239
+ */
240
+ accountBreakdown = "{}";
241
+ profileId = null;
242
+ constructor(options = {}) {
243
+ super(options);
244
+ if (options.tenantId !== void 0) this.tenantId = options.tenantId;
245
+ if (options.ownerUserId !== void 0) this.ownerUserId = options.ownerUserId;
246
+ if (options.address !== void 0) this.address = options.address;
247
+ if (options.displayName !== void 0) this.displayName = options.displayName;
248
+ if (options.messageCount !== void 0) this.messageCount = options.messageCount;
249
+ if (options.sentCount !== void 0) this.sentCount = options.sentCount;
250
+ if (options.receivedCount !== void 0) this.receivedCount = options.receivedCount;
251
+ if (options.firstContactAt !== void 0) this.firstContactAt = options.firstContactAt;
252
+ if (options.lastContactAt !== void 0) this.lastContactAt = options.lastContactAt;
253
+ if (options.accountIds !== void 0) this.accountIds = options.accountIds;
254
+ if (options.accountBreakdown !== void 0) this.accountBreakdown = options.accountBreakdown;
255
+ if (options.profileId !== void 0) this.profileId = options.profileId;
256
+ }
257
+ /** Account ids this address was seen in (empty on unreadable JSON). */
258
+ get seenInAccountIds() {
259
+ try {
260
+ const parsed = JSON.parse(this.accountIds || "[]");
261
+ return Array.isArray(parsed) ? parsed.filter((id) => typeof id === "string") : [];
262
+ } catch {
263
+ return [];
264
+ }
265
+ }
266
+ };
267
+ __publicField$12(Correspondent, "__smrtPackage__", "@happyvertical/smrt-messages");
268
+ __decorateClass$12([tenantId()], Correspondent.prototype, "tenantId", 2);
269
+ __decorateClass$12([crossPackageRef("@happyvertical/smrt-users:User", {
270
+ required: true,
271
+ requiredFor: "identity"
272
+ })], Correspondent.prototype, "ownerUserId", 2);
273
+ __decorateClass$12([field({
274
+ required: true,
275
+ requiredFor: "identity"
276
+ })], Correspondent.prototype, "address", 2);
277
+ __decorateClass$12([crossPackageRef("@happyvertical/smrt-profiles:Profile", { nullable: true })], Correspondent.prototype, "profileId", 2);
278
+ Correspondent = __decorateClass$12([TenantScoped({ mode: "required" }), smrt({
279
+ tableName: "correspondents",
280
+ api: false,
281
+ mcp: false,
282
+ cli: false,
283
+ conflictColumns: [
284
+ "tenant_id",
285
+ "owner_user_id",
286
+ "address"
287
+ ],
288
+ indexes: [{
289
+ name: "correspondents_owner_last_contact_idx",
290
+ columns: [
291
+ "tenantId",
292
+ "ownerUserId",
293
+ "lastContactAt"
294
+ ]
295
+ }]
296
+ })], Correspondent);
297
+ //#endregion
298
+ //#region src/collections/CorrespondentCollection.ts
299
+ var CorrespondentCollection = class extends SmrtCollection {
300
+ static _itemClass = Correspondent;
301
+ };
302
+ //#endregion
202
303
  //#region src/models/NotificationDelivery.ts
203
304
  var __defProp$11 = Object.defineProperty;
204
305
  var __getOwnPropDesc$11 = Object.getOwnPropertyDescriptor;
@@ -786,7 +887,7 @@ var EmailAttachment = class extends Attachment {
786
887
  */
787
888
  async getEmail() {
788
889
  if (!this.messageId) return null;
789
- const { EmailCollection } = await import("./chunks/EmailCollection-CHINTmyA.js").then((n) => n.n);
890
+ const { EmailCollection } = await import("./chunks/EmailCollection-lo8WePl-.js").then((n) => n.n);
790
891
  return await (await EmailCollection.create(this.options)).get({ id: this.messageId });
791
892
  }
792
893
  };
@@ -1869,6 +1970,736 @@ function isPrivateMailHost(host) {
1869
1970
  return false;
1870
1971
  }
1871
1972
  //#endregion
1973
+ //#region src/services/MailSearchService.ts
1974
+ var DEFAULT_LIMIT$3 = 25;
1975
+ var MAX_LIMIT$3 = 100;
1976
+ var SCAN_BATCH$1 = 200;
1977
+ var SCAN_LIMIT = 5e3;
1978
+ var SNIPPET_LENGTH = 200;
1979
+ function clampLimit$1(limit) {
1980
+ if (limit === void 0) return DEFAULT_LIMIT$3;
1981
+ if (!Number.isInteger(limit) || limit < 1) throw new Error("Mail search limit must be a positive integer.");
1982
+ return Math.min(limit, MAX_LIMIT$3);
1983
+ }
1984
+ function parseCursor(cursor) {
1985
+ if (!cursor) return 0;
1986
+ const n = Number(cursor);
1987
+ if (!Number.isInteger(n) || n < 0) throw new Error("Invalid mail search cursor.");
1988
+ return n;
1989
+ }
1990
+ var lower = (v) => (v ?? "").toLowerCase();
1991
+ function recipientHaystack(json) {
1992
+ if (!json) return "";
1993
+ try {
1994
+ const parsed = JSON.parse(json);
1995
+ if (!Array.isArray(parsed)) return lower(json);
1996
+ return parsed.map((p) => typeof p === "string" ? p : `${p?.address ?? ""} ${p?.name ?? ""}`).join(" ").toLowerCase();
1997
+ } catch {
1998
+ return lower(json);
1999
+ }
2000
+ }
2001
+ function labelsOf(email) {
2002
+ const out = /* @__PURE__ */ new Set();
2003
+ for (const raw of [email.labels]) try {
2004
+ const parsed = JSON.parse(raw || "[]");
2005
+ if (Array.isArray(parsed)) {
2006
+ for (const l of parsed) if (typeof l === "string") out.add(l);
2007
+ }
2008
+ } catch {}
2009
+ if (email.folderPath) out.add(email.folderPath);
2010
+ return [...out];
2011
+ }
2012
+ function toHit(email, similarity) {
2013
+ const body = (email.textBody || email.body || "").replace(/\s+/g, " ");
2014
+ return {
2015
+ accountId: email.accountId,
2016
+ emailId: email.id ?? null,
2017
+ providerMessageId: email.providerMessageId,
2018
+ threadId: email.threadId,
2019
+ subject: email.subject,
2020
+ fromAddress: email.fromAddress,
2021
+ fromName: email.fromName,
2022
+ date: email.date ?? null,
2023
+ snippet: body.slice(0, SNIPPET_LENGTH),
2024
+ isRead: email.isRead,
2025
+ isFlagged: email.isFlagged,
2026
+ hasAttachments: email.hasAttachments,
2027
+ labels: labelsOf(email),
2028
+ source: "local",
2029
+ ...similarity === void 0 ? {} : { similarity }
2030
+ };
2031
+ }
2032
+ function matches(email, q) {
2033
+ if (q.from) {
2034
+ const f = q.from.toLowerCase();
2035
+ if (!`${lower(email.fromAddress)} ${lower(email.fromName)}`.includes(f)) return false;
2036
+ }
2037
+ if (q.to) {
2038
+ const t = q.to.toLowerCase();
2039
+ if (!`${recipientHaystack(email.toAddresses)} ${recipientHaystack(email.ccAddresses)}`.includes(t)) return false;
2040
+ }
2041
+ if (q.subject && !lower(email.subject).includes(q.subject.toLowerCase())) return false;
2042
+ if (q.label) {
2043
+ const wanted = q.label.toLowerCase();
2044
+ if (!labelsOf(email).some((l) => l.toLowerCase() === wanted)) return false;
2045
+ }
2046
+ if (q.text) {
2047
+ const t = q.text.toLowerCase();
2048
+ const hay = `${lower(email.subject)} ${lower(email.textBody)} ${lower(email.body)} ${lower(email.fromAddress)} ${lower(email.fromName)}`;
2049
+ for (const word of t.split(/\s+/).filter(Boolean)) if (!hay.includes(word)) return false;
2050
+ }
2051
+ return true;
2052
+ }
2053
+ function structuredWhere(q, tenantId, accountIds) {
2054
+ const where = {
2055
+ tenantId,
2056
+ "accountId in": accountIds
2057
+ };
2058
+ if (q.hasAttachment !== void 0) where.hasAttachments = q.hasAttachment;
2059
+ if (q.isRead !== void 0) where.isRead = q.isRead;
2060
+ if (q.isFlagged !== void 0) where.isFlagged = q.isFlagged;
2061
+ if (q.since) where["date >="] = q.since;
2062
+ if (q.before) where["date <"] = q.before;
2063
+ return where;
2064
+ }
2065
+ var MailSearchService = class {
2066
+ constructor(options) {
2067
+ this.options = options;
2068
+ }
2069
+ options;
2070
+ /** Accounts the principal may search: owner or `read` grant, nothing else. */
2071
+ async searchableAccounts() {
2072
+ return readableMailAccounts(this.options);
2073
+ }
2074
+ async scope(requested) {
2075
+ const accounts = await this.searchableAccounts();
2076
+ const wanted = requested ? new Set(requested) : null;
2077
+ const chosen = accounts.filter((a) => !wanted || wanted.has(a.id));
2078
+ return {
2079
+ ids: chosen.map((a) => a.id),
2080
+ accounts: chosen
2081
+ };
2082
+ }
2083
+ /** Search the local index across every readable account. */
2084
+ async search(query = {}) {
2085
+ const limit = clampLimit$1(query.limit);
2086
+ const start = parseCursor(query.cursor);
2087
+ const { ids } = await this.scope(query.accountIds);
2088
+ const empty = {
2089
+ hits: [],
2090
+ nextCursor: null,
2091
+ accountIds: ids,
2092
+ truncated: false,
2093
+ semanticUsed: false
2094
+ };
2095
+ if (!ids.length) return empty;
2096
+ const { tenantId, db } = this.options;
2097
+ return withTenant({ tenantId }, () => runWithMailSystemAccess(async () => {
2098
+ const emails = await EmailCollection.create({ db });
2099
+ const where = structuredWhere(query, tenantId, ids);
2100
+ if (query.mode === "semantic" && query.text) {
2101
+ const ranked = await emails.semanticMatches(query.text, where);
2102
+ if (ranked?.length) {
2103
+ const hits2 = [];
2104
+ for (const match of ranked) {
2105
+ const email = (await emails.list({
2106
+ where: {
2107
+ ...where,
2108
+ id: match.id
2109
+ },
2110
+ limit: 1
2111
+ }))[0];
2112
+ if (email && matches(email, {
2113
+ ...query,
2114
+ text: void 0
2115
+ })) hits2.push(toHit(email, match.similarity));
2116
+ }
2117
+ return {
2118
+ hits: hits2.slice(start, start + limit),
2119
+ nextCursor: start + limit < hits2.length ? String(start + limit) : null,
2120
+ accountIds: ids,
2121
+ truncated: false,
2122
+ semanticUsed: true
2123
+ };
2124
+ }
2125
+ }
2126
+ const hits = [];
2127
+ let scanned = start;
2128
+ let exhausted = false;
2129
+ while (hits.length < limit + 1 && scanned - start < SCAN_LIMIT) {
2130
+ const batch = await emails.list({
2131
+ where,
2132
+ orderBy: ["date DESC", "id ASC"],
2133
+ limit: SCAN_BATCH$1,
2134
+ offset: scanned
2135
+ });
2136
+ for (const email of batch) {
2137
+ scanned += 1;
2138
+ if (matches(email, query)) hits.push(toHit(email));
2139
+ if (hits.length > limit) break;
2140
+ }
2141
+ if (batch.length < SCAN_BATCH$1) {
2142
+ exhausted = true;
2143
+ break;
2144
+ }
2145
+ if (hits.length > limit) break;
2146
+ }
2147
+ const more = hits.length > limit;
2148
+ const pageHits = hits.slice(0, limit);
2149
+ let nextCursor = null;
2150
+ let truncated = false;
2151
+ if (more) nextCursor = String(scanned - 1);
2152
+ else if (!exhausted) {
2153
+ truncated = true;
2154
+ nextCursor = String(scanned);
2155
+ }
2156
+ return {
2157
+ hits: pageHits,
2158
+ nextCursor,
2159
+ accountIds: ids,
2160
+ truncated,
2161
+ semanticUsed: false
2162
+ };
2163
+ }));
2164
+ }
2165
+ /**
2166
+ * Ask each readable account's own server (SDK `search()`), falling back to
2167
+ * the local index for accounts whose provider cannot search or fails. One
2168
+ * account's failure never blocks the others. Provider hits that are already
2169
+ * synced carry their local `emailId`.
2170
+ */
2171
+ async searchProvider(query = {}) {
2172
+ const limit = clampLimit$1(query.limit);
2173
+ const { ids, accounts } = await this.scope(query.accountIds);
2174
+ const result = {
2175
+ hits: [],
2176
+ providerAccountIds: [],
2177
+ fallbackAccounts: [],
2178
+ accountIds: ids,
2179
+ truncated: false
2180
+ };
2181
+ if (!ids.length) return result;
2182
+ const { tenantId, db } = this.options;
2183
+ const criteria = toSearchCriteria(query);
2184
+ for (const listing of accounts) {
2185
+ let answered = false;
2186
+ let reason = "provider search unavailable";
2187
+ try {
2188
+ const hits = await withTenant({ tenantId }, () => runWithMailSystemAccess(async () => {
2189
+ const account = await (await EmailAccountCollection.create({ db })).get({
2190
+ id: listing.id,
2191
+ tenantId
2192
+ });
2193
+ if (!account) throw new Error("account not found");
2194
+ const client = await account.createClient();
2195
+ try {
2196
+ await client.connect();
2197
+ if (!(await client.getCapabilities()).search) {
2198
+ reason = "provider does not support search";
2199
+ return null;
2200
+ }
2201
+ if (client.getAdapter() === "imap") {
2202
+ reason = "provider search needs a selected mailbox";
2203
+ return null;
2204
+ }
2205
+ const found = await client.search(criteria);
2206
+ const emails = await EmailCollection.create({ db });
2207
+ const out = [];
2208
+ for (const msg of found) {
2209
+ if (!matchesFlags(msg, query)) continue;
2210
+ if (out.length >= limit) {
2211
+ result.truncated = true;
2212
+ break;
2213
+ }
2214
+ const local = msg.id ? (await emails.list({
2215
+ where: {
2216
+ tenantId,
2217
+ accountId: listing.id,
2218
+ providerMessageId: msg.id
2219
+ },
2220
+ limit: 1
2221
+ }))[0] : void 0;
2222
+ out.push(local ? {
2223
+ ...toHit(local),
2224
+ source: "provider"
2225
+ } : {
2226
+ accountId: listing.id,
2227
+ emailId: null,
2228
+ providerMessageId: msg.id ?? "",
2229
+ threadId: msg.threadId ?? "",
2230
+ subject: msg.subject ?? "",
2231
+ fromAddress: msg.from?.address ?? "",
2232
+ fromName: msg.from?.name ?? "",
2233
+ date: msg.date ?? null,
2234
+ snippet: (msg.text ?? "").replace(/\s+/g, " ").slice(0, SNIPPET_LENGTH),
2235
+ isRead: (msg.flags ?? []).includes("\\Seen"),
2236
+ isFlagged: (msg.flags ?? []).includes("\\Flagged"),
2237
+ hasAttachments: (msg.attachments?.length ?? 0) > 0,
2238
+ labels: msg.labels ?? [],
2239
+ source: "provider"
2240
+ });
2241
+ }
2242
+ return out;
2243
+ } finally {
2244
+ await client.disconnect().catch(() => void 0);
2245
+ }
2246
+ }));
2247
+ if (hits) {
2248
+ result.hits.push(...hits);
2249
+ result.providerAccountIds.push(listing.id);
2250
+ answered = true;
2251
+ }
2252
+ } catch (error) {
2253
+ reason = "provider search failed";
2254
+ }
2255
+ if (!answered) {
2256
+ result.fallbackAccounts.push({
2257
+ accountId: listing.id,
2258
+ reason
2259
+ });
2260
+ const local = await this.search({
2261
+ ...query,
2262
+ accountIds: [listing.id],
2263
+ cursor: null,
2264
+ mode: "keyword"
2265
+ });
2266
+ result.hits.push(...local.hits);
2267
+ if (local.truncated) result.truncated = true;
2268
+ }
2269
+ }
2270
+ result.hits.sort((a, b) => (b.date?.getTime() ?? 0) - (a.date?.getTime() ?? 0));
2271
+ if (result.hits.length > limit) {
2272
+ result.hits = result.hits.slice(0, limit);
2273
+ result.truncated = true;
2274
+ }
2275
+ return result;
2276
+ }
2277
+ };
2278
+ function toSearchCriteria(q) {
2279
+ return {
2280
+ ...q.text ? { q: q.text } : {},
2281
+ ...q.from ? { from: q.from } : {},
2282
+ ...q.to ? { to: q.to } : {},
2283
+ ...q.subject ? { subject: q.subject } : {},
2284
+ ...q.since ? { since: q.since } : {},
2285
+ ...q.before ? { before: q.before } : {},
2286
+ ...q.isRead === false ? { unread: true } : {},
2287
+ ...q.isFlagged ? { flagged: true } : {}
2288
+ };
2289
+ }
2290
+ function matchesFlags(msg, q) {
2291
+ const flags = new Set((msg.flags ?? []).map((f) => String(f).toLowerCase()));
2292
+ if (q.hasAttachment !== void 0) {
2293
+ if ((msg.attachments?.length ?? 0) > 0 !== q.hasAttachment) return false;
2294
+ }
2295
+ if (q.isRead !== void 0 && flags.has("\\seen") !== q.isRead) return false;
2296
+ if (q.isFlagged !== void 0 && flags.has("\\flagged") !== q.isFlagged) return false;
2297
+ if (q.label) {
2298
+ const wanted = q.label.toLowerCase();
2299
+ if (![
2300
+ ...msg.labels ?? [],
2301
+ ...msg.folders ?? [],
2302
+ ...msg.folder ? [msg.folder] : []
2303
+ ].some((n) => n.toLowerCase() === wanted)) return false;
2304
+ }
2305
+ return true;
2306
+ }
2307
+ async function readableMailAccounts(options) {
2308
+ const settings = new MessagingSettingsService({
2309
+ db: options.db,
2310
+ tenantId: options.tenantId,
2311
+ principal: options.principal,
2312
+ resolvePersonaTenantId: async () => null
2313
+ });
2314
+ const out = [];
2315
+ let cursor = null;
2316
+ do {
2317
+ const page = await settings.listAccounts({
2318
+ limit: 200,
2319
+ cursor
2320
+ });
2321
+ for (const account of page.accounts) if (account.scopes.includes("read")) out.push(account);
2322
+ cursor = page.nextCursor;
2323
+ } while (cursor);
2324
+ return out;
2325
+ }
2326
+ //#endregion
2327
+ //#region src/services/CorrespondentService.ts
2328
+ var SCAN_BATCH = 500;
2329
+ var DEFAULT_LIMIT$2 = 50;
2330
+ var MAX_LIMIT$2 = 200;
2331
+ var SUGGEST_MAX = 20;
2332
+ var EMAIL_PATTERN = /^[^\s@<>]+@[^\s@<>]+$/;
2333
+ function parseParties(json) {
2334
+ if (!json) return [];
2335
+ try {
2336
+ const parsed = JSON.parse(json);
2337
+ if (!Array.isArray(parsed)) return [];
2338
+ const out = [];
2339
+ for (const p of parsed) {
2340
+ const address = normalizeCorrespondentAddress(typeof p === "string" ? p : p?.address);
2341
+ if (address) out.push({
2342
+ address,
2343
+ name: typeof p === "object" && p?.name ? String(p.name).trim() : ""
2344
+ });
2345
+ }
2346
+ return out;
2347
+ } catch {
2348
+ return [];
2349
+ }
2350
+ }
2351
+ function normalizeCorrespondentAddress(value) {
2352
+ if (typeof value !== "string") return null;
2353
+ const address = value.trim().toLowerCase();
2354
+ return EMAIL_PATTERN.test(address) ? address : null;
2355
+ }
2356
+ function parseBreakdown(row) {
2357
+ try {
2358
+ const parsed = JSON.parse(row.accountBreakdown || "{}");
2359
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
2360
+ } catch {
2361
+ return {};
2362
+ }
2363
+ }
2364
+ function viewOf(row, readable) {
2365
+ const all = parseBreakdown(row);
2366
+ const ids = Object.keys(all).filter((id) => readable.has(id));
2367
+ const reset = Object.keys(all).length === 0 && Boolean(row.profileId);
2368
+ if (!ids.length && !reset) return null;
2369
+ let sent = 0;
2370
+ let received = 0;
2371
+ let first = null;
2372
+ let last = null;
2373
+ let name = "";
2374
+ let nameAt = -1;
2375
+ for (const id of ids) {
2376
+ const e = all[id];
2377
+ sent += e.sent;
2378
+ received += e.received;
2379
+ if (e.first !== null) first = first === null ? e.first : Math.min(first, e.first);
2380
+ if (e.last !== null) last = last === null ? e.last : Math.max(last, e.last);
2381
+ if (e.name && e.nameAt >= nameAt) {
2382
+ name = e.name;
2383
+ nameAt = e.nameAt;
2384
+ }
2385
+ }
2386
+ return {
2387
+ id: row.id,
2388
+ address: row.address,
2389
+ displayName: name,
2390
+ messageCount: sent + received,
2391
+ sentCount: sent,
2392
+ receivedCount: received,
2393
+ firstContactAt: first === null ? null : new Date(first),
2394
+ lastContactAt: last === null ? null : new Date(last),
2395
+ accountIds: ids.sort(),
2396
+ profileId: row.profileId
2397
+ };
2398
+ }
2399
+ var CorrespondentService = class {
2400
+ constructor(options) {
2401
+ this.options = options;
2402
+ }
2403
+ options;
2404
+ get ownerUserId() {
2405
+ const { principal } = this.options;
2406
+ return principal.userId ?? principal.id ?? null;
2407
+ }
2408
+ /** Agent-style principal acting under ceilings or a credential id. */
2409
+ get delegated() {
2410
+ const { principal } = this.options;
2411
+ return Boolean(principal.scopes || principal.accountIds || principal.id && principal.userId && principal.id !== principal.userId);
2412
+ }
2413
+ /** The owner whose rows this principal may use, or null. */
2414
+ get actingOwner() {
2415
+ if (this.delegated && !this.options.allowDelegated) return null;
2416
+ return this.ownerUserId;
2417
+ }
2418
+ searchOptions() {
2419
+ return this.options;
2420
+ }
2421
+ async rows() {
2422
+ return CorrespondentCollection.create({ db: this.options.db });
2423
+ }
2424
+ async readableIds() {
2425
+ return new Set((await readableMailAccounts(this.searchOptions())).map((a) => a.id));
2426
+ }
2427
+ /**
2428
+ * Re-derive this owner's correspondents from readable mail. Idempotent.
2429
+ * Only the scanned (readable) accounts' entries are replaced; entries of
2430
+ * accounts outside the scan are kept as they are. Nothing changes when no
2431
+ * account is readable. Addresses of the scanned accounts are not
2432
+ * correspondents. A delegated principal is refused.
2433
+ */
2434
+ async refresh() {
2435
+ const result = {
2436
+ upserted: 0,
2437
+ removed: 0,
2438
+ scanned: 0
2439
+ };
2440
+ if (this.delegated && !this.options.allowDelegated) throw new Error("Correspondents are private to their owner.");
2441
+ const owner = this.actingOwner;
2442
+ const { tenantId, db } = this.options;
2443
+ if (!owner) return result;
2444
+ const ids = (await readableMailAccounts(this.searchOptions())).map((a) => a.id);
2445
+ if (!ids.length) return result;
2446
+ const scanned = new Set(ids);
2447
+ const own = new Set(await this.ownAddresses(ids));
2448
+ const aggs = /* @__PURE__ */ new Map();
2449
+ const touch = (party, kind, at, accountId) => {
2450
+ if (own.has(party.address)) return;
2451
+ let perAccount = aggs.get(party.address);
2452
+ if (!perAccount) {
2453
+ perAccount = {};
2454
+ aggs.set(party.address, perAccount);
2455
+ }
2456
+ let e = perAccount[accountId];
2457
+ if (!e) {
2458
+ e = {
2459
+ sent: 0,
2460
+ received: 0,
2461
+ first: null,
2462
+ last: null,
2463
+ name: "",
2464
+ nameAt: -1
2465
+ };
2466
+ perAccount[accountId] = e;
2467
+ }
2468
+ if (kind === "sent") e.sent += 1;
2469
+ else e.received += 1;
2470
+ if (at) {
2471
+ e.first = e.first === null ? at : Math.min(e.first, at);
2472
+ e.last = e.last === null ? at : Math.max(e.last, at);
2473
+ }
2474
+ if (party.name && at >= e.nameAt) {
2475
+ e.name = party.name;
2476
+ e.nameAt = at;
2477
+ }
2478
+ };
2479
+ await withTenant({ tenantId }, () => runWithMailSystemAccess(async () => {
2480
+ const emails = await EmailCollection.create({ db });
2481
+ for (let offset = 0;; offset += SCAN_BATCH) {
2482
+ const batch = await emails.list({
2483
+ where: {
2484
+ tenantId,
2485
+ "accountId in": ids
2486
+ },
2487
+ orderBy: ["id ASC"],
2488
+ limit: SCAN_BATCH,
2489
+ offset
2490
+ });
2491
+ for (const email of batch) {
2492
+ result.scanned += 1;
2493
+ const at = email.date?.getTime() ?? 0;
2494
+ const sender = normalizeCorrespondentAddress(email.fromAddress);
2495
+ if (sender) touch({
2496
+ address: sender,
2497
+ name: email.fromName?.trim() ?? ""
2498
+ }, "sent", at, email.accountId);
2499
+ for (const p of [...parseParties(email.toAddresses), ...parseParties(email.ccAddresses)]) touch(p, "received", at, email.accountId);
2500
+ }
2501
+ if (batch.length < SCAN_BATCH) break;
2502
+ }
2503
+ }));
2504
+ await withTenant({ tenantId }, async () => {
2505
+ const rows = await this.rows();
2506
+ const existing = await rows.list({
2507
+ where: {
2508
+ tenantId,
2509
+ ownerUserId: owner
2510
+ },
2511
+ limit: 1e5
2512
+ });
2513
+ const byAddress = new Map(existing.map((r) => [r.address, r]));
2514
+ const addresses = /* @__PURE__ */ new Set([...aggs.keys(), ...byAddress.keys()]);
2515
+ for (const address of addresses) {
2516
+ let row = byAddress.get(address);
2517
+ const merged = {};
2518
+ if (row) {
2519
+ for (const [id, e] of Object.entries(parseBreakdown(row))) if (!scanned.has(id)) merged[id] = e;
2520
+ }
2521
+ Object.assign(merged, aggs.get(address) ?? {});
2522
+ if (!Object.keys(merged).length && row && !row.profileId) {
2523
+ await row.delete();
2524
+ result.removed += 1;
2525
+ continue;
2526
+ }
2527
+ if (!row) try {
2528
+ row = await rows.create({
2529
+ _insertOnly: true,
2530
+ tenantId,
2531
+ ownerUserId: owner,
2532
+ address
2533
+ });
2534
+ } catch (error) {
2535
+ if (!isUniqueViolationError(error)) throw error;
2536
+ row = (await rows.list({
2537
+ where: {
2538
+ tenantId,
2539
+ ownerUserId: owner,
2540
+ address
2541
+ },
2542
+ limit: 1
2543
+ }))[0];
2544
+ if (!row) throw error;
2545
+ }
2546
+ let sent = 0;
2547
+ let received = 0;
2548
+ let first = null;
2549
+ let last = null;
2550
+ let name = "";
2551
+ let nameAt = -1;
2552
+ for (const e of Object.values(merged)) {
2553
+ sent += e.sent;
2554
+ received += e.received;
2555
+ if (e.first !== null) first = first === null ? e.first : Math.min(first, e.first);
2556
+ if (e.last !== null) last = last === null ? e.last : Math.max(last, e.last);
2557
+ if (e.name && e.nameAt >= nameAt) {
2558
+ name = e.name;
2559
+ nameAt = e.nameAt;
2560
+ }
2561
+ }
2562
+ row.accountBreakdown = JSON.stringify(merged);
2563
+ row.accountIds = JSON.stringify(Object.keys(merged).sort());
2564
+ row.sentCount = sent;
2565
+ row.receivedCount = received;
2566
+ row.messageCount = sent + received;
2567
+ row.firstContactAt = first === null ? null : new Date(first);
2568
+ row.lastContactAt = last === null ? null : new Date(last);
2569
+ row.displayName = name || row.displayName;
2570
+ await row.save();
2571
+ result.upserted += 1;
2572
+ }
2573
+ });
2574
+ return result;
2575
+ }
2576
+ async ownAddresses(accountIds) {
2577
+ const { EmailAccountCollection } = await import("./chunks/EmailAccountCollection-CgZE9YAM.js").then((n) => n.n);
2578
+ const accounts = await EmailAccountCollection.create({ db: this.options.db });
2579
+ const out = [];
2580
+ for (const id of accountIds) {
2581
+ const addr = normalizeCorrespondentAddress((await accounts.get({
2582
+ id,
2583
+ tenantId: this.options.tenantId
2584
+ }))?.email);
2585
+ if (addr) out.push(addr);
2586
+ }
2587
+ return out;
2588
+ }
2589
+ /** The owner's correspondents, as seen through the readable accounts. */
2590
+ async visible() {
2591
+ const owner = this.actingOwner;
2592
+ if (!owner) return [];
2593
+ const readable = await this.readableIds();
2594
+ if (!readable.size) return [];
2595
+ return withTenant({ tenantId: this.options.tenantId }, async () => {
2596
+ const rows = await (await this.rows()).list({
2597
+ where: {
2598
+ tenantId: this.options.tenantId,
2599
+ ownerUserId: owner
2600
+ },
2601
+ orderBy: ["lastContactAt DESC", "id ASC"],
2602
+ limit: 1e5
2603
+ });
2604
+ const views = [];
2605
+ for (const r of rows) {
2606
+ const v = viewOf(r, readable);
2607
+ if (v?.accountIds.length) views.push(v);
2608
+ }
2609
+ return views.sort((a, b) => (b.lastContactAt?.getTime() ?? 0) - (a.lastContactAt?.getTime() ?? 0) || a.address.localeCompare(b.address));
2610
+ });
2611
+ }
2612
+ async list(options = {}) {
2613
+ const requested = Number.isFinite(options.limit) ? Math.trunc(options.limit) : DEFAULT_LIMIT$2;
2614
+ const limit = Math.min(Math.max(requested, 1), MAX_LIMIT$2);
2615
+ const start = options.cursor ? Number(options.cursor) : 0;
2616
+ if (!Number.isInteger(start) || start < 0) throw new Error("Invalid correspondent cursor.");
2617
+ const q = options.query?.trim().toLowerCase();
2618
+ const all = (await this.visible()).filter((r) => !q || r.address.includes(q) || r.displayName.toLowerCase().includes(q));
2619
+ return {
2620
+ correspondents: all.slice(start, start + limit),
2621
+ nextCursor: start + limit < all.length ? String(start + limit) : null
2622
+ };
2623
+ }
2624
+ /**
2625
+ * Recipient autocomplete: correspondents whose address or name starts with
2626
+ * (or, for names, has a word starting with) `prefix`, best first.
2627
+ */
2628
+ async suggest(prefix, limit = 8) {
2629
+ const p = prefix.trim().toLowerCase();
2630
+ if (!p) return [];
2631
+ const cap = Math.min(Math.max(Math.trunc(limit) || 1, 1), SUGGEST_MAX);
2632
+ const scored = [];
2633
+ for (const view of await this.visible()) {
2634
+ const name = view.displayName.toLowerCase();
2635
+ let rank = -1;
2636
+ if (view.address.startsWith(p)) rank = 0;
2637
+ else if (name.startsWith(p)) rank = 1;
2638
+ else if (name.split(/\s+/).some((w) => w.startsWith(p))) rank = 2;
2639
+ else if (view.address.includes(p)) rank = 3;
2640
+ if (rank >= 0) scored.push({
2641
+ view,
2642
+ rank
2643
+ });
2644
+ }
2645
+ scored.sort((a, b) => a.rank - b.rank || b.view.messageCount - a.view.messageCount || a.view.address.localeCompare(b.view.address));
2646
+ return scored.slice(0, cap).map((s) => s.view);
2647
+ }
2648
+ async owned(id) {
2649
+ const owner = this.actingOwner;
2650
+ if (!owner) return null;
2651
+ const readable = await this.readableIds();
2652
+ if (!readable.size) return null;
2653
+ return withTenant({ tenantId: this.options.tenantId }, async () => {
2654
+ const found = (await (await this.rows()).list({
2655
+ where: {
2656
+ tenantId: this.options.tenantId,
2657
+ ownerUserId: owner,
2658
+ id
2659
+ },
2660
+ limit: 1
2661
+ }))[0];
2662
+ if (!found) return null;
2663
+ const view = viewOf(found, readable);
2664
+ return view ? {
2665
+ row: found,
2666
+ view
2667
+ } : null;
2668
+ });
2669
+ }
2670
+ async get(id) {
2671
+ return (await this.owned(id))?.view ?? null;
2672
+ }
2673
+ assertMayWrite() {
2674
+ if (this.delegated && !this.options.allowDelegated) throw new Error("Correspondents are private to their owner.");
2675
+ }
2676
+ /** Link a correspondent to a `Profile` of this tenant (owner's choice). */
2677
+ async linkProfile(id, profileId) {
2678
+ this.assertMayWrite();
2679
+ const hit = await this.owned(id);
2680
+ if (!hit) throw new Error("Correspondent not found.");
2681
+ const profile = await readNotificationProfile(this.options.db, this.options.tenantId, profileId);
2682
+ if (!profile || profile.tenantId && profile.tenantId !== this.options.tenantId) throw new Error("Profile not found.");
2683
+ hit.row.profileId = profileId;
2684
+ await withTenant({ tenantId: this.options.tenantId }, () => hit.row.save());
2685
+ return {
2686
+ ...hit.view,
2687
+ profileId
2688
+ };
2689
+ }
2690
+ async unlinkProfile(id) {
2691
+ this.assertMayWrite();
2692
+ const hit = await this.owned(id);
2693
+ if (!hit) throw new Error("Correspondent not found.");
2694
+ hit.row.profileId = null;
2695
+ await withTenant({ tenantId: this.options.tenantId }, () => hit.row.save());
2696
+ return {
2697
+ ...hit.view,
2698
+ profileId: null
2699
+ };
2700
+ }
2701
+ };
2702
+ //#endregion
1872
2703
  //#region src/services/NotificationOptOutService.ts
1873
2704
  var NotificationOptOutDeniedError = class extends Error {
1874
2705
  constructor(reason, message) {
@@ -3518,6 +4349,6 @@ ensureBuiltinMessagingProvidersRegistered();
3518
4349
  ensureMessagingPermissionsRegistered();
3519
4350
  ensureMailAccessEnforcementRegistered();
3520
4351
  //#endregion
3521
- export { Account, AccountCollection, Attachment, AttachmentCollection, Blacklist, BlacklistCollection, CHANGE_FEED_PROVIDERS, Email, EmailAccount, EmailAccountCollection, EmailAttachment, EmailAttachmentCollection, EmailCollection, EmailFolder, EmailFolderCollection, EmailSender, MAIL_ACCOUNT_RESOURCE_TYPE, MAIL_SCOPES, MAIL_SYNC_QUEUE, MANAGE_MESSAGE_CREDENTIALS_PERMISSION, MANAGE_MESSAGE_ROUTES_PERMISSION, MESSAGES_ROLE_PERMISSION_MATRIX, MESSAGING_PERMISSION_DEFINITIONS, MailAccessError, MailAccessService, MailWriteBackUnsupportedError, MailboxRecipe, Message, MessageCollection, MessagingEndpoint, MessagingEndpointCollection, MessagingSettingsService, NOTIFICATION_DELIVERY_CHANNELS, NOTIFICATION_OPT_OUT_ALL_SCOPE, NOTIFICATION_OPT_OUT_SCOPE_PATTERN, NotificationDelivery, NotificationDeliveryCollection, NotificationOptOut, NotificationOptOutCollection, NotificationOptOutDeniedError, NotificationOptOutService, NotificationOutboxDeniedError, NotificationOutboxService, NotificationsRecipe, PROFILE_NOTIFICATION_POLICY_PREFIX, PersonaMessageRoute, PersonaMessageRouteCollection, PersonaMessagingService, SEND_MESSAGES_PERMISSION, SlackAccount, SlackMessage, SlackRecipe, SlackSender, TelegramAccount, TelegramSender, Tweet, TweetSender, TwitterAccount, USER_NOTIFICATION_SEVERITIES, UserNotification, UserNotificationCollection, UserNotificationService, Whitelist, WhitelistCollection, ZulipAccount, ZulipSender, assertMailAccess, assertMessagingPermission, assertNotificationProfileRecipientSchema, buildNotificationLink, canAccessMailAccount, configureMailAccess, decideMailAccess, deniedMailAccountIds, enqueueDueMailSyncs, enqueueMailSync, ensureBuiltinMessagingProvidersRegistered, ensureMessagingPermissionsRegistered, getMessagingProvider, isMailScope, isValidNotificationOptOutScope, listMessagingProviders, mailScopePermission, mailSyncDedupeKey, messageSendTransport, messagingPrincipalFromPermissions, migrateNotificationProfileRecipients, notificationDeliveryCorrelationId, notificationDeliveryMessageId, optOutSuppression, planNotificationProfileRecipients, profileNotificationPolicy, registerMessagingProvider, resetMailAccess, runWithMailSystemAccess, seedMessagesRolePermissions };
4352
+ export { Account, AccountCollection, Attachment, AttachmentCollection, Blacklist, BlacklistCollection, CHANGE_FEED_PROVIDERS, Correspondent, CorrespondentCollection, CorrespondentService, Email, EmailAccount, EmailAccountCollection, EmailAttachment, EmailAttachmentCollection, EmailCollection, EmailFolder, EmailFolderCollection, EmailSender, MAIL_ACCOUNT_RESOURCE_TYPE, MAIL_SCOPES, MAIL_SYNC_QUEUE, MANAGE_MESSAGE_CREDENTIALS_PERMISSION, MANAGE_MESSAGE_ROUTES_PERMISSION, MESSAGES_ROLE_PERMISSION_MATRIX, MESSAGING_PERMISSION_DEFINITIONS, MailAccessError, MailAccessService, MailSearchService, MailWriteBackUnsupportedError, MailboxRecipe, Message, MessageCollection, MessagingEndpoint, MessagingEndpointCollection, MessagingSettingsService, NOTIFICATION_DELIVERY_CHANNELS, NOTIFICATION_OPT_OUT_ALL_SCOPE, NOTIFICATION_OPT_OUT_SCOPE_PATTERN, NotificationDelivery, NotificationDeliveryCollection, NotificationOptOut, NotificationOptOutCollection, NotificationOptOutDeniedError, NotificationOptOutService, NotificationOutboxDeniedError, NotificationOutboxService, NotificationsRecipe, PROFILE_NOTIFICATION_POLICY_PREFIX, PersonaMessageRoute, PersonaMessageRouteCollection, PersonaMessagingService, SEND_MESSAGES_PERMISSION, SlackAccount, SlackMessage, SlackRecipe, SlackSender, TelegramAccount, TelegramSender, Tweet, TweetSender, TwitterAccount, USER_NOTIFICATION_SEVERITIES, UserNotification, UserNotificationCollection, UserNotificationService, Whitelist, WhitelistCollection, ZulipAccount, ZulipSender, assertMailAccess, assertMessagingPermission, assertNotificationProfileRecipientSchema, buildNotificationLink, canAccessMailAccount, configureMailAccess, decideMailAccess, deniedMailAccountIds, enqueueDueMailSyncs, enqueueMailSync, ensureBuiltinMessagingProvidersRegistered, ensureMessagingPermissionsRegistered, getMessagingProvider, isMailScope, isValidNotificationOptOutScope, listMessagingProviders, mailScopePermission, mailSyncDedupeKey, messageSendTransport, messagingPrincipalFromPermissions, migrateNotificationProfileRecipients, normalizeCorrespondentAddress, notificationDeliveryCorrelationId, notificationDeliveryMessageId, optOutSuppression, planNotificationProfileRecipients, profileNotificationPolicy, readableMailAccounts, registerMessagingProvider, resetMailAccess, runWithMailSystemAccess, seedMessagesRolePermissions };
3522
4353
 
3523
4354
  //# sourceMappingURL=index.js.map