Skip to content

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

Fix dart menu

Terry Suttonbae9395ff4b9
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
index df352a3f05d..15ed4da6f54 100644
--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
@@ -489,7 +489,7 @@ export const reference = {
export const reference_javascript = {
icon: '/img/icons/javascript-icon.svg',
- title: 'javascript-js',
+ title: 'javascript',
parent: '/reference',
items: [
{
@@ -507,6 +507,26 @@ export const reference_javascript = {
],
}
+export const reference_dart = {
+ icon: '/img/icons/dart-icon.svg',
+ title: 'dart',
+ parent: '/reference',
+ items: [
+ {
+ name: 'Getting Started',
+ items: [
+ {
+ name: 'fake link',
+ href: '/reference/dart/start',
+ level: 'reference_dart',
+ items: [],
+ icon: '/img/icons/dart.svg',
+ },
+ ],
+ },
+ ],
+}
+
export const reference_cli = {
icon: '/img/icons/cli-icon.svg',
title: 'Supabase CLI',
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx
index 044c3c27fc2..03d0cb8d251 100644
--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx
+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx
@@ -53,6 +53,9 @@ const SideNav = () => {
case url.includes(`/docs/new/reference/javascript/`) && url:
setLevel('reference_javascript')
break
+ case url.includes(`/docs/new/reference/dart/`) && url:
+ setLevel('reference_dart')
+ break
case url.includes(`/docs/new/reference/cli/`) && url:
setLevel('reference_cli')
break
@@ -166,8 +169,8 @@ const SideNav = () => {
label: 'Dart Client Library',
icon: '/img/icons/dart-icon',
hasLightIcon: false,
- href: '/new/reference/javascript/start',
- level: 'reference_javascript',
+ href: '/new/reference/dart/start',
+ level: 'reference_dart',
},
{
label: 'Tools Reference',
@@ -275,6 +278,7 @@ const SideNav = () => {
{/* reference level */}
<NavigationMenuRefList id={'reference_javascript'} currentLevel={level} setLevel={setLevel} />
+ <NavigationMenuRefList id={'reference_dart'} currentLevel={level} setLevel={setLevel} />
<NavigationMenuCliList id={'reference_cli'} currentLevel={level} setLevel={setLevel} />
{/* // ref menu */}
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefList.tsx b/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefList.tsx
index 61fbfc1fd8a..65c984f6997 100644
--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefList.tsx
+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefList.tsx
@@ -31,15 +31,19 @@ const NavigationMenuRefList = ({ currentLevel, setLevel, id }) => {
title,
id,
icon,
+ product,
+ library,
}: {
title: string
name: string
id: string
icon?: string
+ product?: string
+ library: string
}) => {
return (
<li key={id}>
- <Link href={`#${id}`} passHref>
+ <Link href={`/new/reference/${library}/${id}`} passHref>
<a className="cursor-pointer transition text-scale-1000 text-sm hover:text-brand-900 flex gap-3">
{icon && <img className="w-3" src={`${router.basePath}${icon}`} />}
{title}
@@ -53,8 +57,8 @@ const NavigationMenuRefList = ({ currentLevel, setLevel, id }) => {
return (
<span
className="
- font-mono text-xs uppercase
- text-scale-1200 font-medium
+ font-mono text-xs uppercase
+ text-scale-1200 font-medium
tracking-wider
mb-3
"
@@ -99,6 +103,7 @@ const NavigationMenuRefList = ({ currentLevel, setLevel, id }) => {
<span>Back to Main Menu</span>
</a>
</Link>
+ {console.log(menu)}
{/* )} */}
{/* {process.env.NEXT_PUBLIC_EXPERIMENTAL_REF !== 'true' && ( */}
<div className="flex items-center gap-3 my-3">
@@ -111,21 +116,21 @@ const NavigationMenuRefList = ({ currentLevel, setLevel, id }) => {
' '
)}
>
- supabase-js
+ {menu.title}
</h2>
</div>
{/* )} */}
<ul className="">
<Divider />
<SideMenuTitle title="Database" />
-
+ {console.log({ clientLibsCommon })}
{clientLibsCommon.functions
.filter((x) => x.product === 'database')
.map((x, index) => {
// console.log(functions)
return (
<>
- <FunctionLink {...x} />
+ <FunctionLink {...x} library={menu.title} />
</>
)
})}
diff --git a/apps/docs/layouts/ref/RefSubLayout.tsx b/apps/docs/layouts/ref/RefSubLayout.tsx
index 1b094ae59ee..ca15f3c4389 100644
--- a/apps/docs/layouts/ref/RefSubLayout.tsx
+++ b/apps/docs/layouts/ref/RefSubLayout.tsx
@@ -26,7 +26,7 @@ const RefSubLayout: FC<RefSubLayoutType> & RefSubLayoutSubComponents = (props) =
return (
<div className="flex my-16">
<div className="w-full">
- <div className={['flex flex-col mx-auto', 'max-w-7xl'].join(' ')}>{props.children}</div>
+ <div className={['grid gap-24 mx-auto', 'max-w-7xl'].join(' ')}>{props.children}</div>
</div>
</div>
)
@@ -56,7 +56,7 @@ const StickyHeader: FC<StickyHeader> = ({ id, title, monoFont }) => {
<h2
ref={ref}
className={[
- 'text-xl font-medium text-scale-1200 mb-12 max-w-xl',
+ 'text-xl font-medium text-scale-1200 mb-8 max-w-xl',
monoFont && 'font-mono',
].join(' ')}
>
diff --git a/apps/docs/next.config.mjs b/apps/docs/next.config.mjs
index d36b0c6eec8..e6c750eb710 100644
--- a/apps/docs/next.config.mjs
+++ b/apps/docs/next.config.mjs
@@ -27,6 +27,7 @@ const withMDX = nextMdx({
theme: codeHikeTheme,
autoImport: true,
lineNumbers: true,
+ showCopyButton: true,
},
],
remarkGfm,
diff --git a/apps/docs/pages/404.mdx b/apps/docs/pages/404.mdx
index 92807aeb5af..a24fcdaa7c7 100644
--- a/apps/docs/pages/404.mdx
+++ b/apps/docs/pages/404.mdx
@@ -1,6 +1,13 @@
+import Layout from '~/layouts/DefaultGuideLayout'
+
export const meta = {
+ id: '404',
title: '404',
description: 'Page not found',
}
# Page not found
+
+export const Page = ({ children }) => <Layout meta={meta} children={children} />
+
+export default Page
diff --git a/apps/docs/pages/new/reference/dart/[...slug].tsx b/apps/docs/pages/new/reference/dart/[...slug].tsx
index 23c4092bc51..eec26f08ed5 100644
--- a/apps/docs/pages/new/reference/dart/[...slug].tsx
+++ b/apps/docs/pages/new/reference/dart/[...slug].tsx
@@ -1,16 +1,10 @@
-import {
- useEffect,
- // useRef,
- useState,
-} from 'react'
-// pages/index.js
+import { useEffect } from 'react'
import fs from 'fs'
import matter from 'gray-matter'
import { MDXRemote } from 'next-mdx-remote'
import { serialize } from 'next-mdx-remote/serialize'
-import remarkGfm from 'remark-gfm'
import components from '~/components/index'
import { getAllDocs } from '~/lib/docs'
@@ -20,298 +14,206 @@ import ReactMarkdown from 'react-markdown'
import jsTypeSpec from '~/../../spec/enrichments/tsdoc_v2/combined.json'
// @ts-ignore
import examples from '~/../../spec/examples/examples.yml' assert { type: 'yml' }
+
// @ts-expect-error
-import jsSpec from '~/../../spec/supabase_dart_v1_temp_new_shape.yml' assert { type: 'yml' }
+import dartSpec from '~/../../spec/supabase_dart_v1_temp_new_shape.yml' assert { type: 'yml' }
import { IconDatabase, Tabs } from 'ui'
import CodeBlock from '~/components/CodeBlock/CodeBlock'
import { useRouter } from 'next/router'
import { extractTsDocNode, generateParameters } from '~/lib/refGenerator/helpers'
+import Param from '~/components/Params'
+import Options from '~/components/Options'
+import RefSubLayout from '~/layouts/ref/RefSubLayout'
-const marginTop = 256
-export default function Ref(props) {
- // const myRef = useRef(null)
-
- console.log('props', props)
-
- const [offsetY, setOffsetY] = useState(0)
- const [sections, setSections] = useState([])
-
- // useEffect(() => {
- // window.scrollTo(0, 0)
- // setOffsetY(0)
- // }, [])
-
- useEffect(() => {
- const els: HTMLElement[] = Array.from(document.querySelectorAll('div.ref-container'))
-
- const allSections = els.map((el: HTMLElement, index: number) => {
- const { top: boundingTop } = el.getBoundingClientRect()
-
- return {
- topic: el.getAttribute('id')!,
- boundingTop,
- isActive: index === 0,
- }
- })
-
- // console.log('allSections', allSections)
- setSections(allSections)
- }, [])
-
- // useEffect(() => {
- // if (sections.length <= 1) return
-
- // const onScroll = () => {
- // console.log('SCROLL EVENT')
- // setOffsetY(window.pageYOffset)
- // }
- // window.addEventListener('scroll', debounce(onScroll, 500))
-
- // return () => window.removeEventListener('scroll', onScroll)
- // }, [sections])
-
- // useEffect(() => {
- // if (sections.length === 0) return
-
- // if (sections.length === 1) {
- // sections[0].isActive = true
- // return
- // }
-
- // sections.forEach((section, index) => {
- // if (index === 0) {
- // section.isActive = sections[index + 1].boundingTop > offsetY + marginTop
- // } else {
- // if (sections[index + 1]) {
- // section.isActive =
- // sections[index + 1].boundingTop > offsetY + marginTop &&
- // sections[index].boundingTop <= offsetY + marginTop
- // } else {
- // section.isActive = sections[index].boundingTop <= offsetY + marginTop
- // }
- // }
- // })
- // }, [sections, offsetY])
-
- // useEffect(() => {
- // const observer = new IntersectionObserver((entries) => {
- // // console.log('entries', entries)
- // const entry = entries[0]
- // // console.log('entry', entry)
- // })
- // // console.log('myRef', myRef.current)
- // observer.observe(myRef.current)
- // }, [])
-
+export default function DartReference(props) {
const router = useRouter()
+ const slug = router.query.slug[0]
- function updateUrl(key) {
- // router.replace(
- // {
- // pathname: `/ref/js/${key}`,
- // // query: { sortBy: 'price' },
- // }
- // // undefined,
- // // { shallow: true }
- // )
- router.replace(
- {
- pathname: `/ref/js/${key}`,
- // query: { sortBy: 'price' },
- },
- undefined,
- { scroll: false }
- )
- }
+ useEffect(() => {
+ if (document && slug !== 'start') {
+ // re-enable this when the new yaml shape file is moved into this branch
+ //document.querySelector(`#${slug}`).scrollIntoView()
+ }
+ })
return (
- <div>
- <div className="flex my-16">
- <div className="px-10 fixed">
- {sections.map((x, i) => {
- return (
- <a
- className={[
- 'block text-sm hover:text-scale-1200 text-scale-1100 cursor-pointer',
- sections && sections[i].isActive ? 'text-brand-900 text-scale-900' : '',
- ].join(' ')}
- key={i}
- onClick={() => {
- window.scrollTo(0, x.boundingTop - marginTop)
- setOffsetY(x.boundingTop - marginTop)
- }}
- >
- {x.topic}
- </a>
- )
- })}
- </div>
-
- <div className="ml-64 w-full">
- <div
- className="flex flex-col gap-32 mx-auto max-w-5xl"
- // ref={myRef}
- >
- {jsSpec.functions.map((item, itemIndex) => {
- // if (item.id !== 'select()') return <div>hidden section</div>
- // const sectionRef = useRef(null)
-
- // console.log('x', x)
- const hasTsRef = item['$ref'] || null
- // console.log('hasTsRef', hasTsRef)
- // console.log('jsTypeSpec', jsTypeSpec)
- const tsDefinition = hasTsRef && extractTsDocNode(hasTsRef, jsTypeSpec)
- // console.log('tsDefinition', tsDefinition)
- // console.log(`tsDefinition for ${item.title ?? item.id}`, tsDefinition)
-
- // useEffect(() => {
- // const observer = new IntersectionObserver((entries) => {
- // // console.log('entries', entries)
- // const entry = entries[0]
-
- // // console.log(
- // // x.id,
- // // 'intersectiong',
- // // entry.isIntersecting,
- // // 'visible',
- // // entry.isVisible
- // // )
- // })
- // // console.log('myRef', myRef.current)
- // observer.observe(sectionRef.current)
- // }, [])
-
- const parameters = hasTsRef ? generateParameters(tsDefinition) : ''
-
- // @ts-ignore
- // const [serialFunctionMarkdownContent, setSerialFunctionMarkdownContent] =
- // useState(null)
-
- const functionMarkdownContent = props?.docs[itemIndex]?.content
-
- // useEffect(() => {
- // async function makeContent() {
- // setSerialFunctionMarkdownContent(
- // await serialize(functionMarkdownContent, {
- // mdxOptions: {
- // remarkPlugins: [remarkGfm],
- // format: 'mdx',
- // },
- // })
- // )
- // }
- // makeContent()
- // }, [])
-
- // console.log('serialFunctionMarkdownContent', serialFunctionMarkdownContent)
-
- return (
+ <RefSubLayout>
+ {dartSpec.functions.map((item, itemIndex) => {
+ const hasTsRef = item['$ref'] || null
+ const tsDefinition = hasTsRef && extractTsDocNode(hasTsRef, jsTypeSpec)
+ const parameters = hasTsRef ? generateParameters(tsDefinition) : ''
+
+ const functionMarkdownContent = props?.docs[itemIndex]?.content
+ const shortText = hasTsRef ? tsDefinition.signatures[0].comment.shortText : ''
+
+ return (
+ <>
+ <RefSubLayout.Section
+ key={item.id}
+ title={
+ examples.functions[itemIndex].title ??
+ examples.functions[itemIndex].id ??
+ item.name ??
+ item.id
+ }
+ id={item.id}
+ >
+ <RefSubLayout.Details>
<>
- <header className="sticky top-0 bg-gray-600 z-10 p-4">
- <h1 className="text-3xl not-prose" onClick={() => updateUrl(item.id)}>
- {examples.functions[itemIndex].title ??
- examples.functions[itemIndex].id ??
- item.name ??
- item.id}
- </h1>
+ <header className={['mb-16'].join(' ')}>
+ {shortText && (
+ <>
+ <p
+ className="text-sm text-scale-1100"
+ dangerouslySetInnerHTML={{ __html: shortText }}
+ ></p>
+ </>
+ )}
</header>
- <div
- className="grid grid-cols-2 pb-32 ref-container gap-10"
- id={item.id}
- // ref={sectionRef}
- >
- <div className="prose" key={item.id}>
- <p className="text-lg not-prose">
- {examples.functions[itemIndex].description}
- </p>
-
- <hr />
- {functionMarkdownContent && (
- <MDXRemote {...functionMarkdownContent} components={components} />
- )}
-
- {item.notes && (
- <div>
- <ReactMarkdown>{item.notes}</ReactMarkdown>
- </div>
- )}
- {/* // parameters */}
- {parameters && <div dangerouslySetInnerHTML={{ __html: parameters }}></div>}
+ {item.description && (
+ <div className="prose">
+ <p className="text-sm">{item.description}</p>
+ </div>
+ )}
+ {functionMarkdownContent && (
+ <div className="prose">
+ <MDXRemote {...functionMarkdownContent} components={components} />
+ </div>
+ )}
+ {item.notes && (
+ <div className="prose">
+ <ReactMarkdown className="text-sm">{item.notes}</ReactMarkdown>
+ </div>
+ )}
+ {/* // parameters */}
+ {parameters && (
+ <div className="not-prose mt-12">
+ <h5 className="mb-3 text-base">Parameters</h5>
+ <ul className="">
+ {parameters.map((param) => {
+ // grab override params from yaml file
+ const overrideParams = item.overrideParams
+
+ // params from the yaml file can override the params from parameters if it matches the name
+ const overide = overrideParams?.filter((x) => {
+ return param.name === x.name
+ })
+
+ const paramItem = overide?.length > 0 ? overide[0] : param
+
+ return (
+ <Param {...paramItem} key={paramItem.title}>
+ {paramItem.subContent && (
+ <div className="mt-3">
+ <Options>
+ {param.subContent.map((param) => {
+ return <Options.Option {...param} />
+ })}
+ </Options>
+ </div>
+ )}
+ </Param>
+ )
+ })}
+ </ul>
</div>
- <div className="w-full">
- <div className="sticky top-24">
- {item.examples && (
- <Tabs
- defaultActiveId={item.examples[0].id}
- size="small"
- type="underlined"
- scrollable
- >
- {item.examples &&
- item.examples.map((example, exampleIndex) => {
- const exampleString = `
+ )}
+ </>
+ </RefSubLayout.Details>
+ <RefSubLayout.Examples>
+ {item.examples && (
+ <>
+ <Tabs
+ defaultActiveId={item.examples[0].id}
+ size="small"
+ type="underlined"
+ scrollable
+ >
+ {item.examples &&
+ item.examples.map((example, exampleIndex) => {
+ const exampleString = `
import { createClient } from '@supabase/supabase-js'
// Create a single supabase client for interacting with your database
const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key')
`
- const currentExampleId = example.id
- // const staticExample =
- // examples.functions[itemIndex].examples[exampleIndex]
-
- // const response = staticExample.response
- // const sql = staticExample?.data?.sql
- // const tables = staticExample?.data?.tables
-
- return (
- <Tabs.Panel id={example.id} label={example.name}>
- <CodeBlock
- className="useless-code-block-class"
- language="dart"
- hideLineNumbers={true}
- >
- {exampleString +
- (example.code &&
- example.code
- .replace('```', '')
- .replace('js', '')
- .replace('```', ''))}
- </CodeBlock>
- </Tabs.Panel>
- )
- })}
- </Tabs>
- )}
- </div>
- </div>
- </div>
- </>
- )
- })}
- </div>
- </div>
- </div>
- </div>
+ const currentExampleId = example.id
+ const staticExample = item.examples[exampleIndex]
+
+ const response = staticExample.response
+ const sql = staticExample?.data?.sql
+ const tables = staticExample?.data?.tables
+
+ return (
+ <Tabs.Panel id={example.id} label={example.name}>
+ {tables &&
+ tables.length > 0 &&
+ tables.map((table) => {
+ return (
+ <div className="bg-scale-300 border rounded prose max-w-none">
+ <div className="bg-scale-200 px-5 py-2">
+ <div className="flex gap-2 items-center">
+ <div className="text-brand-900">
+ <IconDatabase size={16} />
+ </div>
+ <h5 className="text-xs text-scale-1200">{table.name}</h5>
+ </div>
+ </div>
+ </div>
+ )
+ })}
+ {sql && (
+ <CodeBlock
+ className="useless-code-block-class"
+ language="sql"
+ hideLineNumbers={true}
+ >
+ {sql}
+ </CodeBlock>
+ )}
+ <CodeBlock
+ className="useless-code-block-class"
+ language="js"
+ hideLineNumbers={true}
+ >
+ {exampleString +
+ (example.code &&
+ example.code
+ .replace('```', '')
+ .replace('js', '')
+ .replace('```', ''))}
+ </CodeBlock>
+ {response && (
+ <>
+ <CodeBlock
+ className="useless-code-block-class"
+ language="json"
+ hideLineNumbers={true}
+ >
+ {response}
+ </CodeBlock>
+ </>
+ )}
+ </Tabs.Panel>
+ )
+ })}
+ </Tabs>
+ </>
+ )}
+ </RefSubLayout.Examples>
+ </RefSubLayout.Section>
+ </>
+ )
+ })}
+ </RefSubLayout>
)
}
export async function getStaticProps({ params }: { params: { slug: string[] } }) {
- /**
- * This is our collection of human readable titles and IDs
- */
- let markdownDocs = [
- {
- title: 'Inserting data',
- id: 'select()',
- },
- { title: 'Deleting data', id: 'delete()' },
- ]
-
- const pages = jsSpec.functions.map((x) => x.id)
- console.log('pages', pages)
+ const pages = dartSpec.functions.map((x) => x.id)
/**
* Read all the markdown files that might have
@@ -321,10 +223,6 @@ export async function getStaticProps({ params }: { params: { slug: string[] } })
*/
const allMarkdownDocs = await Promise.all(
pages.map(async (x, i) => {
- // const doc = getDocsBySlug(`docs/ref/database/${x}`)
-
- // if (i >= 5) return null
-
const pathName = `docs/ref/js/${x}.mdx`
function checkFileExists(x) {
@@ -342,10 +240,7 @@ export async function getStaticProps({ params }: { params: { slug: string[] } })
const fileContents = markdownExists ? fs.readFileSync(pathName, 'utf8') : ''
const { data, content } = matter(fileContents)
- // console.log('docBySlug', content)
- // console.log()
- if (content) console.log(content)
return {
id: x,
title: x,
@@ -356,8 +251,6 @@ export async function getStaticProps({ params }: { params: { slug: string[] } })
})
)
- // console.log('allMarkdownDocs', allMarkdownDocs)
-
return {
props: {
docs: allMarkdownDocs,
diff --git a/spec/supabase_js_v2_temp_new_shape--reduced.yml b/spec/supabase_js_v2_temp_new_shape--reduced.yml
deleted file mode 100644
index 05b96c47ac5..00000000000
--- a/spec/supabase_js_v2_temp_new_shape--reduced.yml
+++ /dev/null
@@ -1,59 +0,0 @@
-openref: 0.1
-
-info:
- id: reference/supabase-js
- title: Supabase Client
- description: |
-
- Supabase JavaScript.
-
- definition: ../../spec/enrichments/tsdoc_v2/combined.json
- specUrl: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v2.yml
- slugPrefix: '/'
- libraries:
- - id: 'JavaScript'
- version: '0.0.1'
-
-functions:
- - id: auth.signUp()
- title: 'signUp()'
- $ref: '@supabase/gotrue-js.GoTrueClient.signUp'
- notes: |
- - By default, the user needs to verify their email address before logging in. To turn this off, disable **Confirm email** in [your project](https://app.supabase.com/project/_/auth/settings).
- - **Confirm email** determines if users need to confirm their email address after signing up.
- - If **Confirm email** is enabled, a `user` is returned but `session` is null.
- - If **Confirm email** is disabled, both a `user` and a `session` are returned.
- - When the user confirms their email address, they are redirected to the [`SITE_URL`](https://supabase.com/docs/reference/auth/config#site_url) by default. You can modify your `SITE_URL` or add additional redirect URLs in [your project](https://app.supabase.com/project/_/auth/settings).
- - If signUp() is called for an existing confirmed user:
- - If **Confirm email** is enabled in [your project](https://app.supabase.com/project/_/auth/settings), an obfuscated/fake user object is returned.
- - If **Confirm email** is disabled, the error message, `User already registered` is returned.
- - To fetch the currently logged-in user, refer to [`getUser()`](/docs/reference/javascript/auth-getuser).
- examples:
- - id: sign-up.
- name: Sign up.
- isSpotlight: true
- code: |
- ```js
- const { data, error } = await supabase.auth.signUp({
- email: '[email protected]',
- password: 'example-password',
- })
- ```
- - id: sign-up-with-additional-user-metadata.
- name: Sign up with additional user metadata.
- isSpotlight: false
- code: |
- ```js
- const { data, error } = await supabase.auth.signUp(
- {
- email: '[email protected]',
- password: 'example-password',
- options: {
- data: {
- first_name: 'John',
- age: 27,
- }
- }
- }
- )
- ```