Skip to content

Commit 17cd768

Browse files
committed
Merge remote-tracking branch 'origin/main' into sync-progress
2 parents 83f25bc + 16a79c5 commit 17cd768

File tree

79 files changed

+3971
-691
lines changed

Some content is hidden

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

79 files changed

+3971
-691
lines changed

.github/workflows/test.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ jobs:
1616
matrix:
1717
include:
1818
- os: macos-latest
19-
targets: iosSimulatorArm64Test jvmTest lintKotlin
19+
targets: iosSimulatorArm64Test macosArm64Test jvmTest
2020
- os: ubuntu-latest
21-
targets: testDebugUnitTest testReleaseUnitTest jvmTest
21+
targets: testDebugUnitTest testReleaseUnitTest jvmTest lintKotlin
2222
- os: windows-latest
2323
targets: jvmTest
2424
runs-on: ${{ matrix.os }}
@@ -44,4 +44,14 @@ jobs:
4444
./gradlew \
4545
-PGITHUB_PUBLISH_TOKEN=${{ secrets.GITHUB_TOKEN }} \
4646
${{ matrix.targets }}
47-
shell: bash
47+
shell: bash
48+
49+
# Credit: https://github.com/gradle/actions/issues/76#issuecomment-2007584323
50+
- name: Upload reports on failure
51+
if: failure()
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: report-for-${{ matrix.os }}
55+
path: |
56+
**/build/reports/
57+
**/build/test-results/

CHANGELOG.md

Lines changed: 67 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,45 @@
11
# Changelog
22

3-
## 1.0.0-BETA29 (unreleased)
3+
## 1.0.0-BETA31
4+
5+
* Added helpers for Attachment syncing.
6+
* Fix `getNextCrudTransaction()` only returning a single item.
7+
8+
## 1.0.0-BETA30
9+
10+
* Fix a deadlock when calling `connect()` immediately after opening a database.
11+
The issue has been introduced in version `1.0.0-BETA29`.
12+
13+
## 1.0.0-BETA29
414

515
* Fix potential race condition between jobs in `connect()` and `disconnect()`.
6-
* Report real-time progress information about downloads through `SyncStatus.downloadProgress`.
7-
* Compose: Add `composeState()` extension method on `SyncStatus`.
16+
* [JVM Windows] Fixed PowerSync Extension temporary file deletion error on process shutdown.
17+
* [iOS] Fixed issue where automatic driver migrations would fail with the error:
18+
19+
```
20+
Sqlite operation failure database is locked attempted to run migration and failed. closing connection
21+
```
22+
23+
* Fix race condition causing data received during uploads not to be applied.
824

925
## 1.0.0-BETA28
1026

1127
* Update PowerSync SQLite core extension to 0.3.12.
12-
* Added queing protection and warnings when connecting multiple PowerSync clients to the same database file.
13-
* Improved concurrent SQLite connection support accross various platforms. All platforms now use a single write connection and multiple read connections for concurrent read queries.
14-
* Added the ability to open a SQLite database given a custom `dbDirectory` path. This is currently not supported on iOS due to internal driver restrictions.
28+
* Added queing protection and warnings when connecting multiple PowerSync clients to the same
29+
database file.
30+
* Improved concurrent SQLite connection support accross various platforms. All platforms now use a
31+
single write connection and multiple read connections for concurrent read queries.
32+
* Added the ability to open a SQLite database given a custom `dbDirectory` path. This is currently
33+
not supported on iOS due to internal driver restrictions.
1534
* Internaly improved the linking of SQLite for iOS.
1635
* Enabled Full Text Search on iOS platforms.
1736
* Added the ability to update the schema for existing PowerSync clients.
18-
* Fixed bug where local only, insert only and view name overrides were not applied for schema tables.
19-
* The Android SQLite driver now uses the [Xerial JDBC library](https://github.com/xerial/sqlite-jdbc). This removes the requirement for users to add the jitpack Maven repository to their projects.
37+
* Fixed bug where local only, insert only and view name overrides were not applied for schema
38+
tables.
39+
* The Android SQLite driver now uses
40+
the [Xerial JDBC library](https://github.com/xerial/sqlite-jdbc). This removes the requirement for
41+
users to add the jitpack Maven repository to their projects.
42+
2043
```diff
2144
// settings.gradle.kts example
2245
repositories {
@@ -44,8 +67,10 @@
4467

4568
## 1.0.0-BETA24
4669

47-
* Improve internal handling of watch queries to avoid issues where updates are not being received due to transaction commits occurring after the query is run.
48-
* Fix issue in JVM build where `columnNames` was throwing an error due to the index of the JDBC driver starting at 1 instead of 0 as in the other drivers/
70+
* Improve internal handling of watch queries to avoid issues where updates are not being received
71+
due to transaction commits occurring after the query is run.
72+
* Fix issue in JVM build where `columnNames` was throwing an error due to the index of the JDBC
73+
driver starting at 1 instead of 0 as in the other drivers/
4974
* Throw and not just catch `CancellationExceptions` in `runWrappedSuspending`
5075

5176
## 1.0.0-BETA23
@@ -63,14 +88,18 @@
6388

6489
## 1.0.0-BETA20
6590

66-
* Add cursor optional functions: `getStringOptional`, `getLongOptional`, `getDoubleOptional`, `getBooleanOptional` and `getBytesOptional` when using the column name which allow for optional return types
91+
* Add cursor optional functions: `getStringOptional`, `getLongOptional`, `getDoubleOptional`,
92+
`getBooleanOptional` and `getBytesOptional` when using the column name which allow for optional
93+
return types
6794
* Throw errors for invalid column on all cursor functions
68-
* `getString`, `getLong`, `getBytes`, `getDouble` and `getBoolean` used with the column name will now throw an error for non-null values and expect a non optional return type
95+
* `getString`, `getLong`, `getBytes`, `getDouble` and `getBoolean` used with the column name will
96+
now throw an error for non-null values and expect a non optional return type
6997

7098
## 1.0.0-BETA19
7199

72100
* Allow cursor to get values by column name e.g. `getStringOptional("id")`
73-
* BREAKING CHANGE: If you were using `SqlCursor` from SqlDelight previously for your own custom mapper then you must now change to `SqlCursor` exported by the PowerSync module.
101+
* BREAKING CHANGE: If you were using `SqlCursor` from SqlDelight previously for your own custom
102+
mapper then you must now change to `SqlCursor` exported by the PowerSync module.
74103

75104
Previously you would import it like this:
76105

@@ -86,7 +115,8 @@
86115

87116
## 1.0.0-BETA18
88117

89-
* BREAKING CHANGE: Move from async sqldelight calls to synchronous calls. This will only affect `readTransaction` and `writeTransaction`where the callback function is no longer asynchronous.
118+
* BREAKING CHANGE: Move from async sqldelight calls to synchronous calls. This will only affect
119+
`readTransaction` and `writeTransaction`where the callback function is no longer asynchronous.
90120

91121
## 1.0.0-BETA17
92122

@@ -95,7 +125,8 @@
95125
## 1.0.0-BETA16
96126

97127
* Add `close` method to database methods
98-
* Throw when error is a `CancellationError` and remove invalidation for all errors in `streamingSync` catch.
128+
* Throw when error is a `CancellationError` and remove invalidation for all errors in
129+
`streamingSync` catch.
99130

100131
## 1.0.0-BETA15
101132

@@ -109,7 +140,8 @@
109140

110141
## 1.0.0-BETA13
111142

112-
* Move iOS database driver to use IO dispatcher which should avoid race conditions and improve performance.
143+
* Move iOS database driver to use IO dispatcher which should avoid race conditions and improve
144+
performance.
113145

114146
## 1.0.0-BETA12
115147

@@ -126,7 +158,8 @@
126158
## 1.0.0-BETA9
127159

128160
* Re-enable SKIE `SuspendInterop`
129-
* Move transaction functions out of `PowerSyncTransactionFactory` to avoid threading issues in Swift SDK
161+
* Move transaction functions out of `PowerSyncTransactionFactory` to avoid threading issues in Swift
162+
SDK
130163

131164
## 1.0.0-BETA8
132165

@@ -155,37 +188,43 @@
155188
* Add `waitForFirstSync` function - which resolves after the initial sync is completed
156189
* Upgrade to Kotlin 2.0.20 - should not cause any issues with users who are still on Kotlin 1.9
157190
* Upgrade `powersync-sqlite-core` to 0.3.0 - improves incremental sync performance
158-
* Add client sync parameters - which allows you specify sync parameters from the client https://docs.powersync.com/usage/sync-rules/advanced-topics/client-parameters-beta
191+
* Add client sync parameters - which allows you specify sync parameters from the
192+
client https://docs.powersync.com/usage/sync-rules/advanced-topics/client-parameters-beta
193+
159194
```kotlin
160195
val params = JsonParam.Map(
161-
mapOf(
162-
"name" to JsonParam.String("John Doe"),
163-
"age" to JsonParam.Number(30),
164-
"isStudent" to JsonParam.Boolean(false)
165-
)
196+
mapOf(
197+
"name" to JsonParam.String("John Doe"),
198+
"age" to JsonParam.Number(30),
199+
"isStudent" to JsonParam.Boolean(false)
200+
)
166201
)
167202

168203
connect(
169-
...
170-
params = params
204+
...
205+
params = params
171206
)
172207
```
208+
173209
* Add schema validation when schema is generated
174-
* Add warning message if there is a crudItem in the queue that has not yet been synced and after a delay rerun the upload
210+
* Add warning message if there is a crudItem in the queue that has not yet been synced and after a
211+
delay rerun the upload
175212

176213
## 1.0.0-BETA2
177214

178215
* Publish persistence package
179216

180217
## 1.0.0-BETA1
181218

182-
* Improve API by changing from Builder pattern to simply instantiating the database `PowerSyncDatabase`
219+
* Improve API by changing from Builder pattern to simply instantiating the database
220+
`PowerSyncDatabase`
183221
E.g. `val db = PowerSyncDatabase(factory, schema)`
184222
* Use callback context in transactions
185223
E.g. `db.writeTransaction{ ctx -> ctx.execute(...) }`
186224
* Removed unnecessary expiredAt field
187225
* Added table max column validation as there is a hard limit of 63 columns
188226
* Moved SQLDelight models to a separate module to reduce export size
189-
* Replaced default Logger with [Kermit Logger](https://kermit.touchlab.co/) which allows users to more easily use and/or change Logger settings
227+
* Replaced default Logger with [Kermit Logger](https://kermit.touchlab.co/) which allows users to
228+
more easily use and/or change Logger settings
190229
* Add `retryDelay` and `crudThrottle` options when setting up database connection
191230
* Changed `_viewNameOverride` to `viewNameOverride`

PowerSyncKotlin/build.gradle.kts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ kotlin {
1717
iosX64(),
1818
iosArm64(),
1919
iosSimulatorArm64(),
20+
macosArm64(),
21+
macosX64(),
2022
).forEach {
2123
it.binaries.framework {
2224
export(project(":core"))
@@ -41,6 +43,26 @@ kotlin {
4143
}
4244
}
4345

46+
repositories {
47+
maven {
48+
name = "PowerSyncSQLiterFork"
49+
url = uri("https://powersync-ja.github.io/SQLiter")
50+
content {
51+
includeModuleByRegex("co.touchlab", "sqliter-driver.*")
52+
}
53+
}
54+
}
55+
56+
configurations.all {
57+
resolutionStrategy {
58+
// This version has not been released yet (https://github.com/touchlab/SQLiter/pull/124), so we're pointing this
59+
// towards our fork with the repositories block above.
60+
// The API is identical, but we have to make sure this particular project builds the xcframework with the
61+
// patched SQLiter version to avoid linker errors on macOS.
62+
force("co.touchlab:sqliter-driver:1.3.2-powersync")
63+
}
64+
}
65+
4466
kmmbridge {
4567
artifactManager.set(SonatypePortalPublishArtifactManager(project, repositoryName = null))
4668
artifactManager.finalizeValue()

compose/build.gradle.kts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import com.powersync.plugins.sonatype.setupGithubRepository
2+
import com.powersync.plugins.utils.powersyncTargets
23

34
plugins {
45
alias(libs.plugins.kotlinMultiplatform)
@@ -10,15 +11,7 @@ plugins {
1011
}
1112

1213
kotlin {
13-
androidTarget {
14-
publishLibraryVariants("release", "debug")
15-
}
16-
17-
jvm()
18-
19-
iosX64()
20-
iosArm64()
21-
iosSimulatorArm64()
14+
powersyncTargets(includeTargetsWithoutComposeSupport = false)
2215

2316
explicitApi()
2417

connectors/supabase/build.gradle.kts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import com.powersync.plugins.sonatype.setupGithubRepository
2+
import com.powersync.plugins.utils.powersyncTargets
23
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
34

45
plugins {
@@ -10,12 +11,7 @@ plugins {
1011
}
1112

1213
kotlin {
13-
androidTarget {
14-
publishLibraryVariants("release", "debug")
15-
}
16-
17-
jvm()
18-
14+
powersyncTargets()
1915
targets.withType<KotlinNativeTarget> {
2016
compilations.named("main") {
2117
compileTaskProvider {
@@ -24,10 +20,6 @@ kotlin {
2420
}
2521
}
2622

27-
iosX64()
28-
iosArm64()
29-
iosSimulatorArm64()
30-
3123
explicitApi()
3224

3325
sourceSets {
@@ -36,6 +28,7 @@ kotlin {
3628
implementation(libs.kotlinx.coroutines.core)
3729
implementation(libs.supabase.client)
3830
api(libs.supabase.auth)
31+
api(libs.supabase.storage)
3932
}
4033
}
4134
}

connectors/supabase/src/commonMain/kotlin/com/powersync/connector/supabase/SupabaseConnector.kt

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ import io.github.jan.supabase.auth.user.UserSession
1717
import io.github.jan.supabase.createSupabaseClient
1818
import io.github.jan.supabase.postgrest.Postgrest
1919
import io.github.jan.supabase.postgrest.from
20+
import io.github.jan.supabase.storage.BucketApi
21+
import io.github.jan.supabase.storage.Storage
22+
import io.github.jan.supabase.storage.storage
2023
import io.ktor.client.plugins.HttpSend
2124
import io.ktor.client.plugins.plugin
2225
import io.ktor.client.statement.bodyAsText
@@ -31,6 +34,7 @@ import kotlinx.serialization.json.Json
3134
public class SupabaseConnector(
3235
public val supabaseClient: SupabaseClient,
3336
public val powerSyncEndpoint: String,
37+
private val storageBucket: String? = null,
3438
) : PowerSyncBackendConnector() {
3539
private var errorCode: String? = null
3640

@@ -52,17 +56,29 @@ public class SupabaseConnector(
5256
}
5357
}
5458

59+
public fun storageBucket(): BucketApi {
60+
if (storageBucket == null) {
61+
throw Exception("No bucket has been specified")
62+
}
63+
return supabaseClient.storage[storageBucket]
64+
}
65+
5566
public constructor(
5667
supabaseUrl: String,
5768
supabaseKey: String,
5869
powerSyncEndpoint: String,
70+
storageBucket: String? = null,
5971
) : this(
6072
supabaseClient =
6173
createSupabaseClient(supabaseUrl, supabaseKey) {
6274
install(Auth)
6375
install(Postgrest)
76+
if (storageBucket != null) {
77+
install(Storage)
78+
}
6479
},
6580
powerSyncEndpoint = powerSyncEndpoint,
81+
storageBucket = storageBucket,
6682
)
6783

6884
init {
@@ -81,7 +97,10 @@ public class SupabaseConnector(
8197
val responseText = response.bodyAsText()
8298

8399
try {
84-
val error = Json { coerceInputValues = true }.decodeFromString<Map<String, String?>>(responseText)
100+
val error =
101+
Json { coerceInputValues = true }.decodeFromString<Map<String, String?>>(
102+
responseText,
103+
)
85104
errorCode = error["code"]
86105
} catch (e: Exception) {
87106
Logger.e("Failed to parse error response: $e")
@@ -139,7 +158,9 @@ public class SupabaseConnector(
139158
check(supabaseClient.auth.sessionStatus.value is SessionStatus.Authenticated) { "Supabase client is not authenticated" }
140159

141160
// Use Supabase token for PowerSync
142-
val session = supabaseClient.auth.currentSessionOrNull() ?: error("Could not fetch Supabase credentials")
161+
val session =
162+
supabaseClient.auth.currentSessionOrNull()
163+
?: error("Could not fetch Supabase credentials")
143164

144165
check(session.user != null) { "No user data" }
145166

0 commit comments

Comments
 (0)