diff --git a/.github/workflows/studio-tests.yml b/.github/workflows/studio-tests.yml index 11fda1e766c..766fddf9226 100644 --- a/.github/workflows/studio-tests.yml +++ b/.github/workflows/studio-tests.yml @@ -5,12 +5,12 @@ name: Studio Unit Tests on: push: - branches: [master] + branches: [master, studio] paths: - 'studio/**' - 'package-lock.json' pull_request: - branches: [master] + branches: [master, studio] paths: - 'studio/**' - 'package-lock.json' diff --git a/apps/docs/DEVELOPERS.md b/apps/docs/DEVELOPERS.md index 3935d5e0ce0..5c5b74e39de 100644 --- a/apps/docs/DEVELOPERS.md +++ b/apps/docs/DEVELOPERS.md @@ -45,7 +45,7 @@ You can use any standard React components in these `.mdx` files without having t ### Reference docs for client libraries -We maintain client libraries for [Javascript](https://supabase.com/docs/reference/javascript) and [Flutter/Dart](https://supabase.com/docs/reference/dart) (with more to come). These reference docs document every object and method available for developers to use. The are assembled from different sources and work much differently than the `.mdx` Guides we just looked at. +We maintain client libraries for [JavaScript](https://supabase.com/docs/reference/javascript) and [Flutter/Dart](https://supabase.com/docs/reference/dart) (with more to come). These reference docs document every object and method available for developers to use. They are assembled from different sources and work much differently than the `.mdx` Guides we just looked at. The client libraries are essentially wrappers around the clients for the various tools we use — GoTrue, PostgREST, Storage, Functions, and Realtime. The easiest way to describe how the things fit together is to look at an example and trace where the various pieces of information are coming from. diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts index fa70a94cd1a..a5d057ab713 100644 --- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts +++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts @@ -578,6 +578,7 @@ export const functions = { name: 'Connecting directly to Postgres', url: '/guides/functions/connect-to-postgres', }, + { name: 'Dart Edge on Supabase', url: '/guides/functions/dart-edge' }, ], }, { diff --git a/apps/docs/pages/guides/api/quickstart.mdx b/apps/docs/pages/guides/api/quickstart.mdx index 7d645a8b5f7..f71eb970247 100644 --- a/apps/docs/pages/guides/api/quickstart.mdx +++ b/apps/docs/pages/guides/api/quickstart.mdx @@ -78,8 +78,8 @@ We'll create a database table called `todos` for storing tasks. This creates a c -- Allow anonymous access create policy "Allow anonymous access" on todos - to anon for select + to anon using (true); ``` diff --git a/apps/docs/pages/guides/functions/dart-edge.mdx b/apps/docs/pages/guides/functions/dart-edge.mdx new file mode 100644 index 00000000000..49ac9142d37 --- /dev/null +++ b/apps/docs/pages/guides/functions/dart-edge.mdx @@ -0,0 +1,192 @@ +import Layout from '~/layouts/DefaultGuideLayout' + +export const meta = { + id: 'functions-dart-edge', + title: 'Dart Edge', + description: 'Write your functions using Dart.', +} + +[Dart Edge](https://docs.dartedge.dev/), a project built and maintained by [Invertase](https://invertase.io/), enables Dart code to be run on different edge environments. This guide will walk you through how you can start using Dart Edge to write your backend code using Dart and run it on Supabase. + +> ⚠️ WARNING: Dart Edge is an experimental project - it's probably not ready for production usage unless you're okay with living on the 'edge'. Open issues on [Dart Edge repo](https://github.com/invertase/dart_edge) if you encounter any issues. + +## **Pre requirements** + +Make sure you have [the edge CLI](https://docs.dartedge.dev/#getting-started) installed in addition to [the Supabase CLI](https://supabase.com/docs/guides/cli#installation). + +```bash +# install the edge CLI +dart pub global activate edge +``` + +## **Setting up your first Dart Edge project** + +Create a new Dart Edge project using the `new` command on the edge CLI. This will create a familiar boilerplate for your Dart Edge project such as `main.dart` and `pubspec.yaml` file. + +```bash +edge new supabase_functions new_project +``` + +`cd` into the project and initialize a new Supabase project inside the project you just created. + +```bash +cd new_project +supabase init +``` + +Run `pub get` to install the dependencies. + +```bash +dart pub get +``` + +Open the `lib/main.dart` and look at the initial template. + +```dart +void main() { + SupabaseFunctions(fetch: (request) { + return Response("Hello from Supabase Edge Functions!"); + }); +} +``` + +`SupabaseFunctions` class has a `fetch` handler, which is expected to return a `Response` object, and has a `request` parameter, which contains information about the request such as body and headers. + +## Using Supabase Client + +Now let’s try to interact with our Supabase database. We will start by installing the dependencies. + +### Add dependencies + +Add [supabase](https://pub.dev/packages/supabase) to interact with Supabase service. + +```bash +dart pub add supabase +``` + +We also need to use a special HTTP client to HTTP requests in the edge environment. + +```bash +dart pub add edge_http_client +``` + +We also need to add the `yet_another_json_isolate` package, which is the JSON encoder/decoder that utilizes isolate. + +```bash +dart pub add yet_another_json_isolate +``` + +### Override the JSON isolate + +Since isolates are not supported in the edge, we have to override its behavior to handle JSON serialization using the main thread. + +```dart +import 'package:yet_another_json_isolate/yet_another_json_isolate.dart'; + +class EdgeIsolate implements YAJsonIsolate { + @override + Future decode(String json) { + return Future.value(jsonDecode(json)); + } + + @override + Future dispose() async {} + + @override + Future encode(Object? json) { + return Future.value(jsonEncode(json)); + } + + @override + Future initialize() async {} +} +``` + +### Initialize SupabaseClient + +At this point, you can initialize a `SupabaseClient` by passing the [EdgeHttpClient](https://pub.dev/packages/edge_http_client) and the `EdgeIsolate`. We can access the Supabase credentials through the [environment variables](https://supabase.com/docs/guides/functions/secrets) using `Deno.env.get()` method. Note that [Supabase credentials are available by default](https://supabase.com/docs/guides/functions/secrets), so no configurations are necessary. + +Combining the isolates we overrode earlier, we have the following sample functions code to query Supabase database using the Supabase client. + +```dart +import 'dart:convert'; + +import 'package:supabase_functions/supabase_functions.dart'; +import 'package:edge_http_client/edge_http_client.dart'; +import 'package:supabase/supabase.dart'; +import 'package:yet_another_json_isolate/yet_another_json_isolate.dart'; + +void main() { + final supabase = SupabaseClient( + Deno.env.get('SUPABASE_URL')!, + Deno.env.get('SUPABASE_SERVICE_ROLE_KEY')!, // Use service role key to bypass RLS + httpClient: EdgeHttpClient(), + isolate: EdgeIsolate(), + ); + + SupabaseFunctions(fetch: (request) async { + // You can query `public.users` table for example. + final List users = await supabase.from('users').select().limit(10); + return Response.json(users); + }); +} + +class EdgeIsolate implements YAJsonIsolate { + @override + Future decode(String json) { + return Future.value(jsonDecode(json)); + } + + @override + Future dispose() async {} + + @override + Future encode(Object? json) { + return Future.value(jsonEncode(json)); + } + + @override + Future initialize() async {} +} +``` + +## Run the Functions + +### Run locally + +Run the following command to compile your Dart code. This command will start a watcher that will recompile anytime you make changes to your code. + +```bash +edge build supabase_functions --dev +``` + +With docker running, start your local Supabase with the following command + +```bash +supabase start +``` + +While you have the above code running, open another terminal and run the following to start the Supabase local development environment. + +```bash +supabase functions serve dart_edge --no-verify-jwt +``` + +You should be able to access your local function here: + +[http://localhost:54321/functions/v1/dart_edge](http://localhost:54321/functions/v1/dart_edge) + +### Deploy to the Edge + +Run the following commands to compile and deploy your function on Supabase Edge functions. + +```bash +edge build supabase_functions +supabase functions deploy dart_edge +``` + +You will be asked to provide the project reference of your Supabase instance to which you want to deploy the function. You can [link your local project to your Supabase instance](https://supabase.com/docs/guides/cli/local-development#link-your-project) to avoid having to provide the Supabase reference every time you deploy. + +export const Page = ({ children }) => + +export default Page diff --git a/apps/docs/pages/support.mdx b/apps/docs/pages/support.mdx deleted file mode 100644 index 175fb0d0c9b..00000000000 --- a/apps/docs/pages/support.mdx +++ /dev/null @@ -1,23 +0,0 @@ -import Layout from '~/layouts/DefaultGuideLayout' - -export const meta = { - id: 'support', - title: 'Support', - description: 'Supabase Support', -} - -How can we help? - -## Community Support - -For help and questions about best practices, we have a discussion forum set up on GitHub: https://github.com/supabase/supabase/discussions - -## Business Support - -We offer email based support for business users. You can email us at support@supabase.com. - -If you need SLAs, guaranteed response times, or other enterprise level services, please contact us at this email address. - -## Slack Support - -If you are building with Supabase and you would like to set up a shared Slack channel (via [Slack Connect](https://slack.com/connect)), please reach out to us at support@supabase.com. diff --git a/apps/www/_blog/2023-04-07-designing-with-ai-midjourney.mdx b/apps/www/_blog/2023-04-07-designing-with-ai-midjourney.mdx index 2a82e547dce..d3952629f74 100644 --- a/apps/www/_blog/2023-04-07-designing-with-ai-midjourney.mdx +++ b/apps/www/_blog/2023-04-07-designing-with-ai-midjourney.mdx @@ -33,7 +33,11 @@ After exploring a variety of text prompts, blends, and styles, we decided that m After what-seemed-like hours (okay, just a few), we were able to generate some interesting artwork that could be useful. We chose purple hues and simpler swirls - minimalist visuals that could serve as backgrounds for our tickets and landing page. -![midjourney variations](/images/blog/launch-week-7/designing-with-ai-midjourney/midjourney-variations.png) + ### Chasing Gold Behind the Scenes diff --git a/apps/www/_blog/2023-04-07-launch-week-7-hackathon.mdx b/apps/www/_blog/2023-04-07-launch-week-7-hackathon.mdx index de89693f3be..8ea19a22a51 100644 --- a/apps/www/_blog/2023-04-07-launch-week-7-hackathon.mdx +++ b/apps/www/_blog/2023-04-07-launch-week-7-hackathon.mdx @@ -14,7 +14,7 @@ toc_depth: 2 With Easter just around the corner, [Launch Week](https://supabase.com/launch-week) is about to start and, as usual, we're running an async hackathon alongside it. This time it’s AI-themed! -The hackathon starts **now** and ends Monday 16th April at 11:59 pm. You can win extremely limited edition Launch Week themed mechanical keyboards and limited edition Supabase swag. +The hackathon starts **now** and ends Sunday 16th April at 11:59 pm. You can win extremely limited edition Launch Week themed mechanical keyboards and limited edition Supabase swag. For some inspiration check out the [Next.js OpenAI Doc Search template](https://github.com/supabase-community/nextjs-openai-doc-search?og=v2) released yesterday and [storing embeddings on Supabase article](https://supabase.com/blog/openai-embeddings-postgres-vector). diff --git a/apps/www/_blog/2023-04-13-supabase-auth-sso-pkce.mdx b/apps/www/_blog/2023-04-13-supabase-auth-sso-pkce.mdx index e5755476a8d..c1a4dfb36ea 100644 --- a/apps/www/_blog/2023-04-13-supabase-auth-sso-pkce.mdx +++ b/apps/www/_blog/2023-04-13-supabase-auth-sso-pkce.mdx @@ -13,8 +13,9 @@ thumb: launch-week-7/day-4-supabase-auth-sso-pkce/supabase-auth-sso-pkce-og.jpg Today we're excited to announce a few new features for Supabase Auth: -1. Easily add Single Sign-On support to your projects using SAML 2.0. -2. Better support for server-side rendering and mobile apps using PKCE. +1. [Easily add Single Sign-On support to your projects using SAML 2.0](/blog/supabase-auth-sso-pkce#single-sign-on-support-using-saml-20) +2. [Better support for server-side rendering and mobile apps using PKCE](/blog/supabase-auth-sso-pkce#server-side-and-mobile-auth) +3. [Native Apple login on iOS](/blog/supabase-auth-sso-pkce#native-apple-login-on-ios) ## Single Sign-On Support using SAML 2.0 @@ -22,7 +23,7 @@ With Single Sign-On (SSO), your users can login with their company's identity pr Every developer building a B2B application eventually needs the SSO authentication flow to onboard enterprise customers. SSO is a requirement for larger Enterprise customers because it's a standard request in Enterprise Security Policies. Over the past few months, we've been [dogfooding SSO for our own Enterprise customers](https://supabase.com/docs/guides/platform/sso), and today we're releasing it for you to do the same. -Building SSO into your application isn't necessarily hard, but does come with some complexity. A lot of time can be spent understanding the nuances and details of the protocol - from dissecting the jargon to testing the implementation heavily. It took us months to build it for ourselves. With this release, you will have SSO set up and running in less than an hour so that you can focus on shipping the core features of your product. This feature is available for the [Pro-tier and above](https://supabase.com/pricing), starting today. +Building SSO into your application isn't necessarily hard, but does come with some complexity. A lot of time can be spent understanding the nuances and details of the protocol - from dissecting the jargon to testing the implementation heavily. It took us months to build it for ourselves. With this release, you will have SSO set up and running in less than an hour so that you can focus on shipping the core features of your product. This feature is available for the [Pro-tier and above](https://supabase.com/pricing), starting today. This will also be available on the self-hosted version.