harden media

This commit is contained in:
2025-12-31 15:39:28 +01:00
parent 92226800df
commit 8260bf7baf
413 changed files with 8361 additions and 1544 deletions

View File

@@ -17,6 +17,7 @@ import { ParticipantCount } from '../value-objects/ParticipantCount';
import { MaxParticipants } from '../value-objects/MaxParticipants';
import { SessionDuration } from '../value-objects/SessionDuration';
import { RacingDomainValidationError, RacingDomainInvariantError } from '../errors/RacingDomainError';
import { MediaReference } from '@core/domain/media/MediaReference';
/**
* Stewarding decision mode for protests
@@ -99,6 +100,7 @@ export class League implements IEntity<LeagueId> {
readonly category?: string | undefined;
readonly createdAt: LeagueCreatedAt;
readonly socialLinks: LeagueSocialLinks | undefined;
readonly logoRef: MediaReference;
// Domain state for business rule enforcement
private readonly _participantCount: ParticipantCount;
@@ -115,6 +117,7 @@ export class League implements IEntity<LeagueId> {
socialLinks?: LeagueSocialLinks;
participantCount: ParticipantCount;
visibility: LeagueVisibility;
logoRef: MediaReference;
}) {
this.id = props.id;
this.name = props.name;
@@ -126,6 +129,7 @@ export class League implements IEntity<LeagueId> {
this.socialLinks = props.socialLinks;
this._participantCount = props.participantCount;
this._visibility = props.visibility;
this.logoRef = props.logoRef;
}
/**
@@ -146,6 +150,7 @@ export class League implements IEntity<LeagueId> {
websiteUrl?: string;
};
participantCount?: number;
logoRef?: MediaReference;
}): League {
// Validate required fields
if (!props.id || props.id.trim().length === 0) {
@@ -254,6 +259,7 @@ export class League implements IEntity<LeagueId> {
...(socialLinks !== undefined ? { socialLinks } : {}),
participantCount,
visibility,
logoRef: props.logoRef ?? MediaReference.createSystemDefault('logo'),
});
}
@@ -271,6 +277,7 @@ export class League implements IEntity<LeagueId> {
youtubeUrl?: string;
websiteUrl?: string;
};
logoRef?: MediaReference;
}): League {
const id = LeagueId.create(props.id);
const name = LeagueName.create(props.name);
@@ -297,6 +304,7 @@ export class League implements IEntity<LeagueId> {
...(socialLinks !== undefined ? { socialLinks } : {}),
participantCount,
visibility,
logoRef: props.logoRef ?? MediaReference.createSystemDefault('logo'),
});
}
@@ -356,11 +364,13 @@ export class League implements IEntity<LeagueId> {
youtubeUrl?: string;
websiteUrl?: string;
};
logoRef: MediaReference;
}>): League {
const name = props.name ? LeagueName.create(props.name) : this.name;
const description = props.description ? LeagueDescription.create(props.description) : this.description;
const ownerId = props.ownerId ? LeagueOwnerId.create(props.ownerId) : this.ownerId;
const socialLinks = props.socialLinks ? LeagueSocialLinks.create(props.socialLinks) : this.socialLinks;
const logoRef = 'logoRef' in props ? props.logoRef! : this.logoRef;
// If settings are being updated, validate them
let newSettings = props.settings ?? this.settings;
@@ -427,6 +437,7 @@ export class League implements IEntity<LeagueId> {
...(socialLinks !== undefined ? { socialLinks } : {}),
participantCount: this._participantCount,
visibility: this._visibility,
logoRef: logoRef,
});
}
@@ -461,6 +472,7 @@ export class League implements IEntity<LeagueId> {
...(this.socialLinks !== undefined ? { socialLinks: this.socialLinks } : {}),
participantCount: newCount,
visibility: this._visibility,
logoRef: this.logoRef,
});
}
@@ -485,6 +497,7 @@ export class League implements IEntity<LeagueId> {
...(this.socialLinks !== undefined ? { socialLinks: this.socialLinks } : {}),
participantCount: newCount,
visibility: this._visibility,
logoRef: this.logoRef,
});
}