Download desktop/src/api/filesystem.ts from chenbhao/codev: direct link, hf CLI and curl.
- Browser
- Download file 814 Bytes
-
https://huggingface.co/chenbhao/codev/resolve/e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/api/filesystem.ts
- Command line
-
hf download hf://chenbhao/codev@e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/api/filesystem.ts
-
curl -L -o filesystem.ts https://huggingface.co/chenbhao/codev/resolve/e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/api/filesystem.ts
814 Bytes
| 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}`) | |
| }, | |
| } | |