@guren/server 2.9.0 → 2.10.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.
Files changed (92) hide show
  1. package/dist/DocsViewerServiceProvider-qFCaeiUv.js +77 -0
  2. package/dist/Hash-CzrwKeDp.js +133 -0
  3. package/dist/HttpException-BkS3euNG.js +161 -0
  4. package/dist/Job-BVT813DO.js +441 -0
  5. package/dist/McpServiceProvider-BoAN-UcD.js +367 -0
  6. package/dist/MessageSigner-Bd25ZJAV.js +93 -0
  7. package/dist/Random-DbIJ22KQ.js +191 -0
  8. package/dist/address-D0Iq-XIH.js +20 -0
  9. package/dist/auth/index.js +2 -122
  10. package/dist/auth-C7sVmYgc.js +1954 -0
  11. package/dist/authorization/index.js +2 -38
  12. package/dist/authorization-Dbcuc5ZK.js +610 -0
  13. package/dist/broadcasting/index.js +2 -26
  14. package/dist/broadcasting-Dw-FhyjN.js +1055 -0
  15. package/dist/cache/index.js +2 -17
  16. package/dist/cache/types.d.ts +4 -4
  17. package/dist/cache-BYnZf2FR.js +812 -0
  18. package/dist/client-Dd7vLcqp.js +27 -0
  19. package/dist/console/Output.d.ts +18 -18
  20. package/dist/discovery/AutoDiscovery.d.ts +8 -0
  21. package/dist/encryption/index.js +5 -96
  22. package/dist/encryption-fOWQaKqX.js +250 -0
  23. package/dist/endpoint-D-20PiHY.js +46 -0
  24. package/dist/endpoint-D6GIqOpe.js +31 -0
  25. package/dist/errors-quJOkkCn.js +81 -0
  26. package/dist/events/index.js +2 -28
  27. package/dist/events-aIH_bWRx.js +410 -0
  28. package/dist/health/index.js +2 -24
  29. package/dist/health-VWdWXRwh.js +345 -0
  30. package/dist/hot-disposables-WsTX2ySN.js +281 -0
  31. package/dist/hot-reload/testing.d.ts +1 -1
  32. package/dist/http/Application.d.ts +0 -1
  33. package/dist/i18n/index.js +2 -30
  34. package/dist/i18n-mcWi7LCd.js +617 -0
  35. package/dist/index.js +7496 -7281
  36. package/dist/lambda/index.js +114 -71
  37. package/dist/logging/index.js +2 -24
  38. package/dist/logging-CPaRMuPP.js +518 -0
  39. package/dist/loopback-guard-D0Kc7-xc.js +224 -0
  40. package/dist/mail/index.js +2 -27
  41. package/dist/mail-DfEfSQEr.js +699 -0
  42. package/dist/mcp/index.js +2 -10
  43. package/dist/notifications/index.js +2 -33
  44. package/dist/notifications-BGqmUNZ8.js +759 -0
  45. package/dist/queue/index.js +3 -42
  46. package/dist/queue-CXrRK85G.js +948 -0
  47. package/dist/redis/index.js +672 -642
  48. package/dist/rolldown-runtime-8H4AJuhK.js +14 -0
  49. package/dist/runtime/index.js +474 -604
  50. package/dist/scheduling/index.js +2 -29
  51. package/dist/scheduling-CPiEdtQd.js +839 -0
  52. package/dist/storage/index.js +2 -15
  53. package/dist/storage-tWHMv2H_.js +841 -0
  54. package/dist/support/expiry.js +69 -12
  55. package/dist/trim-slashes-ZJ_VsY5s.js +25 -0
  56. package/dist/vite/index.js +118 -181
  57. package/dist/vite/plugin.d.ts +1 -1
  58. package/dist/vite-dev-server-CpCUqmiC.js +131 -0
  59. package/package.json +6 -5
  60. package/dist/DocsViewerServiceProvider-RUYDFBMW.js +0 -75
  61. package/dist/McpServiceProvider-SL7DUZ4G.js +0 -8
  62. package/dist/chunk-2SC566CD.js +0 -376
  63. package/dist/chunk-2V3YID4H.js +0 -20
  64. package/dist/chunk-3KV5X2FL.js +0 -31
  65. package/dist/chunk-63SKW5PS.js +0 -457
  66. package/dist/chunk-6J6B5KOB.js +0 -425
  67. package/dist/chunk-A5JJ7XTH.js +0 -24
  68. package/dist/chunk-AZOYI43J.js +0 -18
  69. package/dist/chunk-B5E5VBDI.js +0 -115
  70. package/dist/chunk-DAQKYKLH.js +0 -182
  71. package/dist/chunk-DRNPVBAA.js +0 -1002
  72. package/dist/chunk-EI5GYMAT.js +0 -853
  73. package/dist/chunk-H3B23O6T.js +0 -271
  74. package/dist/chunk-HPET6XY5.js +0 -853
  75. package/dist/chunk-HR2KZ3WL.js +0 -616
  76. package/dist/chunk-IOTWFHZU.js +0 -558
  77. package/dist/chunk-K6CUBJX6.js +0 -642
  78. package/dist/chunk-KTNJG7R7.js +0 -911
  79. package/dist/chunk-LAJQCSSF.js +0 -355
  80. package/dist/chunk-LHR6OHI7.js +0 -189
  81. package/dist/chunk-N7PLD7MB.js +0 -729
  82. package/dist/chunk-O5XIXGYM.js +0 -274
  83. package/dist/chunk-Q2P6YLRR.js +0 -24
  84. package/dist/chunk-QQKTH5KX.js +0 -114
  85. package/dist/chunk-SFQP6O52.js +0 -126
  86. package/dist/chunk-SQR7277M.js +0 -911
  87. package/dist/chunk-T2FFUU6J.js +0 -484
  88. package/dist/chunk-TVV5YNEC.js +0 -1842
  89. package/dist/chunk-UY3AZSYL.js +0 -14
  90. package/dist/chunk-V4DNC2ER.js +0 -114
  91. package/dist/chunk-YSOJKAAU.js +0 -427
  92. package/dist/errors-PUNHAFL2.js +0 -34
@@ -0,0 +1,699 @@
1
+ import { i as getQueueDriver, o as registerJob, t as Job } from "./Job-BVT813DO.js";
2
+ import { t as parseMailAddress } from "./address-D0Iq-XIH.js";
3
+ import nodemailer from "nodemailer";
4
+ //#region src/mail/transports/SmtpTransport.ts
5
+ /**
6
+ * Format email address for nodemailer.
7
+ */
8
+ function formatAddress(addr) {
9
+ if (addr.name) return `"${addr.name}" <${addr.email}>`;
10
+ return addr.email;
11
+ }
12
+ /**
13
+ * SMTP mail transport using Nodemailer.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const transport = new SmtpTransport({
18
+ * host: 'smtp.example.com',
19
+ * port: 587,
20
+ * auth: {
21
+ * user: 'user@example.com',
22
+ * pass: 'password',
23
+ * },
24
+ * })
25
+ *
26
+ * await transport.send({
27
+ * from: { email: 'sender@example.com' },
28
+ * to: [{ email: 'recipient@example.com' }],
29
+ * subject: 'Hello',
30
+ * text: 'Hello World!',
31
+ * })
32
+ * ```
33
+ */
34
+ var SmtpTransport = class {
35
+ name = "smtp";
36
+ transporter;
37
+ constructor(options) {
38
+ this.transporter = nodemailer.createTransport({
39
+ host: options.host,
40
+ port: options.port ?? 587,
41
+ secure: options.secure ?? false,
42
+ auth: options.auth,
43
+ pool: options.pool ?? true,
44
+ maxConnections: options.maxConnections ?? 5
45
+ });
46
+ }
47
+ /**
48
+ * Send an email via SMTP.
49
+ */
50
+ async send(message) {
51
+ try {
52
+ const mailOptions = {
53
+ from: message.from ? formatAddress(message.from) : void 0,
54
+ to: message.to.map(formatAddress).join(", "),
55
+ cc: message.cc?.map(formatAddress).join(", "),
56
+ bcc: message.bcc?.map(formatAddress).join(", "),
57
+ replyTo: message.replyTo ? formatAddress(message.replyTo) : void 0,
58
+ subject: message.subject,
59
+ text: message.text,
60
+ html: message.html,
61
+ attachments: message.attachments?.map((a) => ({
62
+ filename: a.filename,
63
+ content: a.content,
64
+ path: a.path,
65
+ contentType: a.contentType,
66
+ cid: a.cid
67
+ })),
68
+ headers: message.headers
69
+ };
70
+ const result = await this.transporter.sendMail(mailOptions);
71
+ return {
72
+ success: true,
73
+ messageId: result.messageId,
74
+ response: result.response
75
+ };
76
+ } catch (error) {
77
+ return {
78
+ success: false,
79
+ error: error instanceof Error ? error.message : String(error)
80
+ };
81
+ }
82
+ }
83
+ /**
84
+ * Verify SMTP connection.
85
+ */
86
+ async verify() {
87
+ try {
88
+ await this.transporter.verify();
89
+ return true;
90
+ } catch {
91
+ return false;
92
+ }
93
+ }
94
+ /**
95
+ * Close the transport.
96
+ */
97
+ close() {
98
+ this.transporter.close();
99
+ }
100
+ };
101
+ //#endregion
102
+ //#region src/mail/transports/ResendTransport.ts
103
+ /**
104
+ * Resend mail transport.
105
+ *
106
+ * @example
107
+ * ```ts
108
+ * const transport = new ResendTransport({
109
+ * apiKey: process.env.RESEND_API_KEY,
110
+ * })
111
+ *
112
+ * await transport.send({
113
+ * from: { email: 'sender@example.com' },
114
+ * to: [{ email: 'recipient@example.com' }],
115
+ * subject: 'Hello',
116
+ * html: '<p>Hello World!</p>',
117
+ * })
118
+ * ```
119
+ */
120
+ var ResendTransport = class {
121
+ name = "resend";
122
+ apiKey;
123
+ baseUrl = "https://api.resend.com";
124
+ constructor(options) {
125
+ this.apiKey = options.apiKey;
126
+ }
127
+ /**
128
+ * Format email address for Resend API.
129
+ */
130
+ formatAddress(addr) {
131
+ if (addr.name) return `${addr.name} <${addr.email}>`;
132
+ return addr.email;
133
+ }
134
+ /**
135
+ * Send an email via Resend API.
136
+ */
137
+ async send(message) {
138
+ try {
139
+ const payload = {
140
+ from: message.from ? this.formatAddress(message.from) : void 0,
141
+ to: message.to.map((a) => this.formatAddress(a)),
142
+ subject: message.subject
143
+ };
144
+ if (message.cc?.length) payload.cc = message.cc.map((a) => this.formatAddress(a));
145
+ if (message.bcc?.length) payload.bcc = message.bcc.map((a) => this.formatAddress(a));
146
+ if (message.replyTo) payload.reply_to = this.formatAddress(message.replyTo);
147
+ if (message.text) payload.text = message.text;
148
+ if (message.html) payload.html = message.html;
149
+ if (message.attachments?.length) payload.attachments = message.attachments.map((a) => ({
150
+ filename: a.filename,
151
+ content: a.content instanceof Buffer ? a.content.toString("base64") : a.content,
152
+ content_type: a.contentType
153
+ }));
154
+ if (message.headers) payload.headers = message.headers;
155
+ const response = await fetch(`${this.baseUrl}/emails`, {
156
+ method: "POST",
157
+ headers: {
158
+ "Content-Type": "application/json",
159
+ Authorization: `Bearer ${this.apiKey}`
160
+ },
161
+ body: JSON.stringify(payload)
162
+ });
163
+ if (!response.ok) return {
164
+ success: false,
165
+ error: (await response.json()).message || `HTTP ${response.status}`
166
+ };
167
+ const data = await response.json();
168
+ return {
169
+ success: true,
170
+ messageId: data.id,
171
+ response: `Message sent with ID: ${data.id}`
172
+ };
173
+ } catch (error) {
174
+ return {
175
+ success: false,
176
+ error: error instanceof Error ? error.message : String(error)
177
+ };
178
+ }
179
+ }
180
+ };
181
+ //#endregion
182
+ //#region src/mail/transports/MemoryTransport.ts
183
+ /**
184
+ * In-memory mail transport for testing.
185
+ *
186
+ * Stores all sent messages in memory for inspection.
187
+ *
188
+ * @example
189
+ * ```ts
190
+ * const transport = new MemoryTransport()
191
+ *
192
+ * await transport.send({
193
+ * from: { email: 'sender@example.com' },
194
+ * to: [{ email: 'recipient@example.com' }],
195
+ * subject: 'Hello',
196
+ * text: 'Hello World!',
197
+ * })
198
+ *
199
+ * // Inspect sent messages
200
+ * const messages = transport.getMessages()
201
+ * console.log(messages[0].subject) // 'Hello'
202
+ * ```
203
+ */
204
+ var MemoryTransport = class {
205
+ name = "memory";
206
+ messages = [];
207
+ simulateFailure;
208
+ failureMessage;
209
+ constructor(options = {}) {
210
+ this.simulateFailure = options.simulateFailure ?? false;
211
+ this.failureMessage = options.failureMessage ?? "Simulated email failure";
212
+ }
213
+ /**
214
+ * Send an email (stores in memory).
215
+ */
216
+ async send(message) {
217
+ if (this.simulateFailure) return {
218
+ success: false,
219
+ error: this.failureMessage
220
+ };
221
+ const messageId = `memory-${Date.now()}-${Math.random().toString(36).slice(2)}`;
222
+ this.messages.push({ ...message });
223
+ return {
224
+ success: true,
225
+ messageId,
226
+ response: "Message stored in memory"
227
+ };
228
+ }
229
+ /**
230
+ * Get all sent messages.
231
+ */
232
+ getMessages() {
233
+ return [...this.messages];
234
+ }
235
+ /**
236
+ * Get the last sent message.
237
+ */
238
+ getLastMessage() {
239
+ return this.messages[this.messages.length - 1];
240
+ }
241
+ /**
242
+ * Find messages by recipient email.
243
+ */
244
+ findByRecipient(email) {
245
+ return this.messages.filter((m) => m.to.some((addr) => addr.email.toLowerCase() === email.toLowerCase()));
246
+ }
247
+ /**
248
+ * Find messages by subject.
249
+ */
250
+ findBySubject(subject) {
251
+ return this.messages.filter((m) => m.subject.toLowerCase().includes(subject.toLowerCase()));
252
+ }
253
+ /**
254
+ * Check if any message was sent to a recipient.
255
+ */
256
+ hasSentTo(email) {
257
+ return this.findByRecipient(email).length > 0;
258
+ }
259
+ /**
260
+ * Check if any message was sent with a subject.
261
+ */
262
+ hasSentWithSubject(subject) {
263
+ return this.findBySubject(subject).length > 0;
264
+ }
265
+ /**
266
+ * Get the count of sent messages.
267
+ */
268
+ count() {
269
+ return this.messages.length;
270
+ }
271
+ /**
272
+ * Clear all stored messages.
273
+ */
274
+ clear() {
275
+ this.messages = [];
276
+ }
277
+ /**
278
+ * Set whether to simulate failures.
279
+ */
280
+ setSimulateFailure(simulate, message) {
281
+ this.simulateFailure = simulate;
282
+ if (message) this.failureMessage = message;
283
+ }
284
+ /**
285
+ * Assert that a message was sent to a recipient.
286
+ * Throws if no message was found.
287
+ */
288
+ assertSentTo(email) {
289
+ if (!this.hasSentTo(email)) throw new Error(`No email was sent to ${email}`);
290
+ }
291
+ /**
292
+ * Assert that a message was sent with a subject.
293
+ * Throws if no message was found.
294
+ */
295
+ assertSentWithSubject(subject) {
296
+ if (!this.hasSentWithSubject(subject)) throw new Error(`No email was sent with subject containing "${subject}"`);
297
+ }
298
+ /**
299
+ * Assert that exactly n messages were sent.
300
+ * Throws if count doesn't match.
301
+ */
302
+ assertSentCount(count) {
303
+ if (this.messages.length !== count) throw new Error(`Expected ${count} emails to be sent, but got ${this.messages.length}`);
304
+ }
305
+ };
306
+ //#endregion
307
+ //#region src/mail/transports/LogTransport.ts
308
+ /**
309
+ * Log mail transport: writes each email to the log instead of sending it.
310
+ * This is the development default (`MAIL_MAILER=log`) — every send succeeds
311
+ * and the full message is visible in the server output.
312
+ */
313
+ var LogTransport = class {
314
+ name = "log";
315
+ logger;
316
+ constructor(options = {}) {
317
+ this.logger = options.logger ?? console.log;
318
+ }
319
+ async send(message) {
320
+ const to = message.to.map((address) => address.email).join(", ");
321
+ const from = message.from ? message.from.email : "(default sender)";
322
+ const body = message.text ?? message.html ?? "";
323
+ this.logger([
324
+ "[mail] ------------------------------------------------------------",
325
+ `[mail] To: ${to}`,
326
+ `[mail] From: ${from}`,
327
+ `[mail] Subject: ${message.subject}`,
328
+ `[mail] ${body.split("\n").join("\n[mail] ")}`,
329
+ "[mail] ------------------------------------------------------------"
330
+ ].join("\n"));
331
+ return {
332
+ success: true,
333
+ messageId: `log-${Date.now()}-${Math.random().toString(36).slice(2)}`,
334
+ response: "Message written to log"
335
+ };
336
+ }
337
+ };
338
+ //#endregion
339
+ //#region src/mail/MailManager.ts
340
+ /**
341
+ * Mail manager for handling multiple transports.
342
+ *
343
+ * @example
344
+ * ```ts
345
+ * const mailManager = new MailManager({
346
+ * default: 'smtp',
347
+ * from: { email: 'noreply@example.com', name: 'MyApp' },
348
+ * transports: {
349
+ * smtp: {
350
+ * driver: 'smtp',
351
+ * host: 'smtp.example.com',
352
+ * port: 587,
353
+ * auth: { user: 'user', pass: 'pass' },
354
+ * },
355
+ * resend: {
356
+ * driver: 'resend',
357
+ * apiKey: 'your-api-key',
358
+ * },
359
+ * },
360
+ * })
361
+ *
362
+ * // Get the default transport
363
+ * const transport = mailManager.transport()
364
+ *
365
+ * // Get a specific transport
366
+ * const resendTransport = mailManager.transport('resend')
367
+ * ```
368
+ */
369
+ var MailManager = class {
370
+ defaultTransportName;
371
+ defaultFrom;
372
+ transportFactories = /* @__PURE__ */ new Map();
373
+ resolvedTransports = /* @__PURE__ */ new Map();
374
+ constructor(config = {}) {
375
+ this.defaultTransportName = config.default ?? "smtp";
376
+ this.defaultFrom = config.from;
377
+ this.registerBuiltinDrivers();
378
+ if (config.transports) for (const [name, transportConfig] of Object.entries(config.transports)) this.registerTransportFromConfig(name, transportConfig);
379
+ }
380
+ /**
381
+ * Register built-in transport drivers.
382
+ */
383
+ registerBuiltinDrivers() {
384
+ this.registerDriverFactory("smtp", (options) => {
385
+ return new SmtpTransport(options);
386
+ });
387
+ this.registerDriverFactory("resend", (options) => {
388
+ return new ResendTransport(options);
389
+ });
390
+ this.registerDriverFactory("memory", (options) => {
391
+ return new MemoryTransport(options);
392
+ });
393
+ this.registerDriverFactory("log", (options) => {
394
+ return new LogTransport(options);
395
+ });
396
+ }
397
+ driverFactories = /* @__PURE__ */ new Map();
398
+ /**
399
+ * Register a driver factory.
400
+ */
401
+ registerDriverFactory(driver, factory) {
402
+ this.driverFactories.set(driver, factory);
403
+ }
404
+ /**
405
+ * Register a transport from configuration.
406
+ */
407
+ registerTransportFromConfig(name, config) {
408
+ const { driver, ...options } = config;
409
+ const factory = this.driverFactories.get(driver);
410
+ if (!factory) throw new Error(`Unknown mail driver: ${driver}`);
411
+ this.transportFactories.set(name, () => factory(options));
412
+ }
413
+ /**
414
+ * Get a mail transport by name.
415
+ * Returns the default transport if no name is specified.
416
+ */
417
+ transport(name) {
418
+ const transportName = name ?? this.defaultTransportName;
419
+ const cached = this.resolvedTransports.get(transportName);
420
+ if (cached) return cached;
421
+ const factory = this.transportFactories.get(transportName);
422
+ if (!factory) throw new Error(`Mail transport not found: ${transportName}`);
423
+ const transport = factory();
424
+ this.resolvedTransports.set(transportName, transport);
425
+ return transport;
426
+ }
427
+ /**
428
+ * Register a custom transport.
429
+ */
430
+ registerTransport(name, factory) {
431
+ this.transportFactories.set(name, factory);
432
+ this.resolvedTransports.delete(name);
433
+ }
434
+ /**
435
+ * Check if a transport is registered.
436
+ */
437
+ hasTransport(name) {
438
+ return this.transportFactories.has(name);
439
+ }
440
+ /**
441
+ * Get the default transport name.
442
+ */
443
+ getDefaultTransportName() {
444
+ return this.defaultTransportName;
445
+ }
446
+ /**
447
+ * Get the default from address.
448
+ */
449
+ getDefaultFrom() {
450
+ return this.defaultFrom;
451
+ }
452
+ /**
453
+ * Get all registered transport names.
454
+ */
455
+ getTransportNames() {
456
+ return Array.from(this.transportFactories.keys());
457
+ }
458
+ };
459
+ /**
460
+ * Create a mail manager with configuration.
461
+ */
462
+ function createMailManager(config) {
463
+ return new MailManager(config);
464
+ }
465
+ //#endregion
466
+ //#region src/mail/Mail.ts
467
+ /**
468
+ * Fluent mail builder for composing and sending emails.
469
+ *
470
+ * @example
471
+ * ```ts
472
+ * import { mail, createMailManager } from '@guren/server/mail'
473
+ *
474
+ * const manager = createMailManager({ ... })
475
+ *
476
+ * // Send a simple email
477
+ * await mail(manager)
478
+ * .to('user@example.com')
479
+ * .subject('Hello!')
480
+ * .text('Hello World!')
481
+ * .send()
482
+ *
483
+ * // Send an HTML email with template
484
+ * await mail(manager)
485
+ * .to('user@example.com')
486
+ * .subject('Welcome!')
487
+ * .html('<h1>Welcome to our app!</h1>')
488
+ * .attach({ filename: 'guide.pdf', path: './guide.pdf' })
489
+ * .send()
490
+ *
491
+ * // Queue the email for async sending
492
+ * await mail(manager)
493
+ * .to('user@example.com')
494
+ * .subject('Report')
495
+ * .html('<p>Your report is ready</p>')
496
+ * .queue('emails')
497
+ * ```
498
+ */
499
+ var Mail = class {
500
+ manager;
501
+ message = {
502
+ to: [],
503
+ cc: [],
504
+ bcc: [],
505
+ attachments: []
506
+ };
507
+ transportName;
508
+ constructor(manager) {
509
+ this.manager = manager;
510
+ const defaultFrom = manager.getDefaultFrom();
511
+ if (defaultFrom) this.message.from = defaultFrom;
512
+ }
513
+ /**
514
+ * Set the sender address.
515
+ */
516
+ from(address) {
517
+ this.message.from = parseMailAddress(address);
518
+ return this;
519
+ }
520
+ /**
521
+ * Add a recipient.
522
+ */
523
+ to(address) {
524
+ this.message.to.push(parseMailAddress(address));
525
+ return this;
526
+ }
527
+ /**
528
+ * Add multiple recipients.
529
+ */
530
+ toMany(addresses) {
531
+ for (const addr of addresses) this.to(addr);
532
+ return this;
533
+ }
534
+ /**
535
+ * Add a CC recipient.
536
+ */
537
+ cc(address) {
538
+ this.message.cc.push(parseMailAddress(address));
539
+ return this;
540
+ }
541
+ /**
542
+ * Add a BCC recipient.
543
+ */
544
+ bcc(address) {
545
+ this.message.bcc.push(parseMailAddress(address));
546
+ return this;
547
+ }
548
+ /**
549
+ * Set the reply-to address.
550
+ */
551
+ replyTo(address) {
552
+ this.message.replyTo = parseMailAddress(address);
553
+ return this;
554
+ }
555
+ /**
556
+ * Set the subject.
557
+ */
558
+ subject(subject) {
559
+ this.message.subject = subject;
560
+ return this;
561
+ }
562
+ /**
563
+ * Set the plain text body.
564
+ */
565
+ text(content) {
566
+ this.message.text = content;
567
+ return this;
568
+ }
569
+ /**
570
+ * Set the HTML body.
571
+ */
572
+ html(content) {
573
+ this.message.html = content;
574
+ return this;
575
+ }
576
+ /**
577
+ * Render a React component as HTML body.
578
+ * Requires @react-email/render to be installed.
579
+ *
580
+ * @param component - React component function
581
+ * @param props - Props to pass to the component
582
+ */
583
+ async template(component, props) {
584
+ try {
585
+ const html = await (await import(
586
+ /* @vite-ignore */
587
+ "@react-email/render"
588
+ )).render(component(props));
589
+ this.message.html = html;
590
+ } catch (error) {
591
+ throw new Error("Failed to render email template. Make sure @react-email/render is installed.");
592
+ }
593
+ return this;
594
+ }
595
+ /**
596
+ * Add an attachment.
597
+ */
598
+ attach(attachment) {
599
+ this.message.attachments.push(attachment);
600
+ return this;
601
+ }
602
+ /**
603
+ * Add a custom header.
604
+ * Rejects CR/LF characters to prevent SMTP header injection.
605
+ */
606
+ header(key, value) {
607
+ if (/[\r\n]/.test(key) || /[\r\n]/.test(value)) throw new Error("Mail: header names and values cannot contain newline characters.");
608
+ if (!this.message.headers) this.message.headers = {};
609
+ this.message.headers[key] = value;
610
+ return this;
611
+ }
612
+ /**
613
+ * Specify which transport to use.
614
+ */
615
+ via(transport) {
616
+ this.transportName = transport;
617
+ return this;
618
+ }
619
+ hasRunBuild = false;
620
+ runBuildOnce() {
621
+ if (this.hasRunBuild) return;
622
+ this.hasRunBuild = true;
623
+ this.build?.();
624
+ }
625
+ buildMessage() {
626
+ this.runBuildOnce();
627
+ if (!this.message.to || this.message.to.length === 0) throw new Error("Email must have at least one recipient");
628
+ if (!this.message.subject) throw new Error("Email must have a subject");
629
+ if (!this.message.text && !this.message.html) throw new Error("Email must have a text or html body");
630
+ return this.message;
631
+ }
632
+ /**
633
+ * Send the email immediately.
634
+ */
635
+ async send() {
636
+ const message = this.buildMessage();
637
+ return this.manager.transport(this.transportName).send(message);
638
+ }
639
+ /**
640
+ * Queue the email for async sending.
641
+ */
642
+ async queue(queueName = "default") {
643
+ if (!getQueueDriver()) throw new Error("Queue driver not configured. Use send() instead or configure a queue driver.");
644
+ const message = this.buildMessage();
645
+ registerJob(SendMailJob);
646
+ return SendMailJob.dispatch({
647
+ message,
648
+ transport: this.transportName ?? this.manager.getDefaultTransportName()
649
+ }, { queue: queueName });
650
+ }
651
+ };
652
+ /**
653
+ * Global mail manager reference for the job.
654
+ */
655
+ let globalMailManager = null;
656
+ /**
657
+ * Set the global mail manager for queue jobs.
658
+ */
659
+ function setMailManager(manager) {
660
+ globalMailManager = manager;
661
+ }
662
+ /**
663
+ * Get the global mail manager.
664
+ */
665
+ function getMailManager() {
666
+ return globalMailManager;
667
+ }
668
+ /**
669
+ * Job for sending emails via the queue.
670
+ */
671
+ var SendMailJob = class extends Job {
672
+ static jobName = "SendMailJob";
673
+ static queue = "default";
674
+ static maxAttempts = 3;
675
+ static backoff = "exponential";
676
+ async handle(payload) {
677
+ const manager = globalMailManager;
678
+ if (!manager) throw new Error("Mail manager not configured for queue jobs. Call setMailManager() first.");
679
+ const result = await manager.transport(payload.transport).send(payload.message);
680
+ if (!result.success) throw new Error(result.error ?? "Failed to send email");
681
+ }
682
+ };
683
+ /**
684
+ * Create a new mail builder.
685
+ *
686
+ * @example
687
+ * ```ts
688
+ * await mail(manager)
689
+ * .to('user@example.com')
690
+ * .subject('Hello')
691
+ * .text('Hello World!')
692
+ * .send()
693
+ * ```
694
+ */
695
+ function mail(manager) {
696
+ return new Mail(manager);
697
+ }
698
+ //#endregion
699
+ export { MailManager as a, MemoryTransport as c, setMailManager as i, ResendTransport as l, getMailManager as n, createMailManager as o, mail as r, LogTransport as s, Mail as t, SmtpTransport as u };
package/dist/mcp/index.js CHANGED
@@ -1,10 +1,2 @@
1
- import {
2
- McpServiceProvider,
3
- createMcpServer
4
- } from "../chunk-YSOJKAAU.js";
5
- import "../chunk-Q2P6YLRR.js";
6
- import "../chunk-LHR6OHI7.js";
7
- export {
8
- McpServiceProvider,
9
- createMcpServer
10
- };
1
+ import { r as createMcpServer, t as McpServiceProvider } from "../McpServiceProvider-BoAN-UcD.js";
2
+ export { McpServiceProvider, createMcpServer };