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

Function executeTableSelectionNode

src/nodeExecutor.ts:614–672  ·  view source on GitHub ↗
(
  nodeId: string,
  textValue: string,
  inputData: PackFilesNodeData,
  executionContext?: FlowExecutionContext,
)

Source from the content-addressed store, hash-verified

612}
613
614async function executeTableSelectionNode(
615 nodeId: string,
616 textValue: string,
617 inputData: PackFilesNodeData,
618 executionContext?: FlowExecutionContext,
619): Promise<NodeExecutionResult> {
620 console.log(`TableSelection Node ${nodeId}: Processing "${textValue}" with input:`, inputData);
621
622 if (!inputData || inputData.type !== "PackFiles") {
623 return { success: false, error: "Invalid input: Expected PackFiles data" };
624 }
625
626 const tableNames = textValue
627 .split("\n")
628 .filter((line) => line.trim())
629 .map((name) => name.trim())
630 .map((name) => (name.startsWith("db\\") ? name : `db\\${name}`));
631 const selectedTables = [] as DBTablesNodeTable[];
632
633 for (const file of inputData.files) {
634 if (!file.loaded) {
635 console.warn(`Skipping unloaded file: ${file.path}`);
636 continue;
637 }
638
639 try {
640 const { pack, matchingTablesByName } = await getTableFilesForPackAndTables(
641 file.path,
642 tableNames,
643 executionContext,
644 );
645
646 for (const tableName of tableNames) {
647 const matchingTables = matchingTablesByName.get(tableName) || [];
648
649 for (const table of matchingTables) {
650 selectedTables.push({
651 name: tableName,
652 fileName: table.name,
653 sourceFile: pack,
654 table,
655 });
656 }
657 }
658 } catch (error) {
659 console.error(`Error reading pack file ${file.path}:`, error);
660 }
661 }
662
663 return {
664 success: true,
665 data: {
666 type: "TableSelection",
667 tables: selectedTables,
668 sourceFiles: inputData.files,
669 tableCount: selectedTables.length,
670 } as DBTablesNodeData,
671 };

Callers 1

executeNodeActionFunction · 0.85

Calls 2

getMethod · 0.65

Tested by

no test coverage detected