"use server"; import { revalidatePath } from "next/cache"; import { requireStaff } from "@/lib/admin/guard"; import { prisma } from "@/lib/prisma"; // emulator_settings: PK is the string column `key`, payload is `value` (VarChar 512). // emulator_texts: PK is the string column `key`, payload is `value` (VarChar 4096). // Both tables are emulator-owned; we only ever read/update existing rows or add new // keys via upsert. We never migrate or drop them. export async function updateEmulatorSetting(formData: FormData): Promise { await requireStaff(); const key = String(formData.get("key") ?? "") .normalize("NFC") .trim() .slice(0, 100); const value = String(formData.get("value") ?? "") .normalize("NFC") .slice(0, 512); if (!key) return; await prisma.emulatorSettings.upsert({ where: { key }, update: { value }, create: { key, value }, }); revalidatePath("/admin/emulator"); } export async function updateEmulatorText(formData: FormData): Promise { await requireStaff(); const key = String(formData.get("key") ?? "") .normalize("NFC") .trim() .slice(0, 100); const value = String(formData.get("value") ?? "") .normalize("NFC") .slice(0, 4096); if (!key) return; await prisma.emulatorTexts.upsert({ where: { key }, update: { value }, create: { key, value }, }); revalidatePath("/admin/emulator"); }