From 06f8176e23f0176028a0b54e3995d8db6881142a Mon Sep 17 00:00:00 2001 From: hisatri Date: Tue, 6 Jan 2026 23:49:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BE=9B=E5=9F=BA=E6=9C=AC=E5=89=8D?= =?UTF-8?q?=E5=90=8E=E7=AB=AF=E9=AA=A8=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 8 +- .python-version | 1 + README.md | 118 + app.py | 0 app/__init__.py | 6 + app/api/__init__.py | 2 + app/api/deps.py | 108 + app/api/v1/__init__.py | 2 + app/api/v1/endpoints/__init__.py | 2 + app/api/v1/endpoints/admin/__init__.py | 6 + app/api/v1/endpoints/admin/redeem_codes.py | 613 ++ app/api/v1/endpoints/auth.py | 191 + app/api/v1/endpoints/balance.py | 270 + app/api/v1/endpoints/oauth2.py | 157 + app/api/v1/endpoints/users.py | 103 + app/api/v1/router.py | 45 + app/core/__init__.py | 29 + app/core/config.py | 202 + app/core/config_loader.py | 387 + app/core/exceptions.py | 224 + app/core/security.py | 155 + app/database.py | 100 + app/main.py | 268 + app/models/__init__.py | 28 + app/models/balance.py | 320 + app/models/redeem_code.py | 409 ++ app/models/user.py | 141 + app/repositories/__init__.py | 19 + app/repositories/balance.py | 378 + app/repositories/base.py | 138 + app/repositories/redeem_code.py | 462 ++ app/repositories/user.py | 141 + app/schemas/__init__.py | 75 + app/schemas/auth.py | 112 + app/schemas/balance.py | 285 + app/schemas/base.py | 102 + app/schemas/oauth2.py | 85 + app/schemas/redeem_code.py | 346 + app/schemas/user.py | 156 + app/services/__init__.py | 16 + app/services/auth.py | 296 + app/services/balance.py | 934 +++ app/services/oauth2.py | 395 ++ app/services/redeem_code.py | 570 ++ app/services/user.py | 175 + config.yaml.example | 68 + data/data.db | Bin 0 -> 28672 bytes docs/architecture.md | 303 + docs/auth-api.md | 704 ++ frontend/.gitignore | 41 + frontend/README.md | 137 + frontend/next.config.ts | 36 + frontend/package-lock.json | 6244 +++++++++++++++++ frontend/package.json | 36 + frontend/postcss.config.mjs | 10 + frontend/public/favicon.svg | 13 + frontend/src/app/dashboard/layout.tsx | 37 + frontend/src/app/dashboard/page.tsx | 152 + frontend/src/app/dashboard/profile/page.tsx | 195 + frontend/src/app/dashboard/settings/page.tsx | 181 + frontend/src/app/globals.css | 256 + frontend/src/app/layout.tsx | 32 + frontend/src/app/login/page.tsx | 40 + frontend/src/app/not-found.tsx | 57 + frontend/src/app/oauth2/callback/page.tsx | 158 + frontend/src/app/page.tsx | 28 + frontend/src/app/register/page.tsx | 40 + frontend/src/components/auth/AuthLayout.tsx | 126 + frontend/src/components/auth/LoginForm.tsx | 131 + frontend/src/components/auth/RegisterForm.tsx | 118 + frontend/src/components/auth/index.ts | 4 + .../components/dashboard/DashboardLayout.tsx | 233 + frontend/src/components/dashboard/index.ts | 2 + frontend/src/components/ui/Alert.tsx | 96 + frontend/src/components/ui/Avatar.tsx | 59 + frontend/src/components/ui/Button.tsx | 105 + frontend/src/components/ui/Card.tsx | 109 + frontend/src/components/ui/Input.tsx | 118 + frontend/src/components/ui/Logo.tsx | 83 + frontend/src/components/ui/Spinner.tsx | 38 + frontend/src/components/ui/index.ts | 8 + frontend/src/lib/api.ts | 255 + frontend/src/lib/store.ts | 146 + frontend/src/lib/utils.ts | 45 + frontend/src/lib/validations.ts | 85 + frontend/tailwind.config.ts | 96 + frontend/tsconfig.json | 28 + main.py | 24 + pyproject.toml | 38 + 89 files changed, 19293 insertions(+), 2 deletions(-) create mode 100644 .python-version create mode 100644 app.py create mode 100644 app/__init__.py create mode 100644 app/api/__init__.py create mode 100644 app/api/deps.py create mode 100644 app/api/v1/__init__.py create mode 100644 app/api/v1/endpoints/__init__.py create mode 100644 app/api/v1/endpoints/admin/__init__.py create mode 100644 app/api/v1/endpoints/admin/redeem_codes.py create mode 100644 app/api/v1/endpoints/auth.py create mode 100644 app/api/v1/endpoints/balance.py create mode 100644 app/api/v1/endpoints/oauth2.py create mode 100644 app/api/v1/endpoints/users.py create mode 100644 app/api/v1/router.py create mode 100644 app/core/__init__.py create mode 100644 app/core/config.py create mode 100644 app/core/config_loader.py create mode 100644 app/core/exceptions.py create mode 100644 app/core/security.py create mode 100644 app/database.py create mode 100644 app/main.py create mode 100644 app/models/__init__.py create mode 100644 app/models/balance.py create mode 100644 app/models/redeem_code.py create mode 100644 app/models/user.py create mode 100644 app/repositories/__init__.py create mode 100644 app/repositories/balance.py create mode 100644 app/repositories/base.py create mode 100644 app/repositories/redeem_code.py create mode 100644 app/repositories/user.py create mode 100644 app/schemas/__init__.py create mode 100644 app/schemas/auth.py create mode 100644 app/schemas/balance.py create mode 100644 app/schemas/base.py create mode 100644 app/schemas/oauth2.py create mode 100644 app/schemas/redeem_code.py create mode 100644 app/schemas/user.py create mode 100644 app/services/__init__.py create mode 100644 app/services/auth.py create mode 100644 app/services/balance.py create mode 100644 app/services/oauth2.py create mode 100644 app/services/redeem_code.py create mode 100644 app/services/user.py create mode 100644 config.yaml.example create mode 100644 data/data.db create mode 100644 docs/architecture.md create mode 100644 docs/auth-api.md create mode 100644 frontend/.gitignore create mode 100644 frontend/README.md create mode 100644 frontend/next.config.ts create mode 100644 frontend/package-lock.json create mode 100644 frontend/package.json create mode 100644 frontend/postcss.config.mjs create mode 100644 frontend/public/favicon.svg create mode 100644 frontend/src/app/dashboard/layout.tsx create mode 100644 frontend/src/app/dashboard/page.tsx create mode 100644 frontend/src/app/dashboard/profile/page.tsx create mode 100644 frontend/src/app/dashboard/settings/page.tsx create mode 100644 frontend/src/app/globals.css create mode 100644 frontend/src/app/layout.tsx create mode 100644 frontend/src/app/login/page.tsx create mode 100644 frontend/src/app/not-found.tsx create mode 100644 frontend/src/app/oauth2/callback/page.tsx create mode 100644 frontend/src/app/page.tsx create mode 100644 frontend/src/app/register/page.tsx create mode 100644 frontend/src/components/auth/AuthLayout.tsx create mode 100644 frontend/src/components/auth/LoginForm.tsx create mode 100644 frontend/src/components/auth/RegisterForm.tsx create mode 100644 frontend/src/components/auth/index.ts create mode 100644 frontend/src/components/dashboard/DashboardLayout.tsx create mode 100644 frontend/src/components/dashboard/index.ts create mode 100644 frontend/src/components/ui/Alert.tsx create mode 100644 frontend/src/components/ui/Avatar.tsx create mode 100644 frontend/src/components/ui/Button.tsx create mode 100644 frontend/src/components/ui/Card.tsx create mode 100644 frontend/src/components/ui/Input.tsx create mode 100644 frontend/src/components/ui/Logo.tsx create mode 100644 frontend/src/components/ui/Spinner.tsx create mode 100644 frontend/src/components/ui/index.ts create mode 100644 frontend/src/lib/api.ts create mode 100644 frontend/src/lib/store.ts create mode 100644 frontend/src/lib/utils.ts create mode 100644 frontend/src/lib/validations.ts create mode 100644 frontend/tailwind.config.ts create mode 100644 frontend/tsconfig.json create mode 100644 main.py create mode 100644 pyproject.toml diff --git a/.gitignore b/.gitignore index d7817cb..9c0af22 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,7 @@ dist/ downloads/ eggs/ .eggs/ -lib/ +/lib/ lib64/ parts/ sdist/ @@ -99,7 +99,7 @@ ipython_config.py # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control. # This is especially recommended for binary packages to ensure reproducibility, and is more # commonly ignored for libraries. -#uv.lock +uv.lock # poetry # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. @@ -137,6 +137,10 @@ ENV/ env.bak/ venv.bak/ +# Application config (contains secrets) +config.yaml +config.yml + # Spyder project settings .spyderproject .spyproject diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..e4fba21 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.12 diff --git a/README.md b/README.md index 95cafc3..23a0ab8 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,120 @@ # SatoNano +云服务综合管理平台 + +## 功能特性 + +- ✅ 用户注册、登录、退出 +- ✅ JWT 令牌认证(Access + Refresh Token) +- ✅ 密码修改 +- ✅ 用户信息管理 +- 🔜 邀请码注册 +- 🔜 OAuth2 第三方登录 + +## 技术栈 + +- **Web 框架**: FastAPI +- **ORM**: SQLAlchemy 2.0 (异步) +- **密码哈希**: Argon2 +- **认证**: JWT (PyJWT) +- **数据验证**: Pydantic v2 + +## 快速开始 + +### 环境要求 + +- Python 3.12+ +- [uv](https://github.com/astral-sh/uv) (推荐) + +### 安装 + +```bash +# 克隆项目 +git clone +cd SatoNano + +# 安装依赖 +uv sync + +# 配置环境变量(可选) +cp .env.example .env +# 编辑 .env 文件设置 SECRET_KEY 等配置 +``` + +### 启动服务 + +```bash +# 开发模式(自动重载) +uv run python main.py + +# 或使用 uvicorn +uv run uvicorn app.main:app --reload --host 0.0.0.0 --port 8000 +``` + +### 访问 API + +- API 文档: http://localhost:8000/docs +- ReDoc 文档: http://localhost:8000/redoc +- 健康检查: http://localhost:8000/health + +## API 接口 + +| 接口 | 方法 | 描述 | +|------|------|------| +| `/api/v1/auth/register` | POST | 用户注册 | +| `/api/v1/auth/login` | POST | 用户登录 | +| `/api/v1/auth/logout` | POST | 用户退出 | +| `/api/v1/auth/refresh` | POST | 刷新令牌 | +| `/api/v1/auth/change-password` | POST | 修改密码 | +| `/api/v1/users/me` | GET | 获取当前用户 | +| `/api/v1/users/me` | PATCH | 更新用户信息 | + +详细文档请查看 [docs/auth-api.md](docs/auth-api.md) + +## 项目结构 + +``` +app/ +├── api/ # API 路由层 +├── core/ # 核心功能(配置、安全、异常) +├── models/ # 数据库模型 +├── repositories/ # 数据访问层 +├── schemas/ # 数据验证模式 +├── services/ # 业务逻辑层 +├── database.py # 数据库连接 +└── main.py # 应用入口 +``` + +详细架构说明请查看 [docs/architecture.md](docs/architecture.md) + +## 开发 + +```bash +# 安装开发依赖 +uv sync --dev + +# 代码格式化 +uv run ruff format . + +# 代码检查 +uv run ruff check . + +# 运行测试 +uv run pytest +``` + +## 配置说明 + +支持通过环境变量或 `.env` 文件配置: + +| 变量 | 默认值 | 说明 | +|------|--------|------| +| `SECRET_KEY` | - | JWT 签名密钥(生产必改) | +| `DEBUG` | false | 调试模式 | +| `DATABASE_URL` | sqlite+aiosqlite:///./satonano.db | 数据库连接 | +| `ACCESS_TOKEN_EXPIRE_MINUTES` | 30 | 访问令牌有效期 | +| `REFRESH_TOKEN_EXPIRE_DAYS` | 7 | 刷新令牌有效期 | + +## License + +MIT diff --git a/app.py b/app.py new file mode 100644 index 0000000..e69de29 diff --git a/app/__init__.py b/app/__init__.py new file mode 100644 index 0000000..3df3157 --- /dev/null +++ b/app/__init__.py @@ -0,0 +1,6 @@ +""" +SatoNano - 现代化用户认证系统 +""" + +__version__ = "0.1.0" + diff --git a/app/api/__init__.py b/app/api/__init__.py new file mode 100644 index 0000000..f4a1a37 --- /dev/null +++ b/app/api/__init__.py @@ -0,0 +1,2 @@ +"""API 模块""" + diff --git a/app/api/deps.py b/app/api/deps.py new file mode 100644 index 0000000..071dac2 --- /dev/null +++ b/app/api/deps.py @@ -0,0 +1,108 @@ +""" +API 依赖注入 + +定义 FastAPI 依赖项。 +""" + +from typing import Annotated + +from fastapi import Depends, HTTPException, status +from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer +from sqlalchemy.ext.asyncio import AsyncSession + +from app.core.exceptions import ( + TokenError, + UserDisabledError, +) +from app.database import get_db +from app.models.user import User +from app.services.auth import AuthService + +# HTTP Bearer 认证方案 +security = HTTPBearer(auto_error=False) + + +async def get_auth_service( + session: Annotated[AsyncSession, Depends(get_db)], +) -> AuthService: + """获取认证服务实例""" + return AuthService(session) + + +async def get_current_user( + credentials: Annotated[ + HTTPAuthorizationCredentials | None, + Depends(security), + ], + auth_service: Annotated[AuthService, Depends(get_auth_service)], +) -> User: + """ + 获取当前认证用户 + + 从请求头的 Bearer Token 中解析用户信息。 + + Raises: + HTTPException 401: 未认证 + HTTPException 403: 用户被禁用 + """ + if not credentials: + raise HTTPException( + status_code=status.HTTP_401_UNAUTHORIZED, + detail="未提供认证信息", + headers={"WWW-Authenticate": "Bearer"}, + ) + + try: + user = await auth_service.get_current_user(credentials.credentials) + return user + except TokenError as e: + raise HTTPException( + status_code=status.HTTP_401_UNAUTHORIZED, + detail=e.message, + headers={"WWW-Authenticate": "Bearer"}, + ) + except UserDisabledError as e: + raise HTTPException( + status_code=status.HTTP_403_FORBIDDEN, + detail=e.message, + ) + + +async def get_current_active_user( + current_user: Annotated[User, Depends(get_current_user)], +) -> User: + """ + 获取当前活跃用户 + + 确保用户处于激活状态。 + """ + if not current_user.is_active: + raise HTTPException( + status_code=status.HTTP_403_FORBIDDEN, + detail="账户已被禁用", + ) + return current_user + + +async def get_current_superuser( + current_user: Annotated[User, Depends(get_current_active_user)], +) -> User: + """ + 获取当前超级管理员 + + 确保用户具有超级管理员权限。 + """ + if not current_user.is_superuser: + raise HTTPException( + status_code=status.HTTP_403_FORBIDDEN, + detail="需要管理员权限", + ) + return current_user + + +# 类型别名,简化依赖注入声明 +DbSession = Annotated[AsyncSession, Depends(get_db)] +CurrentUser = Annotated[User, Depends(get_current_user)] +ActiveUser = Annotated[User, Depends(get_current_active_user)] +SuperUser = Annotated[User, Depends(get_current_superuser)] + diff --git a/app/api/v1/__init__.py b/app/api/v1/__init__.py new file mode 100644 index 0000000..40b6a20 --- /dev/null +++ b/app/api/v1/__init__.py @@ -0,0 +1,2 @@ +"""API v1 模块""" + diff --git a/app/api/v1/endpoints/__init__.py b/app/api/v1/endpoints/__init__.py new file mode 100644 index 0000000..32499d2 --- /dev/null +++ b/app/api/v1/endpoints/__init__.py @@ -0,0 +1,2 @@ +"""API v1 端点""" + diff --git a/app/api/v1/endpoints/admin/__init__.py b/app/api/v1/endpoints/admin/__init__.py new file mode 100644 index 0000000..33d9354 --- /dev/null +++ b/app/api/v1/endpoints/admin/__init__.py @@ -0,0 +1,6 @@ +"""管理员 API 端点""" + +from app.api.v1.endpoints.admin import redeem_codes + +__all__ = ["redeem_codes"] + diff --git a/app/api/v1/endpoints/admin/redeem_codes.py b/app/api/v1/endpoints/admin/redeem_codes.py new file mode 100644 index 0000000..f180ef2 --- /dev/null +++ b/app/api/v1/endpoints/admin/redeem_codes.py @@ -0,0 +1,613 @@ +""" +管理员 - 兑换码管理 API + +包括批量生成、导入导出、查询使用日志等接口。 +""" + +from datetime import datetime + +from fastapi import APIRouter, HTTPException, Query, status +from fastapi.responses import JSONResponse + +from app.api.deps import SuperUser, DbSession +from app.core.exceptions import ResourceNotFoundError, ValidationError +from app.schemas.base import APIResponse, PaginatedResponse +from app.schemas.balance import ( + AdminAdjustmentRequest, + AdminBalanceResponse, + format_display, +) +from app.schemas.redeem_code import ( + BatchCreateRequest, + BatchResponse, + BatchDetailResponse, + BatchListResponse, + RedeemCodeDetailResponse, + RedeemCodeListResponse, + BulkImportRequest, + BulkImportResponse, + ExportResponse, + ExportCodeItem, + UsageLogResponse, + UsageLogListResponse, +) +from app.services.balance import BalanceService, InsufficientBalanceError +from app.services.redeem_code import RedeemCodeService +from app.models.redeem_code import RedeemCodeStatus + +router = APIRouter() + + +# ============================================================ +# 批次管理 +# ============================================================ + +@router.post( + "/batches", + response_model=APIResponse[BatchResponse], + summary="创建兑换码批次", + description="批量生成指定数量的兑换码", +) +async def create_batch( + request: BatchCreateRequest, + current_user: SuperUser, + session: DbSession, +) -> APIResponse[BatchResponse]: + """ + 创建兑换码批次 + + 批量生成指定数量的兑换码。 + + - **name**: 批次名称 + - **face_value**: 面值(如 10.00) + - **count**: 生成数量(最大 10000) + - **max_uses**: 每个兑换码最大使用次数 + - **expires_at**: 过期时间(可选) + """ + redeem_service = RedeemCodeService(session) + + try: + batch = await redeem_service.create_batch( + name=request.name, + face_value_units=request.face_value_units, + count=request.count, + created_by=current_user.id, + description=request.description, + max_uses=request.max_uses, + expires_at=request.expires_at, + ) + + return APIResponse.ok( + data=BatchResponse( + id=batch.id, + name=batch.name, + description=batch.description, + face_value_units=batch.face_value, + total_count=batch.total_count, + used_count=batch.used_count, + created_by=batch.created_by, + created_at=batch.created_at, + ), + message=f"成功创建批次,生成 {request.count} 个兑换码", + ) + + except ValidationError as e: + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail=e.message, + ) + + +@router.get( + "/batches", + response_model=APIResponse[BatchListResponse], + summary="获取批次列表", + description="获取所有兑换码批次", +) +async def get_batches( + current_user: SuperUser, + session: DbSession, + page: int = Query(1, ge=1), + page_size: int = Query(20, ge=1, le=100), +) -> APIResponse[BatchListResponse]: + """获取批次列表""" + redeem_service = RedeemCodeService(session) + offset = (page - 1) * page_size + + batches, total = await redeem_service.get_batches( + offset=offset, + limit=page_size, + ) + + items = [ + BatchResponse( + id=b.id, + name=b.name, + description=b.description, + face_value_units=b.face_value, + total_count=b.total_count, + used_count=b.used_count, + created_by=b.created_by, + created_at=b.created_at, + ) + for b in batches + ] + + return APIResponse.ok( + data=BatchListResponse.create( + items=items, + total=total, + page=page, + page_size=page_size, + ), + ) + + +@router.get( + "/batches/{batch_id}", + response_model=APIResponse[BatchDetailResponse], + summary="获取批次详情", + description="获取指定批次的详细信息", +) +async def get_batch_detail( + batch_id: str, + current_user: SuperUser, + session: DbSession, +) -> APIResponse[BatchDetailResponse]: + """获取批次详情""" + redeem_service = RedeemCodeService(session) + + try: + batch = await redeem_service.get_batch_detail(batch_id) + + return APIResponse.ok( + data=BatchDetailResponse( + id=batch.id, + name=batch.name, + description=batch.description, + face_value_units=batch.face_value, + total_count=batch.total_count, + used_count=batch.used_count, + created_by=batch.created_by, + created_at=batch.created_at, + ), + ) + + except ResourceNotFoundError as e: + raise HTTPException( + status_code=status.HTTP_404_NOT_FOUND, + detail=e.message, + ) + + +# ============================================================ +# 兑换码管理 +# ============================================================ + +@router.get( + "/codes", + response_model=APIResponse[RedeemCodeListResponse], + summary="获取兑换码列表", + description="获取所有兑换码,支持多种过滤条件", +) +async def get_codes( + current_user: SuperUser, + session: DbSession, + page: int = Query(1, ge=1), + page_size: int = Query(20, ge=1, le=100), + status_filter: RedeemCodeStatus | None = Query(None, alias="status"), + batch_id: str | None = Query(None), + code: str | None = Query(None, description="兑换码模糊搜索"), + created_after: datetime | None = Query(None), + created_before: datetime | None = Query(None), +) -> APIResponse[RedeemCodeListResponse]: + """ + 获取兑换码列表 + + 支持过滤: + - **status**: 状态(active/used/disabled/expired) + - **batch_id**: 批次 ID + - **code**: 兑换码模糊搜索 + - **created_after/created_before**: 创建时间范围 + """ + redeem_service = RedeemCodeService(session) + offset = (page - 1) * page_size + + codes, total = await redeem_service.get_codes( + offset=offset, + limit=page_size, + status=status_filter, + batch_id=batch_id, + code_like=code, + created_after=created_after, + created_before=created_before, + ) + + items = [ + RedeemCodeDetailResponse( + id=c.id, + code=c.code, + face_value_units=c.face_value, + status=c.status, + max_uses=c.max_uses, + used_count=c.used_count, + expires_at=c.expires_at, + used_at=c.used_at, + created_at=c.created_at, + batch_id=c.batch_id, + batch_name=c.batch.name if c.batch else None, + remark=c.remark, + created_by=c.created_by, + used_by=c.used_by, + ) + for c in codes + ] + + return APIResponse.ok( + data=RedeemCodeListResponse.create( + items=items, + total=total, + page=page, + page_size=page_size, + ), + ) + + +@router.get( + "/codes/{code_id}", + response_model=APIResponse[RedeemCodeDetailResponse], + summary="获取兑换码详情", +) +async def get_code_detail( + code_id: str, + current_user: SuperUser, + session: DbSession, +) -> APIResponse[RedeemCodeDetailResponse]: + """获取兑换码详情""" + redeem_service = RedeemCodeService(session) + + try: + code = await redeem_service.get_code_detail(code_id) + + return APIResponse.ok( + data=RedeemCodeDetailResponse( + id=code.id, + code=code.code, + face_value_units=code.face_value, + status=code.status, + max_uses=code.max_uses, + used_count=code.used_count, + expires_at=code.expires_at, + used_at=code.used_at, + created_at=code.created_at, + batch_id=code.batch_id, + batch_name=code.batch.name if code.batch else None, + remark=code.remark, + created_by=code.created_by, + used_by=code.used_by, + ), + ) + + except ResourceNotFoundError as e: + raise HTTPException( + status_code=status.HTTP_404_NOT_FOUND, + detail=e.message, + ) + + +@router.post( + "/codes/{code_id}/disable", + response_model=APIResponse[RedeemCodeDetailResponse], + summary="禁用兑换码", +) +async def disable_code( + code_id: str, + current_user: SuperUser, + session: DbSession, +) -> APIResponse[RedeemCodeDetailResponse]: + """禁用指定兑换码""" + redeem_service = RedeemCodeService(session) + + try: + code = await redeem_service.disable_code(code_id) + + return APIResponse.ok( + data=RedeemCodeDetailResponse( + id=code.id, + code=code.code, + face_value_units=code.face_value, + status=code.status, + max_uses=code.max_uses, + used_count=code.used_count, + expires_at=code.expires_at, + used_at=code.used_at, + created_at=code.created_at, + batch_id=code.batch_id, + remark=code.remark, + created_by=code.created_by, + used_by=code.used_by, + ), + message="兑换码已禁用", + ) + + except ResourceNotFoundError as e: + raise HTTPException( + status_code=status.HTTP_404_NOT_FOUND, + detail=e.message, + ) + + +@router.post( + "/codes/{code_id}/enable", + response_model=APIResponse[RedeemCodeDetailResponse], + summary="启用兑换码", +) +async def enable_code( + code_id: str, + current_user: SuperUser, + session: DbSession, +) -> APIResponse[RedeemCodeDetailResponse]: + """重新启用指定兑换码""" + redeem_service = RedeemCodeService(session) + + try: + code = await redeem_service.enable_code(code_id) + + return APIResponse.ok( + data=RedeemCodeDetailResponse( + id=code.id, + code=code.code, + face_value_units=code.face_value, + status=code.status, + max_uses=code.max_uses, + used_count=code.used_count, + expires_at=code.expires_at, + used_at=code.used_at, + created_at=code.created_at, + batch_id=code.batch_id, + remark=code.remark, + created_by=code.created_by, + used_by=code.used_by, + ), + message="兑换码已启用", + ) + + except ResourceNotFoundError as e: + raise HTTPException( + status_code=status.HTTP_404_NOT_FOUND, + detail=e.message, + ) + + +# ============================================================ +# 导入导出 +# ============================================================ + +@router.post( + "/codes/import", + response_model=APIResponse[BulkImportResponse], + summary="批量导入兑换码", + description="批量导入自定义兑换码", +) +async def import_codes( + request: BulkImportRequest, + current_user: SuperUser, + session: DbSession, +) -> APIResponse[BulkImportResponse]: + """ + 批量导入兑换码 + + 可以导入自定义格式的兑换码。 + + - **codes**: 兑换码列表 + - **batch_name**: 批次名称(可选) + """ + redeem_service = RedeemCodeService(session) + + # 转换请求数据 + codes_data = [ + { + "code": c.code, + "face_value_units": c.face_value_units, + "max_uses": c.max_uses, + "expires_at": c.expires_at, + "remark": c.remark, + } + for c in request.codes + ] + + result = await redeem_service.import_codes( + codes_data, + created_by=current_user.id, + batch_name=request.batch_name, + ) + + return APIResponse.ok( + data=BulkImportResponse( + success_count=result["success_count"], + failed_count=result["failed_count"], + failed_codes=result["failed_codes"], + batch_id=result["batch_id"], + ), + message=f"导入完成:成功 {result['success_count']},失败 {result['failed_count']}", + ) + + +@router.get( + "/codes/export", + response_model=APIResponse[ExportResponse], + summary="导出兑换码", + description="导出兑换码数据", +) +async def export_codes( + current_user: SuperUser, + session: DbSession, + batch_id: str | None = Query(None), + status_filter: RedeemCodeStatus | None = Query(None, alias="status"), + limit: int = Query(10000, ge=1, le=50000), +) -> APIResponse[ExportResponse]: + """ + 导出兑换码 + + 支持按批次或状态过滤。 + """ + redeem_service = RedeemCodeService(session) + + codes = await redeem_service.export_codes( + batch_id=batch_id, + status=status_filter, + limit=limit, + ) + + items = [ + ExportCodeItem( + code=c["code"], + face_value=c["face_value"], + status=c["status"], + max_uses=c["max_uses"], + used_count=c["used_count"], + expires_at=c["expires_at"], + created_at=c["created_at"], + used_at=c["used_at"], + used_by=c["used_by"], + ) + for c in codes + ] + + return APIResponse.ok( + data=ExportResponse( + total=len(items), + codes=items, + ), + ) + + +# ============================================================ +# 使用日志 +# ============================================================ + +@router.get( + "/usage-logs", + response_model=APIResponse[UsageLogListResponse], + summary="获取使用日志", + description="查询兑换码使用记录", +) +async def get_usage_logs( + current_user: SuperUser, + session: DbSession, + page: int = Query(1, ge=1), + page_size: int = Query(20, ge=1, le=100), + redeem_code_id: str | None = Query(None), + user_id: str | None = Query(None), + code: str | None = Query(None, description="兑换码模糊搜索"), + created_after: datetime | None = Query(None), + created_before: datetime | None = Query(None), +) -> APIResponse[UsageLogListResponse]: + """ + 获取使用日志 + + 支持过滤: + - **redeem_code_id**: 兑换码 ID + - **user_id**: 用户 ID + - **code**: 兑换码模糊搜索 + - **created_after/created_before**: 使用时间范围 + """ + redeem_service = RedeemCodeService(session) + offset = (page - 1) * page_size + + logs, total = await redeem_service.get_usage_logs( + offset=offset, + limit=page_size, + redeem_code_id=redeem_code_id, + user_id=user_id, + code_like=code, + created_after=created_after, + created_before=created_before, + ) + + items = [ + UsageLogResponse( + id=log.id, + redeem_code_id=log.redeem_code_id, + code_snapshot=log.code_snapshot, + user_id=log.user_id, + username=log.user.username if log.user else None, + face_value=format_display(log.face_value), + ip_address=log.ip_address, + created_at=log.created_at, + ) + for log in logs + ] + + return APIResponse.ok( + data=UsageLogListResponse.create( + items=items, + total=total, + page=page, + page_size=page_size, + ), + ) + + +# ============================================================ +# 余额管理 +# ============================================================ + +@router.post( + "/balance/adjust", + response_model=APIResponse[AdminBalanceResponse], + summary="调整用户余额", + description="管理员手动调整用户余额", +) +async def adjust_balance( + request: AdminAdjustmentRequest, + current_user: SuperUser, + session: DbSession, +) -> APIResponse[AdminBalanceResponse]: + """ + 调整用户余额 + + - **user_id**: 目标用户 ID + - **amount**: 调整金额(正数增加,负数减少) + - **reason**: 调整原因 + """ + balance_service = BalanceService(session) + + try: + transaction = await balance_service.admin_adjust( + request.user_id, + request.amount_units, + operator_id=current_user.id, + reason=request.reason, + ) + + # 获取更新后的余额 + balance = await balance_service.get_balance(request.user_id) + + return APIResponse.ok( + data=AdminBalanceResponse( + user_id=balance.user_id, + username=balance.user.username if balance.user else "", + balance=format_display(balance.balance), + available_balance=format_display(balance.available_balance), + frozen_balance=format_display(balance.frozen_balance), + total_recharged=format_display(balance.total_recharged), + total_consumed=format_display(balance.total_consumed), + version=balance.version, + created_at=balance.created_at, + updated_at=balance.updated_at, + ), + message=f"余额调整成功,变动 {request.amount:+.2f}", + ) + + except InsufficientBalanceError as e: + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail=e.message, + ) + except ValidationError as e: + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail=e.message, + ) + diff --git a/app/api/v1/endpoints/auth.py b/app/api/v1/endpoints/auth.py new file mode 100644 index 0000000..505da68 --- /dev/null +++ b/app/api/v1/endpoints/auth.py @@ -0,0 +1,191 @@ +""" +认证相关 API + +包括注册、登录、退出、刷新令牌、修改密码等接口。 +""" + +from typing import Annotated + +from fastapi import APIRouter, Depends, HTTPException, status +from sqlalchemy.ext.asyncio import AsyncSession + +from app.api.deps import ActiveUser, DbSession, get_auth_service +from app.core.exceptions import ( + InvalidCredentialsError, + PasswordValidationError, + ResourceConflictError, + TokenError, + UserDisabledError, +) +from app.schemas.auth import ( + LoginRequest, + PasswordChangeRequest, + RefreshTokenRequest, + TokenResponse, +) +from app.schemas.base import APIResponse +from app.schemas.user import UserCreate, UserResponse +from app.services.auth import AuthService +from app.services.user import UserService + +router = APIRouter() + + +@router.post( + "/register", + response_model=APIResponse[UserResponse], + status_code=status.HTTP_201_CREATED, + summary="用户注册", + description="创建新用户账户", +) +async def register( + user_data: UserCreate, + session: DbSession, +) -> APIResponse[UserResponse]: + """ + 用户注册接口 + + - **username**: 用户名(字母开头,3-32位) + - **email**: 邮箱(可选) + - **password**: 密码(8位以上,需包含大小写字母和数字) + - **nickname**: 昵称(可选) + """ + user_service = UserService(session) + + try: + user = await user_service.create_user(user_data) + return APIResponse.ok( + data=UserResponse.model_validate(user), + message="注册成功", + ) + except ResourceConflictError as e: + raise HTTPException( + status_code=status.HTTP_409_CONFLICT, + detail=e.message, + ) + + +@router.post( + "/login", + response_model=APIResponse[TokenResponse], + summary="用户登录", + description="使用用户名/邮箱和密码登录", +) +async def login( + login_data: LoginRequest, + auth_service: Annotated[AuthService, Depends(get_auth_service)], +) -> APIResponse[TokenResponse]: + """ + 用户登录接口 + + - **username**: 用户名或邮箱 + - **password**: 密码 + + 返回访问令牌和刷新令牌。 + """ + try: + _, tokens = await auth_service.login( + username=login_data.username, + password=login_data.password, + ) + return APIResponse.ok(data=tokens, message="登录成功") + except InvalidCredentialsError as e: + raise HTTPException( + status_code=status.HTTP_401_UNAUTHORIZED, + detail=e.message, + headers={"WWW-Authenticate": "Bearer"}, + ) + except UserDisabledError as e: + raise HTTPException( + status_code=status.HTTP_403_FORBIDDEN, + detail=e.message, + ) + + +@router.post( + "/logout", + response_model=APIResponse[None], + summary="用户退出", + description="退出登录(客户端应删除本地令牌)", +) +async def logout( + current_user: ActiveUser, +) -> APIResponse[None]: + """ + 用户退出接口 + + 由于使用的是无状态 JWT,服务端不存储令牌, + 因此退出登录主要由客户端删除本地存储的令牌实现。 + + 如果需要实现令牌黑名单,可以在后续版本中添加。 + """ + # 可以在这里添加令牌黑名单逻辑 + # 或者记录退出日志 + return APIResponse.ok(message="退出成功") + + +@router.post( + "/refresh", + response_model=APIResponse[TokenResponse], + summary="刷新令牌", + description="使用刷新令牌获取新的访问令牌", +) +async def refresh_token( + token_data: RefreshTokenRequest, + auth_service: Annotated[AuthService, Depends(get_auth_service)], +) -> APIResponse[TokenResponse]: + """ + 刷新令牌接口 + + 使用刷新令牌获取新的访问令牌和刷新令牌。 + """ + try: + tokens = await auth_service.refresh_tokens(token_data.refresh_token) + return APIResponse.ok(data=tokens, message="刷新成功") + except TokenError as e: + raise HTTPException( + status_code=status.HTTP_401_UNAUTHORIZED, + detail=e.message, + headers={"WWW-Authenticate": "Bearer"}, + ) + except UserDisabledError as e: + raise HTTPException( + status_code=status.HTTP_403_FORBIDDEN, + detail=e.message, + ) + + +@router.post( + "/change-password", + response_model=APIResponse[None], + summary="修改密码", + description="修改当前用户密码", +) +async def change_password( + password_data: PasswordChangeRequest, + current_user: ActiveUser, + auth_service: Annotated[AuthService, Depends(get_auth_service)], +) -> APIResponse[None]: + """ + 修改密码接口 + + - **current_password**: 当前密码 + - **new_password**: 新密码 + """ + try: + await auth_service.change_password( + user_id=current_user.id, + password_data=password_data, + ) + return APIResponse.ok(message="密码修改成功") + except InvalidCredentialsError as e: + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail=e.message, + ) + except PasswordValidationError as e: + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail=e.message, + ) + diff --git a/app/api/v1/endpoints/balance.py b/app/api/v1/endpoints/balance.py new file mode 100644 index 0000000..04e3f6e --- /dev/null +++ b/app/api/v1/endpoints/balance.py @@ -0,0 +1,270 @@ +""" +余额相关 API + +包括余额查询、交易记录、兑换等接口。 +""" + +from fastapi import APIRouter, HTTPException, Query, Request, status + +from app.api.deps import ActiveUser, DbSession +from app.core.exceptions import AppException, ValidationError +from app.schemas.base import APIResponse, PaginatedResponse +from app.schemas.balance import ( + BalanceResponse, + TransactionResponse, + DeductionRequest, + DeductionResponse, + UNITS_PER_DISPLAY, + format_display, +) +from app.schemas.redeem_code import RedeemRequest, RedeemResponse +from app.services.balance import ( + BalanceService, + InsufficientBalanceError, + DuplicateTransactionError, +) +from app.services.redeem_code import ( + RedeemCodeService, + RedeemCodeNotFoundError, + RedeemCodeInvalidError, + RedeemCodeExpiredError, + RedeemCodeUsedError, + RedeemCodeDisabledError, +) +from app.models.balance import TransactionType + +router = APIRouter() + + +# ============================================================ +# 余额查询 +# ============================================================ + +@router.get( + "", + response_model=APIResponse[BalanceResponse], + summary="获取当前用户余额", + description="获取当前登录用户的余额信息", +) +async def get_my_balance( + current_user: ActiveUser, + session: DbSession, +) -> APIResponse[BalanceResponse]: + """ + 获取当前用户余额 + + 返回: + - **balance**: 当前总余额 + - **available_balance**: 可用余额(总余额 - 冻结) + - **frozen_balance**: 冻结余额 + - **total_recharged**: 累计充值 + - **total_consumed**: 累计消费 + """ + balance_service = BalanceService(session) + balance = await balance_service.get_balance(current_user.id) + + return APIResponse.ok( + data=BalanceResponse( + user_id=balance.user_id, + balance_units=balance.balance, + frozen_units=balance.frozen_balance, + total_recharged_units=balance.total_recharged, + total_consumed_units=balance.total_consumed, + ), + ) + + +# ============================================================ +# 交易记录 +# ============================================================ + +@router.get( + "/transactions", + response_model=APIResponse[PaginatedResponse[TransactionResponse]], + summary="获取交易记录", + description="获取当前用户的余额交易记录", +) +async def get_my_transactions( + current_user: ActiveUser, + session: DbSession, + page: int = Query(1, ge=1, description="页码"), + page_size: int = Query(20, ge=1, le=100, description="每页数量"), + transaction_type: TransactionType | None = Query( + None, description="交易类型过滤" + ), +) -> APIResponse[PaginatedResponse[TransactionResponse]]: + """ + 获取交易记录 + + 支持按交易类型过滤: + - **recharge**: 充值 + - **deduction**: 扣款 + - **refund**: 退款 + - **adjustment**: 管理员调整 + """ + balance_service = BalanceService(session) + offset = (page - 1) * page_size + + transactions, total = await balance_service.get_transactions( + current_user.id, + offset=offset, + limit=page_size, + transaction_type=transaction_type, + ) + + items = [ + TransactionResponse( + id=t.id, + transaction_type=t.transaction_type, + status=t.status, + amount_units=t.amount, + balance_before_units=t.balance_before, + balance_after_units=t.balance_after, + reference_type=t.reference_type, + reference_id=t.reference_id, + description=t.description, + created_at=t.created_at, + ) + for t in transactions + ] + + return APIResponse.ok( + data=PaginatedResponse.create( + items=items, + total=total, + page=page, + page_size=page_size, + ), + ) + + +# ============================================================ +# 兑换码兑换 +# ============================================================ + +@router.post( + "/redeem", + response_model=APIResponse[RedeemResponse], + summary="兑换余额", + description="使用兑换码充值余额", +) +async def redeem_code( + request: Request, + redeem_request: RedeemRequest, + current_user: ActiveUser, + session: DbSession, +) -> APIResponse[RedeemResponse]: + """ + 使用兑换码充值余额 + + - **code**: 兑换码(格式如 XXXX-XXXX-XXXX-XXXX) + + 返回兑换结果,包括充值金额和余额变化。 + """ + redeem_service = RedeemCodeService(session) + + # 获取客户端信息 + ip_address = request.client.host if request.client else None + user_agent = request.headers.get("user-agent") + + try: + result = await redeem_service.redeem( + current_user.id, + redeem_request.code, + ip_address=ip_address, + user_agent=user_agent, + ) + + return APIResponse.ok( + data=RedeemResponse( + success=True, + message="兑换成功", + face_value=result["face_value"], + balance_before=result["balance_before"], + balance_after=result["balance_after"], + ), + message="兑换成功", + ) + + except RedeemCodeNotFoundError as e: + raise HTTPException( + status_code=status.HTTP_404_NOT_FOUND, + detail=e.message, + ) + except ( + RedeemCodeInvalidError, + RedeemCodeExpiredError, + RedeemCodeUsedError, + RedeemCodeDisabledError, + ) as e: + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail=e.message, + ) + + +# ============================================================ +# 扣款(内部 API / 服务间调用) +# ============================================================ + +@router.post( + "/deduct", + response_model=APIResponse[DeductionResponse], + summary="扣款", + description="从当前用户余额中扣款(通常由其他服务调用)", + include_in_schema=True, # 可设为 False 隐藏此 API +) +async def deduct_balance( + deduction_request: DeductionRequest, + current_user: ActiveUser, + session: DbSession, +) -> APIResponse[DeductionResponse]: + """ + 扣款 + + 从当前用户余额中扣除指定金额。 + + - **amount**: 扣款金额(如 1.00) + - **reference_type**: 关联业务类型(如 api_call) + - **reference_id**: 关联业务 ID + - **description**: 交易描述 + - **idempotency_key**: 幂等键(防止重复扣款) + """ + balance_service = BalanceService(session) + + try: + transaction = await balance_service.deduct( + current_user.id, + deduction_request.amount_units, + reference_type=deduction_request.reference_type, + reference_id=deduction_request.reference_id, + description=deduction_request.description, + idempotency_key=deduction_request.idempotency_key, + ) + + return APIResponse.ok( + data=DeductionResponse( + transaction_id=transaction.id, + amount=format_display(abs(transaction.amount)), + balance_before=format_display(transaction.balance_before), + balance_after=format_display(transaction.balance_after), + ), + message="扣款成功", + ) + + except InsufficientBalanceError as e: + raise HTTPException( + status_code=status.HTTP_402_PAYMENT_REQUIRED, + detail=e.message, + ) + except DuplicateTransactionError as e: + raise HTTPException( + status_code=status.HTTP_409_CONFLICT, + detail=e.message, + ) + except ValidationError as e: + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail=e.message, + ) + diff --git a/app/api/v1/endpoints/oauth2.py b/app/api/v1/endpoints/oauth2.py new file mode 100644 index 0000000..60ef30b --- /dev/null +++ b/app/api/v1/endpoints/oauth2.py @@ -0,0 +1,157 @@ +""" +OAuth2 认证 API + +提供 OAuth2 第三方登录功能。 +""" + +from typing import Annotated + +from fastapi import APIRouter, Depends, HTTPException, Query, Request, status +from sqlalchemy.ext.asyncio import AsyncSession + +from app.api.deps import DbSession +from app.core.config import settings +from app.core.exceptions import AuthenticationError +from app.schemas.base import APIResponse +from app.schemas.oauth2 import OAuth2AuthorizeResponse, OAuth2LoginResponse +from app.services.oauth2 import OAuth2Service, OAuth2StateError + +router = APIRouter() + + +def get_oauth2_service(session: DbSession) -> OAuth2Service: + """获取 OAuth2 服务实例""" + return OAuth2Service(session) + + +def _get_redirect_uri(request: Request) -> str: + """ + 获取 OAuth2 回调 URL + + 根据请求动态构建完整的回调 URL + """ + # 优先使用 X-Forwarded 头(反向代理场景) + scheme = request.headers.get("X-Forwarded-Proto", request.url.scheme) + host = request.headers.get("X-Forwarded-Host", request.url.netloc) + + return f"{scheme}://{host}{settings.oauth2_callback_path}" + + +@router.get( + "/authorize", + response_model=APIResponse[OAuth2AuthorizeResponse], + summary="获取 OAuth2 授权 URL", + description="获取第三方登录授权页面 URL", +) +async def get_authorize_url( + request: Request, + session: DbSession, +) -> APIResponse[OAuth2AuthorizeResponse]: + """ + 获取 OAuth2 授权 URL + + 返回授权页面 URL 和状态码,客户端应重定向用户到该 URL。 + + 流程: + 1. 前端调用此接口获取授权 URL + 2. 前端将用户重定向到授权 URL + 3. 用户在第三方平台完成授权 + 4. 第三方平台重定向回回调 URL,携带 code 和 state + 5. 前端调用 /callback 接口完成登录 + """ + # 检查 OAuth2 是否已配置 + if not settings.oauth2_client_id or not settings.oauth2_client_secret: + raise HTTPException( + status_code=status.HTTP_503_SERVICE_UNAVAILABLE, + detail="OAuth2 登录未配置", + ) + + oauth2_service = OAuth2Service(session) + redirect_uri = _get_redirect_uri(request) + + authorize_url, state = oauth2_service.generate_authorize_url(redirect_uri) + + return APIResponse.ok( + data=OAuth2AuthorizeResponse( + authorize_url=authorize_url, + state=state, + ), + message="请重定向到授权 URL", + ) + + +@router.get( + "/callback", + response_model=APIResponse[OAuth2LoginResponse], + summary="OAuth2 回调", + description="处理 OAuth2 授权回调,完成登录", +) +async def oauth2_callback( + request: Request, + code: Annotated[str, Query(description="授权码")], + state: Annotated[str, Query(description="状态码")], + session: DbSession, +) -> APIResponse[OAuth2LoginResponse]: + """ + OAuth2 回调接口 + + 处理第三方平台的授权回调: + 1. 验证 state 防止 CSRF 攻击 + 2. 用 code 换取访问令牌 + 3. 获取用户信息 + 4. 创建或关联本地用户 + 5. 返回 JWT 令牌 + """ + oauth2_service = OAuth2Service(session) + redirect_uri = _get_redirect_uri(request) + + try: + user, tokens, is_new_user = await oauth2_service.authenticate( + code=code, + state=state, + redirect_uri=redirect_uri, + ) + + return APIResponse.ok( + data=OAuth2LoginResponse( + access_token=tokens.access_token, + refresh_token=tokens.refresh_token, + token_type=tokens.token_type, + expires_in=tokens.expires_in, + is_new_user=is_new_user, + ), + message="登录成功" if not is_new_user else "注册并登录成功", + ) + + except OAuth2StateError as e: + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail=e.message, + ) + except AuthenticationError as e: + raise HTTPException( + status_code=status.HTTP_401_UNAUTHORIZED, + detail=e.message, + ) + + +@router.post( + "/callback", + response_model=APIResponse[OAuth2LoginResponse], + summary="OAuth2 回调 (POST)", + description="处理 OAuth2 授权回调(POST 方式)", +) +async def oauth2_callback_post( + request: Request, + code: Annotated[str, Query(description="授权码")], + state: Annotated[str, Query(description="状态码")], + session: DbSession, +) -> APIResponse[OAuth2LoginResponse]: + """ + OAuth2 回调接口(POST 方式) + + 某些场景下前端可能使用 POST 方式调用回调。 + 逻辑与 GET 方式相同。 + """ + return await oauth2_callback(request, code, state, session) + diff --git a/app/api/v1/endpoints/users.py b/app/api/v1/endpoints/users.py new file mode 100644 index 0000000..c69035a --- /dev/null +++ b/app/api/v1/endpoints/users.py @@ -0,0 +1,103 @@ +""" +用户相关 API + +包括获取用户信息、更新用户资料等接口。 +""" + +from fastapi import APIRouter, HTTPException, status + +from app.api.deps import ActiveUser, DbSession +from app.core.exceptions import ResourceConflictError, UserNotFoundError +from app.schemas.base import APIResponse +from app.schemas.user import UserResponse, UserUpdate +from app.services.user import UserService + +router = APIRouter() + + +@router.get( + "/me", + response_model=APIResponse[UserResponse], + summary="获取当前用户信息", + description="获取当前登录用户的详细信息", +) +async def get_current_user_info( + current_user: ActiveUser, +) -> APIResponse[UserResponse]: + """ + 获取当前用户信息 + + 返回当前登录用户的完整信息。 + """ + return APIResponse.ok( + data=UserResponse.model_validate(current_user), + ) + + +@router.patch( + "/me", + response_model=APIResponse[UserResponse], + summary="更新当前用户信息", + description="更新当前登录用户的资料", +) +async def update_current_user( + update_data: UserUpdate, + current_user: ActiveUser, + session: DbSession, +) -> APIResponse[UserResponse]: + """ + 更新当前用户信息 + + 支持更新: + - **nickname**: 昵称 + - **email**: 邮箱 + - **avatar_url**: 头像 URL + - **bio**: 个人简介 + """ + user_service = UserService(session) + + try: + user = await user_service.update_user( + user_id=current_user.id, + update_data=update_data, + ) + return APIResponse.ok( + data=UserResponse.model_validate(user), + message="更新成功", + ) + except ResourceConflictError as e: + raise HTTPException( + status_code=status.HTTP_409_CONFLICT, + detail=e.message, + ) + + +@router.get( + "/{user_id}", + response_model=APIResponse[UserResponse], + summary="获取指定用户信息", + description="获取指定用户的公开信息", +) +async def get_user_by_id( + user_id: str, + current_user: ActiveUser, + session: DbSession, +) -> APIResponse[UserResponse]: + """ + 获取指定用户信息 + + - **user_id**: 用户 ID + """ + user_service = UserService(session) + + try: + user = await user_service.get_user_by_id(user_id) + return APIResponse.ok( + data=UserResponse.model_validate(user), + ) + except UserNotFoundError: + raise HTTPException( + status_code=status.HTTP_404_NOT_FOUND, + detail="用户不存在", + ) + diff --git a/app/api/v1/router.py b/app/api/v1/router.py new file mode 100644 index 0000000..680a238 --- /dev/null +++ b/app/api/v1/router.py @@ -0,0 +1,45 @@ +""" +API v1 路由聚合 + +汇总所有 v1 版本的 API 路由。 +""" + +from fastapi import APIRouter + +from app.api.v1.endpoints import auth, oauth2, users, balance +from app.api.v1.endpoints.admin import redeem_codes as admin_redeem_codes + +api_router = APIRouter() + +# 注册子路由 +api_router.include_router( + auth.router, + prefix="/auth", + tags=["认证"], +) + +api_router.include_router( + oauth2.router, + prefix="/auth/oauth2", + tags=["OAuth2 登录"], +) + +api_router.include_router( + users.router, + prefix="/users", + tags=["用户"], +) + +api_router.include_router( + balance.router, + prefix="/balance", + tags=["余额"], +) + +# 管理员路由 +api_router.include_router( + admin_redeem_codes.router, + prefix="/admin/redeem-codes", + tags=["管理员 - 兑换码"], +) + diff --git a/app/core/__init__.py b/app/core/__init__.py new file mode 100644 index 0000000..0c6ccb5 --- /dev/null +++ b/app/core/__init__.py @@ -0,0 +1,29 @@ +"""核心功能模块""" + +from .config import Settings, get_settings, settings +from .config_loader import ( + ConfigLoader, + ConfigSource, + ConfigSourceError, + EnvConfigSource, + YamlConfigSource, + config_loader, + create_config_loader, + get_config_loader, +) + +__all__ = [ + # 配置系统 + "Settings", + "get_settings", + "settings", + # 配置加载器 + "ConfigLoader", + "ConfigSource", + "ConfigSourceError", + "EnvConfigSource", + "YamlConfigSource", + "config_loader", + "create_config_loader", + "get_config_loader", +] diff --git a/app/core/config.py b/app/core/config.py new file mode 100644 index 0000000..2f3884c --- /dev/null +++ b/app/core/config.py @@ -0,0 +1,202 @@ +""" +应用配置管理 + +使用 Pydantic Settings 进行类型安全的配置管理, +集成 ConfigLoader 支持环境变量和 YAML 配置文件。 + +配置优先级(从高到低): +1. 环境变量(前缀 SATONANO_) +2. config.yaml 文件 +3. .env 文件 +4. 默认值 +""" + +from functools import lru_cache +from pathlib import Path +from typing import Any, Literal + +from pydantic import Field, computed_field +from pydantic_settings import BaseSettings, SettingsConfigDict + +from .config_loader import create_config_loader + + +def _yaml_settings_source() -> dict[str, Any]: + """ + YAML 配置源工厂函数 + + 为 Pydantic Settings 提供 YAML 配置数据 + """ + # 查找配置文件路径 + config_paths = [ + Path("config.yaml"), + Path("config.yml"), + Path(__file__).parent.parent.parent / "config.yaml", + Path(__file__).parent.parent.parent / "config.yml", + ] + + yaml_path = None + for path in config_paths: + if path.exists(): + yaml_path = path + break + + if yaml_path is None: + return {} + + # 使用 ConfigLoader 加载配置(不带环境变量前缀,让 pydantic 处理) + loader = create_config_loader( + yaml_path=yaml_path, + env_prefix="", # 不读取环境变量,由 pydantic-settings 处理 + yaml_required=False, + ) + return loader.load() + + +class Settings(BaseSettings): + """应用配置""" + + model_config = SettingsConfigDict( + env_prefix="SATONANO_", + env_file=".env", + env_file_encoding="utf-8", + case_sensitive=False, + extra="ignore", + ) + + # 应用基础配置 + app_name: str = "SatoNano" + app_version: str = "0.1.0" + debug: bool = False + environment: Literal["development", "staging", "production"] = "development" + + # API 配置 + api_v1_prefix: str = "/api/v1" + + # 安全配置 + secret_key: str = Field( + default="CHANGE-THIS-SECRET-KEY-IN-PRODUCTION", + description="JWT 签名密钥,生产环境必须更改", + ) + algorithm: str = "HS256" + access_token_expire_minutes: int = 30 + refresh_token_expire_days: int = 7 + + # 数据库配置 + database_type: Literal["sqlite", "mysql", "postgresql"] = "sqlite" + database_host: str = "localhost" + database_port: int = 3306 + database_name: str = "satonano" + database_username: str = "" + database_password: str = "" + database_sqlite_path: str = "./satonano.db" + database_echo: bool = False + + # OAuth2 配置 (Linux.do) + oauth2_client_id: str = "" + oauth2_client_secret: str = "" + oauth2_callback_path: str = "/oauth2/callback" + # 首选端点 + oauth2_authorize_endpoint: str = "https://connect.linux.do/oauth2/authorize" + oauth2_token_endpoint: str = "https://connect.linux.do/oauth2/token" + oauth2_user_info_endpoint: str = "https://connect.linux.do/api/user" + # 备用端点 + oauth2_authorize_endpoint_reserve: str = "https://connect.linuxdo.org/oauth2/authorize" + oauth2_token_endpoint_reserve: str = "https://connect.linuxdo.org/oauth2/token" + oauth2_user_info_endpoint_reserve: str = "https://connect.linuxdo.org/api/user" + oauth2_request_timeout: int = 10 # 请求超时时间(秒) + + # 密码策略 + password_min_length: int = 8 + password_max_length: int = 128 + password_require_uppercase: bool = True + password_require_lowercase: bool = True + password_require_digit: bool = True + password_require_special: bool = False + + # 用户名策略 + username_min_length: int = 3 + username_max_length: int = 32 + + # 前端静态文件配置 + frontend_static_path: str = "./frontend/out" + + @computed_field + @property + def database_url(self) -> str: + """ + 动态构建数据库连接 URL + + 根据 database_type 自动生成对应的连接字符串 + """ + if self.database_type == "sqlite": + return f"sqlite+aiosqlite:///{self.database_sqlite_path}" + + if self.database_type == "mysql": + return ( + f"mysql+aiomysql://{self.database_username}:{self.database_password}" + f"@{self.database_host}:{self.database_port}/{self.database_name}" + ) + + if self.database_type == "postgresql": + return ( + f"postgresql+asyncpg://{self.database_username}:{self.database_password}" + f"@{self.database_host}:{self.database_port}/{self.database_name}" + ) + + return f"sqlite+aiosqlite:///{self.database_sqlite_path}" + + @computed_field + @property + def is_production(self) -> bool: + """是否为生产环境""" + return self.environment == "production" + + @classmethod + def settings_customise_sources( + cls, + settings_cls: type[BaseSettings], + init_settings: Any, + env_settings: Any, + dotenv_settings: Any, + file_secret_settings: Any, + ) -> tuple[Any, ...]: + """ + 自定义配置源优先级 + + 优先级顺序(从高到低): + 1. 初始化参数 + 2. 环境变量 + 3. YAML 文件 + 4. .env 文件 + 5. 文件密钥 + """ + + class YamlConfigSettingsSource: + """YAML 配置源适配器""" + + def __init__(self, settings_cls: type[BaseSettings]) -> None: + self.settings_cls = settings_cls + self._yaml_data: dict[str, Any] | None = None + + def __call__(self) -> dict[str, Any]: + if self._yaml_data is None: + self._yaml_data = _yaml_settings_source() + return self._yaml_data + + return ( + init_settings, + env_settings, + YamlConfigSettingsSource(settings_cls), + dotenv_settings, + file_secret_settings, + ) + + +@lru_cache +def get_settings() -> Settings: + """获取配置单例""" + return Settings() + + +settings = get_settings() diff --git a/app/core/config_loader.py b/app/core/config_loader.py new file mode 100644 index 0000000..fa9f0f5 --- /dev/null +++ b/app/core/config_loader.py @@ -0,0 +1,387 @@ +""" +配置加载器模块 + +提供统一的配置加载机制,支持多数据源配置合并: +- 环境变量(优先级最高) +- YAML 配置文件 +- 默认值(优先级最低) + +设计原则: +- 单一职责:仅负责配置的加载和合并 +- 依赖倒置:通过抽象接口解耦配置源 +- 开闭原则:易于扩展新的配置源 +""" + +from __future__ import annotations + +import os +from abc import ABC, abstractmethod +from functools import lru_cache +from pathlib import Path +from typing import Any, TypeVar + +import yaml + +T = TypeVar("T") + + +class ConfigSourceError(Exception): + """配置源加载错误""" + + def __init__(self, source: str, message: str) -> None: + self.source = source + self.message = message + super().__init__(f"[{source}] {message}") + + +class ConfigSource(ABC): + """配置源抽象基类""" + + @property + @abstractmethod + def name(self) -> str: + """配置源名称""" + ... + + @property + @abstractmethod + def priority(self) -> int: + """优先级,数值越大优先级越高""" + ... + + @abstractmethod + def load(self) -> dict[str, Any]: + """加载配置,返回扁平化的键值对""" + ... + + +class EnvConfigSource(ConfigSource): + """环境变量配置源""" + + def __init__(self, prefix: str = "") -> None: + """ + 初始化环境变量配置源 + + Args: + prefix: 环境变量前缀,用于过滤相关配置 + 例如 prefix="SATONANO_" 时只读取以此为前缀的变量 + """ + self._prefix = prefix.upper() + + @property + def name(self) -> str: + return "environment" + + @property + def priority(self) -> int: + return 100 # 最高优先级 + + def load(self) -> dict[str, Any]: + """ + 加载环境变量 + + Returns: + 配置字典,键名转换为小写并移除前缀 + """ + config: dict[str, Any] = {} + prefix_len = len(self._prefix) + + for key, value in os.environ.items(): + if self._prefix and not key.upper().startswith(self._prefix): + continue + + # 移除前缀并转为小写 + config_key = key[prefix_len:].lower() if self._prefix else key.lower() + config[config_key] = self._parse_value(value) + + return config + + @staticmethod + def _parse_value(value: str) -> Any: + """ + 解析环境变量值,自动转换类型 + + Args: + value: 原始字符串值 + + Returns: + 转换后的值(bool/int/float/str) + """ + # 布尔值 + if value.lower() in ("true", "yes", "1", "on"): + return True + if value.lower() in ("false", "no", "0", "off"): + return False + + # 整数 + try: + return int(value) + except ValueError: + pass + + # 浮点数 + try: + return float(value) + except ValueError: + pass + + return value + + +class YamlConfigSource(ConfigSource): + """YAML 配置文件源""" + + def __init__( + self, + file_path: str | Path = "config.yaml", + required: bool = False, + ) -> None: + """ + 初始化 YAML 配置源 + + Args: + file_path: 配置文件路径 + required: 是否必须存在,为 True 时文件不存在会抛出异常 + """ + self._file_path = Path(file_path) + self._required = required + + @property + def name(self) -> str: + return f"yaml:{self._file_path}" + + @property + def priority(self) -> int: + return 50 # 中等优先级 + + def load(self) -> dict[str, Any]: + """ + 加载 YAML 配置文件 + + Returns: + 配置字典 + + Raises: + ConfigSourceError: 文件不存在(required=True)或解析错误 + """ + if not self._file_path.exists(): + if self._required: + raise ConfigSourceError( + self.name, + f"配置文件不存在: {self._file_path.absolute()}", + ) + return {} + + try: + with open(self._file_path, encoding="utf-8") as f: + data = yaml.safe_load(f) + except yaml.YAMLError as e: + raise ConfigSourceError(self.name, f"YAML 解析错误: {e}") from e + + if data is None: + return {} + + # 处理列表格式(兼容用户示例格式) + if isinstance(data, list): + return self._flatten_list(data) + + # 标准字典格式 + if isinstance(data, dict): + return self._normalize_keys(data) + + raise ConfigSourceError( + self.name, + f"不支持的配置格式,期望 dict 或 list,得到 {type(data).__name__}", + ) + + @staticmethod + def _flatten_list(items: list) -> dict[str, Any]: + """ + 将列表格式配置展平为字典 + + 支持格式: + - key: value + - key: value + """ + result: dict[str, Any] = {} + for item in items: + if isinstance(item, dict): + for key, value in item.items(): + result[key.lower()] = value + return result + + @staticmethod + def _normalize_keys(data: dict) -> dict[str, Any]: + """键名标准化为小写""" + return {k.lower(): v for k, v in data.items()} + + +class ConfigLoader: + """ + 配置加载器 + + 负责从多个配置源加载并合并配置,按优先级覆盖。 + + Example: + >>> loader = ConfigLoader() + >>> loader.add_source(YamlConfigSource("config.yaml")) + >>> loader.add_source(EnvConfigSource("SATONANO_")) + >>> config = loader.load() + >>> db_type = loader.get("database_type", "sqlite") + """ + + def __init__(self) -> None: + self._sources: list[ConfigSource] = [] + self._config: dict[str, Any] = {} + self._loaded = False + + def add_source(self, source: ConfigSource) -> ConfigLoader: + """ + 添加配置源 + + Args: + source: 配置源实例 + + Returns: + self,支持链式调用 + """ + self._sources.append(source) + self._loaded = False # 标记需要重新加载 + return self + + def load(self) -> dict[str, Any]: + """ + 加载并合并所有配置源 + + Returns: + 合并后的配置字典 + """ + # 按优先级升序排序,后加载的覆盖先加载的 + sorted_sources = sorted(self._sources, key=lambda s: s.priority) + + self._config = {} + for source in sorted_sources: + source_config = source.load() + self._config.update(source_config) + + self._loaded = True + return self._config.copy() + + def get(self, key: str, default: T = None) -> T | Any: + """ + 获取配置值 + + Args: + key: 配置键名(不区分大小写) + default: 默认值 + + Returns: + 配置值或默认值 + """ + if not self._loaded: + self.load() + return self._config.get(key.lower(), default) + + def get_str(self, key: str, default: str = "") -> str: + """获取字符串配置""" + value = self.get(key, default) + return str(value) if value is not None else default + + def get_int(self, key: str, default: int = 0) -> int: + """获取整数配置""" + value = self.get(key, default) + if isinstance(value, int): + return value + try: + return int(value) + except (ValueError, TypeError): + return default + + def get_float(self, key: str, default: float = 0.0) -> float: + """获取浮点数配置""" + value = self.get(key, default) + if isinstance(value, float): + return value + try: + return float(value) + except (ValueError, TypeError): + return default + + def get_bool(self, key: str, default: bool = False) -> bool: + """获取布尔配置""" + value = self.get(key, default) + if isinstance(value, bool): + return value + if isinstance(value, str): + return value.lower() in ("true", "yes", "1", "on") + return bool(value) + + def require(self, key: str) -> Any: + """ + 获取必需的配置值 + + Args: + key: 配置键名 + + Returns: + 配置值 + + Raises: + KeyError: 配置不存在 + """ + if not self._loaded: + self.load() + + key_lower = key.lower() + if key_lower not in self._config: + raise KeyError(f"缺少必需的配置项: {key}") + return self._config[key_lower] + + def all(self) -> dict[str, Any]: + """获取所有配置的副本""" + if not self._loaded: + self.load() + return self._config.copy() + + def __contains__(self, key: str) -> bool: + """检查配置是否存在""" + if not self._loaded: + self.load() + return key.lower() in self._config + + def __repr__(self) -> str: + sources = ", ".join(s.name for s in self._sources) + return f"ConfigLoader(sources=[{sources}], loaded={self._loaded})" + + +def create_config_loader( + yaml_path: str | Path = "config.yaml", + env_prefix: str = "SATONANO_", + yaml_required: bool = False, +) -> ConfigLoader: + """ + 创建预配置的配置加载器 + + Args: + yaml_path: YAML 配置文件路径 + env_prefix: 环境变量前缀 + yaml_required: YAML 文件是否必须存在 + + Returns: + 配置好的 ConfigLoader 实例 + """ + loader = ConfigLoader() + loader.add_source(YamlConfigSource(yaml_path, required=yaml_required)) + loader.add_source(EnvConfigSource(env_prefix)) + return loader + + +@lru_cache +def get_config_loader() -> ConfigLoader: + """获取全局配置加载器单例""" + return create_config_loader() + + +# 便捷访问的全局实例 +config_loader = get_config_loader() + diff --git a/app/core/exceptions.py b/app/core/exceptions.py new file mode 100644 index 0000000..a357ae9 --- /dev/null +++ b/app/core/exceptions.py @@ -0,0 +1,224 @@ +""" +自定义异常类 + +定义业务层面的异常,便于统一处理和返回合适的 HTTP 响应。 +""" + +from typing import Any + + +class AppException(Exception): + """应用基础异常""" + + def __init__( + self, + message: str, + code: str = "APP_ERROR", + details: dict[str, Any] | None = None, + ): + self.message = message + self.code = code + self.details = details or {} + super().__init__(message) + + +class AuthenticationError(AppException): + """认证错误""" + + def __init__( + self, + message: str = "认证失败", + code: str = "AUTHENTICATION_ERROR", + details: dict[str, Any] | None = None, + ): + super().__init__(message, code, details) + + +class InvalidCredentialsError(AuthenticationError): + """无效凭证""" + + def __init__(self, message: str = "用户名或密码错误"): + super().__init__(message, "INVALID_CREDENTIALS") + + +class TokenError(AuthenticationError): + """令牌错误""" + + def __init__(self, message: str = "令牌无效或已过期"): + super().__init__(message, "TOKEN_ERROR") + + +class TokenExpiredError(TokenError): + """令牌过期""" + + def __init__(self, message: str = "令牌已过期"): + super().__init__(message) + self.code = "TOKEN_EXPIRED" + + +class AuthorizationError(AppException): + """授权错误""" + + def __init__( + self, + message: str = "权限不足", + code: str = "AUTHORIZATION_ERROR", + details: dict[str, Any] | None = None, + ): + super().__init__(message, code, details) + + +class ValidationError(AppException): + """验证错误""" + + def __init__( + self, + message: str = "数据验证失败", + code: str = "VALIDATION_ERROR", + details: dict[str, Any] | None = None, + ): + super().__init__(message, code, details) + + +class ResourceNotFoundError(AppException): + """资源未找到""" + + def __init__( + self, + message: str = "资源不存在", + resource_type: str = "resource", + resource_id: Any = None, + ): + super().__init__( + message, + "RESOURCE_NOT_FOUND", + {"resource_type": resource_type, "resource_id": resource_id}, + ) + + +class ResourceConflictError(AppException): + """资源冲突(如重复创建)""" + + def __init__( + self, + message: str = "资源已存在", + code: str = "RESOURCE_CONFLICT", + details: dict[str, Any] | None = None, + ): + super().__init__(message, code, details) + + +class UserNotFoundError(ResourceNotFoundError): + """用户不存在""" + + def __init__(self, user_id: Any = None): + super().__init__("用户不存在", "user", user_id) + + +class UserAlreadyExistsError(ResourceConflictError): + """用户已存在""" + + def __init__(self, field: str = "username"): + super().__init__( + f"该{field}已被注册", + "USER_ALREADY_EXISTS", + {"field": field}, + ) + + +class UserDisabledError(AuthenticationError): + """用户被禁用""" + + def __init__(self): + super().__init__("账户已被禁用", "USER_DISABLED") + + +class PasswordValidationError(ValidationError): + """密码验证错误""" + + def __init__(self, message: str = "密码不符合要求"): + super().__init__(message, "PASSWORD_VALIDATION_ERROR") + + +# ============================================================ +# 余额相关异常 +# ============================================================ + +class InsufficientBalanceError(AppException): + """余额不足""" + + def __init__(self, required: int, available: int): + super().__init__( + f"余额不足,需要 {required / 1000:.2f},当前可用 {available / 1000:.2f}", + "INSUFFICIENT_BALANCE", + {"required_units": required, "available_units": available}, + ) + + +class DuplicateTransactionError(AppException): + """重复交易""" + + def __init__(self, idempotency_key: str): + super().__init__( + "该交易已处理", + "DUPLICATE_TRANSACTION", + {"idempotency_key": idempotency_key}, + ) + + +class ConcurrencyError(AppException): + """并发冲突""" + + def __init__(self): + super().__init__( + "操作冲突,请重试", + "CONCURRENCY_ERROR", + ) + + +# ============================================================ +# 兑换码相关异常 +# ============================================================ + +class RedeemCodeNotFoundError(AppException): + """兑换码不存在""" + + def __init__(self, code: str): + super().__init__( + "兑换码不存在", + "REDEEM_CODE_NOT_FOUND", + {"code": code}, + ) + + +class RedeemCodeInvalidError(AppException): + """兑换码无效""" + + def __init__(self, code: str, reason: str): + super().__init__( + f"兑换码无效: {reason}", + "REDEEM_CODE_INVALID", + {"code": code, "reason": reason}, + ) + + +class RedeemCodeExpiredError(AppException): + """兑换码已过期""" + + def __init__(self, code: str): + super().__init__( + "兑换码已过期", + "REDEEM_CODE_EXPIRED", + {"code": code}, + ) + + +class RedeemCodeUsedError(AppException): + """兑换码已使用""" + + def __init__(self, code: str): + super().__init__( + "兑换码已使用", + "REDEEM_CODE_USED", + {"code": code}, + ) diff --git a/app/core/security.py b/app/core/security.py new file mode 100644 index 0000000..1b5d47f --- /dev/null +++ b/app/core/security.py @@ -0,0 +1,155 @@ +""" +安全相关功能 + +包括密码哈希、JWT 令牌生成与验证。 +使用 Argon2 作为密码哈希算法(目前最安全的选择)。 +""" + +from datetime import datetime, timedelta, timezone +from typing import Any + +import jwt +from argon2 import PasswordHasher +from argon2.exceptions import InvalidHashError, VerifyMismatchError + +from app.core.config import settings + +# Argon2 密码哈希器,使用推荐的安全参数 +_password_hasher = PasswordHasher( + time_cost=3, # 迭代次数 + memory_cost=65536, # 内存使用 (64MB) + parallelism=4, # 并行度 +) + + +def hash_password(password: str) -> str: + """ + 对密码进行哈希处理 + + Args: + password: 明文密码 + + Returns: + Argon2 哈希字符串 + """ + return _password_hasher.hash(password) + + +def verify_password(password: str, hashed_password: str) -> bool: + """ + 验证密码是否匹配 + + Args: + password: 明文密码 + hashed_password: 已哈希的密码 + + Returns: + 密码是否正确 + """ + try: + _password_hasher.verify(hashed_password, password) + return True + except (VerifyMismatchError, InvalidHashError): + return False + + +def password_needs_rehash(hashed_password: str) -> bool: + """ + 检查密码是否需要重新哈希(参数升级时使用) + + Args: + hashed_password: 已哈希的密码 + + Returns: + 是否需要重新哈希 + """ + return _password_hasher.check_needs_rehash(hashed_password) + + +def create_access_token( + subject: str | int, + expires_delta: timedelta | None = None, + extra_claims: dict[str, Any] | None = None, +) -> str: + """ + 创建访问令牌 + + Args: + subject: 令牌主体(通常是用户ID) + expires_delta: 过期时间增量 + extra_claims: 额外的声明数据 + + Returns: + JWT 访问令牌 + """ + now = datetime.now(timezone.utc) + + if expires_delta: + expire = now + expires_delta + else: + expire = now + timedelta(minutes=settings.access_token_expire_minutes) + + payload = { + "sub": str(subject), + "iat": now, + "exp": expire, + "type": "access", + } + + if extra_claims: + payload.update(extra_claims) + + return jwt.encode(payload, settings.secret_key, algorithm=settings.algorithm) + + +def create_refresh_token( + subject: str | int, + expires_delta: timedelta | None = None, +) -> str: + """ + 创建刷新令牌 + + Args: + subject: 令牌主体(通常是用户ID) + expires_delta: 过期时间增量 + + Returns: + JWT 刷新令牌 + """ + now = datetime.now(timezone.utc) + + if expires_delta: + expire = now + expires_delta + else: + expire = now + timedelta(days=settings.refresh_token_expire_days) + + payload = { + "sub": str(subject), + "iat": now, + "exp": expire, + "type": "refresh", + } + + return jwt.encode(payload, settings.secret_key, algorithm=settings.algorithm) + + +def decode_token(token: str) -> dict[str, Any]: + """ + 解码并验证 JWT 令牌 + + Args: + token: JWT 令牌字符串 + + Returns: + 解码后的负载数据 + + Raises: + jwt.InvalidTokenError: 令牌无效 + jwt.ExpiredSignatureError: 令牌已过期 + """ + return jwt.decode( + token, + settings.secret_key, + algorithms=[settings.algorithm], + ) + diff --git a/app/database.py b/app/database.py new file mode 100644 index 0000000..3a1f290 --- /dev/null +++ b/app/database.py @@ -0,0 +1,100 @@ +""" +数据库连接与会话管理 + +使用 SQLAlchemy 2.0 异步模式。 +""" + +import logging +from collections.abc import AsyncGenerator +from pathlib import Path + +from sqlalchemy.ext.asyncio import ( + AsyncSession, + async_sessionmaker, + create_async_engine, +) +from sqlalchemy.orm import DeclarativeBase + +from app.core.config import settings + +logger = logging.getLogger(__name__) + + +class Base(DeclarativeBase): + """SQLAlchemy 声明式基类""" + pass + + +def _ensure_sqlite_dir() -> None: + """ + 确保 SQLite 数据库目录存在 + + 如果配置使用 SQLite,自动创建数据库文件所在的目录。 + """ + if settings.database_type != "sqlite": + return + + db_path = Path(settings.database_sqlite_path) + db_dir = db_path.parent + + if not db_dir.exists(): + logger.info(f"创建数据库目录: {db_dir.absolute()}") + db_dir.mkdir(parents=True, exist_ok=True) + + +# 确保 SQLite 目录存在 +_ensure_sqlite_dir() + +# 创建异步引擎 +engine = create_async_engine( + settings.database_url, + echo=settings.database_echo, + future=True, +) + +# 创建异步会话工厂 +async_session_factory = async_sessionmaker( + engine, + class_=AsyncSession, + expire_on_commit=False, + autocommit=False, + autoflush=False, +) + + +async def get_db() -> AsyncGenerator[AsyncSession, None]: + """ + 获取数据库会话(依赖注入用) + + Yields: + 异步数据库会话 + """ + async with async_session_factory() as session: + try: + yield session + finally: + await session.close() + + +async def init_db() -> None: + """初始化数据库(创建所有表)""" + # 导入所有模型以确保它们被注册 + from app.models import ( # noqa: F401 + User, + UserBalance, + BalanceTransaction, + RedeemCode, + RedeemCodeBatch, + RedeemCodeUsageLog, + ) + + logger.info(f"初始化数据库: {settings.database_url}") + async with engine.begin() as conn: + await conn.run_sync(Base.metadata.create_all) + logger.info("数据库初始化完成") + + +async def close_db() -> None: + """关闭数据库连接""" + await engine.dispose() + diff --git a/app/main.py b/app/main.py new file mode 100644 index 0000000..2cc415c --- /dev/null +++ b/app/main.py @@ -0,0 +1,268 @@ +""" +FastAPI 应用入口 + +配置应用实例、中间件、异常处理器等。 +""" + +from contextlib import asynccontextmanager +from pathlib import Path +from typing import AsyncGenerator + +from fastapi import FastAPI, Request, status +from fastapi.exceptions import RequestValidationError +from fastapi.middleware.cors import CORSMiddleware +from fastapi.responses import FileResponse, JSONResponse +from fastapi.staticfiles import StaticFiles + +from app.api.v1.router import api_router +from app.core.config import settings +from app.core.exceptions import ( + AppException, + AuthenticationError, + AuthorizationError, + ResourceConflictError, + ResourceNotFoundError, + ValidationError, +) +from app.database import close_db, init_db + + +def get_frontend_dir() -> Path: + """ + 获取前端静态文件目录 + + 支持相对路径和绝对路径配置 + """ + path = Path(settings.frontend_static_path) + if path.is_absolute(): + return path + # 相对路径基于项目根目录 + return Path(__file__).parent.parent / path + + +@asynccontextmanager +async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]: + """ + 应用生命周期管理 + + 启动时初始化数据库,关闭时释放资源。 + """ + # 启动时 + await init_db() + yield + # 关闭时 + await close_db() + + +def create_application() -> FastAPI: + """ + 创建 FastAPI 应用实例 + + Returns: + 配置完成的 FastAPI 应用 + """ + app = FastAPI( + title=settings.app_name, + version=settings.app_version, + description="现代化用户认证系统 API", + docs_url="/docs" if not settings.is_production else None, + redoc_url="/redoc" if not settings.is_production else None, + openapi_url="/openapi.json" if not settings.is_production else None, + lifespan=lifespan, + ) + + # 配置 CORS + app.add_middleware( + CORSMiddleware, + allow_origins=["*"] if settings.debug else [], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], + ) + + # 注册异常处理器 + register_exception_handlers(app) + + # 注册路由 + app.include_router(api_router, prefix=settings.api_v1_prefix) + + # 健康检查端点 + @app.get("/health", tags=["健康检查"]) + async def health_check(): + """健康检查接口""" + return {"status": "healthy", "version": settings.app_version} + + # 挂载前端静态文件(当静态文件目录存在时) + frontend_dir = get_frontend_dir() + if frontend_dir.exists(): + setup_frontend_routes(app, frontend_dir) + + return app + + +def setup_frontend_routes(app: FastAPI, frontend_dir: Path) -> None: + """ + 配置前端静态文件路由 + + Args: + app: FastAPI 应用实例 + frontend_dir: 前端静态文件目录 + """ + # 挂载 _next 静态资源目录(Next.js 构建产物) + next_static_dir = frontend_dir / "_next" + if next_static_dir.exists(): + app.mount( + "/_next", + StaticFiles(directory=str(next_static_dir)), + name="next_static", + ) + + # 挂载 assets 目录(通用静态资源) + assets_dir = frontend_dir / "assets" + if assets_dir.exists(): + app.mount( + "/assets", + StaticFiles(directory=str(assets_dir)), + name="assets", + ) + + # 挂载 static 目录(通用静态资源) + static_dir = frontend_dir / "static" + if static_dir.exists(): + app.mount( + "/static", + StaticFiles(directory=str(static_dir)), + name="static", + ) + + # SPA 路由处理 - 必须在最后注册,以避免覆盖 API 路由 + @app.get("/{full_path:path}", include_in_schema=False) + async def serve_spa(request: Request, full_path: str): + """ + SPA 路由处理 + + - 对于静态文件请求,直接返回文件 + - 对于 SPA 路由请求,返回 index.html + """ + # 跳过 API 路由和健康检查 + if full_path.startswith("api/") or full_path == "health": + return JSONResponse( + status_code=404, + content={"success": False, "message": "Not Found"}, + ) + + # 尝试查找静态文件 + file_path = frontend_dir / full_path + + # 如果是目录,尝试查找 index.html + if file_path.is_dir(): + file_path = file_path / "index.html" + + # 如果文件存在,返回文件 + if file_path.is_file(): + return FileResponse( + file_path, + headers=_get_cache_headers(full_path), + ) + + # 尝试添加 .html 后缀(Next.js 静态导出格式) + html_path = frontend_dir / f"{full_path}.html" + if html_path.is_file(): + return FileResponse(html_path) + + # 默认返回 index.html(SPA 路由回退) + index_path = frontend_dir / "index.html" + if index_path.is_file(): + return FileResponse(index_path) + + # 前端文件不存在 + return JSONResponse( + status_code=404, + content={"success": False, "message": "Not Found"}, + ) + + +def _get_cache_headers(path: str) -> dict[str, str]: + """ + 根据文件类型返回适当的缓存头 + + Args: + path: 请求路径 + + Returns: + 缓存相关的 HTTP 头 + """ + # 静态资源(带 hash 的文件)使用长期缓存 + if "/_next/" in path or path.startswith("_next/"): + return {"Cache-Control": "public, max-age=31536000, immutable"} + + # 其他静态文件使用短期缓存 + static_extensions = {".js", ".css", ".png", ".jpg", ".jpeg", ".gif", ".svg", ".ico", ".woff", ".woff2"} + if any(path.endswith(ext) for ext in static_extensions): + return {"Cache-Control": "public, max-age=86400"} + + # HTML 文件不缓存 + return {"Cache-Control": "no-cache"} + + +def register_exception_handlers(app: FastAPI) -> None: + """注册全局异常处理器""" + + @app.exception_handler(AppException) + async def app_exception_handler( + request: Request, + exc: AppException, + ) -> JSONResponse: + """应用异常处理""" + status_code = status.HTTP_500_INTERNAL_SERVER_ERROR + + if isinstance(exc, AuthenticationError): + status_code = status.HTTP_401_UNAUTHORIZED + elif isinstance(exc, AuthorizationError): + status_code = status.HTTP_403_FORBIDDEN + elif isinstance(exc, ResourceNotFoundError): + status_code = status.HTTP_404_NOT_FOUND + elif isinstance(exc, ResourceConflictError): + status_code = status.HTTP_409_CONFLICT + elif isinstance(exc, ValidationError): + status_code = status.HTTP_422_UNPROCESSABLE_ENTITY + + return JSONResponse( + status_code=status_code, + content={ + "success": False, + "message": exc.message, + "code": exc.code, + "details": exc.details, + }, + ) + + @app.exception_handler(RequestValidationError) + async def validation_exception_handler( + request: Request, + exc: RequestValidationError, + ) -> JSONResponse: + """请求验证异常处理""" + errors = [] + for error in exc.errors(): + field = ".".join(str(loc) for loc in error["loc"]) + errors.append({ + "field": field, + "message": error["msg"], + "type": error["type"], + }) + + return JSONResponse( + status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, + content={ + "success": False, + "message": "请求数据验证失败", + "code": "VALIDATION_ERROR", + "details": {"errors": errors}, + }, + ) + + +# 创建应用实例 +app = create_application() + diff --git a/app/models/__init__.py b/app/models/__init__.py new file mode 100644 index 0000000..30d5cfd --- /dev/null +++ b/app/models/__init__.py @@ -0,0 +1,28 @@ +"""数据库模型""" + +from app.models.user import User +from app.models.balance import ( + UserBalance, + BalanceTransaction, + TransactionType, + TransactionStatus, +) +from app.models.redeem_code import ( + RedeemCode, + RedeemCodeBatch, + RedeemCodeUsageLog, + RedeemCodeStatus, +) + +__all__ = [ + "User", + "UserBalance", + "BalanceTransaction", + "TransactionType", + "TransactionStatus", + "RedeemCode", + "RedeemCodeBatch", + "RedeemCodeUsageLog", + "RedeemCodeStatus", +] + diff --git a/app/models/balance.py b/app/models/balance.py new file mode 100644 index 0000000..f75f497 --- /dev/null +++ b/app/models/balance.py @@ -0,0 +1,320 @@ +""" +余额与交易模型 + +定义用户余额、余额交易记录相关的数据表结构。 + +设计说明: +- 余额内部以无符号整数存储(单位额度),避免浮点精度问题 +- 1.00 显示余额 = 1000 单位额度(精度 0.001) +- 所有金额操作都在单位额度层面进行,只在展示时转换 +""" + +from datetime import datetime, timezone +from enum import Enum +from typing import TYPE_CHECKING +from uuid import uuid4 + +from sqlalchemy import ( + BigInteger, + DateTime, + Enum as SQLEnum, + ForeignKey, + Index, + String, + Text, + func, +) +from sqlalchemy.orm import Mapped, mapped_column, relationship + +from app.database import Base + +if TYPE_CHECKING: + from app.models.user import User + + +def generate_uuid() -> str: + """生成 UUID 字符串""" + return str(uuid4()) + + +def utc_now() -> datetime: + """获取当前 UTC 时间""" + return datetime.now(timezone.utc) + + +class TransactionType(str, Enum): + """交易类型枚举""" + + RECHARGE = "recharge" # 充值(兑换码等) + DEDUCTION = "deduction" # 扣款(API 调用等) + REFUND = "refund" # 退款 + ADJUSTMENT = "adjustment" # 管理员调整 + TRANSFER_IN = "transfer_in" # 转入 + TRANSFER_OUT = "transfer_out" # 转出 + + +class TransactionStatus(str, Enum): + """交易状态枚举""" + + PENDING = "pending" # 待处理 + COMPLETED = "completed" # 已完成 + FAILED = "failed" # 失败 + CANCELLED = "cancelled" # 已取消 + + +class UserBalance(Base): + """ + 用户余额模型 + + 独立的余额表,便于扩展(如多币种、账户类型)和锁管理 + """ + + __tablename__ = "user_balances" + + # 主键 + id: Mapped[str] = mapped_column( + String(36), + primary_key=True, + default=generate_uuid, + comment="余额记录唯一标识", + ) + + # 关联用户(一对一) + user_id: Mapped[str] = mapped_column( + String(36), + ForeignKey("users.id", ondelete="CASCADE"), + unique=True, + nullable=False, + index=True, + comment="关联用户 ID", + ) + + # 余额信息(内部以整数单位存储) + balance: Mapped[int] = mapped_column( + BigInteger, + default=0, + nullable=False, + comment="当前余额(单位额度,1000 = 1.00 显示余额)", + ) + + # 冻结金额(用于处理中的交易) + frozen_balance: Mapped[int] = mapped_column( + BigInteger, + default=0, + nullable=False, + comment="冻结余额(单位额度)", + ) + + # 累计统计 + total_recharged: Mapped[int] = mapped_column( + BigInteger, + default=0, + nullable=False, + comment="累计充值(单位额度)", + ) + total_consumed: Mapped[int] = mapped_column( + BigInteger, + default=0, + nullable=False, + comment="累计消费(单位额度)", + ) + + # 乐观锁版本号 + version: Mapped[int] = mapped_column( + BigInteger, + default=0, + nullable=False, + comment="版本号(乐观锁)", + ) + + # 时间戳 + created_at: Mapped[datetime] = mapped_column( + DateTime(timezone=True), + default=utc_now, + server_default=func.now(), + nullable=False, + comment="创建时间", + ) + updated_at: Mapped[datetime] = mapped_column( + DateTime(timezone=True), + default=utc_now, + onupdate=utc_now, + server_default=func.now(), + nullable=False, + comment="更新时间", + ) + + # 关系 + user: Mapped["User"] = relationship( + "User", + back_populates="balance_account", + lazy="selectin", + ) + transactions: Mapped[list["BalanceTransaction"]] = relationship( + "BalanceTransaction", + back_populates="balance_account", + lazy="selectin", + order_by="desc(BalanceTransaction.created_at)", + ) + + @property + def available_balance(self) -> int: + """可用余额(总余额 - 冻结余额)""" + return self.balance - self.frozen_balance + + @property + def display_balance(self) -> str: + """显示余额(2 位小数)""" + return f"{self.balance / 1000:.2f}" + + @property + def display_available_balance(self) -> str: + """显示可用余额(2 位小数)""" + return f"{self.available_balance / 1000:.2f}" + + def __repr__(self) -> str: + return f"" + + +class BalanceTransaction(Base): + """ + 余额交易记录模型 + + 记录所有余额变动,用于审计和对账 + """ + + __tablename__ = "balance_transactions" + __table_args__ = ( + Index("ix_balance_transactions_user_created", "user_id", "created_at"), + Index("ix_balance_transactions_type_status", "transaction_type", "status"), + ) + + # 主键 + id: Mapped[str] = mapped_column( + String(36), + primary_key=True, + default=generate_uuid, + comment="交易记录唯一标识", + ) + + # 关联 + user_id: Mapped[str] = mapped_column( + String(36), + ForeignKey("users.id", ondelete="CASCADE"), + nullable=False, + index=True, + comment="关联用户 ID", + ) + balance_account_id: Mapped[str] = mapped_column( + String(36), + ForeignKey("user_balances.id", ondelete="CASCADE"), + nullable=False, + index=True, + comment="关联余额账户 ID", + ) + + # 交易信息 + transaction_type: Mapped[TransactionType] = mapped_column( + SQLEnum(TransactionType), + nullable=False, + comment="交易类型", + ) + status: Mapped[TransactionStatus] = mapped_column( + SQLEnum(TransactionStatus), + default=TransactionStatus.COMPLETED, + nullable=False, + comment="交易状态", + ) + + # 金额(整数单位) + amount: Mapped[int] = mapped_column( + BigInteger, + nullable=False, + comment="交易金额(单位额度,正数表示收入,负数表示支出)", + ) + balance_before: Mapped[int] = mapped_column( + BigInteger, + nullable=False, + comment="交易前余额(单位额度)", + ) + balance_after: Mapped[int] = mapped_column( + BigInteger, + nullable=False, + comment="交易后余额(单位额度)", + ) + + # 业务关联 + reference_type: Mapped[str | None] = mapped_column( + String(64), + nullable=True, + index=True, + comment="关联业务类型(如 redeem_code、api_call)", + ) + reference_id: Mapped[str | None] = mapped_column( + String(64), + nullable=True, + index=True, + comment="关联业务 ID", + ) + + # 描述 + description: Mapped[str | None] = mapped_column( + String(255), + nullable=True, + comment="交易描述", + ) + remark: Mapped[str | None] = mapped_column( + Text, + nullable=True, + comment="备注(内部使用)", + ) + + # 操作人(管理员调整时记录) + operator_id: Mapped[str | None] = mapped_column( + String(36), + ForeignKey("users.id", ondelete="SET NULL"), + nullable=True, + comment="操作人 ID(管理员调整时)", + ) + + # 幂等键(防止重复提交) + idempotency_key: Mapped[str | None] = mapped_column( + String(64), + unique=True, + nullable=True, + comment="幂等键", + ) + + # 时间戳 + created_at: Mapped[datetime] = mapped_column( + DateTime(timezone=True), + default=utc_now, + server_default=func.now(), + nullable=False, + comment="创建时间", + ) + + # 关系 + user: Mapped["User"] = relationship( + "User", + foreign_keys=[user_id], + lazy="selectin", + ) + balance_account: Mapped["UserBalance"] = relationship( + "UserBalance", + back_populates="transactions", + lazy="selectin", + ) + + @property + def display_amount(self) -> str: + """显示金额(带符号,2 位小数)""" + return f"{self.amount / 1000:+.2f}" + + def __repr__(self) -> str: + return ( + f"" + ) + diff --git a/app/models/redeem_code.py b/app/models/redeem_code.py new file mode 100644 index 0000000..15b37f4 --- /dev/null +++ b/app/models/redeem_code.py @@ -0,0 +1,409 @@ +""" +兑换码模型 + +定义余额兑换码相关的数据表结构。 + +设计说明: +- 兑换码支持批量生成、导入导出 +- 记录完整的使用日志 +- 支持设置有效期和使用限制 +""" + +from datetime import datetime, timezone +from enum import Enum +from typing import TYPE_CHECKING +from uuid import uuid4 +import secrets +import string + +from sqlalchemy import ( + BigInteger, + Boolean, + DateTime, + Enum as SQLEnum, + ForeignKey, + Index, + Integer, + String, + Text, + func, +) +from sqlalchemy.orm import Mapped, mapped_column, relationship + +from app.database import Base + +if TYPE_CHECKING: + from app.models.user import User + + +def generate_uuid() -> str: + """生成 UUID 字符串""" + return str(uuid4()) + + +def utc_now() -> datetime: + """获取当前 UTC 时间""" + return datetime.now(timezone.utc) + + +def generate_redeem_code(length: int = 16) -> str: + """ + 生成兑换码 + + 格式:大写字母和数字,分段显示(如 XXXX-XXXX-XXXX-XXXX) + 排除容易混淆的字符:0/O, 1/I/L + """ + # 可用字符集(排除易混淆字符) + alphabet = "ABCDEFGHJKMNPQRSTUVWXYZ23456789" + code = "".join(secrets.choice(alphabet) for _ in range(length)) + # 每 4 个字符用连字符分隔 + return "-".join(code[i:i + 4] for i in range(0, len(code), 4)) + + +class RedeemCodeStatus(str, Enum): + """兑换码状态枚举""" + + ACTIVE = "active" # 可用 + USED = "used" # 已使用 + DISABLED = "disabled" # 已禁用 + EXPIRED = "expired" # 已过期 + + +class RedeemCodeBatch(Base): + """ + 兑换码批次模型 + + 用于管理批量生成的兑换码 + """ + + __tablename__ = "redeem_code_batches" + + # 主键 + id: Mapped[str] = mapped_column( + String(36), + primary_key=True, + default=generate_uuid, + comment="批次唯一标识", + ) + + # 批次信息 + name: Mapped[str] = mapped_column( + String(128), + nullable=False, + comment="批次名称", + ) + description: Mapped[str | None] = mapped_column( + Text, + nullable=True, + comment="批次描述", + ) + + # 面值(单位额度) + face_value: Mapped[int] = mapped_column( + BigInteger, + nullable=False, + comment="面值(单位额度,1000 = 1.00)", + ) + + # 数量统计 + total_count: Mapped[int] = mapped_column( + Integer, + default=0, + nullable=False, + comment="生成总数", + ) + used_count: Mapped[int] = mapped_column( + Integer, + default=0, + nullable=False, + comment="已使用数量", + ) + + # 创建者 + created_by: Mapped[str] = mapped_column( + String(36), + ForeignKey("users.id", ondelete="SET NULL"), + nullable=True, + comment="创建者 ID", + ) + + # 时间戳 + created_at: Mapped[datetime] = mapped_column( + DateTime(timezone=True), + default=utc_now, + server_default=func.now(), + nullable=False, + comment="创建时间", + ) + + # 关系 + codes: Mapped[list["RedeemCode"]] = relationship( + "RedeemCode", + back_populates="batch", + lazy="selectin", + ) + creator: Mapped["User"] = relationship( + "User", + lazy="selectin", + ) + + @property + def display_face_value(self) -> str: + """显示面值(2 位小数)""" + return f"{self.face_value / 1000:.2f}" + + def __repr__(self) -> str: + return f"" + + +class RedeemCode(Base): + """ + 兑换码模型 + + 单个兑换码记录 + """ + + __tablename__ = "redeem_codes" + __table_args__ = ( + Index("ix_redeem_codes_status_expires", "status", "expires_at"), + ) + + # 主键 + id: Mapped[str] = mapped_column( + String(36), + primary_key=True, + default=generate_uuid, + comment="兑换码记录唯一标识", + ) + + # 兑换码(唯一索引) + code: Mapped[str] = mapped_column( + String(32), + unique=True, + nullable=False, + index=True, + default=generate_redeem_code, + comment="兑换码", + ) + + # 批次关联(可选) + batch_id: Mapped[str | None] = mapped_column( + String(36), + ForeignKey("redeem_code_batches.id", ondelete="SET NULL"), + nullable=True, + index=True, + comment="关联批次 ID", + ) + + # 面值(单位额度) + face_value: Mapped[int] = mapped_column( + BigInteger, + nullable=False, + comment="面值(单位额度,1000 = 1.00)", + ) + + # 状态 + status: Mapped[RedeemCodeStatus] = mapped_column( + SQLEnum(RedeemCodeStatus), + default=RedeemCodeStatus.ACTIVE, + nullable=False, + index=True, + comment="兑换码状态", + ) + + # 使用限制 + max_uses: Mapped[int] = mapped_column( + Integer, + default=1, + nullable=False, + comment="最大使用次数", + ) + used_count: Mapped[int] = mapped_column( + Integer, + default=0, + nullable=False, + comment="已使用次数", + ) + + # 有效期 + expires_at: Mapped[datetime | None] = mapped_column( + DateTime(timezone=True), + nullable=True, + comment="过期时间", + ) + + # 使用信息 + used_by: Mapped[str | None] = mapped_column( + String(36), + ForeignKey("users.id", ondelete="SET NULL"), + nullable=True, + comment="使用者 ID(最后使用)", + ) + used_at: Mapped[datetime | None] = mapped_column( + DateTime(timezone=True), + nullable=True, + comment="使用时间(最后使用)", + ) + + # 备注 + remark: Mapped[str | None] = mapped_column( + Text, + nullable=True, + comment="备注", + ) + + # 创建者 + created_by: Mapped[str | None] = mapped_column( + String(36), + ForeignKey("users.id", ondelete="SET NULL"), + nullable=True, + comment="创建者 ID", + ) + + # 时间戳 + created_at: Mapped[datetime] = mapped_column( + DateTime(timezone=True), + default=utc_now, + server_default=func.now(), + nullable=False, + comment="创建时间", + ) + updated_at: Mapped[datetime] = mapped_column( + DateTime(timezone=True), + default=utc_now, + onupdate=utc_now, + server_default=func.now(), + nullable=False, + comment="更新时间", + ) + + # 关系 + batch: Mapped["RedeemCodeBatch | None"] = relationship( + "RedeemCodeBatch", + back_populates="codes", + lazy="selectin", + ) + usage_logs: Mapped[list["RedeemCodeUsageLog"]] = relationship( + "RedeemCodeUsageLog", + back_populates="redeem_code", + lazy="selectin", + order_by="desc(RedeemCodeUsageLog.created_at)", + ) + + @property + def display_face_value(self) -> str: + """显示面值(2 位小数)""" + return f"{self.face_value / 1000:.2f}" + + @property + def is_valid(self) -> bool: + """检查兑换码是否有效""" + if self.status != RedeemCodeStatus.ACTIVE: + return False + if self.used_count >= self.max_uses: + return False + if self.expires_at and self.expires_at < utc_now(): + return False + return True + + def __repr__(self) -> str: + return f"" + + +class RedeemCodeUsageLog(Base): + """ + 兑换码使用日志模型 + + 记录每次兑换的详细信息 + """ + + __tablename__ = "redeem_code_usage_logs" + __table_args__ = ( + Index("ix_redeem_usage_user_created", "user_id", "created_at"), + ) + + # 主键 + id: Mapped[str] = mapped_column( + String(36), + primary_key=True, + default=generate_uuid, + comment="日志唯一标识", + ) + + # 关联 + redeem_code_id: Mapped[str] = mapped_column( + String(36), + ForeignKey("redeem_codes.id", ondelete="CASCADE"), + nullable=False, + index=True, + comment="关联兑换码 ID", + ) + user_id: Mapped[str] = mapped_column( + String(36), + ForeignKey("users.id", ondelete="CASCADE"), + nullable=False, + index=True, + comment="使用者 ID", + ) + transaction_id: Mapped[str | None] = mapped_column( + String(36), + ForeignKey("balance_transactions.id", ondelete="SET NULL"), + nullable=True, + comment="关联交易记录 ID", + ) + + # 兑换信息快照 + code_snapshot: Mapped[str] = mapped_column( + String(32), + nullable=False, + comment="兑换码快照", + ) + face_value: Mapped[int] = mapped_column( + BigInteger, + nullable=False, + comment="面值(单位额度)", + ) + + # 客户端信息 + ip_address: Mapped[str | None] = mapped_column( + String(64), + nullable=True, + comment="客户端 IP", + ) + user_agent: Mapped[str | None] = mapped_column( + String(512), + nullable=True, + comment="User Agent", + ) + + # 时间戳 + created_at: Mapped[datetime] = mapped_column( + DateTime(timezone=True), + default=utc_now, + server_default=func.now(), + nullable=False, + comment="使用时间", + ) + + # 关系 + redeem_code: Mapped["RedeemCode"] = relationship( + "RedeemCode", + back_populates="usage_logs", + lazy="selectin", + ) + user: Mapped["User"] = relationship( + "User", + lazy="selectin", + ) + + @property + def display_face_value(self) -> str: + """显示面值(2 位小数)""" + return f"{self.face_value / 1000:.2f}" + + def __repr__(self) -> str: + return ( + f"" + ) + diff --git a/app/models/user.py b/app/models/user.py new file mode 100644 index 0000000..266b4c9 --- /dev/null +++ b/app/models/user.py @@ -0,0 +1,141 @@ +""" +用户模型 + +定义用户数据表结构。 +""" + +from datetime import datetime, timezone +from typing import TYPE_CHECKING +from uuid import uuid4 + +from sqlalchemy import Boolean, DateTime, String, Text, func +from sqlalchemy.orm import Mapped, mapped_column, relationship + +from app.database import Base + +if TYPE_CHECKING: + from app.models.balance import UserBalance + + +def generate_uuid() -> str: + """生成 UUID 字符串""" + return str(uuid4()) + + +def utc_now() -> datetime: + """获取当前 UTC 时间""" + return datetime.now(timezone.utc) + + +class User(Base): + """用户模型""" + + __tablename__ = "users" + + # 主键:使用 UUID 字符串 + id: Mapped[str] = mapped_column( + String(36), + primary_key=True, + default=generate_uuid, + comment="用户唯一标识", + ) + + # 账户信息 + username: Mapped[str] = mapped_column( + String(32), + unique=True, + index=True, + nullable=False, + comment="用户名", + ) + email: Mapped[str | None] = mapped_column( + String(255), + unique=True, + index=True, + nullable=True, + comment="邮箱地址", + ) + hashed_password: Mapped[str | None] = mapped_column( + String(255), + nullable=True, # OAuth2 用户可能没有密码 + comment="密码哈希", + ) + + # OAuth2 关联信息 + oauth_provider: Mapped[str | None] = mapped_column( + String(32), + nullable=True, + index=True, + comment="OAuth2 提供商(如 linuxdo)", + ) + oauth_user_id: Mapped[str | None] = mapped_column( + String(128), + nullable=True, + index=True, + comment="OAuth2 用户 ID", + ) + + # 用户状态 + is_active: Mapped[bool] = mapped_column( + Boolean, + default=True, + nullable=False, + comment="是否激活", + ) + is_superuser: Mapped[bool] = mapped_column( + Boolean, + default=False, + nullable=False, + comment="是否为超级管理员", + ) + + # 个人信息 + nickname: Mapped[str | None] = mapped_column( + String(64), + nullable=True, + comment="昵称", + ) + avatar_url: Mapped[str | None] = mapped_column( + String(512), + nullable=True, + comment="头像 URL", + ) + bio: Mapped[str | None] = mapped_column( + Text, + nullable=True, + comment="个人简介", + ) + + # 时间戳 + created_at: Mapped[datetime] = mapped_column( + DateTime(timezone=True), + default=utc_now, + server_default=func.now(), + nullable=False, + comment="创建时间", + ) + updated_at: Mapped[datetime] = mapped_column( + DateTime(timezone=True), + default=utc_now, + onupdate=utc_now, + server_default=func.now(), + nullable=False, + comment="更新时间", + ) + last_login_at: Mapped[datetime | None] = mapped_column( + DateTime(timezone=True), + nullable=True, + comment="最后登录时间", + ) + + # 关系 + balance_account: Mapped["UserBalance | None"] = relationship( + "UserBalance", + back_populates="user", + uselist=False, + lazy="selectin", + ) + + def __repr__(self) -> str: + return f"" + diff --git a/app/repositories/__init__.py b/app/repositories/__init__.py new file mode 100644 index 0000000..e20ec95 --- /dev/null +++ b/app/repositories/__init__.py @@ -0,0 +1,19 @@ +"""数据仓库层""" + +from app.repositories.user import UserRepository +from app.repositories.balance import BalanceRepository, TransactionRepository +from app.repositories.redeem_code import ( + RedeemCodeRepository, + RedeemCodeBatchRepository, + RedeemCodeUsageLogRepository, +) + +__all__ = [ + "UserRepository", + "BalanceRepository", + "TransactionRepository", + "RedeemCodeRepository", + "RedeemCodeBatchRepository", + "RedeemCodeUsageLogRepository", +] + diff --git a/app/repositories/balance.py b/app/repositories/balance.py new file mode 100644 index 0000000..a75f806 --- /dev/null +++ b/app/repositories/balance.py @@ -0,0 +1,378 @@ +""" +余额仓库 + +处理余额相关的数据库操作。 + +设计说明: +- 使用乐观锁(version)防止并发更新冲突 +- 提供行级锁支持(悲观锁)用于关键操作 +""" + +from datetime import datetime +from typing import Any + +from sqlalchemy import select, update, and_ +from sqlalchemy.ext.asyncio import AsyncSession + +from app.models.balance import ( + UserBalance, + BalanceTransaction, + TransactionType, + TransactionStatus, +) +from app.repositories.base import BaseRepository + + +class BalanceRepository(BaseRepository[UserBalance]): + """余额仓库""" + + model = UserBalance + + async def get_by_user_id(self, user_id: str) -> UserBalance | None: + """ + 通过用户 ID 获取余额账户 + + Args: + user_id: 用户 ID + + Returns: + 余额账户或 None + """ + stmt = select(UserBalance).where(UserBalance.user_id == user_id) + result = await self.session.execute(stmt) + return result.scalar_one_or_none() + + async def get_by_user_id_for_update(self, user_id: str) -> UserBalance | None: + """ + 通过用户 ID 获取余额账户(加行级锁) + + 用于需要原子性更新的场景,如扣款操作。 + + Args: + user_id: 用户 ID + + Returns: + 余额账户或 None + """ + stmt = ( + select(UserBalance) + .where(UserBalance.user_id == user_id) + .with_for_update() # 行级锁 + ) + result = await self.session.execute(stmt) + return result.scalar_one_or_none() + + async def get_or_create(self, user_id: str) -> UserBalance: + """ + 获取或创建余额账户 + + 如果用户没有余额账户,自动创建一个。 + + Args: + user_id: 用户 ID + + Returns: + 余额账户 + """ + balance = await self.get_by_user_id(user_id) + if balance is None: + balance = await self.create(user_id=user_id) + return balance + + async def get_or_create_for_update(self, user_id: str) -> UserBalance: + """ + 获取或创建余额账户(加行级锁) + + Args: + user_id: 用户 ID + + Returns: + 余额账户 + """ + balance = await self.get_by_user_id_for_update(user_id) + if balance is None: + balance = await self.create(user_id=user_id) + # 重新获取并加锁 + await self.session.flush() + balance = await self.get_by_user_id_for_update(user_id) + return balance # type: ignore + + async def update_balance_optimistic( + self, + balance: UserBalance, + delta: int, + *, + is_recharge: bool = False, + is_consumption: bool = False, + ) -> bool: + """ + 使用乐观锁更新余额 + + 通过版本号检查确保并发安全。 + + Args: + balance: 余额账户 + delta: 变化量(正数增加,负数减少) + is_recharge: 是否为充值 + is_consumption: 是否为消费 + + Returns: + 是否更新成功 + """ + current_version = balance.version + new_balance = balance.balance + delta + + # 构建更新语句 + update_values: dict[str, Any] = { + "balance": new_balance, + "version": current_version + 1, + } + + if is_recharge and delta > 0: + update_values["total_recharged"] = balance.total_recharged + delta + if is_consumption and delta < 0: + update_values["total_consumed"] = balance.total_consumed + abs(delta) + + stmt = ( + update(UserBalance) + .where( + and_( + UserBalance.id == balance.id, + UserBalance.version == current_version, # 乐观锁检查 + ) + ) + .values(**update_values) + ) + + result = await self.session.execute(stmt) + + if result.rowcount == 1: + # 更新成功,刷新对象 + balance.balance = new_balance + balance.version = current_version + 1 + if is_recharge and delta > 0: + balance.total_recharged += delta + if is_consumption and delta < 0: + balance.total_consumed += abs(delta) + return True + + return False + + async def freeze_balance( + self, + balance: UserBalance, + amount: int, + ) -> bool: + """ + 冻结余额 + + Args: + balance: 余额账户 + amount: 冻结金额(正数) + + Returns: + 是否成功 + """ + if amount <= 0: + return False + if balance.available_balance < amount: + return False + + current_version = balance.version + stmt = ( + update(UserBalance) + .where( + and_( + UserBalance.id == balance.id, + UserBalance.version == current_version, + UserBalance.balance - UserBalance.frozen_balance >= amount, + ) + ) + .values( + frozen_balance=UserBalance.frozen_balance + amount, + version=current_version + 1, + ) + ) + + result = await self.session.execute(stmt) + + if result.rowcount == 1: + balance.frozen_balance += amount + balance.version = current_version + 1 + return True + + return False + + async def unfreeze_balance( + self, + balance: UserBalance, + amount: int, + ) -> bool: + """ + 解冻余额 + + Args: + balance: 余额账户 + amount: 解冻金额(正数) + + Returns: + 是否成功 + """ + if amount <= 0: + return False + if balance.frozen_balance < amount: + return False + + current_version = balance.version + stmt = ( + update(UserBalance) + .where( + and_( + UserBalance.id == balance.id, + UserBalance.version == current_version, + UserBalance.frozen_balance >= amount, + ) + ) + .values( + frozen_balance=UserBalance.frozen_balance - amount, + version=current_version + 1, + ) + ) + + result = await self.session.execute(stmt) + + if result.rowcount == 1: + balance.frozen_balance -= amount + balance.version = current_version + 1 + return True + + return False + + +class TransactionRepository(BaseRepository[BalanceTransaction]): + """交易记录仓库""" + + model = BalanceTransaction + + async def get_by_user_id( + self, + user_id: str, + *, + offset: int = 0, + limit: int = 20, + transaction_type: TransactionType | None = None, + status: TransactionStatus | None = None, + ) -> list[BalanceTransaction]: + """ + 获取用户的交易记录 + + Args: + user_id: 用户 ID + offset: 偏移量 + limit: 限制数量 + transaction_type: 交易类型过滤 + status: 状态过滤 + + Returns: + 交易记录列表 + """ + stmt = select(BalanceTransaction).where( + BalanceTransaction.user_id == user_id + ) + + if transaction_type: + stmt = stmt.where(BalanceTransaction.transaction_type == transaction_type) + if status: + stmt = stmt.where(BalanceTransaction.status == status) + + stmt = ( + stmt + .order_by(BalanceTransaction.created_at.desc()) + .offset(offset) + .limit(limit) + ) + + result = await self.session.execute(stmt) + return list(result.scalars().all()) + + async def count_by_user_id( + self, + user_id: str, + *, + transaction_type: TransactionType | None = None, + status: TransactionStatus | None = None, + ) -> int: + """ + 统计用户的交易记录数量 + + Args: + user_id: 用户 ID + transaction_type: 交易类型过滤 + status: 状态过滤 + + Returns: + 记录数量 + """ + from sqlalchemy import func + + stmt = select(func.count()).select_from(BalanceTransaction).where( + BalanceTransaction.user_id == user_id + ) + + if transaction_type: + stmt = stmt.where(BalanceTransaction.transaction_type == transaction_type) + if status: + stmt = stmt.where(BalanceTransaction.status == status) + + result = await self.session.execute(stmt) + return result.scalar() or 0 + + async def get_by_idempotency_key( + self, + idempotency_key: str, + ) -> BalanceTransaction | None: + """ + 通过幂等键获取交易记录 + + 用于防止重复提交。 + + Args: + idempotency_key: 幂等键 + + Returns: + 交易记录或 None + """ + stmt = select(BalanceTransaction).where( + BalanceTransaction.idempotency_key == idempotency_key + ) + result = await self.session.execute(stmt) + return result.scalar_one_or_none() + + async def get_by_reference( + self, + reference_type: str, + reference_id: str, + ) -> list[BalanceTransaction]: + """ + 通过业务关联获取交易记录 + + Args: + reference_type: 关联业务类型 + reference_id: 关联业务 ID + + Returns: + 交易记录列表 + """ + stmt = ( + select(BalanceTransaction) + .where( + and_( + BalanceTransaction.reference_type == reference_type, + BalanceTransaction.reference_id == reference_id, + ) + ) + .order_by(BalanceTransaction.created_at.desc()) + ) + result = await self.session.execute(stmt) + return list(result.scalars().all()) + diff --git a/app/repositories/base.py b/app/repositories/base.py new file mode 100644 index 0000000..2d8356e --- /dev/null +++ b/app/repositories/base.py @@ -0,0 +1,138 @@ +""" +基础仓库类 + +提供通用的 CRUD 操作封装。 +""" + +from typing import Any, Generic, TypeVar +from uuid import uuid4 + +from sqlalchemy import select, func +from sqlalchemy.ext.asyncio import AsyncSession + +from app.database import Base + +ModelT = TypeVar("ModelT", bound=Base) + + +class BaseRepository(Generic[ModelT]): + """ + 基础仓库类 + + 提供通用的数据库操作方法。 + """ + + model: type[ModelT] + + def __init__(self, session: AsyncSession): + """ + 初始化仓库 + + Args: + session: 异步数据库会话 + """ + self.session = session + + async def get_by_id(self, id: str) -> ModelT | None: + """ + 通过 ID 获取实体 + + Args: + id: 实体 ID + + Returns: + 实体对象或 None + """ + return await self.session.get(self.model, id) + + async def get_all( + self, + *, + offset: int = 0, + limit: int = 100, + ) -> list[ModelT]: + """ + 获取所有实体 + + Args: + offset: 偏移量 + limit: 限制数量 + + Returns: + 实体列表 + """ + stmt = select(self.model).offset(offset).limit(limit) + result = await self.session.execute(stmt) + return list(result.scalars().all()) + + async def count(self) -> int: + """ + 获取实体总数 + + Returns: + 实体数量 + """ + stmt = select(func.count()).select_from(self.model) + result = await self.session.execute(stmt) + return result.scalar() or 0 + + async def create(self, **kwargs: Any) -> ModelT: + """ + 创建新实体 + + Args: + **kwargs: 实体属性 + + Returns: + 新创建的实体 + """ + if "id" not in kwargs: + kwargs["id"] = str(uuid4()) + + entity = self.model(**kwargs) + self.session.add(entity) + await self.session.flush() + await self.session.refresh(entity) + return entity + + async def update( + self, + entity: ModelT, + **kwargs: Any, + ) -> ModelT: + """ + 更新实体 + + Args: + entity: 要更新的实体 + **kwargs: 要更新的属性 + + Returns: + 更新后的实体 + """ + for key, value in kwargs.items(): + if hasattr(entity, key): + setattr(entity, key, value) + + await self.session.flush() + await self.session.refresh(entity) + return entity + + async def delete(self, entity: ModelT) -> None: + """ + 删除实体 + + Args: + entity: 要删除的实体 + """ + await self.session.delete(entity) + await self.session.flush() + + async def commit(self) -> None: + """提交事务""" + await self.session.commit() + + async def rollback(self) -> None: + """回滚事务""" + await self.session.rollback() + diff --git a/app/repositories/redeem_code.py b/app/repositories/redeem_code.py new file mode 100644 index 0000000..47fd966 --- /dev/null +++ b/app/repositories/redeem_code.py @@ -0,0 +1,462 @@ +""" +兑换码仓库 + +处理兑换码相关的数据库操作。 +""" + +from datetime import datetime, timezone +from typing import Any + +from sqlalchemy import select, update, and_, or_, func +from sqlalchemy.ext.asyncio import AsyncSession + +from app.models.redeem_code import ( + RedeemCode, + RedeemCodeBatch, + RedeemCodeUsageLog, + RedeemCodeStatus, +) +from app.repositories.base import BaseRepository + + +class RedeemCodeRepository(BaseRepository[RedeemCode]): + """兑换码仓库""" + + model = RedeemCode + + async def get_by_code(self, code: str) -> RedeemCode | None: + """ + 通过兑换码获取记录 + + Args: + code: 兑换码 + + Returns: + 兑换码记录或 None + """ + # 标准化兑换码格式 + normalized_code = code.strip().upper().replace(" ", "") + stmt = select(RedeemCode).where(RedeemCode.code == normalized_code) + result = await self.session.execute(stmt) + return result.scalar_one_or_none() + + async def get_by_code_for_update(self, code: str) -> RedeemCode | None: + """ + 通过兑换码获取记录(加行级锁) + + 用于兑换操作,防止并发兑换。 + + Args: + code: 兑换码 + + Returns: + 兑换码记录或 None + """ + normalized_code = code.strip().upper().replace(" ", "") + stmt = ( + select(RedeemCode) + .where(RedeemCode.code == normalized_code) + .with_for_update() + ) + result = await self.session.execute(stmt) + return result.scalar_one_or_none() + + async def get_valid_code(self, code: str) -> RedeemCode | None: + """ + 获取有效的兑换码 + + 检查状态、使用次数和有效期。 + + Args: + code: 兑换码 + + Returns: + 有效的兑换码或 None + """ + normalized_code = code.strip().upper().replace(" ", "") + now = datetime.now(timezone.utc) + + stmt = ( + select(RedeemCode) + .where( + and_( + RedeemCode.code == normalized_code, + RedeemCode.status == RedeemCodeStatus.ACTIVE, + RedeemCode.used_count < RedeemCode.max_uses, + or_( + RedeemCode.expires_at.is_(None), + RedeemCode.expires_at > now, + ), + ) + ) + ) + result = await self.session.execute(stmt) + return result.scalar_one_or_none() + + async def mark_as_used( + self, + code: RedeemCode, + user_id: str, + ) -> bool: + """ + 标记兑换码已使用 + + 更新使用计数和状态。 + + Args: + code: 兑换码记录 + user_id: 使用者 ID + + Returns: + 是否成功 + """ + now = datetime.now(timezone.utc) + new_used_count = code.used_count + 1 + new_status = ( + RedeemCodeStatus.USED + if new_used_count >= code.max_uses + else RedeemCodeStatus.ACTIVE + ) + + stmt = ( + update(RedeemCode) + .where( + and_( + RedeemCode.id == code.id, + RedeemCode.used_count == code.used_count, # 乐观锁 + ) + ) + .values( + used_count=new_used_count, + status=new_status, + used_by=user_id, + used_at=now, + ) + ) + + result = await self.session.execute(stmt) + + if result.rowcount == 1: + code.used_count = new_used_count + code.status = new_status + code.used_by = user_id + code.used_at = now + return True + + return False + + async def get_all_with_filters( + self, + *, + offset: int = 0, + limit: int = 20, + status: RedeemCodeStatus | None = None, + batch_id: str | None = None, + code_like: str | None = None, + created_after: datetime | None = None, + created_before: datetime | None = None, + ) -> list[RedeemCode]: + """ + 获取兑换码列表(支持过滤) + + Args: + offset: 偏移量 + limit: 限制数量 + status: 状态过滤 + batch_id: 批次 ID 过滤 + code_like: 兑换码模糊匹配 + created_after: 创建时间起始 + created_before: 创建时间结束 + + Returns: + 兑换码列表 + """ + stmt = select(RedeemCode) + + conditions = [] + if status: + conditions.append(RedeemCode.status == status) + if batch_id: + conditions.append(RedeemCode.batch_id == batch_id) + if code_like: + conditions.append(RedeemCode.code.contains(code_like.upper())) + if created_after: + conditions.append(RedeemCode.created_at >= created_after) + if created_before: + conditions.append(RedeemCode.created_at <= created_before) + + if conditions: + stmt = stmt.where(and_(*conditions)) + + stmt = ( + stmt + .order_by(RedeemCode.created_at.desc()) + .offset(offset) + .limit(limit) + ) + + result = await self.session.execute(stmt) + return list(result.scalars().all()) + + async def count_with_filters( + self, + *, + status: RedeemCodeStatus | None = None, + batch_id: str | None = None, + code_like: str | None = None, + created_after: datetime | None = None, + created_before: datetime | None = None, + ) -> int: + """ + 统计兑换码数量(支持过滤) + """ + stmt = select(func.count()).select_from(RedeemCode) + + conditions = [] + if status: + conditions.append(RedeemCode.status == status) + if batch_id: + conditions.append(RedeemCode.batch_id == batch_id) + if code_like: + conditions.append(RedeemCode.code.contains(code_like.upper())) + if created_after: + conditions.append(RedeemCode.created_at >= created_after) + if created_before: + conditions.append(RedeemCode.created_at <= created_before) + + if conditions: + stmt = stmt.where(and_(*conditions)) + + result = await self.session.execute(stmt) + return result.scalar() or 0 + + async def bulk_create( + self, + codes_data: list[dict[str, Any]], + ) -> list[RedeemCode]: + """ + 批量创建兑换码 + + Args: + codes_data: 兑换码数据列表 + + Returns: + 创建的兑换码列表 + """ + codes = [RedeemCode(**data) for data in codes_data] + self.session.add_all(codes) + await self.session.flush() + return codes + + async def disable_code(self, code: RedeemCode) -> RedeemCode: + """ + 禁用兑换码 + + Args: + code: 兑换码记录 + + Returns: + 更新后的兑换码 + """ + return await self.update(code, status=RedeemCodeStatus.DISABLED) + + async def enable_code(self, code: RedeemCode) -> RedeemCode: + """ + 启用兑换码 + + Args: + code: 兑换码记录 + + Returns: + 更新后的兑换码 + """ + # 只有禁用状态的可以重新启用 + if code.status != RedeemCodeStatus.DISABLED: + return code + + # 如果使用次数已满,改为已使用状态 + if code.used_count >= code.max_uses: + return await self.update(code, status=RedeemCodeStatus.USED) + + return await self.update(code, status=RedeemCodeStatus.ACTIVE) + + +class RedeemCodeBatchRepository(BaseRepository[RedeemCodeBatch]): + """兑换码批次仓库""" + + model = RedeemCodeBatch + + async def get_all_batches( + self, + *, + offset: int = 0, + limit: int = 20, + ) -> list[RedeemCodeBatch]: + """ + 获取所有批次 + + Args: + offset: 偏移量 + limit: 限制数量 + + Returns: + 批次列表 + """ + stmt = ( + select(RedeemCodeBatch) + .order_by(RedeemCodeBatch.created_at.desc()) + .offset(offset) + .limit(limit) + ) + result = await self.session.execute(stmt) + return list(result.scalars().all()) + + async def increment_used_count(self, batch_id: str) -> None: + """ + 增加批次已使用计数 + + Args: + batch_id: 批次 ID + """ + stmt = ( + update(RedeemCodeBatch) + .where(RedeemCodeBatch.id == batch_id) + .values(used_count=RedeemCodeBatch.used_count + 1) + ) + await self.session.execute(stmt) + + +class RedeemCodeUsageLogRepository(BaseRepository[RedeemCodeUsageLog]): + """兑换码使用日志仓库""" + + model = RedeemCodeUsageLog + + async def get_by_code_id( + self, + redeem_code_id: str, + *, + offset: int = 0, + limit: int = 20, + ) -> list[RedeemCodeUsageLog]: + """ + 获取兑换码的使用日志 + + Args: + redeem_code_id: 兑换码 ID + offset: 偏移量 + limit: 限制数量 + + Returns: + 使用日志列表 + """ + stmt = ( + select(RedeemCodeUsageLog) + .where(RedeemCodeUsageLog.redeem_code_id == redeem_code_id) + .order_by(RedeemCodeUsageLog.created_at.desc()) + .offset(offset) + .limit(limit) + ) + result = await self.session.execute(stmt) + return list(result.scalars().all()) + + async def get_by_user_id( + self, + user_id: str, + *, + offset: int = 0, + limit: int = 20, + ) -> list[RedeemCodeUsageLog]: + """ + 获取用户的兑换日志 + + Args: + user_id: 用户 ID + offset: 偏移量 + limit: 限制数量 + + Returns: + 使用日志列表 + """ + stmt = ( + select(RedeemCodeUsageLog) + .where(RedeemCodeUsageLog.user_id == user_id) + .order_by(RedeemCodeUsageLog.created_at.desc()) + .offset(offset) + .limit(limit) + ) + result = await self.session.execute(stmt) + return list(result.scalars().all()) + + async def get_all_with_filters( + self, + *, + offset: int = 0, + limit: int = 20, + redeem_code_id: str | None = None, + user_id: str | None = None, + code_like: str | None = None, + created_after: datetime | None = None, + created_before: datetime | None = None, + ) -> list[RedeemCodeUsageLog]: + """ + 获取使用日志(支持过滤) + """ + stmt = select(RedeemCodeUsageLog) + + conditions = [] + if redeem_code_id: + conditions.append(RedeemCodeUsageLog.redeem_code_id == redeem_code_id) + if user_id: + conditions.append(RedeemCodeUsageLog.user_id == user_id) + if code_like: + conditions.append(RedeemCodeUsageLog.code_snapshot.contains(code_like.upper())) + if created_after: + conditions.append(RedeemCodeUsageLog.created_at >= created_after) + if created_before: + conditions.append(RedeemCodeUsageLog.created_at <= created_before) + + if conditions: + stmt = stmt.where(and_(*conditions)) + + stmt = ( + stmt + .order_by(RedeemCodeUsageLog.created_at.desc()) + .offset(offset) + .limit(limit) + ) + + result = await self.session.execute(stmt) + return list(result.scalars().all()) + + async def count_with_filters( + self, + *, + redeem_code_id: str | None = None, + user_id: str | None = None, + code_like: str | None = None, + created_after: datetime | None = None, + created_before: datetime | None = None, + ) -> int: + """ + 统计使用日志数量 + """ + stmt = select(func.count()).select_from(RedeemCodeUsageLog) + + conditions = [] + if redeem_code_id: + conditions.append(RedeemCodeUsageLog.redeem_code_id == redeem_code_id) + if user_id: + conditions.append(RedeemCodeUsageLog.user_id == user_id) + if code_like: + conditions.append(RedeemCodeUsageLog.code_snapshot.contains(code_like.upper())) + if created_after: + conditions.append(RedeemCodeUsageLog.created_at >= created_after) + if created_before: + conditions.append(RedeemCodeUsageLog.created_at <= created_before) + + if conditions: + stmt = stmt.where(and_(*conditions)) + + result = await self.session.execute(stmt) + return result.scalar() or 0 + diff --git a/app/repositories/user.py b/app/repositories/user.py new file mode 100644 index 0000000..3bd165f --- /dev/null +++ b/app/repositories/user.py @@ -0,0 +1,141 @@ +""" +用户仓库 + +处理用户相关的数据库操作。 +""" + +from sqlalchemy import or_, select + +from app.models.user import User +from app.repositories.base import BaseRepository + + +class UserRepository(BaseRepository[User]): + """用户数据仓库""" + + model = User + + async def get_by_username(self, username: str) -> User | None: + """ + 通过用户名获取用户 + + Args: + username: 用户名 + + Returns: + 用户对象或 None + """ + stmt = select(User).where(User.username == username.lower()) + result = await self.session.execute(stmt) + return result.scalar_one_or_none() + + async def get_by_email(self, email: str) -> User | None: + """ + 通过邮箱获取用户 + + Args: + email: 邮箱地址 + + Returns: + 用户对象或 None + """ + stmt = select(User).where(User.email == email.lower()) + result = await self.session.execute(stmt) + return result.scalar_one_or_none() + + async def get_by_username_or_email(self, identifier: str) -> User | None: + """ + 通过用户名或邮箱获取用户 + + Args: + identifier: 用户名或邮箱 + + Returns: + 用户对象或 None + """ + identifier_lower = identifier.lower() + stmt = select(User).where( + or_( + User.username == identifier_lower, + User.email == identifier_lower, + ) + ) + result = await self.session.execute(stmt) + return result.scalar_one_or_none() + + async def exists_by_username(self, username: str) -> bool: + """ + 检查用户名是否存在 + + Args: + username: 用户名 + + Returns: + 是否存在 + """ + user = await self.get_by_username(username) + return user is not None + + async def exists_by_email(self, email: str) -> bool: + """ + 检查邮箱是否存在 + + Args: + email: 邮箱地址 + + Returns: + 是否存在 + """ + if not email: + return False + user = await self.get_by_email(email) + return user is not None + + async def get_by_oauth( + self, + provider: str, + oauth_user_id: str, + ) -> User | None: + """ + 通过 OAuth2 提供商和用户 ID 获取用户 + + Args: + provider: OAuth2 提供商标识 + oauth_user_id: OAuth2 用户 ID + + Returns: + 用户对象或 None + """ + stmt = select(User).where( + User.oauth_provider == provider, + User.oauth_user_id == oauth_user_id, + ) + result = await self.session.execute(stmt) + return result.scalar_one_or_none() + + async def get_active_users( + self, + *, + offset: int = 0, + limit: int = 100, + ) -> list[User]: + """ + 获取活跃用户列表 + + Args: + offset: 偏移量 + limit: 限制数量 + + Returns: + 活跃用户列表 + """ + stmt = ( + select(User) + .where(User.is_active == True) # noqa: E712 + .offset(offset) + .limit(limit) + .order_by(User.created_at.desc()) + ) + result = await self.session.execute(stmt) + return list(result.scalars().all()) + diff --git a/app/schemas/__init__.py b/app/schemas/__init__.py new file mode 100644 index 0000000..5269cf4 --- /dev/null +++ b/app/schemas/__init__.py @@ -0,0 +1,75 @@ +"""Pydantic 数据模式""" + +from app.schemas.auth import ( + LoginRequest, + PasswordChangeRequest, + RefreshTokenRequest, + TokenResponse, +) +from app.schemas.oauth2 import ( + OAuth2AuthorizeResponse, + OAuth2CallbackRequest, + OAuth2LoginResponse, + OAuth2TokenData, + OAuth2UserInfo, +) +from app.schemas.user import ( + UserCreate, + UserResponse, + UserUpdate, +) +from app.schemas.balance import ( + BalanceResponse, + TransactionResponse, + DeductionRequest, + DeductionResponse, + AdminAdjustmentRequest, + AdminBalanceResponse, +) +from app.schemas.redeem_code import ( + RedeemRequest, + RedeemResponse, + RedeemCodeResponse, + BatchCreateRequest, + BatchResponse, + BulkImportRequest, + BulkImportResponse, + ExportResponse, + UsageLogResponse, +) + +__all__ = [ + # Auth + "LoginRequest", + "TokenResponse", + "RefreshTokenRequest", + "PasswordChangeRequest", + # OAuth2 + "OAuth2AuthorizeResponse", + "OAuth2CallbackRequest", + "OAuth2LoginResponse", + "OAuth2TokenData", + "OAuth2UserInfo", + # User + "UserCreate", + "UserResponse", + "UserUpdate", + # Balance + "BalanceResponse", + "TransactionResponse", + "DeductionRequest", + "DeductionResponse", + "AdminAdjustmentRequest", + "AdminBalanceResponse", + # Redeem Code + "RedeemRequest", + "RedeemResponse", + "RedeemCodeResponse", + "BatchCreateRequest", + "BatchResponse", + "BulkImportRequest", + "BulkImportResponse", + "ExportResponse", + "UsageLogResponse", +] + diff --git a/app/schemas/auth.py b/app/schemas/auth.py new file mode 100644 index 0000000..ba72418 --- /dev/null +++ b/app/schemas/auth.py @@ -0,0 +1,112 @@ +""" +认证相关 Schema + +定义登录、令牌等数据结构。 +""" + +from typing import Annotated + +from pydantic import Field + +from app.schemas.base import BaseSchema + + +class LoginRequest(BaseSchema): + """登录请求""" + + username: Annotated[ + str, + Field( + min_length=1, + description="用户名或邮箱", + examples=["john_doe"], + ), + ] + password: Annotated[ + str, + Field( + min_length=1, + description="密码", + examples=["SecurePass123"], + ), + ] + + +class TokenResponse(BaseSchema): + """令牌响应""" + + access_token: str = Field(description="访问令牌") + refresh_token: str = Field(description="刷新令牌") + token_type: str = Field(default="Bearer", description="令牌类型") + expires_in: int = Field(description="访问令牌过期时间(秒)") + + +class RefreshTokenRequest(BaseSchema): + """刷新令牌请求""" + + refresh_token: Annotated[ + str, + Field( + min_length=1, + description="刷新令牌", + ), + ] + + +class PasswordChangeRequest(BaseSchema): + """修改密码请求""" + + current_password: Annotated[ + str, + Field( + min_length=1, + description="当前密码", + ), + ] + new_password: Annotated[ + str, + Field( + min_length=8, + max_length=128, + description="新密码", + ), + ] + + def model_post_init(self, __context) -> None: + """验证新旧密码不同""" + if self.current_password == self.new_password: + raise ValueError("新密码不能与当前密码相同") + + +class PasswordResetRequest(BaseSchema): + """密码重置请求(忘记密码)""" + + email: Annotated[ + str, + Field( + min_length=1, + description="注册邮箱", + examples=["user@example.com"], + ), + ] + + +class PasswordResetConfirm(BaseSchema): + """密码重置确认""" + + token: Annotated[ + str, + Field( + min_length=1, + description="重置令牌", + ), + ] + new_password: Annotated[ + str, + Field( + min_length=8, + max_length=128, + description="新密码", + ), + ] + diff --git a/app/schemas/balance.py b/app/schemas/balance.py new file mode 100644 index 0000000..748a6d7 --- /dev/null +++ b/app/schemas/balance.py @@ -0,0 +1,285 @@ +""" +余额相关 Schema + +定义余额数据的验证和序列化规则。 + +设计说明: +- 内部存储使用整数单位(units),外部显示使用小数(display) +- 1.00 显示余额 = 1000 单位额度 +""" + +from datetime import datetime +from typing import Annotated + +from pydantic import Field, field_validator, computed_field + +from app.schemas.base import BaseSchema, PaginatedResponse +from app.models.balance import TransactionType, TransactionStatus + + +# ============================================================ +# 余额单位转换工具 +# ============================================================ + +UNITS_PER_DISPLAY = 1000 # 1.00 显示余额 = 1000 单位额度 + + +def display_to_units(display_amount: float) -> int: + """将显示金额转换为单位额度""" + return int(round(display_amount * UNITS_PER_DISPLAY)) + + +def units_to_display(units: int) -> float: + """将单位额度转换为显示金额""" + return units / UNITS_PER_DISPLAY + + +def format_display(units: int) -> str: + """格式化显示金额(2 位小数)""" + return f"{units / UNITS_PER_DISPLAY:.2f}" + + +# ============================================================ +# 余额账户 Schema +# ============================================================ + +class BalanceResponse(BaseSchema): + """余额信息响应""" + + user_id: str + balance_units: Annotated[ + int, + Field(description="当前余额(单位额度)"), + ] + frozen_units: Annotated[ + int, + Field(description="冻结余额(单位额度)"), + ] + total_recharged_units: Annotated[ + int, + Field(description="累计充值(单位额度)"), + ] + total_consumed_units: Annotated[ + int, + Field(description="累计消费(单位额度)"), + ] + + @computed_field + @property + def balance(self) -> str: + """显示余额(2 位小数)""" + return format_display(self.balance_units) + + @computed_field + @property + def available_balance(self) -> str: + """显示可用余额(2 位小数)""" + return format_display(self.balance_units - self.frozen_units) + + @computed_field + @property + def frozen_balance(self) -> str: + """显示冻结余额(2 位小数)""" + return format_display(self.frozen_units) + + @computed_field + @property + def total_recharged(self) -> str: + """显示累计充值(2 位小数)""" + return format_display(self.total_recharged_units) + + @computed_field + @property + def total_consumed(self) -> str: + """显示累计消费(2 位小数)""" + return format_display(self.total_consumed_units) + + +class BalanceSummaryResponse(BaseSchema): + """余额简要信息响应(用于嵌入用户信息)""" + + balance: str = Field(description="当前余额") + available_balance: str = Field(description="可用余额") + + +# ============================================================ +# 交易记录 Schema +# ============================================================ + +class TransactionResponse(BaseSchema): + """交易记录响应""" + + id: str + transaction_type: TransactionType + status: TransactionStatus + amount_units: Annotated[ + int, + Field(description="交易金额(单位额度,正数收入,负数支出)"), + ] + balance_before_units: Annotated[ + int, + Field(description="交易前余额(单位额度)"), + ] + balance_after_units: Annotated[ + int, + Field(description="交易后余额(单位额度)"), + ] + reference_type: str | None + reference_id: str | None + description: str | None + created_at: datetime + + @computed_field + @property + def amount(self) -> str: + """显示交易金额(带符号,2 位小数)""" + return f"{self.amount_units / UNITS_PER_DISPLAY:+.2f}" + + @computed_field + @property + def balance_before(self) -> str: + """显示交易前余额(2 位小数)""" + return format_display(self.balance_before_units) + + @computed_field + @property + def balance_after(self) -> str: + """显示交易后余额(2 位小数)""" + return format_display(self.balance_after_units) + + +class TransactionListResponse(PaginatedResponse[TransactionResponse]): + """交易记录列表响应""" + pass + + +# ============================================================ +# 扣款请求 Schema +# ============================================================ + +class DeductionRequest(BaseSchema): + """扣款请求""" + + amount: Annotated[ + float, + Field( + gt=0, + description="扣款金额(显示金额,如 1.00)", + examples=[1.00, 0.50], + ), + ] + reference_type: Annotated[ + str | None, + Field( + default=None, + max_length=64, + description="关联业务类型", + examples=["api_call", "service_fee"], + ), + ] + reference_id: Annotated[ + str | None, + Field( + default=None, + max_length=64, + description="关联业务 ID", + ), + ] + description: Annotated[ + str | None, + Field( + default=None, + max_length=255, + description="交易描述", + ), + ] + idempotency_key: Annotated[ + str | None, + Field( + default=None, + max_length=64, + description="幂等键(防止重复扣款)", + ), + ] + + @field_validator("amount") + @classmethod + def validate_amount(cls, v: float) -> float: + """验证金额精度""" + # 最小精度 0.001(即 1 单位额度) + if round(v, 3) != v: + raise ValueError("金额精度不能超过 3 位小数") + return v + + @property + def amount_units(self) -> int: + """转换为单位额度""" + return display_to_units(self.amount) + + +class DeductionResponse(BaseSchema): + """扣款响应""" + + transaction_id: str + amount: str = Field(description="扣款金额") + balance_before: str = Field(description="扣款前余额") + balance_after: str = Field(description="扣款后余额") + + +# ============================================================ +# 管理员操作 Schema +# ============================================================ + +class AdminAdjustmentRequest(BaseSchema): + """管理员余额调整请求""" + + user_id: Annotated[ + str, + Field(description="目标用户 ID"), + ] + amount: Annotated[ + float, + Field( + description="调整金额(正数增加,负数减少)", + examples=[10.00, -5.00], + ), + ] + reason: Annotated[ + str, + Field( + min_length=1, + max_length=255, + description="调整原因", + ), + ] + + @field_validator("amount") + @classmethod + def validate_amount(cls, v: float) -> float: + """验证金额精度""" + if round(v, 3) != v: + raise ValueError("金额精度不能超过 3 位小数") + if v == 0: + raise ValueError("调整金额不能为 0") + return v + + @property + def amount_units(self) -> int: + """转换为单位额度""" + return display_to_units(self.amount) + + +class AdminBalanceResponse(BaseSchema): + """管理员查看的余额信息(包含更多细节)""" + + user_id: str + username: str + balance: str + available_balance: str + frozen_balance: str + total_recharged: str + total_consumed: str + version: int + created_at: datetime + updated_at: datetime + diff --git a/app/schemas/base.py b/app/schemas/base.py new file mode 100644 index 0000000..3314de3 --- /dev/null +++ b/app/schemas/base.py @@ -0,0 +1,102 @@ +""" +基础 Schema 定义 + +定义通用的响应模式和基础配置。 +""" + +from datetime import datetime +from typing import Any, Generic, TypeVar + +from pydantic import BaseModel, ConfigDict + +DataT = TypeVar("DataT") + + +class BaseSchema(BaseModel): + """基础 Schema 配置""" + + model_config = ConfigDict( + from_attributes=True, # 支持从 ORM 对象创建 + populate_by_name=True, # 支持字段别名 + str_strip_whitespace=True, # 自动去除字符串首尾空白 + ) + + +class TimestampMixin(BaseModel): + """时间戳混入""" + + created_at: datetime + updated_at: datetime + + +class APIResponse(BaseModel, Generic[DataT]): + """统一 API 响应格式""" + + success: bool = True + message: str = "操作成功" + data: DataT | None = None + + @classmethod + def ok(cls, data: DataT | None = None, message: str = "操作成功") -> "APIResponse[DataT]": + """成功响应""" + return cls(success=True, message=message, data=data) + + @classmethod + def error(cls, message: str = "操作失败", data: DataT | None = None) -> "APIResponse[DataT]": + """错误响应""" + return cls(success=False, message=message, data=data) + + +class ErrorResponse(BaseModel): + """错误响应""" + + success: bool = False + message: str + code: str + details: dict[str, Any] = {} + + +class PaginationParams(BaseModel): + """分页参数""" + + page: int = 1 + page_size: int = 20 + + @property + def offset(self) -> int: + """计算偏移量""" + return (self.page - 1) * self.page_size + + @property + def limit(self) -> int: + """获取限制数量""" + return self.page_size + + +class PaginatedResponse(BaseModel, Generic[DataT]): + """分页响应""" + + items: list[DataT] + total: int + page: int + page_size: int + total_pages: int + + @classmethod + def create( + cls, + items: list[DataT], + total: int, + page: int, + page_size: int, + ) -> "PaginatedResponse[DataT]": + """创建分页响应""" + total_pages = (total + page_size - 1) // page_size if page_size > 0 else 0 + return cls( + items=items, + total=total, + page=page, + page_size=page_size, + total_pages=total_pages, + ) + diff --git a/app/schemas/oauth2.py b/app/schemas/oauth2.py new file mode 100644 index 0000000..494a6ea --- /dev/null +++ b/app/schemas/oauth2.py @@ -0,0 +1,85 @@ +""" +OAuth2 相关 Schema + +定义 OAuth2 认证流程的数据结构。 +""" + +from typing import Annotated + +from pydantic import Field + +from app.schemas.base import BaseSchema + + +class OAuth2AuthorizeResponse(BaseSchema): + """OAuth2 授权 URL 响应""" + + authorize_url: str = Field(description="OAuth2 授权页面 URL") + state: str = Field(description="防 CSRF 状态码") + + +class OAuth2CallbackRequest(BaseSchema): + """OAuth2 回调请求""" + + code: Annotated[ + str, + Field( + min_length=1, + description="授权码", + ), + ] + state: Annotated[ + str, + Field( + min_length=1, + description="状态码(用于验证请求合法性)", + ), + ] + + +class OAuth2TokenData(BaseSchema): + """OAuth2 令牌数据(从 OAuth 提供商获取)""" + + access_token: str + token_type: str = "Bearer" + expires_in: int | None = None + refresh_token: str | None = None + scope: str | None = None + + +class OAuth2UserInfo(BaseSchema): + """ + OAuth2 用户信息(从 Linux.do 获取) + + 示例响应: + { + "id": 1, + "username": "neo", + "name": "Neo", + "active": true, + "trust_level": 4, + "email": "u1@linux.do", + "avatar_url": "https://linux.do/xxxx", + "silenced": false + } + """ + + id: int | str = Field(description="用户 ID") + username: str = Field(description="用户名") + name: str | None = Field(default=None, description="显示名称") + email: str | None = Field(default=None, description="邮箱") + avatar_url: str | None = Field(default=None, description="头像 URL") + active: bool = Field(default=True, description="是否激活") + trust_level: int | None = Field(default=None, description="信任等级") + silenced: bool = Field(default=False, description="是否被禁言") + + +class OAuth2LoginResponse(BaseSchema): + """OAuth2 登录响应""" + + access_token: str = Field(description="JWT 访问令牌") + refresh_token: str = Field(description="JWT 刷新令牌") + token_type: str = Field(default="Bearer", description="令牌类型") + expires_in: int = Field(description="访问令牌过期时间(秒)") + is_new_user: bool = Field(description="是否为新注册用户") + diff --git a/app/schemas/redeem_code.py b/app/schemas/redeem_code.py new file mode 100644 index 0000000..a838dc7 --- /dev/null +++ b/app/schemas/redeem_code.py @@ -0,0 +1,346 @@ +""" +兑换码相关 Schema + +定义兑换码数据的验证和序列化规则。 +""" + +from datetime import datetime +from typing import Annotated + +from pydantic import Field, field_validator + +from app.schemas.base import BaseSchema, PaginatedResponse +from app.schemas.balance import UNITS_PER_DISPLAY, display_to_units, format_display +from app.models.redeem_code import RedeemCodeStatus + + +# ============================================================ +# 用户兑换 Schema +# ============================================================ + +class RedeemRequest(BaseSchema): + """兑换请求""" + + code: Annotated[ + str, + Field( + min_length=1, + max_length=32, + description="兑换码", + examples=["ABCD-EFGH-JKLM-NPQR"], + ), + ] + + @field_validator("code") + @classmethod + def normalize_code(cls, v: str) -> str: + """标准化兑换码格式""" + # 移除空格,转大写 + return v.strip().upper().replace(" ", "") + + +class RedeemResponse(BaseSchema): + """兑换响应""" + + success: bool = True + message: str = "兑换成功" + face_value: str = Field(description="兑换金额") + balance_before: str = Field(description="兑换前余额") + balance_after: str = Field(description="兑换后余额") + + +# ============================================================ +# 兑换码信息 Schema +# ============================================================ + +class RedeemCodeResponse(BaseSchema): + """兑换码信息响应""" + + id: str + code: str + face_value_units: int = Field(description="面值(单位额度)") + status: RedeemCodeStatus + max_uses: int + used_count: int + expires_at: datetime | None + used_at: datetime | None + created_at: datetime + + @property + def face_value(self) -> str: + """显示面值(2 位小数)""" + return format_display(self.face_value_units) + + @property + def is_valid(self) -> bool: + """是否有效""" + if self.status != RedeemCodeStatus.ACTIVE: + return False + if self.used_count >= self.max_uses: + return False + if self.expires_at and self.expires_at < datetime.now(self.expires_at.tzinfo): + return False + return True + + +class RedeemCodeDetailResponse(RedeemCodeResponse): + """兑换码详细信息响应(管理员用)""" + + batch_id: str | None + batch_name: str | None = None + remark: str | None + created_by: str | None + used_by: str | None + + +class RedeemCodeListResponse(PaginatedResponse[RedeemCodeDetailResponse]): + """兑换码列表响应""" + pass + + +# ============================================================ +# 批次 Schema +# ============================================================ + +class BatchCreateRequest(BaseSchema): + """创建兑换码批次请求""" + + name: Annotated[ + str, + Field( + min_length=1, + max_length=128, + description="批次名称", + examples=["2024年1月活动"], + ), + ] + description: Annotated[ + str | None, + Field( + default=None, + max_length=500, + description="批次描述", + ), + ] + face_value: Annotated[ + float, + Field( + gt=0, + description="面值(显示金额)", + examples=[10.00, 50.00], + ), + ] + count: Annotated[ + int, + Field( + gt=0, + le=10000, + description="生成数量", + examples=[100], + ), + ] + max_uses: Annotated[ + int, + Field( + default=1, + gt=0, + le=100, + description="每个兑换码最大使用次数", + ), + ] + expires_at: Annotated[ + datetime | None, + Field( + default=None, + description="过期时间", + ), + ] + + @field_validator("face_value") + @classmethod + def validate_face_value(cls, v: float) -> float: + """验证面值精度""" + if round(v, 3) != v: + raise ValueError("面值精度不能超过 3 位小数") + return v + + @property + def face_value_units(self) -> int: + """转换为单位额度""" + return display_to_units(self.face_value) + + +class BatchResponse(BaseSchema): + """批次信息响应""" + + id: str + name: str + description: str | None + face_value_units: int + total_count: int + used_count: int + created_by: str | None + created_at: datetime + + @property + def face_value(self) -> str: + """显示面值(2 位小数)""" + return format_display(self.face_value_units) + + @property + def unused_count(self) -> int: + """未使用数量""" + return self.total_count - self.used_count + + +class BatchDetailResponse(BatchResponse): + """批次详细信息响应""" + + codes: list[RedeemCodeResponse] = [] + + +class BatchListResponse(PaginatedResponse[BatchResponse]): + """批次列表响应""" + pass + + +# ============================================================ +# 导入导出 Schema +# ============================================================ + +class ImportCodeRequest(BaseSchema): + """导入兑换码请求""" + + code: Annotated[ + str, + Field( + min_length=1, + max_length=32, + description="兑换码", + ), + ] + face_value: Annotated[ + float, + Field( + gt=0, + description="面值", + ), + ] + max_uses: Annotated[ + int, + Field( + default=1, + gt=0, + ), + ] + expires_at: datetime | None = None + remark: str | None = None + + @field_validator("code") + @classmethod + def normalize_code(cls, v: str) -> str: + """标准化兑换码""" + return v.strip().upper() + + @property + def face_value_units(self) -> int: + """转换为单位额度""" + return display_to_units(self.face_value) + + +class BulkImportRequest(BaseSchema): + """批量导入兑换码请求""" + + codes: Annotated[ + list[ImportCodeRequest], + Field( + min_length=1, + max_length=1000, + description="兑换码列表", + ), + ] + batch_name: Annotated[ + str | None, + Field( + default=None, + max_length=128, + description="批次名称(可选)", + ), + ] + + +class BulkImportResponse(BaseSchema): + """批量导入响应""" + + success_count: int + failed_count: int + failed_codes: list[str] = [] + batch_id: str | None = None + + +class ExportCodeItem(BaseSchema): + """导出兑换码条目""" + + code: str + face_value: str + status: str + max_uses: int + used_count: int + expires_at: str | None + created_at: str + used_at: str | None + used_by: str | None + + +class ExportResponse(BaseSchema): + """导出响应""" + + total: int + codes: list[ExportCodeItem] + + +# ============================================================ +# 使用日志 Schema +# ============================================================ + +class UsageLogResponse(BaseSchema): + """兑换码使用日志响应""" + + id: str + redeem_code_id: str + code_snapshot: str + user_id: str + username: str | None = None + face_value: str + ip_address: str | None + created_at: datetime + + +class UsageLogListResponse(PaginatedResponse[UsageLogResponse]): + """使用日志列表响应""" + pass + + +# ============================================================ +# 查询参数 Schema +# ============================================================ + +class RedeemCodeQueryParams(BaseSchema): + """兑换码查询参数""" + + status: RedeemCodeStatus | None = None + batch_id: str | None = None + code: str | None = None + created_after: datetime | None = None + created_before: datetime | None = None + + +class UsageLogQueryParams(BaseSchema): + """使用日志查询参数""" + + redeem_code_id: str | None = None + user_id: str | None = None + code: str | None = None + created_after: datetime | None = None + created_before: datetime | None = None + diff --git a/app/schemas/user.py b/app/schemas/user.py new file mode 100644 index 0000000..4742439 --- /dev/null +++ b/app/schemas/user.py @@ -0,0 +1,156 @@ +""" +用户相关 Schema + +定义用户数据的验证和序列化规则。 +""" + +import re +from datetime import datetime +from typing import Annotated + +from pydantic import EmailStr, Field, field_validator + +from app.core.config import settings +from app.schemas.base import BaseSchema + + +# 用户名正则:字母开头,只允许字母、数字、下划线 +USERNAME_PATTERN = re.compile(r"^[a-zA-Z][a-zA-Z0-9_]*$") + + +class UserBase(BaseSchema): + """用户基础字段""" + + username: Annotated[ + str, + Field( + min_length=settings.username_min_length, + max_length=settings.username_max_length, + description="用户名(字母开头,只允许字母、数字、下划线)", + examples=["john_doe"], + ), + ] + email: Annotated[ + EmailStr | None, + Field( + default=None, + description="邮箱地址", + examples=["user@example.com"], + ), + ] + nickname: Annotated[ + str | None, + Field( + default=None, + max_length=64, + description="昵称", + examples=["John"], + ), + ] + + @field_validator("username") + @classmethod + def validate_username(cls, v: str) -> str: + """验证用户名格式""" + if not USERNAME_PATTERN.match(v): + raise ValueError("用户名必须以字母开头,只能包含字母、数字和下划线") + return v.lower() # 统一转小写 + + +class UserCreate(UserBase): + """用户注册请求""" + + password: Annotated[ + str, + Field( + min_length=settings.password_min_length, + max_length=settings.password_max_length, + description="密码", + examples=["SecurePass123"], + ), + ] + + @field_validator("password") + @classmethod + def validate_password(cls, v: str) -> str: + """验证密码强度""" + errors: list[str] = [] + + if settings.password_require_uppercase and not re.search(r"[A-Z]", v): + errors.append("至少包含一个大写字母") + + if settings.password_require_lowercase and not re.search(r"[a-z]", v): + errors.append("至少包含一个小写字母") + + if settings.password_require_digit and not re.search(r"\d", v): + errors.append("至少包含一个数字") + + if settings.password_require_special and not re.search(r"[!@#$%^&*(),.?\":{}|<>]", v): + errors.append("至少包含一个特殊字符") + + if errors: + raise ValueError("密码强度不足:" + ";".join(errors)) + + return v + + +class UserUpdate(BaseSchema): + """用户信息更新请求""" + + nickname: Annotated[ + str | None, + Field( + default=None, + max_length=64, + description="昵称", + ), + ] + email: Annotated[ + EmailStr | None, + Field( + default=None, + description="邮箱地址", + ), + ] + avatar_url: Annotated[ + str | None, + Field( + default=None, + max_length=512, + description="头像 URL", + ), + ] + bio: Annotated[ + str | None, + Field( + default=None, + max_length=500, + description="个人简介", + ), + ] + + +class UserResponse(BaseSchema): + """用户信息响应""" + + id: str + username: str + email: str | None + nickname: str | None + avatar_url: str | None + bio: str | None + is_active: bool + created_at: datetime + last_login_at: datetime | None + + +class UserProfileResponse(BaseSchema): + """用户公开资料响应(不包含敏感信息)""" + + id: str + username: str + nickname: str | None + avatar_url: str | None + bio: str | None + created_at: datetime + diff --git a/app/services/__init__.py b/app/services/__init__.py new file mode 100644 index 0000000..338915c --- /dev/null +++ b/app/services/__init__.py @@ -0,0 +1,16 @@ +"""业务服务层""" + +from app.services.auth import AuthService +from app.services.oauth2 import OAuth2Service +from app.services.user import UserService +from app.services.balance import BalanceService +from app.services.redeem_code import RedeemCodeService + +__all__ = [ + "AuthService", + "OAuth2Service", + "UserService", + "BalanceService", + "RedeemCodeService", +] + diff --git a/app/services/auth.py b/app/services/auth.py new file mode 100644 index 0000000..d45f0bb --- /dev/null +++ b/app/services/auth.py @@ -0,0 +1,296 @@ +""" +认证服务 + +处理用户认证相关的业务逻辑。 +""" + +from datetime import timedelta + +import jwt + +from sqlalchemy.ext.asyncio import AsyncSession + +from app.core.config import settings +from app.core.exceptions import ( + InvalidCredentialsError, + PasswordValidationError, + TokenError, + TokenExpiredError, + UserDisabledError, + UserNotFoundError, +) +from app.core.security import ( + create_access_token, + create_refresh_token, + decode_token, + hash_password, + password_needs_rehash, + verify_password, +) +from app.models.user import User +from app.repositories.user import UserRepository +from app.schemas.auth import PasswordChangeRequest, TokenResponse +from app.services.user import UserService + + +class AuthService: + """认证服务""" + + def __init__(self, session: AsyncSession): + """ + 初始化认证服务 + + Args: + session: 数据库会话 + """ + self.session = session + self.user_repo = UserRepository(session) + self.user_service = UserService(session) + + async def authenticate( + self, + username: str, + password: str, + ) -> User: + """ + 验证用户凭证 + + Args: + username: 用户名或邮箱 + password: 密码 + + Returns: + 验证成功的用户对象 + + Raises: + InvalidCredentialsError: 凭证无效 + UserDisabledError: 用户被禁用 + """ + # 查找用户(支持用户名或邮箱登录) + user = await self.user_repo.get_by_username_or_email(username) + + if not user: + # 防止时序攻击:即使用户不存在也进行密码验证 + verify_password(password, "$argon2id$v=19$m=65536,t=3,p=4$dummy$dummy") + raise InvalidCredentialsError() + + # 验证密码 + if not verify_password(password, user.hashed_password): + raise InvalidCredentialsError() + + # 检查用户状态 + if not user.is_active: + raise UserDisabledError() + + # 检查是否需要重新哈希密码(参数升级) + if password_needs_rehash(user.hashed_password): + await self.user_repo.update( + user, + hashed_password=hash_password(password), + ) + await self.user_repo.commit() + + return user + + async def login( + self, + username: str, + password: str, + ) -> tuple[User, TokenResponse]: + """ + 用户登录 + + Args: + username: 用户名或邮箱 + password: 密码 + + Returns: + (用户对象, 令牌响应) + """ + user = await self.authenticate(username, password) + + # 更新最后登录时间 + await self.user_service.update_last_login(user) + + # 生成令牌 + tokens = self._create_tokens(user) + + return user, tokens + + def _create_tokens(self, user: User) -> TokenResponse: + """ + 为用户创建访问令牌和刷新令牌 + + Args: + user: 用户对象 + + Returns: + 令牌响应 + """ + access_token = create_access_token( + subject=user.id, + extra_claims={ + "username": user.username, + "is_superuser": user.is_superuser, + }, + ) + + refresh_token = create_refresh_token(subject=user.id) + + return TokenResponse( + access_token=access_token, + refresh_token=refresh_token, + token_type="Bearer", + expires_in=settings.access_token_expire_minutes * 60, + ) + + async def refresh_tokens(self, refresh_token: str) -> TokenResponse: + """ + 刷新访问令牌 + + Args: + refresh_token: 刷新令牌 + + Returns: + 新的令牌响应 + + Raises: + TokenError: 令牌无效 + TokenExpiredError: 令牌已过期 + """ + try: + payload = decode_token(refresh_token) + except jwt.ExpiredSignatureError: + raise TokenExpiredError() + except jwt.InvalidTokenError: + raise TokenError() + + # 验证令牌类型 + if payload.get("type") != "refresh": + raise TokenError("无效的令牌类型") + + # 获取用户 + user_id = payload.get("sub") + if not user_id: + raise TokenError() + + user = await self.user_repo.get_by_id(user_id) + if not user: + raise UserNotFoundError(user_id) + + if not user.is_active: + raise UserDisabledError() + + # 生成新令牌 + return self._create_tokens(user) + + async def change_password( + self, + user_id: str, + password_data: PasswordChangeRequest, + ) -> None: + """ + 修改用户密码 + + Args: + user_id: 用户 ID + password_data: 密码修改数据 + + Raises: + UserNotFoundError: 用户不存在 + InvalidCredentialsError: 当前密码错误 + PasswordValidationError: 新密码不符合要求 + """ + user = await self.user_repo.get_by_id(user_id) + if not user: + raise UserNotFoundError(user_id) + + # 验证当前密码 + if not verify_password(password_data.current_password, user.hashed_password): + raise InvalidCredentialsError("当前密码错误") + + # 验证新密码强度 + self._validate_password_strength(password_data.new_password) + + # 更新密码 + await self.user_repo.update( + user, + hashed_password=hash_password(password_data.new_password), + ) + await self.user_repo.commit() + + def _validate_password_strength(self, password: str) -> None: + """ + 验证密码强度 + + Args: + password: 密码 + + Raises: + PasswordValidationError: 密码不符合要求 + """ + import re + + errors: list[str] = [] + + if len(password) < settings.password_min_length: + errors.append(f"密码长度不能少于 {settings.password_min_length} 位") + + if len(password) > settings.password_max_length: + errors.append(f"密码长度不能超过 {settings.password_max_length} 位") + + if settings.password_require_uppercase and not re.search(r"[A-Z]", password): + errors.append("至少包含一个大写字母") + + if settings.password_require_lowercase and not re.search(r"[a-z]", password): + errors.append("至少包含一个小写字母") + + if settings.password_require_digit and not re.search(r"\d", password): + errors.append("至少包含一个数字") + + if settings.password_require_special and not re.search(r"[!@#$%^&*(),.?\":{}|<>]", password): + errors.append("至少包含一个特殊字符") + + if errors: + raise PasswordValidationError(";".join(errors)) + + async def get_current_user(self, token: str) -> User: + """ + 从令牌获取当前用户 + + Args: + token: 访问令牌 + + Returns: + 用户对象 + + Raises: + TokenError: 令牌无效 + TokenExpiredError: 令牌已过期 + UserNotFoundError: 用户不存在 + UserDisabledError: 用户被禁用 + """ + try: + payload = decode_token(token) + except jwt.ExpiredSignatureError: + raise TokenExpiredError() + except jwt.InvalidTokenError: + raise TokenError() + + # 验证令牌类型 + if payload.get("type") != "access": + raise TokenError("无效的令牌类型") + + user_id = payload.get("sub") + if not user_id: + raise TokenError() + + user = await self.user_repo.get_by_id(user_id) + if not user: + raise UserNotFoundError(user_id) + + if not user.is_active: + raise UserDisabledError() + + return user + diff --git a/app/services/balance.py b/app/services/balance.py new file mode 100644 index 0000000..9129f3c --- /dev/null +++ b/app/services/balance.py @@ -0,0 +1,934 @@ +""" +余额服务 + +处理余额相关的业务逻辑。 + +设计说明: +- 所有金额操作使用整数单位(units),避免浮点精度问题 +- 扣款操作使用行级锁(悲观锁)确保原子性 +- 充值操作使用乐观锁,配合重试机制 +- 每笔操作都记录交易流水 + +预扣款流程(内部方法,用于耗时付费操作): +1. pre_authorize() - 预扣款,冻结金额,快速释放锁,返回交易ID +2. 执行耗时的付费操作(使用交易ID追踪) +3. confirm() 或 cancel() - 根据操作结果确认或取消 + +推荐使用上下文管理器 deduction_context() 自动处理确认/取消。 +""" + +import logging +from contextlib import asynccontextmanager +from dataclasses import dataclass +from datetime import datetime, timezone +from typing import Any, AsyncIterator, Callable, Awaitable, TypeVar + +from sqlalchemy.ext.asyncio import AsyncSession + +from app.core.exceptions import ( + AppException, + ResourceNotFoundError, + ValidationError, +) +from app.models.balance import ( + UserBalance, + BalanceTransaction, + TransactionType, + TransactionStatus, +) +from app.repositories.balance import BalanceRepository, TransactionRepository + +logger = logging.getLogger(__name__) + +T = TypeVar("T") + + +class InsufficientBalanceError(AppException): + """余额不足""" + + def __init__(self, required: int, available: int): + super().__init__( + f"余额不足,需要 {required / 1000:.2f},当前可用 {available / 1000:.2f}", + "INSUFFICIENT_BALANCE", + {"required_units": required, "available_units": available}, + ) + + +class DuplicateTransactionError(AppException): + """重复交易""" + + def __init__(self, idempotency_key: str): + super().__init__( + "该交易已处理", + "DUPLICATE_TRANSACTION", + {"idempotency_key": idempotency_key}, + ) + + +class ConcurrencyError(AppException): + """并发冲突""" + + def __init__(self): + super().__init__( + "操作冲突,请重试", + "CONCURRENCY_ERROR", + ) + + +class TransactionNotFoundError(AppException): + """交易不存在""" + + def __init__(self, transaction_id: str): + super().__init__( + "交易记录不存在", + "TRANSACTION_NOT_FOUND", + {"transaction_id": transaction_id}, + ) + + +class TransactionStateError(AppException): + """交易状态错误""" + + def __init__(self, transaction_id: str, current_status: str, expected_status: str = "pending"): + super().__init__( + f"交易状态无效:当前 {current_status},预期 {expected_status}", + "TRANSACTION_STATE_ERROR", + { + "transaction_id": transaction_id, + "current_status": current_status, + "expected_status": expected_status, + }, + ) + + +@dataclass +class PreAuthResult: + """ + 预授权结果 + + 包含交易ID和相关信息,用于后续确认或取消操作。 + """ + + transaction_id: str + """交易ID,用于后续 confirm/cancel 操作""" + + user_id: str + """用户ID""" + + amount_units: int + """预扣款金额(单位额度)""" + + frozen_at: datetime + """冻结时间""" + + @property + def amount_display(self) -> str: + """显示金额(2位小数)""" + return f"{self.amount_units / 1000:.2f}" + + +@dataclass +class DeductionResult: + """ + 扣款结果 + + 包含扣款操作的完整信息。 + """ + + transaction_id: str + """交易ID""" + + status: TransactionStatus + """交易状态""" + + amount_units: int + """实际扣款金额(单位额度)""" + + balance_before: int + """扣款前余额""" + + balance_after: int + """扣款后余额""" + + @property + def success(self) -> bool: + """是否扣款成功""" + return self.status == TransactionStatus.COMPLETED + + @property + def amount_display(self) -> str: + """显示金额""" + return f"{abs(self.amount_units) / 1000:.2f}" + + @property + def balance_before_display(self) -> str: + """显示扣款前余额""" + return f"{self.balance_before / 1000:.2f}" + + @property + def balance_after_display(self) -> str: + """显示扣款后余额""" + return f"{self.balance_after / 1000:.2f}" + + +class BalanceService: + """余额服务""" + + # 乐观锁最大重试次数 + MAX_RETRIES = 3 + + def __init__(self, session: AsyncSession): + """ + 初始化余额服务 + + Args: + session: 数据库会话 + """ + self.session = session + self.balance_repo = BalanceRepository(session) + self.transaction_repo = TransactionRepository(session) + + # ============================================================ + # 余额查询 + # ============================================================ + + async def get_balance(self, user_id: str) -> UserBalance: + """ + 获取用户余额 + + 如果用户没有余额账户,自动创建一个。 + + Args: + user_id: 用户 ID + + Returns: + 余额账户 + """ + balance = await self.balance_repo.get_or_create(user_id) + await self.balance_repo.commit() + return balance + + async def get_balance_detail(self, user_id: str) -> dict[str, Any]: + """ + 获取用户余额详情 + + Args: + user_id: 用户 ID + + Returns: + 余额详情字典 + """ + balance = await self.get_balance(user_id) + return { + "user_id": balance.user_id, + "balance_units": balance.balance, + "frozen_units": balance.frozen_balance, + "available_units": balance.available_balance, + "total_recharged_units": balance.total_recharged, + "total_consumed_units": balance.total_consumed, + } + + async def get_transactions( + self, + user_id: str, + *, + offset: int = 0, + limit: int = 20, + transaction_type: TransactionType | None = None, + ) -> tuple[list[BalanceTransaction], int]: + """ + 获取用户交易记录 + + Args: + user_id: 用户 ID + offset: 偏移量 + limit: 限制数量 + transaction_type: 交易类型过滤 + + Returns: + (交易记录列表, 总数) + """ + transactions = await self.transaction_repo.get_by_user_id( + user_id, + offset=offset, + limit=limit, + transaction_type=transaction_type, + ) + total = await self.transaction_repo.count_by_user_id( + user_id, + transaction_type=transaction_type, + ) + return transactions, total + + # ============================================================ + # 扣款操作(使用行级锁 - 悲观锁) + # ============================================================ + + async def deduct( + self, + user_id: str, + amount_units: int, + *, + reference_type: str | None = None, + reference_id: str | None = None, + description: str | None = None, + idempotency_key: str | None = None, + ) -> BalanceTransaction: + """ + 扣款 + + 使用行级锁确保原子性,防止并发扣款导致余额变负。 + + Args: + user_id: 用户 ID + amount_units: 扣款金额(单位额度,正数) + reference_type: 关联业务类型 + reference_id: 关联业务 ID + description: 交易描述 + idempotency_key: 幂等键 + + Returns: + 交易记录 + + Raises: + InsufficientBalanceError: 余额不足 + DuplicateTransactionError: 重复交易 + """ + if amount_units <= 0: + raise ValidationError("扣款金额必须大于 0") + + # 检查幂等性 + if idempotency_key: + existing = await self.transaction_repo.get_by_idempotency_key( + idempotency_key + ) + if existing: + raise DuplicateTransactionError(idempotency_key) + + # 获取余额账户并加锁 + balance = await self.balance_repo.get_or_create_for_update(user_id) + + # 检查可用余额 + if balance.available_balance < amount_units: + raise InsufficientBalanceError(amount_units, balance.available_balance) + + # 记录扣款前余额 + balance_before = balance.balance + + # 执行扣款 + balance.balance -= amount_units + balance.total_consumed += amount_units + balance.version += 1 + + # 创建交易记录 + transaction = await self.transaction_repo.create( + user_id=user_id, + balance_account_id=balance.id, + transaction_type=TransactionType.DEDUCTION, + status=TransactionStatus.COMPLETED, + amount=-amount_units, # 负数表示支出 + balance_before=balance_before, + balance_after=balance.balance, + reference_type=reference_type, + reference_id=reference_id, + description=description, + idempotency_key=idempotency_key, + ) + + await self.balance_repo.commit() + + logger.info( + f"用户 {user_id} 扣款成功: {amount_units} 单位, " + f"余额 {balance_before} -> {balance.balance}" + ) + + return transaction + + # ============================================================ + # 预扣款流程(内部方法,用于耗时付费操作) + # ============================================================ + + async def pre_authorize( + self, + user_id: str, + amount_units: int, + *, + reference_type: str | None = None, + reference_id: str | None = None, + description: str | None = None, + ) -> PreAuthResult: + """ + 预授权扣款(内部方法) + + 冻结指定金额,快速释放数据库锁,返回交易ID供后续操作使用。 + 此方法设计用于耗时的付费操作场景。 + + 使用流程: + 1. 调用 pre_authorize() 获取 PreAuthResult + 2. 执行可能失败的耗时操作 + 3. 根据操作结果调用 confirm() 或 cancel() + + 推荐使用 deduction_context() 上下文管理器自动处理。 + + Args: + user_id: 用户 ID + amount_units: 扣款金额(单位额度,正数) + reference_type: 关联业务类型(如 api_call, service) + reference_id: 关联业务 ID + description: 交易描述 + + Returns: + PreAuthResult: 预授权结果,包含交易ID + + Raises: + InsufficientBalanceError: 余额不足 + ValidationError: 参数无效 + """ + if amount_units <= 0: + raise ValidationError("预扣款金额必须大于 0") + + # 获取余额账户并加锁(短暂持有) + balance = await self.balance_repo.get_or_create_for_update(user_id) + + # 检查可用余额 + if balance.available_balance < amount_units: + raise InsufficientBalanceError(amount_units, balance.available_balance) + + now = datetime.now(timezone.utc) + + # 执行冻结 + balance.frozen_balance += amount_units + balance.version += 1 + + # 创建待处理交易记录 + transaction = await self.transaction_repo.create( + user_id=user_id, + balance_account_id=balance.id, + transaction_type=TransactionType.DEDUCTION, + status=TransactionStatus.PENDING, + amount=-amount_units, + balance_before=balance.balance, + balance_after=balance.balance, # 尚未实际扣款 + reference_type=reference_type, + reference_id=reference_id, + description=description, + remark=f"预授权冻结: {amount_units} 单位", + ) + + # 快速提交释放锁 + await self.balance_repo.commit() + + logger.info( + f"用户 {user_id} 预授权成功: {amount_units} 单位, " + f"交易ID: {transaction.id}" + ) + + return PreAuthResult( + transaction_id=transaction.id, + user_id=user_id, + amount_units=amount_units, + frozen_at=now, + ) + + async def confirm( + self, + transaction_id: str, + *, + actual_amount_units: int | None = None, + ) -> DeductionResult: + """ + 确认预授权扣款(内部方法) + + 将预冻结的金额实际扣除。支持部分扣款。 + + Args: + transaction_id: 预授权交易 ID + actual_amount_units: 实际扣款金额(可选,用于部分扣款,默认全额) + + Returns: + DeductionResult: 扣款结果 + + Raises: + TransactionNotFoundError: 交易不存在 + TransactionStateError: 交易状态不是 PENDING + ValidationError: 参数无效 + """ + transaction = await self.transaction_repo.get_by_id(transaction_id) + if not transaction: + raise TransactionNotFoundError(transaction_id) + + if transaction.status != TransactionStatus.PENDING: + raise TransactionStateError( + transaction_id, + transaction.status.value, + ) + + # 获取余额账户并加锁 + balance = await self.balance_repo.get_by_user_id_for_update(transaction.user_id) + if not balance: + raise ResourceNotFoundError("余额账户不存在") + + frozen_amount = abs(transaction.amount) + + # 确定实际扣款金额 + if actual_amount_units is not None: + if actual_amount_units <= 0: + raise ValidationError("实际扣款金额必须大于 0") + if actual_amount_units > frozen_amount: + raise ValidationError( + f"实际扣款金额 ({actual_amount_units}) 不能超过预授权金额 ({frozen_amount})" + ) + deduct_amount = actual_amount_units + else: + deduct_amount = frozen_amount + + # 检查冻结金额 + if balance.frozen_balance < frozen_amount: + raise ValidationError("冻结金额不足,可能已被其他操作修改") + + balance_before = balance.balance + + # 执行扣款:解冻全部,扣除实际金额 + balance.frozen_balance -= frozen_amount + balance.balance -= deduct_amount + balance.total_consumed += deduct_amount + balance.version += 1 + + # 更新交易记录 + transaction.status = TransactionStatus.COMPLETED + transaction.amount = -deduct_amount # 更新为实际扣款金额 + transaction.balance_after = balance.balance + + await self.balance_repo.commit() + + logger.info( + f"用户 {transaction.user_id} 确认扣款: {deduct_amount} 单位, " + f"余额 {balance_before} -> {balance.balance}" + ) + + return DeductionResult( + transaction_id=transaction.id, + status=TransactionStatus.COMPLETED, + amount_units=deduct_amount, + balance_before=balance_before, + balance_after=balance.balance, + ) + + async def cancel( + self, + transaction_id: str, + *, + reason: str | None = None, + ) -> DeductionResult: + """ + 取消预授权扣款(内部方法) + + 解冻预授权的金额,退回用户可用余额。 + + Args: + transaction_id: 预授权交易 ID + reason: 取消原因(可选,记录在日志中) + + Returns: + DeductionResult: 取消结果 + + Raises: + TransactionNotFoundError: 交易不存在 + TransactionStateError: 交易状态不是 PENDING + """ + transaction = await self.transaction_repo.get_by_id(transaction_id) + if not transaction: + raise TransactionNotFoundError(transaction_id) + + if transaction.status != TransactionStatus.PENDING: + raise TransactionStateError( + transaction_id, + transaction.status.value, + ) + + # 获取余额账户并加锁 + balance = await self.balance_repo.get_by_user_id_for_update(transaction.user_id) + if not balance: + raise ResourceNotFoundError("余额账户不存在") + + frozen_amount = abs(transaction.amount) + + # 解冻 + balance.frozen_balance -= frozen_amount + balance.version += 1 + + # 更新交易记录 + transaction.status = TransactionStatus.CANCELLED + if reason: + transaction.remark = f"{transaction.remark or ''}; 取消原因: {reason}" + + await self.balance_repo.commit() + + logger.info( + f"用户 {transaction.user_id} 取消预授权: {frozen_amount} 单位" + + (f", 原因: {reason}" if reason else "") + ) + + return DeductionResult( + transaction_id=transaction.id, + status=TransactionStatus.CANCELLED, + amount_units=0, # 实际未扣款 + balance_before=balance.balance, + balance_after=balance.balance, + ) + + @asynccontextmanager + async def deduction_context( + self, + user_id: str, + amount_units: int, + *, + reference_type: str | None = None, + reference_id: str | None = None, + description: str | None = None, + auto_cancel_on_error: bool = True, + ) -> AsyncIterator[PreAuthResult]: + """ + 扣款上下文管理器(推荐使用) + + 提供简便的预扣款流程,自动处理确认和取消。 + 异常时自动取消预授权,退回冻结金额。 + + 用法示例: + ```python + async with balance_service.deduction_context( + user_id, + 1000, # 扣款金额(单位额度) + reference_type="api_call", + description="API调用费用", + ) as pre_auth: + # pre_auth.transaction_id 可用于追踪 + # 执行可能失败的耗时操作 + result = await call_external_api() + if not result.success: + raise Exception("API 调用失败") + # 成功退出时自动确认扣款 + # 异常退出时自动取消预授权(如果 auto_cancel_on_error=True) + ``` + + Args: + user_id: 用户 ID + amount_units: 扣款金额(单位额度) + reference_type: 关联业务类型 + reference_id: 关联业务 ID + description: 交易描述 + auto_cancel_on_error: 异常时是否自动取消(默认 True) + + Yields: + PreAuthResult: 预授权结果,包含交易ID + + Raises: + InsufficientBalanceError: 余额不足 + """ + # 第一阶段:预授权 + pre_auth = await self.pre_authorize( + user_id, + amount_units, + reference_type=reference_type, + reference_id=reference_id, + description=description, + ) + + try: + yield pre_auth + # 正常退出:确认扣款 + await self.confirm(pre_auth.transaction_id) + except Exception as e: + # 异常退出:取消预授权 + if auto_cancel_on_error: + try: + await self.cancel( + pre_auth.transaction_id, + reason=f"操作失败: {str(e)[:200]}", + ) + except Exception as cancel_error: + logger.error( + f"取消预授权失败: {pre_auth.transaction_id}, " + f"错误: {cancel_error}" + ) + raise + + async def execute_with_deduction( + self, + user_id: str, + amount_units: int, + operation: Callable[[PreAuthResult], Awaitable[T]], + *, + reference_type: str | None = None, + reference_id: str | None = None, + description: str | None = None, + ) -> tuple[DeductionResult, T]: + """ + 执行带扣款的操作(函数式接口) + + 预扣款后执行指定操作,根据操作结果自动确认或取消。 + + 用法示例: + ```python + async def call_api(pre_auth: PreAuthResult): + return await external_api.call( + transaction_id=pre_auth.transaction_id, + amount=pre_auth.amount_display, + ) + + deduction_result, api_result = await balance_service.execute_with_deduction( + user_id, + 1000, + call_api, + reference_type="api_call", + ) + ``` + + Args: + user_id: 用户 ID + amount_units: 扣款金额(单位额度) + operation: 要执行的异步操作,接收 PreAuthResult 参数 + reference_type: 关联业务类型 + reference_id: 关联业务 ID + description: 交易描述 + + Returns: + (DeductionResult, operation返回值): 扣款结果和操作结果 + + Raises: + InsufficientBalanceError: 余额不足 + Exception: 操作抛出的异常(预授权会自动取消) + """ + pre_auth = await self.pre_authorize( + user_id, + amount_units, + reference_type=reference_type, + reference_id=reference_id, + description=description, + ) + + try: + # 执行操作 + result = await operation(pre_auth) + # 成功:确认扣款 + deduction_result = await self.confirm(pre_auth.transaction_id) + return deduction_result, result + except Exception as e: + # 失败:取消预授权 + try: + await self.cancel( + pre_auth.transaction_id, + reason=f"操作失败: {str(e)[:200]}", + ) + except Exception as cancel_error: + logger.error( + f"取消预授权失败: {pre_auth.transaction_id}, " + f"错误: {cancel_error}" + ) + raise + + # ============================================================ + # 兼容方法(保留旧接口) + # ============================================================ + + async def deduct_with_freeze( + self, + user_id: str, + amount_units: int, + *, + reference_type: str | None = None, + reference_id: str | None = None, + description: str | None = None, + ) -> str: + """ + 冻结并预扣款(兼容方法,推荐使用 pre_authorize) + + Returns: + 交易ID + """ + result = await self.pre_authorize( + user_id, + amount_units, + reference_type=reference_type, + reference_id=reference_id, + description=description, + ) + return result.transaction_id + + async def confirm_frozen_deduction(self, transaction_id: str) -> BalanceTransaction: + """ + 确认冻结扣款(兼容方法,推荐使用 confirm) + """ + await self.confirm(transaction_id) + transaction = await self.transaction_repo.get_by_id(transaction_id) + return transaction # type: ignore + + async def cancel_frozen_deduction(self, transaction_id: str) -> BalanceTransaction: + """ + 取消冻结扣款(兼容方法,推荐使用 cancel) + """ + await self.cancel(transaction_id) + transaction = await self.transaction_repo.get_by_id(transaction_id) + return transaction # type: ignore + + # ============================================================ + # 充值操作(使用乐观锁 + 重试) + # ============================================================ + + async def recharge( + self, + user_id: str, + amount_units: int, + *, + reference_type: str | None = None, + reference_id: str | None = None, + description: str | None = None, + idempotency_key: str | None = None, + ) -> BalanceTransaction: + """ + 充值 + + 使用乐观锁,配合重试机制处理并发冲突。 + + Args: + user_id: 用户 ID + amount_units: 充值金额(单位额度,正数) + reference_type: 关联业务类型 + reference_id: 关联业务 ID + description: 交易描述 + idempotency_key: 幂等键 + + Returns: + 交易记录 + + Raises: + DuplicateTransactionError: 重复交易 + ConcurrencyError: 并发冲突(重试失败) + """ + if amount_units <= 0: + raise ValidationError("充值金额必须大于 0") + + # 检查幂等性 + if idempotency_key: + existing = await self.transaction_repo.get_by_idempotency_key( + idempotency_key + ) + if existing: + raise DuplicateTransactionError(idempotency_key) + + # 乐观锁重试 + for attempt in range(self.MAX_RETRIES): + balance = await self.balance_repo.get_or_create(user_id) + balance_before = balance.balance + + # 尝试更新余额 + success = await self.balance_repo.update_balance_optimistic( + balance, + amount_units, + is_recharge=True, + ) + + if success: + # 创建交易记录 + transaction = await self.transaction_repo.create( + user_id=user_id, + balance_account_id=balance.id, + transaction_type=TransactionType.RECHARGE, + status=TransactionStatus.COMPLETED, + amount=amount_units, # 正数表示收入 + balance_before=balance_before, + balance_after=balance.balance, + reference_type=reference_type, + reference_id=reference_id, + description=description, + idempotency_key=idempotency_key, + ) + + await self.balance_repo.commit() + + logger.info( + f"用户 {user_id} 充值成功: {amount_units} 单位, " + f"余额 {balance_before} -> {balance.balance}" + ) + + return transaction + + # 冲突,重试 + logger.warning( + f"用户 {user_id} 充值冲突,重试 {attempt + 1}/{self.MAX_RETRIES}" + ) + await self.balance_repo.rollback() + + # 重试失败 + raise ConcurrencyError() + + # ============================================================ + # 管理员操作 + # ============================================================ + + async def admin_adjust( + self, + user_id: str, + amount_units: int, + *, + operator_id: str, + reason: str, + ) -> BalanceTransaction: + """ + 管理员调整余额 + + Args: + user_id: 目标用户 ID + amount_units: 调整金额(正数增加,负数减少) + operator_id: 操作人 ID + reason: 调整原因 + + Returns: + 交易记录 + + Raises: + InsufficientBalanceError: 减少金额时余额不足 + """ + if amount_units == 0: + raise ValidationError("调整金额不能为 0") + + # 获取余额账户并加锁 + balance = await self.balance_repo.get_or_create_for_update(user_id) + + # 减少时检查余额 + if amount_units < 0 and balance.available_balance < abs(amount_units): + raise InsufficientBalanceError( + abs(amount_units), balance.available_balance + ) + + balance_before = balance.balance + + # 执行调整 + balance.balance += amount_units + if amount_units > 0: + balance.total_recharged += amount_units + balance.version += 1 + + # 创建交易记录 + transaction = await self.transaction_repo.create( + user_id=user_id, + balance_account_id=balance.id, + transaction_type=TransactionType.ADJUSTMENT, + status=TransactionStatus.COMPLETED, + amount=amount_units, + balance_before=balance_before, + balance_after=balance.balance, + description=reason, + operator_id=operator_id, + remark=f"管理员调整: {reason}", + ) + + await self.balance_repo.commit() + + logger.info( + f"管理员 {operator_id} 调整用户 {user_id} 余额: {amount_units} 单位, " + f"原因: {reason}" + ) + + return transaction + diff --git a/app/services/oauth2.py b/app/services/oauth2.py new file mode 100644 index 0000000..2f2a375 --- /dev/null +++ b/app/services/oauth2.py @@ -0,0 +1,395 @@ +""" +OAuth2 认证服务 + +处理 OAuth2 认证流程,支持主备端点自动切换。 +当首选端点不可达时,自动回退到备用端点。 +""" + +import logging +import secrets +from urllib.parse import urlencode + +import httpx +from sqlalchemy.ext.asyncio import AsyncSession + +from app.core.config import settings +from app.core.exceptions import ( + AuthenticationError, + ResourceConflictError, +) +from app.core.security import create_access_token, create_refresh_token +from app.models.user import User +from app.repositories.user import UserRepository +from app.schemas.auth import TokenResponse +from app.schemas.oauth2 import OAuth2TokenData, OAuth2UserInfo + +logger = logging.getLogger(__name__) + +# OAuth2 提供商标识 +OAUTH_PROVIDER_LINUXDO = "linuxdo" + + +class OAuth2EndpointError(AuthenticationError): + """OAuth2 端点错误""" + + def __init__(self, message: str = "OAuth2 服务不可用"): + super().__init__(message, "OAUTH2_ENDPOINT_ERROR") + + +class OAuth2StateError(AuthenticationError): + """OAuth2 状态验证错误""" + + def __init__(self, message: str = "无效的状态码"): + super().__init__(message, "OAUTH2_STATE_ERROR") + + +class OAuth2Service: + """ + OAuth2 认证服务 + + 特性: + - 支持主备端点自动切换 + - 首选端点请求失败时自动回退到备用端点 + - 状态码验证防止 CSRF 攻击 + """ + + # 存储状态码(生产环境应使用 Redis) + _state_store: dict[str, bool] = {} + + def __init__(self, session: AsyncSession): + """ + 初始化 OAuth2 服务 + + Args: + session: 数据库会话 + """ + self.session = session + self.user_repo = UserRepository(session) + + # 端点配置 + self._endpoints = { + "authorize": { + "primary": settings.oauth2_authorize_endpoint, + "reserve": settings.oauth2_authorize_endpoint_reserve, + }, + "token": { + "primary": settings.oauth2_token_endpoint, + "reserve": settings.oauth2_token_endpoint_reserve, + }, + "userinfo": { + "primary": settings.oauth2_user_info_endpoint, + "reserve": settings.oauth2_user_info_endpoint_reserve, + }, + } + + self._timeout = settings.oauth2_request_timeout + + def generate_authorize_url(self, redirect_uri: str) -> tuple[str, str]: + """ + 生成 OAuth2 授权 URL + + Args: + redirect_uri: 回调 URL + + Returns: + (授权 URL, 状态码) + """ + state = secrets.token_urlsafe(32) + self._state_store[state] = True # 存储状态码 + + params = { + "client_id": settings.oauth2_client_id, + "redirect_uri": redirect_uri, + "response_type": "code", + "state": state, + "scope": "read", # 根据实际需要调整 + } + + # 使用首选授权端点 + authorize_url = f"{self._endpoints['authorize']['primary']}?{urlencode(params)}" + + return authorize_url, state + + def validate_state(self, state: str) -> bool: + """ + 验证状态码(防 CSRF) + + Args: + state: 状态码 + + Returns: + 是否有效 + """ + if state in self._state_store: + del self._state_store[state] # 使用后立即删除 + return True + return False + + async def _request_with_fallback( + self, + endpoint_type: str, + method: str, + **kwargs, + ) -> httpx.Response: + """ + 带回退的 HTTP 请求 + + 首先尝试首选端点,失败后自动切换到备用端点。 + + Args: + endpoint_type: 端点类型(token/userinfo) + method: HTTP 方法 + **kwargs: 请求参数 + + Returns: + 响应对象 + + Raises: + OAuth2EndpointError: 所有端点都不可用 + """ + endpoints = self._endpoints[endpoint_type] + last_error: Exception | None = None + + for endpoint_name, url in [("primary", endpoints["primary"]), ("reserve", endpoints["reserve"])]: + try: + logger.debug(f"尝试 OAuth2 {endpoint_type} 端点 ({endpoint_name}): {url}") + + async with httpx.AsyncClient(timeout=self._timeout) as client: + if method.upper() == "POST": + response = await client.post(url, **kwargs) + else: + response = await client.get(url, **kwargs) + + # 检查 HTTP 状态 + if response.status_code >= 500: + logger.warning( + f"OAuth2 {endpoint_type} 端点 ({endpoint_name}) " + f"返回服务器错误: {response.status_code}" + ) + continue + + logger.info(f"OAuth2 {endpoint_type} 请求成功 ({endpoint_name})") + return response + + except httpx.TimeoutException as e: + logger.warning(f"OAuth2 {endpoint_type} 端点 ({endpoint_name}) 超时: {e}") + last_error = e + except httpx.ConnectError as e: + logger.warning(f"OAuth2 {endpoint_type} 端点 ({endpoint_name}) 连接失败: {e}") + last_error = e + except Exception as e: + logger.error(f"OAuth2 {endpoint_type} 端点 ({endpoint_name}) 请求异常: {e}") + last_error = e + + # 所有端点都失败 + error_msg = f"OAuth2 {endpoint_type} 服务不可用" + if last_error: + error_msg += f": {last_error}" + raise OAuth2EndpointError(error_msg) + + async def exchange_code_for_token( + self, + code: str, + redirect_uri: str, + ) -> OAuth2TokenData: + """ + 用授权码换取访问令牌 + + Args: + code: 授权码 + redirect_uri: 回调 URL(必须与授权时一致) + + Returns: + OAuth2 令牌数据 + + Raises: + OAuth2EndpointError: 端点不可用 + AuthenticationError: 换取令牌失败 + """ + data = { + "grant_type": "authorization_code", + "client_id": settings.oauth2_client_id, + "client_secret": settings.oauth2_client_secret, + "code": code, + "redirect_uri": redirect_uri, + } + + response = await self._request_with_fallback( + "token", + "POST", + data=data, + headers={"Accept": "application/json"}, + ) + + if response.status_code != 200: + logger.error(f"OAuth2 token 响应错误: {response.status_code} - {response.text}") + raise AuthenticationError( + f"获取访问令牌失败: {response.status_code}", + "OAUTH2_TOKEN_ERROR", + ) + + token_data = response.json() + return OAuth2TokenData(**token_data) + + async def get_user_info(self, access_token: str) -> OAuth2UserInfo: + """ + 获取 OAuth2 用户信息 + + Args: + access_token: OAuth2 访问令牌 + + Returns: + 用户信息 + + Raises: + OAuth2EndpointError: 端点不可用 + AuthenticationError: 获取用户信息失败 + """ + response = await self._request_with_fallback( + "userinfo", + "GET", + headers={ + "Authorization": f"Bearer {access_token}", + "Accept": "application/json", + }, + ) + + if response.status_code != 200: + logger.error(f"OAuth2 userinfo 响应错误: {response.status_code} - {response.text}") + raise AuthenticationError( + f"获取用户信息失败: {response.status_code}", + "OAUTH2_USERINFO_ERROR", + ) + + user_data = response.json() + return OAuth2UserInfo(**user_data) + + async def authenticate( + self, + code: str, + state: str, + redirect_uri: str, + ) -> tuple[User, TokenResponse, bool]: + """ + 完整的 OAuth2 认证流程 + + 1. 验证状态码 + 2. 用授权码换取令牌 + 3. 获取用户信息 + 4. 创建或更新用户 + 5. 生成 JWT 令牌 + + Args: + code: 授权码 + state: 状态码 + redirect_uri: 回调 URL + + Returns: + (用户对象, JWT 令牌响应, 是否新用户) + + Raises: + OAuth2StateError: 状态码无效 + OAuth2EndpointError: OAuth2 服务不可用 + AuthenticationError: 认证失败 + """ + # 1. 验证状态码 + if not self.validate_state(state): + raise OAuth2StateError() + + # 2. 换取令牌 + oauth_token = await self.exchange_code_for_token(code, redirect_uri) + + # 3. 获取用户信息 + oauth_user = await self.get_user_info(oauth_token.access_token) + + # 4. 查找或创建用户 + user, is_new_user = await self._get_or_create_user(oauth_user) + + # 5. 生成 JWT 令牌 + tokens = self._create_tokens(user) + + return user, tokens, is_new_user + + async def _get_or_create_user( + self, + oauth_user: OAuth2UserInfo, + ) -> tuple[User, bool]: + """ + 根据 OAuth2 用户信息获取或创建本地用户 + + Args: + oauth_user: OAuth2 用户信息 + + Returns: + (用户对象, 是否新创建) + """ + oauth_user_id = str(oauth_user.id) + + # 先通过 OAuth ID 查找 + user = await self.user_repo.get_by_oauth( + provider=OAUTH_PROVIDER_LINUXDO, + oauth_user_id=oauth_user_id, + ) + + if user: + # 更新用户信息(头像等可能变化) + await self.user_repo.update( + user, + nickname=oauth_user.name or oauth_user.username, + avatar_url=oauth_user.avatar_url, + ) + await self.user_repo.commit() + return user, False + + # 检查用户名是否已存在 + username = oauth_user.username.lower() + existing_user = await self.user_repo.get_by_username(username) + if existing_user: + # 用户名冲突,添加后缀 + username = f"{username}_{oauth_user_id[:8]}" + + # 创建新用户 + user = await self.user_repo.create( + username=username, + email=oauth_user.email, + nickname=oauth_user.name or oauth_user.username, + avatar_url=oauth_user.avatar_url, + oauth_provider=OAUTH_PROVIDER_LINUXDO, + oauth_user_id=oauth_user_id, + hashed_password=None, # OAuth2 用户无密码 + is_active=oauth_user.active, + ) + + await self.user_repo.commit() + logger.info(f"创建 OAuth2 用户: {user.username} (provider={OAUTH_PROVIDER_LINUXDO})") + + return user, True + + def _create_tokens(self, user: User) -> TokenResponse: + """ + 为用户创建 JWT 令牌 + + Args: + user: 用户对象 + + Returns: + 令牌响应 + """ + access_token = create_access_token( + subject=user.id, + extra_claims={ + "username": user.username, + "is_superuser": user.is_superuser, + "oauth_provider": user.oauth_provider, + }, + ) + + refresh_token = create_refresh_token(subject=user.id) + + return TokenResponse( + access_token=access_token, + refresh_token=refresh_token, + token_type="Bearer", + expires_in=settings.access_token_expire_minutes * 60, + ) + diff --git a/app/services/redeem_code.py b/app/services/redeem_code.py new file mode 100644 index 0000000..00710b1 --- /dev/null +++ b/app/services/redeem_code.py @@ -0,0 +1,570 @@ +""" +兑换码服务 + +处理兑换码相关的业务逻辑。 + +设计说明: +- 兑换操作使用行级锁确保原子性 +- 支持批量生成和导入导出 +- 记录完整的使用日志 +""" + +import logging +from datetime import datetime, timezone +from typing import Any + +from sqlalchemy.ext.asyncio import AsyncSession + +from app.core.exceptions import ( + AppException, + ResourceNotFoundError, + ValidationError, +) +from app.models.redeem_code import ( + RedeemCode, + RedeemCodeBatch, + RedeemCodeUsageLog, + RedeemCodeStatus, + generate_redeem_code, +) +from app.models.balance import TransactionType +from app.repositories.redeem_code import ( + RedeemCodeRepository, + RedeemCodeBatchRepository, + RedeemCodeUsageLogRepository, +) +from app.services.balance import BalanceService + +logger = logging.getLogger(__name__) + + +class RedeemCodeNotFoundError(AppException): + """兑换码不存在""" + + def __init__(self, code: str): + super().__init__( + "兑换码不存在", + "REDEEM_CODE_NOT_FOUND", + {"code": code}, + ) + + +class RedeemCodeInvalidError(AppException): + """兑换码无效""" + + def __init__(self, code: str, reason: str): + super().__init__( + f"兑换码无效: {reason}", + "REDEEM_CODE_INVALID", + {"code": code, "reason": reason}, + ) + + +class RedeemCodeExpiredError(AppException): + """兑换码已过期""" + + def __init__(self, code: str): + super().__init__( + "兑换码已过期", + "REDEEM_CODE_EXPIRED", + {"code": code}, + ) + + +class RedeemCodeUsedError(AppException): + """兑换码已使用""" + + def __init__(self, code: str): + super().__init__( + "兑换码已使用", + "REDEEM_CODE_USED", + {"code": code}, + ) + + +class RedeemCodeDisabledError(AppException): + """兑换码已禁用""" + + def __init__(self, code: str): + super().__init__( + "兑换码已禁用", + "REDEEM_CODE_DISABLED", + {"code": code}, + ) + + +class RedeemCodeService: + """兑换码服务""" + + def __init__(self, session: AsyncSession): + """ + 初始化兑换码服务 + + Args: + session: 数据库会话 + """ + self.session = session + self.code_repo = RedeemCodeRepository(session) + self.batch_repo = RedeemCodeBatchRepository(session) + self.log_repo = RedeemCodeUsageLogRepository(session) + self.balance_service = BalanceService(session) + + # ============================================================ + # 用户兑换 + # ============================================================ + + async def redeem( + self, + user_id: str, + code: str, + *, + ip_address: str | None = None, + user_agent: str | None = None, + ) -> dict[str, Any]: + """ + 用户兑换余额 + + 使用行级锁确保原子性,防止并发兑换。 + + Args: + user_id: 用户 ID + code: 兑换码 + ip_address: 客户端 IP + user_agent: User Agent + + Returns: + 兑换结果 + + Raises: + RedeemCodeNotFoundError: 兑换码不存在 + RedeemCodeInvalidError: 兑换码无效 + """ + # 标准化兑换码 + normalized_code = code.strip().upper().replace(" ", "") + + # 获取兑换码并加锁 + redeem_code = await self.code_repo.get_by_code_for_update(normalized_code) + + if not redeem_code: + raise RedeemCodeNotFoundError(normalized_code) + + # 验证兑换码状态 + self._validate_redeem_code(redeem_code) + + # 获取用户当前余额 + balance = await self.balance_service.get_balance(user_id) + balance_before = balance.balance + + # 执行充值 + transaction = await self.balance_service.recharge( + user_id, + redeem_code.face_value, + reference_type="redeem_code", + reference_id=redeem_code.id, + description=f"兑换码充值: {redeem_code.code}", + ) + + # 标记兑换码已使用 + await self.code_repo.mark_as_used(redeem_code, user_id) + + # 更新批次统计 + if redeem_code.batch_id: + await self.batch_repo.increment_used_count(redeem_code.batch_id) + + # 记录使用日志 + await self.log_repo.create( + redeem_code_id=redeem_code.id, + user_id=user_id, + transaction_id=transaction.id, + code_snapshot=redeem_code.code, + face_value=redeem_code.face_value, + ip_address=ip_address, + user_agent=user_agent, + ) + + await self.code_repo.commit() + + logger.info( + f"用户 {user_id} 兑换成功: {redeem_code.code}, " + f"面值 {redeem_code.face_value} 单位" + ) + + return { + "success": True, + "message": "兑换成功", + "face_value": f"{redeem_code.face_value / 1000:.2f}", + "balance_before": f"{balance_before / 1000:.2f}", + "balance_after": f"{transaction.balance_after / 1000:.2f}", + } + + def _validate_redeem_code(self, code: RedeemCode) -> None: + """验证兑换码有效性""" + if code.status == RedeemCodeStatus.DISABLED: + raise RedeemCodeDisabledError(code.code) + + if code.status == RedeemCodeStatus.USED or code.used_count >= code.max_uses: + raise RedeemCodeUsedError(code.code) + + if code.expires_at and code.expires_at < datetime.now(timezone.utc): + raise RedeemCodeExpiredError(code.code) + + # ============================================================ + # 管理员:批量生成 + # ============================================================ + + async def create_batch( + self, + name: str, + face_value_units: int, + count: int, + *, + created_by: str, + description: str | None = None, + max_uses: int = 1, + expires_at: datetime | None = None, + ) -> RedeemCodeBatch: + """ + 创建兑换码批次 + + 批量生成指定数量的兑换码。 + + Args: + name: 批次名称 + face_value_units: 面值(单位额度) + count: 生成数量 + created_by: 创建者 ID + description: 批次描述 + max_uses: 每个兑换码最大使用次数 + expires_at: 过期时间 + + Returns: + 创建的批次 + """ + if face_value_units <= 0: + raise ValidationError("面值必须大于 0") + if count <= 0 or count > 10000: + raise ValidationError("数量必须在 1-10000 之间") + + # 创建批次 + batch = await self.batch_repo.create( + name=name, + description=description, + face_value=face_value_units, + total_count=count, + created_by=created_by, + ) + + # 批量生成兑换码 + codes_data = [] + generated_codes = set() + + while len(codes_data) < count: + new_code = generate_redeem_code() + if new_code not in generated_codes: + generated_codes.add(new_code) + codes_data.append({ + "code": new_code, + "batch_id": batch.id, + "face_value": face_value_units, + "max_uses": max_uses, + "expires_at": expires_at, + "created_by": created_by, + }) + + await self.code_repo.bulk_create(codes_data) + await self.batch_repo.commit() + + logger.info( + f"管理员 {created_by} 创建批次 '{name}': " + f"{count} 个兑换码, 面值 {face_value_units} 单位" + ) + + return batch + + # ============================================================ + # 管理员:导入 + # ============================================================ + + async def import_codes( + self, + codes: list[dict[str, Any]], + *, + created_by: str, + batch_name: str | None = None, + ) -> dict[str, Any]: + """ + 导入兑换码 + + Args: + codes: 兑换码数据列表 + created_by: 创建者 ID + batch_name: 批次名称(可选) + + Returns: + 导入结果 + """ + batch_id = None + + # 创建批次(如果指定) + if batch_name: + # 计算总面值用于批次记录 + total_face_value = sum(c.get("face_value_units", 0) for c in codes) + batch = await self.batch_repo.create( + name=batch_name, + description="导入批次", + face_value=total_face_value // len(codes) if codes else 0, + total_count=len(codes), + created_by=created_by, + ) + batch_id = batch.id + + success_count = 0 + failed_codes = [] + + for code_data in codes: + try: + # 检查兑换码是否已存在 + existing = await self.code_repo.get_by_code(code_data["code"]) + if existing: + failed_codes.append(code_data["code"]) + continue + + # 创建兑换码 + await self.code_repo.create( + code=code_data["code"].strip().upper(), + batch_id=batch_id, + face_value=code_data["face_value_units"], + max_uses=code_data.get("max_uses", 1), + expires_at=code_data.get("expires_at"), + remark=code_data.get("remark"), + created_by=created_by, + ) + success_count += 1 + + except Exception as e: + logger.warning(f"导入兑换码失败: {code_data.get('code')}, {e}") + failed_codes.append(code_data.get("code", "unknown")) + + await self.code_repo.commit() + + logger.info( + f"管理员 {created_by} 导入兑换码: " + f"成功 {success_count}, 失败 {len(failed_codes)}" + ) + + return { + "success_count": success_count, + "failed_count": len(failed_codes), + "failed_codes": failed_codes, + "batch_id": batch_id, + } + + # ============================================================ + # 管理员:导出 + # ============================================================ + + async def export_codes( + self, + *, + batch_id: str | None = None, + status: RedeemCodeStatus | None = None, + limit: int = 10000, + ) -> list[dict[str, Any]]: + """ + 导出兑换码 + + Args: + batch_id: 批次 ID 过滤 + status: 状态过滤 + limit: 最大导出数量 + + Returns: + 兑换码数据列表 + """ + codes = await self.code_repo.get_all_with_filters( + batch_id=batch_id, + status=status, + limit=limit, + ) + + result = [] + for code in codes: + result.append({ + "code": code.code, + "face_value": f"{code.face_value / 1000:.2f}", + "status": code.status.value, + "max_uses": code.max_uses, + "used_count": code.used_count, + "expires_at": code.expires_at.isoformat() if code.expires_at else None, + "created_at": code.created_at.isoformat(), + "used_at": code.used_at.isoformat() if code.used_at else None, + "used_by": code.used_by, + }) + + return result + + # ============================================================ + # 管理员:查询 + # ============================================================ + + async def get_codes( + self, + *, + offset: int = 0, + limit: int = 20, + status: RedeemCodeStatus | None = None, + batch_id: str | None = None, + code_like: str | None = None, + created_after: datetime | None = None, + created_before: datetime | None = None, + ) -> tuple[list[RedeemCode], int]: + """ + 获取兑换码列表 + + Returns: + (兑换码列表, 总数) + """ + codes = await self.code_repo.get_all_with_filters( + offset=offset, + limit=limit, + status=status, + batch_id=batch_id, + code_like=code_like, + created_after=created_after, + created_before=created_before, + ) + total = await self.code_repo.count_with_filters( + status=status, + batch_id=batch_id, + code_like=code_like, + created_after=created_after, + created_before=created_before, + ) + return codes, total + + async def get_code_detail(self, code_id: str) -> RedeemCode: + """ + 获取兑换码详情 + + Args: + code_id: 兑换码 ID + + Returns: + 兑换码记录 + """ + code = await self.code_repo.get_by_id(code_id) + if not code: + raise ResourceNotFoundError("兑换码不存在", "redeem_code", code_id) + return code + + async def disable_code(self, code_id: str) -> RedeemCode: + """ + 禁用兑换码 + + Args: + code_id: 兑换码 ID + + Returns: + 更新后的兑换码 + """ + code = await self.get_code_detail(code_id) + code = await self.code_repo.disable_code(code) + await self.code_repo.commit() + + logger.info(f"兑换码已禁用: {code.code}") + return code + + async def enable_code(self, code_id: str) -> RedeemCode: + """ + 启用兑换码 + + Args: + code_id: 兑换码 ID + + Returns: + 更新后的兑换码 + """ + code = await self.get_code_detail(code_id) + code = await self.code_repo.enable_code(code) + await self.code_repo.commit() + + logger.info(f"兑换码已启用: {code.code}") + return code + + # ============================================================ + # 管理员:批次管理 + # ============================================================ + + async def get_batches( + self, + *, + offset: int = 0, + limit: int = 20, + ) -> tuple[list[RedeemCodeBatch], int]: + """ + 获取批次列表 + + Returns: + (批次列表, 总数) + """ + batches = await self.batch_repo.get_all_batches( + offset=offset, + limit=limit, + ) + total = await self.batch_repo.count() + return batches, total + + async def get_batch_detail(self, batch_id: str) -> RedeemCodeBatch: + """ + 获取批次详情 + + Args: + batch_id: 批次 ID + + Returns: + 批次记录 + """ + batch = await self.batch_repo.get_by_id(batch_id) + if not batch: + raise ResourceNotFoundError("批次不存在", "batch", batch_id) + return batch + + # ============================================================ + # 管理员:使用日志 + # ============================================================ + + async def get_usage_logs( + self, + *, + offset: int = 0, + limit: int = 20, + redeem_code_id: str | None = None, + user_id: str | None = None, + code_like: str | None = None, + created_after: datetime | None = None, + created_before: datetime | None = None, + ) -> tuple[list[RedeemCodeUsageLog], int]: + """ + 获取使用日志 + + Returns: + (日志列表, 总数) + """ + logs = await self.log_repo.get_all_with_filters( + offset=offset, + limit=limit, + redeem_code_id=redeem_code_id, + user_id=user_id, + code_like=code_like, + created_after=created_after, + created_before=created_before, + ) + total = await self.log_repo.count_with_filters( + redeem_code_id=redeem_code_id, + user_id=user_id, + code_like=code_like, + created_after=created_after, + created_before=created_before, + ) + return logs, total + diff --git a/app/services/user.py b/app/services/user.py new file mode 100644 index 0000000..6df3be6 --- /dev/null +++ b/app/services/user.py @@ -0,0 +1,175 @@ +""" +用户服务 + +处理用户相关的业务逻辑。 +""" + +from datetime import datetime, timezone + +from sqlalchemy.ext.asyncio import AsyncSession + +from app.core.exceptions import ( + UserAlreadyExistsError, + UserNotFoundError, +) +from app.core.security import hash_password +from app.models.user import User +from app.repositories.user import UserRepository +from app.schemas.user import UserCreate, UserUpdate + + +class UserService: + """用户服务""" + + def __init__(self, session: AsyncSession): + """ + 初始化用户服务 + + Args: + session: 数据库会话 + """ + self.session = session + self.user_repo = UserRepository(session) + + async def create_user(self, user_data: UserCreate) -> User: + """ + 创建新用户 + + Args: + user_data: 用户注册数据 + + Returns: + 新创建的用户 + + Raises: + UserAlreadyExistsError: 用户名或邮箱已存在 + """ + # 检查用户名是否已存在 + if await self.user_repo.exists_by_username(user_data.username): + raise UserAlreadyExistsError("用户名") + + # 检查邮箱是否已存在 + if user_data.email and await self.user_repo.exists_by_email(user_data.email): + raise UserAlreadyExistsError("邮箱") + + # 创建用户 + user = await self.user_repo.create( + username=user_data.username.lower(), + email=user_data.email.lower() if user_data.email else None, + nickname=user_data.nickname, + hashed_password=hash_password(user_data.password), + ) + + await self.user_repo.commit() + return user + + async def get_user_by_id(self, user_id: str) -> User: + """ + 通过 ID 获取用户 + + Args: + user_id: 用户 ID + + Returns: + 用户对象 + + Raises: + UserNotFoundError: 用户不存在 + """ + user = await self.user_repo.get_by_id(user_id) + if not user: + raise UserNotFoundError(user_id) + return user + + async def get_user_by_username(self, username: str) -> User | None: + """ + 通过用户名获取用户 + + Args: + username: 用户名 + + Returns: + 用户对象或 None + """ + return await self.user_repo.get_by_username(username) + + async def update_user( + self, + user_id: str, + update_data: UserUpdate, + ) -> User: + """ + 更新用户信息 + + Args: + user_id: 用户 ID + update_data: 更新数据 + + Returns: + 更新后的用户 + + Raises: + UserNotFoundError: 用户不存在 + UserAlreadyExistsError: 邮箱已被使用 + """ + user = await self.get_user_by_id(user_id) + + # 检查邮箱是否被其他用户使用 + if update_data.email: + existing_user = await self.user_repo.get_by_email(update_data.email) + if existing_user and existing_user.id != user_id: + raise UserAlreadyExistsError("邮箱") + + # 准备更新数据 + update_dict = update_data.model_dump(exclude_unset=True) + if update_dict.get("email"): + update_dict["email"] = update_dict["email"].lower() + + # 更新用户 + user = await self.user_repo.update(user, **update_dict) + await self.user_repo.commit() + return user + + async def update_last_login(self, user: User) -> None: + """ + 更新用户最后登录时间 + + Args: + user: 用户对象 + """ + await self.user_repo.update( + user, + last_login_at=datetime.now(timezone.utc), + ) + await self.user_repo.commit() + + async def deactivate_user(self, user_id: str) -> User: + """ + 禁用用户账户 + + Args: + user_id: 用户 ID + + Returns: + 更新后的用户 + """ + user = await self.get_user_by_id(user_id) + user = await self.user_repo.update(user, is_active=False) + await self.user_repo.commit() + return user + + async def activate_user(self, user_id: str) -> User: + """ + 激活用户账户 + + Args: + user_id: 用户 ID + + Returns: + 更新后的用户 + """ + user = await self.get_user_by_id(user_id) + user = await self.user_repo.update(user, is_active=True) + await self.user_repo.commit() + return user + diff --git a/config.yaml.example b/config.yaml.example new file mode 100644 index 0000000..9b690f4 --- /dev/null +++ b/config.yaml.example @@ -0,0 +1,68 @@ +# ============================================================================= +# 安全配置 +# ============================================================================= +secret_key: CHANGE-THIS-SECRET-KEY-IN-PRODUCTION +algorithm: HS256 +access_token_expire_minutes: 30 +refresh_token_expire_days: 7 + +# ============================================================================= +# 数据库配置 +# ============================================================================= +database_type: sqlite +database_host: localhost +database_port: 3306 +database_name: satonano +database_username: satonano +database_password: your_password_here +database_echo: false + +# SQLite 专用(当 database_type=sqlite 时使用) +database_sqlite_path: ./satonano.db + +# ============================================================================= +# OAuth2 配置 (Linux.do) +# ============================================================================= +oauth2_client_id: your_client_id +oauth2_client_secret: your_client_secret +# 回调路径(指向前端页面,非后端API) +# 开发环境在 OAuth2 提供商处配置为: http://localhost:3000/oauth2/callback +# 生产环境在 OAuth2 提供商处配置为: https://your-domain.com/oauth2/callback +oauth2_callback_path: /oauth2/callback + +# 首选端点 +oauth2_authorize_endpoint: https://connect.linux.do/oauth2/authorize +oauth2_token_endpoint: https://connect.linux.do/oauth2/token +oauth2_user_info_endpoint: https://connect.linux.do/api/user + +# 备用端点(首选不可达时自动回退) +oauth2_authorize_endpoint_reserve: https://connect.linuxdo.org/oauth2/authorize +oauth2_token_endpoint_reserve: https://connect.linuxdo.org/oauth2/token +oauth2_user_info_endpoint_reserve: https://connect.linuxdo.org/api/user + +# 请求超时(秒) +oauth2_request_timeout: 10 + +# ============================================================================= +# 密码策略 +# ============================================================================= +password_min_length: 8 +password_max_length: 128 +password_require_uppercase: true +password_require_lowercase: true +password_require_digit: true +password_require_special: false + +# ============================================================================= +# 用户名策略 +# ============================================================================= +username_min_length: 3 +username_max_length: 32 + +# ============================================================================= +# 前端静态文件配置 +# ============================================================================= +# 前端构建产物的路径(相对于项目根目录或绝对路径) +# Next.js 静态导出: ./frontend/out +# Vite 构建: ./frontend/dist +frontend_static_path: ./frontend/out \ No newline at end of file diff --git a/data/data.db b/data/data.db new file mode 100644 index 0000000000000000000000000000000000000000..a44d13a2b66785dff6708a4f5c41867bb69c7160 GIT binary patch literal 28672 zcmeI)&2QRf90zb4k`PBt=?;|-Q8gbTEocFZ@f(>U)k#RlN=P7(rrQBMU;|#vOKn45 zE)$!ksoMY29d_Gc|G^Hs?H`ylsh3LKq#b7)NI*@iYT99mzLpHOpXd2K&-1|`{Ve0d zV%~HOuFes+LatbOqoYaHsV*jmVx_qSHpbGGE?rc)(#*Blt!*8YAzs}*Jj?3FtG-stqYwnE3OpUlii7K5;4KwM&1 z`?hu2qm&YYqMF&|%Gu+xKeoDU5Z9ZUmnrXfXKp#Sm*sY{yILh*=C&)PQnpa8`Uelo z+TOv;$of6~U$(S}<5sP1)9g%l>yPH3l-tuvPr1k0r`(#U$ChHT&;q;3(o}GQInOLF zv#)yJyKb;Q{vxJ=lOgQ=(D?a1wd}2-y9{;rPwxc_1Rwwb2tWV=5P$##AOHaf+ukW@nYy&2C39 z_0_>nq>KqL|K9Wz%yAogQS&eqjJv{xgxZ3=jG+U2$50dp_ zvj3T`S(UBh!dW?|WUOZAg4pJhy_!`lKW^;i1YVHid@9b%Tq?C8W;R46A;^-~&2=Sd zSrygP^(9J1QNL#B4=O9e2h_@aX7R&e#G5O{3q({ELyZ%@p~S_SRF4ypG~$Fb>O8O1 zRkfaJnGSJnQ)=m!-D-5&XXlxVwwtbH27SqCT(nw(`0QNd1-)mc6)A0r7gCeAPI@N~ zd$#FaVK8jNBIgOq?DWqPdN+92yMm~yzkmDukDs4w+mBkV+jBOO$w{4LaJgr6dE)Be zcpynZRg;3ut4dW!^g7MU8B1JB+z{mrNlgf8mCsx$y-~8{ebk}o4^;Fw?*$74AOHaf zKmY;|fB*y_009U<00RF9fwgdjexJ)Sp^w59=6$YdjPn22RP?oXlRg#*KmY;|fB*y_ z009U<00Izz00eG}z+9N3Ly_=(#=rAml>fh=qA#L9-j)es9uR;41Rwwb2tWV=5P$## zAOL}zEfA#c`MKc(=D+$A!YKcLNkv~q|GL>W7(E0a009U<00Izz00bZa0SG_<0-gX9 zX6fK@4WXs*3NwC&z$pKJMMYmB|HoMZ0SG_<0uX=z1Rwwb2tWV=5V$P@!5svC{y%>D F;6DKu4C?>@ literal 0 HcmV?d00001 diff --git a/docs/architecture.md b/docs/architecture.md new file mode 100644 index 0000000..20ee006 --- /dev/null +++ b/docs/architecture.md @@ -0,0 +1,303 @@ +# 认证系统架构设计文档 + +## 技术栈 + +| 组件 | 技术选型 | 说明 | +|------|----------|------| +| Web 框架 | FastAPI 0.128+ | 异步、高性能、自动 OpenAPI 文档 | +| ORM | SQLAlchemy 2.0+ | 异步支持、类型安全 | +| 数据库 | SQLite (aiosqlite) | 开发环境,可切换 PostgreSQL | +| 密码哈希 | Argon2 | 密码学家推荐的哈希算法 | +| 令牌 | PyJWT | JSON Web Token 实现 | +| 数据验证 | Pydantic v2 | 高性能数据验证 | +| 配置管理 | pydantic-settings | 类型安全的环境变量配置 | + +## 项目结构 + +``` +app/ +├── __init__.py +├── main.py # FastAPI 应用入口 +├── database.py # 数据库连接与会话管理 +│ +├── core/ # 核心功能模块 +│ ├── config.py # 配置管理 +│ ├── security.py # 安全功能(密码哈希、JWT) +│ └── exceptions.py # 自定义异常类 +│ +├── models/ # SQLAlchemy ORM 模型 +│ └── user.py # 用户数据模型 +│ +├── schemas/ # Pydantic 数据模式 +│ ├── base.py # 基础响应格式 +│ ├── user.py # 用户相关 Schema +│ └── auth.py # 认证相关 Schema +│ +├── repositories/ # 数据访问层 (Repository Pattern) +│ ├── base.py # 基础 CRUD 操作 +│ └── user.py # 用户数据仓库 +│ +├── services/ # 业务逻辑层 (Service Layer) +│ ├── user.py # 用户服务 +│ └── auth.py # 认证服务 +│ +└── api/ # API 路由层 + ├── deps.py # 依赖注入定义 + └── v1/ + ├── router.py # 路由聚合 + └── endpoints/ + ├── auth.py # 认证接口 + └── users.py # 用户接口 +``` + +## 分层架构 + +``` +┌─────────────────────────────────────────────┐ +│ API Layer │ +│ (FastAPI Endpoints + Deps) │ +├─────────────────────────────────────────────┤ +│ Service Layer │ +│ (Business Logic + Rules) │ +├─────────────────────────────────────────────┤ +│ Repository Layer │ +│ (Data Access + Queries) │ +├─────────────────────────────────────────────┤ +│ Model Layer │ +│ (SQLAlchemy ORM Models) │ +├─────────────────────────────────────────────┤ +│ Database │ +│ (SQLite / PostgreSQL) │ +└─────────────────────────────────────────────┘ +``` + +### 各层职责 + +| 层 | 职责 | 示例 | +|----|------|------| +| **API Layer** | 处理 HTTP 请求/响应、参数验证、依赖注入 | `auth.py`, `users.py` | +| **Service Layer** | 业务逻辑、规则校验、跨仓库协调 | `AuthService`, `UserService` | +| **Repository Layer** | 数据库操作封装、查询构建 | `UserRepository` | +| **Model Layer** | 数据结构定义、表关系映射 | `User` | + +## 数据流 + +### 用户注册流程 + +``` +Client Request + │ + ▼ +┌─────────────────┐ +│ API Endpoint │ POST /api/v1/auth/register +│ (auth.py) │ 接收请求、验证 Schema +└────────┬────────┘ + │ UserCreate + ▼ +┌─────────────────┐ +│ UserService │ 检查用户名/邮箱唯一性 +│ (user.py) │ 哈希密码 +└────────┬────────┘ + │ + ▼ +┌─────────────────┐ +│ UserRepository │ 创建用户记录 +│ (user.py) │ 提交事务 +└────────┬────────┘ + │ + ▼ +┌─────────────────┐ +│ Database │ INSERT INTO users +└─────────────────┘ +``` + +### 用户登录流程 + +``` +Client Request + │ + ▼ +┌─────────────────┐ +│ API Endpoint │ POST /api/v1/auth/login +│ (auth.py) │ 接收凭证 +└────────┬────────┘ + │ LoginRequest + ▼ +┌─────────────────┐ +│ AuthService │ 1. 查找用户 +│ (auth.py) │ 2. 验证密码 +│ │ 3. 检查用户状态 +│ │ 4. 更新登录时间 +│ │ 5. 生成 JWT +└────────┬────────┘ + │ + ▼ +┌─────────────────┐ +│ UserRepository │ 查询用户 +│ (user.py) │ 更新 last_login_at +└────────┬────────┘ + │ + ▼ + TokenResponse +``` + +### 认证流程 (受保护接口) + +``` +Client Request + Bearer Token + │ + ▼ +┌─────────────────┐ +│ HTTPBearer │ 提取 Authorization header +│ (FastAPI) │ +└────────┬────────┘ + │ + ▼ +┌─────────────────┐ +│ get_current_user│ 1. 解码 JWT +│ (deps.py) │ 2. 验证签名和过期 +│ │ 3. 查询用户 +│ │ 4. 检查用户状态 +└────────┬────────┘ + │ User + ▼ +┌─────────────────┐ +│ API Endpoint │ 使用已认证用户执行业务逻辑 +└─────────────────┘ +``` + +## 安全设计 + +### 密码存储 + +使用 **Argon2id** 算法(密码哈希竞赛获胜算法): + +```python +# 参数配置 +time_cost=3 # 迭代次数 +memory_cost=65536 # 内存使用 (64MB) +parallelism=4 # 并行度 +``` + +特性: +- 抗 GPU/ASIC 攻击 +- 可调参数适应硬件升级 +- 自动包含盐值 + +### JWT 令牌 + +**Access Token:** +- 算法:HS256 +- 有效期:30 分钟(可配置) +- 包含:用户 ID、用户名、角色 + +**Refresh Token:** +- 算法:HS256 +- 有效期:7 天(可配置) +- 仅包含:用户 ID + +### 防护措施 + +| 威胁 | 防护 | +|------|------| +| 暴力破解 | Argon2 计算成本 | +| 时序攻击 | 无论用户是否存在都执行密码验证 | +| Token 泄露 | 短期 Access Token + 长期 Refresh Token | +| SQL 注入 | SQLAlchemy 参数化查询 | +| XSS | JSON 响应(非 HTML) | + +## 扩展点 + +### 邀请码注册 + +```python +# schemas/user.py +class UserCreate(UserBase): + password: str + invite_code: str | None = None # 新增字段 + +# services/user.py +async def create_user(self, user_data: UserCreate) -> User: + if settings.require_invite_code: + await self._validate_invite_code(user_data.invite_code) + # ... 原有逻辑 +``` + +### OAuth2 登录 + +```python +# services/oauth.py +class OAuthService: + async def authenticate_google(self, code: str) -> User: + ... + + async def authenticate_github(self, code: str) -> User: + ... + +# api/v1/endpoints/oauth.py +@router.get("/google/callback") +async def google_callback(code: str, oauth: OAuthService = Depends()): + user = await oauth.authenticate_google(code) + tokens = auth_service.create_tokens(user) + return tokens +``` + +### 令牌黑名单 + +```python +# models/token_blacklist.py +class TokenBlacklist(Base): + __tablename__ = "token_blacklist" + + jti: Mapped[str] = mapped_column(primary_key=True) + expires_at: Mapped[datetime] + +# services/auth.py +async def logout(self, token: str) -> None: + payload = decode_token(token) + await self.blacklist_repo.add(payload["jti"], payload["exp"]) +``` + +## 配置参考 + +```bash +# .env 配置示例 + +# 环境 +ENVIRONMENT=development # development | staging | production +DEBUG=true + +# 安全 +SECRET_KEY=your-256-bit-secret-key +ACCESS_TOKEN_EXPIRE_MINUTES=30 +REFRESH_TOKEN_EXPIRE_DAYS=7 + +# 数据库 +DATABASE_URL=sqlite+aiosqlite:///./satonano.db +# PostgreSQL: postgresql+asyncpg://user:pass@localhost/dbname + +# 密码策略 +PASSWORD_MIN_LENGTH=8 +PASSWORD_REQUIRE_UPPERCASE=true +PASSWORD_REQUIRE_LOWERCASE=true +PASSWORD_REQUIRE_DIGIT=true +PASSWORD_REQUIRE_SPECIAL=false +``` + +## 测试建议 + +```bash +# 安装测试依赖 +uv add --dev pytest pytest-asyncio httpx + +# 运行测试 +uv run pytest tests/ -v +``` + +测试覆盖点: +- 用户注册(正常、重复用户名、弱密码) +- 用户登录(正常、错误密码、禁用用户) +- 令牌刷新(正常、过期令牌、无效令牌) +- 密码修改(正常、错误当前密码) +- 权限验证(未认证、已认证、管理员) + diff --git a/docs/auth-api.md b/docs/auth-api.md new file mode 100644 index 0000000..c79230c --- /dev/null +++ b/docs/auth-api.md @@ -0,0 +1,704 @@ +# 用户认证系统 API 文档 + +## 概述 + +本文档描述 SatoNano 云服务综合管理平台的用户认证系统 API。 + +### 基础信息 + +- **Base URL**: `http://localhost:8000/api/v1` +- **认证方式**: Bearer Token (JWT) +- **Content-Type**: `application/json` +- **支持登录方式**: 用户名密码 / OAuth2 (Linux.do) + +### 统一响应格式 + +所有 API 响应遵循统一格式: + +```json +{ + "success": true, + "message": "操作成功", + "data": { ... } +} +``` + +错误响应: + +```json +{ + "success": false, + "message": "错误描述", + "code": "ERROR_CODE", + "details": { ... } +} +``` + +--- + +## 认证接口 + +### 1. 用户注册 + +创建新用户账户。 + +**请求** + +``` +POST /auth/register +``` + +**请求体** + +| 字段 | 类型 | 必填 | 描述 | +|------|------|------|------| +| username | string | ✅ | 用户名(3-32位,字母开头,只允许字母、数字、下划线) | +| password | string | ✅ | 密码(8-128位,需包含大小写字母和数字) | +| email | string | ❌ | 邮箱地址 | +| nickname | string | ❌ | 昵称(最长64位) | + +**示例请求** + +```json +{ + "username": "john_doe", + "password": "SecurePass123", + "email": "john@example.com", + "nickname": "John" +} +``` + +**成功响应** `201 Created` + +```json +{ + "success": true, + "message": "注册成功", + "data": { + "id": "875cd9b4-3504-455d-9290-b6d1ba6b56e0", + "username": "john_doe", + "email": "john@example.com", + "nickname": "John", + "avatar_url": null, + "bio": null, + "is_active": true, + "created_at": "2026-01-05T13:39:07.653138", + "last_login_at": null + } +} +``` + +**错误响应** + +| 状态码 | 说明 | +|--------|------| +| 409 | 用户名或邮箱已被注册 | +| 422 | 请求数据验证失败 | + +--- + +### 2. 用户登录 + +使用用户名/邮箱和密码登录,获取访问令牌。 + +**请求** + +``` +POST /auth/login +``` + +**请求体** + +| 字段 | 类型 | 必填 | 描述 | +|------|------|------|------| +| username | string | ✅ | 用户名或邮箱 | +| password | string | ✅ | 密码 | + +**示例请求** + +```json +{ + "username": "john_doe", + "password": "SecurePass123" +} +``` + +**成功响应** `200 OK` + +```json +{ + "success": true, + "message": "登录成功", + "data": { + "access_token": "eyJhbGciOiJIUzI1NiIs...", + "refresh_token": "eyJhbGciOiJIUzI1NiIs...", + "token_type": "Bearer", + "expires_in": 1800 + } +} +``` + +**错误响应** + +| 状态码 | 说明 | +|--------|------| +| 401 | 用户名或密码错误 | +| 403 | 账户已被禁用 | + +--- + +### 3. 刷新令牌 + +使用刷新令牌获取新的访问令牌。 + +**请求** + +``` +POST /auth/refresh +``` + +**请求体** + +| 字段 | 类型 | 必填 | 描述 | +|------|------|------|------| +| refresh_token | string | ✅ | 刷新令牌 | + +**示例请求** + +```json +{ + "refresh_token": "eyJhbGciOiJIUzI1NiIs..." +} +``` + +**成功响应** `200 OK` + +```json +{ + "success": true, + "message": "刷新成功", + "data": { + "access_token": "eyJhbGciOiJIUzI1NiIs...", + "refresh_token": "eyJhbGciOiJIUzI1NiIs...", + "token_type": "Bearer", + "expires_in": 1800 + } +} +``` + +**错误响应** + +| 状态码 | 说明 | +|--------|------| +| 401 | 令牌无效或已过期 | +| 403 | 账户已被禁用 | + +--- + +### 4. 用户退出 + +退出登录。客户端应删除本地存储的令牌。 + +**请求** + +``` +POST /auth/logout +``` + +**请求头** + +``` +Authorization: Bearer +``` + +**成功响应** `200 OK` + +```json +{ + "success": true, + "message": "退出成功", + "data": null +} +``` + +--- + +### 5. 修改密码 + +修改当前用户的密码。 + +**请求** + +``` +POST /auth/change-password +``` + +**请求头** + +``` +Authorization: Bearer +``` + +**请求体** + +| 字段 | 类型 | 必填 | 描述 | +|------|------|------|------| +| current_password | string | ✅ | 当前密码 | +| new_password | string | ✅ | 新密码(8-128位) | + +**示例请求** + +```json +{ + "current_password": "SecurePass123", + "new_password": "NewSecurePass456" +} +``` + +**成功响应** `200 OK` + +```json +{ + "success": true, + "message": "密码修改成功", + "data": null +} +``` + +**错误响应** + +| 状态码 | 说明 | +|--------|------| +| 400 | 当前密码错误 / 新密码不符合要求 | +| 401 | 未认证 | + +--- + +## OAuth2 接口 + +SatoNano 支持通过 Linux.do 平台进行 OAuth2 第三方登录。 + +### 特性 + +- **主备端点自动切换**:当首选 OAuth2 端点不可达时,自动回退到备用端点 +- **状态码验证**:使用 state 参数防止 CSRF 攻击 +- **自动用户创建**:首次登录自动创建本地用户账户 + +### 1. 获取授权 URL + +获取 OAuth2 授权页面 URL,用于重定向用户到第三方平台。 + +**请求** + +``` +GET /auth/oauth2/authorize +``` + +**成功响应** `200 OK` + +```json +{ + "success": true, + "message": "请重定向到授权 URL", + "data": { + "authorize_url": "https://connect.linux.do/oauth2/authorize?client_id=xxx&redirect_uri=xxx&response_type=code&state=xxx&scope=read", + "state": "random-state-string" + } +} +``` + +**使用流程** + +1. 前端调用此接口获取 `authorize_url` +2. 将用户重定向到 `authorize_url` +3. 用户在 Linux.do 完成授权 +4. Linux.do 重定向回应用的回调 URL + +--- + +### 2. OAuth2 回调 + +处理 OAuth2 授权回调,完成登录流程。 + +**请求** + +``` +GET /auth/oauth2/callback?code=xxx&state=xxx +``` + +**查询参数** + +| 参数 | 类型 | 必填 | 描述 | +|------|------|------|------| +| code | string | ✅ | OAuth2 授权码 | +| state | string | ✅ | 状态码(防 CSRF) | + +**成功响应** `200 OK` + +```json +{ + "success": true, + "message": "登录成功", + "data": { + "access_token": "eyJhbGciOiJIUzI1NiIs...", + "refresh_token": "eyJhbGciOiJIUzI1NiIs...", + "token_type": "Bearer", + "expires_in": 1800, + "is_new_user": false + } +} +``` + +**响应字段说明** + +| 字段 | 说明 | +|------|------| +| is_new_user | `true` 表示首次登录,已自动创建账户 | + +**错误响应** + +| 状态码 | 说明 | +|--------|------| +| 400 | 无效的状态码(可能是 CSRF 攻击或状态已过期) | +| 401 | OAuth2 认证失败(授权码无效等) | +| 503 | OAuth2 未配置或服务不可用 | + +--- + +### OAuth2 登录流程图 + +``` +┌─────────────┐ ┌─────────────┐ ┌─────────────┐ +│ 前端应用 │ │ SatoNano │ │ Linux.do │ +└─────┬───────┘ └──────┬──────┘ └──────┬──────┘ + │ │ │ + │ 1. GET /auth/oauth2/authorize │ + │─────────────────────────> │ + │ │ │ + │ 2. 返回 authorize_url + state │ + │<───────────────────────── │ + │ │ │ + │ 3. 重定向用户到 authorize_url │ + │──────────────────────────────────────────────────> + │ │ │ + │ │ 4. 用户授权 │ + │ │<───────────────────────│ + │ │ │ + │ 5. 重定向回 callback?code=xxx&state=xxx │ + │<────────────────────────────────────────────────── + │ │ │ + │ 6. GET /auth/oauth2/callback │ + │─────────────────────────> │ + │ │ │ + │ │ 7. 用 code 换取 token │ + │ │───────────────────────>│ + │ │ │ + │ │ 8. 返回 access_token │ + │ │<───────────────────────│ + │ │ │ + │ │ 9. 获取用户信息 │ + │ │───────────────────────>│ + │ │ │ + │ │ 10. 返回 user info │ + │ │<───────────────────────│ + │ │ │ + │ 11. 返回 JWT 令牌 │ │ + │<───────────────────────── │ + │ │ │ +``` + +--- + +## 用户接口 + +### 1. 获取当前用户信息 + +获取当前登录用户的详细信息。 + +**请求** + +``` +GET /users/me +``` + +**请求头** + +``` +Authorization: Bearer +``` + +**成功响应** `200 OK` + +```json +{ + "success": true, + "message": "操作成功", + "data": { + "id": "875cd9b4-3504-455d-9290-b6d1ba6b56e0", + "username": "john_doe", + "email": "john@example.com", + "nickname": "John", + "avatar_url": null, + "bio": null, + "is_active": true, + "created_at": "2026-01-05T13:39:07.653138", + "last_login_at": "2026-01-05T13:39:19.028376" + } +} +``` + +--- + +### 2. 更新当前用户信息 + +更新当前登录用户的资料。 + +**请求** + +``` +PATCH /users/me +``` + +**请求头** + +``` +Authorization: Bearer +``` + +**请求体**(所有字段可选) + +| 字段 | 类型 | 描述 | +|------|------|------| +| nickname | string | 昵称(最长64位) | +| email | string | 邮箱地址 | +| avatar_url | string | 头像 URL(最长512位) | +| bio | string | 个人简介(最长500位) | + +**示例请求** + +```json +{ + "nickname": "Johnny", + "bio": "Hello, World!" +} +``` + +**成功响应** `200 OK` + +```json +{ + "success": true, + "message": "更新成功", + "data": { + "id": "875cd9b4-3504-455d-9290-b6d1ba6b56e0", + "username": "john_doe", + "email": "john@example.com", + "nickname": "Johnny", + "avatar_url": null, + "bio": "Hello, World!", + "is_active": true, + "created_at": "2026-01-05T13:39:07.653138", + "last_login_at": "2026-01-05T13:39:19.028376" + } +} +``` + +**错误响应** + +| 状态码 | 说明 | +|--------|------| +| 409 | 邮箱已被其他用户使用 | + +--- + +### 3. 获取指定用户信息 + +获取指定用户的信息。 + +**请求** + +``` +GET /users/{user_id} +``` + +**请求头** + +``` +Authorization: Bearer +``` + +**路径参数** + +| 参数 | 类型 | 描述 | +|------|------|------| +| user_id | string | 用户 UUID | + +**成功响应** `200 OK` + +```json +{ + "success": true, + "message": "操作成功", + "data": { + "id": "875cd9b4-3504-455d-9290-b6d1ba6b56e0", + "username": "john_doe", + "email": "john@example.com", + "nickname": "Johnny", + "avatar_url": null, + "bio": "Hello, World!", + "is_active": true, + "created_at": "2026-01-05T13:39:07.653138", + "last_login_at": "2026-01-05T13:39:19.028376" + } +} +``` + +**错误响应** + +| 状态码 | 说明 | +|--------|------| +| 404 | 用户不存在 | + +--- + +## 错误码说明 + +| 错误码 | HTTP 状态 | 说明 | +|--------|-----------|------| +| AUTHENTICATION_ERROR | 401 | 认证失败 | +| INVALID_CREDENTIALS | 401 | 用户名或密码错误 | +| TOKEN_ERROR | 401 | 令牌无效 | +| TOKEN_EXPIRED | 401 | 令牌已过期 | +| OAUTH2_ENDPOINT_ERROR | 401 | OAuth2 服务不可用 | +| OAUTH2_STATE_ERROR | 400 | OAuth2 状态码无效 | +| OAUTH2_TOKEN_ERROR | 401 | OAuth2 令牌获取失败 | +| OAUTH2_USERINFO_ERROR | 401 | OAuth2 用户信息获取失败 | +| AUTHORIZATION_ERROR | 403 | 权限不足 | +| USER_DISABLED | 403 | 账户已被禁用 | +| RESOURCE_NOT_FOUND | 404 | 资源不存在 | +| USER_ALREADY_EXISTS | 409 | 用户已存在 | +| VALIDATION_ERROR | 422 | 数据验证失败 | +| PASSWORD_VALIDATION_ERROR | 422 | 密码不符合要求 | + +--- + +## 密码策略 + +默认密码要求: + +- 长度:8-128 位 +- 必须包含至少一个大写字母 +- 必须包含至少一个小写字母 +- 必须包含至少一个数字 + +可通过环境变量配置: + +```bash +PASSWORD_MIN_LENGTH=8 +PASSWORD_MAX_LENGTH=128 +PASSWORD_REQUIRE_UPPERCASE=true +PASSWORD_REQUIRE_LOWERCASE=true +PASSWORD_REQUIRE_DIGIT=true +PASSWORD_REQUIRE_SPECIAL=false +``` + +--- + +## 令牌说明 + +### Access Token + +- 用于 API 认证 +- 默认有效期:30 分钟 +- 通过 `Authorization: Bearer ` 请求头传递 + +### Refresh Token + +- 用于获取新的 Access Token +- 默认有效期:7 天 +- 仅用于 `/auth/refresh` 接口 + +### JWT Payload 结构 + +**Access Token:** + +```json +{ + "sub": "user-uuid", + "iat": 1767620359, + "exp": 1767622159, + "type": "access", + "username": "john_doe", + "is_superuser": false, + "oauth_provider": null +} +``` + +> OAuth2 登录的用户 `oauth_provider` 字段为 `"linuxdo"` + +**Refresh Token:** + +```json +{ + "sub": "user-uuid", + "iat": 1767620359, + "exp": 1768225159, + "type": "refresh" +} +``` + +--- + +## OAuth2 配置说明 + +### Linux.do OAuth2 端点 + +| 端点 | URL | +|------|-----| +| authorize | `https://connect.linux.do/oauth2/authorize` | +| token | `https://connect.linux.do/oauth2/token` | +| userinfo | `https://connect.linux.do/api/user` | + +### 在 `config.yaml` 中配置 + +```yaml +# OAuth2 配置 (Linux.do) +oauth2_client_id: your_client_id +oauth2_client_secret: your_client_secret +oauth2_callback_path: /api/v1/auth/oauth2/callback + +# 首选端点 +oauth2_authorize_endpoint: https://connect.linux.do/oauth2/authorize +oauth2_token_endpoint: https://connect.linux.do/oauth2/token +oauth2_user_info_endpoint: https://connect.linux.do/api/user + +# 备用端点(首选不可达时自动回退) +oauth2_authorize_endpoint_reserve: https://connect.linuxdo.org/oauth2/authorize +oauth2_token_endpoint_reserve: https://connect.linuxdo.org/oauth2/token +oauth2_user_info_endpoint_reserve: https://connect.linuxdo.org/api/user + +# 请求超时(秒) +oauth2_request_timeout: 10 +``` + +### Linux.do 返回的用户信息 + +```json +{ + "id": 1, + "username": "neo", + "name": "Neo", + "active": true, + "trust_level": 4, + "email": "u1@linux.do", + "avatar_url": "https://linux.do/xxxx", + "silenced": false +} +``` + +### 主备端点切换逻辑 + +1. 首先尝试首选端点(`connect.linux.do`) +2. 如果首选端点超时、连接失败或返回 5xx 错误,自动切换到备用端点(`connect.linuxdo.org`) +3. 如果备用端点也失败,抛出 `OAUTH2_ENDPOINT_ERROR` 错误 + diff --git a/frontend/.gitignore b/frontend/.gitignore new file mode 100644 index 0000000..4ca7bc6 --- /dev/null +++ b/frontend/.gitignore @@ -0,0 +1,41 @@ +# Dependencies +/node_modules +/.pnp +.pnp.js +.yarn/install-state.gz + +# Testing +/coverage + +# Next.js +/.next/ +/out/ + +# Production +/build + +# Misc +.DS_Store +*.pem + +# Debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Local env files +.env*.local + +# Vercel +.vercel + +# TypeScript +*.tsbuildinfo +next-env.d.ts + +# IDE +.idea/ +.vscode/ +*.swp +*.swo + diff --git a/frontend/README.md b/frontend/README.md new file mode 100644 index 0000000..634278a --- /dev/null +++ b/frontend/README.md @@ -0,0 +1,137 @@ +# SatoNano Frontend + +现代化的用户认证系统前端,基于 Next.js 15 构建。 + +## 快速开始 + +### 1. 安装依赖 + +```bash +cd frontend +npm install +``` + +### 2. 启动开发服务器 + +确保后端服务已启动在 `http://localhost:8000`,然后: + +```bash +npm run dev +``` + +前端将运行在 `http://localhost:3000`,API 请求会自动代理到后端。 + +### 3. 配置 OAuth2(可选) + +如果需要使用 Linux.do OAuth2 登录: + +1. 在 Linux.do 开发者后台注册应用 +2. 设置回调 URL 为: + - 开发环境:`http://localhost:3000/oauth2/callback` + - 生产环境:`https://your-domain.com/oauth2/callback` +3. 更新 `config.yaml` 中的 OAuth2 配置 + +## 技术栈 + +- **框架**: Next.js 15 (App Router) +- **语言**: TypeScript +- **样式**: Tailwind CSS +- **状态管理**: Zustand +- **表单处理**: React Hook Form + Zod +- **动画**: Framer Motion +- **图标**: Lucide Icons + +## 开发 + +### 安装依赖 + +```bash +npm install +# 或 +pnpm install +``` + +### 启动开发服务器 + +```bash +npm run dev +``` + +开发环境下,API 请求会自动代理到 `http://localhost:8000`。 + +### 构建生产版本 + +```bash +npm run build +``` + +构建后的静态文件将输出到 `out` 目录。 + +## 项目结构 + +``` +frontend/ +├── src/ +│ ├── app/ # Next.js App Router 页面 +│ │ ├── dashboard/ # 用户控制台 +│ │ ├── login/ # 登录页 +│ │ ├── register/ # 注册页 +│ │ ├── oauth2/ # OAuth2 回调 +│ │ ├── globals.css # 全局样式 +│ │ ├── layout.tsx # 根布局 +│ │ └── page.tsx # 首页 +│ ├── components/ # React 组件 +│ │ ├── ui/ # 通用 UI 组件 +│ │ ├── auth/ # 认证相关组件 +│ │ └── dashboard/ # Dashboard 组件 +│ └── lib/ # 工具库 +│ ├── api.ts # API 服务层 +│ ├── store.ts # 状态管理 +│ ├── utils.ts # 工具函数 +│ └── validations.ts # 表单验证 +├── public/ # 静态资源 +├── next.config.ts # Next.js 配置 +├── tailwind.config.ts # Tailwind 配置 +└── tsconfig.json # TypeScript 配置 +``` + +## 开发/生产环境 + +### 开发环境 + +- 前端运行在 `http://localhost:3000` +- API 请求通过 Next.js 的 rewrites 代理到后端 `http://localhost:8000` +- 支持热重载 + +### 生产环境 + +构建后输出静态文件到 `out` 目录,由后端 FastAPI 服务托管: + +1. 构建前端:`npm run build` +2. 静态文件会被输出到 `frontend/out/` +3. 后端会自动挂载该目录作为静态文件服务 +4. 前后端位于同一域名,无跨域问题 + +### OAuth2 配置说明 + +OAuth2 登录流程: + +``` +用户点击登录 → 前端获取授权URL → 重定向到Linux.do → +用户授权 → 重定向回前端/oauth2/callback → 前端调用后端API → +获取JWT令牌 → 登录成功 +``` + +**重要**:确保 `config.yaml` 中的 `oauth2_callback_path` 设置为 `/oauth2/callback`(前端路由),而非后端 API 路径。 + +## 功能特性 + +- ✅ 用户登录/注册 +- ✅ OAuth2 第三方登录 (Linux.do) +- ✅ JWT 令牌自动刷新 +- ✅ 个人资料管理 +- ✅ 密码修改 +- ✅ 响应式设计 +- ✅ 深色主题 +- ✅ 动画效果 + diff --git a/frontend/next.config.ts b/frontend/next.config.ts new file mode 100644 index 0000000..c630df6 --- /dev/null +++ b/frontend/next.config.ts @@ -0,0 +1,36 @@ +import type { NextConfig } from 'next'; + +const isProd = process.env.NODE_ENV === 'production'; + +const nextConfig: NextConfig = { + // 生产环境静态导出,开发环境正常运行 + ...(isProd ? { output: 'export' } : {}), + + // 图片优化(静态导出时禁用) + images: { + unoptimized: true, + }, + + // 尾随斜杠 + trailingSlash: false, + + // 开发环境 API 代理 + async rewrites() { + if (!isProd) { + return [ + { + source: '/api/:path*', + destination: 'http://localhost:8000/api/:path*', + }, + { + source: '/health', + destination: 'http://localhost:8000/health', + }, + ]; + } + return []; + }, +}; + +export default nextConfig; + diff --git a/frontend/package-lock.json b/frontend/package-lock.json new file mode 100644 index 0000000..d860668 --- /dev/null +++ b/frontend/package-lock.json @@ -0,0 +1,6244 @@ +{ + "name": "satonano-frontend", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "satonano-frontend", + "version": "0.1.0", + "dependencies": { + "@hookform/resolvers": "^3.9.1", + "clsx": "^2.1.1", + "framer-motion": "^11.15.0", + "lucide-react": "^0.469.0", + "next": "^15.1.3", + "react": "^19.0.0", + "react-dom": "^19.0.0", + "react-hook-form": "^7.54.2", + "zod": "^3.24.1", + "zustand": "^5.0.2" + }, + "devDependencies": { + "@types/node": "^22.10.5", + "@types/react": "^19.0.2", + "@types/react-dom": "^19.0.2", + "autoprefixer": "^10.4.20", + "eslint": "^9.17.0", + "eslint-config-next": "^15.1.3", + "postcss": "^8.4.49", + "tailwindcss": "^3.4.17", + "typescript": "^5.7.2" + } + }, + "node_modules/@alloc/quick-lru": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/@alloc/quick-lru/-/quick-lru-5.2.0.tgz", + "integrity": "sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@emnapi/core": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.8.1.tgz", + "integrity": "sha512-AvT9QFpxK0Zd8J0jopedNm+w/2fIzvtPKPjqyw9jwvBaReTTqPBk9Hixaz7KbjimP+QNz605/XnjFcDAL2pqBg==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/wasi-threads": "1.1.0", + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/runtime": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.8.1.tgz", + "integrity": "sha512-mehfKSMWjjNol8659Z8KxEMrdSJDDot5SXMq00dM8BN4o+CLNXQ0xH2V7EchNHV4RmbZLmmPdEaXZc5H2FXmDg==", + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/wasi-threads": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.1.0.tgz", + "integrity": "sha512-WI0DdZ8xFSbgMjR1sFsKABJ/C5OnRrjT06JXbZKexJGrDuPTzZdDYfFlsgcCXCyf+suG5QU2e/y1Wo2V/OapLQ==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.9.1.tgz", + "integrity": "sha512-phrYmNiYppR7znFEdqgfWHXR6NCkZEK7hwWDHZUjit/2/U0r6XvkDl0SYnoM51Hq7FhCGdLDT6zxCCOY1hexsQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.12.2", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.2.tgz", + "integrity": "sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/config-array": { + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.21.1.tgz", + "integrity": "sha512-aw1gNayWpdI/jSYVgzN5pL0cfzU02GT3NBpeT/DXbx1/1x7ZKxFPd9bwrzygx/qiwIQiJ1sw/zD8qY/kRvlGHA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/object-schema": "^2.1.7", + "debug": "^4.3.1", + "minimatch": "^3.1.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/config-helpers": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.4.2.tgz", + "integrity": "sha512-gBrxN88gOIf3R7ja5K9slwNayVcZgK6SOUORm2uBzTeIEfeVaIhOpCtTox3P6R7o2jLFwLFTLnC7kU/RGcYEgw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^0.17.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/core": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.17.0.tgz", + "integrity": "sha512-yL/sLrpmtDaFEiUj1osRP4TI2MDz1AddJL+jZ7KSqvBuliN4xqYY54IfdN8qD8Toa6g1iloph1fxQNkjOxrrpQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@types/json-schema": "^7.0.15" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.3.tgz", + "integrity": "sha512-Kr+LPIUVKz2qkx1HAMH8q1q6azbqBAsXJUxBl/ODDuVPX45Z9DfwB8tPjTi6nNZ8BuM3nbJxC5zCAg5elnBUTQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^10.0.1", + "globals": "^14.0.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.1", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/js": { + "version": "9.39.2", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.39.2.tgz", + "integrity": "sha512-q1mjIoW1VX4IvSocvM/vbTiveKC4k9eLrajNEuSsmjymSDEbpGddtpfOoN7YGAqBK3NG+uqo8ia4PDTt8buCYA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://eslint.org/donate" + } + }, + "node_modules/@eslint/object-schema": { + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.7.tgz", + "integrity": "sha512-VtAOaymWVfZcmZbp6E2mympDIHvyjXs/12LqWYjVw6qjrfF+VK+fyG33kChz3nnK+SU5/NeHOqrTEHS8sXO3OA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/plugin-kit": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.4.1.tgz", + "integrity": "sha512-43/qtrDUokr7LJqoF2c3+RInu/t4zfrpYdoSDfYyhg52rwLV6TnOvdG4fXm7IkSB3wErkcmJS9iEhjVtOSEjjA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^0.17.0", + "levn": "^0.4.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@hookform/resolvers": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/@hookform/resolvers/-/resolvers-3.10.0.tgz", + "integrity": "sha512-79Dv+3mDF7i+2ajj7SkypSKHhl1cbln1OGavqrsF7p6mbUv11xpqpacPsGDCTRvCSjEEIez2ef1NveSVL3b0Ag==", + "license": "MIT", + "peerDependencies": { + "react-hook-form": "^7.0.0" + } + }, + "node_modules/@humanfs/core": { + "version": "0.19.1", + "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz", + "integrity": "sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/node": { + "version": "0.16.7", + "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.7.tgz", + "integrity": "sha512-/zUx+yOsIrG4Y43Eh2peDeKCxlRt/gET6aHfaKpuq267qXdYDFViVHfMaLyygZOnl0kGWxFIgsBy8QFuTLUXEQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@humanfs/core": "^0.19.1", + "@humanwhocodes/retry": "^0.4.0" + }, + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/retry": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.3.tgz", + "integrity": "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@img/colour": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.0.0.tgz", + "integrity": "sha512-A5P/LfWGFSl6nsckYtjw9da+19jB8hkJ6ACTGcDfEJ0aE+l2n2El7dsVM7UVHZQ9s2lmYMWlrS21YLy2IR1LUw==", + "license": "MIT", + "optional": true, + "engines": { + "node": ">=18" + } + }, + "node_modules/@img/sharp-darwin-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.34.5.tgz", + "integrity": "sha512-imtQ3WMJXbMY4fxb/Ndp6HBTNVtWCUI0WdobyheGf5+ad6xX8VIDO8u2xE4qc/fr08CKG/7dDseFtn6M6g/r3w==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-arm64": "1.2.4" + } + }, + "node_modules/@img/sharp-darwin-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.34.5.tgz", + "integrity": "sha512-YNEFAF/4KQ/PeW0N+r+aVVsoIY0/qxxikF2SWdp+NRkmMB7y9LBZAVqQ4yhGCm/H3H270OSykqmQMKLBhBJDEw==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-x64": "1.2.4" + } + }, + "node_modules/@img/sharp-libvips-darwin-arm64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.2.4.tgz", + "integrity": "sha512-zqjjo7RatFfFoP0MkQ51jfuFZBnVE2pRiaydKJ1G/rHZvnsrHAOcQALIi9sA5co5xenQdTugCvtb1cuf78Vf4g==", + "cpu": [ + "arm64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-x64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.2.4.tgz", + "integrity": "sha512-1IOd5xfVhlGwX+zXv2N93k0yMONvUlANylbJw1eTah8K/Jtpi15KC+WSiaX/nBmbm2HxRM1gZ0nSdjSsrZbGKg==", + "cpu": [ + "x64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.2.4.tgz", + "integrity": "sha512-bFI7xcKFELdiNCVov8e44Ia4u2byA+l3XtsAj+Q8tfCwO6BQ8iDojYdvoPMqsKDkuoOo+X6HZA0s0q11ANMQ8A==", + "cpu": [ + "arm" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.2.4.tgz", + "integrity": "sha512-excjX8DfsIcJ10x1Kzr4RcWe1edC9PquDRRPx3YVCvQv+U5p7Yin2s32ftzikXojb1PIFc/9Mt28/y+iRklkrw==", + "cpu": [ + "arm64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-ppc64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.2.4.tgz", + "integrity": "sha512-FMuvGijLDYG6lW+b/UvyilUWu5Ayu+3r2d1S8notiGCIyYU/76eig1UfMmkZ7vwgOrzKzlQbFSuQfgm7GYUPpA==", + "cpu": [ + "ppc64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-riscv64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.2.4.tgz", + "integrity": "sha512-oVDbcR4zUC0ce82teubSm+x6ETixtKZBh/qbREIOcI3cULzDyb18Sr/Wcyx7NRQeQzOiHTNbZFF1UwPS2scyGA==", + "cpu": [ + "riscv64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-s390x": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.2.4.tgz", + "integrity": "sha512-qmp9VrzgPgMoGZyPvrQHqk02uyjA0/QrTO26Tqk6l4ZV0MPWIW6LTkqOIov+J1yEu7MbFQaDpwdwJKhbJvuRxQ==", + "cpu": [ + "s390x" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-x64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.2.4.tgz", + "integrity": "sha512-tJxiiLsmHc9Ax1bz3oaOYBURTXGIRDODBqhveVHonrHJ9/+k89qbLl0bcJns+e4t4rvaNBxaEZsFtSfAdquPrw==", + "cpu": [ + "x64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-arm64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.2.4.tgz", + "integrity": "sha512-FVQHuwx1IIuNow9QAbYUzJ+En8KcVm9Lk5+uGUQJHaZmMECZmOlix9HnH7n1TRkXMS0pGxIJokIVB9SuqZGGXw==", + "cpu": [ + "arm64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-x64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.2.4.tgz", + "integrity": "sha512-+LpyBk7L44ZIXwz/VYfglaX/okxezESc6UxDSoyo2Ks6Jxc4Y7sGjpgU9s4PMgqgjj1gZCylTieNamqA1MF7Dg==", + "cpu": [ + "x64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-linux-arm": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.34.5.tgz", + "integrity": "sha512-9dLqsvwtg1uuXBGZKsxem9595+ujv0sJ6Vi8wcTANSFpwV/GONat5eCkzQo/1O6zRIkh0m/8+5BjrRr7jDUSZw==", + "cpu": [ + "arm" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.34.5.tgz", + "integrity": "sha512-bKQzaJRY/bkPOXyKx5EVup7qkaojECG6NLYswgktOZjaXecSAeCWiZwwiFf3/Y+O1HrauiE3FVsGxFg8c24rZg==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm64": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-ppc64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.34.5.tgz", + "integrity": "sha512-7zznwNaqW6YtsfrGGDA6BRkISKAAE1Jo0QdpNYXNMHu2+0dTrPflTLNkpc8l7MUP5M16ZJcUvysVWWrMefZquA==", + "cpu": [ + "ppc64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-ppc64": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-riscv64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.34.5.tgz", + "integrity": "sha512-51gJuLPTKa7piYPaVs8GmByo7/U7/7TZOq+cnXJIHZKavIRHAP77e3N2HEl3dgiqdD/w0yUfiJnII77PuDDFdw==", + "cpu": [ + "riscv64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-riscv64": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-s390x": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.34.5.tgz", + "integrity": "sha512-nQtCk0PdKfho3eC5MrbQoigJ2gd1CgddUMkabUj+rBevs8tZ2cULOx46E7oyX+04WGfABgIwmMC0VqieTiR4jg==", + "cpu": [ + "s390x" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-s390x": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.34.5.tgz", + "integrity": "sha512-MEzd8HPKxVxVenwAa+JRPwEC7QFjoPWuS5NZnBt6B3pu7EG2Ge0id1oLHZpPJdn3OQK+BQDiw9zStiHBTJQQQQ==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-x64": "1.2.4" + } + }, + "node_modules/@img/sharp-linuxmusl-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.34.5.tgz", + "integrity": "sha512-fprJR6GtRsMt6Kyfq44IsChVZeGN97gTD331weR1ex1c1rypDEABN6Tm2xa1wE6lYb5DdEnk03NZPqA7Id21yg==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-arm64": "1.2.4" + } + }, + "node_modules/@img/sharp-linuxmusl-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.34.5.tgz", + "integrity": "sha512-Jg8wNT1MUzIvhBFxViqrEhWDGzqymo3sV7z7ZsaWbZNDLXRJZoRGrjulp60YYtV4wfY8VIKcWidjojlLcWrd8Q==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-x64": "1.2.4" + } + }, + "node_modules/@img/sharp-wasm32": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.34.5.tgz", + "integrity": "sha512-OdWTEiVkY2PHwqkbBI8frFxQQFekHaSSkUIJkwzclWZe64O1X4UlUjqqqLaPbUpMOQk6FBu/HtlGXNblIs0huw==", + "cpu": [ + "wasm32" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", + "optional": true, + "dependencies": { + "@emnapi/runtime": "^1.7.0" + }, + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.34.5.tgz", + "integrity": "sha512-WQ3AgWCWYSb2yt+IG8mnC6Jdk9Whs7O0gxphblsLvdhSpSTtmu69ZG1Gkb6NuvxsNACwiPV6cNSZNzt0KPsw7g==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-ia32": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.34.5.tgz", + "integrity": "sha512-FV9m/7NmeCmSHDD5j4+4pNI8Cp3aW+JvLoXcTUo0IqyjSfAZJ8dIUmijx1qaJsIiU+Hosw6xM5KijAWRJCSgNg==", + "cpu": [ + "ia32" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.34.5.tgz", + "integrity": "sha512-+29YMsqY2/9eFEiW93eqWnuLcWcufowXewwSNIT6UwZdUUCrM3oFjMWH/Z6/TMmb4hlFenmfAVbpWeup2jryCw==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", + "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@napi-rs/wasm-runtime": { + "version": "0.2.12", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-0.2.12.tgz", + "integrity": "sha512-ZVWUcfwY4E/yPitQJl481FjFo3K22D6qF0DuFH6Y/nbnE11GY5uguDxZMGXPQ8WQ0128MXQD7TnfHyK4oWoIJQ==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/core": "^1.4.3", + "@emnapi/runtime": "^1.4.3", + "@tybys/wasm-util": "^0.10.0" + } + }, + "node_modules/@next/env": { + "version": "15.5.9", + "resolved": "https://registry.npmjs.org/@next/env/-/env-15.5.9.tgz", + "integrity": "sha512-4GlTZ+EJM7WaW2HEZcyU317tIQDjkQIyENDLxYJfSWlfqguN+dHkZgyQTV/7ykvobU7yEH5gKvreNrH4B6QgIg==", + "license": "MIT" + }, + "node_modules/@next/eslint-plugin-next": { + "version": "15.5.9", + "resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-15.5.9.tgz", + "integrity": "sha512-kUzXx0iFiXw27cQAViE1yKWnz/nF8JzRmwgMRTMh8qMY90crNsdXJRh2e+R0vBpFR3kk1yvAR7wev7+fCCb79Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-glob": "3.3.1" + } + }, + "node_modules/@next/swc-darwin-arm64": { + "version": "15.5.7", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-15.5.7.tgz", + "integrity": "sha512-IZwtxCEpI91HVU/rAUOOobWSZv4P2DeTtNaCdHqLcTJU4wdNXgAySvKa/qJCgR5m6KI8UsKDXtO2B31jcaw1Yw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-darwin-x64": { + "version": "15.5.7", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-15.5.7.tgz", + "integrity": "sha512-UP6CaDBcqaCBuiq/gfCEJw7sPEoX1aIjZHnBWN9v9qYHQdMKvCKcAVs4OX1vIjeE+tC5EIuwDTVIoXpUes29lg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-gnu": { + "version": "15.5.7", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-15.5.7.tgz", + "integrity": "sha512-NCslw3GrNIw7OgmRBxHtdWFQYhexoUCq+0oS2ccjyYLtcn1SzGzeM54jpTFonIMUjNbHmpKpziXnpxhSWLcmBA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-musl": { + "version": "15.5.7", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-15.5.7.tgz", + "integrity": "sha512-nfymt+SE5cvtTrG9u1wdoxBr9bVB7mtKTcj0ltRn6gkP/2Nu1zM5ei8rwP9qKQP0Y//umK+TtkKgNtfboBxRrw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-gnu": { + "version": "15.5.7", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-15.5.7.tgz", + "integrity": "sha512-hvXcZvCaaEbCZcVzcY7E1uXN9xWZfFvkNHwbe/n4OkRhFWrs1J1QV+4U1BN06tXLdaS4DazEGXwgqnu/VMcmqw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-musl": { + "version": "15.5.7", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-15.5.7.tgz", + "integrity": "sha512-4IUO539b8FmF0odY6/SqANJdgwn1xs1GkPO5doZugwZ3ETF6JUdckk7RGmsfSf7ws8Qb2YB5It33mvNL/0acqA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-arm64-msvc": { + "version": "15.5.7", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-15.5.7.tgz", + "integrity": "sha512-CpJVTkYI3ZajQkC5vajM7/ApKJUOlm6uP4BknM3XKvJ7VXAvCqSjSLmM0LKdYzn6nBJVSjdclx8nYJSa3xlTgQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-x64-msvc": { + "version": "15.5.7", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-15.5.7.tgz", + "integrity": "sha512-gMzgBX164I6DN+9/PGA+9dQiwmTkE4TloBNx8Kv9UiGARsr9Nba7IpcBRA1iTV9vwlYnrE3Uy6I7Aj6qLjQuqw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nolyfill/is-core-module": { + "version": "1.0.39", + "resolved": "https://registry.npmjs.org/@nolyfill/is-core-module/-/is-core-module-1.0.39.tgz", + "integrity": "sha512-nn5ozdjYQpUCZlWGuxcJY/KpxkWQs4DcbMCmKojjyrYDEAGy4Ce19NN4v5MduafTwJlbKc99UA8YhSVqq9yPZA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.4.0" + } + }, + "node_modules/@rtsao/scc": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@rtsao/scc/-/scc-1.1.0.tgz", + "integrity": "sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g==", + "dev": true, + "license": "MIT" + }, + "node_modules/@rushstack/eslint-patch": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/@rushstack/eslint-patch/-/eslint-patch-1.15.0.tgz", + "integrity": "sha512-ojSshQPKwVvSMR8yT2L/QtUkV5SXi/IfDiJ4/8d6UbTPjiHVmxZzUAzGD8Tzks1b9+qQkZa0isUOvYObedITaw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@swc/helpers": { + "version": "0.5.15", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.15.tgz", + "integrity": "sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.8.0" + } + }, + "node_modules/@tybys/wasm-util": { + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.1.tgz", + "integrity": "sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@types/estree": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", + "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/json5": { + "version": "0.0.29", + "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", + "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "22.19.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.3.tgz", + "integrity": "sha512-1N9SBnWYOJTrNZCdh/yJE+t910Y128BoyY+zBLWhL3r0TYzlTmFdXrPwHL9DyFZmlEXNQQolTZh3KHV31QDhyA==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/@types/react": { + "version": "19.2.7", + "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.7.tgz", + "integrity": "sha512-MWtvHrGZLFttgeEj28VXHxpmwYbor/ATPYbBfSFZEIRK0ecCFLl2Qo55z52Hss+UV9CRN7trSeq1zbgx7YDWWg==", + "devOptional": true, + "license": "MIT", + "dependencies": { + "csstype": "^3.2.2" + } + }, + "node_modules/@types/react-dom": { + "version": "19.2.3", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.2.3.tgz", + "integrity": "sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@types/react": "^19.2.0" + } + }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.52.0.tgz", + "integrity": "sha512-okqtOgqu2qmZJ5iN4TWlgfF171dZmx2FzdOv2K/ixL2LZWDStL8+JgQerI2sa8eAEfoydG9+0V96m7V+P8yE1Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/regexpp": "^4.12.2", + "@typescript-eslint/scope-manager": "8.52.0", + "@typescript-eslint/type-utils": "8.52.0", + "@typescript-eslint/utils": "8.52.0", + "@typescript-eslint/visitor-keys": "8.52.0", + "ignore": "^7.0.5", + "natural-compare": "^1.4.0", + "ts-api-utils": "^2.4.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^8.52.0", + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": { + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.5.tgz", + "integrity": "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.52.0.tgz", + "integrity": "sha512-iIACsx8pxRnguSYhHiMn2PvhvfpopO9FXHyn1mG5txZIsAaB6F0KwbFnUQN3KCiG3Jcuad/Cao2FAs1Wp7vAyg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/scope-manager": "8.52.0", + "@typescript-eslint/types": "8.52.0", + "@typescript-eslint/typescript-estree": "8.52.0", + "@typescript-eslint/visitor-keys": "8.52.0", + "debug": "^4.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/project-service": { + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.52.0.tgz", + "integrity": "sha512-xD0MfdSdEmeFa3OmVqonHi+Cciab96ls1UhIF/qX/O/gPu5KXD0bY9lu33jj04fjzrXHcuvjBcBC+D3SNSadaw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/tsconfig-utils": "^8.52.0", + "@typescript-eslint/types": "^8.52.0", + "debug": "^4.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.52.0.tgz", + "integrity": "sha512-ixxqmmCcc1Nf8S0mS0TkJ/3LKcC8mruYJPOU6Ia2F/zUUR4pApW7LzrpU3JmtePbRUTes9bEqRc1Gg4iyRnDzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.52.0", + "@typescript-eslint/visitor-keys": "8.52.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/tsconfig-utils": { + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.52.0.tgz", + "integrity": "sha512-jl+8fzr/SdzdxWJznq5nvoI7qn2tNYV/ZBAEcaFMVXf+K6jmXvAFrgo/+5rxgnL152f//pDEAYAhhBAZGrVfwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.52.0.tgz", + "integrity": "sha512-JD3wKBRWglYRQkAtsyGz1AewDu3mTc7NtRjR/ceTyGoPqmdS5oCdx/oZMWD5Zuqmo6/MpsYs0wp6axNt88/2EQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.52.0", + "@typescript-eslint/typescript-estree": "8.52.0", + "@typescript-eslint/utils": "8.52.0", + "debug": "^4.4.3", + "ts-api-utils": "^2.4.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/types": { + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.52.0.tgz", + "integrity": "sha512-LWQV1V4q9V4cT4H5JCIx3481iIFxH1UkVk+ZkGGAV1ZGcjGI9IoFOfg3O6ywz8QqCDEp7Inlg6kovMofsNRaGg==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.52.0.tgz", + "integrity": "sha512-XP3LClsCc0FsTK5/frGjolyADTh3QmsLp6nKd476xNI9CsSsLnmn4f0jrzNoAulmxlmNIpeXuHYeEQv61Q6qeQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/project-service": "8.52.0", + "@typescript-eslint/tsconfig-utils": "8.52.0", + "@typescript-eslint/types": "8.52.0", + "@typescript-eslint/visitor-keys": "8.52.0", + "debug": "^4.4.3", + "minimatch": "^9.0.5", + "semver": "^7.7.3", + "tinyglobby": "^0.2.15", + "ts-api-utils": "^2.4.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", + "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.52.0.tgz", + "integrity": "sha512-wYndVMWkweqHpEpwPhwqE2lnD2DxC6WVLupU/DOt/0/v+/+iQbbzO3jOHjmBMnhu0DgLULvOaU4h4pwHYi2oRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.9.1", + "@typescript-eslint/scope-manager": "8.52.0", + "@typescript-eslint/types": "8.52.0", + "@typescript-eslint/typescript-estree": "8.52.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.52.0.tgz", + "integrity": "sha512-ink3/Zofus34nmBsPjow63FP5M7IGff0RKAgqR6+CFpdk22M7aLwC9gOcLGYqr7MczLPzZVERW9hRog3O4n1sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.52.0", + "eslint-visitor-keys": "^4.2.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@unrs/resolver-binding-android-arm-eabi": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-android-arm-eabi/-/resolver-binding-android-arm-eabi-1.11.1.tgz", + "integrity": "sha512-ppLRUgHVaGRWUx0R0Ut06Mjo9gBaBkg3v/8AxusGLhsIotbBLuRk51rAzqLC8gq6NyyAojEXglNjzf6R948DNw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@unrs/resolver-binding-android-arm64": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-android-arm64/-/resolver-binding-android-arm64-1.11.1.tgz", + "integrity": "sha512-lCxkVtb4wp1v+EoN+HjIG9cIIzPkX5OtM03pQYkG+U5O/wL53LC4QbIeazgiKqluGeVEeBlZahHalCaBvU1a2g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@unrs/resolver-binding-darwin-arm64": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-darwin-arm64/-/resolver-binding-darwin-arm64-1.11.1.tgz", + "integrity": "sha512-gPVA1UjRu1Y/IsB/dQEsp2V1pm44Of6+LWvbLc9SDk1c2KhhDRDBUkQCYVWe6f26uJb3fOK8saWMgtX8IrMk3g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@unrs/resolver-binding-darwin-x64": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-darwin-x64/-/resolver-binding-darwin-x64-1.11.1.tgz", + "integrity": "sha512-cFzP7rWKd3lZaCsDze07QX1SC24lO8mPty9vdP+YVa3MGdVgPmFc59317b2ioXtgCMKGiCLxJ4HQs62oz6GfRQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@unrs/resolver-binding-freebsd-x64": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-freebsd-x64/-/resolver-binding-freebsd-x64-1.11.1.tgz", + "integrity": "sha512-fqtGgak3zX4DCB6PFpsH5+Kmt/8CIi4Bry4rb1ho6Av2QHTREM+47y282Uqiu3ZRF5IQioJQ5qWRV6jduA+iGw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@unrs/resolver-binding-linux-arm-gnueabihf": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-linux-arm-gnueabihf/-/resolver-binding-linux-arm-gnueabihf-1.11.1.tgz", + "integrity": "sha512-u92mvlcYtp9MRKmP+ZvMmtPN34+/3lMHlyMj7wXJDeXxuM0Vgzz0+PPJNsro1m3IZPYChIkn944wW8TYgGKFHw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/resolver-binding-linux-arm-musleabihf": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-linux-arm-musleabihf/-/resolver-binding-linux-arm-musleabihf-1.11.1.tgz", + "integrity": "sha512-cINaoY2z7LVCrfHkIcmvj7osTOtm6VVT16b5oQdS4beibX2SYBwgYLmqhBjA1t51CarSaBuX5YNsWLjsqfW5Cw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/resolver-binding-linux-arm64-gnu": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-linux-arm64-gnu/-/resolver-binding-linux-arm64-gnu-1.11.1.tgz", + "integrity": "sha512-34gw7PjDGB9JgePJEmhEqBhWvCiiWCuXsL9hYphDF7crW7UgI05gyBAi6MF58uGcMOiOqSJ2ybEeCvHcq0BCmQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/resolver-binding-linux-arm64-musl": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-linux-arm64-musl/-/resolver-binding-linux-arm64-musl-1.11.1.tgz", + "integrity": "sha512-RyMIx6Uf53hhOtJDIamSbTskA99sPHS96wxVE/bJtePJJtpdKGXO1wY90oRdXuYOGOTuqjT8ACccMc4K6QmT3w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/resolver-binding-linux-ppc64-gnu": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-linux-ppc64-gnu/-/resolver-binding-linux-ppc64-gnu-1.11.1.tgz", + "integrity": "sha512-D8Vae74A4/a+mZH0FbOkFJL9DSK2R6TFPC9M+jCWYia/q2einCubX10pecpDiTmkJVUH+y8K3BZClycD8nCShA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/resolver-binding-linux-riscv64-gnu": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-linux-riscv64-gnu/-/resolver-binding-linux-riscv64-gnu-1.11.1.tgz", + "integrity": "sha512-frxL4OrzOWVVsOc96+V3aqTIQl1O2TjgExV4EKgRY09AJ9leZpEg8Ak9phadbuX0BA4k8U5qtvMSQQGGmaJqcQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/resolver-binding-linux-riscv64-musl": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-linux-riscv64-musl/-/resolver-binding-linux-riscv64-musl-1.11.1.tgz", + "integrity": "sha512-mJ5vuDaIZ+l/acv01sHoXfpnyrNKOk/3aDoEdLO/Xtn9HuZlDD6jKxHlkN8ZhWyLJsRBxfv9GYM2utQ1SChKew==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/resolver-binding-linux-s390x-gnu": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-linux-s390x-gnu/-/resolver-binding-linux-s390x-gnu-1.11.1.tgz", + "integrity": "sha512-kELo8ebBVtb9sA7rMe1Cph4QHreByhaZ2QEADd9NzIQsYNQpt9UkM9iqr2lhGr5afh885d/cB5QeTXSbZHTYPg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/resolver-binding-linux-x64-gnu": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-linux-x64-gnu/-/resolver-binding-linux-x64-gnu-1.11.1.tgz", + "integrity": "sha512-C3ZAHugKgovV5YvAMsxhq0gtXuwESUKc5MhEtjBpLoHPLYM+iuwSj3lflFwK3DPm68660rZ7G8BMcwSro7hD5w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/resolver-binding-linux-x64-musl": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-linux-x64-musl/-/resolver-binding-linux-x64-musl-1.11.1.tgz", + "integrity": "sha512-rV0YSoyhK2nZ4vEswT/QwqzqQXw5I6CjoaYMOX0TqBlWhojUf8P94mvI7nuJTeaCkkds3QE4+zS8Ko+GdXuZtA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/resolver-binding-wasm32-wasi": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-wasm32-wasi/-/resolver-binding-wasm32-wasi-1.11.1.tgz", + "integrity": "sha512-5u4RkfxJm+Ng7IWgkzi3qrFOvLvQYnPBmjmZQ8+szTK/b31fQCnleNl1GgEt7nIsZRIf5PLhPwT0WM+q45x/UQ==", + "cpu": [ + "wasm32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@napi-rs/wasm-runtime": "^0.2.11" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@unrs/resolver-binding-win32-arm64-msvc": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-win32-arm64-msvc/-/resolver-binding-win32-arm64-msvc-1.11.1.tgz", + "integrity": "sha512-nRcz5Il4ln0kMhfL8S3hLkxI85BXs3o8EYoattsJNdsX4YUU89iOkVn7g0VHSRxFuVMdM4Q1jEpIId1Ihim/Uw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@unrs/resolver-binding-win32-ia32-msvc": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-win32-ia32-msvc/-/resolver-binding-win32-ia32-msvc-1.11.1.tgz", + "integrity": "sha512-DCEI6t5i1NmAZp6pFonpD5m7i6aFrpofcp4LA2i8IIq60Jyo28hamKBxNrZcyOwVOZkgsRp9O2sXWBWP8MnvIQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@unrs/resolver-binding-win32-x64-msvc": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-win32-x64-msvc/-/resolver-binding-win32-x64-msvc-1.11.1.tgz", + "integrity": "sha512-lrW200hZdbfRtztbygyaq/6jP6AKE8qQN2KvPcJ+x7wiD038YtnYtZ82IMNJ69GJibV7bwL3y9FgK+5w/pYt6g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/acorn": { + "version": "8.15.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", + "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/any-promise": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", + "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==", + "dev": true, + "license": "MIT" + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "license": "ISC", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/arg": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz", + "integrity": "sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==", + "dev": true, + "license": "MIT" + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, + "license": "Python-2.0" + }, + "node_modules/aria-query": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.2.tgz", + "integrity": "sha512-COROpnaoap1E2F000S62r6A60uHZnmlvomhfyT2DlTcrY1OrBKn2UhH7qn5wTC9zMvD0AY7csdPSNwKP+7WiQw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/array-buffer-byte-length": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-buffer-byte-length/-/array-buffer-byte-length-1.0.2.tgz", + "integrity": "sha512-LHE+8BuR7RYGDKvnrmcuSq3tDcKv9OFEXQt/HpbZhY7V6h0zlUXutnAD82GiFx9rdieCMjkvtcsPqBwgUl1Iiw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "is-array-buffer": "^3.0.5" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array-includes": { + "version": "3.1.9", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.9.tgz", + "integrity": "sha512-FmeCCAenzH0KH381SPT5FZmiA/TmpndpcaShhfgEN9eCVjnFBqq3l1xrI42y8+PPLI6hypzou4GXw00WHmPBLQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.4", + "define-properties": "^1.2.1", + "es-abstract": "^1.24.0", + "es-object-atoms": "^1.1.1", + "get-intrinsic": "^1.3.0", + "is-string": "^1.1.1", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array.prototype.findlast": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/array.prototype.findlast/-/array.prototype.findlast-1.2.5.tgz", + "integrity": "sha512-CVvd6FHg1Z3POpBLxO6E6zr+rSKEQ9L6rZHAaY7lLfhKsWYUBBOuMs0e9o24oopj6H+geRCX0YJ+TJLBK2eHyQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.2", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.0.0", + "es-shim-unscopables": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array.prototype.findlastindex": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/array.prototype.findlastindex/-/array.prototype.findlastindex-1.2.6.tgz", + "integrity": "sha512-F/TKATkzseUExPlfvmwQKGITM3DGTK+vkAsCZoDc5daVygbJBnjEUCbgkAvVFsgfXfX4YIqZ/27G3k3tdXrTxQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.4", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.9", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "es-shim-unscopables": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array.prototype.flat": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.3.tgz", + "integrity": "sha512-rwG/ja1neyLqCuGZ5YYrznA62D4mZXg0i1cIskIUKSiqF3Cje9/wXAls9B9s1Wa2fomMsIv8czB8jZcPmxCXFg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.5", + "es-shim-unscopables": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array.prototype.flatmap": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/array.prototype.flatmap/-/array.prototype.flatmap-1.3.3.tgz", + "integrity": "sha512-Y7Wt51eKJSyi80hFrJCePGGNo5ktJCslFuboqJsbf57CCPcm5zztluPlc4/aD8sWsKvlwatezpV4U1efk8kpjg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.5", + "es-shim-unscopables": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array.prototype.tosorted": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/array.prototype.tosorted/-/array.prototype.tosorted-1.1.4.tgz", + "integrity": "sha512-p6Fx8B7b7ZhL/gmUsAy0D15WhvDccw3mnGNbZpi3pmeJdxtWsj2jEaI4Y6oo3XiHfzuSgPwKc04MYt6KgvC/wA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.3", + "es-errors": "^1.3.0", + "es-shim-unscopables": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/arraybuffer.prototype.slice": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/arraybuffer.prototype.slice/-/arraybuffer.prototype.slice-1.0.4.tgz", + "integrity": "sha512-BNoCY6SXXPQ7gF2opIP4GBE+Xw7U+pHMYKuzjgCN3GwiaIR09UUeKfheyIry77QtrCBlC0KK0q5/TER/tYh3PQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "array-buffer-byte-length": "^1.0.1", + "call-bind": "^1.0.8", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.5", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "is-array-buffer": "^3.0.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/ast-types-flow": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/ast-types-flow/-/ast-types-flow-0.0.8.tgz", + "integrity": "sha512-OH/2E5Fg20h2aPrbe+QL8JZQFko0YZaF+j4mnQ7BGhfavO7OpSLa8a0y9sBwomHdSbkhTS8TQNayBfnW5DwbvQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/async-function": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/async-function/-/async-function-1.0.0.tgz", + "integrity": "sha512-hsU18Ae8CDTR6Kgu9DYf0EbCr/a5iGL0rytQDobUcdpYOKokk8LEjVphnXkDkgpi0wYVsqrXuP0bZxJaTqdgoA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/autoprefixer": { + "version": "10.4.23", + "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.23.tgz", + "integrity": "sha512-YYTXSFulfwytnjAPlw8QHncHJmlvFKtczb8InXaAx9Q0LbfDnfEYDE55omerIJKihhmU61Ft+cAOSzQVaBUmeA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/autoprefixer" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "browserslist": "^4.28.1", + "caniuse-lite": "^1.0.30001760", + "fraction.js": "^5.3.4", + "picocolors": "^1.1.1", + "postcss-value-parser": "^4.2.0" + }, + "bin": { + "autoprefixer": "bin/autoprefixer" + }, + "engines": { + "node": "^10 || ^12 || >=14" + }, + "peerDependencies": { + "postcss": "^8.1.0" + } + }, + "node_modules/available-typed-arrays": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz", + "integrity": "sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "possible-typed-array-names": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/axe-core": { + "version": "4.11.0", + "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.11.0.tgz", + "integrity": "sha512-ilYanEU8vxxBexpJd8cWM4ElSQq4QctCLKih0TSfjIfCQTeyH/6zVrmIJfLPrKTKJRbiG+cfnZbQIjAlJmF1jQ==", + "dev": true, + "license": "MPL-2.0", + "engines": { + "node": ">=4" + } + }, + "node_modules/axobject-query": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.1.0.tgz", + "integrity": "sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/baseline-browser-mapping": { + "version": "2.9.11", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.9.11.tgz", + "integrity": "sha512-Sg0xJUNDU1sJNGdfGWhVHX0kkZ+HWcvmVymJbj6NSgZZmW/8S9Y2HQ5euytnIgakgxN6papOAWiwDo1ctFDcoQ==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "baseline-browser-mapping": "dist/cli.js" + } + }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/brace-expansion": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browserslist": { + "version": "4.28.1", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.1.tgz", + "integrity": "sha512-ZC5Bd0LgJXgwGqUknZY/vkUQ04r8NXnJZ3yYi4vDmSiZmC/pdSN0NbNRPxZpbtO4uAfDUAFffO8IZoM3Gj8IkA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "baseline-browser-mapping": "^2.9.0", + "caniuse-lite": "^1.0.30001759", + "electron-to-chromium": "^1.5.263", + "node-releases": "^2.0.27", + "update-browserslist-db": "^1.2.0" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/call-bind": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.8.tgz", + "integrity": "sha512-oKlSFMcMwpUg2ednkhQ454wfWiU/ul3CkJe/PEHcTKuiX6RpbehUiFMXu13HalGZxfUwCQzZG747YXBn1im9ww==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.0", + "es-define-property": "^1.0.0", + "get-intrinsic": "^1.2.4", + "set-function-length": "^1.2.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/camelcase-css": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/camelcase-css/-/camelcase-css-2.0.1.tgz", + "integrity": "sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001762", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001762.tgz", + "integrity": "sha512-PxZwGNvH7Ak8WX5iXzoK1KPZttBXNPuaOvI2ZYU7NrlM+d9Ov+TUvlLOBNGzVXAntMSMMlJPd+jY6ovrVjSmUw==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/chokidar/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/client-only": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/client-only/-/client-only-0.0.1.tgz", + "integrity": "sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==", + "license": "MIT" + }, + "node_modules/clsx": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", + "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/commander": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", + "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true, + "license": "MIT" + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/cssesc": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", + "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==", + "dev": true, + "license": "MIT", + "bin": { + "cssesc": "bin/cssesc" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/csstype": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", + "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", + "devOptional": true, + "license": "MIT" + }, + "node_modules/damerau-levenshtein": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz", + "integrity": "sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==", + "dev": true, + "license": "BSD-2-Clause" + }, + "node_modules/data-view-buffer": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/data-view-buffer/-/data-view-buffer-1.0.2.tgz", + "integrity": "sha512-EmKO5V3OLXh1rtK2wgXRansaK1/mtVdTUEiEI0W8RkvgT05kfxaH29PliLnpLP73yYO6142Q72QNa8Wx/A5CqQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "es-errors": "^1.3.0", + "is-data-view": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/data-view-byte-length": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/data-view-byte-length/-/data-view-byte-length-1.0.2.tgz", + "integrity": "sha512-tuhGbE6CfTM9+5ANGf+oQb72Ky/0+s3xKUpHvShfiz2RxMFgFPjsXuRLBVMtvMs15awe45SRb83D6wH4ew6wlQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "es-errors": "^1.3.0", + "is-data-view": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/inspect-js" + } + }, + "node_modules/data-view-byte-offset": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/data-view-byte-offset/-/data-view-byte-offset-1.0.1.tgz", + "integrity": "sha512-BS8PfmtDGnrgYdOonGZQdLZslWIeCGFP9tpan0hi1Co2Zr2NKADsvGYA8XxuG/4UWgJ6Cjtv+YJnB6MM69QGlQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "is-data-view": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/define-data-property": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/define-properties": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", + "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-data-property": "^1.0.1", + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "license": "Apache-2.0", + "optional": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/didyoumean": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz", + "integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/dlv": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/dlv/-/dlv-1.1.3.tgz", + "integrity": "sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==", + "dev": true, + "license": "MIT" + }, + "node_modules/doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/electron-to-chromium": { + "version": "1.5.267", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.267.tgz", + "integrity": "sha512-0Drusm6MVRXSOJpGbaSVgcQsuB4hEkMpHXaVstcPmhu5LIedxs1xNK/nIxmQIU/RPC0+1/o0AVZfBTkTNJOdUw==", + "dev": true, + "license": "ISC" + }, + "node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true, + "license": "MIT" + }, + "node_modules/es-abstract": { + "version": "1.24.1", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.24.1.tgz", + "integrity": "sha512-zHXBLhP+QehSSbsS9Pt23Gg964240DPd6QCf8WpkqEXxQ7fhdZzYsocOr5u7apWonsS5EjZDmTF+/slGMyasvw==", + "dev": true, + "license": "MIT", + "dependencies": { + "array-buffer-byte-length": "^1.0.2", + "arraybuffer.prototype.slice": "^1.0.4", + "available-typed-arrays": "^1.0.7", + "call-bind": "^1.0.8", + "call-bound": "^1.0.4", + "data-view-buffer": "^1.0.2", + "data-view-byte-length": "^1.0.2", + "data-view-byte-offset": "^1.0.1", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "es-set-tostringtag": "^2.1.0", + "es-to-primitive": "^1.3.0", + "function.prototype.name": "^1.1.8", + "get-intrinsic": "^1.3.0", + "get-proto": "^1.0.1", + "get-symbol-description": "^1.1.0", + "globalthis": "^1.0.4", + "gopd": "^1.2.0", + "has-property-descriptors": "^1.0.2", + "has-proto": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "internal-slot": "^1.1.0", + "is-array-buffer": "^3.0.5", + "is-callable": "^1.2.7", + "is-data-view": "^1.0.2", + "is-negative-zero": "^2.0.3", + "is-regex": "^1.2.1", + "is-set": "^2.0.3", + "is-shared-array-buffer": "^1.0.4", + "is-string": "^1.1.1", + "is-typed-array": "^1.1.15", + "is-weakref": "^1.1.1", + "math-intrinsics": "^1.1.0", + "object-inspect": "^1.13.4", + "object-keys": "^1.1.1", + "object.assign": "^4.1.7", + "own-keys": "^1.0.1", + "regexp.prototype.flags": "^1.5.4", + "safe-array-concat": "^1.1.3", + "safe-push-apply": "^1.0.0", + "safe-regex-test": "^1.1.0", + "set-proto": "^1.0.0", + "stop-iteration-iterator": "^1.1.0", + "string.prototype.trim": "^1.2.10", + "string.prototype.trimend": "^1.0.9", + "string.prototype.trimstart": "^1.0.8", + "typed-array-buffer": "^1.0.3", + "typed-array-byte-length": "^1.0.3", + "typed-array-byte-offset": "^1.0.4", + "typed-array-length": "^1.0.7", + "unbox-primitive": "^1.1.0", + "which-typed-array": "^1.1.19" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-iterator-helpers": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/es-iterator-helpers/-/es-iterator-helpers-1.2.2.tgz", + "integrity": "sha512-BrUQ0cPTB/IwXj23HtwHjS9n7O4h9FX94b4xc5zlTHxeLgTAdzYUDyy6KdExAl9lbN5rtfe44xpjpmj9grxs5w==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.4", + "define-properties": "^1.2.1", + "es-abstract": "^1.24.1", + "es-errors": "^1.3.0", + "es-set-tostringtag": "^2.1.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.3.0", + "globalthis": "^1.0.4", + "gopd": "^1.2.0", + "has-property-descriptors": "^1.0.2", + "has-proto": "^1.2.0", + "has-symbols": "^1.1.0", + "internal-slot": "^1.1.0", + "iterator.prototype": "^1.1.5", + "safe-array-concat": "^1.1.3" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-shim-unscopables": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/es-shim-unscopables/-/es-shim-unscopables-1.1.0.tgz", + "integrity": "sha512-d9T8ucsEhh8Bi1woXCf+TIKDIROLG5WCkxg8geBCbvk22kzwC5G2OnXVMO6FUsvQlgUUXQ2itephWDLqDzbeCw==", + "dev": true, + "license": "MIT", + "dependencies": { + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-to-primitive": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.3.0.tgz", + "integrity": "sha512-w+5mJ3GuFL+NjVtJlvydShqE1eN3h3PbI7/5LAsYJP/2qtuMXjfL2LpHSRqo4b4eSF5K/DH1JXKUAHSB2UW50g==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-callable": "^1.2.7", + "is-date-object": "^1.0.5", + "is-symbol": "^1.0.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint": { + "version": "9.39.2", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.39.2.tgz", + "integrity": "sha512-LEyamqS7W5HB3ujJyvi0HQK/dtVINZvd5mAAp9eT5S/ujByGjiZLCzPcHVzuXbpJDJF/cxwHlfceVUDZ2lnSTw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.8.0", + "@eslint-community/regexpp": "^4.12.1", + "@eslint/config-array": "^0.21.1", + "@eslint/config-helpers": "^0.4.2", + "@eslint/core": "^0.17.0", + "@eslint/eslintrc": "^3.3.1", + "@eslint/js": "9.39.2", + "@eslint/plugin-kit": "^0.4.1", + "@humanfs/node": "^0.16.6", + "@humanwhocodes/module-importer": "^1.0.1", + "@humanwhocodes/retry": "^0.4.2", + "@types/estree": "^1.0.6", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.6", + "debug": "^4.3.2", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^8.4.0", + "eslint-visitor-keys": "^4.2.1", + "espree": "^10.4.0", + "esquery": "^1.5.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^8.0.0", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "jiti": "*" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + } + } + }, + "node_modules/eslint-config-next": { + "version": "15.5.9", + "resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-15.5.9.tgz", + "integrity": "sha512-852JYI3NkFNzW8CqsMhI0K2CDRxTObdZ2jQJj5CtpEaOkYHn13107tHpNuD/h0WRpU4FAbCdUaxQsrfBtNK9Kw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@next/eslint-plugin-next": "15.5.9", + "@rushstack/eslint-patch": "^1.10.3", + "@typescript-eslint/eslint-plugin": "^5.4.2 || ^6.0.0 || ^7.0.0 || ^8.0.0", + "@typescript-eslint/parser": "^5.4.2 || ^6.0.0 || ^7.0.0 || ^8.0.0", + "eslint-import-resolver-node": "^0.3.6", + "eslint-import-resolver-typescript": "^3.5.2", + "eslint-plugin-import": "^2.31.0", + "eslint-plugin-jsx-a11y": "^6.10.0", + "eslint-plugin-react": "^7.37.0", + "eslint-plugin-react-hooks": "^5.0.0" + }, + "peerDependencies": { + "eslint": "^7.23.0 || ^8.0.0 || ^9.0.0", + "typescript": ">=3.3.1" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/eslint-import-resolver-node": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz", + "integrity": "sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^3.2.7", + "is-core-module": "^2.13.0", + "resolve": "^1.22.4" + } + }, + "node_modules/eslint-import-resolver-node/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-import-resolver-typescript": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-3.10.1.tgz", + "integrity": "sha512-A1rHYb06zjMGAxdLSkN2fXPBwuSaQ0iO5M/hdyS0Ajj1VBaRp0sPD3dn1FhME3c/JluGFbwSxyCfqdSbtQLAHQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "@nolyfill/is-core-module": "1.0.39", + "debug": "^4.4.0", + "get-tsconfig": "^4.10.0", + "is-bun-module": "^2.0.0", + "stable-hash": "^0.0.5", + "tinyglobby": "^0.2.13", + "unrs-resolver": "^1.6.2" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint-import-resolver-typescript" + }, + "peerDependencies": { + "eslint": "*", + "eslint-plugin-import": "*", + "eslint-plugin-import-x": "*" + }, + "peerDependenciesMeta": { + "eslint-plugin-import": { + "optional": true + }, + "eslint-plugin-import-x": { + "optional": true + } + } + }, + "node_modules/eslint-module-utils": { + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.12.1.tgz", + "integrity": "sha512-L8jSWTze7K2mTg0vos/RuLRS5soomksDPoJLXIslC7c8Wmut3bx7CPpJijDcBZtxQ5lrbUdM+s0OlNbz0DCDNw==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^3.2.7" + }, + "engines": { + "node": ">=4" + }, + "peerDependenciesMeta": { + "eslint": { + "optional": true + } + } + }, + "node_modules/eslint-module-utils/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-plugin-import": { + "version": "2.32.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.32.0.tgz", + "integrity": "sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rtsao/scc": "^1.1.0", + "array-includes": "^3.1.9", + "array.prototype.findlastindex": "^1.2.6", + "array.prototype.flat": "^1.3.3", + "array.prototype.flatmap": "^1.3.3", + "debug": "^3.2.7", + "doctrine": "^2.1.0", + "eslint-import-resolver-node": "^0.3.9", + "eslint-module-utils": "^2.12.1", + "hasown": "^2.0.2", + "is-core-module": "^2.16.1", + "is-glob": "^4.0.3", + "minimatch": "^3.1.2", + "object.fromentries": "^2.0.8", + "object.groupby": "^1.0.3", + "object.values": "^1.2.1", + "semver": "^6.3.1", + "string.prototype.trimend": "^1.0.9", + "tsconfig-paths": "^3.15.0" + }, + "engines": { + "node": ">=4" + }, + "peerDependencies": { + "eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8 || ^9" + } + }, + "node_modules/eslint-plugin-import/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-plugin-import/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/eslint-plugin-jsx-a11y": { + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.10.2.tgz", + "integrity": "sha512-scB3nz4WmG75pV8+3eRUQOHZlNSUhFNq37xnpgRkCCELU3XMvXAxLk1eqWWyE22Ki4Q01Fnsw9BA3cJHDPgn2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "aria-query": "^5.3.2", + "array-includes": "^3.1.8", + "array.prototype.flatmap": "^1.3.2", + "ast-types-flow": "^0.0.8", + "axe-core": "^4.10.0", + "axobject-query": "^4.1.0", + "damerau-levenshtein": "^1.0.8", + "emoji-regex": "^9.2.2", + "hasown": "^2.0.2", + "jsx-ast-utils": "^3.3.5", + "language-tags": "^1.0.9", + "minimatch": "^3.1.2", + "object.fromentries": "^2.0.8", + "safe-regex-test": "^1.0.3", + "string.prototype.includes": "^2.0.1" + }, + "engines": { + "node": ">=4.0" + }, + "peerDependencies": { + "eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9" + } + }, + "node_modules/eslint-plugin-react": { + "version": "7.37.5", + "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.37.5.tgz", + "integrity": "sha512-Qteup0SqU15kdocexFNAJMvCJEfa2xUKNV4CC1xsVMrIIqEy3SQ/rqyxCWNzfrd3/ldy6HMlD2e0JDVpDg2qIA==", + "dev": true, + "license": "MIT", + "dependencies": { + "array-includes": "^3.1.8", + "array.prototype.findlast": "^1.2.5", + "array.prototype.flatmap": "^1.3.3", + "array.prototype.tosorted": "^1.1.4", + "doctrine": "^2.1.0", + "es-iterator-helpers": "^1.2.1", + "estraverse": "^5.3.0", + "hasown": "^2.0.2", + "jsx-ast-utils": "^2.4.1 || ^3.0.0", + "minimatch": "^3.1.2", + "object.entries": "^1.1.9", + "object.fromentries": "^2.0.8", + "object.values": "^1.2.1", + "prop-types": "^15.8.1", + "resolve": "^2.0.0-next.5", + "semver": "^6.3.1", + "string.prototype.matchall": "^4.0.12", + "string.prototype.repeat": "^1.0.0" + }, + "engines": { + "node": ">=4" + }, + "peerDependencies": { + "eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9.7" + } + }, + "node_modules/eslint-plugin-react-hooks": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-5.2.0.tgz", + "integrity": "sha512-+f15FfK64YQwZdJNELETdn5ibXEUQmW1DZL6KXhNnc2heoy/sg9VJJeT7n8TlMWouzWqSWavFkIhHyIbIAEapg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0" + } + }, + "node_modules/eslint-plugin-react/node_modules/resolve": { + "version": "2.0.0-next.5", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-2.0.0-next.5.tgz", + "integrity": "sha512-U7WjGVG9sH8tvjW5SmGbQuui75FiyjAX72HX15DwBBwF9dNiQZRQAg9nnPhYy+TUnE0+VcrttuvNI8oSxZcocA==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-core-module": "^2.13.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/eslint-plugin-react/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/eslint-scope": { + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.4.0.tgz", + "integrity": "sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", + "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/espree": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.4.0.tgz", + "integrity": "sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "acorn": "^8.15.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^4.2.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/esquery": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.7.0.tgz", + "integrity": "sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-glob": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", + "integrity": "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fast-glob/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fastq": { + "version": "1.20.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.20.1.tgz", + "integrity": "sha512-GGToxJ/w1x32s/D2EKND7kTil4n8OVk/9mycTc4VDza13lOvpUZTGX3mFSCtV9ksdGBVzvsyAVLM6mHFThxXxw==", + "dev": true, + "license": "ISC", + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/file-entry-cache": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", + "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "flat-cache": "^4.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat-cache": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", + "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "flatted": "^3.2.9", + "keyv": "^4.5.4" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/flatted": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.3.tgz", + "integrity": "sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==", + "dev": true, + "license": "ISC" + }, + "node_modules/for-each": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.5.tgz", + "integrity": "sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-callable": "^1.2.7" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/fraction.js": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-5.3.4.tgz", + "integrity": "sha512-1X1NTtiJphryn/uLQz3whtY6jK3fTqoE3ohKs0tT+Ujr1W59oopxmoEh7Lu5p6vBaPbgoM0bzveAW4Qi5RyWDQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/rawify" + } + }, + "node_modules/framer-motion": { + "version": "11.18.2", + "resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-11.18.2.tgz", + "integrity": "sha512-5F5Och7wrvtLVElIpclDT0CBzMVg3dL22B64aZwHtsIY8RB4mXICLrkajK4G9R+ieSAGcgrLeae2SeUTg2pr6w==", + "license": "MIT", + "dependencies": { + "motion-dom": "^11.18.1", + "motion-utils": "^11.18.1", + "tslib": "^2.4.0" + }, + "peerDependencies": { + "@emotion/is-prop-valid": "*", + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@emotion/is-prop-valid": { + "optional": true + }, + "react": { + "optional": true + }, + "react-dom": { + "optional": true + } + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/function.prototype.name": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.8.tgz", + "integrity": "sha512-e5iwyodOHhbMr/yNrc7fDYG4qlbIvI5gajyzPnb5TCwyhjApznQh1BMFou9b30SevY43gCJKXycoCBjMbsuW0Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.3", + "define-properties": "^1.2.1", + "functions-have-names": "^1.2.3", + "hasown": "^2.0.2", + "is-callable": "^1.2.7" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/functions-have-names": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", + "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/generator-function": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/generator-function/-/generator-function-2.0.1.tgz", + "integrity": "sha512-SFdFmIJi+ybC0vjlHN0ZGVGHc3lgE0DxPAT0djjVg+kjOnSqclqmj0KQ7ykTOLP6YxoqOvuAODGdcHJn+43q3g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "dev": true, + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/get-symbol-description": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.1.0.tgz", + "integrity": "sha512-w9UMqWwJxHNOvoNzSJ2oPF5wvYcvP7jUvYzhp67yEhTi17ZDBBC1z9pTdGuzjD+EFIqLSYRweZjqfiPzQ06Ebg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-tsconfig": { + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.13.0.tgz", + "integrity": "sha512-1VKTZJCwBrvbd+Wn3AOgQP/2Av+TfTCOlE4AcRJE72W1ksZXbAx8PPBR9RzgTeSPzlPMHrbANMH3LbltH73wxQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/globalthis": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.4.tgz", + "integrity": "sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-properties": "^1.2.1", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-bigints": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.1.0.tgz", + "integrity": "sha512-R3pbpkcIqv2Pm3dUwgjclDRVmWpTJW2DcMzcIhEXEx1oh/CEMObMm3KLmRJOdvhM7o4uQBnwr8pzRK2sJWIqfg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-proto": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.2.0.tgz", + "integrity": "sha512-KIL7eQPfHQRC8+XluaIw7BHUwwqL19bQn4hzNgdr+1wXoU0KKj6rufu47lhY7KbJR2C6T6+PfyN0Ea7wkSS+qQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ignore": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/import-fresh": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", + "integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/internal-slot": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.1.0.tgz", + "integrity": "sha512-4gd7VpWNQNB4UKKCFFVcp1AVv+FMOgs9NKzjHKusc8jTMhd5eL1NqQqOpE0KzMds804/yHlglp3uxgluOqAPLw==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "hasown": "^2.0.2", + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/is-array-buffer": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.5.tgz", + "integrity": "sha512-DDfANUiiG2wC1qawP66qlTugJeL5HyzMpfr8lLK+jMQirGzNod0B12cFB/9q838Ru27sBwfw78/rdoU7RERz6A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.3", + "get-intrinsic": "^1.2.6" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-async-function": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-async-function/-/is-async-function-2.1.1.tgz", + "integrity": "sha512-9dgM/cZBnNvjzaMYHVoxxfPj2QXt22Ev7SuuPrs+xav0ukGB0S6d4ydZdEiM48kLx5kDV+QBPrpVnFyefL8kkQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "async-function": "^1.0.0", + "call-bound": "^1.0.3", + "get-proto": "^1.0.1", + "has-tostringtag": "^1.0.2", + "safe-regex-test": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-bigint": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.1.0.tgz", + "integrity": "sha512-n4ZT37wG78iz03xPRKJrHTdZbe3IicyucEtdRsV5yglwc3GyUfbAfpSeD0FJ41NbUNSt5wbhqfp1fS+BgnvDFQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-bigints": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "license": "MIT", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-boolean-object": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.2.2.tgz", + "integrity": "sha512-wa56o2/ElJMYqjCjGkXri7it5FbebW5usLw/nPmCMs5DeZ7eziSYZhSmPRn0txqeW4LnAmQQU7FgqLpsEFKM4A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-bun-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-bun-module/-/is-bun-module-2.0.0.tgz", + "integrity": "sha512-gNCGbnnnnFAUGKeZ9PdbyeGYJqewpmc2aKHUEMO5nQPWU9lOmv7jcmQIv+qHD8fXW6W7qfuCwX4rY9LNRjXrkQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.7.1" + } + }, + "node_modules/is-callable": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", + "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-core-module": { + "version": "2.16.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz", + "integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==", + "dev": true, + "license": "MIT", + "dependencies": { + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-data-view": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-data-view/-/is-data-view-1.0.2.tgz", + "integrity": "sha512-RKtWF8pGmS87i2D6gqQu/l7EYRlVdfzemCJN/P3UOs//x1QE7mfhvzHIApBTRf7axvT6DMGwSwBXYCT0nfB9xw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "get-intrinsic": "^1.2.6", + "is-typed-array": "^1.1.13" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-date-object": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.1.0.tgz", + "integrity": "sha512-PwwhEakHVKTdRNVOw+/Gyh0+MzlCl4R6qKvkhuvLtPMggI1WAHt9sOwZxQLSGpUaDnrdyDsomoRgNnCfKNSXXg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-finalizationregistry": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-finalizationregistry/-/is-finalizationregistry-1.1.1.tgz", + "integrity": "sha512-1pC6N8qWJbWoPtEjgcL2xyhQOP491EQjeUo3qTKcmV8YSDDJrOepfG8pcC7h/QgnQHYSv0mJ3Z/ZWxmatVrysg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-generator-function": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.1.2.tgz", + "integrity": "sha512-upqt1SkGkODW9tsGNG5mtXTXtECizwtS2kA161M+gJPc1xdb/Ax629af6YrTwcOeQHbewrPNlE5Dx7kzvXTizA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.4", + "generator-function": "^2.0.0", + "get-proto": "^1.0.1", + "has-tostringtag": "^1.0.2", + "safe-regex-test": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-map": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.3.tgz", + "integrity": "sha512-1Qed0/Hr2m+YqxnM09CjA2d/i6YZNfF6R2oRAOj36eUdS6qIV/huPJNSEpKbupewFs+ZsJlxsjjPbc0/afW6Lw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-negative-zero": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.3.tgz", + "integrity": "sha512-5KoIu2Ngpyek75jXodFvnafB6DJgr3u8uuK0LEZJjrU19DrMD3EVERaR8sjz8CCGgpZvxPl9SuE1GMVPFHx1mw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-number-object": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.1.1.tgz", + "integrity": "sha512-lZhclumE1G6VYD8VHe35wFaIif+CTy5SJIi5+3y4psDgWu4wPDoBhF8NxUOinEc7pHgiTsT6MaBb92rKhhD+Xw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-regex": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.2.1.tgz", + "integrity": "sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "gopd": "^1.2.0", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-set": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-set/-/is-set-2.0.3.tgz", + "integrity": "sha512-iPAjerrse27/ygGLxw+EBR9agv9Y6uLeYVJMu+QNCoouJ1/1ri0mGrcWpfCqFZuzzx3WjtwxG098X+n4OuRkPg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-shared-array-buffer": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.4.tgz", + "integrity": "sha512-ISWac8drv4ZGfwKl5slpHG9OwPNty4jOWPRIhBpxOoD+hqITiwuipOQ2bNthAzwA3B4fIjO4Nln74N0S9byq8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-string": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.1.1.tgz", + "integrity": "sha512-BtEeSsoaQjlSPBemMQIrY1MY0uM6vnS1g5fmufYOtnxLGUZM2178PKbhsk7Ffv58IX+ZtcvoGwccYsh0PglkAA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-symbol": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.1.1.tgz", + "integrity": "sha512-9gGx6GTtCQM73BgmHQXfDmLtfjjTUDSyoxTCbp5WtoixAhfgsDirWIcVQ/IHpvI5Vgd5i/J5F7B9cN/WlVbC/w==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "has-symbols": "^1.1.0", + "safe-regex-test": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-typed-array": { + "version": "1.1.15", + "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.15.tgz", + "integrity": "sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "which-typed-array": "^1.1.16" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-weakmap": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.2.tgz", + "integrity": "sha512-K5pXYOm9wqY1RgjpL3YTkF39tni1XajUIkawTLUo9EZEVUFga5gSQJF8nNS7ZwJQ02y+1YCNYcMh+HIf1ZqE+w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-weakref": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.1.1.tgz", + "integrity": "sha512-6i9mGWSlqzNMEqpCp93KwRS1uUOodk2OJ6b+sq7ZPDSy2WuI5NFIxp/254TytR8ftefexkWn5xNiHUNpPOfSew==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-weakset": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-weakset/-/is-weakset-2.0.4.tgz", + "integrity": "sha512-mfcwb6IzQyOKTs84CQMrOwW4gQcaTOAWJ0zzJCl2WSPDrWk/OzDaImWFH3djXhb24g4eudZfLRozAvPGw4d9hQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "get-intrinsic": "^1.2.6" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", + "dev": true, + "license": "MIT" + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, + "node_modules/iterator.prototype": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/iterator.prototype/-/iterator.prototype-1.1.5.tgz", + "integrity": "sha512-H0dkQoCa3b2VEeKQBOxFph+JAbcrQdE7KC0UkqwpLmv2EC4P41QXP+rqo9wYodACiG5/WM5s9oDApTU8utwj9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-data-property": "^1.1.4", + "es-object-atoms": "^1.0.0", + "get-intrinsic": "^1.2.6", + "get-proto": "^1.0.0", + "has-symbols": "^1.1.0", + "set-function-name": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/jiti": { + "version": "1.21.7", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-1.21.7.tgz", + "integrity": "sha512-/imKNG4EbWNrVjoNC/1H5/9GFy+tqjGBHCaSsN+P2RnPqjsLmv6UD3Ej+Kj8nBWaRAwyk7kK5ZUc+OEatnTR3A==", + "dev": true, + "license": "MIT", + "bin": { + "jiti": "bin/jiti.js" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/js-yaml": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz", + "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==", + "dev": true, + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/json5": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", + "dev": true, + "license": "MIT", + "dependencies": { + "minimist": "^1.2.0" + }, + "bin": { + "json5": "lib/cli.js" + } + }, + "node_modules/jsx-ast-utils": { + "version": "3.3.5", + "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.3.5.tgz", + "integrity": "sha512-ZZow9HBI5O6EPgSJLUb8n2NKgmVWTwCvHGwFuJlMjvLFqlGG6pjirPhtdsseaLZjSibD8eegzmYpUZwoIlj2cQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "array-includes": "^3.1.6", + "array.prototype.flat": "^1.3.1", + "object.assign": "^4.1.4", + "object.values": "^1.1.6" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/keyv": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "json-buffer": "3.0.1" + } + }, + "node_modules/language-subtag-registry": { + "version": "0.3.23", + "resolved": "https://registry.npmjs.org/language-subtag-registry/-/language-subtag-registry-0.3.23.tgz", + "integrity": "sha512-0K65Lea881pHotoGEa5gDlMxt3pctLi2RplBb7Ezh4rRdLEOtgi7n4EwK9lamnUCkKBqaeKRVebTq6BAxSkpXQ==", + "dev": true, + "license": "CC0-1.0" + }, + "node_modules/language-tags": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/language-tags/-/language-tags-1.0.9.tgz", + "integrity": "sha512-MbjN408fEndfiQXbFQ1vnd+1NoLDsnQW41410oQBXiyXDMYH5z505juWa4KUE1LqxRC7DgOgZDbKLxHIwm27hA==", + "dev": true, + "license": "MIT", + "dependencies": { + "language-subtag-registry": "^0.3.20" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/lilconfig": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.3.tgz", + "integrity": "sha512-/vlFKAoH5Cgt3Ie+JLhRbwOsCQePABiU3tJ1egGvyQ+33R/vcwM2Zl2QR/LzjsBeItPt3oSVXapn+m4nQDvpzw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antonk52" + } + }, + "node_modules/lines-and-columns": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", + "dev": true, + "license": "MIT" + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "js-tokens": "^3.0.0 || ^4.0.0" + }, + "bin": { + "loose-envify": "cli.js" + } + }, + "node_modules/lucide-react": { + "version": "0.469.0", + "resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-0.469.0.tgz", + "integrity": "sha512-28vvUnnKQ/dBwiCQtwJw7QauYnE7yd2Cyp4tTTJpvglX4EMpbflcdBgrgToX2j71B3YvugK/NH3BGUk+E/p/Fw==", + "license": "ISC", + "peerDependencies": { + "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "dev": true, + "license": "MIT", + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/motion-dom": { + "version": "11.18.1", + "resolved": "https://registry.npmjs.org/motion-dom/-/motion-dom-11.18.1.tgz", + "integrity": "sha512-g76KvA001z+atjfxczdRtw/RXOM3OMSdd1f4DL77qCTF/+avrRJiawSG4yDibEQ215sr9kpinSlX2pCTJ9zbhw==", + "license": "MIT", + "dependencies": { + "motion-utils": "^11.18.1" + } + }, + "node_modules/motion-utils": { + "version": "11.18.1", + "resolved": "https://registry.npmjs.org/motion-utils/-/motion-utils-11.18.1.tgz", + "integrity": "sha512-49Kt+HKjtbJKLtgO/LKj9Ld+6vw9BjH5d9sc40R/kVyH8GLAXgT42M2NnuPcJNuA3s9ZfZBUcwIgpmZWGEE+hA==", + "license": "MIT" + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/mz": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", + "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "any-promise": "^1.0.0", + "object-assign": "^4.0.1", + "thenify-all": "^1.0.0" + } + }, + "node_modules/nanoid": { + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/napi-postinstall": { + "version": "0.3.4", + "resolved": "https://registry.npmjs.org/napi-postinstall/-/napi-postinstall-0.3.4.tgz", + "integrity": "sha512-PHI5f1O0EP5xJ9gQmFGMS6IZcrVvTjpXjz7Na41gTE7eE2hK11lg04CECCYEEjdc17EV4DO+fkGEtt7TpTaTiQ==", + "dev": true, + "license": "MIT", + "bin": { + "napi-postinstall": "lib/cli.js" + }, + "engines": { + "node": "^12.20.0 || ^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/napi-postinstall" + } + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true, + "license": "MIT" + }, + "node_modules/next": { + "version": "15.5.9", + "resolved": "https://registry.npmjs.org/next/-/next-15.5.9.tgz", + "integrity": "sha512-agNLK89seZEtC5zUHwtut0+tNrc0Xw4FT/Dg+B/VLEo9pAcS9rtTKpek3V6kVcVwsB2YlqMaHdfZL4eLEVYuCg==", + "license": "MIT", + "dependencies": { + "@next/env": "15.5.9", + "@swc/helpers": "0.5.15", + "caniuse-lite": "^1.0.30001579", + "postcss": "8.4.31", + "styled-jsx": "5.1.6" + }, + "bin": { + "next": "dist/bin/next" + }, + "engines": { + "node": "^18.18.0 || ^19.8.0 || >= 20.0.0" + }, + "optionalDependencies": { + "@next/swc-darwin-arm64": "15.5.7", + "@next/swc-darwin-x64": "15.5.7", + "@next/swc-linux-arm64-gnu": "15.5.7", + "@next/swc-linux-arm64-musl": "15.5.7", + "@next/swc-linux-x64-gnu": "15.5.7", + "@next/swc-linux-x64-musl": "15.5.7", + "@next/swc-win32-arm64-msvc": "15.5.7", + "@next/swc-win32-x64-msvc": "15.5.7", + "sharp": "^0.34.3" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.1.0", + "@playwright/test": "^1.51.1", + "babel-plugin-react-compiler": "*", + "react": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0", + "react-dom": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0", + "sass": "^1.3.0" + }, + "peerDependenciesMeta": { + "@opentelemetry/api": { + "optional": true + }, + "@playwright/test": { + "optional": true + }, + "babel-plugin-react-compiler": { + "optional": true + }, + "sass": { + "optional": true + } + } + }, + "node_modules/next/node_modules/postcss": { + "version": "8.4.31", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", + "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.6", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/node-releases": { + "version": "2.0.27", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.27.tgz", + "integrity": "sha512-nmh3lCkYZ3grZvqcCH+fjmQ7X+H0OeZgP40OierEaAptX4XofMh5kwNbWh7lBduUzCcV/8kZ+NDLCwm2iorIlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-hash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-3.0.0.tgz", + "integrity": "sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/object.assign": { + "version": "4.1.7", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.7.tgz", + "integrity": "sha512-nK28WOo+QIjBkDduTINE4JkF/UJJKyf2EJxvJKfblDpyg0Q+pkOHNTL0Qwy6NP6FhE/EnzV73BxxqcJaXY9anw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.3", + "define-properties": "^1.2.1", + "es-object-atoms": "^1.0.0", + "has-symbols": "^1.1.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object.entries": { + "version": "1.1.9", + "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.9.tgz", + "integrity": "sha512-8u/hfXFRBD1O0hPUjioLhoWFHRmt6tKA4/vZPyckBr18l1KE9uHrFaFaUi8MDRTpi4uak2goyPTSNJLXX2k2Hw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.4", + "define-properties": "^1.2.1", + "es-object-atoms": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/object.fromentries": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.8.tgz", + "integrity": "sha512-k6E21FzySsSK5a21KRADBd/NGneRegFO5pLHfdQLpRDETUNJueLXs3WCzyQ3tFRDYgbq3KHGXfTbi2bs8WQ6rQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.2", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object.groupby": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/object.groupby/-/object.groupby-1.0.3.tgz", + "integrity": "sha512-+Lhy3TQTuzXI5hevh8sBGqbmurHbbIjAi0Z4S63nthVLmLxfbj4T54a4CfZrXIrt9iP4mVAPYMo/v99taj3wjQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/object.values": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.2.1.tgz", + "integrity": "sha512-gXah6aZrcUxjWg2zR2MwouP2eHlCBzdV4pygudehaKXSGW4v2AsRQUK+lwwXhii6KFZcunEnmSUoYp5CXibxtA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.3", + "define-properties": "^1.2.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/optionator": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.5" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/own-keys": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/own-keys/-/own-keys-1.0.1.tgz", + "integrity": "sha512-qFOyK5PjiWZd+QQIh+1jhdb9LpxTF0qs7Pm8o5QHYZ0M3vKqSqzsZaEB6oWlxZ+q2sJBMI/Ktgd2N5ZwQoRHfg==", + "dev": true, + "license": "MIT", + "dependencies": { + "get-intrinsic": "^1.2.6", + "object-keys": "^1.1.1", + "safe-push-apply": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "license": "MIT", + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true, + "license": "MIT" + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pirates": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.7.tgz", + "integrity": "sha512-TfySrs/5nm8fQJDcBDuUng3VOUKsd7S+zqvbOTiGXHfxX4wK31ard+hoNuvkicM/2YFzlpDgABOevKSsB4G/FA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/possible-typed-array-names": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz", + "integrity": "sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/postcss": { + "version": "8.5.6", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz", + "integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.11", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/postcss-import": { + "version": "15.1.0", + "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-15.1.0.tgz", + "integrity": "sha512-hpr+J05B2FVYUAXHeK1YyI267J/dDDhMU6B6civm8hSY1jYJnBXxzKDKDswzJmtLHryrjhnDjqqp/49t8FALew==", + "dev": true, + "license": "MIT", + "dependencies": { + "postcss-value-parser": "^4.0.0", + "read-cache": "^1.0.0", + "resolve": "^1.1.7" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "postcss": "^8.0.0" + } + }, + "node_modules/postcss-js": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/postcss-js/-/postcss-js-4.1.0.tgz", + "integrity": "sha512-oIAOTqgIo7q2EOwbhb8UalYePMvYoIeRY2YKntdpFQXNosSu3vLrniGgmH9OKs/qAkfoj5oB3le/7mINW1LCfw==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "camelcase-css": "^2.0.1" + }, + "engines": { + "node": "^12 || ^14 || >= 16" + }, + "peerDependencies": { + "postcss": "^8.4.21" + } + }, + "node_modules/postcss-load-config": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-6.0.1.tgz", + "integrity": "sha512-oPtTM4oerL+UXmx+93ytZVN82RrlY/wPUV8IeDxFrzIjXOLF1pN+EmKPLbubvKHT2HC20xXsCAH2Z+CKV6Oz/g==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "lilconfig": "^3.1.1" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "jiti": ">=1.21.0", + "postcss": ">=8.0.9", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + }, + "postcss": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/postcss-nested": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/postcss-nested/-/postcss-nested-6.2.0.tgz", + "integrity": "sha512-HQbt28KulC5AJzG+cZtj9kvKB93CFCdLvog1WFLf1D+xmMvPGlBstkpTEZfK5+AN9hfJocyBFCNiqyS48bpgzQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "postcss-selector-parser": "^6.1.1" + }, + "engines": { + "node": ">=12.0" + }, + "peerDependencies": { + "postcss": "^8.2.14" + } + }, + "node_modules/postcss-selector-parser": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.1.2.tgz", + "integrity": "sha512-Q8qQfPiZ+THO/3ZrOrO0cJJKfpYCagtMUkXbnEfmgUjwXg6z/WBeOyS9APBBPCTSiDV+s4SwQGu8yFsiMRIudg==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/postcss-value-parser": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", + "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/prop-types": { + "version": "15.8.1", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", + "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", + "dev": true, + "license": "MIT", + "dependencies": { + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.13.1" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/react": { + "version": "19.2.3", + "resolved": "https://registry.npmjs.org/react/-/react-19.2.3.tgz", + "integrity": "sha512-Ku/hhYbVjOQnXDZFv2+RibmLFGwFdeeKHFcOTlrt7xplBnya5OGn/hIRDsqDiSUcfORsDC7MPxwork8jBwsIWA==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-dom": { + "version": "19.2.3", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.3.tgz", + "integrity": "sha512-yELu4WmLPw5Mr/lmeEpox5rw3RETacE++JgHqQzd2dg+YbJuat3jH4ingc+WPZhxaoFzdv9y33G+F7Nl5O0GBg==", + "license": "MIT", + "dependencies": { + "scheduler": "^0.27.0" + }, + "peerDependencies": { + "react": "^19.2.3" + } + }, + "node_modules/react-hook-form": { + "version": "7.70.0", + "resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.70.0.tgz", + "integrity": "sha512-COOMajS4FI3Wuwrs3GPpi/Jeef/5W1DRR84Yl5/ShlT3dKVFUfoGiEZ/QE6Uw8P4T2/CLJdcTVYKvWBMQTEpvw==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/react-hook-form" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17 || ^18 || ^19" + } + }, + "node_modules/react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/read-cache": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", + "integrity": "sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA==", + "dev": true, + "license": "MIT", + "dependencies": { + "pify": "^2.3.0" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/reflect.getprototypeof": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.10.tgz", + "integrity": "sha512-00o4I+DVrefhv+nX0ulyi3biSHCPDe+yLv5o/p6d/UVlirijB8E16FtfwSAi4g3tcqrQ4lRAqQSoFEZJehYEcw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.9", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.0.0", + "get-intrinsic": "^1.2.7", + "get-proto": "^1.0.1", + "which-builtin-type": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/regexp.prototype.flags": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.4.tgz", + "integrity": "sha512-dYqgNSZbDwkaJ2ceRd9ojCGjBq+mOm9LmtXnAnEGyHhN/5R7iDW2TRw3h+o/jCFxus3P2LfWIIiwowAjANm7IA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "define-properties": "^1.2.1", + "es-errors": "^1.3.0", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "set-function-name": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/resolve": { + "version": "1.22.11", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.11.tgz", + "integrity": "sha512-RfqAvLnMl313r7c9oclB1HhUEAezcpLjz95wFH4LVuhk9JF/r22qmVP9AMmOU4vMX7Q8pN8jwNg/CSpdFnMjTQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-core-module": "^2.16.1", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, + "node_modules/reusify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz", + "integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==", + "dev": true, + "license": "MIT", + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, + "node_modules/safe-array-concat": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.1.3.tgz", + "integrity": "sha512-AURm5f0jYEOydBj7VQlVvDrjeFgthDdEF5H1dP+6mNpoXOMo1quQqJ4wvJDyRZ9+pO3kGWoOdmV08cSv2aJV6Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.2", + "get-intrinsic": "^1.2.6", + "has-symbols": "^1.1.0", + "isarray": "^2.0.5" + }, + "engines": { + "node": ">=0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/safe-push-apply": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/safe-push-apply/-/safe-push-apply-1.0.0.tgz", + "integrity": "sha512-iKE9w/Z7xCzUMIZqdBsp6pEQvwuEebH4vdpjcDWnyzaI6yl6O9FHvVpmGelvEHNsoY6wGblkxR6Zty/h00WiSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "isarray": "^2.0.5" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/safe-regex-test": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.1.0.tgz", + "integrity": "sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "is-regex": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/scheduler": { + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.27.0.tgz", + "integrity": "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==", + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.7.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz", + "integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==", + "devOptional": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/set-function-length": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/set-function-name": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/set-function-name/-/set-function-name-2.0.2.tgz", + "integrity": "sha512-7PGFlmtwsEADb0WYyvCMa1t+yke6daIG4Wirafur5kcf+MhUnPms1UeR0CKQdTZD81yESwMHbtn+TR+dMviakQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "functions-have-names": "^1.2.3", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/set-proto": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/set-proto/-/set-proto-1.0.0.tgz", + "integrity": "sha512-RJRdvCo6IAnPdsvP/7m6bsQqNnn1FCBX5ZNtFL98MmFF/4xAIJTIg1YbHW5DC2W5SKZanrC6i4HsJqlajw/dZw==", + "dev": true, + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/sharp": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.34.5.tgz", + "integrity": "sha512-Ou9I5Ft9WNcCbXrU9cMgPBcCK8LiwLqcbywW3t4oDV37n1pzpuNLsYiAV8eODnjbtQlSDwZ2cUEeQz4E54Hltg==", + "hasInstallScript": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@img/colour": "^1.0.0", + "detect-libc": "^2.1.2", + "semver": "^7.7.3" + }, + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-darwin-arm64": "0.34.5", + "@img/sharp-darwin-x64": "0.34.5", + "@img/sharp-libvips-darwin-arm64": "1.2.4", + "@img/sharp-libvips-darwin-x64": "1.2.4", + "@img/sharp-libvips-linux-arm": "1.2.4", + "@img/sharp-libvips-linux-arm64": "1.2.4", + "@img/sharp-libvips-linux-ppc64": "1.2.4", + "@img/sharp-libvips-linux-riscv64": "1.2.4", + "@img/sharp-libvips-linux-s390x": "1.2.4", + "@img/sharp-libvips-linux-x64": "1.2.4", + "@img/sharp-libvips-linuxmusl-arm64": "1.2.4", + "@img/sharp-libvips-linuxmusl-x64": "1.2.4", + "@img/sharp-linux-arm": "0.34.5", + "@img/sharp-linux-arm64": "0.34.5", + "@img/sharp-linux-ppc64": "0.34.5", + "@img/sharp-linux-riscv64": "0.34.5", + "@img/sharp-linux-s390x": "0.34.5", + "@img/sharp-linux-x64": "0.34.5", + "@img/sharp-linuxmusl-arm64": "0.34.5", + "@img/sharp-linuxmusl-x64": "0.34.5", + "@img/sharp-wasm32": "0.34.5", + "@img/sharp-win32-arm64": "0.34.5", + "@img/sharp-win32-ia32": "0.34.5", + "@img/sharp-win32-x64": "0.34.5" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/side-channel": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", + "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/stable-hash": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/stable-hash/-/stable-hash-0.0.5.tgz", + "integrity": "sha512-+L3ccpzibovGXFK+Ap/f8LOS0ahMrHTf3xu7mMLSpEGU0EO9ucaysSylKo9eRDFNhWve/y275iPmIZ4z39a9iA==", + "dev": true, + "license": "MIT" + }, + "node_modules/stop-iteration-iterator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.1.0.tgz", + "integrity": "sha512-eLoXW/DHyl62zxY4SCaIgnRhuMr6ri4juEYARS8E6sCEqzKpOiE521Ucofdx+KnDZl5xmvGYaaKCk5FEOxJCoQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "internal-slot": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/string.prototype.includes": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/string.prototype.includes/-/string.prototype.includes-2.0.1.tgz", + "integrity": "sha512-o7+c9bW6zpAdJHTtujeePODAhkuicdAryFsfVKwA+wGw89wJ4GTY484WTucM9hLtDEOpOvI+aHnzqnC5lHp4Rg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.3" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/string.prototype.matchall": { + "version": "4.0.12", + "resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.12.tgz", + "integrity": "sha512-6CC9uyBL+/48dYizRf7H7VAYCMCNTBeM78x/VTUe9bFEaxBepPJDa1Ow99LqI/1yF7kuy7Q3cQsYMrcjGUcskA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.3", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.6", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.0.0", + "get-intrinsic": "^1.2.6", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "internal-slot": "^1.1.0", + "regexp.prototype.flags": "^1.5.3", + "set-function-name": "^2.0.2", + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string.prototype.repeat": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/string.prototype.repeat/-/string.prototype.repeat-1.0.0.tgz", + "integrity": "sha512-0u/TldDbKD8bFCQ/4f5+mNRrXwZ8hg2w7ZR8wa16e8z9XpePWl3eGEcUD0OXpEH/VJH/2G3gjUtR3ZOiBe2S/w==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.5" + } + }, + "node_modules/string.prototype.trim": { + "version": "1.2.10", + "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.10.tgz", + "integrity": "sha512-Rs66F0P/1kedk5lyYyH9uBzuiI/kNRmwJAR9quK6VOtIpZ2G+hMZd+HQbbv25MgCA6gEffoMZYxlTod4WcdrKA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.2", + "define-data-property": "^1.1.4", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.5", + "es-object-atoms": "^1.0.0", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string.prototype.trimend": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.9.tgz", + "integrity": "sha512-G7Ok5C6E/j4SGfyLCloXTrngQIQU3PWtXGst3yM7Bea9FRURf1S42ZHlZZtsNque2FN2PoUhfZXYLNWwEr4dLQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.2", + "define-properties": "^1.2.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string.prototype.trimstart": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.8.tgz", + "integrity": "sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/styled-jsx": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.1.6.tgz", + "integrity": "sha512-qSVyDTeMotdvQYoHWLNGwRFJHC+i+ZvdBRYosOFgC+Wg1vx4frN2/RG/NA7SYqqvKNLf39P2LSRA2pu6n0XYZA==", + "license": "MIT", + "dependencies": { + "client-only": "0.0.1" + }, + "engines": { + "node": ">= 12.0.0" + }, + "peerDependencies": { + "react": ">= 16.8.0 || 17.x.x || ^18.0.0-0 || ^19.0.0-0" + }, + "peerDependenciesMeta": { + "@babel/core": { + "optional": true + }, + "babel-plugin-macros": { + "optional": true + } + } + }, + "node_modules/sucrase": { + "version": "3.35.1", + "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.35.1.tgz", + "integrity": "sha512-DhuTmvZWux4H1UOnWMB3sk0sbaCVOoQZjv8u1rDoTV0HTdGem9hkAZtl4JZy8P2z4Bg0nT+YMeOFyVr4zcG5Tw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.2", + "commander": "^4.0.0", + "lines-and-columns": "^1.1.6", + "mz": "^2.7.0", + "pirates": "^4.0.1", + "tinyglobby": "^0.2.11", + "ts-interface-checker": "^0.1.9" + }, + "bin": { + "sucrase": "bin/sucrase", + "sucrase-node": "bin/sucrase-node" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/tailwindcss": { + "version": "3.4.19", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.19.tgz", + "integrity": "sha512-3ofp+LL8E+pK/JuPLPggVAIaEuhvIz4qNcf3nA1Xn2o/7fb7s/TYpHhwGDv1ZU3PkBluUVaF8PyCHcm48cKLWQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@alloc/quick-lru": "^5.2.0", + "arg": "^5.0.2", + "chokidar": "^3.6.0", + "didyoumean": "^1.2.2", + "dlv": "^1.1.3", + "fast-glob": "^3.3.2", + "glob-parent": "^6.0.2", + "is-glob": "^4.0.3", + "jiti": "^1.21.7", + "lilconfig": "^3.1.3", + "micromatch": "^4.0.8", + "normalize-path": "^3.0.0", + "object-hash": "^3.0.0", + "picocolors": "^1.1.1", + "postcss": "^8.4.47", + "postcss-import": "^15.1.0", + "postcss-js": "^4.0.1", + "postcss-load-config": "^4.0.2 || ^5.0 || ^6.0", + "postcss-nested": "^6.2.0", + "postcss-selector-parser": "^6.1.2", + "resolve": "^1.22.8", + "sucrase": "^3.35.0" + }, + "bin": { + "tailwind": "lib/cli.js", + "tailwindcss": "lib/cli.js" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/tailwindcss/node_modules/fast-glob": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", + "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.8" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/tailwindcss/node_modules/fast-glob/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/thenify": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", + "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", + "dev": true, + "license": "MIT", + "dependencies": { + "any-promise": "^1.0.0" + } + }, + "node_modules/thenify-all": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", + "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", + "dev": true, + "license": "MIT", + "dependencies": { + "thenify": ">= 3.1.0 < 4" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.15", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", + "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.3" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tinyglobby/node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/tinyglobby/node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/ts-api-utils": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.4.0.tgz", + "integrity": "sha512-3TaVTaAv2gTiMB35i3FiGJaRfwb3Pyn/j3m/bfAvGe8FB7CF6u+LMYqYlDh7reQf7UNvoTvdfAqHGmPGOSsPmA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18.12" + }, + "peerDependencies": { + "typescript": ">=4.8.4" + } + }, + "node_modules/ts-interface-checker": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", + "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/tsconfig-paths": { + "version": "3.15.0", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz", + "integrity": "sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/json5": "^0.0.29", + "json5": "^1.0.2", + "minimist": "^1.2.6", + "strip-bom": "^3.0.0" + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "license": "0BSD" + }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/typed-array-buffer": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/typed-array-buffer/-/typed-array-buffer-1.0.3.tgz", + "integrity": "sha512-nAYYwfY3qnzX30IkA6AQZjVbtK6duGontcQm1WSG1MD94YLqK0515GNApXkoxKOWMusVssAHWLh9SeaoefYFGw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "es-errors": "^1.3.0", + "is-typed-array": "^1.1.14" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/typed-array-byte-length": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/typed-array-byte-length/-/typed-array-byte-length-1.0.3.tgz", + "integrity": "sha512-BaXgOuIxz8n8pIq3e7Atg/7s+DpiYrxn4vdot3w9KbnBhcRQq6o3xemQdIfynqSeXeDrF32x+WvfzmOjPiY9lg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "for-each": "^0.3.3", + "gopd": "^1.2.0", + "has-proto": "^1.2.0", + "is-typed-array": "^1.1.14" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/typed-array-byte-offset": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/typed-array-byte-offset/-/typed-array-byte-offset-1.0.4.tgz", + "integrity": "sha512-bTlAFB/FBYMcuX81gbL4OcpH5PmlFHqlCCpAl8AlEzMz5k53oNDvN8p1PNOWLEmI2x4orp3raOFB51tv9X+MFQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "available-typed-arrays": "^1.0.7", + "call-bind": "^1.0.8", + "for-each": "^0.3.3", + "gopd": "^1.2.0", + "has-proto": "^1.2.0", + "is-typed-array": "^1.1.15", + "reflect.getprototypeof": "^1.0.9" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/typed-array-length": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/typed-array-length/-/typed-array-length-1.0.7.tgz", + "integrity": "sha512-3KS2b+kL7fsuk/eJZ7EQdnEmQoaho/r6KUef7hxvltNA5DR8NAUM+8wJMbJyZ4G9/7i3v5zPBIMN5aybAh2/Jg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.7", + "for-each": "^0.3.3", + "gopd": "^1.0.1", + "is-typed-array": "^1.1.13", + "possible-typed-array-names": "^1.0.0", + "reflect.getprototypeof": "^1.0.6" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/unbox-primitive": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.1.0.tgz", + "integrity": "sha512-nWJ91DjeOkej/TA8pXQ3myruKpKEYgqvpw9lz4OPHj/NWFNluYrjbz9j01CJ8yKQd2g4jFoOkINCTW2I5LEEyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "has-bigints": "^1.0.2", + "has-symbols": "^1.1.0", + "which-boxed-primitive": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/unrs-resolver": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/unrs-resolver/-/unrs-resolver-1.11.1.tgz", + "integrity": "sha512-bSjt9pjaEBnNiGgc9rUiHGKv5l4/TGzDmYw3RhnkJGtLhbnnA/5qJj7x3dNDCRx/PJxu774LlH8lCOlB4hEfKg==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "napi-postinstall": "^0.3.0" + }, + "funding": { + "url": "https://opencollective.com/unrs-resolver" + }, + "optionalDependencies": { + "@unrs/resolver-binding-android-arm-eabi": "1.11.1", + "@unrs/resolver-binding-android-arm64": "1.11.1", + "@unrs/resolver-binding-darwin-arm64": "1.11.1", + "@unrs/resolver-binding-darwin-x64": "1.11.1", + "@unrs/resolver-binding-freebsd-x64": "1.11.1", + "@unrs/resolver-binding-linux-arm-gnueabihf": "1.11.1", + "@unrs/resolver-binding-linux-arm-musleabihf": "1.11.1", + "@unrs/resolver-binding-linux-arm64-gnu": "1.11.1", + "@unrs/resolver-binding-linux-arm64-musl": "1.11.1", + "@unrs/resolver-binding-linux-ppc64-gnu": "1.11.1", + "@unrs/resolver-binding-linux-riscv64-gnu": "1.11.1", + "@unrs/resolver-binding-linux-riscv64-musl": "1.11.1", + "@unrs/resolver-binding-linux-s390x-gnu": "1.11.1", + "@unrs/resolver-binding-linux-x64-gnu": "1.11.1", + "@unrs/resolver-binding-linux-x64-musl": "1.11.1", + "@unrs/resolver-binding-wasm32-wasi": "1.11.1", + "@unrs/resolver-binding-win32-arm64-msvc": "1.11.1", + "@unrs/resolver-binding-win32-ia32-msvc": "1.11.1", + "@unrs/resolver-binding-win32-x64-msvc": "1.11.1" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.2.3.tgz", + "integrity": "sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "escalade": "^3.2.0", + "picocolors": "^1.1.1" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true, + "license": "MIT" + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/which-boxed-primitive": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.1.1.tgz", + "integrity": "sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-bigint": "^1.1.0", + "is-boolean-object": "^1.2.1", + "is-number-object": "^1.1.1", + "is-string": "^1.1.1", + "is-symbol": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/which-builtin-type": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/which-builtin-type/-/which-builtin-type-1.2.1.tgz", + "integrity": "sha512-6iBczoX+kDQ7a3+YJBnh3T+KZRxM/iYNPXicqk66/Qfm1b93iu+yOImkg0zHbj5LNOcNv1TEADiZ0xa34B4q6Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "function.prototype.name": "^1.1.6", + "has-tostringtag": "^1.0.2", + "is-async-function": "^2.0.0", + "is-date-object": "^1.1.0", + "is-finalizationregistry": "^1.1.0", + "is-generator-function": "^1.0.10", + "is-regex": "^1.2.1", + "is-weakref": "^1.0.2", + "isarray": "^2.0.5", + "which-boxed-primitive": "^1.1.0", + "which-collection": "^1.0.2", + "which-typed-array": "^1.1.16" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/which-collection": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/which-collection/-/which-collection-1.0.2.tgz", + "integrity": "sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-map": "^2.0.3", + "is-set": "^2.0.3", + "is-weakmap": "^2.0.2", + "is-weakset": "^2.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/which-typed-array": { + "version": "1.1.19", + "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.19.tgz", + "integrity": "sha512-rEvr90Bck4WZt9HHFC4DJMsjvu7x+r6bImz0/BrbWb7A2djJ8hnZMrWnHo9F8ssv0OMErasDhftrfROTyqSDrw==", + "dev": true, + "license": "MIT", + "dependencies": { + "available-typed-arrays": "^1.0.7", + "call-bind": "^1.0.8", + "call-bound": "^1.0.4", + "for-each": "^0.3.5", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/word-wrap": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/zod": { + "version": "3.25.76", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", + "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + }, + "node_modules/zustand": { + "version": "5.0.9", + "resolved": "https://registry.npmjs.org/zustand/-/zustand-5.0.9.tgz", + "integrity": "sha512-ALBtUj0AfjJt3uNRQoL1tL2tMvj6Gp/6e39dnfT6uzpelGru8v1tPOGBzayOWbPJvujM8JojDk3E1LxeFisBNg==", + "license": "MIT", + "engines": { + "node": ">=12.20.0" + }, + "peerDependencies": { + "@types/react": ">=18.0.0", + "immer": ">=9.0.6", + "react": ">=18.0.0", + "use-sync-external-store": ">=1.2.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "immer": { + "optional": true + }, + "react": { + "optional": true + }, + "use-sync-external-store": { + "optional": true + } + } + } + } +} diff --git a/frontend/package.json b/frontend/package.json new file mode 100644 index 0000000..5f2cfb4 --- /dev/null +++ b/frontend/package.json @@ -0,0 +1,36 @@ +{ + "name": "satonano-frontend", + "version": "0.1.0", + "private": true, + "scripts": { + "dev": "next dev --turbopack", + "build": "next build", + "start": "next start", + "lint": "next lint", + "export": "next build" + }, + "dependencies": { + "next": "^15.1.3", + "react": "^19.0.0", + "react-dom": "^19.0.0", + "zustand": "^5.0.2", + "react-hook-form": "^7.54.2", + "@hookform/resolvers": "^3.9.1", + "zod": "^3.24.1", + "framer-motion": "^11.15.0", + "lucide-react": "^0.469.0", + "clsx": "^2.1.1" + }, + "devDependencies": { + "@types/node": "^22.10.5", + "@types/react": "^19.0.2", + "@types/react-dom": "^19.0.2", + "typescript": "^5.7.2", + "tailwindcss": "^3.4.17", + "postcss": "^8.4.49", + "autoprefixer": "^10.4.20", + "eslint": "^9.17.0", + "eslint-config-next": "^15.1.3" + } +} + diff --git a/frontend/postcss.config.mjs b/frontend/postcss.config.mjs new file mode 100644 index 0000000..0b705dd --- /dev/null +++ b/frontend/postcss.config.mjs @@ -0,0 +1,10 @@ +/** @type {import('postcss-load-config').Config} */ +const config = { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +}; + +export default config; + diff --git a/frontend/public/favicon.svg b/frontend/public/favicon.svg new file mode 100644 index 0000000..8bcda1b --- /dev/null +++ b/frontend/public/favicon.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/frontend/src/app/dashboard/layout.tsx b/frontend/src/app/dashboard/layout.tsx new file mode 100644 index 0000000..121ab28 --- /dev/null +++ b/frontend/src/app/dashboard/layout.tsx @@ -0,0 +1,37 @@ +'use client'; + +import { useEffect, ReactNode } from 'react'; +import { useRouter } from 'next/navigation'; +import { useAuthStore } from '@/lib/store'; +import { DashboardLayout } from '@/components/dashboard'; +import { PageLoader } from '@/components/ui'; + +interface LayoutProps { + children: ReactNode; +} + +export default function Layout({ children }: LayoutProps) { + const router = useRouter(); + const { isAuthenticated, isLoading, fetchUser } = useAuthStore(); + + useEffect(() => { + fetchUser(); + }, [fetchUser]); + + useEffect(() => { + if (!isLoading && !isAuthenticated) { + router.replace('/login'); + } + }, [isLoading, isAuthenticated, router]); + + if (isLoading) { + return ; + } + + if (!isAuthenticated) { + return ; + } + + return {children}; +} + diff --git a/frontend/src/app/dashboard/page.tsx b/frontend/src/app/dashboard/page.tsx new file mode 100644 index 0000000..928ac45 --- /dev/null +++ b/frontend/src/app/dashboard/page.tsx @@ -0,0 +1,152 @@ +'use client'; + +import { motion } from 'framer-motion'; +import { + Shield, + Clock, + User, + Mail, + Calendar, + Activity, +} from 'lucide-react'; + +import { Card, CardContent, Avatar } from '@/components/ui'; +import { useAuthStore } from '@/lib/store'; +import { formatDate, getDisplayName, getAvatarUrl } from '@/lib/utils'; + +export default function DashboardPage() { + const { user } = useAuthStore(); + + if (!user) return null; + + const stats = [ + { + label: '账户状态', + value: user.is_active ? '正常' : '已禁用', + icon: Shield, + color: user.is_active ? 'text-accent-green' : 'text-accent-red', + }, + { + label: '注册时间', + value: formatDate(user.created_at).split(' ')[0], + icon: Calendar, + color: 'text-primary', + }, + { + label: '最近登录', + value: user.last_login_at ? formatDate(user.last_login_at).split(' ')[0] : '首次登录', + icon: Clock, + color: 'text-accent-cyan', + }, + ]; + + return ( +
+ {/* 页面标题 */} + +

+ 欢迎回来,{getDisplayName(user)} +

+

+ 这是您的个人控制台 +

+
+ + {/* 统计卡片 */} +
+ {stats.map((stat, index) => ( + + + +
+ +
+
+

{stat.label}

+

{stat.value}

+
+
+
+
+ ))} +
+ + {/* 用户信息卡片 */} + + + +
+ {/* 头像 */} +
+ +
+ + {/* 用户详情 */} +
+
+

+ {getDisplayName(user)} +

+

@{user.username}

+
+ + {user.bio && ( +

+ {user.bio} +

+ )} + +
+
+ + ID: {user.id.slice(0, 8)}... +
+ + {user.email && ( +
+ + {user.email} +
+ )} + +
+ + 注册于 {formatDate(user.created_at)} +
+ +
+ + + {user.last_login_at + ? `最近活跃于 ${formatDate(user.last_login_at)}` + : '首次登录'} + +
+
+
+
+
+
+
+
+ ); +} + diff --git a/frontend/src/app/dashboard/profile/page.tsx b/frontend/src/app/dashboard/profile/page.tsx new file mode 100644 index 0000000..3c02e11 --- /dev/null +++ b/frontend/src/app/dashboard/profile/page.tsx @@ -0,0 +1,195 @@ +'use client'; + +import { useState } from 'react'; +import { useForm } from 'react-hook-form'; +import { zodResolver } from '@hookform/resolvers/zod'; +import { motion } from 'framer-motion'; +import { User, Mail, FileText, Link as LinkIcon, Save, CheckCircle } from 'lucide-react'; + +import { + Card, + CardHeader, + CardTitle, + CardDescription, + CardContent, + Button, + Input, + Alert, + Avatar, +} from '@/components/ui'; +import { useAuthStore } from '@/lib/store'; +import { updateProfileSchema, UpdateProfileFormData } from '@/lib/validations'; +import { getAvatarUrl, getDisplayName } from '@/lib/utils'; + +export default function ProfilePage() { + const { user, updateUser, error, clearError, isLoading } = useAuthStore(); + const [success, setSuccess] = useState(false); + + const { + register, + handleSubmit, + formState: { errors, isDirty }, + } = useForm({ + resolver: zodResolver(updateProfileSchema), + defaultValues: { + nickname: user?.nickname || '', + email: user?.email || '', + bio: user?.bio || '', + avatar_url: user?.avatar_url || '', + }, + }); + + const onSubmit = async (data: UpdateProfileFormData) => { + setSuccess(false); + try { + await updateUser({ + nickname: data.nickname || undefined, + email: data.email || undefined, + bio: data.bio || undefined, + avatar_url: data.avatar_url || undefined, + }); + setSuccess(true); + setTimeout(() => setSuccess(false), 3000); + } catch { + // 错误已在 store 中处理 + } + }; + + if (!user) return null; + + return ( +
+ {/* 页面标题 */} + +

+ 个人资料 +

+

+ 管理您的个人信息 +

+
+ + {/* 当前头像预览 */} + + + + +
+

+ {getDisplayName(user)} +

+

@{user.username}

+

+ 用户名创建后无法修改 +

+
+
+
+
+ + {/* 编辑表单 */} + + + + 基本信息 + + 更新您的个人资料信息 + + + + {/* 提示信息 */} + {error && ( + + {error} + + )} + + {success && ( + + + 资料更新成功 + + )} + +
+ } + error={errors.nickname?.message} + /> + + } + error={errors.email?.message} + /> + + } + error={errors.avatar_url?.message} + hint="支持 http/https 链接" + /> + +
+ +
+ +