Skip to content

Commit

Permalink
Remove deprecated methods/classes and stabilize some features
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-tennert committed Nov 19, 2023
1 parent 13255f8 commit 6c7b8eb
Show file tree
Hide file tree
Showing 15 changed files with 14 additions and 246 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package io.github.jan.supabase.functions

import io.github.jan.supabase.SupabaseClient
import io.github.jan.supabase.SupabaseSerializer
import io.github.jan.supabase.annotations.SupabaseExperimental
import io.github.jan.supabase.annotations.SupabaseInternal
import io.github.jan.supabase.encode
import io.github.jan.supabase.exceptions.BadRequestRestException
Expand Down Expand Up @@ -126,7 +125,6 @@ class Functions(override val config: Config, override val supabaseClient: Supaba
override var jwtToken: String? = null,
) : MainConfig, CustomSerializationConfig {

@SupabaseExperimental
override var serializer: SupabaseSerializer? = null

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package io.github.jan.supabase.gotrue

import co.touchlab.kermit.Logger
import io.github.jan.supabase.SupabaseClient
import io.github.jan.supabase.annotations.SupabaseExperimental
import io.github.jan.supabase.gotrue.user.UserSession
import kotlinx.coroutines.launch
import platform.Foundation.NSURL
Expand All @@ -15,7 +14,6 @@ import platform.Foundation.NSURLQueryItem
* @param url The url from the ios app delegate
* @param onSessionSuccess The callback when the session was successfully imported
*/
@SupabaseExperimental
fun SupabaseClient.handleDeeplinks(url: NSURL, onSessionSuccess: (UserSession) -> Unit = {}) {
if (url.scheme != auth.config.scheme || url.host != auth.config.host) {
Logger.d { "Received deeplink with wrong scheme or host" }
Expand Down
104 changes: 0 additions & 104 deletions GoTrue/src/commonMain/kotlin/io/github/jan/supabase/gotrue/Auth.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package io.github.jan.supabase.gotrue

import co.touchlab.kermit.Logger
import io.github.jan.supabase.SupabaseClient
import io.github.jan.supabase.encodeToJsonElement
import io.github.jan.supabase.exceptions.HttpRequestException
import io.github.jan.supabase.exceptions.RestException
import io.github.jan.supabase.gotrue.admin.AdminApi
Expand All @@ -11,7 +10,6 @@ import io.github.jan.supabase.gotrue.providers.AuthProvider
import io.github.jan.supabase.gotrue.providers.ExternalAuthConfigDefaults
import io.github.jan.supabase.gotrue.providers.Google
import io.github.jan.supabase.gotrue.providers.OAuthProvider
import io.github.jan.supabase.gotrue.providers.builtin.DefaultAuthProvider
import io.github.jan.supabase.gotrue.providers.builtin.Email
import io.github.jan.supabase.gotrue.providers.builtin.Phone
import io.github.jan.supabase.gotrue.providers.builtin.SSO
Expand All @@ -23,8 +21,6 @@ import io.github.jan.supabase.plugins.MainPlugin
import io.github.jan.supabase.plugins.SupabasePluginProvider
import io.ktor.client.plugins.HttpRequestTimeoutException
import kotlinx.coroutines.flow.StateFlow
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.jsonObject

/**
* Plugin to interact with the Supabase Auth API
Expand Down Expand Up @@ -103,33 +99,6 @@ sealed interface Auth : MainPlugin<AuthConfig>, CustomSerializationPlugin {
config: (C.() -> Unit)? = null
): R?

/**
* Logins the user with the specified [provider]
*
* Example:
* ```kotlin
* val result = gotrue.signInWith(Email) {
* email = "[email protected]"
* password = "password"
* }
* or
* gotrue.signInWith(Google) // Opens the browser to login with google
* ```
*
* @param provider the provider to use for signing up. E.g. [Email], [Phone] or [Google]
* @param redirectUrl The redirect url to use. If you don't specify this, the platform specific will be used, like deeplinks on android.
* @param config The configuration to use for the sign-up.
* @throws RestException or one of its subclasses if receiving an error response
* @throws HttpRequestTimeoutException if the request timed out
* @throws HttpRequestException on network related issues
*/
@Deprecated("Use signInWith instead", ReplaceWith("signInWith(provider, redirectUrl, config)"))
suspend fun <C, R, Provider : AuthProvider<C, R>> loginWith(
provider: Provider,
redirectUrl: String? = null,
config: (C.() -> Unit)? = null
) = signInWith(provider, redirectUrl, config)

/**
* Signs in the user with the specified [provider]
*
Expand Down Expand Up @@ -177,33 +146,6 @@ sealed interface Auth : MainPlugin<AuthConfig>, CustomSerializationPlugin {
config: UserUpdateBuilder.() -> Unit
): UserInfo

/**
* Sends a one time password to the specified [provider]
*
* Example:
* ```kotlin
* gotrue.sendOtpTo(Email) {
* email = "[email protected]"
* password = "password"
* }
* ```
*
* @param provider The provider to use. Either [Email] or [Phone]
* @param createUser Whether to create a user when a user with the given credentials doesn't exist
* @param redirectUrl The redirect url to use. If you don't specify this, the platform specific will be use, like deeplinks on android.
* @throws RestException or one of its subclasses if receiving an error response
* @throws HttpRequestTimeoutException if the request timed out
* @throws HttpRequestException on network related issues
*/
@Deprecated("Use signInWith(OTP) instead", level = DeprecationLevel.WARNING)
suspend fun <C, R, Provider : DefaultAuthProvider<C, R>> sendOtpTo(
provider: Provider,
createUser: Boolean = false,
redirectUrl: String? = null,
data: JsonObject? = null,
config: C.() -> Unit
)

/**
* Resends an existing signup confirmation email, email change email
* @param type The email otp type
Expand Down Expand Up @@ -293,17 +235,6 @@ sealed interface Auth : MainPlugin<AuthConfig>, CustomSerializationPlugin {
*/
suspend fun signOut(scope: SignOutScope = SignOutScope.LOCAL)

/**
* Logs out the current user, which means [sessionStatus] will be [SessionStatus.NotAuthenticated] and the access token will be revoked
* @param scope The scope of the logout.
* @throws RestException or one of its subclasses if receiving an error response
* @throws HttpRequestTimeoutException if the request timed out
* @throws HttpRequestException on network related issues
* @see SignOutScope
*/
@Deprecated("Use signOut instead", ReplaceWith("signOut(scope)", "io.github.jan.supabase.gotrue.SignOutScope"), DeprecationLevel.WARNING)
suspend fun logout(scope: SignOutScope = SignOutScope.LOCAL) = signOut(scope)

/**
* Imports a user session and starts auto-refreshing if [autoRefresh] is true
*/
Expand Down Expand Up @@ -404,41 +335,6 @@ sealed interface Auth : MainPlugin<AuthConfig>, CustomSerializationPlugin {

}

/**
* Sends a one time password to the specified [provider]
*
* Example:
* ```kotlin
* gotrue.sendOtpTo(Email) {
* email = "[email protected]"
* password = "password"
* }
* ```
*
* @param provider The provider to use. Either [Email] or [Phone]
* @param createUser Whether to create a user when a user with the given credentials doesn't exist
* @param redirectUrl The redirect url to use. If you don't specify this, the platform specific will be used, like deeplinks on android.
* @throws RestException or one of its subclasses if receiving an error response
* @throws HttpRequestTimeoutException if the request timed out
* @throws HttpRequestException on network related issues
*/
suspend inline fun <C, R, reified D : Any, Provider : DefaultAuthProvider<C, R>> Auth.sendOtpTo(
provider: Provider,
data: D,
createUser: Boolean = false,
redirectUrl: String? = null,
noinline config: C.() -> Unit = { }
): Unit = sendOtpTo(provider, createUser, redirectUrl, this.serializer.encodeToJsonElement(data).jsonObject, config)

/**
* The Auth plugin handles everything related to supabase's authentication system
*
* **DEPRECATED** Use [auth] instead
*/
@Deprecated("Use auth instead", ReplaceWith("auth", "io.github.jan.supabase.gotrue.auth"), DeprecationLevel.WARNING)
val SupabaseClient.gotrue: GoTrue
get() = pluginManager.getPlugin(GoTrue)

/**
* The Auth plugin handles everything related to Supabase's authentication system
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package io.github.jan.supabase.gotrue

import io.github.jan.supabase.SupabaseClientBuilder
import io.github.jan.supabase.SupabaseSerializer
import io.github.jan.supabase.annotations.SupabaseExperimental
import io.github.jan.supabase.plugins.CustomSerializationConfig
import io.github.jan.supabase.plugins.MainConfig
import kotlinx.coroutines.CoroutineDispatcher
Expand Down Expand Up @@ -93,6 +92,5 @@ enum class FlowType {
*
* Note: OTP's via a link and sign up verification links are not supported on desktop. Replace your email template to send the token instead.
*/
@SupabaseExperimental
PKCE
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package io.github.jan.supabase.postgrest

import io.github.jan.supabase.SupabaseClient
import io.github.jan.supabase.SupabaseSerializer
import io.github.jan.supabase.annotations.SupabaseExperimental
import io.github.jan.supabase.plugins.CustomSerializationConfig
import io.github.jan.supabase.plugins.CustomSerializationPlugin
import io.github.jan.supabase.plugins.MainConfig
Expand Down Expand Up @@ -70,7 +69,6 @@ sealed interface Postgrest : MainPlugin<Postgrest.Config>, CustomSerializationPl
var propertyConversionMethod: PropertyConversionMethod = PropertyConversionMethod.CAMEL_CASE_TO_SNAKE_CASE,
): MainConfig, CustomSerializationConfig {

@SupabaseExperimental
override var serializer: SupabaseSerializer? = null

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,6 @@ sealed interface Realtime : MainPlugin<Realtime.Config>, CustomSerializationPlug

}

/**
* Creates a new [RealtimeChannel]
*/
@Deprecated("Use channel instead", ReplaceWith("channel(channelId, builder)", "io.github.jan.supabase.realtime"))
inline fun Realtime.createChannel(channelId: String, builder: RealtimeChannelBuilder.() -> Unit = {}): RealtimeChannel {
return RealtimeChannelBuilder("realtime:$channelId", this as RealtimeImpl).apply(builder).build()
}

/**
* Creates a new [RealtimeChannel]
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@ sealed interface RealtimeChannel {
@SupabaseInternal
val callbackManager: CallbackManager

/**
* Joins the channel
* @param blockUntilJoined if true, the method will block until the [status] is [Status.JOINED]
*/
@Deprecated("Use subscribe instead", ReplaceWith("subscribe(blockUntilJoined)"))
suspend fun join(blockUntilJoined: Boolean = false) = subscribe(blockUntilJoined)

/**
* Subscribes to the channel
* @param blockUntilSubscribed if true, the method will block the coroutine until the [status] is [Status.JOINED]
Expand All @@ -53,12 +46,6 @@ sealed interface RealtimeChannel {
*/
suspend fun updateAuth(jwt: String)

/**
* Leaves the channel
*/
@Deprecated("Use unsubscribe instead", ReplaceWith("unsubscribe()"))
suspend fun leave() = unsubscribe()

/**
* Unsubscribes from the channel
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.github.jan.supabase.storage

import android.net.Uri
import io.github.jan.supabase.annotations.SupabaseExperimental
import io.ktor.utils.io.ByteReadChannel
import io.ktor.utils.io.jvm.javaio.toByteReadChannel

Expand All @@ -12,7 +11,6 @@ import io.ktor.utils.io.jvm.javaio.toByteReadChannel
* @param upsert Whether to overwrite an existing file
* @return the key to the updated file
*/
@SupabaseExperimental
suspend fun BucketApi.upload(path: String, uri: Uri, upsert: Boolean = false) = upload(path, UploadData(uri.readChannel(), uri.contentSize), upsert)

/**
Expand All @@ -22,7 +20,6 @@ suspend fun BucketApi.upload(path: String, uri: Uri, upsert: Boolean = false) =
* @param upsert Whether to overwrite an existing file
* @return A flow that emits the upload progress and at last the key to the updated file
*/
@SupabaseExperimental
fun BucketApi.uploadAsFlow(path: String, uri: Uri, upsert: Boolean = false) = uploadAsFlow(path, UploadData(uri.readChannel(), uri.contentSize), upsert)

/**
Expand All @@ -32,7 +29,6 @@ fun BucketApi.uploadAsFlow(path: String, uri: Uri, upsert: Boolean = false) = up
* @param uri The uri to upload
* @return the key to the updated file
*/
@SupabaseExperimental
suspend fun BucketApi.uploadToSignedUrl(path: String, token: String, uri: Uri, upsert: Boolean = false) = uploadToSignedUrl(path, token, UploadData(uri.readChannel(), uri.contentSize), upsert)

/**
Expand All @@ -43,7 +39,6 @@ suspend fun BucketApi.uploadToSignedUrl(path: String, token: String, uri: Uri, u
* @param upsert Whether to overwrite an existing file
* @return A flow that emits the upload progress and at last the key to the updated file
*/
@SupabaseExperimental
fun BucketApi.uploadToSignedUrlAsFlow(path: String, token: String, uri: Uri, upsert: Boolean = false) = uploadToSignedUrlAsFlow(path, token, UploadData(uri.readChannel(), uri.contentSize), upsert)

/**
Expand All @@ -53,7 +48,6 @@ fun BucketApi.uploadToSignedUrlAsFlow(path: String, token: String, uri: Uri, ups
* @param upsert Whether to overwrite an existing file
* @return the key to the updated file
*/
@SupabaseExperimental
suspend fun BucketApi.update(path: String, uri: Uri, upsert: Boolean = false) = update(path, UploadData(uri.readChannel(), uri.contentSize), upsert)

/**
Expand All @@ -63,11 +57,12 @@ suspend fun BucketApi.update(path: String, uri: Uri, upsert: Boolean = false) =
* @param upsert Whether to overwrite an existing file
* @return A flow that emits the upload progress and at last the key to the updated file
*/
@SupabaseExperimental
fun BucketApi.updateAsFlow(path: String, uri: Uri, upsert: Boolean = false) = updateAsFlow(path, UploadData(uri.readChannel(), uri.contentSize), upsert)

private fun Uri.readChannel(): ByteReadChannel {
val context = applicationContext()
val inputStream = context.contentResolver.openInputStream(this) ?: throw IllegalArgumentException("Uri is not readable")
return inputStream.toByteReadChannel()
return inputStream.use {
it.toByteReadChannel()
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.github.jan.supabase.storage

import io.github.jan.supabase.SupabaseClient
import io.github.jan.supabase.annotations.SupabaseExperimental
import io.github.jan.supabase.exceptions.HttpRequestException
import io.github.jan.supabase.exceptions.RestException
import io.github.jan.supabase.gotrue.Auth
Expand Down Expand Up @@ -29,7 +28,6 @@ sealed interface BucketApi {
/**
* The client for interacting with the resumable upload api
*/
@SupabaseExperimental
val resumable: ResumableClient

/**
Expand Down
Loading

0 comments on commit 6c7b8eb

Please sign in to comment.