2025-08-08 16:01:56 +01:00
|
|
|
import { FileOperation } from '../types/fileContext';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates operation tracking data for FileContext integration
|
|
|
|
*/
|
|
|
|
export const createOperation = <TParams = void>(
|
|
|
|
operationType: string,
|
|
|
|
params: TParams,
|
|
|
|
selectedFiles: File[]
|
|
|
|
): { operation: FileOperation; operationId: string; fileId: string } => {
|
|
|
|
const operationId = `${operationType}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
|
|
const fileId = selectedFiles.map(f => f.name).join(',');
|
|
|
|
|
|
|
|
const operation: FileOperation = {
|
|
|
|
id: operationId,
|
|
|
|
type: operationType,
|
|
|
|
timestamp: Date.now(),
|
|
|
|
fileIds: selectedFiles.map(f => f.name),
|
|
|
|
status: 'pending',
|
|
|
|
metadata: {
|
|
|
|
originalFileName: selectedFiles[0]?.name,
|
|
|
|
parameters: params,
|
|
|
|
fileSize: selectedFiles.reduce((sum, f) => sum + f.size, 0)
|
|
|
|
}
|
2025-08-11 16:40:38 +01:00
|
|
|
} as any /* FIX ME*/;
|
2025-08-08 16:01:56 +01:00
|
|
|
|
|
|
|
return { operation, operationId, fileId };
|
2025-08-11 16:40:38 +01:00
|
|
|
};
|