mirror of
https://github.com/supabase/supabase.git
synced 2026-10-11 04:15:04 +03:00
* Add custom types for queries, mutations and infinite queries. * Migrate all queries to use the new type. * Migrate all infinite queries to useCustomInfiniteQueryOptions. * Migrate all mutations to use useCustomMutationOptions. * Add type to all imports in `types` folder.
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import { useQuery } from '@tanstack/react-query'
|
|
import { components } from 'api-types'
|
|
import { get, handleError } from 'data/fetchers'
|
|
import type { ResponseError, UseCustomQueryOptions } from 'types'
|
|
import { keys } from './keys'
|
|
|
|
export type GetThirdPartyAuthIntegrationsVariables = {
|
|
projectRef?: string
|
|
}
|
|
|
|
export type ThirdPartyAuthIntegration = components['schemas']['ThirdPartyAuth']
|
|
|
|
export async function getThirdPartyAuthIntegrations(
|
|
{ projectRef }: GetThirdPartyAuthIntegrationsVariables,
|
|
signal?: AbortSignal
|
|
) {
|
|
if (!projectRef) throw new Error('projectRef is required')
|
|
|
|
const { data, error } = await get('/v1/projects/{ref}/config/auth/third-party-auth', {
|
|
params: { path: { ref: projectRef } },
|
|
signal,
|
|
})
|
|
|
|
if (error) handleError(error)
|
|
return data
|
|
}
|
|
|
|
export type ThirdPartyAuthIntegrationsData = Awaited<
|
|
ReturnType<typeof getThirdPartyAuthIntegrations>
|
|
>
|
|
|
|
export const useThirdPartyAuthIntegrationsQuery = <TData = ThirdPartyAuthIntegrationsData>(
|
|
{ projectRef }: GetThirdPartyAuthIntegrationsVariables,
|
|
{
|
|
enabled = true,
|
|
...options
|
|
}: UseCustomQueryOptions<ThirdPartyAuthIntegrationsData, ResponseError, TData> = {}
|
|
) =>
|
|
useQuery<ThirdPartyAuthIntegrationsData, ResponseError, TData>({
|
|
queryKey: keys.integrations(projectRef),
|
|
queryFn: ({ signal }) => getThirdPartyAuthIntegrations({ projectRef }, signal),
|
|
enabled: enabled && typeof projectRef !== 'undefined',
|
|
...options,
|
|
})
|