@pithy-sh/email 0.7.0 → 0.8.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 +8 -0
- package/dist/capability.d.ts +2 -2
- package/dist/capability.d.ts.map +1 -1
- package/dist/capability.js +23 -2
- package/dist/consent/consent.d.ts +57 -0
- package/dist/consent/consent.d.ts.map +1 -0
- package/dist/consent/consent.js +135 -0
- package/dist/data/emailEvent.d.ts +1 -1
- package/dist/data/emailEvent.d.ts.map +1 -1
- package/dist/data/emailEvent.js +2 -1
- package/dist/data/emailJob.d.ts +6 -2
- package/dist/data/emailJob.d.ts.map +1 -1
- package/dist/data/emailJob.js +8 -3
- package/dist/data/emailSuppression.d.ts +1 -1
- package/dist/data/emailSuppression.d.ts.map +1 -1
- package/dist/data/emailSuppression.js +2 -1
- package/dist/data/tables.d.ts +4 -4
- package/dist/http/guards.d.ts +2 -2
- package/dist/http/guards.d.ts.map +1 -1
- package/dist/http/guards.js +12 -0
- package/dist/processing/activities.d.ts +9 -0
- package/dist/processing/activities.d.ts.map +1 -0
- package/dist/processing/activities.js +40 -0
- package/dist/purge/contribution.d.ts +27 -0
- package/dist/purge/contribution.d.ts.map +1 -0
- package/dist/purge/contribution.js +67 -0
- package/dist/send/enqueue.d.ts +26 -7
- package/dist/send/enqueue.d.ts.map +1 -1
- package/dist/send/enqueue.js +36 -13
- package/dist/templates/messages.d.ts +1 -2
- package/dist/templates/messages.d.ts.map +1 -1
- package/dist/templates/messages.js +7 -10
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/package.json +3 -3
- package/src/capability.ts +33 -7
- package/src/consent/consent.ts +183 -0
- package/src/data/emailEvent.ts +2 -1
- package/src/data/emailJob.ts +21 -8
- package/src/data/emailSuppression.ts +2 -1
- package/src/http/guards.ts +14 -2
- package/src/processing/activities.ts +41 -0
- package/src/purge/contribution.ts +83 -0
- package/src/send/enqueue.ts +62 -24
- package/src/templates/messages.ts +10 -13
- package/src/version.generated.ts +1 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
import { type RetainingPurgeContribution } from "@pithy-sh/core/src/capability/purge";
|
|
4
|
+
/**
|
|
5
|
+
* What a person's purge means for `@pithy-sh/email` (#814): **nothing is erased, and the export says so and why.**
|
|
6
|
+
*
|
|
7
|
+
* A suppression has to outlive the person. It is the record that an address bounced, complained or asked not to be
|
|
8
|
+
* mailed, and the list is checked before every send: erase the row and the next send — a newsletter to an address
|
|
9
|
+
* that unsubscribed — goes out, because nothing remembers that it should not. So this contribution **retains**, and
|
|
10
|
+
* the log of mail sent to the address stays beside it as the delivery record a bounce or a complaint is read
|
|
11
|
+
* against. The purge records the step as retained with the basis below, and erases no row.
|
|
12
|
+
*
|
|
13
|
+
* **Found by address.** Email stores no user id: the suppression list and the log are keyed by the address, in
|
|
14
|
+
* `normalizeAddress`'s form. The step reads the account's address (`PurgeContext.address`); with none to read there
|
|
15
|
+
* is nothing to find.
|
|
16
|
+
*
|
|
17
|
+
* **Never a message's payload, and never a tracked link.** A job's payload is the template's variables, and a sign-in
|
|
18
|
+
* mail's variables are the link that signs the person in; a click event's URL can be that link. The export carries
|
|
19
|
+
* what was sent, when and how it went, and leaves both out.
|
|
20
|
+
*/
|
|
21
|
+
/** The one sentence the purge records with this step. */
|
|
22
|
+
export declare const EMAIL_PURGE_SUMMARY = "Keeps the user's address on the suppression list, and the log of mail sent to it.";
|
|
23
|
+
/** Why, in the sentence the person is told. */
|
|
24
|
+
export declare const EMAIL_RETENTION_BASIS = "Kept so your unsubscribe holds: the address stays on the list of addresses not to mail, with the record of what was sent to it.";
|
|
25
|
+
/** The user contribution `email()` declares, over its two D1 bindings. */
|
|
26
|
+
export declare function emailUserPurge(database?: string, suppressions?: string): RetainingPurgeContribution;
|
|
27
|
+
//# sourceMappingURL=contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contribution.d.ts","sourceRoot":"","sources":["../../src/purge/contribution.ts"],"names":[],"mappings":"AAKA,OAAO,EAA4B,KAAK,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AAMhH;;;;;;;;;;;;;;;;GAgBG;AAEH,yDAAyD;AACzD,eAAO,MAAM,mBAAmB,sFAAsF,CAAC;AAEvH,+CAA+C;AAC/C,eAAO,MAAM,qBAAqB,oIACiG,CAAC;AAEpI,0EAA0E;AAC1E,wBAAgB,cAAc,CAAC,QAAQ,SAAO,EAAE,YAAY,SAAuB,GAAG,0BAA0B,CA6C/G"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
import { EmailEvent } from "../data/emailEvent.js";
|
|
4
|
+
import { EmailJob } from "../data/emailJob.js";
|
|
5
|
+
import { EmailSuppression } from "../data/emailSuppression.js";
|
|
6
|
+
import { emailDatabase, emailSuppressionDatabase } from "../data/tables.js";
|
|
7
|
+
import { normalizeAddress } from "@pithy-sh/core/src/address/address";
|
|
8
|
+
import { exportRows, purgeBinding } from "@pithy-sh/core/src/capability/purge";
|
|
9
|
+
//#region src/purge/contribution.ts
|
|
10
|
+
/**
|
|
11
|
+
* What a person's purge means for `@pithy-sh/email` (#814): **nothing is erased, and the export says so and why.**
|
|
12
|
+
*
|
|
13
|
+
* A suppression has to outlive the person. It is the record that an address bounced, complained or asked not to be
|
|
14
|
+
* mailed, and the list is checked before every send: erase the row and the next send — a newsletter to an address
|
|
15
|
+
* that unsubscribed — goes out, because nothing remembers that it should not. So this contribution **retains**, and
|
|
16
|
+
* the log of mail sent to the address stays beside it as the delivery record a bounce or a complaint is read
|
|
17
|
+
* against. The purge records the step as retained with the basis below, and erases no row.
|
|
18
|
+
*
|
|
19
|
+
* **Found by address.** Email stores no user id: the suppression list and the log are keyed by the address, in
|
|
20
|
+
* `normalizeAddress`'s form. The step reads the account's address (`PurgeContext.address`); with none to read there
|
|
21
|
+
* is nothing to find.
|
|
22
|
+
*
|
|
23
|
+
* **Never a message's payload, and never a tracked link.** A job's payload is the template's variables, and a sign-in
|
|
24
|
+
* mail's variables are the link that signs the person in; a click event's URL can be that link. The export carries
|
|
25
|
+
* what was sent, when and how it went, and leaves both out.
|
|
26
|
+
*/
|
|
27
|
+
/** The one sentence the purge records with this step. */
|
|
28
|
+
const EMAIL_PURGE_SUMMARY = "Keeps the user's address on the suppression list, and the log of mail sent to it.";
|
|
29
|
+
/** Why, in the sentence the person is told. */
|
|
30
|
+
const EMAIL_RETENTION_BASIS = "Kept so your unsubscribe holds: the address stays on the list of addresses not to mail, with the record of what was sent to it.";
|
|
31
|
+
/** The user contribution `email()` declares, over its two D1 bindings. */
|
|
32
|
+
function emailUserPurge(database = "DB", suppressions = "EMAIL_SUPPRESSIONS") {
|
|
33
|
+
return {
|
|
34
|
+
subject: "user",
|
|
35
|
+
summary: EMAIL_PURGE_SUMMARY,
|
|
36
|
+
retain: { basis: EMAIL_RETENTION_BASIS },
|
|
37
|
+
export: async (context) => {
|
|
38
|
+
const read = await context.address?.();
|
|
39
|
+
if (!read) return {
|
|
40
|
+
suppressions: [],
|
|
41
|
+
jobs: [],
|
|
42
|
+
events: []
|
|
43
|
+
};
|
|
44
|
+
const address = normalizeAddress(read);
|
|
45
|
+
const log = emailDatabase(purgeBinding(context.env, database, "email"));
|
|
46
|
+
const list = emailSuppressionDatabase(purgeBinding(context.env, suppressions, "email"));
|
|
47
|
+
const [suppressed, jobs, events] = await Promise.all([
|
|
48
|
+
list.selectFrom("pithyEmailSuppressions").selectAll().where("email", "=", address).execute(),
|
|
49
|
+
log.selectFrom("pithyEmailJobs").selectAll().where("recipientKey", "=", address).orderBy("createdAt").orderBy("id").execute(),
|
|
50
|
+
log.selectFrom("pithyEmailEvents").selectAll().where("recipient", "=", address).orderBy("createdAt").orderBy("id").execute()
|
|
51
|
+
]);
|
|
52
|
+
return {
|
|
53
|
+
suppressions: exportRows(suppressed.map((row) => EmailSuppression.parse(row))),
|
|
54
|
+
jobs: exportRows(jobs.map((row) => {
|
|
55
|
+
const { payload: _variables, ...job } = EmailJob.parse(row);
|
|
56
|
+
return job;
|
|
57
|
+
})),
|
|
58
|
+
events: exportRows(events.map((row) => {
|
|
59
|
+
const { linkUrl: _link, ...event } = EmailEvent.parse(row);
|
|
60
|
+
return event;
|
|
61
|
+
}))
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
export { EMAIL_PURGE_SUMMARY, EMAIL_RETENTION_BASIS, emailUserPurge };
|
package/dist/send/enqueue.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
+
import type { ConsentReader, ConsentSubject } from "@pithy-sh/core/src/consent/reader";
|
|
3
4
|
import type { MeterCharge, MeterSubject } from "@pithy-sh/core/src/entitlement/meter";
|
|
4
5
|
import type { EmailJobStatus, SendMode, SuppressionReason } from "../data/enums";
|
|
5
6
|
import type { EmailDatabase, EmailSuppressionDatabase } from "../data/tables";
|
|
@@ -11,7 +12,7 @@ import type { EmailTheme } from "../templates/theme";
|
|
|
11
12
|
* `scheduled` and `timezone` jobs are left for the every-minute scheduler to pick up. The payload is
|
|
12
13
|
* validated against the template schema here, so a bad call fails at enqueue, not mid-send.
|
|
13
14
|
*
|
|
14
|
-
* **Suppression is consulted here too, and no caller asks for it
|
|
15
|
+
* **Suppression is consulted here too, and no caller asks for it**. A blocked
|
|
15
16
|
* recipient never becomes a queued send: the row is born `suppressed`, no Workflow is started, and the
|
|
16
17
|
* reason comes back on the result. The point is not a second gate — `runSend` is and stays the
|
|
17
18
|
* authority, because whether an address is blocked is a question about the instant of sending and a
|
|
@@ -29,7 +30,7 @@ import type { EmailTheme } from "../templates/theme";
|
|
|
29
30
|
* The Workflow binding used to start a send (Cloudflare `Workflow.create`). At enqueue it sends a batch
|
|
30
31
|
* of one; the scheduler's fan-out starts one instance per batch through the same binding.
|
|
31
32
|
*
|
|
32
|
-
* `id` names the instance being created, and **every dispatcher passes one
|
|
33
|
+
* `id` names the instance being created, and **every dispatcher passes one**: the
|
|
33
34
|
* scheduler passes its batch's, an enqueue passes the one it just stamped on the row, and a retry passes
|
|
34
35
|
* the one it minted to replace the failed batch's. It is optional here only because the platform allows
|
|
35
36
|
* omitting it, and omitting it is what made an immediate send unattributable to any instance — so the
|
|
@@ -79,7 +80,7 @@ export interface EnqueueInput {
|
|
|
79
80
|
/**
|
|
80
81
|
* What this message is *about*, when the template id does not say it on its own.
|
|
81
82
|
*
|
|
82
|
-
* The discriminator for a template that carries more than one kind of message
|
|
83
|
+
* The discriminator for a template that carries more than one kind of message.
|
|
83
84
|
* `sentSince` matches on it, so a caller deciding whether to send — or whether to send a *correction* —
|
|
84
85
|
* can tell two messages apart that share a template and a recipient. Opaque: nothing here parses it,
|
|
85
86
|
* renders it, or puts it on a header or a link.
|
|
@@ -123,6 +124,14 @@ export interface EnqueueInput {
|
|
|
123
124
|
* enqueue past the period's quota throws `payments/quota_exceeded` and writes no job.
|
|
124
125
|
*/
|
|
125
126
|
subject?: MeterSubject;
|
|
127
|
+
/**
|
|
128
|
+
* Whose consent this message is sent under, when `@pithy-sh/consent` is composed: the recipient's account,
|
|
129
|
+
* or the visitor id they consented under. A `marketing` template is sent only to a subject consenting to
|
|
130
|
+
* `email.marketing`, and opens and clicks are tracked only for one consenting to `email.tracking`. Omitted, a
|
|
131
|
+
* marketing message is withheld and nothing is tracked, because nobody's consent can be shown. Transactional mail
|
|
132
|
+
* is never gated, and without consent composed this is ignored.
|
|
133
|
+
*/
|
|
134
|
+
consentSubject?: ConsentSubject;
|
|
126
135
|
}
|
|
127
136
|
/** Dependencies enqueue needs: the database, the from identity, optional send-Workflow binding, time, ids. */
|
|
128
137
|
export interface EnqueueDeps {
|
|
@@ -155,12 +164,16 @@ export interface EnqueueDeps {
|
|
|
155
164
|
* request's env. Absent when no provider is composed, and then nothing is counted.
|
|
156
165
|
*/
|
|
157
166
|
meter?: (charge: MeterCharge) => Promise<void>;
|
|
167
|
+
/**
|
|
168
|
+
* The composed consent reader, or absent when no consent capability is composed — and then nothing is
|
|
169
|
+
* gated.
|
|
170
|
+
*/
|
|
171
|
+
consent?: ConsentReader | null;
|
|
158
172
|
now: Date;
|
|
159
173
|
/** Generate a job id (a UUID in production). */
|
|
160
174
|
newId: () => string;
|
|
161
175
|
/**
|
|
162
|
-
* Mint the id of the batch this enqueue dispatches — **the send Workflow instance's id
|
|
163
|
-
* (pithy-sh/pithy#342). Defaults to {@link mintBatchId}; injected only so a test can name it.
|
|
176
|
+
* Mint the id of the batch this enqueue dispatches — **the send Workflow instance's id**. Defaults to {@link mintBatchId}; injected only so a test can name it.
|
|
164
177
|
*/
|
|
165
178
|
newBatchId?: () => string;
|
|
166
179
|
}
|
|
@@ -172,7 +185,7 @@ export interface EnqueueResult {
|
|
|
172
185
|
*
|
|
173
186
|
* `pending` and `scheduled` both mean a send is on its way. `suppressed` means the address is
|
|
174
187
|
* blocked. **`undispatched` means this composition binds no send Workflow**, so nothing was started
|
|
175
|
-
* and nothing is coming while it stays that way
|
|
188
|
+
* and nothing is coming while it stays that way: a caller that renders "check
|
|
176
189
|
* your inbox" off it is reporting a delivery that cannot happen. It is the one status here that
|
|
177
190
|
* describes the *deployment* rather than the message — and the scheduler drains those rows once a
|
|
178
191
|
* host exists, so it is not the end of the job.
|
|
@@ -187,9 +200,15 @@ export interface EnqueueResult {
|
|
|
187
200
|
* operator's next move depends on.
|
|
188
201
|
*/
|
|
189
202
|
suppressionReason?: SuppressionReason;
|
|
203
|
+
/**
|
|
204
|
+
* The consent purpose that withheld this message, when consent is composed and the subject does not hold it —
|
|
205
|
+
* `email.marketing`. The row is born `suppressed` and nothing is sent. Absent for every message consent
|
|
206
|
+
* did not withhold.
|
|
207
|
+
*/
|
|
208
|
+
consentWithheld?: string;
|
|
190
209
|
/**
|
|
191
210
|
* The **enqueue-time** render — the sentence this call wrote to `pithy_email_jobs.subject`, in the
|
|
192
|
-
* recipient's language, and the value the row is born with
|
|
211
|
+
* recipient's language, and the value the row is born with.
|
|
193
212
|
*
|
|
194
213
|
* **For the caller that has to say what it queued.** Enqueuing is what a surface does; auditing it is
|
|
195
214
|
* what a surface with an administrative trail also does. Without this, that caller had to render the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enqueue.d.ts","sourceRoot":"","sources":["../../src/send/enqueue.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"enqueue.d.ts","sourceRoot":"","sources":["../../src/send/enqueue.ts"],"names":[],"mappings":"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"}
|
package/dist/send/enqueue.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
-
import { EmailJob } from "../data/emailJob.js";
|
|
3
|
+
import { EmailJob, personalAddress } from "../data/emailJob.js";
|
|
4
4
|
import { recordEvent } from "./events.js";
|
|
5
5
|
import { blockingSuppression } from "./suppression.js";
|
|
6
|
+
import { consentGate } from "../consent/consent.js";
|
|
6
7
|
import { EmailInvalidPayloadError } from "../error/errors.js";
|
|
7
8
|
import { emailTranslator, kitEmailLayers } from "../templates/messages.js";
|
|
8
9
|
import { getTemplate, renderSubject, templateKind } from "../templates/engine.js";
|
|
@@ -47,11 +48,20 @@ async function enqueueEmail(deps, input) {
|
|
|
47
48
|
* agreeing is what makes a hard bounce withhold an invitation while an unsubscribe does not. A caller
|
|
48
49
|
* cannot influence this and is not asked to: it is the template's own declaration.
|
|
49
50
|
*/
|
|
50
|
-
const
|
|
51
|
+
const suppressed = deps.suppressionDb ? await blockingSuppression(deps.suppressionDb, input.to, deps.now, templateKind(input.template)) : null;
|
|
52
|
+
/**
|
|
53
|
+
* What consent allows, when it is composed: a marketing message to a subject not consenting to it is
|
|
54
|
+
* withheld like a suppressed one, and tracking runs only for a subject consenting to it. Transactional mail is
|
|
55
|
+
* never withheld. With no consent composed the gate passes everything.
|
|
56
|
+
*/
|
|
57
|
+
const marketing = template.category === "marketing";
|
|
58
|
+
const gate = await consentGate(deps.consent, input.consentSubject, marketing);
|
|
59
|
+
const withheld = suppressed === null ? gate.withheld : null;
|
|
60
|
+
const blocked = suppressed !== null || withheld !== null;
|
|
51
61
|
const recipient = normalizeAddress(input.to);
|
|
52
62
|
const sender = !blocked && mode === "immediate" ? deps.sender : void 0;
|
|
53
63
|
/**
|
|
54
|
-
* An immediate job with nothing to dispatch it on
|
|
64
|
+
* An immediate job with nothing to dispatch it on.
|
|
55
65
|
*
|
|
56
66
|
* A missing binding is a **configuration fact known at compose time**, not a transient failure, and
|
|
57
67
|
* the two used to be recorded identically: both left the row `pending` and told the caller "on its
|
|
@@ -74,7 +84,7 @@ async function enqueueEmail(deps, input) {
|
|
|
74
84
|
const status = blocked ? "suppressed" : undispatchable ? "undispatched" : scheduled;
|
|
75
85
|
/**
|
|
76
86
|
* The batch this enqueue is about to start — named here, before the row exists, because the row has to
|
|
77
|
-
* carry it
|
|
87
|
+
* carry it.
|
|
78
88
|
*
|
|
79
89
|
* Without it the row is born naming nobody, and a row naming nobody is stranded by definition: the
|
|
80
90
|
* scheduler's safety net claims any `pending` job older than `graceMs` and starts a *second* send
|
|
@@ -103,11 +113,10 @@ async function enqueueEmail(deps, input) {
|
|
|
103
113
|
amount: 1,
|
|
104
114
|
now: deps.now
|
|
105
115
|
});
|
|
106
|
-
const marketing = template.category === "marketing";
|
|
107
116
|
const job = {
|
|
108
117
|
id: deps.newId(),
|
|
109
|
-
toAddress: input.to,
|
|
110
|
-
recipientKey: recipient,
|
|
118
|
+
toAddress: personalAddress(input.to),
|
|
119
|
+
recipientKey: personalAddress(recipient),
|
|
111
120
|
fromAddress: deps.fromAddress,
|
|
112
121
|
fromName: deps.fromName,
|
|
113
122
|
subject,
|
|
@@ -125,10 +134,10 @@ async function enqueueEmail(deps, input) {
|
|
|
125
134
|
campaignId: input.campaignId ?? null,
|
|
126
135
|
locale: isLocale(input.locale ?? "") ? input.locale ?? null : null,
|
|
127
136
|
correlation: input.correlation ?? null,
|
|
128
|
-
openTracking: input.openTracking ?? marketing,
|
|
129
|
-
clickTracking: input.clickTracking ?? marketing,
|
|
137
|
+
openTracking: (input.openTracking ?? marketing) && gate.tracking,
|
|
138
|
+
clickTracking: (input.clickTracking ?? marketing) && gate.tracking,
|
|
130
139
|
messageId: null,
|
|
131
|
-
error:
|
|
140
|
+
error: suppressed ? `recipient suppressed: ${suppressed}` : withheld ? `no consent: ${withheld}` : undispatchable ? "no EMAIL_SENDER binding: this composition can start no send Workflow" : null,
|
|
132
141
|
bounceCode: null,
|
|
133
142
|
bounceType: null,
|
|
134
143
|
replyTo: input.replyTo ?? null,
|
|
@@ -139,18 +148,32 @@ async function enqueueEmail(deps, input) {
|
|
|
139
148
|
sentAt: null
|
|
140
149
|
};
|
|
141
150
|
await deps.db.insertInto("pithyEmailJobs").values(EmailJob.encode(job)).execute();
|
|
142
|
-
if (
|
|
151
|
+
if (suppressed) {
|
|
152
|
+
await recordEvent(deps.db, {
|
|
153
|
+
jobId: job.id,
|
|
154
|
+
recipient,
|
|
155
|
+
type: "suppressed",
|
|
156
|
+
detail: suppressed
|
|
157
|
+
}, deps.now);
|
|
158
|
+
return {
|
|
159
|
+
jobId: job.id,
|
|
160
|
+
status,
|
|
161
|
+
subject,
|
|
162
|
+
suppressionReason: suppressed
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
if (withheld) {
|
|
143
166
|
await recordEvent(deps.db, {
|
|
144
167
|
jobId: job.id,
|
|
145
168
|
recipient,
|
|
146
169
|
type: "suppressed",
|
|
147
|
-
detail:
|
|
170
|
+
detail: `consent:${withheld}`
|
|
148
171
|
}, deps.now);
|
|
149
172
|
return {
|
|
150
173
|
jobId: job.id,
|
|
151
174
|
status,
|
|
152
175
|
subject,
|
|
153
|
-
|
|
176
|
+
consentWithheld: withheld
|
|
154
177
|
};
|
|
155
178
|
}
|
|
156
179
|
if (sender && batchId) try {
|
|
@@ -6,8 +6,7 @@ import { type Translator } from "@pithy-sh/core/src/i18n/translator";
|
|
|
6
6
|
* Every language this capability's own copy is written in.
|
|
7
7
|
*
|
|
8
8
|
* **Bundled, not stamped.** The send Worker is deployed with this map inside it, so adding a language
|
|
9
|
-
* to the kit costs an adopter a package upgrade and no configuration at all
|
|
10
|
-
* #442. What still travels as a variable is the adopter's diff against this: usually nothing, and at
|
|
9
|
+
* to the kit costs an adopter a package upgrade and no configuration at all. What still travels as a variable is the adopter's diff against this: usually nothing, and at
|
|
11
10
|
* most the sentences they changed.
|
|
12
11
|
*/
|
|
13
12
|
export declare const EMAIL_MESSAGES: LocaleCatalogs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/templates/messages.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,cAAc,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEtF,OAAO,EAAoC,KAAK,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAgNvG
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/templates/messages.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,cAAc,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEtF,OAAO,EAAoC,KAAK,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAgNvG;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,EAAE,cAA+C,CAAC;AAE7E;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,SAAS,CAAC,cAAc,GAAG,SAAS,CAAC,EAAE,CAAC;AAE7F,iHAAiH;AACjH,eAAO,MAAM,cAAc,EAAE,kBAA+D,CAAC;AAoB7F;;;;;;;GAOG;AACH;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,wBAAwB,oBAAoB,CAAC;AAE1D;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKhE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,cAAc,CAa5E;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,cAAc,GAAG,kBAAkB,CAa1E;AA2BD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,SAAS,EAAE,kBAAkB,GAAG,UAAU,CAG5G"}
|
|
@@ -43,13 +43,13 @@ import { DEFAULT_LOCALE, createTranslator } from "@pithy-sh/core/src/i18n/transl
|
|
|
43
43
|
*
|
|
44
44
|
* ## Only the kit's own copy
|
|
45
45
|
*
|
|
46
|
-
*
|
|
46
|
+
* Seventeen templates are here. The five whose words arrive as payload — `testerNudge`, `supportReply`,
|
|
47
47
|
* `operationalNotice`, `newsletter`, `marketingCampaign` — are the adopter's copy, chosen by a human
|
|
48
48
|
* for one message, and a catalog cannot translate a sentence it has never seen. Their **shell** still
|
|
49
49
|
* follows the job's locale (the severity word, the footer, the document's `lang` and `dir`), so a
|
|
50
50
|
* notice at locale `es` reads its severity in Spanish and its summary in whatever the caller wrote.
|
|
51
51
|
*/
|
|
52
|
-
/** The kit's English for every string the
|
|
52
|
+
/** The kit's English for every string the seventeen kit-authored templates and the shared shell render. */
|
|
53
53
|
const EMAIL_EN = {
|
|
54
54
|
"email/shell.greeting": "Hi,",
|
|
55
55
|
"email/shell.greeting_named": "Hi {name},",
|
|
@@ -161,8 +161,7 @@ const EMAIL_EN = {
|
|
|
161
161
|
* Every language this capability's own copy is written in.
|
|
162
162
|
*
|
|
163
163
|
* **Bundled, not stamped.** The send Worker is deployed with this map inside it, so adding a language
|
|
164
|
-
* to the kit costs an adopter a package upgrade and no configuration at all
|
|
165
|
-
* #442. What still travels as a variable is the adopter's diff against this: usually nothing, and at
|
|
164
|
+
* to the kit costs an adopter a package upgrade and no configuration at all. What still travels as a variable is the adopter's diff against this: usually nothing, and at
|
|
166
165
|
* most the sentences they changed.
|
|
167
166
|
*/
|
|
168
167
|
const EMAIL_MESSAGES = {
|
|
@@ -178,12 +177,10 @@ function languageOf(tag) {
|
|
|
178
177
|
/**
|
|
179
178
|
* This package's own copy for `locale`, reduced to the language when the region was not written for.
|
|
180
179
|
*
|
|
181
|
-
* **The reduction has to happen here too, and not only over the stamped catalogs.**
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
* exact-tag lookup on `es-AR` answered `undefined` — so a reader whose `pithy_auth_users.locale` is
|
|
186
|
-
* `es-AR` or `es-MX` got an English letter from a project that ships Spanish.
|
|
180
|
+
* **The reduction has to happen here too, and not only over the stamped catalogs.** With the kit's copy
|
|
181
|
+
* bundled here, the stamped catalog is empty for a project that overrode nothing, so an exact-tag
|
|
182
|
+
* lookup on `es-AR` alone would send a reader whose `pithy_auth_users.locale` is `es-AR` or `es-MX` an
|
|
183
|
+
* English letter from a project that ships Spanish.
|
|
187
184
|
*/
|
|
188
185
|
function bundledFor(locale) {
|
|
189
186
|
const language = languageOf(locale);
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
/** This package's npm name — the join key against a release feed. */
|
|
4
4
|
export declare const PACKAGE_NAME = "@pithy-sh/email";
|
|
5
5
|
/** This package's version, stamped from its own package.json at generation time. */
|
|
6
|
-
export declare const PACKAGE_VERSION = "0.
|
|
6
|
+
export declare const PACKAGE_VERSION = "0.8.0";
|
|
7
7
|
//# sourceMappingURL=version.generated.d.ts.map
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
/** This package's npm name — the join key against a release feed. */
|
|
5
5
|
const PACKAGE_NAME = "@pithy-sh/email";
|
|
6
6
|
/** This package's version, stamped from its own package.json at generation time. */
|
|
7
|
-
const PACKAGE_VERSION = "0.
|
|
7
|
+
const PACKAGE_VERSION = "0.8.0";
|
|
8
8
|
//#endregion
|
|
9
9
|
export { PACKAGE_NAME, PACKAGE_VERSION };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pithy-sh/email",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"postal-mime": "^3.0.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@pithy-sh/core": "^0.
|
|
46
|
-
"@pithy-sh/secrets": "^0.6.
|
|
45
|
+
"@pithy-sh/core": "^0.14.0",
|
|
46
|
+
"@pithy-sh/secrets": "^0.6.2",
|
|
47
47
|
"hono": "^4.13.2",
|
|
48
48
|
"kysely": "^0.29.0",
|
|
49
49
|
"zod": "^4.4.0"
|
package/src/capability.ts
CHANGED
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
import type { D1Database } from "@cloudflare/workers-types";
|
|
5
5
|
import { type Capability, defineCapability } from "@pithy-sh/core/src/capability/capability";
|
|
6
6
|
import { pithyCommandOf } from "@pithy-sh/core/src/cli/command";
|
|
7
|
+
import { composedConsent } from "@pithy-sh/core/src/consent/reader";
|
|
7
8
|
import { composedUsageMeter, type MeterCharge, type UsageMeter } from "@pithy-sh/core/src/entitlement/meter";
|
|
8
9
|
import { InternalError } from "@pithy-sh/core/src/error/pithyError";
|
|
9
10
|
import type { LocaleCatalogs } from "@pithy-sh/core/src/i18n/catalog";
|
|
10
11
|
import { z } from "zod";
|
|
11
12
|
import { createBounceHandler } from "./bounce/handler";
|
|
13
|
+
import { EMAIL_CONSENT_PURPOSES, emailConsentGranted, emailConsentWithdrawn } from "./consent/consent";
|
|
12
14
|
import { emailSigningRegistry } from "./crypto/signingKey";
|
|
13
15
|
import {
|
|
14
16
|
type EmailSuppressionDatabase,
|
|
@@ -23,9 +25,11 @@ import { emailAdminRoutes } from "./http/guards";
|
|
|
23
25
|
import { registerEmailAdminRoutes } from "./http/routes";
|
|
24
26
|
import { email_0001_init } from "./migrations/0001_init";
|
|
25
27
|
import { email_0001_suppressions } from "./migrations/0001_suppressions";
|
|
28
|
+
import { EMAIL_PROCESSING } from "./processing/activities";
|
|
26
29
|
import { DevMailDelivery } from "./provision/devDelivery";
|
|
27
30
|
import { emailHostCatalogs } from "./provision/hostCatalogs";
|
|
28
31
|
import { emailSettings } from "./provision/settingsCheck";
|
|
32
|
+
import { emailUserPurge } from "./purge/contribution";
|
|
29
33
|
import { type EnqueueInput, type EnqueueResult, enqueueEmail } from "./send/enqueue";
|
|
30
34
|
import { type EmailSenderEnv, emailSenderBinding } from "./send/senderBinding";
|
|
31
35
|
import { EMAIL_MESSAGES, type EmailMessageLayers, kitEmailLayers } from "./templates/messages";
|
|
@@ -38,7 +42,7 @@ import { EmailScheduleParams, EmailSendParams } from "./workflows/params";
|
|
|
38
42
|
* global suppression database. A consumer (e.g. `@pithy-sh/auth`) forwards its worker env; it never
|
|
39
43
|
* names these bindings itself.
|
|
40
44
|
*
|
|
41
|
-
* **`EMAIL_SUPPRESSIONS` is on this list
|
|
45
|
+
* **`EMAIL_SUPPRESSIONS` is on this list.** The wiring is
|
|
42
46
|
* not the adopter's problem: the capability declares the binding, `pithy add email` provisions it,
|
|
43
47
|
* `enqueue` reads it off the env, and no consumer config, route option, or constant names it. What an
|
|
44
48
|
* adopter *may* do — because it is their database — is ask for it back through
|
|
@@ -139,7 +143,7 @@ export interface EmailCapability extends Capability {
|
|
|
139
143
|
enqueue: (env: EmailEnqueueEnv, input: EnqueueInput) => Promise<EnqueueResult>;
|
|
140
144
|
/**
|
|
141
145
|
* The suppression list, from a request env — **it is the adopter's database, and this is how they open
|
|
142
|
-
* it
|
|
146
|
+
* it**.
|
|
143
147
|
*
|
|
144
148
|
* Nobody has to call this to be protected: `enqueue` consults the list on its own and `runSend`
|
|
145
149
|
* refuses a blocked recipient regardless. This exists for the adopter who genuinely wants to look —
|
|
@@ -201,12 +205,17 @@ export function email(config: EmailConfigInput): EmailCapability {
|
|
|
201
205
|
* exactly as it always was: nothing is counted and nothing is refused.
|
|
202
206
|
*/
|
|
203
207
|
let meter: UsageMeter | undefined;
|
|
208
|
+
/**
|
|
209
|
+
* Every composed capability, kept by `compose` so an enqueue can find the consent reader over its own env.
|
|
210
|
+
* Empty until then, which is a composition with no consent: nothing is gated.
|
|
211
|
+
*/
|
|
212
|
+
let composition: readonly Capability[] = [];
|
|
204
213
|
const capability = defineCapability({
|
|
205
214
|
name: "email",
|
|
206
215
|
// The package this capability ships in and the version it ships at, both stamped by
|
|
207
216
|
// `scripts/stampVersions.ts` — a Worker cannot read its own package.json. Reported per capability by
|
|
208
217
|
// the control-plane manifest, and reported together: a release feed is keyed by package name, so the
|
|
209
|
-
// version alone leaves a client guessing the key
|
|
218
|
+
// version alone leaves a client guessing the key.
|
|
210
219
|
version: PACKAGE_VERSION,
|
|
211
220
|
package: PACKAGE_NAME,
|
|
212
221
|
// The link-signing key is read through @pithy-sh/secrets, so the secrets capability must be
|
|
@@ -218,7 +227,7 @@ export function email(config: EmailConfigInput): EmailCapability {
|
|
|
218
227
|
* This capability's own copy — the seven templates whose words the kit owns, plus the shell's
|
|
219
228
|
* severity vocabulary and its opt-out link. All under `email/`, which `composeMessages` enforces.
|
|
220
229
|
*
|
|
221
|
-
* **In every language it is written in, not English alone
|
|
230
|
+
* **In every language it is written in, not English alone.** The send Worker is a separate
|
|
222
231
|
* deploy with no request and no config, so anything it does not bundle is stamped into it as a
|
|
223
232
|
* variable — and the kit's own translations were doing that on every provision run. Held here,
|
|
224
233
|
* they are built into the host and only an adopter's diff travels.
|
|
@@ -243,6 +252,7 @@ export function email(config: EmailConfigInput): EmailCapability {
|
|
|
243
252
|
*/
|
|
244
253
|
compose: ({ capabilities }) => {
|
|
245
254
|
meter = composedUsageMeter(capabilities);
|
|
255
|
+
composition = capabilities;
|
|
246
256
|
for (const composed of capabilities) {
|
|
247
257
|
if (composed.name !== "i18n") continue;
|
|
248
258
|
const candidate = (composed as { layersFor?: unknown }).layersFor;
|
|
@@ -277,10 +287,24 @@ export function email(config: EmailConfigInput): EmailCapability {
|
|
|
277
287
|
},
|
|
278
288
|
// Every address that bounced, complained or unsubscribed. Dropping it is not a schema change — the
|
|
279
289
|
// next send goes to people who asked not to be mailed, and the list cannot be rebuilt from anywhere.
|
|
280
|
-
// Declared retained, so no `down` runs against it while it holds rows unless counted
|
|
290
|
+
// Declared retained, so no `down` runs against it while it holds rows unless counted.
|
|
281
291
|
retained: emailSuppressionsRetainedTables,
|
|
282
292
|
},
|
|
283
293
|
},
|
|
294
|
+
// A person's suppression and the log of mail sent to them are kept through their purge, so an unsubscribe holds,
|
|
295
|
+
// and exported on an access request with the basis that keeps them.
|
|
296
|
+
purge: [emailUserPurge()],
|
|
297
|
+
processing: EMAIL_PROCESSING,
|
|
298
|
+
/**
|
|
299
|
+
* What email processes under consent: marketing mail and open and click tracking. With
|
|
300
|
+
* `@pithy-sh/consent` composed, an enqueue asks before either; without it, nothing is gated and `pithy doctor`
|
|
301
|
+
* says tracking runs with no consent record behind it.
|
|
302
|
+
*/
|
|
303
|
+
consentPurposes: EMAIL_CONSENT_PURPOSES,
|
|
304
|
+
// A withdrawal from marketing suppresses the address for marketing; one from tracking stops tracking mail
|
|
305
|
+
// already queued. The suppression list and the consent record never disagree.
|
|
306
|
+
consentWithdrawn: emailConsentWithdrawn,
|
|
307
|
+
consentGranted: emailConsentGranted,
|
|
284
308
|
/**
|
|
285
309
|
* The two durable jobs email owns. Both classes live in the prebuilt email worker
|
|
286
310
|
* (`workflows/worker.ts`), never in the app worker — the app only ever dispatches into `send`.
|
|
@@ -296,7 +320,7 @@ export function email(config: EmailConfigInput): EmailCapability {
|
|
|
296
320
|
className: "EmailSendWorkflow",
|
|
297
321
|
// The same object the host's own registry and its dispatch route validate against
|
|
298
322
|
// (`workflows/params.ts`). One schema, three readers: what the app dispatches, what the host
|
|
299
|
-
// deploys, and what a loopback dispatch is checked against at the door
|
|
323
|
+
// deploys, and what a loopback dispatch is checked against at the door.
|
|
300
324
|
params: EmailSendParams,
|
|
301
325
|
},
|
|
302
326
|
schedule: {
|
|
@@ -331,7 +355,7 @@ export function email(config: EmailConfigInput): EmailCapability {
|
|
|
331
355
|
*/
|
|
332
356
|
adminRoutes: emailAdminRoutes(resolved.basePath),
|
|
333
357
|
/**
|
|
334
|
-
* How `pithy doctor` checks that these settings **work**, not merely that they are written
|
|
358
|
+
* How `pithy doctor` checks that these settings **work**, not merely that they are written.
|
|
335
359
|
*
|
|
336
360
|
* Built from the resolved config, on the instance, so discovery needs no `pithy.manifest.json` and no
|
|
337
361
|
* import of this package by the CLI. The local half runs `workflows/hostEnv.ts` — the very declaration
|
|
@@ -382,6 +406,8 @@ export function email(config: EmailConfigInput): EmailCapability {
|
|
|
382
406
|
suppressionDb: env.EMAIL_SUPPRESSIONS ? emailSuppressionDatabase(env.EMAIL_SUPPRESSIONS) : undefined,
|
|
383
407
|
// Read through the closure for the reason `layersFor` is: `compose` fills it after this is defined.
|
|
384
408
|
meter: chargeFor(env),
|
|
409
|
+
// Read through the closure for the same reason: `compose` fills the composition after this is defined.
|
|
410
|
+
consent: composedConsent(composition, env as unknown as Record<string, unknown>),
|
|
385
411
|
now: new Date(),
|
|
386
412
|
newId: () => crypto.randomUUID(),
|
|
387
413
|
},
|