The open source coding agent.
TypeScript
wip: zen
Frank0772a9591807
diff --git a/packages/console/core/script/lookup-user.ts b/packages/console/core/script/lookup-user.tsindex 0dfda24116d..8b7bbc1caa6 100644--- a/packages/console/core/script/lookup-user.ts+++ b/packages/console/core/script/lookup-user.ts@@ -3,6 +3,7 @@ import { AuthTable } from "../src/schema/auth.sql.js"import { UserTable } from "../src/schema/user.sql.js"import { BillingTable, PaymentTable, SubscriptionTable, BlackPlans, UsageTable } from "../src/schema/billing.sql.js"import { WorkspaceTable } from "../src/schema/workspace.sql.js"+import { KeyTable } from "../src/schema/key.sql.js"import { BlackData } from "../src/black.js"import { centsToMicroCents } from "../src/util/price.js"import { getWeekBounds } from "../src/util/date.js"@@ -10,13 +11,31 @@ import { getWeekBounds } from "../src/util/date.js"// get input from command lineconst identifier = process.argv[2]if (!identifier) {- console.error("Usage: bun lookup-user.ts <email|workspaceID>")+ console.error("Usage: bun lookup-user.ts <email|workspaceID|apiKey>")process.exit(1)}+// loop up by workspace IDif (identifier.startsWith("wrk_")) {await printWorkspace(identifier)-} else {+}+// lookup by API key+else if (identifier.startsWith("key_")) {+ const key = await Database.use((tx) =>+ tx+ .select()+ .from(KeyTable)+ .where(eq(KeyTable.id, identifier))+ .then((rows) => rows[0]),+ )+ if (!key) {+ console.error("API key not found")+ process.exit(1)+ }+ await printWorkspace(key.workspaceID)+}+// lookup by email+else {const authData = await Database.use(async (tx) =>tx.select().from(AuthTable).where(eq(AuthTable.subject, identifier)),)