import PostgrestTransformBuilder from './PostgrestTransformBuilder'; import { JsonPathToAccessor, JsonPathToType } from './select-query-parser/utils'; import { GenericSchema } from './types'; type FilterOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ilike' | 'is' | 'in' | 'cs' | 'cd' | 'sl' | 'sr' | 'nxl' | 'nxr' | 'adj' | 'ov' | 'fts' | 'plfts' | 'phfts' | 'wfts'; export type IsStringOperator = Path extends `${string}->>${string}` ? true : false; type ResolveFilterValue, ColumnName extends string> = ColumnName extends `${infer RelationshipTable}.${infer Remainder}` ? Remainder extends `${infer _}.${infer _}` ? ResolveFilterValue : ResolveFilterRelationshipValue : ColumnName extends keyof Row ? Row[ColumnName] : IsStringOperator extends true ? string : JsonPathToType> extends infer JsonPathValue ? JsonPathValue extends never ? never : JsonPathValue : never; type ResolveFilterRelationshipValue = Schema['Tables'] & Schema['Views'] extends infer TablesAndViews ? RelationshipTable extends keyof TablesAndViews ? 'Row' extends keyof TablesAndViews[RelationshipTable] ? RelationshipColumn extends keyof TablesAndViews[RelationshipTable]['Row'] ? TablesAndViews[RelationshipTable]['Row'][RelationshipColumn] : unknown : unknown : unknown : never; export default class PostgrestFilterBuilder, Result, RelationName = unknown, Relationships = unknown> extends PostgrestTransformBuilder { /** * Match only rows where `column` is equal to `value`. * * To check if the value of `column` is NULL, you should use `.is()` instead. * * @param column - The column to filter on * @param value - The value to filter with */ eq(column: ColumnName, value: ResolveFilterValue extends never ? NonNullable : ResolveFilterValue extends infer ResolvedFilterValue ? NonNullable : never): this; /** * Match only rows where `column` is not equal to `value`. * * @param column - The column to filter on * @param value - The value to filter with */ neq(column: ColumnName, value: ResolveFilterValue extends never ? unknown : ResolveFilterValue extends infer ResolvedFilterValue ? ResolvedFilterValue : never): this; gt(column: ColumnName, value: Row[ColumnName]): this; gt(column: string, value: unknown): this; gte(column: ColumnName, value: Row[ColumnName]): this; gte(column: string, value: unknown): this; lt(column: ColumnName, value: Row[ColumnName]): this; lt(column: string, value: unknown): this; lte(column: ColumnName, value: Row[ColumnName]): this; lte(column: string, value: unknown): this; like(column: ColumnName, pattern: string): this; like(column: string, pattern: string): this; likeAllOf(column: ColumnName, patterns: readonly string[]): this; likeAllOf(column: string, patterns: readonly string[]): this; likeAnyOf(column: ColumnName, patterns: readonly string[]): this; likeAnyOf(column: string, patterns: readonly string[]): this; ilike(column: ColumnName, pattern: string): this; ilike(column: string, pattern: string): this; ilikeAllOf(column: ColumnName, patterns: readonly string[]): this; ilikeAllOf(column: string, patterns: readonly string[]): this; ilikeAnyOf(column: ColumnName, patterns: readonly string[]): this; ilikeAnyOf(column: string, patterns: readonly string[]): this; is(column: ColumnName, value: Row[ColumnName] & (boolean | null)): this; is(column: string, value: boolean | null): this; /** * Match only rows where `column` is included in the `values` array. * * @param column - The column to filter on * @param values - The values array to filter with */ in(column: ColumnName, values: ReadonlyArray extends never ? unknown : ResolveFilterValue extends infer ResolvedFilterValue ? ResolvedFilterValue : never>): this; contains(column: ColumnName, value: string | ReadonlyArray | Record): this; contains(column: string, value: string | readonly unknown[] | Record): this; containedBy(column: ColumnName, value: string | ReadonlyArray | Record): this; containedBy(column: string, value: string | readonly unknown[] | Record): this; rangeGt(column: ColumnName, range: string): this; rangeGt(column: string, range: string): this; rangeGte(column: ColumnName, range: string): this; rangeGte(column: string, range: string): this; rangeLt(column: ColumnName, range: string): this; rangeLt(column: string, range: string): this; rangeLte(column: ColumnName, range: string): this; rangeLte(column: string, range: string): this; rangeAdjacent(column: ColumnName, range: string): this; rangeAdjacent(column: string, range: string): this; overlaps(column: ColumnName, value: string | ReadonlyArray): this; overlaps(column: string, value: string | readonly unknown[]): this; textSearch(column: ColumnName, query: string, options?: { config?: string; type?: 'plain' | 'phrase' | 'websearch'; }): this; textSearch(column: string, query: string, options?: { config?: string; type?: 'plain' | 'phrase' | 'websearch'; }): this; match(query: Record): this; match(query: Record): this; not(column: ColumnName, operator: FilterOperator, value: Row[ColumnName]): this; not(column: string, operator: string, value: unknown): this; /** * Match only rows which satisfy at least one of the filters. * * Unlike most filters, `filters` is used as-is and needs to follow [PostgREST * syntax](https://postgrest.org/en/stable/api.html#operators). You also need * to make sure it's properly sanitized. * * It's currently not possible to do an `.or()` filter across multiple tables. * * @param filters - The filters to use, following PostgREST syntax * @param options - Named parameters * @param options.referencedTable - Set this to filter on referenced tables * instead of the parent table * @param options.foreignTable - Deprecated, use `referencedTable` instead */ or(filters: string, { foreignTable, referencedTable, }?: { foreignTable?: string; referencedTable?: string; }): this; filter(column: ColumnName, operator: `${'' | 'not.'}${FilterOperator}`, value: unknown): this; filter(column: string, operator: string, value: unknown): this; } export {}; //# sourceMappingURL=PostgrestFilterBuilder.d.ts.map