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

Function executeReferenceLookupNode

src/nodeExecutor.ts:1297–1537  ·  view source on GitHub ↗
(
  nodeId: string,
  textValue: string,
  inputData: DBTablesNodeData,
  config?: unknown,
  executionContext?: FlowExecutionContext,
)

Source from the content-addressed store, hash-verified

1295}
1296
1297async function executeReferenceLookupNode(
1298 nodeId: string,
1299 textValue: string,
1300 inputData: DBTablesNodeData,
1301 config?: unknown,
1302 executionContext?: FlowExecutionContext,
1303): Promise<NodeExecutionResult> {
1304 console.log(`Reference Lookup Node ${nodeId}: Processing with input tables:`, {
1305 tableCount: inputData?.tables?.length,
1306 tableNames: inputData?.tables?.map((t) => t.name),
1307 });
1308
1309 if (!inputData || inputData.type !== "TableSelection") {
1310 return { success: false, error: "Invalid input: Expected TableSelection data" };
1311 }
1312
1313 // Parse selected reference table and includeBaseGame from textValue
1314 const parsed = getNodeConfig<{ selectedReferenceTable?: string; includeBaseGame?: boolean }>(config, textValue);
1315 if (!parsed) {
1316 return { success: false, error: "Invalid node configuration" };
1317 }
1318 const selectedReferenceTable = parsed.selectedReferenceTable || "";
1319 const includeBaseGame = parsed.includeBaseGame !== false;
1320
1321 // Build source files list, potentially including base game
1322 const sourceFiles = [...(inputData.sourceFiles || [])];
1323
1324 if (includeBaseGame) {
1325 const baseGamePackName = gameToPackWithDBTablesName[appData.currentGame];
1326 if (baseGamePackName) {
1327 const baseGameFolder = appData.gamesToGameFolderPaths[appData.currentGame].dataFolder;
1328 if (baseGameFolder) {
1329 const baseGamePackPath = path.join(baseGameFolder, baseGamePackName);
1330 // Check if base game pack is not already in sourceFiles
1331 if (!sourceFiles.some((sf) => sf.path === baseGamePackPath)) {
1332 if (fs.existsSync(baseGamePackPath)) {
1333 sourceFiles.push({
1334 name: baseGamePackName,
1335 path: baseGamePackPath,
1336 loaded: true,
1337 });
1338 console.log(`Reference Lookup Node ${nodeId}: Added base game pack from ${baseGamePackPath}`);
1339 }
1340 }
1341 }
1342 }
1343 }
1344
1345 if (!selectedReferenceTable || selectedReferenceTable.trim() === "") {
1346 console.log(`Reference Lookup Node ${nodeId}: No reference table selected, returning empty result`);
1347 return {
1348 success: true,
1349 data: {
1350 type: "TableSelection",
1351 tables: [],
1352 sourceFiles: sourceFiles,
1353 tableCount: 0,
1354 } as DBTablesNodeData,

Callers 1

executeNodeActionFunction · 0.85

Calls 6

flowExecutionDebugLogFunction · 0.90
getNodeConfigFunction · 0.85
getRowsForPackedFileFunction · 0.70
addMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected