The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Add shortText, add ComesFrom component
Terry Sutton1e16e0fdd9bb
diff --git a/apps/docs/components/ComesFrom.tsx b/apps/docs/components/ComesFrom.tsxnew file mode 100644index 00000000000..052b50d4099--- /dev/null+++ b/apps/docs/components/ComesFrom.tsx@@ -0,0 +1,22 @@+import { FC } from 'react'+import { IconSearch } from '~/../../packages/ui'+// [Terry] — delete this after development+// just for making it easy to see where things are coming from+interface Props {+ link: string+ text: string+ className?: string+}+export const ComesFrom: FC<Props> = ({ link, text, className }) => {+ return (+ <div className={`comes-from text-xs flex items-center gap-2 -mb-6 ${className}`}>+ <span className="uppercase bg-slate-100 p-1 text-slate-600 flex gap-2 items-center">+ <IconSearch size={14} />+ Comes from:+ </span>+ <a className="text-slate-600 no-underline hover:underline" href={link}>+ {text}+ </a>+ </div>+ )+}diff --git a/apps/docs/docs/reference/javascript/v1/initializing.mdx b/apps/docs/docs/reference/javascript/v1/initializing.mdxindex 46d057e1cca..d18f8017b3e 100644--- a/apps/docs/docs/reference/javascript/v1/initializing.mdx+++ b/apps/docs/docs/reference/javascript/v1/initializing.mdx@@ -16,7 +16,7 @@ and is the easiest way to interact with everything we offer within the Supabase## Parameters<ul className="method-list-group">-+<li className="method-list-item"><h4 className="method-list-item-label"><span className="method-list-item-label-name">@@ -34,7 +34,7 @@ and is the easiest way to interact with everything we offer within the SupabaseThe unique Supabase URL which is supplied when you create a new project in your project dashboard.</div>-+</li><li className="method-list-item">@@ -54,7 +54,7 @@ The unique Supabase URL which is supplied when you create a new project in yourThe unique Supabase Key which is supplied when you create a new project in your project dashboard.</div>-+</li><li className="method-list-item">@@ -74,7 +74,7 @@ The unique Supabase Key which is supplied when you create a new project in yourNo description provided.</div>-+</li></ul>diff --git a/apps/docs/layouts/SiteLayout.tsx b/apps/docs/layouts/SiteLayout.tsxindex 7dbf79d0aa6..9bd2bc2e39e 100644--- a/apps/docs/layouts/SiteLayout.tsx+++ b/apps/docs/layouts/SiteLayout.tsx@@ -1,3 +1,4 @@+import { useEffect } from 'react'import Link from 'next/link'import { useRouter } from 'next/router'import Footer from '~/components/Footer'@@ -6,6 +7,17 @@ import TopNavBar from '~/components/Navigation/NavigationMenu/TopNavBar'const Layout = ({ children }) => {const router = useRouter()++ useEffect(() => {+ const key = localStorage.getItem('supabaseDarkMode')+ if (!key) {+ // Default to dark mode if no preference config+ document.documentElement.className = 'dark'+ } else {+ document.documentElement.className = key === 'true' ? 'dark' : ''+ }+ }, [])+return (<><main>diff --git a/apps/docs/lib/refGenerator/helpers.ts b/apps/docs/lib/refGenerator/helpers.tsindex 2b2be0980be..4129f67b843 100644--- a/apps/docs/lib/refGenerator/helpers.ts+++ b/apps/docs/lib/refGenerator/helpers.ts@@ -17,6 +17,7 @@ export function extractTsDocNode(nodeToFind: string, definition: any) {}i++}+return currentNode}diff --git a/apps/docs/package.json b/apps/docs/package.jsonindex 6eb7d215d50..8d7768df8ec 100644--- a/apps/docs/package.json+++ b/apps/docs/package.json@@ -81,15 +81,15 @@"config": "*","ejs": "^3.1.8","eslint": "8.9.0",+ "globby": "^12.0.2","minimist": "^1.2.6","next-transpile-modules": "9.0.0","npm-run-all": "^4.1.5","openapi-types": "^12.0.2",+ "prettier": "^2.2.1","sass": "^1.55.0","ts-node": "^10.9.1","tsconfig": "*",- "typescript": "^4.5.3",- "globby": "^12.0.2",- "prettier": "^2.2.1"+ "typescript": "^4.5.3"}}diff --git a/apps/docs/pages/new/reference/javascript/[...slug].tsx b/apps/docs/pages/new/reference/javascript/[...slug].tsxindex ef87acb52e1..a0461c36bb5 100644--- a/apps/docs/pages/new/reference/javascript/[...slug].tsx+++ b/apps/docs/pages/new/reference/javascript/[...slug].tsx@@ -28,12 +28,15 @@ import CodeBlock from '~/components/CodeBlock/CodeBlock'import { useRouter } from 'next/router'import { extractTsDocNode, generateParameters } from '~/lib/refGenerator/helpers'+import { ComesFrom } from '~/components/ComesFrom'+import Link from 'next/link'const marginTop = 256export default function Ref(props) {// const myRef = useRef(null)- console.log('props', props)+ //console.log('props', props)+ // console.log({ jsSpec })const [offsetY, setOffsetY] = useState(0)const [sections, setSections] = useState([])@@ -132,19 +135,21 @@ export default function Ref(props) {<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>+ <Link href={`#${x.topic}`} key={i}>+ <a+ className={[+ 'block text-sm hover:text-scale-1200 text-scale-1100 cursor-pointer',+ sections && sections[i].isActive ? 'text-brand-900' : 'text-scale-1100',+ ].join(' ')}+ // key={i}+ // onClick={() => {+ // window.scrollTo(0, x.boundingTop - marginTop)+ // setOffsetY(x.boundingTop - marginTop)+ // }}+ >+ {x.topic}+ </a>+ </Link>)})}</div>@@ -155,6 +160,7 @@ export default function Ref(props) {// ref={myRef}>{jsSpec.functions.map((item, itemIndex) => {+ if (item['$ref']) console.log('$ref', item['$ref'])// if (item.id !== 'select()') return <div>hidden section</div>// const sectionRef = useRef(null)@@ -163,7 +169,7 @@ export default function Ref(props) {// console.log('hasTsRef', hasTsRef)// console.log('jsTypeSpec', jsTypeSpec)const tsDefinition = hasTsRef && extractTsDocNode(hasTsRef, jsTypeSpec)- // console.log('tsDefinition', tsDefinition)+ console.log('tsDefinition', tsDefinition)// console.log(`tsDefinition for ${item.title ?? item.id}`, tsDefinition)// useEffect(() => {@@ -207,9 +213,11 @@ export default function Ref(props) {// console.log('serialFunctionMarkdownContent', serialFunctionMarkdownContent)+ const shortText = hasTsRef ? tsDefinition.signatures[0].comment.shortText : ''+return (<>- <header className="sticky top-0 bg-gray-600 z-10 p-4">+ <header className="sticky top-14 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 ??@@ -223,126 +231,177 @@ export default function Ref(props) {// ref={sectionRef}><div className="prose" key={item.id}>- <p className="text-lg not-prose">- {examples.functions[itemIndex].description}- </p>+ {shortText && (+ <>+ <ComesFrom+ link="https://raw.githubusercontent.com/supabase/supabase/master/spec/enrichments/tsdoc_v2/combined.json"+ text="combined.json"+ />+ <p+ className="text-lg not-prose"+ dangerouslySetInnerHTML={{ __html: shortText }}+ ></p>+ </>+ )}+ {examples.functions[itemIndex].description && (+ <>+ <ComesFrom+ link="https://github.com/supabase/supabase/pull/10095/files#diff-c514c66b77772b9e3d9a5403c136ee52dfeaaeacb1d8138ea85ce35ee64e5006"+ text="examples.yml"+ />+ <p className="text-lg not-prose">+ {examples.functions[itemIndex].description}+ </p>+ </>+ )}<hr />{functionMarkdownContent && (- <MDXRemote {...functionMarkdownContent} components={components} />+ <>+ <ComesFrom+ link="https://github.com/supabase/supabase/pull/10095/files#diff-bf42aab7d324c5330e4ae65d94803cd6da686d2241015536b0263e7f76aeca35"+ text="auth.signUp().mdx"+ />+ <MDXRemote {...functionMarkdownContent} components={components} />+ </>)}-{item.notes && (<div>+ <ComesFrom+ link="https://github.com/supabase/supabase/blob/master/spec/supabase_js_v2.yml#L105"+ text="supabase_js_v2"+ /><ReactMarkdown>{item.notes}</ReactMarkdown></div>)}-{/* // parameters */}- {parameters && <div dangerouslySetInnerHTML={{ __html: parameters }}></div>}+ {parameters && (+ <>+ <ComesFrom+ link="https://github.com/supabase/supabase/blob/master/spec/enrichments/tsdoc_v2/combined.json"+ text="combined.json"+ />+ <div dangerouslySetInnerHTML={{ __html: parameters }}></div>+ </>+ )}</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 = `+ <>+ {' '}+ <ComesFrom+ className="mb-5"+ link="https://github.com/supabase/supabase/blob/master/spec/supabase_js_v2.yml"+ text="supabase_js_v2"+ />+ <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 databaseconst 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}>- {tables &&- tables.length > 0 &&- tables.map((table) => {- console.log(table)-- // @ts-ignore- // const [content, setContent] = useState(null)-- // // @ts-ignore- // useEffect(() => {- // async function makeContent() {- // setContent(- // await serialize(table.content, {- // mdxOptions: {- // remarkPlugins: [remarkGfm],- // format: 'mdx',- // },- // })- // )- // }- // makeContent()- // }, [])-- 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} />+ 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}>+ {tables &&+ tables.length > 0 &&+ tables.map((table) => {+ console.log(table)++ // @ts-ignore+ // const [content, setContent] = useState(null)++ // // @ts-ignore+ // useEffect(() => {+ // async function makeContent() {+ // setContent(+ // await serialize(table.content, {+ // mdxOptions: {+ // remarkPlugins: [remarkGfm],+ // format: 'mdx',+ // },+ // })+ // )+ // }+ // makeContent()+ // }, [])++ 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>- <h5 className="text-xs text-scale-1200">- {table.name}- </h5></div>- </div>- {/* <ReactMarkdown>{table.content}</ReactMarkdown> */}- {/* {content && <MDXRemote {...content} />} */}- </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 && (+ {/* <ReactMarkdown>{table.content}</ReactMarkdown> */}+ {/* {content && <MDXRemote {...content} />} */}+ </div>+ )+ })}+ {sql && (+ <CodeBlock+ className="useless-code-block-class"+ language="sql"+ hideLineNumbers={true}+ >+ {sql}+ </CodeBlock>+ )}<CodeBlockclassName="useless-code-block-class"- language="json"+ language="js"hideLineNumbers={true}>- {response}+ {exampleString ++ (example.code &&+ example.code+ .replace('```', '')+ .replace('js', '')+ .replace('```', ''))}</CodeBlock>- )}- </Tabs.Panel>- )- })}- </Tabs>+ {response && (+ <>+ <ComesFrom+ className="mb-5 mt-5"+ link="https://github.com/supabase/supabase/pull/10095/files#diff-c514c66b77772b9e3d9a5403c136ee52dfeaaeacb1d8138ea85ce35ee64e5006"+ text="examples.yml"+ />+ <CodeBlock+ className="useless-code-block-class"+ language="json"+ hideLineNumbers={true}+ >+ {response}+ </CodeBlock>+ </>+ )}+ </Tabs.Panel>+ )+ })}+ </Tabs>+ </>)}</div></div>diff --git a/spec/supabase_js_v2_temp_new_shape--reduced.yml b/spec/supabase_js_v2_temp_new_shape--reduced.ymlindex 2e5c827cd45..05b96c47ac5 100644--- a/spec/supabase_js_v2_temp_new_shape--reduced.yml+++ b/spec/supabase_js_v2_temp_new_shape--reduced.yml@@ -15,93 +15,6 @@ info:version: '0.0.1'functions:- - id: initializing- $ref: '@supabase/supabase-js.index.SupabaseClient.constructor'- description: |- You can initialize a new Supabase client using the `createClient()` method.-- The Supabase client is your entrypoint to the rest of the Supabase functionality- and is the easiest way to interact with everything we offer within the Supabase ecosystem.-- examples:- - id: create-client- name: createClient()- code: |- ```js- 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')- ```- - id: with-additional-parameters- name: With additional parameters- code: |- ```js- import { createClient } from '@supabase/supabase-js'-- const options = {- db: {- schema: 'public',- },- auth: {- autoRefreshToken: true,- persistSession: true,- detectSessionInUrl: true- },- global: {- headers: { 'x-my-custom-header': 'my-app-name' },- },- }- const supabase = createClient("https://xyzcompany.supabase.co", "public-anon-key", options)- ```- - id: api-schemas- name: API schemas- code: |- ```js- import { createClient } from '@supabase/supabase-js'-- // Provide a custom schema. Defaults to "public".- const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key', {- db: { schema: 'other_schema' }- })- ```-- By default the API server points to the `public` schema. You can enable other database schemas within the Dashboard.- Go to `Settings > API > Schema` and add the schema which you want to expose to the API.-- Note: each client connection can only access a single schema, so the code above can access the `other_schema` schema but cannot access the `public` schema.- - id: custom-fetch-implementation- name: Custom `fetch` implementation- code: |- ```js- import { createClient } from '@supabase/supabase-js'-- const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key', {- global: { fetch: fetch.bind(globalThis) }- })- ```-- `supabase-js` uses the [`cross-fetch`](https://www.npmjs.com/package/cross-fetch) library to make HTTP requests,- but an alternative `fetch` implementation can be provided as an option.- This is most useful in environments where `cross-fetch` is not compatible (for instance Cloudflare Workers).- - id: react-native-options- name: React Native options- code: |- ```js- import { createClient } from '@supabase/supabase-js'- import AsyncStorage from "@react-native-async-storage/async-storage";-- const supabase = createClient("https://xyzcompany.supabase.co", "public-anon-key", {- auth: {- storage: AsyncStorage,- autoRefreshToken: true,- persistSession: true,- detectSessionInUrl: false,- },- });- ```-- For React Native we recommend using `AsyncStorage` as the storage implementation for Supabase Auth.- id: auth.signUp()title: 'signUp()'$ref: '@supabase/gotrue-js.GoTrueClient.signUp'@@ -144,158 +57,3 @@ functions:})```- - id: auth.signInWithPassword()- title: 'signInWithPassword()'- $ref: '@supabase/gotrue-js.GoTrueClient.signInWithPassword'- notes: |- - Requires either an email and password or a phone number and password.- examples:- - id: sign-in-with-email-and-password- name: Sign in with email and password- isSpotlight: true- code: |- ```js- const { data, error } = await supabase.auth.signInWithPassword({- email: '[email protected]',- password: 'example-password',- })- ```- - id: sign-in-with-phone-and-password- name: Sign in with phone and password- isSpotlight: false- code: |- ```js- const { data, error } = await supabase.auth.signInWithPassword({- phone: '+13334445555',- password: 'some-password',- })-- // After receiving a SMS with a OTP.- const { data, error } = await supabase.auth.verifyOtp({- phone: '+13334445555',- token: '123456',- })- ```- - id: auth.signInWithOtp()- title: 'signInWithOtp()'- $ref: '@supabase/gotrue-js.GoTrueClient.signInWithOtp'- notes: |- - Requires either an email or phone number.- - This method is used for passwordless sign-ins where a OTP is sent to the user's email or phone number.- - If you're using an email, you can configure whether you want the user to receive a magiclink or a OTP.- - If you're using phone, you can configure whether you want the user to receive a OTP.- - The magic link's destination URL is determined by the [`SITE_URL`](https://supabase.com/docs/reference/auth/config#site_url). You can modify the `SITE_URL` or add additional redirect urls in [your project](https://app.supabase.com/project/_/auth/settings).- examples:- - id: sign-in-with-email.- name: Sign in with email.- isSpotlight: true- description: The user will be sent an email which contains either a magiclink or a OTP or both. By default, a given user can only request a OTP once every 60 seconds.- code: |- ```js- const { data, error } = await supabase.auth.signInWithOtp({- email: '[email protected]',- })- ```- - id: sign-in-with-sms-otp.- name: Sign in with SMS OTP.- isSpotlight: false- description: The user will be sent a SMS which contains a OTP. By default, a given user can only request a OTP once every 60 seconds.- code: |- ```js- const { data, error } = await supabase.auth.signInWithOtp({- phone: '+13334445555',- })- ```- - id: auth.signInWithOAuth()- title: 'signInWithOAuth()'- $ref: '@supabase/gotrue-js.GoTrueClient.signInWithOAuth'- notes: |- - This method is used for signing in using a third-party provider.- - Supabase supports many different [third-party providers](https://supabase.com/docs/guides/auth#providers).- examples:- - id: sign-in-using-a-third-party-provider- name: Sign in using a third-party provider-- isSpotlight: true- code: |- ```js- const { data, error } = await supabase.auth.signInWithOAuth({- provider: 'github'- })- ```- - id: sign-in-using-a-third-party-provider-with-redirect- name: Sign in using a third-party provider with redirect- isSpotlight: false- description: |- When the third-party provider successfully authenticates the user, the provider will redirect the user to the URL specified in the `redirectTo` parameter. This parameter defaults to the [`SITE_URL`](https://supabase.com/docs/reference/auth/config#site_url). It does not redirect the user immediately after invoking this method.- You can modify the `SITE_URL` or add additional redirect urls in [your project](https://app.supabase.com/project/_/auth/settings).- code: |- ```js- const { data, error } = await supabase.auth.signInWithOAuth({- provider: 'github'- options: {- redirectTo: 'https://example.com/welcome'- }- }- ```- - id: sign-in-with-scopes- name: Sign in with scopes- isSpotlight: false- description: |- If you need additional data from an OAuth provider, you can include a space-separated list of scopes in your request to get back an OAuth provider token.- You may also need to specify the scopes in the provider's OAuth app settings, depending on the provider. The list of scopes will be documented by the third-party provider you are using and specifying scopes will enable you to use the OAuth provider token to call additional APIs supported by the third-party provider to get more information.- code: |- ```js- const { data, error } = await supabase.auth.signInWithOAuth({- provider: 'github'- options: {- scopes: 'repo gist notifications'- }- })- const oAuthToken = data.session.provider_token // use to access provider API- ```- - id: auth.signOut()- title: 'signOut()'- $ref: '@supabase/gotrue-js.GoTrueClient.signOut'- notes: |- - In order to use the `signOut()` method, the user needs to be signed in first.- examples:- - id: sign-out- name: Sign out- isSpotlight: true- code: |- ```js- const { error } = await supabase.auth.signOut()- ```- - id: auth.verifyOtp()- title: 'verifyOtp()'- $ref: '@supabase/gotrue-js.GoTrueClient.verifyOtp'- notes: |- - The `verifyOtp` method takes in different verification types. If a phone number is used, the type can either be `sms` or `phone_change`. If an email address is used, the type can be one of the following: `signup`, `magiclink`, `recovery`, `invite` or `email_change`.- - The verification type used should be determined based on the corresponding auth method called before `verifyOtp` to sign up / sign-in a user.- examples:- - id: verify-sms-one-time-password(otp)- name: Verify Sms One-Time Password (OTP)- isSpotlight: true- code: |- ```js- const { data, error } = await supabase.auth.verifyOtp({ phone, token, type: 'sms'})- ```- - id: verify-signup-one-time-password(otp)- name: Verify Signup One-Time Password (OTP)- isSpotlight: false- code: |- ```js- const { data, error } = await supabase.auth.verifyOtp({ email, token, type: 'signup'})- ```- - id: auth.getSession()- title: 'getSession()'- $ref: '@supabase/gotrue-js.GoTrueClient.getSession'- examples:- - id: get-the-session-data- name: Get the session data- isSpotlight: true- code: |- ```js- const { data, error } = await supabase.auth.getSession()- ```