wip
This commit is contained in:
@@ -23,14 +23,14 @@ import {
|
||||
import { PinoLogAdapter } from '@/packages/automation/infrastructure/adapters/logging/PinoLogAdapter';
|
||||
import { NoOpLogAdapter } from '@/packages/automation/infrastructure/adapters/logging/NoOpLogAdapter';
|
||||
import { loadLoggingConfig } from '@/packages/automation/infrastructure/config/LoggingConfig';
|
||||
import type { ISessionRepository } from '@/packages/automation/application/ports/ISessionRepository';
|
||||
import type { IScreenAutomation } from '@/packages/automation/application/ports/IScreenAutomation';
|
||||
import type { IAutomationEngine } from '@/packages/automation/application/ports/IAutomationEngine';
|
||||
import type { IAuthenticationService } from '@/packages/automation/application/ports/IAuthenticationService';
|
||||
import type { ICheckoutConfirmationPort } from '@/packages/automation/application/ports/ICheckoutConfirmationPort';
|
||||
import type { ILogger } from '@/packages/automation/application/ports/ILogger';
|
||||
import type { SessionRepositoryPort } from '@gridpilot/automation/application/ports/SessionRepositoryPort';
|
||||
import type { ScreenAutomationPort } from '@gridpilot/automation/application/ports/ScreenAutomationPort';
|
||||
import type { AutomationEnginePort } from '@gridpilot/automation/application/ports/AutomationEnginePort';
|
||||
import type { AuthenticationServicePort } from '@gridpilot/automation/application/ports/AuthenticationServicePort';
|
||||
import type { CheckoutConfirmationPort } from '@gridpilot/automation/application/ports/CheckoutConfirmationPort';
|
||||
import type { LoggerPort } from '@gridpilot/automation/application/ports/LoggerPort';
|
||||
import type { OverlaySyncPort } from '@gridpilot/automation/application/ports/OverlaySyncPort';
|
||||
import type { IAutomationLifecycleEmitter } from '@/packages/automation/infrastructure/adapters/IAutomationLifecycleEmitter';
|
||||
import type { IOverlaySyncPort } from '@/packages/automation/application/ports/IOverlaySyncPort';
|
||||
import { OverlaySyncService } from '@/packages/automation/application/services/OverlaySyncService';
|
||||
|
||||
export interface BrowserConnectionResult {
|
||||
@@ -96,7 +96,7 @@ export function resolveTemplatePath(): string {
|
||||
* Create logger based on environment configuration.
|
||||
* In test environment, returns NoOpLogAdapter for silent logging.
|
||||
*/
|
||||
function createLogger(): ILogger {
|
||||
function createLogger(): LoggerPort {
|
||||
const config = loadLoggingConfig();
|
||||
|
||||
if (process.env.NODE_ENV === 'test') {
|
||||
@@ -204,10 +204,10 @@ function createBrowserAutomationAdapter(
|
||||
export class DIContainer {
|
||||
private static instance: DIContainer;
|
||||
|
||||
private logger: ILogger;
|
||||
private sessionRepository!: ISessionRepository;
|
||||
private logger: LoggerPort;
|
||||
private sessionRepository!: SessionRepositoryPort;
|
||||
private browserAutomation!: PlaywrightAutomationAdapter | MockBrowserAutomationAdapter;
|
||||
private automationEngine!: IAutomationEngine;
|
||||
private automationEngine!: AutomationEnginePort;
|
||||
private fixtureServer: FixtureServer | null = null;
|
||||
private startAutomationUseCase!: StartAutomationSessionUseCase;
|
||||
private checkAuthenticationUseCase: CheckAuthenticationUseCase | null = null;
|
||||
@@ -322,12 +322,12 @@ export class DIContainer {
|
||||
return this.startAutomationUseCase;
|
||||
}
|
||||
|
||||
public getSessionRepository(): ISessionRepository {
|
||||
public getSessionRepository(): SessionRepositoryPort {
|
||||
this.ensureInitialized();
|
||||
return this.sessionRepository;
|
||||
}
|
||||
|
||||
public getAutomationEngine(): IAutomationEngine {
|
||||
|
||||
public getAutomationEngine(): AutomationEnginePort {
|
||||
this.ensureInitialized();
|
||||
return this.automationEngine;
|
||||
}
|
||||
@@ -336,12 +336,12 @@ export class DIContainer {
|
||||
return this.automationMode;
|
||||
}
|
||||
|
||||
public getBrowserAutomation(): IScreenAutomation {
|
||||
public getBrowserAutomation(): ScreenAutomationPort {
|
||||
this.ensureInitialized();
|
||||
return this.browserAutomation;
|
||||
}
|
||||
|
||||
public getLogger(): ILogger {
|
||||
|
||||
public getLogger(): LoggerPort {
|
||||
return this.logger;
|
||||
}
|
||||
|
||||
@@ -360,16 +360,16 @@ export class DIContainer {
|
||||
return this.clearSessionUseCase;
|
||||
}
|
||||
|
||||
public getAuthenticationService(): IAuthenticationService | null {
|
||||
public getAuthenticationService(): AuthenticationServicePort | null {
|
||||
this.ensureInitialized();
|
||||
if (this.browserAutomation instanceof PlaywrightAutomationAdapter) {
|
||||
return this.browserAutomation as IAuthenticationService;
|
||||
return this.browserAutomation as AuthenticationServicePort;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public setConfirmCheckoutUseCase(
|
||||
checkoutConfirmationPort: ICheckoutConfirmationPort
|
||||
checkoutConfirmationPort: CheckoutConfirmationPort
|
||||
): void {
|
||||
this.ensureInitialized();
|
||||
// Create ConfirmCheckoutUseCase with checkout service from browser automation
|
||||
@@ -487,7 +487,7 @@ export class DIContainer {
|
||||
return this.browserModeConfigLoader;
|
||||
}
|
||||
|
||||
public getOverlaySyncPort(): IOverlaySyncPort {
|
||||
public getOverlaySyncPort(): OverlaySyncPort {
|
||||
this.ensureInitialized();
|
||||
if (!this.overlaySyncService) {
|
||||
// Use the browser automation adapter as the lifecycle emitter when available.
|
||||
@@ -542,7 +542,7 @@ export class DIContainer {
|
||||
|
||||
// Recreate authentication use-cases if adapter supports them, otherwise clear
|
||||
if (this.browserAutomation instanceof PlaywrightAutomationAdapter) {
|
||||
const authService = this.browserAutomation as IAuthenticationService;
|
||||
const authService = this.browserAutomation as AuthenticationServicePort;
|
||||
this.checkAuthenticationUseCase = new CheckAuthenticationUseCase(authService);
|
||||
this.initiateLoginUseCase = new InitiateLoginUseCase(authService);
|
||||
this.clearSessionUseCase = new ClearSessionUseCase(authService);
|
||||
|
||||
Reference in New Issue
Block a user