@open-workspace/email 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -22
- package/alchemy/index.ts +273 -0
- package/drizzle/mailbox/0000_puzzling_dracula.sql +149 -0
- package/drizzle/mailbox/0001_mute_jack_flag.sql +12 -0
- package/drizzle/mailbox/meta/0000_snapshot.json +1002 -0
- package/drizzle/mailbox/meta/0001_snapshot.json +1002 -0
- package/drizzle/mailbox/meta/_journal.json +20 -0
- package/drizzle/mailbox/migrations.js +12 -0
- package/index.ts +3 -1
- package/migrations/{0000_email.sql → 0000_dry_moon_knight.sql} +26 -20
- package/migrations/meta/0000_snapshot.json +125 -109
- package/migrations/meta/_journal.json +2 -2
- package/package.json +74 -68
- package/shared/attachment-preview.ts +37 -27
- package/shared/folder-order.ts +106 -0
- package/shared/mail-authentication.ts +8 -3
- package/shared/mail-feedback.ts +18 -25
- package/shared/mail-headers.ts +114 -39
- package/shared/mail-import.ts +38 -0
- package/shared/mail-path.ts +42 -0
- package/shared/mail-received.ts +174 -31
- package/shared/mail-remote.ts +59 -2
- package/shared/mail-sender-intel.ts +22 -4
- package/shared/mail.ts +77 -28
- package/shared/module.ts +33 -0
- package/shared/office-preview.ts +14 -2
- package/shared/pdfjs-assets.ts +35 -0
- package/shared/permissions.ts +73 -0
- package/shared/webhooks.ts +41 -0
- package/src/admin/blocked-senders.tsx +189 -0
- package/src/client.tsx +97 -0
- package/src/lib/mail-api.ts +9 -0
- package/src/mail/attachment-preview-dialog.tsx +161 -0
- package/src/mail/blocked-senders.tsx +138 -0
- package/src/mail/compose-window-chrome.tsx +194 -0
- package/src/mail/compose-window.tsx +486 -0
- package/src/mail/composer-asset-bookmarks.ts +409 -0
- package/src/mail/composer-asset.tsx +229 -0
- package/src/mail/composer-attachment-list.tsx +138 -0
- package/src/mail/composer-editor-document.ts +65 -0
- package/src/mail/composer-editor.tsx +284 -0
- package/src/mail/composer-linked-attachment-text.ts +12 -0
- package/src/mail/composer-recipient-fields.tsx +165 -0
- package/src/mail/composer-recipients.ts +208 -0
- package/src/mail/composer-session.ts +562 -0
- package/src/mail/composer-toolbar.tsx +303 -0
- package/src/mail/composer-upload-client.ts +105 -0
- package/src/mail/composer-upload-progress.ts +53 -0
- package/src/mail/conversation-list.tsx +550 -0
- package/src/mail/conversation-loading-skeleton.tsx +119 -0
- package/src/mail/conversation-message.tsx +346 -0
- package/src/mail/conversation-reply.tsx +470 -0
- package/src/mail/conversation-selection-toolbar.tsx +322 -0
- package/src/mail/conversation-view.tsx +437 -0
- package/src/mail/delivery-indicator.tsx +272 -0
- package/src/mail/email-html-body.tsx +203 -0
- package/src/mail/folder-glyph.tsx +46 -0
- package/src/mail/folder-manager.tsx +532 -0
- package/src/mail/format-bytes.ts +7 -0
- package/src/mail/mail-app-bar.tsx +253 -0
- package/src/mail/mail-background.tsx +12 -0
- package/src/mail/mail-dock.tsx +137 -0
- package/src/mail/mail-folders.ts +44 -0
- package/src/mail/mail-layout.css +236 -0
- package/src/mail/mail-location.ts +73 -0
- package/src/mail/mail-mailbox-sheet.tsx +275 -0
- package/src/mail/mail-nav-rail.tsx +129 -0
- package/src/mail/mail-nav.tsx +324 -0
- package/src/mail/mail-prefetch.ts +59 -0
- package/src/mail/mail-primitives.tsx +66 -0
- package/src/mail/mail-queries.ts +209 -0
- package/src/mail/mail-query-cache.ts +486 -0
- package/src/mail/mail-seed.ts +47 -0
- package/src/mail/mail-shell.tsx +126 -0
- package/src/mail/mailbox-ai-settings.tsx +185 -0
- package/src/mail/mailbox-realtime.tsx +251 -0
- package/src/mail/mailbox-route.tsx +15 -0
- package/src/mail/message-actions.tsx +353 -0
- package/src/mail/message-attachments.tsx +200 -0
- package/src/mail/message-format.ts +75 -0
- package/src/mail/message-header.tsx +260 -0
- package/src/mail/message-translation.tsx +225 -0
- package/src/mail/original-message-sheet.tsx +619 -0
- package/src/mail/original-message.ts +191 -0
- package/src/mail/outbound-notification.ts +53 -0
- package/src/mail/pane-splitter.tsx +117 -0
- package/src/mail/pdf-preview-toolbar.tsx +152 -0
- package/src/mail/pdf-preview.css +44 -0
- package/src/mail/pdf-preview.tsx +156 -0
- package/src/mail/pdf-translation-layout.ts +95 -0
- package/src/mail/print-message.ts +92 -0
- package/src/mail/reader-pane.tsx +535 -0
- package/src/mail/recipient-combobox.tsx +335 -0
- package/src/mail/recipient-field-row.tsx +34 -0
- package/src/mail/reply-to-warning.tsx +50 -0
- package/src/mail/sanitize-email-html.ts +430 -0
- package/src/mail/sender-actions.tsx +149 -0
- package/src/mail/sender-authentication.tsx +485 -0
- package/src/mail/sender-dialogs.tsx +384 -0
- package/src/mail/sender-security.tsx +545 -0
- package/src/mail/toolbar-tooltip.tsx +29 -0
- package/src/mail/translation-html.ts +49 -0
- package/src/mail/translation-language.ts +21 -0
- package/src/mail/types.ts +53 -0
- package/src/mail/unread-document-indicator.tsx +60 -0
- package/src/mail/use-compose-submission.ts +208 -0
- package/src/mail/use-composer-attachment-preflight.ts +184 -0
- package/src/mail/use-composer-submission.ts +117 -0
- package/src/mail/use-conversation-selection.ts +186 -0
- package/src/mail/use-mail-controller.ts +427 -0
- package/src/mail/use-mail-data.ts +279 -0
- package/src/mail/use-mail-safety.ts +155 -0
- package/src/mail/use-mail-send.ts +142 -0
- package/src/mail/use-pdf-translation-overlay.ts +156 -0
- package/src/mail/use-pdf-translation.ts +100 -0
- package/src/mail/use-pdf-viewer.ts +215 -0
- package/src/mail/use-reply-submission.ts +114 -0
- package/src/mail/use-sanitized-email-html.ts +20 -0
- package/src/mail/use-visible-message-read.ts +138 -0
- package/src/pwa/push-subscription.ts +151 -0
- package/src/settings/mail-apps-page.tsx +235 -0
- package/src/settings/notifications-page.tsx +291 -0
- package/worker/admin/blocked-sender-routes.ts +166 -0
- package/worker/admin/schemas.ts +11 -0
- package/worker/bindings.d.ts +14 -10
- package/worker/db/schema.ts +63 -40
- package/worker/jmap/eventsource.ts +84 -16
- package/worker/jmap/methods.ts +1630 -524
- package/worker/jmap/push-types.ts +27 -0
- package/worker/jmap/push.ts +140 -56
- package/worker/jmap/routes.ts +366 -105
- package/worker/mail/access.ts +258 -21
- package/worker/mail/ai-classification.ts +36 -20
- package/worker/mail/ai-translation.ts +13 -6
- package/worker/mail/auth-headers.ts +395 -137
- package/worker/mail/bimi.ts +200 -73
- package/worker/mail/bootstrap.ts +79 -0
- package/worker/mail/capped-body.ts +36 -0
- package/worker/mail/classification-signals.ts +35 -25
- package/worker/mail/conversation-cursor.ts +30 -19
- package/worker/mail/delivery-events.ts +88 -62
- package/worker/mail/delivery-facts.ts +46 -10
- package/worker/mail/demo-routes.ts +34 -10
- package/worker/mail/doh.ts +62 -23
- package/worker/mail/downloads.ts +75 -40
- package/worker/mail/edge-cache.ts +155 -0
- package/worker/mail/header-metadata.ts +88 -22
- package/worker/mail/impersonation.ts +160 -38
- package/worker/mail/import-routes.ts +313 -0
- package/worker/mail/inbound-delivery.ts +19 -9
- package/worker/mail/inbound-threading.ts +18 -8
- package/worker/mail/inbound.ts +82 -40
- package/worker/mail/ip-intel.ts +110 -27
- package/worker/mail/isolate-cache.ts +35 -0
- package/worker/mail/link-domains.ts +29 -7
- package/worker/mail/mailbox-deletion.ts +10 -4
- package/worker/mail/mailbox-directory.ts +16 -6
- package/worker/mail/mailing-list.ts +94 -39
- package/worker/mail/message-security.ts +90 -15
- package/worker/mail/message-view.ts +18 -6
- package/worker/mail/office-conversion.ts +31 -9
- package/worker/mail/office-preview-container.ts +40 -13
- package/worker/mail/office-preview-queue.ts +76 -32
- package/worker/mail/org-domain.ts +8 -1
- package/worker/mail/outbound-content.ts +71 -26
- package/worker/mail/outbound-delivery.ts +31 -17
- package/worker/mail/outbound-service.ts +48 -30
- package/worker/mail/outbound-threading.ts +30 -17
- package/worker/mail/outbound.ts +97 -70
- package/worker/mail/outgoing-context.ts +25 -15
- package/worker/mail/participants.ts +44 -29
- package/worker/mail/push-notifications.ts +271 -173
- package/worker/mail/quote-parser.ts +21 -10
- package/worker/mail/r2-presigned-urls.ts +31 -25
- package/worker/mail/receive.ts +23 -11
- package/worker/mail/recipients.ts +6 -1
- package/worker/mail/remote-proxy.ts +187 -31
- package/worker/mail/remote-routes.ts +87 -0
- package/worker/mail/remote-token.ts +104 -0
- package/worker/mail/repeat.ts +19 -0
- package/worker/mail/reply-plan.ts +62 -33
- package/worker/mail/rfc.ts +32 -7
- package/worker/mail/routes.ts +870 -541
- package/worker/mail/safety-routes.ts +328 -200
- package/worker/mail/schemas.ts +84 -105
- package/worker/mail/search.ts +1 -0
- package/worker/mail/security-settings.ts +41 -9
- package/worker/mail/sender-intel.ts +206 -51
- package/worker/mail/spamhaus.ts +92 -45
- package/worker/mail/unsubscribe.ts +76 -18
- package/worker/mail/uploads.ts +126 -93
- package/worker/mail/webhook-source.ts +35 -12
- package/worker/mail/workspace-safety.ts +97 -38
- package/worker/mailbox/demo-html.ts +7 -7
- package/worker/mailbox/demo-seed.ts +10 -44
- package/worker/mailbox/demo.ts +595 -225
- package/worker/mailbox/email-index.ts +53 -0
- package/worker/mailbox/folder-model.ts +53 -17
- package/worker/mailbox/import-placement.ts +88 -0
- package/worker/mailbox/inbox-counts.ts +106 -0
- package/worker/mailbox/index.ts +1734 -721
- package/worker/mailbox/jmap-store.ts +139 -35
- package/worker/mailbox/model.ts +8 -6
- package/worker/mailbox/office-preview-jobs.ts +56 -25
- package/worker/mailbox/schema.ts +87 -66
- package/worker/mailbox/senders.ts +176 -70
- package/worker/mcp/mail-action-tools.ts +128 -87
- package/worker/mcp/mail-compose-tools.ts +133 -82
- package/worker/mcp/mail-query-tools.ts +120 -71
- package/worker/mcp/mail-safety-tools.ts +321 -248
- package/worker/mcp/schemas.ts +43 -0
- package/worker/mcp/tools.ts +13 -10
- package/worker/module.ts +43 -18
- package/worker/sql.d.ts +8 -0
- package/alchemy.ts +0 -142
- package/containers/office-preview/Dockerfile +0 -10
- package/shared/mail-rules.ts +0 -156
- package/worker/admin/report-routes.ts +0 -164
- package/worker/mail/reported-messages.ts +0 -68
- package/worker/mailbox/migrations.ts +0 -10
- package/worker/mailbox/rules.ts +0 -110
package/worker/mailbox/schema.ts
CHANGED
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
text,
|
|
7
7
|
uniqueIndex,
|
|
8
8
|
} from "drizzle-orm/sqlite-core";
|
|
9
|
+
|
|
9
10
|
import { transportStates } from "../../shared/mail";
|
|
10
|
-
import type { MailRuleActions, MailRuleConditions } from "../../shared/mail-rules";
|
|
11
11
|
import { mailboxStates } from "./folder-model";
|
|
12
12
|
import type {
|
|
13
13
|
DeliveryFacts,
|
|
@@ -35,9 +35,18 @@ export const folders = sqliteTable(
|
|
|
35
35
|
(table) => [
|
|
36
36
|
uniqueIndex("folders_name_unique").on(table.name),
|
|
37
37
|
index("folders_order_idx").on(table.sortOrder, table.name),
|
|
38
|
-
]
|
|
38
|
+
]
|
|
39
39
|
);
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Where a system folder sits in the mailbox's one folder order, once someone
|
|
43
|
+
* has moved it. Without a row it keeps its default place; Inbox never has one.
|
|
44
|
+
*/
|
|
45
|
+
export const systemFolderOrder = sqliteTable("system_folder_order", {
|
|
46
|
+
folderId: text("folder_id").primaryKey(),
|
|
47
|
+
sortOrder: integer("sort_order").notNull(),
|
|
48
|
+
});
|
|
49
|
+
|
|
41
50
|
/**
|
|
42
51
|
* A row exists only while raw MIME still needs to be materialized as an email.
|
|
43
52
|
* Deterministic MIME errors are converted into a visible fallback message;
|
|
@@ -55,14 +64,16 @@ export const pendingInbound = sqliteTable(
|
|
|
55
64
|
receivedAt: integer("received_at", { mode: "timestamp_ms" }).notNull(),
|
|
56
65
|
attempts: integer("attempts").notNull().default(0),
|
|
57
66
|
aiAttempts: integer("ai_attempts").notNull().default(0),
|
|
58
|
-
nextAttemptAt: integer("next_attempt_at", {
|
|
67
|
+
nextAttemptAt: integer("next_attempt_at", {
|
|
68
|
+
mode: "timestamp_ms",
|
|
69
|
+
}).notNull(),
|
|
59
70
|
},
|
|
60
71
|
(table) => [
|
|
61
72
|
index("pending_inbound_next_attempt_idx").on(
|
|
62
73
|
table.nextAttemptAt,
|
|
63
|
-
table.receivedAt
|
|
74
|
+
table.receivedAt
|
|
64
75
|
),
|
|
65
|
-
]
|
|
76
|
+
]
|
|
66
77
|
);
|
|
67
78
|
|
|
68
79
|
/**
|
|
@@ -75,11 +86,13 @@ export const pendingObjectDeletions = sqliteTable(
|
|
|
75
86
|
{
|
|
76
87
|
objectKey: text("object_key").primaryKey(),
|
|
77
88
|
attempts: integer("attempts").notNull().default(0),
|
|
78
|
-
nextAttemptAt: integer("next_attempt_at", {
|
|
89
|
+
nextAttemptAt: integer("next_attempt_at", {
|
|
90
|
+
mode: "timestamp_ms",
|
|
91
|
+
}).notNull(),
|
|
79
92
|
},
|
|
80
93
|
(table) => [
|
|
81
94
|
index("pending_object_deletions_next_attempt_idx").on(table.nextAttemptAt),
|
|
82
|
-
]
|
|
95
|
+
]
|
|
83
96
|
);
|
|
84
97
|
|
|
85
98
|
export const pendingOfficePreviews = sqliteTable(
|
|
@@ -89,9 +102,13 @@ export const pendingOfficePreviews = sqliteTable(
|
|
|
89
102
|
emailId: text("email_id").notNull(),
|
|
90
103
|
attachmentId: text("attachment_id").notNull(),
|
|
91
104
|
attempts: integer("attempts").notNull().default(0),
|
|
92
|
-
nextAttemptAt: integer("next_attempt_at", {
|
|
105
|
+
nextAttemptAt: integer("next_attempt_at", {
|
|
106
|
+
mode: "timestamp_ms",
|
|
107
|
+
}).notNull(),
|
|
93
108
|
},
|
|
94
|
-
(table) => [
|
|
109
|
+
(table) => [
|
|
110
|
+
index("pending_office_previews_next_attempt_idx").on(table.nextAttemptAt),
|
|
111
|
+
]
|
|
95
112
|
);
|
|
96
113
|
|
|
97
114
|
/**
|
|
@@ -143,26 +160,32 @@ export const emails = sqliteTable(
|
|
|
143
160
|
bodyHtmlR2Key: text("body_html_r2_key"),
|
|
144
161
|
rawMimeR2Key: text("raw_mime_r2_key"),
|
|
145
162
|
/** Header-derived sender authentication for incoming mail. */
|
|
146
|
-
authenticationResultsJson: text("authentication_results_json", {
|
|
147
|
-
|
|
163
|
+
authenticationResultsJson: text("authentication_results_json", {
|
|
164
|
+
mode: "json",
|
|
165
|
+
}).$type<StoredEmailAuthentication>(),
|
|
148
166
|
/** SMTP envelope as delivered by Email Routing (MAIL FROM / RCPT TO). */
|
|
149
167
|
envelopeFrom: text("envelope_from"),
|
|
150
168
|
envelopeTo: text("envelope_to"),
|
|
151
|
-
listUnsubscribeJson: text("list_unsubscribe_json", {
|
|
152
|
-
|
|
169
|
+
listUnsubscribeJson: text("list_unsubscribe_json", {
|
|
170
|
+
mode: "json",
|
|
171
|
+
}).$type<ListUnsubscribe>(),
|
|
153
172
|
/** DNS facts about the delivering server, gathered at ingestion. */
|
|
154
|
-
senderIntelJson: text("sender_intel_json", {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
173
|
+
senderIntelJson: text("sender_intel_json", {
|
|
174
|
+
mode: "json",
|
|
175
|
+
}).$type<SenderIntel>(),
|
|
176
|
+
aiClassificationJson: text("ai_classification_json", {
|
|
177
|
+
mode: "json",
|
|
178
|
+
}).$type<EmailAiClassification>(),
|
|
158
179
|
/** Who the message was written for and whether it was forwarded, from ingestion. */
|
|
159
|
-
deliveryJson: text("delivery_json", {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
180
|
+
deliveryJson: text("delivery_json", {
|
|
181
|
+
mode: "json",
|
|
182
|
+
}).$type<DeliveryFacts>(),
|
|
183
|
+
/** Sender-block decisions taken at ingestion, before AI classification. */
|
|
184
|
+
screeningJson: text("screening_json", {
|
|
185
|
+
mode: "json",
|
|
186
|
+
}).$type<EmailScreening>(),
|
|
187
|
+
/** Set to "spam" when someone in this mailbox reported the message; only its presence is read. */
|
|
188
|
+
reportLabel: text("report_label", { enum: ["spam"] }),
|
|
166
189
|
attachmentsJson: text("attachments_json", { mode: "json" })
|
|
167
190
|
.$type<StoredAttachment[]>()
|
|
168
191
|
.notNull()
|
|
@@ -172,7 +195,9 @@ export const emails = sqliteTable(
|
|
|
172
195
|
listPostAddress: text("list_post_address"),
|
|
173
196
|
timelineAt: integer("timeline_at", { mode: "timestamp_ms" }).notNull(),
|
|
174
197
|
|
|
175
|
-
transportState: text("transport_state", {
|
|
198
|
+
transportState: text("transport_state", {
|
|
199
|
+
enum: transportStates,
|
|
200
|
+
}).notNull(),
|
|
176
201
|
transportError: text("transport_error"),
|
|
177
202
|
deliveryStatusJson: text("delivery_status_json", { mode: "json" })
|
|
178
203
|
.$type<RecipientDeliveryStatus[]>()
|
|
@@ -183,15 +208,15 @@ export const emails = sqliteTable(
|
|
|
183
208
|
index("emails_conversation_timeline_idx").on(
|
|
184
209
|
table.conversationId,
|
|
185
210
|
table.timelineAt,
|
|
186
|
-
table.id
|
|
211
|
+
table.id
|
|
187
212
|
),
|
|
188
213
|
index("emails_message_id_header_idx").on(table.messageIdHeader),
|
|
189
|
-
]
|
|
214
|
+
]
|
|
190
215
|
);
|
|
191
216
|
|
|
192
217
|
/**
|
|
193
|
-
* Small mutable projection used by folder lists.
|
|
194
|
-
*
|
|
218
|
+
* Small mutable projection used by folder lists. Every email insert updates it
|
|
219
|
+
* in the same transaction (`indexInsertedEmail`).
|
|
195
220
|
*/
|
|
196
221
|
export const conversations = sqliteTable(
|
|
197
222
|
"conversations",
|
|
@@ -215,25 +240,28 @@ export const conversations = sqliteTable(
|
|
|
215
240
|
.default(false),
|
|
216
241
|
},
|
|
217
242
|
(table) => [
|
|
218
|
-
index("conversations_timeline_idx").on(
|
|
243
|
+
index("conversations_timeline_idx").on(
|
|
244
|
+
table.timelineAt,
|
|
245
|
+
table.latestEmailId
|
|
246
|
+
),
|
|
219
247
|
index("conversations_inbox_timeline_idx").on(
|
|
220
248
|
table.mailboxState,
|
|
221
249
|
table.hasIncoming,
|
|
222
250
|
table.timelineAt,
|
|
223
|
-
table.latestEmailId
|
|
251
|
+
table.latestEmailId
|
|
224
252
|
),
|
|
225
253
|
index("conversations_sent_timeline_idx").on(
|
|
226
254
|
table.mailboxState,
|
|
227
255
|
table.hasOutgoing,
|
|
228
256
|
table.timelineAt,
|
|
229
|
-
table.latestEmailId
|
|
257
|
+
table.latestEmailId
|
|
230
258
|
),
|
|
231
259
|
index("conversations_folder_timeline_idx").on(
|
|
232
260
|
table.folderId,
|
|
233
261
|
table.timelineAt,
|
|
234
|
-
table.latestEmailId
|
|
262
|
+
table.latestEmailId
|
|
235
263
|
),
|
|
236
|
-
]
|
|
264
|
+
]
|
|
237
265
|
);
|
|
238
266
|
|
|
239
267
|
/**
|
|
@@ -257,11 +285,11 @@ export const senders = sqliteTable(
|
|
|
257
285
|
trustedAt: integer("trusted_at", { mode: "timestamp_ms" }),
|
|
258
286
|
reportedAt: integer("reported_at", { mode: "timestamp_ms" }),
|
|
259
287
|
},
|
|
260
|
-
(table) => [index("senders_domain_idx").on(table.domain)]
|
|
288
|
+
(table) => [index("senders_domain_idx").on(table.domain)]
|
|
261
289
|
);
|
|
262
290
|
|
|
263
291
|
/**
|
|
264
|
-
* Spam
|
|
292
|
+
* Spam and not-spam reports made in this mailbox. They feed the
|
|
265
293
|
* AI classifier as sender history and are never sent anywhere by themselves.
|
|
266
294
|
*/
|
|
267
295
|
export const senderFeedback = sqliteTable(
|
|
@@ -271,14 +299,15 @@ export const senderFeedback = sqliteTable(
|
|
|
271
299
|
address: text("address").notNull(),
|
|
272
300
|
domain: text("domain").notNull(),
|
|
273
301
|
emailId: text("email_id"),
|
|
274
|
-
|
|
302
|
+
/** "spam" or "not_spam"; any label other than "not_spam" is read as a report. */
|
|
303
|
+
label: text("label", { enum: ["spam", "not_spam"] }).notNull(),
|
|
275
304
|
userId: text("user_id"),
|
|
276
305
|
createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
277
306
|
},
|
|
278
307
|
(table) => [
|
|
279
308
|
index("sender_feedback_address_idx").on(table.address, table.createdAt),
|
|
280
309
|
index("sender_feedback_domain_idx").on(table.domain),
|
|
281
|
-
]
|
|
310
|
+
]
|
|
282
311
|
);
|
|
283
312
|
|
|
284
313
|
/** Latest unsubscribe attempt per list (List-Id, else the From organizational domain). */
|
|
@@ -286,38 +315,21 @@ export const unsubscriptions = sqliteTable("unsubscriptions", {
|
|
|
286
315
|
listKey: text("list_key").primaryKey(),
|
|
287
316
|
emailId: text("email_id"),
|
|
288
317
|
method: text("method", { enum: ["one_click", "mailto", "link"] }).notNull(),
|
|
289
|
-
status: text("status", {
|
|
318
|
+
status: text("status", {
|
|
319
|
+
enum: ["done", "requested", "opened", "failed"],
|
|
320
|
+
}).notNull(),
|
|
290
321
|
target: text("target"),
|
|
291
322
|
detail: text("detail"),
|
|
292
323
|
userId: text("user_id"),
|
|
293
324
|
createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
294
325
|
});
|
|
295
326
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
"
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
sortOrder: integer("sort_order").notNull().default(100),
|
|
303
|
-
enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
|
|
304
|
-
conditionsJson: text("conditions_json", { mode: "json" }).$type<MailRuleConditions>().notNull(),
|
|
305
|
-
actionsJson: text("actions_json", { mode: "json" }).$type<MailRuleActions>().notNull(),
|
|
306
|
-
createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
307
|
-
updatedAt: integer("updated_at", { mode: "timestamp_ms" }).notNull(),
|
|
308
|
-
},
|
|
309
|
-
(table) => [index("mail_rules_order_idx").on(table.sortOrder, table.createdAt)],
|
|
310
|
-
);
|
|
311
|
-
|
|
312
|
-
export const mailboxAiConfiguration = sqliteTable(
|
|
313
|
-
"mailbox_ai_configuration",
|
|
314
|
-
{
|
|
315
|
-
id: text("id").primaryKey(),
|
|
316
|
-
instructions: text("instructions").notNull().default(""),
|
|
317
|
-
confidenceThreshold: integer("confidence_threshold").notNull().default(75),
|
|
318
|
-
updatedAt: integer("updated_at", { mode: "timestamp_ms" }).notNull(),
|
|
319
|
-
},
|
|
320
|
-
);
|
|
327
|
+
export const mailboxAiConfiguration = sqliteTable("mailbox_ai_configuration", {
|
|
328
|
+
id: text("id").primaryKey(),
|
|
329
|
+
instructions: text("instructions").notNull().default(""),
|
|
330
|
+
confidenceThreshold: integer("confidence_threshold").notNull().default(75),
|
|
331
|
+
updatedAt: integer("updated_at", { mode: "timestamp_ms" }).notNull(),
|
|
332
|
+
});
|
|
321
333
|
|
|
322
334
|
/**
|
|
323
335
|
* Read state belongs to a person, not to the mailbox. This keeps shared
|
|
@@ -336,18 +348,27 @@ export const emailReadStates = sqliteTable(
|
|
|
336
348
|
(table) => [
|
|
337
349
|
primaryKey({ columns: [table.userId, table.emailId] }),
|
|
338
350
|
index("email_read_states_email_idx").on(table.emailId),
|
|
339
|
-
]
|
|
351
|
+
]
|
|
340
352
|
);
|
|
341
353
|
|
|
342
354
|
export type Email = typeof emails.$inferSelect;
|
|
355
|
+
|
|
343
356
|
export type SenderRecord = typeof senders.$inferSelect;
|
|
344
|
-
|
|
357
|
+
|
|
345
358
|
export type UnsubscriptionRecord = typeof unsubscriptions.$inferSelect;
|
|
359
|
+
|
|
346
360
|
export type NewEmail = typeof emails.$inferInsert;
|
|
361
|
+
|
|
347
362
|
export type EmailReadState = typeof emailReadStates.$inferSelect;
|
|
363
|
+
|
|
348
364
|
export type PendingInbound = typeof pendingInbound.$inferSelect;
|
|
365
|
+
|
|
349
366
|
export type PendingObjectDeletion = typeof pendingObjectDeletions.$inferSelect;
|
|
367
|
+
|
|
350
368
|
export type NewPendingInbound = typeof pendingInbound.$inferInsert;
|
|
369
|
+
|
|
351
370
|
export type ConversationRecord = typeof conversations.$inferSelect;
|
|
371
|
+
|
|
352
372
|
export type FolderRecord = typeof folders.$inferSelect;
|
|
373
|
+
|
|
353
374
|
export type NewFolder = typeof folders.$inferInsert;
|