import { BaseFlowClient } from './client'; import { BaseFlowResponse, PostgrestBuilder as IPostgrestBuilder, PostgrestFilterBuilder as IPostgrestFilterBuilder, PostgrestQueryBuilder as IPostgrestQueryBuilder } from './types'; /** * A thenable class that represents a PostgREST request. */ export declare class PostgrestBuilder implements IPostgrestBuilder { protected client: BaseFlowClient; protected table: string; protected method: string; protected path: string; protected params: Record; protected body: any; protected headers: Record; constructor(client: BaseFlowClient, table: string); /** * Executes the request and returns a promise that resolves with the response. * * @param onfulfilled A function to be called when the promise is fulfilled. * @param onrejected A function to be called when the promise is rejected. * @returns A promise that resolves with the response. */ then, TResult2 = never>(onfulfilled?: ((value: BaseFlowResponse) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): Promise; } /** * A builder for creating PostgREST filters. */ export declare class PostgrestFilterBuilder extends PostgrestBuilder implements IPostgrestFilterBuilder { /** * Adds an 'equals' filter to the query. * * @param column The column to filter on. * @param value The value to filter by. * @returns The filter builder. */ eq(column: keyof T, value: any): PostgrestFilterBuilder; /** * Adds a 'not equals' filter to the query. * * @param column The column to filter on. * @param value The value to filter by. * @returns The filter builder. */ neq(column: keyof T, value: any): PostgrestFilterBuilder; /** * Adds a 'greater than' filter to the query. * * @param column The column to filter on. * @param value The value to filter by. * @returns The filter builder. */ gt(column: keyof T, value: any): PostgrestFilterBuilder; /** * Adds a 'greater than or equal to' filter to the query. * * @param column The column to filter on. * @param value The value to filter by. * @returns The filter builder. */ gte(column: keyof T, value: any): PostgrestFilterBuilder; /** * Adds a 'less than' filter to the query. * * @param column The column to filter on. * @param value The value to filter by. * @returns The filter builder. */ lt(column: keyof T, value: any): PostgrestFilterBuilder; /** * Adds a 'less than or equal to' filter to the query. * * @param column The column to filter on. * @param value The value to filter by. * @returns The filter builder. */ lte(column: keyof T, value: any): PostgrestFilterBuilder; /** * Adds a 'like' filter to the query. * * @param column The column to filter on. * @param pattern The pattern to match. * @returns The filter builder. */ like(column: keyof T, pattern: string): PostgrestFilterBuilder; /** * Adds a 'case-insensitive like' filter to the query. * * @param column The column to filter on. * @param pattern The pattern to match. * @returns The filter builder. */ ilike(column: keyof T, pattern: string): PostgrestFilterBuilder; /** * Adds an 'is' filter to the query. * * @param column The column to filter on. * @param value The value to filter by. * @returns The filter builder. */ is(column: keyof T, value: null | boolean): PostgrestFilterBuilder; /** * Adds an 'in' filter to the query. * * @param column The column to filter on. * @param values The values to filter by. * @returns The filter builder. */ in(column: keyof T, values: any[]): PostgrestFilterBuilder; /** * Adds a 'contains' filter to the query. * * @param column The column to filter on. * @param value The value to filter by. * @returns The filter builder. */ contains(column: keyof T, value: any): PostgrestFilterBuilder; /** * Adds a 'contained by' filter to the query. * * @param column The column to filter on. * @param value The value to filter by. * @returns The filter builder. */ containedBy(column: keyof T, value: any): PostgrestFilterBuilder; /** * Adds a 'range greater than' filter to the query. * * @param column The column to filter on. * @param value The value to filter by. * @returns The filter builder. */ rangeGt(column: keyof T, value: any): PostgrestFilterBuilder; /** * Adds a 'range greater than or equal to' filter to the query. * * @param column The column to filter on. * @param value The value to filter by. * @returns The filter builder. */ rangeGte(column: keyof T, value: any): PostgrestFilterBuilder; /** * Adds a 'range less than' filter to the query. * * @param column The column to filter on. * @param value The value to filter by. * @returns The filter builder. */ rangeLt(column: keyof T, value: any): PostgrestFilterBuilder; /** * Adds a 'range less than or equal to' filter to the query. * * @param column The column to filter on. * @param value The value to filter by. * @returns The filter builder. */ rangeLte(column: keyof T, value: any): PostgrestFilterBuilder; /** * Adds a 'range adjacent' filter to the query. * * @param column The column to filter on. * @param value The value to filter by. * @returns The filter builder. */ rangeAdjacent(column: keyof T, value: any): PostgrestFilterBuilder; /** * Adds an 'overlaps' filter to the query. * * @param column The column to filter on. * @param value The value to filter by. * @returns The filter builder. */ overlaps(column: keyof T, value: any): PostgrestFilterBuilder; /** * Adds a 'text search' filter to the query. * * @param column The column to filter on. * @param query The query to search for. * @returns The filter builder. */ textSearch(column: keyof T, query: string): PostgrestFilterBuilder; /** * Adds a 'match' filter to the query. * * @param query The query to match. * @returns The filter builder. */ match(query: Record): PostgrestFilterBuilder; /** * Adds a 'not' filter to the query. * * @param column The column to filter on. * @param operator The operator to use. * @param value The value to filter by. * @returns The filter builder. */ not(column: keyof T, operator: string, value: any): PostgrestFilterBuilder; /** * Adds an 'or' filter to the query. * * @param filters The filters to apply. * @returns The filter builder. */ or(filters: string): PostgrestFilterBuilder; /** * Adds a filter to the query. * * @param column The column to filter on. * @param operator The operator to use. * @param value The value to filter by. * @returns The filter builder. */ filter(column: keyof T, operator: string, value: any): PostgrestFilterBuilder; protected addFilter(existing: string | undefined, newFilter: string, operator?: string): string; protected escapeValue(value: any): string; } /** * A builder for creating PostgREST queries. */ export declare class PostgrestQueryBuilder extends PostgrestFilterBuilder implements IPostgrestQueryBuilder { /** * Specifies the columns to select. * Supports Supabase-like syntax with JOINs and nested selections. * * Examples: * - select('*') - Select all columns * - select('name, email') - Select specific columns * - select('title, author:users(name, email)') - JOIN with users table * - select('title, comments(count)') - Aggregate count of comments * * @param columns The columns to select. * @returns The query builder. */ select(columns?: string): PostgrestQueryBuilder; /** * Inserts data into the table. * * @param data The data to insert. * @returns A promise that resolves with the response. */ insert(data: Partial | Partial[]): PostgrestBuilder; /** * Updates data in the table. * * @param data The data to update. * @returns A filter builder for specifying which rows to update. */ update(data: Partial): PostgrestFilterBuilder; /** * Deletes data from the table. * * @returns A filter builder for specifying which rows to delete. */ delete(): PostgrestFilterBuilder; /** * Adds an 'order by' clause to the query. * * @param column The column to order by. * @param options The ordering options. * @returns The query builder. */ order(column: keyof T, options?: { ascending?: boolean; nullsFirst?: boolean; }): PostgrestQueryBuilder; /** * Limits the number of rows returned. * * @param count The maximum number of rows to return. * @returns The query builder. */ limit(count: number): PostgrestQueryBuilder; /** * Specifies a range of rows to return. * * @param from The starting row index. * @param to The ending row index. * @returns The query builder. */ range(from: number, to: number): PostgrestQueryBuilder; /** * Returns a single row from the query. * * @returns The filter builder. */ single(): PostgrestFilterBuilder; /** * Returns a single row from the query, or null if no rows are found. * * @returns The filter builder. */ maybeSingle(): PostgrestFilterBuilder; /** * Subscribe to real-time changes on this table * * @param event The event type to listen for * @param callback The callback function to execute when changes occur * @returns The subscription object */ on(event: 'INSERT' | 'UPDATE' | 'DELETE' | '*', callback: (payload: any) => void): RealtimeSubscriptionBuilder; } /** * Real-time subscription builder */ export declare class RealtimeSubscriptionBuilder { private client; private table; private event; private callback; private filters; constructor(client: BaseFlowClient, table: string, event: 'INSERT' | 'UPDATE' | 'DELETE' | '*', callback: (payload: any) => void, filters?: Record); }