@visulima/email 1.0.0-alpha.1 → 1.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +140 -0
- package/LICENSE.md +6 -6
- package/README.md +408 -72
- package/dist/crypto/index.js +1 -1
- package/dist/draft-mail-message.d.ts +13 -0
- package/dist/index.d.ts +3 -16
- package/dist/index.js +1 -1
- package/dist/mail-message.d.ts +425 -0
- package/dist/mail.d.ts +124 -275
- package/dist/packem_shared/{DkimSigner-Z8D4Il10.js → DkimSigner-pFd4c3fZ.js} +1 -1
- package/dist/packem_shared/EmailError-C4nx6TgJ.js +1 -0
- package/dist/packem_shared/Mail-CmvJ5iZg.js +1 -0
- package/dist/packem_shared/MailMessage-B76GPBBA.js +1 -0
- package/dist/packem_shared/{RequiredOptionError-CevW3u2K.js → RequiredOptionError-BeTzeno6.js} +1 -1
- package/dist/packem_shared/{SmimeSigner-02aXVi90.js → SmimeSigner-CObA4jzT.js} +1 -1
- package/dist/packem_shared/ahaSendProvider-CBqIPxEd.js +1 -0
- package/dist/packem_shared/{attachment-processor-2rHmfa7j.js → attachment-processor-E18l3TW_.js} +1 -1
- package/dist/packem_shared/{awsSesProvider-CkuFOzb0.js → awsSesProvider-BPRp4yoX.js} +6 -6
- package/dist/packem_shared/azureProvider-m8hC1YG8.js +1 -0
- package/dist/packem_shared/brevoProvider-D9c9c-Ef.js +1 -0
- package/dist/packem_shared/build-mime-message-BzDR2Zv-.js +2 -0
- package/dist/packem_shared/create-logger-BiWdqFNg.js +1 -0
- package/dist/packem_shared/failoverProvider-uP2Wpi5x.js +1 -0
- package/dist/packem_shared/{generateBoundary-CZ8kJuY6.js → generate-boundary-Cx8nXYS0.js} +1 -1
- package/dist/packem_shared/{generateMessageId-11Ls5JsR.js → generate-message-id-D4uA8gkj.js} +1 -1
- package/dist/packem_shared/headers-to-record-Qo124ImV.js +1 -0
- package/dist/packem_shared/httpProvider-DAZnfgDh.js +1 -0
- package/dist/packem_shared/infobipProvider-pP3a1I1z.js +1 -0
- package/dist/packem_shared/{mailCrabProvider-BEwRjB3F.js → mailCrabProvider-Ccm6HIsr.js} +1 -1
- package/dist/packem_shared/mailPaceProvider-BdpdKp7S.js +1 -0
- package/dist/packem_shared/mailerSendProvider-BPJ4RzsE.js +1 -0
- package/dist/packem_shared/mailgunProvider-CwvMTsc_.js +1 -0
- package/dist/packem_shared/mailjetProvider-CUJMsFSY.js +1 -0
- package/dist/packem_shared/mailomatProvider-B_l5QnwN.js +1 -0
- package/dist/packem_shared/mailtrapProvider-CmICY2yv.js +1 -0
- package/dist/packem_shared/{makeRequest-DwxHX0xo.js → make-request-sA_-JKm0.js} +1 -1
- package/dist/packem_shared/mandrillProvider-Dj4vhxjz.js +1 -0
- package/dist/packem_shared/mockProvider-UiTviqTp.js +1 -0
- package/dist/packem_shared/nodemailerProvider-BqG5vYka.js +1 -0
- package/dist/packem_shared/opentelemetryProvider-1uJuHIQ5.js +1 -0
- package/dist/packem_shared/plunkProvider-DMdTroUj.js +1 -0
- package/dist/packem_shared/postalProvider-DG2rY0mt.js +1 -0
- package/dist/packem_shared/postmarkProvider-DaR-sY5P.js +1 -0
- package/dist/packem_shared/provider-base-8LBAorjm.js +1 -0
- package/dist/packem_shared/resendProvider-998actWK.js +1 -0
- package/dist/packem_shared/roundRobinProvider-DroogcP0.js +1 -0
- package/dist/packem_shared/scalewayProvider-BWUCBzur.js +1 -0
- package/dist/packem_shared/sendGridProvider-D82muNhj.js +1 -0
- package/dist/packem_shared/smtpProvider-DzSgmGjo.js +23 -0
- package/dist/packem_shared/sweegoProvider-dOP4zYOR.js +1 -0
- package/dist/packem_shared/validate-email-options-DfJ7llf8.js +1 -0
- package/dist/packem_shared/zeptomailProvider-BWyoNPZH.js +1 -0
- package/dist/providers/ahasend/index.js +1 -1
- package/dist/providers/aws-ses/index.js +1 -1
- package/dist/providers/azure/index.js +1 -1
- package/dist/providers/brevo/index.js +1 -1
- package/dist/providers/brevo/types.d.ts +10 -3
- package/dist/providers/failover/index.js +1 -1
- package/dist/providers/http/index.js +1 -1
- package/dist/providers/infobip/index.js +1 -1
- package/dist/providers/mailcrab/index.js +1 -1
- package/dist/providers/mailersend/index.js +1 -1
- package/dist/providers/mailgun/index.js +1 -1
- package/dist/providers/mailjet/index.js +1 -1
- package/dist/providers/mailomat/index.js +1 -1
- package/dist/providers/mailpace/index.js +1 -1
- package/dist/providers/mailtrap/index.js +1 -1
- package/dist/providers/mandrill/index.js +1 -1
- package/dist/providers/mock/index.js +1 -1
- package/dist/providers/nodemailer/index.js +1 -1
- package/dist/providers/opentelemetry/index.js +1 -1
- package/dist/providers/plunk/index.js +1 -1
- package/dist/providers/postal/index.js +1 -1
- package/dist/providers/postmark/index.js +1 -1
- package/dist/providers/resend/index.js +1 -1
- package/dist/providers/roundrobin/index.js +1 -1
- package/dist/providers/scaleway/index.js +1 -1
- package/dist/providers/sendgrid/index.js +1 -1
- package/dist/providers/smtp/index.js +1 -1
- package/dist/providers/sweego/index.js +1 -1
- package/dist/providers/zeptomail/index.js +1 -1
- package/dist/template-engines/handlebars.js +1 -1
- package/dist/template-engines/html-to-text.js +1 -1
- package/dist/template-engines/mjml.js +1 -1
- package/dist/template-engines/react-email.js +1 -1
- package/dist/template-engines/vue-email.js +1 -1
- package/dist/types.d.ts +18 -0
- package/dist/utils/cache.d.ts +54 -0
- package/dist/utils/cache.js +1 -0
- package/dist/utils/create-logger.d.ts +2 -4
- package/dist/utils/format-email-address.js +1 -0
- package/dist/utils/normalize-email-aliases.d.ts +22 -0
- package/dist/utils/normalize-email-aliases.js +1 -0
- package/dist/utils/parse-address.js +1 -0
- package/dist/utils/validation/check-mx-records.d.ts +42 -0
- package/dist/utils/validation/check-mx-records.js +1 -0
- package/dist/utils/validation/disposable-email-domains.d.ts +13 -0
- package/dist/utils/validation/disposable-email-domains.js +1 -0
- package/dist/utils/validation/role-accounts.d.ts +21 -0
- package/dist/utils/validation/role-accounts.js +1 -0
- package/dist/utils/{validate-email-options.d.ts → validation/validate-email-options.d.ts} +1 -1
- package/dist/utils/validation/verify-email.d.ts +47 -0
- package/dist/utils/validation/verify-email.js +1 -0
- package/dist/utils/validation/verify-smtp.d.ts +39 -0
- package/dist/utils/validation/verify-smtp.js +4 -0
- package/package.json +49 -3
- package/dist/packem_shared/EmailError-zm2ffVav.js +0 -1
- package/dist/packem_shared/MailMessage-Hdgowmvi.js +0 -1
- package/dist/packem_shared/ahaSendProvider-NUD_kwyT.js +0 -1
- package/dist/packem_shared/azureProvider-Ckdrpmw9.js +0 -1
- package/dist/packem_shared/brevoProvider-CB3IYW4n.js +0 -1
- package/dist/packem_shared/buildMimeMessage-BPtd0pno.js +0 -2
- package/dist/packem_shared/comparePriority-BfiwjVsV.js +0 -1
- package/dist/packem_shared/createLogger-DlElSVQP.js +0 -1
- package/dist/packem_shared/failoverProvider-sam9n1AG.js +0 -1
- package/dist/packem_shared/formatEmailAddress-CHeME3Vk.js +0 -1
- package/dist/packem_shared/formatEmailAddresses-UegVOe5A.js +0 -1
- package/dist/packem_shared/headersToRecord-BKUTr40L.js +0 -1
- package/dist/packem_shared/httpProvider-BhN0RrK-.js +0 -1
- package/dist/packem_shared/infobipProvider-D8vYTHV4.js +0 -1
- package/dist/packem_shared/isPortAvailable-5kfsfo8u.js +0 -1
- package/dist/packem_shared/mailPaceProvider-C47Izgaj.js +0 -1
- package/dist/packem_shared/mailerSendProvider-C4uAo-fc.js +0 -1
- package/dist/packem_shared/mailgunProvider-B7upu_OV.js +0 -1
- package/dist/packem_shared/mailjetProvider-ReErm08u.js +0 -1
- package/dist/packem_shared/mailomatProvider-OlCT_O2i.js +0 -1
- package/dist/packem_shared/mailtrapProvider-hVMV3h6r.js +0 -1
- package/dist/packem_shared/mandrillProvider-DdnbkHZI.js +0 -1
- package/dist/packem_shared/mockProvider-BDWZJpea.js +0 -1
- package/dist/packem_shared/nodemailerProvider-BV21eRGX.js +0 -1
- package/dist/packem_shared/opentelemetryProvider-kAz62mKm.js +0 -1
- package/dist/packem_shared/parseAddress-CATTKGe_.js +0 -1
- package/dist/packem_shared/plunkProvider-Bs6K51lT.js +0 -1
- package/dist/packem_shared/postalProvider-Bcsxp-z6.js +0 -1
- package/dist/packem_shared/postmarkProvider-BUq3wuYD.js +0 -1
- package/dist/packem_shared/provider-base-_hbWXBdK.js +0 -1
- package/dist/packem_shared/resendProvider-D-_HQpN_.js +0 -1
- package/dist/packem_shared/retry-D1MBqS49.js +0 -1
- package/dist/packem_shared/roundRobinProvider-CejLM1rZ.js +0 -1
- package/dist/packem_shared/scalewayProvider-1n6ePiGl.js +0 -1
- package/dist/packem_shared/sendGridProvider-B1T62dyX.js +0 -1
- package/dist/packem_shared/smtpProvider-CcAoRrkt.js +0 -23
- package/dist/packem_shared/sweegoProvider-CxFmEUh6.js +0 -1
- package/dist/packem_shared/validateEmailOptions-BzlJECG5.js +0 -1
- package/dist/packem_shared/zeptomailProvider-CWYQPAJk.js +0 -1
- package/dist/utils/compare-priority.d.ts +0 -16
- /package/dist/utils/{validate-email.d.ts → validation/validate-email.d.ts} +0 -0
- /package/dist/{packem_shared/validateEmail-BkVdVioP.js → utils/validation/validate-email.js} +0 -0
|
@@ -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;
|
|
File without changes
|
/package/dist/{packem_shared/validateEmail-BkVdVioP.js → utils/validation/validate-email.js}
RENAMED
|
File without changes
|