Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. 🫖 Status page with uptime monitoring & API monitoring as code 🫖 openstatus.dev
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536import { eq } from "@openstatus/db";import { page } from "@openstatus/db/src/schema";
import { emitAudit } from "../audit";import { requireScope } from "../auth";import { type ServiceContext, withTransaction } from "../context";import { getPageInWorkspace } from "./internal";import { DeletePageInput } from "./schemas";
/** Delete a page. FK cascade clears pageComponents / statusReports / … */export async function deletePage(args: { ctx: ServiceContext; input: DeletePageInput;}): Promise<void> { const { ctx } = args; requireScope(ctx, "write"); const input = DeletePageInput.parse(args.input);
await withTransaction(ctx, async (tx) => { const existing = await getPageInWorkspace({ tx, id: input.id, workspaceId: ctx.workspace.id, });
await tx.delete(page).where(eq(page.id, existing.id));
await emitAudit(tx, ctx, { action: "page.delete", entityType: "page", entityId: existing.id, before: existing, }); });}