Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Revert "Port private link endpoints from platform to v2" (#52139)

Joshen Limdd09501bac34
diff --git a/apps/studio/data/aws-accounts/aws-account-create-mutation.ts b/apps/studio/data/aws-accounts/aws-account-create-mutation.ts
index cc29ba52ad7..74123679e0e 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('/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,
- },
+ const { data, error } = await post(
+ '/platform/projects/{ref}/privatelink/associations/aws-account',
+ {
+ params: {
+ path: { ref: projectRef },
},
- },
- })
+ body: {
+ aws_account_id: awsAccountId,
+ account_name: accountName,
+ database_identifier: databaseIdentifier,
+ },
+ }
+ )
if (error) handleError(error)
return data
diff --git a/apps/studio/data/aws-accounts/aws-account-delete-mutation.ts b/apps/studio/data/aws-accounts/aws-account-delete-mutation.ts
index 4097a0e739d..cafbe33ff7a 100644
--- a/apps/studio/data/aws-accounts/aws-account-delete-mutation.ts
+++ b/apps/studio/data/aws-accounts/aws-account-delete-mutation.ts
@@ -16,22 +16,28 @@ export async function deleteAWSAccount({
awsAccountId,
databaseIdentifier,
}: AWSAccountDeleteVariables) {
- 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 } },
- })
+ 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 } : {}),
+ },
+ },
+ })
if (error) handleError(error)
return data
diff --git a/apps/studio/data/aws-accounts/aws-accounts-query.ts b/apps/studio/data/aws-accounts/aws-accounts-query.ts
index df4e4022dc0..29293d29793 100644
--- a/apps/studio/data/aws-accounts/aws-accounts-query.ts
+++ b/apps/studio/data/aws-accounts/aws-accounts-query.ts
@@ -1,5 +1,6 @@
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'
@@ -10,10 +11,20 @@ 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('/v2/projects/{ref}/private-link/associations', {
+ const { data, error } = await get('/platform/projects/{ref}/privatelink/associations', {
params: {
path: { ref: projectRef },
},
@@ -21,11 +32,9 @@ async function getAWSAccounts({ projectRef }: AWSAccountsVariables, signal?: Abo
})
if (error) handleError(error)
- return (data?.data ?? []).map(({ attributes }) => attributes)
+ return data.private_link_associations as AWSAccount[]
}
-export type AWSAccount = Awaited<ReturnType<typeof getAWSAccounts>>[number]
-
type AWSAccountsData = Awaited<ReturnType<typeof getAWSAccounts>>
type AWSAccountsError = ResponseError
diff --git a/apps/studio/data/mutation-callbacks.test.tsx b/apps/studio/data/mutation-callbacks.test.tsx
index 044ec21f172..a02757ab36d 100644
--- a/apps/studio/data/mutation-callbacks.test.tsx
+++ b/apps/studio/data/mutation-callbacks.test.tsx
@@ -1,6 +1,5 @@
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'
@@ -70,24 +69,11 @@ describe('mutation callback contracts', () => {
queryClient.setQueryData(key, [])
addAPIMock({
method: 'post',
- path: '/v2/projects/:ref/private-link/associations',
+ path: '/platform/projects/:ref/privatelink/associations/aws-account',
response: () =>
failure
? HttpResponse.json<APIErrorBody>({ message: 'Mutation failed' }, { status: 500 })
- : 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',
- },
- },
- }),
+ : HttpResponse.json<null>(null),
})
const onSuccess = vi.fn()
const onError = vi.fn()