import { json } from '@sveltejs/kit'; import { cancelCollection } from '$lib/server/fleet/collections.js'; import { db } from '$lib/server/db/index.js'; import { kickProvisioning } from '$lib/server/pipeline/worker.js'; export function POST({ params }: { params: { id: string } }) { if (!db().prepare('SELECT 1 FROM server_launch_collections WHERE id=?').get(params.id)) { return json({ error: 'Collection not found.' }, { status: 404 }); } if (!cancelCollection(params.id)) { return json({ error: 'This collection has no work that can still be cancelled. Refresh to see its current state.' }, { status: 409 }); } void kickProvisioning(); return json({ ok: true }); }