Files
kandev/apps/web/lib/api/domains/task-dependencies-api.ts
T
João Salavisa 1f38b6b435 feat(tasks): add task dependencies with auto-start chaining (#2589)
Co-authored-by: Kandev Agent <agent@kandev.dev>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-13 11:27:17 +01:00

30 lines
974 B
TypeScript

import { fetchJson, type ApiRequestOptions } from "@/lib/api/client";
const BASE = "/api/v1";
export type TaskDependencyRefResponse = {
id: string;
title?: string;
state?: string;
status?: "resolved" | "failed" | "pending";
};
/**
* Reads one task's dependency projection.
*
* The chip prefers the board store, but a task.updated event can land before or
* after hydration carrying no dependency fields, which leaves the store copy
* without them. Rather than depend on WS/hydration ordering for a field the
* server derives per read, fall back to asking for it — the same
* fetch-your-own-data shape `PRStatusChip` already uses via `useTaskPR`.
*/
export function getTaskDependencies(taskId: string, options?: ApiRequestOptions) {
return fetchJson<{
id: string;
blocked?: boolean;
blocked_reason?: string;
depends_on?: TaskDependencyRefResponse[];
blocks?: TaskDependencyRefResponse[];
}>(`${BASE}/tasks/${taskId}`, options);
}