@visulima/email 1.0.0-alpha.33 → 1.0.0-alpha.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +112 -0
- package/README.md +40 -0
- package/dist/crypto/index.js +1 -1
- package/dist/index.d.ts +34 -3
- package/dist/index.js +1 -1
- package/dist/packem_shared/{DkimSigner-CX2yGILn.js → DkimSigner-CT2DSHD1.js} +1 -1
- package/dist/packem_shared/Mail-BWSWWq6m.js +1 -0
- package/dist/packem_shared/{MailMessage-Dy1gP5e-.js → MailMessage-BvaH5tZZ.js} +1 -1
- package/dist/packem_shared/{SmimeEncrypter-DInfo-l0.js → SmimeEncrypter-ZhHEgDwY.js} +1 -1
- package/dist/packem_shared/{SmimeSigner-CSWbZ41O.js → SmimeSigner-CYSVF6ez.js} +1 -1
- package/dist/packem_shared/aggregate-features-BvgdYul-.js +1 -0
- package/dist/packem_shared/{detectMimeType-BtkVEtZF.js → detectMimeType-bo5oxfnt.js} +1 -1
- package/dist/packem_shared/failoverProvider-D90MHT2T.js +1 -0
- package/dist/packem_shared/readFile-BAVMZg5e-C4whBIPd.js +1 -0
- package/dist/packem_shared/roundRobinProvider-B_60F0BC.js +1 -0
- package/dist/providers/failover/index.js +1 -1
- package/dist/providers/roundrobin/index.js +1 -1
- package/dist/utils/validation/check-feature-support.d.ts +53 -0
- package/dist/utils/validation/check-feature-support.js +1 -0
- package/package.json +5 -1
- package/dist/packem_shared/Mail-KMrKXmyB.js +0 -1
- package/dist/packem_shared/failoverProvider-W5ctAhdC.js +0 -1
- package/dist/packem_shared/readFile-BAVMZg5e-CTXYIyEU.js +0 -1
- package/dist/packem_shared/roundRobinProvider-FvZQKl6n.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,115 @@
|
|
|
1
|
+
## @visulima/email [1.0.0-alpha.34](https://github.com/visulima/visulima/compare/@visulima/email@1.0.0-alpha.33...@visulima/email@1.0.0-alpha.34) (2026-06-02)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* **email:** add fail-fast capability guard ([#657](https://github.com/visulima/visulima/issues/657)) ([81f24ab](https://github.com/visulima/visulima/commit/81f24abcde5cb8b6bbbd989a5ad397eefb3292ab))
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
* **tests:** revert unsafe vitest autofixes from the lint sweep ([378f27c](https://github.com/visulima/visulima/commit/378f27caa370f1d3188aef2ed36d46839abc88c4))
|
|
10
|
+
|
|
11
|
+
### Miscellaneous Chores
|
|
12
|
+
|
|
13
|
+
* apply eslint + prettier autofixes across packages ([c1bb784](https://github.com/visulima/visulima/commit/c1bb7848a0d93d0dfe2960c77e3cda22239c79a0))
|
|
14
|
+
|
|
15
|
+
### Tests
|
|
16
|
+
|
|
17
|
+
* **email:** cover address normalization branches ([128f9d4](https://github.com/visulima/visulima/commit/128f9d485b0007636cf369f0c9a435c50d445794))
|
|
18
|
+
* **email:** cover ahasend request, attachment and availability branches ([747ba3c](https://github.com/visulima/visulima/commit/747ba3cef6b84cd79d82b8441cb250032e9247eb))
|
|
19
|
+
* **email:** cover ahasend send and messageId branches ([b9c5085](https://github.com/visulima/visulima/commit/b9c5085546f2abad3515d9d899a7f40f2b12cb58))
|
|
20
|
+
* **email:** cover angle-bracket first-bracket fallback ([3f6f8b9](https://github.com/visulima/visulima/commit/3f6f8b9c6d44d370140d59146d8446be3a5b035a))
|
|
21
|
+
* **email:** cover attach/embed empty basename fallback ([b5be774](https://github.com/visulima/visulima/commit/b5be7745cfeed21ec92911f1673c712744f2f311))
|
|
22
|
+
* **email:** cover attachment content-type fallbacks ([94bf172](https://github.com/visulima/visulima/commit/94bf172278f65af5c3e4260ae2aeaf7ed35ca67a))
|
|
23
|
+
* **email:** cover attachment default content type ([ac83c50](https://github.com/visulima/visulima/commit/ac83c501a40a874e721d9a58e5e5b0fd6125795e))
|
|
24
|
+
* **email:** cover aws-ses branch paths ([c299c28](https://github.com/visulima/visulima/commit/c299c2873fcc309ce2c6695fb148dfab36bf795d))
|
|
25
|
+
* **email:** cover aws-ses initialize, isAvailable, request errors and SES params ([b0c90c7](https://github.com/visulima/visulima/commit/b0c90c7245d3a68d891e1673e7acf8d6a9f129d7))
|
|
26
|
+
* **email:** cover azure availability non-error branch ([1fea2cb](https://github.com/visulima/visulima/commit/1fea2cb1bd6908ef87b2de109b7e7159015f30ad))
|
|
27
|
+
* **email:** cover azure connection-string auth and send/getEmail branches ([462d4f9](https://github.com/visulima/visulima/commit/462d4f95bb8d59fd459b1cd812640028abf60237))
|
|
28
|
+
* **email:** cover azure getEmail auth, isAvailable status codes and send failure ([d03fe62](https://github.com/visulima/visulima/commit/d03fe62ceffce0598af844453e40daa64817bb0a))
|
|
29
|
+
* **email:** cover brevo getEmail, replyTo array branches, batch and attachments ([e967213](https://github.com/visulima/visulima/commit/e967213b93e24075d62bd6e12e43015fed045dda))
|
|
30
|
+
* **email:** cover brevo send and getEmail branches ([78389b9](https://github.com/visulima/visulima/commit/78389b90d0bf19e89e6e58ecdb07887a1e8618c4))
|
|
31
|
+
* **email:** cover build-mime-message attachment headers and encodings ([1095d47](https://github.com/visulima/visulima/commit/1095d471f8ed38755b3a847f3b39fdb3e7621722))
|
|
32
|
+
* **email:** cover dkim empty-body canonicalization ([b5a7f4c](https://github.com/visulima/visulima/commit/b5a7f4c24ca211d0ae76d8df9a9f667e890cfcc0))
|
|
33
|
+
* **email:** cover dkim-signer canonicalization branches ([d6c0bec](https://github.com/visulima/visulima/commit/d6c0bece326173678650f5a4f30078e35e17cffb))
|
|
34
|
+
* **email:** cover failover init failures and fallbacks ([2cbead7](https://github.com/visulima/visulima/commit/2cbead75a564c25d3f921e80f49b099595927628))
|
|
35
|
+
* **email:** cover failover unnamed-provider init failure ([38e0060](https://github.com/visulima/visulima/commit/38e0060f3cdfc963b6a85d725b7519b0fa188fb6))
|
|
36
|
+
* **email:** cover handlebars register error rethrow ([b740f8f](https://github.com/visulima/visulima/commit/b740f8f2ed121a953cb5e02f81eebef4f172b598))
|
|
37
|
+
* **email:** cover http initialize, availability, and cc/bcc branches ([b2f6509](https://github.com/visulima/visulima/commit/b2f6509c67fd3ba5e4b4e20be8c48965fa0e1928))
|
|
38
|
+
* **email:** cover http send, init, and message-id branches ([62719bd](https://github.com/visulima/visulima/commit/62719bd9e9e9dece8de1e26b44854c73923b4cf8))
|
|
39
|
+
* **email:** cover in-memory cache delete, clear and eviction ([e4b0333](https://github.com/visulima/visulima/commit/e4b03330889d2f5e822fa61b201411991c19d498))
|
|
40
|
+
* **email:** cover infobip request, attachment and availability branches ([2dac360](https://github.com/visulima/visulima/commit/2dac3608200f75f7f795accadf226f242937831b))
|
|
41
|
+
* **email:** cover infobip send and getEmail branches ([4d8719d](https://github.com/visulima/visulima/commit/4d8719db845882f0c52d580b47f040e5533fbae8))
|
|
42
|
+
* **email:** cover Mail logger, sendMany, and global-config merge paths ([bd5c50b](https://github.com/visulima/visulima/commit/bd5c50be8b6aa110086f0c9975440decf1189ab6))
|
|
43
|
+
* **email:** cover mail message replyTo setter ([afe8dae](https://github.com/visulima/visulima/commit/afe8daed7363d7fdd7354b8e3190602fdc635347))
|
|
44
|
+
* **email:** cover mail send and batch branch paths ([b45b1b0](https://github.com/visulima/visulima/commit/b45b1b0e0066a276bee5a6bfddde13a63f7f415b))
|
|
45
|
+
* **email:** cover mail-message auto-text generation ([2c44d7f](https://github.com/visulima/visulima/commit/2c44d7fa6636ca4c88e38504aa988855f6387436))
|
|
46
|
+
* **email:** cover mail-message logger branches ([23b4496](https://github.com/visulima/visulima/commit/23b44963ed8edf4e794544bdcde94f2d3798994a))
|
|
47
|
+
* **email:** cover mailersend request, attachment and availability branches ([999e22c](https://github.com/visulima/visulima/commit/999e22c94828e382f962d3bb695f2a63bc3e985b))
|
|
48
|
+
* **email:** cover mailersend send and getEmail branches ([e20e805](https://github.com/visulima/visulima/commit/e20e8055fc8058a471fd45fb1526a6e35504865e))
|
|
49
|
+
* **email:** cover mailgun getEmail events, tracking flags, form encoding and attachments ([cf63a01](https://github.com/visulima/visulima/commit/cf63a013cdcfc546fb731ad7c9b381b637490bd5))
|
|
50
|
+
* **email:** cover mailgun send and getEmail branches ([3f63011](https://github.com/visulima/visulima/commit/3f63011a43752e8ba4f19e11857843b1f4830557))
|
|
51
|
+
* **email:** cover mailjet getEmail, send failure, campaign fields and attachments ([2f4147f](https://github.com/visulima/visulima/commit/2f4147ff105386ac13700154a2fb5e081fa6d70b))
|
|
52
|
+
* **email:** cover mailjet send and getEmail branches ([d692d34](https://github.com/visulima/visulima/commit/d692d346dc179f9778857d502824b3f68cd0f769))
|
|
53
|
+
* **email:** cover mailomat and mailpace getEmail and edge paths ([519d057](https://github.com/visulima/visulima/commit/519d057b19f23f2157c379595fa041fb17fff189))
|
|
54
|
+
* **email:** cover mailomat getEmail and branch paths ([8b52328](https://github.com/visulima/visulima/commit/8b52328146ccb0f6f2a10ce4652679e13debdb1a))
|
|
55
|
+
* **email:** cover mailomat send/getEmail branch paths ([df5b5a4](https://github.com/visulima/visulima/commit/df5b5a446c8f373d09f5cab3d98280b35d495657))
|
|
56
|
+
* **email:** cover mailpace availability and send branches ([b89b4ad](https://github.com/visulima/visulima/commit/b89b4ad51cde34d58656944a171434d6b2d361d7))
|
|
57
|
+
* **email:** cover mailpace logger branch ([8e4fe77](https://github.com/visulima/visulima/commit/8e4fe779599f5ad43a63c24f7e7e9fa4d5b631ce))
|
|
58
|
+
* **email:** cover mailtrap request, attachment and availability branches ([ee23353](https://github.com/visulima/visulima/commit/ee2335365cf6aac08578e7010b20752768bc3c8d))
|
|
59
|
+
* **email:** cover mailtrap send and getEmail branches ([be3e1a3](https://github.com/visulima/visulima/commit/be3e1a3b85fc49c7f9848d3d5f12b1aa2df18ab8))
|
|
60
|
+
* **email:** cover make-request non-error rejection ([9626626](https://github.com/visulima/visulima/commit/9626626f57afca5b8dcbb1653d9796575a17d666))
|
|
61
|
+
* **email:** cover make-request timeout cleanup, json fallback and body coercion ([3d76d4e](https://github.com/visulima/visulima/commit/3d76d4ee92da4159ea9a5c6d247ee22f680ed3a4))
|
|
62
|
+
* **email:** cover mandrill request, analytics and availability branches ([1233ff3](https://github.com/visulima/visulima/commit/1233ff327f34246ea2363a0b914e88d7c8471d78))
|
|
63
|
+
* **email:** cover mandrill send and template branches ([297754f](https://github.com/visulima/visulima/commit/297754f8aa984269da98a082e8252b4cca9f1fc2))
|
|
64
|
+
* **email:** cover mock init, recipient, and response branches ([5b301f5](https://github.com/visulima/visulima/commit/5b301f5d8de4bc0778379d9b2da8024913f2bcc2))
|
|
65
|
+
* **email:** cover mock provider send/retrieve catch paths ([bb47683](https://github.com/visulima/visulima/commit/bb47683295e249f37cea1ea6bfb6bdda9f29a8d5))
|
|
66
|
+
* **email:** cover mx lookup non-error rejection ([e52a2b6](https://github.com/visulima/visulima/commit/e52a2b663fe795a1c6f8727dc6ea655425c140b0))
|
|
67
|
+
* **email:** cover nodemailer branch paths and fix lint ([6b5b72b](https://github.com/visulima/visulima/commit/6b5b72b0d8404a25d386d9d6cd0b79199550a1ed))
|
|
68
|
+
* **email:** cover opentelemetry branches and fix lint ([6ac926b](https://github.com/visulima/visulima/commit/6ac926b484a229a66ac38c98dbe8e0c47e431ee8))
|
|
69
|
+
* **email:** cover parse-address domain-literal and quoted-local edge cases ([fa909c7](https://github.com/visulima/visulima/commit/fa909c735d849997f99254f5dcfd0a3bf62b4804))
|
|
70
|
+
* **email:** cover parse-address quote after at-sign ([49143f6](https://github.com/visulima/visulima/commit/49143f65e65b317d1da6e42cab7d2c03f1e63fca))
|
|
71
|
+
* **email:** cover payload builder recipient/template branches ([e629d81](https://github.com/visulima/visulima/commit/e629d814c02576c4b24035235b4fdadf4021a61e))
|
|
72
|
+
* **email:** cover plunk getEmail throw and attachment branches ([c24c2bf](https://github.com/visulima/visulima/commit/c24c2bf0e14247a8bd8538b679ba0f869276107a))
|
|
73
|
+
* **email:** cover plunk send/getEmail branch paths ([96c2097](https://github.com/visulima/visulima/commit/96c2097ae3cb3bec00a57a04d768c83cd816c1db))
|
|
74
|
+
* **email:** cover postal request, attachment and availability branches ([8617ce2](https://github.com/visulima/visulima/commit/8617ce2e43a5244a94434a0995367f5bbb4669b3))
|
|
75
|
+
* **email:** cover postal send and getEmail branches ([9e78f76](https://github.com/visulima/visulima/commit/9e78f769faf6dcb38311995d1f26dee11f2727c8))
|
|
76
|
+
* **email:** cover postmark getEmail, template alias, metadata and attachments ([58236b4](https://github.com/visulima/visulima/commit/58236b47e751a893cca3762e11600fd29fecf4a8))
|
|
77
|
+
* **email:** cover postmark send and template branches ([5c298da](https://github.com/visulima/visulima/commit/5c298da4a20d1125d82cb36cb3c324948ab7c228))
|
|
78
|
+
* **email:** cover provider address formatters ([dd4da80](https://github.com/visulima/visulima/commit/dd4da80afd21074fb145b65d75ad44da5bfaac2f))
|
|
79
|
+
* **email:** cover reply-to validation and mx cache-on-error ([16cc9c2](https://github.com/visulima/visulima/commit/16cc9c2f96368d364271a11a72ec679af5d3df0a))
|
|
80
|
+
* **email:** cover resend getEmail, isAvailable, and full send payload ([e0c4981](https://github.com/visulima/visulima/commit/e0c4981ece5a148c941b3239d53e87dd1b38cb48))
|
|
81
|
+
* **email:** cover resend send, getEmail, availability branches ([bfca30d](https://github.com/visulima/visulima/commit/bfca30d7387d9c351f4b201f21e287fc8a7b2eb6))
|
|
82
|
+
* **email:** cover roundrobin init, wait and failover branches ([8b42738](https://github.com/visulima/visulima/commit/8b427389ff13d9b5cf7d79e318522d54be103ac7))
|
|
83
|
+
* **email:** cover roundrobin name fallbacks and retry paths ([57d56c8](https://github.com/visulima/visulima/commit/57d56c8f8fca3ec17088b09000deac6d0c0707c2))
|
|
84
|
+
* **email:** cover scaleway branch and init failure paths ([5ca4c8f](https://github.com/visulima/visulima/commit/5ca4c8fa479b94d675bc5b6982d6dbe8564a4f0c))
|
|
85
|
+
* **email:** cover scaleway getEmail failure and attachment branches ([1fdbb2f](https://github.com/visulima/visulima/commit/1fdbb2f9404e988129ef485c3ec86a10f870b431))
|
|
86
|
+
* **email:** cover sendgrid getEmail, settings, send failure and attachments ([db99fc8](https://github.com/visulima/visulima/commit/db99fc82e925c5c1187c00185d11872ffc5b5247))
|
|
87
|
+
* **email:** cover sendgrid send and availability branches ([5bca44a](https://github.com/visulima/visulima/commit/5bca44a7fdde5cca30d4079b6ab222271eefb8ad))
|
|
88
|
+
* **email:** cover smime aes128/aes192 algorithm aliases ([715482a](https://github.com/visulima/visulima/commit/715482aeabd6b90949e4a0f70cc9c6b11f0e9170))
|
|
89
|
+
* **email:** cover smime build-message and algorithm paths ([49319c1](https://github.com/visulima/visulima/commit/49319c1c540dc5dd2a1b568791e40e246358c91b))
|
|
90
|
+
* **email:** cover smime empty-body and empty recipient ([bc8ab8c](https://github.com/visulima/visulima/commit/bc8ab8cae1f15c466dfb08eef07312081e358484))
|
|
91
|
+
* **email:** cover smtp 551/553 recipient rejections ([7c4630c](https://github.com/visulima/visulima/commit/7c4630c87496d62c371443412ecb22aabab44be7))
|
|
92
|
+
* **email:** cover smtp branch paths ([d0c135e](https://github.com/visulima/visulima/commit/d0c135eaf7739d1f3025060eaf0bf953c7d41d13))
|
|
93
|
+
* **email:** cover smtp provider via mock-socket harness ([08d98f9](https://github.com/visulima/visulima/commit/08d98f95bb677df4212928a9019cfd7cdf9de898))
|
|
94
|
+
* **email:** cover smtp verify cache write error ([eceaf97](https://github.com/visulima/visulima/commit/eceaf9785081ec4418db0e279009a0c2238a87e8))
|
|
95
|
+
* **email:** cover sweego branch and init failure paths ([99abf7a](https://github.com/visulima/visulima/commit/99abf7a3cd42fba2f4808539f4177368f7186de8))
|
|
96
|
+
* **email:** cover sweego getEmail throw and attachment branches ([139d0ca](https://github.com/visulima/visulima/commit/139d0ca18be97d91a92dbbf9dd6da81693375e0c))
|
|
97
|
+
* **email:** cover to-base64 buffer-less fallback and is-port-available ([c8c7454](https://github.com/visulima/visulima/commit/c8c7454bf0bcf9d734384bac21f24739eeb8de84))
|
|
98
|
+
* **email:** cover validate-email hyphen domain rejection paths ([125eab0](https://github.com/visulima/visulima/commit/125eab0d9a543196496aea6de7d8adf3b3441aae))
|
|
99
|
+
* **email:** cover verify-email mx and smtp branches ([70905d1](https://github.com/visulima/visulima/commit/70905d1430e00efea031116ac675ef30919cee51))
|
|
100
|
+
* **email:** cover verify-smtp socket state machine and caching ([2b84cc1](https://github.com/visulima/visulima/commit/2b84cc1e36c01ef067ec571acdcfe614d9b2d1dc))
|
|
101
|
+
* **email:** cover vue-email default data branch ([c51b812](https://github.com/visulima/visulima/commit/c51b812079f98eca77615c0c08fd206dfb67ad39))
|
|
102
|
+
* **email:** cover zeptomail send error detail and exception branches ([ea74549](https://github.com/visulima/visulima/commit/ea745494f693360cc48d12bfb2bd8af66be0395e))
|
|
103
|
+
* **email:** cover zeptomail send error/header/attachment branches ([5b78e15](https://github.com/visulima/visulima/commit/5b78e15a97a8f0070fe172e5dc92b0a3926bb01b))
|
|
104
|
+
* **email:** fix lint in smtp harness test ([87811af](https://github.com/visulima/visulima/commit/87811af4dc6dea41a5a6ea2f96e3af19b168a0b3))
|
|
105
|
+
* improve coverage across packages ([91bd6d3](https://github.com/visulima/visulima/commit/91bd6d3b61736e3c8bd1fc59b0b5955f76a5d323))
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
### Dependencies
|
|
109
|
+
|
|
110
|
+
* **@visulima/error:** upgraded to 6.0.0-alpha.31
|
|
111
|
+
* **@visulima/fs:** upgraded to 5.0.0-alpha.29
|
|
112
|
+
|
|
1
113
|
## @visulima/email [1.0.0-alpha.33](https://github.com/visulima/visulima/compare/@visulima/email@1.0.0-alpha.32...@visulima/email@1.0.0-alpha.33) (2026-05-27)
|
|
2
114
|
|
|
3
115
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -114,6 +114,46 @@ const message = new MailMessage().to("user@example.com").subject("Hello").html("
|
|
|
114
114
|
await mail.send(message);
|
|
115
115
|
```
|
|
116
116
|
|
|
117
|
+
### Capability Guard (fail-fast field support)
|
|
118
|
+
|
|
119
|
+
Every provider declares which capabilities it supports through its `features` flags (attachments, tagging, scheduling, HTML, custom headers, reply-to, templates, ...). Before a message is handed to the provider, `Mail` runs a fail-fast check: if the message uses a capability the provider has **explicitly** declared unsupported (`features[x] === false`), the send is rejected locally — no wasted network round-trip and no silent data loss.
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
import { createMail } from "@visulima/email";
|
|
123
|
+
import { awsSesProvider } from "@visulima/email/providers/aws-ses";
|
|
124
|
+
|
|
125
|
+
// AWS SES declares `tagging: false`
|
|
126
|
+
const mail = createMail(awsSesProvider({ accessKeyId, secretAccessKey, region }));
|
|
127
|
+
|
|
128
|
+
const result = await mail.send({
|
|
129
|
+
from: { email: "noreply@example.com" },
|
|
130
|
+
subject: "Hi",
|
|
131
|
+
tags: ["promo"], // not representable by AWS SES
|
|
132
|
+
text: "Body",
|
|
133
|
+
to: { email: "user@example.com" },
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
result.success; // false
|
|
137
|
+
(result.error as { code?: string }).code; // "UNSUPPORTED_FEATURES"
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Capabilities left `undefined` are treated as "unknown" and never rejected, so providers that publish a partial (or no) `features` map are never falsely blocked. The behaviour is configurable per `Mail` instance:
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
createMail(provider, { featureCheck: "error" }); // default — reject unsupported fields
|
|
144
|
+
createMail(provider, { featureCheck: "warn" }); // log a warning and send anyway
|
|
145
|
+
createMail(provider, { featureCheck: "off" }); // skip the check entirely
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
You can also run the check standalone (e.g. inside a custom provider):
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
import { checkFeatureSupport } from "@visulima/email";
|
|
152
|
+
// or the focused entry point: "@visulima/email/validation/check-feature-support"
|
|
153
|
+
|
|
154
|
+
const { supported, violations } = checkFeatureSupport(message, provider.features);
|
|
155
|
+
```
|
|
156
|
+
|
|
117
157
|
### Creating Draft Emails
|
|
118
158
|
|
|
119
159
|
You can create draft emails in EML (RFC 822) format without sending them. The `draft()` method returns the email as an EML string with an `X-Unsent: 1` header automatically added:
|
package/dist/crypto/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DkimSigner as m,createDkimSigner as i}from"../packem_shared/DkimSigner-
|
|
1
|
+
import{DkimSigner as m,createDkimSigner as i}from"../packem_shared/DkimSigner-CT2DSHD1.js";import{SmimeEncrypter as S,createSmimeEncrypter as n}from"../packem_shared/SmimeEncrypter-ZhHEgDwY.js";import{SmimeSigner as c,createSmimeSigner as p}from"../packem_shared/SmimeSigner-CYSVF6ez.js";export{m as DkimSigner,S as SmimeEncrypter,c as SmimeSigner,i as createDkimSigner,n as createSmimeEncrypter,p as createSmimeSigner};
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { E as EmailSigner, a as EmailEncrypter } from "./packem_shared/types.d-C
|
|
|
6
6
|
import { T as TemplateRenderer } from "./packem_shared/types.d-nyR1ty1Q.js";
|
|
7
7
|
import { a as Provider } from "./packem_shared/provider.d-DcfYeGJJ.js";
|
|
8
8
|
export { type P as ProviderFactory, d as defineProvider } from "./packem_shared/provider.d-DcfYeGJJ.js";
|
|
9
|
+
export { type FeatureSupportResult, type FeatureViolation, default as checkFeatureSupport } from "./utils/validation/check-feature-support.js";
|
|
9
10
|
/**
|
|
10
11
|
* Detects MIME type from filename using mime package.
|
|
11
12
|
* Falls back to application/octet-stream if not found.
|
|
@@ -585,6 +586,23 @@ declare class DraftMailMessage extends MailMessage {
|
|
|
585
586
|
*/
|
|
586
587
|
type SendableMessage = MailMessage | EmailOptions;
|
|
587
588
|
/**
|
|
589
|
+
* Controls the fail-fast capability guard that runs before a message is handed to the provider.
|
|
590
|
+
*
|
|
591
|
+
* `"error"` (default) rejects the send with a failed Result when the message uses a capability the provider has explicitly declared unsupported.
|
|
592
|
+
* `"warn"` logs a warning and sends anyway. `"off"` skips the check entirely.
|
|
593
|
+
*/
|
|
594
|
+
type FeatureCheckMode = "error" | "off" | "warn";
|
|
595
|
+
/**
|
|
596
|
+
* Options for a {@link Mail} instance.
|
|
597
|
+
*/
|
|
598
|
+
interface MailOptions {
|
|
599
|
+
/**
|
|
600
|
+
* How to handle messages that use capabilities the provider has declared unsupported.
|
|
601
|
+
* @default "error"
|
|
602
|
+
*/
|
|
603
|
+
featureCheck?: FeatureCheckMode;
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
588
606
|
* Global email configuration that applies to all emails sent through a Mail instance.
|
|
589
607
|
*/
|
|
590
608
|
interface MailGlobalConfig {
|
|
@@ -617,11 +635,13 @@ declare class Mail {
|
|
|
617
635
|
private logger?;
|
|
618
636
|
private loggerInstance?;
|
|
619
637
|
private globalConfig?;
|
|
638
|
+
private readonly featureCheck;
|
|
620
639
|
/**
|
|
621
640
|
* Creates a new Mail instance with a provider.
|
|
622
641
|
* @param provider The email provider instance.
|
|
642
|
+
* @param options Optional Mail configuration.
|
|
623
643
|
*/
|
|
624
|
-
constructor(provider: Provider);
|
|
644
|
+
constructor(provider: Provider, options?: MailOptions);
|
|
625
645
|
/**
|
|
626
646
|
* Sets the logger instance for this mail instance.
|
|
627
647
|
* @param logger The logger instance (Console) to use for logging.
|
|
@@ -742,6 +762,13 @@ declare class Mail {
|
|
|
742
762
|
signal?: AbortSignal;
|
|
743
763
|
}): AsyncIterable<Receipt>;
|
|
744
764
|
/**
|
|
765
|
+
* Runs the fail-fast capability guard for the configured {@link FeatureCheckMode}.
|
|
766
|
+
* @param emailOptions The fully-resolved email options about to be sent.
|
|
767
|
+
* @returns An {@link EmailError} when the send should be rejected, otherwise undefined.
|
|
768
|
+
* @private
|
|
769
|
+
*/
|
|
770
|
+
private assertFeatureSupport;
|
|
771
|
+
/**
|
|
745
772
|
* Builds email options from a MailMessage instance for draft creation.
|
|
746
773
|
* Applies global configuration before building to ensure required fields are set.
|
|
747
774
|
* @param message The MailMessage or DraftMailMessage instance.
|
|
@@ -774,12 +801,16 @@ declare class Mail {
|
|
|
774
801
|
/**
|
|
775
802
|
* Creates a new Mail instance with a provider.
|
|
776
803
|
* @param provider The email provider instance.
|
|
804
|
+
* @param options Optional Mail configuration, e.g. the {@link FeatureCheckMode}.
|
|
777
805
|
* @returns A new Mail instance.
|
|
778
806
|
* @example
|
|
779
807
|
* ```ts
|
|
780
808
|
* const mail = createMail(provider);
|
|
781
809
|
* mail.setFrom({ email: "noreply@example.com", name: "My App" });
|
|
810
|
+
*
|
|
811
|
+
* // Disable the fail-fast capability guard
|
|
812
|
+
* const lenient = createMail(provider, { featureCheck: "off" });
|
|
782
813
|
* ```
|
|
783
814
|
*/
|
|
784
|
-
declare const createMail: (provider: Provider) => Mail;
|
|
785
|
-
export { type Attachment, type AttachmentDataOptions, type AttachmentOptions, type CalendarEventOptions, type EmailAddress, EmailError, type EmailHeaders, type EmailOptions, type EmailResult, Mail, type MailGlobalConfig, MailMessage, type Priority, type Provider, type Receipt, RequiredOptionError, type Result, type SendableMessage, type TemplateRenderer, createMail, detectMimeType, generateContentId, readFileAsBuffer };
|
|
815
|
+
declare const createMail: (provider: Provider, options?: MailOptions) => Mail;
|
|
816
|
+
export { type Attachment, type AttachmentDataOptions, type AttachmentOptions, type CalendarEventOptions, type EmailAddress, EmailError, type EmailHeaders, type EmailOptions, type EmailResult, type FeatureCheckMode, Mail, type MailGlobalConfig, MailMessage, type MailOptions, type Priority, type Provider, type Receipt, RequiredOptionError, type Result, type SendableMessage, type TemplateRenderer, createMail, detectMimeType, generateContentId, readFileAsBuffer };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{detectMimeType as o,generateContentId as t,readFileAsBuffer as a}from"./packem_shared/detectMimeType-
|
|
1
|
+
import{detectMimeType as o,generateContentId as t,readFileAsBuffer as a}from"./packem_shared/detectMimeType-bo5oxfnt.js";import{default as p}from"./packem_shared/EmailError-zm2ffVav.js";import{default as d}from"./packem_shared/RequiredOptionError-CevW3u2K.js";import{Mail as l,createMail as u}from"./packem_shared/Mail-BWSWWq6m.js";import{MailMessage as s}from"./packem_shared/MailMessage-BvaH5tZZ.js";import{defineProvider as M}from"./packem_shared/defineProvider-CtLH0VBE.js";import{default as E}from"./utils/validation/check-feature-support.js";export{p as EmailError,l as Mail,s as MailMessage,d as RequiredOptionError,E as checkFeatureSupport,u as createMail,M as defineProvider,o as detectMimeType,t as generateContentId,a as readFileAsBuffer};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var v=Object.defineProperty;var m=(o,e)=>v(o,"name",{value:e,configurable:!0});import{createRequire as w}from"node:module";import{B as x}from"./readFile-BAVMZg5e-
|
|
1
|
+
var v=Object.defineProperty;var m=(o,e)=>v(o,"name",{value:e,configurable:!0});import{createRequire as w}from"node:module";import{B as x}from"./readFile-BAVMZg5e-C4whBIPd.js";import{i as z}from"./headers-to-record-Qo124ImV.js";const C=w(import.meta.url),p=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=m(o=>{if(typeof p<"u"&&p.versions&&p.versions.node){const[e,t]=p.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return p.getBuiltinModule(o)}return C(o)},"__cjs_getBuiltinModule"),{createHash:M,createSign:S,createPrivateKey:_}=T("node:crypto");var H=Object.defineProperty,d=m((o,e)=>H(o,"name",{value:e,configurable:!0}),"l");const I=d((o,e="simple")=>{const t=[];for(const[r,a]of Object.entries(o)){const n=e==="relaxed"?r.toLowerCase().trim():r,s=e==="relaxed"?a.replaceAll(/\s+/g," ").trim():a;t.push(`${n}:${s}`)}return t.join(`\r
|
|
2
2
|
`)},"canonicalizeHeaders"),K=d((o,e="simple")=>{if(e==="simple"){const n=o.replace(/(\r\n|\r|\n)$/,`
|
|
3
3
|
`);let s=n.length;for(;s>0&&n[s-1]===`
|
|
4
4
|
`;)s-=1;const c=n.slice(0,s);return c?`${c}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var p=Object.defineProperty;var n=(a,e)=>p(a,"name",{value:e,configurable:!0});import{MailMessage as c}from"./MailMessage-BvaH5tZZ.js";import m from"./EmailError-zm2ffVav.js";import{z as b}from"./build-mime-message-6xstxaUV.js";import{c as y}from"./create-logger-BiWdqFNg.js";import{i as d}from"./headers-to-record-Qo124ImV.js";import C from"../utils/validation/check-feature-support.js";var v=Object.defineProperty,M=n((a,e)=>v(a,"name",{value:e,configurable:!0}),"s");class f extends c{static{n(this,"DraftMailMessage")}static{M(this,"DraftMailMessage")}constructor(){super(),this.header("X-Unsent","1")}}var w=Object.defineProperty,u=n((a,e)=>w(a,"name",{value:e,configurable:!0}),"d");const T=u((a,e,r)=>{e.success&&e.data?a&&a.info("Email sent successfully",{messageId:e.data.messageId,provider:e.data.provider}):a&&a.error("Email send failed",{error:e.error,provider:r})},"logSendResult");class h{static{n(this,"Mail")}static{u(this,"Mail")}static extractErrorMessages(e){return e instanceof Error?[e.message]:[String(e??"Unknown error")]}provider;logger;loggerInstance;globalConfig;featureCheck;constructor(e,r){this.provider=e,this.featureCheck=r?.featureCheck??"error"}setLogger(e){return this.loggerInstance=e,this.logger=y("Mail",e),this}setFrom(e){return this.globalConfig??={},this.globalConfig.from=e,this.logger&&this.logger.debug("Default from address updated",{from:e.email}),this}setReplyTo(e){return this.globalConfig??={},this.globalConfig.replyTo=e,this.logger&&this.logger.debug("Default reply-to address updated",{replyTo:e.email}),this}setHeaders(e){if(this.globalConfig??={},this.globalConfig.headers=e,this.logger){const r=d(e);this.logger.debug("Default headers updated",{count:Object.keys(r).length,headers:Object.keys(r)})}return this}async draft(e){let r=e instanceof c||e instanceof f?await this.buildDraftFromMessage(e):await this.buildDraftFromOptions(e);r=this.applyGlobalConfig(r);const t=r.headers?d(r.headers):{};r.headers={...t,"X-Unsent":"1"};const s=await b(r);return this.logger&&this.logger.debug("Draft created successfully in EML format",{from:r.from.email,size:s.length,subject:r.subject,to:Array.isArray(r.to)?r.to.length:1}),s}async send(e){if(e instanceof f)throw new TypeError("Cannot send draft messages. Convert to MailMessage first or remove X-Unsent header.");let r;if(e instanceof c)this.logger&&this.logger.debug("Sending MailMessage instance"),this.loggerInstance&&e.setLogger(this.loggerInstance),r=await e.build();else{const o=e;this.logger&&this.logger.debug("Sending email with options",{subject:o.subject,to:Array.isArray(o.to)?o.to.length:1}),r=o}r=this.applyGlobalConfig(r);const t=this.assertFeatureSupport(r);if(t)return{error:t,success:!1};const s=await this.provider.sendEmail(r);return T(this.logger,s,this.provider.name??"unknown"),s}async*sendMany(e,r){const t=this.provider.name;let s=0,o=0,g=0;this.logger&&this.logger.debug("Starting batch email send",{provider:t});for await(const l of e){if(l instanceof f)throw new TypeError("Cannot send draft messages. Convert to MailMessage first or remove X-Unsent header.");if(r?.signal?.aborted){this.logger&&this.logger.warn("Batch send operation was aborted",{failed:g,processed:s,successful:o}),yield{errorMessages:["Send operation was aborted"],provider:t,successful:!1};return}s+=1;try{const i=await this.send(l);i.success&&i.data?(o+=1,this.logger&&this.logger.debug(`Email ${s} sent successfully`,{messageId:i.data.messageId}),yield{messageId:i.data.messageId,provider:i.data.provider??t,response:i.data.response,successful:!0,timestamp:i.data.timestamp}):(g+=1,this.logger&&this.logger.error(`Email ${s} send failed`,{error:i.error}),yield{errorMessages:h.extractErrorMessages(i.error),provider:t,successful:!1})}catch(i){g+=1,this.logger&&this.logger.error(`Email ${s} send failed with exception`,i),yield{errorMessages:h.extractErrorMessages(i),provider:t,successful:!1}}}this.logger&&this.logger.debug("Batch email send completed",{failureCount:g,processedCount:s,provider:t,successCount:o})}assertFeatureSupport(e){if(this.featureCheck==="off")return;const{supported:r,violations:t}=C(e,this.provider.features);if(r)return;const s=this.provider.name??"unknown",o=t.map(l=>l.field),g=t.map(l=>l.message);if(this.featureCheck==="warn"){this.logger&&this.logger.warn("Message uses capabilities the provider does not support",{fields:o,provider:s});return}return this.logger&&this.logger.error("Message rejected by capability guard",{fields:o,provider:s}),new m(s,`Provider does not support the following message fields: ${o.join(", ")}`,{code:"UNSUPPORTED_FEATURES",hint:g})}async buildDraftFromMessage(e){return this.logger&&this.logger.debug("Creating draft from MailMessage instance"),this.loggerInstance&&e.setLogger(this.loggerInstance),this.applyGlobalConfigToMessage(e),await e.build()}async buildDraftFromOptions(e){return this.logger&&this.logger.debug("Creating draft from email options",{subject:e.subject,to:Array.isArray(e.to)?e.to.length:1}),e}applyGlobalConfigToMessage(e){const r=this.globalConfig?.from;r&&!e.getFrom()&&e.from(r);const t=this.globalConfig?.replyTo;if(t&&!e.getReplyTo()&&e.replyTo(t),this.globalConfig?.headers){const s=d(this.globalConfig.headers);Object.entries(s).forEach(([o,g])=>{e.header(o,g)})}}applyGlobalConfig(e){if(!this.globalConfig)return e;const r={...e};if(!r.from&&this.globalConfig.from&&(r.from=this.globalConfig.from,this.logger&&this.logger.debug("Applied global from address",{from:this.globalConfig.from.email})),!r.replyTo&&this.globalConfig.replyTo&&(r.replyTo=this.globalConfig.replyTo,this.logger&&this.logger.debug("Applied global reply-to address",{replyTo:this.globalConfig.replyTo.email})),this.globalConfig.headers){const t=d(this.globalConfig.headers),s=r.headers?d(r.headers):{};r.headers={...t,...s},this.logger&&this.logger.debug("Merged global headers",{globalCount:Object.keys(t).length,messageCount:Object.keys(s).length})}return r}}const A=u((a,e)=>new h(a,e),"createMail");export{h as Mail,A as createMail};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var A=Object.defineProperty;var d=(n,e)=>A(n,"name",{value:e,configurable:!0});import{createRequire as b}from"node:module";import C from"ical-generator";import{readFileAsBuffer as u,detectMimeType as g,generateContentId as m}from"./detectMimeType-
|
|
1
|
+
var A=Object.defineProperty;var d=(n,e)=>A(n,"name",{value:e,configurable:!0});import{createRequire as b}from"node:module";import C from"ical-generator";import{readFileAsBuffer as u,detectMimeType as g,generateContentId as m}from"./detectMimeType-bo5oxfnt.js";import p from"../template-engines/html-to-text.js";import{c as E}from"./create-logger-BiWdqFNg.js";import{i as l}from"./headers-to-record-Qo124ImV.js";const T=b(import.meta.url),a=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,f=d(n=>{if(typeof a<"u"&&a.versions&&a.versions.node){const[e,t]=a.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return a.getBuiltinModule(n)}return T(n)},"__cjs_getBuiltinModule"),{basename:c}=f("node:path"),{fileURLToPath:x}=f("node:url");var w=Object.defineProperty,y=d((n,e)=>w(n,"name",{value:e,configurable:!0}),"l");const o=y(n=>Array.isArray(n)?n.map(e=>typeof e=="string"?{email:e}:e):typeof n=="string"?[{email:n}]:[n],"normalizeAddresses");class M{static{d(this,"MailMessage")}static{y(this,"MailMessage")}fromAddress;toAddresses=[];ccAddresses=[];bccAddresses=[];subjectText="";textContent;textCharset="utf8";autoTextEnabled=!0;htmlContent;htmlCharset="utf8";dateValue;returnPathAddress;senderAddress;headers={};attachments=[];replyToAddress;priorityValue;tagsValue=[];signer;encrypter;logger;icalEventData;from(e){return this.fromAddress=typeof e=="string"?{email:e}:e,this}to(e){return this.toAddresses.length=0,this.toAddresses.push(...o(e)),this}cc(e){return this.ccAddresses.length=0,this.ccAddresses.push(...o(e)),this}bcc(e){return this.bccAddresses.length=0,this.bccAddresses.push(...o(e)),this}subject(e){return this.subjectText=e,this}text(e,t="utf8"){return this.textContent=e,this.textCharset=t,this}html(e,t="utf8"){return this.htmlContent=e,this.htmlCharset=t,this}header(e,t){return this.headers[e]=t,this}setHeaders(e){const t=l(e);return Object.assign(this.headers,t),this}async attachFromPath(e,t){try{const s=await u(e),i=t?.filename??(c(e)||"attachment"),r=t?.contentType??g(i);this.attachments.push({cid:t?.cid,content:s,contentDisposition:t?.contentDisposition??"attachment",contentType:r,encoding:t?.encoding,filename:i,headers:t?.headers}),this.logger&&this.logger.debug(`Attachment added from path: ${e}`,{contentType:r,filename:i})}catch(s){throw this.logger&&this.logger.error(`Failed to attach file from path: ${e}`,s),s}return this}attachData(e,t){const s=t.contentType??g(t.filename);return this.attachments.push({cid:t.cid,content:e,contentDisposition:t.contentDisposition??"attachment",contentType:s,encoding:t.encoding,filename:t.filename,headers:t.headers}),this.logger&&this.logger.debug("Attachment added from data",{contentType:s,filename:t.filename}),this}async embedFromPath(e,t){try{const s=await u(e),i=t?.filename??(c(e)||"inline"),r=t?.contentType??g(i),h=m(i);return this.attachments.push({cid:h,content:s,contentDisposition:"inline",contentType:r,filename:i}),this.logger&&this.logger.debug(`Inline attachment embedded from path: ${e}`,{cid:h,contentType:r,filename:i}),h}catch(s){throw this.logger&&this.logger.error(`Failed to embed file from path: ${e}`,s),s}}embedData(e,t,s){const i=s?.contentType??g(t),r=m(t);return this.attachments.push({cid:r,content:e,contentDisposition:"inline",contentType:i,filename:t}),this.logger&&this.logger.debug("Inline attachment embedded from data",{cid:r,contentType:i,filename:t}),r}replyTo(e){return this.replyToAddress=typeof e=="string"?{email:e}:e,this}date(e){return this.dateValue=typeof e=="string"?new Date(e):e,this.logger&&this.logger.debug("Date header set",{date:this.dateValue.toISOString()}),this}returnPath(e){return this.returnPathAddress=typeof e=="string"?{email:e}:e,this.logger&&this.logger.debug("Return-path address set",{returnPath:this.returnPathAddress.email}),this}sender(e){return this.senderAddress=typeof e=="string"?{email:e}:e,this.logger&&this.logger.debug("Sender address set",{sender:this.senderAddress.email}),this}addTo(e){return this.toAddresses.push(...o(e)),this}addCc(e){return this.ccAddresses.push(...o(e)),this}addBcc(e){return this.bccAddresses.push(...o(e)),this}addReplyTo(e){const t=Array.isArray(e)?e:[e];if(t.length>0){const s=t[0];this.replyToAddress=typeof s=="string"?{email:s}:s}return this}addFrom(e){const t=Array.isArray(e)?e:[e];if(t.length>0){const s=t[0];this.fromAddress=typeof s=="string"?{email:s}:s}return this}priority(e){return this.priorityValue=e,this}tags(e){return this.tagsValue=Array.isArray(e)?e:[e],this}sign(e){return this.signer=e,this.logger&&this.logger.debug("Email signer configured"),this}encrypt(e){return this.encrypter=e,this.logger&&this.logger.debug("Email encrypter configured"),this}setLogger(e){return this.logger=E("MailMessage",e),this}icalEvent(e,t){if(typeof e=="function"){const s=C();e(s),this.icalEventData={content:s.toString(),...t}}else this.icalEventData={content:e,...t};return this.logger&&this.logger.debug("Calendar event attached",{method:t?.method}),this}icalEventFromFile(e,t){const s=typeof e=="string"?e:x(e);return this.icalEventData={path:s,...t},this.logger&&this.logger.debug(`Calendar event attached from file: ${s}`,{method:t?.method}),this}icalEventFromUrl(e,t){return this.icalEventData={href:e,...t},this.logger&&this.logger.debug(`Calendar event attached from URL: ${e}`,{method:t?.method}),this}async view(e,t,s,i){try{const r=i?.autoText!==!1;this.autoTextEnabled=r,this.logger&&this.logger.debug("Rendering template",{autoText:r});const h=await e(t,s,i);this.html(h),r&&h&&this.tryAutoGenerateText(h),this.logger&&this.logger.debug("Template rendered successfully")}catch(r){throw this.logger&&this.logger.error("Failed to render template",r),new Error(`Failed to render template: ${r.message}`)}return this}async viewText(e,t,s,i){try{this.logger&&this.logger.debug("Rendering text template");const r=await e(t,s,i);if(typeof r=="string")this.text(r),this.logger&&this.logger.debug("Text template rendered successfully");else throw new TypeError("Text renderer must return a string")}catch(r){throw this.logger&&this.logger.error("Failed to render text template",r),new Error(`Failed to render text template: ${r.message}`)}return this}async build(){if(this.logger&&this.logger.debug("Building email message"),this.fromAddress||this.throwAndLogError("From address is required","Build failed: from address is required"),this.toAddresses.length===0&&this.throwAndLogError("At least one recipient is required","Build failed: at least one recipient is required"),this.subjectText||this.throwAndLogError("Subject is required","Build failed: subject is required"),this.htmlContent&&!this.textContent&&this.autoTextEnabled)try{this.textContent=p(this.htmlContent),this.logger&&this.logger.debug("Auto-generated text content from HTML")}catch{this.logger&&this.logger.debug("Failed to convert HTML to text; proceeding without text content.")}!this.textContent&&!this.htmlContent&&this.throwAndLogError("Either text or html content is required","Build failed: either text or html content is required");let e={from:this.fromAddress,html:this.htmlContent,subject:this.subjectText,text:this.textContent,to:this.toAddresses.length===1?this.toAddresses[0]:this.toAddresses};return this.ccAddresses.length>0&&(e.cc=this.ccAddresses.length===1?this.ccAddresses[0]:this.ccAddresses),this.bccAddresses.length>0&&(e.bcc=this.bccAddresses.length===1?this.bccAddresses[0]:this.bccAddresses),Object.keys(this.headers).length>0&&(e.headers=this.headers),this.attachments.length>0&&(e.attachments=this.attachments,this.logger&&this.logger.debug(`Email includes ${this.attachments.length} attachment(s)`)),this.replyToAddress&&(e.replyTo=this.replyToAddress),this.priorityValue&&(e.priority=this.priorityValue),this.tagsValue.length>0&&(e.tags=this.tagsValue),this.icalEventData&&(e.icalEvent=this.icalEventData,this.logger&&this.logger.debug("Email includes calendar event")),this.dateValue&&(e.headers={...l(e.headers??{}),Date:this.dateValue.toUTCString()}),this.returnPathAddress&&(e.headers={...l(e.headers??{}),"Return-Path":this.returnPathAddress.email}),this.senderAddress&&(e.headers={...l(e.headers??{}),Sender:this.senderAddress.email}),this.signer&&(this.logger&&this.logger.debug("Signing email message"),e=await this.signer.sign(e),this.logger&&this.logger.debug("Email message signed successfully")),this.encrypter&&(this.logger&&this.logger.debug("Encrypting email message"),e=await this.encrypter.encrypt(e),this.logger&&this.logger.debug("Email message encrypted successfully")),this.logger&&this.logger.debug("Email message built successfully",{bcc:this.bccAddresses.length,cc:this.ccAddresses.length,hasHtml:!!this.htmlContent,hasText:!!this.textContent,to:this.toAddresses.length}),e}getSubject(){return this.subjectText}getFrom(){return this.fromAddress}getTo(){return[...this.toAddresses]}getCc(){return[...this.ccAddresses]}getBcc(){return[...this.bccAddresses]}getReplyTo(){return this.replyToAddress}getSender(){return this.senderAddress}getReturnPath(){return this.returnPathAddress}getDate(){return this.dateValue}getPriority(){return this.priorityValue}getTextBody(){return this.textContent}getTextCharset(){return this.textCharset}getHtmlBody(){return this.htmlContent}getHtmlCharset(){return this.htmlCharset}getAttachments(){return[...this.attachments]}tryAutoGenerateText(e){try{const t=p(e);t&&!this.textContent&&this.text(t),this.logger&&this.logger.debug("Auto-generated text content from HTML template")}catch(t){this.logger&&this.logger.warn("Failed to auto-generate text from HTML template",t)}}throwAndLogError(e,t){const s=new Error(e);throw this.logger&&this.logger.error(t??e),s}}export{M as MailMessage,M as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var K=Object.defineProperty;var g=(s,e)=>K(s,"name",{value:e,configurable:!0});import{createRequire as U}from"node:module";import{B as S}from"./readFile-BAVMZg5e-
|
|
1
|
+
var K=Object.defineProperty;var g=(s,e)=>K(s,"name",{value:e,configurable:!0});import{createRequire as U}from"node:module";import{B as S}from"./readFile-BAVMZg5e-C4whBIPd.js";import{fromBER as $,OctetString as T}from"asn1js";import{Certificate as j,EnvelopedData as z,EncryptedContentInfo as J,id_ContentType_Data as Q,RecipientInfo as W,KeyTransRecipientInfo as X,IssuerAndSerialNumber as Y,AlgorithmIdentifier as x,ContentInfo as Z,id_ContentType_EnvelopedData as ee}from"pkijs";const q=U(import.meta.url),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,H=g(s=>{if(typeof h<"u"&&h.versions&&h.versions.node){const[e,t]=h.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return h.getBuiltinModule(s)}return q(s)},"__cjs_getBuiltinModule"),{randomBytes:I,createCipheriv:L,createPublicKey:G,publicEncrypt:V}=H("node:crypto");var te=Object.defineProperty,y=g((s,e)=>te(s,"name",{value:e,configurable:!0}),"l");const w=globalThis.Buffer!==void 0,N=y(s=>{const e=s.replaceAll(/-----BEGIN[^-]+-----/g,"").replaceAll(/-----END[^-]+-----/g,"").replaceAll(/\s/g,"");if(w)return Buffer.from(e,"base64");const t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r+=1)n[r]=t.charCodeAt(r);return n},"pemToDer"),R=y((s,e)=>{let t;if(w)t=Buffer.from(s).toString("base64");else{const r=new Uint8Array(s);let u="";const o=8192;for(let i=0;i<r.length;i+=o){const m=r.subarray(i,Math.min(i+o,r.length));u+=String.fromCharCode(...m)}t=btoa(u)}const n=t.match(/.{1,64}/g)??[];return`-----BEGIN ${e}-----
|
|
2
2
|
${n.join(`
|
|
3
3
|
`)}
|
|
4
4
|
-----END ${e}-----
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var L=Object.defineProperty;var g=(n,e)=>L(n,"name",{value:e,configurable:!0});import{createRequire as V}from"node:module";import{B as b}from"./readFile-BAVMZg5e-
|
|
1
|
+
var L=Object.defineProperty;var g=(n,e)=>L(n,"name",{value:e,configurable:!0});import{createRequire as V}from"node:module";import{B as b}from"./readFile-BAVMZg5e-C4whBIPd.js";import{fromBER as B,ObjectIdentifier as Y,OctetString as E,UTCTime as Z}from"asn1js";import{Certificate as N,SignedData as ee,EncapsulatedContentInfo as te,id_ContentType_Data as D,SignerInfo as re,AlgorithmIdentifier as P,IssuerAndSerialNumber as ne,id_sha256 as se,SignedAndUnsignedAttributes as oe,Attribute as A,ContentInfo as ie,id_ContentType_SignedData as ae}from"pkijs";import{a as ce}from"./generate-boundary-Cx8nXYS0.js";const z=V(import.meta.url),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,J=g(n=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[e,t]=u.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return u.getBuiltinModule(n)}return z(n)},"__cjs_getBuiltinModule"),{createPrivateKey:x,createHash:Q,createSign:W,randomBytes:X}=J("node:crypto");var le=Object.defineProperty,y=g((n,e)=>le(n,"name",{value:e,configurable:!0}),"u");const pe="1.2.840.113549.1.9.3",ue="1.2.840.113549.1.9.4",fe="1.2.840.113549.1.9.5",me="1.2.840.113549.1.1.1",de={v1:1},he={v1:1},f=globalThis.Buffer!==void 0,M=y(n=>{const e=n.replaceAll(/-----BEGIN[^-]+-----/g,"").replaceAll(/-----END[^-]+-----/g,"").replaceAll(/\s/g,"");if(f)return Buffer.from(e,"base64");const t=atob(e),o=new Uint8Array(t.length);for(let r=0;r<t.length;r+=1)o[r]=t.codePointAt(r);return o},"pemToDer"),ge=y((n,e)=>{let t;if(f)t=Buffer.from(n).toString("base64");else{const r=new Uint8Array(n);let s="";const a=8192;for(let i=0;i<r.length;i+=a){const d=r.subarray(i,Math.min(i+a,r.length));s+=String.fromCharCode(...d)}t=btoa(s)}const o=t.match(/.{1,64}/g)??[];return`-----BEGIN ${e}-----
|
|
2
2
|
${o.join(`
|
|
3
3
|
`)}
|
|
4
4
|
-----END ${e}-----
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var u=Object.defineProperty;var o=(e,r)=>u(e,"name",{value:r,configurable:!0});var c=Object.defineProperty,i=o((e,r)=>c(e,"name",{value:r,configurable:!0}),"n");const l=["attachments","batchSending","customHeaders","html","replyTo","scheduling","tagging","templates","tracking"],f=i(e=>typeof e=="function","isProviderFactory"),g=i(e=>e!==null&&typeof e=="object"&&"initialize"in e&&"isAvailable"in e&&"sendEmail"in e,"isProvider"),v=i(e=>{if(g(e))return e.features;if(f(e))try{return e({}).features}catch{return}},"resolveFeatures");function d(e){const r=e.map(t=>v(t)).filter(t=>t!==void 0),a={};if(r.length===0)return a;for(const t of l){const s=r.map(n=>n[t]);s.every(n=>n===!0)?a[t]=!0:s.every(n=>n===!1)&&(a[t]=!1)}return a}o(d,"l");i(d,"aggregateProviderFeatures");export{d as l};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var l=Object.defineProperty;var a=(e,r)=>l(e,"name",{value:r,configurable:!0});import{B as n}from"./readFile-BAVMZg5e-
|
|
1
|
+
var l=Object.defineProperty;var a=(e,r)=>l(e,"name",{value:r,configurable:!0});import{B as n}from"./readFile-BAVMZg5e-C4whBIPd.js";import i from"mime";var c=Object.defineProperty,t=a((e,r)=>c(e,"name",{value:r,configurable:!0}),"e");const d=t(e=>i.getType(e)??"application/octet-stream","detectMimeType"),g=t(e=>{const r=e.replaceAll(/[^a-z0-9]/gi,"-").replaceAll(/-+/g,"-").replaceAll(/^-|-$/g,"").toLowerCase(),o=Math.random().toString(36).slice(2,9);return`${r}-${o}@email`},"generateContentId"),s=t(e=>n(e,{buffer:!0}),"readFileAsBuffer");export{d as detectMimeType,g as generateContentId,s as readFileAsBuffer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var w=Object.defineProperty;var h=(e,s)=>w(e,"name",{value:s,configurable:!0});import u from"./EmailError-zm2ffVav.js";import $ from"./RequiredOptionError-CevW3u2K.js";import{c as E}from"./create-logger-BiWdqFNg.js";import{s as A}from"./generate-message-id-D4uA8gkj.js";import{defineProvider as z}from"./defineProvider-CtLH0VBE.js";import{l as P}from"./aggregate-features-BvgdYul-.js";var F=Object.defineProperty,p=h((e,s)=>F(e,"name",{value:s,configurable:!0}),"g");const k=p(e=>typeof e=="function","isProviderFactory"),S=p(e=>e!==null&&typeof e=="object"&&"sendEmail"in e&&"initialize"in e&&"isAvailable"in e,"isProvider"),l="failover",T=z((e={})=>{if(!e.mailers||e.mailers.length===0)throw new $(l,"mailers");const s={debug:e.debug??!1,mailers:e.mailers,retryAfter:e.retryAfter??60};let b=!1;const t=[],n=E(l,e.logger);let g;const m=p(async()=>g||(g=(async()=>{t.length=0;for(const a of s.mailers)try{let r;if(k(a))r=a({});else if(S(a))r=a;else{n.debug(`Skipping invalid mailer: ${a}`);continue}try{await r.initialize(),t.push(r),n.debug(`Initialized provider: ${r.name??"unknown"}`)}catch(c){n.debug(`Failed to initialize provider ${r.name??"unknown"}:`,c)}}catch(r){n.debug("Error processing mailer:",r)}if(t.length===0)throw new u(l,"No providers could be initialized")})(),g),"initializeProviders");return{features:P(s.mailers),async initialize(){if(!b)try{await m(),b=!0,n.debug(`Failover provider initialized with ${t.length} provider(s)`)}catch(a){throw new u(l,`Failed to initialize: ${a.message}`,{cause:a})}},async isAvailable(){try{t.length===0&&await m();for(const a of t)try{if(await a.isAvailable())return!0}catch{}return!1}catch{return!1}},name:l,options:s,async sendEmail(a){try{if(t.length===0&&await m(),t.length===0)return{error:new u(l,"No providers available"),success:!1};const r=[];let c;for(let o=0;o<t.length;o+=1){const f=t[o];if(!f)continue;const d=f.name??`provider-${o+1}`;n.debug(`Attempting to send email via ${d} (${o+1}/${t.length})`);try{if(!await f.isAvailable()){n.debug(`Provider ${d} is not available, skipping`),r.push(new u(l,`Provider ${d} is not available`));continue}const i=await f.sendEmail(a);if(i.success&&i.data)return n.debug(`Email sent successfully via ${d}`),{data:{...i.data,messageId:i.data.messageId||A(),provider:`${l}(${d})`},success:!0};if(i.error){c=i.error,r.push(i.error);const v=i.error instanceof Error?i.error.message:String(i.error);n.debug(`Failed to send via ${d}:`,v)}}catch(i){c=i instanceof Error?i:new Error(String(i)),r.push(c);const v=c instanceof Error?c.message:String(c);n.debug(`Exception sending via ${d}:`,v)}o<t.length-1&&s.retryAfter>0&&(n.debug(`Waiting ${s.retryAfter}ms before trying next provider`),await new Promise(i=>{setTimeout(()=>{i()},s.retryAfter)}))}const y=r.map(o=>o instanceof Error?o.message:String(o)).join("; ");return{error:new u(l,`All providers failed. Errors: ${y}`,{cause:c}),success:!1}}catch(r){return{error:new u(l,`Failed to send email: ${r.message}`,{cause:r}),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{T as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var jr=Object.defineProperty;var b=(e,r)=>jr(e,"name",{value:r,configurable:!0});import{createRequire as Or}from"node:module";const Pr=Or(import.meta.url),D=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,zr=b(e=>{if(typeof D<"u"&&D.versions&&D.versions.node){const[r,i]=D.versions.node.split(".").map(Number);if(r>22||r===22&&i>=3||r===20&&i>=16)return D.getBuiltinModule(e)}return Pr(e)},"__cjs_getBuiltinModule"),{createRequire:ae}=zr("node:module"),_r=0,Er=4;var Mr=Object.defineProperty,kr=b((e,r)=>Mr(e,"name",{value:r,configurable:!0}),"t$2"),Ar=Object.defineProperty,Rr=kr((e,r)=>Ar(e,"name",{value:r,configurable:!0}),"t"),Br=Object.defineProperty,Tr=Rr((e,r)=>Br(e,"name",{value:r,configurable:!0}),"n");const Ie=Tr(e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},"assertValidFileOrDirectoryPath");var Nr=Object.defineProperty,Sr=b((e,r)=>Nr(e,"name",{value:r,configurable:!0}),"$e"),Ir=Object.defineProperty,ie=Sr((e,r)=>Ir(e,"name",{value:r,configurable:!0}),"W"),Fr=Object.defineProperty,c=ie((e,r)=>Fr(e,"name",{value:r,configurable:!0}),"u$1");let Re=c(()=>{var e=(()=>{var r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,g=Object.prototype.hasOwnProperty,x=c((t,n)=>{for(var o in n)r(t,o,{get:n[o],enumerable:!0})},"ne"),y=c((t,n,o,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of u(n))!g.call(t,s)&&s!==o&&r(t,s,{get:c(()=>n[s],"get"),enumerable:!(a=i(n,s))||a.enumerable});return t},"ae"),v=c(t=>y(r({},"__esModule",{value:!0}),t),"oe"),k={};x(k,{zeptomatch:c(()=>Ae,"zeptomatch")});var I=c(t=>{const n=new Set,o=[t];for(let a=0;a<o.length;a++){const s=o[a];if(n.has(s))continue;n.add(s);const{children:l}=s;if(l?.length)for(let f=0,d=l.length;f<d;f++)o.push(l[f])}return Array.from(n)},"M"),Y=c(t=>{let n="";const o=I(t);for(let a=0,s=o.length;a<s;a++){const l=o[a];if(!l.regex)continue;const f=l.regex.flags;if(n||(n=f),n!==f)throw new Error(`Inconsistent RegExp flags used: "${n}" and "${f}"`)}return n},"se"),ge=c((t,n,o)=>{const a=o.get(t);if(a!==void 0)return a;const s=t.partial??n;let l="";if(t.regex&&(l+=s?"(?:$|":"",l+=t.regex.source),t.children?.length){const f=Qe(t.children.map(d=>ge(d,n,o)).filter(Boolean));if(f?.length){const d=t.children.some(C=>!C.regex||!(C.partial??n)),h=f.length>1||s&&(!l.length||d);l+=h?s?"(?:$|":"(?:":"",l+=f.join("|"),l+=h?")":""}}return t.regex&&(l+=s?")":""),o.set(t,l),l},"O"),Ke=c((t,n)=>{const o=new Map,a=I(t);for(let s=a.length-1;s>=0;s--){const l=ge(a[s],n,o);if(!(s>0))return l}return""},"ie"),Qe=c(t=>Array.from(new Set(t)),"ue"),Q=c((t,n,o)=>Q.compile(t,o).test(n),"R");Q.compile=(t,n)=>{const o=n?.partial??!1,a=Ke(t,o),s=Y(t);return new RegExp(`^(?:${a})$`,s)};var Xe=Q,et=c((t,n)=>{const o=Xe.compile(t,n),a=`${o.source.slice(0,-1)}[\\\\/]?$`,s=o.flags;return new RegExp(a,s)},"le"),tt=et,rt=c(t=>{const n=t.map(a=>a.source).join("|")||"$^",o=t[0]?.flags;return new RegExp(n,o)},"ve"),nt=rt,de=c(t=>Array.isArray(t),"j"),F=c(t=>typeof t=="function","_"),ot=c(t=>t.length===0,"he"),st=(()=>{const{toString:t}=Function.prototype,n=/(?:^\(\s*(?:[^,.()]|\.(?!\.\.))*\s*\)\s*=>|^\s*[a-zA-Z$_][a-zA-Z0-9$_]*\s*=>)/;return o=>(o.length===0||o.length===1)&&n.test(t.call(o))})(),at=c(t=>typeof t=="number","de"),it=c(t=>typeof t=="object"&&t!==null,"xe"),lt=c(t=>t instanceof RegExp,"me"),ut=(()=>{const t=/\\\(|\((?!\?(?::|=|!|<=|<!))/;return n=>t.test(n.source)})(),ct=(()=>{const t=/^[a-zA-Z0-9_-]+$/;return n=>t.test(n.source)&&!n.flags.includes("i")})(),me=c(t=>typeof t=="string","A"),_=c(t=>t===void 0,"f"),ft=c(t=>{const n=new Map;return o=>{const a=n.get(o);if(a!==void 0)return a;const s=t(o);return n.set(o,s),s}},"ye"),he=c((t,n,o={})=>{const a={cache:{},input:t,index:0,indexBacktrackMax:0,options:o,output:[]},s=E(n)(a),l=Math.max(a.index,a.indexBacktrackMax);if(s&&a.index===t.length)return a.output;throw new Error(`Failed to parse at index ${l}`)},"I"),p=c((t,n)=>de(t)?pt(t,n):me(t)?be(t,n):gt(t,n),"i"),pt=c((t,n)=>{const o={};for(const a of t){if(a.length!==1)throw new Error(`Invalid character: "${a}"`);const s=a.charCodeAt(0);o[s]=!0}return a=>{const s=a.input;let l=a.index,f=l;for(;f<s.length&&s.charCodeAt(f)in o;)f+=1;if(f>l){if(!_(n)&&!a.options.silent){const d=s.slice(l,f),h=F(n)?n(d,s,`${l}`):n;_(h)||a.output.push(h)}a.index=f}return!0}},"we"),gt=c((t,n)=>{if(ct(t))return be(t.source,n);{const o=t.source,a=t.flags.replace(/y|$/,"y"),s=new RegExp(o,a);return ut(t)&&F(n)&&!st(n)?dt(s,n):mt(s,n)}},"$e"),dt=c((t,n)=>o=>{const a=o.index,s=o.input;t.lastIndex=a;const l=t.exec(s);if(l){const f=t.lastIndex;if(!o.options.silent){const d=n(...l,s,`${a}`);_(d)||o.output.push(d)}return o.index=f,!0}else return!1},"Ee"),mt=c((t,n)=>o=>{const a=o.index,s=o.input;if(t.lastIndex=a,t.test(s)){const l=t.lastIndex;if(!_(n)&&!o.options.silent){const f=F(n)?n(s.slice(a,l),s,`${a}`):n;_(f)||o.output.push(f)}return o.index=l,!0}else return!1},"Ce"),be=c((t,n)=>o=>{const a=o.index,s=o.input;if(s.startsWith(t,a)){if(!_(n)&&!o.options.silent){const l=F(n)?n(t,s,`${a}`):n;_(l)||o.output.push(l)}return o.index+=t.length,!0}else return!1},"F"),X=c((t,n,o,a)=>{const s=E(t),l=n>1;return te(ee(ve(f=>{let d=0;for(;d<o;){const h=f.index;if(!s(f)||(d+=1,f.index===h))break}return d>=n},l),a))},"k"),xe=c((t,n)=>X(t,0,1,n),"L"),H=c((t,n)=>X(t,0,1/0,n),"$"),ht=c((t,n)=>X(t,1,1/0,n),"Re"),B=c((t,n)=>{const o=t.map(E);return te(ee(ve(a=>{for(let s=0,l=o.length;s<l;s++)if(!o[s](a))return!1;return!0}),n))},"x"),w=c((t,n)=>{const o=t.map(E);return te(ee(a=>{for(let s=0,l=o.length;s<l;s++)if(o[s](a))return!0;return!1},n))},"p"),ve=c((t,n=!0,o=!1)=>{const a=E(t);return n?s=>{const l=s.index,f=s.output.length,d=a(s);return!d&&!o&&(s.indexBacktrackMax=Math.max(s.indexBacktrackMax,s.index)),(!d||o)&&(s.index=l,s.output.length!==f&&(s.output.length=f)),d}:a},"q"),ee=c((t,n)=>{const o=E(t);return n?a=>{if(a.options.silent)return o(a);const s=a.output.length;if(o(a)){const l=a.output.splice(s,1/0),f=n(l);return _(f)||a.output.push(f),!0}else return!1}:o},"B"),te=(()=>{let t=0;return n=>{const o=E(n),a=t+=1;return s=>{var l;if(s.options.memoization===!1)return o(s);const f=s.index,d=(l=s.cache)[a]||(l[a]={indexMax:-1,queue:[]}),h=d.queue;if(f<=d.indexMax){const W=d.store||(d.store=new Map);if(h.length){for(let N=0,$r=h.length;N<$r;N+=2){const yr=h[N*2],wr=h[N*2+1];W.set(yr,wr)}h.length=0}const j=W.get(f);if(j===!1)return!1;if(at(j))return s.index=j,!0;if(j)return s.index=j.index,j.output?.length&&s.output.push(...j.output),!0}const C=s.output.length,vr=o(s);if(d.indexMax=Math.max(d.indexMax,f),vr){const W=s.index,j=s.output.length;if(j>C){const N=s.output.slice(C,j);h.push(f,{index:W,output:N})}else h.push(f,W);return!0}else return h.push(f,!1),!1}}})(),$e=c(t=>{let n;return o=>(n||(n=E(t())),n(o))},"G"),E=ft(t=>{if(F(t))return ot(t)?$e(t):t;if(me(t)||lt(t))return p(t);if(de(t))return B(t);if(it(t))return w(Object.values(t));throw new Error("Invalid rule")}),A=c(t=>t,"d"),bt=c(t=>typeof t=="string","ke"),xt=c(t=>{const n=new WeakMap,o=new WeakMap;return(a,s)=>{const l=s?.partial?o:n,f=l.get(a);if(f!==void 0)return f;const d=t(a,s);return l.set(a,d),d}},"Be"),vt=c(t=>{const n={},o={};return(a,s)=>{const l=s?.partial?o:n;return l[a]??(l[a]=t(a,s))}},"Pe"),$t=p(/\\./,A),yt=p(/./,A),wt=p(/\*\*\*+/,"*"),jt=p(/([^/{[(!])\*\*/,(t,n)=>`${n}*`),Ot=p(/(^|.)\*\*(?=[^*/)\]}])/,(t,n)=>`${n}*`),Pt=H(w([$t,wt,jt,Ot,yt])),zt=Pt,_t=c(t=>he(t,zt,{memoization:!1}).join(""),"Ie"),Et=_t,ye="abcdefghijklmnopqrstuvwxyz",Mt=c(t=>{let n="";for(;t>0;){const o=(t-1)%26;n=ye[o]+n,t=Math.floor((t-1)/26)}return n},"Le"),we=c(t=>{let n=0;for(let o=0,a=t.length;o<a;o++)n=n*26+ye.indexOf(t[o])+1;return n},"V"),re=c((t,n)=>{if(n<t)return re(n,t);const o=[];for(;t<=n;)o.push(t++);return o},"b"),kt=c((t,n,o)=>re(t,n).map(a=>String(a).padStart(o,"0")),"qe"),je=c((t,n)=>re(we(t),we(n)).map(Mt),"W"),m=c(t=>({partial:!1,regex:new RegExp(t,"s"),children:[]}),"c"),q=c(t=>({children:t}),"y"),T=(()=>{const t=c((n,o,a)=>{if(a.has(n))return;a.add(n);const{children:s}=n;if(!s.length)s.push(o);else for(let l=0,f=s.length;l<f;l++)t(s[l],o,a)},"e");return n=>{if(!n.length)return q([]);for(let o=n.length-1;o>=1;o--){const a=new Set,s=n[o-1],l=n[o];t(s,l,a)}return n[0]}})(),M=c(()=>({regex:new RegExp("[\\\\/]","s"),children:[]}),"g"),At=p(/\\./,m),Rt=p(/[$.*+?^(){}[\]\|]/,t=>m(`\\${t}`)),Bt=p(/[\\\/]/,M),Tt=p(/[^$.*+?^(){}[\]\|\\\/]+/,m),Nt=p(/^(?:!!)*!(.*)$/,(t,n)=>m(`(?!^${Ae.compile(n).source}$).*?`)),St=p(/^(!!)+/),It=w([Nt,St]),Ft=p(/\/(\*\*\/)+/,()=>q([T([M(),m(".+?"),M()]),M()])),qt=p(/^(\*\*\/)+/,()=>q([m("^"),T([m(".*?"),M()])])),Ct=p(/\/(\*\*)$/,()=>q([T([M(),m(".*?")]),m("$")])),Wt=p(/\*\*/,()=>m(".*?")),Oe=w([Ft,qt,Ct,Wt]),Dt=p(/\*\/(?!\*\*\/|\*$)/,()=>T([m("[^\\\\/]*?"),M()])),Lt=p(/\*/,()=>m("[^\\\\/]*")),Pe=w([Dt,Lt]),ze=p("?",()=>m("[^\\\\/]")),Ut=p("[",A),Zt=p("]",A),Gt=p(/[!^]/,"^\\\\/"),Vt=p(/[a-z]-[a-z]|[0-9]-[0-9]/i,A),Yt=p(/\\./,A),Ht=p(/[$.*+?^(){}[\|]/,t=>`\\${t}`),Jt=p(/[\\\/]/,"\\\\/"),Kt=p(/[^$.*+?^(){}[\]\|\\\/]+/,A),Qt=w([Yt,Ht,Jt,Vt,Kt]),_e=B([Ut,xe(Gt),H(Qt),Zt],t=>m(t.join(""))),Xt=p("{","(?:"),er=p("}",")"),tr=p(/(\d+)\.\.(\d+)/,(t,n,o)=>kt(+n,+o,Math.min(n.length,o.length)).join("|")),rr=p(/([a-z]+)\.\.([a-z]+)/,(t,n,o)=>je(n,o).join("|")),nr=p(/([A-Z]+)\.\.([A-Z]+)/,(t,n,o)=>je(n.toLowerCase(),o.toLowerCase()).join("|").toUpperCase()),or=w([tr,rr,nr]),Ee=B([Xt,or,er],t=>m(t.join(""))),sr=p("{"),ar=p("}"),ir=p(","),lr=p(/\\./,m),ur=p(/[$.*+?^(){[\]\|]/,t=>m(`\\${t}`)),cr=p(/[\\\/]/,M),fr=p(/[^$.*+?^(){}[\]\|\\\/,]+/,m),pr=$e(()=>ke),gr=p("",()=>m("(?:)")),dr=ht(w([Oe,Pe,ze,_e,Ee,pr,lr,ur,cr,fr]),T),Me=w([dr,gr]),ke=B([sr,xe(B([Me,H(B([ir,Me]))])),ar],q),mr=H(w([It,Oe,Pe,ze,_e,Ee,ke,At,Rt,Bt,Tt]),T),hr=mr,br=c(t=>he(t,hr,{memoization:!1})[0],"kr"),xr=br,ne=c((t,n,o)=>ne.compile(t,o).test(n),"N");ne.compile=(()=>{const t=vt((o,a)=>tt(xr(Et(o)),a)),n=xt((o,a)=>nt(o.map(s=>t(s,a))));return(o,a)=>bt(o)?t(o,a):n(o,a)})();var Ae=ne;return v(k)})();return e.default||e},"_lazyMatch"),oe;const qr=c((e,r)=>(oe||(oe=Re(),Re=null),oe(e,r)),"default");var Cr=Object.defineProperty,Wr=ie((e,r)=>Cr(e,"name",{value:r,configurable:!0}),"t$1");const Dr=/^[A-Z]:\//i,O=Wr((e="")=>e&&e.replaceAll("\\","/").replace(Dr,r=>r.toUpperCase()),"normalizeWindowsPath");var Lr=Object.defineProperty,$=ie((e,r)=>Lr(e,"name",{value:r,configurable:!0}),"r");const Ur=/^[/\\]{2}/,Zr=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,Fe=/^[A-Z]:$/i,Be=/^\/([A-Z]:)?$/i,Gr=/.(\.[^./]+)$/,Vr=/^[/\\]|^[a-z]:[/\\]/i,Yr=/\/$/,Hr=$(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd"),qe=$((e,r)=>{let i="",u=0,g=-1,x=0,y;for(let v=0;v<=e.length;++v){if(v<e.length)y=e[v];else{if(y==="/")break;y="/"}if(y==="/"){if(!(g===v-1||x===1))if(x===2){if(i.length<2||u!==2||!i.endsWith(".")||i.at(-2)!=="."){if(i.length>2){const k=i.lastIndexOf("/");k===-1?(i="",u=0):(i=i.slice(0,k),u=i.length-1-i.lastIndexOf("/")),g=v,x=0;continue}else if(i.length>0){i="",u=0,g=v,x=0;continue}}r&&(i+=i.length>0?"/..":"..",u=2)}else i.length>0?i+=`/${e.slice(g+1,v)}`:i=e.slice(g+1,v),u=v-g-1;g=v,x=0}else y==="."&&x!==-1?++x:x=-1}return i},"normalizeString"),G=$(e=>Zr.test(e),"isAbsolute"),Ce=$(function(e){if(e.length===0)return".";e=O(e);const r=Ur.exec(e),i=G(e),u=e.at(-1)==="/";return e=qe(e,!i),e.length===0?i?"/":u?"./":".":(u&&(e+="/"),Fe.test(e)&&(e+="/"),r?i?`//${e}`:`//./${e}`:i&&!G(e)?`/${e}`:e)},"normalize"),We=$((...e)=>{let r="";for(const i of e)if(i)if(r.length>0){const u=r.at(-1)==="/",g=i[0]==="/";u&&g?r+=i.slice(1):r+=u||g?i:`/${i}`}else r+=i;return Ce(r)},"join"),se=$(function(...e){e=e.map(u=>O(u));let r="",i=!1;for(let u=e.length-1;u>=-1&&!i;u--){const g=u>=0?e[u]:Hr();!g||g.length===0||(r=`${g}/${r}`,i=G(g))}return r=qe(r,!i),i&&!G(r)?`/${r}`:r.length>0?r:"."},"resolve");$(function(e){return O(e)},"toNamespacedPath");const De=$(function(e){return Gr.exec(O(e))?.[1]??""},"extname");$(function(e,r){const i=se(e).replace(Be,"$1").split("/"),u=se(r).replace(Be,"$1").split("/");if(u[0][1]===":"&&i[0][1]===":"&&i[0]!==u[0])return u.join("/");const g=[...i];for(const x of g){if(u[0]!==x)break;i.shift(),u.shift()}return[...i.map(()=>".."),...u].join("/")},"relative");const Jr=$(e=>{const r=O(e).replace(Yr,"").split("/").slice(0,-1);return r.length===1&&Fe.test(r[0])&&(r[0]=`${r[0]}/`),r.join("/")||(G(e)?"/":".")},"dirname");$(function(e){const r=[e.root,e.dir,e.base??e.name+e.ext].filter(Boolean);return O(e.root?se(...r):r.join("/"))},"format");const Kr=$((e,r)=>{const i=O(e).split("/").pop();return r&&i.endsWith(r)?i.slice(0,-r.length):i},"basename");$(function(e){const r=Vr.exec(e)?.[0]?.replaceAll("\\","/")??"",i=Kr(e),u=De(i);return{base:i,dir:Jr(e),ext:u,name:i.slice(0,i.length-u.length),root:r}},"parse");$((e,r)=>qr(r,Ce(e)),"matchesGlob");var Qr=Object.defineProperty,R=b((e,r)=>Qr(e,"name",{value:r,configurable:!0}),"n$2"),Xr=Object.defineProperty,z=R((e,r)=>Xr(e,"name",{value:r,configurable:!0}),"a");const en=ae(import.meta.url),L=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,tn=z(e=>{if(typeof L<"u"&&L.versions&&L.versions.node){const[r,i]=L.versions.node.split(".").map(Number);if(r>22||r===22&&i>=3||r===20&&i>=16)return L.getBuiltinModule(e)}return en(e)},"__cjs_getBuiltinModule"),{fileURLToPath:rn}=tn("node:url");var nn=Object.defineProperty,S=z((e,r)=>nn(e,"name",{value:r,configurable:!0}),"t$1");function K(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}b(K,"m$2");R(K,"d");z(K,"getDefaultExportFromCjs");S(K,"getDefaultExportFromCjs");function le(e){return e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}b(le,"h$1");R(le,"O");z(le,"getDefaultExportFromNamespaceIfPresent");S(le,"getDefaultExportFromNamespaceIfPresent");function ue(e){return e&&Object.prototype.hasOwnProperty.call(e,"default")&&Object.keys(e).length===1?e.default:e}b(ue,"x");R(ue,"P");z(ue,"getDefaultExportFromNamespaceIfNotNamed");S(ue,"getDefaultExportFromNamespaceIfNotNamed");function ce(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var r=e.default;if(typeof r=="function"){var i=S(z(R(b(function u(){var g=!1;try{g=this instanceof u}catch{}return g?Reflect.construct(r,arguments,this.constructor):r.apply(this,arguments)},"a"),"s"),"a"),"a");i.prototype=r.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(e).forEach(function(u){var g=Object.getOwnPropertyDescriptor(e,u);Object.defineProperty(i,u,g.get?g:{enumerable:!0,get:S(function(){return e[u]},"get")})}),i}b(ce,"y");R(ce,"_");z(ce,"getAugmentedNamespace");S(ce,"getAugmentedNamespace");var Te,Ne;function fe(){return Ne||(Ne=1,Te=["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cr3","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),Te}b(fe,"w$1");R(fe,"k");z(fe,"requireBinaryExtensions");var on=fe();const sn=K(on);var an=Object.defineProperty,P=z((e,r)=>an(e,"name",{value:r,configurable:!0}),"r");const ln=new Set(sn),un=new Set(["/","\\",void 0]),Se=Symbol.for("pathe:normalizedAlias"),cn=/(^|[/\\])([^/\\]+?)(?=(?:\.[^.]+)?$)/,fn=P((e,r)=>r.split("/").length-e.split("/").length,"compareAliases"),J=P((e="/")=>{const r=e.at(-1);return r==="/"||r==="\\"},"hasTrailingSlash"),Le=P(e=>{if(e[Se])return e;const r=Object.fromEntries(Object.entries(e).toSorted(([i],[u])=>fn(i,u)));for(const i in r)for(const u in r)u===i||i.startsWith(u)||r[i].startsWith(u)&&un.has(r[i][u.length])&&(r[i]=r[u]+r[i].slice(u.length));return Object.defineProperty(r,Se,{enumerable:!1,value:!0}),r},"normalizeAliases");P((e,r)=>{e=O(e),r=Le(r);for(const[i,u]of Object.entries(r)){if(!e.startsWith(i))continue;const g=J(i)?i.slice(0,-1):i;if(J(e[g.length]))return We(u,e.slice(i.length))}return e},"resolveAlias");P(e=>cn.exec(e)?.[2],"filename");P((e,r)=>{e=O(e),r=Le(r);for(const[i,u]of Object.entries(r).toReversed()){if(!e.startsWith(u))continue;const g=J(u)?u.slice(0,-1):u;if(J(e[g.length]))return We(i,e.slice(u.length))}return e},"reverseResolveAlias");const pn=/^(?:\.?\.[/\\]|\.\.\B)/,gn=/^(?:msys|cygwin)$/;P(e=>pn.test(e)||e==="..","isRelative");P(e=>ln.has(De(e).slice(1).toLowerCase()),"isBinaryPath");const Ue=P(e=>O(e instanceof URL?rn(e):e),"toPath");P(()=>{if(!globalThis.process)return!1;if(globalThis.process.platform==="win32"||globalThis.process.platform==="cygwin")return!0;const e=globalThis.process.env.OSTYPE;return typeof e!="string"?!1:gn.test(e)},"isWindows");var dn=Object.defineProperty,Ze=b((e,r)=>dn(e,"name",{value:r,configurable:!0}),"t$1"),mn=Object.defineProperty,pe=Ze((e,r)=>mn(e,"name",{value:r,configurable:!0}),"s");const hn=ae(import.meta.url),U=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,bn=pe(e=>{if(typeof U<"u"&&U.versions&&U.versions.node){const[r,i]=U.versions.node.split(".").map(Number);if(r>22||r===22&&i>=3||r===20&&i>=16)return U.getBuiltinModule(e)}return hn(e)},"__cjs_getBuiltinModule"),{access:xn}=bn("node:fs/promises");var vn=Object.defineProperty,$n=pe((e,r)=>vn(e,"name",{value:r,configurable:!0}),"o");async function V(e,r=_r){Ie(e),e=Ue(e);try{return await xn(e,r),!0}catch{return!1}}b(V,"i$1");Ze(V,"d");pe(V,"m");$n(V,"isAccessible");var yn=Object.defineProperty,Ge=b((e,r)=>yn(e,"name",{value:r,configurable:!0}),"t"),wn=Object.defineProperty,Ve=Ge((e,r)=>wn(e,"name",{value:r,configurable:!0}),"t"),jn=Object.defineProperty,On=Ve((e,r)=>jn(e,"name",{value:r,configurable:!0}),"o");let Pn=class extends Error{static{b(this,"c")}static{Ge(this,"i")}static{Ve(this,"n")}static{On(this,"PermissionError")}constructor(r){super(`EPERM: Operation not permitted, ${r}`)}get code(){return"EPERM"}set code(r){throw new Error("Cannot overwrite code EPERM")}get name(){return"PermissionError"}set name(r){throw new Error("Cannot overwrite name of PermissionError")}};var zn=Object.defineProperty,_n=b((e,r)=>zn(e,"name",{value:r,configurable:!0}),"f"),En=Object.defineProperty,Ye=_n((e,r)=>En(e,"name",{value:r,configurable:!0}),"i");const Mn=ae(import.meta.url),Z=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,He=Ye(e=>{if(typeof Z<"u"&&Z.versions&&Z.versions.node){const[r,i]=Z.versions.node.split(".").map(Number);if(r>22||r===22&&i>=3||r===20&&i>=16)return Z.getBuiltinModule(e)}return Mn(e)},"__cjs_getBuiltinModule"),{readFile:kn}=He("node:fs/promises"),{unzip:An,brotliDecompress:Rn}=He("node:zlib");var Bn=Object.defineProperty,Je=Ye((e,r)=>Bn(e,"name",{value:r,configurable:!0}),"n");const Tn={brotli:Rn,gzip:An,none:Je((e,r)=>{r(null,e)},"none")},Fn=Je(async(e,r)=>{if(Ie(e),e=Ue(e),!await V(e))throw new Pn(`unable to read the non-accessible file: ${e}`);if(!await V(e,Er))throw new Error(`Unable to read the non-readable file: ${e}`);const{buffer:i,compression:u,encoding:g,flag:x}=r??{};return await kn(e,x?{encoding:g,flag:x}:{encoding:g}).then(async y=>await new Promise((v,k)=>{Tn[u??"none"](y,(I,Y)=>{I?k(I):v(i?Y:Y.toString())})})).catch(y=>{throw y})},"readFile");export{Fn as B};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var E=Object.defineProperty;var y=(e,l)=>E(e,"name",{value:l,configurable:!0});import f from"./EmailError-zm2ffVav.js";import z from"./RequiredOptionError-CevW3u2K.js";import{c as A}from"./create-logger-BiWdqFNg.js";import{defineProvider as P}from"./defineProvider-CtLH0VBE.js";import{l as k}from"./aggregate-features-BvgdYul-.js";var x=Object.defineProperty,m=y((e,l)=>x(e,"name",{value:l,configurable:!0}),"f");const S=m(e=>typeof e=="function","isProviderFactory"),F=m(e=>e!=null&&typeof e=="object"&&"sendEmail"in e&&"initialize"in e&&"isAvailable"in e,"isProvider"),o="roundrobin",L=P((e={})=>{if(!e.mailers||e.mailers.length===0)throw new z(o,"mailers");const l={debug:e.debug??!1,logger:e.logger,mailers:e.mailers,retries:e.retries??3,retryAfter:e.retryAfter??60,timeout:e.timeout??3e4};let p=!1;const i=[];let a=0;const n=A(o,e.logger),v=m(async()=>{i.length=0;for(const t of l.mailers)try{let r;if(S(t))r=t({});else if(F(t))r=t;else{n.debug(`Skipping invalid mailer: ${t}`);continue}try{await r.initialize(),i.push(r),n.debug(`Initialized provider: ${r.name??"unknown"}`)}catch(s){n.debug(`Failed to initialize provider ${r.name??"unknown"}:`,s)}}catch(r){n.debug("Error processing mailer:",r)}if(i.length===0)throw new f(o,"No providers could be initialized");a=Math.floor(Math.random()*i.length),n.debug(`Round robin starting at index ${a} (${i[a]?.name??"unknown"})`)},"initializeProviders"),b=m(async()=>{if(i.length===0)return;const t=a;let r=0;for(;r<i.length;){const s=i[a];if(!s){a=(a+1)%i.length,r+=1;continue}const g=s.name??`provider-${a+1}`;try{if(await s.isAvailable())return a=(a+1)%i.length,n.debug(`Selected provider: ${g} (index ${a===0?i.length-1:a-1})`),s}catch{}a=(a+1)%i.length,r+=1,r<i.length&&l.retryAfter>0&&await new Promise(u=>{setTimeout(()=>{u(void 0)},l.retryAfter)})}return n.debug(`No available providers found, using provider at index ${t}`),i[t]??void 0},"getNextProvider");return{features:k(l.mailers),async initialize(){if(!p)try{await v(),p=!0,n.debug(`Round robin provider initialized with ${i.length} provider(s)`)}catch(t){throw new f(o,`Failed to initialize: ${t.message}`,{cause:t})}},async isAvailable(){try{return i.length===0&&await v(),(await Promise.allSettled(i.map(t=>t.isAvailable()))).some(t=>t.status==="fulfilled"&&t.value)}catch{return!1}},name:o,options:l,async sendEmail(t){try{if(i.length===0&&await v(),i.length===0)return{error:new f(o,"No providers available"),success:!1};const r=await b();if(!r)return{error:new f(o,"No available providers found"),success:!1};const s=r.name??"unknown";n.debug(`Sending email via ${s}`);const g=await r.sendEmail(t);if(g.success)return n.debug(`Email sent successfully via ${s}`),{data:{...g.data,provider:`${o}(${s})`},success:!0};n.debug(`Failed to send via ${s}, trying next provider`);const u=[];g.error&&u.push(g.error);let w=0;for(;w<i.length-1;){const d=await b();if(!d||d===r)break;const h=d.name??"unknown";n.debug(`Retrying with ${h}`);try{const c=await d.sendEmail(t);if(c.success)return n.debug(`Email sent successfully via ${h} (after retry)`),{data:{...c.data,provider:`${o}(${h})`},success:!0};c.error&&u.push(c.error)}catch(c){u.push(c instanceof Error?c:new Error(String(c)))}w+=1}const $=u.map(d=>d instanceof Error?d.message:String(d)).join("; ");return{error:new f(o,`Failed to send email via all providers. Errors: ${$}`,{cause:u[0]instanceof Error?u[0]:new Error(String(u[0]))}),success:!1}}catch(r){return{error:new f(o,`Failed to send email: ${r.message}`,{cause:r}),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{L as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as o}from"../../packem_shared/failoverProvider-
|
|
1
|
+
import{default as o}from"../../packem_shared/failoverProvider-D90MHT2T.js";export{o as failoverProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as d}from"../../packem_shared/roundRobinProvider-
|
|
1
|
+
import{default as d}from"../../packem_shared/roundRobinProvider-B_60F0BC.js";export{d as roundRobinProvider};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { F as FeatureFlags, E as EmailOptions } from "../../packem_shared/types.d-wwpgA3to.js";
|
|
2
|
+
import 'node:buffer';
|
|
3
|
+
/**
|
|
4
|
+
* A single capability that a message uses but the target provider cannot represent.
|
|
5
|
+
*/
|
|
6
|
+
interface FeatureViolation {
|
|
7
|
+
/**
|
|
8
|
+
* The provider capability flag that is not supported.
|
|
9
|
+
*/
|
|
10
|
+
feature: keyof FeatureFlags;
|
|
11
|
+
/**
|
|
12
|
+
* The message field that triggered the check.
|
|
13
|
+
*/
|
|
14
|
+
field: string;
|
|
15
|
+
/**
|
|
16
|
+
* Human-readable explanation of the violation.
|
|
17
|
+
*/
|
|
18
|
+
message: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Result of a fail-fast provider capability check.
|
|
22
|
+
*/
|
|
23
|
+
interface FeatureSupportResult {
|
|
24
|
+
/**
|
|
25
|
+
* True when the message uses no capability the provider has explicitly disabled.
|
|
26
|
+
*/
|
|
27
|
+
supported: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* The list of capabilities the message uses that the provider cannot represent.
|
|
30
|
+
*/
|
|
31
|
+
violations: FeatureViolation[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Performs a fail-fast field-support check for a message against a provider's declared capabilities.
|
|
35
|
+
*
|
|
36
|
+
* A capability counts as a violation only when the message actually uses it **and** the provider
|
|
37
|
+
* has explicitly declared it unsupported (`features[capability] === false`). Capabilities left
|
|
38
|
+
* `undefined` are treated as "unknown" and never raise a violation, so providers that publish a
|
|
39
|
+
* partial (or no) {@link FeatureFlags} map are never falsely rejected.
|
|
40
|
+
* @param options The normalized email options about to be sent.
|
|
41
|
+
* @param features The target provider's declared capabilities. When omitted the check is a no-op.
|
|
42
|
+
* @returns A {@link FeatureSupportResult} describing any unsupported capabilities in use.
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* const { supported, violations } = checkFeatureSupport(message, provider.features);
|
|
46
|
+
*
|
|
47
|
+
* if (!supported) {
|
|
48
|
+
* throw new Error(violations.map((v) => v.message).join(", "));
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
declare function checkFeatureSupport(options: EmailOptions, features?: FeatureFlags): FeatureSupportResult;
|
|
53
|
+
export { FeatureSupportResult, FeatureViolation, checkFeatureSupport as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i=Object.defineProperty;var l=(e,a)=>i(e,"name",{value:a,configurable:!0});import{i as u}from"../../packem_shared/headers-to-record-Qo124ImV.js";var n=Object.defineProperty,t=l((e,a)=>n(e,"name",{value:a,configurable:!0}),"t");const o=t(e=>Array.isArray(e)&&e.length>0,"hasItems"),c=t((e,a)=>a.find(r=>e[r]!==void 0),"firstSetField"),f=[{detect:t(e=>o(e.attachments)?"attachments":void 0,"detect"),feature:"attachments",label:"attachments"},{detect:t(e=>typeof e.html=="string"&&e.html.length>0?"html":void 0,"detect"),feature:"html",label:"HTML content"},{detect:t(e=>e.replyTo?"replyTo":void 0,"detect"),feature:"replyTo",label:"a reply-to address"},{detect:t(e=>e.headers!==void 0&&Object.keys(u(e.headers)).length>0?"headers":void 0,"detect"),feature:"customHeaders",label:"custom headers"},{detect:t(e=>o(e.tags)?"tags":void 0,"detect"),feature:"tagging",label:"tags"},{detect:t(e=>c(e,["scheduledAt","sendAt"]),"detect"),feature:"scheduling",label:"scheduled delivery"},{detect:t(e=>c(e,["templateId","template"]),"detect"),feature:"templates",label:"provider templates"}];function h(e,a){if(!a)return{supported:!0,violations:[]};const r=[];for(const d of f){if(a[d.feature]!==!1)continue;const s=d.detect(e);s!==void 0&&r.push({feature:d.feature,field:s,message:`Message uses ${d.label} (field "${s}") but the provider does not support the "${d.feature}" capability`})}return{supported:r.length===0,violations:r}}l(h,"f");t(h,"checkFeatureSupport");export{h as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/email",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.34",
|
|
4
4
|
"description": "A comprehensive email library with multi-provider support, crypto utilities, and template engines",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ahasend",
|
|
@@ -249,6 +249,10 @@
|
|
|
249
249
|
"types": "./dist/utils/validation/verify-email.d.ts",
|
|
250
250
|
"default": "./dist/utils/validation/verify-email.js"
|
|
251
251
|
},
|
|
252
|
+
"./validation/check-feature-support": {
|
|
253
|
+
"types": "./dist/utils/validation/check-feature-support.d.ts",
|
|
254
|
+
"default": "./dist/utils/validation/check-feature-support.js"
|
|
255
|
+
},
|
|
252
256
|
"./utils/normalize-email-aliases": {
|
|
253
257
|
"types": "./dist/utils/normalize-email-aliases.d.ts",
|
|
254
258
|
"default": "./dist/utils/normalize-email-aliases.js"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var p=Object.defineProperty;var l=(o,e)=>p(o,"name",{value:e,configurable:!0});import{MailMessage as f}from"./MailMessage-Dy1gP5e-.js";import{z as b}from"./build-mime-message-6xstxaUV.js";import{c as m}from"./create-logger-BiWdqFNg.js";import{i as n}from"./headers-to-record-Qo124ImV.js";var y=Object.defineProperty,C=l((o,e)=>y(o,"name",{value:e,configurable:!0}),"s");class h extends f{static{l(this,"DraftMailMessage")}static{C(this,"DraftMailMessage")}constructor(){super(),this.header("X-Unsent","1")}}var M=Object.defineProperty,c=l((o,e)=>M(o,"name",{value:e,configurable:!0}),"n");const v=c((o,e,s)=>{e.success&&e.data?o&&o.info("Email sent successfully",{messageId:e.data.messageId,provider:e.data.provider}):o&&o.error("Email send failed",{error:e.error,provider:s})},"logSendResult");class d{static{l(this,"Mail")}static{c(this,"Mail")}static extractErrorMessages(e){return e instanceof Error?[e.message]:[String(e??"Unknown error")]}provider;logger;loggerInstance;globalConfig;constructor(e){this.provider=e}setLogger(e){return this.loggerInstance=e,this.logger=m("Mail",e),this}setFrom(e){return this.globalConfig??={},this.globalConfig.from=e,this.logger&&this.logger.debug("Default from address updated",{from:e.email}),this}setReplyTo(e){return this.globalConfig??={},this.globalConfig.replyTo=e,this.logger&&this.logger.debug("Default reply-to address updated",{replyTo:e.email}),this}setHeaders(e){if(this.globalConfig??={},this.globalConfig.headers=e,this.logger){const s=n(e);this.logger.debug("Default headers updated",{count:Object.keys(s).length,headers:Object.keys(s)})}return this}async draft(e){let s=e instanceof f||e instanceof h?await this.buildDraftFromMessage(e):await this.buildDraftFromOptions(e);s=this.applyGlobalConfig(s);const t=s.headers?n(s.headers):{};s.headers={...t,"X-Unsent":"1"};const r=await b(s);return this.logger&&this.logger.debug("Draft created successfully in EML format",{from:s.from.email,size:r.length,subject:s.subject,to:Array.isArray(s.to)?s.to.length:1}),r}async send(e){if(e instanceof h)throw new TypeError("Cannot send draft messages. Convert to MailMessage first or remove X-Unsent header.");let s;if(e instanceof f)this.logger&&this.logger.debug("Sending MailMessage instance"),this.loggerInstance&&e.setLogger(this.loggerInstance),s=await e.build();else{const r=e;this.logger&&this.logger.debug("Sending email with options",{subject:r.subject,to:Array.isArray(r.to)?r.to.length:1}),s=r}s=this.applyGlobalConfig(s);const t=await this.provider.sendEmail(s);return v(this.logger,t,this.provider.name??"unknown"),t}async*sendMany(e,s){const t=this.provider.name;let r=0,g=0,i=0;this.logger&&this.logger.debug("Starting batch email send",{provider:t});for await(const u of e){if(u instanceof h)throw new TypeError("Cannot send draft messages. Convert to MailMessage first or remove X-Unsent header.");if(s?.signal?.aborted){this.logger&&this.logger.warn("Batch send operation was aborted",{failed:i,processed:r,successful:g}),yield{errorMessages:["Send operation was aborted"],provider:t,successful:!1};return}r+=1;try{const a=await this.send(u);a.success&&a.data?(g+=1,this.logger&&this.logger.debug(`Email ${r} sent successfully`,{messageId:a.data.messageId}),yield{messageId:a.data.messageId,provider:a.data.provider??t,response:a.data.response,successful:!0,timestamp:a.data.timestamp}):(i+=1,this.logger&&this.logger.error(`Email ${r} send failed`,{error:a.error}),yield{errorMessages:d.extractErrorMessages(a.error),provider:t,successful:!1})}catch(a){i+=1,this.logger&&this.logger.error(`Email ${r} send failed with exception`,a),yield{errorMessages:d.extractErrorMessages(a),provider:t,successful:!1}}}this.logger&&this.logger.debug("Batch email send completed",{failureCount:i,processedCount:r,provider:t,successCount:g})}async buildDraftFromMessage(e){return this.logger&&this.logger.debug("Creating draft from MailMessage instance"),this.loggerInstance&&e.setLogger(this.loggerInstance),this.applyGlobalConfigToMessage(e),await e.build()}async buildDraftFromOptions(e){return this.logger&&this.logger.debug("Creating draft from email options",{subject:e.subject,to:Array.isArray(e.to)?e.to.length:1}),e}applyGlobalConfigToMessage(e){const s=this.globalConfig?.from;s&&!e.getFrom()&&e.from(s);const t=this.globalConfig?.replyTo;if(t&&!e.getReplyTo()&&e.replyTo(t),this.globalConfig?.headers){const r=n(this.globalConfig.headers);Object.entries(r).forEach(([g,i])=>{e.header(g,i)})}}applyGlobalConfig(e){if(!this.globalConfig)return e;const s={...e};if(!s.from&&this.globalConfig.from&&(s.from=this.globalConfig.from,this.logger&&this.logger.debug("Applied global from address",{from:this.globalConfig.from.email})),!s.replyTo&&this.globalConfig.replyTo&&(s.replyTo=this.globalConfig.replyTo,this.logger&&this.logger.debug("Applied global reply-to address",{replyTo:this.globalConfig.replyTo.email})),this.globalConfig.headers){const t=n(this.globalConfig.headers),r=s.headers?n(s.headers):{};s.headers={...t,...r},this.logger&&this.logger.debug("Merged global headers",{globalCount:Object.keys(t).length,messageCount:Object.keys(r).length})}return s}}const D=c(o=>new d(o),"createMail");export{d as Mail,D as createMail};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var w=Object.defineProperty;var b=(e,l)=>w(e,"name",{value:l,configurable:!0});import u from"./EmailError-zm2ffVav.js";import $ from"./RequiredOptionError-CevW3u2K.js";import{c as E}from"./create-logger-BiWdqFNg.js";import{s as A}from"./generate-message-id-D4uA8gkj.js";import{defineProvider as z}from"./defineProvider-CtLH0VBE.js";var P=Object.defineProperty,p=b((e,l)=>P(e,"name",{value:l,configurable:!0}),"v");const F=p(e=>typeof e=="function","isProviderFactory"),k=p(e=>e!==null&&typeof e=="object"&&"sendEmail"in e&&"initialize"in e&&"isAvailable"in e,"isProvider"),o="failover",C=z((e={})=>{if(!e.mailers||e.mailers.length===0)throw new $(o,"mailers");const l={debug:e.debug??!1,mailers:e.mailers,retryAfter:e.retryAfter??60};let h=!1;const t=[],n=E(o,e.logger);let g;const m=p(async()=>g||(g=(async()=>{t.length=0;for(const a of l.mailers)try{let r;if(F(a))r=a({});else if(k(a))r=a;else{n.debug(`Skipping invalid mailer: ${a}`);continue}try{await r.initialize(),t.push(r),n.debug(`Initialized provider: ${r.name??"unknown"}`)}catch(c){n.debug(`Failed to initialize provider ${r.name??"unknown"}:`,c)}}catch(r){n.debug("Error processing mailer:",r)}if(t.length===0)throw new u(o,"No providers could be initialized")})(),g),"initializeProviders");return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!1,tracking:!1},async initialize(){if(!h)try{await m(),h=!0,n.debug(`Failover provider initialized with ${t.length} provider(s)`)}catch(a){throw new u(o,`Failed to initialize: ${a.message}`,{cause:a})}},async isAvailable(){try{t.length===0&&await m();for(const a of t)try{if(await a.isAvailable())return!0}catch{}return!1}catch{return!1}},name:o,options:l,async sendEmail(a){try{if(t.length===0&&await m(),t.length===0)return{error:new u(o,"No providers available"),success:!1};const r=[];let c;for(let s=0;s<t.length;s+=1){const f=t[s];if(!f)continue;const d=f.name??`provider-${s+1}`;n.debug(`Attempting to send email via ${d} (${s+1}/${t.length})`);try{if(!await f.isAvailable()){n.debug(`Provider ${d} is not available, skipping`),r.push(new u(o,`Provider ${d} is not available`));continue}const i=await f.sendEmail(a);if(i.success&&i.data)return n.debug(`Email sent successfully via ${d}`),{data:{...i.data,messageId:i.data.messageId||A(),provider:`${o}(${d})`},success:!0};if(i.error){c=i.error,r.push(i.error);const v=i.error instanceof Error?i.error.message:String(i.error);n.debug(`Failed to send via ${d}:`,v)}}catch(i){c=i instanceof Error?i:new Error(String(i)),r.push(c);const v=c instanceof Error?c.message:String(c);n.debug(`Exception sending via ${d}:`,v)}s<t.length-1&&l.retryAfter>0&&(n.debug(`Waiting ${l.retryAfter}ms before trying next provider`),await new Promise(i=>{setTimeout(()=>{i()},l.retryAfter)}))}const y=r.map(s=>s instanceof Error?s.message:String(s)).join("; ");return{error:new u(o,`All providers failed. Errors: ${y}`,{cause:c}),success:!1}}catch(r){return{error:new u(o,`Failed to send email: ${r.message}`,{cause:r}),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{C as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var mr=Object.defineProperty;var $=(t,n)=>mr(t,"name",{value:n,configurable:!0});import{createRequire as hr}from"node:module";const xr=hr(import.meta.url),C=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,br=$(t=>{if(typeof C<"u"&&C.versions&&C.versions.node){const[n,a]=C.versions.node.split(".").map(Number);if(n>22||n===22&&a>=3||n===20&&a>=16)return C.getBuiltinModule(t)}return xr(t)},"__cjs_getBuiltinModule"),{createRequire:te}=br("node:module"),vr=0,$r=4;var wr=Object.defineProperty,yr=$((t,n)=>wr(t,"name",{value:n,configurable:!0}),"t$2"),jr=Object.defineProperty,zr=yr((t,n)=>jr(t,"name",{value:n,configurable:!0}),"t"),Pr=Object.defineProperty,Or=zr((t,n)=>Pr(t,"name",{value:n,configurable:!0}),"n");const Me=Or(t=>{if(!t||!(t instanceof URL)&&typeof t!="string")throw new TypeError("Path must be a non-empty string or URL.")},"assertValidFileOrDirectoryPath");var Mr=Object.defineProperty,l=$((t,n)=>Mr(t,"name",{value:n,configurable:!0}),"s$2");let ye=l(()=>{var t=(()=>{var n=Object.defineProperty,a=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.prototype.hasOwnProperty,x=l((e,r)=>{for(var o in r)n(e,o,{get:r[o],enumerable:!0})},"ne"),w=l((e,r,o,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of u(r))!d.call(e,s)&&s!==o&&n(e,s,{get:l(()=>r[s],"get"),enumerable:!(i=a(r,s))||i.enumerable});return e},"ae"),b=l(e=>w(n({},"__esModule",{value:!0}),e),"oe"),_={};x(_,{zeptomatch:l(()=>we,"zeptomatch")});var T=l(e=>{const r=new Set,o=[e];for(let i=0;i<o.length;i++){const s=o[i];if(r.has(s))continue;r.add(s);const{children:c}=s;if(c?.length)for(let p=0,g=c.length;p<g;p++)o.push(c[p])}return Array.from(r)},"M"),U=l(e=>{let r="";const o=T(e);for(let i=0,s=o.length;i<s;i++){const c=o[i];if(!c.regex)continue;const p=c.regex.flags;if(r||(r=p),r!==p)throw new Error(`Inconsistent RegExp flags used: "${r}" and "${p}"`)}return r},"se"),ne=l((e,r,o)=>{const i=o.get(e);if(i!==void 0)return i;const s=e.partial??r;let c="";if(e.regex&&(c+=s?"(?:$|":"",c+=e.regex.source),e.children?.length){const p=Ue(e.children.map(g=>ne(g,r,o)).filter(Boolean));if(p?.length){const g=e.children.some(q=>!q.regex||!(q.partial??r)),h=p.length>1||s&&(!c.length||g);c+=h?s?"(?:$|":"(?:":"",c+=p.join("|"),c+=h?")":""}}return e.regex&&(c+=s?")":""),o.set(e,c),c},"O"),Ne=l((e,r)=>{const o=new Map,i=T(e);for(let s=i.length-1;s>=0;s--){const c=ne(i[s],r,o);if(!(s>0))return c}return""},"ie"),Ue=l(e=>Array.from(new Set(e)),"ue"),V=l((e,r,o)=>V.compile(e,o).test(r),"R");V.compile=(e,r)=>{const o=r?.partial??!1,i=Ne(e,o),s=U(e);return new RegExp(`^(?:${i})$`,s)};var De=V,Ge=l((e,r)=>{const o=De.compile(e,r),i=`${o.source.slice(0,-1)}[\\\\/]?$`,s=o.flags;return new RegExp(i,s)},"le"),Ve=Ge,Ye=l(e=>{const r=e.map(i=>i.source).join("|")||"$^",o=e[0]?.flags;return new RegExp(r,o)},"ve"),He=Ye,oe=l(e=>Array.isArray(e),"j"),B=l(e=>typeof e=="function","_"),Je=l(e=>e.length===0,"he"),Ke=(()=>{const{toString:e}=Function.prototype,r=/(?:^\(\s*(?:[^,.()]|\.(?!\.\.))*\s*\)\s*=>|^\s*[a-zA-Z$_][a-zA-Z0-9$_]*\s*=>)/;return o=>(o.length===0||o.length===1)&&r.test(e.call(o))})(),Qe=l(e=>typeof e=="number","de"),Xe=l(e=>typeof e=="object"&&e!==null,"xe"),et=l(e=>e instanceof RegExp,"me"),tt=(()=>{const e=/\\\(|\((?!\?(?::|=|!|<=|<!))/;return r=>e.test(r.source)})(),rt=(()=>{const e=/^[a-zA-Z0-9_-]+$/;return r=>e.test(r.source)&&!r.flags.includes("i")})(),se=l(e=>typeof e=="string","A"),P=l(e=>e===void 0,"f"),nt=l(e=>{const r=new Map;return o=>{const i=r.get(o);if(i!==void 0)return i;const s=e(o);return r.set(o,s),s}},"ye"),ie=l((e,r,o={})=>{const i={cache:{},input:e,index:0,indexBacktrackMax:0,options:o,output:[]},s=O(r)(i),c=Math.max(i.index,i.indexBacktrackMax);if(s&&i.index===e.length)return i.output;throw new Error(`Failed to parse at index ${c}`)},"I"),f=l((e,r)=>oe(e)?ot(e,r):se(e)?ae(e,r):st(e,r),"i"),ot=l((e,r)=>{const o={};for(const i of e){if(i.length!==1)throw new Error(`Invalid character: "${i}"`);const s=i.charCodeAt(0);o[s]=!0}return i=>{const s=i.input;let c=i.index,p=c;for(;p<s.length&&s.charCodeAt(p)in o;)p+=1;if(p>c){if(!P(r)&&!i.options.silent){const g=s.slice(c,p),h=B(r)?r(g,s,`${c}`):r;P(h)||i.output.push(h)}i.index=p}return!0}},"we"),st=l((e,r)=>{if(rt(e))return ae(e.source,r);{const o=e.source,i=e.flags.replace(/y|$/,"y"),s=new RegExp(o,i);return tt(e)&&B(r)&&!Ke(r)?it(s,r):at(s,r)}},"$e"),it=l((e,r)=>o=>{const i=o.index,s=o.input;e.lastIndex=i;const c=e.exec(s);if(c){const p=e.lastIndex;if(!o.options.silent){const g=r(...c,s,`${i}`);P(g)||o.output.push(g)}return o.index=p,!0}else return!1},"Ee"),at=l((e,r)=>o=>{const i=o.index,s=o.input;if(e.lastIndex=i,e.test(s)){const c=e.lastIndex;if(!P(r)&&!o.options.silent){const p=B(r)?r(s.slice(i,c),s,`${i}`):r;P(p)||o.output.push(p)}return o.index=c,!0}else return!1},"Ce"),ae=l((e,r)=>o=>{const i=o.index,s=o.input;if(s.startsWith(e,i)){if(!P(r)&&!o.options.silent){const c=B(r)?r(e,s,`${i}`):r;P(c)||o.output.push(c)}return o.index+=e.length,!0}else return!1},"F"),Y=l((e,r,o,i)=>{const s=O(e),c=r>1;return J(H(ce(p=>{let g=0;for(;g<o;){const h=p.index;if(!s(p)||(g+=1,p.index===h))break}return g>=r},c),i))},"k"),le=l((e,r)=>Y(e,0,1,r),"L"),D=l((e,r)=>Y(e,0,1/0,r),"$"),lt=l((e,r)=>Y(e,1,1/0,r),"Re"),k=l((e,r)=>{const o=e.map(O);return J(H(ce(i=>{for(let s=0,c=o.length;s<c;s++)if(!o[s](i))return!1;return!0}),r))},"x"),y=l((e,r)=>{const o=e.map(O);return J(H(i=>{for(let s=0,c=o.length;s<c;s++)if(o[s](i))return!0;return!1},r))},"p"),ce=l((e,r=!0,o=!1)=>{const i=O(e);return r?s=>{const c=s.index,p=s.output.length,g=i(s);return!g&&!o&&(s.indexBacktrackMax=Math.max(s.indexBacktrackMax,s.index)),(!g||o)&&(s.index=c,s.output.length!==p&&(s.output.length=p)),g}:i},"q"),H=l((e,r)=>{const o=O(e);return r?i=>{if(i.options.silent)return o(i);const s=i.output.length;if(o(i)){const c=i.output.splice(s,1/0),p=r(c);return P(p)||i.output.push(p),!0}else return!1}:o},"B"),J=(()=>{let e=0;return r=>{const o=O(r),i=e+=1;return s=>{var c;if(s.options.memoization===!1)return o(s);const p=s.index,g=(c=s.cache)[i]||(c[i]={indexMax:-1,queue:[]}),h=g.queue;if(p<=g.indexMax){const W=g.store||(g.store=new Map);if(h.length){for(let R=0,fr=h.length;R<fr;R+=2){const gr=h[R*2],dr=h[R*2+1];W.set(gr,dr)}h.length=0}const j=W.get(p);if(j===!1)return!1;if(Qe(j))return s.index=j,!0;if(j)return s.index=j.index,j.output?.length&&s.output.push(...j.output),!0}const q=s.output.length,pr=o(s);if(g.indexMax=Math.max(g.indexMax,p),pr){const W=s.index,j=s.output.length;if(j>q){const R=s.output.slice(q,j);h.push(p,{index:W,output:R})}else h.push(p,W);return!0}else return h.push(p,!1),!1}}})(),ue=l(e=>{let r;return o=>(r||(r=O(e())),r(o))},"G"),O=nt(e=>{if(B(e))return Je(e)?ue(e):e;if(se(e)||et(e))return f(e);if(oe(e))return k(e);if(Xe(e))return y(Object.values(e));throw new Error("Invalid rule")}),E=l(e=>e,"d"),ct=l(e=>typeof e=="string","ke"),ut=l(e=>{const r=new WeakMap,o=new WeakMap;return(i,s)=>{const c=s?.partial?o:r,p=c.get(i);if(p!==void 0)return p;const g=e(i,s);return c.set(i,g),g}},"Be"),pt=l(e=>{const r={},o={};return(i,s)=>{const c=s?.partial?o:r;return c[i]??(c[i]=e(i,s))}},"Pe"),ft=f(/\\./,E),gt=f(/./,E),dt=f(/\*\*\*+/,"*"),mt=f(/([^/{[(!])\*\*/,(e,r)=>`${r}*`),ht=f(/(^|.)\*\*(?=[^*/)\]}])/,(e,r)=>`${r}*`),xt=D(y([ft,dt,mt,ht,gt])),bt=xt,vt=l(e=>ie(e,bt,{memoization:!1}).join(""),"Ie"),$t=vt,pe="abcdefghijklmnopqrstuvwxyz",wt=l(e=>{let r="";for(;e>0;){const o=(e-1)%26;r=pe[o]+r,e=Math.floor((e-1)/26)}return r},"Le"),fe=l(e=>{let r=0;for(let o=0,i=e.length;o<i;o++)r=r*26+pe.indexOf(e[o])+1;return r},"V"),K=l((e,r)=>{if(r<e)return K(r,e);const o=[];for(;e<=r;)o.push(e++);return o},"b"),yt=l((e,r,o)=>K(e,r).map(i=>String(i).padStart(o,"0")),"qe"),ge=l((e,r)=>K(fe(e),fe(r)).map(wt),"W"),m=l(e=>({partial:!1,regex:new RegExp(e,"s"),children:[]}),"c"),S=l(e=>({children:e}),"y"),A=(()=>{const e=l((r,o,i)=>{if(i.has(r))return;i.add(r);const{children:s}=r;if(!s.length)s.push(o);else for(let c=0,p=s.length;c<p;c++)e(s[c],o,i)},"e");return r=>{if(!r.length)return S([]);for(let o=r.length-1;o>=1;o--){const i=new Set,s=r[o-1],c=r[o];e(s,c,i)}return r[0]}})(),M=l(()=>({regex:new RegExp("[\\\\/]","s"),children:[]}),"g"),jt=f(/\\./,m),zt=f(/[$.*+?^(){}[\]\|]/,e=>m(`\\${e}`)),Pt=f(/[\\\/]/,M),Ot=f(/[^$.*+?^(){}[\]\|\\\/]+/,m),Mt=f(/^(?:!!)*!(.*)$/,(e,r)=>m(`(?!^${we.compile(r).source}$).*?`)),_t=f(/^(!!)+/),Et=y([Mt,_t]),kt=f(/\/(\*\*\/)+/,()=>S([A([M(),m(".+?"),M()]),M()])),At=f(/^(\*\*\/)+/,()=>S([m("^"),A([m(".*?"),M()])])),Rt=f(/\/(\*\*)$/,()=>S([A([M(),m(".*?")]),m("$")])),Tt=f(/\*\*/,()=>m(".*?")),de=y([kt,At,Rt,Tt]),Bt=f(/\*\/(?!\*\*\/|\*$)/,()=>A([m("[^\\\\/]*?"),M()])),St=f(/\*/,()=>m("[^\\\\/]*")),me=y([Bt,St]),he=f("?",()=>m("[^\\\\/]")),qt=f("[",E),Wt=f("]",E),Ct=f(/[!^]/,"^\\\\/"),It=f(/[a-z]-[a-z]|[0-9]-[0-9]/i,E),Lt=f(/\\./,E),Zt=f(/[$.*+?^(){}[\|]/,e=>`\\${e}`),Ft=f(/[\\\/]/,"\\\\/"),Nt=f(/[^$.*+?^(){}[\]\|\\\/]+/,E),Ut=y([Lt,Zt,Ft,It,Nt]),xe=k([qt,le(Ct),D(Ut),Wt],e=>m(e.join(""))),Dt=f("{","(?:"),Gt=f("}",")"),Vt=f(/(\d+)\.\.(\d+)/,(e,r,o)=>yt(+r,+o,Math.min(r.length,o.length)).join("|")),Yt=f(/([a-z]+)\.\.([a-z]+)/,(e,r,o)=>ge(r,o).join("|")),Ht=f(/([A-Z]+)\.\.([A-Z]+)/,(e,r,o)=>ge(r.toLowerCase(),o.toLowerCase()).join("|").toUpperCase()),Jt=y([Vt,Yt,Ht]),be=k([Dt,Jt,Gt],e=>m(e.join(""))),Kt=f("{"),Qt=f("}"),Xt=f(","),er=f(/\\./,m),tr=f(/[$.*+?^(){[\]\|]/,e=>m(`\\${e}`)),rr=f(/[\\\/]/,M),nr=f(/[^$.*+?^(){}[\]\|\\\/,]+/,m),or=ue(()=>$e),sr=f("",()=>m("(?:)")),ir=lt(y([de,me,he,xe,be,or,er,tr,rr,nr]),A),ve=y([ir,sr]),$e=k([Kt,le(k([ve,D(k([Xt,ve]))])),Qt],S),ar=D(y([Et,de,me,he,xe,be,$e,jt,zt,Pt,Ot]),A),lr=ar,cr=l(e=>ie(e,lr,{memoization:!1})[0],"kr"),ur=cr,Q=l((e,r,o)=>Q.compile(e,o).test(r),"N");Q.compile=(()=>{const e=pt((o,i)=>Ve(ur($t(o)),i)),r=ut((o,i)=>He(o.map(s=>e(s,i))));return(o,i)=>ct(o)?e(o,i):r(o,i)})();var we=Q;return b(_)})();return t.default||t},"_lazyMatch"),X;const _r=l((t,n)=>(X||(X=ye(),ye=null),X(t,n)),"zeptomatch"),Er=/^[A-Z]:\//i,z=l((t="")=>t&&t.replaceAll("\\","/").replace(Er,n=>n.toUpperCase()),"normalizeWindowsPath"),kr=/^[/\\]{2}/,Ar=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,_e=/^[A-Z]:$/i,je=/^\/([A-Z]:)?$/i,Rr=/.(\.[^./]+)$/,Tr=/^[/\\]|^[a-z]:[/\\]/i,Br=/\/$/,Sr=l(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd"),Ee=l((t,n)=>{let a="",u=0,d=-1,x=0,w;for(let b=0;b<=t.length;++b){if(b<t.length)w=t[b];else{if(w==="/")break;w="/"}if(w==="/"){if(!(d===b-1||x===1))if(x===2){if(a.length<2||u!==2||!a.endsWith(".")||a.at(-2)!=="."){if(a.length>2){const _=a.lastIndexOf("/");_===-1?(a="",u=0):(a=a.slice(0,_),u=a.length-1-a.lastIndexOf("/")),d=b,x=0;continue}else if(a.length>0){a="",u=0,d=b,x=0;continue}}n&&(a+=a.length>0?"/..":"..",u=2)}else a.length>0?a+=`/${t.slice(d+1,b)}`:a=t.slice(d+1,b),u=b-d-1;d=b,x=0}else w==="."&&x!==-1?++x:x=-1}return a},"normalizeString"),F=l(t=>Ar.test(t),"isAbsolute"),ke=l(function(t){if(t.length===0)return".";t=z(t);const n=kr.exec(t),a=F(t),u=t.at(-1)==="/";return t=Ee(t,!a),t.length===0?a?"/":u?"./":".":(u&&(t+="/"),_e.test(t)&&(t+="/"),n?a?`//${t}`:`//./${t}`:a&&!F(t)?`/${t}`:t)},"normalize"),Ae=l((...t)=>{let n="";for(const a of t)if(a)if(n.length>0){const u=n.at(-1)==="/",d=a[0]==="/";u&&d?n+=a.slice(1):n+=u||d?a:`/${a}`}else n+=a;return ke(n)},"join"),ee=l(function(...t){t=t.map(u=>z(u));let n="",a=!1;for(let u=t.length-1;u>=-1&&!a;u--){const d=u>=0?t[u]:Sr();!d||d.length===0||(n=`${d}/${n}`,a=F(d))}return n=Ee(n,!a),a&&!F(n)?`/${n}`:n.length>0?n:"."},"resolve");l(function(t){return z(t)},"toNamespacedPath");const Re=l(function(t){return Rr.exec(z(t))?.[1]??""},"extname");l(function(t,n){const a=ee(t).replace(je,"$1").split("/"),u=ee(n).replace(je,"$1").split("/");if(u[0][1]===":"&&a[0][1]===":"&&a[0]!==u[0])return u.join("/");const d=[...a];for(const x of d){if(u[0]!==x)break;a.shift(),u.shift()}return[...a.map(()=>".."),...u].join("/")},"relative");const qr=l(t=>{const n=z(t).replace(Br,"").split("/").slice(0,-1);return n.length===1&&_e.test(n[0])&&(n[0]=`${n[0]}/`),n.join("/")||(F(t)?"/":".")},"dirname");l(function(t){const n=[t.root,t.dir,t.base??t.name+t.ext].filter(Boolean);return z(t.root?ee(...n):n.join("/"))},"format");const Wr=l((t,n)=>{const a=z(t).split("/").pop();return n&&a.endsWith(n)?a.slice(0,-n.length):a},"basename");l(function(t){const n=Tr.exec(t)?.[0]?.replaceAll("\\","/")??"",a=Wr(t),u=Re(a);return{base:a,dir:qr(t),ext:u,name:a.slice(0,a.length-u.length),root:n}},"parse");l((t,n)=>_r(n,ke(t)),"matchesGlob");var Cr=Object.defineProperty,v=$((t,n)=>Cr(t,"name",{value:n,configurable:!0}),"i$2");const Ir=te(import.meta.url),I=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Lr=v(t=>{if(typeof I<"u"&&I.versions&&I.versions.node){const[n,a]=I.versions.node.split(".").map(Number);if(n>22||n===22&&a>=3||n===20&&a>=16)return I.getBuiltinModule(t)}return Ir(t)},"__cjs_getBuiltinModule"),{fileURLToPath:Zr}=Lr("node:url");function Te(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}$(Te,"w$1");v(Te,"getDefaultExportFromCjs");var ze,Pe;function Be(){return Pe||(Pe=1,ze=["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cr3","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),ze}$(Be,"y");v(Be,"requireBinaryExtensions");var Fr=Be();const Nr=Te(Fr),Ur=new Set(Nr),Dr=new Set(["/","\\",void 0]),Oe=Symbol.for("pathe:normalizedAlias"),Gr=/(^|[/\\])([^/\\]+?)(?=(?:\.[^.]+)?$)/,Vr=v((t,n)=>n.split("/").length-t.split("/").length,"compareAliases"),G=v((t="/")=>{const n=t.at(-1);return n==="/"||n==="\\"},"hasTrailingSlash"),Se=v(t=>{if(t[Oe])return t;const n=Object.fromEntries(Object.entries(t).toSorted(([a],[u])=>Vr(a,u)));for(const a in n)for(const u in n)u===a||a.startsWith(u)||n[a].startsWith(u)&&Dr.has(n[a][u.length])&&(n[a]=n[u]+n[a].slice(u.length));return Object.defineProperty(n,Oe,{enumerable:!1,value:!0}),n},"normalizeAliases");v((t,n)=>{t=z(t),n=Se(n);for(const[a,u]of Object.entries(n)){if(!t.startsWith(a))continue;const d=G(a)?a.slice(0,-1):a;if(G(t[d.length]))return Ae(u,t.slice(a.length))}return t},"resolveAlias");v(t=>Gr.exec(t)?.[2],"filename");v((t,n)=>{t=z(t),n=Se(n);for(const[a,u]of Object.entries(n).toReversed()){if(!t.startsWith(u))continue;const d=G(u)?u.slice(0,-1):u;if(G(t[d.length]))return Ae(a,t.slice(u.length))}return t},"reverseResolveAlias");const Yr=/^(?:\.?\.[/\\]|\.\.\B)/,Hr=/^(?:msys|cygwin)$/;v(t=>Yr.test(t)||t==="..","isRelative");v(t=>Ur.has(Re(t).slice(1).toLowerCase()),"isBinaryPath");const qe=v(t=>z(t instanceof URL?Zr(t):t),"toPath");v(()=>{if(!globalThis.process)return!1;if(globalThis.process.platform==="win32"||globalThis.process.platform==="cygwin")return!0;const t=globalThis.process.env.OSTYPE;return typeof t!="string"?!1:Hr.test(t)},"isWindows");var Jr=Object.defineProperty,We=$((t,n)=>Jr(t,"name",{value:n,configurable:!0}),"t$1"),Kr=Object.defineProperty,re=We((t,n)=>Kr(t,"name",{value:n,configurable:!0}),"s");const Qr=te(import.meta.url),L=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Xr=re(t=>{if(typeof L<"u"&&L.versions&&L.versions.node){const[n,a]=L.versions.node.split(".").map(Number);if(n>22||n===22&&a>=3||n===20&&a>=16)return L.getBuiltinModule(t)}return Qr(t)},"__cjs_getBuiltinModule"),{access:en}=Xr("node:fs/promises");var tn=Object.defineProperty,rn=re((t,n)=>tn(t,"name",{value:n,configurable:!0}),"o");async function N(t,n=vr){Me(t),t=qe(t);try{return await en(t,n),!0}catch{return!1}}$(N,"i$1");We(N,"d");re(N,"m");rn(N,"isAccessible");var nn=Object.defineProperty,Ce=$((t,n)=>nn(t,"name",{value:n,configurable:!0}),"t"),on=Object.defineProperty,Ie=Ce((t,n)=>on(t,"name",{value:n,configurable:!0}),"t"),sn=Object.defineProperty,an=Ie((t,n)=>sn(t,"name",{value:n,configurable:!0}),"o");let ln=class extends Error{static{$(this,"c")}static{Ce(this,"i")}static{Ie(this,"n")}static{an(this,"PermissionError")}constructor(n){super(`EPERM: Operation not permitted, ${n}`)}get code(){return"EPERM"}set code(n){throw new Error("Cannot overwrite code EPERM")}get name(){return"PermissionError"}set name(n){throw new Error("Cannot overwrite name of PermissionError")}};var cn=Object.defineProperty,un=$((t,n)=>cn(t,"name",{value:n,configurable:!0}),"f"),pn=Object.defineProperty,Le=un((t,n)=>pn(t,"name",{value:n,configurable:!0}),"i");const fn=te(import.meta.url),Z=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ze=Le(t=>{if(typeof Z<"u"&&Z.versions&&Z.versions.node){const[n,a]=Z.versions.node.split(".").map(Number);if(n>22||n===22&&a>=3||n===20&&a>=16)return Z.getBuiltinModule(t)}return fn(t)},"__cjs_getBuiltinModule"),{readFile:gn}=Ze("node:fs/promises"),{unzip:dn,brotliDecompress:mn}=Ze("node:zlib");var hn=Object.defineProperty,Fe=Le((t,n)=>hn(t,"name",{value:n,configurable:!0}),"n");const xn={brotli:mn,gzip:dn,none:Fe((t,n)=>{n(null,t)},"none")},wn=Fe(async(t,n)=>{if(Me(t),t=qe(t),!await N(t))throw new ln(`unable to read the non-accessible file: ${t}`);if(!await N(t,$r))throw new Error(`Unable to read the non-readable file: ${t}`);const{buffer:a,compression:u,encoding:d,flag:x}=n??{};return await gn(t,x?{encoding:d,flag:x}:{encoding:d}).then(async w=>await new Promise((b,_)=>{xn[u??"none"](w,(T,U)=>{T?_(T):b(a?U:U.toString())})})).catch(w=>{throw w})},"readFile");export{wn as B};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var E=Object.defineProperty;var y=(e,u)=>E(e,"name",{value:u,configurable:!0});import f from"./EmailError-zm2ffVav.js";import A from"./RequiredOptionError-CevW3u2K.js";import{c as k}from"./create-logger-BiWdqFNg.js";import{defineProvider as z}from"./defineProvider-CtLH0VBE.js";var P=Object.defineProperty,m=y((e,u)=>P(e,"name",{value:u,configurable:!0}),"f");const S=m(e=>typeof e=="function","isProviderFactory"),x=m(e=>e!=null&&typeof e=="object"&&"sendEmail"in e&&"initialize"in e&&"isAvailable"in e,"isProvider"),o="roundrobin",T=z((e={})=>{if(!e.mailers||e.mailers.length===0)throw new A(o,"mailers");const u={debug:e.debug??!1,logger:e.logger,mailers:e.mailers,retries:e.retries??3,retryAfter:e.retryAfter??60,timeout:e.timeout??3e4};let p=!1;const t=[];let a=0;const n=k(o,e.logger),v=m(async()=>{t.length=0;for(const i of u.mailers)try{let r;if(S(i))r=i({});else if(x(i))r=i;else{n.debug(`Skipping invalid mailer: ${i}`);continue}try{await r.initialize(),t.push(r),n.debug(`Initialized provider: ${r.name??"unknown"}`)}catch(s){n.debug(`Failed to initialize provider ${r.name??"unknown"}:`,s)}}catch(r){n.debug("Error processing mailer:",r)}if(t.length===0)throw new f(o,"No providers could be initialized");a=Math.floor(Math.random()*t.length),n.debug(`Round robin starting at index ${a} (${t[a]?.name??"unknown"})`)},"initializeProviders"),b=m(async()=>{if(t.length===0)return;const i=a;let r=0;for(;r<t.length;){const s=t[a];if(!s){a=(a+1)%t.length,r+=1;continue}const g=s.name??`provider-${a+1}`;try{if(await s.isAvailable())return a=(a+1)%t.length,n.debug(`Selected provider: ${g} (index ${a===0?t.length-1:a-1})`),s}catch{}a=(a+1)%t.length,r+=1,r<t.length&&u.retryAfter>0&&await new Promise(l=>{setTimeout(()=>{l(void 0)},u.retryAfter)})}return n.debug(`No available providers found, using provider at index ${i}`),t[i]??void 0},"getNextProvider");return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!1,tracking:!1},async initialize(){if(!p)try{await v(),p=!0,n.debug(`Round robin provider initialized with ${t.length} provider(s)`)}catch(i){throw new f(o,`Failed to initialize: ${i.message}`,{cause:i})}},async isAvailable(){try{return t.length===0&&await v(),(await Promise.allSettled(t.map(i=>i.isAvailable()))).some(i=>i.status==="fulfilled"&&i.value)}catch{return!1}},name:o,options:u,async sendEmail(i){try{if(t.length===0&&await v(),t.length===0)return{error:new f(o,"No providers available"),success:!1};const r=await b();if(!r)return{error:new f(o,"No available providers found"),success:!1};const s=r.name??"unknown";n.debug(`Sending email via ${s}`);const g=await r.sendEmail(i);if(g.success)return n.debug(`Email sent successfully via ${s}`),{data:{...g.data,provider:`${o}(${s})`},success:!0};n.debug(`Failed to send via ${s}, trying next provider`);const l=[];g.error&&l.push(g.error);let w=0;for(;w<t.length-1;){const c=await b();if(!c||c===r)break;const h=c.name??"unknown";n.debug(`Retrying with ${h}`);try{const d=await c.sendEmail(i);if(d.success)return n.debug(`Email sent successfully via ${h} (after retry)`),{data:{...d.data,provider:`${o}(${h})`},success:!0};d.error&&l.push(d.error)}catch(d){l.push(d instanceof Error?d:new Error(String(d)))}w+=1}const $=l.map(c=>c instanceof Error?c.message:String(c)).join("; ");return{error:new f(o,`Failed to send email via all providers. Errors: ${$}`,{cause:l[0]instanceof Error?l[0]:new Error(String(l[0]))}),success:!1}}catch(r){return{error:new f(o,`Failed to send email: ${r.message}`,{cause:r}),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{T as default};
|