Feature/v2/automate (#4248)

* automate feature
* Moved all providers to app level to simplify homepage 
* Circular dependency fixes
* You will see that now toolRegistry gets a tool config and a tool
settings object. These enable automate to run the tools using as much
static code as possible.

---------

Co-authored-by: Connor Yoh <[email protected]>
This commit is contained in:
ConnorYoh
2025-08-22 14:40:27 +01:00
committed by GitHub
co-authored by Connor Yoh
parent 7d9c0b0298
commit 23d86deae7
84 changed files with 4784 additions and 572 deletions
+70
View File
@@ -0,0 +1,70 @@
/**
* Types for automation functionality
*/
export interface AutomationOperation {
operation: string;
parameters: Record<string, any>;
}
export interface AutomationConfig {
id: string;
name: string;
description?: string;
operations: AutomationOperation[];
createdAt: string;
updatedAt: string;
}
export interface AutomationTool {
id: string;
operation: string;
name: string;
configured: boolean;
parameters?: Record<string, any>;
}
export interface AutomationStepData {
step: 'selection' | 'creation' | 'run';
mode?: AutomationMode;
automation?: AutomationConfig;
}
export interface ExecutionStep {
id: string;
operation: string;
name: string;
status: 'pending' | 'running' | 'completed' | 'error';
error?: string;
}
export interface AutomationExecutionCallbacks {
onStepStart?: (stepIndex: number, operationName: string) => void;
onStepComplete?: (stepIndex: number, resultFiles: File[]) => void;
onStepError?: (stepIndex: number, error: string) => void;
}
export interface AutomateParameters extends AutomationExecutionCallbacks {
automationConfig?: AutomationConfig;
}
export enum AutomationMode {
CREATE = 'create',
EDIT = 'edit',
SUGGESTED = 'suggested'
}
export interface SuggestedAutomation {
id: string;
name: string;
description?: string;
operations: AutomationOperation[];
createdAt: string;
updatedAt: string;
icon: any; // MUI Icon component
}
// Export the AutomateParameters interface that was previously defined inline
export interface AutomateParameters extends AutomationExecutionCallbacks {
automationConfig?: AutomationConfig;
}
+42
View File
@@ -0,0 +1,42 @@
/**
* Shared navigation types to avoid circular dependencies
*/
// Navigation mode types - complete list to match contexts
export type ModeType =
| 'viewer'
| 'pageEditor'
| 'fileEditor'
| 'merge'
| 'split'
| 'compress'
| 'ocr'
| 'convert'
| 'sanitize'
| 'addPassword'
| 'changePermissions'
| 'addWatermark'
| 'removePassword'
| 'single-large-page'
| 'repair'
| 'unlockPdfForms'
| 'removeCertificateSign';
// Utility functions for mode handling
export const isValidMode = (mode: string): mode is ModeType => {
const validModes: ModeType[] = [
'viewer', 'pageEditor', 'fileEditor', 'merge', 'split',
'compress', 'ocr', 'convert', 'addPassword', 'changePermissions',
'sanitize', 'addWatermark', 'removePassword', 'single-large-page',
'repair', 'unlockPdfForms', 'removeCertificateSign'
];
return validModes.includes(mode as ModeType);
};
export const getDefaultMode = (): ModeType => 'pageEditor';
// Route parsing result
export interface ToolRoute {
mode: ModeType;
toolKey: string | null;
}
+21
View File
@@ -0,0 +1,21 @@
/**
* Navigation action interfaces to break circular dependencies
*/
import { ModeType } from './navigation';
export interface NavigationActions {
setMode: (mode: ModeType) => void;
setHasUnsavedChanges: (hasChanges: boolean) => void;
showNavigationWarning: (show: boolean) => void;
requestNavigation: (navigationFn: () => void) => void;
confirmNavigation: () => void;
cancelNavigation: () => void;
}
export interface NavigationState {
currentMode: ModeType;
hasUnsavedChanges: boolean;
pendingNavigation: (() => void) | null;
showNavigationWarning: boolean;
}
+24
View File
@@ -1,4 +1,5 @@
import React from 'react';
import { ToolOperationHook } from '../hooks/tools/shared/useToolOperation';
export type MaxFiles = number; // 1=single, >1=limited, -1=unlimited
export type ToolCategory = 'manipulation' | 'conversion' | 'analysis' | 'utility' | 'optimization' | 'security';
@@ -11,6 +12,29 @@ export interface BaseToolProps {
onPreviewFile?: (file: File | null) => void;
}
/**
* Interface for tool components that support automation.
* Tools implementing this interface can be used in automation workflows.
*/
export interface AutomationCapableTool {
/**
* Static method that returns the operation hook for this tool.
* This enables automation to execute the tool programmatically.
*/
tool: () => () => ToolOperationHook<any>;
/**
* Static method that returns the default parameters for this tool.
* This enables automation creation to initialize tools with proper defaults.
*/
getDefaultParameters: () => any;
}
/**
* Type for tool components that can be used in automation
*/
export type ToolComponent = React.ComponentType<BaseToolProps> & AutomationCapableTool;
export interface ToolStepConfig {
type: ToolStepType;
title: string;