(documentName: string)
| 19 | * Otherwise, the filename is normalized to `.txt` with `text/plain`. |
| 20 | */ |
| 21 | export function inferDocumentFileInfo(documentName: string): { |
| 22 | filename: string |
| 23 | mimeType: string |
| 24 | } { |
| 25 | const ext = getFileExtension(documentName) |
| 26 | if (ext) { |
| 27 | const mimeType = getUploadMimeType(ext) |
| 28 | if (TEXT_COMPATIBLE_MIME_TYPES.has(mimeType)) { |
| 29 | return { filename: documentName, mimeType } |
| 30 | } |
| 31 | } |
| 32 | const base = ext ? documentName.slice(0, documentName.lastIndexOf('.')) : documentName |
| 33 | return { filename: `${base || documentName}.txt`, mimeType: 'text/plain' } |
| 34 | } |
| 35 | |
| 36 | interface KnowledgeSearchResult { |
| 37 | documentId: string |
no test coverage detected