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

Function buildInputDataForTarget

src/nodeGraphExecutor.ts:234–317  ·  view source on GitHub ↗
(
  targetNode: SerializedNode,
  targetIncomingConnections: SerializedConnection[],
  executionResults: Map<string, NodeExecutionResult>,
  nodeMap: Map<string, SerializedNode>,
)

Source from the content-addressed store, hash-verified

232 };
233};
234const buildInputDataForTarget = (
235 targetNode: SerializedNode,
236 targetIncomingConnections: SerializedConnection[],
237 executionResults: Map<string, NodeExecutionResult>,
238 nodeMap: Map<string, SerializedNode>,
239) => {
240 if (
241 targetNode.type === "mergechanges" ||
242 targetNode.type === "numericadjustment" ||
243 targetNode.type === "mathmax" ||
244 targetNode.type === "mathceil"
245 ) {
246 const allInputs = targetIncomingConnections
247 .map((connection) => extractConnectionData(connection, executionResults, nodeMap))
248 .filter((data) => data !== null && data !== undefined);
249 return allInputs.length > 0 ? allInputs : null;
250 }
251 if (targetNode.type === "savechanges") {
252 const allTables: any[] = [];
253 const allSourceFiles: any[] = [];
254 let changedColumnSelectionData = null;
255 let textData = null;
256 for (const connection of targetIncomingConnections) {
257 const inputData = extractConnectionData(connection, executionResults, nodeMap);
258 if (inputData?.type === "Text" && !textData) {
259 textData = inputData;
260 } else if (inputData?.type === "TableSelection") {
261 if (inputData.tables) {
262 allTables.push(...inputData.tables);
263 }
264 if (inputData.sourceFiles) {
265 allSourceFiles.push(...inputData.sourceFiles);
266 }
267 } else if (inputData?.type === "ChangedColumnSelection" && !changedColumnSelectionData) {
268 changedColumnSelectionData = inputData;
269 }
270 }
271 if (textData) return textData;
272 if (changedColumnSelectionData) return changedColumnSelectionData;
273 if (allTables.length > 0) {
274 return {
275 type: "TableSelection",
276 tables: allTables,
277 sourceFiles: allSourceFiles,
278 tableCount: allTables.length,
279 };
280 }
281 return null;
282 }
283 if (targetNode.type === "lookup") {
284 const sourceConnection = targetIncomingConnections.find((connection) => connection.targetHandle === "input-source");
285 const indexConnection = targetIncomingConnections.find((connection) => connection.targetHandle === "input-index");
286 if (!sourceConnection || !indexConnection) {
287 return null;
288 }
289 return [
290 extractConnectionData(sourceConnection, executionResults, nodeMap),
291 extractConnectionData(indexConnection, executionResults, nodeMap),

Callers 1

executeNodeGraphFunction · 0.85

Calls 2

extractConnectionDataFunction · 0.85

Tested by

no test coverage detected