resend 6.34.1 → 6.36.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
@@ -57,7 +57,7 @@ const MOVE_THREAD_FOLDERS = [
57
57
  ];
58
58
  //#endregion
59
59
  //#region package.json
60
- var version = "6.34.1";
60
+ var version = "6.36.0";
61
61
  //#endregion
62
62
  //#region src/common/utils/build-pagination-query.ts
63
63
  function buildPaginationUrl(base, options) {
@@ -1659,6 +1659,9 @@ function getDefaultBaseUrl() {
1659
1659
  function getDefaultUserAgent() {
1660
1660
  return typeof process !== "undefined" && process.env ? process.env.RESEND_USER_AGENT || defaultUserAgent : defaultUserAgent;
1661
1661
  }
1662
+ function isDebugEnabled() {
1663
+ return typeof process !== "undefined" && process.env ? process.env.RESEND_DEBUG === "true" : false;
1664
+ }
1662
1665
  var Resend = class {
1663
1666
  constructor(key, options) {
1664
1667
  this.key = key;
@@ -1687,6 +1690,7 @@ var Resend = class {
1687
1690
  }
1688
1691
  this.baseUrl = options?.baseUrl ?? getDefaultBaseUrl();
1689
1692
  this.userAgent = options?.userAgent ?? getDefaultUserAgent();
1693
+ this.debug = isDebugEnabled();
1690
1694
  this.headers = new Headers({
1691
1695
  Authorization: `Bearer ${this.key}`,
1692
1696
  "User-Agent": this.userAgent,
@@ -1694,7 +1698,8 @@ var Resend = class {
1694
1698
  });
1695
1699
  }
1696
1700
  logError(error, path, status) {
1697
- if (typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production") console.error("[Resend API Error]:", {
1701
+ if (!this.debug) return;
1702
+ console.error("[Resend API Error]:", {
1698
1703
  ...status !== void 0 && { status },
1699
1704
  error,
1700
1705
  path
package/dist/index.d.cts CHANGED
@@ -1828,12 +1828,22 @@ interface InboxDraftAttachment {
1828
1828
  content_type: string;
1829
1829
  size: number;
1830
1830
  }
1831
- interface InboxDraftAttachmentOptions {
1831
+ interface InboxDraftContentAttachmentOptions {
1832
1832
  /** Content of the file, as a base64 string or a Buffer. */
1833
1833
  content: string | Buffer;
1834
+ path?: never;
1834
1835
  filename: string;
1835
1836
  contentType: string;
1836
1837
  }
1838
+ interface InboxDraftPathAttachmentOptions {
1839
+ content?: never;
1840
+ /** URL of the file, downloaded when the request is made and stored on the draft. */
1841
+ path: string;
1842
+ filename: string;
1843
+ /** Defaults to the content type of the downloaded file. */
1844
+ contentType?: string;
1845
+ }
1846
+ type InboxDraftAttachmentOptions = InboxDraftContentAttachmentOptions | InboxDraftPathAttachmentOptions;
1837
1847
  interface InboxDraft {
1838
1848
  object: 'inbox_draft';
1839
1849
  id: string;
@@ -1874,8 +1884,10 @@ type CreateInboxDraftContent = RequireAtLeastOne<{
1874
1884
  text?: string | null;
1875
1885
  html?: string | null;
1876
1886
  /**
1877
- * Files to store on the draft. Each one needs `content`, `filename` and `contentType`.
1878
- * The files on a draft can total at most 25 MB. An empty file or a blocked file type returns a 422.
1887
+ * Files to store on the draft. Each one needs a `filename` and either `content` with a `contentType`,
1888
+ * or a `path` URL that is downloaded when the request is made.
1889
+ * The files on a draft, downloaded ones included, can total at most 25 MB. An empty file, a blocked file type,
1890
+ * or a `path` that cannot be downloaded returns a 422.
1879
1891
  */
1880
1892
  attachments?: InboxDraftAttachmentOptions[];
1881
1893
  }>;
@@ -1949,8 +1961,10 @@ type UpdateInboxDraftOptions = InboxSelector & {
1949
1961
  text?: string | null;
1950
1962
  html?: string | null;
1951
1963
  /**
1952
- * Files to store on the draft. Each one needs `content`, `filename` and `contentType`.
1953
- * The files on a draft can total at most 25 MB. An empty file or a blocked file type returns a 422.
1964
+ * Files to store on the draft. Each one needs a `filename` and either `content` with a `contentType`,
1965
+ * or a `path` URL that is downloaded when the request is made.
1966
+ * The files on a draft, downloaded ones included, can total at most 25 MB. An empty file, a blocked file type,
1967
+ * or a `path` that cannot be downloaded returns a 422.
1954
1968
  * Sending the field replaces every attachment on the draft. Send `[]` or `null` to remove them all.
1955
1969
  */
1956
1970
  attachments?: InboxDraftAttachmentOptions[] | null;
@@ -3552,6 +3566,7 @@ export declare class Resend {
3552
3566
  readonly key?: string | undefined;
3553
3567
  readonly baseUrl: string;
3554
3568
  readonly userAgent: string;
3569
+ private readonly debug;
3555
3570
  private readonly headers;
3556
3571
  readonly segments: Segments;
3557
3572
  readonly apiKeys: ApiKeys;
package/dist/index.d.mts CHANGED
@@ -1828,12 +1828,22 @@ interface InboxDraftAttachment {
1828
1828
  content_type: string;
1829
1829
  size: number;
1830
1830
  }
1831
- interface InboxDraftAttachmentOptions {
1831
+ interface InboxDraftContentAttachmentOptions {
1832
1832
  /** Content of the file, as a base64 string or a Buffer. */
1833
1833
  content: string | Buffer;
1834
+ path?: never;
1834
1835
  filename: string;
1835
1836
  contentType: string;
1836
1837
  }
1838
+ interface InboxDraftPathAttachmentOptions {
1839
+ content?: never;
1840
+ /** URL of the file, downloaded when the request is made and stored on the draft. */
1841
+ path: string;
1842
+ filename: string;
1843
+ /** Defaults to the content type of the downloaded file. */
1844
+ contentType?: string;
1845
+ }
1846
+ type InboxDraftAttachmentOptions = InboxDraftContentAttachmentOptions | InboxDraftPathAttachmentOptions;
1837
1847
  interface InboxDraft {
1838
1848
  object: 'inbox_draft';
1839
1849
  id: string;
@@ -1874,8 +1884,10 @@ type CreateInboxDraftContent = RequireAtLeastOne<{
1874
1884
  text?: string | null;
1875
1885
  html?: string | null;
1876
1886
  /**
1877
- * Files to store on the draft. Each one needs `content`, `filename` and `contentType`.
1878
- * The files on a draft can total at most 25 MB. An empty file or a blocked file type returns a 422.
1887
+ * Files to store on the draft. Each one needs a `filename` and either `content` with a `contentType`,
1888
+ * or a `path` URL that is downloaded when the request is made.
1889
+ * The files on a draft, downloaded ones included, can total at most 25 MB. An empty file, a blocked file type,
1890
+ * or a `path` that cannot be downloaded returns a 422.
1879
1891
  */
1880
1892
  attachments?: InboxDraftAttachmentOptions[];
1881
1893
  }>;
@@ -1949,8 +1961,10 @@ type UpdateInboxDraftOptions = InboxSelector & {
1949
1961
  text?: string | null;
1950
1962
  html?: string | null;
1951
1963
  /**
1952
- * Files to store on the draft. Each one needs `content`, `filename` and `contentType`.
1953
- * The files on a draft can total at most 25 MB. An empty file or a blocked file type returns a 422.
1964
+ * Files to store on the draft. Each one needs a `filename` and either `content` with a `contentType`,
1965
+ * or a `path` URL that is downloaded when the request is made.
1966
+ * The files on a draft, downloaded ones included, can total at most 25 MB. An empty file, a blocked file type,
1967
+ * or a `path` that cannot be downloaded returns a 422.
1954
1968
  * Sending the field replaces every attachment on the draft. Send `[]` or `null` to remove them all.
1955
1969
  */
1956
1970
  attachments?: InboxDraftAttachmentOptions[] | null;
@@ -3552,6 +3566,7 @@ export declare class Resend {
3552
3566
  readonly key?: string | undefined;
3553
3567
  readonly baseUrl: string;
3554
3568
  readonly userAgent: string;
3569
+ private readonly debug;
3555
3570
  private readonly headers;
3556
3571
  readonly segments: Segments;
3557
3572
  readonly apiKeys: ApiKeys;
package/dist/index.mjs CHANGED
@@ -33,7 +33,7 @@ const MOVE_THREAD_FOLDERS = [
33
33
  ];
34
34
  //#endregion
35
35
  //#region package.json
36
- var version = "6.34.1";
36
+ var version = "6.36.0";
37
37
  //#endregion
38
38
  //#region src/common/utils/build-pagination-query.ts
39
39
  function buildPaginationUrl(base, options) {
@@ -1635,6 +1635,9 @@ function getDefaultBaseUrl() {
1635
1635
  function getDefaultUserAgent() {
1636
1636
  return typeof process !== "undefined" && process.env ? process.env.RESEND_USER_AGENT || defaultUserAgent : defaultUserAgent;
1637
1637
  }
1638
+ function isDebugEnabled() {
1639
+ return typeof process !== "undefined" && process.env ? process.env.RESEND_DEBUG === "true" : false;
1640
+ }
1638
1641
  var Resend = class {
1639
1642
  constructor(key, options) {
1640
1643
  this.key = key;
@@ -1663,6 +1666,7 @@ var Resend = class {
1663
1666
  }
1664
1667
  this.baseUrl = options?.baseUrl ?? getDefaultBaseUrl();
1665
1668
  this.userAgent = options?.userAgent ?? getDefaultUserAgent();
1669
+ this.debug = isDebugEnabled();
1666
1670
  this.headers = new Headers({
1667
1671
  Authorization: `Bearer ${this.key}`,
1668
1672
  "User-Agent": this.userAgent,
@@ -1670,7 +1674,8 @@ var Resend = class {
1670
1674
  });
1671
1675
  }
1672
1676
  logError(error, path, status) {
1673
- if (typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production") console.error("[Resend API Error]:", {
1677
+ if (!this.debug) return;
1678
+ console.error("[Resend API Error]:", {
1674
1679
  ...status !== void 0 && { status },
1675
1680
  error,
1676
1681
  path
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resend",
3
- "version": "6.34.1",
3
+ "version": "6.36.0",
4
4
  "description": "Node.js library for the Resend API",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",