import { type CreditGrantClass } from "@opengeni/contracts"; import type { Database } from "./database.js"; /** * Server-side usage analytics reads and writes (migration 0565). Every value * is content-free: opaque `user:` subjects for presence, and bounded classes * for credit grants. None of these is an authorization input. */ /** Fixed presence windows published as `opengeni_active_users{window}`. */ export declare const ACTIVE_USER_WINDOWS: readonly ["5m", "15m", "1h", "24h", "7d", "30d"]; export type ActiveUserWindow = (typeof ACTIVE_USER_WINDOWS)[number]; /** The only subjects presence accepts: opaque managed-human identifiers. */ export declare const USER_ACTIVITY_PRESENCE_SUBJECT_PATTERN: RegExp; /** Upper bound of one presence batch; the database function enforces it too. */ export declare const USER_ACTIVITY_PRESENCE_MAX_BATCH = 1000; /** * Record that these managed humans were active now. Subjects outside the * opaque `user:` shape are dropped here and again in the database. The UTC-day * change of a row writes the `user.active` lifecycle fact. Returns the number * of rows written; rows seen in the last 30 seconds are left untouched. */ export declare function recordUserActivityPresence(db: Database, subjectIds: readonly string[]): Promise; /** Distinct managed humans seen within each fixed window, including zeroes. */ export declare function countActiveUsers(db: Database): Promise>; export type CreditGrantTotals = Record; /** * Positive credit grants observed since migration 0565, by class, including * zeroes. The ledger trigger observes every writer: the verified-signup trial * trigger, Stripe coupon checkouts, and operator grants. */ export declare function readCreditGrantTotals(db: Database): Promise;