Skip to content

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

feat: upgrade flow and other improvements (#43289)

Raminder Singh65237597e4d8
diff --git a/apps/studio/components/interfaces/Integrations/Landing/useInstalledIntegrations.tsx b/apps/studio/components/interfaces/Integrations/Landing/useInstalledIntegrations.tsx
index 25a0e115196..f5a8572ded4 100644
--- a/apps/studio/components/interfaces/Integrations/Landing/useInstalledIntegrations.tsx
+++ b/apps/studio/components/interfaces/Integrations/Landing/useInstalledIntegrations.tsx
@@ -5,13 +5,13 @@ import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
import { EMPTY_ARR } from 'lib/void'
import { useMemo } from 'react'
+import { parseSchemaComment } from 'stripe-experiment-sync/supabase'
import { wrapperMetaComparator } from '../Wrappers/Wrappers.utils'
import { INTEGRATIONS } from './Integrations.constants'
import {
isInstalled as checkIsInstalled,
findStripeSchema,
- parseStripeSchema,
} from '@/components/interfaces/Integrations/templates/StripeSyncEngine/stripe-sync-status'
export const useInstalledIntegrations = () => {
@@ -77,7 +77,7 @@ export const useInstalledIntegrations = () => {
}
if (integration.id === 'stripe_sync_engine') {
const stripeSchema = findStripeSchema(schemas)
- const parsedSchema = parseStripeSchema(stripeSchema)
+ const parsedSchema = parseSchemaComment(stripeSchema?.comment)
return checkIsInstalled(parsedSchema.status)
}
if (integration.type === 'wrapper') {
diff --git a/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/InstallationError.tsx b/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/InstallationError.tsx
index 2c8e63d7b5c..90bf85d1f8f 100644
--- a/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/InstallationError.tsx
+++ b/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/InstallationError.tsx
@@ -1,37 +1,50 @@
import { useParams } from 'common'
import { Button } from 'ui'
-import { Admonition } from 'ui-patterns'
-import { ContactSupportButton } from '@/components/ui/AlertError'
+import { useStripeSyncStatus } from './useStripeSyncStatus'
+import AlertError from '@/components/ui/AlertError'
+import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
export const InstallationError = ({
error,
handleUninstall,
handleOpenInstallSheet,
+ isUpgrade,
+ installing,
+ uninstalling,
}: {
error: 'install' | 'uninstall'
handleUninstall: () => void
handleOpenInstallSheet: () => void
+ isUpgrade?: boolean
+ installing?: boolean
+ uninstalling?: boolean
}) => {
- const { ref } = useParams()
+ const { data: project } = useSelectedProjectQuery()
+
+ const {
+ schemaComment: { errorMessage },
+ } = useStripeSyncStatus({
+ projectRef: project?.ref,
+ connectionString: project?.connectionString,
+ })
if (error === 'uninstall') {
return (
- <Admonition
- type="warning"
- layout="responsive"
- title="Failed to uninstall Stripe Sync Engine"
+ <AlertError
+ layout="horizontal"
+ subject="Failed to uninstall Stripe Sync Engine"
+ error={errorMessage ? { message: errorMessage } : undefined}
description="There was an error during the uninstallation of the Stripe Sync Engine, please try again. If the problem persists, contact support."
- actions={
- <div className="flex items-center gap-x-2">
- <Button type="default" onClick={handleUninstall}>
- Retry uninstall
- </Button>
- <ContactSupportButton
- projectRef={ref}
- subject="Failed to uninstall Stripe Sync Engine"
- />
- </div>
+ additionalActions={
+ <Button
+ type="default"
+ onClick={handleUninstall}
+ disabled={uninstalling}
+ loading={uninstalling}
+ >
+ Retry uninstallation
+ </Button>
}
/>
)
@@ -39,18 +52,27 @@ export const InstallationError = ({
if (error === 'install') {
return (
- <Admonition
- type="warning"
- layout="responsive"
- title="Failed to install Stripe Sync Engine"
- description="There was an error during the installation of the Stripe Sync Engine, please try reinstalling the integration. If the problem persists, contact support."
- actions={
- <div className="flex items-center gap-x-2">
- <Button type="default" onClick={handleOpenInstallSheet}>
- Retry install
- </Button>
- <ContactSupportButton projectRef={ref} subject="Failed to install Stripe Sync Engine" />
- </div>
+ <AlertError
+ subject={
+ isUpgrade
+ ? 'Failed to upgrade Stripe Sync Engine'
+ : 'Failed to install Stripe Sync Engine'
+ }
+ error={errorMessage ? { message: errorMessage } : undefined}
+ description={
+ isUpgrade
+ ? 'There was an error during the upgrade of the Stripe Sync Engine, please try again. If the problem persists, contact support.'
+ : 'There was an error during the installation of the Stripe Sync Engine, please try reinstalling the integration. If the problem persists, contact support.'
+ }
+ additionalActions={
+ <Button
+ type="default"
+ onClick={handleOpenInstallSheet}
+ disabled={installing}
+ loading={installing}
+ >
+ {isUpgrade ? 'Retry upgrade' : 'Retry installation'}
+ </Button>
}
/>
)
diff --git a/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/InstallationOverview.tsx b/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/InstallationOverview.tsx
index d1a3343376f..fbcd7c929b6 100644
--- a/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/InstallationOverview.tsx
+++ b/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/InstallationOverview.tsx
@@ -45,8 +45,6 @@ import {
} from './stripe-sync-status'
import { StripeSyncChangesCard } from './StripeSyncChangesCard'
import { useStripeSyncStatus } from '@/components/interfaces/Integrations/templates/StripeSyncEngine/useStripeSyncStatus'
-import { InlineLink } from '@/components/ui/InlineLink'
-import { useSSLEnforcementQuery } from '@/data/ssl-enforcement/ssl-enforcement-query'
const installFormSchema = z.object({
stripeSecretKey: z.string().min(1, 'Stripe API key is required'),
@@ -71,7 +69,10 @@ export const StripeSyncInstallationPage = () => {
})
const {
- parsedSchema: { status: installationStatus },
+ schemaComment,
+ schemaComment: { status: installationStatus },
+ latestAvailableVersion,
+ timedOut,
} = useStripeSyncStatus({
projectRef: project?.ref,
connectionString: project?.connectionString,
@@ -91,6 +92,22 @@ export const StripeSyncInstallationPage = () => {
const installDone = isInstallDone(installationStatus)
const uninstallDone = isUninstallDone(installationStatus)
+ // Detect if this is an upgrade (both old and new versions present)
+ let oldVersion
+ let newVersion
+ if (installed) {
+ // when installed we compare the installed version against the latest available
+ oldVersion = schemaComment?.newVersion
+ newVersion = latestAvailableVersion
+ } else {
+ // otherwise compare the old and new versions from the schema
+ oldVersion = schemaComment?.oldVersion
+ newVersion = schemaComment?.newVersion
+ }
+
+ const upgradeAvailable = !!(oldVersion && newVersion && oldVersion !== newVersion)
+ const upgradeDone = latestAvailableVersion == schemaComment?.newVersion
+
const {
mutate: installStripeSync,
isPending: isInstallRequested,
@@ -98,7 +115,9 @@ export const StripeSyncInstallationPage = () => {
reset: resetInstallError,
} = useStripeSyncInstallMutation({
onSuccess: () => {
- toast.success('Stripe Sync installation started')
+ toast.success(
+ upgradeAvailable ? 'Stripe Sync upgrade started' : 'Stripe Sync installation started'
+ )
setShouldShowInstallSheet(false)
form.reset()
setIsInstallInitiated(true)
@@ -115,11 +134,12 @@ export const StripeSyncInstallationPage = () => {
})
// Combine schema status with mutation/initiated states for UI
- const installing = installInProgress || isInstallRequested || isInstallInitiated
- const uninstalling = uninstallInProgress || isUninstallRequested || isUninstallInitiated
+ const installing = (installInProgress || isInstallRequested || isInstallInitiated) && !timedOut
+ const uninstalling =
+ (uninstallInProgress || isUninstallRequested || isUninstallInitiated) && !timedOut
const canInstall = checkCanInstall(installationStatus) && !installed && !installing
- const hasError = (uninstallError || installError) && !uninstalling && !installing
+ const hasError = (uninstallError || installError) && ((!uninstalling && !installing) || timedOut)
// Poll for schema changes during transitions
useSchemasQuery(
@@ -127,19 +147,12 @@ export const StripeSyncInstallationPage = () => {
{ refetchInterval: installing || uninstalling ? 5000 : false }
)
- const { data: sslEnforcementConfiguration, isSuccess: isSuccessSslEnforcement } =
- useSSLEnforcementQuery({
- projectRef: project?.ref,
- })
- const isSSLEnforced =
- sslEnforcementConfiguration?.appliedSuccessfully &&
- sslEnforcementConfiguration?.currentConfig.database
-
const handleUninstall = useCallback(() => {
if (!project?.ref) return
uninstallStripeSync({
projectRef: project.ref,
+ startTime: Date.now(),
})
}, [project?.ref, uninstallStripeSync])
@@ -173,12 +186,13 @@ export const StripeSyncInstallationPage = () => {
}
}, [installError, track])
- // Clear install initiated flag once schema reflects completion or error
+ // Clear install initiated flag once schema reflects successful completion
+ // For errors, the flag is cleared when user manually retries (handleOpenInstallSheet)
useEffect(() => {
- if (isInstallInitiated && installDone) {
+ if (isInstallInitiated && installDone && upgradeDone && !installError) {
setIsInstallInitiated(false)
}
- }, [isInstallInitiated, installDone])
+ }, [isInstallInitiated, installDone, upgradeDone, installError])
// Clear uninstall initiated flag once schema is removed or error
useEffect(() => {
@@ -195,20 +209,30 @@ export const StripeSyncInstallationPage = () => {
error={uninstallError ? 'uninstall' : 'install'}
handleUninstall={handleUninstall}
handleOpenInstallSheet={handleOpenInstallSheet}
+ isUpgrade={upgradeAvailable}
+ installing={installing}
+ uninstalling={uninstalling}
/>
) : null
}
status={
<StatusDisplay
status={installationStatus}
- isInstallRequested={isInstallRequested || isInstallInitiated}
- isUninstallRequested={isUninstallRequested || isUninstallInitiated}
+ isInstallRequested={isInstallRequested}
+ isInstallInitiated={isInstallInitiated}
+ isUninstallRequested={isUninstallRequested}
+ isUninstallInitiated={isUninstallInitiated}
+ isUpgrade={upgradeAvailable}
+ timedOut={timedOut}
/>
}
actions={
!installed && !uninstalling && !uninstallError ? (
<>
- <StripeSyncChangesCard installationStatus={installationStatus} />
+ <StripeSyncChangesCard
+ installationStatus={installationStatus}
+ isUpgrade={upgradeAvailable}
+ />
<div className="flex gap-x-2 justify-end mt-4">
<ButtonTooltip
type="primary"
@@ -225,7 +249,13 @@ export const StripeSyncInstallationPage = () => {
},
}}
>
- {installError ? 'Retry installation' : 'Install integration'}
+ {installError
+ ? upgradeAvailable
+ ? 'Retry upgrade'
+ : 'Retry installation'
+ : upgradeAvailable
+ ? 'Upgrade integration'
+ : 'Install integration'}
</ButtonTooltip>
{installError && (
<Button type="default" loading={isUninstallRequested} onClick={handleUninstall}>
@@ -236,12 +266,32 @@ export const StripeSyncInstallationPage = () => {
</>
) : installed || uninstalling || uninstallError ? (
<>
- <StripeSyncChangesCard installationStatus={installationStatus} />
- <div className="flex justify-end mt-4">
+ <StripeSyncChangesCard
+ installationStatus={installationStatus}
+ isUpgrade={upgradeAvailable}
+ />
+ <div className="flex gap-x-2 justify-end mt-4">
+ {upgradeAvailable && !uninstallError && !uninstalling && (
+ <ButtonTooltip
+ type="primary"
+ onClick={() => setShouldShowInstallSheet(true)}
+ disabled={installing || !canManageSecrets}
+ loading={installing}
+ tooltip={{
+ content: {
+ text: !canManageSecrets
+ ? 'You need additional permissions to upgrade the Stripe Sync Engine.'
+ : undefined,
+ },
+ }}
+ >
+ Upgrade integration
+ </ButtonTooltip>
+ )}
<ButtonTooltip
type="default"
onClick={() => setShowUninstallModal(true)}
- disabled={!canManageSecrets}
+ disabled={installing || uninstalling || !canManageSecrets}
loading={uninstalling}
tooltip={{
content: {
@@ -251,7 +301,7 @@ export const StripeSyncInstallationPage = () => {
},
}}
>
- Uninstall integration
+ {uninstallError ? 'Retry uninstallation' : 'Uninstall integration'}
</ButtonTooltip>
</div>
</>
@@ -265,33 +315,24 @@ export const StripeSyncInstallationPage = () => {
id={formId}
onSubmit={form.handleSubmit(({ stripeSecretKey }) => {
if (!project?.ref) return
- installStripeSync({ projectRef: project.ref, stripeSecretKey })
+ installStripeSync({
+ projectRef: project.ref,
+ stripeSecretKey,
+ startTime: Date.now(),
+ })
})}
className="overflow-auto flex-grow px-0 flex flex-col"
>
<SheetHeader>
- <SheetTitle>Install Stripe Sync Engine</SheetTitle>
+ <SheetTitle>
+ {upgradeAvailable ? 'Upgrade' : 'Install'} Stripe Sync Engine
+ </SheetTitle>
</SheetHeader>
<SheetSection className="flex-1 flex flex-col gap-y-6">
- <StripeSyncChangesCard installationStatus={installationStatus} />
-
- {isSuccessSslEnforcement && isSSLEnforced && (
- <Admonition type="warning">
- <h5 className="mb-0.5">
- This integration currently requires{' '}
- <InlineLink
- href={`/project/${project?.ref ?? '_'}/database/settings#ssl-configuration`}
- >
- SSL Enforcement
- </InlineLink>{' '}
- to be disabled during initial setup.
- </h5>
- <p className="text-foreground-light">
- Support for SSL Enforcement will be added in a future update. Once installed,
- all webhook and sync operations use HTTPS/SSL.
- </p>
- </Admonition>
- )}
+ <StripeSyncChangesCard
+ installationStatus={installationStatus}
+ isUpgrade={upgradeAvailable}
+ />
<h3 className="heading-default">Configuration</h3>
@@ -368,7 +409,13 @@ export const StripeSyncInstallationPage = () => {
loading={isInstallRequested}
disabled={!form.formState.isValid || isInstallRequested}
>
- {isInstallRequested ? 'Installing' : 'Install'}
+ {isInstallRequested
+ ? upgradeAvailable
+ ? 'Upgrading'
+ : 'Installing'
+ : upgradeAvailable
+ ? 'Upgrade integration'
+ : 'Install integration'}
</Button>
</SheetFooter>
</form>
diff --git a/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/StatusDisplay.tsx b/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/StatusDisplay.tsx
index da6e6ee44c7..488845d21c8 100644
--- a/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/StatusDisplay.tsx
+++ b/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/StatusDisplay.tsx
@@ -1,4 +1,5 @@
import { AlertCircle, Check, RefreshCwIcon } from 'lucide-react'
+import { SchemaInstallationStatus } from 'stripe-experiment-sync/supabase'
import {
hasInstallError,
@@ -6,17 +7,24 @@ import {
isInstalled,
isInstalling,
isUninstalling,
- StripeInstallationStatus,
} from './stripe-sync-status'
export const StatusDisplay = ({
status,
isInstallRequested,
+ isInstallInitiated,
isUninstallRequested,
+ isUninstallInitiated,
+ isUpgrade,
+ timedOut,
}: {
- status: StripeInstallationStatus
+ status: SchemaInstallationStatus
isInstallRequested: boolean
+ isInstallInitiated: boolean
isUninstallRequested: boolean
+ isUninstallInitiated: boolean
+ isUpgrade?: boolean
+ timedOut: boolean
}) => {
const installed = isInstalled(status)
const installError = hasInstallError(status)
@@ -24,17 +32,10 @@ export const StatusDisplay = ({
const installInProgress = isInstalling(status)
const uninstallInProgress = isUninstalling(status)
- const installing = installInProgress || isInstallRequested
- const uninstalling = uninstallInProgress || isUninstallRequested
+ const installing = (installInProgress || isInstallRequested || isInstallInitiated) && !timedOut
+ const uninstalling =
+ (uninstallInProgress || isUninstallRequested || isUninstallInitiated) && !timedOut
- if (uninstallError) {
- return (
- <span className="flex items-center gap-2 text-foreground-light text-sm">
- <AlertCircle size={14} className="text-destructive" />
- Uninstallation error
- </span>
- )
- }
if (uninstalling) {
return (
<span className="flex items-center gap-2 text-foreground-light text-sm">
@@ -43,11 +44,11 @@ export const StatusDisplay = ({
</span>
)
}
- if (installError) {
+ if (uninstallError) {
return (
<span className="flex items-center gap-2 text-foreground-light text-sm">
<AlertCircle size={14} className="text-destructive" />
- Installation error
+ Uninstallation error
</span>
)
}
@@ -55,7 +56,15 @@ export const StatusDisplay = ({
return (
<span className="flex items-center gap-2 text-foreground-light text-sm">
<RefreshCwIcon size={14} className="animate-spin text-foreground-lighter" />
- Installing...
+ {isUpgrade ? 'Upgrading...' : 'Installing...'}
+ </span>
+ )
+ }
+ if (installError) {
+ return (
+ <span className="flex items-center gap-2 text-foreground-light text-sm">
+ <AlertCircle size={14} className="text-destructive" />
+ {isUpgrade ? 'Upgrade error' : 'Installation error'}
</span>
)
}
diff --git a/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/StripeSyncChangesCard.tsx b/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/StripeSyncChangesCard.tsx
index 98db11118c3..a0bb8094a39 100644
--- a/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/StripeSyncChangesCard.tsx
+++ b/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/StripeSyncChangesCard.tsx
@@ -1,5 +1,6 @@
import { EdgeFunctions } from 'icons'
-import { Layers, Table } from 'lucide-react'
+import { Layers, Loader2, Table } from 'lucide-react'
+import { SchemaInstallationStatus } from 'stripe-experiment-sync/supabase'
import { Card, CardContent, cn } from 'ui'
import {
@@ -10,12 +11,12 @@ import {
isInstalling,
isUninstallDone,
isUninstalling,
- StripeInstallationStatus,
} from './stripe-sync-status'
type StripeSyncChangesCardProps = {
- installationStatus: StripeInstallationStatus
+ installationStatus: SchemaInstallationStatus
className?: string
+ isUpgrade?: boolean
}
const ListItemClassName = 'flex items-center gap-x-3 py-2 px-3 border-b'
@@ -23,6 +24,7 @@ const ListItemClassName = 'flex items-center gap-x-3 py-2 px-3 border-b'
export const StripeSyncChangesCard = ({
installationStatus,
className,
+ isUpgrade,
}: StripeSyncChangesCardProps) => {
const installed = isInstalled(installationStatus)
const installError = hasInstallError(installationStatus)
@@ -32,53 +34,70 @@ export const StripeSyncChangesCard = ({
const installDone = isInstallDone(installationStatus)
const uninstallDone = isUninstallDone(installationStatus)
- const title =
- uninstallDone || installError
+ // Special case: installed integration with upgrade available (shown in sheet context)
+ const isInProgress = installInProgress || uninstallInProgress
+ const isInstalledWithUpgrade = installed && isUpgrade
+
+ const title = isInstalledWithUpgrade
+ ? 'This integration will upgrade your Supabase project:'
+ : uninstallDone || installError
? 'This integration will modify your Supabase project:'
- : installInProgress || uninstallInProgress
+ : isInProgress
? 'This integration is modifying your Supabase project:'
: installDone || installed || uninstallError
? 'This integration has modified your Supabase project:'
: ''
- const dbLine =
- uninstallDone || installError
- ? 'Creates a new database schema named '
+ const dbLine = isInstalledWithUpgrade
+ ? 'Upgrades the database schema named'
+ : uninstallDone || installError
+ ? 'Creates a new database schema named'
: installInProgress
- ? 'Creating a new database schema named '
+ ? isUpgrade
+ ? 'Upgrading database schema named'
+ : 'Creating a new database schema named'
: installDone || installed || uninstallError
- ? 'Created a new database schema named '
+ ? 'Created a new database schema named'
: uninstallInProgress
- ? 'Dropping database schema named '
+ ? 'Dropping database schema named'
: ''
- const tableAndViewLine =
- uninstallDone || installError
- ? 'Creates tables and views in the '
+ const tableAndViewLine = isInstalledWithUpgrade
+ ? 'Upgrades tables and views in the'
+ : uninstallDone || installError
+ ? 'Creates tables and views in the'
: installInProgress
- ? 'Creating tables and views in the '
+ ? isUpgrade
+ ? 'Upgrading tables and views in the'
+ : 'Creating tables and views in the'
: installDone || installed || uninstallError
- ? 'Created tables and views in the '
+ ? 'Created tables and views in the'
: uninstallInProgress
- ? 'Dropping tables and views in the '
+ ? 'Dropping tables and views in the'
: ''
- const edgeFunctionsLine =
- uninstallDone || installError
+ const edgeFunctionsLine = isInstalledWithUpgrade
+ ? 'Upgrades Edge Functions to handle incoming webhooks from Stripe'
+ : uninstallDone || installError
? 'Deploys Edge Functions to handle incoming webhooks from Stripe'
: installInProgress
- ? 'Deploying Edge Functions to handle incoming webhooks from Stripe'
+ ? isUpgrade
+ ? 'Upgrading Edge Functions to handle incoming webhooks from Stripe'
+ : 'Deploying Edge Functions to handle incoming webhooks from Stripe'
: installDone || installed || uninstallError
? 'Deployed Edge Functions to handle incoming webhooks from Stripe'
: uninstallInProgress
? 'Undeploying Edge Functions to handle incoming webhooks from Stripe'
: ''
- const scheduleLine =
- uninstallDone || installError
+ const scheduleLine = isInstalledWithUpgrade
+ ? 'Upgrades automatic Stripe data syncs using Supabase Queues'
+ : uninstallDone || installError
? 'Schedules automatic Stripe data syncs using Supabase Queues'
: installInProgress
- ? 'Scheduling automatic Stripe data syncs using Supabase Queues'
+ ? isUpgrade
+ ? 'Upgrading automatic Stripe data syncs using Supabase Queues'
+ : 'Scheduling automatic Stripe data syncs using Supabase Queues'
: installDone || installed || uninstallError
? 'Scheduled automatic Stripe data syncs using Supabase Queues'
: uninstallInProgress
@@ -92,28 +111,44 @@ export const StripeSyncChangesCard = ({
<CardContent className="p-0">
<ul className="text-foreground-light text-sm">
<li className={ListItemClassName}>
- <Table size={16} strokeWidth={1.5} className="text-foreground-lighter shrink-0" />
+ {isInProgress ? (
+ <Loader2 size={16} className="animate-spin" />
+ ) : (
+ <Table size={16} strokeWidth={1.5} className="text-foreground-lighter shrink-0" />
+ )}
<span>
{dbLine} <code className="text-code-inline">stripe</code>
</span>
</li>
<li className={ListItemClassName}>
- <Table size={16} strokeWidth={1.5} className="text-foreground-lighter shrink-0" />
+ {isInProgress ? (
+ <Loader2 size={16} className="animate-spin" />
+ ) : (
+ <Table size={16} strokeWidth={1.5} className="text-foreground-lighter shrink-0" />
+ )}
<span>
{tableAndViewLine} <code className="text-code-inline">stripe</code> schema for
synced Stripe data
</span>
</li>
<li className={ListItemClassName}>
- <EdgeFunctions
- size={16}
- strokeWidth={1.5}
- className="text-foreground-lighter shrink-0"
- />
+ {isInProgress ? (
+ <Loader2 size={16} className="animate-spin" />
+ ) : (
+ <EdgeFunctions
+ size={16}
+ strokeWidth={1.5}
+ className="text-foreground-lighter shrink-0"
+ />
+ )}
<span>{edgeFunctionsLine}</span>
</li>
<li className="flex items-center gap-x-3 py-2 px-3">
- <Layers size={16} strokeWidth={1.5} className="text-foreground-lighter shrink-0" />
+ {isInProgress ? (
+ <Loader2 size={16} className="animate-spin" />
+ ) : (
+ <Layers size={16} strokeWidth={1.5} className="text-foreground-lighter shrink-0" />
+ )}
<span>{scheduleLine}</span>
</li>
</ul>
diff --git a/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/StripeSyncSettingsPage.tsx b/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/StripeSyncSettingsPage.tsx
index 311e61e292c..5114ef2c1a2 100644
--- a/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/StripeSyncSettingsPage.tsx
+++ b/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/StripeSyncSettingsPage.tsx
@@ -1,10 +1,9 @@
import { formatRelative } from 'date-fns'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
-import { BadgeCheck, RefreshCwIcon, Table2 } from 'lucide-react'
+import { BadgeCheck, RefreshCwIcon } from 'lucide-react'
import Link from 'next/link'
-import { useRouter } from 'next/router'
-import { Button, Card, CardContent } from 'ui'
-import { Admonition } from 'ui-patterns'
+import { Button, Card, CardContent, CardHeader, CardTitle } from 'ui'
+import { Admonition, ShimmeringLoader, TimestampInfo } from 'ui-patterns'
import { PageContainer } from 'ui-patterns/PageContainer'
import {
PageSection,
@@ -19,13 +18,11 @@ import { isInstalled, isSyncRunning, isUninstalling } from './stripe-sync-status
import { useStripeSyncStatus } from '@/components/interfaces/Integrations/templates/StripeSyncEngine/useStripeSyncStatus'
export const StripeSyncSettingsPage = () => {
- const router = useRouter()
const { data: project } = useSelectedProjectQuery()
const {
- parsedSchema: { status: installationStatus },
+ schemaComment: { status: installationStatus },
syncState,
- isLoading: isLoadingInstallationStatus,
} = useStripeSyncStatus({
projectRef: project?.ref,
connectionString: project?.connectionString,
@@ -33,79 +30,92 @@ export const StripeSyncSettingsPage = () => {
const installed = isInstalled(installationStatus)
const isSyncing = isSyncRunning(syncState)
const uninstalling = isUninstalling(installationStatus)
- const tableEditorUrl = `/project/${project?.ref}/editor?schema=stripe`
+
+ if (!installed || uninstalling) {
+ return (
+ <PageContainer className="mx-0">
+ <PageSection>
+ <Admonition type="default" title="Stripe Sync Engine is not installed" />
+ </PageSection>
+ </PageContainer>
+ )
+ }
return (
<PageContainer className="mx-0">
- {syncState && installed && !uninstalling && (
- <PageSection id="sync-status">
- <PageSectionMeta>
- <PageSectionSummary>
- <PageSectionTitle>Sync Status</PageSectionTitle>
- </PageSectionSummary>
- </PageSectionMeta>
- <PageSectionContent>
- <Admonition type="default" showIcon={false}>
- <div className="flex items-center justify-between gap-2">
- {isSyncing ? (
- <>
- <div className="flex items-center gap-2">
- <RefreshCwIcon size={14} className="animate-spin" />
- <div>Sync in progress...</div>
- </div>
- <div className="text-foreground-light text-sm">
- Started{' '}
- {syncState.started_at
- ? formatRelative(new Date(syncState.started_at), new Date())
- : 'recently'}
- </div>
- </>
- ) : (
- <>
- <div className="flex items-center gap-2">
- <BadgeCheck size={14} className="text-brand" />
- <div>All up to date</div>
- <Button asChild type="text">
- <Link href={tableEditorUrl}>View data</Link>
- </Button>
- </div>
- <div className="text-foreground-light text-sm">
- Last synced{' '}
- {syncState.closed_at
- ? formatRelative(new Date(syncState.closed_at), new Date())
- : 'recently'}
- </div>
- </>
- )}
- </div>
- </Admonition>
- </PageSectionContent>
- </PageSection>
- )}
- <PageSection id="stripe-schema">
+ <PageSection>
<PageSectionMeta>
<PageSectionSummary>
- <PageSectionTitle>Stripe Schema</PageSectionTitle>
+ <PageSectionTitle>Manage Stripe data</PageSectionTitle>
<PageSectionDescription>
Access and manage the synced Stripe data in your database.
</PageSectionDescription>
</PageSectionSummary>
</PageSectionMeta>
<PageSectionContent>
- <Card>
+ <Card className="max-w-4xl">
+ <CardHeader>
+ <CardTitle className="text-foreground-lighter">
+ {!syncState ? (
+ <ShimmeringLoader className="py-2" />
+ ) : (
+ <div className="flex items-center justify-between gap-2">
+ {isSyncing ? (
+ <>
+ <div className="flex items-center gap-x-3 text-foreground-light">
+ <RefreshCwIcon size={14} className="animate-spin" />
+ <p>Sync in progress</p>
+ </div>
+ {syncState.started_at && (
+ <p className="text-foreground-light">
+ Started{' '}
+ <TimestampInfo
+ utcTimestamp={syncState.started_at}
+ label={
+ syncState.started_at
+ ? formatRelative(new Date(syncState.started_at), new Date())
+ : 'recently'
+ }
+ />
+ </p>
+ )}
+ </>
+ ) : (
+ <>
+ <div className="flex items-center gap-x-3 text-foreground-light">
+ <BadgeCheck size={14} />
+ <p>All up to date</p>
+ </div>
+ {syncState.closed_at && (
+ <p className="text-foreground-light">
+ Last synced{' '}
+ <TimestampInfo
+ utcTimestamp={syncState.closed_at}
+ label={
+ syncState.closed_at
+ ? formatRelative(new Date(syncState.closed_at), new Date())
+ : 'recently'
+ }
+ />
+ </p>
+ )}
+ </>
+ )}
+ </div>
+ )}
+ </CardTitle>
+ </CardHeader>
<CardContent className="@container">
<div className="flex flex-col items-start justify-between gap-4 @md:flex-row @md:items-center">
- <div className="flex gap-x-4">
- <Table2 className="w-5 h-5 shrink-0" />
- <div className="flex flex-col gap-1">
- <h5 className="text-sm mb-1">Open Stripe schema in Table Editor</h5>
- <p className="text-sm text-foreground-light text-balance">
- The Stripe Sync Engine stores all synced data in the{' '}
- <code className="text-code-inline !break-keep">stripe</code> schema. You can
- view and query this data directly in the Table Editor.
- </p>
- </div>
+ <div className="flex flex-col gap-1">
+ <h5 className="text-sm">View Stripe data in Table Editor</h5>
+ <p className="text-sm text-foreground-light text-balance">
+ The Stripe Sync Engine stores all synced data in the{' '}
+ <code className="text-code-inline !break-keep">stripe</code> schema. You can
+ view and query this data directly in the Table Editor.
+ </p>
</div>
+
<Button asChild type="default" className="ml-8 @md:ml-0">
<Link href={`/project/${project?.ref}/editor?schema=stripe`}>
Open Table Editor
diff --git a/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/stripe-sync-status.ts b/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/stripe-sync-status.ts
index d57ce7100b9..314d2f5cbd1 100644
--- a/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/stripe-sync-status.ts
+++ b/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/stripe-sync-status.ts
@@ -3,177 +3,73 @@ import type {
StripeSyncStateData,
} from 'data/database-integrations/stripe/sync-state-query'
import type { Schema } from 'data/database/schemas-query'
-import {
- INSTALLATION_ERROR_SUFFIX,
- INSTALLATION_INSTALLED_SUFFIX,
- INSTALLATION_STARTED_SUFFIX,
- STRIPE_SCHEMA_COMMENT_PREFIX,
-} from 'stripe-experiment-sync/supabase'
-
-/**
- * All possible Stripe Sync installation states.
- */
-export type StripeInstallationStatus =
- | 'installing'
- | 'installed'
- | 'install_error'
- | 'uninstalling'
- | 'uninstalled'
- | 'uninstall_error'
-
-/**
- * Parsed Stripe schema status including version and error message
- */
-export interface ParsedStripeSchema {
- /** The installation status */
- status: StripeInstallationStatus
-
- /** The version from the schema comment (e.g., 'v1.2.3') */
- version?: string
-
- /** Error message if status is install_error or uninstall_error */
- errorMessage?: string
-}
+import { SchemaInstallationStatus, StripeSchemaComment } from 'stripe-experiment-sync/supabase'
/**
* Complete Stripe Sync status including schema, installation state, and sync state
*/
export interface StripeSyncStatusResult {
/** The parsed schema with status, version and error */
- parsedSchema: ParsedStripeSchema
+ schemaComment: StripeSchemaComment
/** Current sync run state (only available when installationStatus is installed) */
syncState: StripeSyncState | undefined
/** Whether the status is still being determined (schemas query is loading) */
isLoading: boolean
-}
-
-// TODO: The current version of the package 'stripe-experiment-sync' doesn't export
-// these constants, but we plan to export them in future version. For now we
-// declare the same constants here to deploy this code without waiting for
-// a new version. We'll import them when we bump 'stripe-experiment-sync' package
-// version.
-const UNINSTALLATION_STARTED_SUFFIX = 'uninstallation:started'
-const UNINSTALLATION_ERROR_SUFFIX = 'uninstallation:error'
-export function findStripeSchema(schemas: Schema[] | undefined): Schema | undefined {
- return schemas?.find((s) => s.name === 'stripe')
-}
+ /** Latest version of stripe sync engine available for installation */
+ latestAvailableVersion: string
-function isStripeSyncSchema(schema: Schema | undefined): boolean {
- return !!schema?.comment?.startsWith(STRIPE_SCHEMA_COMMENT_PREFIX)
+ /** True when installation or uninstallation has timed out */
+ timedOut: boolean
}
-/**
- * Parse the installation status from a stripe schema.
- *
- * Schema comment format: {PREFIX} {version} {SUFFIX}[ - {error message}]
- * Example: "stripe_sync v1.2.3 installation:error - Could not apply migration"
- *
- * @param stripeSchema - The stripe schema from the database, if it exists
- * @returns The parsed status including version and optional error message
- */
-export function parseStripeSchema(stripeSchema: Schema | undefined): ParsedStripeSchema {
- if (!isStripeSyncSchema(stripeSchema)) {
- return { status: 'uninstalled' }
- }
-
- const comment = stripeSchema!.comment!
-
- // Remove prefix and leading space
- const afterPrefix = comment.slice(STRIPE_SCHEMA_COMMENT_PREFIX.length).trimStart()
-
- // Split at first space to get version and trailing segment
- const firstSpaceIndex = afterPrefix.indexOf(' ')
- if (firstSpaceIndex === -1) {
- return { status: 'uninstalled' }
- }
-
- const version = afterPrefix.slice(0, firstSpaceIndex)
- const trailing = afterPrefix.slice(firstSpaceIndex + 1)
-
- // Helper to extract error message if present after ' - ' separator
- const extractError = (afterSuffix: string): string | undefined => {
- if (afterSuffix.startsWith(' - ')) {
- return afterSuffix.slice(3) // Remove ' - ' (3 characters)
- }
- return afterSuffix
- }
-
- // Check status in priority order
- if (trailing.startsWith(UNINSTALLATION_ERROR_SUFFIX)) {
- return {
- status: 'uninstall_error',
- version,
- errorMessage: extractError(trailing.slice(UNINSTALLATION_ERROR_SUFFIX.length)),
- }
- }
-
- if (trailing.startsWith(INSTALLATION_ERROR_SUFFIX)) {
- return {
- status: 'install_error',
- version,
- errorMessage: extractError(trailing.slice(INSTALLATION_ERROR_SUFFIX.length)),
- }
- }
-
- if (trailing.startsWith(UNINSTALLATION_STARTED_SUFFIX)) {
- return { status: 'uninstalling', version }
- }
-
- if (trailing.startsWith(INSTALLATION_STARTED_SUFFIX)) {
- return { status: 'installing', version }
- }
-
- if (trailing.startsWith(INSTALLATION_INSTALLED_SUFFIX)) {
- return { status: 'installed', version }
- }
-
- return { status: 'uninstalled' }
+export function findStripeSchema(schemas: Schema[] | undefined): Schema | undefined {
+ return schemas?.find((s) => s.name === 'stripe')
}
-export function isInstalled(status: StripeInstallationStatus): boolean {
+export function isInstalled(status: SchemaInstallationStatus): boolean {
return status === 'installed'
}
-export function isUninstalled(status: StripeInstallationStatus): boolean {
+export function isUninstalled(status: SchemaInstallationStatus): boolean {
return status === 'uninstalled'
}
-export function hasInstallError(status: StripeInstallationStatus): boolean {
- return status === 'install_error'
+export function hasInstallError(status: SchemaInstallationStatus): boolean {
+ return status === 'install error'
}
-export function hasUninstallError(status: StripeInstallationStatus): boolean {
- return status === 'uninstall_error'
+export function hasUninstallError(status: SchemaInstallationStatus): boolean {
+ return status === 'uninstall error'
}
-export function hasError(status: StripeInstallationStatus): boolean {
+export function hasError(status: SchemaInstallationStatus): boolean {
return hasInstallError(status) || hasUninstallError(status)
}
-export function isInstalling(status: StripeInstallationStatus): boolean {
+export function isInstalling(status: SchemaInstallationStatus): boolean {
return status === 'installing'
}
-export function isUninstalling(status: StripeInstallationStatus): boolean {
+export function isUninstalling(status: SchemaInstallationStatus): boolean {
return status === 'uninstalling'
}
-export function isInProgress(status: StripeInstallationStatus): boolean {
+export function isInProgress(status: SchemaInstallationStatus): boolean {
return isInstalling(status) || isUninstalling(status)
}
-export function isInstallDone(status: StripeInstallationStatus): boolean {
+export function isInstallDone(status: SchemaInstallationStatus): boolean {
return isInstalled(status) || hasInstallError(status)
}
-export function isUninstallDone(status: StripeInstallationStatus): boolean {
+export function isUninstallDone(status: SchemaInstallationStatus): boolean {
return isUninstalled(status) || hasUninstallError(status)
}
-export function canInstall(status: StripeInstallationStatus): boolean {
+export function canInstall(status: SchemaInstallationStatus): boolean {
return isUninstalled(status) || hasError(status)
}
diff --git a/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/useStripeSyncStatus.ts b/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/useStripeSyncStatus.ts
index 4332391c25c..e366e1167a5 100644
--- a/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/useStripeSyncStatus.ts
+++ b/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/useStripeSyncStatus.ts
@@ -1,15 +1,19 @@
import { useStripeSyncingState } from 'data/database-integrations/stripe/sync-state-query'
import { SchemasVariables, useSchemasQuery } from 'data/database/schemas-query'
import { useEffect } from 'react'
+import { checkDomainOfScale } from 'recharts/types/util/ChartUtils'
+import { getCurrentVersion, parseSchemaComment } from 'stripe-experiment-sync/supabase'
import {
findStripeSchema,
isInProgress,
isInstalled,
- parseStripeSchema,
type StripeSyncStatusResult,
} from '@/components/interfaces/Integrations/templates/StripeSyncEngine/stripe-sync-status'
+// Maximum time allowed for installation or uninstallation operations before the UI times out
+const OPERATION_TIME_OUT_MS: number = 5 * 60 * 1000 // 5 minutes
+
/**
* Unified hook for Stripe Sync installation status.
*
@@ -21,6 +25,8 @@ export function useStripeSyncStatus({
projectRef,
connectionString,
}: SchemasVariables): StripeSyncStatusResult {
+ const latestAvailableVersion = getCurrentVersion()
+
// Query schemas once
const {
data: schemas,
@@ -30,10 +36,42 @@ export function useStripeSyncStatus({
// Find and parse stripe schema status
const stripeSchema = findStripeSchema(schemas)
- const parsedSchema = parseStripeSchema(stripeSchema)
+ const rawSchemaComment = parseSchemaComment(stripeSchema?.comment)
+
+ const now = Date.now()
+ const timedOut = rawSchemaComment.startTime
+ ? now - rawSchemaComment.startTime > OPERATION_TIME_OUT_MS
+ : false
+
+ const status = timedOut
+ ? rawSchemaComment.status === 'installing'
+ ? 'install error'
+ : rawSchemaComment.status === 'uninstalling'
+ ? 'uninstall error'
+ : rawSchemaComment.status
+ : rawSchemaComment.status
+
+ const errorMessage = timedOut
+ ? rawSchemaComment.status === 'installing'
+ ? 'Installation timed out'
+ : rawSchemaComment.status === 'uninstalling'
+ ? 'Uninstallation timed out'
+ : rawSchemaComment.errorMessage
+ : rawSchemaComment.errorMessage
+
+ const schemaComment = { ...rawSchemaComment, status, errorMessage }
- const installed = isInstalled(parsedSchema.status)
- const inProgress = isInProgress(parsedSchema.status)
+ const installed = isInstalled(schemaComment.status)
+ const inProgress = isInProgress(schemaComment.status)
+
+ // Query sync state only when installed
+ const { data: syncState, isPending: isLoadingStripeSyncState } = useStripeSyncingState(
+ { projectRef: projectRef!, connectionString },
+ {
+ refetchInterval: 4000,
+ enabled: !!projectRef && installed,
+ }
+ )
// Poll schemas during install/uninstall operations
useEffect(() => {
@@ -48,18 +86,11 @@ export function useStripeSyncStatus({
return () => clearInterval(interval)
}, [inProgress, refetch])
- // Query sync state only when installed
- const { data: syncState, isLoading: isSyncStateLoading } = useStripeSyncingState(
- { projectRef: projectRef!, connectionString },
- {
- refetchInterval: 4000,
- enabled: !!projectRef && installed,
- }
- )
-
return {
- parsedSchema,
+ schemaComment,
syncState: installed ? syncState : undefined,
- isLoading: isSchemasLoading,
+ isLoading: isSchemasLoading || isLoadingStripeSyncState,
+ latestAvailableVersion,
+ timedOut,
}
}
diff --git a/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/FloatingMobileToolbar.tsx b/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/FloatingMobileToolbar.tsx
index cffc4dd9365..db5dd46ba48 100644
--- a/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/FloatingMobileToolbar.tsx
+++ b/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/FloatingMobileToolbar.tsx
@@ -16,7 +16,7 @@ import { useFloatingToolbarNavSize } from './useFloatingToolbarNavSize'
import { useFloatingToolbarSheet } from './useFloatingToolbarSheet'
import { useFloatingToolbarSidebarClick } from './useFloatingToolbarSidebarClick'
-const FloatingMobileToolbar = ({ hideMobileMenu }: { hideMobileMenu?: boolean }) => {
+export const FloatingMobileToolbar = ({ hideMobileMenu }: { hideMobileMenu?: boolean }) => {
const navRef = useRef<HTMLElement | null>(null)
const sheet = useFloatingToolbarSheet(hideMobileMenu)
const drag = useFloatingToolbarDrag(navRef)
@@ -58,6 +58,7 @@ const FloatingMobileToolbar = ({ hideMobileMenu }: { hideMobileMenu?: boolean })
>
<AnimatePresence initial={false}>
<ButtonTooltip
+ key="search"
type={isSearchOpen ? 'secondary' : 'outline'}
size="tiny"
id="search-trigger"
@@ -80,24 +81,25 @@ const FloatingMobileToolbar = ({ hideMobileMenu }: { hideMobileMenu?: boolean })
>
<Search size={16} strokeWidth={1} />
</ButtonTooltip>
- <span data-sidebar-id={SIDEBAR_KEYS.HELP_PANEL}>
+ <span key="help" data-sidebar-id={SIDEBAR_KEYS.HELP_PANEL}>
<HelpButton />
</span>
- <span data-sidebar-id={SIDEBAR_KEYS.ADVISOR_PANEL}>
+ <span key="advisor" data-sidebar-id={SIDEBAR_KEYS.ADVISOR_PANEL}>
<AdvisorButton projectRef={projectRef} />
</span>
{!!projectRef && (
<>
- <span data-sidebar-id={SIDEBAR_KEYS.EDITOR_PANEL}>
+ <span key="editor" data-sidebar-id={SIDEBAR_KEYS.EDITOR_PANEL}>
<InlineEditorButton />
</span>
- <span data-sidebar-id={SIDEBAR_KEYS.AI_ASSISTANT}>
+ <span key="assistant" data-sidebar-id={SIDEBAR_KEYS.AI_ASSISTANT}>
<AssistantButton />
</span>
</>
)}
{sheet.showMenuButton && sheet.isSheetOpen && (
<Button
+ key="menu"
title="Menu dropdown button"
type={sheet.isMenuOpen ? 'secondary' : 'default'}
className={cn(
@@ -129,5 +131,3 @@ const FloatingMobileToolbar = ({ hideMobileMenu }: { hideMobileMenu?: boolean })
</nav>
)
}
-
-export default FloatingMobileToolbar
diff --git a/apps/studio/components/layouts/Navigation/NavigationBar/MobileNavigationBar.tsx b/apps/studio/components/layouts/Navigation/NavigationBar/MobileNavigationBar.tsx
index e9c4b5fbe4c..112a4224e53 100644
--- a/apps/studio/components/layouts/Navigation/NavigationBar/MobileNavigationBar.tsx
+++ b/apps/studio/components/layouts/Navigation/NavigationBar/MobileNavigationBar.tsx
@@ -4,7 +4,7 @@ import { ConnectButton } from 'components/interfaces/ConnectButton/ConnectButton
import { LocalDropdown } from 'components/interfaces/LocalDropdown'
import { SidebarContent } from 'components/interfaces/Sidebar'
import { UserDropdown } from 'components/interfaces/UserDropdown'
-import FloatingMobileToolbar from 'components/layouts/Navigation/FloatingMobileToolbar/FloatingMobileToolbar'
+import { FloatingMobileToolbar } from 'components/layouts/Navigation/FloatingMobileToolbar/FloatingMobileToolbar'
import { useOrganizationsQuery } from 'data/organizations/organizations-query'
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
import { IS_PLATFORM } from 'lib/constants'
diff --git a/apps/studio/components/ui/AlertError.tsx b/apps/studio/components/ui/AlertError.tsx
index b95b2ea77aa..822c289b42c 100644
--- a/apps/studio/components/ui/AlertError.tsx
+++ b/apps/studio/components/ui/AlertError.tsx
@@ -8,6 +8,7 @@ import { Admonition } from 'ui-patterns/admonition'
export interface AlertErrorProps {
projectRef?: string
subject?: string
+ description?: string
error?: { message: string } | null
layout?: 'vertical' | 'horizontal' | 'responsive'
className?: string
@@ -46,6 +47,7 @@ export const ContactSupportButton = ({
export const AlertError = ({
projectRef,
subject,
+ description = 'Try refreshing your browser, but if the issue persists for more than a few minutes, please reach out to us via support.',
error,
className,
showIcon = true,
@@ -87,12 +89,7 @@ export const AlertError = ({
{formattedErrorMessage}
</p>
)}
- {showInstructions && (
- <p>
- Try refreshing your browser, but if the issue persists for more than a few minutes,
- please reach out to us via support.
- </p>
- )}
+ {showInstructions && <p>{description}</p>}
{children}
</>
}
diff --git a/apps/studio/data/database-integrations/stripe/stripe-sync-install-mutation.ts b/apps/studio/data/database-integrations/stripe/stripe-sync-install-mutation.ts
index de346162491..a0ce42e41b3 100644
--- a/apps/studio/data/database-integrations/stripe/stripe-sync-install-mutation.ts
+++ b/apps/studio/data/database-integrations/stripe/stripe-sync-install-mutation.ts
@@ -1,16 +1,17 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
-import { toast } from 'sonner'
-
import { getAccessToken } from 'common'
import { databaseKeys } from 'data/database/keys'
import { BASE_PATH } from 'lib/constants'
import { useTrack } from 'lib/telemetry/track'
+import { toast } from 'sonner'
import type { ResponseError } from 'types'
+
import { stripeSyncKeys } from './keys'
export type StripeSyncInstallVariables = {
projectRef: string
stripeSecretKey: string
+ startTime: number
}
export type StripeSyncInstallResponse = {
@@ -21,6 +22,7 @@ export type StripeSyncInstallResponse = {
export async function installStripeSync({
projectRef,
stripeSecretKey,
+ startTime,
}: StripeSyncInstallVariables): Promise<StripeSyncInstallResponse> {
const accessToken = await getAccessToken()
@@ -33,6 +35,7 @@ export async function installStripeSync({
body: JSON.stringify({
projectRef,
stripeSecretKey,
+ startTime,
}),
})
diff --git a/apps/studio/data/database-integrations/stripe/stripe-sync-uninstall-mutation.ts b/apps/studio/data/database-integrations/stripe/stripe-sync-uninstall-mutation.ts
index 2cd9e892bf0..ce32dcb8e85 100644
--- a/apps/studio/data/database-integrations/stripe/stripe-sync-uninstall-mutation.ts
+++ b/apps/studio/data/database-integrations/stripe/stripe-sync-uninstall-mutation.ts
@@ -1,15 +1,16 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
-import { toast } from 'sonner'
-
import { getAccessToken } from 'common'
import { databaseKeys } from 'data/database/keys'
import { BASE_PATH } from 'lib/constants'
import { useTrack } from 'lib/telemetry/track'
+import { toast } from 'sonner'
import type { ResponseError } from 'types'
+
import { stripeSyncKeys } from './keys'
export type StripeSyncUninstallVariables = {
projectRef: string
+ startTime: number
}
export type StripeSyncUninstallResponse = {
@@ -19,6 +20,7 @@ export type StripeSyncUninstallResponse = {
export async function uninstallStripeSync({
projectRef,
+ startTime,
}: StripeSyncUninstallVariables): Promise<StripeSyncUninstallResponse> {
const accessToken = await getAccessToken()
@@ -30,6 +32,7 @@ export async function uninstallStripeSync({
},
body: JSON.stringify({
projectRef,
+ startTime,
}),
})
diff --git a/apps/studio/package.json b/apps/studio/package.json
index caf3c5239d9..b0d8393fd37 100644
--- a/apps/studio/package.json
+++ b/apps/studio/package.json
@@ -137,7 +137,7 @@
"sql-formatter": "^15.0.0",
"sqlstring": "^2.3.2",
"streamdown": "^1.3.0",
- "stripe-experiment-sync": "^1.0.19",
+ "stripe-experiment-sync": "1.0.27",
"tus-js-client": "^4.1.0",
"ui": "workspace:*",
"ui-patterns": "workspace:*",
diff --git a/apps/studio/pages/api/integrations/stripe-sync.ts b/apps/studio/pages/api/integrations/stripe-sync.ts
index 3e43dd7de11..be245948a41 100644
--- a/apps/studio/pages/api/integrations/stripe-sync.ts
+++ b/apps/studio/pages/api/integrations/stripe-sync.ts
@@ -7,10 +7,12 @@ import { z } from 'zod'
const InstallBodySchema = z.object({
projectRef: z.string().min(1),
stripeSecretKey: z.string().min(1),
+ startTime: z.number().positive().optional(),
})
const UninstallBodySchema = z.object({
projectRef: z.string().min(1),
+ startTime: z.number().positive().optional(),
})
async function isStripeSyncEnabled() {
@@ -59,7 +61,7 @@ async function handleDeleteStripeSyncInstall(req: NextApiRequest, res: NextApiRe
.status(400)
.json({ data: null, error: { message: 'Bad Request: Invalid request body' } })
}
- const { projectRef } = parsed.data
+ const { projectRef, startTime } = parsed.data
waitUntil(
uninstall({
@@ -67,6 +69,7 @@ async function handleDeleteStripeSyncInstall(req: NextApiRequest, res: NextApiRe
supabaseProjectRef: projectRef,
baseProjectUrl: process.env.NEXT_PUBLIC_CUSTOMER_DOMAIN,
supabaseManagementUrl: process.env.NEXT_PUBLIC_API_DOMAIN,
+ startTime,
}).catch((error) => {
console.error('Stripe Sync Engine uninstallation failed.', error)
throw error
@@ -92,7 +95,7 @@ async function handleSetupStripeSyncInstall(req: NextApiRequest, res: NextApiRes
.status(400)
.json({ data: null, error: { message: 'Bad Request: Invalid request body' } })
}
- const { projectRef, stripeSecretKey } = parsed.data
+ const { projectRef, stripeSecretKey, startTime } = parsed.data
// Validate the Stripe API key before proceeding with installation
try {
@@ -113,10 +116,12 @@ async function handleSetupStripeSyncInstall(req: NextApiRequest, res: NextApiRes
error: { message: errorMessage },
})
}
- } catch (error: any) {
+ } catch (error) {
+ const normalizedErrorMessage = error instanceof Error ? error.message : String(error)
+
return res.status(400).json({
data: null,
- error: { message: `Failed to validate Stripe API key: ${error.message}` },
+ error: { message: `Failed to validate Stripe API key: ${normalizedErrorMessage}` },
})
}
waitUntil(
@@ -127,6 +132,7 @@ async function handleSetupStripeSyncInstall(req: NextApiRequest, res: NextApiRes
baseProjectUrl: process.env.NEXT_PUBLIC_CUSTOMER_DOMAIN,
supabaseManagementUrl: process.env.NEXT_PUBLIC_API_DOMAIN,
packageVersion: VERSION,
+ startTime,
}).catch((error) => {
console.error('Stripe Sync Engine installation failed.', error)
throw error
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 3c500b8865a..e2827af1d7e 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1081,8 +1081,8 @@ importers:
specifier: ^1.3.0
stripe-experiment-sync:
- specifier: ^1.0.19
- version: 1.0.19(@types/[email protected])([email protected])
+ specifier: 1.0.27
+ version: 1.0.27(@types/[email protected])([email protected])
tus-js-client:
specifier: ^4.1.0
version: 4.1.0
@@ -4354,15 +4354,6 @@ packages:
'@types/node':
optional: true
- '@inquirer/[email protected]':
- resolution: {integrity: sha512-sXhVB8n20NYkUBfDYgizGHlpRVaCRjtuzNZA6xpALIUbkgfd2Hjz+DfEN6+h1BRnuxw0/P4jCIMjMsEOAMwAJw==}
- engines: {node: '>=18'}
- peerDependencies:
- '@types/node': '>=18'
- peerDependenciesMeta:
- '@types/node':
- optional: true
-
'@inquirer/[email protected]':
resolution: {integrity: sha512-43RTuEbfP8MbKzedNqBrlhhNKVwoK//vUFNW3Q3vZ88BLcrs4kYpGg+B2mm5p2K/HfygoCxuKwJJiv8PbGmE0A==}
engines: {node: '>=18'}
@@ -4399,10 +4390,6 @@ packages:
'@types/node':
optional: true
- '@inquirer/[email protected]':
- resolution: {integrity: sha512-eOg92lvrn/aRUqbxRyvpEWnrvRuTYRifixHkYVpJiygTgVSBIHDqLh0SrMQXkafvULg3ck11V7xvR+zcgvpHFw==}
- engines: {node: '>=18'}
-
'@inquirer/[email protected]':
resolution: {integrity: sha512-t2IEY+unGHOzAaVM5Xx6DEWKeXlDDcNPeDyUpsRc6CUhBfU3VQOEl+Vssh7VNp1dR8MdUJBWhuObjXCsVpjN5g==}
engines: {node: '>=18'}
@@ -4479,15 +4466,6 @@ packages:
'@types/node':
optional: true
- '@inquirer/[email protected]':
- resolution: {integrity: sha512-ZJpeIYYueOz/i/ONzrfof8g89kNdO2hjGuvULROo3O8rlB2CRtSseE5KeirnyE4t/thAn/EwvS/vuQeJCn+NZg==}
- engines: {node: '>=18'}
- peerDependencies:
- '@types/node': '>=18'
- peerDependenciesMeta:
- '@types/node':
- optional: true
-
'@ioredis/[email protected]':
resolution: {integrity: sha512-aFT2yemJJo+TZCmieA7qnYGQooOS7QfNmYrzGtsYd3g9j5iDP8AimYYAesf79ohjbLG12XxC4nG5DyEnC88AsQ==}
@@ -15085,9 +15063,6 @@ packages:
resolution: {integrity: sha512-yJ4QKRyNxE44baQ9mY5+r/kAzZ8yXMemtNAOFwOzRXJscdjSxxzWSNlyBAr+o5JjkUw9Lc3W7OIoca0cY3PYnQ==}
- resolution: {integrity: sha512-Faj29Kzh7oCbt1bz6vAGNKtRJlV/GolOQTx87eYUnfCK7eVXdN9jQVojroc7tcJ5OQgyhbeOqD7LS/8UtGBnMQ==}
-
resolution: {integrity: sha512-s1cIatOqrrhSj2tmJ4abFYZQK6l5v+V4toO5q1Pa0DyN8mtyqy2I+Qrj5W9vOELEtybIMQs/TBZGVO/DtTFK8w==}
@@ -17261,8 +17236,8 @@ packages:
resolution: {integrity: sha512-8r3mkIM/2+PpjHoOtiAW8Rg3jJLHaV7xPwG+YRGrv6FP0wwk/toTpATxWYOW0BKdWwl82VT2tFYi5DlROa0Mxg==}
- resolution: {integrity: sha512-sGFMnHrXp8by6DvKARx1yaAhPWGJj2v83y566VOWUV+O/mok0WRlKBCqoAnjsuA9WRF4AkIrido1LR9BEYaYUw==}
+ resolution: {integrity: sha512-Uxt3DLFnjUnBza8c6xrEW1MWrvnIaLg0J7TfZA3kDSlxsNkI3xSj7KV4Gx221ruOgjcbpa2yN++mLLjM795V0w==}
hasBin: true
@@ -17332,8 +17307,8 @@ packages:
engines: {node: '>=8'}
hasBin: true
- resolution: {integrity: sha512-TDQg6Nh7e2DaLmMjqpJt7Wwh2Au5loVPH2gwKMkD89e3pb5F/zMQGWt22asEXme031jEmhjazixFH0lwMgbRJA==}
+ resolution: {integrity: sha512-CWGAczaNXTUDExaxi+hUEPqlPtCiZ4r3a74NXOx7+Sf+P75foCuX/aXL9MztosWwRnZZAI8VGUXpdNe6K3xTtA==}
engines: {node: '>=18.0.0'}
@@ -18742,10 +18717,6 @@ packages:
resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}
engines: {node: '>=10'}
- resolution: {integrity: sha512-cYVsTjKl8b+FrnidjibDWskAv7UKOfcwaVZdp/it9n1s9fU3IkgDbhdIRKCW4JDsAlECJY0ytoVPT3sK6kideA==}
- engines: {node: '>=18'}
-
resolution: {integrity: sha512-U/PBtDf35ff0D8X8D0jfdzHYEPFxAI7jJlxZXwCSez5M3190m+QobIfh+sWDWSHMCWWJN2AWamkegn6vr6YBTw==}
engines: {node: '>=18'}
@@ -18791,6 +18762,9 @@ packages:
resolution: {integrity: sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==}
+ resolution: {integrity: sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==}
+
resolution: {integrity: sha512-QFJWJMdlETcI69paJwhSMJz7PPWjVP8Sjhclxmxmxv/RYI7ZOvR5BHX+ktH0we9gTWQMxcne8q1OY8xxz604gw==}
engines: {node: '>=12.7.0'}
@@ -21240,21 +21214,8 @@ snapshots:
dependencies:
- '@inquirer/core': 10.1.9(@types/[email protected])
- '@inquirer/type': 3.0.5(@types/[email protected])
- optionalDependencies:
- '@types/node': 22.13.14
-
- '@inquirer/[email protected](@types/[email protected])':
- dependencies:
- '@inquirer/figures': 1.0.11
+ '@inquirer/core': 10.3.2(@types/[email protected])
'@inquirer/type': 3.0.10(@types/[email protected])
- ansi-escapes: 4.3.2
- cli-width: 4.1.0
- mute-stream: 2.0.0
- signal-exit: 4.1.0
- wrap-ansi: 6.2.0
- yoctocolors-cjs: 2.1.2
optionalDependencies:
'@types/node': 22.13.14
@@ -21294,8 +21255,6 @@ snapshots:
optionalDependencies:
'@types/node': 22.13.14
- '@inquirer/[email protected]': {}
-
'@inquirer/[email protected]': {}
@@ -21366,10 +21325,6 @@ snapshots:
optionalDependencies:
'@types/node': 22.13.14
- '@inquirer/[email protected](@types/[email protected])':
- optionalDependencies:
- '@types/node': 22.13.14
-
'@ioredis/[email protected]': {}
'@isaacs/[email protected]':
@@ -34109,8 +34064,6 @@ snapshots:
dependencies:
openapi-typescript-helpers: 0.0.15
-
dependencies:
'@types/json-schema': 7.0.15
@@ -36764,24 +36717,26 @@ snapshots:
dependencies:
js-tokens: 9.0.1
dependencies:
'@ngrok/ngrok': 1.6.0
chalk: 5.4.1
commander: 12.1.0
dotenv: 16.5.0
+ esbuild: 0.25.2
express: 4.22.1([email protected])
inquirer: 12.11.1(@types/[email protected])
papaparse: 5.4.1
pg: 8.16.3
pg-node-migrations: 0.0.8
stripe: 17.7.0
- supabase-management-js: 0.1.6
+ supabase-management-js: 2.0.2
ws: 8.18.3
yesql: 7.0.0
transitivePeerDependencies:
- '@types/node'
- bufferutil
+ - debug
- pg-native
- supports-color
- utf-8-validate
@@ -36868,9 +36823,12 @@ snapshots:
pirates: 4.0.6
ts-interface-checker: 0.1.13
dependencies:
- openapi-fetch: 0.6.2
+ axios: 1.13.5
+ zod: 4.3.6
+ transitivePeerDependencies:
+ - debug
dependencies:
@@ -38396,8 +38354,6 @@ snapshots:
-
@@ -38447,6 +38403,8 @@ snapshots:
+
dependencies:
use-sync-external-store: 1.2.0([email protected])