/** * XML parsing utilities for Yahoo Fantasy Sports API * * Yahoo's XML API returns cleaner, more consistent data than JSON: * - No numeric string keys ("0", "1", "2") * - No redundant wrapper objects * - Direct hierarchical structure * - 3.7x smaller response size * * ## Usage * * The main export is `parseYahooXML()`, which handles all Yahoo Fantasy Sports API * XML responses. It automatically: * - Parses the XML structure * - Unwraps the fantasy_content wrapper * - Detects and normalizes arrays (e.g., `teams.team` → `teams` as array) * - Handles error responses * * ```typescript * import { parseYahooXML } from './utils/xmlParser.js'; * * const xmlString = await response.text(); * const data = parseYahooXML(xmlString); * * // Arrays are automatically normalized - no need for ensureArray() * const teams = data.league.teams; // Always an array * const players = data.team.roster.players; // Always an array * ``` * * @module */ /** * Parses Yahoo Fantasy Sports API XML response with automatic array normalization * * This is the main parsing function that handles all Yahoo Fantasy Sports API XML responses. * It automatically: * - Parses the XML structure * - Unwraps the fantasy_content wrapper * - Detects and normalizes arrays (e.g., teams.team -> teams as array) * - Handles error responses * * @param xml - Raw XML string from API * @returns Parsed and normalized data object * @throws {Error} If XML is invalid or API returns an error * * @example * ```typescript * const xmlString = await response.text(); * const data = parseYahooXML(xmlString); * * // Arrays are automatically normalized * const teams = data.league.teams; // Always an array, even with 1 team * const players = data.team.roster.players; // Always an array * ``` */ export declare function parseYahooXML(xml: string): T; /** * Ensures a value is an array * * XML parsers return arrays for multiple elements but single objects for one element. * This helper normalizes both cases to always return an array. * * @deprecated Arrays are now automatically normalized by parseYahooXML. Use direct property access instead. */ export declare function ensureArray(value: T | T[] | undefined | null | ''): T[]; /** * Identifies array patterns in raw XML by finding plural tags containing singular child elements * * Analyzes XML structure to detect patterns like: * - `` containing `` elements * - `` containing `` elements * - `` containing `` elements * * This is more reliable than just checking for plural tag names, as it validates * the actual parent-child relationship in the XML structure. */ export declare function detectArrayPatterns(xml: string): Map; export declare function normalizeArrays(data: Record): Record; //# sourceMappingURL=xmlParser.d.ts.map