@visulima/email 1.0.0-alpha.1
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 +22 -0
- package/LICENSE.md +1266 -0
- package/README.md +1084 -0
- package/dist/attachment-helpers.d.ts +64 -0
- package/dist/crypto/dkim-signer.d.ts +48 -0
- package/dist/crypto/index.d.ts +4 -0
- package/dist/crypto/index.js +1 -0
- package/dist/crypto/smime-encrypter.d.ts +53 -0
- package/dist/crypto/smime-signer.d.ts +48 -0
- package/dist/crypto/types.d.ts +101 -0
- package/dist/errors/email-error.d.ts +17 -0
- package/dist/errors/required-option-error.d.ts +10 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +1 -0
- package/dist/mail.d.ts +357 -0
- package/dist/packem_shared/DkimSigner-Z8D4Il10.js +18 -0
- package/dist/packem_shared/EmailError-zm2ffVav.js +1 -0
- package/dist/packem_shared/MailMessage-Hdgowmvi.js +1 -0
- package/dist/packem_shared/RequiredOptionError-CevW3u2K.js +1 -0
- package/dist/packem_shared/SmimeEncrypter-CBevU534.js +6 -0
- package/dist/packem_shared/SmimeSigner-02aXVi90.js +8 -0
- package/dist/packem_shared/address-formatter-Cm_E_ZMa.js +1 -0
- package/dist/packem_shared/ahaSendProvider-NUD_kwyT.js +1 -0
- package/dist/packem_shared/attachment-processor-2rHmfa7j.js +1 -0
- package/dist/packem_shared/awsSesProvider-CkuFOzb0.js +32 -0
- package/dist/packem_shared/azureProvider-Ckdrpmw9.js +1 -0
- package/dist/packem_shared/brevoProvider-CB3IYW4n.js +1 -0
- package/dist/packem_shared/buildMimeMessage-BPtd0pno.js +2 -0
- package/dist/packem_shared/comparePriority-BfiwjVsV.js +1 -0
- package/dist/packem_shared/createLogger-DlElSVQP.js +1 -0
- package/dist/packem_shared/defineProvider-B9rSklAJ.js +1 -0
- package/dist/packem_shared/detectMimeType-S8WRsNtY.js +1 -0
- package/dist/packem_shared/failoverProvider-sam9n1AG.js +1 -0
- package/dist/packem_shared/formatEmailAddress-CHeME3Vk.js +1 -0
- package/dist/packem_shared/formatEmailAddresses-UegVOe5A.js +1 -0
- package/dist/packem_shared/generateBoundary-CZ8kJuY6.js +1 -0
- package/dist/packem_shared/generateMessageId-11Ls5JsR.js +1 -0
- package/dist/packem_shared/headersToRecord-BKUTr40L.js +1 -0
- package/dist/packem_shared/httpProvider-BhN0RrK-.js +1 -0
- package/dist/packem_shared/infobipProvider-D8vYTHV4.js +1 -0
- package/dist/packem_shared/isPortAvailable-5kfsfo8u.js +1 -0
- package/dist/packem_shared/mailCrabProvider-BEwRjB3F.js +1 -0
- package/dist/packem_shared/mailPaceProvider-C47Izgaj.js +1 -0
- package/dist/packem_shared/mailerSendProvider-C4uAo-fc.js +1 -0
- package/dist/packem_shared/mailgunProvider-B7upu_OV.js +1 -0
- package/dist/packem_shared/mailjetProvider-ReErm08u.js +1 -0
- package/dist/packem_shared/mailomatProvider-OlCT_O2i.js +1 -0
- package/dist/packem_shared/mailtrapProvider-hVMV3h6r.js +1 -0
- package/dist/packem_shared/makeRequest-DwxHX0xo.js +1 -0
- package/dist/packem_shared/mandrillProvider-DdnbkHZI.js +1 -0
- package/dist/packem_shared/mockProvider-BDWZJpea.js +1 -0
- package/dist/packem_shared/nodemailerProvider-BV21eRGX.js +1 -0
- package/dist/packem_shared/opentelemetryProvider-kAz62mKm.js +1 -0
- package/dist/packem_shared/parseAddress-CATTKGe_.js +1 -0
- package/dist/packem_shared/plunkProvider-Bs6K51lT.js +1 -0
- package/dist/packem_shared/postalProvider-Bcsxp-z6.js +1 -0
- package/dist/packem_shared/postmarkProvider-BUq3wuYD.js +1 -0
- package/dist/packem_shared/provider-base-_hbWXBdK.js +1 -0
- package/dist/packem_shared/readFile-BlZxbhCU-C8bCdiA2.js +1 -0
- package/dist/packem_shared/resendProvider-D-_HQpN_.js +1 -0
- package/dist/packem_shared/retry-D1MBqS49.js +1 -0
- package/dist/packem_shared/roundRobinProvider-CejLM1rZ.js +1 -0
- package/dist/packem_shared/sanitize-header-wWav-Scu.js +1 -0
- package/dist/packem_shared/scalewayProvider-1n6ePiGl.js +1 -0
- package/dist/packem_shared/sendGridProvider-B1T62dyX.js +1 -0
- package/dist/packem_shared/smtpProvider-CcAoRrkt.js +23 -0
- package/dist/packem_shared/sweegoProvider-CxFmEUh6.js +1 -0
- package/dist/packem_shared/validateEmail-BkVdVioP.js +1 -0
- package/dist/packem_shared/validateEmailOptions-BzlJECG5.js +1 -0
- package/dist/packem_shared/zeptomailProvider-CWYQPAJk.js +1 -0
- package/dist/providers/ahasend/index.d.ts +3 -0
- package/dist/providers/ahasend/index.js +1 -0
- package/dist/providers/ahasend/provider.d.ts +7 -0
- package/dist/providers/ahasend/types.d.ts +28 -0
- package/dist/providers/aws-ses/index.d.ts +3 -0
- package/dist/providers/aws-ses/index.js +1 -0
- package/dist/providers/aws-ses/provider.d.ts +8 -0
- package/dist/providers/aws-ses/types.d.ts +38 -0
- package/dist/providers/azure/index.d.ts +3 -0
- package/dist/providers/azure/index.js +1 -0
- package/dist/providers/azure/provider.d.ts +7 -0
- package/dist/providers/azure/types.d.ts +44 -0
- package/dist/providers/brevo/index.d.ts +3 -0
- package/dist/providers/brevo/index.js +1 -0
- package/dist/providers/brevo/provider.d.ts +7 -0
- package/dist/providers/brevo/types.d.ts +50 -0
- package/dist/providers/failover/index.d.ts +3 -0
- package/dist/providers/failover/index.js +1 -0
- package/dist/providers/failover/provider.d.ts +7 -0
- package/dist/providers/failover/types.d.ts +19 -0
- package/dist/providers/http/index.d.ts +3 -0
- package/dist/providers/http/index.js +1 -0
- package/dist/providers/http/provider.d.ts +7 -0
- package/dist/providers/http/types.d.ts +27 -0
- package/dist/providers/infobip/index.d.ts +3 -0
- package/dist/providers/infobip/index.js +1 -0
- package/dist/providers/infobip/provider.d.ts +7 -0
- package/dist/providers/infobip/types.d.ts +48 -0
- package/dist/providers/mailcrab/index.d.ts +3 -0
- package/dist/providers/mailcrab/index.js +1 -0
- package/dist/providers/mailcrab/provider.d.ts +9 -0
- package/dist/providers/mailcrab/types.d.ts +22 -0
- package/dist/providers/mailersend/index.d.ts +3 -0
- package/dist/providers/mailersend/index.js +1 -0
- package/dist/providers/mailersend/provider.d.ts +7 -0
- package/dist/providers/mailersend/types.d.ts +43 -0
- package/dist/providers/mailgun/index.d.ts +3 -0
- package/dist/providers/mailgun/index.js +1 -0
- package/dist/providers/mailgun/provider.d.ts +7 -0
- package/dist/providers/mailgun/types.d.ts +65 -0
- package/dist/providers/mailjet/index.d.ts +3 -0
- package/dist/providers/mailjet/index.js +1 -0
- package/dist/providers/mailjet/provider.d.ts +7 -0
- package/dist/providers/mailjet/types.d.ts +64 -0
- package/dist/providers/mailomat/index.d.ts +3 -0
- package/dist/providers/mailomat/index.js +1 -0
- package/dist/providers/mailomat/provider.d.ts +7 -0
- package/dist/providers/mailomat/types.d.ts +32 -0
- package/dist/providers/mailpace/index.d.ts +3 -0
- package/dist/providers/mailpace/index.js +1 -0
- package/dist/providers/mailpace/provider.d.ts +7 -0
- package/dist/providers/mailpace/types.d.ts +44 -0
- package/dist/providers/mailtrap/index.d.ts +3 -0
- package/dist/providers/mailtrap/index.js +1 -0
- package/dist/providers/mailtrap/provider.d.ts +7 -0
- package/dist/providers/mailtrap/types.d.ts +36 -0
- package/dist/providers/mandrill/index.d.ts +3 -0
- package/dist/providers/mandrill/index.js +1 -0
- package/dist/providers/mandrill/provider.d.ts +7 -0
- package/dist/providers/mandrill/types.d.ts +79 -0
- package/dist/providers/mock/index.d.ts +3 -0
- package/dist/providers/mock/index.js +1 -0
- package/dist/providers/mock/provider.d.ts +8 -0
- package/dist/providers/mock/types.d.ts +50 -0
- package/dist/providers/nodemailer/index.d.ts +3 -0
- package/dist/providers/nodemailer/index.js +1 -0
- package/dist/providers/nodemailer/provider.d.ts +7 -0
- package/dist/providers/nodemailer/types.d.ts +30 -0
- package/dist/providers/opentelemetry/index.d.ts +3 -0
- package/dist/providers/opentelemetry/index.js +1 -0
- package/dist/providers/opentelemetry/provider.d.ts +8 -0
- package/dist/providers/opentelemetry/types.d.ts +31 -0
- package/dist/providers/plunk/index.d.ts +3 -0
- package/dist/providers/plunk/index.js +1 -0
- package/dist/providers/plunk/provider.d.ts +7 -0
- package/dist/providers/plunk/types.d.ts +30 -0
- package/dist/providers/postal/index.d.ts +3 -0
- package/dist/providers/postal/index.js +1 -0
- package/dist/providers/postal/provider.d.ts +7 -0
- package/dist/providers/postal/types.d.ts +40 -0
- package/dist/providers/postmark/index.d.ts +3 -0
- package/dist/providers/postmark/index.js +1 -0
- package/dist/providers/postmark/provider.d.ts +7 -0
- package/dist/providers/postmark/types.d.ts +52 -0
- package/dist/providers/provider.d.ts +27 -0
- package/dist/providers/resend/index.d.ts +3 -0
- package/dist/providers/resend/index.js +1 -0
- package/dist/providers/resend/provider.d.ts +7 -0
- package/dist/providers/resend/types.d.ts +43 -0
- package/dist/providers/roundrobin/index.d.ts +3 -0
- package/dist/providers/roundrobin/index.js +1 -0
- package/dist/providers/roundrobin/provider.d.ts +7 -0
- package/dist/providers/roundrobin/types.d.ts +19 -0
- package/dist/providers/scaleway/index.d.ts +3 -0
- package/dist/providers/scaleway/index.js +1 -0
- package/dist/providers/scaleway/provider.d.ts +7 -0
- package/dist/providers/scaleway/types.d.ts +36 -0
- package/dist/providers/sendgrid/index.d.ts +3 -0
- package/dist/providers/sendgrid/index.js +1 -0
- package/dist/providers/sendgrid/provider.d.ts +7 -0
- package/dist/providers/sendgrid/types.d.ts +76 -0
- package/dist/providers/smtp/index.d.ts +3 -0
- package/dist/providers/smtp/index.js +1 -0
- package/dist/providers/smtp/provider.d.ts +7 -0
- package/dist/providers/smtp/types.d.ts +63 -0
- package/dist/providers/sweego/index.d.ts +3 -0
- package/dist/providers/sweego/index.js +1 -0
- package/dist/providers/sweego/provider.d.ts +7 -0
- package/dist/providers/sweego/types.d.ts +32 -0
- package/dist/providers/utils/address-formatter.d.ts +139 -0
- package/dist/providers/utils/attachment-processor.d.ts +58 -0
- package/dist/providers/utils/index.d.ts +4 -0
- package/dist/providers/utils/payload-builder.d.ts +78 -0
- package/dist/providers/utils/provider-base.d.ts +69 -0
- package/dist/providers/zeptomail/index.d.ts +3 -0
- package/dist/providers/zeptomail/index.js +1 -0
- package/dist/providers/zeptomail/provider.d.ts +7 -0
- package/dist/providers/zeptomail/types.d.ts +29 -0
- package/dist/template-engines/handlebars.d.ts +25 -0
- package/dist/template-engines/handlebars.js +1 -0
- package/dist/template-engines/html-to-text.d.ts +27 -0
- package/dist/template-engines/html-to-text.js +1 -0
- package/dist/template-engines/mjml.d.ts +12 -0
- package/dist/template-engines/mjml.js +1 -0
- package/dist/template-engines/react-email.d.ts +11 -0
- package/dist/template-engines/react-email.js +1 -0
- package/dist/template-engines/types.d.ts +8 -0
- package/dist/template-engines/vue-email.d.ts +11 -0
- package/dist/template-engines/vue-email.js +1 -0
- package/dist/types.d.ts +185 -0
- package/dist/utils/build-mime-message.d.ts +8 -0
- package/dist/utils/compare-priority.d.ts +16 -0
- package/dist/utils/create-logger.d.ts +18 -0
- package/dist/utils/format-email-address.d.ts +9 -0
- package/dist/utils/format-email-addresses.d.ts +8 -0
- package/dist/utils/generate-boundary.d.ts +7 -0
- package/dist/utils/generate-message-id.d.ts +6 -0
- package/dist/utils/headers-to-record.d.ts +9 -0
- package/dist/utils/is-port-available.d.ts +9 -0
- package/dist/utils/make-request.d.ts +18 -0
- package/dist/utils/parse-address.d.ts +19 -0
- package/dist/utils/retry.d.ts +10 -0
- package/dist/utils/sanitize-header.d.ts +14 -0
- package/dist/utils/to-base64.d.ts +8 -0
- package/dist/utils/validate-email-options.d.ts +8 -0
- package/dist/utils/validate-email.d.ts +7 -0
- package/package.json +269 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { TemplateRenderer } from "./types.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Renders Handlebars template.
|
|
4
|
+
* @param template Handlebars template string.
|
|
5
|
+
* @param data Data to pass to the template.
|
|
6
|
+
* @param options Handlebars compile options.
|
|
7
|
+
* @returns Rendered HTML string.
|
|
8
|
+
* @throws {TypeError} When template is not a string.
|
|
9
|
+
* @throws {EmailError} When Handlebars is not installed or rendering fails.
|
|
10
|
+
*/
|
|
11
|
+
export declare const renderHandlebars: TemplateRenderer;
|
|
12
|
+
/**
|
|
13
|
+
* Registers a Handlebars helper function for use in templates.
|
|
14
|
+
* @param name The name of the helper to register.
|
|
15
|
+
* @param helper The helper function to register.
|
|
16
|
+
* @throws {EmailError} When Handlebars is not installed.
|
|
17
|
+
*/
|
|
18
|
+
export declare const registerHandlebarsHelper: (name: string, helper: unknown) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Registers a Handlebars partial template for reuse in other templates.
|
|
21
|
+
* @param name The name of the partial to register.
|
|
22
|
+
* @param partial The partial template string to register.
|
|
23
|
+
* @throws {EmailError} When Handlebars is not installed.
|
|
24
|
+
*/
|
|
25
|
+
export declare const registerHandlebarsPartial: (name: string, partial: string) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i=Object.defineProperty;var d=(a,r)=>i(a,"name",{value:r,configurable:!0});import t from"handlebars";import s from"../packem_shared/EmailError-zm2ffVav.js";var o=Object.defineProperty,l=d((a,r)=>o(a,"name",{value:r,configurable:!0}),"s");const p=l((a,r,e)=>{try{if(typeof a!="string")throw new TypeError("Handlebars template must be a string");return t.compile(a,e)(r||{})}catch(n){throw n instanceof Error&&n.message.includes("Cannot find module")?new s("handlebars","Handlebars is not installed. Please install it: pnpm add handlebars",{cause:n}):new s("handlebars",`Failed to render Handlebars template: ${n.message}`,{cause:n})}},"renderHandlebars"),u=l((a,r)=>{try{t.registerHelper(a,r)}catch(e){throw e instanceof Error&&e.message.includes("Cannot find module")?new s("handlebars","Handlebars is not installed. Please install it: pnpm add handlebars",{cause:e}):e}},"registerHandlebarsHelper"),h=l((a,r)=>{try{t.registerPartial(a,r)}catch(e){throw e instanceof Error&&e.message.includes("Cannot find module")?new s("handlebars","Handlebars is not installed. Please install it: pnpm add handlebars",{cause:e}):e}},"registerHandlebarsPartial");export{u as registerHandlebarsHelper,h as registerHandlebarsPartial,p as renderHandlebars};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts HTML content to plain text format.
|
|
3
|
+
* @param html The HTML string to convert.
|
|
4
|
+
* @param options Configuration options for the html-to-text conversion.
|
|
5
|
+
* @param options.longWordSplit Options for handling long words that exceed the word wrap limit.
|
|
6
|
+
* @param options.longWordSplit.forceWrapOnLimit Whether to force wrap on the limit.
|
|
7
|
+
* @param options.longWordSplit.wrapCharacters Characters to use for wrapping.
|
|
8
|
+
* @param options.preserveNewlines Whether to preserve newlines in the output.
|
|
9
|
+
* @param options.selectors Custom selectors for formatting specific HTML elements.
|
|
10
|
+
* @param options.wordwrap The word wrap limit (number of characters) or false to disable.
|
|
11
|
+
* @returns The converted plain text string.
|
|
12
|
+
* @throws {EmailError} When html-to-text is not installed or conversion fails.
|
|
13
|
+
*/
|
|
14
|
+
declare const htmlToText: (html: string, options?: {
|
|
15
|
+
longWordSplit?: {
|
|
16
|
+
forceWrapOnLimit?: boolean;
|
|
17
|
+
wrapCharacters?: string[];
|
|
18
|
+
};
|
|
19
|
+
preserveNewlines?: boolean;
|
|
20
|
+
selectors?: {
|
|
21
|
+
format?: string;
|
|
22
|
+
options?: Record<string, unknown>;
|
|
23
|
+
selector: string;
|
|
24
|
+
}[];
|
|
25
|
+
wordwrap?: number | false;
|
|
26
|
+
}) => string;
|
|
27
|
+
export default htmlToText;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var n=Object.defineProperty;var o=(t,e)=>n(t,"name",{value:e,configurable:!0});import{convert as a}from"html-to-text";import l from"../packem_shared/EmailError-zm2ffVav.js";var s=Object.defineProperty,i=o((t,e)=>s(t,"name",{value:e,configurable:!0}),"o");const p=i((t,e)=>{try{return a(t,{longWordSplit:e?.longWordSplit,preserveNewlines:e?.preserveNewlines??!1,selectors:e?.selectors,wordwrap:e?.wordwrap??80})}catch(r){throw r instanceof Error&&r.message.includes("Cannot find module")?new l("html-to-text","html-to-text is not installed. Please install it: pnpm add html-to-text",{cause:r}):new l("html-to-text",`Failed to convert HTML to text: ${r.message}`,{cause:r})}},"htmlToText");export{p as default};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TemplateRenderer } from "./types.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Renders MJML to HTML.
|
|
4
|
+
* @param template MJML template string.
|
|
5
|
+
* @param _data Data (not used for MJML).
|
|
6
|
+
* @param options MJML options (beautify, fonts, keepComments, minify, validationLevel).
|
|
7
|
+
* @returns Rendered HTML string.
|
|
8
|
+
* @throws {TypeError} When template is not a string.
|
|
9
|
+
* @throws {EmailError} When MJML is not installed, validation fails, or rendering fails.
|
|
10
|
+
*/
|
|
11
|
+
declare const mjml: TemplateRenderer;
|
|
12
|
+
export default mjml;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i=Object.defineProperty;var a=(t,o)=>i(t,"name",{value:o,configurable:!0});import l from"mjml";import r from"../packem_shared/EmailError-zm2ffVav.js";var f=Object.defineProperty,d=a((t,o)=>f(t,"name",{value:o,configurable:!0}),"o");const v=d((t,o,n)=>{try{if(typeof t!="string")throw new TypeError("MJML template must be a string");const e=l(t,{beautify:n?.beautify??!1,fonts:n?.fonts,keepComments:n?.keepComments??!0,minify:n?.minify??!1,validationLevel:n?.validationLevel??"soft"});if(e.errors&&e.errors.length>0){const s=e.errors.map(m=>m.message).join("; ");throw new r("mjml",`MJML validation errors: ${s}`)}return e.html}catch(e){throw e instanceof Error&&e.message.includes("Cannot find module")?new r("mjml","MJML is not installed. Please install it: pnpm add mjml",{cause:e}):e instanceof r?e:new r("mjml",`Failed to render MJML: ${e.message}`,{cause:e})}},"mjml");export{v as default};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TemplateRenderer } from "./types.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Renders a React Email component to HTML.
|
|
4
|
+
* @param template The React component from \@react-email/components to render.
|
|
5
|
+
* @param _data Data object (not used for React Email, but kept for API compatibility).
|
|
6
|
+
* @param options Render options including plainText and pretty formatting.
|
|
7
|
+
* @returns The rendered HTML string.
|
|
8
|
+
* @throws {EmailError} When \@react-email/render is not installed or rendering fails.
|
|
9
|
+
*/
|
|
10
|
+
declare const reactEmail: TemplateRenderer;
|
|
11
|
+
export default reactEmail;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var l=Object.defineProperty;var n=(e,t)=>l(e,"name",{value:t,configurable:!0});import{render as c}from"@react-email/render";import i from"../packem_shared/EmailError-zm2ffVav.js";var o=Object.defineProperty,m=n((e,t)=>o(e,"name",{value:t,configurable:!0}),"t");const u=m(async(e,t,r)=>{try{return await c(e,{plainText:r?.plainText,pretty:r?.pretty})}catch(a){throw a instanceof Error&&a.message.includes("Cannot find module")?new i("react-email","@react-email/render is not installed. Please install it: pnpm add @react-email/render",{cause:a}):new i("react-email",`Failed to render React Email component: ${a.message}`,{cause:a})}},"reactEmail");export{u as default};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template render function type.
|
|
3
|
+
* @param template Template content (string, React component, etc.).
|
|
4
|
+
* @param data Data/variables to pass to the template.
|
|
5
|
+
* @param options Options specific to the template engine.
|
|
6
|
+
* @returns Rendered HTML string.
|
|
7
|
+
*/
|
|
8
|
+
export type TemplateRenderer = (template: unknown, data?: Record<string, unknown>, options?: Record<string, unknown>) => string | Promise<string>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TemplateRenderer } from "./types.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Renders a Vue Email component to HTML.
|
|
4
|
+
* @param template The Vue component from \@vue-email/components to render.
|
|
5
|
+
* @param data Data and variables to pass to the template.
|
|
6
|
+
* @param options Render options including pretty formatting, plainText output, and htmlToTextOptions.
|
|
7
|
+
* @returns The rendered HTML or plain text string.
|
|
8
|
+
* @throws {EmailError} When \@vue-email/render is not installed or rendering fails.
|
|
9
|
+
*/
|
|
10
|
+
declare const vueEmail: TemplateRenderer;
|
|
11
|
+
export default vueEmail;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var l=Object.defineProperty;var r=(e,a)=>l(e,"name",{value:a,configurable:!0});import{render as o}from"@vue-email/render";import i from"../packem_shared/EmailError-zm2ffVav.js";var m=Object.defineProperty,s=r((e,a)=>m(e,"name",{value:a,configurable:!0}),"a");const c=s(async(e,a,n)=>{try{return await o(e,a??{},{htmlToTextOptions:n?.htmlToTextOptions,plainText:n?.plainText,pretty:n?.pretty})}catch(t){throw t instanceof Error&&t.message.includes("Cannot find module")?new i("vue-email","@vue-email/render is not installed. Please install it: pnpm add @vue-email/render",{cause:t}):new i("vue-email",`Failed to render Vue Email component: ${t.message}`,{cause:t})}},"vueEmail");export{c as default};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import type { Buffer } from "node:buffer";
|
|
2
|
+
/**
|
|
3
|
+
* Utility type for values that can be promises
|
|
4
|
+
*/
|
|
5
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
6
|
+
/**
|
|
7
|
+
* Feature flags indicating what capabilities a provider supports
|
|
8
|
+
*/
|
|
9
|
+
export interface FeatureFlags {
|
|
10
|
+
attachments?: boolean;
|
|
11
|
+
batchSending?: boolean;
|
|
12
|
+
customHeaders?: boolean;
|
|
13
|
+
html?: boolean;
|
|
14
|
+
replyTo?: boolean;
|
|
15
|
+
scheduling?: boolean;
|
|
16
|
+
tagging?: boolean;
|
|
17
|
+
templates?: boolean;
|
|
18
|
+
tracking?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Base configuration for all providers
|
|
22
|
+
*/
|
|
23
|
+
export interface BaseConfig {
|
|
24
|
+
debug?: boolean;
|
|
25
|
+
logger?: Console;
|
|
26
|
+
retries?: number;
|
|
27
|
+
timeout?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Email address with optional name
|
|
31
|
+
*/
|
|
32
|
+
export interface EmailAddress {
|
|
33
|
+
email: string;
|
|
34
|
+
name?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Email attachment
|
|
38
|
+
*/
|
|
39
|
+
export interface Attachment {
|
|
40
|
+
/**
|
|
41
|
+
* Content-ID for inline attachments (used in HTML with cid:)
|
|
42
|
+
*/
|
|
43
|
+
cid?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Attachment content (string, Buffer, or Promise<Uint8Array> for async loading)
|
|
46
|
+
* Required if path, href, or raw are not provided
|
|
47
|
+
*/
|
|
48
|
+
content?: string | Buffer | Promise<Uint8Array>;
|
|
49
|
+
/**
|
|
50
|
+
* Content disposition: 'attachment' (default) or 'inline'
|
|
51
|
+
*/
|
|
52
|
+
contentDisposition?: "attachment" | "inline";
|
|
53
|
+
/**
|
|
54
|
+
* MIME type of the attachment
|
|
55
|
+
*/
|
|
56
|
+
contentType?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Content transfer encoding (e.g., 'base64', '7bit', 'quoted-printable')
|
|
59
|
+
*/
|
|
60
|
+
encoding?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Filename for the attachment
|
|
63
|
+
*/
|
|
64
|
+
filename: string;
|
|
65
|
+
/**
|
|
66
|
+
* Custom headers for this attachment
|
|
67
|
+
*/
|
|
68
|
+
headers?: Record<string, string>;
|
|
69
|
+
/**
|
|
70
|
+
* URL to fetch attachment from
|
|
71
|
+
* Alternative to content or path
|
|
72
|
+
*/
|
|
73
|
+
href?: string;
|
|
74
|
+
/**
|
|
75
|
+
* HTTP headers to use when fetching from href
|
|
76
|
+
*/
|
|
77
|
+
httpHeaders?: Record<string, string>;
|
|
78
|
+
/**
|
|
79
|
+
* File path to read attachment from
|
|
80
|
+
* Alternative to content
|
|
81
|
+
*/
|
|
82
|
+
path?: string;
|
|
83
|
+
/**
|
|
84
|
+
* Raw attachment data (alternative to content)
|
|
85
|
+
* Can be used for pre-encoded content
|
|
86
|
+
*/
|
|
87
|
+
raw?: string | Buffer;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Email tag for categorization
|
|
91
|
+
*/
|
|
92
|
+
export interface EmailTag {
|
|
93
|
+
name: string;
|
|
94
|
+
value: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Priority levels for email messages
|
|
98
|
+
*/
|
|
99
|
+
export type Priority = "high" | "normal" | "low";
|
|
100
|
+
/**
|
|
101
|
+
* Represents the headers of an email message.
|
|
102
|
+
* This type is a supertype of the standard `Headers` class, which is used to manage HTTP headers.
|
|
103
|
+
* Note that this type does not include methods for modifying the headers,
|
|
104
|
+
* such as `append`, `delete`, or `set`. It is intended to be used for
|
|
105
|
+
* read-only access to the headers of an email message.
|
|
106
|
+
*/
|
|
107
|
+
export type ImmutableHeaders = Omit<Headers, "append" | "delete" | "set">;
|
|
108
|
+
/**
|
|
109
|
+
* Email headers can be either a plain object or an ImmutableHeaders instance
|
|
110
|
+
*/
|
|
111
|
+
export type EmailHeaders = Record<string, string> | ImmutableHeaders;
|
|
112
|
+
/**
|
|
113
|
+
* Common email options that all providers support
|
|
114
|
+
*/
|
|
115
|
+
export interface EmailOptions {
|
|
116
|
+
attachments?: Attachment[];
|
|
117
|
+
bcc?: EmailAddress | EmailAddress[];
|
|
118
|
+
cc?: EmailAddress | EmailAddress[];
|
|
119
|
+
from: EmailAddress;
|
|
120
|
+
headers?: EmailHeaders;
|
|
121
|
+
html?: string;
|
|
122
|
+
priority?: Priority;
|
|
123
|
+
replyTo?: EmailAddress;
|
|
124
|
+
subject: string;
|
|
125
|
+
tags?: string[];
|
|
126
|
+
text?: string;
|
|
127
|
+
to: EmailAddress | EmailAddress[];
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Result of sending an email
|
|
131
|
+
*/
|
|
132
|
+
export interface EmailResult {
|
|
133
|
+
messageId: string;
|
|
134
|
+
provider?: string;
|
|
135
|
+
response?: unknown;
|
|
136
|
+
sent: boolean;
|
|
137
|
+
timestamp: Date;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Receipt type for email sending results
|
|
141
|
+
* Uses discriminated union for type safety
|
|
142
|
+
*/
|
|
143
|
+
export type Receipt = {
|
|
144
|
+
/**
|
|
145
|
+
* The unique identifier for the message that was sent
|
|
146
|
+
*/
|
|
147
|
+
readonly messageId: string;
|
|
148
|
+
/**
|
|
149
|
+
* Optional provider name
|
|
150
|
+
*/
|
|
151
|
+
readonly provider?: string;
|
|
152
|
+
/**
|
|
153
|
+
* Optional response data from provider
|
|
154
|
+
*/
|
|
155
|
+
readonly response?: unknown;
|
|
156
|
+
/**
|
|
157
|
+
* Indicates that the email was sent successfully
|
|
158
|
+
*/
|
|
159
|
+
readonly successful: true;
|
|
160
|
+
/**
|
|
161
|
+
* Timestamp when email was sent
|
|
162
|
+
*/
|
|
163
|
+
readonly timestamp: Date;
|
|
164
|
+
} | {
|
|
165
|
+
/**
|
|
166
|
+
* An array of error messages that occurred during the sending process
|
|
167
|
+
*/
|
|
168
|
+
readonly errorMessages: ReadonlyArray<string>;
|
|
169
|
+
/**
|
|
170
|
+
* Optional provider name
|
|
171
|
+
*/
|
|
172
|
+
readonly provider?: string;
|
|
173
|
+
/**
|
|
174
|
+
* Indicates that the email failed to send
|
|
175
|
+
*/
|
|
176
|
+
readonly successful: false;
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* Generic result type
|
|
180
|
+
*/
|
|
181
|
+
export interface Result<T = unknown> {
|
|
182
|
+
data?: T;
|
|
183
|
+
error?: Error | unknown;
|
|
184
|
+
success: boolean;
|
|
185
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { EmailOptions } from "../types.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Builds a MIME-formatted email message from email options.
|
|
4
|
+
* @param options The email options to build the MIME message from.
|
|
5
|
+
* @returns The MIME-formatted email message as a string.
|
|
6
|
+
*/
|
|
7
|
+
declare const buildMimeMessage: <T extends EmailOptions>(options: T) => Promise<string>;
|
|
8
|
+
export default buildMimeMessage;
|
|
@@ -0,0 +1,16 @@
|
|
|
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;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger interface with debug, error, info, and warn methods.
|
|
3
|
+
*/
|
|
4
|
+
type Logger = {
|
|
5
|
+
debug: (message: string, ...args: unknown[]) => void;
|
|
6
|
+
error: (message: string, ...args: unknown[]) => void;
|
|
7
|
+
info: (message: string, ...args: unknown[]) => void;
|
|
8
|
+
warn: (message: string, ...args: unknown[]) => void;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Creates a logger instance for a provider with optional console output.
|
|
12
|
+
* @param providerName The name of the provider (used as prefix in log messages).
|
|
13
|
+
* @param logger Optional Console instance. If provided, logs will be displayed with prefixes. If not provided, returns a no-op logger.
|
|
14
|
+
* @returns A logger instance with debug, error, info, and warn methods.
|
|
15
|
+
*/
|
|
16
|
+
declare const createLogger: (providerName: string, logger?: Console) => Logger;
|
|
17
|
+
export type { Logger };
|
|
18
|
+
export default createLogger;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { EmailAddress } from "../types.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Formats an email address as "Name <email@example.com>" or just "email@example.com" if no name is provided.
|
|
4
|
+
* @param address The email address object to format.
|
|
5
|
+
* @returns The formatted email address string in RFC 5322 format.
|
|
6
|
+
* @throws {EmailError} When the email address is invalid.
|
|
7
|
+
*/
|
|
8
|
+
declare const formatEmailAddress: (address: EmailAddress) => string;
|
|
9
|
+
export default formatEmailAddress;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { EmailAddress } from "../types.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Formats a list of email addresses into a comma-separated string.
|
|
4
|
+
* @param addresses The email address(es) to format (single or array).
|
|
5
|
+
* @returns The formatted email addresses string (comma-separated if multiple).
|
|
6
|
+
*/
|
|
7
|
+
declare const formatEmailAddresses: (addresses: EmailAddress | EmailAddress[]) => string;
|
|
8
|
+
export default formatEmailAddresses;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a unique boundary string for MIME multipart email messages.
|
|
3
|
+
* Works across Node.js, Deno, Bun, and Workers.
|
|
4
|
+
* @returns A unique boundary string for MIME multipart messages.
|
|
5
|
+
*/
|
|
6
|
+
declare const generateBoundary: () => string;
|
|
7
|
+
export default generateBoundary;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { EmailHeaders } from "../types.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Converts EmailHeaders (Record<string, string> or ImmutableHeaders) to Record<string, string>.
|
|
4
|
+
* This allows us to work with headers uniformly regardless of their input type.
|
|
5
|
+
* @param headers The headers to convert (Record or ImmutableHeaders).
|
|
6
|
+
* @returns A plain object Record<string, string> representation of the headers.
|
|
7
|
+
*/
|
|
8
|
+
declare const headersToRecord: (headers: EmailHeaders) => Record<string, string>;
|
|
9
|
+
export default headersToRecord;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a port is available on a host.
|
|
3
|
+
* Works across environments with polyfills.
|
|
4
|
+
* @param host The hostname or IP address to check.
|
|
5
|
+
* @param port The port number to check.
|
|
6
|
+
* @returns Promise that resolves to true if the port is available, false otherwise.
|
|
7
|
+
*/
|
|
8
|
+
declare const isPortAvailable: (host: string, port: number) => Promise<boolean>;
|
|
9
|
+
export default isPortAvailable;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Result } from "../types.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Request options compatible with both Fetch API and Node.js http
|
|
4
|
+
*/
|
|
5
|
+
export interface RequestOptions {
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
headers?: Record<string, string>;
|
|
8
|
+
method?: string;
|
|
9
|
+
timeout?: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Makes an HTTP request using Fetch API (compatible with Node.js 20.19+, Deno, Bun, Cloudflare Workers).
|
|
13
|
+
* @param url The URL to make the request to.
|
|
14
|
+
* @param options Request options including method, headers, and timeout.
|
|
15
|
+
* @param data Optional request body data (string, Buffer, or Uint8Array).
|
|
16
|
+
* @returns A result object containing the response data or error.
|
|
17
|
+
*/
|
|
18
|
+
export declare const makeRequest: (url: string | URL, options?: RequestOptions, data?: string | Buffer | Uint8Array) => Promise<Result<unknown>>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { EmailAddress } from "../types.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Parses a string representation of an email address into an EmailAddress object.
|
|
4
|
+
* Supports formats: "email@example.com", "Name <email@example.com>", "<email@example.com>".
|
|
5
|
+
* @example Parsing an address with a name
|
|
6
|
+
* ```ts
|
|
7
|
+
* const address = parseAddress("John Doe <john@example.com>");
|
|
8
|
+
* // { name: "John Doe", email: "john@example.com" }
|
|
9
|
+
* ```
|
|
10
|
+
* @example Parsing an address without a name
|
|
11
|
+
* ```ts
|
|
12
|
+
* const address = parseAddress("jane@example.com");
|
|
13
|
+
* // { email: "jane@example.com" }
|
|
14
|
+
* ```
|
|
15
|
+
* @param address The string representation of the address to parse.
|
|
16
|
+
* @returns An EmailAddress object if parsing is successful, or undefined if invalid.
|
|
17
|
+
*/
|
|
18
|
+
declare const parseAddress: (address: string) => EmailAddress | undefined;
|
|
19
|
+
export default parseAddress;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Result } from "../types.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Helper function to retry an async function with exponential backoff.
|
|
4
|
+
* @param function_ The async function to retry.
|
|
5
|
+
* @param retries Number of retry attempts (default: 3).
|
|
6
|
+
* @param delay Initial delay in milliseconds (default: 300, doubles on each retry).
|
|
7
|
+
* @returns A result object containing the function result or error.
|
|
8
|
+
*/
|
|
9
|
+
declare const retry: <T>(function_: () => Promise<Result<T>>, retries?: number, delay?: number) => Promise<Result<T>>;
|
|
10
|
+
export default retry;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sanitizes header values to prevent CRLF injection attacks.
|
|
3
|
+
* Removes carriage return (\r) and line feed (\n) characters.
|
|
4
|
+
* @param value The header value to sanitize.
|
|
5
|
+
* @returns The sanitized header value with CR/LF characters removed.
|
|
6
|
+
*/
|
|
7
|
+
export declare const sanitizeHeaderValue: (value: string) => string;
|
|
8
|
+
/**
|
|
9
|
+
* Sanitizes header names to prevent CRLF injection attacks.
|
|
10
|
+
* Removes carriage return (\r) and line feed (\n) characters.
|
|
11
|
+
* @param name The header name to sanitize.
|
|
12
|
+
* @returns The sanitized header name with CR/LF characters removed.
|
|
13
|
+
*/
|
|
14
|
+
export declare const sanitizeHeaderName: (name: string) => string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts content to a base64-encoded string.
|
|
3
|
+
* Works across Node.js, Deno, Bun, and Workers.
|
|
4
|
+
* @param content The content to convert (string, Buffer, Uint8Array, or ArrayLike<number>).
|
|
5
|
+
* @returns The base64-encoded string.
|
|
6
|
+
*/
|
|
7
|
+
declare const toBase64: (content: string | Buffer | Uint8Array | ArrayLike<number>) => string;
|
|
8
|
+
export default toBase64;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { EmailOptions } from "../types.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Validates email options and returns any validation errors.
|
|
4
|
+
* @param options The email options to validate.
|
|
5
|
+
* @returns Array of error messages (empty if validation passes).
|
|
6
|
+
*/
|
|
7
|
+
declare const validateEmailOptions: <T extends EmailOptions>(options: T) => string[];
|
|
8
|
+
export default validateEmailOptions;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates an email address format according to basic RFC standards.
|
|
3
|
+
* @param email The email address string to validate.
|
|
4
|
+
* @returns True if the email address is valid, false otherwise.
|
|
5
|
+
*/
|
|
6
|
+
declare const validateEmail: (email: string) => boolean;
|
|
7
|
+
export default validateEmail;
|