- Docker infrastructure (Dockerfile, docker-compose.yml, genieacs-sim) - AdonisJS v7 app with Inertia.js + Vue 3 - MongoDB integration - CWMP/TR-069 state machine engine - Configuration engine with compliance tracking - Branding: ADAM ACS (favicon, navbar, locales) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
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('.') + '.'
|
|
}
|