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

Jonathan Summers-Muir2cba3a975420
diff --git a/apps/docs/components/reference/RefFunctionSection.tsx b/apps/docs/components/reference/RefFunctionSection.tsx
index 69027fb6763..d5b7cd88955 100644
--- a/apps/docs/components/reference/RefFunctionSection.tsx
+++ b/apps/docs/components/reference/RefFunctionSection.tsx
@@ -22,12 +22,12 @@ interface ICommonFunc {
interface IRefFunctionSection {
funcData: any
commonFuncData: ICommonFunc
- libSpec: any
- typeSpec: any
+ spec: any
+ typeSpec?: any
}
const RefFunctionSection: React.FC<IRefFunctionSection> = (props) => {
- const item = props.libSpec.functions.find((x: any) => x.id === props.funcData.id)
+ const item = props.spec.functions.find((x: any) => x.id === props.funcData.id)
// gracefully return nothing if function does not exist
if (!item) return <></>
@@ -38,9 +38,11 @@ const RefFunctionSection: React.FC<IRefFunctionSection> = (props) => {
// console.log(item)
const hasTsRef = item['$ref'] || null
- const tsDefinition = hasTsRef && extractTsDocNode(hasTsRef, props.typeSpec)
- const parameters = hasTsRef ? generateParameters(tsDefinition) : ''
- const shortText = hasTsRef ? tsDefinition.signatures[0].comment.shortText : ''
+
+ const tsDefinition =
+ hasTsRef && props.typeSpec ? extractTsDocNode(hasTsRef, props.typeSpec) : null
+ const parameters = hasTsRef && tsDefinition ? generateParameters(tsDefinition) : ''
+ const shortText = hasTsRef && tsDefinition ? tsDefinition.signatures[0].comment.shortText : ''
return (
<>
diff --git a/apps/docs/docs/ref/js/database.mdx b/apps/docs/docs/ref/js/database.mdx
new file mode 100644
index 00000000000..5165b487991
--- /dev/null
+++ b/apps/docs/docs/ref/js/database.mdx
@@ -0,0 +1,19 @@
+---
+hideTitle: true
+---
+
+<div className="flex items-center gap-3 not-prose">
+ <div className="w-8 h-8 bg-brand-500 rounded flex items-center justify-center">
+ <img className="w-6 h-6" src="/docs/img/icons/menu/database.svg" />
+ </div>
+ <h2>Database</h2>
+</div>
+
+<RefSubLayout.EducationRow>
+ <RefSubLayout.Details>
+ <p className="text-lg">
+ Every Supabase project comes with a full Postgres database, a free and open source database
+ which is considered one of the world's most stable and advanced databases.
+ </p>
+ </RefSubLayout.Details>
+</RefSubLayout.EducationRow>
diff --git a/apps/docs/docs/ref/js/v1/introduction.mdx b/apps/docs/docs/ref/js/v1/introduction.mdx
new file mode 100644
index 00000000000..95e99f2d978
--- /dev/null
+++ b/apps/docs/docs/ref/js/v1/introduction.mdx
@@ -0,0 +1,20 @@
+---
+id: introduction
+title: Introduction
+hideTitle: true
+---
+
+<div className="flex items-start gap-6 not-prose">
+ <img src="/docs/img/icons/javascript-icon.svg" className="w-8 h-8 rounded" />
+ <div className="flex flex-col gap-2">
+ <h1 className="text-3xl text-scale-1200 m-0">Javascript Client Library</h1>
+ <h2 className="text-base font-mono text-scale-1100">@supabase/supabase-js</h2>
+ </div>
+</div>
+
+<div className="max-w-xl">
+ This reference documents every object and method available in Supabase's isomorphic JavaScript
+ library, supabase-js. You can use supabase-js to interact with your Postgres database, listen to
+ database changes, invoke Deno Edge Functions, build login and user management functionality, and
+ manage large files.
+</div>
diff --git a/apps/docs/pages/reference/dart/[...slug].tsx b/apps/docs/pages/reference/dart/[...slug].tsx
index 462396f95df..1dc62468490 100644
--- a/apps/docs/pages/reference/dart/[...slug].tsx
+++ b/apps/docs/pages/reference/dart/[...slug].tsx
@@ -1,53 +1,32 @@
-import { useEffect } from 'react'
-
-import fs from 'fs'
-import toc from 'markdown-toc'
-
-import matter from 'gray-matter'
import { MDXRemote } from 'next-mdx-remote'
-import { serialize } from 'next-mdx-remote/serialize'
-import components from '~/components/index'
-import { getAllDocs, getDocsBySlug } from '~/lib/docs'
-
-import ReactMarkdown from 'react-markdown'
-import RefDetailCollapse from '~/components/reference/RefDetailCollapse'
-
-// @ts-ignore
-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 dartSpec from '~/../../spec/supabase_dart_v1_temp_new_shape.yml' assert { type: 'yml' }
-
-import commonLibJson from '~/../../spec/common-client-libs-sections.json'
-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'
-
-import OldLayout from '~/layouts/Default'
-
+import { useEffect } from 'react'
import clientLibsCommonSections from '~/../../spec/common-client-libs-sections.json'
+// @ts-expect-error
+import spec from '~/../../spec/supabase_dart_v1_temp_new_shape.yml' assert { type: 'yml' }
+import components from '~/components'
+import RefEducationSection from '~/components/reference/RefEducationSection'
+import RefFunctionSection from '~/components/reference/RefFunctionSection'
+import OldLayout from '~/layouts/Default'
+import { getAllDocs } from '~/lib/docs'
+import { flattenSections } from '~/lib/helpers'
+import generateOldRefMarkdown from '~/lib/mdx/generateOldRefMarkdown'
+import generateRefMarkdown from '~/lib/mdx/generateRefMarkdown'
-const allFunctions = Object.values(clientLibsCommonSections.sections.functions)
- .map((fn: any) => fn.items)
- .flat(2)
+const sections = flattenSections(clientLibsCommonSections)
-export default function DartReference(props) {
- //console.log('docs', props.docs)
+export default function JSReference(props) {
+ // console.log('docs', props.docs)
const router = useRouter()
+
const slug = router.query.slug[0]
const isNewDocs = process.env.NEXT_PUBLIC_NEW_DOCS === 'true'
+ // When user lands on a url like http://supabase.com/docs/reference/javascript/sign-up
+ // find the #sign-up element and scroll to that
useEffect(() => {
if (isNewDocs && document && slug !== 'start') {
- // re-enable this when the new yaml shape file is moved into this branch
document.querySelector(`#${slug}`) && document.querySelector(`#${slug}`).scrollIntoView()
}
})
@@ -66,275 +45,35 @@ export default function DartReference(props) {
return (
<>
- <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}
- singleColumn={true}
- >
- <MDXRemote {...item.content} components={components} />
- </RefSubLayout.Section>
- ))}
- </RefSubLayout>
- <hr />
- <RefSubLayout>
- {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 : ''
+ {sections.map((x) => {
+ switch (x.isFunc) {
+ case false:
+ const markdownData = props.docs.find((doc) => doc.id === x.id)
+ console.log(markdownData)
- // const introFileMarkdownContent =
- //console.log('props.docs', props.docs)
- // if (item.id !== 'db-modifiers-select') return <></>
+ return <RefEducationSection item={x} markdownContent={markdownData} />
+ break
+ default:
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>
- )}
- </Param>
- )
- })}
- </ul>
- </div>
- )}
- </>
- </RefSubLayout.Details>
- <RefSubLayout.Examples>
- {item.examples && item.examples.length > 0 && (
- <>
- <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"
- >
- {((tables && tables.length > 0) || sql) && (
- <RefDetailCollapse
- 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>
- )}
- </>
- </RefDetailCollapse>
- )}
-
- <CodeBlock
- className="useless-code-block-class"
- language="js"
- hideLineNumbers={true}
- >
- {exampleString +
- (example.code &&
- example.code
- .replace('```', '')
- .replace('js', '')
- .replace('```', ''))}
- </CodeBlock>
- {response && (
- <RefDetailCollapse
- 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>
- </RefDetailCollapse>
- )}
- </Tabs.Panel>
- )
- })}
- </Tabs>
- </>
- )}
- </RefSubLayout.Examples>
- </RefSubLayout.Section>
- </>
+ <RefFunctionSection
+ funcData={x}
+ commonFuncData={x}
+ spec={spec}
+ // typeSpec={jsTypeSpec}
+ />
)
- })}
- </RefSubLayout>
+ break
+ }
+ })}
</>
)
}
export async function getStaticProps({ params }: { params: { slug: string[] } }) {
- // 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
- * - custom text
- * - call outs
- * - important notes regarding implementation
- */
- const allMarkdownDocs = await Promise.all(
- pages.map(async (x, i) => {
- const pathName = `docs/ref/dart/${x}.mdx`
-
- function checkFileExists(x) {
- // console.log('checking this ', x)
- if (fs.existsSync(x)) {
- return true
- } else {
- return false
- }
- }
-
- const markdownExists = checkFileExists(pathName)
+ let markdownContent = await generateRefMarkdown(sections, '/dart')
- console.log(x, 'markdownExists', markdownExists)
-
- const fileContents = markdownExists ? fs.readFileSync(pathName, 'utf8') : ''
- const { data, content } = matter(fileContents)
-
- return {
- id: x,
- title: x,
- // ...content,
- meta: data,
- introPage: introPages.includes(x),
- content: content ? await serialize(content || '') : null,
- }
- })
- )
+ console.log(markdownContent)
/*
* old content generation
@@ -352,22 +91,11 @@ export async function getStaticProps({ params }: { params: { slug: string[] } })
* handle old ref pages
*/
if (process.env.NEXT_PUBLIC_NEW_DOCS === 'false') {
- let doc = getDocsBySlug(slug)
- const content = await serialize(doc.content || '')
- return {
- props: {
- /*
- * old reference docs are below
- */
- ...doc,
- content,
- toc: toc(doc.content, { maxdepth: 1, firsth1: false }),
- },
- }
+ return await generateOldRefMarkdown(slug)
} else {
return {
props: {
- docs: allMarkdownDocs,
+ docs: markdownContent,
},
}
}
@@ -387,3 +115,7 @@ export function getStaticPaths() {
fallback: 'blocking',
}
}
+
+export const config = {
+ unstable_includeFiles: ['node_modules/**/shiki/**/*.json'],
+}
diff --git a/packages/config/tailwind.config.js b/packages/config/tailwind.config.js
index 0f1c25dbfe3..5fd41709ca8 100644
--- a/packages/config/tailwind.config.js
+++ b/packages/config/tailwind.config.js
@@ -21,6 +21,7 @@ module.exports = ui({
'./components/**/*.tsx',
'./layouts/**/*.tsx',
'./pages/**/*.{tsx,mdx}',
+ './docs/**/*.{tsx,mdx}',
'./_blog/*.mdx',
// purge styles from supabase ui theme
],
@@ -213,17 +214,17 @@ module.exports = ui({
},
}),
screens: {
- xs: '480px'
- // sm: '640px',
- // // => @media (min-width: 640px) { ... }
- // md: '768px',
- // // => @media (min-width: 768px) { ... }
- // lg: '1024px',
- // // => @media (min-width: 1024px) { ... }
- // xl: '1280px',
- // // => @media (min-width: 1280px) { ... }
- // '2xl': '1536px',
- // // => @media (min-width: 1536px) { ... }
+ xs: '480px',
+ // sm: '640px',
+ // // => @media (min-width: 640px) { ... }
+ // md: '768px',
+ // // => @media (min-width: 768px) { ... }
+ // lg: '1024px',
+ // // => @media (min-width: 1024px) { ... }
+ // xl: '1280px',
+ // // => @media (min-width: 1280px) { ... }
+ // '2xl': '1536px',
+ // // => @media (min-width: 1536px) { ... }
},
// colors: {
// 'gray-light': '#7B7F86',
diff --git a/spec/common-client-libs-sections-old.json b/spec/common-client-libs-sections-old.json
index ec7ac40b649..e4f7544e944 100644
--- a/spec/common-client-libs-sections-old.json
+++ b/spec/common-client-libs-sections-old.json
@@ -47,20 +47,6 @@
]
}
},
- {
- "id": "select",
- "title": "Fetch data",
- "slug": "select",
- "product": "database",
- "libs": ["js", "js_v1", "dart", "dart_v0"]
- },
- {
- "id": "insert",
- "title": "Insert data",
- "slug": "insert",
- "product": "database",
- "libs": ["js", "js_v1", "dart", "dart_v0"]
- },
"functions": [
{
"title": "Database",
diff --git a/spec/common-client-libs-sections.json b/spec/common-client-libs-sections.json
index 5a7daa4a2cb..583b8dcf390 100644
--- a/spec/common-client-libs-sections.json
+++ b/spec/common-client-libs-sections.json
@@ -26,7 +26,7 @@
{
"id": "database",
"title": "Database",
- "slug": "database",
+ "slug": "overview",
"product": "database",
"isFunc": false,
"libs": ["js", "js_v1", "dart", "dart_v0"]