supabase-kt

A Kotlin Multiplatform Client for Supabase.

MIT License

Stars
389
Committers
22

Bot releases are hidden (Show)

supabase-kt - 2.1.0

Published by jan-tennert 9 months ago

Notes

The documentation has been updated accordingly.
It might take a bit to appear on Maven Central, as publishing seems to be broken right now

Changes

Add iOS targets to the chat-demo by @hieuwu in #397

Realtime

  • Add an option (Realtime.Config#disconnectOnNoSubscriptions) to automatically disconnect from the websocket, once there is no channel left, which defaults to true. (in #416 by @jan-tennert)
  • Remove the error for Realtime when a channel is already connected by @jollygreenegiant in https://github.com/supabase-community/supabase-kt/pull/430
  • Provide a new (experimental) way to listen to Realtime data (built on top of the existing ones) (in #386 by @jan-tennert):

Note: For both methods, the flows automatically emit the initial data and then listen for events using the existing methods.
Listen for changes in all messages (handles inserts, updates and deletes automatically and emits the updated list)

val messageFlow: Flow<List<Message>> = channel.postgresListDataFlow<Message>( //provide your serializable type (in this case Message)
    table = "messages",
    filter = FilterOperation("id", FilterOperator.IN, listOf(1, 2, 3, 4)), //optional filter
    primaryKey = Message::id //provide the primary key for caching
)

Listen for changes on a single value

val singleMessageFlow: Flow<Message> = channel.postgresSingleDataFlow<Message>( //Automatically emits the updated message and closes on delete
    table = "messages",
    primaryKey = Message::id
) { //this is the same filter builder the Postgrest plugin uses, so you can use everything:
    Message::id eq 2
    or {
        Message::creatorId isIn listOf("1", "2", "3")
        Message::content like "%test%"
    }
}

Listen to presence changes (joins & leaves are handled automatically)

val presenceFlow: Flow<List<User>> = channel.presenceDataFlow<User>()
  • Add a new method for adding a filter to postgres changes:
supabase.channel("channel").postgresChangeFlow<PostgresAction>("public") {
    //Still only one filter supported
    filter("id", FilterOperator.EQ, 2)
    //Note that some values get converted to strings e.g. the List<Int> to (1,2,3)
    filter("id", FilterOperator.IN, listOf(1, 2, 3, 4))
}

New methods:

  • RealtimeChannel#postgresSingleDataFlow
  • RealtimeChannel#postgresListDataFlow
  • RealtimeChannel#presenceDataFlow
  • RealtimeChannelBuilder#filter

GoTrue

Compose Auth

Postgrest

  • Fix nested logical operators by @jan-tennert in #435
supabase-kt - 2.1.0-rc-1

Published by jan-tennert 9 months ago

Docs PR open https://github.com/supabase/supabase/pull/20734

Changes

No changes since last beta

supabase-kt - 2.1.0-beta-1

Published by jan-tennert 9 months ago

I decided to skip wasm support this release and going to release 2.1.0 soon once the documentation update is up. Wasm will probably be in 2.2.0. Wasm support in Ktor is taking longer than expected.

Changes

Realtime

GoTrue

Compose Auth

supabase-kt - 2.1.0-alpha-2

Published by jan-tennert 9 months ago

Changes

It might take a while for the next stage/actual release as I'm still waiting to merge wasm support (blocked by ktor)

Realtime

supabase-kt - 2.1.0-alpha-1

Published by jan-tennert 10 months ago

Changes

Realtime

  • Add an option (Realtime.Config#disconnectOnNoSubscriptions) to automatically disconnect from the websocket, once there is no channel left, which defaults to true. (in #416 by @jan-tennert)
  • Provide a new way to listen to Realtime data (built on top of the existing ones) (in #386 by @jan-tennert):

Note: For both methods, the flows automatically emit the initial data and then listen for events using the existing methods.
Listen for changes in all messages (handles inserts, updates and deletes automatically and emits the updated list)

val messageFlow: Flow<List<Message>> = channel.postgresListDataFlow<Message>( //provide your serializable type (in this case Message)
    table = "messages",
    filter = FilterOperation("id", FilterOperator.IN, listOf(1, 2, 3, 4)), //optional filter
    primaryKey = Message::id //provide the primary key for caching
)

Listen for changes on a single value

val singleMessageFlow: Flow<Message> = channel.postgresSingleDataFlow<Message>( //Automatically emits the updated message and closes on delete
    table = "messages",
    primaryKey = Message::id
) { //this is the same filter builder the Postgrest plugin uses, so you can use everything:
    Message::id eq 2
    or {
        Message::creatorId isIn listOf("1", "2", "3")
        Message::content like "%test%"
    }
}

Listen to presence changes (joins & leaves are handled automatically)

val presenceFlow: Flow<List<User>> = channel.presenceDataFlow<User>()
  • Add a new method for adding a filter to postgres changes:
supabase.channel("channel").postgresChangeFlow<PostgresAction>("public") {
    //Still only one filter supported
    filter("id", FilterOperator.EQ, 2)
    //Note that some values get converted to strings e.g. the List<Int> to (1,2,3)
    filter("id", FilterOperator.IN, listOf(1, 2, 3, 4))
}

New methods:

  • RealtimeChannel#postgresSingleDataFlow
  • RealtimeChannel#postgresListDataFlow
  • RealtimeChannel#presenceDataFlow
  • RealtimeChannelBuilder#filter
supabase-kt - 2.0.4

Published by jan-tennert 10 months ago

(might take a little bit to appear on maven central)

Changes

Auth

New Contributors

supabase-kt - 2.0.3

Published by jan-tennert 10 months ago

Changes

Postgrest

  • Fix PostgrestFilterBuilder#textSearch producing an invalid query (by @jan-tennert in #409)
supabase-kt - 2.0.2-wasm0

Published by jan-tennert 10 months ago

Changes

Add wasm-js target in supabase-kt, gotrue-kt, realtime-kt, storage-kt, functions-kt, postgrest-kt

Notes

  • You have to add this repository: https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental
  • The wasm-js implementation works the same as js
  • mingwX64, linuxX64, macosX64 targets are not supported due to the experimental ktor version.
supabase-kt - 2.0.1

Published by jan-tennert 10 months ago

Changes

Auth

  • Fix linking identities via Auth#linkIdentity
  • Add updateLocalUser parameter to Auth#unlinkIdentity
  • Add utility method Auth#awaitInitialization, which blocks the current coroutine until the sessionStatus changes from SessionStatus.LoadingFromStorage.
supabase-kt - 2.0.0

Published by jan-tennert 10 months ago

Note

Migration guide
Documentation

Changes

Core

  • Add tag for all logging occurences

GoTrue

  • Rename and refactor GoTrue methods and classes (in #337 by @jan-tennert):
    • Rename GoTrue plugin to Auth
    • Rename GoTrueConfig to AuthConfig
    • Rename SupabaseClient#gotrue to SupabaseClient#auth
    • Rename Auth#loginWith to Auth#signInWith
    • Rename Auth#logout to Auth#signOut
    • Rename LogoutScope to SignOutScope
  • Remove Auth#sendOtpTo and add new OTP auth provider (in #350 by @jan-tennert):
supabase.auth.signInWith(OTP) {
    email = "[email protected]"
}
  • Refactor SSO auth to match other auth providers (in #351 by @jan-tennert):
supabase.auth.signInWith(SSO) {
    domain = "domain"
}
  • Rename AdminUserUpdateBuilder#phoneNumber to AdminUserUpdateBuilder#phone
  • Rename UserUpdateBuilder#phoneNumber to UserUpdateBuilder#phone
  • Rename Phone.Config#phoneNumber to Phone.Config#phone
  • Rename Auth#sendRecoveryEmail to Auth#resetPasswordForEmail and add PKCE support (in #367 by @jan-tennert)
  • Rework internal implementation of OAuth & SSO login
  • Add support for linking OAuth identities (experimental, untested as unsupported in hosted Supabase): (in #368 by @jan-tennert)
    • Add Auth#linkIdentity(OAuthProvider) - The works the same as signInWith(OAuthProvider) but links an additional OAuth provider to an authenticated user
    • Add Auth#unlinkIdentity(identityId)
    • Add Auth#currentIdentitiesOrNull

Realtime

  • Refactor and rename Realtime methods (in #349 by @jan-tennert):
    • Rename Realtime#createChannel to Realtime#channel
    • Remove RealtimeChannel#join and add new RealtimeChannel#subscribe method, which does the same but also connects to the realtime websocket automatically
    • Add Realtime.Config#connectOnSubscribe to disable this behaviour
    • Rename RealtimeChannel#leave to RealtimeChannel#unsubscribe
    • Add SupabaseClient#channel extension function delegating to Realtime#channel
    • Rename Realtime.Status to reflect the new methods:
      • UNSUBSCRIBED
      • SUBSCRIBING
      • SUBSCRIBED
      • UNSUBSCRIBING

Postgrest

  • Rename and refactor Postgrest methods (in #353 by @jan-tennert):
  • Remove upsert parameter in insert and update methods and add new upsert method
  • Remove returning, count and single parameters from postgrest methods
  • Rework postgrest methods:
val result = supabase.postgrest["messages"].select {
     single() //receive an object rather than an array
     count(Count.EXACT) //receive amount of database entries
     limit(10) //limit amount of results
     range(2, 3) //change range of results
     select() //return the data when updating/deleting/upserting (same as settings 'returning' to REPRESENTATION before)
     filter {
          eq("id", 1)
     }
}
  • Add new methods to this builder:
val result = supabase.postgrest["messages"].select {
     csv() //receive data as csv
     geojson() //receive data as geojson
     explain(/* */) //debug queries
}
  • Rename PostgrestResult#count to PostgrestResult#countOrNull
  • Reanem PostgrestResult#range to PostgrestResult#rangeOrNull
  • Add SupabaseClient#from delegating to Postgrest#from
  • Rename PostgrestResult#body to PostgrestResult#data
  • Change type of PostgrestResult#data to String
  • Allow destructuring of PostgrestResult: (especially handy when dealing with datatypes other than json)
val (data, headers) = supabase.from("countries").select {
    csv()
}

Compose Auth

  • Refactor and rename Realtime methods (in #345 by @jan-tennert):
    • Rename ComposeAuth#rememberLoginWithGoogle to ComposeAuth#rememberSignInWithGoogle
    • Rename ComposeAuth#rememberLoginWithApple to ComposeAuth#rememberSignInWithApple
    • Rename ComposeAuth#rememberSignOut to ComposeAuth#rememberSignOutWithGoogle
  • Re-implement Credential Manager Native Google Auth on Android 14+ (in #336 by @jan-tennert)

New module: Coil Integration

This new plugin can be added to a Coil ImageLoader to easily display images from public and non-public buckets from storage (Android only)
(in #323 by @jan-tennert).
Learn more

New module: Compose-ImageLoader Integration

This new plugin can be added to a ImageLoader to easily display images from public and non-public buckets from storage (All Compose targets) (in #335 by @jan-tennert).
Learn more

supabase-kt - 2.0.0-rc-1

Published by jan-tennert 11 months ago

Changes

No changes since last beta

Note

Final version will be released once the documentation update has been merged.

supabase-kt - 2.0.0-beta-2

Published by jan-tennert 11 months ago

Changes

Storage

  • Fix exception when trying to upload a file using an Android Uri (#370 fixed by #375)
supabase-kt - 2.0.0-beta-1

Published by jan-tennert 11 months ago

Note

If you can, please start to try out the 2.0.0 version(s) as there are alot of breaking changes from 1.5.X and I cannot test everything! :)
Migration guide will be on the development branch soon! Initial version: here

Changes

Core

  • Add tag for all logging occurences

GoTrue

  • Rename Auth#sendRecoveryEmail to Auth#resetPasswordForEmail and add PKCE support (in #367 by @jan-tennert)
  • Rework internal implementation of OAuth & SSO login
  • Add support for linking OAuth identities (experimental, untested as unsupported in hosted Supabase): (in #368 by @jan-tennert)
    • Add Auth#linkIdentity(OAuthProvider) - The works the same as signInWith(OAuthProvider) but links an additional OAuth provider to an authenticated user
    • Add Auth#unlinkIdentity(identityId)
    • Add Auth#currentIdentitiesOrNull
supabase-kt - 2.0.0-alpha-2

Published by jan-tennert 11 months ago

Changes

Core

  • Fix an issue causing the Authorization header not getting added to any request when Auth is not installed
  • Mark some DSL functions with an DSL marker
  • Update to Kotlin 1.9.21 to fix an issue with klib dependencies

Postgrest

  • Add columns parameter to PostgrestRequestBuilder#select to allow restricting which columns to receive when using UPDATE, DELETE, INSERT
supabase-kt - 2.0.0-alpha-1

Published by jan-tennert 11 months ago

Changes

Note: As this is a major version, this update contains breaking changes so be sure to read the changelog fully!
And feedback is definitely welcome and needed!

Core

  • Remove SupabaseClient#standaloneSupabaseModule (because this function was misused a lot, you can essentially do the same by creating a SupabaseClient and then just call SupabaseClient#module)

GoTrue

  • Rename and refactor GoTrue methods and classes (in #337 by @jan-tennert):
    • Rename GoTrue plugin to Auth
    • Rename GoTrueConfig to AuthConfig
    • Rename SupabaseClient#gotrue to SupabaseClient#auth
    • Rename Auth#loginWith to Auth#signInWith
    • Rename Auth#logout to Auth#signOut
    • Rename LogoutScope to SignOutScope
  • Remove Auth#sendOtpTo and add new OTP auth provider (in #350 by @jan-tennert):
supabase.auth.signInWith(OTP) {
    email = "[email protected]"
}
  • Refactor SSO auth to match other auth providers (in #351 by @jan-tennert):
supabase.auth.signInWith(SSO) {
    domain = "domain"
}
  • Rename AdminUserUpdateBuilder#phoneNumber to AdminUserUpdateBuilder#phone
  • Rename UserUpdateBuilder#phoneNumber to UserUpdateBuilder#phone
  • Rename Phone.Config#phoneNumber to Phone.Config#phone

Realtime

  • Refactor and rename Realtime methods (in #349 by @jan-tennert):
    • Rename Realtime#createChannel to Realtime#channel
    • Remove RealtimeChannel#join and add new RealtimeChannel#subscribe method, which does the same but also connects to the realtime websocket automatically
    • Add Realtime.Config#connectOnSubscribe to disable this behaviour
    • Rename RealtimeChannel#leave to RealtimeChannel#unsubscribe
    • Add SupabaseClient#channel extension function delegating to Realtime#channel
    • Rename Realtime.Status to reflect the new methods:
      • UNSUBSCRIBED
      • SUBSCRIBING
      • SUBSCRIBED
      • UNSUBSCRIBING

Postgrest

  • Rename and refactor Postgrest methods (in #353 by @jan-tennert):
  • Remove upsert parameter in insert and update methods and add new upsert method
  • Remove returning, count and single parameters from postgrest methods
  • Rework postgrest methods:
val result = supabase.postgrest["messages"].select {
     single() //receive an object rather than an array
     count(Count.EXACT) //receive amount of database entries
     limit(10) //limit amount of results
     range(2, 3) //change range of results
     select() //return the data when updating/deleting/upserting (same as settings 'returning' to REPRESENTATION before)
     filter {
          eq("id", 1)
     }
}
  • Add new methods to this builder:
val result = supabase.postgrest["messages"].select {
     csv() //receive data as csv
     geojson() //receive data as geojson
     explain(/* */) //debug queries
}
  • Rename PostgrestResult#count to PostgrestResult#countOrNull
  • Reanem PostgrestResult#range to PostgrestResult#rangeOrNull
  • Add SupabaseClient#from delegating to Postgrest#from
  • Rename PostgrestResult#body to PostgrestResult#data
  • Change type of PostgrestResult#data to String
  • Allow destructuring of PostgrestResult: (especially handy when dealing with datatypes other than json)
val (data, headers) = supabase.from("countries").select {
    csv()
}

Compose Auth

  • Refactor and rename Realtime methods (in #345 by @jan-tennert):
    • Rename ComposeAuth#rememberLoginWithGoogle to ComposeAuth#rememberSignInWithGoogle
    • Rename ComposeAuth#rememberLoginWithApple to ComposeAuth#rememberSignInWithApple
    • Rename ComposeAuth#rememberSignOut to ComposeAuth#rememberSignOutWithGoogle
  • Re-implement Credential Manager Native Google Auth on Android 14+ (in #336 by @jan-tennert)

New module: Coil Integration

This new plugin can be added to a Coil ImageLoader to easily display images from public and non-public buckets from storage (Android only)
(in #323 by @jan-tennert).
Learn more

New module: Compose-ImageLoader Integration

This new plugin can be added to a ImageLoader to easily display images from public and non-public buckets from storage (All Compose targets) (in #335 by @jan-tennert).
Learn more

supabase-kt - 1.5.0-alpha-1

Published by jan-tennert 11 months ago

Changes

GoTrue

  • Rename some classes/methods/properties to match other client libraries (in #337 by @jan-tennert):
    • GoTrue: DEPRECATED -> Replaced by Auth
    • supabaseClient#gotrue: DEPRECATED -> Replaced by supabaseClient#auth
    • GoTrue#loginWith: DEPRECATED -> Replaced by GoTrue#signInWith
    • GoTrueConfig -> Renamed to AuthConfig
    • GoTrueExt.kt -> Renamed to AuthExtensions.kt
    • GoTrueImpl -> Renamed to AuthImpl

This won't break existing apps, you will just get deprecation warnings

ComposeAuth

  • Re-implement Credential Manager Native Google Auth on Android 14+ (in #336 by @jan-tennert)

New module: Coil Integration

This new plugin can be added to a Coil ImageLoader to easily display images from public and non-public buckets from storage (Android only)
(in #323 by @jan-tennert).
Learn more

New module: Compose-ImageLoader Integration

This new plugin can be added to a ImageLoader to easily display images from public and non-public buckets from storage (All Compose targets) (in #335 by @jan-tennert).
Learn more

supabase-kt - 1.4.7

Published by jan-tennert 12 months ago

Changes

GoTrue

  • Change UserInfo#appMetadata type to JsonObject to allow access to all keys and values

Storage

  • Fix Storage documentation (by @shubhamsinghshubham777 in #329)
supabase-kt - 1.4.6

Published by jan-tennert 12 months ago

Changes

Core

  • Update to Kotlin 1.9.20 and Compose 1.5.10

Compose Auth

  • Downgrade play-store dependency to fix a error when using Native Google Auth
  • Use Google Identity for signing out on Android 14 (until 1.5.X)

GoTrue

  • Fix OAuth with Custom Tabs crashing
supabase-kt - 1.4.5

Published by jan-tennert 12 months ago

Changes

Postgrest

  • Add missing generic overload for PostgrestUpdate#set
  • Fix serialization with PostgrestUpdate when not using KotlinX Serialization
supabase-kt - 1.4.4

Published by jan-tennert 12 months ago