2026-05-17 08:38:41 +00:00
|
|
|
import { apiRequest } from './api.js'
|
|
|
|
|
|
2026-05-15 06:56:17 +00:00
|
|
|
export function fetchKnowledgeLibrary() {
|
|
|
|
|
return apiRequest('/knowledge/library')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function fetchKnowledgeDocument(documentId) {
|
|
|
|
|
return apiRequest(`/knowledge/documents/${documentId}`)
|
|
|
|
|
}
|
2026-05-09 05:59:46 +00:00
|
|
|
|
|
|
|
|
export function fetchKnowledgeOnlyOfficeConfig(documentId) {
|
|
|
|
|
return apiRequest(`/knowledge/documents/${documentId}/onlyoffice-config`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function uploadKnowledgeDocument({ folder, file }) {
|
|
|
|
|
return apiRequest(
|
|
|
|
|
`/knowledge/documents?folder=${encodeURIComponent(folder)}&filename=${encodeURIComponent(file.name)}`,
|
|
|
|
|
{
|
|
|
|
|
method: 'POST',
|
|
|
|
|
body: file,
|
|
|
|
|
contentType: file.type || 'application/octet-stream'
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-15 06:56:17 +00:00
|
|
|
export function deleteKnowledgeDocument(documentId) {
|
|
|
|
|
return apiRequest(`/knowledge/documents/${documentId}`, {
|
|
|
|
|
method: 'DELETE'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-17 08:38:41 +00:00
|
|
|
export function syncKnowledgeLibrary({ folder, documentIds = [], force = false }) {
|
|
|
|
|
return apiRequest('/knowledge/sync', {
|
2026-05-15 06:56:17 +00:00
|
|
|
method: 'POST',
|
|
|
|
|
body: JSON.stringify({
|
|
|
|
|
folder,
|
2026-05-17 08:38:41 +00:00
|
|
|
document_ids: Array.isArray(documentIds) ? documentIds : [],
|
2026-05-15 06:56:17 +00:00
|
|
|
force
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function fetchKnowledgeDocumentBlob(documentId, disposition = 'inline') {
|
|
|
|
|
return apiRequest(`/knowledge/documents/${documentId}/content?disposition=${disposition}`, {
|
|
|
|
|
responseType: 'blob',
|
2026-05-09 05:59:46 +00:00
|
|
|
contentType: null
|
|
|
|
|
})
|
|
|
|
|
}
|