From 893fb1fa4e04c4eefbde8610b894f2229d054066 Mon Sep 17 00:00:00 2001 From: Copple <10214025+kiwicopple@users.noreply.github.com> Date: Wed, 5 Oct 2022 14:30:28 +0200 Subject: [PATCH] prettier --- apps/reference/_api/usage.mdx | 536 +++--------------- apps/reference/_gotrue/config.mdx | 16 +- apps/reference/_gotrue/usage.mdx | 7 +- .../version-v1/generating-types.mdx | 20 +- .../version-v1/index.mdx | 9 +- .../version-v1/initializing.mdx | 70 +-- .../version-v1/installing.mdx | 11 +- apps/reference/docs/about.mdx | 11 +- .../docs/guides/auth/auth-helpers/index.mdx | 10 +- .../docs/guides/auth/auth-helpers/nextjs.mdx | 2 +- .../guides/auth/auth-helpers/sveltekit.mdx | 418 +++++++------- .../docs/guides/cli/local-development.mdx | 2 +- .../database/connecting-to-postgres.mdx | 7 +- .../database/migrating-between-projects.mdx | 3 +- apps/reference/docs/guides/functions.mdx | 18 +- .../docs/guides/hosting/platform.mdx | 15 +- .../docs/guides/integrations/authsignal.mdx | 3 +- .../docs/guides/integrations/polyscale.mdx | 2 +- .../docs/guides/migrations/firebase-auth.mdx | 28 +- .../guides/migrations/firebase-storage.mdx | 10 +- .../docs/guides/migrations/firestore-data.mdx | 159 +++--- .../docs/guides/migrations/heroku.mdx | 8 +- .../docs/guides/platform/disk-usage.mdx | 1 - apps/reference/docs/guides/platform/logs.mdx | 54 +- .../docs/guides/realtime/broadcast.mdx | 2 +- apps/reference/docs/guides/with-expo.mdx | 80 ++- .../docs/guides/with-ionic-react.mdx | 2 +- apps/reference/docs/guides/with-nuxt-3.mdx | 16 +- apps/reference/docs/guides/with-solidjs.mdx | 20 +- apps/reference/docs/guides/with-svelte.mdx | 66 ++- apps/reference/docs/guides/with-sveltekit.mdx | 37 +- apps/reference/generator/legacy.ts | 4 +- 32 files changed, 687 insertions(+), 960 deletions(-) diff --git a/apps/reference/_api/usage.mdx b/apps/reference/_api/usage.mdx index 09584d7a96b..26e64d10479 100644 --- a/apps/reference/_api/usage.mdx +++ b/apps/reference/_api/usage.mdx @@ -5,25 +5,17 @@ title: Usage toc_max_heading_level: 3 --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - +import Tabs from '@theme/Tabs' +import TabItem from '@theme/TabItem' - - - - - ## Organizations {#organizations} Organization endpoints - - ### List all organizations {#list-all-organizations} @@ -34,15 +26,8 @@ GET https://api.supabase.com/v1/organizations - - - - - - - #### Responses @@ -51,11 +36,8 @@ GET https://api.supabase.com/v1/organizations - - - ```json { "schema": { @@ -70,16 +52,12 @@ GET https://api.supabase.com/v1/organizations "type": "string" } }, - "required": [ - "id", - "name" - ] + "required": ["id", "name"] } } } ``` - @@ -90,8 +68,6 @@ Unexpected error listing organizations - - @@ -100,7 +76,6 @@ Unexpected error listing organizations
- ### Create an organization {#create-an-organization} @@ -111,14 +86,8 @@ POST https://api.supabase.com/v1/organizations - - - - - - #### Body Parameters ```json @@ -130,14 +99,11 @@ POST https://api.supabase.com/v1/organizations "type": "string" } }, - "required": [ - "name" - ] + "required": ["name"] } } ``` - #### Responses @@ -146,11 +112,8 @@ POST https://api.supabase.com/v1/organizations - - - ```json { "schema": { @@ -163,15 +126,11 @@ POST https://api.supabase.com/v1/organizations "type": "string" } }, - "required": [ - "id", - "name" - ] + "required": ["id", "name"] } } ``` - @@ -182,8 +141,6 @@ Unexpected error creating an organization - - @@ -192,14 +149,10 @@ Unexpected error creating an organization
- - ## Projects {#projects} Project endpoints - - ### List all projects {#list-all-projects} @@ -210,15 +163,8 @@ GET https://api.supabase.com/v1/projects - - - - - - - #### Responses @@ -227,11 +173,8 @@ GET https://api.supabase.com/v1/projects - - - ```json { "schema": { @@ -255,19 +198,12 @@ GET https://api.supabase.com/v1/projects "type": "string" } }, - "required": [ - "id", - "organization_id", - "name", - "region", - "created_at" - ] + "required": ["id", "organization_id", "name", "region", "created_at"] } } } ``` - @@ -276,7 +212,6 @@ GET https://api.supabase.com/v1/projects
- ### Create a project {#create-a-project} @@ -287,14 +222,8 @@ POST https://api.supabase.com/v1/projects - - - - - - #### Body Parameters ```json @@ -313,10 +242,7 @@ POST https://api.supabase.com/v1/projects }, "plan": { "type": "string", - "enum": [ - "free", - "pro" - ] + "enum": ["free", "pro"] }, "region": { "type": "string", @@ -339,18 +265,11 @@ POST https://api.supabase.com/v1/projects "type": "boolean" } }, - "required": [ - "db_pass", - "name", - "organization_id", - "plan", - "region" - ] + "required": ["db_pass", "name", "organization_id", "plan", "region"] } } ``` - #### Responses @@ -359,11 +278,8 @@ POST https://api.supabase.com/v1/projects - - - ```json { "schema": { @@ -385,18 +301,11 @@ POST https://api.supabase.com/v1/projects "type": "string" } }, - "required": [ - "id", - "organization_id", - "name", - "region", - "created_at" - ] + "required": ["id", "organization_id", "name", "region", "created_at"] } } ``` - @@ -405,7 +314,6 @@ POST https://api.supabase.com/v1/projects
- ### List all functions {#list-all-functions} @@ -416,39 +324,24 @@ GET https://api.supabase.com/v1/projects/{ref}/functions - #### Path Parameters - - - - - - #### Responses @@ -457,11 +350,8 @@ GET https://api.supabase.com/v1/projects/{ref}/functions - - - ```json { "schema": { @@ -479,11 +369,7 @@ GET https://api.supabase.com/v1/projects/{ref}/functions "type": "string" }, "status": { - "enum": [ - "ACTIVE", - "REMOVED", - "THROTTLED" - ], + "enum": ["ACTIVE", "REMOVED", "THROTTLED"], "type": "string" }, "version": { @@ -513,19 +399,14 @@ GET https://api.supabase.com/v1/projects/{ref}/functions } ``` - - - - - @@ -536,8 +417,6 @@ Failed to retrieve project's functions - - @@ -546,7 +425,6 @@ Failed to retrieve project's functions
- ### Create a function {#create-a-function} @@ -557,38 +435,24 @@ POST https://api.supabase.com/v1/projects/{ref}/functions - #### Path Parameters - - - - - #### Body Parameters ```json @@ -610,16 +474,11 @@ POST https://api.supabase.com/v1/projects/{ref}/functions "type": "boolean" } }, - "required": [ - "slug", - "name", - "body" - ] + "required": ["slug", "name", "body"] } } ``` - #### Responses @@ -628,11 +487,8 @@ POST https://api.supabase.com/v1/projects/{ref}/functions - - - ```json { "schema": { @@ -648,11 +504,7 @@ POST https://api.supabase.com/v1/projects/{ref}/functions "type": "string" }, "status": { - "enum": [ - "ACTIVE", - "REMOVED", - "THROTTLED" - ], + "enum": ["ACTIVE", "REMOVED", "THROTTLED"], "type": "string" }, "version": { @@ -681,19 +533,14 @@ POST https://api.supabase.com/v1/projects/{ref}/functions } ``` - - - - - @@ -704,8 +551,6 @@ Failed to create project's function - - @@ -714,7 +559,6 @@ Failed to create project's function
- ### Retrieve a function {#retrieve-a-function} @@ -725,57 +569,34 @@ GET https://api.supabase.com/v1/projects/{ref}/functions/{function_slug} - #### Path Parameters - - - - - - #### Responses @@ -784,11 +605,8 @@ GET https://api.supabase.com/v1/projects/{ref}/functions/{function_slug} - - - ```json { "schema": { @@ -804,11 +622,7 @@ GET https://api.supabase.com/v1/projects/{ref}/functions/{function_slug} "type": "string" }, "status": { - "enum": [ - "ACTIVE", - "REMOVED", - "THROTTLED" - ], + "enum": ["ACTIVE", "REMOVED", "THROTTLED"], "type": "string" }, "version": { @@ -840,19 +654,14 @@ GET https://api.supabase.com/v1/projects/{ref}/functions/{function_slug} } ``` - - - - - @@ -863,8 +672,6 @@ Failed to retrieve function with given slug - - @@ -873,7 +680,6 @@ Failed to retrieve function with given slug
- ### Update a function {#update-a-function} @@ -884,56 +690,34 @@ PATCH https://api.supabase.com/v1/projects/{ref}/functions/{function_slug} - #### Path Parameters - - - - - #### Body Parameters ```json @@ -955,7 +739,6 @@ PATCH https://api.supabase.com/v1/projects/{ref}/functions/{function_slug} } ``` - #### Responses @@ -964,11 +747,8 @@ PATCH https://api.supabase.com/v1/projects/{ref}/functions/{function_slug} - - - ```json { "schema": { @@ -984,11 +764,7 @@ PATCH https://api.supabase.com/v1/projects/{ref}/functions/{function_slug} "type": "string" }, "status": { - "enum": [ - "ACTIVE", - "REMOVED", - "THROTTLED" - ], + "enum": ["ACTIVE", "REMOVED", "THROTTLED"], "type": "string" }, "version": { @@ -1017,19 +793,14 @@ PATCH https://api.supabase.com/v1/projects/{ref}/functions/{function_slug} } ``` - - - - - @@ -1040,8 +811,6 @@ Failed to update function with given slug - - @@ -1050,7 +819,6 @@ Failed to update function with given slug
- ### Delete a function {#delete-a-function} @@ -1061,57 +829,34 @@ DELETE https://api.supabase.com/v1/projects/{ref}/functions/{function_slug} - #### Path Parameters - - - - - - #### Responses @@ -1120,24 +865,16 @@ DELETE https://api.supabase.com/v1/projects/{ref}/functions/{function_slug} - - - - - - - - @@ -1148,8 +885,6 @@ Failed to delete function with given slug - - @@ -1158,7 +893,6 @@ Failed to delete function with given slug
- ### List all secrets {#list-all-secrets} @@ -1169,39 +903,24 @@ GET https://api.supabase.com/v1/projects/{ref}/secrets - #### Path Parameters - - - - - - #### Responses @@ -1210,11 +929,8 @@ GET https://api.supabase.com/v1/projects/{ref}/secrets - - - ```json { "schema": { @@ -1229,28 +945,20 @@ GET https://api.supabase.com/v1/projects/{ref}/secrets "type": "string" } }, - "required": [ - "name", - "value" - ] + "required": ["name", "value"] } } } ``` - - - - - @@ -1261,8 +969,6 @@ Failed to retrieve project's secrets - - @@ -1271,7 +977,6 @@ Failed to retrieve project's secrets
- ### Bulk create secrets {#bulk-create-secrets} @@ -1282,38 +987,24 @@ POST https://api.supabase.com/v1/projects/{ref}/secrets - #### Path Parameters - - - - - #### Body Parameters ```json @@ -1331,16 +1022,12 @@ POST https://api.supabase.com/v1/projects/{ref}/secrets "pattern": "/^(?!SUPABASE_).*/" } }, - "required": [ - "name", - "value" - ] + "required": ["name", "value"] } } } ``` - #### Responses @@ -1349,24 +1036,16 @@ POST https://api.supabase.com/v1/projects/{ref}/secrets - - - - - - - - @@ -1377,8 +1056,6 @@ Failed to create project's secrets - - @@ -1387,7 +1064,6 @@ Failed to create project's secrets
- ### Bulk delete secrets {#bulk-delete-secrets} @@ -1398,38 +1074,24 @@ DELETE https://api.supabase.com/v1/projects/{ref}/secrets - #### Path Parameters - - - - - #### Body Parameters ```json @@ -1443,7 +1105,6 @@ DELETE https://api.supabase.com/v1/projects/{ref}/secrets } ``` - #### Responses @@ -1452,11 +1113,8 @@ DELETE https://api.supabase.com/v1/projects/{ref}/secrets - - - ```json { "schema": { @@ -1465,19 +1123,14 @@ DELETE https://api.supabase.com/v1/projects/{ref}/secrets } ``` - - - - - @@ -1488,8 +1141,6 @@ Failed to delete secrets with given names - - @@ -1497,4 +1148,3 @@ Failed to delete secrets with given names
- diff --git a/apps/reference/_gotrue/config.mdx b/apps/reference/_gotrue/config.mdx index 9a00a5a380e..391c9378400 100644 --- a/apps/reference/_gotrue/config.mdx +++ b/apps/reference/_gotrue/config.mdx @@ -11,25 +11,21 @@ A `config.toml` file is generated after running `supabase init`. This file is located in the `supabase` folder under `supabase/config.toml`. - - - ## General {#general} - - ### `project_id` {#project_id} A string used to distinguish different Supabase projects on the same host. Defaults to the working directory name when running `supabase init`. -
- - diff --git a/apps/reference/_gotrue/usage.mdx b/apps/reference/_gotrue/usage.mdx index 64eed5538f0..3a4a64e2d2f 100644 --- a/apps/reference/_gotrue/usage.mdx +++ b/apps/reference/_gotrue/usage.mdx @@ -5,14 +5,11 @@ title: Usage toc_max_heading_level: 3 --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - +import Tabs from '@theme/Tabs' +import TabItem from '@theme/TabItem' Documentation of the gotrue API. - - diff --git a/apps/reference/_supabase_js_versioned_docs/version-v1/generating-types.mdx b/apps/reference/_supabase_js_versioned_docs/version-v1/generating-types.mdx index 83aa820316b..033cfdb9165 100644 --- a/apps/reference/_supabase_js_versioned_docs/version-v1/generating-types.mdx +++ b/apps/reference/_supabase_js_versioned_docs/version-v1/generating-types.mdx @@ -1,12 +1,12 @@ --- id: generating-types -title: "Generating Types" +title: 'Generating Types' slug: generating-types custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v1.yml --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; +import Tabs from '@theme/Tabs' +import TabItem from '@theme/TabItem' Supabase will soon release native type generators that dump your database types for various languages. For now, we support TypeScript [through third-party tools](/docs/guides/api/generating-types). @@ -19,12 +19,12 @@ If you don't provide a type for the row you need to explicitly pass `from(' ```ts type Message = { - id: number; - inserted_at: string; - message: string; - user_id: string; - channel_id: number; - author: { username: string }; + id: number + inserted_at: string + message: string + user_id: string + channel_id: number + author: { username: string } } const response = await supabase @@ -39,4 +39,4 @@ const response = await supabase .select('*, author:user_id(username)') .match({ channel_id: 2 }) response.data // Response data will be of type Array. -``` \ No newline at end of file +``` diff --git a/apps/reference/_supabase_js_versioned_docs/version-v1/index.mdx b/apps/reference/_supabase_js_versioned_docs/version-v1/index.mdx index b775dbbf9dc..8f37f5853e8 100644 --- a/apps/reference/_supabase_js_versioned_docs/version-v1/index.mdx +++ b/apps/reference/_supabase_js_versioned_docs/version-v1/index.mdx @@ -1,12 +1,11 @@ --- id: index -title: "Supabase Client" +title: 'Supabase Client' slug: supabase-client custom_edit_url: ../../spec/supabase_js_v1.yml --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; +import Tabs from '@theme/Tabs' +import TabItem from '@theme/TabItem' - -Supabase JavaScript. \ No newline at end of file +Supabase JavaScript. diff --git a/apps/reference/_supabase_js_versioned_docs/version-v1/initializing.mdx b/apps/reference/_supabase_js_versioned_docs/version-v1/initializing.mdx index 705503497f6..711f03f2aed 100644 --- a/apps/reference/_supabase_js_versioned_docs/version-v1/initializing.mdx +++ b/apps/reference/_supabase_js_versioned_docs/version-v1/initializing.mdx @@ -1,24 +1,20 @@ --- id: initializing -title: "Initializing" +title: 'Initializing' slug: initializing custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v1.yml --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; +import Tabs from '@theme/Tabs' +import TabItem from '@theme/TabItem' 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. - - - ## Parameters - - - - - - - - - - - - - - ## Examples ### createClient() - - ```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') +const supabase = createClient( + 'https://xyzcompany.supabase.co', + 'public-anon-key' +) ``` ### With additional parameters - - ```js import { createClient } from '@supabase/supabase-js' @@ -123,22 +103,28 @@ const options = { headers: { 'x-my-custom-header': 'my-app-name' }, autoRefreshToken: true, persistSession: true, - detectSessionInUrl: true + detectSessionInUrl: true, } -const supabase = createClient("https://xyzcompany.supabase.co", "public-anon-key", options) +const supabase = createClient( + 'https://xyzcompany.supabase.co', + 'public-anon-key', + options +) ``` ### API schemas - - ```js import { createClient } from '@supabase/supabase-js' // Provide a custom schema. Defaults to "public". -const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key', { - schema: 'other_schema' -}) +const supabase = createClient( + 'https://xyzcompany.supabase.co', + 'public-anon-key', + { + schema: 'other_schema', + } +) ``` By default the API server points to the `public` schema. You can enable other database schemas within the Dashboard. @@ -148,16 +134,18 @@ Note: each client connection can only access a single schema, so the code above ### Custom `fetch` implementation - - ```js import { createClient } from '@supabase/supabase-js' -const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key', { - fetch: fetch.bind(globalThis) -}) +const supabase = createClient( + 'https://xyzcompany.supabase.co', + 'public-anon-key', + { + 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). \ No newline at end of file +This is most useful in environments where `cross-fetch` is not compatible (for instance Cloudflare Workers). diff --git a/apps/reference/_supabase_js_versioned_docs/version-v1/installing.mdx b/apps/reference/_supabase_js_versioned_docs/version-v1/installing.mdx index 5e21a5ba8f4..18d83d1fe6f 100644 --- a/apps/reference/_supabase_js_versioned_docs/version-v1/installing.mdx +++ b/apps/reference/_supabase_js_versioned_docs/version-v1/installing.mdx @@ -1,12 +1,12 @@ --- id: installing -title: "Installing" +title: 'Installing' slug: installing custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v1.yml --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; +import Tabs from '@theme/Tabs' +import TabItem from '@theme/TabItem' All JavaScript libraries are built directly by the Supabase team. @@ -15,11 +15,13 @@ Other languages are built by the community and supported by Supabase. ## JavaScript Via NPM + ```bash npm install @supabase/supabase-js ``` Via Yarn + ```bash yarn add @supabase/supabase-js ``` @@ -27,8 +29,9 @@ yarn add @supabase/supabase-js Find the source code on [GitHub](https://github.com/supabase/supabase-js). Or via CDN + ```js //or -``` \ No newline at end of file +``` diff --git a/apps/reference/docs/about.mdx b/apps/reference/docs/about.mdx index 07e696f4a9e..41cf64120b3 100755 --- a/apps/reference/docs/about.mdx +++ b/apps/reference/docs/about.mdx @@ -79,7 +79,7 @@ You can use it completely, or just the features you need. description={'User management with Row Level Security.'} style={{ height: '100%' }} /> - + {/* Auto-generated APIs */}
{frameworks.map((x) => ( -
+
) : ( -
+
{/* Next.js */}
@@ -38,7 +40,9 @@ A collection of framework-specific Auth utilities for working with Supabase. class="card" to={useBaseUrl('/guides/auth/auth-helpers/sveltekit')} title={'SvelteKit'} - description={'Helpers for authenticating users in SvelteKit applications.'} + description={ + 'Helpers for authenticating users in SvelteKit applications.' + } style={{ height: '100%' }} />
diff --git a/apps/reference/docs/guides/auth/auth-helpers/nextjs.mdx b/apps/reference/docs/guides/auth/auth-helpers/nextjs.mdx index 193a970ebe9..724088ac743 100644 --- a/apps/reference/docs/guides/auth/auth-helpers/nextjs.mdx +++ b/apps/reference/docs/guides/auth/auth-helpers/nextjs.mdx @@ -2,7 +2,7 @@ id: nextjs title: Supabase Auth with Next.js description: Authentication helpers for Next.js API routes, middleware, and SSR. -sidebar_label: "Next.js" +sidebar_label: 'Next.js' --- This submodule provides convenience helpers for implementing user authentication in Next.js applications. diff --git a/apps/reference/docs/guides/auth/auth-helpers/sveltekit.mdx b/apps/reference/docs/guides/auth/auth-helpers/sveltekit.mdx index 4d7d1f3d317..67b655863dc 100644 --- a/apps/reference/docs/guides/auth/auth-helpers/sveltekit.mdx +++ b/apps/reference/docs/guides/auth/auth-helpers/sveltekit.mdx @@ -56,24 +56,28 @@ PUBLIC_SUPABASE_ANON_KEY=your-anon-key Start off by creating a `db.ts` file inside of the `src/lib` directory and instantiate the `supabaseClient`. ```ts title="src/lib/db.ts" -import { createClient } from '@supabase/supabase-js'; -import { setupSupabaseHelpers } from '@supabase/auth-helpers-sveltekit'; -import { dev } from '$app/environment'; -import { env } from '$env/dynamic/public'; +import { createClient } from '@supabase/supabase-js' +import { setupSupabaseHelpers } from '@supabase/auth-helpers-sveltekit' +import { dev } from '$app/environment' +import { env } from '$env/dynamic/public' // or use the static env // import { PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY } from '$env/static/public'; -export const supabaseClient = createClient(env.PUBLIC_SUPABASE_URL, env.PUBLIC_SUPABASE_ANON_KEY, { - persistSession: false, - autoRefreshToken: false -}); +export const supabaseClient = createClient( + env.PUBLIC_SUPABASE_URL, + env.PUBLIC_SUPABASE_ANON_KEY, + { + persistSession: false, + autoRefreshToken: false, + } +) setupSupabaseHelpers({ - supabaseClient, - cookieOptions: { - secure: !dev - } -}); + supabaseClient, + cookieOptions: { + secure: !dev, + }, +}) ``` ### Initialize the client @@ -83,16 +87,16 @@ Edit your `+layout.svelte` file and set up the client-side. ```html title="src/routes/+layout.svelte" @@ -104,16 +108,16 @@ The `hooks.ts` file is where the heavy lifting of this library happens: ```ts title="src/hooks.server.ts" // make sure the supabase instance is initialized on the server -import '$lib/db'; -import { dev } from '$app/environment'; -import { auth } from '@supabase/auth-helpers-sveltekit/server'; +import '$lib/db' +import { dev } from '$app/environment' +import { auth } from '@supabase/auth-helpers-sveltekit/server' -export const handle = auth(); +export const handle = auth() // use the sequence helper if you have additional Handle methods -import { sequence } from '@sveltejs/kit/hooks'; +import { sequence } from '@sveltejs/kit/hooks' -export const handle = sequence(auth(), yourHandler); +export const handle = sequence(auth(), yourHandler) ``` There are three handle methods available: @@ -130,13 +134,13 @@ There are three handle methods available: In order to make the session available to the UI (e.g., pages and layouts), pass the session in the root layout load function: ```ts title="src/routes/+layout.server.ts" -import type { LayoutServerLoad } from './$types'; +import type { LayoutServerLoad } from './$types' export const load: LayoutServerLoad = async ({ locals }) => { return { - session: locals.session - }; -}; + session: locals.session, + } +} ``` ### Typings @@ -151,10 +155,10 @@ In order to get the most out of TypeScript and IntelliSense, import the types in // and what to do when importing types declare namespace App { interface Locals { - session: import('@supabase/auth-helpers-sveltekit').SupabaseSession; + session: import('@supabase/auth-helpers-sveltekit').SupabaseSession } interface PageData { - session: import('@supabase/auth-helpers-sveltekit').SupabaseSession; + session: import('@supabase/auth-helpers-sveltekit').SupabaseSession } // interface Error {} // interface Platform {} @@ -168,22 +172,23 @@ This library has provided a method to delete the session cookie. Create a server only page with an action to delete the cookie ```ts title="src/routes/logout/+page.server.ts" -import { deleteSession } from '@supabase/auth-helpers-sveltekit/server'; -import { redirect } from '@sveltejs/kit'; -import type { Actions } from './$types'; +import { deleteSession } from '@supabase/auth-helpers-sveltekit/server' +import { redirect } from '@sveltejs/kit' +import type { Actions } from './$types' export const actions: Actions = { - async default({ cookies }) { - deleteSession(cookies); - throw redirect(303, '/'); - } -}; + async default({ cookies }) { + deleteSession(cookies) + throw redirect(303, '/') + }, +} ``` + Then make a **POST** request with a form to the server only page above. ```html
@@ -197,14 +202,14 @@ You can now determine if a user is authenticated on the client-side by checking ```html title="src/routes/+page.svelte" {#if !$page.data.session.user} -

I am not logged in

+

I am not logged in

{:else} -

Welcome {$page.data.session.user.email}

-

I am logged in!

+

Welcome {$page.data.session.user.email}

+

I am logged in!

{/if} ``` @@ -214,23 +219,23 @@ For [row level security](https://supabase.com/docs/learn/auth-deep-dive/auth-row ```html {#if $page.data.session.user} -

client-side data fetching with RLS

-
{JSON.stringify(loadedData, null, 2)}
+

client-side data fetching with RLS

+
{JSON.stringify(loadedData, null, 2)}
{/if} ``` @@ -239,8 +244,8 @@ For [row level security](https://supabase.com/docs/learn/auth-deep-dive/auth-row ```html title="src/routes/profile/+page.svelte"
Protected content for {user.email}
@@ -281,14 +286,14 @@ Always use the instance returned by `getSupabaseClient()` directly! ```ts // Bad -const supabaseClient = getSupabaseClient(); +const supabaseClient = getSupabaseClient() -await supabaseClient.from('table1').select(); -await supabaseClient.from('table2').select(); +await supabaseClient.from('table1').select() +await supabaseClient.from('table2').select() // Good -await getSupabaseClient().from('table1').select(); -await getSupabaseClient().from('table2').select(); +await getSupabaseClient().from('table1').select() +await getSupabaseClient().from('table2').select() ``` ## Protecting API routes @@ -324,34 +329,34 @@ If you visit `/api/protected-route` without a valid session cookie, you will get Wrap an Action to check that the user has a valid session. If they're not logged in, the session is `null`. ```ts title="src/routes/posts/+page.server.ts" -import type { Actions } from './$types'; -import { withAuth } from '@supabase/auth-helpers-sveltekit'; -import { error, invalid } from '@sveltejs/kit'; +import type { Actions } from './$types' +import { withAuth } from '@supabase/auth-helpers-sveltekit' +import { error, invalid } from '@sveltejs/kit' export const actions: Actions = { createPost: withAuth(async ({ session, getSupabaseClient, request }) => { if (!session.user) { // the user is not signed in - throw error(403, { message: 'Unauthorized' }); + throw error(403, { message: 'Unauthorized' }) } // we are save, let the user create the post - const formData = await request.formData(); - const content = formData.get('content'); + const formData = await request.formData() + const content = formData.get('content') const { error: createPostError, data: newPost } = await getSupabaseClient() .from('posts') - .insert({ content }); + .insert({ content }) if (createPostError) { return invalid(500, { - supabaseErrorMessage: createPostError.message - }); + supabaseErrorMessage: createPostError.message, + }) } return { - newPost - }; - }) -}; + newPost, + } + }), +} ``` If you try to submit a form with the action `?/createPost` without a valid session cookie, you will get a 403 error response. @@ -361,62 +366,62 @@ If you try to submit a form with the action `?/createPost` without a valid sessi Use `saveSession` to save the session cookies: ```ts -import type { Actions } from './$types'; -import { supabaseClient } from '$lib/db'; -import { invalid, redirect } from '@sveltejs/kit'; -import { saveSession } from '@supabase/auth-helpers-sveltekit/server'; +import type { Actions } from './$types' +import { supabaseClient } from '$lib/db' +import { invalid, redirect } from '@sveltejs/kit' +import { saveSession } from '@supabase/auth-helpers-sveltekit/server' export const actions: Actions = { async signin({ request, cookies, url }) { - const formData = await request.formData(); + const formData = await request.formData() - const email = formData.get('email') as string; - const password = formData.get('password') as string; + const email = formData.get('email') as string + const password = formData.get('password') as string const { data, error } = await supabaseClient.auth.api.signInWithEmail( email, password, { - redirectTo: `${url.origin}/logging-in` + redirectTo: `${url.origin}/logging-in`, } - ); + ) if (error || !data) { if (error?.status === 400) { return invalid(400, { error: 'Invalid credentials', values: { - email - } - }); + email, + }, + }) } return invalid(500, { error: 'Server error. Try again later.', values: { - email - } - }); + email, + }, + }) } - saveSession(cookies, data); - throw redirect(303, '/dashboard'); - } -}; + saveSession(cookies, data) + throw redirect(303, '/dashboard') + }, +} ``` Use `deleteSession` to delete the session cookies: ```ts -import type { Actions } from './$types'; -import { deleteSession } from '@supabase/auth-helpers-sveltekit/server'; -import { redirect } from '@sveltejs/kit'; +import type { Actions } from './$types' +import { deleteSession } from '@supabase/auth-helpers-sveltekit/server' +import { redirect } from '@sveltejs/kit' export const actions: Actions = { async logout({ cookies }) { - deleteSession(cookies); - throw redirect(303, '/'); - } -}; + deleteSession(cookies) + throw redirect(303, '/') + }, +} ``` ## Custom session namespace @@ -426,10 +431,10 @@ If you want to use something other than `locals.session` and `$page.data.session ```ts title="src/app.d.ts" declare namespace App { interface Locals { - mySupabaseSession: import('@supabase/auth-helpers-sveltekit').SupabaseSession; + mySupabaseSession: import('@supabase/auth-helpers-sveltekit').SupabaseSession } interface PageData { - mySupabaseSession: import('@supabase/auth-helpers-sveltekit').SupabaseSession; + mySupabaseSession: import('@supabase/auth-helpers-sveltekit').SupabaseSession } } ``` @@ -438,20 +443,20 @@ declare namespace App { setupSupabaseServer({ supabaseClient, cookieOptions: { - secure: !dev + secure: !dev, }, // --- change location within locals --- getSessionFromLocals: (locals) => locals.mySupabaseSession, - setSessionToLocals: (locals, session) => (locals.mySupabaseSession = session) -}); + setSessionToLocals: (locals, session) => (locals.mySupabaseSession = session), +}) ``` ```ts title="src/lib/db.ts" setupSupabaseClient({ supabaseClient, // --- change location within pageData --- - getSessionFromPageData: (data) => data.mySupabaseSession -}); + getSessionFromPageData: (data) => data.mySupabaseSession, +}) ``` ## Migrate from 0.6.11 and below to 0.7.0 {#migration} @@ -489,25 +494,29 @@ export { supabaseClient }; ```js title="src/lib/db.ts" -import { createClient } from '@supabase/supabase-js'; -import { setupSupabaseHelpers } from '@supabase/auth-helpers-sveltekit'; -import { dev } from '$app/environment'; -import { env } from '$env/dynamic/public'; +import { createClient } from '@supabase/supabase-js' +import { setupSupabaseHelpers } from '@supabase/auth-helpers-sveltekit' +import { dev } from '$app/environment' +import { env } from '$env/dynamic/public' // or use the static env // import { PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY } from '$env/static/public'; -export const supabaseClient = createClient(env.PUBLIC_SUPABASE_URL, env.PUBLIC_SUPABASE_ANON_KEY, { - persistSession: false, - autoRefreshToken: false -}); +export const supabaseClient = createClient( + env.PUBLIC_SUPABASE_URL, + env.PUBLIC_SUPABASE_ANON_KEY, + { + persistSession: false, + autoRefreshToken: false, + } +) setupSupabaseHelpers({ supabaseClient, cookieOptions: { - secure: !dev - } -}); + secure: !dev, + }, +}) ``` @@ -526,9 +535,9 @@ setupSupabaseHelpers({ ```html title="src/routes/__layout.svelte" @@ -545,16 +554,16 @@ The `@supabase/auth-helpers-svelte` library is no longer required as the `@supab ```html title="src/routes/+layout.svelte" @@ -575,18 +584,18 @@ The `@supabase/auth-helpers-svelte` library is no longer required as the `@supab ```ts title="src/hooks.ts" -import { handleAuth } from '@supabase/auth-helpers-sveltekit'; -import type { GetSession, Handle } from '@sveltejs/kit'; -import { sequence } from '@sveltejs/kit/hooks'; +import { handleAuth } from '@supabase/auth-helpers-sveltekit' +import type { GetSession, Handle } from '@sveltejs/kit' +import { sequence } from '@sveltejs/kit/hooks' -export const handle: Handle = sequence(...handleAuth()); +export const handle: Handle = sequence(...handleAuth()) export const getSession: GetSession = async (event) => { - const { user, accessToken, error } = event.locals; - return { - user, - accessToken, - error + const { user, accessToken, error } = event.locals + return { + user, + accessToken, + error, } } ``` @@ -597,23 +606,23 @@ export const getSession: GetSession = async (event) => { ```ts title="src/hooks.server.ts" // make sure the supabase instance is initialized on the server -import '$lib/db'; -import { dev } from '$app/environment'; -import { auth } from '@supabase/auth-helpers-sveltekit/server'; +import '$lib/db' +import { dev } from '$app/environment' +import { auth } from '@supabase/auth-helpers-sveltekit/server' -export const handle = auth(); +export const handle = auth() ``` -**Optional** *if using additional handle methods* +**Optional** _if using additional handle methods_ ```ts title="src/hooks.server.ts" // make sure the supabase instance is initialized on the server -import '$lib/db'; -import { dev } from '$app/environment'; -import { auth } from '@supabase/auth-helpers-sveltekit/server'; -import { sequence } from '@sveltejs/kit/hooks'; +import '$lib/db' +import { dev } from '$app/environment' +import { auth } from '@supabase/auth-helpers-sveltekit/server' +import { sequence } from '@sveltejs/kit/hooks' -export const handle = sequence(auth(), yourHandler); +export const handle = sequence(auth(), yourHandler) ``` @@ -636,16 +645,16 @@ export const handle = sequence(auth(), yourHandler); // for information about these interfaces declare namespace App { interface UserSession { - user: import('@supabase/supabase-js').User; - accessToken?: string; + user: import('@supabase/supabase-js').User + accessToken?: string } interface Locals extends UserSession { - error: import('@supabase/supabase-js').ApiError; + error: import('@supabase/supabase-js').ApiError } interface Session extends UserSession {} - + // interface Platform {} // interface Stuff {} } @@ -663,11 +672,11 @@ declare namespace App { // and what to do when importing types declare namespace App { interface Locals { - session: import('@supabase/auth-helpers-sveltekit').SupabaseSession; + session: import('@supabase/auth-helpers-sveltekit').SupabaseSession } interface PageData { - session: import('@supabase/auth-helpers-sveltekit').SupabaseSession; + session: import('@supabase/auth-helpers-sveltekit').SupabaseSession } // interface Error {} @@ -691,14 +700,14 @@ declare namespace App { ```html title="src/routes/index.svelte" {#if !$session.user} -

I am not logged in

+

I am not logged in

{:else} -

Welcome {$session.user.email}

-

I am logged in!

+

Welcome {$session.user.email}

+

I am logged in!

{/if} ``` @@ -708,14 +717,14 @@ declare namespace App { ```html title="src/routes/+page.svelte" {#if !$page.data.session.user} -

I am not logged in

+

I am not logged in

{:else} -

Welcome {$page.data.session.user.email}

-

I am logged in!

+

Welcome {$page.data.session.user.email}

+

I am logged in!

{/if} ``` @@ -735,25 +744,30 @@ declare namespace App { ```html title="src/routes/protected-route.svelte"
Protected content for {user.email}
@@ -769,13 +783,12 @@ export let user; ```html title="src/routes/protected-route/+page.svelte" -
Protected content for {user.email}

server-side fetched data with RLS:

{JSON.stringify(tableData, null, 2)}
@@ -784,18 +797,22 @@ export let user; ``` ```ts title="src/routes/protected-route/+page.ts" -import { withAuth } from '@supabase/auth-helpers-sveltekit'; -import { redirect } from '@sveltejs/kit'; -import type { PageLoad } from './$types'; +import { withAuth } from '@supabase/auth-helpers-sveltekit' +import { redirect } from '@sveltejs/kit' +import type { PageLoad } from './$types' -export const load: PageLoad = withAuth(async ({ session, getSupabaseClient }) => { - if (!session.user) { - throw redirect(303, '/'); +export const load: PageLoad = withAuth( + async ({ session, getSupabaseClient }) => { + if (!session.user) { + throw redirect(303, '/') + } + + const { data: tableData } = await getSupabaseClient() + .from('test') + .select('*') + return { tableData, user: session.user } } - - const { data: tableData } = await getSupabaseClient().from('test').select('*'); - return { tableData, user: session.user }; -}); +) ``` @@ -813,28 +830,33 @@ export const load: PageLoad = withAuth(async ({ session, getSupabaseClient }) => ```ts title="src/routes/api/protected-route.ts" -import { supabaseServerClient, withApiAuth } from "@supabase/auth-helpers-sveltekit"; -import type { RequestHandler } from "./__types/protected-route"; +import { + supabaseServerClient, + withApiAuth, +} from '@supabase/auth-helpers-sveltekit' +import type { RequestHandler } from './__types/protected-route' interface TestTable { - id: string; - created_at: string; + id: string + created_at: string } interface GetOutput { - data: TestTable[]; + data: TestTable[] } export const GET: RequestHandler = async ({ locals, request }) => withApiAuth({ user: locals.user }, async () => { // Run queries with RLS on the server - const { data } = await supabaseServerClient(request).from("test").select("*"); + const { data } = await supabaseServerClient(request) + .from('test') + .select('*') return { status: 200, - body: { data } - }; - }); + body: { data }, + } + }) ``` diff --git a/apps/reference/docs/guides/cli/local-development.mdx b/apps/reference/docs/guides/cli/local-development.mdx index 7883f25647c..a4d7d7fc38e 100644 --- a/apps/reference/docs/guides/cli/local-development.mdx +++ b/apps/reference/docs/guides/cli/local-development.mdx @@ -110,7 +110,7 @@ http://localhost:54321/auth/v1/ # Auth (GoTrue) :::note To access the database from an edge function in your local Supabase setup, replace `localhost` with `host.docker.internal`. ::: - + ## Database migrations Database changes are managed through "migrations." Database migrations are a common way of tracking changes to your database over time. diff --git a/apps/reference/docs/guides/database/connecting-to-postgres.mdx b/apps/reference/docs/guides/database/connecting-to-postgres.mdx index 3d05bfa1c74..e6882cf3883 100644 --- a/apps/reference/docs/guides/database/connecting-to-postgres.mdx +++ b/apps/reference/docs/guides/database/connecting-to-postgres.mdx @@ -112,7 +112,12 @@ This is the most granular option. Connections are returned to the pool after eve 3. Find your Connection Info and Connection String. Connection pooling is on port `6543`. ## Connecting with SSL diff --git a/apps/reference/docs/guides/database/migrating-between-projects.mdx b/apps/reference/docs/guides/database/migrating-between-projects.mdx index 536fb45f810..1e637b7ce8e 100644 --- a/apps/reference/docs/guides/database/migrating-between-projects.mdx +++ b/apps/reference/docs/guides/database/migrating-between-projects.mdx @@ -16,11 +16,13 @@ Migrating projects can be achieved using standard PostgreSQL tooling. This is pa ## Migrate the database In your old project: + 1. Run `ALTER ROLE postgres SUPERUSER` in the [SQL editor](https://app.supabase.com/project/_/sql). 1. Run `pg_dump --clean --if-exists --quote-all-identifiers -h $OLD_DB_URL -U postgres > dump.sql` from your terminal. 1. Run `ALTER ROLE postgres NOSUPERUSER` in the [SQL editor](https://app.supabase.com/project/_/sql). In your new project: + 1. Run `ALTER ROLE postgres SUPERUSER` in the [SQL editor](https://app.supabase.com/project/_/sql). 1. Run `psql -h $NEW_DB_URL -U postgres -f dump.sql` from your terminal. 1. Run `TRUNCATE storage.objects` in the [SQL editor](https://app.supabase.com/project/_/sql). @@ -94,4 +96,3 @@ const NEW_PROJECT_SERVICE_KEY = 'new-project-service-key-yyy' } })() ``` - diff --git a/apps/reference/docs/guides/functions.mdx b/apps/reference/docs/guides/functions.mdx index b88a5c21a29..c5b4ddf8ce9 100644 --- a/apps/reference/docs/guides/functions.mdx +++ b/apps/reference/docs/guides/functions.mdx @@ -241,15 +241,15 @@ You can find a list of useful [Edge Function Examples](https://github.com/supaba
{examples.map((x) => ( -
- -
+
+ +
))}
diff --git a/apps/reference/docs/guides/hosting/platform.mdx b/apps/reference/docs/guides/hosting/platform.mdx index 9304734111f..bbfe32e34f8 100644 --- a/apps/reference/docs/guides/hosting/platform.mdx +++ b/apps/reference/docs/guides/hosting/platform.mdx @@ -29,17 +29,22 @@ Organizations are a way to group your projects. Each organization can be configu You can invite your team members into your organizations to collaborate on projects. You can also assign roles to your team members with different access levels. The table below shows the corresponding permissions for each available role in the Dashboard. | Permissions | Owner | Administrator | Developer | | ------------------------ | ----- | ------------- | --------- | -| **Organization** | +| **Organization** | | Change organization name | ✅ | | | | Delete organization | ✅ | | | -| **Members** | +| **Members** | | Add an Owner | ✅ | | | | Remove an Owner | ✅ | | | | Add an Adminstrator | ✅ | ✅ | | @@ -48,7 +53,7 @@ You can also assign roles to your team members with different access levels. The | Remove a Developer | ✅ | ✅ | | | Revoke an invite | ✅ | ✅ | | | Resend an invite | ✅ | ✅ | | -| **Billing** | +| **Billing** | | Read invoices | ✅ | ✅ | ✅ | | Read billing email | ✅ | ✅ | ✅ | | Change billing email | ✅ | | | @@ -60,7 +65,7 @@ You can also assign roles to your team members with different access levels. The | Update tax codes | ✅ | ✅ | | | Read payment methods | ✅ | ✅ | ✅ | | Update payment methods | ✅ | ✅ | | -| **Projects** | +| **Projects** | | Create a project | ✅ | ✅ | | | Delete a project | ✅ | ✅ | | | Update a project | ✅ | ✅ | | diff --git a/apps/reference/docs/guides/integrations/authsignal.mdx b/apps/reference/docs/guides/integrations/authsignal.mdx index ccf1f2e94f4..c98930959f3 100644 --- a/apps/reference/docs/guides/integrations/authsignal.mdx +++ b/apps/reference/docs/guides/integrations/authsignal.mdx @@ -346,7 +346,7 @@ export default function HomePage({ user, isEnrolled }: Props) {
Signed in as: {user?.email}
-
diff --git a/apps/reference/docs/guides/with-solidjs.mdx b/apps/reference/docs/guides/with-solidjs.mdx index 77ccae4961a..bcd892215b4 100644 --- a/apps/reference/docs/guides/with-solidjs.mdx +++ b/apps/reference/docs/guides/with-solidjs.mdx @@ -272,14 +272,14 @@ import { Component, createEffect, createSignal } from 'solid-js' import { supabase } from './supabaseClient' interface Props { - session: AuthSession + session: AuthSession; } const Account: Component = ({ session }) => { const [loading, setLoading] = createSignal(true) - const [username, setUsername] = createSignal(null) - const [website, setWebsite] = createSignal(null) - const [avatarUrl, setAvatarUrl] = createSignal(null) + const [username, setUsername] = (createSignal < string) | (null > null) + const [website, setWebsite] = (createSignal < string) | (null > null) + const [avatarUrl, setAvatarUrl] = (createSignal < string) | (null > null) createEffect(() => { getProfile() @@ -366,11 +366,19 @@ const Account: Component = ({ session }) => { />
-
- diff --git a/apps/reference/docs/guides/with-svelte.mdx b/apps/reference/docs/guides/with-svelte.mdx index 7c6a60fffe9..4995742c55c 100644 --- a/apps/reference/docs/guides/with-svelte.mdx +++ b/apps/reference/docs/guides/with-svelte.mdx @@ -192,7 +192,7 @@ Let's set up a Svelte component to manage logins and sign ups. We'll use Magic L ```html title="src/lib/Auth.svelte"
- {#if avatarUrl} - {avatarUrl - {:else} -
+ {#if avatarUrl} {avatarUrl {:else} +
{/if}
@@ -497,9 +495,9 @@ And then we can add the widget to the Account page: import Avatar from './Avatar.svelte' -
+ - + diff --git a/apps/reference/docs/guides/with-sveltekit.mdx b/apps/reference/docs/guides/with-sveltekit.mdx index c190597b9c8..fb3374561ae 100644 --- a/apps/reference/docs/guides/with-sveltekit.mdx +++ b/apps/reference/docs/guides/with-sveltekit.mdx @@ -252,27 +252,27 @@ Let's create a new component for that called `Profile.svelte`. let avatar_url = null function getProfile(node) { - try { - loading = true; - const user = supabase.auth.user(); + try { + loading = true + const user = supabase.auth.user() - supabase - .from("profiles") - .select(`username, website, avatar_url`) - .eq("id", user?.id) - .single() - .then(({ data, error, status }) => { - if (data) { - username = data.username; - website = data.website; - avatar_url = data.avatar_url; - } - if (error && status !== 406) throw error; - }); + supabase + .from('profiles') + .select(`username, website, avatar_url`) + .eq('id', user?.id) + .single() + .then(({ data, error, status }) => { + if (data) { + username = data.username + website = data.website + avatar_url = data.avatar_url + } + if (error && status !== 406) throw error + }) } catch (error) { - alert(error.message); + alert(error.message) } finally { - loading = false; + loading = false } } @@ -311,7 +311,6 @@ Let's create a new component for that called `Profile.svelte`. } finally { loading = false } - } diff --git a/apps/reference/generator/legacy.ts b/apps/reference/generator/legacy.ts index a432608294f..6a2b906af3f 100644 --- a/apps/reference/generator/legacy.ts +++ b/apps/reference/generator/legacy.ts @@ -131,7 +131,9 @@ function recurseThroughParams(paramDefinition: TsDoc.TypeDefinition) { children = param.type?.declaration?.children } else if (isUnion(param)) { // We don't want to show the union types if it's a literal - const nonLiteralVariants = param.type.types.filter(({ type }) => type !== 'literal') + const nonLiteralVariants = param.type.types.filter( + ({ type }) => type !== 'literal' + ) if (nonLiteralVariants.length === 0) { children = null