( nodeId: string, textValue: string, inputData: DBTablesNodeData, config?: unknown, executionContext?: FlowExecutionContext, )
| 1295 | } |
| 1296 | |
| 1297 | async 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, |
no test coverage detected