/** * @module minions-sdk/storage/supabase * Supabase (Postgres) storage adapter for the Minions structured object system. * * Requires the `@supabase/supabase-js` package as a peer dependency. * * @example * ```typescript * import { createClient } from '@supabase/supabase-js'; * import { SupabaseStorageAdapter } from 'minions-sdk'; * * const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY); * const storage = new SupabaseStorageAdapter(supabase); * * const minions = new Minions({ storage }); * ``` */ import type { Minion } from '../types/index.js'; import type { StorageAdapter, StorageFilter } from './StorageAdapter.js'; /** Response shape returned by Supabase query builders. */ interface SupabaseResponse { data: T | null; error: { message: string; code?: string; } | null; } /** Minimal Supabase query builder chain. */ interface SupabaseQueryBuilder { select(columns?: string): SupabaseFilterBuilder; insert(values: Record | Record[], options?: Record): SupabaseFilterBuilder; update(values: Record): SupabaseFilterBuilder; upsert(values: Record | Record[], options?: Record): SupabaseFilterBuilder; delete(): SupabaseFilterBuilder; } /** Minimal Supabase filter builder chain. */ interface SupabaseFilterBuilder { eq(column: string, value: unknown): SupabaseFilterBuilder; neq(column: string, value: unknown): SupabaseFilterBuilder; is(column: string, value: null): SupabaseFilterBuilder; not(column: string, operator: string, value: unknown): SupabaseFilterBuilder; contains(column: string, value: unknown): SupabaseFilterBuilder; textSearch(column: string, query: string, options?: Record): SupabaseFilterBuilder; ilike(column: string, pattern: string): SupabaseFilterBuilder; order(column: string, options?: { ascending?: boolean; }): SupabaseFilterBuilder; range(from: number, to: number): SupabaseFilterBuilder; limit(count: number): SupabaseFilterBuilder; single(): SupabaseFilterBuilder; maybeSingle(): SupabaseFilterBuilder; then(onfulfilled?: (value: SupabaseResponse) => TResult, onrejected?: (reason: unknown) => TResult): Promise; [Symbol.toStringTag]?: string; } /** * Minimal interface for a Supabase client. * * Any object that exposes a `from(table)` method returning a query builder * matching the `@supabase/supabase-js` contract will work. */ export interface SupabaseClientLike { from(table: string): SupabaseQueryBuilder; } /** Options for the Supabase storage adapter. */ export interface SupabaseStorageOptions { /** * Name of the Postgres table that stores minions. * Defaults to `"minions"`. */ table?: string; } /** * Storage adapter backed by **Supabase** (Postgres). * * Minions are stored in a single Postgres table with a JSONB `data` column * containing the full `Minion` object, plus a few denormalized columns * (`minion_type_id`, `status`, `deleted_at`, `searchable_text`, `tags`) * for efficient server-side filtering. * * Use {@link SupabaseStorageAdapter.createTableSQL} to get the DDL for * creating the table. * * @example * ```sql * -- Run this in your Supabase SQL editor: * CREATE TABLE IF NOT EXISTS minions ( * id TEXT PRIMARY KEY, * data JSONB NOT NULL, * minion_type_id TEXT NOT NULL, * status TEXT, * deleted_at TEXT, * searchable_text TEXT, * tags TEXT[], * created_at TIMESTAMPTZ DEFAULT now(), * updated_at TIMESTAMPTZ DEFAULT now() * ); * * -- Optional: full-text search index * CREATE INDEX IF NOT EXISTS idx_minions_searchable * ON minions USING gin(to_tsvector('english', coalesce(searchable_text, ''))); * ``` */ export declare class SupabaseStorageAdapter implements StorageAdapter { private client; private table; constructor(client: SupabaseClientLike, options?: SupabaseStorageOptions); /** * Returns the SQL DDL statement for creating the minions table. * Run this in your Supabase SQL editor or in a migration. */ static createTableSQL(table?: string): string; /** Convert a Minion to a table row. */ private toRow; /** Convert a table row back to a Minion. */ private fromRow; /** Throw if the Supabase response contains an error. */ private throwIfError; get(id: string): Promise; set(minion: Minion): Promise; delete(id: string): Promise; list(filter?: StorageFilter): Promise; search(query: string): Promise; } export {}; //# sourceMappingURL=SupabaseStorageAdapter.d.ts.map