Entitlement constructor

const Entitlement({
  1. required PlanTier plan,
  2. required EntitlementSource source,
  3. DateTime? expiresAt,
  4. DateTime? trialExpiresAt,
  5. DateTime? trialStartedAt,
  6. @Default(<String, dynamic>{}) Map<String, dynamic> entitlements,
  7. @Default(<String>[]) List<String> grantsApplied,
  8. int? aiDailyCap,
  9. int? aiWeeklyCap,
  10. int? aiTotalCap,
  11. @Default(0) int aiBoost,
})

Implementation

const factory Entitlement({
  required PlanTier plan,
  required EntitlementSource source,

  /// End of the current subscription period, if any.
  DateTime? expiresAt,

  /// Computed trial_started_at + 14 days + any extend_trial grants.
  DateTime? trialExpiresAt,

  /// Raw trial_started_at from profiles.settings.
  DateTime? trialStartedAt,

  /// Raw flattened entitlement map from plan_catalog(). Prefer the typed
  /// getters below over indexing this directly.
  @Default(<String, dynamic>{}) Map<String, dynamic> entitlements,

  /// Active admin_grant IDs contributing to this entitlement, for audit.
  @Default(<String>[]) List<String> grantsApplied,

  /// Null = no daily cap for the plan (e.g. unlimited).
  int? aiDailyCap,

  /// Null = no weekly cap for the plan.
  int? aiWeeklyCap,

  /// Null = no total cap. Non-null only for trial users: total AI messages
  /// allowed for the entire trial period (e.g. 50).
  int? aiTotalCap,

  /// Extra AI messages granted via usage_boost grants.
  @Default(0) int aiBoost,
}) = _Entitlement;