@huloglobal/vendure-plugin-quotations 0.9.0 → 0.10.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/CHANGELOG.md CHANGED
@@ -5,6 +5,38 @@ documented here. The format follows
5
5
  [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project
6
6
  adheres to [semantic versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.10.0] — 2026-11-16
9
+
10
+ ### Changed
11
+ - **Every e-mail restyled to one shared design:** a 600px white card on a light grey background, the store's
12
+ logo (or its name) over a 3px accent bar, a clear heading, the quote's reference, validity and total in a
13
+ summary box, a button, a "Kind regards" sign-off with the store's reply-to address, and a footer strip with
14
+ the store's address, phone, website and footer note. Inline styles and tables only, every value escaped,
15
+ and every message now has a plain-text part. It uses the existing **Accent colour**, **Logo URL** and
16
+ footer settings, so nothing needs setting up. Restyled: the quote e-mail, test sends (now with a "Test
17
+ send" warning box), the chaser, the expiry reminder (its heading names the date), follow-up steps, the
18
+ pay-link e-mails for the whole amount, a deposit or the balance (the pay button plus a secondary "View
19
+ your quotation" button, and the amount due now), and the request acknowledgement (which had no HTML
20
+ part). Store notifications (new request, first view, accepted, declined) and discount-approval requests
21
+ and outcomes use the same design, more compact; they were plain text. The weekly report uses the shared
22
+ design from the licence SDK 0.15.7 with the store's logo and accent colour.
23
+ - Your own e-mail templates are used as they are: the summary box and button go where the template has the
24
+ quote link on a line of its own (else before its sign-off), and no second sign-off is added when the
25
+ template has one.
26
+ - Default texts: British English, "Kind regards", "e-mail"; the request acknowledgement no longer promises
27
+ a reply "usually within one working day" (nothing in the plugin ensures that). Stored templates are not
28
+ changed.
29
+ - Licence SDK `^0.15.7`; dev dependencies refreshed to the latest minor versions (TypeScript 5.9, Vitest
30
+ 2.1, @types/nodemailer 6.4). Held back: TypeScript 7, Vitest 5 (the monorepo harness pins Vitest 2) and
31
+ @types/nodemailer 8 (the types for nodemailer 8+, while the peer range starts at 6).
32
+
33
+ ### Fixed
34
+ - The plain-text part of the pay-link e-mails had no link (it said "with the button below"); it now carries
35
+ the pay link and the quote link.
36
+ - The public quote page and the accept/decline form are rate limited per client address (120 page views
37
+ and 20 responses a minute; 429 after that), as the PDF download already was.
38
+ - Store notification subjects are kept to one line whatever the requester typed.
39
+
8
40
  ## [0.9.0] — 2026-11-13
9
41
 
10
42
  Parity with HULO Quotations for WordPress (free 0.1.4 and Pro).
package/README.md CHANGED
@@ -109,6 +109,26 @@ const res = await fetch('https://shop.example.com/quotations/my', {
109
109
  Only quotes linked to the customer's account are listed (staff link them with
110
110
  the customer picker); drafts are never shown.
111
111
 
112
+ ## E-mails
113
+
114
+ Every message the plugin sends shares one design: a 600px white card, your
115
+ logo (or business name) over a 3px bar in your accent colour, a heading, the
116
+ quote's reference, validity and total in a summary box, a button, a "Kind
117
+ regards" sign-off with your reply-to address, and a footer strip with your
118
+ address, phone, website and footer note. Inline styles only, with a
119
+ plain-text part. It is set from **Settings** (business name, logo URL, accent
120
+ colour, reply-to, address, phone, website, footer note); nothing extra.
121
+
122
+ - **To customers:** the quote, test sends (marked "Test send"), the chaser,
123
+ the expiry reminder, follow-up steps, pay-link e-mails (whole amount,
124
+ deposit or balance) and the request acknowledgement. Your subject and body
125
+ templates are used as written; the summary box and button go where the
126
+ body has `{{quoteUrl}}` on a line of its own, else before your sign-off.
127
+ - **To your team (compact):** new request, first view, accepted, declined,
128
+ approval requested, approved or not.
129
+ - **Weekly report:** the licence SDK's report layout with your logo and
130
+ accent colour.
131
+
112
132
  ## PDF
113
133
 
114
134
  `GET /quotations/quote/:token/pdf` (the customer link, rate-limited, never
@@ -0,0 +1,104 @@
1
+ /**
2
+ * One e-mail design for every message Quotations sends: a 600px white card
3
+ * on a light grey background, the store's logo (or name) over a 3px accent
4
+ * bar, a 22px heading, body text, info and warning boxes, buttons, a
5
+ * "Kind regards" sign-off and a small footer strip with the store's own
6
+ * details. Inline styles and tables only (some senders strip <style>), every
7
+ * interpolated value escaped. Each message also gets a plain-text part.
8
+ *
9
+ * Pure functions, no I/O: the service builds an EmailDoc and an EmailBrand
10
+ * and sends the html and text it gets back.
11
+ */
12
+ export interface EmailBrand {
13
+ /** shown as the header when there is no logo, and in the sign-off */
14
+ storeName: string;
15
+ /** absolute https URL of the store's logo */
16
+ logoUrl?: string;
17
+ /** accent colour (#rrggbb); anything else falls back to the default */
18
+ accent?: string;
19
+ /** shown under the sign-off when set */
20
+ supportEmail?: string;
21
+ /** the store's own footer text (address, phone, website, legal note), one item per line */
22
+ footerLines?: string[];
23
+ }
24
+ export interface EmailButton {
25
+ url: string;
26
+ label: string;
27
+ }
28
+ export type EmailBlock =
29
+ /** A paragraph of plain text: escaped, line breaks kept, bare URLs linked. `textOnly` keeps it out of the HTML. */
30
+ {
31
+ type: 'p';
32
+ text: string;
33
+ textOnly?: boolean;
34
+ label?: string;
35
+ }
36
+ /** A grey info box: a row of label/value columns (`columns`) and/or label/value rows. */
37
+ | {
38
+ type: 'info';
39
+ title?: string;
40
+ columns?: EmailField[];
41
+ rows?: EmailField[];
42
+ }
43
+ /** An amber warning box. */
44
+ | {
45
+ type: 'warn';
46
+ title?: string;
47
+ text: string;
48
+ }
49
+ /** A primary (accent) button and an optional secondary (outlined) one. */
50
+ | {
51
+ type: 'buttons';
52
+ primary?: EmailButton;
53
+ secondary?: EmailButton;
54
+ }
55
+ /** A small uppercase label over a bulleted list. */
56
+ | {
57
+ type: 'list';
58
+ title?: string;
59
+ items: string[];
60
+ };
61
+ export interface EmailField {
62
+ label: string;
63
+ value: string;
64
+ mono?: boolean;
65
+ }
66
+ export interface EmailDoc {
67
+ /** hidden preview line shown by mail clients after the subject */
68
+ preheader?: string;
69
+ heading: string;
70
+ blocks: EmailBlock[];
71
+ /**
72
+ * 'auto' (default): "Kind regards," + the store name, unless the body
73
+ * already ends with a sign-off of its own (merchant templates usually do).
74
+ * 'none': no sign-off (staff notifications). A string: that name instead
75
+ * of the store name.
76
+ */
77
+ signOff?: 'auto' | 'none' | {
78
+ name: string;
79
+ };
80
+ /** tighter spacing and no sign-off: store and staff notifications */
81
+ compact?: boolean;
82
+ }
83
+ export declare const DEFAULT_ACCENT = "#155dfc";
84
+ export declare function esc(s: unknown): string;
85
+ /** A #rgb / #rrggbb colour, else the default (the value lands in a style attribute). */
86
+ export declare function safeAccent(c: unknown): string;
87
+ /** Only absolute http(s) URLs reach an href or src. */
88
+ export declare function safeUrl(u: unknown): string;
89
+ export declare function isSignOff(text: string): boolean;
90
+ /** True when one of the last two text paragraphs is a sign-off. */
91
+ export declare function hasOwnSignOff(blocks: EmailBlock[]): boolean;
92
+ /** Split a plain-text template body into paragraph blocks (blank line = new paragraph). */
93
+ export declare function paragraphs(body: string, opts?: {
94
+ textOnlyIf?: (p: string) => boolean;
95
+ }): EmailBlock[];
96
+ /** The HTML part. */
97
+ export declare function renderEmailHtml(doc: EmailDoc, brand: EmailBrand): string;
98
+ /** The plain-text part: the same content, readable without HTML. */
99
+ export declare function renderEmailText(doc: EmailDoc, brand: EmailBrand): string;
100
+ export declare function renderEmail(doc: EmailDoc, brand: EmailBrand): {
101
+ html: string;
102
+ text: string;
103
+ };
104
+ //# sourceMappingURL=email-layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email-layout.d.ts","sourceRoot":"","sources":["../src/email-layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,UAAU;IACvB,qEAAqE;IACrE,SAAS,EAAE,MAAM,CAAC;IAClB,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2FAA2F;IAC3F,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,WAAW;IAAG,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,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AIxC,wBAAgB,GAAG,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAEtC;AAED,wFAAwF;AACxF,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAG7C;AAED,uDAAuD;AACvD,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAG1C;AAqBD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE/C;AAED,mEAAmE;AACnE,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAG3D;AAED,2FAA2F;AAC3F,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE;IAAE,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAA;CAAO,GAAG,UAAU,EAAE,CAIzG;AAiED,qBAAqB;AACrB,wBAAgB,eAAe,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAyCxE;AAED,oEAAoE;AACpE,wBAAgB,eAAe,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CA0CxE;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAE5F"}
@@ -0,0 +1,250 @@
1
+ "use strict";
2
+ /**
3
+ * One e-mail design for every message Quotations sends: a 600px white card
4
+ * on a light grey background, the store's logo (or name) over a 3px accent
5
+ * bar, a 22px heading, body text, info and warning boxes, buttons, a
6
+ * "Kind regards" sign-off and a small footer strip with the store's own
7
+ * details. Inline styles and tables only (some senders strip <style>), every
8
+ * interpolated value escaped. Each message also gets a plain-text part.
9
+ *
10
+ * Pure functions, no I/O: the service builds an EmailDoc and an EmailBrand
11
+ * and sends the html and text it gets back.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.DEFAULT_ACCENT = void 0;
15
+ exports.esc = esc;
16
+ exports.safeAccent = safeAccent;
17
+ exports.safeUrl = safeUrl;
18
+ exports.isSignOff = isSignOff;
19
+ exports.hasOwnSignOff = hasOwnSignOff;
20
+ exports.paragraphs = paragraphs;
21
+ exports.renderEmailHtml = renderEmailHtml;
22
+ exports.renderEmailText = renderEmailText;
23
+ exports.renderEmail = renderEmail;
24
+ exports.DEFAULT_ACCENT = '#155dfc';
25
+ const MONO = "Consolas,Menlo,Monaco,'Courier New',monospace";
26
+ const FONT = 'Arial,Helvetica,sans-serif';
27
+ function esc(s) {
28
+ return String(s !== null && s !== void 0 ? s : '').replace(/[&<>"']/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
29
+ }
30
+ /** A #rgb / #rrggbb colour, else the default (the value lands in a style attribute). */
31
+ function safeAccent(c) {
32
+ const v = String(c !== null && c !== void 0 ? c : '').trim();
33
+ return /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(v) ? v : exports.DEFAULT_ACCENT;
34
+ }
35
+ /** Only absolute http(s) URLs reach an href or src. */
36
+ function safeUrl(u) {
37
+ const v = String(u !== null && u !== void 0 ? u : '').trim();
38
+ return /^https?:\/\/[^\s"'<>]+$/i.test(v) ? v : '';
39
+ }
40
+ /** Escape, keep line breaks, and turn bare http(s) URLs into links. */
41
+ function richText(text, accent) {
42
+ const parts = String(text !== null && text !== void 0 ? text : '').split(/(https?:\/\/[^\s<>"']+)/g);
43
+ return parts.map((p, i) => {
44
+ if (i % 2 === 1) {
45
+ // Trailing sentence punctuation is not part of the link.
46
+ const m = /^(.*?)([.,;:!?)]*)$/.exec(p);
47
+ const url = safeUrl(m[1]);
48
+ return url
49
+ ? `<a href="${esc(url)}" style="color:${accent};text-decoration:underline;word-break:break-all">${esc(m[1])}</a>${esc(m[2])}`
50
+ : esc(p);
51
+ }
52
+ return esc(p);
53
+ }).join('').replace(/\r?\n/g, '<br>');
54
+ }
55
+ /** A paragraph whose first line is a closing such as "Kind regards," or "Many thanks". */
56
+ const SIGN_OFF_LINE = /^(?:(?:kind|best|warm|warmest|with kind)\s+)?(?:regards|wishes)[,.!]?$|^(?:many\s+)?thanks(?:\s+again)?[,.!]?$|^thank\s+you[,.!]?$|^cheers[,.!]?$|^best[,.!]?$|^all the best[,.!]?$|^yours(?:\s+(?:sincerely|faithfully|truly))?[,.!]?$|^(?:sincerely|faithfully)[,.!]?$/i;
57
+ function isSignOff(text) {
58
+ return SIGN_OFF_LINE.test(String(text !== null && text !== void 0 ? text : '').trim().split(/\r?\n/)[0].trim());
59
+ }
60
+ /** True when one of the last two text paragraphs is a sign-off. */
61
+ function hasOwnSignOff(blocks) {
62
+ const ps = blocks.filter((b) => b.type === 'p').slice(-2);
63
+ return ps.some(p => isSignOff(p.text));
64
+ }
65
+ /** Split a plain-text template body into paragraph blocks (blank line = new paragraph). */
66
+ function paragraphs(body, opts = {}) {
67
+ return String(body !== null && body !== void 0 ? body : '').replace(/\r\n?/g, '\n').split(/\n\s*\n/)
68
+ .map(p => p.trim()).filter(Boolean)
69
+ .map(p => { var _a; return ({ type: 'p', text: p, textOnly: ((_a = opts.textOnlyIf) === null || _a === void 0 ? void 0 : _a.call(opts, p)) || undefined }); });
70
+ }
71
+ function fieldValue(f, big = false) {
72
+ const style = `font-size:${big ? 16 : 14}px;color:#111827;font-weight:bold;${f.mono ? `font-family:${MONO};` : ''}`;
73
+ return `<span style="${style}">${esc(f.value)}</span>`;
74
+ }
75
+ const LABEL = `font-size:12px;line-height:16px;color:#6b7280;text-transform:uppercase;letter-spacing:1px;font-weight:bold;font-family:${FONT}`;
76
+ function blockHtml(b, accent, compact) {
77
+ const gap = compact ? 12 : 16;
78
+ switch (b.type) {
79
+ case 'p':
80
+ if (b.textOnly)
81
+ return '';
82
+ return `<tr><td style="padding:0 0 ${gap - 2}px 0;font-family:${FONT};font-size:14px;line-height:22px;color:#374151">` +
83
+ (b.label ? `<div style="${LABEL};padding-bottom:4px">${esc(b.label)}</div>` : '') + `${richText(b.text, accent)}</td></tr>`;
84
+ case 'info': {
85
+ const cols = (b.columns || []).filter(f => f.value !== '');
86
+ const rows = (b.rows || []).filter(f => f.value !== '');
87
+ if (!cols.length && !rows.length)
88
+ return '';
89
+ const inner = [];
90
+ if (b.title)
91
+ inner.push(`<div style="${LABEL};padding-bottom:6px">${esc(b.title)}</div>`);
92
+ if (cols.length) {
93
+ inner.push(`<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse"><tr>` +
94
+ cols.map((f, i) => `<td${i === cols.length - 1 && cols.length > 1 ? ' align="right"' : ''} style="${LABEL};padding:0 0 4px 0">${esc(f.label)}</td>`).join('') +
95
+ `</tr><tr>` +
96
+ cols.map((f, i) => `<td${i === cols.length - 1 && cols.length > 1 ? ' align="right"' : ''} style="font-family:${FONT};vertical-align:top">${fieldValue(f, i === cols.length - 1 && cols.length > 1)}</td>`).join('') +
97
+ `</tr></table>`);
98
+ }
99
+ if (rows.length) {
100
+ inner.push(`<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse${cols.length ? ';margin-top:10px;border-top:1px solid #e5e7eb' : ''}">` +
101
+ rows.map(f => `<tr><td style="padding:4px 12px 4px 0;font-family:${FONT};font-size:14px;line-height:20px;color:#6b7280;vertical-align:top;white-space:nowrap">${esc(f.label)}</td>` +
102
+ `<td align="right" style="padding:4px 0;font-family:${f.mono ? MONO : FONT};font-size:14px;line-height:20px;color:#111827;font-weight:bold;vertical-align:top">${esc(f.value).replace(/\r?\n/g, '<br>')}</td></tr>`).join('') +
103
+ `</table>`);
104
+ }
105
+ return `<tr><td style="padding:0 0 ${gap}px 0"><table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="border-collapse:separate">` +
106
+ `<tr><td style="padding:14px 16px;background-color:#f9fafb;border:1px solid #e5e7eb;border-radius:8px">${inner.join('')}</td></tr></table></td></tr>`;
107
+ }
108
+ case 'warn':
109
+ return `<tr><td style="padding:0 0 ${gap}px 0"><table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="border-collapse:separate">` +
110
+ `<tr><td style="padding:14px 16px;background-color:#fffbeb;border:1px solid #fde68a;border-radius:8px;font-family:${FONT}">` +
111
+ (b.title ? `<div style="font-size:15px;font-weight:bold;color:#92400e;padding-bottom:4px">${esc(b.title)}</div>` : '') +
112
+ `<div style="font-size:13px;line-height:20px;color:#78350f">${richText(b.text, '#92400e')}</div></td></tr></table></td></tr>`;
113
+ case 'buttons': {
114
+ const p = b.primary && safeUrl(b.primary.url) ? b.primary : null;
115
+ const s = b.secondary && safeUrl(b.secondary.url) ? b.secondary : null;
116
+ if (!p && !s)
117
+ return '';
118
+ const cell = (btn, primary) => `<td style="border-radius:8px;background-color:${primary ? accent : '#ffffff'};border:2px solid ${accent}">` +
119
+ `<a href="${esc(safeUrl(btn.url))}" style="display:inline-block;padding:${primary ? '12px 24px' : '12px 20px'};font-family:${FONT};font-size:15px;line-height:20px;font-weight:bold;color:${primary ? '#ffffff' : accent};text-decoration:none;border-radius:8px">${esc(btn.label)}</a></td>`;
120
+ const cells = [p ? cell(p, true) : '', p && s ? '<td style="width:10px;font-size:0;line-height:0">&nbsp;</td>' : '', s ? cell(s, !p) : ''].join('');
121
+ return `<tr><td style="padding:${compact ? 2 : 6}px 0 ${gap + 4}px 0"><table role="presentation" cellpadding="0" cellspacing="0" border="0" style="border-collapse:separate"><tr>${cells}</tr></table></td></tr>`;
122
+ }
123
+ case 'list': {
124
+ const items = b.items.filter(Boolean);
125
+ if (!items.length)
126
+ return '';
127
+ return `<tr><td style="padding:0 0 ${gap}px 0;font-family:${FONT}">` +
128
+ (b.title ? `<div style="${LABEL};padding-bottom:6px">${esc(b.title)}</div>` : '') +
129
+ items.map(i => `<div style="font-size:14px;line-height:22px;color:#374151;padding:0 0 4px 0">&bull;&nbsp;${richText(i, accent)}</div>`).join('') +
130
+ `</td></tr>`;
131
+ }
132
+ }
133
+ return '';
134
+ }
135
+ /** The HTML part. */
136
+ function renderEmailHtml(doc, brand) {
137
+ var _a;
138
+ const accent = safeAccent(brand.accent);
139
+ const compact = !!doc.compact;
140
+ const pad = compact ? '20px 24px' : '28px 28px';
141
+ const storeName = String(brand.storeName || '').trim();
142
+ const logo = safeUrl(brand.logoUrl);
143
+ const header = logo
144
+ ? `<img src="${esc(logo)}" alt="${esc(storeName)}" width="140" style="display:block;width:140px;max-width:100%;height:auto;border:0;outline:none;text-decoration:none">`
145
+ : `<span style="font-family:${FONT};font-size:18px;line-height:24px;font-weight:bold;color:#111827">${esc(storeName)}</span>`;
146
+ const blocks = doc.blocks.map(b => blockHtml(b, accent, compact)).join('');
147
+ const mode = (_a = doc.signOff) !== null && _a !== void 0 ? _a : (compact ? 'none' : 'auto');
148
+ const support = brand.supportEmail && /^[^\s@<>"]+@[^\s@<>"]+\.[^\s@<>"]+$/.test(brand.supportEmail) ? brand.supportEmail : '';
149
+ let sign = '';
150
+ if (mode !== 'none') {
151
+ const name = typeof mode === 'object' ? mode.name : storeName;
152
+ const own = mode === 'auto' && hasOwnSignOff(doc.blocks);
153
+ const lines = [];
154
+ if (!own) {
155
+ lines.push(`<div style="padding:0 0 4px 0">Kind regards,</div>`);
156
+ if (name)
157
+ lines.push(`<div style="font-weight:bold;color:#111827">${esc(name)}</div>`);
158
+ }
159
+ if (support)
160
+ lines.push(`<div><a href="mailto:${esc(support)}" style="color:${accent};text-decoration:none">${esc(support)}</a></div>`);
161
+ if (lines.length)
162
+ sign = `<tr><td style="padding:${own ? 0 : 6}px 0 0 0;font-family:${FONT};font-size:14px;line-height:22px;color:#374151">${lines.join('')}</td></tr>`;
163
+ }
164
+ const footerLines = (brand.footerLines || []).map(l => String(l || '').trim()).filter(Boolean);
165
+ const footer = footerLines.length
166
+ ? `<tr><td style="padding:14px 28px;background-color:#f9fafb;border-top:1px solid #e5e7eb;border-radius:0 0 10px 10px;font-family:${FONT};font-size:11px;line-height:16px;color:#6b7280">${footerLines.map(l => richText(l, '#374151')).join('<br>')}</td></tr>`
167
+ : '';
168
+ const preheader = doc.preheader
169
+ ? `<div style="display:none;max-height:0;overflow:hidden;mso-hide:all;font-size:1px;line-height:1px;color:#f3f4f6;opacity:0">${esc(doc.preheader)}</div>`
170
+ : '';
171
+ return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="x-apple-disable-message-reformatting"><title>${esc(doc.heading)}</title></head>` +
172
+ `<body style="margin:0;padding:0;background-color:#f3f4f6;font-family:${FONT}">${preheader}` +
173
+ `<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color:#f3f4f6;border-collapse:collapse"><tr><td align="center" style="padding:24px 12px">` +
174
+ `<table role="presentation" width="600" cellpadding="0" cellspacing="0" border="0" style="width:100%;max-width:600px;background-color:#ffffff;border:1px solid #e5e7eb;border-radius:10px;border-collapse:separate">` +
175
+ `<tr><td style="padding:${compact ? '16px 24px' : '22px 28px'};border-bottom:3px solid ${accent}">${header}</td></tr>` +
176
+ `<tr><td style="padding:${pad}"><table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse">` +
177
+ `<tr><td style="padding:0 0 ${compact ? 10 : 12}px 0;font-family:${FONT};font-size:${compact ? 18 : 22}px;line-height:${compact ? 24 : 28}px;font-weight:bold;color:#111827">${esc(doc.heading)}</td></tr>` +
178
+ blocks + sign +
179
+ `</table></td></tr>` + footer +
180
+ `</table></td></tr></table></body></html>`;
181
+ }
182
+ /** The plain-text part: the same content, readable without HTML. */
183
+ function renderEmailText(doc, brand) {
184
+ var _a;
185
+ const out = [];
186
+ const texts = doc.blocks.filter(b => b.type === 'p').map(b => b.text).join('\n');
187
+ out.push(doc.heading, '');
188
+ for (const b of doc.blocks) {
189
+ switch (b.type) {
190
+ case 'p':
191
+ if (b.label)
192
+ out.push(b.label.toUpperCase());
193
+ out.push(b.text, '');
194
+ break;
195
+ case 'info': {
196
+ const fields = [...(b.columns || []), ...(b.rows || [])].filter(f => f.value !== '');
197
+ if (!fields.length)
198
+ break;
199
+ if (b.title)
200
+ out.push(b.title.toUpperCase());
201
+ for (const f of fields)
202
+ out.push(`${f.label}: ${f.value.replace(/\r?\n/g, '\n ')}`);
203
+ out.push('');
204
+ break;
205
+ }
206
+ case 'warn':
207
+ out.push(b.title ? `${b.title}: ${b.text}` : b.text, '');
208
+ break;
209
+ case 'buttons':
210
+ for (const btn of [b.primary, b.secondary]) {
211
+ const url = btn && safeUrl(btn.url);
212
+ // A link the body already prints is not repeated.
213
+ if (btn && url && !texts.includes(url))
214
+ out.push(`${btn.label}: ${url}`);
215
+ }
216
+ if (out[out.length - 1] !== '')
217
+ out.push('');
218
+ break;
219
+ case 'list':
220
+ if (!b.items.length)
221
+ break;
222
+ if (b.title)
223
+ out.push(b.title.toUpperCase());
224
+ for (const i of b.items)
225
+ out.push(`- ${i}`);
226
+ out.push('');
227
+ break;
228
+ }
229
+ }
230
+ const mode = (_a = doc.signOff) !== null && _a !== void 0 ? _a : (doc.compact ? 'none' : 'auto');
231
+ if (mode !== 'none') {
232
+ const name = typeof mode === 'object' ? mode.name : String(brand.storeName || '').trim();
233
+ if (!(mode === 'auto' && hasOwnSignOff(doc.blocks))) {
234
+ out.push('Kind regards,');
235
+ if (name)
236
+ out.push(name);
237
+ }
238
+ if (brand.supportEmail)
239
+ out.push(brand.supportEmail);
240
+ out.push('');
241
+ }
242
+ const footer = (brand.footerLines || []).map(l => String(l || '').trim()).filter(Boolean);
243
+ if (footer.length)
244
+ out.push('--', ...footer);
245
+ return out.join('\n').replace(/\n{3,}/g, '\n\n').trim() + '\n';
246
+ }
247
+ function renderEmail(doc, brand) {
248
+ return { html: renderEmailHtml(doc, brand), text: renderEmailText(doc, brand) };
249
+ }
250
+ //# sourceMappingURL=email-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email-layout.js","sourceRoot":"","sources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AM,MAAM,GAAG,CAAC,KAAK,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC1F,IAAI,MAAM,CAAC,MAAM;QAAE,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,MAAM,CAAC,CAAC;IAC7C,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC;AACnE,CAAC;AAED,SAAgB,WAAW,CAAC,GAAa,EAAE,KAAiB;IACxD,OAAO,EAAE,IAAI,EAAE,eAAe,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,IAAI,EAAE,eAAe,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC;AACpF,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { QuoteChannelConfig } from './types';
2
+ import { EmailBrand, EmailButton, EmailField } from './email-layout';
3
+ export declare function fmtLongDate(d: any): string;
4
+ /** The store's look and details, from the channel's Quotations settings. */
5
+ export declare function brandOf(cfg: Partial<QuoteChannelConfig>): EmailBrand;
6
+ export type CustomerKind = 'quote' | 'chaser' | 'expiry' | 'followup' | 'pay-deposit' | 'pay-balance' | 'pay-full' | 'custom';
7
+ export interface CustomerMailInput {
8
+ q: any;
9
+ cfg: QuoteChannelConfig;
10
+ kind: CustomerKind;
11
+ /** the body template, already rendered (placeholders filled) */
12
+ body: string;
13
+ quoteUrl: string;
14
+ test?: boolean;
15
+ /** a pay link (pay-* kinds) */
16
+ button?: EmailButton;
17
+ /** what the pay link pays now */
18
+ amountDue?: string;
19
+ }
20
+ /**
21
+ * A customer e-mail about a quote: the merchant's template text, with the
22
+ * quote's summary box and button placed where the template had the link
23
+ * (else before its sign-off, else at the end).
24
+ */
25
+ export declare function customerQuoteMail(i: CustomerMailInput): {
26
+ html: string;
27
+ text: string;
28
+ };
29
+ /** The acknowledgement a customer gets when their quote request lands. */
30
+ export declare function requestAckMail(q: any, cfg: QuoteChannelConfig, body: string): {
31
+ html: string;
32
+ text: string;
33
+ };
34
+ /** A compact note to the store or a member of staff. */
35
+ export declare function staffMail(cfg: Partial<QuoteChannelConfig> | null, opts: {
36
+ heading: string;
37
+ intro?: string;
38
+ rows?: EmailField[];
39
+ list?: {
40
+ title?: string;
41
+ items: string[];
42
+ };
43
+ note?: {
44
+ title?: string;
45
+ text: string;
46
+ };
47
+ warn?: {
48
+ title?: string;
49
+ text: string;
50
+ };
51
+ button?: EmailButton;
52
+ outro?: string;
53
+ }): {
54
+ html: string;
55
+ text: string;
56
+ };
57
+ //# sourceMappingURL=emails.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emails.d.ts","sourceRoot":"","sources":["../src/emails.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAc,UAAU,EAAE,WAAW,EAAY,UAAU,EAAqD,MAAM,gBAAgB,CAAC;AAE9I,wBAAgB,WAAW,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAI1C;AAED,4EAA4E;AAC5E,wBAAgB,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,kBAAkB,CAAC,GAAG,UAAU,CAUpE;AAED,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,aAAa,GAAG,aAAa,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE9H,MAAM,WAAW,iBAAiB;IAC9B,CAAC,EAAE,GAAG,CAAC;IACP,GAAG,EAAE,kBAAkB,CAAC;IACxB,IAAI,EAAE,YAAY,CAAC;IACnB,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAA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
3
+ exports.fmtLongDate = fmtLongDate;
4
+ exports.brandOf = brandOf;
5
+ exports.customerQuoteMail = customerQuoteMail;
6
+ exports.requestAckMail = requestAckMail;
7
+ exports.staffMail = staffMail;
8
+ /**
9
+ * The e-mails Quotations sends, as EmailDocs for email-layout.ts. Pure: the
10
+ * service passes in the quote, the channel settings and the rendered
11
+ * template text, and sends the html/text it gets back.
12
+ */
13
+ const pricing_1 = require("./pricing");
14
+ const email_layout_1 = require("./email-layout");
15
+ function fmtLongDate(d) {
16
+ if (!d)
17
+ return '';
18
+ const dt = new Date(d);
19
+ return isNaN(dt.getTime()) ? '' : dt.toLocaleDateString('en-GB', { day: 'numeric', month: 'long', year: 'numeric' });
20
+ }
21
+ /** The store's look and details, from the channel's Quotations settings. */
22
+ function brandOf(cfg) {
23
+ const address = String(cfg.addressText || '').split(/\r?\n/).map(s => s.trim()).filter(Boolean).join(', ');
24
+ const contact = [String(cfg.phone || '').trim(), String(cfg.websiteUrl || '').trim()].filter(Boolean).join(' · ');
25
+ return {
26
+ storeName: String(cfg.businessName || '').trim(),
27
+ logoUrl: cfg.logoUrl || '',
28
+ accent: cfg.accentColor || '',
29
+ supportEmail: String(cfg.replyTo || '').split(',')[0].trim(),
30
+ footerLines: [cfg.businessName ? String(cfg.businessName) : '', address, contact, String(cfg.footerNote || '')].filter(Boolean),
31
+ };
32
+ }
33
+ function headingFor(i) {
34
+ const ref = String(i.q.reference || '');
35
+ switch (i.kind) {
36
+ case 'chaser': return `Your quotation ${ref} is waiting for you`;
37
+ case 'expiry': return i.q.validUntil ? `Your quotation ${ref} expires on ${fmtLongDate(i.q.validUntil)}` : `Your quotation ${ref} expires soon`;
38
+ case 'pay-deposit': return 'Pay your deposit';
39
+ case 'pay-balance': return 'Pay the balance';
40
+ case 'pay-full': return `Pay for quotation ${ref}`;
41
+ default: return `Your quotation ${ref}`;
42
+ }
43
+ }
44
+ /**
45
+ * A customer e-mail about a quote: the merchant's template text, with the
46
+ * quote's summary box and button placed where the template had the link
47
+ * (else before its sign-off, else at the end).
48
+ */
49
+ function customerQuoteMail(i) {
50
+ const { q } = i;
51
+ const money = (0, pricing_1.formatMoney)(Number(q.totalPence || 0), q.currency || 'GBP');
52
+ const isPay = i.kind.startsWith('pay-');
53
+ const primary = isPay && i.button
54
+ ? i.button
55
+ : { url: i.quoteUrl, label: i.kind === 'expiry' ? 'Review and accept your quotation' : 'View and respond to your quotation' };
56
+ const secondary = isPay ? { url: i.quoteUrl, label: 'View your quotation' } : undefined;
57
+ const summary = {
58
+ type: 'info',
59
+ columns: [
60
+ { label: 'Quotation', value: String(q.reference || ''), mono: true },
61
+ { label: 'Valid until', value: isPay ? '' : fmtLongDate(q.validUntil) },
62
+ { label: 'Total', value: money },
63
+ ],
64
+ rows: isPay && i.amountDue ? [{ label: i.kind === 'pay-deposit' ? 'Deposit due now' : i.kind === 'pay-balance' ? 'Balance due now' : 'Due now', value: i.amountDue }] : [],
65
+ };
66
+ const cta = { type: 'buttons', primary, secondary };
67
+ // The paragraph that is only the link becomes the button (the plain text keeps the link).
68
+ const linkOnly = (p) => p === i.quoteUrl || (!!i.button && p === i.button.url);
69
+ const body = (0, email_layout_1.paragraphs)(i.body, { textOnlyIf: linkOnly });
70
+ let at = body.findIndex(b => b.type === 'p' && b.textOnly);
71
+ if (at >= 0)
72
+ at += 1;
73
+ else if ((0, email_layout_1.hasOwnSignOff)(body)) {
74
+ // Before the sign-off paragraph (one of the last two).
75
+ const ps = body.map((b, n) => ({ b, n })).filter(x => x.b.type === 'p');
76
+ const sign = ps.slice(-2).reverse().find(x => (0, email_layout_1.isSignOff)(x.b.text));
77
+ at = sign ? sign.n : body.length;
78
+ }
79
+ else
80
+ at = body.length;
81
+ const blocks = [];
82
+ if (i.test)
83
+ blocks.push({ type: 'warn', title: 'Test send', text: 'This is a test copy of the e-mail your customer receives. The links are live, so do not accept or pay through them.' });
84
+ blocks.push(...body.slice(0, at), summary, cta, ...body.slice(at));
85
+ const doc = {
86
+ heading: headingFor(i),
87
+ preheader: isPay && i.amountDue
88
+ ? `${i.amountDue} due for quotation ${q.reference}.`
89
+ : `Quotation ${q.reference} for ${money}${q.validUntil ? `, valid until ${fmtLongDate(q.validUntil)}` : ''}.`,
90
+ blocks,
91
+ };
92
+ return (0, email_layout_1.renderEmail)(doc, brandOf(i.cfg));
93
+ }
94
+ /** The acknowledgement a customer gets when their quote request lands. */
95
+ function requestAckMail(q, cfg, body) {
96
+ const blocks = (0, email_layout_1.paragraphs)(body);
97
+ const box = { type: 'info', columns: [{ label: 'Your reference', value: String(q.reference || ''), mono: true }] };
98
+ // After the greeting/first paragraph, so the reference stands out.
99
+ blocks.splice(Math.min(1, blocks.length), 0, box);
100
+ return (0, email_layout_1.renderEmail)({ heading: 'We have received your quote request', preheader: `Your reference is ${q.reference}.`, blocks }, brandOf(cfg));
101
+ }
102
+ /** A compact note to the store or a member of staff. */
103
+ function staffMail(cfg, opts) {
104
+ var _a, _b, _c;
105
+ const blocks = [];
106
+ if (opts.intro)
107
+ blocks.push({ type: 'p', text: opts.intro });
108
+ if (opts.warn)
109
+ blocks.push({ type: 'warn', ...opts.warn });
110
+ if ((_a = opts.rows) === null || _a === void 0 ? void 0 : _a.length)
111
+ blocks.push({ type: 'info', rows: opts.rows });
112
+ if ((_b = opts.list) === null || _b === void 0 ? void 0 : _b.items.length)
113
+ blocks.push({ type: 'list', title: opts.list.title, items: opts.list.items });
114
+ if ((_c = opts.note) === null || _c === void 0 ? void 0 : _c.text)
115
+ blocks.push({ type: 'p', label: opts.note.title, text: opts.note.text });
116
+ if (opts.outro)
117
+ blocks.push({ type: 'p', text: opts.outro });
118
+ if (opts.button)
119
+ blocks.push({ type: 'buttons', primary: opts.button });
120
+ const brand = brandOf(cfg || {});
121
+ // Staff notes carry no store footer; the header still shows whose store it is.
122
+ return (0, email_layout_1.renderEmail)({ heading: opts.heading, blocks, compact: true }, { ...brand, footerLines: [], supportEmail: '' });
123
+ }
124
+ //# sourceMappingURL=emails.js.map