UNPKG

matterbridge-roborock-vacuum-plugin

Version:
37 lines 959 B
/** * Value object representing a device identifier (DUID). * Ensures device IDs are valid and immutable. */ export class DeviceId { value; constructor(value) { this.value = value; } /** * Create a DeviceId from a string. * @throws Error if the device ID is invalid */ static create(duid) { if (!duid || typeof duid !== 'string') { throw new Error('Device ID is required and must be a string'); } const trimmed = duid.trim(); if (trimmed.length < 5) { throw new Error('Device ID must be at least 5 characters long'); } return new DeviceId(trimmed); } /** * Get the string representation of this device ID. */ toString() { return this.value; } /** * Check if two DeviceIds are equal. */ equals(other) { return this.value === other.value; } } //# sourceMappingURL=DeviceId.js.map