{"version":3,"file":"run-read-only-query.mjs","names":[],"sources":["../../src/actions/run-read-only-query.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 SupabaseRunReadOnlyQueryInput = z.object({\n  ref: z.string().describe(\"The unique reference ID of the Supabase project (used in the URL path). Must be exactly 20 lowercase letters (a-z). Can be found in Project Settings > General > Reference ID in the Supabase Dashboard, or from the dashboard URL: https://supabase.com/dashboard/project/<project-ref>. Can also be provided as 'project_ref'.\"),\n  query: z.string().describe(\"The SQL query to be executed as supabase_read_only_user. Only SELECT and other read-only operations are allowed. Write operations (INSERT, UPDATE, DELETE, CREATE, etc.) will be rejected. Can also be provided as 'sql'. IMPORTANT - Single Quote Handling: DO NOT double or escape single quotes in your SQL. The query is transmitted as a JSON string body, so standard SQL single quotes work directly. For example, write WHERE name = 'John' NOT WHERE name = ''John''.\"),\n  parameters: z.array(z.union([z.string(), z.number().int(), z.number(), z.boolean()]).nullable()).describe(\"Optional array of parameters for parameterized queries. Use $1, $2, etc. in the query to reference parameters.\").optional(),\n}).describe(\"Request schema for running a read-only SQL query.\");\nexport const SupabaseRunReadOnlyQueryOutput = z.object({\n  result: z.array(z.record(z.string(), z.unknown())).describe(\"Query results as an array of row objects. For SELECT queries: contains the retrieved rows. Empty array if no rows match.\").nullable().optional(),\n  rows_returned: z.number().int().describe(\"Number of rows returned by the query.\").nullable().optional(),\n}).passthrough().describe(\"Response from executing a read-only SQL query.\");\n\nexport const supabaseRunReadOnlyQuery: AppAction<\n  typeof SupabaseRunReadOnlyQueryInput,\n  typeof SupabaseRunReadOnlyQueryOutput,\n  typeof supabase.credential\n> = action(\"SUPABASE_RUN_READ_ONLY_QUERY\", {\n  slug: \"supabase-run-read-only-query\",\n  name: \"Execute read-only database query\",\n  description: \"[Beta] Run a SQL query as supabase_read_only_user. Use when you need to safely execute SELECT queries without risk of modifying data. Only read operations are allowed.\",\n  input: SupabaseRunReadOnlyQueryInput,\n  output: SupabaseRunReadOnlyQueryOutput,\n});\n"],"mappings":";;;AAgBA,MAAa,2BAIT,OAAO,gCAAgC;CACzC,MAAM;CACN,MAAM;CACN,aAAa;CACb,OAlB2C,EAAE,OAAO;EACpD,KAAK,EAAE,OAAO,CAAC,CAAC,SAAS,kUAAkU;EAC3V,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,gdAAgd;EAC3e,YAAY,EAAE,MAAM,EAAE,MAAM;GAAC,EAAE,OAAO;GAAG,EAAE,OAAO,CAAC,CAAC,IAAI;GAAG,EAAE,OAAO;GAAG,EAAE,QAAQ;EAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,gHAAgH,CAAC,CAAC,SAAS;CACvO,CAAC,CAAC,CAAC,SAAS,mDAcH;CACP,QAd4C,EAAE,OAAO;EACrD,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,0HAA0H,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;EAC5M,eAAe,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,uCAAuC,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;CACxG,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,SAAS,gDAWhB;AACV,CAAC"}