(value: unknown)
| 29 | } |
| 30 | |
| 31 | function extractText(value: unknown): string { |
| 32 | if (typeof value === "string") { |
| 33 | return value; |
| 34 | } |
| 35 | |
| 36 | if (Array.isArray(value)) { |
| 37 | return value |
| 38 | .map((item) => extractText(item)) |
| 39 | .filter((item) => item.length > 0) |
| 40 | .join(" "); |
| 41 | } |
| 42 | |
| 43 | if (!isRecord(value)) { |
| 44 | return ""; |
| 45 | } |
| 46 | |
| 47 | if (typeof value.text === "string") { |
| 48 | return value.text; |
| 49 | } |
| 50 | |
| 51 | if ("content" in value) { |
| 52 | return extractText(value.content); |
| 53 | } |
| 54 | |
| 55 | if ("parts" in value) { |
| 56 | return extractText(value.parts); |
| 57 | } |
| 58 | |
| 59 | return ""; |
| 60 | } |
| 61 | |
| 62 | function truncateMessage(message: string, maxLength = 80): string { |
| 63 | if (message.length <= maxLength) { |
no test coverage detected