diff --git a/packages/functions_client/lib/src/functions_client.dart b/packages/functions_client/lib/src/functions_client.dart index 84b44674..fdf0fe71 100644 --- a/packages/functions_client/lib/src/functions_client.dart +++ b/packages/functions_client/lib/src/functions_client.dart @@ -113,11 +113,11 @@ class FunctionsClient { ); final fields = body as Map?; - request = http.MultipartRequest(method.name, uri) + request = http.MultipartRequest(method.value, uri) ..fields.addAll(fields ?? {}) ..files.addAll(files); } else { - final bodyRequest = http.Request(method.name, uri); + final bodyRequest = http.Request(method.value, uri); if (body == null) { // No body to set diff --git a/packages/functions_client/lib/src/types.dart b/packages/functions_client/lib/src/types.dart index 4021e57f..a12b5c9a 100644 --- a/packages/functions_client/lib/src/types.dart +++ b/packages/functions_client/lib/src/types.dart @@ -4,11 +4,15 @@ import 'dart:typed_data'; import 'package:http/http.dart'; enum HttpMethod { - get, - post, - put, - delete, - patch, + get("GET"), + post("POST"), + put("PUT"), + delete("DELETE"), + patch("PATCH"); + + /// The uppercase HTTP method name. This should be used for a [Request] + final String value; + const HttpMethod(this.value); } class FunctionResponse { diff --git a/packages/functions_client/test/functions_dart_test.dart b/packages/functions_client/test/functions_dart_test.dart index 48074f2c..e3abb70e 100644 --- a/packages/functions_client/test/functions_dart_test.dart +++ b/packages/functions_client/test/functions_dart_test.dart @@ -186,7 +186,7 @@ void main() { ); final req = customHttpClient.receivedRequests.last; - expect(req.method, 'get'); + expect(req.method, 'GET'); }); test('PUT method', () async { @@ -196,7 +196,7 @@ void main() { ); final req = customHttpClient.receivedRequests.last; - expect(req.method, 'put'); + expect(req.method, 'PUT'); }); test('DELETE method', () async { @@ -206,7 +206,7 @@ void main() { ); final req = customHttpClient.receivedRequests.last; - expect(req.method, 'delete'); + expect(req.method, 'DELETE'); }); test('PATCH method', () async { @@ -216,7 +216,7 @@ void main() { ); final req = customHttpClient.receivedRequests.last; - expect(req.method, 'patch'); + expect(req.method, 'PATCH'); }); }); diff --git a/packages/supabase/lib/src/realtime_client_options.dart b/packages/supabase/lib/src/realtime_client_options.dart deleted file mode 100644 index 2c1ffb39..00000000 --- a/packages/supabase/lib/src/realtime_client_options.dart +++ /dev/null @@ -1,26 +0,0 @@ -import 'package:realtime_client/realtime_client.dart'; - -/// {@template realtime_client_options} -/// Options to pass to the RealtimeClient. -/// {@endtemplate} -class RealtimeClientOptions { - /// How many events the RealtimeClient can push in a second - /// - /// Defaults to 10 events per second - @Deprecated( - 'Client side rate limit has been removed. This option will be ignored.') - final int? eventsPerSecond; - - /// Level of realtime server logs to be logged - final RealtimeLogLevel? logLevel; - - /// the timeout to trigger push timeouts - final Duration? timeout; - - /// {@macro realtime_client_options} - const RealtimeClientOptions({ - this.eventsPerSecond, - this.logLevel, - this.timeout, - }); -} diff --git a/packages/supabase/lib/src/supabase_client.dart b/packages/supabase/lib/src/supabase_client.dart index 382569f8..aa51c921 100644 --- a/packages/supabase/lib/src/supabase_client.dart +++ b/packages/supabase/lib/src/supabase_client.dart @@ -330,6 +330,7 @@ class SupabaseClient { 'apikey': _supabaseKey, }, headers: {'apikey': _supabaseKey, ...headers}, + transport: options.webSocketTransport, logLevel: options.logLevel, httpClient: _authHttpClient, timeout: options.timeout ?? RealtimeConstants.defaultTimeout, diff --git a/packages/supabase/lib/src/supabase_client_options.dart b/packages/supabase/lib/src/supabase_client_options.dart index 3587e618..af24c51d 100644 --- a/packages/supabase/lib/src/supabase_client_options.dart +++ b/packages/supabase/lib/src/supabase_client_options.dart @@ -23,3 +23,47 @@ class StorageClientOptions { const StorageClientOptions({this.retryAttempts = 0}); } + +/// {@template realtime_client_options} +/// Options to pass to the RealtimeClient. +/// {@endtemplate} +class RealtimeClientOptions { + /// How many events the RealtimeClient can push in a second + /// + /// Defaults to 10 events per second + @Deprecated( + 'Client side rate limit has been removed. This option will be ignored.') + final int? eventsPerSecond; + + /// Level of realtime server logs to be logged + final RealtimeLogLevel? logLevel; + + /// the timeout to trigger push timeouts + final Duration? timeout; + + /// The WebSocket implementation to use + final WebSocketTransport? webSocketTransport; + + /// {@macro realtime_client_options} + const RealtimeClientOptions({ + this.eventsPerSecond, + this.logLevel, + this.timeout, + this.webSocketTransport, + }); + + RealtimeClientOptions copyWith({ + int? eventsPerSecond, + RealtimeLogLevel? logLevel, + Duration? timeout, + WebSocketTransport? webSocketTransport, + }) { + return RealtimeClientOptions( + // ignore: deprecated_member_use_from_same_package + eventsPerSecond: eventsPerSecond ?? this.eventsPerSecond, + logLevel: logLevel ?? this.logLevel, + timeout: timeout ?? this.timeout, + webSocketTransport: webSocketTransport ?? this.webSocketTransport, + ); + } +} diff --git a/packages/supabase/lib/supabase.dart b/packages/supabase/lib/supabase.dart index dc899cea..176b244e 100644 --- a/packages/supabase/lib/supabase.dart +++ b/packages/supabase/lib/supabase.dart @@ -11,7 +11,6 @@ export 'package:realtime_client/realtime_client.dart'; export 'package:storage_client/storage_client.dart'; export 'src/auth_user.dart'; -export 'src/realtime_client_options.dart'; export 'src/remove_subscription_result.dart'; export 'src/supabase_client.dart'; export 'src/supabase_client_options.dart';