1use wasm_bindgen::prelude::*;
5
6#[wasm_bindgen(getter_with_clone)]
8pub struct Credentials {
9 pub email: String,
10 pub password: String,
11}
12
13#[wasm_bindgen(getter_with_clone)]
14pub struct SignInWithOAuthCredentials {
15 pub provider: String,
16 pub options: JsValue,
17}
18
19#[wasm_bindgen(getter_with_clone)]
20pub struct CurrentSession {
21 pub access_token: String,
22 pub refresh_token: String,
23}
24
25#[wasm_bindgen]
42extern "C" {
43
44 #[derive(Debug, Clone, PartialEq)]
45 pub type SupabaseClient;
46
47 #[wasm_bindgen(js_namespace = ["supabase"], js_name = createClient)]
50 pub fn create_client(supabase_url: &str, supabase_key: &str) -> SupabaseClient;
51
52 #[wasm_bindgen(method, js_name = from)]
53 pub fn from(this: &SupabaseClient, table: &str) -> Database;
54
55 pub type Database;
56
57 #[wasm_bindgen(method, catch, js_name = select)]
58 pub async fn select(this: &Database, columns: Option<&str>) -> Result<JsValue, JsValue>;
59 #[wasm_bindgen(method, js_name = select)]
60 pub fn select_(this: &Database, columns: Option<&str>) -> Database;
61
62 #[wasm_bindgen(method, catch, js_name = order)]
90 pub async fn order(this: &Database, column: &str, options: JsValue)
91 -> Result<JsValue, JsValue>;
92 #[wasm_bindgen(method, js_name = order)]
93 pub fn order_(this: &Database, column: &str, options: JsValue) -> Database;
94
95 #[wasm_bindgen(method, catch, js_name = limit)]
100 pub async fn limit(this: &Database, count: u32) -> Result<JsValue, JsValue>;
101 #[wasm_bindgen(method, js_name = limit)]
102 pub fn limit_(this: &Database, count: u32) -> Database;
103
104 #[wasm_bindgen(method, catch, js_name = range)]
109 pub async fn range(this: &Database, from: u32, to: u32) -> Result<JsValue, JsValue>;
110 #[wasm_bindgen(method, js_name = range)]
111 pub fn range_(this: &Database, from: u32, to: u32) -> Database;
112
113 #[wasm_bindgen(method, catch, js_name = single)]
118 pub async fn single(this: &Database) -> Result<JsValue, JsValue>;
119
120 #[wasm_bindgen(method, catch, js_name = maybeSingle)]
125 pub async fn maybe_single(this: &Database) -> Result<JsValue, JsValue>;
126
127 #[wasm_bindgen(method, catch, js_name = csv)]
136 pub async fn csv(this: &Database) -> Result<JsValue, JsValue>;
137
138 #[wasm_bindgen(method, catch, js_name = eq)]
143 pub async fn eq(this: &Database, column: &str, value: &JsValue) -> Result<JsValue, JsValue>;
144 #[wasm_bindgen(method, js_name = eq)]
145 pub fn eq_(this: &Database, column: &str, value: &JsValue) -> Database;
146
147 #[wasm_bindgen(method, catch, js_name = neq)]
152 pub async fn neq(this: &Database, column: &str, value: &JsValue) -> Result<JsValue, JsValue>;
153 #[wasm_bindgen(method, js_name = neq)]
154 pub fn neq_(this: &Database, column: &str, value: &JsValue) -> Database;
155
156 #[wasm_bindgen(method, catch, js_name = gt)]
161 pub async fn gt(this: &Database, column: &str, value: &JsValue) -> Result<JsValue, JsValue>;
162 #[wasm_bindgen(method, js_name = gt)]
163 pub fn gt_(this: &Database, column: &str, value: &JsValue) -> Database;
164
165 #[wasm_bindgen(method, catch, js_name = gte)]
170 pub async fn gte(this: &Database, column: &str, value: &JsValue) -> Result<JsValue, JsValue>;
171 #[wasm_bindgen(method, js_name = gte)]
172 pub fn gte_(this: &Database, column: &str, value: &JsValue) -> Database;
173
174 #[wasm_bindgen(method, catch, js_name = lt)]
179 pub async fn lt(this: &Database, column: &str, value: &JsValue) -> Result<JsValue, JsValue>;
180 #[wasm_bindgen(method, js_name = lt)]
181 pub fn lt_(this: &Database, column: &str, value: &JsValue) -> Database;
182
183 #[wasm_bindgen(method, catch, js_name = lte)]
188 pub async fn lte(this: &Database, column: &str, value: &JsValue) -> Result<JsValue, JsValue>;
189 #[wasm_bindgen(method, js_name = lte)]
190 pub fn lte_(this: &Database, column: &str, value: &JsValue) -> Database;
191
192 #[wasm_bindgen(method, catch, js_name = like)]
197 pub async fn like(this: &Database, column: &str, pattern: &str) -> Result<JsValue, JsValue>;
198 #[wasm_bindgen(method, js_name = like)]
199 pub fn like_(this: &Database, column: &str, pattern: &str) -> Database;
200
201 #[wasm_bindgen(method, catch, js_name = ilike)]
210 pub async fn ilike(this: &Database, column: &str, pattern: &str) -> Result<JsValue, JsValue>;
211 #[wasm_bindgen(method, js_name = ilike)]
212 pub fn ilike_(this: &Database, column: &str, pattern: &str) -> Database;
213
214 #[wasm_bindgen(method, catch, js_name = is)]
226 pub async fn is(this: &Database, column: &str, value: &JsValue) -> Result<JsValue, JsValue>;
227 #[wasm_bindgen(method, js_name = is)]
228 pub fn is_(this: &Database, column: &str, value: &JsValue) -> Database;
229
230 #[wasm_bindgen(method, catch, js_name = in)]
235 pub async fn r#in(
236 this: &Database,
237 column: &str,
238 values: Vec<JsValue>,
239 ) -> Result<JsValue, JsValue>;
240 #[wasm_bindgen(method, js_name = in)]
241 pub fn r#in_(this: &Database, column: &str, values: Vec<JsValue>) -> Database;
242
243 #[wasm_bindgen(method, catch, js_name = contains)]
248 pub async fn contains(
249 this: &Database,
250 column: &str,
251 value: JsValue,
252 ) -> Result<JsValue, JsValue>;
253 #[wasm_bindgen(method, js_name = contains)]
254 pub fn contains_(this: &Database, column: &str, value: JsValue) -> Database;
255
256 #[wasm_bindgen(method, catch, js_name = containedBy)]
261 pub async fn contained_by(
262 this: &Database,
263 column: &str,
264 value: JsValue,
265 ) -> Result<JsValue, JsValue>;
266 #[wasm_bindgen(method, js_name = containedBy)]
267 pub fn contained_by_(this: &Database, column: &str, value: JsValue) -> Database;
268
269 #[wasm_bindgen(method, catch, js_name = rangeGt)]
274 pub async fn range_gt(this: &Database, column: &str, range: &str) -> Result<JsValue, JsValue>;
275 #[wasm_bindgen(method, js_name = rangeGt)]
276 pub fn range_gt_(this: &Database, column: &str, range: &str) -> Database;
277
278 #[wasm_bindgen(method, catch, js_name = rangeGte)]
283 pub async fn range_gte(this: &Database, column: &str, range: &str) -> Result<JsValue, JsValue>;
284 #[wasm_bindgen(method, js_name = rangeGte)]
285 pub fn range_gte_(this: &Database, column: &str, range: &str) -> Database;
286
287 #[wasm_bindgen(method, catch, js_name = rangeLt)]
292 pub async fn range_lt(this: &Database, column: &str, range: &str) -> Result<JsValue, JsValue>;
293 #[wasm_bindgen(method, js_name = rangeLt)]
294 pub fn range_lt_(this: &Database, column: &str, range: &str) -> Database;
295
296 #[wasm_bindgen(method, catch, js_name = rangeLte)]
301 pub async fn range_lte(this: &Database, column: &str, range: &str) -> Result<JsValue, JsValue>;
302 #[wasm_bindgen(method, js_name = rangeLte)]
303 pub fn range_lte_(this: &Database, column: &str, range: &str) -> Database;
304
305 #[wasm_bindgen(method, catch, js_name = rangeAdjacent)]
310 pub async fn range_adjacent(
311 this: &Database,
312 column: &str,
313 range: &str,
314 ) -> Result<JsValue, JsValue>;
315 #[wasm_bindgen(method, js_name = rangeAdjacent)]
316 pub fn range_adjacent_(this: &Database, column: &str, range: &str) -> Database;
317
318 #[wasm_bindgen(method, catch, js_name = overlaps)]
323 pub async fn overlaps(
324 this: &Database,
325 column: &str,
326 value: JsValue,
327 ) -> Result<JsValue, JsValue>;
328 #[wasm_bindgen(method, js_name = overlaps)]
329 pub fn overlaps_(this: &Database, column: &str, value: JsValue) -> Database;
330
331 #[wasm_bindgen(method, catch, js_name = textSearch)]
336 pub async fn text_search(
337 this: &Database,
338 column: &str,
339 query: &str,
340 options: JsValue,
341 ) -> Result<JsValue, JsValue>;
342 #[wasm_bindgen(method, js_name = textSearch)]
343 pub fn text_search_(this: &Database, column: &str, query: &str, options: JsValue) -> Database;
344
345 #[wasm_bindgen(method, catch, js_name = update)]
350 pub async fn update(this: &Database, values: &JsValue) -> Result<JsValue, JsValue>;
351 #[wasm_bindgen(method, js_name = update)]
352 pub fn update_(this: &Database, values: &JsValue) -> Database;
353
354 #[wasm_bindgen(method, js_name = upsert)]
359 pub fn upsert(this: &Database, values: JsValue) -> Database;
360
361 #[wasm_bindgen(method, js_name = delete)]
371 pub fn delete(this: &Database) -> Database;
372
373 #[wasm_bindgen(method, catch, js_name = insert)]
378 pub async fn insert(this: &Database, values: JsValue) -> Result<JsValue, JsValue>;
379 #[wasm_bindgen(method, js_name = insert)]
380 pub fn insert_(this: &Database, values: JsValue) -> Database;
381
382 #[wasm_bindgen(method, getter = auth)]
384 pub fn auth(this: &SupabaseClient) -> Auth;
385
386 pub type Auth;
387
388 #[wasm_bindgen(method, catch, js_name = signInAnonymously)]
391 pub async fn sign_in_anonymously(this: &Auth) -> Result<JsValue, JsValue>;
392
393 #[wasm_bindgen(method, catch, js_name = signUp)]
396 pub async fn sign_up(this: &Auth, credentials: Credentials) -> Result<JsValue, JsValue>;
397
398 #[wasm_bindgen(method, catch, js_name = signInWithPassword)]
401 pub async fn sign_in_with_password(
402 this: &Auth,
403 credentials: Credentials,
404 ) -> Result<JsValue, JsValue>;
405
406 #[wasm_bindgen(method, catch, js_name = signInWithOtp)]
411 pub async fn sign_in_with_otp(this: &Auth, credentials: JsValue) -> Result<JsValue, JsValue>;
412
413 #[wasm_bindgen(method, catch, js_name = signInWithOAuth)]
418 pub async fn sign_in_with_oauth(
419 this: &Auth,
420 credentials: SignInWithOAuthCredentials,
421 ) -> Result<JsValue, JsValue>;
422
423 #[wasm_bindgen(method, catch, js_name = signOut)]
426 pub async fn sign_out(this: &Auth) -> Result<JsValue, JsValue>;
427
428 #[wasm_bindgen(method, catch, js_name = getSession)]
432 pub async fn get_session(this: &Auth) -> Result<JsValue, JsValue>;
433
434 #[wasm_bindgen(method, catch, js_name = refreshSession)]
438 pub async fn refresh_session(this: &Auth) -> Result<JsValue, JsValue>;
439
440 #[wasm_bindgen(method, catch, js_name = getUser)]
444 pub async fn get_user(this: &Auth, jwt: Option<&str>) -> Result<JsValue, JsValue>;
445
446 #[wasm_bindgen(method, catch, js_name = updateUser)]
451 pub async fn update_user(this: &Auth, attributes: JsValue) -> Result<JsValue, JsValue>;
452
453 #[wasm_bindgen(method, catch, js_name = setSession)]
454 pub async fn set_session(
455 this: &Auth,
456 current_session: CurrentSession,
457 ) -> Result<JsValue, JsValue>;
458
459 #[wasm_bindgen(method, js_name = onAuthStateChange)]
472 pub fn on_auth_state_change(this: &Auth, callback: &Closure<dyn FnMut(JsValue, JsValue)>);
473
474 #[wasm_bindgen(method, catch, js_name = resetPasswordForEmail)]
479 pub async fn reset_password_for_email(
480 this: &Auth,
481 email: &str,
482 options: JsValue,
483 ) -> Result<JsValue, JsValue>;
484
485 #[wasm_bindgen(method, js_name = channel)]
501 pub fn channel(this: &SupabaseClient, name: &str) -> RealtimeChannel;
502
503 #[wasm_bindgen(method, js_name = removeAllChannels)]
506 pub fn remove_all_channels(this: &SupabaseClient);
507
508 #[wasm_bindgen(method, js_name = getChannels)]
511 pub fn get_channels(this: &SupabaseClient) -> JsValue;
512
513 pub type RealtimeChannel;
514
515 #[wasm_bindgen(method, js_name = on)]
518 pub fn on(
519 this: &RealtimeChannel,
520 r#type: &str,
521 filter: &JsValue,
522 callback: &Closure<dyn Fn(JsValue)>,
523 ) -> RealtimeChannel;
524
525 #[wasm_bindgen(method, js_name = subscribe)]
526 pub fn subscribe(
527 this: &RealtimeChannel,
528 callback: Option<&Closure<dyn FnMut(JsValue, JsValue)>>,
529 ) -> RealtimeChannel;
530
531 #[wasm_bindgen(method, js_name = storage)]
532 pub fn storage(this: &SupabaseClient) -> Storage;
533
534 pub type Storage;
535
536 #[wasm_bindgen(method, catch, js_name = createBucket)]
541 pub async fn create_bucket(this: &Storage, id: &str) -> Result<JsValue, JsValue>;
542
543 #[wasm_bindgen(method, catch, js_name = getBucket)]
548 pub async fn get_bucket(this: &Storage, id: &str) -> Result<JsValue, JsValue>;
549
550 #[wasm_bindgen(method, catch, js_name = listBuckets)]
555 pub async fn list_buckets(this: &Storage) -> Result<JsValue, JsValue>;
556
557 #[wasm_bindgen(method, catch, js_name = updateBucket)]
562 pub async fn update_bucket(this: &Storage, options: JsValue) -> Result<JsValue, JsValue>;
563
564 #[wasm_bindgen(method, catch, js_name = emptyBucket)]
569 pub async fn empty_bucket(this: &Storage, id: &str) -> Result<JsValue, JsValue>;
570
571 #[wasm_bindgen(method, catch, js_name = deleteBucket)]
576 pub async fn delete_bucket(this: &Storage, id: &str) -> Result<JsValue, JsValue>;
577
578}