(blockId: string)
| 9 | import type { TriggerConfig } from '@/triggers/types' |
| 10 | |
| 11 | async function fetchTableColumns(blockId: string): Promise<Array<{ label: string; id: string }>> { |
| 12 | const activeWorkflowId = useWorkflowRegistry.getState().activeWorkflowId |
| 13 | const workspaceId = useWorkflowRegistry.getState().hydration.workspaceId |
| 14 | if (!activeWorkflowId || !workspaceId) return [] |
| 15 | |
| 16 | const blockValues = useSubBlockStore.getState().workflowValues[activeWorkflowId]?.[blockId] |
| 17 | const tableId = (blockValues?.tableSelector as string) || (blockValues?.manualTableId as string) |
| 18 | if (!tableId) return [] |
| 19 | |
| 20 | const tables = await getQueryClient().fetchQuery({ |
| 21 | queryKey: tableKeys.list(workspaceId), |
| 22 | queryFn: async ({ signal }): Promise<TableDefinition[]> => { |
| 23 | const response = await requestJson(listTablesContract, { |
| 24 | query: { workspaceId, scope: 'active' }, |
| 25 | signal, |
| 26 | }) |
| 27 | return (response.data.tables ?? []) as TableDefinition[] |
| 28 | }, |
| 29 | staleTime: 60 * 1000, |
| 30 | }) |
| 31 | |
| 32 | const table = tables.find((t: TableDefinition) => t.id === tableId) |
| 33 | if (!table?.schema?.columns) return [] |
| 34 | |
| 35 | return table.schema.columns.map((col) => ({ id: col.name, label: col.name })) |
| 36 | } |
| 37 | |
| 38 | export const tableNewRowTrigger: TriggerConfig = { |
| 39 | id: 'table_new_row', |
nothing calls this directly
no test coverage detected