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

Function executeDeduplicateNode

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

Source from the content-addressed store, hash-verified

4488}
4489
4490async function executeDeduplicateNode(
4491 nodeId: string,
4492 textValue: string,
4493 inputData: DBTablesNodeData,
4494 config?: unknown,
4495 executionContext?: FlowExecutionContext,
4496): Promise<NodeExecutionResult> {
4497 console.log(`Deduplicate Node ${nodeId}: Processing with input tables:`, {
4498 tableCount: inputData?.tables?.length,
4499 tableNames: inputData?.tables?.map((t) => t.name),
4500 });
4501
4502 if (!inputData || inputData.type !== "TableSelection") {
4503 return { success: false, error: "Invalid input: Expected TableSelection data" };
4504 }
4505
4506 // Parse configuration from textValue
4507 const parsed = getNodeConfig<{ dedupeByColumns?: string[]; dedupeAgainstVanilla?: boolean }>(config, textValue);
4508 if (!parsed) {
4509 return { success: false, error: "Invalid deduplicate configuration" };
4510 }
4511 const dedupeByColumns = parsed.dedupeByColumns || [];
4512 const dedupeAgainstVanilla = parsed.dedupeAgainstVanilla || false;
4513
4514 console.log(
4515 `Deduplicate Node ${nodeId}: dedupeByColumns: [${dedupeByColumns.join(", ")}], dedupeAgainstVanilla: ${dedupeAgainstVanilla}`,
4516 );
4517
4518 if (dedupeByColumns.length === 0) {
4519 return { success: false, error: "No dedupe by columns specified" };
4520 }
4521
4522 const dedupedTables = [] as DBTablesNodeTable[];
4523 const inputTableToDupes = new Map<number, Set<number>>();
4524 const alreadyPresentRowHashes = new Set<number>();
4525
4526 // If dedupeAgainstVanilla is enabled, build a set of vanilla row hashes
4527 const vanillaRowHashes = new Set<number>();
4528 if (dedupeAgainstVanilla) {
4529 console.log(`Deduplicate Node ${nodeId}: Building vanilla row hashes...`);
4530
4531 // Get the base game pack path
4532 const baseGamePackName = gameToPackWithDBTablesName[appData.currentGame];
4533 if (baseGamePackName) {
4534 const baseGameFolder = appData.gamesToGameFolderPaths[appData.currentGame].dataFolder;
4535 if (baseGameFolder) {
4536 const baseGamePackPath = path.join(baseGameFolder, baseGamePackName);
4537 if (fs.existsSync(baseGamePackPath)) {
4538 // Get unique table names from input data
4539 const tableNamesToRead = new Set<string>();
4540 for (const tableData of inputData.tables) {
4541 tableNamesToRead.add(tableData.name);
4542 }
4543
4544 console.log(
4545 `Deduplicate Node ${nodeId}: Reading vanilla tables: [${Array.from(tableNamesToRead).join(", ")}]`,
4546 );
4547

Callers 1

executeNodeActionFunction · 0.85

Calls 7

getPacksTableDataFunction · 0.90
cyrb53Function · 0.90
getNodeConfigFunction · 0.85
readPackCachedFunction · 0.85
getRowsForPackedFileFunction · 0.70
addMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected