website refactor
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { describe, it, expect, vi, Mocked } from 'vitest';
|
||||
import { AnalyticsService } from './AnalyticsService';
|
||||
import { AnalyticsApiClient } from '../../api/analytics/AnalyticsApiClient';
|
||||
import { RecordPageViewOutputViewModel } from '../../view-models/RecordPageViewOutputViewModel';
|
||||
import { RecordEngagementOutputViewModel } from '../../view-models/RecordEngagementOutputViewModel';
|
||||
import { AnalyticsApiClient } from '@/lib/api/analytics/AnalyticsApiClient';
|
||||
import { RecordPageViewOutputViewModel } from '@/lib/view-models/RecordPageViewOutputViewModel';
|
||||
import { RecordEngagementOutputViewModel } from '@/lib/view-models/RecordEngagementOutputViewModel';
|
||||
|
||||
describe('AnalyticsService', () => {
|
||||
let mockApiClient: Mocked<AnalyticsApiClient>;
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
import { AnalyticsApiClient } from '../../api/analytics/AnalyticsApiClient';
|
||||
import { RecordPageViewOutputViewModel } from '../../view-models/RecordPageViewOutputViewModel';
|
||||
import { RecordEngagementOutputViewModel } from '../../view-models/RecordEngagementOutputViewModel';
|
||||
import { RecordPageViewInputDTO } from '../../types/generated/RecordPageViewInputDTO';
|
||||
import { RecordEngagementInputDTO } from '../../types/generated/RecordEngagementInputDTO';
|
||||
|
||||
/**
|
||||
* Analytics Service
|
||||
*
|
||||
* Orchestrates analytics operations by coordinating API calls.
|
||||
* All dependencies are injected via constructor.
|
||||
*/
|
||||
export class AnalyticsService {
|
||||
constructor(
|
||||
private readonly apiClient: AnalyticsApiClient
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Record a page view
|
||||
*/
|
||||
async recordPageView(input: RecordPageViewInputDTO): Promise<RecordPageViewOutputViewModel> {
|
||||
const result = await this.apiClient.recordPageView(input);
|
||||
return new RecordPageViewOutputViewModel(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Record an engagement event
|
||||
*/
|
||||
async recordEngagement(input: RecordEngagementInputDTO): Promise<RecordEngagementOutputViewModel> {
|
||||
const result = await this.apiClient.recordEngagement(input);
|
||||
return new RecordEngagementOutputViewModel(result);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, vi, Mocked } from 'vitest';
|
||||
import { DashboardService } from './DashboardService';
|
||||
import { AnalyticsApiClient } from '../../api/analytics/AnalyticsApiClient';
|
||||
import { AnalyticsApiClient } from '@/lib/api/analytics/AnalyticsApiClient';
|
||||
import { AnalyticsDashboardViewModel, AnalyticsMetricsViewModel } from '../../view-models';
|
||||
|
||||
describe('DashboardService', () => {
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
import { AnalyticsDashboardViewModel } from '@/lib/view-models/AnalyticsDashboardViewModel';
|
||||
import { AnalyticsMetricsViewModel } from '@/lib/view-models/AnalyticsMetricsViewModel';
|
||||
import { AnalyticsApiClient } from '../../api/analytics/AnalyticsApiClient';
|
||||
|
||||
/**
|
||||
* Dashboard Service
|
||||
*
|
||||
* Orchestrates dashboard operations by coordinating API calls and view model creation.
|
||||
* All dependencies are injected via constructor.
|
||||
*/
|
||||
export class DashboardService {
|
||||
constructor(
|
||||
private readonly apiClient: AnalyticsApiClient
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Get dashboard data with view model transformation
|
||||
*/
|
||||
async getDashboardData(): Promise<AnalyticsDashboardViewModel> {
|
||||
const dto = await this.apiClient.getDashboardData();
|
||||
return new AnalyticsDashboardViewModel(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get analytics metrics with view model transformation
|
||||
*/
|
||||
async getAnalyticsMetrics(): Promise<AnalyticsMetricsViewModel> {
|
||||
const dto = await this.apiClient.getAnalyticsMetrics();
|
||||
return new AnalyticsMetricsViewModel(dto);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user