import { NextResponse } from "next/server"; import { z } from "zod"; import { authenticateRequest, handleApiError } from "@/lib/api/authenticate"; import { importHomeBoxItems } from "@/lib/services/inventory-import"; const schema = z.object({ csv: z.string().min(1), skip: z.array(z.string()).optional(), }); // POST /api/v1/items/import — import a HomeBox CSV export. `skip` lists item // names to leave out (e.g. the ones unchecked in the preview). export async function POST(req: Request) { try { const ctx = await authenticateRequest(req, "items:write"); const { csv, skip } = schema.parse(await req.json()); const summary = await importHomeBoxItems(ctx, { csv, skip }); return NextResponse.json(summary, { status: 201 }); } catch (err) { return handleApiError(err); } }