MCPcopy Create free account
hub / github.com/Shazbot/WH3-Mod-Manager / executeNumericAdjustmentNode

Function executeNumericAdjustmentNode

src/nodeExecutor.ts:1991–2182  ·  view source on GitHub ↗
(
  nodeId: string,
  textValue: string,
  inputData:
    | DBColumnSelectionNodeData
    | DBColumnSelectionNodeData[]
    | DBNumericAdjustmentNodeData
    | DBNumericAdjustmentNodeData[],
  executionContext?: FlowExecutionContext,
)

Source from the content-addressed store, hash-verified

1989}
1990
1991async function executeNumericAdjustmentNode(
1992 nodeId: string,
1993 textValue: string,
1994 inputData:
1995 | DBColumnSelectionNodeData
1996 | DBColumnSelectionNodeData[]
1997 | DBNumericAdjustmentNodeData
1998 | DBNumericAdjustmentNodeData[],
1999 executionContext?: FlowExecutionContext,
2000): Promise<NodeExecutionResult> {
2001 console.log(`NumericAdjustment Node ${nodeId}: Processing formula "${textValue}" with input:`, inputData);
2002
2003 // Convert single input to array for uniform handling
2004 const inputs = Array.isArray(inputData) ? inputData : [inputData];
2005
2006 if (inputs.length === 0) {
2007 return { success: false, error: "No inputs provided. Connect at least one node." };
2008 }
2009
2010 // Extract ColumnSelection data from inputs (handle both ColumnSelection and ChangedColumnSelection)
2011 const columnSelectionInputs: DBColumnSelectionNodeData[] = [];
2012 for (let i = 0; i < inputs.length; i++) {
2013 const input = inputs[i];
2014 if (!input) {
2015 return { success: false, error: `Invalid input at index ${i}: No data provided` };
2016 }
2017
2018 if (input.type === "ColumnSelection") {
2019 columnSelectionInputs.push(input as DBColumnSelectionNodeData);
2020 } else if (input.type === "ChangedColumnSelection") {
2021 columnSelectionInputs.push((input as DBNumericAdjustmentNodeData).adjustedInputData);
2022 } else {
2023 return {
2024 success: false,
2025 error: `Invalid input at index ${i}: Expected ColumnSelection or ChangedColumnSelection data`,
2026 };
2027 }
2028 }
2029
2030 // Merge all inputs if there are multiple
2031 let mergedInput: DBColumnSelectionNodeData;
2032 if (columnSelectionInputs.length === 1) {
2033 mergedInput = columnSelectionInputs[0];
2034 } else {
2035 hotPathLog(executionContext, `NumericAdjustment Node ${nodeId}: Merging ${columnSelectionInputs.length} inputs`);
2036
2037 // Collect unique tables and merge selectedColumns/data WITHOUT cloning yet
2038 // We'll clone once at the end when we apply the formula
2039 const tableMap = new Map<
2040 string,
2041 { column: any; selectedColumns: Set<string>; dataMap: Map<string, any> }
2042 >();
2043 const allSourceTables: any[] = [];
2044 const seenSourceTables = new Set<string>();
2045
2046 for (const input of columnSelectionInputs) {
2047 for (const column of input.columns) {
2048 const key = `${column.tableName}|${column.fileName}`;

Callers 1

executeNodeActionFunction · 0.85

Calls 5

hotPathLogFunction · 0.85
evaluateFormulaFunction · 0.85
getRowsForPackedFileFunction · 0.70
getMethod · 0.65
addMethod · 0.65

Tested by

no test coverage detected