@nebutra/email 0.1.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/AGENTS.md ADDED
@@ -0,0 +1,83 @@
1
+ # AGENTS.md — packages/email
2
+
3
+ Execution contract for Nebutra's transactional email package.
4
+
5
+ ## Scope
6
+
7
+ Applies to everything under `packages/integrations/email/`.
8
+
9
+ ## Source Of Truth
10
+
11
+ - Public package surface and stable sender exports: `src/index.ts` and
12
+ `package.json`
13
+ - Template catalog, preview filenames, and stable sender mapping:
14
+ `EMAIL_TEMPLATE_CATALOG` in `src/index.ts`
15
+ - Send pipeline and Resend transport handoff: `src/index.ts`
16
+ - Package-local contract coverage: `src/__tests__/email-contract.test.ts`
17
+ - React Email-style template surface (`{ subject, preview, render }`):
18
+ `src/templates/index.ts` plus per-template modules under `src/templates/`
19
+ - Per-template body coverage: `src/templates/__tests__/templates.test.ts`
20
+
21
+ ## React Email-style templates
22
+
23
+ Live under `src/templates/`. Each module exports typed `Props`, `subject`,
24
+ `preview`, and `render` plus a default named bundle (e.g. `welcomeEmail`).
25
+
26
+ Currently registered:
27
+
28
+ | File | Catalog id | Send helper |
29
+ | ---- | ---------- | ----------- |
30
+ | `welcome.tsx` | `welcome-react` | `sendWelcomeReactEmail` |
31
+ | `password-reset.tsx` | `password-reset` | `sendPasswordResetEmail` |
32
+ | `invitation.tsx` | `invitation` | `sendInvitationEmail` |
33
+ | `receipt.tsx` | `receipt` | `sendReceiptEmail` |
34
+
35
+ `react-email` / `@react-email/components` is not installed in this workspace.
36
+ The templates are framework-free `.tsx` files that compose plain template
37
+ literals through `src/templates/_layout.ts` (`baseLayout`, `escapeHtml`).
38
+ Migration to React Email is a drop-in replacement of the renderers; the public
39
+ contract (`{ subject, preview, render }`) and `EMAIL_TEMPLATE_CATALOG` entries
40
+ stay stable.
41
+
42
+ `apps/mail-preview/scripts/render-react-templates.ts` materializes these four
43
+ templates into `apps/mail-preview/dist/<file>-email.html` so the existing
44
+ `pnpm --filter mail-preview check` flow finds them.
45
+
46
+ ## Contract Boundaries
47
+
48
+ - Keep template registration centralized through `EMAIL_TEMPLATE_CATALOG`.
49
+ If a template is added, removed, or renamed, update the catalog, exported
50
+ sender surface, preview output, and contract tests in the same change.
51
+ - Do not instantiate delivery providers at import time. No-key preview,
52
+ documentation, and test flows must be able to import `@nebutra/email` without
53
+ `RESEND_API_KEY`.
54
+ - Do not patch rendered preview HTML directly as a source-of-truth change.
55
+ Update the sender/template catalog first, then regenerate or validate preview
56
+ output through `apps/mail-preview`.
57
+ - Preserve the stable caller surface in `src/index.ts`. If send helper params,
58
+ tags, or exported types change, align package exports and tests together.
59
+ - Treat `apps/mail-preview` as a consumer of this package, not a second source
60
+ of truth. Preview/export flows should reflect `EMAIL_TEMPLATE_CATALOG` rather
61
+ than redefining template behavior there.
62
+ - A future React Email extraction is allowed, but it must introduce the real
63
+ files, scripts, and tests in the same change before AGENTS names those paths.
64
+
65
+ ## Generated And Derived Files
66
+
67
+ - `dist/` is build output from `tsup`. Do not hand-edit it.
68
+ - Exported preview artifacts such as `apps/mail-preview/dist/` are derived from
69
+ the templates in this package. Regenerate them instead of editing output.
70
+ - Treat transient preview state, coverage output, and Vitest artifacts as
71
+ derived files.
72
+
73
+ ## Validation
74
+
75
+ - Template, subject, preview text, or registry changes:
76
+ `pnpm --filter @nebutra/email test`
77
+ - Export or type surface changes:
78
+ `pnpm --filter @nebutra/email typecheck`
79
+ - Preview/export workflow changes that affect this package:
80
+ `pnpm mail:check` and, when rendered output matters, `pnpm mail:export`
81
+
82
+ Prefer the smallest meaningful update under `src/__tests__` when changing
83
+ template contracts, sender exports, or delivery behavior.