@visulima/email 1.0.0-alpha.1 → 1.0.0-alpha.3

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 (142) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +408 -72
  3. package/dist/crypto/index.js +1 -1
  4. package/dist/draft-mail-message.d.ts +13 -0
  5. package/dist/index.d.ts +3 -16
  6. package/dist/index.js +1 -1
  7. package/dist/mail-message.d.ts +425 -0
  8. package/dist/mail.d.ts +124 -275
  9. package/dist/packem_shared/{DkimSigner-Z8D4Il10.js → DkimSigner-BrJfmMey.js} +1 -1
  10. package/dist/packem_shared/Mail-CC7Oh--8.js +1 -0
  11. package/dist/packem_shared/MailMessage-n7kyh9vB.js +1 -0
  12. package/dist/packem_shared/{SmimeEncrypter-CBevU534.js → SmimeEncrypter-CtvWNS8B.js} +1 -1
  13. package/dist/packem_shared/{SmimeSigner-02aXVi90.js → SmimeSigner-DZ1hSOM3.js} +1 -1
  14. package/dist/packem_shared/ahaSendProvider-DlFKEQ6D.js +1 -0
  15. package/dist/packem_shared/{awsSesProvider-CkuFOzb0.js → awsSesProvider-Ba-eVJxZ.js} +6 -6
  16. package/dist/packem_shared/azureProvider-CQYAkgVF.js +1 -0
  17. package/dist/packem_shared/brevoProvider-5p6jjiK9.js +1 -0
  18. package/dist/packem_shared/build-mime-message-IYaUqqPJ.js +2 -0
  19. package/dist/packem_shared/create-logger-BiWdqFNg.js +1 -0
  20. package/dist/packem_shared/{detectMimeType-S8WRsNtY.js → detectMimeType-CrDG3LaZ.js} +1 -1
  21. package/dist/packem_shared/failoverProvider-CAHQQueo.js +1 -0
  22. package/dist/packem_shared/{generateBoundary-CZ8kJuY6.js → generate-boundary-Cx8nXYS0.js} +1 -1
  23. package/dist/packem_shared/{generateMessageId-11Ls5JsR.js → generate-message-id-D4uA8gkj.js} +1 -1
  24. package/dist/packem_shared/headers-to-record-Qo124ImV.js +1 -0
  25. package/dist/packem_shared/httpProvider-CZD6LZX3.js +1 -0
  26. package/dist/packem_shared/infobipProvider-CtLwrUaP.js +1 -0
  27. package/dist/packem_shared/{mailCrabProvider-BEwRjB3F.js → mailCrabProvider-CM_CFDca.js} +1 -1
  28. package/dist/packem_shared/mailPaceProvider-B6yKvh6z.js +1 -0
  29. package/dist/packem_shared/mailerSendProvider-CeeIXFnW.js +1 -0
  30. package/dist/packem_shared/mailgunProvider-mmjKzouh.js +1 -0
  31. package/dist/packem_shared/mailjetProvider-DwN6i0VA.js +1 -0
  32. package/dist/packem_shared/mailomatProvider-DMQmjKHT.js +1 -0
  33. package/dist/packem_shared/mailtrapProvider-BN3UBEQw.js +1 -0
  34. package/dist/packem_shared/{makeRequest-DwxHX0xo.js → make-request-BDzF9W9D.js} +1 -1
  35. package/dist/packem_shared/mandrillProvider-370y7CLu.js +1 -0
  36. package/dist/packem_shared/mockProvider-DN5ZwutD.js +1 -0
  37. package/dist/packem_shared/nodemailerProvider-_w8QXMU-.js +1 -0
  38. package/dist/packem_shared/opentelemetryProvider-C_ZXOLSd.js +1 -0
  39. package/dist/packem_shared/plunkProvider-DfJumQ4U.js +1 -0
  40. package/dist/packem_shared/postalProvider-Bavx2FcH.js +1 -0
  41. package/dist/packem_shared/postmarkProvider-DFC0uvjO.js +1 -0
  42. package/dist/packem_shared/provider-base-Cmzx6BTO.js +1 -0
  43. package/dist/packem_shared/readFile-BlZxbhCU-C8Z4K-ib.js +1 -0
  44. package/dist/packem_shared/resendProvider-CfqU7UdE.js +1 -0
  45. package/dist/packem_shared/roundRobinProvider-1WQnuKR8.js +1 -0
  46. package/dist/packem_shared/scalewayProvider-be1HPimL.js +1 -0
  47. package/dist/packem_shared/sendGridProvider-BVI1sq3n.js +1 -0
  48. package/dist/packem_shared/smtpProvider-BV-ufR53.js +23 -0
  49. package/dist/packem_shared/sweegoProvider-7419CSAq.js +1 -0
  50. package/dist/packem_shared/validate-email-options-DfJ7llf8.js +1 -0
  51. package/dist/packem_shared/zeptomailProvider-C2lh0Xmo.js +1 -0
  52. package/dist/providers/ahasend/index.js +1 -1
  53. package/dist/providers/aws-ses/index.js +1 -1
  54. package/dist/providers/azure/index.js +1 -1
  55. package/dist/providers/brevo/index.js +1 -1
  56. package/dist/providers/brevo/types.d.ts +10 -3
  57. package/dist/providers/failover/index.js +1 -1
  58. package/dist/providers/http/index.js +1 -1
  59. package/dist/providers/infobip/index.js +1 -1
  60. package/dist/providers/mailcrab/index.js +1 -1
  61. package/dist/providers/mailersend/index.js +1 -1
  62. package/dist/providers/mailgun/index.js +1 -1
  63. package/dist/providers/mailjet/index.js +1 -1
  64. package/dist/providers/mailomat/index.js +1 -1
  65. package/dist/providers/mailpace/index.js +1 -1
  66. package/dist/providers/mailtrap/index.js +1 -1
  67. package/dist/providers/mandrill/index.js +1 -1
  68. package/dist/providers/mock/index.js +1 -1
  69. package/dist/providers/nodemailer/index.js +1 -1
  70. package/dist/providers/opentelemetry/index.js +1 -1
  71. package/dist/providers/plunk/index.js +1 -1
  72. package/dist/providers/postal/index.js +1 -1
  73. package/dist/providers/postmark/index.js +1 -1
  74. package/dist/providers/resend/index.js +1 -1
  75. package/dist/providers/roundrobin/index.js +1 -1
  76. package/dist/providers/scaleway/index.js +1 -1
  77. package/dist/providers/sendgrid/index.js +1 -1
  78. package/dist/providers/smtp/index.js +1 -1
  79. package/dist/providers/sweego/index.js +1 -1
  80. package/dist/providers/zeptomail/index.js +1 -1
  81. package/dist/types.d.ts +18 -0
  82. package/dist/utils/cache.d.ts +54 -0
  83. package/dist/utils/cache.js +1 -0
  84. package/dist/utils/create-logger.d.ts +2 -4
  85. package/dist/utils/format-email-address.js +1 -0
  86. package/dist/utils/normalize-email-aliases.d.ts +22 -0
  87. package/dist/utils/normalize-email-aliases.js +1 -0
  88. package/dist/utils/parse-address.js +1 -0
  89. package/dist/utils/validation/check-mx-records.d.ts +42 -0
  90. package/dist/utils/validation/check-mx-records.js +1 -0
  91. package/dist/utils/validation/disposable-email-domains.d.ts +13 -0
  92. package/dist/utils/validation/disposable-email-domains.js +1 -0
  93. package/dist/utils/validation/role-accounts.d.ts +21 -0
  94. package/dist/utils/validation/role-accounts.js +1 -0
  95. package/dist/utils/{validate-email-options.d.ts → validation/validate-email-options.d.ts} +1 -1
  96. package/dist/utils/validation/verify-email.d.ts +47 -0
  97. package/dist/utils/validation/verify-email.js +1 -0
  98. package/dist/utils/validation/verify-smtp.d.ts +39 -0
  99. package/dist/utils/validation/verify-smtp.js +4 -0
  100. package/package.json +49 -3
  101. package/dist/packem_shared/MailMessage-Hdgowmvi.js +0 -1
  102. package/dist/packem_shared/ahaSendProvider-NUD_kwyT.js +0 -1
  103. package/dist/packem_shared/azureProvider-Ckdrpmw9.js +0 -1
  104. package/dist/packem_shared/brevoProvider-CB3IYW4n.js +0 -1
  105. package/dist/packem_shared/buildMimeMessage-BPtd0pno.js +0 -2
  106. package/dist/packem_shared/comparePriority-BfiwjVsV.js +0 -1
  107. package/dist/packem_shared/createLogger-DlElSVQP.js +0 -1
  108. package/dist/packem_shared/failoverProvider-sam9n1AG.js +0 -1
  109. package/dist/packem_shared/formatEmailAddress-CHeME3Vk.js +0 -1
  110. package/dist/packem_shared/formatEmailAddresses-UegVOe5A.js +0 -1
  111. package/dist/packem_shared/headersToRecord-BKUTr40L.js +0 -1
  112. package/dist/packem_shared/httpProvider-BhN0RrK-.js +0 -1
  113. package/dist/packem_shared/infobipProvider-D8vYTHV4.js +0 -1
  114. package/dist/packem_shared/isPortAvailable-5kfsfo8u.js +0 -1
  115. package/dist/packem_shared/mailPaceProvider-C47Izgaj.js +0 -1
  116. package/dist/packem_shared/mailerSendProvider-C4uAo-fc.js +0 -1
  117. package/dist/packem_shared/mailgunProvider-B7upu_OV.js +0 -1
  118. package/dist/packem_shared/mailjetProvider-ReErm08u.js +0 -1
  119. package/dist/packem_shared/mailomatProvider-OlCT_O2i.js +0 -1
  120. package/dist/packem_shared/mailtrapProvider-hVMV3h6r.js +0 -1
  121. package/dist/packem_shared/mandrillProvider-DdnbkHZI.js +0 -1
  122. package/dist/packem_shared/mockProvider-BDWZJpea.js +0 -1
  123. package/dist/packem_shared/nodemailerProvider-BV21eRGX.js +0 -1
  124. package/dist/packem_shared/opentelemetryProvider-kAz62mKm.js +0 -1
  125. package/dist/packem_shared/parseAddress-CATTKGe_.js +0 -1
  126. package/dist/packem_shared/plunkProvider-Bs6K51lT.js +0 -1
  127. package/dist/packem_shared/postalProvider-Bcsxp-z6.js +0 -1
  128. package/dist/packem_shared/postmarkProvider-BUq3wuYD.js +0 -1
  129. package/dist/packem_shared/provider-base-_hbWXBdK.js +0 -1
  130. package/dist/packem_shared/readFile-BlZxbhCU-C8bCdiA2.js +0 -1
  131. package/dist/packem_shared/resendProvider-D-_HQpN_.js +0 -1
  132. package/dist/packem_shared/retry-D1MBqS49.js +0 -1
  133. package/dist/packem_shared/roundRobinProvider-CejLM1rZ.js +0 -1
  134. package/dist/packem_shared/scalewayProvider-1n6ePiGl.js +0 -1
  135. package/dist/packem_shared/sendGridProvider-B1T62dyX.js +0 -1
  136. package/dist/packem_shared/smtpProvider-CcAoRrkt.js +0 -23
  137. package/dist/packem_shared/sweegoProvider-CxFmEUh6.js +0 -1
  138. package/dist/packem_shared/validateEmailOptions-BzlJECG5.js +0 -1
  139. package/dist/packem_shared/zeptomailProvider-CWYQPAJk.js +0 -1
  140. package/dist/utils/compare-priority.d.ts +0 -16
  141. /package/dist/utils/{validate-email.d.ts → validation/validate-email.d.ts} +0 -0
  142. /package/dist/{packem_shared/validateEmail-BkVdVioP.js → utils/validation/validate-email.js} +0 -0
@@ -1 +0,0 @@
1
- var P=Object.defineProperty;var y=(i,r)=>P(i,"name",{value:r,configurable:!0});import{createRequire as $}from"node:module";import c from"./EmailError-zm2ffVav.js";import S from"./RequiredOptionError-CevW3u2K.js";import _ from"./generateMessageId-11Ls5JsR.js";import E from"./headersToRecord-BKUTr40L.js";import{makeRequest as f}from"./makeRequest-DwxHX0xo.js";import b from"./retry-D1MBqS49.js";import z from"./validateEmailOptions-BzlJECG5.js";import{defineProvider as k}from"./defineProvider-B9rSklAJ.js";import{c as q,h as w,P as K}from"./provider-base-_hbWXBdK.js";import{f as p,a as B}from"./address-formatter-Cm_E_ZMa.js";const I=$(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=y(i=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[r,u]=m.versions.node.split(".").map(Number);if(r>22||r===22&&u>=3||r===20&&u>=16)return m.getBuiltinModule(i)}return I(i)},"__cjs_getBuiltinModule"),{Buffer:j}=T("node:buffer"),s="ahasend",C="https://api.ahasend.com",x=3e4,G=3,W=k((i={})=>{if(!i.apiKey)throw new S(s,"apiKey");const r={apiKey:i.apiKey,debug:i.debug||!1,endpoint:i.endpoint||C,retries:i.retries||G,timeout:i.timeout||x,...i.logger&&{logger:i.logger}},u=new K,n=q(s,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(s,"Email ID is required to retrieve email details"),success:!1};await this.initialize();const o={Authorization:`Bearer ${r.apiKey}`,"Content-Type":"application/json"};n.debug("Retrieving email details",{id:e});const t=await b(async()=>f(`${r.endpoint}/emails/${e}`,{headers:o,method:"GET",timeout:r.timeout}),r.retries);return t.success?(n.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(n.debug("API request failed when retrieving email",t.error),{error:new c(s,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(o){return{error:w(s,"retrieve email",o,n),success:!1}}},async initialize(){await u.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(s,"AhaSend API not available or invalid API key");n.debug("Provider initialized successfully")},s)},async isAvailable(){try{return n.debug("Checking AhaSend API availability"),!!(await f(`${r.endpoint}/v2/ping`,{headers:{Authorization:`Bearer ${r.apiKey}`,"Content-Type":"application/json"},method:"GET",timeout:r.timeout})).success}catch(e){return n.debug("Error checking availability:",e),!1}},name:s,options:r,async sendEmail(e){try{const o=z(e);if(o.length>0)return{error:new c(s,`Invalid email options: ${o.join(", ")}`),success:!1};await this.initialize();const t={from:{email:e.from.email,name:e.from.name},subject:e.subject,to:p(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=p(e.cc)),e.bcc&&(t.bcc=p(e.bcc)),e.replyTo&&(t.replyTo=B(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 a=E(e.headers);t.headers=a}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async a=>{let d;if(a.content)if(typeof a.content=="string")d=a.content;else if(a.content instanceof Promise){const A=await a.content;d=j.from(A).toString("base64")}else d=a.content.toString("base64");else if(a.raw)d=typeof a.raw=="string"?a.raw:a.raw.toString("base64");else throw new c(s,`Attachment ${a.filename} has no content`);return{content:d,contentType:a.contentType||"application/octet-stream",filename:a.filename,...a.cid&&{cid:a.cid}}}))),n.debug("Sending email via AhaSend API",{subject:t.subject,to:t.to});const v={Authorization:`Bearer ${r.apiKey}`,"Content-Type":"application/json"},l=await b(async()=>f(`${r.endpoint}/send`,{headers:v,method:"POST",timeout:r.timeout},JSON.stringify(t)),r.retries);if(!l.success)return n.debug("API request failed when sending email",l.error),{error:l.error||new c(s,"Failed to send email"),success:!1};const g=l.data?.body,h=g?.messageId||g?.id||_();return n.debug("Email sent successfully",{messageId:h}),{data:{messageId:h,provider:s,response:l.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:w(s,"send email",o,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{W as default};
@@ -1 +0,0 @@
1
- var k=Object.defineProperty;var w=(n,l)=>k(n,"name",{value:l,configurable:!0});import{createRequire as z}from"node:module";import u from"./EmailError-zm2ffVav.js";import v from"./RequiredOptionError-CevW3u2K.js";import P from"./generateMessageId-11Ls5JsR.js";import j from"./headersToRecord-BKUTr40L.js";import{makeRequest as h}from"./makeRequest-DwxHX0xo.js";import T from"./retry-D1MBqS49.js";import _ from"./validateEmailOptions-BzlJECG5.js";import{defineProvider as B}from"./defineProvider-B9rSklAJ.js";import{j as y,k as C}from"./address-formatter-Cm_E_ZMa.js";import{c as E,P as q,h as S}from"./provider-base-_hbWXBdK.js";const $=z(import.meta.url),f=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,I=w(n=>{if(typeof f<"u"&&f.versions&&f.versions.node){const[l,t]=f.versions.node.split(".").map(Number);if(l>22||l===22&&t>=3||l===20&&t>=16)return f.getBuiltinModule(n)}return $(n)},"__cjs_getBuiltinModule"),{Buffer:p}=I("node:buffer"),s="azure",x=3e4,O=3,V=B((n={})=>{if(!n.region)throw new v(s,"region");if(!n.connectionString&&!n.accessToken)throw new v(s,"connectionString or accessToken");const l=n.endpoint||`https://${n.region}.communication.azure.com`,t={debug:n.debug||!1,endpoint:l,region:n.region,retries:n.retries||O,timeout:n.timeout||x,...n.connectionString&&{connectionString:n.connectionString},...n.accessToken&&{accessToken:n.accessToken},...n.logger&&{logger:n.logger}},g=new q,o=E(s,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 u(s,"Email ID is required to retrieve email details"),success:!1};await g.ensureInitialized(()=>this.initialize(),s);const a={"Content-Type":"application/json"};if(t.accessToken)a.Authorization=`Bearer ${t.accessToken}`;else if(t.connectionString){const c=t.connectionString.match(/endpoint=([^;]+);accesskey=([^;]+)/);c&&(a.Authorization=`Bearer ${c[2]}`)}o.debug("Retrieving email details",{id:e});const r=await T(async()=>h(`${t.endpoint}/emails/${e}`,{headers:a,method:"GET",timeout:t.timeout}),t.retries);return r.success?(o.debug("Email details retrieved successfully"),{data:r.data?.body,success:!0}):(o.debug("API request failed when retrieving email",r.error),{error:new u(s,`Failed to retrieve email: ${r.error instanceof Error?r.error.message:"Unknown error"}`,{cause:r.error}),success:!1})}catch(a){return{error:S(s,"retrieve email",a,o),success:!1}}},async initialize(){await g.ensureInitialized(async()=>{if(!await this.isAvailable())throw new u(s,"Azure Communication Services API not available or invalid credentials");o.debug("Provider initialized successfully")},s)},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;o.debug("Checking Azure Communication Services API availability");const a=await h(`${t.endpoint}/emails:send`,{headers:e,method:"POST",timeout:t.timeout},JSON.stringify({}));if(a.success)return!0;const r=a.data?.statusCode;return r===401||r===403?!1:r===400}catch(e){if(o.debug("Error checking availability:",e),e instanceof Error){const a=e.message;if(a.includes("401")||a.includes("403"))return!1}return!1}},name:s,options:t,async sendEmail(e){try{const a=_(e);if(a.length>0)return{error:new u(s,`Invalid email options: ${a.join(", ")}`),success:!1};await g.ensureInitialized(()=>this.initialize(),s);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=C(e.replyTo).email),e.importance&&(r.importance=e.importance),e.headers){const i=j(e.headers);r.headers=i}e.attachments&&e.attachments.length>0&&(r.attachments=await Promise.all(e.attachments.map(async i=>{let d;if(i.content)if(typeof i.content=="string")d=p.from(i.content,"utf8").toString("base64");else if(i.content&&typeof i.content.then=="function"){const A=await i.content;d=p.from(A).toString("base64")}else d=i.content.toString("base64");else if(i.raw)d=typeof i.raw=="string"?p.from(i.raw,"utf8").toString("base64"):i.raw.toString("base64");else throw new u(s,`Attachment ${i.filename} has no content`);return{contentInBase64:d,contentType:i.contentType||"application/octet-stream",name:i.filename}}))),o.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 i=t.connectionString.match(/endpoint=([^;]+);accesskey=([^;]+)/);if(i)c.Authorization=`Bearer ${i[2]}`;else return{error:new u(s,"Invalid connection string format"),success:!1}}const m=await T(async()=>h(`${t.endpoint}/emails:send`,{headers:c,method:"POST",timeout:t.timeout},JSON.stringify(r)),t.retries);if(!m.success)return o.debug("API request failed when sending email",m.error),{error:m.error||new u(s,"Failed to send email"),success:!1};const b=m.data?.body?.messageId||P();return o.debug("Email sent successfully",{messageId:b}),{data:{messageId:b,provider:s,response:m.data,sent:!0,timestamp:new Date},success:!0}}catch(a){return{error:S(s,"send email",a,o),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{V as default};
@@ -1 +0,0 @@
1
- var P=Object.defineProperty;var h=(o,a)=>P(o,"name",{value:a,configurable:!0});import{createRequire as A}from"node:module";import d from"./EmailError-zm2ffVav.js";import S from"./RequiredOptionError-CevW3u2K.js";import _ from"./generateMessageId-11Ls5JsR.js";import k from"./headersToRecord-BKUTr40L.js";import{makeRequest as p}from"./makeRequest-DwxHX0xo.js";import y from"./retry-D1MBqS49.js";import E from"./validateEmailOptions-BzlJECG5.js";import{defineProvider as $}from"./defineProvider-B9rSklAJ.js";import{c as B,P as q,h as b}from"./provider-base-_hbWXBdK.js";import{f,a as v}from"./address-formatter-Cm_E_ZMa.js";const j=A(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=h(o=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[a,c]=m.versions.node.split(".").map(Number);if(a>22||a===22&&c>=3||a===20&&c>=16)return m.getBuiltinModule(o)}return j(o)},"__cjs_getBuiltinModule"),{Buffer:C}=T("node:buffer"),i="brevo",z="https://api.brevo.com/v3",K=3e4,x=3,V=$((o={})=>{if(!o.apiKey)throw new S(i,"apiKey");const a={apiKey:o.apiKey,debug:o.debug||!1,endpoint:o.endpoint||z,retries:o.retries||x,timeout:o.timeout||K,...o.logger&&{logger:o.logger}},c=new q,n=B(i,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 d(i,"Email ID is required to retrieve email details"),success:!1};await c.ensureInitialized(()=>this.initialize(),i);const r={"api-key":a.apiKey,"Content-Type":"application/json"};n.debug("Retrieving email details",{id:e});const t=await y(async()=>p(`${a.endpoint}/smtp/emails/${e}`,{headers:r,method:"GET",timeout:a.timeout}),a.retries);return t.success?(n.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(n.debug("API request failed when retrieving email",t.error),{error:new d(i,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(r){return{error:b(i,"retrieve email",r,n),success:!1}}},async initialize(){await c.ensureInitialized(async()=>{if(!await this.isAvailable())throw new d(i,"Brevo API not available or invalid API key");n.debug("Provider initialized successfully")},i)},async isAvailable(){try{const e={"api-key":a.apiKey,"Content-Type":"application/json"};n.debug("Checking Brevo API availability");const r=await p(`${a.endpoint}/account`,{headers:e,method:"GET",timeout:a.timeout});return n.debug("Brevo 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 n.debug("Error checking availability:",e),!1}},name:i,options:a,async sendEmail(e){try{const r=E(e);if(r.length>0)return{error:new d(i,`Invalid email options: ${r.join(", ")}`),success:!1};await c.ensureInitialized(()=>this.initialize(),i);const t={sender:v(e.from),subject:e.subject,to:f(e.to)};if(e.html&&(t.htmlContent=e.html),e.text&&(t.textContent=e.text),e.cc&&(t.cc=f(e.cc)),e.bcc&&(t.bcc=f(e.bcc)),e.replyTo&&(t.replyTo=v(e.replyTo)),e.templateId&&(t.templateId=e.templateId,e.templateParams&&(t.params=e.templateParams)),e.tags&&e.tags.length>0&&(t.tags=e.tags),e.scheduledAt){const s=typeof e.scheduledAt=="number"?new Date(e.scheduledAt*1e3).toISOString():e.scheduledAt;t.scheduledAt=s}if(e.batchId&&(t.batchId=e.batchId),e.headers){const s=k(e.headers);t.headers=s}e.attachments&&e.attachments.length>0&&(t.attachment=await Promise.all(e.attachments.map(async s=>{let u;if(s.content)if(typeof s.content=="string")u=s.content;else if(s.content instanceof Promise){const I=await s.content;u=C.from(I).toString("base64")}else u=s.content.toString("base64");else if(s.raw)u=typeof s.raw=="string"?s.raw:s.raw.toString("base64");else throw new d(i,`Attachment ${s.filename} has no content`);return{content:u,name:s.filename,...s.contentType&&{type:s.contentType}}}))),n.debug("Sending email via Brevo API",{subject:t.subject,to:t.to});const w={"api-key":a.apiKey,"Content-Type":"application/json"},l=await y(async()=>p(`${a.endpoint}/smtp/email`,{headers:w,method:"POST",timeout:a.timeout},JSON.stringify(t)),a.retries);if(!l.success)return n.debug("API request failed when sending email",l.error),{error:l.error||new d(i,"Failed to send email"),success:!1};const g=l.data?.body?.messageId||_();return n.debug("Email sent successfully",{messageId:g}),{data:{messageId:g,provider:i,response:l.data,sent:!0,timestamp:new Date},success:!0}}catch(r){return{error:b(i,"send email",r,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{V as default};
@@ -1,2 +0,0 @@
1
- var v=Object.defineProperty;var p=(e,o)=>v(e,"name",{value:o,configurable:!0});import C from"./EmailError-zm2ffVav.js";import d from"./formatEmailAddress-CHeME3Vk.js";import l from"./formatEmailAddresses-UegVOe5A.js";import w from"./generateBoundary-CZ8kJuY6.js";import x from"./headersToRecord-BKUTr40L.js";import{s as h,a as b}from"./sanitize-header-wWav-Scu.js";var B=Object.defineProperty,E=p((e,o)=>B(e,"name",{value:o,configurable:!0}),"b");const m=globalThis.Buffer!==void 0,g=E(e=>{if(typeof e=="string"){if(m)return Buffer.from(e,"utf8").toString("base64");const t=new TextEncoder().encode(e);let r="";const a=8192;for(let s=0;s<t.length;s+=a){const f=t.subarray(s,Math.min(s+a,t.length));r+=String.fromCharCode.apply(void 0,f)}return btoa(r)}if(m&&e instanceof Buffer)return e.toString("base64");const o=e instanceof Uint8Array?e:new Uint8Array(e);if(m)return Buffer.from(o).toString("base64");let n="";const c=8192;for(let t=0;t<o.length;t+=c){const r=o.subarray(t,Math.min(t+c,o.length));n+=String.fromCharCode.apply(void 0,r)}return btoa(n)},"toBase64");var M=Object.defineProperty,j=p((e,o)=>M(e,"name",{value:o,configurable:!0}),"h");const S=globalThis.Buffer!==void 0,I=j(async e=>{const o=w(),n=[`From: ${d(e.from)}`,`To: ${l(e.to)}`];if(e.cc&&n.push(`Cc: ${l(e.cc)}`),e.bcc&&n.push(`Bcc: ${l(e.bcc)}`),e.replyTo&&n.push(`Reply-To: ${d(e.replyTo)}`),n.push(`Subject: ${h(e.subject)}`,"MIME-Version: 1.0"),e.headers){const c=x(e.headers);Object.entries(c).forEach(([t,r])=>{const a=b(t),s=h(r);n.push(`${a}: ${s}`)})}if(n.push(`Content-Type: multipart/mixed; boundary="${o}"`,""),e.text&&n.push(`--${o}`,"Content-Type: text/plain; charset=UTF-8","Content-Transfer-Encoding: 7bit","",e.text,""),e.html&&n.push(`--${o}`,"Content-Type: text/html; charset=UTF-8","Content-Transfer-Encoding: 7bit","",e.html,""),e.attachments&&e.attachments.length>0){const c=await Promise.all(e.attachments.map(async t=>{let r;if(t.raw!==void 0)r=t.raw;else{if(t.content===void 0)throw new C("attachment",`Attachment '${t.filename}' must have content, raw, or be resolved from path/href before building MIME message`);r=t.content instanceof Promise?await t.content:t.content}return{...t,resolvedContent:r}}));for(const t of c){n.push(`--${o}`);const r=t.contentType||"application/octet-stream",a=h(t.filename);n.push(`Content-Type: ${r}; name="${a}"`);const s=t.contentDisposition||"attachment";n.push(`Content-Disposition: ${s}; filename="${a}"`),t.cid&&n.push(`Content-ID: <${t.cid}>`),t.headers&&Object.entries(t.headers).forEach(([u,$])=>{const y=b(u),T=h($);n.push(`${y}: ${T}`)});const f=t.encoding||"base64";n.push(`Content-Transfer-Encoding: ${f}`,"");const i=t.resolvedContent;if(f==="base64")n.push(g(i));else if(f==="7bit"||f==="8bit")if(typeof i=="string")n.push(i);else if(S&&i instanceof Buffer)n.push(i.toString("utf8"));else{const u=new TextDecoder;n.push(u.decode(i))}else n.push(g(i));n.push("")}}return n.push(`--${o}--`),n.join(`\r
2
- `)},"buildMimeMessage");export{I as default};
@@ -1 +0,0 @@
1
- var r=Object.defineProperty;var o=(e,a)=>r(e,"name",{value:a,configurable:!0});var t=Object.defineProperty,i=o((e,a)=>t(e,"name",{value:a,configurable:!0}),"t");const h=i((e,a)=>e===a?0:e==="high"?-1:a==="high"||e==="low"?1:-1,"comparePriority");export{h as default};
@@ -1 +0,0 @@
1
- var $=Object.defineProperty;var u=(e,r)=>$(e,"name",{value:r,configurable:!0});var f=Object.defineProperty,n=u((e,r)=>f(e,"name",{value:r,configurable:!0}),"s");const b=n((e,r)=>{const t=n(()=>{},"noop");return r?{debug:n((o,...a)=>{r.log(`[${e}] ${o}`,...a)},"debug"),error:n((o,...a)=>{r.error(`[${e}] ${o}`,...a)},"error"),info:n((o,...a)=>{r.info(`[${e}] ${o}`,...a)},"info"),warn:n((o,...a)=>{r.warn(`[${e}] ${o}`,...a)},"warn")}:{debug:t,error:t,info:t,warn:t}},"createLogger");export{b as default};
@@ -1 +0,0 @@
1
- var w=Object.defineProperty;var b=(e,l)=>w(e,"name",{value:l,configurable:!0});import u from"./EmailError-zm2ffVav.js";import $ from"./RequiredOptionError-CevW3u2K.js";import A from"./generateMessageId-11Ls5JsR.js";import{defineProvider as E}from"./defineProvider-B9rSklAJ.js";import z from"./createLogger-DlElSVQP.js";var P=Object.defineProperty,p=b((e,l)=>P(e,"name",{value:l,configurable:!0}),"v");const k=p(e=>typeof e=="function","isProviderFactory"),F=p(e=>e!==null&&typeof e=="object"&&"sendEmail"in e&&"initialize"in e&&"isAvailable"in e,"isProvider"),o="failover",C=E((e={})=>{if(!e.mailers||e.mailers.length===0)throw new $(o,"mailers");const l={debug:e.debug||!1,mailers:e.mailers,retryAfter:e.retryAfter??60};let h=!1;const t=[],s=z(o,e.logger);let g;const m=p(async()=>g||(g=(async()=>{t.length=0;for(const a of l.mailers)try{let r;if(k(a))r=a({});else if(F(a))r=a;else{s.debug(`Skipping invalid mailer: ${a}`);continue}try{await r.initialize(),t.push(r),s.debug(`Initialized provider: ${r.name||"unknown"}`)}catch(c){s.debug(`Failed to initialize provider ${r.name||"unknown"}:`,c)}}catch(r){s.debug("Error processing mailer:",r)}if(t.length===0)throw new u(o,"No providers could be initialized")})(),g),"initializeProviders");return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!1,tracking:!1},async initialize(){if(!h)try{await m(),h=!0,s.debug(`Failover provider initialized with ${t.length} provider(s)`)}catch(a){throw new u(o,`Failed to initialize: ${a.message}`,{cause:a})}},async isAvailable(){try{t.length===0&&await m();for(const a of t)try{if(await a.isAvailable())return!0}catch{}return!1}catch{return!1}},name:o,options:l,async sendEmail(a){try{if(t.length===0&&await m(),t.length===0)return{error:new u(o,"No providers available"),success:!1};const r=[];let c;for(let n=0;n<t.length;n+=1){const f=t[n];if(!f)continue;const d=f.name||`provider-${n+1}`;s.debug(`Attempting to send email via ${d} (${n+1}/${t.length})`);try{if(!await f.isAvailable()){s.debug(`Provider ${d} is not available, skipping`),r.push(new u(o,`Provider ${d} is not available`));continue}const i=await f.sendEmail(a);if(i.success&&i.data)return s.debug(`Email sent successfully via ${d}`),{data:{...i.data,messageId:i.data.messageId||A(),provider:`${o}(${d})`},success:!0};if(i.error){c=i.error,r.push(i.error);const v=i.error instanceof Error?i.error.message:String(i.error);s.debug(`Failed to send via ${d}:`,v)}}catch(i){c=i instanceof Error?i:new Error(String(i)),r.push(c);const v=c instanceof Error?c.message:String(c);s.debug(`Exception sending via ${d}:`,v)}n<t.length-1&&l.retryAfter>0&&(s.debug(`Waiting ${l.retryAfter}ms before trying next provider`),await new Promise(i=>{setTimeout(()=>{i()},l.retryAfter)}))}const y=r.map(n=>n instanceof Error?n.message:String(n)).join("; ");return{error:new u(o,`All providers failed. Errors: ${y}`,{cause:c}),success:!1}}catch(r){return{error:new u(o,`Failed to send email: ${r.message}`,{cause:r}),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{C as default};
@@ -1 +0,0 @@
1
- var m=Object.defineProperty;var r=(e,a)=>m(e,"name",{value:a,configurable:!0});import o from"./EmailError-zm2ffVav.js";import{s as l}from"./sanitize-header-wWav-Scu.js";import t from"./validateEmail-BkVdVioP.js";var i=Object.defineProperty,n=r((e,a)=>i(e,"name",{value:a,configurable:!0}),"m");const p=n(e=>{if(!t(e.email))throw new o("email",`Invalid email address: ${e.email}`);return e.name?`${l(e.name)} <${e.email}>`:e.email},"formatEmailAddress");export{p as default};
@@ -1 +0,0 @@
1
- var t=Object.defineProperty;var r=(a,e)=>t(a,"name",{value:e,configurable:!0});import o from"./formatEmailAddress-CHeME3Vk.js";var m=Object.defineProperty,i=r((a,e)=>m(a,"name",{value:e,configurable:!0}),"m");const n=i(a=>Array.isArray(a)?a.map(e=>o(e)).join(", "):o(a),"formatEmailAddresses");export{n as default};
@@ -1 +0,0 @@
1
- var o=Object.defineProperty;var a=(e,r)=>o(e,"name",{value:r,configurable:!0});var c=Object.defineProperty,f=a((e,r)=>c(e,"name",{value:r,configurable:!0}),"t");const u=f(e=>{if(!(e instanceof Headers))return e;const r={};return e.forEach((t,n)=>{r[n]=t}),r},"headersToRecord");export{u as default};
@@ -1 +0,0 @@
1
- var v=Object.defineProperty;var p=(r,a)=>v(r,"name",{value:a,configurable:!0});import d from"./EmailError-zm2ffVav.js";import A from"./RequiredOptionError-CevW3u2K.js";import j from"./generateMessageId-11Ls5JsR.js";import{makeRequest as u}from"./makeRequest-DwxHX0xo.js";import O from"./validateEmailOptions-BzlJECG5.js";import{defineProvider as P}from"./defineProvider-B9rSklAJ.js";var C=Object.defineProperty,h=p((r,a)=>C(r,"name",{value:a,configurable:!0}),"f");const n="http",I="POST",f=3e4,z=P((r={})=>{if(!r.endpoint)throw new A(n,"endpoint");const a={apiKey:r.apiKey||"",endpoint:r.endpoint,headers:r.headers||{},method:r.method||I},m=h(()=>{const e={"Content-Type":"application/json",...a.headers};return a.apiKey&&(e.Authorization=`Bearer ${a.apiKey}`),e},"getStandardHeaders"),y=h(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},"formatRequest");let l=!1;return{features:{attachments:!1,batchSending:!1,customHeaders:!0,html:!0,replyTo:!1,scheduling:!1,tagging:!1,templates:!1,tracking:!1},async initialize(){if(!l){if(!await this.isAvailable())throw new d(n,"API endpoint not available");l=!0}},async isAvailable(){try{return!!(await u(a.endpoint,{headers:m(),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:n,options:a,async sendEmail(e){try{const t=O(e);if(t.length>0)return{error:new d(n,`Invalid email options: ${t.join(", ")}`),success:!1};l||await this.initialize();const s=m();e.headers&&Object.assign(s,e.headers);const b=y(e),g=e.endpointOverride||a.endpoint,w=e.methodOverride||a.method,o=await u(g,{headers:s,method:w,timeout:f},JSON.stringify(b));if(!o.success)return{error:new d(n,`Failed to send email: ${o.error?.message||"Unknown error"}`,{cause:o.error}),success:!1};let c;const i=o.data?.body;return i&&typeof i=="object"&&(c=i.id||i.messageId||i.data&&typeof i.data=="object"&&(i.data.id||i.data.messageId)),c||(c=j()),{data:{messageId:c,provider:n,response:o.data?.body,sent:!0,timestamp:new Date},success:!0}}catch(t){return{error:new d(n,`Failed to send email: ${t.message}`,{cause:t}),success:!1}}},async validateCredentials(){try{const e=await u(a.endpoint,{headers:m(),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{z as default};
@@ -1 +0,0 @@
1
- var T=Object.defineProperty;var b=(r,n)=>T(r,"name",{value:n,configurable:!0});import{createRequire as P}from"node:module";import c from"./EmailError-zm2ffVav.js";import z from"./RequiredOptionError-CevW3u2K.js";import E from"./generateMessageId-11Ls5JsR.js";import U from"./headersToRecord-BKUTr40L.js";import{makeRequest as g}from"./makeRequest-DwxHX0xo.js";import w from"./retry-D1MBqS49.js";import k from"./validateEmailOptions-BzlJECG5.js";import{defineProvider as S}from"./defineProvider-B9rSklAJ.js";import{c as q,P as K,h as v}from"./provider-base-_hbWXBdK.js";import{l as y}from"./address-formatter-Cm_E_ZMa.js";const $=P(import.meta.url),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=b(r=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[n,p]=d.versions.node.split(".").map(Number);if(n>22||n===22&&p>=3||n===20&&p>=16)return d.getBuiltinModule(r)}return $(r)},"__cjs_getBuiltinModule"),{Buffer:_}=j("node:buffer"),a="infobip",R="https://api.infobip.com",C=3e4,x=3,W=S((r={})=>{if(!r.apiKey)throw new z(a,"apiKey");const n=r.baseUrl||R,p=r.endpoint||`${n}/email/3/send`,s={apiKey:r.apiKey,baseUrl:n,debug:r.debug||!1,endpoint:p,retries:r.retries||x,timeout:r.timeout||C,...r.logger&&{logger:r.logger}},f=new K,o=q(a,r.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(a,"Email ID is required to retrieve email details"),success:!1};await f.ensureInitialized(()=>this.initialize(),a);const l={Authorization:`App ${s.apiKey}`,"Content-Type":"application/json"};o.debug("Retrieving email details",{id:e});const t=await w(async()=>g(`${s.baseUrl}/email/3/reports/${e}`,{headers:l,method:"GET",timeout:s.timeout}),s.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 c(a,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(l){return{error:v(a,"retrieve email",l,o),success:!1}}},async initialize(){await f.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(a,"Infobip API not available or invalid API key");o.debug("Provider initialized successfully")},a)},async isAvailable(){try{o.debug("Checking Infobip API availability");const e={Authorization:`App ${s.apiKey}`,"Content-Type":"application/json"};return(await g(`${s.baseUrl}/account/1/me`,{headers:e,method:"GET",timeout:s.timeout})).success}catch(e){return o.debug("Error checking availability:",e),!1}},name:a,options:s,async sendEmail(e){try{const l=k(e);if(l.length>0)return{error:new c(a,`Invalid email options: ${l.join(", ")}`),success:!1};await f.ensureInitialized(()=>this.initialize(),a);const t={from:typeof e.from=="string"?e.from:e.from.email,subject:e.subject,to:y(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=y(e.cc)),e.bcc&&(t.bcc=y(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 i=U(e.headers);t.headers=i}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async i=>{let u;if(i.content)if(typeof i.content=="string")u=i.content;else if(i.content instanceof Promise){const A=await i.content;u=_.from(A).toString("base64")}else u=i.content.toString("base64");else if(i.raw)u=typeof i.raw=="string"?i.raw:i.raw.toString("base64");else throw new c(a,`Attachment ${i.filename} has no content`);return{content:u,contentType:i.contentType||"application/octet-stream",name:i.filename}}))),o.debug("Sending email via Infobip API",{subject:t.subject,to:t.to});const I={Authorization:`App ${s.apiKey}`,"Content-Type":"application/json"},m=await w(async()=>g(s.endpoint,{headers:I,method:"POST",timeout:s.timeout},JSON.stringify(t)),s.retries);if(!m.success)return o.debug("API request failed when sending email",m.error),{error:m.error||new c(a,"Failed to send email"),success:!1};const h=m.data?.body?.messages?.[0]?.messageId||E();return o.debug("Email sent successfully",{messageId:h}),{data:{messageId:h,provider:a,response:m.data,sent:!0,timestamp:new Date},success:!0}}catch(l){return{error:v(a,"send email",l,o),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{W as default};
@@ -1 +0,0 @@
1
- var u=Object.defineProperty;var s=(o,e)=>u(o,"name",{value:e,configurable:!0});import{createRequire as a}from"node:module";const l=a(import.meta.url),n=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,d=s(o=>{if(typeof n<"u"&&n.versions&&n.versions.node){const[e,t]=n.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return n.getBuiltinModule(o)}return l(o)},"__cjs_getBuiltinModule"),{Socket:f}=d("node:net");var m=Object.defineProperty,c=s((o,e)=>m(o,"name",{value:e,configurable:!0}),"n");const b=c((o,e)=>new Promise(t=>{const r=new f,i=c(()=>{r.destroy(),t(!1)},"onError");r.setTimeout(1e3),r.on("error",i),r.on("timeout",i),r.connect(e,o,()=>{r.end(),t(!0)})}),"isPortAvailable");export{b as default};
@@ -1 +0,0 @@
1
- import c from"./EmailError-zm2ffVav.js";import P from"./RequiredOptionError-CevW3u2K.js";import I from"./generateMessageId-11Ls5JsR.js";import T from"./headersToRecord-BKUTr40L.js";import{makeRequest as d}from"./makeRequest-DwxHX0xo.js";import g from"./retry-D1MBqS49.js";import{s as A,a as k}from"./sanitize-header-wWav-Scu.js";import $ from"./validateEmailOptions-BzlJECG5.js";import{defineProvider as z}from"./defineProvider-B9rSklAJ.js";import{n as u,c as f}from"./address-formatter-Cm_E_ZMa.js";import{c as E,P as j,h}from"./provider-base-_hbWXBdK.js";const r="mailpace",C="https://app.mailpace.com/api/v1",M=3e4,S=3,N=z(((o={})=>{if(!o.apiToken)throw new P(r,"apiToken");const s={apiToken:o.apiToken,debug:o.debug||!1,endpoint:o.endpoint||C,retries:o.retries||S,timeout:o.timeout||M,...o.logger&&{logger:o.logger}},l=new j,i=E(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:h(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=$(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:f(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=f(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[k(v)]=A(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:h(r,"send email",a,i),success:!1}}},async validateCredentials(){return this.isAvailable()}}}));export{N as default};
@@ -1 +0,0 @@
1
- var T=Object.defineProperty;var h=(o,a)=>T(o,"name",{value:a,configurable:!0});import{createRequire as A}from"node:module";import l from"./EmailError-zm2ffVav.js";import k from"./RequiredOptionError-CevW3u2K.js";import z from"./generateMessageId-11Ls5JsR.js";import j from"./headersToRecord-BKUTr40L.js";import{makeRequest as p}from"./makeRequest-DwxHX0xo.js";import b from"./retry-D1MBqS49.js";import S from"./validateEmailOptions-BzlJECG5.js";import{defineProvider as $}from"./defineProvider-B9rSklAJ.js";import{c as C,P as E,h as y}from"./provider-base-_hbWXBdK.js";import{f,a as q}from"./address-formatter-Cm_E_ZMa.js";const I=A(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,P=h(o=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[a,c]=m.versions.node.split(".").map(Number);if(a>22||a===22&&c>=3||a===20&&c>=16)return m.getBuiltinModule(o)}return I(o)},"__cjs_getBuiltinModule"),{Buffer:_}=P("node:buffer"),s="mailersend",M="https://api.mailersend.com",B=3e4,R=3,Q=$((o={})=>{if(!o.apiToken)throw new k(s,"apiToken");const a={apiToken:o.apiToken,debug:o.debug||!1,endpoint:o.endpoint||M,retries:o.retries||R,timeout:o.timeout||B,...o.logger&&{logger:o.logger}},c=new E,n=C(s,o.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(s,"Email ID is required to retrieve email details"),success:!1};await c.ensureInitialized(()=>this.initialize(),s);const r={Authorization:`Bearer ${a.apiToken}`,"Content-Type":"application/json"};n.debug("Retrieving email details",{id:e});const t=await b(async()=>p(`${a.endpoint}/v1/activity/${e}`,{headers:r,method:"GET",timeout:a.timeout}),a.retries);return t.success?(n.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(n.debug("API request failed when retrieving email",t.error),{error:new l(s,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(r){return{error:y(s,"retrieve email",r,n),success:!1}}},async initialize(){await c.ensureInitialized(async()=>{if(!await this.isAvailable())throw new l(s,"MailerSend API not available or invalid API token");n.debug("Provider initialized successfully")},s)},async isAvailable(){try{const e={Authorization:`Bearer ${a.apiToken}`,"Content-Type":"application/json"};n.debug("Checking MailerSend API availability");const r=await p(`${a.endpoint}/v1/tokens/verify`,{headers:e,method:"GET",timeout:a.timeout});return n.debug("MailerSend 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 n.debug("Error checking availability:",e),!1}},name:s,options:a,async sendEmail(e){try{const r=S(e);if(r.length>0)return{error:new l(s,`Invalid email options: ${r.join(", ")}`),success:!1};await c.ensureInitialized(()=>this.initialize(),s);const t={from:{email:e.from.email,name:e.from.name},subject:e.subject,to:f(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=f(e.cc)),e.bcc&&(t.bcc=f(e.bcc)),e.replyTo&&(t.reply_to=q(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 i=j(e.headers);t.headers=i}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async i=>{let u;if(i.content)if(typeof i.content=="string")u=i.content;else if(i.content instanceof Promise){const w=await i.content;u=_.from(w).toString("base64")}else u=i.content.toString("base64");else if(i.raw)u=typeof i.raw=="string"?i.raw:i.raw.toString("base64");else throw new l(s,`Attachment ${i.filename} has no content`);return{content:u,filename:i.filename,...i.contentType&&{type:i.contentType},...i.cid&&{id:i.cid}}}))),n.debug("Sending email via MailerSend API",{subject:t.subject,to:t.to});const v={Authorization:`Bearer ${a.apiToken}`,"Content-Type":"application/json"},d=await b(async()=>p(`${a.endpoint}/v1/email`,{headers:v,method:"POST",timeout:a.timeout},JSON.stringify(t)),a.retries);if(!d.success)return n.debug("API request failed when sending email",d.error),{error:d.error||new l(s,"Failed to send email"),success:!1};const g=d.data?.body?.message_id||z();return n.debug("Email sent successfully",{messageId:g}),{data:{messageId:g,provider:s,response:d.data,sent:!0,timestamp:new Date},success:!0}}catch(r){return{error:y(s,"send email",r,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{Q as default};
@@ -1 +0,0 @@
1
- var I=Object.defineProperty;var y=(r,i)=>I(r,"name",{value:i,configurable:!0});import{createRequire as A}from"node:module";import m from"./EmailError-zm2ffVav.js";import T from"./RequiredOptionError-CevW3u2K.js";import R from"./generateMessageId-11Ls5JsR.js";import S from"./headersToRecord-BKUTr40L.js";import{makeRequest as h}from"./makeRequest-DwxHX0xo.js";import $ from"./retry-D1MBqS49.js";import _ from"./validateEmailOptions-BzlJECG5.js";import{defineProvider as z}from"./defineProvider-B9rSklAJ.js";import{a as E}from"./attachment-processor-2rHmfa7j.js";import{c as q,P as U,h as j}from"./provider-base-_hbWXBdK.js";import{b as v,c as k}from"./address-formatter-Cm_E_ZMa.js";const P=A(import.meta.url),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,C=y(r=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[i,n]=u.versions.node.split(".").map(Number);if(i>22||i===22&&n>=3||i===20&&n>=16)return u.getBuiltinModule(r)}return P(r)},"__cjs_getBuiltinModule"),{Buffer:b}=C("node:buffer");var M=Object.defineProperty,K=y((r,i)=>M(r,"name",{value:i,configurable:!0}),"k");const o="mailgun",B="https://api.mailgun.net",O=3e4,x=3,D=K(r=>{const i=[];for(const[n,a]of Object.entries(r))if(a!=null)if(Array.isArray(a))for(const e of a)i.push(`${encodeURIComponent(n)}=${encodeURIComponent(String(e))}`);else typeof a=="object"?i.push(`${encodeURIComponent(n)}=${encodeURIComponent(JSON.stringify(a))}`):i.push(`${encodeURIComponent(n)}=${encodeURIComponent(String(a))}`);return i.join("&")},"objectToFormData"),te=z((r={})=>{if(!r.apiKey)throw new T(o,"apiKey");if(!r.domain)throw new T(o,"domain");const i={apiKey:r.apiKey,debug:r.debug||!1,domain:r.domain,endpoint:r.endpoint||B,retries:r.retries||x,timeout:r.timeout||O,...r.logger&&{logger:r.logger}},n=new U,a=q(o,r.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 m(o,"Email ID is required to retrieve email details"),success:!1};await n.ensureInitialized(()=>this.initialize(),o);const s={Authorization:`Basic ${b.from(`api:${i.apiKey}`).toString("base64")}`,"Content-Type":"application/json"};a.debug("Retrieving email details",{id:e});const t=await $(async()=>h(`${i.endpoint}/v3/${i.domain}/events?message-id=${encodeURIComponent(e)}&limit=1`,{headers:s,method:"GET",timeout:i.timeout}),i.retries);if(!t.success)return a.debug("API request failed when retrieving email",t.error),{error:new m(o,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1};a.debug("Email details retrieved successfully");const p=t.data?.items||[],f=p.length>0?p[0]:void 0;return{data:f?.message?.headers||f?.storage||void 0,success:!0}}catch(s){return{error:j(o,"retrieve email",s,a),success:!1}}},async initialize(){await n.ensureInitialized(async()=>{if(!await this.isAvailable())throw new m(o,"Mailgun API not available or invalid API key/domain");a.debug("Provider initialized successfully")},o)},async isAvailable(){try{const e={Authorization:`Basic ${b.from(`api:${i.apiKey}`).toString("base64")}`,"Content-Type":"application/json"};a.debug("Checking Mailgun API availability");const s=await h(`${i.endpoint}/v3/domains/${i.domain}`,{headers:e,method:"GET",timeout:i.timeout});if(a.debug("Mailgun API availability check response:",{error:s.error instanceof Error?s.error.message:void 0,statusCode:s.data?.statusCode,success:s.success}),!s.success||!s.data||typeof s.data!="object")return!1;const{statusCode:t}=s.data;return typeof t=="number"&&t>=200&&t<300}catch(e){return a.debug("Error checking availability:",e),!1}},name:o,options:i,async sendEmail(e){try{const s=_(e);if(s.length>0)return{error:new m(o,`Invalid email options: ${s.join(", ")}`),success:!1};await n.ensureInitialized(()=>this.initialize(),o);const t={from:k(e.from),to:v(e.to).join(",")};if(e.subject&&(t.subject=e.subject),e.cc&&(t.cc=v(e.cc).join(",")),e.bcc&&(t.bcc=v(e.bcc).join(",")),e.replyTo&&(t["h:Reply-To"]=k(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=S(e.headers);for(const[c,g]of Object.entries(d))t[`h:${c}`]=g}if(e.attachments&&e.attachments.length>0){const d=await Promise.all(e.attachments.map((c,g)=>E(c,o,g)));for(const c of d)t[c.key]=c.content}a.debug("Sending email via Mailgun API",{subject:t.subject,to:t.to});const p={Authorization:`Basic ${b.from(`api:${i.apiKey}`).toString("base64")}`,"Content-Type":"application/x-www-form-urlencoded"},f=D(t),l=await $(async()=>h(`${i.endpoint}/v3/${i.domain}/messages`,{headers:p,method:"POST",timeout:i.timeout},f),i.retries);if(!l.success)return a.debug("API request failed when sending email",l.error),{error:l.error||new m(o,"Failed to send email"),success:!1};const w=l.data?.body?.id||R();return a.debug("Email sent successfully",{messageId:w}),{data:{messageId:w,provider:o,response:l.data,sent:!0,timestamp:new Date},success:!0}}catch(s){return{error:j(o,"send email",s,a),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{te as default};
@@ -1 +0,0 @@
1
- var P=Object.defineProperty;var b=(s,a)=>P(s,"name",{value:a,configurable:!0});import{createRequire as $}from"node:module";import d from"./EmailError-zm2ffVav.js";import v from"./RequiredOptionError-CevW3u2K.js";import M from"./generateMessageId-11Ls5JsR.js";import _ from"./headersToRecord-BKUTr40L.js";import{makeRequest as f}from"./makeRequest-DwxHX0xo.js";import w from"./retry-D1MBqS49.js";import z from"./validateEmailOptions-BzlJECG5.js";import{defineProvider as D}from"./defineProvider-B9rSklAJ.js";import{d as y,e as T}from"./address-formatter-Cm_E_ZMa.js";import{c as B,P as R,h as S}from"./provider-base-_hbWXBdK.js";const A=$(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,E=b(s=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[a,l]=m.versions.node.split(".").map(Number);if(a>22||a===22&&l>=3||a===20&&l>=16)return m.getBuiltinModule(s)}return A(s)},"__cjs_getBuiltinModule"),{Buffer:p}=E("node:buffer"),n="mailjet",k="https://api.mailjet.com",q=3e4,K=3,X=D(((s={})=>{if(!s.apiKey)throw new v(n,"apiKey");if(!s.apiSecret)throw new v(n,"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}},l=new R,o=B(n,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 d(n,"Email ID is required to retrieve email details"),success:!1};await l.ensureInitialized(()=>this.initialize(),n);const i={Authorization:`Basic ${p.from(`${a.apiKey}:${a.apiSecret}`).toString("base64")}`,"Content-Type":"application/json"};o.debug("Retrieving email details",{id:e});const t=await w(async()=>f(`${a.endpoint}/v3.1/REST/message/${e}`,{headers:i,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 d(n,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(i){return{error:S(n,"retrieve email",i,o),success:!1}}},async initialize(){await l.ensureInitialized(async()=>{if(!await this.isAvailable())throw new d(n,"Mailjet API not available or invalid API credentials");o.debug("Provider initialized successfully")},n)},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 i=await f(`${a.endpoint}/v3.1/REST/user`,{headers:e,method:"GET",timeout:a.timeout});return o.debug("Mailjet API availability check response:",{error:i.error instanceof Error?i.error.message:void 0,statusCode:i.data?.statusCode,success:i.success}),!!(i.success&&i.data&&typeof i.data=="object"&&"statusCode"in i.data&&typeof i.data.statusCode=="number"&&i.data.statusCode>=200&&i.data.statusCode<300)}catch(e){return o.debug("Error checking availability:",e),!1}},name:n,options:a,async sendEmail(e){try{const i=z(e);if(i.length>0)return{error:new d(n,`Invalid email options: ${i.join(", ")}`),success:!1};await l.ensureInitialized(()=>this.initialize(),n);const t={From:T(e.from),Subject:e.subject,To:y(e.to)};if(e.html&&(t.HTMLPart=e.html),e.text&&(t.TextPart=e.text),e.cc&&(t.Cc=y(e.cc)),e.bcc&&(t.Bcc=y(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 r=_(e.headers),c=[];for(const[g,I]of Object.entries(r))c.push({Name:g,Value:String(I)});c.length>0&&(t.Headers=c)}e.attachments&&e.attachments.length>0&&(t.Attachments=await Promise.all(e.attachments.map(async r=>{let c;if(r.content)if(typeof r.content=="string")c=r.content;else if(r.content instanceof Promise){const g=await r.content;c=p.from(g).toString("base64")}else c=r.content.toString("base64");else if(r.raw)c=typeof r.raw=="string"?r.raw:r.raw.toString("base64");else throw new d(n,`Attachment ${r.filename} has no content`);return{Base64Content:c,ContentType:r.contentType||"application/octet-stream",Filename:r.filename,...r.cid&&{ContentID:r.cid}}})));const j={Messages:[t]};o.debug("Sending email via Mailjet API",{subject:t.Subject,to:t.To});const C={Authorization:`Basic ${p.from(`${a.apiKey}:${a.apiSecret}`).toString("base64")}`,"Content-Type":"application/json"},u=await w(async()=>f(`${a.endpoint}/v3.1/send`,{headers:C,method:"POST",timeout:a.timeout},JSON.stringify(j)),a.retries);if(!u.success)return o.debug("API request failed when sending email",u.error),{error:u.error||new d(n,"Failed to send email"),success:!1};const h=u.data?.body?.Messages?.[0]?.To?.[0]?.MessageID?.toString()||M();return o.debug("Email sent successfully",{messageId:h}),{data:{messageId:h,provider:n,response:u.data,sent:!0,timestamp:new Date},success:!0}}catch(i){return{error:S(n,"send email",i,o),success:!1}}},async validateCredentials(){return this.isAvailable()}}}));export{X as default};
@@ -1 +0,0 @@
1
- var P=Object.defineProperty;var h=(s,a)=>P(s,"name",{value:a,configurable:!0});import{createRequire as A}from"node:module";import c from"./EmailError-zm2ffVav.js";import S from"./RequiredOptionError-CevW3u2K.js";import E from"./generateMessageId-11Ls5JsR.js";import K from"./headersToRecord-BKUTr40L.js";import{makeRequest as y}from"./makeRequest-DwxHX0xo.js";import b from"./retry-D1MBqS49.js";import k from"./validateEmailOptions-BzlJECG5.js";import{defineProvider as q}from"./defineProvider-B9rSklAJ.js";import{c as z,P as C,h as w}from"./provider-base-_hbWXBdK.js";import{f,a as M}from"./address-formatter-Cm_E_ZMa.js";const j=A(import.meta.url),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=h(s=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[a,l]=u.versions.node.split(".").map(Number);if(a>22||a===22&&l>=3||a===20&&l>=16)return u.getBuiltinModule(s)}return j(s)},"__cjs_getBuiltinModule"),{Buffer:_}=T("node:buffer"),i="mailomat",x="https://api.mailomat.com",R=3e4,B=3,Q=q((s={})=>{if(!s.apiKey)throw new S(i,"apiKey");const a={apiKey:s.apiKey,debug:s.debug||!1,endpoint:s.endpoint||x,retries:s.retries||B,timeout:s.timeout||R,...s.logger&&{logger:s.logger}},l=new C,n=z(i,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 c(i,"Email ID is required to retrieve email details"),success:!1};await l.ensureInitialized(()=>this.initialize(),i);const o={"Content-Type":"application/json","X-API-Key":a.apiKey};n.debug("Retrieving email details",{id:e});const t=await b(async()=>y(`${a.endpoint}/emails/${e}`,{headers:o,method:"GET",timeout:a.timeout}),a.retries);return t.success?(n.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(n.debug("API request failed when retrieving email",t.error),{error:new c(i,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(o){return{error:w(i,"retrieve email",o,n),success:!1}}},async initialize(){await l.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(i,"Mailomat API not available or invalid API key");n.debug("Provider initialized successfully")},i)},async isAvailable(){try{return n.debug("Checking Mailomat API availability"),!0}catch(e){return n.debug("Error checking availability:",e),!1}},name:i,options:a,async sendEmail(e){try{const o=k(e);if(o.length>0)return{error:new c(i,`Invalid email options: ${o.join(", ")}`),success:!1};await l.ensureInitialized(()=>this.initialize(),i);const t={from:{email:e.from.email,name:e.from.name},subject:e.subject,to:f(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=f(e.cc)),e.bcc&&(t.bcc=f(e.bcc)),e.replyTo&&(t.replyTo=M(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 r=K(e.headers);t.headers=r}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async r=>{let d;if(r.content)if(typeof r.content=="string")d=r.content;else if(r.content instanceof Promise){const I=await r.content;d=_.from(I).toString("base64")}else d=r.content.toString("base64");else if(r.raw)d=typeof r.raw=="string"?r.raw:r.raw.toString("base64");else throw new c(i,`Attachment ${r.filename} has no content`);return{content:d,contentType:r.contentType||"application/octet-stream",filename:r.filename,...r.cid&&{cid:r.cid}}}))),n.debug("Sending email via Mailomat API",{subject:t.subject,to:t.to});const v={"Content-Type":"application/json","X-API-Key":a.apiKey},m=await b(async()=>y(`${a.endpoint}/send`,{headers:v,method:"POST",timeout:a.timeout},JSON.stringify(t)),a.retries);if(!m.success)return n.debug("API request failed when sending email",m.error),{error:m.error||new c(i,"Failed to send email"),success:!1};const p=m.data?.body,g=p?.messageId||p?.id||E();return n.debug("Email sent successfully",{messageId:g}),{data:{messageId:g,provider:i,response:m.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:w(i,"send email",o,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{Q as default};
@@ -1 +0,0 @@
1
- var T=Object.defineProperty;var b=(o,a)=>T(o,"name",{value:a,configurable:!0});import{createRequire as _}from"node:module";import l from"./EmailError-zm2ffVav.js";import I from"./RequiredOptionError-CevW3u2K.js";import j from"./generateMessageId-11Ls5JsR.js";import C from"./headersToRecord-BKUTr40L.js";import{makeRequest as p}from"./makeRequest-DwxHX0xo.js";import h from"./retry-D1MBqS49.js";import E from"./validateEmailOptions-BzlJECG5.js";import{defineProvider as S}from"./defineProvider-B9rSklAJ.js";import{c as $,P as q,h as y}from"./provider-base-_hbWXBdK.js";import{f,a as z}from"./address-formatter-Cm_E_ZMa.js";const k=_(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,P=b(o=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[a,c]=m.versions.node.split(".").map(Number);if(a>22||a===22&&c>=3||a===20&&c>=16)return m.getBuiltinModule(o)}return k(o)},"__cjs_getBuiltinModule"),{Buffer:A}=P("node:buffer"),s="mailtrap",M="https://send.api.mailtrap.io",x=3e4,G=3,Q=S((o={})=>{if(!o.apiToken)throw new I(s,"apiToken");const a={apiToken:o.apiToken,debug:o.debug||!1,endpoint:o.endpoint||M,retries:o.retries||G,timeout:o.timeout||x,...o.logger&&{logger:o.logger}},c=new q,n=$(s,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(s,"Email ID is required to retrieve email details"),success:!1};await c.ensureInitialized(()=>this.initialize(),s);const r={"Api-Token":a.apiToken,"Content-Type":"application/json"};n.debug("Retrieving email details",{id:e});const t=await h(async()=>p(`${a.endpoint}/api/send/${e}`,{headers:r,method:"GET",timeout:a.timeout}),a.retries);return t.success?(n.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(n.debug("API request failed when retrieving email",t.error),{error:new l(s,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(r){return{error:y(s,"retrieve email",r,n),success:!1}}},async initialize(){await c.ensureInitialized(async()=>{if(!await this.isAvailable())throw new l(s,"Mailtrap API not available or invalid API token");n.debug("Provider initialized successfully")},s)},async isAvailable(){try{const e={"Api-Token":a.apiToken,"Content-Type":"application/json"};n.debug("Checking Mailtrap API availability");const r=await p(`${a.endpoint}/api/account`,{headers:e,method:"GET",timeout:a.timeout});return n.debug("Mailtrap 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 n.debug("Error checking availability:",e),!1}},name:s,options:a,async sendEmail(e){try{const r=E(e);if(r.length>0)return{error:new l(s,`Invalid email options: ${r.join(", ")}`),success:!1};await c.ensureInitialized(()=>this.initialize(),s);const t={from:{email:e.from.email,name:e.from.name},subject:e.subject,to:f(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=f(e.cc)),e.bcc&&(t.bcc=f(e.bcc)),e.replyTo&&(t.reply_to=z(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 i=C(e.headers);t.headers=i}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async i=>{let u;if(i.content)if(typeof i.content=="string")u=i.content;else if(i.content instanceof Promise){const w=await i.content;u=A.from(w).toString("base64")}else u=i.content.toString("base64");else if(i.raw)u=typeof i.raw=="string"?i.raw:i.raw.toString("base64");else throw new l(s,`Attachment ${i.filename} has no content`);return{content:u,filename:i.filename,type:i.contentType||"application/octet-stream",...i.cid&&{cid:i.cid}}}))),n.debug("Sending email via Mailtrap API",{subject:t.subject,to:t.to});const v={"Api-Token":a.apiToken,"Content-Type":"application/json"},d=await h(async()=>p(`${a.endpoint}/api/send`,{headers:v,method:"POST",timeout:a.timeout},JSON.stringify(t)),a.retries);if(!d.success)return n.debug("API request failed when sending email",d.error),{error:d.error||new l(s,"Failed to send email"),success:!1};const g=d.data?.body?.message_ids?.[0]||j();return n.debug("Email sent successfully",{messageId:g}),{data:{messageId:g,provider:s,response:d.data,sent:!0,timestamp:new Date},success:!0}}catch(r){return{error:y(s,"send email",r,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{Q as default};
@@ -1 +0,0 @@
1
- var A=Object.defineProperty;var h=(i,r)=>A(i,"name",{value:r,configurable:!0});import{createRequire as T}from"node:module";import d from"./EmailError-zm2ffVav.js";import k from"./RequiredOptionError-CevW3u2K.js";import z from"./generateMessageId-11Ls5JsR.js";import E from"./headersToRecord-BKUTr40L.js";import{makeRequest as f}from"./makeRequest-DwxHX0xo.js";import v from"./retry-D1MBqS49.js";import{s as w,a as M}from"./sanitize-header-wWav-Scu.js";import q from"./validateEmailOptions-BzlJECG5.js";import{defineProvider as K}from"./defineProvider-B9rSklAJ.js";import{g as y}from"./address-formatter-Cm_E_ZMa.js";import{c as N,P as O,h as _}from"./provider-base-_hbWXBdK.js";const C=T(import.meta.url),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,I=h(i=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[r,m]=g.versions.node.split(".").map(Number);if(r>22||r===22&&m>=3||r===20&&m>=16)return g.getBuiltinModule(i)}return C(i)},"__cjs_getBuiltinModule"),{Buffer:S}=I("node:buffer"),s="mandrill",V="https://mandrillapp.com/api/1.0",D=3e4,R=3,Z=K((i={})=>{if(!i.apiKey)throw new k(s,"apiKey");const r={apiKey:i.apiKey,debug:i.debug||!1,endpoint:i.endpoint||V,retries:i.retries||R,timeout:i.timeout||D,...i.logger&&{logger:i.logger}},m=new O,o=N(s,i.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(s,"Email ID is required to retrieve email details"),success:!1};await m.ensureInitialized(()=>this.initialize(),s),o.debug("Retrieving email details",{id:e});const l={id:e,key:r.apiKey},t={"Content-Type":"application/json"},n=await v(async()=>f(`${r.endpoint}/messages/info.json`,{headers:t,method:"POST",timeout:r.timeout},JSON.stringify(l)),r.retries);return n.success?(o.debug("Email details retrieved successfully"),{data:n.data?.body,success:!0}):(o.debug("API request failed when retrieving email",n.error),{error:new d(s,`Failed to retrieve email: ${n.error instanceof Error?n.error.message:"Unknown error"}`,{cause:n.error}),success:!1})}catch(l){return{error:_(s,"retrieve email",l,o),success:!1}}},async initialize(){await m.ensureInitialized(async()=>{if(!await this.isAvailable())throw new d(s,"Mandrill API not available or invalid API key");o.debug("Provider initialized successfully")},s)},async isAvailable(){try{o.debug("Checking Mandrill API availability");const e={key:r.apiKey},l={"Content-Type":"application/json"},t=await f(`${r.endpoint}/users/info.json`,{headers:l,method:"POST",timeout:r.timeout},JSON.stringify(e));return o.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 o.debug("Error checking availability:",e),!1}},name:s,options:r,async sendEmail(e){try{const l=q(e);if(l.length>0)return{error:new d(s,`Invalid email options: ${l.join(", ")}`),success:!1};await m.ensureInitialized(()=>this.initialize(),s);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:y(e.to,"to")};if(e.cc){const a=y(e.cc,"cc");for(const c of a)c.type="cc";t.to=[...t.to,...a]}if(e.bcc){const a=y(e.bcc,"bcc");for(const c of a)c.type="bcc";t.to=[...t.to,...a]}if(e.replyTo){const a=e.replyTo.name?`${w(e.replyTo.name)} <${e.replyTo.email}>`:e.replyTo.email;t.headers={"Reply-To":a}}if(e.headers){const a=E(e.headers),c={};Object.entries(a).forEach(([p,P])=>{c[M(p)]=w(P)}),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 a=>{let c;if(a.content)if(typeof a.content=="string")c=a.content;else if(a.content instanceof Promise){const p=await a.content;c=S.from(p).toString("base64")}else c=a.content.toString("base64");else if(a.raw)c=typeof a.raw=="string"?a.raw:a.raw.toString("base64");else throw new d(s,`Attachment ${a.filename} has no content`);return{content:c,name:a.filename,type:a.contentType||"application/octet-stream"}})));const n={key:r.apiKey,message:t};e.templateName&&(n.template_name=e.templateName,e.templateContent&&(n.template_content=e.templateContent),e.templateVariables&&(n.template_vars=e.templateVariables)),e.globalMergeVars&&(t.global_merge_vars=e.globalMergeVars),e.mergeVars&&(t.merge_vars=e.mergeVars),e.sendAt&&(n.send_at=e.sendAt),o.debug("Sending email via Mandrill API",{subject:t.subject,to:t.to});const j={"Content-Type":"application/json"},u=await v(async()=>f(`${r.endpoint}/messages/send.json`,{headers:j,method:"POST",timeout:r.timeout},JSON.stringify(n)),r.retries);if(!u.success)return o.debug("API request failed when sending email",u.error),{error:u.error||new d(s,"Failed to send email"),success:!1};const b=u.data?.body?.[0]?.id||z();return o.debug("Email sent successfully",{messageId:b}),{data:{messageId:b,provider:s,response:u.data,sent:!0,timestamp:new Date},success:!0}}catch(l){return{error:_(s,"send email",l,o),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{Z as default};
@@ -1 +0,0 @@
1
- var S=Object.defineProperty;var v=(m,l)=>S(m,"name",{value:l,configurable:!0});import c from"./EmailError-zm2ffVav.js";import I from"./createLogger-DlElSVQP.js";import D from"./generateMessageId-11Ls5JsR.js";import $ from"./validateEmailOptions-BzlJECG5.js";import{defineProvider as A}from"./defineProvider-B9rSklAJ.js";var F=Object.defineProperty,k=v((m,l)=>F(m,"name",{value:l,configurable:!0}),"k");const u="mock",p=new Map,M=k(()=>({debug:!1,delay:0,failureRate:0,randomDelayRange:{max:0,min:0},retries:0,simulateFailure:!1,timeout:0}),"createDefaultConfig"),q=A((m={})=>{const l=`mock-${Date.now()}-${Math.random().toString(36).slice(2,9)}`;p.has(l)||p.set(l,[]);const a=p.get(l);if(!a)throw new Error(`Storage not found for instance: ${l}`);let y=!1,f;const s={...M(),defaultResponse:m.defaultResponse,logger:m.logger,randomDelayRange:m.randomDelayRange||{max:0,min:0},...m},r=I(u,s.logger);return{clearSentMessages(){a.length=0,r.debug("Cleared all sent messages")},features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!1,tracking:!1},findMessageBy(e){return a.find(t=>e(t))},findMessagesBy(e){return a.filter(t=>e(t))},async getEmail(e){try{if(!e)return{error:new c(u,"Email ID is required to retrieve email details"),success:!1};const t=a.find(o=>o.id===e);return t?(r.debug("Retrieved email",{id:e}),{data:t,success:!0}):{error:new c(u,`Email with ID ${e} not found`),success:!1}}catch(t){return r.debug("Exception retrieving email",t),{error:new c(u,`Failed to retrieve email: ${t.message}`,{cause:t}),success:!1}}},getInstance(){return a},getLastSentMessage(){return a[a.length-1]},getMessagesBySubject(e){return a.filter(t=>t.options.subject===e)},getMessagesTo(e){return a.filter(t=>{const o=Array.isArray(t.options.to)?t.options.to:[t.options.to];let i=[];t.options.cc&&(i=Array.isArray(t.options.cc)?t.options.cc:[t.options.cc]);let d=[];return t.options.bcc&&(d=Array.isArray(t.options.bcc)?t.options.bcc:[t.options.bcc]),[...o,...i,...d].some(w=>w.email===e)})},getSentEmails(){return[...a]},getSentMessages(){return[...a]},getSentMessagesCount(){return a.length},async initialize(){y||(s.delay>0&&await new Promise(e=>{setTimeout(e,s.delay)}),y=!0,r.debug("Mock provider initialized"))},async isAvailable(){return!0},name:u,options:s,reset(){a.length=0,f=void 0;const e=M();s.debug=e.debug,s.delay=e.delay,s.failureRate=e.failureRate,s.retries=e.retries,s.simulateFailure=e.simulateFailure,s.timeout=e.timeout,s.randomDelayRange={max:0,min:0},s.defaultResponse=void 0,r.debug("Mock provider reset to initial state")},async sendEmail(e){try{const t=$(e);if(t.length>0)return{error:new c(u,`Invalid email options: ${t.join(", ")}`),success:!1};y||await this.initialize();let o=s.delay;if(s.randomDelayRange&&s.randomDelayRange.max>0){const{max:n,min:g}=s.randomDelayRange;o=Math.floor(Math.random()*(n-g+1))+g}if(o>0&&await new Promise(n=>{setTimeout(n,o)}),f!==void 0){const n=f;if(f=void 0,!n.successful)return r.debug("Using next response (failure)",n),{error:new c(u,n.errorMessages.join(", ")),success:!1};const g=n.messageId||D(),b=n.timestamp||new Date,h={messageId:g,provider:n.provider||u,response:n.response,sent:!0,timestamp:b},E={id:g,options:e,result:h,timestamp:b};return a.push(E),r.debug("Email stored using next response",{messageId:g}),{data:h,success:!0}}if(s.simulateFailure||s.failureRate>0&&Math.random()<s.failureRate)return r.debug("Simulating email send failure"),{error:new c(u,"Simulated failure"),success:!1};const i=s.defaultResponse?.successful?s.defaultResponse.messageId:D(),d=s.defaultResponse?.successful&&s.defaultResponse.timestamp?s.defaultResponse.timestamp:new Date,w=s.defaultResponse&&"response"in s.defaultResponse?s.defaultResponse.response:void 0,R={messageId:i,provider:u,response:w??{mock:!0,stored:!0},sent:!0,timestamp:d},x={id:i,options:e,result:R,timestamp:d};return a.push(x),r.debug("Email stored in mock provider",{messageId:i,subject:e.subject,to:Array.isArray(e.to)?e.to.map(n=>n.email):e.to.email}),{data:R,success:!0}}catch(t){return r.debug("Exception sending email",t),{error:new c(u,`Failed to send email: ${t.message}`,{cause:t}),success:!1}}},setDefaultResponse(e){s.defaultResponse=e,r.debug("Set default response",{receipt:e})},setDelay(e){if(e<0)throw new RangeError("Delay must be non-negative");s.delay=e,s.randomDelayRange={max:0,min:0},r.debug("Set fixed delay",{milliseconds:e})},setFailureRate(e){if(e<0||e>1)throw new RangeError("Failure rate must be between 0.0 and 1.0");s.failureRate=e,r.debug("Set failure rate",{rate:e})},setNextResponse(e){f=e,r.debug("Set next response",{receipt:e})},setRandomDelay(e,t){if(e<0||t<0||e>t)throw new RangeError("Invalid delay range");s.delay=0,s.randomDelayRange={max:t,min:e},r.debug("Set random delay range",{max:t,min:e})},async shutdown(){a.length=0,p.delete(l),r.debug("Mock provider shutdown")},async validateCredentials(){return!0},async waitForMessage(e,t=5e3){const o=Date.now();for(;;){const i=a.find(d=>e(d));if(i)return i;if(Date.now()-o>t)throw new Error("Timeout waiting for message");await new Promise(d=>{setTimeout(d,10)})}},async waitForMessageCount(e,t=5e3){const o=Date.now();for(;a.length<e;){if(Date.now()-o>t)throw new Error(`Timeout waiting for ${e} messages (got ${a.length})`);await new Promise(i=>{setTimeout(i,10)})}}}});export{q as default};
@@ -1 +0,0 @@
1
- var w=Object.defineProperty;var h=(s,r)=>w(s,"name",{value:r,configurable:!0});import v from"nodemailer";import p from"./EmailError-zm2ffVav.js";import g from"./RequiredOptionError-CevW3u2K.js";import T from"./generateMessageId-11Ls5JsR.js";import $ from"./headersToRecord-BKUTr40L.js";import b from"./validateEmailOptions-BzlJECG5.js";import{defineProvider as A}from"./defineProvider-B9rSklAJ.js";var E=Object.defineProperty,i=h((s,r)=>E(s,"name",{value:r,configurable:!0}),"s");const c="nodemailer",C=A((s={})=>{if(!s.transport)throw new g(c,"transport");let r;const l=i(t=>{const m=t||s.transport;return v.createTransport(m)},"createTransporter");let d=!1;const u=i(async()=>{if(!d)try{r=l(),await r.verify(),d=!0}catch(t){throw new p(c,`Failed to initialize nodemailer transport: ${t instanceof Error?t.message:String(t)}`,{cause:t instanceof Error?t:new Error(String(t))})}},"initializeProvider"),y=i(t=>{const m=i(e=>e.name?`${e.name} <${e.email}>`:e.email,"formatFromAddress"),a=i(e=>e.name?`${e.name} <${e.email}>`:e.email,"formatToAddress"),f=s.defaultFrom||t.from,n={from:m(f),subject:t.subject,to:Array.isArray(t.to)?t.to.map(e=>a(e)):a(t.to)};return t.text&&(n.text=t.text),t.html&&(n.html=t.html),t.cc&&(n.cc=Array.isArray(t.cc)?t.cc.map(e=>a(e)):a(t.cc)),t.bcc&&(n.bcc=Array.isArray(t.bcc)?t.bcc.map(e=>a(e)):a(t.bcc)),t.replyTo&&(n.replyTo=t.replyTo.name?`${t.replyTo.name} <${t.replyTo.email}>`:t.replyTo.email),t.headers&&(n.headers=$(t.headers)),t.attachments&&t.attachments.length>0&&(n.attachments=t.attachments.map(e=>{const o={filename:e.filename};return e.raw!==void 0?o.content=e.raw:e.content!==void 0?o.content=e.content:e.path&&(o.path=e.path),e.contentType&&(o.contentType=e.contentType),e.contentDisposition&&(o.contentDisposition=e.contentDisposition),e.cid&&(o.cid=e.cid),e.encoding&&(o.encoding=e.encoding),e.headers&&(o.headers=e.headers),e.href&&(o.href=e.href),e.httpHeaders&&(o.httpHeaders=e.httpHeaders),o})),n},"convertToNodemailerOptions");return{features:{attachments:!0,customHeaders:!0,html:!0,replyTo:!0},initialize:u,isAvailable:i(async()=>{try{return r||(r=l()),await r.verify(),!0}catch{return!1}},"isAvailable"),name:c,options:s,sendEmail:i(async t=>{const m=b(t);if(m.length>0)return{error:new p(c,`Validation failed: ${m.join(", ")}`),success:!1};try{if(d||await u(),!r)throw new p(c,"Transporter not initialized. Call initialize() first.");const a=t.transportOverride?l(t.transportOverride):r,f=y(t),n=await a.sendMail(f);return{data:{messageId:n.messageId||T(),provider:c,response:n,sent:!0,timestamp:new Date},success:!0}}catch(a){return{error:new p(c,`Failed to send email: ${a instanceof Error?a.message:String(a)}`,{cause:a instanceof Error?a:new Error(String(a))}),success:!1}}},"sendEmail"),shutdown:i(async()=>{r&&typeof r.close=="function"&&r.close(),r=void 0,d=!1},"shutdown"),validateCredentials:i(async()=>{try{return r||(r=l()),await r.verify(),!0}catch{return!1}},"validateCredentials")}});export{C as default};
@@ -1 +0,0 @@
1
- var E=Object.defineProperty;var v=(e,r)=>E(e,"name",{value:r,configurable:!0});import{context as h,trace as w,SpanStatusCode as f}from"@opentelemetry/api";import d from"./EmailError-zm2ffVav.js";import A from"./RequiredOptionError-CevW3u2K.js";import S from"./createLogger-DlElSVQP.js";import{defineProvider as $}from"./defineProvider-B9rSklAJ.js";var x=Object.defineProperty,c=v((e,r)=>x(e,"name",{value:r,configurable:!0}),"c");const z=c(e=>typeof e=="function","isProviderFactory"),C=c(e=>e!==null&&typeof e=="object"&&"sendEmail"in e&&"initialize"in e&&"isAvailable"in e,"isProvider"),s="opentelemetry",F="email",P="email.send",u=c(e=>e?typeof e=="string"?e:Array.isArray(e)?e.map(r=>typeof r=="string"?r:r.email).join(", "):e.email:"","formatEmailAddress"),k=c((e,r)=>{const i={"email.from":u(e.from),"email.subject":e.subject};return e.to&&(i["email.to"]=u(e.to)),e.cc&&(i["email.cc"]=u(e.cc)),e.bcc&&(i["email.bcc"]=u(e.bcc)),e.replyTo&&(i["email.reply_to"]=u(e.replyTo)),e.priority&&(i["email.priority"]=e.priority),e.tags&&e.tags.length>0&&(i["email.tags"]=e.tags.join(", ")),e.attachments&&e.attachments.length>0&&(i["email.attachments.count"]=e.attachments.length),r?(e.text&&(i["email.text.length"]=e.text.length),e.html&&(i["email.html.length"]=e.html.length)):(e.text&&(i["email.has_text"]=!0),e.html&&(i["email.has_html"]=!0)),i},"createSpanAttributes"),N=$(e=>{if(!e.provider)throw new A(s,"provider");const r={debug:e.debug||!1,logger:e.logger,provider:e.provider,recordContent:e.recordContent||!1,retries:e.retries||3,serviceName:e.serviceName||F,timeout:e.timeout||3e4,tracer:e.tracer};let i=!1,t;const m=S(s,e.logger),y=c(()=>r.tracer?r.tracer:w.getTracer(r.serviceName),"getTracer"),p=c(async()=>{try{if(z(r.provider))t=r.provider({});else if(C(r.provider))t=r.provider;else throw new d(s,"Invalid provider: must be a Provider instance or ProviderFactory function");await t.initialize(),m.debug(`Initialized wrapped provider: ${t.name||"unknown"}`)}catch(o){throw new d(s,`Failed to initialize wrapped provider: ${o.message}`,{cause:o})}},"initializeProvider"),b=c(()=>t?.features?t.features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!1,tracking:!1},"getFeatures");return{get features(){return b()},getInstance(){if(!t)throw new d(s,"Provider not initialized. Call initialize() first.");return t},async initialize(){if(!i)try{await p(),i=!0,m.debug("OpenTelemetry provider initialized")}catch(o){throw new d(s,`Failed to initialize: ${o.message}`,{cause:o})}},async isAvailable(){try{return t||await p(),await t.isAvailable()}catch{return!1}},name:s,options:r,async sendEmail(o){const n=y().startSpan(P);try{t||await p();const l=k(o,r.recordContent);n.setAttributes(l),t.name&&n.setAttribute("email.provider",t.name);const a=await h.with(w.setSpan(h.active(),n),async()=>await t.sendEmail(o));if(a.success&&a.data)return n.setStatus({code:f.OK}),n.setAttribute("email.message_id",a.data.messageId),n.setAttribute("email.sent",!0),a.data.timestamp&&n.setAttribute("email.timestamp",a.data.timestamp.toISOString()),m.debug(`Email sent successfully via ${t.name||"unknown"}`),{data:{...a.data,provider:`${s}(${t.name||"unknown"})`},success:!0};const g=a.error instanceof Error?a.error.message:String(a.error||"Unknown error");return n.setStatus({code:f.ERROR,message:g}),n.setAttribute("email.sent",!1),n.recordException(a.error instanceof Error?a.error:new Error(g)),m.debug(`Failed to send email via ${t.name||"unknown"}:`,g),a}catch(l){const a=l instanceof Error?l.message:String(l);return n.setStatus({code:f.ERROR,message:a}),n.setAttribute("email.sent",!1),n.recordException(l instanceof Error?l:new Error(a)),m.debug("Exception sending email:",a),{error:new d(s,`Failed to send email: ${a}`,{cause:l}),success:!1}}finally{n.end()}},async shutdown(){t&&t.shutdown&&await t.shutdown(),i=!1},async validateCredentials(){try{return t||await p(),t.validateCredentials?await t.validateCredentials():await t.isAvailable()}catch{return!1}}}});export{N as default};
@@ -1 +0,0 @@
1
- var m=Object.defineProperty;var o=(t,e)=>m(t,"name",{value:e,configurable:!0});import d from"./validateEmail-BkVdVioP.js";var h=Object.defineProperty,c=o((t,e)=>h(t,"name",{value:e,configurable:!0}),"l");const g=c(t=>{const e=t.replace(/^"(.+)"$/,"$1");return!(!e||e.length===0||e.includes("..")||e.startsWith(".")||e.endsWith("."))},"isValidLocalPart"),a=c(t=>{const e=t.indexOf("@[");if(e>0&&t.endsWith("]")){const n=t.length-1,l=t.slice(e+2,n);if(l.includes("@["))return!1;const i=t.slice(0,e),s=l;return!s||s.trim().length===0||s.includes("]")?!1:i?g(i):!1}if(t.includes("@[")&&!t.includes("]"))return!1;const r=t.match(/^"((?:[^"\\]|\\.)+)"@(.+)$/);if(r&&r[2]){const n=r[2];return n.startsWith("[")?!1:d(`test@${n}`)}return d(t)},"isValidEmailFormat"),$=c(t=>{if(!t||typeof t!="string")return;const e=t.trim();if(!e)return;const r=e.lastIndexOf("<"),n=e.lastIndexOf(">");if(r!==-1&&n>r){const i=e.slice(0,r).trim(),s=e.slice(r+1,n).trim();if(s&&a(s)){if(i){const f=i.replace(/^"(.+)"$/,"$1");return{email:s,name:f}}return{email:s}}}const l=e.match(/^<([^>]+)>$/);if(l&&l[1]){const i=l[1].trim();return a(i)?{email:i}:void 0}if(!(e.includes("]")&&!e.includes("@["))&&!(e.includes('"')&&!e.startsWith('"')&&e.indexOf('"')<e.indexOf("@"))){if(e.startsWith('"')){let i=1,s=!1;for(;i<e.length;)if(e[i]==="\\"&&i+1<e.length)i+=2;else if(e[i]==='"'){if(i+1<e.length&&e[i+1]==="@"){s=!0;break}i+=1}else i+=1;if(!s&&e.includes("@")){const f=e.indexOf("@"),u=e.slice(1).indexOf('"');if(u===-1||f<u+1)return}}if(a(e))return{email:e}}},"parseAddress");export{$ as default};
@@ -1 +0,0 @@
1
- var j=Object.defineProperty;var b=(i,t)=>j(i,"name",{value:t,configurable:!0});import{createRequire as A}from"node:module";import u from"./EmailError-zm2ffVav.js";import z from"./RequiredOptionError-CevW3u2K.js";import h from"./generateMessageId-11Ls5JsR.js";import E from"./headersToRecord-BKUTr40L.js";import{makeRequest as v}from"./makeRequest-DwxHX0xo.js";import w from"./retry-D1MBqS49.js";import{s as K,a as x}from"./sanitize-header-wWav-Scu.js";import S from"./validateEmailOptions-BzlJECG5.js";import{defineProvider as q}from"./defineProvider-B9rSklAJ.js";import{c as B,P as R,h as P}from"./provider-base-_hbWXBdK.js";const $=A(import.meta.url),f=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=b(i=>{if(typeof f<"u"&&f.versions&&f.versions.node){const[t,m]=f.versions.node.split(".").map(Number);if(t>22||t===22&&m>=3||t===20&&m>=16)return f.getBuiltinModule(i)}return $(i)},"__cjs_getBuiltinModule"),{Buffer:k}=T("node:buffer");var O=Object.defineProperty,C=b((i,t)=>O(i,"name",{value:t,configurable:!0}),"b");const s="plunk",D="https://api.useplunk.com/v1",H=3e4,N=3,ee=q((i={})=>{if(!i.apiKey)throw new z(s,"apiKey");const t={apiKey:i.apiKey,debug:i.debug||!1,endpoint:i.endpoint||D,logger:i.logger,retries:i.retries||N,timeout:i.timeout||H},m=new R,n=B(s,i.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 u(s,"Email ID is required to retrieve email details"),success:!1};await m.ensureInitialized(()=>this.initialize(),s);const c={Authorization:`Bearer ${t.apiKey}`,"Content-Type":"application/json"};n.debug("Retrieving email details",{id:e});const l=await w(async()=>v(`${t.endpoint}/emails/${e}`,{headers:c,method:"GET",timeout:t.timeout}),t.retries);return l.success?(n.debug("Email details retrieved successfully"),{data:l.data?.body,success:!0}):(n.debug("API request failed when retrieving email",l.error),{error:new u(s,`Failed to retrieve email: ${l.error instanceof Error?l.error.message:"Unknown error"}`,{cause:l.error}),success:!1})}catch(c){return{error:P(s,"retrieve email",c,n),success:!1}}},async initialize(){await m.ensureInitialized(async()=>{if(!await this.isAvailable())throw new u(s,"Plunk API not available or invalid API key");n.debug("Provider initialized successfully")},s)},async isAvailable(){try{return t.apiKey&&t.apiKey.length>0?(n.debug("API key exists, assuming Plunk is available"),!0):!1}catch(e){return n.debug("Error checking availability:",e),!1}},name:s,options:t,async sendEmail(e){try{const c=S(e);if(c.length>0)return{error:new u(s,`Invalid email options: ${c.join(", ")}`),success:!1};await m.ensureInitialized(()=>this.initialize(),s);const l=C(r=>Array.isArray(r)?r.map(o=>o.email):[r.email],"formatRecipients"),a={to:e.subscriber||(Array.isArray(e.to)?e.to[0]?.email:e.to.email)};if(e.from&&(a.from=e.from.email,e.from.name&&(a.from_name=e.from.name)),e.subject&&(a.subject=e.subject),e.html?a.body=e.html:e.text&&(a.body=e.text),e.html&&e.text&&(a.text=e.text),e.cc&&(a.cc=l(e.cc)),e.bcc&&(a.bcc=l(e.bcc)),e.replyTo&&(a.reply_to=e.replyTo.email,e.replyTo.name&&(a.reply_to_name=e.replyTo.name)),e.templateId&&(a.template=e.templateId),e.data&&(a.data=e.data),e.subscriberId&&(a.subscriber_id=e.subscriberId),e.headers){const r=E(e.headers),o={};Object.entries(r).forEach(([y,_])=>{o[x(y)]=K(_)}),a.headers=o}e.attachments&&e.attachments.length>0&&(a.attachments=await Promise.all(e.attachments.map(async r=>{let o;if(r.content)if(typeof r.content=="string")o=r.content;else if(r.content instanceof Promise){const y=await r.content;o=k.from(y).toString("base64")}else o=r.content.toString("base64");else if(r.raw)o=typeof r.raw=="string"?r.raw:r.raw.toString("base64");else throw new u(s,`Attachment ${r.filename} has no content`);return{content:o,filename:r.filename,type:r.contentType||"application/octet-stream"}}))),n.debug("Sending email via Plunk API",{subject:a.subject,to:a.to});const I={Authorization:`Bearer ${t.apiKey}`,"Content-Type":"application/json"},d=await w(async()=>v(`${t.endpoint}/send`,{headers:I,method:"POST",timeout:t.timeout},JSON.stringify(a)),t.retries);if(!d.success)return n.debug("API request failed when sending email",d.error),{error:d.error||new u(s,"Failed to send email"),success:!1};const p=d.data,g=p?.body&&typeof p.body=="object"?p.body.id||p.body.messageId||h():h();return n.debug("Email sent successfully",{messageId:g}),{data:{messageId:g,provider:s,response:d.data,sent:!0,timestamp:new Date},success:!0}}catch(c){return{error:P(s,"send email",c,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{ee as default};
@@ -1 +0,0 @@
1
- var I=Object.defineProperty;var y=(r,l)=>I(r,"name",{value:l,configurable:!0});import{createRequire as A}from"node:module";import c from"./EmailError-zm2ffVav.js";import b from"./RequiredOptionError-CevW3u2K.js";import T from"./generateMessageId-11Ls5JsR.js";import E from"./headersToRecord-BKUTr40L.js";import{makeRequest as f}from"./makeRequest-DwxHX0xo.js";import v from"./retry-D1MBqS49.js";import C from"./validateEmailOptions-BzlJECG5.js";import{defineProvider as K}from"./defineProvider-B9rSklAJ.js";import{h as g,i as w}from"./address-formatter-Cm_E_ZMa.js";import{c as k,P as q}from"./provider-base-_hbWXBdK.js";const j=A(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,$=y(r=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[l,n]=m.versions.node.split(".").map(Number);if(l>22||l===22&&n>=3||l===20&&n>=16)return m.getBuiltinModule(r)}return j(r)},"__cjs_getBuiltinModule"),{Buffer:S}=$("node:buffer"),i="postal",z=3e4,x=3,L=K((r={})=>{if(!r.host)throw new b(i,"host");if(!r.apiKey)throw new b(i,"apiKey");const l=r.endpoint||`https://${r.host}/api/v1`,n={apiKey:r.apiKey,debug:r.debug||!1,endpoint:l,host:r.host,retries:r.retries||x,timeout:r.timeout||z,...r.logger&&{logger:r.logger}},p=new q,o=k(i,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 c(i,"Email ID is required to retrieve email details"),success:!1};await p.ensureInitialized(()=>this.initialize(),i);const t={"Content-Type":"application/json","X-Server-API-Key":n.apiKey};o.debug("Retrieving email details",{id:e});const a=await v(async()=>f(`${n.endpoint}/messages/${e}`,{headers:t,method:"GET",timeout:n.timeout}),n.retries);return a.success?(o.debug("Email details retrieved successfully"),{data:a.data?.body,success:!0}):(o.debug("API request failed when retrieving email",a.error),{error:new c(i,`Failed to retrieve email: ${a.error instanceof Error?a.error.message:"Unknown error"}`,{cause:a.error}),success:!1})}catch(t){return o.debug("Exception retrieving email",t),{error:new c(i,`Failed to retrieve email: ${t.message}`,{cause:t}),success:!1}}},async initialize(){await p.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(i,"Postal API not available or invalid API key");o.debug("Provider initialized successfully")},i)},async isAvailable(){try{const e={"Content-Type":"application/json","X-Server-API-Key":n.apiKey};o.debug("Checking Postal API availability");const t=await f(`${n.endpoint}/server`,{headers:e,method:"GET",timeout:n.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:i,options:n,async sendEmail(e){try{const t=C(e);if(t.length>0)return{error:new c(i,`Invalid email options: ${t.join(", ")}`),success:!1};await p.ensureInitialized(()=>this.initialize(),i);const a={from:w(e.from).address,subject:e.subject,to:g(e.to).map(s=>s.address)};if(e.html&&(a.html_body=e.html),e.text&&(a.plain_body=e.text),e.cc&&(a.cc=g(e.cc).map(s=>s.address)),e.bcc&&(a.bcc=g(e.bcc).map(s=>s.address)),e.replyTo&&(a.reply_to=w(e.replyTo).address),e.templateId&&(a.template_id=e.templateId,e.templateVariables&&(a.template_variables=e.templateVariables)),e.tags&&e.tags.length>0&&(a.tag=e.tags.join(",")),e.headers){const s=E(e.headers);a.headers=s}e.attachments&&e.attachments.length>0&&(a.attachments=await Promise.all(e.attachments.map(async s=>{let u;if(s.content)if(typeof s.content=="string")u=s.content;else if(s.content instanceof Promise){const _=await s.content;u=S.from(_).toString("base64")}else u=s.content.toString("base64");else if(s.raw)u=typeof s.raw=="string"?s.raw:s.raw.toString("base64");else throw new c(i,`Attachment ${s.filename} has no content`);return{content_type:s.contentType||"application/octet-stream",data:u,name:s.filename}}))),o.debug("Sending email via Postal API",{subject:a.subject,to:a.to});const P={"Content-Type":"application/json","X-Server-API-Key":n.apiKey},d=await v(async()=>f(`${n.endpoint}/send/message`,{headers:P,method:"POST",timeout:n.timeout},JSON.stringify(a)),n.retries);if(!d.success)return o.debug("API request failed when sending email",d.error),{error:d.error||new c(i,"Failed to send email"),success:!1};const h=d.data?.body?.message_id?.toString()||T();return o.debug("Email sent successfully",{messageId:h}),{data:{messageId:h,provider:i,response:d.data,sent:!0,timestamp:new Date},success:!0}}catch(t){return o.debug("Exception sending email",t),{error:new c(i,`Failed to send email: ${t.message}`,{cause:t}),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{L as default};
@@ -1 +0,0 @@
1
- import d from"./EmailError-zm2ffVav.js";import T from"./RequiredOptionError-CevW3u2K.js";import P from"./generateMessageId-11Ls5JsR.js";import w from"./headersToRecord-BKUTr40L.js";import{makeRequest as u}from"./makeRequest-DwxHX0xo.js";import f from"./retry-D1MBqS49.js";import{s as I,a as A}from"./sanitize-header-wWav-Scu.js";import C from"./validateEmailOptions-BzlJECG5.js";import{defineProvider as S}from"./defineProvider-B9rSklAJ.js";import{b as j}from"./attachment-processor-2rHmfa7j.js";import{c as E,P as z,h}from"./provider-base-_hbWXBdK.js";import{b as p,c as v}from"./address-formatter-Cm_E_ZMa.js";const r="postmark",M="https://api.postmarkapp.com",$=3e4,O=3,J=S((o={})=>{if(!o.serverToken)throw new T(r,"serverToken");const s={debug:o.debug||!1,endpoint:o.endpoint||M,retries:o.retries||O,serverToken:o.serverToken,timeout:o.timeout||$,...o.logger&&{logger:o.logger}},m=new z,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=>j(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{J as default};
@@ -1 +0,0 @@
1
- var d=Object.defineProperty;var s=(t,e)=>d(t,"name",{value:e,configurable:!0});import o from"./EmailError-zm2ffVav.js";import c from"./createLogger-DlElSVQP.js";var l=Object.defineProperty,r=s((t,e)=>l(t,"name",{value:e,configurable:!0}),"o");class g{static{s(this,"ProviderState")}static{r(this,"ProviderState")}isInitialized=!1;get initialized(){return this.isInitialized}setInitialized(){this.isInitialized=!0}async ensureInitialized(e,i){if(!this.isInitialized)try{await e(),this.isInitialized=!0}catch(a){throw new o(i,`Failed to initialize: ${a.message}`,{cause:a})}}}const v=r((t,e)=>c(t,e),"createProviderLogger");r(t=>{if(!t.success||!t.data)return!1;const e=t.data;return typeof e.statusCode=="number"&&e.statusCode>=200&&e.statusCode<300},"isSuccessfulResponse");const z=r((t,e,i,a)=>{const n=`Failed to ${e}: ${i.message}`;return a&&a.debug(`Exception ${e}`,i),new o(t,n,{cause:i})},"handleProviderError");export{g as P,v as c,z as h};
@@ -1 +0,0 @@
1
- var vr=Object.defineProperty;var $=(e,n)=>vr(e,"name",{value:n,configurable:!0});import{createRequire as $r}from"node:module";const wr=$r(import.meta.url),C=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,yr=$(e=>{if(typeof C<"u"&&C.versions&&C.versions.node){const[n,i]=C.versions.node.split(".").map(Number);if(n>22||n===22&&i>=3||n===20&&i>=16)return C.getBuiltinModule(e)}return wr(e)},"__cjs_getBuiltinModule"),{createRequire:ne}=yr("node:module"),jr=0,zr=4;var Or=Object.defineProperty,Pr=$((e,n)=>Or(e,"name",{value:n,configurable:!0}),"t$2"),Mr=Object.defineProperty,_r=Pr((e,n)=>Mr(e,"name",{value:n,configurable:!0}),"t"),Er=Object.defineProperty,kr=_r((e,n)=>Er(e,"name",{value:n,configurable:!0}),"n");const Be=kr(e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},"assertValidFileOrDirectoryPath");var Ar=Object.defineProperty,Rr=$((e,n)=>Ar(e,"name",{value:n,configurable:!0}),"$e"),Br=Object.defineProperty,oe=Rr((e,n)=>Br(e,"name",{value:n,configurable:!0}),"W"),Tr=Object.defineProperty,u=oe((e,n)=>Tr(e,"name",{value:n,configurable:!0}),"u$1");let _e=u(()=>{var e=(()=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,d=Object.prototype.hasOwnProperty,b=u((t,r)=>{for(var o in r)n(t,o,{get:r[o],enumerable:!0})},"ne"),w=u((t,r,o,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of c(r))!d.call(t,s)&&s!==o&&n(t,s,{get:u(()=>r[s],"get"),enumerable:!(a=i(r,s))||a.enumerable});return t},"ae"),x=u(t=>w(n({},"__esModule",{value:!0}),t),"oe"),E={};b(E,{zeptomatch:u(()=>Me,"zeptomatch")});var T=u(t=>{const r=new Set,o=[t];for(let a=0;a<o.length;a++){const s=o[a];if(r.has(s))continue;r.add(s);const{children:l}=s;if(l?.length)for(let f=0,g=l.length;f<g;f++)o.push(l[f])}return Array.from(r)},"M"),D=u(t=>{let r="";const o=T(t);for(let a=0,s=o.length;a<s;a++){const l=o[a];if(!l.regex)continue;const f=l.regex.flags;if(r||(r=f),r!==f)throw new Error(`Inconsistent RegExp flags used: "${r}" and "${f}"`)}return r},"se"),ue=u((t,r,o)=>{const a=o.get(t);if(a!==void 0)return a;const s=t.partial??r;let l="";if(t.regex&&(l+=s?"(?:$|":"",l+=t.regex.source),t.children?.length){const f=Ye(t.children.map(g=>ue(g,r,o)).filter(Boolean));if(f?.length){const g=t.children.some(q=>!q.regex||!(q.partial??r)),h=f.length>1||s&&(!l.length||g);l+=h?s?"(?:$|":"(?:":"",l+=f.join("|"),l+=h?")":""}}return t.regex&&(l+=s?")":""),o.set(t,l),l},"O"),Ve=u((t,r)=>{const o=new Map,a=T(t);for(let s=a.length-1;s>=0;s--){const l=ue(a[s],r,o);if(!(s>0))return l}return""},"ie"),Ye=u(t=>Array.from(new Set(t)),"ue"),H=u((t,r,o)=>H.compile(t,o).test(r),"R");H.compile=(t,r)=>{const o=r?.partial??!1,a=Ve(t,o),s=D(t);return new RegExp(`^(?:${a})$`,s)};var He=H,Je=u((t,r)=>{const o=He.compile(t,r),a=`${o.source.slice(0,-1)}[\\\\/]?$`,s=o.flags;return new RegExp(a,s)},"le"),Ke=Je,Qe=u(t=>{const r=t.map(a=>a.source).join("|")||"$^",o=t[0]?.flags;return new RegExp(r,o)},"ve"),Xe=Qe,ce=u(t=>Array.isArray(t),"j"),S=u(t=>typeof t=="function","_"),et=u(t=>t.length===0,"he"),tt=(()=>{const{toString:t}=Function.prototype,r=/(?:^\(\s*(?:[^,.()]|\.(?!\.\.))*\s*\)\s*=>|^\s*[a-zA-Z$_][a-zA-Z0-9$_]*\s*=>)/;return o=>(o.length===0||o.length===1)&&r.test(t.call(o))})(),rt=u(t=>typeof t=="number","de"),nt=u(t=>typeof t=="object"&&t!==null,"xe"),ot=u(t=>t instanceof RegExp,"me"),st=(()=>{const t=/\\\(|\((?!\?(?::|=|!|<=|<!))/;return r=>t.test(r.source)})(),at=(()=>{const t=/^[a-zA-Z0-9_-]+$/;return r=>t.test(r.source)&&!r.flags.includes("i")})(),fe=u(t=>typeof t=="string","A"),P=u(t=>t===void 0,"f"),it=u(t=>{const r=new Map;return o=>{const a=r.get(o);if(a!==void 0)return a;const s=t(o);return r.set(o,s),s}},"ye"),pe=u((t,r,o={})=>{const a={cache:{},input:t,index:0,indexBacktrackMax:0,options:o,output:[]},s=M(r)(a),l=Math.max(a.index,a.indexBacktrackMax);if(s&&a.index===t.length)return a.output;throw new Error(`Failed to parse at index ${l}`)},"I"),p=u((t,r)=>ce(t)?lt(t,r):fe(t)?ge(t,r):ut(t,r),"i"),lt=u((t,r)=>{const o={};for(const a of t){if(a.length!==1)throw new Error(`Invalid character: "${a}"`);const s=a.charCodeAt(0);o[s]=!0}return a=>{const s=a.input;let l=a.index,f=l;for(;f<s.length&&s.charCodeAt(f)in o;)f+=1;if(f>l){if(!P(r)&&!a.options.silent){const g=s.slice(l,f),h=S(r)?r(g,s,`${l}`):r;P(h)||a.output.push(h)}a.index=f}return!0}},"we"),ut=u((t,r)=>{if(at(t))return ge(t.source,r);{const o=t.source,a=t.flags.replace(/y|$/,"y"),s=new RegExp(o,a);return st(t)&&S(r)&&!tt(r)?ct(s,r):ft(s,r)}},"$e"),ct=u((t,r)=>o=>{const a=o.index,s=o.input;t.lastIndex=a;const l=t.exec(s);if(l){const f=t.lastIndex;if(!o.options.silent){const g=r(...l,s,`${a}`);P(g)||o.output.push(g)}return o.index=f,!0}else return!1},"Ee"),ft=u((t,r)=>o=>{const a=o.index,s=o.input;if(t.lastIndex=a,t.test(s)){const l=t.lastIndex;if(!P(r)&&!o.options.silent){const f=S(r)?r(s.slice(a,l),s,`${a}`):r;P(f)||o.output.push(f)}return o.index=l,!0}else return!1},"Ce"),ge=u((t,r)=>o=>{const a=o.index,s=o.input;if(s.startsWith(t,a)){if(!P(r)&&!o.options.silent){const l=S(r)?r(t,s,`${a}`):r;P(l)||o.output.push(l)}return o.index+=t.length,!0}else return!1},"F"),J=u((t,r,o,a)=>{const s=M(t),l=r>1;return Q(K(me(f=>{let g=0;for(;g<o;){const h=f.index;if(!s(f)||(g+=1,f.index===h))break}return g>=r},l),a))},"k"),de=u((t,r)=>J(t,0,1,r),"L"),G=u((t,r)=>J(t,0,1/0,r),"$"),pt=u((t,r)=>J(t,1,1/0,r),"Re"),A=u((t,r)=>{const o=t.map(M);return Q(K(me(a=>{for(let s=0,l=o.length;s<l;s++)if(!o[s](a))return!1;return!0}),r))},"x"),y=u((t,r)=>{const o=t.map(M);return Q(K(a=>{for(let s=0,l=o.length;s<l;s++)if(o[s](a))return!0;return!1},r))},"p"),me=u((t,r=!0,o=!1)=>{const a=M(t);return r?s=>{const l=s.index,f=s.output.length,g=a(s);return!g&&!o&&(s.indexBacktrackMax=Math.max(s.indexBacktrackMax,s.index)),(!g||o)&&(s.index=l,s.output.length!==f&&(s.output.length=f)),g}:a},"q"),K=u((t,r)=>{const o=M(t);return r?a=>{if(a.options.silent)return o(a);const s=a.output.length;if(o(a)){const l=a.output.splice(s,1/0),f=r(l);return P(f)||a.output.push(f),!0}else return!1}:o},"B"),Q=(()=>{let t=0;return r=>{const o=M(r),a=t+=1;return s=>{var l;if(s.options.memoization===!1)return o(s);const f=s.index,g=(l=s.cache)[a]||(l[a]={indexMax:-1,queue:[]}),h=g.queue;if(f<=g.indexMax){const I=g.store||(g.store=new Map);if(h.length){for(let B=0,hr=h.length;B<hr;B+=2){const br=h[B*2],xr=h[B*2+1];I.set(br,xr)}h.length=0}const j=I.get(f);if(j===!1)return!1;if(rt(j))return s.index=j,!0;if(j)return s.index=j.index,j.output?.length&&s.output.push(...j.output),!0}const q=s.output.length,mr=o(s);if(g.indexMax=Math.max(g.indexMax,f),mr){const I=s.index,j=s.output.length;if(j>q){const B=s.output.slice(q,j);h.push(f,{index:I,output:B})}else h.push(f,I);return!0}else return h.push(f,!1),!1}}})(),he=u(t=>{let r;return o=>(r||(r=M(t())),r(o))},"G"),M=it(t=>{if(S(t))return et(t)?he(t):t;if(fe(t)||ot(t))return p(t);if(ce(t))return A(t);if(nt(t))return y(Object.values(t));throw new Error("Invalid rule")}),k=u(t=>t,"d"),gt=u(t=>typeof t=="string","ke"),dt=u(t=>{const r=new WeakMap,o=new WeakMap;return(a,s)=>{const l=s?.partial?o:r,f=l.get(a);if(f!==void 0)return f;const g=t(a,s);return l.set(a,g),g}},"Be"),mt=u(t=>{const r={},o={};return(a,s)=>{const l=s?.partial?o:r;return l[a]??(l[a]=t(a,s))}},"Pe"),ht=p(/\\./,k),bt=p(/./,k),xt=p(/\*\*\*+/,"*"),vt=p(/([^/{[(!])\*\*/,(t,r)=>`${r}*`),$t=p(/(^|.)\*\*(?=[^*/)\]}])/,(t,r)=>`${r}*`),wt=G(y([ht,xt,vt,$t,bt])),yt=wt,jt=u(t=>pe(t,yt,{memoization:!1}).join(""),"Ie"),zt=jt,be="abcdefghijklmnopqrstuvwxyz",Ot=u(t=>{let r="";for(;t>0;){const o=(t-1)%26;r=be[o]+r,t=Math.floor((t-1)/26)}return r},"Le"),xe=u(t=>{let r=0;for(let o=0,a=t.length;o<a;o++)r=r*26+be.indexOf(t[o])+1;return r},"V"),X=u((t,r)=>{if(r<t)return X(r,t);const o=[];for(;t<=r;)o.push(t++);return o},"b"),Pt=u((t,r,o)=>X(t,r).map(a=>String(a).padStart(o,"0")),"qe"),ve=u((t,r)=>X(xe(t),xe(r)).map(Ot),"W"),m=u(t=>({partial:!1,regex:new RegExp(t,"s"),children:[]}),"c"),W=u(t=>({children:t}),"y"),R=(()=>{const t=u((r,o,a)=>{if(a.has(r))return;a.add(r);const{children:s}=r;if(!s.length)s.push(o);else for(let l=0,f=s.length;l<f;l++)t(s[l],o,a)},"e");return r=>{if(!r.length)return W([]);for(let o=r.length-1;o>=1;o--){const a=new Set,s=r[o-1],l=r[o];t(s,l,a)}return r[0]}})(),_=u(()=>({regex:new RegExp("[\\\\/]","s"),children:[]}),"g"),Mt=p(/\\./,m),_t=p(/[$.*+?^(){}[\]\|]/,t=>m(`\\${t}`)),Et=p(/[\\\/]/,_),kt=p(/[^$.*+?^(){}[\]\|\\\/]+/,m),At=p(/^(?:!!)*!(.*)$/,(t,r)=>m(`(?!^${Me.compile(r).source}$).*?`)),Rt=p(/^(!!)+/),Bt=y([At,Rt]),Tt=p(/\/(\*\*\/)+/,()=>W([R([_(),m(".+?"),_()]),_()])),St=p(/^(\*\*\/)+/,()=>W([m("^"),R([m(".*?"),_()])])),Wt=p(/\/(\*\*)$/,()=>W([R([_(),m(".*?")]),m("$")])),qt=p(/\*\*/,()=>m(".*?")),$e=y([Tt,St,Wt,qt]),It=p(/\*\/(?!\*\*\/|\*$)/,()=>R([m("[^\\\\/]*?"),_()])),Ct=p(/\*/,()=>m("[^\\\\/]*")),we=y([It,Ct]),ye=p("?",()=>m("[^\\\\/]")),Lt=p("[",k),Ft=p("]",k),Zt=p(/[!^]/,"^\\\\/"),Nt=p(/[a-z]-[a-z]|[0-9]-[0-9]/i,k),Ut=p(/\\./,k),Dt=p(/[$.*+?^(){}[\|]/,t=>`\\${t}`),Gt=p(/[\\\/]/,"\\\\/"),Vt=p(/[^$.*+?^(){}[\]\|\\\/]+/,k),Yt=y([Ut,Dt,Gt,Nt,Vt]),je=A([Lt,de(Zt),G(Yt),Ft],t=>m(t.join(""))),Ht=p("{","(?:"),Jt=p("}",")"),Kt=p(/(\d+)\.\.(\d+)/,(t,r,o)=>Pt(+r,+o,Math.min(r.length,o.length)).join("|")),Qt=p(/([a-z]+)\.\.([a-z]+)/,(t,r,o)=>ve(r,o).join("|")),Xt=p(/([A-Z]+)\.\.([A-Z]+)/,(t,r,o)=>ve(r.toLowerCase(),o.toLowerCase()).join("|").toUpperCase()),er=y([Kt,Qt,Xt]),ze=A([Ht,er,Jt],t=>m(t.join(""))),tr=p("{"),rr=p("}"),nr=p(","),or=p(/\\./,m),sr=p(/[$.*+?^(){[\]\|]/,t=>m(`\\${t}`)),ar=p(/[\\\/]/,_),ir=p(/[^$.*+?^(){}[\]\|\\\/,]+/,m),lr=he(()=>Pe),ur=p("",()=>m("(?:)")),cr=pt(y([$e,we,ye,je,ze,lr,or,sr,ar,ir]),R),Oe=y([cr,ur]),Pe=A([tr,de(A([Oe,G(A([nr,Oe]))])),rr],W),fr=G(y([Bt,$e,we,ye,je,ze,Pe,Mt,_t,Et,kt]),R),pr=fr,gr=u(t=>pe(t,pr,{memoization:!1})[0],"kr"),dr=gr,ee=u((t,r,o)=>ee.compile(t,o).test(r),"N");ee.compile=(()=>{const t=mt((o,a)=>Ke(dr(zt(o)),a)),r=dt((o,a)=>Xe(o.map(s=>t(s,a))));return(o,a)=>gt(o)?t(o,a):r(o,a)})();var Me=ee;return x(E)})();return e.default||e},"_lazyMatch"),te;const Sr=u((e,n)=>(te||(te=_e(),_e=null),te(e,n)),"default");var Wr=Object.defineProperty,qr=oe((e,n)=>Wr(e,"name",{value:n,configurable:!0}),"t$1");const Ir=/^[A-Z]:\//i,z=qr((e="")=>e&&e.replaceAll("\\","/").replace(Ir,n=>n.toUpperCase()),"normalizeWindowsPath");var Cr=Object.defineProperty,v=oe((e,n)=>Cr(e,"name",{value:n,configurable:!0}),"r");const Lr=/^[/\\]{2}/,Fr=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,Te=/^[A-Z]:$/i,Ee=/^\/([A-Z]:)?$/i,Zr=/.(\.[^./]+)$/,Nr=/^[/\\]|^[a-z]:[/\\]/i,Ur=v(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd"),Se=v((e,n)=>{let i="",c=0,d=-1,b=0,w;for(let x=0;x<=e.length;++x){if(x<e.length)w=e[x];else{if(w==="/")break;w="/"}if(w==="/"){if(!(d===x-1||b===1))if(b===2){if(i.length<2||c!==2||!i.endsWith(".")||i.at(-2)!=="."){if(i.length>2){const E=i.lastIndexOf("/");E===-1?(i="",c=0):(i=i.slice(0,E),c=i.length-1-i.lastIndexOf("/")),d=x,b=0;continue}else if(i.length>0){i="",c=0,d=x,b=0;continue}}n&&(i+=i.length>0?"/..":"..",c=2)}else i.length>0?i+=`/${e.slice(d+1,x)}`:i=e.slice(d+1,x),c=x-d-1;d=x,b=0}else w==="."&&b!==-1?++b:b=-1}return i},"normalizeString"),N=v(e=>Fr.test(e),"isAbsolute"),We=v(function(e){if(e.length===0)return".";e=z(e);const n=Lr.exec(e),i=N(e),c=e.at(-1)==="/";return e=Se(e,!i),e.length===0?i?"/":c?"./":".":(c&&(e+="/"),Te.test(e)&&(e+="/"),n?i?`//${e}`:`//./${e}`:i&&!N(e)?`/${e}`:e)},"normalize"),qe=v((...e)=>{let n="";for(const i of e)if(i)if(n.length>0){const c=n[n.length-1]==="/",d=i[0]==="/";c&&d?n+=i.slice(1):n+=c||d?i:`/${i}`}else n+=i;return We(n)},"join"),re=v(function(...e){e=e.map(c=>z(c));let n="",i=!1;for(let c=e.length-1;c>=-1&&!i;c--){const d=c>=0?e[c]:Ur();!d||d.length===0||(n=`${d}/${n}`,i=N(d))}return n=Se(n,!i),i&&!N(n)?`/${n}`:n.length>0?n:"."},"resolve");v(function(e){return z(e)},"toNamespacedPath");const Ie=v(function(e){return Zr.exec(z(e))?.[1]??""},"extname");v(function(e,n){const i=re(e).replace(Ee,"$1").split("/"),c=re(n).replace(Ee,"$1").split("/");if(c[0][1]===":"&&i[0][1]===":"&&i[0]!==c[0])return c.join("/");const d=[...i];for(const b of d){if(c[0]!==b)break;i.shift(),c.shift()}return[...i.map(()=>".."),...c].join("/")},"relative");const Dr=v(e=>{const n=z(e).replace(/\/$/,"").split("/").slice(0,-1);return n.length===1&&Te.test(n[0])&&(n[0]+="/"),n.join("/")||(N(e)?"/":".")},"dirname");v(function(e){const n=[e.root,e.dir,e.base??e.name+e.ext].filter(Boolean);return z(e.root?re(...n):n.join("/"))},"format");const Gr=v((e,n)=>{const i=z(e).split("/").pop();return n&&i.endsWith(n)?i.slice(0,-n.length):i},"basename");v(function(e){const n=Nr.exec(e)?.[0]?.replaceAll("\\","/")??"",i=Gr(e),c=Ie(i);return{base:i,dir:Dr(e),ext:c,name:i.slice(0,i.length-c.length),root:n}},"parse");v((e,n)=>Sr(n,We(e)),"matchesGlob");var Vr=Object.defineProperty,se=$((e,n)=>Vr(e,"name",{value:n,configurable:!0}),"o$2"),Yr=Object.defineProperty,Y=se((e,n)=>Yr(e,"name",{value:n,configurable:!0}),"o");const Hr=ne(import.meta.url),L=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Jr=Y(e=>{if(typeof L<"u"&&L.versions&&L.versions.node){const[n,i]=L.versions.node.split(".").map(Number);if(n>22||n===22&&i>=3||n===20&&i>=16)return L.getBuiltinModule(e)}return Hr(e)},"__cjs_getBuiltinModule"),{fileURLToPath:Kr}=Jr("node:url");function ae(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}$(ae,"b$1");se(ae,"j");Y(ae,"getDefaultExportFromCjs");var ke,Ae;function ie(){return Ae||(Ae=1,ke=["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cr3","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),ke}$(ie,"v$1");se(ie,"z");Y(ie,"requireBinaryExtensions");var Qr=ie();const Xr=ae(Qr);var en=Object.defineProperty,O=Y((e,n)=>en(e,"name",{value:n,configurable:!0}),"r");const tn=new Set(Xr),rn=new Set(["/","\\",void 0]),Re=Symbol.for("pathe:normalizedAlias"),nn=/(^|[/\\])([^/\\]+?)(?=(?:\.[^.]+)?$)/,on=O((e,n)=>n.split("/").length-e.split("/").length,"compareAliases"),V=O((e="/")=>{const n=e.at(-1);return n==="/"||n==="\\"},"hasTrailingSlash"),Ce=O(e=>{if(e[Re])return e;const n=Object.fromEntries(Object.entries(e).toSorted(([i],[c])=>on(i,c)));for(const i in n)for(const c in n)c===i||i.startsWith(c)||n[i].startsWith(c)&&rn.has(n[i][c.length])&&(n[i]=n[c]+n[i].slice(c.length));return Object.defineProperty(n,Re,{enumerable:!1,value:!0}),n},"normalizeAliases");O((e,n)=>{e=z(e),n=Ce(n);for(const[i,c]of Object.entries(n)){if(!e.startsWith(i))continue;const d=V(i)?i.slice(0,-1):i;if(V(e[d.length]))return qe(c,e.slice(i.length))}return e},"resolveAlias");O(e=>nn.exec(e)?.[2],"filename");O((e,n)=>{e=z(e),n=Ce(n);for(const[i,c]of Object.entries(n).toReversed()){if(!e.startsWith(c))continue;const d=V(c)?c.slice(0,-1):c;if(V(e[d.length]))return qe(i,e.slice(c.length))}return e},"reverseResolveAlias");O(e=>/^(?:\.?\.[/\\]|\.\.\B)/.test(e)||e==="..","isRelative");O(e=>tn.has(Ie(e).slice(1).toLowerCase()),"isBinaryPath");const Le=O(e=>z(e instanceof URL?Kr(e):e),"toPath");O(()=>{if(!globalThis?.process)return!1;if(globalThis?.process?.platform==="win32"||globalThis?.process?.platform==="cygwin")return!0;const e=globalThis?.process?.env.OSTYPE;return typeof e!="string"?!1:/^(?:msys|cygwin)$/.test(e)},"isWindows");var sn=Object.defineProperty,Fe=$((e,n)=>sn(e,"name",{value:n,configurable:!0}),"t$1"),an=Object.defineProperty,le=Fe((e,n)=>an(e,"name",{value:n,configurable:!0}),"s");const ln=ne(import.meta.url),F=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,un=le(e=>{if(typeof F<"u"&&F.versions&&F.versions.node){const[n,i]=F.versions.node.split(".").map(Number);if(n>22||n===22&&i>=3||n===20&&i>=16)return F.getBuiltinModule(e)}return ln(e)},"__cjs_getBuiltinModule"),{access:cn}=un("node:fs/promises");var fn=Object.defineProperty,pn=le((e,n)=>fn(e,"name",{value:n,configurable:!0}),"o");async function U(e,n=jr){Be(e),e=Le(e);try{return await cn(e,n),!0}catch{return!1}}$(U,"i$1");Fe(U,"d");le(U,"m");pn(U,"isAccessible");var gn=Object.defineProperty,Ze=$((e,n)=>gn(e,"name",{value:n,configurable:!0}),"t"),dn=Object.defineProperty,Ne=Ze((e,n)=>dn(e,"name",{value:n,configurable:!0}),"t"),mn=Object.defineProperty,hn=Ne((e,n)=>mn(e,"name",{value:n,configurable:!0}),"o");let bn=class extends Error{static{$(this,"c")}static{Ze(this,"i")}static{Ne(this,"n")}static{hn(this,"PermissionError")}constructor(n){super(`EPERM: Operation not permitted, ${n}`)}get code(){return"EPERM"}set code(n){throw new Error("Cannot overwrite code EPERM")}get name(){return"PermissionError"}set name(n){throw new Error("Cannot overwrite name of PermissionError")}};var xn=Object.defineProperty,vn=$((e,n)=>xn(e,"name",{value:n,configurable:!0}),"f"),$n=Object.defineProperty,Ue=vn((e,n)=>$n(e,"name",{value:n,configurable:!0}),"i");const wn=ne(import.meta.url),Z=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,De=Ue(e=>{if(typeof Z<"u"&&Z.versions&&Z.versions.node){const[n,i]=Z.versions.node.split(".").map(Number);if(n>22||n===22&&i>=3||n===20&&i>=16)return Z.getBuiltinModule(e)}return wn(e)},"__cjs_getBuiltinModule"),{readFile:yn}=De("node:fs/promises"),{unzip:jn,brotliDecompress:zn}=De("node:zlib");var On=Object.defineProperty,Ge=Ue((e,n)=>On(e,"name",{value:n,configurable:!0}),"n");const Pn={brotli:zn,gzip:jn,none:Ge((e,n)=>{n(null,e)},"none")},kn=Ge(async(e,n)=>{if(Be(e),e=Le(e),!await U(e))throw new bn(`unable to read the non-accessible file: ${e}`);if(!await U(e,zr))throw new Error(`Unable to read the non-readable file: ${e}`);const{buffer:i,compression:c,encoding:d,flag:b}=n??{};return await yn(e,b?{encoding:d,flag:b}:{encoding:d}).then(async w=>await new Promise((x,E)=>{Pn[c??"none"](w,(T,D)=>{T?E(T):x(i?D:D.toString())})})).catch(w=>{throw w})},"readFile");export{kn as B};
@@ -1 +0,0 @@
1
- var I=Object.defineProperty;var h=(r,a)=>I(r,"name",{value:a,configurable:!0});import c from"./EmailError-zm2ffVav.js";import P from"./RequiredOptionError-CevW3u2K.js";import $ from"./generateMessageId-11Ls5JsR.js";import j from"./headersToRecord-BKUTr40L.js";import{makeRequest as f}from"./makeRequest-DwxHX0xo.js";import y from"./retry-D1MBqS49.js";import T from"./validateEmailOptions-BzlJECG5.js";import{defineProvider as C}from"./defineProvider-B9rSklAJ.js";import{c as E,P as S,h as b}from"./provider-base-_hbWXBdK.js";import{b as z,c as v,l as w}from"./address-formatter-Cm_E_ZMa.js";var k=Object.defineProperty,K=h((r,a)=>k(r,"name",{value:a,configurable:!0}),"p");const n="resend",R="https://api.resend.com",_=3e4,x=3,D=K(r=>{const a=[],l=/^[\w-]+$/;return l.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`),l.test(r.value)||a.push(`Tag value '${r.value}' for tag '${r.name}' must only contain ASCII letters, numbers, underscores, or dashes`),a},"validateTag"),M=C(((r={})=>{if(!r.apiKey)throw new P(n,"apiKey");const a={apiKey:r.apiKey,debug:r.debug||!1,endpoint:r.endpoint||R,logger:r.logger,retries:r.retries||x,timeout:r.timeout||_},l=new S,o=E(n,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(n,"Email ID is required to retrieve email details"),success:!1};await l.ensureInitialized(()=>this.initialize(),n);const t={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"};o.debug("Retrieving email details",{id:e});const i=await y(async()=>f(`${a.endpoint}/emails/${e}`,{headers:t,method:"GET",timeout:a.timeout}),a.retries);return i.success?(o.debug("Email details retrieved successfully"),{data:i.data?.body,success:!0}):(o.debug("API request failed when retrieving email",i.error),{error:new c(n,`Failed to retrieve email: ${i.error instanceof Error?i.error.message:"Unknown error"}`,{cause:i.error}),success:!1})}catch(t){return{error:b(n,"retrieve email",t,o),success:!1}}},async initialize(){await l.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(n,"Resend API not available or invalid API key");o.debug("Provider initialized successfully")},n)},async isAvailable(){try{if(a.apiKey&&a.apiKey.startsWith("re_"))return o.debug("API key format is valid, assuming Resend is available"),!0;const e={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"};o.debug("Checking Resend API availability");const t=await f(`${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"?(o.debug("API key is valid but restricted to only sending emails"),!0):(o.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 o.debug("Error checking availability:",e),!1}},name:n,options:a,async sendEmail(e){try{const t=T(e);if(t.length>0)return{error:new c(n,`Invalid email options: ${t.join(", ")}`),success:!1};await l.ensureInitialized(()=>this.initialize(),n);const i={from:v(e.from),headers:e.headers?j(e.headers):{},html:e.html,subject:e.subject,text:e.text,to:z(e.to)};if(e.cc&&(i.cc=w(e.cc)),e.bcc&&(i.bcc=w(e.bcc)),e.replyTo&&(i.reply_to=v(e.replyTo)),e.templateId&&(i.template=e.templateId,e.templateData&&(i.data=e.templateData)),e.scheduledAt&&(i.scheduled_at=typeof e.scheduledAt=="string"?e.scheduledAt:e.scheduledAt.toISOString()),e.tags&&e.tags.length>0){const s=[];if(e.tags.forEach(d=>{const p=D(d);p.length>0&&s.push(...p)}),s.length>0)return{error:new c(n,`Invalid email tags: ${s.join(", ")}`),success:!1};i.tags=e.tags.map(d=>({name:d.name,value:d.value}))}e.attachments&&e.attachments.length>0&&(i.attachments=await Promise.all(e.attachments.map(async s=>{let d;if(s.content)if(typeof s.content=="string")d=s.content;else if(s.content instanceof Promise){const p=await s.content;d=Buffer.from(p).toString("base64")}else d=s.content.toString("base64");else if(s.raw)d=typeof s.raw=="string"?s.raw:s.raw.toString("base64");else throw new c(n,`Attachment ${s.filename} has no content`);return{content:d,content_type:s.contentType,filename:s.filename,...s.path&&{path:s.path}}}))),o.debug("Sending email via Resend API",{subject:i.subject,to:i.to});const A={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"},u=await y(async()=>f(`${a.endpoint}/emails`,{headers:A,method:"POST",timeout:a.timeout},JSON.stringify(i)),a.retries);if(!u.success)return o.debug("API request failed when sending email",u.error),{error:u.error||new c(n,"Failed to send email"),success:!1};const m=u.data,g=m?.body&&typeof m.body=="object"&&m.body.id?m.body.id:$();return o.debug("Email sent successfully",{messageId:g}),{data:{messageId:g,provider:n,response:u.data,sent:!0,timestamp:new Date},success:!0}}catch(t){return{error:b(n,"send email",t,o),success:!1}}},async validateCredentials(){return this.isAvailable()}}}));export{M as default};
@@ -1 +0,0 @@
1
- var c=Object.defineProperty;var o=(r,e)=>c(r,"name",{value:e,configurable:!0});var i=Object.defineProperty,u=o((r,e)=>i(r,"name",{value:e,configurable:!0}),"i");const s=u(async(r,e=3,a=300)=>{try{const t=await r();return t.success||e<=0?t:(await new Promise(n=>{setTimeout(()=>{n()},a)}),s(r,e-1,a*2))}catch(t){return e<=0?{error:t instanceof Error?t:new Error(String(t)),success:!1}:(await new Promise(n=>{setTimeout(()=>{n()},a)}),s(r,e-1,a*2))}},"retry");export{s as default};
@@ -1 +0,0 @@
1
- var E=Object.defineProperty;var y=(e,u)=>E(e,"name",{value:u,configurable:!0});import f from"./EmailError-zm2ffVav.js";import A from"./RequiredOptionError-CevW3u2K.js";import k from"./createLogger-DlElSVQP.js";import{defineProvider as z}from"./defineProvider-B9rSklAJ.js";var P=Object.defineProperty,m=y((e,u)=>P(e,"name",{value:u,configurable:!0}),"f");const S=m(e=>typeof e=="function","isProviderFactory"),x=m(e=>e!=null&&typeof e=="object"&&"sendEmail"in e&&"initialize"in e&&"isAvailable"in e,"isProvider"),o="roundrobin",T=z((e={})=>{if(!e.mailers||e.mailers.length===0)throw new A(o,"mailers");const u={debug:e.debug||!1,logger:e.logger,mailers:e.mailers,retries:e.retries||3,retryAfter:e.retryAfter??60,timeout:e.timeout||3e4};let p=!1;const t=[];let a=0;const n=k(o,e.logger),v=m(async()=>{t.length=0;for(const i of u.mailers)try{let r;if(S(i))r=i({});else if(x(i))r=i;else{n.debug(`Skipping invalid mailer: ${i}`);continue}try{await r.initialize(),t.push(r),n.debug(`Initialized provider: ${r.name||"unknown"}`)}catch(s){n.debug(`Failed to initialize provider ${r.name||"unknown"}:`,s)}}catch(r){n.debug("Error processing mailer:",r)}if(t.length===0)throw new f(o,"No providers could be initialized");a=Math.floor(Math.random()*t.length),n.debug(`Round robin starting at index ${a} (${t[a]?.name||"unknown"})`)},"initializeProviders"),b=m(async()=>{if(t.length===0)return;const i=a;let r=0;for(;r<t.length;){const s=t[a];if(!s){a=(a+1)%t.length,r+=1;continue}const g=s.name||`provider-${a+1}`;try{if(await s.isAvailable())return a=(a+1)%t.length,n.debug(`Selected provider: ${g} (index ${a===0?t.length-1:a-1})`),s}catch{}a=(a+1)%t.length,r+=1,r<t.length&&u.retryAfter>0&&await new Promise(l=>{setTimeout(()=>{l(void 0)},u.retryAfter)})}return n.debug(`No available providers found, using provider at index ${i}`),t[i]||void 0},"getNextProvider");return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!1,tracking:!1},async initialize(){if(!p)try{await v(),p=!0,n.debug(`Round robin provider initialized with ${t.length} provider(s)`)}catch(i){throw new f(o,`Failed to initialize: ${i.message}`,{cause:i})}},async isAvailable(){try{return t.length===0&&await v(),(await Promise.allSettled(t.map(i=>i.isAvailable()))).some(i=>i.status==="fulfilled"&&i.value===!0)}catch{return!1}},name:o,options:u,async sendEmail(i){try{if(t.length===0&&await v(),t.length===0)return{error:new f(o,"No providers available"),success:!1};const r=await b();if(!r)return{error:new f(o,"No available providers found"),success:!1};const s=r.name||"unknown";n.debug(`Sending email via ${s}`);const g=await r.sendEmail(i);if(g.success)return n.debug(`Email sent successfully via ${s}`),{data:{...g.data,provider:`${o}(${s})`},success:!0};n.debug(`Failed to send via ${s}, trying next provider`);const l=[];g.error&&l.push(g.error);let w=0;for(;w<t.length-1;){const d=await b();if(!d||d===r)break;const h=d.name||"unknown";n.debug(`Retrying with ${h}`);try{const c=await d.sendEmail(i);if(c.success)return n.debug(`Email sent successfully via ${h} (after retry)`),{data:{...c.data,provider:`${o}(${h})`},success:!0};c.error&&l.push(c.error)}catch(c){l.push(c instanceof Error?c:new Error(String(c)))}w+=1}const $=l.map(d=>d instanceof Error?d.message:String(d)).join("; ");return{error:new f(o,`Failed to send email via all providers. Errors: ${$}`,{cause:l[0]instanceof Error?l[0]:new Error(String(l[0]))}),success:!1}}catch(r){return{error:new f(o,`Failed to send email: ${r.message}`,{cause:r}),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{T as default};
@@ -1 +0,0 @@
1
- var P=Object.defineProperty;var h=(r,l)=>P(r,"name",{value:l,configurable:!0});import{createRequire as A}from"node:module";import c from"./EmailError-zm2ffVav.js";import y from"./RequiredOptionError-CevW3u2K.js";import E from"./generateMessageId-11Ls5JsR.js";import k from"./headersToRecord-BKUTr40L.js";import{makeRequest as b}from"./makeRequest-DwxHX0xo.js";import w from"./retry-D1MBqS49.js";import z from"./validateEmailOptions-BzlJECG5.js";import{defineProvider as q}from"./defineProvider-B9rSklAJ.js";import{c as K,P as C,h as v}from"./provider-base-_hbWXBdK.js";import{f as p,a as x}from"./address-formatter-Cm_E_ZMa.js";const T=A(import.meta.url),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,S=h(r=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[l,s]=u.versions.node.split(".").map(Number);if(l>22||l===22&&s>=3||l===20&&s>=16)return u.getBuiltinModule(r)}return T(r)},"__cjs_getBuiltinModule"),{Buffer:_}=S("node:buffer"),a="scaleway",R="https://api.scaleway.com/transactional-email/v1alpha1",B=3e4,G=3,Q=q((r={})=>{if(!r.apiKey)throw new y(a,"apiKey");if(!r.region)throw new y(a,"region");const l=r.endpoint||R,s={apiKey:r.apiKey,debug:r.debug||!1,endpoint:l,region:r.region,retries:r.retries||G,timeout:r.timeout||B,...r.logger&&{logger:r.logger}},f=new C,n=K(a,r.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(a,"Email ID is required to retrieve email details"),success:!1};await f.ensureInitialized(()=>this.initialize(),a);const o={"Content-Type":"application/json","X-Auth-Token":s.apiKey};n.debug("Retrieving email details",{id:e});const t=await w(async()=>b(`${s.endpoint}/regions/${s.region}/emails/${e}`,{headers:o,method:"GET",timeout:s.timeout}),s.retries);return t.success?(n.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(n.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:v(a,"retrieve email",o,n),success:!1}}},async initialize(){await f.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(a,"Scaleway API not available or invalid API key");n.debug("Provider initialized successfully")},a)},async isAvailable(){try{return n.debug("Checking Scaleway API availability"),!0}catch(e){return n.debug("Error checking availability:",e),!1}},name:a,options:s,async sendEmail(e){try{const o=z(e);if(o.length>0)return{error:new c(a,`Invalid email options: ${o.join(", ")}`),success:!1};await f.ensureInitialized(()=>this.initialize(),a);const t={from:{email:e.from.email,...e.from.name&&{name:e.from.name}},subject:e.subject,to:p(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=p(e.cc)),e.bcc&&(t.bcc=p(e.bcc)),e.replyTo&&(t.replyTo=x(e.replyTo)),e.templateId&&(t.templateId=e.templateId,e.templateVariables&&(t.templateVariables=e.templateVariables)),e.projectId&&(t.projectId=e.projectId),e.headers){const i=k(e.headers);t.headers=i}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async i=>{let d;if(i.content)if(typeof i.content=="string")d=i.content;else if(i.content instanceof Promise){const j=await i.content;d=_.from(j).toString("base64")}else d=i.content.toString("base64");else if(i.raw)d=typeof i.raw=="string"?i.raw:i.raw.toString("base64");else throw new c(a,`Attachment ${i.filename} has no content`);return{content:d,name:i.filename,type:i.contentType||"application/octet-stream"}}))),n.debug("Sending email via Scaleway API",{subject:t.subject,to:t.to});const I={"Content-Type":"application/json","X-Auth-Token":s.apiKey},m=await w(async()=>b(`${s.endpoint}/regions/${s.region}/emails`,{headers:I,method:"POST",timeout:s.timeout},JSON.stringify(t)),s.retries);if(!m.success)return n.debug("API request failed when sending email",m.error),{error:m.error||new c(a,"Failed to send email"),success:!1};const g=m.data?.body?.id||E();return n.debug("Email sent successfully",{messageId:g}),{data:{messageId:g,provider:a,response:m.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:v(a,"send email",o,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{Q as default};
@@ -1 +0,0 @@
1
- import l from"./EmailError-zm2ffVav.js";import A from"./RequiredOptionError-CevW3u2K.js";import S from"./generateMessageId-11Ls5JsR.js";import P from"./headersToRecord-BKUTr40L.js";import{makeRequest as h}from"./makeRequest-DwxHX0xo.js";import b from"./retry-D1MBqS49.js";import $ from"./validateEmailOptions-BzlJECG5.js";import{defineProvider as j}from"./defineProvider-B9rSklAJ.js";import{f,a as v}from"./address-formatter-Cm_E_ZMa.js";import{c as G}from"./attachment-processor-2rHmfa7j.js";import{c as z,P as k,h as I}from"./provider-base-_hbWXBdK.js";const s="sendgrid",C="https://api.sendgrid.com/v3",E=3e4,T=3,J=j((o={})=>{if(!o.apiKey)throw new A(s,"apiKey");const a={apiKey:o.apiKey,debug:o.debug||!1,endpoint:o.endpoint||C,...o.logger&&{logger:o.logger},retries:o.retries||T,timeout:o.timeout||E},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:I(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=$(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:v(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=v(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=P(e.headers);n.headers=d}e.attachments&&e.attachments.length>0&&(n.attachments=await Promise.all(e.attachments.map(async d=>G(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)||S();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:I(s,"send email",t,i),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{J as default};
@@ -1,23 +0,0 @@
1
- var B=Object.defineProperty;var D=(l,r)=>B(l,"name",{value:r,configurable:!0});import{createRequire as X}from"node:module";import m from"./EmailError-zm2ffVav.js";import V from"./RequiredOptionError-CevW3u2K.js";import Z from"./buildMimeMessage-BPtd0pno.js";import J from"./generateMessageId-11Ls5JsR.js";import ee from"./isPortAvailable-5kfsfo8u.js";import te from"./validateEmailOptions-BzlJECG5.js";import{defineProvider as re}from"./defineProvider-B9rSklAJ.js";const q=X(import.meta.url),M=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,O=D(l=>{if(typeof M<"u"&&M.versions&&M.versions.node){const[r,y]=M.versions.node.split(".").map(Number);if(r>22||r===22&&y>=3||r===20&&y>=16)return M.getBuiltinModule(l)}return q(l)},"__cjs_getBuiltinModule"),{Buffer:L}=O("node:buffer"),{createHmac:W,createHash:K,createSign:Y}=O("node:crypto"),{createConnection:Q}=O("node:net"),{connect:z}=O("node:tls");var se=Object.defineProperty,p=D((l,r)=>se(l,"name",{value:r,configurable:!0}),"h");const u="smtp",oe=25,ae=465,ne=1e4,ie=!1,ce=5,_=3e4,ye=re((l={})=>{if(!l.host)throw new V(u,"host");const r={authMethod:l.authMethod||"LOGIN",debug:l.debug??!1,dkim:l.dkim,host:l.host,maxConnections:l.maxConnections??ce,oauth2:l.oauth2,password:l.password,pool:l.pool??!1,port:l.port!==void 0?l.port:l.secure?ae:oe,rejectUnauthorized:l.rejectUnauthorized??!0,retries:l.retries??0,secure:l.secure??ie,timeout:l.timeout??ne,user:l.user,...l.logger&&{logger:l.logger}};let y=!1;const A=[],g=[],b=p(e=>e.replaceAll(/[\r\n\t\v\f]/g," ").trim(),"sanitizeHeaderValue"),U=p(e=>{const c=e.split(`\r
2
- `),o={};for(const i of c)if(i.startsWith("250-")||i.startsWith("250 ")){const n=i.slice(4).trim().split(" "),s=n[0];s&&(o[s]=n.slice(1))}return o},"parseEhloResponse"),h=p(async(e,c,o)=>new Promise((i,n)=>{const s=Array.isArray(o)?o:[o];let a="",t="";const d=setTimeout(()=>{f(),n(new m(u,`Command timeout after ${r.timeout}ms: ${c?.slice(0,50)}...`))},r.timeout),f=p(()=>{e.removeListener("data",$),e.removeListener("error",v),d&&clearTimeout(d)},"cleanup"),$=p(S=>{a+=S.toString();const j=a.split(`\r
3
- `).filter(Boolean);if(j.length>0){const I=j[j.length-1];if(I){const C=I.match(/^(\d{3})[\s-]/);if(C){const[,H]=C;t=H,I[3]===" "&&(f(),s.includes(t)?i(a):n(new m(u,`Expected ${s.join(" or ")}, got ${t}: ${a.trim()}`)))}}}},"onData"),v=p(S=>{f(),n(new m(u,`Socket error: ${S.message}`,{cause:S}))},"onError");e.on("data",$),e.on("error",v),c&&e.write(`${c}\r
4
- `)}),"sendSmtpCommand"),k=p(async()=>{if(r.pool&&A.length>0){const e=A.pop();if(e&&!e.destroyed)return e}return r.pool&&A.length+1>=r.maxConnections?new Promise((e,c)=>{const o={reject:c,resolve:e};o.timeout=setTimeout(()=>{const i=g.indexOf(o);i!==-1&&g.splice(i,1),c(new m(u,`Connection queue timeout after ${_}ms`))},_),g.push(o)}):new Promise((e,c)=>{let o,i=!1,n;const s=p(()=>{o&&clearTimeout(o)},"cleanup");o=setTimeout(()=>{i||(i=!0,n&&!n.destroyed&&n.destroy(),s(),c(new m(u,`Connection timeout to ${r.host}:${r.port} after ${r.timeout}ms`)))},r.timeout);try{n=r.secure?z({host:r.host,port:r.port,rejectUnauthorized:r.rejectUnauthorized}):Q(r.port,r.host),n.on("error",a=>{i||(i=!0,s(),c(new m(u,`Connection error: ${a.message}`,{cause:a})))}),n.once("data",a=>{if(!i&&n){i=!0,s();const t=a.toString();t.slice(0,3)==="220"?e(n):(n.destroy(),c(new m(u,`Unexpected server greeting: ${t.trim()}`)))}})}catch(a){i||(i=!0,s(),c(new m(u,`Failed to create connection: ${a.message}`,{cause:a})))}})},"createSmtpConnection"),N=p(async e=>new Promise((c,o)=>{let i,n=!1,s;const a=p(()=>{i&&clearTimeout(i)},"cleanup");i=setTimeout(()=>{n||(n=!0,s&&!s.destroyed&&s.destroy(),a(),o(new m(u,`TLS connection timeout after ${r.timeout}ms`)))},r.timeout);try{const t={host:r.host,rejectUnauthorized:r.rejectUnauthorized,socket:e};s=z(t),s.on("error",d=>{n||(n=!0,a(),o(new m(u,`TLS connection error: ${d.message}`,{cause:d})))}),s.once("secure",()=>{!n&&s&&(n=!0,a(),c(s))})}catch(t){n||(n=!0,a(),o(new m(u,`Failed to upgrade to TLS: ${t.message}`,{cause:t})))}}),"upgradeToTLS"),x=p(e=>{if(e.destroyed||!r.pool){try{e.destroy()}catch{}return}if(g.length>0){const c=g.shift();if(c){clearTimeout(c.timeout),c.resolve(e);return}}A.push(e)},"releaseConnection"),T=p(async(e,c=!1)=>new Promise(o=>{try{if(c){e.write(`RSET\r
5
- `),x(e),o();return}e.write(`QUIT\r
6
- `),e.end(),e.once("close",()=>o())}catch{o()}}),"closeConnection"),P=p(async e=>{if(!r.user)return;const c=await h(e,`EHLO ${r.host}`,"250"),o=U(c),i=Object.keys(o).find(a=>a.toUpperCase()==="AUTH");if(!i&&(r.user||r.password))throw new m(u,"Server does not support authentication");const n=i?o[i]||[]:[];let{authMethod:s}=r;if(s||(n.includes("CRAM-MD5")?s="CRAM-MD5":n.includes("LOGIN")?s="LOGIN":n.includes("PLAIN")&&(s="PLAIN")),!s)throw new m(u,"No supported authentication methods");if(s==="OAUTH2"&&r.oauth2)try{const{accessToken:a,user:t}=r.oauth2,d=`user=${t}auth=Bearer ${a}`,f=L.from(d).toString("base64");await h(e,`AUTH XOAUTH2 ${f}`,"235");return}catch(a){const t=a.message;throw t.includes("535")||t.includes("Authentication failed")?new m(u,"Authentication failed: Invalid OAuth2 credentials"):a}if(s==="CRAM-MD5"&&r.password)try{const a=(await h(e,"AUTH CRAM-MD5","334")).split(" ")[1];if(!a)throw new m(u,"Invalid CRAM-MD5 challenge response");const t=L.from(a,"base64").toString("utf8"),d=W("md5",r.password);d.update(t);const f=d.digest("hex"),$=`${r.user} ${f}`;await h(e,L.from($).toString("base64"),"235");return}catch(a){const t=a.message;throw t.includes("535")||t.includes("Authentication failed")?new m(u,"Authentication failed: Invalid username or password"):a}if(s==="LOGIN"&&r.password)try{await h(e,"AUTH LOGIN","334"),await h(e,L.from(r.user).toString("base64"),"334"),await h(e,L.from(r.password).toString("base64"),"235");return}catch(a){const t=a.message;throw t.includes("535")||t.includes("Authentication failed")?new m(u,"Authentication failed: Invalid username or password"):a}if(s==="PLAIN"&&r.password)try{const a=L.from(`\0${r.user}\0${r.password}`).toString("base64");await h(e,`AUTH PLAIN ${a}`,"235");return}catch(a){const t=a.message;throw t.includes("535")||t.includes("Authentication failed")?new m(u,"Authentication failed: Invalid username or password"):a}throw new m(u,"Authentication failed - no valid credentials or method")},"authenticate"),F=p(e=>{if(!r.dkim)return e;const{domainName:c,keySelector:o,privateKey:i}=r.dkim;try{const[n,s]=e.split(`\r
7
- \r
8
- `);if(!n||!s)return e;const a=n.split(`\r
9
- `),t=p(w=>w.replaceAll(`\r
10
- `,`
11
- `).replaceAll(/\s+/g," ").trim(),"canonicalize"),d=t(s),f=K("sha256").update(d).digest("base64"),$=["from","to","subject","date"],v=a.filter(w=>$.some(R=>w.toLowerCase().startsWith(`${R}:`))),S=v.map(w=>w.split(":")[0]?.toLowerCase()||"").filter(Boolean).join(":"),j=Math.floor(Date.now()/1e3),I={a:"rsa-sha256",bh:f,c:"relaxed/relaxed",d:c,h:S,s:o,t:j.toString(),v:"1"},C=`DKIM-Signature: ${Object.entries(I).map(([w,R])=>`${w}=${R}`).join("; ")}; b=`,H=[...v,C].map(w=>t(w)).join(`\r
12
- `),E=Y("RSA-SHA256");E.update(H);const G=E.sign(i,"base64");return`${`${C}${G}`}\r
13
- ${a.join(`\r
14
- `)}\r
15
- \r
16
- ${s}`}catch(n){return console.error(`[${u}] DKIM signing error:`,n),e}},"signWithDkim");return{features:{attachments:!0,batchSending:r.pool,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!1,tracking:!1},async initialize(){if(!y)try{if(!await this.isAvailable())throw new m(u,`SMTP server not available at ${r.host}:${r.port}`);y=!0}catch(e){throw new m(u,`Failed to initialize: ${e.message}`,{cause:e})}},async isAvailable(){try{if(!await ee(r.host,r.port))return!1;const e=await k();return await T(e),!0}catch{return!1}},name:u,options:r,async sendEmail(e){try{const c=te(e);if(c.length>0)return{error:new m(u,`Invalid email options: ${c.join(", ")}`),success:!1};y||await this.initialize();let o=await k();try{if(await h(o,`EHLO ${r.host}`,"250"),!r.secure)try{const t=await h(o,`EHLO ${r.host}`,"250"),d=U(t);Object.keys(d).includes("STARTTLS")&&(await h(o,"STARTTLS","220"),o=await N(o),await h(o,`EHLO ${r.host}`,"250"))}catch(t){if(r.rejectUnauthorized!==!1)throw new m(u,`STARTTLS failed or not supported: ${t.message}`,{cause:t})}await P(o),await h(o,`MAIL FROM:<${e.from.email}>`,"250");const i=[];Array.isArray(e.to)?i.push(...e.to.map(t=>t.email)):i.push(e.to.email),e.cc&&(Array.isArray(e.cc)?i.push(...e.cc.map(t=>t.email)):i.push(e.cc.email)),e.bcc&&(Array.isArray(e.bcc)?i.push(...e.bcc.map(t=>t.email)):i.push(e.bcc.email));for(const t of i)await h(o,`RCPT TO:<${t}>`,"250");await h(o,"DATA","354");let n=await Z(e);const s=[];if(e.dsn){const t=[];e.dsn.success&&t.push("SUCCESS"),e.dsn.failure&&t.push("FAILURE"),e.dsn.delay&&t.push("DELAY"),t.length>0&&s.push(`X-DSN-NOTIFY: ${t.join(",")}`)}if(e.priority){let t="";switch(e.priority){case"high":{t="1 (Highest)",s.push("Importance: High");break}case"low":{t="5 (Lowest)",s.push("Importance: Low");break}case"normal":{t="3 (Normal)",s.push("Importance: Normal");break}default:{t="3 (Normal)";break}}s.push(`X-Priority: ${t}`)}if(e.inReplyTo&&s.push(`In-Reply-To: ${b(e.inReplyTo)}`),e.references){const t=Array.isArray(e.references)?e.references.map(d=>b(d)).join(" "):b(e.references);s.push(`References: ${t}`)}if(e.listUnsubscribe){const t=Array.isArray(e.listUnsubscribe)?e.listUnsubscribe.map(d=>`<${b(d)}>`).join(", "):`<${b(e.listUnsubscribe)}>`;s.push(`List-Unsubscribe: ${t}`)}if(e.googleMailHeaders){const{googleMailHeaders:t}=e;t.feedbackId&&s.push(`Feedback-ID: ${b(t.feedbackId)}`),t.promotionalContent&&s.push("X-Google-Promotion: promotional"),t.category&&s.push(`X-Gmail-Labels: ${t.category}`)}if(s.length>0){const t=n.indexOf(`\r
17
- \r
18
- `);if(t!==-1){const d=n.slice(0,t),f=n.slice(t+4);n=`${d}\r
19
- ${s.join(`\r
20
- `)}\r
21
- \r
22
- ${f}`}}r.dkim&&(e.useDkim||e.useDkim===void 0)&&(n=F(n)),await h(o,`${n}\r
23
- .`,"250");const a=J();return await T(o,r.pool),{data:{messageId:a,provider:u,response:"Message accepted",sent:!0,timestamp:new Date},success:!0}}catch(i){try{await T(o)}catch{}throw i}}catch(c){return{error:new m(u,`Failed to send email: ${c.message}`,{cause:c}),success:!1}}},async shutdown(){for(const e of A)try{await T(e)}catch{}A.length=0;for(const e of g)clearTimeout(e.timeout),e.reject(new Error("Provider shutdown"));g.length=0},async validateCredentials(){try{if(!await this.isAvailable())return!1;const e=await k();try{if(await h(e,`EHLO ${r.host}`,"250"),!r.secure)try{const c=await h(e,`EHLO ${r.host}`,"250"),o=U(c);if(Object.keys(o).includes("STARTTLS")){await h(e,"STARTTLS","220");const i=await N(e);Object.assign(e,i),await h(e,`EHLO ${r.host}`,"250")}}catch{if(r.rejectUnauthorized!==!1)return!1}return await P(e),await T(e),!0}catch{return await T(e),!1}}catch{return!1}}}});export{ye as default};
@@ -1 +0,0 @@
1
- var P=Object.defineProperty;var h=(s,a)=>P(s,"name",{value:a,configurable:!0});import{createRequire as A}from"node:module";import l from"./EmailError-zm2ffVav.js";import _ from"./RequiredOptionError-CevW3u2K.js";import z from"./generateMessageId-11Ls5JsR.js";import E from"./headersToRecord-BKUTr40L.js";import{makeRequest as y}from"./makeRequest-DwxHX0xo.js";import b from"./retry-D1MBqS49.js";import q from"./validateEmailOptions-BzlJECG5.js";import{defineProvider as k}from"./defineProvider-B9rSklAJ.js";import{c as K,P as B,h as w}from"./provider-base-_hbWXBdK.js";import{f,a as C}from"./address-formatter-Cm_E_ZMa.js";const j=A(import.meta.url),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,S=h(s=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[a,c]=u.versions.node.split(".").map(Number);if(a>22||a===22&&c>=3||a===20&&c>=16)return u.getBuiltinModule(s)}return j(s)},"__cjs_getBuiltinModule"),{Buffer:T}=S("node:buffer"),i="sweego",$="https://api.sweego.com",x=3e4,R=3,W=k((s={})=>{if(!s.apiKey)throw new _(i,"apiKey");const a={apiKey:s.apiKey,debug:s.debug||!1,endpoint:s.endpoint||$,retries:s.retries||R,timeout:s.timeout||x,...s.logger&&{logger:s.logger}},c=new B,n=K(i,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(i,"Email ID is required to retrieve email details"),success:!1};await c.ensureInitialized(()=>this.initialize(),i);const o={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"};n.debug("Retrieving email details",{id:e});const t=await b(async()=>y(`${a.endpoint}/emails/${e}`,{headers:o,method:"GET",timeout:a.timeout}),a.retries);return t.success?(n.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(n.debug("API request failed when retrieving email",t.error),{error:new l(i,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(o){return{error:w(i,"retrieve email",o,n),success:!1}}},async initialize(){await c.ensureInitialized(async()=>{if(!await this.isAvailable())throw new l(i,"Sweego API not available or invalid API key");n.debug("Provider initialized successfully")},i)},async isAvailable(){try{return n.debug("Checking Sweego API availability"),!0}catch(e){return n.debug("Error checking availability:",e),!1}},name:i,options:a,async sendEmail(e){try{const o=q(e);if(o.length>0)return{error:new l(i,`Invalid email options: ${o.join(", ")}`),success:!1};await c.ensureInitialized(()=>this.initialize(),i);const t={from:{email:e.from.email,name:e.from.name},subject:e.subject,to:f(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=f(e.cc)),e.bcc&&(t.bcc=f(e.bcc)),e.replyTo&&(t.replyTo=C(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 r=E(e.headers);t.headers=r}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async r=>{let d;if(r.content)if(typeof r.content=="string")d=r.content;else if(r.content instanceof Promise){const I=await r.content;d=T.from(I).toString("base64")}else d=r.content.toString("base64");else if(r.raw)d=typeof r.raw=="string"?r.raw:r.raw.toString("base64");else throw new l(i,`Attachment ${r.filename} has no content`);return{content:d,contentType:r.contentType||"application/octet-stream",filename:r.filename,...r.cid&&{cid:r.cid}}}))),n.debug("Sending email via Sweego API",{subject:t.subject,to:t.to});const v={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"},m=await b(async()=>y(`${a.endpoint}/send`,{headers:v,method:"POST",timeout:a.timeout},JSON.stringify(t)),a.retries);if(!m.success)return n.debug("API request failed when sending email",m.error),{error:m.error||new l(i,"Failed to send email"),success:!1};const g=m.data?.body,p=g?.messageId||g?.id||z();return n.debug("Email sent successfully",{messageId:p}),{data:{messageId:p,provider:i,response:m.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:w(i,"send email",o,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{W as default};
@@ -1 +0,0 @@
1
- var d=Object.defineProperty;var o=(r,e)=>d(r,"name",{value:e,configurable:!0});import a from"./validateEmail-BkVdVioP.js";var c=Object.defineProperty,t=o((r,e)=>c(r,"name",{value:e,configurable:!0}),"m");const f=t(r=>{const e=[];(!r.from||!r.from.email)&&e.push("Missing required field: from"),r.to||e.push("Missing required field: to"),r.subject||e.push("Missing required field: subject"),!r.text&&!r.html&&e.push("Either text or html content is required"),r.from&&r.from.email&&!a(r.from.email)&&e.push(`Invalid from email address: ${r.from.email}`);const s=t((i,m)=>{i&&(Array.isArray(i)?i:[i]).forEach(l=>{a(l.email)||e.push(`Invalid ${m} email address: ${l.email}`)})},"checkAddresses");return s(r.to,"to"),s(r.cc,"cc"),s(r.bcc,"bcc"),r.replyTo&&!a(r.replyTo.email)&&e.push(`Invalid replyTo email address: ${r.replyTo.email}`),e},"validateEmailOptions");export{f as default};
@@ -1 +0,0 @@
1
- import l from"./EmailError-zm2ffVav.js";import y from"./RequiredOptionError-CevW3u2K.js";import b from"./generateMessageId-11Ls5JsR.js";import k from"./headersToRecord-BKUTr40L.js";import{makeRequest as v}from"./makeRequest-DwxHX0xo.js";import w from"./retry-D1MBqS49.js";import{s as A,a as _}from"./sanitize-header-wWav-Scu.js";import z from"./validateEmailOptions-BzlJECG5.js";import{defineProvider as j}from"./defineProvider-B9rSklAJ.js";import{m as h}from"./address-formatter-Cm_E_ZMa.js";import{c as P,P as I,h as T}from"./provider-base-_hbWXBdK.js";const i="zeptomail",$="https://api.zeptomail.com/v1.1",O=3e4,Z=3,J=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||$,logger:s.logger,retries:s.retries||Z,timeout:s.timeout||O,token:s.token},u=new I,n=P(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=z(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||(a.mime_headers={}),Object.entries(t).forEach(([r,d])=>{a.mime_headers&&(a.mime_headers[_(r)]=A(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:T(i,"send email",m,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{J as default};
@@ -1,16 +0,0 @@
1
- import type { Priority } from "../types.d.ts";
2
- /**
3
- * Compares two priority levels and returns a number indicating their relative order.
4
- * High priority is considered greater than normal, which is greater than low.
5
- * @example Sorting priorities
6
- * ```ts
7
- * const priorities: Priority[] = ["normal", "low", "high"];
8
- * priorities.sort(comparePriority);
9
- * // ["high", "normal", "low"]
10
- * ```
11
- * @param a The first priority to compare
12
- * @param b The second priority to compare
13
- * @returns A negative number if a is less than b, a positive number if a is greater than b, and zero if they are equal
14
- */
15
- declare const comparePriority: (a: Priority, b: Priority) => number;
16
- export default comparePriority;