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.mjs CHANGED
@@ -1,7 +1,33 @@
1
1
  import PostalMime from "postal-mime";
2
2
  import { Webhook } from "standardwebhooks";
3
+ //#region src/inboxes/agent/interfaces/agent.ts
4
+ const INBOX_AGENT_ACTIONS = [
5
+ "draft_reply",
6
+ "forward_thread",
7
+ "add_labels",
8
+ "assign_thread",
9
+ "mark_as_spam",
10
+ "archive_thread",
11
+ "delete_thread"
12
+ ];
13
+ //#endregion
14
+ //#region src/inboxes/interfaces/inbox.ts
15
+ const INBOX_MESSAGE_FOLDERS = [
16
+ "inbox",
17
+ "archive",
18
+ "spam",
19
+ "sent",
20
+ "trash"
21
+ ];
22
+ const MOVE_THREAD_FOLDERS = [
23
+ "inbox",
24
+ "archive",
25
+ "spam",
26
+ "trash"
27
+ ];
28
+ //#endregion
3
29
  //#region package.json
4
- var version = "6.32.1";
30
+ var version = "6.33.0";
5
31
  //#endregion
6
32
  //#region src/common/utils/build-pagination-query.ts
7
33
  function buildPaginationUrl(base, options) {
@@ -955,6 +981,241 @@ var Events$1 = class {
955
981
  }
956
982
  };
957
983
  //#endregion
984
+ //#region src/inboxes/agent/agent.ts
985
+ var InboxAgent = class {
986
+ constructor(resend) {
987
+ this.resend = resend;
988
+ }
989
+ async get(options, requestOptions = {}) {
990
+ return this.resend.get(`/inboxes/${options.inboxId}/agent`, requestOptions);
991
+ }
992
+ async update(options, requestOptions = {}) {
993
+ const { inboxId, instructions, tone, enabledActions } = options;
994
+ return this.resend.patch(`/inboxes/${inboxId}/agent`, {
995
+ instructions,
996
+ tone,
997
+ enabled_actions: enabledActions
998
+ }, requestOptions);
999
+ }
1000
+ };
1001
+ //#endregion
1002
+ //#region src/inboxes/build-inbox-cursor-query.ts
1003
+ function buildInboxCursorUrl(base, options = {}) {
1004
+ const searchParams = new URLSearchParams();
1005
+ for (const [key, value] of Object.entries(options)) {
1006
+ if (value === void 0) continue;
1007
+ searchParams.set(key, Array.isArray(value) ? value.join(",") : String(value));
1008
+ }
1009
+ const queryString = searchParams.toString();
1010
+ return queryString ? `${base}?${queryString}` : base;
1011
+ }
1012
+ //#endregion
1013
+ //#region src/inboxes/drafts/drafts.ts
1014
+ var InboxDrafts = class {
1015
+ constructor(resend) {
1016
+ this.resend = resend;
1017
+ }
1018
+ async list(options, requestOptions = {}) {
1019
+ const { inboxId, limit, after, before } = options;
1020
+ const url = buildInboxCursorUrl(`/inboxes/${inboxId}/drafts`, {
1021
+ limit,
1022
+ after,
1023
+ before
1024
+ });
1025
+ return this.resend.get(url, requestOptions);
1026
+ }
1027
+ async create(payload, options = {}) {
1028
+ const { inboxId, threadId, replyToEmailId, attachments, ...content } = payload;
1029
+ return this.resend.post(`/inboxes/${inboxId}/drafts`, {
1030
+ ...content,
1031
+ attachments: parseAttachments(attachments),
1032
+ thread_id: threadId,
1033
+ reply_to_email_id: replyToEmailId
1034
+ }, options);
1035
+ }
1036
+ async get(options, requestOptions = {}) {
1037
+ const { inboxId, draftId } = options;
1038
+ return this.resend.get(`/inboxes/${inboxId}/drafts/${draftId}`, requestOptions);
1039
+ }
1040
+ async update(options, requestOptions = {}) {
1041
+ const { inboxId, draftId, attachments, ...content } = options;
1042
+ return this.resend.patch(`/inboxes/${inboxId}/drafts/${draftId}`, {
1043
+ ...content,
1044
+ attachments: attachments === null ? null : parseAttachments(attachments)
1045
+ }, requestOptions);
1046
+ }
1047
+ async remove(options, requestOptions = {}) {
1048
+ const { inboxId, draftId } = options;
1049
+ return this.resend.delete(`/inboxes/${inboxId}/drafts/${draftId}`, void 0, requestOptions);
1050
+ }
1051
+ async send(payload, options = {}) {
1052
+ const { inboxId, draftId, headers } = payload;
1053
+ return this.resend.post(`/inboxes/${inboxId}/drafts/${draftId}/send`, headers ? { headers } : void 0, options);
1054
+ }
1055
+ };
1056
+ //#endregion
1057
+ //#region src/inboxes/labels/labels.ts
1058
+ var InboxLabels = class {
1059
+ constructor(resend) {
1060
+ this.resend = resend;
1061
+ }
1062
+ async list(options, requestOptions = {}) {
1063
+ return this.resend.get(`/inboxes/${options.inboxId}/labels`, requestOptions);
1064
+ }
1065
+ async create(payload, options = {}) {
1066
+ const { inboxId, name, color } = payload;
1067
+ return this.resend.post(`/inboxes/${inboxId}/labels`, {
1068
+ name,
1069
+ color
1070
+ }, options);
1071
+ }
1072
+ async update(options, requestOptions = {}) {
1073
+ const { inboxId, labelId, name, color } = options;
1074
+ return this.resend.patch(`/inboxes/${inboxId}/labels/${labelId}`, {
1075
+ name,
1076
+ color
1077
+ }, requestOptions);
1078
+ }
1079
+ async remove(options, requestOptions = {}) {
1080
+ const { inboxId, labelId } = options;
1081
+ return this.resend.delete(`/inboxes/${inboxId}/labels/${labelId}`, void 0, requestOptions);
1082
+ }
1083
+ };
1084
+ //#endregion
1085
+ //#region src/inboxes/threads/emails/emails.ts
1086
+ var InboxThreadEmails = class {
1087
+ constructor(resend) {
1088
+ this.resend = resend;
1089
+ }
1090
+ async list(options, requestOptions = {}) {
1091
+ const { inboxId, threadId, ...pagination } = options;
1092
+ const url = buildPaginationUrl(`/inboxes/${inboxId}/threads/${threadId}/emails`, pagination);
1093
+ return this.resend.get(url, requestOptions);
1094
+ }
1095
+ async get(options, requestOptions = {}) {
1096
+ const { inboxId, threadId, emailId } = options;
1097
+ return this.resend.get(`/inboxes/${inboxId}/threads/${threadId}/emails/${emailId}`, requestOptions);
1098
+ }
1099
+ async reply(payload, options = {}) {
1100
+ const { inboxId, threadId, emailId, cc, bcc, html, text, subject, replyAll, attachments, headers } = payload;
1101
+ return this.resend.post(`/inboxes/${inboxId}/threads/${threadId}/emails/${emailId}/reply`, {
1102
+ cc,
1103
+ bcc,
1104
+ html,
1105
+ text,
1106
+ subject,
1107
+ reply_all: replyAll,
1108
+ attachments: parseAttachments(attachments),
1109
+ headers
1110
+ }, options);
1111
+ }
1112
+ async forward(payload, options = {}) {
1113
+ const { inboxId, threadId, emailId, to, cc, bcc, html, text, subject, attachments, headers } = payload;
1114
+ return this.resend.post(`/inboxes/${inboxId}/threads/${threadId}/emails/${emailId}/forward`, {
1115
+ to,
1116
+ cc,
1117
+ bcc,
1118
+ html,
1119
+ text,
1120
+ subject,
1121
+ attachments: parseAttachments(attachments),
1122
+ headers
1123
+ }, options);
1124
+ }
1125
+ };
1126
+ //#endregion
1127
+ //#region src/inboxes/threads/threads.ts
1128
+ var InboxThreads = class {
1129
+ constructor(resend) {
1130
+ this.resend = resend;
1131
+ this.emails = new InboxThreadEmails(resend);
1132
+ }
1133
+ async list(options, requestOptions = {}) {
1134
+ const { inboxId, folders, labels, read, limit, after, before } = options;
1135
+ const url = buildInboxCursorUrl(`/inboxes/${inboxId}/threads`, {
1136
+ folders,
1137
+ labels,
1138
+ read,
1139
+ limit,
1140
+ after,
1141
+ before
1142
+ });
1143
+ return this.resend.get(url, requestOptions);
1144
+ }
1145
+ async search(options, requestOptions = {}) {
1146
+ const { inboxId, folders, labels, read, query, from, to, cc, bcc, hasAttachment, startDate, endDate, limit, after, before } = options;
1147
+ const url = buildInboxCursorUrl(`/inboxes/${inboxId}/threads/search`, {
1148
+ folders,
1149
+ labels,
1150
+ read,
1151
+ query,
1152
+ from,
1153
+ to,
1154
+ cc,
1155
+ bcc,
1156
+ has_attachment: hasAttachment,
1157
+ start_date: startDate,
1158
+ end_date: endDate,
1159
+ limit,
1160
+ after,
1161
+ before
1162
+ });
1163
+ return this.resend.get(url, requestOptions);
1164
+ }
1165
+ async get(options, requestOptions = {}) {
1166
+ const { inboxId, threadId } = options;
1167
+ return this.resend.get(`/inboxes/${inboxId}/threads/${threadId}`, requestOptions);
1168
+ }
1169
+ async update(options, requestOptions = {}) {
1170
+ const { inboxId, threadId, read, folder, addLabelIds, removeLabelIds } = options;
1171
+ return this.resend.patch(`/inboxes/${inboxId}/threads/${threadId}`, {
1172
+ read,
1173
+ folder,
1174
+ add_label_ids: addLabelIds,
1175
+ remove_label_ids: removeLabelIds
1176
+ }, requestOptions);
1177
+ }
1178
+ async remove(options, requestOptions = {}) {
1179
+ const { inboxId, threadId } = options;
1180
+ return this.resend.delete(`/inboxes/${inboxId}/threads/${threadId}`, void 0, requestOptions);
1181
+ }
1182
+ };
1183
+ //#endregion
1184
+ //#region src/inboxes/inboxes.ts
1185
+ var Inboxes = class {
1186
+ constructor(resend) {
1187
+ this.resend = resend;
1188
+ this.threads = new InboxThreads(resend);
1189
+ this.labels = new InboxLabels(resend);
1190
+ this.drafts = new InboxDrafts(resend);
1191
+ this.agent = new InboxAgent(resend);
1192
+ }
1193
+ async create(payload, options = {}) {
1194
+ return this.resend.post("/inboxes", {
1195
+ email_address: payload.emailAddress,
1196
+ name: payload.name,
1197
+ forwarding: payload.forwarding,
1198
+ from_name: payload.fromName
1199
+ }, options);
1200
+ }
1201
+ async list(options = {}, requestOptions = {}) {
1202
+ const url = buildPaginationUrl("/inboxes", options);
1203
+ return this.resend.get(url, requestOptions);
1204
+ }
1205
+ async get(idOrEmail, requestOptions = {}) {
1206
+ return this.resend.get(`/inboxes/${encodeURIComponent(idOrEmail)}`, requestOptions);
1207
+ }
1208
+ async update(id, payload, requestOptions = {}) {
1209
+ return this.resend.patch(`/inboxes/${id}`, {
1210
+ name: payload.name,
1211
+ from_name: payload.fromName
1212
+ }, requestOptions);
1213
+ }
1214
+ async remove(id, requestOptions = {}) {
1215
+ return this.resend.delete(`/inboxes/${id}`, void 0, requestOptions);
1216
+ }
1217
+ };
1218
+ //#endregion
958
1219
  //#region src/logs/logs.ts
959
1220
  var Logs = class {
960
1221
  constructor(resend) {
@@ -1294,6 +1555,7 @@ var Resend = class {
1294
1555
  this.domains = new Domains(this);
1295
1556
  this.emails = new Emails(this);
1296
1557
  this.events = new Events$1(this);
1558
+ this.inboxes = new Inboxes(this);
1297
1559
  this.logs = new Logs(this);
1298
1560
  this.oauthGrants = new OAuthGrants(this);
1299
1561
  this.suppressions = new Suppressions(this);
@@ -1450,4 +1712,4 @@ var Resend = class {
1450
1712
  }
1451
1713
  };
1452
1714
  //#endregion
1453
- export { Resend };
1715
+ export { INBOX_AGENT_ACTIONS, INBOX_MESSAGE_FOLDERS, MOVE_THREAD_FOLDERS, Resend };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resend",
3
- "version": "6.32.1",
3
+ "version": "6.33.0",
4
4
  "description": "Node.js library for the Resend API",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
package/readme.md CHANGED
@@ -174,6 +174,22 @@ await resend.templates
174
174
  .publish({ signal });
175
175
  ```
176
176
 
177
+ ## Inboxes
178
+
179
+ Create an inbox and list its threads:
180
+
181
+ ```js
182
+ const { data: inbox } = await resend.inboxes.create({
183
+ emailAddress: 'support@example.com',
184
+ name: 'support',
185
+ });
186
+
187
+ const { data: threads } = await resend.inboxes.threads.list({
188
+ inboxId: inbox.id,
189
+ folders: ['inbox'],
190
+ });
191
+ ```
192
+
177
193
  ## License
178
194
 
179
195
  MIT License