Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.google.firebase.FirebaseApp
import com.google.firebase.dataconnect.ConnectorConfig
import com.google.firebase.dataconnect.DataConnectSettings
import com.google.firebase.dataconnect.FirebaseDataConnect
import com.google.firebase.dataconnect.copy
import com.google.firebase.dataconnect.getInstance
import com.google.firebase.dataconnect.testutil.DataConnectBackend.Autopush
import com.google.firebase.dataconnect.testutil.DataConnectBackend.Companion.fromInstrumentationArguments
Expand Down
60 changes: 14 additions & 46 deletions firebase-dataconnect/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,25 @@ package com.google.firebase.dataconnect {
ctor public AnyValue(@NonNull String value);
ctor public AnyValue(boolean value);
ctor public AnyValue(double value);
method public <T> T decode(@NonNull kotlinx.serialization.DeserializationStrategy<? extends T> deserializer, @Nullable kotlinx.serialization.modules.SerializersModule serializersModule = null);
method public inline <reified T> T decode();
method @NonNull public Object getValue();
property @NonNull public final Object value;
field @NonNull public static final com.google.firebase.dataconnect.AnyValue.Companion Companion;
}

public static final class AnyValue.Companion {
method @NonNull public <T> com.google.firebase.dataconnect.AnyValue encode(@Nullable T value, @NonNull kotlinx.serialization.SerializationStrategy<? super T> serializer, @Nullable kotlinx.serialization.modules.SerializersModule serializersModule = null);
method public inline <reified T> com.google.firebase.dataconnect.AnyValue encode(@Nullable T value);
method @NonNull public com.google.firebase.dataconnect.AnyValue fromAny(@NonNull Object value);
method @Nullable public com.google.firebase.dataconnect.AnyValue fromNullableAny(@Nullable Object value);
}

public final class AnyValueKt {
method public static <T> T decode(@NonNull com.google.firebase.dataconnect.AnyValue, @NonNull kotlinx.serialization.DeserializationStrategy<? extends T> deserializer, @Nullable kotlinx.serialization.modules.SerializersModule serializersModule = null);
method public static inline <reified T> T decode(@NonNull com.google.firebase.dataconnect.AnyValue);
method @NonNull public static <T> com.google.firebase.dataconnect.AnyValue encode(@NonNull com.google.firebase.dataconnect.AnyValue.Companion, @Nullable T value, @NonNull kotlinx.serialization.SerializationStrategy<? super T> serializer, @Nullable kotlinx.serialization.modules.SerializersModule serializersModule = null);
method public static inline <reified T> com.google.firebase.dataconnect.AnyValue encode(@NonNull com.google.firebase.dataconnect.AnyValue.Companion, @Nullable T value);
method @NonNull public static com.google.firebase.dataconnect.AnyValue fromAny(@NonNull com.google.firebase.dataconnect.AnyValue.Companion, @NonNull Object value);
method @Nullable public static com.google.firebase.dataconnect.AnyValue fromNullableAny(@NonNull com.google.firebase.dataconnect.AnyValue.Companion, @Nullable Object value);
}

public final class ConnectorConfig {
ctor public ConnectorConfig(@NonNull String connector, @NonNull String location, @NonNull String serviceId);
method @NonNull public com.google.firebase.dataconnect.ConnectorConfig copy(@NonNull String connector = connector, @NonNull String location = location, @NonNull String serviceId = serviceId);
method @NonNull public String getConnector();
method @NonNull public String getLocation();
method @NonNull public String getServiceId();
Expand All @@ -32,20 +34,24 @@ package com.google.firebase.dataconnect {
property @NonNull public final String serviceId;
}

public final class ConnectorConfigKt {
method @NonNull public static com.google.firebase.dataconnect.ConnectorConfig copy(@NonNull com.google.firebase.dataconnect.ConnectorConfig, @NonNull String connector = connector, @NonNull String location = location, @NonNull String serviceId = serviceId);
}

public class DataConnectException extends java.lang.Exception {
ctor public DataConnectException(@NonNull String message, @Nullable Throwable cause = null);
}

public final class DataConnectSettings {
ctor public DataConnectSettings(@NonNull String host = "firebasedataconnect.googleapis.com", boolean sslEnabled = true);
method @NonNull public com.google.firebase.dataconnect.DataConnectSettings copy(@NonNull String host = host, boolean sslEnabled = sslEnabled);
method @NonNull public String getHost();
method public boolean getSslEnabled();
property @NonNull public final String host;
property public final boolean sslEnabled;
}

public final class DataConnectSettingsKt {
method @NonNull public static com.google.firebase.dataconnect.DataConnectSettings copy(@NonNull com.google.firebase.dataconnect.DataConnectSettings, @NonNull String host = host, boolean sslEnabled = sslEnabled);
}

public interface FirebaseDataConnect extends java.lang.AutoCloseable {
Expand Down Expand Up @@ -216,28 +222,6 @@ package com.google.firebase.dataconnect {

}

package com.google.firebase.dataconnect.core {

public final class DataConnectCredentialsTokenManagerKt {
}

public final class DataConnectGrpcClientKt {
}

public final class FirebaseDataConnectFactoryKt {
}

public final class LoggerKt {
}

public final class MutationRefImplKt {
}

public final class QueryRefImplKt {
}

}

package com.google.firebase.dataconnect.generated {

public interface GeneratedConnector {
Expand Down Expand Up @@ -307,19 +291,3 @@ package com.google.firebase.dataconnect.serializers {

}

package com.google.firebase.dataconnect.util {

public final class ProtoStructDecoderKt {
}

public final class ProtoStructEncoderKt {
}

public final class ProtoUtilKt {
}

public final class UtilKt {
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.google.firebase.dataconnect.AnyValue
import com.google.firebase.dataconnect.DataConnectException
import com.google.firebase.dataconnect.OperationRef
import com.google.firebase.dataconnect.connectors.demo.testutil.DemoConnectorIntegrationTestBase
import com.google.firebase.dataconnect.fromAny
import com.google.firebase.dataconnect.generated.GeneratedMutation
import com.google.firebase.dataconnect.generated.GeneratedQuery
import com.google.firebase.dataconnect.testutil.EdgeCases
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import com.google.firebase.dataconnect.testutil.operationName
import com.google.firebase.dataconnect.testutil.schemas.PersonSchema
import com.google.firebase.dataconnect.testutil.schemas.PersonSchema.GetPersonAuthQuery
import com.google.firebase.dataconnect.testutil.schemas.randomPersonId
import com.google.firebase.dataconnect.util.buildStructProto
import com.google.firebase.dataconnect.util.ProtoUtil.buildStructProto
import com.google.firebase.util.nextAlphanumericString
import google.firebase.dataconnect.proto.executeMutationResponse
import google.firebase.dataconnect.proto.executeQueryResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package com.google.firebase.dataconnect.testutil

import com.google.firebase.FirebaseApp
import com.google.firebase.dataconnect.FirebaseDataConnect
import com.google.firebase.dataconnect.util.buildStructProto
import com.google.firebase.dataconnect.util.ProtoUtil.buildStructProto
import google.firebase.dataconnect.proto.ConnectorServiceGrpc
import google.firebase.dataconnect.proto.ExecuteMutationRequest
import google.firebase.dataconnect.proto.ExecuteMutationResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.google.firebase.dataconnect.testutil.schemas

import com.google.firebase.dataconnect.FirebaseDataConnect
import com.google.firebase.dataconnect.copy
import com.google.firebase.dataconnect.testutil.DataConnectIntegrationTestBase
import com.google.firebase.dataconnect.testutil.DataConnectIntegrationTestBase.Companion.testConnectorConfig
import com.google.firebase.dataconnect.testutil.TestDataConnectFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.google.firebase.dataconnect.testutil.schemas

import com.google.firebase.dataconnect.FirebaseDataConnect
import com.google.firebase.dataconnect.copy
import com.google.firebase.dataconnect.testutil.DataConnectIntegrationTestBase
import com.google.firebase.dataconnect.testutil.DataConnectIntegrationTestBase.Companion.testConnectorConfig
import com.google.firebase.dataconnect.testutil.TestDataConnectFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@

package com.google.firebase.dataconnect

import com.google.firebase.dataconnect.AnyValue.Companion.serializer
import com.google.firebase.dataconnect.serializers.AnyValueSerializer
import com.google.firebase.dataconnect.util.decodeFromValue
import com.google.firebase.dataconnect.util.encodeToValue
import com.google.firebase.dataconnect.util.toAny
import com.google.firebase.dataconnect.util.toCompactString
import com.google.firebase.dataconnect.util.toValueProto
import com.google.firebase.dataconnect.util.ProtoUtil.decodeFromValue
import com.google.firebase.dataconnect.util.ProtoUtil.encodeToValue
import com.google.firebase.dataconnect.util.ProtoUtil.toAny
import com.google.firebase.dataconnect.util.ProtoUtil.toCompactString
import com.google.firebase.dataconnect.util.ProtoUtil.toValueProto
import com.google.protobuf.Struct
import com.google.protobuf.Value
import kotlinx.serialization.DeserializationStrategy
Expand Down Expand Up @@ -141,30 +142,6 @@ public class AnyValue internal constructor(internal val protoValue: Value) {
// of this class asserts that `protoValue` is not NULL_VALUE.
get() = protoValue.toAny()!!

/**
* Decodes the encapsulated value using the given deserializer.
*
* @param deserializer The deserializer for the decoder to use.
* @param serializersModule a [SerializersModule] to use during deserialization; may be `null`
* (the default) to _not_ use a [SerializersModule] to use during deserialization.
*
* @return the object of type `T` created by decoding the encapsulated value using the given
* deserializer.
*/
public fun <T> decode(
deserializer: DeserializationStrategy<T>,
serializersModule: SerializersModule? = null
): T = decodeFromValue(protoValue, deserializer, serializersModule)

/**
* Decodes the encapsulated value using the _default_ serializer for the return type, as computed
* by [serializer].
*
* @return the object of type `T` created by decoding the encapsulated value using the _default_
* serializer for the return type, as computed by [serializer].
*/
public inline fun <reified T> decode(): T = decode(serializer<T>())

/**
* Compares this object with another object for equality.
*
Expand Down Expand Up @@ -196,67 +173,95 @@ public class AnyValue internal constructor(internal val protoValue: Value) {
*/
override fun toString(): String = protoValue.toCompactString(keySortSelector = { it })

public companion object {
/**
* Provides extension functions that can be used independently of a specified [AnyValue] instance.
*/
public companion object
}

/**
* Encodes the given value using the given serializer to an [AnyValue] object, and returns it.
*
* @param value the value to serialize.
* @param serializer the serializer for the encoder to use.
* @param serializersModule a [SerializersModule] to use during serialization; may be `null`
* (the default) to _not_ use a [SerializersModule] to use during serialization.
*
* @return a new `AnyValue` object whose encapsulated value is the encoding of the given value
* when decoded with the given serializer.
*/
public fun <T> encode(
value: T,
serializer: SerializationStrategy<T>,
serializersModule: SerializersModule? = null
): AnyValue = AnyValue(encodeToValue(value, serializer, serializersModule))
/**
* Decodes the encapsulated value using the given deserializer.
*
* @param deserializer The deserializer for the decoder to use.
* @param serializersModule a [SerializersModule] to use during deserialization; may be `null` (the
* default) to _not_ use a [SerializersModule] to use during deserialization.
*
* @return the object of type `T` created by decoding the encapsulated value using the given
* deserializer.
*/
public fun <T> AnyValue.decode(
deserializer: DeserializationStrategy<T>,
serializersModule: SerializersModule? = null
): T = decodeFromValue(protoValue, deserializer, serializersModule)

/**
* Encodes the given value using the given _default_ serializer for the given object, as
* computed by [serializer].
*
* @param value the value to serialize.
* @return a new `AnyValue` object whose encapsulated value is the encoding of the given value
* when decoded with the _default_ serializer for the given object, as computed by [serializer].
*/
public inline fun <reified T> encode(value: T): AnyValue = encode(value, serializer<T>())
/**
* Decodes the encapsulated value using the _default_ serializer for the return type, as computed by
* [serializer].
*
* @return the object of type `T` created by decoding the encapsulated value using the _default_
* serializer for the return type, as computed by [serializer].
*/
public inline fun <reified T> AnyValue.decode(): T = decode(serializer<T>())

/**
* Creates and returns an `AnyValue` object created using the `AnyValue` constructor that
* corresponds to the runtime type of the given value, or returns `null` if the given value is
* `null`.
*
* @throws IllegalArgumentException if the given value is not supported by `AnyValue`; see the
* `AnyValue` constructor for details.
*/
@JvmName("fromNullableAny")
public fun fromAny(value: Any?): AnyValue? = if (value === null) null else fromAny(value)
/**
* Encodes the given value using the given serializer to an [AnyValue] object, and returns it.
*
* @param value the value to serialize.
* @param serializer the serializer for the encoder to use.
* @param serializersModule a [SerializersModule] to use during serialization; may be `null` (the
* default) to _not_ use a [SerializersModule] to use during serialization.
*
* @return a new `AnyValue` object whose encapsulated value is the encoding of the given value when
* decoded with the given serializer.
*/
public fun <T> AnyValue.Companion.encode(
value: T,
serializer: SerializationStrategy<T>,
serializersModule: SerializersModule? = null
): AnyValue = AnyValue(encodeToValue(value, serializer, serializersModule))

/**
* Creates and returns an `AnyValue` object created using the `AnyValue` constructor that
* corresponds to the runtime type of the given value.
*
* @throws IllegalArgumentException if the given value is not supported by `AnyValue`; see the
* `AnyValue` constructor for details.
*/
public fun fromAny(value: Any): AnyValue {
@Suppress("UNCHECKED_CAST")
return when (value) {
is String -> AnyValue(value)
is Boolean -> AnyValue(value)
is Double -> AnyValue(value)
is List<*> -> AnyValue(value)
is Map<*, *> -> AnyValue(value as Map<String, Any?>)
else ->
throw IllegalArgumentException(
"unsupported type: ${value::class.qualifiedName}" +
" (supported types: null, String, Boolean, Double, List<Any?>, Map<String, Any?>)"
)
}
}
/**
* Encodes the given value using the given _default_ serializer for the given object, as computed by
* [serializer].
*
* @param value the value to serialize.
* @return a new `AnyValue` object whose encapsulated value is the encoding of the given value when
* decoded with the _default_ serializer for the given object, as computed by [serializer].
*/
public inline fun <reified T> AnyValue.Companion.encode(value: T): AnyValue =
encode(value, serializer<T>())

/**
* Creates and returns an `AnyValue` object created using the `AnyValue` constructor that
* corresponds to the runtime type of the given value, or returns `null` if the given value is
* `null`.
*
* @throws IllegalArgumentException if the given value is not supported by `AnyValue`; see the
* `AnyValue` constructor for details.
*/
@JvmName("fromNullableAny")
public fun AnyValue.Companion.fromAny(value: Any?): AnyValue? =
if (value === null) null else fromAny(value)

/**
* Creates and returns an `AnyValue` object created using the `AnyValue` constructor that
* corresponds to the runtime type of the given value.
*
* @throws IllegalArgumentException if the given value is not supported by `AnyValue`; see the
* `AnyValue` constructor for details.
*/
public fun AnyValue.Companion.fromAny(value: Any): AnyValue {
@Suppress("UNCHECKED_CAST")
return when (value) {
is String -> AnyValue(value)
is Boolean -> AnyValue(value)
is Double -> AnyValue(value)
is List<*> -> AnyValue(value)
is Map<*, *> -> AnyValue(value as Map<String, Any?>)
else ->
throw IllegalArgumentException(
"unsupported type: ${value::class.qualifiedName}" +
" (supported types: null, String, Boolean, Double, List<Any?>, Map<String, Any?>)"
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ public class ConnectorConfig(
public val serviceId: String
) {

/** Creates and returns a new [ConnectorConfig] instance with the given property values. */
public fun copy(
connector: String = this.connector,
location: String = this.location,
serviceId: String = this.serviceId
): ConnectorConfig =
ConnectorConfig(connector = connector, location = location, serviceId = serviceId)

/**
* Compares this object with another object for equality.
*
Expand Down Expand Up @@ -85,3 +77,11 @@ public class ConnectorConfig(
override fun toString(): String =
"ConnectorConfig(connector=$connector, location=$location, serviceId=$serviceId)"
}

/** Creates and returns a new [ConnectorConfig] instance with the given property values. */
public fun ConnectorConfig.copy(
connector: String = this.connector,
location: String = this.location,
serviceId: String = this.serviceId
): ConnectorConfig =
ConnectorConfig(connector = connector, location = location, serviceId = serviceId)
Loading
Loading