resend 6.2.1 → 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.js +387 -485
- package/dist/index.mjs +387 -485
- package/package.json +1 -1
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,88 +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
|
-
statusCode: null,
|
|
375
|
-
name: "missing_required_field"
|
|
376
|
-
}
|
|
377
|
-
};
|
|
378
|
-
}
|
|
379
|
-
const data = yield this.resend.get(
|
|
380
|
-
`/audiences/${options.audienceId}/contacts/${(options == null ? void 0 : options.email) ? options == null ? void 0 : options.email : options == null ? void 0 : options.id}`
|
|
381
|
-
);
|
|
382
|
-
return data;
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
update(options) {
|
|
386
|
-
return __async(this, null, function* () {
|
|
387
|
-
if (!options.id && !options.email) {
|
|
388
|
-
return {
|
|
389
|
-
data: null,
|
|
390
|
-
error: {
|
|
391
|
-
message: "Missing `id` or `email` field.",
|
|
392
|
-
statusCode: null,
|
|
393
|
-
name: "missing_required_field"
|
|
394
|
-
}
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
|
-
const data = yield this.resend.patch(
|
|
398
|
-
`/audiences/${options.audienceId}/contacts/${(options == null ? void 0 : options.email) ? options == null ? void 0 : options.email : options == null ? void 0 : options.id}`,
|
|
399
|
-
{
|
|
400
|
-
unsubscribed: options.unsubscribed,
|
|
401
|
-
first_name: options.firstName,
|
|
402
|
-
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"
|
|
403
319
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
return
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
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
|
|
419
344
|
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
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;
|
|
425
363
|
}
|
|
426
364
|
};
|
|
427
365
|
|
|
@@ -439,60 +377,48 @@ var Domains = class {
|
|
|
439
377
|
constructor(resend) {
|
|
440
378
|
this.resend = resend;
|
|
441
379
|
}
|
|
442
|
-
create(
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
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;
|
|
459
410
|
}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
return data;
|
|
466
|
-
});
|
|
411
|
+
async remove(id) {
|
|
412
|
+
const data = await this.resend.delete(
|
|
413
|
+
`/domains/${id}`
|
|
414
|
+
);
|
|
415
|
+
return data;
|
|
467
416
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
click_tracking: payload.clickTracking,
|
|
474
|
-
open_tracking: payload.openTracking,
|
|
475
|
-
tls: payload.tls
|
|
476
|
-
}
|
|
477
|
-
);
|
|
478
|
-
return data;
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
remove(id) {
|
|
482
|
-
return __async(this, null, function* () {
|
|
483
|
-
const data = yield this.resend.delete(
|
|
484
|
-
`/domains/${id}`
|
|
485
|
-
);
|
|
486
|
-
return data;
|
|
487
|
-
});
|
|
488
|
-
}
|
|
489
|
-
verify(id) {
|
|
490
|
-
return __async(this, null, function* () {
|
|
491
|
-
const data = yield this.resend.post(
|
|
492
|
-
`/domains/${id}/verify`
|
|
493
|
-
);
|
|
494
|
-
return data;
|
|
495
|
-
});
|
|
417
|
+
async verify(id) {
|
|
418
|
+
const data = await this.resend.post(
|
|
419
|
+
`/domains/${id}/verify`
|
|
420
|
+
);
|
|
421
|
+
return data;
|
|
496
422
|
}
|
|
497
423
|
};
|
|
498
424
|
|
|
@@ -501,58 +427,46 @@ var Emails = class {
|
|
|
501
427
|
constructor(resend) {
|
|
502
428
|
this.resend = resend;
|
|
503
429
|
}
|
|
504
|
-
send(
|
|
505
|
-
return
|
|
506
|
-
return this.create(payload, options);
|
|
507
|
-
});
|
|
430
|
+
async send(payload, options = {}) {
|
|
431
|
+
return this.create(payload, options);
|
|
508
432
|
}
|
|
509
|
-
create(
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
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
|
|
513
461
|
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
parseEmailToApiOptions(payload),
|
|
517
|
-
options
|
|
518
|
-
);
|
|
519
|
-
return data;
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
get(id) {
|
|
523
|
-
return __async(this, null, function* () {
|
|
524
|
-
const data = yield this.resend.get(
|
|
525
|
-
`/emails/${id}`
|
|
526
|
-
);
|
|
527
|
-
return data;
|
|
528
|
-
});
|
|
462
|
+
);
|
|
463
|
+
return data;
|
|
529
464
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
return data;
|
|
536
|
-
});
|
|
537
|
-
}
|
|
538
|
-
update(payload) {
|
|
539
|
-
return __async(this, null, function* () {
|
|
540
|
-
const data = yield this.resend.patch(
|
|
541
|
-
`/emails/${payload.id}`,
|
|
542
|
-
{
|
|
543
|
-
scheduled_at: payload.scheduledAt
|
|
544
|
-
}
|
|
545
|
-
);
|
|
546
|
-
return data;
|
|
547
|
-
});
|
|
548
|
-
}
|
|
549
|
-
cancel(id) {
|
|
550
|
-
return __async(this, null, function* () {
|
|
551
|
-
const data = yield this.resend.post(
|
|
552
|
-
`/emails/${id}/cancel`
|
|
553
|
-
);
|
|
554
|
-
return data;
|
|
555
|
-
});
|
|
465
|
+
async cancel(id) {
|
|
466
|
+
const data = await this.resend.post(
|
|
467
|
+
`/emails/${id}/cancel`
|
|
468
|
+
);
|
|
469
|
+
return data;
|
|
556
470
|
}
|
|
557
471
|
};
|
|
558
472
|
|
|
@@ -601,129 +515,117 @@ var Resend = class {
|
|
|
601
515
|
"Content-Type": "application/json"
|
|
602
516
|
});
|
|
603
517
|
}
|
|
604
|
-
fetchRequest(
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
}
|
|
621
|
-
};
|
|
622
|
-
}
|
|
623
|
-
const error = {
|
|
624
|
-
message: response.statusText,
|
|
625
|
-
statusCode: response.status,
|
|
626
|
-
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
|
+
}
|
|
627
534
|
};
|
|
628
|
-
if (err instanceof Error) {
|
|
629
|
-
return { data: null, error: __spreadProps(__spreadValues({}, error), { message: err.message }) };
|
|
630
|
-
}
|
|
631
|
-
return { data: null, error };
|
|
632
535
|
}
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
name: "application_error",
|
|
641
|
-
statusCode: null,
|
|
642
|
-
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 }) };
|
|
643
543
|
}
|
|
644
|
-
|
|
645
|
-
}
|
|
646
|
-
});
|
|
647
|
-
}
|
|
648
|
-
post(_0, _1) {
|
|
649
|
-
return __async(this, arguments, function* (path, entity, options = {}) {
|
|
650
|
-
const headers = new Headers(this.headers);
|
|
651
|
-
if (options.headers) {
|
|
652
|
-
for (const [key, value] of new Headers(options.headers).entries()) {
|
|
653
|
-
headers.set(key, value);
|
|
544
|
+
return { data: null, error };
|
|
654
545
|
}
|
|
655
546
|
}
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
return this.fetchRequest(path, requestOptions);
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
get(_0) {
|
|
669
|
-
return __async(this, arguments, function* (path, options = {}) {
|
|
670
|
-
const headers = new Headers(this.headers);
|
|
671
|
-
if (options.headers) {
|
|
672
|
-
for (const [key, value] of new Headers(options.headers).entries()) {
|
|
673
|
-
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."
|
|
674
556
|
}
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
method: "GET"
|
|
678
|
-
}, options), {
|
|
679
|
-
headers
|
|
680
|
-
});
|
|
681
|
-
return this.fetchRequest(path, requestOptions);
|
|
682
|
-
});
|
|
557
|
+
};
|
|
558
|
+
}
|
|
683
559
|
}
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
headers.set(key, value);
|
|
690
|
-
}
|
|
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);
|
|
691
565
|
}
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
})
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
return
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
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);
|
|
708
583
|
}
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
const
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
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);
|
|
727
629
|
}
|
|
728
630
|
};
|
|
729
631
|
// Annotate the CommonJS export names for ESM import in node:
|