resend 0.14.1 → 0.15.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resend",
3
- "version": "0.14.1",
3
+ "version": "0.15.1",
4
4
  "description": "Node.js library for the Resend API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Emails = void 0;
13
+ const render_1 = require("@react-email/render");
13
14
  class Emails {
14
15
  constructor(resend) {
15
16
  this.resend = resend;
@@ -21,6 +22,10 @@ class Emails {
21
22
  }
22
23
  create(payload, options = {}) {
23
24
  return __awaiter(this, void 0, void 0, function* () {
25
+ if (payload.react) {
26
+ payload.html = (0, render_1.render)(payload.react);
27
+ delete payload.react;
28
+ }
24
29
  const data = yield this.resend.post('/emails', payload, options);
25
30
  return data;
26
31
  });
@@ -1,11 +1,16 @@
1
+ /// <reference types="node" />
2
+ import { ReactElement } from 'react';
1
3
  import { PostOptions } from '../../common/interfaces';
2
4
  export interface CreateEmailOptions {
5
+ attachments?: Attachment[];
3
6
  bcc?: string | string[];
4
7
  cc?: string | string[];
5
8
  from: string;
6
9
  html?: string;
10
+ react?: ReactElement;
7
11
  reply_to?: string | string[];
8
12
  subject: string;
13
+ tags?: Tag[];
9
14
  text?: string;
10
15
  to: string | string[];
11
16
  }
@@ -14,3 +19,13 @@ export interface CreateEmailRequestOptions extends PostOptions {
14
19
  export interface CreateEmailResponse {
15
20
  id: string;
16
21
  }
22
+ interface Attachment {
23
+ content?: string | Buffer;
24
+ filename?: string | false | undefined;
25
+ path?: string;
26
+ }
27
+ export type Tag = {
28
+ name: string;
29
+ value: string;
30
+ };
31
+ export {};
@@ -1,2 +1,2 @@
1
1
  export { Resend } from './resend';
2
- export { SendEmailResponse, EmailResponse, ErrorResponse, SendEmailData, } from './interfaces';
2
+ export { ErrorResponse } from './interfaces';
@@ -1,55 +1,3 @@
1
- /// <reference types="node" />
2
- import { ReactElement } from 'react';
3
- export interface SendEmailData {
4
- /** Sender email address. */
5
- from: string;
6
- /** Recipient email address. Max 50. */
7
- to: string | string[];
8
- /** Bcc recipient email address. Max 50. */
9
- bcc?: string | string[];
10
- /** Cc recipient email address. Max 50. */
11
- cc?: string | string[];
12
- /** Reply-to email address. Max 50. */
13
- reply_to?: string | string[];
14
- /** Email subject. */
15
- subject: string;
16
- /** The plain text version of the message. */
17
- text?: string;
18
- /** The HTML version of the message. */
19
- html?: string;
20
- /** The React version of the message. */
21
- react?: ReactElement;
22
- /** Attachments */
23
- attachments?: Attachment[];
24
- /** Email tags */
25
- tags?: Tag[];
26
- }
27
- interface Attachment {
28
- content?: string | Buffer;
29
- filename?: string | false | undefined;
30
- }
31
- export interface SendEmailRequest {
32
- /** Sender email address. */
33
- from: string;
34
- /** Recipient email address. Max 50. */
35
- to: string | string[];
36
- /** Bcc recipient email address. Max 50. */
37
- bcc?: string | string[];
38
- /** Cc recipient email address. Max 50. */
39
- cc?: string | string[];
40
- /** Reply-to email address. Max 50. */
41
- reply_to?: string | string[];
42
- /** Email subject. */
43
- subject: string;
44
- /** The HTML version of the message. */
45
- text?: string;
46
- /** The plain text version of the message. */
47
- html?: string;
48
- /** Attachments */
49
- attachments?: Attachment[];
50
- /** Email tags */
51
- tags?: Tag[];
52
- }
53
1
  export declare const RESEND_ERROR_CODES_BY_KEY: {
54
2
  readonly missing_required_fields: 422;
55
3
  readonly missing_api_key: 401;
@@ -62,10 +10,6 @@ export declare const RESEND_ERROR_CODES_BY_KEY: {
62
10
  type ValueOf<TObj> = TObj[keyof TObj];
63
11
  export type RESEND_ERROR_CODE_NUMBER = ValueOf<typeof RESEND_ERROR_CODES_BY_KEY>;
64
12
  export type RESEND_ERROR_CODE_KEY = keyof typeof RESEND_ERROR_CODES_BY_KEY;
65
- interface EmailResponse extends Pick<SendEmailRequest, 'to' | 'from'> {
66
- id: string;
67
- created_at: string;
68
- }
69
13
  interface ErrorResponse {
70
14
  error: {
71
15
  message: string;
@@ -73,8 +17,7 @@ interface ErrorResponse {
73
17
  type: RESEND_ERROR_CODE_KEY;
74
18
  };
75
19
  }
76
- export type SendEmailResponse = EmailResponse | ErrorResponse;
77
- export { EmailResponse, ErrorResponse };
20
+ export { ErrorResponse };
78
21
  export type Tag = {
79
22
  name: string;
80
23
  value: string;
@@ -1,9 +1,9 @@
1
1
  import { AxiosResponse } from 'axios';
2
- import { SendEmailData, SendEmailResponse } from './interfaces';
3
2
  import { GetOptions, PostOptions, PutOptions } from './common/interfaces';
4
3
  import { ApiKeys } from './api-keys/api-keys';
5
4
  import { Domains } from './domains/domains';
6
5
  import { Emails } from './emails/emails';
6
+ import { CreateEmailOptions, CreateEmailResponse } from './emails/interfaces';
7
7
  export declare class Resend {
8
8
  readonly key?: string | undefined;
9
9
  readonly baseUrl: string;
@@ -17,5 +17,5 @@ export declare class Resend {
17
17
  get<T>(path: string, options?: GetOptions): Promise<T>;
18
18
  put(path: string, entity: any, options?: PutOptions): Promise<AxiosResponse>;
19
19
  delete(path: string, query?: any): Promise<AxiosResponse>;
20
- sendEmail(data: SendEmailData): Promise<SendEmailResponse>;
20
+ sendEmail(data: CreateEmailOptions): Promise<CreateEmailResponse>;
21
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resend",
3
- "version": "0.14.1",
3
+ "version": "0.15.1",
4
4
  "description": "Node.js library for the Resend API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",