(value: unknown)
| 72 | } |
| 73 | |
| 74 | function renderMetadataValue(value: unknown) { |
| 75 | if (value == null) return <span className='text-[var(--text-muted)]'>-</span> |
| 76 | |
| 77 | if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') { |
| 78 | return <span className='text-[var(--text-primary)]'>{formatPrimitiveValue(value)}</span> |
| 79 | } |
| 80 | |
| 81 | if (Array.isArray(value)) { |
| 82 | if (value.length === 0) { |
| 83 | return <span className='text-[var(--text-muted)]'>None</span> |
| 84 | } |
| 85 | |
| 86 | const hasComplexValues = value.some((item) => typeof item === 'object' && item !== null) |
| 87 | if (!hasComplexValues) { |
| 88 | return ( |
| 89 | <span className='text-[var(--text-primary)]'> |
| 90 | {value |
| 91 | .map((item) => formatPrimitiveValue((item as string | number | boolean | null) ?? null)) |
| 92 | .join(', ')} |
| 93 | </span> |
| 94 | ) |
| 95 | } |
| 96 | |
| 97 | return ( |
| 98 | <pre className='min-w-0 flex-1 overflow-x-auto whitespace-pre-wrap break-all text-[var(--text-secondary)] text-xs'> |
| 99 | {JSON.stringify(value, null, 2)} |
| 100 | </pre> |
| 101 | ) |
| 102 | } |
| 103 | |
| 104 | if (isRecordLike(value)) { |
| 105 | const entries = Object.entries(value).filter(([, nestedValue]) => nestedValue !== undefined) |
| 106 | if (entries.length === 0) { |
| 107 | return <span className='text-[var(--text-muted)]'>None</span> |
| 108 | } |
| 109 | |
| 110 | const hasComplexValues = entries.some(([, nestedValue]) => { |
| 111 | return Array.isArray(nestedValue) || isRecordLike(nestedValue) |
| 112 | }) |
| 113 | |
| 114 | if (!hasComplexValues) { |
| 115 | return ( |
| 116 | <span className='text-[var(--text-primary)]'> |
| 117 | {entries |
| 118 | .map(([nestedKey, nestedValue]) => { |
| 119 | return `${formatMetadataLabel(nestedKey)}: ${formatPrimitiveValue((nestedValue as string | number | boolean | null) ?? null)}` |
| 120 | }) |
| 121 | .join(' · ')} |
| 122 | </span> |
| 123 | ) |
| 124 | } |
| 125 | |
| 126 | return ( |
| 127 | <pre className='min-w-0 flex-1 overflow-x-auto whitespace-pre-wrap break-all text-[var(--text-secondary)] text-xs'> |
| 128 | {JSON.stringify(value, null, 2)} |
| 129 | </pre> |
| 130 | ) |
| 131 | } |
no test coverage detected