feat: add task workflow and asset downloads

This commit is contained in:
inman
2026-05-29 12:32:02 +08:00
parent f9c3393f84
commit 63e62d444c
61 changed files with 2773 additions and 2181 deletions

View File

@@ -0,0 +1,26 @@
import { clearGenerationJobLock, getGenerationJob, updateGenerationJob } from "@/lib/server/data-store";
import { jsonError, jsonOk } from "@/lib/server/api";
import { authenticatePublicApiRequest } from "@/lib/server/public-api-auth";
import { publicApiError } from "@/lib/server/public-api-response";
export const runtime = "nodejs";
export async function POST(request: Request, context: { params: Promise<{ id: string }> }) {
try {
const client = authenticatePublicApiRequest(request);
const { id } = await context.params;
const job = await getGenerationJob(id);
if (!job || job.externalClientId !== client.id) return jsonError("Job not found.", 404);
if (["succeeded", "failed", "expired", "cancelled"].includes(job.status)) {
return jsonOk({ job });
}
await updateGenerationJob(id, {
status: "cancelled",
completedAt: new Date().toISOString()
});
const cancelled = await clearGenerationJobLock(id);
return jsonOk({ job: cancelled });
} catch (error) {
return publicApiError(error);
}
}