taskflow-ai
Version:
TaskFlow AI - 智能PRD文档解析与任务管理助手,支持多模型AI协同、MCP编辑器集成,专为开发团队设计的CLI工具
111 lines (110 loc) • 2.44 kB
TypeScript
/**
* 配置验证器
* 提供配置文件的结构化验证和错误报告
*/
import { JSONValue, JSONObject } from '../../types/strict-types';
import { ValidationError } from '../error-handling/typed-errors';
/**
* 配置验证规则接口
*/
export interface ConfigValidationRule {
required?: boolean;
type: 'string' | 'number' | 'boolean' | 'object' | 'array';
min?: number;
max?: number;
pattern?: RegExp;
enum?: JSONValue[];
default?: JSONValue;
description: string;
example?: JSONValue;
deprecated?: boolean;
deprecationMessage?: string;
}
/**
* 配置模式接口
*/
export interface ConfigSchema {
[key: string]: ConfigValidationRule | ConfigSchema;
}
/**
* 验证结果接口
*/
export interface ConfigValidationResult {
isValid: boolean;
errors: ConfigValidationError[];
warnings: ConfigValidationWarning[];
normalizedConfig?: JSONObject;
}
/**
* 配置验证错误接口
*/
export interface ConfigValidationError {
path: string;
message: string;
value?: JSONValue;
rule?: ConfigValidationRule;
}
/**
* 配置验证警告接口
*/
export interface ConfigValidationWarning {
path: string;
message: string;
value?: JSONValue;
suggestion?: string;
}
/**
* 配置验证器类
*/
export declare class ConfigValidator {
private schema;
constructor(schema: ConfigSchema);
/**
* 验证配置对象
*/
validate(config: JSONObject): ConfigValidationResult;
/**
* 验证对象
*/
private validateObject;
/**
* 验证单个字段
*/
private validateField;
/**
* 验证类型
*/
private validateType;
/**
* 验证范围
*/
private validateRange;
/**
* 检查是否为验证规则
*/
private isValidationRule;
/**
* 检查是否有必需字段
*/
private hasRequiredFields;
/**
* 生成配置文档
*/
generateDocumentation(): string;
/**
* 生成模式文档
*/
private generateSchemaDoc;
}
/**
* TaskFlow AI 配置模式
*/
export declare const TaskFlowConfigSchema: ConfigSchema;
/**
* 验证TaskFlow配置
*/
export declare function validateTaskFlowConfig(config: JSONObject): ConfigValidationResult;
/**
* 创建配置验证错误
*/
export declare function createConfigValidationError(message: string, path: string, value?: JSONValue): ValidationError;