Skip to content

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

Update types

Joshen Limaf11d197619d
diff --git a/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRows.utils.ts b/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRows.utils.ts
index 8c4499e3928..e6441325024 100644
--- a/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRows.utils.ts
+++ b/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/NotificationRows.utils.ts
@@ -1,5 +1,15 @@
import { Project } from 'types'
-import { Notification, NotificationName } from '@supabase/shared-types/out/notifications'
+import {
+ ExtensionsUpgrade,
+ Notification,
+ NotificationName,
+ PostgresqlUpgradeData,
+ ProjectExceedingTierLimitData,
+ ProjectUpdateData,
+ ServerUpgrade,
+ ServiceUpgrade,
+ ViolatedLimit,
+} from '@supabase/shared-types/out/notifications'
// Switch to proper typing with NotificationName after PR is in
export const formatNotificationText = (project: Project, notification: Notification) => {
@@ -7,33 +17,37 @@ export const formatNotificationText = (project: Project, notification: Notificat
const notificationName = notification.notification_name
if (notificationName === NotificationName.ProjectExceedingTierLimit) {
- const { violations } = notification.data
+ const { violations } = notification.data as ProjectExceedingTierLimitData
const violationsText = violations
- .map((violation: any) => violation.dimension)
+ .map((violation: ViolatedLimit) => violation.dimension as string)
.reduce((a: string, b: string) => `${a}, ${b}`)
return `Your project "${projectName}" has exceeded its limits in the following areas: ${violationsText}. Please upgrade your project to ensure continued availability.`
- } else if (notificationName === 'postgresql.upgrade-available') {
- const { upgrade_type, additional } = notification.data
- const { name, version_to } = additional
+ } else if (notificationName === NotificationName.PostgresqlUpgradeAvailable) {
+ const { upgrade_type, additional } = notification.data as PostgresqlUpgradeData
+
if (upgrade_type === 'postgresql-server') {
+ const { version_to } = additional as ServerUpgrade
return `A new version of Postgres (${version_to}) is now available for project "${projectName}". You may restart your project to get this update.`
} else if (upgrade_type === 'extensions') {
+ const { name, version_to } = additional as ExtensionsUpgrade
return `A new version of the extension "${name}" (${version_to}) is now available for project "${projectName}". You may restart your project to get this update.`
}
return ''
- } else if (notificationName === 'postgresql.upgrade-completed') {
- const { upgrade_type, additional } = notification.data
- const { name, version_to } = additional
+ } else if (notificationName === NotificationName.PostgresqlUpgradeCompleted) {
+ const { upgrade_type, additional } = notification.data as PostgresqlUpgradeData
+
if (upgrade_type === 'postgresql-server') {
+ const { version_to } = additional as ServerUpgrade
return `Postgres (${version_to}) has been successfully updated to ${version_to} for project "${projectName}".`
} else if (upgrade_type === 'extensions') {
+ const { name, version_to } = additional as ExtensionsUpgrade
return `The extension "${name}" has been successfully updated to ${version_to} for project "${projectName}`
}
} else if (notificationName === 'project.update-completed') {
- const { upgrades } = notification.data
+ const { upgrades } = notification.data as ProjectUpdateData
const upgradesText = upgrades
- .map((upgrade: any) => upgrade.name)
+ .map((upgrade: ServiceUpgrade) => upgrade.name)
.reduce((a: string, b: string) => `${a}, ${b}`)
return `The following services have been successfully updated for project "${projectName}": ${upgradesText}`
} else {
diff --git a/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/Notifications.types.ts b/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/Notifications.types.ts
deleted file mode 100644
index d5d35fa1582..00000000000
--- a/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/Notifications.types.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-// These should go into shared-types repo i think, but chucking it here for now
-// For discussion on Monday
-
-export interface TierLimitExceededNotification {
- dimension: string // probably an enum
- tier_limit: number
- maximum_recent_value: number
- // When values are updated, instead of creating a new notification
- last_updated_at: string
- first_violated_at: string
-}
-
-export interface PostgreslInformationalNotification {
- type: string // probably an enum
- new_version: string // This is assuming that all notifications are about version updates
- extension_name: string
-}
-
-export interface PostgresqlBugfixNotification {}
-
-export interface NotificationMeta {
- restart_required: boolean
- services_to_restart: string[] // I don't think we need this
-}
-
-/**
- * Other questions:
- * - how many notifications to fetch at once?
- * - how to mark as seen from UI
- */