diff --git a/server-node/src/routes/api/dynamic-operations-controller.ts b/server-node/src/routes/api/dynamic-operations-controller.ts index ff124328b..f5ac99507 100644 --- a/server-node/src/routes/api/dynamic-operations-controller.ts +++ b/server-node/src/routes/api/dynamic-operations-controller.ts @@ -29,7 +29,7 @@ function handleEndpoint(req: Request, res: Response) { pdfFiles = PdfFile.fromMulterFiles(Object.values(req.files).flatMap(va => va)); } - const operator: typeof Operator = getOperatorByName(req.params.func); + const operator = getOperatorByName(req.params.func); if(operator) { const operation = new operator({type: req.params.func, values: req.body}); const validationResults = operation.validate(); diff --git a/shared-operations/src/workflow/getOperatorByName.ts b/shared-operations/src/workflow/getOperatorByName.ts index f7da50479..179a7b093 100644 --- a/shared-operations/src/workflow/getOperatorByName.ts +++ b/shared-operations/src/workflow/getOperatorByName.ts @@ -7,8 +7,8 @@ export const Operators = { } // TODO: Convert this to a map or similar -export function getOperatorByName(name: string): typeof Operator { - let foundClass: typeof Operator = null; +export function getOperatorByName(name: string): typeof Operator | undefined { + let foundClass: typeof Operator | undefined = undefined; // Loop over each default export Object.entries(Operators).some(([className, exportedClass]) => { @@ -27,5 +27,5 @@ export function getOperatorByName(name: string): typeof Operator { export function listOperatorNames(): string[] { // TODO: Implement this - return + return []; } \ No newline at end of file diff --git a/shared-operations/src/workflow/traverseOperations.ts b/shared-operations/src/workflow/traverseOperations.ts index fc4faed46..a2f3e50cd 100644 --- a/shared-operations/src/workflow/traverseOperations.ts +++ b/shared-operations/src/workflow/traverseOperations.ts @@ -18,17 +18,14 @@ export async function traverseOperations(operations: Action[], input: PdfFile[], return results; async function nextOperation(actions: Action[] | undefined, input: PdfFile[], progressCallback: (state: Progress) => void): Promise { - console.log("Next Operation"); - if(actions === undefined || (Array.isArray(actions) && actions.length == 0)) { // isEmpty - console.log("Last Operation"); - if(Array.isArray(input)) { - console.log("ArrayOut: ", input); + if(!actions || (Array.isArray(actions) && actions.length == 0)) { // isEmpty + if(input && Array.isArray(input)) { console.log("operation done: " + input[0].filename + (input.length > 1 ? "+" : "")); results = results.concat(input); - return; } + return; } - + for (let i = 0; i < actions.length; i++) { await computeOperation(actions[i], Object.assign([], input), progressCallback); // structuredClone-like for ts TODO: test if this really works }