resend 6.26.0 → 6.28.0-preview-inboxes.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 +204 -1
- package/dist/index.d.cts +485 -1
- package/dist/index.d.mts +485 -1
- package/dist/index.mjs +202 -2
- package/package.json +16 -14
- package/readme.md +16 -0
package/dist/index.cjs
CHANGED
|
@@ -24,8 +24,36 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
let postal_mime = require("postal-mime");
|
|
25
25
|
postal_mime = __toESM(postal_mime);
|
|
26
26
|
let standardwebhooks = require("standardwebhooks");
|
|
27
|
+
//#region src/inboxes/interfaces/inbox.ts
|
|
28
|
+
const INBOX_MESSAGE_FOLDERS = [
|
|
29
|
+
"inbox",
|
|
30
|
+
"archive",
|
|
31
|
+
"spam",
|
|
32
|
+
"sent",
|
|
33
|
+
"trash"
|
|
34
|
+
];
|
|
35
|
+
const MOVE_THREAD_FOLDERS = [
|
|
36
|
+
"inbox",
|
|
37
|
+
"archive",
|
|
38
|
+
"spam",
|
|
39
|
+
"trash"
|
|
40
|
+
];
|
|
41
|
+
const INBOX_LABEL_COLORS = [
|
|
42
|
+
"cyan",
|
|
43
|
+
"teal",
|
|
44
|
+
"grass",
|
|
45
|
+
"lime",
|
|
46
|
+
"yellow",
|
|
47
|
+
"orange",
|
|
48
|
+
"iris",
|
|
49
|
+
"plum",
|
|
50
|
+
"crimson",
|
|
51
|
+
"bronze",
|
|
52
|
+
"mauve"
|
|
53
|
+
];
|
|
54
|
+
//#endregion
|
|
27
55
|
//#region package.json
|
|
28
|
-
var version = "6.
|
|
56
|
+
var version = "6.28.0-preview-inboxes.0";
|
|
29
57
|
//#endregion
|
|
30
58
|
//#region src/common/utils/build-pagination-query.ts
|
|
31
59
|
function buildPaginationUrl(base, options) {
|
|
@@ -961,6 +989,174 @@ var Events$1 = class {
|
|
|
961
989
|
}
|
|
962
990
|
};
|
|
963
991
|
//#endregion
|
|
992
|
+
//#region src/inboxes/build-inbox-cursor-query.ts
|
|
993
|
+
function buildInboxCursorUrl(base, options = {}) {
|
|
994
|
+
const searchParams = new URLSearchParams();
|
|
995
|
+
if (options.folder !== void 0) searchParams.set("folder", options.folder);
|
|
996
|
+
if (options.query !== void 0) searchParams.set("query", options.query);
|
|
997
|
+
if (options.from !== void 0) searchParams.set("from", options.from);
|
|
998
|
+
if (options.cursor !== void 0) searchParams.set("cursor", options.cursor);
|
|
999
|
+
const labels = options.label === void 0 ? [] : Array.isArray(options.label) ? options.label : [options.label];
|
|
1000
|
+
for (const label of labels) searchParams.append("label", label);
|
|
1001
|
+
const queryString = searchParams.toString();
|
|
1002
|
+
return queryString ? `${base}?${queryString}` : base;
|
|
1003
|
+
}
|
|
1004
|
+
//#endregion
|
|
1005
|
+
//#region src/inboxes/drafts/drafts.ts
|
|
1006
|
+
var InboxDrafts = class {
|
|
1007
|
+
constructor(resend) {
|
|
1008
|
+
this.resend = resend;
|
|
1009
|
+
}
|
|
1010
|
+
async list(options) {
|
|
1011
|
+
const { inboxId, cursor } = options;
|
|
1012
|
+
const url = buildInboxCursorUrl(`/inboxes/${inboxId}/drafts`, { cursor });
|
|
1013
|
+
return this.resend.get(url);
|
|
1014
|
+
}
|
|
1015
|
+
async create(payload, options = {}) {
|
|
1016
|
+
const { inboxId, threadId, replyToEmailId, ...content } = payload;
|
|
1017
|
+
return this.resend.post(`/inboxes/${inboxId}/drafts`, {
|
|
1018
|
+
...content,
|
|
1019
|
+
thread_id: threadId,
|
|
1020
|
+
reply_to_email_id: replyToEmailId
|
|
1021
|
+
}, options);
|
|
1022
|
+
}
|
|
1023
|
+
async get(options) {
|
|
1024
|
+
const { inboxId, draftId } = options;
|
|
1025
|
+
return this.resend.get(`/inboxes/${inboxId}/drafts/${draftId}`);
|
|
1026
|
+
}
|
|
1027
|
+
async update(options) {
|
|
1028
|
+
const { inboxId, draftId, ...content } = options;
|
|
1029
|
+
return this.resend.patch(`/inboxes/${inboxId}/drafts/${draftId}`, content);
|
|
1030
|
+
}
|
|
1031
|
+
async remove(options) {
|
|
1032
|
+
const { inboxId, draftId } = options;
|
|
1033
|
+
return this.resend.delete(`/inboxes/${inboxId}/drafts/${draftId}`);
|
|
1034
|
+
}
|
|
1035
|
+
async send(payload, options = {}) {
|
|
1036
|
+
const { inboxId, draftId } = payload;
|
|
1037
|
+
return this.resend.post(`/inboxes/${inboxId}/drafts/${draftId}/send`, void 0, options);
|
|
1038
|
+
}
|
|
1039
|
+
};
|
|
1040
|
+
//#endregion
|
|
1041
|
+
//#region src/inboxes/labels/labels.ts
|
|
1042
|
+
var InboxLabels = class {
|
|
1043
|
+
constructor(resend) {
|
|
1044
|
+
this.resend = resend;
|
|
1045
|
+
}
|
|
1046
|
+
async list(options) {
|
|
1047
|
+
return this.resend.get(`/inboxes/${options.inboxId}/labels`);
|
|
1048
|
+
}
|
|
1049
|
+
async create(payload, options = {}) {
|
|
1050
|
+
const { inboxId, name, color } = payload;
|
|
1051
|
+
return this.resend.post(`/inboxes/${inboxId}/labels`, {
|
|
1052
|
+
name,
|
|
1053
|
+
color
|
|
1054
|
+
}, options);
|
|
1055
|
+
}
|
|
1056
|
+
async update(options) {
|
|
1057
|
+
const { inboxId, labelId, name, color } = options;
|
|
1058
|
+
return this.resend.patch(`/inboxes/${inboxId}/labels/${labelId}`, {
|
|
1059
|
+
name,
|
|
1060
|
+
color
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1063
|
+
async remove(options) {
|
|
1064
|
+
const { inboxId, labelId } = options;
|
|
1065
|
+
return this.resend.delete(`/inboxes/${inboxId}/labels/${labelId}`);
|
|
1066
|
+
}
|
|
1067
|
+
};
|
|
1068
|
+
//#endregion
|
|
1069
|
+
//#region src/inboxes/threads/emails/emails.ts
|
|
1070
|
+
var InboxThreadEmails = class {
|
|
1071
|
+
constructor(resend) {
|
|
1072
|
+
this.resend = resend;
|
|
1073
|
+
}
|
|
1074
|
+
async get(options) {
|
|
1075
|
+
const { inboxId, threadId, emailId } = options;
|
|
1076
|
+
return this.resend.get(`/inboxes/${inboxId}/threads/${threadId}/emails/${emailId}`);
|
|
1077
|
+
}
|
|
1078
|
+
async reply(payload, options = {}) {
|
|
1079
|
+
const { inboxId, threadId, emailId, html, text, subject } = payload;
|
|
1080
|
+
return this.resend.post(`/inboxes/${inboxId}/threads/${threadId}/emails/${emailId}/reply`, {
|
|
1081
|
+
html,
|
|
1082
|
+
text,
|
|
1083
|
+
subject
|
|
1084
|
+
}, options);
|
|
1085
|
+
}
|
|
1086
|
+
async forward(payload, options = {}) {
|
|
1087
|
+
const { inboxId, threadId, emailId, to, html, text, subject } = payload;
|
|
1088
|
+
return this.resend.post(`/inboxes/${inboxId}/threads/${threadId}/emails/${emailId}/forward`, {
|
|
1089
|
+
to,
|
|
1090
|
+
html,
|
|
1091
|
+
text,
|
|
1092
|
+
subject
|
|
1093
|
+
}, options);
|
|
1094
|
+
}
|
|
1095
|
+
};
|
|
1096
|
+
//#endregion
|
|
1097
|
+
//#region src/inboxes/threads/threads.ts
|
|
1098
|
+
var InboxThreads = class {
|
|
1099
|
+
constructor(resend) {
|
|
1100
|
+
this.resend = resend;
|
|
1101
|
+
this.emails = new InboxThreadEmails(resend);
|
|
1102
|
+
}
|
|
1103
|
+
async list(options) {
|
|
1104
|
+
const { inboxId, ...query } = options;
|
|
1105
|
+
const url = buildInboxCursorUrl(`/inboxes/${inboxId}/threads`, query);
|
|
1106
|
+
return this.resend.get(url);
|
|
1107
|
+
}
|
|
1108
|
+
async get(options) {
|
|
1109
|
+
const { inboxId, threadId } = options;
|
|
1110
|
+
return this.resend.get(`/inboxes/${inboxId}/threads/${threadId}`);
|
|
1111
|
+
}
|
|
1112
|
+
async update(options) {
|
|
1113
|
+
const { inboxId, threadId, read, folder, labelId } = options;
|
|
1114
|
+
return this.resend.patch(`/inboxes/${inboxId}/threads/${threadId}`, {
|
|
1115
|
+
read,
|
|
1116
|
+
folder,
|
|
1117
|
+
label_id: labelId
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
async remove(options) {
|
|
1121
|
+
const { inboxId, threadId } = options;
|
|
1122
|
+
return this.resend.delete(`/inboxes/${inboxId}/threads/${threadId}`);
|
|
1123
|
+
}
|
|
1124
|
+
};
|
|
1125
|
+
//#endregion
|
|
1126
|
+
//#region src/inboxes/inboxes.ts
|
|
1127
|
+
var Inboxes = class {
|
|
1128
|
+
constructor(resend) {
|
|
1129
|
+
this.resend = resend;
|
|
1130
|
+
this.threads = new InboxThreads(resend);
|
|
1131
|
+
this.labels = new InboxLabels(resend);
|
|
1132
|
+
this.drafts = new InboxDrafts(resend);
|
|
1133
|
+
}
|
|
1134
|
+
async create(payload, options = {}) {
|
|
1135
|
+
return this.resend.post("/inboxes", {
|
|
1136
|
+
email_address: payload.emailAddress,
|
|
1137
|
+
name: payload.name,
|
|
1138
|
+
forwarding: payload.forwarding,
|
|
1139
|
+
friendly_name: payload.friendlyName
|
|
1140
|
+
}, options);
|
|
1141
|
+
}
|
|
1142
|
+
async list(options = {}) {
|
|
1143
|
+
const url = buildPaginationUrl("/inboxes", options);
|
|
1144
|
+
return this.resend.get(url);
|
|
1145
|
+
}
|
|
1146
|
+
async get(id) {
|
|
1147
|
+
return this.resend.get(`/inboxes/${id}`);
|
|
1148
|
+
}
|
|
1149
|
+
async update(id, payload) {
|
|
1150
|
+
return this.resend.patch(`/inboxes/${id}`, {
|
|
1151
|
+
name: payload.name,
|
|
1152
|
+
friendly_name: payload.friendlyName
|
|
1153
|
+
});
|
|
1154
|
+
}
|
|
1155
|
+
async remove(id) {
|
|
1156
|
+
return this.resend.delete(`/inboxes/${id}`);
|
|
1157
|
+
}
|
|
1158
|
+
};
|
|
1159
|
+
//#endregion
|
|
964
1160
|
//#region src/logs/logs.ts
|
|
965
1161
|
var Logs = class {
|
|
966
1162
|
constructor(resend) {
|
|
@@ -1255,6 +1451,9 @@ var Webhooks = class {
|
|
|
1255
1451
|
async remove(id) {
|
|
1256
1452
|
return await this.resend.delete(`/webhooks/${id}`);
|
|
1257
1453
|
}
|
|
1454
|
+
async rotateSigningSecret(id) {
|
|
1455
|
+
return await this.resend.post(`/webhooks/${id}/signing-secret/rotate`);
|
|
1456
|
+
}
|
|
1258
1457
|
verify(payload) {
|
|
1259
1458
|
return new standardwebhooks.Webhook(payload.webhookSecret).verify(payload.payload, {
|
|
1260
1459
|
"webhook-id": payload.headers.id,
|
|
@@ -1287,6 +1486,7 @@ var Resend = class {
|
|
|
1287
1486
|
this.domains = new Domains(this);
|
|
1288
1487
|
this.emails = new Emails(this);
|
|
1289
1488
|
this.events = new Events$1(this);
|
|
1489
|
+
this.inboxes = new Inboxes(this);
|
|
1290
1490
|
this.logs = new Logs(this);
|
|
1291
1491
|
this.oauthGrants = new OAuthGrants(this);
|
|
1292
1492
|
this.suppressions = new Suppressions(this);
|
|
@@ -1440,4 +1640,7 @@ var Resend = class {
|
|
|
1440
1640
|
}
|
|
1441
1641
|
};
|
|
1442
1642
|
//#endregion
|
|
1643
|
+
exports.INBOX_LABEL_COLORS = INBOX_LABEL_COLORS;
|
|
1644
|
+
exports.INBOX_MESSAGE_FOLDERS = INBOX_MESSAGE_FOLDERS;
|
|
1645
|
+
exports.MOVE_THREAD_FOLDERS = MOVE_THREAD_FOLDERS;
|
|
1443
1646
|
exports.Resend = Resend;
|