export type GetApiWatchFilesystemPathArgs = {ignore?: string | undefined, path: string}; export type GetApiWatchFilesystemPathOptions = {baseUrl?: string | undefined, OAuth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Stream file modification events in a directory * * GET /watch/filesystem/{path} * * Also accepts auth: ApiKeyAuth */ export const getApiWatchFilesystemPath = async (args: GetApiWatchFilesystemPathArgs, options?: GetApiWatchFilesystemPathOptions) => { const {baseUrl = "https://api.blaxel.ai/v0", fetch: fetchFn = fetch, OAuth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/plain") if (args.ignore != null) query.append("ignore", String(args.ignore)) if (OAuth2 !== undefined) headers.set('authorization', `Bearer ${OAuth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/watch/filesystem/${encodeURIComponent(String(args.path))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };