Files
supabase/apps/studio/data/privileges/keys.ts
Alaister Young 3eb0022264 [FE-2158] (part 2) – feat(studio): Add exposed functions config to Postgrest settings (#43478)
**Changes:**
- Add function exposure controls to Data API settings
- Adds a per-function GRANT/REVOKE UI to the Data API settings page,
alongside the existing table selector.
- Empty state: shows "No tables/functions available" instead of "0 of 0
X exposed" when there's nothing to show
- Renamed update-exposed-tables-mutation →
update-exposed-entities-mutation to handle both tables and functions in
one save
**Decisions of note:**
- Functions are grouped by schema.name across overloads — toggling one
entry grants/revokes `EXECUTE` on all overloads
- Only normal and window functions are shown (`prokind in ('f', 'w')`) —
triggers and aggregates are excluded

---

**To test:**

- Table and schema selectors still works end-to-end
- Toggling a function and saving updates the count label and applies the
grant (check via SQL Editor: select * from
information_schema.role_routine_grants where routine_schema = 'public')
- Functions in unexposed schemas are dimmed and unclickable
- With no functions in the selected schemas, the selector label reads
"No functions available" and the dropdown shows the same
2026-03-10 22:11:59 +08:00

27 lines
1.1 KiB
TypeScript

export const privilegeKeys = {
tablePrivilegesList: (projectRef: string | undefined) =>
['projects', projectRef, 'database', 'table-privileges'] as const,
columnPrivilegesList: (projectRef: string | undefined) =>
['projects', projectRef, 'database', 'column-privileges'] as const,
exposedTablesInfinite: (projectRef: string | undefined, search?: string) =>
[
'projects',
projectRef,
'privileges',
'exposed-tables-infinite',
...(search ? ([{ search }] as const) : []),
] as const,
exposedTableCounts: (projectRef: string | undefined, selectedSchemas: string[]) =>
['projects', projectRef, 'privileges', 'exposed-table-counts', ...selectedSchemas] as const,
exposedFunctionsInfinite: (projectRef: string | undefined, search?: string) =>
[
'projects',
projectRef,
'privileges',
'exposed-functions-infinite',
...(search ? ([{ search }] as const) : []),
] as const,
exposedFunctionCounts: (projectRef: string | undefined, selectedSchemas: string[]) =>
['projects', projectRef, 'privileges', 'exposed-function-counts', ...selectedSchemas] as const,
}