diff --git a/firebase-firestore/api/android/firebase-firestore.api b/firebase-firestore/api/android/firebase-firestore.api index 9dea82602..acbd2f13e 100644 --- a/firebase-firestore/api/android/firebase-firestore.api +++ b/firebase-firestore/api/android/firebase-firestore.api @@ -68,20 +68,16 @@ public final class dev/gitlive/firebase/firestore/DocumentReference { public final fun snapshots (Z)Lkotlinx/coroutines/flow/Flow; public static synthetic fun snapshots$default (Ldev/gitlive/firebase/firestore/DocumentReference;ZILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow; public fun toString ()Ljava/lang/String; + public final fun update (Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun update (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun update (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; public static synthetic fun update$default (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; public final fun updateEncoded (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun updateEncodedFieldPathsAndValues (Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun updateEncodedFieldsAndValues (Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun updateFieldPaths ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static synthetic fun updateFieldPaths$default (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; - public final fun updateFieldPathsWithEncodableValue ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static synthetic fun updateFieldPathsWithEncodableValue$default (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; public final fun updateFields ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static synthetic fun updateFields$default (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; - public final fun updateFieldsWithEncodableValues ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static synthetic fun updateFieldsWithEncodableValues$default (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; } public final class dev/gitlive/firebase/firestore/DocumentReference$Companion { @@ -135,21 +131,6 @@ public final class dev/gitlive/firebase/firestore/DoubleAsTimestampSerializer : public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V } -public final class dev/gitlive/firebase/firestore/EncodableValue { - public fun (Lkotlin/jvm/functions/Function1;)V - public final fun component1 ()Lkotlin/jvm/functions/Function1; - public final fun copy (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/EncodableValue; - public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/EncodableValue;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/EncodableValue; - public fun equals (Ljava/lang/Object;)Z - public final fun getEncoded ()Lkotlin/jvm/functions/Function1; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class dev/gitlive/firebase/firestore/EncodableValueKt { - public static final fun encodableWithStrategy (Ljava/lang/Object;Lkotlinx/serialization/SerializationStrategy;)Ldev/gitlive/firebase/firestore/EncodableValue; -} - public final class dev/gitlive/firebase/firestore/FieldPath { public static final field Companion Ldev/gitlive/firebase/firestore/FieldPath$Companion; public fun ([Ljava/lang/String;)V @@ -180,6 +161,13 @@ public final class dev/gitlive/firebase/firestore/FieldValue$Companion { public final fun serializer ()Lkotlinx/serialization/KSerializer; } +public final class dev/gitlive/firebase/firestore/FieldValueBuilder { + public final fun addEncoded (Ljava/lang/Object;)V + public final fun addWithStrategy (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V + public final fun getBuildSettings ()Lkotlin/jvm/functions/Function1; + public final fun setBuildSettings (Lkotlin/jvm/functions/Function1;)V +} + public final class dev/gitlive/firebase/firestore/FieldValueSerializer : kotlinx/serialization/KSerializer { public static final field INSTANCE Ldev/gitlive/firebase/firestore/FieldValueSerializer; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/gitlive/firebase/firestore/FieldValue; @@ -189,6 +177,15 @@ public final class dev/gitlive/firebase/firestore/FieldValueSerializer : kotlinx public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V } +public final class dev/gitlive/firebase/firestore/FieldsAndValuesBuilder { + public final fun getBuildSettings ()Lkotlin/jvm/functions/Function1; + public final fun setBuildSettings (Lkotlin/jvm/functions/Function1;)V + public final fun to (Ldev/gitlive/firebase/firestore/FieldPath;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V + public final fun to (Ljava/lang/String;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V + public final fun toEncoded (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)V + public final fun toEncoded (Ljava/lang/String;Ljava/lang/Object;)V +} + public abstract class dev/gitlive/firebase/firestore/Filter { } @@ -360,12 +357,6 @@ public final class dev/gitlive/firebase/firestore/GeoPointSerializer : kotlinx/s public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V } -public final class dev/gitlive/firebase/firestore/HelpersKt { - public static final fun encodeFieldAndValue ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Ljava/util/List; - public static final fun performUpdateFieldPaths ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ljava/util/List; - public static final fun performUpdateFields ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ljava/util/List; -} - public abstract interface class dev/gitlive/firebase/firestore/LocalCacheSettings { } @@ -451,15 +442,13 @@ public final class dev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings public class dev/gitlive/firebase/firestore/Query { public static final field Companion Ldev/gitlive/firebase/firestore/Query$Companion; public final fun endAt (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Ldev/gitlive/firebase/firestore/Query; + public final fun endAt (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; public final fun endAt ([Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; public static synthetic fun endAt$default (Ldev/gitlive/firebase/firestore/Query;[Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; - public final fun endAtWithEncodableValue ([Ldev/gitlive/firebase/firestore/EncodableValue;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; - public static synthetic fun endAtWithEncodableValue$default (Ldev/gitlive/firebase/firestore/Query;[Ldev/gitlive/firebase/firestore/EncodableValue;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; public final fun endBefore (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Ldev/gitlive/firebase/firestore/Query; + public final fun endBefore (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; public final fun endBefore ([Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; public static synthetic fun endBefore$default (Ldev/gitlive/firebase/firestore/Query;[Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; - public final fun endBeforeWithEncodableValue ([Ldev/gitlive/firebase/firestore/EncodableValue;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; - public static synthetic fun endBeforeWithEncodableValue$default (Ldev/gitlive/firebase/firestore/Query;[Ldev/gitlive/firebase/firestore/EncodableValue;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; public final fun get (Ldev/gitlive/firebase/firestore/Source;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static synthetic fun get$default (Ldev/gitlive/firebase/firestore/Query;Ldev/gitlive/firebase/firestore/Source;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; public final fun getSnapshots ()Lkotlinx/coroutines/flow/Flow; @@ -471,15 +460,13 @@ public class dev/gitlive/firebase/firestore/Query { public final fun snapshots (Z)Lkotlinx/coroutines/flow/Flow; public static synthetic fun snapshots$default (Ldev/gitlive/firebase/firestore/Query;ZILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow; public final fun startAfter (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Ldev/gitlive/firebase/firestore/Query; + public final fun startAfter (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; public final fun startAfter ([Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; public static synthetic fun startAfter$default (Ldev/gitlive/firebase/firestore/Query;[Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; - public final fun startAfterWithEncodableValue ([Ldev/gitlive/firebase/firestore/EncodableValue;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; - public static synthetic fun startAfterWithEncodableValue$default (Ldev/gitlive/firebase/firestore/Query;[Ldev/gitlive/firebase/firestore/EncodableValue;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; public final fun startAt (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Ldev/gitlive/firebase/firestore/Query; + public final fun startAt (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; public final fun startAt ([Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; public static synthetic fun startAt$default (Ldev/gitlive/firebase/firestore/Query;[Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; - public final fun startAtWithEncodableValue ([Ldev/gitlive/firebase/firestore/EncodableValue;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; - public static synthetic fun startAtWithEncodableValue$default (Ldev/gitlive/firebase/firestore/Query;[Ldev/gitlive/firebase/firestore/EncodableValue;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; public final fun where (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; } @@ -595,21 +582,16 @@ public final class dev/gitlive/firebase/firestore/Transaction { public fun toString ()Ljava/lang/String; public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;Z)Ldev/gitlive/firebase/firestore/Transaction; + public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Z)Ldev/gitlive/firebase/firestore/Transaction; public static synthetic fun update$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; public static synthetic fun update$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; public final fun updateEncoded (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/internal/EncodedObject;)Ldev/gitlive/firebase/firestore/Transaction; - public final fun updateEncodedFieldPathsAndValues (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Transaction; - public final fun updateEncodedFieldsAndValues (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Transaction; public final fun updateFieldPaths (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; public static synthetic fun updateFieldPaths$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; - public final fun updateFieldPathsWithEncodableValue (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; - public static synthetic fun updateFieldPathsWithEncodableValue$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; public final fun updateFields (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; public static synthetic fun updateFields$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; - public final fun updateFieldsWithEncodableValue (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; - public static synthetic fun updateFieldsWithEncodableValue$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; } public final class dev/gitlive/firebase/firestore/Transaction$Companion { @@ -738,6 +720,7 @@ public final class dev/gitlive/firebase/firestore/WriteBatch { public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; public final fun setEncoded (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/internal/EncodedObject;Ldev/gitlive/firebase/firestore/internal/SetOptions;)Ldev/gitlive/firebase/firestore/WriteBatch; public fun toString ()Ljava/lang/String; + public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch; public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch; public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Z)Ldev/gitlive/firebase/firestore/WriteBatch; public static synthetic fun update$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; @@ -748,10 +731,6 @@ public final class dev/gitlive/firebase/firestore/WriteBatch { public static synthetic fun updateField$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; public final fun updateFieldPath (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch; public static synthetic fun updateFieldPath$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; - public final fun updateFieldPathWithEncodableValues (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch; - public static synthetic fun updateFieldPathWithEncodableValues$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; - public final fun updateFieldWithEncodableValues (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch; - public static synthetic fun updateFieldWithEncodableValues$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; } public final class dev/gitlive/firebase/firestore/WriteBatch$Companion { diff --git a/firebase-firestore/api/jvm/firebase-firestore.api b/firebase-firestore/api/jvm/firebase-firestore.api index ccf423cda..1a5f56fdb 100644 --- a/firebase-firestore/api/jvm/firebase-firestore.api +++ b/firebase-firestore/api/jvm/firebase-firestore.api @@ -68,20 +68,16 @@ public final class dev/gitlive/firebase/firestore/DocumentReference { public final fun snapshots (Z)Lkotlinx/coroutines/flow/Flow; public static synthetic fun snapshots$default (Ldev/gitlive/firebase/firestore/DocumentReference;ZILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow; public fun toString ()Ljava/lang/String; + public final fun update (Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun update (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun update (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; public static synthetic fun update$default (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; public final fun updateEncoded (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun updateEncodedFieldPathsAndValues (Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun updateEncodedFieldsAndValues (Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun updateFieldPaths ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static synthetic fun updateFieldPaths$default (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; - public final fun updateFieldPathsWithEncodableValue ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static synthetic fun updateFieldPathsWithEncodableValue$default (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; public final fun updateFields ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static synthetic fun updateFields$default (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; - public final fun updateFieldsWithEncodableValues ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static synthetic fun updateFieldsWithEncodableValues$default (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; } public final class dev/gitlive/firebase/firestore/DocumentReference$Companion { @@ -135,21 +131,6 @@ public final class dev/gitlive/firebase/firestore/DoubleAsTimestampSerializer : public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V } -public final class dev/gitlive/firebase/firestore/EncodableValue { - public fun (Lkotlin/jvm/functions/Function1;)V - public final fun component1 ()Lkotlin/jvm/functions/Function1; - public final fun copy (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/EncodableValue; - public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/EncodableValue;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/EncodableValue; - public fun equals (Ljava/lang/Object;)Z - public final fun getEncoded ()Lkotlin/jvm/functions/Function1; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class dev/gitlive/firebase/firestore/EncodableValueKt { - public static final fun encodableWithStrategy (Ljava/lang/Object;Lkotlinx/serialization/SerializationStrategy;)Ldev/gitlive/firebase/firestore/EncodableValue; -} - public final class dev/gitlive/firebase/firestore/FieldPath { public static final field Companion Ldev/gitlive/firebase/firestore/FieldPath$Companion; public fun ([Ljava/lang/String;)V @@ -180,6 +161,13 @@ public final class dev/gitlive/firebase/firestore/FieldValue$Companion { public final fun serializer ()Lkotlinx/serialization/KSerializer; } +public final class dev/gitlive/firebase/firestore/FieldValueBuilder { + public final fun addEncoded (Ljava/lang/Object;)V + public final fun addWithStrategy (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V + public final fun getBuildSettings ()Lkotlin/jvm/functions/Function1; + public final fun setBuildSettings (Lkotlin/jvm/functions/Function1;)V +} + public final class dev/gitlive/firebase/firestore/FieldValueSerializer : kotlinx/serialization/KSerializer { public static final field INSTANCE Ldev/gitlive/firebase/firestore/FieldValueSerializer; public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/gitlive/firebase/firestore/FieldValue; @@ -189,6 +177,15 @@ public final class dev/gitlive/firebase/firestore/FieldValueSerializer : kotlinx public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V } +public final class dev/gitlive/firebase/firestore/FieldsAndValuesBuilder { + public final fun getBuildSettings ()Lkotlin/jvm/functions/Function1; + public final fun setBuildSettings (Lkotlin/jvm/functions/Function1;)V + public final fun to (Ldev/gitlive/firebase/firestore/FieldPath;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V + public final fun to (Ljava/lang/String;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V + public final fun toEncoded (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)V + public final fun toEncoded (Ljava/lang/String;Ljava/lang/Object;)V +} + public abstract class dev/gitlive/firebase/firestore/Filter { } @@ -360,12 +357,6 @@ public final class dev/gitlive/firebase/firestore/GeoPointSerializer : kotlinx/s public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V } -public final class dev/gitlive/firebase/firestore/HelpersKt { - public static final fun encodeFieldAndValue ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Ljava/util/List; - public static final fun performUpdateFieldPaths ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ljava/util/List; - public static final fun performUpdateFields ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ljava/util/List; -} - public abstract interface class dev/gitlive/firebase/firestore/LocalCacheSettings { } @@ -451,15 +442,13 @@ public final class dev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings public class dev/gitlive/firebase/firestore/Query { public static final field Companion Ldev/gitlive/firebase/firestore/Query$Companion; public final fun endAt (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Ldev/gitlive/firebase/firestore/Query; + public final fun endAt (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; public final fun endAt ([Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; public static synthetic fun endAt$default (Ldev/gitlive/firebase/firestore/Query;[Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; - public final fun endAtWithEncodableValue ([Ldev/gitlive/firebase/firestore/EncodableValue;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; - public static synthetic fun endAtWithEncodableValue$default (Ldev/gitlive/firebase/firestore/Query;[Ldev/gitlive/firebase/firestore/EncodableValue;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; public final fun endBefore (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Ldev/gitlive/firebase/firestore/Query; + public final fun endBefore (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; public final fun endBefore ([Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; public static synthetic fun endBefore$default (Ldev/gitlive/firebase/firestore/Query;[Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; - public final fun endBeforeWithEncodableValue ([Ldev/gitlive/firebase/firestore/EncodableValue;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; - public static synthetic fun endBeforeWithEncodableValue$default (Ldev/gitlive/firebase/firestore/Query;[Ldev/gitlive/firebase/firestore/EncodableValue;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; public final fun get (Ldev/gitlive/firebase/firestore/Source;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static synthetic fun get$default (Ldev/gitlive/firebase/firestore/Query;Ldev/gitlive/firebase/firestore/Source;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; public final fun getSnapshots ()Lkotlinx/coroutines/flow/Flow; @@ -471,15 +460,13 @@ public class dev/gitlive/firebase/firestore/Query { public final fun snapshots (Z)Lkotlinx/coroutines/flow/Flow; public static synthetic fun snapshots$default (Ldev/gitlive/firebase/firestore/Query;ZILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow; public final fun startAfter (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Ldev/gitlive/firebase/firestore/Query; + public final fun startAfter (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; public final fun startAfter ([Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; public static synthetic fun startAfter$default (Ldev/gitlive/firebase/firestore/Query;[Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; - public final fun startAfterWithEncodableValue ([Ldev/gitlive/firebase/firestore/EncodableValue;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; - public static synthetic fun startAfterWithEncodableValue$default (Ldev/gitlive/firebase/firestore/Query;[Ldev/gitlive/firebase/firestore/EncodableValue;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; public final fun startAt (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Ldev/gitlive/firebase/firestore/Query; + public final fun startAt (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; public final fun startAt ([Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; public static synthetic fun startAt$default (Ldev/gitlive/firebase/firestore/Query;[Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; - public final fun startAtWithEncodableValue ([Ldev/gitlive/firebase/firestore/EncodableValue;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; - public static synthetic fun startAtWithEncodableValue$default (Ldev/gitlive/firebase/firestore/Query;[Ldev/gitlive/firebase/firestore/EncodableValue;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; public final fun where (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; } @@ -595,21 +582,16 @@ public final class dev/gitlive/firebase/firestore/Transaction { public fun toString ()Ljava/lang/String; public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;Z)Ldev/gitlive/firebase/firestore/Transaction; + public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Z)Ldev/gitlive/firebase/firestore/Transaction; public static synthetic fun update$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; public static synthetic fun update$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; public final fun updateEncoded (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/internal/EncodedObject;)Ldev/gitlive/firebase/firestore/Transaction; - public final fun updateEncodedFieldPathsAndValues (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Transaction; - public final fun updateEncodedFieldsAndValues (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Transaction; public final fun updateFieldPaths (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; public static synthetic fun updateFieldPaths$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; - public final fun updateFieldPathsWithEncodableValue (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; - public static synthetic fun updateFieldPathsWithEncodableValue$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; public final fun updateFields (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; public static synthetic fun updateFields$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; - public final fun updateFieldsWithEncodableValue (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; - public static synthetic fun updateFieldsWithEncodableValue$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; } public final class dev/gitlive/firebase/firestore/Transaction$Companion { @@ -738,6 +720,7 @@ public final class dev/gitlive/firebase/firestore/WriteBatch { public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; public final fun setEncoded (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/internal/EncodedObject;Ldev/gitlive/firebase/firestore/internal/SetOptions;)Ldev/gitlive/firebase/firestore/WriteBatch; public fun toString ()Ljava/lang/String; + public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch; public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch; public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Z)Ldev/gitlive/firebase/firestore/WriteBatch; public static synthetic fun update$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; @@ -748,10 +731,6 @@ public final class dev/gitlive/firebase/firestore/WriteBatch { public static synthetic fun updateField$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; public final fun updateFieldPath (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch; public static synthetic fun updateFieldPath$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; - public final fun updateFieldPathWithEncodableValues (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch; - public static synthetic fun updateFieldPathWithEncodableValues$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; - public final fun updateFieldWithEncodableValues (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch; - public static synthetic fun updateFieldWithEncodableValues$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; } public final class dev/gitlive/firebase/firestore/WriteBatch$Companion { diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt index cb91ffd74..2cc2047a0 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt @@ -2,7 +2,6 @@ package dev.gitlive.firebase.firestore.internal import com.google.android.gms.tasks.TaskExecutors import com.google.firebase.firestore.MetadataChanges -import dev.gitlive.firebase.firestore.EncodedFieldPath import dev.gitlive.firebase.firestore.NativeDocumentReferenceType import dev.gitlive.firebase.firestore.NativeDocumentSnapshot import dev.gitlive.firebase.firestore.Source @@ -44,19 +43,12 @@ internal actual class NativeDocumentReference actual constructor(actual val nati android.update(encodedData.android).await() } - actual suspend fun updateEncodedFieldsAndValues(encodedFieldsAndValues: List>) { + actual suspend fun updateEncoded(encodedFieldsAndValues: List) { encodedFieldsAndValues.takeUnless { encodedFieldsAndValues.isEmpty() }?.let { - android.update(encodedFieldsAndValues.toMap()) + encodedFieldsAndValues.performUpdate(android::update, android::update) }?.await() } - actual suspend fun updateEncodedFieldPathsAndValues(encodedFieldsAndValues: List>) { - encodedFieldsAndValues.takeUnless { encodedFieldsAndValues.isEmpty() } - ?.performUpdate { field, value, moreFieldsAndValues -> - android.update(field, value, *moreFieldsAndValues) - }?.await() - } - actual suspend fun delete() { android.delete().await() } diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt index 4b8219703..ea20d3f33 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt @@ -1,7 +1,6 @@ package dev.gitlive.firebase.firestore.internal import dev.gitlive.firebase.firestore.DocumentReference -import dev.gitlive.firebase.firestore.EncodedFieldPath import dev.gitlive.firebase.firestore.NativeTransaction import dev.gitlive.firebase.firestore.android import dev.gitlive.firebase.firestore.performUpdate @@ -23,19 +22,17 @@ internal actual class NativeTransactionWrapper internal actual constructor(actua actual fun updateEncoded(documentRef: DocumentReference, encodedData: EncodedObject) = native.update(documentRef.android, encodedData.android).let { this } - actual fun updateEncodedFieldsAndValues( + actual fun updateEncoded( documentRef: DocumentReference, - encodedFieldsAndValues: List>, - ) = encodedFieldsAndValues.performUpdate { field, value, moreFieldsAndValues -> - native.update(documentRef.android, field, value, *moreFieldsAndValues) - }.let { this } - - actual fun updateEncodedFieldPathsAndValues( - documentRef: DocumentReference, - encodedFieldsAndValues: List>, - ) = encodedFieldsAndValues.performUpdate { field, value, moreFieldsAndValues -> - native.update(documentRef.android, field, value, *moreFieldsAndValues) - }.let { this } + encodedFieldsAndValues: List, + ) = encodedFieldsAndValues.performUpdate( + updateAsField = { field, value, moreFieldsAndValues -> + native.update(documentRef.android, field, value, *moreFieldsAndValues) + }, + updateAsFieldPath = { fieldPath, value, moreFieldsAndValues -> + native.update(documentRef.android, fieldPath, value, *moreFieldsAndValues) + }, + ).let { this } actual fun delete(documentRef: DocumentReference) = native.delete(documentRef.android).let { this } diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt index 9aa34f700..1a3bd69b9 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt @@ -1,7 +1,6 @@ package dev.gitlive.firebase.firestore.internal import dev.gitlive.firebase.firestore.DocumentReference -import dev.gitlive.firebase.firestore.EncodedFieldPath import dev.gitlive.firebase.firestore.NativeWriteBatch import dev.gitlive.firebase.firestore.android import dev.gitlive.firebase.firestore.performUpdate @@ -25,19 +24,17 @@ internal actual class NativeWriteBatchWrapper internal actual constructor(actual actual fun updateEncoded(documentRef: DocumentReference, encodedData: EncodedObject) = native.update(documentRef.android, encodedData.android).let { this } - actual fun updateEncodedFieldsAndValues( + actual fun updateEncoded( documentRef: DocumentReference, - encodedFieldsAndValues: List>, - ) = encodedFieldsAndValues.performUpdate { field, value, moreFieldsAndValues -> - native.update(documentRef.android, field, value, *moreFieldsAndValues) - }.let { this } - - actual fun updateEncodedFieldPathsAndValues( - documentRef: DocumentReference, - encodedFieldsAndValues: List>, - ) = encodedFieldsAndValues.performUpdate { field, value, moreFieldsAndValues -> - native.update(documentRef.android, field, value, *moreFieldsAndValues) - }.let { this } + encodedFieldsAndValues: List, + ) = encodedFieldsAndValues.performUpdate( + updateAsField = { field, value, moreFieldsAndValues -> + native.update(documentRef.android, field, value, *moreFieldsAndValues) + }, + updateAsFieldPath = { fieldPath, value, moreFieldsAndValues -> + native.update(documentRef.android, fieldPath, value, *moreFieldsAndValues) + }, + ).let { this } actual fun delete(documentRef: DocumentReference) = native.delete(documentRef.android).let { this } diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/EncodableValue.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/EncodableValue.kt deleted file mode 100644 index ba97efbd7..000000000 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/EncodableValue.kt +++ /dev/null @@ -1,13 +0,0 @@ -package dev.gitlive.firebase.firestore - -import dev.gitlive.firebase.EncodeSettings -import kotlinx.serialization.SerializationStrategy - -public data class EncodableValue(public val encoded: (EncodeSettings.Builder.() -> Unit) -> Any?) - -public inline fun T.encodable(): EncodableValue = EncodableValue { - encode(this, it) -} -public fun T.encodableWithStrategy(stategy: SerializationStrategy): EncodableValue = EncodableValue { - dev.gitlive.firebase.internal.encode(stategy, this, it) -} diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValueBuilder.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValueBuilder.kt new file mode 100644 index 000000000..53d5a0d13 --- /dev/null +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValueBuilder.kt @@ -0,0 +1,25 @@ +package dev.gitlive.firebase.firestore + +import dev.gitlive.firebase.EncodeSettings +import kotlinx.serialization.SerializationStrategy + +public class FieldValueBuilder internal constructor() { + + internal val fieldValues: MutableList = mutableListOf() + public var buildSettings: EncodeSettings.Builder.() -> Unit = { + encodeDefaults = true + } + + public inline fun add(value: T) { + addEncoded(encode(value, buildSettings)!!) + } + + public fun addWithStrategy(strategy: SerializationStrategy, value: T) { + addEncoded(dev.gitlive.firebase.internal.encode(strategy, value, buildSettings)!!) + } + + @PublishedApi + internal fun addEncoded(encodedValue: Any) { + fieldValues += encodedValue + } +} diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldsAndValuesBuilder.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldsAndValuesBuilder.kt new file mode 100644 index 000000000..aba64b228 --- /dev/null +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldsAndValuesBuilder.kt @@ -0,0 +1,39 @@ +package dev.gitlive.firebase.firestore + +import dev.gitlive.firebase.EncodeSettings +import dev.gitlive.firebase.firestore.internal.FieldAndValue +import kotlinx.serialization.SerializationStrategy + +public class FieldsAndValuesBuilder internal constructor() { + + internal val fieldAndValues: MutableList = mutableListOf() + public var buildSettings: EncodeSettings.Builder.() -> Unit = { + encodeDefaults = true + } + + public inline infix fun String.to(value: T) { + toEncoded(encode(value, buildSettings)) + } + + public inline infix fun FieldPath.to(value: T) { + toEncoded(encode(value, buildSettings)) + } + + public fun String.to(strategy: SerializationStrategy, value: T) { + toEncoded(dev.gitlive.firebase.internal.encode(strategy, value, buildSettings)) + } + + public fun FieldPath.to(strategy: SerializationStrategy, value: T) { + toEncoded(dev.gitlive.firebase.internal.encode(strategy, value, buildSettings)) + } + + @PublishedApi + internal fun String.toEncoded(encodedValue: Any?) { + fieldAndValues += FieldAndValue.WithStringField(this, encodedValue) + } + + @PublishedApi + internal fun FieldPath.toEncoded(encodedValue: Any?) { + fieldAndValues += FieldAndValue.WithFieldPath(this, encodedValue) + } +} diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 98f744214..bde643033 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -10,6 +10,7 @@ import dev.gitlive.firebase.internal.EncodedObject import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException +import dev.gitlive.firebase.firestore.internal.FieldAndValue import dev.gitlive.firebase.firestore.internal.NativeCollectionReferenceWrapper import dev.gitlive.firebase.firestore.internal.NativeDocumentReference import dev.gitlive.firebase.firestore.internal.NativeDocumentSnapshotWrapper @@ -192,32 +193,33 @@ public data class Transaction internal constructor(internal val nativeWrapper: N @JvmName("updateFields") public fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Transaction = update( documentRef, - *fieldsAndValues.map { (key, value) -> key to value.encodable() }.toTypedArray(), - buildSettings = buildSettings, + fieldsAndValuesBuilder = { + this.buildSettings = buildSettings + fieldsAndValues.forEach { (field, value) -> + field to value + } + }, ) - @JvmName("updateFieldsWithEncodableValue") - public fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Transaction = updateEncodedFieldsAndValues(documentRef, encodeFieldAndValue(fieldsAndValues, buildSettings).orEmpty()) - @JvmName("updateFieldPaths") public fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Transaction = update( documentRef, - *fieldsAndValues.map { (key, value) -> key to value.encodable() }.toTypedArray(), - buildSettings = buildSettings, + fieldsAndValuesBuilder = { + this.buildSettings = buildSettings + fieldsAndValues.forEach { (field, value) -> + field to value + } + }, ) - @JvmName("updateFieldPathsWithEncodableValue") - public fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Transaction = updateEncodedFieldPathsAndValues(documentRef, encodeFieldAndValue(fieldsAndValues, buildSettings).orEmpty()) + public fun update( + documentRef: DocumentReference, + fieldsAndValuesBuilder: FieldsAndValuesBuilder.() -> Unit, + ): Transaction = Transaction(nativeWrapper.updateEncoded(documentRef, FieldsAndValuesBuilder().apply(fieldsAndValuesBuilder).fieldAndValues)) @PublishedApi internal fun updateEncoded(documentRef: DocumentReference, encodedData: EncodedObject): Transaction = Transaction(nativeWrapper.updateEncoded(documentRef, encodedData)) - @PublishedApi - internal fun updateEncodedFieldsAndValues(documentRef: DocumentReference, encodedFieldsAndValues: List>): Transaction = Transaction(nativeWrapper.updateEncodedFieldsAndValues(documentRef, encodedFieldsAndValues)) - - @PublishedApi - internal fun updateEncodedFieldPathsAndValues(documentRef: DocumentReference, encodedFieldsAndValues: List>): Transaction = Transaction(nativeWrapper.updateEncodedFieldPathsAndValues(documentRef, encodedFieldsAndValues)) - public fun delete(documentRef: DocumentReference): Transaction = Transaction(nativeWrapper.delete(documentRef)) public suspend fun get(documentRef: DocumentReference): DocumentSnapshot = DocumentSnapshot(nativeWrapper.get(documentRef)) } @@ -243,26 +245,48 @@ public open class Query internal constructor(internal val nativeQuery: NativeQue public fun orderBy(field: FieldPath, direction: Direction = Direction.ASCENDING): Query = Query(nativeQuery.orderBy(field.encoded, direction)) public fun startAfter(document: DocumentSnapshot): Query = Query(nativeQuery.startAfter(document.native)) - public fun startAfter(vararg fieldValues: Any?, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Query = startAfter(*fieldValues.map { it.encodable() }.toTypedArray(), buildSettings = buildSettings) + public fun startAfter(vararg fieldValues: Any?, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Query = startAfter( + builder = { + this.buildSettings = buildSettings + fieldValues.forEach { + add(it) + } + }, + ) + public fun startAfter(builder: FieldValueBuilder.() -> Unit): Query = Query(nativeQuery.startAfter(*FieldValueBuilder().apply(builder).fieldValues.toTypedArray())) - @JvmName("startAfterWithEncodableValue") - public fun startAfter(vararg fieldValues: EncodableValue, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Query = Query(nativeQuery.startAfter(*(fieldValues.map { it.encoded(buildSettings)!! }.toTypedArray()))) public fun startAt(document: DocumentSnapshot): Query = Query(nativeQuery.startAt(document.native)) - public fun startAt(vararg fieldValues: Any?, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Query = startAt(*fieldValues.map { it.encodable() }.toTypedArray(), buildSettings = buildSettings) - - @JvmName("startAtWithEncodableValue") - public fun startAt(vararg fieldValues: EncodableValue, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Query = Query(nativeQuery.startAt(*(fieldValues.map { it.encoded(buildSettings)!! }.toTypedArray()))) + public fun startAt(vararg fieldValues: Any?, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Query = startAt( + builder = { + this.buildSettings = buildSettings + fieldValues.forEach { + add(it) + } + }, + ) + public fun startAt(builder: FieldValueBuilder.() -> Unit): Query = Query(nativeQuery.startAt(*FieldValueBuilder().apply(builder).fieldValues.toTypedArray())) public fun endBefore(document: DocumentSnapshot): Query = Query(nativeQuery.endBefore(document.native)) - public fun endBefore(vararg fieldValues: Any?, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Query = endBefore(*fieldValues.map { it.encodable() }.toTypedArray(), buildSettings = buildSettings) + public fun endBefore(vararg fieldValues: Any?, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Query = endBefore( + builder = { + this.buildSettings = buildSettings + fieldValues.forEach { + add(it) + } + }, + ) + public fun endBefore(builder: FieldValueBuilder.() -> Unit): Query = Query(nativeQuery.endBefore(*FieldValueBuilder().apply(builder).fieldValues.toTypedArray())) - @JvmName("endBeforeWithEncodableValue") - public fun endBefore(vararg fieldValues: EncodableValue, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Query = Query(nativeQuery.endBefore(*(fieldValues.map { it.encoded(buildSettings)!! }.toTypedArray()))) public fun endAt(document: DocumentSnapshot): Query = Query(nativeQuery.endAt(document.native)) - public fun endAt(vararg fieldValues: Any?, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Query = endAt(*fieldValues.map { it.encodable() }.toTypedArray(), buildSettings = buildSettings) - - @JvmName("endAtWithEncodableValue") - public fun endAt(vararg fieldValues: EncodableValue, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Query = Query(nativeQuery.endAt(*(fieldValues.map { it.encoded(buildSettings)!! }.toTypedArray()))) + public fun endAt(vararg fieldValues: Any?, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Query = endAt( + builder = { + this.buildSettings = buildSettings + fieldValues.forEach { + add(it) + } + }, + ) + public fun endAt(builder: FieldValueBuilder.() -> Unit): Query = Query(nativeQuery.endAt(*FieldValueBuilder().apply(builder).fieldValues.toTypedArray())) } @Deprecated("Deprecated in favor of using a [FilterBuilder]", replaceWith = ReplaceWith("where { field equalTo equalTo }", "dev.gitlive.firebase.firestore")) @@ -389,31 +413,41 @@ public data class WriteBatch internal constructor(internal val nativeWrapper: Na @JvmName("updateField") public fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = update( documentRef, - *fieldsAndValues.map { (key, value) -> key to value.encodable() }.toTypedArray(), - buildSettings = buildSettings, + fieldAndValuesBuilder = { + this.buildSettings = buildSettings + fieldsAndValues.forEach { (field, value) -> + field to value + } + }, ) - @JvmName("updateFieldWithEncodableValues") - public fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = updateEncodedFieldsAndValues(documentRef, encodeFieldAndValue(fieldsAndValues, buildSettings).orEmpty()) - @JvmName("updateFieldPath") public fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = update( documentRef, - *fieldsAndValues.map { (key, value) -> key to value.encodable() }.toTypedArray(), - buildSettings = buildSettings, + fieldAndValuesBuilder = { + this.buildSettings = buildSettings + fieldsAndValues.forEach { (path, value) -> + path to value + } + }, ) - @JvmName("updateFieldPathWithEncodableValues") - public fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = updateEncodedFieldPathsAndValues(documentRef, encodeFieldAndValue(fieldsAndValues, buildSettings).orEmpty()) + public fun update( + documentRef: DocumentReference, + fieldAndValuesBuilder: FieldsAndValuesBuilder.() -> Unit, + ): WriteBatch = updateEncodedFieldPathsAndValues( + documentRef, + FieldsAndValuesBuilder().apply(fieldAndValuesBuilder).fieldAndValues, + ) @PublishedApi internal fun updateEncoded(documentRef: DocumentReference, encodedData: EncodedObject): WriteBatch = WriteBatch(nativeWrapper.updateEncoded(documentRef, encodedData)) @PublishedApi - internal fun updateEncodedFieldsAndValues(documentRef: DocumentReference, encodedFieldsAndValues: List>): WriteBatch = WriteBatch(nativeWrapper.updateEncodedFieldsAndValues(documentRef, encodedFieldsAndValues)) + internal fun updateEncodedFieldsAndValues(documentRef: DocumentReference, encodedFieldsAndValues: List): WriteBatch = WriteBatch(nativeWrapper.updateEncoded(documentRef, encodedFieldsAndValues)) @PublishedApi - internal fun updateEncodedFieldPathsAndValues(documentRef: DocumentReference, encodedFieldsAndValues: List>): WriteBatch = WriteBatch(nativeWrapper.updateEncodedFieldPathsAndValues(documentRef, encodedFieldsAndValues)) + internal fun updateEncodedFieldPathsAndValues(documentRef: DocumentReference, encodedFieldsAndValues: List): WriteBatch = WriteBatch(nativeWrapper.updateEncoded(documentRef, encodedFieldsAndValues)) public fun delete(documentRef: DocumentReference): WriteBatch = WriteBatch(nativeWrapper.delete(documentRef)) public suspend fun commit() { @@ -553,44 +587,33 @@ public data class DocumentReference internal constructor(internal val native: Na @JvmName("updateFields") public suspend fun update(vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Unit = update( - *fieldsAndValues.map { (key, value) -> key to value.encodable() }.toTypedArray(), - buildSettings = buildSettings, + fieldsAndValuesBuilder = { + this.buildSettings = buildSettings + fieldsAndValues.forEach { (field, value) -> + field to value + } + }, ) - @JvmName("updateFieldsWithEncodableValues") - public suspend fun update(vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit = {}) { - updateEncodedFieldsAndValues( - encodeFieldAndValue( - fieldsAndValues, - buildSettings, - ).orEmpty(), - ) - } - - @PublishedApi - internal suspend fun updateEncodedFieldsAndValues(encodedFieldsAndValues: List>) { - native.updateEncodedFieldsAndValues(encodedFieldsAndValues) - } - @JvmName("updateFieldPaths") public suspend fun update(vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Unit = update( - *fieldsAndValues.map { (key, value) -> key to value.encodable() }.toTypedArray(), - buildSettings = buildSettings, + fieldsAndValuesBuilder = { + this.buildSettings = buildSettings + fieldsAndValues.forEach { (fieldPath, value) -> + fieldPath to value + } + }, ) - @JvmName("updateFieldPathsWithEncodableValue") - public suspend fun update(vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit = {}) { - updateEncodedFieldPathsAndValues( - encodeFieldAndValue( - fieldsAndValues, - buildSettings, - ).orEmpty(), - ) + public suspend fun update( + fieldsAndValuesBuilder: FieldsAndValuesBuilder.() -> Unit, + ) { + updateEncodedFieldPathsAndValues(FieldsAndValuesBuilder().apply(fieldsAndValuesBuilder).fieldAndValues) } @PublishedApi - internal suspend fun updateEncodedFieldPathsAndValues(encodedFieldsAndValues: List>) { - native.updateEncodedFieldPathsAndValues(encodedFieldsAndValues) + internal suspend fun updateEncodedFieldPathsAndValues(encodedFieldsAndValues: List) { + native.updateEncoded(encodedFieldsAndValues) } public suspend fun delete() { diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/helpers.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/helpers.kt index 7a225b0f4..7247ca002 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/helpers.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/helpers.kt @@ -1,38 +1,39 @@ package dev.gitlive.firebase.firestore -import dev.gitlive.firebase.EncodeSettings -import kotlin.jvm.JvmName +import dev.gitlive.firebase.firestore.internal.FieldAndValue -// ** Helper method to perform an update operation. */ -@JvmName("performUpdateFields") -@PublishedApi -internal fun encodeFieldAndValue( - fieldsAndValues: Array>, - buildSettings: EncodeSettings.Builder.() -> Unit, -): List>? = encodeFieldAndValue(fieldsAndValues, encodeField = { it }, buildSettings) +internal fun List.performUpdate( + updateAsField: (String, Any?, Array) -> R, + updateAsFieldPath: (EncodedFieldPath, Any?, Array) -> R, +): R { + val first = first() + val remaining = drop(1).flatMap { fieldAndValue -> + listOf( + when (fieldAndValue) { + is FieldAndValue.WithFieldPath -> fieldAndValue.path.encoded + is FieldAndValue.WithStringField -> fieldAndValue.field + }, + fieldAndValue.value, + ) + } + return when (first) { + is FieldAndValue.WithFieldPath -> updateAsFieldPath( + first.path.encoded, + first.value, + remaining.toTypedArray(), + ) -/** Helper method to perform an update operation. */ -@JvmName("performUpdateFieldPaths") -@PublishedApi -internal fun encodeFieldAndValue( - fieldsAndValues: Array>, - buildSettings: EncodeSettings.Builder.() -> Unit, -): List>? = encodeFieldAndValue(fieldsAndValues, { it.encoded }, buildSettings) + is FieldAndValue.WithStringField -> updateAsField( + first.field, + first.value, + remaining.toTypedArray(), + ) + } +} -/** Helper method to perform an update operation in Android and JS. */ -@PublishedApi -internal inline fun encodeFieldAndValue( - fieldsAndValues: Array>, - encodeField: (T) -> K, - noinline buildSettings: EncodeSettings.Builder.() -> Unit, -): List>? = - fieldsAndValues.takeUnless { fieldsAndValues.isEmpty() } - ?.map { (field, value) -> encodeField(field) to value.encoded(buildSettings) } - -internal fun List>.performUpdate( - update: (K, Any?, Array) -> R, -) = update( - this[0].first, - this[0].second, - this.drop(1).flatMap { (field, value) -> listOf(field, value) }.toTypedArray(), -) +internal fun List.toEncodedMap(): Map = associate { fieldAndValue -> + when (fieldAndValue) { + is FieldAndValue.WithStringField -> fieldAndValue.field to fieldAndValue.value + is FieldAndValue.WithFieldPath -> fieldAndValue.path.encoded to fieldAndValue.value + } +} diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/FieldAndValue.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/FieldAndValue.kt new file mode 100644 index 000000000..c4d5beeb4 --- /dev/null +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/FieldAndValue.kt @@ -0,0 +1,11 @@ +package dev.gitlive.firebase.firestore.internal + +import dev.gitlive.firebase.firestore.FieldPath + +internal sealed class FieldAndValue { + + abstract val value: Any? + + data class WithStringField(val field: String, override val value: Any?) : FieldAndValue() + data class WithFieldPath(val path: FieldPath, override val value: Any?) : FieldAndValue() +} diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt index baa706419..7cf376cf8 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt @@ -1,6 +1,5 @@ package dev.gitlive.firebase.firestore.internal -import dev.gitlive.firebase.firestore.EncodedFieldPath import dev.gitlive.firebase.firestore.NativeCollectionReference import dev.gitlive.firebase.firestore.NativeDocumentReferenceType import dev.gitlive.firebase.firestore.NativeDocumentSnapshot @@ -20,7 +19,6 @@ internal expect class NativeDocumentReference(nativeValue: NativeDocumentReferen suspend fun get(source: Source = Source.DEFAULT): NativeDocumentSnapshot suspend fun setEncoded(encodedData: EncodedObject, setOptions: SetOptions) suspend fun updateEncoded(encodedData: EncodedObject) - suspend fun updateEncodedFieldsAndValues(encodedFieldsAndValues: List>) - suspend fun updateEncodedFieldPathsAndValues(encodedFieldsAndValues: List>) + suspend fun updateEncoded(encodedFieldsAndValues: List) suspend fun delete() } diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt index 6bb72eedf..8a4df4971 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt @@ -1,7 +1,6 @@ package dev.gitlive.firebase.firestore.internal import dev.gitlive.firebase.firestore.DocumentReference -import dev.gitlive.firebase.firestore.EncodedFieldPath import dev.gitlive.firebase.firestore.NativeTransaction import dev.gitlive.firebase.internal.EncodedObject @@ -11,8 +10,7 @@ internal expect class NativeTransactionWrapper internal constructor(native: Nati fun setEncoded(documentRef: DocumentReference, encodedData: EncodedObject, setOptions: SetOptions): NativeTransactionWrapper fun updateEncoded(documentRef: DocumentReference, encodedData: EncodedObject): NativeTransactionWrapper - fun updateEncodedFieldsAndValues(documentRef: DocumentReference, encodedFieldsAndValues: List>): NativeTransactionWrapper - fun updateEncodedFieldPathsAndValues(documentRef: DocumentReference, encodedFieldsAndValues: List>): NativeTransactionWrapper + fun updateEncoded(documentRef: DocumentReference, encodedFieldsAndValues: List): NativeTransactionWrapper fun delete(documentRef: DocumentReference): NativeTransactionWrapper suspend fun get(documentRef: DocumentReference): NativeDocumentSnapshotWrapper } diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt index bea3d0071..fee11b836 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt @@ -1,7 +1,6 @@ package dev.gitlive.firebase.firestore.internal import dev.gitlive.firebase.firestore.DocumentReference -import dev.gitlive.firebase.firestore.EncodedFieldPath import dev.gitlive.firebase.firestore.NativeWriteBatch import dev.gitlive.firebase.internal.EncodedObject @@ -9,8 +8,7 @@ internal expect class NativeWriteBatchWrapper internal constructor(native: Nativ val native: NativeWriteBatch fun setEncoded(documentRef: DocumentReference, encodedData: EncodedObject, setOptions: SetOptions): NativeWriteBatchWrapper fun updateEncoded(documentRef: DocumentReference, encodedData: EncodedObject): NativeWriteBatchWrapper - fun updateEncodedFieldsAndValues(documentRef: DocumentReference, encodedFieldsAndValues: List>): NativeWriteBatchWrapper - fun updateEncodedFieldPathsAndValues(documentRef: DocumentReference, encodedFieldsAndValues: List>): NativeWriteBatchWrapper + fun updateEncoded(documentRef: DocumentReference, encodedFieldsAndValues: List): NativeWriteBatchWrapper fun delete(documentRef: DocumentReference): NativeWriteBatchWrapper suspend fun commit() } diff --git a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 54375c9b5..4c727df6a 100644 --- a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -728,9 +728,12 @@ class FirebaseFirestoreTest { // update data val updatedData = DataWithDocumentReference(documentRef2) - getDocument().update( - FieldPath(DataWithDocumentReference::documentReference.name) to updatedData.documentReference.encodableWithStrategy(DocumentReferenceSerializer), - ) + getDocument().update(fieldsAndValuesBuilder = { + FieldPath(DataWithDocumentReference::documentReference.name).to( + DocumentReferenceSerializer, + updatedData.documentReference, + ) + }) // verify update val updatedSavedData = getDocument().get().data(DataWithDocumentReference.serializer()) assertEquals(updatedData.documentReference.path, updatedSavedData.documentReference.path) diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt index 98856556b..4f2c72d14 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt @@ -1,10 +1,10 @@ package dev.gitlive.firebase.firestore.internal -import dev.gitlive.firebase.firestore.EncodedFieldPath import dev.gitlive.firebase.firestore.NativeDocumentReferenceType import dev.gitlive.firebase.firestore.Source import dev.gitlive.firebase.firestore.await import dev.gitlive.firebase.firestore.awaitResult +import dev.gitlive.firebase.firestore.toEncodedMap import dev.gitlive.firebase.firestore.toException import dev.gitlive.firebase.internal.EncodedObject import dev.gitlive.firebase.internal.ios @@ -55,14 +55,9 @@ internal actual class NativeDocumentReference actual constructor(actual val nati ios.updateData(encodedData.ios, it) } - actual suspend fun updateEncodedFieldsAndValues(encodedFieldsAndValues: List>) = + actual suspend fun updateEncoded(encodedFieldsAndValues: List) = await { - ios.updateData(encodedFieldsAndValues.toMap(), it) - } - - actual suspend fun updateEncodedFieldPathsAndValues(encodedFieldsAndValues: List>) = - await { - ios.updateData(encodedFieldsAndValues.toMap(), it) + ios.updateData(encodedFieldsAndValues.toEncodedMap(), it) } actual suspend fun delete() = await { ios.deleteDocumentWithCompletion(it) } diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt index a9fe0014d..4a95a6610 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt @@ -2,8 +2,8 @@ package dev.gitlive.firebase.firestore.internal import cocoapods.FirebaseFirestoreInternal.FIRTransaction import dev.gitlive.firebase.firestore.DocumentReference -import dev.gitlive.firebase.firestore.EncodedFieldPath import dev.gitlive.firebase.firestore.ios +import dev.gitlive.firebase.firestore.toEncodedMap import dev.gitlive.firebase.internal.EncodedObject import dev.gitlive.firebase.internal.ios @@ -22,19 +22,11 @@ internal actual class NativeTransactionWrapper actual constructor(actual val nat actual fun updateEncoded(documentRef: DocumentReference, encodedData: EncodedObject): NativeTransactionWrapper = native.updateData(encodedData.ios, documentRef.ios).let { this } - actual fun updateEncodedFieldsAndValues( + actual fun updateEncoded( documentRef: DocumentReference, - encodedFieldsAndValues: List>, + encodedFieldsAndValues: List, ): NativeTransactionWrapper = native.updateData( - encodedFieldsAndValues.toMap(), - documentRef.ios, - ).let { this } - - actual fun updateEncodedFieldPathsAndValues( - documentRef: DocumentReference, - encodedFieldsAndValues: List>, - ): NativeTransactionWrapper = native.updateData( - encodedFieldsAndValues.toMap(), + encodedFieldsAndValues.toEncodedMap(), documentRef.ios, ).let { this } diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt index f1551cecf..ef8899553 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt @@ -1,10 +1,10 @@ package dev.gitlive.firebase.firestore.internal import dev.gitlive.firebase.firestore.DocumentReference -import dev.gitlive.firebase.firestore.EncodedFieldPath import dev.gitlive.firebase.firestore.NativeWriteBatch import dev.gitlive.firebase.firestore.await import dev.gitlive.firebase.firestore.ios +import dev.gitlive.firebase.firestore.toEncodedMap import dev.gitlive.firebase.internal.EncodedObject import dev.gitlive.firebase.internal.ios @@ -23,19 +23,11 @@ internal actual class NativeWriteBatchWrapper actual constructor(actual val nati actual fun updateEncoded(documentRef: DocumentReference, encodedData: EncodedObject): NativeWriteBatchWrapper = native.updateData(encodedData.ios, documentRef.ios).let { this } - actual fun updateEncodedFieldsAndValues( + actual fun updateEncoded( documentRef: DocumentReference, - encodedFieldsAndValues: List>, + encodedFieldsAndValues: List, ): NativeWriteBatchWrapper = native.updateData( - encodedFieldsAndValues.toMap(), - documentRef.ios, - ).let { this } - - actual fun updateEncodedFieldPathsAndValues( - documentRef: DocumentReference, - encodedFieldsAndValues: List>, - ): NativeWriteBatchWrapper = native.updateData( - encodedFieldsAndValues.toMap(), + encodedFieldsAndValues.toEncodedMap(), documentRef.ios, ).let { this } diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt index 5065defa2..ac72e14af 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt @@ -1,6 +1,5 @@ package dev.gitlive.firebase.firestore.internal -import dev.gitlive.firebase.firestore.EncodedFieldPath import dev.gitlive.firebase.firestore.NativeCollectionReference import dev.gitlive.firebase.firestore.NativeDocumentReferenceType import dev.gitlive.firebase.firestore.NativeDocumentSnapshot @@ -74,25 +73,21 @@ internal actual class NativeDocumentReference actual constructor(actual val nati ).await() } - actual suspend fun updateEncodedFieldsAndValues(encodedFieldsAndValues: List>) { + actual suspend fun updateEncoded(encodedFieldsAndValues: List) { rethrow { encodedFieldsAndValues.takeUnless { encodedFieldsAndValues.isEmpty() } - ?.performUpdate { field, value, moreFieldsAndValues -> - updateDoc(js, field, value, *moreFieldsAndValues) - } + ?.performUpdate( + updateAsField = { field, value, moreFieldsAndValues -> + updateDoc(js, field, value, *moreFieldsAndValues) + }, + updateAsFieldPath = { fieldPath, value, moreFieldsAndValues -> + updateDoc(js, fieldPath, value, *moreFieldsAndValues) + }, + ) ?.await() } } - actual suspend fun updateEncodedFieldPathsAndValues(encodedFieldsAndValues: List>) { - rethrow { - encodedFieldsAndValues.takeUnless { encodedFieldsAndValues.isEmpty() } - ?.performUpdate { field, value, moreFieldsAndValues -> - updateDoc(js, field, value, *moreFieldsAndValues) - }?.await() - } - } - actual suspend fun delete() = rethrow { deleteDoc(js).await() } override fun equals(other: Any?): Boolean = diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt index 59ba9896d..f12b9d637 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt @@ -1,7 +1,6 @@ package dev.gitlive.firebase.firestore.internal import dev.gitlive.firebase.firestore.DocumentReference -import dev.gitlive.firebase.firestore.EncodedFieldPath import dev.gitlive.firebase.firestore.NativeTransaction import dev.gitlive.firebase.firestore.externals.Transaction import dev.gitlive.firebase.firestore.js @@ -29,22 +28,18 @@ internal actual class NativeTransactionWrapper internal actual constructor(actua actual fun updateEncoded(documentRef: DocumentReference, encodedData: EncodedObject): NativeTransactionWrapper = rethrow { js.update(documentRef.js, encodedData.js) } .let { this } - actual fun updateEncodedFieldsAndValues( + actual fun updateEncoded( documentRef: DocumentReference, - encodedFieldsAndValues: List>, + encodedFieldsAndValues: List, ): NativeTransactionWrapper = rethrow { - encodedFieldsAndValues.performUpdate { field, value, moreFieldsAndValues -> - js.update(documentRef.js, field, value, *moreFieldsAndValues) - } - }.let { this } - - actual fun updateEncodedFieldPathsAndValues( - documentRef: DocumentReference, - encodedFieldsAndValues: List>, - ): NativeTransactionWrapper = rethrow { - encodedFieldsAndValues.performUpdate { field, value, moreFieldsAndValues -> - js.update(documentRef.js, field, value, *moreFieldsAndValues) - } + encodedFieldsAndValues.performUpdate( + updateAsField = { field, value, moreFieldsAndValues -> + js.update(documentRef.js, field, value, *moreFieldsAndValues) + }, + updateAsFieldPath = { fieldPath, value, moreFieldsAndValues -> + js.update(documentRef.js, fieldPath, value, *moreFieldsAndValues) + }, + ) }.let { this } actual fun delete(documentRef: DocumentReference) = diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt index e97cc31ab..45515bdcc 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt @@ -1,7 +1,6 @@ package dev.gitlive.firebase.firestore.internal import dev.gitlive.firebase.firestore.DocumentReference -import dev.gitlive.firebase.firestore.EncodedFieldPath import dev.gitlive.firebase.firestore.NativeWriteBatch import dev.gitlive.firebase.firestore.externals.WriteBatch import dev.gitlive.firebase.firestore.js @@ -26,22 +25,18 @@ internal actual class NativeWriteBatchWrapper internal actual constructor(actual actual fun updateEncoded(documentRef: DocumentReference, encodedData: EncodedObject): NativeWriteBatchWrapper = rethrow { js.update(documentRef.js, encodedData.js) } .let { this } - actual fun updateEncodedFieldsAndValues( + actual fun updateEncoded( documentRef: DocumentReference, - encodedFieldsAndValues: List>, + encodedFieldsAndValues: List, ): NativeWriteBatchWrapper = rethrow { - encodedFieldsAndValues.performUpdate { field, value, moreFieldsAndValues -> - js.update(documentRef.js, field, value, *moreFieldsAndValues) - } - }.let { this } - - actual fun updateEncodedFieldPathsAndValues( - documentRef: DocumentReference, - encodedFieldsAndValues: List>, - ): NativeWriteBatchWrapper = rethrow { - encodedFieldsAndValues.performUpdate { field, value, moreFieldsAndValues -> - js.update(documentRef.js, field, value, *moreFieldsAndValues) - } + encodedFieldsAndValues.performUpdate( + updateAsField = { field, value, moreFieldsAndValues -> + js.update(documentRef.js, field, value, *moreFieldsAndValues) + }, + updateAsFieldPath = { fieldPath, value, moreFieldsAndValues -> + js.update(documentRef.js, fieldPath, value, *moreFieldsAndValues) + }, + ) }.let { this } actual fun delete(documentRef: DocumentReference) =