import { v4 as uuidv4, validate as uuidValidate } from 'uuid'; import { DomainException } from '../../shared/exceptions/domain.exception'; export class InstallId { private readonly _value: string; private constructor(value: string) { this._value = value; } get value(): string { return this._value; } static generate(): InstallId { return new InstallId(uuidv4()); } static fromString(value: string): InstallId { if (!value || value.trim() === '') { throw new DomainException('InstallId cannot be empty'); } // 允许非UUID格式,但需要有基本长度 if (value.length < 8 || value.length > 128) { throw new DomainException('InstallId length must be between 8 and 128 characters'); } return new InstallId(value.trim()); } equals(other: InstallId): boolean { return this._value === other._value; } toString(): string { return this._value; } }