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

Function fetchTableSchema

apps/sim/tools/schema-enrichers.ts:7–31  ·  view source on GitHub ↗
(tableId: string)

Source from the content-addressed store, hash-verified

5const logger = createLogger('SchemaEnrichers')
6
7async function fetchTableSchema(tableId: string): Promise<TableSummary | null> {
8 try {
9 const { buildAuthHeaders, buildAPIUrl } = await import('@/executor/utils/http')
10
11 const headers = await buildAuthHeaders()
12 const url = buildAPIUrl(`/api/table/${tableId}/schema`)
13
14 const response = await fetch(url.toString(), { headers })
15 if (!response.ok) {
16 logger.warn(`Failed to fetch table schema for ${tableId}: ${response.status}`)
17 return null
18 }
19
20 const result = await response.json()
21 const data = result.data || result
22
23 return {
24 name: data.name || 'Table',
25 columns: data.columns || [],
26 }
27 } catch (error) {
28 logger.error('Failed to fetch table schema:', error)
29 return null
30 }
31}
32
33export async function enrichTableToolSchema(
34 tableId: string,

Callers 1

enrichTableToolSchemaFunction · 0.85

Calls 5

buildAPIUrlFunction · 0.85
errorMethod · 0.80
warnMethod · 0.65
buildAuthHeadersFunction · 0.50
toStringMethod · 0.45

Tested by

no test coverage detected