( nodeId: string, inputData: DBNumericAdjustmentNodeData | DBNumericAdjustmentNodeData[], executionContext?: FlowExecutionContext, )
| 2359 | } |
| 2360 | |
| 2361 | async function executeMathCeilNode( |
| 2362 | nodeId: string, |
| 2363 | inputData: DBNumericAdjustmentNodeData | DBNumericAdjustmentNodeData[], |
| 2364 | executionContext?: FlowExecutionContext, |
| 2365 | ): Promise<NodeExecutionResult> { |
| 2366 | console.log(`MathCeil Node ${nodeId}: Processing with input:`, inputData); |
| 2367 | |
| 2368 | // Convert single input to array for uniform handling |
| 2369 | const inputs = Array.isArray(inputData) ? inputData : [inputData]; |
| 2370 | |
| 2371 | if (inputs.length === 0) { |
| 2372 | return { success: false, error: "No inputs provided. Connect at least one node." }; |
| 2373 | } |
| 2374 | |
| 2375 | // Validate all inputs are ChangedColumnSelection |
| 2376 | for (let i = 0; i < inputs.length; i++) { |
| 2377 | if (!inputs[i] || inputs[i].type !== "ChangedColumnSelection") { |
| 2378 | return { |
| 2379 | success: false, |
| 2380 | error: `Invalid input at index ${i}: Expected ChangedColumnSelection data`, |
| 2381 | }; |
| 2382 | } |
| 2383 | } |
| 2384 | |
| 2385 | // Merge all inputs if there are multiple |
| 2386 | let mergedInputData: DBColumnSelectionNodeData; |
| 2387 | let originalData: DBColumnSelectionNodeData; |
| 2388 | |
| 2389 | if (inputs.length === 1) { |
| 2390 | mergedInputData = inputs[0].adjustedInputData; |
| 2391 | originalData = inputs[0].originalData; |
| 2392 | } else { |
| 2393 | // Start with a deep clone of the first input as the base |
| 2394 | mergedInputData = structuredClone(inputs[0].adjustedInputData); |
| 2395 | originalData = inputs[0].originalData; |
| 2396 | |
| 2397 | // Merge all subsequent inputs |
| 2398 | for (let i = 1; i < inputs.length; i++) { |
| 2399 | const currentInput = inputs[i].adjustedInputData; |
| 2400 | |
| 2401 | // For each table in the current input, merge with the corresponding table in mergedInputData |
| 2402 | for (const currentColumn of currentInput.columns) { |
| 2403 | // Find if this table already exists in mergedInputData |
| 2404 | const existingColumn = mergedInputData.columns.find( |
| 2405 | (col) => col.tableName === currentColumn.tableName && col.fileName === currentColumn.fileName, |
| 2406 | ); |
| 2407 | |
| 2408 | if (existingColumn) { |
| 2409 | // Merge the changes from currentColumn into existingColumn |
| 2410 | if ( |
| 2411 | currentColumn.sourceTable.schemaFields && |
| 2412 | existingColumn.sourceTable.schemaFields && |
| 2413 | currentColumn.sourceTable.tableSchema && |
| 2414 | existingColumn.sourceTable.tableSchema |
| 2415 | ) { |
| 2416 | // Merge schemaFields row by row |
| 2417 | const currentRows = getRowsForPackedFile(currentColumn.sourceTable, executionContext); |
| 2418 | const existingRows = getRowsForPackedFile(existingColumn.sourceTable, executionContext); |
no test coverage detected