resend 4.1.1-canary.0 → 4.1.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.
- package/dist/index.d.mts +48 -2
- package/dist/index.d.ts +48 -2
- package/dist/index.js +42 -2
- package/dist/index.mjs +42 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -344,6 +344,46 @@ interface CreateBroadcastResponse {
|
|
|
344
344
|
error: ErrorResponse | null;
|
|
345
345
|
}
|
|
346
346
|
|
|
347
|
+
interface Broadcast {
|
|
348
|
+
id: string;
|
|
349
|
+
name: string;
|
|
350
|
+
audience_id: string | null;
|
|
351
|
+
from: string | null;
|
|
352
|
+
subject: string | null;
|
|
353
|
+
reply_to: string[] | null;
|
|
354
|
+
preview_text: string | null;
|
|
355
|
+
status: 'draft' | 'sent' | 'queued';
|
|
356
|
+
created_at: string;
|
|
357
|
+
scheduled_at: string | null;
|
|
358
|
+
sent_at: string | null;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
interface GetBroadcastResponseSuccess extends Broadcast {
|
|
362
|
+
object: 'broadcast';
|
|
363
|
+
}
|
|
364
|
+
interface GetBroadcastResponse {
|
|
365
|
+
data: GetBroadcastResponseSuccess | null;
|
|
366
|
+
error: ErrorResponse | null;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
type ListBroadcastsResponseSuccess = {
|
|
370
|
+
object: 'list';
|
|
371
|
+
data: Pick<Broadcast, 'id' | 'name' | 'audience_id' | 'status' | 'created_at' | 'scheduled_at' | 'sent_at'>[];
|
|
372
|
+
};
|
|
373
|
+
interface ListBroadcastsResponse {
|
|
374
|
+
data: ListBroadcastsResponseSuccess | null;
|
|
375
|
+
error: ErrorResponse | null;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
interface RemoveBroadcastResponseSuccess extends Pick<Broadcast, 'id'> {
|
|
379
|
+
object: 'broadcast';
|
|
380
|
+
deleted: boolean;
|
|
381
|
+
}
|
|
382
|
+
interface RemoveBroadcastResponse {
|
|
383
|
+
data: RemoveBroadcastResponseSuccess | null;
|
|
384
|
+
error: ErrorResponse | null;
|
|
385
|
+
}
|
|
386
|
+
|
|
347
387
|
interface SendBroadcastBaseOptions {
|
|
348
388
|
/**
|
|
349
389
|
* Schedule email to be sent later.
|
|
@@ -372,6 +412,9 @@ declare class Broadcasts {
|
|
|
372
412
|
constructor(resend: Resend);
|
|
373
413
|
create(payload: CreateBroadcastOptions, options?: CreateBroadcastRequestOptions): Promise<SendBroadcastResponse>;
|
|
374
414
|
send(id: string, payload?: SendBroadcastOptions): Promise<SendBroadcastResponse>;
|
|
415
|
+
list(): Promise<ListBroadcastsResponse>;
|
|
416
|
+
get(id: string): Promise<GetBroadcastResponse>;
|
|
417
|
+
remove(id: string): Promise<RemoveBroadcastResponse>;
|
|
375
418
|
}
|
|
376
419
|
|
|
377
420
|
interface PatchOptions {
|
|
@@ -457,8 +500,11 @@ interface RemoveContactsResponse {
|
|
|
457
500
|
error: ErrorResponse | null;
|
|
458
501
|
}
|
|
459
502
|
|
|
460
|
-
interface
|
|
461
|
-
id
|
|
503
|
+
interface UpdateContactBaseOptions {
|
|
504
|
+
id?: string;
|
|
505
|
+
email?: string;
|
|
506
|
+
}
|
|
507
|
+
interface UpdateContactOptions extends UpdateContactBaseOptions {
|
|
462
508
|
audienceId: string;
|
|
463
509
|
unsubscribed?: boolean;
|
|
464
510
|
firstName?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -344,6 +344,46 @@ interface CreateBroadcastResponse {
|
|
|
344
344
|
error: ErrorResponse | null;
|
|
345
345
|
}
|
|
346
346
|
|
|
347
|
+
interface Broadcast {
|
|
348
|
+
id: string;
|
|
349
|
+
name: string;
|
|
350
|
+
audience_id: string | null;
|
|
351
|
+
from: string | null;
|
|
352
|
+
subject: string | null;
|
|
353
|
+
reply_to: string[] | null;
|
|
354
|
+
preview_text: string | null;
|
|
355
|
+
status: 'draft' | 'sent' | 'queued';
|
|
356
|
+
created_at: string;
|
|
357
|
+
scheduled_at: string | null;
|
|
358
|
+
sent_at: string | null;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
interface GetBroadcastResponseSuccess extends Broadcast {
|
|
362
|
+
object: 'broadcast';
|
|
363
|
+
}
|
|
364
|
+
interface GetBroadcastResponse {
|
|
365
|
+
data: GetBroadcastResponseSuccess | null;
|
|
366
|
+
error: ErrorResponse | null;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
type ListBroadcastsResponseSuccess = {
|
|
370
|
+
object: 'list';
|
|
371
|
+
data: Pick<Broadcast, 'id' | 'name' | 'audience_id' | 'status' | 'created_at' | 'scheduled_at' | 'sent_at'>[];
|
|
372
|
+
};
|
|
373
|
+
interface ListBroadcastsResponse {
|
|
374
|
+
data: ListBroadcastsResponseSuccess | null;
|
|
375
|
+
error: ErrorResponse | null;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
interface RemoveBroadcastResponseSuccess extends Pick<Broadcast, 'id'> {
|
|
379
|
+
object: 'broadcast';
|
|
380
|
+
deleted: boolean;
|
|
381
|
+
}
|
|
382
|
+
interface RemoveBroadcastResponse {
|
|
383
|
+
data: RemoveBroadcastResponseSuccess | null;
|
|
384
|
+
error: ErrorResponse | null;
|
|
385
|
+
}
|
|
386
|
+
|
|
347
387
|
interface SendBroadcastBaseOptions {
|
|
348
388
|
/**
|
|
349
389
|
* Schedule email to be sent later.
|
|
@@ -372,6 +412,9 @@ declare class Broadcasts {
|
|
|
372
412
|
constructor(resend: Resend);
|
|
373
413
|
create(payload: CreateBroadcastOptions, options?: CreateBroadcastRequestOptions): Promise<SendBroadcastResponse>;
|
|
374
414
|
send(id: string, payload?: SendBroadcastOptions): Promise<SendBroadcastResponse>;
|
|
415
|
+
list(): Promise<ListBroadcastsResponse>;
|
|
416
|
+
get(id: string): Promise<GetBroadcastResponse>;
|
|
417
|
+
remove(id: string): Promise<RemoveBroadcastResponse>;
|
|
375
418
|
}
|
|
376
419
|
|
|
377
420
|
interface PatchOptions {
|
|
@@ -457,8 +500,11 @@ interface RemoveContactsResponse {
|
|
|
457
500
|
error: ErrorResponse | null;
|
|
458
501
|
}
|
|
459
502
|
|
|
460
|
-
interface
|
|
461
|
-
id
|
|
503
|
+
interface UpdateContactBaseOptions {
|
|
504
|
+
id?: string;
|
|
505
|
+
email?: string;
|
|
506
|
+
}
|
|
507
|
+
interface UpdateContactOptions extends UpdateContactBaseOptions {
|
|
462
508
|
audienceId: string;
|
|
463
509
|
unsubscribed?: boolean;
|
|
464
510
|
firstName?: string;
|
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.1.1
|
|
75
|
+
var version = "4.1.1";
|
|
76
76
|
|
|
77
77
|
// src/api-keys/api-keys.ts
|
|
78
78
|
var ApiKeys = class {
|
|
@@ -230,6 +230,28 @@ var Broadcasts = class {
|
|
|
230
230
|
return data;
|
|
231
231
|
});
|
|
232
232
|
}
|
|
233
|
+
list() {
|
|
234
|
+
return __async(this, null, function* () {
|
|
235
|
+
const data = yield this.resend.get("/broadcasts");
|
|
236
|
+
return data;
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
get(id) {
|
|
240
|
+
return __async(this, null, function* () {
|
|
241
|
+
const data = yield this.resend.get(
|
|
242
|
+
`/broadcasts/${id}`
|
|
243
|
+
);
|
|
244
|
+
return data;
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
remove(id) {
|
|
248
|
+
return __async(this, null, function* () {
|
|
249
|
+
const data = yield this.resend.delete(
|
|
250
|
+
`/broadcasts/${id}`
|
|
251
|
+
);
|
|
252
|
+
return data;
|
|
253
|
+
});
|
|
254
|
+
}
|
|
233
255
|
};
|
|
234
256
|
|
|
235
257
|
// src/contacts/contacts.ts
|
|
@@ -270,8 +292,17 @@ var Contacts = class {
|
|
|
270
292
|
}
|
|
271
293
|
update(payload) {
|
|
272
294
|
return __async(this, null, function* () {
|
|
295
|
+
if (!payload.id && !payload.email) {
|
|
296
|
+
return {
|
|
297
|
+
data: null,
|
|
298
|
+
error: {
|
|
299
|
+
message: "Missing `id` or `email` field.",
|
|
300
|
+
name: "missing_required_field"
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
}
|
|
273
304
|
const data = yield this.resend.patch(
|
|
274
|
-
`/audiences/${payload.audienceId}/contacts/${payload.id}`,
|
|
305
|
+
`/audiences/${payload.audienceId}/contacts/${(payload == null ? void 0 : payload.email) ? payload == null ? void 0 : payload.email : payload == null ? void 0 : payload.id}`,
|
|
275
306
|
{
|
|
276
307
|
unsubscribed: payload.unsubscribed,
|
|
277
308
|
first_name: payload.firstName,
|
|
@@ -283,6 +314,15 @@ var Contacts = class {
|
|
|
283
314
|
}
|
|
284
315
|
remove(payload) {
|
|
285
316
|
return __async(this, null, function* () {
|
|
317
|
+
if (!payload.id && !payload.email) {
|
|
318
|
+
return {
|
|
319
|
+
data: null,
|
|
320
|
+
error: {
|
|
321
|
+
message: "Missing `id` or `email` field.",
|
|
322
|
+
name: "missing_required_field"
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
}
|
|
286
326
|
const data = yield this.resend.delete(
|
|
287
327
|
`/audiences/${payload.audienceId}/contacts/${(payload == null ? void 0 : payload.email) ? payload == null ? void 0 : payload.email : payload == null ? void 0 : payload.id}`
|
|
288
328
|
);
|
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.1.1
|
|
42
|
+
var version = "4.1.1";
|
|
43
43
|
|
|
44
44
|
// src/api-keys/api-keys.ts
|
|
45
45
|
var ApiKeys = class {
|
|
@@ -197,6 +197,28 @@ var Broadcasts = class {
|
|
|
197
197
|
return data;
|
|
198
198
|
});
|
|
199
199
|
}
|
|
200
|
+
list() {
|
|
201
|
+
return __async(this, null, function* () {
|
|
202
|
+
const data = yield this.resend.get("/broadcasts");
|
|
203
|
+
return data;
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
get(id) {
|
|
207
|
+
return __async(this, null, function* () {
|
|
208
|
+
const data = yield this.resend.get(
|
|
209
|
+
`/broadcasts/${id}`
|
|
210
|
+
);
|
|
211
|
+
return data;
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
remove(id) {
|
|
215
|
+
return __async(this, null, function* () {
|
|
216
|
+
const data = yield this.resend.delete(
|
|
217
|
+
`/broadcasts/${id}`
|
|
218
|
+
);
|
|
219
|
+
return data;
|
|
220
|
+
});
|
|
221
|
+
}
|
|
200
222
|
};
|
|
201
223
|
|
|
202
224
|
// src/contacts/contacts.ts
|
|
@@ -237,8 +259,17 @@ var Contacts = class {
|
|
|
237
259
|
}
|
|
238
260
|
update(payload) {
|
|
239
261
|
return __async(this, null, function* () {
|
|
262
|
+
if (!payload.id && !payload.email) {
|
|
263
|
+
return {
|
|
264
|
+
data: null,
|
|
265
|
+
error: {
|
|
266
|
+
message: "Missing `id` or `email` field.",
|
|
267
|
+
name: "missing_required_field"
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
}
|
|
240
271
|
const data = yield this.resend.patch(
|
|
241
|
-
`/audiences/${payload.audienceId}/contacts/${payload.id}`,
|
|
272
|
+
`/audiences/${payload.audienceId}/contacts/${(payload == null ? void 0 : payload.email) ? payload == null ? void 0 : payload.email : payload == null ? void 0 : payload.id}`,
|
|
242
273
|
{
|
|
243
274
|
unsubscribed: payload.unsubscribed,
|
|
244
275
|
first_name: payload.firstName,
|
|
@@ -250,6 +281,15 @@ var Contacts = class {
|
|
|
250
281
|
}
|
|
251
282
|
remove(payload) {
|
|
252
283
|
return __async(this, null, function* () {
|
|
284
|
+
if (!payload.id && !payload.email) {
|
|
285
|
+
return {
|
|
286
|
+
data: null,
|
|
287
|
+
error: {
|
|
288
|
+
message: "Missing `id` or `email` field.",
|
|
289
|
+
name: "missing_required_field"
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
}
|
|
253
293
|
const data = yield this.resend.delete(
|
|
254
294
|
`/audiences/${payload.audienceId}/contacts/${(payload == null ? void 0 : payload.email) ? payload == null ? void 0 : payload.email : payload == null ? void 0 : payload.id}`
|
|
255
295
|
);
|