resend 6.28.0 → 6.28.1-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 +202 -2
- package/dist/index.d.cts +837 -362
- package/dist/index.d.mts +837 -362
- package/dist/index.mjs +199 -2
- package/package.json +25 -23
- package/readme.md +16 -0
package/dist/index.cjs
CHANGED
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
20
20
|
value: mod,
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
@@ -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.28.0";
|
|
56
|
+
var version = "6.28.1-preview-inboxes.0";
|
|
29
57
|
//#endregion
|
|
30
58
|
//#region src/common/utils/build-pagination-query.ts
|
|
31
59
|
function buildPaginationUrl(base, options) {
|
|
@@ -964,6 +992,174 @@ var Events$1 = class {
|
|
|
964
992
|
}
|
|
965
993
|
};
|
|
966
994
|
//#endregion
|
|
995
|
+
//#region src/inboxes/build-inbox-cursor-query.ts
|
|
996
|
+
function buildInboxCursorUrl(base, options = {}) {
|
|
997
|
+
const searchParams = new URLSearchParams();
|
|
998
|
+
if (options.folder !== void 0) searchParams.set("folder", options.folder);
|
|
999
|
+
if (options.query !== void 0) searchParams.set("query", options.query);
|
|
1000
|
+
if (options.from !== void 0) searchParams.set("from", options.from);
|
|
1001
|
+
if (options.cursor !== void 0) searchParams.set("cursor", options.cursor);
|
|
1002
|
+
const labels = options.label === void 0 ? [] : Array.isArray(options.label) ? options.label : [options.label];
|
|
1003
|
+
for (const label of labels) searchParams.append("label", label);
|
|
1004
|
+
const queryString = searchParams.toString();
|
|
1005
|
+
return queryString ? `${base}?${queryString}` : base;
|
|
1006
|
+
}
|
|
1007
|
+
//#endregion
|
|
1008
|
+
//#region src/inboxes/drafts/drafts.ts
|
|
1009
|
+
var InboxDrafts = class {
|
|
1010
|
+
constructor(resend) {
|
|
1011
|
+
this.resend = resend;
|
|
1012
|
+
}
|
|
1013
|
+
async list(options) {
|
|
1014
|
+
const { inboxId, cursor } = options;
|
|
1015
|
+
const url = buildInboxCursorUrl(`/inboxes/${inboxId}/drafts`, { cursor });
|
|
1016
|
+
return this.resend.get(url);
|
|
1017
|
+
}
|
|
1018
|
+
async create(payload, options = {}) {
|
|
1019
|
+
const { inboxId, threadId, replyToEmailId, ...content } = payload;
|
|
1020
|
+
return this.resend.post(`/inboxes/${inboxId}/drafts`, {
|
|
1021
|
+
...content,
|
|
1022
|
+
thread_id: threadId,
|
|
1023
|
+
reply_to_email_id: replyToEmailId
|
|
1024
|
+
}, options);
|
|
1025
|
+
}
|
|
1026
|
+
async get(options) {
|
|
1027
|
+
const { inboxId, draftId } = options;
|
|
1028
|
+
return this.resend.get(`/inboxes/${inboxId}/drafts/${draftId}`);
|
|
1029
|
+
}
|
|
1030
|
+
async update(options) {
|
|
1031
|
+
const { inboxId, draftId, ...content } = options;
|
|
1032
|
+
return this.resend.patch(`/inboxes/${inboxId}/drafts/${draftId}`, content);
|
|
1033
|
+
}
|
|
1034
|
+
async remove(options) {
|
|
1035
|
+
const { inboxId, draftId } = options;
|
|
1036
|
+
return this.resend.delete(`/inboxes/${inboxId}/drafts/${draftId}`);
|
|
1037
|
+
}
|
|
1038
|
+
async send(payload, options = {}) {
|
|
1039
|
+
const { inboxId, draftId } = payload;
|
|
1040
|
+
return this.resend.post(`/inboxes/${inboxId}/drafts/${draftId}/send`, void 0, options);
|
|
1041
|
+
}
|
|
1042
|
+
};
|
|
1043
|
+
//#endregion
|
|
1044
|
+
//#region src/inboxes/labels/labels.ts
|
|
1045
|
+
var InboxLabels = class {
|
|
1046
|
+
constructor(resend) {
|
|
1047
|
+
this.resend = resend;
|
|
1048
|
+
}
|
|
1049
|
+
async list(options) {
|
|
1050
|
+
return this.resend.get(`/inboxes/${options.inboxId}/labels`);
|
|
1051
|
+
}
|
|
1052
|
+
async create(payload, options = {}) {
|
|
1053
|
+
const { inboxId, name, color } = payload;
|
|
1054
|
+
return this.resend.post(`/inboxes/${inboxId}/labels`, {
|
|
1055
|
+
name,
|
|
1056
|
+
color
|
|
1057
|
+
}, options);
|
|
1058
|
+
}
|
|
1059
|
+
async update(options) {
|
|
1060
|
+
const { inboxId, labelId, name, color } = options;
|
|
1061
|
+
return this.resend.patch(`/inboxes/${inboxId}/labels/${labelId}`, {
|
|
1062
|
+
name,
|
|
1063
|
+
color
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
async remove(options) {
|
|
1067
|
+
const { inboxId, labelId } = options;
|
|
1068
|
+
return this.resend.delete(`/inboxes/${inboxId}/labels/${labelId}`);
|
|
1069
|
+
}
|
|
1070
|
+
};
|
|
1071
|
+
//#endregion
|
|
1072
|
+
//#region src/inboxes/threads/emails/emails.ts
|
|
1073
|
+
var InboxThreadEmails = class {
|
|
1074
|
+
constructor(resend) {
|
|
1075
|
+
this.resend = resend;
|
|
1076
|
+
}
|
|
1077
|
+
async get(options) {
|
|
1078
|
+
const { inboxId, threadId, emailId } = options;
|
|
1079
|
+
return this.resend.get(`/inboxes/${inboxId}/threads/${threadId}/emails/${emailId}`);
|
|
1080
|
+
}
|
|
1081
|
+
async reply(payload, options = {}) {
|
|
1082
|
+
const { inboxId, threadId, emailId, html, text, subject } = payload;
|
|
1083
|
+
return this.resend.post(`/inboxes/${inboxId}/threads/${threadId}/emails/${emailId}/reply`, {
|
|
1084
|
+
html,
|
|
1085
|
+
text,
|
|
1086
|
+
subject
|
|
1087
|
+
}, options);
|
|
1088
|
+
}
|
|
1089
|
+
async forward(payload, options = {}) {
|
|
1090
|
+
const { inboxId, threadId, emailId, to, html, text, subject } = payload;
|
|
1091
|
+
return this.resend.post(`/inboxes/${inboxId}/threads/${threadId}/emails/${emailId}/forward`, {
|
|
1092
|
+
to,
|
|
1093
|
+
html,
|
|
1094
|
+
text,
|
|
1095
|
+
subject
|
|
1096
|
+
}, options);
|
|
1097
|
+
}
|
|
1098
|
+
};
|
|
1099
|
+
//#endregion
|
|
1100
|
+
//#region src/inboxes/threads/threads.ts
|
|
1101
|
+
var InboxThreads = class {
|
|
1102
|
+
constructor(resend) {
|
|
1103
|
+
this.resend = resend;
|
|
1104
|
+
this.emails = new InboxThreadEmails(resend);
|
|
1105
|
+
}
|
|
1106
|
+
async list(options) {
|
|
1107
|
+
const { inboxId, ...query } = options;
|
|
1108
|
+
const url = buildInboxCursorUrl(`/inboxes/${inboxId}/threads`, query);
|
|
1109
|
+
return this.resend.get(url);
|
|
1110
|
+
}
|
|
1111
|
+
async get(options) {
|
|
1112
|
+
const { inboxId, threadId } = options;
|
|
1113
|
+
return this.resend.get(`/inboxes/${inboxId}/threads/${threadId}`);
|
|
1114
|
+
}
|
|
1115
|
+
async update(options) {
|
|
1116
|
+
const { inboxId, threadId, read, folder, labelId } = options;
|
|
1117
|
+
return this.resend.patch(`/inboxes/${inboxId}/threads/${threadId}`, {
|
|
1118
|
+
read,
|
|
1119
|
+
folder,
|
|
1120
|
+
label_id: labelId
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1123
|
+
async remove(options) {
|
|
1124
|
+
const { inboxId, threadId } = options;
|
|
1125
|
+
return this.resend.delete(`/inboxes/${inboxId}/threads/${threadId}`);
|
|
1126
|
+
}
|
|
1127
|
+
};
|
|
1128
|
+
//#endregion
|
|
1129
|
+
//#region src/inboxes/inboxes.ts
|
|
1130
|
+
var Inboxes = class {
|
|
1131
|
+
constructor(resend) {
|
|
1132
|
+
this.resend = resend;
|
|
1133
|
+
this.threads = new InboxThreads(resend);
|
|
1134
|
+
this.labels = new InboxLabels(resend);
|
|
1135
|
+
this.drafts = new InboxDrafts(resend);
|
|
1136
|
+
}
|
|
1137
|
+
async create(payload, options = {}) {
|
|
1138
|
+
return this.resend.post("/inboxes", {
|
|
1139
|
+
email_address: payload.emailAddress,
|
|
1140
|
+
name: payload.name,
|
|
1141
|
+
forwarding: payload.forwarding,
|
|
1142
|
+
friendly_name: payload.friendlyName
|
|
1143
|
+
}, options);
|
|
1144
|
+
}
|
|
1145
|
+
async list(options = {}) {
|
|
1146
|
+
const url = buildPaginationUrl("/inboxes", options);
|
|
1147
|
+
return this.resend.get(url);
|
|
1148
|
+
}
|
|
1149
|
+
async get(id) {
|
|
1150
|
+
return this.resend.get(`/inboxes/${id}`);
|
|
1151
|
+
}
|
|
1152
|
+
async update(id, payload) {
|
|
1153
|
+
return this.resend.patch(`/inboxes/${id}`, {
|
|
1154
|
+
name: payload.name,
|
|
1155
|
+
friendly_name: payload.friendlyName
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
1158
|
+
async remove(id) {
|
|
1159
|
+
return this.resend.delete(`/inboxes/${id}`);
|
|
1160
|
+
}
|
|
1161
|
+
};
|
|
1162
|
+
//#endregion
|
|
967
1163
|
//#region src/logs/logs.ts
|
|
968
1164
|
var Logs = class {
|
|
969
1165
|
constructor(resend) {
|
|
@@ -1293,6 +1489,7 @@ var Resend = class {
|
|
|
1293
1489
|
this.domains = new Domains(this);
|
|
1294
1490
|
this.emails = new Emails(this);
|
|
1295
1491
|
this.events = new Events$1(this);
|
|
1492
|
+
this.inboxes = new Inboxes(this);
|
|
1296
1493
|
this.logs = new Logs(this);
|
|
1297
1494
|
this.oauthGrants = new OAuthGrants(this);
|
|
1298
1495
|
this.suppressions = new Suppressions(this);
|
|
@@ -1446,4 +1643,7 @@ var Resend = class {
|
|
|
1446
1643
|
}
|
|
1447
1644
|
};
|
|
1448
1645
|
//#endregion
|
|
1646
|
+
exports.INBOX_LABEL_COLORS = INBOX_LABEL_COLORS;
|
|
1647
|
+
exports.INBOX_MESSAGE_FOLDERS = INBOX_MESSAGE_FOLDERS;
|
|
1648
|
+
exports.MOVE_THREAD_FOLDERS = MOVE_THREAD_FOLDERS;
|
|
1449
1649
|
exports.Resend = Resend;
|