- 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>
46 lines
1.1 KiB
TypeScript
46 lines
1.1 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: any): DeviceId {
|
|
return new DeviceId(
|
|
String(informData?.Manufacturer ?? ''),
|
|
String(informData?.OUI ?? ''),
|
|
String(informData?.ProductClass ?? ''),
|
|
String(informData?.SerialNumber ?? '')
|
|
)
|
|
}
|
|
|
|
public toString(): string {
|
|
return this.toIdentifier()
|
|
}
|
|
}
|