import { errorResponse, listEditorChannels } from "@/lib/articles/generation"; import { createSourcesOf } from "@/lib/articles/createSources"; import { listSources } from "@/lib/research/sources"; export const dynamic = "force-dynamic"; // The corpora "Article from a question" may sweep (demo epic D1 item 2): the // editor's own (its channels and the build holding them; handle "") and every // published archive the source picker offers (connected archives first). With // no local corpus — the editor holds no channel of its own — and an archive to // offer, the first archive is preselected. // // GET -> { sources: [{ handle, label, detail? }], preselect } export async function GET() { try { const [sources, channels] = await Promise.all([listSources(), listEditorChannels().catch(() => null)]); return Response.json(createSourcesOf(sources, channels), { headers: { "cache-control": "no-store" } }); } catch (err) { return errorResponse(err); } }