mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-09 02:47:45 +08:00
- 新建独立 aether-admin crate 承载 admin 相关共享契约与纯辅助函数 - 拆分 ai_pipeline 下 kiro/private_envelope/conversion/planner 等大文件为子模块目录 - 重组 admin handlers 各业务域(billing/oauth/provider/system/users 等)为目录结构,移除 shared.rs/builders.rs 等反模式 - 移除 ai_pipeline runtime adapters 旧实现(claude/openai/gemini/kiro/vertex/antigravity 等),改由 provider transport 统一承载 - 移除 control_facade/execution_facade/auth_snapshot_facade 等冗余 facade 层 - 拆分 query/billing 与 query/monitoring 模块、state/runtime/payments 与 security 模块 - 扩展架构测试覆盖 admin_billing/admin_model/admin_users 等新模块 - 删除 docs/architecture/refactor-execution-plan.md 已完成的执行计划文档
125 lines
4.3 KiB
Rust
125 lines
4.3 KiB
Rust
pub(crate) fn admin_provider_id_for_health_monitor(request_path: &str) -> Option<String> {
|
|
admin_provider_id_for_suffix(request_path, "/health-monitor")
|
|
}
|
|
|
|
pub(crate) fn admin_provider_id_for_mapping_preview(request_path: &str) -> Option<String> {
|
|
admin_provider_id_for_suffix(request_path, "/mapping-preview")
|
|
}
|
|
|
|
pub(crate) fn admin_provider_id_for_pool_status(request_path: &str) -> Option<String> {
|
|
admin_provider_id_for_suffix(request_path, "/pool-status")
|
|
}
|
|
|
|
pub(crate) fn admin_provider_clear_pool_cooldown_parts(
|
|
request_path: &str,
|
|
) -> Option<(String, String)> {
|
|
admin_provider_pool_key_route_parts(request_path, "/pool/clear-cooldown/")
|
|
}
|
|
|
|
pub(crate) fn admin_provider_reset_pool_cost_parts(request_path: &str) -> Option<(String, String)> {
|
|
admin_provider_pool_key_route_parts(request_path, "/pool/reset-cost/")
|
|
}
|
|
|
|
pub(crate) fn admin_provider_delete_task_parts(request_path: &str) -> Option<(String, String)> {
|
|
let raw = request_path.strip_prefix("/api/admin/providers/")?;
|
|
let (provider_id, task_id) = raw.split_once("/delete-task/")?;
|
|
let provider_id = provider_id.trim().trim_matches('/');
|
|
let task_id = task_id.trim().trim_matches('/');
|
|
if provider_id.is_empty()
|
|
|| task_id.is_empty()
|
|
|| provider_id.contains('/')
|
|
|| task_id.contains('/')
|
|
{
|
|
None
|
|
} else {
|
|
Some((provider_id.to_string(), task_id.to_string()))
|
|
}
|
|
}
|
|
|
|
pub(crate) fn admin_provider_id_for_summary(request_path: &str) -> Option<String> {
|
|
admin_provider_id_for_suffix(request_path, "/summary")
|
|
}
|
|
|
|
pub(crate) fn admin_provider_id_for_manage_path(request_path: &str) -> Option<String> {
|
|
let raw = request_path.strip_prefix("/api/admin/providers/")?;
|
|
let normalized = raw.trim().trim_matches('/');
|
|
if normalized.is_empty() || normalized.contains('/') {
|
|
None
|
|
} else {
|
|
Some(normalized.to_string())
|
|
}
|
|
}
|
|
|
|
pub(crate) fn is_admin_providers_root(request_path: &str) -> bool {
|
|
matches!(
|
|
request_path,
|
|
"/api/admin/providers" | "/api/admin/providers/"
|
|
)
|
|
}
|
|
|
|
pub(crate) fn admin_provider_id_for_models_list(request_path: &str) -> Option<String> {
|
|
admin_provider_id_for_suffix(request_path, "/models")
|
|
}
|
|
|
|
pub(crate) fn admin_provider_model_route_parts(request_path: &str) -> Option<(String, String)> {
|
|
let raw = request_path.strip_prefix("/api/admin/providers/")?;
|
|
let (provider_id, model_id) = raw.split_once("/models/")?;
|
|
let provider_id = provider_id.trim().trim_matches('/');
|
|
let model_id = model_id.trim().trim_matches('/');
|
|
if provider_id.is_empty()
|
|
|| model_id.is_empty()
|
|
|| provider_id.contains('/')
|
|
|| model_id.contains('/')
|
|
{
|
|
None
|
|
} else {
|
|
Some((provider_id.to_string(), model_id.to_string()))
|
|
}
|
|
}
|
|
|
|
pub(crate) fn admin_provider_models_batch_path(request_path: &str) -> Option<String> {
|
|
admin_provider_id_for_suffix(request_path, "/models/batch")
|
|
}
|
|
|
|
pub(crate) fn admin_provider_available_source_models_path(request_path: &str) -> Option<String> {
|
|
admin_provider_id_for_suffix(request_path, "/available-source-models")
|
|
}
|
|
|
|
pub(crate) fn admin_provider_assign_global_models_path(request_path: &str) -> Option<String> {
|
|
admin_provider_id_for_suffix(request_path, "/assign-global-models")
|
|
}
|
|
|
|
pub(crate) fn admin_provider_import_models_path(request_path: &str) -> Option<String> {
|
|
admin_provider_id_for_suffix(request_path, "/import-from-upstream")
|
|
}
|
|
|
|
fn admin_provider_id_for_suffix(request_path: &str, suffix: &str) -> Option<String> {
|
|
let raw = request_path.strip_prefix("/api/admin/providers/")?;
|
|
let raw = raw.strip_suffix(suffix)?;
|
|
let normalized = raw.trim().trim_matches('/');
|
|
if normalized.is_empty() || normalized.contains('/') {
|
|
None
|
|
} else {
|
|
Some(normalized.to_string())
|
|
}
|
|
}
|
|
|
|
fn admin_provider_pool_key_route_parts(
|
|
request_path: &str,
|
|
marker: &str,
|
|
) -> Option<(String, String)> {
|
|
let raw = request_path.strip_prefix("/api/admin/providers/")?;
|
|
let (provider_id, key_id) = raw.split_once(marker)?;
|
|
let provider_id = provider_id.trim().trim_matches('/');
|
|
let key_id = key_id.trim().trim_matches('/');
|
|
if provider_id.is_empty()
|
|
|| key_id.is_empty()
|
|
|| provider_id.contains('/')
|
|
|| key_id.contains('/')
|
|
{
|
|
None
|
|
} else {
|
|
Some((provider_id.to_string(), key_id.to_string()))
|
|
}
|
|
}
|