resend 6.39.0 → 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 +28 -18
- package/dist/index.d.cts +8 -1
- package/dist/index.d.mts +8 -1
- package/dist/index.mjs +28 -18
- package/package.json +1 -1
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) {
|
|
@@ -253,13 +253,15 @@ var Automations = class {
|
|
|
253
253
|
}
|
|
254
254
|
};
|
|
255
255
|
//#endregion
|
|
256
|
-
//#region src/common/utils/
|
|
256
|
+
//#region src/common/utils/encode-base64.ts
|
|
257
257
|
function encodeBase64(bytes) {
|
|
258
258
|
if (typeof Buffer !== "undefined") return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("base64");
|
|
259
259
|
let binary = "";
|
|
260
260
|
for (let i = 0; i < bytes.length; i += 32768) binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
|
|
261
261
|
return btoa(binary);
|
|
262
262
|
}
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/common/utils/parse-email-to-api-options.ts
|
|
263
265
|
/**
|
|
264
266
|
* JSON.stringify turns a Uint8Array into an object of indexes and an
|
|
265
267
|
* ArrayBuffer into `{}`, so binary content is sent as base64 instead.
|
|
@@ -845,6 +847,17 @@ var Attachments$1 = class {
|
|
|
845
847
|
}
|
|
846
848
|
};
|
|
847
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
|
|
848
861
|
//#region src/emails/receiving/attachments/attachments.ts
|
|
849
862
|
var Attachments = class {
|
|
850
863
|
constructor(resend) {
|
|
@@ -875,7 +888,15 @@ var Receiving = class {
|
|
|
875
888
|
return await this.resend.get(path, requestOptions);
|
|
876
889
|
}
|
|
877
890
|
async list(options = {}, requestOptions = {}) {
|
|
878
|
-
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
|
+
});
|
|
879
900
|
return await this.resend.get(url, requestOptions);
|
|
880
901
|
}
|
|
881
902
|
async forward(options, requestOptions = {}) {
|
|
@@ -964,7 +985,7 @@ var Receiving = class {
|
|
|
964
985
|
html,
|
|
965
986
|
attachments: [{
|
|
966
987
|
filename: "forwarded_message.eml",
|
|
967
|
-
content:
|
|
988
|
+
content: encodeBase64(new Uint8Array(raw.content)),
|
|
968
989
|
content_type: "message/rfc822"
|
|
969
990
|
}]
|
|
970
991
|
}, requestOptions);
|
|
@@ -1114,17 +1135,6 @@ var InboxAgent = class {
|
|
|
1114
1135
|
}
|
|
1115
1136
|
};
|
|
1116
1137
|
//#endregion
|
|
1117
|
-
//#region src/inboxes/build-inbox-cursor-query.ts
|
|
1118
|
-
function buildInboxCursorUrl(base, options = {}) {
|
|
1119
|
-
const searchParams = new URLSearchParams();
|
|
1120
|
-
for (const [key, value] of Object.entries(options)) {
|
|
1121
|
-
if (value === void 0) continue;
|
|
1122
|
-
searchParams.set(key, Array.isArray(value) ? value.join(",") : String(value));
|
|
1123
|
-
}
|
|
1124
|
-
const queryString = searchParams.toString();
|
|
1125
|
-
return queryString ? `${base}?${queryString}` : base;
|
|
1126
|
-
}
|
|
1127
|
-
//#endregion
|
|
1128
1138
|
//#region src/inboxes/drafts/drafts.ts
|
|
1129
1139
|
var InboxDrafts = class {
|
|
1130
1140
|
constructor(resend) {
|
|
@@ -1134,7 +1144,7 @@ var InboxDrafts = class {
|
|
|
1134
1144
|
const inboxPath = buildInboxPath(options);
|
|
1135
1145
|
if (!inboxPath) return missingInboxError();
|
|
1136
1146
|
const { limit, after, before } = options;
|
|
1137
|
-
const url =
|
|
1147
|
+
const url = buildQueryUrl(`${inboxPath}/drafts`, {
|
|
1138
1148
|
limit,
|
|
1139
1149
|
after,
|
|
1140
1150
|
before
|
|
@@ -1300,7 +1310,7 @@ var InboxThreads = class {
|
|
|
1300
1310
|
const inboxPath = buildInboxPath(options);
|
|
1301
1311
|
if (!inboxPath) return missingInboxError();
|
|
1302
1312
|
const { folders, labels, read, limit, after, before } = options;
|
|
1303
|
-
const url =
|
|
1313
|
+
const url = buildQueryUrl(`${inboxPath}/threads`, {
|
|
1304
1314
|
folders,
|
|
1305
1315
|
labels,
|
|
1306
1316
|
read,
|
|
@@ -1314,7 +1324,7 @@ var InboxThreads = class {
|
|
|
1314
1324
|
const inboxPath = buildInboxPath(options);
|
|
1315
1325
|
if (!inboxPath) return missingInboxError();
|
|
1316
1326
|
const { folders, labels, read, query, from, to, cc, bcc, hasAttachment, startDate, endDate, limit, after, before } = options;
|
|
1317
|
-
const url =
|
|
1327
|
+
const url = buildQueryUrl(`${inboxPath}/threads/search`, {
|
|
1318
1328
|
folders,
|
|
1319
1329
|
labels,
|
|
1320
1330
|
read,
|
package/dist/index.d.cts
CHANGED
|
@@ -1704,7 +1704,14 @@ export interface GetReceivingEmailOptions {
|
|
|
1704
1704
|
}
|
|
1705
1705
|
//#endregion
|
|
1706
1706
|
//#region src/emails/receiving/interfaces/list-receiving-emails.interface.d.ts
|
|
1707
|
-
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
|
+
};
|
|
1708
1715
|
export type ListReceivingEmail = Omit<GetReceivingEmailResponseSuccess, 'html' | 'text' | 'headers' | 'raw' | 'object'>;
|
|
1709
1716
|
export interface ListReceivingEmailsResponseSuccess {
|
|
1710
1717
|
object: 'list';
|
package/dist/index.d.mts
CHANGED
|
@@ -1704,7 +1704,14 @@ export interface GetReceivingEmailOptions {
|
|
|
1704
1704
|
}
|
|
1705
1705
|
//#endregion
|
|
1706
1706
|
//#region src/emails/receiving/interfaces/list-receiving-emails.interface.d.ts
|
|
1707
|
-
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
|
+
};
|
|
1708
1715
|
export type ListReceivingEmail = Omit<GetReceivingEmailResponseSuccess, 'html' | 'text' | 'headers' | 'raw' | 'object'>;
|
|
1709
1716
|
export interface ListReceivingEmailsResponseSuccess {
|
|
1710
1717
|
object: 'list';
|
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) {
|
|
@@ -229,13 +229,15 @@ var Automations = class {
|
|
|
229
229
|
}
|
|
230
230
|
};
|
|
231
231
|
//#endregion
|
|
232
|
-
//#region src/common/utils/
|
|
232
|
+
//#region src/common/utils/encode-base64.ts
|
|
233
233
|
function encodeBase64(bytes) {
|
|
234
234
|
if (typeof Buffer !== "undefined") return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("base64");
|
|
235
235
|
let binary = "";
|
|
236
236
|
for (let i = 0; i < bytes.length; i += 32768) binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
|
|
237
237
|
return btoa(binary);
|
|
238
238
|
}
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region src/common/utils/parse-email-to-api-options.ts
|
|
239
241
|
/**
|
|
240
242
|
* JSON.stringify turns a Uint8Array into an object of indexes and an
|
|
241
243
|
* ArrayBuffer into `{}`, so binary content is sent as base64 instead.
|
|
@@ -821,6 +823,17 @@ var Attachments$1 = class {
|
|
|
821
823
|
}
|
|
822
824
|
};
|
|
823
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
|
|
824
837
|
//#region src/emails/receiving/attachments/attachments.ts
|
|
825
838
|
var Attachments = class {
|
|
826
839
|
constructor(resend) {
|
|
@@ -851,7 +864,15 @@ var Receiving = class {
|
|
|
851
864
|
return await this.resend.get(path, requestOptions);
|
|
852
865
|
}
|
|
853
866
|
async list(options = {}, requestOptions = {}) {
|
|
854
|
-
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
|
+
});
|
|
855
876
|
return await this.resend.get(url, requestOptions);
|
|
856
877
|
}
|
|
857
878
|
async forward(options, requestOptions = {}) {
|
|
@@ -940,7 +961,7 @@ var Receiving = class {
|
|
|
940
961
|
html,
|
|
941
962
|
attachments: [{
|
|
942
963
|
filename: "forwarded_message.eml",
|
|
943
|
-
content:
|
|
964
|
+
content: encodeBase64(new Uint8Array(raw.content)),
|
|
944
965
|
content_type: "message/rfc822"
|
|
945
966
|
}]
|
|
946
967
|
}, requestOptions);
|
|
@@ -1090,17 +1111,6 @@ var InboxAgent = class {
|
|
|
1090
1111
|
}
|
|
1091
1112
|
};
|
|
1092
1113
|
//#endregion
|
|
1093
|
-
//#region src/inboxes/build-inbox-cursor-query.ts
|
|
1094
|
-
function buildInboxCursorUrl(base, options = {}) {
|
|
1095
|
-
const searchParams = new URLSearchParams();
|
|
1096
|
-
for (const [key, value] of Object.entries(options)) {
|
|
1097
|
-
if (value === void 0) continue;
|
|
1098
|
-
searchParams.set(key, Array.isArray(value) ? value.join(",") : String(value));
|
|
1099
|
-
}
|
|
1100
|
-
const queryString = searchParams.toString();
|
|
1101
|
-
return queryString ? `${base}?${queryString}` : base;
|
|
1102
|
-
}
|
|
1103
|
-
//#endregion
|
|
1104
1114
|
//#region src/inboxes/drafts/drafts.ts
|
|
1105
1115
|
var InboxDrafts = class {
|
|
1106
1116
|
constructor(resend) {
|
|
@@ -1110,7 +1120,7 @@ var InboxDrafts = class {
|
|
|
1110
1120
|
const inboxPath = buildInboxPath(options);
|
|
1111
1121
|
if (!inboxPath) return missingInboxError();
|
|
1112
1122
|
const { limit, after, before } = options;
|
|
1113
|
-
const url =
|
|
1123
|
+
const url = buildQueryUrl(`${inboxPath}/drafts`, {
|
|
1114
1124
|
limit,
|
|
1115
1125
|
after,
|
|
1116
1126
|
before
|
|
@@ -1276,7 +1286,7 @@ var InboxThreads = class {
|
|
|
1276
1286
|
const inboxPath = buildInboxPath(options);
|
|
1277
1287
|
if (!inboxPath) return missingInboxError();
|
|
1278
1288
|
const { folders, labels, read, limit, after, before } = options;
|
|
1279
|
-
const url =
|
|
1289
|
+
const url = buildQueryUrl(`${inboxPath}/threads`, {
|
|
1280
1290
|
folders,
|
|
1281
1291
|
labels,
|
|
1282
1292
|
read,
|
|
@@ -1290,7 +1300,7 @@ var InboxThreads = class {
|
|
|
1290
1300
|
const inboxPath = buildInboxPath(options);
|
|
1291
1301
|
if (!inboxPath) return missingInboxError();
|
|
1292
1302
|
const { folders, labels, read, query, from, to, cc, bcc, hasAttachment, startDate, endDate, limit, after, before } = options;
|
|
1293
|
-
const url =
|
|
1303
|
+
const url = buildQueryUrl(`${inboxPath}/threads/search`, {
|
|
1294
1304
|
folders,
|
|
1295
1305
|
labels,
|
|
1296
1306
|
read,
|