@nexusts/mail 0.8.4 → 0.9.0

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/dist/index.js CHANGED
@@ -31,9 +31,6 @@ var __legacyMetadataTS = (k, v) => {
31
31
  return Reflect.metadata(k, v);
32
32
  };
33
33
  var __require = import.meta.require;
34
-
35
- // packages/mail/src/types.ts
36
- import"reflect-metadata";
37
34
  // packages/mail/src/transports/null.ts
38
35
  class NullTransport {
39
36
  kind = "null";
@@ -210,7 +207,6 @@ MailService = __legacyDecorateClassTS([
210
207
  ])
211
208
  ], MailService);
212
209
  // packages/mail/src/mail.module.ts
213
- import"reflect-metadata";
214
210
  import { Module } from "@nexusts/core";
215
211
  class MailModule {
216
212
  static forRoot(config = {}) {
@@ -254,5 +250,5 @@ export {
254
250
  FileTransport
255
251
  };
256
252
 
257
- //# debugId=AE5AFC70E0F5B29164756E2164756E21
253
+ //# debugId=07D20E8117E7E46E64756E2164756E21
258
254
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,15 +1,14 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/types.ts", "../src/transports/null.ts", "../src/transports/file.ts", "../src/transports/smtp.ts", "../src/mail.service.ts", "../src/mail.module.ts"],
3
+ "sources": ["../src/transports/null.ts", "../src/transports/file.ts", "../src/transports/smtp.ts", "../src/mail.service.ts", "../src/mail.module.ts"],
4
4
  "sourcesContent": [
5
- "/**\n * `nexusjs/mail` — outbound email.\n *\n * const mail = new MailService({ transport: new SmtpTransport({ host: 'smtp.gmail.com' }) });\n * await mail.send({\n * from: 'no-reply@example.com',\n * to: 'user@example.com',\n * subject: 'Welcome',\n * html: '<h1>Hi</h1>',\n * });\n *\n * Transports:\n * - `SmtpTransport` — SMTP via nodemailer (peer dep)\n * - `FileTransport` — write .eml files to a directory (dev/test)\n * - `NullTransport` — drop everything (tests)\n *\n * mail.renderMjml('template', { name: 'Kim' }) // compile MJML to HTML\n */\nimport \"reflect-metadata\";\n\n/** A single recipient. */\nexport type MailAddress = string | { name?: string; address: string };\n\n/** A mail message. */\nexport interface MailMessage {\n\tfrom?: MailAddress;\n\tto: MailAddress | MailAddress[];\n\tcc?: MailAddress | MailAddress[];\n\tbcc?: MailAddress | MailAddress[];\n\treplyTo?: MailAddress;\n\tsubject: string;\n\ttext?: string;\n\thtml?: string;\n\t/** Attachments. */\n\tattachments?: MailAttachment[];\n\t/** Custom headers. */\n\theaders?: Record<string, string>;\n\t/** Priority: 1 (high), 3 (normal), 5 (low). */\n\tpriority?: \"high\" | \"normal\" | \"low\";\n}\n\nexport interface MailAttachment {\n\tfilename: string;\n\t/** File content (Buffer / string). */\n\tcontent: Buffer | string;\n\t/** MIME type. Default: 'application/octet-stream'. */\n\tcontentType?: string;\n\t/** Content-ID for inline images. */\n\tcid?: string;\n}\n\n/** Result returned by a transport after sending. */\nexport interface MailSendResult {\n\t/** Transport-specific ID (e.g. SMTP message-id). */\n\tid: string;\n\t/** When the message was sent (unix-ms). */\n\tsentAt: number;\n}\n\n/** Transport that knows how to deliver a message. */\nexport interface MailTransport {\n\treadonly kind: string;\n\tsend(msg: MailMessage): Promise<MailSendResult>;\n\tclose?(): Promise<void>;\n}\n\n/** Top-level config. */\nexport interface MailConfig {\n\t/** Transport backend. Default: NullTransport. */\n\ttransport?: MailTransport;\n\t/** Default `from` address. */\n\tdefaultFrom?: MailAddress;\n\t/** Whether to expose raw `nodemailer` (only if SmtpTransport is used). */\n\tdebug?: boolean;\n}\n",
6
5
  "/**\n * Null mail transport. Drops every message. Useful in tests.\n */\nimport type { MailMessage, MailSendResult, MailTransport } from \"../types.js\";\n\nexport class NullTransport implements MailTransport {\n\treadonly kind = \"null\";\n\t/** Captured messages for inspection in tests. */\n\tsent: MailMessage[] = [];\n\n\tasync send(msg: MailMessage): Promise<MailSendResult> {\n\t\tthis.sent.push(msg);\n\t\treturn {\n\t\t\tid: `null-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,\n\t\t\tsentAt: Date.now(),\n\t\t};\n\t}\n}\n",
7
6
  "/**\n * File mail transport. Writes each outgoing message as a `.eml` file\n * under a directory. Useful for development and acceptance tests.\n *\n * new FileTransport({ dir: './tmp/mail', pretty: true });\n */\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport type { MailMessage, MailSendResult, MailTransport } from \"../types.js\";\n\nexport interface FileTransportOptions {\n\t/** Directory where `.eml` files are written. */\n\tdir: string;\n\t/** Format the .eml with proper headers (true) or just the body (false). Default: true. */\n\tincludeHeaders?: boolean;\n\t/** Pretty-print JSON content-type bodies. */\n\tpretty?: boolean;\n}\n\nexport class FileTransport implements MailTransport {\n\treadonly kind = \"file\";\n\tprivate opts: Required<FileTransportOptions>;\n\n\tconstructor(opts: FileTransportOptions) {\n\t\tthis.opts = {\n\t\t\tdir: opts.dir,\n\t\t\tincludeHeaders: opts.includeHeaders ?? true,\n\t\t\tpretty: opts.pretty ?? true,\n\t\t};\n\t}\n\n\tasync send(msg: MailMessage): Promise<MailSendResult> {\n\t\tawait mkdir(this.opts.dir, { recursive: true });\n\t\tconst id = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;\n\t\tconst filename = `${id}.eml`;\n\t\tconst body = this.opts.includeHeaders ? this.toEml(msg) : this.toBody(msg);\n\t\tawait writeFile(join(this.opts.dir, filename), body, \"utf-8\");\n\t\treturn { id, sentAt: Date.now() };\n\t}\n\n\tprivate toEml(msg: MailMessage): string {\n\t\tconst headers: string[] = [];\n\t\tif (msg.from) headers.push(`From: ${this.formatAddr(msg.from)}`);\n\t\theaders.push(`To: ${this.formatAddr(msg.to)}`);\n\t\tif (msg.cc) headers.push(`Cc: ${this.formatAddr(msg.cc)}`);\n\t\tif (msg.replyTo) headers.push(`Reply-To: ${this.formatAddr(msg.replyTo)}`);\n\t\theaders.push(`Subject: ${msg.subject}`);\n\t\theaders.push(`Date: ${new Date().toUTCString()}`);\n\t\theaders.push(`MIME-Version: 1.0`);\n\t\tif (msg.html) {\n\t\t\theaders.push(`Content-Type: text/html; charset=utf-8`);\n\t\t} else {\n\t\t\theaders.push(`Content-Type: text/plain; charset=utf-8`);\n\t\t}\n\t\tconst body = msg.html ?? msg.text ?? \"\";\n\t\treturn `${headers.join(\"\\r\\n\")}\\r\\n\\r\\n${body}`;\n\t}\n\n\tprivate toBody(msg: MailMessage): string {\n\t\treturn msg.html ?? msg.text ?? \"\";\n\t}\n\n\tprivate formatAddr(a: MailMessage[\"to\"]): string {\n\t\tif (Array.isArray(a)) return a.map((x) => this.formatAddr(x)).join(\", \");\n\t\tif (typeof a === \"string\") return a;\n\t\treturn a.name ? `${a.name} <${a.address}>` : a.address;\n\t}\n}\n",
8
7
  "/**\n * SMTP mail transport. Uses `nodemailer` as an optional peer dep.\n *\n * const transport = new SmtpTransport({\n * host: 'smtp.gmail.com',\n * port: 465,\n * secure: true,\n * auth: { user: '...', pass: '...' },\n * });\n * const mail = new MailService({ transport });\n */\nimport type { MailMessage, MailSendResult, MailTransport } from \"../types.js\";\n\nexport interface SmtpTransportOptions {\n\thost: string;\n\tport?: number;\n\tsecure?: boolean;\n\tauth?: { user: string; pass: string };\n\t/** Optional pool of pre-opened connections. */\n\tpool?: boolean;\n\t/** Maximum connections. */\n\tmaxConnections?: number;\n\t/** Sender override. */\n\tdefaultFrom?: string;\n\t/** `nodemailer` extra options. */\n\textras?: Record<string, any>;\n}\n\nexport class SmtpTransport implements MailTransport {\n\treadonly kind = \"smtp\";\n\tprivate opts: SmtpTransportOptions;\n\tprivate _transporter: any = null;\n\n\tconstructor(opts: SmtpTransportOptions) {\n\t\tthis.opts = opts;\n\t}\n\n\tprivate async transporter() {\n\t\tif (this._transporter) return this._transporter;\n\t\ttry {\n\t\t\tconst mod = await import(\"nodemailer\");\n\t\t\tthis._transporter = mod.default.createTransport({\n\t\t\t\thost: this.opts.host,\n\t\t\t\tport: this.opts.port,\n\t\t\t\tsecure: this.opts.secure,\n\t\t\t\tauth: this.opts.auth,\n\t\t\t\tpool: this.opts.pool,\n\t\t\t\tmaxConnections: this.opts.maxConnections,\n\t\t\t\t...this.opts.extras,\n\t\t\t});\n\t\t} catch (err) {\n\t\t\tthrow new Error(\n\t\t\t\t\"SmtpTransport requires nodemailer. Install it with: bun add nodemailer\",\n\t\t\t);\n\t\t}\n\t\treturn this._transporter;\n\t}\n\n\tasync send(msg: MailMessage): Promise<MailSendResult> {\n\t\tconst t = await this.transporter();\n\t\tconst from = this.formatAddr(msg.from ?? this.opts.defaultFrom);\n\t\tconst res = await t.sendMail({\n\t\t\tfrom,\n\t\t\tto: this.formatAddr(msg.to),\n\t\t\tcc: msg.cc ? this.formatAddr(msg.cc) : undefined,\n\t\t\tbcc: msg.bcc ? this.formatAddr(msg.bcc) : undefined,\n\t\t\treplyTo: msg.replyTo ? this.formatAddr(msg.replyTo) : undefined,\n\t\t\tsubject: msg.subject,\n\t\t\ttext: msg.text,\n\t\t\thtml: msg.html,\n\t\t\tattachments: msg.attachments?.map((a) => ({\n\t\t\t\tfilename: a.filename,\n\t\t\t\tcontent: a.content,\n\t\t\t\tcontentType: a.contentType,\n\t\t\t\tcid: a.cid,\n\t\t\t})),\n\t\t\theaders: msg.headers,\n\t\t\tpriority: msg.priority,\n\t\t});\n\t\treturn {\n\t\t\tid: res.messageId ?? `smtp-${Date.now()}`,\n\t\t\tsentAt: Date.now(),\n\t\t};\n\t}\n\n\tasync close(): Promise<void> {\n\t\tif (this._transporter) {\n\t\t\tawait this._transporter.close();\n\t\t\tthis._transporter = null;\n\t\t}\n\t}\n\n\tprivate formatAddr(a: MailMessage[\"to\"] | undefined): string {\n\t\tif (!a) return \"\";\n\t\tif (Array.isArray(a)) return a.map((x) => this.formatAddr(x)).join(\", \");\n\t\tif (typeof a === \"string\") return a;\n\t\treturn a.name ? `${a.name} <${a.address}>` : a.address;\n\t}\n}\n",
9
8
  "/**\n * `MailService` — main entry point for outbound mail.\n *\n * const mail = new MailService({ transport: new NullTransport() });\n * await mail.send({ to: 'a@b.com', subject: 'hi', html: '<h1>hi</h1>' });\n *\n * mail.renderMjml('<mjml>...</mjml>', { name: 'Kim' });\n */\nimport { Inject, Injectable } from \"@nexusts/core\";\nimport { NullTransport } from \"./transports/null.js\";\nimport type {\n\tMailConfig,\n\tMailMessage,\n\tMailSendResult,\n\tMailTransport,\n} from \"./types.js\";\n\n@Injectable()\nexport class MailService {\n\t/** DI token. */\n\tstatic readonly TOKEN = Symbol.for(\"nexus:MailService\");\n\n\ttransport: MailTransport;\n\tdefaultFrom?: MailConfig[\"defaultFrom\"];\n\n\tconstructor(@Inject(\"MAIL_CONFIG\") config: MailConfig = {}) {\n\t\tthis.transport = config.transport ?? new NullTransport();\n\t\tthis.defaultFrom = config.defaultFrom;\n\t}\n\n\t/** Send a single message. */\n\tasync send(msg: MailMessage): Promise<MailSendResult> {\n\t\tconst full = { ...msg, from: msg.from ?? this.defaultFrom };\n\t\treturn this.transport.send(full);\n\t}\n\n\t/** Send the same message to many recipients (one envelope per call). */\n\tasync sendBatch(msg: Omit<MailMessage, \"to\">, recipients: string[]): Promise<MailSendResult[]> {\n\t\tconst results: MailSendResult[] = [];\n\t\tfor (const to of recipients) {\n\t\t\tresults.push(await this.send({ ...msg, to }));\n\t\t}\n\t\treturn results;\n\t}\n\n\t/**\n\t * Render an MJML template. The optional `mjml` peer dep is loaded lazily.\n\t * Throws a clear error if not installed.\n\t */\n\tasync renderMjml(template: string, _vars?: Record<string, unknown>): Promise<string> {\n\t\ttry {\n\t\t\tconst mod = await import(\"mjml\");\n\t\t\tconst { html } = mod.mjml2html(template);\n\t\t\treturn html;\n\t\t} catch (err) {\n\t\t\tthrow new Error(\n\t\t\t\t\"renderMjml requires the 'mjml' package. Install it with: bun add mjml\",\n\t\t\t);\n\t\t}\n\t}\n}\n",
10
- "/**\n * `MailModule` — drop-in mail.\n *\n * @Module({\n * imports: [\n * MailModule.forRoot({\n * transport: new SmtpTransport({ host: 'smtp.example.com' }),\n * defaultFrom: 'no-reply@example.com',\n * }),\n * ],\n * })\n * export class AppModule {}\n */\nimport \"reflect-metadata\";\nimport { Module } from \"@nexusts/core\";\nimport { MailService } from \"./mail.service.js\";\nimport { NullTransport } from \"./transports/null.js\";\nimport type { MailConfig } from \"./types.js\";\n\n@Module({\n\tproviders: [\n\t\tMailService,\n\t\t{ provide: MailService.TOKEN, useExisting: MailService },\n\t],\n\texports: [MailService, MailService.TOKEN],\n})\nexport class MailModule {\n\tstatic forRoot(config: MailConfig = {}) {\n\t\tconst cfg: MailConfig = {\n\t\t\ttransport: new NullTransport(),\n\t\t\t...config,\n\t\t};\n\t\t@Module({\n\t\t\tproviders: [\n\t\t\t\tMailService,\n\t\t\t\t{ provide: MailService.TOKEN, useExisting: MailService },\n\t\t\t\t{ provide: \"MAIL_CONFIG\", useValue: cfg },\n\t\t\t],\n\t\t\texports: [MailService, MailService.TOKEN],\n\t\t})\n\t\tclass ConfiguredMailModule {}\n\t\tObject.defineProperty(ConfiguredMailModule, \"name\", {\n\t\t\tvalue: \"ConfiguredMailModule\",\n\t\t});\n\t\treturn ConfiguredMailModule;\n\t}\n}\n"
9
+ "/**\n * `MailModule` — drop-in mail.\n *\n * @Module({\n * imports: [\n * MailModule.forRoot({\n * transport: new SmtpTransport({ host: 'smtp.example.com' }),\n * defaultFrom: 'no-reply@example.com',\n * }),\n * ],\n * })\n * export class AppModule {}\n */\nimport { Module } from \"@nexusts/core\";\nimport { MailService } from \"./mail.service.js\";\nimport { NullTransport } from \"./transports/null.js\";\nimport type { MailConfig } from \"./types.js\";\nimport { safeGetMeta, safeDefineMeta, safeHasMeta } from \"@nexusts/core/di/safe-reflect\";\n\n@Module({\n\tproviders: [\n\t\tMailService,\n\t\t{ provide: MailService.TOKEN, useExisting: MailService },\n\t],\n\texports: [MailService, MailService.TOKEN],\n})\nexport class MailModule {\n\tstatic forRoot(config: MailConfig = {}) {\n\t\tconst cfg: MailConfig = {\n\t\t\ttransport: new NullTransport(),\n\t\t\t...config,\n\t\t};\n\t\t@Module({\n\t\t\tproviders: [\n\t\t\t\tMailService,\n\t\t\t\t{ provide: MailService.TOKEN, useExisting: MailService },\n\t\t\t\t{ provide: \"MAIL_CONFIG\", useValue: cfg },\n\t\t\t],\n\t\t\texports: [MailService, MailService.TOKEN],\n\t\t})\n\t\tclass ConfiguredMailModule {}\n\t\tObject.defineProperty(ConfiguredMailModule, \"name\", {\n\t\t\tvalue: \"ConfiguredMailModule\",\n\t\t});\n\t\treturn ConfiguredMailModule;\n\t}\n}\n"
11
10
  ],
12
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA;;ACbO,MAAM,cAAuC;AAAA,EAC1C,OAAO;AAAA,EAEhB,OAAsB,CAAC;AAAA,OAEjB,KAAI,CAAC,KAA2C;AAAA,IACrD,KAAK,KAAK,KAAK,GAAG;AAAA,IAClB,OAAO;AAAA,MACN,IAAI,QAAQ,KAAK,IAAI,KAAK,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,CAAC;AAAA,MAC/D,QAAQ,KAAK,IAAI;AAAA,IAClB;AAAA;AAEF;;ACXA;AACA;AAAA;AAYO,MAAM,cAAuC;AAAA,EAC1C,OAAO;AAAA,EACR;AAAA,EAER,WAAW,CAAC,MAA4B;AAAA,IACvC,KAAK,OAAO;AAAA,MACX,KAAK,KAAK;AAAA,MACV,gBAAgB,KAAK,kBAAkB;AAAA,MACvC,QAAQ,KAAK,UAAU;AAAA,IACxB;AAAA;AAAA,OAGK,KAAI,CAAC,KAA2C;AAAA,IACrD,MAAM,MAAM,KAAK,KAAK,KAAK,EAAE,WAAW,KAAK,CAAC;AAAA,IAC9C,MAAM,KAAK,GAAG,KAAK,IAAI,KAAK,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,CAAC;AAAA,IACjE,MAAM,WAAW,GAAG;AAAA,IACpB,MAAM,OAAO,KAAK,KAAK,iBAAiB,KAAK,MAAM,GAAG,IAAI,KAAK,OAAO,G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ACvC,MAAM,MAAkB;AAAA,MACvB,WAAW,IAAI;AAAA,SACZ;AAAA,IACJ;AAAA;AAAA,IASA,MAAM,qBAAqB;AAAA,IAAC;AAAA,IAAtB,uBAAN;AAAA,MARC,OAAO;AAAA,QACP,WAAW;AAAA,UACV;AAAA,UACA,EAAE,SAAS,YAAY,OAAO,aAAa,YAAY;AAAA,UACvD,EAAE,SAAS,eAAe,UAAU,IAAI;AAAA,QACzC;AAAA,QACA,SAAS,CAAC,aAAa,YAAY,KAAK;AAAA,MACzC,CAAC;AAAA,OACK;AAAA,IACN,OAAO,eAAe,sBAAsB,QAAQ;AAAA,MACnD,OAAO;AAAA,IACR,CAAC;AAAA,IACD,OAAO;AAAA;AAET;AApBa,aAAN;AAAA,EAPN,OAAO;AAAA,IACP,WAAW;AAAA,MACV;AAAA,MACA,EAAE,SAAS,YAAY,OAAO,aAAa,YAAY;AAAA,IACxD;AAAA,IACA,SAAS,CAAC,aAAa,YAAY,KAAK;AAAA,EACzC,CAAC;AAAA,GACY;",
12
+ "debugId": "07D20E8117E7E46E64756E2164756E21",
14
13
  "names": []
15
14
  }
@@ -1,17 +1,3 @@
1
- /**
2
- * `MailModule` — drop-in mail.
3
- *
4
- * @Module({
5
- * imports: [
6
- * MailModule.forRoot({
7
- * transport: new SmtpTransport({ host: 'smtp.example.com' }),
8
- * defaultFrom: 'no-reply@example.com',
9
- * }),
10
- * ],
11
- * })
12
- * export class AppModule {}
13
- */
14
- import "reflect-metadata";
15
1
  import type { MailConfig } from "./types.js";
16
2
  export declare class MailModule {
17
3
  static forRoot(config?: MailConfig): {
package/dist/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  /**
2
+ import { safeGetMeta, safeDefineMeta, safeHasMeta } from "@nexusts/core/di/safe-reflect";
2
3
  * `nexusjs/mail` — outbound email.
3
4
  *
4
5
  * const mail = new MailService({ transport: new SmtpTransport({ host: 'smtp.gmail.com' }) });
@@ -16,7 +17,6 @@
16
17
  *
17
18
  * mail.renderMjml('template', { name: 'Kim' }) // compile MJML to HTML
18
19
  */
19
- import "reflect-metadata";
20
20
  /** A single recipient. */
21
21
  export type MailAddress = string | {
22
22
  name?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexusts/mail",
3
- "version": "0.8.4",
3
+ "version": "0.9.0",
4
4
  "description": "Outbound email (SMTP / File / Null transports)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -26,7 +26,7 @@
26
26
  ],
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
- "@nexusts/core": "^0.8.4"
29
+ "@nexusts/core": "^0.9.0"
30
30
  },
31
31
  "repository": {
32
32
  "type": "git",