优化: 代码质量收尾(搜索索引补全+编译警告清理+i18n核验+String替newtype)
This commit is contained in:
@@ -1,5 +1,20 @@
|
||||
//! TypeScript 类型定义 — 与 Rust Record 结构体严格对齐
|
||||
|
||||
// ============================================================
|
||||
// 域 ID newtype(纯类型级标记,零运行时开销)
|
||||
// ============================================================
|
||||
|
||||
/** 项目 ID — branded newtype,替代 string */
|
||||
export type ProjectId = string & { readonly __brand: 'ProjectId' }
|
||||
/** 任务 ID — branded newtype,替代 string */
|
||||
export type TaskId = string & { readonly __brand: 'TaskId' }
|
||||
/** 对话 ID — branded newtype,替代 string */
|
||||
export type ConvId = string & { readonly __brand: 'ConvId' }
|
||||
/** 工程/模块 ID — branded newtype,替代 string */
|
||||
export type ModuleId = string & { readonly __brand: 'ModuleId' }
|
||||
/** 消息 ID — branded newtype,替代 string */
|
||||
export type MessageId = string & { readonly __brand: 'MessageId' }
|
||||
|
||||
// ============================================================
|
||||
// 灵感
|
||||
// ============================================================
|
||||
@@ -78,7 +93,7 @@ export type ProjectStatus =
|
||||
| 'planning' | 'in_progress' | 'testing' | 'releasing' | 'completed' | 'paused' | 'cancelled'
|
||||
|
||||
export interface ProjectRecord {
|
||||
id: string
|
||||
id: ProjectId
|
||||
name: string
|
||||
description: string
|
||||
status: ProjectStatus
|
||||
@@ -116,7 +131,7 @@ export interface AiScanResult {
|
||||
/** 灵感晋升结果(后端 promote_idea 返回) */
|
||||
export interface PromotionResult {
|
||||
idea_id: string
|
||||
project_id: string
|
||||
project_id: ProjectId
|
||||
promoted: boolean
|
||||
reason: string
|
||||
}
|
||||
@@ -133,8 +148,8 @@ export type TaskStatus =
|
||||
| 'todo' | 'in_progress' | 'in_review' | 'testing' | 'done' | 'blocked' | 'cancelled'
|
||||
|
||||
export interface TaskRecord {
|
||||
id: string
|
||||
project_id: string
|
||||
id: TaskId
|
||||
project_id: ProjectId
|
||||
title: string
|
||||
description: string
|
||||
status: TaskStatus
|
||||
@@ -159,7 +174,7 @@ export interface TaskRecord {
|
||||
}
|
||||
|
||||
export interface CreateTaskInput {
|
||||
project_id: string
|
||||
project_id: ProjectId
|
||||
title: string
|
||||
description?: string
|
||||
priority?: number
|
||||
@@ -423,7 +438,7 @@ export type AiChatEvent = ({
|
||||
// 上下文已清空:前端刷新消息列表 + toast 提示
|
||||
type: 'AiContextCleared'
|
||||
}) & {
|
||||
conversation_id?: string
|
||||
conversation_id?: ConvId
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -447,7 +462,7 @@ export type ContentPart =
|
||||
|
||||
/** AI 消息(前端渲染用,isError 标记错误消息用于差异化样式) */
|
||||
export interface AiMessage {
|
||||
id: string
|
||||
id: MessageId
|
||||
role: 'user' | 'assistant' | 'tool' | 'system'
|
||||
content: string
|
||||
isError?: boolean
|
||||
@@ -581,7 +596,7 @@ export interface AiToolCallInfo {
|
||||
|
||||
/** 对话列表摘要 */
|
||||
export interface AiConversationSummary {
|
||||
id: string
|
||||
id: ConvId
|
||||
title: string | null
|
||||
provider_id: string | null
|
||||
model: string | null
|
||||
@@ -620,7 +635,7 @@ export interface HumanApprovalResponse {
|
||||
|
||||
/** 切换对话返回(含 messages JSON) */
|
||||
export interface AiConversationDetail {
|
||||
id: string
|
||||
id: ConvId
|
||||
title: string | null
|
||||
messages: string // JSON string of ChatMessage[]
|
||||
/** 生成中返回 true(后端 ai_conversation_switch 在 generating 时置),前端据此禁编辑(FR-C5) */
|
||||
|
||||
Reference in New Issue
Block a user