mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
db: allow public read access to troubleshooting entries table (#33172)
* db: allow public read access to troubleshooting entries table * chore: allow troubleshooting generation from public client
This commit is contained in:
1 parent
37500328a2
commit
f1e4970352
3 files changed
+20
-11
No files matched your search
@@ -2,8 +2,7 @@ import { cache } from 'react'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { cache_fullProcess_withDevCacheBust } from '~/features/helpers.fs'
|
||||
import { IS_PLATFORM } from '~/lib/constants'
|
||||
import { supabaseAdmin } from '~/lib/supabaseAdmin'
|
||||
import { supabase } from '~/lib/supabase'
|
||||
import {
|
||||
getAllTroubleshootingEntriesInternal,
|
||||
getArticleSlug as getArticleSlugInternal,
|
||||
@@ -27,10 +26,9 @@ export interface ITroubleshootingEntry {
|
||||
export const getArticleSlug = getArticleSlugInternal
|
||||
|
||||
async function getAllTroubleshootingEntriesTyped() {
|
||||
const result: ITroubleshootingEntry[] = (
|
||||
IS_PLATFORM ? await getAllTroubleshootingEntriesInternal() : []
|
||||
) as ITroubleshootingEntry[]
|
||||
return result
|
||||
const result: ITroubleshootingEntry[] =
|
||||
(await getAllTroubleshootingEntriesInternal()) as ITroubleshootingEntry[]
|
||||
return result ?? []
|
||||
}
|
||||
export const getAllTroubleshootingEntries = cache_fullProcess_withDevCacheBust(
|
||||
getAllTroubleshootingEntriesTyped,
|
||||
@@ -91,15 +89,11 @@ export async function getAllTroubleshootingErrors() {
|
||||
}
|
||||
|
||||
async function getTroubleshootingUpdatedDatesInternal() {
|
||||
if (!IS_PLATFORM) {
|
||||
return new Map<string, Date>()
|
||||
}
|
||||
|
||||
const databaseIds = (await getAllTroubleshootingEntries())
|
||||
.map((entry) => entry.data.database_id)
|
||||
.filter((id) => !id.startsWith('pseudo-'))
|
||||
|
||||
const { data, error } = await supabaseAdmin()
|
||||
const { data, error } = await supabase()
|
||||
.from('troubleshooting_entries')
|
||||
.select('id, date_updated')
|
||||
.in('id', databaseIds)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { createClient, type SupabaseClient } from '@supabase/supabase-js'
|
||||
|
||||
import { type Database as DatabaseGenerated } from 'common'
|
||||
|
||||
export type Database = {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
-- Give anon and authenticated read access to the troubleshooting entries table
|
||||
-- Allows troubleshooting entries to be generated in local dev
|
||||
|
||||
create policy anon_read_troubleshooting_entries
|
||||
on public.troubleshooting_entries
|
||||
for select
|
||||
to anon
|
||||
using (true);
|
||||
|
||||
create policy authenticated_read_troubleshooting_entries
|
||||
on public.troubleshooting_entries
|
||||
for select
|
||||
to authenticated
|
||||
using (true);
|
||||
Reference in new issue
Block a user