resend 6.32.1 → 6.33.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 CHANGED
@@ -24,8 +24,34 @@ 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/agent/interfaces/agent.ts
28
+ const INBOX_AGENT_ACTIONS = [
29
+ "draft_reply",
30
+ "forward_thread",
31
+ "add_labels",
32
+ "assign_thread",
33
+ "mark_as_spam",
34
+ "archive_thread",
35
+ "delete_thread"
36
+ ];
37
+ //#endregion
38
+ //#region src/inboxes/interfaces/inbox.ts
39
+ const INBOX_MESSAGE_FOLDERS = [
40
+ "inbox",
41
+ "archive",
42
+ "spam",
43
+ "sent",
44
+ "trash"
45
+ ];
46
+ const MOVE_THREAD_FOLDERS = [
47
+ "inbox",
48
+ "archive",
49
+ "spam",
50
+ "trash"
51
+ ];
52
+ //#endregion
27
53
  //#region package.json
28
- var version = "6.32.1";
54
+ var version = "6.33.0";
29
55
  //#endregion
30
56
  //#region src/common/utils/build-pagination-query.ts
31
57
  function buildPaginationUrl(base, options) {
@@ -979,6 +1005,241 @@ var Events$1 = class {
979
1005
  }
980
1006
  };
981
1007
  //#endregion
1008
+ //#region src/inboxes/agent/agent.ts
1009
+ var InboxAgent = class {
1010
+ constructor(resend) {
1011
+ this.resend = resend;
1012
+ }
1013
+ async get(options, requestOptions = {}) {
1014
+ return this.resend.get(`/inboxes/${options.inboxId}/agent`, requestOptions);
1015
+ }
1016
+ async update(options, requestOptions = {}) {
1017
+ const { inboxId, instructions, tone, enabledActions } = options;
1018
+ return this.resend.patch(`/inboxes/${inboxId}/agent`, {
1019
+ instructions,
1020
+ tone,
1021
+ enabled_actions: enabledActions
1022
+ }, requestOptions);
1023
+ }
1024
+ };
1025
+ //#endregion
1026
+ //#region src/inboxes/build-inbox-cursor-query.ts
1027
+ function buildInboxCursorUrl(base, options = {}) {
1028
+ const searchParams = new URLSearchParams();
1029
+ for (const [key, value] of Object.entries(options)) {
1030
+ if (value === void 0) continue;
1031
+ searchParams.set(key, Array.isArray(value) ? value.join(",") : String(value));
1032
+ }
1033
+ const queryString = searchParams.toString();
1034
+ return queryString ? `${base}?${queryString}` : base;
1035
+ }
1036
+ //#endregion
1037
+ //#region src/inboxes/drafts/drafts.ts
1038
+ var InboxDrafts = class {
1039
+ constructor(resend) {
1040
+ this.resend = resend;
1041
+ }
1042
+ async list(options, requestOptions = {}) {
1043
+ const { inboxId, limit, after, before } = options;
1044
+ const url = buildInboxCursorUrl(`/inboxes/${inboxId}/drafts`, {
1045
+ limit,
1046
+ after,
1047
+ before
1048
+ });
1049
+ return this.resend.get(url, requestOptions);
1050
+ }
1051
+ async create(payload, options = {}) {
1052
+ const { inboxId, threadId, replyToEmailId, attachments, ...content } = payload;
1053
+ return this.resend.post(`/inboxes/${inboxId}/drafts`, {
1054
+ ...content,
1055
+ attachments: parseAttachments(attachments),
1056
+ thread_id: threadId,
1057
+ reply_to_email_id: replyToEmailId
1058
+ }, options);
1059
+ }
1060
+ async get(options, requestOptions = {}) {
1061
+ const { inboxId, draftId } = options;
1062
+ return this.resend.get(`/inboxes/${inboxId}/drafts/${draftId}`, requestOptions);
1063
+ }
1064
+ async update(options, requestOptions = {}) {
1065
+ const { inboxId, draftId, attachments, ...content } = options;
1066
+ return this.resend.patch(`/inboxes/${inboxId}/drafts/${draftId}`, {
1067
+ ...content,
1068
+ attachments: attachments === null ? null : parseAttachments(attachments)
1069
+ }, requestOptions);
1070
+ }
1071
+ async remove(options, requestOptions = {}) {
1072
+ const { inboxId, draftId } = options;
1073
+ return this.resend.delete(`/inboxes/${inboxId}/drafts/${draftId}`, void 0, requestOptions);
1074
+ }
1075
+ async send(payload, options = {}) {
1076
+ const { inboxId, draftId, headers } = payload;
1077
+ return this.resend.post(`/inboxes/${inboxId}/drafts/${draftId}/send`, headers ? { headers } : void 0, options);
1078
+ }
1079
+ };
1080
+ //#endregion
1081
+ //#region src/inboxes/labels/labels.ts
1082
+ var InboxLabels = class {
1083
+ constructor(resend) {
1084
+ this.resend = resend;
1085
+ }
1086
+ async list(options, requestOptions = {}) {
1087
+ return this.resend.get(`/inboxes/${options.inboxId}/labels`, requestOptions);
1088
+ }
1089
+ async create(payload, options = {}) {
1090
+ const { inboxId, name, color } = payload;
1091
+ return this.resend.post(`/inboxes/${inboxId}/labels`, {
1092
+ name,
1093
+ color
1094
+ }, options);
1095
+ }
1096
+ async update(options, requestOptions = {}) {
1097
+ const { inboxId, labelId, name, color } = options;
1098
+ return this.resend.patch(`/inboxes/${inboxId}/labels/${labelId}`, {
1099
+ name,
1100
+ color
1101
+ }, requestOptions);
1102
+ }
1103
+ async remove(options, requestOptions = {}) {
1104
+ const { inboxId, labelId } = options;
1105
+ return this.resend.delete(`/inboxes/${inboxId}/labels/${labelId}`, void 0, requestOptions);
1106
+ }
1107
+ };
1108
+ //#endregion
1109
+ //#region src/inboxes/threads/emails/emails.ts
1110
+ var InboxThreadEmails = class {
1111
+ constructor(resend) {
1112
+ this.resend = resend;
1113
+ }
1114
+ async list(options, requestOptions = {}) {
1115
+ const { inboxId, threadId, ...pagination } = options;
1116
+ const url = buildPaginationUrl(`/inboxes/${inboxId}/threads/${threadId}/emails`, pagination);
1117
+ return this.resend.get(url, requestOptions);
1118
+ }
1119
+ async get(options, requestOptions = {}) {
1120
+ const { inboxId, threadId, emailId } = options;
1121
+ return this.resend.get(`/inboxes/${inboxId}/threads/${threadId}/emails/${emailId}`, requestOptions);
1122
+ }
1123
+ async reply(payload, options = {}) {
1124
+ const { inboxId, threadId, emailId, cc, bcc, html, text, subject, replyAll, attachments, headers } = payload;
1125
+ return this.resend.post(`/inboxes/${inboxId}/threads/${threadId}/emails/${emailId}/reply`, {
1126
+ cc,
1127
+ bcc,
1128
+ html,
1129
+ text,
1130
+ subject,
1131
+ reply_all: replyAll,
1132
+ attachments: parseAttachments(attachments),
1133
+ headers
1134
+ }, options);
1135
+ }
1136
+ async forward(payload, options = {}) {
1137
+ const { inboxId, threadId, emailId, to, cc, bcc, html, text, subject, attachments, headers } = payload;
1138
+ return this.resend.post(`/inboxes/${inboxId}/threads/${threadId}/emails/${emailId}/forward`, {
1139
+ to,
1140
+ cc,
1141
+ bcc,
1142
+ html,
1143
+ text,
1144
+ subject,
1145
+ attachments: parseAttachments(attachments),
1146
+ headers
1147
+ }, options);
1148
+ }
1149
+ };
1150
+ //#endregion
1151
+ //#region src/inboxes/threads/threads.ts
1152
+ var InboxThreads = class {
1153
+ constructor(resend) {
1154
+ this.resend = resend;
1155
+ this.emails = new InboxThreadEmails(resend);
1156
+ }
1157
+ async list(options, requestOptions = {}) {
1158
+ const { inboxId, folders, labels, read, limit, after, before } = options;
1159
+ const url = buildInboxCursorUrl(`/inboxes/${inboxId}/threads`, {
1160
+ folders,
1161
+ labels,
1162
+ read,
1163
+ limit,
1164
+ after,
1165
+ before
1166
+ });
1167
+ return this.resend.get(url, requestOptions);
1168
+ }
1169
+ async search(options, requestOptions = {}) {
1170
+ const { inboxId, folders, labels, read, query, from, to, cc, bcc, hasAttachment, startDate, endDate, limit, after, before } = options;
1171
+ const url = buildInboxCursorUrl(`/inboxes/${inboxId}/threads/search`, {
1172
+ folders,
1173
+ labels,
1174
+ read,
1175
+ query,
1176
+ from,
1177
+ to,
1178
+ cc,
1179
+ bcc,
1180
+ has_attachment: hasAttachment,
1181
+ start_date: startDate,
1182
+ end_date: endDate,
1183
+ limit,
1184
+ after,
1185
+ before
1186
+ });
1187
+ return this.resend.get(url, requestOptions);
1188
+ }
1189
+ async get(options, requestOptions = {}) {
1190
+ const { inboxId, threadId } = options;
1191
+ return this.resend.get(`/inboxes/${inboxId}/threads/${threadId}`, requestOptions);
1192
+ }
1193
+ async update(options, requestOptions = {}) {
1194
+ const { inboxId, threadId, read, folder, addLabelIds, removeLabelIds } = options;
1195
+ return this.resend.patch(`/inboxes/${inboxId}/threads/${threadId}`, {
1196
+ read,
1197
+ folder,
1198
+ add_label_ids: addLabelIds,
1199
+ remove_label_ids: removeLabelIds
1200
+ }, requestOptions);
1201
+ }
1202
+ async remove(options, requestOptions = {}) {
1203
+ const { inboxId, threadId } = options;
1204
+ return this.resend.delete(`/inboxes/${inboxId}/threads/${threadId}`, void 0, requestOptions);
1205
+ }
1206
+ };
1207
+ //#endregion
1208
+ //#region src/inboxes/inboxes.ts
1209
+ var Inboxes = class {
1210
+ constructor(resend) {
1211
+ this.resend = resend;
1212
+ this.threads = new InboxThreads(resend);
1213
+ this.labels = new InboxLabels(resend);
1214
+ this.drafts = new InboxDrafts(resend);
1215
+ this.agent = new InboxAgent(resend);
1216
+ }
1217
+ async create(payload, options = {}) {
1218
+ return this.resend.post("/inboxes", {
1219
+ email_address: payload.emailAddress,
1220
+ name: payload.name,
1221
+ forwarding: payload.forwarding,
1222
+ from_name: payload.fromName
1223
+ }, options);
1224
+ }
1225
+ async list(options = {}, requestOptions = {}) {
1226
+ const url = buildPaginationUrl("/inboxes", options);
1227
+ return this.resend.get(url, requestOptions);
1228
+ }
1229
+ async get(idOrEmail, requestOptions = {}) {
1230
+ return this.resend.get(`/inboxes/${encodeURIComponent(idOrEmail)}`, requestOptions);
1231
+ }
1232
+ async update(id, payload, requestOptions = {}) {
1233
+ return this.resend.patch(`/inboxes/${id}`, {
1234
+ name: payload.name,
1235
+ from_name: payload.fromName
1236
+ }, requestOptions);
1237
+ }
1238
+ async remove(id, requestOptions = {}) {
1239
+ return this.resend.delete(`/inboxes/${id}`, void 0, requestOptions);
1240
+ }
1241
+ };
1242
+ //#endregion
982
1243
  //#region src/logs/logs.ts
983
1244
  var Logs = class {
984
1245
  constructor(resend) {
@@ -1318,6 +1579,7 @@ var Resend = class {
1318
1579
  this.domains = new Domains(this);
1319
1580
  this.emails = new Emails(this);
1320
1581
  this.events = new Events$1(this);
1582
+ this.inboxes = new Inboxes(this);
1321
1583
  this.logs = new Logs(this);
1322
1584
  this.oauthGrants = new OAuthGrants(this);
1323
1585
  this.suppressions = new Suppressions(this);
@@ -1474,4 +1736,7 @@ var Resend = class {
1474
1736
  }
1475
1737
  };
1476
1738
  //#endregion
1739
+ exports.INBOX_AGENT_ACTIONS = INBOX_AGENT_ACTIONS;
1740
+ exports.INBOX_MESSAGE_FOLDERS = INBOX_MESSAGE_FOLDERS;
1741
+ exports.MOVE_THREAD_FOLDERS = MOVE_THREAD_FOLDERS;
1477
1742
  exports.Resend = Resend;