@impruthvi/nodemail 0.4.0 โ 0.5.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/README.md +123 -78
- package/dist/core/MailFacade.d.ts +42 -5
- package/dist/core/MailFacade.d.ts.map +1 -1
- package/dist/core/MailFacade.js +187 -4
- package/dist/core/MailFacade.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/testing/AssertableMessage.d.ts +40 -0
- package/dist/testing/AssertableMessage.d.ts.map +1 -0
- package/dist/testing/AssertableMessage.js +158 -0
- package/dist/testing/AssertableMessage.js.map +1 -0
- package/dist/testing/MailFake.d.ts +32 -0
- package/dist/testing/MailFake.d.ts.map +1 -0
- package/dist/testing/MailFake.js +155 -0
- package/dist/testing/MailFake.js.map +1 -0
- package/dist/testing/index.d.ts +4 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +8 -0
- package/dist/testing/index.js.map +1 -0
- package/examples/testing-example.ts +303 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,12 +3,10 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@impruthvi/nodemail)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
[](https://www.typescriptlang.org/)
|
|
6
|
-
[](https://github.com/impruthvi/nodemail)
|
|
7
7
|
[](https://github.com/impruthvi/nodemail)
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
**@impruthvi/nodemail** aims to bring the simplicity and elegance of Laravel's Mail system to the Node.js ecosystem with full TypeScript support.
|
|
9
|
+
**@impruthvi/nodemail** brings the simplicity and elegance of Laravel's Mail system to the Node.js ecosystem with full TypeScript support.
|
|
12
10
|
|
|
13
11
|
## ๐ฏ Vision
|
|
14
12
|
|
|
@@ -22,10 +20,11 @@ Inspired by [Laravel's Mail system](https://laravel.com/docs/mail).
|
|
|
22
20
|
|
|
23
21
|
## โจ Features
|
|
24
22
|
|
|
25
|
-
### โ
Available Now (v0.
|
|
23
|
+
### โ
Available Now (v0.5.0)
|
|
26
24
|
- ๐ฏ **Multiple Providers** - SMTP (Nodemailer), SendGrid, AWS SES, Mailgun, Resend, Postmark
|
|
27
25
|
- ๐จ **Template Engines** - Handlebars, EJS, Pug support with dynamic loading
|
|
28
26
|
- ๐ **Mailable Classes** - Reusable email definitions with template support
|
|
27
|
+
- ๐งช **Testing Utilities** - Mail::fake() for testing (Laravel-style assertions)
|
|
29
28
|
- ๐ชถ **Lightweight** - Only ~25MB with SMTP, install additional providers as needed
|
|
30
29
|
- ๐ **Type-Safe** - Full TypeScript support with strict typing
|
|
31
30
|
- โจ **Complete Fluent API** - Chain to(), subject(), html(), template(), data(), cc(), bcc(), attachments(), headers()
|
|
@@ -35,7 +34,6 @@ Inspired by [Laravel's Mail system](https://laravel.com/docs/mail).
|
|
|
35
34
|
### ๐ง Coming Soon
|
|
36
35
|
- ๐ **Notifications** - Multi-channel notification system
|
|
37
36
|
- ๐ **Markdown Mail** - Beautiful emails from markdown
|
|
38
|
-
- ๐งช **Testing Utilities** - Mail::fake() for testing
|
|
39
37
|
- ๐ฆ **Queue Support** - Background email sending (Bull/BullMQ)
|
|
40
38
|
- ๐ **i18n Support** - Multi-language emails
|
|
41
39
|
- ๐ **More Providers** - Mailtrap and others
|
|
@@ -43,12 +41,12 @@ Inspired by [Laravel's Mail system](https://laravel.com/docs/mail).
|
|
|
43
41
|
## ๐ฆ Installation
|
|
44
42
|
|
|
45
43
|
```bash
|
|
46
|
-
npm install @impruthvi/nodemail
|
|
44
|
+
npm install @impruthvi/nodemail
|
|
47
45
|
```
|
|
48
46
|
|
|
49
|
-
Or
|
|
47
|
+
Or install a specific version:
|
|
50
48
|
```bash
|
|
51
|
-
npm install @impruthvi/nodemail
|
|
49
|
+
npm install @impruthvi/nodemail@0.5.0
|
|
52
50
|
```
|
|
53
51
|
|
|
54
52
|
**Lightweight by default!** Only includes SMTP support (~25MB).
|
|
@@ -338,79 +336,109 @@ await Mail.to('user@example.com').send(new WelcomeEmail(user, 'My App'));
|
|
|
338
336
|
await new WelcomeEmail(user, 'My App').to('user@example.com').send();
|
|
339
337
|
```
|
|
340
338
|
|
|
341
|
-
|
|
339
|
+
## ๐งช Testing with Mail::fake()
|
|
342
340
|
|
|
343
|
-
|
|
344
|
-
import { Mail } from 'nodemail';
|
|
345
|
-
|
|
346
|
-
// Configure once
|
|
347
|
-
Mail.configure({
|
|
348
|
-
default: 'smtp',
|
|
349
|
-
from: {
|
|
350
|
-
address: 'noreply@example.com',
|
|
351
|
-
name: 'My App',
|
|
352
|
-
},
|
|
353
|
-
mailers: {
|
|
354
|
-
smtp: {
|
|
355
|
-
driver: 'smtp',
|
|
356
|
-
host: process.env.MAIL_HOST,
|
|
357
|
-
port: 587,
|
|
358
|
-
username: process.env.MAIL_USERNAME,
|
|
359
|
-
password: process.env.MAIL_PASSWORD,
|
|
360
|
-
},
|
|
361
|
-
},
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
// Send emails
|
|
365
|
-
await Mail.to('user@example.com')
|
|
366
|
-
.subject('Welcome!')
|
|
367
|
-
.html('<h1>Hello World!</h1>')
|
|
368
|
-
.send();
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
**Advanced usage (coming soon):**
|
|
341
|
+
Test your emails without actually sending them - just like Laravel's `Mail::fake()`:
|
|
372
342
|
|
|
373
343
|
```typescript
|
|
374
|
-
import { Mail } from 'nodemail';
|
|
375
|
-
|
|
376
|
-
// Configure once
|
|
377
|
-
Mail.configure({
|
|
378
|
-
default: 'smtp',
|
|
379
|
-
from: {
|
|
380
|
-
address: 'noreply@example.com',
|
|
381
|
-
name: 'My App',
|
|
382
|
-
},
|
|
383
|
-
mailers: {
|
|
384
|
-
smtp: {
|
|
385
|
-
driver: 'smtp',
|
|
386
|
-
host: process.env.MAIL_HOST,
|
|
387
|
-
port: 587,
|
|
388
|
-
username: process.env.MAIL_USERNAME,
|
|
389
|
-
password: process.env.MAIL_PASSWORD,
|
|
390
|
-
},
|
|
391
|
-
},
|
|
392
|
-
});
|
|
393
|
-
|
|
394
|
-
// Send anywhere in your app
|
|
395
|
-
await Mail.to('user@example.com')
|
|
396
|
-
.subject('Welcome!')
|
|
397
|
-
.html('<h1>Hello World!</h1>')
|
|
398
|
-
.send();
|
|
344
|
+
import { Mail, Mailable } from '@impruthvi/nodemail';
|
|
399
345
|
|
|
400
|
-
//
|
|
346
|
+
// Your Mailable class
|
|
401
347
|
class WelcomeEmail extends Mailable {
|
|
402
|
-
constructor(
|
|
348
|
+
constructor(public userName: string) {
|
|
403
349
|
super();
|
|
404
350
|
}
|
|
405
351
|
|
|
406
352
|
build() {
|
|
407
353
|
return this
|
|
408
|
-
.subject(`Welcome, ${this.
|
|
409
|
-
.
|
|
354
|
+
.subject(`Welcome, ${this.userName}!`)
|
|
355
|
+
.html(`<h1>Hello ${this.userName}!</h1>`);
|
|
410
356
|
}
|
|
411
357
|
}
|
|
412
358
|
|
|
413
|
-
|
|
359
|
+
// In your tests
|
|
360
|
+
describe('User Registration', () => {
|
|
361
|
+
beforeEach(() => {
|
|
362
|
+
Mail.fake(); // Enable fake mode
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
afterEach(() => {
|
|
366
|
+
Mail.restore(); // Restore real mailer
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
it('sends welcome email on registration', async () => {
|
|
370
|
+
// Your application code that sends email
|
|
371
|
+
await Mail.to('user@example.com').send(new WelcomeEmail('John'));
|
|
372
|
+
|
|
373
|
+
// Assert email was sent
|
|
374
|
+
Mail.assertSent(WelcomeEmail);
|
|
375
|
+
|
|
376
|
+
// Assert with conditions
|
|
377
|
+
Mail.assertSent(WelcomeEmail, (mail) => {
|
|
378
|
+
return mail.hasTo('user@example.com') &&
|
|
379
|
+
mail.subjectContains('Welcome');
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
// Assert sent count
|
|
383
|
+
Mail.assertSentCount(WelcomeEmail, 1);
|
|
384
|
+
|
|
385
|
+
// Assert other mailables were NOT sent
|
|
386
|
+
Mail.assertNotSent(PasswordResetEmail);
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
it('does not send email when validation fails', async () => {
|
|
390
|
+
// Code that doesn't send email
|
|
391
|
+
Mail.assertNothingSent();
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### Available Assertions
|
|
397
|
+
|
|
398
|
+
| Method | Description |
|
|
399
|
+
|--------|-------------|
|
|
400
|
+
| `Mail.fake()` | Enable fake mode (store emails instead of sending) |
|
|
401
|
+
| `Mail.restore()` | Restore real mailer |
|
|
402
|
+
| `Mail.assertSent(Mailable)` | Assert mailable was sent |
|
|
403
|
+
| `Mail.assertSent(Mailable, callback)` | Assert with custom conditions |
|
|
404
|
+
| `Mail.assertSentCount(Mailable, count)` | Assert sent exactly N times |
|
|
405
|
+
| `Mail.assertNotSent(Mailable)` | Assert mailable was NOT sent |
|
|
406
|
+
| `Mail.assertNothingSent()` | Assert no emails were sent |
|
|
407
|
+
| `Mail.assertQueued(Mailable)` | Assert mailable was queued |
|
|
408
|
+
| `Mail.assertNothingQueued()` | Assert nothing was queued |
|
|
409
|
+
| `Mail.sent()` | Get all sent messages |
|
|
410
|
+
| `Mail.sent(Mailable)` | Get sent messages of specific type |
|
|
411
|
+
|
|
412
|
+
### AssertableMessage Methods
|
|
413
|
+
|
|
414
|
+
When inspecting sent messages, you can use these helper methods:
|
|
415
|
+
|
|
416
|
+
```typescript
|
|
417
|
+
const sent = Mail.sent(WelcomeEmail)[0];
|
|
418
|
+
|
|
419
|
+
// Check recipients
|
|
420
|
+
sent.hasTo('user@example.com'); // Check TO
|
|
421
|
+
sent.hasCc('cc@example.com'); // Check CC
|
|
422
|
+
sent.hasBcc('bcc@example.com'); // Check BCC
|
|
423
|
+
|
|
424
|
+
// Check content
|
|
425
|
+
sent.hasSubject('Welcome!'); // Exact subject match
|
|
426
|
+
sent.subjectContains('Welcome'); // Subject contains
|
|
427
|
+
sent.htmlContains('Hello'); // HTML contains
|
|
428
|
+
sent.textContains('Hello'); // Plain text contains
|
|
429
|
+
|
|
430
|
+
// Check attachments
|
|
431
|
+
sent.hasAttachments(); // Has any attachments
|
|
432
|
+
sent.hasAttachment('file.pdf'); // Has specific attachment
|
|
433
|
+
|
|
434
|
+
// Check headers
|
|
435
|
+
sent.hasHeader('X-Custom'); // Has header
|
|
436
|
+
sent.hasHeader('X-Custom', 'value'); // Header with value
|
|
437
|
+
|
|
438
|
+
// Get values
|
|
439
|
+
sent.getTo(); // Get recipients array
|
|
440
|
+
sent.getSubject(); // Get subject
|
|
441
|
+
sent.getHtml(); // Get HTML content
|
|
414
442
|
```
|
|
415
443
|
|
|
416
444
|
## ๐ ๏ธ Current Status
|
|
@@ -428,20 +456,37 @@ await Mail.to('user@example.com').send(new WelcomeEmail(user));
|
|
|
428
456
|
- โ
SMTP Provider (nodemailer)
|
|
429
457
|
- โ
SendGrid Provider (@sendgrid/mail)
|
|
430
458
|
- โ
AWS SES Provider (@aws-sdk/client-ses)
|
|
431
|
-
- โ
Message builder with fluent API
|
|
459
|
+
- โ
Message builder with complete fluent API
|
|
432
460
|
- โ
Configuration system
|
|
433
461
|
- โ
Error handling & graceful degradation
|
|
434
|
-
- ๐ง Other providers (Mailgun, Resend, Postmark) - coming soon
|
|
435
462
|
|
|
436
|
-
**Phase 3:
|
|
437
|
-
-
|
|
438
|
-
-
|
|
463
|
+
**Phase 3: Additional Providers** โ
Complete
|
|
464
|
+
- โ
Mailgun Provider (mailgun.js)
|
|
465
|
+
- โ
Resend Provider (resend)
|
|
466
|
+
- โ
Postmark Provider (postmark)
|
|
467
|
+
- โ
Dynamic loading for all providers
|
|
468
|
+
- โ
Comprehensive provider tests
|
|
469
|
+
|
|
470
|
+
**Phase 4: Template Engines & Mailable** โ
Complete
|
|
471
|
+
- โ
Template engines (Handlebars, EJS, Pug)
|
|
472
|
+
- โ
Laravel-like Mailable classes with template support
|
|
473
|
+
- โ
Complete fluent API (cc, bcc, replyTo, attachments, headers)
|
|
474
|
+
- โ
Dynamic template loading with caching
|
|
475
|
+
|
|
476
|
+
**Phase 5: Testing Utilities** โ
Complete (v0.5.0)
|
|
477
|
+
- โ
Mail::fake() for testing
|
|
478
|
+
- โ
assertSent(), assertNotSent(), assertNothingSent()
|
|
479
|
+
- โ
assertQueued(), assertNothingQueued()
|
|
480
|
+
- โ
AssertableMessage with inspection methods
|
|
481
|
+
- โ
Comprehensive test suite (172 tests)
|
|
482
|
+
- โ
85%+ code coverage
|
|
483
|
+
|
|
484
|
+
**Phase 6: Advanced Features** ๐ง Coming Soon
|
|
439
485
|
- Queue integration (Bull/BullMQ)
|
|
440
|
-
- Template engines (Handlebars, EJS, Pug)
|
|
441
|
-
- Testing utilities (Mail::fake(), assertSent())
|
|
442
|
-
- Unit test coverage
|
|
443
486
|
- CLI tools
|
|
444
487
|
- Markdown mail support
|
|
488
|
+
- Multi-channel notifications
|
|
489
|
+
- i18n support
|
|
445
490
|
|
|
446
491
|
## ๐ค Contributing
|
|
447
492
|
|
|
@@ -504,7 +549,7 @@ Unlike other packages that bundle everything:
|
|
|
504
549
|
- **Type-Safe**: Full TypeScript support with strict typing
|
|
505
550
|
- **Developer-Friendly**: Clean, intuitive API
|
|
506
551
|
- **Production-Ready**: Built with best practices
|
|
507
|
-
- **Well-Tested**:
|
|
552
|
+
- **Well-Tested**: 172 passing tests with 85%+ coverage
|
|
508
553
|
|
|
509
554
|
## ๐ License
|
|
510
555
|
|
|
@@ -1,14 +1,51 @@
|
|
|
1
1
|
import { MailManager } from './MailManager';
|
|
2
|
-
import type { MailConfig } from '../types';
|
|
2
|
+
import type { MailConfig, MailOptions, MailResponse } from '../types';
|
|
3
|
+
import type { Mailable } from './Mailable';
|
|
4
|
+
import { MailFake } from '../testing/MailFake';
|
|
5
|
+
import type { AssertableMessage } from '../testing/AssertableMessage';
|
|
3
6
|
declare class MailFacade {
|
|
4
7
|
private static instance;
|
|
8
|
+
private static fakeInstance;
|
|
9
|
+
private static config;
|
|
5
10
|
static configure(config: MailConfig): void;
|
|
6
11
|
private static getInstance;
|
|
7
|
-
static
|
|
12
|
+
private static isFaking;
|
|
13
|
+
static to(address: string | string[]): FakeableMessageBuilder;
|
|
8
14
|
static mailer(name: string): MailManager;
|
|
9
|
-
static send(mailable:
|
|
10
|
-
static fake():
|
|
11
|
-
static
|
|
15
|
+
static send(mailable: Mailable): Promise<MailResponse>;
|
|
16
|
+
static fake(): MailFake;
|
|
17
|
+
static restore(): void;
|
|
18
|
+
static getFake(): MailFake | null;
|
|
19
|
+
static assertSent<T extends Mailable>(mailableClass: new (...args: unknown[]) => T, callback?: (message: AssertableMessage) => boolean): void;
|
|
20
|
+
static assertSentCount<T extends Mailable>(mailableClass: new (...args: unknown[]) => T, count: number): void;
|
|
21
|
+
static assertNotSent<T extends Mailable>(mailableClass: new (...args: unknown[]) => T, callback?: (message: AssertableMessage) => boolean): void;
|
|
22
|
+
static assertNothingSent(): void;
|
|
23
|
+
static assertQueued<T extends Mailable>(mailableClass: new (...args: unknown[]) => T, callback?: (message: AssertableMessage) => boolean): void;
|
|
24
|
+
static assertQueuedCount<T extends Mailable>(mailableClass: new (...args: unknown[]) => T, count: number): void;
|
|
25
|
+
static assertNotQueued<T extends Mailable>(mailableClass: new (...args: unknown[]) => T, callback?: (message: AssertableMessage) => boolean): void;
|
|
26
|
+
static assertNothingQueued(): void;
|
|
27
|
+
static sent<T extends Mailable>(mailableClass?: new (...args: unknown[]) => T): AssertableMessage[];
|
|
28
|
+
static queued<T extends Mailable>(mailableClass?: new (...args: unknown[]) => T): AssertableMessage[];
|
|
29
|
+
static hasSent(): boolean;
|
|
30
|
+
static hasQueued(): boolean;
|
|
31
|
+
}
|
|
32
|
+
declare class FakeableMessageBuilder {
|
|
33
|
+
private manager;
|
|
34
|
+
options: Partial<MailOptions>;
|
|
35
|
+
constructor(manager: MailManager | MailFake, to: string | string[]);
|
|
36
|
+
subject(subject: string): this;
|
|
37
|
+
html(html: string): this;
|
|
38
|
+
text(text: string): this;
|
|
39
|
+
from(from: string): this;
|
|
40
|
+
cc(cc: string | string[]): this;
|
|
41
|
+
bcc(bcc: string | string[]): this;
|
|
42
|
+
replyTo(replyTo: string): this;
|
|
43
|
+
attachments(attachments: import('../types').Attachment[]): this;
|
|
44
|
+
headers(headers: Record<string, string>): this;
|
|
45
|
+
template(template: string): this;
|
|
46
|
+
data(data: Record<string, unknown>): this;
|
|
47
|
+
send(mailable?: Mailable): Promise<MailResponse>;
|
|
48
|
+
queue(mailable?: Mailable): Promise<MailResponse>;
|
|
12
49
|
}
|
|
13
50
|
export { MailFacade as Mail };
|
|
14
51
|
//# sourceMappingURL=MailFacade.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MailFacade.d.ts","sourceRoot":"","sources":["../../src/core/MailFacade.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MailFacade.d.ts","sourceRoot":"","sources":["../../src/core/MailFacade.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEtE,cAAM,UAAU;IACd,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA4B;IACnD,OAAO,CAAC,MAAM,CAAC,YAAY,CAAyB;IACpD,OAAO,CAAC,MAAM,CAAC,MAAM,CAA2B;IAKhD,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAQ1C,O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AAM,GAAG,IAAI;IAK9B,WAAW,CAAC,WAAW,EAAE,OAAO,UAAU,EAAE,UAAU,EAAE,GAAG,IAAI;IAK/D,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAK9C,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAKhC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAKnC,IAAI,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC;IAwChD,KAAK,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC;CAqBxD;AAED,OAAO,EAAE,UAAU,IAAI,IAAI,EAAE,CAAC"}
|
package/dist/core/MailFacade.js
CHANGED
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Mail = void 0;
|
|
4
4
|
const MailManager_1 = require("./MailManager");
|
|
5
|
+
const MailFake_1 = require("../testing/MailFake");
|
|
5
6
|
class MailFacade {
|
|
6
7
|
static instance = null;
|
|
8
|
+
static fakeInstance = null;
|
|
9
|
+
static config = null;
|
|
7
10
|
static configure(config) {
|
|
11
|
+
this.config = config;
|
|
8
12
|
this.instance = new MailManager_1.MailManager(config);
|
|
9
13
|
}
|
|
10
14
|
static getInstance() {
|
|
@@ -13,22 +17,201 @@ class MailFacade {
|
|
|
13
17
|
}
|
|
14
18
|
return this.instance;
|
|
15
19
|
}
|
|
20
|
+
static isFaking() {
|
|
21
|
+
return this.fakeInstance !== null;
|
|
22
|
+
}
|
|
16
23
|
static to(address) {
|
|
17
|
-
|
|
24
|
+
if (this.isFaking()) {
|
|
25
|
+
return new FakeableMessageBuilder(this.fakeInstance, address);
|
|
26
|
+
}
|
|
27
|
+
return new FakeableMessageBuilder(this.getInstance(), address);
|
|
18
28
|
}
|
|
19
29
|
static mailer(name) {
|
|
20
30
|
return this.getInstance().mailer(name);
|
|
21
31
|
}
|
|
22
32
|
static async send(mailable) {
|
|
33
|
+
if (this.isFaking()) {
|
|
34
|
+
const options = mailable.getMailOptions();
|
|
35
|
+
return this.fakeInstance.send(options, mailable);
|
|
36
|
+
}
|
|
23
37
|
mailable.setMailManager(this.getInstance());
|
|
24
38
|
return mailable.send();
|
|
25
39
|
}
|
|
26
40
|
static fake() {
|
|
27
|
-
|
|
41
|
+
this.fakeInstance = new MailFake_1.MailFake(this.config || undefined);
|
|
42
|
+
return this.fakeInstance;
|
|
43
|
+
}
|
|
44
|
+
static restore() {
|
|
45
|
+
this.fakeInstance = null;
|
|
46
|
+
}
|
|
47
|
+
static getFake() {
|
|
48
|
+
return this.fakeInstance;
|
|
49
|
+
}
|
|
50
|
+
static assertSent(mailableClass, callback) {
|
|
51
|
+
if (!this.fakeInstance) {
|
|
52
|
+
throw new Error('Mail::fake() must be called before using assertions.');
|
|
53
|
+
}
|
|
54
|
+
this.fakeInstance.assertSent(mailableClass, callback);
|
|
55
|
+
}
|
|
56
|
+
static assertSentCount(mailableClass, count) {
|
|
57
|
+
if (!this.fakeInstance) {
|
|
58
|
+
throw new Error('Mail::fake() must be called before using assertions.');
|
|
59
|
+
}
|
|
60
|
+
this.fakeInstance.assertSentCount(mailableClass, count);
|
|
61
|
+
}
|
|
62
|
+
static assertNotSent(mailableClass, callback) {
|
|
63
|
+
if (!this.fakeInstance) {
|
|
64
|
+
throw new Error('Mail::fake() must be called before using assertions.');
|
|
65
|
+
}
|
|
66
|
+
this.fakeInstance.assertNotSent(mailableClass, callback);
|
|
67
|
+
}
|
|
68
|
+
static assertNothingSent() {
|
|
69
|
+
if (!this.fakeInstance) {
|
|
70
|
+
throw new Error('Mail::fake() must be called before using assertions.');
|
|
71
|
+
}
|
|
72
|
+
this.fakeInstance.assertNothingSent();
|
|
73
|
+
}
|
|
74
|
+
static assertQueued(mailableClass, callback) {
|
|
75
|
+
if (!this.fakeInstance) {
|
|
76
|
+
throw new Error('Mail::fake() must be called before using assertions.');
|
|
77
|
+
}
|
|
78
|
+
this.fakeInstance.assertQueued(mailableClass, callback);
|
|
79
|
+
}
|
|
80
|
+
static assertQueuedCount(mailableClass, count) {
|
|
81
|
+
if (!this.fakeInstance) {
|
|
82
|
+
throw new Error('Mail::fake() must be called before using assertions.');
|
|
83
|
+
}
|
|
84
|
+
this.fakeInstance.assertQueuedCount(mailableClass, count);
|
|
85
|
+
}
|
|
86
|
+
static assertNotQueued(mailableClass, callback) {
|
|
87
|
+
if (!this.fakeInstance) {
|
|
88
|
+
throw new Error('Mail::fake() must be called before using assertions.');
|
|
89
|
+
}
|
|
90
|
+
this.fakeInstance.assertNotQueued(mailableClass, callback);
|
|
91
|
+
}
|
|
92
|
+
static assertNothingQueued() {
|
|
93
|
+
if (!this.fakeInstance) {
|
|
94
|
+
throw new Error('Mail::fake() must be called before using assertions.');
|
|
95
|
+
}
|
|
96
|
+
this.fakeInstance.assertNothingQueued();
|
|
97
|
+
}
|
|
98
|
+
static sent(mailableClass) {
|
|
99
|
+
if (!this.fakeInstance) {
|
|
100
|
+
throw new Error('Mail::fake() must be called before using sent().');
|
|
101
|
+
}
|
|
102
|
+
return this.fakeInstance.sent(mailableClass);
|
|
103
|
+
}
|
|
104
|
+
static queued(mailableClass) {
|
|
105
|
+
if (!this.fakeInstance) {
|
|
106
|
+
throw new Error('Mail::fake() must be called before using queued().');
|
|
107
|
+
}
|
|
108
|
+
return this.fakeInstance.queued(mailableClass);
|
|
109
|
+
}
|
|
110
|
+
static hasSent() {
|
|
111
|
+
if (!this.fakeInstance) {
|
|
112
|
+
throw new Error('Mail::fake() must be called before using hasSent().');
|
|
113
|
+
}
|
|
114
|
+
return this.fakeInstance.hasSent();
|
|
28
115
|
}
|
|
29
|
-
static
|
|
30
|
-
|
|
116
|
+
static hasQueued() {
|
|
117
|
+
if (!this.fakeInstance) {
|
|
118
|
+
throw new Error('Mail::fake() must be called before using hasQueued().');
|
|
119
|
+
}
|
|
120
|
+
return this.fakeInstance.hasQueued();
|
|
31
121
|
}
|
|
32
122
|
}
|
|
33
123
|
exports.Mail = MailFacade;
|
|
124
|
+
class FakeableMessageBuilder {
|
|
125
|
+
manager;
|
|
126
|
+
options = {};
|
|
127
|
+
constructor(manager, to) {
|
|
128
|
+
this.manager = manager;
|
|
129
|
+
this.options.to = to;
|
|
130
|
+
}
|
|
131
|
+
subject(subject) {
|
|
132
|
+
this.options.subject = subject;
|
|
133
|
+
return this;
|
|
134
|
+
}
|
|
135
|
+
html(html) {
|
|
136
|
+
this.options.html = html;
|
|
137
|
+
return this;
|
|
138
|
+
}
|
|
139
|
+
text(text) {
|
|
140
|
+
this.options.text = text;
|
|
141
|
+
return this;
|
|
142
|
+
}
|
|
143
|
+
from(from) {
|
|
144
|
+
this.options.from = from;
|
|
145
|
+
return this;
|
|
146
|
+
}
|
|
147
|
+
cc(cc) {
|
|
148
|
+
this.options.cc = cc;
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
bcc(bcc) {
|
|
152
|
+
this.options.bcc = bcc;
|
|
153
|
+
return this;
|
|
154
|
+
}
|
|
155
|
+
replyTo(replyTo) {
|
|
156
|
+
this.options.replyTo = replyTo;
|
|
157
|
+
return this;
|
|
158
|
+
}
|
|
159
|
+
attachments(attachments) {
|
|
160
|
+
this.options.attachments = attachments;
|
|
161
|
+
return this;
|
|
162
|
+
}
|
|
163
|
+
headers(headers) {
|
|
164
|
+
this.options.headers = headers;
|
|
165
|
+
return this;
|
|
166
|
+
}
|
|
167
|
+
template(template) {
|
|
168
|
+
this.options.template = template;
|
|
169
|
+
return this;
|
|
170
|
+
}
|
|
171
|
+
data(data) {
|
|
172
|
+
this.options.data = data;
|
|
173
|
+
return this;
|
|
174
|
+
}
|
|
175
|
+
async send(mailable) {
|
|
176
|
+
if (this.manager instanceof MailFake_1.MailFake) {
|
|
177
|
+
if (mailable) {
|
|
178
|
+
const mailOptions = mailable.getMailOptions();
|
|
179
|
+
return this.manager.send({ ...mailOptions, to: this.options.to }, mailable);
|
|
180
|
+
}
|
|
181
|
+
if (!this.options.subject) {
|
|
182
|
+
throw new Error('Email subject is required');
|
|
183
|
+
}
|
|
184
|
+
return this.manager.send(this.options);
|
|
185
|
+
}
|
|
186
|
+
const realManager = this.manager;
|
|
187
|
+
if (!(realManager instanceof MailManager_1.MailManager)) {
|
|
188
|
+
throw new Error('Invalid mail manager');
|
|
189
|
+
}
|
|
190
|
+
if (mailable) {
|
|
191
|
+
mailable.setMailManager(realManager);
|
|
192
|
+
const mailOptions = mailable.getMailOptions();
|
|
193
|
+
return realManager.send({
|
|
194
|
+
...mailOptions,
|
|
195
|
+
to: this.options.to,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
if (!this.options.subject) {
|
|
199
|
+
throw new Error('Email subject is required');
|
|
200
|
+
}
|
|
201
|
+
return realManager.send(this.options);
|
|
202
|
+
}
|
|
203
|
+
async queue(mailable) {
|
|
204
|
+
if (this.manager instanceof MailFake_1.MailFake) {
|
|
205
|
+
if (mailable) {
|
|
206
|
+
const mailOptions = mailable.getMailOptions();
|
|
207
|
+
return this.manager.queue({ ...mailOptions, to: this.options.to }, mailable);
|
|
208
|
+
}
|
|
209
|
+
if (!this.options.subject) {
|
|
210
|
+
throw new Error('Email subject is required');
|
|
211
|
+
}
|
|
212
|
+
return this.manager.queue(this.options);
|
|
213
|
+
}
|
|
214
|
+
throw new Error('Queue functionality not yet implemented. Use Mail.fake() for testing queue assertions.');
|
|
215
|
+
}
|
|
216
|
+
}
|
|
34
217
|
//# sourceMappingURL=MailFacade.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MailFacade.js","sourceRoot":"","sources":["../../src/core/MailFacade.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"MailFacade.js","sourceRoot":"","sources":["../../src/core/MailFacade.ts"],"names":[],"mappings":";;;AAMA,+CAA4C;AAG5C,kDAA+C;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YAED,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;gBAC1B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;YAC/C,CAAC;YAED,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAsB,CAAC,CAAC;QACzD,CAAC;QAGD,MAAM,IAAI,KAAK,CAAC,wFAAwF,CAAC,CAAC;IAC5G,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export { ResendProvider } from './providers/ResendProvider';
|
|
|
10
10
|
export { PostmarkProvider } from './providers/PostmarkProvider';
|
|
11
11
|
export type { TemplateEngine, TemplateEngineOptions } from './templates';
|
|
12
12
|
export { HandlebarsEngine, EjsEngine, PugEngine } from './templates';
|
|
13
|
+
export { MailFake, AssertableMessage } from './testing';
|
|
14
|
+
export type { SentMessage } from './testing';
|
|
13
15
|
export * from './types';
|
|
14
|
-
export declare const VERSION = "0.
|
|
16
|
+
export declare const VERSION = "0.5.0";
|
|
15
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAGzC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,c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@@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.VERSION = exports.PugEngine = exports.EjsEngine = exports.HandlebarsEngine = exports.PostmarkProvider = exports.ResendProvider = exports.MailgunProvider = exports.SesProvider = exports.SendGridProvider = exports.SmtpProvider = exports.Message = exports.Mailable = exports.MailManager = exports.Mail = void 0;
|
|
17
|
+
exports.VERSION = exports.AssertableMessage = exports.MailFake = exports.PugEngine = exports.EjsEngine = exports.HandlebarsEngine = exports.PostmarkProvider = exports.ResendProvider = exports.MailgunProvider = exports.SesProvider = exports.SendGridProvider = exports.SmtpProvider = exports.Message = exports.Mailable = exports.MailManager = exports.Mail = void 0;
|
|
18
18
|
var MailFacade_1 = require("./core/MailFacade");
|
|
19
19
|
Object.defineProperty(exports, "Mail", { enumerable: true, get: function () { return MailFacade_1.Mail; } });
|
|
20
20
|
var MailManager_1 = require("./core/MailManager");
|
|
@@ -39,6 +39,9 @@ var templates_1 = require("./templates");
|
|
|
39
39
|
Object.defineProperty(exports, "HandlebarsEngine", { enumerable: true, get: function () { return templates_1.HandlebarsEngine; } });
|
|
40
40
|
Object.defineProperty(exports, "EjsEngine", { enumerable: true, get: function () { return templates_1.EjsEngine; } });
|
|
41
41
|
Object.defineProperty(exports, "PugEngine", { enumerable: true, get: function () { return templates_1.PugEngine; } });
|
|
42
|
+
var testing_1 = require("./testing");
|
|
43
|
+
Object.defineProperty(exports, "MailFake", { enumerable: true, get: function () { return testing_1.MailFake; } });
|
|
44
|
+
Object.defineProperty(exports, "AssertableMessage", { enumerable: true, get: function () { return testing_1.AssertableMessage; } });
|
|
42
45
|
__exportStar(require("./types"), exports);
|
|
43
|
-
exports.VERSION = '0.
|
|
46
|
+
exports.VERSION = '0.5.0';
|
|
44
47
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAKA,gDAAyC;AAAhC,kGAAA,IAAI,OAAA;AACb,kDAAiD;AAAxC,0GAAA,WAAW,OAAA;AACpB,4CAA2C;AAAlC,oGAAA,QAAQ,OAAA;AACjB,0CAAyC;AAAhC,kGAAA,OAAO,OAAA;AAGhB,yDAAwD;AAA/C,4GAAA,YAAY,OAAA;AACrB,iEAAgE;AAAvD,oHAAA,gBAAgB,OAAA;AACzB,uDAAsD;AAA7C,0GAAA,WAAW,OAAA;AACpB,+DAA8D;AAArD,kHAAA,eAAe,OAAA;AACxB,6DAA4D;AAAnD,gHAAA,cAAc,OAAA;AACvB,iEAAgE;AAAvD,oHAAA,gBAAgB,OAAA;AAIzB,yCAAqE;AAA5D,6GAAA,gBAAgB,OAAA;AAAE,sGAAA,SAAS,OAAA;AAAE,sGAAA,SAAS,OAAA;AAG/C,0CAAwB;AAGX,QAAA,OAAO,GAAG,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAKA,gDAAyC;AAAhC,kGAAA,IAAI,OAAA;AACb,kDAAiD;AAAxC,0GAAA,WAAW,OAAA;AACpB,4CAA2C;AAAlC,oGAAA,QAAQ,OAAA;AACjB,0CAAyC;AAAhC,kGAAA,OAAO,OAAA;AAGhB,yDAAwD;AAA/C,4GAAA,YAAY,OAAA;AACrB,iEAAgE;AAAvD,oHAAA,gBAAgB,OAAA;AACzB,uDAAsD;AAA7C,0GAAA,WAAW,OAAA;AACpB,+DAA8D;AAArD,kHAAA,eAAe,OAAA;AACxB,6DAA4D;AAAnD,gHAAA,cAAc,OAAA;AACvB,iEAAgE;AAAvD,oHAAA,gBAAgB,OAAA;AAIzB,yCAAqE;AAA5D,6GAAA,gBAAgB,OAAA;AAAE,sGAAA,SAAS,OAAA;AAAE,sGAAA,SAAS,OAAA;AAG/C,qCAAwD;AAA/C,mGAAA,QAAQ,OAAA;AAAE,4GAAA,iBAAiB,OAAA;AAIpC,0CAAwB;AAGX,QAAA,OAAO,GAAG,OAAO,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { MailOptions, Attachment } from '../types';
|
|
2
|
+
import type { Mailable } from '../core/Mailable';
|
|
3
|
+
export declare class AssertableMessage {
|
|
4
|
+
private readonly options;
|
|
5
|
+
private readonly mailable?;
|
|
6
|
+
constructor(options: MailOptions, mailable?: Mailable | undefined);
|
|
7
|
+
getOptions(): MailOptions;
|
|
8
|
+
getMailable(): Mailable | undefined;
|
|
9
|
+
hasTo(email: string): boolean;
|
|
10
|
+
hasCc(email: string): boolean;
|
|
11
|
+
hasBcc(email: string): boolean;
|
|
12
|
+
hasFrom(email: string): boolean;
|
|
13
|
+
hasSubject(subject: string): boolean;
|
|
14
|
+
subjectContains(text: string): boolean;
|
|
15
|
+
hasReplyTo(email: string): boolean;
|
|
16
|
+
hasHtml(): boolean;
|
|
17
|
+
htmlContains(text: string): boolean;
|
|
18
|
+
hasText(): boolean;
|
|
19
|
+
textContains(text: string): boolean;
|
|
20
|
+
hasAttachments(): boolean;
|
|
21
|
+
hasAttachment(filename: string): boolean;
|
|
22
|
+
getAttachments(): Attachment[];
|
|
23
|
+
hasHeader(name: string, value?: string): boolean;
|
|
24
|
+
getHeader(name: string): string | undefined;
|
|
25
|
+
hasTemplate(template: string): boolean;
|
|
26
|
+
hasData(key: string, value?: unknown): boolean;
|
|
27
|
+
getData(key: string): unknown;
|
|
28
|
+
getAllData(): Record<string, unknown> | undefined;
|
|
29
|
+
getTo(): string[];
|
|
30
|
+
getCc(): string[];
|
|
31
|
+
getBcc(): string[];
|
|
32
|
+
getSubject(): string;
|
|
33
|
+
getFrom(): string | undefined;
|
|
34
|
+
getHtml(): string | undefined;
|
|
35
|
+
getText(): string | undefined;
|
|
36
|
+
getTemplate(): string | undefined;
|
|
37
|
+
private hasRecipient;
|
|
38
|
+
private normalizeRecipients;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=AssertableMessage.d.ts.map
|