refactor: 拆分大文件(contracts 端点、整理服务、浏览器纯函数、整理弹窗来源)
- contracts/src/api.ts 2733 行 → api/*.ts 13 个领域文件 + shared.ts;api.ts 按原顺序合并 Api。 新旧对比:354 个端点内容与顺序一致,分组键与对外导出一致 - acquisition-organize/services/organize.ts 2645 行 → organize-types / -plan / -exec / -finalize / -records, organize.ts 保留为汇总入口,外部引用不变 - browser/service.ts 类外的纯函数(视图映射、原因文案、坐标换算、图片尺寸、出口代理)移到 session-view.ts, service.ts 照旧转出 - organize-wizard:来源解析 useResolvedSource 移到 source.ts,FormSelect 移到 form-select.tsx 只挪位置不改逻辑;typecheck、lint、test:all、web build、server 编译与编译产物自检通过。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
c9e8120fc6
commit
8bec4bad5d
26 files changed
+5906
-5696
No files matched your search
@@ -0,0 +1,126 @@
|
||||
import { z } from "zod";
|
||||
import { Id, IdParam } from "../common.ts";
|
||||
import * as board from "../download-board.ts";
|
||||
import * as execution from "../execution.ts";
|
||||
import { crud, ep, R } from "./shared.ts";
|
||||
|
||||
export const executionApi = {
|
||||
// ── 执行 ──
|
||||
tasks: {
|
||||
...crud(
|
||||
"/tasks",
|
||||
"任务",
|
||||
{
|
||||
row: execution.Task,
|
||||
filters: {
|
||||
status: execution.TaskStatus.optional(),
|
||||
kind: execution.TaskKind.optional(),
|
||||
subjectId: Id.optional(),
|
||||
},
|
||||
},
|
||||
R,
|
||||
),
|
||||
cancel: ep({
|
||||
method: "post",
|
||||
path: "/tasks/{id}/cancel",
|
||||
scope: "organize.execute",
|
||||
summary: "取消任务(停止未来步骤)",
|
||||
params: IdParam,
|
||||
body: execution.TaskCancelRequest,
|
||||
response: execution.Task,
|
||||
}),
|
||||
retry: ep({
|
||||
method: "post",
|
||||
path: "/tasks/{id}/retry",
|
||||
scope: "organize.execute",
|
||||
summary: "重试失败任务",
|
||||
params: IdParam,
|
||||
response: execution.Task,
|
||||
}),
|
||||
operations: ep({
|
||||
method: "get",
|
||||
path: "/tasks/{id}/operations",
|
||||
scope: "read",
|
||||
summary: "任务的操作账本(业务时间线)",
|
||||
params: IdParam,
|
||||
response: z.object({ items: z.array(execution.AssetOperation) }),
|
||||
}),
|
||||
},
|
||||
acquisitionPlans: {
|
||||
...crud(
|
||||
"/acquisition-plans",
|
||||
"下载计划",
|
||||
{
|
||||
row: execution.AcquisitionPlan,
|
||||
filters: { slotId: Id.optional(), status: execution.PlanStatus.optional() },
|
||||
},
|
||||
R,
|
||||
),
|
||||
create: ep({
|
||||
method: "post",
|
||||
path: "/acquisition-plans",
|
||||
scope: "organize.execute",
|
||||
summary: "独立手动下载:不要求订阅,支持未知资源确认、下载器与目录选择,以及本次正常或洗版入库",
|
||||
body: execution.ManualAcquisitionRequest,
|
||||
response: execution.ManualAcquisitionResult,
|
||||
}),
|
||||
why: ep({
|
||||
method: "get",
|
||||
path: "/acquisition-plans/{id}/why",
|
||||
scope: "read",
|
||||
summary:
|
||||
"下载的来由:来源(订阅 / 智能体会话 / 手动)、目的(补缺 / 升级 / 换源)、被替换的版本、选中理由要点与原始评估",
|
||||
params: IdParam,
|
||||
response: board.DownloadWhy,
|
||||
}),
|
||||
cancel: ep({
|
||||
method: "post",
|
||||
path: "/acquisition-plans/{id}/cancel",
|
||||
scope: "organize.execute",
|
||||
summary:
|
||||
"取消还没提交到下载器的计划(待批准 / 已预留):释放收录版本与预算预留;已有下载任务的返回 409。待批准的计划请拒绝审批(拒绝后计划自动取消)",
|
||||
params: IdParam,
|
||||
response: execution.AcquisitionPlan,
|
||||
}),
|
||||
},
|
||||
downloadTasks: {
|
||||
...crud(
|
||||
"/download-tasks",
|
||||
"下载任务",
|
||||
{
|
||||
row: execution.DownloadTask,
|
||||
filters: {
|
||||
instanceId: Id.optional(),
|
||||
status: execution.DownloadStatus.optional(),
|
||||
managed: z.enum(["true", "false"]).optional(),
|
||||
},
|
||||
},
|
||||
R,
|
||||
),
|
||||
board: ep({
|
||||
method: "get",
|
||||
path: "/download-tasks/board",
|
||||
scope: "read",
|
||||
summary:
|
||||
"下载面板:按进行中 / 已完成分组列出下载任务(进行中含还没提交、在等批准或下载盘空间的计划,kind=plan),附每个种子的实时速度、剩余时间、连接数与下载器总速度(实时数据短时缓存)",
|
||||
query: board.DownloadBoardQuery,
|
||||
response: board.DownloadBoard,
|
||||
}),
|
||||
pause: ep({
|
||||
method: "post",
|
||||
path: "/download-tasks/{id}/pause",
|
||||
scope: "organize.execute",
|
||||
summary: "暂停(记为用户暂停,阈值恢复不会自动恢复)",
|
||||
params: IdParam,
|
||||
response: execution.DownloadTask,
|
||||
}),
|
||||
resume: ep({
|
||||
method: "post",
|
||||
path: "/download-tasks/{id}/resume",
|
||||
scope: "organize.execute",
|
||||
summary: "恢复下载",
|
||||
params: IdParam,
|
||||
response: execution.DownloadTask,
|
||||
}),
|
||||
},
|
||||
} as const;
|
||||
Reference in new issue
Block a user