Skip to content

Remove Native classes from Public API #555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 4 additions & 27 deletions firebase-database/api/android/firebase-database.api
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public final class dev/gitlive/firebase/database/DataSnapshot {
public final class dev/gitlive/firebase/database/DatabaseReference : dev/gitlive/firebase/database/Query {
public final fun child (Ljava/lang/String;)Ldev/gitlive/firebase/database/DatabaseReference;
public final fun getKey ()Ljava/lang/String;
public final fun getNativeReference ()Ldev/gitlive/firebase/database/NativeDatabaseReference;
public final fun onDisconnect ()Ldev/gitlive/firebase/database/OnDisconnect;
public final fun push ()Ldev/gitlive/firebase/database/DatabaseReference;
public final fun removeValue (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Expand All @@ -47,9 +46,11 @@ public final class dev/gitlive/firebase/database/DatabaseReference : dev/gitlive
public final fun setValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun setValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun setValue$default (Ldev/gitlive/firebase/database/DatabaseReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public final fun setValueEncoded (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun updateChildren (Ljava/util/Map;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun updateChildren (Ljava/util/Map;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun updateChildren$default (Ldev/gitlive/firebase/database/DatabaseReference;Ljava/util/Map;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public final fun updateEncodedChildren (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

public final class dev/gitlive/firebase/database/FirebaseDatabase {
Expand All @@ -68,41 +69,17 @@ public final class dev/gitlive/firebase/database/FirebaseDatabase {
public final class dev/gitlive/firebase/database/FirebaseDatabase$Companion {
}

public final class dev/gitlive/firebase/database/NativeDatabaseReference {
public final fun child (Ljava/lang/String;)Ldev/gitlive/firebase/database/NativeDatabaseReference;
public fun getAndroid ()Lcom/google/firebase/database/DatabaseReference;
public synthetic fun getAndroid ()Lcom/google/firebase/database/Query;
public final fun getDatabase ()Ldev/gitlive/firebase/database/FirebaseDatabase;
public final fun getKey ()Ljava/lang/String;
public final fun onDisconnect ()Ldev/gitlive/firebase/database/NativeOnDisconnect;
public final fun push ()Ldev/gitlive/firebase/database/NativeDatabaseReference;
public final fun removeValue (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun runTransaction (Lkotlinx/serialization/KSerializer;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun runTransaction$default (Ldev/gitlive/firebase/database/NativeDatabaseReference;Lkotlinx/serialization/KSerializer;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public final fun setValueEncoded (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun updateEncodedChildren (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

public final class dev/gitlive/firebase/database/NativeOnDisconnect {
public final fun cancel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getAndroid ()Lcom/google/firebase/database/OnDisconnect;
public final fun getDatabase ()Ldev/gitlive/firebase/database/FirebaseDatabase;
public final fun getPersistenceEnabled ()Z
public final fun removeValue (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun setValue (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun updateEncodedChildren (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

public final class dev/gitlive/firebase/database/OnDisconnect {
public final fun cancel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getNative ()Ldev/gitlive/firebase/database/NativeOnDisconnect;
public final fun removeValue (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun setEncodedValue (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why have these been added?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we have a bunch of inline methods that need access to the Native classes. Though those had been set as internal and annotated with @PublishedApi, this results in them still poping up in the API specification.

So it's essentially choosing between having the Native... classes in the api or these methods. I want for these because it makes the API "smaller"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify: these methods are also marked as@PublishedApi internal fun and the access the native classes inside their code. As a result the Native classes no longer need to be Published, but the method does because public inline methods can only call publish/Published code

public final fun setValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun setValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun setValue$default (Ldev/gitlive/firebase/database/OnDisconnect;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public final fun updateChildren (Ljava/util/Map;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun updateChildren (Ljava/util/Map;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun updateChildren$default (Ldev/gitlive/firebase/database/OnDisconnect;Ljava/util/Map;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public final fun updateEncodedChildren (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why have these been added?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

public class dev/gitlive/firebase/database/Query {
Expand Down
31 changes: 4 additions & 27 deletions firebase-database/api/jvm/firebase-database.api
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public final class dev/gitlive/firebase/database/DataSnapshot {
public final class dev/gitlive/firebase/database/DatabaseReference : dev/gitlive/firebase/database/Query {
public final fun child (Ljava/lang/String;)Ldev/gitlive/firebase/database/DatabaseReference;
public final fun getKey ()Ljava/lang/String;
public final fun getNativeReference ()Ldev/gitlive/firebase/database/NativeDatabaseReference;
public final fun onDisconnect ()Ldev/gitlive/firebase/database/OnDisconnect;
public final fun push ()Ldev/gitlive/firebase/database/DatabaseReference;
public final fun removeValue (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Expand All @@ -47,9 +46,11 @@ public final class dev/gitlive/firebase/database/DatabaseReference : dev/gitlive
public final fun setValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun setValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun setValue$default (Ldev/gitlive/firebase/database/DatabaseReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public final fun setValueEncoded (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun updateChildren (Ljava/util/Map;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun updateChildren (Ljava/util/Map;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun updateChildren$default (Ldev/gitlive/firebase/database/DatabaseReference;Ljava/util/Map;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public final fun updateEncodedChildren (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

public final class dev/gitlive/firebase/database/FirebaseDatabase {
Expand All @@ -68,41 +69,17 @@ public final class dev/gitlive/firebase/database/FirebaseDatabase {
public final class dev/gitlive/firebase/database/FirebaseDatabase$Companion {
}

public final class dev/gitlive/firebase/database/NativeDatabaseReference {
public final fun child (Ljava/lang/String;)Ldev/gitlive/firebase/database/NativeDatabaseReference;
public fun getAndroid ()Lcom/google/firebase/database/DatabaseReference;
public synthetic fun getAndroid ()Lcom/google/firebase/database/Query;
public final fun getDatabase ()Ldev/gitlive/firebase/database/FirebaseDatabase;
public final fun getKey ()Ljava/lang/String;
public final fun onDisconnect ()Ldev/gitlive/firebase/database/NativeOnDisconnect;
public final fun push ()Ldev/gitlive/firebase/database/NativeDatabaseReference;
public final fun removeValue (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun runTransaction (Lkotlinx/serialization/KSerializer;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun runTransaction$default (Ldev/gitlive/firebase/database/NativeDatabaseReference;Lkotlinx/serialization/KSerializer;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public final fun setValueEncoded (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun updateEncodedChildren (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

public final class dev/gitlive/firebase/database/NativeOnDisconnect {
public final fun cancel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getAndroid ()Lcom/google/firebase/database/OnDisconnect;
public final fun getDatabase ()Ldev/gitlive/firebase/database/FirebaseDatabase;
public final fun getPersistenceEnabled ()Z
public final fun removeValue (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun setValue (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun updateEncodedChildren (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

public final class dev/gitlive/firebase/database/OnDisconnect {
public final fun cancel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getNative ()Ldev/gitlive/firebase/database/NativeOnDisconnect;
public final fun removeValue (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun setEncodedValue (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun setValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun setValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun setValue$default (Ldev/gitlive/firebase/database/OnDisconnect;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public final fun updateChildren (Ljava/util/Map;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun updateChildren (Ljava/util/Map;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun updateChildren$default (Ldev/gitlive/firebase/database/OnDisconnect;Ljava/util/Map;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public final fun updateEncodedChildren (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

public class dev/gitlive/firebase/database/Query {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ public actual open class Query internal actual constructor(
override fun toString(): String = android.toString()
}

@PublishedApi
internal actual class NativeDatabaseReference internal constructor(
override val android: com.google.firebase.database.DatabaseReference,
persistenceEnabled: Boolean,
Expand Down Expand Up @@ -292,7 +291,6 @@ public actual class DataSnapshot internal constructor(
public actual val children: Iterable<DataSnapshot> get() = android.children.map { DataSnapshot(it, persistenceEnabled) }
}

@PublishedApi
internal actual class NativeOnDisconnect internal constructor(
val android: com.google.firebase.database.OnDisconnect,
val persistenceEnabled: Boolean,
Expand All @@ -309,7 +307,7 @@ internal actual class NativeOnDisconnect internal constructor(
.run { if (persistenceEnabled) await() else awaitWhileOnline(database) }
}

actual suspend fun setValue(encodedValue: Any?) {
actual suspend fun setEncodedValue(encodedValue: Any?) {
android.setValue(encodedValue)
.run { if (persistenceEnabled) await() else awaitWhileOnline(database) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ public expect open class Query internal constructor(nativeQuery: NativeQuery) {
public fun equalTo(value: Boolean, key: String? = null): Query
}

@PublishedApi
internal expect class NativeDatabaseReference : NativeQuery {
val key: String?
fun push(): NativeDatabaseReference
Expand All @@ -307,7 +306,7 @@ internal expect class NativeDatabaseReference : NativeQuery {
* This class is the starting point for all Database operations. After you've initialized it with
* a URL, you can use it to read data, write data, and to create new DatabaseReferences.
*/
public class DatabaseReference internal constructor(@PublishedApi internal val nativeReference: NativeDatabaseReference) : Query(nativeReference) {
public class DatabaseReference internal constructor(internal val nativeReference: NativeDatabaseReference) : Query(nativeReference) {
/**
* @return The last token in the location pointed to by this reference or null if this reference
* points to the database root
Expand Down Expand Up @@ -346,7 +345,7 @@ public class DatabaseReference internal constructor(@PublishedApi internal val n
}
}
public suspend inline fun <reified T> setValue(value: T?, buildSettings: EncodeSettings.Builder.() -> Unit = {}) {
nativeReference.setValueEncoded(encode(value, buildSettings))
setValueEncoded(encode(value, buildSettings))
}

@Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("setValue(strategy, value) { this.encodeDefaults = encodeDefaults }"))
Expand All @@ -356,7 +355,12 @@ public class DatabaseReference internal constructor(@PublishedApi internal val n
}
}
public suspend inline fun <T> setValue(strategy: SerializationStrategy<T>, value: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}) {
nativeReference.setValueEncoded(encode(strategy, value, buildSettings))
setValueEncoded(encode(strategy, value, buildSettings))
}

@PublishedApi
internal suspend fun setValueEncoded(encodedValue: Any?) {
nativeReference.setValueEncoded(encodedValue)
}

@Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("updateChildren(update) { this.encodeDefaults = encodeDefaults }"))
Expand All @@ -374,11 +378,16 @@ public class DatabaseReference internal constructor(@PublishedApi internal val n
* @return The {@link Task} for this operation.
*/
public suspend inline fun updateChildren(update: Map<String, Any?>, buildSettings: EncodeSettings.Builder.() -> Unit = {}) {
nativeReference.updateEncodedChildren(
updateEncodedChildren(
encodeAsObject(update, buildSettings),
)
}

@PublishedApi
internal suspend fun updateEncodedChildren(encodedUpdate: EncodedObject) {
nativeReference.updateEncodedChildren(encodedUpdate)
}

/**
* Set the value at this location to 'null'
*
Expand Down Expand Up @@ -478,11 +487,10 @@ public expect class DataSnapshot {
*/
public expect class DatabaseException(message: String?, cause: Throwable?) : RuntimeException

@PublishedApi
internal expect class NativeOnDisconnect {
suspend fun removeValue()
suspend fun cancel()
suspend fun setValue(encodedValue: Any?)
suspend fun setEncodedValue(encodedValue: Any?)
suspend fun updateEncodedChildren(encodedUpdate: EncodedObject)
}

Expand All @@ -494,7 +502,7 @@ internal expect class NativeOnDisconnect {
* Instances of this class are obtained by calling [DatabaseReference.onDisconnect]
* on a Firebase Database ref.
*/
public class OnDisconnect internal constructor(@PublishedApi internal val native: NativeOnDisconnect) {
public class OnDisconnect internal constructor(internal val native: NativeOnDisconnect) {
/**
* Remove the value at this location when the client disconnects
*
Expand Down Expand Up @@ -535,7 +543,7 @@ public class OnDisconnect internal constructor(@PublishedApi internal val native
* @param value The value to be set when a disconnect occurs or null to delete the existing value
*/
public suspend inline fun <reified T> setValue(value: T?, buildSettings: EncodeSettings.Builder.() -> Unit = {}) {
native.setValue(encode(value, buildSettings))
setEncodedValue(encode(value, buildSettings))
}

/**
Expand Down Expand Up @@ -565,13 +573,18 @@ public class OnDisconnect internal constructor(@PublishedApi internal val native
setValue(encode(strategy, value, buildSettings))
}

@PublishedApi
internal suspend fun setEncodedValue(encodedValue: Any?) {
native.setEncodedValue(encodedValue)
}

/**
* Ensure the data has the specified child values updated when the client is disconnected
*
* @param update The paths to update, along with their desired values
*/
public suspend inline fun updateChildren(update: Map<String, Any?>, buildSettings: EncodeSettings.Builder.() -> Unit = {}) {
native.updateEncodedChildren(
updateEncodedChildren(
encodeAsObject(update, buildSettings),
)
}
Expand All @@ -587,4 +600,9 @@ public class OnDisconnect internal constructor(@PublishedApi internal val native
this.encodeDefaults = encodeDefaults
}
}

@PublishedApi
internal suspend fun updateEncodedChildren(encodedUpdate: EncodedObject) {
native.updateEncodedChildren(encodedUpdate)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ public actual open class Query internal actual constructor(
override fun toString(): String = ios.toString()
}

@PublishedApi
internal actual class NativeDatabaseReference internal constructor(
override val ios: FIRDatabaseReference,
persistenceEnabled: Boolean,
Expand Down Expand Up @@ -236,7 +235,6 @@ public actual class DataSnapshot internal constructor(
public actual val children: Iterable<DataSnapshot> get() = ios.children.allObjects.map { DataSnapshot(it as FIRDataSnapshot, persistenceEnabled) }
}

@PublishedApi
internal actual class NativeOnDisconnect internal constructor(
val ios: FIRDatabaseReference,
val persistenceEnabled: Boolean,
Expand All @@ -249,7 +247,7 @@ internal actual class NativeOnDisconnect internal constructor(
ios.await(persistenceEnabled) { cancelDisconnectOperationsWithCompletionBlock(it) }
}

actual suspend fun setValue(encodedValue: Any?) {
actual suspend fun setEncodedValue(encodedValue: Any?) {
ios.await(persistenceEnabled) { onDisconnectSetValue(encodedValue, it) }
}

Expand Down
Loading
Loading