Fix-convert-V2 (#5147)

Custom processors can now return consume all inputs flag. This allows to
have many inputs to single output consumption

Fixed multi call conversion logic
This commit is contained in:
ConnorYoh
2025-12-03 17:39:49 +00:00
committed by GitHub
parent 5d827df08c
commit f2bffe2dc6
13 changed files with 207 additions and 87 deletions
@@ -158,8 +158,8 @@ export const executeToolOperationWithPrefix = async (
try {
// Check if tool uses custom processor (like Convert tool)
if (config.customProcessor) {
const resultFiles = await config.customProcessor(parameters, files);
return resultFiles;
const result = await config.customProcessor(parameters, files);
return result.files;
}
// Execute based on tool type
+12
View File
@@ -60,6 +60,18 @@ export const isWebFormat = (extension: string): boolean => {
return ['html', 'zip'].includes(extension.toLowerCase());
};
/**
* Checks if the given extension is an office format (Word, Excel, PowerPoint, OpenOffice)
* These formats use LibreOffice for conversion and require individual file processing
*/
export const isOfficeFormat = (extension: string): boolean => {
return [
'docx', 'doc', 'odt', // Word processors
'xlsx', 'xls', 'ods', // Spreadsheets
'pptx', 'ppt', 'odp' // Presentations
].includes(extension.toLowerCase());
};
/**
* Gets available target extensions for a given source extension
* Extracted from useConvertParameters to be reusable in automation settings
+23
View File
@@ -52,6 +52,29 @@ export function detectFileExtension(filename: string): string {
return extension;
}
/**
* Removes the file extension from a filename
* @param filename - The filename to process
* @param options - Options for processing
* @param options.preserveCase - If true, preserves original case. If false (default), converts to lowercase
* @returns Filename without extension
* @example
* getFilenameWithoutExtension('document.pdf') // 'document'
* getFilenameWithoutExtension('my.file.name.txt') // 'my.file.name'
* getFilenameWithoutExtension('REPORT.PDF', { preserveCase: true }) // 'REPORT'
*/
export function getFilenameWithoutExtension(
filename: string,
options: { preserveCase?: boolean } = {}
): string {
if (!filename || typeof filename !== 'string') return '';
const { preserveCase = false } = options;
const withoutExtension = filename.replace(/\.[^.]+$/, '');
return preserveCase ? withoutExtension : withoutExtension.toLowerCase();
}
/**
* Checks if a file is a PDF based on extension and MIME type
* @param file - File or file-like object with name and type properties