resend 4.0.1 → 4.1.0-alpha.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/dist/index.d.mts CHANGED
@@ -137,7 +137,7 @@ type RequireAtLeastOne<T> = {
137
137
  [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;
138
138
  }[keyof T];
139
139
 
140
- interface EmailRenderOptions {
140
+ interface EmailRenderOptions$1 {
141
141
  /**
142
142
  * The React component used to write the message.
143
143
  *
@@ -220,7 +220,7 @@ interface CreateEmailBaseOptions {
220
220
  */
221
221
  scheduledAt?: string;
222
222
  }
223
- type CreateEmailOptions = RequireAtLeastOne<EmailRenderOptions> & CreateEmailBaseOptions;
223
+ type CreateEmailOptions = RequireAtLeastOne<EmailRenderOptions$1> & CreateEmailBaseOptions;
224
224
  interface CreateEmailRequestOptions extends PostOptions {
225
225
  }
226
226
  interface CreateEmailResponseSuccess {
@@ -274,6 +274,106 @@ declare class Batch {
274
274
  create(payload: CreateBatchOptions, options?: CreateBatchRequestOptions): Promise<CreateBatchResponse>;
275
275
  }
276
276
 
277
+ interface EmailRenderOptions {
278
+ /**
279
+ * The React component used to write the message.
280
+ *
281
+ * @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
282
+ */
283
+ react: React.ReactNode;
284
+ /**
285
+ * The HTML version of the message.
286
+ *
287
+ * @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
288
+ */
289
+ html: string;
290
+ /**
291
+ * The plain text version of the message.
292
+ *
293
+ * @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
294
+ */
295
+ text: string;
296
+ }
297
+ interface CreateBroadcastBaseOptions {
298
+ /**
299
+ * The name of the broadcast
300
+ *
301
+ * @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
302
+ */
303
+ name?: string;
304
+ /**
305
+ * The id of the audience you want to send to
306
+ *
307
+ * @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
308
+ */
309
+ audienceId: string;
310
+ /**
311
+ * A short snippet of text displayed as a preview in recipients' inboxes, often shown below or beside the subject line.
312
+ *
313
+ * @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
314
+ */
315
+ previewText?: string;
316
+ /**
317
+ * Sender email address. To include a friendly name, use the format `"Your Name <sender@domain.com>"`
318
+ *
319
+ * @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
320
+ */
321
+ from: string;
322
+ /**
323
+ * Reply-to email address. For multiple addresses, send as an array of strings.
324
+ *
325
+ * @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
326
+ */
327
+ replyTo?: string | string[];
328
+ /**
329
+ * Email subject.
330
+ *
331
+ * @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
332
+ */
333
+ subject: string;
334
+ }
335
+ type CreateBroadcastOptions = RequireAtLeastOne<EmailRenderOptions> & CreateBroadcastBaseOptions;
336
+ interface CreateBroadcastRequestOptions extends PostOptions {
337
+ }
338
+ interface CreateBroadcastResponseSuccess {
339
+ /** The ID of the newly sent broadcasts. */
340
+ id: string;
341
+ }
342
+ interface CreateBroadcastResponse {
343
+ data: CreateBroadcastResponseSuccess | null;
344
+ error: ErrorResponse | null;
345
+ }
346
+
347
+ interface SendBroadcastBaseOptions {
348
+ /**
349
+ * Schedule email to be sent later.
350
+ * The date should be in ISO 8601 format (e.g: 2024-08-05T11:52:01.858Z)
351
+ * or relative time (eg: in 2 days).
352
+ *
353
+ * @link https://resend.com/docs/api-reference/broadcasts/send#body-parameters
354
+ */
355
+ scheduledAt?: string;
356
+ }
357
+ type SendBroadcastOptions = SendBroadcastBaseOptions;
358
+ interface SendBroadcastRequestOptions extends PostOptions {
359
+ }
360
+ interface SendBroadcastResponseSuccess {
361
+ /** The ID of the sent broadcast. */
362
+ id: string;
363
+ }
364
+ interface SendBroadcastResponse {
365
+ data: SendBroadcastResponseSuccess | null;
366
+ error: ErrorResponse | null;
367
+ }
368
+
369
+ declare class Broadcasts {
370
+ private readonly resend;
371
+ private renderAsync?;
372
+ constructor(resend: Resend);
373
+ create(payload: CreateBroadcastOptions, options?: CreateBroadcastRequestOptions): Promise<SendBroadcastResponse>;
374
+ send(id: string, payload: SendBroadcastOptions): Promise<SendBroadcastResponse>;
375
+ }
376
+
277
377
  interface PatchOptions {
278
378
  query?: {
279
379
  [key: string]: unknown;
@@ -547,6 +647,7 @@ declare class Resend {
547
647
  readonly apiKeys: ApiKeys;
548
648
  readonly audiences: Audiences;
549
649
  readonly batch: Batch;
650
+ readonly broadcasts: Broadcasts;
550
651
  readonly contacts: Contacts;
551
652
  readonly domains: Domains;
552
653
  readonly emails: Emails;
@@ -577,4 +678,4 @@ declare class Resend {
577
678
  }>;
578
679
  }
579
680
 
580
- export { CreateApiKeyOptions, CreateApiKeyRequestOptions, CreateApiKeyResponse, CreateApiKeyResponseSuccess, CreateAudienceOptions, CreateAudienceRequestOptions, CreateAudienceResponse, CreateAudienceResponseSuccess, CreateBatchOptions, CreateBatchRequestOptions, CreateBatchResponse, CreateBatchSuccessResponse, CreateContactOptions, CreateContactRequestOptions, CreateContactResponse, CreateContactResponseSuccess, CreateDomainOptions, CreateDomainRequestOptions, CreateDomainResponse, CreateDomainResponseSuccess, CreateEmailOptions, CreateEmailRequestOptions, CreateEmailResponse, CreateEmailResponseSuccess, ErrorResponse, GetAudienceResponse, GetAudienceResponseSuccess, GetContactOptions, GetContactResponse, GetContactResponseSuccess, GetDomainResponse, GetDomainResponseSuccess, GetEmailResponse, GetEmailResponseSuccess, ListApiKeysResponse, ListApiKeysResponseSuccess, ListAudiencesResponse, ListAudiencesResponseSuccess, ListContactsOptions, ListContactsResponse, ListContactsResponseSuccess, ListDomainsResponse, ListDomainsResponseSuccess, RemoveApiKeyResponse, RemoveApiKeyResponseSuccess, RemoveAudiencesResponse, RemoveAudiencesResponseSuccess, RemoveContactOptions, RemoveContactsResponse, RemoveContactsResponseSuccess, RemoveDomainsResponse, RemoveDomainsResponseSuccess, Resend, Tag, UpdateContactOptions, UpdateContactResponse, UpdateContactResponseSuccess, UpdateDomainsOptions, UpdateDomainsResponse, UpdateDomainsResponseSuccess, VerifyDomainsResponse, VerifyDomainsResponseSuccess };
681
+ export { CreateApiKeyOptions, CreateApiKeyRequestOptions, CreateApiKeyResponse, CreateApiKeyResponseSuccess, CreateAudienceOptions, CreateAudienceRequestOptions, CreateAudienceResponse, CreateAudienceResponseSuccess, CreateBatchOptions, CreateBatchRequestOptions, CreateBatchResponse, CreateBatchSuccessResponse, CreateBroadcastOptions, CreateBroadcastRequestOptions, CreateBroadcastResponse, CreateBroadcastResponseSuccess, CreateContactOptions, CreateContactRequestOptions, CreateContactResponse, CreateContactResponseSuccess, CreateDomainOptions, CreateDomainRequestOptions, CreateDomainResponse, CreateDomainResponseSuccess, CreateEmailOptions, CreateEmailRequestOptions, CreateEmailResponse, CreateEmailResponseSuccess, ErrorResponse, GetAudienceResponse, GetAudienceResponseSuccess, GetContactOptions, GetContactResponse, GetContactResponseSuccess, GetDomainResponse, GetDomainResponseSuccess, GetEmailResponse, GetEmailResponseSuccess, ListApiKeysResponse, ListApiKeysResponseSuccess, ListAudiencesResponse, ListAudiencesResponseSuccess, ListContactsOptions, ListContactsResponse, ListContactsResponseSuccess, ListDomainsResponse, ListDomainsResponseSuccess, RemoveApiKeyResponse, RemoveApiKeyResponseSuccess, RemoveAudiencesResponse, RemoveAudiencesResponseSuccess, RemoveContactOptions, RemoveContactsResponse, RemoveContactsResponseSuccess, RemoveDomainsResponse, RemoveDomainsResponseSuccess, Resend, SendBroadcastOptions, SendBroadcastRequestOptions, SendBroadcastResponse, SendBroadcastResponseSuccess, Tag, UpdateContactOptions, UpdateContactResponse, UpdateContactResponseSuccess, UpdateDomainsOptions, UpdateDomainsResponse, UpdateDomainsResponseSuccess, VerifyDomainsResponse, VerifyDomainsResponseSuccess };
package/dist/index.d.ts CHANGED
@@ -137,7 +137,7 @@ type RequireAtLeastOne<T> = {
137
137
  [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;
138
138
  }[keyof T];
139
139
 
140
- interface EmailRenderOptions {
140
+ interface EmailRenderOptions$1 {
141
141
  /**
142
142
  * The React component used to write the message.
143
143
  *
@@ -220,7 +220,7 @@ interface CreateEmailBaseOptions {
220
220
  */
221
221
  scheduledAt?: string;
222
222
  }
223
- type CreateEmailOptions = RequireAtLeastOne<EmailRenderOptions> & CreateEmailBaseOptions;
223
+ type CreateEmailOptions = RequireAtLeastOne<EmailRenderOptions$1> & CreateEmailBaseOptions;
224
224
  interface CreateEmailRequestOptions extends PostOptions {
225
225
  }
226
226
  interface CreateEmailResponseSuccess {
@@ -274,6 +274,106 @@ declare class Batch {
274
274
  create(payload: CreateBatchOptions, options?: CreateBatchRequestOptions): Promise<CreateBatchResponse>;
275
275
  }
276
276
 
277
+ interface EmailRenderOptions {
278
+ /**
279
+ * The React component used to write the message.
280
+ *
281
+ * @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
282
+ */
283
+ react: React.ReactNode;
284
+ /**
285
+ * The HTML version of the message.
286
+ *
287
+ * @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
288
+ */
289
+ html: string;
290
+ /**
291
+ * The plain text version of the message.
292
+ *
293
+ * @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
294
+ */
295
+ text: string;
296
+ }
297
+ interface CreateBroadcastBaseOptions {
298
+ /**
299
+ * The name of the broadcast
300
+ *
301
+ * @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
302
+ */
303
+ name?: string;
304
+ /**
305
+ * The id of the audience you want to send to
306
+ *
307
+ * @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
308
+ */
309
+ audienceId: string;
310
+ /**
311
+ * A short snippet of text displayed as a preview in recipients' inboxes, often shown below or beside the subject line.
312
+ *
313
+ * @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
314
+ */
315
+ previewText?: string;
316
+ /**
317
+ * Sender email address. To include a friendly name, use the format `"Your Name <sender@domain.com>"`
318
+ *
319
+ * @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
320
+ */
321
+ from: string;
322
+ /**
323
+ * Reply-to email address. For multiple addresses, send as an array of strings.
324
+ *
325
+ * @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
326
+ */
327
+ replyTo?: string | string[];
328
+ /**
329
+ * Email subject.
330
+ *
331
+ * @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
332
+ */
333
+ subject: string;
334
+ }
335
+ type CreateBroadcastOptions = RequireAtLeastOne<EmailRenderOptions> & CreateBroadcastBaseOptions;
336
+ interface CreateBroadcastRequestOptions extends PostOptions {
337
+ }
338
+ interface CreateBroadcastResponseSuccess {
339
+ /** The ID of the newly sent broadcasts. */
340
+ id: string;
341
+ }
342
+ interface CreateBroadcastResponse {
343
+ data: CreateBroadcastResponseSuccess | null;
344
+ error: ErrorResponse | null;
345
+ }
346
+
347
+ interface SendBroadcastBaseOptions {
348
+ /**
349
+ * Schedule email to be sent later.
350
+ * The date should be in ISO 8601 format (e.g: 2024-08-05T11:52:01.858Z)
351
+ * or relative time (eg: in 2 days).
352
+ *
353
+ * @link https://resend.com/docs/api-reference/broadcasts/send#body-parameters
354
+ */
355
+ scheduledAt?: string;
356
+ }
357
+ type SendBroadcastOptions = SendBroadcastBaseOptions;
358
+ interface SendBroadcastRequestOptions extends PostOptions {
359
+ }
360
+ interface SendBroadcastResponseSuccess {
361
+ /** The ID of the sent broadcast. */
362
+ id: string;
363
+ }
364
+ interface SendBroadcastResponse {
365
+ data: SendBroadcastResponseSuccess | null;
366
+ error: ErrorResponse | null;
367
+ }
368
+
369
+ declare class Broadcasts {
370
+ private readonly resend;
371
+ private renderAsync?;
372
+ constructor(resend: Resend);
373
+ create(payload: CreateBroadcastOptions, options?: CreateBroadcastRequestOptions): Promise<SendBroadcastResponse>;
374
+ send(id: string, payload: SendBroadcastOptions): Promise<SendBroadcastResponse>;
375
+ }
376
+
277
377
  interface PatchOptions {
278
378
  query?: {
279
379
  [key: string]: unknown;
@@ -547,6 +647,7 @@ declare class Resend {
547
647
  readonly apiKeys: ApiKeys;
548
648
  readonly audiences: Audiences;
549
649
  readonly batch: Batch;
650
+ readonly broadcasts: Broadcasts;
550
651
  readonly contacts: Contacts;
551
652
  readonly domains: Domains;
552
653
  readonly emails: Emails;
@@ -577,4 +678,4 @@ declare class Resend {
577
678
  }>;
578
679
  }
579
680
 
580
- export { CreateApiKeyOptions, CreateApiKeyRequestOptions, CreateApiKeyResponse, CreateApiKeyResponseSuccess, CreateAudienceOptions, CreateAudienceRequestOptions, CreateAudienceResponse, CreateAudienceResponseSuccess, CreateBatchOptions, CreateBatchRequestOptions, CreateBatchResponse, CreateBatchSuccessResponse, CreateContactOptions, CreateContactRequestOptions, CreateContactResponse, CreateContactResponseSuccess, CreateDomainOptions, CreateDomainRequestOptions, CreateDomainResponse, CreateDomainResponseSuccess, CreateEmailOptions, CreateEmailRequestOptions, CreateEmailResponse, CreateEmailResponseSuccess, ErrorResponse, GetAudienceResponse, GetAudienceResponseSuccess, GetContactOptions, GetContactResponse, GetContactResponseSuccess, GetDomainResponse, GetDomainResponseSuccess, GetEmailResponse, GetEmailResponseSuccess, ListApiKeysResponse, ListApiKeysResponseSuccess, ListAudiencesResponse, ListAudiencesResponseSuccess, ListContactsOptions, ListContactsResponse, ListContactsResponseSuccess, ListDomainsResponse, ListDomainsResponseSuccess, RemoveApiKeyResponse, RemoveApiKeyResponseSuccess, RemoveAudiencesResponse, RemoveAudiencesResponseSuccess, RemoveContactOptions, RemoveContactsResponse, RemoveContactsResponseSuccess, RemoveDomainsResponse, RemoveDomainsResponseSuccess, Resend, Tag, UpdateContactOptions, UpdateContactResponse, UpdateContactResponseSuccess, UpdateDomainsOptions, UpdateDomainsResponse, UpdateDomainsResponseSuccess, VerifyDomainsResponse, VerifyDomainsResponseSuccess };
681
+ export { CreateApiKeyOptions, CreateApiKeyRequestOptions, CreateApiKeyResponse, CreateApiKeyResponseSuccess, CreateAudienceOptions, CreateAudienceRequestOptions, CreateAudienceResponse, CreateAudienceResponseSuccess, CreateBatchOptions, CreateBatchRequestOptions, CreateBatchResponse, CreateBatchSuccessResponse, CreateBroadcastOptions, CreateBroadcastRequestOptions, CreateBroadcastResponse, CreateBroadcastResponseSuccess, CreateContactOptions, CreateContactRequestOptions, CreateContactResponse, CreateContactResponseSuccess, CreateDomainOptions, CreateDomainRequestOptions, CreateDomainResponse, CreateDomainResponseSuccess, CreateEmailOptions, CreateEmailRequestOptions, CreateEmailResponse, CreateEmailResponseSuccess, ErrorResponse, GetAudienceResponse, GetAudienceResponseSuccess, GetContactOptions, GetContactResponse, GetContactResponseSuccess, GetDomainResponse, GetDomainResponseSuccess, GetEmailResponse, GetEmailResponseSuccess, ListApiKeysResponse, ListApiKeysResponseSuccess, ListAudiencesResponse, ListAudiencesResponseSuccess, ListContactsOptions, ListContactsResponse, ListContactsResponseSuccess, ListDomainsResponse, ListDomainsResponseSuccess, RemoveApiKeyResponse, RemoveApiKeyResponseSuccess, RemoveAudiencesResponse, RemoveAudiencesResponseSuccess, RemoveContactOptions, RemoveContactsResponse, RemoveContactsResponseSuccess, RemoveDomainsResponse, RemoveDomainsResponseSuccess, Resend, SendBroadcastOptions, SendBroadcastRequestOptions, SendBroadcastResponse, SendBroadcastResponseSuccess, Tag, UpdateContactOptions, UpdateContactResponse, UpdateContactResponseSuccess, UpdateDomainsOptions, UpdateDomainsResponse, UpdateDomainsResponseSuccess, VerifyDomainsResponse, VerifyDomainsResponseSuccess };
package/dist/index.js CHANGED
@@ -72,7 +72,7 @@ __export(src_exports, {
72
72
  module.exports = __toCommonJS(src_exports);
73
73
 
74
74
  // package.json
75
- var version = "4.0.1";
75
+ var version = "4.1.0-alpha.0";
76
76
 
77
77
  // src/api-keys/api-keys.ts
78
78
  var ApiKeys = class {
@@ -182,6 +182,56 @@ var Batch = class {
182
182
  }
183
183
  };
184
184
 
185
+ // src/broadcasts/broadcasts.ts
186
+ var Broadcasts = class {
187
+ constructor(resend) {
188
+ this.resend = resend;
189
+ }
190
+ create(_0) {
191
+ return __async(this, arguments, function* (payload, options = {}) {
192
+ if (payload.react) {
193
+ if (!this.renderAsync) {
194
+ try {
195
+ const { renderAsync } = yield import("@react-email/render");
196
+ this.renderAsync = renderAsync;
197
+ } catch (error) {
198
+ throw new Error(
199
+ "Failed to render React component. Make sure to install `@react-email/render`"
200
+ );
201
+ }
202
+ }
203
+ payload.html = yield this.renderAsync(
204
+ payload.react
205
+ );
206
+ }
207
+ const data = yield this.resend.post(
208
+ "/broadcasts",
209
+ {
210
+ name: payload.name,
211
+ audience_id: payload.audienceId,
212
+ preview_text: payload.previewText,
213
+ from: payload.from,
214
+ html: payload.html,
215
+ reply_to: payload.replyTo,
216
+ subject: payload.subject,
217
+ text: payload.text
218
+ },
219
+ options
220
+ );
221
+ return data;
222
+ });
223
+ }
224
+ send(id, payload) {
225
+ return __async(this, null, function* () {
226
+ const data = yield this.resend.post(
227
+ `/broadcasts/${id}/send`,
228
+ { scheduled_at: payload.scheduledAt }
229
+ );
230
+ return data;
231
+ });
232
+ }
233
+ };
234
+
185
235
  // src/contacts/contacts.ts
186
236
  var Contacts = class {
187
237
  constructor(resend) {
@@ -389,6 +439,7 @@ var Resend = class {
389
439
  this.apiKeys = new ApiKeys(this);
390
440
  this.audiences = new Audiences(this);
391
441
  this.batch = new Batch(this);
442
+ this.broadcasts = new Broadcasts(this);
392
443
  this.contacts = new Contacts(this);
393
444
  this.domains = new Domains(this);
394
445
  this.emails = new Emails(this);
package/dist/index.mjs CHANGED
@@ -39,7 +39,7 @@ var __async = (__this, __arguments, generator) => {
39
39
  };
40
40
 
41
41
  // package.json
42
- var version = "4.0.1";
42
+ var version = "4.1.0-alpha.0";
43
43
 
44
44
  // src/api-keys/api-keys.ts
45
45
  var ApiKeys = class {
@@ -149,6 +149,56 @@ var Batch = class {
149
149
  }
150
150
  };
151
151
 
152
+ // src/broadcasts/broadcasts.ts
153
+ var Broadcasts = class {
154
+ constructor(resend) {
155
+ this.resend = resend;
156
+ }
157
+ create(_0) {
158
+ return __async(this, arguments, function* (payload, options = {}) {
159
+ if (payload.react) {
160
+ if (!this.renderAsync) {
161
+ try {
162
+ const { renderAsync } = yield import("@react-email/render");
163
+ this.renderAsync = renderAsync;
164
+ } catch (error) {
165
+ throw new Error(
166
+ "Failed to render React component. Make sure to install `@react-email/render`"
167
+ );
168
+ }
169
+ }
170
+ payload.html = yield this.renderAsync(
171
+ payload.react
172
+ );
173
+ }
174
+ const data = yield this.resend.post(
175
+ "/broadcasts",
176
+ {
177
+ name: payload.name,
178
+ audience_id: payload.audienceId,
179
+ preview_text: payload.previewText,
180
+ from: payload.from,
181
+ html: payload.html,
182
+ reply_to: payload.replyTo,
183
+ subject: payload.subject,
184
+ text: payload.text
185
+ },
186
+ options
187
+ );
188
+ return data;
189
+ });
190
+ }
191
+ send(id, payload) {
192
+ return __async(this, null, function* () {
193
+ const data = yield this.resend.post(
194
+ `/broadcasts/${id}/send`,
195
+ { scheduled_at: payload.scheduledAt }
196
+ );
197
+ return data;
198
+ });
199
+ }
200
+ };
201
+
152
202
  // src/contacts/contacts.ts
153
203
  var Contacts = class {
154
204
  constructor(resend) {
@@ -356,6 +406,7 @@ var Resend = class {
356
406
  this.apiKeys = new ApiKeys(this);
357
407
  this.audiences = new Audiences(this);
358
408
  this.batch = new Batch(this);
409
+ this.broadcasts = new Broadcasts(this);
359
410
  this.contacts = new Contacts(this);
360
411
  this.domains = new Domains(this);
361
412
  this.emails = new Emails(this);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resend",
3
- "version": "4.0.1",
3
+ "version": "4.1.0-alpha.0",
4
4
  "description": "Node.js library for the Resend API",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",