130 lines
4.9 KiB
JavaScript
130 lines
4.9 KiB
JavaScript
// api/bioflow.js —— 生信服务 8098 端点封装(P2-P5/dev3 A3 归属)
|
||
// 全部经 BFF 反代(浏览器同源 /api/bioflow/*),底层走 http.js 统一错误信封
|
||
// (BFF 反代失败 502/503 UPSTREAM_DOWN;生信服务错误统一 {ok:false,error:{...}})。
|
||
// SSE 流(chat/stream、jobs/{id}/events)raw 透传(fetch Response 由调用方消费)。
|
||
|
||
import { get, post, del } from './http.js';
|
||
|
||
// ---------- 探活(FR-BIO-025 显隐) ----------
|
||
export function bioflowHealth(opts = {}) {
|
||
return get('/api/bioflow/health', {}, { timeout: 5000, ...opts });
|
||
}
|
||
|
||
// ---------- 阶段目录(FR-BIO-002/003) ----------
|
||
export function bioflowCatalog(params = {}, opts = {}) {
|
||
return get('/api/bioflow/catalog', params, opts);
|
||
}
|
||
|
||
// ---------- 对话规划(SSE;FR-BIO-001/002/003/023/026 全链路) ----------
|
||
/** POST /api/bioflow/chat/stream —— 返回原始 fetch Response(SSE 由调用方消费)。
|
||
* body: {session_id, message, has_attachments, has_active_artifact, has_bioflow_context, last_seq} */
|
||
export function bioflowChatStream(body, opts = {}) {
|
||
return post('/api/bioflow/chat/stream', body, { raw: true, timeout: 0, ...opts });
|
||
}
|
||
|
||
// ---------- 流程知识库咨询(FR-BIO-026) ----------
|
||
export function bioflowAsk(body, opts = {}) {
|
||
return post('/api/bioflow/ask', body, opts);
|
||
}
|
||
|
||
// ---------- 任务(FR-BIO-004/024) ----------
|
||
export function createBioflowJob(body, opts = {}) {
|
||
return post('/api/bioflow/jobs', body, opts);
|
||
}
|
||
|
||
export function listBioflowJobs(params = {}, opts = {}) {
|
||
return get('/api/bioflow/jobs', params, opts);
|
||
}
|
||
|
||
export function getBioflowJob(jobId, opts = {}) {
|
||
return get(`/api/bioflow/jobs/${jobId}`, {}, opts);
|
||
}
|
||
|
||
export function deleteBioflowJob(jobId, opts = {}) {
|
||
return del(`/api/bioflow/jobs/${jobId}`, opts);
|
||
}
|
||
|
||
// ---------- 文件上传 / 服务器路径登记(FR-BIO-006/007) ----------
|
||
/** multipart 流式上传(XHR 进度)或 JSON 路径登记(server_path)。
|
||
* 上传超时 3600s(与 BFF 反代上传阶梯一致;0 = 不设前端超时,由 BFF 控制)。 */
|
||
export function uploadBioflowFile(jobId, body, opts = {}) {
|
||
return post(`/api/bioflow/jobs/${jobId}/files`, body, {
|
||
timeout: 0,
|
||
...opts,
|
||
});
|
||
}
|
||
|
||
export function listBioflowFiles(jobId, opts = {}) {
|
||
return get(`/api/bioflow/jobs/${jobId}/files`, {}, opts);
|
||
}
|
||
|
||
// ---------- 阶段控制(FR-BIO-009/012/010/011) ----------
|
||
export function confirmBioflowStage(jobId, stage, params, opts = {}) {
|
||
return post(`/api/bioflow/jobs/${jobId}/stages/${stage}/confirm`, { params }, opts);
|
||
}
|
||
|
||
export function rerunBioflowStage(jobId, stage, params, opts = {}) {
|
||
return post(`/api/bioflow/jobs/${jobId}/stages/${stage}/rerun`,
|
||
params === null || params === undefined ? {} : { params }, opts);
|
||
}
|
||
|
||
export function skipBioflowStage(jobId, stage, opts = {}) {
|
||
return post(`/api/bioflow/jobs/${jobId}/stages/${stage}/skip`, {}, opts);
|
||
}
|
||
|
||
export function pauseBioflowJob(jobId, opts = {}) {
|
||
return post(`/api/bioflow/jobs/${jobId}/pause`, {}, opts);
|
||
}
|
||
|
||
export function resumeBioflowJob(jobId, opts = {}) {
|
||
return post(`/api/bioflow/jobs/${jobId}/resume`, {}, opts);
|
||
}
|
||
|
||
export function getBioflowStageManifest(jobId, stage, opts = {}) {
|
||
return get(`/api/bioflow/jobs/${jobId}/stages/${stage}/manifest`, {}, opts);
|
||
}
|
||
|
||
// ---------- 任务事件(SSE;FR-BIO-014 断线重连回放) ----------
|
||
/** GET /api/bioflow/jobs/{id}/events —— 返回原始 fetch Response(SSE 由调用方消费)。
|
||
* params: {stage, last_seq} */
|
||
export function bioflowJobEvents(jobId, params = {}, opts = {}) {
|
||
return get(`/api/bioflow/jobs/${jobId}/events`, params, { raw: true, timeout: 0, ...opts });
|
||
}
|
||
|
||
// ---------- 报告修订(FR-BIO-019) ----------
|
||
export function reviseBioflowReport(jobId, body, opts = {}) {
|
||
return post(`/api/bioflow/report/${jobId}/revise`, body, opts);
|
||
}
|
||
|
||
// ---------- 存档(FR-BIO-020/021/022/023) ----------
|
||
export function createBioflowArchive(body, opts = {}) {
|
||
return post('/api/bioflow/archives', body, opts);
|
||
}
|
||
|
||
export function listBioflowArchives(params = {}, opts = {}) {
|
||
return get('/api/bioflow/archives', params, opts);
|
||
}
|
||
|
||
export function getBioflowArchive(archiveId, opts = {}) {
|
||
return get(`/api/bioflow/archives/${archiveId}`, {}, opts);
|
||
}
|
||
|
||
export function deleteBioflowArchive(archiveId, opts = {}) {
|
||
return del(`/api/bioflow/archives/${archiveId}`, opts);
|
||
}
|
||
|
||
/** 复用发起:POST archives/{id}/run(返回新任务详情) */
|
||
export function runBioflowArchive(archiveId, body, opts = {}) {
|
||
return post(`/api/bioflow/archives/${archiveId}/run`, body, opts);
|
||
}
|
||
|
||
/** 按名称匹配复用:POST archives/run(精确优先;模糊候选) */
|
||
export function runBioflowArchiveByName(body, opts = {}) {
|
||
return post('/api/bioflow/archives/run', body, opts);
|
||
}
|
||
|
||
/** 报告登记(BFF 反代落 doc_artifacts;template_name='bioflow_report' 与 A2 对齐) */
|
||
export function registerBioflowReport(body, opts = {}) {
|
||
return post('/api/bioflow/reports/register', body, opts);
|
||
}
|