📄 types.ts  •  2102 bytes
/**
 * 验证系统 - 类型定义
 * Phase 3: 代码验证
 */

/** 验证类型 */
export type VerificationType = 
  | 'syntax'    // 语法检查
  | 'types'      // 类型检查
  | 'tests'      // 测试验证
  | 'security'   // 安全扫描
  | 'consistency' // 一致性检查

/** 验证状态 */
export type VerificationStatus = 'pending' | 'running' | 'passed' | 'failed' | 'skipped'

/** 验证问题 */
export interface VerificationIssue {
  type: 'error' | 'warning' | 'info'
  code?: string
  message: string
  location?: {
    file: string
    line?: number
    column?: number
  }
  suggestion?: string
}

/** 单项验证结果 */
export interface VerificationResult {
  type: VerificationType
  status: VerificationStatus
  passed: boolean
  issues: VerificationIssue[]
  duration: number  // 耗时(ms)
  output?: string   // 原始输出
}

/** 完整验证报告 */
export interface VerificationReport {
  id: string
  file: string
  timestamp: string
  results: VerificationResult[]
  overallPassed: boolean
  summary: {
    total: number
    passed: number
    failed: number
    warnings: number
  }
}

/** 验证选项 */
export interface VerificationOptions {
  enableSyntax: boolean
  enableTypes: boolean
  enableTests: boolean
  enableSecurity: boolean
  enableConsistency: boolean
  failOnWarning: boolean
  failOnInfo: boolean
}

/** 默认验证选项 */
export const DEFAULT_VERIFICATION_OPTIONS: VerificationOptions = {
  enableSyntax: true,
  enableTypes: true,
  enableTests: true,
  enableSecurity: false,
  enableConsistency: true,
  failOnWarning: false,
  failOnInfo: false,
}

/** 验证状态标签 */
export const STATUS_LABELS: Record<VerificationStatus, string> = {
  pending: '⏳ 待验证',
  running: '🔄 验证中',
  passed: '✅ 通过',
  failed: '❌ 失败',
  skipped: '⏭️ 跳过',
}

/** 验证类型标签 */
export const TYPE_LABELS: Record<VerificationType, string> = {
  syntax: '🔤 语法检查',
  types: '📝 类型检查',
  tests: '🧪 测试验证',
  security: '🔒 安全扫描',
  consistency: '🔗 一致性检查',
}