The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Port private link endpoints from platform to v2 (#51996)
Joshen Lim6e2c59d850ea
diff --git a/apps/studio/data/aws-accounts/aws-account-create-mutation.ts b/apps/studio/data/aws-accounts/aws-account-create-mutation.tsindex 74123679e0e..cc29ba52ad7 100644--- a/apps/studio/data/aws-accounts/aws-account-create-mutation.ts+++ b/apps/studio/data/aws-accounts/aws-account-create-mutation.ts@@ -18,19 +18,19 @@ export async function createAWSAccount({accountName,databaseIdentifier,}: AWSAccountCreateVariables) {- const { data, error } = await post(- '/platform/projects/{ref}/privatelink/associations/aws-account',- {- params: {- path: { ref: projectRef },+ const { data, error } = await post('/v2/projects/{ref}/private-link/associations', {+ params: { path: { ref: projectRef } },+ body: {+ data: {+ type: 'private_link_association',+ attributes: {+ aws_account_id: awsAccountId,+ account_name: accountName,+ database_identifier: databaseIdentifier,+ },},- body: {- aws_account_id: awsAccountId,- account_name: accountName,- database_identifier: databaseIdentifier,- },- }- )+ },+ })if (error) handleError(error)return datadiff --git a/apps/studio/data/aws-accounts/aws-account-delete-mutation.ts b/apps/studio/data/aws-accounts/aws-account-delete-mutation.tsindex cafbe33ff7a..4097a0e739d 100644--- a/apps/studio/data/aws-accounts/aws-account-delete-mutation.ts+++ b/apps/studio/data/aws-accounts/aws-account-delete-mutation.ts@@ -16,28 +16,22 @@ export async function deleteAWSAccount({awsAccountId,databaseIdentifier,}: AWSAccountDeleteVariables) {- const deleteRequest = del as unknown as (- path: string,- init: {- params: {- path: Record<string, string>- }- }- ) => Promise<{ data: unknown; error: unknown }>-- const path = databaseIdentifier- ? '/platform/projects/{ref}/privatelink/associations/aws-account/{aws_account_id}/database/{database_identifier}'- : '/platform/projects/{ref}/privatelink/associations/aws-account/{aws_account_id}'-- const { data, error } = await deleteRequest(path, {- params: {- path: {- ref: projectRef,- aws_account_id: awsAccountId,- ...(databaseIdentifier ? { database_identifier: databaseIdentifier } : {}),- },- },- })+ const { data, error } = databaseIdentifier+ ? await del(+ '/v2/projects/{ref}/private-link/associations/aws-account/{aws_account_id}/database/{database_identifier}',+ {+ params: {+ path: {+ ref: projectRef,+ aws_account_id: awsAccountId,+ database_identifier: databaseIdentifier,+ },+ },+ }+ )+ : await del('/v2/projects/{ref}/private-link/associations/aws-account/{aws_account_id}', {+ params: { path: { ref: projectRef, aws_account_id: awsAccountId } },+ })if (error) handleError(error)return datadiff --git a/apps/studio/data/aws-accounts/aws-accounts-query.ts b/apps/studio/data/aws-accounts/aws-accounts-query.tsindex 29293d29793..df4e4022dc0 100644--- a/apps/studio/data/aws-accounts/aws-accounts-query.ts+++ b/apps/studio/data/aws-accounts/aws-accounts-query.ts@@ -1,6 +1,5 @@import type { UseQueryOptions } from '@tanstack/react-query'import { useQuery } from '@tanstack/react-query'-import { components } from 'api-types'import { awsAccountKeys } from './keys'import { get, handleError } from '@/data/fetchers'@@ -11,20 +10,10 @@ type AWSAccountsVariables = {projectRef?: string}-// [Joshen] API types should be updated with these parameters, so remove once verified-export type AWSAccount =- components['schemas']['GetPrivateLinkResponse_Output']['private_link_associations'][number] & {- database_type?: 'PRIMARY' | 'READ_REPLICA'- database_identifier?: string- resource_access_manager_resource_config_id?: string- resource_access_manager_resource_config_arn?: string- resource_access_manager_share_arn?: string- }-async function getAWSAccounts({ projectRef }: AWSAccountsVariables, signal?: AbortSignal) {if (!projectRef) throw new Error('Project ref is required')- const { data, error } = await get('/platform/projects/{ref}/privatelink/associations', {+ const { data, error } = await get('/v2/projects/{ref}/private-link/associations', {params: {path: { ref: projectRef },},@@ -32,9 +21,11 @@ async function getAWSAccounts({ projectRef }: AWSAccountsVariables, signal?: Abo})if (error) handleError(error)- return data.private_link_associations as AWSAccount[]+ return (data?.data ?? []).map(({ attributes }) => attributes)}+export type AWSAccount = Awaited<ReturnType<typeof getAWSAccounts>>[number]+type AWSAccountsData = Awaited<ReturnType<typeof getAWSAccounts>>type AWSAccountsError = ResponseErrordiff --git a/apps/studio/data/mutation-callbacks.test.tsx b/apps/studio/data/mutation-callbacks.test.tsxindex a02757ab36d..044ec21f172 100644--- a/apps/studio/data/mutation-callbacks.test.tsx+++ b/apps/studio/data/mutation-callbacks.test.tsx@@ -1,5 +1,6 @@import { QueryClient } from '@tanstack/react-query'import { act } from '@testing-library/react'+import type { components } from 'api-types'import { HttpResponse } from 'msw'import { describe, expect, it, vi } from 'vitest'@@ -69,11 +70,24 @@ describe('mutation callback contracts', () => {queryClient.setQueryData(key, [])addAPIMock({method: 'post',- path: '/platform/projects/:ref/privatelink/associations/aws-account',+ path: '/v2/projects/:ref/private-link/associations',response: () =>failure? HttpResponse.json<APIErrorBody>({ message: 'Mutation failed' }, { status: 500 })- : HttpResponse.json<null>(null),+ : HttpResponse.json<components['schemas']['V2PrivateLinkAssociationResponse_Output']>({+ data: {+ type: 'private_link_association',+ id: '1',+ attributes: {+ aws_account_id: 'test-account',+ custom_dns_name: 'db.example.com',+ database_identifier: 'default',+ database_type: 'PRIMARY',+ shared_at: null,+ status: 'CREATING',+ },+ },+ }),})const onSuccess = vi.fn()const onError = vi.fn()