feat: unified credits and its cost calculations

This commit is contained in:
DESKTOP-RTLN3BA\$punk 2026-05-02 14:34:23 -07:00
parent 451a98936e
commit ae9d36d77f
61 changed files with 5835 additions and 272 deletions

View file

@ -1,11 +1,20 @@
import { number, string, table } from "@rocicorp/zero";
/**
* Live-meter slice of the ``user`` table replicated through Zero.
*
* ``premiumCreditMicrosLimit`` / ``premiumCreditMicrosUsed`` are stored
* as integer micro-USD (1_000_000 == $1.00). UI consumers divide by 1M
* when displaying. Sensitive fields (email, hashed_password, oauth, etc.)
* are intentionally omitted via the Postgres column-list publication so
* they never enter WAL replication.
*/
export const userTable = table("user")
.columns({
id: string(),
pagesLimit: number().from("pages_limit"),
pagesUsed: number().from("pages_used"),
premiumTokensLimit: number().from("premium_tokens_limit"),
premiumTokensUsed: number().from("premium_tokens_used"),
premiumCreditMicrosLimit: number().from("premium_credit_micros_limit"),
premiumCreditMicrosUsed: number().from("premium_credit_micros_used"),
})
.primaryKey("id");