diff --git a/src/main/controllers/automation.controller.ts b/src/main/controllers/automation.controller.ts new file mode 100644 index 0000000..b6edac9 --- /dev/null +++ b/src/main/controllers/automation.controller.ts @@ -0,0 +1,32 @@ +import { ipcMain, IpcMainInvokeEvent } from 'electron'; +import { LoggerService } from '../services/logger.service'; + +export function registerAutomationHandlers(): void { + LoggerService.info('Registering automation handlers'); + + ipcMain.handle('automation:clean', async (event: IpcMainInvokeEvent, params: any) => { + LoggerService.info('Clean automation requested'); + // TODO: Implement in Phase 4 + return { + success: false, + error: { code: 'NOT_IMPLEMENTED', message: 'Not yet implemented' }, + }; + }); + + ipcMain.handle('automation:extract', async (event: IpcMainInvokeEvent, params: any) => { + LoggerService.info('Extract automation requested'); + // TODO: Implement in Phase 4 + return { + success: false, + error: { code: 'NOT_IMPLEMENTED', message: 'Not yet implemented' }, + }; + }); + + ipcMain.handle('automation:stop', async (event: IpcMainInvokeEvent, params: any) => { + LoggerService.info('Stop automation requested'); + // TODO: Implement task cancellation + return { + success: true, + }; + }); +} diff --git a/src/main/index.ts b/src/main/index.ts index 92404fb..bda7194 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -2,6 +2,7 @@ import { app, shell, BrowserWindow, ipcMain } from 'electron' import { join } from 'path' import { electronApp, optimizer, is } from '@electron-toolkit/utils' import icon from '../../resources/icon.png?asset' +import { registerAutomationHandlers } from './controllers/automation.controller' function createWindow(): void { // Create the browser window. @@ -53,8 +54,9 @@ app.whenReady().then(() => { ipcMain.on('ping', () => console.log('pong')) // IPC Handler Registration + registerAutomationHandlers() // TODO: Register IPC handlers for: - // - automation:clean, automation:extract, automation:stop, automation:progress + // - automation:progress // - database:query-production-orders, database:query-materials-to-delete // - auth:login, auth:logout diff --git a/src/main/models/ipc.types.ts b/src/main/models/ipc.types.ts index 70dc5be..cbf1479 100644 --- a/src/main/models/ipc.types.ts +++ b/src/main/models/ipc.types.ts @@ -1,7 +1,18 @@ +/** + * Response structure for automation IPC handlers + */ +export interface AutomationResponse { + success: boolean; + error?: { + code: string; + message: string; + }; +} + export interface IPCChannels { - 'automation:clean': any; - 'automation:extract': any; - 'automation:stop': any; + 'automation:clean': () => Promise; + 'automation:extract': () => Promise; + 'automation:stop': () => Promise; 'automation:progress': any; 'database:query-production-orders': any; 'database:query-materials-to-delete': any;