resend 6.38.1 → 6.40.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.cjs +45 -20
- package/dist/index.d.cts +55 -9
- package/dist/index.d.mts +55 -9
- package/dist/index.mjs +45 -20
- package/package.json +1 -1
- package/readme.md +8 -9
package/dist/index.cjs
CHANGED
|
@@ -57,7 +57,7 @@ const MOVE_THREAD_FOLDERS = [
|
|
|
57
57
|
];
|
|
58
58
|
//#endregion
|
|
59
59
|
//#region package.json
|
|
60
|
-
var version = "6.
|
|
60
|
+
var version = "6.40.0";
|
|
61
61
|
//#endregion
|
|
62
62
|
//#region src/common/utils/build-pagination-query.ts
|
|
63
63
|
function buildPaginationUrl(base, options) {
|
|
@@ -116,6 +116,9 @@ var AutomationRuns = class {
|
|
|
116
116
|
const url = qs ? `/automations/${options.automationId}/runs?${qs}` : `/automations/${options.automationId}/runs`;
|
|
117
117
|
return await this.resend.get(url, requestOptions);
|
|
118
118
|
}
|
|
119
|
+
async cancel(options, requestOptions = {}) {
|
|
120
|
+
return await this.resend.post(`/automations/${options.automationId}/runs/${options.runId}/cancel`, void 0, requestOptions);
|
|
121
|
+
}
|
|
119
122
|
};
|
|
120
123
|
//#endregion
|
|
121
124
|
//#region src/common/utils/parse-automation-to-api-options.ts
|
|
@@ -250,13 +253,15 @@ var Automations = class {
|
|
|
250
253
|
}
|
|
251
254
|
};
|
|
252
255
|
//#endregion
|
|
253
|
-
//#region src/common/utils/
|
|
256
|
+
//#region src/common/utils/encode-base64.ts
|
|
254
257
|
function encodeBase64(bytes) {
|
|
255
258
|
if (typeof Buffer !== "undefined") return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("base64");
|
|
256
259
|
let binary = "";
|
|
257
260
|
for (let i = 0; i < bytes.length; i += 32768) binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
|
|
258
261
|
return btoa(binary);
|
|
259
262
|
}
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/common/utils/parse-email-to-api-options.ts
|
|
260
265
|
/**
|
|
261
266
|
* JSON.stringify turns a Uint8Array into an object of indexes and an
|
|
262
267
|
* ArrayBuffer into `{}`, so binary content is sent as base64 instead.
|
|
@@ -781,11 +786,22 @@ var DomainClaims = class {
|
|
|
781
786
|
}
|
|
782
787
|
};
|
|
783
788
|
//#endregion
|
|
789
|
+
//#region src/domains/forge/forge.ts
|
|
790
|
+
var Forge = class {
|
|
791
|
+
constructor(resend) {
|
|
792
|
+
this.resend = resend;
|
|
793
|
+
}
|
|
794
|
+
async enable(payload, requestOptions = {}) {
|
|
795
|
+
return await this.resend.post(`/domains/${payload.id}/forge`, { custom_return_path: payload.customReturnPath }, requestOptions);
|
|
796
|
+
}
|
|
797
|
+
};
|
|
798
|
+
//#endregion
|
|
784
799
|
//#region src/domains/domains.ts
|
|
785
800
|
var Domains = class {
|
|
786
801
|
constructor(resend) {
|
|
787
802
|
this.resend = resend;
|
|
788
803
|
this.claims = new DomainClaims(this.resend);
|
|
804
|
+
this.forge = new Forge(this.resend);
|
|
789
805
|
}
|
|
790
806
|
async create(payload, requestOptions = {}) {
|
|
791
807
|
return await this.resend.post("/domains", parseDomainToApiOptions(payload), requestOptions);
|
|
@@ -809,8 +825,9 @@ var Domains = class {
|
|
|
809
825
|
async remove(id, requestOptions = {}) {
|
|
810
826
|
return await this.resend.delete(`/domains/${id}`, void 0, requestOptions);
|
|
811
827
|
}
|
|
812
|
-
async verify(id,
|
|
813
|
-
|
|
828
|
+
async verify(id, options = {}) {
|
|
829
|
+
const { scope, ...requestOptions } = options;
|
|
830
|
+
return await this.resend.post(`/domains/${id}/verify`, scope ? { scope } : void 0, requestOptions);
|
|
814
831
|
}
|
|
815
832
|
};
|
|
816
833
|
//#endregion
|
|
@@ -830,6 +847,17 @@ var Attachments$1 = class {
|
|
|
830
847
|
}
|
|
831
848
|
};
|
|
832
849
|
//#endregion
|
|
850
|
+
//#region src/common/utils/build-query-url.ts
|
|
851
|
+
function buildQueryUrl(base, params = {}) {
|
|
852
|
+
const searchParams = new URLSearchParams();
|
|
853
|
+
for (const [key, value] of Object.entries(params)) {
|
|
854
|
+
if (value === void 0) continue;
|
|
855
|
+
searchParams.set(key, Array.isArray(value) ? value.join(",") : String(value));
|
|
856
|
+
}
|
|
857
|
+
const queryString = searchParams.toString();
|
|
858
|
+
return queryString ? `${base}?${queryString}` : base;
|
|
859
|
+
}
|
|
860
|
+
//#endregion
|
|
833
861
|
//#region src/emails/receiving/attachments/attachments.ts
|
|
834
862
|
var Attachments = class {
|
|
835
863
|
constructor(resend) {
|
|
@@ -860,7 +888,15 @@ var Receiving = class {
|
|
|
860
888
|
return await this.resend.get(path, requestOptions);
|
|
861
889
|
}
|
|
862
890
|
async list(options = {}, requestOptions = {}) {
|
|
863
|
-
const
|
|
891
|
+
const { to, startDate, endDate, limit } = options;
|
|
892
|
+
const url = buildQueryUrl("/emails/receiving", {
|
|
893
|
+
to,
|
|
894
|
+
start_date: startDate,
|
|
895
|
+
end_date: endDate,
|
|
896
|
+
limit,
|
|
897
|
+
after: "after" in options ? options.after : void 0,
|
|
898
|
+
before: "before" in options ? options.before : void 0
|
|
899
|
+
});
|
|
864
900
|
return await this.resend.get(url, requestOptions);
|
|
865
901
|
}
|
|
866
902
|
async forward(options, requestOptions = {}) {
|
|
@@ -949,7 +985,7 @@ var Receiving = class {
|
|
|
949
985
|
html,
|
|
950
986
|
attachments: [{
|
|
951
987
|
filename: "forwarded_message.eml",
|
|
952
|
-
content:
|
|
988
|
+
content: encodeBase64(new Uint8Array(raw.content)),
|
|
953
989
|
content_type: "message/rfc822"
|
|
954
990
|
}]
|
|
955
991
|
}, requestOptions);
|
|
@@ -1099,17 +1135,6 @@ var InboxAgent = class {
|
|
|
1099
1135
|
}
|
|
1100
1136
|
};
|
|
1101
1137
|
//#endregion
|
|
1102
|
-
//#region src/inboxes/build-inbox-cursor-query.ts
|
|
1103
|
-
function buildInboxCursorUrl(base, options = {}) {
|
|
1104
|
-
const searchParams = new URLSearchParams();
|
|
1105
|
-
for (const [key, value] of Object.entries(options)) {
|
|
1106
|
-
if (value === void 0) continue;
|
|
1107
|
-
searchParams.set(key, Array.isArray(value) ? value.join(",") : String(value));
|
|
1108
|
-
}
|
|
1109
|
-
const queryString = searchParams.toString();
|
|
1110
|
-
return queryString ? `${base}?${queryString}` : base;
|
|
1111
|
-
}
|
|
1112
|
-
//#endregion
|
|
1113
1138
|
//#region src/inboxes/drafts/drafts.ts
|
|
1114
1139
|
var InboxDrafts = class {
|
|
1115
1140
|
constructor(resend) {
|
|
@@ -1119,7 +1144,7 @@ var InboxDrafts = class {
|
|
|
1119
1144
|
const inboxPath = buildInboxPath(options);
|
|
1120
1145
|
if (!inboxPath) return missingInboxError();
|
|
1121
1146
|
const { limit, after, before } = options;
|
|
1122
|
-
const url =
|
|
1147
|
+
const url = buildQueryUrl(`${inboxPath}/drafts`, {
|
|
1123
1148
|
limit,
|
|
1124
1149
|
after,
|
|
1125
1150
|
before
|
|
@@ -1285,7 +1310,7 @@ var InboxThreads = class {
|
|
|
1285
1310
|
const inboxPath = buildInboxPath(options);
|
|
1286
1311
|
if (!inboxPath) return missingInboxError();
|
|
1287
1312
|
const { folders, labels, read, limit, after, before } = options;
|
|
1288
|
-
const url =
|
|
1313
|
+
const url = buildQueryUrl(`${inboxPath}/threads`, {
|
|
1289
1314
|
folders,
|
|
1290
1315
|
labels,
|
|
1291
1316
|
read,
|
|
@@ -1299,7 +1324,7 @@ var InboxThreads = class {
|
|
|
1299
1324
|
const inboxPath = buildInboxPath(options);
|
|
1300
1325
|
if (!inboxPath) return missingInboxError();
|
|
1301
1326
|
const { folders, labels, read, query, from, to, cc, bcc, hasAttachment, startDate, endDate, limit, after, before } = options;
|
|
1302
|
-
const url =
|
|
1327
|
+
const url = buildQueryUrl(`${inboxPath}/threads/search`, {
|
|
1303
1328
|
folders,
|
|
1304
1329
|
labels,
|
|
1305
1330
|
read,
|
package/dist/index.d.cts
CHANGED
|
@@ -418,6 +418,18 @@ export interface AutomationRun {
|
|
|
418
418
|
}
|
|
419
419
|
export type AutomationRunItem = Pick<AutomationRun, 'id' | 'status' | 'started_at' | 'completed_at' | 'created_at'>;
|
|
420
420
|
//#endregion
|
|
421
|
+
//#region src/automation-runs/interfaces/cancel-automation-run.interface.d.ts
|
|
422
|
+
export interface CancelAutomationRunOptions {
|
|
423
|
+
automationId: string;
|
|
424
|
+
runId: string;
|
|
425
|
+
}
|
|
426
|
+
export interface CancelAutomationRunResponseSuccess {
|
|
427
|
+
object: 'automation_run';
|
|
428
|
+
id: string;
|
|
429
|
+
status: 'cancelled';
|
|
430
|
+
}
|
|
431
|
+
export type CancelAutomationRunResponse = Response<CancelAutomationRunResponseSuccess>;
|
|
432
|
+
//#endregion
|
|
421
433
|
//#region src/automation-runs/interfaces/get-automation-run.interface.d.ts
|
|
422
434
|
export interface GetAutomationRunOptions {
|
|
423
435
|
automationId: string;
|
|
@@ -1372,6 +1384,22 @@ export interface VerifyDomainClaimResponseSuccess extends DomainClaim {
|
|
|
1372
1384
|
}
|
|
1373
1385
|
export type VerifyDomainClaimResponse = Response<VerifyDomainClaimResponseSuccess>;
|
|
1374
1386
|
//#endregion
|
|
1387
|
+
//#region src/domains/interfaces/get-domain.interface.d.ts
|
|
1388
|
+
export interface GetDomainResponseSuccess extends Pick<Domain, 'id' | 'name' | 'created_at' | 'region' | 'status' | 'capabilities' | 'open_tracking' | 'click_tracking' | 'tracking_subdomain'> {
|
|
1389
|
+
object: 'domain';
|
|
1390
|
+
records: DomainRecords[];
|
|
1391
|
+
}
|
|
1392
|
+
export type GetDomainResponse = Response<GetDomainResponseSuccess>;
|
|
1393
|
+
//#endregion
|
|
1394
|
+
//#region src/domains/forge/interfaces/enable-forge.interface.d.ts
|
|
1395
|
+
export interface EnableForgeOptions {
|
|
1396
|
+
id: string;
|
|
1397
|
+
customReturnPath?: string;
|
|
1398
|
+
}
|
|
1399
|
+
export interface EnableForgeRequestOptions extends PostOptions {}
|
|
1400
|
+
export interface EnableForgeResponseSuccess extends GetDomainResponseSuccess {}
|
|
1401
|
+
export type EnableForgeResponse = Response<EnableForgeResponseSuccess>;
|
|
1402
|
+
//#endregion
|
|
1375
1403
|
//#region src/domains/interfaces/create-domain-options.interface.d.ts
|
|
1376
1404
|
export interface CreateDomainOptions {
|
|
1377
1405
|
name: string;
|
|
@@ -1390,13 +1418,6 @@ export interface CreateDomainResponseSuccess extends Pick<Domain, 'name' | 'id'
|
|
|
1390
1418
|
}
|
|
1391
1419
|
export type CreateDomainResponse = Response<CreateDomainResponseSuccess>;
|
|
1392
1420
|
//#endregion
|
|
1393
|
-
//#region src/domains/interfaces/get-domain.interface.d.ts
|
|
1394
|
-
export interface GetDomainResponseSuccess extends Pick<Domain, 'id' | 'name' | 'created_at' | 'region' | 'status' | 'capabilities' | 'open_tracking' | 'click_tracking' | 'tracking_subdomain'> {
|
|
1395
|
-
object: 'domain';
|
|
1396
|
-
records: DomainRecords[];
|
|
1397
|
-
}
|
|
1398
|
-
export type GetDomainResponse = Response<GetDomainResponseSuccess>;
|
|
1399
|
-
//#endregion
|
|
1400
1421
|
//#region src/domains/interfaces/list-domains.interface.d.ts
|
|
1401
1422
|
export type ListDomainsOptions = PaginationOptions;
|
|
1402
1423
|
export type ListDomainsResponseSuccess = {
|
|
@@ -1428,6 +1449,15 @@ export type UpdateDomainsResponseSuccess = Pick<Domain, 'id'> & {
|
|
|
1428
1449
|
export type UpdateDomainsResponse = Response<UpdateDomainsResponseSuccess>;
|
|
1429
1450
|
//#endregion
|
|
1430
1451
|
//#region src/domains/interfaces/verify-domain.interface.d.ts
|
|
1452
|
+
export type VerifyDomainsScope = 'forge';
|
|
1453
|
+
export interface VerifyDomainsOptions extends RequestOptions {
|
|
1454
|
+
/**
|
|
1455
|
+
* Limit the check to specific records. Pass `['forge']` to verify only the
|
|
1456
|
+
* Forge record and leave the other records untouched. Requires Forge to be
|
|
1457
|
+
* enabled on the domain. When omitted, all records are checked.
|
|
1458
|
+
*/
|
|
1459
|
+
scope?: VerifyDomainsScope[];
|
|
1460
|
+
}
|
|
1431
1461
|
export type VerifyDomainsResponseSuccess = Pick<Domain, 'id'> & {
|
|
1432
1462
|
object: 'domain';
|
|
1433
1463
|
};
|
|
@@ -1674,7 +1704,14 @@ export interface GetReceivingEmailOptions {
|
|
|
1674
1704
|
}
|
|
1675
1705
|
//#endregion
|
|
1676
1706
|
//#region src/emails/receiving/interfaces/list-receiving-emails.interface.d.ts
|
|
1677
|
-
export type ListReceivingEmailsOptions = PaginationOptions
|
|
1707
|
+
export type ListReceivingEmailsOptions = PaginationOptions & {
|
|
1708
|
+
/** Only return emails received by one of these addresses (exact, case-sensitive match, up to 20). */
|
|
1709
|
+
to?: string[];
|
|
1710
|
+
/** Inclusive lower bound on `created_at`. ISO 8601 date or datetime, read as UTC without an offset. */
|
|
1711
|
+
startDate?: string;
|
|
1712
|
+
/** Upper bound on `created_at`. A bare date (`YYYY-MM-DD`) covers that whole day. */
|
|
1713
|
+
endDate?: string;
|
|
1714
|
+
};
|
|
1678
1715
|
export type ListReceivingEmail = Omit<GetReceivingEmailResponseSuccess, 'html' | 'text' | 'headers' | 'raw' | 'object'>;
|
|
1679
1716
|
export interface ListReceivingEmailsResponseSuccess {
|
|
1680
1717
|
object: 'list';
|
|
@@ -2392,6 +2429,7 @@ declare class AutomationRuns {
|
|
|
2392
2429
|
constructor(resend: Resend);
|
|
2393
2430
|
get(options: GetAutomationRunOptions, requestOptions?: RequestOptions): Promise<GetAutomationRunResponse>;
|
|
2394
2431
|
list(options: ListAutomationRunsOptions, requestOptions?: RequestOptions): Promise<ListAutomationRunsResponse>;
|
|
2432
|
+
cancel(options: CancelAutomationRunOptions, requestOptions?: RequestOptions): Promise<CancelAutomationRunResponse>;
|
|
2395
2433
|
}
|
|
2396
2434
|
//#endregion
|
|
2397
2435
|
//#region src/automations/automations.d.ts
|
|
@@ -2496,17 +2534,25 @@ declare class DomainClaims {
|
|
|
2496
2534
|
verify(domainId: string, requestOptions?: RequestOptions): Promise<VerifyDomainClaimResponse>;
|
|
2497
2535
|
}
|
|
2498
2536
|
//#endregion
|
|
2537
|
+
//#region src/domains/forge/forge.d.ts
|
|
2538
|
+
declare class Forge {
|
|
2539
|
+
private readonly resend;
|
|
2540
|
+
constructor(resend: Resend);
|
|
2541
|
+
enable(payload: EnableForgeOptions, requestOptions?: EnableForgeRequestOptions): Promise<EnableForgeResponse>;
|
|
2542
|
+
}
|
|
2543
|
+
//#endregion
|
|
2499
2544
|
//#region src/domains/domains.d.ts
|
|
2500
2545
|
declare class Domains {
|
|
2501
2546
|
private readonly resend;
|
|
2502
2547
|
readonly claims: DomainClaims;
|
|
2548
|
+
readonly forge: Forge;
|
|
2503
2549
|
constructor(resend: Resend);
|
|
2504
2550
|
create(payload: CreateDomainOptions, requestOptions?: CreateDomainRequestOptions): Promise<CreateDomainResponse>;
|
|
2505
2551
|
list(options?: ListDomainsOptions, requestOptions?: RequestOptions): Promise<ListDomainsResponse>;
|
|
2506
2552
|
get(id: string, requestOptions?: RequestOptions): Promise<GetDomainResponse>;
|
|
2507
2553
|
update(payload: UpdateDomainsOptions, requestOptions?: RequestOptions): Promise<UpdateDomainsResponse>;
|
|
2508
2554
|
remove(id: string, requestOptions?: RequestOptions): Promise<RemoveDomainsResponse>;
|
|
2509
|
-
verify(id: string,
|
|
2555
|
+
verify(id: string, options?: VerifyDomainsOptions): Promise<VerifyDomainsResponse>;
|
|
2510
2556
|
}
|
|
2511
2557
|
//#endregion
|
|
2512
2558
|
//#region src/emails/attachments/attachments.d.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -418,6 +418,18 @@ export interface AutomationRun {
|
|
|
418
418
|
}
|
|
419
419
|
export type AutomationRunItem = Pick<AutomationRun, 'id' | 'status' | 'started_at' | 'completed_at' | 'created_at'>;
|
|
420
420
|
//#endregion
|
|
421
|
+
//#region src/automation-runs/interfaces/cancel-automation-run.interface.d.ts
|
|
422
|
+
export interface CancelAutomationRunOptions {
|
|
423
|
+
automationId: string;
|
|
424
|
+
runId: string;
|
|
425
|
+
}
|
|
426
|
+
export interface CancelAutomationRunResponseSuccess {
|
|
427
|
+
object: 'automation_run';
|
|
428
|
+
id: string;
|
|
429
|
+
status: 'cancelled';
|
|
430
|
+
}
|
|
431
|
+
export type CancelAutomationRunResponse = Response<CancelAutomationRunResponseSuccess>;
|
|
432
|
+
//#endregion
|
|
421
433
|
//#region src/automation-runs/interfaces/get-automation-run.interface.d.ts
|
|
422
434
|
export interface GetAutomationRunOptions {
|
|
423
435
|
automationId: string;
|
|
@@ -1372,6 +1384,22 @@ export interface VerifyDomainClaimResponseSuccess extends DomainClaim {
|
|
|
1372
1384
|
}
|
|
1373
1385
|
export type VerifyDomainClaimResponse = Response<VerifyDomainClaimResponseSuccess>;
|
|
1374
1386
|
//#endregion
|
|
1387
|
+
//#region src/domains/interfaces/get-domain.interface.d.ts
|
|
1388
|
+
export interface GetDomainResponseSuccess extends Pick<Domain, 'id' | 'name' | 'created_at' | 'region' | 'status' | 'capabilities' | 'open_tracking' | 'click_tracking' | 'tracking_subdomain'> {
|
|
1389
|
+
object: 'domain';
|
|
1390
|
+
records: DomainRecords[];
|
|
1391
|
+
}
|
|
1392
|
+
export type GetDomainResponse = Response<GetDomainResponseSuccess>;
|
|
1393
|
+
//#endregion
|
|
1394
|
+
//#region src/domains/forge/interfaces/enable-forge.interface.d.ts
|
|
1395
|
+
export interface EnableForgeOptions {
|
|
1396
|
+
id: string;
|
|
1397
|
+
customReturnPath?: string;
|
|
1398
|
+
}
|
|
1399
|
+
export interface EnableForgeRequestOptions extends PostOptions {}
|
|
1400
|
+
export interface EnableForgeResponseSuccess extends GetDomainResponseSuccess {}
|
|
1401
|
+
export type EnableForgeResponse = Response<EnableForgeResponseSuccess>;
|
|
1402
|
+
//#endregion
|
|
1375
1403
|
//#region src/domains/interfaces/create-domain-options.interface.d.ts
|
|
1376
1404
|
export interface CreateDomainOptions {
|
|
1377
1405
|
name: string;
|
|
@@ -1390,13 +1418,6 @@ export interface CreateDomainResponseSuccess extends Pick<Domain, 'name' | 'id'
|
|
|
1390
1418
|
}
|
|
1391
1419
|
export type CreateDomainResponse = Response<CreateDomainResponseSuccess>;
|
|
1392
1420
|
//#endregion
|
|
1393
|
-
//#region src/domains/interfaces/get-domain.interface.d.ts
|
|
1394
|
-
export interface GetDomainResponseSuccess extends Pick<Domain, 'id' | 'name' | 'created_at' | 'region' | 'status' | 'capabilities' | 'open_tracking' | 'click_tracking' | 'tracking_subdomain'> {
|
|
1395
|
-
object: 'domain';
|
|
1396
|
-
records: DomainRecords[];
|
|
1397
|
-
}
|
|
1398
|
-
export type GetDomainResponse = Response<GetDomainResponseSuccess>;
|
|
1399
|
-
//#endregion
|
|
1400
1421
|
//#region src/domains/interfaces/list-domains.interface.d.ts
|
|
1401
1422
|
export type ListDomainsOptions = PaginationOptions;
|
|
1402
1423
|
export type ListDomainsResponseSuccess = {
|
|
@@ -1428,6 +1449,15 @@ export type UpdateDomainsResponseSuccess = Pick<Domain, 'id'> & {
|
|
|
1428
1449
|
export type UpdateDomainsResponse = Response<UpdateDomainsResponseSuccess>;
|
|
1429
1450
|
//#endregion
|
|
1430
1451
|
//#region src/domains/interfaces/verify-domain.interface.d.ts
|
|
1452
|
+
export type VerifyDomainsScope = 'forge';
|
|
1453
|
+
export interface VerifyDomainsOptions extends RequestOptions {
|
|
1454
|
+
/**
|
|
1455
|
+
* Limit the check to specific records. Pass `['forge']` to verify only the
|
|
1456
|
+
* Forge record and leave the other records untouched. Requires Forge to be
|
|
1457
|
+
* enabled on the domain. When omitted, all records are checked.
|
|
1458
|
+
*/
|
|
1459
|
+
scope?: VerifyDomainsScope[];
|
|
1460
|
+
}
|
|
1431
1461
|
export type VerifyDomainsResponseSuccess = Pick<Domain, 'id'> & {
|
|
1432
1462
|
object: 'domain';
|
|
1433
1463
|
};
|
|
@@ -1674,7 +1704,14 @@ export interface GetReceivingEmailOptions {
|
|
|
1674
1704
|
}
|
|
1675
1705
|
//#endregion
|
|
1676
1706
|
//#region src/emails/receiving/interfaces/list-receiving-emails.interface.d.ts
|
|
1677
|
-
export type ListReceivingEmailsOptions = PaginationOptions
|
|
1707
|
+
export type ListReceivingEmailsOptions = PaginationOptions & {
|
|
1708
|
+
/** Only return emails received by one of these addresses (exact, case-sensitive match, up to 20). */
|
|
1709
|
+
to?: string[];
|
|
1710
|
+
/** Inclusive lower bound on `created_at`. ISO 8601 date or datetime, read as UTC without an offset. */
|
|
1711
|
+
startDate?: string;
|
|
1712
|
+
/** Upper bound on `created_at`. A bare date (`YYYY-MM-DD`) covers that whole day. */
|
|
1713
|
+
endDate?: string;
|
|
1714
|
+
};
|
|
1678
1715
|
export type ListReceivingEmail = Omit<GetReceivingEmailResponseSuccess, 'html' | 'text' | 'headers' | 'raw' | 'object'>;
|
|
1679
1716
|
export interface ListReceivingEmailsResponseSuccess {
|
|
1680
1717
|
object: 'list';
|
|
@@ -2392,6 +2429,7 @@ declare class AutomationRuns {
|
|
|
2392
2429
|
constructor(resend: Resend);
|
|
2393
2430
|
get(options: GetAutomationRunOptions, requestOptions?: RequestOptions): Promise<GetAutomationRunResponse>;
|
|
2394
2431
|
list(options: ListAutomationRunsOptions, requestOptions?: RequestOptions): Promise<ListAutomationRunsResponse>;
|
|
2432
|
+
cancel(options: CancelAutomationRunOptions, requestOptions?: RequestOptions): Promise<CancelAutomationRunResponse>;
|
|
2395
2433
|
}
|
|
2396
2434
|
//#endregion
|
|
2397
2435
|
//#region src/automations/automations.d.ts
|
|
@@ -2496,17 +2534,25 @@ declare class DomainClaims {
|
|
|
2496
2534
|
verify(domainId: string, requestOptions?: RequestOptions): Promise<VerifyDomainClaimResponse>;
|
|
2497
2535
|
}
|
|
2498
2536
|
//#endregion
|
|
2537
|
+
//#region src/domains/forge/forge.d.ts
|
|
2538
|
+
declare class Forge {
|
|
2539
|
+
private readonly resend;
|
|
2540
|
+
constructor(resend: Resend);
|
|
2541
|
+
enable(payload: EnableForgeOptions, requestOptions?: EnableForgeRequestOptions): Promise<EnableForgeResponse>;
|
|
2542
|
+
}
|
|
2543
|
+
//#endregion
|
|
2499
2544
|
//#region src/domains/domains.d.ts
|
|
2500
2545
|
declare class Domains {
|
|
2501
2546
|
private readonly resend;
|
|
2502
2547
|
readonly claims: DomainClaims;
|
|
2548
|
+
readonly forge: Forge;
|
|
2503
2549
|
constructor(resend: Resend);
|
|
2504
2550
|
create(payload: CreateDomainOptions, requestOptions?: CreateDomainRequestOptions): Promise<CreateDomainResponse>;
|
|
2505
2551
|
list(options?: ListDomainsOptions, requestOptions?: RequestOptions): Promise<ListDomainsResponse>;
|
|
2506
2552
|
get(id: string, requestOptions?: RequestOptions): Promise<GetDomainResponse>;
|
|
2507
2553
|
update(payload: UpdateDomainsOptions, requestOptions?: RequestOptions): Promise<UpdateDomainsResponse>;
|
|
2508
2554
|
remove(id: string, requestOptions?: RequestOptions): Promise<RemoveDomainsResponse>;
|
|
2509
|
-
verify(id: string,
|
|
2555
|
+
verify(id: string, options?: VerifyDomainsOptions): Promise<VerifyDomainsResponse>;
|
|
2510
2556
|
}
|
|
2511
2557
|
//#endregion
|
|
2512
2558
|
//#region src/emails/attachments/attachments.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -33,7 +33,7 @@ const MOVE_THREAD_FOLDERS = [
|
|
|
33
33
|
];
|
|
34
34
|
//#endregion
|
|
35
35
|
//#region package.json
|
|
36
|
-
var version = "6.
|
|
36
|
+
var version = "6.40.0";
|
|
37
37
|
//#endregion
|
|
38
38
|
//#region src/common/utils/build-pagination-query.ts
|
|
39
39
|
function buildPaginationUrl(base, options) {
|
|
@@ -92,6 +92,9 @@ var AutomationRuns = class {
|
|
|
92
92
|
const url = qs ? `/automations/${options.automationId}/runs?${qs}` : `/automations/${options.automationId}/runs`;
|
|
93
93
|
return await this.resend.get(url, requestOptions);
|
|
94
94
|
}
|
|
95
|
+
async cancel(options, requestOptions = {}) {
|
|
96
|
+
return await this.resend.post(`/automations/${options.automationId}/runs/${options.runId}/cancel`, void 0, requestOptions);
|
|
97
|
+
}
|
|
95
98
|
};
|
|
96
99
|
//#endregion
|
|
97
100
|
//#region src/common/utils/parse-automation-to-api-options.ts
|
|
@@ -226,13 +229,15 @@ var Automations = class {
|
|
|
226
229
|
}
|
|
227
230
|
};
|
|
228
231
|
//#endregion
|
|
229
|
-
//#region src/common/utils/
|
|
232
|
+
//#region src/common/utils/encode-base64.ts
|
|
230
233
|
function encodeBase64(bytes) {
|
|
231
234
|
if (typeof Buffer !== "undefined") return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("base64");
|
|
232
235
|
let binary = "";
|
|
233
236
|
for (let i = 0; i < bytes.length; i += 32768) binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
|
|
234
237
|
return btoa(binary);
|
|
235
238
|
}
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region src/common/utils/parse-email-to-api-options.ts
|
|
236
241
|
/**
|
|
237
242
|
* JSON.stringify turns a Uint8Array into an object of indexes and an
|
|
238
243
|
* ArrayBuffer into `{}`, so binary content is sent as base64 instead.
|
|
@@ -757,11 +762,22 @@ var DomainClaims = class {
|
|
|
757
762
|
}
|
|
758
763
|
};
|
|
759
764
|
//#endregion
|
|
765
|
+
//#region src/domains/forge/forge.ts
|
|
766
|
+
var Forge = class {
|
|
767
|
+
constructor(resend) {
|
|
768
|
+
this.resend = resend;
|
|
769
|
+
}
|
|
770
|
+
async enable(payload, requestOptions = {}) {
|
|
771
|
+
return await this.resend.post(`/domains/${payload.id}/forge`, { custom_return_path: payload.customReturnPath }, requestOptions);
|
|
772
|
+
}
|
|
773
|
+
};
|
|
774
|
+
//#endregion
|
|
760
775
|
//#region src/domains/domains.ts
|
|
761
776
|
var Domains = class {
|
|
762
777
|
constructor(resend) {
|
|
763
778
|
this.resend = resend;
|
|
764
779
|
this.claims = new DomainClaims(this.resend);
|
|
780
|
+
this.forge = new Forge(this.resend);
|
|
765
781
|
}
|
|
766
782
|
async create(payload, requestOptions = {}) {
|
|
767
783
|
return await this.resend.post("/domains", parseDomainToApiOptions(payload), requestOptions);
|
|
@@ -785,8 +801,9 @@ var Domains = class {
|
|
|
785
801
|
async remove(id, requestOptions = {}) {
|
|
786
802
|
return await this.resend.delete(`/domains/${id}`, void 0, requestOptions);
|
|
787
803
|
}
|
|
788
|
-
async verify(id,
|
|
789
|
-
|
|
804
|
+
async verify(id, options = {}) {
|
|
805
|
+
const { scope, ...requestOptions } = options;
|
|
806
|
+
return await this.resend.post(`/domains/${id}/verify`, scope ? { scope } : void 0, requestOptions);
|
|
790
807
|
}
|
|
791
808
|
};
|
|
792
809
|
//#endregion
|
|
@@ -806,6 +823,17 @@ var Attachments$1 = class {
|
|
|
806
823
|
}
|
|
807
824
|
};
|
|
808
825
|
//#endregion
|
|
826
|
+
//#region src/common/utils/build-query-url.ts
|
|
827
|
+
function buildQueryUrl(base, params = {}) {
|
|
828
|
+
const searchParams = new URLSearchParams();
|
|
829
|
+
for (const [key, value] of Object.entries(params)) {
|
|
830
|
+
if (value === void 0) continue;
|
|
831
|
+
searchParams.set(key, Array.isArray(value) ? value.join(",") : String(value));
|
|
832
|
+
}
|
|
833
|
+
const queryString = searchParams.toString();
|
|
834
|
+
return queryString ? `${base}?${queryString}` : base;
|
|
835
|
+
}
|
|
836
|
+
//#endregion
|
|
809
837
|
//#region src/emails/receiving/attachments/attachments.ts
|
|
810
838
|
var Attachments = class {
|
|
811
839
|
constructor(resend) {
|
|
@@ -836,7 +864,15 @@ var Receiving = class {
|
|
|
836
864
|
return await this.resend.get(path, requestOptions);
|
|
837
865
|
}
|
|
838
866
|
async list(options = {}, requestOptions = {}) {
|
|
839
|
-
const
|
|
867
|
+
const { to, startDate, endDate, limit } = options;
|
|
868
|
+
const url = buildQueryUrl("/emails/receiving", {
|
|
869
|
+
to,
|
|
870
|
+
start_date: startDate,
|
|
871
|
+
end_date: endDate,
|
|
872
|
+
limit,
|
|
873
|
+
after: "after" in options ? options.after : void 0,
|
|
874
|
+
before: "before" in options ? options.before : void 0
|
|
875
|
+
});
|
|
840
876
|
return await this.resend.get(url, requestOptions);
|
|
841
877
|
}
|
|
842
878
|
async forward(options, requestOptions = {}) {
|
|
@@ -925,7 +961,7 @@ var Receiving = class {
|
|
|
925
961
|
html,
|
|
926
962
|
attachments: [{
|
|
927
963
|
filename: "forwarded_message.eml",
|
|
928
|
-
content:
|
|
964
|
+
content: encodeBase64(new Uint8Array(raw.content)),
|
|
929
965
|
content_type: "message/rfc822"
|
|
930
966
|
}]
|
|
931
967
|
}, requestOptions);
|
|
@@ -1075,17 +1111,6 @@ var InboxAgent = class {
|
|
|
1075
1111
|
}
|
|
1076
1112
|
};
|
|
1077
1113
|
//#endregion
|
|
1078
|
-
//#region src/inboxes/build-inbox-cursor-query.ts
|
|
1079
|
-
function buildInboxCursorUrl(base, options = {}) {
|
|
1080
|
-
const searchParams = new URLSearchParams();
|
|
1081
|
-
for (const [key, value] of Object.entries(options)) {
|
|
1082
|
-
if (value === void 0) continue;
|
|
1083
|
-
searchParams.set(key, Array.isArray(value) ? value.join(",") : String(value));
|
|
1084
|
-
}
|
|
1085
|
-
const queryString = searchParams.toString();
|
|
1086
|
-
return queryString ? `${base}?${queryString}` : base;
|
|
1087
|
-
}
|
|
1088
|
-
//#endregion
|
|
1089
1114
|
//#region src/inboxes/drafts/drafts.ts
|
|
1090
1115
|
var InboxDrafts = class {
|
|
1091
1116
|
constructor(resend) {
|
|
@@ -1095,7 +1120,7 @@ var InboxDrafts = class {
|
|
|
1095
1120
|
const inboxPath = buildInboxPath(options);
|
|
1096
1121
|
if (!inboxPath) return missingInboxError();
|
|
1097
1122
|
const { limit, after, before } = options;
|
|
1098
|
-
const url =
|
|
1123
|
+
const url = buildQueryUrl(`${inboxPath}/drafts`, {
|
|
1099
1124
|
limit,
|
|
1100
1125
|
after,
|
|
1101
1126
|
before
|
|
@@ -1261,7 +1286,7 @@ var InboxThreads = class {
|
|
|
1261
1286
|
const inboxPath = buildInboxPath(options);
|
|
1262
1287
|
if (!inboxPath) return missingInboxError();
|
|
1263
1288
|
const { folders, labels, read, limit, after, before } = options;
|
|
1264
|
-
const url =
|
|
1289
|
+
const url = buildQueryUrl(`${inboxPath}/threads`, {
|
|
1265
1290
|
folders,
|
|
1266
1291
|
labels,
|
|
1267
1292
|
read,
|
|
@@ -1275,7 +1300,7 @@ var InboxThreads = class {
|
|
|
1275
1300
|
const inboxPath = buildInboxPath(options);
|
|
1276
1301
|
if (!inboxPath) return missingInboxError();
|
|
1277
1302
|
const { folders, labels, read, query, from, to, cc, bcc, hasAttachment, startDate, endDate, limit, after, before } = options;
|
|
1278
|
-
const url =
|
|
1303
|
+
const url = buildQueryUrl(`${inboxPath}/threads/search`, {
|
|
1279
1304
|
folders,
|
|
1280
1305
|
labels,
|
|
1281
1306
|
read,
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -9,15 +9,14 @@
|
|
|
9
9
|
Framework guides
|
|
10
10
|
</p>
|
|
11
11
|
<p align="center">
|
|
12
|
-
<a
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
- <a href="https://resend.com/docs/send-with-astro">Astro</a>
|
|
12
|
+
<a href="https://resend.com/docs/send-with-nextjs">Next.js</a> ·
|
|
13
|
+
<a href="https://resend.com/docs/send-with-remix">Remix</a> ·
|
|
14
|
+
<a href="https://resend.com/docs/send-with-nuxt">Nuxt</a> ·
|
|
15
|
+
<a href="https://resend.com/docs/send-with-express">Express</a> ·
|
|
16
|
+
<a href="https://resend.com/docs/send-with-redwoodjs">RedwoodJS</a> ·
|
|
17
|
+
<a href="https://resend.com/docs/send-with-hono">Hono</a> ·
|
|
18
|
+
<a href="https://resend.com/docs/send-with-bun">Bun</a> ·
|
|
19
|
+
<a href="https://resend.com/docs/send-with-astro">Astro</a>
|
|
21
20
|
</p>
|
|
22
21
|
|
|
23
22
|
# Resend Node.js SDK
|