Files
resolutionflow/backend/app/schemas/account.py
Michael Chihlas 47ff8ad2b5 feat(l1): enforce seat limits on invite, accept-invite, role-change
For engineer + l1_tech roles, check_seat_available is called at each
mutation point. Returns 402 Payment Required with structured detail
{code: 'seat_limit_exceeded', role, current, limit, upgrade_url} when
seats are full. Grandfathering: existing over-seated accounts keep
existing users; only new mutations are blocked.

Also updates AccountInviteCreate and AccountRoleUpdate schemas to
accept l1_tech as a valid role value.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-28 12:49:59 -04:00

54 lines
1.3 KiB
Python

from datetime import datetime
from typing import Optional
from uuid import UUID
from pydantic import BaseModel, Field
class AccountResponse(BaseModel):
id: UUID
name: str
display_code: str
owner_id: UUID
stripe_customer_id: Optional[str] = None
created_at: datetime
updated_at: datetime
model_config = {"from_attributes": True}
class AccountUpdate(BaseModel):
name: Optional[str] = Field(None, min_length=1, max_length=255)
class TransferOwnershipRequest(BaseModel):
current_password: str
target_user_id: UUID
class AccountInviteCreate(BaseModel):
email: str = Field(..., max_length=255)
role: str = Field("engineer", pattern="^(engineer|viewer|l1_tech)$")
expires_in_days: Optional[int] = Field(None, ge=1, le=30)
class AccountInviteResponse(BaseModel):
id: UUID
account_id: UUID
email: str
code: str
role: str
expires_at: Optional[datetime] = None
created_at: datetime
used_at: Optional[datetime] = None
model_config = {"from_attributes": True}
class AccountInviteBulkCreate(BaseModel):
invites: list[AccountInviteCreate]
class AccountInviteBulkResponse(BaseModel):
created: list[AccountInviteResponse]
failed: list[dict] # entries shaped {"email": str, "error": str}