suplex 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
suplex-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,285 @@
1
+ Metadata-Version: 2.4
2
+ Name: suplex
3
+ Version: 0.1.0
4
+ Summary: A Python library for interacting with Supabase REST API in Reflex applications
5
+ Author-email: Jeremy Medlin <jeremy.f.medlin@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/hjpr/suplex
8
+ Project-URL: Bug Tracker, https://github.com/hjpr/suplex/issues
9
+ Keywords: supabase,reflex,authentication,database
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Requires-Python: >=3.12
16
+ Description-Content-Type: text/markdown
17
+ Requires-Dist: dotenv>=0.9.9
18
+ Requires-Dist: pyjwt>=2.10.1
19
+ Requires-Dist: reflex>=0.7.3
20
+ Requires-Dist: httpx>=0.24.0
21
+
22
+ # Suplex
23
+
24
+ Suplex is a Python library that provides a clean interface for interacting with Supabase REST API in Reflex applications. It simplifies user authentication, session management, and database operations.
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ pip install suplex
30
+ ```
31
+
32
+ ## Features
33
+
34
+ - User authentication (sign-in, sign-up, OAuth providers)
35
+ - Session management with JWT tokens
36
+ - Database operations (select, insert, update, delete)
37
+ - Query filters and modifiers
38
+ - Synchronous and asynchronous execution
39
+
40
+ ## Quick Start
41
+
42
+ ### Initialize Suplex
43
+
44
+ ```python
45
+ from suplex import Suplex
46
+
47
+ # Initialize Suplex with your Supabase credentials
48
+ supabase = Suplex(
49
+ api_url="your-supabase-url",
50
+ api_key="your-api-key",
51
+ jwt_secret="your-jwt-secret",
52
+ service_role="your-service-role" # Optional: only for admin operations
53
+ )
54
+ ```
55
+
56
+ ### User Authentication
57
+
58
+ #### Sign Up
59
+
60
+ ```python
61
+ # Sign up a new user with email and password
62
+ supabase.auth.sign_up(
63
+ email="user@example.com",
64
+ password="secure-password"
65
+ )
66
+
67
+ # Sign up with additional metadata
68
+ supabase.auth.sign_up(
69
+ email="user@example.com",
70
+ password="secure-password",
71
+ options={
72
+ "data": {
73
+ "first_name": "John",
74
+ "last_name": "Doe"
75
+ }
76
+ }
77
+ )
78
+ ```
79
+
80
+ #### Sign In with Password
81
+
82
+ ```python
83
+ # Sign in with email and password
84
+ user = supabase.auth.sign_in_with_password(
85
+ email="user@example.com",
86
+ password="secure-password"
87
+ )
88
+ ```
89
+
90
+ #### Sign In with OAuth
91
+
92
+ ```python
93
+ import reflex as rx
94
+
95
+ class BaseState(rx.State):
96
+ def login_with_google(self):
97
+ redirect_url = supabase.auth.sign_in_with_oauth(
98
+ provider="google",
99
+ options={
100
+ "redirect_to": "https://your-app.com/auth/callback"
101
+ }
102
+ )
103
+ return rx.redirect(redirect_url)
104
+ ```
105
+
106
+ #### Get Current User
107
+
108
+ ```python
109
+ # Get the current authenticated user
110
+ user = supabase.auth.get_user()
111
+
112
+ # Get the current session info
113
+ session = supabase.auth.get_session()
114
+ ```
115
+
116
+ #### Update User
117
+
118
+ ```python
119
+ # Update user profile
120
+ updated_user = supabase.auth.update_user(
121
+ email="new-email@example.com",
122
+ user_metadata={
123
+ "first_name": "Updated",
124
+ "profile_picture": "https://example.com/picture.jpg"
125
+ }
126
+ )
127
+ ```
128
+
129
+ #### Logout
130
+
131
+ ```python
132
+ # Logout the current user
133
+ supabase.auth.logout()
134
+ ```
135
+
136
+ ### Database Operations
137
+
138
+ #### Select Data
139
+
140
+ ```python
141
+ # Select all columns from a table
142
+ response = supabase.table("users").select("*").execute()
143
+ users = response.json()
144
+
145
+ # Select specific columns
146
+ response = supabase.table("users").select("id, name, email").execute()
147
+ users = response.json()
148
+
149
+ # Select with filtering
150
+ response = supabase.table("users").select("*").eq("id", 123).execute()
151
+ user = response.json()
152
+ ```
153
+
154
+ #### Insert Data
155
+
156
+ ```python
157
+ # Insert a single row
158
+ response = supabase.table("users").insert({
159
+ "name": "John Doe",
160
+ "email": "john@example.com"
161
+ }).execute()
162
+
163
+ # Insert multiple rows
164
+ response = supabase.table("users").insert([
165
+ {"name": "Jane Doe", "email": "jane@example.com"},
166
+ {"name": "Bob Smith", "email": "bob@example.com"}
167
+ ]).execute()
168
+ ```
169
+
170
+ #### Update Data
171
+
172
+ ```python
173
+ # Update data
174
+ response = supabase.table("users").update({
175
+ "name": "Updated Name"
176
+ }).eq("id", 123).execute()
177
+ ```
178
+
179
+ #### Upsert Data
180
+
181
+ ```python
182
+ # Insert if not exists, update if exists
183
+ response = supabase.table("users").upsert({
184
+ "id": 123,
185
+ "name": "John Doe Updated",
186
+ "email": "john@example.com"
187
+ }).execute()
188
+ ```
189
+
190
+ #### Delete Data
191
+
192
+ ```python
193
+ # Delete data (CAUTION: this will match all rows by default!)
194
+ response = supabase.table("users").delete().eq("id", 123).execute()
195
+ ```
196
+
197
+ ### Using Filters
198
+
199
+ ```python
200
+ # Equal
201
+ response = supabase.table("users").select("*").eq("name", "John Doe").execute()
202
+
203
+ # Not equal
204
+ response = supabase.table("users").select("*").neq("status", "inactive").execute()
205
+
206
+ # Greater than
207
+ response = supabase.table("users").select("*").gt("age", 21).execute()
208
+
209
+ # Less than
210
+ response = supabase.table("users").select("*").lt("age", 65).execute()
211
+
212
+ # Like (case-sensitive pattern matching)
213
+ response = supabase.table("users").select("*").like("name", "%Doe%").execute()
214
+
215
+ # Case-insensitive pattern matching
216
+ response = supabase.table("users").select("*").ilike("name", "%doe%").execute()
217
+
218
+ # Check for null values
219
+ response = supabase.table("users").select("*").is_("deleted_at", "null").execute()
220
+
221
+ # Check for values in a list
222
+ response = supabase.table("users").select("*").in_("status", ["active", "pending"]).execute()
223
+ ```
224
+
225
+ ### Using Modifiers
226
+
227
+ ```python
228
+ # Order results
229
+ response = supabase.table("users").select("*").order("created_at", ascending=False).execute()
230
+
231
+ # Limit results
232
+ response = supabase.table("users").select("*").limit(10).execute()
233
+ ```
234
+
235
+ ### Async Operations
236
+
237
+ ```python
238
+ import asyncio
239
+
240
+ async def get_users():
241
+ # Async execution
242
+ response = await supabase.table("users").select("*").async_execute()
243
+ return response.json()
244
+
245
+ # Run the async function
246
+ users = asyncio.run(get_users())
247
+ ```
248
+
249
+ ### Error Handling
250
+
251
+ Suplex methods will raise exceptions for most errors. Use try/except blocks for production code:
252
+
253
+ ```python
254
+ try:
255
+ response = supabase.table("users").select("*").execute()
256
+ users = response.json()
257
+ except Exception as e:
258
+ # Handle error appropriately
259
+ print(f"Error fetching users: {e}")
260
+ ```
261
+
262
+ ### Row Level Security
263
+
264
+ When working with authenticated users, Supabase Row Level Security (RLS) policies will be applied. If you're not seeing data that should be available, check your RLS policies.
265
+
266
+ For admin operations that should bypass RLS, instantiate Suplex with the service_role parameter.
267
+
268
+ ### JWT Token Management
269
+
270
+ Suplex automatically manages JWT tokens, including refreshing them when they're close to expiration. The tokens are stored as cookies.
271
+
272
+ ## Advanced Usage
273
+
274
+ ### Custom HTTP Parameters
275
+
276
+ You can pass additional parameters to the underlying httpx client:
277
+
278
+ ```python
279
+ # Set a timeout for the request
280
+ response = supabase.table("users").select("*").execute(timeout=10.0)
281
+ ```
282
+
283
+ ## License
284
+
285
+ This project is licensed under the MIT License - see the LICENSE file for details.
suplex-0.1.0/README.md ADDED
@@ -0,0 +1,264 @@
1
+ # Suplex
2
+
3
+ Suplex is a Python library that provides a clean interface for interacting with Supabase REST API in Reflex applications. It simplifies user authentication, session management, and database operations.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install suplex
9
+ ```
10
+
11
+ ## Features
12
+
13
+ - User authentication (sign-in, sign-up, OAuth providers)
14
+ - Session management with JWT tokens
15
+ - Database operations (select, insert, update, delete)
16
+ - Query filters and modifiers
17
+ - Synchronous and asynchronous execution
18
+
19
+ ## Quick Start
20
+
21
+ ### Initialize Suplex
22
+
23
+ ```python
24
+ from suplex import Suplex
25
+
26
+ # Initialize Suplex with your Supabase credentials
27
+ supabase = Suplex(
28
+ api_url="your-supabase-url",
29
+ api_key="your-api-key",
30
+ jwt_secret="your-jwt-secret",
31
+ service_role="your-service-role" # Optional: only for admin operations
32
+ )
33
+ ```
34
+
35
+ ### User Authentication
36
+
37
+ #### Sign Up
38
+
39
+ ```python
40
+ # Sign up a new user with email and password
41
+ supabase.auth.sign_up(
42
+ email="user@example.com",
43
+ password="secure-password"
44
+ )
45
+
46
+ # Sign up with additional metadata
47
+ supabase.auth.sign_up(
48
+ email="user@example.com",
49
+ password="secure-password",
50
+ options={
51
+ "data": {
52
+ "first_name": "John",
53
+ "last_name": "Doe"
54
+ }
55
+ }
56
+ )
57
+ ```
58
+
59
+ #### Sign In with Password
60
+
61
+ ```python
62
+ # Sign in with email and password
63
+ user = supabase.auth.sign_in_with_password(
64
+ email="user@example.com",
65
+ password="secure-password"
66
+ )
67
+ ```
68
+
69
+ #### Sign In with OAuth
70
+
71
+ ```python
72
+ import reflex as rx
73
+
74
+ class BaseState(rx.State):
75
+ def login_with_google(self):
76
+ redirect_url = supabase.auth.sign_in_with_oauth(
77
+ provider="google",
78
+ options={
79
+ "redirect_to": "https://your-app.com/auth/callback"
80
+ }
81
+ )
82
+ return rx.redirect(redirect_url)
83
+ ```
84
+
85
+ #### Get Current User
86
+
87
+ ```python
88
+ # Get the current authenticated user
89
+ user = supabase.auth.get_user()
90
+
91
+ # Get the current session info
92
+ session = supabase.auth.get_session()
93
+ ```
94
+
95
+ #### Update User
96
+
97
+ ```python
98
+ # Update user profile
99
+ updated_user = supabase.auth.update_user(
100
+ email="new-email@example.com",
101
+ user_metadata={
102
+ "first_name": "Updated",
103
+ "profile_picture": "https://example.com/picture.jpg"
104
+ }
105
+ )
106
+ ```
107
+
108
+ #### Logout
109
+
110
+ ```python
111
+ # Logout the current user
112
+ supabase.auth.logout()
113
+ ```
114
+
115
+ ### Database Operations
116
+
117
+ #### Select Data
118
+
119
+ ```python
120
+ # Select all columns from a table
121
+ response = supabase.table("users").select("*").execute()
122
+ users = response.json()
123
+
124
+ # Select specific columns
125
+ response = supabase.table("users").select("id, name, email").execute()
126
+ users = response.json()
127
+
128
+ # Select with filtering
129
+ response = supabase.table("users").select("*").eq("id", 123).execute()
130
+ user = response.json()
131
+ ```
132
+
133
+ #### Insert Data
134
+
135
+ ```python
136
+ # Insert a single row
137
+ response = supabase.table("users").insert({
138
+ "name": "John Doe",
139
+ "email": "john@example.com"
140
+ }).execute()
141
+
142
+ # Insert multiple rows
143
+ response = supabase.table("users").insert([
144
+ {"name": "Jane Doe", "email": "jane@example.com"},
145
+ {"name": "Bob Smith", "email": "bob@example.com"}
146
+ ]).execute()
147
+ ```
148
+
149
+ #### Update Data
150
+
151
+ ```python
152
+ # Update data
153
+ response = supabase.table("users").update({
154
+ "name": "Updated Name"
155
+ }).eq("id", 123).execute()
156
+ ```
157
+
158
+ #### Upsert Data
159
+
160
+ ```python
161
+ # Insert if not exists, update if exists
162
+ response = supabase.table("users").upsert({
163
+ "id": 123,
164
+ "name": "John Doe Updated",
165
+ "email": "john@example.com"
166
+ }).execute()
167
+ ```
168
+
169
+ #### Delete Data
170
+
171
+ ```python
172
+ # Delete data (CAUTION: this will match all rows by default!)
173
+ response = supabase.table("users").delete().eq("id", 123).execute()
174
+ ```
175
+
176
+ ### Using Filters
177
+
178
+ ```python
179
+ # Equal
180
+ response = supabase.table("users").select("*").eq("name", "John Doe").execute()
181
+
182
+ # Not equal
183
+ response = supabase.table("users").select("*").neq("status", "inactive").execute()
184
+
185
+ # Greater than
186
+ response = supabase.table("users").select("*").gt("age", 21).execute()
187
+
188
+ # Less than
189
+ response = supabase.table("users").select("*").lt("age", 65).execute()
190
+
191
+ # Like (case-sensitive pattern matching)
192
+ response = supabase.table("users").select("*").like("name", "%Doe%").execute()
193
+
194
+ # Case-insensitive pattern matching
195
+ response = supabase.table("users").select("*").ilike("name", "%doe%").execute()
196
+
197
+ # Check for null values
198
+ response = supabase.table("users").select("*").is_("deleted_at", "null").execute()
199
+
200
+ # Check for values in a list
201
+ response = supabase.table("users").select("*").in_("status", ["active", "pending"]).execute()
202
+ ```
203
+
204
+ ### Using Modifiers
205
+
206
+ ```python
207
+ # Order results
208
+ response = supabase.table("users").select("*").order("created_at", ascending=False).execute()
209
+
210
+ # Limit results
211
+ response = supabase.table("users").select("*").limit(10).execute()
212
+ ```
213
+
214
+ ### Async Operations
215
+
216
+ ```python
217
+ import asyncio
218
+
219
+ async def get_users():
220
+ # Async execution
221
+ response = await supabase.table("users").select("*").async_execute()
222
+ return response.json()
223
+
224
+ # Run the async function
225
+ users = asyncio.run(get_users())
226
+ ```
227
+
228
+ ### Error Handling
229
+
230
+ Suplex methods will raise exceptions for most errors. Use try/except blocks for production code:
231
+
232
+ ```python
233
+ try:
234
+ response = supabase.table("users").select("*").execute()
235
+ users = response.json()
236
+ except Exception as e:
237
+ # Handle error appropriately
238
+ print(f"Error fetching users: {e}")
239
+ ```
240
+
241
+ ### Row Level Security
242
+
243
+ When working with authenticated users, Supabase Row Level Security (RLS) policies will be applied. If you're not seeing data that should be available, check your RLS policies.
244
+
245
+ For admin operations that should bypass RLS, instantiate Suplex with the service_role parameter.
246
+
247
+ ### JWT Token Management
248
+
249
+ Suplex automatically manages JWT tokens, including refreshing them when they're close to expiration. The tokens are stored as cookies.
250
+
251
+ ## Advanced Usage
252
+
253
+ ### Custom HTTP Parameters
254
+
255
+ You can pass additional parameters to the underlying httpx client:
256
+
257
+ ```python
258
+ # Set a timeout for the request
259
+ response = supabase.table("users").select("*").execute(timeout=10.0)
260
+ ```
261
+
262
+ ## License
263
+
264
+ This project is licensed under the MIT License - see the LICENSE file for details.
@@ -0,0 +1,35 @@
1
+ [build-system]
2
+ requires = ["setuptools >= 61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "suplex"
7
+ version = "0.1.0"
8
+ description = "A Python library for interacting with Supabase REST API in Reflex applications"
9
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ license = {text = "MIT"}
12
+ authors = [
13
+ {name = "Jeremy Medlin", email = "jeremy.f.medlin@gmail.com"}
14
+ ]
15
+ keywords = ["supabase", "reflex", "authentication", "database"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.12",
22
+ ]
23
+ dependencies = [
24
+ "dotenv>=0.9.9",
25
+ "pyjwt>=2.10.1",
26
+ "reflex>=0.7.3",
27
+ "httpx>=0.24.0",
28
+ ]
29
+
30
+ [project.urls]
31
+ "Homepage" = "https://github.com/hjpr/suplex"
32
+ "Bug Tracker" = "https://github.com/hjpr/suplex/issues"
33
+
34
+ [tool.setuptools.packages.find]
35
+ include = ["suplex", "suplex.*", "auth", "auth.*"]
suplex-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes
File without changes