File size: 814 Bytes
1f21206 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | import { api } from './client'
type DirEntry = {
name: string
path: string
isDirectory: boolean
relativePath?: string
}
type BrowseResult = {
currentPath: string
parentPath: string
entries: DirEntry[]
query?: string
}
export const filesystemApi = {
browse(path?: string, options?: { includeFiles?: boolean }) {
const q = new URLSearchParams()
if (path) q.set('path', path)
if (options?.includeFiles) q.set('includeFiles', 'true')
const qs = q.toString()
return api.get<BrowseResult>(`/api/filesystem/browse${qs ? `?${qs}` : ''}`)
},
search(query: string, cwd?: string) {
const q = new URLSearchParams({ search: query, maxResults: '200', includeFiles: 'true' })
if (cwd) q.set('path', cwd)
return api.get<BrowseResult>(`/api/filesystem/browse?${q}`)
},
}
|