feat: sync project understanding for imported devices

This commit is contained in:
kris
2026-04-04 08:29:17 +08:00
parent 01f438e3af
commit 432cf97541
9 changed files with 587 additions and 18 deletions

View File

@@ -0,0 +1,30 @@
import { NextRequest, NextResponse } from "next/server";
import { authorizeDeviceSessionRequest } from "@/lib/boss-device-auth";
import { syncDeviceProjectUnderstanding } from "@/lib/boss-data";
export async function POST(
request: NextRequest,
context: { params: Promise<{ deviceId: string }> },
) {
const { deviceId } = await context.params;
const auth = await authorizeDeviceSessionRequest(request, deviceId);
if (!auth.ok) {
return NextResponse.json(
{ ok: false, message: auth.status === 404 ? "DEVICE_NOT_FOUND" : "UNAUTHORIZED" },
{ status: auth.status },
);
}
try {
const result = await syncDeviceProjectUnderstanding({
deviceId,
requestedByAccount: auth.session.account,
});
return NextResponse.json(result);
} catch (error) {
return NextResponse.json(
{ ok: false, message: error instanceof Error ? error.message : "UNKNOWN_ERROR" },
{ status: 400 },
);
}
}