@@ -34,6 +34,9 @@ export type GetRpcFunctionFilterBuilderByArgs<
34
34
// on the function arguments provided
35
35
Args extends GenericFunction [ 'Args' ]
36
36
? FindMatchingFunctionByArgs < Schema [ 'Functions' ] [ FnName ] , Args >
37
+ : // If we can't find a matching function by args, we try to find one by function name
38
+ ExtractExactFunction < Schema [ 'Functions' ] [ FnName ] , Args > extends GenericFunction
39
+ ? ExtractExactFunction < Schema [ 'Functions' ] [ FnName ] , Args >
37
40
: any
38
41
} [ 1 ] extends infer Fn
39
42
? // If we are dealing with an non-typed client everything is any
@@ -192,9 +195,17 @@ export default class PostgrestClient<
192
195
* `"estimated"`: Uses exact count for low numbers and planned count for high
193
196
* numbers.
194
197
*/
195
- rpc < FnName extends string & keyof Schema [ 'Functions' ] , Fn extends Schema [ 'Functions' ] [ FnName ] > (
198
+ rpc <
199
+ FnName extends string & keyof Schema [ 'Functions' ] ,
200
+ Args extends Schema [ 'Functions' ] [ FnName ] [ 'Args' ] = { } ,
201
+ FilterBuilder extends GetRpcFunctionFilterBuilderByArgs <
202
+ Schema ,
203
+ FnName ,
204
+ Args
205
+ > = GetRpcFunctionFilterBuilderByArgs < Schema , FnName , Args >
206
+ > (
196
207
fn : FnName ,
197
- args : Fn [ ' Args' ] = { } ,
208
+ args : Args = { } as Args ,
198
209
{
199
210
head = false ,
200
211
get = false ,
@@ -207,14 +218,10 @@ export default class PostgrestClient<
207
218
) : PostgrestFilterBuilder <
208
219
ClientOptions ,
209
220
Schema ,
210
- Fn [ 'Returns' ] extends any [ ]
211
- ? Fn [ 'Returns' ] [ number ] extends Record < string , unknown >
212
- ? Fn [ 'Returns' ] [ number ]
213
- : { }
214
- : { } ,
215
- Fn [ 'Returns' ] ,
216
- FnName ,
217
- null ,
221
+ FilterBuilder [ 'Row' ] ,
222
+ FilterBuilder [ 'Result' ] ,
223
+ FilterBuilder [ 'RelationName' ] ,
224
+ FilterBuilder [ 'Relationships' ] ,
218
225
'RPC'
219
226
> {
220
227
let method : 'HEAD' | 'GET' | 'POST'
0 commit comments