From 662ae929223a82e0b0113248b6643d75bee3d2eb Mon Sep 17 00:00:00 2001 From: Gildas Garcia <1122076+djhi@users.noreply.github.com> Date: Wed, 8 Nov 2023 10:45:11 +0100 Subject: [PATCH] Allow to pass custom provider types to addRefreshAuth functions --- packages/ra-core/src/auth/addRefreshAuthToAuthProvider.ts | 8 +++++--- packages/ra-core/src/auth/addRefreshAuthToDataProvider.ts | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/ra-core/src/auth/addRefreshAuthToAuthProvider.ts b/packages/ra-core/src/auth/addRefreshAuthToAuthProvider.ts index 6c88b339936..6eb3b73c32a 100644 --- a/packages/ra-core/src/auth/addRefreshAuthToAuthProvider.ts +++ b/packages/ra-core/src/auth/addRefreshAuthToAuthProvider.ts @@ -20,10 +20,12 @@ import { AuthProvider } from '../types'; * * const authProvider = addRefreshAuthToAuthProvider(authProvider, refreshAuth); */ -export const addRefreshAuthToAuthProvider = ( - provider: AuthProvider, +export const addRefreshAuthToAuthProvider = < + AuthProviderType extends AuthProvider = AuthProvider +>( + provider: AuthProviderType, refreshAuth: () => Promise -): AuthProvider => { +): AuthProviderType => { const proxy = new Proxy(provider, { get(_, name) { const shouldIntercept = diff --git a/packages/ra-core/src/auth/addRefreshAuthToDataProvider.ts b/packages/ra-core/src/auth/addRefreshAuthToDataProvider.ts index 100f9d7e723..722bfb463ee 100644 --- a/packages/ra-core/src/auth/addRefreshAuthToDataProvider.ts +++ b/packages/ra-core/src/auth/addRefreshAuthToDataProvider.ts @@ -19,10 +19,12 @@ import { DataProvider } from '../types'; * * const dataProvider = addRefreshAuthToDataProvider(jsonServerProvider('http://localhost:3000'), refreshAuth); */ -export const addRefreshAuthToDataProvider = ( - provider: DataProvider, +export const addRefreshAuthToDataProvider = < + DataProviderType extends DataProvider = DataProvider +>( + provider: DataProviderType, refreshAuth: () => Promise -): DataProvider => { +): DataProviderType => { const proxy = new Proxy(provider, { get(_, name) { return async (...args: any[]) => {