Skip to content

Commit

Permalink
chore: Function -> Fn, like supabase-js
Browse files Browse the repository at this point in the history
  • Loading branch information
soedirgo committed Apr 11, 2024
1 parent 2895b77 commit ec0762c
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/PostgrestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,9 @@ export default class PostgrestClient<
* `"estimated"`: Uses exact count for low numbers and planned count for high
* numbers.
*/
rpc<
FunctionName extends string & keyof Schema['Functions'],
Function_ extends Schema['Functions'][FunctionName]
>(
fn: FunctionName,
args: Function_['Args'] = {},
rpc<FnName extends string & keyof Schema['Functions'], Fn extends Schema['Functions'][FnName]>(
fn: FnName,
args: Fn['Args'] = {},
{
head = false,
get = false,
Expand All @@ -138,12 +135,12 @@ export default class PostgrestClient<
} = {}
): PostgrestFilterBuilder<
Schema,
Function_['Returns'] extends any[]
? Function_['Returns'][number] extends Record<string, unknown>
? Function_['Returns'][number]
Fn['Returns'] extends any[]
? Fn['Returns'][number] extends Record<string, unknown>
? Fn['Returns'][number]
: never
: never,
Function_['Returns']
Fn['Returns']
> {
let method: 'HEAD' | 'GET' | 'POST'
const url = new URL(`${this.url}/rpc/${fn}`)
Expand Down Expand Up @@ -180,6 +177,6 @@ export default class PostgrestClient<
body,
fetch: this.fetch,
allowEmpty: false,
} as unknown as PostgrestBuilder<Function_['Returns']>)
} as unknown as PostgrestBuilder<Fn['Returns']>)
}
}

0 comments on commit ec0762c

Please sign in to comment.