The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix
Joshen Lim9e67f2b86bb7
diff --git a/studio/data/subscriptions/org-subscription-update-mutation.ts b/studio/data/subscriptions/org-subscription-update-mutation.tsindex 99f7ed989c4..210f85bdf2f 100644--- a/studio/data/subscriptions/org-subscription-update-mutation.ts+++ b/studio/data/subscriptions/org-subscription-update-mutation.ts@@ -2,7 +2,7 @@ import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/reactimport { put } from 'lib/common/fetch'import { API_URL } from 'lib/constants'import { subscriptionKeys } from './keys'-import { SupaResponse } from 'types/base'+import { SupaResponseV2 } from 'types/base'export type SubscriptionTier =| 'tier_free'@@ -17,21 +17,23 @@ export type OrgSubscriptionUpdateVariables = {tier: SubscriptionTier}-export async function updateOrgSubscription<T = any>({+export async function updateOrgSubscription<T = void>({slug,tier,paymentMethod,-}: OrgSubscriptionUpdateVariables): Promise<SupaResponse<T>> {+}: OrgSubscriptionUpdateVariables) {if (!slug) throw new Error('slug is required')if (!tier) throw new Error('tier is required')const payload: { tier: string; payment_method?: string } = { tier }if (paymentMethod !== undefined) payload.payment_method = paymentMethod- const response = await put(`${API_URL}/organizations/${slug}/billing/subscription`, payload)- if (response.error) throw response.error-- return response as SupaResponse<T>+ const response = (await put(+ `${API_URL}/organizations/${slug}/billing/subscription`,+ payload+ )) as SupaResponseV2<T>+ if (typeof response === 'object' && response !== null && 'error' in response) throw response.error+ return response}type OrgSubscriptionUpdateData = Awaited<ReturnType<typeof updateOrgSubscription>>diff --git a/studio/lib/integration-utils.ts b/studio/lib/integration-utils.tsindex 63f9a93969f..da206ee5f29 100644--- a/studio/lib/integration-utils.ts+++ b/studio/lib/integration-utils.ts@@ -1,8 +1,6 @@-import { ResponseFailure } from 'types'+import { SupaResponseV2 } from 'types'-type SupaResponse<T> = T | ResponseFailure--async function fetchGitHub<T = any>(url: string, responseJson = true): Promise<SupaResponse<T>> {+async function fetchGitHub<T = any>(url: string, responseJson = true): Promise<SupaResponseV2<T>> {const response = await fetch(url)if (!response.ok) {return {diff --git a/studio/types/base.ts b/studio/types/base.tsindex eb61191087d..53bef164213 100644--- a/studio/types/base.ts+++ b/studio/types/base.ts@@ -83,7 +83,10 @@ export interface ResponseFailure {error: ResponseError}-export type SupaResponse<T> = T | ResponseFailure+// [Joshen] This should ideally be | but not changing now as its gonna cause a lot of build errors+export type SupaResponse<T> = T & ResponseFailure+// [Joshen] Use this for now, eventually deprecate SupaResponse<T> above+export type SupaResponseV2<T> = T | ResponseFailureexport interface ResponseError {code: number