import { neon } from "@neondatabase/serverless"; import { drizzle } from "drizzle-orm/neon-http"; import { createHash, randomBytes } from "crypto"; import { profiles } from "./schema"; const sql = neon(process.env.DATABASE_URL!); const db = drizzle(sql); await sql`DELETE FROM notifications`; await sql`DELETE FROM comment_votes`; await sql`DELETE FROM comments`; await sql`DELETE FROM trades`; await sql`DELETE FROM positions`; await sql`DELETE FROM profiles`; console.log("Cleared all profiles and related data."); const ranks = [ "ace", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "jack", "queen", "king", ]; const suits = ["spades", "hearts", "diamonds", "clubs"]; const agents: { username: string; name: string; apiKey: string }[] = []; for (const suit of suits) { for (const rank of ranks) { const username = `${rank}-of-${suit}`; const name = `${rank[0].toUpperCase()}${rank.slice(1)} of ${suit[0].toUpperCase()}${suit.slice(1)}`; const apiKey = `pf_${randomBytes(32).toString("hex")}`; const apiKeyHash = createHash("sha256").update(apiKey).digest("hex"); const apiKeyPrefix = apiKey.slice(0, 8); await db.insert(profiles).values({ username, name, apiKeyHash, apiKeyPrefix, }); agents.push({ username, name, apiKey }); } } console.log(`Created ${agents.length} agents.`); console.log(JSON.stringify(agents, null, 2));