diff --git a/packages/core/lib/spec-parser.ts b/packages/core/lib/spec-parser.ts index 8ffb862..1a38ec7 100644 --- a/packages/core/lib/spec-parser.ts +++ b/packages/core/lib/spec-parser.ts @@ -1,37 +1,18 @@ -/** - * Parses hardware specs out of a Paymenter product description (HTML). - * - * Descriptions follow consistent bullet-point patterns, e.g.: - * "2 Cores of Ryzen 7 Power: ..." - * "4 GB DDR4 RAM: ..." - * "100 GB SSD Storage: ..." - * "1 Gbps Network Port: ... 1 TB included outbound ..." - * - * Everything extractable comes from here; the only things left in config - * are `popular` flags and the series→location map. - */ export interface ParsedSpecs { cpu?: number ramGB?: number - /** RAM generation if the description names one, e.g. "DDR3"/"DDR4"/"DDR5" — omitted when unspecified. */ ramType?: string storageGB?: number - /** Raw storage label extracted from the description, e.g. "2 × 1 TB NVMe SSD (RAID 1)" */ storageDescription?: string - /** Which storage keyword the description actually used — "generic" when it only said e.g. "40 GB Storage Array" with no drive type. */ storageType?: "nvme" | "ssd" | "hdd" | "generic" bandwidth?: { amount: number; unit: "MB" | "GB" | "TB" } | null uplink?: { amount: number; unit: "Mbps" | "Gbps" } cpuModel?: string hardware?: "amd" | "intel" | "arm" - /** Short description extracted from the first bullet's subtitle. */ description?: string - /** Location(s) named in a "location"/"region" bullet, e.g. "Newcastle, UK / New York, US" — omitted if none named. */ location?: string - /** Number of databases included, e.g. "3x MySQL Databases" → 3. */ databases?: number - /** Whether the description mentions automatic/included backups. */ backups?: boolean } @@ -39,21 +20,10 @@ function stripHtml(html: string): string { return html.replace(/<[^>]*>/g, " ").replace(/&/g, "&").replace(/\s+/g, " ").trim() } -/** - * Split into individual bullet lines. Paymenter descriptions are usually a - * `