{"version":3,"file":"select-from-table.mjs","names":[],"sources":["../../src/actions/select-from-table.ts"],"sourcesContent":["import type { AppAction } from \"@keystrokehq/keystroke/app\";\nimport { z } from \"zod\";\n\nimport { action } from \"../action\";\nimport { supabase } from \"../app\";\n\nexport const SupabaseSelectFromTableInput = z.object({\n  limit: z.number().int().describe(\"Maximum number of rows to return (must be >= 1)\").optional(),\n  order: z.string().describe(\"Ordering expression in the form `column.asc` or `column.desc`\").optional(),\n  table: z.string().describe(\"Table or view name to select from\"),\n  offset: z.number().int().describe(\"Number of rows to skip before returning results (must be >= 0)\").optional(),\n  select: z.string().describe(\"Comma-separated list of columns to return. Supports nested/related selections and JSON path selectors (e.g., address->postcode).\"),\n  filters: z.array(z.object({\n  value: z.union([z.string(), z.number().int(), z.number(), z.boolean(), z.array(z.union([z.string(), z.number().int(), z.number(), z.boolean()])), z.record(z.string(), z.unknown())]),\n  column: z.string().describe(\"Column name to filter on\"),\n  operator: z.enum([\"eq\", \"neq\", \"gt\", \"gte\", \"lt\", \"lte\", \"like\", \"ilike\", \"is\", \"in\", \"cs\", \"cd\", \"sl\", \"sr\", \"nxl\", \"nxr\", \"adj\", \"ov\", \"fts\", \"plfts\", \"phfts\", \"wfts\"]).describe(\"PostgREST filter operator to apply\"),\n}).passthrough().describe(\"Filter on a single column using a PostgREST operator.\")).describe(\"Optional list of filters. Each filter will be rendered as `<column>_<operator>=<value>` in the query string (e.g., id_eq=123). Can be provided as a list of FilterItem objects. Each FilterItem must have: column (string), operator (one of: eq, neq, gt, gte, lt, lte, like, ilike, is, in, cs, cd, sl, sr, nxl, nxr, adj, ov, fts, plfts, phfts, wfts), and value (the comparison value).\").optional(),\n  project_ref: z.string().describe(\"Unique reference ID of the Supabase project (used in the hostname)\"),\n}).describe(\"Request schema for selecting rows from a PostgREST table.\");\nconst SupabaseSelectFromTable_QueryDiagnosticsSchema = z.object({\n  warning: z.string().describe(\"Warning message if the result seems suspicious (e.g., empty results from auth.users with service_role key)\").nullable().optional(),\n  schema_hint: z.string().describe(\"If table name includes a schema prefix (e.g., 'auth.users'), this indicates the schema\").nullable().optional(),\n  total_count: z.number().int().describe(\"Total row count from Content-Range header (if available). When using count=exact with simple column filters (e.g., status=eq.active, created_at=gte.2024-01-01), this reflects the FILTERED count matching your query conditions. Note: With embedded resource filters using !inner joins, PostgREST may return the unfiltered table count due to a known issue (PostgREST #2009).\").nullable().optional(),\n  api_key_type: z.string().describe(\"Type of API key used: 'service_role' (bypasses RLS), 'anon' (subject to RLS), or 'unknown'\").nullable().optional(),\n  table_queried: z.string().describe(\"The table or view that was queried\").nullable(),\n  query_executed: z.boolean().describe(\"Whether the query was executed successfully (HTTP 200 from PostgREST)\").nullable(),\n  http_status_code: z.number().int().describe(\"HTTP status code from the PostgREST response\").nullable().optional(),\n  content_range_header: z.string().describe(\"Raw Content-Range header from PostgREST response (e.g., '0-9/100' means rows 0-9 of 100 total)\").nullable().optional(),\n}).passthrough().describe(\"Diagnostic information about the query execution.\");\nexport const SupabaseSelectFromTableOutput = z.object({\n  rows: z.array(z.record(z.string(), z.unknown())).describe(\"List of result rows, each containing only the selected columns\"),\n  diagnostics: SupabaseSelectFromTable_QueryDiagnosticsSchema.nullable().optional(),\n  composio_execution_message: z.string().describe(\"Informational message about the query execution, especially for empty results\").nullable().optional(),\n}).passthrough().describe(\"Response containing rows returned by the select query with diagnostic information.\");\n\nexport const supabaseSelectFromTable: AppAction<\n  typeof SupabaseSelectFromTableInput,\n  typeof SupabaseSelectFromTableOutput,\n  typeof supabase.credential\n> = action(\"SUPABASE_SELECT_FROM_TABLE\", {\n  slug: \"supabase-select-from-table\",\n  name: \"Select From Table\",\n  description: \"Tool to select rows from a Supabase/PostgREST table. Use for read-only queries with filtering, sorting, and pagination.\",\n  input: SupabaseSelectFromTableInput,\n  output: SupabaseSelectFromTableOutput,\n});\n"],"mappings":";;;;AAMA,MAAa,+BAA+B,EAAE,OAAO;CACnD,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,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