docling-studio/frontend/src/features/store/api.ts
Pier-Jean Malandrino 66f0d0cf62 feat(#243,#244,#245): E8 — Stores pages (list, detail, query)
- features/store: api + types (StoreInfo, StoreDocEntry, QueryResult)
- StoresListPage: table with connection status, click → StoreDetail
- StoreDetailPage: doc table with StatusBadge, remove, bulk remove, link to query
- StoreQueryPage: query form (Ctrl+Enter), topK, scored results with doc links
- i18n: stores.* / storeDetail.* / storeQuery.* keys (FR + EN)

Closes #243
Closes #244
Closes #245
2026-04-30 14:59:56 +02:00

50 lines
1.3 KiB
TypeScript

import { apiFetch } from '../../shared/api/http'
import type { DocumentLifecycleState } from '../../shared/types'
export interface StoreInfo {
name: string
type: string
connected: boolean
documentCount: number
chunkCount: number
errorMessage?: string
}
export interface StoreDocEntry {
docId: string
filename: string
state: DocumentLifecycleState
chunkCount: number
pushedAt: string
}
export interface QueryResult {
chunkId: string
docId: string
filename: string
text: string
score: number
pageRange?: [number, number]
}
export function fetchStores(): Promise<StoreInfo[]> {
return apiFetch<StoreInfo[]>('/api/stores')
}
export function fetchStoreDocuments(store: string): Promise<StoreDocEntry[]> {
return apiFetch<StoreDocEntry[]>(`/api/stores/${encodeURIComponent(store)}/documents`)
}
export function removeDocumentFromStore(store: string, docId: string): Promise<void> {
return apiFetch<void>(
`/api/stores/${encodeURIComponent(store)}/documents/${encodeURIComponent(docId)}`,
{ method: 'DELETE' },
)
}
export function queryStore(store: string, query: string, topK = 5): Promise<QueryResult[]> {
return apiFetch<QueryResult[]>(`/api/stores/${encodeURIComponent(store)}/query`, {
method: 'POST',
body: JSON.stringify({ query, top_k: topK }),
})
}