- Migration 030: add email, assigned_plan, trial_duration_days, email_sent_at
to invite_codes with CHECK constraints
- Resend email integration (graceful degradation when API key not set)
- Invite codes now support plan assignment (free/pro/team) and trial duration (1-90 days)
- Registration applies invite code plan/trial to new subscription
- Auto-downgrade expired trials on authenticated access
- Enriched GET /admin/users/{id} with account, subscription, sessions, audit logs
- New endpoints: PUT /admin/users/{id}/subscription/plan and extend-trial
- Frontend: enhanced invite codes page with email, plan, trial fields
- Frontend: new user detail page at /admin/users/:userId
- Fixed API path drift: /invite-codes -> /invites
- 11 new backend tests, 416 total passing
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
53 lines
1.3 KiB
Python
53 lines
1.3 KiB
Python
from typing import Optional
|
|
from uuid import UUID
|
|
from datetime import datetime
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class SubscriptionResponse(BaseModel):
|
|
id: UUID
|
|
plan: str
|
|
status: str
|
|
billing_interval: Optional[str] = None
|
|
current_period_start: Optional[datetime] = None
|
|
current_period_end: Optional[datetime] = None
|
|
cancel_at_period_end: bool = False
|
|
stripe_subscription_id: Optional[str] = None
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class PlanLimitsResponse(BaseModel):
|
|
plan: str
|
|
max_trees: Optional[int] = None
|
|
max_sessions_per_month: Optional[int] = None
|
|
max_users: Optional[int] = None
|
|
custom_branding: bool = False
|
|
priority_support: bool = False
|
|
export_formats: list[str] = ["markdown", "text"]
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class UsageResponse(BaseModel):
|
|
tree_count: int
|
|
session_count_this_month: int
|
|
|
|
|
|
class SubscriptionDetails(BaseModel):
|
|
subscription: SubscriptionResponse
|
|
limits: PlanLimitsResponse
|
|
usage: UsageResponse
|
|
|
|
|
|
class SubscriptionPlanUpdate(BaseModel):
|
|
plan: str # free, pro, team
|
|
|
|
model_config = {"json_schema_extra": {"examples": [{"plan": "pro"}]}}
|
|
|
|
|
|
class ExtendTrialRequest(BaseModel):
|
|
days: int # 1-90
|
|
|
|
model_config = {"json_schema_extra": {"examples": [{"days": 14}]}}
|