feat(adapters): 接入 CloudCone/Zeabur/Dynadot/新网/Agnes 五个平台
线上平台列表里 cloudcone、zeabur、xinwang、dynadot、agnes 的 sdk_type 仍为空, 平台卡片只能显示「未对接」,用户无法同步。按各自真实 API 能力补齐: - CloudCone:实例清单 + 开机/关机/重启;无公开账单接口,不声明余额与续费 - Zeabur:服务器清单 + 重启;毫核/MB 归一化为核/GB,未采集时不伪造规格 - Dynadot:域名清单(含到期日)+ 账户余额;set_dns2 位置参数无法安全 CRUD - 新网:代理 API 按域名逐个查到期日;无列表接口,需在账号里填 domains 清单 - Agnes:/models 校验 Key;无余额接口,如实标记不支持 配套改动: - _align_preset_providers 为库中为空的 sdk_type 回填种子值(启动即生效), 避免新适配器上线后线上仍停留在「未对接」 - 适配器可声明 plain_config,代理号/域名等非密钥字段前端按明文输入 - PRESET_PROVIDERS 五条记录填上对应 sdk_type 测试:445 passed(新增 tests/test_platform_adapters.py),vitest 62 passed。
This commit is contained in:
+12
-5
@@ -189,13 +189,13 @@ def _align_preset_providers(conn) -> None:
|
||||
(新增适配器、废弃从未实现的 sdk_type)必须在这里落地,否则线上会长期
|
||||
停留在旧声明上。
|
||||
|
||||
- sdk_type:库里声明的值不在适配器注册表内就清空。留着会让平台卡片显示
|
||||
「API 对接: xxx」,用户建好账号点同步才撞「暂不支持的 SDK 类型」——
|
||||
声明支持却不支持,比明说不支持更糟。
|
||||
- sdk_type:库里声明了但注册表没有的值要清空(声明支持却不支持,比明说不支持
|
||||
更糟);库里为空而种子已给出且已实现的要补上——否则新增适配器上线后,
|
||||
线上平台卡片仍停留在「未对接」,用户永远点不到同步。
|
||||
- services:只增量补标签,不删除。用户可能手动加过标签(线上 aliyun-intl
|
||||
就多了 ai_agent/other),按种子值整体覆盖会丢用户配置。
|
||||
|
||||
只处理 slug 命中 PRESET_PROVIDERS 的行,用户自建平台(如 tothost)不动。
|
||||
只处理 slug 命中 PRESET_PROVIDERS 的行,用户自建平台不动。
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from app.adapters import registry
|
||||
@@ -213,12 +213,19 @@ def _align_preset_providers(conn) -> None:
|
||||
if not data:
|
||||
continue
|
||||
|
||||
declared = row[2]
|
||||
declared = (row[2] or "").strip()
|
||||
if declared and declared not in supported:
|
||||
conn.execute(
|
||||
sa.text("UPDATE providers SET sdk_type = NULL WHERE id = :id"),
|
||||
{"id": row[0]},
|
||||
)
|
||||
elif not declared:
|
||||
seed_sdk = (data.get("sdk_type") or "").strip()
|
||||
if seed_sdk and seed_sdk in supported:
|
||||
conn.execute(
|
||||
sa.text("UPDATE providers SET sdk_type = :sdk WHERE id = :id"),
|
||||
{"sdk": seed_sdk, "id": row[0]},
|
||||
)
|
||||
|
||||
seed_services = [s.strip() for s in (data.get("services") or "").split(",") if s.strip()]
|
||||
if not seed_services:
|
||||
|
||||
Reference in New Issue
Block a user