- Add #domain, #protocol, #utils aliases to package.json imports map - Replace all relative imports (./, ../, ../..) in app/ and database/mongo_migrations/ with the corresponding #alias imports, eliminating relative path traversal across the codebase - Remove dead code: ConfigurationVersionModel.findByConfigurationIdentifier (unused, superseded by paginateVersions) and unused exception classes (NotFoundException, UnprocessableEntityException, DatabaseException) from app/exceptions/index.ts, keeping only BadRequestException - Fix pre-existing syntax error in configuration_version.ts (mismatched parenthesis) that broke tsc - Fix eqeqeq violation in configuration_service.ts and isNaN -> Number.isNaN in configuration_engine.ts / cwmp-1-0.ts / exchange_controller.ts - Fix no-shadow violation in cwmp-1-0.ts EventStruct constructor - Prettier formatting pass on touched files Validated: tsc --noEmit clean, eslint app/ clean, full test suite green.
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import type { InventoryPath } from '#domain/configuration/configuration'
|
|
|
|
/**
|
|
* 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('.') + '.'
|
|
}
|