@resq-systems/email-templates 0.4.0 → 0.5.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.
Files changed (2) hide show
  1. package/README.md +9 -4
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -18,7 +18,7 @@
18
18
 
19
19
  Type-safe transactional email templates for React apps and backend pipelines.
20
20
 
21
- - **One contract.** Every email is a validated `{ name, to, data }` payload, described by an [Effect Schema](https://effect.website) discriminated union. Nothing else can be enqueued or rendered.
21
+ - **One contract.** Every email is a validated `{ name, to, data }` payload, described by an [Effect Schema](https://effect.website) discriminated union — including a validated, branded recipient (`EmailAddress`). Nothing else can be enqueued or rendered.
22
22
  - **React Email components.** Templates are React components built on [React Email](https://react.email) with a `<Tailwind>` theme mapped to the dark-first ResQ Systems brand — red primary, Syne/DM Sans/DM Mono — with oklch tokens converted to email-safe hex.
23
23
  - **Headless render.** `renderEmail(payload)` returns `{ to, subject, html, text }` with no DOM — safe to call from queue workers, cron jobs, and other pipelines.
24
24
  - **Pluggable sending.** A provider-agnostic `EmailSender` port with an optional Resend adapter under `@resq-systems/email-templates/send`.
@@ -37,7 +37,7 @@ bun add resend
37
37
 
38
38
  | Import | Contents | Runtime |
39
39
  | --- | --- | --- |
40
- | `@resq-systems/email-templates` | `EmailPayload` schema, types, `decodeEmailPayload`, `registry`, `renderEmail` | browser + server |
40
+ | `@resq-systems/email-templates` | `EmailPayload` schema, types, `EmailAddress`, `decodeEmailPayload`, `registry`, `renderEmail` | browser + server |
41
41
  | `@resq-systems/email-templates/emails` | `Email` primitives, `emailColors`, and the template components | browser + server |
42
42
  | `@resq-systems/email-templates/send` | `EmailSender` port, `createResendSender`, `sendEmail` | **server only** |
43
43
 
@@ -76,7 +76,7 @@ const { subject, html, text } = await renderEmail({
76
76
  // pass subject/html/text to SES, Postmark, Nodemailer, etc.
77
77
  ```
78
78
 
79
- The payload is validated at the boundary — an unknown `name` or missing required `data` throws `EmailValidationError`.
79
+ The payload is validated at the boundary — an unknown `name`, a missing required `data` field, or a malformed recipient `to` (including one carrying a CR/LF header-injection payload) throws `EmailValidationError`. The decoded `to` is a branded `EmailAddress`, so a validated recipient can't be confused with a raw string downstream.
80
80
 
81
81
  ## React app usage
82
82
 
@@ -97,6 +97,10 @@ import { WelcomeEmail } from "@resq-systems/email-templates/emails";
97
97
  | `password-reset` | `firstName?`, `resetUrl`, `expiresInMinutes?` |
98
98
  | `notification` | `title`, `body`, `severity?`, `actionUrl?`, `actionLabel?` |
99
99
  | `incident-alert` | `incidentId`, `title`, `severity`, `summary`, `location?`, `detectedAt?`, `dashboardUrl` |
100
+ | `password-changed` | `firstName?`, `changedAt?`, `secureAccountUrl?` |
101
+ | `new-device-login` | `firstName?`, `device?`, `location?`, `ipAddress?`, `at?`, `secureAccountUrl?` |
102
+ | `mission-approval` | `missionId`, `title`, `summary?`, `requestedBy?`, `severity?`, `approveUrl`, `expiresInMinutes?` |
103
+ | `org-invitation` | `orgName`, `inviterName?`, `orgRole?`, `acceptUrl`, `expiresInDays?` |
100
104
 
101
105
  ## Theming
102
106
 
@@ -152,7 +156,8 @@ const { html, text } = await mailer.renderEmail({
152
156
  ```
153
157
 
154
158
  `mailer` exposes `{ schema, registry, names, decode, renderEmail }`, each fully
155
- typed over your template set — unknown names and bad `data` are rejected at decode.
159
+ typed over your template set — unknown names, malformed recipients, and bad `data`
160
+ are rejected at decode.
156
161
 
157
162
  ## Adding a built-in template
158
163
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resq-systems/email-templates",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Type-safe transactional email templates: an Effect Schema contract, React Email components, headless render-to-html/text, and an optional Resend sender",
5
5
  "license": "Apache-2.0",
6
6
  "author": {