Skip to content

Commit 2cce560

Browse files
authored
chore: release v4.8.0 (#556)
1 parent eb2b233 commit 2cce560

File tree

4 files changed

+32
-5
lines changed

4 files changed

+32
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "resend",
3-
"version": "4.7.0",
3+
"version": "4.8.0",
44
"description": "Node.js library for the Resend API",
55
"main": "./dist/index.js",
66
"module": "./dist/index.mjs",

src/common/interfaces/email-api-options.interface.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
import type { Attachment } from '../../emails/interfaces/create-email-options.interface';
21
import type { Tag } from '../../interfaces';
32

3+
export interface EmailApiAttachment {
4+
content?: string | Buffer;
5+
filename?: string | false | undefined;
6+
path?: string;
7+
content_type?: string;
8+
inline_content_id?: string;
9+
}
10+
411
export interface EmailApiOptions {
512
from: string;
613
to: string | string[];
@@ -14,5 +21,5 @@ export interface EmailApiOptions {
1421
reply_to?: string | string[];
1522
scheduled_at?: string;
1623
tags?: Tag[];
17-
attachments?: Attachment[];
24+
attachments?: EmailApiAttachment[];
1825
}

src/common/utils/parse-email-to-api-options.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
import type { CreateEmailOptions } from '../../emails/interfaces/create-email-options.interface';
2-
import type { EmailApiOptions } from '../interfaces/email-api-options.interface';
2+
import type {
3+
EmailApiAttachment,
4+
EmailApiOptions,
5+
} from '../interfaces/email-api-options.interface';
6+
7+
function parseAttachments(
8+
attachments: CreateEmailOptions['attachments'],
9+
): EmailApiAttachment[] | undefined {
10+
return attachments?.map((attachment) => ({
11+
content: attachment.content,
12+
filename: attachment.filename,
13+
path: attachment.path,
14+
content_type: attachment.contentType,
15+
inline_content_id: attachment.inlineContentId,
16+
}));
17+
}
318

419
export function parseEmailToApiOptions(
520
email: CreateEmailOptions,
621
): EmailApiOptions {
722
return {
8-
attachments: email.attachments,
23+
attachments: parseAttachments(email.attachments),
924
bcc: email.bcc,
1025
cc: email.cc,
1126
from: email.from,

src/emails/interfaces/create-email-options.interface.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ export interface Attachment {
120120
path?: string;
121121
/** Optional content type for the attachment, if not set will be derived from the filename property */
122122
contentType?: string;
123+
/**
124+
* Optional content ID for the attachment, to be used as a reference in the HTML content.
125+
* If set, this attachment will be sent as an inline attachment and you can reference it in the HTML content using the `cid:` prefix.
126+
*/
127+
inlineContentId?: string;
123128
}
124129

125130
export type Tag = {

0 commit comments

Comments
 (0)