@pithy-sh/email 0.1.1 → 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.
Files changed (176) hide show
  1. package/dist/analytics.d.ts +19 -0
  2. package/dist/analytics.d.ts.map +1 -0
  3. package/dist/analytics.js +13 -0
  4. package/dist/audit/actions.d.ts +45 -0
  5. package/dist/audit/actions.d.ts.map +1 -0
  6. package/dist/audit/actions.js +45 -0
  7. package/dist/bounce/classify.d.ts +38 -0
  8. package/dist/bounce/classify.d.ts.map +1 -0
  9. package/dist/bounce/classify.js +46 -0
  10. package/dist/bounce/handler.d.ts +32 -0
  11. package/dist/bounce/handler.d.ts.map +1 -0
  12. package/dist/bounce/handler.js +81 -0
  13. package/dist/capability.d.ts +158 -0
  14. package/dist/capability.d.ts.map +1 -0
  15. package/dist/capability.js +255 -0
  16. package/dist/crypto/signingKey.d.ts +36 -0
  17. package/dist/crypto/signingKey.d.ts.map +1 -0
  18. package/dist/crypto/signingKey.js +36 -0
  19. package/dist/crypto/token.d.ts +47 -0
  20. package/dist/crypto/token.d.ts.map +1 -0
  21. package/dist/crypto/token.js +99 -0
  22. package/dist/data/emailEvent.d.ts +28 -0
  23. package/dist/data/emailEvent.d.ts.map +1 -0
  24. package/dist/data/emailEvent.js +22 -0
  25. package/dist/data/emailJob.d.ts +76 -0
  26. package/dist/data/emailJob.d.ts.map +1 -0
  27. package/dist/data/emailJob.js +62 -0
  28. package/dist/data/emailSuppression.d.ts +23 -0
  29. package/dist/data/emailSuppression.d.ts.map +1 -0
  30. package/dist/data/emailSuppression.js +21 -0
  31. package/dist/data/enums.d.ts +76 -0
  32. package/dist/data/enums.d.ts.map +1 -0
  33. package/dist/data/enums.js +65 -0
  34. package/dist/data/tables.d.ts +114 -0
  35. package/dist/data/tables.d.ts.map +1 -0
  36. package/dist/data/tables.js +30 -0
  37. package/dist/error/errors.d.ts +60 -0
  38. package/dist/error/errors.d.ts.map +1 -0
  39. package/dist/error/errors.js +82 -0
  40. package/dist/http/callbacks.d.ts +21 -0
  41. package/dist/http/callbacks.d.ts.map +1 -0
  42. package/dist/http/callbacks.js +110 -0
  43. package/dist/http/guards.d.ts +99 -0
  44. package/dist/http/guards.d.ts.map +1 -0
  45. package/dist/http/guards.js +144 -0
  46. package/dist/http/responses.d.ts +295 -0
  47. package/dist/http/responses.d.ts.map +1 -0
  48. package/dist/http/responses.js +115 -0
  49. package/dist/http/routes.d.ts +71 -0
  50. package/dist/http/routes.d.ts.map +1 -0
  51. package/dist/http/routes.js +292 -0
  52. package/dist/http/schemas.d.ts +90 -0
  53. package/dist/http/schemas.d.ts.map +1 -0
  54. package/dist/http/schemas.js +91 -0
  55. package/dist/http/view.d.ts +78 -0
  56. package/dist/http/view.d.ts.map +1 -0
  57. package/dist/http/view.js +130 -0
  58. package/dist/index.d.ts +46 -0
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/index.js +11 -0
  61. package/dist/jobs/read.d.ts +191 -0
  62. package/dist/jobs/read.d.ts.map +1 -0
  63. package/dist/jobs/read.js +143 -0
  64. package/dist/jobs/retry.d.ts +99 -0
  65. package/dist/jobs/retry.d.ts.map +1 -0
  66. package/dist/jobs/retry.js +67 -0
  67. package/dist/migrations/0001_init.d.ts +32 -0
  68. package/dist/migrations/0001_init.d.ts.map +1 -0
  69. package/dist/migrations/0001_init.js +60 -0
  70. package/dist/migrations/0001_suppressions.d.ts +10 -0
  71. package/dist/migrations/0001_suppressions.d.ts.map +1 -0
  72. package/dist/migrations/0001_suppressions.js +20 -0
  73. package/dist/provision/devDelivery.d.ts +32 -0
  74. package/dist/provision/devDelivery.d.ts.map +1 -0
  75. package/dist/provision/devDelivery.js +37 -0
  76. package/dist/provision/hostCatalogs.d.ts +10 -0
  77. package/dist/provision/hostCatalogs.d.ts.map +1 -0
  78. package/dist/provision/hostCatalogs.js +78 -0
  79. package/dist/provision/provisionEmail.d.ts +143 -0
  80. package/dist/provision/provisionEmail.d.ts.map +1 -0
  81. package/dist/provision/provisionEmail.js +118 -0
  82. package/dist/provision/resolveEmailConfig.d.ts +122 -0
  83. package/dist/provision/resolveEmailConfig.d.ts.map +1 -0
  84. package/dist/provision/resolveEmailConfig.js +124 -0
  85. package/dist/provision/settingsCheck.d.ts +40 -0
  86. package/dist/provision/settingsCheck.d.ts.map +1 -0
  87. package/dist/provision/settingsCheck.js +138 -0
  88. package/dist/send/batchIdentity.d.ts +42 -0
  89. package/dist/send/batchIdentity.d.ts.map +1 -0
  90. package/dist/send/batchIdentity.js +46 -0
  91. package/dist/send/enqueue.d.ts +216 -0
  92. package/dist/send/enqueue.d.ts.map +1 -0
  93. package/dist/send/enqueue.js +153 -0
  94. package/dist/send/errorMapping.d.ts +27 -0
  95. package/dist/send/errorMapping.d.ts.map +1 -0
  96. package/dist/send/errorMapping.js +52 -0
  97. package/dist/send/events.d.ts +15 -0
  98. package/dist/send/events.d.ts.map +1 -0
  99. package/dist/send/events.js +17 -0
  100. package/dist/send/fromComposition.d.ts +47 -0
  101. package/dist/send/fromComposition.d.ts.map +1 -0
  102. package/dist/send/fromComposition.js +53 -0
  103. package/dist/send/retryPolicy.d.ts +32 -0
  104. package/dist/send/retryPolicy.d.ts.map +1 -0
  105. package/dist/send/retryPolicy.js +39 -0
  106. package/dist/send/runSend.d.ts +106 -0
  107. package/dist/send/runSend.d.ts.map +1 -0
  108. package/dist/send/runSend.js +218 -0
  109. package/dist/send/sendAt.d.ts +6 -0
  110. package/dist/send/sendAt.d.ts.map +1 -0
  111. package/dist/send/sendAt.js +62 -0
  112. package/dist/send/sender.d.ts +42 -0
  113. package/dist/send/sender.d.ts.map +1 -0
  114. package/dist/send/sender.js +0 -0
  115. package/dist/send/senderBinding.d.ts +44 -0
  116. package/dist/send/senderBinding.d.ts.map +1 -0
  117. package/dist/send/senderBinding.js +21 -0
  118. package/dist/send/suppression.d.ts +93 -0
  119. package/dist/send/suppression.d.ts.map +1 -0
  120. package/dist/send/suppression.js +132 -0
  121. package/dist/templates/engine.d.ts +109 -0
  122. package/dist/templates/engine.d.ts.map +1 -0
  123. package/dist/templates/engine.js +258 -0
  124. package/dist/templates/messages.d.ts +94 -0
  125. package/dist/templates/messages.d.ts.map +1 -0
  126. package/dist/templates/messages.es.d.ts +29 -0
  127. package/dist/templates/messages.es.d.ts.map +1 -0
  128. package/dist/templates/messages.es.js +82 -0
  129. package/dist/templates/messages.js +266 -0
  130. package/dist/templates/partials.d.ts +5 -0
  131. package/dist/templates/partials.d.ts.map +1 -0
  132. package/dist/templates/partials.js +59 -0
  133. package/dist/templates/precompiled.generated.d.ts +266 -0
  134. package/dist/templates/precompiled.generated.d.ts.map +1 -0
  135. package/dist/templates/precompiled.generated.js +4039 -0
  136. package/dist/templates/registry.d.ts +118 -0
  137. package/dist/templates/registry.d.ts.map +1 -0
  138. package/dist/templates/registry.js +323 -0
  139. package/dist/templates/samples.d.ts +7 -0
  140. package/dist/templates/samples.d.ts.map +1 -0
  141. package/dist/templates/samples.js +98 -0
  142. package/dist/templates/severity.d.ts +40 -0
  143. package/dist/templates/severity.d.ts.map +1 -0
  144. package/dist/templates/severity.js +81 -0
  145. package/dist/templates/theme.d.ts +193 -0
  146. package/dist/templates/theme.d.ts.map +1 -0
  147. package/dist/templates/theme.js +168 -0
  148. package/dist/version.generated.d.ts +5 -0
  149. package/dist/version.generated.d.ts.map +1 -0
  150. package/dist/version.generated.js +7 -0
  151. package/dist/workflows/hostApp.d.ts +33 -0
  152. package/dist/workflows/hostApp.d.ts.map +1 -0
  153. package/dist/workflows/hostApp.js +19 -0
  154. package/dist/workflows/hostEnv.d.ts +129 -0
  155. package/dist/workflows/hostEnv.d.ts.map +1 -0
  156. package/dist/workflows/hostEnv.js +147 -0
  157. package/dist/workflows/instanceLiveness.d.ts +3 -0
  158. package/dist/workflows/instanceLiveness.d.ts.map +1 -0
  159. package/dist/workflows/instanceLiveness.js +37 -0
  160. package/dist/workflows/instances.d.ts +18 -0
  161. package/dist/workflows/instances.d.ts.map +1 -0
  162. package/dist/workflows/instances.js +0 -0
  163. package/dist/workflows/params.d.ts +23 -0
  164. package/dist/workflows/params.d.ts.map +1 -0
  165. package/dist/workflows/params.js +21 -0
  166. package/dist/workflows/scheduler.d.ts +82 -0
  167. package/dist/workflows/scheduler.d.ts.map +1 -0
  168. package/dist/workflows/scheduler.js +111 -0
  169. package/dist/workflows/sendBatch.d.ts +85 -0
  170. package/dist/workflows/sendBatch.d.ts.map +1 -0
  171. package/dist/workflows/sendBatch.js +50 -0
  172. package/dist/workflows/worker.d.ts +100 -0
  173. package/dist/workflows/worker.d.ts.map +1 -0
  174. package/dist/workflows/worker.js +117 -0
  175. package/package.json +22 -11
  176. package/src/version.generated.ts +1 -1
@@ -0,0 +1,138 @@
1
+ import { EMAIL_LINK_SIGNING_KEY } from "../crypto/signingKey.js";
2
+ import { emailHostEnv } from "../workflows/hostEnv.js";
3
+ import { suppressionDatabaseName } from "./provisionEmail.js";
4
+ import { hostEnvFindings } from "@pithy-sh/core/src/capability/settings";
5
+ import { checkHostEnv } from "@pithy-sh/core/src/workflow/hostEnv";
6
+ //#region src/provision/settingsCheck.ts
7
+ /**
8
+ * A stand-in for a binding, so the local tier judges values rather than wiring.
9
+ *
10
+ * `EmailHostEnv` duck-types its bindings — it asserts the method the host calls, because these are host
11
+ * objects the runtime hands over and there is no class to compare against. That is what makes a stub
12
+ * possible here at all, and it is why the stub carries the methods rather than being an empty object: the
13
+ * schema would refuse `{}` and the report would fill with wiring faults doctor already states elsewhere.
14
+ */
15
+ function stubBindings() {
16
+ const d1 = { prepare: () => void 0 };
17
+ return {
18
+ DB: d1,
19
+ EMAIL_SUPPRESSIONS: d1,
20
+ SECRETS: d1,
21
+ SECRETS_ENCRYPTION_KEYS: "checked elsewhere",
22
+ EMAIL: { send: () => void 0 },
23
+ EMAIL_SENDER: {
24
+ create: () => void 0,
25
+ get: () => void 0
26
+ },
27
+ EMAIL_SCHEDULER: { create: () => void 0 }
28
+ };
29
+ }
30
+ /** The domain half of an address, lowercased, or `null` where the address carries none usable. */
31
+ function domainOf(address) {
32
+ const at = address.lastIndexOf("@");
33
+ if (at < 0) return null;
34
+ const domain = address.slice(at + 1).trim().toLowerCase();
35
+ return domain.includes(".") ? domain : null;
36
+ }
37
+ /** The origin of a URL, or `null` when it is not one. Compared origin-to-origin, never string-to-string. */
38
+ function originOf(url) {
39
+ try {
40
+ return new URL(url).origin;
41
+ } catch {
42
+ return null;
43
+ }
44
+ }
45
+ /**
46
+ * The host's own parse of the values this composition would hand it.
47
+ *
48
+ * Run **once**, not once per environment, and reported with no environment named: `email({ … })` is one
49
+ * config object per Worker, so a `BASE_URL` that is not a URL is one edit however many environments a
50
+ * project declares. Three lines about one key is how a report stops being read.
51
+ */
52
+ function localHostEnv(config) {
53
+ const candidate = {
54
+ ...stubBindings(),
55
+ BASE_URL: config.baseUrl,
56
+ ...config.theme ? { EMAIL_THEME: JSON.stringify(config.theme) } : {}
57
+ };
58
+ return hostEnvFindings(checkHostEnv(emailHostEnv, candidate), null);
59
+ }
60
+ /**
61
+ * Whether the configured base URL is an origin this project actually answers on.
62
+ *
63
+ * `pithy email provision` stamps each host's `BASE_URL` from that environment's *resolved worker address*,
64
+ * so a deployed host is right by construction — but `email({ baseUrl })` is what `pithy dev` renders links
65
+ * against and what the repository states its intent with, and a value matching no declared origin is a
66
+ * link to a host nothing serves. Asked only when some environment declares one: a project before its first
67
+ * domain has nothing to compare against, and `Origins:` already reports that.
68
+ */
69
+ function localBaseUrlOrigin(config, context) {
70
+ const declared = context.environments.map((environment) => environment.origin === null ? null : originOf(environment.origin)).filter((origin) => origin !== null);
71
+ const configured = originOf(config.baseUrl);
72
+ if (declared.length === 0 || configured === null || declared.includes(configured)) return [];
73
+ return [{
74
+ setting: "BASE_URL",
75
+ environment: null,
76
+ problem: `Links are built against ${configured}, and no environment this project declares answers on it.`,
77
+ action: `Set \`email({ baseUrl })\` to an origin this project serves: ${declared.join(", ")}.`
78
+ }];
79
+ }
80
+ /** The address question, asked once: it is one config key, and one edit fixes every environment. */
81
+ function localForAddress(config) {
82
+ if (domainOf(config.fromAddress) !== null) return [];
83
+ return [{
84
+ setting: "fromAddress",
85
+ environment: null,
86
+ problem: `${config.fromAddress} is not an address a sending domain can be read from.`,
87
+ action: "Set `email({ fromAddress })` to an address on a domain you have onboarded onto Email Service."
88
+ }];
89
+ }
90
+ /** The last declared environment — the one a project-wide remedy is named for. */
91
+ function lastEnvironment(context) {
92
+ return context.environments.at(-1)?.name ?? "prod";
93
+ }
94
+ /** The account half: the zone, the suppression database, and the signing key. */
95
+ async function accountFindings(config, context) {
96
+ const findings = [];
97
+ const domain = domainOf(config.fromAddress);
98
+ if (domain !== null && !await context.account.zone(domain)) findings.push({
99
+ setting: "fromAddress",
100
+ environment: null,
101
+ problem: `${domain} is not a zone on this Cloudflare account, so it cannot be onboarded onto Email Service.`,
102
+ action: `Add ${domain} to this Cloudflare account, then onboard it onto Email Service in the dashboard.`
103
+ });
104
+ const suppressions = suppressionDatabaseName(context.project);
105
+ if (!(await context.account.d1Databases()).includes(suppressions)) findings.push({
106
+ setting: "EMAIL_SUPPRESSIONS",
107
+ environment: null,
108
+ problem: `No D1 database named ${suppressions} exists on this account.`,
109
+ action: `Run \`pithy email provision --env ${lastEnvironment(context)}\`. Nothing is suppressed until it exists.`
110
+ });
111
+ for (const environment of context.environments) {
112
+ if (environment.name === "dev") continue;
113
+ if (await context.account.secret({
114
+ name: "email-link-signing-key",
115
+ environment: environment.name
116
+ })) continue;
117
+ findings.push({
118
+ setting: EMAIL_LINK_SIGNING_KEY,
119
+ environment: environment.name,
120
+ problem: `The link-signing key has no value in ${environment.name}, so no tracking or unsubscribe link can be signed.`,
121
+ action: `Run \`pithy secrets provision --env ${environment.name}\`.`
122
+ });
123
+ }
124
+ return findings;
125
+ }
126
+ /** Email's settings check, built from one composition's resolved config. Declared on the capability. */
127
+ function emailSettings(config) {
128
+ return {
129
+ local: (context) => [
130
+ ...localHostEnv(config),
131
+ ...localForAddress(config),
132
+ ...localBaseUrlOrigin(config, context)
133
+ ],
134
+ account: (context) => accountFindings(config, context)
135
+ };
136
+ }
137
+ //#endregion
138
+ export { emailSettings };
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Batch identity — the one rule every dispatcher of a send Workflow keeps (pithy-sh/pithy#342).
3
+ *
4
+ * **A job's `batchId` names the send Workflow instance that is coming for it, and nothing else.** Null
5
+ * means no instance is. There is no third meaning, and in particular it is not a history of which batch
6
+ * touched the row last.
7
+ *
8
+ * It binds over every row in a status `runScheduler` queries — `scheduled`, `pending`, `sending` — which
9
+ * is every row the id can be read from. A terminal row (`sent`, `failed`, `suppressed`, `bounced`,
10
+ * `canceled`) keeps whatever it last carried, because no tick will ever look at it and clearing it
11
+ * would be a write bought for nobody. What that costs is exactly one obligation, and it is `retryJob`'s:
12
+ * the write that brings a terminal row back into the queried set must set this in the same statement.
13
+ *
14
+ * So the rule for a future writer is short. **If you move a job into `scheduled`, `pending` or
15
+ * `sending`, you own this column in that statement.** Three places do today.
16
+ *
17
+ * That is the whole basis of the scheduler's veto. `runScheduler` leaves a stale-looking row alone when
18
+ * the runtime says the instance it names is alive, so a row naming an instance that is *not* the one
19
+ * working it turns the veto into a lie in one of two directions:
20
+ *
21
+ * - It names a **dead** instance and a live one is working the row anyway — the tick re-drives, a second
22
+ * Workflow renders and sends, and one person gets two copies.
23
+ * - It names a **live** instance that is not working the row — the tick holds a genuinely stranded job
24
+ * for as long as some unrelated batch keeps running, and the mail does not go out.
25
+ *
26
+ * Three places set a job to a status the scheduler queries, so three places must uphold it: `enqueueEmail`
27
+ * (immediate dispatch), `retryJob` (an operator re-queueing a failure), and `runScheduler` itself (the
28
+ * claim). Each mints the id *before* the write that makes the row queryable and creates the instance
29
+ * under it afterwards, so the worst an interrupted dispatch can leave behind is a row naming an instance
30
+ * that does not exist — which the runtime disowns, which reads as dead, which is recovered. The failure
31
+ * mode of this design is a duplicate render that `runSend` short-circuits, never a duplicate send.
32
+ */
33
+ /**
34
+ * Mint a batch id. A UUID, and deliberately nothing more.
35
+ *
36
+ * It becomes a Workflow instance id, so uniqueness is the only property it needs and the only one
37
+ * anything may read from it: a batch id is not a timestamp, not a shard key, and not sortable. It is
38
+ * here rather than inline at each dispatcher so that the three of them cannot drift into three id
39
+ * schemes, one of which collides and rejects a `create` nobody sees fail.
40
+ */
41
+ export declare function mintBatchId(): string;
42
+ //# sourceMappingURL=batchIdentity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"batchIdentity.d.ts","sourceRoot":"","sources":["../../src/send/batchIdentity.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH;;;;;;;GAOG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAEpC"}
@@ -0,0 +1,46 @@
1
+ //#region src/send/batchIdentity.ts
2
+ /**
3
+ * Batch identity — the one rule every dispatcher of a send Workflow keeps (pithy-sh/pithy#342).
4
+ *
5
+ * **A job's `batchId` names the send Workflow instance that is coming for it, and nothing else.** Null
6
+ * means no instance is. There is no third meaning, and in particular it is not a history of which batch
7
+ * touched the row last.
8
+ *
9
+ * It binds over every row in a status `runScheduler` queries — `scheduled`, `pending`, `sending` — which
10
+ * is every row the id can be read from. A terminal row (`sent`, `failed`, `suppressed`, `bounced`,
11
+ * `canceled`) keeps whatever it last carried, because no tick will ever look at it and clearing it
12
+ * would be a write bought for nobody. What that costs is exactly one obligation, and it is `retryJob`'s:
13
+ * the write that brings a terminal row back into the queried set must set this in the same statement.
14
+ *
15
+ * So the rule for a future writer is short. **If you move a job into `scheduled`, `pending` or
16
+ * `sending`, you own this column in that statement.** Three places do today.
17
+ *
18
+ * That is the whole basis of the scheduler's veto. `runScheduler` leaves a stale-looking row alone when
19
+ * the runtime says the instance it names is alive, so a row naming an instance that is *not* the one
20
+ * working it turns the veto into a lie in one of two directions:
21
+ *
22
+ * - It names a **dead** instance and a live one is working the row anyway — the tick re-drives, a second
23
+ * Workflow renders and sends, and one person gets two copies.
24
+ * - It names a **live** instance that is not working the row — the tick holds a genuinely stranded job
25
+ * for as long as some unrelated batch keeps running, and the mail does not go out.
26
+ *
27
+ * Three places set a job to a status the scheduler queries, so three places must uphold it: `enqueueEmail`
28
+ * (immediate dispatch), `retryJob` (an operator re-queueing a failure), and `runScheduler` itself (the
29
+ * claim). Each mints the id *before* the write that makes the row queryable and creates the instance
30
+ * under it afterwards, so the worst an interrupted dispatch can leave behind is a row naming an instance
31
+ * that does not exist — which the runtime disowns, which reads as dead, which is recovered. The failure
32
+ * mode of this design is a duplicate render that `runSend` short-circuits, never a duplicate send.
33
+ */
34
+ /**
35
+ * Mint a batch id. A UUID, and deliberately nothing more.
36
+ *
37
+ * It becomes a Workflow instance id, so uniqueness is the only property it needs and the only one
38
+ * anything may read from it: a batch id is not a timestamp, not a shard key, and not sortable. It is
39
+ * here rather than inline at each dispatcher so that the three of them cannot drift into three id
40
+ * schemes, one of which collides and rejects a `create` nobody sees fail.
41
+ */
42
+ function mintBatchId() {
43
+ return crypto.randomUUID();
44
+ }
45
+ //#endregion
46
+ export { mintBatchId };
@@ -0,0 +1,216 @@
1
+ import type { EmailJobStatus, SendMode, SuppressionReason } from "../data/enums";
2
+ import type { EmailDatabase, EmailSuppressionDatabase } from "../data/tables";
3
+ import { type EmailMessageLayers } from "../templates/messages";
4
+ import type { EmailTheme } from "../templates/theme";
5
+ /**
6
+ * Enqueue an email. A request handler only ever does this — it never sends inline. Every email becomes
7
+ * a `pithy_email_jobs` row; an `immediate` job also kicks the send Workflow now (lowest latency), while
8
+ * `scheduled` and `timezone` jobs are left for the every-minute scheduler to pick up. The payload is
9
+ * validated against the template schema here, so a bad call fails at enqueue, not mid-send.
10
+ *
11
+ * **Suppression is consulted here too, and no caller asks for it** (pithy-sh/pithy#355). A blocked
12
+ * recipient never becomes a queued send: the row is born `suppressed`, no Workflow is started, and the
13
+ * reason comes back on the result. The point is not a second gate — `runSend` is and stays the
14
+ * authority, because whether an address is blocked is a question about the instant of sending and a
15
+ * scheduled job is enqueued days before that. The point is that the caller **learns**, at the moment it
16
+ * asked, without holding the suppression database itself. A three-person account whose addresses have
17
+ * all hard-bounced is otherwise three ordinary skips in a send log nobody reads, rather than one notice
18
+ * that reached nobody, said at the moment it went out.
19
+ *
20
+ * **The kind comes from the template, never from a caller** — {@link templateKind}, the same accessor
21
+ * `runSend` uses. That is what keeps an unsubscribe from a newsletter from withholding an invitation:
22
+ * the four suppression reasons stopped being interchangeable, and a check that restated
23
+ * `"transactional"` at the call site would be making a claim about somebody else's template.
24
+ */
25
+ /**
26
+ * The Workflow binding used to start a send (Cloudflare `Workflow.create`). At enqueue it sends a batch
27
+ * of one; the scheduler's fan-out starts one instance per batch through the same binding.
28
+ *
29
+ * `id` names the instance being created, and **every dispatcher passes one** (pithy-sh/pithy#342): the
30
+ * scheduler passes its batch's, an enqueue passes the one it just stamped on the row, and a retry passes
31
+ * the one it minted to replace the failed batch's. It is optional here only because the platform allows
32
+ * omitting it, and omitting it is what made an immediate send unattributable to any instance — so the
33
+ * row could not say a Workflow was coming and the safety net sent a second one. See
34
+ * `send/batchIdentity.ts`.
35
+ */
36
+ export interface SendWorkflowBinding {
37
+ create(options: {
38
+ id?: string;
39
+ params: {
40
+ jobIds: string[];
41
+ };
42
+ }): Promise<unknown>;
43
+ }
44
+ /** What the caller provides to enqueue an email. */
45
+ export interface EnqueueInput {
46
+ /** The recipient address. */
47
+ to: string;
48
+ /** The template id (e.g. `magicLink`). */
49
+ template: string;
50
+ /** The template input variables; validated against the template's payload schema. */
51
+ payload: unknown;
52
+ /** Send mode; defaults to `immediate`. */
53
+ mode?: SendMode;
54
+ /** For `scheduled` mode: the absolute time to send. */
55
+ sendAt?: Date;
56
+ /** For `timezone` mode: the recipient-local time-of-day, `HH:MM`. */
57
+ localTime?: string;
58
+ /** For `timezone` mode: the recipient's IANA timezone. */
59
+ timezone?: string;
60
+ /** The marketing campaign id, for attribution. */
61
+ campaignId?: string;
62
+ /**
63
+ * The language to write this message in, as a BCP-47 tag. Omit where the recipient has not chosen one.
64
+ *
65
+ * **The recipient's, never the caller's.** A magic link is answered by the person who asked for it,
66
+ * and the request that triggers it is theirs — but a nudge, an invitation and an operational notice
67
+ * are all enqueued by somebody else's request, or by a cron with no request at all. So the tag comes
68
+ * from what is known about the *recipient* (`pithy_auth_users.locale` for a signed-up reader, the
69
+ * negotiated request locale for somebody signing in for the first time), and it is stored on the row
70
+ * so the send Workflow renders the body in the language the subject was already written in.
71
+ *
72
+ * Omitted renders the kit's English, which is the seam's behavior everywhere: a project that never
73
+ * composed an i18n capability sends exactly what it sent before any of this landed.
74
+ */
75
+ locale?: string;
76
+ /**
77
+ * What this message is *about*, when the template id does not say it on its own.
78
+ *
79
+ * The discriminator for a template that carries more than one kind of message (pithy-sh/pithy#382).
80
+ * `sentSince` matches on it, so a caller deciding whether to send — or whether to send a *correction* —
81
+ * can tell two messages apart that share a template and a recipient. Opaque: nothing here parses it,
82
+ * renders it, or puts it on a header or a link.
83
+ *
84
+ * **Not `campaignId`.** That one is marketing attribution and it leaves this row — onto every event,
85
+ * into `campaignStats`, and signed into the tracking token that travels in a delivered email's URLs.
86
+ * See the column's own note on `EmailJob`.
87
+ *
88
+ * Omit it where the template id already answers "what is this", which is most templates.
89
+ */
90
+ correlation?: string;
91
+ /** Override click-link rewriting (defaults on for marketing, off for transactional). */
92
+ clickTracking?: boolean;
93
+ /** Override open-pixel injection (defaults on for marketing, off for transactional). */
94
+ openTracking?: boolean;
95
+ /**
96
+ * The address a recipient's answer should go to, when it is not `fromAddress`.
97
+ *
98
+ * `@pithy-sh/support` is what this is for: a reply is sent as the adopter's onboarded sending
99
+ * identity (Cloudflare validates the `From` domain against exactly what was onboarded) while the
100
+ * conversation has to come back to the support inbox, which is usually a different subdomain.
101
+ */
102
+ replyTo?: string;
103
+ /**
104
+ * The `Message-ID` this job answers, angle brackets included — the `In-Reply-To` header.
105
+ *
106
+ * Set together with {@link references}. Threading on ids is what keeps a customer's client showing
107
+ * one conversation instead of one message per answer, and only the Worker holds the chain, which
108
+ * is why a reply is enqueued here rather than composed by whatever surface a human typed it into.
109
+ */
110
+ inReplyTo?: string;
111
+ /** The `References` chain, angle-bracketed and space-separated. Built by the caller from the parent. */
112
+ references?: string;
113
+ }
114
+ /** Dependencies enqueue needs: the database, the from identity, optional send-Workflow binding, time, ids. */
115
+ export interface EnqueueDeps {
116
+ db: EmailDatabase;
117
+ fromAddress: string;
118
+ fromName: string;
119
+ theme: EmailTheme;
120
+ /**
121
+ * Where the words for a locale come from — the composed project's catalogs.
122
+ *
123
+ * Absent walks this package's own English, which is what keeps the i18n capability optional. The
124
+ * email capability fills it from a composed `i18n` at assembly; nothing here imports that package.
125
+ */
126
+ layersFor?: EmailMessageLayers;
127
+ /** The send Workflow binding. When present, an immediate job is dispatched now; absent, the scheduler takes it. */
128
+ sender?: SendWorkflowBinding;
129
+ /**
130
+ * The global suppression list. When present, a blocked recipient is recorded here and never queued.
131
+ *
132
+ * Optional for the same reason {@link EnqueueDeps.sender} is, and it is worth being exact about which
133
+ * reason: absence does not mean "send to blocked addresses". The capability declares
134
+ * `EMAIL_SUPPRESSIONS` a required binding, so a composed app worker always has one; and where a caller
135
+ * genuinely has none, `runSend` still refuses the recipient before anything leaves. Making it fatal
136
+ * here would mean refusing to *queue* a message because a list that will be consulted again before it
137
+ * goes could not be consulted yet, which is strictly worse than queueing it.
138
+ */
139
+ suppressionDb?: EmailSuppressionDatabase;
140
+ now: Date;
141
+ /** Generate a job id (a UUID in production). */
142
+ newId: () => string;
143
+ /**
144
+ * Mint the id of the batch this enqueue dispatches — **the send Workflow instance's id**
145
+ * (pithy-sh/pithy#342). Defaults to {@link mintBatchId}; injected only so a test can name it.
146
+ */
147
+ newBatchId?: () => string;
148
+ }
149
+ /** The result of enqueuing: the new job id and its initial status. */
150
+ export interface EnqueueResult {
151
+ jobId: string;
152
+ /**
153
+ * What the row was born as — and, for the caller, whether anything is coming for it.
154
+ *
155
+ * `pending` and `scheduled` both mean a send is on its way. `suppressed` means the address is
156
+ * blocked. **`undispatched` means this composition binds no send Workflow**, so nothing was started
157
+ * and nothing is coming while it stays that way (pithy-sh/pithy#410): a caller that renders "check
158
+ * your inbox" off it is reporting a delivery that cannot happen. It is the one status here that
159
+ * describes the *deployment* rather than the message — and the scheduler drains those rows once a
160
+ * host exists, so it is not the end of the job.
161
+ */
162
+ status: EmailJobStatus;
163
+ /**
164
+ * Why nothing was queued, when the recipient is on the suppression list.
165
+ *
166
+ * The same field {@link import("./runSend").SendOutcome} carries and for the same reason: a caller
167
+ * that only saw a status other than `failed` would report a delivery that never happened. "Suppressed"
168
+ * alone is not enough either — whether the mailbox bounced, complained, or opted out is what an
169
+ * operator's next move depends on.
170
+ */
171
+ suppressionReason?: SuppressionReason;
172
+ /**
173
+ * The **enqueue-time** render — the sentence this call wrote to `pithy_email_jobs.subject`, in the
174
+ * recipient's language, and the value the row is born with (pithy-sh/pithy#443).
175
+ *
176
+ * **For the caller that has to say what it queued.** Enqueuing is what a surface does; auditing it is
177
+ * what a surface with an administrative trail also does. Without this, that caller had to render the
178
+ * same key a second time — restating the theme it configured and the layer stack it composed, then
179
+ * holding a test pinning its own copy against the kit's catalog to notice when the kit's wording
180
+ * moved. An audit row written at enqueue now reads the same string the job row was written with,
181
+ * rather than a second rendering free to disagree with it.
182
+ *
183
+ * **Locale is what makes it more than a convenience.** A caller that mirrored the English sentence by
184
+ * hand agreed with the row by coincidence, for as long as there was one language. Pass a `locale` and
185
+ * the template renders the recipient's catalog while the mirror keeps restating English, and the trail
186
+ * then claims a subject nobody was ever sent.
187
+ *
188
+ * **{@link import("./runSend").runSend} remains the authority on what was *delivered***, because it
189
+ * renders again — in the send Worker, at the moment the message leaves — and rewrites this column
190
+ * from that render. Three things part the two renders — the three `runSend` names at the line where
191
+ * it rewrites: a template corrected, a theme renamed, or a catalog sentence retranslated. A subject
192
+ * can interpolate the theme (`welcome`'s takes `theme.appName`), so a rename parts them with no
193
+ * catalog movement at all.
194
+ *
195
+ * **And the gap between the two is not only the wait in the queue.** Waiting sets one bound on it,
196
+ * seconds for an immediate send and days for a `scheduled` one. The other is that the send Workflow
197
+ * is its own deploy: it carries the kit's email copy in its own bundle, and the theme and any
198
+ * override sentences in vars stamped at provision (`docs/I18N.md`). So a send Worker whose copy has
199
+ * drifted from the Worker that enqueued is not a window a fast send outruns — it stands until the two
200
+ * are back in step, and an immediate send lands inside it like any other. This is a record of what
201
+ * was queued, never a promise about the delivered sentence — a trail that must reflect delivery reads
202
+ * the row back after the send.
203
+ *
204
+ * Present on every result, including a `suppressed` one: the withheld row carries a rendered subject
205
+ * like any other, no send will ever rewrite it, and a message that reached nobody is the one an
206
+ * operator most needs on the record.
207
+ *
208
+ * **Deliberately not the body.** A body is large, it is the thing this capability is careful never to
209
+ * log, and no caller has a reason to hold one — `runSend` renders it inside the Workflow, at the
210
+ * moment it leaves, and that is the only place it exists.
211
+ */
212
+ subject: string;
213
+ }
214
+ /** Enqueue an email job, dispatching the send Workflow immediately when the mode is `immediate`. */
215
+ export declare function enqueueEmail(deps: EnqueueDeps, input: EnqueueInput): Promise<EnqueueResult>;
216
+ //# sourceMappingURL=enqueue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enqueue.d.ts","sourceRoot":"","sources":["../../src/send/enqueue.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAG9E,OAAO,EAAE,KAAK,kBAAkB,EAAmC,MAAM,uBAAuB,CAAC;AACjG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAMrD;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,OAAO,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE;YAAE,MAAM,EAAE,MAAM,EAAE,CAAA;SAAE,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAClF;AAED,oDAAoD;AACpD,MAAM,WAAW,YAAY;IAC3B,6BAA6B;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,qFAAqF;IACrF,OAAO,EAAE,OAAO,CAAC;IACjB,0CAA0C;IAC1C,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,uDAAuD;IACvD,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;;;;;;OAaG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wFAAwF;IACxF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,wFAAwF;IACxF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wGAAwG;IACxG,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,8GAA8G;AAC9G,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,aAAa,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,UAAU,CAAC;IAClB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,kBAAkB,CAAC;IAC/B,mHAAmH;IACnH,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,wBAAwB,CAAC;IACzC,GAAG,EAAE,IAAI,CAAC;IACV,gDAAgD;IAChD,KAAK,EAAE,MAAM,MAAM,CAAC;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,MAAM,CAAC;CAC3B;AAED,sEAAsE;AACtE,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;;;;OASG;IACH,MAAM,EAAE,cAAc,CAAC;IACvB;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAgBD,oGAAoG;AACpG,wBAAsB,YAAY,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,CAoJjG"}
@@ -0,0 +1,153 @@
1
+ import { EmailJob } from "../data/emailJob.js";
2
+ import { recordEvent } from "./events.js";
3
+ import { blockingSuppression } from "./suppression.js";
4
+ import { EmailInvalidPayloadError } from "../error/errors.js";
5
+ import { emailTranslator, kitEmailLayers } from "../templates/messages.js";
6
+ import { getTemplate, renderSubject, templateKind } from "../templates/engine.js";
7
+ import { mintBatchId } from "./batchIdentity.js";
8
+ import { resolveTimezoneSendAt } from "./sendAt.js";
9
+ import { normalizeAddress } from "@pithy-sh/core/src/address/address";
10
+ import { isLocale } from "@pithy-sh/core/src/i18n/locale";
11
+ //#region src/send/enqueue.ts
12
+ /** Resolve the absolute send time and initial status from the requested mode. */
13
+ function resolveSchedule(input, now) {
14
+ const mode = input.mode ?? "immediate";
15
+ if (mode === "immediate") return {
16
+ mode,
17
+ sendAt: now,
18
+ status: "pending"
19
+ };
20
+ if (mode === "scheduled") {
21
+ if (!input.sendAt) throw new EmailInvalidPayloadError({ detail: "scheduled mode requires an absolute sendAt" });
22
+ return {
23
+ mode,
24
+ sendAt: input.sendAt,
25
+ status: "scheduled"
26
+ };
27
+ }
28
+ if (!input.localTime || !input.timezone) throw new EmailInvalidPayloadError({ detail: "timezone mode requires localTime and timezone" });
29
+ return {
30
+ mode,
31
+ sendAt: resolveTimezoneSendAt(input.localTime, input.timezone, now),
32
+ status: "scheduled"
33
+ };
34
+ }
35
+ /** Enqueue an email job, dispatching the send Workflow immediately when the mode is `immediate`. */
36
+ async function enqueueEmail(deps, input) {
37
+ const template = getTemplate(input.template);
38
+ const translator = emailTranslator(input.locale, deps.layersFor ?? kitEmailLayers);
39
+ const subject = renderSubject(input.template, input.payload, deps.theme, translator);
40
+ const { mode, sendAt, status: scheduled } = resolveSchedule(input, deps.now);
41
+ /**
42
+ * Whether the suppression list withholds *this* message from *this* address.
43
+ *
44
+ * `templateKind(input.template)` and never a literal — `runSend` reads the same accessor, and the two
45
+ * agreeing is what makes a hard bounce withhold an invitation while an unsubscribe does not. A caller
46
+ * cannot influence this and is not asked to: it is the template's own declaration.
47
+ */
48
+ const blocked = deps.suppressionDb ? await blockingSuppression(deps.suppressionDb, input.to, deps.now, templateKind(input.template)) : null;
49
+ const recipient = normalizeAddress(input.to);
50
+ const sender = !blocked && mode === "immediate" ? deps.sender : void 0;
51
+ /**
52
+ * An immediate job with nothing to dispatch it on (pithy-sh/pithy#410).
53
+ *
54
+ * A missing binding is a **configuration fact known at compose time**, not a transient failure, and
55
+ * the two used to be recorded identically: both left the row `pending` and told the caller "on its
56
+ * way". That reads as deferral because of the scheduler's safety net — but the net is the
57
+ * every-minute cron on the host worker, and a composition with no send Workflow binding has no host
58
+ * worker either. So there is nothing to defer to *yet*, and `pending` was a promise the deployment
59
+ * could not keep. A magic link enqueued under `pithy dev` sat in that state forever while the sign-in
60
+ * screen said "check your inbox".
61
+ *
62
+ * It is a truthful status, never a grave. The day a host is deployed, its first tick claims these
63
+ * rows exactly as it claims a stranded `pending` one — a tick running at all is the host existing —
64
+ * so mail enqueued before `pithy email provision` is delayed and not lost.
65
+ *
66
+ * A `scheduled` or `timezone` job is deliberately not this: the scheduler claims it by `sendAt` and
67
+ * never needed a binding at enqueue. Nor is a suppressed recipient, which has its own status and its
68
+ * own event. This is only the case where the caller asked for a send now and nothing exists to make
69
+ * one.
70
+ */
71
+ const undispatchable = !blocked && mode === "immediate" && !deps.sender;
72
+ const status = blocked ? "suppressed" : undispatchable ? "undispatched" : scheduled;
73
+ /**
74
+ * The batch this enqueue is about to start — named here, before the row exists, because the row has to
75
+ * carry it (pithy-sh/pithy#342).
76
+ *
77
+ * Without it the row is born naming nobody, and a row naming nobody is stranded by definition: the
78
+ * scheduler's safety net claims any `pending` job older than `graceMs` and starts a *second* send
79
+ * Workflow for it. That is not a hypothetical race with a slow enqueue — it is the ordinary shape of a
80
+ * transient send failure. `runSend` throws on a retryable error so the Workflow step backs off, and a
81
+ * backoff writes nothing at all, so the very first retry leaves the row looking exactly like a dispatch
82
+ * that died. `runSend` short-circuits only a job already `sent`, so both instances would render and
83
+ * both would call the Email Service. One person, two emails.
84
+ *
85
+ * Null for a `scheduled` or `timezone` job, and for an immediate one with no binding, because in those
86
+ * cases nothing is coming for the row and saying otherwise would hold it against a batch that does not
87
+ * exist.
88
+ */
89
+ const batchId = sender ? (deps.newBatchId ?? mintBatchId)() : null;
90
+ const marketing = template.category === "marketing";
91
+ const job = {
92
+ id: deps.newId(),
93
+ toAddress: input.to,
94
+ recipientKey: recipient,
95
+ fromAddress: deps.fromAddress,
96
+ fromName: deps.fromName,
97
+ subject,
98
+ template: input.template,
99
+ category: template.category,
100
+ payload: input.payload,
101
+ payloadRedactedAt: null,
102
+ status,
103
+ mode,
104
+ attempts: 0,
105
+ batchId,
106
+ sendAt,
107
+ timezone: input.timezone ?? null,
108
+ localTime: input.localTime ?? null,
109
+ campaignId: input.campaignId ?? null,
110
+ locale: isLocale(input.locale ?? "") ? input.locale ?? null : null,
111
+ correlation: input.correlation ?? null,
112
+ openTracking: input.openTracking ?? marketing,
113
+ clickTracking: input.clickTracking ?? marketing,
114
+ messageId: null,
115
+ error: blocked ? `recipient suppressed: ${blocked}` : undispatchable ? "no EMAIL_SENDER binding: this composition can start no send Workflow" : null,
116
+ bounceCode: null,
117
+ bounceType: null,
118
+ replyTo: input.replyTo ?? null,
119
+ inReplyTo: input.inReplyTo ?? null,
120
+ references: input.references ?? null,
121
+ createdAt: deps.now,
122
+ updatedAt: deps.now,
123
+ sentAt: null
124
+ };
125
+ await deps.db.insertInto("pithyEmailJobs").values(EmailJob.encode(job)).execute();
126
+ if (blocked) {
127
+ await recordEvent(deps.db, {
128
+ jobId: job.id,
129
+ recipient,
130
+ type: "suppressed",
131
+ detail: blocked
132
+ }, deps.now);
133
+ return {
134
+ jobId: job.id,
135
+ status,
136
+ subject,
137
+ suppressionReason: blocked
138
+ };
139
+ }
140
+ if (sender && batchId) try {
141
+ await sender.create({
142
+ id: batchId,
143
+ params: { jobIds: [job.id] }
144
+ });
145
+ } catch {}
146
+ return {
147
+ jobId: job.id,
148
+ status,
149
+ subject
150
+ };
151
+ }
152
+ //#endregion
153
+ export { enqueueEmail };
@@ -0,0 +1,27 @@
1
+ import type { PithyError } from "@pithy-sh/core/src/error/pithyError";
2
+ /**
3
+ * Map a Cloudflare Email Service binding error (thrown with an `E_*` `.code`) to a Pithy error and a
4
+ * retry decision. The codes are documented at
5
+ * https://developers.cloudflare.com/email-service/api/send-emails/rest-api/ and in the binding's error
6
+ * table. Retryable codes (rate/quota/transient delivery) are surfaced so the send Workflow re-drives
7
+ * them with backoff; validation/sender/content codes are terminal — retrying cannot help.
8
+ */
9
+ /** How a given send error is handled: which Pithy error to raise, and whether the send Workflow retries. */
10
+ export interface ClassifiedSendError {
11
+ /** The `E_*` code reported by the binding, or `E_UNKNOWN` when none was present. */
12
+ code: string;
13
+ /** Whether the send should be retried with backoff. */
14
+ retryable: boolean;
15
+ /** Whether the failure means the recipient is suppressed (so the address should be locally suppressed). */
16
+ suppressed: boolean;
17
+ /** The Pithy error carrying the public-safe message and the code/detail for logs. */
18
+ error: PithyError;
19
+ }
20
+ /**
21
+ * Classify a send failure. `E_RECIPIENT_SUPPRESSED` is terminal and means the address must be
22
+ * suppressed locally too; rate/quota and transient delivery codes are retryable; everything else
23
+ * (validation, sender, content, headers) is terminal. An unknown code is treated as a transient
24
+ * failure so a momentary fault gets one bounded retry rather than failing the job outright.
25
+ */
26
+ export declare function classifySendError(err: unknown): ClassifiedSendError;
27
+ //# sourceMappingURL=errorMapping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorMapping.d.ts","sourceRoot":"","sources":["../../src/send/errorMapping.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAGtE;;;;;;GAMG;AAEH,4GAA4G;AAC5G,MAAM,WAAW,mBAAmB;IAClC,oFAAoF;IACpF,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,SAAS,EAAE,OAAO,CAAC;IACnB,2GAA2G;IAC3G,UAAU,EAAE,OAAO,CAAC;IACpB,qFAAqF;IACrF,KAAK,EAAE,UAAU,CAAC;CACnB;AAuBD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,mBAAmB,CAmBnE"}