resend 6.28.0 → 6.28.1-preview-inboxes.1

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
@@ -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.1";
29
57
  //#endregion
30
58
  //#region src/common/utils/build-pagination-query.ts
31
59
  function buildPaginationUrl(base, options) {
@@ -964,6 +992,180 @@ 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.limit !== void 0) searchParams.set("limit", String(options.limit));
1002
+ if (options.after !== void 0) searchParams.set("after", options.after);
1003
+ if (options.before !== void 0) searchParams.set("before", options.before);
1004
+ const labels = options.label === void 0 ? [] : Array.isArray(options.label) ? options.label : [options.label];
1005
+ for (const label of labels) searchParams.append("label", label);
1006
+ const queryString = searchParams.toString();
1007
+ return queryString ? `${base}?${queryString}` : base;
1008
+ }
1009
+ //#endregion
1010
+ //#region src/inboxes/drafts/drafts.ts
1011
+ var InboxDrafts = class {
1012
+ constructor(resend) {
1013
+ this.resend = resend;
1014
+ }
1015
+ async list(options) {
1016
+ const { inboxId, limit, after, before } = options;
1017
+ const url = buildInboxCursorUrl(`/inboxes/${inboxId}/drafts`, {
1018
+ limit,
1019
+ after,
1020
+ before
1021
+ });
1022
+ return this.resend.get(url);
1023
+ }
1024
+ async create(payload, options = {}) {
1025
+ const { inboxId, threadId, replyToEmailId, ...content } = payload;
1026
+ return this.resend.post(`/inboxes/${inboxId}/drafts`, {
1027
+ ...content,
1028
+ thread_id: threadId,
1029
+ reply_to_email_id: replyToEmailId
1030
+ }, options);
1031
+ }
1032
+ async get(options) {
1033
+ const { inboxId, draftId } = options;
1034
+ return this.resend.get(`/inboxes/${inboxId}/drafts/${draftId}`);
1035
+ }
1036
+ async update(options) {
1037
+ const { inboxId, draftId, ...content } = options;
1038
+ return this.resend.patch(`/inboxes/${inboxId}/drafts/${draftId}`, content);
1039
+ }
1040
+ async remove(options) {
1041
+ const { inboxId, draftId } = options;
1042
+ return this.resend.delete(`/inboxes/${inboxId}/drafts/${draftId}`);
1043
+ }
1044
+ async send(payload, options = {}) {
1045
+ const { inboxId, draftId } = payload;
1046
+ return this.resend.post(`/inboxes/${inboxId}/drafts/${draftId}/send`, void 0, options);
1047
+ }
1048
+ };
1049
+ //#endregion
1050
+ //#region src/inboxes/labels/labels.ts
1051
+ var InboxLabels = class {
1052
+ constructor(resend) {
1053
+ this.resend = resend;
1054
+ }
1055
+ async list(options) {
1056
+ return this.resend.get(`/inboxes/${options.inboxId}/labels`);
1057
+ }
1058
+ async create(payload, options = {}) {
1059
+ const { inboxId, name, color } = payload;
1060
+ return this.resend.post(`/inboxes/${inboxId}/labels`, {
1061
+ name,
1062
+ color
1063
+ }, options);
1064
+ }
1065
+ async update(options) {
1066
+ const { inboxId, labelId, name, color } = options;
1067
+ return this.resend.patch(`/inboxes/${inboxId}/labels/${labelId}`, {
1068
+ name,
1069
+ color
1070
+ });
1071
+ }
1072
+ async remove(options) {
1073
+ const { inboxId, labelId } = options;
1074
+ return this.resend.delete(`/inboxes/${inboxId}/labels/${labelId}`);
1075
+ }
1076
+ };
1077
+ //#endregion
1078
+ //#region src/inboxes/threads/emails/emails.ts
1079
+ var InboxThreadEmails = class {
1080
+ constructor(resend) {
1081
+ this.resend = resend;
1082
+ }
1083
+ async get(options) {
1084
+ const { inboxId, threadId, emailId } = options;
1085
+ return this.resend.get(`/inboxes/${inboxId}/threads/${threadId}/emails/${emailId}`);
1086
+ }
1087
+ async reply(payload, options = {}) {
1088
+ const { inboxId, threadId, emailId, html, text, subject } = payload;
1089
+ return this.resend.post(`/inboxes/${inboxId}/threads/${threadId}/emails/${emailId}/reply`, {
1090
+ html,
1091
+ text,
1092
+ subject
1093
+ }, options);
1094
+ }
1095
+ async forward(payload, options = {}) {
1096
+ const { inboxId, threadId, emailId, to, html, text, subject } = payload;
1097
+ return this.resend.post(`/inboxes/${inboxId}/threads/${threadId}/emails/${emailId}/forward`, {
1098
+ to,
1099
+ html,
1100
+ text,
1101
+ subject
1102
+ }, options);
1103
+ }
1104
+ };
1105
+ //#endregion
1106
+ //#region src/inboxes/threads/threads.ts
1107
+ var InboxThreads = class {
1108
+ constructor(resend) {
1109
+ this.resend = resend;
1110
+ this.emails = new InboxThreadEmails(resend);
1111
+ }
1112
+ async list(options) {
1113
+ const { inboxId, ...query } = options;
1114
+ const url = buildInboxCursorUrl(`/inboxes/${inboxId}/threads`, query);
1115
+ return this.resend.get(url);
1116
+ }
1117
+ async get(options) {
1118
+ const { inboxId, threadId } = options;
1119
+ return this.resend.get(`/inboxes/${inboxId}/threads/${threadId}`);
1120
+ }
1121
+ async update(options) {
1122
+ const { inboxId, threadId, read, folder, labelId } = options;
1123
+ return this.resend.patch(`/inboxes/${inboxId}/threads/${threadId}`, {
1124
+ read,
1125
+ folder,
1126
+ label_id: labelId
1127
+ });
1128
+ }
1129
+ async remove(options) {
1130
+ const { inboxId, threadId } = options;
1131
+ return this.resend.delete(`/inboxes/${inboxId}/threads/${threadId}`);
1132
+ }
1133
+ };
1134
+ //#endregion
1135
+ //#region src/inboxes/inboxes.ts
1136
+ var Inboxes = class {
1137
+ constructor(resend) {
1138
+ this.resend = resend;
1139
+ this.threads = new InboxThreads(resend);
1140
+ this.labels = new InboxLabels(resend);
1141
+ this.drafts = new InboxDrafts(resend);
1142
+ }
1143
+ async create(payload, options = {}) {
1144
+ return this.resend.post("/inboxes", {
1145
+ email_address: payload.emailAddress,
1146
+ name: payload.name,
1147
+ forwarding: payload.forwarding,
1148
+ friendly_name: payload.friendlyName
1149
+ }, options);
1150
+ }
1151
+ async list(options = {}) {
1152
+ const url = buildPaginationUrl("/inboxes", options);
1153
+ return this.resend.get(url);
1154
+ }
1155
+ async get(id) {
1156
+ return this.resend.get(`/inboxes/${id}`);
1157
+ }
1158
+ async update(id, payload) {
1159
+ return this.resend.patch(`/inboxes/${id}`, {
1160
+ name: payload.name,
1161
+ friendly_name: payload.friendlyName
1162
+ });
1163
+ }
1164
+ async remove(id) {
1165
+ return this.resend.delete(`/inboxes/${id}`);
1166
+ }
1167
+ };
1168
+ //#endregion
967
1169
  //#region src/logs/logs.ts
968
1170
  var Logs = class {
969
1171
  constructor(resend) {
@@ -1293,6 +1495,7 @@ var Resend = class {
1293
1495
  this.domains = new Domains(this);
1294
1496
  this.emails = new Emails(this);
1295
1497
  this.events = new Events$1(this);
1498
+ this.inboxes = new Inboxes(this);
1296
1499
  this.logs = new Logs(this);
1297
1500
  this.oauthGrants = new OAuthGrants(this);
1298
1501
  this.suppressions = new Suppressions(this);
@@ -1446,4 +1649,7 @@ var Resend = class {
1446
1649
  }
1447
1650
  };
1448
1651
  //#endregion
1652
+ exports.INBOX_LABEL_COLORS = INBOX_LABEL_COLORS;
1653
+ exports.INBOX_MESSAGE_FOLDERS = INBOX_MESSAGE_FOLDERS;
1654
+ exports.MOVE_THREAD_FOLDERS = MOVE_THREAD_FOLDERS;
1449
1655
  exports.Resend = Resend;