resend 6.26.0 → 6.28.0-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.mjs CHANGED
@@ -1,7 +1,35 @@
1
1
  import PostalMime from "postal-mime";
2
2
  import { Webhook } from "standardwebhooks";
3
+ //#region src/inboxes/interfaces/inbox.ts
4
+ const INBOX_MESSAGE_FOLDERS = [
5
+ "inbox",
6
+ "archive",
7
+ "spam",
8
+ "sent",
9
+ "trash"
10
+ ];
11
+ const MOVE_THREAD_FOLDERS = [
12
+ "inbox",
13
+ "archive",
14
+ "spam",
15
+ "trash"
16
+ ];
17
+ const INBOX_LABEL_COLORS = [
18
+ "cyan",
19
+ "teal",
20
+ "grass",
21
+ "lime",
22
+ "yellow",
23
+ "orange",
24
+ "iris",
25
+ "plum",
26
+ "crimson",
27
+ "bronze",
28
+ "mauve"
29
+ ];
30
+ //#endregion
3
31
  //#region package.json
4
- var version = "6.26.0";
32
+ var version = "6.28.0-preview-inboxes.0";
5
33
  //#endregion
6
34
  //#region src/common/utils/build-pagination-query.ts
7
35
  function buildPaginationUrl(base, options) {
@@ -937,6 +965,174 @@ var Events$1 = class {
937
965
  }
938
966
  };
939
967
  //#endregion
968
+ //#region src/inboxes/build-inbox-cursor-query.ts
969
+ function buildInboxCursorUrl(base, options = {}) {
970
+ const searchParams = new URLSearchParams();
971
+ if (options.folder !== void 0) searchParams.set("folder", options.folder);
972
+ if (options.query !== void 0) searchParams.set("query", options.query);
973
+ if (options.from !== void 0) searchParams.set("from", options.from);
974
+ if (options.cursor !== void 0) searchParams.set("cursor", options.cursor);
975
+ const labels = options.label === void 0 ? [] : Array.isArray(options.label) ? options.label : [options.label];
976
+ for (const label of labels) searchParams.append("label", label);
977
+ const queryString = searchParams.toString();
978
+ return queryString ? `${base}?${queryString}` : base;
979
+ }
980
+ //#endregion
981
+ //#region src/inboxes/drafts/drafts.ts
982
+ var InboxDrafts = class {
983
+ constructor(resend) {
984
+ this.resend = resend;
985
+ }
986
+ async list(options) {
987
+ const { inboxId, cursor } = options;
988
+ const url = buildInboxCursorUrl(`/inboxes/${inboxId}/drafts`, { cursor });
989
+ return this.resend.get(url);
990
+ }
991
+ async create(payload, options = {}) {
992
+ const { inboxId, threadId, replyToEmailId, ...content } = payload;
993
+ return this.resend.post(`/inboxes/${inboxId}/drafts`, {
994
+ ...content,
995
+ thread_id: threadId,
996
+ reply_to_email_id: replyToEmailId
997
+ }, options);
998
+ }
999
+ async get(options) {
1000
+ const { inboxId, draftId } = options;
1001
+ return this.resend.get(`/inboxes/${inboxId}/drafts/${draftId}`);
1002
+ }
1003
+ async update(options) {
1004
+ const { inboxId, draftId, ...content } = options;
1005
+ return this.resend.patch(`/inboxes/${inboxId}/drafts/${draftId}`, content);
1006
+ }
1007
+ async remove(options) {
1008
+ const { inboxId, draftId } = options;
1009
+ return this.resend.delete(`/inboxes/${inboxId}/drafts/${draftId}`);
1010
+ }
1011
+ async send(payload, options = {}) {
1012
+ const { inboxId, draftId } = payload;
1013
+ return this.resend.post(`/inboxes/${inboxId}/drafts/${draftId}/send`, void 0, options);
1014
+ }
1015
+ };
1016
+ //#endregion
1017
+ //#region src/inboxes/labels/labels.ts
1018
+ var InboxLabels = class {
1019
+ constructor(resend) {
1020
+ this.resend = resend;
1021
+ }
1022
+ async list(options) {
1023
+ return this.resend.get(`/inboxes/${options.inboxId}/labels`);
1024
+ }
1025
+ async create(payload, options = {}) {
1026
+ const { inboxId, name, color } = payload;
1027
+ return this.resend.post(`/inboxes/${inboxId}/labels`, {
1028
+ name,
1029
+ color
1030
+ }, options);
1031
+ }
1032
+ async update(options) {
1033
+ const { inboxId, labelId, name, color } = options;
1034
+ return this.resend.patch(`/inboxes/${inboxId}/labels/${labelId}`, {
1035
+ name,
1036
+ color
1037
+ });
1038
+ }
1039
+ async remove(options) {
1040
+ const { inboxId, labelId } = options;
1041
+ return this.resend.delete(`/inboxes/${inboxId}/labels/${labelId}`);
1042
+ }
1043
+ };
1044
+ //#endregion
1045
+ //#region src/inboxes/threads/emails/emails.ts
1046
+ var InboxThreadEmails = class {
1047
+ constructor(resend) {
1048
+ this.resend = resend;
1049
+ }
1050
+ async get(options) {
1051
+ const { inboxId, threadId, emailId } = options;
1052
+ return this.resend.get(`/inboxes/${inboxId}/threads/${threadId}/emails/${emailId}`);
1053
+ }
1054
+ async reply(payload, options = {}) {
1055
+ const { inboxId, threadId, emailId, html, text, subject } = payload;
1056
+ return this.resend.post(`/inboxes/${inboxId}/threads/${threadId}/emails/${emailId}/reply`, {
1057
+ html,
1058
+ text,
1059
+ subject
1060
+ }, options);
1061
+ }
1062
+ async forward(payload, options = {}) {
1063
+ const { inboxId, threadId, emailId, to, html, text, subject } = payload;
1064
+ return this.resend.post(`/inboxes/${inboxId}/threads/${threadId}/emails/${emailId}/forward`, {
1065
+ to,
1066
+ html,
1067
+ text,
1068
+ subject
1069
+ }, options);
1070
+ }
1071
+ };
1072
+ //#endregion
1073
+ //#region src/inboxes/threads/threads.ts
1074
+ var InboxThreads = class {
1075
+ constructor(resend) {
1076
+ this.resend = resend;
1077
+ this.emails = new InboxThreadEmails(resend);
1078
+ }
1079
+ async list(options) {
1080
+ const { inboxId, ...query } = options;
1081
+ const url = buildInboxCursorUrl(`/inboxes/${inboxId}/threads`, query);
1082
+ return this.resend.get(url);
1083
+ }
1084
+ async get(options) {
1085
+ const { inboxId, threadId } = options;
1086
+ return this.resend.get(`/inboxes/${inboxId}/threads/${threadId}`);
1087
+ }
1088
+ async update(options) {
1089
+ const { inboxId, threadId, read, folder, labelId } = options;
1090
+ return this.resend.patch(`/inboxes/${inboxId}/threads/${threadId}`, {
1091
+ read,
1092
+ folder,
1093
+ label_id: labelId
1094
+ });
1095
+ }
1096
+ async remove(options) {
1097
+ const { inboxId, threadId } = options;
1098
+ return this.resend.delete(`/inboxes/${inboxId}/threads/${threadId}`);
1099
+ }
1100
+ };
1101
+ //#endregion
1102
+ //#region src/inboxes/inboxes.ts
1103
+ var Inboxes = class {
1104
+ constructor(resend) {
1105
+ this.resend = resend;
1106
+ this.threads = new InboxThreads(resend);
1107
+ this.labels = new InboxLabels(resend);
1108
+ this.drafts = new InboxDrafts(resend);
1109
+ }
1110
+ async create(payload, options = {}) {
1111
+ return this.resend.post("/inboxes", {
1112
+ email_address: payload.emailAddress,
1113
+ name: payload.name,
1114
+ forwarding: payload.forwarding,
1115
+ friendly_name: payload.friendlyName
1116
+ }, options);
1117
+ }
1118
+ async list(options = {}) {
1119
+ const url = buildPaginationUrl("/inboxes", options);
1120
+ return this.resend.get(url);
1121
+ }
1122
+ async get(id) {
1123
+ return this.resend.get(`/inboxes/${id}`);
1124
+ }
1125
+ async update(id, payload) {
1126
+ return this.resend.patch(`/inboxes/${id}`, {
1127
+ name: payload.name,
1128
+ friendly_name: payload.friendlyName
1129
+ });
1130
+ }
1131
+ async remove(id) {
1132
+ return this.resend.delete(`/inboxes/${id}`);
1133
+ }
1134
+ };
1135
+ //#endregion
940
1136
  //#region src/logs/logs.ts
941
1137
  var Logs = class {
942
1138
  constructor(resend) {
@@ -1231,6 +1427,9 @@ var Webhooks = class {
1231
1427
  async remove(id) {
1232
1428
  return await this.resend.delete(`/webhooks/${id}`);
1233
1429
  }
1430
+ async rotateSigningSecret(id) {
1431
+ return await this.resend.post(`/webhooks/${id}/signing-secret/rotate`);
1432
+ }
1234
1433
  verify(payload) {
1235
1434
  return new Webhook(payload.webhookSecret).verify(payload.payload, {
1236
1435
  "webhook-id": payload.headers.id,
@@ -1263,6 +1462,7 @@ var Resend = class {
1263
1462
  this.domains = new Domains(this);
1264
1463
  this.emails = new Emails(this);
1265
1464
  this.events = new Events$1(this);
1465
+ this.inboxes = new Inboxes(this);
1266
1466
  this.logs = new Logs(this);
1267
1467
  this.oauthGrants = new OAuthGrants(this);
1268
1468
  this.suppressions = new Suppressions(this);
@@ -1416,4 +1616,4 @@ var Resend = class {
1416
1616
  }
1417
1617
  };
1418
1618
  //#endregion
1419
- export { Resend };
1619
+ export { INBOX_LABEL_COLORS, INBOX_MESSAGE_FOLDERS, MOVE_THREAD_FOLDERS, Resend };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resend",
3
- "version": "6.26.0",
3
+ "version": "6.28.0-preview-inboxes.0",
4
4
  "description": "Node.js library for the Resend API",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -29,6 +29,19 @@
29
29
  }
30
30
  }
31
31
  },
32
+ "scripts": {
33
+ "build": "tsdown src/index.ts --format esm,cjs --dts",
34
+ "integration:nextjs": "cd ./e2e/nextjs && next build --turbopack",
35
+ "lint": "biome check .",
36
+ "lint:fix": "biome check . --write",
37
+ "prepublishOnly": "pnpm run build",
38
+ "test": "vitest run --exclude e2e",
39
+ "test:dev": "cross-env TEST_MODE=dev vitest run --exclude e2e",
40
+ "test:e2e": "vitest run e2e",
41
+ "test:record": "rimraf --glob \"**/__recordings__\" && cross-env TEST_MODE=record vitest run --exclude e2e",
42
+ "test:watch": "vitest --exclude e2e",
43
+ "typecheck": "tsc --noEmit"
44
+ },
32
45
  "repository": {
33
46
  "type": "git",
34
47
  "url": "git+https://github.com/resend/resend-node.git"
@@ -70,16 +83,5 @@
70
83
  "vitest": "4.1.10",
71
84
  "vitest-fetch-mock": "0.4.5"
72
85
  },
73
- "scripts": {
74
- "build": "tsdown src/index.ts --format esm,cjs --dts",
75
- "integration:nextjs": "cd ./e2e/nextjs && next build --turbopack",
76
- "lint": "biome check .",
77
- "lint:fix": "biome check . --write",
78
- "test": "vitest run --exclude e2e",
79
- "test:dev": "cross-env TEST_MODE=dev vitest run --exclude e2e",
80
- "test:e2e": "vitest run e2e",
81
- "test:record": "rimraf --glob \"**/__recordings__\" && cross-env TEST_MODE=record vitest run --exclude e2e",
82
- "test:watch": "vitest --exclude e2e",
83
- "typecheck": "tsc --noEmit"
84
- }
85
- }
86
+ "packageManager": "pnpm@11.12.0"
87
+ }
package/readme.md CHANGED
@@ -134,6 +134,22 @@ console.log(`Email ${data.id} with a React template has been sent`);
134
134
  >});
135
135
  >```
136
136
 
137
+ ## Inboxes
138
+
139
+ Create an inbox and list its threads:
140
+
141
+ ```js
142
+ const { data: inbox } = await resend.inboxes.create({
143
+ emailAddress: 'support@example.com',
144
+ name: 'support',
145
+ });
146
+
147
+ const { data: threads } = await resend.inboxes.threads.list({
148
+ inboxId: inbox.id,
149
+ folder: 'inbox',
150
+ });
151
+ ```
152
+
137
153
  ## License
138
154
 
139
155
  MIT License