@travetto/email-nodemailer 5.0.0-rc.1 → 5.0.0-rc.11

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 (2) hide show
  1. package/package.json +3 -3
  2. package/src/nodemailer.ts +10 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/email-nodemailer",
3
- "version": "5.0.0-rc.1",
3
+ "version": "5.0.0-rc.11",
4
4
  "description": "Email transmission module.",
5
5
  "keywords": [
6
6
  "email",
@@ -24,12 +24,12 @@
24
24
  "directory": "module/email-nodemailer"
25
25
  },
26
26
  "dependencies": {
27
- "@travetto/email": "^5.0.0-rc.1",
27
+ "@travetto/email": "^5.0.0-rc.11",
28
28
  "@types/nodemailer": "^6.4.15",
29
29
  "nodemailer": "^6.9.14"
30
30
  },
31
31
  "devDependencies": {
32
- "@aws-sdk/client-ses": "^3.609.0"
32
+ "@aws-sdk/client-ses": "^3.631.0"
33
33
  },
34
34
  "travetto": {
35
35
  "displayName": "Email Nodemailer Support"
package/src/nodemailer.ts CHANGED
@@ -5,6 +5,7 @@ import type ses from 'nodemailer/lib/ses-transport';
5
5
  import type sendmail from 'nodemailer/lib/sendmail-transport';
6
6
 
7
7
  import { MailTransport, EmailOptions, SentEmail } from '@travetto/email';
8
+ import { castTo } from '@travetto/runtime';
8
9
 
9
10
  type Transport = TransportType | json.Options | smtp.Options | ses.Options | sendmail.Options;
10
11
 
@@ -12,7 +13,13 @@ type Transport = TransportType | json.Options | smtp.Options | ses.Options | sen
12
13
  * Nodemailer transport, takes in a transport factory as the input
13
14
  */
14
15
  export class NodemailerTransport implements MailTransport {
15
- #transport: Transporter;
16
+ #transport: Transporter<SentEmail & {
17
+ envelope?: Record<string, string>;
18
+ accepted?: string[];
19
+ rejected?: string[];
20
+ pending?: string[];
21
+ response?: string;
22
+ }>;
16
23
 
17
24
  /**
18
25
  * Force content into alternative slots
@@ -37,21 +44,12 @@ export class NodemailerTransport implements MailTransport {
37
44
 
38
45
  mail = this.#forceContentToAlternative(mail);
39
46
 
40
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
41
- const res = await this.#transport.sendMail(mail) as {
42
- messageId?: string;
43
- envelope?: Record<string, string>;
44
- accepted?: string[];
45
- rejected?: string[];
46
- pending?: string[];
47
- response?: string;
48
- };
47
+ const res = await this.#transport.sendMail(mail);
49
48
 
50
49
  if (res.rejected?.length) {
51
50
  console.error('Unable to send emails', { recipientCount: res.rejected?.length });
52
51
  }
53
52
 
54
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
55
- return res as S;
53
+ return castTo(res);
56
54
  }
57
55
  }