2026-02-09 15:49:50 +05:30
|
|
|
"""User API schemas for create, update, and read operations."""
|
|
|
|
|
|
2026-02-04 02:28:51 +05:30
|
|
|
from __future__ import annotations
|
|
|
|
|
|
2026-02-09 17:24:21 +05:30
|
|
|
from uuid import UUID
|
2026-02-04 02:28:51 +05:30
|
|
|
|
2026-02-15 02:35:31 +05:30
|
|
|
from pydantic import Field
|
2026-02-04 02:28:51 +05:30
|
|
|
from sqlmodel import SQLModel
|
|
|
|
|
|
2026-02-09 17:24:21 +05:30
|
|
|
RUNTIME_ANNOTATION_TYPES = (UUID,)
|
|
|
|
|
|
2026-02-04 02:28:51 +05:30
|
|
|
|
|
|
|
|
class UserBase(SQLModel):
|
2026-02-09 15:49:50 +05:30
|
|
|
"""Common user profile fields shared across user payload schemas."""
|
|
|
|
|
|
2026-02-15 02:35:31 +05:30
|
|
|
clerk_user_id: str = Field(
|
|
|
|
|
description="External auth provider user identifier (Clerk).",
|
|
|
|
|
examples=["user_2abcXYZ"],
|
|
|
|
|
)
|
|
|
|
|
email: str | None = Field(
|
|
|
|
|
default=None,
|
|
|
|
|
description="Primary email address for the user.",
|
|
|
|
|
examples=["alex@example.com"],
|
|
|
|
|
)
|
|
|
|
|
name: str | None = Field(
|
|
|
|
|
default=None,
|
|
|
|
|
description="Full display name.",
|
|
|
|
|
examples=["Alex Chen"],
|
|
|
|
|
)
|
|
|
|
|
preferred_name: str | None = Field(
|
|
|
|
|
default=None,
|
|
|
|
|
description="Preferred short name used in UI.",
|
|
|
|
|
examples=["Alex"],
|
|
|
|
|
)
|
|
|
|
|
pronouns: str | None = Field(
|
|
|
|
|
default=None,
|
|
|
|
|
description="Preferred pronouns.",
|
|
|
|
|
examples=["they/them"],
|
|
|
|
|
)
|
|
|
|
|
timezone: str | None = Field(
|
|
|
|
|
default=None,
|
|
|
|
|
description="IANA timezone identifier.",
|
|
|
|
|
examples=["America/Los_Angeles"],
|
|
|
|
|
)
|
|
|
|
|
notes: str | None = Field(
|
|
|
|
|
default=None,
|
|
|
|
|
description="Internal notes for operators.",
|
|
|
|
|
examples=["Primary operator for board triage."],
|
|
|
|
|
)
|
|
|
|
|
context: str | None = Field(
|
|
|
|
|
default=None,
|
|
|
|
|
description="Additional context used by the system for personalization.",
|
|
|
|
|
examples=["Handles incident coordination and escalation."],
|
|
|
|
|
)
|
2026-02-04 02:28:51 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
class UserCreate(UserBase):
|
2026-02-09 15:49:50 +05:30
|
|
|
"""Payload used to create a user record."""
|
2026-02-04 02:28:51 +05:30
|
|
|
|
|
|
|
|
|
2026-02-04 20:21:33 +05:30
|
|
|
class UserUpdate(SQLModel):
|
2026-02-09 15:49:50 +05:30
|
|
|
"""Payload for partial user profile updates."""
|
|
|
|
|
|
2026-02-04 20:21:33 +05:30
|
|
|
name: str | None = None
|
|
|
|
|
preferred_name: str | None = None
|
|
|
|
|
pronouns: str | None = None
|
|
|
|
|
timezone: str | None = None
|
|
|
|
|
notes: str | None = None
|
|
|
|
|
context: str | None = None
|
|
|
|
|
|
|
|
|
|
|
2026-02-04 02:28:51 +05:30
|
|
|
class UserRead(UserBase):
|
2026-02-09 15:49:50 +05:30
|
|
|
"""Full user payload returned by API responses."""
|
|
|
|
|
|
2026-02-15 02:35:31 +05:30
|
|
|
id: UUID = Field(
|
|
|
|
|
description="Internal user UUID.",
|
|
|
|
|
examples=["11111111-1111-1111-1111-111111111111"],
|
|
|
|
|
)
|
|
|
|
|
is_super_admin: bool = Field(
|
|
|
|
|
description="Whether this user has tenant-wide super-admin privileges.",
|
|
|
|
|
examples=[False],
|
|
|
|
|
)
|