The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: cleanup deprecated project usage (#18659)
Kevin Grüneberg394b9844b613
diff --git a/studio/components/interfaces/Home/ProjectUsageSection.tsx b/studio/components/interfaces/Home/ProjectUsageSection.tsxindex 493de068e3f..79b85b9fa4e 100644--- a/studio/components/interfaces/Home/ProjectUsageSection.tsx+++ b/studio/components/interfaces/Home/ProjectUsageSection.tsx@@ -4,20 +4,16 @@ import { IconAlertCircle, IconLoader } from 'ui'import { NewProjectPanel } from 'components/interfaces/Home'import InformationBox from 'components/ui/InformationBox'-import { ProjectUsageResponseUsageKeys, useProjectUsageQuery } from 'data/usage/project-usage-query'import ProjectUsage from './ProjectUsage'+import { useProjectLogRequestsCountQuery } from 'data/analytics/project-log-requests-count-query'const ProjectUsageSection = observer(() => {const { ref: projectRef } = useParams()- const { data: usage, error: usageError, isLoading } = useProjectUsageQuery({ projectRef })-- const usageColumns = [- 'db_egress',- 'storage_egress',- 'monthly_active_users',- 'realtime_message_count',- 'func_invocations',- ]+ const {+ data: usage,+ error: usageError,+ isLoading,+ } = useProjectLogRequestsCountQuery({ projectRef })if (usageError) {return (@@ -30,11 +26,8 @@ const ProjectUsageSection = observer(() => {)}- const hasProjectData = usage- ? usageColumns- .map((key) => usage[key as ProjectUsageResponseUsageKeys].usage)- .some((usage) => (usage ?? 0) > 0)- : false+ const hasProjectData =+ usage?.result && usage.result.length > 0 ? usage.result[0].count > 0 : falsereturn (<>diff --git a/studio/components/interfaces/Settings/Database/DiskSizeConfiguration.tsx b/studio/components/interfaces/Settings/Database/DiskSizeConfiguration.tsxindex d40c42651b2..6c55eceb11b 100644--- a/studio/components/interfaces/Settings/Database/DiskSizeConfiguration.tsx+++ b/studio/components/interfaces/Settings/Database/DiskSizeConfiguration.tsx@@ -11,7 +11,6 @@ import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectConteimport { FormHeader } from 'components/ui/Forms'import Panel from 'components/ui/Panel'import { useProjectDiskResizeMutation } from 'data/config/project-disk-resize-mutation'-import { useProjectUsageQuery } from 'data/usage/project-usage-query'import { useCheckPermissions, useSelectedOrganization, useStore } from 'hooks'import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'@@ -43,7 +42,6 @@ const DiskSizeConfiguration = ({ disabled = false }: DiskSizeConfigurationProps)},})- const { data: projectUsage } = useProjectUsageQuery({ projectRef })const { data: projectSubscriptionData } = useOrgSubscriptionQuery({ orgSlug: organization?.slug })const { mutate: updateProjectUsage, isLoading: isUpdatingDiskSize } =useProjectDiskResizeMutation({@@ -62,7 +60,7 @@ const DiskSizeConfiguration = ({ disabled = false }: DiskSizeConfigurationProps)updateProjectUsage({ projectRef, volumeSize })}- const currentDiskSize = projectUsage?.disk_volume_size_gb ?? 0+ const currentDiskSize = project?.volumeSizeGb ?? 0// to do, update with max_disk_volume_size_gbconst maxDiskSize = 200@@ -87,7 +85,7 @@ const DiskSizeConfiguration = ({ disabled = false }: DiskSizeConfigurationProps)<Panel.Content><div className="grid grid-cols-1 items-center lg:grid-cols-3"><div className="col-span-2 space-y-1">- {projectUsage?.disk_volume_size_gb && (+ {currentDiskSize && (<span className="text-foreground-light flex gap-2 items-baseline"><span className="text-foreground">Current Disk Storage Size:</span><span className="text-foreground text-xl">diff --git a/studio/data/analytics/daily-stats-query.ts b/studio/data/analytics/daily-stats-query.tsdeleted file mode 100644index 4e5050a14af..00000000000--- a/studio/data/analytics/daily-stats-query.ts+++ /dev/null@@ -1,187 +0,0 @@-import { useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query'-import dayjs from 'dayjs'-import { get } from 'lib/common/fetch'-import { API_URL } from 'lib/constants'-import { useCallback } from 'react'-import { AnalyticsData } from './constants'-import { analyticsKeys } from './keys'--export type DailyStatsVariables = {- projectRef?: string- attribute:- | 'total_db_egress_bytes'- | 'total_db_size_bytes'- | 'total_egress_modified'-- // Realtime- | 'total_realtime_ingress'- | 'total_realtime_egress'- | 'total_realtime_message_count'- | 'total_realtime_peak_connection'- | 'total_realtime_requests'- | 'total_realtime_get_requests'- | 'total_realtime_post_requests'- | 'total_realtime_patch_requests'- | 'total_realtime_delete_requests'- | 'total_realtime_options_requests'-- // Rest- | 'total_rest_ingress'- | 'total_rest_egress'- | 'total_rest_requests'- | 'total_rest_get_requests'- | 'total_rest_post_requests'- | 'total_rest_patch_requests'- | 'total_rest_delete_requests'- | 'total_rest_options_requests'-- // Auth- | 'total_auth_billing_period_mau'- | 'total_auth_billing_period_sso_mau'- | 'total_auth_ingress'- | 'total_auth_egress'- | 'total_auth_texts'- | 'total_auth_users'- | 'total_auth_emails'- | 'total_auth_requests'- | 'total_auth_get_requests'- | 'total_auth_post_requests'- | 'total_auth_patch_requests'- | 'total_auth_delete_requests'- | 'total_auth_options_requests'-- // Storage- | 'total_storage_ingress'- | 'total_storage_egress'- | 'total_storage_size_bytes'- | 'total_storage_image_render_count'- | 'total_storage_requests'- | 'total_storage_get_requests'- | 'total_storage_post_requests'- | 'total_storage_patch_requests'- | 'total_storage_delete_requests'- | 'total_storage_options_requests'-- // Edge functions- | 'total_func_count'- | 'total_func_invocations'- | 'total_func_exec_time_ms'- | 'total_func_ingress'- | 'total_func_egress'-- // Combined- | 'total_ingress'- | 'total_egress'- | 'total_requests'- | 'total_get_requests'- | 'total_post_requests'- | 'total_patch_requests'- | 'total_delete_requests'- | 'total_options_requests'- startDate?: string- endDate?: string- interval?: string- dateFormat?: string- modifier?: (x: number) => number-}--export async function getDailyStats(- { projectRef, attribute, startDate, endDate, interval = '1d' }: DailyStatsVariables,- signal?: AbortSignal-) {- if (!projectRef) throw new Error('Project ref is required')- if (!attribute) throw new Error('Attribute is required')- if (!startDate) throw new Error('Start date is required')- if (!endDate) throw new Error('Start date is required')-- const data = await get(- `${API_URL}/projects/${projectRef}/daily-stats?attribute=${attribute}&startDate=${encodeURIComponent(- startDate- )}&endDate=${encodeURIComponent(endDate)}&interval=${interval}`,- { signal }- )- if (data.error) throw data.error- return data as AnalyticsData-}--export type DailyStatsData = Awaited<ReturnType<typeof getDailyStats>>-export type DailyStatsError = unknown--export const useDailyStatsQuery = <TData = DailyStatsData>(- {- projectRef,- attribute,- startDate,- endDate,- interval = '1d',- dateFormat = 'DD MMM',- modifier,- }: DailyStatsVariables,- { enabled = true, ...options }: UseQueryOptions<DailyStatsData, DailyStatsError, TData> = {}-) =>- useQuery<DailyStatsData, DailyStatsError, TData>(- analyticsKeys.dailyStats(projectRef, { attribute, startDate, endDate, interval }),- ({ signal }) => getDailyStats({ projectRef, attribute, startDate, endDate, interval }, signal),- {- enabled:- enabled &&- typeof projectRef !== 'undefined' &&- typeof attribute !== 'undefined' &&- typeof startDate !== 'undefined' &&- typeof endDate !== 'undefined',-- select(data) {- const noDataYet = data.data[0]?.id === undefined-- // [Joshen] Ideally handled by API, like infra-monitoring- if (noDataYet) {- const days = dayjs(endDate).diff(dayjs(startDate), 'days')- const tempArray = new Array(days).fill(0)- const mockData = tempArray.map((x, idx) => {- return {- loopId: idx,- period_start: dayjs(startDate).add(idx, 'day').format('DD MMM YYYY'),- periodStartFormatted: dayjs(startDate).add(idx, 'day').format(dateFormat),- [attribute]: 0,- }- })- return { ...data, data: mockData, hasNoData: true } as TData- } else {- return {- ...data,- hasNoData: false,- data: data.data.map((x) => {- return {- ...x,- [attribute]:- modifier !== undefined ? modifier(Number(x[attribute])) : Number(x[attribute]),- periodStartFormatted: dayjs(x.period_start).format(dateFormat),- }- }),- } as TData- }- },- staleTime: 1000 * 60 * 60, // default good for an hour for now- ...options,- }- )--export const useDailyStatsPrefetch = ({- projectRef,- attribute,- startDate,- endDate,- interval = '1d',-}: DailyStatsVariables) => {- const client = useQueryClient()-- return useCallback(() => {- if (projectRef && attribute && startDate && endDate && interval) {- client.prefetchQuery(- analyticsKeys.dailyStats(projectRef, { attribute, startDate, endDate, interval }),- ({ signal }) =>- getDailyStats({ projectRef, attribute, startDate, endDate, interval }, signal)- )- }- }, [projectRef])-}diff --git a/studio/data/analytics/functions-inv-stats-query.ts b/studio/data/analytics/functions-inv-stats-query.tsindex 5433a29ea1e..b40713a2a01 100644--- a/studio/data/analytics/functions-inv-stats-query.ts+++ b/studio/data/analytics/functions-inv-stats-query.ts@@ -1,7 +1,6 @@-import { useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query'+import { useQuery, UseQueryOptions } from '@tanstack/react-query'import { get } from 'lib/common/fetch'import { API_URL } from 'lib/constants'-import { useCallback } from 'react'import { analyticsKeys } from './keys'export type FunctionsInvStatsVariables = {@@ -61,20 +60,3 @@ export const useFunctionsInvStatsQuery = <TData = FunctionsInvStatsData>(...options,})--export const useFunctionsInvStatsPrefetch = ({- projectRef,- functionId,- interval,-}: FunctionsInvStatsVariables) => {- const client = useQueryClient()-- return useCallback(() => {- if (projectRef && functionId && interval) {- client.prefetchQuery(- analyticsKeys.functionsInvStats(projectRef, { functionId, interval }),- ({ signal }) => getFunctionsInvStats({ projectRef, functionId, interval }, signal)- )- }- }, [projectRef, functionId, interval])-}diff --git a/studio/data/analytics/infra-monitoring-query.ts b/studio/data/analytics/infra-monitoring-query.tsindex 1783de01939..6f8101451af 100644--- a/studio/data/analytics/infra-monitoring-query.ts+++ b/studio/data/analytics/infra-monitoring-query.ts@@ -1,8 +1,7 @@-import { useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query'+import { useQuery, UseQueryOptions } from '@tanstack/react-query'import dayjs from 'dayjs'import { get } from 'lib/common/fetch'import { API_URL } from 'lib/constants'-import { useCallback } from 'react'import { AnalyticsData } from './constants'import { analyticsKeys } from './keys'@@ -88,23 +87,3 @@ export const useInfraMonitoringQuery = <TData = InfraMonitoringData>(...options,})--export const useInfraMonitoringPrefetch = ({- projectRef,- attribute,- startDate,- endDate,- interval = '1d',-}: InfraMonitoringVariables) => {- const client = useQueryClient()-- return useCallback(() => {- if (projectRef && attribute && startDate && endDate && interval) {- client.prefetchQuery(- analyticsKeys.infraMonitoring(projectRef, { attribute, startDate, endDate, interval }),- ({ signal }) =>- getInfraMonitoring({ projectRef, attribute, startDate, endDate, interval }, signal)- )- }- }, [projectRef])-}diff --git a/studio/data/analytics/keys.ts b/studio/data/analytics/keys.tsindex e05ca869d93..41029a404ff 100644--- a/studio/data/analytics/keys.ts+++ b/studio/data/analytics/keys.ts@@ -68,6 +68,9 @@ export const analyticsKeys = {] as const,usageApiCounts: (projectRef: string | undefined, interval: string | undefined) =>['projects', projectRef, 'usage.api-counts', interval] as const,++ usageApiRequestsCount: (projectRef: string | undefined) =>+ ['projects', projectRef, 'usage.api-requests-count'] as const,}function isoDateStringToDate(isoDateString: string | undefined): string | undefined {diff --git a/studio/data/analytics/project-log-requests-count-query.ts b/studio/data/analytics/project-log-requests-count-query.tsnew file mode 100644index 00000000000..dd092593fc1--- /dev/null+++ b/studio/data/analytics/project-log-requests-count-query.ts@@ -0,0 +1,56 @@+import { useQuery, UseQueryOptions } from '@tanstack/react-query'+import { get } from 'data/fetchers'+import { analyticsKeys } from './keys'+import { ResponseError } from 'types'++export type ProjectLogRequestsCountVariables = {+ projectRef?: string+}++export async function getProjectLogRequestsCountStats(+ { projectRef }: ProjectLogRequestsCountVariables,+ signal?: AbortSignal+) {+ if (!projectRef) {+ throw new Error('projectRef is required')+ }++ const { data, error } = await get(+ '/platform/projects/{ref}/analytics/endpoints/usage.api-requests-count',+ {+ params: {+ path: {+ ref: projectRef,+ },+ },+ signal,+ }+ )++ if (error) {+ throw error+ }++ return data+}++export type ProjectLogRequestsCountData = Awaited<+ ReturnType<typeof getProjectLogRequestsCountStats>+>+export type ProjectLogRequestsCountError = ResponseError++export const useProjectLogRequestsCountQuery = <TData = ProjectLogRequestsCountData>(+ { projectRef }: ProjectLogRequestsCountVariables,+ {+ enabled = true,+ ...options+ }: UseQueryOptions<ProjectLogRequestsCountData, ProjectLogRequestsCountError, TData> = {}+) =>+ useQuery<ProjectLogRequestsCountData, ProjectLogRequestsCountError, TData>(+ analyticsKeys.usageApiRequestsCount(projectRef),+ ({ signal }) => getProjectLogRequestsCountStats({ projectRef }, signal),+ {+ enabled: enabled && typeof projectRef !== 'undefined',+ ...options,+ }+ )diff --git a/studio/data/analytics/project-log-stats-query.ts b/studio/data/analytics/project-log-stats-query.tsindex 015ff60cb86..d29c1dce999 100644--- a/studio/data/analytics/project-log-stats-query.ts+++ b/studio/data/analytics/project-log-stats-query.ts@@ -1,7 +1,6 @@-import { useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query'+import { useQuery, UseQueryOptions } from '@tanstack/react-query'import { get, isResponseOk } from 'lib/common/fetch'import { API_URL } from 'lib/constants'-import { useCallback } from 'react'import { analyticsKeys } from './keys'export type ProjectLogStatsVariables = {@@ -62,15 +61,3 @@ export const useProjectLogStatsQuery = <TData = ProjectLogStatsData>(...options,})--export const useProjectLogStatsPrefetch = ({ projectRef, interval }: ProjectLogStatsVariables) => {- const client = useQueryClient()-- return useCallback(() => {- if (projectRef && interval) {- client.prefetchQuery(analyticsKeys.usageApiCounts(projectRef, interval), ({ signal }) =>- getProjectLogStats({ projectRef, interval }, signal)- )- }- }, [projectRef, interval])-}diff --git a/studio/data/api.d.ts b/studio/data/api.d.tsindex 4d217ede240..82697fa9173 100644--- a/studio/data/api.d.ts+++ b/studio/data/api.d.ts@@ -52,6 +52,10 @@ export interface paths {*/get: operations['ProjectsResourceWarningsController_getProjectsResourceWarnings']}+ '/platform/tos/fly': {+ /** Redirects to Fly sso flow */+ get: operations['TermsOfServiceController_flyTosAccepted']+ }'/platform/auth/{ref}/config': {/** Gets GoTrue config */get: operations['GoTrueConfigController_getGoTrueConfig']@@ -549,6 +553,10 @@ export interface paths {/** Gets project's usage api counts */get: operations['UsageApiController_getApiCounts']}+ '/platform/projects/{ref}/analytics/endpoints/usage.api-requests-count': {+ /** Gets project's usage api requests count */+ get: operations['UsageApiController_getApiRequestsCount']+ }'/platform/projects/{ref}/config/pgbouncer': {/** Gets project's pgbouncer config */get: operations['PgbouncerConfigController_getPgbouncerConfig']@@ -792,6 +800,10 @@ export interface paths {/** Gets a specific github branch for a given repo */get: operations['GitHubBranchController_getBranchByName']}+ '/platform/integrations/github/pull-requests/{organization_integration_id}/{repo_owner}/{repo_name}': {+ /** Gets github pull requests for a given repo */+ get: operations['GitHubPullRequestController_getPullRequestsByNumber']+ }'/platform/integrations/github/pull-requests/{organization_integration_id}/{repo_owner}/{repo_name}/{target}': {/** Gets github pull requests for a given repo */get: operations['GitHubPullRequestController_getPullRequests']@@ -1281,6 +1293,10 @@ export interface paths {/** Gets project's usage api counts */get: operations['UsageApiController_getApiCounts']}+ '/v0/projects/{ref}/analytics/endpoints/usage.api-requests-count': {+ /** Gets project's usage api requests count */+ get: operations['UsageApiController_getApiRequestsCount']+ }'/v0/projects/{ref}/config/pgbouncer': {/** Gets project's pgbouncer config */get: operations['PgbouncerConfigController_getPgbouncerConfig']@@ -1655,7 +1671,7 @@ export interface paths {get: operations['SnippetsController_getSnippet']}'/partners/flyio/callback': {- /** Redirects to Supabase dashboard after Fly sso with Gotrue */+ /** Redirects to Supabase dashboard after completing Fly sso */get: operations['CallbackController_redirectToDashboardFlyioExtensionScreen']}'/partners/flyio/extensions/{extension_id}': {@@ -1665,7 +1681,7 @@ export interface paths {delete: operations['ExtensionController_deleteResource']}'/partners/flyio/extensions/{extension_id}/sso': {- /** Starts Flyio single sign on */+ /** Starts Fly single sign on */get: operations['ExtensionController_startFlyioSSO']}'/partners/flyio/extensions/{extension_id}/billing': {@@ -1676,6 +1692,14 @@ export interface paths {/** Creates a database */post: operations['ExtensionsController_provisionResource']}+ '/partners/flyio/organizations/{organization_id}/extensions': {+ /** Gets all databases that belong to the Fly organization */+ get: operations['OrganizationsController_getOrgExtensions']+ }+ '/partners/flyio/organizations/{organization_id}/sso': {+ /** Starts Fly single sign on */+ get: operations['OrganizationsController_startFlyioSSO']+ }}export type webhooks = Record<string, never>@@ -3295,11 +3319,11 @@ export interface components {| 'project_storage:all'| 'project_edge_function:all'| 'profile:update'- | 'billing:all'| 'billing:account_data'| 'billing:credits'| 'billing:invoices'| 'billing:payment_methods'+ | 'realtime:all')[]}UpdateProfileBody: {@@ -4164,7 +4188,7 @@ export interface components {GitRef: {repo: stringbranch: string- label: string+ label?: string}GetGithubPullRequest: {id: number@@ -4175,7 +4199,7 @@ export interface components {created_by?: stringrepo: stringbranch: string- label: string+ label?: string}FunctionResponse: {id: string@@ -4404,6 +4428,9 @@ export interface components {UpgradeDatabaseBody: {target_version: number}+ ProjectUpgradeInitiateResponse: {+ tracking_id: string+ }ProjectVersion: {postgres_version: numberapp_version: string@@ -4785,6 +4812,29 @@ export interface components {/** @description Welcome message */message: string}+ OrganizationExtensionStatus: {+ /** @description Supabase project instance compute size */+ compute: string+ /** @description Unique ID representing the fly extension */+ id: string+ /**+ * @description Supabase project status+ * @example ACTIVE_HEALTHY+ * @enum {string}+ */+ status:+ | 'REMOVED'+ | 'COMING_UP'+ | 'INACTIVE'+ | 'ACTIVE_HEALTHY'+ | 'ACTIVE_UNHEALTHY'+ | 'UNKNOWN'+ | 'GOING_DOWN'+ | 'INIT_FAILED'+ | 'RESTORING'+ | 'UPGRADING'+ | 'PAUSING'+ }}responses: neverparameters: never@@ -4960,6 +5010,20 @@ export interface operations {}}}+ /** Redirects to Fly sso flow */+ TermsOfServiceController_flyTosAccepted: {+ parameters: {+ query: {+ extension_id: string+ organization_id: string+ }+ }+ responses: {+ 200: {+ content: never+ }+ }+ }/** Gets GoTrue config */GoTrueConfigController_getGoTrueConfig: {parameters: {@@ -8778,6 +8842,26 @@ export interface operations {}}}+ /** Gets project's usage api requests count */+ UsageApiController_getApiRequestsCount: {+ parameters: {+ path: {+ /** @description Project ref */+ ref: string+ }+ }+ responses: {+ 200: {+ content: {+ 'application/json': components['schemas']['AnalyticsResponse']+ }+ }+ /** @description Failed to get project's usage api requests count */+ 500: {+ content: never+ }+ }+ }/** Gets project's pgbouncer config */PgbouncerConfigController_getPgbouncerConfig: {parameters: {@@ -10130,6 +10214,30 @@ export interface operations {}}/** Gets github pull requests for a given repo */+ GitHubPullRequestController_getPullRequestsByNumber: {+ parameters: {+ query: {+ pr_number: number+ }+ path: {+ organization_integration_id: string+ repo_owner: string+ repo_name: string+ }+ }+ responses: {+ 200: {+ content: {+ 'application/json': components['schemas']['GetGithubPullRequest'][]+ }+ }+ /** @description Failed to get github pull requests for a given repo */+ 500: {+ content: never+ }+ }+ }+ /** Gets github pull requests for a given repo */GitHubPullRequestController_getPullRequests: {parameters: {query?: {@@ -11477,7 +11585,9 @@ export interface operations {}responses: {201: {- content: never+ content: {+ 'application/json': components['schemas']['ProjectUpgradeInitiateResponse']+ }}403: {content: never@@ -12137,7 +12247,7 @@ export interface operations {}}}- /** Redirects to Supabase dashboard after Fly sso with Gotrue */+ /** Redirects to Supabase dashboard after completing Fly sso */CallbackController_redirectToDashboardFlyioExtensionScreen: {responses: {200: {@@ -12173,7 +12283,7 @@ export interface operations {}}}- /** Starts Flyio single sign on */+ /** Starts Fly single sign on */ExtensionController_startFlyioSSO: {parameters: {path: {@@ -12216,4 +12326,32 @@ export interface operations {}}}+ /** Gets all databases that belong to the Fly organization */+ OrganizationsController_getOrgExtensions: {+ parameters: {+ path: {+ organization_id: string+ }+ }+ responses: {+ 200: {+ content: {+ 'application/json': components['schemas']['OrganizationExtensionStatus'][]+ }+ }+ }+ }+ /** Starts Fly single sign on */+ OrganizationsController_startFlyioSSO: {+ parameters: {+ path: {+ organization_id: string+ }+ }+ responses: {+ 200: {+ content: never+ }+ }+ }}diff --git a/studio/data/custom-domains/custom-domains-query.ts b/studio/data/custom-domains/custom-domains-query.tsindex 1bcaf877586..05e43eea7ad 100644--- a/studio/data/custom-domains/custom-domains-query.ts+++ b/studio/data/custom-domains/custom-domains-query.ts@@ -1,5 +1,4 @@-import { useCallback } from 'react'-import { useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query'+import { useQuery, UseQueryOptions } from '@tanstack/react-query'import { get } from 'lib/common/fetch'import { API_ADMIN_URL, IS_PLATFORM } from 'lib/constants'@@ -135,15 +134,3 @@ export const useCustomDomainsQuery = <TData = CustomDomainsData>(({ signal }) => getCustomDomains({ projectRef }, signal),{ enabled: enabled && IS_PLATFORM && typeof projectRef !== 'undefined', ...options })--export const useCustomDomainsPrefetch = ({ projectRef }: CustomDomainsVariables) => {- const client = useQueryClient()-- return useCallback(() => {- if (projectRef) {- client.prefetchQuery(customDomainKeys.list(projectRef), ({ signal }) =>- getCustomDomains({ projectRef }, signal)- )- }- }, [projectRef])-}diff --git a/studio/data/organizations/organization-audit-logs-query.ts b/studio/data/organizations/organization-audit-logs-query.tsindex 8da3d9c1c44..269419e97bd 100644--- a/studio/data/organizations/organization-audit-logs-query.ts+++ b/studio/data/organizations/organization-audit-logs-query.ts@@ -1,6 +1,5 @@-import { useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query'+import { useQuery, UseQueryOptions } from '@tanstack/react-query'import dayjs from 'dayjs'-import { useCallback } from 'react'import { get } from 'lib/common/fetch'import { API_URL } from 'lib/constants'@@ -81,20 +80,3 @@ export const useOrganizationAuditLogsQuery = <TData = OrganizationAuditLogsData>})}--export const useOrganizationAuditLogsPrefetch = (vars: OrganizationAuditLogsVariables) => {- const { slug, iso_timestamp_start, iso_timestamp_end } = vars- const client = useQueryClient()-- return useCallback(() => {- if (slug) {- const date_start = dayjs(iso_timestamp_start).utc().format('YYYY-MM-DD')- const date_end = dayjs(iso_timestamp_end).utc().format('YYYY-MM-DD')- client.prefetchQuery(- organizationKeys.auditLogs(slug, { date_start, date_end }),- ({ signal }) => getOrganizationAuditLogs(vars, signal)- )- }- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [client, vars])-}diff --git a/studio/data/organizations/organization-detail-query.ts b/studio/data/organizations/organization-detail-query.tsindex f07aa19e74d..3fddeb74dfb 100644--- a/studio/data/organizations/organization-detail-query.ts+++ b/studio/data/organizations/organization-detail-query.ts@@ -1,7 +1,6 @@-import { useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query'+import { useQuery, UseQueryOptions } from '@tanstack/react-query'import { get } from 'lib/common/fetch'import { API_URL } from 'lib/constants'-import { useCallback } from 'react'import { Member, ResponseError } from 'types'import { organizationKeys } from './keys'@@ -73,15 +72,3 @@ export const useOrganizationDetailQuery = <TData = OrganizationDetailData>(...options,})--export const useOrganizationDetailPrefetch = ({ slug }: OrganizationDetailVariables) => {- const client = useQueryClient()-- return useCallback(() => {- if (slug) {- client.prefetchQuery(organizationKeys.detail(slug), ({ signal }) =>- getOrganizationDetail({ slug }, signal)- )- }- }, [slug])-}diff --git a/studio/data/organizations/organization-roles-query.ts b/studio/data/organizations/organization-roles-query.tsindex 699eef8cd89..5079dcb0f4b 100644--- a/studio/data/organizations/organization-roles-query.ts+++ b/studio/data/organizations/organization-roles-query.ts@@ -1,7 +1,6 @@-import { useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query'+import { useQuery, UseQueryOptions } from '@tanstack/react-query'import { get } from 'lib/common/fetch'import { API_URL } from 'lib/constants'-import { useCallback } from 'react'import { ResponseError, Role } from 'types'import { organizationKeys } from './keys'@@ -49,15 +48,3 @@ export const useOrganizationRolesQuery = <TData = OrganizationRolesData>(...options,})--export const useOrganizationRolesPrefetch = ({ slug }: OrganizationRolesVariables) => {- const client = useQueryClient()-- return useCallback(() => {- if (slug) {- client.prefetchQuery(organizationKeys.roles(slug), ({ signal }) =>- getOrganizationRoles({ slug }, signal)- )- }- }, [slug])-}diff --git a/studio/data/projects/project-transfer-preview-query.ts b/studio/data/projects/project-transfer-preview-query.tsindex a5edae66caf..08bab5b916b 100644--- a/studio/data/projects/project-transfer-preview-query.ts+++ b/studio/data/projects/project-transfer-preview-query.ts@@ -1,7 +1,6 @@-import { useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query'+import { useQuery, UseQueryOptions } from '@tanstack/react-query'import { post } from 'lib/common/fetch'import { API_URL } from 'lib/constants'-import { useCallback } from 'react'import { projectKeys } from './keys'export type ProjectTransferPreviewVariables = {@@ -105,19 +104,3 @@ export const useProjectTransferPreviewQuery = <TData = ProjectTransferPreviewDat},})--export const useProjectTransferPreviewPrefetch = ({- projectRef,- targetOrganizationSlug,-}: ProjectTransferPreviewVariables) => {- const client = useQueryClient()-- return useCallback(() => {- if (projectRef && targetOrganizationSlug) {- client.prefetchQuery(- projectKeys.projectTransferPreview(projectRef, targetOrganizationSlug),- ({ signal }) => previewProjectTransfer({ projectRef, targetOrganizationSlug }, signal)- )- }- }, [projectRef, targetOrganizationSlug])-}diff --git a/studio/data/usage/project-usage-query.ts b/studio/data/usage/project-usage-query.tsdeleted file mode 100644index bc1e7a1ce19..00000000000--- a/studio/data/usage/project-usage-query.ts+++ /dev/null@@ -1,83 +0,0 @@-import { useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query'-import { get } from 'lib/common/fetch'-import { API_URL } from 'lib/constants'-import { useCallback } from 'react'-import { usageKeys } from './keys'--export type ProjectUsageVariables = {- projectRef?: string-}--export interface UsageMetric {- usage: number- limit: number- cost: number- available_in_plan: boolean- // [Joshen] can we verify if this is still getting passed?- // Only for database and storage size- current?: number-}--export type ProjectUsageResponse = {- db_size: UsageMetric- db_egress: UsageMetric- storage_size: UsageMetric- storage_egress: UsageMetric- storage_image_render_count: UsageMetric- monthly_active_users: UsageMetric- monthly_active_sso_users: UsageMetric- realtime_message_count: UsageMetric- realtime_peak_connection: UsageMetric- func_count: UsageMetric- func_invocations: UsageMetric- disk_volume_size_gb: number-}--export type ProjectUsageResponseUsageKeys = keyof Omit<ProjectUsageResponse, 'disk_volume_size_gb'>--export async function getProjectUsage({ projectRef }: ProjectUsageVariables, signal?: AbortSignal) {- if (!projectRef) {- throw new Error('projectRef is required')- }-- const response = await get(`${API_URL}/projects/${projectRef}/usage`, {- signal,- })- if (response.error) {- throw response.error- }-- return response as ProjectUsageResponse-}--export type ProjectUsageData = Awaited<ReturnType<typeof getProjectUsage>>-export type ProjectUsageError = unknown--export const useProjectUsageQuery = <TData = ProjectUsageData>(- { projectRef }: ProjectUsageVariables,- { enabled = true, ...options }: UseQueryOptions<ProjectUsageData, ProjectUsageError, TData> = {}-) =>- useQuery<ProjectUsageData, ProjectUsageError, TData>(- usageKeys.usage(projectRef),- ({ signal }) => getProjectUsage({ projectRef }, signal),- {- enabled: enabled && typeof projectRef !== 'undefined',- select(data) {- return Object.fromEntries(- Object.entries(data).map(([key, value]) => {- if (typeof value === 'object') {- const formattedValue = {- ...value,- usage: Number(value.usage),- }-- return [key, formattedValue]- } else {- return [key, value]- }- })- )- },- ...options,- }- )diff --git a/studio/pages/api/projects/[ref]/daily-stats.ts b/studio/pages/api/projects/[ref]/daily-stats.tsdeleted file mode 100644index 35523e117a2..00000000000--- a/studio/pages/api/projects/[ref]/daily-stats.ts+++ /dev/null@@ -1,28 +0,0 @@-import { NextApiRequest, NextApiResponse } from 'next'-import apiWrapper from 'lib/api/apiWrapper'--export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)--async function handler(req: NextApiRequest, res: NextApiResponse) {- const { method } = req-- switch (method) {- case 'GET':- return handleGetAll(req, res)- default:- res.setHeader('Allow', ['GET'])- res.status(405).json({ data: null, error: { message: `Method ${method} Not Allowed` } })- }-}--const handleGetAll = async (req: NextApiRequest, res: NextApiResponse) => {- // Platform specific endpoint- const response = {- data: [],- yAxisLimit: 0,- format: '%',- totalAverage: 0,- total: 0,- }- return res.status(200).json(response)-}diff --git a/studio/pages/api/projects/[ref]/usage.ts b/studio/pages/api/projects/[ref]/usage.tsdeleted file mode 100644index 107a5ace541..00000000000--- a/studio/pages/api/projects/[ref]/usage.ts+++ /dev/null@@ -1,22 +0,0 @@-import { NextApiRequest, NextApiResponse } from 'next'-import apiWrapper from 'lib/api/apiWrapper'--export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)--async function handler(req: NextApiRequest, res: NextApiResponse) {- const { method } = req-- switch (method) {- case 'GET':- return handleGetAll(req, res)- default:- res.setHeader('Allow', ['GET'])- res.status(405).json({ data: null, error: { message: `Method ${method} Not Allowed` } })- }-}--const handleGetAll = async (req: NextApiRequest, res: NextApiResponse) => {- return res- .status(200)- .json({ dbSize: '888888', authUsers: '0', bucketSize: '888888', dbTables: '0' })-}diff --git a/studio/types/base.ts b/studio/types/base.tsindex aa9df3e7e28..c28d6f76565 100644--- a/studio/types/base.ts+++ b/studio/types/base.ts@@ -48,6 +48,7 @@ export interface Project extends ProjectBase {* irregardless of being on any branch, such as ProjectDropdown and Vercel integration* */parentRef?: string+ volumeSizeGb?: number}export interface User {