From 62454ff274dc9c745d682486ca671d1d9597a293 Mon Sep 17 00:00:00 2001 From: Ivan Vasilov Date: Tue, 7 Nov 2023 14:56:50 +0100 Subject: [PATCH 01/58] fix: Fix the Docker build for studio (#18753) * Fix the copying folder when building a Docker image of studio. * Fix the name for the realtime container. * chore: revert realtime container name --------- Co-authored-by: Han Qiao --- docker/docker-compose.yml | 1 + studio/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index b2bdec3260d96..467760742ba93 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -154,6 +154,7 @@ services: command: "postgrest" realtime: + # This container name looks inconsistent but is correct because realtime constructs tenant id by parsing the subdomain container_name: realtime-dev.supabase-realtime image: supabase/realtime:v2.10.1 depends_on: diff --git a/studio/Dockerfile b/studio/Dockerfile index 4da64dbbceff4..0f1ca272a6740 100644 --- a/studio/Dockerfile +++ b/studio/Dockerfile @@ -53,7 +53,7 @@ RUN npx turbo run build --scope=studio --include-dependencies --no-deps # Copy only compiled code and dependencies FROM base as production COPY --from=builder /app/studio/public ./studio/public -COPY --from=builder /app/studio/.next/standalone/app ./ +COPY --from=builder /app/studio/.next/standalone ./ COPY --from=builder /app/studio/.next/static ./studio/.next/static EXPOSE 3000 ENTRYPOINT ["docker-entrypoint.sh"] From 9fd5da39cd7aa1c043cfe8e268963f40f6ab85d8 Mon Sep 17 00:00:00 2001 From: Joshen Lim Date: Tue, 7 Nov 2023 22:16:20 +0800 Subject: [PATCH 02/58] Fix json side panel editor in table editor not updating properly (#18786) --- .../components/grid/components/editor/JsonEditor.tsx | 2 +- .../RowEditor/JsonEditor/JsonCodeEditor.tsx | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/studio/components/grid/components/editor/JsonEditor.tsx b/studio/components/grid/components/editor/JsonEditor.tsx index ce1211e7c01fd..7a4250b89fc1b 100644 --- a/studio/components/grid/components/editor/JsonEditor.tsx +++ b/studio/components/grid/components/editor/JsonEditor.tsx @@ -36,7 +36,7 @@ export const JsonEditor = ({ }, []) const saveChanges = useCallback((newValue: string | null) => { - commitChange(newValue) + if (newValue !== value) commitChange(newValue) }, []) const onChange = (_value: string | undefined) => { diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/JsonEditor/JsonCodeEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/JsonEditor/JsonCodeEditor.tsx index 0dfdda0a335cf..3b309e6fb18eb 100644 --- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/JsonEditor/JsonCodeEditor.tsx +++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/JsonEditor/JsonCodeEditor.tsx @@ -1,6 +1,7 @@ import Editor from '@monaco-editor/react' +import { uuidv4 } from 'lib/helpers' import { noop } from 'lodash' -import { useRef } from 'react' +import { useRef, useState, useEffect } from 'react' // [Joshen] Should just use CodeEditor instead of declaring Editor here so that all the mount logic is consistent @@ -12,12 +13,13 @@ interface JsonEditorProps { } const JsonEditor = ({ - queryId = '', + queryId, defaultValue = '', readOnly = false, onInputChange = noop, }: JsonEditorProps) => { const editorRef = useRef() + const [id, setId] = useState(uuidv4()) const onMount = (editor: any, monaco: any) => { editorRef.current = editor @@ -34,13 +36,17 @@ const JsonEditor = ({ const Loading = () =>

Loading

+ useEffect(() => { + setId(uuidv4()) + }, [defaultValue]) + return ( } options={{ readOnly, From 82967759400fccd96975759d989a5d1a092fdf12 Mon Sep 17 00:00:00 2001 From: Francesco Sansalvadore Date: Tue, 7 Nov 2023 15:19:55 +0100 Subject: [PATCH 03/58] Fix RowContextMenu bg (#18791) fix RowContextMenu bg --- studio/components/grid/components/menu/RowContextMenu.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/studio/components/grid/components/menu/RowContextMenu.tsx b/studio/components/grid/components/menu/RowContextMenu.tsx index 879181b81ef54..3bdde7454d332 100644 --- a/studio/components/grid/components/menu/RowContextMenu.tsx +++ b/studio/components/grid/components/menu/RowContextMenu.tsx @@ -60,7 +60,7 @@ const RowContextMenu = ({ rows }: RowContextMenuProps) => { return ( <> - + Copy cell content From 81dcc3bf69d03a96b251195241725e6d68f964bf Mon Sep 17 00:00:00 2001 From: AngelKaz Date: Tue, 7 Nov 2023 15:30:59 +0100 Subject: [PATCH 04/58] Update README.da.md (#18784) --- i18n/README.da.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/README.da.md b/i18n/README.da.md index f0100027ee8b6..298fecce71a0f 100644 --- a/i18n/README.da.md +++ b/i18n/README.da.md @@ -41,7 +41,7 @@ For at se, hvordan man bidrager, besøg [Getting Started](../DEVELOPERS.md) - [x] Alpha: Vi tester Supabase med et lukket sæt af kunder - [x] Offentlig Alpha: Alle kan tilmelde sig på [supabase.com/dashboard](https://supabase.com/dashboard). Men vær forsigtig med os, der er et par knuder - [x] Public Beta: Stabil nok til de fleste ikke-virksomhedsrelaterede brugssager -- [ ] Public: Public: Generel tilgængelighed [[status](https://supabase.com/docs/guides/getting-started/features#feature-status)] +- [ ] Public: Generel tilgængelighed [[status](https://supabase.com/docs/guides/getting-started/features#feature-status)] Vi er i øjeblikket i Public Beta. Hold øje med "releases" i denne repo for at få besked om større opdateringer. From 68a91f0381c32b6ad88e127a78724d1cbb9c8537 Mon Sep 17 00:00:00 2001 From: Yug Bhanushali Date: Tue, 7 Nov 2023 20:03:27 +0530 Subject: [PATCH 05/58] fixes quotes in search result (using cmdk) crashes the application (#18302) * fixed quotes in search result (using cmdk) crashes the application * fixed quotes in search result (using cmdk) crashes the application * fixes quotes in search result (using cmdk) crashes the application --- packages/ui/src/components/Command/DocsSearch.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/ui/src/components/Command/DocsSearch.tsx b/packages/ui/src/components/Command/DocsSearch.tsx index a3d11cddeb5c0..14223bea2ef63 100644 --- a/packages/ui/src/components/Command/DocsSearch.tsx +++ b/packages/ui/src/components/Command/DocsSearch.tsx @@ -49,6 +49,11 @@ export interface PageResult { sections: PageSection[] } +function removeDoubleQuotes(inputString: string): string { + // Use the replace method with a regular expression to remove double quotes + return inputString.replace(/"/g, '') +} + const getDocsUrl = () => { if (!process.env.NEXT_PUBLIC_SITE_URL || !process.env.NEXT_PUBLIC_LOCAL_SUPABASE) { return 'https://supabase.com/docs' @@ -171,7 +176,7 @@ const DocsSearch = () => { > { openLink(page.type, formatPageUrl(page)) @@ -202,7 +207,9 @@ const DocsSearch = () => { openLink(page.type, formatSectionUrl(page, section)) }} key={`${page.meta.title}__${section.heading}-item-index-${i}`} - value={`${page.meta.title}__${section.heading}-item-index-${i}`} + value={`${removeDoubleQuotes(page.meta.title)}__${removeDoubleQuotes( + section.heading ?? '' + )}-item-index-${i}`} type="block-link" >
From 68c0f467bc5b87222da22e4bcf666962091d39b5 Mon Sep 17 00:00:00 2001 From: Kiet Hung <110903974+jonshung@users.noreply.github.com> Date: Wed, 8 Nov 2023 00:13:48 +0700 Subject: [PATCH 06/58] docs: outdated reference to GraphQL and Realtime docs in root README (#18771) --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 88e63413c0542..629835eae3111 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ - [x] Hosted Postgres Database. [Docs](https://supabase.com/docs/guides/database) - [x] Authentication and Authorization. [Docs](https://supabase.com/docs/guides/auth) - [x] Auto-generated APIs. - - [x] REST. [Docs](https://supabase.com/docs/guides/api#rest-api-overview) - - [x] GraphQL. [Docs](https://supabase.com/docs/guides/api#graphql-api-overview) - - [x] Realtime subscriptions. [Docs](https://supabase.com/docs/guides/api#realtime-api-overview) + - [x] REST. [Docs](https://supabase.com/docs/guides/api) + - [x] GraphQL. [Docs](https://supabase.com/docs/guides/graphql) + - [x] Realtime subscriptions. [Docs](https://supabase.com/docs/guides/realtime) - [x] Functions. - [x] Database Functions. [Docs](https://supabase.com/docs/guides/database/functions) - [x] Edge Functions [Docs](https://supabase.com/docs/guides/functions) From fb4dc354934df05ed149f3d7fd5f008f6e093c1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Gr=C3=BCneberg?= Date: Tue, 7 Nov 2023 20:17:17 +0100 Subject: [PATCH 07/58] chore: use light mode of lottie (#18705) --- apps/www/components/LaunchWeek/7/Releases/index.tsx | 2 +- apps/www/package.json | 2 +- package-lock.json | 12 ++++++------ packages/ui/package.json | 2 +- packages/ui/src/components/LogoLoader/LogoLoader.tsx | 2 +- studio/components/ui/Loading/Loading.tsx | 2 +- studio/package.json | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/www/components/LaunchWeek/7/Releases/index.tsx b/apps/www/components/LaunchWeek/7/Releases/index.tsx index 6aeb2fad7125f..900b81f9eac04 100644 --- a/apps/www/components/LaunchWeek/7/Releases/index.tsx +++ b/apps/www/components/LaunchWeek/7/Releases/index.tsx @@ -1,7 +1,7 @@ import Image from 'next/image' import { useEffect } from 'react' import { Accordion } from 'ui' -import Lottie from 'lottie-react' +import Lottie from 'lottie-light-react' import days, { WeekDayProps, endOfLW7 } from '~/components/LaunchWeek/7/lw7_days' import SectionContainer from '~/components/Layouts/SectionContainer' diff --git a/apps/www/package.json b/apps/www/package.json index 0f5a86bab77c2..5776293b5c8fc 100644 --- a/apps/www/package.json +++ b/apps/www/package.json @@ -31,7 +31,7 @@ "framer-motion": "^6.5.1", "globby": "^13.2.2", "gray-matter": "^4.0.3", - "lottie-react": "^2.4.0", + "lottie-light-react": "^2.4.0", "markdown-toc": "^1.2.0", "next": "^13.5.3", "next-mdx-remote": "^4.4.1", diff --git a/package-lock.json b/package-lock.json index ac89918039938..dd2d67e1a0ee8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -281,7 +281,7 @@ "framer-motion": "^6.5.1", "globby": "^13.2.2", "gray-matter": "^4.0.3", - "lottie-react": "^2.4.0", + "lottie-light-react": "^2.4.0", "markdown-toc": "^1.2.0", "next": "^13.5.3", "next-mdx-remote": "^4.4.1", @@ -22102,10 +22102,10 @@ "loose-envify": "cli.js" } }, - "node_modules/lottie-react": { + "node_modules/lottie-light-react": { "version": "2.4.0", - "resolved": "https://registry.npmjs.org/lottie-react/-/lottie-react-2.4.0.tgz", - "integrity": "sha512-pDJGj+AQlnlyHvOHFK7vLdsDcvbuqvwPZdMlJ360wrzGFurXeKPr8SiRCjLf3LrNYKANQtSsh5dz9UYQHuqx4w==", + "resolved": "https://registry.npmjs.org/lottie-light-react/-/lottie-light-react-2.4.0.tgz", + "integrity": "sha512-TXJOnyqEc6ev9/um8Xkxve5EVcgCX2pi1olWc8jj+81qaPyFBA+VxHIc2Ojl42IqeAiKhGHz098ztQOIImJcyg==", "dependencies": { "lottie-web": "^5.10.2" }, @@ -36166,7 +36166,7 @@ "date-fns": "^2.30.0", "formik": "^2.2.9", "lodash": "^4.17.21", - "lottie-react": "^2.4.0", + "lottie-light-react": "^2.4.0", "lucide-react": "^0.167.0", "next-themes": "^0.2.1", "openai": "^3.3.0", @@ -37776,7 +37776,7 @@ "json-logic-js": "^2.0.2", "jsonrepair": "^3.2.3", "lodash": "^4.17.21", - "lottie-react": "^2.4.0", + "lottie-light-react": "^2.4.0", "lucide-react": "^0.167.0", "markdown-table": "=2.0.0", "mobx": "^6.10.2", diff --git a/packages/ui/package.json b/packages/ui/package.json index fac8bfc2f2104..70684a2414916 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -61,7 +61,7 @@ "date-fns": "^2.30.0", "formik": "^2.2.9", "lodash": "^4.17.21", - "lottie-react": "^2.4.0", + "lottie-light-react": "^2.4.0", "lucide-react": "^0.167.0", "next-themes": "^0.2.1", "openai": "^3.3.0", diff --git a/packages/ui/src/components/LogoLoader/LogoLoader.tsx b/packages/ui/src/components/LogoLoader/LogoLoader.tsx index 42fc397fbc94c..36646671d0bbd 100644 --- a/packages/ui/src/components/LogoLoader/LogoLoader.tsx +++ b/packages/ui/src/components/LogoLoader/LogoLoader.tsx @@ -1,4 +1,4 @@ -import Lottie from 'lottie-react' +import Lottie from 'lottie-light-react' import loadingAnim from './LogoLoader.anim.json' const LogoLoader = () => ( diff --git a/studio/components/ui/Loading/Loading.tsx b/studio/components/ui/Loading/Loading.tsx index f8a407c7c6a82..3b3b9ed6e517e 100644 --- a/studio/components/ui/Loading/Loading.tsx +++ b/studio/components/ui/Loading/Loading.tsx @@ -1,4 +1,4 @@ -import Lottie from 'lottie-react' +import Lottie from 'lottie-light-react' import loadingAnim from './Loading.anim.json' const Connecting = () => ( diff --git a/studio/package.json b/studio/package.json index bce7724b70ab9..31fb542bf9883 100644 --- a/studio/package.json +++ b/studio/package.json @@ -62,7 +62,7 @@ "json-logic-js": "^2.0.2", "jsonrepair": "^3.2.3", "lodash": "^4.17.21", - "lottie-react": "^2.4.0", + "lottie-light-react": "^2.4.0", "lucide-react": "^0.167.0", "markdown-table": "=2.0.0", "mobx": "^6.10.2", From 3b933e3b55758f02556329a7fa6bdd5bd03bbdd1 Mon Sep 17 00:00:00 2001 From: Jan Tennert Date: Tue, 7 Nov 2023 20:29:22 +0100 Subject: [PATCH 08/58] Fix Kotlin Realtime filter docs (#18728) Fix Realtime filter docs --- spec/supabase_kt_v0.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/supabase_kt_v0.yml b/spec/supabase_kt_v0.yml index def420d1d98b7..beb98ea7a3fee 100644 --- a/spec/supabase_kt_v0.yml +++ b/spec/supabase_kt_v0.yml @@ -3297,7 +3297,7 @@ functions: } val changeFlow = channel.postgresChangeFlow(schema = "public") { table = "users" - filter = "id.eq.1" + filter = "id=eq.1" } //in a new coroutine: From 1e7c27a27da72d575ab62742e1f555ab769e6f77 Mon Sep 17 00:00:00 2001 From: Ivan Vasilov Date: Tue, 7 Nov 2023 20:43:40 +0100 Subject: [PATCH 09/58] fix: Move dat.gui dependency to the common package (#18793) Remove dat.gui from docs and studio since it's not used directly. Add dat.gui as a dependency to common package. --- apps/docs/package.json | 1 - package-lock.json | 11 +++++------ packages/common/package.json | 2 ++ studio/package.json | 1 - 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/docs/package.json b/apps/docs/package.json index f46d37dc2d364..3890e74f69088 100644 --- a/apps/docs/package.json +++ b/apps/docs/package.json @@ -57,7 +57,6 @@ "@supabase/supabase-js": "^2.38.2", "common": "*", "config": "*", - "dat.gui": "^0.7.9", "framer-motion": "^6.5.1", "github-slugger": "^2.0.0", "gray-matter": "^4.0.3", diff --git a/package-lock.json b/package-lock.json index dd2d67e1a0ee8..fb6c5075f2b0f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -45,7 +45,6 @@ "@supabase/supabase-js": "^2.38.2", "common": "*", "config": "*", - "dat.gui": "^0.7.9", "framer-motion": "^6.5.1", "github-slugger": "^2.0.0", "gray-matter": "^4.0.3", @@ -9664,10 +9663,9 @@ } }, "node_modules/@types/dat.gui": { - "version": "0.7.10", - "resolved": "https://registry.npmjs.org/@types/dat.gui/-/dat.gui-0.7.10.tgz", - "integrity": "sha512-sLifoNrvs4lgJkAUZcTB28dbWy0AM05Yc0BzTqHheK0tRYRVsJHoFLocB5heDbb5amaFLEXna41GOM6IG06oqA==", - "dev": true + "version": "0.7.12", + "resolved": "https://registry.npmjs.org/@types/dat.gui/-/dat.gui-0.7.12.tgz", + "integrity": "sha512-el5dYeQZu2r6YW6Ft4rGtjr/dLe/uzXESMoie5UM6/weVShB1V8IRpXtTKrczd4qe7044fTKZS2l8d6EBFOkoA==" }, "node_modules/@types/debounce-promise": { "version": "3.1.7", @@ -35919,7 +35917,9 @@ "version": "0.0.0", "license": "MIT", "dependencies": { + "@types/dat.gui": "^0.7.12", "config": "*", + "dat.gui": "^0.7.9", "lodash": "^4.17.21", "next-themes": "^0.2.1", "react-hot-toast": "^2.4.1", @@ -37762,7 +37762,6 @@ "common-tags": "^1.8.2", "config": "*", "configcat-js": "^7.0.0", - "dat.gui": "^0.7.9", "dayjs": "^1.11.10", "eslint-config-next": "^13.3.0", "file-saver": "^2.0.5", diff --git a/packages/common/package.json b/packages/common/package.json index 0ae6ad43e3394..9b7ab361b0b0b 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -8,7 +8,9 @@ "typecheck_CURRENTLY_IGNORED": "tsc --noEmit" }, "dependencies": { + "@types/dat.gui": "^0.7.12", "config": "*", + "dat.gui": "^0.7.9", "lodash": "^4.17.21", "next-themes": "^0.2.1", "react-hot-toast": "^2.4.1", diff --git a/studio/package.json b/studio/package.json index 31fb542bf9883..04cddab4e5840 100644 --- a/studio/package.json +++ b/studio/package.json @@ -48,7 +48,6 @@ "common-tags": "^1.8.2", "config": "*", "configcat-js": "^7.0.0", - "dat.gui": "^0.7.9", "dayjs": "^1.11.10", "eslint-config-next": "^13.3.0", "file-saver": "^2.0.5", From 9cb33d2fd365ebbf99cee62efe6c7ca285263edf Mon Sep 17 00:00:00 2001 From: Charis <26616127+charislam@users.noreply.github.com> Date: Tue, 7 Nov 2023 14:50:12 -0500 Subject: [PATCH 10/58] remove deprecated file (#18794) `getComponents` file is no longer imported anywhere --- apps/docs/lib/mdx/getComponents.tsx | 39 ----------------------------- 1 file changed, 39 deletions(-) delete mode 100644 apps/docs/lib/mdx/getComponents.tsx diff --git a/apps/docs/lib/mdx/getComponents.tsx b/apps/docs/lib/mdx/getComponents.tsx deleted file mode 100644 index 07d9695f71224..0000000000000 --- a/apps/docs/lib/mdx/getComponents.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import Image from 'next/legacy/image' -import LinkCard from '~/components/LinkCard' -import LinkCardsWrapper from '~/components/LinkCardsWrapper' - -const ignoreClass = 'ignore-on-export' - -function getComponents(type: any) { - const components = { - LinkCardsWrapper: (props: any) => , - LinkCard: (props: any) => , - img: (props: any) => { - if (props.className !== ignoreClass) { - return ( -
- -
- ) - } - // eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text - return - }, - } - - return components -} - -export default getComponents From d5f037abd2fb58f5b289149a61e3a8d8f1f7fe6f Mon Sep 17 00:00:00 2001 From: Stojan Dimitrovski Date: Tue, 7 Nov 2023 22:32:32 +0100 Subject: [PATCH 11/58] docs: fix token refresh requests rate limit typo (#18801) --- apps/docs/pages/guides/platform/going-into-prod.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/docs/pages/guides/platform/going-into-prod.mdx b/apps/docs/pages/guides/platform/going-into-prod.mdx index 6c2f4974d0c51..eae61f7fd31fc 100644 --- a/apps/docs/pages/guides/platform/going-into-prod.mdx +++ b/apps/docs/pages/guides/platform/going-into-prod.mdx @@ -70,7 +70,7 @@ After developing your project and deciding it's Production Ready, you should run | Signup confirmation request | `/auth/v1/signup` | Last request | Defaults to 60 seconds window before a new request is allowed. Is customizable. | | Password Reset Request | `/auth/v1/recover` | Last request | Defaults to 60 seconds window before a new request is allowed. Is customizable. | | Verification requests | `/auth/v1/verify` | IP Address | 360 requests per hour (with bursts up to 30 requests) | -| Token refresh requests | `/auth/v1/token` | IP Address | 360 requests per hour (with bursts up to 30 requests) | +| Token refresh requests | `/auth/v1/token` | IP Address | 1800 requests per hour (with bursts up to 30 requests) | | Create or Verify an MFA challenge | `/auth/v1/factors/:id/challenge` `/auth/v1/factors/:id/verify` | IP Address | 15 requests per minute (with bursts up to 30 requests) | ### Realtime Quotas From 394b9844b613687e4d528fc5bfb674226876a284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Gr=C3=BCneberg?= Date: Tue, 7 Nov 2023 23:03:26 +0100 Subject: [PATCH 12/58] chore: cleanup deprecated project usage (#18659) --- .../interfaces/Home/ProjectUsageSection.tsx | 23 +-- .../Database/DiskSizeConfiguration.tsx | 6 +- studio/data/analytics/daily-stats-query.ts | 187 ------------------ .../analytics/functions-inv-stats-query.ts | 20 +- .../data/analytics/infra-monitoring-query.ts | 23 +-- studio/data/analytics/keys.ts | 3 + .../project-log-requests-count-query.ts | 56 ++++++ .../data/analytics/project-log-stats-query.ts | 15 +- studio/data/api.d.ts | 154 ++++++++++++++- .../custom-domains/custom-domains-query.ts | 15 +- .../organization-audit-logs-query.ts | 20 +- .../organization-detail-query.ts | 15 +- .../organizations/organization-roles-query.ts | 15 +- .../project-transfer-preview-query.ts | 19 +- studio/data/usage/project-usage-query.ts | 83 -------- .../pages/api/projects/[ref]/daily-stats.ts | 28 --- studio/pages/api/projects/[ref]/usage.ts | 22 --- studio/types/base.ts | 1 + 18 files changed, 224 insertions(+), 481 deletions(-) delete mode 100644 studio/data/analytics/daily-stats-query.ts create mode 100644 studio/data/analytics/project-log-requests-count-query.ts delete mode 100644 studio/data/usage/project-usage-query.ts delete mode 100644 studio/pages/api/projects/[ref]/daily-stats.ts delete mode 100644 studio/pages/api/projects/[ref]/usage.ts diff --git a/studio/components/interfaces/Home/ProjectUsageSection.tsx b/studio/components/interfaces/Home/ProjectUsageSection.tsx index 493de068e3f95..79b85b9fa4e87 100644 --- a/studio/components/interfaces/Home/ProjectUsageSection.tsx +++ b/studio/components/interfaces/Home/ProjectUsageSection.tsx @@ -4,20 +4,16 @@ import { IconAlertCircle, IconLoader } from 'ui' import { NewProjectPanel } from 'components/interfaces/Home' import InformationBox from 'components/ui/InformationBox' -import { ProjectUsageResponseUsageKeys, useProjectUsageQuery } from 'data/usage/project-usage-query' import ProjectUsage from './ProjectUsage' +import { useProjectLogRequestsCountQuery } from 'data/analytics/project-log-requests-count-query' const ProjectUsageSection = observer(() => { const { ref: projectRef } = useParams() - const { data: usage, error: usageError, isLoading } = useProjectUsageQuery({ projectRef }) - - const usageColumns = [ - 'db_egress', - 'storage_egress', - 'monthly_active_users', - 'realtime_message_count', - 'func_invocations', - ] + const { + data: usage, + error: usageError, + isLoading, + } = useProjectLogRequestsCountQuery({ projectRef }) if (usageError) { return ( @@ -30,11 +26,8 @@ const ProjectUsageSection = observer(() => { ) } - const hasProjectData = usage - ? usageColumns - .map((key) => usage[key as ProjectUsageResponseUsageKeys].usage) - .some((usage) => (usage ?? 0) > 0) - : false + const hasProjectData = + usage?.result && usage.result.length > 0 ? usage.result[0].count > 0 : false return ( <> diff --git a/studio/components/interfaces/Settings/Database/DiskSizeConfiguration.tsx b/studio/components/interfaces/Settings/Database/DiskSizeConfiguration.tsx index d40c42651b2c6..6c55eceb11bc0 100644 --- a/studio/components/interfaces/Settings/Database/DiskSizeConfiguration.tsx +++ b/studio/components/interfaces/Settings/Database/DiskSizeConfiguration.tsx @@ -11,7 +11,6 @@ import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectConte import { FormHeader } from 'components/ui/Forms' import Panel from 'components/ui/Panel' import { useProjectDiskResizeMutation } from 'data/config/project-disk-resize-mutation' -import { useProjectUsageQuery } from 'data/usage/project-usage-query' import { useCheckPermissions, useSelectedOrganization, useStore } from 'hooks' import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query' @@ -43,7 +42,6 @@ const DiskSizeConfiguration = ({ disabled = false }: DiskSizeConfigurationProps) }, }) - const { data: projectUsage } = useProjectUsageQuery({ projectRef }) const { data: projectSubscriptionData } = useOrgSubscriptionQuery({ orgSlug: organization?.slug }) const { mutate: updateProjectUsage, isLoading: isUpdatingDiskSize } = useProjectDiskResizeMutation({ @@ -62,7 +60,7 @@ const DiskSizeConfiguration = ({ disabled = false }: DiskSizeConfigurationProps) updateProjectUsage({ projectRef, volumeSize }) } - const currentDiskSize = projectUsage?.disk_volume_size_gb ?? 0 + const currentDiskSize = project?.volumeSizeGb ?? 0 // to do, update with max_disk_volume_size_gb const maxDiskSize = 200 @@ -87,7 +85,7 @@ const DiskSizeConfiguration = ({ disabled = false }: DiskSizeConfigurationProps)
- {projectUsage?.disk_volume_size_gb && ( + {currentDiskSize && ( Current Disk Storage Size: diff --git a/studio/data/analytics/daily-stats-query.ts b/studio/data/analytics/daily-stats-query.ts deleted file mode 100644 index 4e5050a14afce..0000000000000 --- a/studio/data/analytics/daily-stats-query.ts +++ /dev/null @@ -1,187 +0,0 @@ -import { useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query' -import dayjs from 'dayjs' -import { get } from 'lib/common/fetch' -import { API_URL } from 'lib/constants' -import { useCallback } from 'react' -import { AnalyticsData } from './constants' -import { analyticsKeys } from './keys' - -export type DailyStatsVariables = { - projectRef?: string - attribute: - | 'total_db_egress_bytes' - | 'total_db_size_bytes' - | 'total_egress_modified' - - // Realtime - | 'total_realtime_ingress' - | 'total_realtime_egress' - | 'total_realtime_message_count' - | 'total_realtime_peak_connection' - | 'total_realtime_requests' - | 'total_realtime_get_requests' - | 'total_realtime_post_requests' - | 'total_realtime_patch_requests' - | 'total_realtime_delete_requests' - | 'total_realtime_options_requests' - - // Rest - | 'total_rest_ingress' - | 'total_rest_egress' - | 'total_rest_requests' - | 'total_rest_get_requests' - | 'total_rest_post_requests' - | 'total_rest_patch_requests' - | 'total_rest_delete_requests' - | 'total_rest_options_requests' - - // Auth - | 'total_auth_billing_period_mau' - | 'total_auth_billing_period_sso_mau' - | 'total_auth_ingress' - | 'total_auth_egress' - | 'total_auth_texts' - | 'total_auth_users' - | 'total_auth_emails' - | 'total_auth_requests' - | 'total_auth_get_requests' - | 'total_auth_post_requests' - | 'total_auth_patch_requests' - | 'total_auth_delete_requests' - | 'total_auth_options_requests' - - // Storage - | 'total_storage_ingress' - | 'total_storage_egress' - | 'total_storage_size_bytes' - | 'total_storage_image_render_count' - | 'total_storage_requests' - | 'total_storage_get_requests' - | 'total_storage_post_requests' - | 'total_storage_patch_requests' - | 'total_storage_delete_requests' - | 'total_storage_options_requests' - - // Edge functions - | 'total_func_count' - | 'total_func_invocations' - | 'total_func_exec_time_ms' - | 'total_func_ingress' - | 'total_func_egress' - - // Combined - | 'total_ingress' - | 'total_egress' - | 'total_requests' - | 'total_get_requests' - | 'total_post_requests' - | 'total_patch_requests' - | 'total_delete_requests' - | 'total_options_requests' - startDate?: string - endDate?: string - interval?: string - dateFormat?: string - modifier?: (x: number) => number -} - -export async function getDailyStats( - { projectRef, attribute, startDate, endDate, interval = '1d' }: DailyStatsVariables, - signal?: AbortSignal -) { - if (!projectRef) throw new Error('Project ref is required') - if (!attribute) throw new Error('Attribute is required') - if (!startDate) throw new Error('Start date is required') - if (!endDate) throw new Error('Start date is required') - - const data = await get( - `${API_URL}/projects/${projectRef}/daily-stats?attribute=${attribute}&startDate=${encodeURIComponent( - startDate - )}&endDate=${encodeURIComponent(endDate)}&interval=${interval}`, - { signal } - ) - if (data.error) throw data.error - return data as AnalyticsData -} - -export type DailyStatsData = Awaited> -export type DailyStatsError = unknown - -export const useDailyStatsQuery = ( - { - projectRef, - attribute, - startDate, - endDate, - interval = '1d', - dateFormat = 'DD MMM', - modifier, - }: DailyStatsVariables, - { enabled = true, ...options }: UseQueryOptions = {} -) => - useQuery( - analyticsKeys.dailyStats(projectRef, { attribute, startDate, endDate, interval }), - ({ signal }) => getDailyStats({ projectRef, attribute, startDate, endDate, interval }, signal), - { - enabled: - enabled && - typeof projectRef !== 'undefined' && - typeof attribute !== 'undefined' && - typeof startDate !== 'undefined' && - typeof endDate !== 'undefined', - - select(data) { - const noDataYet = data.data[0]?.id === undefined - - // [Joshen] Ideally handled by API, like infra-monitoring - if (noDataYet) { - const days = dayjs(endDate).diff(dayjs(startDate), 'days') - const tempArray = new Array(days).fill(0) - const mockData = tempArray.map((x, idx) => { - return { - loopId: idx, - period_start: dayjs(startDate).add(idx, 'day').format('DD MMM YYYY'), - periodStartFormatted: dayjs(startDate).add(idx, 'day').format(dateFormat), - [attribute]: 0, - } - }) - return { ...data, data: mockData, hasNoData: true } as TData - } else { - return { - ...data, - hasNoData: false, - data: data.data.map((x) => { - return { - ...x, - [attribute]: - modifier !== undefined ? modifier(Number(x[attribute])) : Number(x[attribute]), - periodStartFormatted: dayjs(x.period_start).format(dateFormat), - } - }), - } as TData - } - }, - staleTime: 1000 * 60 * 60, // default good for an hour for now - ...options, - } - ) - -export const useDailyStatsPrefetch = ({ - projectRef, - attribute, - startDate, - endDate, - interval = '1d', -}: DailyStatsVariables) => { - const client = useQueryClient() - - return useCallback(() => { - if (projectRef && attribute && startDate && endDate && interval) { - client.prefetchQuery( - analyticsKeys.dailyStats(projectRef, { attribute, startDate, endDate, interval }), - ({ signal }) => - getDailyStats({ projectRef, attribute, startDate, endDate, interval }, signal) - ) - } - }, [projectRef]) -} diff --git a/studio/data/analytics/functions-inv-stats-query.ts b/studio/data/analytics/functions-inv-stats-query.ts index 5433a29ea1e22..b40713a2a0173 100644 --- a/studio/data/analytics/functions-inv-stats-query.ts +++ b/studio/data/analytics/functions-inv-stats-query.ts @@ -1,7 +1,6 @@ -import { useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query' +import { useQuery, UseQueryOptions } from '@tanstack/react-query' import { get } from 'lib/common/fetch' import { API_URL } from 'lib/constants' -import { useCallback } from 'react' import { analyticsKeys } from './keys' export type FunctionsInvStatsVariables = { @@ -61,20 +60,3 @@ export const useFunctionsInvStatsQuery = ( ...options, } ) - -export const useFunctionsInvStatsPrefetch = ({ - projectRef, - functionId, - interval, -}: FunctionsInvStatsVariables) => { - const client = useQueryClient() - - return useCallback(() => { - if (projectRef && functionId && interval) { - client.prefetchQuery( - analyticsKeys.functionsInvStats(projectRef, { functionId, interval }), - ({ signal }) => getFunctionsInvStats({ projectRef, functionId, interval }, signal) - ) - } - }, [projectRef, functionId, interval]) -} diff --git a/studio/data/analytics/infra-monitoring-query.ts b/studio/data/analytics/infra-monitoring-query.ts index 1783de01939ca..6f8101451af32 100644 --- a/studio/data/analytics/infra-monitoring-query.ts +++ b/studio/data/analytics/infra-monitoring-query.ts @@ -1,8 +1,7 @@ -import { useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query' +import { useQuery, UseQueryOptions } from '@tanstack/react-query' import dayjs from 'dayjs' import { get } from 'lib/common/fetch' import { API_URL } from 'lib/constants' -import { useCallback } from 'react' import { AnalyticsData } from './constants' import { analyticsKeys } from './keys' @@ -88,23 +87,3 @@ export const useInfraMonitoringQuery = ( ...options, } ) - -export const useInfraMonitoringPrefetch = ({ - projectRef, - attribute, - startDate, - endDate, - interval = '1d', -}: InfraMonitoringVariables) => { - const client = useQueryClient() - - return useCallback(() => { - if (projectRef && attribute && startDate && endDate && interval) { - client.prefetchQuery( - analyticsKeys.infraMonitoring(projectRef, { attribute, startDate, endDate, interval }), - ({ signal }) => - getInfraMonitoring({ projectRef, attribute, startDate, endDate, interval }, signal) - ) - } - }, [projectRef]) -} diff --git a/studio/data/analytics/keys.ts b/studio/data/analytics/keys.ts index e05ca869d93ad..41029a404ffd7 100644 --- a/studio/data/analytics/keys.ts +++ b/studio/data/analytics/keys.ts @@ -68,6 +68,9 @@ export const analyticsKeys = { ] as const, usageApiCounts: (projectRef: string | undefined, interval: string | undefined) => ['projects', projectRef, 'usage.api-counts', interval] as const, + + usageApiRequestsCount: (projectRef: string | undefined) => + ['projects', projectRef, 'usage.api-requests-count'] as const, } function isoDateStringToDate(isoDateString: string | undefined): string | undefined { diff --git a/studio/data/analytics/project-log-requests-count-query.ts b/studio/data/analytics/project-log-requests-count-query.ts new file mode 100644 index 0000000000000..dd092593fc123 --- /dev/null +++ b/studio/data/analytics/project-log-requests-count-query.ts @@ -0,0 +1,56 @@ +import { useQuery, UseQueryOptions } from '@tanstack/react-query' +import { get } from 'data/fetchers' +import { analyticsKeys } from './keys' +import { ResponseError } from 'types' + +export type ProjectLogRequestsCountVariables = { + projectRef?: string +} + +export async function getProjectLogRequestsCountStats( + { projectRef }: ProjectLogRequestsCountVariables, + signal?: AbortSignal +) { + if (!projectRef) { + throw new Error('projectRef is required') + } + + const { data, error } = await get( + '/platform/projects/{ref}/analytics/endpoints/usage.api-requests-count', + { + params: { + path: { + ref: projectRef, + }, + }, + signal, + } + ) + + if (error) { + throw error + } + + return data +} + +export type ProjectLogRequestsCountData = Awaited< + ReturnType +> +export type ProjectLogRequestsCountError = ResponseError + +export const useProjectLogRequestsCountQuery = ( + { projectRef }: ProjectLogRequestsCountVariables, + { + enabled = true, + ...options + }: UseQueryOptions = {} +) => + useQuery( + analyticsKeys.usageApiRequestsCount(projectRef), + ({ signal }) => getProjectLogRequestsCountStats({ projectRef }, signal), + { + enabled: enabled && typeof projectRef !== 'undefined', + ...options, + } + ) diff --git a/studio/data/analytics/project-log-stats-query.ts b/studio/data/analytics/project-log-stats-query.ts index 015ff60cb8629..d29c1dce999e7 100644 --- a/studio/data/analytics/project-log-stats-query.ts +++ b/studio/data/analytics/project-log-stats-query.ts @@ -1,7 +1,6 @@ -import { useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query' +import { useQuery, UseQueryOptions } from '@tanstack/react-query' import { get, isResponseOk } from 'lib/common/fetch' import { API_URL } from 'lib/constants' -import { useCallback } from 'react' import { analyticsKeys } from './keys' export type ProjectLogStatsVariables = { @@ -62,15 +61,3 @@ export const useProjectLogStatsQuery = ( ...options, } ) - -export const useProjectLogStatsPrefetch = ({ projectRef, interval }: ProjectLogStatsVariables) => { - const client = useQueryClient() - - return useCallback(() => { - if (projectRef && interval) { - client.prefetchQuery(analyticsKeys.usageApiCounts(projectRef, interval), ({ signal }) => - getProjectLogStats({ projectRef, interval }, signal) - ) - } - }, [projectRef, interval]) -} diff --git a/studio/data/api.d.ts b/studio/data/api.d.ts index 4d217ede2400a..82697fa9173d8 100644 --- a/studio/data/api.d.ts +++ b/studio/data/api.d.ts @@ -52,6 +52,10 @@ export interface paths { */ get: operations['ProjectsResourceWarningsController_getProjectsResourceWarnings'] } + '/platform/tos/fly': { + /** Redirects to Fly sso flow */ + get: operations['TermsOfServiceController_flyTosAccepted'] + } '/platform/auth/{ref}/config': { /** Gets GoTrue config */ get: operations['GoTrueConfigController_getGoTrueConfig'] @@ -549,6 +553,10 @@ export interface paths { /** Gets project's usage api counts */ get: operations['UsageApiController_getApiCounts'] } + '/platform/projects/{ref}/analytics/endpoints/usage.api-requests-count': { + /** Gets project's usage api requests count */ + get: operations['UsageApiController_getApiRequestsCount'] + } '/platform/projects/{ref}/config/pgbouncer': { /** Gets project's pgbouncer config */ get: operations['PgbouncerConfigController_getPgbouncerConfig'] @@ -792,6 +800,10 @@ export interface paths { /** Gets a specific github branch for a given repo */ get: operations['GitHubBranchController_getBranchByName'] } + '/platform/integrations/github/pull-requests/{organization_integration_id}/{repo_owner}/{repo_name}': { + /** Gets github pull requests for a given repo */ + get: operations['GitHubPullRequestController_getPullRequestsByNumber'] + } '/platform/integrations/github/pull-requests/{organization_integration_id}/{repo_owner}/{repo_name}/{target}': { /** Gets github pull requests for a given repo */ get: operations['GitHubPullRequestController_getPullRequests'] @@ -1281,6 +1293,10 @@ export interface paths { /** Gets project's usage api counts */ get: operations['UsageApiController_getApiCounts'] } + '/v0/projects/{ref}/analytics/endpoints/usage.api-requests-count': { + /** Gets project's usage api requests count */ + get: operations['UsageApiController_getApiRequestsCount'] + } '/v0/projects/{ref}/config/pgbouncer': { /** Gets project's pgbouncer config */ get: operations['PgbouncerConfigController_getPgbouncerConfig'] @@ -1655,7 +1671,7 @@ export interface paths { get: operations['SnippetsController_getSnippet'] } '/partners/flyio/callback': { - /** Redirects to Supabase dashboard after Fly sso with Gotrue */ + /** Redirects to Supabase dashboard after completing Fly sso */ get: operations['CallbackController_redirectToDashboardFlyioExtensionScreen'] } '/partners/flyio/extensions/{extension_id}': { @@ -1665,7 +1681,7 @@ export interface paths { delete: operations['ExtensionController_deleteResource'] } '/partners/flyio/extensions/{extension_id}/sso': { - /** Starts Flyio single sign on */ + /** Starts Fly single sign on */ get: operations['ExtensionController_startFlyioSSO'] } '/partners/flyio/extensions/{extension_id}/billing': { @@ -1676,6 +1692,14 @@ export interface paths { /** Creates a database */ post: operations['ExtensionsController_provisionResource'] } + '/partners/flyio/organizations/{organization_id}/extensions': { + /** Gets all databases that belong to the Fly organization */ + get: operations['OrganizationsController_getOrgExtensions'] + } + '/partners/flyio/organizations/{organization_id}/sso': { + /** Starts Fly single sign on */ + get: operations['OrganizationsController_startFlyioSSO'] + } } export type webhooks = Record @@ -3295,11 +3319,11 @@ export interface components { | 'project_storage:all' | 'project_edge_function:all' | 'profile:update' - | 'billing:all' | 'billing:account_data' | 'billing:credits' | 'billing:invoices' | 'billing:payment_methods' + | 'realtime:all' )[] } UpdateProfileBody: { @@ -4164,7 +4188,7 @@ export interface components { GitRef: { repo: string branch: string - label: string + label?: string } GetGithubPullRequest: { id: number @@ -4175,7 +4199,7 @@ export interface components { created_by?: string repo: string branch: string - label: string + label?: string } FunctionResponse: { id: string @@ -4404,6 +4428,9 @@ export interface components { UpgradeDatabaseBody: { target_version: number } + ProjectUpgradeInitiateResponse: { + tracking_id: string + } ProjectVersion: { postgres_version: number app_version: string @@ -4785,6 +4812,29 @@ export interface components { /** @description Welcome message */ message: string } + OrganizationExtensionStatus: { + /** @description Supabase project instance compute size */ + compute: string + /** @description Unique ID representing the fly extension */ + id: string + /** + * @description Supabase project status + * @example ACTIVE_HEALTHY + * @enum {string} + */ + status: + | 'REMOVED' + | 'COMING_UP' + | 'INACTIVE' + | 'ACTIVE_HEALTHY' + | 'ACTIVE_UNHEALTHY' + | 'UNKNOWN' + | 'GOING_DOWN' + | 'INIT_FAILED' + | 'RESTORING' + | 'UPGRADING' + | 'PAUSING' + } } responses: never parameters: never @@ -4960,6 +5010,20 @@ export interface operations { } } } + /** Redirects to Fly sso flow */ + TermsOfServiceController_flyTosAccepted: { + parameters: { + query: { + extension_id: string + organization_id: string + } + } + responses: { + 200: { + content: never + } + } + } /** Gets GoTrue config */ GoTrueConfigController_getGoTrueConfig: { parameters: { @@ -8778,6 +8842,26 @@ export interface operations { } } } + /** Gets project's usage api requests count */ + UsageApiController_getApiRequestsCount: { + parameters: { + path: { + /** @description Project ref */ + ref: string + } + } + responses: { + 200: { + content: { + 'application/json': components['schemas']['AnalyticsResponse'] + } + } + /** @description Failed to get project's usage api requests count */ + 500: { + content: never + } + } + } /** Gets project's pgbouncer config */ PgbouncerConfigController_getPgbouncerConfig: { parameters: { @@ -10130,6 +10214,30 @@ export interface operations { } } /** Gets github pull requests for a given repo */ + GitHubPullRequestController_getPullRequestsByNumber: { + parameters: { + query: { + pr_number: number + } + path: { + organization_integration_id: string + repo_owner: string + repo_name: string + } + } + responses: { + 200: { + content: { + 'application/json': components['schemas']['GetGithubPullRequest'][] + } + } + /** @description Failed to get github pull requests for a given repo */ + 500: { + content: never + } + } + } + /** Gets github pull requests for a given repo */ GitHubPullRequestController_getPullRequests: { parameters: { query?: { @@ -11477,7 +11585,9 @@ export interface operations { } responses: { 201: { - content: never + content: { + 'application/json': components['schemas']['ProjectUpgradeInitiateResponse'] + } } 403: { content: never @@ -12137,7 +12247,7 @@ export interface operations { } } } - /** Redirects to Supabase dashboard after Fly sso with Gotrue */ + /** Redirects to Supabase dashboard after completing Fly sso */ CallbackController_redirectToDashboardFlyioExtensionScreen: { responses: { 200: { @@ -12173,7 +12283,7 @@ export interface operations { } } } - /** Starts Flyio single sign on */ + /** Starts Fly single sign on */ ExtensionController_startFlyioSSO: { parameters: { path: { @@ -12216,4 +12326,32 @@ export interface operations { } } } + /** Gets all databases that belong to the Fly organization */ + OrganizationsController_getOrgExtensions: { + parameters: { + path: { + organization_id: string + } + } + responses: { + 200: { + content: { + 'application/json': components['schemas']['OrganizationExtensionStatus'][] + } + } + } + } + /** Starts Fly single sign on */ + OrganizationsController_startFlyioSSO: { + parameters: { + path: { + organization_id: string + } + } + responses: { + 200: { + content: never + } + } + } } diff --git a/studio/data/custom-domains/custom-domains-query.ts b/studio/data/custom-domains/custom-domains-query.ts index 1bcaf87758691..05e43eea7ad9a 100644 --- a/studio/data/custom-domains/custom-domains-query.ts +++ b/studio/data/custom-domains/custom-domains-query.ts @@ -1,5 +1,4 @@ -import { useCallback } from 'react' -import { useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query' +import { useQuery, UseQueryOptions } from '@tanstack/react-query' import { get } from 'lib/common/fetch' import { API_ADMIN_URL, IS_PLATFORM } from 'lib/constants' @@ -135,15 +134,3 @@ export const useCustomDomainsQuery = ( ({ signal }) => getCustomDomains({ projectRef }, signal), { enabled: enabled && IS_PLATFORM && typeof projectRef !== 'undefined', ...options } ) - -export const useCustomDomainsPrefetch = ({ projectRef }: CustomDomainsVariables) => { - const client = useQueryClient() - - return useCallback(() => { - if (projectRef) { - client.prefetchQuery(customDomainKeys.list(projectRef), ({ signal }) => - getCustomDomains({ projectRef }, signal) - ) - } - }, [projectRef]) -} diff --git a/studio/data/organizations/organization-audit-logs-query.ts b/studio/data/organizations/organization-audit-logs-query.ts index 8da3d9c1c44f6..269419e97bde9 100644 --- a/studio/data/organizations/organization-audit-logs-query.ts +++ b/studio/data/organizations/organization-audit-logs-query.ts @@ -1,6 +1,5 @@ -import { useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query' +import { useQuery, UseQueryOptions } from '@tanstack/react-query' import dayjs from 'dayjs' -import { useCallback } from 'react' import { get } from 'lib/common/fetch' import { API_URL } from 'lib/constants' @@ -81,20 +80,3 @@ export const useOrganizationAuditLogsQuery = } ) } - -export const useOrganizationAuditLogsPrefetch = (vars: OrganizationAuditLogsVariables) => { - const { slug, iso_timestamp_start, iso_timestamp_end } = vars - const client = useQueryClient() - - return useCallback(() => { - if (slug) { - const date_start = dayjs(iso_timestamp_start).utc().format('YYYY-MM-DD') - const date_end = dayjs(iso_timestamp_end).utc().format('YYYY-MM-DD') - client.prefetchQuery( - organizationKeys.auditLogs(slug, { date_start, date_end }), - ({ signal }) => getOrganizationAuditLogs(vars, signal) - ) - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [client, vars]) -} diff --git a/studio/data/organizations/organization-detail-query.ts b/studio/data/organizations/organization-detail-query.ts index f07aa19e74ddb..3fddeb74dfbf2 100644 --- a/studio/data/organizations/organization-detail-query.ts +++ b/studio/data/organizations/organization-detail-query.ts @@ -1,7 +1,6 @@ -import { useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query' +import { useQuery, UseQueryOptions } from '@tanstack/react-query' import { get } from 'lib/common/fetch' import { API_URL } from 'lib/constants' -import { useCallback } from 'react' import { Member, ResponseError } from 'types' import { organizationKeys } from './keys' @@ -73,15 +72,3 @@ export const useOrganizationDetailQuery = ( ...options, } ) - -export const useOrganizationDetailPrefetch = ({ slug }: OrganizationDetailVariables) => { - const client = useQueryClient() - - return useCallback(() => { - if (slug) { - client.prefetchQuery(organizationKeys.detail(slug), ({ signal }) => - getOrganizationDetail({ slug }, signal) - ) - } - }, [slug]) -} diff --git a/studio/data/organizations/organization-roles-query.ts b/studio/data/organizations/organization-roles-query.ts index 699eef8cd899f..5079dcb0f4b50 100644 --- a/studio/data/organizations/organization-roles-query.ts +++ b/studio/data/organizations/organization-roles-query.ts @@ -1,7 +1,6 @@ -import { useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query' +import { useQuery, UseQueryOptions } from '@tanstack/react-query' import { get } from 'lib/common/fetch' import { API_URL } from 'lib/constants' -import { useCallback } from 'react' import { ResponseError, Role } from 'types' import { organizationKeys } from './keys' @@ -49,15 +48,3 @@ export const useOrganizationRolesQuery = ( ...options, } ) - -export const useOrganizationRolesPrefetch = ({ slug }: OrganizationRolesVariables) => { - const client = useQueryClient() - - return useCallback(() => { - if (slug) { - client.prefetchQuery(organizationKeys.roles(slug), ({ signal }) => - getOrganizationRoles({ slug }, signal) - ) - } - }, [slug]) -} diff --git a/studio/data/projects/project-transfer-preview-query.ts b/studio/data/projects/project-transfer-preview-query.ts index a5edae66caf52..08bab5b916b56 100644 --- a/studio/data/projects/project-transfer-preview-query.ts +++ b/studio/data/projects/project-transfer-preview-query.ts @@ -1,7 +1,6 @@ -import { useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query' +import { useQuery, UseQueryOptions } from '@tanstack/react-query' import { post } from 'lib/common/fetch' import { API_URL } from 'lib/constants' -import { useCallback } from 'react' import { projectKeys } from './keys' export type ProjectTransferPreviewVariables = { @@ -105,19 +104,3 @@ export const useProjectTransferPreviewQuery = { - const client = useQueryClient() - - return useCallback(() => { - if (projectRef && targetOrganizationSlug) { - client.prefetchQuery( - projectKeys.projectTransferPreview(projectRef, targetOrganizationSlug), - ({ signal }) => previewProjectTransfer({ projectRef, targetOrganizationSlug }, signal) - ) - } - }, [projectRef, targetOrganizationSlug]) -} diff --git a/studio/data/usage/project-usage-query.ts b/studio/data/usage/project-usage-query.ts deleted file mode 100644 index bc1e7a1ce19e7..0000000000000 --- a/studio/data/usage/project-usage-query.ts +++ /dev/null @@ -1,83 +0,0 @@ -import { useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query' -import { get } from 'lib/common/fetch' -import { API_URL } from 'lib/constants' -import { useCallback } from 'react' -import { usageKeys } from './keys' - -export type ProjectUsageVariables = { - projectRef?: string -} - -export interface UsageMetric { - usage: number - limit: number - cost: number - available_in_plan: boolean - // [Joshen] can we verify if this is still getting passed? - // Only for database and storage size - current?: number -} - -export type ProjectUsageResponse = { - db_size: UsageMetric - db_egress: UsageMetric - storage_size: UsageMetric - storage_egress: UsageMetric - storage_image_render_count: UsageMetric - monthly_active_users: UsageMetric - monthly_active_sso_users: UsageMetric - realtime_message_count: UsageMetric - realtime_peak_connection: UsageMetric - func_count: UsageMetric - func_invocations: UsageMetric - disk_volume_size_gb: number -} - -export type ProjectUsageResponseUsageKeys = keyof Omit - -export async function getProjectUsage({ projectRef }: ProjectUsageVariables, signal?: AbortSignal) { - if (!projectRef) { - throw new Error('projectRef is required') - } - - const response = await get(`${API_URL}/projects/${projectRef}/usage`, { - signal, - }) - if (response.error) { - throw response.error - } - - return response as ProjectUsageResponse -} - -export type ProjectUsageData = Awaited> -export type ProjectUsageError = unknown - -export const useProjectUsageQuery = ( - { projectRef }: ProjectUsageVariables, - { enabled = true, ...options }: UseQueryOptions = {} -) => - useQuery( - usageKeys.usage(projectRef), - ({ signal }) => getProjectUsage({ projectRef }, signal), - { - enabled: enabled && typeof projectRef !== 'undefined', - select(data) { - return Object.fromEntries( - Object.entries(data).map(([key, value]) => { - if (typeof value === 'object') { - const formattedValue = { - ...value, - usage: Number(value.usage), - } - - return [key, formattedValue] - } else { - return [key, value] - } - }) - ) - }, - ...options, - } - ) diff --git a/studio/pages/api/projects/[ref]/daily-stats.ts b/studio/pages/api/projects/[ref]/daily-stats.ts deleted file mode 100644 index 35523e117a2d4..0000000000000 --- a/studio/pages/api/projects/[ref]/daily-stats.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { NextApiRequest, NextApiResponse } from 'next' -import apiWrapper from 'lib/api/apiWrapper' - -export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler) - -async function handler(req: NextApiRequest, res: NextApiResponse) { - const { method } = req - - switch (method) { - case 'GET': - return handleGetAll(req, res) - default: - res.setHeader('Allow', ['GET']) - res.status(405).json({ data: null, error: { message: `Method ${method} Not Allowed` } }) - } -} - -const handleGetAll = async (req: NextApiRequest, res: NextApiResponse) => { - // Platform specific endpoint - const response = { - data: [], - yAxisLimit: 0, - format: '%', - totalAverage: 0, - total: 0, - } - return res.status(200).json(response) -} diff --git a/studio/pages/api/projects/[ref]/usage.ts b/studio/pages/api/projects/[ref]/usage.ts deleted file mode 100644 index 107a5ace54104..0000000000000 --- a/studio/pages/api/projects/[ref]/usage.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { NextApiRequest, NextApiResponse } from 'next' -import apiWrapper from 'lib/api/apiWrapper' - -export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler) - -async function handler(req: NextApiRequest, res: NextApiResponse) { - const { method } = req - - switch (method) { - case 'GET': - return handleGetAll(req, res) - default: - res.setHeader('Allow', ['GET']) - res.status(405).json({ data: null, error: { message: `Method ${method} Not Allowed` } }) - } -} - -const handleGetAll = async (req: NextApiRequest, res: NextApiResponse) => { - return res - .status(200) - .json({ dbSize: '888888', authUsers: '0', bucketSize: '888888', dbTables: '0' }) -} diff --git a/studio/types/base.ts b/studio/types/base.ts index aa9df3e7e2820..c28d6f76565b2 100644 --- a/studio/types/base.ts +++ b/studio/types/base.ts @@ -48,6 +48,7 @@ export interface Project extends ProjectBase { * irregardless of being on any branch, such as ProjectDropdown and Vercel integration * */ parentRef?: string + volumeSizeGb?: number } export interface User { From 46610352eb00a8eeb831af06de1defbfd199a6f5 Mon Sep 17 00:00:00 2001 From: Francesco Sansalvadore Date: Wed, 8 Nov 2023 05:05:09 +0100 Subject: [PATCH 13/58] Fix react-contexify styling (#18802) * fix storage popover bg * fix react-contexify bgs * fix react-contexify styling * fix react-contexify styling * fix react-contexify styling * fix react-contexify styling --- .../components/grid/components/menu/RowContextMenu.tsx | 2 +- studio/styles/contextMenu.scss | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/studio/components/grid/components/menu/RowContextMenu.tsx b/studio/components/grid/components/menu/RowContextMenu.tsx index 3bdde7454d332..879181b81ef54 100644 --- a/studio/components/grid/components/menu/RowContextMenu.tsx +++ b/studio/components/grid/components/menu/RowContextMenu.tsx @@ -60,7 +60,7 @@ const RowContextMenu = ({ rows }: RowContextMenuProps) => { return ( <> - + Copy cell content diff --git a/studio/styles/contextMenu.scss b/studio/styles/contextMenu.scss index 9608d8dc8e569..04c8581f197d5 100644 --- a/studio/styles/contextMenu.scss +++ b/studio/styles/contextMenu.scss @@ -1,8 +1,10 @@ .react-contexify { - @apply bg-surface-100 border border-default; + @apply border border-default; + background-color: hsl(var(--background-surface-100)) !important; + .react-contexify__item { .react-contexify__item__content { - @apply dark:text-white text-sm; + @apply text-foreground text-sm; } .react-contexify__submenu { @apply bg-surface-100 border; @@ -12,9 +14,9 @@ > .react-contexify__item__content, .react-contexify__item:not(.react-contexify__item--disabled):focus > .react-contexify__item__content { - @apply dark:bg-overlay-hover; + @apply bg-overlay-hover; } .react-contexify__separator { - @apply dark:bg-overlay; + @apply bg-overlay; } } From 51106a2a1864cde1f67b3dfa0d35a8b0f65b66b6 Mon Sep 17 00:00:00 2001 From: Terry Sutton Date: Wed, 8 Nov 2023 02:44:00 -0330 Subject: [PATCH 14/58] Chore/link to docs redirect urls (#18799) * Link to docs from redirect urls settings * tooltip trigger asChild --------- Co-authored-by: Alaister Young --- .../Auth/RedirectUrls/RedirectUrls.tsx | 61 +++++++++++-------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/studio/components/interfaces/Auth/RedirectUrls/RedirectUrls.tsx b/studio/components/interfaces/Auth/RedirectUrls/RedirectUrls.tsx index 84c75908c48bc..a412b17085ee9 100644 --- a/studio/components/interfaces/Auth/RedirectUrls/RedirectUrls.tsx +++ b/studio/components/interfaces/Auth/RedirectUrls/RedirectUrls.tsx @@ -9,6 +9,7 @@ import { Button, Form, IconAlertCircle, + IconExternalLink, Input, Modal, } from 'ui' @@ -23,6 +24,7 @@ import { useCheckPermissions, useStore } from 'hooks' import { urlRegex } from '../Auth.constants' import RedirectUrlList from './RedirectUrlList' import ValueContainer from './ValueContainer' +import Link from 'next/link' const RedirectUrls = () => { const { ui } = useStore() @@ -119,30 +121,41 @@ const RedirectUrls = () => { title="Redirect URLs" description={`URLs that auth providers are permitted to redirect to post authentication. Wildcards are allowed, for example, https://*.domain.com`} /> - - - - - {!canUpdateConfig && ( - - - -
- - You need additional permissions to update redirect URLs - -
-
-
- )} -
+
+ + + + + + {!canUpdateConfig && ( + + + +
+ + You need additional permissions to update redirect URLs + +
+
+
+ )} +
+
{isLoading && ( <> From c83e165b6e81e0830bf6b5ed1f901b044dfc9d02 Mon Sep 17 00:00:00 2001 From: Joel Lee Date: Wed, 8 Nov 2023 18:09:20 +0800 Subject: [PATCH 15/58] chore: update pgtap.mdx (#18813) Update pgtap.mdx --- apps/docs/pages/guides/database/extensions/pgtap.mdx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/docs/pages/guides/database/extensions/pgtap.mdx b/apps/docs/pages/guides/database/extensions/pgtap.mdx index 435d2ed8e3318..acf5ef9f19542 100644 --- a/apps/docs/pages/guides/database/extensions/pgtap.mdx +++ b/apps/docs/pages/guides/database/extensions/pgtap.mdx @@ -135,12 +135,14 @@ API: ## Testing Functions ```sql -begin; -select plan( 1 ); +prepare hello_expr as select 'hello' -select function_returns( 'hello_world', 'text' ); # test if the function "hello_world" returns text -select function_returns( 'is_even', ARRAY['integer'], 'boolean' ); # test if the function "is_even" returns a boolean -select results_eq('select * from hello_world()', 'hello'); # test if the function "hello_world" returns "hello" +begin; +select plan(3); +-- You'll need to create a hello_world and is_even function +select function_returns( 'hello_world', 'text' ); -- test if the function "hello_world" returns text +select function_returns( 'is_even', ARRAY['integer'], 'boolean' ); -- test if the function "is_even" returns a boolean +select results_eq('select * from hello_world()', 'hello_expr'); -- test if the function "hello_world" returns "hello" select * from finish(); rollback; From 8e1204101dd312cea27d9f3294db9d65df59b443 Mon Sep 17 00:00:00 2001 From: Francesco Sansalvadore Date: Wed, 8 Nov 2023 11:24:23 +0100 Subject: [PATCH 16/58] Fix react-contexify light (#18812) * fix react-contexify light hover styling * fix react-contexify light hover styling --- studio/styles/contextMenu.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/studio/styles/contextMenu.scss b/studio/styles/contextMenu.scss index 04c8581f197d5..76d63f0e2e53d 100644 --- a/studio/styles/contextMenu.scss +++ b/studio/styles/contextMenu.scss @@ -4,7 +4,7 @@ .react-contexify__item { .react-contexify__item__content { - @apply text-foreground text-sm; + @apply text-foreground-light text-sm; } .react-contexify__submenu { @apply bg-surface-100 border; @@ -14,7 +14,7 @@ > .react-contexify__item__content, .react-contexify__item:not(.react-contexify__item--disabled):focus > .react-contexify__item__content { - @apply bg-overlay-hover; + @apply bg-overlay-hover text-foreground; } .react-contexify__separator { @apply bg-overlay; From cb0a464575f9531716912d1760c547e5577cbc92 Mon Sep 17 00:00:00 2001 From: Copple <10214025+kiwicopple@users.noreply.github.com> Date: Wed, 8 Nov 2023 11:27:13 +0100 Subject: [PATCH 17/58] docs: fix highlights (#18814) --- apps/docs/pages/guides/functions/auth.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/docs/pages/guides/functions/auth.mdx b/apps/docs/pages/guides/functions/auth.mdx index 6afaded5159ac..d50a436d4b0e6 100644 --- a/apps/docs/pages/guides/functions/auth.mdx +++ b/apps/docs/pages/guides/functions/auth.mdx @@ -13,7 +13,7 @@ Edge Functions work seamlessly with [Supabase Auth](/docs/guides/auth). When a user makes a request to an Edge Function, you can use the Authorization header to set the Auth context in the Supabase client: -```js mark=10 +```js mark=9 import { createClient } from 'https://esm.sh/@supabase/supabase-js@2' Deno.serve(async (req: Request) => { @@ -34,7 +34,7 @@ Importantly, this is done _inside_ the `Deno.serve()` callback argument, so that After initializing a Supabase client with the Auth context, you can use `getUser()` to fetch the user object, and run queries in the context of the user with [Row Level Security (RLS)](/docs/guides/auth/row-level-security) policies enforced. -```js mark=13:14 +```js mark=12:13 import { createClient } from 'https://esm.sh/@supabase/supabase-js@2' Deno.serve(async (req: Request) => { @@ -61,7 +61,7 @@ Deno.serve(async (req: Request) => { After initializing a Supabase client with the Auth context, all queries will be executed with the context of the user. For database queries, this means [Row Level Security](/docs/guides/auth/row-level-security) will be enforced. -```js mark=13 +```js mark=12 import { createClient } from 'https://esm.sh/@supabase/supabase-js@2' Deno.serve(async (req: Request) => { From ae4d3c916c05d9a4810b392d945ec6eebd18ac98 Mon Sep 17 00:00:00 2001 From: Francesco Sansalvadore Date: Wed, 8 Nov 2023 11:51:04 +0100 Subject: [PATCH 18/58] Fix link underline brand color (#18817) fix link underline brand color --- packages/config/tailwind.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/config/tailwind.config.js b/packages/config/tailwind.config.js index 7a4865644495a..04e54a1fd0f71 100644 --- a/packages/config/tailwind.config.js +++ b/packages/config/tailwind.config.js @@ -232,7 +232,7 @@ const uiConfig = ui({ fontWeight: '400', color: 'hsl(var(--colors-scale12))', textDecorationLine: 'underline', - textDecorationColor: 'hsl(var(--brand-400))', + textDecorationColor: 'hsl(var(--brand-500))', textDecorationThickness: '1px', textUnderlineOffset: '4px', }, From 11490e695be997b3d4105bc726e4eeaefef914a2 Mon Sep 17 00:00:00 2001 From: Pamela Chia Date: Wed, 8 Nov 2023 19:34:17 +0800 Subject: [PATCH 19/58] fix: add link in docs to compute size change (#18816) fix: add link to compute size change --- apps/docs/pages/guides/platform/compute-add-ons.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/docs/pages/guides/platform/compute-add-ons.mdx b/apps/docs/pages/guides/platform/compute-add-ons.mdx index 646cb64adac41..17f19f00b3c40 100644 --- a/apps/docs/pages/guides/platform/compute-add-ons.mdx +++ b/apps/docs/pages/guides/platform/compute-add-ons.mdx @@ -25,7 +25,7 @@ Number of connections above are recommended values. We charge hourly for additional compute based on your usage. Read more about [usage-based billing for compute](/docs/guides/platform/org-based-billing#usage-based-billing-for-compute). -[Contact us](https://supabase.com/contact/enterprise) if you require a custom plan. +Compute sizes can be changed in [the dashboard here by selecting your project](https://supabase.com/dashboard/project/_/settings/addons?panel=computeInstance). [Contact us](https://supabase.com/contact/enterprise) if you require a custom plan. ## Dedicated vs. shared CPU From a9d4eb0f3f3d87460df5a02aea6ba0093938ac32 Mon Sep 17 00:00:00 2001 From: Lakshan Perera Date: Wed, 8 Nov 2023 23:06:50 +1100 Subject: [PATCH 20/58] fix: Update edge function examples in guides (#18808) * fix: Update edge function examples in guides * fix: revert the sidebar title --- .../pages/guides/functions/connect-to-postgres.mdx | 3 +-- apps/docs/pages/guides/functions/cors.mdx | 3 +-- apps/docs/pages/guides/functions/debugging.mdx | 11 +++-------- .../functions/examples/cloudflare-turnstile.mdx | 3 +-- .../pages/guides/functions/examples/discord-bot.mdx | 4 ++-- .../docs/pages/guides/functions/examples/og-image.mdx | 3 +-- .../pages/guides/functions/examples/send-emails.mdx | 4 +--- .../guides/functions/examples/slack-bot-mention.mdx | 3 +-- .../pages/guides/functions/examples/upstash-redis.mdx | 3 +-- 9 files changed, 12 insertions(+), 25 deletions(-) diff --git a/apps/docs/pages/guides/functions/connect-to-postgres.mdx b/apps/docs/pages/guides/functions/connect-to-postgres.mdx index 070c9e60a955e..96218ca9967b2 100644 --- a/apps/docs/pages/guides/functions/connect-to-postgres.mdx +++ b/apps/docs/pages/guides/functions/connect-to-postgres.mdx @@ -50,7 +50,6 @@ Because Edge Functions are a server-side technology, it's safe to connect direct ```ts index.ts import * as postgres from 'https://deno.land/x/postgres@v0.17.0/mod.ts' -import { serve } from 'https://deno.land/std@0.177.0/http/server.ts' // Get the connection string from the environment variable "SUPABASE_DB_URL" const databaseUrl = Deno.env.get('SUPABASE_DB_URL')! @@ -58,7 +57,7 @@ const databaseUrl = Deno.env.get('SUPABASE_DB_URL')! // Create a database pool with three connections that are lazily established const pool = new postgres.Pool(databaseUrl, 3, true) -serve(async (_req) => { +Deno.serve(async (_req) => { try { // Grab a connection from the pool const connection = await pool.connect() diff --git a/apps/docs/pages/guides/functions/cors.mdx b/apps/docs/pages/guides/functions/cors.mdx index 75525da0741bd..758b90cce3d88 100644 --- a/apps/docs/pages/guides/functions/cors.mdx +++ b/apps/docs/pages/guides/functions/cors.mdx @@ -24,12 +24,11 @@ export const corsHeaders = { You can then import and use the CORS headers within your functions: ```ts index.ts -import { serve } from 'https://deno.land/std@0.177.0/http/server.ts' import { corsHeaders } from '../_shared/cors.ts' console.log(`Function "browser-with-cors" up and running!`) -serve(async (req) => { +Deno.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 }) diff --git a/apps/docs/pages/guides/functions/debugging.mdx b/apps/docs/pages/guides/functions/debugging.mdx index 09d3b473e967c..cb422794df0a1 100644 --- a/apps/docs/pages/guides/functions/debugging.mdx +++ b/apps/docs/pages/guides/functions/debugging.mdx @@ -26,15 +26,10 @@ When [developing locally](/docs/guides/functions/local-development) you will see ## Limitations -### Deno Deploy limitations - -- Deno does not support outgoing connections to ports `25`, `465`, and `587`. -- Deno-deployed functions cannot read or write to the file system. -- NPM modules are not supported. - -### Supabase Edge Functions - +- Outgoing connections to ports `25`, `465`, and `587` are not allowed. - Serving of HTML content is not supported (`GET` requests that return `text/html` will be rewritten to `text/plain`). +- Deno FileSystem APIs are not available to use within Edge Functions. +- Importing modules using `npm:` specifier is currently not supported ([use a CDN to load npm modules](/docs/guides/functions/import-maps)). ## Troubleshooting diff --git a/apps/docs/pages/guides/functions/examples/cloudflare-turnstile.mdx b/apps/docs/pages/guides/functions/examples/cloudflare-turnstile.mdx index bb6bdf7d71dc7..c1c0b694e14da 100644 --- a/apps/docs/pages/guides/functions/examples/cloudflare-turnstile.mdx +++ b/apps/docs/pages/guides/functions/examples/cloudflare-turnstile.mdx @@ -34,7 +34,6 @@ 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.177.0/http/server.ts' import { corsHeaders } from '../_shared/cors.ts' console.log('Hello from Cloudflare Trunstile!') @@ -43,7 +42,7 @@ function ips(req: Request) { return req.headers.get('x-forwarded-for')?.split(/\s*,\s*/) } -serve(async (req) => { +Deno.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 }) diff --git a/apps/docs/pages/guides/functions/examples/discord-bot.mdx b/apps/docs/pages/guides/functions/examples/discord-bot.mdx index e542f346ca65a..14ff7c54163c7 100644 --- a/apps/docs/pages/guides/functions/examples/discord-bot.mdx +++ b/apps/docs/pages/guides/functions/examples/discord-bot.mdx @@ -47,10 +47,10 @@ This will register a Slash Command named `hello` that accepts a parameter named // Sift is a small routing library that abstracts away details like starting a // listener on a port, and provides a simple function (serve) that has an API // to invoke a function for a specific path. -import { json, serve, validateRequest } from 'sift' +import { json, serve, validateRequest } from 'https://deno.land/x/sift@0.6.0/mod.ts' // TweetNaCl is a cryptography library that we use to verify requests // from Discord. -import nacl from 'tweetnacl' +import nacl from 'https://cdn.skypack.dev/tweetnacl@v1.0.3?dts' enum DiscordCommandType { Ping = 1, diff --git a/apps/docs/pages/guides/functions/examples/og-image.mdx b/apps/docs/pages/guides/functions/examples/og-image.mdx index be4f4dc46d285..ecb1a060537e2 100644 --- a/apps/docs/pages/guides/functions/examples/og-image.mdx +++ b/apps/docs/pages/guides/functions/examples/og-image.mdx @@ -50,12 +50,11 @@ 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.177.0/http/server.ts' import handler from './handler.tsx' console.log('Hello from og-image Function!') -serve(handler) +Deno.serve(handler) ``` export const Page = ({ children }) => diff --git a/apps/docs/pages/guides/functions/examples/send-emails.mdx b/apps/docs/pages/guides/functions/examples/send-emails.mdx index 6f7b52ab51aaa..a54187849b858 100644 --- a/apps/docs/pages/guides/functions/examples/send-emails.mdx +++ b/apps/docs/pages/guides/functions/examples/send-emails.mdx @@ -31,8 +31,6 @@ Store the `RESEND_API_KEY` in your `.env` file. Paste the following code into the `index.ts` file: ```tsx -import { serve } from 'https://deno.land/std@0.168.0/http/server.ts' - const RESEND_API_KEY = Deno.env.get('RESEND_API_KEY') const handler = async (_request: Request): Promise => { @@ -60,7 +58,7 @@ const handler = async (_request: Request): Promise => { }) } -serve(handler) +Deno.serve(handler) ``` ### 3. Deploy and send email diff --git a/apps/docs/pages/guides/functions/examples/slack-bot-mention.mdx b/apps/docs/pages/guides/functions/examples/slack-bot-mention.mdx index cb1486f98b91b..e3aff2ea780f0 100644 --- a/apps/docs/pages/guides/functions/examples/slack-bot-mention.mdx +++ b/apps/docs/pages/guides/functions/examples/slack-bot-mention.mdx @@ -29,14 +29,13 @@ set SLACK_TOKEN= Here's the code of the Edge Function, you can change the response to handle the text received: ```ts index.ts -import { serve } from 'https://deno.land/std@0.197.0/http/server.ts' import { WebClient } from 'https://deno.land/x/slack_web_api@6.7.2/mod.js' const slackBotToken = Deno.env.get('SLACK_TOKEN') ?? '' const botClient = new WebClient(slackBotToken) console.log(`Slack URL verification function up and running!`) -serve(async (req) => { +Deno.serve(async (req) => { try { const reqBody = await req.json() console.log(JSON.stringify(reqBody, null, 2)) diff --git a/apps/docs/pages/guides/functions/examples/upstash-redis.mdx b/apps/docs/pages/guides/functions/examples/upstash-redis.mdx index d97d1879e632a..a356e1214d48b 100644 --- a/apps/docs/pages/guides/functions/examples/upstash-redis.mdx +++ b/apps/docs/pages/guides/functions/examples/upstash-redis.mdx @@ -41,12 +41,11 @@ supabase functions new upstash-redis-counter And add the code to the `index.ts` file: ```ts index.ts -import { serve } from 'https://deno.land/std@0.177.0/http/server.ts' import { Redis } from 'https://deno.land/x/upstash_redis@v1.19.3/mod.ts' console.log(`Function "upstash-redis-counter" up and running!`) -serve(async (_req) => { +Deno.serve(async (_req) => { try { const redis = new Redis({ url: Deno.env.get('UPSTASH_REDIS_REST_URL')!, From ecae02090be1064286c9f1ef8de2654c014a554b Mon Sep 17 00:00:00 2001 From: Francesco Sansalvadore Date: Wed, 8 Nov 2023 13:10:34 +0100 Subject: [PATCH 21/58] Fix next-themes resolvedTheme bug (#18818) temporary fix for next-themes bug --- apps/www/components/Footer/index.tsx | 18 +++++++++++++++++- apps/www/components/Nav/index.tsx | 21 ++++++++++++++++++--- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/apps/www/components/Footer/index.tsx b/apps/www/components/Footer/index.tsx index afd443a4fbddd..ec9b7ed1adebd 100644 --- a/apps/www/components/Footer/index.tsx +++ b/apps/www/components/Footer/index.tsx @@ -1,3 +1,4 @@ +import { useEffect, useState } from 'react' import Link from 'next/link' import { useTheme } from 'next-themes' import { Badge, IconDiscord, IconGitHubSolid, IconTwitterX, IconYoutubeSolid, cn } from 'ui' @@ -21,6 +22,21 @@ const Footer = (props: Props) => { const isLaunchWeekPage = pathname.includes('launch-week') || pathname === '/' + /** + * Temporary fix for next-theme client side bug + * https://github.com/pacocoursey/next-themes/issues/169 + * TODO: remove when bug has been fixed + */ + const [mounted, setMounted] = useState(false) + + useEffect(() => { + setMounted(true) + }, []) + + if (!mounted) { + return null + } + return (