@wraps.dev/cli 2.17.2 → 2.17.4

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.
@@ -78,16 +78,34 @@ export async function handler(event: S3Event, context: Context) {
78
78
  // Generate email ID
79
79
  const emailId = `inb_${randomUUID().replace(/-/g, "").slice(0, 12)}`;
80
80
 
81
- // 3. Extract headers as lowercase key-value pairs
82
- const headers: Record<string, string> = {};
81
+ // 3. Extract headers as key-value pairs
82
+ // mailparser returns most headers as strings, but some (list, received,
83
+ // references) are complex objects. We preserve objects as-is so downstream
84
+ // consumers can access nested fields like list.unsubscribe.
85
+ const headers: Record<string, unknown> = {};
83
86
  if (parsed.headers) {
84
87
  for (const [key, value] of parsed.headers) {
85
- const headerValue =
86
- typeof value === "object" && value !== null && "text" in value
87
- ? (value as { text: string }).text
88
- : String(value);
89
- if (headers[key]) {
90
- headers[key] = `${headers[key]}, ${headerValue}`;
88
+ let headerValue: unknown;
89
+ if (typeof value === "string") {
90
+ headerValue = value;
91
+ } else if (
92
+ typeof value === "object" &&
93
+ value !== null &&
94
+ "text" in value
95
+ ) {
96
+ headerValue = (value as { text: string }).text;
97
+ } else if (typeof value === "object" && value !== null) {
98
+ // Preserve nested objects (e.g. list.unsubscribe, list.post)
99
+ headerValue = value;
100
+ } else {
101
+ headerValue = String(value);
102
+ }
103
+
104
+ if (headers[key] != null) {
105
+ // Multiple values for same header — combine strings, keep first object
106
+ if (typeof headers[key] === "string" && typeof headerValue === "string") {
107
+ headers[key] = `${headers[key]}, ${headerValue}`;
108
+ }
91
109
  } else {
92
110
  headers[key] = headerValue;
93
111
  }
@@ -1 +1 @@
1
- Built at: 2026-02-26T21:17:45.486Z
1
+ Built at: 2026-02-27T23:36:52.912Z
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wraps.dev/cli",
3
- "version": "2.17.2",
3
+ "version": "2.17.4",
4
4
  "description": "CLI for deploying Wraps email infrastructure to your AWS account",
5
5
  "type": "module",
6
6
  "main": "./dist/cli.js",