import type { Db } from "@stc/db"; /** A user's display name and email (for commit authorship, e.g. the AI generator's studio drafts); null if unknown. */ export async function userIdentity(db: Db, userId: string): Promise<{ name: string; email: string } | null> { const rows = await db.sql`SELECT name, email FROM auth_user WHERE id = ${userId}`; const r = rows[0] as { name: string | null; email: string } | undefined; if (!r) return null; return { name: r.name?.trim() || r.email, email: r.email }; }