Skip to content

Commit 98c4cac

Browse files
committed
feat: move integrations to separate repositories
1 parent 1f54ec8 commit 98c4cac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+129
-4387
lines changed

.github/workflows/lint.yml renamed to .github/workflows/ci.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: lint
1+
name: ci
22

33
on:
44
push:
@@ -28,7 +28,12 @@ jobs:
2828
run: docker login https://ghcr.io --username "$GHCR_USERNAME" --password "$GHCR_TOKEN"
2929
- name: Download latest earthly
3030
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/latest/download/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'"
31+
3132
- name: Earthly version
3233
run: earthly --version
33-
- name: Run lint
34-
run: earthly -P --build-arg GITHUB_REPO=${{ github.repository }} +ci
34+
35+
- name: Run CI
36+
run: earthly -P +ci
37+
38+
- name: Run Tests
39+
run: earthly -P +test

.github/workflows/docker.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

Earthfile

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
VERSION 0.7
22

3+
ARG MIX_ENV=test
4+
35
deps:
46
ARG ELIXIR=1.15.7
57
ARG OTP=26.1.2
6-
ARG MIX_ENV=test
78
FROM hexpm/elixir:${ELIXIR}-erlang-${OTP}-alpine-3.17.5
89
RUN apk add --no-cache build-base
910
WORKDIR /src
1011
RUN mix local.rebar --force
1112
RUN mix local.hex --force
1213
COPY mix.exs mix.lock ./
13-
COPY --dir apps . # check .earthlyignore
14+
COPY --dir lib . # check .earthlyignore
1415
RUN mix deps.get
1516
RUN mix deps.compile --force
1617
RUN mix compile
@@ -28,15 +29,5 @@ ci:
2829
test:
2930
FROM +deps
3031
COPY mix.exs mix.lock ./
31-
COPY --dir apps ./
32+
COPY --dir lib ./
3233
RUN mix test
33-
34-
docker:
35-
FROM +deps
36-
ENV MIX_ENV=dev
37-
RUN mix deps.compile
38-
COPY --dir apps ./
39-
RUN mix compile
40-
CMD ["iex", "-S", "mix"]
41-
ARG GITHUB_REPO=zoedsoupe/supabase
42-
SAVE IMAGE --push ghcr.io/$GITHUB_REPO:dev

README.md

Lines changed: 59 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,6 @@
1-
# Supabase Elixir SDK
1+
# Supabase Potion
22

3-
[![Hex.pm](https://img.shields.io/hexpm/v/supabase_potion.svg)](https://hex.pm/packages/supabase_potion)
4-
[![Downloads](https://img.shields.io/hexpm/dt/supabase_potion.svg)](https://hex.pm/packages/supabase_potion)
5-
[![Documentation](https://img.shields.io/badge/documentation-gray)](https://hexdocs.pm/supabase_potion)
6-
[![lint](https://github.com/zoedsoupe/supabase/actions/workflows/lint.yml/badge.svg)](https://github.com/zoedsoupe/supabase/actions/workflows/lint.yml)
7-
[![test](https://github.com/zoedsoupe/supabase/actions/workflows/test.yml/badge.svg)](https://github.com/zoedsoupe/supabase/actions/workflows/test.yml)
8-
9-
> Complete SDK and APIs integrations with Supabase
10-
11-
This monorepo houses the collection of Elixir SDK packages for integrating with Supabase, the open-source Firebase alternative. Our goal is to offer developers a seamless integration experience with Supabase services using Elixir.
12-
13-
## Packages Overview
14-
15-
- **Supabase Potion**: Main entrypoint for the Supabase SDK library, providing easy management for Supabase clients and connections. [Guide](./apps/supabase_potion/README.md).
16-
- **Supabase Storage**: Offers developers a way to store large objects like images, videos, and other files. [Guide](./guides/storage.md)
17-
- **Supabase PostgREST**: Directly turns your PostgreSQL database into a RESTful API using PostgREST. [Guide](#)
18-
- **Supabase Realtime**: Provides a realtime websocket API, enabling listening to database changes. [Guide](#)
19-
- **Supabase Auth**: A comprehensive user authentication system, complete with email sign-in, password recovery, session management, and more. [Guide](./apps/supabase_auth/README.md)
20-
- **Supabase UI**: UI components to help build Supabase-powered applications quickly. [Guide](#)
21-
- **Supabase Fetcher**: Customized HTTP client for making requests to Supabase APIs. [Guide](./guides/fetcher.md)
3+
Where the magic starts!
224

235
## Getting Started
246

@@ -34,89 +16,81 @@ def deps do
3416
end
3517
```
3618

37-
Then you can each package for the service you want to use. For example, if you want to use only the `Storage` integration:
38-
39-
```elixir
40-
def deps do
41-
[
42-
{:supabase_potion, "~> 0.3"},
43-
{:supabase_storage, "~> 0.2"}
44-
]
45-
end
46-
```
47-
48-
## Starting a Client
49-
50-
```elixir
51-
iex> Supabase.Client.init_client!(%{conn: %{base_url: "<supa-url>", api_key: "<supa-key>"}, name: MyClient})
52-
{:ok, #PID<0.123.0>}
53-
```
54-
55-
For more information, refer to the [supabase_potion](./apps/supabase_potion/README.md) readme!
56-
57-
## Supabase Services
58-
59-
The Supabase Elixir SDK allows you to interact with various Supabase services:
60-
61-
### Supabase Storage
62-
63-
Supabase Storage is a service for storing large objects like images, videos, and other files. It provides a simple API with strong consistency, similar to AWS S3.
64-
65-
### Supabase PostgREST
66-
67-
PostgREST is a web server that turns your PostgreSQL database into a RESTful API. It automatically generates API endpoints and operations based on your database's structure and permissions.
68-
69-
### Supabase Realtime
19+
### Clients
7020

71-
Supabase Realtime offers a realtime WebSocket API powered by PostgreSQL notifications. You can use it to listen to changes in your database and receive updates instantly as they happen.
21+
A `Supabase.Client` is an Agent that holds general information about Supabase, that can be used to intereact with any of the children integrations, for example: `Supabase.Storage` or `Supabase.UI`.
7222

73-
### Supabase Auth
23+
`Supabase.Client` is defined as:
7424

75-
Supabase Auth is a comprehensive user authentication system that includes features like email and password sign-in, email verification, password recovery, session management, and more, out of the box.
25+
- `:name` - the name of the client, started by `start_link/1`
26+
- `:conn` - connection information, the only required option as it is vital to the `Supabase.Client`.
27+
- `:base_url` - The base url of the Supabase API, it is usually in the form `https://<app-name>.supabase.io`.
28+
- `:api_key` - The API key used to authenticate requests to the Supabase API.
29+
- `:access_token` - Token with specific permissions to access the Supabase API, it is usually the same as the API key.
30+
- `:db` - default database options
31+
- `:schema` - default schema to use, defaults to `"public"`
32+
- `:global` - global options config
33+
- `:headers` - additional headers to use on each request
34+
- `:auth` - authentication options
35+
- `:auto_refresh_token` - automatically refresh the token when it expires, defaults to `true`
36+
- `:debug` - enable debug mode, defaults to `false`
37+
- `:detect_session_in_url` - detect session in URL, defaults to `true`
38+
- `:flow_type` - authentication flow type, defaults to `"web"`
39+
- `:persist_session` - persist session, defaults to `true`
40+
- `:storage` - storage type
41+
- `:storage_key` - storage key
7642

77-
### Supabase UI
43+
## Usage
7844

79-
Supabase UI provides a set of UI components to help you build Supabase-powered applications quickly. It's built on top of Tailwind CSS and Headless UI, and it's fully customizable. The package even includes `Phoenix.LiveView` components!
45+
The Supabase Elixir SDK provides a flexible way to manage `Supabase.Client` instances, which can, in turn, manage multiple `Supabase.Client` instances. Here's a brief overview of the key concepts:
8046

81-
### Supabase Fetcher
47+
### Starting a Client
8248

83-
Supabase Fetcher is a customized HTTP client for Supabase, mainly used in Supabase Potion. It gives you complete control over how you make requests to any Supabase API.
84-
85-
## General Roadmap
86-
87-
If you want to track integration-specific roadmaps, check their own README.
88-
89-
- [x] Fetcher to interact with the Supabase API in a low-level way
90-
- [x] Supabase Storage integration
91-
- [ ] Supabase UI for Phoenix Live View
92-
- [ ] Supabase Postgrest integration
93-
- [x] Supabase Auth integration
94-
- [ ] Supabase Realtime API integration
49+
You can start a client using the `Supabase.Client.start_link/1` function. However, it's recommended to use `Supabase.init_client!/1`, which allows you to pass client options and automatically manage `Supabase.Client` processes.
9550

51+
```elixir
52+
iex> Supabase.Client.init_client!(%{conn: %{base_url: "<supa-url>", api_key: "<supa-key>"}})
53+
{:ok, #PID<0.123.0>}
54+
```
9655

97-
## Why another Supabase package?
56+
## Configuration
9857

99-
Well, I tried to to use the [supabase-elixir](https://github.com/treebee/supabase-elixir) package but I had some strange behaviour and it didn't match some requirements of my project. So I started to search about Elixir-Supabase integrations and found some old, non-maintained packages that doesn't match some Elixir "idioms" and don't leverage the BEAM for a more integrated experience.
58+
Ensure your Supabase configurations are set:
10059

101-
Also I would like to contribute to OSS in some way and gain more experience with the BEAM and HTTP integrations too. So feel free to not to use, give some counter arguments and also contribute to these packages!
60+
```elixir
61+
import Config
10262

103-
## Credits & Inspirations
63+
config :supabase,
64+
manage_clients: false,
65+
supabase_base_url: System.fetch_env!("SUPABASE_BASE_URL"),
66+
supabase_api_key: System.fetch_env!("SUPABASE_API_KEY"),
67+
```
10468

105-
- [supabase-elixir](https://github.com/treebee/supabase-elixir)
106-
- [storage-js](https://github.com/supabase/storage-js)
69+
- `supabase_base_url`: The base URL of your Supabase project! More information on how to find it can be seen on the [next section](#how-to-find-my-supabase-base-url?)
70+
- `supabase_api_key`: The secret of your Supabase project! More information on how to find it can be seen on the [next section](#how-to-find-my-supabase-api-key?)
71+
- `manage_clients`: Enable or disable the internal client management by the library. Defauls to `true`, see more on the [library supervisor documentation](https://hexdocs.pm/supabase_potion/Supabase.ClientSupervisor.html).
10772

108-
## Contributing
73+
Make sure to set the environment variables `SUPABASE_BASE_URL` and `SUPABASE_API_KEY`.
10974

110-
Contributions, issues, and feature requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
75+
### How to find my Supabase base URL?
11176

112-
## Acknowledgements
77+
You can find your Supabase base URL in the Settings page of your project.
78+
Firstly select your project from the initial Dashboard.
79+
On the left sidebar, click on the Settings icon, then select API.
80+
The base URL is the first field on the page.
11381

114-
This SDK is a comprehensive representation of Supabase's client integrations. Thanks to the Supabase community for their support and collaboration.
82+
### How to find my Supabase API Key?
11583

116-
## License
84+
You can find your Supabase API key in the Settings page of your project.
85+
Firstly select your project from the initial Dashboard.
86+
On the left sidebar, click on the Settings icon, then select API.
87+
The API key is the second field on the page.
11788

118-
[MIT](LICENSE)
89+
There two types of API keys, the public and the private. The last one
90+
bypass any Row Level Security (RLS) rules you have set up.
91+
So you shouldn't use it in your frontend application.
11992

120-
---
93+
If you don't know what RLS is, you can read more about it here:
94+
https://supabase.com/docs/guides/auth/row-level-security
12195

122-
With the Supabase Elixir SDK, you have the tools you need to supercharge your Elixir applications by seamlessly integrating them with Supabase's powerful cloud services. Happy coding! 😄
96+
For most cases you should prefer to use the public "anon" Key.

apps/supabase_auth/.formatter.exs

Lines changed: 0 additions & 4 deletions
This file was deleted.

apps/supabase_auth/.gitignore

Lines changed: 0 additions & 40 deletions
This file was deleted.

apps/supabase_auth/LICENSE

Lines changed: 0 additions & 13 deletions
This file was deleted.

apps/supabase_auth/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)