import type { InventoryPath } from '../domain/configuration/configuration.js' /** * Checks whether a desired parameter is covered by at least one inventory path. * An inventory path ending with "." covers all parameters starting with that prefix (subtree match). * An inventory path without trailing "." requires an exact match. */ export function isParameterCoveredByInventory( paramName: string, inventoryPaths: InventoryPath[] ): boolean { return inventoryPaths.some((inv) => { const path = inv.path if (!path.endsWith('.')) { return paramName === path } // Subtree match: param starts with the inventory path return paramName.startsWith(path) }) } /** * Suggests the inventory path to add to cover a given parameter. * Removes the leaf name and adds a trailing dot. * Example: "InternetGatewayDevice.ManagementServer.PeriodicInformInterval" * → "InternetGatewayDevice.ManagementServer." */ export function suggestInventoryPath(paramName: string): string { const parts = paramName.split('.') parts.pop() // Remove leaf name return parts.join('.') + '.' }