@ultimat3/mail 31.21.0 → 31.22.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/CLAUDE.md +4 -3
- package/README.md +3 -1
- package/package.json +6 -6
- package/src/index.ts +17 -2
- package/src/layout.ts +19 -0
- package/src/mail.ts +13 -0
package/CLAUDE.md
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
|
|
7
7
|
| File | Single responsibility |
|
|
8
8
|
|---|---|
|
|
9
|
-
| `mail.ts` | `defineMail`, the registry, `send` / `sendById` / `renderMessage` |
|
|
9
|
+
| `mail.ts` | `defineMail`, the registry (`restoreMails`: test-only), `send` / `sendById` / `renderMessage` |
|
|
10
10
|
| `blocks.ts` | the template vocabulary: `MailBlock`, `blocks`, `MailTemplate`, `TemplateArgs` |
|
|
11
11
|
| `render.ts` | blocks → HTML **and** text, plus the layout call and the footer slots |
|
|
12
|
-
| `layout.ts` | `MAIL_TOKENS` (light + dark), the 600px table shell, layout registry |
|
|
12
|
+
| `layout.ts` | `MAIL_TOKENS` (light + dark), the 600px table shell, layout registry (`restoreLayouts`: test-only) |
|
|
13
13
|
| `adapter.ts` | `@ultimat3/mail/adapter`: `installMailDriver` + reset, the `MailDriver` port, `MailError`/`sendFailed` — never on the `.` barrel; an app's line is `mail:` in `apps/<app>/runtime.ts` |
|
|
14
14
|
| `driver.ts` | `MailDriver` + memory/log/unconfigured + `resultFor` + the `installMailDriver` seam (on `./adapter`) |
|
|
15
15
|
| `driver-env.ts` | `selectMailDriver`: which transport an environment installs, and nothing else |
|
|
@@ -248,7 +248,8 @@ bun run --filter @ultimat3/mail typecheck
|
|
|
248
248
|
Gotchas:
|
|
249
249
|
- The registry erases `I` (`AnyMailDefinition`); `sendById` holds the package's only cast.
|
|
250
250
|
- No job driver configured ⇒ `send` delivers inline rather than dropping the message.
|
|
251
|
-
- Tests must not call `resetMails()` — template registration is module-level and shared.
|
|
251
|
+
- Tests must not call `resetMails()` — template registration is module-level and shared. Take a
|
|
252
|
+
test's own mails back with `restoreMails(held)` (`mail-registry.test.ts`).
|
|
252
253
|
- `driver-smtp.test.ts` runs a real `Bun.listen` SMTP server on loopback. The sealed test network
|
|
253
254
|
covers `fetch` only, so this is allowed — and it is the only proof the socket, the chunk queue
|
|
254
255
|
and the reply framing agree. Resend tests inject `options.fetch`; never unseal.
|
package/README.md
CHANGED
|
@@ -200,7 +200,9 @@ export const resend = resendEventReceiver({ secret: env['RESEND_WEBHOOK_SECRET']
|
|
|
200
200
|
|
|
201
201
|
The package ships none (v31). Every mail is an app's own `defineMail`; `@ultimat3/auth` sends
|
|
202
202
|
`auth.<purpose>` templates whose words live in the app catalog. `registeredMails()` /
|
|
203
|
-
`registeredMailIds()` list what the app declared, and nothing else.
|
|
203
|
+
`registeredMailIds()` list what the app declared, and nothing else. Test-only:
|
|
204
|
+
`restoreMails(mails)` and `restoreLayouts([{ name, layout }])` make either registry exactly what
|
|
205
|
+
was read (`registeredMails()`, `registeredLayouts()` + `layoutFor()`) — the rerun seam's pair.
|
|
204
206
|
|
|
205
207
|
## Previews — `defineMail({ preview })`
|
|
206
208
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/mail",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.22.0",
|
|
4
4
|
"description": "Transactional email as data: one template renders HTML and text, sent through a job.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ultimate",
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
"test": "bun test"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@ultimat3/core": "31.
|
|
47
|
-
"@ultimat3/i18n": "31.
|
|
48
|
-
"@ultimat3/jobs": "31.
|
|
49
|
-
"@ultimat3/schema": "31.
|
|
50
|
-
"@ultimat3/time": "31.
|
|
46
|
+
"@ultimat3/core": "31.22.0",
|
|
47
|
+
"@ultimat3/i18n": "31.22.0",
|
|
48
|
+
"@ultimat3/jobs": "31.22.0",
|
|
49
|
+
"@ultimat3/schema": "31.22.0",
|
|
50
|
+
"@ultimat3/time": "31.22.0"
|
|
51
51
|
}
|
|
52
52
|
}
|
package/src/index.ts
CHANGED
|
@@ -43,8 +43,22 @@ export { assertHeaderSafe } from './header-safety';
|
|
|
43
43
|
export { safeMailHref } from './html';
|
|
44
44
|
export { mailIdempotencyKey, mailMessageIdToken } from './idempotency';
|
|
45
45
|
export { mailMessageSchema, sendMailJob } from './job';
|
|
46
|
-
export type {
|
|
47
|
-
|
|
46
|
+
export type {
|
|
47
|
+
ColorScheme,
|
|
48
|
+
LayoutInput,
|
|
49
|
+
LayoutRegistration,
|
|
50
|
+
MailLayout,
|
|
51
|
+
MailToken,
|
|
52
|
+
UnsubscribeSlot,
|
|
53
|
+
} from './layout';
|
|
54
|
+
export {
|
|
55
|
+
layoutFor,
|
|
56
|
+
MAIL_TOKENS,
|
|
57
|
+
registeredLayouts,
|
|
58
|
+
registerLayout,
|
|
59
|
+
restoreLayouts,
|
|
60
|
+
token,
|
|
61
|
+
} from './layout';
|
|
48
62
|
export type { AnyMailDefinition, MailDefinition, MailInit, MailPreview, SendOptions } from './mail';
|
|
49
63
|
export {
|
|
50
64
|
defineMail,
|
|
@@ -53,6 +67,7 @@ export {
|
|
|
53
67
|
registeredMails,
|
|
54
68
|
renderMessage,
|
|
55
69
|
resetMails,
|
|
70
|
+
restoreMails,
|
|
56
71
|
send,
|
|
57
72
|
} from './mail';
|
|
58
73
|
export type { MailPreviewResult, PreviewOptions } from './preview';
|
package/src/layout.ts
CHANGED
|
@@ -228,3 +228,22 @@ export function layoutFor(name: string): MailLayout | undefined {
|
|
|
228
228
|
export function registeredLayouts(): readonly string[] {
|
|
229
229
|
return [...layouts.keys()].sort();
|
|
230
230
|
}
|
|
231
|
+
|
|
232
|
+
/** One layout under its name, as `restoreLayouts` takes it back. */
|
|
233
|
+
export interface LayoutRegistration {
|
|
234
|
+
readonly name: string;
|
|
235
|
+
readonly layout: MailLayout;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Test-only: the layouts become exactly `registrations`, `base` only if it is among them. One name
|
|
240
|
+
* twice is still `X_MAIL_DUPLICATE`. The map has no delete otherwise, so this is how
|
|
241
|
+
* `@ultimat3/testing`'s rerun seam forgets the layouts one test file registered.
|
|
242
|
+
*/
|
|
243
|
+
export function restoreLayouts(registrations: readonly LayoutRegistration[]): void {
|
|
244
|
+
layouts.clear();
|
|
245
|
+
for (const { name, layout } of registrations) {
|
|
246
|
+
if (layouts.has(name)) throw mailLayoutDuplicate(name);
|
|
247
|
+
layouts.set(name, layout);
|
|
248
|
+
}
|
|
249
|
+
}
|
package/src/mail.ts
CHANGED
|
@@ -125,6 +125,19 @@ export function resetMails(): void {
|
|
|
125
125
|
registry.clear();
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Test-only: the registry becomes exactly `mails` — what `registeredMails()` read earlier. One id
|
|
130
|
+
* twice is still `X_MAIL_DUPLICATE`. `@ultimat3/testing`'s rerun seam forgets one test file's ids
|
|
131
|
+
* with it, where `resetMails` would drop every mail a module imported earlier declared for good.
|
|
132
|
+
*/
|
|
133
|
+
export function restoreMails(mails: readonly AnyMailDefinition[]): void {
|
|
134
|
+
registry.clear();
|
|
135
|
+
for (const mail of mails) {
|
|
136
|
+
if (registry.has(mail.id)) throw mailDuplicate(mail.id);
|
|
137
|
+
registry.set(mail.id, mail);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
128
141
|
/**
|
|
129
142
|
* Validate, render, and build the envelope — everything `send` does before it decides
|
|
130
143
|
* between the queue and the transport. Exported so a host or a test can render a mail without
|