mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 01:45:10 +03:00
refactor(studio): import SQL editor store from source, delete facade + barrel (#47533)
## What Final PR of the SQL editor state re-layering stack. Removes the compatibility shims left in place during the migration: - Migrates all **23** consumers of the `@/state/sql-editor-v2` facade to import directly from `@/state/sql-editor/sql-editor-state`, where `useSqlEditorV2StateSnapshot`, `getSqlEditorV2StateSnapshot`, `useSnippets`, and `useSnippetFolders` actually live. - Deletes `state/sql-editor-v2.ts` (the facade) and `state/sql-editor/index.ts` (the barrel). Both re-exported the same symbols; nothing imports them after the migration. This collapses the two-layer re-export (`sql-editor-v2` → `index` → source) into direct source imports, matching the repo convention to avoid barrel re-export files. ## Notes - Pure import-path migration — no behavior change. All 23 consumers imported only value symbols that resolve to `sql-editor-state.ts`; none imported the `StateSnippet`/`StateSnippetFolder` types via the facade. - Symbol names keep their `V2` suffix for now — renaming `useSqlEditorV2StateSnapshot` etc. is a separate, larger churn best done on its own. - 25 files: 23 one-line import changes + 2 deletions (23 insertions / 39 deletions). ## Validation - `pnpm --filter studio typecheck` ✅ (confirms no dangling facade/barrel imports anywhere) - `pnpm exec vitest --run state/sql-editor/` ✅ (113 passed) - lint ✅ (0 errors; no ratcheted-rule regressions — a path swap can't add `any`/deps/nested-component violations, and no import-order rule is enforced) - grep confirms zero remaining `sql-editor-v2` references --------- Co-authored-by: supabase-autofix-bot <noreply@supabase.com>
This commit is contained in:
1 parent
aa764e4013
commit
cdc2dc4e26
25 files changed
+26
-39
No files matched your search
@@ -7,7 +7,7 @@ import { SIDEBAR_KEYS } from '@/components/layouts/ProjectLayout/LayoutSidebar/L
|
||||
import { AiAssistantDropdown } from '@/components/ui/AiAssistantDropdown'
|
||||
import { useAiAssistantStateSnapshot } from '@/state/ai-assistant-state'
|
||||
import { useSidebarManagerSnapshot } from '@/state/sidebar-manager-state'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor-v2'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor/sql-editor-state'
|
||||
|
||||
export interface ExplainSummary {
|
||||
totalTime: number
|
||||
|
||||
@@ -27,7 +27,7 @@ import {
|
||||
} from './SQLEditor.utils'
|
||||
import { TwoOptionToggle } from '@/components/ui/TwoOptionToggle'
|
||||
import { DOCS_URL } from '@/lib/constants'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor-v2'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor/sql-editor-state'
|
||||
|
||||
const CLI_DOCS_URL = `${DOCS_URL}/guides/cli/local-development`
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ import { useContentUpsertMutation } from '@/data/content/content-upsert-mutation
|
||||
import { useSQLSnippetFolderCreateMutation } from '@/data/content/sql-folder-create-mutation'
|
||||
import { Snippet } from '@/data/content/sql-folders-query'
|
||||
import type { SnippetWithContent } from '@/data/content/sql-folders-query'
|
||||
import { useSnippetFolders, useSqlEditorV2StateSnapshot } from '@/state/sql-editor-v2'
|
||||
import { useSnippetFolders, useSqlEditorV2StateSnapshot } from '@/state/sql-editor/sql-editor-state'
|
||||
import { createTabId, useTabsStateSnapshot } from '@/state/tabs'
|
||||
|
||||
interface MoveQueryModalProps {
|
||||
|
||||
@@ -35,7 +35,7 @@ import { Snippet } from '@/data/content/sql-folders-query'
|
||||
import type { SqlSnippet } from '@/data/content/sql-snippets-query'
|
||||
import { useOrgAiOptInLevel } from '@/hooks/misc/useOrgOptedIntoAi'
|
||||
import { IS_PLATFORM } from '@/lib/constants'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor-v2'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor/sql-editor-state'
|
||||
import { createTabId, useTabsStateSnapshot } from '@/state/tabs'
|
||||
|
||||
export interface RenameQueryModalProps {
|
||||
|
||||
@@ -92,9 +92,12 @@ import {
|
||||
import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
|
||||
import { useShortcut } from '@/state/shortcuts/useShortcut'
|
||||
import { useSidebarManagerSnapshot } from '@/state/sidebar-manager-state'
|
||||
import { getSqlEditorV2StateSnapshot, useSqlEditorV2StateSnapshot } from '@/state/sql-editor-v2'
|
||||
import { useSqlEditorDiffRequestSnapshot } from '@/state/sql-editor/sql-editor-diff-request'
|
||||
import { useSqlEditorSessionSnapshot } from '@/state/sql-editor/sql-editor-session-state'
|
||||
import {
|
||||
getSqlEditorV2StateSnapshot,
|
||||
useSqlEditorV2StateSnapshot,
|
||||
} from '@/state/sql-editor/sql-editor-state'
|
||||
import { createTabId, useTabsStateSnapshot } from '@/state/tabs'
|
||||
|
||||
// Load the monaco editor client-side only (does not behave well server-side)
|
||||
|
||||
@@ -12,7 +12,7 @@ import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
|
||||
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
||||
import { useProfile } from '@/lib/profile'
|
||||
import { useTrack } from '@/lib/telemetry/track'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor-v2'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor/sql-editor-state'
|
||||
|
||||
const SQLExamples = () => {
|
||||
const router = useRouter()
|
||||
|
||||
@@ -12,7 +12,7 @@ import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
|
||||
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
||||
import { useProfile } from '@/lib/profile'
|
||||
import { useTrack } from '@/lib/telemetry/track'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor-v2'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor/sql-editor-state'
|
||||
|
||||
const SQLTemplates = () => {
|
||||
const router = useRouter()
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Badge } from 'ui'
|
||||
|
||||
import { useProfile } from '@/lib/profile'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor-v2'
|
||||
import { isSnippetOwner } from '@/state/sql-editor/sql-editor-rules'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor/sql-editor-state'
|
||||
|
||||
export type ReadOnlyBadgeProps = { id: string }
|
||||
const ReadOnlyBadge = ({ id }: ReadOnlyBadgeProps) => {
|
||||
|
||||
@@ -5,10 +5,10 @@ import { Button, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
|
||||
|
||||
import ReadOnlyBadge from './ReadOnlyBadge'
|
||||
import { useProfile } from '@/lib/profile'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor-v2'
|
||||
import { isSaveFailed, isSaving } from '@/state/sql-editor/sql-editor-lifecycle'
|
||||
import { isSnippetOwner } from '@/state/sql-editor/sql-editor-rules'
|
||||
import { useSqlEditorSaveCoordinator } from '@/state/sql-editor/sql-editor-save-coordinator'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor/sql-editor-state'
|
||||
|
||||
export type SavingIndicatorProps = { id: string }
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'
|
||||
import { IS_PLATFORM } from '@/lib/constants'
|
||||
import { hotkeyToKeys } from '@/state/shortcuts/formatShortcut'
|
||||
import { SHORTCUT_DEFINITIONS, SHORTCUT_IDS } from '@/state/shortcuts/registry'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor-v2'
|
||||
import { useSqlEditorSessionSnapshot } from '@/state/sql-editor/sql-editor-session-state'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor/sql-editor-state'
|
||||
|
||||
export type UtilityActionsProps = {
|
||||
id: string
|
||||
|
||||
@@ -10,8 +10,8 @@ import { DownloadResultsButton } from '@/components/ui/DownloadResultsButton'
|
||||
import { useContentUpsertMutation } from '@/data/content/content-upsert-mutation'
|
||||
import { Snippet } from '@/data/content/sql-folders-query'
|
||||
import { useTrack } from '@/lib/telemetry/track'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor-v2'
|
||||
import { useSqlEditorSessionSnapshot } from '@/state/sql-editor/sql-editor-session-state'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor/sql-editor-state'
|
||||
|
||||
export type UtilityPanelProps = {
|
||||
id: string
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
|
||||
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
||||
import { useProfile } from '@/lib/profile'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor-v2'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor/sql-editor-state'
|
||||
|
||||
export const useNewQuery = () => {
|
||||
const router = useRouter()
|
||||
|
||||
@@ -12,7 +12,7 @@ import { useTableColumnsQuery } from '@/data/database/table-columns-query'
|
||||
import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'
|
||||
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
||||
import { formatSql } from '@/lib/formatSql'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor-v2'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor/sql-editor-state'
|
||||
|
||||
export const useAddDefinitions = (id: string, monaco: Monaco | null) => {
|
||||
const { data: project } = useSelectedProjectQuery()
|
||||
|
||||
@@ -5,9 +5,9 @@ import { useEffect, useEffectEvent } from 'react'
|
||||
import { createSqlSnippetSkeletonV2 } from './SQLEditor.utils'
|
||||
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
||||
import { useProfile } from '@/lib/profile'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor-v2'
|
||||
import { wasNeverPersisted } from '@/state/sql-editor/sql-editor-lifecycle'
|
||||
import { canEditSnippet } from '@/state/sql-editor/sql-editor-rules'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor/sql-editor-state'
|
||||
import { useTabsStateSnapshot } from '@/state/tabs'
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,7 +29,7 @@ import { useLocalStorage } from '@/hooks/misc/useLocalStorage'
|
||||
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
||||
import { useProfile } from '@/lib/profile'
|
||||
import { getAppStateSnapshot } from '@/state/app-state'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor-v2'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor/sql-editor-state'
|
||||
|
||||
export const SQLEditorMenu = () => {
|
||||
const router = useRouter()
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
|
||||
|
||||
import { useContentDeleteMutation } from '@/data/content/content-delete-mutation'
|
||||
import { Snippet } from '@/data/content/sql-folders-query'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor-v2'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor/sql-editor-state'
|
||||
import { createTabId, useTabsStateSnapshot } from '@/state/tabs'
|
||||
|
||||
export const DeleteSnippetsModal = ({
|
||||
|
||||
@@ -38,8 +38,8 @@ import { useSqlSnippetsQuery } from '@/data/content/sql-snippets-query'
|
||||
import { useLocalStorage } from '@/hooks/misc/useLocalStorage'
|
||||
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
||||
import { useProfile } from '@/lib/profile'
|
||||
import { useSnippetFolders, useSqlEditorV2StateSnapshot } from '@/state/sql-editor-v2'
|
||||
import { isNewFolder } from '@/state/sql-editor/sql-editor-lifecycle'
|
||||
import { useSnippetFolders, useSqlEditorV2StateSnapshot } from '@/state/sql-editor/sql-editor-state'
|
||||
import { createTabId, useTabsStateSnapshot } from '@/state/tabs'
|
||||
|
||||
interface SQLEditorNavProps {
|
||||
|
||||
+1
-1
@@ -36,12 +36,12 @@ import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
|
||||
import { useLatest } from '@/hooks/misc/useLatest'
|
||||
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
||||
import { useProfile } from '@/lib/profile'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor-v2'
|
||||
import {
|
||||
isFolderEditing,
|
||||
isFolderSaving,
|
||||
type FolderStatus,
|
||||
} from '@/state/sql-editor/sql-editor-lifecycle'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor/sql-editor-state'
|
||||
|
||||
interface SQLEditorTreeViewItemProps extends Omit<
|
||||
ComponentProps<typeof TreeViewItem>,
|
||||
|
||||
@@ -6,7 +6,7 @@ import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
|
||||
import { getContentById } from '@/data/content/content-id-query'
|
||||
import { useContentUpsertMutation } from '@/data/content/content-upsert-mutation'
|
||||
import { Snippet } from '@/data/content/sql-folders-query'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor-v2'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor/sql-editor-state'
|
||||
import type { SqlSnippets } from '@/types'
|
||||
|
||||
export const ShareSnippetModal = ({
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
|
||||
import { getContentById } from '@/data/content/content-id-query'
|
||||
import { useContentUpsertMutation } from '@/data/content/content-upsert-mutation'
|
||||
import { Snippet } from '@/data/content/sql-folders-query'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor-v2'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor/sql-editor-state'
|
||||
import type { SqlSnippets } from '@/types'
|
||||
|
||||
export const UnshareSnippetModal = ({
|
||||
|
||||
@@ -54,7 +54,7 @@ import { useAiAssistantState, useAiAssistantStateSnapshot } from '@/state/ai-ass
|
||||
import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
|
||||
import { useShortcut } from '@/state/shortcuts/useShortcut'
|
||||
import { useSidebarManagerSnapshot } from '@/state/sidebar-manager-state'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor-v2'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor/sql-editor-state'
|
||||
|
||||
interface AIAssistantProps {
|
||||
initialMessages?: MessageType[] | undefined
|
||||
|
||||
@@ -66,7 +66,7 @@ import { editorPanelState, useEditorPanelStateSnapshot } from '@/state/editor-pa
|
||||
import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
|
||||
import { useIsShortcutEnabled } from '@/state/shortcuts/useIsShortcutEnabled'
|
||||
import { useSidebarManagerSnapshot } from '@/state/sidebar-manager-state'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor-v2'
|
||||
import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor/sql-editor-state'
|
||||
|
||||
export const EditorPanel = () => {
|
||||
const {
|
||||
|
||||
@@ -17,8 +17,8 @@ import { useSqlSnippetByIdQuery } from '@/data/content/content-id-query'
|
||||
import { useDashboardHistory } from '@/hooks/misc/useDashboardHistory'
|
||||
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
||||
import { IS_PLATFORM } from '@/lib/constants'
|
||||
import { useSnippets, useSqlEditorV2StateSnapshot } from '@/state/sql-editor-v2'
|
||||
import { wasNeverPersisted } from '@/state/sql-editor/sql-editor-lifecycle'
|
||||
import { useSnippets, useSqlEditorV2StateSnapshot } from '@/state/sql-editor/sql-editor-state'
|
||||
import { createTabId, useTabsStateSnapshot } from '@/state/tabs'
|
||||
import type { NextPageWithLayout } from '@/types'
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
export type { StateSnippet, StateSnippetFolder } from './sql-editor'
|
||||
export {
|
||||
sqlEditorState,
|
||||
getSqlEditorV2StateSnapshot,
|
||||
useSqlEditorV2StateSnapshot,
|
||||
useSnippetFolders,
|
||||
useSnippets,
|
||||
} from './sql-editor'
|
||||
@@ -1,8 +0,0 @@
|
||||
export type { StateSnippet, StateSnippetFolder } from './types'
|
||||
export {
|
||||
sqlEditorState,
|
||||
getSqlEditorV2StateSnapshot,
|
||||
useSqlEditorV2StateSnapshot,
|
||||
useSnippetFolders,
|
||||
useSnippets,
|
||||
} from './sql-editor-state'
|
||||
Reference in new issue
Block a user