The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
refactor(docs): migrate cli reference to app router (#29117)
Charis84a8fa7ac35e
diff --git a/apps/docs/app/api/crawlers/route.ts b/apps/docs/app/api/crawlers/route.tsindex 51850fa26e3..fb2f68fdb9c 100644--- a/apps/docs/app/api/crawlers/route.ts+++ b/apps/docs/app/api/crawlers/route.ts@@ -14,7 +14,7 @@ import {} from '~/features/docs/Reference.generated.singleton'import { getRefMarkdown } from '~/features/docs/Reference.mdx'import type { MethodTypes } from '~/features/docs/Reference.typeSpec'-import type { AbbrevCommonClientLibSection } from '~/features/docs/Reference.utils'+import type { AbbrevApiReferenceSection } from '~/features/docs/Reference.utils'import { notFoundLink } from '~/features/recommendations/NotFound.utils'import { BASE_PATH } from '~/lib/constants'@@ -30,8 +30,8 @@ export async function GET(request: Request) {slug = maybeVersion}- let section: AbbrevCommonClientLibSection- let sectionsWithUrl: Array<AbbrevCommonClientLibSection & { url: URL }>+ let section: AbbrevApiReferenceSection+ let sectionsWithUrl: Array<AbbrevApiReferenceSection & { url: URL }>try {const flattenedSections = (await getFlattenedSections(lib, version)) ?? []sectionsWithUrl = flattenedSections.map((section) => {@@ -72,7 +72,7 @@ function htmlShell(lib: string,version: string | null,slug: string,- section: AbbrevCommonClientLibSection,+ section: AbbrevApiReferenceSection,body: string) {const libraryName = REFERENCES[lib].name@@ -96,7 +96,7 @@ function htmlShell()}-function libraryNav(sections: Array<AbbrevCommonClientLibSection & { url: URL }>) {+function libraryNav(sections: Array<AbbrevApiReferenceSection & { url: URL }>) {return ('<nav><ul>' +sections@@ -106,7 +106,7 @@ function libraryNav(sections: Array<AbbrevCommonClientLibSection & { url: URL }>)}-async function sectionDetails(lib: string, version: string, section: AbbrevCommonClientLibSection) {+async function sectionDetails(lib: string, version: string, section: AbbrevApiReferenceSection) {const libraryName = REFERENCES[lib].namelet result = '<h1>' + (libraryName + ': ' + section.title ?? '') + '</h1>'@@ -119,11 +119,7 @@ async function sectionDetails(lib: string, version: string, section: AbbrevCommoreturn result}-async function markdown(- lib: string,- version: string | null,- section: AbbrevCommonClientLibSection-) {+async function markdown(lib: string, version: string | null, section: AbbrevApiReferenceSection) {const dir = !!section.meta?.shared ? 'shared' : lib + (version ? '/' + version : '')let content = await getRefMarkdown(dir + '/' + section.slug)@@ -134,7 +130,7 @@ async function markdown(async function functionDetails(lib: string,version: string | null,- section: AbbrevCommonClientLibSection+ section: AbbrevApiReferenceSection) {const libraryMeta = REFERENCES[lib]diff --git a/apps/docs/app/reference/[...slug]/page.tsx b/apps/docs/app/reference/[...slug]/page.tsxindex 43f8903399d..5859b8f563d 100644--- a/apps/docs/app/reference/[...slug]/page.tsx+++ b/apps/docs/app/reference/[...slug]/page.tsx@@ -1,6 +1,7 @@import { redirect } from 'next/navigation'import { REFERENCES } from '~/content/navigation.references'+import { CliReferencePage } from '~/features/docs/Reference.cliPage'import { ClientSdkReferencePage } from '~/features/docs/Reference.sdkPage'import {generateReferenceMetadata,@@ -21,7 +22,7 @@ export default async function ReferencePage({const parsedPath = parseReferencePath(slug)const isClientSdkReference = parsedPath.__type === 'clientSdk'-+ const isCliReference = parsedPath.__type === 'cli'if (isClientSdkReference) {const { sdkId, maybeVersion, path } = parsedPath@@ -32,8 +33,10 @@ export default async function ReferencePage({await redirectNonexistentReferenceSection(sdkId, version, path, version === latestVersion)return <ClientSdkReferencePage sdkId={sdkId} libVersion={version} />+ } else if (isCliReference) {+ return <CliReferencePage />} else {- // Unimplemented -- eventually API and CLI+ // Unimplemented -- eventually APIredirect(notFoundLink(slug.join('/')))}}diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.Context.tsx b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.Context.tsxindex f4fb58904cf..dd26ebb55c4 100644--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.Context.tsx+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.Context.tsx@@ -1,3 +1,5 @@+'use client'+import { createContext, useContext } from 'react'interface ContextProps {diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.tsindex e31cdb31931..82f44a46ef8 100644--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts@@ -2252,6 +2252,10 @@ export const reference_cli = {title: 'Supabase CLI',url: '/guides/reference/cli',parent: '/',+ pkg: {+ name: 'supabase',+ repo: 'https://github.com/supabase/cli',+ },}export const reference_api = {icon: 'reference-api',diff --git a/apps/docs/content/navigation.references.ts b/apps/docs/content/navigation.references.tsindex fb56ab7c6c7..9239014cf15 100644--- a/apps/docs/content/navigation.references.ts+++ b/apps/docs/content/navigation.references.ts@@ -107,6 +107,7 @@ export const REFERENCES = {cli: {type: 'cli',name: 'CLI',+ libPath: 'cli',versions: [],icon: 'reference-cli',},diff --git a/apps/docs/features/docs/Reference.cliPage.tsx b/apps/docs/features/docs/Reference.cliPage.tsxnew file mode 100644index 00000000000..9d549b5d858--- /dev/null+++ b/apps/docs/features/docs/Reference.cliPage.tsx@@ -0,0 +1,40 @@+import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'+import { reference_cli } from '~/components/Navigation/NavigationMenu/NavigationMenu.constants'+import { ClientLibIntroduction } from '~/features/docs/Reference.introduction'+import { ReferenceNavigation } from '~/features/docs/Reference.navigation'+import { ReferenceContentScrollHandler } from '~/features/docs/Reference.navigation.client'+import { RefSections } from '~/features/docs/Reference.sections'+import { LayoutMainContent } from '~/layouts/DefaultLayout'+import { SidebarSkeleton } from '~/layouts/MainSkeleton'++export async function CliReferencePage() {+ return (+ <ReferenceContentScrollHandler libPath="cli" version="latest" isLatestVersion={true}>+ <SidebarSkeleton+ menuId={MenuId.RefCli}+ NavigationMenu={+ <ReferenceNavigation+ libraryId="cli"+ name="Supabase CLI"+ menuData={reference_cli}+ libPath="cli"+ version="latest"+ isLatestVersion={true}+ />+ }+ >+ <LayoutMainContent>+ <article className="@container/article">+ <ClientLibIntroduction+ libPath="cli"+ version="latest"+ isLatestVersion={true}+ className="max-w-[unset]"+ />+ <RefSections libraryId="cli" version="latest" />+ </article>+ </LayoutMainContent>+ </SidebarSkeleton>+ </ReferenceContentScrollHandler>+ )+}diff --git a/apps/docs/features/docs/Reference.generated.script.ts b/apps/docs/features/docs/Reference.generated.script.tsindex 860ac2d272b..87678489ea3 100644--- a/apps/docs/features/docs/Reference.generated.script.ts+++ b/apps/docs/features/docs/Reference.generated.script.ts@@ -6,9 +6,10 @@ import { parse } from 'yaml'import { REFERENCES, clientSdkIds } from '~/content/navigation.references'import { parseTypeSpec } from '~/features/docs/Reference.typeSpec'-import type { AbbrevCommonClientLibSection } from '~/features/docs/Reference.utils'+import type { AbbrevApiReferenceSection } from '~/features/docs/Reference.utils'import { deepFilterRec } from '~/features/helpers.fn'import type { Json } from '~/features/helpers.types'+import cliCommonSections from '~/spec/common-cli-sections.json' assert { type: 'json' }import commonClientLibSections from '~/spec/common-client-libs-sections.json' assert { type: 'json' }const DOCS_DIRECTORY = join(dirname(fileURLToPath(import.meta.url)), '../..')@@ -18,7 +19,7 @@ const GENERATED_DIRECTORY = join(dirname(fileURLToPath(import.meta.url)), 'generasync function getSpec(specFile: string, { ext = 'yml' }: { ext?: string } = {}) {const specFullPath = join(SPEC_DIRECTORY, `${specFile}.${ext}`)const rawSpec = await readFile(specFullPath, 'utf-8')- return ext === 'yml' ? parse(rawSpec) : rawSpec+ return ext === 'yml' || ext === 'yaml' ? parse(rawSpec) : rawSpec}async function parseFnsList(rawSpec: Json): Promise<Array<{ id: unknown }>> {@@ -34,7 +35,7 @@ async function parseFnsList(rawSpec: Json): Promise<Array<{ id: unknown }>> {function genClientSdkSectionTree(fns: Array<{ id: unknown }>, excludeName: string) {const validSections = deepFilterRec(- commonClientLibSections as Array<AbbrevCommonClientLibSection>,+ commonClientLibSections as Array<AbbrevApiReferenceSection>,'items',(section) =>section.type === 'markdown' || section.type === 'category'@@ -46,7 +47,19 @@ function genClientSdkSectionTree(fns: Array<{ id: unknown }>, excludeName: strinreturn validSections}-export function flattenCommonClientLibSections(tree: Array<AbbrevCommonClientLibSection>) {+async function genCliSectionTree() {+ const cliSpec = await getSpec('cli_v1_commands', { ext: 'yaml' })++ const validSections = deepFilterRec(+ cliCommonSections as Array<AbbrevApiReferenceSection>,+ 'items',+ (section) =>+ section.type === 'cli-command' ? cliSpec.commands.some(({ id }) => id === section.id) : true+ )+ return validSections+}++export function flattenCommonClientLibSections(tree: Array<AbbrevApiReferenceSection>) {return tree.reduce((acc, elem) => {if ('items' in elem) {const prunedElem = { ...elem }@@ -58,7 +71,7 @@ export function flattenCommonClientLibSections(tree: Array<AbbrevCommonClientLib}return acc- }, [] as Array<AbbrevCommonClientLibSection>)+ }, [] as Array<AbbrevApiReferenceSection>)}async function writeTypes() {@@ -95,29 +108,56 @@ async function writeReferenceSections() {JSON.stringify(fnsList))- const sectionTree = genClientSdkSectionTree(fnsList, REFERENCES[sdkId].meta[version].libId)- const pendingSectionTreeWrite = writeFile(+ const sdkSectionTree = genClientSdkSectionTree(+ fnsList,+ REFERENCES[sdkId].meta[version].libId+ )+ const pendingSdkSectionTreeWrite = writeFile(join(GENERATED_DIRECTORY, `${sdkId}.${version}.sections.json`),- JSON.stringify(sectionTree)+ JSON.stringify(sdkSectionTree)+ )++ const cliSectionTree = await genCliSectionTree()+ const pendingCliSectionTreeWrite = writeFile(+ join(GENERATED_DIRECTORY, 'cli.latest.sections.json'),+ JSON.stringify(cliSectionTree))- const flattened = flattenCommonClientLibSections(sectionTree)- const pendingFlattenedWrite = writeFile(+ const flattenedSdkSections = flattenCommonClientLibSections(sdkSectionTree)+ const pendingFlattenedSdkSectionsWrite = writeFile(join(GENERATED_DIRECTORY, `${sdkId}.${version}.flat.json`),- JSON.stringify(flattened)+ JSON.stringify(flattenedSdkSections)+ )++ const flattenedCliSections = flattenCommonClientLibSections(cliSectionTree)+ const pendingFlattenedCliSectionsWrite = writeFile(+ join(GENERATED_DIRECTORY, 'cli.latest.flat.json'),+ JSON.stringify(flattenedCliSections))- const sectionsBySlug = keyBy(flattened, (section) => section.slug)- const pendingSlugDictionaryWrite = writeFile(+ const sdkSectionsBySlug = keyBy(flattenedSdkSections, (section) => section.slug)+ const pendingSdkSlugDictionaryWrite = writeFile(join(GENERATED_DIRECTORY, `${sdkId}.${version}.bySlug.json`),- JSON.stringify(sectionsBySlug)+ JSON.stringify(sdkSectionsBySlug)+ )++ const cliSectionsBySlug = keyBy(+ flattenedCliSections.filter(({ slug }) => !!slug),+ (section) => section.slug+ )+ const pendingCliSlugDictionaryWrite = writeFile(+ join(GENERATED_DIRECTORY, 'cli.latest.bySlug.json'),+ JSON.stringify(cliSectionsBySlug))return [pendingFnListWrite,- pendingSectionTreeWrite,- pendingFlattenedWrite,- pendingSlugDictionaryWrite,+ pendingSdkSectionTreeWrite,+ pendingCliSectionTreeWrite,+ pendingFlattenedSdkSectionsWrite,+ pendingFlattenedCliSectionsWrite,+ pendingSdkSlugDictionaryWrite,+ pendingCliSlugDictionaryWrite,]}))diff --git a/apps/docs/features/docs/Reference.generated.singleton.ts b/apps/docs/features/docs/Reference.generated.singleton.tsindex 27b185b4052..ede3ac8cb64 100644--- a/apps/docs/features/docs/Reference.generated.singleton.ts+++ b/apps/docs/features/docs/Reference.generated.singleton.ts@@ -1,8 +1,10 @@import { readFile } from 'node:fs/promises'import { join } from 'node:path'+import { parse } from 'yaml'import type { ModuleTypes } from '~/features/docs/Reference.typeSpec'-import type { AbbrevCommonClientLibSection } from '~/features/docs/Reference.utils'+import type { AbbrevApiReferenceSection } from '~/features/docs/Reference.utils'+import { type Json } from '../helpers.types'let typeSpec: Array<ModuleTypes>@@ -34,6 +36,17 @@ export async function getTypeSpec(ref: string) {return mod?.methods.get(ref)}+let cliSpec: Json++export async function getCliSpec() {+ if (!cliSpec) {+ const rawSpec = await readFile(join(process.cwd(), 'spec', 'cli_v1_commands.yaml'), 'utf-8')+ cliSpec = parse(rawSpec)+ }++ return cliSpec+}+const functionsList = new Map<string, Array<{ id: unknown }>>()export async function getFunctionsList(sdkId: string, version: string) {@@ -50,7 +63,7 @@ export async function getFunctionsList(sdkId: string, version: string) {return functionsList.get(key)}-const referenceSections = new Map<string, Array<AbbrevCommonClientLibSection>>()+const referenceSections = new Map<string, Array<AbbrevApiReferenceSection>>()export async function getReferenceSections(sdkId: string, version: string) {const key = `${sdkId}.${version}`@@ -66,7 +79,7 @@ export async function getReferenceSections(sdkId: string, version: string) {return referenceSections.get(key)}-const flatSections = new Map<string, Array<AbbrevCommonClientLibSection>>()+const flatSections = new Map<string, Array<AbbrevApiReferenceSection>>()export async function getFlattenedSections(sdkId: string, version: string) {const key = `${sdkId}.${version}`@@ -82,7 +95,7 @@ export async function getFlattenedSections(sdkId: string, version: string) {return flatSections.get(key)}-const sectionsBySlug = new Map<string, Map<string, AbbrevCommonClientLibSection>>()+const sectionsBySlug = new Map<string, Map<string, AbbrevApiReferenceSection>>()export async function getSectionsBySlug(sdkId: string, version: string) {const key = `${sdkId}.${version}`diff --git a/apps/docs/features/docs/Reference.introduction.tsx b/apps/docs/features/docs/Reference.introduction.tsxindex c8ae9c7a809..66e4609c77d 100644--- a/apps/docs/features/docs/Reference.introduction.tsx+++ b/apps/docs/features/docs/Reference.introduction.tsx@@ -3,28 +3,29 @@ import Link from 'next/link'import { Alert_Shadcn_, AlertDescription_Shadcn_, AlertTitle_Shadcn_, cn } from 'ui'-import { MDXRemoteBase } from '~/features/docs/MdxBase'-import { getRefMarkdown } from '~/features/docs/Reference.mdx'+import { getRefMarkdown, MDXRemoteRefs } from '~/features/docs/Reference.mdx'import { ReferenceSectionWrapper } from '~/features/docs/Reference.ui.client'import commonClientLibSections from '~/spec/common-client-libs-sections.json' assert { type: 'json' }-function hasIntro(sections: typeof commonClientLibSections, excludeName: string) {+function hasIntro(sections: typeof commonClientLibSections, excludeName?: string) {return Boolean(sections[0]?.type === 'markdown' &§ions[0]?.slug === 'introduction' &&- !(- 'excludes' in sections[0] &&- Array.isArray(sections[0].excludes) &&- sections[0].excludes?.includes(excludeName)- )+ (!excludeName ||+ !(+ 'excludes' in sections[0] &&+ Array.isArray(sections[0].excludes) &&+ sections[0].excludes?.includes(excludeName)+ )))}interface ClientLibIntroductionProps {libPath: string- excludeName: string+ excludeName?: stringversion: stringisLatestVersion: boolean+ className?: string}export async function ClientLibIntroduction({@@ -32,6 +33,7 @@ export async function ClientLibIntroduction({excludeName,version,isLatestVersion,+ className,}: ClientLibIntroductionProps) {if (!hasIntro(commonClientLibSections, excludeName)) return null@@ -43,9 +45,9 @@ export async function ClientLibIntroduction({<ReferenceSectionWrapperid="introduction"link={`/docs/reference/${libPath}/${isLatestVersion ? '' : `${version}/`}introduction`}- className="prose"+ className={cn('prose', className)}>- <MDXRemoteBase source={content} />+ <MDXRemoteRefs source={content} /></ReferenceSectionWrapper>)}diff --git a/apps/docs/features/docs/Reference.mdx.tsx b/apps/docs/features/docs/Reference.mdx.tsxindex d5d326a1426..1024e5771ad 100644--- a/apps/docs/features/docs/Reference.mdx.tsx+++ b/apps/docs/features/docs/Reference.mdx.tsx@@ -2,6 +2,7 @@ import matter from 'gray-matter'import { readFile } from 'node:fs/promises'import { join } from 'node:path'+import CliGlobalFlagsHandler from '~/components/reference/enrichments/cli/CliGlobalFlagsHandler'import { MDXRemoteBase } from '~/features/docs/MdxBase'import { components } from '~/features/docs/MdxBase.shared'import { RefSubLayout } from '~/features/docs/Reference.ui'@@ -41,7 +42,7 @@ interface MDXRemoteRefsProps {}function MDXRemoteRefs({ source }: MDXRemoteRefsProps) {- const refComponents = { ...components, RefSubLayout }+ const refComponents = { ...components, RefSubLayout, CliGlobalFlagsHandler }return <MDXRemoteBase source={source} components={refComponents} />}diff --git a/apps/docs/features/docs/Reference.navigation.client.tsx b/apps/docs/features/docs/Reference.navigation.client.tsxindex ef2c860f0b9..11d926481b6 100644--- a/apps/docs/features/docs/Reference.navigation.client.tsx+++ b/apps/docs/features/docs/Reference.navigation.client.tsx@@ -1,6 +1,7 @@'use client'import * as Collapsible from '@radix-ui/react-collapsible'+import { debounce } from 'lodash'import { ChevronUp } from 'lucide-react'import Link from 'next/link'@@ -11,7 +12,7 @@ import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useimport { cn } from 'ui'import { BASE_PATH } from '~/lib/constants'-import type { AbbrevCommonClientLibSection } from '~/features/docs/Reference.navigation'+import type { AbbrevApiReferenceSection } from '~/features/docs/Reference.utils'import { isElementInViewport } from '~/features/ui/helpers.dom'export const ReferenceContentInitiallyScrolledContext = createContext<boolean>(false)@@ -91,7 +92,7 @@ export function ReferenceNavigationScrollHandler({)}-function deriveHref(basePath: string, section: AbbrevCommonClientLibSection) {+function deriveHref(basePath: string, section: AbbrevApiReferenceSection) {return 'slug' in section ? `${basePath}/${section.slug}` : ''}@@ -105,6 +106,48 @@ function getLinkStyles(isActive: boolean, className?: string) {)}+/**+ * Creates a function that navigates to a reference subsection.+ *+ * Since reference "pages" are actually an agglomeration of many "pages", we+ * don't want to actually complete a full page navigation.+ *+ * @param href - The path to the navigation target.+ * @param sectionSlug - The slug of the section to navigate to.+ * @returns A function that navigates to the reference subsection.+ */+function createReferenceSubsectionNavigator(href: string, sectionSlug?: string) {+ return function navigateToReferenceSubsection(evt: MouseEvent) {+ if (sectionSlug) {+ evt.preventDefault()+ history.pushState({}, '', `${BASE_PATH}${href}`)++ const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches+ const domElement = document.getElementById(sectionSlug)+ domElement?.scrollIntoView({+ behavior: reduceMotion ? 'auto' : 'smooth',+ })+ domElement?.querySelector('h2')?.focus()+ }+ }+}++export function RefInternalLink({+ href,+ sectionSlug,+ children,+}: {+ href: string+ sectionSlug?: string+ children: React.ReactNode+}) {+ return (+ <Link href={href} onClick={createReferenceSubsectionNavigator(href, sectionSlug)}>+ {children}+ </Link>+ )+}+export function RefLink({basePath,section,@@ -112,7 +155,7 @@ export function RefLink({className,}: {basePath: string- section: AbbrevCommonClientLibSection+ section: AbbrevApiReferenceSectionskipChildren?: booleanclassName?: string}) {@@ -137,23 +180,7 @@ export function RefLink({href={href}aria-current={isActive ? 'page' : false}className={getLinkStyles(isActive, className)}- onClick={(evt: MouseEvent) => {- /*- * We don't actually want to navigate or rerender anything since- * links are all to sections on the same page.- */- evt.preventDefault()- history.pushState({}, '', `${BASE_PATH}${href}`)-- if ('slug' in section) {- const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches- const domElement = document.getElementById(section.slug)- domElement?.scrollIntoView({- behavior: reduceMotion ? 'auto' : 'smooth',- })- domElement?.querySelector('h2')?.focus()- }- }}+ onClick={createReferenceSubsectionNavigator(href, section.slug)}>{section.title}</Link>@@ -162,7 +189,7 @@ export function RefLink({)}-function useCompoundRefLinkActive(basePath: string, section: AbbrevCommonClientLibSection) {+function useCompoundRefLinkActive(basePath: string, section: AbbrevApiReferenceSection) {const [open, _setOpen] = useState(false)const pathname = usePathname()@@ -195,7 +222,7 @@ function CompoundRefLink({section,}: {basePath: string- section: AbbrevCommonClientLibSection+ section: AbbrevApiReferenceSection}) {const { open, setOpen, isActive } = useCompoundRefLinkActive(basePath, section)diff --git a/apps/docs/features/docs/Reference.navigation.tsx b/apps/docs/features/docs/Reference.navigation.tsxindex cc74f48821a..eedb4e4e058 100644--- a/apps/docs/features/docs/Reference.navigation.tsx+++ b/apps/docs/features/docs/Reference.navigation.tsx@@ -9,10 +9,10 @@ import {RefLink,ReferenceNavigationScrollHandler,} from '~/features/docs/Reference.navigation.client'-import { type AbbrevCommonClientLibSection } from '~/features/docs/Reference.utils'+import { type AbbrevApiReferenceSection } from '~/features/docs/Reference.utils'-interface ClientSdkNavigationProps {- sdkId: string+interface ReferenceNavigationProps {+ libraryId: stringname: stringmenuData: { icon?: string }libPath: string@@ -20,15 +20,15 @@ interface ClientSdkNavigationProps {isLatestVersion: boolean}-async function ClientSdkNavigation({- sdkId,+export async function ReferenceNavigation({+ libraryId,name,menuData,libPath,version,isLatestVersion,-}: ClientSdkNavigationProps) {- const navSections = await getReferenceSections(sdkId, version)+}: ReferenceNavigationProps) {+ const navSections = await getReferenceSections(libraryId, version)const basePath = `/reference/${libPath}${isLatestVersion ? '' : `/${version}`}`@@ -65,7 +65,7 @@ function RefCategory({section,}: {basePath: string- section: AbbrevCommonClientLibSection+ section: AbbrevApiReferenceSection}) {if (!('items' in section && section.items.length > 0)) return null@@ -100,6 +100,3 @@ function SideMenuTitle({ children, className }: PropsWithChildren<{ className?:</div>)}--export { ClientSdkNavigation }-export type { AbbrevCommonClientLibSection }diff --git a/apps/docs/features/docs/Reference.sdkPage.tsx b/apps/docs/features/docs/Reference.sdkPage.tsxindex 30b3d32a9d9..71a07857641 100644--- a/apps/docs/features/docs/Reference.sdkPage.tsx+++ b/apps/docs/features/docs/Reference.sdkPage.tsx@@ -1,11 +1,10 @@-import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'import * as NavItems from '~/components/Navigation/NavigationMenu/NavigationMenu.constants'import { REFERENCES } from '~/content/navigation.references'import { ClientLibHeader } from '~/features/docs/Reference.header'import { ClientLibIntroduction, OldVersionAlert } from '~/features/docs/Reference.introduction'-import { ClientSdkNavigation } from '~/features/docs/Reference.navigation'+import { ReferenceNavigation } from '~/features/docs/Reference.navigation'import { ReferenceContentScrollHandler } from '~/features/docs/Reference.navigation.client'-import { ClientLibRefSections } from '~/features/docs/Reference.sections'+import { RefSections } from '~/features/docs/Reference.sections'import { LayoutMainContent } from '~/layouts/DefaultLayout'import { SidebarSkeleton } from '~/layouts/MainSkeleton'@@ -28,10 +27,10 @@ export async function ClientSdkReferencePage({ sdkId, libVersion }: ClientSdkRefisLatestVersion={isLatestVersion}><SidebarSkeleton- menuId={MenuId.RefJavaScriptV2}+ menuId={libraryMeta.meta[libVersion].libId}NavigationMenu={- <ClientSdkNavigation- sdkId={sdkId}+ <ReferenceNavigation+ libraryId={sdkId}name={menuData.title}menuData={menuData}libPath={libraryMeta.libPath}@@ -55,7 +54,7 @@ export async function ClientSdkReferencePage({ sdkId, libVersion }: ClientSdkRefversion={libVersion}isLatestVersion={isLatestVersion}/>- <ClientLibRefSections sdkId={sdkId} version={libVersion} />+ <RefSections libraryId={sdkId} version={libVersion} /></article></LayoutMainContent></SidebarSkeleton>diff --git a/apps/docs/features/docs/Reference.sections.tsx b/apps/docs/features/docs/Reference.sections.tsxindex 16176203f96..a241e15cf6b 100644--- a/apps/docs/features/docs/Reference.sections.tsx+++ b/apps/docs/features/docs/Reference.sections.tsx@@ -1,12 +1,20 @@import { Fragment } from 'react'--import { Tabs_Shadcn_, TabsContent_Shadcn_, TabsList_Shadcn_, TabsTrigger_Shadcn_, cn } from 'ui'+import ReactMarkdown from 'react-markdown'+import {+ Tabs_Shadcn_,+ TabsContent_Shadcn_,+ TabsList_Shadcn_,+ TabsTrigger_Shadcn_,+ cn,+ CodeBlock,+} from 'ui'import { REFERENCES } from '~/content/navigation.references'import { MDXRemoteRefs, getRefMarkdown } from '~/features/docs/Reference.mdx'import { MDXProviderReference } from '~/features/docs/Reference.mdx.client'import type { MethodTypes } from '~/features/docs/Reference.typeSpec'import {+ getCliSpec,getFlattenedSections,getFunctionsList,getTypeSpec,@@ -15,19 +23,21 @@ import {CollapsibleDetails,FnParameterDetails,RefSubLayout,+ RequiredBadge,ReturnTypeDetails,StickyHeader,} from '~/features/docs/Reference.ui'-import type { AbbrevCommonClientLibSection } from '~/features/docs/Reference.utils'+import type { AbbrevApiReferenceSection } from '~/features/docs/Reference.utils'import { normalizeMarkdown } from '~/features/docs/Reference.utils'+import { RefInternalLink } from './Reference.navigation.client'-type ClientLibRefSectionsProps = {- sdkId: string+type RefSectionsProps = {+ libraryId: stringversion: string}-async function ClientLibRefSections({ sdkId, version }: ClientLibRefSectionsProps) {- let flattenedSections = await getFlattenedSections(sdkId, version)+async function RefSections({ libraryId, version }: RefSectionsProps) {+ let flattenedSections = await getFlattenedSections(libraryId, version)flattenedSections = trimIntro(flattenedSections)return (@@ -38,7 +48,7 @@ async function ClientLibRefSections({ sdkId, version }: ClientLibRefSectionsProp.map((section, idx) => (<Fragment key={`${section.id}-${idx}`}><SectionDivider />- <SectionSwitch sdkId={sdkId} version={version} section={section} />+ <SectionSwitch libraryId={libraryId} version={version} section={section} /></Fragment>))}</div>@@ -46,7 +56,7 @@ async function ClientLibRefSections({ sdkId, version }: ClientLibRefSectionsProp)}-function trimIntro(sections: Array<AbbrevCommonClientLibSection>) {+function trimIntro(sections: Array<AbbrevApiReferenceSection>) {const hasIntro = sections[0]?.type === 'markdown' && sections[0]?.slug === 'introduction'if (hasIntro) {return sections.slice(1)@@ -59,14 +69,15 @@ function SectionDivider() {}type SectionSwitchProps = {- sdkId: string+ libraryId: stringversion: string- section: AbbrevCommonClientLibSection+ section: AbbrevApiReferenceSection}-export function SectionSwitch({ sdkId, version, section }: SectionSwitchProps) {- const libPath = REFERENCES[sdkId].libPath- const isLatestVersion = version === REFERENCES[sdkId].versions[0]+export function SectionSwitch({ libraryId, version, section }: SectionSwitchProps) {+ const libPath = REFERENCES[libraryId].libPath+ const allAvailableVersions = REFERENCES[libraryId].versions+ const isLatestVersion = allAvailableVersions.length === 0 || version === allAvailableVersions[0]const sectionLink = `/docs/reference/${libPath}/${isLatestVersion ? '' : `${version}/`}${section.slug}`@@ -84,13 +95,15 @@ export function SectionSwitch({ sdkId, version, section }: SectionSwitchProps) {case 'function':return (<FunctionSection- sdkId={sdkId}+ sdkId={libraryId}version={version}link={sectionLink}section={section}- useTypeSpec={REFERENCES[sdkId].typeSpec}+ useTypeSpec={REFERENCES[libraryId].typeSpec}/>)+ case 'cli-command':+ return <CliCommandSection link={sectionLink} section={section} />default:console.error(`Unhandled type in reference sections: ${section.type}`)return null@@ -102,7 +115,7 @@ interface MarkdownSectionProps {version: stringisLatestVersion: booleanlink: string- section: AbbrevCommonClientLibSection+ section: AbbrevApiReferenceSection}async function MarkdownSection({@@ -126,11 +139,121 @@ async function MarkdownSection({)}+interface CliCommandSectionProps {+ link: string+ section: AbbrevApiReferenceSection+}++async function CliCommandSection({ link, section }: CliCommandSectionProps) {+ const cliSpec = await getCliSpec()+ const command = ((cliSpec as any).commands ?? []).find((cmd) => cmd.id === section.id)++ if (!command) return null++ return (+ <RefSubLayout.Section columns="double" link={link} {...section}>+ <StickyHeader title={command.title} className="col-[1_/_-1]" monoFont={true} />+ <div>+ {command.description && (+ <ReactMarkdown className="prose break-words mb-8">{command.description}</ReactMarkdown>+ )}+ {(command.subcommands ?? []).length > 0 && (+ <>+ <h3 className="mb-3 text-base text-foreground">Subcommands</h3>+ <ul className="prose">+ {command.subcommands.map((subcommand, index) => {+ const subcommandDetails = (cliSpec as any).commands.find(+ (cmd) => cmd.id === subcommand+ )+ if (!subcommandDetails) return null+ return (+ <li key={index} className="ml-4">+ <RefInternalLink+ href={`/reference/cli/${subcommandDetails.id}`}+ sectionSlug={subcommandDetails.id}+ >+ {subcommandDetails.title}+ </RefInternalLink>+ </li>+ )+ })}+ </ul>+ </>+ )}+ {(command.flags ?? []).length > 0 && (+ <>+ <h3 className="mb-3 text-base text-foreground">Flags</h3>+ <ul>+ {command.flags.map((flag, index) => (+ <li key={index} className="border-t last-of-type:border-b py-5 flex flex-col gap-3">+ <div className="flex flex-wrap items-baseline gap-3">+ <span className="font-mono text-sm font-medium text-foreground">+ {flag.name}+ </span>+ <RequiredBadge isOptional={!flag.required} />+ </div>+ {flag.description && (+ <ReactMarkdown className="prose break-words text-sm">+ {flag.description}+ </ReactMarkdown>+ )}+ </li>+ ))}+ </ul>+ </>+ )}+ </div>+ <div className="overflow-auto">+ {'examples' in command &&+ Array.isArray(command.examples) &&+ command.examples.length > 0 && (+ <Tabs_Shadcn_ defaultValue={command.examples[0].id}>+ <TabsList_Shadcn_ className="flex-wrap gap-2 border-0">+ {command.examples.map((example) => (+ <TabsTrigger_Shadcn_+ key={example.id}+ value={example.id}+ className={cn(+ 'px-2.5 py-1 rounded-full',+ 'border-0 bg-surface-200 hover:bg-surface-300',+ 'text-xs text-foreground-lighter',+ // Undoing styles from primitive component+ 'data-[state=active]:border-0 data-[state=active]:shadow-0',+ 'data-[state=active]:bg-foreground data-[state=active]:text-background',+ 'transition'+ )}+ >+ {example.name}+ </TabsTrigger_Shadcn_>+ ))}+ </TabsList_Shadcn_>+ {command.examples.map((example) => (+ <TabsContent_Shadcn_ key={example.id} value={example.id}>+ <CodeBlock+ language="bash"+ className="p-4 rounded-md border"+ wrapperClassName="mb-8"+ >+ {example.code}+ </CodeBlock>+ <h3 className="text-foreground-lighter text-sm mb-2">Response</h3>+ <CodeBlock language="bash" className="p-4 rounded-md border">+ {example.response}+ </CodeBlock>+ </TabsContent_Shadcn_>+ ))}+ </Tabs_Shadcn_>+ )}+ </div>+ </RefSubLayout.Section>+ )+}+interface FunctionSectionProps {sdkId: stringversion: stringlink: string- section: AbbrevCommonClientLibSection+ section: AbbrevApiReferenceSectionuseTypeSpec: boolean}@@ -205,27 +328,25 @@ async function FunctionSection({</TabsTrigger_Shadcn_>))}</TabsList_Shadcn_>- {'examples' in fn &&- Array.isArray(fn.examples) &&- fn.examples.map((example) => (- <TabsContent_Shadcn_ key={example.id} value={example.id}>- <MDXRemoteRefs source={example.code} />- <div className="flex flex-col gap-2">- {!!example.data?.sql && (- <CollapsibleDetails title="Data source" content={example.data.sql} />- )}- {!!example.response && (- <CollapsibleDetails title="Response" content={example.response} />- )}- {!!example.description && (- <CollapsibleDetails- title="Notes"- content={normalizeMarkdown(example.description)}- />- )}- </div>- </TabsContent_Shadcn_>- ))}+ {fn.examples.map((example) => (+ <TabsContent_Shadcn_ key={example.id} value={example.id}>+ <MDXRemoteRefs source={example.code} />+ <div className="flex flex-col gap-2">+ {!!example.data?.sql && (+ <CollapsibleDetails title="Data source" content={example.data.sql} />+ )}+ {!!example.response && (+ <CollapsibleDetails title="Response" content={example.response} />+ )}+ {!!example.description && (+ <CollapsibleDetails+ title="Notes"+ content={normalizeMarkdown(example.description)}+ />+ )}+ </div>+ </TabsContent_Shadcn_>+ ))}</Tabs_Shadcn_>)}</div>@@ -233,4 +354,4 @@ async function FunctionSection({)}-export { ClientLibRefSections }+export { RefSections }diff --git a/apps/docs/features/docs/Reference.ui.tsx b/apps/docs/features/docs/Reference.ui.tsxindex 32770a45090..6631da1f364 100644--- a/apps/docs/features/docs/Reference.ui.tsx+++ b/apps/docs/features/docs/Reference.ui.tsx@@ -97,7 +97,7 @@ export function StickyHeader({ title, monoFont = false, className }: StickyHeade// spaced-out in regular position'pt-[calc(var(--header-height)+1rem)] -mt-[calc(var(--header-height)+1rem-2px)]',// Same for bottom- 'pb-8 -mb-4',+ 'pb-8 -mb-3','bg-gradient-to-b from-background from-85% to-transparent to-100%','text-2xl font-medium text-foreground','scroll-mt-[calc(var(--header-height)+1rem)]',@@ -308,7 +308,7 @@ function TypeSubDetails({)}-function RequiredBadge({ isOptional }: { isOptional: boolean | 'NA' }) {+export function RequiredBadge({ isOptional }: { isOptional: boolean | 'NA' }) {return isOptional === true ? (<span className="font-mono text-[10px] text-foreground-lighter tracking-wide">Optional</span>) : isOptional === false ? (diff --git a/apps/docs/features/docs/Reference.utils.ts b/apps/docs/features/docs/Reference.utils.tsindex bd262da6617..e8d9d046475 100644--- a/apps/docs/features/docs/Reference.utils.ts+++ b/apps/docs/features/docs/Reference.utils.ts@@ -11,12 +11,12 @@ import { getFlattenedSections } from '~/features/docs/Reference.generated.singleimport { generateOpenGraphImageMeta } from '~/features/seo/openGraph'import { BASE_PATH } from '~/lib/constants'-export interface AbbrevCommonClientLibSection {+export interface AbbrevApiReferenceSection {id: stringtype: stringtitle?: stringslug?: string- items?: Array<AbbrevCommonClientLibSection>+ items?: Array<AbbrevApiReferenceSection>excludes?: Array<string>meta?: {shared?: boolean@@ -25,6 +25,7 @@ export interface AbbrevCommonClientLibSection {export function parseReferencePath(slug: Array<string>) {const isClientSdkReference = clientSdkIds.includes(slug[0])+ const isCliReference = slug[0] === 'cli'if (isClientSdkReference) {let [sdkId, maybeVersion, maybeCrawlers, ...path] = slug@@ -45,6 +46,11 @@ export function parseReferencePath(slug: Array<string>) {maybeCrawlers,path,}+ } else if (isCliReference) {+ return {+ __type: 'cli' as const,+ path: slug.slice(1),+ }} else {return {__type: 'UNIMPLEMENTED' as const,@@ -68,7 +74,7 @@ async function generateStaticParamsForSdkVersion(sdkId: string, version: string)}export async function generateReferenceStaticParams() {- const nonCrawlerPages = clientSdkIds+ const sdkPages = clientSdkIds.flatMap((sdkId) =>REFERENCES[sdkId].versions.map((version) => ({sdkId,@@ -79,7 +85,13 @@ export async function generateReferenceStaticParams() {slug: [sdkId, version === REFERENCES[sdkId].versions[0] ? null : version].filter(Boolean),}))- return nonCrawlerPages+ const cliPages = [+ {+ slug: ['cli'],+ },+ ]++ return [...sdkPages, ...cliPages]}export async function generateReferenceMetadata(@@ -90,6 +102,7 @@ export async function generateReferenceMetadata(const parsedPath = parseReferencePath(slug)const isClientSdkReference = parsedPath.__type === 'clientSdk'+ const isCliReference = parsedPath.__type === 'cli'if (isClientSdkReference) {const { sdkId, maybeVersion } = parsedPath@@ -126,6 +139,11 @@ export async function generateReferenceMetadata(images,},}+ } else if (isCliReference) {+ return {+ title: 'CLI Reference | Supabase Docs',+ description: 'CLI reference for the Supabase CLI',+ }} else {return {}}diff --git a/apps/docs/middleware.ts b/apps/docs/middleware.tsindex b9ceafb535e..6bec442e946 100644--- a/apps/docs/middleware.ts+++ b/apps/docs/middleware.ts@@ -32,6 +32,12 @@ export function middleware(request: NextRequest) {}} else {const [, lib, maybeVersion] = url.pathname.replace(REFERENCE_PATH, '').split('/')++ if (lib === 'cli') {+ const rewritePath = [REFERENCE_PATH, 'cli'].join('/')+ return NextResponse.rewrite(new URL(rewritePath, request.url))+ }+if (clientSdkIds.includes(lib)) {const version = /v\d+/.test(maybeVersion) ? maybeVersion : nullconst rewritePath = [REFERENCE_PATH, lib, version].filter(Boolean).join('/')diff --git a/apps/docs/pages/reference/cli/[...slug].tsx b/apps/docs/pages/reference/cli/[...slug].tsxdeleted file mode 100644index 779e04540b6..00000000000--- a/apps/docs/pages/reference/cli/[...slug].tsx+++ /dev/null@@ -1,31 +0,0 @@-import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'-import RefSectionHandler from '~/components/reference/RefSectionHandler'-import { flattenSections } from '~/lib/helpers'-import handleRefGetStaticPaths from '~/lib/mdx/handleRefStaticPaths'-import handleRefStaticProps from '~/lib/mdx/handleRefStaticProps'--import spec from '~/spec/cli_v1_commands.yaml' assert { type: 'yml' }-import cliCommonSections from '~/spec/common-cli-sections.json' assert { type: 'json' }--const sections = flattenSections(cliCommonSections)-const libraryPath = '/cli'--export default function CliRef(props) {- return (- <RefSectionHandler- menuId={MenuId.RefCli}- sections={sections}- spec={spec}- pageProps={props}- type="cli"- />- )-}--export async function getStaticProps() {- return handleRefStaticProps(sections, libraryPath)-}--export async function getStaticPaths() {- return handleRefGetStaticPaths(sections)-}