resend 6.1.0-canary.1 → 6.1.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 +333 -93
- package/dist/index.d.ts +333 -93
- package/dist/index.js +129 -122
- package/dist/index.mjs +129 -122
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2,41 +2,42 @@ import * as React$1 from 'react';
|
|
|
2
2
|
|
|
3
3
|
interface GetOptions {
|
|
4
4
|
query?: Record<string, unknown>;
|
|
5
|
+
headers?: HeadersInit;
|
|
5
6
|
}
|
|
6
7
|
|
|
8
|
+
type PaginationOptions = {
|
|
9
|
+
/**
|
|
10
|
+
* Maximum number of items to return (1-100, default: 20)
|
|
11
|
+
*/
|
|
12
|
+
limit?: number;
|
|
13
|
+
} & ({
|
|
14
|
+
/**
|
|
15
|
+
* Get items after this cursor (cannot be used with 'before')
|
|
16
|
+
*/
|
|
17
|
+
after?: string;
|
|
18
|
+
before?: never;
|
|
19
|
+
} | {
|
|
20
|
+
/**
|
|
21
|
+
* Get items before this cursor (cannot be used with 'after')
|
|
22
|
+
*/
|
|
23
|
+
before?: string;
|
|
24
|
+
after?: never;
|
|
25
|
+
});
|
|
26
|
+
|
|
7
27
|
interface PostOptions {
|
|
8
28
|
query?: {
|
|
9
29
|
[key: string]: unknown;
|
|
10
30
|
};
|
|
31
|
+
headers?: HeadersInit;
|
|
11
32
|
}
|
|
12
33
|
|
|
13
34
|
interface PutOptions {
|
|
14
35
|
query?: {
|
|
15
36
|
[key: string]: unknown;
|
|
16
37
|
};
|
|
38
|
+
headers?: HeadersInit;
|
|
17
39
|
}
|
|
18
40
|
|
|
19
|
-
type RateLimit = {
|
|
20
|
-
/**
|
|
21
|
-
* The maximum amount of requests that can be made in the time window of {@link shouldResetAfter}.
|
|
22
|
-
*/
|
|
23
|
-
limit: number;
|
|
24
|
-
/**
|
|
25
|
-
* The amount of requests that can still be made before hitting {@link RateLimit.limit}.
|
|
26
|
-
*
|
|
27
|
-
* Resets after the seconds in {@link RateLimit.shouldResetAfter} go by.
|
|
28
|
-
*/
|
|
29
|
-
remainingRequests: number;
|
|
30
|
-
/**
|
|
31
|
-
* The number of seconds after which the rate limiting will reset,
|
|
32
|
-
* and {@link RateLimit.remainingRequests} goes back to the value of
|
|
33
|
-
* {@link RateLimit.limit}.
|
|
34
|
-
*
|
|
35
|
-
* @see {@link import('./interfaces').Response.retryAfter}
|
|
36
|
-
*/
|
|
37
|
-
shouldResetAfter: number;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
41
|
declare const RESEND_ERROR_CODES_BY_KEY: {
|
|
41
42
|
readonly missing_required_field: 422;
|
|
42
43
|
readonly invalid_idempotency_key: 400;
|
|
@@ -47,7 +48,7 @@ declare const RESEND_ERROR_CODES_BY_KEY: {
|
|
|
47
48
|
readonly invalid_region: 422;
|
|
48
49
|
readonly rate_limit_exceeded: 429;
|
|
49
50
|
readonly missing_api_key: 401;
|
|
50
|
-
readonly
|
|
51
|
+
readonly invalid_api_key: 403;
|
|
51
52
|
readonly invalid_from_address: 403;
|
|
52
53
|
readonly validation_error: 403;
|
|
53
54
|
readonly not_found: 404;
|
|
@@ -56,26 +57,10 @@ declare const RESEND_ERROR_CODES_BY_KEY: {
|
|
|
56
57
|
readonly internal_server_error: 500;
|
|
57
58
|
};
|
|
58
59
|
type RESEND_ERROR_CODE_KEY = keyof typeof RESEND_ERROR_CODES_BY_KEY;
|
|
59
|
-
|
|
60
|
+
interface ErrorResponse {
|
|
60
61
|
message: string;
|
|
61
|
-
name:
|
|
62
|
-
}
|
|
63
|
-
message: string;
|
|
64
|
-
name: Extract<RESEND_ERROR_CODE_KEY, 'rate_limit_exceeded'>;
|
|
65
|
-
/**
|
|
66
|
-
* Time in seconds.
|
|
67
|
-
*/
|
|
68
|
-
retryAfter: number;
|
|
69
|
-
};
|
|
70
|
-
type Response<Data> = {
|
|
71
|
-
data: Data;
|
|
72
|
-
rateLimiting: RateLimit;
|
|
73
|
-
error: null;
|
|
74
|
-
} | {
|
|
75
|
-
data: null;
|
|
76
|
-
rateLimiting: RateLimit | null;
|
|
77
|
-
error: ErrorResponse;
|
|
78
|
-
};
|
|
62
|
+
name: RESEND_ERROR_CODE_KEY;
|
|
63
|
+
}
|
|
79
64
|
|
|
80
65
|
interface CreateApiKeyOptions {
|
|
81
66
|
name: string;
|
|
@@ -88,7 +73,13 @@ interface CreateApiKeyResponseSuccess {
|
|
|
88
73
|
token: string;
|
|
89
74
|
id: string;
|
|
90
75
|
}
|
|
91
|
-
type CreateApiKeyResponse =
|
|
76
|
+
type CreateApiKeyResponse = {
|
|
77
|
+
data: CreateApiKeyResponseSuccess;
|
|
78
|
+
error: null;
|
|
79
|
+
} | {
|
|
80
|
+
data: null;
|
|
81
|
+
error: ErrorResponse;
|
|
82
|
+
};
|
|
92
83
|
|
|
93
84
|
interface ApiKey {
|
|
94
85
|
created_at: string;
|
|
@@ -96,11 +87,28 @@ interface ApiKey {
|
|
|
96
87
|
name: string;
|
|
97
88
|
}
|
|
98
89
|
|
|
99
|
-
type
|
|
100
|
-
type
|
|
90
|
+
type ListApiKeysOptions = PaginationOptions;
|
|
91
|
+
type ListApiKeysResponseSuccess = {
|
|
92
|
+
object: 'list';
|
|
93
|
+
has_more: boolean;
|
|
94
|
+
data: Pick<ApiKey, 'name' | 'id' | 'created_at'>[];
|
|
95
|
+
};
|
|
96
|
+
type ListApiKeysResponse = {
|
|
97
|
+
data: ListApiKeysResponseSuccess;
|
|
98
|
+
error: null;
|
|
99
|
+
} | {
|
|
100
|
+
data: null;
|
|
101
|
+
error: ErrorResponse;
|
|
102
|
+
};
|
|
101
103
|
|
|
102
104
|
type RemoveApiKeyResponseSuccess = {};
|
|
103
|
-
type RemoveApiKeyResponse =
|
|
105
|
+
type RemoveApiKeyResponse = {
|
|
106
|
+
data: RemoveApiKeyResponseSuccess;
|
|
107
|
+
error: null;
|
|
108
|
+
} | {
|
|
109
|
+
data: null;
|
|
110
|
+
error: ErrorResponse;
|
|
111
|
+
};
|
|
104
112
|
|
|
105
113
|
interface Audience {
|
|
106
114
|
created_at: string;
|
|
@@ -116,24 +124,50 @@ interface CreateAudienceRequestOptions extends PostOptions {
|
|
|
116
124
|
interface CreateAudienceResponseSuccess extends Pick<Audience, 'name' | 'id'> {
|
|
117
125
|
object: 'audience';
|
|
118
126
|
}
|
|
119
|
-
type CreateAudienceResponse =
|
|
127
|
+
type CreateAudienceResponse = {
|
|
128
|
+
data: CreateAudienceResponseSuccess;
|
|
129
|
+
error: null;
|
|
130
|
+
} | {
|
|
131
|
+
data: null;
|
|
132
|
+
error: ErrorResponse;
|
|
133
|
+
};
|
|
120
134
|
|
|
121
135
|
interface GetAudienceResponseSuccess extends Pick<Audience, 'id' | 'name' | 'created_at'> {
|
|
122
136
|
object: 'audience';
|
|
123
137
|
}
|
|
124
|
-
type GetAudienceResponse =
|
|
138
|
+
type GetAudienceResponse = {
|
|
139
|
+
data: GetAudienceResponseSuccess;
|
|
140
|
+
error: null;
|
|
141
|
+
} | {
|
|
142
|
+
data: null;
|
|
143
|
+
error: ErrorResponse;
|
|
144
|
+
};
|
|
125
145
|
|
|
146
|
+
type ListAudiencesOptions = PaginationOptions;
|
|
126
147
|
type ListAudiencesResponseSuccess = {
|
|
127
148
|
object: 'list';
|
|
128
149
|
data: Audience[];
|
|
150
|
+
has_more: boolean;
|
|
151
|
+
};
|
|
152
|
+
type ListAudiencesResponse = {
|
|
153
|
+
data: ListAudiencesResponseSuccess;
|
|
154
|
+
error: null;
|
|
155
|
+
} | {
|
|
156
|
+
data: null;
|
|
157
|
+
error: ErrorResponse;
|
|
129
158
|
};
|
|
130
|
-
type ListAudiencesResponse = Response<ListAudiencesResponseSuccess>;
|
|
131
159
|
|
|
132
160
|
interface RemoveAudiencesResponseSuccess extends Pick<Audience, 'id'> {
|
|
133
161
|
object: 'audience';
|
|
134
162
|
deleted: boolean;
|
|
135
163
|
}
|
|
136
|
-
type RemoveAudiencesResponse =
|
|
164
|
+
type RemoveAudiencesResponse = {
|
|
165
|
+
data: RemoveAudiencesResponseSuccess;
|
|
166
|
+
error: null;
|
|
167
|
+
} | {
|
|
168
|
+
data: null;
|
|
169
|
+
error: ErrorResponse;
|
|
170
|
+
};
|
|
137
171
|
|
|
138
172
|
interface IdempotentRequest {
|
|
139
173
|
/**
|
|
@@ -238,7 +272,13 @@ interface CreateEmailResponseSuccess {
|
|
|
238
272
|
/** The ID of the newly created email. */
|
|
239
273
|
id: string;
|
|
240
274
|
}
|
|
241
|
-
type CreateEmailResponse =
|
|
275
|
+
type CreateEmailResponse = {
|
|
276
|
+
data: CreateEmailResponseSuccess;
|
|
277
|
+
error: null;
|
|
278
|
+
} | {
|
|
279
|
+
data: null;
|
|
280
|
+
error: ErrorResponse;
|
|
281
|
+
};
|
|
242
282
|
interface Attachment {
|
|
243
283
|
/** Content of an attached file. */
|
|
244
284
|
content?: string | Buffer;
|
|
@@ -267,14 +307,38 @@ type Tag = {
|
|
|
267
307
|
|
|
268
308
|
type CreateBatchOptions = CreateEmailOptions[];
|
|
269
309
|
interface CreateBatchRequestOptions extends PostOptions, IdempotentRequest {
|
|
310
|
+
/**
|
|
311
|
+
* @default 'strict'
|
|
312
|
+
*/
|
|
313
|
+
batchValidation?: 'strict' | 'permissive';
|
|
270
314
|
}
|
|
271
|
-
|
|
315
|
+
type CreateBatchSuccessResponse<Options extends CreateBatchRequestOptions = CreateBatchRequestOptions> = {
|
|
272
316
|
data: {
|
|
273
317
|
/** The ID of the newly created email. */
|
|
274
318
|
id: string;
|
|
275
319
|
}[];
|
|
276
|
-
}
|
|
277
|
-
|
|
320
|
+
} & (Options['batchValidation'] extends 'permissive' ? {
|
|
321
|
+
/**
|
|
322
|
+
* Only present when header "x-batch-validation" is set to 'permissive'.
|
|
323
|
+
*/
|
|
324
|
+
errors: {
|
|
325
|
+
/**
|
|
326
|
+
* The index of the failed email in the batch
|
|
327
|
+
*/
|
|
328
|
+
index: number;
|
|
329
|
+
/**
|
|
330
|
+
* The error message for the failed email
|
|
331
|
+
*/
|
|
332
|
+
message: string;
|
|
333
|
+
}[];
|
|
334
|
+
} : Record<string, never>);
|
|
335
|
+
type CreateBatchResponse<Options extends CreateBatchRequestOptions> = {
|
|
336
|
+
data: CreateBatchSuccessResponse<Options>;
|
|
337
|
+
error: null;
|
|
338
|
+
} | {
|
|
339
|
+
data: null;
|
|
340
|
+
error: ErrorResponse;
|
|
341
|
+
};
|
|
278
342
|
|
|
279
343
|
interface EmailRenderOptions {
|
|
280
344
|
/**
|
|
@@ -341,7 +405,13 @@ interface CreateBroadcastResponseSuccess {
|
|
|
341
405
|
/** The ID of the newly sent broadcasts. */
|
|
342
406
|
id: string;
|
|
343
407
|
}
|
|
344
|
-
type CreateBroadcastResponse =
|
|
408
|
+
type CreateBroadcastResponse = {
|
|
409
|
+
data: CreateBroadcastResponseSuccess;
|
|
410
|
+
error: null;
|
|
411
|
+
} | {
|
|
412
|
+
data: null;
|
|
413
|
+
error: ErrorResponse;
|
|
414
|
+
};
|
|
345
415
|
|
|
346
416
|
interface SendBroadcastBaseOptions {
|
|
347
417
|
/**
|
|
@@ -360,7 +430,13 @@ interface SendBroadcastResponseSuccess {
|
|
|
360
430
|
/** The ID of the sent broadcast. */
|
|
361
431
|
id: string;
|
|
362
432
|
}
|
|
363
|
-
type SendBroadcastResponse =
|
|
433
|
+
type SendBroadcastResponse = {
|
|
434
|
+
data: SendBroadcastResponseSuccess;
|
|
435
|
+
error: null;
|
|
436
|
+
} | {
|
|
437
|
+
data: null;
|
|
438
|
+
error: ErrorResponse;
|
|
439
|
+
};
|
|
364
440
|
|
|
365
441
|
interface Contact {
|
|
366
442
|
created_at: string;
|
|
@@ -410,7 +486,13 @@ interface CreateContactRequestOptions extends PostOptions {
|
|
|
410
486
|
interface CreateContactResponseSuccess extends Pick<Contact, 'id'> {
|
|
411
487
|
object: 'contact';
|
|
412
488
|
}
|
|
413
|
-
type CreateContactResponse =
|
|
489
|
+
type CreateContactResponse = {
|
|
490
|
+
data: CreateContactResponseSuccess;
|
|
491
|
+
error: null;
|
|
492
|
+
} | {
|
|
493
|
+
data: null;
|
|
494
|
+
error: ErrorResponse;
|
|
495
|
+
};
|
|
414
496
|
|
|
415
497
|
type GetContactOptions = {
|
|
416
498
|
audienceId: string;
|
|
@@ -418,16 +500,29 @@ type GetContactOptions = {
|
|
|
418
500
|
interface GetContactResponseSuccess extends Pick<Contact, 'id' | 'email' | 'created_at' | 'first_name' | 'last_name' | 'unsubscribed'> {
|
|
419
501
|
object: 'contact';
|
|
420
502
|
}
|
|
421
|
-
type GetContactResponse =
|
|
503
|
+
type GetContactResponse = {
|
|
504
|
+
data: GetContactResponseSuccess;
|
|
505
|
+
error: null;
|
|
506
|
+
} | {
|
|
507
|
+
data: null;
|
|
508
|
+
error: ErrorResponse;
|
|
509
|
+
};
|
|
422
510
|
|
|
423
|
-
|
|
511
|
+
type ListContactsOptions = {
|
|
424
512
|
audienceId: string;
|
|
425
|
-
}
|
|
513
|
+
} & PaginationOptions;
|
|
426
514
|
interface ListContactsResponseSuccess {
|
|
427
515
|
object: 'list';
|
|
428
516
|
data: Contact[];
|
|
517
|
+
has_more: boolean;
|
|
429
518
|
}
|
|
430
|
-
type ListContactsResponse =
|
|
519
|
+
type ListContactsResponse = {
|
|
520
|
+
data: ListContactsResponseSuccess;
|
|
521
|
+
error: null;
|
|
522
|
+
} | {
|
|
523
|
+
data: null;
|
|
524
|
+
error: ErrorResponse;
|
|
525
|
+
};
|
|
431
526
|
|
|
432
527
|
type RemoveContactsResponseSuccess = {
|
|
433
528
|
object: 'contact';
|
|
@@ -437,7 +532,13 @@ type RemoveContactsResponseSuccess = {
|
|
|
437
532
|
type RemoveContactOptions = SelectingField & {
|
|
438
533
|
audienceId: string;
|
|
439
534
|
};
|
|
440
|
-
type RemoveContactsResponse =
|
|
535
|
+
type RemoveContactsResponse = {
|
|
536
|
+
data: RemoveContactsResponseSuccess;
|
|
537
|
+
error: null;
|
|
538
|
+
} | {
|
|
539
|
+
data: null;
|
|
540
|
+
error: ErrorResponse;
|
|
541
|
+
};
|
|
441
542
|
|
|
442
543
|
type UpdateContactOptions = {
|
|
443
544
|
audienceId: string;
|
|
@@ -448,7 +549,13 @@ type UpdateContactOptions = {
|
|
|
448
549
|
type UpdateContactResponseSuccess = Pick<Contact, 'id'> & {
|
|
449
550
|
object: 'contact';
|
|
450
551
|
};
|
|
451
|
-
type UpdateContactResponse =
|
|
552
|
+
type UpdateContactResponse = {
|
|
553
|
+
data: UpdateContactResponseSuccess;
|
|
554
|
+
error: null;
|
|
555
|
+
} | {
|
|
556
|
+
data: null;
|
|
557
|
+
error: ErrorResponse;
|
|
558
|
+
};
|
|
452
559
|
|
|
453
560
|
type DomainRegion = 'us-east-1' | 'eu-west-1' | 'sa-east-1' | 'ap-northeast-1';
|
|
454
561
|
type DomainStatus = 'pending' | 'verified' | 'failed' | 'temporary_failure' | 'not_started';
|
|
@@ -493,24 +600,51 @@ interface CreateDomainRequestOptions extends PostOptions {
|
|
|
493
600
|
interface CreateDomainResponseSuccess extends Pick<Domain, 'name' | 'id' | 'status' | 'created_at' | 'region'> {
|
|
494
601
|
records: DomainRecords[];
|
|
495
602
|
}
|
|
496
|
-
type CreateDomainResponse =
|
|
603
|
+
type CreateDomainResponse = {
|
|
604
|
+
data: CreateDomainResponseSuccess;
|
|
605
|
+
error: null;
|
|
606
|
+
} | {
|
|
607
|
+
data: null;
|
|
608
|
+
error: ErrorResponse;
|
|
609
|
+
};
|
|
497
610
|
|
|
498
611
|
interface GetDomainResponseSuccess extends Pick<Domain, 'id' | 'name' | 'created_at' | 'region' | 'status'> {
|
|
499
612
|
object: 'domain';
|
|
500
613
|
records: DomainRecords[];
|
|
501
614
|
}
|
|
502
|
-
type GetDomainResponse =
|
|
615
|
+
type GetDomainResponse = {
|
|
616
|
+
data: GetDomainResponseSuccess;
|
|
617
|
+
error: null;
|
|
618
|
+
} | {
|
|
619
|
+
data: null;
|
|
620
|
+
error: ErrorResponse;
|
|
621
|
+
};
|
|
503
622
|
|
|
623
|
+
type ListDomainsOptions = PaginationOptions;
|
|
504
624
|
type ListDomainsResponseSuccess = {
|
|
505
625
|
data: Domain[];
|
|
626
|
+
object: 'list';
|
|
627
|
+
has_more: boolean;
|
|
628
|
+
};
|
|
629
|
+
type ListDomainsResponse = {
|
|
630
|
+
data: ListDomainsResponseSuccess;
|
|
631
|
+
error: null;
|
|
632
|
+
} | {
|
|
633
|
+
data: null;
|
|
634
|
+
error: ErrorResponse;
|
|
506
635
|
};
|
|
507
|
-
type ListDomainsResponse = Response<ListDomainsResponseSuccess>;
|
|
508
636
|
|
|
509
637
|
type RemoveDomainsResponseSuccess = Pick<Domain, 'id'> & {
|
|
510
638
|
object: 'domain';
|
|
511
639
|
deleted: boolean;
|
|
512
640
|
};
|
|
513
|
-
type RemoveDomainsResponse =
|
|
641
|
+
type RemoveDomainsResponse = {
|
|
642
|
+
data: RemoveDomainsResponseSuccess;
|
|
643
|
+
error: null;
|
|
644
|
+
} | {
|
|
645
|
+
data: null;
|
|
646
|
+
error: ErrorResponse;
|
|
647
|
+
};
|
|
514
648
|
|
|
515
649
|
interface UpdateDomainsOptions {
|
|
516
650
|
id: string;
|
|
@@ -521,12 +655,24 @@ interface UpdateDomainsOptions {
|
|
|
521
655
|
type UpdateDomainsResponseSuccess = Pick<Domain, 'id'> & {
|
|
522
656
|
object: 'domain';
|
|
523
657
|
};
|
|
524
|
-
type UpdateDomainsResponse =
|
|
658
|
+
type UpdateDomainsResponse = {
|
|
659
|
+
data: UpdateDomainsResponseSuccess;
|
|
660
|
+
error: null;
|
|
661
|
+
} | {
|
|
662
|
+
data: null;
|
|
663
|
+
error: ErrorResponse;
|
|
664
|
+
};
|
|
525
665
|
|
|
526
666
|
type VerifyDomainsResponseSuccess = Pick<Domain, 'id'> & {
|
|
527
667
|
object: 'domain';
|
|
528
668
|
};
|
|
529
|
-
type VerifyDomainsResponse =
|
|
669
|
+
type VerifyDomainsResponse = {
|
|
670
|
+
data: VerifyDomainsResponseSuccess;
|
|
671
|
+
error: null;
|
|
672
|
+
} | {
|
|
673
|
+
data: null;
|
|
674
|
+
error: ErrorResponse;
|
|
675
|
+
};
|
|
530
676
|
|
|
531
677
|
interface GetEmailResponseSuccess {
|
|
532
678
|
bcc: string[] | null;
|
|
@@ -547,13 +693,19 @@ interface GetEmailResponseSuccess {
|
|
|
547
693
|
scheduled_at: string | null;
|
|
548
694
|
object: 'email';
|
|
549
695
|
}
|
|
550
|
-
type GetEmailResponse =
|
|
696
|
+
type GetEmailResponse = {
|
|
697
|
+
data: GetEmailResponseSuccess;
|
|
698
|
+
error: null;
|
|
699
|
+
} | {
|
|
700
|
+
data: null;
|
|
701
|
+
error: ErrorResponse;
|
|
702
|
+
};
|
|
551
703
|
|
|
552
704
|
declare class ApiKeys {
|
|
553
705
|
private readonly resend;
|
|
554
706
|
constructor(resend: Resend);
|
|
555
707
|
create(payload: CreateApiKeyOptions, options?: CreateApiKeyRequestOptions): Promise<CreateApiKeyResponse>;
|
|
556
|
-
list(): Promise<ListApiKeysResponse>;
|
|
708
|
+
list(options?: ListApiKeysOptions): Promise<ListApiKeysResponse>;
|
|
557
709
|
remove(id: string): Promise<RemoveApiKeyResponse>;
|
|
558
710
|
}
|
|
559
711
|
|
|
@@ -561,17 +713,16 @@ declare class Audiences {
|
|
|
561
713
|
private readonly resend;
|
|
562
714
|
constructor(resend: Resend);
|
|
563
715
|
create(payload: CreateAudienceOptions, options?: CreateAudienceRequestOptions): Promise<CreateAudienceResponse>;
|
|
564
|
-
list(): Promise<ListAudiencesResponse>;
|
|
716
|
+
list(options?: ListAudiencesOptions): Promise<ListAudiencesResponse>;
|
|
565
717
|
get(id: string): Promise<GetAudienceResponse>;
|
|
566
718
|
remove(id: string): Promise<RemoveAudiencesResponse>;
|
|
567
719
|
}
|
|
568
720
|
|
|
569
721
|
declare class Batch {
|
|
570
722
|
private readonly resend;
|
|
571
|
-
private renderAsync?;
|
|
572
723
|
constructor(resend: Resend);
|
|
573
|
-
send(payload: CreateBatchOptions, options?:
|
|
574
|
-
create(payload: CreateBatchOptions, options?:
|
|
724
|
+
send<Options extends CreateBatchRequestOptions>(payload: CreateBatchOptions, options?: Options): Promise<CreateBatchResponse<Options>>;
|
|
725
|
+
create<Options extends CreateBatchRequestOptions>(payload: CreateBatchOptions, options?: Options): Promise<CreateBatchResponse<Options>>;
|
|
575
726
|
}
|
|
576
727
|
|
|
577
728
|
interface Broadcast {
|
|
@@ -591,19 +742,39 @@ interface Broadcast {
|
|
|
591
742
|
interface GetBroadcastResponseSuccess extends Broadcast {
|
|
592
743
|
object: 'broadcast';
|
|
593
744
|
}
|
|
594
|
-
type GetBroadcastResponse =
|
|
745
|
+
type GetBroadcastResponse = {
|
|
746
|
+
data: GetBroadcastResponseSuccess;
|
|
747
|
+
error: null;
|
|
748
|
+
} | {
|
|
749
|
+
data: null;
|
|
750
|
+
error: ErrorResponse;
|
|
751
|
+
};
|
|
595
752
|
|
|
753
|
+
type ListBroadcastsOptions = PaginationOptions;
|
|
596
754
|
type ListBroadcastsResponseSuccess = {
|
|
597
755
|
object: 'list';
|
|
756
|
+
has_more: boolean;
|
|
598
757
|
data: Pick<Broadcast, 'id' | 'name' | 'audience_id' | 'status' | 'created_at' | 'scheduled_at' | 'sent_at'>[];
|
|
599
758
|
};
|
|
600
|
-
type ListBroadcastsResponse =
|
|
759
|
+
type ListBroadcastsResponse = {
|
|
760
|
+
data: ListBroadcastsResponseSuccess;
|
|
761
|
+
error: null;
|
|
762
|
+
} | {
|
|
763
|
+
data: null;
|
|
764
|
+
error: ErrorResponse;
|
|
765
|
+
};
|
|
601
766
|
|
|
602
767
|
interface RemoveBroadcastResponseSuccess extends Pick<Broadcast, 'id'> {
|
|
603
768
|
object: 'broadcast';
|
|
604
769
|
deleted: boolean;
|
|
605
770
|
}
|
|
606
|
-
type RemoveBroadcastResponse =
|
|
771
|
+
type RemoveBroadcastResponse = {
|
|
772
|
+
data: RemoveBroadcastResponseSuccess;
|
|
773
|
+
error: null;
|
|
774
|
+
} | {
|
|
775
|
+
data: null;
|
|
776
|
+
error: ErrorResponse;
|
|
777
|
+
};
|
|
607
778
|
|
|
608
779
|
interface UpdateBroadcastResponseSuccess {
|
|
609
780
|
id: string;
|
|
@@ -619,15 +790,20 @@ type UpdateBroadcastOptions = {
|
|
|
619
790
|
replyTo?: string[];
|
|
620
791
|
previewText?: string;
|
|
621
792
|
};
|
|
622
|
-
type UpdateBroadcastResponse =
|
|
793
|
+
type UpdateBroadcastResponse = {
|
|
794
|
+
data: UpdateBroadcastResponseSuccess;
|
|
795
|
+
error: null;
|
|
796
|
+
} | {
|
|
797
|
+
data: null;
|
|
798
|
+
error: ErrorResponse;
|
|
799
|
+
};
|
|
623
800
|
|
|
624
801
|
declare class Broadcasts {
|
|
625
802
|
private readonly resend;
|
|
626
|
-
private renderAsync?;
|
|
627
803
|
constructor(resend: Resend);
|
|
628
804
|
create(payload: CreateBroadcastOptions, options?: CreateBroadcastRequestOptions): Promise<SendBroadcastResponse>;
|
|
629
805
|
send(id: string, payload?: SendBroadcastOptions): Promise<SendBroadcastResponse>;
|
|
630
|
-
list(): Promise<ListBroadcastsResponse>;
|
|
806
|
+
list(options?: ListBroadcastsOptions): Promise<ListBroadcastsResponse>;
|
|
631
807
|
get(id: string): Promise<GetBroadcastResponse>;
|
|
632
808
|
remove(id: string): Promise<RemoveBroadcastResponse>;
|
|
633
809
|
update(id: string, payload: UpdateBroadcastOptions): Promise<UpdateBroadcastResponse>;
|
|
@@ -637,6 +813,7 @@ interface PatchOptions {
|
|
|
637
813
|
query?: {
|
|
638
814
|
[key: string]: unknown;
|
|
639
815
|
};
|
|
816
|
+
headers?: HeadersInit;
|
|
640
817
|
}
|
|
641
818
|
|
|
642
819
|
declare class Contacts {
|
|
@@ -653,7 +830,7 @@ declare class Domains {
|
|
|
653
830
|
private readonly resend;
|
|
654
831
|
constructor(resend: Resend);
|
|
655
832
|
create(payload: CreateDomainOptions, options?: CreateDomainRequestOptions): Promise<CreateDomainResponse>;
|
|
656
|
-
list(): Promise<ListDomainsResponse>;
|
|
833
|
+
list(options?: ListDomainsOptions): Promise<ListDomainsResponse>;
|
|
657
834
|
get(id: string): Promise<GetDomainResponse>;
|
|
658
835
|
update(payload: UpdateDomainsOptions): Promise<UpdateDomainsResponse>;
|
|
659
836
|
remove(id: string): Promise<RemoveDomainsResponse>;
|
|
@@ -664,7 +841,28 @@ interface CancelEmailResponseSuccess {
|
|
|
664
841
|
object: 'email';
|
|
665
842
|
id: string;
|
|
666
843
|
}
|
|
667
|
-
type CancelEmailResponse =
|
|
844
|
+
type CancelEmailResponse = {
|
|
845
|
+
data: CancelEmailResponseSuccess;
|
|
846
|
+
error: null;
|
|
847
|
+
} | {
|
|
848
|
+
data: null;
|
|
849
|
+
error: ErrorResponse;
|
|
850
|
+
};
|
|
851
|
+
|
|
852
|
+
type ListEmailsOptions = PaginationOptions;
|
|
853
|
+
type ListEmail = Omit<GetEmailResponseSuccess, 'html' | 'text' | 'tags' | 'object'>;
|
|
854
|
+
type ListEmailsResponseSuccess = {
|
|
855
|
+
object: 'list';
|
|
856
|
+
has_more: boolean;
|
|
857
|
+
data: ListEmail[];
|
|
858
|
+
};
|
|
859
|
+
type ListEmailsResponse = {
|
|
860
|
+
data: ListEmailsResponseSuccess;
|
|
861
|
+
error: null;
|
|
862
|
+
} | {
|
|
863
|
+
data: null;
|
|
864
|
+
error: ErrorResponse;
|
|
865
|
+
};
|
|
668
866
|
|
|
669
867
|
interface UpdateEmailOptions {
|
|
670
868
|
id: string;
|
|
@@ -674,15 +872,21 @@ interface UpdateEmailResponseSuccess {
|
|
|
674
872
|
id: string;
|
|
675
873
|
object: 'email';
|
|
676
874
|
}
|
|
677
|
-
type UpdateEmailResponse =
|
|
875
|
+
type UpdateEmailResponse = {
|
|
876
|
+
data: UpdateEmailResponseSuccess;
|
|
877
|
+
error: null;
|
|
878
|
+
} | {
|
|
879
|
+
data: null;
|
|
880
|
+
error: ErrorResponse;
|
|
881
|
+
};
|
|
678
882
|
|
|
679
883
|
declare class Emails {
|
|
680
884
|
private readonly resend;
|
|
681
|
-
private renderAsync?;
|
|
682
885
|
constructor(resend: Resend);
|
|
683
886
|
send(payload: CreateEmailOptions, options?: CreateEmailRequestOptions): Promise<CreateEmailResponse>;
|
|
684
887
|
create(payload: CreateEmailOptions, options?: CreateEmailRequestOptions): Promise<CreateEmailResponse>;
|
|
685
888
|
get(id: string): Promise<GetEmailResponse>;
|
|
889
|
+
list(options?: ListEmailsOptions): Promise<ListEmailsResponse>;
|
|
686
890
|
update(payload: UpdateEmailOptions): Promise<UpdateEmailResponse>;
|
|
687
891
|
cancel(id: string): Promise<CancelEmailResponse>;
|
|
688
892
|
}
|
|
@@ -698,12 +902,48 @@ declare class Resend {
|
|
|
698
902
|
readonly domains: Domains;
|
|
699
903
|
readonly emails: Emails;
|
|
700
904
|
constructor(key?: string | undefined);
|
|
701
|
-
fetchRequest<T>(path: string, options?: {}): Promise<
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
|
|
905
|
+
fetchRequest<T>(path: string, options?: {}): Promise<{
|
|
906
|
+
data: T;
|
|
907
|
+
error: null;
|
|
908
|
+
} | {
|
|
909
|
+
data: null;
|
|
910
|
+
error: ErrorResponse;
|
|
911
|
+
}>;
|
|
912
|
+
post<T>(path: string, entity?: unknown, options?: PostOptions & IdempotentRequest): Promise<{
|
|
913
|
+
data: null;
|
|
914
|
+
error: ErrorResponse;
|
|
915
|
+
} | {
|
|
916
|
+
data: T;
|
|
917
|
+
error: null;
|
|
918
|
+
}>;
|
|
919
|
+
get<T>(path: string, options?: GetOptions): Promise<{
|
|
920
|
+
data: null;
|
|
921
|
+
error: ErrorResponse;
|
|
922
|
+
} | {
|
|
923
|
+
data: T;
|
|
924
|
+
error: null;
|
|
925
|
+
}>;
|
|
926
|
+
put<T>(path: string, entity: unknown, options?: PutOptions): Promise<{
|
|
927
|
+
data: null;
|
|
928
|
+
error: ErrorResponse;
|
|
929
|
+
} | {
|
|
930
|
+
data: T;
|
|
931
|
+
error: null;
|
|
932
|
+
}>;
|
|
933
|
+
patch<T>(path: string, entity: unknown, options?: PatchOptions): Promise<{
|
|
934
|
+
data: null;
|
|
935
|
+
error: ErrorResponse;
|
|
936
|
+
} | {
|
|
937
|
+
data: T;
|
|
938
|
+
error: null;
|
|
939
|
+
}>;
|
|
940
|
+
delete<T>(path: string, query?: unknown): Promise<{
|
|
941
|
+
data: null;
|
|
942
|
+
error: ErrorResponse;
|
|
943
|
+
} | {
|
|
944
|
+
data: T;
|
|
945
|
+
error: null;
|
|
946
|
+
}>;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
export { type Attachment, type CreateApiKeyOptions, type CreateApiKeyRequestOptions, type CreateApiKeyResponse, type CreateApiKeyResponseSuccess, type CreateAudienceOptions, type CreateAudienceRequestOptions, type CreateAudienceResponse, type CreateAudienceResponseSuccess, type CreateBatchOptions, type CreateBatchRequestOptions, type CreateBatchResponse, type CreateBatchSuccessResponse, type CreateBroadcastOptions, type CreateBroadcastRequestOptions, type CreateBroadcastResponse, type CreateBroadcastResponseSuccess, type CreateContactOptions, type CreateContactRequestOptions, type CreateContactResponse, type CreateContactResponseSuccess, type CreateDomainOptions, type CreateDomainRequestOptions, type CreateDomainResponse, type CreateDomainResponseSuccess, type CreateEmailOptions, type CreateEmailRequestOptions, type CreateEmailResponse, type CreateEmailResponseSuccess, type ErrorResponse, type GetAudienceResponse, type GetAudienceResponseSuccess, type GetContactOptions, type GetContactResponse, type GetContactResponseSuccess, type GetDomainResponse, type GetDomainResponseSuccess, type GetEmailResponse, type GetEmailResponseSuccess, type ListApiKeysOptions, type ListApiKeysResponse, type ListApiKeysResponseSuccess, type ListAudiencesOptions, type ListAudiencesResponse, type ListAudiencesResponseSuccess, type ListContactsOptions, type ListContactsResponse, type ListContactsResponseSuccess, type ListDomainsOptions, type ListDomainsResponse, type ListDomainsResponseSuccess, type PaginationOptions, type RemoveApiKeyResponse, type RemoveApiKeyResponseSuccess, type RemoveAudiencesResponse, type RemoveAudiencesResponseSuccess, type RemoveContactOptions, type RemoveContactsResponse, type RemoveContactsResponseSuccess, type RemoveDomainsResponse, type RemoveDomainsResponseSuccess, Resend, type SendBroadcastOptions, type SendBroadcastRequestOptions, type SendBroadcastResponse, type SendBroadcastResponseSuccess, type Tag, type UpdateContactOptions, type UpdateContactResponse, type UpdateContactResponseSuccess, type UpdateDomainsOptions, type UpdateDomainsResponse, type UpdateDomainsResponseSuccess, type VerifyDomainsResponse, type VerifyDomainsResponseSuccess };
|