( nodeId: string, textValue: string, inputData: DBTablesNodeData, executionContext?: FlowExecutionContext, config?: unknown, )
| 1920 | } |
| 1921 | |
| 1922 | async function executeColumnSelectionDropdownNode( |
| 1923 | nodeId: string, |
| 1924 | textValue: string, |
| 1925 | inputData: DBTablesNodeData, |
| 1926 | executionContext?: FlowExecutionContext, |
| 1927 | config?: unknown, |
| 1928 | ): Promise<NodeExecutionResult> { |
| 1929 | const parsedConfig = getNodeConfig<{ selectedColumn?: string }>(config, textValue); |
| 1930 | const selectedColumn = parsedConfig?.selectedColumn ?? textValue; |
| 1931 | |
| 1932 | console.log( |
| 1933 | `ColumnSelection Dropdown Node ${nodeId}: Processing selected column "${selectedColumn}" with num input tables:`, |
| 1934 | inputData.tables.length, |
| 1935 | `table names:`, |
| 1936 | inputData.tables.map((t) => t.name), |
| 1937 | ); |
| 1938 | |
| 1939 | if (!inputData || inputData.type !== "TableSelection") { |
| 1940 | return { success: false, error: "Invalid input: Expected TableSelection data" }; |
| 1941 | } |
| 1942 | |
| 1943 | if (!selectedColumn || selectedColumn.trim() === "") { |
| 1944 | return { |
| 1945 | success: false, |
| 1946 | error: "No column selected. Please select a column from the dropdown.", |
| 1947 | }; |
| 1948 | } |
| 1949 | |
| 1950 | const selectedColumns = [selectedColumn.trim()]; |
| 1951 | const selectedColumnsSet = new Set(selectedColumns); |
| 1952 | const columnData = [] as DBColumnSelectionTableValues[]; |
| 1953 | |
| 1954 | for (const tableData of inputData.tables) { |
| 1955 | if ( |
| 1956 | tableData.table.tableSchema && |
| 1957 | tableData.table.schemaFields && |
| 1958 | tableData.table.schemaFields.length != 0 |
| 1959 | ) { |
| 1960 | const rows = getRowsForPackedFile(tableData.table, executionContext); |
| 1961 | const cellData = [] as { col: string; data: string }[]; |
| 1962 | for (const row of rows) { |
| 1963 | for (const cell of row) { |
| 1964 | if (selectedColumnsSet.has(cell.name)) { |
| 1965 | cellData.push({ col: cell.name, data: cell.resolvedKeyValue }); |
| 1966 | } |
| 1967 | } |
| 1968 | } |
| 1969 | columnData.push({ |
| 1970 | tableName: tableData.name, |
| 1971 | fileName: tableData.fileName, |
| 1972 | sourcePack: tableData.sourceFile, |
| 1973 | sourceTable: tableData.table, |
| 1974 | selectedColumns: selectedColumns, |
| 1975 | data: cellData, |
| 1976 | } as DBColumnSelectionTableValues); |
| 1977 | } |
| 1978 | } |
| 1979 |
no test coverage detected