mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
ref: Remove unused queries/mutations (#41163)
This commit is contained in:
1 parent
39c1e14fd8
commit
762bdfa741
4 files changed
-178
No files matched your search
@@ -1,73 +0,0 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import { toast } from 'sonner'
|
||||
|
||||
import type { components } from 'data/api'
|
||||
import { handleError, post } from 'data/fetchers'
|
||||
import type { ResponseError, UseCustomMutationOptions } from 'types'
|
||||
import type { Content } from './content-query'
|
||||
import { contentKeys } from './keys'
|
||||
|
||||
export type InsertContentPayload = Omit<components['schemas']['CreateContentBody'], 'content'> & {
|
||||
content: Content['content']
|
||||
favorite?: boolean
|
||||
}
|
||||
|
||||
export type InsertContentVariables = {
|
||||
projectRef: string
|
||||
payload: InsertContentPayload
|
||||
}
|
||||
|
||||
export type InsertContentResponse = components['schemas']['UserContentObject']
|
||||
|
||||
export async function insertContent(
|
||||
{ projectRef, payload }: InsertContentVariables,
|
||||
signal?: AbortSignal
|
||||
) {
|
||||
const { data, error } = await post('/platform/projects/{ref}/content', {
|
||||
params: { path: { ref: projectRef } },
|
||||
body: {
|
||||
id: payload.id,
|
||||
name: payload.name,
|
||||
description: payload.description,
|
||||
owner_id: payload.owner_id,
|
||||
type: payload.type,
|
||||
visibility: payload.visibility,
|
||||
content: payload.content as any,
|
||||
folder_id: payload.folder_id,
|
||||
favorite: payload.favorite,
|
||||
},
|
||||
signal,
|
||||
})
|
||||
if (error) handleError(error)
|
||||
return data
|
||||
}
|
||||
|
||||
export type InsertContentData = Awaited<ReturnType<typeof insertContent>>
|
||||
|
||||
export const useContentInsertMutation = ({
|
||||
onError,
|
||||
onSuccess,
|
||||
...options
|
||||
}: Omit<
|
||||
UseCustomMutationOptions<InsertContentData, ResponseError, InsertContentVariables>,
|
||||
'mutationFn'
|
||||
> = {}) => {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation<InsertContentData, ResponseError, InsertContentVariables>({
|
||||
mutationFn: (args) => insertContent(args),
|
||||
async onSuccess(data, variables, context) {
|
||||
const { projectRef } = variables
|
||||
await queryClient.invalidateQueries({ queryKey: contentKeys.allContentLists(projectRef) })
|
||||
await onSuccess?.(data, variables, context)
|
||||
},
|
||||
async onError(data, variables, context) {
|
||||
if (onError === undefined) {
|
||||
toast.error(`Failed to insert content: ${data.message}`)
|
||||
} else {
|
||||
onError(data, variables, context)
|
||||
}
|
||||
},
|
||||
...options,
|
||||
})
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import { toast } from 'sonner'
|
||||
|
||||
import type { components } from 'data/api'
|
||||
import { handleError, patch } from 'data/fetchers'
|
||||
import type { ResponseError, UseCustomMutationOptions } from 'types'
|
||||
import { databaseKeys } from './keys'
|
||||
|
||||
type SupavisorConfigurationUpdateVariables = {
|
||||
ref: string
|
||||
} & components['schemas']['UpdateSupavisorConfigBody']
|
||||
|
||||
export async function updateSupavisorConfiguration({
|
||||
ref,
|
||||
default_pool_size,
|
||||
}: SupavisorConfigurationUpdateVariables) {
|
||||
if (!ref) return console.error('Project ref is required')
|
||||
|
||||
const { data, error } = await patch('/platform/projects/{ref}/config/supavisor', {
|
||||
params: { path: { ref } },
|
||||
body: { default_pool_size },
|
||||
})
|
||||
|
||||
if (error) handleError(error)
|
||||
return data
|
||||
}
|
||||
|
||||
type SupavisorConfigurationUpdateData = Awaited<ReturnType<typeof updateSupavisorConfiguration>>
|
||||
|
||||
export const useSupavisorConfigurationUpdateMutation = ({
|
||||
onSuccess,
|
||||
onError,
|
||||
...options
|
||||
}: Omit<
|
||||
UseCustomMutationOptions<
|
||||
SupavisorConfigurationUpdateData,
|
||||
ResponseError,
|
||||
SupavisorConfigurationUpdateVariables
|
||||
>,
|
||||
'mutationFn'
|
||||
> = {}) => {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation<
|
||||
SupavisorConfigurationUpdateData,
|
||||
ResponseError,
|
||||
SupavisorConfigurationUpdateVariables
|
||||
>({
|
||||
mutationFn: (vars) => updateSupavisorConfiguration(vars),
|
||||
async onSuccess(data, variables, context) {
|
||||
const { ref } = variables
|
||||
await queryClient.invalidateQueries({ queryKey: databaseKeys.poolingConfiguration(ref) })
|
||||
await onSuccess?.(data, variables, context)
|
||||
},
|
||||
async onError(data, variables, context) {
|
||||
if (onError === undefined) {
|
||||
toast.error(`Failed to update Shared Pooler configuration: ${data.message}`)
|
||||
} else {
|
||||
onError(data, variables, context)
|
||||
}
|
||||
},
|
||||
...options,
|
||||
})
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { get, handleError } from 'data/fetchers'
|
||||
import type { ResponseError, UseCustomQueryOptions } from 'types'
|
||||
import { integrationKeys } from './keys'
|
||||
|
||||
export type GitHubBranchesVariables = {
|
||||
connectionId?: number
|
||||
}
|
||||
|
||||
export async function getGitHubBranches(
|
||||
{ connectionId }: GitHubBranchesVariables,
|
||||
signal?: AbortSignal
|
||||
) {
|
||||
if (!connectionId) throw new Error('connectionId is required')
|
||||
|
||||
const { data, error } = await get(`/platform/integrations/github/branches/{connection_id}`, {
|
||||
params: { path: { connection_id: connectionId } },
|
||||
signal,
|
||||
})
|
||||
|
||||
if (error) handleError(error)
|
||||
return data
|
||||
}
|
||||
|
||||
export type GitHubBranchesData = Awaited<ReturnType<typeof getGitHubBranches>>
|
||||
export type GitHubBranchesError = ResponseError
|
||||
|
||||
export const useGitHubBranchesQuery = <TData = GitHubBranchesData>(
|
||||
{ connectionId }: GitHubBranchesVariables,
|
||||
{
|
||||
enabled = true,
|
||||
...options
|
||||
}: UseCustomQueryOptions<GitHubBranchesData, GitHubBranchesError, TData> = {}
|
||||
) =>
|
||||
useQuery<GitHubBranchesData, GitHubBranchesError, TData>({
|
||||
queryKey: integrationKeys.githubBranchesList(connectionId),
|
||||
queryFn: ({ signal }) => getGitHubBranches({ connectionId }, signal),
|
||||
enabled: enabled && typeof connectionId !== 'undefined',
|
||||
...options,
|
||||
})
|
||||
@@ -21,7 +21,6 @@ export const integrationKeys = {
|
||||
],
|
||||
githubAuthorization: () => ['github-authorization'] as const,
|
||||
githubRepositoriesList: () => ['github-repositories'] as const,
|
||||
githubBranchesList: (connectionId: number | undefined) => ['github-branches', connectionId],
|
||||
githubConnectionsList: (organizationId: number | undefined) =>
|
||||
['organizations', organizationId, 'github-connections'] as const,
|
||||
vercelRedirect: (installationId?: string) => ['vercel-redirect', installationId] as const,
|
||||
|
||||
Reference in new issue
Block a user