@upyo/plunk 0.6.0-dev.325 → 0.6.0-dev.336

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
@@ -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
  /**
@@ -230,7 +231,11 @@ function truncateErrorBody(text) {
230
231
  * @param message - The Upyo message to convert
231
232
  * @param config - Resolved Plunk configuration
232
233
  * @returns Promise that resolves to Plunk-formatted email data
233
- * @throws {TypeError} If the message carries an invalid message identifier.
234
+ * @throws {TypeError} If the message carries an invalid message identifier, or
235
+ * calendar content that is not a single well-formed
236
+ * iCalendar object.
237
+ * @throws {RangeError} If a calendar message carries so many attachments that
238
+ * one would have to be dropped.
234
239
  */
235
240
  async function convertMessage(message, _config, signal) {
236
241
  const recipients = message.recipients.map((addr) => addr.address);
@@ -256,10 +261,12 @@ async function convertMessage(message, _config, signal) {
256
261
  ].includes(lowerKey) && !ownedHeaders.has(lowerKey)) customHeaders[lowerKey] = value;
257
262
  }
258
263
  for (const [name, value] of threading) if (value != null) customHeaders[name] = value;
264
+ const sourceAttachments = message.calendar == null ? message.attachments : [(0, __upyo_core_calendar.createCalendarAttachment)(message.calendar), ...message.attachments];
265
+ if (message.calendar != null && sourceAttachments.length > 5) throw new RangeError("Plunk supports at most five attachments, and a calendar message needs one of them for the invitation.");
259
266
  const attachments = [];
260
- const maxAttachments = Math.min(message.attachments.length, 5);
267
+ const maxAttachments = Math.min(sourceAttachments.length, 5);
261
268
  for (let i = 0; i < maxAttachments; i++) {
262
- const attachment = message.attachments[i];
269
+ const attachment = sourceAttachments[i];
263
270
  const convertedAttachment = await convertAttachment(attachment, signal);
264
271
  if (convertedAttachment) attachments.push(convertedAttachment);
265
272
  }
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
  /**
@@ -207,7 +208,11 @@ function truncateErrorBody(text) {
207
208
  * @param message - The Upyo message to convert
208
209
  * @param config - Resolved Plunk configuration
209
210
  * @returns Promise that resolves to Plunk-formatted email data
210
- * @throws {TypeError} If the message carries an invalid message identifier.
211
+ * @throws {TypeError} If the message carries an invalid message identifier, or
212
+ * calendar content that is not a single well-formed
213
+ * iCalendar object.
214
+ * @throws {RangeError} If a calendar message carries so many attachments that
215
+ * one would have to be dropped.
211
216
  */
212
217
  async function convertMessage(message, _config, signal) {
213
218
  const recipients = message.recipients.map((addr) => addr.address);
@@ -233,10 +238,12 @@ async function convertMessage(message, _config, signal) {
233
238
  ].includes(lowerKey) && !ownedHeaders.has(lowerKey)) customHeaders[lowerKey] = value;
234
239
  }
235
240
  for (const [name, value] of threading) if (value != null) customHeaders[name] = value;
241
+ const sourceAttachments = message.calendar == null ? message.attachments : [createCalendarAttachment(message.calendar), ...message.attachments];
242
+ if (message.calendar != null && sourceAttachments.length > 5) throw new RangeError("Plunk supports at most five attachments, and a calendar message needs one of them for the invitation.");
236
243
  const attachments = [];
237
- const maxAttachments = Math.min(message.attachments.length, 5);
244
+ const maxAttachments = Math.min(sourceAttachments.length, 5);
238
245
  for (let i = 0; i < maxAttachments; i++) {
239
- const attachment = message.attachments[i];
246
+ const attachment = sourceAttachments[i];
240
247
  const convertedAttachment = await convertAttachment(attachment, signal);
241
248
  if (convertedAttachment) attachments.push(convertedAttachment);
242
249
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upyo/plunk",
3
- "version": "0.6.0-dev.325",
3
+ "version": "0.6.0-dev.336",
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.325+1818f43d"
56
+ "@upyo/core": "0.6.0-dev.336+ec6e189b"
57
57
  },
58
58
  "devDependencies": {
59
59
  "tsdown": "^0.12.7",