A social knowledge tool for researchers built on ATProto
at main 32 lines 908 B view raw
1import { ValueObject } from '../../../../shared/domain/ValueObject'; 2import { UniqueEntityID } from '../../../../shared/domain/UniqueEntityID'; 3import { Result, ok, err } from '../../../../shared/core/Result'; 4 5interface ActivityIdProps { 6 value: UniqueEntityID; 7} 8 9export class ActivityId extends ValueObject<ActivityIdProps> { 10 getStringValue(): string { 11 return this.props.value.toString(); 12 } 13 14 getValue(): UniqueEntityID { 15 return this.props.value; 16 } 17 18 private constructor(value: UniqueEntityID) { 19 super({ value }); 20 } 21 22 public static create(id?: UniqueEntityID): Result<ActivityId> { 23 return ok(new ActivityId(id || new UniqueEntityID())); 24 } 25 26 public static createFromString(id: string): Result<ActivityId> { 27 if (!id || id.trim().length === 0) { 28 return err(new Error('Activity ID cannot be empty')); 29 } 30 return ok(new ActivityId(new UniqueEntityID(id))); 31 } 32}