@upyo/mailtrap 0.6.0-dev.318 → 0.6.0-dev.319

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
@@ -313,6 +313,7 @@ const STANDARD_HEADERS = new Set([
313
313
  * @param config The resolved Mailtrap configuration.
314
314
  * @param signal Optional abort signal for cancellation.
315
315
  * @returns JSON object ready for Mailtrap API submission.
316
+ * @throws {TypeError} If the message carries an invalid message identifier.
316
317
  * @throws {RangeError} If the message has no text or HTML content.
317
318
  * @throws {Error} If the caller aborts the operation.
318
319
  * @since 0.6.0
@@ -344,7 +345,10 @@ async function convertMessage(message, config, signal) {
344
345
  };
345
346
  headers["X-Priority"] = priorityMap[message.priority];
346
347
  }
347
- for (const [key, value] of message.headers.entries()) if (!isStandardHeader(key)) headers[key] = value;
348
+ const threading = (0, __upyo_core.resolveThreadingHeaders)(message);
349
+ const ownedHeaders = new Set([...threading.keys()].map((name) => name.toLowerCase()));
350
+ for (const [key, value] of message.headers.entries()) if (!isStandardHeader(key) && !ownedHeaders.has(key.toLowerCase())) headers[key] = value;
351
+ for (const [name, value] of threading) if (value != null) headers[name] = value;
348
352
  if (Object.keys(headers).length > 0) emailData.headers = headers;
349
353
  if (message.attachments.length > 0) {
350
354
  const cancellation = new AbortController();
package/dist/index.d.cts CHANGED
@@ -223,6 +223,7 @@ interface MailtrapEmail {
223
223
  * @param config The resolved Mailtrap configuration.
224
224
  * @param signal Optional abort signal for cancellation.
225
225
  * @returns JSON object ready for Mailtrap API submission.
226
+ * @throws {TypeError} If the message carries an invalid message identifier.
226
227
  * @throws {RangeError} If the message has no text or HTML content.
227
228
  * @throws {Error} If the caller aborts the operation.
228
229
  * @since 0.6.0
package/dist/index.d.ts CHANGED
@@ -223,6 +223,7 @@ interface MailtrapEmail {
223
223
  * @param config The resolved Mailtrap configuration.
224
224
  * @param signal Optional abort signal for cancellation.
225
225
  * @returns JSON object ready for Mailtrap API submission.
226
+ * @throws {TypeError} If the message carries an invalid message identifier.
226
227
  * @throws {RangeError} If the message has no text or HTML content.
227
228
  * @throws {Error} If the caller aborts the operation.
228
229
  * @since 0.6.0
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { combineSignals, createFailedReceipt, readAttachmentContent } from "@upyo/core";
1
+ import { combineSignals, createFailedReceipt, readAttachmentContent, resolveThreadingHeaders } from "@upyo/core";
2
2
 
3
3
  //#region src/config.ts
4
4
  const DEFAULT_SEND_BASE_URL = "https://send.api.mailtrap.io";
@@ -290,6 +290,7 @@ const STANDARD_HEADERS = new Set([
290
290
  * @param config The resolved Mailtrap configuration.
291
291
  * @param signal Optional abort signal for cancellation.
292
292
  * @returns JSON object ready for Mailtrap API submission.
293
+ * @throws {TypeError} If the message carries an invalid message identifier.
293
294
  * @throws {RangeError} If the message has no text or HTML content.
294
295
  * @throws {Error} If the caller aborts the operation.
295
296
  * @since 0.6.0
@@ -321,7 +322,10 @@ async function convertMessage(message, config, signal) {
321
322
  };
322
323
  headers["X-Priority"] = priorityMap[message.priority];
323
324
  }
324
- for (const [key, value] of message.headers.entries()) if (!isStandardHeader(key)) headers[key] = value;
325
+ const threading = resolveThreadingHeaders(message);
326
+ const ownedHeaders = new Set([...threading.keys()].map((name) => name.toLowerCase()));
327
+ for (const [key, value] of message.headers.entries()) if (!isStandardHeader(key) && !ownedHeaders.has(key.toLowerCase())) headers[key] = value;
328
+ for (const [name, value] of threading) if (value != null) headers[name] = value;
325
329
  if (Object.keys(headers).length > 0) emailData.headers = headers;
326
330
  if (message.attachments.length > 0) {
327
331
  const cancellation = new AbortController();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upyo/mailtrap",
3
- "version": "0.6.0-dev.318",
3
+ "version": "0.6.0-dev.319",
4
4
  "description": "Mailtrap 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.318+9378b2c8"
56
+ "@upyo/core": "0.6.0-dev.319+2324fa8c"
57
57
  },
58
58
  "devDependencies": {
59
59
  "tsdown": "^0.12.7",