supabase-rb 2.0.0

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.
Files changed (74) hide show
  1. checksums.yaml +7 -0
  2. data/lib/supabase/README.md +90 -0
  3. data/lib/supabase/auth/README.md +172 -0
  4. data/lib/supabase/auth/admin_api.rb +218 -0
  5. data/lib/supabase/auth/admin_oauth_api.rb +51 -0
  6. data/lib/supabase/auth/api.rb +125 -0
  7. data/lib/supabase/auth/async/admin_api.rb +36 -0
  8. data/lib/supabase/auth/async/admin_oauth_api.rb +15 -0
  9. data/lib/supabase/auth/async/api.rb +32 -0
  10. data/lib/supabase/auth/async/client.rb +33 -0
  11. data/lib/supabase/auth/async.rb +14 -0
  12. data/lib/supabase/auth/client.rb +1217 -0
  13. data/lib/supabase/auth/constants.rb +32 -0
  14. data/lib/supabase/auth/errors.rb +207 -0
  15. data/lib/supabase/auth/helpers.rb +222 -0
  16. data/lib/supabase/auth/memory_storage.rb +25 -0
  17. data/lib/supabase/auth/storage.rb +19 -0
  18. data/lib/supabase/auth/timer.rb +40 -0
  19. data/lib/supabase/auth/types.rb +517 -0
  20. data/lib/supabase/auth/version.rb +7 -0
  21. data/lib/supabase/auth.rb +19 -0
  22. data/lib/supabase/client.rb +200 -0
  23. data/lib/supabase/client_options.rb +82 -0
  24. data/lib/supabase/functions/README.md +71 -0
  25. data/lib/supabase/functions/async/client.rb +45 -0
  26. data/lib/supabase/functions/async.rb +8 -0
  27. data/lib/supabase/functions/client.rb +174 -0
  28. data/lib/supabase/functions/errors.rb +38 -0
  29. data/lib/supabase/functions/types.rb +37 -0
  30. data/lib/supabase/functions/version.rb +7 -0
  31. data/lib/supabase/functions.rb +11 -0
  32. data/lib/supabase/postgrest/README.md +84 -0
  33. data/lib/supabase/postgrest/async/client.rb +50 -0
  34. data/lib/supabase/postgrest/async.rb +8 -0
  35. data/lib/supabase/postgrest/client.rb +136 -0
  36. data/lib/supabase/postgrest/errors.rb +49 -0
  37. data/lib/supabase/postgrest/request_builder.rb +657 -0
  38. data/lib/supabase/postgrest/types.rb +60 -0
  39. data/lib/supabase/postgrest/utils.rb +24 -0
  40. data/lib/supabase/postgrest/version.rb +7 -0
  41. data/lib/supabase/postgrest.rb +13 -0
  42. data/lib/supabase/realtime/README.md +90 -0
  43. data/lib/supabase/realtime/channel.rb +274 -0
  44. data/lib/supabase/realtime/client.rb +182 -0
  45. data/lib/supabase/realtime/errors.rb +19 -0
  46. data/lib/supabase/realtime/message.rb +38 -0
  47. data/lib/supabase/realtime/presence.rb +136 -0
  48. data/lib/supabase/realtime/push.rb +48 -0
  49. data/lib/supabase/realtime/socket.rb +40 -0
  50. data/lib/supabase/realtime/sockets/async_websocket.rb +175 -0
  51. data/lib/supabase/realtime/sockets/websocket_client_simple.rb +94 -0
  52. data/lib/supabase/realtime/test_socket.rb +65 -0
  53. data/lib/supabase/realtime/transformers.rb +26 -0
  54. data/lib/supabase/realtime/types.rb +70 -0
  55. data/lib/supabase/realtime/version.rb +7 -0
  56. data/lib/supabase/realtime.rb +18 -0
  57. data/lib/supabase/storage/README.md +108 -0
  58. data/lib/supabase/storage/analytics.rb +69 -0
  59. data/lib/supabase/storage/async/client.rb +52 -0
  60. data/lib/supabase/storage/async.rb +8 -0
  61. data/lib/supabase/storage/bucket_api.rb +65 -0
  62. data/lib/supabase/storage/client.rb +80 -0
  63. data/lib/supabase/storage/errors.rb +32 -0
  64. data/lib/supabase/storage/file_api.rb +281 -0
  65. data/lib/supabase/storage/request.rb +63 -0
  66. data/lib/supabase/storage/types.rb +236 -0
  67. data/lib/supabase/storage/utils.rb +35 -0
  68. data/lib/supabase/storage/vectors.rb +189 -0
  69. data/lib/supabase/storage/version.rb +7 -0
  70. data/lib/supabase/storage.rb +17 -0
  71. data/lib/supabase/version.rb +5 -0
  72. data/lib/supabase-auth.rb +3 -0
  73. data/lib/supabase.rb +63 -0
  74. metadata +272 -0
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "async/http/faraday"
4
+
5
+ require_relative "admin_oauth_api"
6
+
7
+ module Supabase
8
+ module Auth
9
+ module Async
10
+ # Async counterpart to {Supabase::Auth::AdminApi}.
11
+ #
12
+ # Inherits all admin methods (user CRUD, generate_link, invite, MFA admin,
13
+ # OAuth admin) and only swaps the Faraday adapter to async-http-faraday.
14
+ # `admin.oauth` returns an {Async::AdminOAuthApi} for naming consistency.
15
+ class AdminApi < Supabase::Auth::AdminApi
16
+ def initialize(url:, headers: {}, http_client: nil, verify: true, proxy: nil, timeout: nil)
17
+ super
18
+ @oauth = AdminOAuthApi.new(self)
19
+ end
20
+
21
+ private
22
+
23
+ def build_connection
24
+ Faraday.new(url: @url, ssl: { verify: @verify }, proxy: @proxy) do |f|
25
+ f.response :raise_error
26
+ if @timeout
27
+ f.options.timeout = @timeout
28
+ f.options.open_timeout = @timeout
29
+ end
30
+ f.adapter :async_http
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Supabase
4
+ module Auth
5
+ module Async
6
+ # Async counterpart to {Supabase::Auth::AdminOAuthApi}.
7
+ #
8
+ # Behavior is identical — it delegates to the wrapped {AdminApi}'s
9
+ # underscored methods. The wrapped admin uses the async Faraday adapter,
10
+ # so calls inside `Async do ... end` yield to the reactor on I/O.
11
+ class AdminOAuthApi < Supabase::Auth::AdminOAuthApi
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "async/http/faraday"
4
+
5
+ module Supabase
6
+ module Auth
7
+ module Async
8
+ # Async counterpart to {Supabase::Auth::Api}.
9
+ #
10
+ # Inherits everything (request dispatch, header merging, error mapping, JSON
11
+ # parsing) and only swaps the Faraday adapter to async-http-faraday so HTTP
12
+ # I/O yields back to the {::Async} reactor instead of blocking the thread.
13
+ #
14
+ # Call sites must run inside an `Async do ... end` block; outside one, the
15
+ # adapter still works but loses the concurrency win.
16
+ class Api < Supabase::Auth::Api
17
+ private
18
+
19
+ def build_connection
20
+ Faraday.new(url: @url, ssl: { verify: @verify }, proxy: @proxy) do |f|
21
+ f.response :raise_error
22
+ if @timeout
23
+ f.options.timeout = @timeout
24
+ f.options.open_timeout = @timeout
25
+ end
26
+ f.adapter :async_http
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "api"
4
+ require_relative "admin_api"
5
+
6
+ module Supabase
7
+ module Auth
8
+ module Async
9
+ # Async counterpart to {Supabase::Auth::Client}.
10
+ #
11
+ # Inherits the full public surface (sign_up, sign_in_with_password, get_user,
12
+ # set_session, refresh_session, MFA, identities, JWT claims, subscriptions,
13
+ # etc.) and rewires only the HTTP layer to use async-http-faraday:
14
+ #
15
+ # - `@api` is {Async::Api} instead of {::Supabase::Auth::Api}
16
+ # - `@admin` is {Async::AdminApi} instead of {::Supabase::Auth::AdminApi}
17
+ # - `@mfa` is unchanged — it dispatches through `@client._request`, which
18
+ # reaches the async `@api` via the parent's `_request` delegate
19
+ #
20
+ # Call sites must run inside an `Async do ... end` block (see docs/async_design.md
21
+ # §4 for usage examples and §6 for fiber/state semantics).
22
+ class Client < Supabase::Auth::Client
23
+ def initialize(url:, headers: {}, **options)
24
+ super
25
+ @api = Api.new(url: @url, headers: @headers, http_client: @http_client,
26
+ verify: @verify, proxy: @proxy, timeout: @timeout)
27
+ @admin = AdminApi.new(url: @url, headers: @headers, http_client: @http_client,
28
+ verify: @verify, proxy: @proxy, timeout: @timeout)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Convenience loader for the async variant. Production sync users do NOT need this —
4
+ # `require "supabase/auth"` ships zero async transitive deps. Users who want the
5
+ # async variant add `gem "async"` and `gem "async-http-faraday"` to their Gemfile,
6
+ # then `require "supabase/auth/async"`.
7
+ #
8
+ # See docs/async_design.md for the full architecture rationale.
9
+
10
+ require_relative "../auth"
11
+ require_relative "async/api"
12
+ require_relative "async/admin_oauth_api"
13
+ require_relative "async/admin_api"
14
+ require_relative "async/client"