···11+import e from "express";
12import { ValueObject } from "../../../../shared/domain/ValueObject";
33+import { Annotation } from "../aggregates";
24import { AnnotationType } from "./AnnotationType";
3546// Define interfaces for the props of each value object type
···22242325// Abstract base class for all annotation values, extending the shared ValueObject
2426export abstract class AnnotationValueBase<
2525- T extends object
2727+ T extends object,
2628> extends ValueObject<T> {
2729 abstract readonly type: AnnotationType;
2830···3335 * @returns True if the types match, false otherwise.
3436 */
3537 public isSameType(other?: AnnotationValueBase<any>): boolean {
3636- // Use the equals method of the AnnotationType value object
3738 return !!other && this.type.equals(other.type);
3839 }
3940}
···5758 }
5859 return new DyadValue({ value });
5960 }
6060-6161- // Base ValueObject.equals should suffice as it compares props
6261}
63626463export class TriadValue extends AnnotationValueBase<ITriadValueProps> {
···7372 get vertexC(): number {
7473 return this.props.vertexC;
7574 }
7676- // sum is an invariant checked at creation, not stored state
77757876 private constructor(props: ITriadValueProps) {
7977 super(props);
···9290 }
9391 return new TriadValue({ vertexA, vertexB, vertexC });
9492 }
9595-9696- // Base ValueObject.equals should suffice
9793}
98949995export class RatingValue extends AnnotationValueBase<IRatingValueProps> {
···115111 }
116112 return new RatingValue({ rating });
117113 }
118118-119119- // Base ValueObject.equals should suffice
120114}
121115122116export class SingleSelectValue extends AnnotationValueBase<ISingleSelectValueProps> {
···138132 }
139133 return new SingleSelectValue({ option });
140134 }
141141-142142- // Base ValueObject.equals should suffice
143135}
144136145137export class MultiSelectValue extends AnnotationValueBase<IMultiSelectValueProps> {
···167159 const uniqueSortedOptions = [...new Set(options)].sort();
168160 return new MultiSelectValue({ options: uniqueSortedOptions });
169161 }
170170-171171- // Base ValueObject.equals should suffice because options in props are sorted
172162}
173163174174-// Union type of all concrete AnnotationValue implementations
175175-export type AnnotationValue =
176176- | DyadValue
177177- | TriadValue
178178- | RatingValue
179179- | SingleSelectValue
180180- | MultiSelectValue;
164164+export type AnnotationValue = AnnotationValueBase<object>;
···11export * from "./AnnotationValue";
22-export * from "./FieldDefinition";
22+export * from "./AnnotationFieldDefinition";
33export * from "./Identifier";
44export * from "./URI";
55export * from "./AnnotationFieldId";
···77export * from "./AnnotationNote";
88export * from "./AnnotationId";
99export * from "./PublishedRecordId";
1010+export * from "./CuratorId";