数据目录闭环(前端):类型、接口、文案和纯函数——起草任务的逐段落盘、块进度字段和清单的 blank_columns_from;审阅队列、成批审阅、审阅进度、用过这张表的运行;导出导入(下载文件、预览、导入);表助手的事件流(按行读 data: <JSON>,开流前被拒带状态码和机读码,能停止);表助手的对话怎么截(最多 40 条、每条 4000 字、从用户的话开始)、待保存的修改怎么累积(同一路径以最后一次提案为准、保存带最早那条提案的版本、409 后按预览重算);审阅视图的地址参数、成批结果和表详情改过之后的状态同步;文案进 lib/terms.ts

This commit is contained in:
ThearchyHelios
2026-10-14 08:44:14 +08:00
parent a87b935ebf
commit a9ffbcfa86
6 changed files with 959 additions and 9 deletions
+182
View File
@@ -2884,6 +2884,16 @@ export interface CatalogDraftTask {
/** 模型分几段起草(超过 40 列的宽表拆成表级一段加列分段);不用模型时为 null */
parts_total: number | null
parts_done: number
/**
* 已经写进目录的段数:每写完一段就并入目录,停止、服务重启时已写进的段保留。老服务端没有这个键
*/
parts_written?: number
/**
* 这张表实际分成的块数和已结束的块数:额度用完、超时后段被缩小、拆半,块会比段多。不用模型时为 null;
* 老服务端没有这两个键
*/
chunks_total?: number | null
chunks_done?: number | null
added: number
updated: number
removed: number
@@ -2984,6 +2994,13 @@ export interface CatalogLastDraft {
model_error: string | null
/** 那次起草模型拿不准、留空的列数(同 CatalogDraftTask.blank_columns)。老服务端没有这个键 */
blank_columns?: number
/**
* 最近一次这张表结束于完成、部分完成的起草记下的留空列数(没有这样的起草为 null)。最近一次是停止、服务重启中断、
* 又没有新写入时,界面用它接着提示留空的列。老服务端没有这个键
*/
blank_columns_from?: number | null
/** 那次起草已写进目录的段数(同 CatalogDraftTask.parts_written)。接口约定里没有这一项,服务端给了才用 */
parts_written?: number
}
/**
@@ -3046,6 +3063,171 @@ export interface CatalogImpactTemplate {
nodes: CatalogImpactNode[]
}
// ---------------------------------------------------------------------------
// 审阅队列(/api/datasources/{id}/catalog/review-queue、review/batch、review-progress、{table}/usage,后端
// data/catalog_review.py):跨表列出推断项,按表的使用次数、这一项对数字的影响和来源排好,可以成批确认、驳回。
// ---------------------------------------------------------------------------
/** 队列的筛选:全部、影响数字的项(有效记录条件、去重、业务日期、关联关系、业务主键、度量类型)、名称和含义 */
export type CatalogReviewKind = 'all' | 'facts' | 'names'
/** 队列里的一项(只列推断状态的项) */
export interface CatalogReviewItem {
table_name: string
/** 审阅接口的路径写法 */
path: string
/** 字段名(valid_filter、label……) */
field: string
/** 给人看的位置(服务端写好的,比如「列 status 的码值」) */
field_label: string
value: unknown
/** 值写成一行字(服务端写好的) */
display: string
source: CatalogSource
status: CatalogStatus
note: string | null
/** 越大越靠前:表的使用次数权重 × 风险权重 × 来源权重 */
priority: number
/** 为什么排在这里(中文,服务端写好的) */
reasons: string[]
/** 所在表被运行用过的次数 */
table_usage: number
/** 所在表的目录版本:成批审阅时逐表带上 */
version: number
}
/** GET /catalog/review-queue */
export interface CatalogReviewQueue {
total: number
items: CatalogReviewItem[]
}
/** POST /catalog/review/batch 的一项 */
export interface CatalogReviewBatchItem {
table_name: string
path: string
action: CatalogReviewAction
if_version: number
}
/** 成批审阅逐条的结果:一张表冲突不影响别的表;成功的写明这张表写入后的版本 */
export interface CatalogReviewBatchResult {
table_name: string
path: string
ok: boolean
version: number | null
error: string | null
code: string | null
}
/** 用过这张表的一次运行(新的在前) */
export interface CatalogUsageRun {
run_id: string
workflow_id: string | null
workflow_name: string | null
run_class: 'formal' | 'exploratory' | null
status: string
started_at: string | null
}
/** GET /catalog/{table}/usage */
export interface CatalogTableUsage {
total: number
runs: CatalogUsageRun[]
}
/** GET /catalog/review-progress:常用的前 top_n 张表、全部表、影响数字的项各审阅到哪儿 */
export interface CatalogReviewProgress {
top_n: number
top: { tables: number; items_total: number; items_confirmed: number }
all: { items_total: number; items_confirmed: number; items_proposed: number; items_rejected: number }
facts: { proposed: number; confirmed: number }
}
// ---------------------------------------------------------------------------
// 导出导入(/api/datasources/{id}/catalog/export、import/preview、import,后端 data/catalog_transfer.py):
// 本机整理好的目录带到另一个实例。先预览(只读),确认后逐表写入。
// ---------------------------------------------------------------------------
/** 导出的文件:含全部状态的项 */
export interface CatalogExportFile {
format: 'agentlab-catalog'
version: 1
exported_at: string
source: { name: string; kind: string }
guidance: string | null
tables: Record<string, { notes: CatalogNotes; version: number }>
}
/** 一处冲突:这里已确认、已驳回的项和文件中的不一样,以这里为准 */
export interface CatalogImportConflict {
path: string
label: string
file_value: unknown
target_value: unknown
why: string
}
/** 预览、导入报告里的一张表 */
export interface CatalogImportTable {
/** 文件中的表名 */
table_name: string
/** 对上的这个数据源里的表名(名字不一样时才有意思);对不上为 null */
matched_as: string | null
add: number
update: number
keep: number
conflicts: CatalogImportConflict[]
skipped: { path: string; why: string }[]
/** 导入后这张表的目录版本(只有导入的报告有) */
version?: number | null
/** 这张表没导入的原因(逐表写入,一张表失败不影响别的)。接口约定里没有写明,服务端给了才显示 */
error?: string | null
}
export interface CatalogImportTotals {
tables: number
add: number
update: number
keep: number
conflicts: number
skipped: number
}
/** POST /catalog/import/preview、/catalog/import */
export interface CatalogImportReport {
tables: CatalogImportTable[]
/** 文件中有、这个数据源里对不上的表 */
unmatched_tables: string[]
totals: CatalogImportTotals
/** 起草要求:写入文件中的(这里还没有)、保留这里的、不导入 */
guidance: { file: string | null; target: string | null; action: 'keep' | 'replace' | 'none' }
}
// ---------------------------------------------------------------------------
// 表助手(POST /api/datasources/{id}/catalog/{table}/assistant,后端 data/catalog_assistant.py):对话完善一张表的
// 目录。回答是事件流,每个事件一行 data: <JSON>。对话不存服务端,每一轮都把前面的对话和还没保存的修改带上。
// ---------------------------------------------------------------------------
/** 提案里的一项:和助手流里的 catalog_patch 一样,多一个给人看的位置 */
export interface CatalogAssistantChange extends CatalogPatchChange {
label?: string
}
export type CatalogAssistantEvent =
| { type: 'text'; delta: string }
| { type: 'query'; sql: string; columns: string[]; rows: unknown[][]; row_count: number; error: string | null }
| { type: 'proposal'; source_id: string; table: string; version: number; changes: CatalogAssistantChange[] }
| { type: 'done'; usage: { input_tokens: number; output_tokens: number }; queries: number }
| { type: 'error'; message: string; code?: string | null }
/** 交给表助手的一轮请求 */
export interface CatalogAssistantRequest {
messages: { role: 'user' | 'assistant'; content: string }[]
/** 界面上还没保存的修改 */
pending: CatalogPatchSubmit[]
}
/** GET /datasources/{id}/catalog/{table}/impact */
export interface CatalogImpact {
table: string