@sofianedjerbi/knowledge-tree-mcp
Version:
MCP server for hierarchical project knowledge management
71 lines • 2.88 kB
TypeScript
/**
* Validation utilities for Knowledge Tree MCP
* Handles all validation logic for knowledge entries, paths, and relationships
*/
import type { KnowledgeEntry, Priority } from '../types/index.js';
import { BIDIRECTIONAL_RELATIONSHIPS, isValidPriority as isValidPriorityConst, isValidRelationshipType, isBidirectionalRelationship as isBidirectionalRelationshipConst } from '../constants/index.js';
export declare const isValidPriority: typeof isValidPriorityConst;
export declare const isValidRelationship: typeof isValidRelationshipType;
export declare const isBidirectionalRelationship: typeof isBidirectionalRelationshipConst;
export declare const VALID_PRIORITIES: readonly ["CRITICAL", "REQUIRED", "COMMON", "EDGE-CASE"];
export declare const VALID_RELATIONSHIPS: readonly ["related", "supersedes", "superseded_by", "conflicts_with", "implements", "implemented_by"];
export { BIDIRECTIONAL_RELATIONSHIPS };
/**
* Validates a path format
* @param path - Path to validate
* @returns Validation result with error message if invalid
*/
export declare function validatePath(path: string): {
valid: boolean;
error?: string;
};
/**
* Validates that a filename matches the priority prefix
* @param filename - Filename to check
* @param priority - Expected priority
* @returns Validation result with error message if invalid
* @deprecated Priority is no longer part of the filename, only a JSON attribute
*/
export declare function validateFilenameMatchesPriority(filename: string, priority: Priority): {
valid: boolean;
error?: string;
};
/**
* Validates required fields for a knowledge entry
* @param entry - Partial knowledge entry to validate
* @returns Array of validation errors
*/
export declare function validateRequiredFields(entry: Partial<KnowledgeEntry>): string[];
/**
* Validates relationships in a knowledge entry
* @param relationships - Array of relationships to validate
* @returns Array of validation errors
*/
export declare function validateRelationships(relationships?: KnowledgeEntry['related_to']): string[];
/**
* Validates a complete knowledge entry
* @param entry - Knowledge entry to validate
* @param path - Path where the entry will be stored
* @returns Object with validation result and errors
*/
export declare function validateKnowledgeEntry(entry: Partial<KnowledgeEntry>, path: string): {
valid: boolean;
errors: string[];
};
/**
* Validates JSON format
* @param content - String content to validate as JSON
* @returns Validation result with parsed data or error
*/
export declare function validateJSON<T = any>(content: string): {
valid: boolean;
data?: T;
error?: string;
};
/**
* Escapes HTML special characters
* @param text - Text to escape
* @returns Escaped HTML string
*/
export declare function escapeHtml(text: string): string;
//# sourceMappingURL=validation.d.ts.map