Your Name 1967992de7
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled
feat(video): storyboard task tables and delayed archive flow
2026-03-05 15:58:43 +08:00

51 lines
1.2 KiB
TypeScript

import { NextResponse } from "next/server";
import { z } from "zod";
import { ChatSDKError } from "@/lib/errors";
import { requireAdmin } from "@/lib/middleware/admin";
import { getVideoStoryboardTaskDetail } from "@/lib/video-agent/task-store";
const paramsSchema = z.object({
taskId: z.string().uuid(),
});
export async function GET(
_request: Request,
{ params }: { params: Promise<{ taskId: string }> }
) {
try {
await requireAdmin();
const parsed = paramsSchema.parse(await params);
const detail = await getVideoStoryboardTaskDetail(parsed.taskId);
if (!detail) {
return NextResponse.json(
{ success: false, error: "任务不存在" },
{ status: 404 }
);
}
return NextResponse.json({
success: true,
task: detail.task,
shots: detail.shots,
});
} catch (error) {
if (error instanceof ChatSDKError) {
return error.toResponse();
}
if (error instanceof z.ZodError) {
return NextResponse.json(
{ success: false, error: error.message },
{ status: 400 }
);
}
return NextResponse.json(
{
success: false,
error: error instanceof Error ? error.message : "查询任务失败",
},
{ status: 500 }
);
}
}