1283f65a95
用户反馈:加了钉盘来源后「来源与目录」里看不到。根因不是丢数据,而是列表只列"已经有快照" 的来源 —— 首次扫描要几分钟到几十分钟(钉盘空间 2900+ 个文件夹),这段时间页面上什么都没有。 - 新 Store 方法 ListCatalogScanProgress:已启用 + 还没有 catalog head + 有在跑/排队的 source.catalog.refresh(三条件同时成立)。进度直接取 worker 写在任务载荷里的同一份计数 (progress/message/scanned_directories/discovered_directories/scanned_files),不另立口径。 - /api/v1/source-catalog/sources 在既有列表后追加这些行(snapshot_status="scanning" + scan_progress/scan_message)。走窄接口按需接线:未接线时安静跳过,不会把旧列表弄坏。 - 前端:左列显示「首次扫描中 44%」,选中后是进度面板(百分比 + 进度条 + 当前文案 + 已发现文件数),并说明"扫完自动出现目录";有来源在扫描时每 3 秒自动刷新列表, 扫完那一行自动变成「本地只读快照」。扫描中不拉目录节点、也不显示标注/格式入口。 - 解析器保持严格:snapshot_status 只接受 ready/scanning,scanning 必须带 scan_progress, 否则整包拒绝 —— 不给"假装 0%"的机会。 测试:postgres 集成测试(真库)覆盖四种不该出现的来源(停用、已有快照、任务类型不符、 历史上已完成的那次任务);前端 parser + 渲染各一条;Go 全绿、前端 192 条 + tsc 干净。 面板实测:左列「公司级营销资料管理 · 首次扫描中 44%」,主区「首次扫描中 · 44% / 正在扫描目录:已完成 1540 个文件夹 / 已发现约 4934 份文件」。
187 lines
6.6 KiB
Go
187 lines
6.6 KiB
Go
package governance
|
|
|
|
import "time"
|
|
|
|
type CatalogSource struct {
|
|
ConnectionID string `json:"connection_id"`
|
|
SourceType SourceType `json:"source_type"`
|
|
Name string `json:"name"`
|
|
RootNodeID string `json:"root_node_id"`
|
|
FolderCount int `json:"folder_count"`
|
|
FileCount int `json:"file_count"`
|
|
ObservedAt time.Time `json:"observed_at"`
|
|
SnapshotOnly bool `json:"snapshot_only"`
|
|
SnapshotStatus string `json:"snapshot_status"`
|
|
LastRefreshDurationMS int64 `json:"last_refresh_duration_ms"`
|
|
// ScanProgress / ScanMessage 只在 SnapshotStatus == "scanning" 时有值:新来源在首次扫描
|
|
// 完成前也出现在「来源与目录」里,带着百分比与进度文案,不必等到快照落地才看得见。
|
|
ScanProgress int `json:"scan_progress,omitempty"`
|
|
ScanMessage string `json:"scan_message,omitempty"`
|
|
}
|
|
|
|
// CatalogScanProgress 是「已登记、但还没有快照」的来源的首次扫描进度(来自 worker 写在
|
|
// 任务载荷里的进度,非另起一套计数)。
|
|
type CatalogScanProgress struct {
|
|
ConnectionID string
|
|
SourceType SourceType
|
|
Name string
|
|
Progress int
|
|
Message string
|
|
ScannedDirectories int
|
|
DiscoveredDirectories int
|
|
ScannedFiles int
|
|
StartedAt time.Time
|
|
}
|
|
|
|
type CatalogBreadcrumb struct {
|
|
NodeID string `json:"node_id"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
type CatalogNode struct {
|
|
NodeID string `json:"node_id"`
|
|
ParentNodeID string `json:"parent_node_id,omitempty"`
|
|
NodeType string `json:"node_type"`
|
|
Name string `json:"name"`
|
|
DirectChildCount int `json:"direct_child_count"`
|
|
SubtreeFileCount int `json:"subtree_file_count"`
|
|
SubtreeBytes int64 `json:"subtree_bytes"`
|
|
SizeBytes *int64 `json:"size_bytes,omitempty"`
|
|
ModifiedAt *time.Time `json:"modified_at,omitempty"`
|
|
ContentSHA256 *string `json:"content_sha256,omitempty"`
|
|
Visibility string `json:"visibility"`
|
|
ImportedCount int `json:"imported_count"`
|
|
ParsedCount int `json:"parsed_count"`
|
|
ActiveCount int `json:"active_count"`
|
|
FailedCount int `json:"failed_count"`
|
|
RoutableCount int `json:"routable_count"`
|
|
}
|
|
|
|
type CatalogNodeFilter struct {
|
|
ConnectionID string
|
|
ParentNodeID string
|
|
Limit int
|
|
Offset int
|
|
}
|
|
|
|
type CatalogNodePage struct {
|
|
Current CatalogNode `json:"current"`
|
|
Breadcrumbs []CatalogBreadcrumb `json:"breadcrumbs"`
|
|
Items []CatalogNode `json:"items"`
|
|
Total int `json:"total"`
|
|
Limit int `json:"limit"`
|
|
Offset int `json:"offset"`
|
|
}
|
|
|
|
type CatalogSnapshot struct {
|
|
SnapshotID string `json:"snapshot_id"`
|
|
ConnectionID string `json:"connection_id"`
|
|
RootNodeID string `json:"root_node_id"`
|
|
SourceName string `json:"source_name"`
|
|
NodeCount int `json:"node_count"`
|
|
FolderCount int `json:"folder_count"`
|
|
FileCount int `json:"file_count"`
|
|
ObservedAt time.Time `json:"observed_at"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
IsHead bool `json:"is_head"`
|
|
}
|
|
|
|
type CatalogSnapshotPage struct {
|
|
Items []CatalogSnapshot `json:"items"`
|
|
Total int `json:"total"`
|
|
Limit int `json:"limit"`
|
|
Offset int `json:"offset"`
|
|
}
|
|
|
|
type CatalogSnapshotNodeFilter struct {
|
|
ConnectionID string
|
|
SnapshotID string
|
|
ParentNodeID string
|
|
Limit int
|
|
Offset int
|
|
}
|
|
|
|
type CatalogRouteRequest struct {
|
|
ConnectionID string
|
|
NodeIDs []string
|
|
Visibility Visibility
|
|
TargetKnowledgeBaseID string
|
|
TargetKnowledgeBaseIDs []string
|
|
OperatorRef string
|
|
Reason string
|
|
Now time.Time
|
|
}
|
|
|
|
// CatalogRouteFile is one selected file plus the metadata snapshot the policy
|
|
// fulfillment path needs to materialize and fetch it later.
|
|
type CatalogRouteFile struct {
|
|
NodeID string
|
|
Name string
|
|
RelativePath string
|
|
SizeBytes *int64
|
|
ModifiedAt *time.Time
|
|
ContentSHA256 *string
|
|
LocatorHash string
|
|
Direct bool
|
|
}
|
|
|
|
// CatalogRouteResult describes the desired-state write only. Policy fulfillment
|
|
// records intents, queues artifact fetches and plans publications; counts tell
|
|
// the operator what will show up in 解析监控.
|
|
type CatalogRouteResult struct {
|
|
SelectedFiles int `json:"selected_files"`
|
|
IntentsRecorded int `json:"intents_recorded"`
|
|
FetchQueued int `json:"fetch_queued"`
|
|
PlannedPublications int `json:"planned_publications"`
|
|
BlockedItems int `json:"blocked_items"`
|
|
UnboundFiles int `json:"unbound_files"`
|
|
}
|
|
|
|
type CatalogChangeSetFilter struct {
|
|
ConnectionID string
|
|
Action string
|
|
Limit int
|
|
Offset int
|
|
}
|
|
|
|
type CatalogChangeSet struct {
|
|
ID string `json:"id"`
|
|
ConnectionID string `json:"connection_id"`
|
|
SourceName string `json:"source_name"`
|
|
State string `json:"state"`
|
|
AddCount int `json:"add_count"`
|
|
UpdateCount int `json:"update_count"`
|
|
MoveCount int `json:"move_count"`
|
|
MoveScopeCount int `json:"move_scope_count"`
|
|
DeleteCount int `json:"delete_count"`
|
|
NoChangeCount int `json:"no_change_count"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
type CatalogChangeItem struct {
|
|
Action string `json:"action"`
|
|
Title string `json:"title"`
|
|
OldPath string `json:"old_path,omitempty"`
|
|
NewPath string `json:"new_path,omitempty"`
|
|
OldSizeBytes *int64 `json:"old_size_bytes,omitempty"`
|
|
NewSizeBytes *int64 `json:"new_size_bytes,omitempty"`
|
|
OldModified *time.Time `json:"old_modified_at,omitempty"`
|
|
NewModified *time.Time `json:"new_modified_at,omitempty"`
|
|
OldContentSHA256 string `json:"old_content_sha256,omitempty"`
|
|
NewContentSHA256 string `json:"new_content_sha256,omitempty"`
|
|
ReasonCode string `json:"reason_code"`
|
|
Seq int64 `json:"seq"`
|
|
OldScope string `json:"old_scope,omitempty"`
|
|
NewScope string `json:"new_scope,omitempty"`
|
|
OldVersionID string `json:"old_version_id,omitempty"`
|
|
NewVersionID string `json:"new_version_id,omitempty"`
|
|
}
|
|
|
|
type CatalogChangeSetDetail struct {
|
|
CatalogChangeSet
|
|
Items []CatalogChangeItem `json:"items"`
|
|
Total int `json:"total"`
|
|
Limit int `json:"limit"`
|
|
Offset int `json:"offset"`
|
|
}
|