11import PostgrestTransformBuilder from './PostgrestTransformBuilder'
22import { JsonPathToAccessor , JsonPathToType } from './select-query-parser/utils'
3- import { ClientServerOptions , GenericSchema } from './types'
3+ import { ClientServerOptions , GenericSchema } from './types/common/common '
44
55type FilterOperator =
66 | 'eq'
@@ -38,27 +38,27 @@ export type IsStringOperator<Path extends string> = Path extends `${string}->>${
3838type ResolveFilterValue <
3939 Schema extends GenericSchema ,
4040 Row extends Record < string , unknown > ,
41- ColumnName extends string ,
41+ ColumnName extends string
4242> = ColumnName extends `${infer RelationshipTable } .${infer Remainder } `
4343 ? Remainder extends `${infer _ } .${infer _ } `
4444 ? ResolveFilterValue < Schema , Row , Remainder >
4545 : ResolveFilterRelationshipValue < Schema , RelationshipTable , Remainder >
4646 : ColumnName extends keyof Row
47- ? Row [ ColumnName ]
48- : // If the column selection is a jsonpath like `data->value` or `data->>value` we attempt to match
49- // the expected type with the parsed custom json type
50- IsStringOperator < ColumnName > extends true
51- ? string
52- : JsonPathToType < Row , JsonPathToAccessor < ColumnName > > extends infer JsonPathValue
53- ? JsonPathValue extends never
54- ? never
55- : JsonPathValue
56- : never
47+ ? Row [ ColumnName ]
48+ : // If the column selection is a jsonpath like `data->value` or `data->>value` we attempt to match
49+ // the expected type with the parsed custom json type
50+ IsStringOperator < ColumnName > extends true
51+ ? string
52+ : JsonPathToType < Row , JsonPathToAccessor < ColumnName > > extends infer JsonPathValue
53+ ? JsonPathValue extends never
54+ ? never
55+ : JsonPathValue
56+ : never
5757
5858type ResolveFilterRelationshipValue <
5959 Schema extends GenericSchema ,
6060 RelationshipTable extends string ,
61- RelationshipColumn extends string ,
61+ RelationshipColumn extends string
6262> = Schema [ 'Tables' ] & Schema [ 'Views' ] extends infer TablesAndViews
6363 ? RelationshipTable extends keyof TablesAndViews
6464 ? 'Row' extends keyof TablesAndViews [ RelationshipTable ]
@@ -78,7 +78,7 @@ export default class PostgrestFilterBuilder<
7878 Result ,
7979 RelationName = unknown ,
8080 Relationships = unknown ,
81- Method = unknown ,
81+ Method = unknown
8282> extends PostgrestTransformBuilder <
8383 ClientOptions ,
8484 Schema ,
@@ -101,11 +101,11 @@ export default class PostgrestFilterBuilder<
101101 value : ResolveFilterValue < Schema , Row , ColumnName > extends never
102102 ? NonNullable < unknown >
103103 : // We want to infer the type before wrapping it into a `NonNullable` to avoid too deep
104- // type resolution error
105- ResolveFilterValue < Schema , Row , ColumnName > extends infer ResolvedFilterValue
106- ? NonNullable < ResolvedFilterValue >
107- : // We should never enter this case as all the branches are covered above
108- never
104+ // type resolution error
105+ ResolveFilterValue < Schema , Row , ColumnName > extends infer ResolvedFilterValue
106+ ? NonNullable < ResolvedFilterValue >
107+ : // We should never enter this case as all the branches are covered above
108+ never
109109 ) : this {
110110 this . url . searchParams . append ( column , `eq.${ value } ` )
111111 return this
@@ -122,8 +122,8 @@ export default class PostgrestFilterBuilder<
122122 value : ResolveFilterValue < Schema , Row , ColumnName > extends never
123123 ? unknown
124124 : ResolveFilterValue < Schema , Row , ColumnName > extends infer ResolvedFilterValue
125- ? ResolvedFilterValue
126- : never
125+ ? ResolvedFilterValue
126+ : never
127127 ) : this {
128128 this . url . searchParams . append ( column , `neq.${ value } ` )
129129 return this
@@ -305,11 +305,11 @@ export default class PostgrestFilterBuilder<
305305 ResolveFilterValue < Schema , Row , ColumnName > extends never
306306 ? unknown
307307 : // We want to infer the type before wrapping it into a `NonNullable` to avoid too deep
308- // type resolution error
309- ResolveFilterValue < Schema , Row , ColumnName > extends infer ResolvedFilterValue
310- ? ResolvedFilterValue
311- : // We should never enter this case as all the branches are covered above
312- never
308+ // type resolution error
309+ ResolveFilterValue < Schema , Row , ColumnName > extends infer ResolvedFilterValue
310+ ? ResolvedFilterValue
311+ : // We should never enter this case as all the branches are covered above
312+ never
313313 >
314314 ) : this {
315315 const cleanedValues = Array . from ( new Set ( values ) )
0 commit comments