A social knowledge tool for researchers built on ATProto
1import { ValueObject } from 'src/shared/domain/ValueObject';
2
3export interface PublishedRecordIdProps {
4 uri: string;
5 cid: string;
6}
7export class PublishedRecordId extends ValueObject<PublishedRecordIdProps> {
8 get uri(): string {
9 return this.props.uri;
10 }
11 get cid(): string {
12 return this.props.cid;
13 }
14 getValue(): PublishedRecordIdProps {
15 return this.props;
16 }
17
18 private constructor(value: PublishedRecordIdProps) {
19 super(value);
20 }
21
22 public static create(value: PublishedRecordIdProps): PublishedRecordId {
23 if (!value.uri.startsWith('at://')) {
24 throw new Error(`Invalid AT URI format: ${value}`);
25 }
26 return new PublishedRecordId(value);
27 }
28 public equals(vo?: ValueObject<PublishedRecordIdProps> | undefined): boolean {
29 if (vo === null || vo === undefined) {
30 return false;
31 }
32 if (vo.props === undefined) {
33 return false;
34 }
35 return this.props.uri === vo.props.uri && this.props.cid === vo.props.cid;
36 }
37}