resend 6.32.0 → 6.32.1-preview-inboxes.2

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,47 @@ 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
+ const INBOX_LABEL_COLORS = [
53
+ "cyan",
54
+ "teal",
55
+ "grass",
56
+ "lime",
57
+ "yellow",
58
+ "orange",
59
+ "iris",
60
+ "plum",
61
+ "crimson",
62
+ "bronze",
63
+ "mauve"
64
+ ];
65
+ //#endregion
27
66
  //#region package.json
28
- var version = "6.32.0";
67
+ var version = "6.32.1-preview-inboxes.2";
29
68
  //#endregion
30
69
  //#region src/common/utils/build-pagination-query.ts
31
70
  function buildPaginationUrl(base, options) {
@@ -979,6 +1018,208 @@ var Events$1 = class {
979
1018
  }
980
1019
  };
981
1020
  //#endregion
1021
+ //#region src/inboxes/agent/agent.ts
1022
+ var InboxAgent = class {
1023
+ constructor(resend) {
1024
+ this.resend = resend;
1025
+ }
1026
+ async get(options, requestOptions = {}) {
1027
+ return this.resend.get(`/inboxes/${options.inboxId}/agent`, requestOptions);
1028
+ }
1029
+ async update(options, requestOptions = {}) {
1030
+ const { inboxId, instructions, tone, enabledActions } = options;
1031
+ return this.resend.patch(`/inboxes/${inboxId}/agent`, {
1032
+ instructions,
1033
+ tone,
1034
+ enabled_actions: enabledActions
1035
+ }, requestOptions);
1036
+ }
1037
+ };
1038
+ //#endregion
1039
+ //#region src/inboxes/build-inbox-cursor-query.ts
1040
+ function buildInboxCursorUrl(base, options = {}) {
1041
+ const searchParams = new URLSearchParams();
1042
+ if (options.folder !== void 0) searchParams.set("folder", options.folder);
1043
+ if (options.query !== void 0) searchParams.set("query", options.query);
1044
+ if (options.from !== void 0) searchParams.set("from", options.from);
1045
+ if (options.limit !== void 0) searchParams.set("limit", String(options.limit));
1046
+ if (options.after !== void 0) searchParams.set("after", options.after);
1047
+ if (options.before !== void 0) searchParams.set("before", options.before);
1048
+ const labels = options.label === void 0 ? [] : Array.isArray(options.label) ? options.label : [options.label];
1049
+ for (const label of labels) searchParams.append("label", label);
1050
+ const queryString = searchParams.toString();
1051
+ return queryString ? `${base}?${queryString}` : base;
1052
+ }
1053
+ //#endregion
1054
+ //#region src/inboxes/drafts/drafts.ts
1055
+ var InboxDrafts = class {
1056
+ constructor(resend) {
1057
+ this.resend = resend;
1058
+ }
1059
+ async list(options, requestOptions = {}) {
1060
+ const { inboxId, limit, after, before } = options;
1061
+ const url = buildInboxCursorUrl(`/inboxes/${inboxId}/drafts`, {
1062
+ limit,
1063
+ after,
1064
+ before
1065
+ });
1066
+ return this.resend.get(url, requestOptions);
1067
+ }
1068
+ async create(payload, options = {}) {
1069
+ const { inboxId, threadId, replyToEmailId, ...content } = payload;
1070
+ return this.resend.post(`/inboxes/${inboxId}/drafts`, {
1071
+ ...content,
1072
+ thread_id: threadId,
1073
+ reply_to_email_id: replyToEmailId
1074
+ }, options);
1075
+ }
1076
+ async get(options, requestOptions = {}) {
1077
+ const { inboxId, draftId } = options;
1078
+ return this.resend.get(`/inboxes/${inboxId}/drafts/${draftId}`, requestOptions);
1079
+ }
1080
+ async update(options, requestOptions = {}) {
1081
+ const { inboxId, draftId, ...content } = options;
1082
+ return this.resend.patch(`/inboxes/${inboxId}/drafts/${draftId}`, content, requestOptions);
1083
+ }
1084
+ async remove(options, requestOptions = {}) {
1085
+ const { inboxId, draftId } = options;
1086
+ return this.resend.delete(`/inboxes/${inboxId}/drafts/${draftId}`, void 0, requestOptions);
1087
+ }
1088
+ async send(payload, options = {}) {
1089
+ const { inboxId, draftId } = payload;
1090
+ return this.resend.post(`/inboxes/${inboxId}/drafts/${draftId}/send`, void 0, options);
1091
+ }
1092
+ };
1093
+ //#endregion
1094
+ //#region src/inboxes/labels/labels.ts
1095
+ var InboxLabels = class {
1096
+ constructor(resend) {
1097
+ this.resend = resend;
1098
+ }
1099
+ async list(options, requestOptions = {}) {
1100
+ return this.resend.get(`/inboxes/${options.inboxId}/labels`, requestOptions);
1101
+ }
1102
+ async create(payload, options = {}) {
1103
+ const { inboxId, name, color } = payload;
1104
+ return this.resend.post(`/inboxes/${inboxId}/labels`, {
1105
+ name,
1106
+ color
1107
+ }, options);
1108
+ }
1109
+ async update(options, requestOptions = {}) {
1110
+ const { inboxId, labelId, name, color } = options;
1111
+ return this.resend.patch(`/inboxes/${inboxId}/labels/${labelId}`, {
1112
+ name,
1113
+ color
1114
+ }, requestOptions);
1115
+ }
1116
+ async remove(options, requestOptions = {}) {
1117
+ const { inboxId, labelId } = options;
1118
+ return this.resend.delete(`/inboxes/${inboxId}/labels/${labelId}`, void 0, requestOptions);
1119
+ }
1120
+ };
1121
+ //#endregion
1122
+ //#region src/inboxes/threads/emails/emails.ts
1123
+ var InboxThreadEmails = class {
1124
+ constructor(resend) {
1125
+ this.resend = resend;
1126
+ }
1127
+ async list(options, requestOptions = {}) {
1128
+ const { inboxId, threadId, ...pagination } = options;
1129
+ const url = buildPaginationUrl(`/inboxes/${inboxId}/threads/${threadId}/emails`, pagination);
1130
+ return this.resend.get(url, requestOptions);
1131
+ }
1132
+ async get(options, requestOptions = {}) {
1133
+ const { inboxId, threadId, emailId } = options;
1134
+ return this.resend.get(`/inboxes/${inboxId}/threads/${threadId}/emails/${emailId}`, requestOptions);
1135
+ }
1136
+ async reply(payload, options = {}) {
1137
+ const { inboxId, threadId, emailId, cc, bcc, html, text, subject } = payload;
1138
+ return this.resend.post(`/inboxes/${inboxId}/threads/${threadId}/emails/${emailId}/reply`, {
1139
+ cc,
1140
+ bcc,
1141
+ html,
1142
+ text,
1143
+ subject
1144
+ }, options);
1145
+ }
1146
+ async forward(payload, options = {}) {
1147
+ const { inboxId, threadId, emailId, to, cc, bcc, html, text, subject } = payload;
1148
+ return this.resend.post(`/inboxes/${inboxId}/threads/${threadId}/emails/${emailId}/forward`, {
1149
+ to,
1150
+ cc,
1151
+ bcc,
1152
+ html,
1153
+ text,
1154
+ subject
1155
+ }, options);
1156
+ }
1157
+ };
1158
+ //#endregion
1159
+ //#region src/inboxes/threads/threads.ts
1160
+ var InboxThreads = class {
1161
+ constructor(resend) {
1162
+ this.resend = resend;
1163
+ this.emails = new InboxThreadEmails(resend);
1164
+ }
1165
+ async list(options, requestOptions = {}) {
1166
+ const { inboxId, ...query } = options;
1167
+ const url = buildInboxCursorUrl(`/inboxes/${inboxId}/threads`, query);
1168
+ return this.resend.get(url, requestOptions);
1169
+ }
1170
+ async get(options, requestOptions = {}) {
1171
+ const { inboxId, threadId } = options;
1172
+ return this.resend.get(`/inboxes/${inboxId}/threads/${threadId}`, requestOptions);
1173
+ }
1174
+ async update(options, requestOptions = {}) {
1175
+ const { inboxId, threadId, read, folder, labelId } = options;
1176
+ return this.resend.patch(`/inboxes/${inboxId}/threads/${threadId}`, {
1177
+ read,
1178
+ folder,
1179
+ label_id: labelId
1180
+ }, requestOptions);
1181
+ }
1182
+ async remove(options, requestOptions = {}) {
1183
+ const { inboxId, threadId } = options;
1184
+ return this.resend.delete(`/inboxes/${inboxId}/threads/${threadId}`, void 0, requestOptions);
1185
+ }
1186
+ };
1187
+ //#endregion
1188
+ //#region src/inboxes/inboxes.ts
1189
+ var Inboxes = class {
1190
+ constructor(resend) {
1191
+ this.resend = resend;
1192
+ this.threads = new InboxThreads(resend);
1193
+ this.labels = new InboxLabels(resend);
1194
+ this.drafts = new InboxDrafts(resend);
1195
+ this.agent = new InboxAgent(resend);
1196
+ }
1197
+ async create(payload, options = {}) {
1198
+ return this.resend.post("/inboxes", {
1199
+ email_address: payload.emailAddress,
1200
+ name: payload.name,
1201
+ forwarding: payload.forwarding,
1202
+ from_name: payload.fromName
1203
+ }, options);
1204
+ }
1205
+ async list(options = {}, requestOptions = {}) {
1206
+ const url = buildPaginationUrl("/inboxes", options);
1207
+ return this.resend.get(url, requestOptions);
1208
+ }
1209
+ async get(idOrEmail, requestOptions = {}) {
1210
+ return this.resend.get(`/inboxes/${encodeURIComponent(idOrEmail)}`, requestOptions);
1211
+ }
1212
+ async update(id, payload, requestOptions = {}) {
1213
+ return this.resend.patch(`/inboxes/${id}`, {
1214
+ name: payload.name,
1215
+ from_name: payload.fromName
1216
+ }, requestOptions);
1217
+ }
1218
+ async remove(id, requestOptions = {}) {
1219
+ return this.resend.delete(`/inboxes/${id}`, void 0, requestOptions);
1220
+ }
1221
+ };
1222
+ //#endregion
982
1223
  //#region src/logs/logs.ts
983
1224
  var Logs = class {
984
1225
  constructor(resend) {
@@ -1318,6 +1559,7 @@ var Resend = class {
1318
1559
  this.domains = new Domains(this);
1319
1560
  this.emails = new Emails(this);
1320
1561
  this.events = new Events$1(this);
1562
+ this.inboxes = new Inboxes(this);
1321
1563
  this.logs = new Logs(this);
1322
1564
  this.oauthGrants = new OAuthGrants(this);
1323
1565
  this.suppressions = new Suppressions(this);
@@ -1474,4 +1716,8 @@ var Resend = class {
1474
1716
  }
1475
1717
  };
1476
1718
  //#endregion
1719
+ exports.INBOX_AGENT_ACTIONS = INBOX_AGENT_ACTIONS;
1720
+ exports.INBOX_LABEL_COLORS = INBOX_LABEL_COLORS;
1721
+ exports.INBOX_MESSAGE_FOLDERS = INBOX_MESSAGE_FOLDERS;
1722
+ exports.MOVE_THREAD_FOLDERS = MOVE_THREAD_FOLDERS;
1477
1723
  exports.Resend = Resend;