website refactor
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Result } from '@core/shared/domain/Result';
|
||||
import type { CheckoutInfoDTO } from '../../../application/dto/CheckoutInfoDTO';
|
||||
import { CheckoutPrice } from '../../../domain/value-objects/CheckoutPrice';
|
||||
import { CheckoutState } from '../../../domain/value-objects/CheckoutState';
|
||||
import type { CheckoutInfoDTO } from '../../../application/dto/CheckoutInfoDTO';
|
||||
import { IRACING_SELECTORS } from './dom/RacingSelectors';
|
||||
|
||||
interface Page {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Page } from 'playwright';
|
||||
import { LoggerPort } from 'apps/companion/main/automation/application/ports/LoggerPort';
|
||||
import { Page } from 'playwright';
|
||||
|
||||
export class AuthenticationGuard {
|
||||
constructor(
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { Page } from 'playwright';
|
||||
import type { LoggerPort } from 'apps/companion/main/automation/application/ports/LoggerPort';
|
||||
import type { IPlaywrightAuthFlow } from './PlaywrightAuthFlow';
|
||||
import { IRACING_URLS, IRACING_SELECTORS, IRACING_TIMEOUTS } from '../dom/RacingSelectors';
|
||||
import type { Page } from 'playwright';
|
||||
import { IRACING_SELECTORS, IRACING_TIMEOUTS, IRACING_URLS } from '../dom/RacingSelectors';
|
||||
import { AuthenticationGuard } from './AuthenticationGuard';
|
||||
import type { IPlaywrightAuthFlow } from './PlaywrightAuthFlow';
|
||||
|
||||
export class IRacingPlaywrightAuthFlow implements IPlaywrightAuthFlow {
|
||||
constructor(private readonly logger?: LoggerPort) {}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import * as fs from 'fs';
|
||||
import type { BrowserContext, Page } from 'playwright';
|
||||
|
||||
import { Result } from '@core/shared/domain/Result';
|
||||
import type { AuthenticationServicePort } from '../../../../application/ports/AuthenticationServicePort';
|
||||
import type { LoggerPort } from '../../../../application/ports/LoggerPort';
|
||||
import { AuthenticationState } from '../../../../domain/value-objects/AuthenticationState';
|
||||
import { BrowserAuthenticationState } from '../../../../domain/value-objects/BrowserAuthenticationState';
|
||||
import { Result } from '@core/shared/domain/Result';
|
||||
import { PlaywrightBrowserSession } from '../core/PlaywrightBrowserSession';
|
||||
import { SessionCookieStore } from './SessionCookieStore';
|
||||
import type { IPlaywrightAuthFlow } from './PlaywrightAuthFlow';
|
||||
import { AuthenticationGuard } from './AuthenticationGuard';
|
||||
import type { IPlaywrightAuthFlow } from './PlaywrightAuthFlow';
|
||||
import { SessionCookieStore } from './SessionCookieStore';
|
||||
|
||||
interface PlaywrightAuthSessionConfig {
|
||||
navigationTimeoutMs?: number;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Result } from '@core/shared/domain/Result';
|
||||
import * as fs from 'fs/promises';
|
||||
import * as path from 'path';
|
||||
import type { LoggerPort } from '../../../../application/ports/LoggerPort';
|
||||
import { AuthenticationState } from '../../../../domain/value-objects/AuthenticationState';
|
||||
import { CookieConfiguration } from '../../../../domain/value-objects/CookieConfiguration';
|
||||
import { Result } from '@core/shared/domain/Result';
|
||||
import type { LoggerPort } from '../../../../application/ports/LoggerPort';
|
||||
|
||||
interface Cookie {
|
||||
name: string;
|
||||
|
||||
@@ -781,23 +781,6 @@ export class PlaywrightAutomationAdapter implements IBrowserAutomation, Authenti
|
||||
return this.stepOrchestrator.executeStep(stepId, config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Step-to-Page mapping for wizard auto-skip detection.
|
||||
* Maps step numbers to their corresponding wizard page names.
|
||||
*/
|
||||
private static readonly STEP_TO_PAGE_MAP: Record<number, string> = {
|
||||
7: 'timeLimit',
|
||||
8: 'cars',
|
||||
9: 'cars',
|
||||
10: 'carClasses',
|
||||
11: 'track',
|
||||
12: 'track',
|
||||
13: 'trackOptions',
|
||||
14: 'timeOfDay',
|
||||
15: 'weather',
|
||||
16: 'raceOptions',
|
||||
17: 'trackConditions',
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { Page } from 'playwright';
|
||||
import type { LoggerPort } from '../../../../application/ports/LoggerPort';
|
||||
import type { FormFillResultDTO } from '../../../../application/dto/FormFillResultDTO';
|
||||
import type { ClickResultDTO } from '../../../../application/dto/ClickResultDTO';
|
||||
import type { FormFillResultDTO } from '../../../../application/dto/FormFillResultDTO';
|
||||
import type { ModalResultDTO } from '../../../../application/dto/ModalResultDTO';
|
||||
import type { LoggerPort } from '../../../../application/ports/LoggerPort';
|
||||
import { StepId } from '../../../../domain/value-objects/StepId';
|
||||
import type { PlaywrightConfig } from '../core/PlaywrightAutomationAdapter';
|
||||
import { PlaywrightBrowserSession } from '../core/PlaywrightBrowserSession';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Page } from 'playwright';
|
||||
import type { LoggerPort } from '../../../../application/ports/LoggerPort';
|
||||
import type { NavigationResultDTO } from '../../../../application/dto/NavigationResultDTO';
|
||||
import type { WaitResultDTO } from '../../../../application/dto/WaitResultDTO';
|
||||
import type { LoggerPort } from '../../../../application/ports/LoggerPort';
|
||||
import type { PlaywrightConfig } from '../core/PlaywrightAutomationAdapter';
|
||||
import { PlaywrightBrowserSession } from '../core/PlaywrightBrowserSession';
|
||||
import { IRACING_SELECTORS, IRACING_TIMEOUTS, IRACING_URLS } from './RacingSelectors';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { Page } from 'playwright';
|
||||
import type { LoggerPort } from 'apps/companion/main/automation/application/ports/LoggerPort';
|
||||
import { IRACING_SELECTORS, BLOCKED_KEYWORDS } from './RacingSelectors';
|
||||
import type { Page } from 'playwright';
|
||||
import type { PlaywrightConfig } from '../core/PlaywrightAutomationAdapter';
|
||||
import { PlaywrightBrowserSession } from '../core/PlaywrightBrowserSession';
|
||||
import { BLOCKED_KEYWORDS, IRACING_SELECTORS } from './RacingSelectors';
|
||||
|
||||
export class SafeClickService {
|
||||
constructor(
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { AutomationEnginePort } from '../../../../application/ports/AutomationEnginePort';
|
||||
import type { HostedSessionConfig } from '../../../../domain/types/HostedSessionConfig';
|
||||
import { StepId } from '../../../../domain/value-objects/StepId';
|
||||
import type { IBrowserAutomation } from '../../../../application/ports/ScreenAutomationPort';
|
||||
import type { SessionRepositoryPort } from '../../../../application/ports/SessionRepositoryPort';
|
||||
import { StepTransitionValidator } from '../../../../domain/services/StepTransitionValidator';
|
||||
import type { HostedSessionConfig } from '../../../../domain/types/HostedSessionConfig';
|
||||
import { StepId } from '../../../../domain/value-objects/StepId';
|
||||
|
||||
type ValidationResult = {
|
||||
isValid: boolean;
|
||||
@@ -29,7 +29,6 @@ type ValidationResult = {
|
||||
*/
|
||||
export class AutomationEngineAdapter implements AutomationEnginePort {
|
||||
private isRunning = false;
|
||||
private automationPromise: Promise<void> | null = null;
|
||||
|
||||
constructor(
|
||||
public readonly browserAutomation: IBrowserAutomation,
|
||||
@@ -99,7 +98,6 @@ export class AutomationEngineAdapter implements AutomationEnginePort {
|
||||
return;
|
||||
}
|
||||
this.isRunning = true;
|
||||
this.automationPromise = this.runAutomationLoop(config);
|
||||
}
|
||||
|
||||
private async runAutomationLoop(config: HostedSessionConfig): Promise<void> {
|
||||
@@ -180,6 +178,5 @@ export class AutomationEngineAdapter implements AutomationEnginePort {
|
||||
|
||||
public stopAutomation(): void {
|
||||
this.isRunning = false;
|
||||
this.automationPromise = null;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as http from 'http';
|
||||
import * as fs from 'fs';
|
||||
import * as http from 'http';
|
||||
import * as path from 'path';
|
||||
|
||||
export interface IFixtureServer {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { AutomationEnginePort } from '../../../../application/ports/AutomationEnginePort';
|
||||
import type { HostedSessionConfig } from '../../../../domain/types/HostedSessionConfig';
|
||||
import { StepId } from '../../../../domain/value-objects/StepId';
|
||||
import type { IBrowserAutomation } from '../../../../application/ports/ScreenAutomationPort';
|
||||
import type { SessionRepositoryPort } from '../../../../application/ports/SessionRepositoryPort';
|
||||
import { StepTransitionValidator } from '../../../../domain/services/StepTransitionValidator';
|
||||
import type { HostedSessionConfig } from '../../../../domain/types/HostedSessionConfig';
|
||||
import { StepId } from '../../../../domain/value-objects/StepId';
|
||||
|
||||
type ValidationResult = {
|
||||
isValid: boolean;
|
||||
@@ -12,7 +12,6 @@ type ValidationResult = {
|
||||
|
||||
export class MockAutomationEngineAdapter implements AutomationEnginePort {
|
||||
private isRunning = false;
|
||||
private automationPromise: Promise<void> | null = null;
|
||||
|
||||
constructor(
|
||||
public readonly browserAutomation: IBrowserAutomation,
|
||||
@@ -82,7 +81,6 @@ export class MockAutomationEngineAdapter implements AutomationEnginePort {
|
||||
return;
|
||||
}
|
||||
this.isRunning = true;
|
||||
this.automationPromise = this.runAutomationLoop(config);
|
||||
}
|
||||
|
||||
private async runAutomationLoop(config: HostedSessionConfig): Promise<void> {
|
||||
@@ -182,6 +180,5 @@ export class MockAutomationEngineAdapter implements AutomationEnginePort {
|
||||
|
||||
public stopAutomation(): void {
|
||||
this.isRunning = false;
|
||||
this.automationPromise = null;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
import { StepId } from '../../../../domain/value-objects/StepId';
|
||||
import type { IBrowserAutomation } from '../../../../application/ports/ScreenAutomationPort';
|
||||
import type { NavigationResultDTO } from '../../../../application/dto/NavigationResultDTO';
|
||||
import type { FormFillResultDTO } from '../../../../application/dto/FormFillResultDTO';
|
||||
import type { ClickResultDTO } from '../../../../application/dto/ClickResultDTO';
|
||||
import type { WaitResultDTO } from '../../../../application/dto/WaitResultDTO';
|
||||
import type { ModalResultDTO } from '../../../../application/dto/ModalResultDTO';
|
||||
import type { AutomationResultDTO } from '../../../../application/dto/AutomationResultDTO';
|
||||
import type { ClickResultDTO } from '../../../../application/dto/ClickResultDTO';
|
||||
import type { FormFillResultDTO } from '../../../../application/dto/FormFillResultDTO';
|
||||
import type { ModalResultDTO } from '../../../../application/dto/ModalResultDTO';
|
||||
import type { NavigationResultDTO } from '../../../../application/dto/NavigationResultDTO';
|
||||
import type { WaitResultDTO } from '../../../../application/dto/WaitResultDTO';
|
||||
import type { IBrowserAutomation } from '../../../../application/ports/ScreenAutomationPort';
|
||||
import { StepId } from '../../../../domain/value-objects/StepId';
|
||||
import type { IAutomationLifecycleEmitter, LifecycleCallback } from '../../AutomationLifecycleEmitter';
|
||||
|
||||
interface MockConfig {
|
||||
@@ -13,17 +13,6 @@ interface MockConfig {
|
||||
failureRate?: number;
|
||||
}
|
||||
|
||||
interface StepExecutionResult {
|
||||
success: boolean;
|
||||
stepId: number;
|
||||
wasModalStep?: boolean;
|
||||
shouldStop?: boolean;
|
||||
executionTime: number;
|
||||
metrics: {
|
||||
totalDelay: number;
|
||||
operationCount: number;
|
||||
};
|
||||
}
|
||||
|
||||
export class MockBrowserAutomationAdapter implements IBrowserAutomation, IAutomationLifecycleEmitter {
|
||||
private config: MockConfig;
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
* Implements ICheckoutConfirmationPort using Electron IPC for main-renderer communication.
|
||||
*/
|
||||
|
||||
import { Result } from '@core/shared/domain/Result';
|
||||
import type { BrowserWindow } from 'electron';
|
||||
import { ipcMain } from 'electron';
|
||||
import { Result } from '@core/shared/domain/Result';
|
||||
import type { CheckoutConfirmationPort } from '../../../application/ports/CheckoutConfirmationPort';
|
||||
import type { CheckoutConfirmationRequestDTO } from '../../../application/dto/CheckoutConfirmationRequestDTO';
|
||||
import type { CheckoutConfirmationPort } from '../../../application/ports/CheckoutConfirmationPort';
|
||||
import { CheckoutConfirmation } from '../../../domain/value-objects/CheckoutConfirmation';
|
||||
|
||||
export class ElectronCheckoutConfirmationAdapter implements CheckoutConfirmationPort {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { LoggerPort } from '../../../application/ports/LoggerPort';
|
||||
import { ConsoleLogger } from '../../../../shared/logging/ConsoleLogger';
|
||||
import { LogContext } from '../../../application/ports/LoggerContext';
|
||||
import { LoggerPort } from '../../../application/ports/LoggerPort';
|
||||
|
||||
export class ConsoleLogAdapter implements LoggerPort {
|
||||
private consoleLogger: ConsoleLogger;
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
* This is where external API calls belong.
|
||||
*/
|
||||
|
||||
import { getWebsiteApiBaseUrl } from '@/lib/config/apiBaseUrl';
|
||||
import { Result } from '@/lib/contracts/Result';
|
||||
import { DomainError } from '@/lib/contracts/services/Service';
|
||||
import { getWebsiteApiBaseUrl } from '@/lib/config/apiBaseUrl';
|
||||
import { MediaBinaryDTO } from '@/lib/types/MediaBinaryDTO';
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user