Files
supabase/apps/studio/data/config/project-config-query.ts
Ivan Vasilov e10f7cc808 feat: Add a config drift page in Studio (#48906)
## New Features
- Initial work for showing configuration drift in Studio
- This only works for Github-connected projects and it'll show a banner
if the project state differs from the git-tracked `config.toml`
- Currently behind a feature-flag `ConfigDrift`, enabled on local and
staging.
- There might be drift shown without changing any setting, this is
work-in-progress.

<img width="1217" height="1195" alt="Screenshot 2026-08-19 at 23 12 10"
src="https://github.com/user-attachments/assets/fb0b18d8-1a93-4595-85cc-e8b8a3462847"
/>

## How to test
1. Connect a project to a Github repo
2. Resync the branch on `/dashboard/project/_/branches`. This will
trigger deployment of the `config.toml` on your project
3. Change some settings (I recommend
`dashboard/project/_/auth/providers`
4. A banner should appear on all project pages with a link 


## Tests
- Added coverage for configuration conversion, normalization, matching,
drift detection, and unmanaged settings.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-08-25 13:56:40 +02:00

42 lines
1.3 KiB
TypeScript

import { queryOptions } from '@tanstack/react-query'
import { configKeys } from './keys'
import { get, handleError } from '@/data/fetchers'
import { IS_PLATFORM } from '@/lib/constants'
import type { ResponseError } from '@/types'
export type ProjectConfigV2Variables = {
projectRef?: string
}
export async function getProjectConfig(
{ projectRef }: ProjectConfigV2Variables,
signal?: AbortSignal
) {
if (!projectRef) throw new Error('Project ref is required')
// [Alpha] GET /v2/projects/{ref}/config — the project's effective service config
// (database, pooler, auth, api, realtime, storage).
const { data, error } = await get('/v2/projects/{ref}/config', {
params: { path: { ref: projectRef } },
signal,
})
if (error) handleError(error)
return (data || { data: undefined }).data
}
export type ProjectConfigV2Data = Awaited<ReturnType<typeof getProjectConfig>>
export type ProjectConfigV2Error = ResponseError
export const projectConfigV2QueryOptions = (
{ projectRef }: ProjectConfigV2Variables,
{ enabled = true }: { enabled?: boolean } = { enabled: true }
) => {
return queryOptions({
queryKey: configKeys.projectConfig(projectRef),
queryFn: ({ signal }) => getProjectConfig({ projectRef }, signal),
enabled: enabled && IS_PLATFORM && typeof projectRef !== 'undefined',
})
}