@upyo/plunk 0.6.0-dev.309 → 0.6.0-dev.312

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
@@ -231,7 +231,7 @@ function truncateErrorBody(text) {
231
231
  * @param config - Resolved Plunk configuration
232
232
  * @returns Promise that resolves to Plunk-formatted email data
233
233
  */
234
- async function convertMessage(message, _config) {
234
+ async function convertMessage(message, _config, signal) {
235
235
  const recipients = message.recipients.map((addr) => addr.address);
236
236
  const to = recipients.length === 1 ? recipients[0] : recipients;
237
237
  const senderName = message.sender.name;
@@ -256,7 +256,7 @@ async function convertMessage(message, _config) {
256
256
  const maxAttachments = Math.min(message.attachments.length, 5);
257
257
  for (let i = 0; i < maxAttachments; i++) {
258
258
  const attachment = message.attachments[i];
259
- const convertedAttachment = await convertAttachment(attachment);
259
+ const convertedAttachment = await convertAttachment(attachment, signal);
260
260
  if (convertedAttachment) attachments.push(convertedAttachment);
261
261
  }
262
262
  const plunkEmail = {
@@ -277,9 +277,9 @@ async function convertMessage(message, _config) {
277
277
  * @param attachment - The Upyo attachment to convert
278
278
  * @returns Promise that resolves to Plunk attachment or null if conversion fails
279
279
  */
280
- async function convertAttachment(attachment) {
280
+ async function convertAttachment(attachment, signal) {
281
281
  try {
282
- const content = await attachment.content;
282
+ const content = await (0, __upyo_core.readAttachmentContent)(attachment.content, signal);
283
283
  const base64Content = arrayBufferToBase64(content);
284
284
  return {
285
285
  filename: attachment.filename,
@@ -287,6 +287,7 @@ async function convertAttachment(attachment) {
287
287
  contentType: attachment.contentType
288
288
  };
289
289
  } catch (error) {
290
+ signal?.throwIfAborted();
290
291
  console.warn(`Failed to convert attachment ${attachment.filename}:`, error);
291
292
  return null;
292
293
  }
@@ -398,7 +399,7 @@ var PlunkTransport = class {
398
399
  async send(message, options) {
399
400
  try {
400
401
  options?.signal?.throwIfAborted();
401
- const emailData = await convertMessage(message, this.config);
402
+ const emailData = await convertMessage(message, this.config, options?.signal);
402
403
  options?.signal?.throwIfAborted();
403
404
  const response = await this.httpClient.sendMessage(emailData, options?.signal);
404
405
  const messageId = this.extractMessageId(response, message);
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { combineSignals, createFailedReceipt, parseRetryAfter } from "@upyo/core";
1
+ import { combineSignals, createFailedReceipt, parseRetryAfter, readAttachmentContent } from "@upyo/core";
2
2
 
3
3
  //#region src/config.ts
4
4
  /**
@@ -208,7 +208,7 @@ function truncateErrorBody(text) {
208
208
  * @param config - Resolved Plunk configuration
209
209
  * @returns Promise that resolves to Plunk-formatted email data
210
210
  */
211
- async function convertMessage(message, _config) {
211
+ async function convertMessage(message, _config, signal) {
212
212
  const recipients = message.recipients.map((addr) => addr.address);
213
213
  const to = recipients.length === 1 ? recipients[0] : recipients;
214
214
  const senderName = message.sender.name;
@@ -233,7 +233,7 @@ async function convertMessage(message, _config) {
233
233
  const maxAttachments = Math.min(message.attachments.length, 5);
234
234
  for (let i = 0; i < maxAttachments; i++) {
235
235
  const attachment = message.attachments[i];
236
- const convertedAttachment = await convertAttachment(attachment);
236
+ const convertedAttachment = await convertAttachment(attachment, signal);
237
237
  if (convertedAttachment) attachments.push(convertedAttachment);
238
238
  }
239
239
  const plunkEmail = {
@@ -254,9 +254,9 @@ async function convertMessage(message, _config) {
254
254
  * @param attachment - The Upyo attachment to convert
255
255
  * @returns Promise that resolves to Plunk attachment or null if conversion fails
256
256
  */
257
- async function convertAttachment(attachment) {
257
+ async function convertAttachment(attachment, signal) {
258
258
  try {
259
- const content = await attachment.content;
259
+ const content = await readAttachmentContent(attachment.content, signal);
260
260
  const base64Content = arrayBufferToBase64(content);
261
261
  return {
262
262
  filename: attachment.filename,
@@ -264,6 +264,7 @@ async function convertAttachment(attachment) {
264
264
  contentType: attachment.contentType
265
265
  };
266
266
  } catch (error) {
267
+ signal?.throwIfAborted();
267
268
  console.warn(`Failed to convert attachment ${attachment.filename}:`, error);
268
269
  return null;
269
270
  }
@@ -375,7 +376,7 @@ var PlunkTransport = class {
375
376
  async send(message, options) {
376
377
  try {
377
378
  options?.signal?.throwIfAborted();
378
- const emailData = await convertMessage(message, this.config);
379
+ const emailData = await convertMessage(message, this.config, options?.signal);
379
380
  options?.signal?.throwIfAborted();
380
381
  const response = await this.httpClient.sendMessage(emailData, options?.signal);
381
382
  const messageId = this.extractMessageId(response, message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upyo/plunk",
3
- "version": "0.6.0-dev.309",
3
+ "version": "0.6.0-dev.312",
4
4
  "description": "Plunk transport for Upyo email library",
5
5
  "keywords": [
6
6
  "email",
@@ -53,7 +53,7 @@
53
53
  },
54
54
  "sideEffects": false,
55
55
  "peerDependencies": {
56
- "@upyo/core": "0.6.0-dev.309+0e4d9155"
56
+ "@upyo/core": "0.6.0-dev.312+646e2370"
57
57
  },
58
58
  "devDependencies": {
59
59
  "tsdown": "^0.12.7",