website refactor
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { Logger, UseCase } from '@core/shared/application';
|
||||
import type { Logger } from '@core/shared/domain/Logger';
|
||||
import type { UseCase } from '@core/shared/application/UseCase';
|
||||
import { Result } from '@core/shared/domain/Result';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
import type { PageViewRepository } from '../repositories/PageViewRepository';
|
||||
@@ -20,7 +21,7 @@ export type GetAnalyticsMetricsErrorCode = 'REPOSITORY_ERROR';
|
||||
export class GetAnalyticsMetricsUseCase implements UseCase<GetAnalyticsMetricsInput, GetAnalyticsMetricsOutput, GetAnalyticsMetricsErrorCode> {
|
||||
constructor(
|
||||
private readonly logger: Logger,
|
||||
private readonly pageViewRepository?: IPageViewRepository,
|
||||
private readonly pageViewRepository?: PageViewRepository,
|
||||
) {}
|
||||
|
||||
async execute(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { Logger, UseCase } from '@core/shared/application';
|
||||
import type { Logger } from '@core/shared/domain/Logger';
|
||||
import type { UseCase } from '@core/shared/application/UseCase';
|
||||
import { Result } from '@core/shared/domain/Result';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ describe('GetEntityAnalyticsQuery', () => {
|
||||
} as unknown as Logger;
|
||||
|
||||
useCase = new GetEntityAnalyticsQuery(
|
||||
pageViewRepository as unknown as IPageViewRepository,
|
||||
engagementRepository as unknown as IEngagementRepository,
|
||||
pageViewRepository as unknown as PageViewRepository,
|
||||
engagementRepository as unknown as EngagementRepository,
|
||||
logger,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
* Returns metrics formatted for display to sponsors and admins.
|
||||
*/
|
||||
|
||||
import type { AsyncUseCase , Logger } from '@core/shared/application';
|
||||
import type { AsyncUseCase } from '@core/shared/application/AsyncUseCase';
|
||||
import type { Logger } from '@core/shared/domain/Logger';
|
||||
import type { PageViewRepository } from '../repositories/PageViewRepository';
|
||||
import type { EngagementRepository } from '@core/analytics/domain/repositories/EngagementRepository';
|
||||
import type { EntityType } from '../../domain/types/PageView';
|
||||
@@ -48,8 +49,8 @@ export type GetEntityAnalyticsErrorCode = 'REPOSITORY_ERROR';
|
||||
export class GetEntityAnalyticsQuery
|
||||
implements AsyncUseCase<GetEntityAnalyticsInput, EntityAnalyticsOutput, GetEntityAnalyticsErrorCode> {
|
||||
constructor(
|
||||
private readonly pageViewRepository: IPageViewRepository,
|
||||
private readonly engagementRepository: IEngagementRepository,
|
||||
private readonly pageViewRepository: PageViewRepository,
|
||||
private readonly engagementRepository: EngagementRepository,
|
||||
private readonly logger: Logger
|
||||
) {}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ describe('RecordEngagementUseCase', () => {
|
||||
} as unknown as Logger;
|
||||
|
||||
useCase = new RecordEngagementUseCase(
|
||||
engagementRepository as unknown as IEngagementRepository,
|
||||
engagementRepository as unknown as EngagementRepository,
|
||||
logger,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { Logger, UseCase } from '@core/shared/application';
|
||||
import type { Logger } from '@core/shared/domain/Logger';
|
||||
import type { UseCase } from '@core/shared/application/UseCase';
|
||||
import { Result } from '@core/shared/domain/Result';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
import { EngagementEvent } from '../../domain/entities/EngagementEvent';
|
||||
@@ -24,7 +25,7 @@ export type RecordEngagementErrorCode = 'REPOSITORY_ERROR';
|
||||
|
||||
export class RecordEngagementUseCase implements UseCase<RecordEngagementInput, RecordEngagementOutput, RecordEngagementErrorCode> {
|
||||
constructor(
|
||||
private readonly engagementRepository: IEngagementRepository,
|
||||
private readonly engagementRepository: EngagementRepository,
|
||||
private readonly logger: Logger,
|
||||
) {}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { Logger, UseCase } from '@core/shared/application';
|
||||
import type { Logger } from '@core/shared/domain/Logger';
|
||||
import type { UseCase } from '@core/shared/application/UseCase';
|
||||
import type { PageViewRepository } from '../repositories/PageViewRepository';
|
||||
import { PageView } from '../../domain/entities/PageView';
|
||||
import type { EntityType, VisitorType } from '../../domain/types/PageView';
|
||||
@@ -24,7 +25,7 @@ export type RecordPageViewErrorCode = 'REPOSITORY_ERROR';
|
||||
|
||||
export class RecordPageViewUseCase implements UseCase<RecordPageViewInput, RecordPageViewOutput, RecordPageViewErrorCode> {
|
||||
constructor(
|
||||
private readonly pageViewRepository: IPageViewRepository,
|
||||
private readonly pageViewRepository: PageViewRepository,
|
||||
private readonly logger: Logger,
|
||||
) {}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Pre-calculated metrics for sponsor dashboard and entity analytics.
|
||||
*/
|
||||
|
||||
import type { Entity } from '@core/shared/domain/Entity';
|
||||
import { Entity } from '@core/shared/domain/Entity';
|
||||
import type {
|
||||
AnalyticsMetrics,
|
||||
AnalyticsSnapshotProps,
|
||||
@@ -15,8 +15,7 @@ import type {
|
||||
import { AnalyticsEntityId } from '../value-objects/AnalyticsEntityId';
|
||||
export type { SnapshotEntityType, SnapshotPeriod } from '../types/AnalyticsSnapshot';
|
||||
|
||||
export class AnalyticsSnapshot implements Entity<string> {
|
||||
readonly id: string;
|
||||
export class AnalyticsSnapshot extends Entity<string> {
|
||||
readonly entityType: SnapshotEntityType;
|
||||
readonly period: SnapshotPeriod;
|
||||
readonly startDate: Date;
|
||||
@@ -27,7 +26,7 @@ export class AnalyticsSnapshot implements Entity<string> {
|
||||
private readonly entityIdVo: AnalyticsEntityId;
|
||||
|
||||
private constructor(props: AnalyticsSnapshotProps) {
|
||||
this.id = props.id;
|
||||
super(props.id);
|
||||
this.entityType = props.entityType;
|
||||
this.entityIdVo = AnalyticsEntityId.create(props.entityId);
|
||||
this.period = props.period;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Tracks clicks, downloads, sign-ups, and other engagement actions.
|
||||
*/
|
||||
|
||||
import type { Entity } from '@core/shared/domain/Entity';
|
||||
import { Entity } from '@core/shared/domain/Entity';
|
||||
import type {
|
||||
EngagementAction,
|
||||
EngagementEntityType,
|
||||
@@ -15,8 +15,7 @@ import { AnalyticsEntityId } from '../value-objects/AnalyticsEntityId';
|
||||
|
||||
export type { EngagementAction, EngagementEntityType } from '../types/EngagementEvent';
|
||||
|
||||
export class EngagementEvent implements Entity<string> {
|
||||
readonly id: string;
|
||||
export class EngagementEvent extends Entity<string> {
|
||||
readonly action: EngagementAction;
|
||||
readonly entityType: EngagementEntityType;
|
||||
readonly actorId: string | undefined;
|
||||
@@ -28,7 +27,8 @@ export class EngagementEvent implements Entity<string> {
|
||||
private readonly entityIdVo: AnalyticsEntityId;
|
||||
|
||||
private constructor(props: EngagementEventProps) {
|
||||
this.id = props.id;
|
||||
super(props.id);
|
||||
|
||||
this.action = props.action;
|
||||
this.entityType = props.entityType;
|
||||
this.entityIdVo = AnalyticsEntityId.create(props.entityId);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Captures visitor interactions with leagues, drivers, teams, races.
|
||||
*/
|
||||
|
||||
import type { Entity } from '@core/shared/domain/Entity';
|
||||
import { Entity } from '@core/shared/domain/Entity';
|
||||
import type { EntityType, PageViewProps, VisitorType } from '../types/PageView';
|
||||
import { AnalyticsEntityId } from '../value-objects/AnalyticsEntityId';
|
||||
import { AnalyticsSessionId } from '../value-objects/AnalyticsSessionId';
|
||||
@@ -13,7 +13,7 @@ import { PageViewId } from '../value-objects/PageViewId';
|
||||
|
||||
export type { EntityType, VisitorType } from '../types/PageView';
|
||||
|
||||
export class PageView implements Entity<string> {
|
||||
export class PageView extends Entity<string> {
|
||||
readonly entityType: EntityType;
|
||||
readonly visitorId: string | undefined;
|
||||
readonly visitorType: VisitorType;
|
||||
@@ -28,6 +28,7 @@ export class PageView implements Entity<string> {
|
||||
private readonly sessionIdVo: AnalyticsSessionId;
|
||||
|
||||
private constructor(props: PageViewProps) {
|
||||
super(props.id);
|
||||
this.idVo = PageViewId.create(props.id);
|
||||
this.entityType = props.entityType;
|
||||
this.entityIdVo = AnalyticsEntityId.create(props.entityId);
|
||||
@@ -41,10 +42,6 @@ export class PageView implements Entity<string> {
|
||||
this.durationMs = props.durationMs;
|
||||
}
|
||||
|
||||
get id(): string {
|
||||
return this.idVo.value;
|
||||
}
|
||||
|
||||
get entityId(): string {
|
||||
return this.entityIdVo.value;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Repository Interface: IAnalyticsSnapshotRepository
|
||||
* Repository Interface: AnalyticsSnapshotRepository
|
||||
*
|
||||
* Defines persistence operations for AnalyticsSnapshot entities.
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ValueObject } from '@core/shared/domain';
|
||||
import type { ValueObject } from '@core/shared/domain/ValueObject';
|
||||
|
||||
export interface AnalyticsEntityIdProps {
|
||||
value: string;
|
||||
@@ -31,7 +31,7 @@ export class AnalyticsEntityId implements ValueObject<AnalyticsEntityIdProps> {
|
||||
return this.props.value;
|
||||
}
|
||||
|
||||
equals(other: IValueObject<AnalyticsEntityIdProps>): boolean {
|
||||
equals(other: ValueObject<AnalyticsEntityIdProps>): boolean {
|
||||
return this.props.value === other.props.value;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ValueObject } from '@core/shared/domain';
|
||||
import type { ValueObject } from '@core/shared/domain/ValueObject';
|
||||
|
||||
export interface AnalyticsSessionIdProps {
|
||||
value: string;
|
||||
@@ -30,7 +30,7 @@ export class AnalyticsSessionId implements ValueObject<AnalyticsSessionIdProps>
|
||||
return this.props.value;
|
||||
}
|
||||
|
||||
equals(other: IValueObject<AnalyticsSessionIdProps>): boolean {
|
||||
equals(other: ValueObject<AnalyticsSessionIdProps>): boolean {
|
||||
return this.props.value === other.props.value;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ValueObject } from '@core/shared/domain';
|
||||
import type { ValueObject } from '@core/shared/domain/ValueObject';
|
||||
|
||||
export interface PageViewIdProps {
|
||||
value: string;
|
||||
@@ -30,7 +30,7 @@ export class PageViewId implements ValueObject<PageViewIdProps> {
|
||||
return this.props.value;
|
||||
}
|
||||
|
||||
equals(other: IValueObject<PageViewIdProps>): boolean {
|
||||
equals(other: ValueObject<PageViewIdProps>): boolean {
|
||||
return this.props.value === other.props.value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user