mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 01:15:03 +03:00
chore(studio): drop @supabase/postgres-meta in favor of @supabase/pg-meta (#45844)
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## What kind of change does this PR introduce? Refactor / dependency cleanup. ## What is the current behavior? `apps/studio` lists both `@supabase/pg-meta` (workspace package) as a runtime dep and `@supabase/postgres-meta` (external npm package, `^0.64.4`) as a devDependency. The external package is used only for type imports across 44 files — there is no runtime usage and no codegen pipeline that needs it. ## What is the new behavior? Every `Postgres*` type import (`PostgresTable`, `PostgresColumn`, `PostgresPolicy`, `PostgresTrigger`, `PostgresView`, `PostgresMaterializedView`, `PostgresForeignTable`, `PostgresSchema`, `PostgresPublication`, `PostgresRelationship`, `PostgresPrimaryKey`) is replaced with its `PG*` counterpart from `@supabase/pg-meta`, and the external dep is removed from \`apps/studio/package.json\`. Top-level type re-exports were added to \`packages/pg-meta/src/index.ts\` so consumers can import directly from the package root. Two latent issues surfaced by the stricter pg-meta types are also fixed: - \`data/foreign-tables/foreign-tables-query.ts\` was casting foreign-table results as \`PostgresView[]\`; corrected to \`PGForeignTable[]\`. - \`pg-meta\`'s \`PGTrigger\` Zod schema declared \`orientation\`/\`activation\` as \`z.string()\`, inconsistent with pg-meta's own \`getDatabaseTriggerUpdateSQL\` helper that requires the narrow literal unions; tightened to \`z.enum\`. ## Additional context <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Updated internal TypeScript type definitions across the codebase to use the latest type system from `@supabase/pg-meta`. * Removed `@supabase/postgres-meta` dependency. * Enhanced type validation for database triggers and schemas to enforce stricter constraints. [](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/45844) <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
1 parent
6383150c3e
commit
d4079083fc
50 files changed
+158
-262
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import type { PostgresTable } from '@supabase/postgres-meta'
|
||||
import type { PGTable } from '@supabase/pg-meta'
|
||||
import { ArrowRight } from 'lucide-react'
|
||||
import type { PropsWithChildren } from 'react'
|
||||
import type { RenderCellProps } from 'react-data-grid'
|
||||
@@ -38,7 +38,7 @@ export const ForeignKeyFormatter = (props: Props) => {
|
||||
r.source_column_name === column.name
|
||||
)
|
||||
|
||||
const { data: targetTable, isPending: isLoadingTargetTable } = useTableQuery<PostgresTable>(
|
||||
const { data: targetTable, isPending: isLoadingTargetTable } = useTableQuery<PGTable>(
|
||||
{
|
||||
projectRef: project?.ref,
|
||||
connectionString: project?.connectionString,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PostgresTable } from '@supabase/postgres-meta'
|
||||
import type { PGTable } from '@supabase/pg-meta'
|
||||
import { keepPreviousData } from '@tanstack/react-query'
|
||||
import { useParams } from 'common'
|
||||
import { Key } from 'lucide-react'
|
||||
@@ -29,7 +29,7 @@ import { useTableRowsQuery } from '@/data/table-rows/table-rows-query'
|
||||
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
||||
|
||||
interface ReferenceRecordPeekProps {
|
||||
table: PostgresTable
|
||||
table: PGTable
|
||||
column: string
|
||||
value: string | number | Record<string, unknown>
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { DndContext, DragOverlay, PointerSensor, useSensor, useSensors } from '@dnd-kit/core'
|
||||
import { horizontalListSortingStrategy, SortableContext } from '@dnd-kit/sortable'
|
||||
import type { PostgresColumn } from '@supabase/postgres-meta'
|
||||
import type { PGColumn } from '@supabase/pg-meta'
|
||||
import { forwardRef, memo, Ref, useCallback, useMemo, useRef, useState } from 'react'
|
||||
import DataGrid, {
|
||||
CalculatedColumn,
|
||||
@@ -137,7 +137,7 @@ export const Grid = memo(
|
||||
tableEditorSnap.onEditForeignKeyColumnValue({
|
||||
foreignKey,
|
||||
row,
|
||||
column: column as unknown as PostgresColumn,
|
||||
column: column as unknown as PGColumn,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { PGPolicy } from '@supabase/pg-meta'
|
||||
import { ident } from '@supabase/pg-meta/src/pg-format'
|
||||
import type { PostgresPolicy } from '@supabase/postgres-meta'
|
||||
import { has, isEmpty, isEqual } from 'lodash'
|
||||
|
||||
import {
|
||||
@@ -19,7 +19,7 @@ import type { ForeignKeyConstraint } from '@/data/database/foreign-key-constrain
|
||||
|
||||
export const createSQLPolicy = (
|
||||
policyFormFields: PolicyFormField,
|
||||
originalPolicyFormFields?: PostgresPolicy
|
||||
originalPolicyFormFields?: PGPolicy
|
||||
) => {
|
||||
const { definition, check } = policyFormFields
|
||||
const formattedPolicyFormFields = {
|
||||
@@ -129,7 +129,7 @@ export const createPayloadForCreatePolicy = (
|
||||
|
||||
export const createPayloadForUpdatePolicy = (
|
||||
policyFormFields: PolicyFormField,
|
||||
originalPolicyFormFields: PostgresPolicy
|
||||
originalPolicyFormFields: PGPolicy
|
||||
): PostgresPolicyUpdatePayload => {
|
||||
const { definition, check } = policyFormFields
|
||||
const formattedPolicyFormFields = {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PostgresPolicy } from '@supabase/postgres-meta'
|
||||
import type { PGPolicy } from '@supabase/pg-meta'
|
||||
import { isEmpty, noop } from 'lodash'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { toast } from 'sonner'
|
||||
@@ -32,7 +32,7 @@ interface PolicyEditorModalProps {
|
||||
visible?: boolean
|
||||
schema?: string
|
||||
table?: string
|
||||
selectedPolicyToEdit?: PostgresPolicy
|
||||
selectedPolicyToEdit?: PGPolicy
|
||||
showAssistantPreview?: boolean
|
||||
onSelectCancel: () => void
|
||||
onCreatePolicy: (payload: PostgresPolicyCreatePayload) => Promise<boolean>
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
import { PostgresPolicy } from '@supabase/postgres-meta'
|
||||
import type { PGPolicy } from '@supabase/pg-meta'
|
||||
import { Lock } from 'lucide-react'
|
||||
|
||||
interface LockedCreateQuerySection {
|
||||
schema: string
|
||||
selectedPolicy?: PostgresPolicy
|
||||
selectedPolicy?: PGPolicy
|
||||
isRenamingPolicy: boolean
|
||||
formFields: { name: string; table: string; behavior: string; command: string; roles: string }
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
import type { PGPolicy } from '@supabase/pg-meta'
|
||||
import { ident, keyword, safeSql, type SafeSqlFragment } from '@supabase/pg-meta/src/pg-format'
|
||||
import type { PostgresPolicy } from '@supabase/postgres-meta'
|
||||
import { isEqual } from 'lodash'
|
||||
|
||||
// [Joshen] Not used but keeping this for now in case we do an inline editor
|
||||
export const generatePlaceholder = (policy?: PostgresPolicy) => {
|
||||
export const generatePlaceholder = (policy?: PGPolicy) => {
|
||||
if (policy === undefined) {
|
||||
return `
|
||||
-- Press tab to use this code\n
|
||||
@@ -78,7 +78,7 @@ export const generateCreatePolicyQuery = ({
|
||||
}
|
||||
|
||||
export const checkIfPolicyHasChanged = (
|
||||
selectedPolicy: PostgresPolicy,
|
||||
selectedPolicy: PGPolicy,
|
||||
policyForm: {
|
||||
name: string
|
||||
roles: string[]
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
import type { PostgresPolicy } from '@supabase/postgres-meta'
|
||||
import type { PGPolicy } from '@supabase/pg-meta'
|
||||
import { ChevronDown, PanelLeftClose, PanelRightClose, X } from 'lucide-react'
|
||||
import { useState } from 'react'
|
||||
import {
|
||||
@@ -19,7 +19,7 @@ export const PolicyEditorPanelHeader = ({
|
||||
showTools,
|
||||
setShowTools,
|
||||
}: {
|
||||
selectedPolicy?: PostgresPolicy
|
||||
selectedPolicy?: PGPolicy
|
||||
showTools: boolean
|
||||
setShowTools: (v: boolean) => void
|
||||
}) => {
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
import { PostgresPolicy } from '@supabase/postgres-meta'
|
||||
import type { PGPolicy } from '@supabase/pg-meta'
|
||||
import { Search } from 'lucide-react'
|
||||
import { useState } from 'react'
|
||||
import {
|
||||
@@ -26,7 +26,7 @@ import { NoSearchResults } from '@/components/ui/NoSearchResults'
|
||||
interface PolicyTemplatesProps {
|
||||
schema: string
|
||||
table: string
|
||||
selectedPolicy?: PostgresPolicy
|
||||
selectedPolicy?: PGPolicy
|
||||
selectedTemplate?: string
|
||||
onSelectTemplate: (template: any) => void
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
import { ident, joinSqlFragments, safeSql, type SafeSqlFragment } from '@supabase/pg-meta'
|
||||
import { PostgresPolicy } from '@supabase/postgres-meta'
|
||||
import type { PGPolicy } from '@supabase/pg-meta'
|
||||
|
||||
import type { TableApiAccessData } from '@/data/privileges/table-api-access-query'
|
||||
|
||||
export type Policy = Omit<PostgresPolicy, 'definition' | 'check'> & {
|
||||
export type Policy = Omit<PGPolicy, 'definition' | 'check'> & {
|
||||
definition: SafeSqlFragment | null
|
||||
check: SafeSqlFragment | null
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { keyword } from '@supabase/pg-meta'
|
||||
import { PGTriggerCreate } from '@supabase/pg-meta/src/pg-meta-triggers'
|
||||
import type { PostgresTrigger } from '@supabase/postgres-meta'
|
||||
import type { PGTrigger, PGTriggerCreate } from '@supabase/pg-meta'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import { useParams } from 'common'
|
||||
import { parseAsBoolean, parseAsString, useQueryState } from 'nuqs'
|
||||
@@ -37,7 +36,7 @@ export const isEdgeFunction = ({
|
||||
|
||||
const FORM_ID = 'edit-hook-panel-form'
|
||||
|
||||
const parseHeaders = (selectedHook?: PostgresTrigger): HTTPArgument[] => {
|
||||
const parseHeaders = (selectedHook?: PGTrigger): HTTPArgument[] => {
|
||||
if (typeof selectedHook === 'undefined') {
|
||||
return [{ id: uuidv4(), name: 'Content-type', value: 'application/json' }]
|
||||
}
|
||||
@@ -57,7 +56,7 @@ const parseHeaders = (selectedHook?: PostgresTrigger): HTTPArgument[] => {
|
||||
}))
|
||||
}
|
||||
|
||||
const parseParameters = (selectedHook?: PostgresTrigger): HTTPArgument[] => {
|
||||
const parseParameters = (selectedHook?: PGTrigger): HTTPArgument[] => {
|
||||
if (typeof selectedHook === 'undefined') {
|
||||
return [{ id: uuidv4(), name: '', value: '' }]
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { PostgresTrigger } from '@supabase/postgres-meta'
|
||||
import type { PGTrigger } from '@supabase/pg-meta'
|
||||
import { PermissionAction } from '@supabase/shared-types/out/constants'
|
||||
import { useParams } from 'common'
|
||||
import Image from 'next/legacy/image'
|
||||
@@ -42,7 +42,7 @@ import { uuidv4 } from '@/lib/helpers'
|
||||
|
||||
export interface FormContentsProps {
|
||||
form: UseFormReturn<WebhookFormValues>
|
||||
selectedHook?: PostgresTrigger
|
||||
selectedHook?: PGTrigger
|
||||
}
|
||||
|
||||
export const FormContents = ({ form, selectedHook }: FormContentsProps) => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { PostgresPublication, PostgresTable } from '@supabase/postgres-meta'
|
||||
import type { PGPublication, PGTable } from '@supabase/pg-meta'
|
||||
import { PermissionAction } from '@supabase/shared-types/out/constants'
|
||||
import { useState } from 'react'
|
||||
import { toast } from 'sonner'
|
||||
@@ -10,8 +10,8 @@ import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
||||
import { useProtectedSchemas } from '@/hooks/useProtectedSchemas'
|
||||
|
||||
interface PublicationsTableItemProps {
|
||||
table: PostgresTable
|
||||
selectedPublication: PostgresPublication
|
||||
table: PGTable
|
||||
selectedPublication: PGPublication
|
||||
}
|
||||
|
||||
export const PublicationsTableItem = ({
|
||||
@@ -35,10 +35,7 @@ export const PublicationsTableItem = ({
|
||||
|
||||
const { mutate: updatePublications, isPending } = useDatabasePublicationUpdateMutation()
|
||||
|
||||
const toggleReplicationForTable = async (
|
||||
table: PostgresTable,
|
||||
publication: PostgresPublication
|
||||
) => {
|
||||
const toggleReplicationForTable = async (table: PGTable, publication: PGPublication) => {
|
||||
if (project === undefined) return console.error('Project is required')
|
||||
|
||||
const originalChecked = checked
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { PostgresSchema, PostgresTable } from '@supabase/postgres-meta'
|
||||
import type { PGSchema, PGTable } from '@supabase/pg-meta'
|
||||
import { PermissionAction } from '@supabase/shared-types/out/constants'
|
||||
import {
|
||||
Background,
|
||||
@@ -75,7 +75,7 @@ export const SchemaGraph = () => {
|
||||
const { resolvedTheme } = useTheme()
|
||||
const { data: project } = useSelectedProjectQuery()
|
||||
const { selectedSchema, setSelectedSchema } = useQuerySchemaState()
|
||||
const [selectedTable, setSelectedTable] = useState<PostgresTable | null>(null)
|
||||
const [selectedTable, setSelectedTable] = useState<PGTable | null>(null)
|
||||
const snap = useTableEditorStateSnapshot()
|
||||
const { isDownloading, exportSchemaToImage } = useExportSchemaToImage()
|
||||
|
||||
@@ -241,7 +241,7 @@ export const SchemaGraph = () => {
|
||||
const isFirstLoad = useRef(true)
|
||||
useEffect(() => {
|
||||
if (isSuccessTables && isSuccessSchemas && tables.length > 0) {
|
||||
const schema = schemas.find((s) => s.name === selectedSchema) as PostgresSchema
|
||||
const schema = schemas.find((s) => s.name === selectedSchema) as PGSchema
|
||||
getGraphDataFromTables(ref as string, schema, tables).then(({ nodes, edges }) => {
|
||||
reactFlowInstance.setNodes(nodes)
|
||||
reactFlowInstance.setEdges(edges)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import dagre from '@dagrejs/dagre'
|
||||
import type { PostgresSchema, PostgresTable } from '@supabase/postgres-meta'
|
||||
import type { PGSchema, PGTable } from '@supabase/pg-meta'
|
||||
import { Edge, Node, Position } from '@xyflow/react'
|
||||
import { uniqBy } from 'lodash'
|
||||
|
||||
@@ -16,8 +16,8 @@ const RANK_SEP = 50
|
||||
|
||||
export async function getGraphDataFromTables(
|
||||
ref?: string,
|
||||
schema?: PostgresSchema,
|
||||
tables?: PostgresTable[]
|
||||
schema?: PGSchema,
|
||||
tables?: PGTable[]
|
||||
): Promise<{
|
||||
nodes: Node<TableNodeData>[]
|
||||
edges: Edge[]
|
||||
@@ -166,7 +166,7 @@ export async function getGraphDataFromTables(
|
||||
}
|
||||
|
||||
function findTablesHandleIds(
|
||||
tables: PostgresTable[],
|
||||
tables: PGTable[],
|
||||
table_name: string,
|
||||
column_name: string
|
||||
): [string?, string?] {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PostgresColumn } from '@supabase/postgres-meta'
|
||||
import type { PGColumn } from '@supabase/pg-meta'
|
||||
import { PermissionAction } from '@supabase/shared-types/out/constants'
|
||||
import { useParams } from 'common'
|
||||
import { noop } from 'lodash'
|
||||
@@ -58,7 +58,7 @@ import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
|
||||
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
||||
import { useIsProtectedSchema } from '@/hooks/useProtectedSchemas'
|
||||
|
||||
const getColumnTypeAffordancePresentation = (column: PostgresColumn) => {
|
||||
const getColumnTypeAffordancePresentation = (column: PGColumn) => {
|
||||
const { kind, label } = getColumnTypeAffordance(column.format)
|
||||
const iconClassName = 'text-foreground-muted'
|
||||
|
||||
@@ -98,8 +98,8 @@ const getColumnTypeAffordancePresentation = (column: PostgresColumn) => {
|
||||
|
||||
interface ColumnListProps {
|
||||
onAddColumn: () => void
|
||||
onEditColumn: (column: PostgresColumn) => void
|
||||
onDeleteColumn: (column: PostgresColumn) => void
|
||||
onEditColumn: (column: PGColumn) => void
|
||||
onDeleteColumn: (column: PGColumn) => void
|
||||
}
|
||||
|
||||
export const ColumnList = ({
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { PostgresTable } from '@supabase/postgres-meta'
|
||||
import type { PGTable } from '@supabase/pg-meta'
|
||||
import { PermissionAction } from '@supabase/shared-types/out/constants'
|
||||
import { useParams } from 'common'
|
||||
import { noop } from 'lodash'
|
||||
@@ -60,9 +60,9 @@ import { useShortcut } from '@/state/shortcuts/useShortcut'
|
||||
|
||||
interface TableListProps {
|
||||
onAddTable: () => void
|
||||
onEditTable: (table: PostgresTable) => void
|
||||
onDeleteTable: (table: PostgresTable) => void
|
||||
onDuplicateTable: (table: PostgresTable) => void
|
||||
onEditTable: (table: PGTable) => void
|
||||
onDeleteTable: (table: PGTable) => void
|
||||
onDuplicateTable: (table: PGTable) => void
|
||||
}
|
||||
|
||||
export const TableList = ({
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { PostgresMaterializedView, PostgresTable, PostgresView } from '@supabase/postgres-meta'
|
||||
import { PostgresForeignTable } from '@supabase/postgres-meta/dist/lib/types'
|
||||
import type { PGForeignTable, PGMaterializedView, PGTable, PGView } from '@supabase/pg-meta'
|
||||
|
||||
import { ENTITY_TYPE } from '@/data/entity-types/entity-type-constants'
|
||||
|
||||
@@ -11,10 +10,10 @@ export const formatAllEntities = ({
|
||||
materializedViews = [],
|
||||
foreignTables = [],
|
||||
}: {
|
||||
tables?: PostgresTable[]
|
||||
views?: PostgresView[]
|
||||
materializedViews?: PostgresMaterializedView[]
|
||||
foreignTables?: PostgresForeignTable[]
|
||||
tables?: PGTable[]
|
||||
views?: PGView[]
|
||||
materializedViews?: PGMaterializedView[]
|
||||
foreignTables?: PGForeignTable[]
|
||||
}) => {
|
||||
const formattedTables = tables.map((x) => {
|
||||
return {
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import type { PostgresTrigger } from '@supabase/postgres-meta'
|
||||
import type { PGTrigger } from '@supabase/pg-meta'
|
||||
|
||||
import { TextConfirmModal } from '@/components/ui/TextConfirmModalWrapper'
|
||||
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
||||
|
||||
interface DeleteTriggerProps {
|
||||
trigger?: PostgresTrigger
|
||||
trigger?: PGTrigger
|
||||
visible: boolean
|
||||
setVisible: (value: string | null) => void
|
||||
onDelete: (params: {
|
||||
projectRef: string
|
||||
connectionString?: string | null
|
||||
trigger: PostgresTrigger
|
||||
trigger: PGTrigger
|
||||
}) => void
|
||||
isLoading: boolean
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { PostgresTrigger } from '@supabase/postgres-meta'
|
||||
import type { PGTrigger } from '@supabase/pg-meta'
|
||||
import { Terminal } from 'lucide-react'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { SubmitHandler, useForm } from 'react-hook-form'
|
||||
@@ -76,7 +76,7 @@ const defaultValues: z.infer<typeof FormSchema> = {
|
||||
}
|
||||
|
||||
interface TriggerSheetProps {
|
||||
selectedTrigger?: PostgresTrigger
|
||||
selectedTrigger?: PGTrigger
|
||||
isDuplicatingTrigger?: boolean
|
||||
open: boolean
|
||||
onClose: () => void
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
import type { PostgresColumn, PostgresTable } from '@supabase/postgres-meta'
|
||||
import type { PGColumn, PGTable } from '@supabase/pg-meta'
|
||||
import { useParams } from 'common'
|
||||
import { isEmpty, noop } from 'lodash'
|
||||
import { ExternalLink, Plus } from 'lucide-react'
|
||||
@@ -65,8 +65,8 @@ import { useProtectedSchemas } from '@/hooks/useProtectedSchemas'
|
||||
import { DOCS_URL } from '@/lib/constants'
|
||||
|
||||
export interface ColumnEditorProps {
|
||||
column?: Readonly<PostgresColumn>
|
||||
selectedTable: PostgresTable
|
||||
column?: Readonly<PGColumn>
|
||||
selectedTable: PGTable
|
||||
visible: boolean
|
||||
closePanel: () => void
|
||||
saveChanges: (
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
import { FOREIGN_KEY_CASCADE_ACTION } from '@supabase/pg-meta'
|
||||
import type { PostgresColumn } from '@supabase/postgres-meta'
|
||||
import type { PGColumn } from '@supabase/pg-meta'
|
||||
import { isNull } from 'lodash'
|
||||
import { toast } from 'sonner'
|
||||
|
||||
@@ -57,7 +57,7 @@ export const generateColumnField = (
|
||||
}
|
||||
|
||||
export const generateColumnFieldFromPostgresColumn = (
|
||||
column: PostgresColumn,
|
||||
column: PGColumn,
|
||||
table: RetrieveTableResult,
|
||||
foreignKeys: ForeignKeyConstraint[]
|
||||
): ColumnField => {
|
||||
@@ -213,7 +213,7 @@ export const getForeignKeyUIState = (
|
||||
}
|
||||
|
||||
export const getColumnForeignKey = (
|
||||
column: PostgresColumn,
|
||||
column: PGColumn,
|
||||
table: RetrieveTableResult,
|
||||
foreignKeys: ForeignKeyConstraint[]
|
||||
) => {
|
||||
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
import type { PostgresColumn, PostgresTable } from '@supabase/postgres-meta'
|
||||
import type { PGColumn, PGTable } from '@supabase/pg-meta'
|
||||
|
||||
interface Props {
|
||||
table: PostgresTable
|
||||
column?: PostgresColumn
|
||||
table: PGTable
|
||||
column?: PGColumn
|
||||
}
|
||||
|
||||
export const HeaderTitle = ({ table, column }: Props) => {
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import { FOREIGN_KEY_CASCADE_ACTION } from '@supabase/pg-meta'
|
||||
import type { PostgresTable } from '@supabase/postgres-meta'
|
||||
import type { PGTable } from '@supabase/pg-meta'
|
||||
import { sortBy } from 'lodash'
|
||||
import { ArrowRight, HelpCircle, Loader2, X } from 'lucide-react'
|
||||
import { Fragment, useEffect, useState } from 'react'
|
||||
@@ -90,7 +90,7 @@ export const ForeignKeySelector = ({
|
||||
includeColumns: false,
|
||||
})
|
||||
|
||||
const { data: selectedTable, isLoading: isLoadingSelectedTable } = useTableQuery<PostgresTable>(
|
||||
const { data: selectedTable, isLoading: isLoadingSelectedTable } = useTableQuery<PGTable>(
|
||||
{
|
||||
projectRef: project?.ref,
|
||||
connectionString: project?.connectionString,
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
import type { PostgresTable } from '@supabase/postgres-meta'
|
||||
import type { PGTable } from '@supabase/pg-meta'
|
||||
import { isEmpty, noop, partition } from 'lodash'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { Label_Shadcn_, SidePanel, Switch } from 'ui'
|
||||
@@ -25,7 +25,7 @@ import type { Dictionary } from '@/types'
|
||||
|
||||
export interface RowEditorProps {
|
||||
row?: Dictionary<any>
|
||||
selectedTable: PostgresTable
|
||||
selectedTable: PGTable
|
||||
visible: boolean
|
||||
editable?: boolean
|
||||
closePanel: () => void
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
import type { PostgresRelationship } from '@supabase/postgres-meta'
|
||||
import type { PGTableRelationship } from '@supabase/pg-meta'
|
||||
|
||||
export interface EditValue {
|
||||
row?: any
|
||||
@@ -14,7 +14,7 @@ export interface RowField {
|
||||
enums: string[]
|
||||
value: string | null | undefined
|
||||
defaultValue: string | null
|
||||
foreignKey?: PostgresRelationship
|
||||
foreignKey?: PGTableRelationship
|
||||
isNullable: boolean
|
||||
isIdentity: boolean
|
||||
isPrimaryKey: boolean
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
import type { PGColumn, PGTable, PGTableRelationship } from '@supabase/pg-meta'
|
||||
import { MAX_ARRAY_SIZE, MAX_CHARACTERS } from '@supabase/pg-meta/src/query/table-row-query'
|
||||
import type { PostgresColumn, PostgresRelationship, PostgresTable } from '@supabase/postgres-meta'
|
||||
import dayjs from 'dayjs'
|
||||
import { compact, isEqual, isString, isUndefined, omitBy } from 'lodash'
|
||||
|
||||
@@ -15,7 +15,7 @@ import type { RowField } from './RowEditor.types'
|
||||
import { minifyJSON, tryParseJson } from '@/lib/helpers'
|
||||
import type { Dictionary } from '@/types'
|
||||
|
||||
const getRowValue = ({ column, row }: { column: PostgresColumn; row?: Dictionary<any> }) => {
|
||||
const getRowValue = ({ column, row }: { column: PGColumn; row?: Dictionary<any> }) => {
|
||||
const isNewRow = row === undefined
|
||||
|
||||
if (isNewRow) {
|
||||
@@ -43,7 +43,7 @@ const getRowValue = ({ column, row }: { column: PostgresColumn; row?: Dictionary
|
||||
|
||||
export const generateRowFields = (
|
||||
row: Dictionary<any> | undefined,
|
||||
table: PostgresTable,
|
||||
table: PGTable,
|
||||
foreignKeys: ForeignKey[]
|
||||
): RowField[] => {
|
||||
const { primary_keys = [] } = table
|
||||
@@ -69,7 +69,7 @@ export const generateRowFields = (
|
||||
target_table_name: foreignKey.table,
|
||||
target_column_name:
|
||||
foreignKey.columns.find((c) => c.source === column.name)?.target ?? '',
|
||||
} as PostgresRelationship)
|
||||
} as PGTableRelationship)
|
||||
: undefined,
|
||||
id: column.id,
|
||||
name: column.name,
|
||||
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
import * as Sentry from '@sentry/nextjs'
|
||||
import type { PostgresColumn, PostgresTable } from '@supabase/postgres-meta'
|
||||
import type { PGColumn, PGTable } from '@supabase/pg-meta'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import { useParams } from 'common'
|
||||
import { isEmpty, isUndefined, noop } from 'lodash'
|
||||
@@ -140,7 +140,7 @@ const createTableApiAccessHandlerParams = ({
|
||||
selectedTable,
|
||||
}: {
|
||||
snap: DeepReadonly<TableEditorState>
|
||||
selectedTable?: PostgresTable
|
||||
selectedTable?: PGTable
|
||||
}): TableApiAccessParams | undefined => {
|
||||
const tableSidePanel = snap.sidePanel?.type === 'table' ? snap.sidePanel : undefined
|
||||
if (!tableSidePanel) return undefined
|
||||
@@ -170,7 +170,7 @@ const createTableApiAccessHandlerParams = ({
|
||||
|
||||
export interface SidePanelEditorProps {
|
||||
editable?: boolean
|
||||
selectedTable?: PostgresTable
|
||||
selectedTable?: PGTable
|
||||
includeColumns?: boolean // This is mainly used for invalidating useTablesQuery
|
||||
|
||||
// Because the panel is shared between grid editor and database pages
|
||||
@@ -396,7 +396,7 @@ export const SidePanelEditor = ({
|
||||
: await updateColumn({
|
||||
projectRef: project?.ref!,
|
||||
connectionString: project?.connectionString,
|
||||
originalColumn: selectedColumnToEdit as PostgresColumn,
|
||||
originalColumn: selectedColumnToEdit as PGColumn,
|
||||
payload: payload as UpdateColumnPayload,
|
||||
selectedTable,
|
||||
primaryKey,
|
||||
@@ -924,7 +924,7 @@ export const SidePanelEditor = ({
|
||||
<ColumnEditor
|
||||
column={
|
||||
snap.sidePanel?.type === 'column'
|
||||
? (snap.sidePanel.column as unknown as PostgresColumn)
|
||||
? (snap.sidePanel.column as unknown as PGColumn)
|
||||
: undefined
|
||||
}
|
||||
selectedTable={selectedTable}
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
import type { PostgresRelationship } from '@supabase/postgres-meta'
|
||||
import type { PGTableRelationship } from '@supabase/pg-meta'
|
||||
|
||||
import { CreateColumnBody } from '@/data/database-columns/database-column-create-mutation'
|
||||
import { UpdateColumnBody } from '@/data/database-columns/database-column-update-mutation'
|
||||
@@ -36,7 +36,7 @@ export interface Field {
|
||||
foreignKey?: { table: string; column: string }
|
||||
}
|
||||
|
||||
export interface ExtendedPostgresRelationship extends PostgresRelationship {
|
||||
export interface ExtendedPostgresRelationship extends PGTableRelationship {
|
||||
deletion_action: string
|
||||
update_action: string
|
||||
}
|
||||
|
||||
+2
-2
@@ -11,8 +11,8 @@ import pgMeta, {
|
||||
getUpdateIdentitySequenceSQL,
|
||||
type ForeignKey,
|
||||
} from '@supabase/pg-meta'
|
||||
import type { PGTablePrimaryKey } from '@supabase/pg-meta'
|
||||
import { Query } from '@supabase/pg-meta/src/query'
|
||||
import type { PostgresPrimaryKey } from '@supabase/postgres-meta'
|
||||
import { chunk, find, isEmpty, isEqual } from 'lodash'
|
||||
import Papa from 'papaparse'
|
||||
import { toast } from 'sonner'
|
||||
@@ -788,7 +788,7 @@ export const updateTable = async ({
|
||||
const primaryKeyColumns = columns
|
||||
.filter((column) => column.isPrimaryKey)
|
||||
.map((column) => column.name)
|
||||
const existingPrimaryKeyColumns = table.primary_keys.map((pk: PostgresPrimaryKey) => pk.name)
|
||||
const existingPrimaryKeyColumns = table.primary_keys.map((pk: PGTablePrimaryKey) => pk.name)
|
||||
const isPrimaryKeyUpdated = !isEqual(primaryKeyColumns, existingPrimaryKeyColumns)
|
||||
|
||||
if (isPrimaryKeyUpdated) {
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
import type { PostgresTable } from '@supabase/postgres-meta'
|
||||
import type { PGTable } from '@supabase/pg-meta'
|
||||
import { useParams } from 'common'
|
||||
import { noop } from 'lodash'
|
||||
import { useCallback, type ChangeEvent, type DragEvent } from 'react'
|
||||
@@ -25,7 +25,7 @@ import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganizati
|
||||
|
||||
interface SpreadsheetImportProps {
|
||||
visible: boolean
|
||||
selectedTable?: PostgresTable
|
||||
selectedTable?: PGTable
|
||||
saveContent: (prefillData: ImportContent) => void
|
||||
closePanel: () => void
|
||||
updateEditorDirty?: (value: boolean) => void
|
||||
|
||||
+5
-5
@@ -1,4 +1,4 @@
|
||||
import type { PostgresTable } from '@supabase/postgres-meta'
|
||||
import type { PGTable } from '@supabase/pg-meta'
|
||||
import { isEmpty, noop } from 'lodash'
|
||||
import { useContext, useEffect, useMemo, useState } from 'react'
|
||||
import { toast } from 'sonner'
|
||||
@@ -23,7 +23,7 @@ import type { ImportContent, TableField } from './TableEditor.types'
|
||||
import {
|
||||
formatImportedContentToColumnFields,
|
||||
generateTableField,
|
||||
generateTableFieldFromPostgresTable,
|
||||
generateTableFieldFromPGTable,
|
||||
validateFields,
|
||||
} from './TableEditor.utils'
|
||||
import { DocsButton } from '@/components/ui/DocsButton'
|
||||
@@ -53,7 +53,7 @@ type SaveTablePayloadFor<Action extends SaveTableParams['action']> =
|
||||
SaveTableParamsFor<Action>['payload']
|
||||
|
||||
export interface TableEditorProps {
|
||||
table?: PostgresTable
|
||||
table?: PGTable
|
||||
isDuplicating: boolean
|
||||
templateData?: Partial<TableField>
|
||||
visible: boolean
|
||||
@@ -281,7 +281,7 @@ export const TableEditor = ({
|
||||
}
|
||||
setFkRelations([])
|
||||
} else {
|
||||
const tableFields = generateTableFieldFromPostgresTable(
|
||||
const tableFields = generateTableFieldFromPGTable(
|
||||
table,
|
||||
foreignKeyMeta ?? [],
|
||||
isDuplicating,
|
||||
@@ -303,7 +303,7 @@ export const TableEditor = ({
|
||||
|
||||
useEffect(() => {
|
||||
if (!isNewRecord) {
|
||||
const tableFields = generateTableFieldFromPostgresTable(
|
||||
const tableFields = generateTableFieldFromPGTable(
|
||||
table,
|
||||
foreignKeyMeta ?? [],
|
||||
isDuplicating,
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
import type { PostgresTable } from '@supabase/postgres-meta'
|
||||
import type { PGTable } from '@supabase/pg-meta'
|
||||
import { some } from 'lodash'
|
||||
|
||||
import {
|
||||
@@ -40,8 +40,8 @@ export const generateTableField = (): TableField => {
|
||||
}
|
||||
}
|
||||
|
||||
export const generateTableFieldFromPostgresTable = (
|
||||
table: PostgresTable,
|
||||
export const generateTableFieldFromPGTable = (
|
||||
table: PGTable,
|
||||
foreignKeys: ForeignKeyConstraint[],
|
||||
isDuplicating = false,
|
||||
isRealtimeEnabled = false
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type PostgresColumn } from '@supabase/postgres-meta'
|
||||
import type { PGColumn } from '@supabase/pg-meta'
|
||||
import { PermissionAction } from '@supabase/shared-types/out/constants'
|
||||
import { useParams } from 'common'
|
||||
import { AlertTriangle, Code, Loader2, Table2 } from 'lucide-react'
|
||||
@@ -350,7 +350,7 @@ function TableSelector() {
|
||||
)
|
||||
}
|
||||
|
||||
function generateSelectStatement(table: TablesData[number] & { columns?: Array<PostgresColumn> }) {
|
||||
function generateSelectStatement(table: TablesData[number] & { columns?: Array<PGColumn> }) {
|
||||
return `
|
||||
select ${
|
||||
!table.columns
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { getDatabaseTriggerUpdateSQL, type SafeSqlFragment } from '@supabase/pg-meta'
|
||||
import { PGTrigger, PGTriggerCreate } from '@supabase/pg-meta/src/pg-meta-triggers'
|
||||
import { PostgresTrigger } from '@supabase/postgres-meta'
|
||||
import {
|
||||
getDatabaseTriggerUpdateSQL,
|
||||
type PGTrigger,
|
||||
type PGTriggerCreate,
|
||||
type SafeSqlFragment,
|
||||
} from '@supabase/pg-meta'
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import { toast } from 'sonner'
|
||||
|
||||
@@ -15,7 +18,7 @@ import type { ResponseError, UseCustomMutationOptions } from '@/types'
|
||||
export type DatabaseTriggerUpdateVariables = {
|
||||
projectRef: string
|
||||
connectionString?: string | null
|
||||
originalTrigger: PostgresTrigger
|
||||
originalTrigger: PGTrigger
|
||||
updatedTrigger: Omit<PGTriggerCreate, 'events'> &
|
||||
Pick<PGTrigger, 'enabled_mode'> & { events: Array<SafeSqlFragment> }
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import pgMeta from '@supabase/pg-meta'
|
||||
import { PostgresView } from '@supabase/postgres-meta'
|
||||
import type { PGForeignTable } from '@supabase/pg-meta'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
|
||||
import { foreignTableKeys } from './keys'
|
||||
@@ -26,7 +26,7 @@ export async function getForeignTables(
|
||||
signal
|
||||
)
|
||||
|
||||
return result as PostgresView[]
|
||||
return result as PGForeignTable[]
|
||||
}
|
||||
|
||||
export type ForeignTablesData = Awaited<ReturnType<typeof getForeignTables>>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { PGMaterializedView } from '@supabase/pg-meta'
|
||||
import { DEFAULT_PLATFORM_APPLICATION_NAME } from '@supabase/pg-meta/src/constants'
|
||||
import { PostgresMaterializedView } from '@supabase/postgres-meta'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
|
||||
import { materializedViewKeys } from './keys'
|
||||
@@ -38,7 +38,7 @@ export async function getMaterializedViews(
|
||||
})
|
||||
|
||||
if (error) handleError(error)
|
||||
return data as PostgresMaterializedView[]
|
||||
return data as PGMaterializedView[]
|
||||
}
|
||||
|
||||
export type MaterializedViewsData = Awaited<ReturnType<typeof getMaterializedViews>>
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import type {
|
||||
PostgresColumn,
|
||||
PostgresMaterializedView,
|
||||
PostgresRelationship,
|
||||
PostgresTable,
|
||||
PostgresView,
|
||||
} from '@supabase/postgres-meta'
|
||||
PGColumn,
|
||||
PGMaterializedView,
|
||||
PGTable,
|
||||
PGTableRelationship,
|
||||
PGView,
|
||||
} from '@supabase/pg-meta'
|
||||
|
||||
import { WRAPPER_HANDLERS } from '@/components/interfaces/Integrations/Wrappers/Wrappers.constants'
|
||||
import { ENTITY_TYPE } from '@/data/entity-types/entity-type-constants'
|
||||
|
||||
interface TableRelationship extends PostgresRelationship {
|
||||
interface TableRelationship extends PGTableRelationship {
|
||||
deletion_action: 'a' | 'r' | 'c' | 'n' | 'd'
|
||||
update_action: 'a' | 'r' | 'c' | 'n' | 'd'
|
||||
}
|
||||
@@ -21,28 +21,28 @@ interface TableUniqueIndex {
|
||||
columns: string[]
|
||||
}
|
||||
|
||||
export interface Table extends PostgresTable {
|
||||
export interface Table extends PGTable {
|
||||
entity_type: ENTITY_TYPE.TABLE
|
||||
columns: PostgresColumn[]
|
||||
columns: PGColumn[]
|
||||
relationships: TableRelationship[]
|
||||
unique_indexes?: TableUniqueIndex[]
|
||||
}
|
||||
|
||||
export interface PartitionedTable extends PostgresTable {
|
||||
export interface PartitionedTable extends PGTable {
|
||||
entity_type: ENTITY_TYPE.PARTITIONED_TABLE
|
||||
columns: PostgresColumn[]
|
||||
columns: PGColumn[]
|
||||
relationships: TableRelationship[]
|
||||
unique_indexes?: TableUniqueIndex[]
|
||||
}
|
||||
|
||||
export interface View extends PostgresView {
|
||||
export interface View extends PGView {
|
||||
entity_type: ENTITY_TYPE.VIEW
|
||||
columns: PostgresColumn[]
|
||||
columns: PGColumn[]
|
||||
}
|
||||
|
||||
export interface MaterializedView extends PostgresMaterializedView {
|
||||
export interface MaterializedView extends PGMaterializedView {
|
||||
entity_type: ENTITY_TYPE.MATERIALIZED_VIEW
|
||||
columns: PostgresColumn[]
|
||||
columns: PGColumn[]
|
||||
}
|
||||
|
||||
export interface ForeignTable {
|
||||
@@ -54,7 +54,7 @@ export interface ForeignTable {
|
||||
foreign_server_name: string
|
||||
foreign_data_wrapper_name: string
|
||||
foreign_data_wrapper_handler: string
|
||||
columns: PostgresColumn[]
|
||||
columns: PGColumn[]
|
||||
}
|
||||
|
||||
export type Entity = Table | PartitionedTable | View | MaterializedView | ForeignTable
|
||||
@@ -100,7 +100,7 @@ export function isViewLike(entity?: Entity): entity is View | MaterializedView {
|
||||
return isView(entity) || isMaterializedView(entity)
|
||||
}
|
||||
|
||||
export function postgresTableToEntity(table: PostgresTable): Entity | undefined {
|
||||
export function postgresTableToEntity(table: PGTable): Entity | undefined {
|
||||
if (table.columns === undefined || table.relationships === undefined) {
|
||||
console.error(
|
||||
'Unable to convert PostgresTable to Entity type: columns and relationships must not be undefined.'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { PGTable } from '@supabase/pg-meta'
|
||||
import { DEFAULT_PLATFORM_APPLICATION_NAME } from '@supabase/pg-meta/src/constants'
|
||||
import type { PostgresTable } from '@supabase/postgres-meta'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { sortBy } from 'lodash'
|
||||
import { useCallback } from 'react'
|
||||
@@ -16,7 +16,7 @@ export type TablesVariables = {
|
||||
* Defaults to false
|
||||
*/
|
||||
includeColumns?: boolean
|
||||
sortByProperty?: keyof PostgresTable
|
||||
sortByProperty?: keyof PGTable
|
||||
}
|
||||
|
||||
export async function getTables(
|
||||
@@ -61,10 +61,10 @@ export async function getTables(
|
||||
|
||||
// Sort the data if the sortByName option is true
|
||||
if (Array.isArray(data) && sortByProperty) {
|
||||
return sortBy(data, (t) => t[sortByProperty]) as PostgresTable[]
|
||||
return sortBy(data, (t) => t[sortByProperty]) as PGTable[]
|
||||
}
|
||||
|
||||
return data as PostgresTable[]
|
||||
return data as PGTable[]
|
||||
}
|
||||
|
||||
export type TablesData = Awaited<ReturnType<typeof getTables>>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { PGView } from '@supabase/pg-meta'
|
||||
import { DEFAULT_PLATFORM_APPLICATION_NAME } from '@supabase/pg-meta/src/constants'
|
||||
import { PostgresView } from '@supabase/postgres-meta'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
|
||||
import { viewKeys } from './keys'
|
||||
@@ -37,7 +37,7 @@ export async function getViews(
|
||||
})
|
||||
|
||||
if (error) handleError(error)
|
||||
return data as PostgresView[]
|
||||
return data as PGView[]
|
||||
}
|
||||
|
||||
export type ViewsData = Awaited<ReturnType<typeof getViews>>
|
||||
|
||||
@@ -151,7 +151,6 @@
|
||||
"@graphql-typed-document-node/core": "^3.2.0",
|
||||
"@radix-ui/react-use-escape-keydown": "^1.1.1",
|
||||
"@smithy/property-provider": "^4.0.4",
|
||||
"@supabase/postgres-meta": "^0.64.4",
|
||||
"@testing-library/dom": "^10.0.0",
|
||||
"@testing-library/jest-dom": "^6.6.0",
|
||||
"@testing-library/react": "^16.0.0",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ident, safeSql } from '@supabase/pg-meta'
|
||||
import type { PostgresTable } from '@supabase/postgres-meta'
|
||||
import type { PGTable } from '@supabase/pg-meta'
|
||||
import { PermissionAction } from '@supabase/shared-types/out/constants'
|
||||
import { LOCAL_STORAGE_KEYS, useParams } from 'common'
|
||||
import { Search, X } from 'lucide-react'
|
||||
@@ -66,11 +66,7 @@ import type { NextPageWithLayout } from '@/types'
|
||||
*
|
||||
* @returns list of table
|
||||
*/
|
||||
const getTableFilterState = (
|
||||
tables: PostgresTable[],
|
||||
policies: Array<Policy>,
|
||||
searchString?: string
|
||||
) => {
|
||||
const getTableFilterState = (tables: PGTable[], policies: Array<Policy>, searchString?: string) => {
|
||||
const sortedTables = tables.slice().sort((a, b) => a.name.localeCompare(b.name))
|
||||
const visibleTableIds = new Set<number>()
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PostgresTable } from '@supabase/postgres-meta'
|
||||
import type { PGTable } from '@supabase/pg-meta'
|
||||
import { LOCAL_STORAGE_KEYS, useParams } from 'common'
|
||||
import { useState } from 'react'
|
||||
import { PageContainer } from 'ui-patterns/PageContainer'
|
||||
@@ -71,7 +71,7 @@ const DatabaseTables: NextPageWithLayout = () => {
|
||||
</TableEditorTableStateContextProvider>
|
||||
)}
|
||||
|
||||
<SidePanelEditor includeColumns selectedTable={selectedTableToEdit as PostgresTable} />
|
||||
<SidePanelEditor includeColumns selectedTable={selectedTableToEdit as PGTable} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as Sentry from '@sentry/nextjs'
|
||||
import type { PostgresColumn } from '@supabase/postgres-meta'
|
||||
import type { PGColumn } from '@supabase/pg-meta'
|
||||
import { useConstant } from 'common'
|
||||
import { createContext, PropsWithChildren, useContext } from 'react'
|
||||
import { proxy, useSnapshot } from 'valtio'
|
||||
@@ -27,13 +27,13 @@ export const TABLE_EDITOR_DEFAULT_ROWS_PER_PAGE = 100
|
||||
type ForeignKeyState = {
|
||||
foreignKey: ForeignKey
|
||||
row: Dictionary<any>
|
||||
column: PostgresColumn
|
||||
column: PGColumn
|
||||
}
|
||||
|
||||
export type SidePanel =
|
||||
| { type: 'cell'; value?: { column: string; row: Dictionary<any> } }
|
||||
| { type: 'row'; row?: Dictionary<any> }
|
||||
| { type: 'column'; column?: PostgresColumn }
|
||||
| { type: 'column'; column?: PGColumn }
|
||||
| { type: 'table'; mode: 'new' | 'edit' | 'duplicate'; templateData?: Partial<TableField> }
|
||||
| { type: 'schema'; mode: 'new' | 'edit' }
|
||||
| { type: 'json'; jsonValue: EditValue }
|
||||
@@ -46,7 +46,7 @@ export type SidePanel =
|
||||
|
||||
export type ConfirmationDialog =
|
||||
| { type: 'table'; isDeleteWithCascade: boolean }
|
||||
| { type: 'column'; column: PostgresColumn; isDeleteWithCascade: boolean }
|
||||
| { type: 'column'; column: PGColumn; isDeleteWithCascade: boolean }
|
||||
// [Joshen] Just FYI callback, numRows, allRowsSelected is a temp workaround so that
|
||||
// DeleteConfirmationDialog can trigger dispatch methods after the successful deletion of rows.
|
||||
// Once we deprecate react tracked and move things to valtio, we can remove this.
|
||||
@@ -142,13 +142,13 @@ export const createTableEditorState = () => {
|
||||
sidePanel: { type: 'column' },
|
||||
}
|
||||
},
|
||||
onEditColumn: (column: PostgresColumn) => {
|
||||
onEditColumn: (column: PGColumn) => {
|
||||
state.ui = {
|
||||
open: 'side-panel',
|
||||
sidePanel: { type: 'column', column },
|
||||
}
|
||||
},
|
||||
onDeleteColumn: (column: PostgresColumn) => {
|
||||
onDeleteColumn: (column: PGColumn) => {
|
||||
state.ui = {
|
||||
open: 'confirmation-dialog',
|
||||
confirmationDialog: { type: 'column', column, isDeleteWithCascade: false },
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { PostgresColumn } from '@supabase/postgres-meta'
|
||||
import type { PGColumn } from '@supabase/pg-meta'
|
||||
|
||||
import { ProjectLogStatsVariables } from '@/data/analytics/project-log-stats-query'
|
||||
|
||||
@@ -41,5 +41,5 @@ export interface SchemaView {
|
||||
schema: string
|
||||
is_updatable: boolean
|
||||
comment?: string
|
||||
columns: PostgresColumn[]
|
||||
columns: PGColumn[]
|
||||
}
|
||||
@@ -45,6 +45,16 @@ export {
|
||||
} from './pg-format'
|
||||
export type { SafeSqlFragment, UntrustedSqlFragment, DisplayableSqlFragment } from './pg-format'
|
||||
|
||||
export type { PGTable, PGTablePrimaryKey, PGTableRelationship } from './pg-meta-tables'
|
||||
export type { PGColumn } from './pg-meta-columns'
|
||||
export type { PGPolicy } from './pg-meta-policies'
|
||||
export type { PGTrigger, PGTriggerCreate, PGTriggerUpdate } from './pg-meta-triggers'
|
||||
export type { PGView } from './pg-meta-views'
|
||||
export type { PGMaterializedView } from './pg-meta-materialized-views'
|
||||
export type { PGForeignTable } from './pg-meta-foreign-tables'
|
||||
export type { PGSchema } from './pg-meta-schemas'
|
||||
export type { PGPublication } from './pg-meta-publications'
|
||||
|
||||
export default {
|
||||
roles,
|
||||
columns,
|
||||
|
||||
@@ -13,6 +13,8 @@ const pgSchemaZod = z.object({
|
||||
const pgSchemaArrayZod = z.array(pgSchemaZod)
|
||||
const pgSchemaOptionalZod = z.optional(pgSchemaZod)
|
||||
|
||||
export type PGSchema = z.infer<typeof pgSchemaZod>
|
||||
|
||||
function list({
|
||||
includeSystemSchemas = false,
|
||||
limit,
|
||||
|
||||
@@ -52,6 +52,8 @@ const pgTableZod = z.object({
|
||||
const pgTableArrayZod = z.array(pgTableZod)
|
||||
|
||||
export type PGTable = z.infer<typeof pgTableZod>
|
||||
export type PGTablePrimaryKey = z.infer<typeof pgTablePrimaryKeyZod>
|
||||
export type PGTableRelationship = z.infer<typeof pgTableRelationshipZod>
|
||||
|
||||
type TableWithoutColumns = Omit<PGTable, 'columns'>
|
||||
type TableWithColumns = PGTable
|
||||
|
||||
@@ -26,8 +26,8 @@ export const pgTriggerZod = z.object({
|
||||
table: z.string(),
|
||||
schema: z.string(),
|
||||
condition: z.string().nullable(),
|
||||
orientation: z.string(),
|
||||
activation: z.string(),
|
||||
orientation: z.enum(['ROW', 'STATEMENT']),
|
||||
activation: z.enum(['BEFORE', 'AFTER', 'INSTEAD OF']),
|
||||
events: z.array(z.string()),
|
||||
function_name: z.string(),
|
||||
function_schema: z.string(),
|
||||
|
||||
Generated
-111
@@ -1209,9 +1209,6 @@ importers:
|
||||
'@smithy/property-provider':
|
||||
specifier: ^4.0.4
|
||||
version: 4.0.4
|
||||
'@supabase/postgres-meta':
|
||||
specifier: ^0.64.4
|
||||
version: 0.64.6(encoding@0.1.13)(supports-color@8.1.1)
|
||||
'@testing-library/dom':
|
||||
specifier: ^10.0.0
|
||||
version: 10.4.1
|
||||
@@ -7396,9 +7393,6 @@ packages:
|
||||
'@simple-git/argv-parser@1.1.1':
|
||||
resolution: {integrity: sha512-Q9lBcfQ+VQCpQqGJFHe5yooOS5hGdLFFbJ5R+R5aDsnkPCahtn1hSkMcORX65J2Z5lxSkD0lQorMsncuBQxYUw==}
|
||||
|
||||
'@sinclair/typebox@0.25.24':
|
||||
resolution: {integrity: sha512-XJfwUVUKDHF5ugKwIcxEgc9k8b7HbznCp6eUfWgu710hMPNIO4aw4/zB5RogDQz8nd6gyCDpU9O/m6qYEWY6yQ==}
|
||||
|
||||
'@sindresorhus/is@7.1.0':
|
||||
resolution: {integrity: sha512-7F/yz2IphV39hiS2zB4QYVkivrptHHh0K8qJJd9HhuWSdvf8AN7NpebW3CcDZDBQsUPMoDKWsY2WWgW7bqOcfA==}
|
||||
engines: {node: '>=18'}
|
||||
@@ -7645,10 +7639,6 @@ packages:
|
||||
'@supabase/phoenix@0.4.2':
|
||||
resolution: {integrity: sha512-YSAGnmDAfuleFCVt3CeurQZAhxRfXWeZIIkwp7NhYzQ1UwW6ePSnzsFAiUm/mbCkfoCf70QQHKW/K6RKh52a4A==}
|
||||
|
||||
'@supabase/postgres-meta@0.64.6':
|
||||
resolution: {integrity: sha512-vz5gc6RKNfDVnIfRUmH2ssTMYFI0U3MYOVyQ9R4YkzOS2dKSanjC4rTEDGjlMFwGTCUPW3N3pbY7HJIW81wMyg==}
|
||||
engines: {node: '>=16', npm: '>=8'}
|
||||
|
||||
'@supabase/postgrest-js@2.105.4':
|
||||
resolution: {integrity: sha512-SppIyLo/kTwIlz1qpv2HN1EQqBg0GVktrDDFsXygYROha3MgVn4rT7p5EjFHFqXQm2rdRGb/BI7bc+jr10m91w==}
|
||||
engines: {node: '>=20.0.0'}
|
||||
@@ -9335,10 +9325,6 @@ packages:
|
||||
bidi-js@1.0.3:
|
||||
resolution: {integrity: sha512-RKshQI1R3YQ+n9YJz2QQ147P66ELpa1FQEg20Dk8oW9t2KgLbpDLLp9aGZ7y8WHSshDknG0bknqGw5/tyCs5tw==}
|
||||
|
||||
big-integer@1.6.51:
|
||||
resolution: {integrity: sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==}
|
||||
engines: {node: '>=0.6'}
|
||||
|
||||
big.js@5.2.2:
|
||||
resolution: {integrity: sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==}
|
||||
|
||||
@@ -10561,9 +10547,6 @@ packages:
|
||||
resolution: {integrity: sha512-nI4U3TottKAcAD9LLud4Cb7b2QztQMUEfHbvhTH09bqXTxnSie8WnjPALV/WMCrJZ6UV/qHJ6L03OqO3LcdYZw==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
dotty@0.1.2:
|
||||
resolution: {integrity: sha512-V0EWmKeH3DEhMwAZ+8ZB2Ao4OK6p++Z0hsDtZq3N0+0ZMVqkzrcEGROvOnZpLnvBg5PTNG23JEDLAm64gPaotQ==}
|
||||
|
||||
drange@1.1.1:
|
||||
resolution: {integrity: sha512-pYxfDYpued//QpnLIm4Avk7rsNtAtQkUES2cwAYSvD/wd2pKD71gN2Ebj3e7klzXwjocvE8c5vx/1fxwpqmSxA==}
|
||||
engines: {node: '>=4'}
|
||||
@@ -13978,10 +13961,6 @@ packages:
|
||||
node-releases@2.0.36:
|
||||
resolution: {integrity: sha512-TdC8FSgHz8Mwtw9g5L4gR/Sh9XhSP/0DEkQxfEFXOpiul5IiHgHan2VhYYb6agDSfp4KuvltmGApc8HMgUrIkA==}
|
||||
|
||||
node-sql-parser@4.18.0:
|
||||
resolution: {integrity: sha512-2YEOR5qlI1zUFbGMLKNfsrR5JUvFg9LxIRVE+xJe962pfVLH0rnItqLzv96XVs1Y1UIR8FxsXAuvX/lYAWZ2BQ==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
non-error@0.1.0:
|
||||
resolution: {integrity: sha512-TMB1uHiGsHRGv1uYclfhivcnf0/PdFp2pNqRxXjncaAsjYMoisaQJI+SSZCqRq+VliwRTC8tsMQfmrWjDMhkPQ==}
|
||||
engines: {node: '>=20'}
|
||||
@@ -14531,10 +14510,6 @@ packages:
|
||||
pg-connection-string@2.9.1:
|
||||
resolution: {integrity: sha512-nkc6NpDcvPVpZXxrreI/FOtX3XemeLl8E0qFr6F2Lrm/I8WOnaWNhIPK2Z7OHpw7gh5XJThi6j6ppgNoaT1w4w==}
|
||||
|
||||
pg-format@1.0.4:
|
||||
resolution: {integrity: sha512-YyKEF78pEA6wwTAqOUaHIN/rWpfzzIuMh9KdAhc3rSLQ/7zkRFcCgYBAEGatDstLyZw4g0s9SNICmaTGnBVeyw==}
|
||||
engines: {node: '>=4.0'}
|
||||
|
||||
pg-int8@1.0.1:
|
||||
resolution: {integrity: sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==}
|
||||
engines: {node: '>=4.0.0'}
|
||||
@@ -14578,16 +14553,6 @@ packages:
|
||||
pgpass@1.0.5:
|
||||
resolution: {integrity: sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==}
|
||||
|
||||
pgsql-deparser@13.4.0:
|
||||
resolution: {integrity: sha512-mVECYO+utvPuw+PWXmPeIkQqVTERreRXVPW1rVmCS4XzXV3hpor9jKhcRbfvmGkGqSHs6KsRdDmYj9QdpdOMng==}
|
||||
|
||||
pgsql-enums@13.1.3:
|
||||
resolution: {integrity: sha512-h3OSGbv1rB1r3lWL3l0gHIMVMVBTzEzROkP2/Wpz2s1eDAffPf9O5x0OqrRdLzhze92S9GUqO/FrS15u027xyg==}
|
||||
|
||||
pgsql-parser@13.5.0:
|
||||
resolution: {integrity: sha512-5eWkisSQo66x9F5m+RvDz12IRtKnAoEEGz3bygwCppQl+0EZ0yrNOB6hhZZHcxoZxJ1psNdobwoQMe7SzaZFWg==}
|
||||
hasBin: true
|
||||
|
||||
phenomenon@1.6.0:
|
||||
resolution: {integrity: sha512-7h9/fjPD3qNlgggzm88cY58l9sudZ6Ey+UmZsizfhtawO6E3srZQXywaNm2lBwT72TbpHYRPy7ytIHeBUD/G0A==}
|
||||
|
||||
@@ -14885,17 +14850,6 @@ packages:
|
||||
prettier-plugin-sql-cst@0.18.0:
|
||||
resolution: {integrity: sha512-IEbKtlZ+H94uWFHQt4iKWMiJJRIuzWYw8jeLz+RCzy4bDtsM3/07GIF1+EFCbT9d0gWibTPotZWx8o3hz+ITeA==}
|
||||
|
||||
prettier-plugin-sql@0.13.0:
|
||||
resolution: {integrity: sha512-Ui9603tDD6PFyr7JvIEoE6cIFMQnJVDriG+oLyVThsGo/MIl5ek18JhH3xtox9ux8jvyww/FUFrJzxpZ7FIdvw==}
|
||||
engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0}
|
||||
peerDependencies:
|
||||
prettier: ^2.0.0
|
||||
|
||||
prettier@2.8.8:
|
||||
resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==}
|
||||
engines: {node: '>=10.13.0'}
|
||||
hasBin: true
|
||||
|
||||
prettier@3.8.1:
|
||||
resolution: {integrity: sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg==}
|
||||
engines: {node: '>=14'}
|
||||
@@ -16091,10 +16045,6 @@ packages:
|
||||
sprintf-js@1.0.3:
|
||||
resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==}
|
||||
|
||||
sql-formatter@11.0.2:
|
||||
resolution: {integrity: sha512-6QumAdGHEnI5dXEq1d0aBRP876AyA9Wp/UE7wopKNA2Mp9sKGRKVqGgoWHk4dr0J0nceesC85Y0p36qmGoNqhw==}
|
||||
hasBin: true
|
||||
|
||||
sql-formatter@15.4.9:
|
||||
resolution: {integrity: sha512-5vmt2HlCAVozxsBZuXWkAki/KGawaK+b5GG5x+BtXOFVpN/8cqppblFUxHl4jxdA0cvo14lABhM+KBnrUapOlw==}
|
||||
hasBin: true
|
||||
@@ -23539,8 +23489,6 @@ snapshots:
|
||||
dependencies:
|
||||
'@simple-git/args-pathspec': 1.0.3
|
||||
|
||||
'@sinclair/typebox@0.25.24': {}
|
||||
|
||||
'@sindresorhus/is@7.1.0': {}
|
||||
|
||||
'@sindresorhus/merge-streams@4.0.0': {}
|
||||
@@ -23889,20 +23837,6 @@ snapshots:
|
||||
|
||||
'@supabase/phoenix@0.4.2': {}
|
||||
|
||||
'@supabase/postgres-meta@0.64.6(encoding@0.1.13)(supports-color@8.1.1)':
|
||||
dependencies:
|
||||
'@sinclair/typebox': 0.25.24
|
||||
pg: 8.16.3
|
||||
pg-format: 1.0.4
|
||||
pgsql-parser: 13.5.0(encoding@0.1.13)(supports-color@8.1.1)
|
||||
postgres-array: 3.0.2
|
||||
prettier: 2.8.8
|
||||
prettier-plugin-sql: 0.13.0(prettier@2.8.8)
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
- pg-native
|
||||
- supports-color
|
||||
|
||||
'@supabase/postgrest-js@2.105.4':
|
||||
dependencies:
|
||||
tslib: 2.8.1
|
||||
@@ -25835,8 +25769,6 @@ snapshots:
|
||||
dependencies:
|
||||
require-from-string: 2.0.2
|
||||
|
||||
big-integer@1.6.51: {}
|
||||
|
||||
big.js@5.2.2: {}
|
||||
|
||||
bin-links@6.0.0:
|
||||
@@ -27178,8 +27110,6 @@ snapshots:
|
||||
|
||||
dotenv@17.4.2: {}
|
||||
|
||||
dotty@0.1.2: {}
|
||||
|
||||
drange@1.1.1: {}
|
||||
|
||||
dset@3.1.4: {}
|
||||
@@ -31585,10 +31515,6 @@ snapshots:
|
||||
|
||||
node-releases@2.0.36: {}
|
||||
|
||||
node-sql-parser@4.18.0:
|
||||
dependencies:
|
||||
big-integer: 1.6.51
|
||||
|
||||
non-error@0.1.0: {}
|
||||
|
||||
nopt@5.0.0:
|
||||
@@ -32336,8 +32262,6 @@ snapshots:
|
||||
|
||||
pg-connection-string@2.9.1: {}
|
||||
|
||||
pg-format@1.0.4: {}
|
||||
|
||||
pg-int8@1.0.1: {}
|
||||
|
||||
pg-minify@1.6.3: {}
|
||||
@@ -32384,27 +32308,6 @@ snapshots:
|
||||
dependencies:
|
||||
split2: 4.2.0
|
||||
|
||||
pgsql-deparser@13.4.0:
|
||||
dependencies:
|
||||
'@babel/runtime': 7.26.10
|
||||
dotty: 0.1.2
|
||||
pgsql-enums: 13.1.3
|
||||
|
||||
pgsql-enums@13.1.3:
|
||||
dependencies:
|
||||
'@babel/runtime': 7.26.10
|
||||
|
||||
pgsql-parser@13.5.0(encoding@0.1.13)(supports-color@8.1.1):
|
||||
dependencies:
|
||||
'@babel/runtime': 7.26.10
|
||||
libpg-query: 15.2.0(encoding@0.1.13)(supports-color@8.1.1)
|
||||
minimist: 1.2.8
|
||||
pgsql-deparser: 13.4.0
|
||||
pgsql-enums: 13.1.3
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
- supports-color
|
||||
|
||||
phenomenon@1.6.0: {}
|
||||
|
||||
picocolors@1.1.1: {}
|
||||
@@ -32678,15 +32581,6 @@ snapshots:
|
||||
prettier: 3.8.1
|
||||
sql-parser-cst: 0.38.2
|
||||
|
||||
prettier-plugin-sql@0.13.0(prettier@2.8.8):
|
||||
dependencies:
|
||||
node-sql-parser: 4.18.0
|
||||
prettier: 2.8.8
|
||||
sql-formatter: 11.0.2
|
||||
tslib: 2.8.1
|
||||
|
||||
prettier@2.8.8: {}
|
||||
|
||||
prettier@3.8.1: {}
|
||||
|
||||
pretty-bytes@7.1.0: {}
|
||||
@@ -34309,11 +34203,6 @@ snapshots:
|
||||
|
||||
sprintf-js@1.0.3: {}
|
||||
|
||||
sql-formatter@11.0.2:
|
||||
dependencies:
|
||||
argparse: 2.0.1
|
||||
nearley: 2.20.1
|
||||
|
||||
sql-formatter@15.4.9:
|
||||
dependencies:
|
||||
argparse: 2.0.1
|
||||
|
||||
Reference in new issue
Block a user