The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix integration types
Alaister Young93da2deb630c
diff --git a/studio/components/interfaces/Integrations/IntegrationPanels.tsx b/studio/components/interfaces/Integrations/IntegrationPanels.tsxindex 6863006001c..268e6c79dd3 100644--- a/studio/components/interfaces/Integrations/IntegrationPanels.tsx+++ b/studio/components/interfaces/Integrations/IntegrationPanels.tsx@@ -7,6 +7,7 @@ import { Integration, IntegrationProjectConnection } from 'data/integrations/intimport { useProjectsQuery } from 'data/projects/projects-query'import { BASE_PATH } from 'lib/constants'import { Badge, Button, IconArrowRight, IconExternalLink, IconGitHub, IconSquare, cn } from 'ui'+import { getIntegrationConfigurationUrl } from 'lib/integration-utils'const ICON_STROKE_WIDTH = 2const ICON_SIZE = 14@@ -14,7 +15,6 @@ const ICON_SIZE = 14export interface IntegrationInstallationProps extends React.RefAttributes<HTMLLIElement> {title: stringintegration: Integration- getManageUrl: (integration: Integration) => string}type HandleIconType = Integration['integration']['name'] | 'Supabase'@@ -24,9 +24,9 @@ const HandleIcon = ({ type, className }: { type: HandleIconType; className?: strcase 'GitHub':return <IconGitHub strokeWidth={ICON_STROKE_WIDTH} size={ICON_SIZE} />break- case 'Netlify':- return <IconSquare strokeWidth={ICON_STROKE_WIDTH} size={ICON_SIZE} />- break+ // case 'Netlify':+ // return <IconSquare strokeWidth={ICON_STROKE_WIDTH} size={ICON_SIZE} />+ // breakcase 'Vercel':return (<svg@@ -66,7 +66,7 @@ const Avatar = ({ src }: { src: string | undefined }) => {}const IntegrationInstallation = React.forwardRef<HTMLLIElement, IntegrationInstallationProps>(- ({ title, integration, getManageUrl, ...props }, ref) => {+ ({ title, integration, ...props }, ref) => {const IntegrationIconBlock = () => {return (<div className="bg-black text-white w-8 h-8 rounded flex items-center justify-center">@@ -92,8 +92,10 @@ const IntegrationInstallation = React.forwardRef<HTMLLIElement, IntegrationInsta<div className="flex flex-col gap-0"><div className="flex items-center gap-2"><span className="text-scale-1200 font-medium">- {/* {title} integration connection •{' '} */}- {integration.metadata?.account.name || integration.metadata?.gitHubConnectionOwner}+ {integration.metadata?.account.name ||+ (integration.metadata !== undefined &&+ 'gitHubConnectionOwner' in integration.metadata &&+ integration.metadata?.gitHubConnectionOwner)}</span><Badge color="scale" className="capitalize">@@ -112,7 +114,11 @@ const IntegrationInstallation = React.forwardRef<HTMLLIElement, IntegrationInsta</div><Button type="default" asChild iconRight={<IconExternalLink />}>- <a href={getManageUrl(integration)} target="_blank" rel="noopener noreferrer">+ <a+ href={getIntegrationConfigurationUrl(integration)}+ target="_blank"+ rel="noopener noreferrer"+ >Manage</a></Button>diff --git a/studio/components/interfaces/Organization/IntegrationSettings/Integration.tsx b/studio/components/interfaces/Organization/IntegrationSettings/Integration.tsxindex 624d050743b..c86012940a2 100644--- a/studio/components/interfaces/Organization/IntegrationSettings/Integration.tsx+++ b/studio/components/interfaces/Organization/IntegrationSettings/Integration.tsx@@ -29,7 +29,6 @@ export interface IntegrationProps {note?: stringdetail?: stringintegrations?: TIntegration[]- getManageUrl: (integration: TIntegration) => stringonAddConnection: (integrationId: string) => voidonDeleteConnection: (connection: IntegrationProjectConnection) => void | Promise<void>}@@ -40,7 +39,6 @@ const Integration = ({note,detail,integrations = EMPTY_ARR,- getManageUrl,onAddConnection,onDeleteConnection,}: IntegrationProps) => {@@ -76,11 +74,7 @@ Repository connections for ${title?.toLowerCase()}integrations.map((integration, i) => {return (<div key={integration.id}>- <IntegrationInstallation- title={title}- integration={integration}- getManageUrl={getManageUrl}- />+ <IntegrationInstallation title={title} integration={integration} />{integration.connections.length > 0 ? (<>diff --git a/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx b/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsxindex 1f122d5462e..a0be0c4b15c 100644--- a/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx+++ b/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx@@ -7,7 +7,7 @@ import { useOrgIntegrationsQuery } from 'data/integrations/integrations-query-orimport { useIntegrationsVercelInstalledConnectionDeleteMutation } from 'data/integrations/integrations-vercel-installed-connection-delete-mutation'import { useVercelProjectsQuery } from 'data/integrations/integrations-vercel-projects-query'import { IntegrationProjectConnection } from 'data/integrations/integrations.types'-import { getGitHubConfigurationUrl, getVercelConfigurationUrl } from 'lib/integration-utils'+import { getIntegrationConfigurationUrl } from 'lib/integration-utils'import Integration from './Integration'import SidePanelGitHubRepoLinker from './SidePanelGitHubRepoLinker'import SidePanelVercelProjectLinker from './SidePanelVercelProjectLinker'@@ -110,14 +110,13 @@ You can also link multiple Vercel Projects to the same Supabase project.vercelProjectCount > 0 && vercelIntegration !== undefined? `Your Vercel connection has access to ${vercelProjectCount} Vercel Projects.-You can change the scope of the access for Supabase by configuring [here](${getVercelConfigurationUrl(+You can change the scope of the access for Supabase by configuring [here](${getIntegrationConfigurationUrl(vercelIntegration)}).`: undefined}integrations={vercelIntegrations}- getManageUrl={getVercelConfigurationUrl}onAddConnection={onAddVercelConnection}onDeleteConnection={onDeleteVercelConnection}/>@@ -138,7 +137,6 @@ The GitHub app will watch for changes in your repository such as file changes, bThese connections will be part of a GitHub workflow that is currently in development.`}integrations={githubIntegrations}- getManageUrl={getGitHubConfigurationUrl}onAddConnection={onAddGitHubConnection}onDeleteConnection={onDeleteGitHubConnection}/>diff --git a/studio/data/integrations/integrations.types.ts b/studio/data/integrations/integrations.types.tsindex 13dbf066ea1..eb2bf344d11 100644--- a/studio/data/integrations/integrations.types.ts+++ b/studio/data/integrations/integrations.types.ts@@ -156,7 +156,7 @@ export type userDetails = {type addedBy = userDetailstype updatedBy = userDetails-export type IntegrationName = 'Vercel' | 'Netlify' | 'GitHub'+export type IntegrationName = 'Vercel' | 'GitHub' // | 'Netlify'export type VercelAccountType = 'Team' | 'Personal'export type VercelSource = 'marketplace' | 'deploy button'@@ -177,11 +177,27 @@ export type VercelTeamAccount = BaseVercelAccount & {team_slug: string}-export type Integration = {+export type VercelMetadata = {+ vercelTeam?: string+ gitHubConnectionOwner?: string+ account: VercelAccount | VercelTeamAccount+ configuration_id: string+}++export type GitHubAccount = {+ name: string+ type: 'User' | 'Organization'+ avatar: string+ installed_by_user_id: number+}++export type GitHubMetadata = {+ installation_id: number+ account: GitHubAccount+}++export type IntegrationBase = {id: string- integration: {- name: IntegrationName- }added_by: addedByinserted_at: stringupdated_at: string@@ -189,10 +205,20 @@ export type Integration = {organization: {slug: string}- metadata?: {- vercelTeam?: string- gitHubConnectionOwner?: string- account: VercelAccount | VercelTeamAccount- configuration_id: string- }}++export type Integration =+ | (IntegrationBase & {+ id: string+ integration: {+ name: 'Vercel'+ }+ metadata?: VercelMetadata+ })+ | (IntegrationBase & {+ id: string+ integration: {+ name: 'GitHub'+ }+ metadata?: GitHubMetadata+ })diff --git a/studio/lib/integration-utils.ts b/studio/lib/integration-utils.tsindex 278cc5b93da..79095f65829 100644--- a/studio/lib/integration-utils.ts+++ b/studio/lib/integration-utils.ts@@ -1,5 +1,5 @@-import { SupaResponseV2 } from 'types'import { Integration } from 'data/integrations/integrations.types'+import { SupaResponseV2 } from 'types'async function fetchGitHub<T = any>(url: string, responseJson = true): Promise<SupaResponseV2<T>> {const response = await fetch(url)@@ -115,7 +115,22 @@ export async function getInitialMigrationSQLFromGitHubRepo(return `${migrations};${migrationsTableSql};${seed}`}-export function getVercelConfigurationUrl(integration: Integration) {+type VercelIntegration = Extract<Integration, { integration: { name: 'Vercel' } }>+type GitHubIntegration = Extract<Integration, { integration: { name: 'GitHub' } }>++export function getIntegrationConfigurationUrl(integration: Integration) {+ if (integration.integration.name === 'Vercel') {+ return getVercelConfigurationUrl(integration as VercelIntegration)+ }++ if (integration.integration.name === 'GitHub') {+ return getGitHubConfigurationUrl(integration as GitHubIntegration)+ }++ return ''+}++export function getVercelConfigurationUrl(integration: VercelIntegration) {return `https://vercel.com/dashboard/${integration.metadata?.account.type === 'Team'? `${integration.metadata?.account.team_slug}/`@@ -123,10 +138,10 @@ export function getVercelConfigurationUrl(integration: Integration) {}integrations/${integration.metadata?.configuration_id}`}-export function getGitHubConfigurationUrl(integration: Integration) {+export function getGitHubConfigurationUrl(integration: GitHubIntegration) {return `https://github.com/${integration.metadata?.account.type === 'Organization'? `organizations/${integration.metadata?.account.name}/`: ''- }settings/installations/${integration.metadata.installation_id}`+ }settings/installations/${integration.metadata?.installation_id}`}diff --git a/studio/pages/integrations/github/install.tsx b/studio/pages/integrations/github/install.tsxindex 08987421df3..46eb8c30f59 100644--- a/studio/pages/integrations/github/install.tsx+++ b/studio/pages/integrations/github/install.tsx@@ -98,7 +98,11 @@ const GitHubIntegration: NextPageWithLayout = () => {const orgSlug = selectedOrg?.slugconst installedIntegration = integrationData?.find(- (x) => x.organization.slug === orgSlug && x.metadata?.installation_id === installationId+ (x) =>+ x.organization.slug === orgSlug &&+ x.metadata !== undefined &&+ 'installation_id' in x.metadata &&+ String(x.metadata?.installation_id) === String(installationId))const isIntegrationInstalled = Boolean(installedIntegration)diff --git a/studio/pages/integrations/vercel/[slug]/marketplace/choose-project.tsx b/studio/pages/integrations/vercel/[slug]/marketplace/choose-project.tsxindex 8e2032902a6..0cb0cacc947 100644--- a/studio/pages/integrations/vercel/[slug]/marketplace/choose-project.tsx+++ b/studio/pages/integrations/vercel/[slug]/marketplace/choose-project.tsx@@ -43,7 +43,12 @@ const VercelIntegration: NextPageWithLayout = () => {const organization = data?.find((organization: Organization) => organization.slug === slug)- const integration = integrationData?.find((x) => x.metadata?.configuration_id === configurationId)+ const integration = integrationData?.find(+ (x) =>+ x.metadata !== undefined &&+ 'configuration_id' in x.metadata &&+ x.metadata?.configuration_id === configurationId+ )const { data: supabaseProjectsData } = useProjectsQuery({enabled: integration?.id !== undefined,