GrantsDatasource class

CRUD for public.admin_grants. Restricted to platform admins by RLS, so these methods will simply return empty lists / throw when called by non-admins.

Constructors

GrantsDatasource(SupabaseClient _client)

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

createCompPlanGrant({String? targetUserId, String? targetOrgId, required String plan, String? reason, DateTime? endsAt}) Future<AdminGrantModel>
Create a comp_plan grant for a user or org. Plan must be one of 'professional', 'team', 'enterprise'.
createExtendTrialGrant({String? targetUserId, String? targetOrgId, required int days, String? reason}) Future<AdminGrantModel>
Create an extend_trial grant: adds days days to the target's trial window.
createUsageBoostGrant({String? targetUserId, String? targetOrgId, required int messages, required DateTime endsAt, String? reason}) Future<AdminGrantModel>
Create a usage_boost grant: adds messages extra AI messages to the daily/weekly cap for the grant window (endsAt).
listOrgGrants(String orgId) Future<List<AdminGrantModel>>
List all grants targeting a specific org (active + revoked).
listUserGrants(String userId) Future<List<AdminGrantModel>>
List all grants targeting a specific user (active + revoked).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
revokeGrant(String grantId) Future<void>
Soft-revoke a grant. The row stays in the table for audit; entitlement resolution ignores it once revoked_at is non-null.
searchUsers(String query) Future<List<Map<String, dynamic>>>
Search users by email or display_name (platform admin only). Uses the backoffice_search_users SECURITY DEFINER RPC to bypass RLS.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited