/** * Supabase MCP Client * * HTTP client for ww-mcp Edge Function following the pattern from * agents/coda/src/services/supabase-mcp.js * * Uses JSON-RPC 2.0 protocol over HTTPS. * Integrates with CacheService for performance. */ import type { Project, SupabaseListOptions, SupabaseSearchOptions } from "../types/index.js"; /** * Build a safe PostgREST `in.(...)` filter from an array of UUIDs. * Rejects any non-UUID values to prevent filter injection via comma-splitting. */ export declare function safeInFilter(ids: string[]): string; /** * Escape PostgREST special characters in a value used within filter expressions. * Prevents injection via characters that have structural meaning in PostgREST syntax: * parentheses (group operators), commas (value separators), dots (operator delimiters). */ export declare function escapePostgRESTValue(value: string): string; /** * Check if Supabase is configured */ export declare function isConfigured(): boolean; /** * List records from a table with optional filters */ export declare function listRecords(options: SupabaseListOptions): Promise; /** * Get a single record by ID */ export declare function getRecord(table: string, id: string): Promise; /** * Upsert (insert or update) a record */ export declare function upsertRecord(table: string, data: Record): Promise; /** * Semantic search across tables * * Generates an embedding for the query, then calls the gitmem_semantic_search * RPC function directly via PostgREST. */ export declare function semanticSearch(options: SupabaseSearchOptions): Promise; /** * Query Supabase REST API directly (bypasses ww-mcp) * * Used for bulk operations like loading all scars with embeddings. * ww-mcp doesn't return embeddings by default to avoid bloated responses, * but for local vector search we need them. */ export declare function directQuery(table: string, options?: { select?: string; filters?: Record; order?: string; limit?: number; }): Promise; /** * Paginated fetch — retrieves ALL matching rows using PostgREST Range headers. * Use instead of directQuery when the result set may exceed a single page. * * @param pageSize Rows per request (default 1000) * @param maxRows Safety cap to prevent runaway queries (default 10000) */ export declare function directQueryAll(table: string, options?: { select?: string; filters?: Record; order?: string; }, pageSize?: number, maxRows?: number): Promise; /** * Knowledge triple from knowledge_triples table */ export interface KnowledgeTriple { subject: string; predicate: string; object: string; event_time: string; decay_weight: number; half_life_days: number; decay_floor: number; source_id: string; } /** * Fetch related knowledge triples for a set of scar IDs * * Queries knowledge_triples table where source_id matches any of the provided scar IDs. * Returns triples grouped by source_id for easy attachment to scars. */ export declare function fetchRelatedTriples(scarIds: string[]): Promise>; /** * Upsert a record directly to Supabase REST API (bypasses ww-mcp) * * Used for tests where ww-mcp authentication is problematic. * Uses Supabase REST API's upsert capability with Prefer: resolution=merge-duplicates. */ export declare function directUpsert(table: string, data: Record): Promise; /** * Patch (partial update) existing records in Supabase REST API. * * Uses HTTP PATCH for true partial updates — only the provided fields are * modified. Unlike directUpsert (POST + merge-duplicates), this does NOT * try to INSERT first, so NOT NULL columns that aren't changing can be * omitted from `data`. * * @param table Target table name * @param filters PostgREST filter to identify the row(s) to update * @param data Fields to update (partial — omitted columns stay unchanged) */ export declare function directPatch(table: string, filters: Record, data: Record): Promise; /** * Load all learnings with embeddings directly from Supabase * * This bypasses ww-mcp because we need the embedding vectors for local search. * Returns learnings (scars, patterns, wins, anti-patterns) with full embedding data. * * NOTE: Changed from "scars only" to "all learning types" */ export declare function loadScarsWithEmbeddings(project?: string, limit?: number): Promise; /** * Scar search with severity weighting * * Generates an embedding for the query, then calls the gitmem_scar_search * RPC function directly via PostgREST. No Edge Function required. */ export declare function scarSearch(query: string, matchCount?: number, project?: Project): Promise; /** * Scar search with caching * * Returns cached results if available, otherwise fetches and caches. */ export declare function cachedScarSearch(query: string, matchCount?: number, project?: Project): Promise<{ results: T[]; cache_hit: boolean; cache_age_ms?: number; }>; /** * List records with caching for decisions */ export declare function cachedListDecisions(project?: Project, limit?: number): Promise<{ data: T[]; cache_hit: boolean; cache_age_ms?: number; }>; /** * List records with caching for wins */ export declare function cachedListWins(project?: Project, limit?: number, columns?: string): Promise<{ data: T[]; cache_hit: boolean; cache_age_ms?: number; }>; /** * Upload a file to Supabase Storage */ export declare function uploadFile(bucket: string, path: string, content: string | Buffer, contentType?: string): Promise<{ path: string; }>; /** * Download a file from Supabase Storage */ export declare function downloadFile(bucket: string, path: string): Promise; /** * Save a session transcript to storage */ export declare function saveTranscript(sessionId: string, transcript: string, metadata?: { project?: string; agent?: string; format?: "json" | "markdown"; }): Promise<{ transcript_path: string; size_bytes: number; patch_warning?: string; }>; /** * Retrieve a session transcript from storage */ export declare function getTranscript(sessionId: string): Promise<{ transcript: string; path: string; } | null>; //# sourceMappingURL=supabase-client.d.ts.map