Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

2.0 KB
Raw Blame
export const privilegeKeys = {
  tablePrivilegesList: (projectRef: string | undefined, includedSchemas?: string[]) =>
    ['projects', projectRef, 'database', 'table-privileges', includedSchemas].filter(Boolean),
  columnPrivilegesList: (
    projectRef: string | undefined,
    schema?: string | undefined,
    table?: string | undefined
  ) => {
    const base = ['projects', projectRef, 'database', 'column-privileges'].filter(Boolean)
    if (table === undefined) return schema === undefined ? base : [...base, schema]
    return [...base, schema ?? null, table]
  },
  exposedTablesInfinite: (projectRef: string | undefined, search?: string) =>
    [
      'projects',
      projectRef,
      'privileges',
      'exposed-tables-infinite',
      ...(search ? ([{ search }] as const) : []),
    ] as const,
  exposedTablesAll: (projectRef: string | undefined) =>
    ['projects', projectRef, 'privileges', 'exposed-tables-all'] as const,
  exposedFunctionsAll: (projectRef: string | undefined) =>
    ['projects', projectRef, 'privileges', 'exposed-functions-all'] as const,
  exposedTableCounts: (projectRef: string | undefined, selectedSchemas?: string[]) =>
    [
      'projects',
      projectRef,
      'privileges',
      'exposed-table-counts',
      ...(selectedSchemas ? ([selectedSchemas] as const) : []),
    ] 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 ? ([selectedSchemas] as const) : []),
    ] as const,
  defaultPrivileges: (projectRef: string | undefined, schema?: string) =>
    [
      'projects',
      projectRef,
      'privileges',
      'default-privileges',
      ...(schema ? [schema] : []),
    ] as const,
}