diff --git a/bricks/supabase_functions/__brick__/.gitignore b/bricks/supabase_functions/__brick__/.gitignore index c7f77dc..c63d6c5 100644 --- a/bricks/supabase_functions/__brick__/.gitignore +++ b/bricks/supabase_functions/__brick__/.gitignore @@ -1 +1,2 @@ -.dart_tool \ No newline at end of file +.dart_tool +supabase/functions/dart_edge \ No newline at end of file diff --git a/docs.json b/docs.json index 908904b..9a5571e 100644 --- a/docs.json +++ b/docs.json @@ -51,6 +51,7 @@ ["Request Properties", "/platform/cloudflare/request-properties"], ["Service Bindings", "/platform/cloudflare/service-bindings"] ] - ] + ], + ["Supabase Edge Functions", [["Getting Started", "/platform/supabase"]]] ] } diff --git a/docs/platform/supabase/index.mdx b/docs/platform/supabase/index.mdx index 0d173f0..3396c1b 100644 --- a/docs/platform/supabase/index.mdx +++ b/docs/platform/supabase/index.mdx @@ -109,6 +109,8 @@ supabase functions serve dart_edge --no-verify-jwt > Note: By default Supabase Functions expects a valid auth header. The `--no-verify-jwt` enables you to run the function without a valid auth header. +You should now be able to access your function at [http://localhost:54321/functions/v1/dart_edge](http://localhost:54321/functions/v1/dart_edge). + To learn more about local Supabase development, view their [documentation](https://supabase.com/docs/guides/functions/local-development). ## Deployment diff --git a/examples/supabase-edge-functions/.gitignore b/examples/supabase-edge-functions/.gitignore new file mode 100644 index 0000000..c63d6c5 --- /dev/null +++ b/examples/supabase-edge-functions/.gitignore @@ -0,0 +1,2 @@ +.dart_tool +supabase/functions/dart_edge \ No newline at end of file diff --git a/examples/supabase-edge-functions/README.md b/examples/supabase-edge-functions/README.md new file mode 100644 index 0000000..10f2ef1 --- /dev/null +++ b/examples/supabase-edge-functions/README.md @@ -0,0 +1,21 @@ +# Supabase Edge Functions Example + +This template demonstrates how to run a [Supabase Edge Functions](https://supabase.com/docs/guides/functions) application via Dart Edge. + +## Getting Started + +Install the dependencies: + +```bash +dart pub get +``` + +Start the application via Dart Edge CLU & the [`supabase` CLI](https://supabase.com/docs/guides/cli): + +```bash +supabase init +edge build supabase_functions --dev +supabase functions serve dart_edge --no-verify-jwt +``` + +For more information, see the [Dart Edge documentation](https://docs.dartedge.dev). \ No newline at end of file diff --git a/examples/supabase-edge-functions/analysis_options.yaml b/examples/supabase-edge-functions/analysis_options.yaml new file mode 100644 index 0000000..3b6a066 --- /dev/null +++ b/examples/supabase-edge-functions/analysis_options.yaml @@ -0,0 +1,24 @@ +# This file configures the static analysis results for your project (errors, +# warnings, and lints). +# +# This enables the 'recommended' set of lints from `package:lints`. +# This set helps identify many issues that may lead to problems when running +# or consuming Dart code, and enforces writing Dart using a single, idiomatic +# style and format. +# +# If you want a smaller set of lints you can change this to specify +# 'package:lints/core.yaml'. These are just the most critical lints +# (the recommended set includes the core lints). +# The core lints are also what is used by pub.dev for scoring packages. + +include: package:lints/recommended.yaml + +# analyzer: +# exclude: +# - path/to/excluded/files/** + +# For more information about the core and recommended set of lints, see +# https://dart.dev/go/core-lints + +# For additional information about configuring this file, see +# https://dart.dev/guides/language/analysis-options \ No newline at end of file diff --git a/examples/supabase-edge-functions/lib/main.dart b/examples/supabase-edge-functions/lib/main.dart new file mode 100644 index 0000000..851c505 --- /dev/null +++ b/examples/supabase-edge-functions/lib/main.dart @@ -0,0 +1,7 @@ +import 'package:supabase_functions/supabase_functions.dart'; + +void main() { + SupabaseFunctions(fetch: (request) { + return Response("Hello from Supabase Edge Functions!"); + }); +} diff --git a/examples/supabase-edge-functions/pubspec.lock b/examples/supabase-edge-functions/pubspec.lock new file mode 100644 index 0000000..0ec9a30 --- /dev/null +++ b/examples/supabase-edge-functions/pubspec.lock @@ -0,0 +1,373 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + ansi_styles: + dependency: transitive + description: + name: ansi_styles + sha256: "9c656cc12b3c27b17dd982b2cc5c0cfdfbdabd7bc8f3ae5e8542d9867b47ce8a" + url: "https://pub.dev" + source: hosted + version: "0.3.2+1" + archive: + dependency: transitive + description: + name: archive + sha256: d6347d54a2d8028e0437e3c099f66fdb8ae02c4720c1e7534c9f24c10351f85d + url: "https://pub.dev" + source: hosted + version: "3.3.6" + args: + dependency: transitive + description: + name: args + sha256: "4cab82a83ffef80b262ddedf47a0a8e56ee6fbf7fe21e6e768b02792034dd440" + url: "https://pub.dev" + source: hosted + version: "2.4.0" + async: + dependency: transitive + description: + name: async + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" + source: hosted + version: "2.11.0" + charcode: + dependency: transitive + description: + name: charcode + sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306 + url: "https://pub.dev" + source: hosted + version: "1.3.1" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: "3d1505d91afa809d177efd4eed5bb0eb65805097a1463abdd2add076effae311" + url: "https://pub.dev" + source: hosted + version: "2.0.2" + collection: + dependency: transitive + description: + name: collection + sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + url: "https://pub.dev" + source: hosted + version: "1.17.1" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + crypto: + dependency: transitive + description: + name: crypto + sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67 + url: "https://pub.dev" + source: hosted + version: "3.0.2" + deno_deploy: + dependency: transitive + description: + name: deno_deploy + sha256: "3b6eef9d88d93e6144b9f9501481615ac1a55e8ca7ff4882250799eeb0d70840" + url: "https://pub.dev" + source: hosted + version: "0.0.1-dev.3" + edge: + dependency: "direct main" + description: + name: edge + sha256: f3c0c6e6e0845c64a8d44c6208a856dbf4a75b8a2d37aeb7a8a338f6c3433426 + url: "https://pub.dev" + source: hosted + version: "0.0.6" + edge_runtime: + dependency: transitive + description: + name: edge_runtime + sha256: "9ce28ef2c83f0db9eb857c4b433c1531c5bab31627cc6544727d4abc918570d7" + url: "https://pub.dev" + source: hosted + version: "0.0.3+1" + file: + dependency: transitive + description: + name: file + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + url: "https://pub.dev" + source: hosted + version: "6.1.4" + freezed_annotation: + dependency: transitive + description: + name: freezed_annotation + sha256: aeac15850ef1b38ee368d4c53ba9a847e900bb2c53a4db3f6881cbb3cb684338 + url: "https://pub.dev" + source: hosted + version: "2.2.0" + glob: + dependency: transitive + description: + name: glob + sha256: "4515b5b6ddb505ebdd242a5f2cc5d22d3d6a80013789debfbda7777f47ea308c" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + hotreloader: + dependency: transitive + description: + name: hotreloader + sha256: "728c0613556c1d153f7e7f4a367cffacc3f5a677d7f6497a1c2b35add4e6dacf" + url: "https://pub.dev" + source: hosted + version: "3.0.6" + http: + dependency: transitive + description: + name: http + sha256: "6aa2946395183537c8b880962d935877325d6a09a2867c3970c05c0fed6ac482" + url: "https://pub.dev" + source: hosted + version: "0.13.5" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" + source: hosted + version: "4.0.2" + io: + dependency: transitive + description: + name: io + sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" + url: "https://pub.dev" + source: hosted + version: "1.0.4" + js: + dependency: transitive + description: + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" + js_bindings: + dependency: transitive + description: + name: js_bindings + sha256: "4b2f25c42b5b5eb2537bfe1006878787bdf10d50f680d80d15bd90569e36c926" + url: "https://pub.dev" + source: hosted + version: "0.1.2+1" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: c33da08e136c3df0190bd5bbe51ae1df4a7d96e7954d1d7249fea2968a72d317 + url: "https://pub.dev" + source: hosted + version: "4.8.0" + lints: + dependency: "direct dev" + description: + name: lints + sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593" + url: "https://pub.dev" + source: hosted + version: "2.0.1" + logging: + dependency: transitive + description: + name: logging + sha256: "04094f2eb032cbb06c6f6e8d3607edcfcb0455e2bb6cbc010cb01171dcb64e6d" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + mason: + dependency: transitive + description: + name: mason + sha256: d122e582f4c332b33d95289aafdea475ff5446e9939338b4b6330e2e488ed4e1 + url: "https://pub.dev" + source: hosted + version: "0.1.0-dev.48" + mason_logger: + dependency: transitive + description: + name: mason_logger + sha256: ca34d14e998cd7a7738e7320b102aa45fb363aa49a290084b211ababf75bb7ee + url: "https://pub.dev" + source: hosted + version: "0.2.5" + meta: + dependency: transitive + description: + name: meta + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + url: "https://pub.dev" + source: hosted + version: "1.9.1" + mustache_template: + dependency: transitive + description: + name: mustache_template + sha256: a46e26f91445bfb0b60519be280555b06792460b27b19e2b19ad5b9740df5d1c + url: "https://pub.dev" + source: hosted + version: "2.0.0" + path: + dependency: transitive + description: + name: path + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" + source: hosted + version: "1.8.3" + petitparser: + dependency: transitive + description: + name: petitparser + sha256: a9346a3fbba7546a28374bdbcd7f54ea48bb47772bf3a7ab4bfaadc40bc8b8c6 + url: "https://pub.dev" + source: hosted + version: "5.3.0" + pointycastle: + dependency: transitive + description: + name: pointycastle + sha256: c3120a968135aead39699267f4c74bc9a08e4e909e86bc1b0af5bfd78691123c + url: "https://pub.dev" + source: hosted + version: "3.7.2" + pool: + dependency: transitive + description: + name: pool + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" + source: hosted + version: "1.5.1" + prompts: + dependency: transitive + description: + name: prompts + sha256: "3773b845e85a849f01e793c4fc18a45d52d7783b4cb6c0569fad19f9d0a774a1" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "307de764d305289ff24ad257ad5c5793ce56d04947599ad68b3baa124105fc17" + url: "https://pub.dev" + source: hosted + version: "2.1.3" + recase: + dependency: transitive + description: + name: recase + sha256: e4eb4ec2dcdee52dcf99cb4ceabaffc631d7424ee55e56f280bc039737f89213 + url: "https://pub.dev" + source: hosted + version: "4.1.0" + source_span: + dependency: transitive + description: + name: source_span + sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + url: "https://pub.dev" + source: hosted + version: "1.9.1" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" + source: hosted + version: "1.11.0" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + supabase_functions: + dependency: "direct main" + description: + name: supabase_functions + sha256: "4f9c5e3755e0f8e6066f528642840ec3ea9a2025ee1069293512083ade375b0b" + url: "https://pub.dev" + source: hosted + version: "0.0.1+1" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + toml: + dependency: transitive + description: + name: toml + sha256: "69756bc12eccf279b72217a87310d217efc4b3752f722e890f672801f19ac485" + url: "https://pub.dev" + source: hosted + version: "0.13.1" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5" + url: "https://pub.dev" + source: hosted + version: "1.3.1" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: f6deed8ed625c52864792459709183da231ebf66ff0cf09e69b573227c377efe + url: "https://pub.dev" + source: hosted + version: "11.3.0" + watcher: + dependency: transitive + description: + name: watcher + sha256: "6a7f46926b01ce81bfc339da6a7f20afbe7733eff9846f6d6a5466aa4c6667c0" + url: "https://pub.dev" + source: hosted + version: "1.0.2" + yaml: + dependency: transitive + description: + name: yaml + sha256: "23812a9b125b48d4007117254bca50abb6c712352927eece9e155207b1db2370" + url: "https://pub.dev" + source: hosted + version: "3.1.1" +sdks: + dart: ">=2.19.0 <3.0.0" diff --git a/examples/supabase-edge-functions/pubspec.yaml b/examples/supabase-edge-functions/pubspec.yaml new file mode 100644 index 0000000..6ff86dc --- /dev/null +++ b/examples/supabase-edge-functions/pubspec.yaml @@ -0,0 +1,14 @@ +name: supabase_edge_functions_example +description: A Supaabase Edge Functions example written in Dart. +version: 1.0.0 +publish_to: none + +environment: + sdk: ">=2.18.5 <3.0.0" + +dependencies: + edge: ^0.0.5 + supabase_functions: ^0.0.1 + +dev_dependencies: + lints: ^2.0.1 \ No newline at end of file diff --git a/examples/supabase-edge-functions/supabase/.gitignore b/examples/supabase-edge-functions/supabase/.gitignore new file mode 100644 index 0000000..773c7c3 --- /dev/null +++ b/examples/supabase-edge-functions/supabase/.gitignore @@ -0,0 +1,3 @@ +# Supabase +.branches +.temp diff --git a/examples/supabase-edge-functions/supabase/config.toml b/examples/supabase-edge-functions/supabase/config.toml new file mode 100644 index 0000000..7e1e77d --- /dev/null +++ b/examples/supabase-edge-functions/supabase/config.toml @@ -0,0 +1,72 @@ +# A string used to distinguish different Supabase projects on the same host. Defaults to the working +# directory name when running `supabase init`. +project_id = "supabase-edge-functions" + +[api] +# Port to use for the API URL. +port = 54321 +# Schemas to expose in your API. Tables, views and stored procedures in this schema will get API +# endpoints. public and storage are always included. +schemas = ["public", "storage", "graphql_public"] +# Extra schemas to add to the search_path of every request. public is always included. +extra_search_path = ["public", "extensions"] +# The maximum number of rows returns from a view, table, or stored procedure. Limits payload size +# for accidental or malicious requests. +max_rows = 1000 + +[db] +# Port to use for the local database URL. +port = 54322 +# The database major version to use. This has to be the same as your remote database's. Run `SHOW +# server_version;` on the remote database to check. +major_version = 15 + +[studio] +# Port to use for Supabase Studio. +port = 54323 + +# Email testing server. Emails sent with the local dev setup are not actually sent - rather, they +# are monitored, and you can view the emails that would have been sent from the web interface. +[inbucket] +# Port to use for the email testing server web interface. +port = 54324 +smtp_port = 54325 +pop3_port = 54326 + +[storage] +# The maximum file size allowed (e.g. "5MB", "500KB"). +file_size_limit = "50MiB" + +[auth] +# The base URL of your website. Used as an allow-list for redirects and for constructing URLs used +# in emails. +site_url = "http://localhost:3000" +# A list of *exact* URLs that auth providers are permitted to redirect to post authentication. +additional_redirect_urls = ["https://localhost:3000"] +# How long tokens are valid for, in seconds. Defaults to 3600 (1 hour), maximum 604,800 seconds (one +# week). +jwt_expiry = 3600 +# Allow/disallow new user signups to your project. +enable_signup = true + +[auth.email] +# Allow/disallow new user signups via email to your project. +enable_signup = true +# If enabled, a user will be required to confirm any email change on both the old, and new email +# addresses. If disabled, only the new email is required to confirm. +double_confirm_changes = true +# If enabled, users need to confirm their email address before signing in. +enable_confirmations = false + +# Use an external OAuth provider. The full list of providers are: `apple`, `azure`, `bitbucket`, +# `discord`, `facebook`, `github`, `gitlab`, `google`, `keycloak`, `linkedin`, `notion`, `twitch`, +# `twitter`, `slack`, `spotify`, `workos`, `zoom`. +[auth.external.apple] +enabled = false +client_id = "" +secret = "" +# Overrides the default auth redirectUrl. +redirect_uri = "" +# Overrides the default auth provider URL. Used to support self-hosted gitlab, single-tenant Azure, +# or any other third-party OIDC providers. +url = "" diff --git a/examples/supabase-edge-functions/supabase/seed.sql b/examples/supabase-edge-functions/supabase/seed.sql new file mode 100644 index 0000000..e69de29 diff --git a/packages/supabase_functions/pubspec.lock b/packages/supabase_functions/pubspec.lock index ae22f0e..3642e26 100644 --- a/packages/supabase_functions/pubspec.lock +++ b/packages/supabase_functions/pubspec.lock @@ -108,24 +108,27 @@ packages: deno_deploy: dependency: "direct main" description: - path: "../deno_deploy" - relative: true - source: path - version: "0.0.1-dev.2" + name: deno_deploy + sha256: "3b6eef9d88d93e6144b9f9501481615ac1a55e8ca7ff4882250799eeb0d70840" + url: "https://pub.dev" + source: hosted + version: "0.0.1-dev.3" edge: dependency: "direct main" description: - path: "../edge" - relative: true - source: path - version: "0.0.5" + name: edge + sha256: f3c0c6e6e0845c64a8d44c6208a856dbf4a75b8a2d37aeb7a8a338f6c3433426 + url: "https://pub.dev" + source: hosted + version: "0.0.6" edge_runtime: dependency: "direct main" description: - path: "../edge_runtime" - relative: true - source: path - version: "0.0.3" + name: edge_runtime + sha256: "9ce28ef2c83f0db9eb857c4b433c1531c5bab31627cc6544727d4abc918570d7" + url: "https://pub.dev" + source: hosted + version: "0.0.3+1" file: dependency: transitive description: