[taskboard] add completion sync APIs

This commit is contained in:
2026-03-07 12:53:22 -08:00
parent e8e79c7b4c
commit 73da5ae6d2
9 changed files with 249 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
import { NextResponse } from "next/server";
import { applyTaskCallback } from "@/lib/tasks";
export async function POST(
request: Request,
{ params }: { params: Promise<{ id: string }> },
) {
const { id } = await params;
const numericId = Number(id);
if (!Number.isInteger(numericId) || numericId <= 0) {
return NextResponse.json({ error: "invalid_task_id" }, { status: 400 });
}
const payload = (await request.json()) as {
status?: "Backlog" | "Todo" | "In Progress" | "Review" | "Done";
dispatch_state?: "planned" | "assigned" | "dispatched" | "acknowledged" | "completed" | "failed";
summary?: string | null;
detail?: string | null;
completed_by?: string | null;
last_error?: string | null;
};
const updated = await applyTaskCallback(numericId, payload);
if (!updated) {
return NextResponse.json({ error: "task_not_found" }, { status: 404 });
}
return NextResponse.json(updated);
}