mirror of
https://github.com/supabase/supabase.git
synced 2026-06-18 21:54:18 +08:00
## 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 -->
63 lines
1.6 KiB
TypeScript
63 lines
1.6 KiB
TypeScript
import type { PGTrigger } from '@supabase/pg-meta'
|
|
|
|
import { TextConfirmModal } from '@/components/ui/TextConfirmModalWrapper'
|
|
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
|
|
|
interface DeleteTriggerProps {
|
|
trigger?: PGTrigger
|
|
visible: boolean
|
|
setVisible: (value: string | null) => void
|
|
onDelete: (params: {
|
|
projectRef: string
|
|
connectionString?: string | null
|
|
trigger: PGTrigger
|
|
}) => void
|
|
isLoading: boolean
|
|
}
|
|
|
|
export const DeleteTrigger = ({
|
|
trigger,
|
|
visible,
|
|
setVisible,
|
|
onDelete,
|
|
isLoading,
|
|
}: DeleteTriggerProps) => {
|
|
const { data: project } = useSelectedProjectQuery()
|
|
const { name, schema } = trigger ?? {}
|
|
|
|
async function handleDelete() {
|
|
if (!project) return console.error('Project is required')
|
|
if (!trigger) return console.error('Trigger ID is required')
|
|
|
|
onDelete({
|
|
projectRef: project.ref,
|
|
connectionString: project.connectionString,
|
|
trigger,
|
|
})
|
|
}
|
|
|
|
return (
|
|
<TextConfirmModal
|
|
variant={'warning'}
|
|
visible={visible}
|
|
onCancel={() => setVisible('')}
|
|
onConfirm={handleDelete}
|
|
title="Delete this trigger"
|
|
loading={isLoading}
|
|
confirmLabel={`Delete trigger ${name}`}
|
|
confirmPlaceholder="Type in name of trigger"
|
|
confirmString={name ?? ''}
|
|
text={
|
|
<>
|
|
This will delete your trigger called{' '}
|
|
<span className="text-bold text-foreground">{name}</span> of schema{' '}
|
|
<span className="text-bold text-foreground">{schema}</span>
|
|
</>
|
|
}
|
|
alert={{
|
|
title: 'You cannot recover this trigger once deleted.',
|
|
}}
|
|
/>
|
|
)
|
|
}
|