This commit is contained in:
2025-12-11 21:06:25 +01:00
parent c49ea2598d
commit ec3ddc3a5c
227 changed files with 3496 additions and 2083 deletions

View File

@@ -34,8 +34,12 @@ export class AvatarGenerationRequest implements IEntity<string> {
this.style = props.style;
this._status = props.status;
this._generatedAvatarUrls = props.generatedAvatarUrls.map(url => MediaUrl.create(url));
this._selectedAvatarIndex = props.selectedAvatarIndex;
this._errorMessage = props.errorMessage;
if (props.selectedAvatarIndex !== undefined) {
this._selectedAvatarIndex = props.selectedAvatarIndex;
}
if (props.errorMessage !== undefined) {
this._errorMessage = props.errorMessage;
}
this.createdAt = props.createdAt;
this._updatedAt = props.updatedAt;
}
@@ -85,10 +89,15 @@ export class AvatarGenerationRequest implements IEntity<string> {
}
get selectedAvatarUrl(): string | undefined {
if (this._selectedAvatarIndex !== undefined && this._generatedAvatarUrls[this._selectedAvatarIndex]) {
return this._generatedAvatarUrls[this._selectedAvatarIndex].value;
const index = this._selectedAvatarIndex;
if (index === undefined) {
return undefined;
}
return undefined;
const avatar = this._generatedAvatarUrls[index];
if (!avatar) {
return undefined;
}
return avatar.value;
}
get errorMessage(): string | undefined {
@@ -172,7 +181,7 @@ export class AvatarGenerationRequest implements IEntity<string> {
}
toProps(): AvatarGenerationRequestProps {
return {
const base: AvatarGenerationRequestProps = {
id: this.id,
userId: this.userId,
facePhotoUrl: this.facePhotoUrl.value,
@@ -180,10 +189,18 @@ export class AvatarGenerationRequest implements IEntity<string> {
style: this.style,
status: this._status,
generatedAvatarUrls: this._generatedAvatarUrls.map(url => url.value),
selectedAvatarIndex: this._selectedAvatarIndex,
errorMessage: this._errorMessage,
createdAt: this.createdAt,
updatedAt: this._updatedAt,
};
return {
...base,
...(this._selectedAvatarIndex !== undefined && {
selectedAvatarIndex: this._selectedAvatarIndex,
}),
...(this._errorMessage !== undefined && {
errorMessage: this._errorMessage,
}),
};
}
}

View File

@@ -4,7 +4,7 @@
* Defines the contract for avatar generation request persistence.
*/
import type { AvatarGenerationRequest, AvatarGenerationRequestProps } from '../entities/AvatarGenerationRequest';
import type { AvatarGenerationRequest } from '../entities/AvatarGenerationRequest';
export interface IAvatarGenerationRepository {
/**