@betterinternship/core 2.26.0 → 2.26.2

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.
@@ -0,0 +1,5 @@
1
+ export interface EmailActionOptions {
2
+ href: string;
3
+ label: string;
4
+ }
5
+ export declare const renderEmailAction: ({ href, label }: EmailActionOptions) => string;
@@ -0,0 +1,15 @@
1
+ const escapeHtml = (value) => value
2
+ .replaceAll('&', '&')
3
+ .replaceAll('<', '&lt;')
4
+ .replaceAll('>', '&gt;')
5
+ .replaceAll('"', '&quot;')
6
+ .replaceAll("'", '&#39;');
7
+ export const renderEmailAction = ({ href, label }) => {
8
+ const escapedHref = escapeHtml(href);
9
+ return `<div style="margin:24px 0 0">
10
+ <a href="${escapedHref}" style="display:inline-block;padding:12px 22px;background:#155eef;color:#ffffff;border-radius:8px;text-decoration:none;font-size:14px;font-weight:700">${escapeHtml(label)} →</a>
11
+ <p style="margin:14px 0 0;font-size:12px;line-height:1.5;color:#64748b">Button not working? Copy and paste this link into your browser:</p>
12
+ <p style="margin:5px 0 0;font-size:12px;line-height:1.5;word-break:break-all"><a href="${escapedHref}" style="color:#155eef;text-decoration:underline;word-break:break-all">${escapedHref}</a></p>
13
+ </div>`;
14
+ };
15
+ //# sourceMappingURL=action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action.js","sourceRoot":"","sources":["../../../lib/email/action.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,EAAE,CACnC,KAAK;KACF,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;KACxB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;KACvB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;KACvB,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC;KACzB,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AAG9B,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAsB,EAAE,EAAE;IACvE,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IACrC,OAAO;aACI,WAAW,2JAA2J,UAAU,CAAC,KAAK,CAAC;;2FAEzG,WAAW,0EAA0E,WAAW;OACpL,CAAC;AACR,CAAC,CAAC"}
@@ -1,2 +1,4 @@
1
1
  export * from './email.js';
2
+ export * from './action.js';
3
+ export * from './preview.js';
2
4
  export * from './shell.js';
@@ -1,3 +1,5 @@
1
1
  export * from './email.js';
2
+ export * from './action.js';
3
+ export * from './preview.js';
2
4
  export * from './shell.js';
3
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/email/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/email/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,11 @@
1
+ export interface EmailPreview {
2
+ name: string;
3
+ html: string;
4
+ sourcePath?: string;
5
+ }
6
+ export interface EmailPreviewCatalogOptions {
7
+ title: string;
8
+ previews: EmailPreview[];
9
+ outputDirectory: string;
10
+ }
11
+ export declare const writeEmailPreviewCatalog: ({ title, previews, outputDirectory, }: EmailPreviewCatalogOptions) => string;
@@ -0,0 +1,52 @@
1
+ import { mkdirSync, writeFileSync } from 'fs';
2
+ import { join } from 'path';
3
+ import { spawnSync } from 'child_process';
4
+ const escapeHtml = (value) => value
5
+ .replaceAll('&', '&amp;')
6
+ .replaceAll('<', '&lt;')
7
+ .replaceAll('>', '&gt;')
8
+ .replaceAll('"', '&quot;')
9
+ .replaceAll("'", '&#39;');
10
+ const isModified = (sourcePath) => {
11
+ if (!sourcePath)
12
+ return false;
13
+ const result = spawnSync('git', ['status', '--porcelain', '--', sourcePath], {
14
+ encoding: 'utf8',
15
+ });
16
+ return result.status === 0 && Boolean(result.stdout.trim());
17
+ };
18
+ export const writeEmailPreviewCatalog = ({ title, previews, outputDirectory, }) => {
19
+ mkdirSync(outputDirectory, { recursive: true });
20
+ const catalogItems = previews.map(({ name, html, sourcePath }, index) => {
21
+ const filename = `${String(index + 1).padStart(2, '0')}.html`;
22
+ writeFileSync(join(outputDirectory, filename), html);
23
+ const escapedName = escapeHtml(name);
24
+ const badge = isModified(sourcePath) ? '<span>Updated</span>' : '';
25
+ return `<section><h2>${escapedName}${badge}</h2><iframe src="${filename}" title="${escapedName}"></iframe></section>`;
26
+ });
27
+ const escapedTitle = escapeHtml(title);
28
+ const catalogPath = join(outputDirectory, 'index.html');
29
+ writeFileSync(catalogPath, `<!doctype html>
30
+ <html lang="en">
31
+ <head>
32
+ <meta charset="utf-8" />
33
+ <title>${escapedTitle}</title>
34
+ <style>
35
+ body { margin: 0; padding: 32px; background: #eef2f7; color: #17213d; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
36
+ h1 { margin: 0 0 8px; }
37
+ p { margin: 0 0 32px; color: #5c6880; }
38
+ section { max-width: 680px; margin: 0 auto 36px; }
39
+ h2 { display: flex; align-items: center; gap: 8px; font-size: 16px; margin: 0 0 10px; }
40
+ h2 span { padding: 3px 7px; border-radius: 999px; background: #dbeafe; color: #1d4ed8; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
41
+ iframe { width: 100%; height: 760px; border: 1px solid #d7deea; background: #fff; border-radius: 8px; }
42
+ </style>
43
+ </head>
44
+ <body>
45
+ <h1>${escapedTitle}</h1>
46
+ <p>Generated from the production email factories and their templates.</p>
47
+ ${catalogItems.join('\n ')}
48
+ </body>
49
+ </html>`);
50
+ return catalogPath;
51
+ };
52
+ //# sourceMappingURL=preview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview.js","sourceRoot":"","sources":["../../../lib/email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