( nodeId: string, textValue: string, inputData: PackFilesNodeData, executionContext?: FlowExecutionContext, config?: unknown, )
| 672 | } |
| 673 | |
| 674 | async function executeTableSelectionDropdownNode( |
| 675 | nodeId: string, |
| 676 | textValue: string, |
| 677 | inputData: PackFilesNodeData, |
| 678 | executionContext?: FlowExecutionContext, |
| 679 | config?: unknown, |
| 680 | ): Promise<NodeExecutionResult> { |
| 681 | const parsedConfig = getNodeConfig<{ selectedTable?: string }>(config, textValue); |
| 682 | const selectedTable = parsedConfig?.selectedTable ?? textValue; |
| 683 | |
| 684 | console.log( |
| 685 | `TableSelection Dropdown Node ${nodeId}: Processing selected table "${selectedTable}" with input:`, |
| 686 | inputData, |
| 687 | ); |
| 688 | |
| 689 | if (!inputData || inputData.type !== "PackFiles") { |
| 690 | return { success: false, error: "Invalid input: Expected PackFiles data" }; |
| 691 | } |
| 692 | |
| 693 | if (!selectedTable || selectedTable.trim() === "") { |
| 694 | return { |
| 695 | success: false, |
| 696 | error: "No table selected. Please select a table from the dropdown.", |
| 697 | }; |
| 698 | } |
| 699 | |
| 700 | // Convert the selected table name to the db\ format if needed |
| 701 | const tableName = selectedTable.startsWith("db\\") ? selectedTable : `db\\${selectedTable}`; |
| 702 | const selectedTables = [] as DBTablesNodeTable[]; |
| 703 | |
| 704 | for (const file of inputData.files) { |
| 705 | if (!file.loaded) { |
| 706 | console.warn(`Skipping unloaded file: ${file.path}`); |
| 707 | continue; |
| 708 | } |
| 709 | |
| 710 | try { |
| 711 | const { pack, matchingTablesByName } = await getTableFilesForPackAndTables( |
| 712 | file.path, |
| 713 | [tableName], |
| 714 | executionContext, |
| 715 | ); |
| 716 | const matchingTables = matchingTablesByName.get(tableName) || []; |
| 717 | |
| 718 | for (const table of matchingTables) { |
| 719 | // Limit to 300 rows for easier testing |
| 720 | const limitedTable = table; |
| 721 | // if (table.tableSchema && table.schemaFields) { |
| 722 | // const rows = chunkSchemaIntoRows(table.schemaFields, table.tableSchema) as AmendedSchemaField[][]; |
| 723 | |
| 724 | // if (rows.length > 300) { |
| 725 | // console.log( |
| 726 | // `TableSelection Dropdown Node ${nodeId}: Limiting ${tableName} from ${rows.length} rows to 300 rows` |
| 727 | // ); |
| 728 | // const limitedRows = rows.slice(0, 300); |
| 729 | // const limitedSchemaFields = limitedRows.flat(); |
| 730 | |
| 731 | // limitedTable = { |
no test coverage detected