import { Table2 } from 'lucide-react' import { useParams } from 'common' import CodeSnippet from 'components/interfaces/Docs/CodeSnippet' import Description from 'components/interfaces/Docs/Description' import Param from 'components/interfaces/Docs/Param' import Snippets from 'components/interfaces/Docs/Snippets' import { useCustomDomainsQuery } from 'data/custom-domains/custom-domains-query' import { useProjectJsonSchemaQuery } from 'data/docs/project-json-schema-query' import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled' import { DOCS_URL } from 'lib/constants' interface ResourceContentProps { apiEndpoint: string resourceId: string resources: { [key: string]: { id: string; displayName: string; camelCase: string } } selectedLang: 'bash' | 'js' showApiKey: string refreshDocs: () => void } export const ResourceContent = ({ apiEndpoint, resourceId, resources, selectedLang, showApiKey, refreshDocs, }: ResourceContentProps) => { const { ref } = useParams() const { data: customDomainData } = useCustomDomainsQuery({ projectRef: ref }) const { realtimeAll: realtimeEnabled } = useIsFeatureEnabled(['realtime:all']) const { data: jsonSchema } = useProjectJsonSchemaQuery({ projectRef: ref }) const { paths, definitions } = jsonSchema || {} const endpoint = customDomainData?.customDomain?.status === 'active' ? `https://${customDomainData.customDomain.hostname}` : apiEndpoint const keyToShow = !!showApiKey ? showApiKey : 'SUPABASE_KEY' const resourcePaths = paths?.[`/${resourceId}`] const resourceDefinition = definitions?.[resourceId] const resourceMeta = resources[resourceId] const description = resourceDefinition?.description || '' const methods = Object.keys(resourcePaths ?? {}).map((x) => x.toUpperCase()) const properties = Object.entries(resourceDefinition?.properties ?? []).map(([id, val]: any) => ({ ...val, id, required: resourceDefinition?.required?.includes(id), })) if (!paths || !definitions) return null return ( <>

{resourceId}

{properties.length > 0 && (
{properties.map((x) => (
))}
)} {methods.includes('GET') && ( <>

Read rows

To read rows in {resourceId}, use the select method.

Learn more

Filtering

Supabase provides a wide range of filters.

Learn more

)} {methods.includes('POST') && ( <>

Insert rows

insert lets you insert into your tables. You can also insert in bulk and do UPSERT.

insert will also return the replaced values for UPSERT.

Learn more

)} {methods.includes('PATCH') && ( <>

Update rows

update lets you update rows. update will match all rows by default. You can update specific rows using horizontal filters, e.g. eq , lt, and is.

update will also return the replaced values for UPDATE.

Learn more

)} {methods.includes('DELETE') && ( <>

Delete rows

delete lets you delete rows. delete will match all rows by default, so remember to specify your filters!

Learn more

)} {realtimeEnabled && (methods.includes('DELETE') || methods.includes('POST') || methods.includes('PATCH')) && ( <>

Subscribe to changes

Supabase provides realtime functionality and broadcasts database changes to authorized users depending on Row Level Security (RLS) policies.

Learn more

)} ) }