feat: 添加审批系统和遗留查询功能支持 - 添加审批系统,包括审批请求模型、服务和路由,支持创建、批准和拒绝操作 - 实现审批API密钥验证机制,区分普通API和审批API访问权限 - 添加Alembic数据库迁移支持,更新初始schema版本并添加降级保护 - 配置遗留MySQL查询白名单机制,支持命名查询和参数化查询 - 更新业务服务以集成审批流程,高风险操作需要审批票证 - 调整安全认证使用常量定义的HTTP头,增强安全性比较 - 优化.gitignore配置,添加日志目录排除和文档文件包含规则 - 更新Dockerfile添加alembic依赖包,修复OpenClaw适配器错误处理 ```
70 lines
1.9 KiB
Python
70 lines
1.9 KiB
Python
from typing import Any
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from app.core.constants import ActorValue
|
|
from app.modules.legacy_mysql.constants import LegacyQueryName
|
|
|
|
|
|
class ReadonlyQueryRequest(BaseModel):
|
|
"""Allowlisted readonly query request for the legacy MySQL connection."""
|
|
|
|
query_name: str | None = Field(
|
|
default=LegacyQueryName.PROJECTS,
|
|
description="Configured readonly query name.",
|
|
)
|
|
sql: str | None = Field(
|
|
default=None,
|
|
description="Deprecated: must exactly match a configured readonly query.",
|
|
)
|
|
params: dict[str, Any] = Field(default_factory=dict)
|
|
limit: int = Field(default=100, ge=1, le=500)
|
|
|
|
|
|
class QueryResult(BaseModel):
|
|
"""Tabular query result returned as JSON rows."""
|
|
|
|
columns: list[str]
|
|
rows: list[dict[str, Any]]
|
|
row_count: int
|
|
|
|
|
|
class LegacyProjectRecord(BaseModel):
|
|
"""Raw project row from the legacy project system."""
|
|
|
|
data: dict[str, Any]
|
|
|
|
|
|
class LegacyProjectSyncRequest(BaseModel):
|
|
"""Request body for syncing legacy projects into the internal ledger."""
|
|
|
|
source_query: str | None = Field(
|
|
default=None,
|
|
description="Deprecated: must exactly match a configured readonly query.",
|
|
)
|
|
source_query_name: str | None = Field(
|
|
default=LegacyQueryName.PROJECTS,
|
|
description="Configured readonly query name for project sync.",
|
|
)
|
|
field_map: dict[str, str] = Field(
|
|
default_factory=dict,
|
|
description=(
|
|
"Map internal project fields to legacy row fields, "
|
|
"e.g. {'name': 'project_name'}."
|
|
),
|
|
)
|
|
limit: int = Field(default=100, ge=1, le=500)
|
|
dry_run: bool = True
|
|
actor: str = ActorValue.API
|
|
|
|
|
|
class LegacyProjectSyncResult(BaseModel):
|
|
"""Summary of a legacy project sync operation."""
|
|
|
|
dry_run: bool
|
|
created: int
|
|
updated: int
|
|
skipped: int
|
|
sync_run_code: str | None = None
|
|
items: list[dict[str, Any]]
|