Skip to content

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

Fix dart ref items

Terry Sutton747a259a7bb8
diff --git a/apps/docs/components/CustomHTMLElements/CustomHTMLElements.utils.ts b/apps/docs/components/CustomHTMLElements/CustomHTMLElements.utils.ts
index e5eb11d9466..eb214e4963b 100644
--- a/apps/docs/components/CustomHTMLElements/CustomHTMLElements.utils.ts
+++ b/apps/docs/components/CustomHTMLElements/CustomHTMLElements.utils.ts
@@ -82,8 +82,8 @@ export const highlightSelectedNavItem = (id: string) => {
const navMenuItems = document.querySelectorAll('.function-link-item a')
// find any currently active items and remove them
- const currentActiveItem = document.querySelector('.function-link-list .text-brand-900')
- currentActiveItem?.classList.remove('text-brand-900')
+ const currentActiveItems = document.querySelectorAll('.function-link-list .text-brand-900')
+ currentActiveItems.forEach((item) => item.classList.remove('text-brand-900'))
// Add active class to the current item
navMenuItems.forEach((item) => {
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx
index bce96f36823..d84449ca809 100644
--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx
+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx
@@ -276,9 +276,24 @@ const SideNav = () => {
<NavigationMenuGuideList id={'platform'} currentLevel={level} setLevel={setLevel} />
{/* 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} />
+ <NavigationMenuRefList
+ id={'reference_javascript'}
+ currentLevel={level}
+ setLevel={setLevel}
+ lib="js"
+ />
+ <NavigationMenuRefList
+ id={'reference_dart'}
+ currentLevel={level}
+ setLevel={setLevel}
+ lib="dart"
+ />
+ <NavigationMenuCliList
+ id={'reference_cli'}
+ currentLevel={level}
+ setLevel={setLevel}
+ lib="cli"
+ />
</div>
)
}
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefList.tsx b/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefList.tsx
index d8d94cf338d..059b9e2f047 100644
--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefList.tsx
+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefList.tsx
@@ -12,9 +12,8 @@ import Image from 'next/image'
const allFunctions = Object.values(clientLibsCommonSections.sections.functions)
-const introItems = Object.values(clientLibsCommonSections.sections.intro.js.items)
-
-const NavigationMenuRefList = ({ currentLevel, setLevel, id }) => {
+const NavigationMenuRefList = ({ currentLevel, setLevel, id, lib }) => {
+ const introItems = Object.values(clientLibsCommonSections.sections.intro[lib].items)
const router = useRouter()
const menu = NavItems[id]
diff --git a/apps/docs/docs/ref/dart/release-notes.mdx b/apps/docs/docs/ref/dart/release-notes.mdx
new file mode 100644
index 00000000000..b5e0e218918
--- /dev/null
+++ b/apps/docs/docs/ref/dart/release-notes.mdx
@@ -0,0 +1,6 @@
+---
+id: release-notes
+title: Release Notes
+---
+
+## dart this is the release notes file.
diff --git a/apps/docs/pages/reference/dart/[...slug].tsx b/apps/docs/pages/reference/dart/[...slug].tsx
index 80649329578..ec3d7a62720 100644
--- a/apps/docs/pages/reference/dart/[...slug].tsx
+++ b/apps/docs/pages/reference/dart/[...slug].tsx
@@ -21,7 +21,7 @@ import dartSpec from '~/../../spec/supabase_dart_v1_temp_new_shape.yml' assert {
// @ts-expect-error
import commonLibSpec from '~/../../spec/common-client-libs.yml' assert { type: 'yml' }
-
+import commonLibJson from '~/../../spec/common-client-libs-sections.json'
import { IconDatabase, Tabs } from 'ui'
import CodeBlock from '~/components/CodeBlock/CodeBlock'
@@ -33,7 +33,14 @@ import RefSubLayout from '~/layouts/ref/RefSubLayout'
import OldLayout from '~/layouts/Default'
+import clientLibsCommonSections from '~/../../spec/common-client-libs-sections.json'
+
+const allFunctions = Object.values(clientLibsCommonSections.sections.functions)
+ .map((fn: any) => fn.items)
+ .flat(2)
+
export default function DartReference(props) {
+ console.log('docs', props.docs)
const router = useRouter()
const slug = router.query.slug[0]
@@ -59,169 +66,241 @@ export default function DartReference(props) {
}
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={item.title}
- id={item.id}
- slug={commonLibSpec.functions.find((commonItem) => commonItem.id === item.id).slug}
- scrollSpyHeader={true}
- >
- <RefSubLayout.Details>
+ <>
+ <RefSubLayout>
+ <div>~~~Preamble pages~~~</div>
+ {props.docs
+ .filter((doc) => doc.introPage)
+ .map((item) => (
+ <RefSubLayout.Section
+ key={item.id}
+ title={item.meta.title}
+ id={item.id}
+ slug={item.id}
+ scrollSpyHeader={true}
+ >
+ <RefSubLayout.Details>
+ <MDXRemote {...item.content} components={components} />
+ </RefSubLayout.Details>
+ </RefSubLayout.Section>
+ ))}
+ </RefSubLayout>
+ <hr />
+ <RefSubLayout>
+ {/* jsSpec.functions.map((item, itemIndex) => { */}
+ {props.docs
+ .filter((doc) => !doc.introPage)
+ .map((doc, itemIndex) => {
+ const item = dartSpec.functions.find((x) => x.id === doc.id)
+ const hasTsRef = item['$ref'] || null
+ const tsDefinition = hasTsRef && extractTsDocNode(hasTsRef, jsTypeSpec)
+ const parameters = hasTsRef ? generateParameters(tsDefinition) : ''
+ // const functionMarkdownContent = props?.docs[itemIndex]?.content
+ // ? props?.docs[itemIndex]?.content
+ // : null
+ const shortText = hasTsRef ? tsDefinition.signatures[0].comment.shortText : ''
+
+ // const introFileMarkdownContent =
+ //console.log('props.docs', props.docs)
+ // if (item.id !== 'db-modifiers-select') return <></>
+
+ return (
<>
- <header className={['mb-16'].join(' ')}>
- {shortText && <ReactMarkdown className="text-sm">{shortText}</ReactMarkdown>}
- </header>
-
- {item.description && (
- <div className="prose">
- <ReactMarkdown className="text-sm">{item.description}</ReactMarkdown>
- </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>
- )}
- </>
- </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 = 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>
+ <RefSubLayout.Section
+ key={item.id}
+ title={item.title}
+ // examples.functions[itemIndex] doesn't pull the right title
+ // and the ids don't match up, so we can't select that way
+ // removing for now
+ // title={
+ // examples.functions[itemIndex].title ??
+ // examples.functions[itemIndex].id ??
+ // item.name ??
+ // item.id
+ // }
+ id={item.id}
+ slug={allFunctions.find((commonItem) => commonItem.id === item.id).slug}
+ scrollSpyHeader={true}
+ >
+ <RefSubLayout.Details>
+ <>
+ <header className={['mb-16'].join(' ')}>
+ {shortText && (
+ <ReactMarkdown className="text-sm">{shortText}</ReactMarkdown>
+ )}
+ </header>
+
+ {item.description && (
+ <div className="prose">
+ <ReactMarkdown className="text-sm">{item.description}</ReactMarkdown>
+ </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 text-scale-1200">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}>
+ {paramItem.subContent && (
+ <div className="mt-3">
+ <Options>
+ {param.subContent.map((param) => {
+ return <Options.Option {...param} />
+ })}
+ </Options>
</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}
+ )}
+ </Param>
+ )
+ })}
+ </ul>
+ </div>
+ )}
+ </>
+ </RefSubLayout.Details>
+ <RefSubLayout.Examples>
+ {item.examples && (
+ <>
+ <Tabs
+ defaultActiveId={item.examples[0].id}
+ size="tiny"
+ type="rounded-pills"
+ 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 = 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}
+ className="flex flex-col gap-3"
>
- {response}
- </CodeBlock>
- </>
- )}
- </Tabs.Panel>
- )
- })}
- </Tabs>
- </>
- )}
- </RefSubLayout.Examples>
- </RefSubLayout.Section>
- )
- })}
- </RefSubLayout>
+ {((tables && tables.length > 0) || sql) && (
+ <ReferenceDetailCollapse
+ id={`${example.id}-${exampleIndex}-data`}
+ label="Example data source"
+ defaultOpen={false}
+ >
+ <>
+ {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 my-0 border border-t-0 border-scale-500 !rounded-tl-none !rounded-tr-none"
+ language="sql"
+ hideLineNumbers={true}
+ >
+ {sql}
+ </CodeBlock>
+ )}
+ </>
+ </ReferenceDetailCollapse>
+ )}
+
+ <CodeBlock
+ className="useless-code-block-class"
+ language="js"
+ hideLineNumbers={true}
+ >
+ {exampleString +
+ (example.code &&
+ example.code
+ .replace('```', '')
+ .replace('js', '')
+ .replace('```', ''))}
+ </CodeBlock>
+ {response && (
+ <ReferenceDetailCollapse
+ id={`${example.id}-${exampleIndex}-response`}
+ label="Example response"
+ defaultOpen={false}
+ >
+ <CodeBlock
+ className="useless-code-block-class"
+ language="js"
+ hideLineNumbers={true}
+ >
+ {response
+ .replace('```', '')
+ .replace('json', '')
+ .replace('```', '')}
+ </CodeBlock>
+ </ReferenceDetailCollapse>
+ )}
+ </Tabs.Panel>
+ )
+ })}
+ </Tabs>
+ </>
+ )}
+ </RefSubLayout.Examples>
+ </RefSubLayout.Section>
+ </>
+ )
+ })}
+ </RefSubLayout>
+ </>
)
}
export async function getStaticProps({ params }: { params: { slug: string[] } }) {
- const pages = dartSpec.functions.map((x) => x.id)
+ // an array of ids of the intro sections for this library
+ const introPages = commonLibJson.sections.intro.dart.items.map((item) => item.id)
+
+ const specPpages = allFunctions.filter((fn) => fn.libs.includes('dart')).map((x) => x.id)
+
+ const pages = [...introPages, ...specPpages]
/**
* Read all the markdown files that might have
@@ -231,7 +310,7 @@ export async function getStaticProps({ params }: { params: { slug: string[] } })
*/
const allMarkdownDocs = await Promise.all(
pages.map(async (x, i) => {
- const pathName = `docs/ref/js/${x}.mdx`
+ const pathName = `docs/ref/dart/${x}.mdx`
function checkFileExists(x) {
// console.log('checking this ', x)
@@ -254,6 +333,7 @@ export async function getStaticProps({ params }: { params: { slug: string[] } })
title: x,
// ...content,
meta: data,
+ introPage: introPages.includes(x),
content: content ? await serialize(content || '') : null,
}
})
diff --git a/apps/docs/pages/reference/javascript/[...slug].tsx b/apps/docs/pages/reference/javascript/[...slug].tsx
index d022ed4701c..457fe308325 100644
--- a/apps/docs/pages/reference/javascript/[...slug].tsx
+++ b/apps/docs/pages/reference/javascript/[...slug].tsx
@@ -42,6 +42,7 @@ const allFunctions = Object.values(clientLibsCommonSections.sections.functions)
.flat(2)
export default function JSReference(props) {
+ console.log('docs', props.docs)
const router = useRouter()
const slug = router.query.slug[0]
@@ -127,9 +128,7 @@ export default function JSReference(props) {
// item.id
// }
id={item.id}
- slug={
- commonLibSpec.functions.find((commonItem) => commonItem.id === item.id).slug
- }
+ slug={allFunctions.find((commonItem) => commonItem.id === item.id).slug}
scrollSpyHeader={true}
>
<RefSubLayout.Details>
@@ -214,8 +213,6 @@ const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key
const sql = staticExample?.data?.sql
const tables = staticExample?.data?.tables
- const [dataOpen, setDataOpen] = useState(false)
-
return (
<Tabs.Panel
id={example.id}
diff --git a/spec/common-client-libs-sections.json b/spec/common-client-libs-sections.json
index 9674b9c8cf5..33d130a389f 100644
--- a/spec/common-client-libs-sections.json
+++ b/spec/common-client-libs-sections.json
@@ -18,11 +18,23 @@
},
"js_v1": {
"title": "Getting Started",
- "items": []
+ "items": [
+ {
+ "id": "release-notes",
+ "title": "Release Notes",
+ "slug": "release-notes"
+ }
+ ]
},
"dart": {
"title": "Getting Started",
- "items": []
+ "items": [
+ {
+ "id": "release-notes",
+ "title": "Release Notes",
+ "slug": "release-notes"
+ }
+ ]
},
"dart_v0": {
"title": "Getting Started",
@@ -281,7 +293,7 @@
"slug": "db-modifiers-select",
"product": "database",
"parent": "modifiers",
- "libs": ["js", "js_v1", "dart", "dart_v0"]
+ "libs": ["js", "js_v1", "dart_v0"]
},
{
"id": "order",
@@ -313,7 +325,7 @@
"slug": "db-abortsignal",
"product": "database",
"parent": "modifiers",
- "libs": ["js", "js_v1", "dart", "dart_v0"]
+ "libs": ["js", "js_v1", "dart_v0"]
},
{
"id": "single",
@@ -329,7 +341,7 @@
"slug": "maybesingle",
"product": "database",
"parent": "modifiers",
- "libs": ["js", "js_v1", "dart", "dart_v0"]
+ "libs": ["js", "js_v1", "dart_v0"]
},
{
"id": "csv",
@@ -337,7 +349,7 @@
"slug": "db-csv",
"product": "database",
"parent": "modifiers",
- "libs": ["js", "js_v1", "dart", "dart_v0"]
+ "libs": ["js", "js_v1", "dart_v0"]
}
]
},
@@ -356,63 +368,63 @@
"title": "Sign in",
"slug": "auth-signin",
"product": "auth",
- "libs": ["js_v1", "dart", "dart_v0"]
+ "libs": ["js_v1", "dart_v0"]
},
{
"id": "send-mobile-otp",
"title": "sendMobileOTP()",
"slug": "auth-api-sendmobileotp",
"product": "auth",
- "libs": ["js_v1", "dart", "dart_v0"]
+ "libs": ["js_v1", "dart_v0"]
},
{
"id": "sign-in-with-password",
"title": "Sign in with password",
"slug": "auth-signinwithpassword",
"product": "auth",
- "libs": ["js", "js_v1", "dart", "dart_v0"]
+ "libs": ["js", "js_v1", "dart_v0"]
},
{
"id": "sign-in-with-otp",
"title": "Sign in with OTP",
"slug": "auth-signinwithotp",
"product": "auth",
- "libs": ["js", "js_v1", "dart", "dart_v0"]
+ "libs": ["js", "js_v1", "dart_v0"]
},
{
"id": "sign-in-with-oauth",
"title": "Sign in with 0auth",
"slug": "auth-signinwithoauth",
"product": "auth",
- "libs": ["js", "js_v1", "dart", "dart_v0"]
+ "libs": ["js", "js_v1", "dart_v0"]
},
{
"id": "sign-out",
"title": "signOut()",
"slug": "auth-signout",
"product": "auth",
- "libs": ["js", "js_v1", "dart", "dart_v0"]
+ "libs": ["js", "js_v1", "dart_v0"]
},
{
"id": "verify-otp",
"title": "verifyOtp()",
"slug": "auth-verifyotp",
"product": "auth",
- "libs": ["js", "js_v1", "dart", "dart_v0"]
+ "libs": ["js", "js_v1", "dart_v0"]
},
{
"id": "current-session",
"title": "currentSession()",
"slug": "auth-currentsession",
"product": "auth",
- "libs": ["dart", "dart_v0"]
+ "libs": ["dart_v0"]
},
{
"id": "current-user",
"title": "currentUser()",
"slug": "auth-currentuser",
"product": "auth",
- "libs": ["dart", "dart_v0"]
+ "libs": ["dart_v0"]
},
{
"id": "get-session",
@@ -440,7 +452,7 @@
"title": "updateUser()",
"slug": "auth-updateuser",
"product": "auth",
- "libs": ["js", "js_v1", "dart", "dart_v0"]
+ "libs": ["js", "js_v1", "dart_v0"]
},
{
"id": "set-session",
@@ -455,14 +467,14 @@
"title": "onAuthStateChange()",
"slug": "auth-onauthstatechange",
"product": "auth",
- "libs": ["js", "js_v1", "dart", "dart_v0"]
+ "libs": ["js", "js_v1", "dart_v0"]
},
{
"id": "reset-password-for-email",
"title": "resetPasswordForEmail()",
"slug": "auth-resetpasswordforemail",
"product": "auth",
- "libs": ["js", "js_v1", "dart", "dart_v0"]
+ "libs": ["js", "js_v1", "dart_v0"]
}
]
},
@@ -568,21 +580,21 @@
"title": "removeSubscription()",
"slug": "removesubscription",
"product": "realtime",
- "libs": ["dart", "dart_v0"]
+ "libs": ["dart_v0"]
},
{
"id": "remove-all-subscriptions",
"title": "removeallsubscriptions()",
"slug": "removeallsubscriptions",
"product": "realtime",
- "libs": ["dart", "dart_v0"]
+ "libs": ["dart_v0"]
},
{
"id": "get-subscriptions",
"title": "getSubscriptions()",
"slug": "getsubscriptions",
"product": "realtime",
- "libs": ["dart", "dart_v0"]
+ "libs": ["dart_v0"]
},
{
@@ -693,7 +705,7 @@
"title": "from.copy()",
"slug": "storage-from-copy",
"product": "storage",
- "libs": ["js", "js_v1", "dart", "dart_v0"]
+ "libs": ["js", "js_v1", "dart_v0"]
},
{
"id": "from-remove",
@@ -714,14 +726,14 @@
"title": "from.createSignedUrls()",
"slug": "storage-from-createsignedurls",
"product": "storage",
- "libs": ["js", "js_v1", "dart", "dart_v0"]
+ "libs": ["js", "js_v1", "dart_v0"]
},
{
"id": "from-get-public-url",
"title": "from.getPublicUrl()",
"slug": "storage-from-getpublicurl",
"product": "storage",
- "libs": ["js", "js_v1", "dart", "dart_v0"]
+ "libs": ["js2", "js_v1", "dart", "dart_v0"]
}
]
}