import type { FileAPI, ExtractorAPI, CleanerAPI, DatabaseAPI, ReportAPI } from '../main/types/ipc-api.types' import type { ResolverInput, ResolverResponse } from '../main/types/resolver-ipc.types' import type { UserInfo } from '../main/types/user.types' import type { CurrentUserResponse, LoginRequest, LoginResponse, SilentLoginResponse, UserSelectionResponse } from '../main/types/auth-ipc.types' import type { ValidationRequest, ValidationResponse, MaterialTypeRecord, MaterialTypeBatchRequest } from '../main/types/validation.types' import type { UserType, ConnectionTestResult, SaveSettingsResult } from '../main/types/settings.types' import type { IpcResult } from '../main/types/ipc.types' import type { LogLevel } from '../shared/ipc-channels' import type { CleanerConfig } from '../main/types/config.schema' import type { DownloadReleaseRequest, UpdateDialogCatalog, UpdateStatus } from '../main/types/update.types' export interface ResolverAPI { resolve: (input: ResolverInput) => Promise> validateFormat: ( inputs: string[] ) => Promise< IpcResult> > } export interface AuthAPI { getComputerName: () => Promise> silentLogin: () => Promise> login: (request: LoginRequest) => Promise> logout: () => Promise> getCurrentUser: () => Promise> getAllUsers: () => Promise> switchUser: (userInfo: UserInfo) => Promise> isAdmin: () => Promise> } export interface ValidationAPI { validate: (request: ValidationRequest) => Promise> setSharedProductionIds: (productionIds: string[]) => Promise> getSharedProductionIds: () => Promise> clearSharedProductionIds: () => Promise> getCleanerData: () => Promise< IpcResult<{ orderNumbers: string[] materialCodes: string[] }> > } export interface MaterialsAPI { upsertBatch: ( materials: { materialCode: string; managerName: string }[] ) => Promise> delete: (materialCodes: string[]) => Promise> getManagers: () => Promise> getByManager: (managerName: string) => Promise> getAll: () => Promise> getStatistics: () => Promise> updateManager: ( materialCode: string, managerName: string ) => Promise> } export interface SettingsAPI { getUserType: () => Promise> getSettings: () => Promise> saveSettings: (settings: { erp?: { username?: string; password?: string } }) => Promise> resetDefaults: () => Promise> testDbConnection: () => Promise> } export interface MaterialTypeAPI { getAll: () => Promise> getByManager: (managerName: string) => Promise> getManagers: () => Promise> upsert: (materialName: string, managerName: string) => Promise> delete: (materialName: string, managerName: string) => Promise> upsertBatch: ( request: MaterialTypeBatchRequest ) => Promise> } export interface UserErpConfigAPI { getCurrent: () => Promise< IpcResult<{ config: { url: string; username: string; password: string } }> > update: (config: { url: string; username: string; password: string }) => Promise< IpcResult<{ config: { url: string; username: string; password: string } }> > testConnection: (config: { url: string username: string password: string }) => Promise> getAll: () => Promise>> } export interface ConfigAPI { getCleaner: () => Promise> updateCleaner: (updates: Partial) => Promise> } export interface LoggerAPI { log: (level: LogLevel, message: string, context?: Record) => void } export interface UpdateAPI { getStatus: () => Promise> checkNow: () => Promise> getCatalog: () => Promise> getChangelog: (release: DownloadReleaseRequest) => Promise> downloadRelease: (release: DownloadReleaseRequest) => Promise> installDownloaded: () => Promise> onStatusChanged: (callback: (data: UpdateStatus) => void) => () => void } export interface DownloadProgress { percent: number // 0-100 downloadedBytes: number totalBytes: number currentFile: string speed: number // bytes/s eta?: number // seconds } export interface PlaywrightBrowserAPI { download: () => Promise> cancel: () => Promise> onProgress: (callback: (data: DownloadProgress) => void) => () => void } export interface ProcessAPI { versions: { electron: string chrome: string node: string } } declare global { interface Window { electron: { process: ProcessAPI file: FileAPI extractor: ExtractorAPI cleaner: CleanerAPI database: DatabaseAPI resolver: ResolverAPI auth: AuthAPI validation: ValidationAPI materials: MaterialsAPI settings: SettingsAPI materialType: MaterialTypeAPI userErpConfig: UserErpConfigAPI config: ConfigAPI logger: LoggerAPI report: ReportAPI update: UpdateAPI playwrightBrowser: PlaywrightBrowserAPI } api: unknown } }