Files
adam-acs/app/domain/device/device_id.ts
T
Kevin L'Hereec f9e56c78b1 refactor: migrate all internal imports to package.json subpath aliases
- 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.
2026-07-22 11:45:14 +02:00

51 lines
1.2 KiB
TypeScript

export class DeviceId {
constructor(
public readonly manufacturer: string,
public readonly oui: string,
public readonly productClass: string,
public readonly serialNumber: string
) {
this.validate()
}
private validate(): void {
if (!this.manufacturer?.trim()) {
throw new Error('Manufacturer is required')
}
if (!this.serialNumber?.trim()) {
throw new Error('Serial number is required')
}
}
public toIdentifier(): string {
return `${this.manufacturer}-${this.oui}-${this.productClass}-${this.serialNumber}`
}
public equals(other: DeviceId): boolean {
return (
this.manufacturer === other.manufacturer &&
this.oui === other.oui &&
this.productClass === other.productClass &&
this.serialNumber === other.serialNumber
)
}
public static fromInform(informData: {
Manufacturer?: string
OUI?: string
ProductClass?: string
SerialNumber?: string
}): DeviceId {
return new DeviceId(
String(informData?.Manufacturer ?? ''),
String(informData?.OUI ?? ''),
String(informData?.ProductClass ?? ''),
String(informData?.SerialNumber ?? '')
)
}
public toString(): string {
return this.toIdentifier()
}
}