export interface PostgrestQueryLike { or: (filters: string, options?: { foreignTable?: string; }) => PostgrestQueryLike; ilike: (column: string, pattern: string) => PostgrestQueryLike; eq: (column: string, value: unknown) => PostgrestQueryLike; in: (column: string, values: unknown[]) => PostgrestQueryLike; order: (column: string, options: { ascending: boolean; nullsFirst?: boolean; foreignTable?: string; }) => PostgrestQueryLike; range: (from: number, to: number, options?: { foreignTable?: string; }) => PostgrestQueryLike; } export interface TableStateLike { currentPage: number; pageSize: number; sortColumn: string | null; sortDirection: "asc" | "desc"; searchText: string; debouncedSearchText?: string; appliedFilters: TFilters; } export interface SupabaseFilterConfig { /** * Database columns to perform global search on. * If search text is provided, it applies: .or("col1.ilike.%text%,col2.ilike.%text%") */ searchColumns?: string[]; /** * Mapping definitions for each key in appliedFilters. */ filters?: { [K in keyof TFilters]?: { /** * Column name in the DB. If omitted, the filter key is used as the column name. */ column?: string; /** * The filter type to apply. * - "ilike": case-insensitive search (uses `%value%`) * - "eq": exact match * - "in": match any value in the array * - "custom": ignored by the helper (handled manually) */ type: "ilike" | "eq" | "in" | "custom"; }; }; /** * Mapping table sortColumn values to database column names. * If a sortColumn value is not mapped here, it will be used as-is. */ sortColumns?: Record; } export declare function applyTableStateToQuery>(query: PostgrestQueryLike, tableState: TableStateLike, config?: SupabaseFilterConfig): PostgrestQueryLike; /** * Extracts a list of related records from a many-to-many join array. * Handles the case where Supabase returns the nested object inside an array or as a single object. * * @example * // profile.tenants_users = [{ tenant_id: 1, tenants: { id: 1, name: "Tenant A" } }] * mapNestedRelationMany(profile.tenants_users, "tenants") // [{ id: 1, name: "Tenant A" }] */ export declare function mapNestedRelationMany(relationArray: Record[] | null | undefined, nestedKey: string): T[]; /** * Extracts a single related record from a join record or array. * * @example * // profile.users_roles = [{ role_id: 2, roles: { id: 2, name: "Admin" } }] * mapNestedRelationOne(profile.users_roles, "roles") // { id: 2, name: "Admin" } */ export declare function mapNestedRelationOne(relationArrayOrObject: Record | Record[] | null | undefined, nestedKey?: string): T | null; //# sourceMappingURL=supabase.helper.d.ts.map