@visulima/email 4.1.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +17 -0
- package/dist/crypto/index.d.ts +2 -2
- package/dist/deliverability/index.d.ts +1 -1
- package/dist/inbound/index.d.ts +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1 -1
- package/dist/middleware/index.d.ts +3 -3
- package/dist/packem_shared/{DraftMailMessage-B0gwf8n_.js → DraftMailMessage-zkKTOxQ8.js} +1 -1
- package/dist/packem_shared/Mail-DtpXUSIl.js +1 -0
- package/dist/packem_shared/MailMessage-Aw0vVAh-.js +1 -0
- package/dist/packem_shared/{createTestEmail-DWimjf0F.js → createTestEmail-B2Fz-Ifb.js} +1 -1
- package/dist/packem_shared/{mail.d-BdyyyQO5.d.ts → mail.d-2u-30lWz.d.ts} +12 -4
- package/dist/packem_shared/{provider.d-Cx5YQJdP.d.ts → provider.d-BLLbEuQ8.d.ts} +1 -1
- package/dist/packem_shared/resendProvider-BaIZCvph.js +1 -0
- package/dist/packem_shared/{types.d-Cb5fls_X.d.ts → types.d-A1Eea-p_.d.ts} +1 -1
- package/dist/packem_shared/{types.d-kHO4kX9q.d.ts → types.d-B5iH_mgb.d.ts} +1 -1
- package/dist/packem_shared/{types.d-GKqPNk0I.d.ts → types.d-Chhzb-48.d.ts} +1 -1
- package/dist/packem_shared/{types.d-B9295M4_.d.ts → types.d-CyiC9uRC.d.ts} +10 -0
- package/dist/packem_shared/{types.d-C5geVKes.d.ts → types.d-V_yuAOrx.d.ts} +1 -1
- package/dist/providers/ahasend/index.d.ts +3 -3
- package/dist/providers/autosend/index.d.ts +3 -3
- package/dist/providers/aws-ses/index.d.ts +3 -3
- package/dist/providers/azure/index.d.ts +3 -3
- package/dist/providers/brevo/index.d.ts +3 -3
- package/dist/providers/cloudflare-email/index.d.ts +4 -4
- package/dist/providers/failover/index.d.ts +3 -3
- package/dist/providers/file/index.d.ts +3 -3
- package/dist/providers/http/index.d.ts +3 -3
- package/dist/providers/infobip/index.d.ts +3 -3
- package/dist/providers/loops/index.d.ts +3 -3
- package/dist/providers/mailchannels/index.d.ts +3 -3
- package/dist/providers/mailcrab/index.d.ts +3 -3
- package/dist/providers/mailersend/index.d.ts +3 -3
- package/dist/providers/mailgun/index.d.ts +3 -3
- package/dist/providers/mailjet/index.d.ts +3 -3
- package/dist/providers/mailomat/index.d.ts +3 -3
- package/dist/providers/mailpace/index.d.ts +3 -3
- package/dist/providers/mailtrap/index.d.ts +3 -3
- package/dist/providers/mandrill/index.d.ts +3 -3
- package/dist/providers/mock/index.d.ts +5 -5
- package/dist/providers/netcore/index.d.ts +3 -3
- package/dist/providers/nodemailer/index.d.ts +3 -3
- package/dist/providers/opentelemetry/index.d.ts +2 -2
- package/dist/providers/outlook365/index.d.ts +3 -3
- package/dist/providers/plunk/index.d.ts +3 -3
- package/dist/providers/postal/index.d.ts +3 -3
- package/dist/providers/postmark/index.d.ts +3 -3
- package/dist/providers/resend/index.d.ts +3 -3
- package/dist/providers/resend/index.js +1 -1
- package/dist/providers/roundrobin/index.d.ts +3 -3
- package/dist/providers/scaleway/index.d.ts +3 -3
- package/dist/providers/sendgrid/index.d.ts +3 -3
- package/dist/providers/smtp/index.d.ts +4 -4
- package/dist/providers/sparkpost/index.d.ts +3 -3
- package/dist/providers/sweego/index.d.ts +3 -3
- package/dist/providers/zeptomail/index.d.ts +3 -3
- package/dist/queue/bullmq-queue.d.ts +2 -2
- package/dist/queue/index.d.ts +2 -2
- package/dist/queue/pg-boss-queue.d.ts +2 -2
- package/dist/queue/sqs-queue.d.ts +2 -2
- package/dist/queue/unstorage-queue.d.ts +2 -2
- package/dist/test/index.d.ts +6 -6
- package/dist/test/index.js +1 -1
- package/dist/utils/format-email-address.d.ts +1 -1
- package/dist/utils/parse-address.d.ts +1 -1
- package/dist/utils/parse-eml.d.ts +1 -1
- package/dist/utils/result.d.ts +1 -1
- package/dist/utils/validation/check-feature-support.d.ts +1 -1
- package/dist/utils/validation/check-feature-support.js +1 -1
- package/package.json +1 -1
- package/dist/packem_shared/Mail-0cxS6jre.js +0 -1
- package/dist/packem_shared/MailMessage-DmmaNHHc.js +0 -1
- package/dist/packem_shared/resendProvider-DC7Op5Gr.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## @visulima/email [4.2.0](https://github.com/visulima/visulima/compare/@visulima/email@4.1.0...@visulima/email@4.2.0) (2026-10-23)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* **email:** add idempotency key for resend ([#982](https://github.com/visulima/visulima/issues/982)) ([53cfa4d](https://github.com/visulima/visulima/commit/53cfa4da67ee38dfdcaf6cd92f518b09adfeaf19))
|
|
6
|
+
|
|
1
7
|
## @visulima/email [4.1.0](https://github.com/visulima/visulima/compare/@visulima/email@4.0.0...@visulima/email@4.1.0) (2026-10-23)
|
|
2
8
|
|
|
3
9
|
### Features
|
package/README.md
CHANGED
|
@@ -154,6 +154,23 @@ import { checkFeatureSupport } from "@visulima/email";
|
|
|
154
154
|
const { supported, violations } = checkFeatureSupport(message, provider.features);
|
|
155
155
|
```
|
|
156
156
|
|
|
157
|
+
### Idempotency Keys
|
|
158
|
+
|
|
159
|
+
Pass an `idempotencyKey` to tell the provider that a repeated send is the same message, so it is not delivered twice. The key is set on the message builder or on `EmailOptions`:
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
await mail.send(
|
|
163
|
+
new MailMessage()
|
|
164
|
+
.from("orders@example.com")
|
|
165
|
+
.to("user@example.com")
|
|
166
|
+
.subject("Order confirmed")
|
|
167
|
+
.text("Thanks for your order")
|
|
168
|
+
.idempotencyKey(`order-${orderId}-confirmation`),
|
|
169
|
+
);
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
The key is sent as an `Idempotency-Key` HTTP header and never appears in the message headers or the MIME body. Only providers that declare `features.idempotency` (currently Resend) use it; other providers ignore the key. Keys must be 1–256 visible ASCII characters. Resend keeps a key for 24 hours and requires a retry to carry the same payload; a retry with a different payload is rejected, and a retry after 24 hours can deliver the email again. The key is therefore protection against accidental double sends within that window, not a permanent guarantee. `sendBatch` does not apply a batch-level key to each recipient, because that would make every recipient look like a repeat of the first.
|
|
173
|
+
|
|
157
174
|
### Creating Draft Emails
|
|
158
175
|
|
|
159
176
|
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.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { KeyObject } from 'node:crypto';
|
|
2
|
-
import { D as DkimOptions, S as SmimeEncryptOptions, E as EmailEncrypter, a as SmimeSignOptions, b as EmailSigner } from "../packem_shared/types.d-
|
|
3
|
-
import { E as EmailOptions } from "../packem_shared/types.d-
|
|
2
|
+
import { D as DkimOptions, S as SmimeEncryptOptions, E as EmailEncrypter, a as SmimeSignOptions, b as EmailSigner } from "../packem_shared/types.d-A1Eea-p_.js";
|
|
3
|
+
import { E as EmailOptions } from "../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* The signature algorithm for the ARC headers. RSA per RFC 8617, Ed25519 per RFC 8463.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as EmailAddress } from "../packem_shared/types.d-
|
|
1
|
+
import { c as EmailAddress } from "../packem_shared/types.d-CyiC9uRC.js";
|
|
2
2
|
import { S as SuppressionReason, a as SuppressionEntry, b as SuppressionStore } from "../packem_shared/types.d-BzoHR9nB.js";
|
|
3
3
|
import 'node:buffer';
|
|
4
4
|
/**
|
package/dist/inbound/index.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export { type A as AttachmentDataOptions, type a as AttachmentOptions, type B as BatchBase, type b as BatchRenderer, D as DraftMailMessage, type F as FeatureCheckMode, M as Mail, type c as MailGlobalConfig, d as MailMessage, type e as MailOptions, type P as Personalization, type S as SendBatchOptions, type f as SendableMessage, g as createMail, h as detectMimeType, i as generateContentId, r as readFileAsBuffer } from "./packem_shared/mail.d-
|
|
2
|
-
export type { M as Middleware, S as SendFunction } from "./packem_shared/types.d-
|
|
3
|
-
export { type a as Provider, type P as ProviderFactory, d as defineProvider } from "./packem_shared/provider.d-
|
|
1
|
+
export { type A as AttachmentDataOptions, type a as AttachmentOptions, type B as BatchBase, type b as BatchRenderer, D as DraftMailMessage, type F as FeatureCheckMode, M as Mail, type c as MailGlobalConfig, d as MailMessage, type e as MailOptions, type P as Personalization, type S as SendBatchOptions, type f as SendableMessage, g as createMail, h as detectMimeType, i as generateContentId, r as readFileAsBuffer } from "./packem_shared/mail.d-2u-30lWz.js";
|
|
2
|
+
export type { M as Middleware, S as SendFunction } from "./packem_shared/types.d-Chhzb-48.js";
|
|
3
|
+
export { type a as Provider, type P as ProviderFactory, d as defineProvider } from "./packem_shared/provider.d-BLLbEuQ8.js";
|
|
4
4
|
export type { T as TemplateRenderer } from "./packem_shared/types.d-I-KeZ5w2.js";
|
|
5
|
-
export type { A as Attachment, B as BaseConfig, C as CalendarEventOptions, c as EmailAddress, e as EmailHeaders, E as EmailOptions, a as EmailResult, d as EmailTag, F as FeatureFlags, I as ImmutableHeaders, M as MaybePromise, P as Priority, b as Receipt, R as Result } from "./packem_shared/types.d-
|
|
5
|
+
export type { A as Attachment, B as BaseConfig, C as CalendarEventOptions, c as EmailAddress, e as EmailHeaders, E as EmailOptions, a as EmailResult, d as EmailTag, F as FeatureFlags, I as ImmutableHeaders, M as MaybePromise, P as Priority, b as Receipt, R as Result } from "./packem_shared/types.d-CyiC9uRC.js";
|
|
6
6
|
export { default as parseEml } from "./utils/parse-eml.js";
|
|
7
7
|
export { type OkResult, isErr, isOk, mapOk, tryAsync, unwrap, unwrapOr } from "./utils/result.js";
|
|
8
8
|
export { type FeatureSupportResult, type FeatureViolation, default as checkFeatureSupport } from "./utils/validation/check-feature-support.js";
|
|
9
9
|
import 'ical-generator';
|
|
10
10
|
import 'node:buffer';
|
|
11
|
-
import "./packem_shared/types.d-
|
|
11
|
+
import "./packem_shared/types.d-A1Eea-p_.js";
|
|
12
12
|
interface ErrorProperties {
|
|
13
13
|
cause?: unknown;
|
|
14
14
|
hint?: ErrorHint;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{detectMimeType as a,generateContentId as t,readFileAsBuffer as o}from"./packem_shared/detectMimeType-BRz3Qjyz.js";import{default as p}from"./packem_shared/DraftMailMessage-
|
|
1
|
+
import{detectMimeType as a,generateContentId as t,readFileAsBuffer as o}from"./packem_shared/detectMimeType-BRz3Qjyz.js";import{default as p}from"./packem_shared/DraftMailMessage-zkKTOxQ8.js";import{default as m}from"./packem_shared/EmailError-SXEFQEyA.js";import{default as l}from"./packem_shared/RequiredOptionError-C2wWqmiE.js";import{Mail as u,createMail as x}from"./packem_shared/Mail-DtpXUSIl.js";import{default as M}from"./packem_shared/MailMessage-Aw0vVAh-.js";import{defineProvider as E}from"./packem_shared/defineProvider-C9q-7iwt.js";import{default as g}from"./utils/parse-eml.js";import{isErr as y,isOk as w,mapOk as A,tryAsync as F,unwrap as h,unwrapOr as q}from"./utils/result.js";import{default as B}from"./utils/validation/check-feature-support.js";export{p as DraftMailMessage,m as EmailError,u as Mail,M as MailMessage,l as RequiredOptionError,B as checkFeatureSupport,x as createMail,E as defineProvider,a as detectMimeType,t as generateContentId,y as isErr,w as isOk,A as mapOk,g as parseEml,o as readFileAsBuffer,F as tryAsync,h as unwrap,q as unwrapOr};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { M as Middleware } from "../packem_shared/types.d-
|
|
2
|
-
export { type S as SendFunction, c as composeMiddleware } from "../packem_shared/types.d-
|
|
3
|
-
import { E as EmailOptions, M as MaybePromise, a as EmailResult, R as Result, c as EmailAddress } from "../packem_shared/types.d-
|
|
1
|
+
import { M as Middleware } from "../packem_shared/types.d-Chhzb-48.js";
|
|
2
|
+
export { type S as SendFunction, c as composeMiddleware } from "../packem_shared/types.d-Chhzb-48.js";
|
|
3
|
+
import { E as EmailOptions, M as MaybePromise, a as EmailResult, R as Result, c as EmailAddress } from "../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import { d as EventBus } from "../packem_shared/event-bus.d-BNQA-FZE.js";
|
|
5
5
|
import { b as SuppressionStore } from "../packem_shared/types.d-BzoHR9nB.js";
|
|
6
6
|
import { T as Tracer } from "../packem_shared/tracer.d-sb5yrt_n.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"./MailMessage-
|
|
1
|
+
import e from"./MailMessage-Aw0vVAh-.js";class t extends e{constructor(){super(),this.header("X-Unsent","1")}}export{t as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import f from"./DraftMailMessage-zkKTOxQ8.js";import v from"./EmailError-SXEFQEyA.js";import u from"./MailMessage-Aw0vVAh-.js";import{composeMiddleware as w}from"./composeMiddleware-B3RCDFsy.js";import{b as C}from"./build-mime-message-D45WdgfP.js";import{c as M}from"./create-logger-CazqtXcL.js";import{h as d}from"./headers-to-record-ZOZ7Dubo.js";import T from"../utils/validation/check-feature-support.js";const S=(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})},E=async(a,e,r)=>{const t={...a,to:e.to};return delete t.idempotencyKey,e.cc&&(t.cc=e.cc),e.bcc&&(t.bcc=e.bcc),e.replyTo&&(t.replyTo=e.replyTo),e.headers&&(t.headers={...d(a.headers??{}),...d(e.headers)}),t.subject=e.subject??a.subject,r&&e.data&&(t.subject=await r(t.subject,e.data),a.html!==void 0&&(t.html=await r(a.html,e.data)),a.text!==void 0&&(t.text=await r(a.text,e.data))),t};class h{static extractErrorMessages(e){return e instanceof Error?[e.message]:[String(e??"Unknown error")]}provider;logger;loggerInstance;globalConfig;featureCheck;middlewares=[];composedSend;mountedProviders=new Map;constructor(e,r){this.provider=e,this.featureCheck=r?.featureCheck??"error"}setLogger(e){return this.loggerInstance=e,this.logger=M("Mail",e),this}use(e){return this.middlewares.push(e),this.composedSend=void 0,this}mount(e,r){return this.mountedProviders.set(e,r),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 u||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 C(r,{includeBcc:!0});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 u)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,this.resolveProvider(r));if(t)return{error:t,success:!1};const s=await this.dispatch(r);return S(this.logger,s,this.provider.name??"unknown"),s}sendMany(e,r){const t=Math.max(1,Math.floor(r?.concurrency??1));return t===1?this.sendManySerial(e,r?.signal):this.sendManyConcurrent(e,t,r?.signal)}sendBatch(e,r,t){const s=async function*(){const o=e instanceof u?await e.build():e;for(const i of r)yield await E(o,i,t?.render)};return this.sendMany(s(),{concurrency:t?.concurrency,signal:t?.signal})}async sendOneToReceipt(e){const r=this.provider.name;try{const t=await this.send(e);return t.success&&t.data?{messageId:t.data.messageId,provider:t.data.provider??r,response:t.data.response,successful:!0,timestamp:t.data.timestamp}:{errorMessages:h.extractErrorMessages(t.error),provider:r,successful:!1}}catch(t){return{errorMessages:h.extractErrorMessages(t),provider:r,successful:!1}}}async*sendManySerial(e,r){const t=this.provider.name;let s=0,o=0,i=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?.aborted){this.logger&&this.logger.warn("Batch send operation was aborted",{failed:i,processed:s,successful:o}),yield{errorMessages:["Send operation was aborted"],provider:t,successful:!1};return}s+=1;const n=await this.sendOneToReceipt(l);n.successful?o+=1:i+=1,yield n}this.logger&&this.logger.debug("Batch email send completed",{failureCount:i,processedCount:s,provider:t,successCount:o})}async*sendManyConcurrent(e,r,t){const s=this.provider.name;this.logger&&this.logger.debug("Starting concurrent batch email send",{concurrency:r,provider:s});const o=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator](),i=new Map;let l=0,n=!1,p=!1;const m=async()=>{for(;!n&&!p&&i.size<r;){const g=await o.next();if(g.done){n=!0;break}const c=g.value;if(c instanceof f)throw new TypeError("Cannot send draft messages. Convert to MailMessage first or remove X-Unsent header.");const b=l;l+=1,i.set(b,this.sendOneToReceipt(c).then(y=>({id:b,receipt:y})))}};for(await m();i.size>0;){if(t?.aborted){p=!0,yield{errorMessages:["Send operation was aborted"],provider:s,successful:!1};return}const{id:g,receipt:c}=await Promise.race(i.values());i.delete(g),yield c,await m()}this.logger&&this.logger.debug("Concurrent batch email send completed",{processedCount:l,provider:s})}async dispatch(e){return this.middlewares.length===0?await this.resolveProvider(e).sendEmail(e):(this.composedSend??=w(this.middlewares,r=>Promise.resolve(this.resolveProvider(r).sendEmail(r))),await this.composedSend(e))}resolveProvider(e){return e.stream!==void 0?this.mountedProviders.get(e.stream)??this.provider:this.provider}assertFeatureSupport(e,r){if(this.featureCheck==="off")return;const{supported:t,violations:s}=T(e,r.features);if(t)return;const o=r.name??"unknown",i=s.map(n=>n.field),l=s.map(n=>n.message);if(this.featureCheck==="warn"){this.logger&&this.logger.warn("Message uses capabilities the provider does not support",{fields:i,provider:o});return}return this.logger&&this.logger.error("Message rejected by capability guard",{fields:i,provider:o}),new v(o,`Provider does not support the following message fields: ${i.join(", ")}`,{code:"UNSUPPORTED_FEATURES",hint:l})}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,i])=>{e.header(o,i)})}}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 O=(a,e)=>new h(a,e);export{h as Mail,O as createMail};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as y}from"node:module";import{readFileAsBuffer as c,detectMimeType as d,generateContentId as u}from"./detectMimeType-BRz3Qjyz.js";import{c as T}from"./create-logger-CazqtXcL.js";import{h as l}from"./headers-to-record-ZOZ7Dubo.js";let p;const A=n=>(p??=y(import.meta.url))(n),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,f=n=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[t,e]=o.versions.node.split(".").map(Number);if(t>22||t===22&&e>=3||t===20&&e>=16)return o.getBuiltinModule(n)}return A(n)},{basename:g}=f("node:path"),{fileURLToPath:b}=f("node:url"),m=async()=>(await import("../template-engines/html-to-text.js")).default,x=async()=>(await import("ical-generator")).default,a=n=>Array.isArray(n)?n.map(t=>typeof t=="string"?{email:t}:t):typeof n=="string"?[{email:n}]:[n];class D{fromAddress;toAddresses=[];ccAddresses=[];bccAddresses=[];subjectText="";textContent;textCharset="utf8";autoTextEnabled=!0;htmlContent;htmlCharset="utf8";dateValue;returnPathAddress;senderAddress;headers={};attachments=[];replyToAddress;priorityValue;tagsValue=[];idempotencyKeyValue;signer;encrypter;logger;icalEventData;icalEventBuilder;from(t){return this.fromAddress=typeof t=="string"?{email:t}:t,this}to(t){return this.toAddresses.length=0,this.toAddresses.push(...a(t)),this}cc(t){return this.ccAddresses.length=0,this.ccAddresses.push(...a(t)),this}bcc(t){return this.bccAddresses.length=0,this.bccAddresses.push(...a(t)),this}subject(t){return this.subjectText=t,this}text(t,e="utf8"){return this.textContent=t,this.textCharset=e,this}html(t,e="utf8"){return this.htmlContent=t,this.htmlCharset=e,this}header(t,e){return this.headers[t]=e,this}setHeaders(t){const e=l(t);return Object.assign(this.headers,e),this}async attachFromPath(t,e){try{const s=await c(t),i=e?.filename??(g(t)||"attachment"),r=e?.contentType??d(i);this.attachments.push({cid:e?.cid,content:s,contentDisposition:e?.contentDisposition??"attachment",contentType:r,encoding:e?.encoding,filename:i,headers:e?.headers}),this.logger&&this.logger.debug(`Attachment added from path: ${t}`,{contentType:r,filename:i})}catch(s){throw this.logger&&this.logger.error(`Failed to attach file from path: ${t}`,s),s}return this}attachData(t,e){const s=e.contentType??d(e.filename);return this.attachments.push({cid:e.cid,content:t,contentDisposition:e.contentDisposition??"attachment",contentType:s,encoding:e.encoding,filename:e.filename,headers:e.headers}),this.logger&&this.logger.debug("Attachment added from data",{contentType:s,filename:e.filename}),this}async embedFromPath(t,e){try{const s=await c(t),i=e?.filename??(g(t)||"inline"),r=e?.contentType??d(i),h=u(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: ${t}`,{cid:h,contentType:r,filename:i}),h}catch(s){throw this.logger&&this.logger.error(`Failed to embed file from path: ${t}`,s),s}}embedData(t,e,s){const i=s?.contentType??d(e),r=u(e);return this.attachments.push({cid:r,content:t,contentDisposition:"inline",contentType:i,filename:e}),this.logger&&this.logger.debug("Inline attachment embedded from data",{cid:r,contentType:i,filename:e}),r}replyTo(t){return this.replyToAddress=typeof t=="string"?{email:t}:t,this}date(t){return this.dateValue=typeof t=="string"?new Date(t):t,this.logger&&this.logger.debug("Date header set",{date:this.dateValue.toISOString()}),this}returnPath(t){return this.returnPathAddress=typeof t=="string"?{email:t}:t,this.logger&&this.logger.debug("Return-path address set",{returnPath:this.returnPathAddress.email}),this}sender(t){return this.senderAddress=typeof t=="string"?{email:t}:t,this.logger&&this.logger.debug("Sender address set",{sender:this.senderAddress.email}),this}addTo(t){return this.toAddresses.push(...a(t)),this}addCc(t){return this.ccAddresses.push(...a(t)),this}addBcc(t){return this.bccAddresses.push(...a(t)),this}addReplyTo(t){const e=Array.isArray(t)?t:[t];if(e.length>0){const s=e[0];this.replyToAddress=typeof s=="string"?{email:s}:s}return this}addFrom(t){const e=Array.isArray(t)?t:[t];if(e.length>0){const s=e[0];this.fromAddress=typeof s=="string"?{email:s}:s}return this}priority(t){return this.priorityValue=t,this}tags(t){return this.tagsValue=Array.isArray(t)?t:[t],this}idempotencyKey(t){return this.idempotencyKeyValue=t,this}sign(t){return this.signer=t,this.logger&&this.logger.debug("Email signer configured"),this}encrypt(t){return this.encrypter=t,this.logger&&this.logger.debug("Email encrypter configured"),this}setLogger(t){return this.logger=T("MailMessage",t),this}icalEvent(t,e){return typeof t=="function"?(this.icalEventBuilder={build:t,options:e},this.icalEventData=void 0):(this.icalEventBuilder=void 0,this.icalEventData={content:t,...e}),this.logger&&this.logger.debug("Calendar event attached",{method:e?.method}),this}icalEventFromFile(t,e){const s=typeof t=="string"?t:b(t);return this.icalEventData={path:s,...e},this.logger&&this.logger.debug(`Calendar event attached from file: ${s}`,{method:e?.method}),this}icalEventFromUrl(t,e){return this.icalEventData={href:t,...e},this.logger&&this.logger.debug(`Calendar event attached from URL: ${t}`,{method:e?.method}),this}async view(t,e,s,i){try{const r=i?.autoText!==!1;this.autoTextEnabled=r,this.logger&&this.logger.debug("Rendering template",{autoText:r});const h=await t(e,s,i);this.html(h),r&&h&&await 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(t,e,s,i){try{this.logger&&this.logger.debug("Rendering text template");const r=await t(e,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{const e=await m();this.textContent=e(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 t={from:this.fromAddress,html:this.htmlContent,subject:this.subjectText,text:this.textContent,to:this.toAddresses.length===1?this.toAddresses[0]:this.toAddresses};if(this.ccAddresses.length>0&&(t.cc=this.ccAddresses.length===1?this.ccAddresses[0]:this.ccAddresses),this.bccAddresses.length>0&&(t.bcc=this.bccAddresses.length===1?this.bccAddresses[0]:this.bccAddresses),Object.keys(this.headers).length>0&&(t.headers=this.headers),this.attachments.length>0&&(t.attachments=this.attachments,this.logger&&this.logger.debug(`Email includes ${this.attachments.length} attachment(s)`)),this.replyToAddress&&(t.replyTo=this.replyToAddress),this.priorityValue&&(t.priority=this.priorityValue),this.tagsValue.length>0&&(t.tags=this.tagsValue),this.idempotencyKeyValue!==void 0&&(t.idempotencyKey=this.idempotencyKeyValue),this.icalEventBuilder){const s=(await x())();this.icalEventBuilder.build(s),this.icalEventData={content:s.toString(),...this.icalEventBuilder.options}}return this.icalEventData&&(t.icalEvent=this.icalEventData,this.logger&&this.logger.debug("Email includes calendar event")),this.dateValue&&(t.headers={...l(t.headers??{}),Date:this.dateValue.toUTCString()}),this.returnPathAddress&&(t.headers={...l(t.headers??{}),"Return-Path":this.returnPathAddress.email}),this.senderAddress&&(t.headers={...l(t.headers??{}),Sender:this.senderAddress.email}),this.signer&&(this.logger&&this.logger.debug("Signing email message"),t=await this.signer.sign(t),this.logger&&this.logger.debug("Email message signed successfully")),this.encrypter&&(this.logger&&this.logger.debug("Encrypting email message"),t=await this.encrypter.encrypt(t),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}),t}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]}async tryAutoGenerateText(t){try{const s=(await m())(t);s&&!this.textContent&&this.text(s),this.logger&&this.logger.debug("Auto-generated text content from HTML template")}catch(e){this.logger&&this.logger.warn("Failed to auto-generate text from HTML template",e)}}throwAndLogError(t,e){const s=new Error(t);throw this.logger&&this.logger.error(e??t),s}}export{D as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createMail as d}from"./Mail-
|
|
1
|
+
import{createMail as d}from"./Mail-DtpXUSIl.js";import w from"./mockProvider-DVtl5Jjy.js";const l=(t,o,e,n)=>{const r=Date.now()+e;return new Promise((i,s)=>{const a=()=>{const c=t.find(m=>o(m));if(c){i(c);return}if(Date.now()>=r){s(new Error("waitFor timed out before a matching message was captured"));return}setTimeout(a,n)};a()})},h=()=>{const t=w(),o=d(t),e=t.getInstance?.();if(!e)throw new Error("mockProvider() did not expose getInstance(); cannot create a test harness");return{mail:o,reset:()=>{e.length=0},sent:()=>e,waitFor:(n,r={})=>l(e,n,r.timeout??1e3,r.interval??10)}};export{h as createTestEmail};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ICalCalendar } from 'ical-generator';
|
|
2
2
|
import { Buffer as Buffer$1 } from 'node:buffer';
|
|
3
3
|
import { T as TemplateRenderer } from "./types.d-I-KeZ5w2.js";
|
|
4
|
-
import { c as EmailAddress, e as EmailHeaders, P as Priority, C as CalendarEventOptions, E as EmailOptions, A as Attachment, M as MaybePromise, a as EmailResult, R as Result, b as Receipt } from "./types.d-
|
|
5
|
-
import { b as EmailSigner, E as EmailEncrypter } from "./types.d-
|
|
6
|
-
import { M as Middleware } from "./types.d-
|
|
7
|
-
import { a as Provider } from "./provider.d-
|
|
4
|
+
import { c as EmailAddress, e as EmailHeaders, P as Priority, C as CalendarEventOptions, E as EmailOptions, A as Attachment, M as MaybePromise, a as EmailResult, R as Result, b as Receipt } from "./types.d-CyiC9uRC.js";
|
|
5
|
+
import { b as EmailSigner, E as EmailEncrypter } from "./types.d-A1Eea-p_.js";
|
|
6
|
+
import { M as Middleware } from "./types.d-Chhzb-48.js";
|
|
7
|
+
import { a as Provider } from "./provider.d-BLLbEuQ8.js";
|
|
8
8
|
/**
|
|
9
9
|
* Detects MIME type from filename using mime package.
|
|
10
10
|
* Falls back to application/octet-stream if not found.
|
|
@@ -91,6 +91,7 @@ declare class MailMessage {
|
|
|
91
91
|
private replyToAddress?;
|
|
92
92
|
private priorityValue?;
|
|
93
93
|
private tagsValue;
|
|
94
|
+
private idempotencyKeyValue?;
|
|
94
95
|
private signer?;
|
|
95
96
|
private encrypter?;
|
|
96
97
|
private logger?;
|
|
@@ -276,6 +277,13 @@ declare class MailMessage {
|
|
|
276
277
|
* @returns This instance for method chaining.
|
|
277
278
|
*/
|
|
278
279
|
tags(tags: string | string[]): this;
|
|
280
|
+
/**
|
|
281
|
+
* Sets an idempotency key so the provider can drop a repeated send of the same message.
|
|
282
|
+
* Honoured only by providers that declare `features.idempotency`.
|
|
283
|
+
* @param key The caller-chosen key, unique per logical message.
|
|
284
|
+
* @returns This instance for method chaining.
|
|
285
|
+
*/
|
|
286
|
+
idempotencyKey(key: string): this;
|
|
279
287
|
/**
|
|
280
288
|
* Signs the email message with an S/MIME signer.
|
|
281
289
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as EmailOptions, F as FeatureFlags, R as Result, M as MaybePromise, a as EmailResult } from "./types.d-
|
|
1
|
+
import { E as EmailOptions, F as FeatureFlags, R as Result, M as MaybePromise, a as EmailResult } from "./types.d-CyiC9uRC.js";
|
|
2
2
|
/**
|
|
3
3
|
* Standard provider interface for email services.
|
|
4
4
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import d from"./EmailError-SXEFQEyA.js";import I from"./RequiredOptionError-C2wWqmiE.js";import{g as A}from"./generate-message-id-C5AM6DFE.js";import{h as w}from"./headers-to-record-ZOZ7Dubo.js";import{m as y}from"./make-request-mszP240P.js";import{r as g}from"./retry-ByPJFAtq.js";import{v as T}from"./validate-email-options-DxdAVLlu.js";import{defineProvider as P}from"./defineProvider-C9q-7iwt.js";import{c as C,P as K,h as b}from"./provider-base-G22b4a87.js";import{e as $,g as v,d as E}from"./address-formatter-w36S9ZYj.js";import{p as R}from"./attachment-processor-AB1m-n9T.js";const s="resend",j="https://api.resend.com",S=3e4,_=3,k=/^[\u0021-\u007E]{1,256}$/,D=o=>{const r=[],c=/^[\w-]+$/;return c.test(o.name)||r.push(`Tag name '${o.name}' must only contain ASCII letters, numbers, underscores, or dashes`),o.name.length>256&&r.push(`Tag name '${o.name}' exceeds maximum length of 256 characters`),c.test(o.value)||r.push(`Tag value '${o.value}' for tag '${o.name}' must only contain ASCII letters, numbers, underscores, or dashes`),r},Y=P((o={})=>{if(!o.apiKey)throw new I(s,"apiKey");const r={apiKey:o.apiKey,debug:o.debug??!1,endpoint:o.endpoint??j,logger:o.logger,retries:o.retries??_,timeout:o.timeout??S},c=new K,n=C(s,o.logger);return{endpoint:r.endpoint,features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,idempotency:!0,replyTo:!0,scheduling:!0,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new d(s,"Email ID is required to retrieve email details"),success:!1};await c.ensureInitialized(()=>this.initialize(),s);const t={Authorization:`Bearer ${r.apiKey}`,"Content-Type":"application/json"};n.debug("Retrieving email details",{id:e});const a=await g(async()=>y(`${r.endpoint}/emails/${e}`,{headers:t,method:"GET",timeout:r.timeout}),r.retries);return a.success?(n.debug("Email details retrieved successfully"),{data:a.data?.body,success:!0}):(n.debug("API request failed when retrieving email",a.error),{error:new d(s,`Failed to retrieve email: ${a.error instanceof Error?a.error.message:"Unknown error"}`,{cause:a.error}),success:!1})}catch(t){return{error:b(s,"retrieve email",t,n),success:!1}}},async initialize(){await c.ensureInitialized(async()=>{if(!await this.isAvailable())throw new d(s,"Resend API not available or invalid API key");n.debug("Provider initialized successfully")},s)},async isAvailable(){try{if(r.apiKey&&r.apiKey.startsWith("re_"))return n.debug("API key format is valid, assuming Resend is available"),!0;const e={Authorization:`Bearer ${r.apiKey}`,"Content-Type":"application/json"};n.debug("Checking Resend API availability");const t=await y(`${r.endpoint}/domains`,{headers:e,method:"GET",timeout:r.timeout});return t.data&&typeof t.data=="object"&&"body"in t.data&&t.data.body&&typeof t.data.body=="object"&&"name"in t.data.body&&t.data.body.name==="restricted_api_key"?(n.debug("API key is valid but restricted to only sending emails"),!0):(n.debug("Resend API availability check response:",{error:t.error instanceof Error?t.error.message:void 0,statusCode:t.data?.statusCode,success:t.success}),!!(t.success&&t.data&&typeof t.data=="object"&&"statusCode"in t.data&&typeof t.data.statusCode=="number"&&t.data.statusCode>=200&&t.data.statusCode<300))}catch(e){return n.debug("Error checking availability:",e),!1}},name:s,options:r,async sendEmail(e){try{const t=T(e);if(t.length>0)return{error:new d(s,`Invalid email options: ${t.join(", ")}`),success:!1};if(e.idempotencyKey!==void 0&&(typeof e.idempotencyKey!="string"||!k.test(e.idempotencyKey)))return{error:new d(s,"Invalid idempotency key: must be 1-256 visible ASCII characters"),success:!1};await c.ensureInitialized(()=>this.initialize(),s);const a={from:v(e.from),headers:e.headers?w(e.headers):{},html:e.html,subject:e.subject,text:e.text,to:$(e.to)};if(e.cc&&(a.cc=E(e.cc)),e.bcc&&(a.bcc=E(e.bcc)),e.replyTo&&(a.reply_to=v(e.replyTo)),e.templateId&&(a.template=e.templateId,e.templateData&&(a.data=e.templateData)),e.scheduledAt&&(a.scheduled_at=typeof e.scheduledAt=="string"?e.scheduledAt:e.scheduledAt.toISOString()),e.tags&&e.tags.length>0){const i=[];if(e.tags.forEach(l=>{const p=D(l);p.length>0&&i.push(...p)}),i.length>0)return{error:new d(s,`Invalid email tags: ${i.join(", ")}`),success:!1};a.tags=e.tags.map(l=>({name:l.name,value:l.value}))}e.attachments&&e.attachments.length>0&&(a.attachments=await Promise.all(e.attachments.map(async i=>({content:await R(i,s),content_type:i.contentType,filename:i.filename,...i.path&&{path:i.path}})))),n.debug("Sending email via Resend API",{subject:a.subject,to:a.to});const f={Authorization:`Bearer ${r.apiKey}`,"Content-Type":"application/json"};e.idempotencyKey!==void 0&&(f["Idempotency-Key"]=e.idempotencyKey);const u=await g(async()=>y(`${r.endpoint}/emails`,{headers:f,method:"POST",timeout:r.timeout},JSON.stringify(a)),r.retries);if(!u.success)return n.debug("API request failed when sending email",u.error),{error:u.error??new d(s,"Failed to send email"),success:!1};const m=u.data,h=m?.body&&typeof m.body=="object"&&m.body.id?m.body.id:A();return n.debug("Email sent successfully",{messageId:h}),{data:{messageId:h,provider:s,response:u.data,sent:!0,timestamp:new Date},success:!0}}catch(t){return{error:b(s,"send email",t,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{Y as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as EmailOptions, a as EmailResult, R as Result } from "./types.d-
|
|
1
|
+
import { E as EmailOptions, a as EmailResult, R as Result } from "./types.d-CyiC9uRC.js";
|
|
2
2
|
/**
|
|
3
3
|
* The terminal send function a middleware wraps — ultimately the provider's `sendEmail`.
|
|
4
4
|
*/
|
|
@@ -11,6 +11,10 @@ interface FeatureFlags {
|
|
|
11
11
|
batchSending?: boolean;
|
|
12
12
|
customHeaders?: boolean;
|
|
13
13
|
html?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* The provider sends `idempotencyKey` upstream, so a repeated send with the same key is not duplicated.
|
|
16
|
+
*/
|
|
17
|
+
idempotency?: boolean;
|
|
14
18
|
replyTo?: boolean;
|
|
15
19
|
scheduling?: boolean;
|
|
16
20
|
tagging?: boolean;
|
|
@@ -137,6 +141,12 @@ interface EmailOptions {
|
|
|
137
141
|
href?: string;
|
|
138
142
|
path?: string;
|
|
139
143
|
};
|
|
144
|
+
/**
|
|
145
|
+
* Caller-chosen key that lets the provider recognise a repeated send of the same message, so a
|
|
146
|
+
* retry after an ambiguous failure does not deliver twice. Only providers that declare
|
|
147
|
+
* `features.idempotency` act on it; it is never written into the message headers or the MIME body.
|
|
148
|
+
*/
|
|
149
|
+
idempotencyKey?: string;
|
|
140
150
|
priority?: Priority;
|
|
141
151
|
replyTo?: EmailAddress;
|
|
142
152
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* AhaSend configuration
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* AutoSend configuration.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* AWS SES configuration
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* Azure Communication Services configuration
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions, c as EmailAddress } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions, c as EmailAddress } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* Brevo configuration
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { D as DkimOptions } from "../../packem_shared/types.d-
|
|
4
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { D as DkimOptions } from "../../packem_shared/types.d-A1Eea-p_.js";
|
|
4
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
5
5
|
import 'node:buffer';
|
|
6
6
|
/**
|
|
7
7
|
* Cloudflare Email Workers configuration.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* Failover configuration
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* File provider configuration.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* HTTP email configuration
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* Infobip configuration
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* Loops configuration.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* MailChannels configuration.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* MailCrab configuration (for local development/testing)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* MailerSend configuration
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* Mailgun configuration
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* Mailjet configuration
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* Mailomat configuration
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* MailPace configuration
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* Mailtrap configuration
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* Mandrill configuration
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { M as MockConfig, a as MockEmailEntry } from "../../packem_shared/types.d-
|
|
4
|
-
export type { b as MockEmailOptions, R as RandomDelayRange } from "../../packem_shared/types.d-
|
|
5
|
-
import "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { M as MockConfig, a as MockEmailEntry } from "../../packem_shared/types.d-V_yuAOrx.js";
|
|
4
|
+
export type { b as MockEmailOptions, R as RandomDelayRange } from "../../packem_shared/types.d-V_yuAOrx.js";
|
|
5
|
+
import "../../packem_shared/types.d-CyiC9uRC.js";
|
|
6
6
|
import 'node:buffer';
|
|
7
7
|
/**
|
|
8
8
|
* Mock Provider for testing emails without actually sending them
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* Netcore (Pepipost) configuration.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { c as EmailAddress, B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { c as EmailAddress, B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* Nodemailer configuration
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as Provider, P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { a as Provider, P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
3
3
|
import { T as Tracer } from "../../packem_shared/tracer.d-sb5yrt_n.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { M as MaybePromise, B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { M as MaybePromise, B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* Which OAuth2 flow a config resolves to.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* Plunk configuration
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* Postal configuration
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* Postmark configuration
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions, d as EmailTag } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions, d as EmailTag } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* Resend configuration
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as d}from"../../packem_shared/resendProvider-
|
|
1
|
+
import{default as d}from"../../packem_shared/resendProvider-BaIZCvph.js";export{d as resendProvider};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* Round Robin configuration
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* Scaleway configuration
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* SendGrid configuration
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { D as DkimOptions } from "../../packem_shared/types.d-
|
|
4
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { D as DkimOptions } from "../../packem_shared/types.d-A1Eea-p_.js";
|
|
4
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
5
5
|
import 'node:buffer';
|
|
6
6
|
/**
|
|
7
7
|
* SMTP configuration
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* SparkPost configuration.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* Sweego configuration
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProviderFactory } from "../../packem_shared/provider.d-
|
|
2
|
-
export type { a as Provider } from "../../packem_shared/provider.d-
|
|
3
|
-
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as ProviderFactory } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
2
|
+
export type { a as Provider } from "../../packem_shared/provider.d-BLLbEuQ8.js";
|
|
3
|
+
import { B as BaseConfig, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
6
6
|
* Zeptomail configuration
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as EmailOptions, a as EmailResult, R as Result } from "../packem_shared/types.d-
|
|
2
|
-
import { E as EnqueueOptions } from "../packem_shared/types.d-
|
|
1
|
+
import { E as EmailOptions, a as EmailResult, R as Result } from "../packem_shared/types.d-CyiC9uRC.js";
|
|
2
|
+
import { E as EnqueueOptions } from "../packem_shared/types.d-B5iH_mgb.js";
|
|
3
3
|
import 'node:buffer';
|
|
4
4
|
/**
|
|
5
5
|
* The subset of a [BullMQ](https://docs.bullmq.io/) `Queue` this adapter uses.
|
package/dist/queue/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as EmailOptions, a as EmailResult, R as Result } from "../packem_shared/types.d-
|
|
2
|
-
import { E as EnqueueOptions, Q as QueueJob, a as EmailQueue } from "../packem_shared/types.d-
|
|
1
|
+
import { E as EmailOptions, a as EmailResult, R as Result } from "../packem_shared/types.d-CyiC9uRC.js";
|
|
2
|
+
import { E as EnqueueOptions, Q as QueueJob, a as EmailQueue } from "../packem_shared/types.d-B5iH_mgb.js";
|
|
3
3
|
export { UnstorageQueue, type UnstorageQueueOptions, createUnstorageQueue } from "./unstorage-queue.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as EmailQueue } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { a as EmailQueue } from "../packem_shared/types.d-B5iH_mgb.js";
|
|
2
|
+
import "../packem_shared/types.d-CyiC9uRC.js";
|
|
3
3
|
import 'node:buffer';
|
|
4
4
|
interface PgBossJob {
|
|
5
5
|
data: unknown;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as EmailQueue } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { a as EmailQueue } from "../packem_shared/types.d-B5iH_mgb.js";
|
|
2
|
+
import "../packem_shared/types.d-CyiC9uRC.js";
|
|
3
3
|
import 'node:buffer';
|
|
4
4
|
/**
|
|
5
5
|
* The subset of the `@aws-sdk/client-sqs` `SQS` client this adapter uses. The `SQS` class (not the
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as EmailOptions } from "../packem_shared/types.d-
|
|
2
|
-
import { E as EnqueueOptions, Q as QueueJob, a as EmailQueue } from "../packem_shared/types.d-
|
|
1
|
+
import { E as EmailOptions } from "../packem_shared/types.d-CyiC9uRC.js";
|
|
2
|
+
import { E as EnqueueOptions, Q as QueueJob, a as EmailQueue } from "../packem_shared/types.d-B5iH_mgb.js";
|
|
3
3
|
import 'node:buffer';
|
|
4
4
|
type StorageValue = null | string | number | boolean | object;
|
|
5
5
|
type WatchEvent = "update" | "remove";
|
package/dist/test/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { E as EmailOptions } from "../packem_shared/types.d-
|
|
2
|
-
import { a as MockEmailEntry } from "../packem_shared/types.d-
|
|
3
|
-
import { M as Mail } from "../packem_shared/mail.d-
|
|
1
|
+
import { E as EmailOptions } from "../packem_shared/types.d-CyiC9uRC.js";
|
|
2
|
+
import { a as MockEmailEntry } from "../packem_shared/types.d-V_yuAOrx.js";
|
|
3
|
+
import { M as Mail } from "../packem_shared/mail.d-2u-30lWz.js";
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
import 'ical-generator';
|
|
6
6
|
import "../packem_shared/types.d-I-KeZ5w2.js";
|
|
7
|
-
import "../packem_shared/types.d-
|
|
8
|
-
import "../packem_shared/types.d-
|
|
9
|
-
import "../packem_shared/provider.d-
|
|
7
|
+
import "../packem_shared/types.d-A1Eea-p_.js";
|
|
8
|
+
import "../packem_shared/types.d-Chhzb-48.js";
|
|
9
|
+
import "../packem_shared/provider.d-BLLbEuQ8.js";
|
|
10
10
|
/**
|
|
11
11
|
* Returns the http(s) URLs in a message without duplicates, in this order: `href` targets of
|
|
12
12
|
* anchor and area elements in the HTML, bare URLs in the visible HTML text, then bare URLs in the
|
package/dist/test/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as a}from"../packem_shared/extractLinks-BwE1SjNF.js";import{emailMatchers as r,registerEmailMatchers as i,toHaveSentMatching as m,toHaveSentTo as n,toHaveSentWithAttachment as c,toHaveSentWithSubject as h}from"../packem_shared/emailMatchers-DpwItmkN.js";import{toEmailSnapshot as S}from"../packem_shared/toEmailSnapshot-BOhTn44E.js";import{createTestEmail as l}from"../packem_shared/createTestEmail-
|
|
1
|
+
import{default as a}from"../packem_shared/extractLinks-BwE1SjNF.js";import{emailMatchers as r,registerEmailMatchers as i,toHaveSentMatching as m,toHaveSentTo as n,toHaveSentWithAttachment as c,toHaveSentWithSubject as h}from"../packem_shared/emailMatchers-DpwItmkN.js";import{toEmailSnapshot as S}from"../packem_shared/toEmailSnapshot-BOhTn44E.js";import{createTestEmail as l}from"../packem_shared/createTestEmail-B2Fz-Ifb.js";export{l as createTestEmail,r as emailMatchers,a as extractLinks,i as registerEmailMatchers,S as toEmailSnapshot,m as toHaveSentMatching,n as toHaveSentTo,c as toHaveSentWithAttachment,h as toHaveSentWithSubject};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as EmailAddress } from "../packem_shared/types.d-
|
|
1
|
+
import { c as EmailAddress } from "../packem_shared/types.d-CyiC9uRC.js";
|
|
2
2
|
import 'node:buffer';
|
|
3
3
|
/**
|
|
4
4
|
* Formats an email address as "Name <email@example.com>" or just "email@example.com" if no name is provided.
|
package/dist/utils/result.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FeatureFlags, E as EmailOptions } from "../../packem_shared/types.d-
|
|
1
|
+
import { F as FeatureFlags, E as EmailOptions } from "../../packem_shared/types.d-CyiC9uRC.js";
|
|
2
2
|
import 'node:buffer';
|
|
3
3
|
/**
|
|
4
4
|
* A single capability that a message uses but the target provider cannot represent.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as
|
|
1
|
+
import{h as l}from"../../packem_shared/headers-to-record-ZOZ7Dubo.js";const s=e=>Array.isArray(e)&&e.length>0,o=(e,d)=>d.find(t=>e[t]!==void 0),c=[{detect:e=>s(e.attachments)?"attachments":void 0,feature:"attachments",label:"attachments"},{detect:e=>typeof e.html=="string"&&e.html.length>0?"html":void 0,feature:"html",label:"HTML content"},{detect:e=>e.replyTo?"replyTo":void 0,feature:"replyTo",label:"a reply-to address"},{detect:e=>e.headers!==void 0&&Object.keys(l(e.headers)).length>0?"headers":void 0,feature:"customHeaders",label:"custom headers"},{detect:e=>s(e.tags)?"tags":void 0,feature:"tagging",label:"tags"},{detect:e=>e.idempotencyKey===void 0?void 0:"idempotencyKey",feature:"idempotency",label:"an idempotency key"},{detect:e=>o(e,["scheduledAt","sendAt"]),feature:"scheduling",label:"scheduled delivery"},{detect:e=>o(e,["templateId","template"]),feature:"templates",label:"provider templates"}];function n(e,d){if(!d)return{supported:!0,violations:[]};const t=[];for(const a of c){if(d[a.feature]!==!1)continue;const r=a.detect(e);r!==void 0&&t.push({feature:a.feature,field:r,message:`Message uses ${a.label} (field "${r}") but the provider does not support the "${a.feature}" capability`})}return{supported:t.length===0,violations:t}}export{n as default};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import f from"./DraftMailMessage-B0gwf8n_.js";import v from"./EmailError-SXEFQEyA.js";import u from"./MailMessage-DmmaNHHc.js";import{composeMiddleware as w}from"./composeMiddleware-B3RCDFsy.js";import{b as C}from"./build-mime-message-D45WdgfP.js";import{c as M}from"./create-logger-CazqtXcL.js";import{h as d}from"./headers-to-record-ZOZ7Dubo.js";import T from"../utils/validation/check-feature-support.js";const S=(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})},E=async(a,e,r)=>{const t={...a,to:e.to};return e.cc&&(t.cc=e.cc),e.bcc&&(t.bcc=e.bcc),e.replyTo&&(t.replyTo=e.replyTo),e.headers&&(t.headers={...d(a.headers??{}),...d(e.headers)}),t.subject=e.subject??a.subject,r&&e.data&&(t.subject=await r(t.subject,e.data),a.html!==void 0&&(t.html=await r(a.html,e.data)),a.text!==void 0&&(t.text=await r(a.text,e.data))),t};class h{static extractErrorMessages(e){return e instanceof Error?[e.message]:[String(e??"Unknown error")]}provider;logger;loggerInstance;globalConfig;featureCheck;middlewares=[];composedSend;mountedProviders=new Map;constructor(e,r){this.provider=e,this.featureCheck=r?.featureCheck??"error"}setLogger(e){return this.loggerInstance=e,this.logger=M("Mail",e),this}use(e){return this.middlewares.push(e),this.composedSend=void 0,this}mount(e,r){return this.mountedProviders.set(e,r),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 u||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 C(r,{includeBcc:!0});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 u)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,this.resolveProvider(r));if(t)return{error:t,success:!1};const s=await this.dispatch(r);return S(this.logger,s,this.provider.name??"unknown"),s}sendMany(e,r){const t=Math.max(1,Math.floor(r?.concurrency??1));return t===1?this.sendManySerial(e,r?.signal):this.sendManyConcurrent(e,t,r?.signal)}sendBatch(e,r,t){const s=async function*(){const o=e instanceof u?await e.build():e;for(const i of r)yield await E(o,i,t?.render)};return this.sendMany(s(),{concurrency:t?.concurrency,signal:t?.signal})}async sendOneToReceipt(e){const r=this.provider.name;try{const t=await this.send(e);return t.success&&t.data?{messageId:t.data.messageId,provider:t.data.provider??r,response:t.data.response,successful:!0,timestamp:t.data.timestamp}:{errorMessages:h.extractErrorMessages(t.error),provider:r,successful:!1}}catch(t){return{errorMessages:h.extractErrorMessages(t),provider:r,successful:!1}}}async*sendManySerial(e,r){const t=this.provider.name;let s=0,o=0,i=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?.aborted){this.logger&&this.logger.warn("Batch send operation was aborted",{failed:i,processed:s,successful:o}),yield{errorMessages:["Send operation was aborted"],provider:t,successful:!1};return}s+=1;const n=await this.sendOneToReceipt(l);n.successful?o+=1:i+=1,yield n}this.logger&&this.logger.debug("Batch email send completed",{failureCount:i,processedCount:s,provider:t,successCount:o})}async*sendManyConcurrent(e,r,t){const s=this.provider.name;this.logger&&this.logger.debug("Starting concurrent batch email send",{concurrency:r,provider:s});const o=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator](),i=new Map;let l=0,n=!1,p=!1;const m=async()=>{for(;!n&&!p&&i.size<r;){const g=await o.next();if(g.done){n=!0;break}const c=g.value;if(c instanceof f)throw new TypeError("Cannot send draft messages. Convert to MailMessage first or remove X-Unsent header.");const b=l;l+=1,i.set(b,this.sendOneToReceipt(c).then(y=>({id:b,receipt:y})))}};for(await m();i.size>0;){if(t?.aborted){p=!0,yield{errorMessages:["Send operation was aborted"],provider:s,successful:!1};return}const{id:g,receipt:c}=await Promise.race(i.values());i.delete(g),yield c,await m()}this.logger&&this.logger.debug("Concurrent batch email send completed",{processedCount:l,provider:s})}async dispatch(e){return this.middlewares.length===0?await this.resolveProvider(e).sendEmail(e):(this.composedSend??=w(this.middlewares,r=>Promise.resolve(this.resolveProvider(r).sendEmail(r))),await this.composedSend(e))}resolveProvider(e){return e.stream!==void 0?this.mountedProviders.get(e.stream)??this.provider:this.provider}assertFeatureSupport(e,r){if(this.featureCheck==="off")return;const{supported:t,violations:s}=T(e,r.features);if(t)return;const o=r.name??"unknown",i=s.map(n=>n.field),l=s.map(n=>n.message);if(this.featureCheck==="warn"){this.logger&&this.logger.warn("Message uses capabilities the provider does not support",{fields:i,provider:o});return}return this.logger&&this.logger.error("Message rejected by capability guard",{fields:i,provider:o}),new v(o,`Provider does not support the following message fields: ${i.join(", ")}`,{code:"UNSUPPORTED_FEATURES",hint:l})}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,i])=>{e.header(o,i)})}}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 O=(a,e)=>new h(a,e);export{h as Mail,O as createMail};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as p}from"node:module";import{readFileAsBuffer as c,detectMimeType as d,generateContentId as u}from"./detectMimeType-BRz3Qjyz.js";import{c as T}from"./create-logger-CazqtXcL.js";import{h as l}from"./headers-to-record-ZOZ7Dubo.js";let y;const A=n=>(y??=p(import.meta.url))(n),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,f=n=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[t,e]=o.versions.node.split(".").map(Number);if(t>22||t===22&&e>=3||t===20&&e>=16)return o.getBuiltinModule(n)}return A(n)},{basename:g}=f("node:path"),{fileURLToPath:b}=f("node:url"),m=async()=>(await import("../template-engines/html-to-text.js")).default,x=async()=>(await import("ical-generator")).default,a=n=>Array.isArray(n)?n.map(t=>typeof t=="string"?{email:t}:t):typeof n=="string"?[{email:n}]:[n];class D{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;icalEventBuilder;from(t){return this.fromAddress=typeof t=="string"?{email:t}:t,this}to(t){return this.toAddresses.length=0,this.toAddresses.push(...a(t)),this}cc(t){return this.ccAddresses.length=0,this.ccAddresses.push(...a(t)),this}bcc(t){return this.bccAddresses.length=0,this.bccAddresses.push(...a(t)),this}subject(t){return this.subjectText=t,this}text(t,e="utf8"){return this.textContent=t,this.textCharset=e,this}html(t,e="utf8"){return this.htmlContent=t,this.htmlCharset=e,this}header(t,e){return this.headers[t]=e,this}setHeaders(t){const e=l(t);return Object.assign(this.headers,e),this}async attachFromPath(t,e){try{const r=await c(t),i=e?.filename??(g(t)||"attachment"),s=e?.contentType??d(i);this.attachments.push({cid:e?.cid,content:r,contentDisposition:e?.contentDisposition??"attachment",contentType:s,encoding:e?.encoding,filename:i,headers:e?.headers}),this.logger&&this.logger.debug(`Attachment added from path: ${t}`,{contentType:s,filename:i})}catch(r){throw this.logger&&this.logger.error(`Failed to attach file from path: ${t}`,r),r}return this}attachData(t,e){const r=e.contentType??d(e.filename);return this.attachments.push({cid:e.cid,content:t,contentDisposition:e.contentDisposition??"attachment",contentType:r,encoding:e.encoding,filename:e.filename,headers:e.headers}),this.logger&&this.logger.debug("Attachment added from data",{contentType:r,filename:e.filename}),this}async embedFromPath(t,e){try{const r=await c(t),i=e?.filename??(g(t)||"inline"),s=e?.contentType??d(i),h=u(i);return this.attachments.push({cid:h,content:r,contentDisposition:"inline",contentType:s,filename:i}),this.logger&&this.logger.debug(`Inline attachment embedded from path: ${t}`,{cid:h,contentType:s,filename:i}),h}catch(r){throw this.logger&&this.logger.error(`Failed to embed file from path: ${t}`,r),r}}embedData(t,e,r){const i=r?.contentType??d(e),s=u(e);return this.attachments.push({cid:s,content:t,contentDisposition:"inline",contentType:i,filename:e}),this.logger&&this.logger.debug("Inline attachment embedded from data",{cid:s,contentType:i,filename:e}),s}replyTo(t){return this.replyToAddress=typeof t=="string"?{email:t}:t,this}date(t){return this.dateValue=typeof t=="string"?new Date(t):t,this.logger&&this.logger.debug("Date header set",{date:this.dateValue.toISOString()}),this}returnPath(t){return this.returnPathAddress=typeof t=="string"?{email:t}:t,this.logger&&this.logger.debug("Return-path address set",{returnPath:this.returnPathAddress.email}),this}sender(t){return this.senderAddress=typeof t=="string"?{email:t}:t,this.logger&&this.logger.debug("Sender address set",{sender:this.senderAddress.email}),this}addTo(t){return this.toAddresses.push(...a(t)),this}addCc(t){return this.ccAddresses.push(...a(t)),this}addBcc(t){return this.bccAddresses.push(...a(t)),this}addReplyTo(t){const e=Array.isArray(t)?t:[t];if(e.length>0){const r=e[0];this.replyToAddress=typeof r=="string"?{email:r}:r}return this}addFrom(t){const e=Array.isArray(t)?t:[t];if(e.length>0){const r=e[0];this.fromAddress=typeof r=="string"?{email:r}:r}return this}priority(t){return this.priorityValue=t,this}tags(t){return this.tagsValue=Array.isArray(t)?t:[t],this}sign(t){return this.signer=t,this.logger&&this.logger.debug("Email signer configured"),this}encrypt(t){return this.encrypter=t,this.logger&&this.logger.debug("Email encrypter configured"),this}setLogger(t){return this.logger=T("MailMessage",t),this}icalEvent(t,e){return typeof t=="function"?(this.icalEventBuilder={build:t,options:e},this.icalEventData=void 0):(this.icalEventBuilder=void 0,this.icalEventData={content:t,...e}),this.logger&&this.logger.debug("Calendar event attached",{method:e?.method}),this}icalEventFromFile(t,e){const r=typeof t=="string"?t:b(t);return this.icalEventData={path:r,...e},this.logger&&this.logger.debug(`Calendar event attached from file: ${r}`,{method:e?.method}),this}icalEventFromUrl(t,e){return this.icalEventData={href:t,...e},this.logger&&this.logger.debug(`Calendar event attached from URL: ${t}`,{method:e?.method}),this}async view(t,e,r,i){try{const s=i?.autoText!==!1;this.autoTextEnabled=s,this.logger&&this.logger.debug("Rendering template",{autoText:s});const h=await t(e,r,i);this.html(h),s&&h&&await this.tryAutoGenerateText(h),this.logger&&this.logger.debug("Template rendered successfully")}catch(s){throw this.logger&&this.logger.error("Failed to render template",s),new Error(`Failed to render template: ${s.message}`)}return this}async viewText(t,e,r,i){try{this.logger&&this.logger.debug("Rendering text template");const s=await t(e,r,i);if(typeof s=="string")this.text(s),this.logger&&this.logger.debug("Text template rendered successfully");else throw new TypeError("Text renderer must return a string")}catch(s){throw this.logger&&this.logger.error("Failed to render text template",s),new Error(`Failed to render text template: ${s.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{const e=await m();this.textContent=e(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 t={from:this.fromAddress,html:this.htmlContent,subject:this.subjectText,text:this.textContent,to:this.toAddresses.length===1?this.toAddresses[0]:this.toAddresses};if(this.ccAddresses.length>0&&(t.cc=this.ccAddresses.length===1?this.ccAddresses[0]:this.ccAddresses),this.bccAddresses.length>0&&(t.bcc=this.bccAddresses.length===1?this.bccAddresses[0]:this.bccAddresses),Object.keys(this.headers).length>0&&(t.headers=this.headers),this.attachments.length>0&&(t.attachments=this.attachments,this.logger&&this.logger.debug(`Email includes ${this.attachments.length} attachment(s)`)),this.replyToAddress&&(t.replyTo=this.replyToAddress),this.priorityValue&&(t.priority=this.priorityValue),this.tagsValue.length>0&&(t.tags=this.tagsValue),this.icalEventBuilder){const r=(await x())();this.icalEventBuilder.build(r),this.icalEventData={content:r.toString(),...this.icalEventBuilder.options}}return this.icalEventData&&(t.icalEvent=this.icalEventData,this.logger&&this.logger.debug("Email includes calendar event")),this.dateValue&&(t.headers={...l(t.headers??{}),Date:this.dateValue.toUTCString()}),this.returnPathAddress&&(t.headers={...l(t.headers??{}),"Return-Path":this.returnPathAddress.email}),this.senderAddress&&(t.headers={...l(t.headers??{}),Sender:this.senderAddress.email}),this.signer&&(this.logger&&this.logger.debug("Signing email message"),t=await this.signer.sign(t),this.logger&&this.logger.debug("Email message signed successfully")),this.encrypter&&(this.logger&&this.logger.debug("Encrypting email message"),t=await this.encrypter.encrypt(t),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}),t}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]}async tryAutoGenerateText(t){try{const r=(await m())(t);r&&!this.textContent&&this.text(r),this.logger&&this.logger.debug("Auto-generated text content from HTML template")}catch(e){this.logger&&this.logger.warn("Failed to auto-generate text from HTML template",e)}}throwAndLogError(t,e){const r=new Error(t);throw this.logger&&this.logger.error(e??t),r}}export{D as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import c from"./EmailError-SXEFQEyA.js";import E from"./RequiredOptionError-C2wWqmiE.js";import{g as I}from"./generate-message-id-C5AM6DFE.js";import{h as w}from"./headers-to-record-ZOZ7Dubo.js";import{m as f}from"./make-request-mszP240P.js";import{r as g}from"./retry-ByPJFAtq.js";import{v as T}from"./validate-email-options-DxdAVLlu.js";import{defineProvider as P}from"./defineProvider-C9q-7iwt.js";import{c as $,P as C,h as p}from"./provider-base-G22b4a87.js";import{e as j,g as b,d as v}from"./address-formatter-w36S9ZYj.js";import{p as R}from"./attachment-processor-AB1m-n9T.js";const o="resend",S="https://api.resend.com",k=3e4,z=3,D=s=>{const r=[],d=/^[\w-]+$/;return d.test(s.name)||r.push(`Tag name '${s.name}' must only contain ASCII letters, numbers, underscores, or dashes`),s.name.length>256&&r.push(`Tag name '${s.name}' exceeds maximum length of 256 characters`),d.test(s.value)||r.push(`Tag value '${s.value}' for tag '${s.name}' must only contain ASCII letters, numbers, underscores, or dashes`),r},V=P((s={})=>{if(!s.apiKey)throw new E(o,"apiKey");const r={apiKey:s.apiKey,debug:s.debug??!1,endpoint:s.endpoint??S,logger:s.logger,retries:s.retries??z,timeout:s.timeout??k},d=new C,n=$(o,s.logger);return{endpoint:r.endpoint,features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!0,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new c(o,"Email ID is required to retrieve email details"),success:!1};await d.ensureInitialized(()=>this.initialize(),o);const t={Authorization:`Bearer ${r.apiKey}`,"Content-Type":"application/json"};n.debug("Retrieving email details",{id:e});const a=await g(async()=>f(`${r.endpoint}/emails/${e}`,{headers:t,method:"GET",timeout:r.timeout}),r.retries);return a.success?(n.debug("Email details retrieved successfully"),{data:a.data?.body,success:!0}):(n.debug("API request failed when retrieving email",a.error),{error:new c(o,`Failed to retrieve email: ${a.error instanceof Error?a.error.message:"Unknown error"}`,{cause:a.error}),success:!1})}catch(t){return{error:p(o,"retrieve email",t,n),success:!1}}},async initialize(){await d.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(o,"Resend API not available or invalid API key");n.debug("Provider initialized successfully")},o)},async isAvailable(){try{if(r.apiKey&&r.apiKey.startsWith("re_"))return n.debug("API key format is valid, assuming Resend is available"),!0;const e={Authorization:`Bearer ${r.apiKey}`,"Content-Type":"application/json"};n.debug("Checking Resend API availability");const t=await f(`${r.endpoint}/domains`,{headers:e,method:"GET",timeout:r.timeout});return t.data&&typeof t.data=="object"&&"body"in t.data&&t.data.body&&typeof t.data.body=="object"&&"name"in t.data.body&&t.data.body.name==="restricted_api_key"?(n.debug("API key is valid but restricted to only sending emails"),!0):(n.debug("Resend API availability check response:",{error:t.error instanceof Error?t.error.message:void 0,statusCode:t.data?.statusCode,success:t.success}),!!(t.success&&t.data&&typeof t.data=="object"&&"statusCode"in t.data&&typeof t.data.statusCode=="number"&&t.data.statusCode>=200&&t.data.statusCode<300))}catch(e){return n.debug("Error checking availability:",e),!1}},name:o,options:r,async sendEmail(e){try{const t=T(e);if(t.length>0)return{error:new c(o,`Invalid email options: ${t.join(", ")}`),success:!1};await d.ensureInitialized(()=>this.initialize(),o);const a={from:b(e.from),headers:e.headers?w(e.headers):{},html:e.html,subject:e.subject,text:e.text,to:j(e.to)};if(e.cc&&(a.cc=v(e.cc)),e.bcc&&(a.bcc=v(e.bcc)),e.replyTo&&(a.reply_to=b(e.replyTo)),e.templateId&&(a.template=e.templateId,e.templateData&&(a.data=e.templateData)),e.scheduledAt&&(a.scheduled_at=typeof e.scheduledAt=="string"?e.scheduledAt:e.scheduledAt.toISOString()),e.tags&&e.tags.length>0){const i=[];if(e.tags.forEach(l=>{const y=D(l);y.length>0&&i.push(...y)}),i.length>0)return{error:new c(o,`Invalid email tags: ${i.join(", ")}`),success:!1};a.tags=e.tags.map(l=>({name:l.name,value:l.value}))}e.attachments&&e.attachments.length>0&&(a.attachments=await Promise.all(e.attachments.map(async i=>({content:await R(i,o),content_type:i.contentType,filename:i.filename,...i.path&&{path:i.path}})))),n.debug("Sending email via Resend API",{subject:a.subject,to:a.to});const A={Authorization:`Bearer ${r.apiKey}`,"Content-Type":"application/json"},u=await g(async()=>f(`${r.endpoint}/emails`,{headers:A,method:"POST",timeout:r.timeout},JSON.stringify(a)),r.retries);if(!u.success)return n.debug("API request failed when sending email",u.error),{error:u.error??new c(o,"Failed to send email"),success:!1};const m=u.data,h=m?.body&&typeof m.body=="object"&&m.body.id?m.body.id:I();return n.debug("Email sent successfully",{messageId:h}),{data:{messageId:h,provider:o,response:u.data,sent:!0,timestamp:new Date},success:!0}}catch(t){return{error:p(o,"send email",t,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{V as default};
|