From 46b04a964d0fc0624a90be9038c48aeecf54ac98 Mon Sep 17 00:00:00 2001 From: Waleed Date: Tue, 6 Jan 2026 12:21:08 -0800 Subject: [PATCH] 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 --- apps/docs/content/docs/en/tools/kalshi.mdx | 2 -- apps/docs/content/docs/en/tools/supabase.mdx | 2 ++ apps/sim/blocks/blocks/supabase.ts | 11 +++++++++++ apps/sim/tools/supabase/get_row.ts | 9 ++++++++- apps/sim/tools/supabase/query.ts | 9 ++++++++- apps/sim/tools/supabase/types.ts | 2 ++ 6 files changed, 31 insertions(+), 4 deletions(-) diff --git a/apps/docs/content/docs/en/tools/kalshi.mdx b/apps/docs/content/docs/en/tools/kalshi.mdx index 7d976ceba..199ec0542 100644 --- a/apps/docs/content/docs/en/tools/kalshi.mdx +++ b/apps/docs/content/docs/en/tools/kalshi.mdx @@ -126,8 +126,6 @@ Retrieve your account balance and portfolio value from Kalshi | --------- | ---- | ----------- | | `balance` | number | Account balance in cents | | `portfolioValue` | number | Portfolio value in cents | -| `balanceDollars` | number | Account balance in dollars | -| `portfolioValueDollars` | number | Portfolio value in dollars | ### `kalshi_get_positions` diff --git a/apps/docs/content/docs/en/tools/supabase.mdx b/apps/docs/content/docs/en/tools/supabase.mdx index 2c6ba254f..a6e285c9a 100644 --- a/apps/docs/content/docs/en/tools/supabase.mdx +++ b/apps/docs/content/docs/en/tools/supabase.mdx @@ -53,6 +53,7 @@ Query data from a Supabase table | `projectId` | string | Yes | Your Supabase project ID \(e.g., jdrkgepadsdopsntdlom\) | | `table` | string | Yes | The name of the Supabase table to query | | `schema` | string | No | Database schema to query from \(default: public\). Use this to access tables in other schemas. | +| `select` | string | No | Columns to return \(comma-separated\). Defaults to * \(all columns\) | | `filter` | string | No | PostgREST filter \(e.g., "id=eq.123"\) | | `orderBy` | string | No | Column to order by \(add DESC for descending\) | | `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 | `projectId` | string | Yes | Your Supabase project ID \(e.g., jdrkgepadsdopsntdlom\) | | `table` | string | Yes | The name of the Supabase table to query | | `schema` | string | No | Database schema to query from \(default: public\). Use this to access tables in other schemas. | +| `select` | string | No | Columns to return \(comma-separated\). Defaults to * \(all columns\) | | `filter` | string | Yes | PostgREST filter to find the specific row \(e.g., "id=eq.123"\) | | `apiKey` | string | Yes | Your Supabase service role secret key | diff --git a/apps/sim/blocks/blocks/supabase.ts b/apps/sim/blocks/blocks/supabase.ts index f4008b02b..b6602362a 100644 --- a/apps/sim/blocks/blocks/supabase.ts +++ b/apps/sim/blocks/blocks/supabase.ts @@ -79,6 +79,16 @@ export const SupabaseBlock: BlockConfig = { value: ['query', 'get_row', 'insert', 'update', 'delete', 'upsert', 'count', 'text_search'], }, }, + { + id: 'select', + title: 'Select Columns', + type: 'short-input', + placeholder: '* (all columns) or id,name,email', + condition: { + field: 'operation', + value: ['query', 'get_row'], + }, + }, { id: 'apiKey', title: 'Service Role Secret', @@ -1044,6 +1054,7 @@ Return ONLY the PostgREST filter expression - no explanations, no markdown, no e projectId: { type: 'string', description: 'Supabase project identifier' }, table: { type: 'string', description: 'Database table name' }, schema: { type: 'string', description: 'Database schema (default: public)' }, + select: { type: 'string', description: 'Columns to return (comma-separated, defaults to *)' }, apiKey: { type: 'string', description: 'Service role secret key' }, // Data for insert/update operations data: { type: 'json', description: 'Row data' }, diff --git a/apps/sim/tools/supabase/get_row.ts b/apps/sim/tools/supabase/get_row.ts index f33e23b04..d65d8ae83 100644 --- a/apps/sim/tools/supabase/get_row.ts +++ b/apps/sim/tools/supabase/get_row.ts @@ -27,6 +27,12 @@ export const getRowTool: ToolConfig { // Construct the URL for the Supabase REST API - let url = `https://${params.projectId}.supabase.co/rest/v1/${params.table}?select=*` + const selectColumns = params.select?.trim() || '*' + let url = `https://${params.projectId}.supabase.co/rest/v1/${params.table}?select=${encodeURIComponent(selectColumns)}` // Add filters (required for get_row) - using PostgREST syntax if (params.filter?.trim()) { diff --git a/apps/sim/tools/supabase/query.ts b/apps/sim/tools/supabase/query.ts index ea91af616..c72ba7252 100644 --- a/apps/sim/tools/supabase/query.ts +++ b/apps/sim/tools/supabase/query.ts @@ -27,6 +27,12 @@ export const queryTool: ToolConfig = description: 'Database schema to query from (default: public). Use this to access tables in other schemas.', }, + select: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Columns to return (comma-separated). Defaults to * (all columns)', + }, filter: { type: 'string', required: false, @@ -56,7 +62,8 @@ export const queryTool: ToolConfig = request: { url: (params) => { // Construct the URL for the Supabase REST API - let url = `https://${params.projectId}.supabase.co/rest/v1/${params.table}?select=*` + const selectColumns = params.select?.trim() || '*' + let url = `https://${params.projectId}.supabase.co/rest/v1/${params.table}?select=${encodeURIComponent(selectColumns)}` // Add filters if provided - using PostgREST syntax if (params.filter?.trim()) { diff --git a/apps/sim/tools/supabase/types.ts b/apps/sim/tools/supabase/types.ts index 898026f1b..ee11e87dc 100644 --- a/apps/sim/tools/supabase/types.ts +++ b/apps/sim/tools/supabase/types.ts @@ -5,6 +5,7 @@ export interface SupabaseQueryParams { projectId: string table: string schema?: string + select?: string filter?: string orderBy?: string limit?: number @@ -23,6 +24,7 @@ export interface SupabaseGetRowParams { projectId: string table: string schema?: string + select?: string filter: string }