Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/packages/cli/src/commands/forms/delete.ts
T

27 lines
919 B
TypeScript

/**
* `forms delete --id <formId>` — hard-delete a form and cascade
* its FormSubmission rows. No soft-delete in Phase-1.
*/
import { defineCommand } from "citty";
import consola from "consola";
export const formsDeleteCommand = defineCommand({
meta: { name: "delete", description: "Delete a form (cascade submissions)." },
args: {
id: { type: "string", required: true, description: "Form ID." },
},
async run({ args }) {
const { getDbClient } = await import("@toolctrl/db/client.server");
const prisma = getDbClient();
const id = String(args.id);
const existing = await prisma.form.findUnique({ where: { id }, select: { id: true, name: true } });
if (!existing) {
consola.error(`Form ${id} not found.`);
process.exitCode = 1;
return;
}
await prisma.form.delete({ where: { id } });
consola.success(`Form deleted: ${id} (${existing.name}).`);
},
});