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

Function transformTable

apps/sim/tools/shared/table.ts:6–38  ·  view source on GitHub ↗
(
  table: TableRow[] | Record<string, any> | string | null
)

Source from the content-addressed store, hash-verified

4 * Transforms a table from the store format to a key-value object.
5 */
6export const transformTable = (
7 table: TableRow[] | Record<string, any> | string | null
8): Record<string, any> => {
9 if (!table) return {}
10
11 if (typeof table === 'string') {
12 try {
13 const parsed = JSON.parse(table) as TableRow[] | Record<string, any>
14 return transformTable(parsed)
15 } catch {
16 return {}
17 }
18 }
19
20 if (Array.isArray(table)) {
21 return table.reduce(
22 (acc, row) => {
23 if (row.cells?.Key && row.cells?.Value !== undefined) {
24 const value = row.cells.Value
25 acc[row.cells.Key] = value
26 }
27 return acc
28 },
29 {} as Record<string, any>
30 )
31 }
32
33 if (typeof table === 'object') {
34 return table
35 }
36
37 return {}
38}

Callers 8

utils.test.tsFile · 0.90
request.tsFile · 0.90
processUrlFunction · 0.90
execute_command.tsFile · 0.90
list_sandboxes.tsFile · 0.90
create_sandbox.tsFile · 0.90
run_code.tsFile · 0.90
normalizeHeadersFunction · 0.90

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected