resolve manual DTOs

This commit is contained in:
2025-12-18 22:19:40 +01:00
parent 4a3087ae35
commit d617654928
179 changed files with 3716 additions and 1257 deletions

View File

@@ -1,24 +1,10 @@
import { BaseApiClient } from '../base/BaseApiClient';
import { RecordPageViewOutputDTO } from '../../types/generated/RecordPageViewOutputDTO';
import { RecordEngagementOutputDTO } from '../../types/generated/RecordEngagementOutputDTO';
// TODO: Move these types to apps/website/lib/types/generated when available
type RecordPageViewInputDto = { path: string; userId?: string };
type RecordEngagementInputDto = { eventType: string; userId?: string; metadata?: Record<string, unknown> };
// TODO: Move these types to apps/website/lib/types/generated when available
type AnalyticsDashboardDto = {
totalUsers: number;
activeUsers: number;
totalRaces: number;
totalLeagues: number;
};
type AnalyticsMetricsDto = {
pageViews: number;
uniqueVisitors: number;
averageSessionDuration: number;
bounceRate: number;
};
import { GetDashboardDataOutputDTO } from '../../types/generated/GetDashboardDataOutputDTO';
import { GetAnalyticsMetricsOutputDTO } from '../../types/generated/GetAnalyticsMetricsOutputDTO';
import { RecordPageViewInputDTO } from '../../types/generated/RecordPageViewInputDTO';
import { RecordEngagementInputDTO } from '../../types/generated/RecordEngagementInputDTO';
/**
* Analytics API Client
@@ -27,22 +13,22 @@ type AnalyticsMetricsDto = {
*/
export class AnalyticsApiClient extends BaseApiClient {
/** Record a page view */
recordPageView(input: RecordPageViewInputDto): Promise<RecordPageViewOutputDTO> {
recordPageView(input: RecordPageViewInputDTO): Promise<RecordPageViewOutputDTO> {
return this.post<RecordPageViewOutputDTO>('/analytics/page-view', input);
}
/** Record an engagement event */
recordEngagement(input: RecordEngagementInputDto): Promise<RecordEngagementOutputDTO> {
recordEngagement(input: RecordEngagementInputDTO): Promise<RecordEngagementOutputDTO> {
return this.post<RecordEngagementOutputDTO>('/analytics/engagement', input);
}
/** Get analytics dashboard data */
getDashboardData(): Promise<AnalyticsDashboardDto> {
return this.get<AnalyticsDashboardDto>('/analytics/dashboard');
getDashboardData(): Promise<GetDashboardDataOutputDTO> {
return this.get<GetDashboardDataOutputDTO>('/analytics/dashboard');
}
/** Get analytics metrics */
getAnalyticsMetrics(): Promise<AnalyticsMetricsDto> {
return this.get<AnalyticsMetricsDto>('/analytics/metrics');
getAnalyticsMetrics(): Promise<GetAnalyticsMetricsOutputDTO> {
return this.get<GetAnalyticsMetricsOutputDTO>('/analytics/metrics');
}
}