@pithy-sh/email 0.5.0 → 0.7.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.
@@ -217,6 +217,131 @@ const PasswordChangedPayload = z
217
217
  })
218
218
  .describe("Inputs for the account-credential-changed security notice.");
219
219
 
220
+ /**
221
+ * The four account-lifecycle notices `@pithy-sh/auth` sends (#620). Every date arrives already written for
222
+ * the reader — `1 November 2026` — because the sender knows the recipient's locale and this template does
223
+ * not, which is the convention `when` set for `securityAlert`.
224
+ */
225
+ const AccountSuspendedPayload = z
226
+ .object({
227
+ name: z.string().optional().describe("The recipient's name, for a personal greeting. Optional."),
228
+ reason: z
229
+ .string()
230
+ .optional()
231
+ .describe(
232
+ "Why the account was suspended, in the operator's words. Rendered escaped, as every payload value is. Omitted when none was given.",
233
+ ),
234
+ until: z
235
+ .string()
236
+ .optional()
237
+ .describe("When the suspension ends by itself, written for the reader. Omitted for one with no end."),
238
+ })
239
+ .describe("Inputs for the notice that an account was suspended.");
240
+
241
+ const AccountReinstatedPayload = z
242
+ .object({
243
+ name: z.string().optional().describe("The recipient's name, for a personal greeting. Optional."),
244
+ })
245
+ .describe("Inputs for the notice that a suspension was lifted.");
246
+
247
+ const DeletionScheduledPayload = z
248
+ .object({
249
+ name: z.string().optional().describe("The recipient's name, for a personal greeting. Optional."),
250
+ purgeOn: z
251
+ .string()
252
+ .describe("The date the account's data will be erased, written for the reader. Until then it can be restored."),
253
+ restoreUrl: z
254
+ .string()
255
+ .optional()
256
+ .describe(
257
+ "Where the account's owner can restore it inside the window. Tracked when click tracking is on. Omitted when the project offers no self-service restore.",
258
+ ),
259
+ })
260
+ .describe("Inputs for the notice that an account was deleted and will be erased.");
261
+
262
+ const DeletionCompletePayload = z
263
+ .object({
264
+ name: z.string().optional().describe("The recipient's name, for a personal greeting. Optional."),
265
+ purgedOn: z.string().describe("The date the account's data was erased, written for the reader."),
266
+ })
267
+ .describe("Inputs for the notice that an account's data was erased — sent before the address is.");
268
+
269
+ /**
270
+ * The three notices `@pithy-sh/organization` sends when an operator changes somebody's membership through
271
+ * the control plane (#624). Each names the organization, because a person in two accounts must be able to
272
+ * tell which one changed, and none carries the operator's reason: that is the trail's, written for the
273
+ * people who answer for the account, not for the person it happened to.
274
+ */
275
+ const OrganizationMemberAddedPayload = z
276
+ .object({
277
+ name: z.string().optional().describe("The recipient's name, for a personal greeting. Optional."),
278
+ organizationName: z
279
+ .string()
280
+ .describe("The organization they were added to, by display name. Tenant text, escaped like every value."),
281
+ role: z.string().describe("The role they hold there now, as the project's catalog names it."),
282
+ })
283
+ .describe("Inputs for the notice that an operator added somebody to an organization.");
284
+
285
+ const OrganizationMemberRemovedPayload = z
286
+ .object({
287
+ name: z.string().optional().describe("The recipient's name, for a personal greeting. Optional."),
288
+ organizationName: z
289
+ .string()
290
+ .describe("The organization they were removed from, by display name. Tenant text, escaped like every value."),
291
+ })
292
+ .describe("Inputs for the notice that an operator removed somebody from an organization.");
293
+
294
+ const OrganizationOwnershipTransferredPayload = z
295
+ .object({
296
+ name: z.string().optional().describe("The recipient's name, for a personal greeting. Optional."),
297
+ organizationName: z
298
+ .string()
299
+ .describe("The organization they now own, by display name. Tenant text, escaped like every value."),
300
+ })
301
+ .describe("Inputs for the notice that an operator made somebody the owner of an organization.");
302
+
303
+ /**
304
+ * The three notices `@pithy-sh/organization` sends an organization's owners when an operator acts on the
305
+ * organization itself (#623): it was suspended, reinstated, or deleted with a date its data is erased. Each names
306
+ * the organization. The suspension carries the operator's reason, because the suspended screen tells every member
307
+ * the owners were told why.
308
+ */
309
+ const OrganizationSuspendedPayload = z
310
+ .object({
311
+ name: z.string().optional().describe("The recipient's name, for a personal greeting. Optional."),
312
+ organizationName: z
313
+ .string()
314
+ .describe("The organization that was suspended, by display name. Tenant text, escaped like every value."),
315
+ reason: z
316
+ .string()
317
+ .optional()
318
+ .describe("Why it was suspended, in the operator's words. Rendered escaped. Omitted when none was given."),
319
+ until: z
320
+ .string()
321
+ .optional()
322
+ .describe("When the suspension ends by itself, written for the reader. Omitted for one with no end."),
323
+ })
324
+ .describe("Inputs for the notice to an owner that their organization was suspended.");
325
+
326
+ const OrganizationReinstatedPayload = z
327
+ .object({
328
+ name: z.string().optional().describe("The recipient's name, for a personal greeting. Optional."),
329
+ organizationName: z
330
+ .string()
331
+ .describe("The organization that was reinstated, by display name. Tenant text, escaped like every value."),
332
+ })
333
+ .describe("Inputs for the notice to an owner that their organization's suspension was lifted.");
334
+
335
+ const OrganizationDeletionScheduledPayload = z
336
+ .object({
337
+ name: z.string().optional().describe("The recipient's name, for a personal greeting. Optional."),
338
+ organizationName: z
339
+ .string()
340
+ .describe("The organization that was deleted, by display name. Tenant text, escaped like every value."),
341
+ purgeOn: z.string().describe("When its data will be erased, written for the reader. Restorable until then."),
342
+ })
343
+ .describe("Inputs for the notice to an owner that their organization was deleted and when it will be erased.");
344
+
220
345
  /** One labeled fact in an operational notice — what makes the notice specific rather than a mood. */
221
346
  const OperationalNoticeFact = z
222
347
  .object({
@@ -463,6 +588,145 @@ export const templates: Record<string, EmailTemplate> = {
463
588
  text: `${greeting}\n\n{{t "email/password_changed.text_body" when=when}} {{supportUrl}}`,
464
589
  links: [{ path: "supportUrl", label: "password-support" }],
465
590
  },
591
+ // The account lifecycle (#620). Transactional in both axes: a person who unsubscribed from a newsletter has
592
+ // not asked to stop being told their account is shut, and an unsubscribe that reached these would leave
593
+ // somebody locked out with no word of why. Each closes on who to answer — a reply, which reaches the
594
+ // adopter's own sending address — because the screen a locked-out person sees cannot name a person.
595
+ accountSuspended: {
596
+ id: "accountSuspended",
597
+ category: "transactional",
598
+ kind: "transactional",
599
+ width: "narrow",
600
+ payload: AccountSuspendedPayload,
601
+ subject: `{{t "email/account_suspended.subject" app=theme.appName}}`,
602
+ html: layout(
603
+ `${heading('{{t "email/account_suspended.heading"}}')}<p style="margin:0 0 8px">${greeting} {{t "email/account_suspended.body" app=theme.appName}}</p>{{#if reason}}<p style="margin:0 0 8px">{{t "email/account_suspended.reason" reason=reason}}</p>{{/if}}{{#if until}}<p style="margin:0 0 8px">{{t "email/account_suspended.until" until=until}}</p>{{/if}}<p class="t-subtle" style="margin:16px 0 0; font-size:13px; color:{{theme.light.textSubtle}}">{{t "email/account_suspended.contact"}}</p>`,
604
+ ),
605
+ text: `${greeting}\n\n{{t "email/account_suspended.text_body" app=theme.appName}}{{#if reason}}\n\n{{t "email/account_suspended.reason" reason=reason}}{{/if}}{{#if until}}\n\n{{t "email/account_suspended.until" until=until}}{{/if}}\n\n{{t "email/account_suspended.text_contact"}}`,
606
+ links: [],
607
+ },
608
+ accountReinstated: {
609
+ id: "accountReinstated",
610
+ category: "transactional",
611
+ kind: "transactional",
612
+ width: "narrow",
613
+ payload: AccountReinstatedPayload,
614
+ subject: `{{t "email/account_reinstated.subject" app=theme.appName}}`,
615
+ html: layout(
616
+ `${heading('{{t "email/account_reinstated.heading"}}')}<p style="margin:0 0 8px">${greeting} {{t "email/account_reinstated.body" app=theme.appName}}</p>`,
617
+ ),
618
+ text: `${greeting}\n\n{{t "email/account_reinstated.text_body" app=theme.appName}}`,
619
+ links: [],
620
+ },
621
+ deletionScheduled: {
622
+ id: "deletionScheduled",
623
+ category: "transactional",
624
+ kind: "transactional",
625
+ width: "narrow",
626
+ payload: DeletionScheduledPayload,
627
+ subject: `{{t "email/deletion_scheduled.subject" app=theme.appName}}`,
628
+ html: layout(
629
+ `${heading('{{t "email/deletion_scheduled.heading"}}')}<p style="margin:0 0 8px">${greeting} {{t "email/deletion_scheduled.body" app=theme.appName}}</p><p style="margin:0 0 8px">{{t "email/deletion_scheduled.purge" purgeOn=purgeOn}}</p>{{#if restoreUrl}}${button("restoreUrl", '{{t "email/deletion_scheduled.cta"}}')}{{/if}}<p class="t-subtle" style="margin:16px 0 0; font-size:13px; color:{{theme.light.textSubtle}}">{{t "email/deletion_scheduled.contact" purgeOn=purgeOn}}</p>`,
630
+ ),
631
+ text: `${greeting}\n\n{{t "email/deletion_scheduled.text_body" app=theme.appName}}\n\n{{t "email/deletion_scheduled.purge" purgeOn=purgeOn}}{{#if restoreUrl}}\n\n{{t "email/deletion_scheduled.text_restore"}} {{restoreUrl}}{{/if}}\n\n{{t "email/deletion_scheduled.text_contact" purgeOn=purgeOn}}`,
632
+ links: [{ path: "restoreUrl", label: "deletion-restore" }],
633
+ },
634
+ deletionComplete: {
635
+ id: "deletionComplete",
636
+ category: "transactional",
637
+ kind: "transactional",
638
+ width: "narrow",
639
+ payload: DeletionCompletePayload,
640
+ subject: `{{t "email/deletion_complete.subject" app=theme.appName}}`,
641
+ html: layout(
642
+ `${heading('{{t "email/deletion_complete.heading"}}')}<p style="margin:0 0 8px">${greeting} {{t "email/deletion_complete.body" app=theme.appName purgedOn=purgedOn}}</p><p class="t-subtle" style="margin:16px 0 0; font-size:13px; color:{{theme.light.textSubtle}}">{{t "email/deletion_complete.last"}}</p>`,
643
+ ),
644
+ text: `${greeting}\n\n{{t "email/deletion_complete.text_body" app=theme.appName purgedOn=purgedOn}}\n\n{{t "email/deletion_complete.last"}}`,
645
+ links: [],
646
+ },
647
+ // Membership administration (#624). Transactional in both axes: somebody whose access to an account was
648
+ // changed by somebody else is owed the word, and an unsubscribe from a newsletter is not a request to stop
649
+ // being told. Each closes on who to answer — a reply — as the lifecycle notices do.
650
+ organizationMemberAdded: {
651
+ id: "organizationMemberAdded",
652
+ category: "transactional",
653
+ kind: "transactional",
654
+ width: "narrow",
655
+ payload: OrganizationMemberAddedPayload,
656
+ subject: `{{t "email/organization_member_added.subject" organization=organizationName}}`,
657
+ html: layout(
658
+ `${heading('{{t "email/organization_member_added.heading"}}')}<p style="margin:0 0 8px">${greeting} {{t "email/organization_member_added.body" organization=organizationName role=role app=theme.appName}}</p><p class="t-subtle" style="margin:16px 0 0; font-size:13px; color:{{theme.light.textSubtle}}">{{t "email/organization_member.contact"}}</p>`,
659
+ ),
660
+ text: `${greeting}\n\n{{t "email/organization_member_added.text_body" organization=organizationName role=role app=theme.appName}}\n\n{{t "email/organization_member.contact"}}`,
661
+ links: [],
662
+ },
663
+ organizationMemberRemoved: {
664
+ id: "organizationMemberRemoved",
665
+ category: "transactional",
666
+ kind: "transactional",
667
+ width: "narrow",
668
+ payload: OrganizationMemberRemovedPayload,
669
+ subject: `{{t "email/organization_member_removed.subject" organization=organizationName}}`,
670
+ html: layout(
671
+ `${heading('{{t "email/organization_member_removed.heading"}}')}<p style="margin:0 0 8px">${greeting} {{t "email/organization_member_removed.body" organization=organizationName app=theme.appName}}</p><p class="t-subtle" style="margin:16px 0 0; font-size:13px; color:{{theme.light.textSubtle}}">{{t "email/organization_member.contact"}}</p>`,
672
+ ),
673
+ text: `${greeting}\n\n{{t "email/organization_member_removed.text_body" organization=organizationName app=theme.appName}}\n\n{{t "email/organization_member.contact"}}`,
674
+ links: [],
675
+ },
676
+ organizationOwnershipTransferred: {
677
+ id: "organizationOwnershipTransferred",
678
+ category: "transactional",
679
+ kind: "transactional",
680
+ width: "narrow",
681
+ payload: OrganizationOwnershipTransferredPayload,
682
+ subject: `{{t "email/organization_ownership_transferred.subject" organization=organizationName}}`,
683
+ html: layout(
684
+ `${heading('{{t "email/organization_ownership_transferred.heading"}}')}<p style="margin:0 0 8px">${greeting} {{t "email/organization_ownership_transferred.body" organization=organizationName app=theme.appName}}</p><p class="t-subtle" style="margin:16px 0 0; font-size:13px; color:{{theme.light.textSubtle}}">{{t "email/organization_member.contact"}}</p>`,
685
+ ),
686
+ text: `${greeting}\n\n{{t "email/organization_ownership_transferred.text_body" organization=organizationName app=theme.appName}}\n\n{{t "email/organization_member.contact"}}`,
687
+ links: [],
688
+ },
689
+ // The organization lifecycle (#623), to its owners. Transactional in both axes, as the account notices are:
690
+ // somebody whose organization an operator shut is owed the word.
691
+ organizationSuspended: {
692
+ id: "organizationSuspended",
693
+ category: "transactional",
694
+ kind: "transactional",
695
+ width: "narrow",
696
+ payload: OrganizationSuspendedPayload,
697
+ subject: `{{t "email/organization_suspended.subject" organization=organizationName}}`,
698
+ html: layout(
699
+ `${heading('{{t "email/organization_suspended.heading"}}')}<p style="margin:0 0 8px">${greeting} {{t "email/organization_suspended.body" organization=organizationName app=theme.appName}}</p>{{#if reason}}<p style="margin:0 0 8px">{{t "email/organization_suspended.reason" reason=reason}}</p>{{/if}}{{#if until}}<p style="margin:0 0 8px">{{t "email/organization_suspended.until" until=until}}</p>{{/if}}<p class="t-subtle" style="margin:16px 0 0; font-size:13px; color:{{theme.light.textSubtle}}">{{t "email/organization_member.contact"}}</p>`,
700
+ ),
701
+ text: `${greeting}\n\n{{t "email/organization_suspended.text_body" organization=organizationName app=theme.appName}}{{#if reason}}\n\n{{t "email/organization_suspended.reason" reason=reason}}{{/if}}{{#if until}}\n\n{{t "email/organization_suspended.until" until=until}}{{/if}}\n\n{{t "email/organization_member.contact"}}`,
702
+ links: [],
703
+ },
704
+ organizationReinstated: {
705
+ id: "organizationReinstated",
706
+ category: "transactional",
707
+ kind: "transactional",
708
+ width: "narrow",
709
+ payload: OrganizationReinstatedPayload,
710
+ subject: `{{t "email/organization_reinstated.subject" organization=organizationName}}`,
711
+ html: layout(
712
+ `${heading('{{t "email/organization_reinstated.heading"}}')}<p style="margin:0 0 8px">${greeting} {{t "email/organization_reinstated.body" organization=organizationName app=theme.appName}}</p><p class="t-subtle" style="margin:16px 0 0; font-size:13px; color:{{theme.light.textSubtle}}">{{t "email/organization_member.contact"}}</p>`,
713
+ ),
714
+ text: `${greeting}\n\n{{t "email/organization_reinstated.text_body" organization=organizationName app=theme.appName}}\n\n{{t "email/organization_member.contact"}}`,
715
+ links: [],
716
+ },
717
+ organizationDeletionScheduled: {
718
+ id: "organizationDeletionScheduled",
719
+ category: "transactional",
720
+ kind: "transactional",
721
+ width: "narrow",
722
+ payload: OrganizationDeletionScheduledPayload,
723
+ subject: `{{t "email/organization_deletion_scheduled.subject" organization=organizationName}}`,
724
+ html: layout(
725
+ `${heading('{{t "email/organization_deletion_scheduled.heading"}}')}<p style="margin:0 0 8px">${greeting} {{t "email/organization_deletion_scheduled.body" organization=organizationName app=theme.appName purgeOn=purgeOn}}</p><p class="t-subtle" style="margin:16px 0 0; font-size:13px; color:{{theme.light.textSubtle}}">{{t "email/organization_deletion_scheduled.contact" purgeOn=purgeOn}}</p>`,
726
+ ),
727
+ text: `${greeting}\n\n{{t "email/organization_deletion_scheduled.text_body" organization=organizationName app=theme.appName purgeOn=purgeOn}}\n\n{{t "email/organization_deletion_scheduled.contact" purgeOn=purgeOn}}`,
728
+ links: [],
729
+ },
466
730
  operationalNotice: {
467
731
  id: "operationalNotice",
468
732
  category: "transactional",
@@ -36,6 +36,21 @@ export const samplePayloads: Record<string, unknown> = {
36
36
  optOutLabel: "No thanks, take me off this list",
37
37
  },
38
38
  passwordChanged: { name: "Sam", when: "just now", supportUrl: "https://example.com/support" },
39
+ accountSuspended: { name: "Sam", reason: "A payment is under review.", until: "1 November 2026" },
40
+ accountReinstated: { name: "Sam" },
41
+ deletionScheduled: { name: "Sam", purgeOn: "19 November 2026", restoreUrl: "https://example.com/account/restore" },
42
+ deletionComplete: { name: "Sam", purgedOn: "19 November 2026" },
43
+ organizationMemberAdded: { name: "Sam", organizationName: "Globex", role: "admin" },
44
+ organizationMemberRemoved: { name: "Sam", organizationName: "Globex" },
45
+ organizationOwnershipTransferred: { name: "Sam", organizationName: "Globex" },
46
+ organizationSuspended: {
47
+ name: "Sam",
48
+ organizationName: "Globex",
49
+ reason: "The invoice for October is unpaid.",
50
+ until: "19 November 2026",
51
+ },
52
+ organizationReinstated: { name: "Sam", organizationName: "Globex" },
53
+ organizationDeletionScheduled: { name: "Sam", organizationName: "Globex", purgeOn: "19 November 2026" },
39
54
  // `warning` rather than `info`: a sample is what somebody looks at to decide whether the severity is
40
55
  // legible, and the middle level is the one that has to earn its place between the other two.
41
56
  operationalNotice: {
@@ -13,4 +13,4 @@
13
13
  export const PACKAGE_NAME = "@pithy-sh/email";
14
14
 
15
15
  /** This package's version, stamped from its own package.json at generation time. */
16
- export const PACKAGE_VERSION = "0.5.0";
16
+ export const PACKAGE_VERSION = "0.7.0";