The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Refactor API docs and add perms against updating description
Joshen Lim92b8454768c5
diff --git a/studio/components/interfaces/Docs/GeneralContent.tsx b/studio/components/interfaces/Docs/GeneralContent.tsxnew file mode 100644index 00000000000..7ca969ab2ed--- /dev/null+++ b/studio/components/interfaces/Docs/GeneralContent.tsx@@ -0,0 +1,39 @@+import Introduction from 'components/to-be-cleaned/Docs/Pages/Introduction'+import Authentication from 'components/to-be-cleaned/Docs/Pages/Authentication'+import TablesIntroduction from 'components/to-be-cleaned/Docs/Pages/Tables/Introduction'+import UserManagement from 'components/to-be-cleaned/Docs/Pages/UserManagement'+import RpcIntroduction from 'components/to-be-cleaned/Docs/Pages/Rpc/Introduction'++const GeneralContent = ({ autoApiService, selectedLang, page, showApiKey }: any) => {+ let selected = page?.toLowerCase()+ if (selected == 'intro' || selected == null)+ return <Introduction autoApiService={autoApiService} selectedLang={selectedLang} />+ if (selected == 'auth')+ return (+ <Authentication+ autoApiService={autoApiService}+ selectedLang={selectedLang}+ showApiKey={showApiKey}+ />+ )+ if (selected == 'users')+ return (+ <UserManagement+ autoApiService={autoApiService}+ selectedLang={selectedLang}+ showApiKey={showApiKey}+ />+ )+ if (selected == 'tables-intro')+ return <TablesIntroduction autoApiService={autoApiService} selectedLang={selectedLang} />+ if (selected == 'rpc-intro') return <RpcIntroduction />+ else+ return (+ <div>+ <h2 className="m-4">Not found</h2>+ <p className="m-4"> Looks like you went somewhere that nobody knows.</p>+ </div>+ )+}++export default GeneralContentdiff --git a/studio/components/interfaces/Docs/ResourceContent.tsx b/studio/components/interfaces/Docs/ResourceContent.tsxnew file mode 100644index 00000000000..6328747a68d--- /dev/null+++ b/studio/components/interfaces/Docs/ResourceContent.tsx@@ -0,0 +1,293 @@+import { PermissionAction } from '@supabase/shared-types/out/constants'++import { checkPermissions } from 'hooks'+import Snippets from 'components/to-be-cleaned/Docs/Snippets'+import CodeSnippet from 'components/to-be-cleaned/Docs/CodeSnippet'+import Param from 'components/to-be-cleaned/Docs/Param'+import Description from 'components/to-be-cleaned/Docs/Description'++const ResourceContent = ({+ autoApiService,+ resourceId,+ resources,+ definitions,+ paths,+ selectedLang,+ showApiKey,+ refreshDocs,+}: any) => {+ if (!paths || !definitions) return null++ const keyToShow = !!showApiKey ? showApiKey : 'SUPABASE_KEY'+ const resourcePaths = paths[`/${resourceId}`]+ const resourceDefinition = definitions[resourceId]+ const resourceMeta = resources[resourceId]+ const description = resourceDefinition.description || null+ 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),+ }))++ const canUpdateDescription = checkPermissions(PermissionAction.TENANT_SQL_ADMIN_WRITE, 'tables')++ return (+ <>+ <h2 className="text-scale-1200mt-0">+ <span className="px-6 py-2 text-2xl">{resourceId}</span>+ </h2>++ <div className="doc-section">+ <article className="text ">+ <Description+ content={description}+ metadata={{ table: resourceId }}+ onChange={refreshDocs}+ disabled={!canUpdateDescription}+ />+ </article>+ <article className="code"></article>+ </div>+ {properties.length > 0 && (+ <div>+ {properties.map((x) => (+ <div className="doc-section py-4" key={x.id}>+ <article className="text">+ <Param+ key={x.id}+ name={x.id}+ type={x.type}+ format={x.format}+ required={x.required}+ description={x.description}+ metadata={{+ table: resourceId,+ column: x.id,+ }}+ onDesciptionUpdated={refreshDocs}+ canUpdateDescription={canUpdateDescription}+ />+ </article>+ <article className="code">+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.readColumns({+ title: `Select ${x.id}`,+ resourceId,+ endpoint: autoApiService.endpoint,+ apiKey: keyToShow,+ columnName: x.id,+ })}+ />+ </article>+ </div>+ ))}+ </div>+ )}+ {methods.includes('GET') && (+ <>+ <h3 className="text-scale-1200 mt-4 px-6">Read rows</h3>+ <div className="doc-section">+ <article className="text ">+ <p>+ To read rows in <code>{resourceId}</code>, use the <code>select</code> method.+ </p>+ <p>+ <a href="https://supabase.com/docs/client/select" target="_blank">+ Learn more.+ </a>+ </p>+ </article>+ <article className="code">+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.readAll(resourceId, autoApiService.endpoint, keyToShow)}+ />+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.readColumns({+ resourceId,+ endpoint: autoApiService.endpoint,+ apiKey: keyToShow,+ })}+ />+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.readForeignTables(resourceId, autoApiService.endpoint, keyToShow)}+ />+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.readRange(resourceId, autoApiService.endpoint, keyToShow)}+ />+ </article>+ </div>+ <div className="doc-section">+ <article className="text ">+ <h4 className="mt-0 text-white">Filtering</h4>+ <p>Supabase provides a wide range of filters.</p>+ <p>+ <a href="https://supabase.com/docs/client/using-filters" target="_blank">+ Learn more.+ </a>+ </p>+ </article>+ <article className="code">+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.readFilters(resourceId, autoApiService.endpoint, keyToShow)}+ />+ </article>+ </div>+ </>+ )}+ {methods.includes('POST') && (+ <>+ <h3 className="text-scale-1200 mt-4 px-6">Insert rows</h3>+ <div className="doc-section">+ <article className="text ">+ <p>+ <code>insert</code> lets you insert into your tables. You can also insert in bulk+ and do UPSERT.+ </p>+ <p>+ <code>insert</code> will also return the replaced values for UPSERT.+ </p>+ <p>+ <a href="https://supabase.com/docs/client/insert" target="_blank">+ Learn more.+ </a>+ </p>+ </article>+ <article className="code">+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.insertSingle(resourceId, autoApiService.endpoint, keyToShow)}+ />+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.insertMany(resourceId, autoApiService.endpoint, keyToShow)}+ />+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.upsert(resourceId, autoApiService.endpoint, keyToShow)}+ />+ </article>+ </div>+ </>+ )}+ {methods.includes('PATCH') && (+ <>+ <h3 className="text-scale-1200 mt-4 px-6">Update rows</h3>+ <div className="doc-section">+ <article className="text ">+ <p>+ <code>update</code> lets you update rows. <code>update</code> will match all rows by+ default. You can update specific rows using horizontal filters, e.g. <code>eq</code>+ , <code>lt</code>, and <code>is</code>.+ </p>+ <p>+ <code>update</code> will also return the replaced values for UPDATE.+ </p>+ <p>+ <a href="https://supabase.com/docs/client/update" target="_blank">+ Learn more.+ </a>+ </p>+ </article>+ <article className="code">+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.update(resourceId, autoApiService.endpoint, keyToShow)}+ />+ </article>+ </div>+ </>+ )}+ {methods.includes('DELETE') && (+ <>+ <h3 className="text-scale-1200 mt-4 px-6">Delete rows</h3>+ <div className="doc-section">+ <article className="text ">+ <p>+ <code>delete</code> lets you delete rows. <code>delete</code> will match all rows by+ default, so remember to specify your filters!+ </p>+ <p>+ <a href="https://supabase.com/docs/client/delete" target="_blank">+ Learn more.+ </a>+ </p>+ </article>+ <article className="code">+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.delete(resourceId, autoApiService.endpoint, keyToShow)}+ />+ </article>+ </div>+ </>+ )}+ <>+ <h3 className="text-scale-1200 mt-4 px-6">Subscribe to changes</h3>+ <div className="doc-section">+ <article className="text ">+ <p>+ Supabase provides realtime functionality and broadcasts database changes to authorized+ users depending on Row Level Security (RLS) policies.+ </p>+ <p>+ <a href="https://supabase.com/docs/client/subscribe" target="_blank">+ Learn more.+ </a>+ </p>+ </article>+ <article className="code">+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.subscribeAll(resourceMeta.camelCase, resourceId)}+ />+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.subscribeInserts(resourceMeta.camelCase, resourceId)}+ />+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.subscribeUpdates(resourceMeta.camelCase, resourceId)}+ />+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.subscribeDeletes(resourceMeta.camelCase, resourceId)}+ />+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.subscribeEq(+ resourceMeta.camelCase,+ resourceId,+ 'column_name',+ 'someValue'+ )}+ />+ </article>+ </div>+ </>+ <>+ <h3 className="text-scale-1200 mt-4 px-6">Much more</h3>+ <div className="doc-section py-4">+ <article className="text ">+ <p>+ These docs are a work in progress! See our{' '}+ <a href="https://supabase.com/docs/" target="_blank">+ docs+ </a>{' '}+ for the additional functionality Supabase has to offer.+ </p>+ </article>+ <article className="code"></article>+ </div>+ </>+ </>+ )+}++export default ResourceContentdiff --git a/studio/components/interfaces/Docs/RpcContent.tsx b/studio/components/interfaces/Docs/RpcContent.tsxnew file mode 100644index 00000000000..eeda7bdf1ac--- /dev/null+++ b/studio/components/interfaces/Docs/RpcContent.tsx@@ -0,0 +1,97 @@+import { PermissionAction } from '@supabase/shared-types/out/constants'++import { checkPermissions } from 'hooks'+import Snippets from 'components/to-be-cleaned/Docs/Snippets'+import CodeSnippet from 'components/to-be-cleaned/Docs/CodeSnippet'+import Param from 'components/to-be-cleaned/Docs/Param'+import Description from 'components/to-be-cleaned/Docs/Description'++/**+ * TODO: need to support rpc with the same name and different params type+ */+const RpcContent = ({+ autoApiService,+ rpcId,+ rpcs,+ paths,+ selectedLang,+ refreshDocs,+ showApiKey,+}: any) => {+ const meta = rpcs[rpcId]+ const pathKey = `/rpc/${rpcId}`+ const path = paths && pathKey in paths ? paths[pathKey] : undefined+ const keyToShow = !!showApiKey ? showApiKey : 'SUPABASE_KEY'++ if (!path) return null++ const {+ post: { parameters, summary },+ } = path+ const rpcParamsObject =+ parameters && parameters[0] && parameters[0].schema && parameters[0].schema.properties+ ? parameters[0].schema.properties+ : {}+ const rpcParams = Object.entries(rpcParamsObject)+ .map(([k, v]: any) => ({ name: k, ...v }))+ .filter((x) => !!x.name)+ const paramList = rpcParams.map((x) => x.type).join(', ')++ const canUpdateDescription = checkPermissions(PermissionAction.TENANT_SQL_ADMIN_WRITE, 'tables')++ return (+ <>+ <h2 className="text-scale-1200 mt-0">+ <span className="px-6 text-2xl">{meta.id}</span>+ </h2>++ <div className="doc-section">+ <article className="text ">+ <Description+ content={summary}+ metadata={{ rpc: `${rpcId} (${paramList})` }}+ onChange={refreshDocs}+ disabled={!canUpdateDescription}+ />+ </article>+ <article className="code">+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.rpcSingle({+ rpcName: rpcId,+ // @ts-ignore+ rpcCamelCase: meta.camelCase,+ rpcParams: rpcParams,+ apiKey: keyToShow,+ endpoint: autoApiService.endpoint,+ })}+ />+ </article>+ </div>+ {rpcParams.length > 0 && (+ <div>+ <h3 className="text-scale-1200 mt-0 px-6 capitalize">Function Arguments</h3>+ {rpcParams.map((x) => {+ return (+ <div className="doc-section">+ <article className="text ">+ <Param+ key={x.name}+ name={x.name}+ type={x.type}+ format={x.format}+ required={true}+ description={false}+ />+ </article>+ <article className="code"></article>+ </div>+ )+ })}+ </div>+ )}+ </>+ )+}++export default RpcContentdiff --git a/studio/components/interfaces/Docs/index.ts b/studio/components/interfaces/Docs/index.tsnew file mode 100644index 00000000000..5449fccdec3--- /dev/null+++ b/studio/components/interfaces/Docs/index.ts@@ -0,0 +1,5 @@+import GeneralContent from './GeneralContent'+import ResourceContent from './ResourceContent'+import RpcContent from './RPCContent'++export { GeneralContent, ResourceContent, RpcContent }diff --git a/studio/components/to-be-cleaned/Docs/Description.js b/studio/components/to-be-cleaned/Docs/Description.jsindex e1e680434c4..14a3654c643 100644--- a/studio/components/to-be-cleaned/Docs/Description.js+++ b/studio/components/to-be-cleaned/Docs/Description.js@@ -1,5 +1,4 @@import { useState } from 'react'-import { useRouter } from 'next/router'import { Button, IconLoader } from '@supabase/ui'import { useStore } from 'hooks'@@ -20,47 +19,52 @@ const temp_removePostgrestText = (content) => {return cleansed}-export default function Description({ content, metadata, onChange = () => {} }) {- const router = useRouter()- const { meta } = useStore()+export default function Description({ content, metadata, disabled = false, onChange = () => {} }) {+ const { meta, ui } = useStore()const contentText = temp_removePostgrestText(content || '').trim()const [value, setValue] = useState(contentText)const [isUpdating, setIsUpdating] = useState(false)- const { ref } = router.queryconst { table, column, rpc } = metadataconst hasChanged = value != contentTextconst animateCss = `transition duration-150`- const buttonCss = `inline-block text-sm border text-white font-bold rounded py-1 px-3 w-20 cursor-pointer`- const primaryCss = `${buttonCss} ${animateCss} bg-gray-500 border-gray-400 hover:border-green-500 hover:bg-green-500 `- const secondaryCss = `${buttonCss} ${animateCss} bg-gray-500 border-gray-400 hover:border-red-500 hover:bg-red-500 `const updateDescription = async () => {if (isUpdating) return false- try {- setIsUpdating(true)- let query = ''- let description = value.replaceAll("'", "''")- if (table && column)- query = `comment on column public."${table}"."${column}" is '${description}';`- if (table && !column) query = `comment on table public."${table}" is '${description}';`- if (rpc) query = `comment on function ${rpc} is '${description}';`- if (query) {- await meta.query(query)- // [Joshen] Temp fix, immediately refreshing the docs fetches stale state- await timeout(500)- }+ setIsUpdating(true)+ let query = ''+ let description = value.replaceAll("'", "''")+ if (table && column)+ query = `comment on column public."${table}"."${column}" is '${description}';`+ if (table && !column) query = `comment on table public."${table}" is '${description}';`+ if (rpc) query = `comment on function ${rpc} is '${description}';`- onChange(value)- } catch (error) {- console.error('Update description error:', error)- } finally {- setIsUpdating(false)+ if (query) {+ const res = await meta.query(query)+ if (res.error) {+ ui.setNotification({+ error: res.error,+ category: 'error',+ message: `Failed to update description: ${res.error.message}`,+ })+ }+ // [Joshen] Temp fix, immediately refreshing the docs fetches stale state+ await timeout(500)}++ onChange(value)+ setIsUpdating(false)}++ if (disabled) {+ return (+ <span className={`block ${value ? 'text-scale-1200' : ''}`}>{value || 'No description'}</span>+ )+ }+return (<div className="space-y-2"><AutoTextAreadiff --git a/studio/components/to-be-cleaned/Docs/Param.js b/studio/components/to-be-cleaned/Docs/Param.jsindex 34f0f509eff..1bc97bcfa00 100644--- a/studio/components/to-be-cleaned/Docs/Param.js+++ b/studio/components/to-be-cleaned/Docs/Param.js@@ -8,6 +8,7 @@ const Param = ({required,description,metadata = {},+ canUpdateDescription = false,onDesciptionUpdated = () => {},}) => {return (@@ -26,8 +27,12 @@ const Param = ({{description !== false && (<><label className="uppercase text-xs font-mono text-scale-900">Description</label>-- <Description content={description} metadata={metadata} onChange={onDesciptionUpdated} />+ <Description+ content={description}+ metadata={metadata}+ onChange={onDesciptionUpdated}+ disabled={!canUpdateDescription}+ /></>)}</>diff --git a/studio/pages/project/[ref]/api/index.tsx b/studio/pages/project/[ref]/api/index.tsxindex 502bd1521d5..ff725ed7dc9 100644--- a/studio/pages/project/[ref]/api/index.tsx+++ b/studio/pages/project/[ref]/api/index.tsx@@ -4,21 +4,13 @@ import { Button, Dropdown, IconKey, Typography } from '@supabase/ui'import { FC, createContext, useContext, useEffect, useState } from 'react'import { observer, useLocalObservable } from 'mobx-react-lite'+import { NextPageWithLayout } from 'types'import { API_URL, IS_PLATFORM } from 'lib/constants'import { useStore } from 'hooks'import { get } from 'lib/common/fetch'import { snakeToCamel } from 'lib/helpers'import { DocsLayout } from 'components/layouts'-import Snippets from 'components/to-be-cleaned/Docs/Snippets'-import CodeSnippet from 'components/to-be-cleaned/Docs/CodeSnippet'-import Param from 'components/to-be-cleaned/Docs/Param'-import Introduction from 'components/to-be-cleaned/Docs/Pages/Introduction'-import Authentication from 'components/to-be-cleaned/Docs/Pages/Authentication'-import TablesIntroduction from 'components/to-be-cleaned/Docs/Pages/Tables/Introduction'-import UserManagement from 'components/to-be-cleaned/Docs/Pages/UserManagement'-import RpcIntroduction from 'components/to-be-cleaned/Docs/Pages/Rpc/Introduction'-import Description from 'components/to-be-cleaned/Docs/Description'-import { NextPageWithLayout } from 'types'+import { GeneralContent, ResourceContent, RpcContent } from 'components/interfaces/Docs'const PageContext = createContext(null)@@ -237,400 +229,3 @@ const DocView: FC<any> = observer(({}) => {</div>)})--const GeneralContent = ({ autoApiService, selectedLang, page, showApiKey }: any) => {- let selected = page?.toLowerCase()- if (selected == 'intro' || selected == null)- return <Introduction autoApiService={autoApiService} selectedLang={selectedLang} />- if (selected == 'auth')- return (- <Authentication- autoApiService={autoApiService}- selectedLang={selectedLang}- showApiKey={showApiKey}- />- )- if (selected == 'users')- return (- <UserManagement- autoApiService={autoApiService}- selectedLang={selectedLang}- showApiKey={showApiKey}- />- )- if (selected == 'tables-intro')- return <TablesIntroduction autoApiService={autoApiService} selectedLang={selectedLang} />- if (selected == 'rpc-intro') return <RpcIntroduction />- else- return (- <div>- <h2 className="m-4">Not found</h2>- <p className="m-4"> Looks like you went somewhere that nobody knows.</p>- </div>- )-}--/**- * TODO: need to support rpc with the same name and different params type- */-const RpcContent = ({- autoApiService,- rpcId,- rpcs,- paths,- selectedLang,- refreshDocs,- showApiKey,-}: any) => {- const meta = rpcs[rpcId]- const pathKey = `/rpc/${rpcId}`- const path = paths && pathKey in paths ? paths[pathKey] : undefined- const keyToShow = !!showApiKey ? showApiKey : 'SUPABASE_KEY'-- if (!path) return null-- const {- post: { parameters, summary },- } = path- const rpcParamsObject =- parameters && parameters[0] && parameters[0].schema && parameters[0].schema.properties- ? parameters[0].schema.properties- : {}- const rpcParams = Object.entries(rpcParamsObject)- .map(([k, v]: any) => ({ name: k, ...v }))- .filter((x) => !!x.name)- const paramList = rpcParams.map((x) => x.type).join(', ')- return (- <>- <h2 className="text-scale-1200 mt-0">- <span className="px-6 text-2xl">{meta.id}</span>- </h2>-- <div className="doc-section">- <article className="text ">- <Description- content={summary}- metadata={{ rpc: `${rpcId} (${paramList})` }}- onChange={refreshDocs}- />- </article>- <article className="code">- <CodeSnippet- selectedLang={selectedLang}- snippet={Snippets.rpcSingle({- rpcName: rpcId,- // @ts-ignore- rpcCamelCase: meta.camelCase,- rpcParams: rpcParams,- apiKey: keyToShow,- endpoint: autoApiService.endpoint,- })}- />- </article>- </div>- {rpcParams.length > 0 && (- <div>- <h3 className="text-scale-1200 mt-0 px-6 capitalize">Function Arguments</h3>- {rpcParams.map((x) => {- return (- <div className="doc-section">- <article className="text ">- <Param- key={x.name}- name={x.name}- type={x.type}- format={x.format}- required={true}- description={false}- />- </article>- <article className="code"></article>- </div>- )- })}- </div>- )}- </>- )-}--const ResourceContent = ({- autoApiService,- resourceId,- resources,- definitions,- paths,- selectedLang,- showApiKey,- refreshDocs,-}: any) => {- if (!paths || !definitions) return null-- const keyToShow = !!showApiKey ? showApiKey : 'SUPABASE_KEY'- const resourcePaths = paths[`/${resourceId}`]- const resourceDefinition = definitions[resourceId]- const resourceMeta = resources[resourceId]- const description = resourceDefinition.description || null- 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),- }))-- return (- <>- <h2 className="text-scale-1200mt-0">- <span className="px-6 py-2 text-2xl">{resourceId}</span>- </h2>-- <div className="doc-section">- <article className="text ">- <Description- content={description}- metadata={{ table: resourceId }}- onChange={refreshDocs}- />- </article>- <article className="code"></article>- </div>- {properties.length > 0 && (- <div>- {/* <h2 className="text-white capitalize mt-0 px-6">Fields</h2> */}- {properties.map((x) => (- <div className="doc-section py-4" key={x.id}>- <article className="text">- <Param- key={x.id}- name={x.id}- type={x.type}- format={x.format}- required={x.required}- description={x.description}- metadata={{- table: resourceId,- column: x.id,- }}- onDesciptionUpdated={refreshDocs}- />- </article>- <article className="code">- <CodeSnippet- selectedLang={selectedLang}- snippet={Snippets.readColumns({- title: `Select ${x.id}`,- resourceId,- endpoint: autoApiService.endpoint,- apiKey: keyToShow,- columnName: x.id,- })}- />- </article>- </div>- ))}- </div>- )}- {methods.includes('GET') && (- <>- <h3 className="text-scale-1200 mt-4 px-6">Read rows</h3>- <div className="doc-section">- <article className="text ">- <p>- To read rows in <code>{resourceId}</code>, use the <code>select</code> method.- </p>- <p>- <a href="https://supabase.com/docs/client/select" target="_blank">- Learn more.- </a>- </p>- </article>- <article className="code">- <CodeSnippet- selectedLang={selectedLang}- snippet={Snippets.readAll(resourceId, autoApiService.endpoint, keyToShow)}- />- <CodeSnippet- selectedLang={selectedLang}- snippet={Snippets.readColumns({- resourceId,- endpoint: autoApiService.endpoint,- apiKey: keyToShow,- })}- />- <CodeSnippet- selectedLang={selectedLang}- snippet={Snippets.readForeignTables(resourceId, autoApiService.endpoint, keyToShow)}- />- <CodeSnippet- selectedLang={selectedLang}- snippet={Snippets.readRange(resourceId, autoApiService.endpoint, keyToShow)}- />- </article>- </div>- <div className="doc-section">- <article className="text ">- <h4 className="mt-0 text-white">Filtering</h4>- <p>Supabase provides a wide range of filters.</p>- <p>- <a href="https://supabase.com/docs/client/using-filters" target="_blank">- Learn more.- </a>- </p>- </article>- <article className="code">- <CodeSnippet- selectedLang={selectedLang}- snippet={Snippets.readFilters(resourceId, autoApiService.endpoint, keyToShow)}- />- </article>- </div>- </>- )}- {methods.includes('POST') && (- <>- <h3 className="text-scale-1200 mt-4 px-6">Insert rows</h3>- <div className="doc-section">- <article className="text ">- <p>- <code>insert</code> lets you insert into your tables. You can also insert in bulk- and do UPSERT.- </p>- <p>- <code>insert</code> will also return the replaced values for UPSERT.- </p>- <p>- <a href="https://supabase.com/docs/client/insert" target="_blank">- Learn more.- </a>- </p>- </article>- <article className="code">- <CodeSnippet- selectedLang={selectedLang}- snippet={Snippets.insertSingle(resourceId, autoApiService.endpoint, keyToShow)}- />- <CodeSnippet- selectedLang={selectedLang}- snippet={Snippets.insertMany(resourceId, autoApiService.endpoint, keyToShow)}- />- <CodeSnippet- selectedLang={selectedLang}- snippet={Snippets.upsert(resourceId, autoApiService.endpoint, keyToShow)}- />- </article>- </div>- </>- )}- {methods.includes('PATCH') && (- <>- <h3 className="text-scale-1200 mt-4 px-6">Update rows</h3>- <div className="doc-section">- <article className="text ">- <p>- <code>update</code> lets you update rows. <code>update</code> will match all rows by- default. You can update specific rows using horizontal filters, e.g. <code>eq</code>- , <code>lt</code>, and <code>is</code>.- </p>- <p>- <code>update</code> will also return the replaced values for UPDATE.- </p>- <p>- <a href="https://supabase.com/docs/client/update" target="_blank">- Learn more.- </a>- </p>- </article>- <article className="code">- <CodeSnippet- selectedLang={selectedLang}- snippet={Snippets.update(resourceId, autoApiService.endpoint, keyToShow)}- />- </article>- </div>- </>- )}- {methods.includes('DELETE') && (- <>- <h3 className="text-scale-1200 mt-4 px-6">Delete rows</h3>- <div className="doc-section">- <article className="text ">- <p>- <code>delete</code> lets you delete rows. <code>delete</code> will match all rows by- default, so remember to specify your filters!- </p>- <p>- <a href="https://supabase.com/docs/client/delete" target="_blank">- Learn more.- </a>- </p>- </article>- <article className="code">- <CodeSnippet- selectedLang={selectedLang}- snippet={Snippets.delete(resourceId, autoApiService.endpoint, keyToShow)}- />- </article>- </div>- </>- )}- <>- <h3 className="text-scale-1200 mt-4 px-6">Subscribe to changes</h3>- <div className="doc-section">- <article className="text ">- <p>- Supabase provides realtime functionality and broadcasts database changes to authorized- users depending on Row Level Security (RLS) policies.- </p>- <p>- <a href="https://supabase.com/docs/client/subscribe" target="_blank">- Learn more.- </a>- </p>- </article>- <article className="code">- <CodeSnippet- selectedLang={selectedLang}- snippet={Snippets.subscribeAll(resourceMeta.camelCase, resourceId)}- />- <CodeSnippet- selectedLang={selectedLang}- snippet={Snippets.subscribeInserts(resourceMeta.camelCase, resourceId)}- />- <CodeSnippet- selectedLang={selectedLang}- snippet={Snippets.subscribeUpdates(resourceMeta.camelCase, resourceId)}- />- <CodeSnippet- selectedLang={selectedLang}- snippet={Snippets.subscribeDeletes(resourceMeta.camelCase, resourceId)}- />- <CodeSnippet- selectedLang={selectedLang}- snippet={Snippets.subscribeEq(- resourceMeta.camelCase,- resourceId,- 'column_name',- 'someValue'- )}- />- </article>- </div>- </>- <>- <h3 className="text-scale-1200 mt-4 px-6">Much more</h3>- <div className="doc-section py-4">- <article className="text ">- <p>- These docs are a work in progress! See our{' '}- <a href="https://supabase.com/docs/" target="_blank">- docs- </a>{' '}- for the additional functionality Supabase has to offer.- </p>- </article>- <article className="code"></article>- </div>- </>- </>- )-}