resend 6.36.1 → 6.37.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.36.1";
60
+ var version = "6.37.0";
61
61
  //#endregion
62
62
  //#region src/common/utils/build-pagination-query.ts
63
63
  function buildPaginationUrl(base, options) {
@@ -240,9 +240,24 @@ var Automations = class {
240
240
  };
241
241
  //#endregion
242
242
  //#region src/common/utils/parse-email-to-api-options.ts
243
+ function encodeBase64(bytes) {
244
+ if (typeof Buffer !== "undefined") return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("base64");
245
+ let binary = "";
246
+ for (let i = 0; i < bytes.length; i += 32768) binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
247
+ return btoa(binary);
248
+ }
249
+ /**
250
+ * JSON.stringify turns a Uint8Array into an object of indexes and an
251
+ * ArrayBuffer into `{}`, so binary content is sent as base64 instead.
252
+ */
253
+ function parseAttachmentContent(content) {
254
+ if (ArrayBuffer.isView(content)) return encodeBase64(new Uint8Array(content.buffer, content.byteOffset, content.byteLength));
255
+ if (content instanceof ArrayBuffer) return encodeBase64(new Uint8Array(content));
256
+ return content;
257
+ }
243
258
  function parseAttachments(attachments) {
244
259
  return attachments?.map((attachment) => ({
245
- content: attachment.content,
260
+ content: parseAttachmentContent(attachment.content),
246
261
  filename: attachment.filename,
247
262
  path: attachment.path,
248
263
  content_type: attachment.contentType,
package/dist/index.d.cts CHANGED
@@ -618,8 +618,8 @@ export interface CreateEmailResponseSuccess {
618
618
  }
619
619
  export type CreateEmailResponse = Response<CreateEmailResponseSuccess>;
620
620
  export interface Attachment {
621
- /** Content of an attached file. */
622
- content?: string | Buffer;
621
+ /** Content of an attached file, as a base64 string or binary data, which is sent as base64. */
622
+ content?: string | Buffer | Uint8Array | ArrayBuffer;
623
623
  /** Name of attached file. */
624
624
  filename?: string | false | undefined;
625
625
  /** Path where the attachment file is hosted */
@@ -1829,8 +1829,8 @@ interface InboxDraftAttachment {
1829
1829
  size: number;
1830
1830
  }
1831
1831
  interface InboxDraftContentAttachmentOptions {
1832
- /** Content of the file, as a base64 string or a Buffer. */
1833
- content: string | Buffer;
1832
+ /** Content of the file, as a base64 string or binary data, which is sent as base64. */
1833
+ content: string | Buffer | Uint8Array | ArrayBuffer;
1834
1834
  path?: never;
1835
1835
  filename: string;
1836
1836
  contentType: string;
package/dist/index.d.mts CHANGED
@@ -618,8 +618,8 @@ export interface CreateEmailResponseSuccess {
618
618
  }
619
619
  export type CreateEmailResponse = Response<CreateEmailResponseSuccess>;
620
620
  export interface Attachment {
621
- /** Content of an attached file. */
622
- content?: string | Buffer;
621
+ /** Content of an attached file, as a base64 string or binary data, which is sent as base64. */
622
+ content?: string | Buffer | Uint8Array | ArrayBuffer;
623
623
  /** Name of attached file. */
624
624
  filename?: string | false | undefined;
625
625
  /** Path where the attachment file is hosted */
@@ -1829,8 +1829,8 @@ interface InboxDraftAttachment {
1829
1829
  size: number;
1830
1830
  }
1831
1831
  interface InboxDraftContentAttachmentOptions {
1832
- /** Content of the file, as a base64 string or a Buffer. */
1833
- content: string | Buffer;
1832
+ /** Content of the file, as a base64 string or binary data, which is sent as base64. */
1833
+ content: string | Buffer | Uint8Array | ArrayBuffer;
1834
1834
  path?: never;
1835
1835
  filename: string;
1836
1836
  contentType: string;
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.36.1";
36
+ var version = "6.37.0";
37
37
  //#endregion
38
38
  //#region src/common/utils/build-pagination-query.ts
39
39
  function buildPaginationUrl(base, options) {
@@ -216,9 +216,24 @@ var Automations = class {
216
216
  };
217
217
  //#endregion
218
218
  //#region src/common/utils/parse-email-to-api-options.ts
219
+ function encodeBase64(bytes) {
220
+ if (typeof Buffer !== "undefined") return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("base64");
221
+ let binary = "";
222
+ for (let i = 0; i < bytes.length; i += 32768) binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
223
+ return btoa(binary);
224
+ }
225
+ /**
226
+ * JSON.stringify turns a Uint8Array into an object of indexes and an
227
+ * ArrayBuffer into `{}`, so binary content is sent as base64 instead.
228
+ */
229
+ function parseAttachmentContent(content) {
230
+ if (ArrayBuffer.isView(content)) return encodeBase64(new Uint8Array(content.buffer, content.byteOffset, content.byteLength));
231
+ if (content instanceof ArrayBuffer) return encodeBase64(new Uint8Array(content));
232
+ return content;
233
+ }
219
234
  function parseAttachments(attachments) {
220
235
  return attachments?.map((attachment) => ({
221
- content: attachment.content,
236
+ content: parseAttachmentContent(attachment.content),
222
237
  filename: attachment.filename,
223
238
  path: attachment.path,
224
239
  content_type: attachment.contentType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resend",
3
- "version": "6.36.1",
3
+ "version": "6.37.0",
4
4
  "description": "Node.js library for the Resend API",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",