diff options
| author | Frank <[email protected]> | 2026-03-17 15:00:44 -0400 |
|---|---|---|
| committer | Frank <[email protected]> | 2026-03-17 15:00:44 -0400 |
| commit | 0772a9591807d15c369c37edc01b9018bdc6e7d1 (patch) | |
| tree | 9e6cea034ebbb9adfe0ec4522809f42813ea19b5 | |
| parent | dadddc9c8c35ecb80b287ab729cfed5869b86d56 (diff) | |
| download | opencode-0772a9591807d15c369c37edc01b9018bdc6e7d1.tar.gz opencode-0772a9591807d15c369c37edc01b9018bdc6e7d1.zip | |
wip: zen
| -rw-r--r-- | packages/console/core/script/lookup-user.ts | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/packages/console/core/script/lookup-user.ts b/packages/console/core/script/lookup-user.ts index 0dfda2411..8b7bbc1ca 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 line const 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 ID if (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)), ) |
