@aglyn/shared-util-email 1.0.0-beta.218 → 1.0.0-beta.219

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.
Files changed (42) hide show
  1. package/README.md +58 -19
  2. package/package.json +3 -3
  3. package/src/index.d.ts +2 -0
  4. package/src/index.js +9 -1
  5. package/src/index.js.map +1 -1
  6. package/src/lib/email-delivery-events.d.ts +41 -48
  7. package/src/lib/email-delivery-events.js +18 -247
  8. package/src/lib/email-delivery-events.js.map +1 -1
  9. package/src/lib/email-health.d.ts +30 -43
  10. package/src/lib/email-health.js +45 -141
  11. package/src/lib/email-health.js.map +1 -1
  12. package/src/lib/mail-provider-resend.d.ts +194 -0
  13. package/src/lib/mail-provider-resend.js +649 -0
  14. package/src/lib/mail-provider-resend.js.map +1 -0
  15. package/src/lib/mail-provider-webhook.d.ts +80 -0
  16. package/src/lib/mail-provider-webhook.js +156 -0
  17. package/src/lib/mail-provider-webhook.js.map +1 -0
  18. package/src/lib/mail-provider.d.ts +148 -0
  19. package/src/lib/mail-provider.js +84 -0
  20. package/src/lib/mail-provider.js.map +1 -0
  21. package/src/lib/mail-providers.d.ts +99 -0
  22. package/src/lib/mail-providers.js +182 -0
  23. package/src/lib/mail-providers.js.map +1 -0
  24. package/src/lib/received-email.d.ts +7 -44
  25. package/src/lib/received-email.js +8 -104
  26. package/src/lib/received-email.js.map +1 -1
  27. package/src/lib/send-ceilings.d.ts +0 -57
  28. package/src/lib/send-ceilings.js +0 -47
  29. package/src/lib/send-ceilings.js.map +1 -1
  30. package/src/lib/send-email.d.ts +29 -58
  31. package/src/lib/send-email.js +98 -131
  32. package/src/lib/send-email.js.map +1 -1
  33. package/src/lib/send-rate.js +4 -3
  34. package/src/lib/send-rate.js.map +1 -1
  35. package/src/lib/system-email-catalog.js +3 -3
  36. package/src/lib/system-email-catalog.js.map +1 -1
  37. package/src/lib/tenant-email-catalog.d.ts +7 -0
  38. package/src/lib/tenant-email-catalog.js +10 -591
  39. package/src/lib/tenant-email-catalog.js.map +1 -1
  40. package/src/lib/tenant-emails.generated.d.ts +11 -0
  41. package/src/lib/tenant-emails.generated.js +594 -0
  42. package/src/lib/tenant-emails.generated.js.map +1 -0
@@ -13,7 +13,8 @@
13
13
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
- */ /**
16
+ */ import { PLUGIN_TENANT_EMAILS } from "./tenant-emails.generated.js";
17
+ /**
17
18
  * The transactional emails a SITE sends to its own end-users (AGL-769/770).
18
19
  *
19
20
  * Distinct from the platform system emails (mail Aglyn sends about the
@@ -21,596 +22,14 @@
21
22
  * list keyed for the host-scoped template store and the `renderHostEmail`
22
23
  * resolver; the console UI groups by `pluginId`. Code-defined and fixed — the
23
24
  * set is whatever the plugins actually send.
24
- */ export const TENANT_EMAILS = [
25
- // ── Bookings ──────────────────────────────────────────────────────────
26
- {
27
- key: 'booking-confirmed',
28
- name: 'Booking confirmed',
29
- description: 'Confirms a booking to the customer, for paid and free services.',
30
- pluginId: 'bookings',
31
- plugin: 'Bookings',
32
- control: 'besigner',
33
- defaultSubject: 'Booking confirmed: {{service.name}}',
34
- mergeTokens: [
35
- {
36
- name: 'name',
37
- description: "The customer's name",
38
- sample: 'Alex'
39
- },
40
- {
41
- name: 'service.name',
42
- description: 'The booked service',
43
- sample: 'Consultation'
44
- },
45
- {
46
- name: 'when',
47
- description: 'Formatted date and time of the booking',
48
- sample: 'Monday, June 1, 2026 at 9:00 AM'
49
- },
50
- {
51
- name: 'timezone',
52
- description: 'Timezone the time is shown in',
53
- sample: 'UTC'
54
- },
55
- {
56
- name: 'booking.ref',
57
- description: 'Booking reference id',
58
- sample: 'bk_123'
59
- }
60
- ],
61
- defaultBody: [
62
- {
63
- block: 'text',
64
- text: 'Booking confirmed',
65
- variant: 'heading'
66
- },
67
- {
68
- block: 'text',
69
- text: 'Hi {{name}}, your booking for "{{service.name}}" is confirmed for ' + '{{when}} ({{timezone}}).',
70
- variant: 'body'
71
- },
72
- {
73
- block: 'text',
74
- text: 'Reference: {{booking.ref}}',
75
- variant: 'caption'
76
- }
77
- ],
78
- footerReason: 'You’re receiving this because you booked with {{host.businessName}}.'
79
- },
80
- {
81
- key: 'booking-reminder',
82
- name: 'Booking reminder',
83
- description: 'Reminds the customer of an upcoming booking.',
84
- pluginId: 'bookings',
85
- plugin: 'Bookings',
86
- control: 'besigner',
87
- defaultSubject: 'Reminder: {{service.name}} is coming up',
88
- mergeTokens: [
89
- {
90
- name: 'name',
91
- description: "The customer's name",
92
- sample: 'Alex'
93
- },
94
- {
95
- name: 'service.name',
96
- description: 'The booked service',
97
- sample: 'Consultation'
98
- },
99
- {
100
- name: 'when',
101
- description: 'Formatted date and time of the booking',
102
- sample: 'Tomorrow at 9:00 AM'
103
- }
104
- ],
105
- defaultBody: [
106
- {
107
- block: 'text',
108
- text: 'Hi {{name}}, this is a reminder that "{{service.name}}" is ' + 'coming up on {{when}}.',
109
- variant: 'body'
110
- }
111
- ],
112
- footerReason: 'You’re receiving this because you have a booking with {{host.businessName}}.'
113
- },
114
- // ── Commerce (fixed for now; flips to `besigner` when the send site is
115
- // wired to renderHostEmail — AGL-770) ────────────────────────────────
116
- {
117
- key: 'order-receipt',
118
- name: 'Order receipt',
119
- description: 'Sent to the buyer after a successful order or checkout.',
120
- pluginId: 'commerce',
121
- plugin: 'Commerce',
122
- control: 'besigner',
123
- defaultSubject: 'Receipt for your order',
124
- mergeTokens: [
125
- {
126
- name: 'order.summary',
127
- description: 'The ordered items, one per line (with any license/download links)',
128
- sample: 'House Blend × 2 — $24.00'
129
- },
130
- {
131
- name: 'order.total',
132
- description: 'Order total',
133
- sample: '$24.00'
134
- },
135
- {
136
- name: 'order.ref',
137
- description: 'Order reference id',
138
- sample: 'cs_test_123'
139
- }
140
- ],
141
- defaultBody: [
142
- {
143
- block: 'text',
144
- text: 'Thanks for your purchase!',
145
- variant: 'heading'
146
- },
147
- {
148
- block: 'text',
149
- text: '{{order.summary}}',
150
- variant: 'body'
151
- },
152
- {
153
- block: 'text',
154
- text: 'Total: {{order.total}}',
155
- variant: 'body'
156
- },
157
- {
158
- block: 'text',
159
- text: 'Order reference: {{order.ref}}',
160
- variant: 'caption'
161
- }
162
- ],
163
- footerReason: 'You’re receiving this because you placed an order with {{host.businessName}}.'
164
- },
165
- {
166
- key: 'sale-notification',
167
- name: 'New sale',
168
- description: 'Notifies the seller when an order is placed.',
169
- pluginId: 'commerce',
170
- plugin: 'Commerce',
171
- control: 'besigner',
172
- defaultSubject: 'New order on {{site.name}}',
173
- mergeTokens: [
174
- {
175
- name: 'site.name',
176
- description: 'The site the sale happened on',
177
- sample: 'Northwind Coffee'
178
- },
179
- {
180
- name: 'order.summary',
181
- description: 'The ordered items',
182
- sample: 'House Blend — $12.00'
183
- },
184
- {
185
- name: 'order.total',
186
- description: 'Order total',
187
- sample: '$12.00'
188
- },
189
- {
190
- name: 'buyer.email',
191
- description: "The buyer's email",
192
- sample: 'buyer@example.com'
193
- },
194
- {
195
- name: 'order.ref',
196
- description: 'Order reference id',
197
- sample: 'cs_test_123'
198
- }
199
- ],
200
- defaultBody: [
201
- {
202
- block: 'text',
203
- text: 'You made a sale',
204
- variant: 'heading'
205
- },
206
- {
207
- block: 'text',
208
- text: 'A new order came in on {{site.name}}.',
209
- variant: 'body'
210
- },
211
- {
212
- block: 'text',
213
- text: '{{order.summary}}',
214
- variant: 'body'
215
- },
216
- {
217
- block: 'text',
218
- text: 'Total: {{order.total}}',
219
- variant: 'body'
220
- },
221
- {
222
- block: 'text',
223
- text: 'Buyer: {{buyer.email}} · Order {{order.ref}}',
224
- variant: 'caption'
225
- }
226
- ],
227
- footerReason: 'You’re receiving this because you manage {{host.businessName}}.'
228
- },
229
- {
230
- key: 'reservation-confirmed',
231
- name: 'Reservation confirmed',
232
- description: 'Confirms a paid reservation to the customer.',
233
- pluginId: 'commerce',
234
- plugin: 'Commerce',
235
- control: 'besigner',
236
- defaultSubject: 'Reservation confirmed',
237
- mergeTokens: [
238
- {
239
- name: 'reservation.checkIn',
240
- description: 'Check-in date',
241
- sample: 'Mon, 01 Jun 2026'
242
- },
243
- {
244
- name: 'reservation.nights',
245
- description: 'Number of nights',
246
- sample: '2'
247
- },
248
- {
249
- name: 'reservation.paid',
250
- description: 'Amount paid today',
251
- sample: '$240.00'
252
- },
253
- {
254
- name: 'reservation.ref',
255
- description: 'Reservation reference id',
256
- sample: 'resv_123'
257
- }
258
- ],
259
- defaultBody: [
260
- {
261
- block: 'text',
262
- text: 'Reservation confirmed',
263
- variant: 'heading'
264
- },
265
- {
266
- block: 'text',
267
- text: 'Your stay is confirmed!',
268
- variant: 'body'
269
- },
270
- {
271
- block: 'text',
272
- text: 'Check-in: {{reservation.checkIn}}',
273
- variant: 'body'
274
- },
275
- {
276
- block: 'text',
277
- text: 'Nights: {{reservation.nights}}',
278
- variant: 'body'
279
- },
280
- {
281
- block: 'text',
282
- text: 'Paid today: {{reservation.paid}}',
283
- variant: 'body'
284
- },
285
- {
286
- block: 'text',
287
- text: 'Reference: {{reservation.ref}}',
288
- variant: 'caption'
289
- }
290
- ],
291
- footerReason: 'You’re receiving this because you made a reservation with {{host.businessName}}.'
292
- },
293
- {
294
- key: 'gift-card',
295
- name: 'Gift card delivery',
296
- description: 'Delivers a purchased gift card to its recipient.',
297
- pluginId: 'commerce',
298
- plugin: 'Commerce',
299
- control: 'besigner',
300
- defaultSubject: 'Your gift card',
301
- mergeTokens: [
302
- {
303
- name: 'giftcard.code',
304
- description: 'The gift card code',
305
- sample: 'GC-ABC123DEF456'
306
- },
307
- {
308
- name: 'giftcard.value',
309
- description: 'The gift card value',
310
- sample: '$25.00'
311
- }
312
- ],
313
- defaultBody: [
314
- {
315
- block: 'text',
316
- text: 'Your gift card',
317
- variant: 'heading'
318
- },
319
- {
320
- block: 'text',
321
- text: 'Gift card code: {{giftcard.code}}',
322
- variant: 'body'
323
- },
324
- {
325
- block: 'text',
326
- text: 'Value: {{giftcard.value}}',
327
- variant: 'body'
328
- },
329
- {
330
- block: 'text',
331
- text: 'Enter it at checkout to apply the balance.',
332
- variant: 'body'
333
- }
334
- ],
335
- footerReason: 'You’re receiving this because a gift card from {{host.businessName}} was sent to this address.'
336
- },
337
- {
338
- key: 'supplier-fulfillment',
339
- name: 'Supplier fulfillment',
340
- description: 'Tells a dropship supplier there is a new order to fulfill.',
341
- pluginId: 'commerce',
342
- plugin: 'Commerce',
343
- control: 'fixed'
344
- },
345
- {
346
- key: 'back-in-stock',
347
- name: 'Back in stock',
348
- description: 'Tells a customer a product they watched is available again.',
349
- pluginId: 'commerce',
350
- plugin: 'Commerce',
351
- control: 'besigner',
352
- defaultSubject: 'Back in stock: {{product.name}}',
353
- mergeTokens: [
354
- {
355
- name: 'product.name',
356
- description: 'The product that restocked',
357
- sample: 'House Blend'
358
- },
359
- {
360
- name: 'product.url',
361
- description: 'Link to the product page',
362
- sample: '/products/house-blend'
363
- }
364
- ],
365
- defaultBody: [
366
- {
367
- block: 'text',
368
- text: '{{product.name}} is available again — grab it before it sells out.',
369
- variant: 'body'
370
- },
371
- {
372
- block: 'button',
373
- label: 'View product',
374
- href: '{{product.url}}'
375
- }
376
- ],
377
- footerReason: 'You’re receiving this because you asked {{host.businessName}} to tell you when this was back.'
378
- },
379
- {
380
- key: 'abandoned-cart',
381
- name: 'Abandoned cart',
382
- description: 'Reminds a shopper of items left in their cart.',
383
- // The cron refuses to send this without the entitlement
384
- // (`process-abandoned.ts:92`), so the console has to say so (AGL-2081).
385
- requiresFeature: 'abandonedCart',
386
- pluginId: 'commerce',
387
- plugin: 'Commerce',
388
- control: 'besigner',
389
- defaultSubject: 'You left something in your cart',
390
- mergeTokens: [
391
- {
392
- name: 'cart.url',
393
- description: 'Link back to the shopper cart',
394
- sample: 'https://shop.example.com/cart'
395
- }
396
- ],
397
- defaultBody: [
398
- {
399
- block: 'text',
400
- text: 'Your cart is still waiting — pick up where you left off.',
401
- variant: 'body'
402
- },
403
- {
404
- block: 'button',
405
- label: 'Return to cart',
406
- href: '{{cart.url}}'
407
- },
408
- {
409
- block: 'text',
410
- text: 'Your items are held but not reserved, so they may sell out.',
411
- variant: 'caption'
412
- }
413
- ],
414
- footerReason: 'You’re receiving this because you started a checkout with {{host.businessName}}.'
415
- },
416
- {
417
- key: 'member-post',
418
- name: 'New member post',
419
- description: 'Notifies members when new members-only content is posted.',
420
- pluginId: 'commerce',
421
- plugin: 'Commerce',
422
- control: 'besigner',
423
- defaultSubject: '{{post.title}}',
424
- mergeTokens: [
425
- {
426
- name: 'post.title',
427
- description: 'The post’s title',
428
- sample: 'This month in the studio'
429
- },
430
- {
431
- name: 'post.body',
432
- description: 'The post, as its author wrote it',
433
- sample: 'Three new pieces are up for members first.'
434
- }
435
- ],
436
- defaultBody: [
437
- {
438
- block: 'text',
439
- text: '{{post.title}}',
440
- variant: 'heading'
441
- },
442
- {
443
- block: 'text',
444
- text: '{{post.body}}',
445
- variant: 'body'
446
- }
447
- ],
448
- footerReason: 'You’re receiving this because you’re a member of {{host.businessName}}.'
449
- },
450
- {
451
- key: 'member-password-reset',
452
- name: 'Member password reset',
453
- description: "Resets a site member's password — a store-member account, separate " + 'from a console login. Sent when the member asks, and when a site ' + 'administrator starts a reset for them.',
454
- pluginId: 'commerce',
455
- plugin: 'Commerce',
456
- control: 'besigner',
457
- defaultSubject: 'Reset your {{site.name}} password',
458
- mergeTokens: [
459
- {
460
- name: 'site.name',
461
- description: 'The site’s name',
462
- sample: 'Northwind Coffee'
463
- },
464
- {
465
- name: 'reset.intro',
466
- description: 'Who started the reset',
467
- sample: 'Someone asked to reset the password for your Northwind Coffee account.'
468
- },
469
- {
470
- name: 'resetUrl',
471
- description: 'The one-time reset link',
472
- sample: 'https://shop.example.com/recover?token=…'
473
- },
474
- {
475
- name: 'reset.note',
476
- description: 'How long the link lasts, and what to do if unexpected',
477
- sample: 'The link works once and expires in 1 hour. If you did not ask for ' + 'this, you can safely ignore this email — your password is unchanged.'
478
- }
479
- ],
480
- defaultBody: [
481
- {
482
- block: 'text',
483
- text: 'Reset your password',
484
- variant: 'heading'
485
- },
486
- {
487
- block: 'text',
488
- text: '{{reset.intro}}',
489
- variant: 'body'
490
- },
491
- {
492
- block: 'button',
493
- label: 'Set a new password',
494
- href: '{{resetUrl}}'
495
- },
496
- {
497
- block: 'text',
498
- text: '{{reset.note}}',
499
- variant: 'caption'
500
- }
501
- ],
502
- footerReason: 'You’re receiving this because a password reset was started for your ' + '{{host.businessName}} account.'
503
- },
504
- {
505
- key: 'member-password-changed',
506
- name: 'Member password changed',
507
- description: 'Tells a site member that a site administrator set a new password on ' + 'their account.',
508
- pluginId: 'commerce',
509
- plugin: 'Commerce',
510
- control: 'besigner',
511
- defaultSubject: 'Your {{site.name}} password was changed',
512
- mergeTokens: [
513
- {
514
- name: 'site.name',
515
- description: 'The site’s name',
516
- sample: 'Northwind Coffee'
517
- },
518
- {
519
- name: 'signInUrl',
520
- description: 'Where the member signs back in',
521
- sample: 'https://shop.example.com'
522
- }
523
- ],
524
- defaultBody: [
525
- {
526
- block: 'text',
527
- text: 'Your password was changed',
528
- variant: 'heading'
529
- },
530
- {
531
- block: 'text',
532
- text: 'An administrator of {{site.name}} set a new password on your ' + 'account. You have been signed out on every device and will need ' + 'the new password to sign back in.',
533
- variant: 'body'
534
- },
535
- {
536
- block: 'button',
537
- label: 'Sign in',
538
- href: '{{signInUrl}}'
539
- },
540
- {
541
- block: 'text',
542
- text: 'If you did not expect this, contact the site owner.',
543
- variant: 'caption'
544
- }
545
- ],
546
- footerReason: 'You’re receiving this because the password on your ' + '{{host.businessName}} account was changed.'
547
- },
548
- {
549
- key: 'newsletter-confirmation',
550
- name: 'Subscription confirmation',
551
- description: 'Asks someone who signed up for a site’s emails to confirm the address ' + 'before anything is sent to it.',
552
- pluginId: 'commerce',
553
- plugin: 'Commerce',
554
- control: 'besigner',
555
- defaultSubject: 'Confirm your subscription',
556
- mergeTokens: [
557
- {
558
- name: 'stream.name',
559
- description: 'What they signed up for',
560
- sample: 'our newsletter'
561
- },
562
- {
563
- name: 'confirmUrl',
564
- description: 'The confirmation link',
565
- sample: 'https://shop.example.com/subscribe/confirm?token=…'
566
- }
567
- ],
568
- defaultBody: [
569
- {
570
- block: 'text',
571
- text: 'Confirm your subscription',
572
- variant: 'heading'
573
- },
574
- {
575
- block: 'text',
576
- text: 'Please confirm that you want to receive {{stream.name}} at this address.',
577
- variant: 'body'
578
- },
579
- {
580
- block: 'button',
581
- label: 'Confirm my subscription',
582
- href: '{{confirmUrl}}'
583
- },
584
- {
585
- block: 'text',
586
- text: 'The link works for three days. If you did not sign up, ignore this ' + 'message — nothing will be sent.',
587
- variant: 'caption'
588
- }
589
- ],
590
- footerReason: 'You’re receiving this because this address was entered on ' + '{{host.businessName}}’s signup form.'
591
- },
592
- // ── Marketing / Workflows (authored in their own UIs) ──────────────────
593
- {
594
- key: 'campaign',
595
- name: 'Campaign broadcast',
596
- description: "A campaign sent to the site's subscriber list.",
597
- pluginId: 'marketing',
598
- plugin: 'Marketing',
599
- control: 'external',
600
- authoredIn: 'Marketing → Campaigns',
601
- footerReason: 'You’re receiving this email from {{host.businessName}}.'
602
- },
603
- {
604
- key: 'workflow-email',
605
- name: 'Workflow email step',
606
- description: "An email sent by a workflow's send-email action when its trigger " + 'fires.',
607
- pluginId: 'workflows',
608
- plugin: 'Workflows',
609
- control: 'external',
610
- authoredIn: 'the workflow that sends it',
611
- footerReason: 'You’re receiving this because you’re in touch with {{host.businessName}}.'
612
- }
613
- ];
25
+ *
26
+ * Each plugin declares its own entries (its `tenantEmails` entry in
27
+ * plugins.config.json) and the manifest generator compiles them here, in
28
+ * config order (AGL-3080). Compiled rather than registered, because the send
29
+ * path reads this list without loading any plugin: a registry it had not
30
+ * filled would find no entry and send the text card instead of the site's
31
+ * designed email, with nothing failing.
32
+ */ export const TENANT_EMAILS = PLUGIN_TENANT_EMAILS;
614
33
  /** Firestore subcollection under a host holding its designed templates. */ export const TENANT_EMAIL_COLLECTION = 'emailTemplates';
615
34
  export function getTenantEmail(key) {
616
35
  return TENANT_EMAILS.find((entry)=>entry.key === key);