Add deterministic UUID generation for achievements

cgen-7e9fd578e56d4a5dbec8fce5ec8f4c92
This commit is contained in:
Builder.io 2025-11-10 03:32:55 +00:00
parent c85d75d09d
commit b304238c3f

View file

@ -1,7 +1,19 @@
import type { VercelRequest, VercelResponse } from "@vercel/node";
import { randomUUID } from "crypto";
import { createHash } from "crypto";
import { getAdminClient } from "../../api/_supabase";
const generateDeterministicUUID = (str: string): string => {
const hash = createHash("sha256").update(str).digest("hex");
return [
hash.slice(0, 8),
hash.slice(8, 12),
"5" + hash.slice(13, 16),
((parseInt(hash.slice(16, 18), 16) & 0x3f) | 0x80).toString(16).padStart(2, "0") + hash.slice(18, 20),
hash.slice(20, 32),
].join("-");
};
const CORE_ACHIEVEMENTS = [
{
id: "welcome-to-aethex",