@upyo/resend 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 +13 -4
- package/dist/index.js +14 -5
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -249,7 +249,16 @@ async function convertMessage(message, _config, options = {}) {
|
|
|
249
249
|
emailData.html = message.content.html;
|
|
250
250
|
if (message.content.text) emailData.text = message.content.text;
|
|
251
251
|
} else emailData.text = message.content.text;
|
|
252
|
-
if (message.attachments.length > 0)
|
|
252
|
+
if (message.attachments.length > 0) {
|
|
253
|
+
const cancellation = new AbortController();
|
|
254
|
+
const combined = (0, __upyo_core.combineSignals)(cancellation.signal, options.signal);
|
|
255
|
+
try {
|
|
256
|
+
emailData.attachments = await Promise.all(message.attachments.map((attachment) => convertAttachment(attachment, combined.signal)));
|
|
257
|
+
} finally {
|
|
258
|
+
cancellation.abort();
|
|
259
|
+
combined.cleanup();
|
|
260
|
+
}
|
|
261
|
+
}
|
|
253
262
|
if (message.tags.length > 0) emailData.tags = message.tags.map((tag, index) => ({
|
|
254
263
|
name: `tag${index + 1}`,
|
|
255
264
|
value: tag
|
|
@@ -306,8 +315,8 @@ function formatAddress(address) {
|
|
|
306
315
|
* @param attachment - The Upyo attachment to convert
|
|
307
316
|
* @returns Resend attachment object
|
|
308
317
|
*/
|
|
309
|
-
async function convertAttachment(attachment) {
|
|
310
|
-
const content = await attachment.content;
|
|
318
|
+
async function convertAttachment(attachment, signal) {
|
|
319
|
+
const content = await (0, __upyo_core.readAttachmentContent)(attachment.content, signal);
|
|
311
320
|
const resendAttachment = {
|
|
312
321
|
filename: attachment.filename,
|
|
313
322
|
content: await uint8ArrayToBase64(content)
|
|
@@ -452,7 +461,7 @@ var ResendTransport = class {
|
|
|
452
461
|
try {
|
|
453
462
|
options?.signal?.throwIfAborted();
|
|
454
463
|
const idempotencyKey = message.idempotencyKey ?? generateIdempotencyKey();
|
|
455
|
-
const emailData = await convertMessage(message, this.config);
|
|
464
|
+
const emailData = await convertMessage(message, this.config, { signal: options?.signal });
|
|
456
465
|
options?.signal?.throwIfAborted();
|
|
457
466
|
const response = await this.httpClient.sendMessage(emailData, options?.signal, idempotencyKey);
|
|
458
467
|
return {
|
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
|
/**
|
|
@@ -226,7 +226,16 @@ async function convertMessage(message, _config, options = {}) {
|
|
|
226
226
|
emailData.html = message.content.html;
|
|
227
227
|
if (message.content.text) emailData.text = message.content.text;
|
|
228
228
|
} else emailData.text = message.content.text;
|
|
229
|
-
if (message.attachments.length > 0)
|
|
229
|
+
if (message.attachments.length > 0) {
|
|
230
|
+
const cancellation = new AbortController();
|
|
231
|
+
const combined = combineSignals(cancellation.signal, options.signal);
|
|
232
|
+
try {
|
|
233
|
+
emailData.attachments = await Promise.all(message.attachments.map((attachment) => convertAttachment(attachment, combined.signal)));
|
|
234
|
+
} finally {
|
|
235
|
+
cancellation.abort();
|
|
236
|
+
combined.cleanup();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
230
239
|
if (message.tags.length > 0) emailData.tags = message.tags.map((tag, index) => ({
|
|
231
240
|
name: `tag${index + 1}`,
|
|
232
241
|
value: tag
|
|
@@ -283,8 +292,8 @@ function formatAddress(address) {
|
|
|
283
292
|
* @param attachment - The Upyo attachment to convert
|
|
284
293
|
* @returns Resend attachment object
|
|
285
294
|
*/
|
|
286
|
-
async function convertAttachment(attachment) {
|
|
287
|
-
const content = await attachment.content;
|
|
295
|
+
async function convertAttachment(attachment, signal) {
|
|
296
|
+
const content = await readAttachmentContent(attachment.content, signal);
|
|
288
297
|
const resendAttachment = {
|
|
289
298
|
filename: attachment.filename,
|
|
290
299
|
content: await uint8ArrayToBase64(content)
|
|
@@ -429,7 +438,7 @@ var ResendTransport = class {
|
|
|
429
438
|
try {
|
|
430
439
|
options?.signal?.throwIfAborted();
|
|
431
440
|
const idempotencyKey = message.idempotencyKey ?? generateIdempotencyKey();
|
|
432
|
-
const emailData = await convertMessage(message, this.config);
|
|
441
|
+
const emailData = await convertMessage(message, this.config, { signal: options?.signal });
|
|
433
442
|
options?.signal?.throwIfAborted();
|
|
434
443
|
const response = await this.httpClient.sendMessage(emailData, options?.signal, idempotencyKey);
|
|
435
444
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@upyo/resend",
|
|
3
|
-
"version": "0.6.0-dev.
|
|
3
|
+
"version": "0.6.0-dev.312",
|
|
4
4
|
"description": "Resend 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.
|
|
56
|
+
"@upyo/core": "0.6.0-dev.312+646e2370"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"tsdown": "^0.12.7",
|