Files
gridpilot.gg/core/analytics/domain/value-objects/AnalyticsSessionId.ts
2026-01-16 16:46:57 +01:00

36 lines
873 B
TypeScript

import type { ValueObject } from '@core/shared/domain/ValueObject';
export interface AnalyticsSessionIdProps {
value: string;
}
/**
* Value Object: AnalyticsSessionId
*
* Represents an analytics session identifier within the analytics bounded context.
*/
export class AnalyticsSessionId implements ValueObject<AnalyticsSessionIdProps> {
public readonly props: AnalyticsSessionIdProps;
private constructor(value: string) {
this.props = { value };
}
static create(raw: string): AnalyticsSessionId {
const value = raw.trim();
if (!value) {
throw new Error('AnalyticsSessionId must be a non-empty string');
}
return new AnalyticsSessionId(value);
}
get value(): string {
return this.props.value;
}
equals(other: ValueObject<AnalyticsSessionIdProps>): boolean {
return this.props.value === other.props.value;
}
}