This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

semble / src / modules / atproto / domain / TID.ts
785 B 31 lines
1import { TID as LexTID } from '@atproto/common'; // Using the official library for generation/validation 2 3// Placeholder for TID Value Object 4// Wraps the @atproto/common TID class for domain modeling purposes 5export class TID { 6 private readonly tid: LexTID; 7 8 private constructor(tid: LexTID) { 9 this.tid = tid; 10 } 11 12 public static fromString(str: string): TID { 13 try { 14 return new TID(LexTID.fromStr(str)); 15 } catch (e) { 16 throw new Error(`Invalid TID format: ${str}`, { cause: e }); 17 } 18 } 19 20 public toString(): string { 21 return this.tid.toString(); 22 } 23 24 public equals(other: TID): boolean { 25 return this.tid.toString() === other.tid.toString(); 26 } 27 28 public static create(): TID { 29 return new TID(LexTID.fromStr(Date.now().toString())); 30 } 31}