import type { Page } from "playwright"; import type { ArtifactRef, DiagnosticsMode, EVisaEvent, HtmlResult, PdfOutputMode, Purpose, TwoFactorMethod } from "../types.js"; import type { PageClassification } from "./page-classifier.js"; export type { TwoFactorMethod } from "../types.js"; export type InternalAuthMethod = { type: "passport"; passportNumber: string; } | { type: "nationalId"; idNumber: string; } | { type: "brc"; cardNumber: string; } | { type: "ukvi"; customerNumber: string; }; export type AuthMethod = InternalAuthMethod; export interface InternalCredentials { auth: InternalAuthMethod; dateOfBirth: { day: number; month: number; year: number; }; preferredTwoFactorMethod?: TwoFactorMethod; } export interface InternalRunOptions { headless: boolean; verbose: boolean; pdfEnabled: boolean; pdfOutput: PdfOutputMode; pdfMaxBytes: number; outputDir: string; outputFile: string; userDataDir: string; diagnosticsMode: DiagnosticsMode; diagnosticsDir: string; navigationTimeoutMs: number; actionTimeoutMs: number; twoFactorTimeoutMs: number; } export type RunOptions = InternalRunOptions; export interface InternalRunResult { shareCode: string; validUntil?: Date; pdfPath?: string; pdfBytes?: Uint8Array; pdfFilename?: string; checkerHtml?: HtmlResult; checkerHtmlArtifact?: ArtifactRef; summary?: { name?: string; nationality?: string; status?: string; }; artifacts?: ArtifactRef[]; } export type RunResult = InternalRunResult; export interface ExtractedData { name?: string; dateOfBirth?: string; nationality?: string; status?: string; validFrom?: string; validUntilText?: string; summary?: Record; checkerHtml?: HtmlResult; checkerHtmlArtifact?: ArtifactRef; } export interface StepContext { credentials: InternalCredentials; purpose: Purpose; options: InternalRunOptions; logger: Logger; page: Page; signal?: AbortSignal; extractedData: ExtractedData; classification?: PageClassification; setResult: (result: InternalRunResult) => void; addArtifacts: (artifacts: ArtifactRef[]) => void; emit: (event: EVisaEvent) => void; onTwoFactorRequired: (method: TwoFactorMethod, context: { deadlineMs: number; signal: AbortSignal; }) => Promise; } export interface Step { id: string; execute(context: StepContext): Promise; } export interface Logger { step(stepId: string, message: string): void; action(action: string, detail?: string): void; info(message: string, meta?: Record): void; warn(message: string, meta?: Record): void; error(message: string, meta?: Record): void; debug(message: string, meta?: Record): void; screenshot(label: string): void; }