@travetto/email-nodemailer 8.0.0-alpha.21 → 8.0.0-alpha.22

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 CHANGED
@@ -57,7 +57,7 @@ class Config {
57
57
  SES: {
58
58
  sesClient: new SESv2Client(),
59
59
  SendEmailCommand
60
- },
60
+ }
61
61
  });
62
62
  }
63
63
  }
package/__index__.ts CHANGED
@@ -1 +1 @@
1
- export * from './src/nodemailer.ts';
1
+ export * from './src/nodemailer.ts';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/email-nodemailer",
3
- "version": "8.0.0-alpha.21",
3
+ "version": "8.0.0-alpha.22",
4
4
  "type": "module",
5
5
  "description": "Email transmission module.",
6
6
  "keywords": [
@@ -25,7 +25,7 @@
25
25
  "directory": "module/email-nodemailer"
26
26
  },
27
27
  "dependencies": {
28
- "@travetto/email": "^8.0.0-alpha.21",
28
+ "@travetto/email": "^8.0.0-alpha.22",
29
29
  "@types/nodemailer": "^8.0.1",
30
30
  "nodemailer": "^9.0.3"
31
31
  },
package/src/nodemailer.ts CHANGED
@@ -2,12 +2,12 @@ import type { Readable } from 'node:stream';
2
2
 
3
3
  import { createTransport, type Transporter, type Transport as TransportType } from 'nodemailer';
4
4
  import type json from 'nodemailer/lib/json-transport';
5
- import type smtp from 'nodemailer/lib/smtp-transport';
6
- import type ses from 'nodemailer/lib/ses-transport';
7
5
  import type sendmail from 'nodemailer/lib/sendmail-transport';
6
+ import type ses from 'nodemailer/lib/ses-transport';
7
+ import type smtp from 'nodemailer/lib/smtp-transport';
8
8
 
9
- import { type MailTransport, type EmailOptions, type SentEmail } from '@travetto/email';
10
- import { BinaryUtil, castTo, CodecUtil } from '@travetto/runtime';
9
+ import type { EmailOptions, MailTransport, SentEmail } from '@travetto/email';
10
+ import { BinaryUtil, CodecUtil, castTo } from '@travetto/runtime';
11
11
 
12
12
  type Transport = TransportType | json.Options | smtp.Options | ses.Options | sendmail.Options;
13
13
 
@@ -15,13 +15,15 @@ type Transport = TransportType | json.Options | smtp.Options | ses.Options | sen
15
15
  * Nodemailer transport, takes in a transport factory as the input
16
16
  */
17
17
  export class NodemailerTransport implements MailTransport {
18
- #transport: Transporter<SentEmail & {
19
- rejected?: unknown[];
20
- }>;
18
+ #transport: Transporter<
19
+ SentEmail & {
20
+ rejected?: unknown[];
21
+ }
22
+ >;
21
23
 
22
24
  /**
23
- * Enforce attachment content is a buffer or stream, converting from string or binary array if needed
24
- */
25
+ * Enforce attachment content is a buffer or stream, converting from string or binary array if needed
26
+ */
25
27
  #enforceAttachmentContent(message: EmailOptions): EmailOptions<Readable | Buffer> {
26
28
  for (const attachment of message.attachments ?? []) {
27
29
  if (attachment.content) {
@@ -41,7 +43,10 @@ export class NodemailerTransport implements MailTransport {
41
43
  * Force content into alternative slots
42
44
  */
43
45
  #forceContentToAlternative(message: EmailOptions): EmailOptions {
44
- for (const [key, mime] of [['text', 'text/plain'], ['html', 'text/html']] as const) {
46
+ for (const [key, mime] of [
47
+ ['text', 'text/plain'],
48
+ ['html', 'text/html']
49
+ ] as const) {
45
50
  if (message[key]) {
46
51
  (message.alternatives ??= []).push({
47
52
  content: message[key],
@@ -61,7 +66,6 @@ export class NodemailerTransport implements MailTransport {
61
66
  }
62
67
 
63
68
  async send<S extends SentEmail = SentEmail>(mail: EmailOptions): Promise<S> {
64
-
65
69
  const forced = this.#enforceAttachmentContent(this.#forceContentToAlternative(mail));
66
70
 
67
71
  const response = await this.#transport.sendMail(forced);
@@ -72,4 +76,4 @@ export class NodemailerTransport implements MailTransport {
72
76
 
73
77
  return castTo(response);
74
78
  }
75
- }
79
+ }