@upyo/resend 0.6.0-dev.327 → 0.6.0-dev.338
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 +7 -5
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -5
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -22,6 +22,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
|
|
23
23
|
//#endregion
|
|
24
24
|
const __upyo_core = __toESM(require("@upyo/core"));
|
|
25
|
+
const __upyo_core_calendar = __toESM(require("@upyo/core/calendar"));
|
|
25
26
|
|
|
26
27
|
//#region src/config.ts
|
|
27
28
|
/**
|
|
@@ -238,6 +239,7 @@ function truncateErrorBody(text) {
|
|
|
238
239
|
* ```
|
|
239
240
|
*/
|
|
240
241
|
async function convertMessage(message, _config, options = {}) {
|
|
242
|
+
const attachments = message.calendar == null ? message.attachments : [(0, __upyo_core_calendar.createCalendarAttachment)(message.calendar), ...message.attachments];
|
|
241
243
|
const emailData = {
|
|
242
244
|
from: formatAddress(message.sender),
|
|
243
245
|
to: message.recipients.length === 1 ? formatAddress(message.recipients[0]) : message.recipients.map(formatAddress),
|
|
@@ -250,11 +252,11 @@ async function convertMessage(message, _config, options = {}) {
|
|
|
250
252
|
emailData.html = message.content.html;
|
|
251
253
|
if (message.content.text) emailData.text = message.content.text;
|
|
252
254
|
} else emailData.text = message.content.text;
|
|
253
|
-
if (
|
|
255
|
+
if (attachments.length > 0) {
|
|
254
256
|
const cancellation = new AbortController();
|
|
255
257
|
const combined = (0, __upyo_core.combineSignals)(cancellation.signal, options.signal);
|
|
256
258
|
try {
|
|
257
|
-
emailData.attachments = await Promise.all(
|
|
259
|
+
emailData.attachments = await Promise.all(attachments.map((attachment) => convertAttachment(attachment, combined.signal)));
|
|
258
260
|
} finally {
|
|
259
261
|
cancellation.abort();
|
|
260
262
|
combined.cleanup();
|
|
@@ -295,7 +297,7 @@ async function convertMessage(message, _config, options = {}) {
|
|
|
295
297
|
async function convertMessagesBatch(messages, _config) {
|
|
296
298
|
if (messages.length > 100) throw new Error("Resend batch API supports maximum 100 emails per request");
|
|
297
299
|
for (const message of messages) {
|
|
298
|
-
if (message.attachments.length > 0) throw new Error("Attachments are not supported in Resend batch API");
|
|
300
|
+
if (message.attachments.length > 0 || message.calendar != null) throw new Error("Attachments are not supported in Resend batch API");
|
|
299
301
|
if (message.tags.length > 0) throw new Error("Tags are not supported in Resend batch API");
|
|
300
302
|
}
|
|
301
303
|
const batchData = await Promise.all(messages.map((message) => convertMessage(message, _config)));
|
|
@@ -602,7 +604,7 @@ var ResendTransport = class {
|
|
|
602
604
|
* Checks if messages can use Resend's batch API.
|
|
603
605
|
*
|
|
604
606
|
* Batch API limitations:
|
|
605
|
-
* - No attachments
|
|
607
|
+
* - No attachments, and so no calendar
|
|
606
608
|
* - No tags
|
|
607
609
|
* - No scheduled sending
|
|
608
610
|
*
|
|
@@ -610,7 +612,7 @@ var ResendTransport = class {
|
|
|
610
612
|
* @returns True if all messages are suitable for batch API
|
|
611
613
|
*/
|
|
612
614
|
canUseBatchApi(messages) {
|
|
613
|
-
return messages.every((message) => message.attachments.length === 0 && message.tags.length === 0);
|
|
615
|
+
return messages.every((message) => message.attachments.length === 0 && message.tags.length === 0 && message.calendar == null);
|
|
614
616
|
}
|
|
615
617
|
/**
|
|
616
618
|
* Splits an array into chunks of specified size.
|
package/dist/index.d.cts
CHANGED
|
@@ -222,7 +222,7 @@ declare class ResendTransport implements Transport<"resend"> {
|
|
|
222
222
|
* Checks if messages can use Resend's batch API.
|
|
223
223
|
*
|
|
224
224
|
* Batch API limitations:
|
|
225
|
-
* - No attachments
|
|
225
|
+
* - No attachments, and so no calendar
|
|
226
226
|
* - No tags
|
|
227
227
|
* - No scheduled sending
|
|
228
228
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -222,7 +222,7 @@ declare class ResendTransport implements Transport<"resend"> {
|
|
|
222
222
|
* Checks if messages can use Resend's batch API.
|
|
223
223
|
*
|
|
224
224
|
* Batch API limitations:
|
|
225
|
-
* - No attachments
|
|
225
|
+
* - No attachments, and so no calendar
|
|
226
226
|
* - No tags
|
|
227
227
|
* - No scheduled sending
|
|
228
228
|
*
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { combineSignals, createFailedReceipt, parseRetryAfter, readAttachmentContent, resolveThreadingHeaders } from "@upyo/core";
|
|
2
|
+
import { createCalendarAttachment } from "@upyo/core/calendar";
|
|
2
3
|
|
|
3
4
|
//#region src/config.ts
|
|
4
5
|
/**
|
|
@@ -215,6 +216,7 @@ function truncateErrorBody(text) {
|
|
|
215
216
|
* ```
|
|
216
217
|
*/
|
|
217
218
|
async function convertMessage(message, _config, options = {}) {
|
|
219
|
+
const attachments = message.calendar == null ? message.attachments : [createCalendarAttachment(message.calendar), ...message.attachments];
|
|
218
220
|
const emailData = {
|
|
219
221
|
from: formatAddress(message.sender),
|
|
220
222
|
to: message.recipients.length === 1 ? formatAddress(message.recipients[0]) : message.recipients.map(formatAddress),
|
|
@@ -227,11 +229,11 @@ async function convertMessage(message, _config, options = {}) {
|
|
|
227
229
|
emailData.html = message.content.html;
|
|
228
230
|
if (message.content.text) emailData.text = message.content.text;
|
|
229
231
|
} else emailData.text = message.content.text;
|
|
230
|
-
if (
|
|
232
|
+
if (attachments.length > 0) {
|
|
231
233
|
const cancellation = new AbortController();
|
|
232
234
|
const combined = combineSignals(cancellation.signal, options.signal);
|
|
233
235
|
try {
|
|
234
|
-
emailData.attachments = await Promise.all(
|
|
236
|
+
emailData.attachments = await Promise.all(attachments.map((attachment) => convertAttachment(attachment, combined.signal)));
|
|
235
237
|
} finally {
|
|
236
238
|
cancellation.abort();
|
|
237
239
|
combined.cleanup();
|
|
@@ -272,7 +274,7 @@ async function convertMessage(message, _config, options = {}) {
|
|
|
272
274
|
async function convertMessagesBatch(messages, _config) {
|
|
273
275
|
if (messages.length > 100) throw new Error("Resend batch API supports maximum 100 emails per request");
|
|
274
276
|
for (const message of messages) {
|
|
275
|
-
if (message.attachments.length > 0) throw new Error("Attachments are not supported in Resend batch API");
|
|
277
|
+
if (message.attachments.length > 0 || message.calendar != null) throw new Error("Attachments are not supported in Resend batch API");
|
|
276
278
|
if (message.tags.length > 0) throw new Error("Tags are not supported in Resend batch API");
|
|
277
279
|
}
|
|
278
280
|
const batchData = await Promise.all(messages.map((message) => convertMessage(message, _config)));
|
|
@@ -579,7 +581,7 @@ var ResendTransport = class {
|
|
|
579
581
|
* Checks if messages can use Resend's batch API.
|
|
580
582
|
*
|
|
581
583
|
* Batch API limitations:
|
|
582
|
-
* - No attachments
|
|
584
|
+
* - No attachments, and so no calendar
|
|
583
585
|
* - No tags
|
|
584
586
|
* - No scheduled sending
|
|
585
587
|
*
|
|
@@ -587,7 +589,7 @@ var ResendTransport = class {
|
|
|
587
589
|
* @returns True if all messages are suitable for batch API
|
|
588
590
|
*/
|
|
589
591
|
canUseBatchApi(messages) {
|
|
590
|
-
return messages.every((message) => message.attachments.length === 0 && message.tags.length === 0);
|
|
592
|
+
return messages.every((message) => message.attachments.length === 0 && message.tags.length === 0 && message.calendar == null);
|
|
591
593
|
}
|
|
592
594
|
/**
|
|
593
595
|
* Splits an array into chunks of specified size.
|
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.338",
|
|
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.338+cae9af76"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"tsdown": "^0.12.7",
|