resend 6.2.0-preview-contacts.0 → 6.2.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.js CHANGED
@@ -22,6 +22,18 @@ var __spreadValues = (a, b) => {
22
22
  return a;
23
23
  };
24
24
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __objRest = (source, exclude) => {
26
+ var target = {};
27
+ for (var prop in source)
28
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
+ target[prop] = source[prop];
30
+ if (source != null && __getOwnPropSymbols)
31
+ for (var prop of __getOwnPropSymbols(source)) {
32
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
+ target[prop] = source[prop];
34
+ }
35
+ return target;
36
+ };
25
37
  var __export = (target, all) => {
26
38
  for (var name in all)
27
39
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -72,7 +84,22 @@ __export(index_exports, {
72
84
  module.exports = __toCommonJS(index_exports);
73
85
 
74
86
  // package.json
75
- var version = "6.2.0-preview-contacts.0";
87
+ var version = "6.2.0";
88
+
89
+ // src/common/utils/build-pagination-query.ts
90
+ function buildPaginationQuery(options) {
91
+ const searchParams = new URLSearchParams();
92
+ if (options.limit !== void 0) {
93
+ searchParams.set("limit", options.limit.toString());
94
+ }
95
+ if ("after" in options && options.after !== void 0) {
96
+ searchParams.set("after", options.after);
97
+ }
98
+ if ("before" in options && options.before !== void 0) {
99
+ searchParams.set("before", options.before);
100
+ }
101
+ return searchParams.toString();
102
+ }
76
103
 
77
104
  // src/api-keys/api-keys.ts
78
105
  var ApiKeys = class {
@@ -90,8 +117,10 @@ var ApiKeys = class {
90
117
  });
91
118
  }
92
119
  list() {
93
- return __async(this, null, function* () {
94
- const data = yield this.resend.get("/api-keys");
120
+ return __async(this, arguments, function* (options = {}) {
121
+ const queryString = buildPaginationQuery(options);
122
+ const url = queryString ? `/api-keys?${queryString}` : "/api-keys";
123
+ const data = yield this.resend.get(url);
95
124
  return data;
96
125
  });
97
126
  }
@@ -121,8 +150,10 @@ var Audiences = class {
121
150
  });
122
151
  }
123
152
  list() {
124
- return __async(this, null, function* () {
125
- const data = yield this.resend.get("/audiences");
153
+ return __async(this, arguments, function* (options = {}) {
154
+ const queryString = buildPaginationQuery(options);
155
+ const url = queryString ? `/audiences?${queryString}` : "/audiences";
156
+ const data = yield this.resend.get(url);
126
157
  return data;
127
158
  });
128
159
  }
@@ -167,37 +198,42 @@ function parseEmailToApiOptions(email) {
167
198
  subject: email.subject,
168
199
  tags: email.tags,
169
200
  text: email.text,
170
- to: email.to,
171
- topic_id: email.topicId
201
+ to: email.to
172
202
  };
173
203
  }
174
204
 
205
+ // src/render.ts
206
+ function render(node) {
207
+ return new Promise((resolve, reject) => {
208
+ import("@react-email/render").then(({ render: render2 }) => {
209
+ resolve(render2(node));
210
+ }).catch(() => {
211
+ reject(
212
+ Error(
213
+ "Failed to render React component. Make sure to install `@react-email/render` or `@react-email/components`."
214
+ )
215
+ );
216
+ });
217
+ });
218
+ }
219
+
175
220
  // src/batch/batch.ts
176
221
  var Batch = class {
177
222
  constructor(resend) {
178
223
  this.resend = resend;
179
224
  }
180
- send(_0) {
181
- return __async(this, arguments, function* (payload, options = {}) {
225
+ send(payload, options) {
226
+ return __async(this, null, function* () {
182
227
  return this.create(payload, options);
183
228
  });
184
229
  }
185
- create(_0) {
186
- return __async(this, arguments, function* (payload, options = {}) {
230
+ create(payload, options) {
231
+ return __async(this, null, function* () {
232
+ var _a;
187
233
  const emails = [];
188
234
  for (const email of payload) {
189
235
  if (email.react) {
190
- if (!this.renderAsync) {
191
- try {
192
- const { renderAsync } = yield import("@react-email/render");
193
- this.renderAsync = renderAsync;
194
- } catch (e) {
195
- throw new Error(
196
- "Failed to render React component. Make sure to install `@react-email/render`"
197
- );
198
- }
199
- }
200
- email.html = yield this.renderAsync(email.react);
236
+ email.html = yield render(email.react);
201
237
  email.react = void 0;
202
238
  }
203
239
  emails.push(parseEmailToApiOptions(email));
@@ -205,7 +241,11 @@ var Batch = class {
205
241
  const data = yield this.resend.post(
206
242
  "/emails/batch",
207
243
  emails,
208
- options
244
+ __spreadProps(__spreadValues({}, options), {
245
+ headers: __spreadValues({
246
+ "x-batch-validation": (_a = options == null ? void 0 : options.batchValidation) != null ? _a : "strict"
247
+ }, options == null ? void 0 : options.headers)
248
+ })
209
249
  );
210
250
  return data;
211
251
  });
@@ -220,19 +260,7 @@ var Broadcasts = class {
220
260
  create(_0) {
221
261
  return __async(this, arguments, function* (payload, options = {}) {
222
262
  if (payload.react) {
223
- if (!this.renderAsync) {
224
- try {
225
- const { renderAsync } = yield import("@react-email/render");
226
- this.renderAsync = renderAsync;
227
- } catch (e) {
228
- throw new Error(
229
- "Failed to render React component. Make sure to install `@react-email/render`"
230
- );
231
- }
232
- }
233
- payload.html = yield this.renderAsync(
234
- payload.react
235
- );
263
+ payload.html = yield render(payload.react);
236
264
  }
237
265
  const data = yield this.resend.post(
238
266
  "/broadcasts",
@@ -244,8 +272,7 @@ var Broadcasts = class {
244
272
  html: payload.html,
245
273
  reply_to: payload.replyTo,
246
274
  subject: payload.subject,
247
- text: payload.text,
248
- topic_id: payload.topicId
275
+ text: payload.text
249
276
  },
250
277
  options
251
278
  );
@@ -262,8 +289,10 @@ var Broadcasts = class {
262
289
  });
263
290
  }
264
291
  list() {
265
- return __async(this, null, function* () {
266
- const data = yield this.resend.get("/broadcasts");
292
+ return __async(this, arguments, function* (options = {}) {
293
+ const queryString = buildPaginationQuery(options);
294
+ const url = queryString ? `/broadcasts?${queryString}` : "/broadcasts";
295
+ const data = yield this.resend.get(url);
267
296
  return data;
268
297
  });
269
298
  }
@@ -286,19 +315,7 @@ var Broadcasts = class {
286
315
  update(id, payload) {
287
316
  return __async(this, null, function* () {
288
317
  if (payload.react) {
289
- if (!this.renderAsync) {
290
- try {
291
- const { renderAsync } = yield import("@react-email/render");
292
- this.renderAsync = renderAsync;
293
- } catch (e) {
294
- throw new Error(
295
- "Failed to render React component. Make sure to install `@react-email/render`"
296
- );
297
- }
298
- }
299
- payload.html = yield this.renderAsync(
300
- payload.react
301
- );
318
+ payload.html = yield render(payload.react);
302
319
  }
303
320
  const data = yield this.resend.patch(
304
321
  `/broadcasts/${id}`,
@@ -310,8 +327,7 @@ var Broadcasts = class {
310
327
  text: payload.text,
311
328
  subject: payload.subject,
312
329
  reply_to: payload.replyTo,
313
- preview_text: payload.previewText,
314
- topic_id: payload.topicId
330
+ preview_text: payload.previewText
315
331
  }
316
332
  );
317
333
  return data;
@@ -319,159 +335,13 @@ var Broadcasts = class {
319
335
  }
320
336
  };
321
337
 
322
- // src/common/utils/create-pagination-query.ts
323
- function createPaginationQuery(options) {
324
- return {
325
- limit: options.limit,
326
- after: "after" in options ? options.after : void 0,
327
- before: "before" in options ? options.before : void 0
328
- };
329
- }
330
-
331
- // src/common/utils/format-paginated-response.ts
332
- function formatPaginatedResponse(response) {
333
- if (!response.data) {
334
- return response;
335
- }
336
- return __spreadProps(__spreadValues({}, response), {
337
- data: {
338
- object: "list",
339
- data: response.data.data,
340
- hasMore: response.data.has_more
341
- }
342
- });
343
- }
344
-
345
- // src/contacts/audiences/contact-audiences.ts
346
- var ContactAudiences = class {
347
- constructor(resend) {
348
- this.resend = resend;
349
- }
350
- list(options) {
351
- return __async(this, null, function* () {
352
- if (!options.contactId && !options.email) {
353
- return {
354
- data: null,
355
- rateLimiting: null,
356
- error: {
357
- message: "Missing `id` or `email` field.",
358
- name: "missing_required_field"
359
- }
360
- };
361
- }
362
- const identifier = options.email ? options.email : options.contactId;
363
- const query = createPaginationQuery(options);
364
- const data = yield this.resend.get(
365
- `/contacts/${identifier}/audiences`,
366
- query
367
- );
368
- return formatPaginatedResponse(data);
369
- });
370
- }
371
- add(options) {
372
- return __async(this, null, function* () {
373
- if (!options.contactId && !options.email) {
374
- return {
375
- data: null,
376
- rateLimiting: null,
377
- error: {
378
- message: "Missing `id` or `email` field.",
379
- name: "missing_required_field"
380
- }
381
- };
382
- }
383
- const identifier = options.email ? options.email : options.contactId;
384
- return this.resend.post(
385
- `/contacts/${identifier}/audiences/${options.audienceId}`
386
- );
387
- });
388
- }
389
- remove(options) {
390
- return __async(this, null, function* () {
391
- if (!options.contactId && !options.email) {
392
- return {
393
- data: null,
394
- rateLimiting: null,
395
- error: {
396
- message: "Missing `id` or `email` field.",
397
- name: "missing_required_field"
398
- }
399
- };
400
- }
401
- const identifier = options.email ? options.email : options.contactId;
402
- return this.resend.delete(
403
- `/contacts/${identifier}/audiences/${options.audienceId}`
404
- );
405
- });
406
- }
407
- };
408
-
409
- // src/contacts/topics/contact-topics.ts
410
- var ContactTopics = class {
411
- constructor(resend) {
412
- this.resend = resend;
413
- }
414
- update(payload) {
415
- return __async(this, null, function* () {
416
- if (!payload.id && !payload.email) {
417
- return {
418
- data: null,
419
- error: {
420
- message: "Missing `id` or `email` field.",
421
- name: "missing_required_field"
422
- }
423
- };
424
- }
425
- const identifier = payload.email ? payload.email : payload.id;
426
- const data = yield this.resend.patch(
427
- `/contacts/${identifier}/topics`,
428
- payload.topics
429
- );
430
- return data;
431
- });
432
- }
433
- get(options) {
434
- return __async(this, null, function* () {
435
- if (!options.id && !options.email) {
436
- return {
437
- data: null,
438
- error: {
439
- message: "Missing `id` or `email` field.",
440
- name: "missing_required_field"
441
- }
442
- };
443
- }
444
- const identifier = options.email ? options.email : options.id;
445
- const data = yield this.resend.get(
446
- `/contacts/${identifier}/topics`
447
- );
448
- return data;
449
- });
450
- }
451
- };
452
-
453
338
  // src/contacts/contacts.ts
454
339
  var Contacts = class {
455
340
  constructor(resend) {
456
341
  this.resend = resend;
457
- this.topics = new ContactTopics(this.resend);
458
- this.audiences = new ContactAudiences(this.resend);
459
342
  }
460
343
  create(_0) {
461
344
  return __async(this, arguments, function* (payload, options = {}) {
462
- if (!payload.audienceId) {
463
- const data2 = yield this.resend.post(
464
- "/contacts",
465
- {
466
- unsubscribed: payload.unsubscribed,
467
- email: payload.email,
468
- first_name: payload.firstName,
469
- last_name: payload.lastName
470
- },
471
- options
472
- );
473
- return data2;
474
- }
475
345
  const data = yield this.resend.post(
476
346
  `/audiences/${payload.audienceId}/contacts`,
477
347
  {
@@ -487,17 +357,10 @@ var Contacts = class {
487
357
  }
488
358
  list(options) {
489
359
  return __async(this, null, function* () {
490
- if (!("audienceId" in options)) {
491
- const query = createPaginationQuery(options);
492
- const data2 = yield this.resend.get(
493
- "/contacts",
494
- { query }
495
- );
496
- return formatPaginatedResponse(data2);
497
- }
498
- const data = yield this.resend.get(
499
- `/audiences/${options.audienceId}/contacts`
500
- );
360
+ const _a = options, { audienceId } = _a, paginationOptions = __objRest(_a, ["audienceId"]);
361
+ const queryString = buildPaginationQuery(paginationOptions);
362
+ const url = queryString ? `/audiences/${audienceId}/contacts?${queryString}` : `/audiences/${audienceId}/contacts`;
363
+ const data = yield this.resend.get(url);
501
364
  return data;
502
365
  });
503
366
  }
@@ -506,19 +369,12 @@ var Contacts = class {
506
369
  if (!options.id && !options.email) {
507
370
  return {
508
371
  data: null,
509
- rateLimiting: null,
510
372
  error: {
511
373
  message: "Missing `id` or `email` field.",
512
374
  name: "missing_required_field"
513
375
  }
514
376
  };
515
377
  }
516
- if (!options.audienceId) {
517
- const data2 = yield this.resend.get(
518
- `/contacts/${(options == null ? void 0 : options.email) ? options == null ? void 0 : options.email : options == null ? void 0 : options.id}`
519
- );
520
- return data2;
521
- }
522
378
  const data = yield this.resend.get(
523
379
  `/audiences/${options.audienceId}/contacts/${(options == null ? void 0 : options.email) ? options == null ? void 0 : options.email : options == null ? void 0 : options.id}`
524
380
  );
@@ -530,24 +386,12 @@ var Contacts = class {
530
386
  if (!options.id && !options.email) {
531
387
  return {
532
388
  data: null,
533
- rateLimiting: null,
534
389
  error: {
535
390
  message: "Missing `id` or `email` field.",
536
391
  name: "missing_required_field"
537
392
  }
538
393
  };
539
394
  }
540
- if (!options.audienceId) {
541
- const data2 = yield this.resend.patch(
542
- `/contacts/${(options == null ? void 0 : options.email) ? options == null ? void 0 : options.email : options == null ? void 0 : options.id}`,
543
- {
544
- unsubscribed: options.unsubscribed,
545
- first_name: options.firstName,
546
- last_name: options.lastName
547
- }
548
- );
549
- return data2;
550
- }
551
395
  const data = yield this.resend.patch(
552
396
  `/audiences/${options.audienceId}/contacts/${(options == null ? void 0 : options.email) ? options == null ? void 0 : options.email : options == null ? void 0 : options.id}`,
553
397
  {
@@ -564,19 +408,12 @@ var Contacts = class {
564
408
  if (!payload.id && !payload.email) {
565
409
  return {
566
410
  data: null,
567
- rateLimiting: null,
568
411
  error: {
569
412
  message: "Missing `id` or `email` field.",
570
413
  name: "missing_required_field"
571
414
  }
572
415
  };
573
416
  }
574
- if (!payload.audienceId) {
575
- const data2 = yield this.resend.delete(
576
- `/contacts/${(payload == null ? void 0 : payload.email) ? payload == null ? void 0 : payload.email : payload == null ? void 0 : payload.id}`
577
- );
578
- return data2;
579
- }
580
417
  const data = yield this.resend.delete(
581
418
  `/audiences/${payload.audienceId}/contacts/${(payload == null ? void 0 : payload.email) ? payload == null ? void 0 : payload.email : payload == null ? void 0 : payload.id}`
582
419
  );
@@ -610,8 +447,10 @@ var Domains = class {
610
447
  });
611
448
  }
612
449
  list() {
613
- return __async(this, null, function* () {
614
- const data = yield this.resend.get("/domains");
450
+ return __async(this, arguments, function* (options = {}) {
451
+ const queryString = buildPaginationQuery(options);
452
+ const url = queryString ? `/domains?${queryString}` : "/domains";
453
+ const data = yield this.resend.get(url);
615
454
  return data;
616
455
  });
617
456
  }
@@ -667,19 +506,7 @@ var Emails = class {
667
506
  create(_0) {
668
507
  return __async(this, arguments, function* (payload, options = {}) {
669
508
  if (payload.react) {
670
- if (!this.renderAsync) {
671
- try {
672
- const { renderAsync } = yield import("@react-email/render");
673
- this.renderAsync = renderAsync;
674
- } catch (e) {
675
- throw new Error(
676
- "Failed to render React component. Make sure to install `@react-email/render`"
677
- );
678
- }
679
- }
680
- payload.html = yield this.renderAsync(
681
- payload.react
682
- );
509
+ payload.html = yield render(payload.react);
683
510
  }
684
511
  const data = yield this.resend.post(
685
512
  "/emails",
@@ -697,6 +524,14 @@ var Emails = class {
697
524
  return data;
698
525
  });
699
526
  }
527
+ list() {
528
+ return __async(this, arguments, function* (options = {}) {
529
+ const queryString = buildPaginationQuery(options);
530
+ const url = queryString ? `/emails?${queryString}` : "/emails";
531
+ const data = yield this.resend.get(url);
532
+ return data;
533
+ });
534
+ }
700
535
  update(payload) {
701
536
  return __async(this, null, function* () {
702
537
  const data = yield this.resend.patch(
@@ -718,96 +553,15 @@ var Emails = class {
718
553
  }
719
554
  };
720
555
 
721
- // src/rate-limiting.ts
722
- function parseRateLimit(headers) {
723
- const limitHeader = headers.get("ratelimit-limit");
724
- const remainingHeader = headers.get("ratelimit-remaining");
725
- const resetHeader = headers.get("ratelimit-reset");
726
- if (!limitHeader || !remainingHeader || !resetHeader) {
727
- throw new Error(
728
- "The rate limit headers are not present in the response, something must've gone wrong, please email us at support@resend.com"
729
- );
730
- }
731
- const limit = Number.parseInt(limitHeader, 10);
732
- const remaining = Number.parseInt(remainingHeader, 10);
733
- const reset = Number.parseInt(resetHeader, 10);
734
- return {
735
- limit,
736
- remainingRequests: remaining,
737
- shouldResetAfter: reset
738
- };
739
- }
740
-
741
- // src/topics/topics.ts
742
- var Topics = class {
743
- constructor(resend) {
744
- this.resend = resend;
745
- }
746
- create(payload) {
747
- return __async(this, null, function* () {
748
- const data = yield this.resend.post(
749
- "/topics",
750
- payload
751
- );
752
- return data;
753
- });
754
- }
755
- list() {
756
- return __async(this, null, function* () {
757
- const data = yield this.resend.get("/topics");
758
- return data;
759
- });
760
- }
761
- get(id) {
762
- return __async(this, null, function* () {
763
- if (!id) {
764
- return {
765
- data: null,
766
- error: {
767
- message: "Missing `id` field.",
768
- name: "missing_required_field"
769
- }
770
- };
771
- }
772
- const data = yield this.resend.get(
773
- `/topics/${id}`
774
- );
775
- return data;
776
- });
777
- }
778
- update(payload) {
779
- return __async(this, null, function* () {
780
- if (!payload.id) {
781
- return {
782
- data: null,
783
- error: {
784
- message: "Missing `id` field.",
785
- name: "missing_required_field"
786
- }
787
- };
788
- }
789
- const data = yield this.resend.patch(
790
- `/topics/${payload.id}`,
791
- payload
792
- );
793
- return data;
794
- });
795
- }
796
- remove(id) {
797
- return __async(this, null, function* () {
798
- if (!id) {
799
- return {
800
- data: null,
801
- error: {
802
- message: "Missing `id` field.",
803
- name: "missing_required_field"
804
- }
805
- };
806
- }
807
- const data = yield this.resend.delete(
808
- `/topics/${id}`
809
- );
810
- return data;
556
+ // src/webhooks/webhooks.ts
557
+ var import_svix = require("svix");
558
+ var Webhooks = class {
559
+ verify(payload) {
560
+ const webhook = new import_svix.Webhook(payload.webhookSecret);
561
+ return webhook.verify(payload.payload, {
562
+ "svix-id": payload.headers.id,
563
+ "svix-timestamp": payload.headers.timestamp,
564
+ "svix-signature": payload.headers.signature
811
565
  });
812
566
  }
813
567
  };
@@ -827,7 +581,7 @@ var Resend = class {
827
581
  this.contacts = new Contacts(this);
828
582
  this.domains = new Domains(this);
829
583
  this.emails = new Emails(this);
830
- this.topics = new Topics(this);
584
+ this.webhooks = new Webhooks();
831
585
  if (!key) {
832
586
  if (typeof process !== "undefined" && process.env) {
833
587
  this.key = process.env.RESEND_API_KEY;
@@ -848,23 +602,14 @@ var Resend = class {
848
602
  return __async(this, arguments, function* (path, options = {}) {
849
603
  try {
850
604
  const response = yield fetch(`${baseUrl}${path}`, options);
851
- const rateLimiting = parseRateLimit(response.headers);
852
605
  if (!response.ok) {
853
606
  try {
854
607
  const rawError = yield response.text();
855
- const error = JSON.parse(rawError);
856
- if (error.name === "rate_limit_exceeded" && response.status === 429) {
857
- const retryAfterHeader = response.headers.get("retry-after");
858
- if (retryAfterHeader) {
859
- error.retryAfter = Number.parseInt(retryAfterHeader, 10);
860
- }
861
- }
862
- return { data: null, rateLimiting, error };
608
+ return { data: null, error: JSON.parse(rawError) };
863
609
  } catch (err) {
864
610
  if (err instanceof SyntaxError) {
865
611
  return {
866
612
  data: null,
867
- rateLimiting,
868
613
  error: {
869
614
  name: "application_error",
870
615
  message: "Internal server error. We are unable to process your request right now, please try again later."
@@ -876,21 +621,16 @@ var Resend = class {
876
621
  name: "application_error"
877
622
  };
878
623
  if (err instanceof Error) {
879
- return {
880
- data: null,
881
- rateLimiting,
882
- error: __spreadProps(__spreadValues({}, error), { message: err.message })
883
- };
624
+ return { data: null, error: __spreadProps(__spreadValues({}, error), { message: err.message }) };
884
625
  }
885
- return { data: null, rateLimiting, error };
626
+ return { data: null, error };
886
627
  }
887
628
  }
888
629
  const data = yield response.json();
889
- return { data, rateLimiting, error: null };
630
+ return { data, error: null };
890
631
  } catch (e) {
891
632
  return {
892
633
  data: null,
893
- rateLimiting: null,
894
634
  error: {
895
635
  name: "application_error",
896
636
  message: "Unable to fetch data. The request could not be resolved."
@@ -902,43 +642,70 @@ var Resend = class {
902
642
  post(_0, _1) {
903
643
  return __async(this, arguments, function* (path, entity, options = {}) {
904
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);
648
+ }
649
+ }
905
650
  if (options.idempotencyKey) {
906
651
  headers.set("Idempotency-Key", options.idempotencyKey);
907
652
  }
908
- const requestOptions = __spreadValues({
653
+ const requestOptions = __spreadProps(__spreadValues({
909
654
  method: "POST",
910
- headers,
911
655
  body: JSON.stringify(entity)
912
- }, options);
656
+ }, options), {
657
+ headers
658
+ });
913
659
  return this.fetchRequest(path, requestOptions);
914
660
  });
915
661
  }
916
662
  get(_0) {
917
663
  return __async(this, arguments, function* (path, options = {}) {
918
- const requestOptions = __spreadValues({
919
- method: "GET",
920
- headers: this.headers
921
- }, 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);
668
+ }
669
+ }
670
+ const requestOptions = __spreadProps(__spreadValues({
671
+ method: "GET"
672
+ }, options), {
673
+ headers
674
+ });
922
675
  return this.fetchRequest(path, requestOptions);
923
676
  });
924
677
  }
925
678
  put(_0, _1) {
926
679
  return __async(this, arguments, function* (path, entity, options = {}) {
927
- const requestOptions = __spreadValues({
680
+ const headers = new Headers(this.headers);
681
+ if (options.headers) {
682
+ for (const [key, value] of new Headers(options.headers).entries()) {
683
+ headers.set(key, value);
684
+ }
685
+ }
686
+ const requestOptions = __spreadProps(__spreadValues({
928
687
  method: "PUT",
929
- headers: this.headers,
930
688
  body: JSON.stringify(entity)
931
- }, options);
689
+ }, options), {
690
+ headers
691
+ });
932
692
  return this.fetchRequest(path, requestOptions);
933
693
  });
934
694
  }
935
695
  patch(_0, _1) {
936
696
  return __async(this, arguments, function* (path, entity, options = {}) {
937
- const requestOptions = __spreadValues({
697
+ const headers = new Headers(this.headers);
698
+ if (options.headers) {
699
+ for (const [key, value] of new Headers(options.headers).entries()) {
700
+ headers.set(key, value);
701
+ }
702
+ }
703
+ const requestOptions = __spreadProps(__spreadValues({
938
704
  method: "PATCH",
939
- headers: this.headers,
940
705
  body: JSON.stringify(entity)
941
- }, options);
706
+ }, options), {
707
+ headers
708
+ });
942
709
  return this.fetchRequest(path, requestOptions);
943
710
  });
944
711
  }
@@ -946,8 +713,8 @@ var Resend = class {
946
713
  return __async(this, null, function* () {
947
714
  const requestOptions = {
948
715
  method: "DELETE",
949
- headers: this.headers,
950
- body: JSON.stringify(query)
716
+ body: JSON.stringify(query),
717
+ headers: this.headers
951
718
  };
952
719
  return this.fetchRequest(path, requestOptions);
953
720
  });