Download references/task-status/src/api/tasks.ts from mirasim-ai/devbrowse-bench: direct link, hf CLI and curl.
- Browser
- Download file 958 Bytes
-
https://huggingface.co/datasets/mirasim-ai/devbrowse-bench/resolve/main/references/task-status/src/api/tasks.ts
- Command line
-
hf download hf://datasets/mirasim-ai/devbrowse-bench/references/task-status/src/api/tasks.ts
-
curl -L -o tasks.ts https://huggingface.co/datasets/mirasim-ai/devbrowse-bench/resolve/main/references/task-status/src/api/tasks.ts
958 Bytes
| import type { Comment, NewTask, Task, TaskPatch, TaskStatus } from "../types"; | |
| import { api } from "./client"; | |
| // Tasks saved before statuses existed carry only a `done` flag. | |
| type TaskRecord = Omit<Task, "status"> & { status?: TaskStatus; done?: boolean }; | |
| const toTask = ({ done, ...t }: TaskRecord): Task => ({ ...t, status: t.status ?? (done ? "done" : "todo") }); | |
| export const tasksApi = { | |
| list: (query = "") => | |
| api.get<TaskRecord[]>(query ? `/tasks?q=${encodeURIComponent(query)}` : "/tasks").then((ts) => ts.map(toTask)), | |
| get: (id: number) => api.get<TaskRecord>(`/tasks/${id}`).then(toTask), | |
| create: (task: NewTask) => api.post<TaskRecord>("/tasks", { ...task, status: "todo" }).then(toTask), | |
| update: (id: number, patch: TaskPatch) => api.patch<TaskRecord>(`/tasks/${id}`, patch).then(toTask), | |
| remove: (id: number) => api.del<{ ok: true }>(`/tasks/${id}`), | |
| comments: (id: number) => api.get<Comment[]>(`/tasks/${id}/comments`), | |
| }; | |