Skip to content

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

Wire up dartv0

Terry Suttone6a80df16c78
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx
index d84449ca809..58463031022 100644
--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx
+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx
@@ -288,12 +288,7 @@ const SideNav = () => {
setLevel={setLevel}
lib="dart"
/>
- <NavigationMenuCliList
- id={'reference_cli'}
- currentLevel={level}
- setLevel={setLevel}
- lib="cli"
- />
+ <NavigationMenuCliList id={'reference_cli'} currentLevel={level} setLevel={setLevel} />
</div>
)
}
diff --git a/apps/docs/docs/ref/dart/v0/release-notes.mdx b/apps/docs/docs/ref/dart/v0/release-notes.mdx
new file mode 100644
index 00000000000..2ecb0ef3990
--- /dev/null
+++ b/apps/docs/docs/ref/dart/v0/release-notes.mdx
@@ -0,0 +1,6 @@
+---
+id: release-notes
+title: Release Notes
+---
+
+## dart v0 this is the release notes file.
diff --git a/apps/docs/pages/reference/dart/v0/[...slug].tsx b/apps/docs/pages/reference/dart/v0/[...slug].tsx
index d59353dc7d5..f6f3eb0ee39 100644
--- a/apps/docs/pages/reference/dart/v0/[...slug].tsx
+++ b/apps/docs/pages/reference/dart/v0/[...slug].tsx
@@ -12,16 +12,16 @@ import { getAllDocs, getDocsBySlug } from '~/lib/docs'
import ReactMarkdown from 'react-markdown'
// @ts-ignore
-import jsTypeSpec from '~/../../spec/enrichments/tsdoc_v2/combined.json'
+import jsTypeSpec from '~/../../spec/enrichments/tsdoc_v1/combined.json'
// @ts-ignore
import examples from '~/../../spec/examples/examples.yml' assert { type: 'yml' }
// @ts-expect-error
-import dartSpec from '~/../../spec/supabase_dart_v1_temp_new_shape.yml' assert { type: 'yml' }
+import dartSpec from '~/../../spec/supabase_dart_v0_temp_new_shape.yml' assert { type: 'yml' }
// @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,21 +33,30 @@ 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]
+ const isNewDocs = process.env.NEXT_PUBLIC_NEW_DOCS === 'true'
+
useEffect(() => {
- if (document && slug !== 'start') {
+ if (isNewDocs && document && slug !== 'start') {
// re-enable this when the new yaml shape file is moved into this branch
- //document.querySelector(`#${slug}`).scrollIntoView()
+ document.querySelector(`#${slug}`) && document.querySelector(`#${slug}`).scrollIntoView()
}
})
/*
* handle old ref pages
*/
- if (process.env.NEXT_PUBLIC_NEW_DOCS === 'false') {
+ if (!isNewDocs) {
return (
// @ts-ignore
<OldLayout meta={props.meta} toc={props.toc}>
@@ -57,171 +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>
+ <div>~~~Preamble pages~~~</div>
+ {props.docs
+ .filter((doc) => doc.introPage)
+ .map((item) => (
<RefSubLayout.Section
key={item.id}
- title={item.title}
+ title={item.meta.title}
id={item.id}
- slug={commonLibSpec.functions.find((commonItem) => commonItem.id === item.id).slug}
+ slug={item.id}
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">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>
- )}
- </>
+ <MDXRemote {...item.content} components={components} />
</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>
- </div>
+ </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 (
+ <>
+ <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>
- )
- })}
- {sql && (
- <CodeBlock
- className="useless-code-block-class"
- language="sql"
- 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"
>
- {sql}
- </CodeBlock>
- )}
- <CodeBlock
- className="useless-code-block-class"
- language="js"
- hideLineNumbers={true}
- >
- {exampleString +
- (example.code &&
- example.code
- .replace('```', '')
- .replace('js', '')
- .replace('```', ''))}
- </CodeBlock>
- {response && (
- <>
+ {((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="json"
+ language="js"
hideLineNumbers={true}
>
- {response}
+ {exampleString +
+ (example.code &&
+ example.code
+ .replace('```', '')
+ .replace('js', '')
+ .replace('```', ''))}
</CodeBlock>
- </>
- )}
- </Tabs.Panel>
- )
- })}
- </Tabs>
- </>
- )}
- </RefSubLayout.Examples>
- </RefSubLayout.Section>
- </>
- )
- })}
- </RefSubLayout>
+ {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_v0'].items.map((item) => item.id)
+
+ const specPpages = allFunctions.filter((fn) => fn.libs.includes('dart_v0')).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/v0/${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/spec/common-client-libs-sections.json b/spec/common-client-libs-sections.json
index 33d130a389f..7ba65ea2d9f 100644
--- a/spec/common-client-libs-sections.json
+++ b/spec/common-client-libs-sections.json
@@ -38,7 +38,13 @@
},
"dart_v0": {
"title": "Getting Started",
- "items": []
+ "items": [
+ {
+ "id": "release-notes",
+ "title": "Release Notes",
+ "slug": "release-notes"
+ }
+ ]
}
},
"functions": [
@@ -293,7 +299,7 @@
"slug": "db-modifiers-select",
"product": "database",
"parent": "modifiers",
- "libs": ["js", "js_v1", "dart_v0"]
+ "libs": ["js", "js_v1", "dart_v8"]
},
{
"id": "order",
@@ -325,7 +331,7 @@
"slug": "db-abortsignal",
"product": "database",
"parent": "modifiers",
- "libs": ["js", "js_v1", "dart_v0"]
+ "libs": ["js", "js_v1", "dart_v8"]
},
{
"id": "single",
@@ -341,7 +347,7 @@
"slug": "maybesingle",
"product": "database",
"parent": "modifiers",
- "libs": ["js", "js_v1", "dart_v0"]
+ "libs": ["js", "js_v1", "dart_v8"]
},
{
"id": "csv",
@@ -349,7 +355,7 @@
"slug": "db-csv",
"product": "database",
"parent": "modifiers",
- "libs": ["js", "js_v1", "dart_v0"]
+ "libs": ["js", "js_v1", "dart_v8"]
}
]
},
@@ -370,61 +376,90 @@
"product": "auth",
"libs": ["js_v1", "dart_v0"]
},
+ {
+ "id": "sign-in-with-provider",
+ "title": "signInWithProvider()",
+ "slug": "auth-signinwithprovider",
+ "product": "auth",
+ "libs": ["js_v1", "dart_v0"]
+ },
{
"id": "send-mobile-otp",
"title": "sendMobileOTP()",
"slug": "auth-api-sendmobileotp",
"product": "auth",
- "libs": ["js_v1", "dart_v0"]
+ "libs": ["js_v1", "dart_v8"]
},
{
"id": "sign-in-with-password",
"title": "Sign in with password",
"slug": "auth-signinwithpassword",
"product": "auth",
- "libs": ["js", "js_v1", "dart_v0"]
+ "libs": ["js", "js_v1", "dart_v8"]
},
{
"id": "sign-in-with-otp",
"title": "Sign in with OTP",
"slug": "auth-signinwithotp",
"product": "auth",
- "libs": ["js", "js_v1", "dart_v0"]
+ "libs": ["js", "js_v1", "dart_v8"]
},
{
"id": "sign-in-with-oauth",
"title": "Sign in with 0auth",
"slug": "auth-signinwithoauth",
"product": "auth",
- "libs": ["js", "js_v1", "dart_v0"]
+ "libs": ["js", "js_v1", "dart_v8"]
},
{
"id": "sign-out",
"title": "signOut()",
"slug": "auth-signout",
"product": "auth",
- "libs": ["js", "js_v1", "dart_v0"]
+ "libs": ["js", "js_v1", "dart_v8"]
+ },
+ {
+ "id": "session",
+ "title": "session()",
+ "slug": "auth-session",
+ "product": "auth",
+ "libs": ["dart_v8"]
+ },
+ {
+ "id": "auth-update",
+ "title": "update()",
+ "slug": "auth-update",
+ "product": "auth",
+ "libs": ["dart_v8"]
+ },
+
+ {
+ "id": "user",
+ "title": "user()",
+ "slug": "auth-user",
+ "product": "auth",
+ "libs": ["dart_v8"]
},
{
"id": "verify-otp",
"title": "verifyOtp()",
"slug": "auth-verifyotp",
"product": "auth",
- "libs": ["js", "js_v1", "dart_v0"]
+ "libs": ["js", "js_v1", "dart_v8"]
},
{
"id": "current-session",
"title": "currentSession()",
"slug": "auth-currentsession",
"product": "auth",
- "libs": ["dart_v0"]
+ "libs": ["dart_v8"]
},
{
"id": "current-user",
"title": "currentUser()",
"slug": "auth-currentuser",
"product": "auth",
- "libs": ["dart_v0"]
+ "libs": ["dart_v8"]
},
{
"id": "get-session",
@@ -452,7 +487,7 @@
"title": "updateUser()",
"slug": "auth-updateuser",
"product": "auth",
- "libs": ["js", "js_v1", "dart_v0"]
+ "libs": ["js", "js_v1", "dart_v8"]
},
{
"id": "set-session",
@@ -580,14 +615,14 @@
"title": "removeSubscription()",
"slug": "removesubscription",
"product": "realtime",
- "libs": ["dart_v0"]
+ "libs": ["dart_v8"]
},
{
"id": "remove-all-subscriptions",
"title": "removeallsubscriptions()",
"slug": "removeallsubscriptions",
"product": "realtime",
- "libs": ["dart_v0"]
+ "libs": ["dart_v8"]
},
{
"id": "get-subscriptions",
@@ -602,21 +637,21 @@
"title": "removeChannel()",
"slug": "removechannel",
"product": "realtime",
- "libs": ["js", "js_v1", "dart", "dart_v0"]
+ "libs": ["js", "js_v1", "dart", "dart_v8"]
},
{
"id": "remove-all-channels",
"title": "removeAllChannels()",
"slug": "removeallchannels",
"product": "realtime",
- "libs": ["js", "js_v1", "dart", "dart_v0"]
+ "libs": ["js", "js_v1", "dart", "dart_v8"]
},
{
"id": "get-channels",
"title": "getChannels()",
"slug": "getchannels",
"product": "realtime",
- "libs": ["js2", "js_v1", "dart", "dart_v0"]
+ "libs": ["js2", "js_v1", "dart", "dart_v8"]
}
]
},
@@ -705,7 +740,7 @@
"title": "from.copy()",
"slug": "storage-from-copy",
"product": "storage",
- "libs": ["js", "js_v1", "dart_v0"]
+ "libs": ["js", "js_v1", "dart_v8"]
},
{
"id": "from-remove",
@@ -726,7 +761,7 @@
"title": "from.createSignedUrls()",
"slug": "storage-from-createsignedurls",
"product": "storage",
- "libs": ["js", "js_v1", "dart_v0"]
+ "libs": ["js", "js_v1", "dart_v8"]
},
{
"id": "from-get-public-url",
diff --git a/spec/supabase_dart_v0_temp_new_shape.yml b/spec/supabase_dart_v0_temp_new_shape.yml
index 3acbf1d2bcf..c774ffacc24 100644
--- a/spec/supabase_dart_v0_temp_new_shape.yml
+++ b/spec/supabase_dart_v0_temp_new_shape.yml
@@ -203,7 +203,29 @@ functions:
final error = res.error;
```
+ - id: session
+ title: session()
+ description: |
+ Returns the session data, if there is an active session.
+ examples:
+ - name: Get the session data
+ isSpotlight: true
+ dart: |
+ ```dart
+ final session = supabase.auth.session();
+ ```
+ - id: user
+ title: user()
+ description: |
+ Returns the user data, if there is a logged in user.
+ examples:
+ - name: Get the logged in user
+ isSpotlight: true
+ dart: |
+ ```dart
+ final user = supabase.auth.user();
+ ```
- id: get-session
title: getSession()
description: |
@@ -216,7 +238,6 @@ functions:
```dart
final session = supabase.auth.session();
```
-
- id: get-user
title: currentUser
description: |
@@ -265,7 +286,7 @@ functions:
});
```
- - id: auth-reset-password-for-email
+ - id: reset-password-for-email
title: Reset Password (Email)
description: |
Sends a reset request to an email address.
@@ -518,16 +539,15 @@ functions:
```
- id: update
+ title: 'Modify data: update()'
description: |
Performs an UPDATE on the table.
- title: 'Modify data: update()'
notes: |
- `update()` should always be combined with [Filters](/docs/reference/dart/using-filters) to target the item(s) you wish to update.
examples:
- - id: updating-your-data
- name: Updating your data
+ - name: Updating your data
isSpotlight: true
- code: |
+ dart: |
```dart
final res = await supabase
.from('cities')
@@ -535,14 +555,13 @@ functions:
.match({ 'name': 'Auckland' })
.execute();
```
- - id: updating-json-data
- name: Updating JSON data
+ - name: Updating JSON data
description: |
Postgres offers a
[number of operators](https://www.postgresql.org/docs/current/functions-json.html)
for working with JSON data. Right now it is only possible to update an entire JSON document,
but we are [working on ideas](https://github.com/PostgREST/postgrest/issues/465) for updating individual keys.
- code: |
+ dart: |
```dart
final res = await supabase
.from('users')