/** * SchemaUtils - JSON Schema validation for SWML documents. * * Provides basic structural validation of rendered SWML and * schema-driven verb extraction/validation. * Set SWML_SKIP_SCHEMA_VALIDATION=true to disable. */ /** Result of validating a SWML document. */ export interface ValidationResult { /** Whether the document passed all validation checks. */ valid: boolean; /** List of human-readable error messages; empty when valid. */ errors: string[]; } /** A verb definition extracted from the schema. */ export interface VerbDefinition { /** The verb name as used in SWML (e.g. "answer", "hangup", "sip_refer"). */ name: string; /** The PascalCase schema definition name (e.g. "Answer", "Hangup", "SIPRefer"). */ schemaName: string; /** The raw JSON Schema definition object for this verb. */ definition: Record; } /** Validates SWML documents against structural rules with an LRU-style result cache. */ export declare class SchemaUtils { private skipValidation; private cache; private maxCacheSize; private schema; private verbs; /** Path to the schema file, or null to use the bundled schema. */ private schemaPath; /** * Create a SchemaUtils instance. * @param opts - Optional settings for skipping validation, limiting cache size, or overriding the schema file path. */ constructor(opts?: { skipValidation?: boolean; maxCacheSize?: number; schemaPath?: string; }); /** * Load the schema from the path specified in opts.schemaPath (if given) or fall back * to the bundled schema.json. Mirrors Python's SchemaUtils which accepts an explicit * schema_path and falls back to _get_default_schema_path() when None is supplied. */ private loadSchema; /** * Extract verb definitions from `$defs/SWMLMethod.anyOf` in the schema. * Mirrors Python SDK's `_extract_verb_definitions()`. */ private extractVerbDefinitions; /** * Get all verb names defined in the schema. * @returns Array of verb names (e.g. ["answer", "ai", "hangup", ...]). */ getVerbNames(): string[]; /** * Get the inner properties schema for a specific verb. * For example, for "hangup" this returns `{ type: "object", properties: { reason: ... }, ... }`. * @param verbName - The verb name (e.g. "answer", "tap"). * @returns The inner schema definition or an empty object if not found. */ getVerbProperties(verbName: string): Record; /** * Get the required properties for a verb's inner config. * @param verbName - The verb name. * @returns Array of required property names. */ getVerbRequiredProperties(verbName: string): string[]; /** * Get the description text for a verb. * @param verbName - The verb name. * @returns The description string or empty string. */ getVerbDescription(verbName: string): string; /** * Check if a verb name is defined in the schema. * @param verbName - The verb name. * @returns True if the verb exists. */ hasVerb(verbName: string): boolean; /** * Lightweight validation of a verb config against the schema. * Checks that the verb exists and required properties are present. * Mirrors Python SDK's `_validate_verb_lightweight()`. * * @param verbName - The verb name. * @param config - The verb configuration to validate. * @returns Validation result. */ validateVerb(verbName: string, config: unknown): ValidationResult; /** * Validate a SWML document against structural rules. * @param swml - The SWML document as a JSON string or parsed object. * @returns The validation result indicating success or a list of errors. */ validate(swml: string | Record): ValidationResult; private validateAiVerb; /** Clear the validation cache */ clearCache(): void; /** * Get the number of cached validation results. * @returns The current cache entry count. */ getCacheSize(): number; private cacheResult; }