@joelincc/mailroom 0.0.0-stage → 0.3.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/LICENSE +21 -0
- package/README.md +207 -2
- package/SECURITY.md +11 -0
- package/bin/mailroom.mjs +26 -0
- package/dist/broadcast/config.js +79 -0
- package/dist/broadcast/explain.js +50 -0
- package/dist/cli/args.js +29 -0
- package/dist/cli/errors.js +31 -0
- package/dist/cli/main.js +475 -0
- package/dist/compose/clicks.js +29 -0
- package/dist/compose/compose.js +224 -0
- package/dist/compose/index.js +8 -0
- package/dist/compose/markdown.js +637 -0
- package/dist/compose/personalize.js +123 -0
- package/dist/compose/preflight.js +251 -0
- package/dist/compose/preview.js +41 -0
- package/dist/compose/render.js +136 -0
- package/dist/compose/template.js +118 -0
- package/docs/broadcast.md +199 -0
- package/docs/composing.md +135 -0
- package/docs/desk-commands.md +52 -0
- package/docs/export.md +51 -0
- package/docs/lists.md +66 -0
- package/docs/security-model.md +82 -0
- package/docs/ses.md +116 -0
- package/docs/unsubscribe.md +117 -0
- package/migrations/0001_init.sql +42 -0
- package/migrations/0002_tier.sql +4 -0
- package/migrations/0003_rate.sql +9 -0
- package/migrations/0004_last_error.sql +2 -0
- package/migrations/0005_lists.sql +41 -0
- package/migrations/0006_broadcast.sql +154 -0
- package/migrations/0007_unsubscribe.sql +12 -0
- package/package.json +64 -4
- package/src/alert.ts +123 -0
- package/src/aws-sigv4.ts +100 -0
- package/src/broadcast/audience.ts +96 -0
- package/src/broadcast/campaigns.ts +339 -0
- package/src/broadcast/config.ts +136 -0
- package/src/broadcast/dispatch.ts +766 -0
- package/src/broadcast/events.ts +107 -0
- package/src/broadcast/explain.ts +73 -0
- package/src/broadcast/freeze.ts +93 -0
- package/src/broadcast/index.ts +21 -0
- package/src/broadcast/postman.ts +229 -0
- package/src/broadcast/reconcile.ts +120 -0
- package/src/broadcast/routes.ts +181 -0
- package/src/broadcast/ses.ts +181 -0
- package/src/broadcast/stats.ts +59 -0
- package/src/broadcast/status.ts +60 -0
- package/src/broadcast/test-send.ts +88 -0
- package/src/broadcast/warmup.ts +150 -0
- package/src/broadcast/worker.ts +177 -0
- package/src/cf-events.ts +84 -0
- package/src/cli/args.ts +27 -0
- package/src/cli/errors.ts +33 -0
- package/src/cli/main.ts +466 -0
- package/src/compose/clicks.ts +45 -0
- package/src/compose/compose.ts +257 -0
- package/src/compose/index.ts +8 -0
- package/src/compose/markdown.ts +624 -0
- package/src/compose/personalize.ts +130 -0
- package/src/compose/preflight.ts +250 -0
- package/src/compose/preview.ts +58 -0
- package/src/compose/render.ts +153 -0
- package/src/compose/template.ts +197 -0
- package/src/core.ts +328 -0
- package/src/export.ts +184 -0
- package/src/feedback.ts +111 -0
- package/src/http.ts +17 -0
- package/src/index.ts +378 -0
- package/src/list-routes.ts +42 -0
- package/src/lists.ts +370 -0
- package/src/ses-events.ts +426 -0
- package/src/transport.ts +193 -0
- package/src/unsub-wiring.ts +64 -0
- package/src/unsub.ts +499 -0
- package/src/webhook.ts +101 -0
- package/wrangler.example.jsonc +56 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Deploy template: copy to wrangler.jsonc, fill in your own account and database ids, then `npm run deploy`.
|
|
3
|
+
// wrangler.jsonc is git-ignored so your real ids never land in a fork.
|
|
4
|
+
"$schema": "node_modules/wrangler/config-schema.json",
|
|
5
|
+
"name": "mailroom",
|
|
6
|
+
// Recommended: deploying to the wrong account then fails loudly.
|
|
7
|
+
// "account_id": "<your Cloudflare account id>",
|
|
8
|
+
"main": "src/index.ts",
|
|
9
|
+
"compatibility_date": "2026-10-01",
|
|
10
|
+
// The public endpoints (Resend webhooks, clients on other Cloudflare accounts) live on workers.dev.
|
|
11
|
+
// If you don't need them, set this to false (or move them to a custom domain).
|
|
12
|
+
"workers_dev": true,
|
|
13
|
+
"preview_urls": false,
|
|
14
|
+
"d1_databases": [
|
|
15
|
+
{ "binding": "DB", "database_name": "mailroom", "database_id": "<fill in after: npx wrangler d1 create mailroom>", "migrations_dir": "migrations" }
|
|
16
|
+
],
|
|
17
|
+
"vars": {
|
|
18
|
+
// Sender domain for tier 1 "must deliver" mail (sign-in, invites, payments). Verify it with your providers first.
|
|
19
|
+
"FROM_DOMAIN": "notify.example.com",
|
|
20
|
+
// Sender domain for tier 2 "service reminders" (off by default). If you enable it, also set the secret
|
|
21
|
+
// RESEND_API_KEY_REMIND — without it tier 2 skips Resend and uses SMTP2GO only.
|
|
22
|
+
// "REMIND_DOMAIN": "remind.example.com",
|
|
23
|
+
// Provider order. Keys are "site:tier" or "*:tier"; anything not listed uses Resend -> SMTP2GO.
|
|
24
|
+
// Example: { "*:remind": ["cloudflare", "resend", "smtp2go"] }
|
|
25
|
+
"ROUTES": {},
|
|
26
|
+
// Clients that send over the public HTTP endpoint (comma separated). Each needs a secret HTTP_KEY_<SITE_NAME_UPPERCASE>.
|
|
27
|
+
"HTTP_CLIENTS": "",
|
|
28
|
+
// Per-client limits on the public HTTP endpoint (caps the damage if a client key leaks).
|
|
29
|
+
// Missing or invalid -> default; an explicit 0 means unlimited.
|
|
30
|
+
"HTTP_RATE_PER_MIN": 60,
|
|
31
|
+
"HTTP_DAILY_LIMIT": 2000
|
|
32
|
+
// Per-client sender allowlist for the public HTTP endpoint (REQUIRED for every client in HTTP_CLIENTS; a client without an entry is refused):
|
|
33
|
+
// "HTTP_FROM": { "shop": ["orders@notify.example.com"] },
|
|
34
|
+
// Delete ledger rows older than this many days (needs the cron trigger below). Unset = never delete automatically.
|
|
35
|
+
// "LEDGER_RETENTION_DAYS": 180
|
|
36
|
+
},
|
|
37
|
+
// Only needed if you send through Cloudflare Email Sending. List every allowed sender address.
|
|
38
|
+
// "send_email": [{ "name": "EMAIL", "remote": true, "allowed_sender_addresses": ["app@remind.example.com"] }],
|
|
39
|
+
// Delivery / bounce / complaint events from Cloudflare Email Sending (only if you use it).
|
|
40
|
+
// "queues": { "consumers": [{ "queue": "mailroom-email-events", "max_batch_size": 50, "max_batch_timeout": 30, "max_retries": 5 }] },
|
|
41
|
+
// Newsletter broadcasting (preview, see docs/broadcast.md). Off unless MARKETING_DOMAIN, NEWSLETTER_POSTMAN and the BROADCAST queue are all set.
|
|
42
|
+
// Add to "vars": "MARKETING_DOMAIN": "mail.example.com", "NEWSLETTER_POSTMAN": "fake", "NEWSLETTER_MAX_PER_DAY": 3000
|
|
43
|
+
// Amazon SES instead of the fake postman (docs/ses.md): "NEWSLETTER_POSTMAN": "ses", "SES_REGION": "us-east-1",
|
|
44
|
+
// "SES_CONFIGURATION_SET": "newsletter-events", "SES_SNS_TOPIC_ARNS": "arn:aws:sns:us-east-1:123456789012:newsletter-events"
|
|
45
|
+
// and Secrets SES_ACCESS_KEY_ID, SES_SECRET_ACCESS_KEY.
|
|
46
|
+
// "queues": {
|
|
47
|
+
// "producers": [{ "binding": "BROADCAST", "queue": "mailroom-broadcast" }],
|
|
48
|
+
// "consumers": [{ "queue": "mailroom-broadcast", "max_batch_size": 10, "max_concurrency": 1, "max_retries": 10, "dead_letter_queue": "mailroom-broadcast-dlq" }]
|
|
49
|
+
// },
|
|
50
|
+
// and a cron that runs every minute: "triggers": { "crons": ["* * * * *"] }
|
|
51
|
+
// Secrets (always add as Secret, never as a plain variable):
|
|
52
|
+
// RESEND_API_KEY, SMTP2GO_API_KEY, RESEND_WEBHOOK_SECRET, DRILL_TOKEN, HTTP_KEY_*, RESEND_API_KEY_REMIND (optional)
|
|
53
|
+
// Needed for LEDGER_RETENTION_DAYS and DAILY_DRILL: the Worker's scheduled handler runs on this trigger.
|
|
54
|
+
// "triggers": { "crons": ["17 3 * * *"] },
|
|
55
|
+
"observability": { "enabled": true }
|
|
56
|
+
}
|