@zigordev/email 0.0.0-stage → 1.25.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 CHANGED
@@ -1,3 +1,95 @@
1
- # Temporary Holding Version
1
+ # @zigordev/email
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The emails of the platform's apps: messages built with React Email on the design tokens, rendered into finished HTML and plain text when the app builds, and filled in with their values when the app sends them. Every message exists in English and Spanish.
4
+
5
+ ## What it is
6
+
7
+ Two entries, for two moments:
8
+
9
+ | Entry | When it runs | What it holds |
10
+ | ----------------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
11
+ | `@zigordev/email/build` | When the app builds | `EmailLayout`, `EmailHeading`, `EmailText`, `EmailButton` and `EmailFooter` on the tokens, `theme`, and `renderTemplate` |
12
+ | `@zigordev/email` | When the app sends | `fillEmail(template, values)`, and the standard messages ready to fill, starting with `verifyEmail({ lang, product, link })` |
13
+
14
+ A template is a subject, the HTML and the plain text of one message in one language, with places to fill written as `{{name}}`. React Email is a library that writes emails as React components and turns them into the old-fashioned HTML that mail clients read.
15
+
16
+ ## Why we have it
17
+
18
+ Every product sends email, starting with the message that confirms an address at sign-up. Each message has to look like the brand, read well in every mail client, and exist in both languages. Without the package, each product would write its own HTML for mail clients, and each would get a different part of it wrong.
19
+
20
+ [Record 0047](../../docs/adr/0047-emails-are-rendered-at-build-and-filled-in-at-send.md) explains the two moments. React Email costs a running service about 46 MB of memory and 176 ms to load, measured on 2026-11-25, and an API container has 256 MB. So React Email runs only when an app builds, and the running service fills in strings.
21
+
22
+ ## How it works here
23
+
24
+ ```mermaid
25
+ flowchart LR
26
+ components["Components on the tokens"] --> render["renderTemplate, when the app builds"]
27
+ render --> saved["src/generated: HTML, text and subject, with {{places}}"]
28
+ saved --> fill["fillEmail, when the app sends"]
29
+ fill --> email["The finished email, handed to the notifications service"]
30
+ ```
31
+
32
+ - **The theme.** The emails wear the light mode of the tokens: the page, the raised card, the text, the lavender button and the 4 px and 6 px corners. Many mail clients read colours only as hexadecimal, so Lightning CSS turns each colour of the tokens into that form, into `src/generated/theme.ts`.
33
+ - **The render.** `renderTemplate(element, subject)` gives the HTML and the plain text of a message. Headings keep their case in the plain text, so a place such as `{{name}}` in a heading survives. A message whose plain text would lose a place fails to render.
34
+ - **The saved copies.** An app commits its rendered templates in `src/generated/`, and a test renders them again and fails when they differ. The package does the same for its own messages, in both languages.
35
+ - **The fill.** `fillEmail` puts each value in its places. In the HTML each value is escaped, so a name cannot add markup. A link must start with `https://` or `http://`. A missing value, or a value with no place, fails the send.
36
+
37
+ Nothing differs between the laptop and production: the same saved templates are filled in both.
38
+
39
+ ## How to use it
40
+
41
+ Sending a standard message takes the send entry only:
42
+
43
+ ```ts
44
+ import { verifyEmail } from '@zigordev/email';
45
+
46
+ const email = verifyEmail({ lang: 'es', product: 'Notes', link: confirmationUrl });
47
+ await addToOutbox(tx, { topic, event: emailRequested, data: { to, ...email } });
48
+ ```
49
+
50
+ A product's own message is a component, rendered at build. Add React Email as a dev dependency:
51
+
52
+ ```bash
53
+ pnpm add @zigordev/email
54
+ pnpm add --save-dev react-email react react-dom
55
+ ```
56
+
57
+ ```ts
58
+ import { createElement as h } from 'react';
59
+ import {
60
+ EmailButton,
61
+ EmailHeading,
62
+ EmailLayout,
63
+ EmailText,
64
+ renderTemplate,
65
+ } from '@zigordev/email/build';
66
+
67
+ export const noteShared = {
68
+ en: await renderTemplate(
69
+ h(
70
+ EmailLayout,
71
+ { lang: 'en', preview: '{{name}} shared a note with you' },
72
+ h(EmailHeading, null, '{{name}} shared a note with you'),
73
+ h(EmailText, null, 'Open it to read it and to add your own lines.'),
74
+ h(EmailButton, { href: '{{link}}' }, 'Open the note')
75
+ ),
76
+ 'A note from {{name}}'
77
+ ),
78
+ };
79
+ ```
80
+
81
+ A script of the app writes such templates into its `src/generated/`, and a test compares them with a fresh render. At send time the app fills them:
82
+
83
+ ```ts
84
+ import { fillEmail } from '@zigordev/email';
85
+ import { noteShared } from './generated/emails.ts';
86
+
87
+ const email = fillEmail(noteShared[lang], { name: owner.name, link });
88
+ ```
89
+
90
+ ## How to check that it works
91
+
92
+ - `pnpm exec vitest run --project email` in `toolkit` renders the standard messages in English and Spanish and compares them with their saved copies, checks the theme against the tokens, and fills the templates.
93
+ - When the saved copies differ after a change of React Email or of the tokens, `pnpm --dir packages/email run generate` renders them again. Read the difference before you commit it.
94
+ - When a send fails with `The email needs a value for ...`, the code passes fewer values than the template has places. `placeholdersOf(template)` lists them.
95
+ - To see a message, write its `html` to a file and open it in a browser, or send it to Mailpit on the laptop.
@@ -0,0 +1,10 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { EmailTemplate, StandardTemplates } from './fill.ts';
3
+ export { EmailButton, EmailFooter, EmailHeading, EmailLayout, type EmailLayoutProps, EmailText, } from './components.ts';
4
+ export type { EmailTemplate, Language, StandardTemplates } from './fill.ts';
5
+ export { languages } from './fill.ts';
6
+ export { theme } from './generated/theme.ts';
7
+ export type { EmailTheme } from './theme.ts';
8
+ export declare function renderTemplate(element: ReactElement, subject: string): Promise<EmailTemplate>;
9
+ export declare function renderStandardMessages(): Promise<StandardTemplates>;
10
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAE9D,OAAO,KAAK,EAAE,aAAa,EAAY,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAI5E,OAAO,EACL,WAAW,EACX,WAAW,EACX,YAAY,EACZ,WAAW,EACX,KAAK,gBAAgB,EACrB,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAO7C,wBAAsB,cAAc,CAClC,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,aAAa,CAAC,CAcxB;AAED,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,iBAAiB,CAAC,CASzE"}
package/dist/build.js ADDED
@@ -0,0 +1,32 @@
1
+ import { createElement as h } from 'react';
2
+ import { render } from 'react-email';
3
+ import { languages, placeholdersOf } from './fill.js';
4
+ import { VerifyEmail, verifyEmailTexts } from './messages/verify-email.js';
5
+ export { EmailButton, EmailFooter, EmailHeading, EmailLayout, EmailText, } from './components.js';
6
+ export { languages } from './fill.js';
7
+ export { theme } from './generated/theme.js';
8
+ const headings = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].map((selector) => ({
9
+ selector,
10
+ options: { uppercase: false },
11
+ }));
12
+ export async function renderTemplate(element, subject) {
13
+ const html = await render(element);
14
+ const text = await render(element, {
15
+ plainText: true,
16
+ htmlToTextOptions: { selectors: headings },
17
+ });
18
+ const inText = placeholdersOf({ subject: '', html: '', text });
19
+ const lost = placeholdersOf({ subject: '', html, text: '' }).filter((name) => !inText.includes(name));
20
+ if (lost.length > 0) {
21
+ throw new Error(`The plain text of the email lost the places for ${lost.join(', ')}`);
22
+ }
23
+ return { subject, html, text };
24
+ }
25
+ export async function renderStandardMessages() {
26
+ const verifyEmail = {};
27
+ for (const lang of languages) {
28
+ verifyEmail[lang] = await renderTemplate(h(VerifyEmail, { lang }), verifyEmailTexts[lang].subject);
29
+ }
30
+ return { verifyEmail };
31
+ }
32
+ //# sourceMappingURL=build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,CAAC,EAAqB,MAAM,OA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IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,mDAAmD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACjC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,sBAAsB;IAC1C,MAAM,WAAW,GAAG,EAAqC,CAAC;IAC1D,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;QAC7B,WAAW,CAAC,IAAI,CAAC,GAAG,MAAM,cAAc,CACtC,CAAC,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC,EACxB,gBAAgB,CAAC,IAAI,CAAC,CAAC,OAAO,CAC/B,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,WAAW,EAAE,CAAC;AACzB,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { type ReactElement, type ReactNode } from 'react';
2
+ export interface EmailLayoutProps {
3
+ readonly lang?: string;
4
+ readonly preview?: string;
5
+ readonly footer?: ReactNode;
6
+ readonly children?: ReactNode;
7
+ }
8
+ export declare function EmailLayout({ lang, preview, footer, children, }: EmailLayoutProps): ReactElement;
9
+ export declare function EmailHeading({ children }: {
10
+ readonly children?: ReactNode;
11
+ }): ReactElement;
12
+ export declare function EmailText({ children, tone, }: {
13
+ readonly children?: ReactNode;
14
+ readonly tone?: 'default' | 'muted';
15
+ }): ReactElement;
16
+ export declare function EmailButton({ href, children, }: {
17
+ readonly href: string;
18
+ readonly children?: ReactNode;
19
+ }): ReactElement;
20
+ export declare function EmailFooter({ children }: {
21
+ readonly children?: ReactNode;
22
+ }): ReactElement;
23
+ //# sourceMappingURL=components.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../src/components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAe9E,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;CAC/B;AAED,wBAAgB,WAAW,CAAC,EAC1B,IAAW,EACX,OAAO,EACP,MAAM,EACN,QAAQ,GACT,EAAE,gBAAgB,GAAG,YAAY,CAyCjC;AAED,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,GAAG,YAAY,CAc1F;AAED,wBAAgB,SAAS,CAAC,EACxB,QAAQ,EACR,IAAgB,GACjB,EAAE;IACD,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;CACrC,GAAG,YAAY,CAaf;AAED,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,QAAQ,GACT,EAAE;IACD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;CAC/B,GAAG,YAAY,CAkBf;AAED,wBAAgB,WAAW,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,GAAG,YAAY,CAoBzF"}
@@ -0,0 +1,75 @@
1
+ import { createElement as h } from 'react';
2
+ import { Body, Button, Container, Head, Heading, Hr, Html, Preview, Section, Text, } from 'react-email';
3
+ import { theme } from './generated/theme.js';
4
+ export function EmailLayout({ lang = 'en', preview, footer, children, }) {
5
+ return h(Html, { lang, dir: 'ltr' }, h(Head), preview === undefined ? null : h(Preview, null, preview), h(Body, {
6
+ style: {
7
+ margin: 0,
8
+ backgroundColor: theme.colors.page,
9
+ color: theme.colors.text,
10
+ fontFamily: theme.font,
11
+ },
12
+ }, h(Container, {
13
+ style: {
14
+ maxWidth: theme.width,
15
+ margin: '0 auto',
16
+ padding: `${theme.space.lg} ${theme.space.md}`,
17
+ },
18
+ }, h(Section, {
19
+ style: {
20
+ backgroundColor: theme.colors.raised,
21
+ border: `1px solid ${theme.colors.border}`,
22
+ borderRadius: theme.radius.card,
23
+ padding: theme.space.lg,
24
+ },
25
+ }, children), footer)));
26
+ }
27
+ export function EmailHeading({ children }) {
28
+ return h(Heading, {
29
+ as: 'h1',
30
+ style: {
31
+ margin: `0 0 ${theme.space.md}`,
32
+ color: theme.colors.text,
33
+ fontSize: theme.fontSize.xl,
34
+ lineHeight: '1.3',
35
+ },
36
+ }, children);
37
+ }
38
+ export function EmailText({ children, tone = 'default', }) {
39
+ return h(Text, {
40
+ style: {
41
+ margin: `0 0 ${theme.space.md}`,
42
+ color: tone === 'muted' ? theme.colors.muted : theme.colors.text,
43
+ fontSize: theme.fontSize.md,
44
+ lineHeight: '1.5',
45
+ },
46
+ }, children);
47
+ }
48
+ export function EmailButton({ href, children, }) {
49
+ return h(Button, {
50
+ href,
51
+ style: {
52
+ display: 'inline-block',
53
+ padding: `${theme.space.sm} ${theme.space.md}`,
54
+ borderRadius: theme.radius.button,
55
+ backgroundColor: theme.colors.accent,
56
+ color: theme.colors.accentOn,
57
+ fontSize: theme.fontSize.md,
58
+ fontWeight: 600,
59
+ textDecoration: 'none',
60
+ },
61
+ }, children);
62
+ }
63
+ export function EmailFooter({ children }) {
64
+ return h('div', null, h(Hr, {
65
+ style: { margin: `${theme.space.lg} 0 ${theme.space.md}`, borderColor: theme.colors.border },
66
+ }), h(Text, {
67
+ style: {
68
+ margin: 0,
69
+ color: theme.colors.muted,
70
+ fontSize: theme.fontSize.sm,
71
+ textAlign: 'center',
72
+ },
73
+ }, children));
74
+ }
75
+ //# sourceMappingURL=components.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,CAAC,EAAqC,MAAM,OAAO,CAAC;AAC9E,OAAO,EACL,IAAI,EACJ,MAAM,EACN,SAAS,EACT,IAAI,EACJ,OAAO,EACP,EAAE,EACF,IAAI,EACJ,OAAO,EACP,OAAO,EACP,IAAI,GACL,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAS7C,MAAM,UAAU,WAAW,CAAC,EAC1B,IAAI,GAAG,IAAI,EACX,OAAO,EACP,MAAM,EACN,QAAQ,GACS;IACjB,OAAO,CAAC,CACN,IAAI,EACJ,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,EACpB,CAAC,CAAC,IAAI,CAAC,EACP,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,EACxD,CAAC,CACC,IAAI,EACJ;QACE,KAAK,EAAE;YACL,MAAM,EAAE,CAAC;YACT,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI;YAClC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI;YACxB,UAAU,EAAE,KAAK,CAAC,IAAI;SACvB;KACF,EACD,CAAC,CACC,SAAS,EACT;QACE,KAAK,EAAE;YACL,QAAQ,EAAE,KAAK,CAAC,KAAK;YACrB,MAAM,EAAE,QAAQ;YAChB,OAAO,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE;SAC/C;KACF,EACD,CAAC,CACC,OAAO,EACP;QACE,KAAK,EAAE;YACL,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM;YACpC,MAAM,EAAE,aAAa,KAAK,CAAC,MAAM,CAAC,MAAM,EA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AAC,MAAM,CAAC,MAAM;YACjC,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM;YACpC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ;YAC5B,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE;YAC3B,UAAU,EAAE,GAAG;YACf,cAAc,EAAE,MAAM;SACvB;KACF,EACD,QAAQ,CACT,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,EAAE,QAAQ,EAAqC;IACzE,OAAO,CAAC,CACN,KAAK,EACL,IAAI,EACJ,CAAC,CAAC,EAAE,EAAE;QACJ,KAAK,EAAE,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE;KAC7F,CAAC,EACF,CAAC,CACC,IAAI,EACJ;QACE,KAAK,EAAE;YACL,MAAM,EAAE,CAAC;YACT,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK;YACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE;YAC3B,SAAS,EAAE,QAAQ;SACpB;KACF,EACD,QAAQ,CACT,CACF,CAAC;AACJ,CAAC"}
package/dist/fill.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ export declare const languages: readonly ['en', 'es'];
2
+ export type Language = (typeof languages)[number];
3
+ export interface EmailTemplate {
4
+ readonly subject: string;
5
+ readonly html: string;
6
+ readonly text: string;
7
+ }
8
+ export type Email = EmailTemplate;
9
+ export type StandardTemplates = Record<'verifyEmail', Record<Language, EmailTemplate>>;
10
+ export declare function placeholdersOf(template: EmailTemplate): string[];
11
+ export declare function fillEmail(template: EmailTemplate, values: Readonly<Record<string, string>>): Email;
12
+ //# sourceMappingURL=fill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fill.d.ts","sourceRoot":"","sources":["../src/fill.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,YAAI,IAAI,EAAE,IAAI,CAAU,CAAC;AAE/C,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAElD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,KAAK,GAAG,aAAa,CAAC;AAElC,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC;AAavF,wBAAgB,cAAc,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,EAAE,CAQhE;AAED,wBAAgB,SAAS,CACvB,QAAQ,EAAE,aAAa,EACvB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GACvC,KAAK,CAqBP"}
package/dist/fill.js ADDED
@@ -0,0 +1,41 @@
1
+ export const languages = ['en', 'es'];
2
+ const placeholder = /\{\{([a-z][a-zA-Z0-9]*)\}\}/g;
3
+ function escapeHtml(value) {
4
+ return value
5
+ .replaceAll('&', '&amp;')
6
+ .replaceAll('<', '&lt;')
7
+ .replaceAll('>', '&gt;')
8
+ .replaceAll('"', '&quot;')
9
+ .replaceAll("'", '&#39;');
10
+ }
11
+ export function placeholdersOf(template) {
12
+ const names = new Set();
13
+ for (const part of [template.subject, template.html, template.text]) {
14
+ for (const [, name = ''] of part.matchAll(placeholder)) {
15
+ names.add(name);
16
+ }
17
+ }
18
+ return [...names].sort();
19
+ }
20
+ export function fillEmail(template, values) {
21
+ const asked = placeholdersOf(template);
22
+ const missing = asked.filter((name) => values[name] === undefined);
23
+ if (missing.length > 0) {
24
+ throw new Error(`The email needs a value for ${missing.join(', ')}`);
25
+ }
26
+ const extra = Object.keys(values).filter((name) => !asked.includes(name));
27
+ if (extra.length > 0) {
28
+ throw new Error(`The email has no place for ${extra.join(', ')}`);
29
+ }
30
+ const link = values.link;
31
+ if (link !== undefined && !/^https?:\/\//.test(link)) {
32
+ throw new Error('The link of an email starts with https:// or http://');
33
+ }
34
+ const fill = (text, encode) => text.replace(placeholder, (_, name) => encode(values[name] ?? ''));
35
+ return {
36
+ subject: fill(template.subject, (value) => value),
37
+ html: fill(template.html, escapeHtml),
38
+ text: fill(template.text, (value) => value),
39
+ };
40
+ }
41
+ //# sourceMappingURL=fill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fill.js","sourceRoot":"","sources":["../src/fill.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,IAAI,CAAU,CAAC;AAc/C,MAAM,WAAW,GAAG,8BAA8B,CAAC;AAEnD,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,KAAK;SACT,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;SACxB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;SACvB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;SACvB,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC;SACzB,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,QAAuB;IACpD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,KAAK,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACpE,KAAK,MAAM,CAAC,EAAE,IAAI,GAAG,EAAE,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YACvD,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC;IACH,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,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC;QACjD,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;QACrC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC;KAC5C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { StandardTemplates } from '../fill.ts';
2
+ export declare const messages: StandardTemplates;
3
+ //# sourceMappingURL=messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/generated/messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,eAAO,MAAM,QAAQ,EAAE,iBAatB,CAAC"}
@@ -0,0 +1,15 @@
1
+ export const messages = {
2
+ "verifyEmail": {
3
+ "en": {
4
+ "subject": "Confirm your email address for {{product}}",
5
+ "html": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html dir=\"ltr\" lang=\"en\"><head><meta content=\"text/html; charset=UTF-8\" http-equiv=\"Content-Type\"/><meta name=\"x-apple-disable-message-reformatting\"/><title>One step to finish signing up to {{product}}</title></head><body dir=\"ltr\" lang=\"en\" style=\"background-color:#f8f9fa;margin:0\"><!--$--><!--html--><!--head--><div style=\"display:none;overflow:hidden;line-height:1px;opacity:0;max-height:0;max-width:0\" data-skip-in-text=\"true\">One step to finish signing up to {{product}}<div> ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍</div></div><!--body--><table border=\"0\" width=\"100%\" cellPadding=\"0\" cellSpacing=\"0\" role=\"presentation\" align=\"center\"><tbody><tr><td dir=\"ltr\" lang=\"en\" style=\"margin:0;background-color:#f8f9fa;color:#1f282a;font-family:&quot;Mona Sans Variable&quot;, &quot;Mona Sans&quot;, system-ui, -apple-system, &quot;Segoe UI&quot;, &quot;Roboto&quot;, sans-serif\"><table align=\"center\" width=\"100%\" border=\"0\" cellPadding=\"0\" cellSpacing=\"0\" role=\"presentation\" style=\"max-width:640px;margin:0 auto\"><tbody><tr style=\"width:100%\"><td style=\"padding:32px 16px\"><table align=\"center\" width=\"100%\" border=\"0\" cellPadding=\"0\" cellSpacing=\"0\" role=\"presentation\" style=\"background-color:#fcfdfd;border:1px solid #d4dcdd;border-radius:6px\"><tbody><tr><td style=\"padding:32px\"><h1 style=\"margin:0 0 16px;color:#1f282a;font-size:20px;line-height:1.3\">Confirm your email address</h1><p style=\"font-size:15px;line-height:1.5;margin:0 0 16px;color:#1f282a;margin-top:0;margin-right:0;margin-bottom:16px;margin-left:0\">Select the button to confirm that this address is yours, and finish signing up to {{product}}.</p><a href=\"{{link}}\" style=\"line-height:100%;text-decoration:none;display:inline-block;max-width:100%;mso-padding-alt:0px;padding:8px 16px;border-radius:4px;background-color:#b7a1f5;color:#0b181c;font-size:15px;font-weight:600;padding-top:8px;padding-right:16px;padding-bottom:8px;padding-left:16px\" target=\"_blank\"><span><!--[if mso]><i style=\"mso-font-width:400%;mso-text-raise:12px\" hidden>&#8202;&#8202;</i><![endif]--></span><span style=\"max-width:100%;display:inline-block;line-height:120%;mso-padding-alt:0px;mso-text-raise:6px\">Confirm email address</span><span><!--[if mso]><i style=\"mso-font-width:400%\" hidden>&#8202;&#8202;&#8203;</i><![endif]--></span></a></td></tr></tbody></table><div><hr style=\"width:100%;border:none;border-color:#d4dcdd;border-top:1px solid #eaeaea;margin:32px 0 16px\"/><p style=\"font-size:13px;line-height:24px;margin:0;color:#5f7074;text-align:center;margin-top:0;margin-bottom:0;margin-left:0;margin-right:0\">If you did not ask for this, you can ignore this email.</p></div></td></tr></tbody></table></td></tr></tbody></table><!--/$--></body></html>",
6
+ "text": "Confirm your email address\n\nSelect the button to confirm that this address is yours, and finish signing up to {{product}}.\n\nConfirm email address {{link}}\n\n----------------------------------------\n\nIf you did not ask for this, you can ignore this email."
7
+ },
8
+ "es": {
9
+ "subject": "Confirma tu dirección de correo para {{product}}",
10
+ "html": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html dir=\"ltr\" lang=\"es\"><head><meta content=\"text/html; charset=UTF-8\" http-equiv=\"Content-Type\"/><meta name=\"x-apple-disable-message-reformatting\"/><title>Un paso para terminar de registrarte en {{product}}</title></head><body dir=\"ltr\" lang=\"en\" style=\"background-color:#f8f9fa;margin:0\"><!--$--><!--html--><!--head--><div style=\"display:none;overflow:hidden;line-height:1px;opacity:0;max-height:0;max-width:0\" data-skip-in-text=\"true\">Un paso para terminar de registrarte en {{product}}<div> ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍ ‌​‍</div></div><!--body--><table border=\"0\" width=\"100%\" cellPadding=\"0\" cellSpacing=\"0\" role=\"presentation\" align=\"center\"><tbody><tr><td dir=\"ltr\" lang=\"en\" style=\"margin:0;background-color:#f8f9fa;color:#1f282a;font-family:&quot;Mona Sans Variable&quot;, &quot;Mona Sans&quot;, system-ui, -apple-system, &quot;Segoe UI&quot;, &quot;Roboto&quot;, sans-serif\"><table align=\"center\" width=\"100%\" border=\"0\" cellPadding=\"0\" cellSpacing=\"0\" role=\"presentation\" style=\"max-width:640px;margin:0 auto\"><tbody><tr style=\"width:100%\"><td style=\"padding:32px 16px\"><table align=\"center\" width=\"100%\" border=\"0\" cellPadding=\"0\" cellSpacing=\"0\" role=\"presentation\" style=\"background-color:#fcfdfd;border:1px solid #d4dcdd;border-radius:6px\"><tbody><tr><td style=\"padding:32px\"><h1 style=\"margin:0 0 16px;color:#1f282a;font-size:20px;line-height:1.3\">Confirma tu dirección de correo</h1><p style=\"font-size:15px;line-height:1.5;margin:0 0 16px;color:#1f282a;margin-top:0;margin-right:0;margin-bottom:16px;margin-left:0\">Selecciona el botón para confirmar que esta dirección es tuya y terminar de registrarte en {{product}}.</p><a href=\"{{link}}\" style=\"line-height:100%;text-decoration:none;display:inline-block;max-width:100%;mso-padding-alt:0px;padding:8px 16px;border-radius:4px;background-color:#b7a1f5;color:#0b181c;font-size:15px;font-weight:600;padding-top:8px;padding-right:16px;padding-bottom:8px;padding-left:16px\" target=\"_blank\"><span><!--[if mso]><i style=\"mso-font-width:400%;mso-text-raise:12px\" hidden>&#8202;&#8202;</i><![endif]--></span><span style=\"max-width:100%;display:inline-block;line-height:120%;mso-padding-alt:0px;mso-text-raise:6px\">Confirmar dirección de correo</span><span><!--[if mso]><i style=\"mso-font-width:400%\" hidden>&#8202;&#8202;&#8203;</i><![endif]--></span></a></td></tr></tbody></table><div><hr style=\"width:100%;border:none;border-color:#d4dcdd;border-top:1px solid #eaeaea;margin:32px 0 16px\"/><p style=\"font-size:13px;line-height:24px;margin:0;color:#5f7074;text-align:center;margin-top:0;margin-bottom:0;margin-left:0;margin-right:0\">Si no lo has pedido, puedes ignorar este correo.</p></div></td></tr></tbody></table></td></tr></tbody></table><!--/$--></body></html>",
11
+ "text": "Confirma tu dirección de correo\n\nSelecciona el botón para confirmar que esta dirección es tuya y terminar de registrarte en {{product}}.\n\nConfirmar dirección de correo {{link}}\n\n----------------------------------------\n\nSi no lo has pedido, puedes ignorar este correo."
12
+ }
13
+ }
14
+ };
15
+ //# sourceMappingURL=messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/generated/messages.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAsB;IACzC,aAAa,EAAE;QACb,IAAI,EAAE;YACJ,SAAS,EAAE,4CAA4C;YACvD,MAAM,EAAE,ilHAAilH;YACzlH,MAAM,EAAE,uQAAuQ;SAChR;QACD,IAAI,EAAE;YACJ,SAAS,EAAE,kDAAkD;YAC7D,MAAM,EAAE,2kHAA2kH;YACnlH,MAAM,EAAE,sRAAsR;SAC/R;KACF;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { EmailTheme } from '../theme.ts';
2
+ export declare const theme: EmailTheme;
3
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/generated/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,eAAO,MAAM,KAAK,EAAE,UA2BnB,CAAC"}
@@ -0,0 +1,29 @@
1
+ export const theme = {
2
+ "colors": {
3
+ "page": "#f8f9fa",
4
+ "raised": "#fcfdfd",
5
+ "text": "#1f282a",
6
+ "muted": "#5f7074",
7
+ "border": "#d4dcdd",
8
+ "accent": "#b7a1f5",
9
+ "accentOn": "#0b181c",
10
+ "accentText": "#7562a8"
11
+ },
12
+ "font": "\"Mona Sans Variable\", \"Mona Sans\", system-ui, -apple-system, \"Segoe UI\", \"Roboto\", sans-serif",
13
+ "fontSize": {
14
+ "sm": "13px",
15
+ "md": "15px",
16
+ "xl": "20px"
17
+ },
18
+ "space": {
19
+ "sm": "8px",
20
+ "md": "16px",
21
+ "lg": "32px"
22
+ },
23
+ "radius": {
24
+ "button": "4px",
25
+ "card": "6px"
26
+ },
27
+ "width": "640px"
28
+ };
29
+ //# sourceMappingURL=theme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/generated/theme.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,KAAK,GAAe;IAC/B,QAAQ,EAAE;QACR,MAAM,EAAE,SAAS;QACjB,QAAQ,EAAE,SAAS;QACnB,MAAM,EAAE,SAAS;QACjB,OAAO,EAAE,SAAS;QAClB,QAAQ,EAAE,SAAS;QACnB,QAAQ,EAAE,SAAS;QACnB,UAAU,EAAE,SAAS;QACrB,YAAY,EAAE,SAAS;KACxB;IACD,MAAM,EAAE,uGAAuG;IAC/G,UAAU,EAAE;QACV,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM;KACb;IACD,OAAO,EAAE;QACP,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM;KACb;IACD,QAAQ,EAAE;QACR,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,KAAK;KACd;IACD,OAAO,EAAE,OAAO;CACjB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type Email, type Language } from './fill.ts';
2
+ export type { Email, EmailTemplate, Language, StandardTemplates } from './fill.ts';
3
+ export { fillEmail, languages, placeholdersOf } from './fill.ts';
4
+ export interface VerifyEmailOptions {
5
+ readonly lang: Language;
6
+ readonly product: string;
7
+ readonly link: string;
8
+ }
9
+ export declare function verifyEmail(options: VerifyEmailOptions): Email;
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAa,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGjE,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEjE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,KAAK,CAK9D"}
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ import { fillEmail } from './fill.js';
2
+ import { messages } from './generated/messages.js';
3
+ export { fillEmail, languages, placeholdersOf } from './fill.js';
4
+ export function verifyEmail(options) {
5
+ return fillEmail(messages.verifyEmail[options.lang], {
6
+ product: options.product,
7
+ link: options.link,
8
+ });
9
+ }
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,SAAS,EAAiB,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAGnD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAQjE,MAAM,UAAU,WAAW,CAAC,OAA2B;IACrD,OAAO,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACnD,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { Language } from '../fill.ts';
3
+ export declare const verifyEmailTexts: {
4
+ readonly en: {
5
+ readonly subject: 'Confirm your email address for {{product}}';
6
+ readonly preview: 'One step to finish signing up to {{product}}';
7
+ readonly heading: 'Confirm your email address';
8
+ readonly body: 'Select the button to confirm that this address is yours, and finish signing up to {{product}}.';
9
+ readonly button: 'Confirm email address';
10
+ readonly footer: 'If you did not ask for this, you can ignore this email.';
11
+ };
12
+ readonly es: {
13
+ readonly subject: 'Confirma tu dirección de correo para {{product}}';
14
+ readonly preview: 'Un paso para terminar de registrarte en {{product}}';
15
+ readonly heading: 'Confirma tu dirección de correo';
16
+ readonly body: 'Selecciona el botón para confirmar que esta dirección es tuya y terminar de registrarte en {{product}}.';
17
+ readonly button: 'Confirmar dirección de correo';
18
+ readonly footer: 'Si no lo has pedido, puedes ignorar este correo.';
19
+ };
20
+ };
21
+ export declare function VerifyEmail({ lang }: {
22
+ readonly lang: Language;
23
+ }): ReactElement;
24
+ //# sourceMappingURL=verify-email.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-email.d.ts","sourceRoot":"","sources":["../../src/messages/verify-email.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAE9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,eAAO,MAAM,gBAAgB;;iBAEzB,OAAO,EAAE,4CAA4C;iBACrD,OAAO,EAAE,8CAA8C;iBACvD,OAAO,EAAE,4BAA4B;iBACrC,IAAI,EAAE,gGAAgG;iBACtG,MAAM,EAAE,uBAAuB;iBAC/B,MAAM,EAAE,yDAAyD;;;iBAGjE,OAAO,EAAE,kDAAkD;iBAC3D,OAAO,EAAE,qDAAqD;iBAC9D,OAAO,EAAE,iCAAiC;iBAC1C,IAAI,EAAE,yGAAyG;iBAC/G,MAAM,EAAE,+BAA+B;iBACvC,MAAM,EAAE,kDAAkD;;CAED,CAAC;AAE9D,wBAAgB,WAAW,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GAAG,YAAY,CAS/E"}
@@ -0,0 +1,25 @@
1
+ import { createElement as h } from 'react';
2
+ import { EmailButton, EmailFooter, EmailHeading, EmailLayout, EmailText } from '../components.js';
3
+ export const verifyEmailTexts = {
4
+ en: {
5
+ subject: 'Confirm your email address for {{product}}',
6
+ preview: 'One step to finish signing up to {{product}}',
7
+ heading: 'Confirm your email address',
8
+ body: 'Select the button to confirm that this address is yours, and finish signing up to {{product}}.',
9
+ button: 'Confirm email address',
10
+ footer: 'If you did not ask for this, you can ignore this email.',
11
+ },
12
+ es: {
13
+ subject: 'Confirma tu dirección de correo para {{product}}',
14
+ preview: 'Un paso para terminar de registrarte en {{product}}',
15
+ heading: 'Confirma tu dirección de correo',
16
+ body: 'Selecciona el botón para confirmar que esta dirección es tuya y terminar de registrarte en {{product}}.',
17
+ button: 'Confirmar dirección de correo',
18
+ footer: 'Si no lo has pedido, puedes ignorar este correo.',
19
+ },
20
+ };
21
+ export function VerifyEmail({ lang }) {
22
+ const texts = verifyEmailTexts[lang];
23
+ return h(EmailLayout, { lang, preview: texts.preview, footer: h(EmailFooter, null, texts.footer) }, h(EmailHeading, null, texts.heading), h(EmailText, null, texts.body), h(EmailButton, { href: '{{link}}' }, texts.button));
24
+ }
25
+ //# sourceMappingURL=verify-email.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-email.js","sourceRoot":"","sources":["../../src/messages/verify-email.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,CAAC,EAAqB,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGlG,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,EAAE,EAAE;QACF,OAAO,EAAE,4CAA4C;QACrD,OAAO,EAAE,8CAA8C;QACvD,OAAO,EAAE,4BAA4B;QACrC,IAAI,EAAE,gGAAgG;QACtG,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,yDAAyD;KAClE;IACD,EAAE,EAAE;QACF,OAAO,EAAE,kDAAkD;QAC3D,OAAO,EAAE,qDAAqD;QAC9D,OAAO,EAAE,iCAAiC;QAC1C,IAAI,EAAE,yGAAyG;QAC/G,MAAM,EAAE,+BAA+B;QACvC,MAAM,EAAE,kDAAkD;KAC3D;CAC0D,CAAC;AAE9D,MAAM,UAAU,WAAW,CAAC,EAAE,IAAI,EAA+B;IAC/D,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACrC,OAAO,CAAC,CACN,WAAW,EACX,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,WAAW,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,EAC5E,CAAC,CAAC,YAAY,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,EACpC,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,EAC9B,CAAC,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC,CACnD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,29 @@
1
+ export interface EmailTheme {
2
+ readonly colors: {
3
+ readonly page: string;
4
+ readonly raised: string;
5
+ readonly text: string;
6
+ readonly muted: string;
7
+ readonly border: string;
8
+ readonly accent: string;
9
+ readonly accentOn: string;
10
+ readonly accentText: string;
11
+ };
12
+ readonly font: string;
13
+ readonly fontSize: {
14
+ readonly sm: string;
15
+ readonly md: string;
16
+ readonly xl: string;
17
+ };
18
+ readonly space: {
19
+ readonly sm: string;
20
+ readonly md: string;
21
+ readonly lg: string;
22
+ };
23
+ readonly radius: {
24
+ readonly button: string;
25
+ readonly card: string;
26
+ };
27
+ readonly width: string;
28
+ }
29
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE;QACf,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;KAC7B,CAAC;IACF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IACrF,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IAClF,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACpE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB"}
package/dist/theme.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=theme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.js","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,65 @@
1
1
  {
2
2
  "name": "@zigordev/email",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.25.0",
4
+ "description": "The emails of zigordev apps: messages rendered with React Email on the design tokens when an app builds, and filled in at send time",
5
+ "license": "UNLICENSED",
6
+ "type": "module",
7
+ "engines": {
8
+ "node": ">=26"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.js"
17
+ },
18
+ "./build": {
19
+ "types": "./dist/build.d.ts",
20
+ "default": "./dist/build.js"
21
+ }
22
+ },
23
+ "peerDependencies": {
24
+ "react": "^19.3.0",
25
+ "react-dom": "^19.3.0",
26
+ "react-email": "^6.11.0"
27
+ },
28
+ "peerDependenciesMeta": {
29
+ "react": {
30
+ "optional": true
31
+ },
32
+ "react-dom": {
33
+ "optional": true
34
+ },
35
+ "react-email": {
36
+ "optional": true
37
+ }
38
+ },
39
+ "devDependencies": {
40
+ "@types/node": "26.6.6",
41
+ "@types/react": "19.3.0",
42
+ "@types/react-dom": "19.3.0",
43
+ "@zigordev/dev": "1.25.0",
44
+ "@zigordev/tokens": "1.25.0",
45
+ "lightningcss": "1.33.0",
46
+ "react": "19.3.1",
47
+ "react-dom": "19.3.1",
48
+ "react-email": "6.11.16",
49
+ "typescript": "7.0.2",
50
+ "vitest": "5.1.1"
51
+ },
52
+ "publishConfig": {
53
+ "access": "public"
54
+ },
55
+ "repository": {
56
+ "type": "git",
57
+ "url": "git+https://github.com/zigordev/toolkit.git",
58
+ "directory": "packages/email"
59
+ },
60
+ "scripts": {
61
+ "build": "tsc -p tsconfig.build.json",
62
+ "typecheck": "tsc -p tsconfig.json",
63
+ "generate": "node scripts/generate-theme.ts"
64
+ }
6
65
  }