@pithy-sh/email 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/capability.d.ts +2 -2
- package/dist/capability.d.ts.map +1 -1
- package/dist/capability.js +23 -2
- package/dist/consent/consent.d.ts +57 -0
- package/dist/consent/consent.d.ts.map +1 -0
- package/dist/consent/consent.js +135 -0
- package/dist/data/emailEvent.d.ts +1 -1
- package/dist/data/emailEvent.d.ts.map +1 -1
- package/dist/data/emailEvent.js +2 -1
- package/dist/data/emailJob.d.ts +6 -2
- package/dist/data/emailJob.d.ts.map +1 -1
- package/dist/data/emailJob.js +8 -3
- package/dist/data/emailSuppression.d.ts +1 -1
- package/dist/data/emailSuppression.d.ts.map +1 -1
- package/dist/data/emailSuppression.js +2 -1
- package/dist/data/tables.d.ts +4 -4
- package/dist/http/guards.d.ts +2 -2
- package/dist/http/guards.d.ts.map +1 -1
- package/dist/http/guards.js +12 -0
- package/dist/processing/activities.d.ts +9 -0
- package/dist/processing/activities.d.ts.map +1 -0
- package/dist/processing/activities.js +40 -0
- package/dist/purge/contribution.d.ts +27 -0
- package/dist/purge/contribution.d.ts.map +1 -0
- package/dist/purge/contribution.js +67 -0
- package/dist/send/enqueue.d.ts +26 -7
- package/dist/send/enqueue.d.ts.map +1 -1
- package/dist/send/enqueue.js +36 -13
- package/dist/templates/messages.d.ts +1 -2
- package/dist/templates/messages.d.ts.map +1 -1
- package/dist/templates/messages.es.d.ts.map +1 -1
- package/dist/templates/messages.es.js +28 -0
- package/dist/templates/messages.js +35 -10
- package/dist/templates/precompiled.generated.d.ts +124 -0
- package/dist/templates/precompiled.generated.d.ts.map +1 -1
- package/dist/templates/precompiled.generated.js +1618 -0
- package/dist/templates/registry.d.ts.map +1 -1
- package/dist/templates/registry.js +106 -0
- package/dist/templates/samples.d.ts.map +1 -1
- package/dist/templates/samples.js +28 -0
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/package.json +3 -3
- package/src/capability.ts +33 -7
- package/src/consent/consent.ts +183 -0
- package/src/data/emailEvent.ts +2 -1
- package/src/data/emailJob.ts +21 -8
- package/src/data/emailSuppression.ts +2 -1
- package/src/http/guards.ts +14 -2
- package/src/processing/activities.ts +41 -0
- package/src/purge/contribution.ts +83 -0
- package/src/send/enqueue.ts +62 -24
- package/src/templates/messages.es.ts +41 -0
- package/src/templates/messages.ts +52 -11
- package/src/templates/precompiled.generated.ts +551 -0
- package/src/templates/registry.ts +159 -0
- package/src/templates/samples.ts +11 -0
- package/src/version.generated.ts +1 -1
|
@@ -266,6 +266,82 @@ const DeletionCompletePayload = z
|
|
|
266
266
|
})
|
|
267
267
|
.describe("Inputs for the notice that an account's data was erased — sent before the address is.");
|
|
268
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
|
+
|
|
269
345
|
/** One labeled fact in an operational notice — what makes the notice specific rather than a mood. */
|
|
270
346
|
const OperationalNoticeFact = z
|
|
271
347
|
.object({
|
|
@@ -568,6 +644,89 @@ export const templates: Record<string, EmailTemplate> = {
|
|
|
568
644
|
text: `${greeting}\n\n{{t "email/deletion_complete.text_body" app=theme.appName purgedOn=purgedOn}}\n\n{{t "email/deletion_complete.last"}}`,
|
|
569
645
|
links: [],
|
|
570
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
|
+
},
|
|
571
730
|
operationalNotice: {
|
|
572
731
|
id: "operationalNotice",
|
|
573
732
|
category: "transactional",
|
package/src/templates/samples.ts
CHANGED
|
@@ -40,6 +40,17 @@ export const samplePayloads: Record<string, unknown> = {
|
|
|
40
40
|
accountReinstated: { name: "Sam" },
|
|
41
41
|
deletionScheduled: { name: "Sam", purgeOn: "19 November 2026", restoreUrl: "https://example.com/account/restore" },
|
|
42
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" },
|
|
43
54
|
// `warning` rather than `info`: a sample is what somebody looks at to decide whether the severity is
|
|
44
55
|
// legible, and the middle level is the one that has to earn its place between the other two.
|
|
45
56
|
operationalNotice: {
|
package/src/version.generated.ts
CHANGED