@visulima/email 2.1.0 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/packem_shared/{ahaSendProvider-D81_wUA1.js → ahaSendProvider-DSuZIzaQ.js} +1 -1
  3. package/dist/packem_shared/{autoSendProvider-Bz3g6aZi.js → autoSendProvider-DqAoelWR.js} +1 -1
  4. package/dist/packem_shared/{awsSesProvider-962hIcbo.js → awsSesProvider-ClK1FUln.js} +1 -1
  5. package/dist/packem_shared/{azureProvider-CmcK4bsf.js → azureProvider-Cw_Tmde6.js} +1 -1
  6. package/dist/packem_shared/{brevoProvider-C1BDXr41.js → brevoProvider-CIzuIDlt.js} +1 -1
  7. package/dist/packem_shared/{httpProvider-DJAsYSun.js → httpProvider-aBfTXyCT.js} +1 -1
  8. package/dist/packem_shared/{infobipProvider-lHyGrXgZ.js → infobipProvider-DxzsONUX.js} +1 -1
  9. package/dist/packem_shared/{loopsProvider-DyloxzNC.js → loopsProvider-QBsAH6Ee.js} +1 -1
  10. package/dist/packem_shared/{mailPaceProvider-DZent57J.js → mailPaceProvider-DCa-4ghl.js} +1 -1
  11. package/dist/packem_shared/{mailchannelsProvider-osRkW_tz.js → mailchannelsProvider-GiwkYBdD.js} +1 -1
  12. package/dist/packem_shared/{mailerSendProvider-C_6LzARK.js → mailerSendProvider-RK6IbUrL.js} +1 -1
  13. package/dist/packem_shared/{mailgunProvider-DkISvMPe.js → mailgunProvider-D9HUWGKN.js} +1 -1
  14. package/dist/packem_shared/{mailjetProvider-CV0i4Xzh.js → mailjetProvider-DelLs2Vt.js} +1 -1
  15. package/dist/packem_shared/{mailomatProvider-B5YFonEO.js → mailomatProvider-DPDpVS8r.js} +1 -1
  16. package/dist/packem_shared/{mailtrapProvider-C4ZquIPz.js → mailtrapProvider-DtrS4Q34.js} +1 -1
  17. package/dist/packem_shared/make-request-B9XjBynA.js +1 -0
  18. package/dist/packem_shared/{mandrillProvider-DSsAknmA.js → mandrillProvider-B84zH-eV.js} +1 -1
  19. package/dist/packem_shared/{netcoreProvider-C5TEciaN.js → netcoreProvider-D-wtCyJj.js} +1 -1
  20. package/dist/packem_shared/{outlook365Provider-CkjXkY-7.js → outlook365Provider-Btk4Emig.js} +1 -1
  21. package/dist/packem_shared/{plunkProvider-D3T2T-2V.js → plunkProvider-Bw8e6460.js} +1 -1
  22. package/dist/packem_shared/{postalProvider-CRX_bMYD.js → postalProvider-CT8zr89z.js} +1 -1
  23. package/dist/packem_shared/{postmarkProvider-vspVSSOp.js → postmarkProvider-CQSqZWDs.js} +1 -1
  24. package/dist/packem_shared/{resendProvider-CiclWxzr.js → resendProvider-drJYlvLP.js} +1 -1
  25. package/dist/packem_shared/retry-ipI5DRJ8.js +1 -0
  26. package/dist/packem_shared/{scalewayProvider-BcND48qO.js → scalewayProvider-DU5gXQrl.js} +1 -1
  27. package/dist/packem_shared/{sendGridProvider-D8ZLgY62.js → sendGridProvider-BuTbEXW8.js} +1 -1
  28. package/dist/packem_shared/{sparkpostProvider-CTYfSRaV.js → sparkpostProvider-UAsFYIjP.js} +1 -1
  29. package/dist/packem_shared/{sweegoProvider-DOoin_vi.js → sweegoProvider-SUz0LIcA.js} +1 -1
  30. package/dist/packem_shared/{zeptomailProvider-DUesgbC-.js → zeptomailProvider-DXNX9mG_.js} +1 -1
  31. package/dist/providers/ahasend/index.js +1 -1
  32. package/dist/providers/autosend/index.js +1 -1
  33. package/dist/providers/aws-ses/index.js +1 -1
  34. package/dist/providers/azure/index.js +1 -1
  35. package/dist/providers/brevo/index.js +1 -1
  36. package/dist/providers/http/index.js +1 -1
  37. package/dist/providers/infobip/index.js +1 -1
  38. package/dist/providers/loops/index.js +1 -1
  39. package/dist/providers/mailchannels/index.js +1 -1
  40. package/dist/providers/mailersend/index.js +1 -1
  41. package/dist/providers/mailgun/index.js +1 -1
  42. package/dist/providers/mailjet/index.js +1 -1
  43. package/dist/providers/mailomat/index.js +1 -1
  44. package/dist/providers/mailpace/index.js +1 -1
  45. package/dist/providers/mailtrap/index.js +1 -1
  46. package/dist/providers/mandrill/index.js +1 -1
  47. package/dist/providers/netcore/index.js +1 -1
  48. package/dist/providers/outlook365/index.js +1 -1
  49. package/dist/providers/plunk/index.js +1 -1
  50. package/dist/providers/postal/index.js +1 -1
  51. package/dist/providers/postmark/index.js +1 -1
  52. package/dist/providers/resend/index.js +1 -1
  53. package/dist/providers/scaleway/index.js +1 -1
  54. package/dist/providers/sendgrid/index.js +1 -1
  55. package/dist/providers/sparkpost/index.js +1 -1
  56. package/dist/providers/sweego/index.js +1 -1
  57. package/dist/providers/zeptomail/index.js +1 -1
  58. package/package.json +1 -1
  59. package/dist/packem_shared/make-request-BlK_B72c.js +0 -1
  60. package/dist/packem_shared/retry-3pnxTuNs.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## @visulima/email [2.1.2](https://github.com/visulima/visulima/compare/%40visulima%2Femail%402.1.1...%40visulima%2Femail%402.1.2) (2026-07-19)
2
+
3
+
4
+ ### Dependencies
5
+
6
+ * **@visulima/fs:** upgraded to 5.0.5
7
+
8
+ ## @visulima/email [2.1.1](https://github.com/visulima/visulima/compare/%40visulima%2Femail%402.1.0...%40visulima%2Femail%402.1.1) (2026-07-17)
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * **@visulima/fs:** upgraded to 5.0.4
14
+
1
15
  ## @visulima/email [2.1.0](https://github.com/visulima/visulima/compare/%40visulima%2Femail%402.0.0...%40visulima%2Femail%402.1.0) (2026-07-17)
2
16
 
3
17
 
@@ -1 +1 @@
1
- import l from"./EmailError-B-sEf3bp.js";import b from"./RequiredOptionError-DuNNY_a5.js";import{e as v}from"./generate-message-id-gXAuMz4g.js";import{s as w}from"./headers-to-record-De1Eg951.js";import{m}from"./make-request-BlK_B72c.js";import{u as g}from"./retry-3pnxTuNs.js";import{f as A}from"./validate-email-options-mCM9dVug.js";import{defineProvider as I}from"./defineProvider-C9q-7iwt.js";import{f as d,a as P}from"./address-formatter-BWR2Dddx.js";import{p as T}from"./attachment-processor-CMp7qqMI.js";import{h,P as E,c as S}from"./provider-base-C7PuopYK.js";const a="ahasend",j="https://api.ahasend.com",z=3e4,k=3,H=I((s={})=>{if(!s.apiKey)throw new b(a,"apiKey");const r={apiKey:s.apiKey,debug:s.debug??!1,endpoint:s.endpoint??j,retries:s.retries??k,timeout:s.timeout??z,...s.logger&&{logger:s.logger}},f=new E,i=S(a,s.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new l(a,"Email ID is required to retrieve email details"),success:!1};await this.initialize();const n={Authorization:`Bearer ${r.apiKey}`,"Content-Type":"application/json"};i.debug("Retrieving email details",{id:e});const t=await g(async()=>m(`${r.endpoint}/emails/${e}`,{headers:n,method:"GET",timeout:r.timeout}),r.retries);return t.success?(i.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(i.debug("API request failed when retrieving email",t.error),{error:new l(a,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(n){return{error:h(a,"retrieve email",n,i),success:!1}}},async initialize(){await f.ensureInitialized(async()=>{if(!await this.isAvailable())throw new l(a,"AhaSend API not available or invalid API key");i.debug("Provider initialized successfully")},a)},async isAvailable(){try{return i.debug("Checking AhaSend API availability"),!!(await m(`${r.endpoint}/v2/ping`,{headers:{Authorization:`Bearer ${r.apiKey}`,"Content-Type":"application/json"},method:"GET",timeout:r.timeout})).success}catch(e){return i.debug("Error checking availability:",e),!1}},name:a,options:r,async sendEmail(e){try{const n=A(e);if(n.length>0)return{error:new l(a,`Invalid email options: ${n.join(", ")}`),success:!1};await this.initialize();const t={from:{email:e.from.email,name:e.from.name},subject:e.subject,to:d(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=d(e.cc)),e.bcc&&(t.bcc=d(e.bcc)),e.replyTo&&(t.replyTo=P(e.replyTo)),e.templateId&&(t.templateId=e.templateId,e.templateVariables&&(t.templateVariables=e.templateVariables)),e.tags&&e.tags.length>0&&(t.tags=e.tags),e.headers){const o=w(e.headers);t.headers=o}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async o=>({content:await T(o,a),contentType:o.contentType??"application/octet-stream",filename:o.filename,...o.cid&&{cid:o.cid}})))),i.debug("Sending email via AhaSend API",{subject:t.subject,to:t.to});const y={Authorization:`Bearer ${r.apiKey}`,"Content-Type":"application/json"},c=await g(async()=>m(`${r.endpoint}/send`,{headers:y,method:"POST",timeout:r.timeout},JSON.stringify(t)),r.retries);if(!c.success)return i.debug("API request failed when sending email",c.error),{error:c.error??new l(a,"Failed to send email"),success:!1};const u=c.data?.body,p=u?.messageId??u?.id??v();return i.debug("Email sent successfully",{messageId:p}),{data:{messageId:p,provider:a,response:c.data,sent:!0,timestamp:new Date},success:!0}}catch(n){return{error:h(a,"send email",n,i),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{H as default};
1
+ import l from"./EmailError-B-sEf3bp.js";import b from"./RequiredOptionError-DuNNY_a5.js";import{e as v}from"./generate-message-id-gXAuMz4g.js";import{s as w}from"./headers-to-record-De1Eg951.js";import{m}from"./make-request-B9XjBynA.js";import{i as g}from"./retry-ipI5DRJ8.js";import{f as A}from"./validate-email-options-mCM9dVug.js";import{defineProvider as I}from"./defineProvider-C9q-7iwt.js";import{f as d,a as P}from"./address-formatter-BWR2Dddx.js";import{p as T}from"./attachment-processor-CMp7qqMI.js";import{h,P as E,c as S}from"./provider-base-C7PuopYK.js";const a="ahasend",j="https://api.ahasend.com",z=3e4,k=3,H=I((s={})=>{if(!s.apiKey)throw new b(a,"apiKey");const r={apiKey:s.apiKey,debug:s.debug??!1,endpoint:s.endpoint??j,retries:s.retries??k,timeout:s.timeout??z,...s.logger&&{logger:s.logger}},f=new E,i=S(a,s.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new l(a,"Email ID is required to retrieve email details"),success:!1};await this.initialize();const n={Authorization:`Bearer ${r.apiKey}`,"Content-Type":"application/json"};i.debug("Retrieving email details",{id:e});const t=await g(async()=>m(`${r.endpoint}/emails/${e}`,{headers:n,method:"GET",timeout:r.timeout}),r.retries);return t.success?(i.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(i.debug("API request failed when retrieving email",t.error),{error:new l(a,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(n){return{error:h(a,"retrieve email",n,i),success:!1}}},async initialize(){await f.ensureInitialized(async()=>{if(!await this.isAvailable())throw new l(a,"AhaSend API not available or invalid API key");i.debug("Provider initialized successfully")},a)},async isAvailable(){try{return i.debug("Checking AhaSend API availability"),!!(await m(`${r.endpoint}/v2/ping`,{headers:{Authorization:`Bearer ${r.apiKey}`,"Content-Type":"application/json"},method:"GET",timeout:r.timeout})).success}catch(e){return i.debug("Error checking availability:",e),!1}},name:a,options:r,async sendEmail(e){try{const n=A(e);if(n.length>0)return{error:new l(a,`Invalid email options: ${n.join(", ")}`),success:!1};await this.initialize();const t={from:{email:e.from.email,name:e.from.name},subject:e.subject,to:d(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=d(e.cc)),e.bcc&&(t.bcc=d(e.bcc)),e.replyTo&&(t.replyTo=P(e.replyTo)),e.templateId&&(t.templateId=e.templateId,e.templateVariables&&(t.templateVariables=e.templateVariables)),e.tags&&e.tags.length>0&&(t.tags=e.tags),e.headers){const o=w(e.headers);t.headers=o}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async o=>({content:await T(o,a),contentType:o.contentType??"application/octet-stream",filename:o.filename,...o.cid&&{cid:o.cid}})))),i.debug("Sending email via AhaSend API",{subject:t.subject,to:t.to});const y={Authorization:`Bearer ${r.apiKey}`,"Content-Type":"application/json"},c=await g(async()=>m(`${r.endpoint}/send`,{headers:y,method:"POST",timeout:r.timeout},JSON.stringify(t)),r.retries);if(!c.success)return i.debug("API request failed when sending email",c.error),{error:c.error??new l(a,"Failed to send email"),success:!1};const u=c.data?.body,p=u?.messageId??u?.id??v();return i.debug("Email sent successfully",{messageId:p}),{data:{messageId:p,provider:a,response:c.data,sent:!0,timestamp:new Date},success:!0}}catch(n){return{error:h(a,"send email",n,i),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{H as default};
@@ -1 +1 @@
1
- import c from"./EmailError-B-sEf3bp.js";import T from"./RequiredOptionError-DuNNY_a5.js";import{s as x}from"./headers-to-record-De1Eg951.js";import{m as z}from"./make-request-BlK_B72c.js";import{u as K}from"./retry-3pnxTuNs.js";import{s as P,a as G}from"./sanitize-header-DtQwAnzg.js";import{f as C}from"./validate-email-options-mCM9dVug.js";import{defineProvider as E}from"./defineProvider-C9q-7iwt.js";import{a as y,f as w}from"./address-formatter-BWR2Dddx.js";import{h as q,P as D,c as B}from"./provider-base-C7PuopYK.js";import{c as F}from"./attachment-processor-CMp7qqMI.js";const n="autosend",H="https://api.autosend.com/v1",N=3e4,R=3,v=50,$=20,A=40*1024*1024,k=20,I=1e3,j=998,Z=/^[A-Z0-9-]{1,76}$/i,J="^[A-Za-z0-9-]{1,76}$",L="Either text or html content is required",g=t=>[t].flat(),V=async t=>{const s=await F(t,n);return{content:s.content,contentType:s.contentType,fileName:s.filename}},U=(t,s)=>{const i=g(t.to);if(i.length!==1)return`AutoSend's send endpoint takes exactly one 'to' recipient, but ${String(i.length)} were given — use 'cc'/'bcc', or send one message per recipient`;const o=i.length+(t.cc?g(t.cc).length:0)+(t.bcc?g(t.bcc).length:0);if(o>v)return`AutoSend allows at most ${String(v)} recipients across to/cc/bcc, but ${String(o)} were given`;if(t.attachments&&t.attachments.length>$)return`AutoSend allows at most ${String($)} attachments, but ${String(t.attachments.length)} were given`;const e=t.attachments?.find(r=>r.cid);if(e)return`AutoSend does not support inline (cid) attachments, but '${e.filename}' sets one — host the image and reference it by URL instead`;if(t.subject.length>j)return`AutoSend allows a subject of at most ${String(j)} characters, but ${String(t.subject.length)} were given`;const a=Object.keys(s);if(a.length>k)return`AutoSend allows at most ${String(k)} custom headers, but ${String(a.length)} were given`;const d=a.find(r=>!Z.test(r));if(d!==void 0)return`AutoSend header names must match ${J}, but '${d}' does not`;const u=a.find(r=>s[r].length>I);if(u!==void 0)return`AutoSend allows header values of at most ${String(I)} characters, but '${u}' is longer`},X=t=>{if(typeof t!="object"||t===null)return{};const s=t;if(s.success===!0)return{emailId:typeof s.data?.emailId=="string"?s.data.emailId:void 0};const i=[s.message,s.error].find(o=>typeof o=="string");return{reason:typeof i=="string"?i:void 0}},ie=E((t={})=>{if(!t.apiKey)throw new T(n,"apiKey");const s={apiKey:t.apiKey,debug:t.debug??!1,endpoint:t.endpoint??H,logger:t.logger,retries:t.retries??R,timeout:t.timeout??N},i=new D,o=B(n,t.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!0,tracking:!0},async initialize(){i.setInitialized()},async isAvailable(){return s.apiKey.length>0},name:n,options:s,async sendEmail(e){try{const a=C(e).filter(l=>!(e.templateId!==void 0&&l===L));if(a.length>0)return{error:new c(n,`Invalid email options: ${a.join(", ")}`),success:!1};const d=e.headers?x(e.headers):{},u=U(e,d);if(u)return{error:new c(n,u),success:!1};const r={from:y(e.from),subject:e.subject,to:y(g(e.to)[0])};if(e.templateId?r.templateId=e.templateId:(e.html&&(r.html=e.html),e.text&&(r.text=e.text)),e.cc&&(r.cc=w(e.cc)),e.bcc&&(r.bcc=w(e.bcc)),e.replyTo&&(r.replyTo=y(e.replyTo)),e.dynamicData&&(r.dynamicData=e.dynamicData),e.unsubscribeGroupId&&(r.unsubscribeGroupId=e.unsubscribeGroupId),e.trackingClick!==void 0&&(r.trackingClick=e.trackingClick),e.trackingOpen!==void 0&&(r.trackingOpen=e.trackingOpen),e.bypassSuppressions!==void 0&&(r.bypassSuppressions=e.bypassSuppressions),Object.keys(d).length>0&&(r.headers=Object.fromEntries(Object.entries(d).map(([l,p])=>[P(l),G(p)]))),e.attachments&&e.attachments.length>0){const l=await Promise.all(e.attachments.map(async b=>V(b))),p=l.reduce((b,O)=>b+O.content.length,0);if(p>A)return{error:new c(n,`AutoSend allows at most ${String(A)} bytes of attachments after Base64 encoding, but this message carries ${String(p)}`),success:!1};r.attachments=l}const f=await K(async()=>z(`${s.endpoint}/mails/send`,{headers:{Authorization:`Bearer ${s.apiKey}`,"Content-Type":"application/json"},method:"POST",timeout:s.timeout},JSON.stringify(r)),s.retries),S=f.data?.body,{emailId:h,reason:m}=X(S);return f.success?m?{error:new c(n,`Failed to send email: ${m}`),success:!1}:h?(o.debug(`Email queued successfully: ${h}`),{data:{messageId:h,provider:n,response:S,sent:!0,timestamp:new Date},success:!0}):{error:new c(n,"AutoSend accepted the message but returned no emailId"),success:!1}:{error:m?new c(n,`Failed to send email: ${m}`):f.error??new c(n,"Failed to send email"),success:!1}}catch(a){return{error:q(n,"send email",a,o),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{ie as default};
1
+ import c from"./EmailError-B-sEf3bp.js";import T from"./RequiredOptionError-DuNNY_a5.js";import{s as x}from"./headers-to-record-De1Eg951.js";import{m as z}from"./make-request-B9XjBynA.js";import{i as K}from"./retry-ipI5DRJ8.js";import{s as P,a as G}from"./sanitize-header-DtQwAnzg.js";import{f as C}from"./validate-email-options-mCM9dVug.js";import{defineProvider as E}from"./defineProvider-C9q-7iwt.js";import{a as y,f as w}from"./address-formatter-BWR2Dddx.js";import{h as q,P as D,c as B}from"./provider-base-C7PuopYK.js";import{c as F}from"./attachment-processor-CMp7qqMI.js";const n="autosend",H="https://api.autosend.com/v1",N=3e4,R=3,v=50,$=20,A=40*1024*1024,k=20,I=1e3,j=998,Z=/^[A-Z0-9-]{1,76}$/i,J="^[A-Za-z0-9-]{1,76}$",L="Either text or html content is required",g=t=>[t].flat(),V=async t=>{const s=await F(t,n);return{content:s.content,contentType:s.contentType,fileName:s.filename}},U=(t,s)=>{const i=g(t.to);if(i.length!==1)return`AutoSend's send endpoint takes exactly one 'to' recipient, but ${String(i.length)} were given — use 'cc'/'bcc', or send one message per recipient`;const o=i.length+(t.cc?g(t.cc).length:0)+(t.bcc?g(t.bcc).length:0);if(o>v)return`AutoSend allows at most ${String(v)} recipients across to/cc/bcc, but ${String(o)} were given`;if(t.attachments&&t.attachments.length>$)return`AutoSend allows at most ${String($)} attachments, but ${String(t.attachments.length)} were given`;const e=t.attachments?.find(r=>r.cid);if(e)return`AutoSend does not support inline (cid) attachments, but '${e.filename}' sets one — host the image and reference it by URL instead`;if(t.subject.length>j)return`AutoSend allows a subject of at most ${String(j)} characters, but ${String(t.subject.length)} were given`;const a=Object.keys(s);if(a.length>k)return`AutoSend allows at most ${String(k)} custom headers, but ${String(a.length)} were given`;const d=a.find(r=>!Z.test(r));if(d!==void 0)return`AutoSend header names must match ${J}, but '${d}' does not`;const u=a.find(r=>s[r].length>I);if(u!==void 0)return`AutoSend allows header values of at most ${String(I)} characters, but '${u}' is longer`},X=t=>{if(typeof t!="object"||t===null)return{};const s=t;if(s.success===!0)return{emailId:typeof s.data?.emailId=="string"?s.data.emailId:void 0};const i=[s.message,s.error].find(o=>typeof o=="string");return{reason:typeof i=="string"?i:void 0}},ie=E((t={})=>{if(!t.apiKey)throw new T(n,"apiKey");const s={apiKey:t.apiKey,debug:t.debug??!1,endpoint:t.endpoint??H,logger:t.logger,retries:t.retries??R,timeout:t.timeout??N},i=new D,o=B(n,t.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!0,tracking:!0},async initialize(){i.setInitialized()},async isAvailable(){return s.apiKey.length>0},name:n,options:s,async sendEmail(e){try{const a=C(e).filter(l=>!(e.templateId!==void 0&&l===L));if(a.length>0)return{error:new c(n,`Invalid email options: ${a.join(", ")}`),success:!1};const d=e.headers?x(e.headers):{},u=U(e,d);if(u)return{error:new c(n,u),success:!1};const r={from:y(e.from),subject:e.subject,to:y(g(e.to)[0])};if(e.templateId?r.templateId=e.templateId:(e.html&&(r.html=e.html),e.text&&(r.text=e.text)),e.cc&&(r.cc=w(e.cc)),e.bcc&&(r.bcc=w(e.bcc)),e.replyTo&&(r.replyTo=y(e.replyTo)),e.dynamicData&&(r.dynamicData=e.dynamicData),e.unsubscribeGroupId&&(r.unsubscribeGroupId=e.unsubscribeGroupId),e.trackingClick!==void 0&&(r.trackingClick=e.trackingClick),e.trackingOpen!==void 0&&(r.trackingOpen=e.trackingOpen),e.bypassSuppressions!==void 0&&(r.bypassSuppressions=e.bypassSuppressions),Object.keys(d).length>0&&(r.headers=Object.fromEntries(Object.entries(d).map(([l,p])=>[P(l),G(p)]))),e.attachments&&e.attachments.length>0){const l=await Promise.all(e.attachments.map(async b=>V(b))),p=l.reduce((b,O)=>b+O.content.length,0);if(p>A)return{error:new c(n,`AutoSend allows at most ${String(A)} bytes of attachments after Base64 encoding, but this message carries ${String(p)}`),success:!1};r.attachments=l}const f=await K(async()=>z(`${s.endpoint}/mails/send`,{headers:{Authorization:`Bearer ${s.apiKey}`,"Content-Type":"application/json"},method:"POST",timeout:s.timeout},JSON.stringify(r)),s.retries),S=f.data?.body,{emailId:h,reason:m}=X(S);return f.success?m?{error:new c(n,`Failed to send email: ${m}`),success:!1}:h?(o.debug(`Email queued successfully: ${h}`),{data:{messageId:h,provider:n,response:S,sent:!0,timestamp:new Date},success:!0}):{error:new c(n,"AutoSend accepted the message but returned no emailId"),success:!1}:{error:m?new c(n,`Failed to send email: ${m}`):f.error??new c(n,"Failed to send email"),success:!1}}catch(a){return{error:q(n,"send email",a,o),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{ie as default};
@@ -1,4 +1,4 @@
1
- import{createRequire as D}from"node:module";import E from"./EmailError-B-sEf3bp.js";import L from"./RequiredOptionError-DuNNY_a5.js";import{c as F}from"./create-logger-BQTS3f-I.js";import f from"../utils/format-email-address.js";import{s as G}from"./headers-to-record-De1Eg951.js";import{m as Q}from"./make-request-BlK_B72c.js";import{a as q,s as X}from"./sanitize-header-DtQwAnzg.js";import{f as Y}from"./validate-email-options-mCM9dVug.js";import{defineProvider as Z}from"./defineProvider-C9q-7iwt.js";const N=D(import.meta.url),A=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,V=y=>{if(typeof A<"u"&&A.versions&&A.versions.node){const[a,d]=A.versions.node.split(".").map(Number);if(a>22||a===22&&d>=3||a===20&&d>=16)return A.getBuiltinModule(y)}return N(y)},{randomUUID:v,createHash:R,createHmac:$}=V("node:crypto"),J=globalThis.Buffer!==void 0,I=()=>{if(!J)throw new Error("Buffer is required for AWS SES provider");return globalThis.Buffer},h="aws-ses",j={apiVersion:"2010-12-01",maxAttempts:3,region:"us-east-1"},ue=Z((y={})=>{const a={...j,...y},d=F("AWS-SES",y.logger),P=(e,i,t,s,o)=>{const u=Object.keys(t).toSorted().map(c=>{const l=t[c];return l===void 0?"":`${encodeURIComponent(c)}=${encodeURIComponent(l)}`}).filter(Boolean).join("&"),r=`${Object.keys(s).toSorted().map(c=>`${c.toLowerCase()}:${s[c]}`).join(`
1
+ import{createRequire as D}from"node:module";import E from"./EmailError-B-sEf3bp.js";import L from"./RequiredOptionError-DuNNY_a5.js";import{c as F}from"./create-logger-BQTS3f-I.js";import f from"../utils/format-email-address.js";import{s as G}from"./headers-to-record-De1Eg951.js";import{m as Q}from"./make-request-B9XjBynA.js";import{a as q,s as X}from"./sanitize-header-DtQwAnzg.js";import{f as Y}from"./validate-email-options-mCM9dVug.js";import{defineProvider as Z}from"./defineProvider-C9q-7iwt.js";const N=D(import.meta.url),A=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,V=y=>{if(typeof A<"u"&&A.versions&&A.versions.node){const[a,d]=A.versions.node.split(".").map(Number);if(a>22||a===22&&d>=3||a===20&&d>=16)return A.getBuiltinModule(y)}return N(y)},{randomUUID:v,createHash:R,createHmac:$}=V("node:crypto"),J=globalThis.Buffer!==void 0,I=()=>{if(!J)throw new Error("Buffer is required for AWS SES provider");return globalThis.Buffer},h="aws-ses",j={apiVersion:"2010-12-01",maxAttempts:3,region:"us-east-1"},ue=Z((y={})=>{const a={...j,...y},d=F("AWS-SES",y.logger),P=(e,i,t,s,o)=>{const u=Object.keys(t).toSorted().map(c=>{const l=t[c];return l===void 0?"":`${encodeURIComponent(c)}=${encodeURIComponent(l)}`}).filter(Boolean).join("&"),r=`${Object.keys(s).toSorted().map(c=>`${c.toLowerCase()}:${s[c]}`).join(`
2
2
  `)}
3
3
  `,n=Object.keys(s).toSorted().map(c=>c.toLowerCase()).join(";"),g=R("sha256").update(o).digest("hex");return[e,i,u,r,n,g].join(`
4
4
  `)},W=(e,i,t)=>{const s=e.slice(0,8),o=R("sha256").update(t).digest("hex");return["AWS4-HMAC-SHA256",e,`${s}/${i}/ses/aws4_request`,o].join(`
@@ -1 +1 @@
1
- import{createRequire as A}from"node:module";import l from"./EmailError-B-sEf3bp.js";import w from"./RequiredOptionError-DuNNY_a5.js";import{e as I}from"./generate-message-id-gXAuMz4g.js";import{s as P}from"./headers-to-record-De1Eg951.js";import{m as h}from"./make-request-BlK_B72c.js";import{u as v}from"./retry-3pnxTuNs.js";import{f as j}from"./validate-email-options-mCM9dVug.js";import{defineProvider as _}from"./defineProvider-C9q-7iwt.js";import{P as B,h as T,c as C}from"./provider-base-C7PuopYK.js";import{b as y,c as E}from"./address-formatter-BWR2Dddx.js";const z=A(import.meta.url),f=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,k=n=>{if(typeof f<"u"&&f.versions&&f.versions.node){const[u,t]=f.versions.node.split(".").map(Number);if(u>22||u===22&&t>=3||u===20&&t>=16)return f.getBuiltinModule(n)}return z(n)},{Buffer:p}=k("node:buffer"),i="azure",q=3e4,R=3,K=_((n={})=>{if(!n.region)throw new w(i,"region");if(!n.connectionString&&!n.accessToken)throw new w(i,"connectionString or accessToken");const u=n.endpoint??`https://${n.region}.communication.azure.com`,t={debug:n.debug??!1,endpoint:u,region:n.region,retries:n.retries??R,timeout:n.timeout??q,...n.connectionString&&{connectionString:n.connectionString},...n.accessToken&&{accessToken:n.accessToken},...n.logger&&{logger:n.logger}},g=new B,a=C(i,n.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!0,tracking:!1},async getEmail(e){try{if(!e)return{error:new l(i,"Email ID is required to retrieve email details"),success:!1};await g.ensureInitialized(()=>this.initialize(),i);const o={"Content-Type":"application/json"};if(t.accessToken)o.Authorization=`Bearer ${t.accessToken}`;else if(t.connectionString){const c=t.connectionString.match(/endpoint=([^;]+);accesskey=([^;]+)/);c&&(o.Authorization=`Bearer ${c[2]}`)}a.debug("Retrieving email details",{id:e});const r=await v(async()=>h(`${t.endpoint}/emails/${e}`,{headers:o,method:"GET",timeout:t.timeout}),t.retries);return r.success?(a.debug("Email details retrieved successfully"),{data:r.data?.body,success:!0}):(a.debug("API request failed when retrieving email",r.error),{error:new l(i,`Failed to retrieve email: ${r.error instanceof Error?r.error.message:"Unknown error"}`,{cause:r.error}),success:!1})}catch(o){return{error:T(i,"retrieve email",o,a),success:!1}}},async initialize(){await g.ensureInitialized(async()=>{if(!await this.isAvailable())throw new l(i,"Azure Communication Services API not available or invalid credentials");a.debug("Provider initialized successfully")},i)},async isAvailable(){try{const e={"Content-Type":"application/json"};if(t.accessToken)e.Authorization=`Bearer ${t.accessToken}`;else if(t.connectionString){const c=t.connectionString.match(/endpoint=([^;]+);accesskey=([^;]+)/);if(c)e.Authorization=`Bearer ${c[2]}`;else return!1}else return!1;a.debug("Checking Azure Communication Services API availability");const o=await h(`${t.endpoint}/emails:send`,{headers:e,method:"POST",timeout:t.timeout},JSON.stringify({}));if(o.success)return!0;const r=o.data?.statusCode;return r===401||r===403?!1:r===400}catch(e){if(a.debug("Error checking availability:",e),e instanceof Error){const o=e.message;if(o.includes("401")||o.includes("403"))return!1}return!1}},name:i,options:t,async sendEmail(e){try{const o=j(e);if(o.length>0)return{error:new l(i,`Invalid email options: ${o.join(", ")}`),success:!1};await g.ensureInitialized(()=>this.initialize(),i);const r={content:{subject:e.subject},recipients:{to:y(e.to)},senderAddress:e.from.email};if(e.html&&(r.content.html=e.html),e.text&&(r.content.plainText=e.text),e.cc&&(r.recipients.cc=y(e.cc)),e.bcc&&(r.recipients.bcc=y(e.bcc)),e.replyTo&&(r.replyTo=E(e.replyTo).email),e.importance&&(r.importance=e.importance),e.headers){const s=P(e.headers);r.headers=s}e.attachments&&e.attachments.length>0&&(r.attachments=await Promise.all(e.attachments.map(async s=>{let d;if(s.content)if(typeof s.content=="string")d=p.from(s.content,"utf8").toString("base64");else if(s.content&&typeof s.content.then=="function"){const S=await s.content;d=p.from(S).toString("base64")}else d=s.content.toString("base64");else if(s.raw)d=typeof s.raw=="string"?p.from(s.raw,"utf8").toString("base64"):s.raw.toString("base64");else throw new l(i,`Attachment ${s.filename} has no content`);return{contentInBase64:d,contentType:s.contentType??"application/octet-stream",name:s.filename}}))),a.debug("Sending email via Azure Communication Services API",{subject:r.content.subject,to:r.recipients.to});const c={"Content-Type":"application/json"};if(t.accessToken)c.Authorization=`Bearer ${t.accessToken}`;else if(t.connectionString){const s=t.connectionString.match(/endpoint=([^;]+);accesskey=([^;]+)/);if(s)c.Authorization=`Bearer ${s[2]}`;else return{error:new l(i,"Invalid connection string format"),success:!1}}const m=await v(async()=>h(`${t.endpoint}/emails:send`,{headers:c,method:"POST",timeout:t.timeout},JSON.stringify(r)),t.retries);if(!m.success)return a.debug("API request failed when sending email",m.error),{error:m.error??new l(i,"Failed to send email"),success:!1};const b=m.data?.body?.messageId??I();return a.debug("Email sent successfully",{messageId:b}),{data:{messageId:b,provider:i,response:m.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:T(i,"send email",o,a),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{K as default};
1
+ import{createRequire as A}from"node:module";import l from"./EmailError-B-sEf3bp.js";import w from"./RequiredOptionError-DuNNY_a5.js";import{e as I}from"./generate-message-id-gXAuMz4g.js";import{s as P}from"./headers-to-record-De1Eg951.js";import{m as h}from"./make-request-B9XjBynA.js";import{i as v}from"./retry-ipI5DRJ8.js";import{f as j}from"./validate-email-options-mCM9dVug.js";import{defineProvider as _}from"./defineProvider-C9q-7iwt.js";import{P as B,h as T,c as C}from"./provider-base-C7PuopYK.js";import{b as y,c as E}from"./address-formatter-BWR2Dddx.js";const z=A(import.meta.url),f=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,k=n=>{if(typeof f<"u"&&f.versions&&f.versions.node){const[u,t]=f.versions.node.split(".").map(Number);if(u>22||u===22&&t>=3||u===20&&t>=16)return f.getBuiltinModule(n)}return z(n)},{Buffer:p}=k("node:buffer"),i="azure",q=3e4,R=3,K=_((n={})=>{if(!n.region)throw new w(i,"region");if(!n.connectionString&&!n.accessToken)throw new w(i,"connectionString or accessToken");const u=n.endpoint??`https://${n.region}.communication.azure.com`,t={debug:n.debug??!1,endpoint:u,region:n.region,retries:n.retries??R,timeout:n.timeout??q,...n.connectionString&&{connectionString:n.connectionString},...n.accessToken&&{accessToken:n.accessToken},...n.logger&&{logger:n.logger}},g=new B,a=C(i,n.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!0,tracking:!1},async getEmail(e){try{if(!e)return{error:new l(i,"Email ID is required to retrieve email details"),success:!1};await g.ensureInitialized(()=>this.initialize(),i);const o={"Content-Type":"application/json"};if(t.accessToken)o.Authorization=`Bearer ${t.accessToken}`;else if(t.connectionString){const c=t.connectionString.match(/endpoint=([^;]+);accesskey=([^;]+)/);c&&(o.Authorization=`Bearer ${c[2]}`)}a.debug("Retrieving email details",{id:e});const r=await v(async()=>h(`${t.endpoint}/emails/${e}`,{headers:o,method:"GET",timeout:t.timeout}),t.retries);return r.success?(a.debug("Email details retrieved successfully"),{data:r.data?.body,success:!0}):(a.debug("API request failed when retrieving email",r.error),{error:new l(i,`Failed to retrieve email: ${r.error instanceof Error?r.error.message:"Unknown error"}`,{cause:r.error}),success:!1})}catch(o){return{error:T(i,"retrieve email",o,a),success:!1}}},async initialize(){await g.ensureInitialized(async()=>{if(!await this.isAvailable())throw new l(i,"Azure Communication Services API not available or invalid credentials");a.debug("Provider initialized successfully")},i)},async isAvailable(){try{const e={"Content-Type":"application/json"};if(t.accessToken)e.Authorization=`Bearer ${t.accessToken}`;else if(t.connectionString){const c=t.connectionString.match(/endpoint=([^;]+);accesskey=([^;]+)/);if(c)e.Authorization=`Bearer ${c[2]}`;else return!1}else return!1;a.debug("Checking Azure Communication Services API availability");const o=await h(`${t.endpoint}/emails:send`,{headers:e,method:"POST",timeout:t.timeout},JSON.stringify({}));if(o.success)return!0;const r=o.data?.statusCode;return r===401||r===403?!1:r===400}catch(e){if(a.debug("Error checking availability:",e),e instanceof Error){const o=e.message;if(o.includes("401")||o.includes("403"))return!1}return!1}},name:i,options:t,async sendEmail(e){try{const o=j(e);if(o.length>0)return{error:new l(i,`Invalid email options: ${o.join(", ")}`),success:!1};await g.ensureInitialized(()=>this.initialize(),i);const r={content:{subject:e.subject},recipients:{to:y(e.to)},senderAddress:e.from.email};if(e.html&&(r.content.html=e.html),e.text&&(r.content.plainText=e.text),e.cc&&(r.recipients.cc=y(e.cc)),e.bcc&&(r.recipients.bcc=y(e.bcc)),e.replyTo&&(r.replyTo=E(e.replyTo).email),e.importance&&(r.importance=e.importance),e.headers){const s=P(e.headers);r.headers=s}e.attachments&&e.attachments.length>0&&(r.attachments=await Promise.all(e.attachments.map(async s=>{let d;if(s.content)if(typeof s.content=="string")d=p.from(s.content,"utf8").toString("base64");else if(s.content&&typeof s.content.then=="function"){const S=await s.content;d=p.from(S).toString("base64")}else d=s.content.toString("base64");else if(s.raw)d=typeof s.raw=="string"?p.from(s.raw,"utf8").toString("base64"):s.raw.toString("base64");else throw new l(i,`Attachment ${s.filename} has no content`);return{contentInBase64:d,contentType:s.contentType??"application/octet-stream",name:s.filename}}))),a.debug("Sending email via Azure Communication Services API",{subject:r.content.subject,to:r.recipients.to});const c={"Content-Type":"application/json"};if(t.accessToken)c.Authorization=`Bearer ${t.accessToken}`;else if(t.connectionString){const s=t.connectionString.match(/endpoint=([^;]+);accesskey=([^;]+)/);if(s)c.Authorization=`Bearer ${s[2]}`;else return{error:new l(i,"Invalid connection string format"),success:!1}}const m=await v(async()=>h(`${t.endpoint}/emails:send`,{headers:c,method:"POST",timeout:t.timeout},JSON.stringify(r)),t.retries);if(!m.success)return a.debug("API request failed when sending email",m.error),{error:m.error??new l(i,"Failed to send email"),success:!1};const b=m.data?.body?.messageId??I();return a.debug("Email sent successfully",{messageId:b}),{data:{messageId:b,provider:i,response:m.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:T(i,"send email",o,a),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{K as default};
@@ -1 +1 @@
1
- import d from"./EmailError-B-sEf3bp.js";import T from"./RequiredOptionError-DuNNY_a5.js";import{e as A}from"./generate-message-id-gXAuMz4g.js";import{s as I}from"./headers-to-record-De1Eg951.js";import{m}from"./make-request-BlK_B72c.js";import{u as g}from"./retry-3pnxTuNs.js";import{f as P}from"./validate-email-options-mCM9dVug.js";import{defineProvider as C}from"./defineProvider-C9q-7iwt.js";import{P as k,h as b,c as E}from"./provider-base-C7PuopYK.js";import{f as p,a as y}from"./address-formatter-BWR2Dddx.js";import{p as j}from"./attachment-processor-CMp7qqMI.js";const r="brevo",S="https://api.brevo.com/v3",z=3e4,K=3,L=C((n={})=>{if(!n.apiKey)throw new T(r,"apiKey");const v=n.endpoint??S,s={apiKey:n.apiKey,debug:n.debug??!1,endpoint:v,hardValidation:n.hardValidation??!1,retries:n.retries??K,timeout:n.timeout??z,...n.logger&&{logger:n.logger}},u=new k,i=E(r,n.logger);return{endpoint:s.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 d(r,"Email ID is required to retrieve email details"),success:!1};await u.ensureInitialized(()=>this.initialize(),r);const t={"api-key":s.apiKey,"Content-Type":"application/json"};i.debug("Retrieving email details",{id:e});const l=await g(async()=>m(`${s.endpoint}/smtp/emails/${e}`,{headers:t,method:"GET",timeout:s.timeout}),s.retries);return l.success?(i.debug("Email details retrieved successfully"),{data:l.data?.body,success:!0}):(i.debug("API request failed when retrieving email",l.error),{error:new d(r,`Failed to retrieve email: ${l.error instanceof Error?l.error.message:"Unknown error"}`,{cause:l.error}),success:!1})}catch(t){return{error:b(r,"retrieve email",t,i),success:!1}}},async initialize(){await u.ensureInitialized(async()=>{if(!await this.isAvailable())throw new d(r,"Brevo API not available or invalid API key");i.debug("Provider initialized successfully")},r)},async isAvailable(){try{const e={"api-key":s.apiKey,"Content-Type":"application/json"};i.debug("Checking Brevo API availability");const t=await m(`${s.endpoint}/account`,{headers:e,method:"GET",timeout:s.timeout});return i.debug("Brevo 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 i.debug("Error checking availability:",e),!1}},name:r,options:s,async sendEmail(e){try{let t;Array.isArray(e.replyTo)?t=e.replyTo.length>0?e.replyTo[0]:void 0:t=e.replyTo;const l={...e,replyTo:t},f=P(l);if(f.length>0)return{error:new d(r,`Invalid email options: ${f.join(", ")}`),success:!1};await u.ensureInitialized(()=>this.initialize(),r);const a={sender:y(e.from),subject:e.subject,to:p(e.to)};if(e.html&&(a.htmlContent=e.html),e.text&&(a.textContent=e.text),e.cc&&(a.cc=p(e.cc)),e.bcc&&(a.bcc=p(e.bcc)),e.replyTo)if(Array.isArray(e.replyTo)){if(s.hardValidation)return{error:new d(r,"Only one replyTo address is allowed"),success:!1};if(e.replyTo.length===0)return{error:new d(r,"replyTo array cannot be empty"),success:!1};const o=e.replyTo[0];if(!o)return{error:new d(r,"replyTo array cannot be empty"),success:!1};a.replyTo=y(o)}else a.replyTo=y(e.replyTo);if(e.templateId&&(a.templateId=e.templateId,e.templateParams&&(a.params=e.templateParams)),e.tags&&e.tags.length>0&&(a.tags=e.tags),e.scheduledAt){const o=typeof e.scheduledAt=="number"?new Date(e.scheduledAt*1e3).toISOString():e.scheduledAt;a.scheduledAt=o}if(e.batchId&&(a.batchId=e.batchId),e.headers){const o=I(e.headers);a.headers=o}e.attachments&&e.attachments.length>0&&(a.attachment=await Promise.all(e.attachments.map(async o=>({content:await j(o,r),name:o.filename,...o.contentType&&{type:o.contentType}})))),i.debug("Sending email via Brevo API",{subject:a.subject,to:a.to});const w={"api-key":s.apiKey,"Content-Type":"application/json"},c=await g(async()=>m(`${s.endpoint}/smtp/email`,{headers:w,method:"POST",timeout:s.timeout},JSON.stringify(a)),s.retries);if(!c.success)return i.debug("API request failed when sending email",c.error),{error:c.error??new d(r,"Failed to send email"),success:!1};const h=c.data?.body?.messageId??A();return i.debug("Email sent successfully",{messageId:h}),{data:{messageId:h,provider:r,response:c.data,sent:!0,timestamp:new Date},success:!0}}catch(t){return{error:b(r,"send email",t,i),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{L as default};
1
+ import d from"./EmailError-B-sEf3bp.js";import T from"./RequiredOptionError-DuNNY_a5.js";import{e as A}from"./generate-message-id-gXAuMz4g.js";import{s as I}from"./headers-to-record-De1Eg951.js";import{m}from"./make-request-B9XjBynA.js";import{i as g}from"./retry-ipI5DRJ8.js";import{f as P}from"./validate-email-options-mCM9dVug.js";import{defineProvider as C}from"./defineProvider-C9q-7iwt.js";import{P as k,h as b,c as E}from"./provider-base-C7PuopYK.js";import{f as p,a as y}from"./address-formatter-BWR2Dddx.js";import{p as j}from"./attachment-processor-CMp7qqMI.js";const r="brevo",S="https://api.brevo.com/v3",z=3e4,K=3,L=C((n={})=>{if(!n.apiKey)throw new T(r,"apiKey");const v=n.endpoint??S,s={apiKey:n.apiKey,debug:n.debug??!1,endpoint:v,hardValidation:n.hardValidation??!1,retries:n.retries??K,timeout:n.timeout??z,...n.logger&&{logger:n.logger}},u=new k,i=E(r,n.logger);return{endpoint:s.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 d(r,"Email ID is required to retrieve email details"),success:!1};await u.ensureInitialized(()=>this.initialize(),r);const t={"api-key":s.apiKey,"Content-Type":"application/json"};i.debug("Retrieving email details",{id:e});const l=await g(async()=>m(`${s.endpoint}/smtp/emails/${e}`,{headers:t,method:"GET",timeout:s.timeout}),s.retries);return l.success?(i.debug("Email details retrieved successfully"),{data:l.data?.body,success:!0}):(i.debug("API request failed when retrieving email",l.error),{error:new d(r,`Failed to retrieve email: ${l.error instanceof Error?l.error.message:"Unknown error"}`,{cause:l.error}),success:!1})}catch(t){return{error:b(r,"retrieve email",t,i),success:!1}}},async initialize(){await u.ensureInitialized(async()=>{if(!await this.isAvailable())throw new d(r,"Brevo API not available or invalid API key");i.debug("Provider initialized successfully")},r)},async isAvailable(){try{const e={"api-key":s.apiKey,"Content-Type":"application/json"};i.debug("Checking Brevo API availability");const t=await m(`${s.endpoint}/account`,{headers:e,method:"GET",timeout:s.timeout});return i.debug("Brevo 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 i.debug("Error checking availability:",e),!1}},name:r,options:s,async sendEmail(e){try{let t;Array.isArray(e.replyTo)?t=e.replyTo.length>0?e.replyTo[0]:void 0:t=e.replyTo;const l={...e,replyTo:t},f=P(l);if(f.length>0)return{error:new d(r,`Invalid email options: ${f.join(", ")}`),success:!1};await u.ensureInitialized(()=>this.initialize(),r);const a={sender:y(e.from),subject:e.subject,to:p(e.to)};if(e.html&&(a.htmlContent=e.html),e.text&&(a.textContent=e.text),e.cc&&(a.cc=p(e.cc)),e.bcc&&(a.bcc=p(e.bcc)),e.replyTo)if(Array.isArray(e.replyTo)){if(s.hardValidation)return{error:new d(r,"Only one replyTo address is allowed"),success:!1};if(e.replyTo.length===0)return{error:new d(r,"replyTo array cannot be empty"),success:!1};const o=e.replyTo[0];if(!o)return{error:new d(r,"replyTo array cannot be empty"),success:!1};a.replyTo=y(o)}else a.replyTo=y(e.replyTo);if(e.templateId&&(a.templateId=e.templateId,e.templateParams&&(a.params=e.templateParams)),e.tags&&e.tags.length>0&&(a.tags=e.tags),e.scheduledAt){const o=typeof e.scheduledAt=="number"?new Date(e.scheduledAt*1e3).toISOString():e.scheduledAt;a.scheduledAt=o}if(e.batchId&&(a.batchId=e.batchId),e.headers){const o=I(e.headers);a.headers=o}e.attachments&&e.attachments.length>0&&(a.attachment=await Promise.all(e.attachments.map(async o=>({content:await j(o,r),name:o.filename,...o.contentType&&{type:o.contentType}})))),i.debug("Sending email via Brevo API",{subject:a.subject,to:a.to});const w={"api-key":s.apiKey,"Content-Type":"application/json"},c=await g(async()=>m(`${s.endpoint}/smtp/email`,{headers:w,method:"POST",timeout:s.timeout},JSON.stringify(a)),s.retries);if(!c.success)return i.debug("API request failed when sending email",c.error),{error:c.error??new d(r,"Failed to send email"),success:!1};const h=c.data?.body?.messageId??A();return i.debug("Email sent successfully",{messageId:h}),{data:{messageId:h,provider:r,response:c.data,sent:!0,timestamp:new Date},success:!0}}catch(t){return{error:b(r,"send email",t,i),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{L as default};
@@ -1 +1 @@
1
- import c from"./EmailError-B-sEf3bp.js";import g from"./RequiredOptionError-DuNNY_a5.js";import{e as w}from"./generate-message-id-gXAuMz4g.js";import{m as u}from"./make-request-BlK_B72c.js";import{f as A}from"./validate-email-options-mCM9dVug.js";import{defineProvider as j}from"./defineProvider-C9q-7iwt.js";const i="http",v="POST",f=3e4,S=j((o={})=>{if(!o.endpoint)throw new g(i,"endpoint");const a={apiKey:o.apiKey??"",endpoint:o.endpoint,headers:o.headers??{},method:o.method??v},d=()=>{const e={"Content-Type":"application/json",...a.headers};return a.apiKey&&(e.Authorization=`Bearer ${a.apiKey}`),e},p=e=>{const t={from:e.from.email,from_name:e.from.name,html:e.html,subject:e.subject,text:e.text,to:Array.isArray(e.to)?e.to.map(s=>s.email):e.to.email};return e.cc&&(t.cc=Array.isArray(e.cc)?e.cc.map(s=>s.email):e.cc.email),e.bcc&&(t.bcc=Array.isArray(e.bcc)?e.bcc.map(s=>s.email):e.bcc.email),e.customParams&&Object.assign(t,e.customParams),t};let m=!1;return{features:{attachments:!1,batchSending:!1,customHeaders:!0,html:!0,replyTo:!1,scheduling:!1,tagging:!1,templates:!1,tracking:!1},async initialize(){if(!m){if(!await this.isAvailable())throw new c(i,"API endpoint not available");m=!0}},async isAvailable(){try{return!!(await u(a.endpoint,{headers:d(),method:"OPTIONS",timeout:f})).success}catch(e){if(e instanceof Error){const t=e.message;if(t.includes("401")||t.includes("403"))return!1}return!1}},name:i,options:a,async sendEmail(e){try{const t=A(e);if(t.length>0)return{error:new c(i,`Invalid email options: ${t.join(", ")}`),success:!1};m||await this.initialize();const s=d();e.headers&&Object.assign(s,e.headers);const h=p(e),y=e.endpointOverride??a.endpoint,b=e.methodOverride??a.method,n=await u(y,{headers:s,method:b,timeout:f},JSON.stringify(h));if(!n.success)return{error:new c(i,`Failed to send email: ${n.error?.message||"Unknown error"}`,{cause:n.error}),success:!1};let l;const r=n.data?.body;return r&&typeof r=="object"&&(l=r.id??r.messageId??(r.data&&typeof r.data=="object"&&(r.data.id??r.data.messageId))),l??=w(),{data:{messageId:l,provider:i,response:n.data?.body,sent:!0,timestamp:new Date},success:!0}}catch(t){return{error:new c(i,`Failed to send email: ${t.message}`,{cause:t}),success:!1}}},async validateCredentials(){try{const e=await u(a.endpoint,{headers:d(),method:"GET",timeout:f});return!!(e.data&&typeof e.data=="object"&&"statusCode"in e.data&&typeof e.data.statusCode=="number"&&e.data.statusCode>=200&&e.data.statusCode<300)}catch{return!1}}}});export{S as default};
1
+ import c from"./EmailError-B-sEf3bp.js";import g from"./RequiredOptionError-DuNNY_a5.js";import{e as w}from"./generate-message-id-gXAuMz4g.js";import{m as u}from"./make-request-B9XjBynA.js";import{f as A}from"./validate-email-options-mCM9dVug.js";import{defineProvider as j}from"./defineProvider-C9q-7iwt.js";const i="http",v="POST",f=3e4,S=j((o={})=>{if(!o.endpoint)throw new g(i,"endpoint");const a={apiKey:o.apiKey??"",endpoint:o.endpoint,headers:o.headers??{},method:o.method??v},d=()=>{const e={"Content-Type":"application/json",...a.headers};return a.apiKey&&(e.Authorization=`Bearer ${a.apiKey}`),e},p=e=>{const t={from:e.from.email,from_name:e.from.name,html:e.html,subject:e.subject,text:e.text,to:Array.isArray(e.to)?e.to.map(s=>s.email):e.to.email};return e.cc&&(t.cc=Array.isArray(e.cc)?e.cc.map(s=>s.email):e.cc.email),e.bcc&&(t.bcc=Array.isArray(e.bcc)?e.bcc.map(s=>s.email):e.bcc.email),e.customParams&&Object.assign(t,e.customParams),t};let m=!1;return{features:{attachments:!1,batchSending:!1,customHeaders:!0,html:!0,replyTo:!1,scheduling:!1,tagging:!1,templates:!1,tracking:!1},async initialize(){if(!m){if(!await this.isAvailable())throw new c(i,"API endpoint not available");m=!0}},async isAvailable(){try{return!!(await u(a.endpoint,{headers:d(),method:"OPTIONS",timeout:f})).success}catch(e){if(e instanceof Error){const t=e.message;if(t.includes("401")||t.includes("403"))return!1}return!1}},name:i,options:a,async sendEmail(e){try{const t=A(e);if(t.length>0)return{error:new c(i,`Invalid email options: ${t.join(", ")}`),success:!1};m||await this.initialize();const s=d();e.headers&&Object.assign(s,e.headers);const h=p(e),y=e.endpointOverride??a.endpoint,b=e.methodOverride??a.method,n=await u(y,{headers:s,method:b,timeout:f},JSON.stringify(h));if(!n.success)return{error:new c(i,`Failed to send email: ${n.error?.message||"Unknown error"}`,{cause:n.error}),success:!1};let l;const r=n.data?.body;return r&&typeof r=="object"&&(l=r.id??r.messageId??(r.data&&typeof r.data=="object"&&(r.data.id??r.data.messageId))),l??=w(),{data:{messageId:l,provider:i,response:n.data?.body,sent:!0,timestamp:new Date},success:!0}}catch(t){return{error:new c(i,`Failed to send email: ${t.message}`,{cause:t}),success:!1}}},async validateCredentials(){try{const e=await u(a.endpoint,{headers:d(),method:"GET",timeout:f});return!!(e.data&&typeof e.data=="object"&&"statusCode"in e.data&&typeof e.data.statusCode=="number"&&e.data.statusCode>=200&&e.data.statusCode<300)}catch{return!1}}}});export{S as default};
@@ -1 +1 @@
1
- import c from"./EmailError-B-sEf3bp.js";import v from"./RequiredOptionError-DuNNY_a5.js";import{e as w}from"./generate-message-id-gXAuMz4g.js";import{s as A}from"./headers-to-record-De1Eg951.js";import{m as d}from"./make-request-BlK_B72c.js";import{u as g}from"./retry-3pnxTuNs.js";import{f as I}from"./validate-email-options-mCM9dVug.js";import{defineProvider as P}from"./defineProvider-C9q-7iwt.js";import{P as T,h as y,c as U}from"./provider-base-C7PuopYK.js";import{d as u}from"./address-formatter-BWR2Dddx.js";import{p as z}from"./attachment-processor-CMp7qqMI.js";const r="infobip",E="https://api.infobip.com",k=3e4,j=3,H=P((s={})=>{if(!s.apiKey)throw new v(r,"apiKey");const p=s.baseUrl??E,h=s.endpoint??`${p}/email/3/send`,a={apiKey:s.apiKey,baseUrl:p,debug:s.debug??!1,endpoint:h,retries:s.retries??j,timeout:s.timeout??k,...s.logger&&{logger:s.logger}},m=new T,i=U(r,s.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!0,tagging:!1,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new c(r,"Email ID is required to retrieve email details"),success:!1};await m.ensureInitialized(()=>this.initialize(),r);const n={Authorization:`App ${a.apiKey}`,"Content-Type":"application/json"};i.debug("Retrieving email details",{id:e});const t=await g(async()=>d(`${a.baseUrl}/email/3/reports/${e}`,{headers:n,method:"GET",timeout:a.timeout}),a.retries);return t.success?(i.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(i.debug("API request failed when retrieving email",t.error),{error:new c(r,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(n){return{error:y(r,"retrieve email",n,i),success:!1}}},async initialize(){await m.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(r,"Infobip API not available or invalid API key");i.debug("Provider initialized successfully")},r)},async isAvailable(){try{i.debug("Checking Infobip API availability");const e={Authorization:`App ${a.apiKey}`,"Content-Type":"application/json"};return(await d(`${a.baseUrl}/account/1/me`,{headers:e,method:"GET",timeout:a.timeout})).success}catch(e){return i.debug("Error checking availability:",e),!1}},name:r,options:a,async sendEmail(e){try{const n=I(e);if(n.length>0)return{error:new c(r,`Invalid email options: ${n.join(", ")}`),success:!1};await m.ensureInitialized(()=>this.initialize(),r);const t={from:typeof e.from=="string"?e.from:e.from.email,subject:e.subject,to:u(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=u(e.cc)),e.bcc&&(t.bcc=u(e.bcc)),e.replyTo&&(t.replyTo=typeof e.replyTo=="string"?e.replyTo:e.replyTo.email),e.templateId&&(t.templateId=e.templateId,e.templateVariables&&(t.templateData=e.templateVariables)),e.trackingUrl&&(t.trackingUrl=e.trackingUrl),e.notifyUrl&&(t.notifyUrl=e.notifyUrl),e.intermediateReport!==void 0&&(t.intermediateReport=e.intermediateReport),e.sendAt&&(t.sendAt=e.sendAt),e.headers){const l=A(e.headers);t.headers=l}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async l=>({content:await z(l,r),contentType:l.contentType??"application/octet-stream",name:l.filename})))),i.debug("Sending email via Infobip API",{subject:t.subject,to:t.to});const b={Authorization:`App ${a.apiKey}`,"Content-Type":"application/json"},o=await g(async()=>d(a.endpoint,{headers:b,method:"POST",timeout:a.timeout},JSON.stringify(t)),a.retries);if(!o.success)return i.debug("API request failed when sending email",o.error),{error:o.error??new c(r,"Failed to send email"),success:!1};const f=o.data?.body?.messages?.[0]?.messageId??w();return i.debug("Email sent successfully",{messageId:f}),{data:{messageId:f,provider:r,response:o.data,sent:!0,timestamp:new Date},success:!0}}catch(n){return{error:y(r,"send email",n,i),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{H as default};
1
+ import c from"./EmailError-B-sEf3bp.js";import v from"./RequiredOptionError-DuNNY_a5.js";import{e as w}from"./generate-message-id-gXAuMz4g.js";import{s as A}from"./headers-to-record-De1Eg951.js";import{m as d}from"./make-request-B9XjBynA.js";import{i as g}from"./retry-ipI5DRJ8.js";import{f as I}from"./validate-email-options-mCM9dVug.js";import{defineProvider as P}from"./defineProvider-C9q-7iwt.js";import{P as T,h as y,c as U}from"./provider-base-C7PuopYK.js";import{d as u}from"./address-formatter-BWR2Dddx.js";import{p as z}from"./attachment-processor-CMp7qqMI.js";const r="infobip",E="https://api.infobip.com",k=3e4,j=3,H=P((s={})=>{if(!s.apiKey)throw new v(r,"apiKey");const p=s.baseUrl??E,h=s.endpoint??`${p}/email/3/send`,a={apiKey:s.apiKey,baseUrl:p,debug:s.debug??!1,endpoint:h,retries:s.retries??j,timeout:s.timeout??k,...s.logger&&{logger:s.logger}},m=new T,i=U(r,s.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!0,tagging:!1,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new c(r,"Email ID is required to retrieve email details"),success:!1};await m.ensureInitialized(()=>this.initialize(),r);const n={Authorization:`App ${a.apiKey}`,"Content-Type":"application/json"};i.debug("Retrieving email details",{id:e});const t=await g(async()=>d(`${a.baseUrl}/email/3/reports/${e}`,{headers:n,method:"GET",timeout:a.timeout}),a.retries);return t.success?(i.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(i.debug("API request failed when retrieving email",t.error),{error:new c(r,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(n){return{error:y(r,"retrieve email",n,i),success:!1}}},async initialize(){await m.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(r,"Infobip API not available or invalid API key");i.debug("Provider initialized successfully")},r)},async isAvailable(){try{i.debug("Checking Infobip API availability");const e={Authorization:`App ${a.apiKey}`,"Content-Type":"application/json"};return(await d(`${a.baseUrl}/account/1/me`,{headers:e,method:"GET",timeout:a.timeout})).success}catch(e){return i.debug("Error checking availability:",e),!1}},name:r,options:a,async sendEmail(e){try{const n=I(e);if(n.length>0)return{error:new c(r,`Invalid email options: ${n.join(", ")}`),success:!1};await m.ensureInitialized(()=>this.initialize(),r);const t={from:typeof e.from=="string"?e.from:e.from.email,subject:e.subject,to:u(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=u(e.cc)),e.bcc&&(t.bcc=u(e.bcc)),e.replyTo&&(t.replyTo=typeof e.replyTo=="string"?e.replyTo:e.replyTo.email),e.templateId&&(t.templateId=e.templateId,e.templateVariables&&(t.templateData=e.templateVariables)),e.trackingUrl&&(t.trackingUrl=e.trackingUrl),e.notifyUrl&&(t.notifyUrl=e.notifyUrl),e.intermediateReport!==void 0&&(t.intermediateReport=e.intermediateReport),e.sendAt&&(t.sendAt=e.sendAt),e.headers){const l=A(e.headers);t.headers=l}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async l=>({content:await z(l,r),contentType:l.contentType??"application/octet-stream",name:l.filename})))),i.debug("Sending email via Infobip API",{subject:t.subject,to:t.to});const b={Authorization:`App ${a.apiKey}`,"Content-Type":"application/json"},o=await g(async()=>d(a.endpoint,{headers:b,method:"POST",timeout:a.timeout},JSON.stringify(t)),a.retries);if(!o.success)return i.debug("API request failed when sending email",o.error),{error:o.error??new c(r,"Failed to send email"),success:!1};const f=o.data?.body?.messages?.[0]?.messageId??w();return i.debug("Email sent successfully",{messageId:f}),{data:{messageId:f,provider:r,response:o.data,sent:!0,timestamp:new Date},success:!0}}catch(n){return{error:y(r,"send email",n,i),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{H as default};
@@ -1 +1 @@
1
- import o from"./EmailError-B-sEf3bp.js";import f from"./RequiredOptionError-DuNNY_a5.js";import{e as g}from"./generate-message-id-gXAuMz4g.js";import{m as h}from"./make-request-BlK_B72c.js";import{u as y}from"./retry-3pnxTuNs.js";import{defineProvider as b}from"./defineProvider-C9q-7iwt.js";import{c as v}from"./attachment-processor-CMp7qqMI.js";import{h as w,P as T,c as A}from"./provider-base-C7PuopYK.js";const t="loops",I="https://app.loops.so/api/v1/transactional",P=3e4,K=3,E=b((a={})=>{if(!a.apiKey)throw new f(t,"apiKey");const r={apiKey:a.apiKey,debug:a.debug??!1,defaultTransactionalId:a.defaultTransactionalId,endpoint:a.endpoint??I,logger:a.logger,retries:a.retries??K,timeout:a.timeout??P},m=new T,u=A(t,a.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!1,html:!1,replyTo:!1,scheduling:!1,tagging:!1,templates:!0,tracking:!0},async initialize(){m.setInitialized()},async isAvailable(){return r.apiKey.length>0},name:t,options:r,async sendEmail(e){try{const s=e.transactionalId??r.defaultTransactionalId;if(!s)return{error:new o(t,"Loops requires a `transactionalId` (on the message or as `defaultTransactionalId`)"),success:!1};const l=Array.isArray(e.to)?e.to:[e.to];if(l.length!==1||e.cc!==void 0||e.bcc!==void 0)return{error:new o(t,"Loops supports exactly one `to` recipient and does not support cc/bcc"),success:!1};const[d]=l;if(!d)return{error:new o(t,"A `to` recipient is required"),success:!1};const n={email:d.email,transactionalId:s};e.dataVariables&&(n.dataVariables=e.dataVariables),e.addToAudience&&(n.addToAudience=!0),e.attachments&&e.attachments.length>0&&(n.attachments=await Promise.all(e.attachments.map(async p=>{const c=await v(p,t);return{contentType:c.contentType,data:c.content,filename:c.filename}})));const i=await y(async()=>h(r.endpoint,{headers:{Authorization:`Bearer ${r.apiKey}`,"Content-Type":"application/json"},method:"POST",timeout:r.timeout},JSON.stringify(n)),r.retries);return i.success?{data:{messageId:g(),provider:t,response:i.data,sent:!0,timestamp:new Date},success:!0}:{error:i.error??new o(t,"Failed to send email"),success:!1}}catch(s){return{error:w(t,"send email",s,u),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{E as default};
1
+ import o from"./EmailError-B-sEf3bp.js";import f from"./RequiredOptionError-DuNNY_a5.js";import{e as g}from"./generate-message-id-gXAuMz4g.js";import{m as h}from"./make-request-B9XjBynA.js";import{i as y}from"./retry-ipI5DRJ8.js";import{defineProvider as b}from"./defineProvider-C9q-7iwt.js";import{c as v}from"./attachment-processor-CMp7qqMI.js";import{h as w,P as T,c as A}from"./provider-base-C7PuopYK.js";const t="loops",I="https://app.loops.so/api/v1/transactional",P=3e4,K=3,E=b((a={})=>{if(!a.apiKey)throw new f(t,"apiKey");const r={apiKey:a.apiKey,debug:a.debug??!1,defaultTransactionalId:a.defaultTransactionalId,endpoint:a.endpoint??I,logger:a.logger,retries:a.retries??K,timeout:a.timeout??P},m=new T,p=A(t,a.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!1,html:!1,replyTo:!1,scheduling:!1,tagging:!1,templates:!0,tracking:!0},async initialize(){m.setInitialized()},async isAvailable(){return r.apiKey.length>0},name:t,options:r,async sendEmail(e){try{const s=e.transactionalId??r.defaultTransactionalId;if(!s)return{error:new o(t,"Loops requires a `transactionalId` (on the message or as `defaultTransactionalId`)"),success:!1};const l=Array.isArray(e.to)?e.to:[e.to];if(l.length!==1||e.cc!==void 0||e.bcc!==void 0)return{error:new o(t,"Loops supports exactly one `to` recipient and does not support cc/bcc"),success:!1};const[d]=l;if(!d)return{error:new o(t,"A `to` recipient is required"),success:!1};const n={email:d.email,transactionalId:s};e.dataVariables&&(n.dataVariables=e.dataVariables),e.addToAudience&&(n.addToAudience=!0),e.attachments&&e.attachments.length>0&&(n.attachments=await Promise.all(e.attachments.map(async u=>{const c=await v(u,t);return{contentType:c.contentType,data:c.content,filename:c.filename}})));const i=await y(async()=>h(r.endpoint,{headers:{Authorization:`Bearer ${r.apiKey}`,"Content-Type":"application/json"},method:"POST",timeout:r.timeout},JSON.stringify(n)),r.retries);return i.success?{data:{messageId:g(),provider:t,response:i.data,sent:!0,timestamp:new Date},success:!0}:{error:i.error??new o(t,"Failed to send email"),success:!1}}catch(s){return{error:w(t,"send email",s,p),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{E as default};
@@ -1 +1 @@
1
- import c from"./EmailError-B-sEf3bp.js";import P from"./RequiredOptionError-DuNNY_a5.js";import{e as I}from"./generate-message-id-gXAuMz4g.js";import{s as T}from"./headers-to-record-De1Eg951.js";import{m as d}from"./make-request-BlK_B72c.js";import{u as g}from"./retry-3pnxTuNs.js";import{s as A,a as k}from"./sanitize-header-DtQwAnzg.js";import{f as z}from"./validate-email-options-mCM9dVug.js";import{defineProvider as j}from"./defineProvider-C9q-7iwt.js";import{P as E,h as f,c as C}from"./provider-base-C7PuopYK.js";import{j as u,g as h}from"./address-formatter-BWR2Dddx.js";const r="mailpace",M="https://app.mailpace.com/api/v1",S=3e4,q=3,R=j((o={})=>{if(!o.apiToken)throw new P(r,"apiToken");const s={apiToken:o.apiToken,debug:o.debug??!1,endpoint:o.endpoint??M,retries:o.retries??q,timeout:o.timeout??S,...o.logger&&{logger:o.logger}},l=new E,i=C(r,o.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!1},async getEmail(e){try{if(!e)return{error:new c(r,"Email ID is required to retrieve email details"),success:!1};await l.ensureInitialized(()=>this.initialize(),r);const a={Authorization:`Bearer ${s.apiToken}`,"Content-Type":"application/json"};i.debug("Retrieving email details",{id:e});const t=await g(async()=>d(`${s.endpoint}/emails/${e}`,{headers:a,method:"GET",timeout:s.timeout}),s.retries);return t.success?(i.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(i.debug("API request failed when retrieving email",t.error),{error:new c(r,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(a){return{error:f(r,"retrieve email",a,i),success:!1}}},async initialize(){await l.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(r,"MailPace API not available or invalid API token");i.debug("Provider initialized successfully")},r)},async isAvailable(){try{const e={Authorization:`Bearer ${s.apiToken}`,"Content-Type":"application/json"};i.debug("Checking MailPace API availability");const a=await d(`${s.endpoint}/account`,{headers:e,method:"GET",timeout:s.timeout});return i.debug("MailPace API availability check response:",{error:a.error instanceof Error?a.error.message:void 0,statusCode:a.data?.statusCode,success:a.success}),!!(a.success&&a.data&&typeof a.data=="object"&&"statusCode"in a.data&&typeof a.data.statusCode=="number"&&a.data.statusCode>=200&&a.data.statusCode<300)}catch(e){return i.debug("Error checking availability:",e),!1}},name:r,options:s,async sendEmail(e){try{const a=z(e);if(a.length>0)return{error:new c(r,`Invalid email options: ${a.join(", ")}`),success:!1};await l.ensureInitialized(()=>this.initialize(),r);const t={from:h(e.from),subject:e.subject,to:u(e.to)};if(e.html&&(t.htmlbody=e.html),e.text&&(t.textbody=e.text),e.cc&&(t.cc=u(e.cc)),e.bcc&&(t.bcc=u(e.bcc)),e.replyTo&&(t.replyto=h(e.replyTo)),e.templateId&&(t.template_id=e.templateId,e.templateVariables&&(t.template_variables=e.templateVariables)),e.tags&&e.tags.length>0&&(t.tags=e.tags),e.listUnsubscribe&&(t.list_unsubscribe=e.listUnsubscribe),e.headers){const y=T(e.headers),p={};Object.entries(y).forEach(([v,w])=>{p[A(v)]=k(w)}),t.headers=p}e.attachments&&e.attachments.length>0&&(t.attachments=e.attachments),i.debug("Sending email via MailPace API",{subject:t.subject,to:t.to});const b={Authorization:`Bearer ${s.apiToken}`,"Content-Type":"application/json"},n=await g(async()=>d(`${s.endpoint}/send`,{headers:b,method:"POST",timeout:s.timeout},JSON.stringify(t)),s.retries);if(!n.success)return i.debug("API request failed when sending email",n.error),{error:n.error??new c(r,"Failed to send email"),success:!1};const m=n.data?.body?.id??I();return i.debug("Email sent successfully",{messageId:m}),{data:{messageId:m,provider:r,response:n.data,sent:!0,timestamp:new Date},success:!0}}catch(a){return{error:f(r,"send email",a,i),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{R as default};
1
+ import c from"./EmailError-B-sEf3bp.js";import P from"./RequiredOptionError-DuNNY_a5.js";import{e as I}from"./generate-message-id-gXAuMz4g.js";import{s as T}from"./headers-to-record-De1Eg951.js";import{m as d}from"./make-request-B9XjBynA.js";import{i as g}from"./retry-ipI5DRJ8.js";import{s as A,a as k}from"./sanitize-header-DtQwAnzg.js";import{f as z}from"./validate-email-options-mCM9dVug.js";import{defineProvider as j}from"./defineProvider-C9q-7iwt.js";import{P as E,h as f,c as C}from"./provider-base-C7PuopYK.js";import{j as u,g as h}from"./address-formatter-BWR2Dddx.js";const r="mailpace",M="https://app.mailpace.com/api/v1",S=3e4,q=3,R=j((o={})=>{if(!o.apiToken)throw new P(r,"apiToken");const s={apiToken:o.apiToken,debug:o.debug??!1,endpoint:o.endpoint??M,retries:o.retries??q,timeout:o.timeout??S,...o.logger&&{logger:o.logger}},l=new E,i=C(r,o.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!1},async getEmail(e){try{if(!e)return{error:new c(r,"Email ID is required to retrieve email details"),success:!1};await l.ensureInitialized(()=>this.initialize(),r);const a={Authorization:`Bearer ${s.apiToken}`,"Content-Type":"application/json"};i.debug("Retrieving email details",{id:e});const t=await g(async()=>d(`${s.endpoint}/emails/${e}`,{headers:a,method:"GET",timeout:s.timeout}),s.retries);return t.success?(i.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(i.debug("API request failed when retrieving email",t.error),{error:new c(r,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(a){return{error:f(r,"retrieve email",a,i),success:!1}}},async initialize(){await l.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(r,"MailPace API not available or invalid API token");i.debug("Provider initialized successfully")},r)},async isAvailable(){try{const e={Authorization:`Bearer ${s.apiToken}`,"Content-Type":"application/json"};i.debug("Checking MailPace API availability");const a=await d(`${s.endpoint}/account`,{headers:e,method:"GET",timeout:s.timeout});return i.debug("MailPace API availability check response:",{error:a.error instanceof Error?a.error.message:void 0,statusCode:a.data?.statusCode,success:a.success}),!!(a.success&&a.data&&typeof a.data=="object"&&"statusCode"in a.data&&typeof a.data.statusCode=="number"&&a.data.statusCode>=200&&a.data.statusCode<300)}catch(e){return i.debug("Error checking availability:",e),!1}},name:r,options:s,async sendEmail(e){try{const a=z(e);if(a.length>0)return{error:new c(r,`Invalid email options: ${a.join(", ")}`),success:!1};await l.ensureInitialized(()=>this.initialize(),r);const t={from:h(e.from),subject:e.subject,to:u(e.to)};if(e.html&&(t.htmlbody=e.html),e.text&&(t.textbody=e.text),e.cc&&(t.cc=u(e.cc)),e.bcc&&(t.bcc=u(e.bcc)),e.replyTo&&(t.replyto=h(e.replyTo)),e.templateId&&(t.template_id=e.templateId,e.templateVariables&&(t.template_variables=e.templateVariables)),e.tags&&e.tags.length>0&&(t.tags=e.tags),e.listUnsubscribe&&(t.list_unsubscribe=e.listUnsubscribe),e.headers){const y=T(e.headers),p={};Object.entries(y).forEach(([v,w])=>{p[A(v)]=k(w)}),t.headers=p}e.attachments&&e.attachments.length>0&&(t.attachments=e.attachments),i.debug("Sending email via MailPace API",{subject:t.subject,to:t.to});const b={Authorization:`Bearer ${s.apiToken}`,"Content-Type":"application/json"},n=await g(async()=>d(`${s.endpoint}/send`,{headers:b,method:"POST",timeout:s.timeout},JSON.stringify(t)),s.retries);if(!n.success)return i.debug("API request failed when sending email",n.error),{error:n.error??new c(r,"Failed to send email"),success:!1};const m=n.data?.body?.id??I();return i.debug("Email sent successfully",{messageId:m}),{data:{messageId:m,provider:r,response:n.data,sent:!0,timestamp:new Date},success:!0}}catch(a){return{error:f(r,"send email",a,i),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{R as default};
@@ -1 +1 @@
1
- import p from"./EmailError-B-sEf3bp.js";import g from"./RequiredOptionError-DuNNY_a5.js";import{e as v}from"./generate-message-id-gXAuMz4g.js";import{s as b}from"./headers-to-record-De1Eg951.js";import{m as w}from"./make-request-BlK_B72c.js";import{u as K}from"./retry-3pnxTuNs.js";import{f as S}from"./validate-email-options-mCM9dVug.js";import{defineProvider as P}from"./defineProvider-C9q-7iwt.js";import{f as l,a as u}from"./address-formatter-BWR2Dddx.js";import{c as x}from"./attachment-processor-CMp7qqMI.js";import{h as A,P as T,c as j}from"./provider-base-C7PuopYK.js";const a="mailchannels",I="https://api.mailchannels.net/tx/v1/send",_=3e4,z=3,N=P((t={})=>{if(!t.apiKey)throw new g(a,"apiKey");const r={apiKey:t.apiKey,debug:t.debug??!1,endpoint:t.endpoint??I,logger:t.logger,retries:t.retries??z,timeout:t.timeout??_},f=new T,h=j(a,t.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!1,tracking:!1},async initialize(){f.setInitialized()},async isAvailable(){return r.apiKey.length>0},name:a,options:r,async sendEmail(e){try{const s=S(e);if(s.length>0)return{error:new p(a,`Invalid email options: ${s.join(", ")}`),success:!1};const o=[];e.text&&o.push({type:"text/plain",value:e.text}),e.html&&o.push({type:"text/html",value:e.html});const c={to:l(e.to)};e.cc&&(c.cc=l(e.cc)),e.bcc&&(c.bcc=l(e.bcc));const n={content:o,from:u(e.from),personalizations:[c],subject:e.subject};e.replyTo&&(n.reply_to=u(e.replyTo)),e.headers&&(n.headers=b(e.headers)),e.attachments&&e.attachments.length>0&&(n.attachments=await Promise.all(e.attachments.map(async y=>{const m=await x(y,a);return{content:m.content,filename:m.filename,type:m.contentType}})));const i=await K(async()=>w(r.endpoint,{headers:{"Content-Type":"application/json","X-Api-Key":r.apiKey},method:"POST",timeout:r.timeout},JSON.stringify(n)),r.retries);if(!i.success)return{error:i.error??new p(a,"Failed to send email"),success:!1};const{body:d}=i.data;return{data:{messageId:d?.message_id??d?.request_id??v(),provider:a,response:i.data,sent:!0,timestamp:new Date},success:!0}}catch(s){return{error:A(a,"send email",s,h),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{N as default};
1
+ import p from"./EmailError-B-sEf3bp.js";import g from"./RequiredOptionError-DuNNY_a5.js";import{e as v}from"./generate-message-id-gXAuMz4g.js";import{s as b}from"./headers-to-record-De1Eg951.js";import{m as w}from"./make-request-B9XjBynA.js";import{i as K}from"./retry-ipI5DRJ8.js";import{f as S}from"./validate-email-options-mCM9dVug.js";import{defineProvider as P}from"./defineProvider-C9q-7iwt.js";import{f as l,a as u}from"./address-formatter-BWR2Dddx.js";import{c as x}from"./attachment-processor-CMp7qqMI.js";import{h as A,P as T,c as j}from"./provider-base-C7PuopYK.js";const a="mailchannels",I="https://api.mailchannels.net/tx/v1/send",_=3e4,z=3,N=P((t={})=>{if(!t.apiKey)throw new g(a,"apiKey");const r={apiKey:t.apiKey,debug:t.debug??!1,endpoint:t.endpoint??I,logger:t.logger,retries:t.retries??z,timeout:t.timeout??_},f=new T,h=j(a,t.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!1,tracking:!1},async initialize(){f.setInitialized()},async isAvailable(){return r.apiKey.length>0},name:a,options:r,async sendEmail(e){try{const s=S(e);if(s.length>0)return{error:new p(a,`Invalid email options: ${s.join(", ")}`),success:!1};const o=[];e.text&&o.push({type:"text/plain",value:e.text}),e.html&&o.push({type:"text/html",value:e.html});const c={to:l(e.to)};e.cc&&(c.cc=l(e.cc)),e.bcc&&(c.bcc=l(e.bcc));const n={content:o,from:u(e.from),personalizations:[c],subject:e.subject};e.replyTo&&(n.reply_to=u(e.replyTo)),e.headers&&(n.headers=b(e.headers)),e.attachments&&e.attachments.length>0&&(n.attachments=await Promise.all(e.attachments.map(async y=>{const m=await x(y,a);return{content:m.content,filename:m.filename,type:m.contentType}})));const i=await K(async()=>w(r.endpoint,{headers:{"Content-Type":"application/json","X-Api-Key":r.apiKey},method:"POST",timeout:r.timeout},JSON.stringify(n)),r.retries);if(!i.success)return{error:i.error??new p(a,"Failed to send email"),success:!1};const{body:d}=i.data;return{data:{messageId:d?.message_id??d?.request_id??v(),provider:a,response:i.data,sent:!0,timestamp:new Date},success:!0}}catch(s){return{error:A(a,"send email",s,h),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{N as default};
@@ -1 +1 @@
1
- import l from"./EmailError-B-sEf3bp.js";import y from"./RequiredOptionError-DuNNY_a5.js";import{e as b}from"./generate-message-id-gXAuMz4g.js";import{s as v}from"./headers-to-record-De1Eg951.js";import{m}from"./make-request-BlK_B72c.js";import{u as g}from"./retry-3pnxTuNs.js";import{f as w}from"./validate-email-options-mCM9dVug.js";import{defineProvider as I}from"./defineProvider-C9q-7iwt.js";import{P as A,h as f,c as T}from"./provider-base-C7PuopYK.js";import{f as u,a as k}from"./address-formatter-BWR2Dddx.js";import{p as P}from"./attachment-processor-CMp7qqMI.js";const r="mailersend",z="https://api.mailersend.com",C=3e4,S=3,O=I((n={})=>{if(!n.apiToken)throw new y(r,"apiToken");const i={apiToken:n.apiToken,debug:n.debug??!1,endpoint:n.endpoint??z,retries:n.retries??S,timeout:n.timeout??C,...n.logger&&{logger:n.logger}},c=new A,s=T(r,n.logger);return{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 l(r,"Email ID is required to retrieve email details"),success:!1};await c.ensureInitialized(()=>this.initialize(),r);const a={Authorization:`Bearer ${i.apiToken}`,"Content-Type":"application/json"};s.debug("Retrieving email details",{id:e});const t=await g(async()=>m(`${i.endpoint}/v1/activity/${e}`,{headers:a,method:"GET",timeout:i.timeout}),i.retries);return t.success?(s.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(s.debug("API request failed when retrieving email",t.error),{error:new l(r,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(a){return{error:f(r,"retrieve email",a,s),success:!1}}},async initialize(){await c.ensureInitialized(async()=>{if(!await this.isAvailable())throw new l(r,"MailerSend API not available or invalid API token");s.debug("Provider initialized successfully")},r)},async isAvailable(){try{const e={Authorization:`Bearer ${i.apiToken}`,"Content-Type":"application/json"};s.debug("Checking MailerSend API availability");const a=await m(`${i.endpoint}/v1/tokens/verify`,{headers:e,method:"GET",timeout:i.timeout});return s.debug("MailerSend API availability check response:",{error:a.error instanceof Error?a.error.message:void 0,statusCode:a.data?.statusCode,success:a.success}),!!(a.success&&a.data&&typeof a.data=="object"&&"statusCode"in a.data&&typeof a.data.statusCode=="number"&&a.data.statusCode>=200&&a.data.statusCode<300)}catch(e){return s.debug("Error checking availability:",e),!1}},name:r,options:i,async sendEmail(e){try{const a=w(e);if(a.length>0)return{error:new l(r,`Invalid email options: ${a.join(", ")}`),success:!1};await c.ensureInitialized(()=>this.initialize(),r);const t={from:{email:e.from.email,name:e.from.name},subject:e.subject,to:u(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=u(e.cc)),e.bcc&&(t.bcc=u(e.bcc)),e.replyTo&&(t.reply_to=k(e.replyTo)),e.templateId&&(t.template_id=e.templateId,e.templateVariables&&(t.variables=e.templateVariables)),e.personalization&&e.personalization.length>0&&(t.personalization=e.personalization),e.tags&&e.tags.length>0&&(t.tags=e.tags),e.scheduledAt&&(t.send_at=e.scheduledAt),e.domainId&&(t.domain_id=e.domainId),e.headers){const o=v(e.headers);t.headers=o}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async o=>({content:await P(o,r),filename:o.filename,...o.contentType&&{type:o.contentType},...o.cid&&{id:o.cid}})))),s.debug("Sending email via MailerSend API",{subject:t.subject,to:t.to});const h={Authorization:`Bearer ${i.apiToken}`,"Content-Type":"application/json"},d=await g(async()=>m(`${i.endpoint}/v1/email`,{headers:h,method:"POST",timeout:i.timeout},JSON.stringify(t)),i.retries);if(!d.success)return s.debug("API request failed when sending email",d.error),{error:d.error??new l(r,"Failed to send email"),success:!1};const p=d.data?.body?.message_id??b();return s.debug("Email sent successfully",{messageId:p}),{data:{messageId:p,provider:r,response:d.data,sent:!0,timestamp:new Date},success:!0}}catch(a){return{error:f(r,"send email",a,s),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{O as default};
1
+ import l from"./EmailError-B-sEf3bp.js";import y from"./RequiredOptionError-DuNNY_a5.js";import{e as b}from"./generate-message-id-gXAuMz4g.js";import{s as v}from"./headers-to-record-De1Eg951.js";import{m}from"./make-request-B9XjBynA.js";import{i as g}from"./retry-ipI5DRJ8.js";import{f as w}from"./validate-email-options-mCM9dVug.js";import{defineProvider as I}from"./defineProvider-C9q-7iwt.js";import{P as A,h as f,c as T}from"./provider-base-C7PuopYK.js";import{f as u,a as k}from"./address-formatter-BWR2Dddx.js";import{p as P}from"./attachment-processor-CMp7qqMI.js";const r="mailersend",z="https://api.mailersend.com",C=3e4,S=3,O=I((n={})=>{if(!n.apiToken)throw new y(r,"apiToken");const i={apiToken:n.apiToken,debug:n.debug??!1,endpoint:n.endpoint??z,retries:n.retries??S,timeout:n.timeout??C,...n.logger&&{logger:n.logger}},c=new A,s=T(r,n.logger);return{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 l(r,"Email ID is required to retrieve email details"),success:!1};await c.ensureInitialized(()=>this.initialize(),r);const a={Authorization:`Bearer ${i.apiToken}`,"Content-Type":"application/json"};s.debug("Retrieving email details",{id:e});const t=await g(async()=>m(`${i.endpoint}/v1/activity/${e}`,{headers:a,method:"GET",timeout:i.timeout}),i.retries);return t.success?(s.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(s.debug("API request failed when retrieving email",t.error),{error:new l(r,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(a){return{error:f(r,"retrieve email",a,s),success:!1}}},async initialize(){await c.ensureInitialized(async()=>{if(!await this.isAvailable())throw new l(r,"MailerSend API not available or invalid API token");s.debug("Provider initialized successfully")},r)},async isAvailable(){try{const e={Authorization:`Bearer ${i.apiToken}`,"Content-Type":"application/json"};s.debug("Checking MailerSend API availability");const a=await m(`${i.endpoint}/v1/tokens/verify`,{headers:e,method:"GET",timeout:i.timeout});return s.debug("MailerSend API availability check response:",{error:a.error instanceof Error?a.error.message:void 0,statusCode:a.data?.statusCode,success:a.success}),!!(a.success&&a.data&&typeof a.data=="object"&&"statusCode"in a.data&&typeof a.data.statusCode=="number"&&a.data.statusCode>=200&&a.data.statusCode<300)}catch(e){return s.debug("Error checking availability:",e),!1}},name:r,options:i,async sendEmail(e){try{const a=w(e);if(a.length>0)return{error:new l(r,`Invalid email options: ${a.join(", ")}`),success:!1};await c.ensureInitialized(()=>this.initialize(),r);const t={from:{email:e.from.email,name:e.from.name},subject:e.subject,to:u(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=u(e.cc)),e.bcc&&(t.bcc=u(e.bcc)),e.replyTo&&(t.reply_to=k(e.replyTo)),e.templateId&&(t.template_id=e.templateId,e.templateVariables&&(t.variables=e.templateVariables)),e.personalization&&e.personalization.length>0&&(t.personalization=e.personalization),e.tags&&e.tags.length>0&&(t.tags=e.tags),e.scheduledAt&&(t.send_at=e.scheduledAt),e.domainId&&(t.domain_id=e.domainId),e.headers){const o=v(e.headers);t.headers=o}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async o=>({content:await P(o,r),filename:o.filename,...o.contentType&&{type:o.contentType},...o.cid&&{id:o.cid}})))),s.debug("Sending email via MailerSend API",{subject:t.subject,to:t.to});const h={Authorization:`Bearer ${i.apiToken}`,"Content-Type":"application/json"},d=await g(async()=>m(`${i.endpoint}/v1/email`,{headers:h,method:"POST",timeout:i.timeout},JSON.stringify(t)),i.retries);if(!d.success)return s.debug("API request failed when sending email",d.error),{error:d.error??new l(r,"Failed to send email"),success:!1};const p=d.data?.body?.message_id??b();return s.debug("Email sent successfully",{messageId:p}),{data:{messageId:p,provider:r,response:d.data,sent:!0,timestamp:new Date},success:!0}}catch(a){return{error:f(r,"send email",a,s),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{O as default};
@@ -1 +1 @@
1
- import{createRequire as j}from"node:module";import m from"./EmailError-B-sEf3bp.js";import w from"./RequiredOptionError-DuNNY_a5.js";import{e as P}from"./generate-message-id-gXAuMz4g.js";import{s as R}from"./headers-to-record-De1Eg951.js";import{m as h}from"./make-request-BlK_B72c.js";import{u as T}from"./retry-3pnxTuNs.js";import{f as S}from"./validate-email-options-mCM9dVug.js";import{defineProvider as _}from"./defineProvider-C9q-7iwt.js";import{P as z,h as k,c as E}from"./provider-base-C7PuopYK.js";import{e as b,g as I}from"./address-formatter-BWR2Dddx.js";import{a as U}from"./attachment-processor-CMp7qqMI.js";const A=j(import.meta.url),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,C=s=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[r,n]=u.versions.node.split(".").map(Number);if(r>22||r===22&&n>=3||r===20&&n>=16)return u.getBuiltinModule(s)}return A(s)},{Buffer:y}=C("node:buffer"),a="mailgun",q="https://api.mailgun.net",M=3e4,K=3,B=s=>{const r=[];for(const[n,i]of Object.entries(s))if(i!=null)if(Array.isArray(i))for(const e of i)r.push(`${encodeURIComponent(n)}=${encodeURIComponent(String(e))}`);else typeof i=="object"?r.push(`${encodeURIComponent(n)}=${encodeURIComponent(JSON.stringify(i))}`):r.push(`${encodeURIComponent(n)}=${encodeURIComponent(String(i))}`);return r.join("&")},X=_((s={})=>{if(!s.apiKey)throw new w(a,"apiKey");if(!s.domain)throw new w(a,"domain");const r={apiKey:s.apiKey,debug:s.debug??!1,domain:s.domain,endpoint:s.endpoint??q,retries:s.retries??K,timeout:s.timeout??M,...s.logger&&{logger:s.logger}},n=new z,i=E(a,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 m(a,"Email ID is required to retrieve email details"),success:!1};await n.ensureInitialized(()=>this.initialize(),a);const o={Authorization:`Basic ${y.from(`api:${r.apiKey}`).toString("base64")}`,"Content-Type":"application/json"};i.debug("Retrieving email details",{id:e});const t=await T(async()=>h(`${r.endpoint}/v3/${r.domain}/events?message-id=${encodeURIComponent(e)}&limit=1`,{headers:o,method:"GET",timeout:r.timeout}),r.retries);if(!t.success)return i.debug("API request failed when retrieving email",t.error),{error:new m(a,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1};i.debug("Email details retrieved successfully");const p=t.data?.items??[],g=p.length>0?p[0]:void 0;return{data:g?.message?.headers??g?.storage??void 0,success:!0}}catch(o){return{error:k(a,"retrieve email",o,i),success:!1}}},async initialize(){await n.ensureInitialized(async()=>{if(!await this.isAvailable())throw new m(a,"Mailgun API not available or invalid API key/domain");i.debug("Provider initialized successfully")},a)},async isAvailable(){try{const e={Authorization:`Basic ${y.from(`api:${r.apiKey}`).toString("base64")}`,"Content-Type":"application/json"};i.debug("Checking Mailgun API availability");const o=await h(`${r.endpoint}/v3/domains/${r.domain}`,{headers:e,method:"GET",timeout:r.timeout});if(i.debug("Mailgun API availability check response:",{error:o.error instanceof Error?o.error.message:void 0,statusCode:o.data?.statusCode,success:o.success}),!o.success||!o.data||typeof o.data!="object")return!1;const{statusCode:t}=o.data;return typeof t=="number"&&t>=200&&t<300}catch(e){return i.debug("Error checking availability:",e),!1}},name:a,options:r,async sendEmail(e){try{const o=S(e);if(o.length>0)return{error:new m(a,`Invalid email options: ${o.join(", ")}`),success:!1};await n.ensureInitialized(()=>this.initialize(),a);const t={from:I(e.from),to:b(e.to).join(",")};if(e.subject&&(t.subject=e.subject),e.cc&&(t.cc=b(e.cc).join(",")),e.bcc&&(t.bcc=b(e.bcc).join(",")),e.replyTo&&(t["h:Reply-To"]=I(e.replyTo)),e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.template&&(t.template=e.template,e.templateVariables))for(const[d,c]of Object.entries(e.templateVariables))t[`v:${d}`]=c;if(e.tags&&e.tags.length>0&&(t["o:tag"]=e.tags),e.campaignId&&(t["o:campaign"]=e.campaignId),e.deliveryTime&&(t["o:deliverytime"]=typeof e.deliveryTime=="number"?new Date(e.deliveryTime*1e3).toUTCString():e.deliveryTime),e.clickTracking!==void 0&&(t["o:clicktracking"]=e.clickTracking?"yes":"no"),e.openTracking!==void 0&&(t["o:tracking"]=e.openTracking?"yes":"no"),e.unsubscribeTracking!==void 0&&(t["o:tracking-clicks"]=e.unsubscribeTracking?"yes":"no"),e.testMode&&(t["o:testmode"]="yes"),e.requireTls&&(t["o:require-tls"]="yes"),e.skipVerification&&(t["o:skip-verification"]="yes"),e.headers){const d=R(e.headers);for(const[c,f]of Object.entries(d))t[`h:${c}`]=f}if(e.attachments&&e.attachments.length>0){const d=await Promise.all(e.attachments.map((c,f)=>U(c,a,f)));for(const c of d)t[c.key]=c.content}i.debug("Sending email via Mailgun API",{subject:t.subject,to:t.to});const p={Authorization:`Basic ${y.from(`api:${r.apiKey}`).toString("base64")}`,"Content-Type":"application/x-www-form-urlencoded"},g=B(t),l=await T(async()=>h(`${r.endpoint}/v3/${r.domain}/messages`,{headers:p,method:"POST",timeout:r.timeout},g),r.retries);if(!l.success)return i.debug("API request failed when sending email",l.error),{error:l.error??new m(a,"Failed to send email"),success:!1};const v=l.data?.body?.id??P();return i.debug("Email sent successfully",{messageId:v}),{data:{messageId:v,provider:a,response:l.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:k(a,"send email",o,i),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{X as default};
1
+ import{createRequire as j}from"node:module";import u from"./EmailError-B-sEf3bp.js";import w from"./RequiredOptionError-DuNNY_a5.js";import{e as P}from"./generate-message-id-gXAuMz4g.js";import{s as R}from"./headers-to-record-De1Eg951.js";import{m as h}from"./make-request-B9XjBynA.js";import{i as T}from"./retry-ipI5DRJ8.js";import{f as S}from"./validate-email-options-mCM9dVug.js";import{defineProvider as _}from"./defineProvider-C9q-7iwt.js";import{P as z,h as k,c as E}from"./provider-base-C7PuopYK.js";import{e as b,g as I}from"./address-formatter-BWR2Dddx.js";import{a as U}from"./attachment-processor-CMp7qqMI.js";const A=j(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,C=s=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[i,n]=m.versions.node.split(".").map(Number);if(i>22||i===22&&n>=3||i===20&&n>=16)return m.getBuiltinModule(s)}return A(s)},{Buffer:y}=C("node:buffer"),a="mailgun",q="https://api.mailgun.net",M=3e4,K=3,B=s=>{const i=[];for(const[n,r]of Object.entries(s))if(r!=null)if(Array.isArray(r))for(const e of r)i.push(`${encodeURIComponent(n)}=${encodeURIComponent(String(e))}`);else typeof r=="object"?i.push(`${encodeURIComponent(n)}=${encodeURIComponent(JSON.stringify(r))}`):i.push(`${encodeURIComponent(n)}=${encodeURIComponent(String(r))}`);return i.join("&")},X=_((s={})=>{if(!s.apiKey)throw new w(a,"apiKey");if(!s.domain)throw new w(a,"domain");const i={apiKey:s.apiKey,debug:s.debug??!1,domain:s.domain,endpoint:s.endpoint??q,retries:s.retries??K,timeout:s.timeout??M,...s.logger&&{logger:s.logger}},n=new z,r=E(a,s.logger);return{endpoint:i.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 u(a,"Email ID is required to retrieve email details"),success:!1};await n.ensureInitialized(()=>this.initialize(),a);const o={Authorization:`Basic ${y.from(`api:${i.apiKey}`).toString("base64")}`,"Content-Type":"application/json"};r.debug("Retrieving email details",{id:e});const t=await T(async()=>h(`${i.endpoint}/v3/${i.domain}/events?message-id=${encodeURIComponent(e)}&limit=1`,{headers:o,method:"GET",timeout:i.timeout}),i.retries);if(!t.success)return r.debug("API request failed when retrieving email",t.error),{error:new u(a,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1};r.debug("Email details retrieved successfully");const p=t.data?.items??[],g=p.length>0?p[0]:void 0;return{data:g?.message?.headers??g?.storage??void 0,success:!0}}catch(o){return{error:k(a,"retrieve email",o,r),success:!1}}},async initialize(){await n.ensureInitialized(async()=>{if(!await this.isAvailable())throw new u(a,"Mailgun API not available or invalid API key/domain");r.debug("Provider initialized successfully")},a)},async isAvailable(){try{const e={Authorization:`Basic ${y.from(`api:${i.apiKey}`).toString("base64")}`,"Content-Type":"application/json"};r.debug("Checking Mailgun API availability");const o=await h(`${i.endpoint}/v3/domains/${i.domain}`,{headers:e,method:"GET",timeout:i.timeout});if(r.debug("Mailgun API availability check response:",{error:o.error instanceof Error?o.error.message:void 0,statusCode:o.data?.statusCode,success:o.success}),!o.success||!o.data||typeof o.data!="object")return!1;const{statusCode:t}=o.data;return typeof t=="number"&&t>=200&&t<300}catch(e){return r.debug("Error checking availability:",e),!1}},name:a,options:i,async sendEmail(e){try{const o=S(e);if(o.length>0)return{error:new u(a,`Invalid email options: ${o.join(", ")}`),success:!1};await n.ensureInitialized(()=>this.initialize(),a);const t={from:I(e.from),to:b(e.to).join(",")};if(e.subject&&(t.subject=e.subject),e.cc&&(t.cc=b(e.cc).join(",")),e.bcc&&(t.bcc=b(e.bcc).join(",")),e.replyTo&&(t["h:Reply-To"]=I(e.replyTo)),e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.template&&(t.template=e.template,e.templateVariables))for(const[d,c]of Object.entries(e.templateVariables))t[`v:${d}`]=c;if(e.tags&&e.tags.length>0&&(t["o:tag"]=e.tags),e.campaignId&&(t["o:campaign"]=e.campaignId),e.deliveryTime&&(t["o:deliverytime"]=typeof e.deliveryTime=="number"?new Date(e.deliveryTime*1e3).toUTCString():e.deliveryTime),e.clickTracking!==void 0&&(t["o:clicktracking"]=e.clickTracking?"yes":"no"),e.openTracking!==void 0&&(t["o:tracking"]=e.openTracking?"yes":"no"),e.unsubscribeTracking!==void 0&&(t["o:tracking-clicks"]=e.unsubscribeTracking?"yes":"no"),e.testMode&&(t["o:testmode"]="yes"),e.requireTls&&(t["o:require-tls"]="yes"),e.skipVerification&&(t["o:skip-verification"]="yes"),e.headers){const d=R(e.headers);for(const[c,f]of Object.entries(d))t[`h:${c}`]=f}if(e.attachments&&e.attachments.length>0){const d=await Promise.all(e.attachments.map((c,f)=>U(c,a,f)));for(const c of d)t[c.key]=c.content}r.debug("Sending email via Mailgun API",{subject:t.subject,to:t.to});const p={Authorization:`Basic ${y.from(`api:${i.apiKey}`).toString("base64")}`,"Content-Type":"application/x-www-form-urlencoded"},g=B(t),l=await T(async()=>h(`${i.endpoint}/v3/${i.domain}/messages`,{headers:p,method:"POST",timeout:i.timeout},g),i.retries);if(!l.success)return r.debug("API request failed when sending email",l.error),{error:l.error??new u(a,"Failed to send email"),success:!1};const v=l.data?.body?.id??P();return r.debug("Email sent successfully",{messageId:v}),{data:{messageId:v,provider:a,response:l.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:k(a,"send email",o,r),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{X as default};
@@ -1 +1 @@
1
- import{createRequire as S}from"node:module";import u from"./EmailError-B-sEf3bp.js";import h from"./RequiredOptionError-DuNNY_a5.js";import{e as E}from"./generate-message-id-gXAuMz4g.js";import{s as M}from"./headers-to-record-De1Eg951.js";import{m as g}from"./make-request-BlK_B72c.js";import{u as b}from"./retry-3pnxTuNs.js";import{f as _}from"./validate-email-options-mCM9dVug.js";import{defineProvider as z}from"./defineProvider-C9q-7iwt.js";import{P as D,h as v,c as B}from"./provider-base-C7PuopYK.js";import{h as f,i as T}from"./address-formatter-BWR2Dddx.js";import{p as R}from"./attachment-processor-CMp7qqMI.js";const P=S(import.meta.url),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=s=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[a,c]=d.versions.node.split(".").map(Number);if(a>22||a===22&&c>=3||a===20&&c>=16)return d.getBuiltinModule(s)}return P(s)},{Buffer:p}=A("node:buffer"),i="mailjet",k="https://api.mailjet.com",q=3e4,K=3,X=z((s={})=>{if(!s.apiKey)throw new h(i,"apiKey");if(!s.apiSecret)throw new h(i,"apiSecret");const a={apiKey:s.apiKey,apiSecret:s.apiSecret,debug:s.debug??!1,endpoint:s.endpoint??k,retries:s.retries??K,timeout:s.timeout??q,...s.logger&&{logger:s.logger}},c=new D,o=B(i,s.logger);return{endpoint:a.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 u(i,"Email ID is required to retrieve email details"),success:!1};await c.ensureInitialized(()=>this.initialize(),i);const r={Authorization:`Basic ${p.from(`${a.apiKey}:${a.apiSecret}`).toString("base64")}`,"Content-Type":"application/json"};o.debug("Retrieving email details",{id:e});const t=await b(async()=>g(`${a.endpoint}/v3.1/REST/message/${e}`,{headers:r,method:"GET",timeout:a.timeout}),a.retries);return t.success?(o.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(o.debug("API request failed when retrieving email",t.error),{error:new u(i,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(r){return{error:v(i,"retrieve email",r,o),success:!1}}},async initialize(){await c.ensureInitialized(async()=>{if(!await this.isAvailable())throw new u(i,"Mailjet API not available or invalid API credentials");o.debug("Provider initialized successfully")},i)},async isAvailable(){try{const e={Authorization:`Basic ${p.from(`${a.apiKey}:${a.apiSecret}`).toString("base64")}`,"Content-Type":"application/json"};o.debug("Checking Mailjet API availability");const r=await g(`${a.endpoint}/v3.1/REST/user`,{headers:e,method:"GET",timeout:a.timeout});return o.debug("Mailjet API availability check response:",{error:r.error instanceof Error?r.error.message:void 0,statusCode:r.data?.statusCode,success:r.success}),!!(r.success&&r.data&&typeof r.data=="object"&&"statusCode"in r.data&&typeof r.data.statusCode=="number"&&r.data.statusCode>=200&&r.data.statusCode<300)}catch(e){return o.debug("Error checking availability:",e),!1}},name:i,options:a,async sendEmail(e){try{const r=_(e);if(r.length>0)return{error:new u(i,`Invalid email options: ${r.join(", ")}`),success:!1};await c.ensureInitialized(()=>this.initialize(),i);const t={From:T(e.from),Subject:e.subject,To:f(e.to)};if(e.html&&(t.HTMLPart=e.html),e.text&&(t.TextPart=e.text),e.cc&&(t.Cc=f(e.cc)),e.bcc&&(t.Bcc=f(e.bcc)),e.replyTo&&(t.ReplyTo=T(e.replyTo)),e.templateId&&(t.TemplateID=e.templateId,t.TemplateLanguage=e.templateLanguage??!0,e.templateVariables&&(t.Variables=e.templateVariables)),e.customId&&(t.CustomID=e.customId),e.eventPayload&&(t.EventPayload=e.eventPayload),e.campaign&&(t.Campaign=e.campaign),e.deduplicateCampaign!==void 0&&(t.DeduplicateCampaign=e.deduplicateCampaign),e.deliveryTime&&(t.Deliverytime=new Date(e.deliveryTime*1e3).toISOString()),e.priority!==void 0&&(t.Priority=e.priority),e.urlTags&&(t.URLTags=e.urlTags),e.tags&&e.tags.length>0&&(t.CustomCampaign=e.tags.join(",")),e.headers){const n=M(e.headers),m=[];for(const[C,I]of Object.entries(n))m.push({Name:C,Value:String(I)});m.length>0&&(t.Headers=m)}e.attachments&&e.attachments.length>0&&(t.Attachments=await Promise.all(e.attachments.map(async n=>({Base64Content:await R(n,i),ContentType:n.contentType??"application/octet-stream",Filename:n.filename,...n.cid&&{ContentID:n.cid}}))));const j={Messages:[t]};o.debug("Sending email via Mailjet API",{subject:t.Subject,to:t.To});const w={Authorization:`Basic ${p.from(`${a.apiKey}:${a.apiSecret}`).toString("base64")}`,"Content-Type":"application/json"},l=await b(async()=>g(`${a.endpoint}/v3.1/send`,{headers:w,method:"POST",timeout:a.timeout},JSON.stringify(j)),a.retries);if(!l.success)return o.debug("API request failed when sending email",l.error),{error:l.error??new u(i,"Failed to send email"),success:!1};const y=l.data?.body?.Messages?.[0]?.To?.[0]?.MessageID?.toString()??E();return o.debug("Email sent successfully",{messageId:y}),{data:{messageId:y,provider:i,response:l.data,sent:!0,timestamp:new Date},success:!0}}catch(r){return{error:v(i,"send email",r,o),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{X as default};
1
+ import{createRequire as S}from"node:module";import u from"./EmailError-B-sEf3bp.js";import h from"./RequiredOptionError-DuNNY_a5.js";import{e as E}from"./generate-message-id-gXAuMz4g.js";import{s as M}from"./headers-to-record-De1Eg951.js";import{m as g}from"./make-request-B9XjBynA.js";import{i as b}from"./retry-ipI5DRJ8.js";import{f as _}from"./validate-email-options-mCM9dVug.js";import{defineProvider as z}from"./defineProvider-C9q-7iwt.js";import{P as D,h as v,c as B}from"./provider-base-C7PuopYK.js";import{h as f,i as T}from"./address-formatter-BWR2Dddx.js";import{p as R}from"./attachment-processor-CMp7qqMI.js";const P=S(import.meta.url),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=s=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[a,c]=d.versions.node.split(".").map(Number);if(a>22||a===22&&c>=3||a===20&&c>=16)return d.getBuiltinModule(s)}return P(s)},{Buffer:p}=A("node:buffer"),i="mailjet",k="https://api.mailjet.com",q=3e4,K=3,X=z((s={})=>{if(!s.apiKey)throw new h(i,"apiKey");if(!s.apiSecret)throw new h(i,"apiSecret");const a={apiKey:s.apiKey,apiSecret:s.apiSecret,debug:s.debug??!1,endpoint:s.endpoint??k,retries:s.retries??K,timeout:s.timeout??q,...s.logger&&{logger:s.logger}},c=new D,o=B(i,s.logger);return{endpoint:a.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 u(i,"Email ID is required to retrieve email details"),success:!1};await c.ensureInitialized(()=>this.initialize(),i);const r={Authorization:`Basic ${p.from(`${a.apiKey}:${a.apiSecret}`).toString("base64")}`,"Content-Type":"application/json"};o.debug("Retrieving email details",{id:e});const t=await b(async()=>g(`${a.endpoint}/v3.1/REST/message/${e}`,{headers:r,method:"GET",timeout:a.timeout}),a.retries);return t.success?(o.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(o.debug("API request failed when retrieving email",t.error),{error:new u(i,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(r){return{error:v(i,"retrieve email",r,o),success:!1}}},async initialize(){await c.ensureInitialized(async()=>{if(!await this.isAvailable())throw new u(i,"Mailjet API not available or invalid API credentials");o.debug("Provider initialized successfully")},i)},async isAvailable(){try{const e={Authorization:`Basic ${p.from(`${a.apiKey}:${a.apiSecret}`).toString("base64")}`,"Content-Type":"application/json"};o.debug("Checking Mailjet API availability");const r=await g(`${a.endpoint}/v3.1/REST/user`,{headers:e,method:"GET",timeout:a.timeout});return o.debug("Mailjet API availability check response:",{error:r.error instanceof Error?r.error.message:void 0,statusCode:r.data?.statusCode,success:r.success}),!!(r.success&&r.data&&typeof r.data=="object"&&"statusCode"in r.data&&typeof r.data.statusCode=="number"&&r.data.statusCode>=200&&r.data.statusCode<300)}catch(e){return o.debug("Error checking availability:",e),!1}},name:i,options:a,async sendEmail(e){try{const r=_(e);if(r.length>0)return{error:new u(i,`Invalid email options: ${r.join(", ")}`),success:!1};await c.ensureInitialized(()=>this.initialize(),i);const t={From:T(e.from),Subject:e.subject,To:f(e.to)};if(e.html&&(t.HTMLPart=e.html),e.text&&(t.TextPart=e.text),e.cc&&(t.Cc=f(e.cc)),e.bcc&&(t.Bcc=f(e.bcc)),e.replyTo&&(t.ReplyTo=T(e.replyTo)),e.templateId&&(t.TemplateID=e.templateId,t.TemplateLanguage=e.templateLanguage??!0,e.templateVariables&&(t.Variables=e.templateVariables)),e.customId&&(t.CustomID=e.customId),e.eventPayload&&(t.EventPayload=e.eventPayload),e.campaign&&(t.Campaign=e.campaign),e.deduplicateCampaign!==void 0&&(t.DeduplicateCampaign=e.deduplicateCampaign),e.deliveryTime&&(t.Deliverytime=new Date(e.deliveryTime*1e3).toISOString()),e.priority!==void 0&&(t.Priority=e.priority),e.urlTags&&(t.URLTags=e.urlTags),e.tags&&e.tags.length>0&&(t.CustomCampaign=e.tags.join(",")),e.headers){const n=M(e.headers),m=[];for(const[C,I]of Object.entries(n))m.push({Name:C,Value:String(I)});m.length>0&&(t.Headers=m)}e.attachments&&e.attachments.length>0&&(t.Attachments=await Promise.all(e.attachments.map(async n=>({Base64Content:await R(n,i),ContentType:n.contentType??"application/octet-stream",Filename:n.filename,...n.cid&&{ContentID:n.cid}}))));const j={Messages:[t]};o.debug("Sending email via Mailjet API",{subject:t.Subject,to:t.To});const w={Authorization:`Basic ${p.from(`${a.apiKey}:${a.apiSecret}`).toString("base64")}`,"Content-Type":"application/json"},l=await b(async()=>g(`${a.endpoint}/v3.1/send`,{headers:w,method:"POST",timeout:a.timeout},JSON.stringify(j)),a.retries);if(!l.success)return o.debug("API request failed when sending email",l.error),{error:l.error??new u(i,"Failed to send email"),success:!1};const y=l.data?.body?.Messages?.[0]?.To?.[0]?.MessageID?.toString()??E();return o.debug("Email sent successfully",{messageId:y}),{data:{messageId:y,provider:i,response:l.data,sent:!0,timestamp:new Date},success:!0}}catch(r){return{error:v(i,"send email",r,o),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{X as default};
@@ -1 +1 @@
1
- import c from"./EmailError-B-sEf3bp.js";import b from"./RequiredOptionError-DuNNY_a5.js";import{e as v}from"./generate-message-id-gXAuMz4g.js";import{s as w}from"./headers-to-record-De1Eg951.js";import{m as g}from"./make-request-BlK_B72c.js";import{u as f}from"./retry-3pnxTuNs.js";import{f as I}from"./validate-email-options-mCM9dVug.js";import{defineProvider as P}from"./defineProvider-C9q-7iwt.js";import{P as A,h,c as T}from"./provider-base-C7PuopYK.js";import{f as d,a as E}from"./address-formatter-BWR2Dddx.js";import{p as K}from"./attachment-processor-CMp7qqMI.js";const a="mailomat",S="https://api.mailomat.com",j=3e4,k=3,X=P((i={})=>{if(!i.apiKey)throw new b(a,"apiKey");const s={apiKey:i.apiKey,debug:i.debug??!1,endpoint:i.endpoint??S,retries:i.retries??k,timeout:i.timeout??j,...i.logger&&{logger:i.logger}},m=new A,r=T(a,i.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new c(a,"Email ID is required to retrieve email details"),success:!1};await m.ensureInitialized(()=>this.initialize(),a);const o={"Content-Type":"application/json","X-API-Key":s.apiKey};r.debug("Retrieving email details",{id:e});const t=await f(async()=>g(`${s.endpoint}/emails/${e}`,{headers:o,method:"GET",timeout:s.timeout}),s.retries);return t.success?(r.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(r.debug("API request failed when retrieving email",t.error),{error:new c(a,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(o){return{error:h(a,"retrieve email",o,r),success:!1}}},async initialize(){await m.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(a,"Mailomat API not available or invalid API key");r.debug("Provider initialized successfully")},a)},async isAvailable(){try{return r.debug("Checking Mailomat API availability"),!0}catch(e){return r.debug("Error checking availability:",e),!1}},name:a,options:s,async sendEmail(e){try{const o=I(e);if(o.length>0)return{error:new c(a,`Invalid email options: ${o.join(", ")}`),success:!1};await m.ensureInitialized(()=>this.initialize(),a);const t={from:{email:e.from.email,name:e.from.name},subject:e.subject,to:d(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=d(e.cc)),e.bcc&&(t.bcc=d(e.bcc)),e.replyTo&&(t.replyTo=E(e.replyTo)),e.templateId&&(t.templateId=e.templateId,e.templateVariables&&(t.templateVariables=e.templateVariables)),e.tags&&e.tags.length>0&&(t.tags=e.tags),e.headers){const n=w(e.headers);t.headers=n}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async n=>({content:await K(n,a),contentType:n.contentType??"application/octet-stream",filename:n.filename,...n.cid&&{cid:n.cid}})))),r.debug("Sending email via Mailomat API",{subject:t.subject,to:t.to});const y={"Content-Type":"application/json","X-API-Key":s.apiKey},l=await f(async()=>g(`${s.endpoint}/send`,{headers:y,method:"POST",timeout:s.timeout},JSON.stringify(t)),s.retries);if(!l.success)return r.debug("API request failed when sending email",l.error),{error:l.error??new c(a,"Failed to send email"),success:!1};const u=l.data?.body,p=u?.messageId??u?.id??v();return r.debug("Email sent successfully",{messageId:p}),{data:{messageId:p,provider:a,response:l.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:h(a,"send email",o,r),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{X as default};
1
+ import c from"./EmailError-B-sEf3bp.js";import b from"./RequiredOptionError-DuNNY_a5.js";import{e as v}from"./generate-message-id-gXAuMz4g.js";import{s as w}from"./headers-to-record-De1Eg951.js";import{m as g}from"./make-request-B9XjBynA.js";import{i as f}from"./retry-ipI5DRJ8.js";import{f as I}from"./validate-email-options-mCM9dVug.js";import{defineProvider as P}from"./defineProvider-C9q-7iwt.js";import{P as A,h,c as T}from"./provider-base-C7PuopYK.js";import{f as d,a as E}from"./address-formatter-BWR2Dddx.js";import{p as K}from"./attachment-processor-CMp7qqMI.js";const a="mailomat",S="https://api.mailomat.com",j=3e4,k=3,X=P((i={})=>{if(!i.apiKey)throw new b(a,"apiKey");const s={apiKey:i.apiKey,debug:i.debug??!1,endpoint:i.endpoint??S,retries:i.retries??k,timeout:i.timeout??j,...i.logger&&{logger:i.logger}},m=new A,r=T(a,i.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new c(a,"Email ID is required to retrieve email details"),success:!1};await m.ensureInitialized(()=>this.initialize(),a);const o={"Content-Type":"application/json","X-API-Key":s.apiKey};r.debug("Retrieving email details",{id:e});const t=await f(async()=>g(`${s.endpoint}/emails/${e}`,{headers:o,method:"GET",timeout:s.timeout}),s.retries);return t.success?(r.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(r.debug("API request failed when retrieving email",t.error),{error:new c(a,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(o){return{error:h(a,"retrieve email",o,r),success:!1}}},async initialize(){await m.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(a,"Mailomat API not available or invalid API key");r.debug("Provider initialized successfully")},a)},async isAvailable(){try{return r.debug("Checking Mailomat API availability"),!0}catch(e){return r.debug("Error checking availability:",e),!1}},name:a,options:s,async sendEmail(e){try{const o=I(e);if(o.length>0)return{error:new c(a,`Invalid email options: ${o.join(", ")}`),success:!1};await m.ensureInitialized(()=>this.initialize(),a);const t={from:{email:e.from.email,name:e.from.name},subject:e.subject,to:d(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=d(e.cc)),e.bcc&&(t.bcc=d(e.bcc)),e.replyTo&&(t.replyTo=E(e.replyTo)),e.templateId&&(t.templateId=e.templateId,e.templateVariables&&(t.templateVariables=e.templateVariables)),e.tags&&e.tags.length>0&&(t.tags=e.tags),e.headers){const n=w(e.headers);t.headers=n}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async n=>({content:await K(n,a),contentType:n.contentType??"application/octet-stream",filename:n.filename,...n.cid&&{cid:n.cid}})))),r.debug("Sending email via Mailomat API",{subject:t.subject,to:t.to});const y={"Content-Type":"application/json","X-API-Key":s.apiKey},l=await f(async()=>g(`${s.endpoint}/send`,{headers:y,method:"POST",timeout:s.timeout},JSON.stringify(t)),s.retries);if(!l.success)return r.debug("API request failed when sending email",l.error),{error:l.error??new c(a,"Failed to send email"),success:!1};const u=l.data?.body,p=u?.messageId??u?.id??v();return r.debug("Email sent successfully",{messageId:p}),{data:{messageId:p,provider:a,response:l.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:h(a,"send email",o,r),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{X as default};
@@ -1 +1 @@
1
- import l from"./EmailError-B-sEf3bp.js";import b from"./RequiredOptionError-DuNNY_a5.js";import{e as y}from"./generate-message-id-gXAuMz4g.js";import{s as v}from"./headers-to-record-De1Eg951.js";import{m}from"./make-request-BlK_B72c.js";import{u as g}from"./retry-3pnxTuNs.js";import{f as w}from"./validate-email-options-mCM9dVug.js";import{defineProvider as T}from"./defineProvider-C9q-7iwt.js";import{P as k,h as f,c as A}from"./provider-base-C7PuopYK.js";import{f as u,a as I}from"./address-formatter-BWR2Dddx.js";import{p as P}from"./attachment-processor-CMp7qqMI.js";const r="mailtrap",C="https://send.api.mailtrap.io",E=3e4,j=3,F=T((o={})=>{if(!o.apiToken)throw new b(r,"apiToken");const i={apiToken:o.apiToken,debug:o.debug??!1,endpoint:o.endpoint??C,retries:o.retries??j,timeout:o.timeout??E,...o.logger&&{logger:o.logger}},d=new k,s=A(r,o.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new l(r,"Email ID is required to retrieve email details"),success:!1};await d.ensureInitialized(()=>this.initialize(),r);const a={"Api-Token":i.apiToken,"Content-Type":"application/json"};s.debug("Retrieving email details",{id:e});const t=await g(async()=>m(`${i.endpoint}/api/send/${e}`,{headers:a,method:"GET",timeout:i.timeout}),i.retries);return t.success?(s.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(s.debug("API request failed when retrieving email",t.error),{error:new l(r,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(a){return{error:f(r,"retrieve email",a,s),success:!1}}},async initialize(){await d.ensureInitialized(async()=>{if(!await this.isAvailable())throw new l(r,"Mailtrap API not available or invalid API token");s.debug("Provider initialized successfully")},r)},async isAvailable(){try{const e={"Api-Token":i.apiToken,"Content-Type":"application/json"};s.debug("Checking Mailtrap API availability");const a=await m(`${i.endpoint}/api/account`,{headers:e,method:"GET",timeout:i.timeout});return s.debug("Mailtrap API availability check response:",{error:a.error instanceof Error?a.error.message:void 0,statusCode:a.data?.statusCode,success:a.success}),!!(a.success&&a.data&&typeof a.data=="object"&&"statusCode"in a.data&&typeof a.data.statusCode=="number"&&a.data.statusCode>=200&&a.data.statusCode<300)}catch(e){return s.debug("Error checking availability:",e),!1}},name:r,options:i,async sendEmail(e){try{const a=w(e);if(a.length>0)return{error:new l(r,`Invalid email options: ${a.join(", ")}`),success:!1};await d.ensureInitialized(()=>this.initialize(),r);const t={from:{email:e.from.email,name:e.from.name},subject:e.subject,to:u(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=u(e.cc)),e.bcc&&(t.bcc=u(e.bcc)),e.replyTo&&(t.reply_to=I(e.replyTo)),e.templateUuid&&(t.template_uuid=e.templateUuid,e.templateVariables&&(t.template_variables=e.templateVariables)),e.category&&(t.category=e.category),e.customVariables&&(t.custom_variables=e.customVariables),e.tags&&e.tags.length>0&&(t.tags=e.tags),e.headers){const n=v(e.headers);t.headers=n}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async n=>({content:await P(n,r),filename:n.filename,type:n.contentType??"application/octet-stream",...n.cid&&{cid:n.cid}})))),s.debug("Sending email via Mailtrap API",{subject:t.subject,to:t.to});const h={"Api-Token":i.apiToken,"Content-Type":"application/json"},c=await g(async()=>m(`${i.endpoint}/api/send`,{headers:h,method:"POST",timeout:i.timeout},JSON.stringify(t)),i.retries);if(!c.success)return s.debug("API request failed when sending email",c.error),{error:c.error??new l(r,"Failed to send email"),success:!1};const p=c.data?.body?.message_ids?.[0]??y();return s.debug("Email sent successfully",{messageId:p}),{data:{messageId:p,provider:r,response:c.data,sent:!0,timestamp:new Date},success:!0}}catch(a){return{error:f(r,"send email",a,s),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{F as default};
1
+ import l from"./EmailError-B-sEf3bp.js";import b from"./RequiredOptionError-DuNNY_a5.js";import{e as y}from"./generate-message-id-gXAuMz4g.js";import{s as v}from"./headers-to-record-De1Eg951.js";import{m}from"./make-request-B9XjBynA.js";import{i as g}from"./retry-ipI5DRJ8.js";import{f as w}from"./validate-email-options-mCM9dVug.js";import{defineProvider as T}from"./defineProvider-C9q-7iwt.js";import{P as k,h as f,c as A}from"./provider-base-C7PuopYK.js";import{f as u,a as I}from"./address-formatter-BWR2Dddx.js";import{p as P}from"./attachment-processor-CMp7qqMI.js";const r="mailtrap",C="https://send.api.mailtrap.io",E=3e4,j=3,F=T((o={})=>{if(!o.apiToken)throw new b(r,"apiToken");const i={apiToken:o.apiToken,debug:o.debug??!1,endpoint:o.endpoint??C,retries:o.retries??j,timeout:o.timeout??E,...o.logger&&{logger:o.logger}},d=new k,s=A(r,o.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new l(r,"Email ID is required to retrieve email details"),success:!1};await d.ensureInitialized(()=>this.initialize(),r);const a={"Api-Token":i.apiToken,"Content-Type":"application/json"};s.debug("Retrieving email details",{id:e});const t=await g(async()=>m(`${i.endpoint}/api/send/${e}`,{headers:a,method:"GET",timeout:i.timeout}),i.retries);return t.success?(s.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(s.debug("API request failed when retrieving email",t.error),{error:new l(r,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(a){return{error:f(r,"retrieve email",a,s),success:!1}}},async initialize(){await d.ensureInitialized(async()=>{if(!await this.isAvailable())throw new l(r,"Mailtrap API not available or invalid API token");s.debug("Provider initialized successfully")},r)},async isAvailable(){try{const e={"Api-Token":i.apiToken,"Content-Type":"application/json"};s.debug("Checking Mailtrap API availability");const a=await m(`${i.endpoint}/api/account`,{headers:e,method:"GET",timeout:i.timeout});return s.debug("Mailtrap API availability check response:",{error:a.error instanceof Error?a.error.message:void 0,statusCode:a.data?.statusCode,success:a.success}),!!(a.success&&a.data&&typeof a.data=="object"&&"statusCode"in a.data&&typeof a.data.statusCode=="number"&&a.data.statusCode>=200&&a.data.statusCode<300)}catch(e){return s.debug("Error checking availability:",e),!1}},name:r,options:i,async sendEmail(e){try{const a=w(e);if(a.length>0)return{error:new l(r,`Invalid email options: ${a.join(", ")}`),success:!1};await d.ensureInitialized(()=>this.initialize(),r);const t={from:{email:e.from.email,name:e.from.name},subject:e.subject,to:u(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=u(e.cc)),e.bcc&&(t.bcc=u(e.bcc)),e.replyTo&&(t.reply_to=I(e.replyTo)),e.templateUuid&&(t.template_uuid=e.templateUuid,e.templateVariables&&(t.template_variables=e.templateVariables)),e.category&&(t.category=e.category),e.customVariables&&(t.custom_variables=e.customVariables),e.tags&&e.tags.length>0&&(t.tags=e.tags),e.headers){const n=v(e.headers);t.headers=n}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async n=>({content:await P(n,r),filename:n.filename,type:n.contentType??"application/octet-stream",...n.cid&&{cid:n.cid}})))),s.debug("Sending email via Mailtrap API",{subject:t.subject,to:t.to});const h={"Api-Token":i.apiToken,"Content-Type":"application/json"},c=await g(async()=>m(`${i.endpoint}/api/send`,{headers:h,method:"POST",timeout:i.timeout},JSON.stringify(t)),i.retries);if(!c.success)return s.debug("API request failed when sending email",c.error),{error:c.error??new l(r,"Failed to send email"),success:!1};const p=c.data?.body?.message_ids?.[0]??y();return s.debug("Email sent successfully",{messageId:p}),{data:{messageId:p,provider:r,response:c.data,sent:!0,timestamp:new Date},success:!0}}catch(a){return{error:f(r,"send email",a,s),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{F as default};
@@ -0,0 +1 @@
1
+ import d from"./EmailError-B-sEf3bp.js";const y=globalThis.Buffer!==void 0,E="ETIMEDOUT",T=async(i,s={},r)=>{const l=typeof i=="string"?new URL(i):i;try{const e=new Headers;s.headers&&Object.entries(s.headers).forEach(([t,u])=>{e.set(t,u)});const o={headers:e,method:s.method??(r?"POST":"GET")};r&&(typeof r=="string"||r instanceof Uint8Array?o.body=r:y&&r instanceof globalThis.Buffer?o.body=new Uint8Array(r):o.body=new Uint8Array(r));let c,a;s.timeout&&(c=new AbortController,a=setTimeout(()=>{c?.abort()},s.timeout),o.signal=c.signal);try{const t=await fetch(l.toString(),o);a&&clearTimeout(a);const u=(t.headers.get("content-type")??"").includes("application/json");let n;if(u)try{n=await t.json()}catch{n=await t.text()}else n=await t.text();const f=t.status>=200&&t.status<300,h={};return t.headers.forEach((m,w)=>{h[w]=m}),{data:{body:n,headers:h,statusCode:t.status},error:f?void 0:new d("http",`Request failed with status ${t.status}`,{code:t.status.toString()}),success:f}}catch(t){if(a&&clearTimeout(a),t instanceof Error&&t.name==="AbortError")return{error:new d("http",`Request timed out after ${s.timeout}ms`,{code:E}),success:!1};throw t}}catch(e){return{error:new d("http",`Request failed: ${e instanceof Error?e.message:String(e)}`,{cause:e instanceof Error?e:new Error(String(e))}),success:!1}}};export{E as R,T as m};
@@ -1 +1 @@
1
- import d from"./EmailError-B-sEf3bp.js";import P from"./RequiredOptionError-DuNNY_a5.js";import{e as C}from"./generate-message-id-gXAuMz4g.js";import{s as j}from"./headers-to-record-De1Eg951.js";import{m as g}from"./make-request-BlK_B72c.js";import{u as y}from"./retry-3pnxTuNs.js";import{a as h,s as I}from"./sanitize-header-DtQwAnzg.js";import{f as T}from"./validate-email-options-mCM9dVug.js";import{defineProvider as _}from"./defineProvider-C9q-7iwt.js";import{P as k,h as b,c as z}from"./provider-base-C7PuopYK.js";import{k as p}from"./address-formatter-BWR2Dddx.js";import{p as E}from"./attachment-processor-CMp7qqMI.js";const a="mandrill",S="https://mandrillapp.com/api/1.0",K=3e4,M=3,B=_((l={})=>{if(!l.apiKey)throw new P(a,"apiKey");const s={apiKey:l.apiKey,debug:l.debug??!1,endpoint:l.endpoint??S,retries:l.retries??M,timeout:l.timeout??K,...l.logger&&{logger:l.logger}},u=new k,i=z(a,l.logger);return{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 d(a,"Email ID is required to retrieve email details"),success:!1};await u.ensureInitialized(()=>this.initialize(),a),i.debug("Retrieving email details",{id:e});const n={id:e,key:s.apiKey},t={"Content-Type":"application/json"},o=await y(async()=>g(`${s.endpoint}/messages/info.json`,{headers:t,method:"POST",timeout:s.timeout},JSON.stringify(n)),s.retries);return o.success?(i.debug("Email details retrieved successfully"),{data:o.data?.body,success:!0}):(i.debug("API request failed when retrieving email",o.error),{error:new d(a,`Failed to retrieve email: ${o.error instanceof Error?o.error.message:"Unknown error"}`,{cause:o.error}),success:!1})}catch(n){return{error:b(a,"retrieve email",n,i),success:!1}}},async initialize(){await u.ensureInitialized(async()=>{if(!await this.isAvailable())throw new d(a,"Mandrill API not available or invalid API key");i.debug("Provider initialized successfully")},a)},async isAvailable(){try{i.debug("Checking Mandrill API availability");const e={key:s.apiKey},n={"Content-Type":"application/json"},t=await g(`${s.endpoint}/users/info.json`,{headers:n,method:"POST",timeout:s.timeout},JSON.stringify(e));return i.debug("Mandrill 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 i.debug("Error checking availability:",e),!1}},name:a,options:s,async sendEmail(e){try{const n=T(e);if(n.length>0)return{error:new d(a,`Invalid email options: ${n.join(", ")}`),success:!1};await u.ensureInitialized(()=>this.initialize(),a);const t={from_email:e.from.email,html:e.html??"",subject:e.subject,text:e.text??"",...e.from.name&&{from_name:e.from.name},to:p(e.to,"to")};if(e.cc){const r=p(e.cc,"cc");for(const c of r)c.type="cc";t.to=[...t.to,...r]}if(e.bcc){const r=p(e.bcc,"bcc");for(const c of r)c.type="bcc";t.to=[...t.to,...r]}if(e.replyTo){const r=e.replyTo.name?`${h(e.replyTo.name)} <${e.replyTo.email}>`:e.replyTo.email;t.headers={"Reply-To":r}}if(e.headers){const r=j(e.headers),c={};Object.entries(r).forEach(([w,A])=>{c[I(w)]=h(A)}),t.headers={...t.headers,...c}}e.tags&&e.tags.length>0&&(t.tags=e.tags),e.metadata&&(t.metadata=e.metadata),(e.googleAnalyticsDomains||e.googleAnalyticsCampaign)&&(t.google_analytics_domains=e.googleAnalyticsDomains,t.google_analytics_campaign=e.googleAnalyticsCampaign),e.subaccount&&(t.subaccount=e.subaccount),e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async r=>({content:await E(r,a),name:r.filename,type:r.contentType??"application/octet-stream"}))));const o={key:s.apiKey,message:t};e.templateName&&(o.template_name=e.templateName,e.templateContent&&(o.template_content=e.templateContent),e.templateVariables&&(o.template_vars=e.templateVariables)),e.globalMergeVars&&(t.global_merge_vars=e.globalMergeVars),e.mergeVars&&(t.merge_vars=e.mergeVars),e.sendAt&&(o.send_at=e.sendAt),i.debug("Sending email via Mandrill API",{subject:t.subject,to:t.to});const v={"Content-Type":"application/json"},m=await y(async()=>g(`${s.endpoint}/messages/send.json`,{headers:v,method:"POST",timeout:s.timeout},JSON.stringify(o)),s.retries);if(!m.success)return i.debug("API request failed when sending email",m.error),{error:m.error??new d(a,"Failed to send email"),success:!1};const f=m.data?.body?.[0]?.id??C();return i.debug("Email sent successfully",{messageId:f}),{data:{messageId:f,provider:a,response:m.data,sent:!0,timestamp:new Date},success:!0}}catch(n){return{error:b(a,"send email",n,i),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{B as default};
1
+ import d from"./EmailError-B-sEf3bp.js";import P from"./RequiredOptionError-DuNNY_a5.js";import{e as C}from"./generate-message-id-gXAuMz4g.js";import{s as j}from"./headers-to-record-De1Eg951.js";import{m as g}from"./make-request-B9XjBynA.js";import{i as y}from"./retry-ipI5DRJ8.js";import{a as h,s as I}from"./sanitize-header-DtQwAnzg.js";import{f as T}from"./validate-email-options-mCM9dVug.js";import{defineProvider as _}from"./defineProvider-C9q-7iwt.js";import{P as k,h as b,c as z}from"./provider-base-C7PuopYK.js";import{k as p}from"./address-formatter-BWR2Dddx.js";import{p as E}from"./attachment-processor-CMp7qqMI.js";const a="mandrill",S="https://mandrillapp.com/api/1.0",K=3e4,M=3,B=_((l={})=>{if(!l.apiKey)throw new P(a,"apiKey");const s={apiKey:l.apiKey,debug:l.debug??!1,endpoint:l.endpoint??S,retries:l.retries??M,timeout:l.timeout??K,...l.logger&&{logger:l.logger}},u=new k,i=z(a,l.logger);return{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 d(a,"Email ID is required to retrieve email details"),success:!1};await u.ensureInitialized(()=>this.initialize(),a),i.debug("Retrieving email details",{id:e});const n={id:e,key:s.apiKey},t={"Content-Type":"application/json"},o=await y(async()=>g(`${s.endpoint}/messages/info.json`,{headers:t,method:"POST",timeout:s.timeout},JSON.stringify(n)),s.retries);return o.success?(i.debug("Email details retrieved successfully"),{data:o.data?.body,success:!0}):(i.debug("API request failed when retrieving email",o.error),{error:new d(a,`Failed to retrieve email: ${o.error instanceof Error?o.error.message:"Unknown error"}`,{cause:o.error}),success:!1})}catch(n){return{error:b(a,"retrieve email",n,i),success:!1}}},async initialize(){await u.ensureInitialized(async()=>{if(!await this.isAvailable())throw new d(a,"Mandrill API not available or invalid API key");i.debug("Provider initialized successfully")},a)},async isAvailable(){try{i.debug("Checking Mandrill API availability");const e={key:s.apiKey},n={"Content-Type":"application/json"},t=await g(`${s.endpoint}/users/info.json`,{headers:n,method:"POST",timeout:s.timeout},JSON.stringify(e));return i.debug("Mandrill 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 i.debug("Error checking availability:",e),!1}},name:a,options:s,async sendEmail(e){try{const n=T(e);if(n.length>0)return{error:new d(a,`Invalid email options: ${n.join(", ")}`),success:!1};await u.ensureInitialized(()=>this.initialize(),a);const t={from_email:e.from.email,html:e.html??"",subject:e.subject,text:e.text??"",...e.from.name&&{from_name:e.from.name},to:p(e.to,"to")};if(e.cc){const r=p(e.cc,"cc");for(const c of r)c.type="cc";t.to=[...t.to,...r]}if(e.bcc){const r=p(e.bcc,"bcc");for(const c of r)c.type="bcc";t.to=[...t.to,...r]}if(e.replyTo){const r=e.replyTo.name?`${h(e.replyTo.name)} <${e.replyTo.email}>`:e.replyTo.email;t.headers={"Reply-To":r}}if(e.headers){const r=j(e.headers),c={};Object.entries(r).forEach(([w,A])=>{c[I(w)]=h(A)}),t.headers={...t.headers,...c}}e.tags&&e.tags.length>0&&(t.tags=e.tags),e.metadata&&(t.metadata=e.metadata),(e.googleAnalyticsDomains||e.googleAnalyticsCampaign)&&(t.google_analytics_domains=e.googleAnalyticsDomains,t.google_analytics_campaign=e.googleAnalyticsCampaign),e.subaccount&&(t.subaccount=e.subaccount),e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async r=>({content:await E(r,a),name:r.filename,type:r.contentType??"application/octet-stream"}))));const o={key:s.apiKey,message:t};e.templateName&&(o.template_name=e.templateName,e.templateContent&&(o.template_content=e.templateContent),e.templateVariables&&(o.template_vars=e.templateVariables)),e.globalMergeVars&&(t.global_merge_vars=e.globalMergeVars),e.mergeVars&&(t.merge_vars=e.mergeVars),e.sendAt&&(o.send_at=e.sendAt),i.debug("Sending email via Mandrill API",{subject:t.subject,to:t.to});const v={"Content-Type":"application/json"},m=await y(async()=>g(`${s.endpoint}/messages/send.json`,{headers:v,method:"POST",timeout:s.timeout},JSON.stringify(o)),s.retries);if(!m.success)return i.debug("API request failed when sending email",m.error),{error:m.error??new d(a,"Failed to send email"),success:!1};const f=m.data?.body?.[0]?.id??C();return i.debug("Email sent successfully",{messageId:f}),{data:{messageId:f,provider:a,response:m.data,sent:!0,timestamp:new Date},success:!0}}catch(n){return{error:b(a,"send email",n,i),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{B as default};
@@ -1 +1 @@
1
- import p from"./EmailError-B-sEf3bp.js";import g from"./RequiredOptionError-DuNNY_a5.js";import{e as y}from"./generate-message-id-gXAuMz4g.js";import{m as v}from"./make-request-BlK_B72c.js";import{u as b}from"./retry-3pnxTuNs.js";import{f as w}from"./validate-email-options-mCM9dVug.js";import{defineProvider as P}from"./defineProvider-C9q-7iwt.js";import{P as I,h as A,c as z}from"./provider-base-C7PuopYK.js";import{a as l}from"./address-formatter-BWR2Dddx.js";import{c as K}from"./attachment-processor-CMp7qqMI.js";const a="netcore",S="https://emailapi.netcorecloud.net/v5.1",T=3e4,_=3,m=r=>[r].flat(),F=P((r={})=>{if(!r.apiKey)throw new g(a,"apiKey");const i={apiKey:r.apiKey,debug:r.debug??!1,endpoint:r.endpoint??S,logger:r.logger,retries:r.retries??_,timeout:r.timeout??T},d=new I,u=z(a,r.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async initialize(){await d.ensureInitialized(async()=>{if(!await this.isAvailable())throw new p(a,"Netcore API not available or invalid API key");u.debug("Provider initialized successfully")},a)},async isAvailable(){return i.apiKey.length>0},name:a,options:i,async sendEmail(t){try{const n=w(t);if(n.length>0)return{error:new p(a,`Invalid email options: ${n.join(", ")}`),success:!1};await d.ensureInitialized(()=>this.initialize(),a);const o={to:m(t.to).map(e=>l(e))};t.cc&&(o.cc=m(t.cc).map(e=>l(e))),t.bcc&&(o.bcc=m(t.bcc).map(e=>l(e)));const s={from:l(t.from),personalizations:[o],subject:t.subject};if(t.templateId)s.template_id=t.templateId,t.templateData&&(o.attributes=t.templateData);else{const e=[];t.html&&e.push({type:"html",value:t.html}),t.text&&e.push({type:"plain",value:t.text}),e.length>0&&(s.content=e)}if(t.replyTo){const e=m(t.replyTo)[0];e&&(s.reply_to=e.email)}t.attachments&&t.attachments.length>0&&(s.attachments=await Promise.all(t.attachments.map(async e=>{const h=await K(e,a);return{content:h.content,name:h.filename}})));const c=await b(async()=>v(`${i.endpoint}/mail/send`,{headers:{api_key:i.apiKey,"Content-Type":"application/json"},method:"POST",timeout:i.timeout},JSON.stringify(s)),i.retries);if(!c.success)return{error:c.error??new p(a,"Failed to send email"),success:!1};const{body:f}=c.data;return{data:{messageId:f?.data?.message_id??f?.message_id??y(),provider:a,response:c.data,sent:!0,timestamp:new Date},success:!0}}catch(n){return{error:A(a,"send email",n,u),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{F as default};
1
+ import p from"./EmailError-B-sEf3bp.js";import g from"./RequiredOptionError-DuNNY_a5.js";import{e as y}from"./generate-message-id-gXAuMz4g.js";import{m as v}from"./make-request-B9XjBynA.js";import{i as b}from"./retry-ipI5DRJ8.js";import{f as w}from"./validate-email-options-mCM9dVug.js";import{defineProvider as P}from"./defineProvider-C9q-7iwt.js";import{P as I,h as A,c as z}from"./provider-base-C7PuopYK.js";import{a as l}from"./address-formatter-BWR2Dddx.js";import{c as K}from"./attachment-processor-CMp7qqMI.js";const a="netcore",S="https://emailapi.netcorecloud.net/v5.1",T=3e4,_=3,m=r=>[r].flat(),F=P((r={})=>{if(!r.apiKey)throw new g(a,"apiKey");const i={apiKey:r.apiKey,debug:r.debug??!1,endpoint:r.endpoint??S,logger:r.logger,retries:r.retries??_,timeout:r.timeout??T},d=new I,u=z(a,r.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async initialize(){await d.ensureInitialized(async()=>{if(!await this.isAvailable())throw new p(a,"Netcore API not available or invalid API key");u.debug("Provider initialized successfully")},a)},async isAvailable(){return i.apiKey.length>0},name:a,options:i,async sendEmail(t){try{const n=w(t);if(n.length>0)return{error:new p(a,`Invalid email options: ${n.join(", ")}`),success:!1};await d.ensureInitialized(()=>this.initialize(),a);const o={to:m(t.to).map(e=>l(e))};t.cc&&(o.cc=m(t.cc).map(e=>l(e))),t.bcc&&(o.bcc=m(t.bcc).map(e=>l(e)));const s={from:l(t.from),personalizations:[o],subject:t.subject};if(t.templateId)s.template_id=t.templateId,t.templateData&&(o.attributes=t.templateData);else{const e=[];t.html&&e.push({type:"html",value:t.html}),t.text&&e.push({type:"plain",value:t.text}),e.length>0&&(s.content=e)}if(t.replyTo){const e=m(t.replyTo)[0];e&&(s.reply_to=e.email)}t.attachments&&t.attachments.length>0&&(s.attachments=await Promise.all(t.attachments.map(async e=>{const h=await K(e,a);return{content:h.content,name:h.filename}})));const c=await b(async()=>v(`${i.endpoint}/mail/send`,{headers:{api_key:i.apiKey,"Content-Type":"application/json"},method:"POST",timeout:i.timeout},JSON.stringify(s)),i.retries);if(!c.success)return{error:c.error??new p(a,"Failed to send email"),success:!1};const{body:f}=c.data;return{data:{messageId:f?.data?.message_id??f?.message_id??y(),provider:a,response:c.data,sent:!0,timestamp:new Date},success:!0}}catch(n){return{error:A(a,"send email",n,u),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{F as default};
@@ -1 +1 @@
1
- import m from"./EmailError-B-sEf3bp.js";import{e as _}from"./generate-message-id-gXAuMz4g.js";import{m as S}from"./make-request-BlK_B72c.js";import{u as v}from"./retry-3pnxTuNs.js";import{f as A}from"./validate-email-options-mCM9dVug.js";import{defineProvider as C}from"./defineProvider-C9q-7iwt.js";import p from"./RequiredOptionError-DuNNY_a5.js";import{d as x}from"./create-token-cache-D56KQGVQ.js";import{c as M}from"./attachment-processor-CMp7qqMI.js";import{h as P,P as R,c as j}from"./provider-base-C7PuopYK.js";const b="https://login.microsoftonline.com",E=6e4,O=3e4,L=3,q=300,z="https://graph.microsoft.com/.default",D=["https://graph.microsoft.com/Mail.Send","offline_access"],F={accessToken:["clientId","clientSecret","refreshToken","tenantId"],clientCredentials:["refreshToken"],getAccessToken:["accessToken","clientId","clientSecret","refreshToken","tenantId"],refreshToken:[]},N=e=>{let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)},U=(e,t)=>{if(e.getAccessToken)return"getAccessToken";if(e.accessToken)return"accessToken";if(e.refreshToken)return"refreshToken";if(e.clientSecret)return"clientCredentials";throw new p(t,["accessToken","getAccessToken","clientSecret","refreshToken"])},$=(e,t,c)=>{const n=e.authMode??U(e,t),h=F[n].filter(a=>e[a]!==void 0);if(h.length>0&&c.warn(`The '${n}' auth mode ignores these configured options: ${h.join(", ")}. Set 'authMode' to pin the intended flow.`),n==="getAccessToken"){const{getAccessToken:a}=e;if(!a)throw new p(t,"getAccessToken");return{getToken:async()=>a(),mode:n}}if(n==="accessToken"){const{accessToken:a}=e;if(!a)throw new p(t,"accessToken");return{getToken:()=>Promise.resolve(a),mode:n}}const{clientId:f,clientSecret:r,refreshToken:i,tenantId:d}=e,o=[];if(d||o.push("tenantId"),f||o.push("clientId"),n==="clientCredentials"&&!r&&o.push("clientSecret"),n==="refreshToken"&&!i&&o.push("refreshToken"),!d||!f)throw new p(t,o);if(n==="clientCredentials"){if(!r)throw new p(t,o);return{clientId:f,clientSecret:r,mode:n,tenantId:d}}if(!i)throw new p(t,o);return{clientId:f,clientSecret:r,mode:n,refreshToken:i,tenantId:d}},B=(e,t,c)=>{if(typeof e!="object"||e===null)throw new m(t,`Token endpoint returned a non-JSON response (status ${String(c)})`);const n=e;if(typeof n.error=="string"){const h=typeof n.error_description=="string"?n.error_description:"no description provided";throw new m(t,`Token request failed: ${n.error} — ${h}`,{code:n.error,hint:"Check the tenantId, clientId and client secret / refresh token in the Azure app registration."})}if(typeof n.access_token!="string")throw new m(t,`Token endpoint response did not contain an access_token (status ${String(c)})`);return{accessToken:n.access_token,expiresIn:typeof n.expires_in=="number"?n.expires_in:q,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0}},H=e=>e===0||e===408||e===429||e>=500,J=(e,t,c,n)=>{if(e.mode==="accessToken"||e.mode==="getAccessToken")return e.getToken;const h=`${N(t.authority??b)}/${e.tenantId}/oauth2/v2.0/token`,f=t.timeout??O,r=t.retries??L,i=t.now??Date.now;let d=e.mode==="refreshToken"?e.refreshToken:void 0;const o=()=>{const s=new URLSearchParams({client_id:e.clientId,scope:(t.scopes??(e.mode==="clientCredentials"?[z]:D)).join(" ")});return e.clientSecret&&s.set("client_secret",e.clientSecret),e.mode==="clientCredentials"?s.set("grant_type","client_credentials"):(s.set("grant_type","refresh_token"),s.set("refresh_token",d)),s.toString()},a=s=>s.data?.statusCode??0,k=async()=>{const s=await S(h,{headers:{"Content-Type":"application/x-www-form-urlencoded"},method:"POST",timeout:f},o());return!s.success&&H(a(s))?s:{data:s.data,success:!0}},T=async s=>{if(d=s,!!t.onRefreshToken)try{await t.onRefreshToken(s)}catch(u){n.error(`Failed to persist the rotated refresh token — the stored token is stale and sending will fail after a restart: ${u instanceof Error?u.message:String(u)}`)}},g=x(async()=>{const s=await v(k,r),u=s.data?.body;if(!s.success&&(typeof u!="object"||u===null))throw s.error instanceof Error?s.error:new m(c,"Token request failed");const w=B(u,c,a(s));return w.refreshToken&&w.refreshToken!==d&&await T(w.refreshToken),{accessToken:w.accessToken,expiresAt:i()+w.expiresIn*1e3}},{now:i,skewMs:t.tokenRefreshSkewMs??E});return async()=>(await g()).accessToken},l="outlook365",G="https://graph.microsoft.com/v1.0",K=3e4,Q=3,y=e=>[e].flat(),I=e=>e.map(t=>({emailAddress:{address:t.email,...t.name?{name:t.name}:{}}})),V=e=>{if(e instanceof m)return e;const t=e instanceof Error?e.message:String(e);return new m(l,`Failed to obtain access token: ${t}`,{cause:e})},ae=C((e={})=>{const t=j(l,e.logger),c=$(e,l,t);if(c.mode==="clientCredentials"&&(e.userId===void 0||e.userId==="me"))throw new m(l,"The app-only (client credentials) flow requires an explicit 'userId'",{hint:"Set 'userId' to the sender's mailbox id or UPN — app-only tokens have no 'me' mailbox."});const n={authMode:c.mode,authority:e.authority??b,clientId:e.clientId,debug:e.debug??!1,endpoint:e.endpoint??G,logger:e.logger,now:e.now,retries:e.retries??Q,saveToSentItems:e.saveToSentItems??!0,scopes:e.scopes,tenantId:e.tenantId,timeout:e.timeout??K,tokenRefreshSkewMs:e.tokenRefreshSkewMs,userId:e.userId??"me"},h=new R,f=J(c,e,l,t);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!1,tracking:!1},async initialize(){h.setInitialized()},async isAvailable(){return!0},name:l,options:n,async sendEmail(r){try{const i=A(r);if(i.length>0)return{error:new m(l,`Invalid email options: ${i.join(", ")}`),success:!1};let d;try{d=await f()}catch(T){return{error:V(T),success:!1}}const o={body:{content:r.html??r.text??"",contentType:r.html?"HTML":"Text"},subject:r.subject,toRecipients:I(y(r.to))};r.cc&&(o.ccRecipients=I(y(r.cc))),r.bcc&&(o.bccRecipients=I(y(r.bcc))),r.replyTo&&(o.replyTo=I(y(r.replyTo))),r.importance&&(o.importance=r.importance),r.attachments&&r.attachments.length>0&&(o.attachments=await Promise.all(r.attachments.map(async T=>{const g=await M(T,l);return{"@odata.type":"#microsoft.graph.fileAttachment",contentBytes:g.content,contentType:g.contentType,name:g.filename}})));const a=n.userId==="me"?"me":`users/${n.userId}`,k=await v(async()=>S(`${n.endpoint}/${a}/sendMail`,{headers:{Authorization:`Bearer ${d}`,"Content-Type":"application/json"},method:"POST",timeout:n.timeout},JSON.stringify({message:o,saveToSentItems:n.saveToSentItems})),n.retries);return k.success?{data:{messageId:_(),provider:l,response:k.data,sent:!0,timestamp:new Date},success:!0}:{error:k.error??new m(l,"Failed to send email"),success:!1}}catch(i){return{error:P(l,"send email",i,t),success:!1}}},async validateCredentials(){try{return await f(),!0}catch(r){return t.warn(`Credential validation failed: ${r instanceof Error?r.message:String(r)}`),!1}}}});export{ae as default};
1
+ import m from"./EmailError-B-sEf3bp.js";import{e as _}from"./generate-message-id-gXAuMz4g.js";import{m as S}from"./make-request-B9XjBynA.js";import{i as v}from"./retry-ipI5DRJ8.js";import{f as A}from"./validate-email-options-mCM9dVug.js";import{defineProvider as C}from"./defineProvider-C9q-7iwt.js";import p from"./RequiredOptionError-DuNNY_a5.js";import{d as x}from"./create-token-cache-D56KQGVQ.js";import{c as M}from"./attachment-processor-CMp7qqMI.js";import{h as P,P as R,c as j}from"./provider-base-C7PuopYK.js";const b="https://login.microsoftonline.com",E=6e4,O=3e4,L=3,q=300,z="https://graph.microsoft.com/.default",D=["https://graph.microsoft.com/Mail.Send","offline_access"],F={accessToken:["clientId","clientSecret","refreshToken","tenantId"],clientCredentials:["refreshToken"],getAccessToken:["accessToken","clientId","clientSecret","refreshToken","tenantId"],refreshToken:[]},N=e=>{let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)},U=(e,t)=>{if(e.getAccessToken)return"getAccessToken";if(e.accessToken)return"accessToken";if(e.refreshToken)return"refreshToken";if(e.clientSecret)return"clientCredentials";throw new p(t,["accessToken","getAccessToken","clientSecret","refreshToken"])},B=(e,t,i)=>{const n=e.authMode??U(e,t),h=F[n].filter(a=>e[a]!==void 0);if(h.length>0&&i.warn(`The '${n}' auth mode ignores these configured options: ${h.join(", ")}. Set 'authMode' to pin the intended flow.`),n==="getAccessToken"){const{getAccessToken:a}=e;if(!a)throw new p(t,"getAccessToken");return{getToken:async()=>a(),mode:n}}if(n==="accessToken"){const{accessToken:a}=e;if(!a)throw new p(t,"accessToken");return{getToken:()=>Promise.resolve(a),mode:n}}const{clientId:f,clientSecret:r,refreshToken:c,tenantId:d}=e,o=[];if(d||o.push("tenantId"),f||o.push("clientId"),n==="clientCredentials"&&!r&&o.push("clientSecret"),n==="refreshToken"&&!c&&o.push("refreshToken"),!d||!f)throw new p(t,o);if(n==="clientCredentials"){if(!r)throw new p(t,o);return{clientId:f,clientSecret:r,mode:n,tenantId:d}}if(!c)throw new p(t,o);return{clientId:f,clientSecret:r,mode:n,refreshToken:c,tenantId:d}},H=(e,t,i)=>{if(typeof e!="object"||e===null)throw new m(t,`Token endpoint returned a non-JSON response (status ${String(i)})`);const n=e;if(typeof n.error=="string"){const h=typeof n.error_description=="string"?n.error_description:"no description provided";throw new m(t,`Token request failed: ${n.error} — ${h}`,{code:n.error,hint:"Check the tenantId, clientId and client secret / refresh token in the Azure app registration."})}if(typeof n.access_token!="string")throw new m(t,`Token endpoint response did not contain an access_token (status ${String(i)})`);return{accessToken:n.access_token,expiresIn:typeof n.expires_in=="number"?n.expires_in:q,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0}},J=e=>e===0||e===408||e===429||e>=500,$=(e,t,i,n)=>{if(e.mode==="accessToken"||e.mode==="getAccessToken")return e.getToken;const h=`${N(t.authority??b)}/${e.tenantId}/oauth2/v2.0/token`,f=t.timeout??O,r=t.retries??L,c=t.now??Date.now;let d=e.mode==="refreshToken"?e.refreshToken:void 0;const o=()=>{const s=new URLSearchParams({client_id:e.clientId,scope:(t.scopes??(e.mode==="clientCredentials"?[z]:D)).join(" ")});return e.clientSecret&&s.set("client_secret",e.clientSecret),e.mode==="clientCredentials"?s.set("grant_type","client_credentials"):(s.set("grant_type","refresh_token"),s.set("refresh_token",d)),s.toString()},a=s=>s.data?.statusCode??0,k=async()=>{const s=await S(h,{headers:{"Content-Type":"application/x-www-form-urlencoded"},method:"POST",timeout:f},o());return!s.success&&J(a(s))?s:{data:s.data,success:!0}},T=async s=>{if(d=s,!!t.onRefreshToken)try{await t.onRefreshToken(s)}catch(u){n.error(`Failed to persist the rotated refresh token — the stored token is stale and sending will fail after a restart: ${u instanceof Error?u.message:String(u)}`)}},g=x(async()=>{const s=await v(k,r),u=s.data?.body;if(!s.success&&(typeof u!="object"||u===null))throw s.error instanceof Error?s.error:new m(i,"Token request failed");const w=H(u,i,a(s));return w.refreshToken&&w.refreshToken!==d&&await T(w.refreshToken),{accessToken:w.accessToken,expiresAt:c()+w.expiresIn*1e3}},{now:c,skewMs:t.tokenRefreshSkewMs??E});return async()=>(await g()).accessToken},l="outlook365",G="https://graph.microsoft.com/v1.0",K=3e4,Q=3,y=e=>[e].flat(),I=e=>e.map(t=>({emailAddress:{address:t.email,...t.name?{name:t.name}:{}}})),V=e=>{if(e instanceof m)return e;const t=e instanceof Error?e.message:String(e);return new m(l,`Failed to obtain access token: ${t}`,{cause:e})},ae=C((e={})=>{const t=j(l,e.logger),i=B(e,l,t);if(i.mode==="clientCredentials"&&(e.userId===void 0||e.userId==="me"))throw new m(l,"The app-only (client credentials) flow requires an explicit 'userId'",{hint:"Set 'userId' to the sender's mailbox id or UPN — app-only tokens have no 'me' mailbox."});const n={authMode:i.mode,authority:e.authority??b,clientId:e.clientId,debug:e.debug??!1,endpoint:e.endpoint??G,logger:e.logger,now:e.now,retries:e.retries??Q,saveToSentItems:e.saveToSentItems??!0,scopes:e.scopes,tenantId:e.tenantId,timeout:e.timeout??K,tokenRefreshSkewMs:e.tokenRefreshSkewMs,userId:e.userId??"me"},h=new R,f=$(i,e,l,t);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!1,tracking:!1},async initialize(){h.setInitialized()},async isAvailable(){return!0},name:l,options:n,async sendEmail(r){try{const c=A(r);if(c.length>0)return{error:new m(l,`Invalid email options: ${c.join(", ")}`),success:!1};let d;try{d=await f()}catch(T){return{error:V(T),success:!1}}const o={body:{content:r.html??r.text??"",contentType:r.html?"HTML":"Text"},subject:r.subject,toRecipients:I(y(r.to))};r.cc&&(o.ccRecipients=I(y(r.cc))),r.bcc&&(o.bccRecipients=I(y(r.bcc))),r.replyTo&&(o.replyTo=I(y(r.replyTo))),r.importance&&(o.importance=r.importance),r.attachments&&r.attachments.length>0&&(o.attachments=await Promise.all(r.attachments.map(async T=>{const g=await M(T,l);return{"@odata.type":"#microsoft.graph.fileAttachment",contentBytes:g.content,contentType:g.contentType,name:g.filename}})));const a=n.userId==="me"?"me":`users/${n.userId}`,k=await v(async()=>S(`${n.endpoint}/${a}/sendMail`,{headers:{Authorization:`Bearer ${d}`,"Content-Type":"application/json"},method:"POST",timeout:n.timeout},JSON.stringify({message:o,saveToSentItems:n.saveToSentItems})),n.retries);return k.success?{data:{messageId:_(),provider:l,response:k.data,sent:!0,timestamp:new Date},success:!0}:{error:k.error??new m(l,"Failed to send email"),success:!1}}catch(c){return{error:P(l,"send email",c,t),success:!1}}},async validateCredentials(){try{return await f(),!0}catch(r){return t.warn(`Credential validation failed: ${r instanceof Error?r.message:String(r)}`),!1}}}});export{ae as default};
@@ -1 +1 @@
1
- import m from"./EmailError-B-sEf3bp.js";import P from"./RequiredOptionError-DuNNY_a5.js";import{e as y}from"./generate-message-id-gXAuMz4g.js";import{s as A}from"./headers-to-record-De1Eg951.js";import{m as b}from"./make-request-BlK_B72c.js";import{u as g}from"./retry-3pnxTuNs.js";import{s as k,a as z}from"./sanitize-header-DtQwAnzg.js";import{f as j}from"./validate-email-options-mCM9dVug.js";import{defineProvider as E}from"./defineProvider-C9q-7iwt.js";import{P as T,h,c as K}from"./provider-base-C7PuopYK.js";import{p as x}from"./attachment-processor-CMp7qqMI.js";const r="plunk",_="https://api.useplunk.com/v1",S=3e4,q=3,U=E((n={})=>{if(!n.apiKey)throw new P(r,"apiKey");const a={apiKey:n.apiKey,debug:n.debug??!1,endpoint:n.endpoint??_,logger:n.logger,retries:n.retries??q,timeout:n.timeout??S},p=new T,i=K(r,n.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new m(r,"Email ID is required to retrieve email details"),success:!1};await p.ensureInitialized(()=>this.initialize(),r);const l={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"};i.debug("Retrieving email details",{id:e});const s=await g(async()=>b(`${a.endpoint}/emails/${e}`,{headers:l,method:"GET",timeout:a.timeout}),a.retries);return s.success?(i.debug("Email details retrieved successfully"),{data:s.data?.body,success:!0}):(i.debug("API request failed when retrieving email",s.error),{error:new m(r,`Failed to retrieve email: ${s.error instanceof Error?s.error.message:"Unknown error"}`,{cause:s.error}),success:!1})}catch(l){return{error:h(r,"retrieve email",l,i),success:!1}}},async initialize(){await p.ensureInitialized(async()=>{if(!await this.isAvailable())throw new m(r,"Plunk API not available or invalid API key");i.debug("Provider initialized successfully")},r)},async isAvailable(){try{return a.apiKey&&a.apiKey.length>0?(i.debug("API key exists, assuming Plunk is available"),!0):!1}catch(e){return i.debug("Error checking availability:",e),!1}},name:r,options:a,async sendEmail(e){try{const l=j(e);if(l.length>0)return{error:new m(r,`Invalid email options: ${l.join(", ")}`),success:!1};await p.ensureInitialized(()=>this.initialize(),r);const s=o=>Array.isArray(o)?o.map(d=>d.email):[o.email],t={to:e.subscriber??(Array.isArray(e.to)?e.to[0]?.email:e.to.email)};if(e.from&&(t.from=e.from.email,e.from.name&&(t.from_name=e.from.name)),e.subject&&(t.subject=e.subject),e.html?t.body=e.html:e.text&&(t.body=e.text),e.html&&e.text&&(t.text=e.text),e.cc&&(t.cc=s(e.cc)),e.bcc&&(t.bcc=s(e.bcc)),e.replyTo&&(t.reply_to=e.replyTo.email,e.replyTo.name&&(t.reply_to_name=e.replyTo.name)),e.templateId&&(t.template=e.templateId),e.data&&(t.data=e.data),e.subscriberId&&(t.subscriber_id=e.subscriberId),e.headers){const o=A(e.headers),d={};Object.entries(o).forEach(([w,I])=>{d[k(w)]=z(I)}),t.headers=d}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async o=>({content:await x(o,r),filename:o.filename,type:o.contentType??"application/octet-stream"})))),i.debug("Sending email via Plunk API",{subject:t.subject,to:t.to});const v={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"},c=await g(async()=>b(`${a.endpoint}/send`,{headers:v,method:"POST",timeout:a.timeout},JSON.stringify(t)),a.retries);if(!c.success)return i.debug("API request failed when sending email",c.error),{error:c.error??new m(r,"Failed to send email"),success:!1};const u=c.data,f=u?.body&&typeof u.body=="object"?u.body.id??u.body.messageId??y():y();return i.debug("Email sent successfully",{messageId:f}),{data:{messageId:f,provider:r,response:c.data,sent:!0,timestamp:new Date},success:!0}}catch(l){return{error:h(r,"send email",l,i),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{U as default};
1
+ import m from"./EmailError-B-sEf3bp.js";import P from"./RequiredOptionError-DuNNY_a5.js";import{e as y}from"./generate-message-id-gXAuMz4g.js";import{s as A}from"./headers-to-record-De1Eg951.js";import{m as b}from"./make-request-B9XjBynA.js";import{i as g}from"./retry-ipI5DRJ8.js";import{s as k,a as z}from"./sanitize-header-DtQwAnzg.js";import{f as j}from"./validate-email-options-mCM9dVug.js";import{defineProvider as E}from"./defineProvider-C9q-7iwt.js";import{P as T,h,c as K}from"./provider-base-C7PuopYK.js";import{p as x}from"./attachment-processor-CMp7qqMI.js";const r="plunk",_="https://api.useplunk.com/v1",S=3e4,q=3,U=E((n={})=>{if(!n.apiKey)throw new P(r,"apiKey");const a={apiKey:n.apiKey,debug:n.debug??!1,endpoint:n.endpoint??_,logger:n.logger,retries:n.retries??q,timeout:n.timeout??S},p=new T,i=K(r,n.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new m(r,"Email ID is required to retrieve email details"),success:!1};await p.ensureInitialized(()=>this.initialize(),r);const l={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"};i.debug("Retrieving email details",{id:e});const s=await g(async()=>b(`${a.endpoint}/emails/${e}`,{headers:l,method:"GET",timeout:a.timeout}),a.retries);return s.success?(i.debug("Email details retrieved successfully"),{data:s.data?.body,success:!0}):(i.debug("API request failed when retrieving email",s.error),{error:new m(r,`Failed to retrieve email: ${s.error instanceof Error?s.error.message:"Unknown error"}`,{cause:s.error}),success:!1})}catch(l){return{error:h(r,"retrieve email",l,i),success:!1}}},async initialize(){await p.ensureInitialized(async()=>{if(!await this.isAvailable())throw new m(r,"Plunk API not available or invalid API key");i.debug("Provider initialized successfully")},r)},async isAvailable(){try{return a.apiKey&&a.apiKey.length>0?(i.debug("API key exists, assuming Plunk is available"),!0):!1}catch(e){return i.debug("Error checking availability:",e),!1}},name:r,options:a,async sendEmail(e){try{const l=j(e);if(l.length>0)return{error:new m(r,`Invalid email options: ${l.join(", ")}`),success:!1};await p.ensureInitialized(()=>this.initialize(),r);const s=o=>Array.isArray(o)?o.map(d=>d.email):[o.email],t={to:e.subscriber??(Array.isArray(e.to)?e.to[0]?.email:e.to.email)};if(e.from&&(t.from=e.from.email,e.from.name&&(t.from_name=e.from.name)),e.subject&&(t.subject=e.subject),e.html?t.body=e.html:e.text&&(t.body=e.text),e.html&&e.text&&(t.text=e.text),e.cc&&(t.cc=s(e.cc)),e.bcc&&(t.bcc=s(e.bcc)),e.replyTo&&(t.reply_to=e.replyTo.email,e.replyTo.name&&(t.reply_to_name=e.replyTo.name)),e.templateId&&(t.template=e.templateId),e.data&&(t.data=e.data),e.subscriberId&&(t.subscriber_id=e.subscriberId),e.headers){const o=A(e.headers),d={};Object.entries(o).forEach(([w,I])=>{d[k(w)]=z(I)}),t.headers=d}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async o=>({content:await x(o,r),filename:o.filename,type:o.contentType??"application/octet-stream"})))),i.debug("Sending email via Plunk API",{subject:t.subject,to:t.to});const v={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"},c=await g(async()=>b(`${a.endpoint}/send`,{headers:v,method:"POST",timeout:a.timeout},JSON.stringify(t)),a.retries);if(!c.success)return i.debug("API request failed when sending email",c.error),{error:c.error??new m(r,"Failed to send email"),success:!1};const u=c.data,f=u?.body&&typeof u.body=="object"?u.body.id??u.body.messageId??y():y();return i.debug("Email sent successfully",{messageId:f}),{data:{messageId:f,provider:r,response:c.data,sent:!0,timestamp:new Date},success:!0}}catch(l){return{error:h(r,"send email",l,i),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{U as default};
@@ -1 +1 @@
1
- import l from"./EmailError-B-sEf3bp.js";import g from"./RequiredOptionError-DuNNY_a5.js";import{e as w}from"./generate-message-id-gXAuMz4g.js";import{s as P}from"./headers-to-record-De1Eg951.js";import{m}from"./make-request-BlK_B72c.js";import{u as f}from"./retry-3pnxTuNs.js";import{f as I}from"./validate-email-options-mCM9dVug.js";import{defineProvider as A}from"./defineProvider-C9q-7iwt.js";import{P as C,c as E}from"./provider-base-C7PuopYK.js";import{l as u,m as h}from"./address-formatter-BWR2Dddx.js";import{p as T}from"./attachment-processor-CMp7qqMI.js";const a="postal",j=3e4,K=3,R=A((r={})=>{if(!r.host)throw new g(a,"host");if(!r.apiKey)throw new g(a,"apiKey");const y=r.endpoint??`https://${r.host}/api/v1`,i={apiKey:r.apiKey,debug:r.debug??!1,endpoint:y,host:r.host,retries:r.retries??K,timeout:r.timeout??j,...r.logger&&{logger:r.logger}},d=new C,o=E(a,r.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new l(a,"Email ID is required to retrieve email details"),success:!1};await d.ensureInitialized(()=>this.initialize(),a);const t={"Content-Type":"application/json","X-Server-API-Key":i.apiKey};o.debug("Retrieving email details",{id:e});const s=await f(async()=>m(`${i.endpoint}/messages/${e}`,{headers:t,method:"GET",timeout:i.timeout}),i.retries);return s.success?(o.debug("Email details retrieved successfully"),{data:s.data?.body,success:!0}):(o.debug("API request failed when retrieving email",s.error),{error:new l(a,`Failed to retrieve email: ${s.error instanceof Error?s.error.message:"Unknown error"}`,{cause:s.error}),success:!1})}catch(t){return o.debug("Exception retrieving email",t),{error:new l(a,`Failed to retrieve email: ${t.message}`,{cause:t}),success:!1}}},async initialize(){await d.ensureInitialized(async()=>{if(!await this.isAvailable())throw new l(a,"Postal API not available or invalid API key");o.debug("Provider initialized successfully")},a)},async isAvailable(){try{const e={"Content-Type":"application/json","X-Server-API-Key":i.apiKey};o.debug("Checking Postal API availability");const t=await m(`${i.endpoint}/server`,{headers:e,method:"GET",timeout:i.timeout});return o.debug("Postal 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 o.debug("Error checking availability:",e),!1}},name:a,options:i,async sendEmail(e){try{const t=I(e);if(t.length>0)return{error:new l(a,`Invalid email options: ${t.join(", ")}`),success:!1};await d.ensureInitialized(()=>this.initialize(),a);const s={from:h(e.from).address,subject:e.subject,to:u(e.to).map(n=>n.address)};if(e.html&&(s.html_body=e.html),e.text&&(s.plain_body=e.text),e.cc&&(s.cc=u(e.cc).map(n=>n.address)),e.bcc&&(s.bcc=u(e.bcc).map(n=>n.address)),e.replyTo&&(s.reply_to=h(e.replyTo).address),e.templateId&&(s.template_id=e.templateId,e.templateVariables&&(s.template_variables=e.templateVariables)),e.tags&&e.tags.length>0&&(s.tag=e.tags.join(",")),e.headers){const n=P(e.headers);s.headers=n}e.attachments&&e.attachments.length>0&&(s.attachments=await Promise.all(e.attachments.map(async n=>{const v=await T(n,a);return{content_type:n.contentType??"application/octet-stream",data:v,name:n.filename}}))),o.debug("Sending email via Postal API",{subject:s.subject,to:s.to});const b={"Content-Type":"application/json","X-Server-API-Key":i.apiKey},c=await f(async()=>m(`${i.endpoint}/send/message`,{headers:b,method:"POST",timeout:i.timeout},JSON.stringify(s)),i.retries);if(!c.success)return o.debug("API request failed when sending email",c.error),{error:c.error??new l(a,"Failed to send email"),success:!1};const p=c.data?.body?.message_id?.toString()??w();return o.debug("Email sent successfully",{messageId:p}),{data:{messageId:p,provider:a,response:c.data,sent:!0,timestamp:new Date},success:!0}}catch(t){return o.debug("Exception sending email",t),{error:new l(a,`Failed to send email: ${t.message}`,{cause:t}),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{R as default};
1
+ import l from"./EmailError-B-sEf3bp.js";import g from"./RequiredOptionError-DuNNY_a5.js";import{e as w}from"./generate-message-id-gXAuMz4g.js";import{s as P}from"./headers-to-record-De1Eg951.js";import{m}from"./make-request-B9XjBynA.js";import{i as f}from"./retry-ipI5DRJ8.js";import{f as I}from"./validate-email-options-mCM9dVug.js";import{defineProvider as A}from"./defineProvider-C9q-7iwt.js";import{P as C,c as E}from"./provider-base-C7PuopYK.js";import{l as u,m as h}from"./address-formatter-BWR2Dddx.js";import{p as T}from"./attachment-processor-CMp7qqMI.js";const a="postal",j=3e4,K=3,R=A((r={})=>{if(!r.host)throw new g(a,"host");if(!r.apiKey)throw new g(a,"apiKey");const y=r.endpoint??`https://${r.host}/api/v1`,i={apiKey:r.apiKey,debug:r.debug??!1,endpoint:y,host:r.host,retries:r.retries??K,timeout:r.timeout??j,...r.logger&&{logger:r.logger}},d=new C,o=E(a,r.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new l(a,"Email ID is required to retrieve email details"),success:!1};await d.ensureInitialized(()=>this.initialize(),a);const t={"Content-Type":"application/json","X-Server-API-Key":i.apiKey};o.debug("Retrieving email details",{id:e});const s=await f(async()=>m(`${i.endpoint}/messages/${e}`,{headers:t,method:"GET",timeout:i.timeout}),i.retries);return s.success?(o.debug("Email details retrieved successfully"),{data:s.data?.body,success:!0}):(o.debug("API request failed when retrieving email",s.error),{error:new l(a,`Failed to retrieve email: ${s.error instanceof Error?s.error.message:"Unknown error"}`,{cause:s.error}),success:!1})}catch(t){return o.debug("Exception retrieving email",t),{error:new l(a,`Failed to retrieve email: ${t.message}`,{cause:t}),success:!1}}},async initialize(){await d.ensureInitialized(async()=>{if(!await this.isAvailable())throw new l(a,"Postal API not available or invalid API key");o.debug("Provider initialized successfully")},a)},async isAvailable(){try{const e={"Content-Type":"application/json","X-Server-API-Key":i.apiKey};o.debug("Checking Postal API availability");const t=await m(`${i.endpoint}/server`,{headers:e,method:"GET",timeout:i.timeout});return o.debug("Postal 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 o.debug("Error checking availability:",e),!1}},name:a,options:i,async sendEmail(e){try{const t=I(e);if(t.length>0)return{error:new l(a,`Invalid email options: ${t.join(", ")}`),success:!1};await d.ensureInitialized(()=>this.initialize(),a);const s={from:h(e.from).address,subject:e.subject,to:u(e.to).map(n=>n.address)};if(e.html&&(s.html_body=e.html),e.text&&(s.plain_body=e.text),e.cc&&(s.cc=u(e.cc).map(n=>n.address)),e.bcc&&(s.bcc=u(e.bcc).map(n=>n.address)),e.replyTo&&(s.reply_to=h(e.replyTo).address),e.templateId&&(s.template_id=e.templateId,e.templateVariables&&(s.template_variables=e.templateVariables)),e.tags&&e.tags.length>0&&(s.tag=e.tags.join(",")),e.headers){const n=P(e.headers);s.headers=n}e.attachments&&e.attachments.length>0&&(s.attachments=await Promise.all(e.attachments.map(async n=>{const v=await T(n,a);return{content_type:n.contentType??"application/octet-stream",data:v,name:n.filename}}))),o.debug("Sending email via Postal API",{subject:s.subject,to:s.to});const b={"Content-Type":"application/json","X-Server-API-Key":i.apiKey},c=await f(async()=>m(`${i.endpoint}/send/message`,{headers:b,method:"POST",timeout:i.timeout},JSON.stringify(s)),i.retries);if(!c.success)return o.debug("API request failed when sending email",c.error),{error:c.error??new l(a,"Failed to send email"),success:!1};const p=c.data?.body?.message_id?.toString()??w();return o.debug("Email sent successfully",{messageId:p}),{data:{messageId:p,provider:a,response:c.data,sent:!0,timestamp:new Date},success:!0}}catch(t){return o.debug("Exception sending email",t),{error:new l(a,`Failed to send email: ${t.message}`,{cause:t}),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{R as default};
@@ -1 +1 @@
1
- import d from"./EmailError-B-sEf3bp.js";import T from"./RequiredOptionError-DuNNY_a5.js";import{e as P}from"./generate-message-id-gXAuMz4g.js";import{s as w}from"./headers-to-record-De1Eg951.js";import{m as u}from"./make-request-BlK_B72c.js";import{u as f}from"./retry-3pnxTuNs.js";import{a as I,s as A}from"./sanitize-header-DtQwAnzg.js";import{f as C}from"./validate-email-options-mCM9dVug.js";import{defineProvider as S}from"./defineProvider-C9q-7iwt.js";import{P as j,h,c as E}from"./provider-base-C7PuopYK.js";import{e as p,g as v}from"./address-formatter-BWR2Dddx.js";import{b as z}from"./attachment-processor-CMp7qqMI.js";const r="postmark",M="https://api.postmarkapp.com",O=3e4,H=3,U=S((o={})=>{if(!o.serverToken)throw new T(r,"serverToken");const s={debug:o.debug??!1,endpoint:o.endpoint??M,retries:o.retries??H,serverToken:o.serverToken,timeout:o.timeout??O,...o.logger&&{logger:o.logger}},m=new j,i=E(r,o.logger);return{endpoint:s.endpoint,features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new d(r,"Email ID is required to retrieve email details"),success:!1};await m.ensureInitialized(()=>this.initialize(),r);const a={"Content-Type":"application/json","X-Postmark-Server-Token":s.serverToken};i.debug("Retrieving email details",{id:e});const t=await f(async()=>u(`${s.endpoint}/messages/outbound/${e}/details`,{headers:a,method:"GET",timeout:s.timeout}),s.retries);return t.success?(i.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(i.debug("API request failed when retrieving email",t.error),{error:new d(r,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(a){return{error:h(r,"retrieve email",a,i),success:!1}}},async initialize(){await m.ensureInitialized(async()=>{if(!await this.isAvailable())throw new d(r,"Postmark API not available or invalid server token");i.debug("Provider initialized successfully")},r)},async isAvailable(){try{const e={"Content-Type":"application/json","X-Postmark-Server-Token":s.serverToken};i.debug("Checking Postmark API availability");const a=await u(`${s.endpoint}/server`,{headers:e,method:"GET",timeout:s.timeout});return i.debug("Postmark API availability check response:",{error:a.error instanceof Error?a.error.message:void 0,statusCode:a.data?.statusCode,success:a.success}),!!(a.success&&a.data&&typeof a.data=="object"&&"statusCode"in a.data&&typeof a.data.statusCode=="number"&&a.data.statusCode>=200&&a.data.statusCode<300)}catch(e){return i.debug("Error checking availability:",e),!1}},name:r,options:s,async sendEmail(e){try{const a=C(e);if(a.length>0)return{error:new d(r,`Invalid email options: ${a.join(", ")}`),success:!1};await m.ensureInitialized(()=>this.initialize(),r);const t={From:v(e.from),Subject:e.subject,To:p(e.to).join(",")};if(e.html&&(t.HtmlBody=e.html),e.text&&(t.TextBody=e.text),e.cc&&(t.Cc=p(e.cc).join(",")),e.bcc&&(t.Bcc=p(e.bcc).join(",")),e.replyTo&&(t.ReplyTo=v(e.replyTo)),e.templateId?(t.TemplateId=e.templateId,e.templateModel&&(t.TemplateModel=e.templateModel)):e.templateAlias&&(t.TemplateAlias=e.templateAlias,e.templateModel&&(t.TemplateModel=e.templateModel)),e.trackOpens!==void 0&&(t.TrackOpens=e.trackOpens),e.trackLinks!==void 0&&(t.TrackLinks=e.trackLinks),e.inlineCss!==void 0&&(t.InlineCss=e.inlineCss),e.messageStream&&(t.MessageStream=e.messageStream),e.metadata&&(t.Metadata=e.metadata),e.tags&&e.tags.length>0){const[l]=e.tags;t.Tag=l}if(e.headers){const l=w(e.headers),c=[];for(const[b,y]of Object.entries(l))c.push({Name:A(b),Value:I(String(y))});c.length>0&&(t.Headers=c)}e.attachments&&e.attachments.length>0&&(t.Attachments=await Promise.all(e.attachments.map(async l=>z(l,r)))),i.debug("Sending email via Postmark API",{subject:t.Subject,to:t.To});const k={"Content-Type":"application/json","X-Postmark-Server-Token":s.serverToken},n=await f(async()=>u(`${s.endpoint}/email`,{headers:k,method:"POST",timeout:s.timeout},JSON.stringify(t)),s.retries);if(!n.success)return i.debug("API request failed when sending email",n.error),{error:n.error??new d(r,"Failed to send email"),success:!1};const g=n.data?.body?.MessageID??P();return i.debug("Email sent successfully",{messageId:g}),{data:{messageId:g,provider:r,response:n.data,sent:!0,timestamp:new Date},success:!0}}catch(a){return{error:h(r,"send email",a,i),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{U as default};
1
+ import d from"./EmailError-B-sEf3bp.js";import T from"./RequiredOptionError-DuNNY_a5.js";import{e as P}from"./generate-message-id-gXAuMz4g.js";import{s as w}from"./headers-to-record-De1Eg951.js";import{m as u}from"./make-request-B9XjBynA.js";import{i as f}from"./retry-ipI5DRJ8.js";import{a as I,s as A}from"./sanitize-header-DtQwAnzg.js";import{f as C}from"./validate-email-options-mCM9dVug.js";import{defineProvider as S}from"./defineProvider-C9q-7iwt.js";import{P as j,h,c as E}from"./provider-base-C7PuopYK.js";import{e as p,g as v}from"./address-formatter-BWR2Dddx.js";import{b as z}from"./attachment-processor-CMp7qqMI.js";const r="postmark",M="https://api.postmarkapp.com",O=3e4,H=3,U=S((o={})=>{if(!o.serverToken)throw new T(r,"serverToken");const s={debug:o.debug??!1,endpoint:o.endpoint??M,retries:o.retries??H,serverToken:o.serverToken,timeout:o.timeout??O,...o.logger&&{logger:o.logger}},m=new j,i=E(r,o.logger);return{endpoint:s.endpoint,features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new d(r,"Email ID is required to retrieve email details"),success:!1};await m.ensureInitialized(()=>this.initialize(),r);const a={"Content-Type":"application/json","X-Postmark-Server-Token":s.serverToken};i.debug("Retrieving email details",{id:e});const t=await f(async()=>u(`${s.endpoint}/messages/outbound/${e}/details`,{headers:a,method:"GET",timeout:s.timeout}),s.retries);return t.success?(i.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(i.debug("API request failed when retrieving email",t.error),{error:new d(r,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(a){return{error:h(r,"retrieve email",a,i),success:!1}}},async initialize(){await m.ensureInitialized(async()=>{if(!await this.isAvailable())throw new d(r,"Postmark API not available or invalid server token");i.debug("Provider initialized successfully")},r)},async isAvailable(){try{const e={"Content-Type":"application/json","X-Postmark-Server-Token":s.serverToken};i.debug("Checking Postmark API availability");const a=await u(`${s.endpoint}/server`,{headers:e,method:"GET",timeout:s.timeout});return i.debug("Postmark API availability check response:",{error:a.error instanceof Error?a.error.message:void 0,statusCode:a.data?.statusCode,success:a.success}),!!(a.success&&a.data&&typeof a.data=="object"&&"statusCode"in a.data&&typeof a.data.statusCode=="number"&&a.data.statusCode>=200&&a.data.statusCode<300)}catch(e){return i.debug("Error checking availability:",e),!1}},name:r,options:s,async sendEmail(e){try{const a=C(e);if(a.length>0)return{error:new d(r,`Invalid email options: ${a.join(", ")}`),success:!1};await m.ensureInitialized(()=>this.initialize(),r);const t={From:v(e.from),Subject:e.subject,To:p(e.to).join(",")};if(e.html&&(t.HtmlBody=e.html),e.text&&(t.TextBody=e.text),e.cc&&(t.Cc=p(e.cc).join(",")),e.bcc&&(t.Bcc=p(e.bcc).join(",")),e.replyTo&&(t.ReplyTo=v(e.replyTo)),e.templateId?(t.TemplateId=e.templateId,e.templateModel&&(t.TemplateModel=e.templateModel)):e.templateAlias&&(t.TemplateAlias=e.templateAlias,e.templateModel&&(t.TemplateModel=e.templateModel)),e.trackOpens!==void 0&&(t.TrackOpens=e.trackOpens),e.trackLinks!==void 0&&(t.TrackLinks=e.trackLinks),e.inlineCss!==void 0&&(t.InlineCss=e.inlineCss),e.messageStream&&(t.MessageStream=e.messageStream),e.metadata&&(t.Metadata=e.metadata),e.tags&&e.tags.length>0){const[l]=e.tags;t.Tag=l}if(e.headers){const l=w(e.headers),c=[];for(const[b,y]of Object.entries(l))c.push({Name:A(b),Value:I(String(y))});c.length>0&&(t.Headers=c)}e.attachments&&e.attachments.length>0&&(t.Attachments=await Promise.all(e.attachments.map(async l=>z(l,r)))),i.debug("Sending email via Postmark API",{subject:t.Subject,to:t.To});const k={"Content-Type":"application/json","X-Postmark-Server-Token":s.serverToken},n=await f(async()=>u(`${s.endpoint}/email`,{headers:k,method:"POST",timeout:s.timeout},JSON.stringify(t)),s.retries);if(!n.success)return i.debug("API request failed when sending email",n.error),{error:n.error??new d(r,"Failed to send email"),success:!1};const g=n.data?.body?.MessageID??P();return i.debug("Email sent successfully",{messageId:g}),{data:{messageId:g,provider:r,response:n.data,sent:!0,timestamp:new Date},success:!0}}catch(a){return{error:h(r,"send email",a,i),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{U as default};
@@ -1 +1 @@
1
- import c from"./EmailError-B-sEf3bp.js";import w from"./RequiredOptionError-DuNNY_a5.js";import{e as I}from"./generate-message-id-gXAuMz4g.js";import{s as P}from"./headers-to-record-De1Eg951.js";import{m as p}from"./make-request-BlK_B72c.js";import{u as y}from"./retry-3pnxTuNs.js";import{f as j}from"./validate-email-options-mCM9dVug.js";import{defineProvider as C}from"./defineProvider-C9q-7iwt.js";import{P as E,h as f,c as T}from"./provider-base-C7PuopYK.js";import{e as z,g as b,d as v}from"./address-formatter-BWR2Dddx.js";import{p as k}from"./attachment-processor-CMp7qqMI.js";const i="resend",S="https://api.resend.com",K=3e4,R=3,_=r=>{const a=[],d=/^[\w-]+$/;return d.test(r.name)||a.push(`Tag name '${r.name}' must only contain ASCII letters, numbers, underscores, or dashes`),r.name.length>256&&a.push(`Tag name '${r.name}' exceeds maximum length of 256 characters`),d.test(r.value)||a.push(`Tag value '${r.value}' for tag '${r.name}' must only contain ASCII letters, numbers, underscores, or dashes`),a},U=C((r={})=>{if(!r.apiKey)throw new w(i,"apiKey");const a={apiKey:r.apiKey,debug:r.debug??!1,endpoint:r.endpoint??S,logger:r.logger,retries:r.retries??R,timeout:r.timeout??K},d=new E,n=T(i,r.logger);return{endpoint:a.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(i,"Email ID is required to retrieve email details"),success:!1};await d.ensureInitialized(()=>this.initialize(),i);const t={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"};n.debug("Retrieving email details",{id:e});const s=await y(async()=>p(`${a.endpoint}/emails/${e}`,{headers:t,method:"GET",timeout:a.timeout}),a.retries);return s.success?(n.debug("Email details retrieved successfully"),{data:s.data?.body,success:!0}):(n.debug("API request failed when retrieving email",s.error),{error:new c(i,`Failed to retrieve email: ${s.error instanceof Error?s.error.message:"Unknown error"}`,{cause:s.error}),success:!1})}catch(t){return{error:f(i,"retrieve email",t,n),success:!1}}},async initialize(){await d.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(i,"Resend API not available or invalid API key");n.debug("Provider initialized successfully")},i)},async isAvailable(){try{if(a.apiKey&&a.apiKey.startsWith("re_"))return n.debug("API key format is valid, assuming Resend is available"),!0;const e={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"};n.debug("Checking Resend API availability");const t=await p(`${a.endpoint}/domains`,{headers:e,method:"GET",timeout:a.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:i,options:a,async sendEmail(e){try{const t=j(e);if(t.length>0)return{error:new c(i,`Invalid email options: ${t.join(", ")}`),success:!1};await d.ensureInitialized(()=>this.initialize(),i);const s={from:b(e.from),headers:e.headers?P(e.headers):{},html:e.html,subject:e.subject,text:e.text,to:z(e.to)};if(e.cc&&(s.cc=v(e.cc)),e.bcc&&(s.bcc=v(e.bcc)),e.replyTo&&(s.reply_to=b(e.replyTo)),e.templateId&&(s.template=e.templateId,e.templateData&&(s.data=e.templateData)),e.scheduledAt&&(s.scheduled_at=typeof e.scheduledAt=="string"?e.scheduledAt:e.scheduledAt.toISOString()),e.tags&&e.tags.length>0){const o=[];if(e.tags.forEach(m=>{const g=_(m);g.length>0&&o.push(...g)}),o.length>0)return{error:new c(i,`Invalid email tags: ${o.join(", ")}`),success:!1};s.tags=e.tags.map(m=>({name:m.name,value:m.value}))}e.attachments&&e.attachments.length>0&&(s.attachments=await Promise.all(e.attachments.map(async o=>({content:await k(o,i),content_type:o.contentType,filename:o.filename,...o.path&&{path:o.path}})))),n.debug("Sending email via Resend API",{subject:s.subject,to:s.to});const A={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"},u=await y(async()=>p(`${a.endpoint}/emails`,{headers:A,method:"POST",timeout:a.timeout},JSON.stringify(s)),a.retries);if(!u.success)return n.debug("API request failed when sending email",u.error),{error:u.error??new c(i,"Failed to send email"),success:!1};const l=u.data,h=l?.body&&typeof l.body=="object"&&l.body.id?l.body.id:I();return n.debug("Email sent successfully",{messageId:h}),{data:{messageId:h,provider:i,response:u.data,sent:!0,timestamp:new Date},success:!0}}catch(t){return{error:f(i,"send email",t,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{U as default};
1
+ import c from"./EmailError-B-sEf3bp.js";import w from"./RequiredOptionError-DuNNY_a5.js";import{e as I}from"./generate-message-id-gXAuMz4g.js";import{s as P}from"./headers-to-record-De1Eg951.js";import{m as p}from"./make-request-B9XjBynA.js";import{i as y}from"./retry-ipI5DRJ8.js";import{f as j}from"./validate-email-options-mCM9dVug.js";import{defineProvider as C}from"./defineProvider-C9q-7iwt.js";import{P as E,h as f,c as T}from"./provider-base-C7PuopYK.js";import{e as z,g as b,d as v}from"./address-formatter-BWR2Dddx.js";import{p as k}from"./attachment-processor-CMp7qqMI.js";const i="resend",S="https://api.resend.com",K=3e4,R=3,_=r=>{const a=[],d=/^[\w-]+$/;return d.test(r.name)||a.push(`Tag name '${r.name}' must only contain ASCII letters, numbers, underscores, or dashes`),r.name.length>256&&a.push(`Tag name '${r.name}' exceeds maximum length of 256 characters`),d.test(r.value)||a.push(`Tag value '${r.value}' for tag '${r.name}' must only contain ASCII letters, numbers, underscores, or dashes`),a},U=C((r={})=>{if(!r.apiKey)throw new w(i,"apiKey");const a={apiKey:r.apiKey,debug:r.debug??!1,endpoint:r.endpoint??S,logger:r.logger,retries:r.retries??R,timeout:r.timeout??K},d=new E,n=T(i,r.logger);return{endpoint:a.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(i,"Email ID is required to retrieve email details"),success:!1};await d.ensureInitialized(()=>this.initialize(),i);const t={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"};n.debug("Retrieving email details",{id:e});const s=await y(async()=>p(`${a.endpoint}/emails/${e}`,{headers:t,method:"GET",timeout:a.timeout}),a.retries);return s.success?(n.debug("Email details retrieved successfully"),{data:s.data?.body,success:!0}):(n.debug("API request failed when retrieving email",s.error),{error:new c(i,`Failed to retrieve email: ${s.error instanceof Error?s.error.message:"Unknown error"}`,{cause:s.error}),success:!1})}catch(t){return{error:f(i,"retrieve email",t,n),success:!1}}},async initialize(){await d.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(i,"Resend API not available or invalid API key");n.debug("Provider initialized successfully")},i)},async isAvailable(){try{if(a.apiKey&&a.apiKey.startsWith("re_"))return n.debug("API key format is valid, assuming Resend is available"),!0;const e={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"};n.debug("Checking Resend API availability");const t=await p(`${a.endpoint}/domains`,{headers:e,method:"GET",timeout:a.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:i,options:a,async sendEmail(e){try{const t=j(e);if(t.length>0)return{error:new c(i,`Invalid email options: ${t.join(", ")}`),success:!1};await d.ensureInitialized(()=>this.initialize(),i);const s={from:b(e.from),headers:e.headers?P(e.headers):{},html:e.html,subject:e.subject,text:e.text,to:z(e.to)};if(e.cc&&(s.cc=v(e.cc)),e.bcc&&(s.bcc=v(e.bcc)),e.replyTo&&(s.reply_to=b(e.replyTo)),e.templateId&&(s.template=e.templateId,e.templateData&&(s.data=e.templateData)),e.scheduledAt&&(s.scheduled_at=typeof e.scheduledAt=="string"?e.scheduledAt:e.scheduledAt.toISOString()),e.tags&&e.tags.length>0){const o=[];if(e.tags.forEach(m=>{const g=_(m);g.length>0&&o.push(...g)}),o.length>0)return{error:new c(i,`Invalid email tags: ${o.join(", ")}`),success:!1};s.tags=e.tags.map(m=>({name:m.name,value:m.value}))}e.attachments&&e.attachments.length>0&&(s.attachments=await Promise.all(e.attachments.map(async o=>({content:await k(o,i),content_type:o.contentType,filename:o.filename,...o.path&&{path:o.path}})))),n.debug("Sending email via Resend API",{subject:s.subject,to:s.to});const A={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"},l=await y(async()=>p(`${a.endpoint}/emails`,{headers:A,method:"POST",timeout:a.timeout},JSON.stringify(s)),a.retries);if(!l.success)return n.debug("API request failed when sending email",l.error),{error:l.error??new c(i,"Failed to send email"),success:!1};const u=l.data,h=u?.body&&typeof u.body=="object"&&u.body.id?u.body.id:I();return n.debug("Email sent successfully",{messageId:h}),{data:{messageId:h,provider:i,response:l.data,sent:!0,timestamp:new Date},success:!0}}catch(t){return{error:f(i,"send email",t,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{U as default};
@@ -0,0 +1 @@
1
+ import c from"./EmailError-B-sEf3bp.js";import{R as i}from"./make-request-B9XjBynA.js";const m=new Set([408,429,503]),u=r=>{const{statusCode:t}=r.data??{};return t!==void 0?m.has(t):!(r.error instanceof c&&r.error.code===i)},a=async(r,t=3,s=300,e=u)=>{try{const o=await r();return o.success||t<=0||!e(o)?o:(await new Promise(n=>{setTimeout(()=>{n()},s)}),a(r,t-1,s*2,e))}catch(o){return t<=0?{error:o instanceof Error?o:new Error(String(o)),success:!1}:(await new Promise(n=>{setTimeout(()=>{n()},s)}),a(r,t-1,s*2,e))}};export{a as i};
@@ -1 +1 @@
1
- import c from"./EmailError-B-sEf3bp.js";import p from"./RequiredOptionError-DuNNY_a5.js";import{e as w}from"./generate-message-id-gXAuMz4g.js";import{s as v}from"./headers-to-record-De1Eg951.js";import{m as f}from"./make-request-BlK_B72c.js";import{u as g}from"./retry-3pnxTuNs.js";import{f as I}from"./validate-email-options-mCM9dVug.js";import{defineProvider as A}from"./defineProvider-C9q-7iwt.js";import{P,h,c as j}from"./provider-base-C7PuopYK.js";import{f as d,a as T}from"./address-formatter-BWR2Dddx.js";import{p as S}from"./attachment-processor-CMp7qqMI.js";const r="scaleway",k="https://api.scaleway.com/transactional-email/v1alpha1",E=3e4,z=3,H=A((a={})=>{if(!a.apiKey)throw new p(r,"apiKey");if(!a.region)throw new p(r,"region");const y=a.endpoint??k,i={apiKey:a.apiKey,debug:a.debug??!1,endpoint:y,region:a.region,retries:a.retries??z,timeout:a.timeout??E,...a.logger&&{logger:a.logger}},m=new P,s=j(r,a.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!0,tracking:!1},async getEmail(e){try{if(!e)return{error:new c(r,"Email ID is required to retrieve email details"),success:!1};await m.ensureInitialized(()=>this.initialize(),r);const n={"Content-Type":"application/json","X-Auth-Token":i.apiKey};s.debug("Retrieving email details",{id:e});const t=await g(async()=>f(`${i.endpoint}/regions/${i.region}/emails/${e}`,{headers:n,method:"GET",timeout:i.timeout}),i.retries);return t.success?(s.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(s.debug("API request failed when retrieving email",t.error),{error:new c(r,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(n){return{error:h(r,"retrieve email",n,s),success:!1}}},async initialize(){await m.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(r,"Scaleway API not available or invalid API key");s.debug("Provider initialized successfully")},r)},async isAvailable(){try{return s.debug("Checking Scaleway API availability"),!0}catch(e){return s.debug("Error checking availability:",e),!1}},name:r,options:i,async sendEmail(e){try{const n=I(e);if(n.length>0)return{error:new c(r,`Invalid email options: ${n.join(", ")}`),success:!1};await m.ensureInitialized(()=>this.initialize(),r);const t={from:{email:e.from.email,...e.from.name&&{name:e.from.name}},subject:e.subject,to:d(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=d(e.cc)),e.bcc&&(t.bcc=d(e.bcc)),e.replyTo&&(t.replyTo=T(e.replyTo)),e.templateId&&(t.templateId=e.templateId,e.templateVariables&&(t.templateVariables=e.templateVariables)),e.projectId&&(t.projectId=e.projectId),e.headers){const l=v(e.headers);t.headers=l}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async l=>({content:await S(l,r),name:l.filename,type:l.contentType??"application/octet-stream"})))),s.debug("Sending email via Scaleway API",{subject:t.subject,to:t.to});const b={"Content-Type":"application/json","X-Auth-Token":i.apiKey},o=await g(async()=>f(`${i.endpoint}/regions/${i.region}/emails`,{headers:b,method:"POST",timeout:i.timeout},JSON.stringify(t)),i.retries);if(!o.success)return s.debug("API request failed when sending email",o.error),{error:o.error??new c(r,"Failed to send email"),success:!1};const u=o.data?.body?.id??w();return s.debug("Email sent successfully",{messageId:u}),{data:{messageId:u,provider:r,response:o.data,sent:!0,timestamp:new Date},success:!0}}catch(n){return{error:h(r,"send email",n,s),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{H as default};
1
+ import c from"./EmailError-B-sEf3bp.js";import p from"./RequiredOptionError-DuNNY_a5.js";import{e as w}from"./generate-message-id-gXAuMz4g.js";import{s as v}from"./headers-to-record-De1Eg951.js";import{m as f}from"./make-request-B9XjBynA.js";import{i as g}from"./retry-ipI5DRJ8.js";import{f as I}from"./validate-email-options-mCM9dVug.js";import{defineProvider as A}from"./defineProvider-C9q-7iwt.js";import{P,h,c as j}from"./provider-base-C7PuopYK.js";import{f as d,a as T}from"./address-formatter-BWR2Dddx.js";import{p as S}from"./attachment-processor-CMp7qqMI.js";const r="scaleway",k="https://api.scaleway.com/transactional-email/v1alpha1",E=3e4,z=3,H=A((a={})=>{if(!a.apiKey)throw new p(r,"apiKey");if(!a.region)throw new p(r,"region");const y=a.endpoint??k,i={apiKey:a.apiKey,debug:a.debug??!1,endpoint:y,region:a.region,retries:a.retries??z,timeout:a.timeout??E,...a.logger&&{logger:a.logger}},m=new P,s=j(r,a.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!0,tracking:!1},async getEmail(e){try{if(!e)return{error:new c(r,"Email ID is required to retrieve email details"),success:!1};await m.ensureInitialized(()=>this.initialize(),r);const n={"Content-Type":"application/json","X-Auth-Token":i.apiKey};s.debug("Retrieving email details",{id:e});const t=await g(async()=>f(`${i.endpoint}/regions/${i.region}/emails/${e}`,{headers:n,method:"GET",timeout:i.timeout}),i.retries);return t.success?(s.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(s.debug("API request failed when retrieving email",t.error),{error:new c(r,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(n){return{error:h(r,"retrieve email",n,s),success:!1}}},async initialize(){await m.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(r,"Scaleway API not available or invalid API key");s.debug("Provider initialized successfully")},r)},async isAvailable(){try{return s.debug("Checking Scaleway API availability"),!0}catch(e){return s.debug("Error checking availability:",e),!1}},name:r,options:i,async sendEmail(e){try{const n=I(e);if(n.length>0)return{error:new c(r,`Invalid email options: ${n.join(", ")}`),success:!1};await m.ensureInitialized(()=>this.initialize(),r);const t={from:{email:e.from.email,...e.from.name&&{name:e.from.name}},subject:e.subject,to:d(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=d(e.cc)),e.bcc&&(t.bcc=d(e.bcc)),e.replyTo&&(t.replyTo=T(e.replyTo)),e.templateId&&(t.templateId=e.templateId,e.templateVariables&&(t.templateVariables=e.templateVariables)),e.projectId&&(t.projectId=e.projectId),e.headers){const l=v(e.headers);t.headers=l}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async l=>({content:await S(l,r),name:l.filename,type:l.contentType??"application/octet-stream"})))),s.debug("Sending email via Scaleway API",{subject:t.subject,to:t.to});const b={"Content-Type":"application/json","X-Auth-Token":i.apiKey},o=await g(async()=>f(`${i.endpoint}/regions/${i.region}/emails`,{headers:b,method:"POST",timeout:i.timeout},JSON.stringify(t)),i.retries);if(!o.success)return s.debug("API request failed when sending email",o.error),{error:o.error??new c(r,"Failed to send email"),success:!1};const u=o.data?.body?.id??w();return s.debug("Email sent successfully",{messageId:u}),{data:{messageId:u,provider:r,response:o.data,sent:!0,timestamp:new Date},success:!0}}catch(n){return{error:h(r,"send email",n,s),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{H as default};
@@ -1 +1 @@
1
- import l from"./EmailError-B-sEf3bp.js";import A from"./RequiredOptionError-DuNNY_a5.js";import{e as P}from"./generate-message-id-gXAuMz4g.js";import{s as S}from"./headers-to-record-De1Eg951.js";import{m as h}from"./make-request-BlK_B72c.js";import{u as b}from"./retry-3pnxTuNs.js";import{f as j}from"./validate-email-options-mCM9dVug.js";import{defineProvider as G}from"./defineProvider-C9q-7iwt.js";import{P as k,h as v,c as z}from"./provider-base-C7PuopYK.js";import{f,a as I}from"./address-formatter-BWR2Dddx.js";import{d as C}from"./attachment-processor-CMp7qqMI.js";const s="sendgrid",E="https://api.sendgrid.com/v3",_=3e4,T=3,L=G((o={})=>{if(!o.apiKey)throw new A(s,"apiKey");const a={apiKey:o.apiKey,debug:o.debug??!1,endpoint:o.endpoint??E,...o.logger&&{logger:o.logger},retries:o.retries??T,timeout:o.timeout??_},p=new k,i=z(s,o.logger);return{endpoint:a.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 l(s,"Email ID is required to retrieve email details"),success:!1};await p.ensureInitialized(()=>this.initialize(),s);const t={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"};i.debug("Retrieving email details",{id:e});const r=await b(async()=>h(`${a.endpoint}/messages/${e}`,{headers:t,method:"GET",timeout:a.timeout}),a.retries);return r.success?(i.debug("Email details retrieved successfully"),{data:r.data?.body,success:!0}):(i.debug("API request failed when retrieving email",r.error),{error:new l(s,`Failed to retrieve email: ${r.error instanceof Error?r.error.message:"Unknown error"}`,{cause:r.error}),success:!1})}catch(t){return{error:v(s,"retrieve email",t,i),success:!1}}},async initialize(){await p.ensureInitialized(async()=>{if(!await this.isAvailable())throw new l(s,"SendGrid API not available or invalid API key");i.debug("Provider initialized successfully")},s)},async isAvailable(){try{if(a.apiKey&&a.apiKey.startsWith("SG."))return i.debug("API key format is valid, assuming SendGrid is available"),!0;const e={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"};i.debug("Checking SendGrid API availability");const t=await h(`${a.endpoint}/user/profile`,{headers:e,method:"GET",timeout:a.timeout});return i.debug("SendGrid 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 i.debug("Error checking availability:",e),!1}},name:s,options:a,async sendEmail(e){try{const t=j(e);if(t.length>0)return{error:new l(s,`Invalid email options: ${t.join(", ")}`),success:!1};await p.ensureInitialized(()=>this.initialize(),s);const r={to:f(e.to)};if(e.cc&&(r.cc=f(e.cc)),e.bcc&&(r.bcc=f(e.bcc)),e.subject&&(r.subject=e.subject),e.tags&&e.tags.length>0){const d={};for(let m=0;m<e.tags.length;m+=1)d[`tag_${m}`]=e.tags[m];r.customArgs=d}const n={from:I(e.from),personalizations:[r]},u=[];if(e.html&&u.push({type:"text/html",value:e.html}),e.text&&u.push({type:"text/plain",value:e.text}),u.length>0&&(n.content=u),e.replyTo&&(n.reply_to=I(e.replyTo)),e.subject&&(n.subject=e.subject),e.templateId&&(n.template_id=e.templateId,e.templateData&&(r.dynamicTemplateData=e.templateData)),e.sendAt&&(r.send_at=e.sendAt),e.batchId&&(n.batch_id=e.batchId),e.asmGroupId&&(n.asm={group_id:e.asmGroupId}),e.ipPoolName&&(n.ip_pool_name=e.ipPoolName),e.mailSettings&&(n.mail_settings=e.mailSettings),e.trackingSettings&&(n.tracking_settings=e.trackingSettings),e.headers){const d=S(e.headers);n.headers=d}e.attachments&&e.attachments.length>0&&(n.attachments=await Promise.all(e.attachments.map(async d=>C(d,s)))),i.debug("Sending email via SendGrid API",{subject:n.subject,to:r.to});const w={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"},c=await b(async()=>h(`${a.endpoint}/mail/send`,{headers:w,method:"POST",timeout:a.timeout},JSON.stringify(n)),a.retries);if(!c.success)return i.debug("API request failed when sending email",c.error),{error:c.error??new l(s,"Failed to send email"),success:!1};const g=c.data?.headers,y=(g&&g instanceof Headers?g.get("X-Message-Id"):void 0)??P();return i.debug("Email sent successfully",{messageId:y}),{data:{messageId:y,provider:s,response:c.data,sent:!0,timestamp:new Date},success:!0}}catch(t){return{error:v(s,"send email",t,i),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{L as default};
1
+ import l from"./EmailError-B-sEf3bp.js";import A from"./RequiredOptionError-DuNNY_a5.js";import{e as P}from"./generate-message-id-gXAuMz4g.js";import{s as S}from"./headers-to-record-De1Eg951.js";import{m as h}from"./make-request-B9XjBynA.js";import{i as b}from"./retry-ipI5DRJ8.js";import{f as j}from"./validate-email-options-mCM9dVug.js";import{defineProvider as G}from"./defineProvider-C9q-7iwt.js";import{P as k,h as v,c as z}from"./provider-base-C7PuopYK.js";import{f,a as I}from"./address-formatter-BWR2Dddx.js";import{d as C}from"./attachment-processor-CMp7qqMI.js";const s="sendgrid",E="https://api.sendgrid.com/v3",_=3e4,T=3,L=G((o={})=>{if(!o.apiKey)throw new A(s,"apiKey");const a={apiKey:o.apiKey,debug:o.debug??!1,endpoint:o.endpoint??E,...o.logger&&{logger:o.logger},retries:o.retries??T,timeout:o.timeout??_},p=new k,i=z(s,o.logger);return{endpoint:a.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 l(s,"Email ID is required to retrieve email details"),success:!1};await p.ensureInitialized(()=>this.initialize(),s);const t={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"};i.debug("Retrieving email details",{id:e});const r=await b(async()=>h(`${a.endpoint}/messages/${e}`,{headers:t,method:"GET",timeout:a.timeout}),a.retries);return r.success?(i.debug("Email details retrieved successfully"),{data:r.data?.body,success:!0}):(i.debug("API request failed when retrieving email",r.error),{error:new l(s,`Failed to retrieve email: ${r.error instanceof Error?r.error.message:"Unknown error"}`,{cause:r.error}),success:!1})}catch(t){return{error:v(s,"retrieve email",t,i),success:!1}}},async initialize(){await p.ensureInitialized(async()=>{if(!await this.isAvailable())throw new l(s,"SendGrid API not available or invalid API key");i.debug("Provider initialized successfully")},s)},async isAvailable(){try{if(a.apiKey&&a.apiKey.startsWith("SG."))return i.debug("API key format is valid, assuming SendGrid is available"),!0;const e={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"};i.debug("Checking SendGrid API availability");const t=await h(`${a.endpoint}/user/profile`,{headers:e,method:"GET",timeout:a.timeout});return i.debug("SendGrid 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 i.debug("Error checking availability:",e),!1}},name:s,options:a,async sendEmail(e){try{const t=j(e);if(t.length>0)return{error:new l(s,`Invalid email options: ${t.join(", ")}`),success:!1};await p.ensureInitialized(()=>this.initialize(),s);const r={to:f(e.to)};if(e.cc&&(r.cc=f(e.cc)),e.bcc&&(r.bcc=f(e.bcc)),e.subject&&(r.subject=e.subject),e.tags&&e.tags.length>0){const d={};for(let m=0;m<e.tags.length;m+=1)d[`tag_${m}`]=e.tags[m];r.customArgs=d}const n={from:I(e.from),personalizations:[r]},u=[];if(e.html&&u.push({type:"text/html",value:e.html}),e.text&&u.push({type:"text/plain",value:e.text}),u.length>0&&(n.content=u),e.replyTo&&(n.reply_to=I(e.replyTo)),e.subject&&(n.subject=e.subject),e.templateId&&(n.template_id=e.templateId,e.templateData&&(r.dynamicTemplateData=e.templateData)),e.sendAt&&(r.send_at=e.sendAt),e.batchId&&(n.batch_id=e.batchId),e.asmGroupId&&(n.asm={group_id:e.asmGroupId}),e.ipPoolName&&(n.ip_pool_name=e.ipPoolName),e.mailSettings&&(n.mail_settings=e.mailSettings),e.trackingSettings&&(n.tracking_settings=e.trackingSettings),e.headers){const d=S(e.headers);n.headers=d}e.attachments&&e.attachments.length>0&&(n.attachments=await Promise.all(e.attachments.map(async d=>C(d,s)))),i.debug("Sending email via SendGrid API",{subject:n.subject,to:r.to});const w={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"},c=await b(async()=>h(`${a.endpoint}/mail/send`,{headers:w,method:"POST",timeout:a.timeout},JSON.stringify(n)),a.retries);if(!c.success)return i.debug("API request failed when sending email",c.error),{error:c.error??new l(s,"Failed to send email"),success:!1};const g=c.data?.headers,y=(g&&g instanceof Headers?g.get("X-Message-Id"):void 0)??P();return i.debug("Email sent successfully",{messageId:y}),{data:{messageId:y,provider:s,response:c.data,sent:!0,timestamp:new Date},success:!0}}catch(t){return{error:v(s,"send email",t,i),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{L as default};
@@ -1 +1 @@
1
- import h from"./EmailError-B-sEf3bp.js";import w from"./RequiredOptionError-DuNNY_a5.js";import{e as P}from"./generate-message-id-gXAuMz4g.js";import{m as j}from"./make-request-BlK_B72c.js";import{u as I}from"./retry-3pnxTuNs.js";import{f as A}from"./validate-email-options-mCM9dVug.js";import{defineProvider as S}from"./defineProvider-C9q-7iwt.js";import{P as z,h as _,c as C}from"./provider-base-C7PuopYK.js";import{a as l}from"./address-formatter-BWR2Dddx.js";import{c as K}from"./attachment-processor-CMp7qqMI.js";const a="sparkpost",O="https://api.sparkpost.com/api/v1",T=3e4,x=3,d=r=>[r].flat(),B=S((r={})=>{if(!r.apiKey)throw new w(a,"apiKey");const n={apiKey:r.apiKey,debug:r.debug??!1,endpoint:r.endpoint??O,logger:r.logger,retries:r.retries??x,timeout:r.timeout??T},g=new z,y=C(a,r.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async initialize(){await g.ensureInitialized(async()=>{if(!await this.isAvailable())throw new h(a,"SparkPost API not available or invalid API key");y.debug("Provider initialized successfully")},a)},async isAvailable(){return n.apiKey.length>0},name:a,options:n,async sendEmail(t){try{const o=A(t);if(o.length>0)return{error:new h(a,`Invalid email options: ${o.join(", ")}`),success:!1};await g.ensureInitialized(()=>this.initialize(),a);const p=d(t.to),u=t.cc?d(t.cc):[],k=t.bcc?d(t.bcc):[],v=[...p.map(e=>({address:l(e)})),...u.map(e=>({address:{...l(e),header_to:p.map(i=>i.email).join(", ")}})),...k.map(e=>({address:{...l(e),header_to:p.map(i=>i.email).join(", ")}}))],s={from:l(t.from),subject:t.subject};if(t.html&&(s.html=t.html),t.text&&(s.text=t.text),t.replyTo){const e=d(t.replyTo)[0];e&&(s.reply_to=e.email)}const c={};if(u.length>0&&(c.CC=u.map(e=>e.email).join(", ")),t.headers)for(const[e,i]of Object.entries(t.headers))c[e]=String(i);Object.keys(c).length>0&&(s.headers=c),t.templateId&&(s.template_id=t.templateId),t.attachments&&t.attachments.length>0&&(s.attachments=await Promise.all(t.attachments.map(async e=>{const i=await K(e,a);return{data:i.content,name:i.filename,type:i.contentType}})));const f={content:s,recipients:v};t.campaignId&&(f.campaign_id=t.campaignId),(t.trackOpens!==void 0||t.trackClicks!==void 0)&&(f.options={click_tracking:t.trackClicks??!0,open_tracking:t.trackOpens??!0});const m=await I(async()=>j(`${n.endpoint}/transmissions`,{headers:{Authorization:n.apiKey,"Content-Type":"application/json"},method:"POST",timeout:n.timeout},JSON.stringify(f)),n.retries);if(!m.success)return{error:m.error??new h(a,"Failed to send email"),success:!1};const{body:b}=m.data;return{data:{messageId:b?.results?.id??P(),provider:a,response:m.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:_(a,"send email",o,y),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{B as default};
1
+ import h from"./EmailError-B-sEf3bp.js";import w from"./RequiredOptionError-DuNNY_a5.js";import{e as P}from"./generate-message-id-gXAuMz4g.js";import{m as j}from"./make-request-B9XjBynA.js";import{i as I}from"./retry-ipI5DRJ8.js";import{f as A}from"./validate-email-options-mCM9dVug.js";import{defineProvider as S}from"./defineProvider-C9q-7iwt.js";import{P as z,h as _,c as C}from"./provider-base-C7PuopYK.js";import{a as l}from"./address-formatter-BWR2Dddx.js";import{c as K}from"./attachment-processor-CMp7qqMI.js";const a="sparkpost",O="https://api.sparkpost.com/api/v1",T=3e4,x=3,d=r=>[r].flat(),B=S((r={})=>{if(!r.apiKey)throw new w(a,"apiKey");const n={apiKey:r.apiKey,debug:r.debug??!1,endpoint:r.endpoint??O,logger:r.logger,retries:r.retries??x,timeout:r.timeout??T},g=new z,y=C(a,r.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async initialize(){await g.ensureInitialized(async()=>{if(!await this.isAvailable())throw new h(a,"SparkPost API not available or invalid API key");y.debug("Provider initialized successfully")},a)},async isAvailable(){return n.apiKey.length>0},name:a,options:n,async sendEmail(t){try{const o=A(t);if(o.length>0)return{error:new h(a,`Invalid email options: ${o.join(", ")}`),success:!1};await g.ensureInitialized(()=>this.initialize(),a);const p=d(t.to),u=t.cc?d(t.cc):[],k=t.bcc?d(t.bcc):[],v=[...p.map(e=>({address:l(e)})),...u.map(e=>({address:{...l(e),header_to:p.map(i=>i.email).join(", ")}})),...k.map(e=>({address:{...l(e),header_to:p.map(i=>i.email).join(", ")}}))],s={from:l(t.from),subject:t.subject};if(t.html&&(s.html=t.html),t.text&&(s.text=t.text),t.replyTo){const e=d(t.replyTo)[0];e&&(s.reply_to=e.email)}const c={};if(u.length>0&&(c.CC=u.map(e=>e.email).join(", ")),t.headers)for(const[e,i]of Object.entries(t.headers))c[e]=String(i);Object.keys(c).length>0&&(s.headers=c),t.templateId&&(s.template_id=t.templateId),t.attachments&&t.attachments.length>0&&(s.attachments=await Promise.all(t.attachments.map(async e=>{const i=await K(e,a);return{data:i.content,name:i.filename,type:i.contentType}})));const f={content:s,recipients:v};t.campaignId&&(f.campaign_id=t.campaignId),(t.trackOpens!==void 0||t.trackClicks!==void 0)&&(f.options={click_tracking:t.trackClicks??!0,open_tracking:t.trackOpens??!0});const m=await I(async()=>j(`${n.endpoint}/transmissions`,{headers:{Authorization:n.apiKey,"Content-Type":"application/json"},method:"POST",timeout:n.timeout},JSON.stringify(f)),n.retries);if(!m.success)return{error:m.error??new h(a,"Failed to send email"),success:!1};const{body:b}=m.data;return{data:{messageId:b?.results?.id??P(),provider:a,response:m.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:_(a,"send email",o,y),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{B as default};
@@ -1 +1 @@
1
- import c from"./EmailError-B-sEf3bp.js";import b from"./RequiredOptionError-DuNNY_a5.js";import{e as w}from"./generate-message-id-gXAuMz4g.js";import{s as v}from"./headers-to-record-De1Eg951.js";import{m as g}from"./make-request-BlK_B72c.js";import{u as f}from"./retry-3pnxTuNs.js";import{f as I}from"./validate-email-options-mCM9dVug.js";import{defineProvider as A}from"./defineProvider-C9q-7iwt.js";import{P,h,c as T}from"./provider-base-C7PuopYK.js";import{f as d,a as z}from"./address-formatter-BWR2Dddx.js";import{p as S}from"./attachment-processor-CMp7qqMI.js";const r="sweego",E="https://api.sweego.com",j=3e4,k=3,H=A((i={})=>{if(!i.apiKey)throw new b(r,"apiKey");const s={apiKey:i.apiKey,debug:i.debug??!1,endpoint:i.endpoint??E,retries:i.retries??k,timeout:i.timeout??j,...i.logger&&{logger:i.logger}},m=new P,a=T(r,i.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new c(r,"Email ID is required to retrieve email details"),success:!1};await m.ensureInitialized(()=>this.initialize(),r);const o={Authorization:`Bearer ${s.apiKey}`,"Content-Type":"application/json"};a.debug("Retrieving email details",{id:e});const t=await f(async()=>g(`${s.endpoint}/emails/${e}`,{headers:o,method:"GET",timeout:s.timeout}),s.retries);return t.success?(a.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(a.debug("API request failed when retrieving email",t.error),{error:new c(r,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(o){return{error:h(r,"retrieve email",o,a),success:!1}}},async initialize(){await m.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(r,"Sweego API not available or invalid API key");a.debug("Provider initialized successfully")},r)},async isAvailable(){try{return a.debug("Checking Sweego API availability"),!0}catch(e){return a.debug("Error checking availability:",e),!1}},name:r,options:s,async sendEmail(e){try{const o=I(e);if(o.length>0)return{error:new c(r,`Invalid email options: ${o.join(", ")}`),success:!1};await m.ensureInitialized(()=>this.initialize(),r);const t={from:{email:e.from.email,name:e.from.name},subject:e.subject,to:d(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=d(e.cc)),e.bcc&&(t.bcc=d(e.bcc)),e.replyTo&&(t.replyTo=z(e.replyTo)),e.templateId&&(t.templateId=e.templateId,e.templateVariables&&(t.templateVariables=e.templateVariables)),e.tags&&e.tags.length>0&&(t.tags=e.tags),e.headers){const n=v(e.headers);t.headers=n}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async n=>({content:await S(n,r),contentType:n.contentType??"application/octet-stream",filename:n.filename,...n.cid&&{cid:n.cid}})))),a.debug("Sending email via Sweego API",{subject:t.subject,to:t.to});const y={Authorization:`Bearer ${s.apiKey}`,"Content-Type":"application/json"},l=await f(async()=>g(`${s.endpoint}/send`,{headers:y,method:"POST",timeout:s.timeout},JSON.stringify(t)),s.retries);if(!l.success)return a.debug("API request failed when sending email",l.error),{error:l.error??new c(r,"Failed to send email"),success:!1};const u=l.data?.body,p=u?.messageId??u?.id??w();return a.debug("Email sent successfully",{messageId:p}),{data:{messageId:p,provider:r,response:l.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:h(r,"send email",o,a),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{H as default};
1
+ import c from"./EmailError-B-sEf3bp.js";import b from"./RequiredOptionError-DuNNY_a5.js";import{e as w}from"./generate-message-id-gXAuMz4g.js";import{s as v}from"./headers-to-record-De1Eg951.js";import{m as g}from"./make-request-B9XjBynA.js";import{i as f}from"./retry-ipI5DRJ8.js";import{f as I}from"./validate-email-options-mCM9dVug.js";import{defineProvider as A}from"./defineProvider-C9q-7iwt.js";import{P,h,c as T}from"./provider-base-C7PuopYK.js";import{f as d,a as z}from"./address-formatter-BWR2Dddx.js";import{p as S}from"./attachment-processor-CMp7qqMI.js";const r="sweego",E="https://api.sweego.com",j=3e4,k=3,H=A((i={})=>{if(!i.apiKey)throw new b(r,"apiKey");const s={apiKey:i.apiKey,debug:i.debug??!1,endpoint:i.endpoint??E,retries:i.retries??k,timeout:i.timeout??j,...i.logger&&{logger:i.logger}},m=new P,a=T(r,i.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new c(r,"Email ID is required to retrieve email details"),success:!1};await m.ensureInitialized(()=>this.initialize(),r);const o={Authorization:`Bearer ${s.apiKey}`,"Content-Type":"application/json"};a.debug("Retrieving email details",{id:e});const t=await f(async()=>g(`${s.endpoint}/emails/${e}`,{headers:o,method:"GET",timeout:s.timeout}),s.retries);return t.success?(a.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(a.debug("API request failed when retrieving email",t.error),{error:new c(r,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(o){return{error:h(r,"retrieve email",o,a),success:!1}}},async initialize(){await m.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(r,"Sweego API not available or invalid API key");a.debug("Provider initialized successfully")},r)},async isAvailable(){try{return a.debug("Checking Sweego API availability"),!0}catch(e){return a.debug("Error checking availability:",e),!1}},name:r,options:s,async sendEmail(e){try{const o=I(e);if(o.length>0)return{error:new c(r,`Invalid email options: ${o.join(", ")}`),success:!1};await m.ensureInitialized(()=>this.initialize(),r);const t={from:{email:e.from.email,name:e.from.name},subject:e.subject,to:d(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=d(e.cc)),e.bcc&&(t.bcc=d(e.bcc)),e.replyTo&&(t.replyTo=z(e.replyTo)),e.templateId&&(t.templateId=e.templateId,e.templateVariables&&(t.templateVariables=e.templateVariables)),e.tags&&e.tags.length>0&&(t.tags=e.tags),e.headers){const n=v(e.headers);t.headers=n}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async n=>({content:await S(n,r),contentType:n.contentType??"application/octet-stream",filename:n.filename,...n.cid&&{cid:n.cid}})))),a.debug("Sending email via Sweego API",{subject:t.subject,to:t.to});const y={Authorization:`Bearer ${s.apiKey}`,"Content-Type":"application/json"},l=await f(async()=>g(`${s.endpoint}/send`,{headers:y,method:"POST",timeout:s.timeout},JSON.stringify(t)),s.retries);if(!l.success)return a.debug("API request failed when sending email",l.error),{error:l.error??new c(r,"Failed to send email"),success:!1};const u=l.data?.body,p=u?.messageId??u?.id??w();return a.debug("Email sent successfully",{messageId:p}),{data:{messageId:p,provider:r,response:l.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:h(r,"send email",o,a),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{H as default};
@@ -1 +1 @@
1
- import l from"./EmailError-B-sEf3bp.js";import y from"./RequiredOptionError-DuNNY_a5.js";import{e as b}from"./generate-message-id-gXAuMz4g.js";import{s as k}from"./headers-to-record-De1Eg951.js";import{m as v}from"./make-request-BlK_B72c.js";import{u as w}from"./retry-3pnxTuNs.js";import{s as A,a as z}from"./sanitize-header-DtQwAnzg.js";import{f as _}from"./validate-email-options-mCM9dVug.js";import{defineProvider as j}from"./defineProvider-C9q-7iwt.js";import{P,h as I,c as T}from"./provider-base-C7PuopYK.js";import{n as h}from"./address-formatter-BWR2Dddx.js";const i="zeptomail",O="https://api.zeptomail.com/v1.1",Z=3e4,E=3,L=j((s={})=>{if(!s.token)throw new y(i,"token");if(!s.token.startsWith("Zoho-enczapikey "))throw new l(i,'Token should be in the format "Zoho-enczapikey <your_api_key>"');const o={debug:s.debug??!1,endpoint:s.endpoint??O,logger:s.logger,retries:s.retries??E,timeout:s.timeout??Z,token:s.token},u=new P,n=T(i,s.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!1,tracking:!0},async initialize(){await u.ensureInitialized(async()=>{if(!await this.isAvailable())throw new l(i,"Zeptomail API not available or invalid token");n.debug("Provider initialized successfully")},i)},async isAvailable(){try{return o.token&&o.token.startsWith("Zoho-enczapikey ")?(n.debug("Token format is valid, assuming Zeptomail is available"),!0):!1}catch(e){return n.debug("Error checking availability:",e),!1}},name:i,options:o,async sendEmail(e){try{const m=_(e);if(m.length>0)return{error:new l(i,`Invalid email options: ${m.join(", ")}`),success:!1};await u.ensureInitialized(()=>this.initialize(),i);const a={from:h(e.from).address,subject:e.subject};if(Array.isArray(e.to)?a.to=e.to.length===1?e.to[0].email:e.to.map(t=>t.email):a.to=e.to.email,e.text&&(a.textbody=e.text),e.html&&(a.htmlbody=e.html),e.cc&&(Array.isArray(e.cc)?a.cc=e.cc.length===1?e.cc[0].email:e.cc.map(t=>t.email):a.cc=e.cc.email),e.bcc&&(Array.isArray(e.bcc)?a.bcc=e.bcc.length===1?e.bcc[0].email:e.bcc.map(t=>t.email):a.bcc=e.bcc.email),e.replyTo&&(a.reply_to=[h(e.replyTo).address]),e.trackClicks!==void 0&&(a.track_clicks=e.trackClicks),e.trackOpens!==void 0&&(a.track_opens=e.trackOpens),e.clientReference&&(a.client_reference=e.clientReference),e.mimeHeaders&&Object.keys(e.mimeHeaders).length>0){const t={};for(const[r,d]of Object.entries(e.mimeHeaders))t[r]=d;a.mime_headers=t}if(e.headers){const t=k(e.headers);Object.keys(t).length>0&&(a.mime_headers??={},Object.entries(t).forEach(([r,d])=>{a.mime_headers&&(a.mime_headers[A(r)]=z(d))}))}e.attachments&&e.attachments.length>0&&(a.attachments=e.attachments.map(t=>{const r={name:t.filename};return t.content?(r.content=typeof t.content=="string"?t.content:t.content.toString("base64"),t.contentType&&(r.mime_type=t.contentType)):t.path&&(r.file_cache_key=t.path),r})),n.debug("Sending email via Zeptomail API",{subject:a.subject,to:a.to});const g={Accept:"application/json",Authorization:o.token,"Content-Type":"application/json"},c=await w(async()=>v(`${o.endpoint}/email`,{headers:g,method:"POST",timeout:o.timeout},JSON.stringify(a)),o.retries);if(!c.success){n.debug("API request failed",c.error);let t=c.error instanceof Error?c.error.message:"Unknown error";const r=c.data;return r?.body?.message?t+=` Details: ${r.body.message}`:r?.body?.error?.message&&(t+=` Details: ${r.body.error.message}`),{error:new l(i,`Failed to send email: ${t}`,{cause:c.error}),success:!1}}const p=c.data?.body,f=p?.request_id??b();return n.debug("Email sent successfully",{messageId:f}),{data:{messageId:f,provider:i,response:p,sent:!0,timestamp:new Date},success:!0}}catch(m){return{error:I(i,"send email",m,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{L as default};
1
+ import l from"./EmailError-B-sEf3bp.js";import y from"./RequiredOptionError-DuNNY_a5.js";import{e as b}from"./generate-message-id-gXAuMz4g.js";import{s as k}from"./headers-to-record-De1Eg951.js";import{m as v}from"./make-request-B9XjBynA.js";import{i as w}from"./retry-ipI5DRJ8.js";import{s as A,a as z}from"./sanitize-header-DtQwAnzg.js";import{f as _}from"./validate-email-options-mCM9dVug.js";import{defineProvider as j}from"./defineProvider-C9q-7iwt.js";import{P,h as I,c as T}from"./provider-base-C7PuopYK.js";import{n as h}from"./address-formatter-BWR2Dddx.js";const i="zeptomail",O="https://api.zeptomail.com/v1.1",Z=3e4,E=3,L=j((s={})=>{if(!s.token)throw new y(i,"token");if(!s.token.startsWith("Zoho-enczapikey "))throw new l(i,'Token should be in the format "Zoho-enczapikey <your_api_key>"');const o={debug:s.debug??!1,endpoint:s.endpoint??O,logger:s.logger,retries:s.retries??E,timeout:s.timeout??Z,token:s.token},u=new P,n=T(i,s.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!1,tracking:!0},async initialize(){await u.ensureInitialized(async()=>{if(!await this.isAvailable())throw new l(i,"Zeptomail API not available or invalid token");n.debug("Provider initialized successfully")},i)},async isAvailable(){try{return o.token&&o.token.startsWith("Zoho-enczapikey ")?(n.debug("Token format is valid, assuming Zeptomail is available"),!0):!1}catch(e){return n.debug("Error checking availability:",e),!1}},name:i,options:o,async sendEmail(e){try{const m=_(e);if(m.length>0)return{error:new l(i,`Invalid email options: ${m.join(", ")}`),success:!1};await u.ensureInitialized(()=>this.initialize(),i);const a={from:h(e.from).address,subject:e.subject};if(Array.isArray(e.to)?a.to=e.to.length===1?e.to[0].email:e.to.map(t=>t.email):a.to=e.to.email,e.text&&(a.textbody=e.text),e.html&&(a.htmlbody=e.html),e.cc&&(Array.isArray(e.cc)?a.cc=e.cc.length===1?e.cc[0].email:e.cc.map(t=>t.email):a.cc=e.cc.email),e.bcc&&(Array.isArray(e.bcc)?a.bcc=e.bcc.length===1?e.bcc[0].email:e.bcc.map(t=>t.email):a.bcc=e.bcc.email),e.replyTo&&(a.reply_to=[h(e.replyTo).address]),e.trackClicks!==void 0&&(a.track_clicks=e.trackClicks),e.trackOpens!==void 0&&(a.track_opens=e.trackOpens),e.clientReference&&(a.client_reference=e.clientReference),e.mimeHeaders&&Object.keys(e.mimeHeaders).length>0){const t={};for(const[r,d]of Object.entries(e.mimeHeaders))t[r]=d;a.mime_headers=t}if(e.headers){const t=k(e.headers);Object.keys(t).length>0&&(a.mime_headers??={},Object.entries(t).forEach(([r,d])=>{a.mime_headers&&(a.mime_headers[A(r)]=z(d))}))}e.attachments&&e.attachments.length>0&&(a.attachments=e.attachments.map(t=>{const r={name:t.filename};return t.content?(r.content=typeof t.content=="string"?t.content:t.content.toString("base64"),t.contentType&&(r.mime_type=t.contentType)):t.path&&(r.file_cache_key=t.path),r})),n.debug("Sending email via Zeptomail API",{subject:a.subject,to:a.to});const g={Accept:"application/json",Authorization:o.token,"Content-Type":"application/json"},c=await w(async()=>v(`${o.endpoint}/email`,{headers:g,method:"POST",timeout:o.timeout},JSON.stringify(a)),o.retries);if(!c.success){n.debug("API request failed",c.error);let t=c.error instanceof Error?c.error.message:"Unknown error";const r=c.data;return r?.body?.message?t+=` Details: ${r.body.message}`:r?.body?.error?.message&&(t+=` Details: ${r.body.error.message}`),{error:new l(i,`Failed to send email: ${t}`,{cause:c.error}),success:!1}}const p=c.data?.body,f=p?.request_id??b();return n.debug("Email sent successfully",{messageId:f}),{data:{messageId:f,provider:i,response:p,sent:!0,timestamp:new Date},success:!0}}catch(m){return{error:I(i,"send email",m,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{L as default};
@@ -1 +1 @@
1
- import{default as r}from"../../packem_shared/ahaSendProvider-D81_wUA1.js";export{r as ahaSendProvider};
1
+ import{default as r}from"../../packem_shared/ahaSendProvider-DSuZIzaQ.js";export{r as ahaSendProvider};
@@ -1 +1 @@
1
- import{default as r}from"../../packem_shared/autoSendProvider-Bz3g6aZi.js";export{r as autoSendProvider};
1
+ import{default as r}from"../../packem_shared/autoSendProvider-DqAoelWR.js";export{r as autoSendProvider};
@@ -1 +1 @@
1
- import{default as a}from"../../packem_shared/awsSesProvider-962hIcbo.js";export{a as awsSesProvider};
1
+ import{default as a}from"../../packem_shared/awsSesProvider-ClK1FUln.js";export{a as awsSesProvider};
@@ -1 +1 @@
1
- import{default as a}from"../../packem_shared/azureProvider-CmcK4bsf.js";export{a as azureProvider};
1
+ import{default as a}from"../../packem_shared/azureProvider-Cw_Tmde6.js";export{a as azureProvider};
@@ -1 +1 @@
1
- import{default as o}from"../../packem_shared/brevoProvider-C1BDXr41.js";export{o as brevoProvider};
1
+ import{default as o}from"../../packem_shared/brevoProvider-CIzuIDlt.js";export{o as brevoProvider};
@@ -1 +1 @@
1
- import{default as e}from"../../packem_shared/httpProvider-DJAsYSun.js";export{e as httpProvider};
1
+ import{default as e}from"../../packem_shared/httpProvider-aBfTXyCT.js";export{e as httpProvider};
@@ -1 +1 @@
1
- import{default as e}from"../../packem_shared/infobipProvider-lHyGrXgZ.js";export{e as infobipProvider};
1
+ import{default as e}from"../../packem_shared/infobipProvider-DxzsONUX.js";export{e as infobipProvider};
@@ -1 +1 @@
1
- import{default as e}from"../../packem_shared/loopsProvider-DyloxzNC.js";export{e as loopsProvider};
1
+ import{default as e}from"../../packem_shared/loopsProvider-QBsAH6Ee.js";export{e as loopsProvider};
@@ -1 +1 @@
1
- import{default as r}from"../../packem_shared/mailchannelsProvider-osRkW_tz.js";export{r as mailchannelsProvider};
1
+ import{default as r}from"../../packem_shared/mailchannelsProvider-GiwkYBdD.js";export{r as mailchannelsProvider};
@@ -1 +1 @@
1
- import{default as a}from"../../packem_shared/mailerSendProvider-C_6LzARK.js";export{a as mailerSendProvider};
1
+ import{default as a}from"../../packem_shared/mailerSendProvider-RK6IbUrL.js";export{a as mailerSendProvider};
@@ -1 +1 @@
1
- import{default as e}from"../../packem_shared/mailgunProvider-DkISvMPe.js";export{e as mailgunProvider};
1
+ import{default as e}from"../../packem_shared/mailgunProvider-D9HUWGKN.js";export{e as mailgunProvider};
@@ -1 +1 @@
1
- import{default as a}from"../../packem_shared/mailjetProvider-CV0i4Xzh.js";export{a as mailjetProvider};
1
+ import{default as a}from"../../packem_shared/mailjetProvider-DelLs2Vt.js";export{a as mailjetProvider};
@@ -1 +1 @@
1
- import{default as r}from"../../packem_shared/mailomatProvider-B5YFonEO.js";export{r as mailomatProvider};
1
+ import{default as r}from"../../packem_shared/mailomatProvider-DPDpVS8r.js";export{r as mailomatProvider};
@@ -1 +1 @@
1
- import{default as r}from"../../packem_shared/mailPaceProvider-DZent57J.js";export{r as mailPaceProvider};
1
+ import{default as r}from"../../packem_shared/mailPaceProvider-DCa-4ghl.js";export{r as mailPaceProvider};
@@ -1 +1 @@
1
- import{default as e}from"../../packem_shared/mailtrapProvider-C4ZquIPz.js";export{e as mailtrapProvider};
1
+ import{default as e}from"../../packem_shared/mailtrapProvider-DtrS4Q34.js";export{e as mailtrapProvider};
@@ -1 +1 @@
1
- import{default as d}from"../../packem_shared/mandrillProvider-DSsAknmA.js";export{d as mandrillProvider};
1
+ import{default as d}from"../../packem_shared/mandrillProvider-B84zH-eV.js";export{d as mandrillProvider};
@@ -1 +1 @@
1
- import{default as o}from"../../packem_shared/netcoreProvider-C5TEciaN.js";export{o as netcoreProvider};
1
+ import{default as o}from"../../packem_shared/netcoreProvider-D-wtCyJj.js";export{o as netcoreProvider};
@@ -1 +1 @@
1
- import{default as e}from"../../packem_shared/outlook365Provider-CkjXkY-7.js";export{e as outlook365Provider};
1
+ import{default as e}from"../../packem_shared/outlook365Provider-Btk4Emig.js";export{e as outlook365Provider};
@@ -1 +1 @@
1
- import{default as o}from"../../packem_shared/plunkProvider-D3T2T-2V.js";export{o as plunkProvider};
1
+ import{default as o}from"../../packem_shared/plunkProvider-Bw8e6460.js";export{o as plunkProvider};
@@ -1 +1 @@
1
- import{default as a}from"../../packem_shared/postalProvider-CRX_bMYD.js";export{a as postalProvider};
1
+ import{default as a}from"../../packem_shared/postalProvider-CT8zr89z.js";export{a as postalProvider};
@@ -1 +1 @@
1
- import{default as a}from"../../packem_shared/postmarkProvider-vspVSSOp.js";export{a as postmarkProvider};
1
+ import{default as a}from"../../packem_shared/postmarkProvider-CQSqZWDs.js";export{a as postmarkProvider};
@@ -1 +1 @@
1
- import{default as d}from"../../packem_shared/resendProvider-CiclWxzr.js";export{d as resendProvider};
1
+ import{default as d}from"../../packem_shared/resendProvider-drJYlvLP.js";export{d as resendProvider};
@@ -1 +1 @@
1
- import{default as r}from"../../packem_shared/scalewayProvider-BcND48qO.js";export{r as scalewayProvider};
1
+ import{default as r}from"../../packem_shared/scalewayProvider-DU5gXQrl.js";export{r as scalewayProvider};
@@ -1 +1 @@
1
- import{default as e}from"../../packem_shared/sendGridProvider-D8ZLgY62.js";export{e as sendGridProvider};
1
+ import{default as e}from"../../packem_shared/sendGridProvider-BuTbEXW8.js";export{e as sendGridProvider};
@@ -1 +1 @@
1
- import{default as a}from"../../packem_shared/sparkpostProvider-CTYfSRaV.js";export{a as sparkpostProvider};
1
+ import{default as a}from"../../packem_shared/sparkpostProvider-UAsFYIjP.js";export{a as sparkpostProvider};
@@ -1 +1 @@
1
- import{default as r}from"../../packem_shared/sweegoProvider-DOoin_vi.js";export{r as sweegoProvider};
1
+ import{default as r}from"../../packem_shared/sweegoProvider-SUz0LIcA.js";export{r as sweegoProvider};
@@ -1 +1 @@
1
- import{default as r}from"../../packem_shared/zeptomailProvider-DUesgbC-.js";export{r as zeptomailProvider};
1
+ import{default as r}from"../../packem_shared/zeptomailProvider-DXNX9mG_.js";export{r as zeptomailProvider};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/email",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "description": "A comprehensive email library with multi-provider support, crypto utilities, and template engines",
5
5
  "keywords": [
6
6
  "ahasend",
@@ -1 +0,0 @@
1
- import d from"./EmailError-B-sEf3bp.js";const y=globalThis.Buffer!==void 0,p=async(i,s={},r)=>{const l=typeof i=="string"?new URL(i):i;try{const e=new Headers;s.headers&&Object.entries(s.headers).forEach(([t,u])=>{e.set(t,u)});const o={headers:e,method:s.method??(r?"POST":"GET")};r&&(typeof r=="string"||r instanceof Uint8Array?o.body=r:y&&r instanceof globalThis.Buffer?o.body=new Uint8Array(r):o.body=new Uint8Array(r));let c,a;s.timeout&&(c=new AbortController,a=setTimeout(()=>{c?.abort()},s.timeout),o.signal=c.signal);try{const t=await fetch(l.toString(),o);a&&clearTimeout(a);const u=(t.headers.get("content-type")??"").includes("application/json");let n;if(u)try{n=await t.json()}catch{n=await t.text()}else n=await t.text();const f=t.status>=200&&t.status<300,h={};return t.headers.forEach((m,w)=>{h[w]=m}),{data:{body:n,headers:h,statusCode:t.status},error:f?void 0:new d("http",`Request failed with status ${t.status}`,{code:t.status.toString()}),success:f}}catch(t){if(a&&clearTimeout(a),t instanceof Error&&t.name==="AbortError")return{error:new d("http",`Request timed out after ${s.timeout}ms`),success:!1};throw t}}catch(e){return{error:new d("http",`Request failed: ${e instanceof Error?e.message:String(e)}`,{cause:e instanceof Error?e:new Error(String(e))}),success:!1}}};export{p as m};
@@ -1 +0,0 @@
1
- const o=async(t,e=3,s=300)=>{try{const r=await t();return r.success||e<=0?r:(await new Promise(n=>{setTimeout(()=>{n()},s)}),o(t,e-1,s*2))}catch(r){return e<=0?{error:r instanceof Error?r:new Error(String(r)),success:!1}:(await new Promise(n=>{setTimeout(()=>{n()},s)}),o(t,e-1,s*2))}};export{o as u};