Skip to content

Commit 46b04a9

Browse files
authored
feat(supabase): added ability so select certain rows in supabase tools (#2689)
* feat(supabase): added ability so select certain rows in supabase tools * ack PR comments
1 parent 964b40d commit 46b04a9

File tree

6 files changed

+31
-4
lines changed

6 files changed

+31
-4
lines changed

apps/docs/content/docs/en/tools/kalshi.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@ Retrieve your account balance and portfolio value from Kalshi
126126
| --------- | ---- | ----------- |
127127
| `balance` | number | Account balance in cents |
128128
| `portfolioValue` | number | Portfolio value in cents |
129-
| `balanceDollars` | number | Account balance in dollars |
130-
| `portfolioValueDollars` | number | Portfolio value in dollars |
131129

132130
### `kalshi_get_positions`
133131

apps/docs/content/docs/en/tools/supabase.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Query data from a Supabase table
5353
| `projectId` | string | Yes | Your Supabase project ID \(e.g., jdrkgepadsdopsntdlom\) |
5454
| `table` | string | Yes | The name of the Supabase table to query |
5555
| `schema` | string | No | Database schema to query from \(default: public\). Use this to access tables in other schemas. |
56+
| `select` | string | No | Columns to return \(comma-separated\). Defaults to * \(all columns\) |
5657
| `filter` | string | No | PostgREST filter \(e.g., "id=eq.123"\) |
5758
| `orderBy` | string | No | Column to order by \(add DESC for descending\) |
5859
| `limit` | number | No | Maximum number of rows to return |
@@ -97,6 +98,7 @@ Get a single row from a Supabase table based on filter criteria
9798
| `projectId` | string | Yes | Your Supabase project ID \(e.g., jdrkgepadsdopsntdlom\) |
9899
| `table` | string | Yes | The name of the Supabase table to query |
99100
| `schema` | string | No | Database schema to query from \(default: public\). Use this to access tables in other schemas. |
101+
| `select` | string | No | Columns to return \(comma-separated\). Defaults to * \(all columns\) |
100102
| `filter` | string | Yes | PostgREST filter to find the specific row \(e.g., "id=eq.123"\) |
101103
| `apiKey` | string | Yes | Your Supabase service role secret key |
102104

apps/sim/blocks/blocks/supabase.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,16 @@ export const SupabaseBlock: BlockConfig<SupabaseResponse> = {
7979
value: ['query', 'get_row', 'insert', 'update', 'delete', 'upsert', 'count', 'text_search'],
8080
},
8181
},
82+
{
83+
id: 'select',
84+
title: 'Select Columns',
85+
type: 'short-input',
86+
placeholder: '* (all columns) or id,name,email',
87+
condition: {
88+
field: 'operation',
89+
value: ['query', 'get_row'],
90+
},
91+
},
8292
{
8393
id: 'apiKey',
8494
title: 'Service Role Secret',
@@ -1044,6 +1054,7 @@ Return ONLY the PostgREST filter expression - no explanations, no markdown, no e
10441054
projectId: { type: 'string', description: 'Supabase project identifier' },
10451055
table: { type: 'string', description: 'Database table name' },
10461056
schema: { type: 'string', description: 'Database schema (default: public)' },
1057+
select: { type: 'string', description: 'Columns to return (comma-separated, defaults to *)' },
10471058
apiKey: { type: 'string', description: 'Service role secret key' },
10481059
// Data for insert/update operations
10491060
data: { type: 'json', description: 'Row data' },

apps/sim/tools/supabase/get_row.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ export const getRowTool: ToolConfig<SupabaseGetRowParams, SupabaseGetRowResponse
2727
description:
2828
'Database schema to query from (default: public). Use this to access tables in other schemas.',
2929
},
30+
select: {
31+
type: 'string',
32+
required: false,
33+
visibility: 'user-or-llm',
34+
description: 'Columns to return (comma-separated). Defaults to * (all columns)',
35+
},
3036
filter: {
3137
type: 'string',
3238
required: true,
@@ -44,7 +50,8 @@ export const getRowTool: ToolConfig<SupabaseGetRowParams, SupabaseGetRowResponse
4450
request: {
4551
url: (params) => {
4652
// Construct the URL for the Supabase REST API
47-
let url = `https://${params.projectId}.supabase.co/rest/v1/${params.table}?select=*`
53+
const selectColumns = params.select?.trim() || '*'
54+
let url = `https://${params.projectId}.supabase.co/rest/v1/${params.table}?select=${encodeURIComponent(selectColumns)}`
4855

4956
// Add filters (required for get_row) - using PostgREST syntax
5057
if (params.filter?.trim()) {

apps/sim/tools/supabase/query.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ export const queryTool: ToolConfig<SupabaseQueryParams, SupabaseQueryResponse> =
2727
description:
2828
'Database schema to query from (default: public). Use this to access tables in other schemas.',
2929
},
30+
select: {
31+
type: 'string',
32+
required: false,
33+
visibility: 'user-or-llm',
34+
description: 'Columns to return (comma-separated). Defaults to * (all columns)',
35+
},
3036
filter: {
3137
type: 'string',
3238
required: false,
@@ -56,7 +62,8 @@ export const queryTool: ToolConfig<SupabaseQueryParams, SupabaseQueryResponse> =
5662
request: {
5763
url: (params) => {
5864
// Construct the URL for the Supabase REST API
59-
let url = `https://${params.projectId}.supabase.co/rest/v1/${params.table}?select=*`
65+
const selectColumns = params.select?.trim() || '*'
66+
let url = `https://${params.projectId}.supabase.co/rest/v1/${params.table}?select=${encodeURIComponent(selectColumns)}`
6067

6168
// Add filters if provided - using PostgREST syntax
6269
if (params.filter?.trim()) {

apps/sim/tools/supabase/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export interface SupabaseQueryParams {
55
projectId: string
66
table: string
77
schema?: string
8+
select?: string
89
filter?: string
910
orderBy?: string
1011
limit?: number
@@ -23,6 +24,7 @@ export interface SupabaseGetRowParams {
2324
projectId: string
2425
table: string
2526
schema?: string
27+
select?: string
2628
filter: string
2729
}
2830

0 commit comments

Comments
 (0)