From d8247c4e4b4cf3661f6695e3201d4e5effc6d174 Mon Sep 17 00:00:00 2001 From: mnbjhu Date: Mon, 4 Sep 2023 17:06:56 +0100 Subject: [PATCH 1/3] Added Docs blocks and @SurrealDbOnlyApi to 'kill' --- src/commonMain/kotlin/uk/gibby/driver/Surreal.kt | 5 ----- src/commonMain/kotlin/uk/gibby/driver/api/LiveQueryFlow.kt | 2 -- src/commonMain/kotlin/uk/gibby/driver/api/Observe.kt | 3 --- src/commonMain/kotlin/uk/gibby/driver/rpc/Kill.kt | 2 -- src/commonMain/kotlin/uk/gibby/driver/rpc/Live.kt | 2 -- src/commonTest/kotlin/KillTest.kt | 2 -- src/commonTest/kotlin/LiveQueryTest.kt | 2 -- 7 files changed, 18 deletions(-) diff --git a/src/commonMain/kotlin/uk/gibby/driver/Surreal.kt b/src/commonMain/kotlin/uk/gibby/driver/Surreal.kt index b05a567..63a593f 100644 --- a/src/commonMain/kotlin/uk/gibby/driver/Surreal.kt +++ b/src/commonMain/kotlin/uk/gibby/driver/Surreal.kt @@ -8,7 +8,6 @@ import kotlinx.coroutines.* import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.* import kotlinx.serialization.json.* -import uk.gibby.driver.annotation.SurrealDbNightlyOnlyApi import uk.gibby.driver.exception.LiveQueryKilledException import uk.gibby.driver.model.rpc.* import uk.gibby.driver.rpc.kill @@ -103,25 +102,21 @@ class Surreal(private val host: String, private val port: Int = 8000) { return channel.receive() } - @SurrealDbNightlyOnlyApi fun subscribeAsJson(liveQueryId: String): Flow> { val channel = liveQueries.getOrPut(liveQueryId) { Channel() } return channel.receiveAsFlow() } - @SurrealDbNightlyOnlyApi inline fun subscribe(liveQueryId: String): Flow> { return subscribeAsJson(liveQueryId).map { it.asType() } } - @SurrealDbNightlyOnlyApi fun unsubscribe(liveQueryId: String) { val channel = liveQueries[liveQueryId] channel?.cancel(LiveQueryKilledException) liveQueries.remove(liveQueryId) } - @SurrealDbNightlyOnlyApi internal fun triggerKill(liveQueryId: String) { context.launch { kill(liveQueryId) } } diff --git a/src/commonMain/kotlin/uk/gibby/driver/api/LiveQueryFlow.kt b/src/commonMain/kotlin/uk/gibby/driver/api/LiveQueryFlow.kt index 7553832..b365d48 100644 --- a/src/commonMain/kotlin/uk/gibby/driver/api/LiveQueryFlow.kt +++ b/src/commonMain/kotlin/uk/gibby/driver/api/LiveQueryFlow.kt @@ -4,7 +4,6 @@ import io.ktor.utils.io.core.* import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map import uk.gibby.driver.Surreal -import uk.gibby.driver.annotation.SurrealDbNightlyOnlyApi import uk.gibby.driver.model.rpc.LiveQueryAction /** @@ -18,7 +17,6 @@ import uk.gibby.driver.model.rpc.LiveQueryAction * @property connection The connection to the database * @constructor Creates a new live query flow */ -@SurrealDbNightlyOnlyApi class LiveQueryFlow( private val flow: Flow>, val id: String, diff --git a/src/commonMain/kotlin/uk/gibby/driver/api/Observe.kt b/src/commonMain/kotlin/uk/gibby/driver/api/Observe.kt index 9ab9dd7..ba6b083 100644 --- a/src/commonMain/kotlin/uk/gibby/driver/api/Observe.kt +++ b/src/commonMain/kotlin/uk/gibby/driver/api/Observe.kt @@ -2,7 +2,6 @@ package uk.gibby.driver.api import kotlinx.serialization.json.JsonElement import uk.gibby.driver.Surreal -import uk.gibby.driver.annotation.SurrealDbNightlyOnlyApi import uk.gibby.driver.rpc.live import uk.gibby.driver.model.rpc.asType import kotlin.jvm.JvmName @@ -16,7 +15,6 @@ import kotlin.jvm.JvmName * @return A [LiveQueryFlow] of [JsonElement]s */ @JvmName("observeJson") -@SurrealDbNightlyOnlyApi suspend fun Surreal.observeLiveQueryAsJson(table: String): LiveQueryFlow { val liveQueryId = live(table) return LiveQueryFlow( @@ -36,7 +34,6 @@ suspend fun Surreal.observeLiveQueryAsJson(table: String): LiveQueryFlowSurreal.observeLiveQuery(table: String): LiveQueryFlow { val jsonFlow = observeLiveQueryAsJson(table) return jsonFlow.map { it.asType() } diff --git a/src/commonMain/kotlin/uk/gibby/driver/rpc/Kill.kt b/src/commonMain/kotlin/uk/gibby/driver/rpc/Kill.kt index 49e0cf5..4ad5363 100644 --- a/src/commonMain/kotlin/uk/gibby/driver/rpc/Kill.kt +++ b/src/commonMain/kotlin/uk/gibby/driver/rpc/Kill.kt @@ -3,7 +3,6 @@ package uk.gibby.driver.rpc import kotlinx.serialization.json.add import kotlinx.serialization.json.buildJsonArray import uk.gibby.driver.Surreal -import uk.gibby.driver.annotation.SurrealDbNightlyOnlyApi /** * Kill @@ -12,7 +11,6 @@ import uk.gibby.driver.annotation.SurrealDbNightlyOnlyApi * * @param liveQueryId The id of the live query to kill */ -@SurrealDbNightlyOnlyApi suspend fun Surreal.kill(liveQueryId: String) { sendRequest("kill", buildJsonArray { add(liveQueryId) }) } diff --git a/src/commonMain/kotlin/uk/gibby/driver/rpc/Live.kt b/src/commonMain/kotlin/uk/gibby/driver/rpc/Live.kt index 6f51ac2..4c01910 100644 --- a/src/commonMain/kotlin/uk/gibby/driver/rpc/Live.kt +++ b/src/commonMain/kotlin/uk/gibby/driver/rpc/Live.kt @@ -4,7 +4,6 @@ import kotlinx.serialization.json.add import kotlinx.serialization.json.buildJsonArray import kotlinx.serialization.json.decodeFromJsonElement import uk.gibby.driver.Surreal -import uk.gibby.driver.annotation.SurrealDbNightlyOnlyApi import uk.gibby.driver.surrealJson @@ -16,7 +15,6 @@ import uk.gibby.driver.surrealJson * @param table Name of the table to 'LIVE SELECT' from * @return The id of the live query */ -@SurrealDbNightlyOnlyApi suspend fun Surreal.live(table: String): String { val response = sendRequest("live", buildJsonArray { add(table) }) return surrealJson.decodeFromJsonElement(response) diff --git a/src/commonTest/kotlin/KillTest.kt b/src/commonTest/kotlin/KillTest.kt index b299f57..9a361fa 100644 --- a/src/commonTest/kotlin/KillTest.kt +++ b/src/commonTest/kotlin/KillTest.kt @@ -1,6 +1,5 @@ import kotlinx.coroutines.test.runTest import uk.gibby.driver.Surreal -import uk.gibby.driver.annotation.SurrealDbNightlyOnlyApi import uk.gibby.driver.rpc.kill import uk.gibby.driver.rpc.live import uk.gibby.driver.rpc.signin @@ -8,7 +7,6 @@ import uk.gibby.driver.rpc.use import utils.cleanDatabase import kotlin.test.Test -@OptIn(SurrealDbNightlyOnlyApi::class) class KillTest { @Test fun testKill() = runTest { diff --git a/src/commonTest/kotlin/LiveQueryTest.kt b/src/commonTest/kotlin/LiveQueryTest.kt index 32c851a..8e31dff 100644 --- a/src/commonTest/kotlin/LiveQueryTest.kt +++ b/src/commonTest/kotlin/LiveQueryTest.kt @@ -1,7 +1,6 @@ import kotlinx.coroutines.flow.first import kotlinx.coroutines.test.runTest import uk.gibby.driver.Surreal -import uk.gibby.driver.annotation.SurrealDbNightlyOnlyApi import uk.gibby.driver.api.observeLiveQuery import uk.gibby.driver.exception.LiveQueryKilledException import uk.gibby.driver.model.rpc.LiveQueryAction @@ -11,7 +10,6 @@ import uk.gibby.driver.rpc.* import utils.cleanDatabase import kotlin.test.* -@OptIn(SurrealDbNightlyOnlyApi::class) class LiveQueryTest { @Test fun testObserve() = runTest { From 0464585df724b52b0860d2f8408202443ecf957e Mon Sep 17 00:00:00 2001 From: mnbjhu Date: Mon, 4 Sep 2023 17:07:56 +0100 Subject: [PATCH 2/3] Using the 'latest' surreal version in CI --- .github/workflows/gradle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 4ed9350..f786d14 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Start Surreal - run: docker run -d -p 8000:8000 surrealdb/surrealdb:nightly start --user root --pass root -- "memory" + run: docker run -d -p 8000:8000 surrealdb/surrealdb:latest start --user root --pass root -- "memory" - uses: actions/checkout@v3 - name: Set up JDK 11 uses: actions/setup-java@v3 From cbd37e8e1580d02c74344ab2f01748675c74afbd Mon Sep 17 00:00:00 2001 From: mnbjhu Date: Mon, 4 Sep 2023 17:29:36 +0100 Subject: [PATCH 3/3] Fixing patch tests --- src/commonMain/kotlin/uk/gibby/driver/rpc/Update.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/commonMain/kotlin/uk/gibby/driver/rpc/Update.kt b/src/commonMain/kotlin/uk/gibby/driver/rpc/Update.kt index 4fafe9b..ab52ec1 100644 --- a/src/commonMain/kotlin/uk/gibby/driver/rpc/Update.kt +++ b/src/commonMain/kotlin/uk/gibby/driver/rpc/Update.kt @@ -130,6 +130,7 @@ class UpdateBuilder(private val table: String, private val db: Surreal) { val response = db.sendRequest("patch", buildJsonArray { add(table) add(surrealJson.encodeToJsonElement(builder.build())) + add(true) }) return surrealJson.decodeFromJsonElement(response) } @@ -267,6 +268,7 @@ class UpdateIdBuilder(private val id: String, private val db: Surreal) { val result = db.sendRequest("patch", buildJsonArray { add(id) add(surrealJson.encodeToJsonElement(builder.build())) + add(true) }) return surrealJson.decodeFromJsonElement(result) }