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

Function executeMathMaxNode

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

Source from the content-addressed store, hash-verified

2182}
2183
2184async function executeMathMaxNode(
2185 nodeId: string,
2186 textValue: string,
2187 inputData: DBNumericAdjustmentNodeData | DBNumericAdjustmentNodeData[],
2188 executionContext?: FlowExecutionContext,
2189): Promise<NodeExecutionResult> {
2190 console.log(`MathMax Node ${nodeId}: Processing with value "${textValue}" and input:`, inputData);
2191
2192 // Convert single input to array for uniform handling
2193 const inputs = Array.isArray(inputData) ? inputData : [inputData];
2194
2195 if (inputs.length === 0) {
2196 return { success: false, error: "No inputs provided. Connect at least one node." };
2197 }
2198
2199 // Validate all inputs are ChangedColumnSelection
2200 for (let i = 0; i < inputs.length; i++) {
2201 if (!inputs[i] || inputs[i].type !== "ChangedColumnSelection") {
2202 return {
2203 success: false,
2204 error: `Invalid input at index ${i}: Expected ChangedColumnSelection data`,
2205 };
2206 }
2207 }
2208
2209 // Merge all inputs if there are multiple
2210 let mergedInputData: DBColumnSelectionNodeData;
2211 let originalData: DBColumnSelectionNodeData;
2212
2213 if (inputs.length === 1) {
2214 mergedInputData = inputs[0].adjustedInputData;
2215 originalData = inputs[0].originalData;
2216 } else {
2217 // Start with a deep clone of the first input as the base
2218 mergedInputData = structuredClone(inputs[0].adjustedInputData);
2219 originalData = inputs[0].originalData;
2220
2221 // Merge all subsequent inputs
2222 for (let i = 1; i < inputs.length; i++) {
2223 const currentInput = inputs[i].adjustedInputData;
2224
2225 // For each table in the current input, merge with the corresponding table in mergedInputData
2226 for (const currentColumn of currentInput.columns) {
2227 // Find if this table already exists in mergedInputData
2228 const existingColumn = mergedInputData.columns.find(
2229 (col) => col.tableName === currentColumn.tableName && col.fileName === currentColumn.fileName,
2230 );
2231
2232 if (existingColumn) {
2233 // Merge the changes from currentColumn into existingColumn
2234 if (
2235 currentColumn.sourceTable.schemaFields &&
2236 existingColumn.sourceTable.schemaFields &&
2237 currentColumn.sourceTable.tableSchema &&
2238 existingColumn.sourceTable.tableSchema
2239 ) {
2240 // Merge schemaFields row by row
2241 const currentRows = getRowsForPackedFile(currentColumn.sourceTable, executionContext);

Callers 1

executeNodeActionFunction · 0.85

Calls 4

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

Tested by

no test coverage detected