/** * Template Validation with Fuzzy Matching * * Provides fail-fast validation for unknown template references * with helpful suggestions for similar template names. */ import type { TemplateRegistry } from "../templates/index.js"; /** * Error thrown when a referenced template does not exist. */ export declare class UnknownTemplateError extends Error { templateId: string; suggestions: string[]; constructor(templateId: string, suggestions: string[]); private static formatMessage; } /** * Compute the Levenshtein distance between two strings. * * @returns The integer edit distance between `a` and `b` (0 when the strings are identical). */ export declare function levenshteinDistance(a: string, b: string): number; /** * Compute a normalized similarity score between two strings (1.0 = identical, 0.0 = completely different). * * Comparison is case-insensitive. * * @param a - The first string to compare * @param b - The second string to compare * @returns A number between 0 and 1 representing similarity; `1` if the strings are identical. Returns `1` when both inputs are empty. */ export declare function similarityScore(a: string, b: string): number; /** * Suggests template IDs from the registry that are most similar to the provided template ID. * * @param templateId - The template identifier to match against the registry * @param templates - The template registry to search * @param maxSuggestions - Maximum number of suggestions to return (default: 5) * @returns An array of template IDs ordered from most to least similar (up to `maxSuggestions`) */ export declare function findSimilarTemplates(templateId: string, templates: TemplateRegistry, maxSuggestions?: number): string[]; /** * Ensures a template with the given ID exists in the provided registry. * * @throws UnknownTemplateError - if the template is not found; the error includes fuzzy-match suggestions for possible template IDs. */ export declare function validateTemplateExists(templateId: string, templates: TemplateRegistry): void; /** * Enhanced version of validateWorkoutRefs that returns detailed error objects. */ export interface PlanTemplateValidationError { templateId: string; week: number; day: string; ref: string; suggestions: string[]; } /** * Collects unknown template references from a compact plan and returns detailed validation errors. * * Iterates the plan's weeks and workouts, identifies template references that are not present in the provided * TemplateRegistry, and returns an array of PlanTemplateValidationError objects containing the week, day, original * reference, the extracted template ID, and suggested similar template IDs. * * @param compactPlan - Plan object with a `weeks` array; each week contains a `week` number and `workouts` mapping days to a template ref or array of refs. * @param templates - TemplateRegistry used to check whether a referenced template ID exists and to derive suggestions for unknown IDs. * @returns An array of PlanTemplateValidationError objects describing each unknown template reference found in the plan. */ export declare function validatePlanTemplates(compactPlan: { weeks: Array<{ week: number; workouts: Record; }>; }, templates: TemplateRegistry): PlanTemplateValidationError[]; /** * Render a list of template validation errors into a concise, human-readable report. * * The returned string lists each unknown reference with its week, day, and original ref, * and includes suggested template IDs when available. If `errors` is empty, returns an empty string. * * @param errors - Array of template validation errors to format * @returns A multi-line message describing each unknown reference and any suggestions, or an empty string if there are no errors */ export declare function formatValidationErrors(errors: PlanTemplateValidationError[]): string;