@pithy-sh/email 0.1.2 → 0.1.3
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/dist/analytics.d.ts +19 -0
- package/dist/analytics.d.ts.map +1 -0
- package/dist/analytics.js +13 -0
- package/dist/audit/actions.d.ts +45 -0
- package/dist/audit/actions.d.ts.map +1 -0
- package/dist/audit/actions.js +45 -0
- package/dist/bounce/classify.d.ts +38 -0
- package/dist/bounce/classify.d.ts.map +1 -0
- package/dist/bounce/classify.js +46 -0
- package/dist/bounce/handler.d.ts +32 -0
- package/dist/bounce/handler.d.ts.map +1 -0
- package/dist/bounce/handler.js +81 -0
- package/dist/capability.d.ts +158 -0
- package/dist/capability.d.ts.map +1 -0
- package/dist/capability.js +255 -0
- package/dist/crypto/signingKey.d.ts +36 -0
- package/dist/crypto/signingKey.d.ts.map +1 -0
- package/dist/crypto/signingKey.js +36 -0
- package/dist/crypto/token.d.ts +47 -0
- package/dist/crypto/token.d.ts.map +1 -0
- package/dist/crypto/token.js +99 -0
- package/dist/data/emailEvent.d.ts +28 -0
- package/dist/data/emailEvent.d.ts.map +1 -0
- package/dist/data/emailEvent.js +22 -0
- package/dist/data/emailJob.d.ts +76 -0
- package/dist/data/emailJob.d.ts.map +1 -0
- package/dist/data/emailJob.js +62 -0
- package/dist/data/emailSuppression.d.ts +23 -0
- package/dist/data/emailSuppression.d.ts.map +1 -0
- package/dist/data/emailSuppression.js +21 -0
- package/dist/data/enums.d.ts +76 -0
- package/dist/data/enums.d.ts.map +1 -0
- package/dist/data/enums.js +65 -0
- package/dist/data/tables.d.ts +114 -0
- package/dist/data/tables.d.ts.map +1 -0
- package/dist/data/tables.js +30 -0
- package/dist/error/errors.d.ts +60 -0
- package/dist/error/errors.d.ts.map +1 -0
- package/dist/error/errors.js +82 -0
- package/dist/http/callbacks.d.ts +21 -0
- package/dist/http/callbacks.d.ts.map +1 -0
- package/dist/http/callbacks.js +110 -0
- package/dist/http/guards.d.ts +99 -0
- package/dist/http/guards.d.ts.map +1 -0
- package/dist/http/guards.js +144 -0
- package/dist/http/responses.d.ts +295 -0
- package/dist/http/responses.d.ts.map +1 -0
- package/dist/http/responses.js +115 -0
- package/dist/http/routes.d.ts +71 -0
- package/dist/http/routes.d.ts.map +1 -0
- package/dist/http/routes.js +292 -0
- package/dist/http/schemas.d.ts +90 -0
- package/dist/http/schemas.d.ts.map +1 -0
- package/dist/http/schemas.js +91 -0
- package/dist/http/view.d.ts +78 -0
- package/dist/http/view.d.ts.map +1 -0
- package/dist/http/view.js +130 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/jobs/read.d.ts +191 -0
- package/dist/jobs/read.d.ts.map +1 -0
- package/dist/jobs/read.js +143 -0
- package/dist/jobs/retry.d.ts +99 -0
- package/dist/jobs/retry.d.ts.map +1 -0
- package/dist/jobs/retry.js +67 -0
- package/dist/migrations/0001_init.d.ts +32 -0
- package/dist/migrations/0001_init.d.ts.map +1 -0
- package/dist/migrations/0001_init.js +60 -0
- package/dist/migrations/0001_suppressions.d.ts +10 -0
- package/dist/migrations/0001_suppressions.d.ts.map +1 -0
- package/dist/migrations/0001_suppressions.js +20 -0
- package/dist/provision/devDelivery.d.ts +32 -0
- package/dist/provision/devDelivery.d.ts.map +1 -0
- package/dist/provision/devDelivery.js +37 -0
- package/dist/provision/hostCatalogs.d.ts +10 -0
- package/dist/provision/hostCatalogs.d.ts.map +1 -0
- package/dist/provision/hostCatalogs.js +78 -0
- package/dist/provision/provisionEmail.d.ts +143 -0
- package/dist/provision/provisionEmail.d.ts.map +1 -0
- package/dist/provision/provisionEmail.js +118 -0
- package/dist/provision/resolveEmailConfig.d.ts +122 -0
- package/dist/provision/resolveEmailConfig.d.ts.map +1 -0
- package/dist/provision/resolveEmailConfig.js +124 -0
- package/dist/provision/settingsCheck.d.ts +40 -0
- package/dist/provision/settingsCheck.d.ts.map +1 -0
- package/dist/provision/settingsCheck.js +138 -0
- package/dist/send/batchIdentity.d.ts +42 -0
- package/dist/send/batchIdentity.d.ts.map +1 -0
- package/dist/send/batchIdentity.js +46 -0
- package/dist/send/enqueue.d.ts +216 -0
- package/dist/send/enqueue.d.ts.map +1 -0
- package/dist/send/enqueue.js +153 -0
- package/dist/send/errorMapping.d.ts +27 -0
- package/dist/send/errorMapping.d.ts.map +1 -0
- package/dist/send/errorMapping.js +52 -0
- package/dist/send/events.d.ts +15 -0
- package/dist/send/events.d.ts.map +1 -0
- package/dist/send/events.js +17 -0
- package/dist/send/fromComposition.d.ts +47 -0
- package/dist/send/fromComposition.d.ts.map +1 -0
- package/dist/send/fromComposition.js +53 -0
- package/dist/send/retryPolicy.d.ts +32 -0
- package/dist/send/retryPolicy.d.ts.map +1 -0
- package/dist/send/retryPolicy.js +39 -0
- package/dist/send/runSend.d.ts +106 -0
- package/dist/send/runSend.d.ts.map +1 -0
- package/dist/send/runSend.js +218 -0
- package/dist/send/sendAt.d.ts +6 -0
- package/dist/send/sendAt.d.ts.map +1 -0
- package/dist/send/sendAt.js +62 -0
- package/dist/send/sender.d.ts +42 -0
- package/dist/send/sender.d.ts.map +1 -0
- package/dist/send/sender.js +0 -0
- package/dist/send/senderBinding.d.ts +44 -0
- package/dist/send/senderBinding.d.ts.map +1 -0
- package/dist/send/senderBinding.js +21 -0
- package/dist/send/suppression.d.ts +93 -0
- package/dist/send/suppression.d.ts.map +1 -0
- package/dist/send/suppression.js +132 -0
- package/dist/templates/engine.d.ts +109 -0
- package/dist/templates/engine.d.ts.map +1 -0
- package/dist/templates/engine.js +258 -0
- package/dist/templates/messages.d.ts +94 -0
- package/dist/templates/messages.d.ts.map +1 -0
- package/dist/templates/messages.es.d.ts +29 -0
- package/dist/templates/messages.es.d.ts.map +1 -0
- package/dist/templates/messages.es.js +82 -0
- package/dist/templates/messages.js +266 -0
- package/dist/templates/partials.d.ts +5 -0
- package/dist/templates/partials.d.ts.map +1 -0
- package/dist/templates/partials.js +59 -0
- package/dist/templates/precompiled.generated.d.ts +266 -0
- package/dist/templates/precompiled.generated.d.ts.map +1 -0
- package/dist/templates/precompiled.generated.js +4039 -0
- package/dist/templates/registry.d.ts +118 -0
- package/dist/templates/registry.d.ts.map +1 -0
- package/dist/templates/registry.js +323 -0
- package/dist/templates/samples.d.ts +7 -0
- package/dist/templates/samples.d.ts.map +1 -0
- package/dist/templates/samples.js +98 -0
- package/dist/templates/severity.d.ts +40 -0
- package/dist/templates/severity.d.ts.map +1 -0
- package/dist/templates/severity.js +81 -0
- package/dist/templates/theme.d.ts +193 -0
- package/dist/templates/theme.d.ts.map +1 -0
- package/dist/templates/theme.js +168 -0
- package/dist/version.generated.d.ts +5 -0
- package/dist/version.generated.d.ts.map +1 -0
- package/dist/version.generated.js +7 -0
- package/dist/workflows/hostApp.d.ts +33 -0
- package/dist/workflows/hostApp.d.ts.map +1 -0
- package/dist/workflows/hostApp.js +19 -0
- package/dist/workflows/hostEnv.d.ts +129 -0
- package/dist/workflows/hostEnv.d.ts.map +1 -0
- package/dist/workflows/hostEnv.js +147 -0
- package/dist/workflows/instanceLiveness.d.ts +3 -0
- package/dist/workflows/instanceLiveness.d.ts.map +1 -0
- package/dist/workflows/instanceLiveness.js +37 -0
- package/dist/workflows/instances.d.ts +18 -0
- package/dist/workflows/instances.d.ts.map +1 -0
- package/dist/workflows/instances.js +0 -0
- package/dist/workflows/params.d.ts +23 -0
- package/dist/workflows/params.d.ts.map +1 -0
- package/dist/workflows/params.js +21 -0
- package/dist/workflows/scheduler.d.ts +82 -0
- package/dist/workflows/scheduler.d.ts.map +1 -0
- package/dist/workflows/scheduler.js +111 -0
- package/dist/workflows/sendBatch.d.ts +85 -0
- package/dist/workflows/sendBatch.d.ts.map +1 -0
- package/dist/workflows/sendBatch.js +50 -0
- package/dist/workflows/worker.d.ts +100 -0
- package/dist/workflows/worker.d.ts.map +1 -0
- package/dist/workflows/worker.js +117 -0
- package/package.json +22 -11
- package/src/version.generated.ts +1 -1
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { EmailJobStatus, SendMode, SuppressionReason, TemplateCategory } from "../data/enums.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/http/responses.ts
|
|
4
|
+
/**
|
|
5
|
+
* What the email management routes return, as Zod objects a management client can validate against.
|
|
6
|
+
*
|
|
7
|
+
* `schemas.ts` bounds what a caller may send; this file states what it gets back. Both halves are
|
|
8
|
+
* runtime values for the same reason: a management client reading a customer's Worker is crossing a
|
|
9
|
+
* trust boundary and must validate what comes back, and a TypeScript interface is erased before it
|
|
10
|
+
* can help. Every client that had only an interface hand-wrote a mirror of these, and the mirror
|
|
11
|
+
* drifted the first time a field landed here.
|
|
12
|
+
*
|
|
13
|
+
* **No codecs, and no transform anywhere in this file.** These describe JSON on the wire, so parsing
|
|
14
|
+
* one hands back exactly what went in — which is what lets `responses.test.ts` compare a parsed value
|
|
15
|
+
* with the projection's output and fail on a field either side forgot.
|
|
16
|
+
*
|
|
17
|
+
* The projections live in `view.ts`, which documents *why* the list masks a recipient and the detail
|
|
18
|
+
* does not, and why `payload` appears in neither. This file is the shape; that file is the argument.
|
|
19
|
+
*
|
|
20
|
+
* **A field added here later is `.optional()`, not merely `.nullable()`.** This module is read across a
|
|
21
|
+
* version boundary — a management client validates a response with this schema against a customer's
|
|
22
|
+
* Worker at whatever kit version it is on — so an additive required key fails `safeParse` for everyone
|
|
23
|
+
* below that release and takes the whole pane with it (#450). Absent then means *this Worker cannot
|
|
24
|
+
* say*, which is a different fact from `null`.
|
|
25
|
+
*/
|
|
26
|
+
/** Where a page resumes, or the end of the list. */
|
|
27
|
+
const NextCursor = z.string().nullable().describe("Where the next page resumes. Null at the end of the list. Opaque — pass it back verbatim.");
|
|
28
|
+
/** One job as the list shows it: enough to scan, not enough to harvest. */
|
|
29
|
+
const EmailJobListItem = z.object({
|
|
30
|
+
id: z.string().describe("The job id — what the detail and retry routes take."),
|
|
31
|
+
recipient: z.string().describe("The recipient, masked (`ad***@example.com`). The detail route has the whole address."),
|
|
32
|
+
template: z.string().describe("The template that produced this email. Structural, so it names the kind of mail with no content."),
|
|
33
|
+
category: TemplateCategory.describe("`transactional` or `marketing`."),
|
|
34
|
+
locale: z.string().nullable().optional().describe("The language this message was written in, as a BCP-47 tag; null when the recipient never chose one and it went out in the kit's English, and absent when the Worker that answered predates the field (#450)."),
|
|
35
|
+
status: EmailJobStatus.describe("The lifecycle state."),
|
|
36
|
+
mode: SendMode.describe("How the send time was decided."),
|
|
37
|
+
attempts: z.number().int().describe("How many send attempts have been made."),
|
|
38
|
+
campaignId: z.string().nullable().describe("The campaign this belongs to; null for transactional mail."),
|
|
39
|
+
bounceType: z.string().nullable().describe("How a bounce was classified (`hard` | `soft` | `complaint` | `auto_reply`), when one arrived. A loose string rather than the enum, because the column is one: a response schema that narrowed what the table admits would reject a row this Worker can legitimately hold, and the place to close that is the column, not the wire."),
|
|
40
|
+
failed: z.boolean().describe("Whether the row carries an error, without carrying it — a provider error routinely embeds the recipient, so the text is on the detail route."),
|
|
41
|
+
sendAt: z.iso.datetime().describe("When this job is (or was) due to send, ISO-8601."),
|
|
42
|
+
createdAt: z.iso.datetime().describe("When the row was created, ISO-8601. The list's sort key."),
|
|
43
|
+
sentAt: z.iso.datetime().nullable().describe("When the send succeeded, ISO-8601; null until then.")
|
|
44
|
+
}).describe("One email job as the send log lists it. The recipient is masked and no rendered content appears.");
|
|
45
|
+
/**
|
|
46
|
+
* One job in full.
|
|
47
|
+
*
|
|
48
|
+
* Re-described after `.omit()`/`.extend()`: each builds a new schema, and a description does not
|
|
49
|
+
* follow it.
|
|
50
|
+
*
|
|
51
|
+
* `locale` is **not** re-declared below. It is on the list item, so the detail inherits it and there is
|
|
52
|
+
* one sentence describing the tag rather than two free to drift — and the fact the detail's own copy
|
|
53
|
+
* used to carry, that null means nobody chose, is the fact the list needs most.
|
|
54
|
+
*/
|
|
55
|
+
const EmailJobDetail = EmailJobListItem.omit({
|
|
56
|
+
recipient: true,
|
|
57
|
+
failed: true
|
|
58
|
+
}).extend({
|
|
59
|
+
toAddress: z.string().describe("The recipient, in full. Disclosed one job at a time, and audited as such."),
|
|
60
|
+
subject: z.string().describe("The rendered subject line — the one piece of rendered content a send cannot be diagnosed without."),
|
|
61
|
+
fromAddress: z.string().describe("The sending identity — the adopter's own configuration."),
|
|
62
|
+
fromName: z.string().describe("The sender display name recipients saw."),
|
|
63
|
+
messageId: z.string().nullable().describe("The Email Service message id a later bounce is attributed through."),
|
|
64
|
+
error: z.string().nullable().describe("The last error recorded against this job; null when healthy."),
|
|
65
|
+
bounceCode: z.string().nullable().describe("The SMTP or Email Service code from a bounce; null unless it bounced."),
|
|
66
|
+
timezone: z.string().nullable().describe("The recipient's IANA timezone, for a `timezone`-mode send."),
|
|
67
|
+
localTime: z.string().nullable().describe("The recipient-local time-of-day, for a `timezone`-mode send."),
|
|
68
|
+
openTracking: z.boolean().describe("Whether an open-tracking pixel was injected."),
|
|
69
|
+
clickTracking: z.boolean().describe("Whether links were rewritten to tracked callbacks."),
|
|
70
|
+
updatedAt: z.iso.datetime().describe("When the row was last written, ISO-8601.")
|
|
71
|
+
}).describe("One email job in full. Never the template payload — that is the sign-in link and the OTP.");
|
|
72
|
+
/** One suppressed address, as a management client sees it. */
|
|
73
|
+
const EmailSuppressionView = z.object({
|
|
74
|
+
id: z.number().int().describe("The row's surrogate key — the handle the audit trail names."),
|
|
75
|
+
email: z.string().describe("The blocked address, in full. The record is the address, so there is nothing to mask."),
|
|
76
|
+
reason: SuppressionReason.describe("Why it is blocked: hard bounce, complaint, unsubscribe, or a manual block."),
|
|
77
|
+
environment: z.string().nullable().describe("The environment the triggering job came from; the block itself applies everywhere."),
|
|
78
|
+
jobId: z.string().nullable().describe("The job that triggered it, when one did."),
|
|
79
|
+
detail: z.string().nullable().describe("Free-form context — the bounce code, or what an operator typed."),
|
|
80
|
+
createdAt: z.iso.datetime().describe("When the address was blocked, ISO-8601."),
|
|
81
|
+
expiresAt: z.iso.datetime().nullable().describe("When a temporary block lifts, ISO-8601; null when permanent."),
|
|
82
|
+
active: z.boolean().describe("Whether the block is in force right now. Computed here, so no client re-implements the comparison the send path already makes.")
|
|
83
|
+
}).describe("One suppressed address, with the block's provenance and whether it is in force.");
|
|
84
|
+
/** `GET {base}/jobs`. */
|
|
85
|
+
const EmailJobsResponse = z.object({
|
|
86
|
+
jobs: z.array(EmailJobListItem).describe("The page, newest first."),
|
|
87
|
+
nextCursor: NextCursor
|
|
88
|
+
}).describe("A page of the send log.");
|
|
89
|
+
/** `GET {base}/jobs/:id`. */
|
|
90
|
+
const EmailJobResponse = z.object({ job: EmailJobDetail.describe("The job, whole recipient included.") }).describe("One email job in full.");
|
|
91
|
+
/** `POST {base}/jobs/:id/retry`. */
|
|
92
|
+
const EmailJobRetryResponse = z.object({
|
|
93
|
+
job: EmailJobDetail.describe("The job as the retry left it."),
|
|
94
|
+
dispatched: z.boolean().describe("Whether a send Workflow actually started. False when no sender is bound — the row is queued, and nothing was mailed.")
|
|
95
|
+
}).describe("The retried job, and whether a send actually started.");
|
|
96
|
+
/** `GET {base}/suppressions`. */
|
|
97
|
+
const EmailSuppressionsResponse = z.object({
|
|
98
|
+
suppressions: z.array(EmailSuppressionView).describe("The page, newest first."),
|
|
99
|
+
nextCursor: NextCursor
|
|
100
|
+
}).describe("A page of the suppression list.");
|
|
101
|
+
/** `POST {base}/suppressions`. */
|
|
102
|
+
const EmailSuppressResponse = z.object({ suppression: EmailSuppressionView.nullable().describe("The row as stored, read back so the response is the truth rather than the request echoed. Null only if the read-back found nothing.") }).describe("The address as the suppression list now holds it.");
|
|
103
|
+
/**
|
|
104
|
+
* `POST {base}/suppressions/remove`.
|
|
105
|
+
*
|
|
106
|
+
* The address is echoed because the caller sent it, normalized so the client learns which row was
|
|
107
|
+
* addressed rather than guessing at the lowercasing. Nothing about the block that was lifted appears:
|
|
108
|
+
* that is in the audit trail, where reading it needs its own grant.
|
|
109
|
+
*/
|
|
110
|
+
const EmailUnsuppressResponse = z.object({
|
|
111
|
+
email: z.string().describe("The address, normalized the way the suppression list stores it."),
|
|
112
|
+
removed: z.boolean().describe("Whether a row was removed. False when the address was not on the list.")
|
|
113
|
+
}).describe("Which address was unblocked, and whether there was anything to unblock.");
|
|
114
|
+
//#endregion
|
|
115
|
+
export { EmailJobDetail, EmailJobListItem, EmailJobResponse, EmailJobRetryResponse, EmailJobsResponse, EmailSuppressResponse, EmailSuppressionView, EmailSuppressionsResponse, EmailUnsuppressResponse };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { PithyHonoEnv } from "@pithy-sh/core/src/capability/capability";
|
|
2
|
+
import type { ControlPlaneScope } from "@pithy-sh/core/src/controlPlane/scope/scope";
|
|
3
|
+
import type { VerificationStrategy } from "@pithy-sh/core/src/http/verification";
|
|
4
|
+
import type { Hono } from "hono";
|
|
5
|
+
/**
|
|
6
|
+
* The email management routes, their declared verification strategies, and what each accepts:
|
|
7
|
+
*
|
|
8
|
+
* GET /email/jobs → the send log (control-plane: email:jobs:read) query
|
|
9
|
+
* GET /email/jobs/:id → one job in full (control-plane: email:jobs:read) param
|
|
10
|
+
* POST /email/jobs/:id/retry → queue it again (control-plane: email:jobs:retry) param
|
|
11
|
+
* GET /email/suppressions → who we won't mail (control-plane: email:suppressions:read) query
|
|
12
|
+
* POST /email/suppressions → block an address (control-plane: email:suppressions:write) json
|
|
13
|
+
* POST /email/suppressions/remove → unblock one (control-plane: email:suppressions:delete) json
|
|
14
|
+
*
|
|
15
|
+
* **Every route here is `control-plane`, and there is no end-user surface in this file.** A recipient
|
|
16
|
+
* interacts with email by receiving it; the three routes a recipient does call — click, open,
|
|
17
|
+
* unsubscribe — live in `callbacks.ts`, are public, and are gated by the signature on the token in the
|
|
18
|
+
* path. Nothing below has any business answering an ordinary user, and with the seam uncomposed every
|
|
19
|
+
* one of them answers 403 `controlplane/not_connected`.
|
|
20
|
+
*
|
|
21
|
+
* **Validators sit after the gate on every line.** A validator ahead of it turns a 403 into a 400 and
|
|
22
|
+
* tells an unverified caller which requests were well-formed — on this surface that is a live oracle
|
|
23
|
+
* for the shape of the send log and, worse, a way to learn that a given address parses as one this
|
|
24
|
+
* deployment would accept.
|
|
25
|
+
*
|
|
26
|
+
* **Every response has an exported schema**, in `responses.ts`, and each `c.json` below is
|
|
27
|
+
* `satisfies`-checked against its envelope. A management client imports the same object and validates
|
|
28
|
+
* with it rather than hand-writing a mirror that drifts. The check is at compile time on purpose:
|
|
29
|
+
* parsing every response would spend a validation pass on rows this Worker just read, and would turn a
|
|
30
|
+
* shape mistake into a 500 in production rather than a red build.
|
|
31
|
+
*
|
|
32
|
+
* **Removal is a POST with a body, not `DELETE /suppressions/:email`.** An address in a path is an
|
|
33
|
+
* address in every access log, every proxy, every trace, and every referrer between the client and the
|
|
34
|
+
* Worker. The record is personal data whether or not it is a person's current address, so it travels in
|
|
35
|
+
* a body. Testers' `POST /remove` is the same call made for the same reason.
|
|
36
|
+
*/
|
|
37
|
+
/** What every route this capability mounts declares: its path, its strategy, and the scope it checks. */
|
|
38
|
+
export interface EmailRouteDeclaration {
|
|
39
|
+
readonly method: "GET" | "POST";
|
|
40
|
+
/** The path relative to the configured `basePath`, e.g. `/jobs`. */
|
|
41
|
+
readonly path: string;
|
|
42
|
+
readonly strategy: VerificationStrategy;
|
|
43
|
+
/** The control-plane scope this route checks. */
|
|
44
|
+
readonly scope: ControlPlaneScope;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Every management route, and how it is gated.
|
|
48
|
+
*
|
|
49
|
+
* Exported so a test can assert against the declaration rather than against a middleware count. A count
|
|
50
|
+
* proves that *something* runs before the handler — a bare `zValidator` satisfies it — and cannot prove
|
|
51
|
+
* *what*. `routeContract.test.ts` checks this list against the paths Hono actually registered, in both
|
|
52
|
+
* directions, so a route added without an entry and an entry without a route both fail.
|
|
53
|
+
*/
|
|
54
|
+
export declare const EMAIL_ADMIN_ROUTES: readonly EmailRouteDeclaration[];
|
|
55
|
+
/** How the email management sub-router is built. */
|
|
56
|
+
export interface EmailAdminRoutesOptions {
|
|
57
|
+
/**
|
|
58
|
+
* Where the routes mount.
|
|
59
|
+
*
|
|
60
|
+
* Required, with no default of its own. The manifest advertises these paths and a client composes its
|
|
61
|
+
* calls from the manifest, so the mount point and the advertised path must come from one value — a
|
|
62
|
+
* default here and a default in the config is two, and the day they disagree every management call
|
|
63
|
+
* 404s against exactly the adopters who customized anything.
|
|
64
|
+
*/
|
|
65
|
+
basePath: string;
|
|
66
|
+
/** The clock. Injected so retried timestamps are deterministic in tests. */
|
|
67
|
+
now?: () => Date;
|
|
68
|
+
}
|
|
69
|
+
/** Register the email management sub-router. Composed alongside the public callbacks. */
|
|
70
|
+
export declare function registerEmailAdminRoutes(options: EmailAdminRoutesOptions): (app: Hono<PithyHonoEnv>) => void;
|
|
71
|
+
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/http/routes.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAG7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AAGrF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,MAAM,CAAC;AA+B1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,yGAAyG;AACzG,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,MAAM,EAAE,KAAK,GAAG,MAAM,CAAC;IAChC,oEAAoE;IACpE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAC;IACxC,iDAAiD;IACjD,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC;CACnC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,EAAE,SAAS,qBAAqB,EAY9D,CAAC;AAaF,oDAAoD;AACpD,MAAM,WAAW,uBAAuB;IACtC;;;;;;;OAOG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAClB;AAiDD,yFAAyF;AACzF,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,uBAAuB,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,IAAI,CA2R5G"}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { emailDatabase, emailSuppressionDatabase } from "../data/tables.js";
|
|
2
|
+
import { listSuppressions, suppress, unsuppress } from "../send/suppression.js";
|
|
3
|
+
import { JobIdParam, JobsQuery, SuppressRequest, SuppressionsQuery, UnsuppressRequest } from "./schemas.js";
|
|
4
|
+
import { EMAIL_JOBS_READ_SCOPE, EMAIL_JOBS_RETRY_SCOPE, EMAIL_SUPPRESSIONS_DELETE_SCOPE, EMAIL_SUPPRESSIONS_READ_SCOPE, EMAIL_SUPPRESSIONS_WRITE_SCOPE } from "./guards.js";
|
|
5
|
+
import { EmailAuditActions } from "../audit/actions.js";
|
|
6
|
+
import { getJob, listJobs } from "../jobs/read.js";
|
|
7
|
+
import { retryJob } from "../jobs/retry.js";
|
|
8
|
+
import { emailSenderBinding } from "../send/senderBinding.js";
|
|
9
|
+
import { jobDetailView, jobListView, suppressionView } from "./view.js";
|
|
10
|
+
import { ConflictError, InternalError, NotFoundError, ValidationError } from "@pithy-sh/core/src/error/pithyError";
|
|
11
|
+
import { normalizeAddress } from "@pithy-sh/core/src/address/address";
|
|
12
|
+
import { zValidator } from "@hono/zod-validator";
|
|
13
|
+
import { validationHook } from "@pithy-sh/core/src/http/validation";
|
|
14
|
+
import { requireControlPlane } from "@pithy-sh/core/src/controlPlane/http/guard";
|
|
15
|
+
//#region src/http/routes.ts
|
|
16
|
+
/**
|
|
17
|
+
* Every management route, and how it is gated.
|
|
18
|
+
*
|
|
19
|
+
* Exported so a test can assert against the declaration rather than against a middleware count. A count
|
|
20
|
+
* proves that *something* runs before the handler — a bare `zValidator` satisfies it — and cannot prove
|
|
21
|
+
* *what*. `routeContract.test.ts` checks this list against the paths Hono actually registered, in both
|
|
22
|
+
* directions, so a route added without an entry and an entry without a route both fail.
|
|
23
|
+
*/
|
|
24
|
+
const EMAIL_ADMIN_ROUTES = [
|
|
25
|
+
{
|
|
26
|
+
method: "GET",
|
|
27
|
+
path: "/jobs",
|
|
28
|
+
strategy: "control-plane",
|
|
29
|
+
scope: EMAIL_JOBS_READ_SCOPE
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
method: "GET",
|
|
33
|
+
path: "/jobs/:id",
|
|
34
|
+
strategy: "control-plane",
|
|
35
|
+
scope: EMAIL_JOBS_READ_SCOPE
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
method: "POST",
|
|
39
|
+
path: "/jobs/:id/retry",
|
|
40
|
+
strategy: "control-plane",
|
|
41
|
+
scope: EMAIL_JOBS_RETRY_SCOPE
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
method: "GET",
|
|
45
|
+
path: "/suppressions",
|
|
46
|
+
strategy: "control-plane",
|
|
47
|
+
scope: EMAIL_SUPPRESSIONS_READ_SCOPE
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
method: "POST",
|
|
51
|
+
path: "/suppressions",
|
|
52
|
+
strategy: "control-plane",
|
|
53
|
+
scope: EMAIL_SUPPRESSIONS_WRITE_SCOPE
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
method: "POST",
|
|
57
|
+
path: "/suppressions/remove",
|
|
58
|
+
strategy: "control-plane",
|
|
59
|
+
scope: EMAIL_SUPPRESSIONS_DELETE_SCOPE
|
|
60
|
+
}
|
|
61
|
+
];
|
|
62
|
+
/**
|
|
63
|
+
* A required D1 binding, or a stated wiring failure.
|
|
64
|
+
*
|
|
65
|
+
* `email()` declares both databases in `requiredBindings`, so an absent one is a Worker assembled
|
|
66
|
+
* wrong rather than a request doing anything unusual — hence a 500 that names the fix, not a 4xx that
|
|
67
|
+
* blames the caller.
|
|
68
|
+
*/
|
|
69
|
+
function d1(c, binding) {
|
|
70
|
+
const found = c.env[binding];
|
|
71
|
+
if (!found) throw new InternalError({
|
|
72
|
+
message: "Email is not fully configured on this Worker.",
|
|
73
|
+
action: `Bind a D1 database named ${binding} in wrangler.jsonc, then run pithy migrate.`,
|
|
74
|
+
detail: `the email management routes require a \`${binding}\` D1 binding; none was present on env`
|
|
75
|
+
});
|
|
76
|
+
return found;
|
|
77
|
+
}
|
|
78
|
+
/** The per-environment jobs database. */
|
|
79
|
+
function jobs(c) {
|
|
80
|
+
return emailDatabase(d1(c, "DB"));
|
|
81
|
+
}
|
|
82
|
+
/** The global suppression database. */
|
|
83
|
+
function suppressions(c) {
|
|
84
|
+
return emailSuppressionDatabase(d1(c, "EMAIL_SUPPRESSIONS"));
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The verified management caller.
|
|
88
|
+
*
|
|
89
|
+
* `requireControlPlane()` has run on every route in this file, so a null here is a route mounted
|
|
90
|
+
* without its gate — a programming error, not an unauthenticated request, and therefore an internal
|
|
91
|
+
* error rather than a 401 that would imply a credential could fix it.
|
|
92
|
+
*/
|
|
93
|
+
function caller(c) {
|
|
94
|
+
const context = c.var.controlPlane;
|
|
95
|
+
if (!context) throw new InternalError({
|
|
96
|
+
message: "Email could not identify the management caller.",
|
|
97
|
+
detail: "requireControlPlane() must run before an email handler reads the caller."
|
|
98
|
+
});
|
|
99
|
+
return context;
|
|
100
|
+
}
|
|
101
|
+
/** Register the email management sub-router. Composed alongside the public callbacks. */
|
|
102
|
+
function registerEmailAdminRoutes(options) {
|
|
103
|
+
const base = options.basePath;
|
|
104
|
+
const clock = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
105
|
+
return (app) => {
|
|
106
|
+
app.get(`${base}/jobs`, requireControlPlane(EMAIL_JOBS_READ_SCOPE), zValidator("query", JobsQuery, validationHook), async (c) => {
|
|
107
|
+
const query = c.req.valid("query");
|
|
108
|
+
const who = caller(c);
|
|
109
|
+
const page = await listJobs(jobs(c), query);
|
|
110
|
+
await c.var.emit({
|
|
111
|
+
action: EmailAuditActions.jobsRead,
|
|
112
|
+
outcome: "success",
|
|
113
|
+
actorType: "control-plane",
|
|
114
|
+
actorId: who.subject,
|
|
115
|
+
resourceType: "email_job",
|
|
116
|
+
resourceId: null,
|
|
117
|
+
metadata: {
|
|
118
|
+
connectionId: who.connectionId,
|
|
119
|
+
status: query.status ?? null,
|
|
120
|
+
returned: page.items.length,
|
|
121
|
+
paged: Boolean(query.cursor)
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
return c.json({
|
|
125
|
+
jobs: page.items.map(jobListView),
|
|
126
|
+
nextCursor: page.nextCursor
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
app.get(`${base}/jobs/:id`, requireControlPlane(EMAIL_JOBS_READ_SCOPE), zValidator("param", JobIdParam, validationHook), async (c) => {
|
|
130
|
+
const { id } = c.req.valid("param");
|
|
131
|
+
const who = caller(c);
|
|
132
|
+
const job = await getJob(jobs(c), id);
|
|
133
|
+
if (!job) throw new NotFoundError({
|
|
134
|
+
message: "No such email job.",
|
|
135
|
+
action: "Check the job id against the send log.",
|
|
136
|
+
detail: `email job '${id}' not found`
|
|
137
|
+
});
|
|
138
|
+
await c.var.emit({
|
|
139
|
+
action: EmailAuditActions.jobRead,
|
|
140
|
+
outcome: "success",
|
|
141
|
+
actorType: "control-plane",
|
|
142
|
+
actorId: who.subject,
|
|
143
|
+
resourceType: "email_job",
|
|
144
|
+
resourceId: job.id,
|
|
145
|
+
metadata: {
|
|
146
|
+
connectionId: who.connectionId,
|
|
147
|
+
status: job.status,
|
|
148
|
+
template: job.template
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
return c.json({ job: jobDetailView(job) });
|
|
152
|
+
});
|
|
153
|
+
app.post(`${base}/jobs/:id/retry`, requireControlPlane(EMAIL_JOBS_RETRY_SCOPE), zValidator("param", JobIdParam, validationHook), async (c) => {
|
|
154
|
+
const { id } = c.req.valid("param");
|
|
155
|
+
const who = caller(c);
|
|
156
|
+
const now = clock();
|
|
157
|
+
const db = jobs(c);
|
|
158
|
+
const before = await getJob(db, id);
|
|
159
|
+
const result = await retryJob({
|
|
160
|
+
db,
|
|
161
|
+
suppressionDb: suppressions(c),
|
|
162
|
+
sender: emailSenderBinding(c.env),
|
|
163
|
+
now
|
|
164
|
+
}, id);
|
|
165
|
+
await c.var.emit({
|
|
166
|
+
action: EmailAuditActions.jobRetried,
|
|
167
|
+
outcome: "success",
|
|
168
|
+
severity: "warning",
|
|
169
|
+
actorType: "control-plane",
|
|
170
|
+
actorId: who.subject,
|
|
171
|
+
resourceType: "email_job",
|
|
172
|
+
resourceId: result.job.id,
|
|
173
|
+
metadata: {
|
|
174
|
+
connectionId: who.connectionId,
|
|
175
|
+
from: before?.status ?? null,
|
|
176
|
+
template: result.job.template,
|
|
177
|
+
dispatched: result.dispatched
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
return c.json({
|
|
181
|
+
job: jobDetailView(result.job),
|
|
182
|
+
dispatched: result.dispatched
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
app.get(`${base}/suppressions`, requireControlPlane(EMAIL_SUPPRESSIONS_READ_SCOPE), zValidator("query", SuppressionsQuery, validationHook), async (c) => {
|
|
186
|
+
const query = c.req.valid("query");
|
|
187
|
+
const who = caller(c);
|
|
188
|
+
const now = clock();
|
|
189
|
+
const page = await listSuppressions(suppressions(c), query);
|
|
190
|
+
await c.var.emit({
|
|
191
|
+
action: EmailAuditActions.suppressionsRead,
|
|
192
|
+
outcome: "success",
|
|
193
|
+
actorType: "control-plane",
|
|
194
|
+
actorId: who.subject,
|
|
195
|
+
resourceType: "email_suppression",
|
|
196
|
+
resourceId: null,
|
|
197
|
+
metadata: {
|
|
198
|
+
connectionId: who.connectionId,
|
|
199
|
+
reason: query.reason ?? null,
|
|
200
|
+
lookup: Boolean(query.email),
|
|
201
|
+
returned: page.items.length,
|
|
202
|
+
paged: Boolean(query.cursor)
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
return c.json({
|
|
206
|
+
suppressions: page.items.map((row) => suppressionView(row, now)),
|
|
207
|
+
nextCursor: page.nextCursor
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
app.post(`${base}/suppressions`, requireControlPlane(EMAIL_SUPPRESSIONS_WRITE_SCOPE), zValidator("json", SuppressRequest, validationHook), async (c) => {
|
|
211
|
+
const input = c.req.valid("json");
|
|
212
|
+
const who = caller(c);
|
|
213
|
+
const now = clock();
|
|
214
|
+
const email = normalizeAddress(input.email);
|
|
215
|
+
const db = suppressions(c);
|
|
216
|
+
const expiresAt = input.expiresAt ? new Date(input.expiresAt) : null;
|
|
217
|
+
if (expiresAt && expiresAt.getTime() <= now.getTime()) throw new ValidationError({
|
|
218
|
+
message: "That expiry has already passed, so it would not block anything.",
|
|
219
|
+
action: "Give a future instant, or omit `expiresAt` to block permanently. To lift an existing block, use the remove route — it requires `email:suppressions:delete`.",
|
|
220
|
+
detail: `refused suppression for ${email} with expiresAt ${expiresAt.toISOString()} at ${now.toISOString()}`
|
|
221
|
+
});
|
|
222
|
+
const current = (await listSuppressions(db, {
|
|
223
|
+
email,
|
|
224
|
+
limit: 1
|
|
225
|
+
})).items[0];
|
|
226
|
+
if (current && current.reason !== "manual") throw new ConflictError({
|
|
227
|
+
message: `${email} is already suppressed as a ${current.reason}, which this route may not overwrite.`,
|
|
228
|
+
action: "Lift it with the remove route, which requires `email:suppressions:delete` — undoing a bounce, a complaint, or someone's own opt-out is a separate decision.",
|
|
229
|
+
detail: `refused manual suppression over an existing ${current.reason} for ${email}`
|
|
230
|
+
});
|
|
231
|
+
await suppress(db, {
|
|
232
|
+
email,
|
|
233
|
+
reason: "manual",
|
|
234
|
+
detail: input.detail ?? "blocked by a management client",
|
|
235
|
+
environment: c.env.ENVIRONMENT ?? null,
|
|
236
|
+
expiresAt
|
|
237
|
+
}, now);
|
|
238
|
+
const row = (await listSuppressions(db, {
|
|
239
|
+
email,
|
|
240
|
+
limit: 1
|
|
241
|
+
})).items[0];
|
|
242
|
+
await c.var.emit({
|
|
243
|
+
action: EmailAuditActions.suppressionAdded,
|
|
244
|
+
outcome: "success",
|
|
245
|
+
severity: "warning",
|
|
246
|
+
actorType: "control-plane",
|
|
247
|
+
actorId: who.subject,
|
|
248
|
+
resourceType: "email_suppression",
|
|
249
|
+
resourceId: row ? String(row.id) : null,
|
|
250
|
+
metadata: {
|
|
251
|
+
connectionId: who.connectionId,
|
|
252
|
+
email,
|
|
253
|
+
reason: "manual",
|
|
254
|
+
expiresAt: input.expiresAt ?? null
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
return c.json({ suppression: row ? suppressionView(row, now) : null }, 200);
|
|
258
|
+
});
|
|
259
|
+
app.post(`${base}/suppressions/remove`, requireControlPlane(EMAIL_SUPPRESSIONS_DELETE_SCOPE), zValidator("json", UnsuppressRequest, validationHook), async (c) => {
|
|
260
|
+
const input = c.req.valid("json");
|
|
261
|
+
const who = caller(c);
|
|
262
|
+
const email = normalizeAddress(input.email);
|
|
263
|
+
const db = suppressions(c);
|
|
264
|
+
const existing = (await listSuppressions(db, {
|
|
265
|
+
email,
|
|
266
|
+
limit: 1
|
|
267
|
+
})).items[0];
|
|
268
|
+
const removed = await unsuppress(db, email);
|
|
269
|
+
await c.var.emit({
|
|
270
|
+
action: EmailAuditActions.suppressionRemoved,
|
|
271
|
+
outcome: "success",
|
|
272
|
+
severity: "warning",
|
|
273
|
+
actorType: "control-plane",
|
|
274
|
+
actorId: who.subject,
|
|
275
|
+
resourceType: "email_suppression",
|
|
276
|
+
resourceId: existing?.id ? String(existing.id) : null,
|
|
277
|
+
metadata: {
|
|
278
|
+
connectionId: who.connectionId,
|
|
279
|
+
email,
|
|
280
|
+
removed,
|
|
281
|
+
reason: existing?.reason ?? null
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
return c.json({
|
|
285
|
+
email,
|
|
286
|
+
removed
|
|
287
|
+
}, 200);
|
|
288
|
+
});
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
//#endregion
|
|
292
|
+
export { EMAIL_ADMIN_ROUTES, registerEmailAdminRoutes };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* The `:token` path parameter every callback route carries. A shape and size bound only — the ceiling
|
|
4
|
+
* is generous enough for a click token whose signed claims embed a long destination URL, so no link we
|
|
5
|
+
* mint can exceed it, while an unbounded segment can no longer reach the verifier.
|
|
6
|
+
*/
|
|
7
|
+
export declare const CallbackTokenParam: z.ZodObject<{
|
|
8
|
+
token: z.ZodString;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
export type CallbackTokenParam = z.output<typeof CallbackTokenParam>;
|
|
11
|
+
/**
|
|
12
|
+
* The optional `?reason=` on the unsubscribe callback — supplied by the app's own preferences flow.
|
|
13
|
+
* The bound is a ceiling, not the storage limit: the handler still truncates to 200 characters before
|
|
14
|
+
* writing, so every real value keeps behaving exactly as it did and only an absurd one is refused.
|
|
15
|
+
*/
|
|
16
|
+
export declare const UnsubscribeQuery: z.ZodObject<{
|
|
17
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export type UnsubscribeQuery = z.output<typeof UnsubscribeQuery>;
|
|
20
|
+
/**
|
|
21
|
+
* The `:id` of one job.
|
|
22
|
+
*
|
|
23
|
+
* Shape and size, not `.uuid()`. Production ids are `crypto.randomUUID()`, but `newId` is an injected
|
|
24
|
+
* dependency of `enqueueEmail`, so a consumer supplying its own generator would find every one of its
|
|
25
|
+
* jobs answering 400 at a route that never reached the lookup. A param schema constrains the string;
|
|
26
|
+
* the handler still does the lookup and still raises its own 404.
|
|
27
|
+
*/
|
|
28
|
+
export declare const JobIdParam: z.ZodObject<{
|
|
29
|
+
id: z.ZodString;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
export type JobIdParam = z.output<typeof JobIdParam>;
|
|
32
|
+
/** The job log query. */
|
|
33
|
+
export declare const JobsQuery: z.ZodObject<{
|
|
34
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
35
|
+
bounced: "bounced";
|
|
36
|
+
canceled: "canceled";
|
|
37
|
+
failed: "failed";
|
|
38
|
+
pending: "pending";
|
|
39
|
+
scheduled: "scheduled";
|
|
40
|
+
sending: "sending";
|
|
41
|
+
sent: "sent";
|
|
42
|
+
suppressed: "suppressed";
|
|
43
|
+
undispatched: "undispatched";
|
|
44
|
+
}>>;
|
|
45
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
46
|
+
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
export type JobsQuery = z.output<typeof JobsQuery>;
|
|
49
|
+
/**
|
|
50
|
+
* The suppression list query.
|
|
51
|
+
*
|
|
52
|
+
* `email` is an exact-match lookup rather than a search, and that is the point: answering "is this one
|
|
53
|
+
* address blocked" should not require paging a list of every other person who ever unsubscribed. A
|
|
54
|
+
* prefix or substring search would turn the endpoint into a way to enumerate the list a page at a time
|
|
55
|
+
* while looking like a lookup.
|
|
56
|
+
*/
|
|
57
|
+
export declare const SuppressionsQuery: z.ZodObject<{
|
|
58
|
+
reason: z.ZodOptional<z.ZodEnum<{
|
|
59
|
+
complaint: "complaint";
|
|
60
|
+
hard_bounce: "hard_bounce";
|
|
61
|
+
manual: "manual";
|
|
62
|
+
unsubscribe: "unsubscribe";
|
|
63
|
+
}>>;
|
|
64
|
+
email: z.ZodOptional<z.ZodString>;
|
|
65
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
66
|
+
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
67
|
+
}, z.core.$strip>;
|
|
68
|
+
export type SuppressionsQuery = z.output<typeof SuppressionsQuery>;
|
|
69
|
+
/**
|
|
70
|
+
* Block an address by hand.
|
|
71
|
+
*
|
|
72
|
+
* **There is no `reason` field, on purpose.** The column records *why an address is blocked*, and three
|
|
73
|
+
* of its four values (`hard_bounce`, `complaint`, `unsubscribe`) are facts the system observed: a
|
|
74
|
+
* bounce arrived, a complaint arrived, a recipient followed their own opt-out link. A management client
|
|
75
|
+
* observed none of them, so letting it name one would let an operator's assertion enter the record as
|
|
76
|
+
* an observation, and the deliverability decisions read off that column would be made on fiction. Every
|
|
77
|
+
* address blocked through this route is `manual`, and what the operator knows goes in `detail`.
|
|
78
|
+
*/
|
|
79
|
+
export declare const SuppressRequest: z.ZodObject<{
|
|
80
|
+
email: z.ZodEmail;
|
|
81
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
82
|
+
expiresAt: z.ZodOptional<z.ZodISODateTime>;
|
|
83
|
+
}, z.core.$strip>;
|
|
84
|
+
export type SuppressRequest = z.output<typeof SuppressRequest>;
|
|
85
|
+
/** Unblock an address — the undo of {@link SuppressRequest}, and of a bounce, complaint, or opt-out. */
|
|
86
|
+
export declare const UnsuppressRequest: z.ZodObject<{
|
|
87
|
+
email: z.ZodString;
|
|
88
|
+
}, z.core.$strip>;
|
|
89
|
+
export type UnsuppressRequest = z.output<typeof UnsuppressRequest>;
|
|
90
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/http/schemas.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA0BxB;;;;GAIG;AACH,eAAO,MAAM,kBAAkB;;iBASoD,CAAC;AACpF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAErE;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;;iBAQqD,CAAC;AACnF,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAoDjE;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU;;iBAS2C,CAAC;AACnE,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AAErD,yBAAyB;AACzB,eAAO,MAAM,SAAS;;;;;;;;;;;;;;iBAQ2D,CAAC;AAClF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,SAAS,CAAC,CAAC;AAEnD;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;iBAW8E,CAAC;AAC7G,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEnE;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe;;;;iBAgBqD,CAAC;AAClF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AAE/D,wGAAwG;AACxG,eAAO,MAAM,iBAAiB;;iBAI+D,CAAC;AAC9F,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
|