(fileInput: unknown)
| 9 | const logger = createLogger('FileBlock') |
| 10 | |
| 11 | const resolveFilePathFromInput = (fileInput: unknown): string | null => { |
| 12 | if (!fileInput || typeof fileInput !== 'object') { |
| 13 | return null |
| 14 | } |
| 15 | |
| 16 | const record = fileInput as Record<string, unknown> |
| 17 | if (typeof record.path === 'string' && record.path.trim() !== '') { |
| 18 | return record.path |
| 19 | } |
| 20 | if (typeof record.url === 'string' && record.url.trim() !== '') { |
| 21 | return record.url |
| 22 | } |
| 23 | if (typeof record.key === 'string' && record.key.trim() !== '') { |
| 24 | const key = record.key.trim() |
| 25 | const context = typeof record.context === 'string' ? record.context : inferContextFromKey(key) |
| 26 | return `/api/files/serve/${encodeURIComponent(key)}?context=${context}` |
| 27 | } |
| 28 | |
| 29 | return null |
| 30 | } |
| 31 | |
| 32 | const resolveFilePathsFromInput = (fileInput: unknown): string[] => { |
| 33 | if (!fileInput) { |
no test coverage detected