diff options
| author | S. Solomon Darnell | 2025-03-28 21:52:21 -0500 |
|---|---|---|
| committer | S. Solomon Darnell | 2025-03-28 21:52:21 -0500 |
| commit | 4a52a71956a8d46fcb7294ac71734504bb09bcc2 (patch) | |
| tree | ee3dc5af3b6313e921cd920906356f5d4febc4ed /.venv/lib/python3.12/site-packages/realtime-2.4.1.dist-info | |
| parent | cc961e04ba734dd72309fb548a2f97d67d578813 (diff) | |
| download | gn-ai-master.tar.gz | |
Diffstat (limited to '.venv/lib/python3.12/site-packages/realtime-2.4.1.dist-info')
5 files changed, 289 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/realtime-2.4.1.dist-info/INSTALLER b/.venv/lib/python3.12/site-packages/realtime-2.4.1.dist-info/INSTALLER new file mode 100644 index 00000000..a1b589e3 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/realtime-2.4.1.dist-info/INSTALLER @@ -0,0 +1 @@ +pip diff --git a/.venv/lib/python3.12/site-packages/realtime-2.4.1.dist-info/LICENSE b/.venv/lib/python3.12/site-packages/realtime-2.4.1.dist-info/LICENSE new file mode 100644 index 00000000..ddeba6a0 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/realtime-2.4.1.dist-info/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Supabase + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/.venv/lib/python3.12/site-packages/realtime-2.4.1.dist-info/METADATA b/.venv/lib/python3.12/site-packages/realtime-2.4.1.dist-info/METADATA new file mode 100644 index 00000000..698f4785 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/realtime-2.4.1.dist-info/METADATA @@ -0,0 +1,224 @@ +Metadata-Version: 2.1 +Name: realtime +Version: 2.4.1 +Summary: +Home-page: https://github.com/supabase/realtime-py +License: MIT +Author: Joel Lee +Author-email: joel@joellee.org +Requires-Python: >=3.9,<4.0 +Classifier: License :: OSI Approved :: MIT License +Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 +Classifier: Programming Language :: Python :: 3.11 +Classifier: Programming Language :: Python :: 3.12 +Classifier: Programming Language :: Python :: 3.13 +Requires-Dist: aiohttp (>=3.11.13,<4.0.0) +Requires-Dist: python-dateutil (>=2.8.1,<3.0.0) +Requires-Dist: typing-extensions (>=4.12.2,<5.0.0) +Requires-Dist: websockets (>=11,<15) +Project-URL: Repository, https://github.com/supabase/realtime-py +Description-Content-Type: text/markdown + +<br /> +<p align="center"> + <a href="https://supabase.io"> + <picture> + <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/supabase/supabase/main/packages/common/assets/images/supabase-logo-wordmark--dark.svg"> + <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/supabase/supabase/main/packages/common/assets/images/supabase-logo-wordmark--light.svg"> + <img alt="Supabase Logo" width="300" src="https://raw.githubusercontent.com/supabase/supabase/main/packages/common/assets/images/logo-preview.jpg"> + </picture> + </a> + + <h1 align="center">Supabase Realtime Client</h1> + + <h3 align="center">Send ephemeral messages with <b>Broadcast</b>, track and synchronize state with <b>Presence</b>, and listen to database changes with <b>Postgres Change Data Capture (CDC)</b>.</h3> + + <p align="center"> + <a href="https://supabase.com/docs/guides/realtime">Guides</a> + · + <a href="https://supabase.com/docs/reference/python">Reference Docs</a> + · + <a href="https://multiplayer.dev">Multiplayer Demo</a> + </p> +</p> + +# Overview + +This client enables you to use the following Supabase Realtime's features: + +- **Broadcast**: send ephemeral messages from client to clients with minimal latency. Use cases include sharing cursor positions between users. +- **Presence**: track and synchronize shared state across clients with the help of CRDTs. Use cases include tracking which users are currently viewing a specific webpage. +- **Postgres Change Data Capture (CDC)**: listen for changes in your PostgreSQL database and send them to clients. + +# Usage + +## Installing the Package + +```bash +pip3 install realtime==2.0.0 +``` + +## Creating a Channel + +```python +import asyncio +from typing import Optional +from realtime.client import RealtimeClient +from realtime.channel import RealtimeSubscribeStates + +client = RealtimeClient(REALTIME_URL, API_KEY) +channel = client.channel('test-channel') + +def _on_subscribe(status: RealtimeSubscribeStates, err: Optional[Exception]): + if status == RealtimeSubscribeStates.SUBSCRIBED: + print('Connected!') + elif status == RealtimeSubscribeStates.CHANNEL_ERROR: + print(f'There was an error subscribing to channel: {err.message}') + elif status == RealtimeSubscribeStates.TIMED_OUT: + print('Realtime server did not respond in time.') + elif status == RealtimeSubscribeStates.CLOSED: + print('Realtime channel was unexpectedly closed.') + +await channel.subscribe(_on_subscribe) +``` + +### Notes: + +- `REALTIME_URL` is `ws://localhost:4000/socket` when developing locally and `wss://<project_ref>.supabase.co/realtime/v1` when connecting to your Supabase project. +- `API_KEY` is a JWT whose claims must contain `exp` and `role` (existing database role). +- Channel name can be any `string`. + +## Broadcast + +Your client can send and receive messages based on the `event`. + +```python +# Setup... + +channel = client.channel( + "broadcast-test", {"config": {"broadcast": {"ack": False, "self": False}}} +) + +await channel.on_broadcast("some-event", lambda payload: print(payload)).subscribe() +await channel.send_broadcast("some-event", {"hello": "world"}) +``` + +### Notes: + +- Setting `ack` to `true` means that the `channel.send` promise will resolve once server replies with acknowledgement that it received the broadcast message request. +- Setting `self` to `true` means that the client will receive the broadcast message it sent out. +- Setting `private` to `true` means that the client will use RLS to determine if the user can connect or not to a given channel. + +## Presence + +Your client can track and sync state that's stored in the channel. + +```python +# Setup... + +channel = client.channel( + "presence-test", + { + "config": { + "presence": { + "key": "" + } + } + } +) + +channel.on_presence_sync(lambda: print("Online users: ", channel.presence_state())) +channel.on_presence_join(lambda new_presences: print("New users have joined: ", new_presences)) +channel.on_presence_leave(lambda left_presences: print("Users have left: ", left_presences)) + +await channel.track({ 'user_id': 1 }) +``` + +## Postgres CDC + +Receive database changes on the client. + +```python +# Setup... + +channel = client.channel("db-changes") + +channel.on_postgres_changes( + "*", + schema="public", + callback=lambda payload: print("All changes in public schema: ", payload), +) + +channel.on_postgres_changes( + "INSERT", + schema="public", + table="messages", + callback=lambda payload: print("All inserts in messages table: ", payload), +) + +channel.on_postgres_changes( + "UPDATE", + schema="public", + table="users", + filter="username=eq.Realtime", + callback=lambda payload: print( + "All updates on users table when username is Realtime: ", payload + ), +) + +channel.subscribe( + lambda status, err: status == RealtimeSubscribeStates.SUBSCRIBED + and print("Ready to receive database changes!") +) +``` + +## Get All Channels + +You can see all the channels that your client has instantiated. + +```python +# Setup... + +client.get_channels() +``` + +## Cleanup + +It is highly recommended that you clean up your channels after you're done with them. + +- Remove a single channel + +```python +# Setup... + +channel = client.channel('some-channel-to-remove') + +channel.subscribe() + +await client.remove_channel(channel) +``` + +- Remove all channels + +```python +# Setup... + +channel1 = client.channel('a-channel-to-remove') +channel2 = client.channel('another-channel-to-remove') + +await channel1.subscribe() +await channel2.subscribe() + +await client.remove_all_channels() +``` + +## Credits + +This repo draws heavily from [phoenix-js](https://github.com/phoenixframework/phoenix/tree/master/assets/js/phoenix). + +## License + +MIT. + diff --git a/.venv/lib/python3.12/site-packages/realtime-2.4.1.dist-info/RECORD b/.venv/lib/python3.12/site-packages/realtime-2.4.1.dist-info/RECORD new file mode 100644 index 00000000..caa2d315 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/realtime-2.4.1.dist-info/RECORD @@ -0,0 +1,39 @@ +realtime-2.4.1.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4 +realtime-2.4.1.dist-info/LICENSE,sha256=M03Wgg4urqsgZOfFkAG4EFZnKKKKQafB2_abvuF9CTY,1065 +realtime-2.4.1.dist-info/METADATA,sha256=06kp8Hv7XhVEWN0ncNbzal4kDiPoF2q0S6mgqH7gfKY,6636 +realtime-2.4.1.dist-info/RECORD,, +realtime-2.4.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88 +realtime/__init__.py,sha256=Ei-CwmnWsJeM5q1v1BSM3L7ABl4I7bxVJBKnNWc6K_0,550 +realtime/__pycache__/__init__.cpython-312.pyc,, +realtime/__pycache__/exceptions.cpython-312.pyc,, +realtime/__pycache__/message.cpython-312.pyc,, +realtime/__pycache__/transformers.cpython-312.pyc,, +realtime/__pycache__/types.cpython-312.pyc,, +realtime/__pycache__/utils.cpython-312.pyc,, +realtime/__pycache__/version.cpython-312.pyc,, +realtime/_async/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +realtime/_async/__pycache__/__init__.cpython-312.pyc,, +realtime/_async/__pycache__/channel.cpython-312.pyc,, +realtime/_async/__pycache__/client.cpython-312.pyc,, +realtime/_async/__pycache__/presence.cpython-312.pyc,, +realtime/_async/__pycache__/push.cpython-312.pyc,, +realtime/_async/__pycache__/timer.cpython-312.pyc,, +realtime/_async/channel.py,sha256=D3J-j52RZ7hIrit4KxOXOXf5timNDGqTL8AkAaRSjQw,19769 +realtime/_async/client.py,sha256=gEAG3IUjTD6JkoklKac1Aj77ds4Kcl1FUW5E1rWFpFA,13767 +realtime/_async/presence.py,sha256=kfV5fFZv_-pJqKW0wloPoKW44iGybG8YpX59ENKHu_g,8510 +realtime/_async/push.py,sha256=WjvY2-V-qtGLHnOeOXcnz7_1ZmEH3Uia9z1E9e-RQDM,3527 +realtime/_async/timer.py,sha256=vVOVoIOR2sUb5vFcWCPir6rLOKkqduTv2N9nhFijriA,1266 +realtime/_sync/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +realtime/_sync/__pycache__/__init__.cpython-312.pyc,, +realtime/_sync/__pycache__/channel.cpython-312.pyc,, +realtime/_sync/__pycache__/client.cpython-312.pyc,, +realtime/_sync/__pycache__/presence.cpython-312.pyc,, +realtime/_sync/channel.py,sha256=J383NMz7FmProoQ0WfGohMp0uSsEVDx642m7B3uxPUg,905 +realtime/_sync/client.py,sha256=Xd7E6ZfVZPsHpL7QPmM1gbM67hxnzMM1FvuYvauPpaA,2858 +realtime/_sync/presence.py,sha256=WQc4JHKzrXmY33bjF9ohe3VCShoybCm54bsVDMRcEK0,242 +realtime/exceptions.py,sha256=kty0VTVUqpKp5-DmZDcoIrcPhnoMqUEzhM77BskhLw0,725 +realtime/message.py,sha256=nah9eYa-S9hTylk96wzbFUimd9lTqVXBtDlFaBLLHQ4,511 +realtime/transformers.py,sha256=-PVDpU5r6fDsrbpYw7rStf4nWwSjopS79gNAv53qUuc,273 +realtime/types.py,sha256=6OsfNMv5naPX2dL2v_MI416-YW6Cb02DElJJiR1_39Q,3432 +realtime/utils.py,sha256=qqUWg7X4x310-Pjz9Nv75D8lmWXr825yVv9cqJEB7l4,135 +realtime/version.py,sha256=kdOXnuKPCPWA3rbjZ8F61a_q_vWAqmoRoTuMoU9x9WM,52 diff --git a/.venv/lib/python3.12/site-packages/realtime-2.4.1.dist-info/WHEEL b/.venv/lib/python3.12/site-packages/realtime-2.4.1.dist-info/WHEEL new file mode 100644 index 00000000..8b9b3a1b --- /dev/null +++ b/.venv/lib/python3.12/site-packages/realtime-2.4.1.dist-info/WHEEL @@ -0,0 +1,4 @@ +Wheel-Version: 1.0 +Generator: poetry-core 1.9.1 +Root-Is-Purelib: true +Tag: py3-none-any |
