resend 6.28.0-preview-inboxes.0 → 6.28.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 +4 -201
- package/dist/index.d.cts +8 -476
- package/dist/index.d.mts +8 -476
- package/dist/index.mjs +5 -199
- package/package.json +14 -16
- package/readme.md +0 -16
package/dist/index.mjs
CHANGED
|
@@ -1,35 +1,7 @@
|
|
|
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
|
|
31
3
|
//#region package.json
|
|
32
|
-
var version = "6.28.0
|
|
4
|
+
var version = "6.28.0";
|
|
33
5
|
//#endregion
|
|
34
6
|
//#region src/common/utils/build-pagination-query.ts
|
|
35
7
|
function buildPaginationUrl(base, options) {
|
|
@@ -327,6 +299,9 @@ var Broadcasts = class {
|
|
|
327
299
|
async cancel(id) {
|
|
328
300
|
return await this.resend.post(`/broadcasts/${id}/cancel`);
|
|
329
301
|
}
|
|
302
|
+
async duplicate(id) {
|
|
303
|
+
return await this.resend.post(`/broadcasts/${id}/duplicate`);
|
|
304
|
+
}
|
|
330
305
|
async update(id, payload) {
|
|
331
306
|
const html = payload.react ? await render(payload.react) : payload.html;
|
|
332
307
|
return await this.resend.patch(`/broadcasts/${id}`, {
|
|
@@ -965,174 +940,6 @@ var Events$1 = class {
|
|
|
965
940
|
}
|
|
966
941
|
};
|
|
967
942
|
//#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
|
|
1136
943
|
//#region src/logs/logs.ts
|
|
1137
944
|
var Logs = class {
|
|
1138
945
|
constructor(resend) {
|
|
@@ -1462,7 +1269,6 @@ var Resend = class {
|
|
|
1462
1269
|
this.domains = new Domains(this);
|
|
1463
1270
|
this.emails = new Emails(this);
|
|
1464
1271
|
this.events = new Events$1(this);
|
|
1465
|
-
this.inboxes = new Inboxes(this);
|
|
1466
1272
|
this.logs = new Logs(this);
|
|
1467
1273
|
this.oauthGrants = new OAuthGrants(this);
|
|
1468
1274
|
this.suppressions = new Suppressions(this);
|
|
@@ -1616,4 +1422,4 @@ var Resend = class {
|
|
|
1616
1422
|
}
|
|
1617
1423
|
};
|
|
1618
1424
|
//#endregion
|
|
1619
|
-
export {
|
|
1425
|
+
export { Resend };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "resend",
|
|
3
|
-
"version": "6.28.0
|
|
3
|
+
"version": "6.28.0",
|
|
4
4
|
"description": "Node.js library for the Resend API",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -29,19 +29,6 @@
|
|
|
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
|
-
},
|
|
45
32
|
"repository": {
|
|
46
33
|
"type": "git",
|
|
47
34
|
"url": "git+https://github.com/resend/resend-node.git"
|
|
@@ -83,5 +70,16 @@
|
|
|
83
70
|
"vitest": "4.1.10",
|
|
84
71
|
"vitest-fetch-mock": "0.4.5"
|
|
85
72
|
},
|
|
86
|
-
"
|
|
87
|
-
|
|
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
|
+
}
|
package/readme.md
CHANGED
|
@@ -134,22 +134,6 @@ 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
|
-
|
|
153
137
|
## License
|
|
154
138
|
|
|
155
139
|
MIT License
|