@nexusts/mail 0.9.6 → 0.9.8

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
@@ -25,11 +25,6 @@ var __legacyDecorateClassTS = function(decorators, target, key, desc) {
25
25
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
26
26
  return c > 3 && r && Object.defineProperty(target, key, r), r;
27
27
  };
28
- var __legacyDecorateParamTS = (index, decorator) => (target, key) => decorator(target, key, index);
29
- var __legacyMetadataTS = (k, v) => {
30
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
31
- return Reflect.metadata(k, v);
32
- };
33
28
  var __require = import.meta.require;
34
29
  // packages/mail/src/transports/null.ts
35
30
  class NullTransport {
@@ -172,15 +167,33 @@ class SmtpTransport {
172
167
  import { Inject, Injectable } from "@nexusts/core";
173
168
  class MailService {
174
169
  static TOKEN = Symbol.for("nexus:MailService");
175
- transport;
176
- defaultFrom;
177
- constructor(config = {}) {
178
- this.transport = config.transport ?? new NullTransport;
179
- this.defaultFrom = config.defaultFrom;
170
+ _transport = null;
171
+ _defaultFrom = undefined;
172
+ init() {
173
+ if (this._transport)
174
+ return;
175
+ const cfg = this.config ?? {};
176
+ this._transport = cfg.transport ?? new NullTransport;
177
+ this._defaultFrom = cfg.defaultFrom;
178
+ }
179
+ get transport() {
180
+ this.init();
181
+ return this._transport;
182
+ }
183
+ set transport(v) {
184
+ this._transport = v;
185
+ }
186
+ get defaultFrom() {
187
+ this.init();
188
+ return this._defaultFrom;
189
+ }
190
+ set defaultFrom(v) {
191
+ this._defaultFrom = v;
180
192
  }
181
193
  async send(msg) {
182
- const full = { ...msg, from: msg.from ?? this.defaultFrom };
183
- return this.transport.send(full);
194
+ this.init();
195
+ const full = { ...msg, from: msg.from ?? this._defaultFrom };
196
+ return this._transport.send(full);
184
197
  }
185
198
  async sendBatch(msg, recipients) {
186
199
  const results = [];
@@ -199,12 +212,11 @@ class MailService {
199
212
  }
200
213
  }
201
214
  }
215
+ __legacyDecorateClassTS([
216
+ Inject("MAIL_CONFIG")
217
+ ], MailService.prototype, "config", undefined);
202
218
  MailService = __legacyDecorateClassTS([
203
- Injectable(),
204
- __legacyDecorateParamTS(0, Inject("MAIL_CONFIG")),
205
- __legacyMetadataTS("design:paramtypes", [
206
- typeof MailConfig === "undefined" ? Object : MailConfig
207
- ])
219
+ Injectable()
208
220
  ], MailService);
209
221
  // packages/mail/src/mail.module.ts
210
222
  import { Module } from "@nexusts/core";
@@ -250,5 +262,5 @@ export {
250
262
  FileTransport
251
263
  };
252
264
 
253
- //# debugId=07D20E8117E7E46E64756E2164756E21
265
+ //# debugId=C368BFBE13D13D3764756E2164756E21
254
266
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -5,10 +5,10 @@
5
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",
6
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",
7
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",
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",
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"
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\t/** Mail config — injected by DI container. */\n\t@Inject(\"MAIL_CONFIG\") declare private config: MailConfig;\n\n\tprivate _transport: MailTransport | null = null;\n\tprivate _defaultFrom: MailConfig[\"defaultFrom\"] = undefined;\n\n\tprivate init(): void {\n\t\tif (this._transport) return;\n\t\tconst cfg = this.config ?? {};\n\t\tthis._transport = cfg.transport ?? new NullTransport();\n\t\tthis._defaultFrom = cfg.defaultFrom;\n\t}\n\n\tget transport(): MailTransport {\n\t\tthis.init();\n\t\treturn this._transport!;\n\t}\n\tset transport(v: MailTransport) { this._transport = v; }\n\n\tget defaultFrom(): MailConfig[\"defaultFrom\"] { this.init(); return this._defaultFrom; }\n\tset defaultFrom(v: MailConfig[\"defaultFrom\"]) { this._defaultFrom = v; }\n\n\t/** Send a single message. */\n\tasync send(msg: MailMessage): Promise<MailSendResult> {\n\t\tthis.init();\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",
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\";\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})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AAA;AAGH;AApDwC;AAAA,EAAtC,OAAO,aAAa;AAAA,GALT,YAK2B;AAL3B,cAAN;AAAA,EADN,WAAW;AAAA,GACC;;ACLb;AAYO,MAAM,WAAW;AAAA,SAChB,OAAO,CAAC,SAAqB,CAAC,GAAG;AAAA,IACvC,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": "C368BFBE13D13D3764756E2164756E21",
13
13
  "names": []
14
14
  }
@@ -2,9 +2,15 @@ import type { MailConfig, MailMessage, MailSendResult, MailTransport } from "./t
2
2
  export declare class MailService {
3
3
  /** DI token. */
4
4
  static readonly TOKEN: unique symbol;
5
- transport: MailTransport;
6
- defaultFrom?: MailConfig["defaultFrom"];
7
- constructor(config?: MailConfig);
5
+ /** Mail config — injected by DI container. */
6
+ private config;
7
+ private _transport;
8
+ private _defaultFrom;
9
+ private init;
10
+ get transport(): MailTransport;
11
+ set transport(v: MailTransport);
12
+ get defaultFrom(): MailConfig["defaultFrom"];
13
+ set defaultFrom(v: MailConfig["defaultFrom"]);
8
14
  /** Send a single message. */
9
15
  send(msg: MailMessage): Promise<MailSendResult>;
10
16
  /** Send the same message to many recipients (one envelope per call). */
package/dist/types.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  /**
2
- import { safeGetMeta, safeDefineMeta, safeHasMeta } from "@nexusts/core/di/safe-reflect";
3
2
  * `@nexusts/mail` — outbound email.
4
3
  *
5
4
  * const mail = new MailService({ transport: new SmtpTransport({ host: 'smtp.gmail.com' }) });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexusts/mail",
3
- "version": "0.9.6",
3
+ "version": "0.9.8",
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.9.6"
29
+ "@nexusts/core": "^0.9.8"
30
30
  },
31
31
  "repository": {
32
32
  "type": "git",