resend 4.6.0 → 4.7.0-preview-topics.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.d.mts CHANGED
@@ -550,8 +550,51 @@ interface UpdateContactResponse {
550
550
  error: ErrorResponse | null;
551
551
  }
552
552
 
553
+ interface GetContactTopicsBaseOptions {
554
+ id?: string;
555
+ email?: string;
556
+ }
557
+ interface GetContactTopicsOptions extends GetContactTopicsBaseOptions {
558
+ }
559
+ interface ContactTopic {
560
+ id: string;
561
+ subscription: 'opt_in' | 'opt_out';
562
+ }
563
+ interface GetContactTopicsResponseSuccess {
564
+ email: string;
565
+ topics: ContactTopic[];
566
+ }
567
+ interface GetContactTopicsResponse {
568
+ data: GetContactTopicsResponseSuccess | null;
569
+ error: ErrorResponse | null;
570
+ }
571
+
572
+ interface UpdateContactTopicsBaseOptions {
573
+ id?: string;
574
+ email?: string;
575
+ }
576
+ interface UpdateContactTopicsOptions extends UpdateContactTopicsBaseOptions {
577
+ opt_in?: string | string[];
578
+ opt_out?: string | string[];
579
+ }
580
+ interface UpdateContactTopicsResponseSuccess {
581
+ id: string;
582
+ }
583
+ interface UpdateContactTopicsResponse {
584
+ data: UpdateContactTopicsResponseSuccess | null;
585
+ error: ErrorResponse | null;
586
+ }
587
+
588
+ declare class ContactTopics {
589
+ private readonly resend;
590
+ constructor(resend: Resend);
591
+ update(payload: UpdateContactTopicsOptions): Promise<UpdateContactTopicsResponse>;
592
+ get(options: GetContactTopicsOptions): Promise<GetContactTopicsResponse>;
593
+ }
594
+
553
595
  declare class Contacts {
554
596
  private readonly resend;
597
+ readonly topics: ContactTopics;
555
598
  constructor(resend: Resend);
556
599
  create(payload: CreateContactOptions, options?: CreateContactRequestOptions): Promise<CreateContactResponse>;
557
600
  list(options: ListContactsOptions): Promise<ListContactsResponse>;
@@ -720,6 +763,69 @@ declare class Emails {
720
763
  cancel(id: string): Promise<CancelEmailResponse>;
721
764
  }
722
765
 
766
+ interface Topic {
767
+ id: string;
768
+ name: string;
769
+ description?: string;
770
+ default_subscription: 'opt_in' | 'opt_out';
771
+ created_at: string;
772
+ }
773
+
774
+ interface CreateTopicOptions {
775
+ name: string;
776
+ description?: string;
777
+ default_subscription: 'opt_in' | 'opt_out';
778
+ }
779
+ type CreateTopicResponseSuccess = Pick<Topic, 'id'>;
780
+ interface CreateTopicResponse {
781
+ data: CreateTopicResponseSuccess | null;
782
+ error: ErrorResponse | null;
783
+ }
784
+
785
+ type GetTopicResponseSuccess = Topic;
786
+ interface GetTopicResponse {
787
+ data: GetTopicResponseSuccess | null;
788
+ error: ErrorResponse | null;
789
+ }
790
+
791
+ interface ListTopicsResponseSuccess {
792
+ data: Topic[];
793
+ }
794
+ interface ListTopicsResponse {
795
+ data: ListTopicsResponseSuccess | null;
796
+ error: ErrorResponse | null;
797
+ }
798
+
799
+ type RemoveTopicResponseSuccess = Pick<Topic, 'id'> & {
800
+ object: 'topic';
801
+ deleted: boolean;
802
+ };
803
+ interface RemoveTopicResponse {
804
+ data: RemoveTopicResponseSuccess | null;
805
+ error: ErrorResponse | null;
806
+ }
807
+
808
+ interface UpdateTopicOptions {
809
+ id: string;
810
+ name?: string;
811
+ description?: string;
812
+ }
813
+ type UpdateTopicResponseSuccess = Pick<Topic, 'id'>;
814
+ interface UpdateTopicResponse {
815
+ data: UpdateTopicResponseSuccess | null;
816
+ error: ErrorResponse | null;
817
+ }
818
+
819
+ declare class Topics {
820
+ private readonly resend;
821
+ constructor(resend: Resend);
822
+ create(payload: CreateTopicOptions): Promise<CreateTopicResponse>;
823
+ list(): Promise<ListTopicsResponse>;
824
+ get(id: string): Promise<GetTopicResponse>;
825
+ update(payload: UpdateTopicOptions): Promise<UpdateTopicResponse>;
826
+ remove(id: string): Promise<RemoveTopicResponse>;
827
+ }
828
+
723
829
  declare class Resend {
724
830
  readonly key?: string | undefined;
725
831
  private readonly headers;
@@ -730,6 +836,7 @@ declare class Resend {
730
836
  readonly contacts: Contacts;
731
837
  readonly domains: Domains;
732
838
  readonly emails: Emails;
839
+ readonly topics: Topics;
733
840
  constructor(key?: string | undefined);
734
841
  fetchRequest<T>(path: string, options?: {}): Promise<{
735
842
  data: T | null;
package/dist/index.d.ts CHANGED
@@ -550,8 +550,51 @@ interface UpdateContactResponse {
550
550
  error: ErrorResponse | null;
551
551
  }
552
552
 
553
+ interface GetContactTopicsBaseOptions {
554
+ id?: string;
555
+ email?: string;
556
+ }
557
+ interface GetContactTopicsOptions extends GetContactTopicsBaseOptions {
558
+ }
559
+ interface ContactTopic {
560
+ id: string;
561
+ subscription: 'opt_in' | 'opt_out';
562
+ }
563
+ interface GetContactTopicsResponseSuccess {
564
+ email: string;
565
+ topics: ContactTopic[];
566
+ }
567
+ interface GetContactTopicsResponse {
568
+ data: GetContactTopicsResponseSuccess | null;
569
+ error: ErrorResponse | null;
570
+ }
571
+
572
+ interface UpdateContactTopicsBaseOptions {
573
+ id?: string;
574
+ email?: string;
575
+ }
576
+ interface UpdateContactTopicsOptions extends UpdateContactTopicsBaseOptions {
577
+ opt_in?: string | string[];
578
+ opt_out?: string | string[];
579
+ }
580
+ interface UpdateContactTopicsResponseSuccess {
581
+ id: string;
582
+ }
583
+ interface UpdateContactTopicsResponse {
584
+ data: UpdateContactTopicsResponseSuccess | null;
585
+ error: ErrorResponse | null;
586
+ }
587
+
588
+ declare class ContactTopics {
589
+ private readonly resend;
590
+ constructor(resend: Resend);
591
+ update(payload: UpdateContactTopicsOptions): Promise<UpdateContactTopicsResponse>;
592
+ get(options: GetContactTopicsOptions): Promise<GetContactTopicsResponse>;
593
+ }
594
+
553
595
  declare class Contacts {
554
596
  private readonly resend;
597
+ readonly topics: ContactTopics;
555
598
  constructor(resend: Resend);
556
599
  create(payload: CreateContactOptions, options?: CreateContactRequestOptions): Promise<CreateContactResponse>;
557
600
  list(options: ListContactsOptions): Promise<ListContactsResponse>;
@@ -720,6 +763,69 @@ declare class Emails {
720
763
  cancel(id: string): Promise<CancelEmailResponse>;
721
764
  }
722
765
 
766
+ interface Topic {
767
+ id: string;
768
+ name: string;
769
+ description?: string;
770
+ default_subscription: 'opt_in' | 'opt_out';
771
+ created_at: string;
772
+ }
773
+
774
+ interface CreateTopicOptions {
775
+ name: string;
776
+ description?: string;
777
+ default_subscription: 'opt_in' | 'opt_out';
778
+ }
779
+ type CreateTopicResponseSuccess = Pick<Topic, 'id'>;
780
+ interface CreateTopicResponse {
781
+ data: CreateTopicResponseSuccess | null;
782
+ error: ErrorResponse | null;
783
+ }
784
+
785
+ type GetTopicResponseSuccess = Topic;
786
+ interface GetTopicResponse {
787
+ data: GetTopicResponseSuccess | null;
788
+ error: ErrorResponse | null;
789
+ }
790
+
791
+ interface ListTopicsResponseSuccess {
792
+ data: Topic[];
793
+ }
794
+ interface ListTopicsResponse {
795
+ data: ListTopicsResponseSuccess | null;
796
+ error: ErrorResponse | null;
797
+ }
798
+
799
+ type RemoveTopicResponseSuccess = Pick<Topic, 'id'> & {
800
+ object: 'topic';
801
+ deleted: boolean;
802
+ };
803
+ interface RemoveTopicResponse {
804
+ data: RemoveTopicResponseSuccess | null;
805
+ error: ErrorResponse | null;
806
+ }
807
+
808
+ interface UpdateTopicOptions {
809
+ id: string;
810
+ name?: string;
811
+ description?: string;
812
+ }
813
+ type UpdateTopicResponseSuccess = Pick<Topic, 'id'>;
814
+ interface UpdateTopicResponse {
815
+ data: UpdateTopicResponseSuccess | null;
816
+ error: ErrorResponse | null;
817
+ }
818
+
819
+ declare class Topics {
820
+ private readonly resend;
821
+ constructor(resend: Resend);
822
+ create(payload: CreateTopicOptions): Promise<CreateTopicResponse>;
823
+ list(): Promise<ListTopicsResponse>;
824
+ get(id: string): Promise<GetTopicResponse>;
825
+ update(payload: UpdateTopicOptions): Promise<UpdateTopicResponse>;
826
+ remove(id: string): Promise<RemoveTopicResponse>;
827
+ }
828
+
723
829
  declare class Resend {
724
830
  readonly key?: string | undefined;
725
831
  private readonly headers;
@@ -730,6 +836,7 @@ declare class Resend {
730
836
  readonly contacts: Contacts;
731
837
  readonly domains: Domains;
732
838
  readonly emails: Emails;
839
+ readonly topics: Topics;
733
840
  constructor(key?: string | undefined);
734
841
  fetchRequest<T>(path: string, options?: {}): Promise<{
735
842
  data: T | null;
package/dist/index.js CHANGED
@@ -72,7 +72,7 @@ __export(src_exports, {
72
72
  module.exports = __toCommonJS(src_exports);
73
73
 
74
74
  // package.json
75
- var version = "4.6.0";
75
+ var version = "4.7.0-preview-topics.0";
76
76
 
77
77
  // src/api-keys/api-keys.ts
78
78
  var ApiKeys = class {
@@ -292,10 +292,58 @@ var Broadcasts = class {
292
292
  }
293
293
  };
294
294
 
295
+ // src/contacts/topics/contact-topics.ts
296
+ var ContactTopics = class {
297
+ constructor(resend) {
298
+ this.resend = resend;
299
+ }
300
+ update(payload) {
301
+ return __async(this, null, function* () {
302
+ if (!payload.id && !payload.email) {
303
+ return {
304
+ data: null,
305
+ error: {
306
+ message: "Missing `id` or `email` field.",
307
+ name: "missing_required_field"
308
+ }
309
+ };
310
+ }
311
+ const identifier = payload.email ? payload.email : payload.id;
312
+ const data = yield this.resend.patch(
313
+ `/contacts/${identifier}/topics`,
314
+ {
315
+ opt_in: payload.opt_in,
316
+ opt_out: payload.opt_out
317
+ }
318
+ );
319
+ return data;
320
+ });
321
+ }
322
+ get(options) {
323
+ return __async(this, null, function* () {
324
+ if (!options.id && !options.email) {
325
+ return {
326
+ data: null,
327
+ error: {
328
+ message: "Missing `id` or `email` field.",
329
+ name: "missing_required_field"
330
+ }
331
+ };
332
+ }
333
+ const identifier = options.email ? options.email : options.id;
334
+ const data = yield this.resend.get(
335
+ `/contacts/${identifier}/topics`
336
+ );
337
+ return data;
338
+ });
339
+ }
340
+ };
341
+
295
342
  // src/contacts/contacts.ts
296
343
  var Contacts = class {
297
344
  constructor(resend) {
298
345
  this.resend = resend;
346
+ this.topics = new ContactTopics(this.resend);
299
347
  }
300
348
  create(_0) {
301
349
  return __async(this, arguments, function* (payload, options = {}) {
@@ -511,6 +559,80 @@ var Emails = class {
511
559
  }
512
560
  };
513
561
 
562
+ // src/topics/topics.ts
563
+ var Topics = class {
564
+ constructor(resend) {
565
+ this.resend = resend;
566
+ }
567
+ create(payload) {
568
+ return __async(this, null, function* () {
569
+ const data = yield this.resend.post(
570
+ "/topics",
571
+ payload
572
+ );
573
+ return data;
574
+ });
575
+ }
576
+ list() {
577
+ return __async(this, null, function* () {
578
+ const data = yield this.resend.get("/topics");
579
+ return data;
580
+ });
581
+ }
582
+ get(id) {
583
+ return __async(this, null, function* () {
584
+ if (!id) {
585
+ return {
586
+ data: null,
587
+ error: {
588
+ message: "Missing `id` field.",
589
+ name: "missing_required_field"
590
+ }
591
+ };
592
+ }
593
+ const data = yield this.resend.get(
594
+ `/topics/${id}`
595
+ );
596
+ return data;
597
+ });
598
+ }
599
+ update(payload) {
600
+ return __async(this, null, function* () {
601
+ if (!payload.id) {
602
+ return {
603
+ data: null,
604
+ error: {
605
+ message: "Missing `id` field.",
606
+ name: "missing_required_field"
607
+ }
608
+ };
609
+ }
610
+ const data = yield this.resend.patch(
611
+ `/topics/${payload.id}`,
612
+ payload
613
+ );
614
+ return data;
615
+ });
616
+ }
617
+ remove(id) {
618
+ return __async(this, null, function* () {
619
+ if (!id) {
620
+ return {
621
+ data: null,
622
+ error: {
623
+ message: "Missing `id` field.",
624
+ name: "missing_required_field"
625
+ }
626
+ };
627
+ }
628
+ const data = yield this.resend.delete(
629
+ `/topics/${id}`
630
+ );
631
+ return data;
632
+ });
633
+ }
634
+ };
635
+
514
636
  // src/resend.ts
515
637
  var defaultBaseUrl = "https://api.resend.com";
516
638
  var defaultUserAgent = `resend-node:${version}`;
@@ -526,6 +648,7 @@ var Resend = class {
526
648
  this.contacts = new Contacts(this);
527
649
  this.domains = new Domains(this);
528
650
  this.emails = new Emails(this);
651
+ this.topics = new Topics(this);
529
652
  if (!key) {
530
653
  if (typeof process !== "undefined" && process.env) {
531
654
  this.key = process.env.RESEND_API_KEY;
package/dist/index.mjs CHANGED
@@ -39,7 +39,7 @@ var __async = (__this, __arguments, generator) => {
39
39
  };
40
40
 
41
41
  // package.json
42
- var version = "4.6.0";
42
+ var version = "4.7.0-preview-topics.0";
43
43
 
44
44
  // src/api-keys/api-keys.ts
45
45
  var ApiKeys = class {
@@ -259,10 +259,58 @@ var Broadcasts = class {
259
259
  }
260
260
  };
261
261
 
262
+ // src/contacts/topics/contact-topics.ts
263
+ var ContactTopics = class {
264
+ constructor(resend) {
265
+ this.resend = resend;
266
+ }
267
+ update(payload) {
268
+ return __async(this, null, function* () {
269
+ if (!payload.id && !payload.email) {
270
+ return {
271
+ data: null,
272
+ error: {
273
+ message: "Missing `id` or `email` field.",
274
+ name: "missing_required_field"
275
+ }
276
+ };
277
+ }
278
+ const identifier = payload.email ? payload.email : payload.id;
279
+ const data = yield this.resend.patch(
280
+ `/contacts/${identifier}/topics`,
281
+ {
282
+ opt_in: payload.opt_in,
283
+ opt_out: payload.opt_out
284
+ }
285
+ );
286
+ return data;
287
+ });
288
+ }
289
+ get(options) {
290
+ return __async(this, null, function* () {
291
+ if (!options.id && !options.email) {
292
+ return {
293
+ data: null,
294
+ error: {
295
+ message: "Missing `id` or `email` field.",
296
+ name: "missing_required_field"
297
+ }
298
+ };
299
+ }
300
+ const identifier = options.email ? options.email : options.id;
301
+ const data = yield this.resend.get(
302
+ `/contacts/${identifier}/topics`
303
+ );
304
+ return data;
305
+ });
306
+ }
307
+ };
308
+
262
309
  // src/contacts/contacts.ts
263
310
  var Contacts = class {
264
311
  constructor(resend) {
265
312
  this.resend = resend;
313
+ this.topics = new ContactTopics(this.resend);
266
314
  }
267
315
  create(_0) {
268
316
  return __async(this, arguments, function* (payload, options = {}) {
@@ -478,6 +526,80 @@ var Emails = class {
478
526
  }
479
527
  };
480
528
 
529
+ // src/topics/topics.ts
530
+ var Topics = class {
531
+ constructor(resend) {
532
+ this.resend = resend;
533
+ }
534
+ create(payload) {
535
+ return __async(this, null, function* () {
536
+ const data = yield this.resend.post(
537
+ "/topics",
538
+ payload
539
+ );
540
+ return data;
541
+ });
542
+ }
543
+ list() {
544
+ return __async(this, null, function* () {
545
+ const data = yield this.resend.get("/topics");
546
+ return data;
547
+ });
548
+ }
549
+ get(id) {
550
+ return __async(this, null, function* () {
551
+ if (!id) {
552
+ return {
553
+ data: null,
554
+ error: {
555
+ message: "Missing `id` field.",
556
+ name: "missing_required_field"
557
+ }
558
+ };
559
+ }
560
+ const data = yield this.resend.get(
561
+ `/topics/${id}`
562
+ );
563
+ return data;
564
+ });
565
+ }
566
+ update(payload) {
567
+ return __async(this, null, function* () {
568
+ if (!payload.id) {
569
+ return {
570
+ data: null,
571
+ error: {
572
+ message: "Missing `id` field.",
573
+ name: "missing_required_field"
574
+ }
575
+ };
576
+ }
577
+ const data = yield this.resend.patch(
578
+ `/topics/${payload.id}`,
579
+ payload
580
+ );
581
+ return data;
582
+ });
583
+ }
584
+ remove(id) {
585
+ return __async(this, null, function* () {
586
+ if (!id) {
587
+ return {
588
+ data: null,
589
+ error: {
590
+ message: "Missing `id` field.",
591
+ name: "missing_required_field"
592
+ }
593
+ };
594
+ }
595
+ const data = yield this.resend.delete(
596
+ `/topics/${id}`
597
+ );
598
+ return data;
599
+ });
600
+ }
601
+ };
602
+
481
603
  // src/resend.ts
482
604
  var defaultBaseUrl = "https://api.resend.com";
483
605
  var defaultUserAgent = `resend-node:${version}`;
@@ -493,6 +615,7 @@ var Resend = class {
493
615
  this.contacts = new Contacts(this);
494
616
  this.domains = new Domains(this);
495
617
  this.emails = new Emails(this);
618
+ this.topics = new Topics(this);
496
619
  if (!key) {
497
620
  if (typeof process !== "undefined" && process.env) {
498
621
  this.key = process.env.RESEND_API_KEY;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resend",
3
- "version": "4.6.0",
3
+ "version": "4.7.0-preview-topics.0",
4
4
  "description": "Node.js library for the Resend API",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",