website refactor

This commit is contained in:
2026-01-16 16:46:57 +01:00
parent 37b1aa626c
commit 2f53727702
445 changed files with 1160 additions and 1150 deletions

View File

@@ -30,7 +30,7 @@ describe('GetUnreadNotificationsUseCase', () => {
} as unknown as Logger;
useCase = new GetUnreadNotificationsUseCase(
notificationRepository as unknown as INotificationRepository,
notificationRepository as unknown as NotificationRepository,
logger,
);
});

View File

@@ -38,7 +38,7 @@ describe('MarkNotificationReadUseCase', () => {
} as unknown as Logger;
useCase = new MarkNotificationReadUseCase(
notificationRepository as unknown as INotificationRepository,
notificationRepository as unknown as NotificationRepository,
logger,
);
});
@@ -152,7 +152,7 @@ describe('MarkAllNotificationsReadUseCase', () => {
};
useCase = new MarkAllNotificationsReadUseCase(
notificationRepository as unknown as INotificationRepository,
notificationRepository as unknown as NotificationRepository,
);
});
@@ -197,7 +197,7 @@ describe('DismissNotificationUseCase', () => {
};
useCase = new DismissNotificationUseCase(
notificationRepository as unknown as INotificationRepository,
notificationRepository as unknown as NotificationRepository,
);
});

View File

@@ -107,7 +107,7 @@ export type MarkAllNotificationsReadErrorCode = 'REPOSITORY_ERROR';
export class MarkAllNotificationsReadUseCase {
constructor(
private readonly notificationRepository: INotificationRepository,
private readonly notificationRepository: NotificationRepository,
) {}
async execute(
@@ -152,7 +152,7 @@ export type DismissNotificationErrorCode =
export class DismissNotificationUseCase {
constructor(
private readonly notificationRepository: INotificationRepository,
private readonly notificationRepository: NotificationRepository,
) {}
async execute(

View File

@@ -46,7 +46,7 @@ describe('NotificationPreferencesUseCases', () => {
preferenceRepository.getOrCreateDefault.mockResolvedValue(preference);
const useCase = new GetNotificationPreferencesQuery(
preferenceRepository as unknown as INotificationPreferenceRepository,
preferenceRepository as unknown as NotificationPreferenceRepository,
logger,
);
@@ -69,7 +69,7 @@ describe('NotificationPreferencesUseCases', () => {
preferenceRepository.getOrCreateDefault.mockResolvedValue(preference);
const useCase = new UpdateChannelPreferenceUseCase(
preferenceRepository as unknown as INotificationPreferenceRepository,
preferenceRepository as unknown as NotificationPreferenceRepository,
logger,
);
@@ -98,7 +98,7 @@ describe('NotificationPreferencesUseCases', () => {
preferenceRepository.getOrCreateDefault.mockResolvedValue(preference);
const useCase = new UpdateTypePreferenceUseCase(
preferenceRepository as unknown as INotificationPreferenceRepository,
preferenceRepository as unknown as NotificationPreferenceRepository,
logger,
);
@@ -127,7 +127,7 @@ describe('NotificationPreferencesUseCases', () => {
preferenceRepository.getOrCreateDefault.mockResolvedValue(preference);
const useCase = new UpdateQuietHoursUseCase(
preferenceRepository as unknown as INotificationPreferenceRepository,
preferenceRepository as unknown as NotificationPreferenceRepository,
logger,
);
@@ -151,7 +151,7 @@ describe('NotificationPreferencesUseCases', () => {
it('UpdateQuietHoursUseCase returns error on invalid hours', async () => {
const useCase = new UpdateQuietHoursUseCase(
preferenceRepository as unknown as INotificationPreferenceRepository,
preferenceRepository as unknown as NotificationPreferenceRepository,
logger,
);
@@ -176,7 +176,7 @@ describe('NotificationPreferencesUseCases', () => {
preferenceRepository.getOrCreateDefault.mockResolvedValue(preference);
const useCase = new SetDigestModeUseCase(
preferenceRepository as unknown as INotificationPreferenceRepository,
preferenceRepository as unknown as NotificationPreferenceRepository,
);
const command: SetDigestModeCommand = {
@@ -199,7 +199,7 @@ describe('NotificationPreferencesUseCases', () => {
it('SetDigestModeUseCase returns error on invalid frequency', async () => {
const useCase = new SetDigestModeUseCase(
preferenceRepository as unknown as INotificationPreferenceRepository,
preferenceRepository as unknown as NotificationPreferenceRepository,
);
const command: SetDigestModeCommand = {

View File

@@ -70,7 +70,7 @@ export type UpdateChannelPreferenceErrorCode =
export class UpdateChannelPreferenceUseCase {
constructor(
private readonly preferenceRepository: INotificationPreferenceRepository,
private readonly preferenceRepository: NotificationPreferenceRepository,
private readonly logger: Logger,
) {}
@@ -125,7 +125,7 @@ export type UpdateTypePreferenceErrorCode = 'REPOSITORY_ERROR';
export class UpdateTypePreferenceUseCase {
constructor(
private readonly preferenceRepository: INotificationPreferenceRepository,
private readonly preferenceRepository: NotificationPreferenceRepository,
private readonly logger: Logger,
) {}
@@ -184,7 +184,7 @@ export type UpdateQuietHoursErrorCode =
export class UpdateQuietHoursUseCase {
constructor(
private readonly preferenceRepository: INotificationPreferenceRepository,
private readonly preferenceRepository: NotificationPreferenceRepository,
private readonly logger: Logger,
) {}
@@ -261,7 +261,7 @@ export type SetDigestModeErrorCode =
export class SetDigestModeUseCase {
constructor(
private readonly preferenceRepository: INotificationPreferenceRepository,
private readonly preferenceRepository: NotificationPreferenceRepository,
) {}
async execute(

View File

@@ -45,8 +45,8 @@ describe('SendNotificationUseCase', () => {
} as unknown as Logger;
useCase = new SendNotificationUseCase(
notificationRepository as unknown as INotificationRepository,
preferenceRepository as unknown as INotificationPreferenceRepository,
notificationRepository as unknown as NotificationRepository,
preferenceRepository as unknown as NotificationPreferenceRepository,
gatewayRegistry as unknown as NotificationGatewayRegistry,
logger,
);

View File

@@ -47,8 +47,8 @@ export type SendNotificationErrorCode = 'REPOSITORY_ERROR';
export class SendNotificationUseCase {
constructor(
private readonly notificationRepository: INotificationRepository,
private readonly preferenceRepository: INotificationPreferenceRepository,
private readonly notificationRepository: NotificationRepository,
private readonly preferenceRepository: NotificationPreferenceRepository,
private readonly gatewayRegistry: NotificationGatewayRegistry,
private readonly logger: Logger,
) {

View File

@@ -5,7 +5,7 @@
* Immutable entity with factory methods and domain validation.
*/
import type { Entity } from '@core/shared/domain/Entity';
import { Entity } from '@core/shared/domain/Entity';
import { NotificationDomainError } from '../errors/NotificationDomainError';
import { NotificationId } from '../value-objects/NotificationId';
@@ -86,8 +86,9 @@ export interface NotificationProps {
respondedAt?: Date;
}
export class Notification implements Entity<string> {
private constructor(private readonly props: NotificationProps) {}
export class Notification extends Entity<NotificationId> {
private constructor(private readonly props: NotificationProps) {
super(props.id);}
static create(props: Omit<NotificationProps, 'id' | 'status' | 'createdAt' | 'urgency'> & {
id: string;
@@ -115,7 +116,6 @@ export class Notification implements Entity<string> {
});
}
get id(): string { return this.props.id.value; }
get recipientId(): string { return this.props.recipientId; }
get type(): NotificationType { return this.props.type; }
get title(): string { return this.props.title; }

View File

@@ -4,7 +4,7 @@
* Represents a user's notification preferences for different channels and types.
*/
import type { Entity } from '@core/shared/domain/Entity';
import { Entity } from '@core/shared/domain/Entity';
import { NotificationDomainError } from '../errors/NotificationDomainError';
import type { NotificationChannel, NotificationType } from '../types/NotificationTypes';
import { QuietHours } from '../value-objects/QuietHours';
@@ -44,8 +44,9 @@ export interface NotificationPreferenceProps {
updatedAt: Date;
}
export class NotificationPreference implements Entity<string> {
private constructor(private readonly props: NotificationPreferenceProps) {}
export class NotificationPreference extends Entity<string> {
private constructor(private readonly props: NotificationPreferenceProps) {
super(props.id);}
static create(
props: Omit<NotificationPreferenceProps, 'updatedAt'> & { updatedAt?: Date },
@@ -78,7 +79,6 @@ export class NotificationPreference implements Entity<string> {
});
}
get id(): string { return this.props.id; }
get driverId(): string { return this.props.driverId; }
get channels(): Record<NotificationChannel, ChannelPreference> { return { ...this.props.channels }; }
get typePreferences(): Partial<Record<NotificationType, TypePreference>> | undefined {

View File

@@ -1,9 +1,10 @@
import type { DomainError, CommonDomainErrorKind } from '@core/shared/errors';
import type { DomainError } from '@core/shared/errors/DomainError';
import type { CommonDomainErrorKind } from '@core/shared/errors/DomainError';
/**
* Domain Error: NotificationDomainError
*
* Implements the shared IDomainError contract for notification domain failures.
* Implements the shared DomainError contract for notification domain failures.
*/
export class NotificationDomainError extends Error implements DomainError<CommonDomainErrorKind> {
readonly name = 'NotificationDomainError';

View File

@@ -1,5 +1,5 @@
/**
* Repository Interface: INotificationPreferenceRepository
* Repository Interface: NotificationPreferenceRepository
*
* Defines the contract for persisting and retrieving NotificationPreference entities.
*/

View File

@@ -1,5 +1,5 @@
/**
* Repository Interface: INotificationRepository
* Repository Interface: NotificationRepository
*
* Defines the contract for persisting and retrieving Notification entities.
*/

View File

@@ -1,4 +1,4 @@
import type { ValueObject } from '@core/shared/domain';
import type { ValueObject } from '@core/shared/domain/ValueObject';
import { NotificationDomainError } from '../errors/NotificationDomainError';
export interface NotificationIdProps {
@@ -37,7 +37,7 @@ export class NotificationId implements ValueObject<NotificationIdProps> {
return this.props.value;
}
equals(other: IValueObject<NotificationIdProps>): boolean {
equals(other: ValueObject<NotificationIdProps>): boolean {
return this.props.value === other.props.value;
}
}

View File

@@ -1,4 +1,4 @@
import type { ValueObject } from '@core/shared/domain';
import type { ValueObject } from '@core/shared/domain/ValueObject';
import { NotificationDomainError } from '../errors/NotificationDomainError';
export interface QuietHoursProps {
@@ -63,7 +63,7 @@ export class QuietHours implements ValueObject<QuietHoursProps> {
return hour >= startHour || hour < endHour;
}
equals(other: IValueObject<QuietHoursProps>): boolean {
equals(other: ValueObject<QuietHoursProps>): boolean {
return (
this.props.startHour === other.props.startHour &&
this.props.endHour === other.props.endHour