import { a as recordAudit } from './audit-log-BXVi9iyE.js';
import { e as executeCliAction } from './cli-action-DQcaqcfn.js';
import 'node:fs';
import 'node:path';
import './spawn-cli-wI1lBJhm.js';
import 'node:child_process';
import '@sveltejs/kit';

//#region src/routes/api/project/gc/+server.ts
/**
* POST /api/project/gc
*
* Runs `cleo nexus gc --json` to garbage-collect orphan rows / dead
* edges in the nexus symbol graph. Always defaults to `--dry-run` unless
* the caller explicitly sends `{ dryRun: false }`.
*
* @task T990
* @wave 1E
*/
var POST = async ({ request, locals }) => {
	let body = {};
	try {
		const raw = await request.json();
		if (raw && typeof raw === "object") body = raw;
	} catch {}
	const dryRun = body.dryRun !== false;
	const args = [
		"nexus",
		"gc",
		"--json"
	];
	if (dryRun) args.push("--dry-run");
	else args.push("--yes");
	recordAudit(locals.projectCtx.projectPath, {
		actor: "studio-admin",
		action: "project.gc",
		target: locals.projectCtx.projectId || locals.projectCtx.projectPath,
		result: dryRun ? "dry-run" : "initiated"
	});
	const response = await executeCliAction(args, {
		errorCode: "E_GC_FAILED",
		meta: { dryRun }
	});
	recordAudit(locals.projectCtx.projectPath, {
		actor: "studio-admin",
		action: "project.gc",
		target: locals.projectCtx.projectId || locals.projectCtx.projectPath,
		result: response.status === 200 ? "success" : "failure",
		detail: dryRun ? "dry-run" : "live"
	});
	return response;
};

export { POST };
//# sourceMappingURL=_server.ts-DnE0f-iC.js.map
