mirror of
https://github.com/supabase/supabase.git
synced 2026-10-11 12:25:05 +03: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 -->
127 lines
4.7 KiB
TypeScript
127 lines
4.7 KiB
TypeScript
import type { PGPolicy } from '@supabase/pg-meta'
|
|
import { Lock } from 'lucide-react'
|
|
|
|
interface LockedCreateQuerySection {
|
|
schema: string
|
|
selectedPolicy?: PGPolicy
|
|
isRenamingPolicy: boolean
|
|
formFields: { name: string; table: string; behavior: string; command: string; roles: string }
|
|
}
|
|
|
|
export const LockedCreateQuerySection = ({
|
|
schema,
|
|
isRenamingPolicy,
|
|
selectedPolicy,
|
|
formFields,
|
|
}: LockedCreateQuerySection) => {
|
|
const isEditing = selectedPolicy !== undefined
|
|
const { name, table, behavior, command, roles } = formFields
|
|
|
|
return (
|
|
<div className="bg-surface-300 pt-2 pb-1">
|
|
<div className="flex items-center justify-between px-5 mb-1">
|
|
<div className="flex items-center">
|
|
<div className="pl-0.5 pr-5 flex items-center justify-center">
|
|
<Lock size={14} className="text-foreground-lighter" />
|
|
</div>
|
|
<p className="text-xs text-foreground-lighter font-mono uppercase">
|
|
Use options above to edit
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<div className="flex items-start" style={{ fontSize: '14px' }}>
|
|
<p className="px-6 font-mono text-sm text-foreground-light select-none">1</p>
|
|
<p className="font-mono tracking-tighter">
|
|
<span className="text-[#569cd6]">{isEditing ? 'alter' : 'create'}</span> policy "
|
|
{isRenamingPolicy ? selectedPolicy?.name : name.length === 0 ? 'policy_name' : name}"
|
|
</p>
|
|
</div>
|
|
<div className="flex items-start" style={{ fontSize: '14px' }}>
|
|
<p className="px-6 font-mono text-sm text-foreground-light select-none">2</p>
|
|
<p className="font-mono tracking-tighter">
|
|
<span className="text-[#569cd6]">on</span> "{schema}"."
|
|
{table}"
|
|
</p>
|
|
</div>
|
|
{!isEditing && (
|
|
<>
|
|
<div className="flex items-start" style={{ fontSize: '14px' }}>
|
|
<p className="px-6 font-mono text-sm text-foreground-light select-none">3</p>
|
|
<p className="font-mono tracking-tighter">
|
|
<span className="text-[#569cd6]">as</span> {behavior.toLocaleUpperCase()}
|
|
</p>
|
|
</div>
|
|
<div className="flex items-start" style={{ fontSize: '14px' }}>
|
|
<p className="px-6 font-mono text-sm text-foreground-light select-none">4</p>
|
|
<p className="font-mono tracking-tighter">
|
|
<span className="text-[#569cd6]">for</span> {command.toLocaleUpperCase()}
|
|
</p>
|
|
</div>
|
|
</>
|
|
)}
|
|
<div className="flex items-start" style={{ fontSize: '14px' }}>
|
|
<p className="px-6 font-mono text-sm text-foreground-light select-none">5</p>
|
|
<p className="font-mono tracking-tighter">
|
|
<span className="text-[#569cd6]">to</span> {roles.length === 0 ? 'public' : roles}
|
|
</p>
|
|
</div>
|
|
<div className="flex items-start" style={{ fontSize: '14px' }}>
|
|
<p className="px-6 font-mono text-sm text-foreground-light select-none">6</p>
|
|
<p className="font-mono tracking-tighter">
|
|
<span className="text-[#569cd6]">{command === 'insert' ? 'with check' : 'using'}</span>{' '}
|
|
<span className="text-[#ffd700]">(</span>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export const LockedRenameQuerySection = ({
|
|
oldName,
|
|
newName,
|
|
schema,
|
|
table,
|
|
lineNumber,
|
|
}: {
|
|
oldName: string
|
|
newName: string
|
|
schema: string
|
|
table: string
|
|
lineNumber: number
|
|
}) => {
|
|
return (
|
|
<div className="bg-surface-300 py-1">
|
|
<div className="flex items-center" style={{ fontSize: '14px' }}>
|
|
<div className="w-[57px]">
|
|
<p className="w-[31px] flex justify-end font-mono text-sm text-foreground-light select-none">
|
|
{lineNumber}
|
|
</p>
|
|
</div>
|
|
<p className="font-mono tracking-tighter">
|
|
<span className="text-[#569cd6]">alter</span> policy "{oldName}"
|
|
</p>
|
|
</div>
|
|
<div className="flex items-center" style={{ fontSize: '14px' }}>
|
|
<div className="w-[57px]">
|
|
<p className="w-[31px] flex justify-end font-mono text-sm text-foreground-light select-none">
|
|
{lineNumber + 1}
|
|
</p>
|
|
</div>
|
|
<p className="font-mono tracking-tighter">
|
|
<span className="text-[#569cd6]">on</span> "{schema}"."{table}"
|
|
</p>
|
|
</div>
|
|
<div className="flex items-center" style={{ fontSize: '14px' }}>
|
|
<div className="w-[57px]">
|
|
<p className="w-[31px] flex justify-end font-mono text-sm text-foreground-light select-none">
|
|
{lineNumber + 2}
|
|
</p>
|
|
</div>
|
|
<p className="font-mono tracking-tighter">
|
|
<span className="text-[#569cd6]">rename</span> to "{newName}";
|
|
</p>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|