@pithy-sh/email 0.1.2 → 0.1.3
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/dist/analytics.d.ts +19 -0
- package/dist/analytics.d.ts.map +1 -0
- package/dist/analytics.js +13 -0
- package/dist/audit/actions.d.ts +45 -0
- package/dist/audit/actions.d.ts.map +1 -0
- package/dist/audit/actions.js +45 -0
- package/dist/bounce/classify.d.ts +38 -0
- package/dist/bounce/classify.d.ts.map +1 -0
- package/dist/bounce/classify.js +46 -0
- package/dist/bounce/handler.d.ts +32 -0
- package/dist/bounce/handler.d.ts.map +1 -0
- package/dist/bounce/handler.js +81 -0
- package/dist/capability.d.ts +158 -0
- package/dist/capability.d.ts.map +1 -0
- package/dist/capability.js +255 -0
- package/dist/crypto/signingKey.d.ts +36 -0
- package/dist/crypto/signingKey.d.ts.map +1 -0
- package/dist/crypto/signingKey.js +36 -0
- package/dist/crypto/token.d.ts +47 -0
- package/dist/crypto/token.d.ts.map +1 -0
- package/dist/crypto/token.js +99 -0
- package/dist/data/emailEvent.d.ts +28 -0
- package/dist/data/emailEvent.d.ts.map +1 -0
- package/dist/data/emailEvent.js +22 -0
- package/dist/data/emailJob.d.ts +76 -0
- package/dist/data/emailJob.d.ts.map +1 -0
- package/dist/data/emailJob.js +62 -0
- package/dist/data/emailSuppression.d.ts +23 -0
- package/dist/data/emailSuppression.d.ts.map +1 -0
- package/dist/data/emailSuppression.js +21 -0
- package/dist/data/enums.d.ts +76 -0
- package/dist/data/enums.d.ts.map +1 -0
- package/dist/data/enums.js +65 -0
- package/dist/data/tables.d.ts +114 -0
- package/dist/data/tables.d.ts.map +1 -0
- package/dist/data/tables.js +30 -0
- package/dist/error/errors.d.ts +60 -0
- package/dist/error/errors.d.ts.map +1 -0
- package/dist/error/errors.js +82 -0
- package/dist/http/callbacks.d.ts +21 -0
- package/dist/http/callbacks.d.ts.map +1 -0
- package/dist/http/callbacks.js +110 -0
- package/dist/http/guards.d.ts +99 -0
- package/dist/http/guards.d.ts.map +1 -0
- package/dist/http/guards.js +144 -0
- package/dist/http/responses.d.ts +295 -0
- package/dist/http/responses.d.ts.map +1 -0
- package/dist/http/responses.js +115 -0
- package/dist/http/routes.d.ts +71 -0
- package/dist/http/routes.d.ts.map +1 -0
- package/dist/http/routes.js +292 -0
- package/dist/http/schemas.d.ts +90 -0
- package/dist/http/schemas.d.ts.map +1 -0
- package/dist/http/schemas.js +91 -0
- package/dist/http/view.d.ts +78 -0
- package/dist/http/view.d.ts.map +1 -0
- package/dist/http/view.js +130 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/jobs/read.d.ts +191 -0
- package/dist/jobs/read.d.ts.map +1 -0
- package/dist/jobs/read.js +143 -0
- package/dist/jobs/retry.d.ts +99 -0
- package/dist/jobs/retry.d.ts.map +1 -0
- package/dist/jobs/retry.js +67 -0
- package/dist/migrations/0001_init.d.ts +32 -0
- package/dist/migrations/0001_init.d.ts.map +1 -0
- package/dist/migrations/0001_init.js +60 -0
- package/dist/migrations/0001_suppressions.d.ts +10 -0
- package/dist/migrations/0001_suppressions.d.ts.map +1 -0
- package/dist/migrations/0001_suppressions.js +20 -0
- package/dist/provision/devDelivery.d.ts +32 -0
- package/dist/provision/devDelivery.d.ts.map +1 -0
- package/dist/provision/devDelivery.js +37 -0
- package/dist/provision/hostCatalogs.d.ts +10 -0
- package/dist/provision/hostCatalogs.d.ts.map +1 -0
- package/dist/provision/hostCatalogs.js +78 -0
- package/dist/provision/provisionEmail.d.ts +143 -0
- package/dist/provision/provisionEmail.d.ts.map +1 -0
- package/dist/provision/provisionEmail.js +118 -0
- package/dist/provision/resolveEmailConfig.d.ts +122 -0
- package/dist/provision/resolveEmailConfig.d.ts.map +1 -0
- package/dist/provision/resolveEmailConfig.js +124 -0
- package/dist/provision/settingsCheck.d.ts +40 -0
- package/dist/provision/settingsCheck.d.ts.map +1 -0
- package/dist/provision/settingsCheck.js +138 -0
- package/dist/send/batchIdentity.d.ts +42 -0
- package/dist/send/batchIdentity.d.ts.map +1 -0
- package/dist/send/batchIdentity.js +46 -0
- package/dist/send/enqueue.d.ts +216 -0
- package/dist/send/enqueue.d.ts.map +1 -0
- package/dist/send/enqueue.js +153 -0
- package/dist/send/errorMapping.d.ts +27 -0
- package/dist/send/errorMapping.d.ts.map +1 -0
- package/dist/send/errorMapping.js +52 -0
- package/dist/send/events.d.ts +15 -0
- package/dist/send/events.d.ts.map +1 -0
- package/dist/send/events.js +17 -0
- package/dist/send/fromComposition.d.ts +47 -0
- package/dist/send/fromComposition.d.ts.map +1 -0
- package/dist/send/fromComposition.js +53 -0
- package/dist/send/retryPolicy.d.ts +32 -0
- package/dist/send/retryPolicy.d.ts.map +1 -0
- package/dist/send/retryPolicy.js +39 -0
- package/dist/send/runSend.d.ts +106 -0
- package/dist/send/runSend.d.ts.map +1 -0
- package/dist/send/runSend.js +218 -0
- package/dist/send/sendAt.d.ts +6 -0
- package/dist/send/sendAt.d.ts.map +1 -0
- package/dist/send/sendAt.js +62 -0
- package/dist/send/sender.d.ts +42 -0
- package/dist/send/sender.d.ts.map +1 -0
- package/dist/send/sender.js +0 -0
- package/dist/send/senderBinding.d.ts +44 -0
- package/dist/send/senderBinding.d.ts.map +1 -0
- package/dist/send/senderBinding.js +21 -0
- package/dist/send/suppression.d.ts +93 -0
- package/dist/send/suppression.d.ts.map +1 -0
- package/dist/send/suppression.js +132 -0
- package/dist/templates/engine.d.ts +109 -0
- package/dist/templates/engine.d.ts.map +1 -0
- package/dist/templates/engine.js +258 -0
- package/dist/templates/messages.d.ts +94 -0
- package/dist/templates/messages.d.ts.map +1 -0
- package/dist/templates/messages.es.d.ts +29 -0
- package/dist/templates/messages.es.d.ts.map +1 -0
- package/dist/templates/messages.es.js +82 -0
- package/dist/templates/messages.js +266 -0
- package/dist/templates/partials.d.ts +5 -0
- package/dist/templates/partials.d.ts.map +1 -0
- package/dist/templates/partials.js +59 -0
- package/dist/templates/precompiled.generated.d.ts +266 -0
- package/dist/templates/precompiled.generated.d.ts.map +1 -0
- package/dist/templates/precompiled.generated.js +4039 -0
- package/dist/templates/registry.d.ts +118 -0
- package/dist/templates/registry.d.ts.map +1 -0
- package/dist/templates/registry.js +323 -0
- package/dist/templates/samples.d.ts +7 -0
- package/dist/templates/samples.d.ts.map +1 -0
- package/dist/templates/samples.js +98 -0
- package/dist/templates/severity.d.ts +40 -0
- package/dist/templates/severity.d.ts.map +1 -0
- package/dist/templates/severity.js +81 -0
- package/dist/templates/theme.d.ts +193 -0
- package/dist/templates/theme.d.ts.map +1 -0
- package/dist/templates/theme.js +168 -0
- package/dist/version.generated.d.ts +5 -0
- package/dist/version.generated.d.ts.map +1 -0
- package/dist/version.generated.js +7 -0
- package/dist/workflows/hostApp.d.ts +33 -0
- package/dist/workflows/hostApp.d.ts.map +1 -0
- package/dist/workflows/hostApp.js +19 -0
- package/dist/workflows/hostEnv.d.ts +129 -0
- package/dist/workflows/hostEnv.d.ts.map +1 -0
- package/dist/workflows/hostEnv.js +147 -0
- package/dist/workflows/instanceLiveness.d.ts +3 -0
- package/dist/workflows/instanceLiveness.d.ts.map +1 -0
- package/dist/workflows/instanceLiveness.js +37 -0
- package/dist/workflows/instances.d.ts +18 -0
- package/dist/workflows/instances.d.ts.map +1 -0
- package/dist/workflows/instances.js +0 -0
- package/dist/workflows/params.d.ts +23 -0
- package/dist/workflows/params.d.ts.map +1 -0
- package/dist/workflows/params.js +21 -0
- package/dist/workflows/scheduler.d.ts +82 -0
- package/dist/workflows/scheduler.d.ts.map +1 -0
- package/dist/workflows/scheduler.js +111 -0
- package/dist/workflows/sendBatch.d.ts +85 -0
- package/dist/workflows/sendBatch.d.ts.map +1 -0
- package/dist/workflows/sendBatch.js +50 -0
- package/dist/workflows/worker.d.ts +100 -0
- package/dist/workflows/worker.d.ts.map +1 -0
- package/dist/workflows/worker.js +117 -0
- package/package.json +22 -11
- package/src/version.generated.ts +1 -1
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { EmailKind, TemplateCategory } from "../data/enums";
|
|
3
|
+
import type { ContentWidth } from "./theme";
|
|
4
|
+
/**
|
|
5
|
+
* The template set. The **typed input contract is the real deliverable**: each template declares a Zod
|
|
6
|
+
* payload schema — its documented, validated variable set — plus a `category` that drives tracking
|
|
7
|
+
* defaults and a `kind` that decides whether the message can be refused. Visual polish is explicitly
|
|
8
|
+
* secondary. Bodies are Handlebars
|
|
9
|
+
* (`{{var}}`, `{{#each}}`, `{{#if}}`) and include the shared `{{> emailHead}}` / `{{> emailFoot}}`
|
|
10
|
+
* partials, so every template inherits the light/dark theme and the Gmail-safe shell; `links` names the
|
|
11
|
+
* URL locations the engine rewrites for click tracking.
|
|
12
|
+
*
|
|
13
|
+
* ## This map is closed to adopters, and that is a decision rather than an omission
|
|
14
|
+
*
|
|
15
|
+
* There is no `registerTemplate`. An adopter composing `email` sends what is in this file, and the
|
|
16
|
+
* argument for that — with what it costs, and what the kit owes in exchange — is in this package's
|
|
17
|
+
* template model at https://pithy.sh/docs/capabilities/email/template-model. The short form is three things, of which the first is not
|
|
18
|
+
* negotiable by design taste:
|
|
19
|
+
*
|
|
20
|
+
* 1. **The Workers runtime forbids code generation**, so a template cannot be compiled where it runs.
|
|
21
|
+
* Every body here is turned into a spec by `scripts/precompile.ts` at build time. Accepting an
|
|
22
|
+
* adopter's template means accepting a *precompiled spec* built by their own Handlebars, and
|
|
23
|
+
* Handlebars refuses a spec whose compiler revision differs from the runtime's — a version skew
|
|
24
|
+
* nobody would see until every email failed to render at once.
|
|
25
|
+
* 2. **The kind would go back to being a claim.** #281's fix rests on a call site being unable to
|
|
26
|
+
* assert that a message is transactional; a registerable template makes that assertion writable
|
|
27
|
+
* again, and the mail it produces ignores an unsubscribe under the adopter's own sending domain.
|
|
28
|
+
* 3. **Escaping is structural here, not conventional.** `testerNudge` and `supportReply` are safe
|
|
29
|
+
* because their bodies are fixed and the words arrive as escaped values. A supplied body with one
|
|
30
|
+
* `{{{triple}}}` is a phishing page sent over the adopter's DKIM signature.
|
|
31
|
+
*
|
|
32
|
+
* What the closure obliges instead: where a shape is missing, the kit adds it, and where the *words*
|
|
33
|
+
* are the adopter's, the template takes them as payload. `supportReply`, `testerNudge` and
|
|
34
|
+
* `operationalNotice` are all that pattern — the kit owns the shell, the caller owns the copy.
|
|
35
|
+
*/
|
|
36
|
+
/** A URL location within a payload that the engine may rewrite to a tracked click callback. A `path`
|
|
37
|
+
* is a top-level key (`"url"`) or an array element field (`"articles[].link"`). */
|
|
38
|
+
export interface LinkSpec {
|
|
39
|
+
/** The payload path to the URL: a key, or `key[].subkey` for each element of an array. */
|
|
40
|
+
path: string;
|
|
41
|
+
/** The link's identity/label, recorded on the click event for attribution. */
|
|
42
|
+
label: string;
|
|
43
|
+
}
|
|
44
|
+
/** One template: its id, category, kind, payload schema, Handlebars sources, and trackable link locations. */
|
|
45
|
+
export interface EmailTemplate {
|
|
46
|
+
/** The template id used to enqueue and render (e.g. `magicLink`). */
|
|
47
|
+
id: string;
|
|
48
|
+
/** What the message is — drives tracking defaults, and makes an unsubscribe link mandatory for `marketing`. */
|
|
49
|
+
category: TemplateCategory;
|
|
50
|
+
/**
|
|
51
|
+
* Whether a recipient may refuse this message.
|
|
52
|
+
*
|
|
53
|
+
* **Required, and declared here rather than passed at the call site.** If "is this transactional" were
|
|
54
|
+
* an argument, a caller could get it wrong, and the failure mode is an account nobody can reach: a
|
|
55
|
+
* magic link sent as elective is a magic link an unrelated unsubscribe silently swallows. Templates
|
|
56
|
+
* are this capability's own — an adopter cannot register one — so declaring the kind on the template
|
|
57
|
+
* makes the wrong thing impossible to write rather than merely discouraged. There is no default, for
|
|
58
|
+
* the same reason: a forgotten field must be a type error, not a silent lockout.
|
|
59
|
+
*/
|
|
60
|
+
kind: EmailKind;
|
|
61
|
+
/** The body width this template renders at — a property of the email type, not the brand theme. */
|
|
62
|
+
width: ContentWidth;
|
|
63
|
+
/** The Zod payload schema — the validated, documented input-variable contract. */
|
|
64
|
+
payload: z.ZodType;
|
|
65
|
+
/** The subject line, as a Handlebars source over the payload + theme. */
|
|
66
|
+
subject: string;
|
|
67
|
+
/** The HTML body, as a Handlebars source including the shared header/footer partials. */
|
|
68
|
+
html: string;
|
|
69
|
+
/** The plain-text body, as a Handlebars source. Always shipped alongside HTML. */
|
|
70
|
+
text: string;
|
|
71
|
+
/** The URL locations the engine rewrites when click tracking is on. */
|
|
72
|
+
links: LinkSpec[];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The operational notice: *something about your own infrastructure changed or needs attention*.
|
|
76
|
+
*
|
|
77
|
+
* **It is not `securityAlert`, and the difference is the whole reason it exists.** That template is
|
|
78
|
+
* about a session — it describes a sign-in and closes with "if this was you, no action is needed",
|
|
79
|
+
* which is the opposite of what an overdue secret or a security release means. This one assumes the
|
|
80
|
+
* recipient is the operator and that the fact is true; there is nothing to confirm, only something to
|
|
81
|
+
* do or to know.
|
|
82
|
+
*
|
|
83
|
+
* **One template rather than one per notice, and one per capability is what it replaces.** A rotation
|
|
84
|
+
* that failed, a release with a security fix, a connection that stopped answering and a job retrying
|
|
85
|
+
* for a day differ only in their words and their urgency. Both of those are payload. What is fixed —
|
|
86
|
+
* the shell, the escaping, the kind, the severity vocabulary — is what the kit is for.
|
|
87
|
+
*
|
|
88
|
+
* The severity is required and has no default. A default would be `info`, and a capability that forgot
|
|
89
|
+
* the field would then send a critical fault at the volume of a newsletter.
|
|
90
|
+
*/
|
|
91
|
+
export declare const OperationalNoticePayload: z.ZodObject<{
|
|
92
|
+
severity: z.ZodEnum<{
|
|
93
|
+
critical: "critical";
|
|
94
|
+
info: "info";
|
|
95
|
+
warning: "warning";
|
|
96
|
+
}>;
|
|
97
|
+
summary: z.ZodString;
|
|
98
|
+
thing: z.ZodString;
|
|
99
|
+
when: z.ZodString;
|
|
100
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
101
|
+
facts: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
102
|
+
label: z.ZodString;
|
|
103
|
+
value: z.ZodString;
|
|
104
|
+
}, z.core.$strip>>>;
|
|
105
|
+
actionUrl: z.ZodOptional<z.ZodString>;
|
|
106
|
+
actionLabel: z.ZodDefault<z.ZodString>;
|
|
107
|
+
}, z.core.$strip>;
|
|
108
|
+
/**
|
|
109
|
+
* `z.input`, not `z.output`: `facts` and `actionLabel` carry defaults, so the parsed shape is the
|
|
110
|
+
* renderer's and this one is the caller's. It is exported because a capability building a notice should
|
|
111
|
+
* be told at compile time that it forgot the severity — the payload reaches `enqueueEmail` as
|
|
112
|
+
* `unknown`, and a Zod failure there is a runtime error in a code path that only runs when something is
|
|
113
|
+
* already wrong.
|
|
114
|
+
*/
|
|
115
|
+
export type OperationalNoticePayload = z.input<typeof OperationalNoticePayload>;
|
|
116
|
+
/** The full template set, keyed by id. */
|
|
117
|
+
export declare const templates: Record<string, EmailTemplate>;
|
|
118
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/templates/registry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH;oFACoF;AACpF,MAAM,WAAW,QAAQ;IACvB,0FAA0F;IAC1F,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAC;CACf;AAED,8GAA8G;AAC9G,MAAM,WAAW,aAAa;IAC5B,qEAAqE;IACrE,EAAE,EAAE,MAAM,CAAC;IACX,+GAA+G;IAC/G,QAAQ,EAAE,gBAAgB,CAAC;IAC3B;;;;;;;;;OASG;IACH,IAAI,EAAE,SAAS,CAAC;IAChB,mGAAmG;IACnG,KAAK,EAAE,YAAY,CAAC;IACpB,kFAAkF;IAClF,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC;IACnB,yEAAyE;IACzE,OAAO,EAAE,MAAM,CAAC;IAChB,yFAAyF;IACzF,IAAI,EAAE,MAAM,CAAC;IACb,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB;AAsJD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;iBA2ClC,CAAC;AACJ;;;;;;GAMG;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAmEhF,0CAA0C;AAC1C,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAwLnD,CAAC"}
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { NoticeSeverity } from "./severity.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/templates/registry.ts
|
|
4
|
+
/** The accent CTA button, with a VML fallback so it renders solid in Outlook. Ink text reads on saffron in both modes. */
|
|
5
|
+
function button(urlVar, label) {
|
|
6
|
+
return `<!--[if mso]><v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="{{${urlVar}}}" style="height:44px;v-text-anchor:middle;width:220px;" arcsize="16%" fillcolor="{{theme.accent}}" stroke="f"><w:anchorlock/><center style="color:#111111;font-family:sans-serif;font-size:14px;font-weight:600;">${label}</center></v:roundrect><![endif]--><!--[if !mso]><!--><a href="{{${urlVar}}}" style="display:inline-block; margin:24px 0; background-color:{{theme.accent}}; color:#111111; font-size:14px; font-weight:600; text-decoration:none; padding:13px 26px; border-radius:8px">${label}</a><!--<![endif]-->`;
|
|
7
|
+
}
|
|
8
|
+
/** A heading in the primary text color (dark-mode aware via the t-ink class). */
|
|
9
|
+
function heading(text) {
|
|
10
|
+
return `<h1 class="t-ink" style="margin:0 0 16px; font-size:22px; font-weight:600; letter-spacing:-0.02em; color:{{theme.light.text}}">${text}</h1>`;
|
|
11
|
+
}
|
|
12
|
+
/** A hairline separator that flips color in dark mode via the sep class. */
|
|
13
|
+
const sep = `<div role="separator" class="sep" style="background-color:{{theme.light.separator}}; height:1px; line-height:1px; margin:28px 0">‍</div>`;
|
|
14
|
+
/** Wrap a body fragment in the shared head/footer partials. */
|
|
15
|
+
function layout(body) {
|
|
16
|
+
return `{{> emailHead}}${body}{{> emailFoot}}`;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The salutation every kit-authored template opens with, named when the payload carries a name.
|
|
20
|
+
*
|
|
21
|
+
* Two catalog keys rather than one sentence with an optional placeholder: a language that greets an
|
|
22
|
+
* unnamed reader differently — not merely with the name deleted — has nowhere to say so otherwise.
|
|
23
|
+
* `{{#if name}}` stays in the template because the *choice* is structural and the *words* are not.
|
|
24
|
+
*/
|
|
25
|
+
const greeting = `{{#if name}}{{t "email/shell.greeting_named" name=name}}{{else}}{{t "email/shell.greeting"}}{{/if}}`;
|
|
26
|
+
const MagicLinkPayload = z.object({
|
|
27
|
+
name: z.string().optional().describe("The recipient's name, for a personal greeting. Optional."),
|
|
28
|
+
url: z.string().describe("The single-use magic sign-in link. Tracked when click tracking is on."),
|
|
29
|
+
expiresMinutes: z.number().int().describe("How many minutes until the link expires, shown to the recipient.")
|
|
30
|
+
}).describe("Inputs for the passwordless magic-link sign-in email.");
|
|
31
|
+
const OtpPayload = z.object({
|
|
32
|
+
name: z.string().optional().describe("The recipient's name, for a personal greeting. Optional."),
|
|
33
|
+
code: z.string().describe("The one-time verification code to display prominently."),
|
|
34
|
+
expiresMinutes: z.number().int().describe("How many minutes until the code expires, shown to the recipient.")
|
|
35
|
+
}).describe("Inputs for the one-time-passcode (OTP) verification email.");
|
|
36
|
+
const WelcomePayload = z.object({
|
|
37
|
+
name: z.string().describe("The new user's name, for the greeting."),
|
|
38
|
+
ctaUrl: z.string().describe("The link to get started (dashboard, onboarding). Tracked when click tracking is on."),
|
|
39
|
+
ctaLabel: z.string().describe("The call-to-action button label, e.g. `Open your dashboard`.")
|
|
40
|
+
}).describe("Inputs for the post-signup welcome email.");
|
|
41
|
+
const SecurityAlertPayload = z.object({
|
|
42
|
+
name: z.string().optional().describe("The recipient's name, for a personal greeting. Optional."),
|
|
43
|
+
event: z.string().describe("A short description of the security event, e.g. `New sign-in from Chrome on macOS`."),
|
|
44
|
+
when: z.string().describe("A human-readable timestamp of the event."),
|
|
45
|
+
ipAddress: z.string().optional().describe("The originating IP address, if known. Optional."),
|
|
46
|
+
actionUrl: z.string().describe("A link to review activity or secure the account. Tracked when click tracking is on.")
|
|
47
|
+
}).describe("Inputs for a security-alert email (new sign-in, settings change, etc.).");
|
|
48
|
+
const InvitePayload = z.object({
|
|
49
|
+
inviterName: z.string().describe("The name of the person who sent the invitation."),
|
|
50
|
+
organizationName: z.string().describe("The team or organization the recipient is invited to."),
|
|
51
|
+
acceptUrl: z.string().describe("The link to accept the invitation. Tracked when click tracking is on.")
|
|
52
|
+
}).describe("Inputs for a team/organization invitation email.");
|
|
53
|
+
/**
|
|
54
|
+
* The one template `@pithy-sh/testers` sends everything through — invitations, confirmations, and every
|
|
55
|
+
* nudge kind.
|
|
56
|
+
*
|
|
57
|
+
* **`paragraphs` is an array of plain strings, and that is the security boundary.** A control-plane
|
|
58
|
+
* caller may supply the words of a nudge, and those words go out over the adopter's own DKIM signature
|
|
59
|
+
* to the adopter's own users. Rendering them through `{{this}}` means Handlebars escapes every one of
|
|
60
|
+
* them, so supplied markup arrives as visible text rather than as markup — structurally, not because a
|
|
61
|
+
* filter guessed right about what to strip. A single `body` string with `{{{triple}}}` interpolation
|
|
62
|
+
* would turn a leaked dashboard credential into a phishing platform running from a trusted domain.
|
|
63
|
+
*
|
|
64
|
+
* One template rather than one per nudge kind, because the kinds differ only in their words, and the
|
|
65
|
+
* words are the half this template deliberately does not own.
|
|
66
|
+
*/
|
|
67
|
+
const TesterNudgePayload = z.object({
|
|
68
|
+
subject: z.string().describe("The subject line. Bounded and stripped of control characters by the testers capability before it arrives."),
|
|
69
|
+
heading: z.string().describe("The email's heading. Always supplied by the testers capability, never by a caller."),
|
|
70
|
+
paragraphs: z.array(z.string()).describe("The body, as one plain string per paragraph. Each renders HTML-escaped, which is what makes caller-supplied copy safe to send over the adopter's own sending domain."),
|
|
71
|
+
ctaUrl: z.string().optional().describe("The confirmation link, when the message carries one. Tracked when click tracking is on."),
|
|
72
|
+
ctaLabel: z.string().optional().describe("The button label. Only rendered when `ctaUrl` is present."),
|
|
73
|
+
footnote: z.string().optional().describe("A closing line in muted type — used for the honesty note about who actually decides the test's outcome."),
|
|
74
|
+
optOutUrl: z.string().optional().describe("The tester's own way out, rendered as a footer link. Transactional mail carries no unsubscribe by default, but a testing program asks one person for something repeatedly over a fortnight, so someone being chased must be able to stop it."),
|
|
75
|
+
optOutLabel: z.string().optional().describe("The wording of that link. Supplied by the capability, never by a caller. Only rendered with `optOutUrl`.")
|
|
76
|
+
}).describe("Inputs for a testing-cohort invitation, confirmation, or nudge. The words may be supplied; the shell never is.");
|
|
77
|
+
const PasswordChangedPayload = z.object({
|
|
78
|
+
name: z.string().optional().describe("The recipient's name, for a personal greeting. Optional."),
|
|
79
|
+
when: z.string().describe("A human-readable timestamp of when the credential changed."),
|
|
80
|
+
supportUrl: z.string().describe("A link to contact support if the change was not the recipient. Tracked when click tracking is on.")
|
|
81
|
+
}).describe("Inputs for the account-credential-changed security notice.");
|
|
82
|
+
/** One labeled fact in an operational notice — what makes the notice specific rather than a mood. */
|
|
83
|
+
const OperationalNoticeFact = z.object({
|
|
84
|
+
label: z.string().describe("What this fact is: `Environment`, `Last rotated`, `Version`, `Owner`."),
|
|
85
|
+
value: z.string().describe("The fact itself, as text. Rendered HTML-escaped — it is a value read off a system, never markup.")
|
|
86
|
+
}).describe("One label/value row in an operational notice's fact table.");
|
|
87
|
+
/**
|
|
88
|
+
* The operational notice: *something about your own infrastructure changed or needs attention*.
|
|
89
|
+
*
|
|
90
|
+
* **It is not `securityAlert`, and the difference is the whole reason it exists.** That template is
|
|
91
|
+
* about a session — it describes a sign-in and closes with "if this was you, no action is needed",
|
|
92
|
+
* which is the opposite of what an overdue secret or a security release means. This one assumes the
|
|
93
|
+
* recipient is the operator and that the fact is true; there is nothing to confirm, only something to
|
|
94
|
+
* do or to know.
|
|
95
|
+
*
|
|
96
|
+
* **One template rather than one per notice, and one per capability is what it replaces.** A rotation
|
|
97
|
+
* that failed, a release with a security fix, a connection that stopped answering and a job retrying
|
|
98
|
+
* for a day differ only in their words and their urgency. Both of those are payload. What is fixed —
|
|
99
|
+
* the shell, the escaping, the kind, the severity vocabulary — is what the kit is for.
|
|
100
|
+
*
|
|
101
|
+
* The severity is required and has no default. A default would be `info`, and a capability that forgot
|
|
102
|
+
* the field would then send a critical fault at the volume of a newsletter.
|
|
103
|
+
*/
|
|
104
|
+
const OperationalNoticePayload = z.object({
|
|
105
|
+
severity: NoticeSeverity.describe("How urgent this is. Sets the subject-line label (`Notice:` / `Action needed:` / `Critical:`), so the level is visible in the inbox before the message is opened."),
|
|
106
|
+
summary: z.string().describe("What happened, in one line. It is the subject after the severity label, and the heading in the body."),
|
|
107
|
+
thing: z.string().describe("What it happened to, named the way an operator would recognize it: `STRIPE_SECRET_KEY`, `@pithy-sh/auth`, `acme-prod-db`. A notice that does not name its subject cannot be acted on."),
|
|
108
|
+
when: z.string().describe("When it happened, human-readable (`2 hours ago`, `18 June, 14:02 UTC`). Formatted by the caller, who knows the recipient's locale and whether an exact time matters."),
|
|
109
|
+
detail: z.string().optional().describe("One paragraph explaining what it means or what to do. Rendered HTML-escaped as a single block. Optional — the summary and the facts already stand alone."),
|
|
110
|
+
facts: z.array(OperationalNoticeFact).default([]).describe("Supporting facts as label/value rows — version, environment, last success, owner. Empty renders nothing at all rather than an empty table."),
|
|
111
|
+
actionUrl: z.string().optional().describe("The one place this can be acted on. Optional, because a caller with nowhere to send somebody would otherwise invent a link, and a dead link in a critical notice is worse than none. Tracked when click tracking is on."),
|
|
112
|
+
actionLabel: z.string().default("Open").describe("The button's words. Only rendered alongside `actionUrl`; defaults to a plain `Open`.")
|
|
113
|
+
}).describe("Inputs for an operational notice — what happened, to what, when, how serious, and one place to act on it.");
|
|
114
|
+
const NewsletterArticle = z.object({
|
|
115
|
+
title: z.string().describe("The article headline."),
|
|
116
|
+
summary: z.string().describe("A one- or two-sentence summary shown under the headline."),
|
|
117
|
+
link: z.string().describe("The link to the full article. Tracked when click tracking is on."),
|
|
118
|
+
featureImage: z.string().optional().describe("An absolute URL of a header image for the article. Optional.")
|
|
119
|
+
}).describe("One article block in a newsletter's iterable list.");
|
|
120
|
+
const NewsletterPayload = z.object({
|
|
121
|
+
subject: z.string().describe("The newsletter subject line."),
|
|
122
|
+
intro: z.string().describe("The opening paragraph above the article list."),
|
|
123
|
+
articles: z.array(NewsletterArticle).describe("The iterable list of article blocks rendered with `{{#each}}`."),
|
|
124
|
+
outro: z.string().optional().describe("An optional closing paragraph below the article list.")
|
|
125
|
+
}).describe("Inputs for the newsletter email — opening copy plus an iterable list of articles.");
|
|
126
|
+
const LeadCapturePayload = z.object({
|
|
127
|
+
name: z.string().optional().describe("The lead's name, for a personal greeting. Optional."),
|
|
128
|
+
assetName: z.string().describe("The name of the downloadable asset, e.g. `The 2026 Backend Playbook`."),
|
|
129
|
+
assetUrl: z.string().describe("The link to download the asset. Tracked when click tracking is on."),
|
|
130
|
+
message: z.string().optional().describe("An optional custom message above the download link.")
|
|
131
|
+
}).describe("Inputs for the lead-capture delivery email (a notice with a link to a downloadable asset).");
|
|
132
|
+
const MarketingCampaignPayload = z.object({
|
|
133
|
+
subject: z.string().describe("The campaign subject line."),
|
|
134
|
+
heading: z.string().describe("The headline at the top of the body."),
|
|
135
|
+
body: z.string().describe("The main campaign copy. Plain text rendered into a paragraph."),
|
|
136
|
+
ctaUrl: z.string().describe("The campaign call-to-action link. Tracked when click tracking is on."),
|
|
137
|
+
ctaLabel: z.string().describe("The call-to-action button label.")
|
|
138
|
+
}).describe("Inputs for a per-user marketing campaign email (tracking-enabled, marketing category).");
|
|
139
|
+
/**
|
|
140
|
+
* The one template `@pithy-sh/support` sends through.
|
|
141
|
+
*
|
|
142
|
+
* **One template, not one per canned reply.** The wording of a support answer belongs to the adopter
|
|
143
|
+
* and changes on a Tuesday; a Handlebars body here is precompiled at build time and changes on a
|
|
144
|
+
* release. So this is the *shell* — the theme, the HTML and text pair, the shape a reply arrives in —
|
|
145
|
+
* and the words are `body`, chosen and edited by a human in the dashboard from the catalog
|
|
146
|
+
* `@pithy-sh/support` federates. The machine's job is a better blank page, not the letter.
|
|
147
|
+
*
|
|
148
|
+
* `{{body}}` is Handlebars-escaped, which matters more here than anywhere else in this file: it is
|
|
149
|
+
* the only template whose payload is free text somebody typed rather than a value this codebase
|
|
150
|
+
* produced.
|
|
151
|
+
*/
|
|
152
|
+
const SupportReplyPayload = z.object({
|
|
153
|
+
subject: z.string().describe("The reply's subject line, already `Re:`-prefixed by the support capability."),
|
|
154
|
+
body: z.string().describe("The reply text a human wrote. Rendered as paragraphs, HTML-escaped — it is free text from an operator, never markup."),
|
|
155
|
+
agentName: z.string().optional().describe("Who is answering, signed at the bottom. Optional; omitted rather than guessed.")
|
|
156
|
+
}).describe("Inputs for a support reply — the shell around text a human wrote and edited.");
|
|
157
|
+
/** The full template set, keyed by id. */
|
|
158
|
+
const templates = {
|
|
159
|
+
magicLink: {
|
|
160
|
+
id: "magicLink",
|
|
161
|
+
category: "transactional",
|
|
162
|
+
kind: "transactional",
|
|
163
|
+
width: "narrow",
|
|
164
|
+
payload: MagicLinkPayload,
|
|
165
|
+
subject: `{{t "email/magic_link.subject"}}`,
|
|
166
|
+
html: layout(`${heading("{{t \"email/magic_link.heading\"}}")}<p style="margin:0 0 16px">${greeting} {{t "email/magic_link.instruction"}} {{tn "email/magic_link.expiry" count=expiresMinutes}}</p>${button("url", "{{t \"email/magic_link.cta\"}}")}<p class="t-subtle" style="margin:16px 0 0; font-size:13px; color:{{theme.light.textSubtle}}">{{t "email/magic_link.ignore"}}</p>`),
|
|
167
|
+
text: `${greeting}\n\n{{tn "email/magic_link.text_instruction" count=expiresMinutes}}\n{{url}}\n\n{{t "email/magic_link.text_ignore"}}`,
|
|
168
|
+
links: [{
|
|
169
|
+
path: "url",
|
|
170
|
+
label: "magic-link"
|
|
171
|
+
}]
|
|
172
|
+
},
|
|
173
|
+
otp: {
|
|
174
|
+
id: "otp",
|
|
175
|
+
category: "transactional",
|
|
176
|
+
kind: "transactional",
|
|
177
|
+
width: "narrow",
|
|
178
|
+
payload: OtpPayload,
|
|
179
|
+
subject: `{{t "email/otp.subject"}}`,
|
|
180
|
+
html: layout(`${heading("{{t \"email/otp.heading\"}}")}<p style="margin:0 0 12px">${greeting} {{t "email/otp.lead"}}</p><p class="t-ink" style="font-size:32px; font-weight:700; letter-spacing:6px; color:{{theme.accent}}; margin:16px 0">{{code}}</p><p style="margin:0">{{tn "email/otp.expiry" count=expiresMinutes}}</p>`),
|
|
181
|
+
text: `${greeting}\n\n{{tn "email/otp.text_body" count=expiresMinutes code=code}}`,
|
|
182
|
+
links: []
|
|
183
|
+
},
|
|
184
|
+
welcome: {
|
|
185
|
+
id: "welcome",
|
|
186
|
+
category: "transactional",
|
|
187
|
+
kind: "transactional",
|
|
188
|
+
width: "narrow",
|
|
189
|
+
payload: WelcomePayload,
|
|
190
|
+
subject: `{{t "email/welcome.subject" app=theme.appName}}`,
|
|
191
|
+
html: layout(`${heading("{{t \"email/welcome.heading\" app=theme.appName}}")}<p style="margin:0 0 8px">{{t "email/welcome.body" name=name app=theme.appName}}</p>${button("ctaUrl", "{{ctaLabel}}")}`),
|
|
192
|
+
text: `{{t "email/shell.greeting_named" name=name}}\n\n{{t "email/welcome.text_body" app=theme.appName}}\n\n{{ctaLabel}}: {{ctaUrl}}`,
|
|
193
|
+
links: [{
|
|
194
|
+
path: "ctaUrl",
|
|
195
|
+
label: "welcome-cta"
|
|
196
|
+
}]
|
|
197
|
+
},
|
|
198
|
+
securityAlert: {
|
|
199
|
+
id: "securityAlert",
|
|
200
|
+
category: "transactional",
|
|
201
|
+
kind: "transactional",
|
|
202
|
+
width: "narrow",
|
|
203
|
+
payload: SecurityAlertPayload,
|
|
204
|
+
subject: `{{t "email/security_alert.subject" event=event}}`,
|
|
205
|
+
html: layout(`${heading("{{t \"email/security_alert.heading\"}}")}<p style="margin:0 0 8px">${greeting} {{t "email/security_alert.body" event=event when=when}}{{#if ipAddress}} {{t "email/security_alert.ip" ip=ipAddress}}{{/if}}</p><p style="margin:0 0 8px">{{t "email/security_alert.reassure"}}</p>${button("actionUrl", "{{t \"email/security_alert.cta\"}}")}`),
|
|
206
|
+
text: `${greeting}\n\n{{t "email/security_alert.body" event=event when=when}}{{#if ipAddress}} {{t "email/security_alert.text_ip" ip=ipAddress}}{{/if}}\n\n{{t "email/security_alert.text_action"}} {{actionUrl}}`,
|
|
207
|
+
links: [{
|
|
208
|
+
path: "actionUrl",
|
|
209
|
+
label: "security-action"
|
|
210
|
+
}]
|
|
211
|
+
},
|
|
212
|
+
invite: {
|
|
213
|
+
id: "invite",
|
|
214
|
+
category: "transactional",
|
|
215
|
+
kind: "transactional",
|
|
216
|
+
width: "narrow",
|
|
217
|
+
payload: InvitePayload,
|
|
218
|
+
subject: `{{t "email/invite.subject" inviter=inviterName organization=organizationName}}`,
|
|
219
|
+
html: layout(`${heading("{{t \"email/invite.heading\"}}")}<p style="margin:0 0 8px">{{t "email/invite.body" inviter=inviterName organization=organizationName app=theme.appName}}</p>${button("acceptUrl", "{{t \"email/invite.cta\"}}")}`),
|
|
220
|
+
text: `{{t "email/invite.body" inviter=inviterName organization=organizationName app=theme.appName}}\n\n{{t "email/invite.text_accept"}} {{acceptUrl}}`,
|
|
221
|
+
links: [{
|
|
222
|
+
path: "acceptUrl",
|
|
223
|
+
label: "invite-accept"
|
|
224
|
+
}]
|
|
225
|
+
},
|
|
226
|
+
testerNudge: {
|
|
227
|
+
id: "testerNudge",
|
|
228
|
+
category: "transactional",
|
|
229
|
+
kind: "elective",
|
|
230
|
+
width: "narrow",
|
|
231
|
+
payload: TesterNudgePayload,
|
|
232
|
+
subject: "{{subject}}",
|
|
233
|
+
html: layout(`{{#if heading}}<h1 class="t-ink" style="margin:0 0 16px; font-size:22px; font-weight:600; letter-spacing:-0.02em; color:{{theme.light.text}}">{{heading}}</h1>{{/if}}{{#each paragraphs}}<p style="margin:0 0 16px">{{this}}</p>{{/each}}{{#if ctaUrl}}${button("ctaUrl", "{{ctaLabel}}")}{{/if}}{{#if footnote}}<p class="t-subtle" style="margin:16px 0 0; font-size:13px; color:{{theme.light.textSubtle}}">{{footnote}}</p>{{/if}}{{#if optOutUrl}}<p class="t-subtle" style="margin:20px 0 0; font-size:13px; color:{{theme.light.textSubtle}}"><a href="{{optOutUrl}}" class="hover-underline t-subtle" style="color:{{theme.light.textSubtle}}; text-decoration:underline">{{optOutLabel}}</a></p>{{/if}}`),
|
|
234
|
+
text: "{{heading}}\n\n{{#each paragraphs}}{{this}}\n\n{{/each}}{{#if ctaUrl}}{{ctaLabel}}: {{ctaUrl}}\n\n{{/if}}{{#if footnote}}{{footnote}}\n\n{{/if}}{{#if optOutUrl}}{{optOutLabel}}: {{optOutUrl}}{{/if}}",
|
|
235
|
+
links: [{
|
|
236
|
+
path: "ctaUrl",
|
|
237
|
+
label: "tester-confirm"
|
|
238
|
+
}]
|
|
239
|
+
},
|
|
240
|
+
passwordChanged: {
|
|
241
|
+
id: "passwordChanged",
|
|
242
|
+
category: "transactional",
|
|
243
|
+
kind: "transactional",
|
|
244
|
+
width: "narrow",
|
|
245
|
+
payload: PasswordChangedPayload,
|
|
246
|
+
subject: `{{t "email/password_changed.subject"}}`,
|
|
247
|
+
html: layout(`${heading("{{t \"email/password_changed.heading\"}}")}<p style="margin:0 0 8px">${greeting} {{t "email/password_changed.body" when=when}}</p><p style="margin:0 0 8px">{{t "email/password_changed.warn"}}</p>${button("supportUrl", "{{t \"email/password_changed.cta\"}}")}`),
|
|
248
|
+
text: `${greeting}\n\n{{t "email/password_changed.text_body" when=when}} {{supportUrl}}`,
|
|
249
|
+
links: [{
|
|
250
|
+
path: "supportUrl",
|
|
251
|
+
label: "password-support"
|
|
252
|
+
}]
|
|
253
|
+
},
|
|
254
|
+
operationalNotice: {
|
|
255
|
+
id: "operationalNotice",
|
|
256
|
+
category: "transactional",
|
|
257
|
+
kind: "transactional",
|
|
258
|
+
width: "narrow",
|
|
259
|
+
payload: OperationalNoticePayload,
|
|
260
|
+
subject: "{{severityLabel severity}}: {{summary}}",
|
|
261
|
+
html: layout(`<p class="sev-{{severity}}" style="margin:0 0 10px; font-size:12px; font-weight:700; letter-spacing:0.08em; text-transform:uppercase; color:{{severityColor severity}}">{{severityLabel severity}}</p>${heading("{{summary}}")}<p class="t-subtle" style="margin:0 0 20px; font-size:13px; color:{{theme.light.textSubtle}}">{{thing}} · {{when}}</p>{{#if detail}}<p style="margin:0 0 16px">{{detail}}</p>{{/if}}{{#if facts.length}}<table cellpadding="0" cellspacing="0" role="none" style="width:100%; margin:0 0 8px">{{#each facts}}<tr><td class="t-subtle" style="padding:4px 16px 4px 0; font-size:13px; color:{{../theme.light.textSubtle}}; vertical-align:top">{{label}}</td><td class="t-ink" style="padding:4px 0; font-size:13px; color:{{../theme.light.text}}; vertical-align:top">{{value}}</td></tr>{{/each}}</table>{{/if}}{{#if actionUrl}}${button("actionUrl", "{{actionLabel}}")}{{/if}}`),
|
|
262
|
+
text: "{{severityLabel severity}} — {{summary}}\n\n{{thing}}\n{{when}}\n\n{{#if detail}}{{detail}}\n\n{{/if}}{{#each facts}}{{label}}: {{value}}\n{{/each}}{{#if actionUrl}}\n{{actionLabel}}: {{actionUrl}}{{/if}}",
|
|
263
|
+
links: [{
|
|
264
|
+
path: "actionUrl",
|
|
265
|
+
label: "operational-action"
|
|
266
|
+
}]
|
|
267
|
+
},
|
|
268
|
+
supportReply: {
|
|
269
|
+
id: "supportReply",
|
|
270
|
+
category: "transactional",
|
|
271
|
+
kind: "transactional",
|
|
272
|
+
width: "wide",
|
|
273
|
+
payload: SupportReplyPayload,
|
|
274
|
+
subject: "{{subject}}",
|
|
275
|
+
html: layout(`<div style="margin:0 0 16px; white-space:pre-wrap">{{body}}</div>{{#if agentName}}<p class="t-subtle" style="margin:24px 0 0; font-size:14px">— {{agentName}}</p>{{/if}}`),
|
|
276
|
+
text: "{{body}}{{#if agentName}}\n\n— {{agentName}}{{/if}}",
|
|
277
|
+
links: []
|
|
278
|
+
},
|
|
279
|
+
newsletter: {
|
|
280
|
+
id: "newsletter",
|
|
281
|
+
category: "marketing",
|
|
282
|
+
kind: "elective",
|
|
283
|
+
width: "wide",
|
|
284
|
+
payload: NewsletterPayload,
|
|
285
|
+
subject: "{{subject}}",
|
|
286
|
+
html: layout(`<p style="margin:0 0 8px">{{intro}}</p>{{#each articles}}${sep}{{#if featureImage}}<a href="{{link}}"><img src="{{featureImage}}" alt="{{title}}" width="100%" style="height:180px; width:100%; object-fit:cover; border-radius:8px; margin-bottom:12px; border:0" /></a>{{/if}}<h2 class="t-ink" style="margin:0 0 8px; font-size:19px; font-weight:600; letter-spacing:-0.02em; color:{{../theme.light.text}}">{{title}}</h2><p style="margin:0 0 8px">{{summary}}</p><a href="{{link}}" class="t-ink" style="color:{{../theme.light.text}}; font-weight:600; text-decoration:none">Read more →</a>{{/each}}{{#if outro}}${sep}<p style="margin:0">{{outro}}</p>{{/if}}`),
|
|
287
|
+
text: "{{intro}}\n\n{{#each articles}}{{title}}\n{{summary}}\n{{link}}\n\n{{/each}}{{#if outro}}{{outro}}{{/if}}",
|
|
288
|
+
links: [{
|
|
289
|
+
path: "articles[].link",
|
|
290
|
+
label: "newsletter-article"
|
|
291
|
+
}]
|
|
292
|
+
},
|
|
293
|
+
leadCapture: {
|
|
294
|
+
id: "leadCapture",
|
|
295
|
+
category: "transactional",
|
|
296
|
+
kind: "elective",
|
|
297
|
+
width: "narrow",
|
|
298
|
+
payload: LeadCapturePayload,
|
|
299
|
+
subject: `{{t "email/lead_capture.subject" asset=assetName}}`,
|
|
300
|
+
html: layout(`${heading("{{t \"email/lead_capture.heading\"}}")}<p style="margin:0 0 8px">${greeting}</p>{{#if message}}<p style="margin:0 0 8px">{{message}}</p>{{/if}}<p style="margin:0 0 8px">{{t "email/lead_capture.ready" asset=assetName}}</p>${button("assetUrl", "{{t \"email/lead_capture.cta\"}}")}`),
|
|
301
|
+
text: `${greeting}\n\n{{#if message}}{{message}}\n\n{{/if}}{{t "email/lead_capture.text_ready" asset=assetName}} {{assetUrl}}`,
|
|
302
|
+
links: [{
|
|
303
|
+
path: "assetUrl",
|
|
304
|
+
label: "lead-asset"
|
|
305
|
+
}]
|
|
306
|
+
},
|
|
307
|
+
marketingCampaign: {
|
|
308
|
+
id: "marketingCampaign",
|
|
309
|
+
category: "marketing",
|
|
310
|
+
kind: "elective",
|
|
311
|
+
width: "narrow",
|
|
312
|
+
payload: MarketingCampaignPayload,
|
|
313
|
+
subject: "{{subject}}",
|
|
314
|
+
html: layout(`${heading("{{heading}}")}<p style="margin:0 0 8px">{{body}}</p>${button("ctaUrl", "{{ctaLabel}}")}`),
|
|
315
|
+
text: "{{heading}}\n\n{{body}}\n\n{{ctaLabel}}: {{ctaUrl}}",
|
|
316
|
+
links: [{
|
|
317
|
+
path: "ctaUrl",
|
|
318
|
+
label: "campaign-cta"
|
|
319
|
+
}]
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
//#endregion
|
|
323
|
+
export { OperationalNoticePayload, templates };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Placeholder payloads — one valid input per template — for previewing a rendered email without real
|
|
3
|
+
* data. `pithy email test` uses these to send a sample of any template through a project's config so a
|
|
4
|
+
* user can see the result and confirm setup. Each satisfies its template's Zod payload schema.
|
|
5
|
+
*/
|
|
6
|
+
export declare const samplePayloads: Record<string, unknown>;
|
|
7
|
+
//# sourceMappingURL=samples.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"samples.d.ts","sourceRoot":"","sources":["../../src/templates/samples.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAkElD,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
//#region src/templates/samples.ts
|
|
2
|
+
/**
|
|
3
|
+
* Placeholder payloads — one valid input per template — for previewing a rendered email without real
|
|
4
|
+
* data. `pithy email test` uses these to send a sample of any template through a project's config so a
|
|
5
|
+
* user can see the result and confirm setup. Each satisfies its template's Zod payload schema.
|
|
6
|
+
*/
|
|
7
|
+
const samplePayloads = {
|
|
8
|
+
magicLink: {
|
|
9
|
+
name: "Sam",
|
|
10
|
+
url: "https://example.com/signin?token=demo",
|
|
11
|
+
expiresMinutes: 15
|
|
12
|
+
},
|
|
13
|
+
supportReply: {
|
|
14
|
+
subject: "Re: I was charged twice this month",
|
|
15
|
+
body: "Hi Sam,\n\nI have refunded the duplicate charge — it should be back on your card within three working days.\n\nSorry for the trouble.",
|
|
16
|
+
agentName: "Alex"
|
|
17
|
+
},
|
|
18
|
+
otp: {
|
|
19
|
+
name: "Sam",
|
|
20
|
+
code: "123456",
|
|
21
|
+
expiresMinutes: 10
|
|
22
|
+
},
|
|
23
|
+
welcome: {
|
|
24
|
+
name: "Sam",
|
|
25
|
+
ctaUrl: "https://example.com/start",
|
|
26
|
+
ctaLabel: "Open your dashboard"
|
|
27
|
+
},
|
|
28
|
+
securityAlert: {
|
|
29
|
+
name: "Sam",
|
|
30
|
+
event: "New sign-in from Chrome on macOS",
|
|
31
|
+
when: "just now",
|
|
32
|
+
ipAddress: "203.0.113.4",
|
|
33
|
+
actionUrl: "https://example.com/activity"
|
|
34
|
+
},
|
|
35
|
+
invite: {
|
|
36
|
+
inviterName: "Pat",
|
|
37
|
+
organizationName: "Acme",
|
|
38
|
+
acceptUrl: "https://example.com/accept"
|
|
39
|
+
},
|
|
40
|
+
testerNudge: {
|
|
41
|
+
subject: "One step left to join the test",
|
|
42
|
+
heading: "Confirm your place",
|
|
43
|
+
paragraphs: ["You were invited to test an early build. Confirming takes one tap, and it is the step that actually enrolls you.", "The test runs for a fixed period, and it needs everyone who joined to stay joined for the whole of it."],
|
|
44
|
+
ctaUrl: "https://example.com/testers/opt-in/sample-token",
|
|
45
|
+
ctaLabel: "Confirm",
|
|
46
|
+
optOutUrl: "https://example.com/testers/opt-out/sample-token",
|
|
47
|
+
optOutLabel: "No thanks, take me off this list"
|
|
48
|
+
},
|
|
49
|
+
passwordChanged: {
|
|
50
|
+
name: "Sam",
|
|
51
|
+
when: "just now",
|
|
52
|
+
supportUrl: "https://example.com/support"
|
|
53
|
+
},
|
|
54
|
+
operationalNotice: {
|
|
55
|
+
severity: "warning",
|
|
56
|
+
summary: "A secret has not been rotated in 90 days",
|
|
57
|
+
thing: "STRIPE_SECRET_KEY",
|
|
58
|
+
when: "18 June, 14:02 UTC",
|
|
59
|
+
detail: "Rotation is overdue. The old value keeps working until the new one is in place.",
|
|
60
|
+
facts: [{
|
|
61
|
+
label: "Environment",
|
|
62
|
+
value: "prod"
|
|
63
|
+
}, {
|
|
64
|
+
label: "Last rotated",
|
|
65
|
+
value: "20 March"
|
|
66
|
+
}],
|
|
67
|
+
actionUrl: "https://example.com/secrets/stripe-secret-key",
|
|
68
|
+
actionLabel: "Rotate it"
|
|
69
|
+
},
|
|
70
|
+
newsletter: {
|
|
71
|
+
subject: "Sample newsletter",
|
|
72
|
+
intro: "Here's what's new this week.",
|
|
73
|
+
articles: [{
|
|
74
|
+
title: "A first headline",
|
|
75
|
+
summary: "A one-line summary of the first article.",
|
|
76
|
+
link: "https://example.com/a"
|
|
77
|
+
}, {
|
|
78
|
+
title: "A second headline",
|
|
79
|
+
summary: "A one-line summary of the second article.",
|
|
80
|
+
link: "https://example.com/b"
|
|
81
|
+
}],
|
|
82
|
+
outro: "That's it for this week."
|
|
83
|
+
},
|
|
84
|
+
leadCapture: {
|
|
85
|
+
name: "Sam",
|
|
86
|
+
assetName: "The 2026 Backend Playbook",
|
|
87
|
+
assetUrl: "https://example.com/download"
|
|
88
|
+
},
|
|
89
|
+
marketingCampaign: {
|
|
90
|
+
subject: "A sample campaign",
|
|
91
|
+
heading: "Big news",
|
|
92
|
+
body: "The body copy of a marketing campaign.",
|
|
93
|
+
ctaUrl: "https://example.com/go",
|
|
94
|
+
ctaLabel: "See what's new"
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
//#endregion
|
|
98
|
+
export { samplePayloads };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* How urgent an operational notice is, and how that urgency is said out loud.
|
|
4
|
+
*
|
|
5
|
+
* **Severity is words first and color second, and the order matters.** A notice is read in an inbox
|
|
6
|
+
* list before it is opened, in a plain-text client that has no colors at all, and by people who cannot
|
|
7
|
+
* tell the red one from the amber one. So each level owns a *label* — which goes in the subject line,
|
|
8
|
+
* in the body, and in the text part — and a color that only ever reinforces it. A design where the
|
|
9
|
+
* only difference between "a release is out" and "your sign-in is broken" is a hex value has flattened
|
|
10
|
+
* them, and a reader who cannot see the difference learns to ignore both.
|
|
11
|
+
*
|
|
12
|
+
* The labels name the response, not the volume. "Action needed" tells somebody what the message wants
|
|
13
|
+
* from them; "Warning" only tells them how loudly it is being said.
|
|
14
|
+
*/
|
|
15
|
+
export declare const NoticeSeverity: z.ZodEnum<{
|
|
16
|
+
critical: "critical";
|
|
17
|
+
info: "info";
|
|
18
|
+
warning: "warning";
|
|
19
|
+
}>;
|
|
20
|
+
export type NoticeSeverity = z.output<typeof NoticeSeverity>;
|
|
21
|
+
/**
|
|
22
|
+
* The catalog key holding the word this level is called.
|
|
23
|
+
*
|
|
24
|
+
* The engine's `{{severityLabel severity}}` helper resolves this through the render's translator, so
|
|
25
|
+
* the level is said in the recipient's language in all three places it appears. Exported as a key and
|
|
26
|
+
* not as a word, because a function returning a word would have to be handed a translator, and then
|
|
27
|
+
* every caller would carry one to ask a question about an enum.
|
|
28
|
+
*/
|
|
29
|
+
export declare function severityLabelKey(severity: unknown): string;
|
|
30
|
+
/** The `{{severityColor severity}}` helper: the light-mode color, applied inline like every other one. */
|
|
31
|
+
export declare function severityColor(severity: unknown): string;
|
|
32
|
+
/**
|
|
33
|
+
* The dark-mode overrides for the severity colors, generated from the same table.
|
|
34
|
+
*
|
|
35
|
+
* The shared head partial carries the light values inline and swaps these in under
|
|
36
|
+
* `prefers-color-scheme: dark`, exactly as it does for the theme's own palette. Generated rather than
|
|
37
|
+
* written out so a color changed here cannot leave dark mode showing the old one.
|
|
38
|
+
*/
|
|
39
|
+
export declare const severityDarkModeCss: string;
|
|
40
|
+
//# sourceMappingURL=severity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"severity.d.ts","sourceRoot":"","sources":["../../src/templates/severity.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,cAAc;;;;EAIxB,CAAC;AACJ,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC;AAmD7D;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAE1D;AAED,0GAA0G;AAC1G,wBAAgB,aAAa,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAEvD;AAED;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAErB,CAAC"}
|