diff --git a/src/app/api/issues/move/route.ts b/src/app/api/issues/move/route.ts index dd9a9dd8..6f35f732 100644 --- a/src/app/api/issues/move/route.ts +++ b/src/app/api/issues/move/route.ts @@ -1,13 +1,9 @@ import { NextResponse } from "next/server"; import { prisma } from "@/lib/prisma"; import { updateIssueLabels, removeIssueLabel, addIssueLabel } from "@/lib/github"; -import { STATUS_LABELS, StatusLabel } from "@/types"; +import { STATUS_LABELS, isStatusLabel } from "@/types"; import { authorizeRequest, getAuthorizedActor } from "@/lib/auth"; -function isStatusLabel(label: string): label is StatusLabel { - return (STATUS_LABELS as readonly string[]).includes(label); -} - export async function POST(request: Request) { const auth = await authorizeRequest(request); if (!auth.authorized) { diff --git a/src/app/api/issues/status/route.ts b/src/app/api/issues/status/route.ts index e843ce21..beaceb58 100644 --- a/src/app/api/issues/status/route.ts +++ b/src/app/api/issues/status/route.ts @@ -1,13 +1,9 @@ import { NextResponse } from "next/server"; import { prisma } from "@/lib/prisma"; import { removeIssueLabel, addIssueLabel } from "@/lib/github"; -import { STATUS_LABELS, StatusLabel } from "@/types"; +import { STATUS_LABELS, StatusLabel, isStatusLabel } from "@/types"; import { authorizeRequest, getAuthorizedActor } from "@/lib/auth"; -function isStatusLabel(label: string): label is StatusLabel { - return (STATUS_LABELS as readonly string[]).includes(label); -} - export async function POST(request: Request) { const auth = await authorizeRequest(request); if (!auth.authorized) { diff --git a/src/types/index.ts b/src/types/index.ts index 915ab19e..41411ba6 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -123,6 +123,11 @@ export const BOARD_COLUMNS: BoardColumn[] = [ export const STATUS_LABELS: StatusLabel[] = BOARD_COLUMNS.map((col) => col.id); export const PRIORITY_LABELS: PriorityLabel[] = ["priority/p0", "priority/p1", "priority/p2", "priority/p3"]; + +/** Type guard: is `label` one of the allowed `status/*` labels? */ +export function isStatusLabel(label: string): label is StatusLabel { + return (STATUS_LABELS as readonly string[]).includes(label); +} export const PROJECT_PREFIX = "project/"; export const AGENT_PREFIX = "agent/"; export const OWNER_PREFIX = "owner/";