Skip to content

Commit 6aef9dc

Browse files
Merge branch 'master' into database-transactions
2 parents 7425a6b + f85e46a commit 6aef9dc

File tree

56 files changed

+742
-129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+742
-129
lines changed

.github/workflows/pull_request.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ jobs:
3030
- name: Assemble
3131
run: ./gradlew assemble
3232
- name: Run JS Tests
33-
run: ./gradlew cleanTest jsTest
33+
run: ./gradlew cleanTest jsLegacyTest
3434
- name: Upload JS test artifact
3535
uses: actions/upload-artifact@v2
3636
if: failure()
3737
with:
3838
name: "JS Test Report HTML"
39-
path: "firebase-firestore/build/reports/tests/jsTest/"
39+
path: "firebase-firestore/build/reports/tests/jsLegacyTest/"
4040
- name: Run iOS Tests
4141
run: ./gradlew cleanTest iosX64Test
4242
- name: Upload iOS test artifact

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,13 @@ You can also omit the serializer but this is discouraged due to a [current limit
9393

9494
```kotlin
9595
@Serializable
96-
data class Post(val timestamp: Double = ServerValue.TIMESTAMP)
96+
data class Post(
97+
// In case using Realtime Database.
98+
val timestamp: Double = ServerValue.TIMESTAMP,
99+
// In case using Cloud Firestore.
100+
val timestamp: Double = FieldValue.serverTimestamp,
101+
)
102+
97103
```
98104

99105
<h3><a href="https://kotlinlang.org/docs/reference/functions.html#default-arguments">Default arguments</a></h3>

build.gradle.kts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,25 @@ buildscript {
1717
}
1818
}
1919
dependencies {
20-
classpath("com.android.tools.build:gradle:7.0.1")
20+
classpath("com.android.tools.build:gradle:7.0.3")
2121
classpath("com.adarshr:gradle-test-logger-plugin:2.1.1")
2222
}
2323
}
2424

2525
val targetSdkVersion by extra(30)
26-
val minSdkVersion by extra(16)
26+
val minSdkVersion by extra(19)
2727

2828
tasks {
2929
val updateVersions by registering {
3030
dependsOn(
3131
"firebase-app:updateVersion", "firebase-app:updateDependencyVersion",
3232
"firebase-auth:updateVersion", "firebase-auth:updateDependencyVersion",
3333
"firebase-common:updateVersion", "firebase-common:updateDependencyVersion",
34+
"firebase-config:updateVersion", "firebase-config:updateDependencyVersion",
3435
"firebase-database:updateVersion", "firebase-database:updateDependencyVersion",
3536
"firebase-firestore:updateVersion", "firebase-firestore:updateDependencyVersion",
3637
"firebase-functions:updateVersion", "firebase-functions:updateDependencyVersion",
37-
"firebase-config:updateVersion", "firebase-config:updateDependencyVersion"
38+
"firebase-installations:updateVersion", "firebase-installations:updateDependencyVersion"
3839
)
3940
}
4041
}
@@ -154,24 +155,25 @@ subprojects {
154155
}
155156
}
156157

157-
if (projectDir.resolve("src/nativeInterop/cinterop/Cartfile").exists()) { // skipping firebase-common module
158-
listOf("bootstrap", "update").forEach {
158+
val carthageTasks = if (projectDir.resolve("src/nativeInterop/cinterop/Cartfile").exists()) { // skipping firebase-common module
159+
listOf("bootstrap", "update").map {
159160
task<Exec>("carthage${it.capitalize()}") {
160161
group = "carthage"
161162
executable = "carthage"
162163
args(
163164
it,
164165
"--project-directory", projectDir.resolve("src/nativeInterop/cinterop"),
165-
"--platform", "iOS",
166-
"--cache-builds"
166+
"--platform", "iOS"
167167
)
168168
}
169169
}
170-
}
170+
} else emptyList()
171171

172172
if (Os.isFamily(Os.FAMILY_MAC)) {
173173
withType(org.jetbrains.kotlin.gradle.tasks.CInteropProcess::class) {
174-
dependsOn("carthageBootstrap")
174+
if (carthageTasks.isNotEmpty()) {
175+
dependsOn("carthageBootstrap")
176+
}
175177
}
176178
}
177179

@@ -195,12 +197,12 @@ subprojects {
195197
}
196198

197199
dependencies {
198-
"commonMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2")
199-
"androidMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.5.2")
200-
"androidMainImplementation"(platform("com.google.firebase:firebase-bom:28.4.1"))
200+
"commonMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2-native-mt")
201+
"androidMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.5.2-native-mt")
202+
"androidMainImplementation"(platform("com.google.firebase:firebase-bom:29.0.1"))
201203
"commonTestImplementation"(kotlin("test-common"))
202204
"commonTestImplementation"(kotlin("test-annotations-common"))
203-
"commonTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2")
205+
"commonTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2-native-mt")
204206
"jsTestImplementation"(kotlin("test-js"))
205207
"androidAndroidTestImplementation"(kotlin("test-junit"))
206208
"androidAndroidTestImplementation"("junit:junit:4.13.2")

firebase-app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ kotlin {
9090
compilations.getByName("main") {
9191
cinterops.create("FirebaseCore") {
9292
compilerOpts(nativeFrameworkPaths.map { "-F$it" })
93-
extraOpts("-verbose")
93+
extraOpts = listOf("-compiler-option", "-DNS_FORMAT_ARGUMENT(A)=", "-verbose")
9494
}
9595
}
9696
}
@@ -134,7 +134,7 @@ kotlin {
134134

135135
val androidMain by getting {
136136
dependencies {
137-
api("com.google.firebase:firebase-common-ktx")
137+
api("com.google.firebase:firebase-common")
138138
}
139139
}
140140

firebase-app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
2525
"dependencies": {
2626
"@gitlive/firebase-common": "1.4.3",
27-
"firebase": "8.10.0",
27+
"firebase": "9.4.1",
2828
"kotlin": "1.5.31",
29-
"kotlinx-coroutines-core": "1.5.2"
29+
"kotlinx-coroutines-core": "1.5.2-native-mt"
3030
}
3131
}

firebase-app/src/iosMain/c_interop/Cartfile.resolved

Lines changed: 0 additions & 1 deletion
This file was deleted.

firebase-app/src/jsTest/kotlin/dev/gitlive/firebase/firebase.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ actual fun runTest(test: suspend () -> Unit) = GlobalScope
1414
try {
1515
test()
1616
} catch (e: dynamic) {
17-
e.log()
17+
(e as? Throwable)?.log()
1818
throw e
1919
}
2020
}.asDynamic()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json" == 8.8.0
1+
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json" == 8.9.1

firebase-auth/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ kotlin {
119119
compilations.getByName("main") {
120120
cinterops.create("FirebaseAuth") {
121121
compilerOpts(nativeFrameworkPaths.map { "-F$it" })
122-
extraOpts("-verbose")
122+
extraOpts = listOf("-compiler-option", "-DNS_FORMAT_ARGUMENT(A)=", "-verbose")
123123
}
124124
}
125125
}
@@ -165,7 +165,7 @@ kotlin {
165165

166166
val androidMain by getting {
167167
dependencies {
168-
api("com.google.firebase:firebase-auth-ktx")
168+
api("com.google.firebase:firebase-auth")
169169
}
170170
}
171171

firebase-auth/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
2525
"dependencies": {
2626
"@gitlive/firebase-app": "1.4.3",
27-
"firebase": "8.10.0",
27+
"firebase": "9.4.1",
2828
"kotlin": "1.5.31",
29-
"kotlinx-coroutines-core": "1.5.2"
29+
"kotlinx-coroutines-core": "1.5.2-native-mt"
3030
}
3131
}

firebase-auth/src/iosMain/c_interop/Cartfile.resolved

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAuthBinary.json" == 8.8.0
1+
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAuthBinary.json" == 8.9.1

firebase-common/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ kotlin {
9292

9393
val androidMain by getting {
9494
dependencies {
95-
api("com.google.firebase:firebase-common-ktx")
95+
api("com.google.firebase:firebase-common")
9696
}
9797
}
9898

@@ -108,7 +108,7 @@ kotlin {
108108

109109
val jsMain by getting {
110110
dependencies {
111-
api(npm("firebase", "8.7.1"))
111+
api(npm("firebase", "9.4.1"))
112112
}
113113
}
114114
}

firebase-common/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
},
2424
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-multiplatform-sdk",
2525
"dependencies": {
26-
"firebase": "8.10.0",
26+
"firebase": "9.4.1",
2727
"kotlin": "1.5.31",
28-
"kotlinx-coroutines-core": "1.5.2",
28+
"kotlinx-coroutines-core": "1.5.2-native-mt",
2929
"kotlinx-serialization-kotlinx-serialization-runtime": "1.3.0"
3030
}
3131
}

firebase-common/src/jsMain/kotlin/dev/gitlive/firebase/externals.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
@file:JsModule("firebase/app")
5+
@file:JsModule("firebase/compat/app")
66

77
package dev.gitlive.firebase
88

@@ -385,10 +385,12 @@ external object firebase {
385385
fun limit(limit: Double): Query
386386
fun orderBy(field: String, direction: Any): Query
387387
fun orderBy(field: FieldPath, direction: Any): Query
388+
fun startAfter(document: DocumentSnapshot): Query
388389
}
389390

390391
open class CollectionReference : Query {
391392
val path: String
393+
val parent: DocumentReference?
392394
fun doc(path: String = definedExternally): DocumentReference
393395
fun add(data: Any): Promise<DocumentReference>
394396
}
@@ -425,6 +427,7 @@ external object firebase {
425427
open class DocumentReference {
426428
val id: String
427429
val path: String
430+
val parent: CollectionReference
428431

429432
fun collection(path: String): CollectionReference
430433
fun get(options: Any? = definedExternally): Promise<DocumentSnapshot>
@@ -501,4 +504,14 @@ external object firebase {
501504
fun getSource(): String
502505
}
503506
}
507+
508+
fun installations(app: App? = definedExternally): installations.Installations
509+
510+
object installations {
511+
interface Installations {
512+
fun delete(): Promise<Unit>
513+
fun getId(): Promise<String>
514+
fun getToken(forceRefresh: Boolean): Promise<String>
515+
}
516+
}
504517
}

firebase-common/src/jsMain/kotlin/dev/gitlive/firebase/externals2.kt

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,26 @@ package dev.gitlive.firebase
66

77
import kotlin.js.Promise
88

9-
@JsModule("firebase/functions")
10-
external object functions
11-
12-
@JsModule("firebase/auth")
9+
@JsModule("firebase/compat/auth")
10+
@JsName("default")
1311
external object auth
1412

15-
@JsModule("firebase/database")
13+
@JsModule("firebase/compat/database")
14+
@JsName("default")
1615
external object database
1716

18-
@JsModule("firebase/firestore")
17+
@JsModule("firebase/compat/firestore")
18+
@JsName("default")
1919
external object firestore
2020

21-
@JsModule("firebase/remote-config")
21+
@JsModule("firebase/compat/functions")
22+
@JsName("default")
23+
external object functions
24+
25+
external object installations
26+
27+
@JsModule("firebase/compat/remote-config")
28+
@JsName("default")
2229
external object remoteConfig
2330

2431
typealias SnapshotCallback = (data: firebase.database.DataSnapshot, b: String?) -> Unit

firebase-config/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ kotlin {
104104
compilations.getByName("main") {
105105
cinterops.create("FirebaseRemoteConfig") {
106106
compilerOpts(nativeFrameworkPaths.map { "-F$it" })
107-
extraOpts("-verbose")
107+
extraOpts = listOf("-compiler-option", "-DNS_FORMAT_ARGUMENT(A)=", "-verbose")
108108
}
109109
}
110110
}

firebase-config/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
2525
"dependencies": {
2626
"@gitlive/firebase-app": "1.4.3",
27-
"firebase": "8.10.0",
27+
"firebase": "9.4.1",
2828
"kotlin": "1.5.31",
29-
"kotlinx-coroutines-core": "1.5.2"
29+
"kotlinx-coroutines-core": "1.5.2-native-mt"
3030
}
3131
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseRemoteConfigBinary.json" == 8.8.0
1+
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseRemoteConfigBinary.json" == 8.9.1

firebase-database/build.gradle.kts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ version = project.property("firebase-database.version") as String
1010
plugins {
1111
id("com.android.library")
1212
kotlin("multiplatform")
13-
kotlin("plugin.serialization") version "1.5.10"
13+
kotlin("plugin.serialization") version "1.5.31"
1414
}
1515

1616
repositories {
@@ -23,11 +23,17 @@ android {
2323
defaultConfig {
2424
minSdk = property("minSdkVersion") as Int
2525
targetSdk = property("targetSdkVersion") as Int
26+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
27+
multiDexEnabled = true
2628
}
2729
sourceSets {
2830
getByName("main") {
2931
manifest.srcFile("src/androidMain/AndroidManifest.xml")
3032
}
33+
getByName("androidTest"){
34+
java.srcDir(file("src/androidAndroidTest/kotlin"))
35+
manifest.srcFile("src/androidAndroidTest/AndroidManifest.xml")
36+
}
3137
}
3238
testOptions {
3339
unitTests.apply {
@@ -96,7 +102,7 @@ kotlin {
96102
compilations.getByName("main") {
97103
cinterops.create("FirebaseDatabase") {
98104
compilerOpts(nativeFrameworkPaths.map { "-F$it" })
99-
extraOpts("-verbose")
105+
extraOpts = listOf("-compiler-option", "-DNS_FORMAT_ARGUMENT(A)=", "-verbose")
100106
}
101107
}
102108
}
@@ -144,7 +150,7 @@ kotlin {
144150

145151
val androidMain by getting {
146152
dependencies {
147-
api("com.google.firebase:firebase-database-ktx")
153+
api("com.google.firebase:firebase-database")
148154
}
149155
}
150156

firebase-database/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
2525
"dependencies": {
2626
"@gitlive/firebase-app": "1.4.3",
27-
"firebase": "8.10.0",
27+
"firebase": "9.4.1",
2828
"kotlin": "1.5.31",
29-
"kotlinx-coroutines-core": "1.5.2"
29+
"kotlinx-coroutines-core": "1.5.2-native-mt"
3030
}
3131
}

firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/database.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ actual class FirebaseDatabase internal constructor(val android: com.google.fireb
6666
actual fun reference(path: String) =
6767
DatabaseReference(android.getReference(path), persistenceEnabled)
6868

69+
actual fun reference() =
70+
DatabaseReference(android.reference, persistenceEnabled)
71+
6972
actual fun setPersistenceEnabled(enabled: Boolean) =
7073
android.setPersistenceEnabled(enabled).also { persistenceEnabled = enabled }
7174

firebase-database/src/commonMain/kotlin/dev/gitlive/firebase/database/database.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ expect fun Firebase.database(app: FirebaseApp, url: String): FirebaseDatabase
2626

2727
expect class FirebaseDatabase {
2828
fun reference(path: String): DatabaseReference
29+
fun reference(): DatabaseReference
2930
fun setPersistenceEnabled(enabled: Boolean)
3031
fun setLoggingEnabled(enabled: Boolean)
3132
fun useEmulator(host: String, port: Int)

0 commit comments

Comments
 (0)