@stacksjs/email 0.75.529 → 0.75.535

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.
@@ -52,6 +52,7 @@ export declare interface CapturedMessage extends EmailMessage {
52
52
  messageId: string
53
53
  }
54
54
  export declare class CaptureEmailDriver extends BaseEmailDriver {
55
+ /** @defaultValue 'capture' */
55
56
  name: string;
56
57
  send(message: EmailMessage, _options?: TemplateOptions): Promise<EmailResult>;
57
58
  static all(): readonly CapturedMessage[];
@@ -1,4 +1,5 @@
1
1
  import { BaseEmailDriver } from './base';
2
+ import { log } from '@stacksjs/logging';
2
3
  import type { EmailMessage, EmailResult } from '@stacksjs/types';
3
4
  import type { TemplateOptions } from '../template';
4
5
  /**
@@ -19,6 +20,7 @@ declare interface CapturedEmail extends EmailMessage {
19
20
  rendered?: { html?: string, text?: string }
20
21
  }
21
22
  export declare class LogEmailDriver extends BaseEmailDriver {
23
+ /** @defaultValue 'log' */
22
24
  name: string;
23
25
  static directory(): string;
24
26
  send(message: EmailMessage, options?: TemplateOptions): Promise<EmailResult>;
@@ -2,6 +2,7 @@ import { BaseEmailDriver } from './base';
2
2
  import type { EmailMessage, EmailResult } from '@stacksjs/types';
3
3
  import type { TemplateOptions } from '../template';
4
4
  export declare class MailgunDriver extends BaseEmailDriver {
5
+ /** @defaultValue 'mailgun' */
5
6
  name: string;
6
7
  private apiKey;
7
8
  private domain;
@@ -22,6 +22,7 @@ export declare const MAILTRAP_SENDING_URL: 'https://send.api.mailtrap.io/api/sen
22
22
  /** Mailtrap's Email Testing (sandbox) API: captures into an inbox, delivers nothing. */
23
23
  export declare const MAILTRAP_SANDBOX_URL: 'https://sandbox.api.mailtrap.io/api/send';
24
24
  export declare class MailtrapDriver extends BaseEmailDriver {
25
+ /** @defaultValue 'mailtrap' */
25
26
  name: string;
26
27
  private getConfig;
27
28
  send(message: EmailMessage, options?: TemplateOptions): Promise<EmailResult>;
@@ -2,6 +2,7 @@ import { BaseEmailDriver } from './base';
2
2
  import type { EmailMessage, EmailResult } from '@stacksjs/types';
3
3
  import type { TemplateOptions } from '../template';
4
4
  export declare class SendGridDriver extends BaseEmailDriver {
5
+ /** @defaultValue 'sendgrid' */
5
6
  name: string;
6
7
  private apiKey;
7
8
  private getApiKey;
@@ -2,6 +2,7 @@ import { BaseEmailDriver } from './base';
2
2
  import type { EmailMessage, EmailResult } from '@stacksjs/types';
3
3
  import type { TemplateOptions } from '../template';
4
4
  export declare class SESDriver extends BaseEmailDriver {
5
+ /** @defaultValue 'ses' */
5
6
  name: string;
6
7
  private client;
7
8
  private clientPromise;
@@ -8,6 +8,7 @@ import type { TemplateOptions } from '../template';
8
8
  */
9
9
  export declare class SMTPDriver extends BaseEmailDriver {
10
10
  private static SMTP_TIMEOUT;
11
+ /** @defaultValue 'smtp' */
11
12
  name: string;
12
13
  private getConfig;
13
14
  send(message: EmailMessage, options?: TemplateOptions): Promise<EmailResult>;
@@ -1,4 +1,4 @@
1
- function splitHeaders(value){const normalized=value.replace(/\r\n/g,`
1
+ import{decodeHtmlEntities}from"@stacksjs/strings";function splitHeaders(value){const normalized=value.replace(/\r\n/g,`
2
2
  `);const separator=normalized.indexOf(`
3
3
 
4
4
  `);if(separator<0)return{headers:{},body:normalized};const headerLines=normalized.slice(0,separator).replace(/\n[ \t]+/g," ").split(`
@@ -6,4 +6,4 @@ function splitHeaders(value){const normalized=value.replace(/\r\n/g,`
6
6
  `).replace(/=\n/g,"");const bytes=[];const encoder=new TextEncoder;for(let index=0;index<input.length;index++){const encoded=input.slice(index,index+3);if(/^=[0-9a-f]{2}$/i.test(encoded)){bytes.push(Number.parseInt(encoded.slice(1),16));index+=2}else{bytes.push(...encoder.encode(input[index]))}}return new TextDecoder().decode(Uint8Array.from(bytes))}function normalizedMimeBody(value,requestedType){const normalized=value.replace(/\r\n/g,`
7
7
  `).trim();const fragmentBoundary=normalized.match(/^--([^\n]+)\n/)?.[1]?.replace(/--$/,"");const hasMimeHeaders=/^(?:content-type|content-transfer-encoding|mime-version):/i.test(normalized);const source=fragmentBoundary?`Content-Type: multipart/mixed; boundary="${fragmentBoundary.replace(/["\\]/g,"")}"
8
8
 
9
- ${normalized}`:normalized;if(fragmentBoundary||hasMimeHeaders){const parts=mimeParts(source);const selected=parts.find((part)=>part.contentType.startsWith(requestedType));if(selected)return decodeBody(selected.body,selected.encoding).trim()}return decodeQuotedPrintable(stripLegacyMimePreamble(normalized)).trim()}function decodeBody(body,encoding){if(encoding==="base64"){try{return Buffer.from(body.replace(/\s+/g,""),"base64").toString("utf8")}catch{return body}}if(encoding==="quoted-printable")return decodeQuotedPrintable(body);return body}function mimeParts(value){const{headers,body}=splitHeaders(value);const contentType=(headers["content-type"]||"text/plain").toLowerCase();const boundary=headers["content-type"]?.match(/boundary\s*=\s*(?:"([^"]+)"|([^;\s]+))/i)?.slice(1).find(Boolean);if(contentType.startsWith("multipart/")&&boundary){return body.split(`--${boundary}`).slice(1).filter((part)=>!part.trimStart().startsWith("--")).flatMap(mimeParts)}return[{contentType,encoding:(headers["content-transfer-encoding"]||"").toLowerCase(),body}]}function stripLegacyMimePreamble(value){let result=value.trim();result=result.replace(/^[-=_]{2,}[^\s]*\s+/,"");for(let pass=0;pass<6;pass++){const next=result.replace(/^content-transfer-encoding:\s*[^\s]+\s*/i,"").replace(/^mime-version:\s*[^\s]+\s*/i,"").replace(/^content-description:\s*[^\s]+\s*/i,"").replace(/^content-type:\s*[^\s;]+(?:;\s*(?:charset|boundary|name)\s*=\s*(?:"[^"]*"|[^\s]+))*\s*/i,"");if(next===result)break;result=next}return result.replace(/^[-=_]{4,}[^\s]*\s*/,"")}function plainText(value){return decodeQuotedPrintable(stripLegacyMimePreamble(value)).replace(/<style\b[\s\S]*?<\/style>/gi," ").replace(/<script\b[\s\S]*?<\/script>/gi," ").replace(/<[^>]+>/g," ").replace(/&nbsp;/gi," ").replace(/&amp;/gi,"&").replace(/&lt;/gi,"<").replace(/&gt;/gi,">").replace(/&quot;/gi,'"').replace(/&#39;/gi,"'").replace(/\s+/g," ").trim()}export function extractEmailPreview(rawEmail,maxLength=200){const parts=mimeParts(rawEmail);const selected=parts.find((part)=>part.contentType.startsWith("text/plain"))||parts.find((part)=>part.contentType.startsWith("text/html"));return plainText(selected?decodeBody(selected.body,selected.encoding):rawEmail).slice(0,maxLength)}export function normalizeEmailPreview(preview,maxLength=200){return plainText(preview).slice(0,maxLength)}export function normalizeEmailTextBody(body){return normalizedMimeBody(body,"text/plain")}export function normalizeEmailHtmlBody(body){return normalizedMimeBody(body,"text/html")}
9
+ ${normalized}`:normalized;if(fragmentBoundary||hasMimeHeaders){const parts=mimeParts(source);const selected=parts.find((part)=>part.contentType.startsWith(requestedType));if(selected)return decodeBody(selected.body,selected.encoding).trim()}return decodeQuotedPrintable(stripLegacyMimePreamble(normalized)).trim()}function decodeBody(body,encoding){if(encoding==="base64"){try{return Buffer.from(body.replace(/\s+/g,""),"base64").toString("utf8")}catch{return body}}if(encoding==="quoted-printable")return decodeQuotedPrintable(body);return body}function mimeParts(value){const{headers,body}=splitHeaders(value);const contentType=(headers["content-type"]||"text/plain").toLowerCase();const boundary=headers["content-type"]?.match(/boundary\s*=\s*(?:"([^"]+)"|([^;\s]+))/i)?.slice(1).find(Boolean);if(contentType.startsWith("multipart/")&&boundary){return body.split(`--${boundary}`).slice(1).filter((part)=>!part.trimStart().startsWith("--")).flatMap(mimeParts)}return[{contentType,encoding:(headers["content-transfer-encoding"]||"").toLowerCase(),body}]}function stripLegacyMimePreamble(value){let result=value.trim();result=result.replace(/^[-=_]{2,}[^\s]*\s+/,"");for(let pass=0;pass<6;pass++){const next=result.replace(/^content-transfer-encoding:\s*[^\s]+\s*/i,"").replace(/^mime-version:\s*[^\s]+\s*/i,"").replace(/^content-description:\s*[^\s]+\s*/i,"").replace(/^content-type:\s*[^\s;]+(?:;\s*(?:charset|boundary|name)\s*=\s*(?:"[^"]*"|[^\s]+))*\s*/i,"");if(next===result)break;result=next}return result.replace(/^[-=_]{4,}[^\s]*\s*/,"")}function plainText(value){const stripped=decodeQuotedPrintable(stripLegacyMimePreamble(value)).replace(/<style\b[\s\S]*?<\/style>/gi," ").replace(/<script\b[\s\S]*?<\/script>/gi," ").replace(/<[^>]+>/g," ");return decodeHtmlEntities(stripped).replace(/\s+/g," ").trim()}export function extractEmailPreview(rawEmail,maxLength=200){const parts=mimeParts(rawEmail);const selected=parts.find((part)=>part.contentType.startsWith("text/plain"))||parts.find((part)=>part.contentType.startsWith("text/html"));return plainText(selected?decodeBody(selected.body,selected.encoding):rawEmail).slice(0,maxLength)}export function normalizeEmailPreview(preview,maxLength=200){return plainText(preview).slice(0,maxLength)}export function normalizeEmailTextBody(body){return normalizedMimeBody(body,"text/plain")}export function normalizeEmailHtmlBody(body){return normalizedMimeBody(body,"text/html")}
@@ -49,4 +49,4 @@ export declare function isHeaderName(name: string): boolean;
49
49
  *
50
50
  * Requires a single `@` separating local part and domain.
51
51
  */
52
- export declare const ENVELOPE_ADDRESS: unknown;
52
+ export declare const ENVELOPE_ADDRESS: RegExp;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/email",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.529",
5
+ "version": "0.75.535",
6
6
  "description": "The Stacks Email integration. Painlessly create & manage your inboxes, templates, and send emails.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -61,26 +61,26 @@
61
61
  "prepublishOnly": "bun run build"
62
62
  },
63
63
  "dependencies": {
64
- "@stacksjs/config": "0.75.529",
65
- "@stacksjs/database": "0.75.529",
66
- "@stacksjs/events": "0.75.529",
67
- "@stacksjs/logging": "0.75.529",
64
+ "@stacksjs/config": "0.75.535",
65
+ "@stacksjs/database": "0.75.535",
66
+ "@stacksjs/events": "0.75.535",
67
+ "@stacksjs/logging": "0.75.535",
68
68
  "@stacksjs/mail": "^0.3.11",
69
- "@stacksjs/path": "0.75.529",
70
- "@stacksjs/storage": "0.75.529",
71
- "@stacksjs/strings": "0.75.529",
72
- "@stacksjs/stx": "0.2.807",
69
+ "@stacksjs/path": "0.75.535",
70
+ "@stacksjs/storage": "0.75.535",
71
+ "@stacksjs/strings": "0.75.535",
72
+ "@stacksjs/stx": "0.2.842",
73
73
  "@stacksjs/ts-cloud": "^0.16.109",
74
- "@stacksjs/utils": "0.75.529"
74
+ "@stacksjs/utils": "0.75.535"
75
75
  },
76
76
  "devDependencies": {
77
- "@stacksjs/cli": "0.75.529",
78
- "@stacksjs/error-handling": "0.75.529",
79
- "@stacksjs/types": "0.75.529",
77
+ "@stacksjs/cli": "0.75.535",
78
+ "@stacksjs/error-handling": "0.75.535",
79
+ "@stacksjs/types": "0.75.535",
80
80
  "better-dx": "^0.2.24"
81
81
  },
82
82
  "peerDependencies": {
83
- "@stacksjs/queue": "0.75.529"
83
+ "@stacksjs/queue": "0.75.535"
84
84
  },
85
85
  "peerDependenciesMeta": {
86
86
  "@stacksjs/queue": {