The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
import { useQuery } from '@tanstack/react-query'
import { oauthAppsKeys } from './keys'
import { getMockOAuthAppsAuthorizeIdentity, USE_MOCKS } from './mocks'
import type { OAuthOrganizationRole } from './types'
import type { ResponseError, UseCustomQueryOptions } from '@/types'
export type OAuthAppsAuthorizeOrganizationsVariables = {
id?: string
}
export type OAuthAppsAuthorizeIdentity = {
email: string
organizations: OAuthOrganizationRole[]
}
export async function getOAuthAppsAuthorizeIdentity({
id,
}: OAuthAppsAuthorizeOrganizationsVariables) {
if (!id) throw new Error('Authorization request id is required')
if (!USE_MOCKS) throw new Error('OAuth app authorization identity is not yet implemented')
return getMockOAuthAppsAuthorizeIdentity(id)
}
export type OAuthAppsAuthorizeOrganizationsData = Awaited<
ReturnType<typeof getOAuthAppsAuthorizeIdentity>
>
export type OAuthAppsAuthorizeOrganizationsError = ResponseError
export const useOAuthAppsAuthorizeOrganizationsQuery = <
TData = OAuthAppsAuthorizeOrganizationsData,
>(
{ id }: OAuthAppsAuthorizeOrganizationsVariables,
{
enabled = true,
...options
}: UseCustomQueryOptions<
OAuthAppsAuthorizeOrganizationsData,
OAuthAppsAuthorizeOrganizationsError,
TData
> = {}
) =>
useQuery<OAuthAppsAuthorizeOrganizationsData, OAuthAppsAuthorizeOrganizationsError, TData>({
queryKey: oauthAppsKeys.authorizeOrganizations(id),
queryFn: () => getOAuthAppsAuthorizeIdentity({ id }),
enabled: enabled && USE_MOCKS && Boolean(id),
...options,
})