resend 6.2.0 → 6.2.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.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +387 -479
- package/dist/index.mjs +387 -479
- package/package.json +11 -13
package/dist/index.js
CHANGED
|
@@ -55,26 +55,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
55
55
|
mod
|
|
56
56
|
));
|
|
57
57
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
58
|
-
var __async = (__this, __arguments, generator) => {
|
|
59
|
-
return new Promise((resolve, reject) => {
|
|
60
|
-
var fulfilled = (value) => {
|
|
61
|
-
try {
|
|
62
|
-
step(generator.next(value));
|
|
63
|
-
} catch (e) {
|
|
64
|
-
reject(e);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
var rejected = (value) => {
|
|
68
|
-
try {
|
|
69
|
-
step(generator.throw(value));
|
|
70
|
-
} catch (e) {
|
|
71
|
-
reject(e);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
75
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
58
|
|
|
79
59
|
// src/index.ts
|
|
80
60
|
var index_exports = {};
|
|
@@ -84,7 +64,7 @@ __export(index_exports, {
|
|
|
84
64
|
module.exports = __toCommonJS(index_exports);
|
|
85
65
|
|
|
86
66
|
// package.json
|
|
87
|
-
var version = "6.2.
|
|
67
|
+
var version = "6.2.2";
|
|
88
68
|
|
|
89
69
|
// src/common/utils/build-pagination-query.ts
|
|
90
70
|
function buildPaginationQuery(options) {
|
|
@@ -106,31 +86,25 @@ var ApiKeys = class {
|
|
|
106
86
|
constructor(resend) {
|
|
107
87
|
this.resend = resend;
|
|
108
88
|
}
|
|
109
|
-
create(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
return __async(this, null, function* () {
|
|
129
|
-
const data = yield this.resend.delete(
|
|
130
|
-
`/api-keys/${id}`
|
|
131
|
-
);
|
|
132
|
-
return data;
|
|
133
|
-
});
|
|
89
|
+
async create(payload, options = {}) {
|
|
90
|
+
const data = await this.resend.post(
|
|
91
|
+
"/api-keys",
|
|
92
|
+
payload,
|
|
93
|
+
options
|
|
94
|
+
);
|
|
95
|
+
return data;
|
|
96
|
+
}
|
|
97
|
+
async list(options = {}) {
|
|
98
|
+
const queryString = buildPaginationQuery(options);
|
|
99
|
+
const url = queryString ? `/api-keys?${queryString}` : "/api-keys";
|
|
100
|
+
const data = await this.resend.get(url);
|
|
101
|
+
return data;
|
|
102
|
+
}
|
|
103
|
+
async remove(id) {
|
|
104
|
+
const data = await this.resend.delete(
|
|
105
|
+
`/api-keys/${id}`
|
|
106
|
+
);
|
|
107
|
+
return data;
|
|
134
108
|
}
|
|
135
109
|
};
|
|
136
110
|
|
|
@@ -139,39 +113,31 @@ var Audiences = class {
|
|
|
139
113
|
constructor(resend) {
|
|
140
114
|
this.resend = resend;
|
|
141
115
|
}
|
|
142
|
-
create(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
remove(id) {
|
|
169
|
-
return __async(this, null, function* () {
|
|
170
|
-
const data = yield this.resend.delete(
|
|
171
|
-
`/audiences/${id}`
|
|
172
|
-
);
|
|
173
|
-
return data;
|
|
174
|
-
});
|
|
116
|
+
async create(payload, options = {}) {
|
|
117
|
+
const data = await this.resend.post(
|
|
118
|
+
"/audiences",
|
|
119
|
+
payload,
|
|
120
|
+
options
|
|
121
|
+
);
|
|
122
|
+
return data;
|
|
123
|
+
}
|
|
124
|
+
async list(options = {}) {
|
|
125
|
+
const queryString = buildPaginationQuery(options);
|
|
126
|
+
const url = queryString ? `/audiences?${queryString}` : "/audiences";
|
|
127
|
+
const data = await this.resend.get(url);
|
|
128
|
+
return data;
|
|
129
|
+
}
|
|
130
|
+
async get(id) {
|
|
131
|
+
const data = await this.resend.get(
|
|
132
|
+
`/audiences/${id}`
|
|
133
|
+
);
|
|
134
|
+
return data;
|
|
135
|
+
}
|
|
136
|
+
async remove(id) {
|
|
137
|
+
const data = await this.resend.delete(
|
|
138
|
+
`/audiences/${id}`
|
|
139
|
+
);
|
|
140
|
+
return data;
|
|
175
141
|
}
|
|
176
142
|
};
|
|
177
143
|
|
|
@@ -203,18 +169,16 @@ function parseEmailToApiOptions(email) {
|
|
|
203
169
|
}
|
|
204
170
|
|
|
205
171
|
// src/render.ts
|
|
206
|
-
function render(node) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
});
|
|
217
|
-
});
|
|
172
|
+
async function render(node) {
|
|
173
|
+
let render2;
|
|
174
|
+
try {
|
|
175
|
+
({ render: render2 } = await import("@react-email/render"));
|
|
176
|
+
} catch (e) {
|
|
177
|
+
throw new Error(
|
|
178
|
+
"Failed to render React component. Make sure to install `@react-email/render` or `@react-email/components`."
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
return render2(node);
|
|
218
182
|
}
|
|
219
183
|
|
|
220
184
|
// src/batch/batch.ts
|
|
@@ -222,33 +186,29 @@ var Batch = class {
|
|
|
222
186
|
constructor(resend) {
|
|
223
187
|
this.resend = resend;
|
|
224
188
|
}
|
|
225
|
-
send(payload, options) {
|
|
226
|
-
return
|
|
227
|
-
return this.create(payload, options);
|
|
228
|
-
});
|
|
189
|
+
async send(payload, options) {
|
|
190
|
+
return this.create(payload, options);
|
|
229
191
|
}
|
|
230
|
-
create(payload, options) {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
email.react = void 0;
|
|
238
|
-
}
|
|
239
|
-
emails.push(parseEmailToApiOptions(email));
|
|
192
|
+
async create(payload, options) {
|
|
193
|
+
var _a;
|
|
194
|
+
const emails = [];
|
|
195
|
+
for (const email of payload) {
|
|
196
|
+
if (email.react) {
|
|
197
|
+
email.html = await render(email.react);
|
|
198
|
+
email.react = void 0;
|
|
240
199
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
200
|
+
emails.push(parseEmailToApiOptions(email));
|
|
201
|
+
}
|
|
202
|
+
const data = await this.resend.post(
|
|
203
|
+
"/emails/batch",
|
|
204
|
+
emails,
|
|
205
|
+
__spreadProps(__spreadValues({}, options), {
|
|
206
|
+
headers: __spreadValues({
|
|
207
|
+
"x-batch-validation": (_a = options == null ? void 0 : options.batchValidation) != null ? _a : "strict"
|
|
208
|
+
}, options == null ? void 0 : options.headers)
|
|
209
|
+
})
|
|
210
|
+
);
|
|
211
|
+
return data;
|
|
252
212
|
}
|
|
253
213
|
};
|
|
254
214
|
|
|
@@ -257,81 +217,69 @@ var Broadcasts = class {
|
|
|
257
217
|
constructor(resend) {
|
|
258
218
|
this.resend = resend;
|
|
259
219
|
}
|
|
260
|
-
create(
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
220
|
+
async create(payload, options = {}) {
|
|
221
|
+
if (payload.react) {
|
|
222
|
+
payload.html = await render(payload.react);
|
|
223
|
+
}
|
|
224
|
+
const data = await this.resend.post(
|
|
225
|
+
"/broadcasts",
|
|
226
|
+
{
|
|
227
|
+
name: payload.name,
|
|
228
|
+
audience_id: payload.audienceId,
|
|
229
|
+
preview_text: payload.previewText,
|
|
230
|
+
from: payload.from,
|
|
231
|
+
html: payload.html,
|
|
232
|
+
reply_to: payload.replyTo,
|
|
233
|
+
subject: payload.subject,
|
|
234
|
+
text: payload.text
|
|
235
|
+
},
|
|
236
|
+
options
|
|
237
|
+
);
|
|
238
|
+
return data;
|
|
239
|
+
}
|
|
240
|
+
async send(id, payload) {
|
|
241
|
+
const data = await this.resend.post(
|
|
242
|
+
`/broadcasts/${id}/send`,
|
|
243
|
+
{ scheduled_at: payload == null ? void 0 : payload.scheduledAt }
|
|
244
|
+
);
|
|
245
|
+
return data;
|
|
246
|
+
}
|
|
247
|
+
async list(options = {}) {
|
|
248
|
+
const queryString = buildPaginationQuery(options);
|
|
249
|
+
const url = queryString ? `/broadcasts?${queryString}` : "/broadcasts";
|
|
250
|
+
const data = await this.resend.get(url);
|
|
251
|
+
return data;
|
|
252
|
+
}
|
|
253
|
+
async get(id) {
|
|
254
|
+
const data = await this.resend.get(
|
|
255
|
+
`/broadcasts/${id}`
|
|
256
|
+
);
|
|
257
|
+
return data;
|
|
258
|
+
}
|
|
259
|
+
async remove(id) {
|
|
260
|
+
const data = await this.resend.delete(
|
|
261
|
+
`/broadcasts/${id}`
|
|
262
|
+
);
|
|
263
|
+
return data;
|
|
264
|
+
}
|
|
265
|
+
async update(id, payload) {
|
|
266
|
+
if (payload.react) {
|
|
267
|
+
payload.html = await render(payload.react);
|
|
268
|
+
}
|
|
269
|
+
const data = await this.resend.patch(
|
|
270
|
+
`/broadcasts/${id}`,
|
|
271
|
+
{
|
|
272
|
+
name: payload.name,
|
|
273
|
+
audience_id: payload.audienceId,
|
|
274
|
+
from: payload.from,
|
|
275
|
+
html: payload.html,
|
|
276
|
+
text: payload.text,
|
|
277
|
+
subject: payload.subject,
|
|
278
|
+
reply_to: payload.replyTo,
|
|
279
|
+
preview_text: payload.previewText
|
|
319
280
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
{
|
|
323
|
-
name: payload.name,
|
|
324
|
-
audience_id: payload.audienceId,
|
|
325
|
-
from: payload.from,
|
|
326
|
-
html: payload.html,
|
|
327
|
-
text: payload.text,
|
|
328
|
-
subject: payload.subject,
|
|
329
|
-
reply_to: payload.replyTo,
|
|
330
|
-
preview_text: payload.previewText
|
|
331
|
-
}
|
|
332
|
-
);
|
|
333
|
-
return data;
|
|
334
|
-
});
|
|
281
|
+
);
|
|
282
|
+
return data;
|
|
335
283
|
}
|
|
336
284
|
};
|
|
337
285
|
|
|
@@ -340,85 +288,78 @@ var Contacts = class {
|
|
|
340
288
|
constructor(resend) {
|
|
341
289
|
this.resend = resend;
|
|
342
290
|
}
|
|
343
|
-
create(
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
data: null,
|
|
372
|
-
error: {
|
|
373
|
-
message: "Missing `id` or `email` field.",
|
|
374
|
-
name: "missing_required_field"
|
|
375
|
-
}
|
|
376
|
-
};
|
|
377
|
-
}
|
|
378
|
-
const data = yield this.resend.get(
|
|
379
|
-
`/audiences/${options.audienceId}/contacts/${(options == null ? void 0 : options.email) ? options == null ? void 0 : options.email : options == null ? void 0 : options.id}`
|
|
380
|
-
);
|
|
381
|
-
return data;
|
|
382
|
-
});
|
|
383
|
-
}
|
|
384
|
-
update(options) {
|
|
385
|
-
return __async(this, null, function* () {
|
|
386
|
-
if (!options.id && !options.email) {
|
|
387
|
-
return {
|
|
388
|
-
data: null,
|
|
389
|
-
error: {
|
|
390
|
-
message: "Missing `id` or `email` field.",
|
|
391
|
-
name: "missing_required_field"
|
|
392
|
-
}
|
|
393
|
-
};
|
|
394
|
-
}
|
|
395
|
-
const data = yield this.resend.patch(
|
|
396
|
-
`/audiences/${options.audienceId}/contacts/${(options == null ? void 0 : options.email) ? options == null ? void 0 : options.email : options == null ? void 0 : options.id}`,
|
|
397
|
-
{
|
|
398
|
-
unsubscribed: options.unsubscribed,
|
|
399
|
-
first_name: options.firstName,
|
|
400
|
-
last_name: options.lastName
|
|
291
|
+
async create(payload, options = {}) {
|
|
292
|
+
const data = await this.resend.post(
|
|
293
|
+
`/audiences/${payload.audienceId}/contacts`,
|
|
294
|
+
{
|
|
295
|
+
unsubscribed: payload.unsubscribed,
|
|
296
|
+
email: payload.email,
|
|
297
|
+
first_name: payload.firstName,
|
|
298
|
+
last_name: payload.lastName
|
|
299
|
+
},
|
|
300
|
+
options
|
|
301
|
+
);
|
|
302
|
+
return data;
|
|
303
|
+
}
|
|
304
|
+
async list(options) {
|
|
305
|
+
const _a = options, { audienceId } = _a, paginationOptions = __objRest(_a, ["audienceId"]);
|
|
306
|
+
const queryString = buildPaginationQuery(paginationOptions);
|
|
307
|
+
const url = queryString ? `/audiences/${audienceId}/contacts?${queryString}` : `/audiences/${audienceId}/contacts`;
|
|
308
|
+
const data = await this.resend.get(url);
|
|
309
|
+
return data;
|
|
310
|
+
}
|
|
311
|
+
async get(options) {
|
|
312
|
+
if (!options.id && !options.email) {
|
|
313
|
+
return {
|
|
314
|
+
data: null,
|
|
315
|
+
error: {
|
|
316
|
+
message: "Missing `id` or `email` field.",
|
|
317
|
+
statusCode: null,
|
|
318
|
+
name: "missing_required_field"
|
|
401
319
|
}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
return
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
const data = await this.resend.get(
|
|
323
|
+
`/audiences/${options.audienceId}/contacts/${(options == null ? void 0 : options.email) ? options == null ? void 0 : options.email : options == null ? void 0 : options.id}`
|
|
324
|
+
);
|
|
325
|
+
return data;
|
|
326
|
+
}
|
|
327
|
+
async update(options) {
|
|
328
|
+
if (!options.id && !options.email) {
|
|
329
|
+
return {
|
|
330
|
+
data: null,
|
|
331
|
+
error: {
|
|
332
|
+
message: "Missing `id` or `email` field.",
|
|
333
|
+
statusCode: null,
|
|
334
|
+
name: "missing_required_field"
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
const data = await this.resend.patch(
|
|
339
|
+
`/audiences/${options.audienceId}/contacts/${(options == null ? void 0 : options.email) ? options == null ? void 0 : options.email : options == null ? void 0 : options.id}`,
|
|
340
|
+
{
|
|
341
|
+
unsubscribed: options.unsubscribed,
|
|
342
|
+
first_name: options.firstName,
|
|
343
|
+
last_name: options.lastName
|
|
416
344
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
345
|
+
);
|
|
346
|
+
return data;
|
|
347
|
+
}
|
|
348
|
+
async remove(payload) {
|
|
349
|
+
if (!payload.id && !payload.email) {
|
|
350
|
+
return {
|
|
351
|
+
data: null,
|
|
352
|
+
error: {
|
|
353
|
+
message: "Missing `id` or `email` field.",
|
|
354
|
+
statusCode: null,
|
|
355
|
+
name: "missing_required_field"
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
const data = await this.resend.delete(
|
|
360
|
+
`/audiences/${payload.audienceId}/contacts/${(payload == null ? void 0 : payload.email) ? payload == null ? void 0 : payload.email : payload == null ? void 0 : payload.id}`
|
|
361
|
+
);
|
|
362
|
+
return data;
|
|
422
363
|
}
|
|
423
364
|
};
|
|
424
365
|
|
|
@@ -436,60 +377,48 @@ var Domains = class {
|
|
|
436
377
|
constructor(resend) {
|
|
437
378
|
this.resend = resend;
|
|
438
379
|
}
|
|
439
|
-
create(
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
380
|
+
async create(payload, options = {}) {
|
|
381
|
+
const data = await this.resend.post(
|
|
382
|
+
"/domains",
|
|
383
|
+
parseDomainToApiOptions(payload),
|
|
384
|
+
options
|
|
385
|
+
);
|
|
386
|
+
return data;
|
|
387
|
+
}
|
|
388
|
+
async list(options = {}) {
|
|
389
|
+
const queryString = buildPaginationQuery(options);
|
|
390
|
+
const url = queryString ? `/domains?${queryString}` : "/domains";
|
|
391
|
+
const data = await this.resend.get(url);
|
|
392
|
+
return data;
|
|
393
|
+
}
|
|
394
|
+
async get(id) {
|
|
395
|
+
const data = await this.resend.get(
|
|
396
|
+
`/domains/${id}`
|
|
397
|
+
);
|
|
398
|
+
return data;
|
|
399
|
+
}
|
|
400
|
+
async update(payload) {
|
|
401
|
+
const data = await this.resend.patch(
|
|
402
|
+
`/domains/${payload.id}`,
|
|
403
|
+
{
|
|
404
|
+
click_tracking: payload.clickTracking,
|
|
405
|
+
open_tracking: payload.openTracking,
|
|
406
|
+
tls: payload.tls
|
|
407
|
+
}
|
|
408
|
+
);
|
|
409
|
+
return data;
|
|
456
410
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
return data;
|
|
463
|
-
});
|
|
411
|
+
async remove(id) {
|
|
412
|
+
const data = await this.resend.delete(
|
|
413
|
+
`/domains/${id}`
|
|
414
|
+
);
|
|
415
|
+
return data;
|
|
464
416
|
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
click_tracking: payload.clickTracking,
|
|
471
|
-
open_tracking: payload.openTracking,
|
|
472
|
-
tls: payload.tls
|
|
473
|
-
}
|
|
474
|
-
);
|
|
475
|
-
return data;
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
remove(id) {
|
|
479
|
-
return __async(this, null, function* () {
|
|
480
|
-
const data = yield this.resend.delete(
|
|
481
|
-
`/domains/${id}`
|
|
482
|
-
);
|
|
483
|
-
return data;
|
|
484
|
-
});
|
|
485
|
-
}
|
|
486
|
-
verify(id) {
|
|
487
|
-
return __async(this, null, function* () {
|
|
488
|
-
const data = yield this.resend.post(
|
|
489
|
-
`/domains/${id}/verify`
|
|
490
|
-
);
|
|
491
|
-
return data;
|
|
492
|
-
});
|
|
417
|
+
async verify(id) {
|
|
418
|
+
const data = await this.resend.post(
|
|
419
|
+
`/domains/${id}/verify`
|
|
420
|
+
);
|
|
421
|
+
return data;
|
|
493
422
|
}
|
|
494
423
|
};
|
|
495
424
|
|
|
@@ -498,58 +427,46 @@ var Emails = class {
|
|
|
498
427
|
constructor(resend) {
|
|
499
428
|
this.resend = resend;
|
|
500
429
|
}
|
|
501
|
-
send(
|
|
502
|
-
return
|
|
503
|
-
return this.create(payload, options);
|
|
504
|
-
});
|
|
430
|
+
async send(payload, options = {}) {
|
|
431
|
+
return this.create(payload, options);
|
|
505
432
|
}
|
|
506
|
-
create(
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
433
|
+
async create(payload, options = {}) {
|
|
434
|
+
if (payload.react) {
|
|
435
|
+
payload.html = await render(payload.react);
|
|
436
|
+
}
|
|
437
|
+
const data = await this.resend.post(
|
|
438
|
+
"/emails",
|
|
439
|
+
parseEmailToApiOptions(payload),
|
|
440
|
+
options
|
|
441
|
+
);
|
|
442
|
+
return data;
|
|
443
|
+
}
|
|
444
|
+
async get(id) {
|
|
445
|
+
const data = await this.resend.get(
|
|
446
|
+
`/emails/${id}`
|
|
447
|
+
);
|
|
448
|
+
return data;
|
|
449
|
+
}
|
|
450
|
+
async list(options = {}) {
|
|
451
|
+
const queryString = buildPaginationQuery(options);
|
|
452
|
+
const url = queryString ? `/emails?${queryString}` : "/emails";
|
|
453
|
+
const data = await this.resend.get(url);
|
|
454
|
+
return data;
|
|
455
|
+
}
|
|
456
|
+
async update(payload) {
|
|
457
|
+
const data = await this.resend.patch(
|
|
458
|
+
`/emails/${payload.id}`,
|
|
459
|
+
{
|
|
460
|
+
scheduled_at: payload.scheduledAt
|
|
510
461
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
parseEmailToApiOptions(payload),
|
|
514
|
-
options
|
|
515
|
-
);
|
|
516
|
-
return data;
|
|
517
|
-
});
|
|
518
|
-
}
|
|
519
|
-
get(id) {
|
|
520
|
-
return __async(this, null, function* () {
|
|
521
|
-
const data = yield this.resend.get(
|
|
522
|
-
`/emails/${id}`
|
|
523
|
-
);
|
|
524
|
-
return data;
|
|
525
|
-
});
|
|
462
|
+
);
|
|
463
|
+
return data;
|
|
526
464
|
}
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
return data;
|
|
533
|
-
});
|
|
534
|
-
}
|
|
535
|
-
update(payload) {
|
|
536
|
-
return __async(this, null, function* () {
|
|
537
|
-
const data = yield this.resend.patch(
|
|
538
|
-
`/emails/${payload.id}`,
|
|
539
|
-
{
|
|
540
|
-
scheduled_at: payload.scheduledAt
|
|
541
|
-
}
|
|
542
|
-
);
|
|
543
|
-
return data;
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
cancel(id) {
|
|
547
|
-
return __async(this, null, function* () {
|
|
548
|
-
const data = yield this.resend.post(
|
|
549
|
-
`/emails/${id}/cancel`
|
|
550
|
-
);
|
|
551
|
-
return data;
|
|
552
|
-
});
|
|
465
|
+
async cancel(id) {
|
|
466
|
+
const data = await this.resend.post(
|
|
467
|
+
`/emails/${id}/cancel`
|
|
468
|
+
);
|
|
469
|
+
return data;
|
|
553
470
|
}
|
|
554
471
|
};
|
|
555
472
|
|
|
@@ -598,126 +515,117 @@ var Resend = class {
|
|
|
598
515
|
"Content-Type": "application/json"
|
|
599
516
|
});
|
|
600
517
|
}
|
|
601
|
-
fetchRequest(
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
};
|
|
618
|
-
}
|
|
619
|
-
const error = {
|
|
620
|
-
message: response.statusText,
|
|
621
|
-
name: "application_error"
|
|
518
|
+
async fetchRequest(path, options = {}) {
|
|
519
|
+
try {
|
|
520
|
+
const response = await fetch(`${baseUrl}${path}`, options);
|
|
521
|
+
if (!response.ok) {
|
|
522
|
+
try {
|
|
523
|
+
const rawError = await response.text();
|
|
524
|
+
return { data: null, error: JSON.parse(rawError) };
|
|
525
|
+
} catch (err) {
|
|
526
|
+
if (err instanceof SyntaxError) {
|
|
527
|
+
return {
|
|
528
|
+
data: null,
|
|
529
|
+
error: {
|
|
530
|
+
name: "application_error",
|
|
531
|
+
statusCode: response.status,
|
|
532
|
+
message: "Internal server error. We are unable to process your request right now, please try again later."
|
|
533
|
+
}
|
|
622
534
|
};
|
|
623
|
-
if (err instanceof Error) {
|
|
624
|
-
return { data: null, error: __spreadProps(__spreadValues({}, error), { message: err.message }) };
|
|
625
|
-
}
|
|
626
|
-
return { data: null, error };
|
|
627
535
|
}
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
name: "application_error",
|
|
636
|
-
message: "Unable to fetch data. The request could not be resolved."
|
|
536
|
+
const error = {
|
|
537
|
+
message: response.statusText,
|
|
538
|
+
statusCode: response.status,
|
|
539
|
+
name: "application_error"
|
|
540
|
+
};
|
|
541
|
+
if (err instanceof Error) {
|
|
542
|
+
return { data: null, error: __spreadProps(__spreadValues({}, error), { message: err.message }) };
|
|
637
543
|
}
|
|
638
|
-
|
|
639
|
-
}
|
|
640
|
-
});
|
|
641
|
-
}
|
|
642
|
-
post(_0, _1) {
|
|
643
|
-
return __async(this, arguments, function* (path, entity, options = {}) {
|
|
644
|
-
const headers = new Headers(this.headers);
|
|
645
|
-
if (options.headers) {
|
|
646
|
-
for (const [key, value] of new Headers(options.headers).entries()) {
|
|
647
|
-
headers.set(key, value);
|
|
544
|
+
return { data: null, error };
|
|
648
545
|
}
|
|
649
546
|
}
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
return this.fetchRequest(path, requestOptions);
|
|
660
|
-
});
|
|
661
|
-
}
|
|
662
|
-
get(_0) {
|
|
663
|
-
return __async(this, arguments, function* (path, options = {}) {
|
|
664
|
-
const headers = new Headers(this.headers);
|
|
665
|
-
if (options.headers) {
|
|
666
|
-
for (const [key, value] of new Headers(options.headers).entries()) {
|
|
667
|
-
headers.set(key, value);
|
|
547
|
+
const data = await response.json();
|
|
548
|
+
return { data, error: null };
|
|
549
|
+
} catch (e) {
|
|
550
|
+
return {
|
|
551
|
+
data: null,
|
|
552
|
+
error: {
|
|
553
|
+
name: "application_error",
|
|
554
|
+
statusCode: null,
|
|
555
|
+
message: "Unable to fetch data. The request could not be resolved."
|
|
668
556
|
}
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
method: "GET"
|
|
672
|
-
}, options), {
|
|
673
|
-
headers
|
|
674
|
-
});
|
|
675
|
-
return this.fetchRequest(path, requestOptions);
|
|
676
|
-
});
|
|
557
|
+
};
|
|
558
|
+
}
|
|
677
559
|
}
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
headers.set(key, value);
|
|
684
|
-
}
|
|
560
|
+
async post(path, entity, options = {}) {
|
|
561
|
+
const headers = new Headers(this.headers);
|
|
562
|
+
if (options.headers) {
|
|
563
|
+
for (const [key, value] of new Headers(options.headers).entries()) {
|
|
564
|
+
headers.set(key, value);
|
|
685
565
|
}
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
})
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
return
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
566
|
+
}
|
|
567
|
+
if (options.idempotencyKey) {
|
|
568
|
+
headers.set("Idempotency-Key", options.idempotencyKey);
|
|
569
|
+
}
|
|
570
|
+
const requestOptions = __spreadProps(__spreadValues({
|
|
571
|
+
method: "POST",
|
|
572
|
+
body: JSON.stringify(entity)
|
|
573
|
+
}, options), {
|
|
574
|
+
headers
|
|
575
|
+
});
|
|
576
|
+
return this.fetchRequest(path, requestOptions);
|
|
577
|
+
}
|
|
578
|
+
async get(path, options = {}) {
|
|
579
|
+
const headers = new Headers(this.headers);
|
|
580
|
+
if (options.headers) {
|
|
581
|
+
for (const [key, value] of new Headers(options.headers).entries()) {
|
|
582
|
+
headers.set(key, value);
|
|
702
583
|
}
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
const
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
584
|
+
}
|
|
585
|
+
const requestOptions = __spreadProps(__spreadValues({
|
|
586
|
+
method: "GET"
|
|
587
|
+
}, options), {
|
|
588
|
+
headers
|
|
589
|
+
});
|
|
590
|
+
return this.fetchRequest(path, requestOptions);
|
|
591
|
+
}
|
|
592
|
+
async put(path, entity, options = {}) {
|
|
593
|
+
const headers = new Headers(this.headers);
|
|
594
|
+
if (options.headers) {
|
|
595
|
+
for (const [key, value] of new Headers(options.headers).entries()) {
|
|
596
|
+
headers.set(key, value);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
const requestOptions = __spreadProps(__spreadValues({
|
|
600
|
+
method: "PUT",
|
|
601
|
+
body: JSON.stringify(entity)
|
|
602
|
+
}, options), {
|
|
603
|
+
headers
|
|
604
|
+
});
|
|
605
|
+
return this.fetchRequest(path, requestOptions);
|
|
606
|
+
}
|
|
607
|
+
async patch(path, entity, options = {}) {
|
|
608
|
+
const headers = new Headers(this.headers);
|
|
609
|
+
if (options.headers) {
|
|
610
|
+
for (const [key, value] of new Headers(options.headers).entries()) {
|
|
611
|
+
headers.set(key, value);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
const requestOptions = __spreadProps(__spreadValues({
|
|
615
|
+
method: "PATCH",
|
|
616
|
+
body: JSON.stringify(entity)
|
|
617
|
+
}, options), {
|
|
618
|
+
headers
|
|
619
|
+
});
|
|
620
|
+
return this.fetchRequest(path, requestOptions);
|
|
621
|
+
}
|
|
622
|
+
async delete(path, query) {
|
|
623
|
+
const requestOptions = {
|
|
624
|
+
method: "DELETE",
|
|
625
|
+
body: JSON.stringify(query),
|
|
626
|
+
headers: this.headers
|
|
627
|
+
};
|
|
628
|
+
return this.fetchRequest(path, requestOptions);
|
|
721
629
|
}
|
|
722
630
|
};
|
|
723
631
|
// Annotate the CommonJS export names for ESM import in node:
|