resend 6.19.0-preview-headless-dashboard.7 → 6.20.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 CHANGED
@@ -25,7 +25,7 @@ let postal_mime = require("postal-mime");
25
25
  postal_mime = __toESM(postal_mime);
26
26
  let standardwebhooks = require("standardwebhooks");
27
27
  //#region package.json
28
- var version = "6.19.0-preview-headless-dashboard.7";
28
+ var version = "6.20.0";
29
29
  //#endregion
30
30
  //#region src/common/utils/build-pagination-query.ts
31
31
  function buildPaginationUrl(base, options) {
@@ -196,6 +196,9 @@ var Automations = class {
196
196
  if (payload.connections !== void 0) apiPayload.connections = payload.connections.map(parseConnection);
197
197
  return await this.resend.patch(`/automations/${id}`, apiPayload);
198
198
  }
199
+ async duplicate(id) {
200
+ return await this.resend.post(`/automations/${id}/duplicate`);
201
+ }
199
202
  async stop(id) {
200
203
  return await this.resend.post(`/automations/${id}/stop`);
201
204
  }
@@ -303,19 +306,6 @@ var Broadcasts = class {
303
306
  async get(id) {
304
307
  return await this.resend.get(`/broadcasts/${id}`);
305
308
  }
306
- async metrics(options = {}) {
307
- const queryString = buildMetricsQuery$2(options);
308
- const url = queryString ? `/broadcasts/metrics?${queryString}` : "/broadcasts/metrics";
309
- return await this.resend.get(url);
310
- }
311
- async recipients(id, options) {
312
- const url = `/broadcasts/${id}/recipients?${buildRecipientsQuery(options)}`;
313
- return await this.resend.get(url);
314
- }
315
- async clickedLinks(id, options = {}) {
316
- const url = buildPaginationUrl(`/broadcasts/${id}/clicked-links`, options);
317
- return await this.resend.get(url);
318
- }
319
309
  async remove(id) {
320
310
  return await this.resend.delete(`/broadcasts/${id}`);
321
311
  }
@@ -338,28 +328,6 @@ var Broadcasts = class {
338
328
  });
339
329
  }
340
330
  };
341
- function buildMetricsQuery$2(options) {
342
- const params = {
343
- start_date: options.startDate,
344
- end_date: options.endDate,
345
- timezone: options.timezone,
346
- granularity: options.granularity,
347
- metrics: options.metrics?.join(","),
348
- dimensions: options.dimensions?.join(","),
349
- broadcast_id: options.broadcastId?.join(",")
350
- };
351
- const searchParams = new URLSearchParams();
352
- for (const [key, value] of Object.entries(params)) if (value !== void 0 && value !== "") searchParams.set(key, value);
353
- return searchParams.toString();
354
- }
355
- function buildRecipientsQuery(options) {
356
- const { type, email, bounceType, ...pagination } = options;
357
- const searchParams = new URLSearchParams(buildPaginationQuery(pagination));
358
- searchParams.set("type", type);
359
- if (email !== void 0) searchParams.set("email", email);
360
- if (bounceType !== void 0) searchParams.set("bounce_type", bounceType);
361
- return searchParams.toString();
362
- }
363
331
  //#endregion
364
332
  //#region src/common/utils/parse-contact-properties-to-api-options.ts
365
333
  function parseContactPropertyFromApi(contactProperty) {
@@ -922,32 +890,10 @@ var Emails = class {
922
890
  async cancel(id) {
923
891
  return await this.resend.post(`/emails/${id}/cancel`);
924
892
  }
925
- async metrics(options = {}) {
926
- const queryString = buildMetricsQuery$1(options);
927
- const url = queryString ? `/emails/metrics?${queryString}` : "/emails/metrics";
928
- return await this.resend.get(url);
929
- }
930
893
  };
931
- function buildMetricsQuery$1(options) {
932
- const params = {
933
- start_date: options.startDate,
934
- end_date: options.endDate,
935
- timezone: options.timezone,
936
- granularity: options.granularity,
937
- metrics: options.metrics?.join(","),
938
- dimensions: options.dimensions?.join(","),
939
- domain_id: options.filter?.domainId?.join(","),
940
- email_id: options.filter?.emailId?.join(","),
941
- sort_by: options.sortBy,
942
- sort_order: options.sortOrder
943
- };
944
- const searchParams = new URLSearchParams();
945
- for (const [key, value] of Object.entries(params)) if (value !== void 0 && value !== "") searchParams.set(key, value);
946
- return searchParams.toString();
947
- }
948
894
  //#endregion
949
895
  //#region src/events/events.ts
950
- var Events$1 = class {
896
+ var Events = class {
951
897
  constructor(resend) {
952
898
  this.resend = resend;
953
899
  }
@@ -1018,24 +964,7 @@ var Segments = class {
1018
964
  async remove(id) {
1019
965
  return await this.resend.delete(`/segments/${id}`);
1020
966
  }
1021
- async metrics(options = {}) {
1022
- const queryString = buildMetricsQuery(options);
1023
- const url = queryString ? `/segments/metrics?${queryString}` : "/segments/metrics";
1024
- return await this.resend.get(url);
1025
- }
1026
967
  };
1027
- function buildMetricsQuery(options) {
1028
- const params = {
1029
- metrics: options.metrics?.join(","),
1030
- dimensions: options.dimensions?.join(","),
1031
- segment_id: options.filter?.segmentId?.join(","),
1032
- sort_by: options.sortBy,
1033
- sort_order: options.sortOrder
1034
- };
1035
- const searchParams = new URLSearchParams();
1036
- for (const [key, value] of Object.entries(params)) if (value !== void 0 && value !== "") searchParams.set(key, value);
1037
- return searchParams.toString();
1038
- }
1039
968
  //#endregion
1040
969
  //#region src/suppressions/batch/batch.ts
1041
970
  var Batch = class {
@@ -1225,50 +1154,10 @@ var Topics = class {
1225
1154
  }
1226
1155
  };
1227
1156
  //#endregion
1228
- //#region src/usage/usage.ts
1229
- var Usage = class {
1230
- constructor(resend) {
1231
- this.resend = resend;
1232
- }
1233
- async get() {
1234
- return await this.resend.get("/usage");
1235
- }
1236
- };
1237
- //#endregion
1238
- //#region src/webhooks/events/attempts/attempts.ts
1239
- var Attempts = class {
1240
- constructor(resend) {
1241
- this.resend = resend;
1242
- }
1243
- async list(options) {
1244
- const { webhookId, eventId } = options;
1245
- const url = buildPaginationUrl(`/webhooks/${webhookId}/events/${eventId}/attempts`, options);
1246
- return await this.resend.get(url);
1247
- }
1248
- };
1249
- //#endregion
1250
- //#region src/webhooks/events/events.ts
1251
- var Events = class {
1252
- constructor(resend) {
1253
- this.resend = resend;
1254
- this.attempts = new Attempts(resend);
1255
- }
1256
- async list(options) {
1257
- const { webhookId } = options;
1258
- const url = buildPaginationUrl(`/webhooks/${webhookId}/events`, options);
1259
- return await this.resend.get(url);
1260
- }
1261
- async get(options) {
1262
- const { webhookId, eventId } = options;
1263
- return await this.resend.get(`/webhooks/${webhookId}/events/${eventId}`);
1264
- }
1265
- };
1266
- //#endregion
1267
1157
  //#region src/webhooks/webhooks.ts
1268
1158
  var Webhooks = class {
1269
1159
  constructor(resend) {
1270
1160
  this.resend = resend;
1271
- this.events = new Events(resend);
1272
1161
  }
1273
1162
  async create(payload, options = {}) {
1274
1163
  return await this.resend.post("/webhooks", payload, options);
@@ -1317,13 +1206,12 @@ var Resend = class {
1317
1206
  this.contacts = new Contacts(this);
1318
1207
  this.domains = new Domains(this);
1319
1208
  this.emails = new Emails(this);
1320
- this.events = new Events$1(this);
1209
+ this.events = new Events(this);
1321
1210
  this.logs = new Logs(this);
1322
1211
  this.oauthGrants = new OAuthGrants(this);
1323
1212
  this.suppressions = new Suppressions(this);
1324
1213
  this.templates = new Templates(this);
1325
1214
  this.topics = new Topics(this);
1326
- this.usage = new Usage(this);
1327
1215
  this.webhooks = new Webhooks(this);
1328
1216
  if (!key) {
1329
1217
  if (typeof process !== "undefined" && process.env) this.key = process.env.RESEND_API_KEY;