From ebd559d9c9a7d2a722b7ca5b39195d3057e01bc9 Mon Sep 17 00:00:00 2001
From: Joshen Lim
Date: Tue, 10 Jan 2023 16:07:08 +0800
Subject: [PATCH 01/48] Update text for RLS in table editor
---
.../SidePanelEditor/TableEditor/TableEditor.tsx | 15 +++++++--------
studio/pages/project/[ref]/auth/policies.tsx | 2 +-
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
index 09928532ab9..6329a56ae4c 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
@@ -17,6 +17,7 @@ import {
generateTableFieldFromPostgresTable,
formatImportedContentToColumnFields,
} from './TableEditor.utils'
+import InformationBox from 'components/ui/InformationBox'
interface Props {
table?: PostgresTable
@@ -215,9 +216,9 @@ const TableEditor: FC = ({
Restrict access to your table by enabling RLS and writing Postgres policies.
-
- If RLS is not enabled, anyone with the anon key can modify and delete your data.
+ RLS is secure by default - all normal access to this table must be allowed by a
+ policy.
{!tableFields.isRLSEnabled && (
= ({
variant="warning"
className="!px-4 !py-3 mt-3"
// @ts-ignore
- title={
-
- Turning off RLS means that you are allowing anonymous access to your table
-
- }
- />
+ title="Turning off RLS means that you are allowing anonymous access to your table"
+ >
+ As such, anyone with the anonymous key can modify or delete your data.
+
)}
>
}
diff --git a/studio/pages/project/[ref]/auth/policies.tsx b/studio/pages/project/[ref]/auth/policies.tsx
index 14fc0d2a805..26a0ceb74ea 100644
--- a/studio/pages/project/[ref]/auth/policies.tsx
+++ b/studio/pages/project/[ref]/auth/policies.tsx
@@ -242,7 +242,7 @@ const AuthPoliciesTables: FC = observer(({ tables, hasP
This is also known as Row-Level Security (RLS). Each policy is attached to a
- table, and the policy is executed everytime a time is accessed.
+ table, and the policy is executed each time its accessed.
+ Policies restrict, on a per-user basis, which rows can be returned by normal
+ queries, or inserted, updated, or deleted by data modification commands.
+
+
+ This is also known as Row-Level Security (RLS). Each policy is attached to a
+ table, and the policy is executed each time its accessed.
+
+
+ }
+ />
+
+ A table within the public schema is required before you can create a Row-Level
+ Security policy.
+
+
+
+
+ )}
+
+
+
+
+
+
+ >
+ )
+}
+
+export default observer(Policies)
diff --git a/studio/components/interfaces/Auth/Policies/index.tsx b/studio/components/interfaces/Auth/Policies/index.tsx
index f1cd35fac60..129075d7344 100644
--- a/studio/components/interfaces/Auth/Policies/index.tsx
+++ b/studio/components/interfaces/Auth/Policies/index.tsx
@@ -1,7 +1,8 @@
+import Policies from './Policies'
import PolicyEditorModal from './PolicyEditorModal'
import PolicyTableRow from './PolicyTableRow'
import PolicySelection from './PolicySelection'
import PolicyTemplates from './PolicyTemplates'
export * from './Policies.constants'
-export { PolicyEditorModal, PolicyTableRow, PolicySelection, PolicyTemplates }
+export { Policies, PolicyEditorModal, PolicyTableRow, PolicySelection, PolicyTemplates }
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
index 6329a56ae4c..b9a68c8aa27 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
@@ -225,7 +225,6 @@ const TableEditor: FC = ({
withIcon
variant="warning"
className="!px-4 !py-3 mt-3"
- // @ts-ignore
title="Turning off RLS means that you are allowing anonymous access to your table"
>
As such, anyone with the anonymous key can modify or delete your data.
diff --git a/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsx b/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsx
index 1bc51c408ae..65ca74e668a 100644
--- a/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsx
+++ b/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsx
@@ -1,5 +1,4 @@
import { FC, useEffect, useState } from 'react'
-import { useRouter } from 'next/router'
import Link from 'next/link'
import { partition } from 'lodash'
import { observer } from 'mobx-react-lite'
@@ -10,6 +9,7 @@ import {
IconCopy,
IconEdit,
IconLoader,
+ IconLock,
IconRefreshCw,
IconSearch,
IconTrash,
@@ -23,7 +23,7 @@ import { PermissionAction } from '@supabase/shared-types/out/constants'
import { PostgresSchema, PostgresTable } from '@supabase/postgres-meta'
import Base64 from 'lib/base64'
-import { checkPermissions, useStore } from 'hooks'
+import { checkPermissions, useStore, useParams } from 'hooks'
import { SchemaView } from './TableEditorLayout.types'
import ProductMenuItem from 'components/ui/ProductMenu/ProductMenuItem'
@@ -44,11 +44,9 @@ const TableEditorMenu: FC = ({
onDeleteTable = () => {},
onDuplicateTable = () => {},
}) => {
- const { meta, ui } = useStore()
- const router = useRouter()
- const { id } = router.query
+ const { meta } = useStore()
+ const { id, ref } = useParams()
- const projectRef = ui.selectedProject?.ref
const schemas: PostgresSchema[] = meta.schemas.list()
const tables: PostgresTable[] = meta.tables.list(
(table: PostgresTable) => table.schema === selectedSchema
@@ -67,15 +65,10 @@ const TableEditorMenu: FC = ({
// We may need to shift this to the schema store and do something like meta.schema.loadViews()
// I don't need we need a separate store for views
useEffect(() => {
- let cancel = false
const fetchViews = async (selectedSchema: string) => {
await meta.schemas.loadViews(selectedSchema)
}
if (selectedSchema) fetchViews(selectedSchema)
-
- return () => {
- cancel = true
- }
}, [selectedSchema])
const refreshTables = async () => {
@@ -258,7 +251,7 @@ const TableEditorMenu: FC = ({
return (
= ({
>
Duplicate Table
,
+
+
+ }>
+ View Policies
+
+
+ ,
,
= ({
const viewId = Base64.encode(JSON.stringify(view))
const isActive = id === viewId
return (
-
+
- Policies restrict, on a per-user basis, which rows can be returned by normal
- queries, or inserted, updated, or deleted by data modification commands.
-
-
- This is also known as Row-Level Security (RLS). Each policy is attached to a
- table, and the policy is executed each time its accessed.
-
-
- }
- />
-
- A table within the public schema is required before you can create a Row-Level
- Security policy.
-
- A table within the public schema is required before you can create a Row-Level
- Security policy.
+ A table within this schema is required before you can create a Row-Level Security
+ policy.
+
See the [example on GitHub](https://github.com/supabase/supabase/blob/master/examples/edge-functions/.github/workflows/deploy.yaml).
export const Page = ({ children }) =>
diff --git a/apps/docs/pages/guides/functions/cors.mdx b/apps/docs/pages/guides/functions/cors.mdx
new file mode 100644
index 00000000000..fca25fa4933
--- /dev/null
+++ b/apps/docs/pages/guides/functions/cors.mdx
@@ -0,0 +1,59 @@
+import Layout from '~/layouts/DefaultGuideLayout'
+
+export const meta = {
+ id: 'functions-cors',
+ title: 'CORS (Cross-Origin Resource Sharing)',
+ description: 'Add CORS headers to invoke functions from the browser.',
+}
+
+To invoke the functions from the browser, you need to handle [CORS Preflight](https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request) requests.
+
+See the [example on GitHub](https://github.com/supabase/supabase/blob/master/examples/edge-functions/supabase/functions/browser-with-cors/index.ts).
+
+### Recommended setup
+
+We recommend adding a `corst.ts` file within a `_shared` folder which makes it easy to reuse the CORS headers across functions:
+
+```ts cors.ts
+export const corsHeaders = {
+ 'Access-Control-Allow-Origin': '*',
+ 'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',
+}
+```
+
+You can then import and use the CORS headers within your functions:
+
+```ts index.ts
+import { serve } from 'https://deno.land/std@0.131.0/http/server.ts'
+import { corsHeaders } from '../_shared/cors.ts'
+
+console.log(`Function "browser-with-cors" up and running!`)
+
+serve(async (req) => {
+ // This is needed if you're planning to invoke your function from a browser.
+ if (req.method === 'OPTIONS') {
+ return new Response('ok', { headers: corsHeaders })
+ }
+
+ try {
+ const { name } = await req.json()
+ const data = {
+ message: `Hello ${name}!`,
+ }
+
+ return new Response(JSON.stringify(data), {
+ headers: { ...corsHeaders, 'Content-Type': 'application/json' },
+ status: 200,
+ })
+ } catch (error) {
+ return new Response(JSON.stringify({ error: error.message }), {
+ headers: { ...corsHeaders, 'Content-Type': 'application/json' },
+ status: 400,
+ })
+ }
+})
+```
+
+export const Page = ({ children }) =>
+
+export default Page
diff --git a/apps/docs/pages/guides/functions/examples/cloudflare-turnstile.mdx b/apps/docs/pages/guides/functions/examples/cloudflare-turnstile.mdx
new file mode 100644
index 00000000000..560b3d9e454
--- /dev/null
+++ b/apps/docs/pages/guides/functions/examples/cloudflare-turnstile.mdx
@@ -0,0 +1,96 @@
+import Layout from '~/layouts/DefaultGuideLayout'
+
+export const meta = {
+ id: 'examples-cloudflare-turnstile',
+ title: 'Cloudflare Turnstile',
+ description: 'Protecting Forms with Cloudflare Turnstile.',
+}
+
+
+
+
+
+[Clouflare Turnstile](https://www.cloudflare.com/products/turnstile/) is a friendly, free CAPTCHA replacement, and it works seamlessly with Supabase Edge Functions to protect your forms. [View on GitHub](https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/cloudflare-turnstile).
+
+## Setup
+
+- Follow these steps to set up a new site: https://developers.cloudflare.com/turnstile/get-started/
+- Add the Cloudflare Turnstile widget to your site: https://developers.cloudflare.com/turnstile/get-started/client-side-rendering/
+
+## Code
+
+Create a new function in your project:
+
+```bash
+supabase functions new cloudflare-turnstile
+```
+
+And add the code to the `index.ts` file:
+
+```ts index.ts
+import { serve } from 'https://deno.land/std@0.131.0/http/server.ts'
+import { corsHeaders } from '../_shared/cors.ts'
+
+console.log('Hello from Cloudflare Trunstile!')
+
+function ips(req: Request) {
+ return req.headers.get('x-forwarded-for')?.split(/\s*,\s*/)
+}
+
+serve(async (req) => {
+ // This is needed if you're planning to invoke your function from a browser.
+ if (req.method === 'OPTIONS') {
+ return new Response('ok', { headers: corsHeaders })
+ }
+
+ const { token } = await req.json()
+ const clientIps = ips(req) || ['']
+ const ip = clientIps[0]
+
+ // Validate the token by calling the
+ // "/siteverify" API endpoint.
+ let formData = new FormData()
+ formData.append('secret', Deno.env.get('CLOUDFLARE_SECRET_KEY') ?? '')
+ formData.append('response', token)
+ formData.append('remoteip', ip)
+
+ const url = 'https://challenges.cloudflare.com/turnstile/v0/siteverify'
+ const result = await fetch(url, {
+ body: formData,
+ method: 'POST',
+ })
+
+ const outcome = await result.json()
+ console.log(outcome)
+ if (outcome.success) {
+ return new Response('success', { headers: corsHeaders })
+ }
+ return new Response('failure', { headers: corsHeaders })
+})
+```
+
+## Deploy the server-side validation Edge Functions
+
+- https://developers.cloudflare.com/turnstile/get-started/server-side-validation/
+
+```bash
+supabase functions deploy cloudflare-turnstile
+supabase secrets set CLOUDFLARE_TURNSTILE_SECRET_KEY=your_secret_key
+```
+
+## Invoke the function from your site
+
+```js
+const { data, error } = await supabase.functions.invoke('cloudflare-turnstile', {
+ body: { token },
+})
+```
+
+export const Page = ({ children }) =>
+
+export default Page
diff --git a/apps/docs/pages/guides/functions/examples/github-actions.mdx b/apps/docs/pages/guides/functions/examples/github-actions.mdx
new file mode 100644
index 00000000000..97456f33767
--- /dev/null
+++ b/apps/docs/pages/guides/functions/examples/github-actions.mdx
@@ -0,0 +1,49 @@
+import Layout from '~/layouts/DefaultGuideLayout'
+
+export const meta = {
+ id: 'examples-github-actions',
+ title: 'GitHub Actions',
+ description: 'Deploying Edge Functions with GitHub Actions.',
+}
+
+
+
+
+
+Use the Supabase CLI together with GitHub Actions to automatically deploy our Supabase Edge Functions. [View on GitHub](https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/github-action-deploy).
+
+```yaml deploy.yaml
+name: Deploy Function
+
+on:
+ push:
+ branches:
+ - main
+ workflow_dispatch:
+
+jobs:
+ deploy:
+ runs-on: ubuntu-latest
+
+ env:
+ SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
+ PROJECT_ID: zdtdtxajzydjqzuktnqx
+
+ steps:
+ - uses: actions/checkout@v3
+
+ - uses: supabase/setup-cli@v1
+ with:
+ version: 1.0.0
+
+ - run: supabase functions deploy github-action-deploy --project-ref $PROJECT_ID
+```
+
+export const Page = ({ children }) =>
+
+export default Page
diff --git a/apps/docs/pages/guides/functions/examples/og-image.mdx b/apps/docs/pages/guides/functions/examples/og-image.mdx
index 2974d5ef853..e4be6c85796 100644
--- a/apps/docs/pages/guides/functions/examples/og-image.mdx
+++ b/apps/docs/pages/guides/functions/examples/og-image.mdx
@@ -17,6 +17,10 @@ export const meta = {
Generate Open Graph images with Deno and Supabase Edge Functions. [View on GitHub](https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/opengraph).
+## Code
+
+Create a `handler.tsx` file to construct the OG image in React:
+
```tsx handler.tsx
import React from 'https://esm.sh/react@18.2.0'
import { ImageResponse } from 'https://deno.land/x/og_edge@0.0.4/mod.ts'
@@ -42,6 +46,8 @@ export default function handler(req: Request) {
}
```
+Create an `index.ts` file to execute the handler on incoming requests:
+
```ts index.ts
import { serve } from 'https://deno.land/std@0.131.0/http/server.ts'
import handler from './handler.tsx'
diff --git a/apps/docs/pages/guides/functions/examples/storage-caching.mdx b/apps/docs/pages/guides/functions/examples/storage-caching.mdx
new file mode 100644
index 00000000000..6e4b6ff604e
--- /dev/null
+++ b/apps/docs/pages/guides/functions/examples/storage-caching.mdx
@@ -0,0 +1,22 @@
+import Layout from '~/layouts/DefaultGuideLayout'
+
+export const meta = {
+ id: 'examples-storage-caching',
+ title: 'Caching Images with Supabase Storage CDN',
+ description: 'Integrate Edge Functions with Supabase Storage to cache images on the Edge (CDN).',
+}
+
+
+
+
+
+Integrate Edge Functions with Supabase Storage to cache images on the Edge (CDN). [View on GitHub](https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/og-image-with-storage-cdn).
+
+export const Page = ({ children }) =>
+
+export default Page
diff --git a/apps/docs/pages/guides/functions/examples/stripe-webhooks.mdx b/apps/docs/pages/guides/functions/examples/stripe-webhooks.mdx
new file mode 100644
index 00000000000..5b75bb48878
--- /dev/null
+++ b/apps/docs/pages/guides/functions/examples/stripe-webhooks.mdx
@@ -0,0 +1,22 @@
+import Layout from '~/layouts/DefaultGuideLayout'
+
+export const meta = {
+ id: 'examples-stripe-webhooks',
+ title: 'Handling Stripe Webhooks',
+ description: 'Handling signed Stripe Webhooks with Edge Functions.',
+}
+
+
+
+
+
+Handling signed Stripe Webhooks with Edge Functions. [View on GitHub](https://github.com/supabase/supabase/blob/master/examples/edge-functions/supabase/functions/stripe-webhooks/index.ts).
+
+export const Page = ({ children }) =>
+
+export default Page
diff --git a/apps/docs/pages/guides/functions/examples/telegram-bot.mdx b/apps/docs/pages/guides/functions/examples/telegram-bot.mdx
new file mode 100644
index 00000000000..bac6a45eba2
--- /dev/null
+++ b/apps/docs/pages/guides/functions/examples/telegram-bot.mdx
@@ -0,0 +1,22 @@
+import Layout from '~/layouts/DefaultGuideLayout'
+
+export const meta = {
+ id: 'examples-telegram-bot',
+ title: 'Telegram Bot',
+ description: 'Building a Telegram Bot with Edge Functions.',
+}
+
+
+
+
+
+Handle Telegram Bot Webhooks with the [grammY framework](https://grammy.dev/). grammY is an open source Telegram Bot Framework which makes it easy to handle and respond to incoming messages. [View on GitHub](https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/telegram-bot).
+
+export const Page = ({ children }) =>
+
+export default Page
diff --git a/apps/docs/pages/guides/functions/overview.mdx b/apps/docs/pages/guides/functions/overview.mdx
new file mode 100644
index 00000000000..49935c280bf
--- /dev/null
+++ b/apps/docs/pages/guides/functions/overview.mdx
@@ -0,0 +1,84 @@
+import Layout from '~/layouts/DefaultGuideLayout'
+
+export const meta = {
+ id: 'functions-overview',
+ title: 'Edge Functions Overview',
+ description: 'Globally distributed TypeScript Functions.',
+ sidebar_label: 'Overview',
+}
+
+Learn how to build an Edge Function locally and deploy it to the Supabase Platform in less than 7 minutes.
+
+
+
+
+
+## Prerequisites
+
+Follow the steps to prepare your Supabase project on your local machine.
+
+- Install the Supabase CLI. [Docs](/docs/guides/cli).
+- Login to the CLI using the command: `supabase login`. [Docs](/docs/reference/cli/usage#supabase-login).
+- Initialize Supabase inside your project using the command: `supabase init`. [Docs](/docs/guides/cli/local-development#getting-started).
+- Link to your Remote Project using the command `supabase link --project-ref your-project-ref`. [Docs](/docs/reference/cli/usage#supabase-link).
+- Optional: Setup your environment: Follow [this setup guide](https://deno.land/manual/getting_started/setup_your_environment) to integrate the Deno language server with your editor.
+
+## Create a function
+
+Let's create a new Edge Function called `hello-world` inside your project:
+
+```bash
+supabase functions new hello-world
+```
+
+This creates a function stub in your `supabase` folder at `./functions/hello-world/index.ts`.
+
+## Deploy to production
+
+```bash
+supabase functions deploy hello-world
+```
+
+This command bundles your Edge Function from `./functions/hello-world/index.ts` and deploys it to the Supabase platform.
+The command outputs a URL to the Supabase Dashboard which you can open to find view more details. Let's open the link to find the execution command.
+
+
+
+By default, Edge Functions require a valid JWT in the authorization header. This header is automatically set when invoking your function via a Supabase client library.
+
+If you want to use Edge Functions to handle webhooks (e.g. [Stripe payment webhooks](https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/stripe-webhooks) etc.), you need to pass the `--no-verify-jwt` flag when deploying your function.
+
+
+
+## Execute remote functions
+
+You can execute Edge Functions using curl. Copy the curl command from the Dashboard. It should look like this:
+
+```bash
+curl --request POST 'https://.functions.supabase.co/hello-world' \
+ --header 'Authorization: Bearer ANON_KEY' \
+ --header 'Content-Type: application/json' \
+ --data '{ "name":"Functions" }'
+```
+
+If you receive an error `Invalid JWT`, find the `ANON_KEY` of your project in the Dashboard under `Settings > API`.
+
+After invoking your Edge Function you should see the response `{ "message":"Hello Functions!" }`.
+
+## Limitations
+
+- Deno Deploy limitations
+ - Deno does not support outgoing connections to ports `25`, `465`, and `587`.
+ - Cannot write to File System
+- Edge Functions
+ - Local development - only one function at a time
+ - Serving of HTML content is not supported (`GET` requests that return `text/html` will be rewritten to `text/plain`).
+
+export const Page = ({ children }) =>
+
+export default Page
diff --git a/apps/docs/pages/guides/functions/quickstart.mdx b/apps/docs/pages/guides/functions/quickstart.mdx
deleted file mode 100644
index 55b9ed617c6..00000000000
--- a/apps/docs/pages/guides/functions/quickstart.mdx
+++ /dev/null
@@ -1,210 +0,0 @@
-import Layout from '~/layouts/DefaultGuideLayout'
-
-export const meta = {
- id: 'functions-quickstart',
- title: 'Edge Functions Quickstart',
- description: 'Globally distributed TypeScript functions.',
- sidebar_label: 'Quickstart',
-}
-
-Learn how to build an Edge Function locally and deploy it to the Supabase Platform in less than 7 minutes.
-
-
-
-
-
-## Prerequisites
-
-Follow the steps to prepare your Supabase project on your local machine.
-
-- Install the Supabase CLI. [Docs](/docs/guides/cli).
-- Login to the CLI using the command: `supabase login`. [Docs](/docs/reference/cli/usage#supabase-login).
-- Initialize Supabase inside your project using the command: `supabase init`. [Docs](/docs/guides/cli/local-development#getting-started).
-- Link to your Remote Project using the command `supabase link --project-ref your-project-ref`. [Docs](/docs/reference/cli/usage#supabase-link).
-- Optional: Setup your environment: Follow [this setup guide](https://deno.land/manual/getting_started/setup_your_environment) to integrate the Deno language server with your editor.
-
-## Create a function
-
-Let's create a new Edge Function called `hello-world` inside your project:
-
-```bash
-supabase functions new hello-world
-```
-
-This creates a function stub in your `supabase` folder at `./functions/hello-world/index.ts`.
-
-## Deploy to production
-
-```bash
-supabase functions deploy hello-world
-```
-
-This command bundles your Edge Function from `./functions/hello-world/index.ts` and deploys it to the Supabase platform.
-The command outputs a URL to the Supabase Dashboard which you can open to find view more details. Let's open the link to find the execution command.
-
-
-
-By default, Edge Functions require a valid JWT in the authorization header. This header is automatically set when invoking your function via a Supabase client library.
-
-If you want to use Edge Functions to handle webhooks (e.g. [Stripe payment webhooks](https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/stripe-webhooks) etc.), you need to pass the `--no-verify-jwt` flag when deploying your function.
-
-
-
-## Execute remote functions
-
-You can execute Edge Functions using curl. Copy the curl command from the Dashboard. It should look like this:
-
-```bash
-curl --request POST 'https://.functions.supabase.co/hello-world' \
- --header 'Authorization: Bearer ANON_KEY' \
- --header 'Content-Type: application/json' \
- --data '{ "name":"Functions" }'
-```
-
-If you receive an error `Invalid JWT`, find the `ANON_KEY` of your project in the Dashboard under `Settings > API`.
-
-After invoking your Edge Function you should see the response `{ "message":"Hello Functions!" }`.
-
-## Debug functions
-
-You can debug your deployed Edge Functions using the "Functions" section of the Dashboard. There are two types debugging tools available:
-
-- Invocations: shows the Request and Response for each execution.
-- Logs: shows any platform events, including deployments and errors.
-
-
-
-## Develop locally
-
-You can run your Edge Function locally using [`supabase functions serve`](/docs/reference/cli/usage#supabase-functions-serve):
-
-```bash
-supabase start # start the supabase stack
-supabase functions serve hello-world # start the Function watcher
-```
-
-The `functions serve` command has hot-reloading capabilities. It will watch for any changes to your files and restart the Deno server.
-
-### Invoke functions locally
-
-While serving your local Function, you can execute it using curl:
-
-```bash
-curl --request POST 'http://localhost:54321/functions/v1/hello-world' \
- --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24ifQ.625_WdcF3KHqz5amU0x2X5WWHP-OEs_4qj0ssLNHzTs' \
- --header 'Content-Type: application/json' \
- --data '{ "name":"Functions" }'
-```
-
-You should see the response `{ "message":"Hello Functions!" }`.
-
-
-Implementation details
-
-- Edge Functions don't serve HTML content (`GET` requests that return `text/html` are rewritten to `text/plain`).
-- The `Authorization` header is required. You can use either the `ANON` key, the `SERVICE_ROLE` key, or a logged-in user's JWT.
-- The Function is proxied through the local API (`http://localhost:54321`)
-
-
-
-
-If you execute Function with a different payload the response will change.
-Modify the `--data '{"name":"Functions"}'` line to `--data '{"name":"World"}'` and try invoking the command again!
-
-## Secrets and Environment Variables
-
-It's common that you will need to use sensitive information or environment-specific variables inside your Edge Functions. You can access these using Deno's built-in handler
-
-```js
-Deno.env.get(MY_SECRET_NAME)
-```
-
-### Default secrets
-
-By default, Edge Functions have access to these secrets:
-
-- `SUPABASE_URL`: The API gateway for your Supabase project.
-- `SUPABASE_ANON_KEY`: The `anon` key for your Supabase API. This is safe to use in a browser when you have [Row Level Security](/docs/guides/auth/row-level-security) enabled.
-- `SUPABASE_SERVICE_ROLE_KEY`: The `service_role` key for your Supabase API. This is safe to use in Edge Functions, but it should NEVER be used in a browser. This key will bypass [Row Level Security](/docs/guides/auth/row-level-security).
-- `SUPABASE_DB_URL`: The URL for your [PostgreSQL database](/docs/guides/database). You can use this to connect directly to your database.
-
-### Local secrets
-
-Let's create a local file for storing our secrets, and inside it we can store a secret `MY_NAME`:
-
-```jsx
-echo "MY_NAME=Yoda" >> ./supabase/.env.local
-```
-
-This creates a new file `./supabase/.env.local` for storing your local development secrets.
-
-
-
-Never check your .env files into Git!
-
-
-
-Now let's access this environment variable `MY_NAME` inside our Function. Anywhere in your function, add this line:
-
-```jsx
-console.log(Deno.env.get('MY_NAME'))
-```
-
-Now we can invoke our function locally, by serving it with our new `.env.local` file:
-
-```bash
-supabase functions serve hello-world --env-file ./supabase/.env.local
-```
-
-When the function starts you should see the name “Yoda” output to the terminal.
-
-### Production secrets
-
-Let's create a `.env` for production. In this case we'll just use the same as our local secrets:
-
-```bash
-cp ./supabase/.env.local ./supabase/.env
-```
-
-This creates a new file `./supabase/.env` for storing your production secrets.
-
-
-
-Never check your `.env` files into Git!
-
-
-
-Let's push all the secrets from the `.env` file to our remote project using [`supabase secrets set`](/docs/reference/cli/usage#supabase-secrets-set):
-
-```bash
-supabase secrets set --env-file ./supabase/.env
-
-# You can also set secrets individually using:
-supabase secrets set MY_NAME=Chewbacca
-```
-
-You don't need to re-deploy after setting your secrets.
-
-To see all the secrets which you have set remotely, use [`supabase secrets list`](/docs/reference/cli/usage#supabase-secrets-list):
-
-```bash
-supabase secrets list
-```
-
-## Limitations
-
-- Deno Deploy limitations
- - Deno does not support outgoing connections to ports `25`, `465`, and `587`.
- - Cannot write to File System
-- Edge Functions
- - Local development - only one function at a time
- - Serving of HTML content is not supported (`GET` requests that return `text/html` will be rewritten to `text/plain`).
-
-export const Page = ({ children }) =>
-
-export default Page
diff --git a/apps/docs/pages/guides/functions/secrets.mdx b/apps/docs/pages/guides/functions/secrets.mdx
new file mode 100644
index 00000000000..dd51094d374
--- /dev/null
+++ b/apps/docs/pages/guides/functions/secrets.mdx
@@ -0,0 +1,89 @@
+import Layout from '~/layouts/DefaultGuideLayout'
+
+export const meta = {
+ id: 'functions-secrets',
+ title: 'Secrets and Environment Variables',
+ description: 'Managing secrets and environment variables.',
+}
+
+It's common that you will need to use sensitive information or environment-specific variables inside your Edge Functions. You can access these using Deno's built-in handler
+
+```js
+Deno.env.get(MY_SECRET_NAME)
+```
+
+### Default secrets
+
+By default, Edge Functions have access to these secrets:
+
+- `SUPABASE_URL`: The API gateway for your Supabase project.
+- `SUPABASE_ANON_KEY`: The `anon` key for your Supabase API. This is safe to use in a browser when you have [Row Level Security](/docs/guides/auth/row-level-security) enabled.
+- `SUPABASE_SERVICE_ROLE_KEY`: The `service_role` key for your Supabase API. This is safe to use in Edge Functions, but it should NEVER be used in a browser. This key will bypass [Row Level Security](/docs/guides/auth/row-level-security).
+- `SUPABASE_DB_URL`: The URL for your [PostgreSQL database](/docs/guides/database). You can use this to connect directly to your database.
+
+### Local secrets
+
+Let's create a local file for storing our secrets, and inside it we can store a secret `MY_NAME`:
+
+```jsx
+echo "MY_NAME=Yoda" >> ./supabase/.env.local
+```
+
+This creates a new file `./supabase/.env.local` for storing your local development secrets.
+
+
+
+Never check your .env files into Git!
+
+
+
+Now let's access this environment variable `MY_NAME` inside our Function. Anywhere in your function, add this line:
+
+```jsx
+console.log(Deno.env.get('MY_NAME'))
+```
+
+Now we can invoke our function locally, by serving it with our new `.env.local` file:
+
+```bash
+supabase functions serve hello-world --env-file ./supabase/.env.local
+```
+
+When the function starts you should see the name “Yoda” output to the terminal.
+
+### Production secrets
+
+Let's create a `.env` for production. In this case we'll just use the same as our local secrets:
+
+```bash
+cp ./supabase/.env.local ./supabase/.env
+```
+
+This creates a new file `./supabase/.env` for storing your production secrets.
+
+
+
+Never check your `.env` files into Git!
+
+
+
+Let's push all the secrets from the `.env` file to our remote project using [`supabase secrets set`](/docs/reference/cli/usage#supabase-secrets-set):
+
+```bash
+supabase secrets set --env-file ./supabase/.env
+
+# You can also set secrets individually using:
+supabase secrets set MY_NAME=Chewbacca
+```
+
+You don't need to re-deploy after setting your secrets.
+
+To see all the secrets which you have set remotely, use [`supabase secrets list`](/docs/reference/cli/usage#supabase-secrets-list):
+
+```bash
+supabase secrets list
+```
+
+export const Page = ({ children }) =>
+
+export default Page
diff --git a/apps/docs/pages/guides/functions/testing-debugging.mdx b/apps/docs/pages/guides/functions/testing-debugging.mdx
new file mode 100644
index 00000000000..b0b4cc468dd
--- /dev/null
+++ b/apps/docs/pages/guides/functions/testing-debugging.mdx
@@ -0,0 +1,55 @@
+import Layout from '~/layouts/DefaultGuideLayout'
+
+export const meta = {
+ id: 'functions-testing-debugging',
+ title: 'Testing and Debugging Functions',
+ description: 'Test and debug functions locally and in production.',
+}
+
+You can debug your deployed Edge Functions using the "Functions" section of the Dashboard. There are two types debugging tools available:
+
+- Invocations: shows the Request and Response for each execution.
+- Logs: shows any platform events, including deployments and errors.
+
+
+
+## Develop locally
+
+You can run your Edge Function locally using [`supabase functions serve`](/docs/reference/cli/usage#supabase-functions-serve):
+
+```bash
+supabase start # start the supabase stack
+supabase functions serve hello-world # start the Function watcher
+```
+
+The `functions serve` command has hot-reloading capabilities. It will watch for any changes to your files and restart the Deno server.
+
+### Invoke functions locally
+
+While serving your local Function, you can execute it using curl:
+
+```bash
+curl --request POST 'http://localhost:54321/functions/v1/hello-world' \
+ --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24ifQ.625_WdcF3KHqz5amU0x2X5WWHP-OEs_4qj0ssLNHzTs' \
+ --header 'Content-Type: application/json' \
+ --data '{ "name":"Functions" }'
+```
+
+You should see the response `{ "message":"Hello Functions!" }`.
+
+
+Implementation details
+
+- Edge Functions don't serve HTML content (`GET` requests that return `text/html` are rewritten to `text/plain`).
+- The `Authorization` header is required. You can use either the `ANON` key, the `SERVICE_ROLE` key, or a logged-in user's JWT.
+- The Function is proxied through the local API (`http://localhost:54321`)
+
+
+
+
+If you execute Function with a different payload the response will change.
+Modify the `--data '{"name":"Functions"}'` line to `--data '{"name":"World"}'` and try invoking the command again!
+
+export const Page = ({ children }) =>
+
+export default Page
diff --git a/apps/docs/pages/guides/functions/best-practices.mdx b/apps/docs/pages/guides/functions/tips.mdx
similarity index 71%
rename from apps/docs/pages/guides/functions/best-practices.mdx
rename to apps/docs/pages/guides/functions/tips.mdx
index b670cd73a05..8d11169805a 100644
--- a/apps/docs/pages/guides/functions/best-practices.mdx
+++ b/apps/docs/pages/guides/functions/tips.mdx
@@ -1,9 +1,9 @@
import Layout from '~/layouts/DefaultGuideLayout'
export const meta = {
- id: 'functions-best-practices',
- title: 'Edge Functions Best Practices',
- description: 'Globally distributed TypeScript functions.',
+ id: 'functions-tips',
+ title: 'Edge Functions Tips',
+ description: 'Misc Tips for Supabase Edge Functions.',
}
## Database Functions vs Edge Functions
@@ -35,26 +35,6 @@ We recommend developing “fat functions”. This means that you should develop
We recommend using hyphens to name functions because hyphens are the most URL-friendly of all the naming conventions (snake_case, camelCase, PascalCase).
-## CORS (Cross-Origin Resource Sharing)
-
-We recommend adding a check to handle [CORS Preflight](https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request) requests in your edge function to be able to invoke the function from browsers.
-
-See the [example on GitHub](https://github.com/supabase/supabase/blob/master/examples/edge-functions/supabase/functions/browser-with-cors/index.ts).
-
-```ts
-export const corsHeaders = {
- 'Access-Control-Allow-Origin': '*',
- 'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey',
-}
-
-serve(async (req) => {
- if (req.method === 'OPTIONS') {
- return new Response('ok', { headers: corsHeaders })
- }
- ...
-})
-```
-
## Using HTTP Methods
Edge Functions supports `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, and `OPTIONS`. A function can be designed to perform different actions based on a request's HTTP method. See the [example on building a RESTful service](https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/restful-tasks) to learn how to handle different HTTP methods in your function.
From 6a09b850a799e8a14f7fd3fe0d95032fc6608f23 Mon Sep 17 00:00:00 2001
From: thorwebdev
Date: Thu, 12 Jan 2023 16:59:39 +0800
Subject: [PATCH 08/48] fix: get started link
---
apps/docs/pages/guides/functions.mdx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/apps/docs/pages/guides/functions.mdx b/apps/docs/pages/guides/functions.mdx
index 9c970cb6bfe..792972fe630 100644
--- a/apps/docs/pages/guides/functions.mdx
+++ b/apps/docs/pages/guides/functions.mdx
@@ -18,7 +18,7 @@ Edge Functions are server-side TypeScript functions, distributed globally at the
- Edge Functions are globally distributed for low-latency.
diff --git a/apps/docs/pages/guides/functions/cors.mdx b/apps/docs/pages/guides/functions/cors.mdx
index fca25fa4933..e991ad181a9 100644
--- a/apps/docs/pages/guides/functions/cors.mdx
+++ b/apps/docs/pages/guides/functions/cors.mdx
@@ -12,7 +12,7 @@ See the [example on GitHub](https://github.com/supabase/supabase/blob/master/exa
### Recommended setup
-We recommend adding a `corst.ts` file within a `_shared` folder which makes it easy to reuse the CORS headers across functions:
+We recommend adding a `corst.ts` file within a [`_shared` folder](/docs/guides/functions/tips#organizing-your-edge-functions) which makes it easy to reuse the CORS headers across functions:
```ts cors.ts
export const corsHeaders = {
diff --git a/apps/docs/pages/guides/functions/debugging.mdx b/apps/docs/pages/guides/functions/debugging.mdx
new file mode 100644
index 00000000000..62c93035b2a
--- /dev/null
+++ b/apps/docs/pages/guides/functions/debugging.mdx
@@ -0,0 +1,20 @@
+import Layout from '~/layouts/DefaultGuideLayout'
+
+export const meta = {
+ id: 'functions-debugging',
+ title: 'Debugging Functions',
+ description: 'Debug functions in production.',
+}
+
+You can debug your deployed Edge Functions using the ["Functions" section](https://app.supabase.com/project/_/functions) of the Dashboard. There are two debugging tools available:
+
+- Invocations: shows the Request and Response for each execution.
+- Logs: shows any platform events, including deployments and errors.
+
+
+
+When [developing locally](/docs/guides/functions/local-development) you will see error messages and console log statements printed to your local terminal window.
+
+export const Page = ({ children }) =>
+
+export default Page
diff --git a/apps/docs/pages/guides/functions/testing-debugging.mdx b/apps/docs/pages/guides/functions/local-development.mdx
similarity index 64%
rename from apps/docs/pages/guides/functions/testing-debugging.mdx
rename to apps/docs/pages/guides/functions/local-development.mdx
index b0b4cc468dd..01bd0f88a4d 100644
--- a/apps/docs/pages/guides/functions/testing-debugging.mdx
+++ b/apps/docs/pages/guides/functions/local-development.mdx
@@ -1,20 +1,11 @@
import Layout from '~/layouts/DefaultGuideLayout'
export const meta = {
- id: 'functions-testing-debugging',
- title: 'Testing and Debugging Functions',
- description: 'Test and debug functions locally and in production.',
+ id: 'functions-local-development',
+ title: 'Local Development',
+ description: 'Run your functions locally.',
}
-You can debug your deployed Edge Functions using the "Functions" section of the Dashboard. There are two types debugging tools available:
-
-- Invocations: shows the Request and Response for each execution.
-- Logs: shows any platform events, including deployments and errors.
-
-
-
-## Develop locally
-
You can run your Edge Function locally using [`supabase functions serve`](/docs/reference/cli/usage#supabase-functions-serve):
```bash
@@ -26,7 +17,7 @@ The `functions serve` command has hot-reloading capabilities. It will watch for
### Invoke functions locally
-While serving your local Function, you can execute it using curl:
+While serving your local Function, you can invoke it using curl:
```bash
curl --request POST 'http://localhost:54321/functions/v1/hello-world' \
@@ -35,20 +26,34 @@ curl --request POST 'http://localhost:54321/functions/v1/hello-world' \
--data '{ "name":"Functions" }'
```
+or using one of the [client libraries](/docs#reference-documentation), e.g. using [supabase-js](/docs/reference/javascript/functions-invoke):
+
+```js
+import { createClient } from '@supabase/supabase-js'
+
+// Use the credentials outputted in your terminal when running `supabase start`
+const supabase = createClient(
+ 'http://localhost:54321',
+ 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0'
+)
+
+const { data, error } = await supabase.functions.invoke('hello-world', {
+ body: { name: 'Functions' },
+})
+```
+
You should see the response `{ "message":"Hello Functions!" }`.
-
-Implementation details
+If you execute Function with a different payload the response will change.
+Modify the `--data '{"name":"Functions"}'` line to `--data '{"name":"World"}'` and try invoking the command again!
+
+
- Edge Functions don't serve HTML content (`GET` requests that return `text/html` are rewritten to `text/plain`).
- The `Authorization` header is required. You can use either the `ANON` key, the `SERVICE_ROLE` key, or a logged-in user's JWT.
- The Function is proxied through the local API (`http://localhost:54321`)
-
-
-
-If you execute Function with a different payload the response will change.
-Modify the `--data '{"name":"Functions"}'` line to `--data '{"name":"World"}'` and try invoking the command again!
+
export const Page = ({ children }) =>
diff --git a/apps/docs/pages/guides/functions/overview.mdx b/apps/docs/pages/guides/functions/quickstart.mdx
similarity index 97%
rename from apps/docs/pages/guides/functions/overview.mdx
rename to apps/docs/pages/guides/functions/quickstart.mdx
index 49935c280bf..7b489f2009e 100644
--- a/apps/docs/pages/guides/functions/overview.mdx
+++ b/apps/docs/pages/guides/functions/quickstart.mdx
@@ -1,10 +1,10 @@
import Layout from '~/layouts/DefaultGuideLayout'
export const meta = {
- id: 'functions-overview',
- title: 'Edge Functions Overview',
+ id: 'functions-quickstart',
+ title: 'Edge Functions Quickstart',
description: 'Globally distributed TypeScript Functions.',
- sidebar_label: 'Overview',
+ sidebar_label: 'Quickstart',
}
Learn how to build an Edge Function locally and deploy it to the Supabase Platform in less than 7 minutes.
diff --git a/apps/docs/pages/guides/functions/tips.mdx b/apps/docs/pages/guides/functions/tips.mdx
index 8d11169805a..9c96998db4a 100644
--- a/apps/docs/pages/guides/functions/tips.mdx
+++ b/apps/docs/pages/guides/functions/tips.mdx
@@ -21,11 +21,12 @@ We recommend developing “fat functions”. This means that you should develop
└── supabase
├── functions
│ ├── _shared
- │ | ├── supabaseAdmin.ts # Supabase client with SERVICE_ROLE key
- │ │ └── supabaseClient.ts # Supabase client with ANON key
- │ ├── function-one # use hyphens to name functions
- │ │ └── index.ts
- │ └── function-two
+ │ │ ├── supabaseAdmin.ts # Supabase client with SERVICE_ROLE key
+ │ │ └── supabaseClient.ts # Supabase client with ANON key
+ │ │ └── cors.ts # Reusable CORS headers
+ │ ├── function-one # use hyphens to name functions
+ │ │ └── index.ts
+ │ └── function-two
│ └── index.ts
├── migrations
└── config.toml
From 17aa997ffe60dc85e21cc1874202678a7e4d32d1 Mon Sep 17 00:00:00 2001
From: Joshen Lim
Date: Fri, 13 Jan 2023 14:04:06 +0800
Subject: [PATCH 11/48] Updates based as per PR comments
---
studio/components/interfaces/Auth/Policies/Policies.tsx | 5 ++---
.../interfaces/Auth/Policies/PolicyTableRow/index.tsx | 8 ++++++--
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/studio/components/interfaces/Auth/Policies/Policies.tsx b/studio/components/interfaces/Auth/Policies/Policies.tsx
index 81669a1a6f5..550bd59f740 100644
--- a/studio/components/interfaces/Auth/Policies/Policies.tsx
+++ b/studio/components/interfaces/Auth/Policies/Policies.tsx
@@ -137,7 +137,7 @@ const Policies: FC = ({ tables, hasTables, isLocked }) => {
= ({ tables, hasTables, isLocked }) => {
}
/>
- A table within this schema is required before you can create a Row-Level Security
- policy.
+ Create a table in this schema first before creating a policy.
- As RLS has been enabled, all normal access to this table must be allowed by a policy.
+ RLS is enabled - create a policy to allow access to this table.
+
+ ) : (
+
+ Warning: RLS is disabled - anonymous access is allowed to this table
- This reference documents every object and method available in Supabase's Flutter
- library, [supabase-flutter](https://pub.dev/packages/supabase_flutter). You can
- use supabase-flutter to interact with your Postgres database, listen to database changes, invoke
- Deno Edge Functions, build login and user management functionality, and manage large files.
-
-
- We also provide [supabase](https://pub.dev/packages/supabase) package for non-Flutter projects.
+
+This reference documents every object and method available in Supabase's Flutter
+library, [supabase-flutter](https://pub.dev/packages/supabase_flutter). You can
+use supabase-flutter to interact with your Postgres database, listen to database changes, invoke
+Deno Edge Functions, build login and user management functionality, and manage large files.
+
+We also provide a [supabase](https://pub.dev/packages/supabase) package for non-Flutter projects.
+
+
+
+ You're viewing the docs for an older version of the `supabase-flutter` library. Learn how to
+ [upgrade to the latest version](/docs/reference/dart/v0/upgrade-guide).
+
+
+This reference documents every object and method available in Supabase's Flutter library, [supabase-flutter](https://pub.dev/packages/supabase_flutter).
+You can use supabase-flutter to interact with your Postgres database, listen to database changes, invoke
+Deno Edge Functions, build login and user management functionality, and manage large files.
+
+We also provide a [supabase](https://pub.dev/packages/supabase) package for non-Flutter projects.
+
+
- 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.
+
+
+ You're viewing the docs for an older version of the `supabase-js` library. View the [latest
+ version](/docs/reference/javascript/introduction) or follow the [supabase-js v2
+ guide](/docs/reference/javascript/v1/upgrade-guide) to upgrade to the latest version.
+
+
+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.
+
From 679de08aa14b8d60cec0a5a8d34e3549aef0340e Mon Sep 17 00:00:00 2001
From: dannykng
Date: Fri, 13 Jan 2023 17:14:05 -0800
Subject: [PATCH 21/48] Move upgrade guides
---
.../dart => ref/dart/v0}/upgrade-guide.mdx | 177 ++++++-
.../ref/javascript/{ => v1}/upgrade-guide.mdx | 0
.../reference/javascript/upgrade-guide.mdx | 439 ------------------
3 files changed, 167 insertions(+), 449 deletions(-)
rename apps/docs/docs/{reference/dart => ref/dart/v0}/upgrade-guide.mdx (68%)
rename apps/docs/docs/ref/javascript/{ => v1}/upgrade-guide.mdx (100%)
delete mode 100644 apps/docs/docs/reference/javascript/upgrade-guide.mdx
diff --git a/apps/docs/docs/reference/dart/upgrade-guide.mdx b/apps/docs/docs/ref/dart/v0/upgrade-guide.mdx
similarity index 68%
rename from apps/docs/docs/reference/dart/upgrade-guide.mdx
rename to apps/docs/docs/ref/dart/v0/upgrade-guide.mdx
index 707cdd06129..6da7b0c0fe5 100644
--- a/apps/docs/docs/reference/dart/upgrade-guide.mdx
+++ b/apps/docs/docs/ref/dart/v0/upgrade-guide.mdx
@@ -4,23 +4,35 @@ title: Upgrade to supabase-flutter v1
description: 'Learn how to upgrade to supabase-flutter v1.'
---
-import Tabs from '@theme/Tabs'
-import TabItem from '@theme/TabItem'
-
-supabase-flutter focuses on improving the developer experience and making it easier to use. This guide will help you upgrade from supabase-flutter v0 to v1.
+supabase-flutter focuses on improving the developer experience and making it easier to use. This guide demonstrates how to upgrade from supabase-flutter v0 to v1.
## Upgrade the client library
+
+
+
Update the package in your pubspec.yaml file.
+
+
+
```yaml
supabase_flutter: ^1.0.0
```
+
+
+
## Error handling
+
+
+
The way supabase-flutter throws error has changed in v1. In v0, errors were returned as a response. In v1, errors are thrown as exceptions. This makes it more intuitive as a Flutter developer to handle errors.
+
+
+
-## Auth classes / methods
+
+
+
+## Auth classes and methods
### Usage of `SupabaseAuthState` and `SupabaseAuthRequiredState` classes
-In v0, `SupabaseAuthState` and `SupabaseAuthRequiredState` were required to handle automatic token refresh and to listen to auth state change. In v1, `SupabaseAuthState` and `SupabaseAuthRequiredState` are deprecated, and token refresh will happen automatically just by initializing Supabase. [`onAuthStateChange`](/docs/reference/dart/upgrade-guide#listening-to-auth-state-change) can be used to action on auth state change.
+
+
+
+In v0, `SupabaseAuthState` and `SupabaseAuthRequiredState` were required to handle automatic token refresh and to listen to auth state change. In v1, `SupabaseAuthState` and `SupabaseAuthRequiredState` are deprecated, and token refresh will happen automatically just by initializing Supabase. [`onAuthStateChange`](#listening-to-auth-state-change) can be used to action on auth state change.
+
+
+
+
+
+
### Listening to auth state change
+
+
+
`onAuthStateChange` now returns a `Stream`.
+
+
+
+
+
+
### Sign in with email and password
-The signIn() method has been deprecated in favor of more explicit method signatures to help with type hinting. Previously it was difficult for developers to know what they were missing (e.g., a lot of developers didn't realize they could use passwordless magic links).
+
+
+
+`signIn()` has been deprecated in favor of more explicit method signatures to help with type hinting. Previously it was difficult for developers to know what they were missing (e.g., a lot of developers didn't realize they could use passwordless magic links).
+
+
+
+
+
+
+
+
+
### Sign in with magic link
+
+
+
+
+
+
+
+
+
### Sign in with a third-party OAuth provider
+
+
+
+
+
+
+
+
+
### Sign in with phone
+
+
+
+
+
+
+
+
+
### Sign in with phone using OTP
+
+
+
+
+
+
+
+
+
### Reset password for email
+
+
+
+
+
+
+
+
+
### Get the user's current session
+
+
+
+
+
+
+
+
+
### Get the logged-in user
+
+
+
+
+
+
+
+
+
### Update user data for a logged-in user
+
+
+
+
+
+
## Data methods
-`.insert()` / `.upsert()` / `.update()` / `.delete()` don't return rows by default.
+`.insert()` / `.upsert()` / `.update()` / `.delete()` no longer return rows by default. Previously, these methods return inserted/updated/deleted rows by default (which caused [some confusion](https://github.com/supabase/supabase/discussions/1548)), and you can opt to not return it by specifying `returning: 'minimal'`. Now the default behavior is to not return rows. To return inserted/updated/deleted rows, add a `.select()` call at the end.
-Previously, these methods return inserted/updated/deleted rows by default (which caused [some confusion](https://github.com/supabase/supabase/discussions/1548)), and you can opt to not return it by specifying `returning: 'minimal'`. Now the default behavior is to not return rows. To return inserted/updated/deleted rows, add a `.select()` call at the end.
+Also, calling `.execute()` at the end of the query was a requirement in v0, but deprecated in v1.
-Also, calling `.execute()` at the end of the query was a requirement in v0, but in v1 `.execute` is deperecated.
+
+
### Insert without returning inserted data
+
+
+
+
+
+
+
+
+
### Insert with returning inserted data
+
+
+
+
+
+
## Realtime methods
+
+
+
### Stream
`.stream()` no longer needs the `.execute()` at the end. Also, filtering by `eq` is a lot easier now. `primaryKey` is now a named parameter to make it more obvious what to pass.
+
+
+
+
+
+
+
+
+
### Subscribe
+
+
+
+
+
+
+
+
+
### Unsubscribe
+
+
+
+
+
+
diff --git a/apps/docs/docs/ref/javascript/upgrade-guide.mdx b/apps/docs/docs/ref/javascript/v1/upgrade-guide.mdx
similarity index 100%
rename from apps/docs/docs/ref/javascript/upgrade-guide.mdx
rename to apps/docs/docs/ref/javascript/v1/upgrade-guide.mdx
diff --git a/apps/docs/docs/reference/javascript/upgrade-guide.mdx b/apps/docs/docs/reference/javascript/upgrade-guide.mdx
deleted file mode 100644
index 282d66d4966..00000000000
--- a/apps/docs/docs/reference/javascript/upgrade-guide.mdx
+++ /dev/null
@@ -1,439 +0,0 @@
----
-id: upgrade-guide
-title: Upgrade to supabase-js v2
-description: 'Learn how to upgrade to supabase-js v2.'
----
-
-import Tabs from '@theme/Tabs'
-import TabItem from '@theme/TabItem'
-
-supabase-js v2 focuses on "quality-of-life" improvements for developers and addresses some of the largest pain points in v1. v2 includes type support, a rebuilt Auth library with async methods, improved errors, and more.
-
-No new features will be added to supabase-js v1 , but we'll continuing merging security fixes to v1, with maintenance patches for the next 3 months.
-
-## Upgrade the client library
-
-```sh
-npm install @supabase/supabase-js@2
-```
-
-_Optionally_ if you are using custom configuration with `createClient` then follow below:
-
-
-
-
-```ts title=src/supabaseClient.ts
-const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY, {
- schema: 'custom',
- persistSession: false,
-})
-```
-
-
-
-
-```ts title=src/supabaseClient.ts
-const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY, {
- db: {
- schema: 'custom',
- },
- auth: {
- persistSession: true,
- },
-})
-```
-
-
-
-
-Read more about the [constructor options](/docs/reference/javascript/release-notes#explicit-constructor-options).
-
-### Auth methods
-
-The signIn() method has been deprecated in favor of more explicit method signatures to help with type hinting. Previously it was difficult for developers to know what they were missing (e.g., a lot of developers didn't realize they could use passwordless magic links).
-
-#### Sign in with email and password
-
-
-
-
-```ts
-const { user, error } = await supabase.auth.signIn({ email, password })
-```
-
-
-
-
-```ts
-const {
- data: { user },
- error,
-} = await supabase.auth.signInWithPassword({ email, password })
-```
-
-
-
-
-#### Sign in with magic link
-
-
-
-
-```ts
-const { error } = await supabase.auth.signIn({ email })
-```
-
-
-
-
-```ts
-const { error } = await supabase.auth.signInWithOtp({ email })
-```
-
-
-
-
-#### Sign in with a third-party provider
-
-
-
-
-```ts
-const { error } = await supabase.auth.signIn({ provider })
-```
-
-
-
-
-```ts
-const { error } = await supabase.auth.signInWithOAuth({ provider })
-```
-
-
-
-
-#### Sign in with phone
-
-
-
-
-```ts
-const { error } = await supabase.auth.signIn({ phone, password })
-```
-
-
-
-
-```ts
-const { error } = await supabase.auth.signInWithPassword({ phone, password })
-```
-
-
-
-
-#### Sign in with phone using OTP
-
-
-
-
-```ts
-const { error } = await supabase.auth.api.sendMobileOTP(phone)
-```
-
-
-
-
-```ts
-const { data, error } = await supabase.auth.signInWithOtp({ phone })
-
-// After receiving a SMS with a OTP.
-const { data, error } = await supabase.auth.verifyOtp({ phone, token })
-```
-
-
-
-
-#### Reset password for email
-
-
-
-
-```ts
-const { data, error } = await supabase.auth.api.resetPasswordForEmail(email)
-```
-
-
-
-
-```ts
-const { data, error } = await supabase.auth.resetPasswordForEmail(email)
-```
-
-
-
-
-#### Get the user's current session
-
-
-
-
-```ts
-const session = supabase.auth.session()
-```
-
-
-
-
-```ts
-const {
- data: { session },
-} = await supabase.auth.getSession()
-```
-
-
-
-
-#### Get the logged-in user
-
-
-
-
-```ts
-const user = supabase.auth.user()
-```
-
-
-
-
-```ts
-const {
- data: { session },
-} = await supabase.auth.getSession()
-const { user } = session
-```
-
-
-
-
-#### Update user data for a logged-in user
-
-
-
-
-```ts
-const { user, error } = await supabase.auth.update({ attributes })
-```
-
-
-
-
-```ts
-const {
- data: { user },
- error,
-} = await supabase.auth.updateUser({ attributes })
-```
-
-
-
-
-#### Use a custom `access_token` JWT with Supabase
-
-
-
-
-```ts
-const { user, error } = supabase.auth.setAuth(access_token)
-```
-
-
-
-
-```ts
-const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY, {
- global: {
- headers: {
- Authorization: `Bearer ${access_token}`,
- },
- },
-})
-```
-
-
-
-
-#### Cookie methods
-
-The cookie-related methods like `setAuthCookie` and `getUserByCookie` have been removed.
-
-For Next.js you can use the [Auth Helpers](https://supabase.com/docs/guides/auth/auth-helpers/nextjs) to help you manage cookies.
-If you can't use the Auth Helpers, you can use [server-side rendering](https://supabase.com/docs/guides/auth/server-side-rendering).
-
-Some the [PR](https://github.com/supabase/gotrue-js/pull/340) for additional background information.
-
-### Data methods
-
-`.insert()` / `.upsert()` / `.update()` / `.delete()` don't return rows by default: [PR](https://github.com/supabase/postgrest-js/pull/276).
-
-Previously, these methods return inserted/updated/deleted rows by default (which caused [some confusion](https://github.com/supabase/supabase/discussions/1548)), and you can opt to not return it by specifying `returning: 'minimal'`. Now the default behavior is to not return rows. To return inserted/updated/deleted rows, add a `.select()` call at the end.
-
-#### Insert and return data
-
-
-
-
-```ts
-const { data, error } = await supabase.auth.insert({ new_data })
-```
-
-
-
-
-```ts
-const { data, error } = await supabase.auth.insert({ new_data }).select()
-```
-
-
-
-
-#### Update and return data
-
-
-
-
-```ts
-const { data, error } = await supabase.auth.update({ new_data }).eq('id', id)
-```
-
-
-
-
-```ts
-const { data, error } = await supabase.auth.update({ new_data }).eq('id', id).select()
-```
-
-
-
-
-### Realtime methods
-
-#### Subscribe
-
-
-
-
-```ts
-const userListener = supabase
- .from('users')
- .on('*', (payload) => handleAllEventsPayload(payload.new))
- .subscribe()
-```
-
-
-
-
-```ts
-const userListener = supabase
- .channel('public:user')
- .on('postgres_changes', { event: '*', schema: 'public', table: 'user' }, (payload) =>
- handleAllEventsPayload()
- )
- .subscribe()
-```
-
-
-
-
-#### Unsubscribe
-
-
-
-
-```ts
-userListener.unsubscribe()
-```
-
-
-
-
-```ts
-supabase.removeChannel(userListener)
-```
-
-
-
From 0c853ca4b04aa68ca3c773aad0419893f7213853 Mon Sep 17 00:00:00 2001
From: dannykng
Date: Fri, 13 Jan 2023 17:14:27 -0800
Subject: [PATCH 22/48] Add redirects
---
apps/www/lib/redirects.js | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/apps/www/lib/redirects.js b/apps/www/lib/redirects.js
index 108782dcb29..420340205b9 100644
--- a/apps/www/lib/redirects.js
+++ b/apps/www/lib/redirects.js
@@ -1891,4 +1891,14 @@ module.exports = [
source: '/legal/soc2',
destination: 'https://forms.supabase.com/soc2',
},
+ {
+ permanent: true,
+ source: '/docs/reference/javascript/upgrade-guide',
+ destination: '/docs/reference/javascript/v1/upgrade-guide',
+ },
+ {
+ permanent: true,
+ source: '/docs/reference/dart/upgrade-guide',
+ destination: '/docs/reference/dart/v0/upgrade-guide',
+ },
]
From 9c46b931111631aa319408908a257223e94918cd Mon Sep 17 00:00:00 2001
From: dannykng
Date: Fri, 13 Jan 2023 17:20:16 -0800
Subject: [PATCH 23/48] Update links
---
apps/docs/data/nonGeneratedReferencePages.ts | 4 ++--
apps/docs/pages/guides/auth/auth-helpers/nextjs.mdx | 2 +-
apps/www/_blog/2022-08-16-supabase-js-v2.mdx | 6 +++---
.../www/_blog/2022-10-20-supabase-js-v2-released.mdx | 12 ++++++------
.../2022-10-21-supabase-flutter-sdk-v1-released.mdx | 6 +++---
5 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/apps/docs/data/nonGeneratedReferencePages.ts b/apps/docs/data/nonGeneratedReferencePages.ts
index fd5ba84d1f5..01b060055c7 100644
--- a/apps/docs/data/nonGeneratedReferencePages.ts
+++ b/apps/docs/data/nonGeneratedReferencePages.ts
@@ -2,7 +2,7 @@ const nonGeneratedReferencePages = [
'docs/reference/javascript',
'docs/reference/javascript/installing',
'docs/reference/javascript/release-notes',
- 'docs/reference/javascript/upgrade-guide',
+ 'docs/reference/javascript/v1/upgrade-guide',
'docs/reference/javascript/typescript-support',
'docs/reference/javascript/v1',
'docs/reference/javascript/v1/installing',
@@ -11,7 +11,7 @@ const nonGeneratedReferencePages = [
'docs/reference/dart',
'docs/reference/dart/installing',
'docs/reference/dart/initializing',
- 'docs/reference/dart/upgrade-guide',
+ 'docs/reference/dart/v0/upgrade-guide',
'docs/reference/dart/v0',
'docs/reference/api',
'docs/reference/api/release-notes',
diff --git a/apps/docs/pages/guides/auth/auth-helpers/nextjs.mdx b/apps/docs/pages/guides/auth/auth-helpers/nextjs.mdx
index 76e169c2271..8f5d318c151 100644
--- a/apps/docs/pages/guides/auth/auth-helpers/nextjs.mdx
+++ b/apps/docs/pages/guides/auth/auth-helpers/nextjs.mdx
@@ -782,7 +782,7 @@ export const config = {
### Migrating to v0.4.X and supabase-js v2
-With the update to `supabase-js` v2 the `auth` API routes are no longer required, therefore you can go ahead and delete your `auth` directory under the `/pages/api/` directory. Please refer to the [v2 migration guide](/docs/reference/javascript/upgrade-guide) for the full set of changes within supabase-js.
+With the update to `supabase-js` v2 the `auth` API routes are no longer required, therefore you can go ahead and delete your `auth` directory under the `/pages/api/` directory. Please refer to the [v2 migration guide](/docs/reference/javascript/v1/upgrade-guide) for the full set of changes within supabase-js.
The `/api/auth/logout` API route has been removed, please use the `signout` method instead:
diff --git a/apps/www/_blog/2022-08-16-supabase-js-v2.mdx b/apps/www/_blog/2022-08-16-supabase-js-v2.mdx
index d7986434a97..07cf3fd54dc 100644
--- a/apps/www/_blog/2022-08-16-supabase-js-v2.mdx
+++ b/apps/www/_blog/2022-08-16-supabase-js-v2.mdx
@@ -13,7 +13,7 @@ toc_depth: 3
@@ -309,7 +309,7 @@ Update today by running:
npm i @supabase/supabase-js@2
```
-[Migration guide](https://supabase.com/docs/reference/javascript/upgrade-guide)
+[Migration guide](https://supabase.com/docs/reference/javascript/v1/upgrade-guide)
We'll continuing merging security fixes to v1, with maintenance patches for the next three months.
@@ -329,6 +329,6 @@ We'll continuing merging security fixes to v1, with maintenance patches for the
## supabase-js v2 resources
- [v2 Documentation](https://supabase.com/docs/reference/javascript)
-- [Migration guide](https://supabase.com/docs/reference/javascript/upgrade-guide)
+- [Migration guide](https://supabase.com/docs/reference/javascript/v1/upgrade-guide)
- [Next.js quickstart guide](/docs/guides/with-nextjs)
- [Examples](https://github.com/supabase/supabase/tree/master/examples)
diff --git a/apps/www/_blog/2022-10-20-supabase-js-v2-released.mdx b/apps/www/_blog/2022-10-20-supabase-js-v2-released.mdx
index 6e17afd4d14..6c2fca19cd8 100644
--- a/apps/www/_blog/2022-10-20-supabase-js-v2-released.mdx
+++ b/apps/www/_blog/2022-10-20-supabase-js-v2-released.mdx
@@ -2,7 +2,7 @@
title: 'supabase-js v2 Released'
description: We've released supabase-js v2. Updated examples, quickstarts, and an improved experience.
author: thor_schaeff
-image: supabase-js-v2-release/supabase-js.jpg
+image: supabase-js-v2-release/supabase-js.jpg
thumb: supabase-js-v2-release/supabase-js.jpg
tags:
- launch-week
@@ -10,17 +10,17 @@ date: '2022-10-20'
toc_depth: 3
---
-During our [last Launch Week](/launch-week) we presented the [release candidate for supabase-js v2](/blog/supabase-js-v2). Since then we've been busy incorporating your feedback, [updating the docs](/docs/reference/javascript/), [examples](https://github.com/supabase/supabase/tree/master/examples), [quickstart guides](/docs/guides/with-nextjs), and putting a [migration guide](/docs/reference/javascript/upgrade-guide) together.
+During our [last Launch Week](/launch-week) we presented the [release candidate for supabase-js v2](/blog/supabase-js-v2). Since then we've been busy incorporating your feedback, [updating the docs](/docs/reference/javascript/), [examples](https://github.com/supabase/supabase/tree/master/examples), [quickstart guides](/docs/guides/with-nextjs), and putting a [migration guide](/docs/reference/javascript/v1/upgrade-guide) together.
## What is new in v2?
-Enhanced TypeScript support built right in was the big one! Now you can use the CLI to generate types, directly from your database.
+Enhanced TypeScript support built right in was the big one! Now you can use the CLI to generate types, directly from your database.
-Plus v2 comes with lots of improvements that solved some of the largest pain-points highlighted by our users. Your feedback help us improve: you speak, we listen.
+Plus v2 comes with lots of improvements that solved some of the largest pain-points highlighted by our users. Your feedback help us improve: you speak, we listen.
Read all the updates and the differences with v1 on the [announcement blog post](/blog/supabase-js-v2)
-## Acknowledgements
+## Acknowledgements
It truly takes a village, well, in this case an entire community, and we want to thank you all for your feedback, and contributions!
@@ -40,7 +40,7 @@ Special shout outs to: [@vejja](https://github.com/vejja), [@pixtron](https://gi
## Links
- [Documentation](/docs/reference/javascript)
-- [Migration Guide](/docs/reference/javascript/upgrade-guide)
+- [Migration Guide](/docs/reference/javascript/v1/upgrade-guide)
- [Quickstart Guides](/docs/guides/with-nextjs)
- [Examples (GitHub)](https://github.com/supabase/supabase/tree/master/examples)
- [Release Notes](/docs/reference/javascript/release-notes)
diff --git a/apps/www/_blog/2022-10-21-supabase-flutter-sdk-v1-released.mdx b/apps/www/_blog/2022-10-21-supabase-flutter-sdk-v1-released.mdx
index e7fdabdc869..92aed5cbb3b 100644
--- a/apps/www/_blog/2022-10-21-supabase-flutter-sdk-v1-released.mdx
+++ b/apps/www/_blog/2022-10-21-supabase-flutter-sdk-v1-released.mdx
@@ -2,7 +2,7 @@
title: 'supabase-flutter v1 Released'
description: We've released supabase-flutter v1. More intuitive way of accessing Supabase from your Flutter application.
author: tyler_shukert
-image: flutter-v1-release/flutter_v1_official_release.jpeg
+image: flutter-v1-release/flutter_v1_official_release.jpeg
thumb: flutter-v1-release/flutter_v1_official_release.jpeg
tags:
- flutter
@@ -11,7 +11,7 @@ date: '2022-10-21'
toc_depth: 3
---
-A few months ago, we announced a [developer preview version of supabase-flutter SDK](https://supabase.com/blog/supabase-flutter-sdk-1-developer-preview). Since then, we have heard a lot of amazing feedback from the community, and have been improving it. Today, we are happy to announce the stable v1 of [supabase-flutter](https://pub.dev/packages/supabase_flutter). You can also find the updated [quick start guide](https://supabase.com/docs/guides/with-flutter), [documentation](https://supabase.com/docs/reference/dart) and a [migration guide from v0](https://supabase.com/docs/reference/dart/upgrade-guide).
+A few months ago, we announced a [developer preview version of supabase-flutter SDK](https://supabase.com/blog/supabase-flutter-sdk-1-developer-preview). Since then, we have heard a lot of amazing feedback from the community, and have been improving it. Today, we are happy to announce the stable v1 of [supabase-flutter](https://pub.dev/packages/supabase_flutter). You can also find the updated [quick start guide](https://supabase.com/docs/guides/with-flutter), [documentation](https://supabase.com/docs/reference/dart) and a [migration guide from v0](https://supabase.com/docs/reference/dart/v0/upgrade-guide).
## What is new in v1?
@@ -97,7 +97,7 @@ It required massive support from the community to bring the supabase-flutter to
- [Install supabase-flutter v1.0](https://pub.dev/packages/supabase_flutter)
- [supabase-flutter documentation](https://supabase.com/docs/reference/dart/)
-- [v0 to v1 migration guide](https://supabase.com/docs/reference/dart/upgrade-guide)
+- [v0 to v1 migration guide](https://supabase.com/docs/reference/dart/v0/upgrade-guide)
- [Flutter Tutorial: building a Flutter chat app](https://supabase.com/blog/flutter-tutorial-building-a-chat-app)
- [Flutter Tutorial - Part 2: Authentication and Authorization with RLS](https://supabase.com/blog/flutter-authentication-and-authorization-with-rls)
- [Build a Flutter app with Very Good CLI and Supabase](https://verygood.ventures/blog/flutter-app-very-good-cli-supabase)
From f92d4369934cb9b2d870bd182c46f4f0bb90ce18 Mon Sep 17 00:00:00 2001
From: dannykng
Date: Fri, 13 Jan 2023 18:19:04 -0800
Subject: [PATCH 24/48] Update callout copy
---
apps/docs/docs/ref/javascript/v1/introduction.mdx | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/apps/docs/docs/ref/javascript/v1/introduction.mdx b/apps/docs/docs/ref/javascript/v1/introduction.mdx
index 6d050a1f668..2c275e45e33 100644
--- a/apps/docs/docs/ref/javascript/v1/introduction.mdx
+++ b/apps/docs/docs/ref/javascript/v1/introduction.mdx
@@ -15,9 +15,8 @@ hideTitle: true
- You're viewing the docs for an older version of the `supabase-js` library. View the [latest
- version](/docs/reference/javascript/introduction) or follow the [supabase-js v2
- guide](/docs/reference/javascript/v1/upgrade-guide) to upgrade to the latest version.
+ You're viewing the docs for an older version of the `supabase-js` library. Learn how to upgrade to
+ the [upgrade to the latest version](/docs/reference/javascript/v1/upgrade-guide).
This reference documents every object and method available in Supabase's isomorphic JavaScript
From 0f1b18680265376fce92790dd863d53da953cbfd Mon Sep 17 00:00:00 2001
From: dannykng
Date: Fri, 13 Jan 2023 18:21:13 -0800
Subject: [PATCH 25/48] Fix typo
---
apps/docs/docs/ref/javascript/v1/introduction.mdx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/apps/docs/docs/ref/javascript/v1/introduction.mdx b/apps/docs/docs/ref/javascript/v1/introduction.mdx
index 2c275e45e33..a62134bdd69 100644
--- a/apps/docs/docs/ref/javascript/v1/introduction.mdx
+++ b/apps/docs/docs/ref/javascript/v1/introduction.mdx
@@ -15,8 +15,8 @@ hideTitle: true
- You're viewing the docs for an older version of the `supabase-js` library. Learn how to upgrade to
- the [upgrade to the latest version](/docs/reference/javascript/v1/upgrade-guide).
+ You're viewing the docs for an older version of the `supabase-js` library. Learn how to [upgrade
+ to the latest version](/docs/reference/javascript/v1/upgrade-guide).
This reference documents every object and method available in Supabase's isomorphic JavaScript
From 1345dba7c5cf94147a266c1f2940ac16d8ddcb54 Mon Sep 17 00:00:00 2001
From: j0hnta <22534726+johnta0@users.noreply.github.com>
Date: Sat, 14 Jan 2023 16:13:16 +0900
Subject: [PATCH 26/48] Update prixma.mdx
* Project ref should be different for each user, so made it unspecific.
* Update supabase.red, seemingly the old domain, to supabase.co.
---
apps/docs/pages/guides/integrations/prisma.mdx | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/apps/docs/pages/guides/integrations/prisma.mdx b/apps/docs/pages/guides/integrations/prisma.mdx
index 6a80e95fee6..840028a00c7 100644
--- a/apps/docs/pages/guides/integrations/prisma.mdx
+++ b/apps/docs/pages/guides/integrations/prisma.mdx
@@ -68,7 +68,7 @@ By default, Prisma migrations will try to drop the `postgres` database, which ca
Create a shadow database in your PostgreSQL server within the same Supabase project using the `psql` CLI and the `DATABASE_URL` from the previous steps (or use the local database).
```bash
-psql postgresql://postgres:[YOUR-PASSWORD]@db.vdbnhqozmlzdsaejdxwr.supabase.red:5432
+psql postgresql://postgres:[YOUR-PASSWORD]@db.[YOUR-PROJECT-REF].supabase.co:5432
```
After you connect to your project's PostgreSQL instance, create another database (e.g., `postgres_shadow`):
@@ -83,8 +83,8 @@ In the `.env` file, update `DATABASE_URL` and `SHADOW_DATABASE_URL` to the conne
```env
# .env
-DATABASE_URL="postgres://postgres:[YOUR-PASSWORD]@db.vdbnhqozmlzdsaejdxwr.supabase.co:5432/postgres"
-SHADOW_DATABASE_URL="postgres://postgres:[YOUR-PASSWORD]@db.vdbnhqozmlzdsaejdxwr.supabase.co:5432/postgres_shadow"
+DATABASE_URL="postgres://postgres:[YOUR-PASSWORD]@db.[YOUR-PROJECT-REF].supabase.co:5432/postgres"
+SHADOW_DATABASE_URL="postgres://postgres:[YOUR-PASSWORD]@db.[YOUR-PROJECT-REF].supabase.co:5432/postgres_shadow"
```
In the `schema.prisma` file, change the `provider` from "sqlite" to `"postgresql"` and add the `shadowDatabaseUrl` property.
@@ -145,8 +145,8 @@ When migrating, you need to use the non-pooled connection URL (like the one used
```env
# .env
-DATABASE_URL="postgres://postgres:[YOUR-PASSWORD]@db.vdbnhqozmlzdsaejdxwr.supabase.co:6543/postgres?pgbouncer=true&connection_limit=1"
-SHADOW_DATABASE_URL="postgres://postgres:[YOUR-PASSWORD]@db.vdbnhqozmlzdsaejdxwr.supabase.co:5432/postgres_shadow"
+DATABASE_URL="postgres://postgres:[YOUR-PASSWORD]@db.[YOUR-PROJECT-REF].supabase.co:6543/postgres?pgbouncer=true&connection_limit=1"
+SHADOW_DATABASE_URL="postgres://postgres:[YOUR-PASSWORD]@db.[YOUR-PROJECT-REF].supabase.co:5432/postgres_shadow"
```
Prisma Migrate uses database transactions to check out the current state of the database and the migrations table. However, the Migration Engine is designed to use a single connection to the database, and does not support connection pooling with PgBouncer. If you attempt to run Prisma Migrate commands in any environment that uses PgBouncer for connection pooling, you might see the following error:
From b8d9ac0a2204e344d585cda7a4c1e988e11fde80 Mon Sep 17 00:00:00 2001
From: Lars Salling
Date: Sun, 15 Jan 2023 14:08:07 +0100
Subject: [PATCH 27/48] fix: link typo
---
apps/www/pages/realtime/Realtime.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/apps/www/pages/realtime/Realtime.tsx b/apps/www/pages/realtime/Realtime.tsx
index cc062d0bde4..890332c1478 100644
--- a/apps/www/pages/realtime/Realtime.tsx
+++ b/apps/www/pages/realtime/Realtime.tsx
@@ -238,7 +238,7 @@ function RealtimePage() {
,
]}
// [TODO] Point to the correct docs URL
- documentation_link={'/docs/guides//docs/guides/realtime/broadcast'}
+ documentation_link={'/docs/guides/realtime/broadcast'}
/>
From 502d9d51c72a82dfd0c2f5c36a2c9c39b4b14324 Mon Sep 17 00:00:00 2001
From: Lukas <69743171+quick007@users.noreply.github.com>
Date: Sun, 15 Jan 2023 16:54:16 -0800
Subject: [PATCH 28/48] Fix example so it works correctly
---
apps/docs/pages/guides/auth/auth-helpers/nextjs.mdx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/apps/docs/pages/guides/auth/auth-helpers/nextjs.mdx b/apps/docs/pages/guides/auth/auth-helpers/nextjs.mdx
index 8f5d318c151..9985e50fb92 100644
--- a/apps/docs/pages/guides/auth/auth-helpers/nextjs.mdx
+++ b/apps/docs/pages/guides/auth/auth-helpers/nextjs.mdx
@@ -584,7 +584,7 @@ export async function middleware(req: NextRequest) {
}
export const config = {
- matcher: '/middleware-protected',
+ matcher: '/middleware-protected/:path*',
}
```
From 17b0cc80d1c7a5e3872e24aada6defce93dd3c4d Mon Sep 17 00:00:00 2001
From: Inian
Date: Mon, 16 Jan 2023 11:59:47 +0800
Subject: [PATCH 29/48] update docs for storage getPublicURL
---
spec/enrichments/tsdoc_v2/combined.json | 2 +-
spec/enrichments/tsdoc_v2/storage.json | 2 +-
spec/enrichments/tsdoc_v2/storage_dereferenced.json | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/spec/enrichments/tsdoc_v2/combined.json b/spec/enrichments/tsdoc_v2/combined.json
index 0c72523e032..57242f4b5bf 100644
--- a/spec/enrichments/tsdoc_v2/combined.json
+++ b/spec/enrichments/tsdoc_v2/combined.json
@@ -79596,7 +79596,7 @@
"kindString": "Call signature",
"flags": {},
"comment": {
- "shortText": "Retrieves the URL for an asset in a public bucket.\nThis function does not verify if the bucket is public. If a public URL is created for a bucket which is not public, you will not be able to download the asset."
+ "shortText": "A simple convenience function to get the URL for an asset in a public bucket. If you do not want to use this function, you can construct the public URL by concatenating the bucket URL with the path to the asset.\nThis function does not verify if the bucket is public. If a public URL is created for a bucket which is not public, you will not be able to download the asset."
},
"parameters": [
{
diff --git a/spec/enrichments/tsdoc_v2/storage.json b/spec/enrichments/tsdoc_v2/storage.json
index 475ba699fc3..fb8baa1c895 100644
--- a/spec/enrichments/tsdoc_v2/storage.json
+++ b/spec/enrichments/tsdoc_v2/storage.json
@@ -5471,7 +5471,7 @@
"kindString": "Call signature",
"flags": {},
"comment": {
- "shortText": "Retrieves the URL for an asset in a public bucket.\nThis function does not verify if the bucket is public. If a public URL is created for a bucket which is not public, you will not be able to download the asset."
+ "shortText": "A simple convenience function to get the URL for an asset in a public bucket. If you do not want to use this function, you can construct the public URL by concatenating the bucket URL with the path to the asset.\nThis function does not verify if the bucket is public. If a public URL is created for a bucket which is not public, you will not be able to download the asset."
},
"parameters": [
{
diff --git a/spec/enrichments/tsdoc_v2/storage_dereferenced.json b/spec/enrichments/tsdoc_v2/storage_dereferenced.json
index 634dd23b469..53596ea9650 100644
--- a/spec/enrichments/tsdoc_v2/storage_dereferenced.json
+++ b/spec/enrichments/tsdoc_v2/storage_dereferenced.json
@@ -5875,7 +5875,7 @@
"kindString": "Call signature",
"flags": {},
"comment": {
- "shortText": "Retrieves the URL for an asset in a public bucket.\nThis function does not verify if the bucket is public. If a public URL is created for a bucket which is not public, you will not be able to download the asset."
+ "shortText": "A simple convenience function to get the URL for an asset in a public bucket. If you do not want to use this function, you can construct the public URL by concatenating the bucket URL with the path to the asset.\nThis function does not verify if the bucket is public. If a public URL is created for a bucket which is not public, you will not be able to download the asset."
},
"parameters": [
{
From 240453a854539bba59a089dde66603a2cd3b0cb7 Mon Sep 17 00:00:00 2001
From: Ollie Halliday <22655069+Hallidayo@users.noreply.github.com>
Date: Mon, 16 Jan 2023 09:46:08 +0000
Subject: [PATCH 30/48] changed order() example
---
spec/supabase_js_v2.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/spec/supabase_js_v2.yml b/spec/supabase_js_v2.yml
index 7e220e2dc23..0cd16c93dbd 100644
--- a/spec/supabase_js_v2.yml
+++ b/spec/supabase_js_v2.yml
@@ -3429,8 +3429,8 @@ functions:
code: |
```ts
const { data, error } = await supabase
- .from('cities')
- .select('name', 'country_id')
+ .from('countries')
+ .select('id', 'name')
.order('id', { ascending: false })
```
data:
From c68d82eff3ab9b086bec65c74f191233be6db531 Mon Sep 17 00:00:00 2001
From: Terry Sutton
Date: Mon, 16 Jan 2023 09:20:07 -0330
Subject: [PATCH 31/48] Update
studio/components/to-be-cleaned/Storage/StorageExplorer/PreviewPane.tsx
---
.../to-be-cleaned/Storage/StorageExplorer/PreviewPane.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/studio/components/to-be-cleaned/Storage/StorageExplorer/PreviewPane.tsx b/studio/components/to-be-cleaned/Storage/StorageExplorer/PreviewPane.tsx
index 855bd029827..a3abf1d1ec1 100644
--- a/studio/components/to-be-cleaned/Storage/StorageExplorer/PreviewPane.tsx
+++ b/studio/components/to-be-cleaned/Storage/StorageExplorer/PreviewPane.tsx
@@ -281,7 +281,7 @@ const PreviewPane = () => {
disabled={isSubmitting}
type="number"
id="expiresIn"
- label="Enter the duration for which the URL will be valid for"
+ label="Enter the duration for which the URL will be valid."
actions={