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

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 (143) hide show
  1. package/CHANGELOG.md +166 -0
  2. package/LICENSE.md +14 -14
  3. package/README.md +408 -72
  4. package/dist/crypto/index.js +1 -1
  5. package/dist/draft-mail-message.d.ts +13 -0
  6. package/dist/index.d.ts +3 -16
  7. package/dist/index.js +1 -1
  8. package/dist/mail-message.d.ts +425 -0
  9. package/dist/mail.d.ts +124 -275
  10. package/dist/packem_shared/{DkimSigner-Z8D4Il10.js → DkimSigner-CNpDVu4V.js} +1 -1
  11. package/dist/packem_shared/Mail-DxAdbjDr.js +1 -0
  12. package/dist/packem_shared/MailMessage-7FA892bF.js +1 -0
  13. package/dist/packem_shared/{SmimeEncrypter-CBevU534.js → SmimeEncrypter-Bv5m28oh.js} +1 -1
  14. package/dist/packem_shared/{SmimeSigner-02aXVi90.js → SmimeSigner-DnBwjJRR.js} +1 -1
  15. package/dist/packem_shared/ahaSendProvider-DlFKEQ6D.js +1 -0
  16. package/dist/packem_shared/{awsSesProvider-CkuFOzb0.js → awsSesProvider-Ba-eVJxZ.js} +6 -6
  17. package/dist/packem_shared/azureProvider-CQYAkgVF.js +1 -0
  18. package/dist/packem_shared/brevoProvider-5p6jjiK9.js +1 -0
  19. package/dist/packem_shared/build-mime-message-IYaUqqPJ.js +2 -0
  20. package/dist/packem_shared/create-logger-BiWdqFNg.js +1 -0
  21. package/dist/packem_shared/{detectMimeType-S8WRsNtY.js → detectMimeType-CPYmHk7Y.js} +1 -1
  22. package/dist/packem_shared/failoverProvider-CAHQQueo.js +1 -0
  23. package/dist/packem_shared/{generateBoundary-CZ8kJuY6.js → generate-boundary-Cx8nXYS0.js} +1 -1
  24. package/dist/packem_shared/{generateMessageId-11Ls5JsR.js → generate-message-id-D4uA8gkj.js} +1 -1
  25. package/dist/packem_shared/headers-to-record-Qo124ImV.js +1 -0
  26. package/dist/packem_shared/httpProvider-CZD6LZX3.js +1 -0
  27. package/dist/packem_shared/infobipProvider-CtLwrUaP.js +1 -0
  28. package/dist/packem_shared/{mailCrabProvider-BEwRjB3F.js → mailCrabProvider-CM_CFDca.js} +1 -1
  29. package/dist/packem_shared/mailPaceProvider-BFn8L0vA.js +1 -0
  30. package/dist/packem_shared/mailerSendProvider-CeeIXFnW.js +1 -0
  31. package/dist/packem_shared/mailgunProvider-mmjKzouh.js +1 -0
  32. package/dist/packem_shared/mailjetProvider-DwN6i0VA.js +1 -0
  33. package/dist/packem_shared/mailomatProvider-DMQmjKHT.js +1 -0
  34. package/dist/packem_shared/mailtrapProvider-BN3UBEQw.js +1 -0
  35. package/dist/packem_shared/{makeRequest-DwxHX0xo.js → make-request-BDzF9W9D.js} +1 -1
  36. package/dist/packem_shared/mandrillProvider-370y7CLu.js +1 -0
  37. package/dist/packem_shared/mockProvider-DN5ZwutD.js +1 -0
  38. package/dist/packem_shared/nodemailerProvider-_w8QXMU-.js +1 -0
  39. package/dist/packem_shared/opentelemetryProvider-C_ZXOLSd.js +1 -0
  40. package/dist/packem_shared/plunkProvider-D48sw9M1.js +1 -0
  41. package/dist/packem_shared/postalProvider-Bavx2FcH.js +1 -0
  42. package/dist/packem_shared/postmarkProvider-DFC0uvjO.js +1 -0
  43. package/dist/packem_shared/provider-base-Cmzx6BTO.js +1 -0
  44. package/dist/packem_shared/readFile-BlZxbhCU-C76YbAVD.js +1 -0
  45. package/dist/packem_shared/resendProvider-CfqU7UdE.js +1 -0
  46. package/dist/packem_shared/roundRobinProvider-1WQnuKR8.js +1 -0
  47. package/dist/packem_shared/scalewayProvider-be1HPimL.js +1 -0
  48. package/dist/packem_shared/sendGridProvider-BVI1sq3n.js +1 -0
  49. package/dist/packem_shared/smtpProvider-BV-ufR53.js +23 -0
  50. package/dist/packem_shared/sweegoProvider-7419CSAq.js +1 -0
  51. package/dist/packem_shared/validate-email-options-DfJ7llf8.js +1 -0
  52. package/dist/packem_shared/zeptomailProvider-DTUWVINJ.js +1 -0
  53. package/dist/providers/ahasend/index.js +1 -1
  54. package/dist/providers/aws-ses/index.js +1 -1
  55. package/dist/providers/azure/index.js +1 -1
  56. package/dist/providers/brevo/index.js +1 -1
  57. package/dist/providers/brevo/types.d.ts +10 -3
  58. package/dist/providers/failover/index.js +1 -1
  59. package/dist/providers/http/index.js +1 -1
  60. package/dist/providers/infobip/index.js +1 -1
  61. package/dist/providers/mailcrab/index.js +1 -1
  62. package/dist/providers/mailersend/index.js +1 -1
  63. package/dist/providers/mailgun/index.js +1 -1
  64. package/dist/providers/mailjet/index.js +1 -1
  65. package/dist/providers/mailomat/index.js +1 -1
  66. package/dist/providers/mailpace/index.js +1 -1
  67. package/dist/providers/mailtrap/index.js +1 -1
  68. package/dist/providers/mandrill/index.js +1 -1
  69. package/dist/providers/mock/index.js +1 -1
  70. package/dist/providers/nodemailer/index.js +1 -1
  71. package/dist/providers/opentelemetry/index.js +1 -1
  72. package/dist/providers/plunk/index.js +1 -1
  73. package/dist/providers/postal/index.js +1 -1
  74. package/dist/providers/postmark/index.js +1 -1
  75. package/dist/providers/resend/index.js +1 -1
  76. package/dist/providers/roundrobin/index.js +1 -1
  77. package/dist/providers/scaleway/index.js +1 -1
  78. package/dist/providers/sendgrid/index.js +1 -1
  79. package/dist/providers/smtp/index.js +1 -1
  80. package/dist/providers/sweego/index.js +1 -1
  81. package/dist/providers/zeptomail/index.js +1 -1
  82. package/dist/types.d.ts +18 -0
  83. package/dist/utils/cache.d.ts +54 -0
  84. package/dist/utils/cache.js +1 -0
  85. package/dist/utils/create-logger.d.ts +2 -4
  86. package/dist/utils/format-email-address.js +1 -0
  87. package/dist/utils/normalize-email-aliases.d.ts +22 -0
  88. package/dist/utils/normalize-email-aliases.js +1 -0
  89. package/dist/utils/parse-address.js +1 -0
  90. package/dist/utils/validation/check-mx-records.d.ts +42 -0
  91. package/dist/utils/validation/check-mx-records.js +1 -0
  92. package/dist/utils/validation/disposable-email-domains.d.ts +13 -0
  93. package/dist/utils/validation/disposable-email-domains.js +1 -0
  94. package/dist/utils/validation/role-accounts.d.ts +21 -0
  95. package/dist/utils/validation/role-accounts.js +1 -0
  96. package/dist/utils/{validate-email-options.d.ts → validation/validate-email-options.d.ts} +1 -1
  97. package/dist/utils/validation/verify-email.d.ts +47 -0
  98. package/dist/utils/validation/verify-email.js +1 -0
  99. package/dist/utils/validation/verify-smtp.d.ts +39 -0
  100. package/dist/utils/validation/verify-smtp.js +4 -0
  101. package/package.json +54 -7
  102. package/dist/packem_shared/MailMessage-Hdgowmvi.js +0 -1
  103. package/dist/packem_shared/ahaSendProvider-NUD_kwyT.js +0 -1
  104. package/dist/packem_shared/azureProvider-Ckdrpmw9.js +0 -1
  105. package/dist/packem_shared/brevoProvider-CB3IYW4n.js +0 -1
  106. package/dist/packem_shared/buildMimeMessage-BPtd0pno.js +0 -2
  107. package/dist/packem_shared/comparePriority-BfiwjVsV.js +0 -1
  108. package/dist/packem_shared/createLogger-DlElSVQP.js +0 -1
  109. package/dist/packem_shared/failoverProvider-sam9n1AG.js +0 -1
  110. package/dist/packem_shared/formatEmailAddress-CHeME3Vk.js +0 -1
  111. package/dist/packem_shared/formatEmailAddresses-UegVOe5A.js +0 -1
  112. package/dist/packem_shared/headersToRecord-BKUTr40L.js +0 -1
  113. package/dist/packem_shared/httpProvider-BhN0RrK-.js +0 -1
  114. package/dist/packem_shared/infobipProvider-D8vYTHV4.js +0 -1
  115. package/dist/packem_shared/isPortAvailable-5kfsfo8u.js +0 -1
  116. package/dist/packem_shared/mailPaceProvider-C47Izgaj.js +0 -1
  117. package/dist/packem_shared/mailerSendProvider-C4uAo-fc.js +0 -1
  118. package/dist/packem_shared/mailgunProvider-B7upu_OV.js +0 -1
  119. package/dist/packem_shared/mailjetProvider-ReErm08u.js +0 -1
  120. package/dist/packem_shared/mailomatProvider-OlCT_O2i.js +0 -1
  121. package/dist/packem_shared/mailtrapProvider-hVMV3h6r.js +0 -1
  122. package/dist/packem_shared/mandrillProvider-DdnbkHZI.js +0 -1
  123. package/dist/packem_shared/mockProvider-BDWZJpea.js +0 -1
  124. package/dist/packem_shared/nodemailerProvider-BV21eRGX.js +0 -1
  125. package/dist/packem_shared/opentelemetryProvider-kAz62mKm.js +0 -1
  126. package/dist/packem_shared/parseAddress-CATTKGe_.js +0 -1
  127. package/dist/packem_shared/plunkProvider-Bs6K51lT.js +0 -1
  128. package/dist/packem_shared/postalProvider-Bcsxp-z6.js +0 -1
  129. package/dist/packem_shared/postmarkProvider-BUq3wuYD.js +0 -1
  130. package/dist/packem_shared/provider-base-_hbWXBdK.js +0 -1
  131. package/dist/packem_shared/readFile-BlZxbhCU-C8bCdiA2.js +0 -1
  132. package/dist/packem_shared/resendProvider-D-_HQpN_.js +0 -1
  133. package/dist/packem_shared/retry-D1MBqS49.js +0 -1
  134. package/dist/packem_shared/roundRobinProvider-CejLM1rZ.js +0 -1
  135. package/dist/packem_shared/scalewayProvider-1n6ePiGl.js +0 -1
  136. package/dist/packem_shared/sendGridProvider-B1T62dyX.js +0 -1
  137. package/dist/packem_shared/smtpProvider-CcAoRrkt.js +0 -23
  138. package/dist/packem_shared/sweegoProvider-CxFmEUh6.js +0 -1
  139. package/dist/packem_shared/validateEmailOptions-BzlJECG5.js +0 -1
  140. package/dist/packem_shared/zeptomailProvider-CWYQPAJk.js +0 -1
  141. package/dist/utils/compare-priority.d.ts +0 -16
  142. /package/dist/utils/{validate-email.d.ts → validation/validate-email.d.ts} +0 -0
  143. /package/dist/{packem_shared/validateEmail-BkVdVioP.js → utils/validation/validate-email.js} +0 -0
@@ -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;