MCPcopy Index your code
hub / github.com/simstudioai/sim / useTablesList

Function useTablesList

apps/sim/hooks/queries/tables.ts:211–239  ·  view source on GitHub ↗
(
  workspaceId?: string,
  scope: TableQueryScope = 'active',
  options?: {
    /** Poll cadence, or a predicate over the current list that returns a cadence (or `false`). */
    refetchInterval?: number | false | ((tables: TableDefinition[] | undefined) => number | false)
  }
)

Source from the content-addressed store, hash-verified

209 * Fetch all tables for a workspace.
210 */
211export function useTablesList(
212 workspaceId?: string,
213 scope: TableQueryScope = 'active',
214 options?: {
215 /** Poll cadence, or a predicate over the current list that returns a cadence (or `false`). */
216 refetchInterval?: number | false | ((tables: TableDefinition[] | undefined) => number | false)
217 }
218) {
219 const refetchInterval = options?.refetchInterval
220 return useQuery({
221 queryKey: tableKeys.list(workspaceId, scope),
222 queryFn: async ({ signal }) => {
223 if (!workspaceId) throw new Error('Workspace ID required')
224
225 const response = await requestJson(listTablesContract, {
226 query: { workspaceId, scope },
227 signal,
228 })
229 return response.data.tables
230 },
231 enabled: Boolean(workspaceId),
232 staleTime: 30 * 1000,
233 placeholderData: keepPreviousData,
234 refetchInterval:
235 typeof refetchInterval === 'function'
236 ? (query) => refetchInterval(query.state.data)
237 : (refetchInterval ?? false),
238 })
239}
240
241/**
242 * Fetch a single table by id.

Callers 12

useMarkdownMentionsFunction · 0.90
TablesFunction · 0.90
useWorkspaceImportsFunction · 0.90
SimResourceCellFunction · 0.90
SuggestedActionsFunction · 0.90
useAvailableResourcesFunction · 0.90
useResourceNameLookupFunction · 0.90
WorkspaceResourceDisplayFunction · 0.90
RecentlyDeletedFunction · 0.90
sidebar.tsxFile · 0.90
TableSelectorFunction · 0.90
workflow-block.tsxFile · 0.90

Calls 1

requestJsonFunction · 0.90

Tested by

no test coverage detected