feat: extend agent-driven map workbench

This commit is contained in:
2026-07-20 19:57:35 +08:00
parent 86e9b08235
commit 7fbd8a5618
63 changed files with 4506 additions and 457 deletions
+30
View File
@@ -0,0 +1,30 @@
import { NextResponse } from "next/server";
import {
MAX_CONDUIT_FEATURES,
MAX_MAP_FEATURE_IDS,
createMapFeatureWfsUrl,
normalizeMapFeatureCollection,
parseMapFeatureQuery
} from "@/features/workbench/map/map-feature-query";
export async function POST(request: Request) {
const parsed = parseMapFeatureQuery(await request.json().catch(() => null));
if (!parsed.ok) {
return NextResponse.json({ code: parsed.code }, { status: parsed.status });
}
try {
const response = await fetch(createMapFeatureWfsUrl(parsed.value), {
cache: "no-store",
signal: AbortSignal.timeout(8_000)
});
const collection = normalizeMapFeatureCollection(
await response.json(),
parsed.value.featureIds ? MAX_MAP_FEATURE_IDS : MAX_CONDUIT_FEATURES
);
if (!response.ok || !collection) throw new Error("Invalid WFS response");
return NextResponse.json(collection);
} catch {
return NextResponse.json({ code: "WFS_UNAVAILABLE" }, { status: 502 });
}
}