refactor driver module (wip)
This commit is contained in:
@@ -166,9 +166,9 @@
|
|||||||
"error",
|
"error",
|
||||||
{
|
{
|
||||||
"args": "all",
|
"args": "all",
|
||||||
"argsIgnorePattern": "^$",
|
"argsIgnorePattern": "^_",
|
||||||
"vars": "all",
|
"vars": "all",
|
||||||
"varsIgnorePattern": "^$",
|
"varsIgnorePattern": "^_",
|
||||||
"caughtErrors": "all"
|
"caughtErrors": "all"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ describe('DriverController', () => {
|
|||||||
|
|
||||||
describe('getDriversLeaderboard', () => {
|
describe('getDriversLeaderboard', () => {
|
||||||
it('should return drivers leaderboard', async () => {
|
it('should return drivers leaderboard', async () => {
|
||||||
const leaderboard: DriversLeaderboardDTO = { items: [] };
|
const leaderboard: DriversLeaderboardDTO = { drivers: [], totalRaces: 0, totalWins: 0, activeCount: 0 };
|
||||||
service.getDriversLeaderboard.mockResolvedValue({ viewModel: leaderboard } as never);
|
service.getDriversLeaderboard.mockResolvedValue({ viewModel: leaderboard } as never);
|
||||||
|
|
||||||
const result = await controller.getDriversLeaderboard();
|
const result = await controller.getDriversLeaderboard();
|
||||||
@@ -94,7 +94,7 @@ describe('DriverController', () => {
|
|||||||
describe('completeOnboarding', () => {
|
describe('completeOnboarding', () => {
|
||||||
it('should complete onboarding', async () => {
|
it('should complete onboarding', async () => {
|
||||||
const userId = 'user-123';
|
const userId = 'user-123';
|
||||||
const input: CompleteOnboardingInputDTO = { someField: 'value' } as CompleteOnboardingInputDTO;
|
const input: CompleteOnboardingInputDTO = { someField: 'value' } as unknown as CompleteOnboardingInputDTO;
|
||||||
const output: CompleteOnboardingOutputDTO = { success: true };
|
const output: CompleteOnboardingOutputDTO = { success: true };
|
||||||
service.completeOnboarding.mockResolvedValue({ viewModel: output } as never);
|
service.completeOnboarding.mockResolvedValue({ viewModel: output } as never);
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ describe('DriverController', () => {
|
|||||||
it('should return registration status', async () => {
|
it('should return registration status', async () => {
|
||||||
const driverId = 'driver-123';
|
const driverId = 'driver-123';
|
||||||
const raceId = 'race-456';
|
const raceId = 'race-456';
|
||||||
const status: DriverRegistrationStatusDTO = { registered: true } as DriverRegistrationStatusDTO;
|
const status: DriverRegistrationStatusDTO = { registered: true } as unknown as DriverRegistrationStatusDTO;
|
||||||
service.getDriverRegistrationStatus.mockResolvedValue({ viewModel: status } as never);
|
service.getDriverRegistrationStatus.mockResolvedValue({ viewModel: status } as never);
|
||||||
|
|
||||||
const result = await controller.getDriverRegistrationStatus(driverId, raceId);
|
const result = await controller.getDriverRegistrationStatus(driverId, raceId);
|
||||||
@@ -137,7 +137,7 @@ describe('DriverController', () => {
|
|||||||
describe('getDriverProfile', () => {
|
describe('getDriverProfile', () => {
|
||||||
it('should return driver profile', async () => {
|
it('should return driver profile', async () => {
|
||||||
const driverId = 'driver-123';
|
const driverId = 'driver-123';
|
||||||
const profile: GetDriverProfileOutputDTO = { id: driverId, bio: 'Bio' };
|
const profile: GetDriverProfileOutputDTO = { id: driverId, bio: 'Bio' } as unknown as GetDriverProfileOutputDTO;
|
||||||
service.getDriverProfile.mockResolvedValue(profile);
|
service.getDriverProfile.mockResolvedValue(profile);
|
||||||
|
|
||||||
const result = await controller.getDriverProfile(driverId);
|
const result = await controller.getDriverProfile(driverId);
|
||||||
@@ -151,7 +151,7 @@ describe('DriverController', () => {
|
|||||||
it('should update driver profile', async () => {
|
it('should update driver profile', async () => {
|
||||||
const driverId = 'driver-123';
|
const driverId = 'driver-123';
|
||||||
const body = { bio: 'New bio', country: 'US' };
|
const body = { bio: 'New bio', country: 'US' };
|
||||||
const updated: GetDriverOutputDTO = { id: driverId, name: 'Driver' };
|
const updated: GetDriverOutputDTO = { id: driverId, name: 'Driver' } as unknown as GetDriverOutputDTO;
|
||||||
service.updateDriverProfile.mockResolvedValue(updated);
|
service.updateDriverProfile.mockResolvedValue(updated);
|
||||||
|
|
||||||
const result = await controller.updateDriverProfile(driverId, body);
|
const result = await controller.updateDriverProfile(driverId, body);
|
||||||
|
|||||||
@@ -1,20 +1,18 @@
|
|||||||
import { Controller, Get, Post, Put, Body, Req, Param } from '@nestjs/common';
|
import { Body, Controller, Get, Param, Post, Put, Req } from '@nestjs/common';
|
||||||
|
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||||
import { Request } from 'express';
|
import { Request } from 'express';
|
||||||
import { ApiTags, ApiResponse, ApiOperation } from '@nestjs/swagger';
|
import { DriverService } from './DriverService';
|
||||||
|
import { CompleteOnboardingInputDTO } from './dtos/CompleteOnboardingInputDTO';
|
||||||
|
import { CompleteOnboardingOutputDTO } from './dtos/CompleteOnboardingOutputDTO';
|
||||||
|
import { DriverRegistrationStatusDTO } from './dtos/DriverRegistrationStatusDTO';
|
||||||
|
import { DriversLeaderboardDTO } from './dtos/DriversLeaderboardDTO';
|
||||||
|
import { DriverStatsDTO } from './dtos/DriverStatsDTO';
|
||||||
|
import { GetDriverOutputDTO } from './dtos/GetDriverOutputDTO';
|
||||||
|
import { GetDriverProfileOutputDTO } from './dtos/GetDriverProfileOutputDTO';
|
||||||
|
|
||||||
interface AuthenticatedRequest extends Request {
|
interface AuthenticatedRequest extends Request {
|
||||||
user?: { userId: string };
|
user?: { userId: string };
|
||||||
}
|
}
|
||||||
import { DriverService } from './DriverService';
|
|
||||||
import { DriversLeaderboardDTO } from './dtos/DriversLeaderboardDTO';
|
|
||||||
import { DriverStatsDTO } from './dtos/DriverStatsDTO';
|
|
||||||
import { CompleteOnboardingInputDTO } from './dtos/CompleteOnboardingInputDTO';
|
|
||||||
import { CompleteOnboardingOutputDTO } from './dtos/CompleteOnboardingOutputDTO';
|
|
||||||
import { GetDriverRegistrationStatusQueryDTO } from './dtos/GetDriverRegistrationStatusQueryDTO';
|
|
||||||
import { DriverRegistrationStatusDTO } from './dtos/DriverRegistrationStatusDTO';
|
|
||||||
import { DriverDTO } from './dtos/DriverDTO';
|
|
||||||
import { GetDriverOutputDTO } from './dtos/GetDriverOutputDTO';
|
|
||||||
import { GetDriverProfileOutputDTO } from './dtos/GetDriverProfileOutputDTO';
|
|
||||||
|
|
||||||
@ApiTags('drivers')
|
@ApiTags('drivers')
|
||||||
@Controller('drivers')
|
@Controller('drivers')
|
||||||
|
|||||||
@@ -2,48 +2,38 @@ import { Provider } from '@nestjs/common';
|
|||||||
import { DriverService } from './DriverService';
|
import { DriverService } from './DriverService';
|
||||||
|
|
||||||
// Import core interfaces
|
// Import core interfaces
|
||||||
import { IDriverRepository } from '@core/racing/domain/repositories/IDriverRepository';
|
|
||||||
import { IRankingService } from '@core/racing/domain/services/IRankingService';
|
|
||||||
import { IDriverStatsService } from '@core/racing/domain/services/IDriverStatsService';
|
|
||||||
import { DriverRatingProvider } from '@core/racing/application/ports/DriverRatingProvider';
|
|
||||||
import { DriverExtendedProfileProvider } from '@core/racing/application/ports/DriverExtendedProfileProvider';
|
import { DriverExtendedProfileProvider } from '@core/racing/application/ports/DriverExtendedProfileProvider';
|
||||||
import { IImageServicePort } from '@core/racing/application/ports/IImageServicePort';
|
import { IDriverRepository } from '@core/racing/domain/repositories/IDriverRepository';
|
||||||
import { IRaceRegistrationRepository } from '@core/racing/domain/repositories/IRaceRegistrationRepository';
|
import { IRaceRegistrationRepository } from '@core/racing/domain/repositories/IRaceRegistrationRepository';
|
||||||
import { INotificationPreferenceRepository } from '@core/notifications/domain/repositories/INotificationPreferenceRepository';
|
|
||||||
import type { Logger } from '@core/shared/application';
|
|
||||||
import type { ITeamRepository } from '@core/racing/domain/repositories/ITeamRepository';
|
|
||||||
import type { ITeamMembershipRepository } from '@core/racing/domain/repositories/ITeamMembershipRepository';
|
import type { ITeamMembershipRepository } from '@core/racing/domain/repositories/ITeamMembershipRepository';
|
||||||
|
import type { ITeamRepository } from '@core/racing/domain/repositories/ITeamRepository';
|
||||||
|
import { IDriverStatsService } from '@core/racing/domain/services/IDriverStatsService';
|
||||||
|
import { IRankingService } from '@core/racing/domain/services/IRankingService';
|
||||||
|
import type { Logger } from '@core/shared/application';
|
||||||
import type { ISocialGraphRepository } from '@core/social/domain/repositories/ISocialGraphRepository';
|
import type { ISocialGraphRepository } from '@core/social/domain/repositories/ISocialGraphRepository';
|
||||||
|
|
||||||
// Import use cases
|
// Import use cases
|
||||||
import { GetDriversLeaderboardUseCase } from '@core/racing/application/use-cases/GetDriversLeaderboardUseCase';
|
|
||||||
import { GetTotalDriversUseCase } from '@core/racing/application/use-cases/GetTotalDriversUseCase';
|
|
||||||
import { CompleteDriverOnboardingUseCase } from '@core/racing/application/use-cases/CompleteDriverOnboardingUseCase';
|
import { CompleteDriverOnboardingUseCase } from '@core/racing/application/use-cases/CompleteDriverOnboardingUseCase';
|
||||||
import { UpdateDriverProfileUseCase } from '@core/racing/application/use-cases/UpdateDriverProfileUseCase';
|
import { GetDriversLeaderboardUseCase } from '@core/racing/application/use-cases/GetDriversLeaderboardUseCase';
|
||||||
import { IsDriverRegisteredForRaceUseCase } from '@core/racing/application/use-cases/IsDriverRegisteredForRaceUseCase';
|
|
||||||
import { GetProfileOverviewUseCase } from '@core/racing/application/use-cases/GetProfileOverviewUseCase';
|
import { GetProfileOverviewUseCase } from '@core/racing/application/use-cases/GetProfileOverviewUseCase';
|
||||||
|
import { GetTotalDriversUseCase } from '@core/racing/application/use-cases/GetTotalDriversUseCase';
|
||||||
// Import presenters
|
import { IsDriverRegisteredForRaceUseCase } from '@core/racing/application/use-cases/IsDriverRegisteredForRaceUseCase';
|
||||||
import { DriverStatsPresenter } from './presenters/DriverStatsPresenter';
|
import { UpdateDriverProfileUseCase } from '@core/racing/application/use-cases/UpdateDriverProfileUseCase';
|
||||||
import { DriversLeaderboardPresenter } from './presenters/DriversLeaderboardPresenter';
|
|
||||||
import { CompleteOnboardingPresenter } from './presenters/CompleteOnboardingPresenter';
|
|
||||||
import { DriverRegistrationStatusPresenter } from './presenters/DriverRegistrationStatusPresenter';
|
|
||||||
import { DriverPresenter } from './presenters/DriverPresenter';
|
|
||||||
import { DriverProfilePresenter } from './presenters/DriverProfilePresenter';
|
|
||||||
|
|
||||||
// Import concrete in-memory implementations
|
// Import concrete in-memory implementations
|
||||||
import { InMemoryDriverRepository } from '@adapters/racing/persistence/inmemory/InMemoryDriverRepository';
|
|
||||||
import { InMemoryRankingService } from '@adapters/racing/services/InMemoryRankingService';
|
|
||||||
import { InMemoryDriverStatsService } from '@adapters/racing/services/InMemoryDriverStatsService';
|
|
||||||
import { InMemoryDriverRatingProvider } from '@adapters/racing/ports/InMemoryDriverRatingProvider';
|
|
||||||
import { InMemoryDriverExtendedProfileProvider } from '@adapters/racing/ports/InMemoryDriverExtendedProfileProvider';
|
|
||||||
import { InMemoryImageServiceAdapter } from '@adapters/media/ports/InMemoryImageServiceAdapter';
|
|
||||||
import { InMemoryRaceRegistrationRepository } from '@adapters/racing/persistence/inmemory/InMemoryRaceRegistrationRepository';
|
|
||||||
import { InMemoryNotificationPreferenceRepository } from '@adapters/notifications/persistence/inmemory/InMemoryNotificationPreferenceRepository';
|
|
||||||
import { InMemoryTeamRepository } from '@adapters/racing/persistence/inmemory/InMemoryTeamRepository';
|
|
||||||
import { InMemoryTeamMembershipRepository } from '@adapters/racing/persistence/inmemory/InMemoryTeamMembershipRepository';
|
|
||||||
import { InMemorySocialGraphRepository } from '@core/social/infrastructure/inmemory/InMemorySocialAndFeed';
|
|
||||||
import { ConsoleLogger } from '@adapters/logging/ConsoleLogger';
|
import { ConsoleLogger } from '@adapters/logging/ConsoleLogger';
|
||||||
|
import { InMemoryImageServiceAdapter } from '@adapters/media/ports/InMemoryImageServiceAdapter';
|
||||||
|
import { InMemoryNotificationPreferenceRepository } from '@adapters/notifications/persistence/inmemory/InMemoryNotificationPreferenceRepository';
|
||||||
|
import { InMemoryDriverRepository } from '@adapters/racing/persistence/inmemory/InMemoryDriverRepository';
|
||||||
|
import { InMemoryRaceRegistrationRepository } from '@adapters/racing/persistence/inmemory/InMemoryRaceRegistrationRepository';
|
||||||
|
import { InMemoryTeamMembershipRepository } from '@adapters/racing/persistence/inmemory/InMemoryTeamMembershipRepository';
|
||||||
|
import { InMemoryTeamRepository } from '@adapters/racing/persistence/inmemory/InMemoryTeamRepository';
|
||||||
|
import { InMemoryDriverExtendedProfileProvider } from '@adapters/racing/ports/InMemoryDriverExtendedProfileProvider';
|
||||||
|
import { InMemoryDriverRatingProvider } from '@adapters/racing/ports/InMemoryDriverRatingProvider';
|
||||||
|
import { InMemoryDriverStatsService } from '@adapters/racing/services/InMemoryDriverStatsService';
|
||||||
|
import { InMemoryRankingService } from '@adapters/racing/services/InMemoryRankingService';
|
||||||
|
import { IImageServicePort } from '@core/racing/application/ports/IImageServicePort';
|
||||||
|
import { InMemorySocialGraphRepository } from '@core/social/infrastructure/inmemory/InMemorySocialAndFeed';
|
||||||
|
|
||||||
// Define injection tokens
|
// Define injection tokens
|
||||||
export const DRIVER_REPOSITORY_TOKEN = 'IDriverRepository';
|
export const DRIVER_REPOSITORY_TOKEN = 'IDriverRepository';
|
||||||
@@ -69,13 +59,6 @@ export const GET_PROFILE_OVERVIEW_USE_CASE_TOKEN = 'GetProfileOverviewUseCase';
|
|||||||
|
|
||||||
export const DriverProviders: Provider[] = [
|
export const DriverProviders: Provider[] = [
|
||||||
DriverService, // Provide the service itself
|
DriverService, // Provide the service itself
|
||||||
// Presenters
|
|
||||||
DriversLeaderboardPresenter,
|
|
||||||
DriverStatsPresenter,
|
|
||||||
CompleteOnboardingPresenter,
|
|
||||||
DriverRegistrationStatusPresenter,
|
|
||||||
DriverPresenter,
|
|
||||||
DriverProfilePresenter,
|
|
||||||
{
|
{
|
||||||
provide: DRIVER_REPOSITORY_TOKEN,
|
provide: DRIVER_REPOSITORY_TOKEN,
|
||||||
useFactory: (logger: Logger) => new InMemoryDriverRepository(logger), // Factory for InMemoryDriverRepository
|
useFactory: (logger: Logger) => new InMemoryDriverRepository(logger), // Factory for InMemoryDriverRepository
|
||||||
@@ -145,30 +128,29 @@ export const DriverProviders: Provider[] = [
|
|||||||
driverStatsService: IDriverStatsService,
|
driverStatsService: IDriverStatsService,
|
||||||
imageService: IImageServicePort,
|
imageService: IImageServicePort,
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
presenter: DriversLeaderboardPresenter,
|
) => new GetDriversLeaderboardUseCase(driverRepo, rankingService, driverStatsService, imageService, logger),
|
||||||
) => new GetDriversLeaderboardUseCase(driverRepo, rankingService, driverStatsService, imageService, logger, presenter),
|
inject: [DRIVER_REPOSITORY_TOKEN, RANKING_SERVICE_TOKEN, DRIVER_STATS_SERVICE_TOKEN, IMAGE_SERVICE_PORT_TOKEN, LOGGER_TOKEN],
|
||||||
inject: [DRIVER_REPOSITORY_TOKEN, RANKING_SERVICE_TOKEN, DRIVER_STATS_SERVICE_TOKEN, IMAGE_SERVICE_PORT_TOKEN, LOGGER_TOKEN, DriversLeaderboardPresenter.name],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: GET_TOTAL_DRIVERS_USE_CASE_TOKEN,
|
provide: GET_TOTAL_DRIVERS_USE_CASE_TOKEN,
|
||||||
useFactory: (driverRepo: IDriverRepository, logger: Logger) => new GetTotalDriversUseCase(driverRepo, logger),
|
useFactory: (driverRepo: IDriverRepository) => new GetTotalDriversUseCase(driverRepo),
|
||||||
inject: [DRIVER_REPOSITORY_TOKEN, LOGGER_TOKEN],
|
inject: [DRIVER_REPOSITORY_TOKEN],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: COMPLETE_DRIVER_ONBOARDING_USE_CASE_TOKEN,
|
provide: COMPLETE_DRIVER_ONBOARDING_USE_CASE_TOKEN,
|
||||||
useFactory: (driverRepo: IDriverRepository, logger: Logger, presenter: CompleteOnboardingPresenter) => new CompleteDriverOnboardingUseCase(driverRepo, logger, presenter),
|
useFactory: (driverRepo: IDriverRepository, logger: Logger) => new CompleteDriverOnboardingUseCase(driverRepo, logger),
|
||||||
inject: [DRIVER_REPOSITORY_TOKEN, LOGGER_TOKEN, CompleteOnboardingPresenter.name],
|
inject: [DRIVER_REPOSITORY_TOKEN, LOGGER_TOKEN],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: IS_DRIVER_REGISTERED_FOR_RACE_USE_CASE_TOKEN,
|
provide: IS_DRIVER_REGISTERED_FOR_RACE_USE_CASE_TOKEN,
|
||||||
useFactory: (registrationRepo: IRaceRegistrationRepository, logger: Logger, presenter: DriverRegistrationStatusPresenter) =>
|
useFactory: (registrationRepo: IRaceRegistrationRepository, logger: Logger) =>
|
||||||
new IsDriverRegisteredForRaceUseCase(registrationRepo, logger, presenter),
|
new IsDriverRegisteredForRaceUseCase(registrationRepo, logger),
|
||||||
inject: [RACE_REGISTRATION_REPOSITORY_TOKEN, LOGGER_TOKEN, DriverRegistrationStatusPresenter.name],
|
inject: [RACE_REGISTRATION_REPOSITORY_TOKEN, LOGGER_TOKEN],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: UPDATE_DRIVER_PROFILE_USE_CASE_TOKEN,
|
provide: UPDATE_DRIVER_PROFILE_USE_CASE_TOKEN,
|
||||||
useFactory: (driverRepo: IDriverRepository, presenter: DriverPresenter, logger: Logger) => new UpdateDriverProfileUseCase(driverRepo, presenter, logger),
|
useFactory: (driverRepo: IDriverRepository, logger: Logger) => new UpdateDriverProfileUseCase(driverRepo, logger),
|
||||||
inject: [DRIVER_REPOSITORY_TOKEN, DriverPresenter.name, LOGGER_TOKEN],
|
inject: [DRIVER_REPOSITORY_TOKEN, LOGGER_TOKEN],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: GET_PROFILE_OVERVIEW_USE_CASE_TOKEN,
|
provide: GET_PROFILE_OVERVIEW_USE_CASE_TOKEN,
|
||||||
@@ -181,14 +163,13 @@ export const DriverProviders: Provider[] = [
|
|||||||
driverExtendedProfileProvider: DriverExtendedProfileProvider,
|
driverExtendedProfileProvider: DriverExtendedProfileProvider,
|
||||||
driverStatsService: IDriverStatsService,
|
driverStatsService: IDriverStatsService,
|
||||||
rankingService: IRankingService,
|
rankingService: IRankingService,
|
||||||
presenter: DriverProfilePresenter,
|
|
||||||
) =>
|
) =>
|
||||||
new GetProfileOverviewUseCase(
|
new GetProfileOverviewUseCase(
|
||||||
driverRepo,
|
driverRepo,
|
||||||
teamRepository,
|
teamRepository,
|
||||||
teamMembershipRepository,
|
teamMembershipRepository,
|
||||||
socialRepository,
|
socialRepository,
|
||||||
imageService,
|
(driverId: string) => Promise.resolve(imageService.getDriverAvatar(driverId)),
|
||||||
driverExtendedProfileProvider,
|
driverExtendedProfileProvider,
|
||||||
(driverId: string) => {
|
(driverId: string) => {
|
||||||
const stats = driverStatsService.getDriverStats(driverId);
|
const stats = driverStatsService.getDriverStats(driverId);
|
||||||
@@ -216,7 +197,6 @@ export const DriverProviders: Provider[] = [
|
|||||||
rating: ranking.rating,
|
rating: ranking.rating,
|
||||||
overallRank: ranking.overallRank,
|
overallRank: ranking.overallRank,
|
||||||
})),
|
})),
|
||||||
presenter,
|
|
||||||
),
|
),
|
||||||
inject: [
|
inject: [
|
||||||
DRIVER_REPOSITORY_TOKEN,
|
DRIVER_REPOSITORY_TOKEN,
|
||||||
@@ -227,7 +207,6 @@ export const DriverProviders: Provider[] = [
|
|||||||
DRIVER_EXTENDED_PROFILE_PROVIDER_TOKEN,
|
DRIVER_EXTENDED_PROFILE_PROVIDER_TOKEN,
|
||||||
DRIVER_STATS_SERVICE_TOKEN,
|
DRIVER_STATS_SERVICE_TOKEN,
|
||||||
RANKING_SERVICE_TOKEN,
|
RANKING_SERVICE_TOKEN,
|
||||||
DriverProfilePresenter.name,
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,16 +1,13 @@
|
|||||||
|
import { CompleteDriverOnboardingUseCase } from '@core/racing/application/use-cases/CompleteDriverOnboardingUseCase';
|
||||||
|
import type { Driver } from '@core/racing/domain/entities/Driver';
|
||||||
|
import { GetDriversLeaderboardUseCase, type GetDriversLeaderboardResult } from '@core/racing/application/use-cases/GetDriversLeaderboardUseCase';
|
||||||
|
import { GetTotalDriversUseCase } from '@core/racing/application/use-cases/GetTotalDriversUseCase';
|
||||||
|
import { IsDriverRegisteredForRaceUseCase } from '@core/racing/application/use-cases/IsDriverRegisteredForRaceUseCase';
|
||||||
|
import type { Logger } from '@core/shared/application';
|
||||||
|
import { Result } from '@core/shared/application/Result';
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { vi } from 'vitest';
|
import { vi } from 'vitest';
|
||||||
import { DriverService } from './DriverService';
|
import { DriverService } from './DriverService';
|
||||||
import { GetDriversLeaderboardUseCase } from '@core/racing/application/use-cases/GetDriversLeaderboardUseCase';
|
|
||||||
import { GetTotalDriversUseCase } from '@core/racing/application/use-cases/GetTotalDriversUseCase';
|
|
||||||
import { CompleteDriverOnboardingUseCase } from '@core/racing/application/use-cases/CompleteDriverOnboardingUseCase';
|
|
||||||
import { IsDriverRegisteredForRaceUseCase } from '@core/racing/application/use-cases/IsDriverRegisteredForRaceUseCase';
|
|
||||||
import { UpdateDriverProfileUseCase } from '@core/racing/application/use-cases/UpdateDriverProfileUseCase';
|
|
||||||
import type { Logger } from '@core/shared/application';
|
|
||||||
import type { IDriverRepository } from '@core/racing/domain/repositories/IDriverRepository';
|
|
||||||
import { Result } from '@core/shared/application/Result';
|
|
||||||
import type { CompleteDriverOnboardingOutputPort } from '@core/racing/application/ports/output/CompleteDriverOnboardingOutputPort';
|
|
||||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
|
||||||
|
|
||||||
describe('DriverService', () => {
|
describe('DriverService', () => {
|
||||||
let service: DriverService;
|
let service: DriverService;
|
||||||
@@ -18,10 +15,6 @@ describe('DriverService', () => {
|
|||||||
let getTotalDriversUseCase: ReturnType<typeof vi.mocked<GetTotalDriversUseCase>>;
|
let getTotalDriversUseCase: ReturnType<typeof vi.mocked<GetTotalDriversUseCase>>;
|
||||||
let completeDriverOnboardingUseCase: ReturnType<typeof vi.mocked<CompleteDriverOnboardingUseCase>>;
|
let completeDriverOnboardingUseCase: ReturnType<typeof vi.mocked<CompleteDriverOnboardingUseCase>>;
|
||||||
let isDriverRegisteredForRaceUseCase: ReturnType<typeof vi.mocked<IsDriverRegisteredForRaceUseCase>>;
|
let isDriverRegisteredForRaceUseCase: ReturnType<typeof vi.mocked<IsDriverRegisteredForRaceUseCase>>;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
let updateDriverProfileUseCase: ReturnType<typeof vi.mocked<UpdateDriverProfileUseCase>>;
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
let driverRepository: ReturnType<typeof vi.mocked<IDriverRepository>>;
|
|
||||||
let logger: ReturnType<typeof vi.mocked<Logger>>;
|
let logger: ReturnType<typeof vi.mocked<Logger>>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
@@ -58,6 +51,12 @@ describe('DriverService', () => {
|
|||||||
execute: vi.fn(),
|
execute: vi.fn(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
provide: 'GetProfileOverviewUseCase',
|
||||||
|
useValue: {
|
||||||
|
execute: vi.fn(),
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
provide: 'IDriverRepository',
|
provide: 'IDriverRepository',
|
||||||
useValue: {
|
useValue: {
|
||||||
@@ -79,8 +78,6 @@ describe('DriverService', () => {
|
|||||||
getTotalDriversUseCase = vi.mocked(module.get('GetTotalDriversUseCase'));
|
getTotalDriversUseCase = vi.mocked(module.get('GetTotalDriversUseCase'));
|
||||||
completeDriverOnboardingUseCase = vi.mocked(module.get('CompleteDriverOnboardingUseCase'));
|
completeDriverOnboardingUseCase = vi.mocked(module.get('CompleteDriverOnboardingUseCase'));
|
||||||
isDriverRegisteredForRaceUseCase = vi.mocked(module.get('IsDriverRegisteredForRaceUseCase'));
|
isDriverRegisteredForRaceUseCase = vi.mocked(module.get('IsDriverRegisteredForRaceUseCase'));
|
||||||
updateDriverProfileUseCase = vi.mocked(module.get('UpdateDriverProfileUseCase'));
|
|
||||||
driverRepository = vi.mocked(module.get('IDriverRepository'));
|
|
||||||
logger = vi.mocked(module.get('Logger'));
|
logger = vi.mocked(module.get('Logger'));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -107,11 +104,27 @@ describe('DriverService', () => {
|
|||||||
activeCount: 1,
|
activeCount: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
getDriversLeaderboardUseCase.execute.mockResolvedValue(Result.ok(mockViewModel));
|
const businessResult = {
|
||||||
|
items: mockViewModel.drivers.map(dto => ({
|
||||||
|
driver: { id: dto.id, name: dto.name, country: dto.nationality },
|
||||||
|
rating: dto.rating,
|
||||||
|
skillLevel: dto.skillLevel,
|
||||||
|
racesCompleted: dto.racesCompleted,
|
||||||
|
wins: dto.wins,
|
||||||
|
podiums: dto.podiums,
|
||||||
|
isActive: dto.isActive,
|
||||||
|
rank: dto.rank,
|
||||||
|
avatarUrl: dto.avatarUrl,
|
||||||
|
})),
|
||||||
|
totalRaces: mockViewModel.totalRaces,
|
||||||
|
totalWins: mockViewModel.totalWins,
|
||||||
|
activeCount: mockViewModel.activeCount,
|
||||||
|
};
|
||||||
|
getDriversLeaderboardUseCase.execute.mockResolvedValue(Result.ok(businessResult as unknown as GetDriversLeaderboardResult));
|
||||||
|
|
||||||
const result = await service.getDriversLeaderboard();
|
const result = await service.getDriversLeaderboard();
|
||||||
|
|
||||||
expect(getDriversLeaderboardUseCase.execute).toHaveBeenCalledWith();
|
expect(getDriversLeaderboardUseCase.execute).toHaveBeenCalledWith({});
|
||||||
expect(logger.debug).toHaveBeenCalledWith('[DriverService] Fetching drivers leaderboard.');
|
expect(logger.debug).toHaveBeenCalledWith('[DriverService] Fetching drivers leaderboard.');
|
||||||
expect(result).toEqual(mockViewModel);
|
expect(result).toEqual(mockViewModel);
|
||||||
});
|
});
|
||||||
@@ -125,7 +138,7 @@ describe('DriverService', () => {
|
|||||||
|
|
||||||
const result = await service.getTotalDrivers();
|
const result = await service.getTotalDrivers();
|
||||||
|
|
||||||
expect(getTotalDriversUseCase.execute).toHaveBeenCalledWith();
|
expect(getTotalDriversUseCase.execute).toHaveBeenCalledWith({});
|
||||||
expect(logger.debug).toHaveBeenCalledWith('[DriverService] Fetching total drivers count.');
|
expect(logger.debug).toHaveBeenCalledWith('[DriverService] Fetching total drivers count.');
|
||||||
expect(result).toEqual(mockOutput);
|
expect(result).toEqual(mockOutput);
|
||||||
});
|
});
|
||||||
@@ -138,12 +151,11 @@ describe('DriverService', () => {
|
|||||||
lastName: 'Doe',
|
lastName: 'Doe',
|
||||||
displayName: 'John Doe',
|
displayName: 'John Doe',
|
||||||
country: 'US',
|
country: 'US',
|
||||||
timezone: 'America/New_York',
|
|
||||||
bio: 'Racing enthusiast',
|
bio: 'Racing enthusiast',
|
||||||
};
|
};
|
||||||
|
|
||||||
completeDriverOnboardingUseCase.execute.mockResolvedValue(
|
completeDriverOnboardingUseCase.execute.mockResolvedValue(
|
||||||
Result.ok<CompleteDriverOnboardingOutputPort, ApplicationErrorCode<string>>({ driverId: 'user-123' })
|
Result.ok({ driver: { id: 'user-123' } as Driver })
|
||||||
);
|
);
|
||||||
|
|
||||||
const result = await service.completeOnboarding('user-123', input);
|
const result = await service.completeOnboarding('user-123', input);
|
||||||
@@ -165,12 +177,11 @@ describe('DriverService', () => {
|
|||||||
lastName: 'Doe',
|
lastName: 'Doe',
|
||||||
displayName: 'John Doe',
|
displayName: 'John Doe',
|
||||||
country: 'US',
|
country: 'US',
|
||||||
timezone: 'America/New_York',
|
|
||||||
bio: 'Racing enthusiast',
|
bio: 'Racing enthusiast',
|
||||||
};
|
};
|
||||||
|
|
||||||
completeDriverOnboardingUseCase.execute.mockResolvedValue(
|
completeDriverOnboardingUseCase.execute.mockResolvedValue(
|
||||||
Result.err<CompleteDriverOnboardingOutputPort, ApplicationErrorCode<string>>({ code: 'DRIVER_ALREADY_EXISTS' })
|
Result.err({ code: 'DRIVER_ALREADY_EXISTS', details: { message: 'Driver already exists' } })
|
||||||
);
|
);
|
||||||
|
|
||||||
const result = await service.completeOnboarding('user-123', input);
|
const result = await service.completeOnboarding('user-123', input);
|
||||||
|
|||||||
@@ -1,45 +1,54 @@
|
|||||||
import { Injectable, Inject } from '@nestjs/common';
|
import { Result } from '@core/shared/application/Result';
|
||||||
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
|
import type { Driver } from '@core/racing/domain/entities/Driver';
|
||||||
import { CompleteOnboardingInputDTO } from './dtos/CompleteOnboardingInputDTO';
|
import { CompleteOnboardingInputDTO } from './dtos/CompleteOnboardingInputDTO';
|
||||||
import { GetDriverRegistrationStatusQueryDTO } from './dtos/GetDriverRegistrationStatusQueryDTO';
|
|
||||||
import { DriversLeaderboardDTO } from './dtos/DriversLeaderboardDTO';
|
|
||||||
import { DriverStatsDTO } from './dtos/DriverStatsDTO';
|
|
||||||
import { CompleteOnboardingOutputDTO } from './dtos/CompleteOnboardingOutputDTO';
|
import { CompleteOnboardingOutputDTO } from './dtos/CompleteOnboardingOutputDTO';
|
||||||
import { DriverRegistrationStatusDTO } from './dtos/DriverRegistrationStatusDTO';
|
import { DriverRegistrationStatusDTO } from './dtos/DriverRegistrationStatusDTO';
|
||||||
|
import { DriversLeaderboardDTO } from './dtos/DriversLeaderboardDTO';
|
||||||
|
import { DriverStatsDTO } from './dtos/DriverStatsDTO';
|
||||||
import { GetDriverOutputDTO } from './dtos/GetDriverOutputDTO';
|
import { GetDriverOutputDTO } from './dtos/GetDriverOutputDTO';
|
||||||
import { GetDriverProfileOutputDTO } from './dtos/GetDriverProfileOutputDTO';
|
import { GetDriverProfileOutputDTO } from './dtos/GetDriverProfileOutputDTO';
|
||||||
|
import { GetDriverRegistrationStatusQueryDTO } from './dtos/GetDriverRegistrationStatusQueryDTO';
|
||||||
|
|
||||||
// Use cases
|
// Use cases
|
||||||
import { GetDriversLeaderboardUseCase } from '@core/racing/application/use-cases/GetDriversLeaderboardUseCase';
|
|
||||||
import { GetTotalDriversUseCase } from '@core/racing/application/use-cases/GetTotalDriversUseCase';
|
|
||||||
import { CompleteDriverOnboardingUseCase } from '@core/racing/application/use-cases/CompleteDriverOnboardingUseCase';
|
import { CompleteDriverOnboardingUseCase } from '@core/racing/application/use-cases/CompleteDriverOnboardingUseCase';
|
||||||
import { IsDriverRegisteredForRaceUseCase } from '@core/racing/application/use-cases/IsDriverRegisteredForRaceUseCase';
|
import { GetDriversLeaderboardUseCase } from '@core/racing/application/use-cases/GetDriversLeaderboardUseCase';
|
||||||
import { GetProfileOverviewUseCase } from '@core/racing/application/use-cases/GetProfileOverviewUseCase';
|
import { GetProfileOverviewUseCase } from '@core/racing/application/use-cases/GetProfileOverviewUseCase';
|
||||||
|
import { GetTotalDriversUseCase } from '@core/racing/application/use-cases/GetTotalDriversUseCase';
|
||||||
|
import { IsDriverRegisteredForRaceUseCase } from '@core/racing/application/use-cases/IsDriverRegisteredForRaceUseCase';
|
||||||
import { UpdateDriverProfileUseCase, type UpdateDriverProfileInput } from '@core/racing/application/use-cases/UpdateDriverProfileUseCase';
|
import { UpdateDriverProfileUseCase, type UpdateDriverProfileInput } from '@core/racing/application/use-cases/UpdateDriverProfileUseCase';
|
||||||
|
|
||||||
// Presenters
|
// Presenters
|
||||||
import { DriverStatsPresenter } from './presenters/DriverStatsPresenter';
|
|
||||||
import { DriversLeaderboardPresenter } from './presenters/DriversLeaderboardPresenter';
|
|
||||||
import { CompleteOnboardingPresenter } from './presenters/CompleteOnboardingPresenter';
|
import { CompleteOnboardingPresenter } from './presenters/CompleteOnboardingPresenter';
|
||||||
import { DriverRegistrationStatusPresenter } from './presenters/DriverRegistrationStatusPresenter';
|
|
||||||
import { DriverPresenter } from './presenters/DriverPresenter';
|
import { DriverPresenter } from './presenters/DriverPresenter';
|
||||||
import { DriverProfilePresenter } from './presenters/DriverProfilePresenter';
|
import { DriverProfilePresenter } from './presenters/DriverProfilePresenter';
|
||||||
|
import { DriverRegistrationStatusPresenter } from './presenters/DriverRegistrationStatusPresenter';
|
||||||
|
import { DriversLeaderboardPresenter } from './presenters/DriversLeaderboardPresenter';
|
||||||
|
import { DriverStatsPresenter } from './presenters/DriverStatsPresenter';
|
||||||
|
|
||||||
// Tokens
|
// Tokens
|
||||||
import {
|
import type { IDriverRepository } from '@core/racing/domain/repositories/IDriverRepository';
|
||||||
GET_DRIVERS_LEADERBOARD_USE_CASE_TOKEN,
|
|
||||||
GET_TOTAL_DRIVERS_USE_CASE_TOKEN,
|
|
||||||
COMPLETE_DRIVER_ONBOARDING_USE_CASE_TOKEN,
|
|
||||||
IS_DRIVER_REGISTERED_FOR_RACE_USE_CASE_TOKEN,
|
|
||||||
UPDATE_DRIVER_PROFILE_USE_CASE_TOKEN,
|
|
||||||
GET_PROFILE_OVERVIEW_USE_CASE_TOKEN,
|
|
||||||
LOGGER_TOKEN,
|
|
||||||
DRIVER_REPOSITORY_TOKEN,
|
|
||||||
} from './DriverProviders';
|
|
||||||
import type { Logger } from '@core/shared/application';
|
import type { Logger } from '@core/shared/application';
|
||||||
import { IDriverRepository } from '@core/racing/domain/repositories/IDriverRepository';
|
import {
|
||||||
|
COMPLETE_DRIVER_ONBOARDING_USE_CASE_TOKEN,
|
||||||
|
DRIVER_REPOSITORY_TOKEN,
|
||||||
|
GET_DRIVERS_LEADERBOARD_USE_CASE_TOKEN,
|
||||||
|
GET_PROFILE_OVERVIEW_USE_CASE_TOKEN,
|
||||||
|
GET_TOTAL_DRIVERS_USE_CASE_TOKEN,
|
||||||
|
IS_DRIVER_REGISTERED_FOR_RACE_USE_CASE_TOKEN,
|
||||||
|
LOGGER_TOKEN,
|
||||||
|
UPDATE_DRIVER_PROFILE_USE_CASE_TOKEN,
|
||||||
|
} from './DriverProviders';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class DriverService {
|
export class DriverService {
|
||||||
|
private readonly driversLeaderboardPresenter = new DriversLeaderboardPresenter();
|
||||||
|
private readonly driverStatsPresenter = new DriverStatsPresenter();
|
||||||
|
private readonly completeOnboardingPresenter = new CompleteOnboardingPresenter();
|
||||||
|
private readonly driverRegistrationStatusPresenter = new DriverRegistrationStatusPresenter();
|
||||||
|
private readonly driverPresenter = new DriverPresenter();
|
||||||
|
private readonly driverProfilePresenter = new DriverProfilePresenter();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(GET_DRIVERS_LEADERBOARD_USE_CASE_TOKEN)
|
@Inject(GET_DRIVERS_LEADERBOARD_USE_CASE_TOKEN)
|
||||||
private readonly getDriversLeaderboardUseCase: GetDriversLeaderboardUseCase,
|
private readonly getDriversLeaderboardUseCase: GetDriversLeaderboardUseCase,
|
||||||
@@ -54,15 +63,9 @@ export class DriverService {
|
|||||||
@Inject(GET_PROFILE_OVERVIEW_USE_CASE_TOKEN)
|
@Inject(GET_PROFILE_OVERVIEW_USE_CASE_TOKEN)
|
||||||
private readonly getProfileOverviewUseCase: GetProfileOverviewUseCase,
|
private readonly getProfileOverviewUseCase: GetProfileOverviewUseCase,
|
||||||
@Inject(DRIVER_REPOSITORY_TOKEN)
|
@Inject(DRIVER_REPOSITORY_TOKEN)
|
||||||
private readonly driverRepository: IDriverRepository,
|
private readonly driverRepository: IDriverRepository, // TODO must be removed from service
|
||||||
@Inject(LOGGER_TOKEN)
|
@Inject(LOGGER_TOKEN)
|
||||||
private readonly logger: Logger,
|
private readonly logger: Logger,
|
||||||
private readonly driversLeaderboardPresenter: DriversLeaderboardPresenter,
|
|
||||||
private readonly driverStatsPresenter: DriverStatsPresenter,
|
|
||||||
private readonly completeOnboardingPresenter: CompleteOnboardingPresenter,
|
|
||||||
private readonly driverRegistrationStatusPresenter: DriverRegistrationStatusPresenter,
|
|
||||||
private readonly driverPresenter: DriverPresenter,
|
|
||||||
private readonly driverProfilePresenter: DriverProfilePresenter,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async getDriversLeaderboard(): Promise<DriversLeaderboardDTO> {
|
async getDriversLeaderboard(): Promise<DriversLeaderboardDTO> {
|
||||||
@@ -70,11 +73,8 @@ export class DriverService {
|
|||||||
|
|
||||||
const result = await this.getDriversLeaderboardUseCase.execute({});
|
const result = await this.getDriversLeaderboardUseCase.execute({});
|
||||||
|
|
||||||
if (result.isErr()) {
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const error = result.unwrapErr();
|
this.driversLeaderboardPresenter.present(result as Result<any, any>);
|
||||||
throw new Error(error.details?.message ?? 'Failed to load drivers leaderboard');
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.driversLeaderboardPresenter.getResponseModel();
|
return this.driversLeaderboardPresenter.getResponseModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,6 +88,7 @@ export class DriverService {
|
|||||||
throw new Error(error.details?.message ?? 'Failed to load driver stats');
|
throw new Error(error.details?.message ?? 'Failed to load driver stats');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.driverStatsPresenter.present(result.unwrap());
|
||||||
return this.driverStatsPresenter.getResponseModel();
|
return this.driverStatsPresenter.getResponseModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,11 +107,7 @@ export class DriverService {
|
|||||||
...(input.bio !== undefined ? { bio: input.bio } : {}),
|
...(input.bio !== undefined ? { bio: input.bio } : {}),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result.isErr()) {
|
this.completeOnboardingPresenter.present(result);
|
||||||
const error = result.unwrapErr();
|
|
||||||
throw new Error(error.details?.message ?? 'Failed to complete onboarding');
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.completeOnboardingPresenter.getResponseModel();
|
return this.completeOnboardingPresenter.getResponseModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,15 +126,17 @@ export class DriverService {
|
|||||||
throw new Error(error.details?.message ?? 'Failed to check registration status');
|
throw new Error(error.details?.message ?? 'Failed to check registration status');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.driverRegistrationStatusPresenter.present(result.unwrap());
|
||||||
return this.driverRegistrationStatusPresenter.getResponseModel();
|
return this.driverRegistrationStatusPresenter.getResponseModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
async getCurrentDriver(userId: string): Promise<GetDriverOutputDTO | null> {
|
async getCurrentDriver(userId: string): Promise<GetDriverOutputDTO | null> {
|
||||||
this.logger.debug(`[DriverService] Fetching current driver for userId: ${userId}`);
|
this.logger.debug(`[DriverService] Fetching current driver for userId: ${userId}`);
|
||||||
|
|
||||||
const driver = await this.driverRepository.findById(userId);
|
const result = Result.ok(await this.driverRepository.findById(userId));
|
||||||
|
|
||||||
this.driverPresenter.present(driver ?? null);
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
this.driverPresenter.present(result as Result<Driver | null, any>);
|
||||||
|
|
||||||
return this.driverPresenter.getResponseModel();
|
return this.driverPresenter.getResponseModel();
|
||||||
}
|
}
|
||||||
@@ -157,12 +156,11 @@ export class DriverService {
|
|||||||
|
|
||||||
if (result.isErr()) {
|
if (result.isErr()) {
|
||||||
this.logger.error(`Failed to update driver profile: ${result.unwrapErr().code}`);
|
this.logger.error(`Failed to update driver profile: ${result.unwrapErr().code}`);
|
||||||
this.driverPresenter.present(null);
|
this.driverPresenter.present(Result.ok(null));
|
||||||
return this.driverPresenter.getResponseModel();
|
return this.driverPresenter.getResponseModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
const updatedDriver = await this.driverRepository.findById(driverId);
|
this.driverPresenter.present(Result.ok(result.unwrap()));
|
||||||
this.driverPresenter.present(updatedDriver ?? null);
|
|
||||||
return this.driverPresenter.getResponseModel();
|
return this.driverPresenter.getResponseModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,7 +169,7 @@ export class DriverService {
|
|||||||
|
|
||||||
const driver = await this.driverRepository.findById(driverId);
|
const driver = await this.driverRepository.findById(driverId);
|
||||||
|
|
||||||
this.driverPresenter.present(driver ?? null);
|
this.driverPresenter.present(Result.ok(driver));
|
||||||
|
|
||||||
return this.driverPresenter.getResponseModel();
|
return this.driverPresenter.getResponseModel();
|
||||||
}
|
}
|
||||||
@@ -186,6 +184,7 @@ export class DriverService {
|
|||||||
throw new Error(error.details?.message ?? 'Failed to load driver profile');
|
throw new Error(error.details?.message ?? 'Failed to load driver profile');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.driverProfilePresenter.present(result.unwrap());
|
||||||
return this.driverProfilePresenter.getResponseModel();
|
return this.driverProfilePresenter.getResponseModel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,22 +5,22 @@ export class CompleteOnboardingInputDTO {
|
|||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
firstName: string;
|
firstName!: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
lastName: string;
|
lastName!: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
displayName: string;
|
displayName!: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
country: string;
|
country!: string;
|
||||||
|
|
||||||
@ApiProperty({ required: false })
|
@ApiProperty({ required: false })
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { IsBoolean, IsString } from 'class-validator';
|
|||||||
export class CompleteOnboardingOutputDTO {
|
export class CompleteOnboardingOutputDTO {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
@IsBoolean()
|
@IsBoolean()
|
||||||
success: boolean;
|
success!: boolean;
|
||||||
|
|
||||||
@ApiProperty({ required: false })
|
@ApiProperty({ required: false })
|
||||||
@IsString()
|
@IsString()
|
||||||
|
|||||||
@@ -2,20 +2,20 @@ import { ApiProperty } from '@nestjs/swagger';
|
|||||||
|
|
||||||
export class DriverDTO {
|
export class DriverDTO {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
id: string;
|
id!: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
iracingId: string;
|
iracingId!: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
name: string;
|
name!: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
country: string;
|
country!: string;
|
||||||
|
|
||||||
@ApiProperty({ required: false })
|
@ApiProperty({ required: false })
|
||||||
bio?: string;
|
bio?: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
joinedAt: string;
|
joinedAt!: string;
|
||||||
}
|
}
|
||||||
@@ -2,34 +2,34 @@ import { ApiProperty } from '@nestjs/swagger';
|
|||||||
|
|
||||||
export class DriverLeaderboardItemDTO {
|
export class DriverLeaderboardItemDTO {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
id: string;
|
id!: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
name: string;
|
name!: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
rating: number;
|
rating!: number;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
skillLevel: string; // Assuming skillLevel is a string like 'Rookie', 'Pro', etc.
|
skillLevel!: string; // Assuming skillLevel is a string like 'Rookie', 'Pro', etc.
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
nationality: string;
|
nationality!: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
racesCompleted: number;
|
racesCompleted!: number;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
wins: number;
|
wins!: number;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
podiums: number;
|
podiums!: number;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
isActive: boolean;
|
isActive!: boolean;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
rank: number;
|
rank!: number;
|
||||||
|
|
||||||
@ApiProperty({ nullable: true })
|
@ApiProperty({ nullable: true })
|
||||||
avatarUrl?: string;
|
avatarUrl?: string;
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ import { ApiProperty } from '@nestjs/swagger';
|
|||||||
|
|
||||||
export class DriverStatsDTO {
|
export class DriverStatsDTO {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
totalDrivers: number;
|
totalDrivers!: number;
|
||||||
}
|
}
|
||||||
@@ -3,14 +3,14 @@ import { DriverLeaderboardItemDTO } from './DriverLeaderboardItemDTO';
|
|||||||
|
|
||||||
export class DriversLeaderboardDTO {
|
export class DriversLeaderboardDTO {
|
||||||
@ApiProperty({ type: [DriverLeaderboardItemDTO] })
|
@ApiProperty({ type: [DriverLeaderboardItemDTO] })
|
||||||
drivers: DriverLeaderboardItemDTO[];
|
drivers!: DriverLeaderboardItemDTO[];
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
totalRaces: number;
|
totalRaces!: number;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
totalWins: number;
|
totalWins!: number;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
activeCount: number;
|
activeCount!: number;
|
||||||
}
|
}
|
||||||
@@ -2,20 +2,20 @@ import { ApiProperty } from '@nestjs/swagger';
|
|||||||
|
|
||||||
export class GetDriverOutputDTO {
|
export class GetDriverOutputDTO {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
id: string;
|
id!: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
iracingId: string;
|
iracingId!: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
name: string;
|
name!: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
country: string;
|
country!: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
bio?: string;
|
bio?: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
joinedAt: string;
|
joinedAt!: string;
|
||||||
}
|
}
|
||||||
@@ -2,81 +2,81 @@ import { ApiProperty } from '@nestjs/swagger';
|
|||||||
|
|
||||||
export class DriverProfileDriverSummaryDTO {
|
export class DriverProfileDriverSummaryDTO {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
id: string;
|
id!: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
name: string;
|
name!: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
country: string;
|
country!: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
avatarUrl: string;
|
avatarUrl!: string;
|
||||||
|
|
||||||
@ApiProperty({ nullable: true })
|
@ApiProperty({ nullable: true })
|
||||||
iracingId: string | null;
|
iracingId!: string | null;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
joinedAt: string;
|
joinedAt!: string;
|
||||||
|
|
||||||
@ApiProperty({ nullable: true })
|
@ApiProperty({ nullable: true })
|
||||||
rating: number | null;
|
rating!: number | null;
|
||||||
|
|
||||||
@ApiProperty({ nullable: true })
|
@ApiProperty({ nullable: true })
|
||||||
globalRank: number | null;
|
globalRank!: number | null;
|
||||||
|
|
||||||
@ApiProperty({ nullable: true })
|
@ApiProperty({ nullable: true })
|
||||||
consistency: number | null;
|
consistency!: number | null;
|
||||||
|
|
||||||
@ApiProperty({ nullable: true })
|
@ApiProperty({ nullable: true })
|
||||||
bio: string | null;
|
bio!: string | null;
|
||||||
|
|
||||||
@ApiProperty({ nullable: true })
|
@ApiProperty({ nullable: true })
|
||||||
totalDrivers: number | null;
|
totalDrivers!: number | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DriverProfileStatsDTO {
|
export class DriverProfileStatsDTO {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
totalRaces: number;
|
totalRaces!: number;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
wins: number;
|
wins!: number;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
podiums: number;
|
podiums!: number;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
dnfs: number;
|
dnfs!: number;
|
||||||
|
|
||||||
@ApiProperty({ nullable: true })
|
@ApiProperty({ nullable: true })
|
||||||
avgFinish: number | null;
|
avgFinish!: number | null;
|
||||||
|
|
||||||
@ApiProperty({ nullable: true })
|
@ApiProperty({ nullable: true })
|
||||||
bestFinish: number | null;
|
bestFinish!: number | null;
|
||||||
|
|
||||||
@ApiProperty({ nullable: true })
|
@ApiProperty({ nullable: true })
|
||||||
worstFinish: number | null;
|
worstFinish!: number | null;
|
||||||
|
|
||||||
@ApiProperty({ nullable: true })
|
@ApiProperty({ nullable: true })
|
||||||
finishRate: number | null;
|
finishRate!: number | null;
|
||||||
|
|
||||||
@ApiProperty({ nullable: true })
|
@ApiProperty({ nullable: true })
|
||||||
winRate: number | null;
|
winRate!: number | null;
|
||||||
|
|
||||||
@ApiProperty({ nullable: true })
|
@ApiProperty({ nullable: true })
|
||||||
podiumRate: number | null;
|
podiumRate!: number | null;
|
||||||
|
|
||||||
@ApiProperty({ nullable: true })
|
@ApiProperty({ nullable: true })
|
||||||
percentile: number | null;
|
percentile!: number | null;
|
||||||
|
|
||||||
@ApiProperty({ nullable: true })
|
@ApiProperty({ nullable: true })
|
||||||
rating: number | null;
|
rating!: number | null;
|
||||||
|
|
||||||
@ApiProperty({ nullable: true })
|
@ApiProperty({ nullable: true })
|
||||||
consistency: number | null;
|
consistency!: number | null;
|
||||||
|
|
||||||
@ApiProperty({ nullable: true })
|
@ApiProperty({ nullable: true })
|
||||||
overallRank: number | null;
|
overallRank!: number | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DriverProfileFinishDistributionDTO {
|
export class DriverProfileFinishDistributionDTO {
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import { IsString } from 'class-validator';
|
|||||||
export class GetDriverRegistrationStatusQueryDTO {
|
export class GetDriverRegistrationStatusQueryDTO {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
@IsString()
|
@IsString()
|
||||||
raceId: string;
|
raceId!: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
@IsString()
|
@IsString()
|
||||||
driverId: string;
|
driverId!: string;
|
||||||
}
|
}
|
||||||
@@ -1,18 +1,20 @@
|
|||||||
import type {
|
import { Result } from '@core/shared/application/Result';
|
||||||
CompleteDriverOnboardingResult,
|
|
||||||
} from '@core/racing/application/use-cases/CompleteDriverOnboardingUseCase';
|
|
||||||
import type { CompleteOnboardingOutputDTO } from '../dtos/CompleteOnboardingOutputDTO';
|
import type { CompleteOnboardingOutputDTO } from '../dtos/CompleteOnboardingOutputDTO';
|
||||||
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
|
|
||||||
|
|
||||||
export class CompleteOnboardingPresenter
|
export class CompleteOnboardingPresenter {
|
||||||
implements UseCaseOutputPort<CompleteDriverOnboardingResult>
|
|
||||||
{
|
|
||||||
private responseModel: CompleteOnboardingOutputDTO | null = null;
|
private responseModel: CompleteOnboardingOutputDTO | null = null;
|
||||||
|
|
||||||
present(result: CompleteDriverOnboardingResult): void {
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
present(result: Result<any, any>): void {
|
||||||
|
if (result.isErr()) {
|
||||||
|
const error = result.unwrapErr();
|
||||||
|
throw new Error(error.details?.message ?? 'Failed to complete onboarding');
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = result.unwrap();
|
||||||
this.responseModel = {
|
this.responseModel = {
|
||||||
success: true,
|
success: true,
|
||||||
driverId: result.driver.id,
|
driverId: data.driver.id,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,18 @@
|
|||||||
|
import { Result } from '@core/shared/application/Result';
|
||||||
import type { Driver } from '@core/racing/domain/entities/Driver';
|
import type { Driver } from '@core/racing/domain/entities/Driver';
|
||||||
import type { GetDriverOutputDTO } from '../dtos/GetDriverOutputDTO';
|
import type { GetDriverOutputDTO } from '../dtos/GetDriverOutputDTO';
|
||||||
|
|
||||||
export class DriverPresenter {
|
export class DriverPresenter {
|
||||||
private responseModel: GetDriverOutputDTO | null = null;
|
private responseModel: GetDriverOutputDTO | null = null;
|
||||||
|
|
||||||
present(driver: Driver | null): void {
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
present(result: Result<Driver | null, any>): void {
|
||||||
|
if (result.isErr()) {
|
||||||
|
const error = result.unwrapErr();
|
||||||
|
throw new Error(error.details?.message ?? 'Failed to get driver');
|
||||||
|
}
|
||||||
|
|
||||||
|
const driver = result.unwrap();
|
||||||
if (!driver) {
|
if (!driver) {
|
||||||
this.responseModel = null;
|
this.responseModel = null;
|
||||||
return;
|
return;
|
||||||
@@ -15,8 +23,8 @@ export class DriverPresenter {
|
|||||||
iracingId: driver.iracingId.toString(),
|
iracingId: driver.iracingId.toString(),
|
||||||
name: driver.name.toString(),
|
name: driver.name.toString(),
|
||||||
country: driver.country.toString(),
|
country: driver.country.toString(),
|
||||||
bio: driver.bio?.toString(),
|
|
||||||
joinedAt: driver.joinedAt.toDate().toISOString(),
|
joinedAt: driver.joinedAt.toDate().toISOString(),
|
||||||
|
...(driver.bio ? { bio: driver.bio.toString() } : {}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
import type {
|
import type {
|
||||||
GetProfileOverviewResult,
|
GetProfileOverviewResult,
|
||||||
} from '@core/racing/application/use-cases/GetProfileOverviewUseCase';
|
} from '@core/racing/application/use-cases/GetProfileOverviewUseCase';
|
||||||
import type { GetDriverProfileOutputDTO } from '../dtos/GetDriverProfileOutputDTO';
|
import type { GetDriverProfileOutputDTO, DriverProfileExtendedProfileDTO } from '../dtos/GetDriverProfileOutputDTO';
|
||||||
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
|
|
||||||
|
|
||||||
export class DriverProfilePresenter
|
export class DriverProfilePresenter
|
||||||
implements UseCaseOutputPort<GetProfileOverviewResult>
|
|
||||||
{
|
{
|
||||||
private responseModel: GetDriverProfileOutputDTO | null = null;
|
private responseModel: GetDriverProfileOutputDTO | null = null;
|
||||||
|
|
||||||
@@ -45,7 +43,7 @@ export class DriverProfilePresenter
|
|||||||
avatarUrl: '', // TODO: get avatar
|
avatarUrl: '', // TODO: get avatar
|
||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
extendedProfile: result.extendedProfile as any,
|
extendedProfile: result.extendedProfile as DriverProfileExtendedProfileDTO | null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +52,7 @@ export class DriverProfilePresenter
|
|||||||
return this.responseModel;
|
return this.responseModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getAvatarUrl(driverId: string): string | undefined {
|
private getAvatarUrl(_driverId: string): string | undefined {
|
||||||
// Avatar resolution is delegated to infrastructure; keep as-is for now.
|
// Avatar resolution is delegated to infrastructure; keep as-is for now.
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,8 @@ import type {
|
|||||||
IsDriverRegisteredForRaceResult,
|
IsDriverRegisteredForRaceResult,
|
||||||
} from '@core/racing/application/use-cases/IsDriverRegisteredForRaceUseCase';
|
} from '@core/racing/application/use-cases/IsDriverRegisteredForRaceUseCase';
|
||||||
import { DriverRegistrationStatusDTO } from '../dtos/DriverRegistrationStatusDTO';
|
import { DriverRegistrationStatusDTO } from '../dtos/DriverRegistrationStatusDTO';
|
||||||
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
|
|
||||||
|
|
||||||
export class DriverRegistrationStatusPresenter
|
export class DriverRegistrationStatusPresenter {
|
||||||
implements UseCaseOutputPort<IsDriverRegisteredForRaceResult>
|
|
||||||
{
|
|
||||||
private responseModel: DriverRegistrationStatusDTO | null = null;
|
private responseModel: DriverRegistrationStatusDTO | null = null;
|
||||||
|
|
||||||
reset(): void {
|
reset(): void {
|
||||||
|
|||||||
@@ -2,11 +2,8 @@ import { DriverStatsDTO } from '../dtos/DriverStatsDTO';
|
|||||||
import type {
|
import type {
|
||||||
GetTotalDriversResult,
|
GetTotalDriversResult,
|
||||||
} from '@core/racing/application/use-cases/GetTotalDriversUseCase';
|
} from '@core/racing/application/use-cases/GetTotalDriversUseCase';
|
||||||
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
|
|
||||||
|
|
||||||
export class DriverStatsPresenter
|
export class DriverStatsPresenter {
|
||||||
implements UseCaseOutputPort<GetTotalDriversResult>
|
|
||||||
{
|
|
||||||
private responseModel: DriverStatsDTO | null = null;
|
private responseModel: DriverStatsDTO | null = null;
|
||||||
|
|
||||||
present(result: GetTotalDriversResult): void {
|
present(result: GetTotalDriversResult): void {
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ describe('DriversLeaderboardPresenter', () => {
|
|||||||
{
|
{
|
||||||
driver: {
|
driver: {
|
||||||
id: 'driver-1',
|
id: 'driver-1',
|
||||||
name: 'Driver One' as any,
|
name: 'Driver One' as unknown,
|
||||||
country: 'US' as any,
|
country: 'US' as unknown,
|
||||||
} as any,
|
} as unknown,
|
||||||
rating: 2500,
|
rating: 2500,
|
||||||
skillLevel: 'advanced' as any,
|
skillLevel: 'advanced' as unknown,
|
||||||
racesCompleted: 50,
|
racesCompleted: 50,
|
||||||
wins: 10,
|
wins: 10,
|
||||||
podiums: 20,
|
podiums: 20,
|
||||||
@@ -34,11 +34,11 @@ describe('DriversLeaderboardPresenter', () => {
|
|||||||
{
|
{
|
||||||
driver: {
|
driver: {
|
||||||
id: 'driver-2',
|
id: 'driver-2',
|
||||||
name: 'Driver Two' as any,
|
name: 'Driver Two' as unknown,
|
||||||
country: 'DE' as any,
|
country: 'DE' as unknown,
|
||||||
} as any,
|
} as unknown,
|
||||||
rating: 2400,
|
rating: 2400,
|
||||||
skillLevel: 'intermediate' as any,
|
skillLevel: 'intermediate' as unknown,
|
||||||
racesCompleted: 40,
|
racesCompleted: 40,
|
||||||
wins: 5,
|
wins: 5,
|
||||||
podiums: 15,
|
podiums: 15,
|
||||||
|
|||||||
@@ -1,15 +1,23 @@
|
|||||||
import { DriversLeaderboardDTO } from '../dtos/DriversLeaderboardDTO';
|
import { DriversLeaderboardDTO } from '../dtos/DriversLeaderboardDTO';
|
||||||
|
import { Result } from '@core/shared/application/Result';
|
||||||
|
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||||
import type {
|
import type {
|
||||||
GetDriversLeaderboardResult,
|
GetDriversLeaderboardResult,
|
||||||
|
GetDriversLeaderboardErrorCode,
|
||||||
} from '@core/racing/application/use-cases/GetDriversLeaderboardUseCase';
|
} from '@core/racing/application/use-cases/GetDriversLeaderboardUseCase';
|
||||||
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
|
|
||||||
|
|
||||||
export class DriversLeaderboardPresenter implements UseCaseOutputPort<GetDriversLeaderboardResult> {
|
export class DriversLeaderboardPresenter {
|
||||||
private responseModel: DriversLeaderboardDTO | null = null;
|
private responseModel: DriversLeaderboardDTO | null = null;
|
||||||
|
|
||||||
present(result: GetDriversLeaderboardResult): void {
|
present(result: Result<GetDriversLeaderboardResult, ApplicationErrorCode<GetDriversLeaderboardErrorCode, { message: string }>>): void {
|
||||||
|
if (result.isErr()) {
|
||||||
|
const error = result.unwrapErr();
|
||||||
|
throw new Error(error.details?.message ?? 'Failed to get drivers leaderboard');
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = result.unwrap();
|
||||||
this.responseModel = {
|
this.responseModel = {
|
||||||
drivers: result.items.map(item => ({
|
drivers: data.items.map(item => ({
|
||||||
id: item.driver.id,
|
id: item.driver.id,
|
||||||
name: item.driver.name.toString(),
|
name: item.driver.name.toString(),
|
||||||
rating: item.rating,
|
rating: item.rating,
|
||||||
@@ -20,11 +28,11 @@ export class DriversLeaderboardPresenter implements UseCaseOutputPort<GetDrivers
|
|||||||
podiums: item.podiums,
|
podiums: item.podiums,
|
||||||
isActive: item.isActive,
|
isActive: item.isActive,
|
||||||
rank: item.rank,
|
rank: item.rank,
|
||||||
avatarUrl: item.avatarUrl,
|
...(item.avatarUrl !== undefined ? { avatarUrl: item.avatarUrl } : {}),
|
||||||
})),
|
})),
|
||||||
totalRaces: result.totalRaces,
|
totalRaces: data.totalRaces,
|
||||||
totalWins: result.totalWins,
|
totalWins: data.totalWins,
|
||||||
activeCount: result.activeCount,
|
activeCount: data.activeCount,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,49 +1,48 @@
|
|||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { ApproveJoinRequestInputDTO } from './dtos/ApproveJoinRequestInputDTO';
|
import { ApproveJoinRequestInputDTO } from './dtos/ApproveJoinRequestInputDTO';
|
||||||
|
import { ApproveLeagueJoinRequestDTO } from './dtos/ApproveLeagueJoinRequestDTO';
|
||||||
import { CreateLeagueInputDTO } from './dtos/CreateLeagueInputDTO';
|
import { CreateLeagueInputDTO } from './dtos/CreateLeagueInputDTO';
|
||||||
import { GetLeagueAdminConfigQueryDTO } from './dtos/GetLeagueAdminConfigQueryDTO';
|
import { GetLeagueAdminConfigQueryDTO } from './dtos/GetLeagueAdminConfigQueryDTO';
|
||||||
import { GetLeagueAdminPermissionsInputDTO } from './dtos/GetLeagueAdminPermissionsInputDTO';
|
import { GetLeagueAdminPermissionsInputDTO } from './dtos/GetLeagueAdminPermissionsInputDTO';
|
||||||
import { GetLeagueOwnerSummaryQueryDTO } from './dtos/GetLeagueOwnerSummaryQueryDTO';
|
import { GetLeagueOwnerSummaryQueryDTO } from './dtos/GetLeagueOwnerSummaryQueryDTO';
|
||||||
import { GetLeagueProtestsQueryDTO } from './dtos/GetLeagueProtestsQueryDTO';
|
import { GetLeagueProtestsQueryDTO } from './dtos/GetLeagueProtestsQueryDTO';
|
||||||
|
import { GetLeagueRacesOutputDTO } from './dtos/GetLeagueRacesOutputDTO';
|
||||||
import { GetLeagueSeasonsQueryDTO } from './dtos/GetLeagueSeasonsQueryDTO';
|
import { GetLeagueSeasonsQueryDTO } from './dtos/GetLeagueSeasonsQueryDTO';
|
||||||
import { RejectJoinRequestInputDTO } from './dtos/RejectJoinRequestInputDTO';
|
import { GetLeagueWalletOutputDTO } from './dtos/GetLeagueWalletOutputDTO';
|
||||||
import { RemoveLeagueMemberInputDTO } from './dtos/RemoveLeagueMemberInputDTO';
|
import { GetSeasonSponsorshipsOutputDTO } from './dtos/GetSeasonSponsorshipsOutputDTO';
|
||||||
import { UpdateLeagueMemberRoleInputDTO } from './dtos/UpdateLeagueMemberRoleInputDTO';
|
|
||||||
import { LeagueAdminDTO } from './dtos/LeagueAdminDTO';
|
import { LeagueAdminDTO } from './dtos/LeagueAdminDTO';
|
||||||
import { LeagueAdminPermissionsDTO } from './dtos/LeagueAdminPermissionsDTO';
|
import { LeagueAdminPermissionsDTO } from './dtos/LeagueAdminPermissionsDTO';
|
||||||
import { LeagueAdminProtestsDTO } from './dtos/LeagueAdminProtestsDTO';
|
import { LeagueAdminProtestsDTO } from './dtos/LeagueAdminProtestsDTO';
|
||||||
|
import { LeagueConfigFormModelDTO } from './dtos/LeagueConfigFormModelDTO';
|
||||||
|
import { LeagueJoinRequestWithDriverDTO } from './dtos/LeagueJoinRequestWithDriverDTO';
|
||||||
import { LeagueMembershipsDTO } from './dtos/LeagueMembershipsDTO';
|
import { LeagueMembershipsDTO } from './dtos/LeagueMembershipsDTO';
|
||||||
import { LeagueOwnerSummaryDTO } from './dtos/LeagueOwnerSummaryDTO';
|
import { LeagueOwnerSummaryDTO } from './dtos/LeagueOwnerSummaryDTO';
|
||||||
import { LeagueScheduleDTO } from './dtos/LeagueScheduleDTO';
|
import { LeagueScheduleDTO } from './dtos/LeagueScheduleDTO';
|
||||||
import { LeagueSeasonSummaryDTO } from './dtos/LeagueSeasonSummaryDTO';
|
import { LeagueSeasonSummaryDTO } from './dtos/LeagueSeasonSummaryDTO';
|
||||||
import { LeagueConfigFormModelDTO } from './dtos/LeagueConfigFormModelDTO';
|
|
||||||
import { LeagueStatsDTO } from './dtos/LeagueStatsDTO';
|
|
||||||
import { LeagueStandingsDTO } from './dtos/LeagueStandingsDTO';
|
import { LeagueStandingsDTO } from './dtos/LeagueStandingsDTO';
|
||||||
import { GetLeagueWalletOutputDTO } from './dtos/GetLeagueWalletOutputDTO';
|
import { LeagueStatsDTO } from './dtos/LeagueStatsDTO';
|
||||||
import { WithdrawFromLeagueWalletInputDTO } from './dtos/WithdrawFromLeagueWalletInputDTO';
|
import { RejectJoinRequestInputDTO } from './dtos/RejectJoinRequestInputDTO';
|
||||||
import { WithdrawFromLeagueWalletOutputDTO } from './dtos/WithdrawFromLeagueWalletOutputDTO';
|
|
||||||
import { GetSeasonSponsorshipsOutputDTO } from './dtos/GetSeasonSponsorshipsOutputDTO';
|
|
||||||
import { GetLeagueRacesOutputDTO } from './dtos/GetLeagueRacesOutputDTO';
|
|
||||||
import { RejectJoinRequestOutputDTO } from './dtos/RejectJoinRequestOutputDTO';
|
import { RejectJoinRequestOutputDTO } from './dtos/RejectJoinRequestOutputDTO';
|
||||||
|
import { RemoveLeagueMemberInputDTO } from './dtos/RemoveLeagueMemberInputDTO';
|
||||||
import { RemoveLeagueMemberOutputDTO } from './dtos/RemoveLeagueMemberOutputDTO';
|
import { RemoveLeagueMemberOutputDTO } from './dtos/RemoveLeagueMemberOutputDTO';
|
||||||
import { TransferLeagueOwnershipOutputDTO } from './dtos/TransferLeagueOwnershipOutputDTO';
|
import { TransferLeagueOwnershipOutputDTO } from './dtos/TransferLeagueOwnershipOutputDTO';
|
||||||
|
import { UpdateLeagueMemberRoleInputDTO } from './dtos/UpdateLeagueMemberRoleInputDTO';
|
||||||
import { UpdateLeagueMemberRoleOutputDTO } from './dtos/UpdateLeagueMemberRoleOutputDTO';
|
import { UpdateLeagueMemberRoleOutputDTO } from './dtos/UpdateLeagueMemberRoleOutputDTO';
|
||||||
import { LeagueJoinRequestWithDriverDTO } from './dtos/LeagueJoinRequestWithDriverDTO';
|
import { WithdrawFromLeagueWalletInputDTO } from './dtos/WithdrawFromLeagueWalletInputDTO';
|
||||||
import { ApproveLeagueJoinRequestDTO } from './dtos/ApproveLeagueJoinRequestDTO';
|
import { WithdrawFromLeagueWalletOutputDTO } from './dtos/WithdrawFromLeagueWalletOutputDTO';
|
||||||
|
|
||||||
// Core imports for view models
|
// Core imports for view models
|
||||||
|
import type { AllLeaguesWithCapacityDTO as AllLeaguesWithCapacityViewModel } from './dtos/AllLeaguesWithCapacityDTO';
|
||||||
|
import type { CreateLeagueViewModel } from './dtos/CreateLeagueDTO';
|
||||||
|
import type { JoinLeagueOutputDTO } from './dtos/JoinLeagueOutputDTO';
|
||||||
|
import { TotalLeaguesDTO } from './dtos/TotalLeaguesDTO';
|
||||||
import type { LeagueScoringConfigViewModel } from './presenters/LeagueScoringConfigPresenter';
|
import type { LeagueScoringConfigViewModel } from './presenters/LeagueScoringConfigPresenter';
|
||||||
import type { LeagueScoringPresetsViewModel } from './presenters/LeagueScoringPresetsPresenter';
|
import type { LeagueScoringPresetsViewModel } from './presenters/LeagueScoringPresetsPresenter';
|
||||||
import type { AllLeaguesWithCapacityDTO as AllLeaguesWithCapacityViewModel } from './dtos/AllLeaguesWithCapacityDTO';
|
|
||||||
import { TotalLeaguesDTO } from './dtos/TotalLeaguesDTO';
|
|
||||||
import type { JoinLeagueOutputDTO } from './dtos/JoinLeagueOutputDTO';
|
|
||||||
import type { CreateLeagueViewModel } from './dtos/CreateLeagueDTO';
|
|
||||||
|
|
||||||
// Core imports
|
// Core imports
|
||||||
import type { Logger } from '@core/shared/application/Logger';
|
import type { Logger } from '@core/shared/application/Logger';
|
||||||
|
|
||||||
// Use cases
|
// Use cases
|
||||||
import { GetLeagueStandingsUseCase } from '@core/racing/application/use-cases/GetLeagueStandingsUseCase';
|
|
||||||
import { ApproveLeagueJoinRequestUseCase } from '@core/racing/application/use-cases/ApproveLeagueJoinRequestUseCase';
|
import { ApproveLeagueJoinRequestUseCase } from '@core/racing/application/use-cases/ApproveLeagueJoinRequestUseCase';
|
||||||
import { CreateLeagueWithSeasonAndScoringUseCase } from '@core/racing/application/use-cases/CreateLeagueWithSeasonAndScoringUseCase';
|
import { CreateLeagueWithSeasonAndScoringUseCase } from '@core/racing/application/use-cases/CreateLeagueWithSeasonAndScoringUseCase';
|
||||||
import { GetAllLeaguesWithCapacityUseCase } from '@core/racing/application/use-cases/GetAllLeaguesWithCapacityUseCase';
|
import { GetAllLeaguesWithCapacityUseCase } from '@core/racing/application/use-cases/GetAllLeaguesWithCapacityUseCase';
|
||||||
@@ -56,8 +55,11 @@ import { GetLeagueProtestsUseCase } from '@core/racing/application/use-cases/Get
|
|||||||
import { GetLeagueScheduleUseCase } from '@core/racing/application/use-cases/GetLeagueScheduleUseCase';
|
import { GetLeagueScheduleUseCase } from '@core/racing/application/use-cases/GetLeagueScheduleUseCase';
|
||||||
import { GetLeagueScoringConfigUseCase } from '@core/racing/application/use-cases/GetLeagueScoringConfigUseCase';
|
import { GetLeagueScoringConfigUseCase } from '@core/racing/application/use-cases/GetLeagueScoringConfigUseCase';
|
||||||
import { GetLeagueSeasonsUseCase } from '@core/racing/application/use-cases/GetLeagueSeasonsUseCase';
|
import { GetLeagueSeasonsUseCase } from '@core/racing/application/use-cases/GetLeagueSeasonsUseCase';
|
||||||
|
import { GetLeagueStandingsUseCase } from '@core/racing/application/use-cases/GetLeagueStandingsUseCase';
|
||||||
import { GetLeagueStatsUseCase } from '@core/racing/application/use-cases/GetLeagueStatsUseCase';
|
import { GetLeagueStatsUseCase } from '@core/racing/application/use-cases/GetLeagueStatsUseCase';
|
||||||
|
import { GetLeagueWalletUseCase } from '@core/racing/application/use-cases/GetLeagueWalletUseCase';
|
||||||
import { GetRaceProtestsUseCase } from '@core/racing/application/use-cases/GetRaceProtestsUseCase';
|
import { GetRaceProtestsUseCase } from '@core/racing/application/use-cases/GetRaceProtestsUseCase';
|
||||||
|
import { GetSeasonSponsorshipsUseCase } from '@core/racing/application/use-cases/GetSeasonSponsorshipsUseCase';
|
||||||
import { GetTotalLeaguesUseCase } from '@core/racing/application/use-cases/GetTotalLeaguesUseCase';
|
import { GetTotalLeaguesUseCase } from '@core/racing/application/use-cases/GetTotalLeaguesUseCase';
|
||||||
import { JoinLeagueUseCase } from '@core/racing/application/use-cases/JoinLeagueUseCase';
|
import { JoinLeagueUseCase } from '@core/racing/application/use-cases/JoinLeagueUseCase';
|
||||||
import { ListLeagueScoringPresetsUseCase } from '@core/racing/application/use-cases/ListLeagueScoringPresetsUseCase';
|
import { ListLeagueScoringPresetsUseCase } from '@core/racing/application/use-cases/ListLeagueScoringPresetsUseCase';
|
||||||
@@ -65,35 +67,30 @@ import { RejectLeagueJoinRequestUseCase } from '@core/racing/application/use-cas
|
|||||||
import { RemoveLeagueMemberUseCase } from '@core/racing/application/use-cases/RemoveLeagueMemberUseCase';
|
import { RemoveLeagueMemberUseCase } from '@core/racing/application/use-cases/RemoveLeagueMemberUseCase';
|
||||||
import { TransferLeagueOwnershipUseCase } from '@core/racing/application/use-cases/TransferLeagueOwnershipUseCase';
|
import { TransferLeagueOwnershipUseCase } from '@core/racing/application/use-cases/TransferLeagueOwnershipUseCase';
|
||||||
import { UpdateLeagueMemberRoleUseCase } from '@core/racing/application/use-cases/UpdateLeagueMemberRoleUseCase';
|
import { UpdateLeagueMemberRoleUseCase } from '@core/racing/application/use-cases/UpdateLeagueMemberRoleUseCase';
|
||||||
import { GetLeagueWalletUseCase } from '@core/racing/application/use-cases/GetLeagueWalletUseCase';
|
|
||||||
import { WithdrawFromLeagueWalletUseCase } from '@core/racing/application/use-cases/WithdrawFromLeagueWalletUseCase';
|
import { WithdrawFromLeagueWalletUseCase } from '@core/racing/application/use-cases/WithdrawFromLeagueWalletUseCase';
|
||||||
import { GetSeasonSponsorshipsUseCase } from '@core/racing/application/use-cases/GetSeasonSponsorshipsUseCase';
|
|
||||||
|
|
||||||
// API Presenters
|
// API Presenters
|
||||||
import { AllLeaguesWithCapacityPresenter } from './presenters/AllLeaguesWithCapacityPresenter';
|
import { CreateLeaguePresenter } from './presenters/CreateLeaguePresenter';
|
||||||
import { TotalLeaguesPresenter } from './presenters/TotalLeaguesPresenter';
|
import { GetLeagueAdminPermissionsPresenter } from './presenters/GetLeagueAdminPermissionsPresenter';
|
||||||
|
import { GetLeagueMembershipsPresenter } from './presenters/GetLeagueMembershipsPresenter';
|
||||||
|
import { GetLeagueOwnerSummaryPresenter } from './presenters/GetLeagueOwnerSummaryPresenter';
|
||||||
|
import { GetLeagueProtestsPresenter } from './presenters/GetLeagueProtestsPresenter';
|
||||||
|
import { GetLeagueSeasonsPresenter } from './presenters/GetLeagueSeasonsPresenter';
|
||||||
|
import { GetSeasonSponsorshipsPresenter } from './presenters/GetSeasonSponsorshipsPresenter';
|
||||||
|
import { JoinLeaguePresenter } from './presenters/JoinLeaguePresenter';
|
||||||
|
import { LeagueAdminPresenter } from './presenters/LeagueAdminPresenter';
|
||||||
|
import { LeagueConfigPresenter } from './presenters/LeagueConfigPresenter';
|
||||||
|
import { LeagueJoinRequestsPresenter } from './presenters/LeagueJoinRequestsPresenter';
|
||||||
|
import { LeagueRacesPresenter, LeagueSchedulePresenter } from './presenters/LeagueSchedulePresenter';
|
||||||
import { LeagueScoringConfigPresenter } from './presenters/LeagueScoringConfigPresenter';
|
import { LeagueScoringConfigPresenter } from './presenters/LeagueScoringConfigPresenter';
|
||||||
import { LeagueScoringPresetsPresenter } from './presenters/LeagueScoringPresetsPresenter';
|
import { LeagueScoringPresetsPresenter } from './presenters/LeagueScoringPresetsPresenter';
|
||||||
import { ApproveLeagueJoinRequestPresenter } from './presenters/ApproveLeagueJoinRequestPresenter';
|
import { LeagueStandingsPresenter } from './presenters/LeagueStandingsPresenter';
|
||||||
import { GetLeagueAdminPermissionsPresenter } from './presenters/GetLeagueAdminPermissionsPresenter';
|
|
||||||
import { GetLeagueOwnerSummaryPresenter } from './presenters/GetLeagueOwnerSummaryPresenter';
|
|
||||||
import { LeagueJoinRequestsPresenter } from './presenters/LeagueJoinRequestsPresenter';
|
|
||||||
import { LeagueSchedulePresenter, LeagueRacesPresenter } from './presenters/LeagueSchedulePresenter';
|
|
||||||
import { LeagueStatsPresenter } from './presenters/LeagueStatsPresenter';
|
import { LeagueStatsPresenter } from './presenters/LeagueStatsPresenter';
|
||||||
import { RejectLeagueJoinRequestPresenter } from './presenters/RejectLeagueJoinRequestPresenter';
|
import { RejectLeagueJoinRequestPresenter } from './presenters/RejectLeagueJoinRequestPresenter';
|
||||||
import { RemoveLeagueMemberPresenter } from './presenters/RemoveLeagueMemberPresenter';
|
import { RemoveLeagueMemberPresenter } from './presenters/RemoveLeagueMemberPresenter';
|
||||||
import { UpdateLeagueMemberRolePresenter } from './presenters/UpdateLeagueMemberRolePresenter';
|
import { TotalLeaguesPresenter } from './presenters/TotalLeaguesPresenter';
|
||||||
import { CreateLeaguePresenter } from './presenters/CreateLeaguePresenter';
|
|
||||||
import { JoinLeaguePresenter } from './presenters/JoinLeaguePresenter';
|
|
||||||
import { TransferLeagueOwnershipPresenter } from './presenters/TransferLeagueOwnershipPresenter';
|
import { TransferLeagueOwnershipPresenter } from './presenters/TransferLeagueOwnershipPresenter';
|
||||||
import { GetLeagueProtestsPresenter } from './presenters/GetLeagueProtestsPresenter';
|
import { UpdateLeagueMemberRolePresenter } from './presenters/UpdateLeagueMemberRolePresenter';
|
||||||
import { GetLeagueSeasonsPresenter } from './presenters/GetLeagueSeasonsPresenter';
|
|
||||||
import { LeagueConfigPresenter } from './presenters/LeagueConfigPresenter';
|
|
||||||
import { LeagueStandingsPresenter } from './presenters/LeagueStandingsPresenter';
|
|
||||||
import { GetLeagueMembershipsPresenter } from './presenters/GetLeagueMembershipsPresenter';
|
|
||||||
import { LeagueOwnerSummaryPresenter } from './presenters/LeagueOwnerSummaryPresenter';
|
|
||||||
import { LeagueAdminPresenter } from './presenters/LeagueAdminPresenter';
|
|
||||||
import { GetSeasonSponsorshipsPresenter } from './presenters/GetSeasonSponsorshipsPresenter';
|
|
||||||
// Tokens
|
// Tokens
|
||||||
import { LOGGER_TOKEN } from './LeagueProviders';
|
import { LOGGER_TOKEN } from './LeagueProviders';
|
||||||
|
|
||||||
@@ -135,7 +132,7 @@ export class LeagueService {
|
|||||||
if (result.isErr()) {
|
if (result.isErr()) {
|
||||||
throw new Error(result.unwrapErr().code);
|
throw new Error(result.unwrapErr().code);
|
||||||
}
|
}
|
||||||
return this.getAllLeaguesWithCapacityUseCase.outputPort.present(result);
|
return this.getAllLeaguesWithCapacityUseCase.outputPort.present(result); // TODO wrong, must use presenter
|
||||||
}
|
}
|
||||||
|
|
||||||
async getTotalLeagues(): Promise<TotalLeaguesDTO> {
|
async getTotalLeagues(): Promise<TotalLeaguesDTO> {
|
||||||
|
|||||||
6
core/racing/application/ports/IImageServicePort.ts
Normal file
6
core/racing/application/ports/IImageServicePort.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export interface IImageServicePort {
|
||||||
|
getDriverAvatar(driverId: string): string;
|
||||||
|
getTeamLogo(teamId: string): string;
|
||||||
|
getLeagueCover(leagueId: string): string;
|
||||||
|
getLeagueLogo(leagueId: string): string;
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ import type { IDriverRepository } from '../../domain/repositories/IDriverReposit
|
|||||||
import { Driver } from '../../domain/entities/Driver';
|
import { Driver } from '../../domain/entities/Driver';
|
||||||
import { Result } from '@core/shared/application/Result';
|
import { Result } from '@core/shared/application/Result';
|
||||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||||
import type { UseCaseOutputPort, UseCase } from '@core/shared/application';
|
import type { UseCase, UseCaseOutputPort } from '@core/shared/application';
|
||||||
import type { Logger } from '@core/shared/application/Logger';
|
import type { Logger } from '@core/shared/application/Logger';
|
||||||
|
|
||||||
export interface CompleteDriverOnboardingInput {
|
export interface CompleteDriverOnboardingInput {
|
||||||
@@ -30,16 +30,15 @@ export type CompleteDriverOnboardingApplicationError = ApplicationErrorCode<
|
|||||||
/**
|
/**
|
||||||
* Use Case for completing driver onboarding.
|
* Use Case for completing driver onboarding.
|
||||||
*/
|
*/
|
||||||
export class CompleteDriverOnboardingUseCase implements UseCase<CompleteDriverOnboardingInput, void, CompleteDriverOnboardingErrorCode> {
|
export class CompleteDriverOnboardingUseCase implements UseCase<CompleteDriverOnboardingInput, CompleteDriverOnboardingResult, CompleteDriverOnboardingErrorCode> {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly driverRepository: IDriverRepository,
|
private readonly driverRepository: IDriverRepository,
|
||||||
private readonly logger: Logger,
|
private readonly logger: Logger,
|
||||||
private readonly output: UseCaseOutputPort<CompleteDriverOnboardingResult>,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async execute(
|
async execute(
|
||||||
input: CompleteDriverOnboardingInput,
|
input: CompleteDriverOnboardingInput,
|
||||||
): Promise<Result<void, CompleteDriverOnboardingApplicationError>> {
|
): Promise<Result<CompleteDriverOnboardingResult, CompleteDriverOnboardingApplicationError>> {
|
||||||
try {
|
try {
|
||||||
const existing = await this.driverRepository.findById(input.userId);
|
const existing = await this.driverRepository.findById(input.userId);
|
||||||
if (existing) {
|
if (existing) {
|
||||||
@@ -59,9 +58,8 @@ export class CompleteDriverOnboardingUseCase implements UseCase<CompleteDriverOn
|
|||||||
|
|
||||||
await this.driverRepository.create(driver);
|
await this.driverRepository.create(driver);
|
||||||
|
|
||||||
this.output.present({ driver });
|
const result: CompleteDriverOnboardingResult = { driver };
|
||||||
|
return Result.ok(result);
|
||||||
return Result.ok(undefined);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const err = error instanceof Error ? error : new Error('Unknown error');
|
const err = error instanceof Error ? error : new Error('Unknown error');
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { Logger, UseCaseOutputPort } from '@core/shared/application';
|
import type { Logger, UseCase } from '@core/shared/application';
|
||||||
import { Result } from '@core/shared/application/Result';
|
import { Result } from '@core/shared/application/Result';
|
||||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||||
import type { Driver } from '../../domain/entities/Driver';
|
import type { Driver } from '../../domain/entities/Driver';
|
||||||
@@ -42,21 +42,20 @@ export type GetDriversLeaderboardErrorCode =
|
|||||||
* Use Case for retrieving driver leaderboard data.
|
* Use Case for retrieving driver leaderboard data.
|
||||||
* Returns a Result containing the domain leaderboard model.
|
* Returns a Result containing the domain leaderboard model.
|
||||||
*/
|
*/
|
||||||
export class GetDriversLeaderboardUseCase {
|
export class GetDriversLeaderboardUseCase implements UseCase<GetDriversLeaderboardInput, GetDriversLeaderboardResult, GetDriversLeaderboardErrorCode> {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly driverRepository: IDriverRepository,
|
private readonly driverRepository: IDriverRepository,
|
||||||
private readonly rankingService: IRankingService,
|
private readonly rankingService: IRankingService,
|
||||||
private readonly driverStatsService: IDriverStatsService,
|
private readonly driverStatsService: IDriverStatsService,
|
||||||
private readonly getDriverAvatar: (driverId: string) => Promise<string | undefined>,
|
private readonly getDriverAvatar: (driverId: string) => Promise<string | undefined>,
|
||||||
private readonly logger: Logger,
|
private readonly logger: Logger,
|
||||||
private readonly output: UseCaseOutputPort<GetDriversLeaderboardResult>,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async execute(
|
async execute(
|
||||||
input: GetDriversLeaderboardInput,
|
input: GetDriversLeaderboardInput,
|
||||||
): Promise<
|
): Promise<
|
||||||
Result<
|
Result<
|
||||||
void,
|
GetDriversLeaderboardResult,
|
||||||
ApplicationErrorCode<GetDriversLeaderboardErrorCode, { message: string }>
|
ApplicationErrorCode<GetDriversLeaderboardErrorCode, { message: string }>
|
||||||
>
|
>
|
||||||
> {
|
> {
|
||||||
@@ -108,9 +107,7 @@ export class GetDriversLeaderboardUseCase {
|
|||||||
|
|
||||||
this.logger.debug('Successfully computed drivers leaderboard');
|
this.logger.debug('Successfully computed drivers leaderboard');
|
||||||
|
|
||||||
this.output.present(result);
|
return Result.ok(result);
|
||||||
|
|
||||||
return Result.ok(undefined);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const err = error instanceof Error ? error : new Error(String(error));
|
const err = error instanceof Error ? error : new Error(String(error));
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ export type GetProfileOverviewErrorCode =
|
|||||||
| 'DRIVER_NOT_FOUND'
|
| 'DRIVER_NOT_FOUND'
|
||||||
| 'REPOSITORY_ERROR';
|
| 'REPOSITORY_ERROR';
|
||||||
|
|
||||||
export class GetProfileOverviewUseCase implements UseCase<GetProfileOverviewInput, void, GetProfileOverviewErrorCode> {
|
export class GetProfileOverviewUseCase implements UseCase<GetProfileOverviewInput, GetProfileOverviewResult, GetProfileOverviewErrorCode> {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly driverRepository: IDriverRepository,
|
private readonly driverRepository: IDriverRepository,
|
||||||
private readonly teamRepository: ITeamRepository,
|
private readonly teamRepository: ITeamRepository,
|
||||||
@@ -102,13 +102,12 @@ export class GetProfileOverviewUseCase implements UseCase<GetProfileOverviewInpu
|
|||||||
private readonly driverExtendedProfileProvider: DriverExtendedProfileProvider,
|
private readonly driverExtendedProfileProvider: DriverExtendedProfileProvider,
|
||||||
private readonly getDriverStats: (driverId: string) => ProfileDriverStatsAdapter | null,
|
private readonly getDriverStats: (driverId: string) => ProfileDriverStatsAdapter | null,
|
||||||
private readonly getAllDriverRankings: () => DriverRankingEntry[],
|
private readonly getAllDriverRankings: () => DriverRankingEntry[],
|
||||||
private readonly output: UseCaseOutputPort<GetProfileOverviewResult>,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async execute(
|
async execute(
|
||||||
input: GetProfileOverviewInput,
|
input: GetProfileOverviewInput,
|
||||||
): Promise<
|
): Promise<
|
||||||
Result<void, ApplicationErrorCode<GetProfileOverviewErrorCode, { message: string }>>
|
Result<GetProfileOverviewResult, ApplicationErrorCode<GetProfileOverviewErrorCode, { message: string }>>
|
||||||
> {
|
> {
|
||||||
try {
|
try {
|
||||||
const { driverId } = input;
|
const { driverId } = input;
|
||||||
@@ -144,9 +143,7 @@ export class GetProfileOverviewUseCase implements UseCase<GetProfileOverviewInpu
|
|||||||
extendedProfile,
|
extendedProfile,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.output.present(result);
|
return Result.ok(result);
|
||||||
|
|
||||||
return Result.ok(undefined);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return Result.err({
|
return Result.err({
|
||||||
code: 'REPOSITORY_ERROR',
|
code: 'REPOSITORY_ERROR',
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { IDriverRepository } from '../../domain/repositories/IDriverRepository';
|
import type { UseCase } from '@core/shared/application';
|
||||||
import { Result } from '@core/shared/application/Result';
|
import { Result } from '@core/shared/application/Result';
|
||||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||||
import type { UseCaseOutputPort, UseCase } from '@core/shared/application';
|
import type { IDriverRepository } from '../../domain/repositories/IDriverRepository';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Input type for retrieving total number of drivers.
|
* Input type for retrieving total number of drivers.
|
||||||
@@ -17,22 +17,19 @@ export type GetTotalDriversResult = {
|
|||||||
|
|
||||||
export type GetTotalDriversErrorCode = 'REPOSITORY_ERROR';
|
export type GetTotalDriversErrorCode = 'REPOSITORY_ERROR';
|
||||||
|
|
||||||
export class GetTotalDriversUseCase implements UseCase<GetTotalDriversInput, void, GetTotalDriversErrorCode> {
|
export class GetTotalDriversUseCase implements UseCase<GetTotalDriversInput, GetTotalDriversResult, GetTotalDriversErrorCode> {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly driverRepository: IDriverRepository,
|
private readonly driverRepository: IDriverRepository,
|
||||||
private readonly output: UseCaseOutputPort<GetTotalDriversResult>,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async execute(
|
async execute(
|
||||||
_input: GetTotalDriversInput,
|
_input: GetTotalDriversInput,
|
||||||
): Promise<Result<void, ApplicationErrorCode<GetTotalDriversErrorCode, { message: string }>>> {
|
): Promise<Result<GetTotalDriversResult, ApplicationErrorCode<GetTotalDriversErrorCode, { message: string }>>> {
|
||||||
try {
|
try {
|
||||||
const drivers = await this.driverRepository.findAll();
|
const drivers = await this.driverRepository.findAll();
|
||||||
const result: GetTotalDriversResult = { totalDrivers: drivers.length };
|
const result: GetTotalDriversResult = { totalDrivers: drivers.length };
|
||||||
|
|
||||||
this.output.present(result);
|
return Result.ok(result);
|
||||||
|
|
||||||
return Result.ok(undefined);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const message = (error as Error | undefined)?.message ?? 'Failed to compute total drivers';
|
const message = (error as Error | undefined)?.message ?? 'Failed to compute total drivers';
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { IRaceRegistrationRepository } from '../../domain/repositories/IRaceRegistrationRepository';
|
import type { IRaceRegistrationRepository } from '../../domain/repositories/IRaceRegistrationRepository';
|
||||||
import type { Logger, UseCaseOutputPort, UseCase } from '@core/shared/application';
|
import type { Logger, UseCase } from '@core/shared/application';
|
||||||
import { Result } from '@core/shared/application/Result';
|
import { Result } from '@core/shared/application/Result';
|
||||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||||
|
|
||||||
@@ -26,23 +26,20 @@ export type IsDriverRegisteredForRaceResult = {
|
|||||||
*
|
*
|
||||||
* Checks if a driver is registered for a specific race.
|
* Checks if a driver is registered for a specific race.
|
||||||
*/
|
*/
|
||||||
export class IsDriverRegisteredForRaceUseCase implements UseCase<IsDriverRegisteredForRaceInput, void, IsDriverRegisteredForRaceErrorCode> {
|
export class IsDriverRegisteredForRaceUseCase implements UseCase<IsDriverRegisteredForRaceInput, IsDriverRegisteredForRaceResult, IsDriverRegisteredForRaceErrorCode> {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly registrationRepository: IRaceRegistrationRepository,
|
private readonly registrationRepository: IRaceRegistrationRepository,
|
||||||
private readonly logger: Logger,
|
private readonly logger: Logger,
|
||||||
private readonly output: UseCaseOutputPort<IsDriverRegisteredForRaceResult>,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async execute(params: IsDriverRegisteredForRaceInput): Promise<Result<void, IsDriverRegisteredForRaceApplicationError>> {
|
async execute(params: IsDriverRegisteredForRaceInput): Promise<Result<IsDriverRegisteredForRaceResult, IsDriverRegisteredForRaceApplicationError>> {
|
||||||
this.logger.debug('IsDriverRegisteredForRaceUseCase:execute', { params });
|
this.logger.debug('IsDriverRegisteredForRaceUseCase:execute', { params });
|
||||||
const { raceId, driverId } = params;
|
const { raceId, driverId } = params;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const isRegistered = await this.registrationRepository.isRegistered(raceId, driverId);
|
const isRegistered = await this.registrationRepository.isRegistered(raceId, driverId);
|
||||||
|
|
||||||
this.output.present({ isRegistered, raceId, driverId });
|
return Result.ok({ isRegistered, raceId, driverId });
|
||||||
|
|
||||||
return Result.ok(undefined);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error(
|
this.logger.error(
|
||||||
'IsDriverRegisteredForRaceUseCase:execution error',
|
'IsDriverRegisteredForRaceUseCase:execution error',
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Result } from '@core/shared/application/Result';
|
import { Result } from '@core/shared/application/Result';
|
||||||
import type { UseCaseOutputPort, UseCase } from '@core/shared/application';
|
import type { UseCase } from '@core/shared/application';
|
||||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||||
import type { Logger } from '@core/shared/application/Logger';
|
import type { Logger } from '@core/shared/application/Logger';
|
||||||
import type { IDriverRepository } from '../../domain/repositories/IDriverRepository';
|
import type { IDriverRepository } from '../../domain/repositories/IDriverRepository';
|
||||||
@@ -23,16 +23,15 @@ export type UpdateDriverProfileErrorCode =
|
|||||||
* Encapsulates domain entity mutation. Mapping to DTOs is handled by presenters
|
* Encapsulates domain entity mutation. Mapping to DTOs is handled by presenters
|
||||||
* in the presentation layer through the output port.
|
* in the presentation layer through the output port.
|
||||||
*/
|
*/
|
||||||
export class UpdateDriverProfileUseCase implements UseCase<UpdateDriverProfileInput, void, UpdateDriverProfileErrorCode> {
|
export class UpdateDriverProfileUseCase implements UseCase<UpdateDriverProfileInput, UpdateDriverProfileResult, UpdateDriverProfileErrorCode> {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly driverRepository: IDriverRepository,
|
private readonly driverRepository: IDriverRepository,
|
||||||
private readonly output: UseCaseOutputPort<UpdateDriverProfileResult>,
|
|
||||||
private readonly logger: Logger,
|
private readonly logger: Logger,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async execute(
|
async execute(
|
||||||
input: UpdateDriverProfileInput,
|
input: UpdateDriverProfileInput,
|
||||||
): Promise<Result<void, ApplicationErrorCode<UpdateDriverProfileErrorCode, { message: string }>>> {
|
): Promise<Result<UpdateDriverProfileResult, ApplicationErrorCode<UpdateDriverProfileErrorCode, { message: string }>>> {
|
||||||
const { driverId, bio, country } = input;
|
const { driverId, bio, country } = input;
|
||||||
|
|
||||||
if ((bio !== undefined && bio.trim().length === 0) || (country !== undefined && country.trim().length === 0)) {
|
if ((bio !== undefined && bio.trim().length === 0) || (country !== undefined && country.trim().length === 0)) {
|
||||||
@@ -62,9 +61,7 @@ export class UpdateDriverProfileUseCase implements UseCase<UpdateDriverProfileIn
|
|||||||
|
|
||||||
await this.driverRepository.update(updated);
|
await this.driverRepository.update(updated);
|
||||||
|
|
||||||
this.output.present(updated);
|
return Result.ok(updated);
|
||||||
|
|
||||||
return Result.ok(undefined);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const message = error instanceof Error ? error.message : 'Failed to update driver profile';
|
const message = error instanceof Error ? error.message : 'Failed to update driver profile';
|
||||||
|
|
||||||
|
|||||||
157
package.json
157
package.json
@@ -1,69 +1,18 @@
|
|||||||
{
|
{
|
||||||
"name": "gridpilot",
|
"dependencies": {
|
||||||
"version": "0.1.0",
|
"@core/social": "file:core/social",
|
||||||
"private": true,
|
"@nestjs/swagger": "11.2.3",
|
||||||
|
"bcrypt": "^6.0.0",
|
||||||
|
"electron-vite": "3.1.0",
|
||||||
|
"next": "15.5.9",
|
||||||
|
"playwright-extra": "^4.3.6",
|
||||||
|
"puppeteer-extra-plugin-stealth": "^2.11.2",
|
||||||
|
"reflect-metadata": "^0.2.2",
|
||||||
|
"tsyringe": "^4.10.0",
|
||||||
|
"uuid": "^13.0.0",
|
||||||
|
"vite": "6.4.1"
|
||||||
|
},
|
||||||
"description": "GridPilot - Clean Architecture monorepo for web platform and Electron companion app",
|
"description": "GridPilot - Clean Architecture monorepo for web platform and Electron companion app",
|
||||||
"engines": {
|
|
||||||
"node": ">=20.0.0"
|
|
||||||
},
|
|
||||||
"workspaces": [
|
|
||||||
"core/*",
|
|
||||||
"apps/*",
|
|
||||||
"testing/*"
|
|
||||||
],
|
|
||||||
"scripts": {
|
|
||||||
"dev": "echo 'Development server placeholder - to be configured'",
|
|
||||||
"build": "echo 'Build all packages placeholder - to be configured'",
|
|
||||||
"docker:dev": "docker-compose -f docker-compose.dev.yml up",
|
|
||||||
"docker:dev:build": "docker-compose -f docker-compose.dev.yml up --build",
|
|
||||||
"docker:dev:down": "docker-compose -f docker-compose.dev.yml down",
|
|
||||||
"docker:dev:logs": "docker-compose -f docker-compose.dev.yml logs -f",
|
|
||||||
"docker:dev:clean": "docker-compose -f docker-compose.dev.yml down -v",
|
|
||||||
"docker:prod": "docker-compose -f docker-compose.prod.yml up -d",
|
|
||||||
"docker:prod:build": "docker-compose -f docker-compose.prod.yml up -d --build",
|
|
||||||
"docker:prod:down": "docker-compose -f docker-compose.prod.yml down",
|
|
||||||
"docker:prod:logs": "docker-compose -f docker-compose.prod.yml logs -f",
|
|
||||||
"docker:prod:clean": "docker-compose -f docker-compose.prod.yml down -v",
|
|
||||||
"api:build": "npm run build --workspace=@gridpilot/api",
|
|
||||||
"api:generate-spec": "tsx scripts/generate-openapi-spec.ts",
|
|
||||||
"api:generate-types": "tsx scripts/generate-api-types.ts",
|
|
||||||
"api:sync-types": "npm run api:generate-spec && npm run api:generate-types",
|
|
||||||
"test": "vitest run \"$@\"",
|
|
||||||
"test:unit": "vitest run tests/unit",
|
|
||||||
"test:integration": "vitest run tests/integration",
|
|
||||||
"test:e2e": "vitest run --config vitest.e2e.config.ts",
|
|
||||||
"test:e2e:docker": "vitest run --config vitest.e2e.config.ts tests/e2e/docker/",
|
|
||||||
"test:watch": "vitest watch",
|
|
||||||
"test:smoke": "vitest run --config vitest.smoke.config.ts",
|
|
||||||
"test:smoke:watch": "vitest watch --config vitest.smoke.config.ts",
|
|
||||||
"test:smoke:electron": "playwright test --config=playwright.smoke.config.ts",
|
|
||||||
"smoke:website": "npm run website:build && npx playwright test -c playwright.website.config.ts",
|
|
||||||
"test:hosted-real": "vitest run --config vitest.e2e.config.ts tests/e2e/hosted-real/",
|
|
||||||
"test:companion-hosted": "vitest run --config vitest.e2e.config.ts tests/e2e/companion/companion-ui-full-workflow.e2e.test.ts",
|
|
||||||
"typecheck": "npx tsc --noEmit",
|
|
||||||
"test:types": "tsc --noEmit -p tsconfig.tests.json",
|
|
||||||
"companion:dev": "npm run dev --workspace=@gridpilot/companion",
|
|
||||||
"companion:build": "npm run build --workspace=@gridpilot/companion",
|
|
||||||
"companion:start": "npm run start --workspace=@gridpilot/companion",
|
|
||||||
"env:website:merge": "node scripts/merge-website-env.js",
|
|
||||||
"website:dev": "npm run env:website:merge && npm run dev --workspace=@gridpilot/website",
|
|
||||||
"website:build": "npm run env:website:merge && npm run build --workspace=@gridpilot/website",
|
|
||||||
"website:start": "npm run start --workspace=@gridpilot/website",
|
|
||||||
"website:lint": "npm run lint --workspace=@gridpilot/website",
|
|
||||||
"website:type-check": "npm run type-check --workspace=@gridpilot/website",
|
|
||||||
"website:clean": "npm run clean --workspace=@gridpilot/website",
|
|
||||||
"deploy:website:preview": "npx vercel deploy --cwd apps/website",
|
|
||||||
"deploy:website:prod": "npx vercel deploy --prod",
|
|
||||||
"deploy:website": "npm run deploy:website:prod",
|
|
||||||
"chrome:debug": "open -a 'Google Chrome' --args --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug",
|
|
||||||
"docker:e2e:up": "docker-compose -f docker/docker-compose.e2e.yml up -d",
|
|
||||||
"docker:e2e:down": "docker-compose -f docker/docker-compose.e2e.yml down",
|
|
||||||
"generate-templates": "npx tsx scripts/generate-templates/index.ts",
|
|
||||||
"minify-fixtures": "npx tsx scripts/minify-fixtures.ts",
|
|
||||||
"minify-fixtures:force": "npx tsx scripts/minify-fixtures.ts --force",
|
|
||||||
"dom:process": "npx tsx scripts/dom-export/processWorkflows.ts",
|
|
||||||
"prepare": "husky install || true"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@cucumber/cucumber": "^11.0.1",
|
"@cucumber/cucumber": "^11.0.1",
|
||||||
"@playwright/test": "^1.57.0",
|
"@playwright/test": "^1.57.0",
|
||||||
@@ -93,17 +42,69 @@
|
|||||||
"typescript": "^5.9.3",
|
"typescript": "^5.9.3",
|
||||||
"vitest": "^4.0.15"
|
"vitest": "^4.0.15"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"engines": {
|
||||||
"@core/social": "file:core/social",
|
"node": ">=20.0.0"
|
||||||
"@nestjs/swagger": "11.2.3",
|
},
|
||||||
"bcrypt": "^6.0.0",
|
"name": "gridpilot",
|
||||||
"electron-vite": "3.1.0",
|
"private": true,
|
||||||
"next": "15.5.9",
|
"scripts": {
|
||||||
"playwright-extra": "^4.3.6",
|
"api:build": "npm run build --workspace=@gridpilot/api",
|
||||||
"puppeteer-extra-plugin-stealth": "^2.11.2",
|
"api:generate-spec": "tsx scripts/generate-openapi-spec.ts",
|
||||||
"reflect-metadata": "^0.2.2",
|
"api:generate-types": "tsx scripts/generate-api-types.ts",
|
||||||
"tsyringe": "^4.10.0",
|
"api:sync-types": "npm run api:generate-spec && npm run api:generate-types",
|
||||||
"uuid": "^13.0.0",
|
"build": "echo 'Build all packages placeholder - to be configured'",
|
||||||
"vite": "6.4.1"
|
"chrome:debug": "open -a 'Google Chrome' --args --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug",
|
||||||
}
|
"companion:build": "npm run build --workspace=@gridpilot/companion",
|
||||||
}
|
"companion:dev": "npm run dev --workspace=@gridpilot/companion",
|
||||||
|
"companion:start": "npm run start --workspace=@gridpilot/companion",
|
||||||
|
"deploy:website": "npm run deploy:website:prod",
|
||||||
|
"deploy:website:preview": "npx vercel deploy --cwd apps/website",
|
||||||
|
"deploy:website:prod": "npx vercel deploy --prod",
|
||||||
|
"dev": "echo 'Development server placeholder - to be configured'",
|
||||||
|
"docker:dev": "docker-compose -f docker-compose.dev.yml up",
|
||||||
|
"docker:dev:build": "docker-compose -f docker-compose.dev.yml up --build",
|
||||||
|
"docker:dev:clean": "docker-compose -f docker-compose.dev.yml down -v",
|
||||||
|
"docker:dev:down": "docker-compose -f docker-compose.dev.yml down",
|
||||||
|
"docker:dev:logs": "docker-compose -f docker-compose.dev.yml logs -f",
|
||||||
|
"docker:e2e:down": "docker-compose -f docker/docker-compose.e2e.yml down",
|
||||||
|
"docker:e2e:up": "docker-compose -f docker/docker-compose.e2e.yml up -d",
|
||||||
|
"docker:prod": "docker-compose -f docker-compose.prod.yml up -d",
|
||||||
|
"docker:prod:build": "docker-compose -f docker-compose.prod.yml up -d --build",
|
||||||
|
"docker:prod:clean": "docker-compose -f docker-compose.prod.yml down -v",
|
||||||
|
"docker:prod:down": "docker-compose -f docker-compose.prod.yml down",
|
||||||
|
"docker:prod:logs": "docker-compose -f docker-compose.prod.yml logs -f",
|
||||||
|
"dom:process": "npx tsx scripts/dom-export/processWorkflows.ts",
|
||||||
|
"env:website:merge": "node scripts/merge-website-env.js",
|
||||||
|
"generate-templates": "npx tsx scripts/generate-templates/index.ts",
|
||||||
|
"minify-fixtures": "npx tsx scripts/minify-fixtures.ts",
|
||||||
|
"minify-fixtures:force": "npx tsx scripts/minify-fixtures.ts --force",
|
||||||
|
"prepare": "husky install || true",
|
||||||
|
"smoke:website": "npm run website:build && npx playwright test -c playwright.website.config.ts",
|
||||||
|
"test": "vitest run \"$@\"",
|
||||||
|
"test:companion-hosted": "vitest run --config vitest.e2e.config.ts tests/e2e/companion/companion-ui-full-workflow.e2e.test.ts",
|
||||||
|
"test:e2e": "vitest run --config vitest.e2e.config.ts",
|
||||||
|
"test:e2e:docker": "vitest run --config vitest.e2e.config.ts tests/e2e/docker/",
|
||||||
|
"test:hosted-real": "vitest run --config vitest.e2e.config.ts tests/e2e/hosted-real/",
|
||||||
|
"test:integration": "vitest run tests/integration",
|
||||||
|
"test:smoke": "vitest run --config vitest.smoke.config.ts",
|
||||||
|
"test:smoke:electron": "playwright test --config=playwright.smoke.config.ts",
|
||||||
|
"test:smoke:watch": "vitest watch --config vitest.smoke.config.ts",
|
||||||
|
"test:types": "tsc --noEmit -p tsconfig.tests.json",
|
||||||
|
"test:unit": "vitest run tests/unit",
|
||||||
|
"test:watch": "vitest watch",
|
||||||
|
"typecheck": "npx tsc --noEmit --project tsconfig.json",
|
||||||
|
"typecheck:grep": "npm run typescript | grep",
|
||||||
|
"website:build": "npm run env:website:merge && npm run build --workspace=@gridpilot/website",
|
||||||
|
"website:clean": "npm run clean --workspace=@gridpilot/website",
|
||||||
|
"website:dev": "npm run env:website:merge && npm run dev --workspace=@gridpilot/website",
|
||||||
|
"website:lint": "npm run lint --workspace=@gridpilot/website",
|
||||||
|
"website:start": "npm run start --workspace=@gridpilot/website",
|
||||||
|
"website:type-check": "npm run type-check --workspace=@gridpilot/website"
|
||||||
|
},
|
||||||
|
"version": "0.1.0",
|
||||||
|
"workspaces": [
|
||||||
|
"core/*",
|
||||||
|
"apps/*",
|
||||||
|
"testing/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user