Files
kandev/apps/web/lib/api/domains/fs-api.ts
T
2026-07-23 14:45:49 +01:00

24 lines
682 B
TypeScript

import { fetchJson, type ApiRequestOptions } from "../client";
export type DirectoryEntry = {
name: string;
path: string;
};
export type DirectoryListing = {
path: string;
parent: string;
entries: DirectoryEntry[];
choosable: boolean;
};
/**
* Lists immediate subdirectories of `path`. When path is empty the backend
* defaults to $HOME. Hidden directories (starting with ".") are excluded.
* Used by the folder picker for repo-less tasks.
*/
export async function listDirectory(path: string, options?: ApiRequestOptions) {
const qs = path ? `?path=${encodeURIComponent(path)}` : "";
return fetchJson<DirectoryListing>(`/api/v1/fs/list-dir${qs}`, options);
}