Skip to content

Commit

Permalink
Merge branch 'master' into sdk-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nbransby authored Nov 23, 2021
2 parents fc3895a + 0ff3444 commit f9593aa
Show file tree
Hide file tree
Showing 22 changed files with 26 additions and 56 deletions.
3 changes: 1 addition & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ subprojects {
args(
it,
"--project-directory", projectDir.resolve("src/nativeInterop/cinterop"),
"--platform", "iOS",
"--cache-builds"
"--platform", "iOS"
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion firebase-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ kotlin {
compilations.getByName("main") {
cinterops.create("FirebaseCore") {
compilerOpts(nativeFrameworkPaths.map { "-F$it" })
extraOpts("-verbose")
extraOpts = listOf("-compiler-option", "-DNS_FORMAT_ARGUMENT(A)=", "-verbose")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion firebase-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
"dependencies": {
"@gitlive/firebase-common": "1.4.3",
"firebase": "8.10.0",
"firebase": "9.4.1",
"kotlin": "1.5.31",
"kotlinx-coroutines-core": "1.5.2"
}
Expand Down
2 changes: 1 addition & 1 deletion firebase-auth/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ kotlin {
compilations.getByName("main") {
cinterops.create("FirebaseAuth") {
compilerOpts(nativeFrameworkPaths.map { "-F$it" })
extraOpts("-verbose")
extraOpts = listOf("-compiler-option", "-DNS_FORMAT_ARGUMENT(A)=", "-verbose")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion firebase-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
"dependencies": {
"@gitlive/firebase-app": "1.4.3",
"firebase": "8.10.0",
"firebase": "9.4.1",
"kotlin": "1.5.31",
"kotlinx-coroutines-core": "1.5.2"
}
Expand Down
2 changes: 1 addition & 1 deletion firebase-common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ kotlin {

val jsMain by getting {
dependencies {
api(npm("firebase", "8.10.0"))
api(npm("firebase", "9.4.1"))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion firebase-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-multiplatform-sdk",
"dependencies": {
"firebase": "8.10.0",
"firebase": "9.4.1",
"kotlin": "1.5.31",
"kotlinx-coroutines-core": "1.5.2",
"kotlinx-serialization-kotlinx-serialization-runtime": "1.3.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license.
*/

@file:JsModule("firebase/app")
@file:JsModule("firebase/compat/app")

package dev.gitlive.firebase

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@ package dev.gitlive.firebase

import kotlin.js.Promise

@JsModule("firebase/functions")
@JsModule("firebase/compat/functions")
@JsName("default")
external object functions

@JsModule("firebase/auth")
@JsModule("firebase/compat/auth")
@JsName("default")
external object auth

@JsModule("firebase/database")
@JsModule("firebase/compat/database")
@JsName("default")
external object database

@JsModule("firebase/firestore")
@JsModule("firebase/compat/firestore")
@JsName("default")
external object firestore

@JsModule("firebase/remote-config")
@JsModule("firebase/compat/remote-config")
@JsName("default")
external object remoteConfig

typealias SnapshotCallback = (data: firebase.database.DataSnapshot, b: String?) -> Unit
Expand Down
2 changes: 1 addition & 1 deletion firebase-config/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ kotlin {
compilations.getByName("main") {
cinterops.create("FirebaseRemoteConfig") {
compilerOpts(nativeFrameworkPaths.map { "-F$it" })
extraOpts("-verbose")
extraOpts = listOf("-compiler-option", "-DNS_FORMAT_ARGUMENT(A)=", "-verbose")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion firebase-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
"dependencies": {
"@gitlive/firebase-app": "1.4.3",
"firebase": "8.10.0",
"firebase": "9.4.1",
"kotlin": "1.5.31",
"kotlinx-coroutines-core": "1.5.2"
}
Expand Down
2 changes: 1 addition & 1 deletion firebase-database/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ kotlin {
compilations.getByName("main") {
cinterops.create("FirebaseDatabase") {
compilerOpts(nativeFrameworkPaths.map { "-F$it" })
extraOpts("-verbose")
extraOpts = listOf("-compiler-option", "-DNS_FORMAT_ARGUMENT(A)=", "-verbose")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion firebase-database/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
"dependencies": {
"@gitlive/firebase-app": "1.4.3",
"firebase": "8.10.0",
"firebase": "9.4.1",
"kotlin": "1.5.31",
"kotlinx-coroutines-core": "1.5.2"
}
Expand Down
2 changes: 1 addition & 1 deletion firebase-firestore/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ kotlin {
compilations.getByName("main") {
cinterops.create("FirebaseFirestore") {
compilerOpts(nativeFrameworkPaths.map { "-F$it" })
extraOpts("-verbose")
extraOpts = listOf("-compiler-option", "-DNS_FORMAT_ARGUMENT(A)=", "-verbose")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion firebase-firestore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
"dependencies": {
"@gitlive/firebase-app": "1.4.3",
"firebase": "8.10.0",
"firebase": "9.4.1",
"kotlin": "1.5.31",
"kotlinx-coroutines-core": "1.5.2"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,6 @@ actual class DocumentSnapshot(val android: com.google.firebase.firestore.Documen
actual fun <T> data(strategy: DeserializationStrategy<T>, serverTimestampBehavior: ServerTimestampBehavior): T =
decode(strategy, android.getData(serverTimestampBehavior.toAndroid()))

actual fun dataMap(serverTimestampBehavior: ServerTimestampBehavior): Map<String, Any?> =
android.getData(serverTimestampBehavior.toAndroid()) ?: emptyMap()

actual inline fun <reified T> get(field: String, serverTimestampBehavior: ServerTimestampBehavior): T =
decode(value = android.get(field, serverTimestampBehavior.toAndroid()))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,6 @@ expect class DocumentSnapshot {
inline fun <reified T: Any> data(serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE): T
fun <T> data(strategy: DeserializationStrategy<T>, serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE): T

fun dataMap(serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE): Map<String, Any?>

val exists: Boolean
val id: String
val reference: DocumentReference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ class FirebaseFirestoreTest {
val pendingWritesSnapshot = deferredPendingWritesSnapshot.await()
assertTrue(pendingWritesSnapshot.metadata.hasPendingWrites)
assertNull(pendingWritesSnapshot.get<Double?>("time", ServerTimestampBehavior.NONE))
assertNull(pendingWritesSnapshot.dataMap(ServerTimestampBehavior.NONE)["time"])
}

@Test
Expand All @@ -181,7 +180,6 @@ class FirebaseFirestoreTest {
val pendingWritesSnapshot = deferredPendingWritesSnapshot.await()
assertTrue(pendingWritesSnapshot.metadata.hasPendingWrites)
assertNotNull(pendingWritesSnapshot.get<Double?>("time", ServerTimestampBehavior.ESTIMATE))
assertNotNull(pendingWritesSnapshot.dataMap(ServerTimestampBehavior.ESTIMATE)["time"])
assertNotEquals(0.0, pendingWritesSnapshot.data(FirestoreTest.serializer(), ServerTimestampBehavior.ESTIMATE).time)
}

Expand All @@ -203,7 +201,6 @@ class FirebaseFirestoreTest {
val pendingWritesSnapshot = deferredPendingWritesSnapshot.await()
assertTrue(pendingWritesSnapshot.metadata.hasPendingWrites)
assertNull(pendingWritesSnapshot.get<Double?>("time", ServerTimestampBehavior.PREVIOUS))
assertNull(pendingWritesSnapshot.dataMap(ServerTimestampBehavior.PREVIOUS)["time"])
}

@Test
Expand All @@ -223,23 +220,6 @@ class FirebaseFirestoreTest {
assertEquals("AutoId", resultDoc.get("prop1"))
}

@Test
fun testDataMap() = runTest {
val doc = Firebase.firestore
.collection("testDataMap")
.document

doc.set(FirestoreTest.serializer(), FirestoreTest("dataMap", 123.45))

val resultDoc = Firebase.firestore
.collection("testDataMap")
.document(doc.id)
.get()

assertEquals(true, resultDoc.exists)
assertEquals(mapOf("prop1" to "dataMap", "time" to 123.45), resultDoc.dataMap())
}

private suspend fun setupFirestoreData() {
Firebase.firestore.collection("FirebaseFirestoreTest")
.document("one")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,12 +388,6 @@ actual class DocumentSnapshot(val ios: FIRDocumentSnapshot) {
return decode(strategy, data?.mapValues { (_, value) -> value?.takeIf { it !is NSNull } })
}

actual fun dataMap(serverTimestampBehavior: ServerTimestampBehavior): Map<String, Any?> =
ios.dataWithServerTimestampBehavior(serverTimestampBehavior.toIos())
?.map { (key, value) -> key.toString() to value?.takeIf { it !is NSNull } }
?.toMap()
?: emptyMap()

actual inline fun <reified T> get(field: String, serverTimestampBehavior: ServerTimestampBehavior): T {
val value = ios.valueForField(field, serverTimestampBehavior.toIos())?.takeIf { it !is NSNull }
return decode(value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,6 @@ actual class DocumentSnapshot(val js: firebase.firestore.DocumentSnapshot) {
actual fun <T> data(strategy: DeserializationStrategy<T>, serverTimestampBehavior: ServerTimestampBehavior): T =
rethrow { decode(strategy, js.data(getTimestampsOptions(serverTimestampBehavior))) }

actual fun dataMap(serverTimestampBehavior: ServerTimestampBehavior): Map<String, Any?> =
rethrow { mapOf(js.data(getTimestampsOptions(serverTimestampBehavior)).asDynamic()) }

actual inline fun <reified T> get(field: String, serverTimestampBehavior: ServerTimestampBehavior) =
rethrow { decode<T>(value = js.get(field, getTimestampsOptions(serverTimestampBehavior))) }

Expand Down
2 changes: 1 addition & 1 deletion firebase-functions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ kotlin {
compilations.getByName("main") {
cinterops.create("FirebaseFunctions") {
compilerOpts(nativeFrameworkPaths.map { "-F$it" })
extraOpts("-verbose")
extraOpts = listOf("-compiler-option", "-DNS_FORMAT_ARGUMENT(A)=", "-verbose")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion firebase-functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
"dependencies": {
"@gitlive/firebase-app": "1.4.3",
"firebase": "8.10.0",
"firebase": "9.4.1",
"kotlin": "1.5.31",
"kotlinx-coroutines-core": "1.5.2"
}
Expand Down

0 comments on commit f9593aa

Please sign in to comment.